Re: [PATCH v2 05/12] media: rkvdec: Add per variant configuration

From: Krzysztof Kozlowski
Date: Mon Aug 11 2025 - 02:13:36 EST


On 08/08/2025 22:03, Detlev Casanova wrote:
> This is to prepare for adding different variants of the decoder and

Prepare for...

> support specific formats and ops.
>
> Signed-off-by: Detlev Casanova <detlev.casanova@xxxxxxxxxxxxx>
> ---


...


> static int rkvdec_init_ctrls(struct rkvdec_ctx *ctx)
> {
> + struct rkvdec_config *cfg = ctx->dev->config;
> unsigned int i, nctrls = 0;
> int ret;
>
> - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++)
> - nctrls += rkvdec_coded_fmts[i].ctrls->num_ctrls;
> + for (i = 0; i < cfg->coded_fmts_num; i++)
> + nctrls += cfg->coded_fmts[i].ctrls->num_ctrls;
>
> v4l2_ctrl_handler_init(&ctx->ctrl_hdl, nctrls);
>
> - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) {
> - ret = rkvdec_add_ctrls(ctx, rkvdec_coded_fmts[i].ctrls);
> + for (i = 0; i < cfg->coded_fmts_num; i++) {
> + ret = rkvdec_add_ctrls(ctx, cfg->coded_fmts[i].ctrls);
> if (ret)
> goto err_free_handler;
> }
> @@ -1119,8 +1127,13 @@ static void rkvdec_watchdog_func(struct work_struct *work)
> }
> }
>
> +const struct rkvdec_config config_rkvdec = {

Why isn't this static?

> + .coded_fmts = (struct rkvdec_coded_fmt_desc *)rkvdec_coded_fmts,
> + .coded_fmts_num = ARRAY_SIZE(rkvdec_coded_fmts),
> +};
> +
> static const struct of_device_id of_rkvdec_match[] = {
> - { .compatible = "rockchip,rk3399-vdec" },
> + { .compatible = "rockchip,rk3399-vdec", .data = &config_rkvdec },
> { /* sentinel */ }
> };
> MODULE_DEVICE_TABLE(of, of_rkvdec_match);
> @@ -1144,6 +1157,9 @@ static int rkvdec_probe(struct platform_device *pdev)
> mutex_init(&rkvdec->vdev_lock);
> INIT_DELAYED_WORK(&rkvdec->watchdog_work, rkvdec_watchdog_func);
>
> + rkvdec->config =
> + (struct rkvdec_config *)of_device_get_match_data(rkvdec->dev);

If you need a cast, your code is wrong.


Best regards,
Krzysztof