mbox series

[v4,0/11] media: mediatek: vcodec: separate encoder and decoder

Message ID 20230626035346.30654-1-yunfei.dong@mediatek.com
Headers show
Series media: mediatek: vcodec: separate encoder and decoder | expand

Message

Yunfei Dong (董云飞) June 26, 2023, 3:53 a.m. UTC
With the driver more and more complex, encoder and decoder need to add more parameter
in shared struct 'mtk_vcodec_ctx' and 'mtk_vcodec_dev'. Encoder use about 40% and
decoder use 60% parameter. Need to allocate extra unused memory when encoder and decoder
working.

Separate encoder and decoder in different folder and use independent data struct.

patch 1 remove unused parameter.
patch 2~3 align fw and interrupt related interface.
patch 4~6 remove the dependency of debug log
patch 7~8 separate mtk_vcodec_ctx and mtk_vcodec_dev
patch 9 fix unreasonable parameter
patch 10 removed unused header files
patch 11 separate encoder and decoder in different folder
---
Changed from v3:
- re-write commit message for patch 3.
Changed from v2:
- This patch main changed:
  1: add different macro mtk_dec_debug and mtk_enc_debug calling common
     macro mtk_vcodec_debug in order to use dev_dbg instead of pr_debug.
  2: add different macro mtk_v4l2_venc_dbg and mtk_v4l2_vdec_dbg calling common
     macro  in order to use dev_dbg instead of pr_debug.
Changed from v1:
- Change pr_dbg to dev_dbg for mtk_v4l2_level and mtk_vcodec_dbg for patch 4.
- Change pr_err to dev_err for mtk_v4l2_err and mtk_vcodec_err for patch 5.
- Fix unreasonable parameter for patch 8.
---
Yunfei Dong (11):
  media: mediatek: vcodec: remove unused parameter
  media: mediatek: vcodec: align fw interface
  media: mediatek: vcodec: Removing struct 'mtk_vcodec_ctx/dev' for
    shared interface
  media: mediatek: vcodec: Removing useless debug log
  media: mediatek: vcodec: remove the dependency of vcodec debug log
  media: mediatek: vcodec: replace pr_* with dev_* for v4l2 debug
    message
  media: mediatek: vcodec: separate struct 'mtk_vcodec_ctx'
  media: mediatek: vcodec: separate struct mtk_vcodec_dev
  media: mediatek: vcodec: fix unreasonable parameter definition and
    style
  media: mediatek: vcodec: remove unused include header
  media: mediatek: vcodec: separete decoder and encoder

 .../media/platform/mediatek/vcodec/Makefile   |  55 +-
 .../platform/mediatek/vcodec/common/Makefile  |  21 +
 .../vcodec/common/mtk_vcodec_com_drv.h        | 147 +++++
 .../vcodec/{ => common}/mtk_vcodec_dbgfs.c    |  57 +-
 .../vcodec/{ => common}/mtk_vcodec_dbgfs.h    |  24 +-
 .../vcodec/{ => common}/mtk_vcodec_fw.c       |  21 +-
 .../vcodec/{ => common}/mtk_vcodec_fw.h       |   8 +-
 .../vcodec/{ => common}/mtk_vcodec_fw_priv.h  |  14 +-
 .../vcodec/{ => common}/mtk_vcodec_fw_scp.c   |  26 +-
 .../vcodec/{ => common}/mtk_vcodec_fw_vpu.c   |  64 +-
 .../mediatek/vcodec/common/mtk_vcodec_intr.c  |  68 +++
 .../vcodec/{ => common}/mtk_vcodec_intr.h     |   6 +-
 .../vcodec/{ => common}/mtk_vcodec_util.c     |  67 +--
 .../mediatek/vcodec/common/mtk_vcodec_util.h  |  70 +++
 .../platform/mediatek/vcodec/decoder/Makefile |  25 +
 .../vcodec/{ => decoder}/mtk_vcodec_dec.c     | 182 +++---
 .../vcodec/{ => decoder}/mtk_vcodec_dec.h     |  10 +-
 .../vcodec/{ => decoder}/mtk_vcodec_dec_drv.c |  84 ++-
 .../vcodec/decoder/mtk_vcodec_dec_drv.h       | 317 ++++++++++
 .../vcodec/{ => decoder}/mtk_vcodec_dec_hw.c  |  19 +-
 .../vcodec/{ => decoder}/mtk_vcodec_dec_hw.h  |   6 +-
 .../vcodec/{ => decoder}/mtk_vcodec_dec_pm.c  |  38 +-
 .../vcodec/{ => decoder}/mtk_vcodec_dec_pm.h  |   6 +-
 .../{ => decoder}/mtk_vcodec_dec_stateful.c   | 176 +++---
 .../{ => decoder}/mtk_vcodec_dec_stateless.c  |  91 +--
 .../{ => decoder}/vdec/vdec_av1_req_lat_if.c  | 158 +++--
 .../vcodec/{ => decoder}/vdec/vdec_h264_if.c  |  79 ++-
 .../{ => decoder}/vdec/vdec_h264_req_common.c |   4 +-
 .../{ => decoder}/vdec/vdec_h264_req_common.h |   6 +-
 .../{ => decoder}/vdec/vdec_h264_req_if.c     |  75 ++-
 .../vdec/vdec_h264_req_multi_if.c             | 157 +++--
 .../vdec/vdec_hevc_req_multi_if.c             | 129 ++---
 .../vcodec/{ => decoder}/vdec/vdec_vp8_if.c   |  70 +--
 .../{ => decoder}/vdec/vdec_vp8_req_if.c      |  81 ++-
 .../vcodec/{ => decoder}/vdec/vdec_vp9_if.c   | 132 ++---
 .../{ => decoder}/vdec/vdec_vp9_req_lat_if.c  | 129 ++---
 .../vcodec/{ => decoder}/vdec_drv_base.h      |   2 +-
 .../vcodec/{ => decoder}/vdec_drv_if.c        |  12 +-
 .../vcodec/{ => decoder}/vdec_drv_if.h        |  10 +-
 .../vcodec/{ => decoder}/vdec_ipi_msg.h       |   0
 .../vcodec/{ => decoder}/vdec_msg_queue.c     |  64 +-
 .../vcodec/{ => decoder}/vdec_msg_queue.h     |  14 +-
 .../vcodec/{ => decoder}/vdec_vpu_if.c        |  57 +-
 .../vcodec/{ => decoder}/vdec_vpu_if.h        |   6 +-
 .../platform/mediatek/vcodec/encoder/Makefile |  11 +
 .../vcodec/{ => encoder}/mtk_vcodec_enc.c     | 296 +++++-----
 .../vcodec/{ => encoder}/mtk_vcodec_enc.h     |  12 +-
 .../vcodec/{ => encoder}/mtk_vcodec_enc_drv.c |  73 +--
 .../vcodec/encoder/mtk_vcodec_enc_drv.h       | 256 ++++++++
 .../vcodec/{ => encoder}/mtk_vcodec_enc_pm.c  |  12 +-
 .../vcodec/{ => encoder}/mtk_vcodec_enc_pm.h  |   4 +-
 .../vcodec/{ => encoder}/venc/venc_h264_if.c  | 110 ++--
 .../vcodec/{ => encoder}/venc/venc_vp8_if.c   |  69 +--
 .../vcodec/{ => encoder}/venc_drv_base.h      |   4 +-
 .../vcodec/{ => encoder}/venc_drv_if.c        |  10 +-
 .../vcodec/{ => encoder}/venc_drv_if.h        |  11 +-
 .../vcodec/{ => encoder}/venc_ipi_msg.h       |   0
 .../vcodec/{ => encoder}/venc_vpu_if.c        |  75 +--
 .../vcodec/{ => encoder}/venc_vpu_if.h        |   3 +-
 .../platform/mediatek/vcodec/mtk_vcodec_drv.h | 548 ------------------
 .../mediatek/vcodec/mtk_vcodec_intr.c         |  43 --
 .../mediatek/vcodec/mtk_vcodec_util.h         |  83 ---
 62 files changed, 2224 insertions(+), 2183 deletions(-)
 create mode 100644 drivers/media/platform/mediatek/vcodec/common/Makefile
 create mode 100644 drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_com_drv.h
 rename drivers/media/platform/mediatek/vcodec/{ => common}/mtk_vcodec_dbgfs.c (76%)
 rename drivers/media/platform/mediatek/vcodec/{ => common}/mtk_vcodec_dbgfs.h (62%)
 rename drivers/media/platform/mediatek/vcodec/{ => common}/mtk_vcodec_fw.c (75%)
 rename drivers/media/platform/mediatek/vcodec/{ => common}/mtk_vcodec_fw.h (86%)
 rename drivers/media/platform/mediatek/vcodec/{ => common}/mtk_vcodec_fw_priv.h (75%)
 rename drivers/media/platform/mediatek/vcodec/{ => common}/mtk_vcodec_fw_scp.c (70%)
 rename drivers/media/platform/mediatek/vcodec/{ => common}/mtk_vcodec_fw_vpu.c (58%)
 create mode 100644 drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_intr.c
 rename drivers/media/platform/mediatek/vcodec/{ => common}/mtk_vcodec_intr.h (68%)
 rename drivers/media/platform/mediatek/vcodec/{ => common}/mtk_vcodec_util.c (55%)
 create mode 100644 drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.h
 create mode 100644 drivers/media/platform/mediatek/vcodec/decoder/Makefile
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/mtk_vcodec_dec.c (83%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/mtk_vcodec_dec.h (91%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/mtk_vcodec_dec_drv.c (83%)
 create mode 100644 drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/mtk_vcodec_dec_hw.c (91%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/mtk_vcodec_dec_hw.h (92%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/mtk_vcodec_dec_pm.c (81%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/mtk_vcodec_dec_pm.h (61%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/mtk_vcodec_dec_stateful.c (73%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/mtk_vcodec_dec_stateless.c (84%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_av1_req_lat_if.c (93%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_h264_if.c (84%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_h264_req_common.c (98%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_h264_req_common.h (97%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_h264_req_if.c (86%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_h264_req_multi_if.c (85%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_hevc_req_multi_if.c (90%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_vp8_if.c (87%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_vp8_req_if.c (81%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_vp9_if.c (87%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec/vdec_vp9_req_lat_if.c (94%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec_drv_base.h (95%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec_drv_if.c (86%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec_drv_if.h (89%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec_ipi_msg.h (100%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec_msg_queue.c (82%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec_msg_queue.h (95%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec_vpu_if.c (79%)
 rename drivers/media/platform/mediatek/vcodec/{ => decoder}/vdec_vpu_if.h (97%)
 create mode 100644 drivers/media/platform/mediatek/vcodec/encoder/Makefile
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/mtk_vcodec_enc.c (82%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/mtk_vcodec_enc.h (78%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/mtk_vcodec_enc_drv.c (86%)
 create mode 100644 drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/mtk_vcodec_enc_pm.c (83%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/mtk_vcodec_enc_pm.h (78%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/venc/venc_h264_if.c (88%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/venc/venc_vp8_if.c (88%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/venc_drv_base.h (94%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/venc_drv_if.c (86%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/venc_drv_if.h (94%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/venc_ipi_msg.h (100%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/venc_vpu_if.c (82%)
 rename drivers/media/platform/mediatek/vcodec/{ => encoder}/venc_vpu_if.h (96%)
 delete mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h
 delete mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
 delete mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h

Comments

Nicolas Dufresne July 3, 2023, 7:36 p.m. UTC | #1
Le lundi 26 juin 2023 à 11:53 +0800, Yunfei Dong a écrit :
> 'mtk_vcodec_debug' and 'mtk_vcodec_err' depends on 'mtk_vcodec_ctx'
> to get the index of each instance. Define two different macro
> mtk_vdec_debug and mtk_venc_debug for decoder and encoder, and re-write
> macro mtk_vcodec_debug as the common interface which is called
> by mtk_vdec_debug and mtk_venc_debug. The vcodec debug log can be
> separeated by encoder and decoder.
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> ---
>  .../mediatek/vcodec/mtk_vcodec_util.h         |  34 +++--
>  .../vcodec/vdec/vdec_av1_req_lat_if.c         | 123 +++++++++--------
>  .../mediatek/vcodec/vdec/vdec_h264_if.c       |  66 +++++-----
>  .../mediatek/vcodec/vdec/vdec_h264_req_if.c   |  46 +++----
>  .../vcodec/vdec/vdec_h264_req_multi_if.c      | 124 +++++++++---------
>  .../vcodec/vdec/vdec_hevc_req_multi_if.c      |  94 +++++++------
>  .../mediatek/vcodec/vdec/vdec_vp8_if.c        |  47 ++++---
>  .../mediatek/vcodec/vdec/vdec_vp8_req_if.c    |  66 +++++-----
>  .../mediatek/vcodec/vdec/vdec_vp9_if.c        | 122 ++++++++---------
>  .../vcodec/vdec/vdec_vp9_req_lat_if.c         | 108 +++++++--------
>  .../platform/mediatek/vcodec/vdec_vpu_if.c    |  45 ++++---
>  .../mediatek/vcodec/venc/venc_h264_if.c       |  69 +++++-----
>  .../mediatek/vcodec/venc/venc_vp8_if.c        |  32 ++---
>  .../platform/mediatek/vcodec/venc_vpu_if.c    |  53 ++++----
>  14 files changed, 494 insertions(+), 535 deletions(-)
> 
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> index a356f42362e4..a684a7e4ab6e 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> @@ -31,9 +31,8 @@ struct mtk_vcodec_dev;
>  #define mtk_v4l2_err(fmt, args...)                \
>  	pr_err("[MTK_V4L2][ERROR] " fmt "\n", ##args)
>  
> -#define mtk_vcodec_err(h, fmt, args...)				\
> -	pr_err("[MTK_VCODEC][ERROR][%d]: " fmt "\n",		\
> -	       ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
> +#define mtk_vcodec_err(inst_id, plat_dev, fmt, args...)                                 \
> +	dev_err(&(plat_dev)->dev, "[MTK_VCODEC][ERROR][%d]: " fmt "\n", inst_id, ##args)
>  
>  #if defined(CONFIG_DEBUG_FS)
>  extern int mtk_v4l2_dbg_level;
> @@ -46,22 +45,31 @@ extern int mtk_vcodec_dbg;
>  				 __func__, __LINE__, ##args);	        \
>  	} while (0)
>  
> -#define mtk_vcodec_debug(h, fmt, args...)				                      \
> -	do {								                      \
> -		if (mtk_vcodec_dbg)					                      \
> -			dev_dbg(&(((struct mtk_vcodec_ctx *)(h)->ctx)->dev->plat_dev->dev),   \
> -				"[MTK_VCODEC][%d]: %s, %d " fmt "\n",                         \
> -				((struct mtk_vcodec_ctx *)(h)->ctx)->id,                      \
> -				__func__, __LINE__, ##args);                                  \
> +#define mtk_vcodec_debug(inst_id, plat_dev, fmt, args...)                               \
> +	do {                                                                            \
> +		if (mtk_vcodec_dbg)                                                     \
> +			dev_dbg(&(plat_dev)->dev, "[MTK_VCODEC][%d]: %s, %d " fmt "\n", \
> +				inst_id, __func__, __LINE__, ##args);                   \
>  	} while (0)
>  #else
>  #define mtk_v4l2_debug(level, fmt, args...) pr_debug(fmt, ##args)
>  
> -#define mtk_vcodec_debug(h, fmt, args...)			\
> -	pr_debug("[MTK_VCODEC][%d]: " fmt "\n",			\
> -		((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
> +#define mtk_vcodec_debug(inst_id, plat_dev, fmt, args...)			\
> +	dev_dbg(&(plat_dev)->dev, "[MTK_VCODEC][%d]: " fmt "\n", inst_id, ##args)
>  #endif
>  
> +#define mtk_vdec_err(ctx, fmt, args...)                               \
> +	mtk_vcodec_err((ctx)->id, (ctx)->dev->plat_dev, fmt, ##args)
> +
> +#define mtk_vdec_debug(ctx, fmt, args...)                             \
> +	mtk_vcodec_debug((ctx)->id, (ctx)->dev->plat_dev, fmt, ##args)
> +
> +#define mtk_venc_err(ctx, fmt, args...)                               \
> +	mtk_vcodec_err((ctx)->id, (ctx)->dev->plat_dev, fmt, ##args)
> +
> +#define mtk_venc_debug(ctx, fmt, args...)                              \
> +	mtk_vcodec_debug((ctx)->id, (ctx)->dev->plat_dev, fmt, ##args)
> +
>  void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base, unsigned int reg_idx);
>  int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem);
>  void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem);
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_av1_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_av1_req_lat_if.c
> index 404a1a23fd40..dfed8fe7f54c 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_av1_req_lat_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_av1_req_lat_if.c
> @@ -778,12 +778,11 @@ static int vdec_av1_slice_init_cdf_table(struct vdec_av1_slice_instance *instanc
>  	remote_cdf_table = mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler,
>  						     (u32)vsi->cdf_table_addr);
>  	if (IS_ERR(remote_cdf_table)) {
> -		mtk_vcodec_err(instance, "failed to map cdf table\n");
> +		mtk_vdec_err(ctx, "failed to map cdf table\n");
>  		return PTR_ERR(remote_cdf_table);
>  	}
>  
> -	mtk_vcodec_debug(instance, "map cdf table to 0x%p\n",
> -			 remote_cdf_table);
> +	mtk_vdec_debug(ctx, "map cdf table to 0x%p\n", remote_cdf_table);
>  
>  	if (instance->cdf_table.va)
>  		mtk_vcodec_mem_free(ctx, &instance->cdf_table);
> @@ -810,11 +809,11 @@ static int vdec_av1_slice_init_iq_table(struct vdec_av1_slice_instance *instance
>  	remote_iq_table = mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler,
>  						    (u32)vsi->iq_table_addr);
>  	if (IS_ERR(remote_iq_table)) {
> -		mtk_vcodec_err(instance, "failed to map iq table\n");
> +		mtk_vdec_err(ctx, "failed to map iq table\n");
>  		return PTR_ERR(remote_iq_table);
>  	}
>  
> -	mtk_vcodec_debug(instance, "map iq table to 0x%p\n", remote_iq_table);
> +	mtk_vdec_debug(ctx, "map iq table to 0x%p\n", remote_iq_table);
>  
>  	if (instance->iq_table.va)
>  		mtk_vcodec_mem_free(ctx, &instance->iq_table);
> @@ -965,8 +964,8 @@ static int vdec_av1_slice_alloc_working_buffer(struct vdec_av1_slice_instance *i
>  	if (level == instance->level)
>  		return 0;
>  
> -	mtk_vcodec_debug(instance, "resolution level changed from %u to %u, %ux%u",
> -			 instance->level, level, w, h);
> +	mtk_vdec_debug(ctx, "resolution level changed from %u to %u, %ux%u",
> +		       instance->level, level, w, h);
>  
>  	max_sb_w = DIV_ROUND_UP(max_w, 128);
>  	max_sb_h = DIV_ROUND_UP(max_h, 128);
> @@ -1400,17 +1399,17 @@ static int vdec_av1_slice_setup_tile_group(struct vdec_av1_slice_instance *insta
>  
>  	if (tile_group->num_tiles != tge_size ||
>  	    tile_group->num_tiles > V4L2_AV1_MAX_TILE_COUNT) {
> -		mtk_vcodec_err(instance, "invalid tge_size %d, tile_num:%d\n",
> -			       tge_size, tile_group->num_tiles);
> +		mtk_vdec_err(instance->ctx, "invalid tge_size %d, tile_num:%d\n",
> +			     tge_size, tile_group->num_tiles);
>  		return -EINVAL;
>  	}
>  
>  	for (i = 0; i < tge_size; i++) {
>  		if (i != ctrl_tge[i].tile_row * vsi->frame.uh.tile.tile_cols +
>  		    ctrl_tge[i].tile_col) {
> -			mtk_vcodec_err(instance, "invalid tge info %d, %d %d %d\n",
> -				       i, ctrl_tge[i].tile_row, ctrl_tge[i].tile_col,
> -				       vsi->frame.uh.tile.tile_rows);
> +			mtk_vdec_err(instance->ctx, "invalid tge info %d, %d %d %d\n",
> +				     i, ctrl_tge[i].tile_row, ctrl_tge[i].tile_col,
> +				     vsi->frame.uh.tile.tile_rows);
>  			return -EINVAL;
>  		}
>  		tile_group->tile_size[i] = ctrl_tge[i].tile_size;
> @@ -1639,7 +1638,7 @@ static void vdec_av1_slice_setup_seg_buffer(struct vdec_av1_slice_instance *inst
>  
>  	/* reset segment buffer */
>  	if (uh->primary_ref_frame == AV1_PRIMARY_REF_NONE || !uh->seg.segmentation_enabled) {
> -		mtk_vcodec_debug(instance, "reset seg %d\n", vsi->slot_id);
> +		mtk_vdec_debug(instance->ctx, "reset seg %d\n", vsi->slot_id);
>  		if (vsi->slot_id != AV1_INVALID_IDX) {
>  			buf = &instance->seg[vsi->slot_id];
>  			memset(buf->va, 0, buf->size);
> @@ -1690,18 +1689,18 @@ static void vdec_av1_slice_setup_tile_buffer(struct vdec_av1_slice_instance *ins
>  		    uh->disable_frame_end_update_cdf == 0)
>  			tile_info_buf[tile_info_base + 4] |= (1 << 17);
>  
> -		mtk_vcodec_debug(instance, "// tile buf %d pos(%dx%d) offset 0x%x\n",
> -				 tile_num, tile_row, tile_col, tile_info_base);
> -		mtk_vcodec_debug(instance, "// %08x %08x %08x %08x\n",
> -				 tile_info_buf[tile_info_base + 0],
> -				 tile_info_buf[tile_info_base + 1],
> -				 tile_info_buf[tile_info_base + 2],
> -				 tile_info_buf[tile_info_base + 3]);
> -		mtk_vcodec_debug(instance, "// %08x %08x %08x %08x\n",
> -				 tile_info_buf[tile_info_base + 4],
> -				 tile_info_buf[tile_info_base + 5],
> -				 tile_info_buf[tile_info_base + 6],
> -				 tile_info_buf[tile_info_base + 7]);
> +		mtk_vdec_debug(instance->ctx, "// tile buf %d pos(%dx%d) offset 0x%x\n",
> +			       tile_num, tile_row, tile_col, tile_info_base);
> +		mtk_vdec_debug(instance->ctx, "// %08x %08x %08x %08x\n",
> +			       tile_info_buf[tile_info_base + 0],
> +			       tile_info_buf[tile_info_base + 1],
> +			       tile_info_buf[tile_info_base + 2],
> +			       tile_info_buf[tile_info_base + 3]);
> +		mtk_vdec_debug(instance->ctx, "// %08x %08x %08x %08x\n",
> +			       tile_info_buf[tile_info_base + 4],
> +			       tile_info_buf[tile_info_base + 5],
> +			       tile_info_buf[tile_info_base + 6],
> +			       tile_info_buf[tile_info_base + 7]);
>  	}
>  }
>  
> @@ -1743,8 +1742,8 @@ static int vdec_av1_slice_update_lat(struct vdec_av1_slice_instance *instance,
>  	struct vdec_av1_slice_vsi *vsi;
>  
>  	vsi = &pfc->vsi;
> -	mtk_vcodec_debug(instance, "frame %u LAT CRC 0x%08x, output size is %d\n",
> -			 pfc->seq, vsi->state.crc[0], vsi->state.out_size);
> +	mtk_vdec_debug(instance->ctx, "frame %u LAT CRC 0x%08x, output size is %d\n",
> +		       pfc->seq, vsi->state.crc[0], vsi->state.out_size);
>  
>  	/* buffer full, need to re-decode */
>  	if (vsi->state.full) {
> @@ -1855,12 +1854,12 @@ static int vdec_av1_slice_update_core(struct vdec_av1_slice_instance *instance,
>  {
>  	struct vdec_av1_slice_vsi *vsi = instance->core_vsi;
>  
> -	mtk_vcodec_debug(instance, "frame %u Y_CRC %08x %08x %08x %08x\n",
> -			 pfc->seq, vsi->state.crc[0], vsi->state.crc[1],
> -			 vsi->state.crc[2], vsi->state.crc[3]);
> -	mtk_vcodec_debug(instance, "frame %u C_CRC %08x %08x %08x %08x\n",
> -			 pfc->seq, vsi->state.crc[8], vsi->state.crc[9],
> -			 vsi->state.crc[10], vsi->state.crc[11]);
> +	mtk_vdec_debug(instance->ctx, "frame %u Y_CRC %08x %08x %08x %08x\n",
> +		       pfc->seq, vsi->state.crc[0], vsi->state.crc[1],
> +		       vsi->state.crc[2], vsi->state.crc[3]);
> +	mtk_vdec_debug(instance->ctx, "frame %u C_CRC %08x %08x %08x %08x\n",
> +		       pfc->seq, vsi->state.crc[8], vsi->state.crc[9],
> +		       vsi->state.crc[10], vsi->state.crc[11]);
>  
>  	return 0;
>  }
> @@ -1883,14 +1882,14 @@ static int vdec_av1_slice_init(struct mtk_vcodec_ctx *ctx)
>  
>  	ret = vpu_dec_init(&instance->vpu);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "failed to init vpu dec, ret %d\n", ret);
> +		mtk_vdec_err(ctx, "failed to init vpu dec, ret %d\n", ret);
>  		goto error_vpu_init;
>  	}
>  
>  	/* init vsi and global flags */
>  	vsi = instance->vpu.vsi;
>  	if (!vsi) {
> -		mtk_vcodec_err(instance, "failed to get AV1 vsi\n");
> +		mtk_vdec_err(ctx, "failed to get AV1 vsi\n");
>  		ret = -EINVAL;
>  		goto error_vsi;
>  	}
> @@ -1898,20 +1897,20 @@ static int vdec_av1_slice_init(struct mtk_vcodec_ctx *ctx)
>  	instance->core_vsi = mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler, (u32)vsi->core_vsi);
>  
>  	if (!instance->core_vsi) {
> -		mtk_vcodec_err(instance, "failed to get AV1 core vsi\n");
> +		mtk_vdec_err(ctx, "failed to get AV1 core vsi\n");
>  		ret = -EINVAL;
>  		goto error_vsi;
>  	}
>  
>  	if (vsi->vsi_size != sizeof(struct vdec_av1_slice_vsi))
> -		mtk_vcodec_err(instance, "remote vsi size 0x%x mismatch! expected: 0x%zx\n",
> -			       vsi->vsi_size, sizeof(struct vdec_av1_slice_vsi));
> +		mtk_vdec_err(ctx, "remote vsi size 0x%x mismatch! expected: 0x%zx\n",
> +			     vsi->vsi_size, sizeof(struct vdec_av1_slice_vsi));
>  
>  	instance->irq_enabled = 1;
>  	instance->inneracing_mode = IS_VDEC_INNER_RACING(instance->ctx->dev->dec_capability);
>  
> -	mtk_vcodec_debug(instance, "vsi 0x%p core_vsi 0x%llx 0x%p, inneracing_mode %d\n",
> -			 vsi, vsi->core_vsi, instance->core_vsi, instance->inneracing_mode);
> +	mtk_vdec_debug(ctx, "vsi 0x%p core_vsi 0x%llx 0x%p, inneracing_mode %d\n",
> +		       vsi, vsi->core_vsi, instance->core_vsi, instance->inneracing_mode);
>  
>  	ret = vdec_av1_slice_init_cdf_table(instance);
>  	if (ret)
> @@ -1938,7 +1937,7 @@ static void vdec_av1_slice_deinit(void *h_vdec)
>  
>  	if (!instance)
>  		return;
> -	mtk_vcodec_debug(instance, "h_vdec 0x%p\n", h_vdec);
> +	mtk_vdec_debug(instance->ctx, "h_vdec 0x%p\n", h_vdec);
>  	vpu_dec_deinit(&instance->vpu);
>  	vdec_av1_slice_free_working_buffer(instance);
>  	vdec_msg_queue_deinit(&instance->ctx->msg_queue, instance->ctx);
> @@ -1951,7 +1950,7 @@ static int vdec_av1_slice_flush(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	struct vdec_av1_slice_instance *instance = h_vdec;
>  	int i;
>  
> -	mtk_vcodec_debug(instance, "flush ...\n");
> +	mtk_vdec_debug(instance->ctx, "flush ...\n");
>  
>  	vdec_msg_queue_wait_lat_buf_full(&instance->ctx->msg_queue);
>  
> @@ -1966,7 +1965,7 @@ static void vdec_av1_slice_get_pic_info(struct vdec_av1_slice_instance *instance
>  	struct mtk_vcodec_ctx *ctx = instance->ctx;
>  	u32 data[3];
>  
> -	mtk_vcodec_debug(instance, "w %u h %u\n", ctx->picinfo.pic_w, ctx->picinfo.pic_h);
> +	mtk_vdec_debug(ctx, "w %u h %u\n", ctx->picinfo.pic_w, ctx->picinfo.pic_h);
>  
>  	data[0] = ctx->picinfo.pic_w;
>  	data[1] = ctx->picinfo.pic_h;
> @@ -1996,8 +1995,8 @@ static void vdec_av1_slice_get_crop_info(struct vdec_av1_slice_instance *instanc
>  	cr->width = ctx->picinfo.pic_w;
>  	cr->height = ctx->picinfo.pic_h;
>  
> -	mtk_vcodec_debug(instance, "l=%d, t=%d, w=%d, h=%d\n",
> -			 cr->left, cr->top, cr->width, cr->height);
> +	mtk_vdec_debug(ctx, "l=%d, t=%d, w=%d, h=%d\n",
> +		       cr->left, cr->top, cr->width, cr->height);
>  }
>  
>  static int vdec_av1_slice_get_param(void *h_vdec, enum vdec_get_param_type type, void *out)
> @@ -2015,7 +2014,7 @@ static int vdec_av1_slice_get_param(void *h_vdec, enum vdec_get_param_type type,
>  		vdec_av1_slice_get_crop_info(instance, out);
>  		break;
>  	default:
> -		mtk_vcodec_err(instance, "invalid get parameter type=%d\n", type);
> +		mtk_vdec_err(instance->ctx, "invalid get parameter type=%d\n", type);
>  		return -EINVAL;
>  	}
>  
> @@ -2039,7 +2038,7 @@ static int vdec_av1_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	/* init msgQ for the first time */
>  	if (vdec_msg_queue_init(&ctx->msg_queue, ctx,
>  				vdec_av1_slice_core_decode, sizeof(*pfc))) {
> -		mtk_vcodec_err(instance, "failed to init AV1 msg queue\n");
> +		mtk_vdec_err(ctx, "failed to init AV1 msg queue\n");
>  		return -ENOMEM;
>  	}
>  
> @@ -2049,7 +2048,7 @@ static int vdec_av1_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	lat_buf = vdec_msg_queue_dqbuf(&ctx->msg_queue.lat_ctx);
>  	if (!lat_buf) {
> -		mtk_vcodec_err(instance, "failed to get AV1 lat buf\n");
> +		mtk_vdec_err(ctx, "failed to get AV1 lat buf\n");
>  		return -EAGAIN;
>  	}
>  	pfc = (struct vdec_av1_slice_pfc *)lat_buf->private_data;
> @@ -2061,14 +2060,14 @@ static int vdec_av1_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	ret = vdec_av1_slice_setup_lat(instance, bs, lat_buf, pfc);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "failed to setup AV1 lat ret %d\n", ret);
> +		mtk_vdec_err(ctx, "failed to setup AV1 lat ret %d\n", ret);
>  		goto err_free_fb_out;
>  	}
>  
>  	vdec_av1_slice_vsi_to_remote(vsi, instance->vsi);
>  	ret = vpu_dec_start(&instance->vpu, NULL, 0);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "failed to dec AV1 ret %d\n", ret);
> +		mtk_vdec_err(ctx, "failed to dec AV1 ret %d\n", ret);
>  		goto err_free_fb_out;
>  	}
>  	if (instance->inneracing_mode)
> @@ -2080,7 +2079,7 @@ static int vdec_av1_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  						   MTK_VDEC_LAT0);
>  		/* update remote vsi if decode timeout */
>  		if (ret) {
> -			mtk_vcodec_err(instance, "AV1 Frame %d decode timeout %d\n", pfc->seq, ret);
> +			mtk_vdec_err(ctx, "AV1 Frame %d decode timeout %d\n", pfc->seq, ret);
>  			WRITE_ONCE(instance->vsi->state.timeout, 1);
>  		}
>  		vpu_dec_end(&instance->vpu);
> @@ -2091,7 +2090,7 @@ static int vdec_av1_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	/* LAT trans full, re-decode */
>  	if (ret == -EAGAIN) {
> -		mtk_vcodec_err(instance, "AV1 Frame %d trans full\n", pfc->seq);
> +		mtk_vdec_err(ctx, "AV1 Frame %d trans full\n", pfc->seq);
>  		if (!instance->inneracing_mode)
>  			vdec_msg_queue_qbuf(&ctx->msg_queue.lat_ctx, lat_buf);
>  		return 0;
> @@ -2099,14 +2098,14 @@ static int vdec_av1_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	/* LAT trans full, no more UBE or decode timeout */
>  	if (ret == -ENOMEM || vsi->state.timeout) {
> -		mtk_vcodec_err(instance, "AV1 Frame %d insufficient buffer or timeout\n", pfc->seq);
> +		mtk_vdec_err(ctx, "AV1 Frame %d insufficient buffer or timeout\n", pfc->seq);
>  		if (!instance->inneracing_mode)
>  			vdec_msg_queue_qbuf(&ctx->msg_queue.lat_ctx, lat_buf);
>  		return -EBUSY;
>  	}
>  	vsi->trans.dma_addr_end += ctx->msg_queue.wdma_addr.dma_addr;
> -	mtk_vcodec_debug(instance, "lat dma 1 0x%pad 0x%pad\n",
> -			 &pfc->vsi.trans.dma_addr, &pfc->vsi.trans.dma_addr_end);
> +	mtk_vdec_debug(ctx, "lat dma 1 0x%pad 0x%pad\n",
> +		       &pfc->vsi.trans.dma_addr, &pfc->vsi.trans.dma_addr_end);
>  
>  	vdec_msg_queue_update_ube_wptr(&ctx->msg_queue, vsi->trans.dma_addr_end);
>  
> @@ -2120,7 +2119,7 @@ static int vdec_av1_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	vdec_msg_queue_qbuf(&ctx->msg_queue.lat_ctx, lat_buf);
>  
>  	if (pfc)
> -		mtk_vcodec_err(instance, "slice dec number: %d err: %d", pfc->seq, ret);
> +		mtk_vdec_err(ctx, "slice dec number: %d err: %d", pfc->seq, ret);
>  
>  	return ret;
>  }
> @@ -2153,13 +2152,13 @@ static int vdec_av1_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  
>  	ret = vdec_av1_slice_setup_core(instance, fb, lat_buf, pfc);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "vdec_av1_slice_setup_core\n");
> +		mtk_vdec_err(ctx, "vdec_av1_slice_setup_core\n");
>  		goto err;
>  	}
>  	vdec_av1_slice_vsi_to_remote(&pfc->vsi, instance->core_vsi);
>  	ret = vpu_dec_core(&instance->vpu);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "vpu_dec_core\n");
> +		mtk_vdec_err(ctx, "vpu_dec_core\n");
>  		goto err;
>  	}
>  
> @@ -2169,7 +2168,7 @@ static int vdec_av1_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  						   MTK_VDEC_CORE);
>  		/* update remote vsi if decode timeout */
>  		if (ret) {
> -			mtk_vcodec_err(instance, "AV1 frame %d core timeout\n", pfc->seq);
> +			mtk_vdec_err(ctx, "AV1 frame %d core timeout\n", pfc->seq);
>  			WRITE_ONCE(instance->vsi->state.timeout, 1);
>  		}
>  		vpu_dec_core_end(&instance->vpu);
> @@ -2177,12 +2176,12 @@ static int vdec_av1_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  
>  	ret = vdec_av1_slice_update_core(instance, lat_buf, pfc);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "vdec_av1_slice_update_core\n");
> +		mtk_vdec_err(ctx, "vdec_av1_slice_update_core\n");
>  		goto err;
>  	}
>  
> -	mtk_vcodec_debug(instance, "core dma_addr_end 0x%pad\n",
> -			 &instance->core_vsi->trans.dma_addr_end);
> +	mtk_vdec_debug(ctx, "core dma_addr_end 0x%pad\n",
> +		       &instance->core_vsi->trans.dma_addr_end);
>  	vdec_msg_queue_update_ube_rptr(&ctx->msg_queue, instance->core_vsi->trans.dma_addr_end);
>  
>  	ctx->dev->vdec_pdata->cap_to_disp(ctx, 0, lat_buf->src_buf_req);
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_if.c
> index 24312a90afbb..ca5437ae37f6 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_if.c
> @@ -144,7 +144,7 @@ static int allocate_predication_buf(struct vdec_h264_inst *inst)
>  	inst->pred_buf.size = BUF_PREDICTION_SZ;
>  	err = mtk_vcodec_mem_alloc(inst->ctx, &inst->pred_buf);
>  	if (err) {
> -		mtk_vcodec_err(inst, "failed to allocate ppl buf");
> +		mtk_vdec_err(inst->ctx, "failed to allocate ppl buf");
>  		return err;
>  	}
>  
> @@ -176,7 +176,7 @@ static int alloc_mv_buf(struct vdec_h264_inst *inst, struct vdec_pic_info *pic)
>  		mem->size = buf_sz;
>  		err = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  		if (err) {
> -			mtk_vcodec_err(inst, "failed to allocate mv buf");
> +			mtk_vdec_err(inst->ctx, "failed to allocate mv buf");
>  			return err;
>  		}
>  		inst->vsi->mv_buf_dma[i] = mem->dma_addr;
> @@ -207,9 +207,9 @@ static int check_list_validity(struct vdec_h264_inst *inst, bool disp_list)
>  	if (list->count > H264_MAX_FB_NUM ||
>  	    list->read_idx >= H264_MAX_FB_NUM ||
>  	    list->write_idx >= H264_MAX_FB_NUM) {
> -		mtk_vcodec_err(inst, "%s list err: cnt=%d r_idx=%d w_idx=%d",
> -			       disp_list ? "disp" : "free", list->count,
> -			       list->read_idx, list->write_idx);
> +		mtk_vdec_err(inst->ctx, "%s list err: cnt=%d r_idx=%d w_idx=%d",
> +			     disp_list ? "disp" : "free", list->count,
> +			     list->read_idx, list->write_idx);
>  		return -EINVAL;
>  	}
>  
> @@ -226,12 +226,12 @@ static void put_fb_to_free(struct vdec_h264_inst *inst, struct vdec_fb *fb)
>  
>  		list = &inst->vsi->list_free;
>  		if (list->count == H264_MAX_FB_NUM) {
> -			mtk_vcodec_err(inst, "[FB] put fb free_list full");
> +			mtk_vdec_err(inst->ctx, "[FB] put fb free_list full");
>  			return;
>  		}
>  
> -		mtk_vcodec_debug(inst, "[FB] put fb into free_list @(%p, %llx)",
> -				 fb->base_y.va, (u64)fb->base_y.dma_addr);
> +		mtk_vdec_debug(inst->ctx, "[FB] put fb into free_list @(%p, %llx)",
> +			       fb->base_y.va, (u64)fb->base_y.dma_addr);
>  
>  		list->fb_list[list->write_idx].vdec_fb_va = (u64)(uintptr_t)fb;
>  		list->write_idx = (list->write_idx == H264_MAX_FB_NUM - 1) ?
> @@ -244,10 +244,9 @@ static void get_pic_info(struct vdec_h264_inst *inst,
>  			 struct vdec_pic_info *pic)
>  {
>  	*pic = inst->vsi->pic;
> -	mtk_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)",
> -			 pic->pic_w, pic->pic_h, pic->buf_w, pic->buf_h);
> -	mtk_vcodec_debug(inst, "fb size: Y(%d), C(%d)",
> -			 pic->fb_sz[0], pic->fb_sz[1]);
> +	mtk_vdec_debug(inst->ctx, "pic(%d, %d), buf(%d, %d)",
> +		       pic->pic_w, pic->pic_h, pic->buf_w, pic->buf_h);
> +	mtk_vdec_debug(inst->ctx, "fb size: Y(%d), C(%d)", pic->fb_sz[0], pic->fb_sz[1]);
>  }
>  
>  static void get_crop_info(struct vdec_h264_inst *inst, struct v4l2_rect *cr)
> @@ -257,14 +256,14 @@ static void get_crop_info(struct vdec_h264_inst *inst, struct v4l2_rect *cr)
>  	cr->width = inst->vsi->crop.width;
>  	cr->height = inst->vsi->crop.height;
>  
> -	mtk_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d",
> -			 cr->left, cr->top, cr->width, cr->height);
> +	mtk_vdec_debug(inst->ctx, "l=%d, t=%d, w=%d, h=%d", cr->left, cr->top,
> +		       cr->width, cr->height);
>  }
>  
>  static void get_dpb_size(struct vdec_h264_inst *inst, unsigned int *dpb_sz)
>  {
>  	*dpb_sz = inst->vsi->dec.dpb_sz;
> -	mtk_vcodec_debug(inst, "sz=%d", *dpb_sz);
> +	mtk_vdec_debug(inst->ctx, "sz=%d", *dpb_sz);
>  }
>  
>  static int vdec_h264_init(struct mtk_vcodec_ctx *ctx)
> @@ -283,7 +282,7 @@ static int vdec_h264_init(struct mtk_vcodec_ctx *ctx)
>  
>  	err = vpu_dec_init(&inst->vpu);
>  	if (err) {
> -		mtk_vcodec_err(inst, "vdec_h264 init err=%d", err);
> +		mtk_vdec_err(ctx, "vdec_h264 init err=%d", err);
>  		goto error_free_inst;
>  	}
>  
> @@ -292,7 +291,7 @@ static int vdec_h264_init(struct mtk_vcodec_ctx *ctx)
>  	if (err)
>  		goto error_deinit;
>  
> -	mtk_vcodec_debug(inst, "H264 Instance >> %p", inst);
> +	mtk_vdec_debug(ctx, "H264 Instance >> %p", inst);
>  
>  	ctx->drv_handle = inst;
>  	return 0;
> @@ -344,8 +343,8 @@ static int vdec_h264_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	uint64_t y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
>  	uint64_t c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
>  
> -	mtk_vcodec_debug(inst, "+ [%d] FB y_dma=%llx c_dma=%llx va=%p",
> -			 ++inst->num_nalu, y_fb_dma, c_fb_dma, fb);
> +	mtk_vdec_debug(inst->ctx, "+ [%d] FB y_dma=%llx c_dma=%llx va=%p",
> +		       ++inst->num_nalu, y_fb_dma, c_fb_dma, fb);
>  
>  	/* bs NULL means flush decoder */
>  	if (bs == NULL)
> @@ -355,15 +354,15 @@ static int vdec_h264_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	buf_sz = bs->size;
>  	nal_start_idx = find_start_code(buf, buf_sz);
>  	if (nal_start_idx < 0) {
> -		mtk_vcodec_err(inst, "invalid nal start code");
> +		mtk_vdec_err(inst->ctx, "invalid nal start code");
>  		err = -EIO;
>  		goto err_free_fb_out;
>  	}
>  
>  	nal_start = buf[nal_start_idx];
>  	nal_type = NAL_TYPE(buf[nal_start_idx]);
> -	mtk_vcodec_debug(inst, "\n + NALU[%d] type %d +\n", inst->num_nalu,
> -			 nal_type);
> +	mtk_vdec_debug(inst->ctx, "\n + NALU[%d] type %d +\n", inst->num_nalu,
> +		       nal_type);
>  
>  	if (nal_type == NAL_H264_PPS) {
>  		buf_sz -= nal_start_idx;
> @@ -384,8 +383,7 @@ static int vdec_h264_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	err = vpu_dec_start(vpu, data, 2);
>  	if (err) {
>  		if (err > 0 && (DEC_ERR_RET(err) == H264_ERR_NOT_VALID)) {
> -			mtk_vcodec_err(inst, "- error bitstream - err = %d -",
> -				       err);
> +			mtk_vdec_err(inst->ctx, "- error bitstream - err = %d -", err);
>  			err = -EIO;
>  		}
>  		goto err_free_fb_out;
> @@ -395,7 +393,7 @@ static int vdec_h264_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	if (*res_chg) {
>  		struct vdec_pic_info pic;
>  
> -		mtk_vcodec_debug(inst, "- resolution changed -");
> +		mtk_vdec_debug(inst->ctx, "- resolution changed -");
>  		get_pic_info(inst, &pic);
>  
>  		if (inst->vsi->dec.realloc_mv_buf) {
> @@ -416,13 +414,12 @@ static int vdec_h264_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  		vpu_dec_end(vpu);
>  	}
>  
> -	mtk_vcodec_debug(inst, "\n - NALU[%d] type=%d -\n", inst->num_nalu,
> -			 nal_type);
> +	mtk_vdec_debug(inst->ctx, "\n - NALU[%d] type=%d -\n", inst->num_nalu, nal_type);
>  	return 0;
>  
>  err_free_fb_out:
>  	put_fb_to_free(inst, fb);
> -	mtk_vcodec_err(inst, "\n - NALU[%d] err=%d -\n", inst->num_nalu, err);
> +	mtk_vdec_err(inst->ctx, "\n - NALU[%d] err=%d -\n", inst->num_nalu, err);
>  	return err;
>  }
>  
> @@ -436,8 +433,7 @@ static void vdec_h264_get_fb(struct vdec_h264_inst *inst,
>  		return;
>  
>  	if (list->count == 0) {
> -		mtk_vcodec_debug(inst, "[FB] there is no %s fb",
> -				 disp_list ? "disp" : "free");
> +		mtk_vdec_debug(inst->ctx, "[FB] there is no %s fb", disp_list ? "disp" : "free");
>  		*out_fb = NULL;
>  		return;
>  	}
> @@ -447,10 +443,10 @@ static void vdec_h264_get_fb(struct vdec_h264_inst *inst,
>  	fb->status |= (disp_list ? FB_ST_DISPLAY : FB_ST_FREE);
>  
>  	*out_fb = fb;
> -	mtk_vcodec_debug(inst, "[FB] get %s fb st=%d poc=%d %llx",
> -			 disp_list ? "disp" : "free",
> -			 fb->status, list->fb_list[list->read_idx].poc,
> -			 list->fb_list[list->read_idx].vdec_fb_va);
> +	mtk_vdec_debug(inst->ctx, "[FB] get %s fb st=%d poc=%d %llx",
> +		       disp_list ? "disp" : "free",
> +		       fb->status, list->fb_list[list->read_idx].poc,
> +		       list->fb_list[list->read_idx].vdec_fb_va);
>  
>  	list->read_idx = (list->read_idx == H264_MAX_FB_NUM - 1) ?
>  			 0 : list->read_idx + 1;
> @@ -484,7 +480,7 @@ static int vdec_h264_get_param(void *h_vdec, enum vdec_get_param_type type,
>  		break;
>  
>  	default:
> -		mtk_vcodec_err(inst, "invalid get parameter type=%d", type);
> +		mtk_vdec_err(inst->ctx, "invalid get parameter type=%d", type);
>  		return -EINVAL;
>  	}
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_if.c
> index dc6ee266f232..250746db366b 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_if.c
> @@ -162,7 +162,7 @@ static int allocate_predication_buf(struct vdec_h264_slice_inst *inst)
>  	inst->pred_buf.size = BUF_PREDICTION_SZ;
>  	err = mtk_vcodec_mem_alloc(inst->ctx, &inst->pred_buf);
>  	if (err) {
> -		mtk_vcodec_err(inst, "failed to allocate ppl buf");
> +		mtk_vdec_err(inst->ctx, "failed to allocate ppl buf");
>  		return err;
>  	}
>  
> @@ -195,7 +195,7 @@ static int alloc_mv_buf(struct vdec_h264_slice_inst *inst,
>  		mem->size = buf_sz;
>  		err = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  		if (err) {
> -			mtk_vcodec_err(inst, "failed to allocate mv buf");
> +			mtk_vdec_err(inst->ctx, "failed to allocate mv buf");
>  			return err;
>  		}
>  		inst->vsi_ctx.mv_buf_dma[i] = mem->dma_addr;
> @@ -230,11 +230,11 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
>  		ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes;
>  
>  	*pic = ctx->picinfo;
> -	mtk_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)",
> -			 ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> -			 ctx->picinfo.buf_w, ctx->picinfo.buf_h);
> -	mtk_vcodec_debug(inst, "Y/C(%d, %d)", ctx->picinfo.fb_sz[0],
> -			 ctx->picinfo.fb_sz[1]);
> +	mtk_vdec_debug(inst->ctx, "pic(%d, %d), buf(%d, %d)",
> +		       ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> +		       ctx->picinfo.buf_w, ctx->picinfo.buf_h);
> +	mtk_vdec_debug(inst->ctx, "Y/C(%d, %d)", ctx->picinfo.fb_sz[0],
> +		       ctx->picinfo.fb_sz[1]);
>  
>  	if (ctx->last_decoded_picinfo.pic_w != ctx->picinfo.pic_w ||
>  	    ctx->last_decoded_picinfo.pic_h != ctx->picinfo.pic_h) {
> @@ -259,14 +259,14 @@ static void get_crop_info(struct vdec_h264_slice_inst *inst, struct v4l2_rect *c
>  	cr->width = inst->vsi_ctx.crop.width;
>  	cr->height = inst->vsi_ctx.crop.height;
>  
> -	mtk_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d",
> -			 cr->left, cr->top, cr->width, cr->height);
> +	mtk_vdec_debug(inst->ctx, "l=%d, t=%d, w=%d, h=%d",
> +		       cr->left, cr->top, cr->width, cr->height);
>  }
>  
>  static void get_dpb_size(struct vdec_h264_slice_inst *inst, unsigned int *dpb_sz)
>  {
>  	*dpb_sz = inst->vsi_ctx.dec.dpb_sz;
> -	mtk_vcodec_debug(inst, "sz=%d", *dpb_sz);
> +	mtk_vdec_debug(inst->ctx, "sz=%d", *dpb_sz);
>  }
>  
>  static int vdec_h264_slice_init(struct mtk_vcodec_ctx *ctx)
> @@ -285,7 +285,7 @@ static int vdec_h264_slice_init(struct mtk_vcodec_ctx *ctx)
>  
>  	err = vpu_dec_init(&inst->vpu);
>  	if (err) {
> -		mtk_vcodec_err(inst, "vdec_h264 init err=%d", err);
> +		mtk_vdec_err(ctx, "vdec_h264 init err=%d", err);
>  		goto error_free_inst;
>  	}
>  
> @@ -297,13 +297,13 @@ static int vdec_h264_slice_init(struct mtk_vcodec_ctx *ctx)
>  	if (err)
>  		goto error_deinit;
>  
> -	mtk_vcodec_debug(inst, "struct size = %zu,%zu,%zu,%zu\n",
> -			 sizeof(struct mtk_h264_sps_param),
> -			 sizeof(struct mtk_h264_pps_param),
> -			 sizeof(struct mtk_h264_dec_slice_param),
> -			 sizeof(struct mtk_h264_dpb_info));
> +	mtk_vdec_debug(ctx, "struct size = %zu,%zu,%zu,%zu\n",
> +		       sizeof(struct mtk_h264_sps_param),
> +		       sizeof(struct mtk_h264_pps_param),
> +		       sizeof(struct mtk_h264_dec_slice_param),
> +		       sizeof(struct mtk_h264_dpb_info));
>  
> -	mtk_vcodec_debug(inst, "H264 Instance >> %p", inst);
> +	mtk_vdec_debug(ctx, "H264 Instance >> %p", inst);
>  
>  	ctx->drv_handle = inst;
>  	return 0;
> @@ -354,8 +354,8 @@ static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
>  	c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
>  
> -	mtk_vcodec_debug(inst, "+ [%d] FB y_dma=%llx c_dma=%llx va=%p",
> -			 inst->num_nalu, y_fb_dma, c_fb_dma, fb);
> +	mtk_vdec_debug(inst->ctx, "+ [%d] FB y_dma=%llx c_dma=%llx va=%p",
> +		       inst->num_nalu, y_fb_dma, c_fb_dma, fb);
>  
>  	inst->vsi_ctx.dec.bs_dma = (uint64_t)bs->dma_addr;
>  	inst->vsi_ctx.dec.y_fb_dma = y_fb_dma;
> @@ -380,7 +380,7 @@ static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	*res_chg = inst->vsi_ctx.dec.resolution_changed;
>  	if (*res_chg) {
> -		mtk_vcodec_debug(inst, "- resolution changed -");
> +		mtk_vdec_debug(inst->ctx, "- resolution changed -");
>  		if (inst->vsi_ctx.dec.realloc_mv_buf) {
>  			err = alloc_mv_buf(inst, &inst->ctx->picinfo);
>  			inst->vsi_ctx.dec.realloc_mv_buf = false;
> @@ -404,11 +404,11 @@ static int vdec_h264_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	vpu_dec_end(vpu);
>  
>  	memcpy(&inst->vsi_ctx, inst->vpu.vsi, sizeof(inst->vsi_ctx));
> -	mtk_vcodec_debug(inst, "\n - NALU[%d]", inst->num_nalu);
> +	mtk_vdec_debug(inst->ctx, "\n - NALU[%d]", inst->num_nalu);
>  	return 0;
>  
>  err_free_fb_out:
> -	mtk_vcodec_err(inst, "\n - NALU[%d] err=%d -\n", inst->num_nalu, err);
> +	mtk_vdec_err(inst->ctx, "\n - NALU[%d] err=%d -\n", inst->num_nalu, err);
>  	return err;
>  }
>  
> @@ -430,7 +430,7 @@ static int vdec_h264_slice_get_param(void *h_vdec, enum vdec_get_param_type type
>  		break;
>  
>  	default:
> -		mtk_vcodec_err(inst, "invalid get parameter type=%d", type);
> +		mtk_vdec_err(inst->ctx, "invalid get parameter type=%d", type);
>  		return -EINVAL;
>  	}
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> index 3cb5b967f48a..2a160dcb5296 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> @@ -199,7 +199,7 @@ static int vdec_h264_slice_fill_decode_parameters(struct vdec_h264_slice_inst *i
>  		return PTR_ERR(pps);
>  
>  	if (dec_params->flags & V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC) {
> -		mtk_vcodec_err(inst, "No support for H.264 field decoding.");
> +		mtk_vdec_err(inst->ctx, "No support for H.264 field decoding.");
>  		inst->is_field_bitstream = true;
>  		return -EINVAL;
>  	}
> @@ -322,7 +322,7 @@ static int vdec_h264_slice_alloc_mv_buf(struct vdec_h264_slice_inst *inst,
>  		mem->size = buf_sz;
>  		err = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  		if (err) {
> -			mtk_vcodec_err(inst, "failed to allocate mv buf");
> +			mtk_vdec_err(inst->ctx, "failed to allocate mv buf");
>  			return err;
>  		}
>  	}
> @@ -359,11 +359,11 @@ static void vdec_h264_slice_get_pic_info(struct vdec_h264_slice_inst *inst)
>  	inst->cap_num_planes =
>  		ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes;
>  
> -	mtk_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)",
> -			 ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> -			 ctx->picinfo.buf_w, ctx->picinfo.buf_h);
> -	mtk_vcodec_debug(inst, "Y/C(%d, %d)", ctx->picinfo.fb_sz[0],
> -			 ctx->picinfo.fb_sz[1]);
> +	mtk_vdec_debug(ctx, "pic(%d, %d), buf(%d, %d)",
> +		       ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> +		       ctx->picinfo.buf_w, ctx->picinfo.buf_h);
> +	mtk_vdec_debug(ctx, "Y/C(%d, %d)", ctx->picinfo.fb_sz[0],
> +		       ctx->picinfo.fb_sz[1]);
>  
>  	if (ctx->last_decoded_picinfo.pic_w != ctx->picinfo.pic_w ||
>  	    ctx->last_decoded_picinfo.pic_h != ctx->picinfo.pic_h) {
> @@ -389,8 +389,8 @@ static void vdec_h264_slice_get_crop_info(struct vdec_h264_slice_inst *inst,
>  	cr->width = inst->ctx->picinfo.pic_w;
>  	cr->height = inst->ctx->picinfo.pic_h;
>  
> -	mtk_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d",
> -			 cr->left, cr->top, cr->width, cr->height);
> +	mtk_vdec_debug(inst->ctx, "l=%d, t=%d, w=%d, h=%d",
> +		       cr->left, cr->top, cr->width, cr->height);
>  }
>  
>  static int vdec_h264_slice_init(struct mtk_vcodec_ctx *ctx)
> @@ -412,7 +412,7 @@ static int vdec_h264_slice_init(struct mtk_vcodec_ctx *ctx)
>  
>  	err = vpu_dec_init(&inst->vpu);
>  	if (err) {
> -		mtk_vcodec_err(inst, "vdec_h264 init err=%d", err);
> +		mtk_vdec_err(ctx, "vdec_h264 init err=%d", err);
>  		goto error_free_inst;
>  	}
>  
> @@ -423,14 +423,14 @@ static int vdec_h264_slice_init(struct mtk_vcodec_ctx *ctx)
>  	inst->resolution_changed = true;
>  	inst->realloc_mv_buf = true;
>  
> -	mtk_vcodec_debug(inst, "lat struct size = %d,%d,%d,%d vsi: %d\n",
> -			 (int)sizeof(struct mtk_h264_sps_param),
> -			 (int)sizeof(struct mtk_h264_pps_param),
> -			 (int)sizeof(struct vdec_h264_slice_lat_dec_param),
> -			 (int)sizeof(struct mtk_h264_dpb_info),
> -			 vsi_size);
> -	mtk_vcodec_debug(inst, "lat H264 instance >> %p, codec_type = 0x%x",
> -			 inst, inst->vpu.codec_type);
> +	mtk_vdec_debug(ctx, "lat struct size = %d,%d,%d,%d vsi: %d\n",
> +		       (int)sizeof(struct mtk_h264_sps_param),
> +		       (int)sizeof(struct mtk_h264_pps_param),
> +		       (int)sizeof(struct vdec_h264_slice_lat_dec_param),
> +		       (int)sizeof(struct mtk_h264_dpb_info),
> +		       vsi_size);
> +	mtk_vdec_debug(ctx, "lat H264 instance >> %p, codec_type = 0x%x",
> +		       inst, inst->vpu.codec_type);
>  
>  	ctx->drv_handle = inst;
>  	return 0;
> @@ -464,14 +464,14 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  	struct mtk_vcodec_mem *mem;
>  	struct vdec_vpu_inst *vpu = &inst->vpu;
>  
> -	mtk_vcodec_debug(inst, "[h264-core] vdec_h264 core decode");
> +	mtk_vdec_debug(ctx, "[h264-core] vdec_h264 core decode");
>  	memcpy(&inst->vsi_core->h264_slice_params, &share_info->h264_slice_params,
>  	       sizeof(share_info->h264_slice_params));
>  
>  	fb = ctx->dev->vdec_pdata->get_cap_buffer(ctx);
>  	if (!fb) {
>  		err = -EBUSY;
> -		mtk_vcodec_err(inst, "fb buffer is NULL");
> +		mtk_vdec_err(ctx, "fb buffer is NULL");
>  		goto vdec_dec_end;
>  	}
>  
> @@ -483,8 +483,7 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  	else
>  		c_fb_dma = (u64)fb->base_c.dma_addr;
>  
> -	mtk_vcodec_debug(inst, "[h264-core] y/c addr = 0x%llx 0x%llx", y_fb_dma,
> -			 c_fb_dma);
> +	mtk_vdec_debug(ctx, "[h264-core] y/c addr = 0x%llx 0x%llx", y_fb_dma, c_fb_dma);
>  
>  	inst->vsi_core->dec.y_fb_dma = y_fb_dma;
>  	inst->vsi_core->dec.c_fb_dma = c_fb_dma;
> @@ -514,7 +513,7 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  
>  	err = vpu_dec_core(vpu);
>  	if (err) {
> -		mtk_vcodec_err(inst, "core decode err=%d", err);
> +		mtk_vdec_err(ctx, "core decode err=%d", err);
>  		goto vdec_dec_end;
>  	}
>  
> @@ -522,22 +521,21 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  	timeout = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED,
>  					       WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE);
>  	if (timeout)
> -		mtk_vcodec_err(inst, "core decode timeout: pic_%d",
> -			       ctx->decoded_frame_cnt);
> +		mtk_vdec_err(ctx, "core decode timeout: pic_%d", ctx->decoded_frame_cnt);
>  	inst->vsi_core->dec.timeout = !!timeout;
>  
>  	vpu_dec_core_end(vpu);
> -	mtk_vcodec_debug(inst, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
> -			 ctx->decoded_frame_cnt,
> -			 inst->vsi_core->dec.crc[0], inst->vsi_core->dec.crc[1],
> -			 inst->vsi_core->dec.crc[2], inst->vsi_core->dec.crc[3],
> -			 inst->vsi_core->dec.crc[4], inst->vsi_core->dec.crc[5],
> -			 inst->vsi_core->dec.crc[6], inst->vsi_core->dec.crc[7]);
> +	mtk_vdec_debug(ctx, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
> +		       ctx->decoded_frame_cnt,
> +		       inst->vsi_core->dec.crc[0], inst->vsi_core->dec.crc[1],
> +		       inst->vsi_core->dec.crc[2], inst->vsi_core->dec.crc[3],
> +		       inst->vsi_core->dec.crc[4], inst->vsi_core->dec.crc[5],
> +		       inst->vsi_core->dec.crc[6], inst->vsi_core->dec.crc[7]);
>  
>  vdec_dec_end:
>  	vdec_msg_queue_update_ube_rptr(&lat_buf->ctx->msg_queue, share_info->trans_end);
>  	ctx->dev->vdec_pdata->cap_to_disp(ctx, !!err, lat_buf->src_buf_req);
> -	mtk_vcodec_debug(inst, "core decode done err=%d", err);
> +	mtk_vdec_debug(ctx, "core decode done err=%d", err);
>  	ctx->decoded_frame_cnt++;
>  	return 0;
>  }
> @@ -594,7 +592,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	lat_buf = vdec_msg_queue_dqbuf(&inst->ctx->msg_queue.lat_ctx);
>  	if (!lat_buf) {
> -		mtk_vcodec_debug(inst, "failed to get lat buffer");
> +		mtk_vdec_debug(inst->ctx, "failed to get lat buffer");
>  		return -EAGAIN;
>  	}
>  	share_info = lat_buf->private_data;
> @@ -623,7 +621,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	*res_chg = inst->resolution_changed;
>  	if (inst->resolution_changed) {
> -		mtk_vcodec_debug(inst, "- resolution changed -");
> +		mtk_vdec_debug(inst->ctx, "- resolution changed -");
>  		if (inst->realloc_mv_buf) {
>  			err = vdec_h264_slice_alloc_mv_buf(inst, &inst->ctx->picinfo);
>  			inst->realloc_mv_buf = false;
> @@ -646,19 +644,19 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	inst->vsi->trans_end = inst->ctx->msg_queue.wdma_rptr_addr;
>  	inst->vsi->trans_start = inst->ctx->msg_queue.wdma_wptr_addr;
> -	mtk_vcodec_debug(inst, "lat:trans(0x%llx 0x%llx) err:0x%llx",
> -			 inst->vsi->wdma_start_addr,
> -			 inst->vsi->wdma_end_addr,
> -			 inst->vsi->wdma_err_addr);
> -
> -	mtk_vcodec_debug(inst, "slice(0x%llx 0x%llx) rprt((0x%llx 0x%llx))",
> -			 inst->vsi->slice_bc_start_addr,
> -			 inst->vsi->slice_bc_end_addr,
> -			 inst->vsi->trans_start,
> -			 inst->vsi->trans_end);
> +	mtk_vdec_debug(inst->ctx, "lat:trans(0x%llx 0x%llx) err:0x%llx",
> +		       inst->vsi->wdma_start_addr,
> +		       inst->vsi->wdma_end_addr,
> +		       inst->vsi->wdma_err_addr);
> +
> +	mtk_vdec_debug(inst->ctx, "slice(0x%llx 0x%llx) rprt((0x%llx 0x%llx))",
> +		       inst->vsi->slice_bc_start_addr,
> +		       inst->vsi->slice_bc_end_addr,
> +		       inst->vsi->trans_start,
> +		       inst->vsi->trans_end);
>  	err = vpu_dec_start(vpu, data, 2);
>  	if (err) {
> -		mtk_vcodec_debug(inst, "lat decode err: %d", err);
> +		mtk_vdec_debug(inst->ctx, "lat decode err: %d", err);
>  		goto err_free_fb_out;
>  	}
>  
> @@ -677,7 +675,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	timeout = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED,
>  					       WAIT_INTR_TIMEOUT_MS, MTK_VDEC_LAT0);
>  	if (timeout)
> -		mtk_vcodec_err(inst, "lat decode timeout: pic_%d", inst->slice_dec_num);
> +		mtk_vdec_err(inst->ctx, "lat decode timeout: pic_%d", inst->slice_dec_num);
>  	inst->vsi->dec.timeout = !!timeout;
>  
>  	err = vpu_dec_end(vpu);
> @@ -685,7 +683,7 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  		if (!IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability))
>  			vdec_msg_queue_qbuf(&inst->ctx->msg_queue.lat_ctx, lat_buf);
>  		inst->slice_dec_num++;
> -		mtk_vcodec_err(inst, "lat dec fail: pic_%d err:%d", inst->slice_dec_num, err);
> +		mtk_vdec_err(inst->ctx, "lat dec fail: pic_%d err:%d", inst->slice_dec_num, err);
>  		return -EINVAL;
>  	}
>  
> @@ -698,14 +696,14 @@ static int vdec_h264_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  		       sizeof(share_info->h264_slice_params));
>  		vdec_msg_queue_qbuf(&inst->ctx->msg_queue.core_ctx, lat_buf);
>  	}
> -	mtk_vcodec_debug(inst, "dec num: %d lat crc: 0x%x 0x%x 0x%x", inst->slice_dec_num,
> -			 inst->vsi->dec.crc[0], inst->vsi->dec.crc[1], inst->vsi->dec.crc[2]);
> +	mtk_vdec_debug(inst->ctx, "dec num: %d lat crc: 0x%x 0x%x 0x%x", inst->slice_dec_num,
> +		       inst->vsi->dec.crc[0], inst->vsi->dec.crc[1], inst->vsi->dec.crc[2]);
>  
>  	inst->slice_dec_num++;
>  	return 0;
>  err_free_fb_out:
>  	vdec_msg_queue_qbuf(&inst->ctx->msg_queue.lat_ctx, lat_buf);
> -	mtk_vcodec_err(inst, "slice dec number: %d err: %d", inst->slice_dec_num, err);
> +	mtk_vdec_err(inst->ctx, "slice dec number: %d err: %d", inst->slice_dec_num, err);
>  	return err;
>  }
>  
> @@ -732,8 +730,8 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs
>  
>  	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
>  	c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
> -	mtk_vcodec_debug(inst, "[h264-dec] [%d] y_dma=%llx c_dma=%llx",
> -			 inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma);
> +	mtk_vdec_debug(inst->ctx, "[h264-dec] [%d] y_dma=%llx c_dma=%llx",
> +		       inst->ctx->decoded_frame_cnt, y_fb_dma, c_fb_dma);
>  
>  	inst->vsi_ctx.dec.bs_buf_addr = (u64)bs->dma_addr;
>  	inst->vsi_ctx.dec.bs_buf_size = bs->size;
> @@ -757,7 +755,7 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs
>  
>  	*res_chg = inst->resolution_changed;
>  	if (inst->resolution_changed) {
> -		mtk_vcodec_debug(inst, "- resolution changed -");
> +		mtk_vdec_debug(inst->ctx, "- resolution changed -");
>  		if (inst->realloc_mv_buf) {
>  			err = vdec_h264_slice_alloc_mv_buf(inst, &inst->ctx->picinfo);
>  			inst->realloc_mv_buf = false;
> @@ -781,8 +779,7 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs
>  	err = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED,
>  					   WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE);
>  	if (err)
> -		mtk_vcodec_err(inst, "decode timeout: pic_%d",
> -			       inst->ctx->decoded_frame_cnt);
> +		mtk_vdec_err(inst->ctx, "decode timeout: pic_%d", inst->ctx->decoded_frame_cnt);
>  
>  	inst->vsi->dec.timeout = !!err;
>  	err = vpu_dec_end(vpu);
> @@ -790,19 +787,18 @@ static int vdec_h264_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs
>  		goto err_free_fb_out;
>  
>  	memcpy(&inst->vsi_ctx, inst->vpu.vsi, sizeof(inst->vsi_ctx));
> -	mtk_vcodec_debug(inst, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
> -			 inst->ctx->decoded_frame_cnt,
> -			 inst->vsi_ctx.dec.crc[0], inst->vsi_ctx.dec.crc[1],
> -			 inst->vsi_ctx.dec.crc[2], inst->vsi_ctx.dec.crc[3],
> -			 inst->vsi_ctx.dec.crc[4], inst->vsi_ctx.dec.crc[5],
> -			 inst->vsi_ctx.dec.crc[6], inst->vsi_ctx.dec.crc[7]);
> +	mtk_vdec_debug(inst->ctx, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
> +		       inst->ctx->decoded_frame_cnt,
> +		       inst->vsi_ctx.dec.crc[0], inst->vsi_ctx.dec.crc[1],
> +		       inst->vsi_ctx.dec.crc[2], inst->vsi_ctx.dec.crc[3],
> +		       inst->vsi_ctx.dec.crc[4], inst->vsi_ctx.dec.crc[5],
> +		       inst->vsi_ctx.dec.crc[6], inst->vsi_ctx.dec.crc[7]);
>  
>  	inst->ctx->decoded_frame_cnt++;
>  	return 0;
>  
>  err_free_fb_out:
> -	mtk_vcodec_err(inst, "dec frame number: %d err: %d",
> -		       inst->ctx->decoded_frame_cnt, err);
> +	mtk_vdec_err(inst->ctx, "dec frame number: %d err: %d", inst->ctx->decoded_frame_cnt, err);
>  	return err;
>  }
>  
> @@ -839,7 +835,7 @@ static int vdec_h264_slice_get_param(void *h_vdec, enum vdec_get_param_type type
>  		vdec_h264_slice_get_crop_info(inst, out);
>  		break;
>  	default:
> -		mtk_vcodec_err(inst, "invalid get parameter type=%d", type);
> +		mtk_vdec_err(inst->ctx, "invalid get parameter type=%d", type);
>  		return -EINVAL;
>  	}
>  	return 0;
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c
> index 0bb5b54578e9..5a864bcfe7ba 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c
> @@ -657,7 +657,7 @@ static int vdec_hevc_slice_alloc_mv_buf(struct vdec_hevc_slice_inst *inst,
>  		mem->size = buf_sz;
>  		err = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  		if (err) {
> -			mtk_vcodec_err(inst, "failed to allocate mv buf");
> +			mtk_vdec_err(inst->ctx, "failed to allocate mv buf");
>  			return err;
>  		}
>  	}
> @@ -694,11 +694,11 @@ static void vdec_hevc_slice_get_pic_info(struct vdec_hevc_slice_inst *inst)
>  	inst->cap_num_planes =
>  		ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes;
>  
> -	mtk_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)",
> -			 ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> -			 ctx->picinfo.buf_w, ctx->picinfo.buf_h);
> -	mtk_vcodec_debug(inst, "Y/C(%d, %d)", ctx->picinfo.fb_sz[0],
> -			 ctx->picinfo.fb_sz[1]);
> +	mtk_vdec_debug(ctx, "pic(%d, %d), buf(%d, %d)",
> +		       ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> +		       ctx->picinfo.buf_w, ctx->picinfo.buf_h);
> +	mtk_vdec_debug(ctx, "Y/C(%d, %d)", ctx->picinfo.fb_sz[0],
> +		       ctx->picinfo.fb_sz[1]);
>  
>  	if (ctx->last_decoded_picinfo.pic_w != ctx->picinfo.pic_w ||
>  	    ctx->last_decoded_picinfo.pic_h != ctx->picinfo.pic_h) {
> @@ -724,8 +724,8 @@ static void vdec_hevc_slice_get_crop_info(struct vdec_hevc_slice_inst *inst,
>  	cr->width = inst->ctx->picinfo.pic_w;
>  	cr->height = inst->ctx->picinfo.pic_h;
>  
> -	mtk_vcodec_debug(inst, "l=%d, t=%d, w=%d, h=%d",
> -			 cr->left, cr->top, cr->width, cr->height);
> +	mtk_vdec_debug(inst->ctx, "l=%d, t=%d, w=%d, h=%d",
> +		       cr->left, cr->top, cr->width, cr->height);
>  }
>  
>  static int vdec_hevc_slice_setup_lat_buffer(struct vdec_hevc_slice_inst *inst,
> @@ -747,7 +747,7 @@ static int vdec_hevc_slice_setup_lat_buffer(struct vdec_hevc_slice_inst *inst,
>  
>  	*res_chg = inst->resolution_changed;
>  	if (inst->resolution_changed) {
> -		mtk_vcodec_debug(inst, "- resolution changed -");
> +		mtk_vdec_debug(inst->ctx, "- resolution changed -");
>  		if (inst->realloc_mv_buf) {
>  			err = vdec_hevc_slice_alloc_mv_buf(inst, &inst->ctx->picinfo);
>  			inst->realloc_mv_buf = false;
> @@ -779,16 +779,16 @@ static int vdec_hevc_slice_setup_lat_buffer(struct vdec_hevc_slice_inst *inst,
>  	share_info->trans.dma_addr = inst->vsi->trans.dma_addr;
>  	share_info->trans.dma_addr_end = inst->vsi->trans.dma_addr_end;
>  
> -	mtk_vcodec_debug(inst, "lat: ube addr/size(0x%llx 0x%llx) err:0x%llx",
> -			 inst->vsi->ube.buf,
> -			 inst->vsi->ube.padding,
> -			 inst->vsi->err_map.buf);
> +	mtk_vdec_debug(inst->ctx, "lat: ube addr/size(0x%llx 0x%llx) err:0x%llx",
> +		       inst->vsi->ube.buf,
> +		       inst->vsi->ube.padding,
> +		       inst->vsi->err_map.buf);
>  
> -	mtk_vcodec_debug(inst, "slice addr/size(0x%llx 0x%llx) trans start/end((0x%llx 0x%llx))",
> -			 inst->vsi->slice_bc.buf,
> -			 inst->vsi->slice_bc.padding,
> -			 inst->vsi->trans.buf,
> -			 inst->vsi->trans.padding);
> +	mtk_vdec_debug(inst->ctx, "slice addr/size(0x%llx 0x%llx) trans start/end((0x%llx 0x%llx))",
> +		       inst->vsi->slice_bc.buf,
> +		       inst->vsi->slice_bc.padding,
> +		       inst->vsi->trans.buf,
> +		       inst->vsi->trans.padding);
>  
>  	return 0;
>  }
> @@ -806,7 +806,7 @@ static int vdec_hevc_slice_setup_core_buffer(struct vdec_hevc_slice_inst *inst,
>  
>  	fb = ctx->dev->vdec_pdata->get_cap_buffer(ctx);
>  	if (!fb) {
> -		mtk_vcodec_err(inst, "fb buffer is NULL");
> +		mtk_vdec_err(inst->ctx, "fb buffer is NULL");
>  		return -EBUSY;
>  	}
>  
> @@ -817,8 +817,7 @@ static int vdec_hevc_slice_setup_core_buffer(struct vdec_hevc_slice_inst *inst,
>  	else
>  		c_fb_dma = (u64)fb->base_c.dma_addr;
>  
> -	mtk_vcodec_debug(inst, "[hevc-core] y/c addr = 0x%llx 0x%llx", y_fb_dma,
> -			 c_fb_dma);
> +	mtk_vdec_debug(inst->ctx, "[hevc-core] y/c addr = 0x%llx 0x%llx", y_fb_dma, c_fb_dma);
>  
>  	inst->vsi_core->fb.y.dma_addr = y_fb_dma;
>  	inst->vsi_core->fb.y.size = ctx->picinfo.fb_sz[0];
> @@ -874,7 +873,7 @@ static int vdec_hevc_slice_init(struct mtk_vcodec_ctx *ctx)
>  	ctx->drv_handle = inst;
>  	err = vpu_dec_init(&inst->vpu);
>  	if (err) {
> -		mtk_vcodec_err(inst, "vdec_hevc init err=%d", err);
> +		mtk_vdec_err(ctx, "vdec_hevc init err=%d", err);
>  		goto error_free_inst;
>  	}
>  
> @@ -891,14 +890,14 @@ static int vdec_hevc_slice_init(struct mtk_vcodec_ctx *ctx)
>  	if (err)
>  		goto error_free_inst;
>  
> -	mtk_vcodec_debug(inst, "lat struct size = %d,%d,%d,%d vsi: %d\n",
> -			 (int)sizeof(struct mtk_hevc_sps_param),
> -			 (int)sizeof(struct mtk_hevc_pps_param),
> -			 (int)sizeof(struct vdec_hevc_slice_lat_dec_param),
> -			 (int)sizeof(struct mtk_hevc_dpb_info),
> +	mtk_vdec_debug(ctx, "lat struct size = %d,%d,%d,%d vsi: %d\n",
> +		       (int)sizeof(struct mtk_hevc_sps_param),
> +		       (int)sizeof(struct mtk_hevc_pps_param),
> +		       (int)sizeof(struct vdec_hevc_slice_lat_dec_param),
> +		       (int)sizeof(struct mtk_hevc_dpb_info),
>  			 vsi_size);
> -	mtk_vcodec_debug(inst, "lat hevc instance >> %p, codec_type = 0x%x",
> -			 inst, inst->vpu.codec_type);
> +	mtk_vdec_debug(ctx, "lat hevc instance >> %p, codec_type = 0x%x",
> +		       inst, inst->vpu.codec_type);
>  
>  	return 0;
>  error_free_inst:
> @@ -930,7 +929,7 @@ static int vdec_hevc_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  	struct vdec_hevc_slice_share_info *share_info = lat_buf->private_data;
>  	struct vdec_vpu_inst *vpu = &inst->vpu;
>  
> -	mtk_vcodec_debug(inst, "[hevc-core] vdec_hevc core decode");
> +	mtk_vdec_debug(ctx, "[hevc-core] vdec_hevc core decode");
>  	memcpy(&inst->vsi_core->hevc_slice_params, &share_info->hevc_slice_params,
>  	       sizeof(share_info->hevc_slice_params));
>  
> @@ -942,7 +941,7 @@ static int vdec_hevc_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  					    share_info);
>  	err = vpu_dec_core(vpu);
>  	if (err) {
> -		mtk_vcodec_err(inst, "core decode err=%d", err);
> +		mtk_vdec_err(ctx, "core decode err=%d", err);
>  		goto vdec_dec_end;
>  	}
>  
> @@ -950,22 +949,21 @@ static int vdec_hevc_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  	timeout = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED,
>  					       WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE);
>  	if (timeout)
> -		mtk_vcodec_err(inst, "core decode timeout: pic_%d",
> -			       ctx->decoded_frame_cnt);
> +		mtk_vdec_err(ctx, "core decode timeout: pic_%d", ctx->decoded_frame_cnt);
>  	inst->vsi_core->dec.timeout = !!timeout;
>  
>  	vpu_dec_core_end(vpu);
> -	mtk_vcodec_debug(inst, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
> -			 ctx->decoded_frame_cnt,
> -			 inst->vsi_core->dec.crc[0], inst->vsi_core->dec.crc[1],
> -			 inst->vsi_core->dec.crc[2], inst->vsi_core->dec.crc[3],
> -			 inst->vsi_core->dec.crc[4], inst->vsi_core->dec.crc[5],
> -			 inst->vsi_core->dec.crc[6], inst->vsi_core->dec.crc[7]);
> +	mtk_vdec_debug(ctx, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
> +		       ctx->decoded_frame_cnt,
> +		       inst->vsi_core->dec.crc[0], inst->vsi_core->dec.crc[1],
> +		       inst->vsi_core->dec.crc[2], inst->vsi_core->dec.crc[3],
> +		       inst->vsi_core->dec.crc[4], inst->vsi_core->dec.crc[5],
> +		       inst->vsi_core->dec.crc[6], inst->vsi_core->dec.crc[7]);
>  
>  vdec_dec_end:
>  	vdec_msg_queue_update_ube_rptr(&lat_buf->ctx->msg_queue, share_info->trans.dma_addr_end);
>  	ctx->dev->vdec_pdata->cap_to_disp(ctx, !!err, lat_buf->src_buf_req);
> -	mtk_vcodec_debug(inst, "core decode done err=%d", err);
> +	mtk_vdec_debug(ctx, "core decode done err=%d", err);
>  	ctx->decoded_frame_cnt++;
>  	return 0;
>  }
> @@ -993,7 +991,7 @@ static int vdec_hevc_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	lat_buf = vdec_msg_queue_dqbuf(&inst->ctx->msg_queue.lat_ctx);
>  	if (!lat_buf) {
> -		mtk_vcodec_debug(inst, "failed to get lat buffer");
> +		mtk_vdec_debug(inst->ctx, "failed to get lat buffer");
>  		return -EAGAIN;
>  	}
>  
> @@ -1008,7 +1006,7 @@ static int vdec_hevc_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	err = vpu_dec_start(vpu, data, 2);
>  	if (err) {
> -		mtk_vcodec_debug(inst, "lat decode err: %d", err);
> +		mtk_vdec_debug(inst->ctx, "lat decode err: %d", err);
>  		goto err_free_fb_out;
>  	}
>  
> @@ -1022,7 +1020,7 @@ static int vdec_hevc_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	timeout = mtk_vcodec_wait_for_done_ctx(inst->ctx, MTK_INST_IRQ_RECEIVED,
>  					       WAIT_INTR_TIMEOUT_MS, MTK_VDEC_LAT0);
>  	if (timeout)
> -		mtk_vcodec_err(inst, "lat decode timeout: pic_%d", inst->slice_dec_num);
> +		mtk_vdec_err(inst->ctx, "lat decode timeout: pic_%d", inst->slice_dec_num);
>  	inst->vsi->dec.timeout = !!timeout;
>  
>  	err = vpu_dec_end(vpu);
> @@ -1030,7 +1028,7 @@ static int vdec_hevc_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  		if (!IS_VDEC_INNER_RACING(inst->ctx->dev->dec_capability))
>  			vdec_msg_queue_qbuf(&inst->ctx->msg_queue.lat_ctx, lat_buf);
>  		inst->slice_dec_num++;
> -		mtk_vcodec_err(inst, "lat dec fail: pic_%d err:%d", inst->slice_dec_num, err);
> +		mtk_vdec_err(inst->ctx, "lat dec fail: pic_%d err:%d", inst->slice_dec_num, err);
>  		return -EINVAL;
>  	}
>  
> @@ -1043,14 +1041,14 @@ static int vdec_hevc_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  		       sizeof(share_info->hevc_slice_params));
>  		vdec_msg_queue_qbuf(&inst->ctx->msg_queue.core_ctx, lat_buf);
>  	}
> -	mtk_vcodec_debug(inst, "dec num: %d lat crc: 0x%x 0x%x 0x%x", inst->slice_dec_num,
> -			 inst->vsi->dec.crc[0], inst->vsi->dec.crc[1], inst->vsi->dec.crc[2]);
> +	mtk_vdec_debug(inst->ctx, "dec num: %d lat crc: 0x%x 0x%x 0x%x", inst->slice_dec_num,
> +		       inst->vsi->dec.crc[0], inst->vsi->dec.crc[1], inst->vsi->dec.crc[2]);
>  
>  	inst->slice_dec_num++;
>  	return 0;
>  err_free_fb_out:
>  	vdec_msg_queue_qbuf(&inst->ctx->msg_queue.lat_ctx, lat_buf);
> -	mtk_vcodec_err(inst, "slice dec number: %d err: %d", inst->slice_dec_num, err);
> +	mtk_vdec_err(inst->ctx, "slice dec number: %d err: %d", inst->slice_dec_num, err);
>  	return err;
>  }
>  
> @@ -1081,7 +1079,7 @@ static int vdec_hevc_slice_get_param(void *h_vdec, enum vdec_get_param_type type
>  		vdec_hevc_slice_get_crop_info(inst, out);
>  		break;
>  	default:
> -		mtk_vcodec_err(inst, "invalid get parameter type=%d", type);
> +		mtk_vdec_err(inst->ctx, "invalid get parameter type=%d", type);
>  		return -EINVAL;
>  	}
>  	return 0;
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> index fb5bc30b113b..295cb2ee5c4a 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> @@ -284,10 +284,10 @@ static void get_pic_info(struct vdec_vp8_inst *inst, struct vdec_pic_info *pic)
>  {
>  	*pic = inst->vsi->pic;
>  
> -	mtk_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)",
> -			 pic->pic_w, pic->pic_h, pic->buf_w, pic->buf_h);
> -	mtk_vcodec_debug(inst, "fb size: Y(%d), C(%d)",
> -			 pic->fb_sz[0], pic->fb_sz[1]);
> +	mtk_vdec_debug(inst->ctx, "pic(%d, %d), buf(%d, %d)",
> +		       pic->pic_w, pic->pic_h, pic->buf_w, pic->buf_h);
> +	mtk_vdec_debug(inst->ctx, "fb size: Y(%d), C(%d)",
> +		       pic->fb_sz[0], pic->fb_sz[1]);
>  }
>  
>  static void vp8_dec_finish(struct vdec_vp8_inst *inst)
> @@ -295,7 +295,7 @@ static void vp8_dec_finish(struct vdec_vp8_inst *inst)
>  	struct vdec_fb_node *node;
>  	uint64_t prev_y_dma = inst->vsi->dec.prev_y_dma;
>  
> -	mtk_vcodec_debug(inst, "prev fb base dma=%llx", prev_y_dma);
> +	mtk_vdec_debug(inst->ctx, "prev fb base dma=%llx", prev_y_dma);
>  
>  	/* put last decode ok frame to fb_free_list */
>  	if (prev_y_dma != 0) {
> @@ -370,7 +370,7 @@ static int alloc_working_buf(struct vdec_vp8_inst *inst)
>  	mem->size = VP8_WORKING_BUF_SZ;
>  	err = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  	if (err) {
> -		mtk_vcodec_err(inst, "Cannot allocate working buffer");
> +		mtk_vdec_err(inst->ctx, "Cannot allocate working buffer");
>  		return err;
>  	}
>  
> @@ -404,7 +404,7 @@ static int vdec_vp8_init(struct mtk_vcodec_ctx *ctx)
>  
>  	err = vpu_dec_init(&inst->vpu);
>  	if (err) {
> -		mtk_vcodec_err(inst, "vdec_vp8 init err=%d", err);
> +		mtk_vdec_err(ctx, "vdec_vp8 init err=%d", err);
>  		goto error_free_inst;
>  	}
>  
> @@ -415,7 +415,7 @@ static int vdec_vp8_init(struct mtk_vcodec_ctx *ctx)
>  		goto error_deinit;
>  
>  	get_hw_reg_base(inst);
> -	mtk_vcodec_debug(inst, "VP8 Instance >> %p", inst);
> +	mtk_vdec_debug(ctx, "VP8 Instance >> %p", inst);
>  
>  	ctx->drv_handle = inst;
>  	return 0;
> @@ -448,8 +448,8 @@ static int vdec_vp8_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	y_fb_dma = fb ? (u64)fb->base_y.dma_addr : 0;
>  	c_fb_dma = fb ? (u64)fb->base_c.dma_addr : 0;
>  
> -	mtk_vcodec_debug(inst, "+ [%d] FB y_dma=%llx c_dma=%llx fb=%p",
> -			 inst->frm_cnt, y_fb_dma, c_fb_dma, fb);
> +	mtk_vdec_debug(inst->ctx, "+ [%d] FB y_dma=%llx c_dma=%llx fb=%p",
> +		       inst->frm_cnt, y_fb_dma, c_fb_dma, fb);
>  
>  	inst->cur_fb = fb;
>  	dec->bs_dma = (unsigned long)bs->dma_addr;
> @@ -457,7 +457,7 @@ static int vdec_vp8_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	dec->cur_y_fb_dma = y_fb_dma;
>  	dec->cur_c_fb_dma = c_fb_dma;
>  
> -	mtk_vcodec_debug(inst, "\n + FRAME[%d] +\n", inst->frm_cnt);
> +	mtk_vdec_debug(inst->ctx, "\n + FRAME[%d] +\n", inst->frm_cnt);
>  
>  	write_hw_segmentation_data(inst);
>  	enable_hw_rw_function(inst);
> @@ -472,7 +472,7 @@ static int vdec_vp8_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	if (err) {
>  		add_fb_to_free_list(inst, fb);
>  		if (dec->wait_key_frame) {
> -			mtk_vcodec_debug(inst, "wait key frame !");
> +			mtk_vdec_debug(inst->ctx, "wait key frame !");
>  			return 0;
>  		}
>  
> @@ -480,7 +480,7 @@ static int vdec_vp8_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	}
>  
>  	if (dec->resolution_changed) {
> -		mtk_vcodec_debug(inst, "- resolution_changed -");
> +		mtk_vdec_debug(inst->ctx, "- resolution_changed -");
>  		*res_chg = true;
>  		add_fb_to_free_list(inst, fb);
>  		return 0;
> @@ -500,14 +500,13 @@ static int vdec_vp8_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	if (err)
>  		goto error;
>  
> -	mtk_vcodec_debug(inst, "\n - FRAME[%d] - show=%d\n", inst->frm_cnt,
> -			 dec->show_frame);
> +	mtk_vdec_debug(inst->ctx, "\n - FRAME[%d] - show=%d\n", inst->frm_cnt, dec->show_frame);
>  	inst->frm_cnt++;
>  	*res_chg = false;
>  	return 0;
>  
>  error:
> -	mtk_vcodec_err(inst, "\n - FRAME[%d] - err=%d\n", inst->frm_cnt, err);
> +	mtk_vdec_err(inst->ctx, "\n - FRAME[%d] - err=%d\n", inst->frm_cnt, err);
>  	return err;
>  }
>  
> @@ -522,11 +521,10 @@ static void get_disp_fb(struct vdec_vp8_inst *inst, struct vdec_fb **out_fb)
>  		list_move_tail(&node->list, &inst->available_fb_node_list);
>  		fb = (struct vdec_fb *)node->fb;
>  		fb->status |= FB_ST_DISPLAY;
> -		mtk_vcodec_debug(inst, "[FB] get disp fb %p st=%d",
> -				 node->fb, fb->status);
> +		mtk_vdec_debug(inst->ctx, "[FB] get disp fb %p st=%d", node->fb, fb->status);
>  	} else {
>  		fb = NULL;
> -		mtk_vcodec_debug(inst, "[FB] there is no disp fb");
> +		mtk_vdec_debug(inst->ctx, "[FB] there is no disp fb");
>  	}
>  
>  	*out_fb = fb;
> @@ -543,11 +541,10 @@ static void get_free_fb(struct vdec_vp8_inst *inst, struct vdec_fb **out_fb)
>  		list_move_tail(&node->list, &inst->available_fb_node_list);
>  		fb = (struct vdec_fb *)node->fb;
>  		fb->status |= FB_ST_FREE;
> -		mtk_vcodec_debug(inst, "[FB] get free fb %p st=%d",
> -				 node->fb, fb->status);
> +		mtk_vdec_debug(inst->ctx, "[FB] get free fb %p st=%d", node->fb, fb->status);
>  	} else {
>  		fb = NULL;
> -		mtk_vcodec_debug(inst, "[FB] there is no free fb");
> +		mtk_vdec_debug(inst->ctx, "[FB] there is no free fb");
>  	}
>  
>  	*out_fb = fb;
> @@ -559,8 +556,8 @@ static void get_crop_info(struct vdec_vp8_inst *inst, struct v4l2_rect *cr)
>  	cr->top = 0;
>  	cr->width = inst->vsi->pic.pic_w;
>  	cr->height = inst->vsi->pic.pic_h;
> -	mtk_vcodec_debug(inst, "get crop info l=%d, t=%d, w=%d, h=%d",
> -			 cr->left, cr->top, cr->width, cr->height);
> +	mtk_vdec_debug(inst->ctx, "get crop info l=%d, t=%d, w=%d, h=%d",
> +		       cr->left, cr->top, cr->width, cr->height);
>  }
>  
>  static int vdec_vp8_get_param(void *h_vdec, enum vdec_get_param_type type,
> @@ -590,7 +587,7 @@ static int vdec_vp8_get_param(void *h_vdec, enum vdec_get_param_type type,
>  		break;
>  
>  	default:
> -		mtk_vcodec_err(inst, "invalid get parameter type=%d", type);
> +		mtk_vdec_err(inst->ctx, "invalid get parameter type=%d", type);
>  		return -EINVAL;
>  	}
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c
> index f7181f4a4d2a..4193fe20bb92 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c
> @@ -137,11 +137,11 @@ static void vdec_vp8_slice_get_pic_info(struct vdec_vp8_slice_inst *inst)
>  	inst->vsi->pic.buf_h = ctx->picinfo.buf_h;
>  	inst->vsi->pic.fb_sz[0] = ctx->picinfo.fb_sz[0];
>  	inst->vsi->pic.fb_sz[1] = ctx->picinfo.fb_sz[1];
> -	mtk_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)",
> -			 ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> -			 ctx->picinfo.buf_w, ctx->picinfo.buf_h);
> -	mtk_vcodec_debug(inst, "fb size: Y(%d), C(%d)",
> -			 ctx->picinfo.fb_sz[0], ctx->picinfo.fb_sz[1]);
> +	mtk_vdec_debug(inst->ctx, "pic(%d, %d), buf(%d, %d)",
> +		       ctx->picinfo.pic_w, ctx->picinfo.pic_h,
> +		       ctx->picinfo.buf_w, ctx->picinfo.buf_h);
> +	mtk_vdec_debug(inst->ctx, "fb size: Y(%d), C(%d)",
> +		       ctx->picinfo.fb_sz[0], ctx->picinfo.fb_sz[1]);
>  }
>  
>  static int vdec_vp8_slice_alloc_working_buf(struct vdec_vp8_slice_inst *inst)
> @@ -153,7 +153,7 @@ static int vdec_vp8_slice_alloc_working_buf(struct vdec_vp8_slice_inst *inst)
>  	mem->size = VP8_SEG_ID_SZ;
>  	err = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  	if (err) {
> -		mtk_vcodec_err(inst, "Cannot allocate working buffer");
> +		mtk_vdec_err(inst->ctx, "Cannot allocate working buffer");
>  		return err;
>  	}
>  	inst->vsi->dec.seg_id_buf_dma = (u64)mem->dma_addr;
> @@ -162,7 +162,7 @@ static int vdec_vp8_slice_alloc_working_buf(struct vdec_vp8_slice_inst *inst)
>  	mem->size = VP8_PP_WRAPY_SZ;
>  	err = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  	if (err) {
> -		mtk_vcodec_err(inst, "cannot allocate WRAP Y buffer");
> +		mtk_vdec_err(inst->ctx, "cannot allocate WRAP Y buffer");
>  		return err;
>  	}
>  	inst->vsi->dec.wrap_y_dma = (u64)mem->dma_addr;
> @@ -171,7 +171,7 @@ static int vdec_vp8_slice_alloc_working_buf(struct vdec_vp8_slice_inst *inst)
>  	mem->size = VP8_PP_WRAPC_SZ;
>  	err = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  	if (err) {
> -		mtk_vcodec_err(inst, "cannot allocate WRAP C buffer");
> +		mtk_vdec_err(inst->ctx, "cannot allocate WRAP C buffer");
>  		return err;
>  	}
>  	inst->vsi->dec.wrap_c_dma = (u64)mem->dma_addr;
> @@ -180,7 +180,7 @@ static int vdec_vp8_slice_alloc_working_buf(struct vdec_vp8_slice_inst *inst)
>  	mem->size = VP8_VLD_PRED_SZ;
>  	err = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  	if (err) {
> -		mtk_vcodec_err(inst, "cannot allocate vld wrapper buffer");
> +		mtk_vdec_err(inst->ctx, "cannot allocate vld wrapper buffer");
>  		return err;
>  	}
>  	inst->vsi->dec.vld_wrapper_dma = (u64)mem->dma_addr;
> @@ -249,8 +249,8 @@ static int vdec_vp8_slice_get_decode_parameters(struct vdec_vp8_slice_inst *inst
>  		vb = vb2_find_buffer(vq, referenct_ts);
>  		if (!vb) {
>  			if (!V4L2_VP8_FRAME_IS_KEY_FRAME(frame_header))
> -				mtk_vcodec_err(inst, "reference invalid: index(%d) ts(%lld)",
> -					       index, referenct_ts);
> +				mtk_vdec_err(inst->ctx, "reference invalid: index(%d) ts(%lld)",
> +					     index, referenct_ts);
>  			inst->vsi->vp8_dpb_info[index].reference_flag = 0;
>  			continue;
>  		}
> @@ -291,7 +291,7 @@ static int vdec_vp8_slice_init(struct mtk_vcodec_ctx *ctx)
>  
>  	err = vpu_dec_init(&inst->vpu);
>  	if (err) {
> -		mtk_vcodec_err(inst, "vdec_vp8 init err=%d", err);
> +		mtk_vdec_err(ctx, "vdec_vp8 init err=%d", err);
>  		goto error_free_inst;
>  	}
>  
> @@ -300,11 +300,11 @@ static int vdec_vp8_slice_init(struct mtk_vcodec_ctx *ctx)
>  	if (err)
>  		goto error_deinit;
>  
> -	mtk_vcodec_debug(inst, "vp8 struct size = %d vsi: %d\n",
> -			 (int)sizeof(struct v4l2_ctrl_vp8_frame),
> -			 (int)sizeof(struct vdec_vp8_slice_vsi));
> -	mtk_vcodec_debug(inst, "vp8:%p, codec_type = 0x%x vsi: 0x%p",
> -			 inst, inst->vpu.codec_type, inst->vpu.vsi);
> +	mtk_vdec_debug(ctx, "vp8 struct size = %d vsi: %d\n",
> +		       (int)sizeof(struct v4l2_ctrl_vp8_frame),
> +		       (int)sizeof(struct vdec_vp8_slice_vsi));
> +	mtk_vdec_debug(ctx, "vp8:%p, codec_type = 0x%x vsi: 0x%p",
> +		       inst, inst->vpu.codec_type, inst->vpu.vsi);
>  
>  	ctx->drv_handle = inst;
>  	return 0;
> @@ -350,10 +350,10 @@ static int vdec_vp8_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	inst->vsi->dec.cur_y_fb_dma = y_fb_dma;
>  	inst->vsi->dec.cur_c_fb_dma = c_fb_dma;
>  
> -	mtk_vcodec_debug(inst, "frame[%d] bs(%zu 0x%llx) y/c(0x%llx 0x%llx)",
> -			 inst->ctx->decoded_frame_cnt,
> -			 bs->size, (u64)bs->dma_addr,
> -			 y_fb_dma, c_fb_dma);
> +	mtk_vdec_debug(inst->ctx, "frame[%d] bs(%zu 0x%llx) y/c(0x%llx 0x%llx)",
> +		       inst->ctx->decoded_frame_cnt,
> +		       bs->size, (u64)bs->dma_addr,
> +		       y_fb_dma, c_fb_dma);
>  
>  	v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb,
>  				   &dst_buf_info->m2m_buf.vb, true);
> @@ -364,12 +364,12 @@ static int vdec_vp8_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	err = vpu_dec_start(vpu, &data, 1);
>  	if (err) {
> -		mtk_vcodec_debug(inst, "vp8 dec start err!");
> +		mtk_vdec_debug(inst->ctx, "vp8 dec start err!");
>  		goto error;
>  	}
>  
>  	if (inst->vsi->dec.resolution_changed) {
> -		mtk_vcodec_debug(inst, "- resolution_changed -");
> +		mtk_vdec_debug(inst->ctx, "- resolution_changed -");
>  		*res_chg = true;
>  		return 0;
>  	}
> @@ -380,15 +380,15 @@ static int vdec_vp8_slice_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	err = vpu_dec_end(vpu);
>  	if (err || timeout)
> -		mtk_vcodec_debug(inst, "vp8 dec error timeout:%d err: %d pic_%d",
> -				 timeout, err, inst->ctx->decoded_frame_cnt);
> +		mtk_vdec_debug(inst->ctx, "vp8 dec error timeout:%d err: %d pic_%d",
> +			       timeout, err, inst->ctx->decoded_frame_cnt);
>  
> -	mtk_vcodec_debug(inst, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
> -			 inst->ctx->decoded_frame_cnt,
> -			 inst->vsi->dec.crc[0], inst->vsi->dec.crc[1],
> -			 inst->vsi->dec.crc[2], inst->vsi->dec.crc[3],
> -			 inst->vsi->dec.crc[4], inst->vsi->dec.crc[5],
> -			 inst->vsi->dec.crc[6], inst->vsi->dec.crc[7]);
> +	mtk_vdec_debug(inst->ctx, "pic[%d] crc: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
> +		       inst->ctx->decoded_frame_cnt,
> +		       inst->vsi->dec.crc[0], inst->vsi->dec.crc[1],
> +		       inst->vsi->dec.crc[2], inst->vsi->dec.crc[3],
> +		       inst->vsi->dec.crc[4], inst->vsi->dec.crc[5],
> +		       inst->vsi->dec.crc[6], inst->vsi->dec.crc[7]);
>  
>  	inst->ctx->decoded_frame_cnt++;
>  error:
> @@ -404,13 +404,13 @@ static int vdec_vp8_slice_get_param(void *h_vdec, enum vdec_get_param_type type,
>  		vdec_vp8_slice_get_pic_info(inst);
>  		break;
>  	case GET_PARAM_CROP_INFO:
> -		mtk_vcodec_debug(inst, "No need to get vp8 crop information.");
> +		mtk_vdec_debug(inst->ctx, "No need to get vp8 crop information.");
>  		break;
>  	case GET_PARAM_DPB_SIZE:
>  		*((unsigned int *)out) = VP8_DPB_SIZE;
>  		break;
>  	default:
> -		mtk_vcodec_err(inst, "invalid get parameter type=%d", type);
> +		mtk_vdec_err(inst->ctx, "invalid get parameter type=%d", type);
>  		return -EINVAL;
>  	}
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c
> index 70b8383f7c8e..62c2b3b021e6 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c
> @@ -246,7 +246,7 @@ static void vp9_add_to_fb_free_list(struct vdec_vp9_inst *inst,
>  			list_move_tail(&node->list, &inst->fb_free_list);
>  		}
>  	} else {
> -		mtk_vcodec_debug(inst, "No free fb node");
> +		mtk_vdec_debug(inst->ctx, "No free fb node");
>  	}
>  }
>  
> @@ -330,7 +330,7 @@ static int vp9_get_sf_ref_fb(struct vdec_vp9_inst *inst)
>  	}
>  
>  	if (idx == ARRAY_SIZE(vsi->sf_ref_fb)) {
> -		mtk_vcodec_err(inst, "List Full");
> +		mtk_vdec_err(inst->ctx, "List Full");
>  		return -1;
>  	}
>  
> @@ -339,7 +339,7 @@ static int vp9_get_sf_ref_fb(struct vdec_vp9_inst *inst)
>  		vsi->buf_len_sz_y;
>  
>  	if (mtk_vcodec_mem_alloc(inst->ctx, mem_basy_y)) {
> -		mtk_vcodec_err(inst, "Cannot allocate sf_ref_buf y_buf");
> +		mtk_vdec_err(inst->ctx, "Cannot allocate sf_ref_buf y_buf");
>  		return -1;
>  	}
>  
> @@ -348,7 +348,7 @@ static int vp9_get_sf_ref_fb(struct vdec_vp9_inst *inst)
>  		vsi->buf_len_sz_c;
>  
>  	if (mtk_vcodec_mem_alloc(inst->ctx, mem_basy_c)) {
> -		mtk_vcodec_err(inst, "Cannot allocate sf_ref_fb c_buf");
> +		mtk_vdec_err(inst->ctx, "Cannot allocate sf_ref_fb c_buf");
>  		return -1;
>  	}
>  	vsi->sf_ref_fb[idx].used = 0;
> @@ -377,17 +377,13 @@ static bool vp9_alloc_work_buf(struct vdec_vp9_inst *inst)
>  
>  	if ((vsi->pic_w > max_pic_w) ||
>  		(vsi->pic_h > max_pic_h)) {
> -		mtk_vcodec_err(inst, "Invalid w/h %d/%d",
> -				vsi->pic_w, vsi->pic_h);
> +		mtk_vdec_err(inst->ctx, "Invalid w/h %d/%d", vsi->pic_w, vsi->pic_h);
>  		return false;
>  	}
>  
> -	mtk_vcodec_debug(inst, "BUF CHG(%d): w/h/sb_w/sb_h=%d/%d/%d/%d",
> -			vsi->resolution_changed,
> -			vsi->pic_w,
> -			vsi->pic_h,
> -			vsi->buf_w,
> -			vsi->buf_h);
> +	mtk_vdec_debug(inst->ctx, "BUF CHG(%d): w/h/sb_w/sb_h=%d/%d/%d/%d",
> +		       vsi->resolution_changed, vsi->pic_w,
> +		       vsi->pic_h, vsi->buf_w, vsi->buf_h);
>  
>  	mem = &inst->mv_buf;
>  	if (mem->va)
> @@ -398,7 +394,7 @@ static bool vp9_alloc_work_buf(struct vdec_vp9_inst *inst)
>  	result = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  	if (result) {
>  		mem->size = 0;
> -		mtk_vcodec_err(inst, "Cannot allocate mv_buf");
> +		mtk_vdec_err(inst->ctx, "Cannot allocate mv_buf");
>  		return false;
>  	}
>  	/* Set the va again */
> @@ -415,7 +411,7 @@ static bool vp9_alloc_work_buf(struct vdec_vp9_inst *inst)
>  	result = mtk_vcodec_mem_alloc(inst->ctx, mem);
>  	if (result) {
>  		mem->size = 0;
> -		mtk_vcodec_err(inst, "Cannot allocate seg_id_buf");
> +		mtk_vdec_err(inst->ctx, "Cannot allocate seg_id_buf");
>  		return false;
>  	}
>  	/* Set the va again */
> @@ -436,7 +432,7 @@ static bool vp9_add_to_fb_disp_list(struct vdec_vp9_inst *inst,
>  	struct vdec_fb_node *node;
>  
>  	if (!fb) {
> -		mtk_vcodec_err(inst, "fb == NULL");
> +		mtk_vdec_err(inst->ctx, "fb == NULL");
>  		return false;
>  	}
>  
> @@ -446,7 +442,7 @@ static bool vp9_add_to_fb_disp_list(struct vdec_vp9_inst *inst,
>  		node->fb = fb;
>  		list_move_tail(&node->list, &inst->fb_disp_list);
>  	} else {
> -		mtk_vcodec_err(inst, "No available fb node");
> +		mtk_vdec_err(inst->ctx, "No available fb node");
>  		return false;
>  	}
>  
> @@ -492,10 +488,10 @@ static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst)
>  			 * size
>  			 */
>  			if (frm_to_show->fb != NULL)
> -				mtk_vcodec_err(inst,
> -					"inst->cur_fb->base_y.size=%zu, frm_to_show->fb.base_y.size=%zu",
> -					inst->cur_fb->base_y.size,
> -					frm_to_show->fb->base_y.size);
> +				mtk_vdec_err(inst->ctx,
> +					     "base_y.size=%zu, frm_to_show: base_y.size=%zu",
> +					     inst->cur_fb->base_y.size,
> +					     frm_to_show->fb->base_y.size);
>  		}
>  		if (!vp9_is_sf_ref_fb(inst, inst->cur_fb)) {
>  			if (vsi->show_frame & BIT(0))
> @@ -582,20 +578,19 @@ static bool vp9_decode_end_proc(struct vdec_vp9_inst *inst)
>  	if (!vsi->show_existing_frame) {
>  		ret = vp9_wait_dec_end(inst);
>  		if (!ret) {
> -			mtk_vcodec_err(inst, "Decode failed, Decode Timeout @[%d]",
> -				vsi->frm_num);
> +			mtk_vdec_err(inst->ctx, "Decode failed, Decode Timeout @[%d]",
> +				     vsi->frm_num);
>  			return false;
>  		}
>  
>  		if (vpu_dec_end(&inst->vpu)) {
> -			mtk_vcodec_err(inst, "vp9_dec_vpu_end failed");
> +			mtk_vdec_err(inst->ctx, "vp9_dec_vpu_end failed");
>  			return false;
>  		}
> -		mtk_vcodec_debug(inst, "Decode Ok @%d (%d/%d)", vsi->frm_num,
> -				vsi->pic_w, vsi->pic_h);
> +		mtk_vdec_debug(inst->ctx, "Decode Ok @%d (%d/%d)", vsi->frm_num,
> +			       vsi->pic_w, vsi->pic_h);
>  	} else {
> -		mtk_vcodec_debug(inst, "Decode Ok @%d (show_existing_frame)",
> -				vsi->frm_num);
> +		mtk_vdec_debug(inst->ctx, "Decode Ok @%d (show_existing_frame)", vsi->frm_num);
>  	}
>  
>  	vp9_swap_frm_bufs(inst);
> @@ -624,10 +619,9 @@ static struct vdec_fb *vp9_rm_from_fb_disp_list(struct vdec_vp9_inst *inst)
>  		fb = (struct vdec_fb *)node->fb;
>  		fb->status |= FB_ST_DISPLAY;
>  		list_move_tail(&node->list, &inst->available_fb_node_list);
> -		mtk_vcodec_debug(inst, "[FB] get disp fb %p st=%d",
> -				 node->fb, fb->status);
> +		mtk_vdec_debug(inst->ctx, "[FB] get disp fb %p st=%d", node->fb, fb->status);
>  	} else
> -		mtk_vcodec_debug(inst, "[FB] there is no disp fb");
> +		mtk_vdec_debug(inst->ctx, "[FB] there is no disp fb");
>  
>  	return fb;
>  }
> @@ -638,7 +632,7 @@ static bool vp9_add_to_fb_use_list(struct vdec_vp9_inst *inst,
>  	struct vdec_fb_node *node;
>  
>  	if (!fb) {
> -		mtk_vcodec_debug(inst, "fb == NULL");
> +		mtk_vdec_debug(inst->ctx, "fb == NULL");
>  		return false;
>  	}
>  
> @@ -648,7 +642,7 @@ static bool vp9_add_to_fb_use_list(struct vdec_vp9_inst *inst,
>  		node->fb = fb;
>  		list_move_tail(&node->list, &inst->fb_use_list);
>  	} else {
> -		mtk_vcodec_err(inst, "No free fb node");
> +		mtk_vdec_err(inst->ctx, "No free fb node");
>  		return false;
>  	}
>  	return true;
> @@ -665,7 +659,7 @@ static void vp9_reset(struct vdec_vp9_inst *inst)
>  	inst->vsi->sf_next_ref_fb_idx = vp9_get_sf_ref_fb(inst);
>  
>  	if (vpu_dec_reset(&inst->vpu))
> -		mtk_vcodec_err(inst, "vp9_dec_vpu_reset failed");
> +		mtk_vdec_err(inst->ctx, "vp9_dec_vpu_reset failed");
>  
>  	/* Set the va again, since vpu_dec_reset will clear mv_buf in vpu */
>  	inst->vsi->mv_buf.va = (unsigned long)inst->mv_buf.va;
> @@ -706,11 +700,9 @@ static void get_pic_info(struct vdec_vp9_inst *inst, struct vdec_pic_info *pic)
>  	pic->buf_w = inst->vsi->buf_w;
>  	pic->buf_h = inst->vsi->buf_h;
>  
> -	mtk_vcodec_debug(inst, "pic(%d, %d), buf(%d, %d)",
> -		 pic->pic_w, pic->pic_h, pic->buf_w, pic->buf_h);
> -	mtk_vcodec_debug(inst, "fb size: Y(%d), C(%d)",
> -		pic->fb_sz[0],
> -		pic->fb_sz[1]);
> +	mtk_vdec_debug(inst->ctx, "pic(%d, %d), buf(%d, %d)",
> +		       pic->pic_w, pic->pic_h, pic->buf_w, pic->buf_h);
> +	mtk_vdec_debug(inst->ctx, "fb size: Y(%d), C(%d)", pic->fb_sz[0], pic->fb_sz[1]);
>  }
>  
>  static void get_disp_fb(struct vdec_vp9_inst *inst, struct vdec_fb **out_fb)
> @@ -732,10 +724,9 @@ static void get_free_fb(struct vdec_vp9_inst *inst, struct vdec_fb **out_fb)
>  		list_move_tail(&node->list, &inst->available_fb_node_list);
>  		fb = (struct vdec_fb *)node->fb;
>  		fb->status |= FB_ST_FREE;
> -		mtk_vcodec_debug(inst, "[FB] get free fb %p st=%d",
> -				 node->fb, fb->status);
> +		mtk_vdec_debug(inst->ctx, "[FB] get free fb %p st=%d", node->fb, fb->status);
>  	} else {
> -		mtk_vcodec_debug(inst, "[FB] there is no free fb");
> +		mtk_vdec_debug(inst->ctx, "[FB] there is no free fb");
>  	}
>  
>  	*out_fb = fb;
> @@ -744,18 +735,15 @@ static void get_free_fb(struct vdec_vp9_inst *inst, struct vdec_fb **out_fb)
>  static int validate_vsi_array_indexes(struct vdec_vp9_inst *inst,
>  		struct vdec_vp9_vsi *vsi) {
>  	if (vsi->sf_frm_idx >= VP9_MAX_FRM_BUF_NUM - 1) {
> -		mtk_vcodec_err(inst, "Invalid vsi->sf_frm_idx=%u.",
> -				vsi->sf_frm_idx);
> +		mtk_vdec_err(inst->ctx, "Invalid vsi->sf_frm_idx=%u.", vsi->sf_frm_idx);
>  		return -EIO;
>  	}
>  	if (vsi->frm_to_show_idx >= VP9_MAX_FRM_BUF_NUM) {
> -		mtk_vcodec_err(inst, "Invalid vsi->frm_to_show_idx=%u.",
> -				vsi->frm_to_show_idx);
> +		mtk_vdec_err(inst->ctx, "Invalid vsi->frm_to_show_idx=%u.", vsi->frm_to_show_idx);
>  		return -EIO;
>  	}
>  	if (vsi->new_fb_idx >= VP9_MAX_FRM_BUF_NUM) {
> -		mtk_vcodec_err(inst, "Invalid vsi->new_fb_idx=%u.",
> -				vsi->new_fb_idx);
> +		mtk_vdec_err(inst->ctx, "Invalid vsi->new_fb_idx=%u.", vsi->new_fb_idx);
>  		return -EIO;
>  	}
>  	return 0;
> @@ -769,7 +757,7 @@ static void vdec_vp9_deinit(void *h_vdec)
>  
>  	ret = vpu_dec_deinit(&inst->vpu);
>  	if (ret)
> -		mtk_vcodec_err(inst, "vpu_dec_deinit failed");
> +		mtk_vdec_err(inst->ctx, "vpu_dec_deinit failed");
>  
>  	mem = &inst->mv_buf;
>  	if (mem->va)
> @@ -798,7 +786,7 @@ static int vdec_vp9_init(struct mtk_vcodec_ctx *ctx)
>  	inst->vpu.ctx = ctx;
>  
>  	if (vpu_dec_init(&inst->vpu)) {
> -		mtk_vcodec_err(inst, "vp9_dec_vpu_init failed");
> +		mtk_vdec_err(inst->ctx, "vp9_dec_vpu_init failed");
>  		goto err_deinit_inst;
>  	}
>  
> @@ -829,17 +817,17 @@ static int vdec_vp9_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	*res_chg = false;
>  
>  	if ((bs == NULL) && (fb == NULL)) {
> -		mtk_vcodec_debug(inst, "[EOS]");
> +		mtk_vdec_debug(inst->ctx, "[EOS]");
>  		vp9_reset(inst);
>  		return ret;
>  	}
>  
>  	if (bs == NULL) {
> -		mtk_vcodec_err(inst, "bs == NULL");
> +		mtk_vdec_err(inst->ctx, "bs == NULL");
>  		return -EINVAL;
>  	}
>  
> -	mtk_vcodec_debug(inst, "Input BS Size = %zu", bs->size);
> +	mtk_vdec_debug(inst->ctx, "Input BS Size = %zu", bs->size);
>  
>  	while (1) {
>  		struct vdec_fb *cur_fb = NULL;
> @@ -882,7 +870,7 @@ static int vdec_vp9_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  		ret = vpu_dec_start(&inst->vpu, data, 3);
>  		if (ret) {
> -			mtk_vcodec_err(inst, "vpu_dec_start failed");
> +			mtk_vdec_err(inst->ctx, "vpu_dec_start failed");
>  			goto DECODE_ERROR;
>  		}
>  
> @@ -892,7 +880,7 @@ static int vdec_vp9_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  			if (vsi->show_frame & BIT(2)) {
>  				ret = vpu_dec_start(&inst->vpu, NULL, 0);
>  				if (ret) {
> -					mtk_vcodec_err(inst, "vpu trig decoder failed");
> +					mtk_vdec_err(inst->ctx, "vpu trig decoder failed");
>  					goto DECODE_ERROR;
>  				}
>  			}
> @@ -900,7 +888,7 @@ static int vdec_vp9_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  		ret = validate_vsi_array_indexes(inst, vsi);
>  		if (ret) {
> -			mtk_vcodec_err(inst, "Invalid values from VPU.");
> +			mtk_vdec_err(inst->ctx, "Invalid values from VPU.");
>  			goto DECODE_ERROR;
>  		}
>  
> @@ -926,18 +914,18 @@ static int vdec_vp9_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  		if (!vp9_is_sf_ref_fb(inst, inst->cur_fb))
>  			vp9_add_to_fb_use_list(inst, inst->cur_fb);
>  
> -		mtk_vcodec_debug(inst, "[#pic %d]", vsi->frm_num);
> +		mtk_vdec_debug(inst->ctx, "[#pic %d]", vsi->frm_num);
>  
>  		if (vsi->show_existing_frame)
> -			mtk_vcodec_debug(inst,
> -				"drv->new_fb_idx=%d, drv->frm_to_show_idx=%d",
> -				vsi->new_fb_idx, vsi->frm_to_show_idx);
> +			mtk_vdec_debug(inst->ctx,
> +				       "drv->new_fb_idx=%d, drv->frm_to_show_idx=%d",
> +				       vsi->new_fb_idx, vsi->frm_to_show_idx);
>  
>  		if (vsi->show_existing_frame && (vsi->frm_to_show_idx <
>  					VP9_MAX_FRM_BUF_NUM)) {
> -			mtk_vcodec_debug(inst,
> -				"Skip Decode drv->new_fb_idx=%d, drv->frm_to_show_idx=%d",
> -				vsi->new_fb_idx, vsi->frm_to_show_idx);
> +			mtk_vdec_debug(inst->ctx,
> +				       "Skip Decode drv->new_fb_idx=%d, drv->frm_to_show_idx=%d",
> +				       vsi->new_fb_idx, vsi->frm_to_show_idx);
>  
>  			vp9_ref_cnt_fb(inst, &vsi->new_fb_idx,
>  					vsi->frm_to_show_idx);
> @@ -954,14 +942,14 @@ static int vdec_vp9_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  		if (vsi->resolution_changed) {
>  			*res_chg = true;
> -			mtk_vcodec_debug(inst, "VDEC_ST_RESOLUTION_CHANGED");
> +			mtk_vdec_debug(inst->ctx, "VDEC_ST_RESOLUTION_CHANGED");
>  
>  			ret = 0;
>  			goto DECODE_ERROR;
>  		}
>  
>  		if (!vp9_decode_end_proc(inst)) {
> -			mtk_vcodec_err(inst, "vp9_decode_end_proc");
> +			mtk_vdec_err(inst->ctx, "vp9_decode_end_proc");
>  			ret = -EINVAL;
>  			goto DECODE_ERROR;
>  		}
> @@ -985,8 +973,8 @@ static void get_crop_info(struct vdec_vp9_inst *inst, struct v4l2_rect *cr)
>  	cr->top = 0;
>  	cr->width = inst->vsi->pic_w;
>  	cr->height = inst->vsi->pic_h;
> -	mtk_vcodec_debug(inst, "get crop info l=%d, t=%d, w=%d, h=%d\n",
> -			 cr->left, cr->top, cr->width, cr->height);
> +	mtk_vdec_debug(inst->ctx, "get crop info l=%d, t=%d, w=%d, h=%d\n",
> +		       cr->left, cr->top, cr->width, cr->height);
>  }
>  
>  static int vdec_vp9_get_param(void *h_vdec, enum vdec_get_param_type type,
> @@ -1012,7 +1000,7 @@ static int vdec_vp9_get_param(void *h_vdec, enum vdec_get_param_type type,
>  		get_crop_info(inst, out);
>  		break;
>  	default:
> -		mtk_vcodec_err(inst, "not supported param type %d", type);
> +		mtk_vdec_err(inst->ctx, "not supported param type %d", type);
>  		ret = -EINVAL;
>  		break;
>  	}
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
> index c2f90848f498..913077d6e701 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
> @@ -518,7 +518,7 @@ static int vdec_vp9_slice_init_default_frame_ctx(struct vdec_vp9_slice_instance
>  	remote_frame_ctx = mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler,
>  						     (u32)vsi->default_frame_ctx);
>  	if (!remote_frame_ctx) {
> -		mtk_vcodec_err(instance, "failed to map default frame ctx\n");
> +		mtk_vdec_err(ctx, "failed to map default frame ctx\n");
>  		return -EINVAL;
>  	}
>  
> @@ -577,8 +577,8 @@ static int vdec_vp9_slice_alloc_working_buffer(struct vdec_vp9_slice_instance *i
>  	if (level == instance->level)
>  		return 0;
>  
> -	mtk_vcodec_debug(instance, "resolution level changed, from %u to %u, %ux%u",
> -			 instance->level, level, w, h);
> +	mtk_vdec_debug(ctx, "resolution level changed, from %u to %u, %ux%u",
> +		       instance->level, level, w, h);
>  
>  	max_sb_w = DIV_ROUND_UP(max_w, 64);
>  	max_sb_h = DIV_ROUND_UP(max_h, 64);
> @@ -1025,9 +1025,9 @@ static int vdec_vp9_slice_setup_prob_buffer(struct vdec_vp9_slice_instance *inst
>  
>  	uh = &vsi->frame.uh;
>  
> -	mtk_vcodec_debug(instance, "ctx dirty %u idx %d\n",
> -			 instance->dirty[uh->frame_context_idx],
> -			 uh->frame_context_idx);
> +	mtk_vdec_debug(instance->ctx, "ctx dirty %u idx %d\n",
> +		       instance->dirty[uh->frame_context_idx],
> +		       uh->frame_context_idx);
>  
>  	if (instance->dirty[uh->frame_context_idx])
>  		frame_ctx = &instance->frame_ctx[uh->frame_context_idx];
> @@ -1051,7 +1051,7 @@ static void vdec_vp9_slice_setup_seg_buffer(struct vdec_vp9_slice_instance *inst
>  	    uh->error_resilient_mode ||
>  	    uh->frame_width != instance->width ||
>  	    uh->frame_height != instance->height) {
> -		mtk_vcodec_debug(instance, "reset seg\n");
> +		mtk_vdec_debug(instance->ctx, "reset seg\n");
>  		memset(buf->va, 0, buf->size);
>  	}
>  }
> @@ -1093,16 +1093,14 @@ static int vdec_vp9_slice_setup_tile_buffer(struct vdec_vp9_slice_instance *inst
>  	cols = 1 << cols_log2;
>  
>  	if (rows > 4 || cols > 64) {
> -		mtk_vcodec_err(instance, "tile_rows %u tile_cols %u\n",
> -			       rows, cols);
> +		mtk_vdec_err(instance->ctx, "tile_rows %u tile_cols %u\n", rows, cols);
>  		return -EINVAL;
>  	}
>  
>  	offset = uh->uncompressed_header_size +
>  		uh->header_size_in_bytes;
>  	if (bs->size <= offset) {
> -		mtk_vcodec_err(instance, "bs size %zu tile offset %u\n",
> -			       bs->size, offset);
> +		mtk_vdec_err(instance->ctx, "bs size %zu tile offset %u\n", bs->size, offset);
>  		return -EINVAL;
>  	}
>  
> @@ -1596,14 +1594,12 @@ static int vdec_vp9_slice_update_single(struct vdec_vp9_slice_instance *instance
>  	vsi = &pfc->vsi;
>  	memcpy(&pfc->state[0], &vsi->state, sizeof(vsi->state));
>  
> -	mtk_vcodec_debug(instance, "Frame %u Y_CRC %08x %08x %08x %08x\n",
> -			 pfc->seq,
> -			 vsi->state.crc[0], vsi->state.crc[1],
> -			 vsi->state.crc[2], vsi->state.crc[3]);
> -	mtk_vcodec_debug(instance, "Frame %u C_CRC %08x %08x %08x %08x\n",
> -			 pfc->seq,
> -			 vsi->state.crc[4], vsi->state.crc[5],
> -			 vsi->state.crc[6], vsi->state.crc[7]);
> +	mtk_vdec_debug(instance->ctx, "Frame %u Y_CRC %08x %08x %08x %08x\n",
> +		       pfc->seq, vsi->state.crc[0], vsi->state.crc[1],
> +		       vsi->state.crc[2], vsi->state.crc[3]);
> +	mtk_vdec_debug(instance->ctx, "Frame %u C_CRC %08x %08x %08x %08x\n",
> +		       pfc->seq, vsi->state.crc[4], vsi->state.crc[5],
> +		       vsi->state.crc[6], vsi->state.crc[7]);
>  
>  	vdec_vp9_slice_update_prob(instance, vsi);
>  
> @@ -1624,10 +1620,10 @@ static int vdec_vp9_slice_update_lat(struct vdec_vp9_slice_instance *instance,
>  	vsi = &pfc->vsi;
>  	memcpy(&pfc->state[0], &vsi->state, sizeof(vsi->state));
>  
> -	mtk_vcodec_debug(instance, "Frame %u LAT CRC 0x%08x %lx %lx\n",
> -			 pfc->seq, vsi->state.crc[0],
> -			 (unsigned long)vsi->trans.dma_addr,
> -			 (unsigned long)vsi->trans.dma_addr_end);
> +	mtk_vdec_debug(instance->ctx, "Frame %u LAT CRC 0x%08x %lx %lx\n",
> +		       pfc->seq, vsi->state.crc[0],
> +		       (unsigned long)vsi->trans.dma_addr,
> +		       (unsigned long)vsi->trans.dma_addr_end);
>  
>  	/* buffer full, need to re-decode */
>  	if (vsi->state.full) {
> @@ -1844,14 +1840,12 @@ static int vdec_vp9_slice_update_core(struct vdec_vp9_slice_instance *instance,
>  	vsi = &pfc->vsi;
>  	memcpy(&pfc->state[1], &vsi->state, sizeof(vsi->state));
>  
> -	mtk_vcodec_debug(instance, "Frame %u Y_CRC %08x %08x %08x %08x\n",
> -			 pfc->seq,
> -			 vsi->state.crc[0], vsi->state.crc[1],
> -			 vsi->state.crc[2], vsi->state.crc[3]);
> -	mtk_vcodec_debug(instance, "Frame %u C_CRC %08x %08x %08x %08x\n",
> -			 pfc->seq,
> -			 vsi->state.crc[4], vsi->state.crc[5],
> -			 vsi->state.crc[6], vsi->state.crc[7]);
> +	mtk_vdec_debug(instance->ctx, "Frame %u Y_CRC %08x %08x %08x %08x\n",
> +		       pfc->seq, vsi->state.crc[0], vsi->state.crc[1],
> +		       vsi->state.crc[2], vsi->state.crc[3]);
> +	mtk_vdec_debug(instance->ctx, "Frame %u C_CRC %08x %08x %08x %08x\n",
> +		       pfc->seq, vsi->state.crc[4], vsi->state.crc[5],
> +		       vsi->state.crc[6], vsi->state.crc[7]);
>  
>  	return 0;
>  }
> @@ -1874,7 +1868,7 @@ static int vdec_vp9_slice_init(struct mtk_vcodec_ctx *ctx)
>  
>  	ret = vpu_dec_init(&instance->vpu);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "failed to init vpu dec, ret %d\n", ret);
> +		mtk_vdec_err(ctx, "failed to init vpu dec, ret %d\n", ret);
>  		goto error_vpu_init;
>  	}
>  
> @@ -1882,7 +1876,7 @@ static int vdec_vp9_slice_init(struct mtk_vcodec_ctx *ctx)
>  
>  	vsi = instance->vpu.vsi;
>  	if (!vsi) {
> -		mtk_vcodec_err(instance, "failed to get VP9 vsi\n");
> +		mtk_vdec_err(ctx, "failed to get VP9 vsi\n");
>  		ret = -EINVAL;
>  		goto error_vsi;
>  	}
> @@ -1890,7 +1884,7 @@ static int vdec_vp9_slice_init(struct mtk_vcodec_ctx *ctx)
>  	instance->core_vsi = mtk_vcodec_fw_map_dm_addr(ctx->dev->fw_handler,
>  						       (u32)vsi->core_vsi);
>  	if (!instance->core_vsi) {
> -		mtk_vcodec_err(instance, "failed to get VP9 core vsi\n");
> +		mtk_vdec_err(ctx, "failed to get VP9 core vsi\n");
>  		ret = -EINVAL;
>  		goto error_vsi;
>  	}
> @@ -1931,7 +1925,7 @@ static int vdec_vp9_slice_flush(void *h_vdec, struct mtk_vcodec_mem *bs,
>  {
>  	struct vdec_vp9_slice_instance *instance = h_vdec;
>  
> -	mtk_vcodec_debug(instance, "flush ...\n");
> +	mtk_vdec_debug(instance->ctx, "flush ...\n");
>  	if (instance->ctx->dev->vdec_pdata->hw_arch != MTK_VDEC_PURE_SINGLE_CORE)
>  		vdec_msg_queue_wait_lat_buf_full(&instance->ctx->msg_queue);
>  	return vpu_dec_reset(&instance->vpu);
> @@ -1942,8 +1936,7 @@ static void vdec_vp9_slice_get_pic_info(struct vdec_vp9_slice_instance *instance
>  	struct mtk_vcodec_ctx *ctx = instance->ctx;
>  	unsigned int data[3];
>  
> -	mtk_vcodec_debug(instance, "w %u h %u\n",
> -			 ctx->picinfo.pic_w, ctx->picinfo.pic_h);
> +	mtk_vdec_debug(instance->ctx, "w %u h %u\n", ctx->picinfo.pic_w, ctx->picinfo.pic_h);
>  
>  	data[0] = ctx->picinfo.pic_w;
>  	data[1] = ctx->picinfo.pic_h;
> @@ -1975,11 +1968,10 @@ static int vdec_vp9_slice_get_param(void *h_vdec, enum vdec_get_param_type type,
>  		vdec_vp9_slice_get_dpb_size(instance, out);
>  		break;
>  	case GET_PARAM_CROP_INFO:
> -		mtk_vcodec_debug(instance, "No need to get vp9 crop information.");
> +		mtk_vdec_debug(instance->ctx, "No need to get vp9 crop information.");
>  		break;
>  	default:
> -		mtk_vcodec_err(instance, "invalid get parameter type=%d\n",
> -			       type);
> +		mtk_vdec_err(instance->ctx, "invalid get parameter type=%d\n", type);
>  		return -EINVAL;
>  	}
>  
> @@ -2011,14 +2003,14 @@ static int vdec_vp9_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	ret = vdec_vp9_slice_setup_single(instance, bs, fb, pfc);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "Failed to setup VP9 single ret %d\n", ret);
> +		mtk_vdec_err(ctx, "Failed to setup VP9 single ret %d\n", ret);
>  		return ret;
>  	}
>  	vdec_vp9_slice_vsi_to_remote(vsi, instance->vsi);
>  
>  	ret = vpu_dec_start(&instance->vpu, NULL, 0);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "Failed to dec VP9 ret %d\n", ret);
> +		mtk_vdec_err(ctx, "Failed to dec VP9 ret %d\n", ret);
>  		return ret;
>  	}
>  
> @@ -2026,7 +2018,7 @@ static int vdec_vp9_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  					   WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE);
>  	/* update remote vsi if decode timeout */
>  	if (ret) {
> -		mtk_vcodec_err(instance, "VP9 decode timeout %d\n", ret);
> +		mtk_vdec_err(ctx, "VP9 decode timeout %d\n", ret);
>  		WRITE_ONCE(instance->vsi->state.timeout, 1);
>  	}
>  
> @@ -2035,7 +2027,7 @@ static int vdec_vp9_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  	vdec_vp9_slice_vsi_from_remote(vsi, instance->vsi, 0);
>  	ret = vdec_vp9_slice_update_single(instance, pfc);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "VP9 decode error: %d\n", ret);
> +		mtk_vdec_err(ctx, "VP9 decode error: %d\n", ret);
>  		return ret;
>  	}
>  
> @@ -2069,7 +2061,7 @@ static int vdec_vp9_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	lat_buf = vdec_msg_queue_dqbuf(&instance->ctx->msg_queue.lat_ctx);
>  	if (!lat_buf) {
> -		mtk_vcodec_debug(instance, "Failed to get VP9 lat buf\n");
> +		mtk_vdec_debug(ctx, "Failed to get VP9 lat buf\n");
>  		return -EAGAIN;
>  	}
>  	pfc = (struct vdec_vp9_slice_pfc *)lat_buf->private_data;
> @@ -2081,14 +2073,14 @@ static int vdec_vp9_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	ret = vdec_vp9_slice_setup_lat(instance, bs, lat_buf, pfc);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "Failed to setup VP9 lat ret %d\n", ret);
> +		mtk_vdec_err(ctx, "Failed to setup VP9 lat ret %d\n", ret);
>  		goto err_free_fb_out;
>  	}
>  	vdec_vp9_slice_vsi_to_remote(vsi, instance->vsi);
>  
>  	ret = vpu_dec_start(&instance->vpu, NULL, 0);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "Failed to dec VP9 ret %d\n", ret);
> +		mtk_vdec_err(ctx, "Failed to dec VP9 ret %d\n", ret);
>  		goto err_free_fb_out;
>  	}
>  
> @@ -2097,7 +2089,7 @@ static int vdec_vp9_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  						   WAIT_INTR_TIMEOUT_MS, MTK_VDEC_LAT0);
>  		/* update remote vsi if decode timeout */
>  		if (ret) {
> -			mtk_vcodec_err(instance, "VP9 decode timeout %d pic %d\n", ret, pfc->seq);
> +			mtk_vdec_err(ctx, "VP9 decode timeout %d pic %d\n", ret, pfc->seq);
>  			WRITE_ONCE(instance->vsi->state.timeout, 1);
>  		}
>  		vpu_dec_end(&instance->vpu);
> @@ -2108,13 +2100,13 @@ static int vdec_vp9_slice_lat_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
>  
>  	/* LAT trans full, no more UBE or decode timeout */
>  	if (ret) {
> -		mtk_vcodec_err(instance, "VP9 decode error: %d\n", ret);
> +		mtk_vdec_err(ctx, "VP9 decode error: %d\n", ret);
>  		goto err_free_fb_out;
>  	}
>  
> -	mtk_vcodec_debug(instance, "lat dma addr: 0x%lx 0x%lx\n",
> -			 (unsigned long)pfc->vsi.trans.dma_addr,
> -			 (unsigned long)pfc->vsi.trans.dma_addr_end);
> +	mtk_vdec_debug(ctx, "lat dma addr: 0x%lx 0x%lx\n",
> +		       (unsigned long)pfc->vsi.trans.dma_addr,
> +		       (unsigned long)pfc->vsi.trans.dma_addr_end);
>  
>  	vdec_msg_queue_update_ube_wptr(&ctx->msg_queue,
>  				       vsi->trans.dma_addr_end +
> @@ -2169,14 +2161,14 @@ static int vdec_vp9_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  
>  	ret = vdec_vp9_slice_setup_core(instance, fb, lat_buf, pfc);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "vdec_vp9_slice_setup_core\n");
> +		mtk_vdec_err(ctx, "vdec_vp9_slice_setup_core\n");
>  		goto err;
>  	}
>  	vdec_vp9_slice_vsi_to_remote(&pfc->vsi, instance->core_vsi);
>  
>  	ret = vpu_dec_core(&instance->vpu);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "vpu_dec_core\n");
> +		mtk_vdec_err(ctx, "vpu_dec_core\n");
>  		goto err;
>  	}
>  
> @@ -2185,7 +2177,7 @@ static int vdec_vp9_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  						   WAIT_INTR_TIMEOUT_MS, MTK_VDEC_CORE);
>  		/* update remote vsi if decode timeout */
>  		if (ret) {
> -			mtk_vcodec_err(instance, "VP9 core timeout pic %d\n", pfc->seq);
> +			mtk_vdec_err(ctx, "VP9 core timeout pic %d\n", pfc->seq);
>  			WRITE_ONCE(instance->core_vsi->state.timeout, 1);
>  		}
>  		vpu_dec_core_end(&instance->vpu);
> @@ -2194,13 +2186,13 @@ static int vdec_vp9_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  	vdec_vp9_slice_vsi_from_remote(&pfc->vsi, instance->core_vsi, 1);
>  	ret = vdec_vp9_slice_update_core(instance, lat_buf, pfc);
>  	if (ret) {
> -		mtk_vcodec_err(instance, "vdec_vp9_slice_update_core\n");
> +		mtk_vdec_err(ctx, "vdec_vp9_slice_update_core\n");
>  		goto err;
>  	}
>  
>  	pfc->vsi.trans.dma_addr_end += ctx->msg_queue.wdma_addr.dma_addr;
> -	mtk_vcodec_debug(instance, "core dma_addr_end 0x%lx\n",
> -			 (unsigned long)pfc->vsi.trans.dma_addr_end);
> +	mtk_vdec_debug(ctx, "core dma_addr_end 0x%lx\n",
> +		       (unsigned long)pfc->vsi.trans.dma_addr_end);
>  	vdec_msg_queue_update_ube_rptr(&ctx->msg_queue, pfc->vsi.trans.dma_addr_end);
>  	ctx->dev->vdec_pdata->cap_to_disp(ctx, 0, lat_buf->src_buf_req);
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> index 60e5b70fa127..ab15ee6e2005 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> @@ -16,7 +16,7 @@ static void handle_init_ack_msg(const struct vdec_vpu_ipi_init_ack *msg)
>  	struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
>  					(unsigned long)msg->ap_inst_addr;
>  
> -	mtk_vcodec_debug(vpu, "+ ap_inst_addr = 0x%llx", msg->ap_inst_addr);
> +	mtk_vdec_debug(vpu->ctx, "+ ap_inst_addr = 0x%llx", msg->ap_inst_addr);
>  
>  	/* mapping VPU address to kernel virtual address */
>  	/* the content in vsi is initialized to 0 in VPU */
> @@ -24,7 +24,7 @@ static void handle_init_ack_msg(const struct vdec_vpu_ipi_init_ack *msg)
>  					     msg->vpu_inst_addr);
>  	vpu->inst_addr = msg->vpu_inst_addr;
>  
> -	mtk_vcodec_debug(vpu, "- vpu_inst_addr = 0x%x", vpu->inst_addr);
> +	mtk_vdec_debug(vpu->ctx, "- vpu_inst_addr = 0x%x", vpu->inst_addr);
>  
>  	/* Set default ABI version if dealing with unversioned firmware. */
>  	vpu->fw_abi_version = 0;
> @@ -40,7 +40,7 @@ static void handle_init_ack_msg(const struct vdec_vpu_ipi_init_ack *msg)
>  
>  	/* Check firmware version. */
>  	vpu->fw_abi_version = msg->vdec_abi_version;
> -	mtk_vcodec_debug(vpu, "firmware version 0x%x\n", vpu->fw_abi_version);
> +	mtk_vdec_debug(vpu->ctx, "firmware version 0x%x\n", vpu->fw_abi_version);
>  	switch (vpu->fw_abi_version) {
>  	case 1:
>  		break;
> @@ -48,8 +48,7 @@ static void handle_init_ack_msg(const struct vdec_vpu_ipi_init_ack *msg)
>  		vpu->inst_id = msg->inst_id;
>  		break;
>  	default:
> -		mtk_vcodec_err(vpu, "unhandled firmware version 0x%x\n",
> -			       vpu->fw_abi_version);
> +		mtk_vdec_err(vpu->ctx, "unhandled firmware version 0x%x\n", vpu->fw_abi_version);
>  		vpu->failure = 1;
>  		break;
>  	}
> @@ -60,7 +59,7 @@ static void handle_get_param_msg_ack(const struct vdec_vpu_ipi_get_param_ack *ms
>  	struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
>  					(unsigned long)msg->ap_inst_addr;
>  
> -	mtk_vcodec_debug(vpu, "+ ap_inst_addr = 0x%llx", msg->ap_inst_addr);
> +	mtk_vdec_debug(vpu->ctx, "+ ap_inst_addr = 0x%llx", msg->ap_inst_addr);
>  
>  	/* param_type is enum vdec_get_param_type */
>  	switch (msg->param_type) {
> @@ -69,7 +68,7 @@ static void handle_get_param_msg_ack(const struct vdec_vpu_ipi_get_param_ack *ms
>  		vpu->fb_sz[1] = msg->data[1];
>  		break;
>  	default:
> -		mtk_vcodec_err(vpu, "invalid get param type=%d", msg->param_type);
> +		mtk_vdec_err(vpu->ctx, "invalid get param type=%d", msg->param_type);
>  		vpu->failure = 1;
>  		break;
>  	}
> @@ -96,7 +95,7 @@ static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
>  		return;
>  	}
>  
> -	mtk_vcodec_debug(vpu, "+ id=%X", msg->msg_id);
> +	mtk_vdec_debug(vpu->ctx, "+ id=%X", msg->msg_id);
>  
>  	vpu->failure = msg->status;
>  	vpu->signaled = 1;
> @@ -119,12 +118,12 @@ static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
>  			handle_get_param_msg_ack(data);
>  			break;
>  		default:
> -			mtk_vcodec_err(vpu, "invalid msg=%X", msg->msg_id);
> +			mtk_vdec_err(vpu->ctx, "invalid msg=%X", msg->msg_id);
>  			break;
>  		}
>  	}
>  
> -	mtk_vcodec_debug(vpu, "- id=%X", msg->msg_id);
> +	mtk_vdec_debug(vpu->ctx, "- id=%X", msg->msg_id);
>  }
>  
>  static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
> @@ -132,7 +131,7 @@ static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
>  	int err, id, msgid;
>  
>  	msgid = *(uint32_t *)msg;
> -	mtk_vcodec_debug(vpu, "id=%X", msgid);
> +	mtk_vdec_debug(vpu->ctx, "id=%X", msgid);
>  
>  	vpu->failure = 0;
>  	vpu->signaled = 0;
> @@ -150,8 +149,8 @@ static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
>  	err = mtk_vcodec_fw_ipi_send(vpu->ctx->dev->fw_handler, id, msg,
>  				     len, 2000);
>  	if (err) {
> -		mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X status=%d",
> -			       id, msgid, err);
> +		mtk_vdec_err(vpu->ctx, "send fail vpu_id=%d msg_id=%X status=%d",
> +			     id, msgid, err);
>  		return err;
>  	}
>  
> @@ -163,7 +162,7 @@ static int vcodec_send_ap_ipi(struct vdec_vpu_inst *vpu, unsigned int msg_id)
>  	struct vdec_ap_ipi_cmd msg;
>  	int err = 0;
>  
> -	mtk_vcodec_debug(vpu, "+ id=%X", msg_id);
> +	mtk_vdec_debug(vpu->ctx, "+ id=%X", msg_id);
>  
>  	memset(&msg, 0, sizeof(msg));
>  	msg.msg_id = msg_id;
> @@ -174,7 +173,7 @@ static int vcodec_send_ap_ipi(struct vdec_vpu_inst *vpu, unsigned int msg_id)
>  	msg.codec_type = vpu->codec_type;
>  
>  	err = vcodec_vpu_send_msg(vpu, &msg, sizeof(msg));
> -	mtk_vcodec_debug(vpu, "- id=%X ret=%d", msg_id, err);
> +	mtk_vdec_debug(vpu->ctx, "- id=%X ret=%d", msg_id, err);
>  	return err;
>  }
>  
> @@ -189,7 +188,7 @@ int vpu_dec_init(struct vdec_vpu_inst *vpu)
>  	err = mtk_vcodec_fw_ipi_register(vpu->ctx->dev->fw_handler, vpu->id,
>  					 vpu->handler, "vdec", NULL);
>  	if (err) {
> -		mtk_vcodec_err(vpu, "vpu_ipi_register fail status=%d", err);
> +		mtk_vdec_err(vpu->ctx, "vpu_ipi_register fail status=%d", err);
>  		return err;
>  	}
>  
> @@ -198,7 +197,7 @@ int vpu_dec_init(struct vdec_vpu_inst *vpu)
>  						 vpu->core_id, vpu->handler,
>  						 "vdec", NULL);
>  		if (err) {
> -			mtk_vcodec_err(vpu, "vpu_ipi_register core fail status=%d", err);
> +			mtk_vdec_err(vpu->ctx, "vpu_ipi_register core fail status=%d", err);
>  			return err;
>  		}
>  	}
> @@ -208,10 +207,10 @@ int vpu_dec_init(struct vdec_vpu_inst *vpu)
>  	msg.ap_inst_addr = (unsigned long)vpu;
>  	msg.codec_type = vpu->codec_type;
>  
> -	mtk_vcodec_debug(vpu, "vdec_inst=%p", vpu);
> +	mtk_vdec_debug(vpu->ctx, "vdec_inst=%p", vpu);
>  
>  	err = vcodec_vpu_send_msg(vpu, (void *)&msg, sizeof(msg));
> -	mtk_vcodec_debug(vpu, "- ret=%d", err);
> +	mtk_vdec_debug(vpu->ctx, "- ret=%d", err);
>  	return err;
>  }
>  
> @@ -222,7 +221,7 @@ int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len)
>  	int err = 0;
>  
>  	if (len > ARRAY_SIZE(msg.data)) {
> -		mtk_vcodec_err(vpu, "invalid len = %d\n", len);
> +		mtk_vdec_err(vpu->ctx, "invalid len = %d\n", len);
>  		return -EINVAL;
>  	}
>  
> @@ -238,7 +237,7 @@ int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len)
>  	msg.codec_type = vpu->codec_type;
>  
>  	err = vcodec_vpu_send_msg(vpu, (void *)&msg, sizeof(msg));
> -	mtk_vcodec_debug(vpu, "- ret=%d", err);
> +	mtk_vdec_debug(vpu->ctx, "- ret=%d", err);
>  	return err;
>  }
>  
> @@ -249,7 +248,7 @@ int vpu_dec_get_param(struct vdec_vpu_inst *vpu, uint32_t *data,
>  	int err;
>  
>  	if (len > ARRAY_SIZE(msg.data)) {
> -		mtk_vcodec_err(vpu, "invalid len = %d\n", len);
> +		mtk_vdec_err(vpu->ctx, "invalid len = %d\n", len);
>  		return -EINVAL;
>  	}
>  
> @@ -261,7 +260,7 @@ int vpu_dec_get_param(struct vdec_vpu_inst *vpu, uint32_t *data,
>  	msg.codec_type = vpu->codec_type;
>  
>  	err = vcodec_vpu_send_msg(vpu, (void *)&msg, sizeof(msg));
> -	mtk_vcodec_debug(vpu, "- ret=%d", err);
> +	mtk_vdec_debug(vpu->ctx, "- ret=%d", err);
>  	return err;
>  }
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> index c821ed427537..5abc9c4e6d4f 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> @@ -240,13 +240,13 @@ static unsigned int h264_get_profile(struct venc_h264_inst *inst,
>  	case V4L2_MPEG_VIDEO_H264_PROFILE_HIGH:
>  		return 100;
>  	case V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE:
> -		mtk_vcodec_err(inst, "unsupported CONSTRAINED_BASELINE");
> +		mtk_venc_err(inst->ctx, "unsupported CONSTRAINED_BASELINE");
>  		return 0;
>  	case V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED:
> -		mtk_vcodec_err(inst, "unsupported EXTENDED");
> +		mtk_venc_err(inst->ctx, "unsupported EXTENDED");
>  		return 0;
>  	default:
> -		mtk_vcodec_debug(inst, "unsupported profile %d", profile);
> +		mtk_venc_debug(inst->ctx, "unsupported profile %d", profile);
>  		return 100;
>  	}
>  }
> @@ -256,7 +256,7 @@ static unsigned int h264_get_level(struct venc_h264_inst *inst,
>  {
>  	switch (level) {
>  	case V4L2_MPEG_VIDEO_H264_LEVEL_1B:
> -		mtk_vcodec_err(inst, "unsupported 1B");
> +		mtk_venc_err(inst->ctx, "unsupported 1B");
>  		return 0;
>  	case V4L2_MPEG_VIDEO_H264_LEVEL_1_0:
>  		return 10;
> @@ -289,7 +289,7 @@ static unsigned int h264_get_level(struct venc_h264_inst *inst,
>  	case V4L2_MPEG_VIDEO_H264_LEVEL_5_1:
>  		return 51;
>  	default:
> -		mtk_vcodec_debug(inst, "unsupported level %d", level);
> +		mtk_venc_debug(inst->ctx, "unsupported level %d", level);
>  		return 31;
>  	}
>  }
> @@ -360,8 +360,7 @@ static int h264_enc_alloc_work_buf(struct venc_h264_inst *inst, bool is_34bit)
>  			ret = mtk_vcodec_mem_alloc(inst->ctx,
>  						   &inst->work_bufs[i]);
>  			if (ret) {
> -				mtk_vcodec_err(inst,
> -					       "cannot allocate buf %d", i);
> +				mtk_venc_err(inst->ctx, "cannot allocate buf %d", i);
>  				goto err_alloc;
>  			}
>  			/*
> @@ -385,18 +384,17 @@ static int h264_enc_alloc_work_buf(struct venc_h264_inst *inst, bool is_34bit)
>  		else
>  			wb[i].iova = inst->work_bufs[i].dma_addr;
>  
> -		mtk_vcodec_debug(inst,
> -				 "work_buf[%d] va=0x%p iova=%pad size=%zu",
> -				 i, inst->work_bufs[i].va,
> -				 &inst->work_bufs[i].dma_addr,
> -				 inst->work_bufs[i].size);
> +		mtk_venc_debug(inst->ctx, "work_buf[%d] va=0x%p iova=%pad size=%zu",
> +			       i, inst->work_bufs[i].va,
> +			       &inst->work_bufs[i].dma_addr,
> +			       inst->work_bufs[i].size);
>  	}
>  
>  	/* the pps_buf is used by AP side only */
>  	inst->pps_buf.size = 128;
>  	ret = mtk_vcodec_mem_alloc(inst->ctx, &inst->pps_buf);
>  	if (ret) {
> -		mtk_vcodec_err(inst, "cannot allocate pps_buf");
> +		mtk_venc_err(inst->ctx, "cannot allocate pps_buf");
>  		goto err_alloc;
>  	}
>  
> @@ -416,7 +414,7 @@ static unsigned int h264_enc_wait_venc_done(struct venc_h264_inst *inst)
>  	if (!mtk_vcodec_wait_for_done_ctx(ctx, MTK_INST_IRQ_RECEIVED,
>  					  WAIT_INTR_TIMEOUT_MS, 0)) {
>  		irq_status = ctx->irq_status;
> -		mtk_vcodec_debug(inst, "irq_status %x <-", irq_status);
> +		mtk_venc_debug(ctx, "irq_status %x <-", irq_status);
>  	}
>  	return irq_status;
>  }
> @@ -450,13 +448,12 @@ static int h264_encode_sps(struct venc_h264_inst *inst,
>  
>  	irq_status = h264_enc_wait_venc_done(inst);
>  	if (irq_status != MTK_VENC_IRQ_STATUS_SPS) {
> -		mtk_vcodec_err(inst, "expect irq status %d",
> -			       MTK_VENC_IRQ_STATUS_SPS);
> +		mtk_venc_err(inst->ctx, "expect irq status %d", MTK_VENC_IRQ_STATUS_SPS);
>  		return -EINVAL;
>  	}
>  
>  	*bs_size = h264_read_reg(inst, VENC_PIC_BITSTREAM_BYTE_CNT);
> -	mtk_vcodec_debug(inst, "bs size %d <-", *bs_size);
> +	mtk_venc_debug(inst->ctx, "bs size %d <-", *bs_size);
>  
>  	return ret;
>  }
> @@ -474,13 +471,12 @@ static int h264_encode_pps(struct venc_h264_inst *inst,
>  
>  	irq_status = h264_enc_wait_venc_done(inst);
>  	if (irq_status != MTK_VENC_IRQ_STATUS_PPS) {
> -		mtk_vcodec_err(inst, "expect irq status %d",
> -			       MTK_VENC_IRQ_STATUS_PPS);
> +		mtk_venc_err(inst->ctx, "expect irq status %d", MTK_VENC_IRQ_STATUS_PPS);
>  		return -EINVAL;
>  	}
>  
>  	*bs_size = h264_read_reg(inst, VENC_PIC_BITSTREAM_BYTE_CNT);
> -	mtk_vcodec_debug(inst, "bs size %d <-", *bs_size);
> +	mtk_venc_debug(inst->ctx, "bs size %d <-", *bs_size);
>  
>  	return ret;
>  }
> @@ -519,7 +515,7 @@ static int h264_encode_frame(struct venc_h264_inst *inst,
>  	struct venc_frame_info frame_info;
>  	struct mtk_vcodec_ctx *ctx = inst->ctx;
>  
> -	mtk_vcodec_debug(inst, "frm_cnt = %d\n ", inst->frm_cnt);
> +	mtk_venc_debug(ctx, "frm_cnt = %d\n ", inst->frm_cnt);
>  
>  	if (MTK_ENC_IOVA_IS_34BIT(ctx)) {
>  		gop_size = inst->vsi_34->config.gop_size;
> @@ -532,9 +528,9 @@ static int h264_encode_frame(struct venc_h264_inst *inst,
>  	frame_info.skip_frm_count = inst->skip_frm_cnt;
>  	frame_info.frm_type = h264_frame_type(inst->frm_cnt, gop_size,
>  					      intra_period);
> -	mtk_vcodec_debug(inst, "frm_count = %d,skip_frm_count =%d,frm_type=%d.\n",
> -			 frame_info.frm_count, frame_info.skip_frm_count,
> -			 frame_info.frm_type);
> +	mtk_venc_debug(ctx, "frm_count = %d,skip_frm_count =%d,frm_type=%d.\n",
> +		       frame_info.frm_count, frame_info.skip_frm_count,
> +		       frame_info.frm_type);
>  
>  	ret = vpu_enc_encode(&inst->vpu_inst, H264_BS_MODE_FRAME,
>  			     frm_buf, bs_buf, &frame_info);
> @@ -557,15 +553,15 @@ static int h264_encode_frame(struct venc_h264_inst *inst,
>  
>  	irq_status = h264_enc_wait_venc_done(inst);
>  	if (irq_status != MTK_VENC_IRQ_STATUS_FRM) {
> -		mtk_vcodec_err(inst, "irq_status=%d failed", irq_status);
> +		mtk_venc_err(ctx, "irq_status=%d failed", irq_status);
>  		return -EIO;
>  	}
>  
>  	*bs_size = h264_read_reg(inst, VENC_PIC_BITSTREAM_BYTE_CNT);
>  
>  	++inst->frm_cnt;
> -	mtk_vcodec_debug(inst, "frm %d bs_size %d key_frm %d <-",
> -			 inst->frm_cnt, *bs_size, inst->vpu_inst.is_key_frm);
> +	mtk_venc_debug(ctx, "frm %d bs_size %d key_frm %d <-",
> +		       inst->frm_cnt, *bs_size, inst->vpu_inst.is_key_frm);
>  
>  	return 0;
>  }
> @@ -576,7 +572,7 @@ static void h264_encode_filler(struct venc_h264_inst *inst, void *buf,
>  	unsigned char *p = buf;
>  
>  	if (size < H264_FILLER_MARKER_SIZE) {
> -		mtk_vcodec_err(inst, "filler size too small %d", size);
> +		mtk_venc_err(inst->ctx, "filler size too small %d", size);
>  		return;
>  	}
>  
> @@ -626,7 +622,7 @@ static int h264_enc_encode(void *handle,
>  	struct venc_h264_inst *inst = (struct venc_h264_inst *)handle;
>  	struct mtk_vcodec_ctx *ctx = inst->ctx;
>  
> -	mtk_vcodec_debug(inst, "opt %d ->", opt);
> +	mtk_venc_debug(ctx, "opt %d ->", opt);
>  
>  	enable_irq(ctx->dev->enc_irq);
>  
> @@ -661,7 +657,7 @@ static int h264_enc_encode(void *handle,
>  			break;
>  		}
>  
> -		mtk_vcodec_debug(inst, "h264_encode_frame prepend SPS/PPS");
> +		mtk_venc_debug(ctx, "h264_encode_frame prepend SPS/PPS");
>  
>  		ret = h264_encode_header(inst, bs_buf, &bs_size_hdr);
>  		if (ret)
> @@ -688,9 +684,8 @@ static int h264_enc_encode(void *handle,
>  
>  		result->bs_size = hdr_sz + filler_sz + bs_size_frm;
>  
> -		mtk_vcodec_debug(inst, "hdr %d filler %d frame %d bs %d",
> -				 hdr_sz, filler_sz, bs_size_frm,
> -				 result->bs_size);
> +		mtk_venc_debug(ctx, "hdr %d filler %d frame %d bs %d",
> +			       hdr_sz, filler_sz, bs_size_frm, result->bs_size);
>  
>  		inst->prepend_hdr = 0;
>  		result->is_key_frm = inst->vpu_inst.is_key_frm;
> @@ -698,7 +693,7 @@ static int h264_enc_encode(void *handle,
>  	}
>  
>  	default:
> -		mtk_vcodec_err(inst, "venc_start_opt %d not supported", opt);
> +		mtk_venc_err(ctx, "venc_start_opt %d not supported", opt);
>  		ret = -EINVAL;
>  		break;
>  	}
> @@ -706,7 +701,7 @@ static int h264_enc_encode(void *handle,
>  encode_err:
>  
>  	disable_irq(ctx->dev->enc_irq);
> -	mtk_vcodec_debug(inst, "opt %d <-", opt);
> +	mtk_venc_debug(ctx, "opt %d <-", opt);
>  
>  	return ret;
>  }
> @@ -758,7 +753,7 @@ static int h264_enc_set_param(void *handle,
>  	struct mtk_vcodec_ctx *ctx = inst->ctx;
>  	const bool is_34bit = MTK_ENC_IOVA_IS_34BIT(ctx);
>  
> -	mtk_vcodec_debug(inst, "->type=%d", type);
> +	mtk_venc_debug(ctx, "->type=%d", type);
>  
>  	switch (type) {
>  	case VENC_SET_PARAM_ENC:
> @@ -781,7 +776,7 @@ static int h264_enc_set_param(void *handle,
>  
>  	case VENC_SET_PARAM_PREPEND_HEADER:
>  		inst->prepend_hdr = 1;
> -		mtk_vcodec_debug(inst, "set prepend header mode");
> +		mtk_venc_debug(ctx, "set prepend header mode");
>  		break;
>  	case VENC_SET_PARAM_FORCE_INTRA:
>  	case VENC_SET_PARAM_GOP_SIZE:
> diff --git a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> index ddcdb565db17..ff54064497f1 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> @@ -171,8 +171,7 @@ static int vp8_enc_alloc_work_buf(struct venc_vp8_inst *inst)
>  		inst->work_bufs[i].size = wb[i].size;
>  		ret = mtk_vcodec_mem_alloc(inst->ctx, &inst->work_bufs[i]);
>  		if (ret) {
> -			mtk_vcodec_err(inst,
> -				       "cannot alloc work_bufs[%d]", i);
> +			mtk_venc_err(inst->ctx, "cannot alloc work_bufs[%d]", i);
>  			goto err_alloc;
>  		}
>  		/*
> @@ -193,11 +192,10 @@ static int vp8_enc_alloc_work_buf(struct venc_vp8_inst *inst)
>  		}
>  		wb[i].iova = inst->work_bufs[i].dma_addr;
>  
> -		mtk_vcodec_debug(inst,
> -				 "work_bufs[%d] va=0x%p,iova=%pad,size=%zu",
> -				 i, inst->work_bufs[i].va,
> -				 &inst->work_bufs[i].dma_addr,
> -				 inst->work_bufs[i].size);
> +		mtk_venc_debug(inst->ctx, "work_bufs[%d] va=0x%p,iova=%pad,size=%zu",
> +			       i, inst->work_bufs[i].va,
> +			       &inst->work_bufs[i].dma_addr,
> +			       inst->work_bufs[i].size);
>  	}
>  
>  	return ret;
> @@ -216,7 +214,7 @@ static unsigned int vp8_enc_wait_venc_done(struct venc_vp8_inst *inst)
>  	if (!mtk_vcodec_wait_for_done_ctx(ctx, MTK_INST_IRQ_RECEIVED,
>  					  WAIT_INTR_TIMEOUT_MS, 0)) {
>  		irq_status = ctx->irq_status;
> -		mtk_vcodec_debug(inst, "isr return %x", irq_status);
> +		mtk_venc_debug(ctx, "isr return %x", irq_status);
>  	}
>  	return irq_status;
>  }
> @@ -261,8 +259,7 @@ static int vp8_enc_compose_one_frame(struct venc_vp8_inst *inst,
>  	}
>  
>  	if (bs_buf->size < bs_hdr_len + bs_frm_size + ac_tag_size) {
> -		mtk_vcodec_err(inst, "bitstream buf size is too small(%zu)",
> -			       bs_buf->size);
> +		mtk_venc_err(inst->ctx, "bitstream buf size is too small(%zu)", bs_buf->size);
>  		return -EINVAL;
>  	}
>  
> @@ -292,7 +289,7 @@ static int vp8_enc_encode_frame(struct venc_vp8_inst *inst,
>  	int ret = 0;
>  	unsigned int irq_status;
>  
> -	mtk_vcodec_debug(inst, "->frm_cnt=%d", inst->frm_cnt);
> +	mtk_venc_debug(inst->ctx, "->frm_cnt=%d", inst->frm_cnt);
>  
>  	ret = vpu_enc_encode(&inst->vpu_inst, 0, frm_buf, bs_buf, NULL);
>  	if (ret)
> @@ -300,18 +297,17 @@ static int vp8_enc_encode_frame(struct venc_vp8_inst *inst,
>  
>  	irq_status = vp8_enc_wait_venc_done(inst);
>  	if (irq_status != MTK_VENC_IRQ_STATUS_FRM) {
> -		mtk_vcodec_err(inst, "irq_status=%d failed", irq_status);
> +		mtk_venc_err(inst->ctx, "irq_status=%d failed", irq_status);
>  		return -EIO;
>  	}
>  
>  	if (vp8_enc_compose_one_frame(inst, bs_buf, bs_size)) {
> -		mtk_vcodec_err(inst, "vp8_enc_compose_one_frame failed");
> +		mtk_venc_err(inst->ctx, "vp8_enc_compose_one_frame failed");
>  		return -EINVAL;
>  	}
>  
>  	inst->frm_cnt++;
> -	mtk_vcodec_debug(inst, "<-size=%d key_frm=%d", *bs_size,
> -			 inst->vpu_inst.is_key_frm);
> +	mtk_venc_debug(inst->ctx, "<-size=%d key_frm=%d", *bs_size, inst->vpu_inst.is_key_frm);
>  
>  	return ret;
>  }
> @@ -364,7 +360,7 @@ static int vp8_enc_encode(void *handle,
>  		break;
>  
>  	default:
> -		mtk_vcodec_err(inst, "opt not support:%d", opt);
> +		mtk_venc_err(ctx, "opt not support:%d", opt);
>  		ret = -EINVAL;
>  		break;
>  	}
> @@ -382,7 +378,7 @@ static int vp8_enc_set_param(void *handle,
>  	int ret = 0;
>  	struct venc_vp8_inst *inst = (struct venc_vp8_inst *)handle;
>  
> -	mtk_vcodec_debug(inst, "->type=%d", type);
> +	mtk_venc_debug(inst->ctx, "->type=%d", type);
>  
>  	switch (type) {
>  	case VENC_SET_PARAM_ENC:
> @@ -413,7 +409,7 @@ static int vp8_enc_set_param(void *handle,
>  	 */
>  	case VENC_SET_PARAM_TS_MODE:
>  		inst->ts_mode = 1;
> -		mtk_vcodec_debug(inst, "set ts_mode");
> +		mtk_venc_debug(inst->ctx, "set ts_mode");
>  		break;
>  
>  	default:
> diff --git a/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c b/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> index 63ebab28242c..c69f66b6d341 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> @@ -22,14 +22,13 @@ static void handle_enc_init_msg(struct venc_vpu_inst *vpu, const void *data)
>  		return;
>  
>  	/* Check firmware version. */
> -	mtk_vcodec_debug(vpu, "firmware version: 0x%x\n",
> -			 msg->venc_abi_version);
> +	mtk_venc_debug(vpu->ctx, "firmware version: 0x%x\n", msg->venc_abi_version);
>  	switch (msg->venc_abi_version) {
>  	case 1:
>  		break;
>  	default:
> -		mtk_vcodec_err(vpu, "unhandled firmware version 0x%x\n",
> -			       msg->venc_abi_version);
> +		mtk_venc_err(vpu->ctx, "unhandled firmware version 0x%x\n",
> +			     msg->venc_abi_version);
>  		vpu->failure = 1;
>  		break;
>  	}
> @@ -50,13 +49,12 @@ static void vpu_enc_ipi_handler(void *data, unsigned int len, void *priv)
>  	struct venc_vpu_inst *vpu =
>  		(struct venc_vpu_inst *)(unsigned long)msg->venc_inst;
>  
> -	mtk_vcodec_debug(vpu, "msg_id %x inst %p status %d",
> -			 msg->msg_id, vpu, msg->status);
> +	mtk_venc_debug(vpu->ctx, "msg_id %x inst %p status %d", msg->msg_id, vpu, msg->status);
>  
>  	vpu->signaled = 1;
>  	vpu->failure = (msg->status != VENC_IPI_MSG_STATUS_OK);
>  	if (vpu->failure) {
> -		mtk_vcodec_err(vpu, "vpu enc status failure %d", vpu->failure);
> +		mtk_venc_err(vpu->ctx, "vpu enc status failure %d", vpu->failure);
>  		return;
>  	}
>  
> @@ -72,7 +70,7 @@ static void vpu_enc_ipi_handler(void *data, unsigned int len, void *priv)
>  	case VPU_IPIMSG_ENC_DEINIT_DONE:
>  		break;
>  	default:
> -		mtk_vcodec_err(vpu, "unknown msg id %x", msg->msg_id);
> +		mtk_venc_err(vpu->ctx, "unknown msg id %x", msg->msg_id);
>  		break;
>  	}
>  }
> @@ -83,15 +81,15 @@ static int vpu_enc_send_msg(struct venc_vpu_inst *vpu, void *msg,
>  	int status;
>  
>  	if (!vpu->ctx->dev->fw_handler) {
> -		mtk_vcodec_err(vpu, "inst dev is NULL");
> +		mtk_venc_err(vpu->ctx, "inst dev is NULL");
>  		return -EINVAL;
>  	}
>  
>  	status = mtk_vcodec_fw_ipi_send(vpu->ctx->dev->fw_handler, vpu->id, msg,
>  					len, 2000);
>  	if (status) {
> -		mtk_vcodec_err(vpu, "vpu_ipi_send msg_id %x len %d fail %d",
> -			       *(uint32_t *)msg, len, status);
> +		mtk_venc_err(vpu->ctx, "vpu_ipi_send msg_id %x len %d fail %d",
> +			     *(uint32_t *)msg, len, status);
>  		return -EINVAL;
>  	}
>  	if (vpu->failure)
> @@ -113,7 +111,7 @@ int vpu_enc_init(struct venc_vpu_inst *vpu)
>  					    vpu_enc_ipi_handler, "venc", NULL);
>  
>  	if (status) {
> -		mtk_vcodec_err(vpu, "vpu_ipi_register fail %d", status);
> +		mtk_venc_err(vpu->ctx, "vpu_ipi_register fail %d", status);
>  		return -EINVAL;
>  	}
>  
> @@ -121,7 +119,7 @@ int vpu_enc_init(struct venc_vpu_inst *vpu)
>  	out.msg_id = AP_IPIMSG_ENC_INIT;
>  	out.venc_inst = (unsigned long)vpu;
>  	if (vpu_enc_send_msg(vpu, &out, sizeof(out))) {
> -		mtk_vcodec_err(vpu, "AP_IPIMSG_ENC_INIT fail");
> +		mtk_venc_err(vpu->ctx, "AP_IPIMSG_ENC_INIT fail");
>  		return -EINVAL;
>  	}
>  
> @@ -157,7 +155,7 @@ int vpu_enc_set_param(struct venc_vpu_inst *vpu,
>  		sizeof(struct venc_ap_ipi_msg_set_param);
>  	struct venc_ap_ipi_msg_set_param_ext out;
>  
> -	mtk_vcodec_debug(vpu, "id %d ->", id);
> +	mtk_venc_debug(vpu->ctx, "id %d ->", id);
>  
>  	memset(&out, 0, sizeof(out));
>  	out.base.msg_id = AP_IPIMSG_ENC_SET_PARAM;
> @@ -199,16 +197,15 @@ int vpu_enc_set_param(struct venc_vpu_inst *vpu,
>  		out.base.data_item = 0;
>  		break;
>  	default:
> -		mtk_vcodec_err(vpu, "id %d not supported", id);
> +		mtk_venc_err(vpu->ctx, "id %d not supported", id);
>  		return -EINVAL;
>  	}
>  	if (vpu_enc_send_msg(vpu, &out, msg_size)) {
> -		mtk_vcodec_err(vpu,
> -			       "AP_IPIMSG_ENC_SET_PARAM %d fail", id);
> +		mtk_venc_err(vpu->ctx, "AP_IPIMSG_ENC_SET_PARAM %d fail", id);
>  		return -EINVAL;
>  	}
>  
> -	mtk_vcodec_debug(vpu, "id %d <-", id);
> +	mtk_venc_debug(vpu->ctx, "id %d <-", id);
>  
>  	return 0;
>  }
> @@ -225,7 +222,7 @@ static int vpu_enc_encode_32bits(struct venc_vpu_inst *vpu,
>  		sizeof(struct venc_ap_ipi_msg_enc);
>  	struct venc_ap_ipi_msg_enc_ext out;
>  
> -	mtk_vcodec_debug(vpu, "bs_mode %d ->", bs_mode);
> +	mtk_venc_debug(vpu->ctx, "bs_mode %d ->", bs_mode);
>  
>  	memset(&out, 0, sizeof(out));
>  	out.base.msg_id = AP_IPIMSG_ENC_ENCODE;
> @@ -239,7 +236,7 @@ static int vpu_enc_encode_32bits(struct venc_vpu_inst *vpu,
>  			out.base.input_addr[1] = frm_buf->fb_addr[1].dma_addr;
>  			out.base.input_addr[2] = frm_buf->fb_addr[2].dma_addr;
>  		} else {
> -			mtk_vcodec_err(vpu, "dma_addr not align to 16");
> +			mtk_venc_err(vpu->ctx, "dma_addr not align to 16");
>  			return -EINVAL;
>  		}
>  	}
> @@ -254,8 +251,7 @@ static int vpu_enc_encode_32bits(struct venc_vpu_inst *vpu,
>  		out.data[2] = frame_info->frm_type;
>  	}
>  	if (vpu_enc_send_msg(vpu, &out, msg_size)) {
> -		mtk_vcodec_err(vpu, "AP_IPIMSG_ENC_ENCODE %d fail",
> -			       bs_mode);
> +		mtk_venc_err(vpu->ctx, "AP_IPIMSG_ENC_ENCODE %d fail", bs_mode);
>  		return -EINVAL;
>  	}
>  
> @@ -271,7 +267,7 @@ static int vpu_enc_encode_34bits(struct venc_vpu_inst *vpu,
>  	struct venc_ap_ipi_msg_enc_ext_34 out;
>  	size_t msg_size = sizeof(struct venc_ap_ipi_msg_enc_ext_34);
>  
> -	mtk_vcodec_debug(vpu, "bs_mode %d ->", bs_mode);
> +	mtk_venc_debug(vpu->ctx, "bs_mode %d ->", bs_mode);
>  
>  	memset(&out, 0, sizeof(out));
>  	out.msg_id = AP_IPIMSG_ENC_ENCODE;
> @@ -286,7 +282,7 @@ static int vpu_enc_encode_34bits(struct venc_vpu_inst *vpu,
>  			out.input_addr[1] = frm_buf->fb_addr[1].dma_addr;
>  			out.input_addr[2] = frm_buf->fb_addr[2].dma_addr;
>  		} else {
> -			mtk_vcodec_err(vpu, "dma_addr not align to 16");
> +			mtk_venc_err(vpu->ctx, "dma_addr not align to 16");
>  			return -EINVAL;
>  		}
>  	}
> @@ -301,8 +297,7 @@ static int vpu_enc_encode_34bits(struct venc_vpu_inst *vpu,
>  		out.data[2] = frame_info->frm_type;
>  	}
>  	if (vpu_enc_send_msg(vpu, &out, msg_size)) {
> -		mtk_vcodec_err(vpu, "AP_IPIMSG_ENC_ENCODE %d fail",
> -			       bs_mode);
> +		mtk_venc_err(vpu->ctx, "AP_IPIMSG_ENC_ENCODE %d fail", bs_mode);
>  		return -EINVAL;
>  	}
>  
> @@ -326,8 +321,8 @@ int vpu_enc_encode(struct venc_vpu_inst *vpu, unsigned int bs_mode,
>  	if (ret)
>  		return ret;
>  
> -	mtk_vcodec_debug(vpu, "bs_mode %d state %d size %d key_frm %d <-",
> -			 bs_mode, vpu->state, vpu->bs_size, vpu->is_key_frm);
> +	mtk_venc_debug(vpu->ctx, "bs_mode %d state %d size %d key_frm %d <-",
> +		       bs_mode, vpu->state, vpu->bs_size, vpu->is_key_frm);
>  
>  	return 0;
>  }
> @@ -340,7 +335,7 @@ int vpu_enc_deinit(struct venc_vpu_inst *vpu)
>  	out.msg_id = AP_IPIMSG_ENC_DEINIT;
>  	out.vpu_inst_addr = vpu->inst_addr;
>  	if (vpu_enc_send_msg(vpu, &out, sizeof(out))) {
> -		mtk_vcodec_err(vpu, "AP_IPIMSG_ENC_DEINIT fail");
> +		mtk_venc_err(vpu->ctx, "AP_IPIMSG_ENC_DEINIT fail");
>  		return -EINVAL;
>  	}
>
Nicolas Dufresne July 3, 2023, 8:06 p.m. UTC | #2
Le lundi 26 juin 2023 à 11:53 +0800, Yunfei Dong a écrit :
> Adding different dev struct for encoder and decoder, remove
> 'struct mtk_vcodec_dev'.
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> ---
>  .../mediatek/vcodec/mtk_vcodec_com_drv.h      |  71 +++++
>  .../mediatek/vcodec/mtk_vcodec_dbgfs.c        |  51 ++-
>  .../mediatek/vcodec/mtk_vcodec_dbgfs.h        |  14 +-
>  .../platform/mediatek/vcodec/mtk_vcodec_dec.c |   4 +-
>  .../mediatek/vcodec/mtk_vcodec_dec_drv.c      |  19 +-
>  .../mediatek/vcodec/mtk_vcodec_dec_drv.h      | 172 +++++++++-
>  .../mediatek/vcodec/mtk_vcodec_dec_hw.c       |   5 +-
>  .../mediatek/vcodec/mtk_vcodec_dec_hw.h       |   4 +-
>  .../mediatek/vcodec/mtk_vcodec_dec_pm.c       |  10 +-
>  .../mediatek/vcodec/mtk_vcodec_dec_pm.h       |   2 +-
>  .../mediatek/vcodec/mtk_vcodec_dec_stateful.c |   3 +-
>  .../vcodec/mtk_vcodec_dec_stateless.c         |   5 +-
>  .../platform/mediatek/vcodec/mtk_vcodec_drv.h | 295 ------------------
>  .../platform/mediatek/vcodec/mtk_vcodec_enc.c |   5 +-
>  .../mediatek/vcodec/mtk_vcodec_enc_drv.c      |  15 +-
>  .../mediatek/vcodec/mtk_vcodec_enc_drv.h      |  93 +++++-
>  .../mediatek/vcodec/mtk_vcodec_enc_pm.c       |   4 +-
>  .../mediatek/vcodec/mtk_vcodec_enc_pm.h       |   4 +-
>  .../platform/mediatek/vcodec/mtk_vcodec_fw.c  |  12 +-
>  .../platform/mediatek/vcodec/mtk_vcodec_fw.h  |   3 +-
>  .../mediatek/vcodec/mtk_vcodec_fw_priv.h      |   3 +-
>  .../mediatek/vcodec/mtk_vcodec_fw_scp.c       |  21 +-
>  .../mediatek/vcodec/mtk_vcodec_fw_vpu.c       |  18 +-
>  .../mediatek/vcodec/mtk_vcodec_intr.c         |   4 +-
>  .../mediatek/vcodec/mtk_vcodec_util.c         |  10 +-
>  .../mediatek/vcodec/mtk_vcodec_util.h         |   8 +-
>  .../vcodec/vdec/vdec_h264_req_common.h        |   2 +-
>  .../vcodec/vdec/vdec_h264_req_multi_if.c      |   2 +-
>  .../platform/mediatek/vcodec/vdec_drv_if.h    |   1 -
>  .../platform/mediatek/vcodec/vdec_msg_queue.c |   4 +-
>  .../platform/mediatek/vcodec/vdec_msg_queue.h |   2 +-
>  .../platform/mediatek/vcodec/vdec_vpu_if.c    |   3 +-
>  .../mediatek/vcodec/venc/venc_h264_if.c       |   2 +-
>  .../mediatek/vcodec/venc/venc_vp8_if.c        |   2 +-
>  .../platform/mediatek/vcodec/venc_drv_base.h  |   2 +-
>  .../platform/mediatek/vcodec/venc_drv_if.c    |   4 +-
>  .../platform/mediatek/vcodec/venc_drv_if.h    |   3 +-
>  .../platform/mediatek/vcodec/venc_vpu_if.c    |   2 +-
>  38 files changed, 465 insertions(+), 419 deletions(-)
>  delete mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h
> 
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_com_drv.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_com_drv.h
> index 3b6e1faf60ce..6087e27bd604 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_com_drv.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_com_drv.h
> @@ -17,6 +17,77 @@
>  
>  #define MTK_VCODEC_MAX_PLANES	3
>  
> +#define WAIT_INTR_TIMEOUT_MS	1000
> +
> +/*
> + * enum mtk_q_type - Type of queue
> + */
> +enum mtk_q_type {
> +	MTK_Q_DATA_SRC = 0,
> +	MTK_Q_DATA_DST = 1,
> +};
> +
> +/*
> + * enum mtk_hw_reg_idx - MTK hw register base index
> + */
> +enum mtk_hw_reg_idx {
> +	VDEC_SYS,
> +	VDEC_MISC,
> +	VDEC_LD,
> +	VDEC_TOP,
> +	VDEC_CM,
> +	VDEC_AD,
> +	VDEC_AV,
> +	VDEC_PP,
> +	VDEC_HWD,
> +	VDEC_HWQ,
> +	VDEC_HWB,
> +	VDEC_HWG,
> +	NUM_MAX_VDEC_REG_BASE,
> +	/* h264 encoder */
> +	VENC_SYS = NUM_MAX_VDEC_REG_BASE,
> +	/* vp8 encoder */
> +	VENC_LT_SYS,
> +	NUM_MAX_VCODEC_REG_BASE
> +};
> +
> +/*
> + * struct mtk_vcodec_clk_info - Structure used to store clock name
> + */
> +struct mtk_vcodec_clk_info {
> +	const char	*clk_name;
> +	struct clk	*vcodec_clk;
> +};
> +
> +/*
> + * struct mtk_vcodec_clk - Structure used to store vcodec clock information
> + */
> +struct mtk_vcodec_clk {
> +	struct mtk_vcodec_clk_info	*clk_info;
> +	int	clk_num;
> +};
> +
> +/*
> + * struct mtk_vcodec_pm - Power management data structure
> + */
> +struct mtk_vcodec_pm {
> +	struct mtk_vcodec_clk	vdec_clk;
> +	struct mtk_vcodec_clk	venc_clk;
> +	struct device	*dev;
> +};
> +
> +/*
> + * enum mtk_vdec_hw_id - Hardware index used to separate
> + *                         different hardware
> + */
> +enum mtk_vdec_hw_id {
> +	MTK_VDEC_CORE,
> +	MTK_VDEC_LAT0,
> +	MTK_VDEC_LAT1,
> +	MTK_VDEC_LAT_SOC,
> +	MTK_VDEC_HW_MAX,
> +};
> +
>  /**
>   * enum mtk_instance_state - The state of an MTK Vcodec instance.
>   * @MTK_STATE_FREE: default state when instance is created
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> index 0f4bbfb3bba5..c6a02b33cc74 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> @@ -7,7 +7,8 @@
>  #include <linux/debugfs.h>
>  
>  #include "mtk_vcodec_dbgfs.h"
> -#include "mtk_vcodec_drv.h"
> +#include "mtk_vcodec_dec_drv.h"
> +#include "mtk_vcodec_enc_drv.h"
>  #include "mtk_vcodec_util.h"
>  
>  static void mtk_vdec_dbgfs_get_format_type(struct mtk_vcodec_dec_ctx *ctx, char *buf,
> @@ -72,7 +73,7 @@ static void mtk_vdec_dbgfs_get_help(char *buf, int *used, int total)
>  static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf,
>  				    size_t count, loff_t *ppos)
>  {
> -	struct mtk_vcodec_dev *vcodec_dev = filp->private_data;
> +	struct mtk_vcodec_dec_dev *vcodec_dev = filp->private_data;
>  	struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs;
>  
>  	mutex_lock(&dbgfs->dbgfs_lock);
> @@ -88,7 +89,7 @@ static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf,
>  static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf,
>  				   size_t count, loff_t *ppos)
>  {
> -	struct mtk_vcodec_dev *vcodec_dev = filp->private_data;
> +	struct mtk_vcodec_dec_dev *vcodec_dev = filp->private_data;
>  	struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs;
>  	struct mtk_vcodec_dbgfs_inst *dbgfs_inst;
>  	struct mtk_vcodec_dec_ctx *ctx;
> @@ -146,7 +147,7 @@ static const struct file_operations vdec_fops = {
>  void mtk_vcodec_dbgfs_create(struct mtk_vcodec_dec_ctx *ctx)
>  {
>  	struct mtk_vcodec_dbgfs_inst *dbgfs_inst;
> -	struct mtk_vcodec_dev *vcodec_dev = ctx->dev;
> +	struct mtk_vcodec_dec_dev *vcodec_dev = ctx->dev;
>  
>  	dbgfs_inst = kzalloc(sizeof(*dbgfs_inst), GFP_KERNEL);
>  	if (!dbgfs_inst)
> @@ -161,7 +162,7 @@ void mtk_vcodec_dbgfs_create(struct mtk_vcodec_dec_ctx *ctx)
>  }
>  EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_create);
>  
> -void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id)
> +void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dec_dev *vcodec_dev, int ctx_id)
>  {
>  	struct mtk_vcodec_dbgfs_inst *dbgfs_inst;
>  
> @@ -179,16 +180,13 @@ void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id)
>  }
>  EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_remove);
>  
> -void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool is_encode)
> +static void mtk_vcodec_dbgfs_vdec_init(struct mtk_vcodec_dec_dev *vcodec_dev)
>  {
>  	struct dentry *vcodec_root;
>  
> -	if (is_encode)
> -		vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-enc", NULL);
> -	else
> -		vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec", NULL);
> +	vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec", NULL);
>  	if (IS_ERR(vcodec_dev->dbgfs.vcodec_root))
> -		dev_err(&vcodec_dev->plat_dev->dev, "create vcodec dir err:%d\n",
> +		dev_err(&vcodec_dev->plat_dev->dev, "create vdec dir err:%d\n",
>  			IS_ERR(vcodec_dev->dbgfs.vcodec_root));
>  
>  	vcodec_root = vcodec_dev->dbgfs.vcodec_root;
> @@ -196,18 +194,39 @@ void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool is_encode)
>  	debugfs_create_x32("mtk_vcodec_dbg", 0644, vcodec_root, &mtk_vcodec_dbg);
>  
>  	vcodec_dev->dbgfs.inst_count = 0;
> -	if (is_encode)
> -		return;
> -
>  	INIT_LIST_HEAD(&vcodec_dev->dbgfs.dbgfs_head);
>  	debugfs_create_file("vdec", 0200, vcodec_root, vcodec_dev, &vdec_fops);
>  	mutex_init(&vcodec_dev->dbgfs.dbgfs_lock);
>  }
> +
> +static void mtk_vcodec_dbgfs_venc_init(struct mtk_vcodec_enc_dev *vcodec_dev)
> +{
> +	struct dentry *vcodec_root;
> +
> +	vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-enc", NULL);
> +	if (IS_ERR(vcodec_dev->dbgfs.vcodec_root))
> +		dev_err(&vcodec_dev->plat_dev->dev, "create venc dir err:%d\n",
> +			IS_ERR(vcodec_dev->dbgfs.vcodec_root));
> +
> +	vcodec_root = vcodec_dev->dbgfs.vcodec_root;
> +	debugfs_create_x32("mtk_v4l2_dbg_level", 0644, vcodec_root, &mtk_v4l2_dbg_level);
> +	debugfs_create_x32("mtk_vcodec_dbg", 0644, vcodec_root, &mtk_vcodec_dbg);
> +
> +	vcodec_dev->dbgfs.inst_count = 0;
> +}
> +
> +void mtk_vcodec_dbgfs_init(void *vcodec_dev, bool is_encode)
> +{
> +	if (is_encode)
> +		mtk_vcodec_dbgfs_venc_init(vcodec_dev);
> +	else
> +		mtk_vcodec_dbgfs_vdec_init(vcodec_dev);
> +}
>  EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_init);
>  
> -void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev)
> +void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dbgfs *dbgfs)
>  {
> -	debugfs_remove_recursive(vcodec_dev->dbgfs.vcodec_root);
> +	debugfs_remove_recursive(dbgfs->vcodec_root);
>  }
>  EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_deinit);
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
> index 372413d590c5..073d2fedb54a 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
> @@ -7,7 +7,7 @@
>  #ifndef __MTK_VCODEC_DBGFS_H__
>  #define __MTK_VCODEC_DBGFS_H__
>  
> -struct mtk_vcodec_dev;
> +struct mtk_vcodec_dec_dev;

I'm far in the review to think about this, but have you considered using a
shorter name, like mtk_vdec_dev ? That being said, I'm not requesting any
changes, this can happen later (or never).

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

>  struct mtk_vcodec_dec_ctx;
>  
>  /*
> @@ -51,23 +51,23 @@ struct mtk_vcodec_dbgfs {
>  
>  #if defined(CONFIG_DEBUG_FS)
>  void mtk_vcodec_dbgfs_create(struct mtk_vcodec_dec_ctx *ctx);
> -void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id);
> -void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool is_encode);
> -void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev);
> +void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dec_dev *vcodec_dev, int ctx_id);
> +void mtk_vcodec_dbgfs_init(void *vcodec_dev, bool is_encode);
> +void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dbgfs *dbgfs);
>  #else
>  static inline void mtk_vcodec_dbgfs_create(struct mtk_vcodec_dec_ctx *ctx)
>  {
>  }
>  
> -static inline void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id)
> +static inline void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dec_dev *vcodec_dev, int ctx_id)
>  {
>  }
>  
> -static inline void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool is_encode)
> +static inline void mtk_vcodec_dbgfs_init(void *vcodec_dev, bool is_encode)
>  {
>  }
>  
> -static inline void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev)
> +static inline void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dbgfs *dbgfs)
>  {
>  }
>  #endif
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> index 619ff3dd8d50..0363fec572e5 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> @@ -9,7 +9,7 @@
>  #include <media/v4l2-mem2mem.h>
>  #include <media/videobuf2-dma-contig.h>
>  
> -#include "mtk_vcodec_drv.h"
> +#include "mtk_vcodec_dec_drv.h"
>  #include "mtk_vcodec_dec.h"
>  #include "mtk_vcodec_intr.h"
>  #include "mtk_vcodec_util.h"
> @@ -890,7 +890,7 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
>  static void m2mops_vdec_device_run(void *priv)
>  {
>  	struct mtk_vcodec_dec_ctx *ctx = priv;
> -	struct mtk_vcodec_dev *dev = ctx->dev;
> +	struct mtk_vcodec_dec_dev *dev = ctx->dev;
>  
>  	queue_work(dev->decode_workqueue, &ctx->decode_work);
>  }
> 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 5609fd3268f2..8e3aea9a3ab0 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
> @@ -17,7 +17,6 @@
>  #include <media/videobuf2-dma-contig.h>
>  #include <media/v4l2-device.h>
>  
> -#include "mtk_vcodec_drv.h"
>  #include "mtk_vcodec_dec.h"
>  #include "mtk_vcodec_dec_hw.h"
>  #include "mtk_vcodec_dec_pm.h"
> @@ -25,7 +24,7 @@
>  #include "mtk_vcodec_util.h"
>  #include "mtk_vcodec_fw.h"
>  
> -static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dec_ctx *ctx, struct mtk_vcodec_dev *dev)
> +static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dec_ctx *ctx, struct mtk_vcodec_dec_dev *dev)
>  {
>  	switch (dev->vdec_pdata->hw_arch) {
>  	case MTK_VDEC_PURE_SINGLE_CORE:
> @@ -40,7 +39,7 @@ static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dec_ctx *ctx, struct mtk_vc
>  
>  static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
>  {
> -	struct mtk_vcodec_dev *dev = priv;
> +	struct mtk_vcodec_dec_dev *dev = priv;
>  	struct mtk_vcodec_dec_ctx *ctx;
>  	u32 cg_status = 0;
>  	unsigned int dec_done_status = 0;
> @@ -75,7 +74,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
>  	return IRQ_HANDLED;
>  }
>  
> -static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev)
> +static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dec_dev *dev)
>  {
>  	struct platform_device *pdev = dev->plat_dev;
>  	int reg_num, i;
> @@ -99,7 +98,7 @@ static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev)
>  	return 0;
>  }
>  
> -static int mtk_vcodec_init_dec_resources(struct mtk_vcodec_dev *dev)
> +static int mtk_vcodec_init_dec_resources(struct mtk_vcodec_dec_dev *dev)
>  {
>  	struct platform_device *pdev = dev->plat_dev;
>  	int ret;
> @@ -136,7 +135,7 @@ static int mtk_vcodec_init_dec_resources(struct mtk_vcodec_dev *dev)
>  
>  static int fops_vcodec_open(struct file *file)
>  {
> -	struct mtk_vcodec_dev *dev = video_drvdata(file);
> +	struct mtk_vcodec_dec_dev *dev = video_drvdata(file);
>  	struct mtk_vcodec_dec_ctx *ctx = NULL;
>  	int ret = 0, i, hw_count;
>  	struct vb2_queue *src_vq;
> @@ -233,7 +232,7 @@ static int fops_vcodec_open(struct file *file)
>  
>  static int fops_vcodec_release(struct file *file)
>  {
> -	struct mtk_vcodec_dev *dev = video_drvdata(file);
> +	struct mtk_vcodec_dec_dev *dev = video_drvdata(file);
>  	struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(file->private_data);
>  
>  	mtk_v4l2_vdec_dbg(0, ctx, "[%d] decoder", ctx->id);
> @@ -270,7 +269,7 @@ static const struct v4l2_file_operations mtk_vcodec_fops = {
>  
>  static int mtk_vcodec_probe(struct platform_device *pdev)
>  {
> -	struct mtk_vcodec_dev *dev;
> +	struct mtk_vcodec_dec_dev *dev;
>  	struct video_device *vfd_dec;
>  	phandle rproc_phandle;
>  	enum mtk_vcodec_fw_type fw_type;
> @@ -477,7 +476,7 @@ MODULE_DEVICE_TABLE(of, mtk_vcodec_match);
>  
>  static void mtk_vcodec_dec_remove(struct platform_device *pdev)
>  {
> -	struct mtk_vcodec_dev *dev = platform_get_drvdata(pdev);
> +	struct mtk_vcodec_dec_dev *dev = platform_get_drvdata(pdev);
>  
>  	destroy_workqueue(dev->decode_workqueue);
>  
> @@ -493,7 +492,7 @@ static void mtk_vcodec_dec_remove(struct platform_device *pdev)
>  	if (dev->vfd_dec)
>  		video_unregister_device(dev->vfd_dec);
>  
> -	mtk_vcodec_dbgfs_deinit(dev);
> +	mtk_vcodec_dbgfs_deinit(&dev->dbgfs);
>  	v4l2_device_unregister(&dev->v4l2_dev);
>  	if (!dev->vdec_pdata->is_subdev_supported)
>  		pm_runtime_disable(dev->pm.dev);
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h
> index 94870b651919..a18ba8f32d41 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h
> @@ -8,9 +8,49 @@
>  #define _MTK_VCODEC_DEC_DRV_H_
>  
>  #include "mtk_vcodec_com_drv.h"
> +#include "mtk_vcodec_dbgfs.h"
>  #include "mtk_vcodec_fw_priv.h"
> +#include "mtk_vcodec_util.h"
>  #include "vdec_msg_queue.h"
>  
> +#define MTK_VCODEC_DEC_NAME	"mtk-vcodec-dec"
> +
> +#define IS_VDEC_LAT_ARCH(hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE)
> +#define IS_VDEC_INNER_RACING(capability) ((capability) & MTK_VCODEC_INNER_RACING)
> +
> +/*
> + * struct mtk_vdec_format_types - Structure used to get supported
> + *		  format types according to decoder capability
> + */
> +enum mtk_vdec_format_types {
> +	MTK_VDEC_FORMAT_MM21 = 0x20,
> +	MTK_VDEC_FORMAT_MT21C = 0x40,
> +	MTK_VDEC_FORMAT_H264_SLICE = 0x100,
> +	MTK_VDEC_FORMAT_VP8_FRAME = 0x200,
> +	MTK_VDEC_FORMAT_VP9_FRAME = 0x400,
> +	MTK_VDEC_FORMAT_AV1_FRAME = 0x800,
> +	MTK_VDEC_FORMAT_HEVC_FRAME = 0x1000,
> +	MTK_VCODEC_INNER_RACING = 0x20000,
> +};
> +
> +/*
> + * enum mtk_vdec_hw_count - Supported hardware count
> + */
> +enum mtk_vdec_hw_count {
> +	MTK_VDEC_NO_HW = 0,
> +	MTK_VDEC_ONE_CORE,
> +	MTK_VDEC_ONE_LAT_ONE_CORE,
> +	MTK_VDEC_MAX_HW_COUNT,
> +};
> +
> +/*
> + * enum mtk_vdec_hw_arch - Used to separate different hardware architecture
> + */
> +enum mtk_vdec_hw_arch {
> +	MTK_VDEC_PURE_SINGLE_CORE,
> +	MTK_VDEC_LAT_SINGLE_CORE,
> +};
> +
>  /**
>   * struct vdec_pic_info  - picture size information
>   * @pic_w: picture width
> @@ -33,24 +73,54 @@ struct vdec_pic_info {
>  	unsigned int reserved;
>  };
>  
> -/*
> - * enum mtk_vdec_hw_id - Hardware index used to separate
> - *                         different hardware
> +/**
> + * struct mtk_vcodec_dec_pdata - compatible data for each IC
> + * @init_vdec_params: init vdec params
> + * @ctrls_setup: init vcodec dec ctrls
> + * @worker: worker to start a decode job
> + * @flush_decoder: function that flushes the decoder
> + * @get_cap_buffer: get capture buffer from capture queue
> + * @cap_to_disp: put capture buffer to disp list for lat and core arch
> + * @vdec_vb2_ops: struct vb2_ops
> + *
> + * @vdec_formats: supported video decoder formats
> + * @num_formats: count of video decoder formats
> + * @default_out_fmt: default output buffer format
> + * @default_cap_fmt: default capture buffer format
> + *
> + * @hw_arch: hardware arch is used to separate pure_sin_core and lat_sin_core
> + *
> + * @is_subdev_supported: whether support parent-node architecture(subdev)
> + * @uses_stateless_api: whether the decoder uses the stateless API with requests
>   */
> -enum mtk_vdec_hw_id {
> -	MTK_VDEC_CORE,
> -	MTK_VDEC_LAT0,
> -	MTK_VDEC_LAT1,
> -	MTK_VDEC_LAT_SOC,
> -	MTK_VDEC_HW_MAX,
> +struct mtk_vcodec_dec_pdata {
> +	void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
> +	int (*ctrls_setup)(struct mtk_vcodec_dec_ctx *ctx);
> +	void (*worker)(struct work_struct *work);
> +	int (*flush_decoder)(struct mtk_vcodec_dec_ctx *ctx);
> +	struct vdec_fb *(*get_cap_buffer)(struct mtk_vcodec_dec_ctx *ctx);
> +	void (*cap_to_disp)(struct mtk_vcodec_dec_ctx *ctx, int error,
> +			    struct media_request *src_buf_req);
> +
> +	const struct vb2_ops *vdec_vb2_ops;
> +
> +	const struct mtk_video_fmt *vdec_formats;
> +	const int *num_formats;
> +	const struct mtk_video_fmt *default_out_fmt;
> +	const struct mtk_video_fmt *default_cap_fmt;
> +
> +	enum mtk_vdec_hw_arch hw_arch;
> +
> +	bool is_subdev_supported;
> +	bool uses_stateless_api;
>  };
>  
>  /**
>   * struct mtk_vcodec_dec_ctx - Context (instance) private data.
>   *
>   * @type: type of the instance - decoder or encoder
> - * @dev: pointer to the mtk_vcodec_dev of the device
> - * @list: link to ctx_list of mtk_vcodec_dev
> + * @dev: pointer to the mtk_vcodec_dec_dev of the device
> + * @list: link to ctx_list of mtk_vcodec_dec_dev
>   *
>   * @fh: struct v4l2_fh
>   * @m2m_ctx: pointer to the v4l2_m2m_ctx of the context
> @@ -95,7 +165,7 @@ enum mtk_vdec_hw_id {
>   */
>  struct mtk_vcodec_dec_ctx {
>  	enum mtk_instance_type type;
> -	struct mtk_vcodec_dev *dev;
> +	struct mtk_vcodec_dec_dev *dev;
>  	struct list_head list;
>  
>  	struct v4l2_fh fh;
> @@ -136,6 +206,84 @@ struct mtk_vcodec_dec_ctx {
>  	struct vdec_msg_queue msg_queue;
>  };
>  
> +/**
> + * struct mtk_vcodec_dec_dev - driver data
> + * @v4l2_dev: V4L2 device to register video devices for.
> + * @vfd_dec: Video device for decoder
> + * @mdev_dec: Media device for decoder
> + *
> + * @m2m_dev_dec: m2m device for decoder
> + * @plat_dev: platform device
> + * @ctx_list: list of struct mtk_vcodec_ctx
> + * @curr_ctx: The context that is waiting for codec hardware
> + *
> + * @reg_base: Mapped address of MTK Vcodec registers.
> + * @vdec_pdata: decoder IC-specific data
> + *
> + * @fw_handler: used to communicate with the firmware.
> + * @id_counter: used to identify current opened instance
> + *
> + * @dec_mutex: decoder hardware lock
> + * @dev_mutex: video_device lock
> + * @decode_workqueue: decode work queue
> + *
> + * @irqlock: protect data access by irq handler and work thread
> + * @dec_irq: decoder irq resource
> + *
> + * @pm: power management control
> + * @dec_capability: used to identify decode capability, ex: 4k
> + *
> + * @core_workqueue: queue used for core hardware decode
> + *
> + * @subdev_dev: subdev hardware device
> + * @subdev_prob_done: check whether all used hw device is prob done
> + * @subdev_bitmap: used to record hardware is ready or not
> + *
> + * @dec_active_cnt: used to mark whether need to record register value
> + * @vdec_racing_info: record register value
> + * @dec_racing_info_mutex: mutex lock used for inner racing mode
> + * @dbgfs: debug log related information
> + */
> +struct mtk_vcodec_dec_dev {
> +	struct v4l2_device v4l2_dev;
> +	struct video_device *vfd_dec;
> +	struct media_device mdev_dec;
> +
> +	struct v4l2_m2m_dev *m2m_dev_dec;
> +	struct platform_device *plat_dev;
> +	struct list_head ctx_list;
> +	struct mtk_vcodec_dec_ctx *curr_ctx;
> +
> +	void __iomem *reg_base[NUM_MAX_VCODEC_REG_BASE];
> +	const struct mtk_vcodec_dec_pdata *vdec_pdata;
> +
> +	struct mtk_vcodec_fw *fw_handler;
> +	unsigned long id_counter;
> +
> +	/* decoder hardware mutex lock */
> +	struct mutex dec_mutex[MTK_VDEC_HW_MAX];
> +	struct mutex dev_mutex;
> +	struct workqueue_struct *decode_workqueue;
> +
> +	spinlock_t irqlock;
> +	int dec_irq;
> +
> +	struct mtk_vcodec_pm pm;
> +	unsigned int dec_capability;
> +
> +	struct workqueue_struct *core_workqueue;
> +
> +	void *subdev_dev[MTK_VDEC_HW_MAX];
> +	int (*subdev_prob_done)(struct mtk_vcodec_dec_dev *vdec_dev);
> +	DECLARE_BITMAP(subdev_bitmap, MTK_VDEC_HW_MAX);
> +
> +	atomic_t dec_active_cnt;
> +	u32 vdec_racing_info[132];
> +	/* Protects access to vdec_racing_info data */
> +	struct mutex dec_racing_info_mutex;
> +	struct mtk_vcodec_dbgfs dbgfs;
> +};
> +
>  static inline struct mtk_vcodec_dec_ctx *fh_to_dec_ctx(struct v4l2_fh *fh)
>  {
>  	return container_of(fh, struct mtk_vcodec_dec_ctx, fh);
> 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 dde0894f2ab0..23c19efa3cf6 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c
> @@ -12,7 +12,6 @@
>  #include <linux/pm_runtime.h>
>  #include <linux/slab.h>
>  
> -#include "mtk_vcodec_drv.h"
>  #include "mtk_vcodec_dec.h"
>  #include "mtk_vcodec_dec_hw.h"
>  #include "mtk_vcodec_dec_pm.h"
> @@ -36,7 +35,7 @@ static const struct of_device_id mtk_vdec_hw_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, mtk_vdec_hw_match);
>  
> -static int mtk_vdec_hw_prob_done(struct mtk_vcodec_dev *vdec_dev)
> +static int mtk_vdec_hw_prob_done(struct mtk_vcodec_dec_dev *vdec_dev)
>  {
>  	struct platform_device *pdev = vdec_dev->plat_dev;
>  	struct device_node *subdev_node;
> @@ -123,7 +122,7 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct mtk_vdec_hw_dev *subdev_dev;
> -	struct mtk_vcodec_dev *main_dev;
> +	struct mtk_vcodec_dec_dev *main_dev;
>  	const struct of_device_id *of_id;
>  	int hw_idx;
>  	int ret;
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.h
> index d62c7f961cfa..2b33f00e931e 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.h
> @@ -10,7 +10,7 @@
>  #include <linux/io.h>
>  #include <linux/platform_device.h>
>  
> -#include "mtk_vcodec_drv.h"
> +#include "mtk_vcodec_dec_drv.h"
>  
>  #define VDEC_HW_ACTIVE 0x10
>  #define VDEC_IRQ_CFG 0x11
> @@ -45,7 +45,7 @@ enum mtk_vdec_hw_reg_idx {
>   */
>  struct mtk_vdec_hw_dev {
>  	struct platform_device *plat_dev;
> -	struct mtk_vcodec_dev *main_dev;
> +	struct mtk_vcodec_dec_dev *main_dev;
>  	void __iomem *reg_base[VDEC_HW_MAX];
>  
>  	struct mtk_vcodec_dec_ctx *curr_ctx;
> 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 29ef00c4a326..ed1f503a944e 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c
> @@ -107,7 +107,7 @@ static void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm)
>  		clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
>  }
>  
> -static void mtk_vcodec_dec_enable_irq(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
> +static void mtk_vcodec_dec_enable_irq(struct mtk_vcodec_dec_dev *vdec_dev, int hw_idx)
>  {
>  	struct mtk_vdec_hw_dev *subdev_dev;
>  
> @@ -125,7 +125,7 @@ static void mtk_vcodec_dec_enable_irq(struct mtk_vcodec_dev *vdec_dev, int hw_id
>  	}
>  }
>  
> -static void mtk_vcodec_dec_disable_irq(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
> +static void mtk_vcodec_dec_disable_irq(struct mtk_vcodec_dec_dev *vdec_dev, int hw_idx)
>  {
>  	struct mtk_vdec_hw_dev *subdev_dev;
>  
> @@ -171,7 +171,7 @@ static void mtk_vcodec_record_racing_info(struct mtk_vcodec_dec_ctx *ctx)
>  	mutex_unlock(&ctx->dev->dec_racing_info_mutex);
>  }
>  
> -static struct mtk_vcodec_pm *mtk_vcodec_dec_get_pm(struct mtk_vcodec_dev *vdec_dev,
> +static struct mtk_vcodec_pm *mtk_vcodec_dec_get_pm(struct mtk_vcodec_dec_dev *vdec_dev,
>  						   int hw_idx)
>  {
>  	struct mtk_vdec_hw_dev *subdev_dev;
> @@ -191,7 +191,7 @@ static struct mtk_vcodec_pm *mtk_vcodec_dec_get_pm(struct mtk_vcodec_dev *vdec_d
>  	return &vdec_dev->pm;
>  }
>  
> -static void mtk_vcodec_dec_child_dev_on(struct mtk_vcodec_dev *vdec_dev,
> +static void mtk_vcodec_dec_child_dev_on(struct mtk_vcodec_dec_dev *vdec_dev,
>  					int hw_idx)
>  {
>  	struct mtk_vcodec_pm *pm;
> @@ -211,7 +211,7 @@ static void mtk_vcodec_dec_child_dev_on(struct mtk_vcodec_dev *vdec_dev,
>  	}
>  }
>  
> -static void mtk_vcodec_dec_child_dev_off(struct mtk_vcodec_dev *vdec_dev,
> +static void mtk_vcodec_dec_child_dev_off(struct mtk_vcodec_dec_dev *vdec_dev,
>  					 int hw_idx)
>  {
>  	struct mtk_vcodec_pm *pm;
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.h
> index f6c68e57bcc1..87a50d589d42 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.h
> @@ -7,7 +7,7 @@
>  #ifndef _MTK_VCODEC_DEC_PM_H_
>  #define _MTK_VCODEC_DEC_PM_H_
>  
> -#include "mtk_vcodec_drv.h"
> +#include "mtk_vcodec_dec_drv.h"
>  
>  int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *pm);
>  
> 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 93230fe7ab97..459e74a46737 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c
> @@ -4,7 +4,6 @@
>  #include <media/v4l2-mem2mem.h>
>  #include <media/videobuf2-dma-contig.h>
>  
> -#include "mtk_vcodec_drv.h"
>  #include "mtk_vcodec_dec.h"
>  #include "mtk_vcodec_intr.h"
>  #include "mtk_vcodec_util.h"
> @@ -279,7 +278,7 @@ static void mtk_vdec_worker(struct work_struct *work)
>  {
>  	struct mtk_vcodec_dec_ctx *ctx =
>  		container_of(work, struct mtk_vcodec_dec_ctx, decode_work);
> -	struct mtk_vcodec_dev *dev = ctx->dev;
> +	struct mtk_vcodec_dec_dev *dev = ctx->dev;
>  	struct vb2_v4l2_buffer *src_buf, *dst_buf;
>  	struct mtk_vcodec_mem buf;
>  	struct vdec_fb *pfb;
> 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 64e9dfd0fcb5..6268a39c2bb3 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> @@ -6,7 +6,6 @@
>  #include <media/v4l2-mem2mem.h>
>  #include <linux/module.h>
>  
> -#include "mtk_vcodec_drv.h"
>  #include "mtk_vcodec_dec.h"
>  #include "mtk_vcodec_intr.h"
>  #include "mtk_vcodec_util.h"
> @@ -288,7 +287,7 @@ static void mtk_vdec_worker(struct work_struct *work)
>  {
>  	struct mtk_vcodec_dec_ctx *ctx =
>  		container_of(work, struct mtk_vcodec_dec_ctx, decode_work);
> -	struct mtk_vcodec_dev *dev = ctx->dev;
> +	struct mtk_vcodec_dec_dev *dev = ctx->dev;
>  	struct vb2_v4l2_buffer *vb2_v4l2_src;
>  	struct vb2_buffer *vb2_src;
>  	struct mtk_vcodec_mem *bs_src;
> @@ -444,7 +443,7 @@ const struct media_device_ops mtk_vcodec_media_ops = {
>  static void mtk_vcodec_add_formats(unsigned int fourcc,
>  				   struct mtk_vcodec_dec_ctx *ctx)
>  {
> -	struct mtk_vcodec_dev *dev = ctx->dev;
> +	struct mtk_vcodec_dec_dev *dev = ctx->dev;
>  	const struct mtk_vcodec_dec_pdata *pdata = dev->vdec_pdata;
>  	int count_formats = *pdata->num_formats;
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h
> deleted file mode 100644
> index 76db7770d981..000000000000
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h
> +++ /dev/null
> @@ -1,295 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0 */
> -/*
> -* Copyright (c) 2016 MediaTek Inc.
> -* Author: PC Chen <pc.chen@mediatek.com>
> -*         Tiffany Lin <tiffany.lin@mediatek.com>
> -*/
> -
> -#ifndef _MTK_VCODEC_DRV_H_
> -#define _MTK_VCODEC_DRV_H_
> -
> -#include <linux/platform_device.h>
> -#include <linux/videodev2.h>
> -#include <media/v4l2-ctrls.h>
> -#include <media/v4l2-device.h>
> -#include <media/v4l2-ioctl.h>
> -#include <media/v4l2-mem2mem.h>
> -#include <media/videobuf2-core.h>
> -
> -#include "mtk_vcodec_dbgfs.h"
> -#include "mtk_vcodec_dec_drv.h"
> -#include "mtk_vcodec_enc_drv.h"
> -#include "mtk_vcodec_util.h"
> -#include "vdec_msg_queue.h"
> -
> -#define MTK_VCODEC_DEC_NAME	"mtk-vcodec-dec"
> -#define MTK_VCODEC_ENC_NAME	"mtk-vcodec-enc"
> -
> -#define MTK_V4L2_BENCHMARK	0
> -#define WAIT_INTR_TIMEOUT_MS	1000
> -#define IS_VDEC_LAT_ARCH(hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE)
> -#define IS_VDEC_INNER_RACING(capability) ((capability) & MTK_VCODEC_INNER_RACING)
> -
> -/*
> - * enum mtk_hw_reg_idx - MTK hw register base index
> - */
> -enum mtk_hw_reg_idx {
> -	VDEC_SYS,
> -	VDEC_MISC,
> -	VDEC_LD,
> -	VDEC_TOP,
> -	VDEC_CM,
> -	VDEC_AD,
> -	VDEC_AV,
> -	VDEC_PP,
> -	VDEC_HWD,
> -	VDEC_HWQ,
> -	VDEC_HWB,
> -	VDEC_HWG,
> -	NUM_MAX_VDEC_REG_BASE,
> -	/* h264 encoder */
> -	VENC_SYS = NUM_MAX_VDEC_REG_BASE,
> -	/* vp8 encoder */
> -	VENC_LT_SYS,
> -	NUM_MAX_VCODEC_REG_BASE
> -};
> -
> -
> -
> -/*
> - * enum mtk_vdec_hw_count - Supported hardware count
> - */
> -enum mtk_vdec_hw_count {
> -	MTK_VDEC_NO_HW = 0,
> -	MTK_VDEC_ONE_CORE,
> -	MTK_VDEC_ONE_LAT_ONE_CORE,
> -	MTK_VDEC_MAX_HW_COUNT,
> -};
> -
> -/*
> - * enum mtk_q_type - Type of queue
> - */
> -enum mtk_q_type {
> -	MTK_Q_DATA_SRC = 0,
> -	MTK_Q_DATA_DST = 1,
> -};
> -
> -
> -/*
> - * struct mtk_vcodec_clk_info - Structure used to store clock name
> - */
> -struct mtk_vcodec_clk_info {
> -	const char	*clk_name;
> -	struct clk	*vcodec_clk;
> -};
> -
> -/*
> - * struct mtk_vcodec_clk - Structure used to store vcodec clock information
> - */
> -struct mtk_vcodec_clk {
> -	struct mtk_vcodec_clk_info	*clk_info;
> -	int	clk_num;
> -};
> -
> -/*
> - * struct mtk_vcodec_pm - Power management data structure
> - */
> -struct mtk_vcodec_pm {
> -	struct mtk_vcodec_clk	vdec_clk;
> -	struct mtk_vcodec_clk	venc_clk;
> -	struct device	*dev;
> -};
> -
> -/*
> - * enum mtk_vdec_hw_arch - Used to separate different hardware architecture
> - */
> -enum mtk_vdec_hw_arch {
> -	MTK_VDEC_PURE_SINGLE_CORE,
> -	MTK_VDEC_LAT_SINGLE_CORE,
> -};
> -
> -/*
> - * struct mtk_vdec_format_types - Structure used to get supported
> - *		  format types according to decoder capability
> - */
> -enum mtk_vdec_format_types {
> -	MTK_VDEC_FORMAT_MM21 = 0x20,
> -	MTK_VDEC_FORMAT_MT21C = 0x40,
> -	MTK_VDEC_FORMAT_H264_SLICE = 0x100,
> -	MTK_VDEC_FORMAT_VP8_FRAME = 0x200,
> -	MTK_VDEC_FORMAT_VP9_FRAME = 0x400,
> -	MTK_VDEC_FORMAT_AV1_FRAME = 0x800,
> -	MTK_VDEC_FORMAT_HEVC_FRAME = 0x1000,
> -	MTK_VCODEC_INNER_RACING = 0x20000,
> -};
> -
> -/**
> - * struct mtk_vcodec_dec_pdata - compatible data for each IC
> - * @init_vdec_params: init vdec params
> - * @ctrls_setup: init vcodec dec ctrls
> - * @worker: worker to start a decode job
> - * @flush_decoder: function that flushes the decoder
> - * @get_cap_buffer: get capture buffer from capture queue
> - * @cap_to_disp: put capture buffer to disp list for lat and core arch
> - * @vdec_vb2_ops: struct vb2_ops
> - *
> - * @vdec_formats: supported video decoder formats
> - * @num_formats: count of video decoder formats
> - * @default_out_fmt: default output buffer format
> - * @default_cap_fmt: default capture buffer format
> - *
> - * @hw_arch: hardware arch is used to separate pure_sin_core and lat_sin_core
> - *
> - * @is_subdev_supported: whether support parent-node architecture(subdev)
> - * @uses_stateless_api: whether the decoder uses the stateless API with requests
> - */
> -
> -struct mtk_vcodec_dec_pdata {
> -	void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
> -	int (*ctrls_setup)(struct mtk_vcodec_dec_ctx *ctx);
> -	void (*worker)(struct work_struct *work);
> -	int (*flush_decoder)(struct mtk_vcodec_dec_ctx *ctx);
> -	struct vdec_fb *(*get_cap_buffer)(struct mtk_vcodec_dec_ctx *ctx);
> -	void (*cap_to_disp)(struct mtk_vcodec_dec_ctx *ctx, int error,
> -			    struct media_request *src_buf_req);
> -
> -	struct vb2_ops *vdec_vb2_ops;
> -
> -	const struct mtk_video_fmt *vdec_formats;
> -	const int *num_formats;
> -	const struct mtk_video_fmt *default_out_fmt;
> -	const struct mtk_video_fmt *default_cap_fmt;
> -
> -	enum mtk_vdec_hw_arch hw_arch;
> -
> -	bool is_subdev_supported;
> -	bool uses_stateless_api;
> -};
> -
> -/**
> - * struct mtk_vcodec_enc_pdata - compatible data for each IC
> - *
> - * @uses_ext: whether the encoder uses the extended firmware messaging format
> - * @min_bitrate: minimum supported encoding bitrate
> - * @max_bitrate: maximum supported encoding bitrate
> - * @capture_formats: array of supported capture formats
> - * @num_capture_formats: number of entries in capture_formats
> - * @output_formats: array of supported output formats
> - * @num_output_formats: number of entries in output_formats
> - * @core_id: stand for h264 or vp8 encode index
> - * @uses_34bit: whether the encoder uses 34-bit iova
> - */
> -struct mtk_vcodec_enc_pdata {
> -	bool uses_ext;
> -	unsigned long min_bitrate;
> -	unsigned long max_bitrate;
> -	const struct mtk_video_fmt *capture_formats;
> -	size_t num_capture_formats;
> -	const struct mtk_video_fmt *output_formats;
> -	size_t num_output_formats;
> -	int core_id;
> -	bool uses_34bit;
> -};
> -
> -#define MTK_ENC_CTX_IS_EXT(ctx) ((ctx)->dev->venc_pdata->uses_ext)
> -#define MTK_ENC_IOVA_IS_34BIT(ctx) ((ctx)->dev->venc_pdata->uses_34bit)
> -
> -/**
> - * struct mtk_vcodec_dev - driver data
> - * @v4l2_dev: V4L2 device to register video devices for.
> - * @vfd_dec: Video device for decoder
> - * @mdev_dec: Media device for decoder
> - * @vfd_enc: Video device for encoder.
> - *
> - * @m2m_dev_dec: m2m device for decoder
> - * @m2m_dev_enc: m2m device for encoder.
> - * @plat_dev: platform device
> - * @ctx_list: list of struct mtk_vcodec_dec_ctx
> - * @irqlock: protect data access by irq handler and work thread
> - * @curr_ctx: The context that is waiting for codec hardware
> - * @curr_enc_ctx: The encoder context that is waiting for codec hardware
> - *
> - * @reg_base: Mapped address of MTK Vcodec registers.
> - * @vdec_pdata: decoder IC-specific data
> - * @venc_pdata: encoder IC-specific data
> - *
> - * @fw_handler: used to communicate with the firmware.
> - * @id_counter: used to identify current opened instance
> - *
> - * @decode_workqueue: decode work queue
> - * @encode_workqueue: encode work queue
> - *
> - * @dev_mutex: video_device lock
> - *
> - * @dec_irq: decoder irq resource
> - * @enc_irq: h264 encoder irq resource
> - *
> - * @dec_mutex: decoder hardware lock
> - * @enc_mutex: encoder hardware lock.
> - *
> - * @pm: power management control
> - * @dec_capability: used to identify decode capability, ex: 4k
> - * @enc_capability: used to identify encode capability
> - *
> - * @core_workqueue: queue used for core hardware decode
> - *
> - * @subdev_dev: subdev hardware device
> - * @subdev_prob_done: check whether all used hw device is prob done
> - * @subdev_bitmap: used to record hardware is ready or not
> - *
> - * @dec_active_cnt: used to mark whether need to record register value
> - * @vdec_racing_info: record register value
> - * @dec_racing_info_mutex: mutex lock used for inner racing mode
> - * @dbgfs: debug log related information
> - */
> -struct mtk_vcodec_dev {
> -	struct v4l2_device v4l2_dev;
> -	struct video_device *vfd_dec;
> -	struct media_device mdev_dec;
> -	struct video_device *vfd_enc;
> -
> -	struct v4l2_m2m_dev *m2m_dev_dec;
> -	struct v4l2_m2m_dev *m2m_dev_enc;
> -	struct platform_device *plat_dev;
> -	struct list_head ctx_list;
> -	spinlock_t irqlock;
> -	struct mtk_vcodec_dec_ctx *curr_ctx;
> -	struct mtk_vcodec_enc_ctx *curr_enc_ctx;
> -	void __iomem *reg_base[NUM_MAX_VCODEC_REG_BASE];
> -	const struct mtk_vcodec_dec_pdata *vdec_pdata;
> -	const struct mtk_vcodec_enc_pdata *venc_pdata;
> -
> -	struct mtk_vcodec_fw *fw_handler;
> -
> -	unsigned long id_counter;
> -
> -	struct workqueue_struct *decode_workqueue;
> -	struct workqueue_struct *encode_workqueue;
> -	struct mutex dev_mutex;
> -
> -	int dec_irq;
> -	int enc_irq;
> -
> -	/* decoder hardware mutex lock */
> -	struct mutex dec_mutex[MTK_VDEC_HW_MAX];
> -	struct mutex enc_mutex;
> -
> -	struct mtk_vcodec_pm pm;
> -	unsigned int dec_capability;
> -	unsigned int enc_capability;
> -
> -	struct workqueue_struct *core_workqueue;
> -
> -	void *subdev_dev[MTK_VDEC_HW_MAX];
> -	int (*subdev_prob_done)(struct mtk_vcodec_dev *vdec_dev);
> -	DECLARE_BITMAP(subdev_bitmap, MTK_VDEC_HW_MAX);
> -
> -	atomic_t dec_active_cnt;
> -	u32 vdec_racing_info[132];
> -	/* Protects access to vdec_racing_info data */
> -	struct mutex dec_racing_info_mutex;
> -
> -	struct mtk_vcodec_dbgfs dbgfs;
> -};
> -
> -#endif /* _MTK_VCODEC_DRV_H_ */
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c
> index deabf012848e..85dabb20fb11 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c
> @@ -10,7 +10,6 @@
>  #include <media/videobuf2-dma-contig.h>
>  #include <linux/pm_runtime.h>
>  
> -#include "mtk_vcodec_drv.h"
>  #include "mtk_vcodec_enc.h"
>  #include "mtk_vcodec_intr.h"
>  #include "mtk_vcodec_util.h"
> @@ -1436,7 +1435,7 @@ int mtk_vcodec_enc_queue_init(void *priv, struct vb2_queue *src_vq,
>  
>  int mtk_venc_unlock(struct mtk_vcodec_enc_ctx *ctx)
>  {
> -	struct mtk_vcodec_dev *dev = ctx->dev;
> +	struct mtk_vcodec_enc_dev *dev = ctx->dev;
>  
>  	mutex_unlock(&dev->enc_mutex);
>  	return 0;
> @@ -1444,7 +1443,7 @@ int mtk_venc_unlock(struct mtk_vcodec_enc_ctx *ctx)
>  
>  int mtk_venc_lock(struct mtk_vcodec_enc_ctx *ctx)
>  {
> -	struct mtk_vcodec_dev *dev = ctx->dev;
> +	struct mtk_vcodec_enc_dev *dev = ctx->dev;
>  
>  	mutex_lock(&dev->enc_mutex);
>  	return 0;
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
> index c9b6ce9dfa2d..0830708de32f 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
> @@ -16,7 +16,6 @@
>  #include <media/v4l2-mem2mem.h>
>  #include <media/videobuf2-dma-contig.h>
>  
> -#include "mtk_vcodec_drv.h"
>  #include "mtk_vcodec_enc.h"
>  #include "mtk_vcodec_enc_pm.h"
>  #include "mtk_vcodec_intr.h"
> @@ -85,14 +84,14 @@ static void clean_irq_status(unsigned int irq_status, void __iomem *addr)
>  }
>  static irqreturn_t mtk_vcodec_enc_irq_handler(int irq, void *priv)
>  {
> -	struct mtk_vcodec_dev *dev = priv;
> +	struct mtk_vcodec_enc_dev *dev = priv;
>  	struct mtk_vcodec_enc_ctx *ctx;
>  	unsigned long flags;
>  	void __iomem *addr;
>  	int core_id;
>  
>  	spin_lock_irqsave(&dev->irqlock, flags);
> -	ctx = dev->curr_enc_ctx;
> +	ctx = dev->curr_ctx;
>  	spin_unlock_irqrestore(&dev->irqlock, flags);
>  
>  	core_id = dev->venc_pdata->core_id;
> @@ -116,7 +115,7 @@ static irqreturn_t mtk_vcodec_enc_irq_handler(int irq, void *priv)
>  
>  static int fops_vcodec_open(struct file *file)
>  {
> -	struct mtk_vcodec_dev *dev = video_drvdata(file);
> +	struct mtk_vcodec_enc_dev *dev = video_drvdata(file);
>  	struct mtk_vcodec_enc_ctx *ctx = NULL;
>  	int ret = 0;
>  	struct vb2_queue *src_vq;
> @@ -203,7 +202,7 @@ static int fops_vcodec_open(struct file *file)
>  
>  static int fops_vcodec_release(struct file *file)
>  {
> -	struct mtk_vcodec_dev *dev = video_drvdata(file);
> +	struct mtk_vcodec_enc_dev *dev = video_drvdata(file);
>  	struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(file->private_data);
>  
>  	mtk_v4l2_venc_dbg(1, ctx, "[%d] encoder", ctx->id);
> @@ -232,7 +231,7 @@ static const struct v4l2_file_operations mtk_vcodec_fops = {
>  
>  static int mtk_vcodec_probe(struct platform_device *pdev)
>  {
> -	struct mtk_vcodec_dev *dev;
> +	struct mtk_vcodec_enc_dev *dev;
>  	struct video_device *vfd_enc;
>  	phandle rproc_phandle;
>  	enum mtk_vcodec_fw_type fw_type;
> @@ -454,7 +453,7 @@ MODULE_DEVICE_TABLE(of, mtk_vcodec_enc_match);
>  
>  static void mtk_vcodec_enc_remove(struct platform_device *pdev)
>  {
> -	struct mtk_vcodec_dev *dev = platform_get_drvdata(pdev);
> +	struct mtk_vcodec_enc_dev *dev = platform_get_drvdata(pdev);
>  
>  	destroy_workqueue(dev->encode_workqueue);
>  	if (dev->m2m_dev_enc)
> @@ -463,7 +462,7 @@ static void mtk_vcodec_enc_remove(struct platform_device *pdev)
>  	if (dev->vfd_enc)
>  		video_unregister_device(dev->vfd_enc);
>  
> -	mtk_vcodec_dbgfs_deinit(dev);
> +	mtk_vcodec_dbgfs_deinit(&dev->dbgfs);
>  	v4l2_device_unregister(&dev->v4l2_dev);
>  	pm_runtime_disable(dev->pm.dev);
>  	mtk_vcodec_fw_release(dev->fw_handler);
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h
> index 6aa4afe5b796..a88ef9078848 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h
> @@ -8,7 +8,39 @@
>  #define _MTK_VCODEC_ENC_DRV_H_
>  
>  #include "mtk_vcodec_com_drv.h"
> +#include "mtk_vcodec_dbgfs.h"
>  #include "mtk_vcodec_fw_priv.h"
> +#include "mtk_vcodec_util.h"
> +
> +#define MTK_VCODEC_ENC_NAME	"mtk-vcodec-enc"
> +
> +#define MTK_ENC_CTX_IS_EXT(ctx) ((ctx)->dev->venc_pdata->uses_ext)
> +#define MTK_ENC_IOVA_IS_34BIT(ctx) ((ctx)->dev->venc_pdata->uses_34bit)
> +
> +/**
> + * struct mtk_vcodec_enc_pdata - compatible data for each IC
> + *
> + * @uses_ext: whether the encoder uses the extended firmware messaging format
> + * @min_bitrate: minimum supported encoding bitrate
> + * @max_bitrate: maximum supported encoding bitrate
> + * @capture_formats: array of supported capture formats
> + * @num_capture_formats: number of entries in capture_formats
> + * @output_formats: array of supported output formats
> + * @num_output_formats: number of entries in output_formats
> + * @core_id: stand for h264 or vp8 encode index
> + * @uses_34bit: whether the encoder uses 34-bit iova
> + */
> +struct mtk_vcodec_enc_pdata {
> +	bool uses_ext;
> +	unsigned long min_bitrate;
> +	unsigned long max_bitrate;
> +	const struct mtk_video_fmt *capture_formats;
> +	size_t num_capture_formats;
> +	const struct mtk_video_fmt *output_formats;
> +	size_t num_output_formats;
> +	int core_id;
> +	bool uses_34bit;
> +};
>  
>  /*
>   * enum mtk_encode_param - General encoding parameters type
> @@ -61,8 +93,8 @@ struct mtk_enc_params {
>   * struct mtk_vcodec_enc_ctx - Context (instance) private data.
>   *
>   * @type: type of the instance - decoder or encoder
> - * @dev: pointer to the mtk_vcodec_dev of the device
> - * @list: link to ctx_list of mtk_vcodec_dev
> + * @dev: pointer to the mtk_vcodec_enc_dev of the device
> + * @list: link to ctx_list of mtk_vcodec_enc_dev
>   *
>   * @fh: struct v4l2_fh
>   * @m2m_ctx: pointer to the v4l2_m2m_ctx of the context
> @@ -101,7 +133,7 @@ struct mtk_enc_params {
>   */
>  struct mtk_vcodec_enc_ctx {
>  	enum mtk_instance_type type;
> -	struct mtk_vcodec_dev *dev;
> +	struct mtk_vcodec_enc_dev *dev;
>  	struct list_head list;
>  
>  	struct v4l2_fh fh;
> @@ -136,6 +168,61 @@ struct mtk_vcodec_enc_ctx {
>  	struct mutex q_mutex;
>  };
>  
> +/**
> + * struct mtk_vcodec_enc_dev - driver data
> + * @v4l2_dev: V4L2 device to register video devices for.
> + * @vfd_enc: Video device for encoder.
> + *
> + * @m2m_dev_enc: m2m device for encoder.
> + * @plat_dev: platform device
> + * @ctx_list: list of struct mtk_vcodec_ctx
> + * @curr_ctx: The context that is waiting for codec hardware
> + *
> + * @reg_base: Mapped address of MTK Vcodec registers.
> + * @venc_pdata: encoder IC-specific data
> + *
> + * @fw_handler: used to communicate with the firmware.
> + * @id_counter: used to identify current opened instance
> + *
> + * @enc_mutex: encoder hardware lock.
> + * @dev_mutex: video_device lock
> + * @encode_workqueue: encode work queue
> + *
> + * @enc_irq: h264 encoder irq resource
> + * @irqlock: protect data access by irq handler and work thread
> + *
> + * @pm: power management control
> + * @enc_capability: used to identify encode capability
> + * @dbgfs: debug log related information
> + */
> +struct mtk_vcodec_enc_dev {
> +	struct v4l2_device v4l2_dev;
> +	struct video_device *vfd_enc;
> +
> +	struct v4l2_m2m_dev *m2m_dev_enc;
> +	struct platform_device *plat_dev;
> +	struct list_head ctx_list;
> +	struct mtk_vcodec_enc_ctx *curr_ctx;
> +
> +	void __iomem *reg_base[NUM_MAX_VCODEC_REG_BASE];
> +	const struct mtk_vcodec_enc_pdata *venc_pdata;
> +
> +	struct mtk_vcodec_fw *fw_handler;
> +	unsigned long id_counter;
> +
> +	/* encoder hardware mutex lock */
> +	struct mutex enc_mutex;
> +	struct mutex dev_mutex;
> +	struct workqueue_struct *encode_workqueue;
> +
> +	int enc_irq;
> +	spinlock_t irqlock;
> +
> +	struct mtk_vcodec_pm pm;
> +	unsigned int enc_capability;
> +	struct mtk_vcodec_dbgfs dbgfs;
> +};
> +
>  static inline struct mtk_vcodec_enc_ctx *fh_to_enc_ctx(struct v4l2_fh *fh)
>  {
>  	return container_of(fh, struct mtk_vcodec_enc_ctx, fh);
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.c
> index 3165e114b221..f7481f33a0b2 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.c
> @@ -9,10 +9,10 @@
>  #include <linux/of_platform.h>
>  #include <linux/pm_runtime.h>
>  
> +#include "mtk_vcodec_enc_drv.h"
>  #include "mtk_vcodec_enc_pm.h"
> -#include "mtk_vcodec_util.h"
>  
> -int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
> +int mtk_vcodec_init_enc_clk(struct mtk_vcodec_enc_dev *mtkdev)
>  {
>  	struct platform_device *pdev;
>  	struct mtk_vcodec_pm *pm;
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.h
> index bc455cefc0cd..e50be0575190 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.h
> @@ -7,9 +7,9 @@
>  #ifndef _MTK_VCODEC_ENC_PM_H_
>  #define _MTK_VCODEC_ENC_PM_H_
>  
> -#include "mtk_vcodec_drv.h"
> +#include "mtk_vcodec_enc_drv.h"
>  
> -int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *dev);
> +int mtk_vcodec_init_enc_clk(struct mtk_vcodec_enc_dev *dev);
>  
>  void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm);
>  void mtk_vcodec_enc_clock_off(struct mtk_vcodec_pm *pm);
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c
> index 623dd916d09e..5c9f04574ad1 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c
> @@ -1,20 +1,28 @@
>  // SPDX-License-Identifier: GPL-2.0
>  
> +#include "mtk_vcodec_dec_drv.h"
> +#include "mtk_vcodec_enc_drv.h"
>  #include "mtk_vcodec_fw.h"
>  #include "mtk_vcodec_fw_priv.h"
>  #include "mtk_vcodec_util.h"
> -#include "mtk_vcodec_drv.h"
>  
>  struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_type type,
>  					   enum mtk_vcodec_fw_use fw_use)
>  {
> +	struct platform_device *plat_dev;
> +
> +	if (fw_use == ENCODER)
> +		plat_dev = ((struct mtk_vcodec_enc_dev *)priv)->plat_dev;
> +	else
> +		plat_dev = ((struct mtk_vcodec_dec_dev *)priv)->plat_dev;
> +
>  	switch (type) {
>  	case VPU:
>  		return mtk_vcodec_fw_vpu_init(priv, fw_use);
>  	case SCP:
>  		return mtk_vcodec_fw_scp_init(priv, fw_use);
>  	default:
> -		pr_err("invalid vcodec fw type");
> +		dev_err(&plat_dev->dev, "invalid vcodec fw type");
>  		return ERR_PTR(-EINVAL);
>  	}
>  }
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.h
> index d8cfbec323d5..83479ab70385 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.h
> @@ -8,7 +8,8 @@
>  
>  #include "../vpu/mtk_vpu.h"
>  
> -struct mtk_vcodec_dev;
> +struct mtk_vcodec_dec_dev;
> +struct mtk_vcodec_enc_dev;
>  
>  enum mtk_vcodec_fw_type {
>  	VPU,
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_priv.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_priv.h
> index 3438a4917344..99603accd82e 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_priv.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_priv.h
> @@ -5,7 +5,8 @@
>  
>  #include "mtk_vcodec_fw.h"
>  
> -struct mtk_vcodec_dev;
> +struct mtk_vcodec_dec_dev;
> +struct mtk_vcodec_enc_dev;
>  
>  struct mtk_vcodec_fw {
>  	enum mtk_vcodec_fw_type type;
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c
> index 71ff1a6ae872..3cb5a5befd24 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c
> @@ -1,8 +1,8 @@
>  // SPDX-License-Identifier: GPL-2.0
>  
> +#include "mtk_vcodec_dec_drv.h"
> +#include "mtk_vcodec_enc_drv.h"
>  #include "mtk_vcodec_fw_priv.h"
> -#include "mtk_vcodec_util.h"
> -#include "mtk_vcodec_drv.h"
>  
>  static int mtk_vcodec_scp_load_firmware(struct mtk_vcodec_fw *fw)
>  {
> @@ -56,14 +56,25 @@ static const struct mtk_vcodec_fw_ops mtk_vcodec_rproc_msg = {
>  struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(void *priv, enum mtk_vcodec_fw_use fw_use)
>  {
>  	struct mtk_vcodec_fw *fw;
> -	struct mtk_vcodec_dev *dev = priv;
>  	struct platform_device *plat_dev;
>  	struct mtk_scp *scp;
>  
> -	plat_dev = dev->plat_dev;
> +	if (fw_use == ENCODER) {
> +		struct mtk_vcodec_enc_dev *enc_dev = priv;
> +
> +		plat_dev = enc_dev->plat_dev;
> +	} else if (fw_use == DECODER) {
> +		struct mtk_vcodec_dec_dev *dec_dev = priv;
> +
> +		plat_dev = dec_dev->plat_dev;
> +	} else {
> +		pr_err("Invalid fw_use %d (use a resonable fw id here)\n", fw_use);
> +		return ERR_PTR(-EINVAL);
> +	}
> +
>  	scp = scp_get(plat_dev);
>  	if (!scp) {
> -		dev_err(&dev->plat_dev->dev, "could not get vdec scp handle");
> +		dev_err(&plat_dev->dev, "could not get vdec scp handle");
>  		return ERR_PTR(-EPROBE_DEFER);
>  	}
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_vpu.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_vpu.c
> index 571072dffbfa..18274a51a8f8 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_vpu.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_vpu.c
> @@ -1,8 +1,8 @@
>  // SPDX-License-Identifier: GPL-2.0
>  
> +#include "mtk_vcodec_dec_drv.h"
> +#include "mtk_vcodec_enc_drv.h"
>  #include "mtk_vcodec_fw_priv.h"
> -#include "mtk_vcodec_util.h"
> -#include "mtk_vcodec_drv.h"
>  
>  static int mtk_vcodec_vpu_load_firmware(struct mtk_vcodec_fw *fw)
>  {
> @@ -53,7 +53,7 @@ static void mtk_vcodec_vpu_release(struct mtk_vcodec_fw *fw)
>  
>  static void mtk_vcodec_vpu_reset_dec_handler(void *priv)
>  {
> -	struct mtk_vcodec_dev *dev = priv;
> +	struct mtk_vcodec_dec_dev *dev = priv;
>  	struct mtk_vcodec_dec_ctx *ctx;
>  
>  	dev_err(&dev->plat_dev->dev, "Watchdog timeout!!");
> @@ -68,7 +68,7 @@ static void mtk_vcodec_vpu_reset_dec_handler(void *priv)
>  
>  static void mtk_vcodec_vpu_reset_enc_handler(void *priv)
>  {
> -	struct mtk_vcodec_dev *dev = priv;
> +	struct mtk_vcodec_enc_dev *dev = priv;
>  	struct mtk_vcodec_enc_ctx *ctx;
>  
>  	dev_err(&dev->plat_dev->dev, "Watchdog timeout!!");
> @@ -94,24 +94,28 @@ static const struct mtk_vcodec_fw_ops mtk_vcodec_vpu_msg = {
>  struct mtk_vcodec_fw *mtk_vcodec_fw_vpu_init(void *priv, enum mtk_vcodec_fw_use fw_use)
>  {
>  	struct platform_device *fw_pdev;
> -	struct mtk_vcodec_dev *dev = priv;
>  	struct platform_device *plat_dev;
>  	struct mtk_vcodec_fw *fw;
>  	enum rst_id rst_id;
>  
>  	if (fw_use == ENCODER) {
> +		struct mtk_vcodec_enc_dev *enc_dev = priv;
> +
> +		plat_dev = enc_dev->plat_dev;
>  		rst_id = VPU_RST_ENC;
>  	} else if (fw_use == DECODER) {
> +		struct mtk_vcodec_dec_dev *dec_dev = priv;
> +
> +		plat_dev = dec_dev->plat_dev;
>  		rst_id = VPU_RST_DEC;
>  	} else {
>  		pr_err("Invalid fw_use %d (use a resonable fw id here)\n", fw_use);
>  		return ERR_PTR(-EINVAL);
>  	}
>  
> -	plat_dev = dev->plat_dev;
>  	fw_pdev = vpu_get_plat_device(plat_dev);
>  	if (!fw_pdev) {
> -		dev_err(&dev->plat_dev->dev, "firmware device is not ready");
> +		dev_err(&plat_dev->dev, "firmware device is not ready");
>  		return ERR_PTR(-EINVAL);
>  	}
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> index 66d1f50d8968..69dae0336a14 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> @@ -7,9 +7,9 @@
>  #include <linux/errno.h>
>  #include <linux/wait.h>
>  
> -#include "mtk_vcodec_drv.h"
> +#include "mtk_vcodec_dec_drv.h"
> +#include "mtk_vcodec_enc_drv.h"
>  #include "mtk_vcodec_intr.h"
> -#include "mtk_vcodec_util.h"
>  
>  int mtk_vcodec_wait_for_done_ctx(void *priv, int command, unsigned int timeout_ms,
>  				 unsigned int hw_id)
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> index adaeae79558a..18f632eb0b8a 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> @@ -9,9 +9,9 @@
>  #include <linux/of.h>
>  #include <linux/of_device.h>
>  
> +#include "mtk_vcodec_dec_drv.h"
> +#include "mtk_vcodec_enc_drv.h"
>  #include "mtk_vcodec_dec_hw.h"
> -#include "mtk_vcodec_drv.h"
> -#include "mtk_vcodec_util.h"
>  
>  #if defined(CONFIG_DEBUG_FS)
>  int mtk_vcodec_dbg;
> @@ -75,7 +75,7 @@ void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem)
>  }
>  EXPORT_SYMBOL(mtk_vcodec_mem_free);
>  
> -void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dev *dev, int hw_idx)
> +void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dec_dev *dev, int hw_idx)
>  {
>  	if (hw_idx >= MTK_VDEC_HW_MAX || hw_idx < 0 || !dev->subdev_dev[hw_idx]) {
>  		dev_err(&dev->plat_dev->dev, "hw idx is out of range:%d", hw_idx);
> @@ -86,7 +86,7 @@ void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dev *dev, int hw_idx)
>  }
>  EXPORT_SYMBOL(mtk_vcodec_get_hw_dev);
>  
> -void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
> +void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dec_dev *vdec_dev,
>  			     struct mtk_vcodec_dec_ctx *ctx, int hw_idx)
>  {
>  	unsigned long flags;
> @@ -108,7 +108,7 @@ void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
>  }
>  EXPORT_SYMBOL(mtk_vcodec_set_curr_ctx);
>  
> -struct mtk_vcodec_dec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
> +struct mtk_vcodec_dec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dec_dev *vdec_dev,
>  						   unsigned int hw_idx)
>  {
>  	unsigned long flags;
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> index 4d48b516f62d..6c24bb8b1715 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> @@ -23,7 +23,7 @@ struct mtk_vcodec_fb {
>  };
>  
>  struct mtk_vcodec_dec_ctx;
> -struct mtk_vcodec_dev;
> +struct mtk_vcodec_dec_dev;
>  
>  #undef pr_fmt
>  #define pr_fmt(fmt) "%s(),%d: " fmt, __func__, __LINE__
> @@ -83,10 +83,10 @@ extern int mtk_vcodec_dbg;
>  void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base, unsigned int reg_idx);
>  int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem);
>  void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem);
> -void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
> +void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dec_dev *vdec_dev,
>  			     struct mtk_vcodec_dec_ctx *ctx, int hw_idx);
> -struct mtk_vcodec_dec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
> +struct mtk_vcodec_dec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dec_dev *vdec_dev,
>  						   unsigned int hw_idx);
> -void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dev *dev, int hw_idx);
> +void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dec_dev *dev, int hw_idx);
>  
>  #endif /* _MTK_VCODEC_UTIL_H_ */
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.h b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.h
> index 0dda9e2315c0..ac82be336055 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.h
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.h
> @@ -13,7 +13,7 @@
>  #include <media/v4l2-mem2mem.h>
>  #include <media/videobuf2-dma-contig.h>
>  
> -#include "../mtk_vcodec_drv.h"
> +#include "../mtk_vcodec_dec_drv.h"
>  
>  #define NAL_NON_IDR_SLICE			0x01
>  #define NAL_IDR_SLICE				0x05
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> index 846cc39c0168..79eff921fc97 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> @@ -540,7 +540,7 @@ static int vdec_h264_slice_core_decode(struct vdec_lat_buf *lat_buf)
>  	return 0;
>  }
>  
> -static void vdec_h264_insert_startcode(struct mtk_vcodec_dev *vcodec_dev, unsigned char *buf,
> +static void vdec_h264_insert_startcode(struct mtk_vcodec_dec_dev *vcodec_dev, unsigned char *buf,
>  				       size_t *bs_size, struct mtk_h264_pps_param *pps)
>  {
>  	struct device *dev = &vcodec_dev->plat_dev->dev;
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h b/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h
> index 816ed6ab1ed0..7b41ce23158b 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h
> +++ b/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h
> @@ -8,7 +8,6 @@
>  #ifndef _VDEC_DRV_IF_H_
>  #define _VDEC_DRV_IF_H_
>  
> -#include "mtk_vcodec_drv.h"
>  #include "mtk_vcodec_dec.h"
>  #include "mtk_vcodec_util.h"
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
> index 0dd1374ccc38..890b955e4b31 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
> @@ -8,8 +8,8 @@
>  #include <linux/interrupt.h>
>  #include <linux/kthread.h>
>  
> +#include "mtk_vcodec_dec_drv.h"
>  #include "mtk_vcodec_dec_pm.h"
> -#include "mtk_vcodec_drv.h"
>  #include "vdec_msg_queue.h"
>  
>  #define VDEC_MSG_QUEUE_TIMEOUT_MS 1500
> @@ -239,7 +239,7 @@ static void vdec_msg_queue_core_work(struct work_struct *work)
>  		container_of(work, struct vdec_msg_queue, core_work);
>  	struct mtk_vcodec_dec_ctx *ctx =
>  		container_of(msg_queue, struct mtk_vcodec_dec_ctx, msg_queue);
> -	struct mtk_vcodec_dev *dev = ctx->dev;
> +	struct mtk_vcodec_dec_dev *dev = ctx->dev;
>  	struct vdec_lat_buf *lat_buf;
>  
>  	spin_lock(&msg_queue->core_ctx.ready_lock);
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
> index 1fb3f57c2384..eeb5deb907ed 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
> +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
> @@ -18,7 +18,7 @@
>  
>  struct vdec_lat_buf;
>  struct mtk_vcodec_dec_ctx;
> -struct mtk_vcodec_dev;
> +struct mtk_vcodec_dec_dev;
>  typedef int (*core_decode_cb_t)(struct vdec_lat_buf *lat_buf);
>  
>  /**
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> index d82391411ba1..7fe8e196cb45 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> @@ -4,8 +4,7 @@
>   * Author: PC Chen <pc.chen@mediatek.com>
>   */
>  
> -#include "mtk_vcodec_drv.h"
> -#include "mtk_vcodec_util.h"
> +#include "mtk_vcodec_dec_drv.h"
>  #include "vdec_drv_if.h"
>  #include "vdec_ipi_msg.h"
>  #include "vdec_vpu_if.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> index c5f9fc24a692..41d463d40843 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> @@ -10,7 +10,7 @@
>  #include <linux/kernel.h>
>  #include <linux/slab.h>
>  
> -#include "../mtk_vcodec_drv.h"
> +#include "../mtk_vcodec_enc_drv.h"
>  #include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../mtk_vcodec_enc.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> index e8e4474eacc7..dfd6833576f4 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> @@ -9,7 +9,7 @@
>  #include <linux/kernel.h>
>  #include <linux/slab.h>
>  
> -#include "../mtk_vcodec_drv.h"
> +#include "../mtk_vcodec_enc_drv.h"
>  #include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../mtk_vcodec_enc.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/venc_drv_base.h b/drivers/media/platform/mediatek/vcodec/venc_drv_base.h
> index 17f8183461b5..856d50151bf6 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc_drv_base.h
> +++ b/drivers/media/platform/mediatek/vcodec/venc_drv_base.h
> @@ -9,7 +9,7 @@
>  #ifndef _VENC_DRV_BASE_
>  #define _VENC_DRV_BASE_
>  
> -#include "mtk_vcodec_drv.h"
> +#include "mtk_vcodec_enc_drv.h"
>  
>  #include "venc_drv_if.h"
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/venc_drv_if.c b/drivers/media/platform/mediatek/vcodec/venc_drv_if.c
> index 08083030516e..1bdaecdd64a7 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc_drv_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc_drv_if.c
> @@ -65,7 +65,7 @@ int venc_if_encode(struct mtk_vcodec_enc_ctx *ctx,
>  	mtk_venc_lock(ctx);
>  
>  	spin_lock_irqsave(&ctx->dev->irqlock, flags);
> -	ctx->dev->curr_enc_ctx = ctx;
> +	ctx->dev->curr_ctx = ctx;
>  	spin_unlock_irqrestore(&ctx->dev->irqlock, flags);
>  
>  	mtk_vcodec_enc_clock_on(&ctx->dev->pm);
> @@ -74,7 +74,7 @@ int venc_if_encode(struct mtk_vcodec_enc_ctx *ctx,
>  	mtk_vcodec_enc_clock_off(&ctx->dev->pm);
>  
>  	spin_lock_irqsave(&ctx->dev->irqlock, flags);
> -	ctx->dev->curr_enc_ctx = NULL;
> +	ctx->dev->curr_ctx = NULL;
>  	spin_unlock_irqrestore(&ctx->dev->irqlock, flags);
>  
>  	mtk_venc_unlock(ctx);
> diff --git a/drivers/media/platform/mediatek/vcodec/venc_drv_if.h b/drivers/media/platform/mediatek/vcodec/venc_drv_if.h
> index 90d714e86ede..d00fb68b8235 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc_drv_if.h
> +++ b/drivers/media/platform/mediatek/vcodec/venc_drv_if.h
> @@ -9,8 +9,7 @@
>  #ifndef _VENC_DRV_IF_H_
>  #define _VENC_DRV_IF_H_
>  
> -#include "mtk_vcodec_drv.h"
> -#include "mtk_vcodec_util.h"
> +#include "mtk_vcodec_enc_drv.h"
>  
>  /*
>   * enum venc_yuv_fmt - The type of input yuv format
> diff --git a/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c b/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> index c69f66b6d341..bfff16da0451 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> @@ -4,7 +4,7 @@
>   * Author: PoChun Lin <pochun.lin@mediatek.com>
>   */
>  
> -#include "mtk_vcodec_drv.h"
> +#include "mtk_vcodec_enc_drv.h"
>  #include "mtk_vcodec_fw.h"
>  #include "venc_ipi_msg.h"
>  #include "venc_vpu_if.h"
Nicolas Dufresne July 3, 2023, 8:09 p.m. UTC | #3
Le lundi 26 juin 2023 à 11:53 +0800, Yunfei Dong a écrit :
> The shared struct 'mtk_vcodec_ctx/dev' will be changed to 'mtk_vcodec_enc_ctx/dev'
> and 'mtk_vcodec_dec_ctx/dev' in order to separate encoder and decoder. Removing
> common struct 'mtk_vcodec_ctx/dev' for shared interface which encoder and decoder
> used at the same time. Then encoder and decoder can call the same interface
> independently.
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> ---
>  .../mediatek/vcodec/mtk_vcodec_intr.c         | 30 ++++++++++++-------
>  .../mediatek/vcodec/mtk_vcodec_intr.h         |  3 +-
>  .../mediatek/vcodec/mtk_vcodec_util.c         | 19 +++++-------
>  .../mediatek/vcodec/mtk_vcodec_util.h         |  9 ++----
>  .../mediatek/vcodec/vdec/vdec_vp8_if.c        | 14 ++++-----
>  .../mediatek/vcodec/venc/venc_h264_if.c       |  2 +-
>  .../mediatek/vcodec/venc/venc_vp8_if.c        |  2 +-
>  7 files changed, 39 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> index 552b4c93d972..daa44f635727 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> @@ -11,32 +11,40 @@
>  #include "mtk_vcodec_intr.h"
>  #include "mtk_vcodec_util.h"
>  
> -int mtk_vcodec_wait_for_done_ctx(struct mtk_vcodec_ctx *ctx,
> -				 int command, unsigned int timeout_ms,
> +int mtk_vcodec_wait_for_done_ctx(void *priv, int command, unsigned int timeout_ms,
>  				 unsigned int hw_id)
>  {
> +	struct mtk_vcodec_ctx *ctx = priv;
>  	long timeout_jiff, ret;
> -	int status = 0;
> +	int status = 0, ctx_id, ctx_type;
> +	int *ctx_int_cond, *ctx_int_type;
> +	wait_queue_head_t *ctx_queue;
> +
> +	ctx_id = ctx->id;
> +	ctx_type = ctx->type;
> +	ctx_int_cond = ctx->int_cond;
> +	ctx_int_type = ctx->int_type;
> +	ctx_queue = ctx->queue;
>  
>  	timeout_jiff = msecs_to_jiffies(timeout_ms);
> -	ret = wait_event_interruptible_timeout(ctx->queue[hw_id],
> -					       ctx->int_cond[hw_id],
> +	ret = wait_event_interruptible_timeout(ctx_queue[hw_id],
> +					       ctx_int_cond[hw_id],
>  					       timeout_jiff);
>  
>  	if (!ret) {
>  		status = -1;	/* timeout */
>  		mtk_v4l2_err("[%d] cmd=%d, type=%d, dec timeout=%ums (%d %d)",
> -			     ctx->id, command, ctx->type, timeout_ms,
> -			     ctx->int_cond[hw_id], ctx->int_type[hw_id]);
> +			     ctx_id, command, ctx_type, timeout_ms,
> +			     ctx_int_cond[hw_id], ctx_int_type[hw_id]);
>  	} else if (-ERESTARTSYS == ret) {
>  		status = -1;
>  		mtk_v4l2_err("[%d] cmd=%d, type=%d, dec inter fail (%d %d)",
> -			     ctx->id, command, ctx->type,
> -			     ctx->int_cond[hw_id], ctx->int_type[hw_id]);
> +			     ctx_id, command, ctx_type,
> +			     ctx_int_cond[hw_id], ctx_int_type[hw_id]);
>  	}
>  
> -	ctx->int_cond[hw_id] = 0;
> -	ctx->int_type[hw_id] = 0;
> +	ctx_int_cond[hw_id] = 0;
> +	ctx_int_type[hw_id] = 0;
>  
>  	return status;
>  }
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.h
> index 9681f492813b..11bf0ef94d5d 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.h
> @@ -12,8 +12,7 @@
>  struct mtk_vcodec_ctx;
>  
>  /* timeout is ms */
> -int mtk_vcodec_wait_for_done_ctx(struct mtk_vcodec_ctx *ctx,
> -				 int command, unsigned int timeout_ms,
> +int mtk_vcodec_wait_for_done_ctx(void *priv, int command, unsigned int timeout_ms,
>  				 unsigned int hw_id);
>  
>  #endif /* _MTK_VCODEC_INTR_H_ */
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> index f214e6f67005..847e321f4fcc 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> @@ -21,24 +21,20 @@ int mtk_v4l2_dbg_level;
>  EXPORT_SYMBOL(mtk_v4l2_dbg_level);
>  #endif
>  
> -void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
> -					unsigned int reg_idx)
> +void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base, unsigned int reg_idx)
>  {
> -	struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data;
> -
> -	if (!data || reg_idx >= NUM_MAX_VCODEC_REG_BASE) {
> +	if (reg_idx >= NUM_MAX_VCODEC_REG_BASE) {
>  		mtk_v4l2_err("Invalid arguments, reg_idx=%d", reg_idx);
>  		return NULL;
>  	}
> -	return ctx->dev->reg_base[reg_idx];
> +	return reg_base[reg_idx];
>  }
>  EXPORT_SYMBOL(mtk_vcodec_get_reg_addr);
>  
> -int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
> -			struct mtk_vcodec_mem *mem)
> +int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem)
>  {
>  	unsigned long size = mem->size;
> -	struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data;
> +	struct mtk_vcodec_ctx *ctx = priv;
>  	struct device *dev = &ctx->dev->plat_dev->dev;
>  
>  	mem->va = dma_alloc_coherent(dev, size, &mem->dma_addr, GFP_KERNEL);
> @@ -57,11 +53,10 @@ int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
>  }
>  EXPORT_SYMBOL(mtk_vcodec_mem_alloc);
>  
> -void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
> -			struct mtk_vcodec_mem *mem)
> +void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem)
>  {
>  	unsigned long size = mem->size;
> -	struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data;
> +	struct mtk_vcodec_ctx *ctx = priv;
>  	struct device *dev = &ctx->dev->plat_dev->dev;
>  
>  	if (!mem->va) {
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> index 88d389b65f13..827937bcb4b4 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> @@ -68,12 +68,9 @@ extern int mtk_vcodec_dbg;
>  #define mtk_vcodec_debug_enter(h)  mtk_vcodec_debug(h, "+")
>  #define mtk_vcodec_debug_leave(h)  mtk_vcodec_debug(h, "-")
>  
> -void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
> -				unsigned int reg_idx);
> -int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
> -				struct mtk_vcodec_mem *mem);
> -void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
> -				struct mtk_vcodec_mem *mem);
> +void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base, unsigned int reg_idx);
> +int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem);
> +void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem);
>  void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
>  			     struct mtk_vcodec_ctx *ctx, int hw_idx);
>  struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> index 88c046731754..5edbccc9ae68 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> @@ -167,13 +167,13 @@ struct vdec_vp8_inst {
>  
>  static void get_hw_reg_base(struct vdec_vp8_inst *inst)
>  {

I'd like to suggest:

+	u32 reg_base = inst->ctx->dev->reg_base

> -	inst->reg_base.top = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_TOP);
> -	inst->reg_base.cm = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_CM);
> -	inst->reg_base.hwd = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_HWD);
> -	inst->reg_base.sys = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_SYS);
> -	inst->reg_base.misc = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_MISC);
> -	inst->reg_base.ld = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_LD);
> -	inst->reg_base.hwb = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_HWB);
> +	inst->reg_base.top = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VDEC_TOP);
> +	inst->reg_base.cm = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VDEC_CM);
> +	inst->reg_base.hwd = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VDEC_HWD);
> +	inst->reg_base.sys = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VDEC_SYS);
> +	inst->reg_base.misc = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VDEC_MISC);
> +	inst->reg_base.ld = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VDEC_LD);
> +	inst->reg_base.hwb = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VDEC_HWB);

+	inst->reg_base.top = mtk_vcodec_get_reg_addr(reg_base, VDEC_TOP);
+	inst->reg_base.cm = mtk_vcodec_get_reg_addr(reg_base, VDEC_CM);
+	inst->reg_base.hwd = mtk_vcodec_get_reg_addr(reg_base, VDEC_HWD);
+	inst->reg_base.sys = mtk_vcodec_get_reg_addr(reg_base, VDEC_SYS);
+	inst->reg_base.misc = mtk_vcodec_get_reg_addr(reg_base, VDEC_MISC);
+	inst->reg_base.ld = mtk_vcodec_get_reg_addr(reg_base, VDEC_LD);
+	inst->reg_base.hwb = mtk_vcodec_get_reg_addr(reg_base, VDEC_HWB);

With such minor stylistic change:

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

>  }
>  
>  static void write_hw_segmentation_data(struct vdec_vp8_inst *inst)
> diff --git a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> index 60fd165c0d94..10365c95ebbe 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> @@ -612,7 +612,7 @@ static int h264_enc_init(struct mtk_vcodec_ctx *ctx)
>  	inst->ctx = ctx;
>  	inst->vpu_inst.ctx = ctx;
>  	inst->vpu_inst.id = is_ext ? SCP_IPI_VENC_H264 : IPI_VENC_H264;
> -	inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx, VENC_SYS);
> +	inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VENC_SYS);
>  
>  	mtk_vcodec_debug_enter(inst);
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> index 56ce58f761f1..73ebc35d7c99 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> @@ -336,7 +336,7 @@ static int vp8_enc_init(struct mtk_vcodec_ctx *ctx)
>  	inst->ctx = ctx;
>  	inst->vpu_inst.ctx = ctx;
>  	inst->vpu_inst.id = IPI_VENC_VP8;
> -	inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx, VENC_LT_SYS);
> +	inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VENC_LT_SYS);
>  
>  	mtk_vcodec_debug_enter(inst);
>
Nicolas Dufresne July 3, 2023, 8:10 p.m. UTC | #4
Le lundi 26 juin 2023 à 11:53 +0800, Yunfei Dong a écrit :
> Fix unreasonable coding style.
> Fix unreasonable parameter definition.
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> ---
>  .../media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h   | 4 ++--
>  .../media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h   | 8 ++++----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h
> index a18ba8f32d41..1a0375dd5b6d 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h
> @@ -19,7 +19,7 @@
>  #define IS_VDEC_INNER_RACING(capability) ((capability) & MTK_VCODEC_INNER_RACING)
>  
>  /*
> - * struct mtk_vdec_format_types - Structure used to get supported
> + * enum mtk_vdec_format_types - Structure used to get supported
>   *		  format types according to decoder capability
>   */
>  enum mtk_vdec_format_types {
> @@ -258,7 +258,7 @@ struct mtk_vcodec_dec_dev {
>  	const struct mtk_vcodec_dec_pdata *vdec_pdata;
>  
>  	struct mtk_vcodec_fw *fw_handler;
> -	unsigned long id_counter;
> +	u64 id_counter;
>  
>  	/* decoder hardware mutex lock */
>  	struct mutex dec_mutex[MTK_VDEC_HW_MAX];
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h
> index a88ef9078848..4804d8531a4e 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h
> @@ -32,13 +32,13 @@
>   */
>  struct mtk_vcodec_enc_pdata {
>  	bool uses_ext;
> -	unsigned long min_bitrate;
> -	unsigned long max_bitrate;
> +	u64 min_bitrate;
> +	u64 max_bitrate;
>  	const struct mtk_video_fmt *capture_formats;
>  	size_t num_capture_formats;
>  	const struct mtk_video_fmt *output_formats;
>  	size_t num_output_formats;
> -	int core_id;
> +	u8 core_id;
>  	bool uses_34bit;
>  };
>  
> @@ -208,7 +208,7 @@ struct mtk_vcodec_enc_dev {
>  	const struct mtk_vcodec_enc_pdata *venc_pdata;
>  
>  	struct mtk_vcodec_fw *fw_handler;
> -	unsigned long id_counter;
> +	u64 id_counter;
>  
>  	/* encoder hardware mutex lock */
>  	struct mutex enc_mutex;
Nicolas Dufresne July 3, 2023, 8:11 p.m. UTC | #5
Le lundi 26 juin 2023 à 11:53 +0800, Yunfei Dong a écrit :
> remove unused include header for .c files
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> ---
>  drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c         | 2 --
>  drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c     | 2 --
>  drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c      | 1 -
>  drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c      | 1 -
>  .../media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c    | 2 --
>  .../media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c   | 2 --
>  drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c         | 2 --
>  drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c     | 2 --
>  drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c          | 2 --
>  .../media/platform/mediatek/vcodec/vdec/vdec_av1_req_lat_if.c   | 1 -
>  drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_if.c      | 1 -
>  drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_if.c  | 1 -
>  .../platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c      | 1 -
>  .../platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c      | 1 -
>  drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c       | 1 -
>  drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c   | 1 -
>  .../media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c   | 1 -
>  drivers/media/platform/mediatek/vcodec/vdec_drv_if.h            | 1 -
>  drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h         | 2 --
>  drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c            | 1 -
>  drivers/media/platform/mediatek/vcodec/vdec_vpu_if.h            | 2 --
>  drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c      | 1 -
>  drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c       | 1 -
>  drivers/media/platform/mediatek/vcodec/venc_vpu_if.c            | 1 -
>  drivers/media/platform/mediatek/vcodec/venc_vpu_if.h            | 1 -
>  25 files changed, 34 deletions(-)
> 
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> index 0363fec572e5..5acb7dff18f2 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> @@ -11,8 +11,6 @@
>  
>  #include "mtk_vcodec_dec_drv.h"
>  #include "mtk_vcodec_dec.h"
> -#include "mtk_vcodec_intr.h"
> -#include "mtk_vcodec_util.h"
>  #include "vdec_drv_if.h"
>  #include "mtk_vcodec_dec_pm.h"
>  
> 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 8e3aea9a3ab0..36970113d069 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
> @@ -21,8 +21,6 @@
>  #include "mtk_vcodec_dec_hw.h"
>  #include "mtk_vcodec_dec_pm.h"
>  #include "mtk_vcodec_intr.h"
> -#include "mtk_vcodec_util.h"
> -#include "mtk_vcodec_fw.h"
>  
>  static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dec_ctx *ctx, struct mtk_vcodec_dec_dev *dev)
>  {
> 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 23c19efa3cf6..fa02fcf4e8c2 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c
> @@ -16,7 +16,6 @@
>  #include "mtk_vcodec_dec_hw.h"
>  #include "mtk_vcodec_dec_pm.h"
>  #include "mtk_vcodec_intr.h"
> -#include "mtk_vcodec_util.h"
>  
>  static const struct of_device_id mtk_vdec_hw_match[] = {
>  	{
> 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 ed1f503a944e..edd3e6e2df85 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c
> @@ -12,7 +12,6 @@
>  
>  #include "mtk_vcodec_dec_hw.h"
>  #include "mtk_vcodec_dec_pm.h"
> -#include "mtk_vcodec_util.h"
>  
>  int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *pm)
>  {
> 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 459e74a46737..11ca2c2fbaad 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c
> @@ -5,8 +5,6 @@
>  #include <media/videobuf2-dma-contig.h>
>  
>  #include "mtk_vcodec_dec.h"
> -#include "mtk_vcodec_intr.h"
> -#include "mtk_vcodec_util.h"
>  #include "mtk_vcodec_dec_pm.h"
>  #include "vdec_drv_if.h"
>  
> 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 6268a39c2bb3..38b30c876ede 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> @@ -7,8 +7,6 @@
>  #include <linux/module.h>
>  
>  #include "mtk_vcodec_dec.h"
> -#include "mtk_vcodec_intr.h"
> -#include "mtk_vcodec_util.h"
>  #include "mtk_vcodec_dec_pm.h"
>  #include "vdec_drv_if.h"
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c
> index 85dabb20fb11..8e44a051edda 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c
> @@ -11,8 +11,6 @@
>  #include <linux/pm_runtime.h>
>  
>  #include "mtk_vcodec_enc.h"
> -#include "mtk_vcodec_intr.h"
> -#include "mtk_vcodec_util.h"
>  #include "venc_drv_if.h"
>  
>  #define MTK_VENC_MIN_W	160U
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
> index 0830708de32f..f1b4d5e8cd49 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
> @@ -19,8 +19,6 @@
>  #include "mtk_vcodec_enc.h"
>  #include "mtk_vcodec_enc_pm.h"
>  #include "mtk_vcodec_intr.h"
> -#include "mtk_vcodec_util.h"
> -#include "mtk_vcodec_fw.h"
>  
>  static const struct mtk_video_fmt mtk_video_formats_output[] = {
>  	{
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c
> index 5c9f04574ad1..e59ce7c78742 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c
> @@ -2,9 +2,7 @@
>  
>  #include "mtk_vcodec_dec_drv.h"
>  #include "mtk_vcodec_enc_drv.h"
> -#include "mtk_vcodec_fw.h"
>  #include "mtk_vcodec_fw_priv.h"
> -#include "mtk_vcodec_util.h"
>  
>  struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum mtk_vcodec_fw_type type,
>  					   enum mtk_vcodec_fw_use fw_use)
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_av1_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_av1_req_lat_if.c
> index 96ed4bec169e..d272fef36cd1 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_av1_req_lat_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_av1_req_lat_if.c
> @@ -8,7 +8,6 @@
>  #include <linux/slab.h>
>  #include <media/videobuf2-dma-contig.h>
>  
> -#include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_dec.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../vdec_drv_base.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_if.c
> index 69914e26cd20..a8175f977ed2 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_if.c
> @@ -8,7 +8,6 @@
>  #include <linux/slab.h>
>  
>  #include "../vdec_drv_if.h"
> -#include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_dec.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../vdec_vpu_if.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_if.c
> index 4eb98a705be4..4c5ef35199a1 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_if.c
> @@ -6,7 +6,6 @@
>  #include <media/v4l2-h264.h>
>  #include <media/videobuf2-dma-contig.h>
>  
> -#include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_dec.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../vdec_drv_base.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> index 79eff921fc97..0f9f7b56882f 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.c
> @@ -10,7 +10,6 @@
>  #include <media/v4l2-mem2mem.h>
>  #include <media/videobuf2-dma-contig.h>
>  
> -#include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_dec.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../vdec_drv_base.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c
> index 67a5f8b82eb8..2682f40d1361 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_hevc_req_multi_if.c
> @@ -8,7 +8,6 @@
>  #include <linux/slab.h>
>  #include <media/videobuf2-dma-contig.h>
>  
> -#include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_dec.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../vdec_drv_base.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> index a8606f74ddc1..ceddcfd9135b 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> @@ -7,7 +7,6 @@
>  
>  #include <linux/slab.h>
>  #include "../vdec_drv_if.h"
> -#include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_dec.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../vdec_vpu_if.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c
> index d3103b877b61..c85c849d2548 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_req_if.c
> @@ -9,7 +9,6 @@
>  #include <media/videobuf2-dma-contig.h>
>  #include <uapi/linux/v4l2-controls.h>
>  
> -#include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_dec.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../vdec_drv_base.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
> index 106ee4daf00b..3e9458470484 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
> @@ -9,7 +9,6 @@
>  #include <media/videobuf2-dma-contig.h>
>  #include <media/v4l2-vp9.h>
>  
> -#include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_dec.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../vdec_drv_base.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h b/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h
> index 7b41ce23158b..bfd297c96850 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h
> +++ b/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h
> @@ -9,7 +9,6 @@
>  #define _VDEC_DRV_IF_H_
>  
>  #include "mtk_vcodec_dec.h"
> -#include "mtk_vcodec_util.h"
>  
>  
>  /**
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
> index eeb5deb907ed..1d9beb9e4a14 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
> +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
> @@ -12,8 +12,6 @@
>  #include <linux/slab.h>
>  #include <media/videobuf2-v4l2.h>
>  
> -#include "mtk_vcodec_util.h"
> -
>  #define NUM_BUFFER_COUNT 3
>  
>  struct vdec_lat_buf;
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> index 7fe8e196cb45..82c3dc8c4127 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> @@ -8,7 +8,6 @@
>  #include "vdec_drv_if.h"
>  #include "vdec_ipi_msg.h"
>  #include "vdec_vpu_if.h"
> -#include "mtk_vcodec_fw.h"
>  
>  static void handle_init_ack_msg(const struct vdec_vpu_ipi_init_ack *msg)
>  {
> diff --git a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.h b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.h
> index c9766c108209..fbb3f34a73f0 100644
> --- a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.h
> +++ b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.h
> @@ -7,8 +7,6 @@
>  #ifndef _VDEC_VPU_IF_H_
>  #define _VDEC_VPU_IF_H_
>  
> -#include "mtk_vcodec_fw.h"
> -
>  struct mtk_vcodec_dec_ctx;
>  
>  /**
> diff --git a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> index 41d463d40843..9127bceb0db4 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> @@ -11,7 +11,6 @@
>  #include <linux/slab.h>
>  
>  #include "../mtk_vcodec_enc_drv.h"
> -#include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../mtk_vcodec_enc.h"
>  #include "../mtk_vcodec_enc_pm.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> index dfd6833576f4..510f3b042670 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> @@ -10,7 +10,6 @@
>  #include <linux/slab.h>
>  
>  #include "../mtk_vcodec_enc_drv.h"
> -#include "../mtk_vcodec_util.h"
>  #include "../mtk_vcodec_intr.h"
>  #include "../mtk_vcodec_enc.h"
>  #include "../mtk_vcodec_enc_pm.h"
> diff --git a/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c b/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> index bfff16da0451..708db1bb32d4 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> @@ -5,7 +5,6 @@
>   */
>  
>  #include "mtk_vcodec_enc_drv.h"
> -#include "mtk_vcodec_fw.h"
>  #include "venc_ipi_msg.h"
>  #include "venc_vpu_if.h"
>  
> diff --git a/drivers/media/platform/mediatek/vcodec/venc_vpu_if.h b/drivers/media/platform/mediatek/vcodec/venc_vpu_if.h
> index 71370ab98809..ede55fc3bd07 100644
> --- a/drivers/media/platform/mediatek/vcodec/venc_vpu_if.h
> +++ b/drivers/media/platform/mediatek/vcodec/venc_vpu_if.h
> @@ -7,7 +7,6 @@
>  #ifndef _VENC_VPU_IF_H_
>  #define _VENC_VPU_IF_H_
>  
> -#include "mtk_vcodec_fw.h"
>  #include "venc_drv_if.h"
>  
>  /*
Yunfei Dong (董云飞) July 4, 2023, 10:59 a.m. UTC | #6
Hi Nicolas,

Thanks for you suggestion.
On Mon, 2023-07-03 at 16:09 -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 :
> > The shared struct 'mtk_vcodec_ctx/dev' will be changed to
> 'mtk_vcodec_enc_ctx/dev'
> > and 'mtk_vcodec_dec_ctx/dev' in order to separate encoder and
> decoder. Removing
> > common struct 'mtk_vcodec_ctx/dev' for shared interface which
> encoder and decoder
> > used at the same time. Then encoder and decoder can call the same
> interface
> > independently.
> > 
> > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> > ---
> >  .../mediatek/vcodec/mtk_vcodec_intr.c         | 30 ++++++++++++---
> ----
> >  .../mediatek/vcodec/mtk_vcodec_intr.h         |  3 +-
> >  .../mediatek/vcodec/mtk_vcodec_util.c         | 19 +++++-------
> >  .../mediatek/vcodec/mtk_vcodec_util.h         |  9 ++----
> >  .../mediatek/vcodec/vdec/vdec_vp8_if.c        | 14 ++++-----
> >  .../mediatek/vcodec/venc/venc_h264_if.c       |  2 +-
> >  .../mediatek/vcodec/venc/venc_vp8_if.c        |  2 +-
> >  7 files changed, 39 insertions(+), 40 deletions(-)
> > 
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> > index 552b4c93d972..daa44f635727 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> > @@ -11,32 +11,40 @@
> >  #include "mtk_vcodec_intr.h"
> >  #include "mtk_vcodec_util.h"
> >  
> > -int mtk_vcodec_wait_for_done_ctx(struct mtk_vcodec_ctx *ctx,
> > - int command, unsigned int timeout_ms,
> > +int mtk_vcodec_wait_for_done_ctx(void *priv, int command, unsigned
> int timeout_ms,
> >   unsigned int hw_id)
> >  {
> > +struct mtk_vcodec_ctx *ctx = priv;
> >  long timeout_jiff, ret;
> > -int status = 0;
> > +int status = 0, ctx_id, ctx_type;
> > +int *ctx_int_cond, *ctx_int_type;
> > +wait_queue_head_t *ctx_queue;
> > +
> > +ctx_id = ctx->id;
> > +ctx_type = ctx->type;
> > +ctx_int_cond = ctx->int_cond;
> > +ctx_int_type = ctx->int_type;
> > +ctx_queue = ctx->queue;
> >  
> >  timeout_jiff = msecs_to_jiffies(timeout_ms);
> > -ret = wait_event_interruptible_timeout(ctx->queue[hw_id],
> > -       ctx->int_cond[hw_id],
> > +ret = wait_event_interruptible_timeout(ctx_queue[hw_id],
> > +       ctx_int_cond[hw_id],
> >         timeout_jiff);
> >  
> >  if (!ret) {
> >  status = -1;/* timeout */
> >  mtk_v4l2_err("[%d] cmd=%d, type=%d, dec timeout=%ums (%d %d)",
> > -     ctx->id, command, ctx->type, timeout_ms,
> > -     ctx->int_cond[hw_id], ctx->int_type[hw_id]);
> > +     ctx_id, command, ctx_type, timeout_ms,
> > +     ctx_int_cond[hw_id], ctx_int_type[hw_id]);
> >  } else if (-ERESTARTSYS == ret) {
> >  status = -1;
> >  mtk_v4l2_err("[%d] cmd=%d, type=%d, dec inter fail (%d %d)",
> > -     ctx->id, command, ctx->type,
> > -     ctx->int_cond[hw_id], ctx->int_type[hw_id]);
> > +     ctx_id, command, ctx_type,
> > +     ctx_int_cond[hw_id], ctx_int_type[hw_id]);
> >  }
> >  
> > -ctx->int_cond[hw_id] = 0;
> > -ctx->int_type[hw_id] = 0;
> > +ctx_int_cond[hw_id] = 0;
> > +ctx_int_type[hw_id] = 0;
> >  
> >  return status;
> >  }
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.h
> > index 9681f492813b..11bf0ef94d5d 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.h
> > @@ -12,8 +12,7 @@
> >  struct mtk_vcodec_ctx;
> >  
> >  /* timeout is ms */
> > -int mtk_vcodec_wait_for_done_ctx(struct mtk_vcodec_ctx *ctx,
> > - int command, unsigned int timeout_ms,
> > +int mtk_vcodec_wait_for_done_ctx(void *priv, int command, unsigned
> int timeout_ms,
> >   unsigned int hw_id);
> >  
> >  #endif /* _MTK_VCODEC_INTR_H_ */
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> > index f214e6f67005..847e321f4fcc 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> > @@ -21,24 +21,20 @@ int mtk_v4l2_dbg_level;
> >  EXPORT_SYMBOL(mtk_v4l2_dbg_level);
> >  #endif
> >  
> > -void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
> > -unsigned int reg_idx)
> > +void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base,
> unsigned int reg_idx)
> >  {
> > -struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data;
> > -
> > -if (!data || reg_idx >= NUM_MAX_VCODEC_REG_BASE) {
> > +if (reg_idx >= NUM_MAX_VCODEC_REG_BASE) {
> >  mtk_v4l2_err("Invalid arguments, reg_idx=%d", reg_idx);
> >  return NULL;
> >  }
> > -return ctx->dev->reg_base[reg_idx];
> > +return reg_base[reg_idx];
> >  }
> >  EXPORT_SYMBOL(mtk_vcodec_get_reg_addr);
> >  
> > -int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
> > -struct mtk_vcodec_mem *mem)
> > +int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem)
> >  {
> >  unsigned long size = mem->size;
> > -struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data;
> > +struct mtk_vcodec_ctx *ctx = priv;
> >  struct device *dev = &ctx->dev->plat_dev->dev;
> >  
> >  mem->va = dma_alloc_coherent(dev, size, &mem->dma_addr,
> GFP_KERNEL);
> > @@ -57,11 +53,10 @@ int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx
> *data,
> >  }
> >  EXPORT_SYMBOL(mtk_vcodec_mem_alloc);
> >  
> > -void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
> > -struct mtk_vcodec_mem *mem)
> > +void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem)
> >  {
> >  unsigned long size = mem->size;
> > -struct mtk_vcodec_ctx *ctx = (struct mtk_vcodec_ctx *)data;
> > +struct mtk_vcodec_ctx *ctx = priv;
> >  struct device *dev = &ctx->dev->plat_dev->dev;
> >  
> >  if (!mem->va) {
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> > index 88d389b65f13..827937bcb4b4 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> > @@ -68,12 +68,9 @@ extern int mtk_vcodec_dbg;
> >  #define mtk_vcodec_debug_enter(h)  mtk_vcodec_debug(h, "+")
> >  #define mtk_vcodec_debug_leave(h)  mtk_vcodec_debug(h, "-")
> >  
> > -void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
> > -unsigned int reg_idx);
> > -int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
> > -struct mtk_vcodec_mem *mem);
> > -void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
> > -struct mtk_vcodec_mem *mem);
> > +void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base,
> unsigned int reg_idx);
> > +int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem);
> > +void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem);
> >  void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
> >       struct mtk_vcodec_ctx *ctx, int hw_idx);
> >  struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct
> mtk_vcodec_dev *vdec_dev,
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> > index 88c046731754..5edbccc9ae68 100644
> > --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp8_if.c
> > @@ -167,13 +167,13 @@ struct vdec_vp8_inst {
> >  
> >  static void get_hw_reg_base(struct vdec_vp8_inst *inst)
> >  {
> 
> I'd like to suggest:
> 
> +u32 reg_base = inst->ctx->dev->reg_base
> 
> > -inst->reg_base.top = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_TOP);
> > -inst->reg_base.cm = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_CM);
> > -inst->reg_base.hwd = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_HWD);
> > -inst->reg_base.sys = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_SYS);
> > -inst->reg_base.misc = mtk_vcodec_get_reg_addr(inst->ctx,
> VDEC_MISC);
> > -inst->reg_base.ld = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_LD);
> > -inst->reg_base.hwb = mtk_vcodec_get_reg_addr(inst->ctx, VDEC_HWB);
> > +inst->reg_base.top = mtk_vcodec_get_reg_addr(inst->ctx->dev-
> >reg_base, VDEC_TOP);
> > +inst->reg_base.cm = mtk_vcodec_get_reg_addr(inst->ctx->dev-
> >reg_base, VDEC_CM);
> > +inst->reg_base.hwd = mtk_vcodec_get_reg_addr(inst->ctx->dev-
> >reg_base, VDEC_HWD);
> > +inst->reg_base.sys = mtk_vcodec_get_reg_addr(inst->ctx->dev-
> >reg_base, VDEC_SYS);
> > +inst->reg_base.misc = mtk_vcodec_get_reg_addr(inst->ctx->dev-
> >reg_base, VDEC_MISC);
> > +inst->reg_base.ld = mtk_vcodec_get_reg_addr(inst->ctx->dev-
> >reg_base, VDEC_LD);
> > +inst->reg_base.hwb = mtk_vcodec_get_reg_addr(inst->ctx->dev-
> >reg_base, VDEC_HWB);
> 
> +inst->reg_base.top = mtk_vcodec_get_reg_addr(reg_base, VDEC_TOP);
> +inst->reg_base.cm = mtk_vcodec_get_reg_addr(reg_base, VDEC_CM);
> +inst->reg_base.hwd = mtk_vcodec_get_reg_addr(reg_base, VDEC_HWD);
> +inst->reg_base.sys = mtk_vcodec_get_reg_addr(reg_base, VDEC_SYS);
> +inst->reg_base.misc = mtk_vcodec_get_reg_addr(reg_base, VDEC_MISC);
> +inst->reg_base.ld = mtk_vcodec_get_reg_addr(reg_base, VDEC_LD);
> +inst->reg_base.hwb = mtk_vcodec_get_reg_addr(reg_base, VDEC_HWB);
> 
> With such minor stylistic change:
> 
> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> 

Fixed in patch v5, please help to review it again.

Best Regards,
Yunfei Dong
> >  }
> >  
> >  static void write_hw_segmentation_data(struct vdec_vp8_inst *inst)
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> > index 60fd165c0d94..10365c95ebbe 100644
> > --- a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> > @@ -612,7 +612,7 @@ static int h264_enc_init(struct mtk_vcodec_ctx
> *ctx)
> >  inst->ctx = ctx;
> >  inst->vpu_inst.ctx = ctx;
> >  inst->vpu_inst.id = is_ext ? SCP_IPI_VENC_H264 : IPI_VENC_H264;
> > -inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx, VENC_SYS);
> > +inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base,
> VENC_SYS);
> >  
> >  mtk_vcodec_debug_enter(inst);
> >  
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> > index 56ce58f761f1..73ebc35d7c99 100644
> > --- a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> > @@ -336,7 +336,7 @@ static int vp8_enc_init(struct mtk_vcodec_ctx
> *ctx)
> >  inst->ctx = ctx;
> >  inst->vpu_inst.ctx = ctx;
> >  inst->vpu_inst.id = IPI_VENC_VP8;
> > -inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx, VENC_LT_SYS);
> > +inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base,
> VENC_LT_SYS);
> >  
> >  mtk_vcodec_debug_enter(inst);
> >  
>
Yunfei Dong (董云飞) July 4, 2023, 11:15 a.m. UTC | #7
Hi Nicolas,

Thanks for your suggestion.
On Mon, 2023-07-03 at 16:06 -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 dev struct for encoder and decoder, remove
> > 'struct mtk_vcodec_dev'.
> > 
> > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> > ---
> >  .../mediatek/vcodec/mtk_vcodec_com_drv.h      |  71 +++++
> >  .../mediatek/vcodec/mtk_vcodec_dbgfs.c        |  51 ++-
> >  .../mediatek/vcodec/mtk_vcodec_dbgfs.h        |  14 +-
> >  .../platform/mediatek/vcodec/mtk_vcodec_dec.c |   4 +-
> >  .../mediatek/vcodec/mtk_vcodec_dec_drv.c      |  19 +-
> >  .../mediatek/vcodec/mtk_vcodec_dec_drv.h      | 172 +++++++++-
> >  .../mediatek/vcodec/mtk_vcodec_dec_hw.c       |   5 +-
> >  .../mediatek/vcodec/mtk_vcodec_dec_hw.h       |   4 +-
> >  .../mediatek/vcodec/mtk_vcodec_dec_pm.c       |  10 +-
> >  .../mediatek/vcodec/mtk_vcodec_dec_pm.h       |   2 +-
> >  .../mediatek/vcodec/mtk_vcodec_dec_stateful.c |   3 +-
> >  .../vcodec/mtk_vcodec_dec_stateless.c         |   5 +-
> >  .../platform/mediatek/vcodec/mtk_vcodec_drv.h | 295 --------------
> ----
> >  .../platform/mediatek/vcodec/mtk_vcodec_enc.c |   5 +-
> >  .../mediatek/vcodec/mtk_vcodec_enc_drv.c      |  15 +-
> >  .../mediatek/vcodec/mtk_vcodec_enc_drv.h      |  93 +++++-
> >  .../mediatek/vcodec/mtk_vcodec_enc_pm.c       |   4 +-
> >  .../mediatek/vcodec/mtk_vcodec_enc_pm.h       |   4 +-
> >  .../platform/mediatek/vcodec/mtk_vcodec_fw.c  |  12 +-
> >  .../platform/mediatek/vcodec/mtk_vcodec_fw.h  |   3 +-
> >  .../mediatek/vcodec/mtk_vcodec_fw_priv.h      |   3 +-
> >  .../mediatek/vcodec/mtk_vcodec_fw_scp.c       |  21 +-
> >  .../mediatek/vcodec/mtk_vcodec_fw_vpu.c       |  18 +-
> >  .../mediatek/vcodec/mtk_vcodec_intr.c         |   4 +-
> >  .../mediatek/vcodec/mtk_vcodec_util.c         |  10 +-
> >  .../mediatek/vcodec/mtk_vcodec_util.h         |   8 +-
> >  .../vcodec/vdec/vdec_h264_req_common.h        |   2 +-
> >  .../vcodec/vdec/vdec_h264_req_multi_if.c      |   2 +-
> >  .../platform/mediatek/vcodec/vdec_drv_if.h    |   1 -
> >  .../platform/mediatek/vcodec/vdec_msg_queue.c |   4 +-
> >  .../platform/mediatek/vcodec/vdec_msg_queue.h |   2 +-
> >  .../platform/mediatek/vcodec/vdec_vpu_if.c    |   3 +-
> >  .../mediatek/vcodec/venc/venc_h264_if.c       |   2 +-
> >  .../mediatek/vcodec/venc/venc_vp8_if.c        |   2 +-
> >  .../platform/mediatek/vcodec/venc_drv_base.h  |   2 +-
> >  .../platform/mediatek/vcodec/venc_drv_if.c    |   4 +-
> >  .../platform/mediatek/vcodec/venc_drv_if.h    |   3 +-
> >  .../platform/mediatek/vcodec/venc_vpu_if.c    |   2 +-
> >  38 files changed, 465 insertions(+), 419 deletions(-)
> >  delete mode 100644
> drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h
> > 
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_com_drv.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_com_drv.h
> > index 3b6e1faf60ce..6087e27bd604 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_com_drv.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_com_drv.h
> > @@ -17,6 +17,77 @@
> >  
> >  #define MTK_VCODEC_MAX_PLANES3
> >  
> > +#define WAIT_INTR_TIMEOUT_MS1000
> > +
> > +/*
> > + * enum mtk_q_type - Type of queue
> > + */
> > +enum mtk_q_type {
> > +MTK_Q_DATA_SRC = 0,
> > +MTK_Q_DATA_DST = 1,
> > +};
> > +
> > +/*
> > + * enum mtk_hw_reg_idx - MTK hw register base index
> > + */
> > +enum mtk_hw_reg_idx {
> > +VDEC_SYS,
> > +VDEC_MISC,
> > +VDEC_LD,
> > +VDEC_TOP,
> > +VDEC_CM,
> > +VDEC_AD,
> > +VDEC_AV,
> > +VDEC_PP,
> > +VDEC_HWD,
> > +VDEC_HWQ,
> > +VDEC_HWB,
> > +VDEC_HWG,
> > +NUM_MAX_VDEC_REG_BASE,
> > +/* h264 encoder */
> > +VENC_SYS = NUM_MAX_VDEC_REG_BASE,
> > +/* vp8 encoder */
> > +VENC_LT_SYS,
> > +NUM_MAX_VCODEC_REG_BASE
> > +};
> > +
> > +/*
> > + * struct mtk_vcodec_clk_info - Structure used to store clock name
> > + */
> > +struct mtk_vcodec_clk_info {
> > +const char*clk_name;
> > +struct clk*vcodec_clk;
> > +};
> > +
> > +/*
> > + * struct mtk_vcodec_clk - Structure used to store vcodec clock
> information
> > + */
> > +struct mtk_vcodec_clk {
> > +struct mtk_vcodec_clk_info*clk_info;
> > +intclk_num;
> > +};
> > +
> > +/*
> > + * struct mtk_vcodec_pm - Power management data structure
> > + */
> > +struct mtk_vcodec_pm {
> > +struct mtk_vcodec_clkvdec_clk;
> > +struct mtk_vcodec_clkvenc_clk;
> > +struct device*dev;
> > +};
> > +
> > +/*
> > + * enum mtk_vdec_hw_id - Hardware index used to separate
> > + *                         different hardware
> > + */
> > +enum mtk_vdec_hw_id {
> > +MTK_VDEC_CORE,
> > +MTK_VDEC_LAT0,
> > +MTK_VDEC_LAT1,
> > +MTK_VDEC_LAT_SOC,
> > +MTK_VDEC_HW_MAX,
> > +};
> > +
> >  /**
> >   * enum mtk_instance_state - The state of an MTK Vcodec instance.
> >   * @MTK_STATE_FREE: default state when instance is created
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> > index 0f4bbfb3bba5..c6a02b33cc74 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> > @@ -7,7 +7,8 @@
> >  #include <linux/debugfs.h>
> >  
> >  #include "mtk_vcodec_dbgfs.h"
> > -#include "mtk_vcodec_drv.h"
> > +#include "mtk_vcodec_dec_drv.h"
> > +#include "mtk_vcodec_enc_drv.h"
> >  #include "mtk_vcodec_util.h"
> >  
> >  static void mtk_vdec_dbgfs_get_format_type(struct
> mtk_vcodec_dec_ctx *ctx, char *buf,
> > @@ -72,7 +73,7 @@ static void mtk_vdec_dbgfs_get_help(char *buf,
> int *used, int total)
> >  static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char
> __user *ubuf,
> >      size_t count, loff_t *ppos)
> >  {
> > -struct mtk_vcodec_dev *vcodec_dev = filp->private_data;
> > +struct mtk_vcodec_dec_dev *vcodec_dev = filp->private_data;
> >  struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs;
> >  
> >  mutex_lock(&dbgfs->dbgfs_lock);
> > @@ -88,7 +89,7 @@ static ssize_t mtk_vdec_dbgfs_write(struct file
> *filp, const char __user *ubuf,
> >  static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user
> *ubuf,
> >     size_t count, loff_t *ppos)
> >  {
> > -struct mtk_vcodec_dev *vcodec_dev = filp->private_data;
> > +struct mtk_vcodec_dec_dev *vcodec_dev = filp->private_data;
> >  struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs;
> >  struct mtk_vcodec_dbgfs_inst *dbgfs_inst;
> >  struct mtk_vcodec_dec_ctx *ctx;
> > @@ -146,7 +147,7 @@ static const struct file_operations vdec_fops =
> {
> >  void mtk_vcodec_dbgfs_create(struct mtk_vcodec_dec_ctx *ctx)
> >  {
> >  struct mtk_vcodec_dbgfs_inst *dbgfs_inst;
> > -struct mtk_vcodec_dev *vcodec_dev = ctx->dev;
> > +struct mtk_vcodec_dec_dev *vcodec_dev = ctx->dev;
> >  
> >  dbgfs_inst = kzalloc(sizeof(*dbgfs_inst), GFP_KERNEL);
> >  if (!dbgfs_inst)
> > @@ -161,7 +162,7 @@ void mtk_vcodec_dbgfs_create(struct
> mtk_vcodec_dec_ctx *ctx)
> >  }
> >  EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_create);
> >  
> > -void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev,
> int ctx_id)
> > +void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dec_dev
> *vcodec_dev, int ctx_id)
> >  {
> >  struct mtk_vcodec_dbgfs_inst *dbgfs_inst;
> >  
> > @@ -179,16 +180,13 @@ void mtk_vcodec_dbgfs_remove(struct
> mtk_vcodec_dev *vcodec_dev, int ctx_id)
> >  }
> >  EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_remove);
> >  
> > -void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool
> is_encode)
> > +static void mtk_vcodec_dbgfs_vdec_init(struct mtk_vcodec_dec_dev
> *vcodec_dev)
> >  {
> >  struct dentry *vcodec_root;
> >  
> > -if (is_encode)
> > -vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-enc",
> NULL);
> > -else
> > -vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec",
> NULL);
> > +vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec",
> NULL);
> >  if (IS_ERR(vcodec_dev->dbgfs.vcodec_root))
> > -dev_err(&vcodec_dev->plat_dev->dev, "create vcodec dir err:%d\n",
> > +dev_err(&vcodec_dev->plat_dev->dev, "create vdec dir err:%d\n",
> >  IS_ERR(vcodec_dev->dbgfs.vcodec_root));
> >  
> >  vcodec_root = vcodec_dev->dbgfs.vcodec_root;
> > @@ -196,18 +194,39 @@ void mtk_vcodec_dbgfs_init(struct
> mtk_vcodec_dev *vcodec_dev, bool is_encode)
> >  debugfs_create_x32("mtk_vcodec_dbg", 0644, vcodec_root,
> &mtk_vcodec_dbg);
> >  
> >  vcodec_dev->dbgfs.inst_count = 0;
> > -if (is_encode)
> > -return;
> > -
> >  INIT_LIST_HEAD(&vcodec_dev->dbgfs.dbgfs_head);
> >  debugfs_create_file("vdec", 0200, vcodec_root, vcodec_dev,
> &vdec_fops);
> >  mutex_init(&vcodec_dev->dbgfs.dbgfs_lock);
> >  }
> > +
> > +static void mtk_vcodec_dbgfs_venc_init(struct mtk_vcodec_enc_dev
> *vcodec_dev)
> > +{
> > +struct dentry *vcodec_root;
> > +
> > +vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-enc",
> NULL);
> > +if (IS_ERR(vcodec_dev->dbgfs.vcodec_root))
> > +dev_err(&vcodec_dev->plat_dev->dev, "create venc dir err:%d\n",
> > +IS_ERR(vcodec_dev->dbgfs.vcodec_root));
> > +
> > +vcodec_root = vcodec_dev->dbgfs.vcodec_root;
> > +debugfs_create_x32("mtk_v4l2_dbg_level", 0644, vcodec_root,
> &mtk_v4l2_dbg_level);
> > +debugfs_create_x32("mtk_vcodec_dbg", 0644, vcodec_root,
> &mtk_vcodec_dbg);
> > +
> > +vcodec_dev->dbgfs.inst_count = 0;
> > +}
> > +
> > +void mtk_vcodec_dbgfs_init(void *vcodec_dev, bool is_encode)
> > +{
> > +if (is_encode)
> > +mtk_vcodec_dbgfs_venc_init(vcodec_dev);
> > +else
> > +mtk_vcodec_dbgfs_vdec_init(vcodec_dev);
> > +}
> >  EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_init);
> >  
> > -void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev)
> > +void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dbgfs *dbgfs)
> >  {
> > -debugfs_remove_recursive(vcodec_dev->dbgfs.vcodec_root);
> > +debugfs_remove_recursive(dbgfs->vcodec_root);
> >  }
> >  EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_deinit);
> >  
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
> > index 372413d590c5..073d2fedb54a 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
> > @@ -7,7 +7,7 @@
> >  #ifndef __MTK_VCODEC_DBGFS_H__
> >  #define __MTK_VCODEC_DBGFS_H__
> >  
> > -struct mtk_vcodec_dev;
> > +struct mtk_vcodec_dec_dev;
> 
> I'm far in the review to think about this, but have you considered
> using a
> shorter name, like mtk_vdec_dev ? That being said, I'm not requesting
> any
> changes, this can happen later (or never).
> 
> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> 
I prefer to use struct mtk_vcodec_dec_dev and struct mtk_vcodec_enc_dev
for current period. Maybe simply the struct name in the future.

Best Regards,
Yunfei Dong
> >  struct mtk_vcodec_dec_ctx;
> >  
> >  /*
> > @@ -51,23 +51,23 @@ struct mtk_vcodec_dbgfs {
> >  
> >  #if defined(CONFIG_DEBUG_FS)
> >  void mtk_vcodec_dbgfs_create(struct mtk_vcodec_dec_ctx *ctx);
> > -void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev,
> int ctx_id);
> > -void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool
> is_encode);
> > -void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev);
> > +void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dec_dev
> *vcodec_dev, int ctx_id);
> > +void mtk_vcodec_dbgfs_init(void *vcodec_dev, bool is_encode);
> > +void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dbgfs *dbgfs);
> >  #else
> >  static inline void mtk_vcodec_dbgfs_create(struct
> mtk_vcodec_dec_ctx *ctx)
> >  {
> >  }
> >  
> > -static inline void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev
> *vcodec_dev, int ctx_id)
> > +static inline void mtk_vcodec_dbgfs_remove(struct
> mtk_vcodec_dec_dev *vcodec_dev, int ctx_id)
> >  {
> >  }
> >  
> > -static inline void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev
> *vcodec_dev, bool is_encode)
> > +static inline void mtk_vcodec_dbgfs_init(void *vcodec_dev, bool
> is_encode)
> >  {
> >  }
> >  
> > -static inline void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev
> *vcodec_dev)
> > +static inline void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dbgfs
> *dbgfs)
> >  {
> >  }
> >  #endif
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> > index 619ff3dd8d50..0363fec572e5 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> > @@ -9,7 +9,7 @@
> >  #include <media/v4l2-mem2mem.h>
> >  #include <media/videobuf2-dma-contig.h>
> >  
> > -#include "mtk_vcodec_drv.h"
> > +#include "mtk_vcodec_dec_drv.h"
> >  #include "mtk_vcodec_dec.h"
> >  #include "mtk_vcodec_intr.h"
> >  #include "mtk_vcodec_util.h"
> > @@ -890,7 +890,7 @@ void vb2ops_vdec_stop_streaming(struct
> vb2_queue *q)
> >  static void m2mops_vdec_device_run(void *priv)
> >  {
> >  struct mtk_vcodec_dec_ctx *ctx = priv;
> > -struct mtk_vcodec_dev *dev = ctx->dev;
> > +struct mtk_vcodec_dec_dev *dev = ctx->dev;
> >  
> >  queue_work(dev->decode_workqueue, &ctx->decode_work);
> >  }
> > 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 5609fd3268f2..8e3aea9a3ab0 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
> > @@ -17,7 +17,6 @@
> >  #include <media/videobuf2-dma-contig.h>
> >  #include <media/v4l2-device.h>
> >  
> > -#include "mtk_vcodec_drv.h"
> >  #include "mtk_vcodec_dec.h"
> >  #include "mtk_vcodec_dec_hw.h"
> >  #include "mtk_vcodec_dec_pm.h"
> > @@ -25,7 +24,7 @@
> >  #include "mtk_vcodec_util.h"
> >  #include "mtk_vcodec_fw.h"
> >  
> > -static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dec_ctx *ctx,
> struct mtk_vcodec_dev *dev)
> > +static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dec_ctx *ctx,
> struct mtk_vcodec_dec_dev *dev)
> >  {
> >  switch (dev->vdec_pdata->hw_arch) {
> >  case MTK_VDEC_PURE_SINGLE_CORE:
> > @@ -40,7 +39,7 @@ static int mtk_vcodec_get_hw_count(struct
> mtk_vcodec_dec_ctx *ctx, struct mtk_vc
> >  
> >  static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
> >  {
> > -struct mtk_vcodec_dev *dev = priv;
> > +struct mtk_vcodec_dec_dev *dev = priv;
> >  struct mtk_vcodec_dec_ctx *ctx;
> >  u32 cg_status = 0;
> >  unsigned int dec_done_status = 0;
> > @@ -75,7 +74,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int
> irq, void *priv)
> >  return IRQ_HANDLED;
> >  }
> >  
> > -static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev)
> > +static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dec_dev
> *dev)
> >  {
> >  struct platform_device *pdev = dev->plat_dev;
> >  int reg_num, i;
> > @@ -99,7 +98,7 @@ static int mtk_vcodec_get_reg_bases(struct
> mtk_vcodec_dev *dev)
> >  return 0;
> >  }
> >  
> > -static int mtk_vcodec_init_dec_resources(struct mtk_vcodec_dev
> *dev)
> > +static int mtk_vcodec_init_dec_resources(struct mtk_vcodec_dec_dev
> *dev)
> >  {
> >  struct platform_device *pdev = dev->plat_dev;
> >  int ret;
> > @@ -136,7 +135,7 @@ static int mtk_vcodec_init_dec_resources(struct
> mtk_vcodec_dev *dev)
> >  
> >  static int fops_vcodec_open(struct file *file)
> >  {
> > -struct mtk_vcodec_dev *dev = video_drvdata(file);
> > +struct mtk_vcodec_dec_dev *dev = video_drvdata(file);
> >  struct mtk_vcodec_dec_ctx *ctx = NULL;
> >  int ret = 0, i, hw_count;
> >  struct vb2_queue *src_vq;
> > @@ -233,7 +232,7 @@ static int fops_vcodec_open(struct file *file)
> >  
> >  static int fops_vcodec_release(struct file *file)
> >  {
> > -struct mtk_vcodec_dev *dev = video_drvdata(file);
> > +struct mtk_vcodec_dec_dev *dev = video_drvdata(file);
> >  struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(file-
> >private_data);
> >  
> >  mtk_v4l2_vdec_dbg(0, ctx, "[%d] decoder", ctx->id);
> > @@ -270,7 +269,7 @@ static const struct v4l2_file_operations
> mtk_vcodec_fops = {
> >  
> >  static int mtk_vcodec_probe(struct platform_device *pdev)
> >  {
> > -struct mtk_vcodec_dev *dev;
> > +struct mtk_vcodec_dec_dev *dev;
> >  struct video_device *vfd_dec;
> >  phandle rproc_phandle;
> >  enum mtk_vcodec_fw_type fw_type;
> > @@ -477,7 +476,7 @@ MODULE_DEVICE_TABLE(of, mtk_vcodec_match);
> >  
> >  static void mtk_vcodec_dec_remove(struct platform_device *pdev)
> >  {
> > -struct mtk_vcodec_dev *dev = platform_get_drvdata(pdev);
> > +struct mtk_vcodec_dec_dev *dev = platform_get_drvdata(pdev);
> >  
> >  destroy_workqueue(dev->decode_workqueue);
> >  
> > @@ -493,7 +492,7 @@ static void mtk_vcodec_dec_remove(struct
> platform_device *pdev)
> >  if (dev->vfd_dec)
> >  video_unregister_device(dev->vfd_dec);
> >  
> > -mtk_vcodec_dbgfs_deinit(dev);
> > +mtk_vcodec_dbgfs_deinit(&dev->dbgfs);
> >  v4l2_device_unregister(&dev->v4l2_dev);
> >  if (!dev->vdec_pdata->is_subdev_supported)
> >  pm_runtime_disable(dev->pm.dev);
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h
> > index 94870b651919..a18ba8f32d41 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.h
> > @@ -8,9 +8,49 @@
> >  #define _MTK_VCODEC_DEC_DRV_H_
> >  
> >  #include "mtk_vcodec_com_drv.h"
> > +#include "mtk_vcodec_dbgfs.h"
> >  #include "mtk_vcodec_fw_priv.h"
> > +#include "mtk_vcodec_util.h"
> >  #include "vdec_msg_queue.h"
> >  
> > +#define MTK_VCODEC_DEC_NAME"mtk-vcodec-dec"
> > +
> > +#define IS_VDEC_LAT_ARCH(hw_arch) ((hw_arch) >=
> MTK_VDEC_LAT_SINGLE_CORE)
> > +#define IS_VDEC_INNER_RACING(capability) ((capability) &
> MTK_VCODEC_INNER_RACING)
> > +
> > +/*
> > + * struct mtk_vdec_format_types - Structure used to get supported
> > + *  format types according to decoder capability
> > + */
> > +enum mtk_vdec_format_types {
> > +MTK_VDEC_FORMAT_MM21 = 0x20,
> > +MTK_VDEC_FORMAT_MT21C = 0x40,
> > +MTK_VDEC_FORMAT_H264_SLICE = 0x100,
> > +MTK_VDEC_FORMAT_VP8_FRAME = 0x200,
> > +MTK_VDEC_FORMAT_VP9_FRAME = 0x400,
> > +MTK_VDEC_FORMAT_AV1_FRAME = 0x800,
> > +MTK_VDEC_FORMAT_HEVC_FRAME = 0x1000,
> > +MTK_VCODEC_INNER_RACING = 0x20000,
> > +};
> > +
> > +/*
> > + * enum mtk_vdec_hw_count - Supported hardware count
> > + */
> > +enum mtk_vdec_hw_count {
> > +MTK_VDEC_NO_HW = 0,
> > +MTK_VDEC_ONE_CORE,
> > +MTK_VDEC_ONE_LAT_ONE_CORE,
> > +MTK_VDEC_MAX_HW_COUNT,
> > +};
> > +
> > +/*
> > + * enum mtk_vdec_hw_arch - Used to separate different hardware
> architecture
> > + */
> > +enum mtk_vdec_hw_arch {
> > +MTK_VDEC_PURE_SINGLE_CORE,
> > +MTK_VDEC_LAT_SINGLE_CORE,
> > +};
> > +
> >  /**
> >   * struct vdec_pic_info  - picture size information
> >   * @pic_w: picture width
> > @@ -33,24 +73,54 @@ struct vdec_pic_info {
> >  unsigned int reserved;
> >  };
> >  
> > -/*
> > - * enum mtk_vdec_hw_id - Hardware index used to separate
> > - *                         different hardware
> > +/**
> > + * struct mtk_vcodec_dec_pdata - compatible data for each IC
> > + * @init_vdec_params: init vdec params
> > + * @ctrls_setup: init vcodec dec ctrls
> > + * @worker: worker to start a decode job
> > + * @flush_decoder: function that flushes the decoder
> > + * @get_cap_buffer: get capture buffer from capture queue
> > + * @cap_to_disp: put capture buffer to disp list for lat and core
> arch
> > + * @vdec_vb2_ops: struct vb2_ops
> > + *
> > + * @vdec_formats: supported video decoder formats
> > + * @num_formats: count of video decoder formats
> > + * @default_out_fmt: default output buffer format
> > + * @default_cap_fmt: default capture buffer format
> > + *
> > + * @hw_arch: hardware arch is used to separate pure_sin_core and
> lat_sin_core
> > + *
> > + * @is_subdev_supported: whether support parent-node
> architecture(subdev)
> > + * @uses_stateless_api: whether the decoder uses the stateless API
> with requests
> >   */
> > -enum mtk_vdec_hw_id {
> > -MTK_VDEC_CORE,
> > -MTK_VDEC_LAT0,
> > -MTK_VDEC_LAT1,
> > -MTK_VDEC_LAT_SOC,
> > -MTK_VDEC_HW_MAX,
> > +struct mtk_vcodec_dec_pdata {
> > +void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
> > +int (*ctrls_setup)(struct mtk_vcodec_dec_ctx *ctx);
> > +void (*worker)(struct work_struct *work);
> > +int (*flush_decoder)(struct mtk_vcodec_dec_ctx *ctx);
> > +struct vdec_fb *(*get_cap_buffer)(struct mtk_vcodec_dec_ctx *ctx);
> > +void (*cap_to_disp)(struct mtk_vcodec_dec_ctx *ctx, int error,
> > +    struct media_request *src_buf_req);
> > +
> > +const struct vb2_ops *vdec_vb2_ops;
> > +
> > +const struct mtk_video_fmt *vdec_formats;
> > +const int *num_formats;
> > +const struct mtk_video_fmt *default_out_fmt;
> > +const struct mtk_video_fmt *default_cap_fmt;
> > +
> > +enum mtk_vdec_hw_arch hw_arch;
> > +
> > +bool is_subdev_supported;
> > +bool uses_stateless_api;
> >  };
> >  
> >  /**
> >   * struct mtk_vcodec_dec_ctx - Context (instance) private data.
> >   *
> >   * @type: type of the instance - decoder or encoder
> > - * @dev: pointer to the mtk_vcodec_dev of the device
> > - * @list: link to ctx_list of mtk_vcodec_dev
> > + * @dev: pointer to the mtk_vcodec_dec_dev of the device
> > + * @list: link to ctx_list of mtk_vcodec_dec_dev
> >   *
> >   * @fh: struct v4l2_fh
> >   * @m2m_ctx: pointer to the v4l2_m2m_ctx of the context
> > @@ -95,7 +165,7 @@ enum mtk_vdec_hw_id {
> >   */
> >  struct mtk_vcodec_dec_ctx {
> >  enum mtk_instance_type type;
> > -struct mtk_vcodec_dev *dev;
> > +struct mtk_vcodec_dec_dev *dev;
> >  struct list_head list;
> >  
> >  struct v4l2_fh fh;
> > @@ -136,6 +206,84 @@ struct mtk_vcodec_dec_ctx {
> >  struct vdec_msg_queue msg_queue;
> >  };
> >  
> > +/**
> > + * struct mtk_vcodec_dec_dev - driver data
> > + * @v4l2_dev: V4L2 device to register video devices for.
> > + * @vfd_dec: Video device for decoder
> > + * @mdev_dec: Media device for decoder
> > + *
> > + * @m2m_dev_dec: m2m device for decoder
> > + * @plat_dev: platform device
> > + * @ctx_list: list of struct mtk_vcodec_ctx
> > + * @curr_ctx: The context that is waiting for codec hardware
> > + *
> > + * @reg_base: Mapped address of MTK Vcodec registers.
> > + * @vdec_pdata: decoder IC-specific data
> > + *
> > + * @fw_handler: used to communicate with the firmware.
> > + * @id_counter: used to identify current opened instance
> > + *
> > + * @dec_mutex: decoder hardware lock
> > + * @dev_mutex: video_device lock
> > + * @decode_workqueue: decode work queue
> > + *
> > + * @irqlock: protect data access by irq handler and work thread
> > + * @dec_irq: decoder irq resource
> > + *
> > + * @pm: power management control
> > + * @dec_capability: used to identify decode capability, ex: 4k
> > + *
> > + * @core_workqueue: queue used for core hardware decode
> > + *
> > + * @subdev_dev: subdev hardware device
> > + * @subdev_prob_done: check whether all used hw device is prob
> done
> > + * @subdev_bitmap: used to record hardware is ready or not
> > + *
> > + * @dec_active_cnt: used to mark whether need to record register
> value
> > + * @vdec_racing_info: record register value
> > + * @dec_racing_info_mutex: mutex lock used for inner racing mode
> > + * @dbgfs: debug log related information
> > + */
> > +struct mtk_vcodec_dec_dev {
> > +struct v4l2_device v4l2_dev;
> > +struct video_device *vfd_dec;
> > +struct media_device mdev_dec;
> > +
> > +struct v4l2_m2m_dev *m2m_dev_dec;
> > +struct platform_device *plat_dev;
> > +struct list_head ctx_list;
> > +struct mtk_vcodec_dec_ctx *curr_ctx;
> > +
> > +void __iomem *reg_base[NUM_MAX_VCODEC_REG_BASE];
> > +const struct mtk_vcodec_dec_pdata *vdec_pdata;
> > +
> > +struct mtk_vcodec_fw *fw_handler;
> > +unsigned long id_counter;
> > +
> > +/* decoder hardware mutex lock */
> > +struct mutex dec_mutex[MTK_VDEC_HW_MAX];
> > +struct mutex dev_mutex;
> > +struct workqueue_struct *decode_workqueue;
> > +
> > +spinlock_t irqlock;
> > +int dec_irq;
> > +
> > +struct mtk_vcodec_pm pm;
> > +unsigned int dec_capability;
> > +
> > +struct workqueue_struct *core_workqueue;
> > +
> > +void *subdev_dev[MTK_VDEC_HW_MAX];
> > +int (*subdev_prob_done)(struct mtk_vcodec_dec_dev *vdec_dev);
> > +DECLARE_BITMAP(subdev_bitmap, MTK_VDEC_HW_MAX);
> > +
> > +atomic_t dec_active_cnt;
> > +u32 vdec_racing_info[132];
> > +/* Protects access to vdec_racing_info data */
> > +struct mutex dec_racing_info_mutex;
> > +struct mtk_vcodec_dbgfs dbgfs;
> > +};
> > +
> >  static inline struct mtk_vcodec_dec_ctx *fh_to_dec_ctx(struct
> v4l2_fh *fh)
> >  {
> >  return container_of(fh, struct mtk_vcodec_dec_ctx, fh);
> > 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 dde0894f2ab0..23c19efa3cf6 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.c
> > @@ -12,7 +12,6 @@
> >  #include <linux/pm_runtime.h>
> >  #include <linux/slab.h>
> >  
> > -#include "mtk_vcodec_drv.h"
> >  #include "mtk_vcodec_dec.h"
> >  #include "mtk_vcodec_dec_hw.h"
> >  #include "mtk_vcodec_dec_pm.h"
> > @@ -36,7 +35,7 @@ static const struct of_device_id
> mtk_vdec_hw_match[] = {
> >  };
> >  MODULE_DEVICE_TABLE(of, mtk_vdec_hw_match);
> >  
> > -static int mtk_vdec_hw_prob_done(struct mtk_vcodec_dev *vdec_dev)
> > +static int mtk_vdec_hw_prob_done(struct mtk_vcodec_dec_dev
> *vdec_dev)
> >  {
> >  struct platform_device *pdev = vdec_dev->plat_dev;
> >  struct device_node *subdev_node;
> > @@ -123,7 +122,7 @@ static int mtk_vdec_hw_probe(struct
> platform_device *pdev)
> >  {
> >  struct device *dev = &pdev->dev;
> >  struct mtk_vdec_hw_dev *subdev_dev;
> > -struct mtk_vcodec_dev *main_dev;
> > +struct mtk_vcodec_dec_dev *main_dev;
> >  const struct of_device_id *of_id;
> >  int hw_idx;
> >  int ret;
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.h
> > index d62c7f961cfa..2b33f00e931e 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_hw.h
> > @@ -10,7 +10,7 @@
> >  #include <linux/io.h>
> >  #include <linux/platform_device.h>
> >  
> > -#include "mtk_vcodec_drv.h"
> > +#include "mtk_vcodec_dec_drv.h"
> >  
> >  #define VDEC_HW_ACTIVE 0x10
> >  #define VDEC_IRQ_CFG 0x11
> > @@ -45,7 +45,7 @@ enum mtk_vdec_hw_reg_idx {
> >   */
> >  struct mtk_vdec_hw_dev {
> >  struct platform_device *plat_dev;
> > -struct mtk_vcodec_dev *main_dev;
> > +struct mtk_vcodec_dec_dev *main_dev;
> >  void __iomem *reg_base[VDEC_HW_MAX];
> >  
> >  struct mtk_vcodec_dec_ctx *curr_ctx;
> > 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 29ef00c4a326..ed1f503a944e 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.c
> > @@ -107,7 +107,7 @@ static void mtk_vcodec_dec_clock_off(struct
> mtk_vcodec_pm *pm)
> >  clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
> >  }
> >  
> > -static void mtk_vcodec_dec_enable_irq(struct mtk_vcodec_dev
> *vdec_dev, int hw_idx)
> > +static void mtk_vcodec_dec_enable_irq(struct mtk_vcodec_dec_dev
> *vdec_dev, int hw_idx)
> >  {
> >  struct mtk_vdec_hw_dev *subdev_dev;
> >  
> > @@ -125,7 +125,7 @@ static void mtk_vcodec_dec_enable_irq(struct
> mtk_vcodec_dev *vdec_dev, int hw_id
> >  }
> >  }
> >  
> > -static void mtk_vcodec_dec_disable_irq(struct mtk_vcodec_dev
> *vdec_dev, int hw_idx)
> > +static void mtk_vcodec_dec_disable_irq(struct mtk_vcodec_dec_dev
> *vdec_dev, int hw_idx)
> >  {
> >  struct mtk_vdec_hw_dev *subdev_dev;
> >  
> > @@ -171,7 +171,7 @@ static void
> mtk_vcodec_record_racing_info(struct mtk_vcodec_dec_ctx *ctx)
> >  mutex_unlock(&ctx->dev->dec_racing_info_mutex);
> >  }
> >  
> > -static struct mtk_vcodec_pm *mtk_vcodec_dec_get_pm(struct
> mtk_vcodec_dev *vdec_dev,
> > +static struct mtk_vcodec_pm *mtk_vcodec_dec_get_pm(struct
> mtk_vcodec_dec_dev *vdec_dev,
> >     int hw_idx)
> >  {
> >  struct mtk_vdec_hw_dev *subdev_dev;
> > @@ -191,7 +191,7 @@ static struct mtk_vcodec_pm
> *mtk_vcodec_dec_get_pm(struct mtk_vcodec_dev *vdec_d
> >  return &vdec_dev->pm;
> >  }
> >  
> > -static void mtk_vcodec_dec_child_dev_on(struct mtk_vcodec_dev
> *vdec_dev,
> > +static void mtk_vcodec_dec_child_dev_on(struct mtk_vcodec_dec_dev
> *vdec_dev,
> >  int hw_idx)
> >  {
> >  struct mtk_vcodec_pm *pm;
> > @@ -211,7 +211,7 @@ static void mtk_vcodec_dec_child_dev_on(struct
> mtk_vcodec_dev *vdec_dev,
> >  }
> >  }
> >  
> > -static void mtk_vcodec_dec_child_dev_off(struct mtk_vcodec_dev
> *vdec_dev,
> > +static void mtk_vcodec_dec_child_dev_off(struct mtk_vcodec_dec_dev
> *vdec_dev,
> >   int hw_idx)
> >  {
> >  struct mtk_vcodec_pm *pm;
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.h
> > index f6c68e57bcc1..87a50d589d42 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_pm.h
> > @@ -7,7 +7,7 @@
> >  #ifndef _MTK_VCODEC_DEC_PM_H_
> >  #define _MTK_VCODEC_DEC_PM_H_
> >  
> > -#include "mtk_vcodec_drv.h"
> > +#include "mtk_vcodec_dec_drv.h"
> >  
> >  int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct
> mtk_vcodec_pm *pm);
> >  
> > 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 93230fe7ab97..459e74a46737 100644
> > ---
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c
> > +++
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateful.c
> > @@ -4,7 +4,6 @@
> >  #include <media/v4l2-mem2mem.h>
> >  #include <media/videobuf2-dma-contig.h>
> >  
> > -#include "mtk_vcodec_drv.h"
> >  #include "mtk_vcodec_dec.h"
> >  #include "mtk_vcodec_intr.h"
> >  #include "mtk_vcodec_util.h"
> > @@ -279,7 +278,7 @@ static void mtk_vdec_worker(struct work_struct
> *work)
> >  {
> >  struct mtk_vcodec_dec_ctx *ctx =
> >  container_of(work, struct mtk_vcodec_dec_ctx, decode_work);
> > -struct mtk_vcodec_dev *dev = ctx->dev;
> > +struct mtk_vcodec_dec_dev *dev = ctx->dev;
> >  struct vb2_v4l2_buffer *src_buf, *dst_buf;
> >  struct mtk_vcodec_mem buf;
> >  struct vdec_fb *pfb;
> > 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 64e9dfd0fcb5..6268a39c2bb3 100644
> > ---
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> > +++
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> > @@ -6,7 +6,6 @@
> >  #include <media/v4l2-mem2mem.h>
> >  #include <linux/module.h>
> >  
> > -#include "mtk_vcodec_drv.h"
> >  #include "mtk_vcodec_dec.h"
> >  #include "mtk_vcodec_intr.h"
> >  #include "mtk_vcodec_util.h"
> > @@ -288,7 +287,7 @@ static void mtk_vdec_worker(struct work_struct
> *work)
> >  {
> >  struct mtk_vcodec_dec_ctx *ctx =
> >  container_of(work, struct mtk_vcodec_dec_ctx, decode_work);
> > -struct mtk_vcodec_dev *dev = ctx->dev;
> > +struct mtk_vcodec_dec_dev *dev = ctx->dev;
> >  struct vb2_v4l2_buffer *vb2_v4l2_src;
> >  struct vb2_buffer *vb2_src;
> >  struct mtk_vcodec_mem *bs_src;
> > @@ -444,7 +443,7 @@ const struct media_device_ops
> mtk_vcodec_media_ops = {
> >  static void mtk_vcodec_add_formats(unsigned int fourcc,
> >     struct mtk_vcodec_dec_ctx *ctx)
> >  {
> > -struct mtk_vcodec_dev *dev = ctx->dev;
> > +struct mtk_vcodec_dec_dev *dev = ctx->dev;
> >  const struct mtk_vcodec_dec_pdata *pdata = dev->vdec_pdata;
> >  int count_formats = *pdata->num_formats;
> >  
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h
> > deleted file mode 100644
> > index 76db7770d981..000000000000
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h
> > +++ /dev/null
> > @@ -1,295 +0,0 @@
> > -/* SPDX-License-Identifier: GPL-2.0 */
> > -/*
> > -* Copyright (c) 2016 MediaTek Inc.
> > -* Author: PC Chen <pc.chen@mediatek.com>
> > -*         Tiffany Lin <tiffany.lin@mediatek.com>
> > -*/
> > -
> > -#ifndef _MTK_VCODEC_DRV_H_
> > -#define _MTK_VCODEC_DRV_H_
> > -
> > -#include <linux/platform_device.h>
> > -#include <linux/videodev2.h>
> > -#include <media/v4l2-ctrls.h>
> > -#include <media/v4l2-device.h>
> > -#include <media/v4l2-ioctl.h>
> > -#include <media/v4l2-mem2mem.h>
> > -#include <media/videobuf2-core.h>
> > -
> > -#include "mtk_vcodec_dbgfs.h"
> > -#include "mtk_vcodec_dec_drv.h"
> > -#include "mtk_vcodec_enc_drv.h"
> > -#include "mtk_vcodec_util.h"
> > -#include "vdec_msg_queue.h"
> > -
> > -#define MTK_VCODEC_DEC_NAME"mtk-vcodec-dec"
> > -#define MTK_VCODEC_ENC_NAME"mtk-vcodec-enc"
> > -
> > -#define MTK_V4L2_BENCHMARK0
> > -#define WAIT_INTR_TIMEOUT_MS1000
> > -#define IS_VDEC_LAT_ARCH(hw_arch) ((hw_arch) >=
> MTK_VDEC_LAT_SINGLE_CORE)
> > -#define IS_VDEC_INNER_RACING(capability) ((capability) &
> MTK_VCODEC_INNER_RACING)
> > -
> > -/*
> > - * enum mtk_hw_reg_idx - MTK hw register base index
> > - */
> > -enum mtk_hw_reg_idx {
> > -VDEC_SYS,
> > -VDEC_MISC,
> > -VDEC_LD,
> > -VDEC_TOP,
> > -VDEC_CM,
> > -VDEC_AD,
> > -VDEC_AV,
> > -VDEC_PP,
> > -VDEC_HWD,
> > -VDEC_HWQ,
> > -VDEC_HWB,
> > -VDEC_HWG,
> > -NUM_MAX_VDEC_REG_BASE,
> > -/* h264 encoder */
> > -VENC_SYS = NUM_MAX_VDEC_REG_BASE,
> > -/* vp8 encoder */
> > -VENC_LT_SYS,
> > -NUM_MAX_VCODEC_REG_BASE
> > -};
> > -
> > -
> > -
> > -/*
> > - * enum mtk_vdec_hw_count - Supported hardware count
> > - */
> > -enum mtk_vdec_hw_count {
> > -MTK_VDEC_NO_HW = 0,
> > -MTK_VDEC_ONE_CORE,
> > -MTK_VDEC_ONE_LAT_ONE_CORE,
> > -MTK_VDEC_MAX_HW_COUNT,
> > -};
> > -
> > -/*
> > - * enum mtk_q_type - Type of queue
> > - */
> > -enum mtk_q_type {
> > -MTK_Q_DATA_SRC = 0,
> > -MTK_Q_DATA_DST = 1,
> > -};
> > -
> > -
> > -/*
> > - * struct mtk_vcodec_clk_info - Structure used to store clock name
> > - */
> > -struct mtk_vcodec_clk_info {
> > -const char*clk_name;
> > -struct clk*vcodec_clk;
> > -};
> > -
> > -/*
> > - * struct mtk_vcodec_clk - Structure used to store vcodec clock
> information
> > - */
> > -struct mtk_vcodec_clk {
> > -struct mtk_vcodec_clk_info*clk_info;
> > -intclk_num;
> > -};
> > -
> > -/*
> > - * struct mtk_vcodec_pm - Power management data structure
> > - */
> > -struct mtk_vcodec_pm {
> > -struct mtk_vcodec_clkvdec_clk;
> > -struct mtk_vcodec_clkvenc_clk;
> > -struct device*dev;
> > -};
> > -
> > -/*
> > - * enum mtk_vdec_hw_arch - Used to separate different hardware
> architecture
> > - */
> > -enum mtk_vdec_hw_arch {
> > -MTK_VDEC_PURE_SINGLE_CORE,
> > -MTK_VDEC_LAT_SINGLE_CORE,
> > -};
> > -
> > -/*
> > - * struct mtk_vdec_format_types - Structure used to get supported
> > - *  format types according to decoder capability
> > - */
> > -enum mtk_vdec_format_types {
> > -MTK_VDEC_FORMAT_MM21 = 0x20,
> > -MTK_VDEC_FORMAT_MT21C = 0x40,
> > -MTK_VDEC_FORMAT_H264_SLICE = 0x100,
> > -MTK_VDEC_FORMAT_VP8_FRAME = 0x200,
> > -MTK_VDEC_FORMAT_VP9_FRAME = 0x400,
> > -MTK_VDEC_FORMAT_AV1_FRAME = 0x800,
> > -MTK_VDEC_FORMAT_HEVC_FRAME = 0x1000,
> > -MTK_VCODEC_INNER_RACING = 0x20000,
> > -};
> > -
> > -/**
> > - * struct mtk_vcodec_dec_pdata - compatible data for each IC
> > - * @init_vdec_params: init vdec params
> > - * @ctrls_setup: init vcodec dec ctrls
> > - * @worker: worker to start a decode job
> > - * @flush_decoder: function that flushes the decoder
> > - * @get_cap_buffer: get capture buffer from capture queue
> > - * @cap_to_disp: put capture buffer to disp list for lat and core
> arch
> > - * @vdec_vb2_ops: struct vb2_ops
> > - *
> > - * @vdec_formats: supported video decoder formats
> > - * @num_formats: count of video decoder formats
> > - * @default_out_fmt: default output buffer format
> > - * @default_cap_fmt: default capture buffer format
> > - *
> > - * @hw_arch: hardware arch is used to separate pure_sin_core and
> lat_sin_core
> > - *
> > - * @is_subdev_supported: whether support parent-node
> architecture(subdev)
> > - * @uses_stateless_api: whether the decoder uses the stateless API
> with requests
> > - */
> > -
> > -struct mtk_vcodec_dec_pdata {
> > -void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx);
> > -int (*ctrls_setup)(struct mtk_vcodec_dec_ctx *ctx);
> > -void (*worker)(struct work_struct *work);
> > -int (*flush_decoder)(struct mtk_vcodec_dec_ctx *ctx);
> > -struct vdec_fb *(*get_cap_buffer)(struct mtk_vcodec_dec_ctx *ctx);
> > -void (*cap_to_disp)(struct mtk_vcodec_dec_ctx *ctx, int error,
> > -    struct media_request *src_buf_req);
> > -
> > -struct vb2_ops *vdec_vb2_ops;
> > -
> > -const struct mtk_video_fmt *vdec_formats;
> > -const int *num_formats;
> > -const struct mtk_video_fmt *default_out_fmt;
> > -const struct mtk_video_fmt *default_cap_fmt;
> > -
> > -enum mtk_vdec_hw_arch hw_arch;
> > -
> > -bool is_subdev_supported;
> > -bool uses_stateless_api;
> > -};
> > -
> > -/**
> > - * struct mtk_vcodec_enc_pdata - compatible data for each IC
> > - *
> > - * @uses_ext: whether the encoder uses the extended firmware
> messaging format
> > - * @min_bitrate: minimum supported encoding bitrate
> > - * @max_bitrate: maximum supported encoding bitrate
> > - * @capture_formats: array of supported capture formats
> > - * @num_capture_formats: number of entries in capture_formats
> > - * @output_formats: array of supported output formats
> > - * @num_output_formats: number of entries in output_formats
> > - * @core_id: stand for h264 or vp8 encode index
> > - * @uses_34bit: whether the encoder uses 34-bit iova
> > - */
> > -struct mtk_vcodec_enc_pdata {
> > -bool uses_ext;
> > -unsigned long min_bitrate;
> > -unsigned long max_bitrate;
> > -const struct mtk_video_fmt *capture_formats;
> > -size_t num_capture_formats;
> > -const struct mtk_video_fmt *output_formats;
> > -size_t num_output_formats;
> > -int core_id;
> > -bool uses_34bit;
> > -};
> > -
> > -#define MTK_ENC_CTX_IS_EXT(ctx) ((ctx)->dev->venc_pdata->uses_ext)
> > -#define MTK_ENC_IOVA_IS_34BIT(ctx) ((ctx)->dev->venc_pdata-
> >uses_34bit)
> > -
> > -/**
> > - * struct mtk_vcodec_dev - driver data
> > - * @v4l2_dev: V4L2 device to register video devices for.
> > - * @vfd_dec: Video device for decoder
> > - * @mdev_dec: Media device for decoder
> > - * @vfd_enc: Video device for encoder.
> > - *
> > - * @m2m_dev_dec: m2m device for decoder
> > - * @m2m_dev_enc: m2m device for encoder.
> > - * @plat_dev: platform device
> > - * @ctx_list: list of struct mtk_vcodec_dec_ctx
> > - * @irqlock: protect data access by irq handler and work thread
> > - * @curr_ctx: The context that is waiting for codec hardware
> > - * @curr_enc_ctx: The encoder context that is waiting for codec
> hardware
> > - *
> > - * @reg_base: Mapped address of MTK Vcodec registers.
> > - * @vdec_pdata: decoder IC-specific data
> > - * @venc_pdata: encoder IC-specific data
> > - *
> > - * @fw_handler: used to communicate with the firmware.
> > - * @id_counter: used to identify current opened instance
> > - *
> > - * @decode_workqueue: decode work queue
> > - * @encode_workqueue: encode work queue
> > - *
> > - * @dev_mutex: video_device lock
> > - *
> > - * @dec_irq: decoder irq resource
> > - * @enc_irq: h264 encoder irq resource
> > - *
> > - * @dec_mutex: decoder hardware lock
> > - * @enc_mutex: encoder hardware lock.
> > - *
> > - * @pm: power management control
> > - * @dec_capability: used to identify decode capability, ex: 4k
> > - * @enc_capability: used to identify encode capability
> > - *
> > - * @core_workqueue: queue used for core hardware decode
> > - *
> > - * @subdev_dev: subdev hardware device
> > - * @subdev_prob_done: check whether all used hw device is prob
> done
> > - * @subdev_bitmap: used to record hardware is ready or not
> > - *
> > - * @dec_active_cnt: used to mark whether need to record register
> value
> > - * @vdec_racing_info: record register value
> > - * @dec_racing_info_mutex: mutex lock used for inner racing mode
> > - * @dbgfs: debug log related information
> > - */
> > -struct mtk_vcodec_dev {
> > -struct v4l2_device v4l2_dev;
> > -struct video_device *vfd_dec;
> > -struct media_device mdev_dec;
> > -struct video_device *vfd_enc;
> > -
> > -struct v4l2_m2m_dev *m2m_dev_dec;
> > -struct v4l2_m2m_dev *m2m_dev_enc;
> > -struct platform_device *plat_dev;
> > -struct list_head ctx_list;
> > -spinlock_t irqlock;
> > -struct mtk_vcodec_dec_ctx *curr_ctx;
> > -struct mtk_vcodec_enc_ctx *curr_enc_ctx;
> > -void __iomem *reg_base[NUM_MAX_VCODEC_REG_BASE];
> > -const struct mtk_vcodec_dec_pdata *vdec_pdata;
> > -const struct mtk_vcodec_enc_pdata *venc_pdata;
> > -
> > -struct mtk_vcodec_fw *fw_handler;
> > -
> > -unsigned long id_counter;
> > -
> > -struct workqueue_struct *decode_workqueue;
> > -struct workqueue_struct *encode_workqueue;
> > -struct mutex dev_mutex;
> > -
> > -int dec_irq;
> > -int enc_irq;
> > -
> > -/* decoder hardware mutex lock */
> > -struct mutex dec_mutex[MTK_VDEC_HW_MAX];
> > -struct mutex enc_mutex;
> > -
> > -struct mtk_vcodec_pm pm;
> > -unsigned int dec_capability;
> > -unsigned int enc_capability;
> > -
> > -struct workqueue_struct *core_workqueue;
> > -
> > -void *subdev_dev[MTK_VDEC_HW_MAX];
> > -int (*subdev_prob_done)(struct mtk_vcodec_dev *vdec_dev);
> > -DECLARE_BITMAP(subdev_bitmap, MTK_VDEC_HW_MAX);
> > -
> > -atomic_t dec_active_cnt;
> > -u32 vdec_racing_info[132];
> > -/* Protects access to vdec_racing_info data */
> > -struct mutex dec_racing_info_mutex;
> > -
> > -struct mtk_vcodec_dbgfs dbgfs;
> > -};
> > -
> > -#endif /* _MTK_VCODEC_DRV_H_ */
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c
> > index deabf012848e..85dabb20fb11 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc.c
> > @@ -10,7 +10,6 @@
> >  #include <media/videobuf2-dma-contig.h>
> >  #include <linux/pm_runtime.h>
> >  
> > -#include "mtk_vcodec_drv.h"
> >  #include "mtk_vcodec_enc.h"
> >  #include "mtk_vcodec_intr.h"
> >  #include "mtk_vcodec_util.h"
> > @@ -1436,7 +1435,7 @@ int mtk_vcodec_enc_queue_init(void *priv,
> struct vb2_queue *src_vq,
> >  
> >  int mtk_venc_unlock(struct mtk_vcodec_enc_ctx *ctx)
> >  {
> > -struct mtk_vcodec_dev *dev = ctx->dev;
> > +struct mtk_vcodec_enc_dev *dev = ctx->dev;
> >  
> >  mutex_unlock(&dev->enc_mutex);
> >  return 0;
> > @@ -1444,7 +1443,7 @@ int mtk_venc_unlock(struct mtk_vcodec_enc_ctx
> *ctx)
> >  
> >  int mtk_venc_lock(struct mtk_vcodec_enc_ctx *ctx)
> >  {
> > -struct mtk_vcodec_dev *dev = ctx->dev;
> > +struct mtk_vcodec_enc_dev *dev = ctx->dev;
> >  
> >  mutex_lock(&dev->enc_mutex);
> >  return 0;
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
> > index c9b6ce9dfa2d..0830708de32f 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
> > @@ -16,7 +16,6 @@
> >  #include <media/v4l2-mem2mem.h>
> >  #include <media/videobuf2-dma-contig.h>
> >  
> > -#include "mtk_vcodec_drv.h"
> >  #include "mtk_vcodec_enc.h"
> >  #include "mtk_vcodec_enc_pm.h"
> >  #include "mtk_vcodec_intr.h"
> > @@ -85,14 +84,14 @@ static void clean_irq_status(unsigned int
> irq_status, void __iomem *addr)
> >  }
> >  static irqreturn_t mtk_vcodec_enc_irq_handler(int irq, void *priv)
> >  {
> > -struct mtk_vcodec_dev *dev = priv;
> > +struct mtk_vcodec_enc_dev *dev = priv;
> >  struct mtk_vcodec_enc_ctx *ctx;
> >  unsigned long flags;
> >  void __iomem *addr;
> >  int core_id;
> >  
> >  spin_lock_irqsave(&dev->irqlock, flags);
> > -ctx = dev->curr_enc_ctx;
> > +ctx = dev->curr_ctx;
> >  spin_unlock_irqrestore(&dev->irqlock, flags);
> >  
> >  core_id = dev->venc_pdata->core_id;
> > @@ -116,7 +115,7 @@ static irqreturn_t
> mtk_vcodec_enc_irq_handler(int irq, void *priv)
> >  
> >  static int fops_vcodec_open(struct file *file)
> >  {
> > -struct mtk_vcodec_dev *dev = video_drvdata(file);
> > +struct mtk_vcodec_enc_dev *dev = video_drvdata(file);
> >  struct mtk_vcodec_enc_ctx *ctx = NULL;
> >  int ret = 0;
> >  struct vb2_queue *src_vq;
> > @@ -203,7 +202,7 @@ static int fops_vcodec_open(struct file *file)
> >  
> >  static int fops_vcodec_release(struct file *file)
> >  {
> > -struct mtk_vcodec_dev *dev = video_drvdata(file);
> > +struct mtk_vcodec_enc_dev *dev = video_drvdata(file);
> >  struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(file-
> >private_data);
> >  
> >  mtk_v4l2_venc_dbg(1, ctx, "[%d] encoder", ctx->id);
> > @@ -232,7 +231,7 @@ static const struct v4l2_file_operations
> mtk_vcodec_fops = {
> >  
> >  static int mtk_vcodec_probe(struct platform_device *pdev)
> >  {
> > -struct mtk_vcodec_dev *dev;
> > +struct mtk_vcodec_enc_dev *dev;
> >  struct video_device *vfd_enc;
> >  phandle rproc_phandle;
> >  enum mtk_vcodec_fw_type fw_type;
> > @@ -454,7 +453,7 @@ MODULE_DEVICE_TABLE(of, mtk_vcodec_enc_match);
> >  
> >  static void mtk_vcodec_enc_remove(struct platform_device *pdev)
> >  {
> > -struct mtk_vcodec_dev *dev = platform_get_drvdata(pdev);
> > +struct mtk_vcodec_enc_dev *dev = platform_get_drvdata(pdev);
> >  
> >  destroy_workqueue(dev->encode_workqueue);
> >  if (dev->m2m_dev_enc)
> > @@ -463,7 +462,7 @@ static void mtk_vcodec_enc_remove(struct
> platform_device *pdev)
> >  if (dev->vfd_enc)
> >  video_unregister_device(dev->vfd_enc);
> >  
> > -mtk_vcodec_dbgfs_deinit(dev);
> > +mtk_vcodec_dbgfs_deinit(&dev->dbgfs);
> >  v4l2_device_unregister(&dev->v4l2_dev);
> >  pm_runtime_disable(dev->pm.dev);
> >  mtk_vcodec_fw_release(dev->fw_handler);
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h
> > index 6aa4afe5b796..a88ef9078848 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.h
> > @@ -8,7 +8,39 @@
> >  #define _MTK_VCODEC_ENC_DRV_H_
> >  
> >  #include "mtk_vcodec_com_drv.h"
> > +#include "mtk_vcodec_dbgfs.h"
> >  #include "mtk_vcodec_fw_priv.h"
> > +#include "mtk_vcodec_util.h"
> > +
> > +#define MTK_VCODEC_ENC_NAME"mtk-vcodec-enc"
> > +
> > +#define MTK_ENC_CTX_IS_EXT(ctx) ((ctx)->dev->venc_pdata->uses_ext)
> > +#define MTK_ENC_IOVA_IS_34BIT(ctx) ((ctx)->dev->venc_pdata-
> >uses_34bit)
> > +
> > +/**
> > + * struct mtk_vcodec_enc_pdata - compatible data for each IC
> > + *
> > + * @uses_ext: whether the encoder uses the extended firmware
> messaging format
> > + * @min_bitrate: minimum supported encoding bitrate
> > + * @max_bitrate: maximum supported encoding bitrate
> > + * @capture_formats: array of supported capture formats
> > + * @num_capture_formats: number of entries in capture_formats
> > + * @output_formats: array of supported output formats
> > + * @num_output_formats: number of entries in output_formats
> > + * @core_id: stand for h264 or vp8 encode index
> > + * @uses_34bit: whether the encoder uses 34-bit iova
> > + */
> > +struct mtk_vcodec_enc_pdata {
> > +bool uses_ext;
> > +unsigned long min_bitrate;
> > +unsigned long max_bitrate;
> > +const struct mtk_video_fmt *capture_formats;
> > +size_t num_capture_formats;
> > +const struct mtk_video_fmt *output_formats;
> > +size_t num_output_formats;
> > +int core_id;
> > +bool uses_34bit;
> > +};
> >  
> >  /*
> >   * enum mtk_encode_param - General encoding parameters type
> > @@ -61,8 +93,8 @@ struct mtk_enc_params {
> >   * struct mtk_vcodec_enc_ctx - Context (instance) private data.
> >   *
> >   * @type: type of the instance - decoder or encoder
> > - * @dev: pointer to the mtk_vcodec_dev of the device
> > - * @list: link to ctx_list of mtk_vcodec_dev
> > + * @dev: pointer to the mtk_vcodec_enc_dev of the device
> > + * @list: link to ctx_list of mtk_vcodec_enc_dev
> >   *
> >   * @fh: struct v4l2_fh
> >   * @m2m_ctx: pointer to the v4l2_m2m_ctx of the context
> > @@ -101,7 +133,7 @@ struct mtk_enc_params {
> >   */
> >  struct mtk_vcodec_enc_ctx {
> >  enum mtk_instance_type type;
> > -struct mtk_vcodec_dev *dev;
> > +struct mtk_vcodec_enc_dev *dev;
> >  struct list_head list;
> >  
> >  struct v4l2_fh fh;
> > @@ -136,6 +168,61 @@ struct mtk_vcodec_enc_ctx {
> >  struct mutex q_mutex;
> >  };
> >  
> > +/**
> > + * struct mtk_vcodec_enc_dev - driver data
> > + * @v4l2_dev: V4L2 device to register video devices for.
> > + * @vfd_enc: Video device for encoder.
> > + *
> > + * @m2m_dev_enc: m2m device for encoder.
> > + * @plat_dev: platform device
> > + * @ctx_list: list of struct mtk_vcodec_ctx
> > + * @curr_ctx: The context that is waiting for codec hardware
> > + *
> > + * @reg_base: Mapped address of MTK Vcodec registers.
> > + * @venc_pdata: encoder IC-specific data
> > + *
> > + * @fw_handler: used to communicate with the firmware.
> > + * @id_counter: used to identify current opened instance
> > + *
> > + * @enc_mutex: encoder hardware lock.
> > + * @dev_mutex: video_device lock
> > + * @encode_workqueue: encode work queue
> > + *
> > + * @enc_irq: h264 encoder irq resource
> > + * @irqlock: protect data access by irq handler and work thread
> > + *
> > + * @pm: power management control
> > + * @enc_capability: used to identify encode capability
> > + * @dbgfs: debug log related information
> > + */
> > +struct mtk_vcodec_enc_dev {
> > +struct v4l2_device v4l2_dev;
> > +struct video_device *vfd_enc;
> > +
> > +struct v4l2_m2m_dev *m2m_dev_enc;
> > +struct platform_device *plat_dev;
> > +struct list_head ctx_list;
> > +struct mtk_vcodec_enc_ctx *curr_ctx;
> > +
> > +void __iomem *reg_base[NUM_MAX_VCODEC_REG_BASE];
> > +const struct mtk_vcodec_enc_pdata *venc_pdata;
> > +
> > +struct mtk_vcodec_fw *fw_handler;
> > +unsigned long id_counter;
> > +
> > +/* encoder hardware mutex lock */
> > +struct mutex enc_mutex;
> > +struct mutex dev_mutex;
> > +struct workqueue_struct *encode_workqueue;
> > +
> > +int enc_irq;
> > +spinlock_t irqlock;
> > +
> > +struct mtk_vcodec_pm pm;
> > +unsigned int enc_capability;
> > +struct mtk_vcodec_dbgfs dbgfs;
> > +};
> > +
> >  static inline struct mtk_vcodec_enc_ctx *fh_to_enc_ctx(struct
> v4l2_fh *fh)
> >  {
> >  return container_of(fh, struct mtk_vcodec_enc_ctx, fh);
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.c
> > index 3165e114b221..f7481f33a0b2 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.c
> > @@ -9,10 +9,10 @@
> >  #include <linux/of_platform.h>
> >  #include <linux/pm_runtime.h>
> >  
> > +#include "mtk_vcodec_enc_drv.h"
> >  #include "mtk_vcodec_enc_pm.h"
> > -#include "mtk_vcodec_util.h"
> >  
> > -int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
> > +int mtk_vcodec_init_enc_clk(struct mtk_vcodec_enc_dev *mtkdev)
> >  {
> >  struct platform_device *pdev;
> >  struct mtk_vcodec_pm *pm;
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.h
> > index bc455cefc0cd..e50be0575190 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_pm.h
> > @@ -7,9 +7,9 @@
> >  #ifndef _MTK_VCODEC_ENC_PM_H_
> >  #define _MTK_VCODEC_ENC_PM_H_
> >  
> > -#include "mtk_vcodec_drv.h"
> > +#include "mtk_vcodec_enc_drv.h"
> >  
> > -int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *dev);
> > +int mtk_vcodec_init_enc_clk(struct mtk_vcodec_enc_dev *dev);
> >  
> >  void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm);
> >  void mtk_vcodec_enc_clock_off(struct mtk_vcodec_pm *pm);
> > diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c
> > index 623dd916d09e..5c9f04574ad1 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.c
> > @@ -1,20 +1,28 @@
> >  // SPDX-License-Identifier: GPL-2.0
> >  
> > +#include "mtk_vcodec_dec_drv.h"
> > +#include "mtk_vcodec_enc_drv.h"
> >  #include "mtk_vcodec_fw.h"
> >  #include "mtk_vcodec_fw_priv.h"
> >  #include "mtk_vcodec_util.h"
> > -#include "mtk_vcodec_drv.h"
> >  
> >  struct mtk_vcodec_fw *mtk_vcodec_fw_select(void *priv, enum
> mtk_vcodec_fw_type type,
> >     enum mtk_vcodec_fw_use fw_use)
> >  {
> > +struct platform_device *plat_dev;
> > +
> > +if (fw_use == ENCODER)
> > +plat_dev = ((struct mtk_vcodec_enc_dev *)priv)->plat_dev;
> > +else
> > +plat_dev = ((struct mtk_vcodec_dec_dev *)priv)->plat_dev;
> > +
> >  switch (type) {
> >  case VPU:
> >  return mtk_vcodec_fw_vpu_init(priv, fw_use);
> >  case SCP:
> >  return mtk_vcodec_fw_scp_init(priv, fw_use);
> >  default:
> > -pr_err("invalid vcodec fw type");
> > +dev_err(&plat_dev->dev, "invalid vcodec fw type");
> >  return ERR_PTR(-EINVAL);
> >  }
> >  }
> > diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.h
> > index d8cfbec323d5..83479ab70385 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw.h
> > @@ -8,7 +8,8 @@
> >  
> >  #include "../vpu/mtk_vpu.h"
> >  
> > -struct mtk_vcodec_dev;
> > +struct mtk_vcodec_dec_dev;
> > +struct mtk_vcodec_enc_dev;
> >  
> >  enum mtk_vcodec_fw_type {
> >  VPU,
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_priv.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_priv.h
> > index 3438a4917344..99603accd82e 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_priv.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_priv.h
> > @@ -5,7 +5,8 @@
> >  
> >  #include "mtk_vcodec_fw.h"
> >  
> > -struct mtk_vcodec_dev;
> > +struct mtk_vcodec_dec_dev;
> > +struct mtk_vcodec_enc_dev;
> >  
> >  struct mtk_vcodec_fw {
> >  enum mtk_vcodec_fw_type type;
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c
> > index 71ff1a6ae872..3cb5a5befd24 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c
> > @@ -1,8 +1,8 @@
> >  // SPDX-License-Identifier: GPL-2.0
> >  
> > +#include "mtk_vcodec_dec_drv.h"
> > +#include "mtk_vcodec_enc_drv.h"
> >  #include "mtk_vcodec_fw_priv.h"
> > -#include "mtk_vcodec_util.h"
> > -#include "mtk_vcodec_drv.h"
> >  
> >  static int mtk_vcodec_scp_load_firmware(struct mtk_vcodec_fw *fw)
> >  {
> > @@ -56,14 +56,25 @@ static const struct mtk_vcodec_fw_ops
> mtk_vcodec_rproc_msg = {
> >  struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(void *priv, enum
> mtk_vcodec_fw_use fw_use)
> >  {
> >  struct mtk_vcodec_fw *fw;
> > -struct mtk_vcodec_dev *dev = priv;
> >  struct platform_device *plat_dev;
> >  struct mtk_scp *scp;
> >  
> > -plat_dev = dev->plat_dev;
> > +if (fw_use == ENCODER) {
> > +struct mtk_vcodec_enc_dev *enc_dev = priv;
> > +
> > +plat_dev = enc_dev->plat_dev;
> > +} else if (fw_use == DECODER) {
> > +struct mtk_vcodec_dec_dev *dec_dev = priv;
> > +
> > +plat_dev = dec_dev->plat_dev;
> > +} else {
> > +pr_err("Invalid fw_use %d (use a resonable fw id here)\n",
> fw_use);
> > +return ERR_PTR(-EINVAL);
> > +}
> > +
> >  scp = scp_get(plat_dev);
> >  if (!scp) {
> > -dev_err(&dev->plat_dev->dev, "could not get vdec scp handle");
> > +dev_err(&plat_dev->dev, "could not get vdec scp handle");
> >  return ERR_PTR(-EPROBE_DEFER);
> >  }
> >  
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_vpu.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_vpu.c
> > index 571072dffbfa..18274a51a8f8 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_vpu.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_vpu.c
> > @@ -1,8 +1,8 @@
> >  // SPDX-License-Identifier: GPL-2.0
> >  
> > +#include "mtk_vcodec_dec_drv.h"
> > +#include "mtk_vcodec_enc_drv.h"
> >  #include "mtk_vcodec_fw_priv.h"
> > -#include "mtk_vcodec_util.h"
> > -#include "mtk_vcodec_drv.h"
> >  
> >  static int mtk_vcodec_vpu_load_firmware(struct mtk_vcodec_fw *fw)
> >  {
> > @@ -53,7 +53,7 @@ static void mtk_vcodec_vpu_release(struct
> mtk_vcodec_fw *fw)
> >  
> >  static void mtk_vcodec_vpu_reset_dec_handler(void *priv)
> >  {
> > -struct mtk_vcodec_dev *dev = priv;
> > +struct mtk_vcodec_dec_dev *dev = priv;
> >  struct mtk_vcodec_dec_ctx *ctx;
> >  
> >  dev_err(&dev->plat_dev->dev, "Watchdog timeout!!");
> > @@ -68,7 +68,7 @@ static void mtk_vcodec_vpu_reset_dec_handler(void
> *priv)
> >  
> >  static void mtk_vcodec_vpu_reset_enc_handler(void *priv)
> >  {
> > -struct mtk_vcodec_dev *dev = priv;
> > +struct mtk_vcodec_enc_dev *dev = priv;
> >  struct mtk_vcodec_enc_ctx *ctx;
> >  
> >  dev_err(&dev->plat_dev->dev, "Watchdog timeout!!");
> > @@ -94,24 +94,28 @@ static const struct mtk_vcodec_fw_ops
> mtk_vcodec_vpu_msg = {
> >  struct mtk_vcodec_fw *mtk_vcodec_fw_vpu_init(void *priv, enum
> mtk_vcodec_fw_use fw_use)
> >  {
> >  struct platform_device *fw_pdev;
> > -struct mtk_vcodec_dev *dev = priv;
> >  struct platform_device *plat_dev;
> >  struct mtk_vcodec_fw *fw;
> >  enum rst_id rst_id;
> >  
> >  if (fw_use == ENCODER) {
> > +struct mtk_vcodec_enc_dev *enc_dev = priv;
> > +
> > +plat_dev = enc_dev->plat_dev;
> >  rst_id = VPU_RST_ENC;
> >  } else if (fw_use == DECODER) {
> > +struct mtk_vcodec_dec_dev *dec_dev = priv;
> > +
> > +plat_dev = dec_dev->plat_dev;
> >  rst_id = VPU_RST_DEC;
> >  } else {
> >  pr_err("Invalid fw_use %d (use a resonable fw id here)\n",
> fw_use);
> >  return ERR_PTR(-EINVAL);
> >  }
> >  
> > -plat_dev = dev->plat_dev;
> >  fw_pdev = vpu_get_plat_device(plat_dev);
> >  if (!fw_pdev) {
> > -dev_err(&dev->plat_dev->dev, "firmware device is not ready");
> > +dev_err(&plat_dev->dev, "firmware device is not ready");
> >  return ERR_PTR(-EINVAL);
> >  }
> >  
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> > index 66d1f50d8968..69dae0336a14 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_intr.c
> > @@ -7,9 +7,9 @@
> >  #include <linux/errno.h>
> >  #include <linux/wait.h>
> >  
> > -#include "mtk_vcodec_drv.h"
> > +#include "mtk_vcodec_dec_drv.h"
> > +#include "mtk_vcodec_enc_drv.h"
> >  #include "mtk_vcodec_intr.h"
> > -#include "mtk_vcodec_util.h"
> >  
> >  int mtk_vcodec_wait_for_done_ctx(void *priv, int command, unsigned
> int timeout_ms,
> >   unsigned int hw_id)
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> > index adaeae79558a..18f632eb0b8a 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c
> > @@ -9,9 +9,9 @@
> >  #include <linux/of.h>
> >  #include <linux/of_device.h>
> >  
> > +#include "mtk_vcodec_dec_drv.h"
> > +#include "mtk_vcodec_enc_drv.h"
> >  #include "mtk_vcodec_dec_hw.h"
> > -#include "mtk_vcodec_drv.h"
> > -#include "mtk_vcodec_util.h"
> >  
> >  #if defined(CONFIG_DEBUG_FS)
> >  int mtk_vcodec_dbg;
> > @@ -75,7 +75,7 @@ void mtk_vcodec_mem_free(void *priv, struct
> mtk_vcodec_mem *mem)
> >  }
> >  EXPORT_SYMBOL(mtk_vcodec_mem_free);
> >  
> > -void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dev *dev, int
> hw_idx)
> > +void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dec_dev *dev, int
> hw_idx)
> >  {
> >  if (hw_idx >= MTK_VDEC_HW_MAX || hw_idx < 0 || !dev-
> >subdev_dev[hw_idx]) {
> >  dev_err(&dev->plat_dev->dev, "hw idx is out of range:%d", hw_idx);
> > @@ -86,7 +86,7 @@ void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dev
> *dev, int hw_idx)
> >  }
> >  EXPORT_SYMBOL(mtk_vcodec_get_hw_dev);
> >  
> > -void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
> > +void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dec_dev *vdec_dev,
> >       struct mtk_vcodec_dec_ctx *ctx, int hw_idx)
> >  {
> >  unsigned long flags;
> > @@ -108,7 +108,7 @@ void mtk_vcodec_set_curr_ctx(struct
> mtk_vcodec_dev *vdec_dev,
> >  }
> >  EXPORT_SYMBOL(mtk_vcodec_set_curr_ctx);
> >  
> > -struct mtk_vcodec_dec_ctx *mtk_vcodec_get_curr_ctx(struct
> mtk_vcodec_dev *vdec_dev,
> > +struct mtk_vcodec_dec_ctx *mtk_vcodec_get_curr_ctx(struct
> mtk_vcodec_dec_dev *vdec_dev,
> >     unsigned int hw_idx)
> >  {
> >  unsigned long flags;
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> > index 4d48b516f62d..6c24bb8b1715 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
> > @@ -23,7 +23,7 @@ struct mtk_vcodec_fb {
> >  };
> >  
> >  struct mtk_vcodec_dec_ctx;
> > -struct mtk_vcodec_dev;
> > +struct mtk_vcodec_dec_dev;
> >  
> >  #undef pr_fmt
> >  #define pr_fmt(fmt) "%s(),%d: " fmt, __func__, __LINE__
> > @@ -83,10 +83,10 @@ extern int mtk_vcodec_dbg;
> >  void __iomem *mtk_vcodec_get_reg_addr(void __iomem **reg_base,
> unsigned int reg_idx);
> >  int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem);
> >  void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem);
> > -void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
> > +void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dec_dev *vdec_dev,
> >       struct mtk_vcodec_dec_ctx *ctx, int hw_idx);
> > -struct mtk_vcodec_dec_ctx *mtk_vcodec_get_curr_ctx(struct
> mtk_vcodec_dev *vdec_dev,
> > +struct mtk_vcodec_dec_ctx *mtk_vcodec_get_curr_ctx(struct
> mtk_vcodec_dec_dev *vdec_dev,
> >     unsigned int hw_idx);
> > -void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dev *dev, int
> hw_idx);
> > +void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dec_dev *dev, int
> hw_idx);
> >  
> >  #endif /* _MTK_VCODEC_UTIL_H_ */
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.h
> b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.h
> > index 0dda9e2315c0..ac82be336055 100644
> > ---
> a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.h
> > +++
> b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_common.h
> > @@ -13,7 +13,7 @@
> >  #include <media/v4l2-mem2mem.h>
> >  #include <media/videobuf2-dma-contig.h>
> >  
> > -#include "../mtk_vcodec_drv.h"
> > +#include "../mtk_vcodec_dec_drv.h"
> >  
> >  #define NAL_NON_IDR_SLICE0x01
> >  #define NAL_IDR_SLICE0x05
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.
> c
> b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.
> c
> > index 846cc39c0168..79eff921fc97 100644
> > ---
> a/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.
> c
> > +++
> b/drivers/media/platform/mediatek/vcodec/vdec/vdec_h264_req_multi_if.
> c
> > @@ -540,7 +540,7 @@ static int vdec_h264_slice_core_decode(struct
> vdec_lat_buf *lat_buf)
> >  return 0;
> >  }
> >  
> > -static void vdec_h264_insert_startcode(struct mtk_vcodec_dev
> *vcodec_dev, unsigned char *buf,
> > +static void vdec_h264_insert_startcode(struct mtk_vcodec_dec_dev
> *vcodec_dev, unsigned char *buf,
> >         size_t *bs_size, struct mtk_h264_pps_param *pps)
> >  {
> >  struct device *dev = &vcodec_dev->plat_dev->dev;
> > diff --git a/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h
> b/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h
> > index 816ed6ab1ed0..7b41ce23158b 100644
> > --- a/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h
> > +++ b/drivers/media/platform/mediatek/vcodec/vdec_drv_if.h
> > @@ -8,7 +8,6 @@
> >  #ifndef _VDEC_DRV_IF_H_
> >  #define _VDEC_DRV_IF_H_
> >  
> > -#include "mtk_vcodec_drv.h"
> >  #include "mtk_vcodec_dec.h"
> >  #include "mtk_vcodec_util.h"
> >  
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
> b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
> > index 0dd1374ccc38..890b955e4b31 100644
> > --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
> > +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
> > @@ -8,8 +8,8 @@
> >  #include <linux/interrupt.h>
> >  #include <linux/kthread.h>
> >  
> > +#include "mtk_vcodec_dec_drv.h"
> >  #include "mtk_vcodec_dec_pm.h"
> > -#include "mtk_vcodec_drv.h"
> >  #include "vdec_msg_queue.h"
> >  
> >  #define VDEC_MSG_QUEUE_TIMEOUT_MS 1500
> > @@ -239,7 +239,7 @@ static void vdec_msg_queue_core_work(struct
> work_struct *work)
> >  container_of(work, struct vdec_msg_queue, core_work);
> >  struct mtk_vcodec_dec_ctx *ctx =
> >  container_of(msg_queue, struct mtk_vcodec_dec_ctx, msg_queue);
> > -struct mtk_vcodec_dev *dev = ctx->dev;
> > +struct mtk_vcodec_dec_dev *dev = ctx->dev;
> >  struct vdec_lat_buf *lat_buf;
> >  
> >  spin_lock(&msg_queue->core_ctx.ready_lock);
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
> b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
> > index 1fb3f57c2384..eeb5deb907ed 100644
> > --- a/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
> > +++ b/drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
> > @@ -18,7 +18,7 @@
> >  
> >  struct vdec_lat_buf;
> >  struct mtk_vcodec_dec_ctx;
> > -struct mtk_vcodec_dev;
> > +struct mtk_vcodec_dec_dev;
> >  typedef int (*core_decode_cb_t)(struct vdec_lat_buf *lat_buf);
> >  
> >  /**
> > diff --git a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> > index d82391411ba1..7fe8e196cb45 100644
> > --- a/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/vdec_vpu_if.c
> > @@ -4,8 +4,7 @@
> >   * Author: PC Chen <pc.chen@mediatek.com>
> >   */
> >  
> > -#include "mtk_vcodec_drv.h"
> > -#include "mtk_vcodec_util.h"
> > +#include "mtk_vcodec_dec_drv.h"
> >  #include "vdec_drv_if.h"
> >  #include "vdec_ipi_msg.h"
> >  #include "vdec_vpu_if.h"
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> > index c5f9fc24a692..41d463d40843 100644
> > --- a/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_h264_if.c
> > @@ -10,7 +10,7 @@
> >  #include <linux/kernel.h>
> >  #include <linux/slab.h>
> >  
> > -#include "../mtk_vcodec_drv.h"
> > +#include "../mtk_vcodec_enc_drv.h"
> >  #include "../mtk_vcodec_util.h"
> >  #include "../mtk_vcodec_intr.h"
> >  #include "../mtk_vcodec_enc.h"
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> > index e8e4474eacc7..dfd6833576f4 100644
> > --- a/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/venc/venc_vp8_if.c
> > @@ -9,7 +9,7 @@
> >  #include <linux/kernel.h>
> >  #include <linux/slab.h>
> >  
> > -#include "../mtk_vcodec_drv.h"
> > +#include "../mtk_vcodec_enc_drv.h"
> >  #include "../mtk_vcodec_util.h"
> >  #include "../mtk_vcodec_intr.h"
> >  #include "../mtk_vcodec_enc.h"
> > diff --git a/drivers/media/platform/mediatek/vcodec/venc_drv_base.h
> b/drivers/media/platform/mediatek/vcodec/venc_drv_base.h
> > index 17f8183461b5..856d50151bf6 100644
> > --- a/drivers/media/platform/mediatek/vcodec/venc_drv_base.h
> > +++ b/drivers/media/platform/mediatek/vcodec/venc_drv_base.h
> > @@ -9,7 +9,7 @@
> >  #ifndef _VENC_DRV_BASE_
> >  #define _VENC_DRV_BASE_
> >  
> > -#include "mtk_vcodec_drv.h"
> > +#include "mtk_vcodec_enc_drv.h"
> >  
> >  #include "venc_drv_if.h"
> >  
> > diff --git a/drivers/media/platform/mediatek/vcodec/venc_drv_if.c
> b/drivers/media/platform/mediatek/vcodec/venc_drv_if.c
> > index 08083030516e..1bdaecdd64a7 100644
> > --- a/drivers/media/platform/mediatek/vcodec/venc_drv_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/venc_drv_if.c
> > @@ -65,7 +65,7 @@ int venc_if_encode(struct mtk_vcodec_enc_ctx
> *ctx,
> >  mtk_venc_lock(ctx);
> >  
> >  spin_lock_irqsave(&ctx->dev->irqlock, flags);
> > -ctx->dev->curr_enc_ctx = ctx;
> > +ctx->dev->curr_ctx = ctx;
> >  spin_unlock_irqrestore(&ctx->dev->irqlock, flags);
> >  
> >  mtk_vcodec_enc_clock_on(&ctx->dev->pm);
> > @@ -74,7 +74,7 @@ int venc_if_encode(struct mtk_vcodec_enc_ctx
> *ctx,
> >  mtk_vcodec_enc_clock_off(&ctx->dev->pm);
> >  
> >  spin_lock_irqsave(&ctx->dev->irqlock, flags);
> > -ctx->dev->curr_enc_ctx = NULL;
> > +ctx->dev->curr_ctx = NULL;
> >  spin_unlock_irqrestore(&ctx->dev->irqlock, flags);
> >  
> >  mtk_venc_unlock(ctx);
> > diff --git a/drivers/media/platform/mediatek/vcodec/venc_drv_if.h
> b/drivers/media/platform/mediatek/vcodec/venc_drv_if.h
> > index 90d714e86ede..d00fb68b8235 100644
> > --- a/drivers/media/platform/mediatek/vcodec/venc_drv_if.h
> > +++ b/drivers/media/platform/mediatek/vcodec/venc_drv_if.h
> > @@ -9,8 +9,7 @@
> >  #ifndef _VENC_DRV_IF_H_
> >  #define _VENC_DRV_IF_H_
> >  
> > -#include "mtk_vcodec_drv.h"
> > -#include "mtk_vcodec_util.h"
> > +#include "mtk_vcodec_enc_drv.h"
> >  
> >  /*
> >   * enum venc_yuv_fmt - The type of input yuv format
> > diff --git a/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> b/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> > index c69f66b6d341..bfff16da0451 100644
> > --- a/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> > +++ b/drivers/media/platform/mediatek/vcodec/venc_vpu_if.c
> > @@ -4,7 +4,7 @@
> >   * Author: PoChun Lin <pochun.lin@mediatek.com>
> >   */
> >  
> > -#include "mtk_vcodec_drv.h"
> > +#include "mtk_vcodec_enc_drv.h"
> >  #include "mtk_vcodec_fw.h"
> >  #include "venc_ipi_msg.h"
> >  #include "venc_vpu_if.h"
>