@@ -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
373383static const struct rkvdec_coded_fmt_desc *
374384rkvdec_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)
390399static const struct rkvdec_coded_fmt_desc *
391400rkvdec_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
10151024static 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
12431250static 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
12481256static 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
12561263static 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
12631269static const struct of_device_id of_rkvdec_match [] = {
0 commit comments