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

media: v4l2-ctrls: Add hevc_ext_sps_[ls]t_rps controls

The vdpu381 decoder found on newer Rockchip SoC need the information
from the long term and short term ref pic sets from the SPS.

So far, it wasn't included in the v4l2 API, so add it with new dynamic
sized controls.

Each element of the hevc_ext_sps_lt_rps array contains the long term ref
pic set at that index.
Each element of the hevc_ext_sps_st_rps contains the short term ref pic
set at that index, as the raw data.
It is the role of the drivers to calculate the reference sets values.

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
fa057051 8a5586d4

+101
+28
drivers/media/v4l2-core/v4l2-ctrls-core.c
··· 424 424 case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS: 425 425 pr_cont("HEVC_SLICE_PARAMS"); 426 426 break; 427 + case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS: 428 + pr_cont("HEVC_EXT_SPS_ST_RPS"); 429 + break; 430 + case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS: 431 + pr_cont("HEVC_EXT_SPS_LT_RPS"); 432 + break; 427 433 case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX: 428 434 pr_cont("HEVC_SCALING_MATRIX"); 429 435 break; ··· 967 961 struct v4l2_ctrl_h264_pred_weights *p_h264_pred_weights; 968 962 struct v4l2_ctrl_h264_slice_params *p_h264_slice_params; 969 963 struct v4l2_ctrl_h264_decode_params *p_h264_dec_params; 964 + struct v4l2_ctrl_hevc_ext_sps_lt_rps *p_hevc_lt_rps; 965 + struct v4l2_ctrl_hevc_ext_sps_st_rps *p_hevc_st_rps; 970 966 struct v4l2_ctrl_hevc_sps *p_hevc_sps; 971 967 struct v4l2_ctrl_hevc_pps *p_hevc_pps; 972 968 struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering; ··· 1260 1252 break; 1261 1253 1262 1254 case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS: 1255 + break; 1256 + 1257 + case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS: 1258 + p_hevc_st_rps = p; 1259 + 1260 + if (p_hevc_st_rps->flags & ~V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_INTER_REF_PIC_SET_PRED) 1261 + return -EINVAL; 1262 + break; 1263 + 1264 + case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS: 1265 + p_hevc_lt_rps = p; 1266 + 1267 + if (p_hevc_lt_rps->flags & ~V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_USED_LT) 1268 + return -EINVAL; 1263 1269 break; 1264 1270 1265 1271 case V4L2_CTRL_TYPE_HDR10_CLL_INFO: ··· 2027 2005 break; 2028 2006 case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS: 2029 2007 elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params); 2008 + break; 2009 + case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS: 2010 + elem_size = sizeof(struct v4l2_ctrl_hevc_ext_sps_st_rps); 2011 + break; 2012 + case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS: 2013 + elem_size = sizeof(struct v4l2_ctrl_hevc_ext_sps_lt_rps); 2030 2014 break; 2031 2015 case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX: 2032 2016 elem_size = sizeof(struct v4l2_ctrl_hevc_scaling_matrix);
+10
drivers/media/v4l2-core/v4l2-ctrls-defs.c
··· 1235 1235 case V4L2_CID_STATELESS_HEVC_DECODE_MODE: return "HEVC Decode Mode"; 1236 1236 case V4L2_CID_STATELESS_HEVC_START_CODE: return "HEVC Start Code"; 1237 1237 case V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS: return "HEVC Entry Point Offsets"; 1238 + case V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS: return "HEVC Short Term Ref Sets"; 1239 + case V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS: return "HEVC Long Term Ref Sets"; 1238 1240 case V4L2_CID_STATELESS_AV1_SEQUENCE: return "AV1 Sequence Parameters"; 1239 1241 case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY: return "AV1 Tile Group Entry"; 1240 1242 case V4L2_CID_STATELESS_AV1_FRAME: return "AV1 Frame Parameters"; ··· 1581 1579 break; 1582 1580 case V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS: 1583 1581 *type = V4L2_CTRL_TYPE_U32; 1582 + *flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY; 1583 + break; 1584 + case V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS: 1585 + *type = V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS; 1586 + *flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY; 1587 + break; 1588 + case V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS: 1589 + *type = V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS; 1584 1590 *flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY; 1585 1591 break; 1586 1592 case V4L2_CID_STATELESS_VP9_COMPRESSED_HDR:
+61
include/uapi/linux/v4l2-controls.h
··· 2101 2101 #define V4L2_CID_STATELESS_HEVC_DECODE_MODE (V4L2_CID_CODEC_STATELESS_BASE + 405) 2102 2102 #define V4L2_CID_STATELESS_HEVC_START_CODE (V4L2_CID_CODEC_STATELESS_BASE + 406) 2103 2103 #define V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS (V4L2_CID_CODEC_STATELESS_BASE + 407) 2104 + #define V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS (V4L2_CID_CODEC_STATELESS_BASE + 408) 2105 + #define V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS (V4L2_CID_CODEC_STATELESS_BASE + 409) 2104 2106 2105 2107 enum v4l2_stateless_hevc_decode_mode { 2106 2108 V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED, ··· 2556 2554 __u8 scaling_list_32x32[2][64]; 2557 2555 __u8 scaling_list_dc_coef_16x16[6]; 2558 2556 __u8 scaling_list_dc_coef_32x32[2]; 2557 + }; 2558 + 2559 + #define V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_INTER_REF_PIC_SET_PRED 0x1 2560 + 2561 + /* 2562 + * struct v4l2_ctrl_hevc_ext_sps_st_rps - HEVC short term RPS parameters 2563 + * 2564 + * Dynamic size 1-dimension array for short term RPS. The number of elements 2565 + * is v4l2_ctrl_hevc_sps::num_short_term_ref_pic_sets. It can contain up to 65 elements. 2566 + * 2567 + * @delta_idx_minus1: Specifies the delta compare to the index. See details in section 7.4.8 2568 + * "Short-term reference picture set semantics" of the specification. 2569 + * @delta_rps_sign: Sign of the delta as specified in section 7.4.8 "Short-term reference picture 2570 + * set semantics" of the specification. 2571 + * @abs_delta_rps_minus1: Absolute delta RPS as specified in section 7.4.8 "Short-term reference 2572 + * picture set semantics" of the specification. 2573 + * @num_negative_pics: Number of short-term RPS entries that have picture order count values less 2574 + * than the picture order count value of the current picture. 2575 + * @num_positive_pics: Number of short-term RPS entries that have picture order count values 2576 + * greater than the picture order count value of the current picture. 2577 + * @used_by_curr_pic: Bit j specifies if short-term RPS j is used by the current picture. 2578 + * @use_delta_flag: Bit j equals to 1 specifies that the j-th entry in the source candidate 2579 + * short-term RPS is included in this candidate short-term RPS. 2580 + * @delta_poc_s0_minus1: Specifies the negative picture order count delta for the i-th entry in 2581 + * the short-term RPS. See details in section 7.4.8 "Short-term reference 2582 + * picture set semantics" of the specification. 2583 + * @delta_poc_s1_minus1: Specifies the positive picture order count delta for the i-th entry in 2584 + * the short-term RPS. See details in section 7.4.8 "Short-term reference 2585 + * picture set semantics" of the specification. 2586 + * @flags: See V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_{} 2587 + */ 2588 + struct v4l2_ctrl_hevc_ext_sps_st_rps { 2589 + __u8 delta_idx_minus1; 2590 + __u8 delta_rps_sign; 2591 + __u8 num_negative_pics; 2592 + __u8 num_positive_pics; 2593 + __u32 used_by_curr_pic; 2594 + __u32 use_delta_flag; 2595 + __u16 abs_delta_rps_minus1; 2596 + __u16 delta_poc_s0_minus1[16]; 2597 + __u16 delta_poc_s1_minus1[16]; 2598 + __u16 flags; 2599 + }; 2600 + 2601 + #define V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_USED_LT 0x1 2602 + 2603 + /* 2604 + * struct v4l2_ctrl_hevc_ext_sps_lt_rps - HEVC long term RPS parameters 2605 + * 2606 + * Dynamic size 1-dimension array for long term RPS. The number of elements 2607 + * is v4l2_ctrl_hevc_sps::num_long_term_ref_pics_sps. It can contain up to 65 elements. 2608 + * 2609 + * @lt_ref_pic_poc_lsb_sps: picture order count modulo MaxPicOrderCntLsb of the i-th candidate 2610 + * long-term reference picture. 2611 + * @flags: See V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_{} 2612 + */ 2613 + struct v4l2_ctrl_hevc_ext_sps_lt_rps { 2614 + __u16 lt_ref_pic_poc_lsb_sps; 2615 + __u16 flags; 2559 2616 }; 2560 2617 2561 2618 /* Stateless VP9 controls */
+2
include/uapi/linux/videodev2.h
··· 1986 1986 V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS = 0x0272, 1987 1987 V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX = 0x0273, 1988 1988 V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS = 0x0274, 1989 + V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS = 0x0275, 1990 + V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS = 0x0276, 1989 1991 1990 1992 V4L2_CTRL_TYPE_AV1_SEQUENCE = 0x280, 1991 1993 V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281,