Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Detlev Casanova and committed by
Hans Verkuil
ae2070ca 34e2b14a

+39 -37
+37 -31
drivers/media/platform/rockchip/rkvdec/rkvdec.c
··· 328 328 .ops = &rkvdec_hevc_fmt_ops, 329 329 .num_decoded_fmts = ARRAY_SIZE(rkvdec_hevc_decoded_fmts), 330 330 .decoded_fmts = rkvdec_hevc_decoded_fmts, 331 - .capability = RKVDEC_CAPABILITY_HEVC, 332 331 }, 333 332 { 334 333 .fourcc = V4L2_PIX_FMT_H264_SLICE, ··· 344 345 .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_decoded_fmts), 345 346 .decoded_fmts = rkvdec_h264_decoded_fmts, 346 347 .subsystem_flags = VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF, 347 - .capability = RKVDEC_CAPABILITY_H264, 348 348 }, 349 349 { 350 350 .fourcc = V4L2_PIX_FMT_VP9_FRAME, ··· 359 361 .ops = &rkvdec_vp9_fmt_ops, 360 362 .num_decoded_fmts = ARRAY_SIZE(rkvdec_vp9_decoded_fmts), 361 363 .decoded_fmts = rkvdec_vp9_decoded_fmts, 362 - .capability = RKVDEC_CAPABILITY_VP9, 363 364 } 364 365 }; 365 366 366 - static bool rkvdec_is_capable(struct rkvdec_ctx *ctx, unsigned int capability) 367 - { 368 - return (ctx->dev->variant->capabilities & capability) == capability; 369 - } 367 + static const struct rkvdec_coded_fmt_desc rk3288_coded_fmts[] = { 368 + { 369 + .fourcc = V4L2_PIX_FMT_HEVC_SLICE, 370 + .frmsize = { 371 + .min_width = 64, 372 + .max_width = 4096, 373 + .step_width = 64, 374 + .min_height = 64, 375 + .max_height = 2304, 376 + .step_height = 16, 377 + }, 378 + .ctrls = &rkvdec_hevc_ctrls, 379 + .ops = &rkvdec_hevc_fmt_ops, 380 + .num_decoded_fmts = ARRAY_SIZE(rkvdec_hevc_decoded_fmts), 381 + .decoded_fmts = rkvdec_hevc_decoded_fmts, 382 + } 383 + }; 370 384 371 385 static const struct rkvdec_coded_fmt_desc * 372 386 rkvdec_enum_coded_fmt_desc(struct rkvdec_ctx *ctx, int index) 373 387 { 388 + const struct rkvdec_variant *variant = ctx->dev->variant; 374 389 int fmt_idx = -1; 375 390 unsigned int i; 376 391 377 - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) { 378 - if (!rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability)) 379 - continue; 392 + for (i = 0; i < variant->num_coded_fmts; i++) { 380 393 fmt_idx++; 381 394 if (index == fmt_idx) 382 - return &rkvdec_coded_fmts[i]; 395 + return &variant->coded_fmts[i]; 383 396 } 384 397 385 398 return NULL; ··· 399 390 static const struct rkvdec_coded_fmt_desc * 400 391 rkvdec_find_coded_fmt_desc(struct rkvdec_ctx *ctx, u32 fourcc) 401 392 { 393 + const struct rkvdec_variant *variant = ctx->dev->variant; 402 394 unsigned int i; 403 395 404 - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) { 405 - if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability) && 406 - rkvdec_coded_fmts[i].fourcc == fourcc) 407 - return &rkvdec_coded_fmts[i]; 396 + for (i = 0; i < variant->num_coded_fmts; i++) { 397 + if (variant->coded_fmts[i].fourcc == fourcc) 398 + return &variant->coded_fmts[i]; 408 399 } 409 400 410 401 return NULL; ··· 1023 1014 1024 1015 static int rkvdec_init_ctrls(struct rkvdec_ctx *ctx) 1025 1016 { 1017 + const struct rkvdec_variant *variant = ctx->dev->variant; 1026 1018 unsigned int i, nctrls = 0; 1027 1019 int ret; 1028 1020 1029 - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) 1030 - if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability)) 1031 - nctrls += rkvdec_coded_fmts[i].ctrls->num_ctrls; 1021 + for (i = 0; i < variant->num_coded_fmts; i++) 1022 + nctrls += variant->coded_fmts[i].ctrls->num_ctrls; 1032 1023 1033 1024 v4l2_ctrl_handler_init(&ctx->ctrl_hdl, nctrls); 1034 1025 1035 - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) { 1036 - if (rkvdec_is_capable(ctx, rkvdec_coded_fmts[i].capability)) { 1037 - ret = rkvdec_add_ctrls(ctx, rkvdec_coded_fmts[i].ctrls); 1038 - if (ret) 1039 - goto err_free_handler; 1040 - } 1026 + for (i = 0; i < variant->num_coded_fmts; i++) { 1027 + ret = rkvdec_add_ctrls(ctx, variant->coded_fmts[i].ctrls); 1028 + if (ret) 1029 + goto err_free_handler; 1041 1030 } 1042 1031 1043 1032 ret = v4l2_ctrl_handler_setup(&ctx->ctrl_hdl); ··· 1249 1242 1250 1243 static const struct rkvdec_variant rk3288_rkvdec_variant = { 1251 1244 .num_regs = 68, 1252 - .capabilities = RKVDEC_CAPABILITY_HEVC, 1245 + .coded_fmts = rk3288_coded_fmts, 1246 + .num_coded_fmts = ARRAY_SIZE(rk3288_coded_fmts), 1253 1247 }; 1254 1248 1255 1249 static const struct rkvdec_variant rk3328_rkvdec_variant = { 1256 1250 .num_regs = 109, 1257 - .capabilities = RKVDEC_CAPABILITY_HEVC | 1258 - RKVDEC_CAPABILITY_H264 | 1259 - RKVDEC_CAPABILITY_VP9, 1251 + .coded_fmts = rkvdec_coded_fmts, 1252 + .num_coded_fmts = ARRAY_SIZE(rkvdec_coded_fmts), 1260 1253 .quirks = RKVDEC_QUIRK_DISABLE_QOS, 1261 1254 }; 1262 1255 1263 1256 static const struct rkvdec_variant rk3399_rkvdec_variant = { 1264 1257 .num_regs = 78, 1265 - .capabilities = RKVDEC_CAPABILITY_HEVC | 1266 - RKVDEC_CAPABILITY_H264 | 1267 - RKVDEC_CAPABILITY_VP9, 1258 + .coded_fmts = rkvdec_coded_fmts, 1259 + .num_coded_fmts = ARRAY_SIZE(rkvdec_coded_fmts), 1268 1260 }; 1269 1261 1270 1262 static const struct of_device_id of_rkvdec_match[] = {
+2 -6
drivers/media/platform/rockchip/rkvdec/rkvdec.h
··· 22 22 #include <media/videobuf2-core.h> 23 23 #include <media/videobuf2-dma-contig.h> 24 24 25 - #define RKVDEC_CAPABILITY_HEVC BIT(0) 26 - #define RKVDEC_CAPABILITY_H264 BIT(1) 27 - #define RKVDEC_CAPABILITY_VP9 BIT(2) 28 - 29 25 #define RKVDEC_QUIRK_DISABLE_QOS BIT(0) 30 26 31 27 struct rkvdec_ctx; ··· 67 71 68 72 struct rkvdec_variant { 69 73 unsigned int num_regs; 70 - unsigned int capabilities; 74 + const struct rkvdec_coded_fmt_desc *coded_fmts; 75 + size_t num_coded_fmts; 71 76 unsigned int quirks; 72 77 }; 73 78 ··· 107 110 unsigned int num_decoded_fmts; 108 111 const struct rkvdec_decoded_fmt_desc *decoded_fmts; 109 112 u32 subsystem_flags; 110 - unsigned int capability; 111 113 }; 112 114 113 115 struct rkvdec_dev {