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: Use structs to represent the HW RPS

This is in preparation to add support for other variants of the decoder.

Moving to struct representation is mainly to prepare for multicore
support that is present in e.g. rk3588.

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
cf29115a 2b0ec900

+84 -9
+84 -9
drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c
··· 18 18 19 19 /* Size with u32 units. */ 20 20 #define RKV_CABAC_INIT_BUFFER_SIZE (3680 + 128) 21 - #define RKV_RPS_SIZE ((128 + 128) / 4) 22 21 #define RKV_ERROR_INFO_SIZE (256 * 144 * 4) 23 22 24 23 #define RKVDEC_NUM_REFLIST 3 ··· 31 32 struct rkvdec_sps_pps_packet { 32 33 u32 info[8]; 33 34 }; 35 + 36 + struct rkvdec_rps_entry { 37 + u32 dpb_info0: 5; 38 + u32 bottom_flag0: 1; 39 + u32 view_index_off0: 1; 40 + u32 dpb_info1: 5; 41 + u32 bottom_flag1: 1; 42 + u32 view_index_off1: 1; 43 + u32 dpb_info2: 5; 44 + u32 bottom_flag2: 1; 45 + u32 view_index_off2: 1; 46 + u32 dpb_info3: 5; 47 + u32 bottom_flag3: 1; 48 + u32 view_index_off3: 1; 49 + u32 dpb_info4: 5; 50 + u32 bottom_flag4: 1; 51 + u32 view_index_off4: 1; 52 + u32 dpb_info5: 5; 53 + u32 bottom_flag5: 1; 54 + u32 view_index_off5: 1; 55 + u32 dpb_info6: 5; 56 + u32 bottom_flag6: 1; 57 + u32 view_index_off6: 1; 58 + u32 dpb_info7: 5; 59 + u32 bottom_flag7: 1; 60 + u32 view_index_off7: 1; 61 + } __packed; 62 + 63 + struct rkvdec_rps { 64 + u16 frame_num[16]; 65 + u32 reserved0; 66 + struct rkvdec_rps_entry entries[12]; 67 + u32 reserved1[66]; 68 + } __packed; 34 69 35 70 struct rkvdec_ps_field { 36 71 u16 offset; ··· 126 93 struct rkvdec_h264_priv_tbl { 127 94 s8 cabac_table[4][464][2]; 128 95 struct rkvdec_h264_scaling_list scaling_list; 129 - u32 rps[RKV_RPS_SIZE]; 96 + struct rkvdec_rps rps; 130 97 struct rkvdec_sps_pps_packet param_set[256]; 131 98 u8 err_info[RKV_ERROR_INFO_SIZE]; 132 99 }; ··· 292 259 } 293 260 } 294 261 262 + static void set_dpb_info(struct rkvdec_rps_entry *entries, 263 + u8 reflist, 264 + u8 refnum, 265 + u8 info, 266 + bool bottom) 267 + { 268 + struct rkvdec_rps_entry *entry = &entries[(reflist * 4) + refnum / 8]; 269 + u8 idx = refnum % 8; 270 + 271 + switch (idx) { 272 + case 0: 273 + entry->dpb_info0 = info; 274 + entry->bottom_flag0 = bottom; 275 + break; 276 + case 1: 277 + entry->dpb_info1 = info; 278 + entry->bottom_flag1 = bottom; 279 + break; 280 + case 2: 281 + entry->dpb_info2 = info; 282 + entry->bottom_flag2 = bottom; 283 + break; 284 + case 3: 285 + entry->dpb_info3 = info; 286 + entry->bottom_flag3 = bottom; 287 + break; 288 + case 4: 289 + entry->dpb_info4 = info; 290 + entry->bottom_flag4 = bottom; 291 + break; 292 + case 5: 293 + entry->dpb_info5 = info; 294 + entry->bottom_flag5 = bottom; 295 + break; 296 + case 6: 297 + entry->dpb_info6 = info; 298 + entry->bottom_flag6 = bottom; 299 + break; 300 + case 7: 301 + entry->dpb_info7 = info; 302 + entry->bottom_flag7 = bottom; 303 + break; 304 + } 305 + } 306 + 295 307 static void assemble_hw_rps(struct rkvdec_ctx *ctx, 296 308 struct v4l2_h264_reflist_builder *builder, 297 309 struct rkvdec_h264_run *run) ··· 346 268 struct rkvdec_h264_ctx *h264_ctx = ctx->priv; 347 269 struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu; 348 270 349 - u32 *hw_rps = priv_tbl->rps; 271 + struct rkvdec_rps *hw_rps = &priv_tbl->rps; 350 272 u32 i, j; 351 - u16 *p = (u16 *)hw_rps; 352 273 353 - memset(hw_rps, 0, sizeof(priv_tbl->rps)); 274 + memset(hw_rps, 0, sizeof(*hw_rps)); 354 275 355 276 /* 356 277 * Assign an invalid pic_num if DPB entry at that position is inactive. ··· 361 284 if (!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) 362 285 continue; 363 286 364 - p[i] = builder->refs[i].frame_num; 287 + hw_rps->frame_num[i] = builder->refs[i].frame_num; 365 288 } 366 289 367 290 for (j = 0; j < RKVDEC_NUM_REFLIST; j++) { ··· 388 311 dpb_valid = run->ref_buf[ref->index] != NULL; 389 312 bottom = ref->fields == V4L2_H264_BOTTOM_FIELD_REF; 390 313 391 - set_ps_field(hw_rps, DPB_INFO(i, j), 392 - ref->index | dpb_valid << 4); 393 - set_ps_field(hw_rps, BOTTOM_FLAG(i, j), bottom); 314 + set_dpb_info(hw_rps->entries, j, i, ref->index | (dpb_valid << 4), bottom); 394 315 } 395 316 } 396 317 }