1 // SPDX-License-Identifier: GPL-2.0-only OR MIT 2 /* Copyright (c) 2023 Imagination Technologies Ltd. */ 3 4 #include "pvr_device_info.h" 5 #include "pvr_rogue_fwif_client.h" 6 #include "pvr_rogue_fwif_stream.h" 7 #include "pvr_stream.h" 8 #include "pvr_stream_defs.h" 9 10 #include <linux/stddef.h> 11 #include <uapi/drm/pvr_drm.h> 12 13 #define PVR_STREAM_DEF_SET(owner, member, _size, _array_size, _feature) \ 14 { .offset = offsetof(struct owner, member), \ 15 .size = (_size), \ 16 .array_size = (_array_size), \ 17 .feature = (_feature) } 18 19 #define PVR_STREAM_DEF(owner, member, member_size) \ 20 PVR_STREAM_DEF_SET(owner, member, PVR_STREAM_SIZE_ ## member_size, 0, PVR_FEATURE_NONE) 21 22 #define PVR_STREAM_DEF_FEATURE(owner, member, member_size, feature) \ 23 PVR_STREAM_DEF_SET(owner, member, PVR_STREAM_SIZE_ ## member_size, 0, feature) 24 25 #define PVR_STREAM_DEF_NOT_FEATURE(owner, member, member_size, feature) \ 26 PVR_STREAM_DEF_SET(owner, member, PVR_STREAM_SIZE_ ## member_size, 0, \ 27 (feature) | PVR_FEATURE_NOT) 28 29 #define PVR_STREAM_DEF_ARRAY(owner, member) \ 30 PVR_STREAM_DEF_SET(owner, member, PVR_STREAM_SIZE_ARRAY, \ 31 sizeof(((struct owner *)0)->member), PVR_FEATURE_NONE) 32 33 #define PVR_STREAM_DEF_ARRAY_FEATURE(owner, member, feature) \ 34 PVR_STREAM_DEF_SET(owner, member, PVR_STREAM_SIZE_ARRAY, \ 35 sizeof(((struct owner *)0)->member), feature) 36 37 #define PVR_STREAM_DEF_ARRAY_NOT_FEATURE(owner, member, feature) \ 38 PVR_STREAM_DEF_SET(owner, member, PVR_STREAM_SIZE_ARRAY, \ 39 sizeof(((struct owner *)0)->member), (feature) | PVR_FEATURE_NOT) 40 41 /* 42 * When adding new parameters to the stream definition, the new parameters must go after the 43 * existing parameters, to preserve order. As parameters are naturally aligned, care must be taken 44 * with respect to implicit padding in the stream; padding should be minimised as much as possible. 45 */ 46 static const struct pvr_stream_def rogue_fwif_cmd_geom_stream[] = { 47 PVR_STREAM_DEF(rogue_fwif_cmd_geom, regs.vdm_ctrl_stream_base, 64), 48 PVR_STREAM_DEF(rogue_fwif_cmd_geom, regs.tpu_border_colour_table, 64), 49 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_geom, regs.vdm_draw_indirect0, 64, 50 PVR_FEATURE_VDM_DRAWINDIRECT), 51 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_geom, regs.vdm_draw_indirect1, 32, 52 PVR_FEATURE_VDM_DRAWINDIRECT), 53 PVR_STREAM_DEF(rogue_fwif_cmd_geom, regs.ppp_ctrl, 32), 54 PVR_STREAM_DEF(rogue_fwif_cmd_geom, regs.te_psg, 32), 55 PVR_STREAM_DEF(rogue_fwif_cmd_geom, regs.vdm_context_resume_task0_size, 32), 56 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_geom, regs.vdm_context_resume_task3_size, 32, 57 PVR_FEATURE_VDM_OBJECT_LEVEL_LLS), 58 PVR_STREAM_DEF(rogue_fwif_cmd_geom, regs.view_idx, 32), 59 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_geom, regs.pds_coeff_free_prog, 32, 60 PVR_FEATURE_TESSELLATION), 61 }; 62 63 static const struct pvr_stream_def rogue_fwif_cmd_geom_stream_brn49927[] = { 64 PVR_STREAM_DEF(rogue_fwif_cmd_geom, regs.tpu, 32), 65 }; 66 67 static const struct pvr_stream_ext_def cmd_geom_ext_streams_0[] = { 68 { 69 .stream = rogue_fwif_cmd_geom_stream_brn49927, 70 .stream_len = ARRAY_SIZE(rogue_fwif_cmd_geom_stream_brn49927), 71 .header_mask = PVR_STREAM_EXTHDR_GEOM0_BRN49927, 72 .quirk = 49927, 73 }, 74 }; 75 76 static const struct pvr_stream_ext_header cmd_geom_ext_headers[] = { 77 { 78 .ext_streams = cmd_geom_ext_streams_0, 79 .ext_streams_num = ARRAY_SIZE(cmd_geom_ext_streams_0), 80 .valid_mask = PVR_STREAM_EXTHDR_GEOM0_VALID, 81 }, 82 }; 83 84 const struct pvr_stream_cmd_defs pvr_cmd_geom_stream = { 85 .type = PVR_STREAM_TYPE_GEOM, 86 87 .main_stream = rogue_fwif_cmd_geom_stream, 88 .main_stream_len = ARRAY_SIZE(rogue_fwif_cmd_geom_stream), 89 90 .ext_nr_headers = ARRAY_SIZE(cmd_geom_ext_headers), 91 .ext_headers = cmd_geom_ext_headers, 92 93 .dest_size = sizeof(struct rogue_fwif_cmd_geom), 94 }; 95 96 static const struct pvr_stream_def rogue_fwif_cmd_frag_stream[] = { 97 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_scissor_base, 64), 98 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_dbias_base, 64), 99 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_oclqry_base, 64), 100 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_zlsctl, 64), 101 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_zload_store_base, 64), 102 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_stencil_load_store_base, 64), 103 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_frag, regs.fb_cdc_zls, 64, 104 PVR_FEATURE_REQUIRES_FB_CDC_ZLS_SETUP), 105 PVR_STREAM_DEF_ARRAY(rogue_fwif_cmd_frag, regs.pbe_word), 106 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.tpu_border_colour_table, 64), 107 PVR_STREAM_DEF_ARRAY(rogue_fwif_cmd_frag, regs.pds_bgnd), 108 PVR_STREAM_DEF_ARRAY(rogue_fwif_cmd_frag, regs.pds_pr_bgnd), 109 PVR_STREAM_DEF_ARRAY(rogue_fwif_cmd_frag, regs.usc_clear_register), 110 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.usc_pixel_output_ctrl, 32), 111 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_bgobjdepth, 32), 112 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_bgobjvals, 32), 113 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_aa, 32), 114 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_frag, regs.isp_xtp_pipe_enable, 32, 115 PVR_FEATURE_S7_TOP_INFRASTRUCTURE), 116 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_ctl, 32), 117 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.event_pixel_pds_info, 32), 118 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_frag, regs.pixel_phantom, 32, 119 PVR_FEATURE_CLUSTER_GROUPING), 120 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.view_idx, 32), 121 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.event_pixel_pds_data, 32), 122 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_frag, regs.isp_oclqry_stride, 32, 123 PVR_FEATURE_GPU_MULTICORE_SUPPORT), 124 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_frag, regs.isp_zls_pixels, 32, 125 PVR_FEATURE_ZLS_SUBTILE), 126 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_frag, regs.rgx_cr_blackpearl_fix, 32, 127 PVR_FEATURE_ISP_ZLS_D24_S8_PACKING_OGL_MODE), 128 PVR_STREAM_DEF(rogue_fwif_cmd_frag, zls_stride, 32), 129 PVR_STREAM_DEF(rogue_fwif_cmd_frag, sls_stride, 32), 130 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_frag, execute_count, 32, 131 PVR_FEATURE_GPU_MULTICORE_SUPPORT), 132 }; 133 134 static const struct pvr_stream_def rogue_fwif_cmd_frag_stream_brn47217[] = { 135 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.isp_oclqry_stride, 32), 136 }; 137 138 static const struct pvr_stream_def rogue_fwif_cmd_frag_stream_brn49927[] = { 139 PVR_STREAM_DEF(rogue_fwif_cmd_frag, regs.tpu, 32), 140 }; 141 142 static const struct pvr_stream_ext_def cmd_frag_ext_streams_0[] = { 143 { 144 .stream = rogue_fwif_cmd_frag_stream_brn47217, 145 .stream_len = ARRAY_SIZE(rogue_fwif_cmd_frag_stream_brn47217), 146 .header_mask = PVR_STREAM_EXTHDR_FRAG0_BRN47217, 147 .quirk = 47217, 148 }, 149 { 150 .stream = rogue_fwif_cmd_frag_stream_brn49927, 151 .stream_len = ARRAY_SIZE(rogue_fwif_cmd_frag_stream_brn49927), 152 .header_mask = PVR_STREAM_EXTHDR_FRAG0_BRN49927, 153 .quirk = 49927, 154 }, 155 }; 156 157 static const struct pvr_stream_ext_header cmd_frag_ext_headers[] = { 158 { 159 .ext_streams = cmd_frag_ext_streams_0, 160 .ext_streams_num = ARRAY_SIZE(cmd_frag_ext_streams_0), 161 .valid_mask = PVR_STREAM_EXTHDR_FRAG0_VALID, 162 }, 163 }; 164 165 const struct pvr_stream_cmd_defs pvr_cmd_frag_stream = { 166 .type = PVR_STREAM_TYPE_FRAG, 167 168 .main_stream = rogue_fwif_cmd_frag_stream, 169 .main_stream_len = ARRAY_SIZE(rogue_fwif_cmd_frag_stream), 170 171 .ext_nr_headers = ARRAY_SIZE(cmd_frag_ext_headers), 172 .ext_headers = cmd_frag_ext_headers, 173 174 .dest_size = sizeof(struct rogue_fwif_cmd_frag), 175 }; 176 177 static const struct pvr_stream_def rogue_fwif_cmd_compute_stream[] = { 178 PVR_STREAM_DEF(rogue_fwif_cmd_compute, regs.tpu_border_colour_table, 64), 179 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_compute, regs.cdm_cb_queue, 64, 180 PVR_FEATURE_CDM_USER_MODE_QUEUE), 181 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_compute, regs.cdm_cb_base, 64, 182 PVR_FEATURE_CDM_USER_MODE_QUEUE), 183 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_compute, regs.cdm_cb, 64, 184 PVR_FEATURE_CDM_USER_MODE_QUEUE), 185 PVR_STREAM_DEF_NOT_FEATURE(rogue_fwif_cmd_compute, regs.cdm_ctrl_stream_base, 64, 186 PVR_FEATURE_CDM_USER_MODE_QUEUE), 187 PVR_STREAM_DEF(rogue_fwif_cmd_compute, regs.cdm_context_state_base_addr, 64), 188 PVR_STREAM_DEF(rogue_fwif_cmd_compute, regs.cdm_resume_pds1, 32), 189 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_compute, regs.cdm_item, 32, 190 PVR_FEATURE_COMPUTE_MORTON_CAPABLE), 191 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_compute, regs.compute_cluster, 32, 192 PVR_FEATURE_CLUSTER_GROUPING), 193 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_compute, regs.tpu_tag_cdm_ctrl, 32, 194 PVR_FEATURE_TPU_DM_GLOBAL_REGISTERS), 195 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_compute, stream_start_offset, 32, 196 PVR_FEATURE_CDM_USER_MODE_QUEUE), 197 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_compute, execute_count, 32, 198 PVR_FEATURE_GPU_MULTICORE_SUPPORT), 199 }; 200 201 static const struct pvr_stream_def rogue_fwif_cmd_compute_stream_brn49927[] = { 202 PVR_STREAM_DEF(rogue_fwif_cmd_compute, regs.tpu, 32), 203 }; 204 205 static const struct pvr_stream_ext_def cmd_compute_ext_streams_0[] = { 206 { 207 .stream = rogue_fwif_cmd_compute_stream_brn49927, 208 .stream_len = ARRAY_SIZE(rogue_fwif_cmd_compute_stream_brn49927), 209 .header_mask = PVR_STREAM_EXTHDR_COMPUTE0_BRN49927, 210 .quirk = 49927, 211 }, 212 }; 213 214 static const struct pvr_stream_ext_header cmd_compute_ext_headers[] = { 215 { 216 .ext_streams = cmd_compute_ext_streams_0, 217 .ext_streams_num = ARRAY_SIZE(cmd_compute_ext_streams_0), 218 .valid_mask = PVR_STREAM_EXTHDR_COMPUTE0_VALID, 219 }, 220 }; 221 222 const struct pvr_stream_cmd_defs pvr_cmd_compute_stream = { 223 .type = PVR_STREAM_TYPE_COMPUTE, 224 225 .main_stream = rogue_fwif_cmd_compute_stream, 226 .main_stream_len = ARRAY_SIZE(rogue_fwif_cmd_compute_stream), 227 228 .ext_nr_headers = ARRAY_SIZE(cmd_compute_ext_headers), 229 .ext_headers = cmd_compute_ext_headers, 230 231 .dest_size = sizeof(struct rogue_fwif_cmd_compute), 232 }; 233 234 static const struct pvr_stream_def rogue_fwif_cmd_transfer_stream[] = { 235 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.pds_bgnd0_base, 64), 236 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.pds_bgnd1_base, 64), 237 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.pds_bgnd3_sizeinfo, 64), 238 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.isp_mtile_base, 64), 239 PVR_STREAM_DEF_ARRAY(rogue_fwif_cmd_transfer, regs.pbe_wordx_mrty), 240 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.isp_bgobjvals, 32), 241 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.usc_pixel_output_ctrl, 32), 242 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.usc_clear_register0, 32), 243 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.usc_clear_register1, 32), 244 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.usc_clear_register2, 32), 245 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.usc_clear_register3, 32), 246 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.isp_mtile_size, 32), 247 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.isp_render_origin, 32), 248 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.isp_ctl, 32), 249 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.isp_aa, 32), 250 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.event_pixel_pds_info, 32), 251 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.event_pixel_pds_code, 32), 252 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.event_pixel_pds_data, 32), 253 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.isp_render, 32), 254 PVR_STREAM_DEF(rogue_fwif_cmd_transfer, regs.isp_rgn, 32), 255 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_transfer, regs.isp_xtp_pipe_enable, 32, 256 PVR_FEATURE_S7_TOP_INFRASTRUCTURE), 257 PVR_STREAM_DEF_FEATURE(rogue_fwif_cmd_transfer, regs.frag_screen, 32, 258 PVR_FEATURE_GPU_MULTICORE_SUPPORT), 259 }; 260 261 const struct pvr_stream_cmd_defs pvr_cmd_transfer_stream = { 262 .type = PVR_STREAM_TYPE_TRANSFER, 263 264 .main_stream = rogue_fwif_cmd_transfer_stream, 265 .main_stream_len = ARRAY_SIZE(rogue_fwif_cmd_transfer_stream), 266 267 .ext_nr_headers = 0, 268 269 .dest_size = sizeof(struct rogue_fwif_cmd_transfer), 270 }; 271 272 static const struct pvr_stream_def rogue_fwif_static_render_context_state_stream[] = { 273 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 274 geom_reg_vdm_context_state_base_addr, 64), 275 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 276 geom_reg_vdm_context_state_resume_addr, 64), 277 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 278 geom_reg_ta_context_state_base_addr, 64), 279 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 280 geom_state[0].geom_reg_vdm_context_store_task0, 64), 281 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 282 geom_state[0].geom_reg_vdm_context_store_task1, 64), 283 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 284 geom_state[0].geom_reg_vdm_context_store_task2, 64), 285 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 286 geom_state[0].geom_reg_vdm_context_store_task3, 64), 287 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 288 geom_state[0].geom_reg_vdm_context_store_task4, 64), 289 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 290 geom_state[0].geom_reg_vdm_context_resume_task0, 64), 291 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 292 geom_state[0].geom_reg_vdm_context_resume_task1, 64), 293 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 294 geom_state[0].geom_reg_vdm_context_resume_task2, 64), 295 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 296 geom_state[0].geom_reg_vdm_context_resume_task3, 64), 297 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 298 geom_state[0].geom_reg_vdm_context_resume_task4, 64), 299 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 300 geom_state[1].geom_reg_vdm_context_store_task0, 64), 301 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 302 geom_state[1].geom_reg_vdm_context_store_task1, 64), 303 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 304 geom_state[1].geom_reg_vdm_context_store_task2, 64), 305 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 306 geom_state[1].geom_reg_vdm_context_store_task3, 64), 307 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 308 geom_state[1].geom_reg_vdm_context_store_task4, 64), 309 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 310 geom_state[1].geom_reg_vdm_context_resume_task0, 64), 311 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 312 geom_state[1].geom_reg_vdm_context_resume_task1, 64), 313 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 314 geom_state[1].geom_reg_vdm_context_resume_task2, 64), 315 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 316 geom_state[1].geom_reg_vdm_context_resume_task3, 64), 317 PVR_STREAM_DEF(rogue_fwif_geom_registers_caswitch, 318 geom_state[1].geom_reg_vdm_context_resume_task4, 64), 319 }; 320 321 const struct pvr_stream_cmd_defs pvr_static_render_context_state_stream = { 322 .type = PVR_STREAM_TYPE_STATIC_RENDER_CONTEXT, 323 324 .main_stream = rogue_fwif_static_render_context_state_stream, 325 .main_stream_len = ARRAY_SIZE(rogue_fwif_static_render_context_state_stream), 326 327 .ext_nr_headers = 0, 328 329 .dest_size = sizeof(struct rogue_fwif_geom_registers_caswitch), 330 }; 331 332 static const struct pvr_stream_def rogue_fwif_static_compute_context_state_stream[] = { 333 PVR_STREAM_DEF(rogue_fwif_cdm_registers_cswitch, cdmreg_cdm_context_pds0, 64), 334 PVR_STREAM_DEF(rogue_fwif_cdm_registers_cswitch, cdmreg_cdm_context_pds1, 64), 335 PVR_STREAM_DEF(rogue_fwif_cdm_registers_cswitch, cdmreg_cdm_terminate_pds, 64), 336 PVR_STREAM_DEF(rogue_fwif_cdm_registers_cswitch, cdmreg_cdm_terminate_pds1, 64), 337 PVR_STREAM_DEF(rogue_fwif_cdm_registers_cswitch, cdmreg_cdm_resume_pds0, 64), 338 PVR_STREAM_DEF(rogue_fwif_cdm_registers_cswitch, cdmreg_cdm_context_pds0_b, 64), 339 PVR_STREAM_DEF(rogue_fwif_cdm_registers_cswitch, cdmreg_cdm_resume_pds0_b, 64), 340 }; 341 342 const struct pvr_stream_cmd_defs pvr_static_compute_context_state_stream = { 343 .type = PVR_STREAM_TYPE_STATIC_COMPUTE_CONTEXT, 344 345 .main_stream = rogue_fwif_static_compute_context_state_stream, 346 .main_stream_len = ARRAY_SIZE(rogue_fwif_static_compute_context_state_stream), 347 348 .ext_nr_headers = 0, 349 350 .dest_size = sizeof(struct rogue_fwif_cdm_registers_cswitch), 351 }; 352