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, /* VGT_STRMOUT_BUFFER_EN */
322 0x00cc0000, /* CB_COLOR_CONTROL */
323 0x00000210, /* DB_SHADER_CNTL */
324 0x00010000, /* PA_CL_CLIP_CNTL */
325 0x00000244, /* PA_SU_SC_MODE_CNTL */
326 0x00000100, /* PA_CL_VTE_CNTL */
327 0x00000000, /* PA_CL_VS_OUT_CNTL */
328 0x00000000, /* PA_CL_NANINF_CNTL */
332 0x0000000f, /* CB_TARGET_MASK */
333 0x0000000f, /* CB_SHADER_MASK */
337 0x00000001, /* CB_SHADER_CONTROL */
341 0x00000000, /* SPI_VS_OUT_ID_0 */
345 0x00000b00, /* SPI_PS_INPUT_CNTL_0 */
349 0x00000000, /* SPI_VS_OUT_CONFIG */
350 0x00000000, /* SPI_THREAD_GROUPING */
351 0x00000001, /* SPI_PS_IN_CONTROL_0 */
352 0x00000000, /* SPI_PS_IN_CONTROL_1 */
353 0x00000000, /* SPI_INTERP_CONTROL_0 */
355 0xc0036e00, /* SET_SAMPLER */
362 const u32 r7xx_default_state
[] =
364 0xc0012800, /* CONTEXT_CONTROL */
370 0x00008000, /* WAIT_UNTIL */
374 0x07000002, /* TA_CNTL_AUX */
378 0x00000000, /* VC_ENHANCE */
382 0x00004000, /* SQ_DYN_GPR_CNTL_PS_FLUSH_REQ */
386 0x00000000, /* DB_DEBUG */
390 0x00420204, /* DB_WATERMARKS */
394 0x00000000, /* SQ_VTX_BASE_VTX_LOC */
395 0x00000000, /* SQ_VTX_START_INST_LOC */
399 0x00000000, /* SQ_ESGS_RING_ITEMSIZE */
411 0x00000000, /* DB_DEPTH_INFO */
415 0x00000000, /* DB_STENCIL_CLEAR */
416 0x00000000, /* DB_DEPTH_CLEAR */
420 0x00000000, /* DB_DEPTH_CONTROL */
424 0x00000060, /* DB_RENDER_CONTROL */
425 0x00000000, /* DB_RENDER_OVERRIDE */
429 0x0000aa00, /* DB_ALPHA_TO_MASK */
433 0x00000800, /* VGT_MAX_VTX_INDX */
434 0x00000000, /* VGT_MIN_VTX_INDX */
435 0x00000000, /* VGT_INDX_OFFSET */
436 0x00000000, /* VGT_MULTI_PRIM_IB_RESET_INDX */
437 0x00000000, /* SX_ALPHA_TEST_CONTROL */
438 0x00000000, /* CB_BLEND_RED */
445 0x00000000, /* DB_STENCILREFMASK */
446 0x00000000, /* DB_STENCILREFMASK_BF */
447 0x00000000, /* SX_ALPHA_REF */
450 0x0000030c, /* CB_CLRCMP_CNTL */
458 0x00000000, /* PA_SC_WINDOW_OFFSET */
462 0x0000ffff, /* PA_SC_CLIP_RECT_RULE */
463 0x00000000, /* PA_SC_CLIPRECT_0_TL */
471 0xaaaaaaaa, /* PA_SC_EDGERULE */
475 0x80000000, /* PA_SC_VPORT_SCISSOR_0_TL */
476 0x20002000, /* PA_SC_VPORT_SCISSOR_0_BR */
477 0x80000000, /* PA_SC_VPORT_SCISSOR_1_TL */
507 0x00000000, /* PA_SC_VPORT_ZMIN_0 */
542 0x00000000, /* PA_SC_MPASS_PS_CNTL */
543 0x00514000, /* PA_SC_MODE_CNTL */
547 0x00000000, /* PA_SC_LINE_CNTL */
548 0x00000000, /* PA_SC_AA_CONFIG */
549 0x0000002d, /* PA_SU_VTX_CNTL */
550 0x3f800000, /* PA_CL_GB_VERT_CLIP_ADJ */
554 0x00000000, /* PA_SC_SAMPLE_LOCS_MCTX */
559 0xffffffff, /* PA_SC_AA_MASK */
563 0x00000000, /* PA_SU_POLY_OFFSET_DB_FMT_CNTL */
564 0x00000000, /* PA_SU_POLY_OFFSET_CLAMP */
565 0x00000000, /* PA_SU_POLY_OFFSET_FRONT_SCALE */
566 0x00000000, /* PA_SU_POLY_OFFSET_FRONT_OFFSET */
567 0x00000000, /* PA_SU_POLY_OFFSET_BACK_SCALE */
568 0x00000000, /* PA_SU_POLY_OFFSET_BACK_OFFSET */
572 0x00000000, /* SPI_INPUT_Z */
573 0x00000000, /* SPI_FOG_CNTL */
574 0x00000000, /* SPI_FOG_FUNC_SCALE */
575 0x00000000, /* SPI_FOG_FUNC_BIAS */
579 0x00000000, /* SQ_PGM_START_FS */
583 0x00000000, /* SQ_PGM_RESOURCES_FS */
587 0x00000000, /* SQ_PGM_CF_OFFSET_FS */
591 0x00000000, /* VGT_INSTANCE_STEP_RATE_0 */
592 0x00000000, /* VGT_INSTANCE_STEP_RATE_1 */
596 0x00000000, /* PA_SU_POINT_SIZE */
597 0x00000000, /* PA_SU_POINT_MINMAX */
598 0x00000008, /* PA_SU_LINE_CNTL */
599 0x00000000, /* PA_SC_LINE_STIPPLE */
600 0x00000000, /* VGT_OUTPUT_PATH_CNTL */
601 0x00000000, /* VGT_HOS_CNTL */
602 0x00000000, /* VGT_HOS_MAX_TESS_LEVEL */
603 0x00000000, /* VGT_HOS_MIN_TESS_LEVEL */
604 0x00000000, /* VGT_HOS_REUSE_DEPTH */
605 0x00000000, /* VGT_GROUP_PRIM_TYPE */
606 0x00000000, /* VGT_GROUP_FIRST_DECR */
607 0x00000000, /* VGT_GROUP_DECR */
608 0x00000000, /* VGT_GROUP_VECT_0_CNTL */
609 0x00000000, /* VGT_GROUP_VECT_1_CNTL */
610 0x00000000, /* VGT_GROUP_VECT_0_FMT_CNTL */
611 0x00000000, /* VGT_GROUP_VECT_1_FMT_CNTL */
612 0x00000000, /* VGT_GS_MODE */
616 0x00000000, /* VGT_PRIMITIVEID_EN */
620 0x00000000, /* VGT_MULTI_PRIM_ID_RESET_EN */
624 0x00000000, /* VGT_STRMOUT_EN */
625 0x00000000, /* VGT_REUSE_OFF */
626 0x00000000, /* VGT_VTX_CNT_EN */
630 0x00000000, /* VGT_STRMOUT_BUFFER_EN */
634 0x00cc0000, /* CB_COLOR_CONTROL */
635 0x00000210, /* DB_SHADER_CNTL */
636 0x00010000, /* PA_CL_CLIP_CNTL */
637 0x00000244, /* PA_SU_SC_MODE_CNTL */
638 0x00000100, /* PA_CL_VTE_CNTL */
639 0x00000000, /* PA_CL_VS_OUT_CNTL */
640 0x00000000, /* PA_CL_NANINF_CNTL */
644 0x0000000f, /* CB_TARGET_MASK */
645 0x0000000f, /* CB_SHADER_MASK */
649 0x00000001, /* CB_SHADER_CONTROL */
653 0x00000000, /* SPI_VS_OUT_ID_0 */
657 0x00000b00, /* SPI_PS_INPUT_CNTL_0 */
661 0x00000000, /* SPI_VS_OUT_CONFIG */
662 0x00000001, /* SPI_THREAD_GROUPING */
663 0x00000001, /* SPI_PS_IN_CONTROL_0 */
664 0x00000000, /* SPI_PS_IN_CONTROL_1 */
665 0x00000000, /* SPI_INTERP_CONTROL_0 */
667 0xc0036e00, /* SET_SAMPLER */
674 /* same for r6xx/r7xx */
675 const u32 r6xx_vs
[] =
695 const u32 r6xx_ps
[] =
707 const u32 r6xx_ps_size
= ARRAY_SIZE(r6xx_ps
);
708 const u32 r6xx_vs_size
= ARRAY_SIZE(r6xx_vs
);
709 const u32 r6xx_default_size
= ARRAY_SIZE(r6xx_default_state
);
710 const u32 r7xx_default_size
= ARRAY_SIZE(r7xx_default_state
);