[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251023214247.459931-9-detlev.casanova@collabora.com>
Date: Thu, 23 Oct 2025 17:42:39 -0400
From: Detlev Casanova <detlev.casanova@...labora.com>
To: linux-kernel@...r.kernel.org
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>,
Detlev Casanova <detlev.casanova@...labora.com>,
Ezequiel Garcia <ezequiel@...guardiasur.com.ar>,
Heiko Stuebner <heiko@...ech.de>,
Ricardo Ribalda <ribalda@...omium.org>,
Hans Verkuil <hverkuil@...nel.org>,
Hans de Goede <hansg@...nel.org>,
Yunke Cao <yunkec@...gle.com>,
Jonathan Corbet <corbet@....net>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
James Cowgill <james.cowgill@...ize.com>,
linux-media@...r.kernel.org,
linux-rockchip@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org,
kernel@...labora.com,
Nicolas Dufresne <nicolas.dufresne@...labora.com>,
Diederik de Haas <didi.debian@...ow.org>
Subject: [PATCH v5 08/15] media: rkvdec: Add variant specific coded formats list
Prepare for adding new variants of the decoder and support specific
formats and format ops per variant.
Tested-by: Diederik de Haas <didi.debian@...ow.org> # Rock 5B
Signed-off-by: Detlev Casanova <detlev.casanova@...labora.com>
---
.../media/platform/rockchip/rkvdec/rkvdec.c | 35 ++++++++++++-------
.../media/platform/rockchip/rkvdec/rkvdec.h | 2 ++
2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index 776149f871b0..968982f6e62c 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
@@ -373,15 +373,16 @@ static bool rkvdec_is_capable(struct rkvdec_ctx *ctx, unsigned int capability)
static const struct rkvdec_coded_fmt_desc *
rkvdec_enum_coded_fmt_desc(struct rkvdec_ctx *ctx, int index)
{
+ const struct rkvdec_variant *variant = ctx->dev->variant;
int fmt_idx = -1;
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) {
- if (!rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability))
+ for (i = 0; i < variant->num_coded_fmts; i++) {
+ if (!rkvdec_is_capable(ctx, variant->coded_fmts[i].capability))
continue;
fmt_idx++;
if (index == fmt_idx)
- return &rkvdec_coded_fmts[i];
+ return &variant->coded_fmts[i];
}
return NULL;
@@ -390,12 +391,13 @@ rkvdec_enum_coded_fmt_desc(struct rkvdec_ctx *ctx, int index)
static const struct rkvdec_coded_fmt_desc *
rkvdec_find_coded_fmt_desc(struct rkvdec_ctx *ctx, u32 fourcc)
{
+ const struct rkvdec_variant *variant = ctx->dev->variant;
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];
+ for (i = 0; i < variant->num_coded_fmts; i++) {
+ if (rkvdec_is_capable(ctx, variant->coded_fmts[i].capability) &&
+ variant->coded_fmts[i].fourcc == fourcc)
+ return &variant->coded_fmts[i];
}
return NULL;
@@ -1014,18 +1016,19 @@ static int rkvdec_add_ctrls(struct rkvdec_ctx *ctx,
static int rkvdec_init_ctrls(struct rkvdec_ctx *ctx)
{
+ const struct rkvdec_variant *variant = ctx->dev->variant;
unsigned int i, nctrls = 0;
int ret;
- for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++)
- if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability))
- nctrls += rkvdec_coded_fmts[i].ctrls->num_ctrls;
+ for (i = 0; i < variant->num_coded_fmts; i++)
+ if (rkvdec_is_capable(ctx, variant->coded_fmts[i].capability))
+ nctrls += variant->coded_fmts[i].ctrls->num_ctrls;
v4l2_ctrl_handler_init(&ctx->ctrl_hdl, nctrls);
- for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) {
- if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability)) {
- ret = rkvdec_add_ctrls(ctx, rkvdec_coded_fmts[i].ctrls);
+ for (i = 0; i < variant->num_coded_fmts; i++) {
+ if (rkvdec_is_capable(ctx, variant->coded_fmts[i].capability)) {
+ ret = rkvdec_add_ctrls(ctx, variant->coded_fmts[i].ctrls);
if (ret)
goto err_free_handler;
}
@@ -1242,11 +1245,15 @@ static void rkvdec_watchdog_func(struct work_struct *work)
static const struct rkvdec_variant rk3288_rkvdec_variant = {
.num_regs = 68,
+ .coded_fmts = rkvdec_coded_fmts,
+ .num_coded_fmts = ARRAY_SIZE(rkvdec_coded_fmts),
.capabilities = RKVDEC_CAPABILITY_HEVC,
};
static const struct rkvdec_variant rk3328_rkvdec_variant = {
.num_regs = 109,
+ .coded_fmts = rkvdec_coded_fmts,
+ .num_coded_fmts = ARRAY_SIZE(rkvdec_coded_fmts),
.capabilities = RKVDEC_CAPABILITY_HEVC |
RKVDEC_CAPABILITY_H264 |
RKVDEC_CAPABILITY_VP9,
@@ -1255,6 +1262,8 @@ static const struct rkvdec_variant rk3328_rkvdec_variant = {
static const struct rkvdec_variant rk3399_rkvdec_variant = {
.num_regs = 78,
+ .coded_fmts = rkvdec_coded_fmts,
+ .num_coded_fmts = ARRAY_SIZE(rkvdec_coded_fmts),
.capabilities = RKVDEC_CAPABILITY_HEVC |
RKVDEC_CAPABILITY_H264 |
RKVDEC_CAPABILITY_VP9,
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.h b/drivers/media/platform/rockchip/rkvdec/rkvdec.h
index f35f6e80ea2e..aac6cba4c623 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.h
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.h
@@ -71,6 +71,8 @@ vb2_to_rkvdec_decoded_buf(struct vb2_buffer *buf)
struct rkvdec_variant {
unsigned int num_regs;
+ const struct rkvdec_coded_fmt_desc *coded_fmts;
+ size_t num_coded_fmts;
unsigned int capabilities;
unsigned int quirks;
};
--
2.51.1.dirty
Powered by blists - more mailing lists