1254885Sdumbbell/*
2254885Sdumbbell * Copyright 2010 Advanced Micro Devices, Inc.
3254885Sdumbbell *
4254885Sdumbbell * Permission is hereby granted, free of charge, to any person obtaining a
5254885Sdumbbell * copy of this software and associated documentation files (the "Software"),
6254885Sdumbbell * to deal in the Software without restriction, including without limitation
7254885Sdumbbell * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8254885Sdumbbell * and/or sell copies of the Software, and to permit persons to whom the
9254885Sdumbbell * Software is furnished to do so, subject to the following conditions:
10254885Sdumbbell *
11254885Sdumbbell * The above copyright notice and this permission notice (including the next
12254885Sdumbbell * paragraph) shall be included in all copies or substantial portions of the
13254885Sdumbbell * Software.
14254885Sdumbbell *
15254885Sdumbbell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16254885Sdumbbell * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17254885Sdumbbell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18254885Sdumbbell * THE COPYRIGHT HOLDER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19254885Sdumbbell * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20254885Sdumbbell * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21254885Sdumbbell * DEALINGS IN THE SOFTWARE.
22254885Sdumbbell *
23254885Sdumbbell * Authors:
24254885Sdumbbell *     Alex Deucher <alexander.deucher@amd.com>
25254885Sdumbbell */
26254885Sdumbbell
27254885Sdumbbell#include <sys/cdefs.h>
28254885Sdumbbell__FBSDID("$FreeBSD$");
29254885Sdumbbell
30254885Sdumbbell#include <dev/drm2/drmP.h>
31254885Sdumbbell
32254885Sdumbbell/*
33254885Sdumbbell * evergreen cards need to use the 3D engine to blit data which requires
34254885Sdumbbell * quite a bit of hw state setup.  Rather than pull the whole 3D driver
35254885Sdumbbell * (which normally generates the 3D state) into the DRM, we opt to use
36254885Sdumbbell * statically generated state tables.  The regsiter state and shaders
37254885Sdumbbell * were hand generated to support blitting functionality.  See the 3D
38254885Sdumbbell * driver or documentation for descriptions of the registers and
39254885Sdumbbell * shader instructions.
40254885Sdumbbell */
41254885Sdumbbell
42254885Sdumbbellconst u32 cayman_default_state[] =
43254885Sdumbbell{
44254885Sdumbbell	0xc0066900,
45254885Sdumbbell	0x00000000,
46254885Sdumbbell	0x00000060, /* DB_RENDER_CONTROL */
47254885Sdumbbell	0x00000000, /* DB_COUNT_CONTROL */
48254885Sdumbbell	0x00000000, /* DB_DEPTH_VIEW */
49254885Sdumbbell	0x0000002a, /* DB_RENDER_OVERRIDE */
50254885Sdumbbell	0x00000000, /* DB_RENDER_OVERRIDE2 */
51254885Sdumbbell	0x00000000, /* DB_HTILE_DATA_BASE */
52254885Sdumbbell
53254885Sdumbbell	0xc0026900,
54254885Sdumbbell	0x0000000a,
55254885Sdumbbell	0x00000000, /* DB_STENCIL_CLEAR */
56254885Sdumbbell	0x00000000, /* DB_DEPTH_CLEAR */
57254885Sdumbbell
58254885Sdumbbell	0xc0036900,
59254885Sdumbbell	0x0000000f,
60254885Sdumbbell	0x00000000, /* DB_DEPTH_INFO */
61254885Sdumbbell	0x00000000, /* DB_Z_INFO */
62254885Sdumbbell	0x00000000, /* DB_STENCIL_INFO */
63254885Sdumbbell
64254885Sdumbbell	0xc0016900,
65254885Sdumbbell	0x00000080,
66254885Sdumbbell	0x00000000, /* PA_SC_WINDOW_OFFSET */
67254885Sdumbbell
68254885Sdumbbell	0xc00d6900,
69254885Sdumbbell	0x00000083,
70254885Sdumbbell	0x0000ffff, /* PA_SC_CLIPRECT_RULE */
71254885Sdumbbell	0x00000000, /* PA_SC_CLIPRECT_0_TL */
72254885Sdumbbell	0x20002000, /* PA_SC_CLIPRECT_0_BR */
73254885Sdumbbell	0x00000000,
74254885Sdumbbell	0x20002000,
75254885Sdumbbell	0x00000000,
76254885Sdumbbell	0x20002000,
77254885Sdumbbell	0x00000000,
78254885Sdumbbell	0x20002000,
79254885Sdumbbell	0xaaaaaaaa, /* PA_SC_EDGERULE */
80254885Sdumbbell	0x00000000, /* PA_SU_HARDWARE_SCREEN_OFFSET */
81254885Sdumbbell	0x0000000f, /* CB_TARGET_MASK */
82254885Sdumbbell	0x0000000f, /* CB_SHADER_MASK */
83254885Sdumbbell
84254885Sdumbbell	0xc0226900,
85254885Sdumbbell	0x00000094,
86254885Sdumbbell	0x80000000, /* PA_SC_VPORT_SCISSOR_0_TL */
87254885Sdumbbell	0x20002000, /* PA_SC_VPORT_SCISSOR_0_BR */
88254885Sdumbbell	0x80000000,
89254885Sdumbbell	0x20002000,
90254885Sdumbbell	0x80000000,
91254885Sdumbbell	0x20002000,
92254885Sdumbbell	0x80000000,
93254885Sdumbbell	0x20002000,
94254885Sdumbbell	0x80000000,
95254885Sdumbbell	0x20002000,
96254885Sdumbbell	0x80000000,
97254885Sdumbbell	0x20002000,
98254885Sdumbbell	0x80000000,
99254885Sdumbbell	0x20002000,
100254885Sdumbbell	0x80000000,
101254885Sdumbbell	0x20002000,
102254885Sdumbbell	0x80000000,
103254885Sdumbbell	0x20002000,
104254885Sdumbbell	0x80000000,
105254885Sdumbbell	0x20002000,
106254885Sdumbbell	0x80000000,
107254885Sdumbbell	0x20002000,
108254885Sdumbbell	0x80000000,
109254885Sdumbbell	0x20002000,
110254885Sdumbbell	0x80000000,
111254885Sdumbbell	0x20002000,
112254885Sdumbbell	0x80000000,
113254885Sdumbbell	0x20002000,
114254885Sdumbbell	0x80000000,
115254885Sdumbbell	0x20002000,
116254885Sdumbbell	0x80000000,
117254885Sdumbbell	0x20002000,
118254885Sdumbbell	0x00000000, /* PA_SC_VPORT_ZMIN_0 */
119254885Sdumbbell	0x3f800000, /* PA_SC_VPORT_ZMAX_0 */
120254885Sdumbbell
121254885Sdumbbell	0xc0016900,
122254885Sdumbbell	0x000000d4,
123254885Sdumbbell	0x00000000, /* SX_MISC */
124254885Sdumbbell
125254885Sdumbbell	0xc0026900,
126254885Sdumbbell	0x000000d9,
127254885Sdumbbell	0x00000000, /* CP_RINGID */
128254885Sdumbbell	0x00000000, /* CP_VMID */
129254885Sdumbbell
130254885Sdumbbell	0xc0096900,
131254885Sdumbbell	0x00000100,
132254885Sdumbbell	0x00ffffff, /* VGT_MAX_VTX_INDX */
133254885Sdumbbell	0x00000000, /* VGT_MIN_VTX_INDX */
134254885Sdumbbell	0x00000000, /* VGT_INDX_OFFSET */
135254885Sdumbbell	0x00000000, /* VGT_MULTI_PRIM_IB_RESET_INDX */
136254885Sdumbbell	0x00000000, /* SX_ALPHA_TEST_CONTROL */
137254885Sdumbbell	0x00000000, /* CB_BLEND_RED */
138254885Sdumbbell	0x00000000, /* CB_BLEND_GREEN */
139254885Sdumbbell	0x00000000, /* CB_BLEND_BLUE */
140254885Sdumbbell	0x00000000, /* CB_BLEND_ALPHA */
141254885Sdumbbell
142254885Sdumbbell	0xc0016900,
143254885Sdumbbell	0x00000187,
144254885Sdumbbell	0x00000100, /* SPI_VS_OUT_ID_0 */
145254885Sdumbbell
146254885Sdumbbell	0xc0026900,
147254885Sdumbbell	0x00000191,
148254885Sdumbbell	0x00000100, /* SPI_PS_INPUT_CNTL_0 */
149254885Sdumbbell	0x00000101, /* SPI_PS_INPUT_CNTL_1 */
150254885Sdumbbell
151254885Sdumbbell	0xc0016900,
152254885Sdumbbell	0x000001b1,
153254885Sdumbbell	0x00000000, /* SPI_VS_OUT_CONFIG */
154254885Sdumbbell
155254885Sdumbbell	0xc0106900,
156254885Sdumbbell	0x000001b3,
157254885Sdumbbell	0x20000001, /* SPI_PS_IN_CONTROL_0 */
158254885Sdumbbell	0x00000000, /* SPI_PS_IN_CONTROL_1 */
159254885Sdumbbell	0x00000000, /* SPI_INTERP_CONTROL_0 */
160254885Sdumbbell	0x00000000, /* SPI_INPUT_Z */
161254885Sdumbbell	0x00000000, /* SPI_FOG_CNTL */
162254885Sdumbbell	0x00100000, /* SPI_BARYC_CNTL */
163254885Sdumbbell	0x00000000, /* SPI_PS_IN_CONTROL_2 */
164254885Sdumbbell	0x00000000, /* SPI_COMPUTE_INPUT_CNTL */
165254885Sdumbbell	0x00000000, /* SPI_COMPUTE_NUM_THREAD_X */
166254885Sdumbbell	0x00000000, /* SPI_COMPUTE_NUM_THREAD_Y */
167254885Sdumbbell	0x00000000, /* SPI_COMPUTE_NUM_THREAD_Z */
168254885Sdumbbell	0x00000000, /* SPI_GPR_MGMT */
169254885Sdumbbell	0x00000000, /* SPI_LDS_MGMT */
170254885Sdumbbell	0x00000000, /* SPI_STACK_MGMT */
171254885Sdumbbell	0x00000000, /* SPI_WAVE_MGMT_1 */
172254885Sdumbbell	0x00000000, /* SPI_WAVE_MGMT_2 */
173254885Sdumbbell
174254885Sdumbbell	0xc0016900,
175254885Sdumbbell	0x000001e0,
176254885Sdumbbell	0x00000000, /* CB_BLEND0_CONTROL */
177254885Sdumbbell
178254885Sdumbbell	0xc00e6900,
179254885Sdumbbell	0x00000200,
180254885Sdumbbell	0x00000000, /* DB_DEPTH_CONTROL */
181254885Sdumbbell	0x00000000, /* DB_EQAA */
182254885Sdumbbell	0x00cc0010, /* CB_COLOR_CONTROL */
183254885Sdumbbell	0x00000210, /* DB_SHADER_CONTROL */
184254885Sdumbbell	0x00010000, /* PA_CL_CLIP_CNTL */
185254885Sdumbbell	0x00000004, /* PA_SU_SC_MODE_CNTL */
186254885Sdumbbell	0x00000100, /* PA_CL_VTE_CNTL */
187254885Sdumbbell	0x00000000, /* PA_CL_VS_OUT_CNTL */
188254885Sdumbbell	0x00000000, /* PA_CL_NANINF_CNTL */
189254885Sdumbbell	0x00000000, /* PA_SU_LINE_STIPPLE_CNTL */
190254885Sdumbbell	0x00000000, /* PA_SU_LINE_STIPPLE_SCALE */
191254885Sdumbbell	0x00000000, /* PA_SU_PRIM_FILTER_CNTL */
192254885Sdumbbell	0x00000000, /*  */
193254885Sdumbbell	0x00000000, /*  */
194254885Sdumbbell
195254885Sdumbbell	0xc0026900,
196254885Sdumbbell	0x00000229,
197254885Sdumbbell	0x00000000, /* SQ_PGM_START_FS */
198254885Sdumbbell	0x00000000,
199254885Sdumbbell
200254885Sdumbbell	0xc0016900,
201254885Sdumbbell	0x0000023b,
202254885Sdumbbell	0x00000000, /* SQ_LDS_ALLOC_PS */
203254885Sdumbbell
204254885Sdumbbell	0xc0066900,
205254885Sdumbbell	0x00000240,
206254885Sdumbbell	0x00000000, /* SQ_ESGS_RING_ITEMSIZE */
207254885Sdumbbell	0x00000000,
208254885Sdumbbell	0x00000000,
209254885Sdumbbell	0x00000000,
210254885Sdumbbell	0x00000000,
211254885Sdumbbell	0x00000000,
212254885Sdumbbell
213254885Sdumbbell	0xc0046900,
214254885Sdumbbell	0x00000247,
215254885Sdumbbell	0x00000000, /* SQ_GS_VERT_ITEMSIZE */
216254885Sdumbbell	0x00000000,
217254885Sdumbbell	0x00000000,
218254885Sdumbbell	0x00000000,
219254885Sdumbbell
220254885Sdumbbell	0xc0116900,
221254885Sdumbbell	0x00000280,
222254885Sdumbbell	0x00000000, /* PA_SU_POINT_SIZE */
223254885Sdumbbell	0x00000000, /* PA_SU_POINT_MINMAX */
224254885Sdumbbell	0x00000008, /* PA_SU_LINE_CNTL */
225254885Sdumbbell	0x00000000, /* PA_SC_LINE_STIPPLE */
226254885Sdumbbell	0x00000000, /* VGT_OUTPUT_PATH_CNTL */
227254885Sdumbbell	0x00000000, /* VGT_HOS_CNTL */
228254885Sdumbbell	0x00000000,
229254885Sdumbbell	0x00000000,
230254885Sdumbbell	0x00000000,
231254885Sdumbbell	0x00000000,
232254885Sdumbbell	0x00000000,
233254885Sdumbbell	0x00000000,
234254885Sdumbbell	0x00000000,
235254885Sdumbbell	0x00000000,
236254885Sdumbbell	0x00000000,
237254885Sdumbbell	0x00000000,
238254885Sdumbbell	0x00000000, /* VGT_GS_MODE */
239254885Sdumbbell
240254885Sdumbbell	0xc0026900,
241254885Sdumbbell	0x00000292,
242254885Sdumbbell	0x00000000, /* PA_SC_MODE_CNTL_0 */
243254885Sdumbbell	0x00000000, /* PA_SC_MODE_CNTL_1 */
244254885Sdumbbell
245254885Sdumbbell	0xc0016900,
246254885Sdumbbell	0x000002a1,
247254885Sdumbbell	0x00000000, /* VGT_PRIMITIVEID_EN */
248254885Sdumbbell
249254885Sdumbbell	0xc0016900,
250254885Sdumbbell	0x000002a5,
251254885Sdumbbell	0x00000000, /* VGT_MULTI_PRIM_IB_RESET_EN */
252254885Sdumbbell
253254885Sdumbbell	0xc0026900,
254254885Sdumbbell	0x000002a8,
255254885Sdumbbell	0x00000000, /* VGT_INSTANCE_STEP_RATE_0 */
256254885Sdumbbell	0x00000000,
257254885Sdumbbell
258254885Sdumbbell	0xc0026900,
259254885Sdumbbell	0x000002ad,
260254885Sdumbbell	0x00000000, /* VGT_REUSE_OFF */
261254885Sdumbbell	0x00000000,
262254885Sdumbbell
263254885Sdumbbell	0xc0016900,
264254885Sdumbbell	0x000002d5,
265254885Sdumbbell	0x00000000, /* VGT_SHADER_STAGES_EN */
266254885Sdumbbell
267254885Sdumbbell	0xc0016900,
268254885Sdumbbell	0x000002dc,
269254885Sdumbbell	0x0000aa00, /* DB_ALPHA_TO_MASK */
270254885Sdumbbell
271254885Sdumbbell	0xc0066900,
272254885Sdumbbell	0x000002de,
273254885Sdumbbell	0x00000000, /* PA_SU_POLY_OFFSET_DB_FMT_CNTL */
274254885Sdumbbell	0x00000000,
275254885Sdumbbell	0x00000000,
276254885Sdumbbell	0x00000000,
277254885Sdumbbell	0x00000000,
278254885Sdumbbell	0x00000000,
279254885Sdumbbell
280254885Sdumbbell	0xc0026900,
281254885Sdumbbell	0x000002e5,
282254885Sdumbbell	0x00000000, /* VGT_STRMOUT_CONFIG */
283254885Sdumbbell	0x00000000,
284254885Sdumbbell
285254885Sdumbbell	0xc01b6900,
286254885Sdumbbell	0x000002f5,
287254885Sdumbbell	0x76543210, /* PA_SC_CENTROID_PRIORITY_0 */
288254885Sdumbbell	0xfedcba98, /* PA_SC_CENTROID_PRIORITY_1 */
289254885Sdumbbell	0x00000000, /* PA_SC_LINE_CNTL */
290254885Sdumbbell	0x00000000, /* PA_SC_AA_CONFIG */
291254885Sdumbbell	0x00000005, /* PA_SU_VTX_CNTL */
292254885Sdumbbell	0x3f800000, /* PA_CL_GB_VERT_CLIP_ADJ */
293254885Sdumbbell	0x3f800000, /* PA_CL_GB_VERT_DISC_ADJ */
294254885Sdumbbell	0x3f800000, /* PA_CL_GB_HORZ_CLIP_ADJ */
295254885Sdumbbell	0x3f800000, /* PA_CL_GB_HORZ_DISC_ADJ */
296254885Sdumbbell	0x00000000, /* PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_0 */
297254885Sdumbbell	0x00000000,
298254885Sdumbbell	0x00000000,
299254885Sdumbbell	0x00000000,
300254885Sdumbbell	0x00000000,
301254885Sdumbbell	0x00000000,
302254885Sdumbbell	0x00000000,
303254885Sdumbbell	0x00000000,
304254885Sdumbbell	0x00000000,
305254885Sdumbbell	0x00000000,
306254885Sdumbbell	0x00000000,
307254885Sdumbbell	0x00000000,
308254885Sdumbbell	0x00000000,
309254885Sdumbbell	0x00000000,
310254885Sdumbbell	0x00000000,
311254885Sdumbbell	0x00000000,
312254885Sdumbbell	0xffffffff, /* PA_SC_AA_MASK_X0Y0_X1Y0 */
313254885Sdumbbell	0xffffffff,
314254885Sdumbbell
315254885Sdumbbell	0xc0026900,
316254885Sdumbbell	0x00000316,
317254885Sdumbbell	0x0000000e, /* VGT_VERTEX_REUSE_BLOCK_CNTL */
318254885Sdumbbell	0x00000010, /*  */
319254885Sdumbbell};
320254885Sdumbbell
321254885Sdumbbellconst u32 cayman_vs[] =
322254885Sdumbbell{
323254885Sdumbbell	0x00000004,
324254885Sdumbbell	0x80400400,
325254885Sdumbbell	0x0000a03c,
326254885Sdumbbell	0x95000688,
327254885Sdumbbell	0x00004000,
328254885Sdumbbell	0x15000688,
329254885Sdumbbell	0x00000000,
330254885Sdumbbell	0x88000000,
331254885Sdumbbell	0x04000000,
332254885Sdumbbell	0x67961001,
333254885Sdumbbell#ifdef __BIG_ENDIAN
334254885Sdumbbell	0x00020000,
335254885Sdumbbell#else
336254885Sdumbbell	0x00000000,
337254885Sdumbbell#endif
338254885Sdumbbell	0x00000000,
339254885Sdumbbell	0x04000000,
340254885Sdumbbell	0x67961000,
341254885Sdumbbell#ifdef __BIG_ENDIAN
342254885Sdumbbell	0x00020008,
343254885Sdumbbell#else
344254885Sdumbbell	0x00000008,
345254885Sdumbbell#endif
346254885Sdumbbell	0x00000000,
347254885Sdumbbell};
348254885Sdumbbell
349254885Sdumbbellconst u32 cayman_ps[] =
350254885Sdumbbell{
351254885Sdumbbell	0x00000004,
352254885Sdumbbell	0xa00c0000,
353254885Sdumbbell	0x00000008,
354254885Sdumbbell	0x80400000,
355254885Sdumbbell	0x00000000,
356254885Sdumbbell	0x95000688,
357254885Sdumbbell	0x00000000,
358254885Sdumbbell	0x88000000,
359254885Sdumbbell	0x00380400,
360254885Sdumbbell	0x00146b10,
361254885Sdumbbell	0x00380000,
362254885Sdumbbell	0x20146b10,
363254885Sdumbbell	0x00380400,
364254885Sdumbbell	0x40146b00,
365254885Sdumbbell	0x80380000,
366254885Sdumbbell	0x60146b00,
367254885Sdumbbell	0x00000010,
368254885Sdumbbell	0x000d1000,
369254885Sdumbbell	0xb0800000,
370254885Sdumbbell	0x00000000,
371254885Sdumbbell};
372254885Sdumbbell
373254885Sdumbbellconst u32 cayman_ps_size = DRM_ARRAY_SIZE(cayman_ps);
374254885Sdumbbellconst u32 cayman_vs_size = DRM_ARRAY_SIZE(cayman_vs);
375254885Sdumbbellconst u32 cayman_default_size = DRM_ARRAY_SIZE(cayman_default_state);
376