From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Jonas Karlman <jonas@kwiboo.se>,
Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
Detlev Casanova <detlev.casanova@collabora.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Heiko Stuebner <heiko@sntech.de>
Cc: Alex Bee <knaerzche@gmail.com>,
Sebastian Fricke <sebastian.fricke@collabora.com>,
linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/7] media: rkvdec: Implement capability filtering
Date: Mon, 11 Aug 2025 17:17:12 -0400 [thread overview]
Message-ID: <a08b45fe17a0374230f300f30d344252b6d597da.camel@collabora.com> (raw)
In-Reply-To: <20250810212454.3237486-4-jonas@kwiboo.se>
[-- Attachment #1: Type: text/plain, Size: 5802 bytes --]
Le dimanche 10 août 2025 à 21:24 +0000, Jonas Karlman a écrit :
> Add filtering of coded formats and controls depending on a variant
> capabilities.
>
> Signed-off-by: Alex Bee <knaerzche@gmail.com>
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> ---
> Changes in v2:
> - Adjust code style in rkvdec_enum_coded_fmt_desc()
> ---
> .../media/platform/rockchip/rkvdec/rkvdec.c | 67 ++++++++++++++-----
> 1 file changed, 49 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> index e7b9dfc2d1ab..56807122720e 100644
> --- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> @@ -365,13 +365,36 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = {
> }
> };
>
> +static bool rkvdec_is_capable(struct rkvdec_ctx *ctx, unsigned int capability)
> +{
> + return (ctx->dev->capabilities & capability) == capability;
> +}
> +
> static const struct rkvdec_coded_fmt_desc *
> -rkvdec_find_coded_fmt_desc(u32 fourcc)
> +rkvdec_enum_coded_fmt_desc(struct rkvdec_ctx *ctx, int index)
> {
> + int fmt_idx = -1;
> unsigned int i;
>
> for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) {
> - if (rkvdec_coded_fmts[i].fourcc == fourcc)
> + if (!rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability))
> + continue;
> + fmt_idx++;
> + if (index == fmt_idx)
> + return &rkvdec_coded_fmts[i];
> + }
> +
> + return NULL;
> +}
> +
> +static const struct rkvdec_coded_fmt_desc *
> +rkvdec_find_coded_fmt_desc(struct rkvdec_ctx *ctx, u32 fourcc)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) {
> + if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability) &&
> + rkvdec_coded_fmts[i].fourcc == fourcc)
> return &rkvdec_coded_fmts[i];
> }
>
> @@ -382,7 +405,7 @@ static void rkvdec_reset_coded_fmt(struct rkvdec_ctx *ctx)
> {
> struct v4l2_format *f = &ctx->coded_fmt;
>
> - ctx->coded_fmt_desc = &rkvdec_coded_fmts[0];
> + ctx->coded_fmt_desc = rkvdec_enum_coded_fmt_desc(ctx, 0);
> rkvdec_reset_fmt(ctx, f, ctx->coded_fmt_desc->fourcc);
>
> f->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
> @@ -396,21 +419,22 @@ static void rkvdec_reset_coded_fmt(struct rkvdec_ctx *ctx)
> static int rkvdec_enum_framesizes(struct file *file, void *priv,
> struct v4l2_frmsizeenum *fsize)
> {
> - const struct rkvdec_coded_fmt_desc *fmt;
> + struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
> + const struct rkvdec_coded_fmt_desc *desc;
>
> if (fsize->index != 0)
> return -EINVAL;
>
> - fmt = rkvdec_find_coded_fmt_desc(fsize->pixel_format);
> - if (!fmt)
> + desc = rkvdec_find_coded_fmt_desc(ctx, fsize->pixel_format);
> + if (!desc)
> return -EINVAL;
>
> fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
> fsize->stepwise.min_width = 1;
> - fsize->stepwise.max_width = fmt->frmsize.max_width;
> + fsize->stepwise.max_width = desc->frmsize.max_width;
> fsize->stepwise.step_width = 1;
> fsize->stepwise.min_height = 1;
> - fsize->stepwise.max_height = fmt->frmsize.max_height;
> + fsize->stepwise.max_height = desc->frmsize.max_height;
> fsize->stepwise.step_height = 1;
>
> return 0;
> @@ -470,10 +494,10 @@ static int rkvdec_try_output_fmt(struct file *file, void *priv,
> struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
> const struct rkvdec_coded_fmt_desc *desc;
>
> - desc = rkvdec_find_coded_fmt_desc(pix_mp->pixelformat);
> + desc = rkvdec_find_coded_fmt_desc(ctx, pix_mp->pixelformat);
> if (!desc) {
> - pix_mp->pixelformat = rkvdec_coded_fmts[0].fourcc;
> - desc = &rkvdec_coded_fmts[0];
> + desc = rkvdec_enum_coded_fmt_desc(ctx, 0);
> + pix_mp->pixelformat = desc->fourcc;
> }
>
> v4l2_apply_frmsize_constraints(&pix_mp->width,
> @@ -550,7 +574,7 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv,
> if (ret)
> return ret;
>
> - desc = rkvdec_find_coded_fmt_desc(f->fmt.pix_mp.pixelformat);
> + desc = rkvdec_find_coded_fmt_desc(ctx, f->fmt.pix_mp.pixelformat);
> if (!desc)
> return -EINVAL;
> ctx->coded_fmt_desc = desc;
> @@ -602,10 +626,14 @@ static int rkvdec_g_capture_fmt(struct file *file, void *priv,
> static int rkvdec_enum_output_fmt(struct file *file, void *priv,
> struct v4l2_fmtdesc *f)
> {
> - if (f->index >= ARRAY_SIZE(rkvdec_coded_fmts))
> + struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
> + const struct rkvdec_coded_fmt_desc *desc;
> +
> + desc = rkvdec_enum_coded_fmt_desc(ctx, f->index);
> + if (!desc)
> return -EINVAL;
>
> - f->pixelformat = rkvdec_coded_fmts[f->index].fourcc;
> + f->pixelformat = desc->fourcc;
> return 0;
> }
>
> @@ -970,14 +998,17 @@ static int rkvdec_init_ctrls(struct rkvdec_ctx *ctx)
> int ret;
>
> for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++)
> - nctrls += rkvdec_coded_fmts[i].ctrls->num_ctrls;
> + if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability))
> + nctrls += rkvdec_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);
> - if (ret)
> - goto err_free_handler;
> + if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability)) {
> + ret = rkvdec_add_ctrls(ctx, rkvdec_coded_fmts[i].ctrls);
> + if (ret)
> + goto err_free_handler;
> + }
> }
>
> ret = v4l2_ctrl_handler_setup(&ctx->ctrl_hdl);
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
cheers,
Nicolas
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2025-08-11 21:17 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-10 21:24 [PATCH v2 0/7] media: rkvdec: Add HEVC backend Jonas Karlman
2025-08-10 21:24 ` [PATCH v2 1/7] " Jonas Karlman
2025-08-11 19:12 ` Nicolas Dufresne
2025-08-11 19:46 ` Jonas Karlman
2025-08-11 20:27 ` Nicolas Dufresne
2025-08-11 21:07 ` Nicolas Dufresne
2025-08-12 0:58 ` Jonas Karlman
2025-08-12 13:07 ` Nicolas Dufresne
2025-08-12 19:54 ` Detlev Casanova
2025-08-17 16:39 ` Jonas Karlman
2025-08-18 8:25 ` Detlev Casanova
2025-08-12 20:10 ` Detlev Casanova
2025-08-17 16:46 ` Jonas Karlman
2025-08-29 20:22 ` Nicolas Dufresne
2025-09-03 7:28 ` Jonas Karlman
2025-09-03 13:44 ` Nicolas Dufresne
2025-08-10 21:24 ` [PATCH v2 2/7] media: rkvdec: Add variants support Jonas Karlman
2025-08-11 21:11 ` Nicolas Dufresne
2025-08-10 21:24 ` [PATCH v2 3/7] media: rkvdec: Implement capability filtering Jonas Karlman
2025-08-11 21:17 ` Nicolas Dufresne [this message]
2025-08-10 21:24 ` [PATCH v2 4/7] media: rkvdec: Add RK3288 variant Jonas Karlman
2025-08-11 21:17 ` Nicolas Dufresne
2025-08-10 21:24 ` [PATCH v2 5/7] media: rkvdec: Disable QoS for HEVC and VP9 on RK3328 Jonas Karlman
2025-08-11 21:25 ` Nicolas Dufresne
2025-08-11 22:22 ` Jonas Karlman
2025-08-12 12:47 ` Nicolas Dufresne
2025-08-11 23:08 ` Jonas Karlman
2025-08-12 13:00 ` Nicolas Dufresne
2025-08-17 16:18 ` Jonas Karlman
2025-08-10 21:24 ` [PATCH v2 6/7] media: dt-bindings: rockchip,vdec: Add RK3288 compatible Jonas Karlman
2025-08-10 21:24 ` [PATCH v2 7/7] ARM: dts: rockchip: Add vdec node for RK3288 Jonas Karlman
2025-08-11 21:52 ` [PATCH v2 0/7] media: rkvdec: Add HEVC backend Nicolas Dufresne
2025-08-12 0:00 ` Jonas Karlman
2025-08-12 12:38 ` Nicolas Dufresne
2025-08-12 12:44 ` Nicolas Dufresne
2025-08-12 17:31 ` Jonas Karlman
2025-08-12 18:26 ` Nicolas Dufresne
2025-08-12 18:52 ` Nicolas Dufresne
2025-08-17 16:33 ` Jonas Karlman
2025-08-12 19:57 ` Detlev Casanova
2025-08-12 21:11 ` Nicolas Dufresne
2025-08-12 12:11 ` Diederik de Haas
2025-08-12 12:55 ` Diederik de Haas
2025-08-12 13:27 ` Nicolas Dufresne
2025-08-12 14:09 ` Diederik de Haas
2025-08-14 21:25 ` Alex Bee
2025-08-12 17:11 ` Jonas Karlman
2025-08-12 18:28 ` Diederik de Haas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a08b45fe17a0374230f300f30d344252b6d597da.camel@collabora.com \
--to=nicolas.dufresne@collabora.com \
--cc=detlev.casanova@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=heiko@sntech.de \
--cc=jonas@kwiboo.se \
--cc=knaerzche@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=sebastian.fricke@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).