1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Rockchip VDPU381 Video Decoder driver registers description 4 * 5 * Copyright (C) 2024 Collabora, Ltd. 6 * Detlev Casanova <detlev.casanova@collabora.com> 7 */ 8 9 #include <linux/types.h> 10 11 #ifndef _RKVDEC_REGS_H_ 12 #define _RKVDEC_REGS_H_ 13 14 #define OFFSET_COMMON_REGS (8 * sizeof(u32)) 15 #define OFFSET_CODEC_PARAMS_REGS (64 * sizeof(u32)) 16 #define OFFSET_COMMON_ADDR_REGS (128 * sizeof(u32)) 17 #define OFFSET_CODEC_ADDR_REGS (160 * sizeof(u32)) 18 #define OFFSET_POC_HIGHBIT_REGS (200 * sizeof(u32)) 19 20 #define VDPU381_MODE_HEVC 0 21 #define VDPU381_MODE_H264 1 22 #define VDPU381_MODE_VP9 2 23 #define VDPU381_MODE_AVS2 3 24 25 #define MAX_SLICE_NUMBER 0x3fff 26 27 #define RKVDEC_TIMEOUT_1080p (0xefffff) 28 #define RKVDEC_TIMEOUT_4K (0x2cfffff) 29 #define RKVDEC_TIMEOUT_8K (0x4ffffff) 30 #define RKVDEC_TIMEOUT_MAX (0xffffffff) 31 32 #define VDPU381_REG_DEC_E 0x028 33 #define VDPU381_DEC_E_BIT 1 34 35 #define VDPU381_REG_IMPORTANT_EN 0x02c 36 #define VDPU381_DEC_IRQ_DISABLE BIT(4) 37 38 #define VDPU381_REG_STA_INT 0x380 39 #define VDPU381_STA_INT_DEC_RDY_STA BIT(2) 40 #define VDPU381_STA_INT_ERROR BIT(4) 41 #define VDPU381_STA_INT_TIMEOUT BIT(5) 42 #define VDPU381_STA_INT_SOFTRESET_RDY BIT(9) 43 44 /* base: OFFSET_COMMON_REGS */ 45 struct rkvdec_vdpu381_regs_common { 46 struct { 47 u32 in_endian : 1; 48 u32 in_swap32_e : 1; 49 u32 in_swap64_e : 1; 50 u32 str_endian : 1; 51 u32 str_swap32_e : 1; 52 u32 str_swap64_e : 1; 53 u32 out_endian : 1; 54 u32 out_swap32_e : 1; 55 u32 out_cbcr_swap : 1; 56 u32 out_swap64_e : 1; 57 u32 reserved : 22; 58 } reg008_in_out; 59 60 struct { 61 u32 dec_mode : 10; 62 u32 reserved : 22; 63 } reg009_dec_mode; 64 65 struct { 66 u32 dec_e : 1; 67 u32 reserved : 31; 68 } reg010_dec_e; 69 70 struct { 71 u32 reserved0 : 1; 72 u32 dec_clkgate_e : 1; 73 u32 dec_e_strmd_clkgate_dis : 1; 74 u32 reserved1 : 1; 75 76 u32 dec_irq_dis : 1; 77 u32 dec_timeout_e : 1; 78 u32 buf_empty_en : 1; 79 u32 reserved2 : 3; 80 81 u32 dec_e_rewrite_valid : 1; 82 u32 reserved3 : 9; 83 u32 softrst_en_p : 1; 84 u32 force_softreset_valid : 1; 85 u32 reserved4 : 2; 86 u32 pix_range_det_e : 1; 87 u32 reserved5 : 7; 88 } reg011_important_en; 89 90 struct { 91 u32 reserved0 : 1; 92 u32 colmv_compress_en : 1; 93 u32 fbc_e : 1; 94 u32 reserved1 : 1; 95 96 u32 buspr_slot_disable : 1; 97 u32 error_info_en : 1; 98 u32 collect_info_en : 1; 99 u32 error_auto_rst_disable : 1; 100 101 u32 scanlist_addr_valid_en : 1; 102 u32 scale_down_en : 1; 103 u32 error_cfg_wr_disable : 1; 104 u32 reserved2 : 21; 105 } reg012_secondary_en; 106 107 struct { 108 u32 reserved0 : 1; 109 u32 req_timeout_rst_sel : 1; 110 u32 reserved1 : 1; 111 u32 dec_commonirq_mode : 1; 112 u32 reserved2 : 2; 113 u32 stmerror_waitdecfifo_empty : 1; 114 u32 reserved3 : 5; 115 u32 allow_not_wr_unref_bframe : 1; 116 u32 fbc_output_wr_disable : 1; 117 u32 reserved4 : 4; 118 u32 error_mode : 1; 119 u32 reserved5 : 2; 120 u32 ycacherd_prior : 1; 121 u32 reserved6 : 2; 122 u32 cur_pic_is_idr : 1; 123 u32 reserved7 : 1; 124 u32 right_auto_rst_disable : 1; 125 u32 frame_end_err_rst_flag : 1; 126 u32 rd_prior_mode : 1; 127 u32 rd_ctrl_prior_mode : 1; 128 u32 reserved8 : 1; 129 u32 filter_outbuf_mode : 1; 130 } reg013_en_mode_set; 131 132 struct { 133 u32 fbc_force_uncompress : 1; 134 135 u32 reserved0 : 2; 136 u32 allow_16x8_cp_flag : 1; 137 u32 reserved1 : 2; 138 139 u32 fbc_h264_exten_4or8_flag : 1; 140 u32 reserved2 : 25; 141 } reg014_fbc_param_set; 142 143 struct { 144 u32 rlc_mode_direct_write : 1; 145 u32 rlc_mode : 1; 146 u32 reserved0 : 3; 147 148 u32 strm_start_bit : 7; 149 u32 reserved1 : 20; 150 } reg015_stream_param_set; 151 152 u32 reg016_stream_len; 153 154 struct { 155 u32 slice_num : 25; 156 u32 reserved : 7; 157 } reg017_slice_number; 158 159 struct { 160 u32 y_hor_virstride : 16; 161 u32 reserved : 16; 162 } reg018_y_hor_stride; 163 164 struct { 165 u32 uv_hor_virstride : 16; 166 u32 reserved : 16; 167 } reg019_uv_hor_stride; 168 169 struct { 170 u32 y_virstride : 28; 171 u32 reserved : 4; 172 } reg020_y_stride; 173 174 struct { 175 u32 inter_error_prc_mode : 1; 176 u32 error_intra_mode : 1; 177 u32 error_deb_en : 1; 178 u32 picidx_replace : 5; 179 u32 error_spread_e : 1; 180 u32 reserved0 : 3; 181 u32 error_inter_pred_cross_slice : 1; 182 u32 reserved1 : 11; 183 u32 roi_error_ctu_cal_en : 1; 184 u32 reserved2 : 7; 185 } reg021_error_ctrl_set; 186 187 struct { 188 u32 roi_x_ctu_offset_st : 12; 189 u32 reserved0 : 4; 190 u32 roi_y_ctu_offset_st : 12; 191 u32 reserved1 : 4; 192 } reg022_err_roi_ctu_offset_start; 193 194 struct { 195 u32 roi_x_ctu_offset_end : 12; 196 u32 reserved0 : 4; 197 u32 roi_y_ctu_offset_end : 12; 198 u32 reserved1 : 4; 199 } reg023_err_roi_ctu_offset_end; 200 201 struct { 202 u32 cabac_err_en_lowbits : 32; 203 } reg024_cabac_error_en_lowbits; 204 205 struct { 206 u32 cabac_err_en_highbits : 30; 207 u32 reserved : 2; 208 } reg025_cabac_error_en_highbits; 209 210 struct { 211 u32 inter_auto_gating_e : 1; 212 u32 filterd_auto_gating_e : 1; 213 u32 strmd_auto_gating_e : 1; 214 u32 mcp_auto_gating_e : 1; 215 u32 busifd_auto_gating_e : 1; 216 u32 reserved0 : 3; 217 u32 dec_ctrl_auto_gating_e : 1; 218 u32 intra_auto_gating_e : 1; 219 u32 mc_auto_gating_e : 1; 220 u32 transd_auto_gating_e : 1; 221 u32 reserved1 : 4; 222 u32 sram_auto_gating_e : 1; 223 u32 cru_auto_gating_e : 1; 224 u32 reserved2 : 13; 225 u32 reg_cfg_gating_en : 1; 226 } reg026_block_gating_en; 227 228 struct { 229 u32 core_safe_x_pixels : 16; 230 u32 core_safe_y_pixels : 16; 231 } reg027_core_safe_pixels; 232 233 struct { 234 u32 vp9_wr_prob_idx : 3; 235 u32 reserved0 : 1; 236 u32 vp9_rd_prob_idx : 3; 237 u32 reserved1 : 1; 238 239 u32 ref_req_advance_flag : 1; 240 u32 colmv_req_advance_flag : 1; 241 u32 poc_only_highbit_flag : 1; 242 u32 poc_arb_flag : 1; 243 244 u32 reserved2 : 4; 245 u32 film_idx : 10; 246 u32 reserved3 : 2; 247 u32 pu_req_mismatch_dis : 1; 248 u32 colmv_req_mismatch_dis : 1; 249 u32 reserved4 : 2; 250 } reg028_multiply_core_ctrl; 251 252 struct { 253 u32 scale_down_hor_ratio : 2; 254 u32 reserved0 : 6; 255 u32 scale_down_vrz_ratio : 2; 256 u32 reserved1 : 22; 257 } reg029_scale_down_ctrl; 258 259 struct { 260 u32 y_scale_down_tile8x8_hor_stride : 20; 261 u32 reserved0 : 12; 262 } reg030_y_scale_down_tile8x8_hor_stride; 263 264 struct { 265 u32 uv_scale_down8x8_tile_hor_stride : 20; 266 u32 reserved0 : 12; 267 } reg031_uv_scale_down_tile8x8_hor_stride; 268 269 u32 reg032_timeout_threshold; 270 } __packed; 271 272 /* base: OFFSET_COMMON_ADDR_REGS */ 273 struct rkvdec_vdpu381_regs_common_addr { 274 u32 rlc_base; 275 u32 rlcwrite_base; 276 u32 decout_base; 277 u32 colmv_cur_base; 278 u32 error_ref_base; 279 u32 rcb_base[10]; 280 } __packed; 281 282 struct rkvdec_vdpu381_h26x_set { 283 u32 h26x_frame_orslice : 1; 284 u32 h26x_rps_mode : 1; 285 u32 h26x_stream_mode : 1; 286 u32 h26x_stream_lastpacket : 1; 287 u32 h264_firstslice_flag : 1; 288 u32 reserved : 27; 289 } __packed; 290 291 /* base: OFFSET_CODEC_PARAMS_REGS */ 292 struct rkvdec_vdpu381_regs_h264_params { 293 struct rkvdec_vdpu381_h26x_set reg064_h26x_set; 294 295 u32 reg065_cur_top_poc; 296 u32 reg066_cur_bot_poc; 297 u32 reg067_098_ref_poc[32]; 298 299 struct rkvdec_vdpu381_h264_info { 300 struct rkvdec_vdpu381_h264_ref_info { 301 u32 ref_field : 1; 302 u32 ref_topfield_used : 1; 303 u32 ref_botfield_used : 1; 304 u32 ref_colmv_use_flag : 1; 305 u32 reserved : 4; 306 } __packed ref_info[4]; 307 } __packed reg099_102_ref_info_regs[4]; 308 309 u32 reserved_103_111[9]; 310 311 struct { 312 u32 avs2_ref_error_field : 1; 313 u32 avs2_ref_error_topfield : 1; 314 u32 ref_error_topfield_used : 1; 315 u32 ref_error_botfield_used : 1; 316 u32 reserved : 28; 317 } reg112_error_ref_info; 318 } __packed; 319 320 struct rkvdec_vdpu381_regs_hevc_params { 321 struct rkvdec_vdpu381_h26x_set reg064_h26x_set; 322 323 u32 reg065_cur_top_poc; 324 u32 reg066_cur_bot_poc; 325 u32 reg067_082_ref_poc[16]; 326 327 u32 reserved_083_098[16]; 328 329 struct { 330 u32 hevc_ref_valid_0 : 1; 331 u32 hevc_ref_valid_1 : 1; 332 u32 hevc_ref_valid_2 : 1; 333 u32 hevc_ref_valid_3 : 1; 334 u32 reserve0 : 4; 335 u32 hevc_ref_valid_4 : 1; 336 u32 hevc_ref_valid_5 : 1; 337 u32 hevc_ref_valid_6 : 1; 338 u32 hevc_ref_valid_7 : 1; 339 u32 reserve1 : 4; 340 u32 hevc_ref_valid_8 : 1; 341 u32 hevc_ref_valid_9 : 1; 342 u32 hevc_ref_valid_10 : 1; 343 u32 hevc_ref_valid_11 : 1; 344 u32 reserve2 : 4; 345 u32 hevc_ref_valid_12 : 1; 346 u32 hevc_ref_valid_13 : 1; 347 u32 hevc_ref_valid_14 : 1; 348 u32 reserve3 : 5; 349 } reg099_hevc_ref_valid; 350 351 u32 reserved_100_102[3]; 352 353 struct { 354 u32 ref_pic_layer_same_with_cur : 16; 355 u32 reserve : 16; 356 } reg103_hevc_mvc0; 357 358 struct { 359 u32 poc_lsb_not_present_flag : 1; 360 u32 num_direct_ref_layers : 6; 361 u32 reserve0 : 1; 362 363 u32 num_reflayer_pics : 6; 364 u32 default_ref_layers_active_flag : 1; 365 u32 max_one_active_ref_layer_flag : 1; 366 367 u32 poc_reset_info_present_flag : 1; 368 u32 vps_poc_lsb_aligned_flag : 1; 369 u32 mvc_poc15_valid_flag : 1; 370 u32 reserve1 : 13; 371 } reg104_hevc_mvc1; 372 373 u32 reserved_105_111[7]; 374 375 struct { 376 u32 avs2_ref_error_field : 1; 377 u32 avs2_ref_error_topfield : 1; 378 u32 ref_error_topfield_used : 1; 379 u32 ref_error_botfield_used : 1; 380 u32 reserve : 28; 381 } reg112_hevc_ref_info; 382 383 } __packed; 384 385 /* base: OFFSET_CODEC_ADDR_REGS */ 386 struct rkvdec_vdpu381_regs_h26x_addr { 387 u32 reserved_160; 388 u32 reg161_pps_base; 389 u32 reserved_162; 390 u32 reg163_rps_base; 391 u32 reg164_180_ref_base[16]; 392 u32 reg181_scanlist_addr; 393 u32 reg182_198_colmv_base[16]; 394 u32 reg199_cabactbl_base; 395 } __packed; 396 397 struct rkvdec_vdpu381_regs_h26x_highpoc { 398 struct { 399 u32 ref0_poc_highbit : 4; 400 u32 ref1_poc_highbit : 4; 401 u32 ref2_poc_highbit : 4; 402 u32 ref3_poc_highbit : 4; 403 u32 ref4_poc_highbit : 4; 404 u32 ref5_poc_highbit : 4; 405 u32 ref6_poc_highbit : 4; 406 u32 ref7_poc_highbit : 4; 407 } reg200_203_ref_poc_highbit[4]; 408 struct { 409 u32 cur_poc_highbit : 4; 410 u32 reserved : 28; 411 } reg204_cur_poc_highbit; 412 } __packed; 413 414 struct rkvdec_vdpu381_regs_h264 { 415 struct rkvdec_vdpu381_regs_common common; 416 struct rkvdec_vdpu381_regs_h264_params h264_param; 417 struct rkvdec_vdpu381_regs_common_addr common_addr; 418 struct rkvdec_vdpu381_regs_h26x_addr h264_addr; 419 struct rkvdec_vdpu381_regs_h26x_highpoc h264_highpoc; 420 } __packed; 421 422 struct rkvdec_vdpu381_regs_hevc { 423 struct rkvdec_vdpu381_regs_common common; 424 struct rkvdec_vdpu381_regs_hevc_params hevc_param; 425 struct rkvdec_vdpu381_regs_common_addr common_addr; 426 struct rkvdec_vdpu381_regs_h26x_addr hevc_addr; 427 struct rkvdec_vdpu381_regs_h26x_highpoc hevc_highpoc; 428 } __packed; 429 430 #endif /* __RKVDEC_REGS_H__ */ 431