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/types.h>
28 #include <linux/kernel.h>
31 * R6xx+ cards need to use the 3D engine to blit data which requires
32 * quite a bit of hw state setup. Rather than pull the whole 3D driver
33 * (which normally generates the 3D state) into the DRM, we opt to use
34 * statically generated state tables. The regsiter state and shaders
35 * were hand generated to support blitting functionality. See the 3D
36 * driver or documentation for descriptions of the registers and
37 * shader instructions.
40 const u32 r6xx_default_state
[] =
42 0xc0002400, /* START_3D_CMDBUF */
45 0xc0012800, /* CONTEXT_CONTROL */
51 0x00008000, /* WAIT_UNTIL */
55 0x07000003, /* TA_CNTL_AUX */
59 0x00000000, /* VC_ENHANCE */
63 0x00000000, /* SQ_DYN_GPR_CNTL_PS_FLUSH_REQ */
67 0x82000000, /* DB_DEBUG */
71 0x01020204, /* DB_WATERMARKS */
75 0x00000000, /* SQ_VTX_BASE_VTX_LOC */
76 0x00000000, /* SQ_VTX_START_INST_LOC */
80 0x00000000, /* SQ_ESGS_RING_ITEMSIZE */
92 0x00000000, /* DB_DEPTH_INFO */
96 0x00000000, /* DB_STENCIL_CLEAR */
97 0x00000000, /* DB_DEPTH_CLEAR */
101 0x00000000, /* DB_DEPTH_CONTROL */
105 0x00000060, /* DB_RENDER_CONTROL */
106 0x00000040, /* DB_RENDER_OVERRIDE */
110 0x0000aa00, /* DB_ALPHA_TO_MASK */
114 0x00000800, /* VGT_MAX_VTX_INDX */
115 0x00000000, /* VGT_MIN_VTX_INDX */
116 0x00000000, /* VGT_INDX_OFFSET */
117 0x00000000, /* VGT_MULTI_PRIM_IB_RESET_INDX */
118 0x00000000, /* SX_ALPHA_TEST_CONTROL */
119 0x00000000, /* CB_BLEND_RED */
123 0x00000000, /* CB_FOG_RED */
126 0x00000000, /* DB_STENCILREFMASK */
127 0x00000000, /* DB_STENCILREFMASK_BF */
128 0x00000000, /* SX_ALPHA_REF */
132 0x01000000, /* CB_CLRCMP_CNTL */
139 0x3f800000, /* CB_CLEAR_RED */
146 0x00000000, /* PA_SC_WINDOW_OFFSET */
150 0x0000ffff, /* PA_SC_CLIP_RECT_RULE */
151 0x00000000, /* PA_SC_CLIPRECT_0_TL */
159 0x00000000, /* PA_SC_EDGERULE */
163 0x80000000, /* PA_SC_VPORT_SCISSOR_0_TL */
164 0x20002000, /* PA_SC_VPORT_SCISSOR_0_BR */
165 0x80000000, /* PA_SC_VPORT_SCISSOR_1_TL */
195 0x00000000, /* PA_SC_VPORT_ZMIN_0 */
230 0x00000000, /* PA_SC_MPASS_PS_CNTL */
231 0x00004010, /* PA_SC_MODE_CNTL */
235 0x00000000, /* PA_SC_LINE_CNTL */
236 0x00000000, /* PA_SC_AA_CONFIG */
237 0x0000002d, /* PA_SU_VTX_CNTL */
238 0x3f800000, /* PA_CL_GB_VERT_CLIP_ADJ */
242 0x00000000, /* PA_SC_SAMPLE_LOCS_MCTX */
247 0xffffffff, /* PA_SC_AA_MASK */
251 0x00000000, /* PA_SU_POLY_OFFSET_DB_FMT_CNTL */
252 0x00000000, /* PA_SU_POLY_OFFSET_CLAMP */
253 0x00000000, /* PA_SU_POLY_OFFSET_FRONT_SCALE */
254 0x00000000, /* PA_SU_POLY_OFFSET_FRONT_OFFSET */
255 0x00000000, /* PA_SU_POLY_OFFSET_BACK_SCALE */
256 0x00000000, /* PA_SU_POLY_OFFSET_BACK_OFFSET */
260 0x00000000, /* SPI_INPUT_Z */
261 0x00000000, /* SPI_FOG_CNTL */
262 0x00000000, /* SPI_FOG_FUNC_SCALE */
263 0x00000000, /* SPI_FOG_FUNC_BIAS */
267 0x00000000, /* SQ_PGM_START_FS */
271 0x00000000, /* SQ_PGM_RESOURCES_FS */
275 0x00000000, /* SQ_PGM_CF_OFFSET_FS */
279 0x00000000, /* VGT_INSTANCE_STEP_RATE_0 */
280 0x00000000, /* VGT_INSTANCE_STEP_RATE_1 */
284 0x00000000, /* PA_SU_POINT_SIZE */
285 0x00000000, /* PA_SU_POINT_MINMAX */
286 0x00000008, /* PA_SU_LINE_CNTL */
287 0x00000000, /* PA_SC_LINE_STIPPLE */
288 0x00000000, /* VGT_OUTPUT_PATH_CNTL */
289 0x00000000, /* VGT_HOS_CNTL */
290 0x00000000, /* VGT_HOS_MAX_TESS_LEVEL */
291 0x00000000, /* VGT_HOS_MIN_TESS_LEVEL */
292 0x00000000, /* VGT_HOS_REUSE_DEPTH */
293 0x00000000, /* VGT_GROUP_PRIM_TYPE */
294 0x00000000, /* VGT_GROUP_FIRST_DECR */
295 0x00000000, /* VGT_GROUP_DECR */
296 0x00000000, /* VGT_GROUP_VECT_0_CNTL */
297 0x00000000, /* VGT_GROUP_VECT_1_CNTL */
298 0x00000000, /* VGT_GROUP_VECT_0_FMT_CNTL */
299 0x00000000, /* VGT_GROUP_VECT_1_FMT_CNTL */
300 0x00000000, /* VGT_GS_MODE */
304 0x00000000, /* VGT_PRIMITIVEID_EN */
308 0x00000000, /* VGT_MULTI_PRIM_ID_RESET_EN */
312 0x00000000, /* VGT_STRMOUT_EN */
313 0x00000000, /* VGT_REUSE_OFF */
314 0x00000000, /* VGT_VTX_CNT_EN */
318 0x00000000, /* SX_MISC */
322 0x00000000, /* VGT_STRMOUT_BUFFER_EN */
326 0x00cc0000, /* CB_COLOR_CONTROL */
327 0x00000210, /* DB_SHADER_CNTL */
328 0x00010000, /* PA_CL_CLIP_CNTL */
329 0x00000244, /* PA_SU_SC_MODE_CNTL */
330 0x00000100, /* PA_CL_VTE_CNTL */
331 0x00000000, /* PA_CL_VS_OUT_CNTL */
332 0x00000000, /* PA_CL_NANINF_CNTL */
336 0x0000000f, /* CB_TARGET_MASK */
337 0x0000000f, /* CB_SHADER_MASK */
341 0x00000001, /* CB_SHADER_CONTROL */
345 0x00000000, /* SPI_VS_OUT_ID_0 */
349 0x00000b00, /* SPI_PS_INPUT_CNTL_0 */
353 0x00000000, /* SPI_VS_OUT_CONFIG */
354 0x00000000, /* SPI_THREAD_GROUPING */
355 0x00000001, /* SPI_PS_IN_CONTROL_0 */
356 0x00000000, /* SPI_PS_IN_CONTROL_1 */
357 0x00000000, /* SPI_INTERP_CONTROL_0 */
359 0xc0036e00, /* SET_SAMPLER */
366 const u32 r7xx_default_state
[] =
368 0xc0012800, /* CONTEXT_CONTROL */
374 0x00008000, /* WAIT_UNTIL */
378 0x07000002, /* TA_CNTL_AUX */
382 0x00000000, /* VC_ENHANCE */
386 0x00004000, /* SQ_DYN_GPR_CNTL_PS_FLUSH_REQ */
390 0x00000000, /* DB_DEBUG */
394 0x00420204, /* DB_WATERMARKS */
398 0x00000000, /* SQ_VTX_BASE_VTX_LOC */
399 0x00000000, /* SQ_VTX_START_INST_LOC */
403 0x00000000, /* SQ_ESGS_RING_ITEMSIZE */
415 0x00000000, /* DB_DEPTH_INFO */
419 0x00000000, /* DB_STENCIL_CLEAR */
420 0x00000000, /* DB_DEPTH_CLEAR */
424 0x00000000, /* DB_DEPTH_CONTROL */
428 0x00000060, /* DB_RENDER_CONTROL */
429 0x00000000, /* DB_RENDER_OVERRIDE */
433 0x0000aa00, /* DB_ALPHA_TO_MASK */
437 0x00000800, /* VGT_MAX_VTX_INDX */
438 0x00000000, /* VGT_MIN_VTX_INDX */
439 0x00000000, /* VGT_INDX_OFFSET */
440 0x00000000, /* VGT_MULTI_PRIM_IB_RESET_INDX */
441 0x00000000, /* SX_ALPHA_TEST_CONTROL */
442 0x00000000, /* CB_BLEND_RED */
449 0x00000000, /* DB_STENCILREFMASK */
450 0x00000000, /* DB_STENCILREFMASK_BF */
451 0x00000000, /* SX_ALPHA_REF */
454 0x0000030c, /* CB_CLRCMP_CNTL */
462 0x00000000, /* PA_SC_WINDOW_OFFSET */
466 0x0000ffff, /* PA_SC_CLIP_RECT_RULE */
467 0x00000000, /* PA_SC_CLIPRECT_0_TL */
475 0xaaaaaaaa, /* PA_SC_EDGERULE */
479 0x80000000, /* PA_SC_VPORT_SCISSOR_0_TL */
480 0x20002000, /* PA_SC_VPORT_SCISSOR_0_BR */
481 0x80000000, /* PA_SC_VPORT_SCISSOR_1_TL */
511 0x00000000, /* PA_SC_VPORT_ZMIN_0 */
546 0x00000000, /* PA_SC_MPASS_PS_CNTL */
547 0x00514000, /* PA_SC_MODE_CNTL */
551 0x00000000, /* PA_SC_LINE_CNTL */
552 0x00000000, /* PA_SC_AA_CONFIG */
553 0x0000002d, /* PA_SU_VTX_CNTL */
554 0x3f800000, /* PA_CL_GB_VERT_CLIP_ADJ */
558 0x00000000, /* PA_SC_SAMPLE_LOCS_MCTX */
563 0xffffffff, /* PA_SC_AA_MASK */
567 0x00000000, /* PA_SU_POLY_OFFSET_DB_FMT_CNTL */
568 0x00000000, /* PA_SU_POLY_OFFSET_CLAMP */
569 0x00000000, /* PA_SU_POLY_OFFSET_FRONT_SCALE */
570 0x00000000, /* PA_SU_POLY_OFFSET_FRONT_OFFSET */
571 0x00000000, /* PA_SU_POLY_OFFSET_BACK_SCALE */
572 0x00000000, /* PA_SU_POLY_OFFSET_BACK_OFFSET */
576 0x00000000, /* SPI_INPUT_Z */
577 0x00000000, /* SPI_FOG_CNTL */
578 0x00000000, /* SPI_FOG_FUNC_SCALE */
579 0x00000000, /* SPI_FOG_FUNC_BIAS */
583 0x00000000, /* SQ_PGM_START_FS */
587 0x00000000, /* SQ_PGM_RESOURCES_FS */
591 0x00000000, /* SQ_PGM_CF_OFFSET_FS */
595 0x00000000, /* VGT_INSTANCE_STEP_RATE_0 */
596 0x00000000, /* VGT_INSTANCE_STEP_RATE_1 */
600 0x00000000, /* PA_SU_POINT_SIZE */
601 0x00000000, /* PA_SU_POINT_MINMAX */
602 0x00000008, /* PA_SU_LINE_CNTL */
603 0x00000000, /* PA_SC_LINE_STIPPLE */
604 0x00000000, /* VGT_OUTPUT_PATH_CNTL */
605 0x00000000, /* VGT_HOS_CNTL */
606 0x00000000, /* VGT_HOS_MAX_TESS_LEVEL */
607 0x00000000, /* VGT_HOS_MIN_TESS_LEVEL */
608 0x00000000, /* VGT_HOS_REUSE_DEPTH */
609 0x00000000, /* VGT_GROUP_PRIM_TYPE */
610 0x00000000, /* VGT_GROUP_FIRST_DECR */
611 0x00000000, /* VGT_GROUP_DECR */
612 0x00000000, /* VGT_GROUP_VECT_0_CNTL */
613 0x00000000, /* VGT_GROUP_VECT_1_CNTL */
614 0x00000000, /* VGT_GROUP_VECT_0_FMT_CNTL */
615 0x00000000, /* VGT_GROUP_VECT_1_FMT_CNTL */
616 0x00000000, /* VGT_GS_MODE */
620 0x00000000, /* VGT_PRIMITIVEID_EN */
624 0x00000000, /* VGT_MULTI_PRIM_ID_RESET_EN */
628 0x00000000, /* VGT_STRMOUT_EN */
629 0x00000000, /* VGT_REUSE_OFF */
630 0x00000000, /* VGT_VTX_CNT_EN */
634 0x00000000, /* SX_MISC */
638 0x00000000, /* VGT_STRMOUT_BUFFER_EN */
642 0x00cc0000, /* CB_COLOR_CONTROL */
643 0x00000210, /* DB_SHADER_CNTL */
644 0x00010000, /* PA_CL_CLIP_CNTL */
645 0x00000244, /* PA_SU_SC_MODE_CNTL */
646 0x00000100, /* PA_CL_VTE_CNTL */
647 0x00000000, /* PA_CL_VS_OUT_CNTL */
648 0x00000000, /* PA_CL_NANINF_CNTL */
652 0x0000000f, /* CB_TARGET_MASK */
653 0x0000000f, /* CB_SHADER_MASK */
657 0x00000001, /* CB_SHADER_CONTROL */
661 0x00000000, /* SPI_VS_OUT_ID_0 */
665 0x00000b00, /* SPI_PS_INPUT_CNTL_0 */
669 0x00000000, /* SPI_VS_OUT_CONFIG */
670 0x00000001, /* SPI_THREAD_GROUPING */
671 0x00000001, /* SPI_PS_IN_CONTROL_0 */
672 0x00000000, /* SPI_PS_IN_CONTROL_1 */
673 0x00000000, /* SPI_INTERP_CONTROL_0 */
675 0xc0036e00, /* SET_SAMPLER */
682 /* same for r6xx/r7xx */
683 const u32 r6xx_vs
[] =
703 const u32 r6xx_ps
[] =
715 const u32 r6xx_ps_size
= ARRAY_SIZE(r6xx_ps
);
716 const u32 r6xx_vs_size
= ARRAY_SIZE(r6xx_vs
);
717 const u32 r6xx_default_size
= ARRAY_SIZE(r6xx_default_state
);
718 const u32 r7xx_default_size
= ARRAY_SIZE(r7xx_default_state
);