[PATCH v4,06/11] media: mediatek: vcodec: replace pr_* with dev_* for v4l2 debug message

Yunfei Dong (董云飞) Yunfei.Dong at mediatek.com
Tue Jul 4 04:08:58 PDT 2023


Hi Nicolas,

Thanks for your suggestion.

On Mon, 2023-07-03 at 15:46 -0400, Nicolas Dufresne wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  Le lundi 26 juin 2023 à 11:53 +0800, Yunfei Dong a écrit :
> > Adding different macro mtk_v4l2_vdec_dbg and mtk_v4l2_venc_dbg for
> > encoder and decoder. Then calling the common marco mtk_v4l2_debug
> to
> > print debug message.
> > 
> > Replace pr_err with dev_err for 'mtk_v4l2_err' debug message.
> > Replace pr_debug with dev_dbg for 'mtk_v4l2_debug' debug message.
> > 
> > Signed-off-by: Yunfei Dong <yunfei.dong at mediatek.com>
> > ---
> >  .../platform/mediatek/vcodec/mtk_vcodec_dec.c | 116 +++++-----
> >  .../mediatek/vcodec/mtk_vcodec_dec_drv.c      |  53 ++---
> >  .../mediatek/vcodec/mtk_vcodec_dec_hw.c       |   7 +-
> >  .../mediatek/vcodec/mtk_vcodec_dec_pm.c       |  19 +-
> >  .../mediatek/vcodec/mtk_vcodec_dec_stateful.c | 143 ++++++------
> >  .../vcodec/mtk_vcodec_dec_stateless.c         |  62 ++---
> >  .../platform/mediatek/vcodec/mtk_vcodec_enc.c | 211 ++++++++----
> ------
> >  .../mediatek/vcodec/mtk_vcodec_enc_drv.c      |  45 ++--
> >  .../mediatek/vcodec/mtk_vcodec_enc_pm.c       |   8 +-
> >  .../platform/mediatek/vcodec/mtk_vcodec_fw.c  |   2 +-
> >  .../mediatek/vcodec/mtk_vcodec_fw_scp.c       |   2 +-
> >  .../mediatek/vcodec/mtk_vcodec_fw_vpu.c       |   7 +-
> >  .../mediatek/vcodec/mtk_vcodec_intr.c         |  12 +-
> >  .../mediatek/vcodec/mtk_vcodec_util.c         |  30 ++-
> >  .../mediatek/vcodec/mtk_vcodec_util.h         |  24 +-
> >  .../vcodec/vdec/vdec_av1_req_lat_if.c         |  10 +-
> >  .../mediatek/vcodec/vdec/vdec_h264_req_if.c   |  14 +-
> >  .../vcodec/vdec/vdec_h264_req_multi_if.c      |  16 +-
> >  .../vcodec/vdec/vdec_hevc_req_multi_if.c      |  14 +-
> >  .../platform/mediatek/vcodec/vdec_drv_if.c    |   4 +-
> >  .../platform/mediatek/vcodec/vdec_msg_queue.c |  52 +++--
> >  .../platform/mediatek/vcodec/vdec_msg_queue.h |   2 +
> >  .../platform/mediatek/vcodec/vdec_vpu_if.c    |   2 +-
> >  23 files changed, 413 insertions(+), 442 deletions(-)
> > 
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> > index 93fcea821001..269f90fe0a1a 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> > @@ -82,7 +82,7 @@ static int vidioc_decoder_cmd(struct file *file,
> void *priv,
> >  if (ret)
> >  return ret;
> >  
> > -mtk_v4l2_debug(1, "decoder cmd=%u", cmd->cmd);
> > +mtk_v4l2_vdec_dbg(1, ctx, "decoder cmd=%u", cmd->cmd);
> >  dst_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
> >  V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
> >  switch (cmd->cmd) {
> > @@ -90,11 +90,11 @@ static int vidioc_decoder_cmd(struct file
> *file, void *priv,
> >  src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
> >  V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
> >  if (!vb2_is_streaming(src_vq)) {
> > -mtk_v4l2_debug(1, "Output stream is off. No need to flush.");
> > +mtk_v4l2_vdec_dbg(1, ctx, "Output stream is off. No need to
> flush.");
> >  return 0;
> >  }
> >  if (!vb2_is_streaming(dst_vq)) {
> > -mtk_v4l2_debug(1, "Capture stream is off. No need to flush.");
> > +mtk_v4l2_vdec_dbg(1, ctx, "Capture stream is off. No need to
> flush.");
> >  return 0;
> >  }
> >  v4l2_m2m_buf_queue(ctx->m2m_ctx, &ctx->empty_flush_buf.vb);
> > @@ -172,8 +172,7 @@ static int vidioc_vdec_qbuf(struct file *file,
> void *priv,
> >  struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> >  
> >  if (ctx->state == MTK_STATE_ABORT) {
> > -mtk_v4l2_err("[%d] Call on QBUF after unrecoverable error",
> > -ctx->id);
> > +mtk_v4l2_vdec_err(ctx, "[%d] Call on QBUF after unrecoverable
> error", ctx->id);
> >  return -EIO;
> >  }
> >  
> > @@ -186,8 +185,7 @@ static int vidioc_vdec_dqbuf(struct file *file,
> void *priv,
> >  struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
> >  
> >  if (ctx->state == MTK_STATE_ABORT) {
> > -mtk_v4l2_err("[%d] Call on DQBUF after unrecoverable error",
> > -ctx->id);
> > +mtk_v4l2_vdec_err(ctx, "[%d] Call on DQBUF after unrecoverable
> error", ctx->id);
> >  return -EIO;
> >  }
> >  
> > @@ -288,11 +286,10 @@ static int vidioc_try_fmt(struct
> mtk_vcodec_ctx *ctx, struct v4l2_format *f,
> >      (pix_fmt_mp->height + 64) <= frmsize->max_height)
> >  pix_fmt_mp->height += 64;
> >  
> > -mtk_v4l2_debug(0,
> > -"before resize width=%d, height=%d, after resize width=%d,
> height=%d, sizeimage=%d",
> > -tmp_w, tmp_h, pix_fmt_mp->width,
> > -pix_fmt_mp->height,
> > -pix_fmt_mp->width * pix_fmt_mp->height);
> > +mtk_v4l2_vdec_dbg(0, ctx,
> > +  "before resize wxh=%dx%d, after resize wxh=%dx%d, sizeimage=%d",
> > +  tmp_w, tmp_h, pix_fmt_mp->width, pix_fmt_mp->height,
> > +  pix_fmt_mp->width * pix_fmt_mp->height);
> >  
> >  pix_fmt_mp->num_planes = fmt->num_planes;
> >  pix_fmt_mp->plane_fmt[0].sizeimage =
> > @@ -344,7 +341,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct
> file *file, void *priv,
> >  }
> >  
> >  if (pix_fmt_mp->plane_fmt[0].sizeimage == 0) {
> > -mtk_v4l2_err("sizeimage of output format must be given");
> > +mtk_v4l2_vdec_err(ctx, "sizeimage of output format must be
> given");
> >  return -EINVAL;
> >  }
> >  
> > @@ -432,7 +429,7 @@ static int vidioc_vdec_s_fmt(struct file *file,
> void *priv,
> >  const struct mtk_video_fmt *fmt;
> >  const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev-
> >vdec_pdata;
> >  
> > -mtk_v4l2_debug(3, "[%d]", ctx->id);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d]", ctx->id);
> >  
> >  q_data = mtk_vdec_get_q_data(ctx, f->type);
> >  if (!q_data)
> > @@ -446,7 +443,7 @@ static int vidioc_vdec_s_fmt(struct file *file,
> void *priv,
> >  if (!dec_pdata->uses_stateless_api &&
> >      f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
> >      vb2_is_busy(&ctx->m2m_ctx->out_q_ctx.q)) {
> > -mtk_v4l2_err("out_q_ctx buffers already requested");
> > +mtk_v4l2_vdec_err(ctx, "out_q_ctx buffers already requested");
> >  ret = -EBUSY;
> >  }
> >  
> > @@ -456,7 +453,7 @@ static int vidioc_vdec_s_fmt(struct file *file,
> void *priv,
> >   */
> >  if ((f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
> >      vb2_is_busy(&ctx->m2m_ctx->cap_q_ctx.q)) {
> > -mtk_v4l2_err("cap_q_ctx buffers already requested");
> > +mtk_v4l2_vdec_err(ctx, "cap_q_ctx buffers already requested");
> >  ret = -EBUSY;
> >  }
> >  
> > @@ -491,8 +488,8 @@ static int vidioc_vdec_s_fmt(struct file *file,
> void *priv,
> >  if (ctx->state == MTK_STATE_FREE) {
> >  ret = vdec_if_init(ctx, q_data->fmt->fourcc);
> >  if (ret) {
> > -mtk_v4l2_err("[%d]: vdec_if_init() fail ret=%d",
> > -ctx->id, ret);
> > +mtk_v4l2_vdec_err(ctx, "[%d]: vdec_if_init() fail ret=%d",
> > +  ctx->id, ret);
> >  return -EINVAL;
> >  }
> >  ctx->state = MTK_STATE_INIT;
> > @@ -515,8 +512,8 @@ static int vidioc_vdec_s_fmt(struct file *file,
> void *priv,
> >   */
> >  ret = vdec_if_get_param(ctx, GET_PARAM_PIC_INFO, &ctx->picinfo);
> >  if (ret) {
> > -mtk_v4l2_err("[%d]Error!! Get GET_PARAM_PICTURE_INFO Fail",
> > -     ctx->id);
> > +mtk_v4l2_vdec_err(ctx, "[%d]Error!! Get GET_PARAM_PICTURE_INFO
> Fail",
> > +  ctx->id);
> >  }
> >  
> >  ctx->last_decoded_picinfo = ctx->picinfo;
> > @@ -540,11 +537,13 @@ static int vidioc_vdec_s_fmt(struct file
> *file, void *priv,
> >  
> >  ctx->q_data[MTK_Q_DATA_DST].coded_width = ctx->picinfo.buf_w;
> >  ctx->q_data[MTK_Q_DATA_DST].coded_height = ctx->picinfo.buf_h;
> > -mtk_v4l2_debug(2, "[%d] vdec_if_init() num_plane = %d wxh=%dx%d
> pic wxh=%dx%d sz[0]=0x%x sz[1]=0x%x",
> > -       ctx->id, pix_mp->num_planes, ctx->picinfo.buf_w, ctx-
> >picinfo.buf_h,
> > -       ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> > -       ctx->q_data[MTK_Q_DATA_DST].sizeimage[0],
> > -       ctx->q_data[MTK_Q_DATA_DST].sizeimage[1]);
> > +mtk_v4l2_vdec_dbg(2, ctx,
> > +  "[%d] init() plane:%d wxh=%dx%d pic wxh=%dx%d sz=0x%x_0x%x",
> > +  ctx->id, pix_mp->num_planes,
> > +  ctx->picinfo.buf_w, ctx->picinfo.buf_h,
> > +  ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> > +  ctx->q_data[MTK_Q_DATA_DST].sizeimage[0],
> > +  ctx->q_data[MTK_Q_DATA_DST].sizeimage[1]);
> >  }
> >  return 0;
> >  }
> > @@ -570,14 +569,11 @@ static int vidioc_enum_framesizes(struct file
> *file, void *priv,
> >  fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
> >  fsize->stepwise = dec_pdata->vdec_formats[i].frmsize;
> >  
> > -mtk_v4l2_debug(1, "%x, %d %d %d %d %d %d",
> > -ctx->dev->dec_capability,
> > -fsize->stepwise.min_width,
> > -fsize->stepwise.max_width,
> > -fsize->stepwise.step_width,
> > -fsize->stepwise.min_height,
> > -fsize->stepwise.max_height,
> > -fsize->stepwise.step_height);
> > +mtk_v4l2_vdec_dbg(1, ctx, "%x, %d %d %d %d %d %d",
> > +  ctx->dev->dec_capability, fsize->stepwise.min_width,
> > +  fsize->stepwise.max_width, fsize->stepwise.step_width,
> > +  fsize->stepwise.min_height, fsize->stepwise.max_height,
> > +  fsize->stepwise.step_height);
> >  
> >  return 0;
> >  }
> > @@ -641,7 +637,7 @@ static int vidioc_vdec_g_fmt(struct file *file,
> void *priv,
> >  
> >  vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
> >  if (!vq) {
> > -mtk_v4l2_err("no vb2 queue for type=%d", f->type);
> > +mtk_v4l2_vdec_err(ctx, "no vb2 queue for type=%d", f->type);
> >  return -EINVAL;
> >  }
> >  
> > @@ -712,8 +708,8 @@ static int vidioc_vdec_g_fmt(struct file *file,
> void *priv,
> >  pix_mp->plane_fmt[1].bytesperline = q_data->bytesperline[1];
> >  pix_mp->plane_fmt[1].sizeimage = q_data->sizeimage[1];
> >  
> > -mtk_v4l2_debug(1, "[%d] type=%d state=%d Format information could
> not be read, not ready yet!",
> > -ctx->id, f->type, ctx->state);
> > +mtk_v4l2_vdec_dbg(1, ctx, "[%d] type=%d state=%d Format
> information not ready!",
> > +  ctx->id, f->type, ctx->state);
> >  }
> >  
> >  return 0;
> > @@ -730,7 +726,7 @@ int vb2ops_vdec_queue_setup(struct vb2_queue
> *vq, unsigned int *nbuffers,
> >  q_data = mtk_vdec_get_q_data(ctx, vq->type);
> >  
> >  if (q_data == NULL) {
> > -mtk_v4l2_err("vq->type=%d err\n", vq->type);
> > +mtk_v4l2_vdec_err(ctx, "vq->type=%d err\n", vq->type);
> >  return -EINVAL;
> >  }
> >  
> > @@ -756,10 +752,9 @@ int vb2ops_vdec_queue_setup(struct vb2_queue
> *vq, unsigned int *nbuffers,
> >  sizes[i] = q_data->sizeimage[i];
> >  }
> >  
> > -mtk_v4l2_debug(1,
> > -"[%d]\t type = %d, get %d plane(s), %d buffer(s) of size 0x%x 0x%x
> ",
> > -ctx->id, vq->type, *nplanes, *nbuffers,
> > -sizes[0], sizes[1]);
> > +mtk_v4l2_vdec_dbg(1, ctx,
> > +  "[%d]\t type = %d, get %d plane(s), %d buffer(s) of size 0x%x
> 0x%x ",
> > +  ctx->id, vq->type, *nplanes, *nbuffers, sizes[0], sizes[1]);
> >  
> >  return 0;
> >  }
> > @@ -770,16 +765,15 @@ int vb2ops_vdec_buf_prepare(struct vb2_buffer
> *vb)
> >  struct mtk_q_data *q_data;
> >  int i;
> >  
> > -mtk_v4l2_debug(3, "[%d] (%d) id=%d",
> > -ctx->id, vb->vb2_queue->type, vb->index);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) id=%d",
> > +  ctx->id, vb->vb2_queue->type, vb->index);
> >  
> >  q_data = mtk_vdec_get_q_data(ctx, vb->vb2_queue->type);
> >  
> >  for (i = 0; i < q_data->fmt->num_planes; i++) {
> >  if (vb2_plane_size(vb, i) < q_data->sizeimage[i]) {
> > -mtk_v4l2_err("data will not fit into plane %d (%lu < %d)",
> > -i, vb2_plane_size(vb, i),
> > -q_data->sizeimage[i]);
> > +mtk_v4l2_vdec_err(ctx, "data will not fit into plane %d (%lu <
> %d)",
> > +  i, vb2_plane_size(vb, i), q_data->sizeimage[i]);
> >  return -EINVAL;
> >  }
> >  if (!V4L2_TYPE_IS_OUTPUT(vb->type))
> > @@ -807,7 +801,7 @@ void vb2ops_vdec_buf_finish(struct vb2_buffer
> *vb)
> >  mutex_unlock(&ctx->lock);
> >  
> >  if (buf_error) {
> > -mtk_v4l2_err("Unrecoverable error on buffer.");
> > +mtk_v4l2_vdec_err(ctx, "Unrecoverable error on buffer.");
> >  ctx->state = MTK_STATE_ABORT;
> >  }
> >  }
> > @@ -843,8 +837,8 @@ void vb2ops_vdec_stop_streaming(struct
> vb2_queue *q)
> >  struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(q);
> >  int ret;
> >  
> > -mtk_v4l2_debug(3, "[%d] (%d) state=(%x) ctx-
> >decoded_frame_cnt=%d",
> > -ctx->id, q->type, ctx->state, ctx->decoded_frame_cnt);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) state=(%x) ctx-
> >decoded_frame_cnt=%d",
> > +  ctx->id, q->type, ctx->state, ctx->decoded_frame_cnt);
> >  
> >  if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
> >  while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx))) {
> > @@ -870,17 +864,17 @@ void vb2ops_vdec_stop_streaming(struct
> vb2_queue *q)
> >   */
> >  ctx->picinfo = ctx->last_decoded_picinfo;
> >  
> > -mtk_v4l2_debug(2,
> > -"[%d]-> new(%d,%d), old(%d,%d), real(%d,%d)",
> > -ctx->id, ctx->last_decoded_picinfo.pic_w,
> > -ctx->last_decoded_picinfo.pic_h,
> > -ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> > -ctx->last_decoded_picinfo.buf_w,
> > -ctx->last_decoded_picinfo.buf_h);
> > +mtk_v4l2_vdec_dbg(2, ctx,
> > +  "[%d]-> new(%d,%d), old(%d,%d), real(%d,%d)",
> > +  ctx->id, ctx->last_decoded_picinfo.pic_w,
> > +  ctx->last_decoded_picinfo.pic_h,
> > +  ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> > +  ctx->last_decoded_picinfo.buf_w,
> > +  ctx->last_decoded_picinfo.buf_h);
> >  
> >  ret = ctx->dev->vdec_pdata->flush_decoder(ctx);
> >  if (ret)
> > -mtk_v4l2_err("DecodeFinal failed, ret=%d", ret);
> > +mtk_v4l2_vdec_err(ctx, "DecodeFinal failed, ret=%d", ret);
> >  }
> >  ctx->state = MTK_STATE_FLUSH;
> >  
> > @@ -905,7 +899,7 @@ static int m2mops_vdec_job_ready(void
> *m2m_priv)
> >  {
> >  struct mtk_vcodec_ctx *ctx = m2m_priv;
> >  
> > -mtk_v4l2_debug(3, "[%d]", ctx->id);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d]", ctx->id);
> >  
> >  if (ctx->state == MTK_STATE_ABORT)
> >  return 0;
> > @@ -973,7 +967,7 @@ int mtk_vcodec_dec_queue_init(void *priv,
> struct vb2_queue *src_vq,
> >  struct mtk_vcodec_ctx *ctx = priv;
> >  int ret = 0;
> >  
> > -mtk_v4l2_debug(3, "[%d]", ctx->id);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d]", ctx->id);
> >  
> >  src_vq->type= V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
> >  src_vq->io_modes= VB2_DMABUF | VB2_MMAP;
> > @@ -988,7 +982,7 @@ int mtk_vcodec_dec_queue_init(void *priv,
> struct vb2_queue *src_vq,
> >  
> >  ret = vb2_queue_init(src_vq);
> >  if (ret) {
> > -mtk_v4l2_err("Failed to initialize videobuf2 queue(output)");
> > +mtk_v4l2_vdec_err(ctx, "Failed to initialize videobuf2
> queue(output)");
> >  return ret;
> >  }
> >  dst_vq->type= V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
> > @@ -1004,7 +998,7 @@ int mtk_vcodec_dec_queue_init(void *priv,
> struct vb2_queue *src_vq,
> >  
> >  ret = vb2_queue_init(dst_vq);
> >  if (ret)
> > -mtk_v4l2_err("Failed to initialize videobuf2 queue(capture)");
> > +mtk_v4l2_vdec_err(ctx, "Failed to initialize videobuf2
> queue(capture)");
> >  
> >  return ret;
> >  }
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
> > index 03721eda2769..4469c2411f40 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
> > @@ -25,7 +25,7 @@
> >  #include "mtk_vcodec_util.h"
> >  #include "mtk_vcodec_fw.h"
> >  
> > -static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dev *dev)
> > +static int mtk_vcodec_get_hw_count(struct mtk_vcodec_ctx *ctx,
> struct mtk_vcodec_dev *dev)
> >  {
> >  switch (dev->vdec_pdata->hw_arch) {
> >  case MTK_VDEC_PURE_SINGLE_CORE:
> > @@ -33,7 +33,7 @@ static int mtk_vcodec_get_hw_count(struct
> mtk_vcodec_dev *dev)
> >  case MTK_VDEC_LAT_SINGLE_CORE:
> >  return MTK_VDEC_ONE_LAT_ONE_CORE;
> >  default:
> > -mtk_v4l2_err("hw arch %d not supported", dev->vdec_pdata-
> >hw_arch);
> > +mtk_v4l2_vdec_err(ctx, "hw arch %d not supported", dev-
> >vdec_pdata->hw_arch);
> >  return MTK_VDEC_NO_HW;
> >  }
> >  }
> > @@ -52,8 +52,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int
> irq, void *priv)
> >  /* check if HW active or not */
> >  cg_status = readl(dev->reg_base[0]);
> >  if ((cg_status & VDEC_HW_ACTIVE) != 0) {
> > -mtk_v4l2_err("DEC ISR, VDEC active is not 0x0 (0x%08x)",
> > -     cg_status);
> > +mtk_v4l2_vdec_err(ctx, "DEC ISR, VDEC active is not 0x0 (0x%08x)",
> cg_status);
> >  return IRQ_HANDLED;
> >  }
> >  
> > @@ -71,9 +70,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int
> irq, void *priv)
> >  
> >  wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, 0);
> >  
> > -mtk_v4l2_debug(3,
> > -"mtk_vcodec_dec_irq_handler :wake up ctx %d, dec_done_status=%x",
> > -ctx->id, dec_done_status);
> > +mtk_v4l2_vdec_dbg(3, ctx, "wake up ctx %d, dec_done_status=%x",
> ctx->id, dec_done_status);
> >  
> >  return IRQ_HANDLED;
> >  }
> > @@ -96,7 +93,7 @@ static int mtk_vcodec_get_reg_bases(struct
> mtk_vcodec_dev *dev)
> >  if (IS_ERR(dev->reg_base[i]))
> >  return PTR_ERR(dev->reg_base[i]);
> >  
> > -mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);
> > +dev_dbg(&pdev->dev, "reg[%d] base=%p", i, dev->reg_base[i]);
> >  }
> >  
> >  return 0;
> > @@ -156,7 +153,7 @@ static int fops_vcodec_open(struct file *file)
> >  INIT_LIST_HEAD(&ctx->list);
> >  ctx->dev = dev;
> >  if (ctx->dev->vdec_pdata->is_subdev_supported) {
> > -hw_count = mtk_vcodec_get_hw_count(dev);
> > +hw_count = mtk_vcodec_get_hw_count(ctx, dev);
> >  if (!hw_count || !dev->subdev_prob_done) {
> >  ret = -EINVAL;
> >  goto err_ctrls_setup;
> > @@ -176,15 +173,14 @@ static int fops_vcodec_open(struct file
> *file)
> >  ctx->type = MTK_INST_DECODER;
> >  ret = dev->vdec_pdata->ctrls_setup(ctx);
> >  if (ret) {
> > -mtk_v4l2_err("Failed to setup mt vcodec controls");
> > +mtk_v4l2_vdec_err(ctx, "Failed to setup mt vcodec controls");
> >  goto err_ctrls_setup;
> >  }
> >  ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_dec, ctx,
> >  &mtk_vcodec_dec_queue_init);
> >  if (IS_ERR((__force void *)ctx->m2m_ctx)) {
> >  ret = PTR_ERR((__force void *)ctx->m2m_ctx);
> > -mtk_v4l2_err("Failed to v4l2_m2m_ctx_init() (%d)",
> > -ret);
> > +mtk_v4l2_vdec_err(ctx, "Failed to v4l2_m2m_ctx_init() (%d)", ret);
> >  goto err_m2m_ctx_init;
> >  }
> >  src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
> > @@ -202,14 +198,14 @@ static int fops_vcodec_open(struct file
> *file)
> >   * Return 0 if downloading firmware successfully,
> >   * otherwise it is failed
> >   */
> > -mtk_v4l2_err("failed to load firmware!");
> > +mtk_v4l2_vdec_err(ctx, "failed to load firmware!");
> >  goto err_load_fw;
> >  }
> >  
> >  dev->dec_capability =
> >  mtk_vcodec_fw_get_vdec_capa(dev->fw_handler);
> >  
> > -mtk_v4l2_debug(0, "decoder capability %x", dev->dec_capability);
> > +mtk_v4l2_vdec_dbg(0, ctx, "decoder capability %x", dev-
> >dec_capability);
> >  }
> >  
> >  ctx->dev->vdec_pdata->init_vdec_params(ctx);
> > @@ -218,8 +214,7 @@ static int fops_vcodec_open(struct file *file)
> >  mtk_vcodec_dbgfs_create(ctx);
> >  
> >  mutex_unlock(&dev->dev_mutex);
> > -mtk_v4l2_debug(0, "%s decoder [%d]", dev_name(&dev->plat_dev-
> >dev),
> > -ctx->id);
> > +mtk_v4l2_vdec_dbg(0, ctx, "%s decoder [%d]", dev_name(&dev-
> >plat_dev->dev), ctx->id);
> >  return ret;
> >  
> >  /* Deinit when failure occurred */
> > @@ -241,7 +236,7 @@ static int fops_vcodec_release(struct file
> *file)
> >  struct mtk_vcodec_dev *dev = video_drvdata(file);
> >  struct mtk_vcodec_ctx *ctx = fh_to_ctx(file->private_data);
> >  
> > -mtk_v4l2_debug(0, "[%d] decoder", ctx->id);
> > +mtk_v4l2_vdec_dbg(0, ctx, "[%d] decoder", ctx->id);
> >  mutex_lock(&dev->dev_mutex);
> >  
> >  /*
> > @@ -296,7 +291,7 @@ static int mtk_vcodec_probe(struct
> platform_device *pdev)
> >   &rproc_phandle)) {
> >  fw_type = SCP;
> >  } else {
> > -mtk_v4l2_err("Could not get vdec IPI device");
> > +dev_dbg(&pdev->dev, "Could not get vdec IPI device");
> >  return -ENODEV;
> >  }
> >  dma_set_max_seg_size(&pdev->dev, UINT_MAX);
> > @@ -316,7 +311,7 @@ static int mtk_vcodec_probe(struct
> platform_device *pdev)
> >  alloc_ordered_workqueue("core-decoder",
> >  WQ_MEM_RECLAIM | WQ_FREEZABLE);
> >  if (!dev->core_workqueue) {
> > -mtk_v4l2_err("Failed to create core workqueue");
> > +dev_dbg(&pdev->dev, "Failed to create core workqueue");
> >  ret = -EINVAL;
> >  goto err_res;
> >  }
> > @@ -332,13 +327,13 @@ static int mtk_vcodec_probe(struct
> platform_device *pdev)
> >  
> >  ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
> >  if (ret) {
> > -mtk_v4l2_err("v4l2_device_register err=%d", ret);
> > +dev_err(&pdev->dev, "v4l2_device_register err=%d", ret);
> >  goto err_core_workq;
> >  }
> >  
> >  vfd_dec = video_device_alloc();
> >  if (!vfd_dec) {
> > -mtk_v4l2_err("Failed to allocate video device");
> > +dev_err(&pdev->dev, "Failed to allocate video device");
> >  ret = -ENOMEM;
> >  goto err_dec_alloc;
> >  }
> > @@ -359,7 +354,7 @@ static int mtk_vcodec_probe(struct
> platform_device *pdev)
> >  
> >  dev->m2m_dev_dec = v4l2_m2m_init(&mtk_vdec_m2m_ops);
> >  if (IS_ERR((__force void *)dev->m2m_dev_dec)) {
> > -mtk_v4l2_err("Failed to init mem2mem dec device");
> > +dev_err(&pdev->dev, "Failed to init mem2mem dec device");
> >  ret = PTR_ERR((__force void *)dev->m2m_dev_dec);
> >  goto err_dec_alloc;
> >  }
> > @@ -368,7 +363,7 @@ static int mtk_vcodec_probe(struct
> platform_device *pdev)
> >  alloc_ordered_workqueue(MTK_VCODEC_DEC_NAME,
> >  WQ_MEM_RECLAIM | WQ_FREEZABLE);
> >  if (!dev->decode_workqueue) {
> > -mtk_v4l2_err("Failed to create decode workqueue");
> > +dev_err(&pdev->dev, "Failed to create decode workqueue");
> >  ret = -EINVAL;
> >  goto err_event_workq;
> >  }
> > @@ -377,7 +372,7 @@ static int mtk_vcodec_probe(struct
> platform_device *pdev)
> >  ret = of_platform_populate(pdev->dev.of_node, NULL, NULL,
> >     &pdev->dev);
> >  if (ret) {
> > -mtk_v4l2_err("Main device of_platform_populate failed.");
> > +dev_err(&pdev->dev, "Main device of_platform_populate failed.");
> >  goto err_reg_cont;
> >  }
> >  } else {
> > @@ -390,7 +385,7 @@ static int mtk_vcodec_probe(struct
> platform_device *pdev)
> >  
> >  ret = video_register_device(vfd_dec, VFL_TYPE_VIDEO, -1);
> >  if (ret) {
> > -mtk_v4l2_err("Failed to register video device");
> > +dev_err(&pdev->dev, "Failed to register video device");
> >  goto err_reg_cont;
> >  }
> >  
> > @@ -409,21 +404,21 @@ static int mtk_vcodec_probe(struct
> platform_device *pdev)
> >  ret = v4l2_m2m_register_media_controller(dev->m2m_dev_dec, dev-
> >vfd_dec,
> >   MEDIA_ENT_F_PROC_VIDEO_DECODER);
> >  if (ret) {
> > -mtk_v4l2_err("Failed to register media controller");
> > +dev_err(&pdev->dev, "Failed to register media controller");
> >  goto err_dec_mem_init;
> >  }
> >  
> >  ret = media_device_register(&dev->mdev_dec);
> >  if (ret) {
> > -mtk_v4l2_err("Failed to register media device");
> > +dev_err(&pdev->dev, "Failed to register media device");
> >  goto err_media_reg;
> >  }
> >  
> > -mtk_v4l2_debug(0, "media registered as /dev/media%d", vfd_dec-
> >minor);
> > +dev_dbg(&pdev->dev, "media registered as /dev/media%d", vfd_dec-
> >minor);
> >  }
> >  
> >  mtk_vcodec_dbgfs_init(dev, false);
> > -mtk_v4l2_debug(0, "decoder registered as /dev/video%d", vfd_dec-
> >minor);
> > +dev_dbg(&pdev->dev, "decoder registered as /dev/video%d", vfd_dec-
> >minor);
> >  
> >  return 0;
> >  
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c
> > index e1cb2f8dca33..7c4d8ec201e3 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c
> > @@ -77,8 +77,7 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int
> irq, void *priv)
> >  /* check if HW active or not */
> >  cg_status = readl(dev->reg_base[VDEC_HW_SYS]);
> >  if (cg_status & VDEC_HW_ACTIVE) {
> > -mtk_v4l2_err("vdec active is not 0x0 (0x%08x)",
> > -     cg_status);
> > +mtk_v4l2_vdec_err(ctx, "vdec active is not 0x0 (0x%08x)",
> cg_status);
> >  return IRQ_HANDLED;
> >  }
> >  
> > @@ -93,8 +92,8 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int
> irq, void *priv)
> >  
> >  wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, dev->hw_idx);
> >  
> > -mtk_v4l2_debug(3, "wake up ctx %d, dec_done_status=%x",
> > -       ctx->id, dec_done_status);
> > +mtk_v4l2_vdec_dbg(3, ctx, "wake up ctx %d, dec_done_status=%x",
> > +  ctx->id, dec_done_status);
> >  
> >  return IRQ_HANDLED;
> >  }
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c
> > index 777d445999e9..3ab996705b97 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c
> > @@ -32,7 +32,7 @@ int mtk_vcodec_init_dec_clk(struct
> platform_device *pdev, struct mtk_vcodec_pm *
> >  if (!dec_clk->clk_info)
> >  return -ENOMEM;
> >  } else {
> > -mtk_v4l2_err("Failed to get vdec clock count");
> > +dev_err(&pdev->dev, "Failed to get vdec clock count");
> >  return -EINVAL;
> >  }
> >  
> > @@ -41,14 +41,13 @@ int mtk_vcodec_init_dec_clk(struct
> platform_device *pdev, struct mtk_vcodec_pm *
> >  ret = of_property_read_string_index(pdev->dev.of_node,
> >  "clock-names", i, &clk_info->clk_name);
> >  if (ret) {
> > -mtk_v4l2_err("Failed to get clock name id = %d", i);
> > +dev_err(&pdev->dev, "Failed to get clock name id = %d", i);
> >  return ret;
> >  }
> >  clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
> >  clk_info->clk_name);
> >  if (IS_ERR(clk_info->vcodec_clk)) {
> > -mtk_v4l2_err("devm_clk_get (%d)%s fail", i,
> > -clk_info->clk_name);
> > +dev_err(&pdev->dev, "devm_clk_get (%d)%s fail", i, clk_info-
> >clk_name);
> >  return PTR_ERR(clk_info->vcodec_clk);
> >  }
> >  }
> > @@ -63,7 +62,7 @@ static int mtk_vcodec_dec_pw_on(struct
> mtk_vcodec_pm *pm)
> >  
> >  ret = pm_runtime_resume_and_get(pm->dev);
> >  if (ret)
> > -mtk_v4l2_err("pm_runtime_resume_and_get fail %d", ret);
> > +dev_err(pm->dev, "pm_runtime_resume_and_get fail %d", ret);
> >  
> >  return ret;
> >  }
> > @@ -74,7 +73,7 @@ static void mtk_vcodec_dec_pw_off(struct
> mtk_vcodec_pm *pm)
> >  
> >  ret = pm_runtime_put(pm->dev);
> >  if (ret && ret != -EAGAIN)
> > -mtk_v4l2_err("pm_runtime_put fail %d", ret);
> > +dev_err(pm->dev, "pm_runtime_put fail %d", ret);
> >  }
> >  
> >  static void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
> > @@ -86,7 +85,7 @@ static void mtk_vcodec_dec_clock_on(struct
> mtk_vcodec_pm *pm)
> >  for (i = 0; i < dec_clk->clk_num; i++) {
> >  ret = clk_prepare_enable(dec_clk->clk_info[i].vcodec_clk);
> >  if (ret) {
> > -mtk_v4l2_err("clk_prepare_enable %d %s fail %d", i,
> > +dev_err(pm->dev, "clk_prepare_enable %d %s fail %d", i,
> >  dec_clk->clk_info[i].clk_name, ret);
> >  goto error;
> >  }
> > @@ -120,7 +119,7 @@ static void mtk_vcodec_dec_enable_irq(struct
> mtk_vcodec_dev *vdec_dev, int hw_id
> >  if (subdev_dev)
> >  enable_irq(subdev_dev->dec_irq);
> >  else
> > -mtk_v4l2_err("Failed to get hw dev\n");
> > +dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev\n");
> >  } else {
> >  enable_irq(vdec_dev->dec_irq);
> >  }
> > @@ -138,7 +137,7 @@ static void mtk_vcodec_dec_disable_irq(struct
> mtk_vcodec_dev *vdec_dev, int hw_i
> >  if (subdev_dev)
> >  disable_irq(subdev_dev->dec_irq);
> >  else
> > -mtk_v4l2_err("Failed to get hw dev\n");
> > +dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev\n");
> >  } else {
> >  disable_irq(vdec_dev->dec_irq);
> >  }
> > @@ -185,7 +184,7 @@ static struct mtk_vcodec_pm
> *mtk_vcodec_dec_get_pm(struct mtk_vcodec_dev *vdec_d
> >  if (subdev_dev)
> >  return &subdev_dev->pm;
> >  
> > -mtk_v4l2_err("Failed to get hw dev\n");
> > +dev_err(&vdec_dev->plat_dev->dev, "Failed to get hw dev\n");
> >  return NULL;
> >  }
> >  
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c
> > index 0fbd030026c7..3c289b08bc87 100644
> > ---
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c
> > +++
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c
> > @@ -61,15 +61,16 @@ static struct vb2_buffer
> *get_display_buffer(struct mtk_vcodec_ctx *ctx)
> >  struct mtk_video_dec_buf *dstbuf;
> >  struct vb2_v4l2_buffer *vb;
> >  
> > -mtk_v4l2_debug(3, "[%d]", ctx->id);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d]", ctx->id);
> >  if (vdec_if_get_param(ctx, GET_PARAM_DISP_FRAME_BUFFER,
> >        &disp_frame_buffer)) {
> > -mtk_v4l2_err("[%d]Cannot get param : GET_PARAM_DISP_FRAME_BUFFER",
> ctx->id);
> > +mtk_v4l2_vdec_err(ctx, "[%d]Cannot get param :
> GET_PARAM_DISP_FRAME_BUFFER",
> > +  ctx->id);
> >  return NULL;
> >  }
> >  
> >  if (!disp_frame_buffer) {
> > -mtk_v4l2_debug(3, "No display frame buffer");
> > +mtk_v4l2_vdec_dbg(3, ctx, "No display frame buffer");
> >  return NULL;
> >  }
> >  
> > @@ -78,9 +79,9 @@ static struct vb2_buffer
> *get_display_buffer(struct mtk_vcodec_ctx *ctx)
> >  vb = &dstbuf->m2m_buf.vb;
> >  mutex_lock(&ctx->lock);
> >  if (dstbuf->used) {
> > -mtk_v4l2_debug(2, "[%d]status=%x queue id=%d to done_list %d",
> > -       ctx->id, disp_frame_buffer->status,
> > -       vb->vb2_buf.index, dstbuf->queued_in_vb2);
> > +mtk_v4l2_vdec_dbg(2, ctx, "[%d]status=%x queue id=%d to done_list
> %d",
> > +  ctx->id, disp_frame_buffer->status,
> > +  vb->vb2_buf.index, dstbuf->queued_in_vb2);
> >  
> >  v4l2_m2m_buf_done(vb, VB2_BUF_STATE_DONE);
> >  ctx->decoded_frame_cnt++;
> > @@ -105,16 +106,16 @@ static struct vb2_buffer
> *get_free_buffer(struct mtk_vcodec_ctx *ctx)
> >  
> >  if (vdec_if_get_param(ctx, GET_PARAM_FREE_FRAME_BUFFER,
> >        &free_frame_buffer)) {
> > -mtk_v4l2_err("[%d] Error!! Cannot get param", ctx->id);
> > +mtk_v4l2_vdec_err(ctx, "[%d] Error!! Cannot get param", ctx->id);
> >  return NULL;
> >  }
> >  if (!free_frame_buffer) {
> > -mtk_v4l2_debug(3, " No free frame buffer");
> > +mtk_v4l2_vdec_dbg(3, ctx, " No free frame buffer");
> >  return NULL;
> >  }
> >  
> > -mtk_v4l2_debug(3, "[%d] tmp_frame_addr = 0x%p", ctx->id,
> > -       free_frame_buffer);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d] tmp_frame_addr = 0x%p", ctx->id,
> > +  free_frame_buffer);
> >  
> >  dstbuf = container_of(free_frame_buffer, struct mtk_video_dec_buf,
> >        frame_buffer);
> > @@ -131,9 +132,9 @@ static struct vb2_buffer
> *get_free_buffer(struct mtk_vcodec_ctx *ctx)
> >   * This reduce overheads that dq/q unused capture
> >   * buffer. In this case, queued_in_vb2 = true.
> >   */
> > -mtk_v4l2_debug(2, "[%d]status=%x queue id=%d to rdy_queue %d",
> > -       ctx->id, free_frame_buffer->status,
> > -       vb->vb2_buf.index, dstbuf->queued_in_vb2);
> > +mtk_v4l2_vdec_dbg(2, ctx, "[%d]status=%x queue id=%d to rdy_queue
> %d",
> > +  ctx->id, free_frame_buffer->status,
> > +  vb->vb2_buf.index, dstbuf->queued_in_vb2);
> >  v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
> >  } else if (!dstbuf->queued_in_vb2 && dstbuf->queued_in_v4l2) {
> >  /*
> > @@ -146,10 +147,10 @@ static struct vb2_buffer
> *get_free_buffer(struct mtk_vcodec_ctx *ctx)
> >   * means this buffer is not from previous decode
> >   * output.
> >   */
> > -mtk_v4l2_debug(2,
> > -       "[%d]status=%x queue id=%d to rdy_queue",
> > -       ctx->id, free_frame_buffer->status,
> > -       vb->vb2_buf.index);
> > +mtk_v4l2_vdec_dbg(2, ctx,
> > +  "[%d]status=%x queue id=%d to rdy_queue",
> > +  ctx->id, free_frame_buffer->status,
> > +  vb->vb2_buf.index);
> >  v4l2_m2m_buf_queue(ctx->m2m_ctx, vb);
> >  dstbuf->queued_in_vb2 = true;
> >  } else {
> > @@ -161,10 +162,10 @@ static struct vb2_buffer
> *get_free_buffer(struct mtk_vcodec_ctx *ctx)
> >   * When this buffer q from user space, it could
> >   * directly q to vb2 buffer
> >   */
> > -mtk_v4l2_debug(3, "[%d]status=%x err queue id=%d %d %d",
> > -       ctx->id, free_frame_buffer->status,
> > -       vb->vb2_buf.index, dstbuf->queued_in_vb2,
> > -       dstbuf->queued_in_v4l2);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d]status=%x err queue id=%d %d %d",
> > +  ctx->id, free_frame_buffer->status,
> > +  vb->vb2_buf.index, dstbuf->queued_in_vb2,
> > +  dstbuf->queued_in_v4l2);
> >  }
> >  dstbuf->used = false;
> >  }
> > @@ -191,7 +192,7 @@ static void mtk_vdec_queue_res_chg_event(struct
> mtk_vcodec_ctx *ctx)
> >  .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION,
> >  };
> >  
> > -mtk_v4l2_debug(1, "[%d]", ctx->id);
> > +mtk_v4l2_vdec_dbg(1, ctx, "[%d]", ctx->id);
> >  v4l2_event_queue_fh(&ctx->fh, &ev_src_ch);
> >  }
> >  
> > @@ -202,7 +203,7 @@ static int mtk_vdec_flush_decoder(struct
> mtk_vcodec_ctx *ctx)
> >  
> >  ret = vdec_if_decode(ctx, NULL, NULL, &res_chg);
> >  if (ret)
> > -mtk_v4l2_err("DecodeFinal failed, ret=%d", ret);
> > +mtk_v4l2_vdec_err(ctx, "DecodeFinal failed, ret=%d", ret);
> >  
> >  clean_display_buffer(ctx);
> >  clean_free_buffer(ctx);
> > @@ -221,14 +222,14 @@ static void mtk_vdec_update_fmt(struct
> mtk_vcodec_ctx *ctx,
> >  for (k = 0; k < num_supported_formats; k++) {
> >  fmt = &mtk_video_formats[k];
> >  if (fmt->fourcc == pixelformat) {
> > -mtk_v4l2_debug(1, "Update cap fourcc(%d -> %d)",
> > -       dst_q_data->fmt->fourcc, pixelformat);
> > +mtk_v4l2_vdec_dbg(1, ctx, "Update cap fourcc(%d -> %d)",
> > +  dst_q_data->fmt->fourcc, pixelformat);
> >  dst_q_data->fmt = fmt;
> >  return;
> >  }
> >  }
> >  
> > -mtk_v4l2_err("Cannot get fourcc(%d), using init value",
> pixelformat);
> > +mtk_v4l2_vdec_err(ctx, "Cannot get fourcc(%d), using init value",
> pixelformat);
> >  }
> >  
> >  static int mtk_vdec_pic_info_update(struct mtk_vcodec_ctx *ctx)
> > @@ -238,7 +239,8 @@ static int mtk_vdec_pic_info_update(struct
> mtk_vcodec_ctx *ctx)
> >  
> >  if (vdec_if_get_param(ctx, GET_PARAM_PIC_INFO,
> >        &ctx->last_decoded_picinfo)) {
> > -mtk_v4l2_err("[%d]Error!! Cannot get param :
> GET_PARAM_PICTURE_INFO ERR", ctx->id);
> > +mtk_v4l2_vdec_err(ctx, "[%d]Error!! Cannot get param :
> GET_PARAM_PICTURE_INFO ERR",
> > +  ctx->id);
> >  return -EINVAL;
> >  }
> >  
> > @@ -246,7 +248,7 @@ static int mtk_vdec_pic_info_update(struct
> mtk_vcodec_ctx *ctx)
> >      ctx->last_decoded_picinfo.pic_h == 0 ||
> >      ctx->last_decoded_picinfo.buf_w == 0 ||
> >      ctx->last_decoded_picinfo.buf_h == 0) {
> > -mtk_v4l2_err("Cannot get correct pic info");
> > +mtk_v4l2_vdec_err(ctx, "Cannot get correct pic info");
> >  return -EINVAL;
> >  }
> >  
> > @@ -258,15 +260,15 @@ static int mtk_vdec_pic_info_update(struct
> mtk_vcodec_ctx *ctx)
> >      ctx->last_decoded_picinfo.pic_h == ctx->picinfo.pic_h)
> >  return 0;
> >  
> > -mtk_v4l2_debug(1, "[%d]-> new(%d,%d), old(%d,%d), real(%d,%d)",
> ctx->id,
> > -       ctx->last_decoded_picinfo.pic_w,
> > -       ctx->last_decoded_picinfo.pic_h, ctx->picinfo.pic_w,
> > -       ctx->picinfo.pic_h, ctx->last_decoded_picinfo.buf_w,
> > -       ctx->last_decoded_picinfo.buf_h);
> > +mtk_v4l2_vdec_dbg(1, ctx, "[%d]-> new(%d,%d), old(%d,%d),
> real(%d,%d)", ctx->id,
> > +  ctx->last_decoded_picinfo.pic_w,
> > +  ctx->last_decoded_picinfo.pic_h, ctx->picinfo.pic_w,
> > +  ctx->picinfo.pic_h, ctx->last_decoded_picinfo.buf_w,
> > +  ctx->last_decoded_picinfo.buf_h);
> >  
> >  ret = vdec_if_get_param(ctx, GET_PARAM_DPB_SIZE, &dpbsize);
> >  if (dpbsize == 0)
> > -mtk_v4l2_err("Incorrect dpb size, ret=%d", ret);
> > +mtk_v4l2_vdec_err(ctx, "Incorrect dpb size, ret=%d", ret);
> >  
> >  ctx->dpb_size = dpbsize;
> >  
> > @@ -288,14 +290,14 @@ static void mtk_vdec_worker(struct
> work_struct *work)
> >  src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> >  if (!src_buf) {
> >  v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
> > -mtk_v4l2_debug(1, "[%d] src_buf empty!!", ctx->id);
> > +mtk_v4l2_vdec_dbg(1, ctx, "[%d] src_buf empty!!", ctx->id);
> >  return;
> >  }
> >  
> >  dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
> >  if (!dst_buf) {
> >  v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
> > -mtk_v4l2_debug(1, "[%d] dst_buf empty!!", ctx->id);
> > +mtk_v4l2_vdec_dbg(1, ctx, "[%d] dst_buf empty!!", ctx->id);
> >  return;
> >  }
> >  
> > @@ -313,15 +315,15 @@ static void mtk_vdec_worker(struct
> work_struct *work)
> >  vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 1);
> >  pfb->base_c.size = ctx->picinfo.fb_sz[1];
> >  pfb->status = 0;
> > -mtk_v4l2_debug(3, "===>[%d] vdec_if_decode() ===>", ctx->id);
> > +mtk_v4l2_vdec_dbg(3, ctx, "===>[%d] vdec_if_decode() ===>", ctx-
> >id);
> >  
> > -mtk_v4l2_debug(3,
> > -       "id=%d Framebuf  pfb=%p VA=%p Y_DMA=%pad C_DMA=%pad
> Size=%zx",
> > -       dst_buf->vb2_buf.index, pfb, pfb->base_y.va,
> > -       &pfb->base_y.dma_addr, &pfb->base_c.dma_addr, pfb-
> >base_y.size);
> > +mtk_v4l2_vdec_dbg(3, ctx,
> > +  "id=%d Framebuf  pfb=%p VA=%p Y_DMA=%pad C_DMA=%pad Size=%zx",
> > +  dst_buf->vb2_buf.index, pfb, pfb->base_y.va,
> > +  &pfb->base_y.dma_addr, &pfb->base_c.dma_addr, pfb->base_y.size);
> >  
> >  if (src_buf == &ctx->empty_flush_buf.vb) {
> > -mtk_v4l2_debug(1, "Got empty flush input buffer.");
> > +mtk_v4l2_vdec_dbg(1, ctx, "Got empty flush input buffer.");
> >  src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> >  
> >  /* update dst buf status */
> > @@ -350,12 +352,12 @@ static void mtk_vdec_worker(struct
> work_struct *work)
> >  buf.size = (size_t)src_buf->vb2_buf.planes[0].bytesused;
> >  if (!buf.va) {
> >  v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
> > -mtk_v4l2_err("[%d] id=%d src_addr is NULL!!", ctx->id,
> > -     src_buf->vb2_buf.index);
> > +mtk_v4l2_vdec_err(ctx, "[%d] id=%d src_addr is NULL!!", ctx->id,
> > +  src_buf->vb2_buf.index);
> >  return;
> >  }
> > -mtk_v4l2_debug(3, "[%d] Bitstream VA=%p DMA=%pad Size=%zx vb=%p",
> > -       ctx->id, buf.va, &buf.dma_addr, buf.size, src_buf);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d] Bitstream VA=%p DMA=%pad Size=%zx
> vb=%p",
> > +  ctx->id, buf.va, &buf.dma_addr, buf.size, src_buf);
> >  dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
> >  dst_buf->timecode = src_buf->timecode;
> >  mutex_lock(&ctx->lock);
> > @@ -366,9 +368,10 @@ static void mtk_vdec_worker(struct work_struct
> *work)
> >  ret = vdec_if_decode(ctx, &buf, pfb, &res_chg);
> >  
> >  if (ret) {
> > -mtk_v4l2_err(" <===[%d], src_buf[%d] sz=0x%zx pts=%llu dst_buf[%d]
> vdec_if_decode() ret=%d res_chg=%d===>",
> > -     ctx->id, src_buf->vb2_buf.index, buf.size,
> > -     src_buf->vb2_buf.timestamp, dst_buf->vb2_buf.index, ret,
> res_chg);
> > +mtk_v4l2_vdec_err(ctx,
> > +  "[%d] decode src[%d] sz=0x%zx pts=%llu dst[%d] ret=%d
> res_chg=%d",
> > +  ctx->id, src_buf->vb2_buf.index, buf.size,
> > +  src_buf->vb2_buf.timestamp, dst_buf->vb2_buf.index, ret,
> res_chg);
> >  src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> >  if (ret == -EIO) {
> >  mutex_lock(&ctx->lock);
> > @@ -421,8 +424,8 @@ static void
> vb2ops_vdec_stateful_buf_queue(struct vb2_buffer *vb)
> >  struct vb2_v4l2_buffer *vb2_v4l2;
> >  struct mtk_q_data *dst_q_data;
> >  
> > -mtk_v4l2_debug(3, "[%d] (%d) id=%d, vb=%p", ctx->id,
> > -       vb->vb2_queue->type, vb->index, vb);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) id=%d, vb=%p", ctx->id,
> > +  vb->vb2_queue->type, vb->index, vb);
> >  /*
> >   * check if this buffer is ready to be used after decode
> >   */
> > @@ -448,20 +451,19 @@ static void
> vb2ops_vdec_stateful_buf_queue(struct vb2_buffer *vb)
> >  v4l2_m2m_buf_queue(ctx->m2m_ctx, to_vb2_v4l2_buffer(vb));
> >  
> >  if (ctx->state != MTK_STATE_INIT) {
> > -mtk_v4l2_debug(3, "[%d] already init driver %d", ctx->id,
> > -       ctx->state);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d] already init driver %d", ctx->id,
> ctx->state);
> >  return;
> >  }
> >  
> >  src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> >  if (!src_buf) {
> > -mtk_v4l2_err("No src buffer");
> > +mtk_v4l2_vdec_err(ctx, "No src buffer");
> >  return;
> >  }
> >  
> >  if (src_buf == &ctx->empty_flush_buf.vb) {
> >  /* This shouldn't happen. Just in case. */
> > -mtk_v4l2_err("Invalid flush buffer.");
> > +mtk_v4l2_vdec_err(ctx, "Invalid flush buffer.");
> >  v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> >  return;
> >  }
> > @@ -469,9 +471,8 @@ static void
> vb2ops_vdec_stateful_buf_queue(struct vb2_buffer *vb)
> >  src_mem.va = vb2_plane_vaddr(&src_buf->vb2_buf, 0);
> >  src_mem.dma_addr = vb2_dma_contig_plane_dma_addr(&src_buf-
> >vb2_buf, 0);
> >  src_mem.size = (size_t)src_buf->vb2_buf.planes[0].bytesused;
> > -mtk_v4l2_debug(2, "[%d] buf id=%d va=%p dma=%pad size=%zx", ctx-
> >id,
> > -       src_buf->vb2_buf.index, src_mem.va, &src_mem.dma_addr,
> > -       src_mem.size);
> > +mtk_v4l2_vdec_dbg(2, ctx, "[%d] buf id=%d va=%p dma=%pad
> size=%zx", ctx->id,
> > +  src_buf->vb2_buf.index, src_mem.va, &src_mem.dma_addr,
> src_mem.size);
> >  
> >  ret = vdec_if_decode(ctx, &src_mem, NULL, &res_chg);
> >  if (ret || !res_chg) {
> > @@ -484,20 +485,22 @@ static void
> vb2ops_vdec_stateful_buf_queue(struct vb2_buffer *vb)
> >  
> >  src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
> >  if (ret == -EIO) {
> > -mtk_v4l2_err("[%d] Unrecoverable error in vdec_if_decode.", ctx-
> >id);
> > +mtk_v4l2_vdec_err(ctx, "[%d] Unrecoverable error in
> vdec_if_decode.",
> > +  ctx->id);
> >  ctx->state = MTK_STATE_ABORT;
> >  v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR);
> >  } else {
> >  v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
> >  }
> > -mtk_v4l2_debug(ret ? 0 : 1,
> > -       "[%d] vdec_if_decode() src_buf=%d, size=%zu, fail=%d,
> res_chg=%d",
> > -       ctx->id, src_buf->vb2_buf.index, src_mem.size, ret,
> res_chg);
> > +mtk_v4l2_vdec_dbg(ret ? 0 : 1, ctx,
> > +  "[%d] decode() src_buf=%d, size=%zu, fail=%d, res_chg=%d",
> > +  ctx->id, src_buf->vb2_buf.index, src_mem.size, ret, res_chg);
> >  return;
> >  }
> >  
> >  if (vdec_if_get_param(ctx, GET_PARAM_PIC_INFO, &ctx->picinfo)) {
> > -mtk_v4l2_err("[%d]Error!! Cannot get param :
> GET_PARAM_PICTURE_INFO ERR", ctx->id);
> > +mtk_v4l2_vdec_err(ctx, "[%d]Error!! Cannot get param :
> GET_PARAM_PICTURE_INFO ERR",
> > +  ctx->id);
> >  return;
> >  }
> >  
> > @@ -508,17 +511,17 @@ static void
> vb2ops_vdec_stateful_buf_queue(struct vb2_buffer *vb)
> >  dst_q_data->bytesperline[i] = ctx->picinfo.buf_w;
> >  }
> >  
> > -mtk_v4l2_debug(2, "[%d] vdec_if_init() OK wxh=%dx%d pic wxh=%dx%d
> sz[0]=0x%x sz[1]=0x%x",
> > -       ctx->id, ctx->picinfo.buf_w, ctx->picinfo.buf_h, ctx-
> >picinfo.pic_w,
> > -       ctx->picinfo.pic_h, dst_q_data->sizeimage[0], dst_q_data-
> >sizeimage[1]);
> > +mtk_v4l2_vdec_dbg(2, ctx, "[%d] init OK wxh=%dx%d pic wxh=%dx%d
> sz[0]=0x%x sz[1]=0x%x",
> > +  ctx->id, ctx->picinfo.buf_w, ctx->picinfo.buf_h, ctx-
> >picinfo.pic_w,
> > +  ctx->picinfo.pic_h, dst_q_data->sizeimage[0], dst_q_data-
> >sizeimage[1]);
> >  
> >  ret = vdec_if_get_param(ctx, GET_PARAM_DPB_SIZE, &dpbsize);
> >  if (dpbsize == 0)
> > -mtk_v4l2_err("[%d] GET_PARAM_DPB_SIZE fail=%d", ctx->id, ret);
> > +mtk_v4l2_vdec_err(ctx, "[%d] GET_PARAM_DPB_SIZE fail=%d", ctx->id, 
> ret);
> >  
> >  ctx->dpb_size = dpbsize;
> >  ctx->state = MTK_STATE_HEADER;
> > -mtk_v4l2_debug(1, "[%d] dpbsize=%d", ctx->id, ctx->dpb_size);
> > +mtk_v4l2_vdec_dbg(1, ctx, "[%d] dpbsize=%d", ctx->id, ctx-
> >dpb_size);
> >  
> >  mtk_vdec_queue_res_chg_event(ctx);
> >  }
> > @@ -533,7 +536,7 @@ static int mtk_vdec_g_v_ctrl(struct v4l2_ctrl
> *ctrl)
> >  if (ctx->state >= MTK_STATE_HEADER) {
> >  ctrl->val = ctx->dpb_size;
> >  } else {
> > -mtk_v4l2_debug(0, "Seqinfo not ready");
> > +mtk_v4l2_vdec_dbg(0, ctx, "Seqinfo not ready");
> >  ctrl->val = 0;
> >  }
> >  break;
> > @@ -570,7 +573,7 @@ static int mtk_vcodec_dec_ctrls_setup(struct
> mtk_vcodec_ctx *ctx)
> >         V4L2_MPEG_VIDEO_H264_PROFILE_MAIN);
> >  
> >  if (ctx->ctrl_hdl.error) {
> > -mtk_v4l2_err("Adding control failed %d", ctx->ctrl_hdl.error);
> > +mtk_v4l2_vdec_err(ctx, "Adding control failed %d", ctx-
> >ctrl_hdl.error);
> >  return ctx->ctrl_hdl.error;
> >  }
> >  
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> > index db1e14a1bd6c..ffe05ff31dd1 100644
> > ---
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> > +++
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> > @@ -232,10 +232,10 @@ static void
> mtk_vdec_stateless_cap_to_disp(struct mtk_vcodec_ctx *ctx, int error
> >  vb2_dst = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
> >  if (vb2_dst) {
> >  v4l2_m2m_buf_done(vb2_dst, state);
> > -mtk_v4l2_debug(2, "free frame buffer id:%d to done list",
> > -       vb2_dst->vb2_buf.index);
> > +mtk_v4l2_vdec_dbg(2, ctx, "free frame buffer id:%d to done list",
> > +  vb2_dst->vb2_buf.index);
> >  } else {
> > -mtk_v4l2_err("dst buffer is NULL");
> > +mtk_v4l2_vdec_err(ctx, "dst buffer is NULL");
> >  }
> >  
> >  if (src_buf_req)
> > @@ -251,7 +251,7 @@ static struct vdec_fb
> *vdec_get_cap_buffer(struct mtk_vcodec_ctx *ctx)
> >  
> >  vb2_v4l2 = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
> >  if (!vb2_v4l2) {
> > -mtk_v4l2_debug(1, "[%d] dst_buf empty!!", ctx->id);
> > +mtk_v4l2_vdec_dbg(1, ctx, "[%d] dst_buf empty!!", ctx->id);
> >  return NULL;
> >  }
> >  
> > @@ -269,9 +269,10 @@ static struct vdec_fb
> *vdec_get_cap_buffer(struct mtk_vcodec_ctx *ctx)
> >  vb2_dma_contig_plane_dma_addr(dst_buf, 1);
> >  pfb->base_c.size = ctx->q_data[MTK_Q_DATA_DST].sizeimage[1];
> >  }
> > -mtk_v4l2_debug(1, "id=%d Framebuf  pfb=%p VA=%p Y_DMA=%pad
> C_DMA=%pad Size=%zx frame_count = %d",
> > -       dst_buf->index, pfb, pfb->base_y.va, &pfb->base_y.dma_addr,
> > -       &pfb->base_c.dma_addr, pfb->base_y.size, ctx-
> >decoded_frame_cnt);
> > +mtk_v4l2_vdec_dbg(1, ctx,
> > +  "id=%d Framebuf pfb=%p VA=%p Y/C_DMA=%pad_%pad Sz=%zx
> frame_count = %d",
> > +  dst_buf->index, pfb, pfb->base_y.va, &pfb->base_y.dma_addr,
> > +  &pfb->base_c.dma_addr, pfb->base_y.size, ctx-
> >decoded_frame_cnt);
> >  
> >  return pfb;
> >  }
> > @@ -300,7 +301,7 @@ static void mtk_vdec_worker(struct work_struct
> *work)
> >  vb2_v4l2_src = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
> >  if (!vb2_v4l2_src) {
> >  v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
> > -mtk_v4l2_debug(1, "[%d] no available source buffer", ctx->id);
> > +mtk_v4l2_vdec_dbg(1, ctx, "[%d] no available source buffer", ctx-
> >id);
> >  return;
> >  }
> >  
> > @@ -309,33 +310,34 @@ static void mtk_vdec_worker(struct
> work_struct *work)
> >     m2m_buf.vb);
> >  bs_src = &dec_buf_src->bs_buffer;
> >  
> > -mtk_v4l2_debug(3, "[%d] (%d) id=%d, vb=%p", ctx->id,
> > -       vb2_src->vb2_queue->type, vb2_src->index, vb2_src);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) id=%d, vb=%p", ctx->id,
> > +  vb2_src->vb2_queue->type, vb2_src->index, vb2_src);
> >  
> >  bs_src->va = vb2_plane_vaddr(vb2_src, 0);
> >  bs_src->dma_addr = vb2_dma_contig_plane_dma_addr(vb2_src, 0);
> >  bs_src->size = (size_t)vb2_src->planes[0].bytesused;
> >  if (!bs_src->va) {
> >  v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx);
> > -mtk_v4l2_err("[%d] id=%d source buffer is NULL", ctx->id,
> > -     vb2_src->index);
> > +mtk_v4l2_vdec_err(ctx, "[%d] id=%d source buffer is NULL", ctx-
> >id,
> > +  vb2_src->index);
> >  return;
> >  }
> >  
> > -mtk_v4l2_debug(3, "[%d] Bitstream VA=%p DMA=%pad Size=%zx vb=%p",
> > -       ctx->id, bs_src->va, &bs_src->dma_addr, bs_src->size,
> vb2_src);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d] Bitstream VA=%p DMA=%pad Size=%zx
> vb=%p",
> > +  ctx->id, bs_src->va, &bs_src->dma_addr, bs_src->size, vb2_src);
> >  /* Apply request controls. */
> >  src_buf_req = vb2_src->req_obj.req;
> >  if (src_buf_req)
> >  v4l2_ctrl_request_setup(src_buf_req, &ctx->ctrl_hdl);
> >  else
> > -mtk_v4l2_err("vb2 buffer media request is NULL");
> > +mtk_v4l2_vdec_err(ctx, "vb2 buffer media request is NULL");
> >  
> >  ret = vdec_if_decode(ctx, bs_src, NULL, &res_chg);
> >  if (ret && ret != -EAGAIN) {
> > -mtk_v4l2_err(" <===[%d], src_buf[%d] sz=0x%zx pts=%llu
> vdec_if_decode() ret=%d res_chg=%d===>",
> > -     ctx->id, vb2_src->index, bs_src->size,
> > -     vb2_src->timestamp, ret, res_chg);
> > +mtk_v4l2_vdec_err(ctx,
> > +  "[%d] decode src_buf[%d] sz=0x%zx pts=%llu ret=%d res_chg=%d",
> > +  ctx->id, vb2_src->index, bs_src->size,
> > +  vb2_src->timestamp, ret, res_chg);
> >  if (ret == -EIO) {
> >  mutex_lock(&ctx->lock);
> >  dec_buf_src->error = true;
> > @@ -363,7 +365,8 @@ static void
> vb2ops_vdec_stateless_buf_queue(struct vb2_buffer *vb)
> >  struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
> >  struct vb2_v4l2_buffer *vb2_v4l2 = to_vb2_v4l2_buffer(vb);
> >  
> > -mtk_v4l2_debug(3, "[%d] (%d) id=%d, vb=%p", ctx->id, vb-
> >vb2_queue->type, vb->index, vb);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) id=%d, vb=%p", ctx->id, vb-
> >vb2_queue->type,
> > +  vb->index, vb);
> >  
> >  mutex_lock(&ctx->lock);
> >  v4l2_m2m_buf_queue(ctx->m2m_ctx, vb2_v4l2);
> > @@ -374,9 +377,9 @@ static void
> vb2ops_vdec_stateless_buf_queue(struct vb2_buffer *vb)
> >  /* If an OUTPUT buffer, we may need to update the state */
> >  if (ctx->state == MTK_STATE_INIT) {
> >  ctx->state = MTK_STATE_HEADER;
> > -mtk_v4l2_debug(1, "Init driver from init to header.");
> > +mtk_v4l2_vdec_dbg(1, ctx, "Init driver from init to header.");
> >  } else {
> > -mtk_v4l2_debug(3, "[%d] already init driver %d", ctx->id, ctx-
> >state);
> > +mtk_v4l2_vdec_dbg(3, ctx, "[%d] already init driver %d", ctx->id,
> ctx->state);
> >  }
> >  }
> >  
> > @@ -393,7 +396,7 @@ static int mtk_vcodec_dec_ctrls_setup(struct
> mtk_vcodec_ctx *ctx)
> >  
> >  v4l2_ctrl_handler_init(&ctx->ctrl_hdl, NUM_CTRLS);
> >  if (ctx->ctrl_hdl.error) {
> > -mtk_v4l2_err("v4l2_ctrl_handler_init failed\n");
> > +mtk_v4l2_vdec_err(ctx, "v4l2_ctrl_handler_init failed\n");
> >  return ctx->ctrl_hdl.error;
> >  }
> >  
> > @@ -402,7 +405,8 @@ static int mtk_vcodec_dec_ctrls_setup(struct
> mtk_vcodec_ctx *ctx)
> >  
> >  v4l2_ctrl_new_custom(&ctx->ctrl_hdl, &cfg, NULL);
> >  if (ctx->ctrl_hdl.error) {
> > -mtk_v4l2_err("Adding control %d failed %d", i, ctx-
> >ctrl_hdl.error);
> > +mtk_v4l2_vdec_err(ctx, "Adding control %d failed %d", i,
> > +  ctx->ctrl_hdl.error);
> >  return ctx->ctrl_hdl.error;
> >  }
> >  }
> > @@ -421,11 +425,11 @@ static int fops_media_request_validate(struct
> media_request *mreq)
> >  /* We expect exactly one buffer with the request */
> >  break;
> >  case 0:
> > -mtk_v4l2_debug(1, "No buffer provided with the request");
> > +pr_debug("[MTK VCODEC] No buffer provided with the request");
> > 
> I suggest following the same format as the macro, "<devname>:
> [MTK_V4L2][ERROR]", you can probably have a macro for that
> formatting. This
> would ensure consitency for all the trace without context. Some of
> the trace
> don't even name anything MTK/VCODEC, like av1_error: prefix. I'd like
> to see
> these fixed.
> 
> pr_debug(MTK_DBG_STR "No buffer provided with...");
> 
> Or add ...no_ctx() debug macro, prepending the string ? This would be
> up to your
> preference.
> 
> regards,
> Nicolas
> 
For pr_debug and pr_err only be used for several functions. Prefer to
add two macro for vcodec and v4l2 debug.

#define MTK_DBG_VCODEC_STR "[MTK_VCODEC]"
#define MTK_DBG_V4L2_STR "[MTK_V4L2]"

Best Regards,
Yunfei Dong


> >  
> >  /**
> > diff --git a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> > index ab15ee6e2005..d82391411ba1 100644
> > --- a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> > @@ -91,7 +91,7 @@ static void vpu_dec_ipi_handler(void *data,
> unsigned int len, void *priv)
> >  (unsigned long)msg->ap_inst_addr;
> >  
> >  if (!vpu) {
> > -mtk_v4l2_err("ap_inst_addr is NULL, did the SCP hang or crash?");
> > +mtk_v4l2_vdec_err(vpu->ctx, "ap_inst_addr is NULL, did the SCP
> hang or crash?");
> >  return;
> >  }
> >  
> 
> 


More information about the Linux-mediatek mailing list