Skip to content

Commit fa05705

Browse files
cazouHans Verkuil
authored andcommitted
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>
1 parent 8a5586d commit fa05705

4 files changed

Lines changed: 101 additions & 0 deletions

File tree

drivers/media/v4l2-core/v4l2-ctrls-core.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ void v4l2_ctrl_type_op_log(const struct v4l2_ctrl *ctrl)
424424
case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
425425
pr_cont("HEVC_SLICE_PARAMS");
426426
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;
427433
case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
428434
pr_cont("HEVC_SCALING_MATRIX");
429435
break;
@@ -961,6 +967,8 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
961967
struct v4l2_ctrl_h264_pred_weights *p_h264_pred_weights;
962968
struct v4l2_ctrl_h264_slice_params *p_h264_slice_params;
963969
struct v4l2_ctrl_h264_decode_params *p_h264_dec_params;
970+
struct v4l2_ctrl_hevc_ext_sps_lt_rps *p_hevc_lt_rps;
971+
struct v4l2_ctrl_hevc_ext_sps_st_rps *p_hevc_st_rps;
964972
struct v4l2_ctrl_hevc_sps *p_hevc_sps;
965973
struct v4l2_ctrl_hevc_pps *p_hevc_pps;
966974
struct v4l2_ctrl_hdr10_mastering_display *p_hdr10_mastering;
@@ -1254,6 +1262,20 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
12541262
case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
12551263
break;
12561264

1265+
case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS:
1266+
p_hevc_st_rps = p;
1267+
1268+
if (p_hevc_st_rps->flags & ~V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_INTER_REF_PIC_SET_PRED)
1269+
return -EINVAL;
1270+
break;
1271+
1272+
case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS:
1273+
p_hevc_lt_rps = p;
1274+
1275+
if (p_hevc_lt_rps->flags & ~V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_USED_LT)
1276+
return -EINVAL;
1277+
break;
1278+
12571279
case V4L2_CTRL_TYPE_HDR10_CLL_INFO:
12581280
break;
12591281

@@ -2006,6 +2028,12 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
20062028
case V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:
20072029
elem_size = sizeof(struct v4l2_ctrl_hevc_slice_params);
20082030
break;
2031+
case V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS:
2032+
elem_size = sizeof(struct v4l2_ctrl_hevc_ext_sps_st_rps);
2033+
break;
2034+
case V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS:
2035+
elem_size = sizeof(struct v4l2_ctrl_hevc_ext_sps_lt_rps);
2036+
break;
20092037
case V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:
20102038
elem_size = sizeof(struct v4l2_ctrl_hevc_scaling_matrix);
20112039
break;

drivers/media/v4l2-core/v4l2-ctrls-defs.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,8 @@ const char *v4l2_ctrl_get_name(u32 id)
12351235
case V4L2_CID_STATELESS_HEVC_DECODE_MODE: return "HEVC Decode Mode";
12361236
case V4L2_CID_STATELESS_HEVC_START_CODE: return "HEVC Start Code";
12371237
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";
12381240
case V4L2_CID_STATELESS_AV1_SEQUENCE: return "AV1 Sequence Parameters";
12391241
case V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY: return "AV1 Tile Group Entry";
12401242
case V4L2_CID_STATELESS_AV1_FRAME: return "AV1 Frame Parameters";
@@ -1581,6 +1583,14 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
15811583
*type = V4L2_CTRL_TYPE_U32;
15821584
*flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY;
15831585
break;
1586+
case V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS:
1587+
*type = V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS;
1588+
*flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY;
1589+
break;
1590+
case V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS:
1591+
*type = V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS;
1592+
*flags |= V4L2_CTRL_FLAG_DYNAMIC_ARRAY;
1593+
break;
15841594
case V4L2_CID_STATELESS_VP9_COMPRESSED_HDR:
15851595
*type = V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR;
15861596
break;

include/uapi/linux/v4l2-controls.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,8 @@ struct v4l2_ctrl_mpeg2_quantisation {
21012101
#define V4L2_CID_STATELESS_HEVC_DECODE_MODE (V4L2_CID_CODEC_STATELESS_BASE + 405)
21022102
#define V4L2_CID_STATELESS_HEVC_START_CODE (V4L2_CID_CODEC_STATELESS_BASE + 406)
21032103
#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)
21042106

21052107
enum v4l2_stateless_hevc_decode_mode {
21062108
V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED,
@@ -2556,6 +2558,65 @@ struct v4l2_ctrl_hevc_scaling_matrix {
25562558
__u8 scaling_list_dc_coef_32x32[2];
25572559
};
25582560

2561+
#define V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_INTER_REF_PIC_SET_PRED 0x1
2562+
2563+
/*
2564+
* struct v4l2_ctrl_hevc_ext_sps_st_rps - HEVC short term RPS parameters
2565+
*
2566+
* Dynamic size 1-dimension array for short term RPS. The number of elements
2567+
* is v4l2_ctrl_hevc_sps::num_short_term_ref_pic_sets. It can contain up to 65 elements.
2568+
*
2569+
* @delta_idx_minus1: Specifies the delta compare to the index. See details in section 7.4.8
2570+
* "Short-term reference picture set semantics" of the specification.
2571+
* @delta_rps_sign: Sign of the delta as specified in section 7.4.8 "Short-term reference picture
2572+
* set semantics" of the specification.
2573+
* @abs_delta_rps_minus1: Absolute delta RPS as specified in section 7.4.8 "Short-term reference
2574+
* picture set semantics" of the specification.
2575+
* @num_negative_pics: Number of short-term RPS entries that have picture order count values less
2576+
* than the picture order count value of the current picture.
2577+
* @num_positive_pics: Number of short-term RPS entries that have picture order count values
2578+
* greater than the picture order count value of the current picture.
2579+
* @used_by_curr_pic: Bit j specifies if short-term RPS j is used by the current picture.
2580+
* @use_delta_flag: Bit j equals to 1 specifies that the j-th entry in the source candidate
2581+
* short-term RPS is included in this candidate short-term RPS.
2582+
* @delta_poc_s0_minus1: Specifies the negative picture order count delta for the i-th entry in
2583+
* the short-term RPS. See details in section 7.4.8 "Short-term reference
2584+
* picture set semantics" of the specification.
2585+
* @delta_poc_s1_minus1: Specifies the positive picture order count delta for the i-th entry in
2586+
* the short-term RPS. See details in section 7.4.8 "Short-term reference
2587+
* picture set semantics" of the specification.
2588+
* @flags: See V4L2_HEVC_EXT_SPS_ST_RPS_FLAG_{}
2589+
*/
2590+
struct v4l2_ctrl_hevc_ext_sps_st_rps {
2591+
__u8 delta_idx_minus1;
2592+
__u8 delta_rps_sign;
2593+
__u8 num_negative_pics;
2594+
__u8 num_positive_pics;
2595+
__u32 used_by_curr_pic;
2596+
__u32 use_delta_flag;
2597+
__u16 abs_delta_rps_minus1;
2598+
__u16 delta_poc_s0_minus1[16];
2599+
__u16 delta_poc_s1_minus1[16];
2600+
__u16 flags;
2601+
};
2602+
2603+
#define V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_USED_LT 0x1
2604+
2605+
/*
2606+
* struct v4l2_ctrl_hevc_ext_sps_lt_rps - HEVC long term RPS parameters
2607+
*
2608+
* Dynamic size 1-dimension array for long term RPS. The number of elements
2609+
* is v4l2_ctrl_hevc_sps::num_long_term_ref_pics_sps. It can contain up to 65 elements.
2610+
*
2611+
* @lt_ref_pic_poc_lsb_sps: picture order count modulo MaxPicOrderCntLsb of the i-th candidate
2612+
* long-term reference picture.
2613+
* @flags: See V4L2_HEVC_EXT_SPS_LT_RPS_FLAG_{}
2614+
*/
2615+
struct v4l2_ctrl_hevc_ext_sps_lt_rps {
2616+
__u16 lt_ref_pic_poc_lsb_sps;
2617+
__u16 flags;
2618+
};
2619+
25592620
/* Stateless VP9 controls */
25602621

25612622
#define V4L2_VP9_LOOP_FILTER_FLAG_DELTA_ENABLED 0x1

include/uapi/linux/videodev2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,8 @@ enum v4l2_ctrl_type {
19861986
V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS = 0x0272,
19871987
V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX = 0x0273,
19881988
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,
19891991

19901992
V4L2_CTRL_TYPE_AV1_SEQUENCE = 0x280,
19911993
V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY = 0x281,

0 commit comments

Comments
 (0)