1 From 2a88d608907e78bc6506579de01fabaa18219483 Mon Sep 17 00:00:00 2001
2 From: John Cox <jc@kynesim.co.uk>
3 Date: Thu, 5 Aug 2021 15:18:50 +0100
4 Subject: [PATCH] media: rpivid: Update to compile with new hevc decode
7 DPB entries have moved from slice params to the new decode params
8 attribute - update to deal with this. Also fixes fallthrough
9 warnings which seem to be new in 5.14.
11 Signed-off-by: John Cox <jc@kynesim.co.uk>
13 drivers/staging/media/rpivid/rpivid.c | 6 ++++
14 drivers/staging/media/rpivid/rpivid.h | 1 +
15 drivers/staging/media/rpivid/rpivid_dec.c | 3 ++
16 drivers/staging/media/rpivid/rpivid_h265.c | 35 ++++++++++++----------
17 4 files changed, 30 insertions(+), 15 deletions(-)
19 --- a/drivers/staging/media/rpivid/rpivid.c
20 +++ b/drivers/staging/media/rpivid/rpivid.c
21 @@ -57,6 +57,12 @@ static const struct rpivid_control rpivi
25 + .id = V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS,
31 .id = V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS,
34 --- a/drivers/staging/media/rpivid/rpivid.h
35 +++ b/drivers/staging/media/rpivid/rpivid.h
36 @@ -52,6 +52,7 @@ struct rpivid_h265_run {
38 const struct v4l2_ctrl_hevc_sps *sps;
39 const struct v4l2_ctrl_hevc_pps *pps;
40 + const struct v4l2_ctrl_hevc_decode_params *dec;
41 const struct v4l2_ctrl_hevc_slice_params *slice_params;
42 const struct v4l2_ctrl_hevc_scaling_matrix *scaling_matrix;
44 --- a/drivers/staging/media/rpivid/rpivid_dec.c
45 +++ b/drivers/staging/media/rpivid/rpivid_dec.c
46 @@ -55,6 +55,9 @@ void rpivid_device_run(void *priv)
47 run.h265.slice_params =
48 rpivid_find_control_data(ctx,
49 V4L2_CID_MPEG_VIDEO_HEVC_SLICE_PARAMS);
51 + rpivid_find_control_data(ctx,
52 + V4L2_CID_MPEG_VIDEO_HEVC_DECODE_PARAMS);
53 run.h265.scaling_matrix =
54 rpivid_find_control_data(ctx,
55 V4L2_CID_MPEG_VIDEO_HEVC_SCALING_MATRIX);
56 --- a/drivers/staging/media/rpivid/rpivid_h265.c
57 +++ b/drivers/staging/media/rpivid/rpivid_h265.c
58 @@ -252,6 +252,7 @@ struct rpivid_dec_state {
61 const struct v4l2_ctrl_hevc_slice_params *sh;
62 + const struct v4l2_ctrl_hevc_decode_params *dec;
63 unsigned int nb_refs[2];
64 unsigned int slice_qp;
65 unsigned int max_num_merge_cand; // 0 if I-slice
66 @@ -799,6 +800,7 @@ static void pre_slice_decode(struct rpiv
67 const struct rpivid_dec_state *const s)
69 const struct v4l2_ctrl_hevc_slice_params *const sh = s->sh;
70 + const struct v4l2_ctrl_hevc_decode_params *const dec = s->dec;
71 int weighted_pred_flag, idx;
73 unsigned int collocated_from_l0_flag;
74 @@ -825,9 +827,9 @@ static void pre_slice_decode(struct rpiv
75 if (sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B) {
76 // Flag to say all reference pictures are from the past
77 const int no_backward_pred_flag =
78 - has_backward(sh->dpb, sh->ref_idx_l0, s->nb_refs[L0],
79 + has_backward(dec->dpb, sh->ref_idx_l0, s->nb_refs[L0],
80 sh->slice_pic_order_cnt) &&
81 - has_backward(sh->dpb, sh->ref_idx_l1, s->nb_refs[L1],
82 + has_backward(dec->dpb, sh->ref_idx_l1, s->nb_refs[L1],
83 sh->slice_pic_order_cnt);
84 cmd_slice |= no_backward_pred_flag << 10;
85 msg_slice(de, cmd_slice);
86 @@ -855,11 +857,11 @@ static void pre_slice_decode(struct rpiv
90 - (sh->dpb[dpb_no].rps ==
91 + (dec->dpb[dpb_no].rps ==
92 V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR ?
94 (weighted_pred_flag ? (3 << 5) : 0));
95 - msg_slice(de, sh->dpb[dpb_no].pic_order_cnt[0]);
96 + msg_slice(de, dec->dpb[dpb_no].pic_order_cnt[0]);
98 if (weighted_pred_flag) {
99 const struct v4l2_hevc_pred_weight_table
100 @@ -901,11 +903,11 @@ static void pre_slice_decode(struct rpiv
101 // "L1[%d]=dpb[%d]\n", idx, dpb_no);
104 - (sh->dpb[dpb_no].rps ==
105 + (dec->dpb[dpb_no].rps ==
106 V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR ?
108 (weighted_pred_flag ? (3 << 5) : 0));
109 - msg_slice(de, sh->dpb[dpb_no].pic_order_cnt[0]);
110 + msg_slice(de, dec->dpb[dpb_no].pic_order_cnt[0]);
111 if (weighted_pred_flag) {
112 const struct v4l2_hevc_pred_weight_table
113 *const w = &sh->pred_weight_table;
114 @@ -1670,6 +1672,8 @@ static void rpivid_h265_setup(struct rpi
115 struct rpivid_dev *const dev = ctx->dev;
116 const struct v4l2_ctrl_hevc_slice_params *const sh =
117 run->h265.slice_params;
118 + const struct v4l2_ctrl_hevc_decode_params *const dec =
120 // const struct v4l2_hevc_pred_weight_table *pred_weight_table;
121 struct rpivid_q_aux *dpb_q_aux[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
122 struct rpivid_dec_state *const s = ctx->state;
123 @@ -1895,6 +1899,7 @@ static void rpivid_h265_setup(struct rpi
125 // Pre calc a few things
128 s->slice_qp = 26 + s->pps.init_qp_minus26 + s->sh->slice_qp_delta;
129 s->max_num_merge_cand = sh->slice_type == HEVC_SLICE_I ?
131 @@ -1965,9 +1970,9 @@ static void rpivid_h265_setup(struct rpi
132 if (write_cmd_buffer(dev, de, s))
135 - for (i = 0; i < sh->num_active_dpb_entries; ++i) {
136 + for (i = 0; i < dec->num_active_dpb_entries; ++i) {
138 - vb2_find_timestamp(vq, sh->dpb[i].timestamp, 0);
139 + vb2_find_timestamp(vq, dec->dpb[i].timestamp, 0);
140 struct vb2_buffer *buf = buffer_index < 0 ?
142 vb2_get_buffer(vq, buffer_index);
143 @@ -1975,7 +1980,7 @@ static void rpivid_h265_setup(struct rpi
145 v4l2_warn(&dev->v4l2_dev,
146 "Missing DPB ent %d, timestamp=%lld, index=%d\n",
147 - i, (long long)sh->dpb[i].timestamp,
148 + i, (long long)dec->dpb[i].timestamp,
152 @@ -1985,7 +1990,7 @@ static void rpivid_h265_setup(struct rpi
154 v4l2_warn(&dev->v4l2_dev,
155 "Missing DPB AUX ent %d, timestamp=%lld, index=%d\n",
156 - i, (long long)sh->dpb[i].timestamp,
157 + i, (long long)dec->dpb[i].timestamp,
161 @@ -2017,11 +2022,11 @@ static void rpivid_h265_setup(struct rpi
164 if (de->dpbno_col != ~0U) {
165 - if (de->dpbno_col >= sh->num_active_dpb_entries) {
166 + if (de->dpbno_col >= dec->num_active_dpb_entries) {
167 v4l2_err(&dev->v4l2_dev,
168 "Col ref index %d >= %d\n",
170 - sh->num_active_dpb_entries);
171 + dec->num_active_dpb_entries);
173 // Standard requires that the col pic is
174 // constant for the duration of the pic
175 @@ -2462,7 +2467,7 @@ static void rpivid_h265_trigger(struct r
176 switch (!de ? RPIVID_DECODE_ERROR_CONTINUE : de->state) {
177 case RPIVID_DECODE_SLICE_START:
178 de->state = RPIVID_DECODE_SLICE_CONTINUE;
181 case RPIVID_DECODE_SLICE_CONTINUE:
182 v4l2_m2m_buf_done_and_job_finish(dev->m2m_dev, ctx->fh.m2m_ctx,
184 @@ -2472,11 +2477,11 @@ static void rpivid_h265_trigger(struct r
186 v4l2_err(&dev->v4l2_dev, "%s: Unexpected state: %d\n", __func__,
190 case RPIVID_DECODE_ERROR_DONE:
195 case RPIVID_DECODE_ERROR_CONTINUE:
197 v4l2_m2m_buf_done_and_job_finish(dev->m2m_dev, ctx->fh.m2m_ctx,