Skip to content

Commit ae2070c

Browse files
cazouHans Verkuil
authored andcommitted
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. This removes the need of capability flags for variants, so remove them. Tested-by: Diederik de Haas <didi.debian@cknow.org> # Rock 5B Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Detlev Casanova <detlev.casanova@collabora.com> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
1 parent 34e2b14 commit ae2070c

2 files changed

Lines changed: 39 additions & 37 deletions

File tree

drivers/media/platform/rockchip/rkvdec/rkvdec.c

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = {
328328
.ops = &rkvdec_hevc_fmt_ops,
329329
.num_decoded_fmts = ARRAY_SIZE(rkvdec_hevc_decoded_fmts),
330330
.decoded_fmts = rkvdec_hevc_decoded_fmts,
331-
.capability = RKVDEC_CAPABILITY_HEVC,
332331
},
333332
{
334333
.fourcc = V4L2_PIX_FMT_H264_SLICE,
@@ -345,7 +344,6 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = {
345344
.num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_decoded_fmts),
346345
.decoded_fmts = rkvdec_h264_decoded_fmts,
347346
.subsystem_flags = VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF,
348-
.capability = RKVDEC_CAPABILITY_H264,
349347
},
350348
{
351349
.fourcc = V4L2_PIX_FMT_VP9_FRAME,
@@ -361,27 +359,38 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = {
361359
.ops = &rkvdec_vp9_fmt_ops,
362360
.num_decoded_fmts = ARRAY_SIZE(rkvdec_vp9_decoded_fmts),
363361
.decoded_fmts = rkvdec_vp9_decoded_fmts,
364-
.capability = RKVDEC_CAPABILITY_VP9,
365362
}
366363
};
367364

368-
static bool rkvdec_is_capable(struct rkvdec_ctx *ctx, unsigned int capability)
369-
{
370-
return (ctx->dev->variant->capabilities & capability) == capability;
371-
}
365+
static const struct rkvdec_coded_fmt_desc rk3288_coded_fmts[] = {
366+
{
367+
.fourcc = V4L2_PIX_FMT_HEVC_SLICE,
368+
.frmsize = {
369+
.min_width = 64,
370+
.max_width = 4096,
371+
.step_width = 64,
372+
.min_height = 64,
373+
.max_height = 2304,
374+
.step_height = 16,
375+
},
376+
.ctrls = &rkvdec_hevc_ctrls,
377+
.ops = &rkvdec_hevc_fmt_ops,
378+
.num_decoded_fmts = ARRAY_SIZE(rkvdec_hevc_decoded_fmts),
379+
.decoded_fmts = rkvdec_hevc_decoded_fmts,
380+
}
381+
};
372382

373383
static const struct rkvdec_coded_fmt_desc *
374384
rkvdec_enum_coded_fmt_desc(struct rkvdec_ctx *ctx, int index)
375385
{
386+
const struct rkvdec_variant *variant = ctx->dev->variant;
376387
int fmt_idx = -1;
377388
unsigned int i;
378389

379-
for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) {
380-
if (!rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability))
381-
continue;
390+
for (i = 0; i < variant->num_coded_fmts; i++) {
382391
fmt_idx++;
383392
if (index == fmt_idx)
384-
return &rkvdec_coded_fmts[i];
393+
return &variant->coded_fmts[i];
385394
}
386395

387396
return NULL;
@@ -390,12 +399,12 @@ rkvdec_enum_coded_fmt_desc(struct rkvdec_ctx *ctx, int index)
390399
static const struct rkvdec_coded_fmt_desc *
391400
rkvdec_find_coded_fmt_desc(struct rkvdec_ctx *ctx, u32 fourcc)
392401
{
402+
const struct rkvdec_variant *variant = ctx->dev->variant;
393403
unsigned int i;
394404

395-
for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) {
396-
if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability) &&
397-
rkvdec_coded_fmts[i].fourcc == fourcc)
398-
return &rkvdec_coded_fmts[i];
405+
for (i = 0; i < variant->num_coded_fmts; i++) {
406+
if (variant->coded_fmts[i].fourcc == fourcc)
407+
return &variant->coded_fmts[i];
399408
}
400409

401410
return NULL;
@@ -1014,21 +1023,19 @@ static int rkvdec_add_ctrls(struct rkvdec_ctx *ctx,
10141023

10151024
static int rkvdec_init_ctrls(struct rkvdec_ctx *ctx)
10161025
{
1026+
const struct rkvdec_variant *variant = ctx->dev->variant;
10171027
unsigned int i, nctrls = 0;
10181028
int ret;
10191029

1020-
for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++)
1021-
if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability))
1022-
nctrls += rkvdec_coded_fmts[i].ctrls->num_ctrls;
1030+
for (i = 0; i < variant->num_coded_fmts; i++)
1031+
nctrls += variant->coded_fmts[i].ctrls->num_ctrls;
10231032

10241033
v4l2_ctrl_handler_init(&ctx->ctrl_hdl, nctrls);
10251034

1026-
for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) {
1027-
if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability)) {
1028-
ret = rkvdec_add_ctrls(ctx, rkvdec_coded_fmts[i].ctrls);
1029-
if (ret)
1030-
goto err_free_handler;
1031-
}
1035+
for (i = 0; i < variant->num_coded_fmts; i++) {
1036+
ret = rkvdec_add_ctrls(ctx, variant->coded_fmts[i].ctrls);
1037+
if (ret)
1038+
goto err_free_handler;
10321039
}
10331040

10341041
ret = v4l2_ctrl_handler_setup(&ctx->ctrl_hdl);
@@ -1242,22 +1249,21 @@ static void rkvdec_watchdog_func(struct work_struct *work)
12421249

12431250
static const struct rkvdec_variant rk3288_rkvdec_variant = {
12441251
.num_regs = 68,
1245-
.capabilities = RKVDEC_CAPABILITY_HEVC,
1252+
.coded_fmts = rk3288_coded_fmts,
1253+
.num_coded_fmts = ARRAY_SIZE(rk3288_coded_fmts),
12461254
};
12471255

12481256
static const struct rkvdec_variant rk3328_rkvdec_variant = {
12491257
.num_regs = 109,
1250-
.capabilities = RKVDEC_CAPABILITY_HEVC |
1251-
RKVDEC_CAPABILITY_H264 |
1252-
RKVDEC_CAPABILITY_VP9,
1258+
.coded_fmts = rkvdec_coded_fmts,
1259+
.num_coded_fmts = ARRAY_SIZE(rkvdec_coded_fmts),
12531260
.quirks = RKVDEC_QUIRK_DISABLE_QOS,
12541261
};
12551262

12561263
static const struct rkvdec_variant rk3399_rkvdec_variant = {
12571264
.num_regs = 78,
1258-
.capabilities = RKVDEC_CAPABILITY_HEVC |
1259-
RKVDEC_CAPABILITY_H264 |
1260-
RKVDEC_CAPABILITY_VP9,
1265+
.coded_fmts = rkvdec_coded_fmts,
1266+
.num_coded_fmts = ARRAY_SIZE(rkvdec_coded_fmts),
12611267
};
12621268

12631269
static const struct of_device_id of_rkvdec_match[] = {

drivers/media/platform/rockchip/rkvdec/rkvdec.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
#include <media/videobuf2-core.h>
2323
#include <media/videobuf2-dma-contig.h>
2424

25-
#define RKVDEC_CAPABILITY_HEVC BIT(0)
26-
#define RKVDEC_CAPABILITY_H264 BIT(1)
27-
#define RKVDEC_CAPABILITY_VP9 BIT(2)
28-
2925
#define RKVDEC_QUIRK_DISABLE_QOS BIT(0)
3026

3127
struct rkvdec_ctx;
@@ -71,7 +67,8 @@ vb2_to_rkvdec_decoded_buf(struct vb2_buffer *buf)
7167

7268
struct rkvdec_variant {
7369
unsigned int num_regs;
74-
unsigned int capabilities;
70+
const struct rkvdec_coded_fmt_desc *coded_fmts;
71+
size_t num_coded_fmts;
7572
unsigned int quirks;
7673
};
7774

@@ -110,7 +107,6 @@ struct rkvdec_coded_fmt_desc {
110107
unsigned int num_decoded_fmts;
111108
const struct rkvdec_decoded_fmt_desc *decoded_fmts;
112109
u32 subsystem_flags;
113-
unsigned int capability;
114110
};
115111

116112
struct rkvdec_dev {

0 commit comments

Comments
 (0)