2 * Copyright 2009 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 * Alex Deucher <alexander.deucher@amd.com>
27 #include <linux/bug.h>
28 #include <linux/types.h>
29 #include <linux/kernel.h>
32 * R6xx+ cards need to use the 3D engine to blit data which requires
33 * quite a bit of hw state setup. Rather than pull the whole 3D driver
34 * (which normally generates the 3D state) into the DRM, we opt to use
35 * statically generated state tables. The register state and shaders
36 * were hand generated to support blitting functionality. See the 3D
37 * driver or documentation for descriptions of the registers and
38 * shader instructions.
41 const u32 r6xx_default_state
[] =
43 0xc0002400, /* START_3D_CMDBUF */
46 0xc0012800, /* CONTEXT_CONTROL */
52 0x00008000, /* WAIT_UNTIL */
56 0x07000003, /* TA_CNTL_AUX */
60 0x00000000, /* VC_ENHANCE */
64 0x00000000, /* SQ_DYN_GPR_CNTL_PS_FLUSH_REQ */
68 0x82000000, /* DB_DEBUG */
72 0x01020204, /* DB_WATERMARKS */
76 0x00000000, /* SQ_VTX_BASE_VTX_LOC */
77 0x00000000, /* SQ_VTX_START_INST_LOC */
81 0x00000000, /* SQ_ESGS_RING_ITEMSIZE */
93 0x00000000, /* DB_DEPTH_INFO */
97 0x00000000, /* DB_STENCIL_CLEAR */
98 0x00000000, /* DB_DEPTH_CLEAR */
102 0x00000000, /* DB_DEPTH_CONTROL */
106 0x00000060, /* DB_RENDER_CONTROL */
107 0x00000040, /* DB_RENDER_OVERRIDE */
111 0x0000aa00, /* DB_ALPHA_TO_MASK */
115 0x00000800, /* VGT_MAX_VTX_INDX */
116 0x00000000, /* VGT_MIN_VTX_INDX */
117 0x00000000, /* VGT_INDX_OFFSET */
118 0x00000000, /* VGT_MULTI_PRIM_IB_RESET_INDX */
119 0x00000000, /* SX_ALPHA_TEST_CONTROL */
120 0x00000000, /* CB_BLEND_RED */
124 0x00000000, /* CB_FOG_RED */
127 0x00000000, /* DB_STENCILREFMASK */
128 0x00000000, /* DB_STENCILREFMASK_BF */
129 0x00000000, /* SX_ALPHA_REF */
133 0x01000000, /* CB_CLRCMP_CNTL */
140 0x3f800000, /* CB_CLEAR_RED */
147 0x00000000, /* PA_SC_WINDOW_OFFSET */
151 0x0000ffff, /* PA_SC_CLIP_RECT_RULE */
152 0x00000000, /* PA_SC_CLIPRECT_0_TL */
160 0x00000000, /* PA_SC_EDGERULE */
164 0x80000000, /* PA_SC_VPORT_SCISSOR_0_TL */
165 0x20002000, /* PA_SC_VPORT_SCISSOR_0_BR */
166 0x80000000, /* PA_SC_VPORT_SCISSOR_1_TL */
196 0x00000000, /* PA_SC_VPORT_ZMIN_0 */
231 0x00000000, /* PA_SC_MPASS_PS_CNTL */
232 0x00004010, /* PA_SC_MODE_CNTL */
236 0x00000000, /* PA_SC_LINE_CNTL */
237 0x00000000, /* PA_SC_AA_CONFIG */
238 0x0000002d, /* PA_SU_VTX_CNTL */
239 0x3f800000, /* PA_CL_GB_VERT_CLIP_ADJ */
243 0x00000000, /* PA_SC_SAMPLE_LOCS_MCTX */
248 0xffffffff, /* PA_SC_AA_MASK */
252 0x00000000, /* PA_SU_POLY_OFFSET_DB_FMT_CNTL */
253 0x00000000, /* PA_SU_POLY_OFFSET_CLAMP */
254 0x00000000, /* PA_SU_POLY_OFFSET_FRONT_SCALE */
255 0x00000000, /* PA_SU_POLY_OFFSET_FRONT_OFFSET */
256 0x00000000, /* PA_SU_POLY_OFFSET_BACK_SCALE */
257 0x00000000, /* PA_SU_POLY_OFFSET_BACK_OFFSET */
261 0x00000000, /* SPI_INPUT_Z */
262 0x00000000, /* SPI_FOG_CNTL */
263 0x00000000, /* SPI_FOG_FUNC_SCALE */
264 0x00000000, /* SPI_FOG_FUNC_BIAS */
268 0x00000000, /* SQ_PGM_START_FS */
272 0x00000000, /* SQ_PGM_RESOURCES_FS */
276 0x00000000, /* SQ_PGM_CF_OFFSET_FS */
280 0x00000000, /* VGT_INSTANCE_STEP_RATE_0 */
281 0x00000000, /* VGT_INSTANCE_STEP_RATE_1 */
285 0x00000000, /* PA_SU_POINT_SIZE */
286 0x00000000, /* PA_SU_POINT_MINMAX */
287 0x00000008, /* PA_SU_LINE_CNTL */
288 0x00000000, /* PA_SC_LINE_STIPPLE */
289 0x00000000, /* VGT_OUTPUT_PATH_CNTL */
290 0x00000000, /* VGT_HOS_CNTL */
291 0x00000000, /* VGT_HOS_MAX_TESS_LEVEL */
292 0x00000000, /* VGT_HOS_MIN_TESS_LEVEL */
293 0x00000000, /* VGT_HOS_REUSE_DEPTH */
294 0x00000000, /* VGT_GROUP_PRIM_TYPE */
295 0x00000000, /* VGT_GROUP_FIRST_DECR */
296 0x00000000, /* VGT_GROUP_DECR */
297 0x00000000, /* VGT_GROUP_VECT_0_CNTL */
298 0x00000000, /* VGT_GROUP_VECT_1_CNTL */
299 0x00000000, /* VGT_GROUP_VECT_0_FMT_CNTL */
300 0x00000000, /* VGT_GROUP_VECT_1_FMT_CNTL */
301 0x00000000, /* VGT_GS_MODE */
305 0x00000000, /* VGT_PRIMITIVEID_EN */
309 0x00000000, /* VGT_MULTI_PRIM_ID_RESET_EN */
313 0x00000000, /* VGT_STRMOUT_EN */
314 0x00000000, /* VGT_REUSE_OFF */
315 0x00000000, /* VGT_VTX_CNT_EN */
319 0x00000000, /* SX_MISC */
323 0x00000000, /* VGT_STRMOUT_BUFFER_EN */
327 0x00cc0000, /* CB_COLOR_CONTROL */
328 0x00000210, /* DB_SHADER_CNTL */
329 0x00010000, /* PA_CL_CLIP_CNTL */
330 0x00000244, /* PA_SU_SC_MODE_CNTL */
331 0x00000100, /* PA_CL_VTE_CNTL */
332 0x00000000, /* PA_CL_VS_OUT_CNTL */
333 0x00000000, /* PA_CL_NANINF_CNTL */
337 0x0000000f, /* CB_TARGET_MASK */
338 0x0000000f, /* CB_SHADER_MASK */
342 0x00000001, /* CB_SHADER_CONTROL */
346 0x00000000, /* SPI_VS_OUT_ID_0 */
350 0x00000b00, /* SPI_PS_INPUT_CNTL_0 */
354 0x00000000, /* SPI_VS_OUT_CONFIG */
355 0x00000000, /* SPI_THREAD_GROUPING */
356 0x00000001, /* SPI_PS_IN_CONTROL_0 */
357 0x00000000, /* SPI_PS_IN_CONTROL_1 */
358 0x00000000, /* SPI_INTERP_CONTROL_0 */
360 0xc0036e00, /* SET_SAMPLER */
367 const u32 r7xx_default_state
[] =
369 0xc0012800, /* CONTEXT_CONTROL */
375 0x00008000, /* WAIT_UNTIL */
379 0x07000002, /* TA_CNTL_AUX */
383 0x00000000, /* VC_ENHANCE */
387 0x00004000, /* SQ_DYN_GPR_CNTL_PS_FLUSH_REQ */
391 0x00000000, /* DB_DEBUG */
395 0x00420204, /* DB_WATERMARKS */
399 0x00000000, /* SQ_VTX_BASE_VTX_LOC */
400 0x00000000, /* SQ_VTX_START_INST_LOC */
404 0x00000000, /* SQ_ESGS_RING_ITEMSIZE */
416 0x00000000, /* DB_DEPTH_INFO */
420 0x00000000, /* DB_STENCIL_CLEAR */
421 0x00000000, /* DB_DEPTH_CLEAR */
425 0x00000000, /* DB_DEPTH_CONTROL */
429 0x00000060, /* DB_RENDER_CONTROL */
430 0x00000000, /* DB_RENDER_OVERRIDE */
434 0x0000aa00, /* DB_ALPHA_TO_MASK */
438 0x00000800, /* VGT_MAX_VTX_INDX */
439 0x00000000, /* VGT_MIN_VTX_INDX */
440 0x00000000, /* VGT_INDX_OFFSET */
441 0x00000000, /* VGT_MULTI_PRIM_IB_RESET_INDX */
442 0x00000000, /* SX_ALPHA_TEST_CONTROL */
443 0x00000000, /* CB_BLEND_RED */
450 0x00000000, /* DB_STENCILREFMASK */
451 0x00000000, /* DB_STENCILREFMASK_BF */
452 0x00000000, /* SX_ALPHA_REF */
455 0x0000030c, /* CB_CLRCMP_CNTL */
463 0x00000000, /* PA_SC_WINDOW_OFFSET */
467 0x0000ffff, /* PA_SC_CLIP_RECT_RULE */
468 0x00000000, /* PA_SC_CLIPRECT_0_TL */
476 0xaaaaaaaa, /* PA_SC_EDGERULE */
480 0x80000000, /* PA_SC_VPORT_SCISSOR_0_TL */
481 0x20002000, /* PA_SC_VPORT_SCISSOR_0_BR */
482 0x80000000, /* PA_SC_VPORT_SCISSOR_1_TL */
512 0x00000000, /* PA_SC_VPORT_ZMIN_0 */
547 0x00000000, /* PA_SC_MPASS_PS_CNTL */
548 0x00514000, /* PA_SC_MODE_CNTL */
552 0x00000000, /* PA_SC_LINE_CNTL */
553 0x00000000, /* PA_SC_AA_CONFIG */
554 0x0000002d, /* PA_SU_VTX_CNTL */
555 0x3f800000, /* PA_CL_GB_VERT_CLIP_ADJ */
559 0x00000000, /* PA_SC_SAMPLE_LOCS_MCTX */
564 0xffffffff, /* PA_SC_AA_MASK */
568 0x00000000, /* PA_SU_POLY_OFFSET_DB_FMT_CNTL */
569 0x00000000, /* PA_SU_POLY_OFFSET_CLAMP */
570 0x00000000, /* PA_SU_POLY_OFFSET_FRONT_SCALE */
571 0x00000000, /* PA_SU_POLY_OFFSET_FRONT_OFFSET */
572 0x00000000, /* PA_SU_POLY_OFFSET_BACK_SCALE */
573 0x00000000, /* PA_SU_POLY_OFFSET_BACK_OFFSET */
577 0x00000000, /* SPI_INPUT_Z */
578 0x00000000, /* SPI_FOG_CNTL */
579 0x00000000, /* SPI_FOG_FUNC_SCALE */
580 0x00000000, /* SPI_FOG_FUNC_BIAS */
584 0x00000000, /* SQ_PGM_START_FS */
588 0x00000000, /* SQ_PGM_RESOURCES_FS */
592 0x00000000, /* SQ_PGM_CF_OFFSET_FS */
596 0x00000000, /* VGT_INSTANCE_STEP_RATE_0 */
597 0x00000000, /* VGT_INSTANCE_STEP_RATE_1 */
601 0x00000000, /* PA_SU_POINT_SIZE */
602 0x00000000, /* PA_SU_POINT_MINMAX */
603 0x00000008, /* PA_SU_LINE_CNTL */
604 0x00000000, /* PA_SC_LINE_STIPPLE */
605 0x00000000, /* VGT_OUTPUT_PATH_CNTL */
606 0x00000000, /* VGT_HOS_CNTL */
607 0x00000000, /* VGT_HOS_MAX_TESS_LEVEL */
608 0x00000000, /* VGT_HOS_MIN_TESS_LEVEL */
609 0x00000000, /* VGT_HOS_REUSE_DEPTH */
610 0x00000000, /* VGT_GROUP_PRIM_TYPE */
611 0x00000000, /* VGT_GROUP_FIRST_DECR */
612 0x00000000, /* VGT_GROUP_DECR */
613 0x00000000, /* VGT_GROUP_VECT_0_CNTL */
614 0x00000000, /* VGT_GROUP_VECT_1_CNTL */
615 0x00000000, /* VGT_GROUP_VECT_0_FMT_CNTL */
616 0x00000000, /* VGT_GROUP_VECT_1_FMT_CNTL */
617 0x00000000, /* VGT_GS_MODE */
621 0x00000000, /* VGT_PRIMITIVEID_EN */
625 0x00000000, /* VGT_MULTI_PRIM_ID_RESET_EN */
629 0x00000000, /* VGT_STRMOUT_EN */
630 0x00000000, /* VGT_REUSE_OFF */
631 0x00000000, /* VGT_VTX_CNT_EN */
635 0x00000000, /* SX_MISC */
639 0x00000000, /* VGT_STRMOUT_BUFFER_EN */
643 0x00cc0000, /* CB_COLOR_CONTROL */
644 0x00000210, /* DB_SHADER_CNTL */
645 0x00010000, /* PA_CL_CLIP_CNTL */
646 0x00000244, /* PA_SU_SC_MODE_CNTL */
647 0x00000100, /* PA_CL_VTE_CNTL */
648 0x00000000, /* PA_CL_VS_OUT_CNTL */
649 0x00000000, /* PA_CL_NANINF_CNTL */
653 0x0000000f, /* CB_TARGET_MASK */
654 0x0000000f, /* CB_SHADER_MASK */
658 0x00000001, /* CB_SHADER_CONTROL */
662 0x00000000, /* SPI_VS_OUT_ID_0 */
666 0x00000b00, /* SPI_PS_INPUT_CNTL_0 */
670 0x00000000, /* SPI_VS_OUT_CONFIG */
671 0x00000001, /* SPI_THREAD_GROUPING */
672 0x00000001, /* SPI_PS_IN_CONTROL_0 */
673 0x00000000, /* SPI_PS_IN_CONTROL_1 */
674 0x00000000, /* SPI_INTERP_CONTROL_0 */
676 0xc0036e00, /* SET_SAMPLER */
683 /* same for r6xx/r7xx */
684 const u32 r6xx_vs
[] =
704 const u32 r6xx_ps
[] =
716 const u32 r6xx_ps_size
= ARRAY_SIZE(r6xx_ps
);
717 const u32 r6xx_vs_size
= ARRAY_SIZE(r6xx_vs
);
718 const u32 r6xx_default_size
= ARRAY_SIZE(r6xx_default_state
);
719 const u32 r7xx_default_size
= ARRAY_SIZE(r7xx_default_state
);