Le mardi 27 janvier 2026 à 10:42 +0800, Kyrie Wu a écrit : > This commit refactors the handling of decoder parameters for H264, > H265, and VP9 codecs by introducing a new structure to standardize > supported level and profile information. By leveraging this changes, this changes -> this change cheers, Nicolas > chipset-specific conditional logic in the codec configuration > functions is significantly reduced. > > Signed-off-by: Kyrie Wu > Reviewed-by: AngeloGioacchino Del Regno > --- >  .../vcodec/decoder/mtk_vcodec_dec_drv.h       | 16 ++++ >  .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 93 ++++--------------- >  2 files changed, 34 insertions(+), 75 deletions(-) > > diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h > index bb293ada6fb2..f38b5dc4bb74 100644 > --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h > +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h > @@ -76,6 +76,16 @@ struct vdec_pic_info { >   unsigned int reserved; >  }; >   > +/** > + * struct mtk_vcodec_dec_params - decoder supported parameters > + * @level: decoder supported vcodec level > + * @profile: decoder supported vcodec profile > + */ > +struct mtk_vcodec_dec_params { > + s64 level; > + s64 profile; > +}; > + >  /** >   * struct mtk_vcodec_dec_pdata - compatible data for each IC >   * @init_vdec_params: init vdec params > @@ -96,6 +106,9 @@ struct vdec_pic_info { >   * @is_subdev_supported: whether support parent-node architecture(subdev) >   * @uses_stateless_api: whether the decoder uses the stateless API with requests >   * @chip_name: platforms configuration values > + * @h264_params: H264 decoder default supported params > + * @h265_params: H265 decoder default supported params > + * @vp9_params: VP9 decoder default supported params >   */ >  struct mtk_vcodec_dec_pdata { >   void (*init_vdec_params)(struct mtk_vcodec_dec_ctx *ctx); > @@ -118,6 +131,9 @@ struct mtk_vcodec_dec_pdata { >   bool is_subdev_supported; >   bool uses_stateless_api; >   unsigned int chip_name; > + struct mtk_vcodec_dec_params h264_params; > + struct mtk_vcodec_dec_params h265_params; > + struct mtk_vcodec_dec_params vp9_params; >  }; >   >  /** > diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c > index aba28d276bdf..a1f419202a24 100644 > --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c > +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c > @@ -549,106 +549,49 @@ static const struct v4l2_ctrl_ops mtk_vcodec_dec_ctrl_ops = { >  static void mtk_vcodec_dec_fill_h264_level(struct v4l2_ctrl_config *cfg, >      struct mtk_vcodec_dec_ctx *ctx) >  { > - switch (ctx->dev->chip_name) { > - case 8192: > - case 8188: > - cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_5_2; > - break; > - case 8195: > - case 8196: > - cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_6_0; > - break; > - case 8183: > - case 8186: > - cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_4_2; > - break; > - default: > - cfg->max = V4L2_MPEG_VIDEO_H264_LEVEL_4_1; > - break; > - } > + struct mtk_vcodec_dec_dev *pdev = ctx->dev; > + > + cfg->max = pdev->vdec_pdata->h264_params.level; >  } >   >  static void mtk_vcodec_dec_fill_h264_profile(struct v4l2_ctrl_config *cfg, >        struct mtk_vcodec_dec_ctx *ctx) >  { > - switch (ctx->dev->chip_name) { > - case 8188: > - case 8195: > - case 8196: > - cfg->max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10; > - break; > - default: > - cfg->max = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH; > - break; > - } > + struct mtk_vcodec_dec_dev *pdev = ctx->dev; > + > + cfg->max = pdev->vdec_pdata->h264_params.profile; >  } >   >  static void mtk_vcodec_dec_fill_h265_level(struct v4l2_ctrl_config *cfg, >      struct mtk_vcodec_dec_ctx *ctx) >  { > - switch (ctx->dev->chip_name) { > - case 8188: > - cfg->max = V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1; > - break; > - case 8195: > - case 8196: > - cfg->max = V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2; > - break; > - default: > - cfg->max = V4L2_MPEG_VIDEO_HEVC_LEVEL_4; > - break; > - } > + struct mtk_vcodec_dec_dev *pdev = ctx->dev; > + > + cfg->max = pdev->vdec_pdata->h265_params.level; >  } >   >  static void mtk_vcodec_dec_fill_h265_profile(struct v4l2_ctrl_config *cfg, >        struct mtk_vcodec_dec_ctx *ctx) >  { > - switch (ctx->dev->chip_name) { > - case 8188: > - case 8195: > - case 8196: > - cfg->max = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10; > - break; > - default: > - cfg->max = V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_STILL_PICTURE; > - break; > - } > + struct mtk_vcodec_dec_dev *pdev = ctx->dev; > + > + cfg->max = pdev->vdec_pdata->h265_params.profile; >  } >   >  static void mtk_vcodec_dec_fill_vp9_level(struct v4l2_ctrl_config *cfg, >     struct mtk_vcodec_dec_ctx *ctx) >  { > - switch (ctx->dev->chip_name) { > - case 8192: > - case 8188: > - cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_5_1; > - break; > - case 8195: > - case 8196: > - cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_5_2; > - break; > - case 8186: > - cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_4_1; > - break; > - default: > - cfg->max = V4L2_MPEG_VIDEO_VP9_LEVEL_4_0; > - break; > - } > + struct mtk_vcodec_dec_dev *pdev = ctx->dev; > + > + cfg->max = pdev->vdec_pdata->vp9_params.level; >  } >   >  static void mtk_vcodec_dec_fill_vp9_profile(struct v4l2_ctrl_config *cfg, >       struct mtk_vcodec_dec_ctx *ctx) >  { > - switch (ctx->dev->chip_name) { > - case 8188: > - case 8195: > - case 8196: > - cfg->max = V4L2_MPEG_VIDEO_VP9_PROFILE_2; > - break; > - default: > - cfg->max = V4L2_MPEG_VIDEO_VP9_PROFILE_1; > - break; > - } > + struct mtk_vcodec_dec_dev *pdev = ctx->dev; > + > + cfg->max = pdev->vdec_pdata->vp9_params.profile; >  } >   >  static void mtk_vcodec_dec_reset_controls(struct v4l2_ctrl_config *cfg,