Set memory attributes on page
[pscnv.git] / pscnv / nv50_grctx.c
blob9edecceb9eb76b6bbae6921f40ded00ae62fe85a
1 /*
2 * Copyright 2009 Marcin Koƛcielnicki
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 shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
23 #define CP_FLAG_CLEAR 0
24 #define CP_FLAG_SET 1
25 #define CP_FLAG_SWAP_DIRECTION ((0 * 32) + 0)
26 #define CP_FLAG_SWAP_DIRECTION_LOAD 0
27 #define CP_FLAG_SWAP_DIRECTION_SAVE 1
28 #define CP_FLAG_UNK01 ((0 * 32) + 1)
29 #define CP_FLAG_UNK01_CLEAR 0
30 #define CP_FLAG_UNK01_SET 1
31 #define CP_FLAG_UNK03 ((0 * 32) + 3)
32 #define CP_FLAG_UNK03_CLEAR 0
33 #define CP_FLAG_UNK03_SET 1
34 #define CP_FLAG_USER_SAVE ((0 * 32) + 5)
35 #define CP_FLAG_USER_SAVE_NOT_PENDING 0
36 #define CP_FLAG_USER_SAVE_PENDING 1
37 #define CP_FLAG_USER_LOAD ((0 * 32) + 6)
38 #define CP_FLAG_USER_LOAD_NOT_PENDING 0
39 #define CP_FLAG_USER_LOAD_PENDING 1
40 #define CP_FLAG_UNK0B ((0 * 32) + 0xb)
41 #define CP_FLAG_UNK0B_CLEAR 0
42 #define CP_FLAG_UNK0B_SET 1
43 #define CP_FLAG_UNK1D ((0 * 32) + 0x1d)
44 #define CP_FLAG_UNK1D_CLEAR 0
45 #define CP_FLAG_UNK1D_SET 1
46 #define CP_FLAG_SYNC_ACK ((0 * 32) + 0x1f)
47 #define CP_FLAG_SYNC_ACK_FALSE 0
48 #define CP_FLAG_SYNC_ACK_TRUE 1
49 #define CP_FLAG_UNK20 ((1 * 32) + 0)
50 #define CP_FLAG_UNK20_CLEAR 0
51 #define CP_FLAG_UNK20_SET 1
52 #define CP_FLAG_STATUS ((2 * 32) + 0)
53 #define CP_FLAG_STATUS_BUSY 0
54 #define CP_FLAG_STATUS_IDLE 1
55 #define CP_FLAG_AUTO_SAVE ((2 * 32) + 4)
56 #define CP_FLAG_AUTO_SAVE_NOT_PENDING 0
57 #define CP_FLAG_AUTO_SAVE_PENDING 1
58 #define CP_FLAG_AUTO_LOAD ((2 * 32) + 5)
59 #define CP_FLAG_AUTO_LOAD_NOT_PENDING 0
60 #define CP_FLAG_AUTO_LOAD_PENDING 1
61 #define CP_FLAG_NEWCTX ((2 * 32) + 10)
62 #define CP_FLAG_NEWCTX_BUSY 0
63 #define CP_FLAG_NEWCTX_DONE 1
64 #define CP_FLAG_XFER ((2 * 32) + 11)
65 #define CP_FLAG_XFER_IDLE 0
66 #define CP_FLAG_XFER_BUSY 1
67 #define CP_FLAG_ALWAYS ((2 * 32) + 13)
68 #define CP_FLAG_ALWAYS_FALSE 0
69 #define CP_FLAG_ALWAYS_TRUE 1
70 #define CP_FLAG_INTR ((2 * 32) + 15)
71 #define CP_FLAG_INTR_NOT_PENDING 0
72 #define CP_FLAG_INTR_PENDING 1
73 #define CP_FLAG_SYNC_REQ ((3 * 32) + 0)
74 #define CP_FLAG_SYNC_REQ_FALSE 0
75 #define CP_FLAG_SYNC_REQ_TRUE 1
77 #define CP_CTX 0x00100000
78 #define CP_CTX_COUNT 0x000f0000
79 #define CP_CTX_COUNT_SHIFT 16
80 #define CP_CTX_REG 0x00003fff
81 #define CP_LOAD_SR 0x00200000
82 #define CP_LOAD_SR_VALUE 0x000fffff
83 #define CP_BRA 0x00400000
84 #define CP_BRA_IP 0x0001ff00
85 #define CP_BRA_IP_SHIFT 8
86 #define CP_BRA_IF_CLEAR 0x00000080
87 #define CP_BRA_FLAG 0x0000007f
88 #define CP_WAIT 0x00500000
89 #define CP_WAIT_SET 0x00000080
90 #define CP_WAIT_FLAG 0x0000007f
91 #define CP_SET 0x00700000
92 #define CP_SET_1 0x00000080
93 #define CP_SET_FLAG 0x0000007f
94 #define CP_NEWCTX 0x00600004
95 #define CP_NEXT_TO_SWAP 0x00600005
96 #define CP_SET_CONTEXT_POINTER 0x00600006
97 #define CP_SET_XFER_POINTER 0x00600007
98 #define CP_ENABLE 0x00600009
99 #define CP_END 0x0060000c
100 #define CP_NEXT_TO_CURRENT 0x0060000d
101 #define CP_DISABLE1 0x0090ffff
102 #define CP_DISABLE2 0x0091ffff
103 #define CP_XFER_1 0x008000ff
104 #define CP_XFER_2 0x008800ff
105 #define CP_SEEK_1 0x00c000ff
106 #define CP_SEEK_2 0x00c800ff
108 #include "nouveau_drv.h"
109 #include "nouveau_grctx.h"
111 #define IS_NVA3F(x) (((x) > 0xa0 && (x) < 0xaa) || (x) == 0xaf)
112 #define IS_NVAAF(x) ((x) >= 0xaa && (x) <= 0xac)
115 * This code deals with PGRAPH contexts on NV50 family cards. Like NV40, it's
116 * the GPU itself that does context-switching, but it needs a special
117 * microcode to do it. And it's the driver's task to supply this microcode,
118 * further known as ctxprog, as well as the initial context values, known
119 * as ctxvals.
121 * Without ctxprog, you cannot switch contexts. Not even in software, since
122 * the majority of context [xfer strands] isn't accessible directly. You're
123 * stuck with a single channel, and you also suffer all the problems resulting
124 * from missing ctxvals, since you cannot load them.
126 * Without ctxvals, you're stuck with PGRAPH's default context. It's enough to
127 * run 2d operations, but trying to utilise 3d or CUDA will just lock you up,
128 * since you don't have... some sort of needed setup.
130 * Nouveau will just disable acceleration if not given ctxprog + ctxvals, since
131 * it's too much hassle to handle no-ctxprog as a special case.
135 * How ctxprogs work.
137 * The ctxprog is written in its own kind of microcode, with very small and
138 * crappy set of available commands. You upload it to a small [512 insns]
139 * area of memory on PGRAPH, and it'll be run when PFIFO wants PGRAPH to
140 * switch channel. or when the driver explicitely requests it. Stuff visible
141 * to ctxprog consists of: PGRAPH MMIO registers, PGRAPH context strands,
142 * the per-channel context save area in VRAM [known as ctxvals or grctx],
143 * 4 flags registers, a scratch register, two grctx pointers, plus many
144 * random poorly-understood details.
146 * When ctxprog runs, it's supposed to check what operations are asked of it,
147 * save old context if requested, optionally reset PGRAPH and switch to the
148 * new channel, and load the new context. Context consists of three major
149 * parts: subset of MMIO registers and two "xfer areas".
152 /* TODO:
153 * - document unimplemented bits compared to nvidia
154 * - NVAx: make a TP subroutine, use it.
155 * - use 0x4008fc instead of 0x1540?
158 enum cp_label {
159 cp_check_load = 1,
160 cp_setup_auto_load,
161 cp_setup_load,
162 cp_setup_save,
163 cp_swap_state,
164 cp_prepare_exit,
165 cp_exit,
166 cp_sync,
169 static void nv50_graph_construct_mmio(struct nouveau_grctx *ctx);
170 static void nv50_graph_construct_xfer1(struct nouveau_grctx *ctx);
171 static void nv50_graph_construct_xfer2(struct nouveau_grctx *ctx);
173 /* Main function: construct the ctxprog skeleton, call the other functions. */
176 nv50_grctx_init(struct nouveau_grctx *ctx)
178 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
180 switch (dev_priv->chipset) {
181 case 0x50:
182 case 0x84:
183 case 0x86:
184 case 0x92:
185 case 0x94:
186 case 0x96:
187 case 0x98:
188 case 0xa0:
189 case 0xa3:
190 case 0xa5:
191 case 0xa8:
192 case 0xaa:
193 case 0xac:
194 case 0xaf:
195 break;
196 default:
197 NV_ERROR(ctx->dev, "I don't know how to make a ctxprog for "
198 "your NV%x card.\n", dev_priv->chipset);
199 NV_ERROR(ctx->dev, "Disabling acceleration. Please contact "
200 "the devs.\n");
201 return -ENOSYS;
203 /* decide whether we're loading/unloading the context */
204 cp_bra (ctx, AUTO_SAVE, PENDING, cp_setup_save);
205 cp_bra (ctx, USER_SAVE, PENDING, cp_setup_save);
207 cp_name(ctx, cp_check_load);
208 cp_bra (ctx, AUTO_LOAD, PENDING, cp_setup_auto_load);
209 cp_bra (ctx, USER_LOAD, PENDING, cp_setup_load);
210 cp_bra (ctx, ALWAYS, TRUE, cp_exit);
212 /* setup for context load */
213 cp_name(ctx, cp_setup_auto_load);
214 cp_out (ctx, CP_DISABLE1);
215 cp_out (ctx, CP_DISABLE2);
216 cp_out (ctx, CP_ENABLE);
217 cp_out (ctx, CP_NEXT_TO_SWAP);
218 cp_set (ctx, UNK01, SET);
219 cp_name(ctx, cp_setup_load);
220 cp_out (ctx, CP_NEWCTX);
221 cp_wait(ctx, NEWCTX, BUSY);
222 cp_set (ctx, UNK1D, CLEAR);
223 cp_set (ctx, SWAP_DIRECTION, LOAD);
224 cp_bra (ctx, UNK0B, SET, cp_prepare_exit);
225 cp_bra (ctx, ALWAYS, TRUE, cp_swap_state);
227 cp_name(ctx, cp_sync);
228 cp_set (ctx, SYNC_ACK, TRUE);
229 cp_bra (ctx, SYNC_REQ, TRUE, cp_sync);
230 cp_set (ctx, SYNC_ACK, FALSE);
231 cp_bra (ctx, SYNC_REQ, TRUE, cp_sync);
233 /* setup for context save */
234 cp_name(ctx, cp_setup_save);
235 cp_set (ctx, UNK1D, SET);
236 cp_bra (ctx, SYNC_REQ, TRUE, cp_sync);
237 cp_bra (ctx, INTR, PENDING, cp_setup_save);
238 cp_bra (ctx, STATUS, BUSY, cp_setup_save);
239 cp_set (ctx, UNK01, SET);
240 cp_set (ctx, SWAP_DIRECTION, SAVE);
242 /* general PGRAPH state */
243 cp_name(ctx, cp_swap_state);
244 cp_set (ctx, UNK03, SET);
245 cp_pos (ctx, 0x00004/4);
246 cp_ctx (ctx, 0x400828, 1); /* needed. otherwise, flickering happens. */
247 cp_pos (ctx, 0x00100/4);
248 nv50_graph_construct_mmio(ctx);
249 nv50_graph_construct_xfer1(ctx);
250 nv50_graph_construct_xfer2(ctx);
252 cp_bra (ctx, SWAP_DIRECTION, SAVE, cp_check_load);
254 cp_set (ctx, UNK20, SET);
255 cp_set (ctx, SWAP_DIRECTION, SAVE); /* no idea why this is needed, but fixes at least one lockup. */
256 cp_lsr (ctx, ctx->ctxvals_base);
257 cp_out (ctx, CP_SET_XFER_POINTER);
258 cp_lsr (ctx, 4);
259 cp_out (ctx, CP_SEEK_1);
260 cp_out (ctx, CP_XFER_1);
261 cp_wait(ctx, XFER, BUSY);
263 /* pre-exit state updates */
264 cp_name(ctx, cp_prepare_exit);
265 cp_set (ctx, UNK01, CLEAR);
266 cp_set (ctx, UNK03, CLEAR);
267 cp_set (ctx, UNK1D, CLEAR);
269 cp_bra (ctx, USER_SAVE, PENDING, cp_exit);
270 cp_out (ctx, CP_NEXT_TO_CURRENT);
272 cp_name(ctx, cp_exit);
273 cp_set (ctx, USER_SAVE, NOT_PENDING);
274 cp_set (ctx, USER_LOAD, NOT_PENDING);
275 cp_out (ctx, CP_END);
276 ctx->ctxvals_pos += 0x400; /* padding... no idea why you need it */
278 return 0;
282 * Constructs MMIO part of ctxprog and ctxvals. Just a matter of knowing which
283 * registers to save/restore and the default values for them.
286 static void
287 nv50_graph_construct_mmio_ddata(struct nouveau_grctx *ctx);
289 static void
290 nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
292 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
293 int i, j;
294 int offset, base;
295 uint32_t units = nv_rd32 (ctx->dev, 0x1540);
297 /* 0800: DISPATCH */
298 cp_ctx(ctx, 0x400808, 7);
299 gr_def(ctx, 0x400814, 0x00000030);
300 cp_ctx(ctx, 0x400834, 0x32);
301 if (dev_priv->chipset == 0x50) {
302 gr_def(ctx, 0x400834, 0xff400040);
303 gr_def(ctx, 0x400838, 0xfff00080);
304 gr_def(ctx, 0x40083c, 0xfff70090);
305 gr_def(ctx, 0x400840, 0xffe806a8);
307 gr_def(ctx, 0x400844, 0x00000002);
308 if (IS_NVA3F(dev_priv->chipset))
309 gr_def(ctx, 0x400894, 0x00001000);
310 gr_def(ctx, 0x4008e8, 0x00000003);
311 gr_def(ctx, 0x4008ec, 0x00001000);
312 if (dev_priv->chipset == 0x50)
313 cp_ctx(ctx, 0x400908, 0xb);
314 else if (dev_priv->chipset < 0xa0)
315 cp_ctx(ctx, 0x400908, 0xc);
316 else
317 cp_ctx(ctx, 0x400908, 0xe);
319 if (dev_priv->chipset >= 0xa0)
320 cp_ctx(ctx, 0x400b00, 0x1);
321 if (IS_NVA3F(dev_priv->chipset)) {
322 cp_ctx(ctx, 0x400b10, 0x1);
323 gr_def(ctx, 0x400b10, 0x0001629d);
324 cp_ctx(ctx, 0x400b20, 0x1);
325 gr_def(ctx, 0x400b20, 0x0001629d);
328 nv50_graph_construct_mmio_ddata(ctx);
330 /* 0C00: VFETCH */
331 cp_ctx(ctx, 0x400c08, 0x2);
332 gr_def(ctx, 0x400c08, 0x0000fe0c);
334 /* 1000 */
335 if (dev_priv->chipset < 0xa0) {
336 cp_ctx(ctx, 0x401008, 0x4);
337 gr_def(ctx, 0x401014, 0x00001000);
338 } else if (!IS_NVA3F(dev_priv->chipset)) {
339 cp_ctx(ctx, 0x401008, 0x5);
340 gr_def(ctx, 0x401018, 0x00001000);
341 } else {
342 cp_ctx(ctx, 0x401008, 0x5);
343 gr_def(ctx, 0x401018, 0x00004000);
346 /* 1400 */
347 cp_ctx(ctx, 0x401400, 0x8);
348 cp_ctx(ctx, 0x401424, 0x3);
349 if (dev_priv->chipset == 0x50)
350 gr_def(ctx, 0x40142c, 0x0001fd87);
351 else
352 gr_def(ctx, 0x40142c, 0x00000187);
353 cp_ctx(ctx, 0x401540, 0x5);
354 gr_def(ctx, 0x401550, 0x00001018);
356 /* 1800: STREAMOUT */
357 cp_ctx(ctx, 0x401814, 0x1);
358 gr_def(ctx, 0x401814, 0x000000ff);
359 if (dev_priv->chipset == 0x50) {
360 cp_ctx(ctx, 0x40181c, 0xe);
361 gr_def(ctx, 0x401850, 0x00000004);
362 } else if (dev_priv->chipset < 0xa0) {
363 cp_ctx(ctx, 0x40181c, 0xf);
364 gr_def(ctx, 0x401854, 0x00000004);
365 } else {
366 cp_ctx(ctx, 0x40181c, 0x13);
367 gr_def(ctx, 0x401864, 0x00000004);
370 /* 1C00 */
371 cp_ctx(ctx, 0x401c00, 0x1);
372 switch (dev_priv->chipset) {
373 case 0x50:
374 gr_def(ctx, 0x401c00, 0x0001005f);
375 break;
376 case 0x84:
377 case 0x86:
378 case 0x94:
379 gr_def(ctx, 0x401c00, 0x044d00df);
380 break;
381 case 0x92:
382 case 0x96:
383 case 0x98:
384 case 0xa0:
385 case 0xaa:
386 case 0xac:
387 gr_def(ctx, 0x401c00, 0x042500df);
388 break;
389 case 0xa3:
390 case 0xa5:
391 case 0xa8:
392 case 0xaf:
393 gr_def(ctx, 0x401c00, 0x142500df);
394 break;
397 /* 2000 */
399 /* 2400 */
400 cp_ctx(ctx, 0x402400, 0x1);
401 if (dev_priv->chipset == 0x50)
402 cp_ctx(ctx, 0x402408, 0x1);
403 else
404 cp_ctx(ctx, 0x402408, 0x2);
405 gr_def(ctx, 0x402408, 0x00000600);
407 /* 2800: CSCHED */
408 cp_ctx(ctx, 0x402800, 0x1);
409 if (dev_priv->chipset == 0x50)
410 gr_def(ctx, 0x402800, 0x00000006);
412 /* 2C00: ZCULL */
413 cp_ctx(ctx, 0x402c08, 0x6);
414 if (dev_priv->chipset != 0x50)
415 gr_def(ctx, 0x402c14, 0x01000000);
416 gr_def(ctx, 0x402c18, 0x000000ff);
417 if (dev_priv->chipset == 0x50)
418 cp_ctx(ctx, 0x402ca0, 0x1);
419 else
420 cp_ctx(ctx, 0x402ca0, 0x2);
421 if (dev_priv->chipset < 0xa0)
422 gr_def(ctx, 0x402ca0, 0x00000400);
423 else if (!IS_NVA3F(dev_priv->chipset))
424 gr_def(ctx, 0x402ca0, 0x00000800);
425 else
426 gr_def(ctx, 0x402ca0, 0x00000400);
427 cp_ctx(ctx, 0x402cac, 0x4);
429 /* 3000: ENG2D */
430 cp_ctx(ctx, 0x403004, 0x1);
431 gr_def(ctx, 0x403004, 0x00000001);
433 /* 3400 */
434 if (dev_priv->chipset >= 0xa0) {
435 cp_ctx(ctx, 0x403404, 0x1);
436 gr_def(ctx, 0x403404, 0x00000001);
439 /* 5000: CCACHE */
440 cp_ctx(ctx, 0x405000, 0x1);
441 switch (dev_priv->chipset) {
442 case 0x50:
443 gr_def(ctx, 0x405000, 0x00300080);
444 break;
445 case 0x84:
446 case 0xa0:
447 case 0xa3:
448 case 0xa5:
449 case 0xa8:
450 case 0xaa:
451 case 0xac:
452 case 0xaf:
453 gr_def(ctx, 0x405000, 0x000e0080);
454 break;
455 case 0x86:
456 case 0x92:
457 case 0x94:
458 case 0x96:
459 case 0x98:
460 gr_def(ctx, 0x405000, 0x00000080);
461 break;
463 cp_ctx(ctx, 0x405014, 0x1);
464 gr_def(ctx, 0x405014, 0x00000004);
465 cp_ctx(ctx, 0x40501c, 0x1);
466 cp_ctx(ctx, 0x405024, 0x1);
467 cp_ctx(ctx, 0x40502c, 0x1);
469 /* 6000? */
470 if (dev_priv->chipset == 0x50)
471 cp_ctx(ctx, 0x4063e0, 0x1);
473 /* 6800: M2MF */
474 if (dev_priv->chipset < 0x90) {
475 cp_ctx(ctx, 0x406814, 0x2b);
476 gr_def(ctx, 0x406818, 0x00000f80);
477 gr_def(ctx, 0x406860, 0x007f0080);
478 gr_def(ctx, 0x40689c, 0x007f0080);
479 } else {
480 cp_ctx(ctx, 0x406814, 0x4);
481 if (dev_priv->chipset == 0x98)
482 gr_def(ctx, 0x406818, 0x00000f80);
483 else
484 gr_def(ctx, 0x406818, 0x00001f80);
485 if (IS_NVA3F(dev_priv->chipset))
486 gr_def(ctx, 0x40681c, 0x00000030);
487 cp_ctx(ctx, 0x406830, 0x3);
490 /* 7000: per-ROP group state */
491 for (i = 0; i < 8; i++) {
492 if (units & (1<<(i+16))) {
493 cp_ctx(ctx, 0x407000 + (i<<8), 3);
494 if (dev_priv->chipset == 0x50)
495 gr_def(ctx, 0x407000 + (i<<8), 0x1b74f820);
496 else if (dev_priv->chipset != 0xa5)
497 gr_def(ctx, 0x407000 + (i<<8), 0x3b74f821);
498 else
499 gr_def(ctx, 0x407000 + (i<<8), 0x7b74f821);
500 gr_def(ctx, 0x407004 + (i<<8), 0x89058001);
502 if (dev_priv->chipset == 0x50) {
503 cp_ctx(ctx, 0x407010 + (i<<8), 1);
504 } else if (dev_priv->chipset < 0xa0) {
505 cp_ctx(ctx, 0x407010 + (i<<8), 2);
506 gr_def(ctx, 0x407010 + (i<<8), 0x00001000);
507 gr_def(ctx, 0x407014 + (i<<8), 0x0000001f);
508 } else {
509 cp_ctx(ctx, 0x407010 + (i<<8), 3);
510 gr_def(ctx, 0x407010 + (i<<8), 0x00001000);
511 if (dev_priv->chipset != 0xa5)
512 gr_def(ctx, 0x407014 + (i<<8), 0x000000ff);
513 else
514 gr_def(ctx, 0x407014 + (i<<8), 0x000001ff);
517 cp_ctx(ctx, 0x407080 + (i<<8), 4);
518 if (dev_priv->chipset != 0xa5)
519 gr_def(ctx, 0x407080 + (i<<8), 0x027c10fa);
520 else
521 gr_def(ctx, 0x407080 + (i<<8), 0x827c10fa);
522 if (dev_priv->chipset == 0x50)
523 gr_def(ctx, 0x407084 + (i<<8), 0x000000c0);
524 else
525 gr_def(ctx, 0x407084 + (i<<8), 0x400000c0);
526 gr_def(ctx, 0x407088 + (i<<8), 0xb7892080);
528 if (dev_priv->chipset < 0xa0)
529 cp_ctx(ctx, 0x407094 + (i<<8), 1);
530 else if (!IS_NVA3F(dev_priv->chipset))
531 cp_ctx(ctx, 0x407094 + (i<<8), 3);
532 else {
533 cp_ctx(ctx, 0x407094 + (i<<8), 4);
534 gr_def(ctx, 0x4070a0 + (i<<8), 1);
539 cp_ctx(ctx, 0x407c00, 0x3);
540 if (dev_priv->chipset < 0x90)
541 gr_def(ctx, 0x407c00, 0x00010040);
542 else if (dev_priv->chipset < 0xa0)
543 gr_def(ctx, 0x407c00, 0x00390040);
544 else
545 gr_def(ctx, 0x407c00, 0x003d0040);
546 gr_def(ctx, 0x407c08, 0x00000022);
547 if (dev_priv->chipset >= 0xa0) {
548 cp_ctx(ctx, 0x407c10, 0x3);
549 cp_ctx(ctx, 0x407c20, 0x1);
550 cp_ctx(ctx, 0x407c2c, 0x1);
553 if (dev_priv->chipset < 0xa0) {
554 cp_ctx(ctx, 0x407d00, 0x9);
555 } else {
556 cp_ctx(ctx, 0x407d00, 0x15);
558 if (dev_priv->chipset == 0x98)
559 gr_def(ctx, 0x407d08, 0x00380040);
560 else {
561 if (dev_priv->chipset < 0x90)
562 gr_def(ctx, 0x407d08, 0x00010040);
563 else if (dev_priv->chipset < 0xa0)
564 gr_def(ctx, 0x407d08, 0x00390040);
565 else
566 gr_def(ctx, 0x407d08, 0x003d0040);
567 gr_def(ctx, 0x407d0c, 0x00000022);
570 /* 8000+: per-TP state */
571 for (i = 0; i < 10; i++) {
572 if (units & (1<<i)) {
573 if (dev_priv->chipset < 0xa0)
574 base = 0x408000 + (i<<12);
575 else
576 base = 0x408000 + (i<<11);
577 if (dev_priv->chipset < 0xa0)
578 offset = base + 0xc00;
579 else
580 offset = base + 0x80;
581 cp_ctx(ctx, offset + 0x00, 1);
582 gr_def(ctx, offset + 0x00, 0x0000ff0a);
583 cp_ctx(ctx, offset + 0x08, 1);
585 /* per-MP state */
586 for (j = 0; j < (dev_priv->chipset < 0xa0 ? 2 : 4); j++) {
587 if (!(units & (1 << (j+24)))) continue;
588 if (dev_priv->chipset < 0xa0)
589 offset = base + 0x200 + (j<<7);
590 else
591 offset = base + 0x100 + (j<<7);
592 cp_ctx(ctx, offset, 0x20);
593 gr_def(ctx, offset + 0x00, 0x01800000);
594 gr_def(ctx, offset + 0x04, 0x00160000);
595 gr_def(ctx, offset + 0x08, 0x01800000);
596 gr_def(ctx, offset + 0x18, 0x0003ffff);
597 switch (dev_priv->chipset) {
598 case 0x50:
599 gr_def(ctx, offset + 0x1c, 0x00080000);
600 break;
601 case 0x84:
602 gr_def(ctx, offset + 0x1c, 0x00880000);
603 break;
604 case 0x86:
605 gr_def(ctx, offset + 0x1c, 0x008c0000);
606 break;
607 case 0x92:
608 case 0x96:
609 case 0x98:
610 gr_def(ctx, offset + 0x1c, 0x118c0000);
611 break;
612 case 0x94:
613 gr_def(ctx, offset + 0x1c, 0x10880000);
614 break;
615 case 0xa0:
616 case 0xa5:
617 gr_def(ctx, offset + 0x1c, 0x310c0000);
618 break;
619 case 0xa3:
620 case 0xa8:
621 case 0xaa:
622 case 0xac:
623 case 0xaf:
624 gr_def(ctx, offset + 0x1c, 0x300c0000);
625 break;
627 gr_def(ctx, offset + 0x40, 0x00010401);
628 if (dev_priv->chipset == 0x50)
629 gr_def(ctx, offset + 0x48, 0x00000040);
630 else
631 gr_def(ctx, offset + 0x48, 0x00000078);
632 gr_def(ctx, offset + 0x50, 0x000000bf);
633 gr_def(ctx, offset + 0x58, 0x00001210);
634 if (dev_priv->chipset == 0x50)
635 gr_def(ctx, offset + 0x5c, 0x00000080);
636 else
637 gr_def(ctx, offset + 0x5c, 0x08000080);
638 if (dev_priv->chipset >= 0xa0)
639 gr_def(ctx, offset + 0x68, 0x0000003e);
642 if (dev_priv->chipset < 0xa0)
643 cp_ctx(ctx, base + 0x300, 0x4);
644 else
645 cp_ctx(ctx, base + 0x300, 0x5);
646 if (dev_priv->chipset == 0x50)
647 gr_def(ctx, base + 0x304, 0x00007070);
648 else if (dev_priv->chipset < 0xa0)
649 gr_def(ctx, base + 0x304, 0x00027070);
650 else if (!IS_NVA3F(dev_priv->chipset))
651 gr_def(ctx, base + 0x304, 0x01127070);
652 else
653 gr_def(ctx, base + 0x304, 0x05127070);
655 if (dev_priv->chipset < 0xa0)
656 cp_ctx(ctx, base + 0x318, 1);
657 else
658 cp_ctx(ctx, base + 0x320, 1);
659 if (dev_priv->chipset == 0x50)
660 gr_def(ctx, base + 0x318, 0x0003ffff);
661 else if (dev_priv->chipset < 0xa0)
662 gr_def(ctx, base + 0x318, 0x03ffffff);
663 else
664 gr_def(ctx, base + 0x320, 0x07ffffff);
666 if (dev_priv->chipset < 0xa0)
667 cp_ctx(ctx, base + 0x324, 5);
668 else
669 cp_ctx(ctx, base + 0x328, 4);
671 if (dev_priv->chipset < 0xa0) {
672 cp_ctx(ctx, base + 0x340, 9);
673 offset = base + 0x340;
674 } else if (!IS_NVA3F(dev_priv->chipset)) {
675 cp_ctx(ctx, base + 0x33c, 0xb);
676 offset = base + 0x344;
677 } else {
678 cp_ctx(ctx, base + 0x33c, 0xd);
679 offset = base + 0x344;
681 gr_def(ctx, offset + 0x0, 0x00120407);
682 gr_def(ctx, offset + 0x4, 0x05091507);
683 if (dev_priv->chipset == 0x84)
684 gr_def(ctx, offset + 0x8, 0x05100202);
685 else
686 gr_def(ctx, offset + 0x8, 0x05010202);
687 gr_def(ctx, offset + 0xc, 0x00030201);
688 if (dev_priv->chipset == 0xa3)
689 cp_ctx(ctx, base + 0x36c, 1);
691 cp_ctx(ctx, base + 0x400, 2);
692 gr_def(ctx, base + 0x404, 0x00000040);
693 cp_ctx(ctx, base + 0x40c, 2);
694 gr_def(ctx, base + 0x40c, 0x0d0c0b0a);
695 gr_def(ctx, base + 0x410, 0x00141210);
697 if (dev_priv->chipset < 0xa0)
698 offset = base + 0x800;
699 else
700 offset = base + 0x500;
701 cp_ctx(ctx, offset, 6);
702 gr_def(ctx, offset + 0x0, 0x000001f0);
703 gr_def(ctx, offset + 0x4, 0x00000001);
704 gr_def(ctx, offset + 0x8, 0x00000003);
705 if (dev_priv->chipset == 0x50 || IS_NVAAF(dev_priv->chipset))
706 gr_def(ctx, offset + 0xc, 0x00008000);
707 gr_def(ctx, offset + 0x14, 0x00039e00);
708 cp_ctx(ctx, offset + 0x1c, 2);
709 if (dev_priv->chipset == 0x50)
710 gr_def(ctx, offset + 0x1c, 0x00000040);
711 else
712 gr_def(ctx, offset + 0x1c, 0x00000100);
713 gr_def(ctx, offset + 0x20, 0x00003800);
715 if (dev_priv->chipset >= 0xa0) {
716 cp_ctx(ctx, base + 0x54c, 2);
717 if (!IS_NVA3F(dev_priv->chipset))
718 gr_def(ctx, base + 0x54c, 0x003fe006);
719 else
720 gr_def(ctx, base + 0x54c, 0x003fe007);
721 gr_def(ctx, base + 0x550, 0x003fe000);
724 if (dev_priv->chipset < 0xa0)
725 offset = base + 0xa00;
726 else
727 offset = base + 0x680;
728 cp_ctx(ctx, offset, 1);
729 gr_def(ctx, offset, 0x00404040);
731 if (dev_priv->chipset < 0xa0)
732 offset = base + 0xe00;
733 else
734 offset = base + 0x700;
735 cp_ctx(ctx, offset, 2);
736 if (dev_priv->chipset < 0xa0)
737 gr_def(ctx, offset, 0x0077f005);
738 else if (dev_priv->chipset == 0xa5)
739 gr_def(ctx, offset, 0x6cf7f007);
740 else if (dev_priv->chipset == 0xa8)
741 gr_def(ctx, offset, 0x6cfff007);
742 else if (dev_priv->chipset == 0xac)
743 gr_def(ctx, offset, 0x0cfff007);
744 else
745 gr_def(ctx, offset, 0x0cf7f007);
746 if (dev_priv->chipset == 0x50)
747 gr_def(ctx, offset + 0x4, 0x00007fff);
748 else if (dev_priv->chipset < 0xa0)
749 gr_def(ctx, offset + 0x4, 0x003f7fff);
750 else
751 gr_def(ctx, offset + 0x4, 0x02bf7fff);
752 cp_ctx(ctx, offset + 0x2c, 1);
753 if (dev_priv->chipset == 0x50) {
754 cp_ctx(ctx, offset + 0x50, 9);
755 gr_def(ctx, offset + 0x54, 0x000003ff);
756 gr_def(ctx, offset + 0x58, 0x00000003);
757 gr_def(ctx, offset + 0x5c, 0x00000003);
758 gr_def(ctx, offset + 0x60, 0x000001ff);
759 gr_def(ctx, offset + 0x64, 0x0000001f);
760 gr_def(ctx, offset + 0x68, 0x0000000f);
761 gr_def(ctx, offset + 0x6c, 0x0000000f);
762 } else if(dev_priv->chipset < 0xa0) {
763 cp_ctx(ctx, offset + 0x50, 1);
764 cp_ctx(ctx, offset + 0x70, 1);
765 } else {
766 cp_ctx(ctx, offset + 0x50, 1);
767 cp_ctx(ctx, offset + 0x60, 5);
773 static void
774 dd_emit(struct nouveau_grctx *ctx, int num, uint32_t val) {
775 int i;
776 if (val && ctx->mode == NOUVEAU_GRCTX_VALS)
777 for (i = 0; i < num; i++)
778 nv_wv32(ctx->data, 4 * (ctx->ctxvals_pos + i), val);
779 ctx->ctxvals_pos += num;
782 static void
783 nv50_graph_construct_mmio_ddata(struct nouveau_grctx *ctx)
785 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
786 int base, num;
787 base = ctx->ctxvals_pos;
789 /* tesla state */
790 dd_emit(ctx, 1, 0); /* 00000001 UNK0F90 */
791 dd_emit(ctx, 1, 0); /* 00000001 UNK135C */
793 /* SRC_TIC state */
794 dd_emit(ctx, 1, 0); /* 00000007 SRC_TILE_MODE_Z */
795 dd_emit(ctx, 1, 2); /* 00000007 SRC_TILE_MODE_Y */
796 dd_emit(ctx, 1, 1); /* 00000001 SRC_LINEAR #1 */
797 dd_emit(ctx, 1, 0); /* 000000ff SRC_ADDRESS_HIGH */
798 dd_emit(ctx, 1, 0); /* 00000001 SRC_SRGB */
799 if (dev_priv->chipset >= 0x94)
800 dd_emit(ctx, 1, 0); /* 00000003 eng2d UNK0258 */
801 dd_emit(ctx, 1, 1); /* 00000fff SRC_DEPTH */
802 dd_emit(ctx, 1, 0x100); /* 0000ffff SRC_HEIGHT */
804 /* turing state */
805 dd_emit(ctx, 1, 0); /* 0000000f TEXTURES_LOG2 */
806 dd_emit(ctx, 1, 0); /* 0000000f SAMPLERS_LOG2 */
807 dd_emit(ctx, 1, 0); /* 000000ff CB_DEF_ADDRESS_HIGH */
808 dd_emit(ctx, 1, 0); /* ffffffff CB_DEF_ADDRESS_LOW */
809 dd_emit(ctx, 1, 0); /* ffffffff SHARED_SIZE */
810 dd_emit(ctx, 1, 2); /* ffffffff REG_MODE */
811 dd_emit(ctx, 1, 1); /* 0000ffff BLOCK_ALLOC_THREADS */
812 dd_emit(ctx, 1, 1); /* 00000001 LANES32 */
813 dd_emit(ctx, 1, 0); /* 000000ff UNK370 */
814 dd_emit(ctx, 1, 0); /* 000000ff USER_PARAM_UNK */
815 dd_emit(ctx, 1, 0); /* 000000ff USER_PARAM_COUNT */
816 dd_emit(ctx, 1, 1); /* 000000ff UNK384 bits 8-15 */
817 dd_emit(ctx, 1, 0x3fffff); /* 003fffff TIC_LIMIT */
818 dd_emit(ctx, 1, 0x1fff); /* 000fffff TSC_LIMIT */
819 dd_emit(ctx, 1, 0); /* 0000ffff CB_ADDR_INDEX */
820 dd_emit(ctx, 1, 1); /* 000007ff BLOCKDIM_X */
821 dd_emit(ctx, 1, 1); /* 000007ff BLOCKDIM_XMY */
822 dd_emit(ctx, 1, 0); /* 00000001 BLOCKDIM_XMY_OVERFLOW */
823 dd_emit(ctx, 1, 1); /* 0003ffff BLOCKDIM_XMYMZ */
824 dd_emit(ctx, 1, 1); /* 000007ff BLOCKDIM_Y */
825 dd_emit(ctx, 1, 1); /* 0000007f BLOCKDIM_Z */
826 dd_emit(ctx, 1, 4); /* 000000ff CP_REG_ALLOC_TEMP */
827 dd_emit(ctx, 1, 1); /* 00000001 BLOCKDIM_DIRTY */
828 if (IS_NVA3F(dev_priv->chipset))
829 dd_emit(ctx, 1, 0); /* 00000003 UNK03E8 */
830 dd_emit(ctx, 1, 1); /* 0000007f BLOCK_ALLOC_HALFWARPS */
831 dd_emit(ctx, 1, 1); /* 00000007 LOCAL_WARPS_NO_CLAMP */
832 dd_emit(ctx, 1, 7); /* 00000007 LOCAL_WARPS_LOG_ALLOC */
833 dd_emit(ctx, 1, 1); /* 00000007 STACK_WARPS_NO_CLAMP */
834 dd_emit(ctx, 1, 7); /* 00000007 STACK_WARPS_LOG_ALLOC */
835 dd_emit(ctx, 1, 1); /* 00001fff BLOCK_ALLOC_REGSLOTS_PACKED */
836 dd_emit(ctx, 1, 1); /* 00001fff BLOCK_ALLOC_REGSLOTS_STRIDED */
837 dd_emit(ctx, 1, 1); /* 000007ff BLOCK_ALLOC_THREADS */
839 /* compat 2d state */
840 if (dev_priv->chipset == 0x50) {
841 dd_emit(ctx, 4, 0); /* 0000ffff clip X, Y, W, H */
843 dd_emit(ctx, 1, 1); /* ffffffff chroma COLOR_FORMAT */
845 dd_emit(ctx, 1, 1); /* ffffffff pattern COLOR_FORMAT */
846 dd_emit(ctx, 1, 0); /* ffffffff pattern SHAPE */
847 dd_emit(ctx, 1, 1); /* ffffffff pattern PATTERN_SELECT */
849 dd_emit(ctx, 1, 0xa); /* ffffffff surf2d SRC_FORMAT */
850 dd_emit(ctx, 1, 0); /* ffffffff surf2d DMA_SRC */
851 dd_emit(ctx, 1, 0); /* 000000ff surf2d SRC_ADDRESS_HIGH */
852 dd_emit(ctx, 1, 0); /* ffffffff surf2d SRC_ADDRESS_LOW */
853 dd_emit(ctx, 1, 0x40); /* 0000ffff surf2d SRC_PITCH */
854 dd_emit(ctx, 1, 0); /* 0000000f surf2d SRC_TILE_MODE_Z */
855 dd_emit(ctx, 1, 2); /* 0000000f surf2d SRC_TILE_MODE_Y */
856 dd_emit(ctx, 1, 0x100); /* ffffffff surf2d SRC_HEIGHT */
857 dd_emit(ctx, 1, 1); /* 00000001 surf2d SRC_LINEAR */
858 dd_emit(ctx, 1, 0x100); /* ffffffff surf2d SRC_WIDTH */
860 dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_B_X */
861 dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_B_Y */
862 dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_C_X */
863 dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_C_Y */
864 dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_D_X */
865 dd_emit(ctx, 1, 0); /* 0000ffff gdirect CLIP_D_Y */
866 dd_emit(ctx, 1, 1); /* ffffffff gdirect COLOR_FORMAT */
867 dd_emit(ctx, 1, 0); /* ffffffff gdirect OPERATION */
868 dd_emit(ctx, 1, 0); /* 0000ffff gdirect POINT_X */
869 dd_emit(ctx, 1, 0); /* 0000ffff gdirect POINT_Y */
871 dd_emit(ctx, 1, 0); /* 0000ffff blit SRC_Y */
872 dd_emit(ctx, 1, 0); /* ffffffff blit OPERATION */
874 dd_emit(ctx, 1, 0); /* ffffffff ifc OPERATION */
876 dd_emit(ctx, 1, 0); /* ffffffff iifc INDEX_FORMAT */
877 dd_emit(ctx, 1, 0); /* ffffffff iifc LUT_OFFSET */
878 dd_emit(ctx, 1, 4); /* ffffffff iifc COLOR_FORMAT */
879 dd_emit(ctx, 1, 0); /* ffffffff iifc OPERATION */
882 /* m2mf state */
883 dd_emit(ctx, 1, 0); /* ffffffff m2mf LINE_COUNT */
884 dd_emit(ctx, 1, 0); /* ffffffff m2mf LINE_LENGTH_IN */
885 dd_emit(ctx, 2, 0); /* ffffffff m2mf OFFSET_IN, OFFSET_OUT */
886 dd_emit(ctx, 1, 1); /* ffffffff m2mf TILING_DEPTH_OUT */
887 dd_emit(ctx, 1, 0x100); /* ffffffff m2mf TILING_HEIGHT_OUT */
888 dd_emit(ctx, 1, 0); /* ffffffff m2mf TILING_POSITION_OUT_Z */
889 dd_emit(ctx, 1, 1); /* 00000001 m2mf LINEAR_OUT */
890 dd_emit(ctx, 2, 0); /* 0000ffff m2mf TILING_POSITION_OUT_X, Y */
891 dd_emit(ctx, 1, 0x100); /* ffffffff m2mf TILING_PITCH_OUT */
892 dd_emit(ctx, 1, 1); /* ffffffff m2mf TILING_DEPTH_IN */
893 dd_emit(ctx, 1, 0x100); /* ffffffff m2mf TILING_HEIGHT_IN */
894 dd_emit(ctx, 1, 0); /* ffffffff m2mf TILING_POSITION_IN_Z */
895 dd_emit(ctx, 1, 1); /* 00000001 m2mf LINEAR_IN */
896 dd_emit(ctx, 2, 0); /* 0000ffff m2mf TILING_POSITION_IN_X, Y */
897 dd_emit(ctx, 1, 0x100); /* ffffffff m2mf TILING_PITCH_IN */
899 /* more compat 2d state */
900 if (dev_priv->chipset == 0x50) {
901 dd_emit(ctx, 1, 1); /* ffffffff line COLOR_FORMAT */
902 dd_emit(ctx, 1, 0); /* ffffffff line OPERATION */
904 dd_emit(ctx, 1, 1); /* ffffffff triangle COLOR_FORMAT */
905 dd_emit(ctx, 1, 0); /* ffffffff triangle OPERATION */
907 dd_emit(ctx, 1, 0); /* 0000000f sifm TILE_MODE_Z */
908 dd_emit(ctx, 1, 2); /* 0000000f sifm TILE_MODE_Y */
909 dd_emit(ctx, 1, 0); /* 000000ff sifm FORMAT_FILTER */
910 dd_emit(ctx, 1, 1); /* 000000ff sifm FORMAT_ORIGIN */
911 dd_emit(ctx, 1, 0); /* 0000ffff sifm SRC_PITCH */
912 dd_emit(ctx, 1, 1); /* 00000001 sifm SRC_LINEAR */
913 dd_emit(ctx, 1, 0); /* 000000ff sifm SRC_OFFSET_HIGH */
914 dd_emit(ctx, 1, 0); /* ffffffff sifm SRC_OFFSET */
915 dd_emit(ctx, 1, 0); /* 0000ffff sifm SRC_HEIGHT */
916 dd_emit(ctx, 1, 0); /* 0000ffff sifm SRC_WIDTH */
917 dd_emit(ctx, 1, 3); /* ffffffff sifm COLOR_FORMAT */
918 dd_emit(ctx, 1, 0); /* ffffffff sifm OPERATION */
920 dd_emit(ctx, 1, 0); /* ffffffff sifc OPERATION */
923 /* tesla state */
924 dd_emit(ctx, 1, 0); /* 0000000f GP_TEXTURES_LOG2 */
925 dd_emit(ctx, 1, 0); /* 0000000f GP_SAMPLERS_LOG2 */
926 dd_emit(ctx, 1, 0); /* 000000ff */
927 dd_emit(ctx, 1, 0); /* ffffffff */
928 dd_emit(ctx, 1, 4); /* 000000ff UNK12B0_0 */
929 dd_emit(ctx, 1, 0x70); /* 000000ff UNK12B0_1 */
930 dd_emit(ctx, 1, 0x80); /* 000000ff UNK12B0_3 */
931 dd_emit(ctx, 1, 0); /* 000000ff UNK12B0_2 */
932 dd_emit(ctx, 1, 0); /* 0000000f FP_TEXTURES_LOG2 */
933 dd_emit(ctx, 1, 0); /* 0000000f FP_SAMPLERS_LOG2 */
934 if (IS_NVA3F(dev_priv->chipset)) {
935 dd_emit(ctx, 1, 0); /* ffffffff */
936 dd_emit(ctx, 1, 0); /* 0000007f MULTISAMPLE_SAMPLES_LOG2 */
937 } else {
938 dd_emit(ctx, 1, 0); /* 0000000f MULTISAMPLE_SAMPLES_LOG2 */
940 dd_emit(ctx, 1, 0xc); /* 000000ff SEMANTIC_COLOR.BFC0_ID */
941 if (dev_priv->chipset != 0x50)
942 dd_emit(ctx, 1, 0); /* 00000001 SEMANTIC_COLOR.CLMP_EN */
943 dd_emit(ctx, 1, 8); /* 000000ff SEMANTIC_COLOR.COLR_NR */
944 dd_emit(ctx, 1, 0x14); /* 000000ff SEMANTIC_COLOR.FFC0_ID */
945 if (dev_priv->chipset == 0x50) {
946 dd_emit(ctx, 1, 0); /* 000000ff SEMANTIC_LAYER */
947 dd_emit(ctx, 1, 0); /* 00000001 */
948 } else {
949 dd_emit(ctx, 1, 0); /* 00000001 SEMANTIC_PTSZ.ENABLE */
950 dd_emit(ctx, 1, 0x29); /* 000000ff SEMANTIC_PTSZ.PTSZ_ID */
951 dd_emit(ctx, 1, 0x27); /* 000000ff SEMANTIC_PRIM */
952 dd_emit(ctx, 1, 0x26); /* 000000ff SEMANTIC_LAYER */
953 dd_emit(ctx, 1, 8); /* 0000000f SMENATIC_CLIP.CLIP_HIGH */
954 dd_emit(ctx, 1, 4); /* 000000ff SEMANTIC_CLIP.CLIP_LO */
955 dd_emit(ctx, 1, 0x27); /* 000000ff UNK0FD4 */
956 dd_emit(ctx, 1, 0); /* 00000001 UNK1900 */
958 dd_emit(ctx, 1, 0); /* 00000007 RT_CONTROL_MAP0 */
959 dd_emit(ctx, 1, 1); /* 00000007 RT_CONTROL_MAP1 */
960 dd_emit(ctx, 1, 2); /* 00000007 RT_CONTROL_MAP2 */
961 dd_emit(ctx, 1, 3); /* 00000007 RT_CONTROL_MAP3 */
962 dd_emit(ctx, 1, 4); /* 00000007 RT_CONTROL_MAP4 */
963 dd_emit(ctx, 1, 5); /* 00000007 RT_CONTROL_MAP5 */
964 dd_emit(ctx, 1, 6); /* 00000007 RT_CONTROL_MAP6 */
965 dd_emit(ctx, 1, 7); /* 00000007 RT_CONTROL_MAP7 */
966 dd_emit(ctx, 1, 1); /* 0000000f RT_CONTROL_COUNT */
967 dd_emit(ctx, 8, 0); /* 00000001 RT_HORIZ_UNK */
968 dd_emit(ctx, 8, 0); /* ffffffff RT_ADDRESS_LOW */
969 dd_emit(ctx, 1, 0xcf); /* 000000ff RT_FORMAT */
970 dd_emit(ctx, 7, 0); /* 000000ff RT_FORMAT */
971 if (dev_priv->chipset != 0x50)
972 dd_emit(ctx, 3, 0); /* 1, 1, 1 */
973 else
974 dd_emit(ctx, 2, 0); /* 1, 1 */
975 dd_emit(ctx, 1, 0); /* ffffffff GP_ENABLE */
976 dd_emit(ctx, 1, 0x80); /* 0000ffff GP_VERTEX_OUTPUT_COUNT*/
977 dd_emit(ctx, 1, 4); /* 000000ff GP_REG_ALLOC_RESULT */
978 dd_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
979 if (IS_NVA3F(dev_priv->chipset)) {
980 dd_emit(ctx, 1, 3); /* 00000003 */
981 dd_emit(ctx, 1, 0); /* 00000001 UNK1418. Alone. */
983 if (dev_priv->chipset != 0x50)
984 dd_emit(ctx, 1, 3); /* 00000003 UNK15AC */
985 dd_emit(ctx, 1, 1); /* ffffffff RASTERIZE_ENABLE */
986 dd_emit(ctx, 1, 0); /* 00000001 FP_CONTROL.EXPORTS_Z */
987 if (dev_priv->chipset != 0x50)
988 dd_emit(ctx, 1, 0); /* 00000001 FP_CONTROL.MULTIPLE_RESULTS */
989 dd_emit(ctx, 1, 0x12); /* 000000ff FP_INTERPOLANT_CTRL.COUNT */
990 dd_emit(ctx, 1, 0x10); /* 000000ff FP_INTERPOLANT_CTRL.COUNT_NONFLAT */
991 dd_emit(ctx, 1, 0xc); /* 000000ff FP_INTERPOLANT_CTRL.OFFSET */
992 dd_emit(ctx, 1, 1); /* 00000001 FP_INTERPOLANT_CTRL.UMASK.W */
993 dd_emit(ctx, 1, 0); /* 00000001 FP_INTERPOLANT_CTRL.UMASK.X */
994 dd_emit(ctx, 1, 0); /* 00000001 FP_INTERPOLANT_CTRL.UMASK.Y */
995 dd_emit(ctx, 1, 0); /* 00000001 FP_INTERPOLANT_CTRL.UMASK.Z */
996 dd_emit(ctx, 1, 4); /* 000000ff FP_RESULT_COUNT */
997 dd_emit(ctx, 1, 2); /* ffffffff REG_MODE */
998 dd_emit(ctx, 1, 4); /* 000000ff FP_REG_ALLOC_TEMP */
999 if (dev_priv->chipset >= 0xa0)
1000 dd_emit(ctx, 1, 0); /* ffffffff */
1001 dd_emit(ctx, 1, 0); /* 00000001 GP_BUILTIN_RESULT_EN.LAYER_IDX */
1002 dd_emit(ctx, 1, 0); /* ffffffff STRMOUT_ENABLE */
1003 dd_emit(ctx, 1, 0x3fffff); /* 003fffff TIC_LIMIT */
1004 dd_emit(ctx, 1, 0x1fff); /* 000fffff TSC_LIMIT */
1005 dd_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE*/
1006 if (dev_priv->chipset != 0x50)
1007 dd_emit(ctx, 8, 0); /* 00000001 */
1008 if (dev_priv->chipset >= 0xa0) {
1009 dd_emit(ctx, 1, 1); /* 00000007 VTX_ATTR_DEFINE.COMP */
1010 dd_emit(ctx, 1, 1); /* 00000007 VTX_ATTR_DEFINE.SIZE */
1011 dd_emit(ctx, 1, 2); /* 00000007 VTX_ATTR_DEFINE.TYPE */
1012 dd_emit(ctx, 1, 0); /* 000000ff VTX_ATTR_DEFINE.ATTR */
1014 dd_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
1015 dd_emit(ctx, 1, 0x14); /* 0000001f ZETA_FORMAT */
1016 dd_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
1017 dd_emit(ctx, 1, 0); /* 0000000f VP_TEXTURES_LOG2 */
1018 dd_emit(ctx, 1, 0); /* 0000000f VP_SAMPLERS_LOG2 */
1019 if (IS_NVA3F(dev_priv->chipset))
1020 dd_emit(ctx, 1, 0); /* 00000001 */
1021 dd_emit(ctx, 1, 2); /* 00000003 POLYGON_MODE_BACK */
1022 if (dev_priv->chipset >= 0xa0)
1023 dd_emit(ctx, 1, 0); /* 00000003 VTX_ATTR_DEFINE.SIZE - 1 */
1024 dd_emit(ctx, 1, 0); /* 0000ffff CB_ADDR_INDEX */
1025 if (dev_priv->chipset >= 0xa0)
1026 dd_emit(ctx, 1, 0); /* 00000003 */
1027 dd_emit(ctx, 1, 0); /* 00000001 CULL_FACE_ENABLE */
1028 dd_emit(ctx, 1, 1); /* 00000003 CULL_FACE */
1029 dd_emit(ctx, 1, 0); /* 00000001 FRONT_FACE */
1030 dd_emit(ctx, 1, 2); /* 00000003 POLYGON_MODE_FRONT */
1031 dd_emit(ctx, 1, 0x1000); /* 00007fff UNK141C */
1032 if (dev_priv->chipset != 0x50) {
1033 dd_emit(ctx, 1, 0xe00); /* 7fff */
1034 dd_emit(ctx, 1, 0x1000); /* 7fff */
1035 dd_emit(ctx, 1, 0x1e00); /* 7fff */
1037 dd_emit(ctx, 1, 0); /* 00000001 BEGIN_END_ACTIVE */
1038 dd_emit(ctx, 1, 1); /* 00000001 POLYGON_MODE_??? */
1039 dd_emit(ctx, 1, 1); /* 000000ff GP_REG_ALLOC_TEMP / 4 rounded up */
1040 dd_emit(ctx, 1, 1); /* 000000ff FP_REG_ALLOC_TEMP... without /4? */
1041 dd_emit(ctx, 1, 1); /* 000000ff VP_REG_ALLOC_TEMP / 4 rounded up */
1042 dd_emit(ctx, 1, 1); /* 00000001 */
1043 dd_emit(ctx, 1, 0); /* 00000001 */
1044 dd_emit(ctx, 1, 0); /* 00000001 VTX_ATTR_MASK_UNK0 nonempty */
1045 dd_emit(ctx, 1, 0); /* 00000001 VTX_ATTR_MASK_UNK1 nonempty */
1046 dd_emit(ctx, 1, 0x200); /* 0003ffff GP_VERTEX_OUTPUT_COUNT*GP_REG_ALLOC_RESULT */
1047 if (IS_NVA3F(dev_priv->chipset))
1048 dd_emit(ctx, 1, 0x200);
1049 dd_emit(ctx, 1, 0); /* 00000001 */
1050 if (dev_priv->chipset < 0xa0) {
1051 dd_emit(ctx, 1, 1); /* 00000001 */
1052 dd_emit(ctx, 1, 0x70); /* 000000ff */
1053 dd_emit(ctx, 1, 0x80); /* 000000ff */
1054 dd_emit(ctx, 1, 0); /* 000000ff */
1055 dd_emit(ctx, 1, 0); /* 00000001 */
1056 dd_emit(ctx, 1, 1); /* 00000001 */
1057 dd_emit(ctx, 1, 0x70); /* 000000ff */
1058 dd_emit(ctx, 1, 0x80); /* 000000ff */
1059 dd_emit(ctx, 1, 0); /* 000000ff */
1060 } else {
1061 dd_emit(ctx, 1, 1); /* 00000001 */
1062 dd_emit(ctx, 1, 0xf0); /* 000000ff */
1063 dd_emit(ctx, 1, 0xff); /* 000000ff */
1064 dd_emit(ctx, 1, 0); /* 000000ff */
1065 dd_emit(ctx, 1, 0); /* 00000001 */
1066 dd_emit(ctx, 1, 1); /* 00000001 */
1067 dd_emit(ctx, 1, 0xf0); /* 000000ff */
1068 dd_emit(ctx, 1, 0xff); /* 000000ff */
1069 dd_emit(ctx, 1, 0); /* 000000ff */
1070 dd_emit(ctx, 1, 9); /* 0000003f UNK114C.COMP,SIZE */
1073 /* eng2d state */
1074 dd_emit(ctx, 1, 0); /* 00000001 eng2d COLOR_KEY_ENABLE */
1075 dd_emit(ctx, 1, 0); /* 00000007 eng2d COLOR_KEY_FORMAT */
1076 dd_emit(ctx, 1, 1); /* ffffffff eng2d DST_DEPTH */
1077 dd_emit(ctx, 1, 0xcf); /* 000000ff eng2d DST_FORMAT */
1078 dd_emit(ctx, 1, 0); /* ffffffff eng2d DST_LAYER */
1079 dd_emit(ctx, 1, 1); /* 00000001 eng2d DST_LINEAR */
1080 dd_emit(ctx, 1, 0); /* 00000007 eng2d PATTERN_COLOR_FORMAT */
1081 dd_emit(ctx, 1, 0); /* 00000007 eng2d OPERATION */
1082 dd_emit(ctx, 1, 0); /* 00000003 eng2d PATTERN_SELECT */
1083 dd_emit(ctx, 1, 0xcf); /* 000000ff eng2d SIFC_FORMAT */
1084 dd_emit(ctx, 1, 0); /* 00000001 eng2d SIFC_BITMAP_ENABLE */
1085 dd_emit(ctx, 1, 2); /* 00000003 eng2d SIFC_BITMAP_UNK808 */
1086 dd_emit(ctx, 1, 0); /* ffffffff eng2d BLIT_DU_DX_FRACT */
1087 dd_emit(ctx, 1, 1); /* ffffffff eng2d BLIT_DU_DX_INT */
1088 dd_emit(ctx, 1, 0); /* ffffffff eng2d BLIT_DV_DY_FRACT */
1089 dd_emit(ctx, 1, 1); /* ffffffff eng2d BLIT_DV_DY_INT */
1090 dd_emit(ctx, 1, 0); /* 00000001 eng2d BLIT_CONTROL_FILTER */
1091 dd_emit(ctx, 1, 0xcf); /* 000000ff eng2d DRAW_COLOR_FORMAT */
1092 dd_emit(ctx, 1, 0xcf); /* 000000ff eng2d SRC_FORMAT */
1093 dd_emit(ctx, 1, 1); /* 00000001 eng2d SRC_LINEAR #2 */
1095 num = ctx->ctxvals_pos - base;
1096 ctx->ctxvals_pos = base;
1097 if (IS_NVA3F(dev_priv->chipset))
1098 cp_ctx(ctx, 0x404800, num);
1099 else
1100 cp_ctx(ctx, 0x405400, num);
1104 * xfer areas. These are a pain.
1106 * There are 2 xfer areas: the first one is big and contains all sorts of
1107 * stuff, the second is small and contains some per-TP context.
1109 * Each area is split into 8 "strands". The areas, when saved to grctx,
1110 * are made of 8-word blocks. Each block contains a single word from
1111 * each strand. The strands are independent of each other, their
1112 * addresses are unrelated to each other, and data in them is closely
1113 * packed together. The strand layout varies a bit between cards: here
1114 * and there, a single word is thrown out in the middle and the whole
1115 * strand is offset by a bit from corresponding one on another chipset.
1116 * For this reason, addresses of stuff in strands are almost useless.
1117 * Knowing sequence of stuff and size of gaps between them is much more
1118 * useful, and that's how we build the strands in our generator.
1120 * NVA0 takes this mess to a whole new level by cutting the old strands
1121 * into a few dozen pieces [known as genes], rearranging them randomly,
1122 * and putting them back together to make new strands. Hopefully these
1123 * genes correspond more or less directly to the same PGRAPH subunits
1124 * as in 400040 register.
1126 * The most common value in default context is 0, and when the genes
1127 * are separated by 0's, gene bounduaries are quite speculative...
1128 * some of them can be clearly deduced, others can be guessed, and yet
1129 * others won't be resolved without figuring out the real meaning of
1130 * given ctxval. For the same reason, ending point of each strand
1131 * is unknown. Except for strand 0, which is the longest strand and
1132 * its end corresponds to end of the whole xfer.
1134 * An unsolved mystery is the seek instruction: it takes an argument
1135 * in bits 8-18, and that argument is clearly the place in strands to
1136 * seek to... but the offsets don't seem to correspond to offsets as
1137 * seen in grctx. Perhaps there's another, real, not randomly-changing
1138 * addressing in strands, and the xfer insn just happens to skip over
1139 * the unused bits? NV10-NV30 PIPE comes to mind...
1141 * As far as I know, there's no way to access the xfer areas directly
1142 * without the help of ctxprog.
1145 static void
1146 xf_emit(struct nouveau_grctx *ctx, int num, uint32_t val) {
1147 int i;
1148 if (val && ctx->mode == NOUVEAU_GRCTX_VALS)
1149 for (i = 0; i < num; i++)
1150 nv_wv32(ctx->data, 4 * (ctx->ctxvals_pos + (i << 3)), val);
1151 ctx->ctxvals_pos += num << 3;
1154 /* Gene declarations... */
1156 static void nv50_graph_construct_gene_dispatch(struct nouveau_grctx *ctx);
1157 static void nv50_graph_construct_gene_m2mf(struct nouveau_grctx *ctx);
1158 static void nv50_graph_construct_gene_ccache(struct nouveau_grctx *ctx);
1159 static void nv50_graph_construct_gene_unk10xx(struct nouveau_grctx *ctx);
1160 static void nv50_graph_construct_gene_unk14xx(struct nouveau_grctx *ctx);
1161 static void nv50_graph_construct_gene_zcull(struct nouveau_grctx *ctx);
1162 static void nv50_graph_construct_gene_clipid(struct nouveau_grctx *ctx);
1163 static void nv50_graph_construct_gene_unk24xx(struct nouveau_grctx *ctx);
1164 static void nv50_graph_construct_gene_vfetch(struct nouveau_grctx *ctx);
1165 static void nv50_graph_construct_gene_eng2d(struct nouveau_grctx *ctx);
1166 static void nv50_graph_construct_gene_csched(struct nouveau_grctx *ctx);
1167 static void nv50_graph_construct_gene_unk1cxx(struct nouveau_grctx *ctx);
1168 static void nv50_graph_construct_gene_strmout(struct nouveau_grctx *ctx);
1169 static void nv50_graph_construct_gene_unk34xx(struct nouveau_grctx *ctx);
1170 static void nv50_graph_construct_gene_ropm1(struct nouveau_grctx *ctx);
1171 static void nv50_graph_construct_gene_ropm2(struct nouveau_grctx *ctx);
1172 static void nv50_graph_construct_gene_ropc(struct nouveau_grctx *ctx);
1173 static void nv50_graph_construct_xfer_tp(struct nouveau_grctx *ctx);
1175 static void
1176 nv50_graph_construct_xfer1(struct nouveau_grctx *ctx)
1178 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
1179 int i;
1180 int offset;
1181 int size = 0;
1182 uint32_t units = nv_rd32 (ctx->dev, 0x1540);
1184 offset = (ctx->ctxvals_pos+0x3f)&~0x3f;
1185 ctx->ctxvals_base = offset;
1187 if (dev_priv->chipset < 0xa0) {
1188 /* Strand 0 */
1189 ctx->ctxvals_pos = offset;
1190 nv50_graph_construct_gene_dispatch(ctx);
1191 nv50_graph_construct_gene_m2mf(ctx);
1192 nv50_graph_construct_gene_unk24xx(ctx);
1193 nv50_graph_construct_gene_clipid(ctx);
1194 nv50_graph_construct_gene_zcull(ctx);
1195 if ((ctx->ctxvals_pos-offset)/8 > size)
1196 size = (ctx->ctxvals_pos-offset)/8;
1198 /* Strand 1 */
1199 ctx->ctxvals_pos = offset + 0x1;
1200 nv50_graph_construct_gene_vfetch(ctx);
1201 nv50_graph_construct_gene_eng2d(ctx);
1202 nv50_graph_construct_gene_csched(ctx);
1203 nv50_graph_construct_gene_ropm1(ctx);
1204 nv50_graph_construct_gene_ropm2(ctx);
1205 if ((ctx->ctxvals_pos-offset)/8 > size)
1206 size = (ctx->ctxvals_pos-offset)/8;
1208 /* Strand 2 */
1209 ctx->ctxvals_pos = offset + 0x2;
1210 nv50_graph_construct_gene_ccache(ctx);
1211 nv50_graph_construct_gene_unk1cxx(ctx);
1212 nv50_graph_construct_gene_strmout(ctx);
1213 nv50_graph_construct_gene_unk14xx(ctx);
1214 nv50_graph_construct_gene_unk10xx(ctx);
1215 nv50_graph_construct_gene_unk34xx(ctx);
1216 if ((ctx->ctxvals_pos-offset)/8 > size)
1217 size = (ctx->ctxvals_pos-offset)/8;
1219 /* Strand 3: per-ROP group state */
1220 ctx->ctxvals_pos = offset + 3;
1221 for (i = 0; i < 6; i++)
1222 if (units & (1 << (i + 16)))
1223 nv50_graph_construct_gene_ropc(ctx);
1224 if ((ctx->ctxvals_pos-offset)/8 > size)
1225 size = (ctx->ctxvals_pos-offset)/8;
1227 /* Strands 4-7: per-TP state */
1228 for (i = 0; i < 4; i++) {
1229 ctx->ctxvals_pos = offset + 4 + i;
1230 if (units & (1 << (2 * i)))
1231 nv50_graph_construct_xfer_tp(ctx);
1232 if (units & (1 << (2 * i + 1)))
1233 nv50_graph_construct_xfer_tp(ctx);
1234 if ((ctx->ctxvals_pos-offset)/8 > size)
1235 size = (ctx->ctxvals_pos-offset)/8;
1237 } else {
1238 /* Strand 0 */
1239 ctx->ctxvals_pos = offset;
1240 nv50_graph_construct_gene_dispatch(ctx);
1241 nv50_graph_construct_gene_m2mf(ctx);
1242 nv50_graph_construct_gene_unk34xx(ctx);
1243 nv50_graph_construct_gene_csched(ctx);
1244 nv50_graph_construct_gene_unk1cxx(ctx);
1245 nv50_graph_construct_gene_strmout(ctx);
1246 if ((ctx->ctxvals_pos-offset)/8 > size)
1247 size = (ctx->ctxvals_pos-offset)/8;
1249 /* Strand 1 */
1250 ctx->ctxvals_pos = offset + 1;
1251 nv50_graph_construct_gene_unk10xx(ctx);
1252 if ((ctx->ctxvals_pos-offset)/8 > size)
1253 size = (ctx->ctxvals_pos-offset)/8;
1255 /* Strand 2 */
1256 ctx->ctxvals_pos = offset + 2;
1257 if (dev_priv->chipset == 0xa0)
1258 nv50_graph_construct_gene_unk14xx(ctx);
1259 nv50_graph_construct_gene_unk24xx(ctx);
1260 if ((ctx->ctxvals_pos-offset)/8 > size)
1261 size = (ctx->ctxvals_pos-offset)/8;
1263 /* Strand 3 */
1264 ctx->ctxvals_pos = offset + 3;
1265 nv50_graph_construct_gene_vfetch(ctx);
1266 if ((ctx->ctxvals_pos-offset)/8 > size)
1267 size = (ctx->ctxvals_pos-offset)/8;
1269 /* Strand 4 */
1270 ctx->ctxvals_pos = offset + 4;
1271 nv50_graph_construct_gene_ccache(ctx);
1272 if ((ctx->ctxvals_pos-offset)/8 > size)
1273 size = (ctx->ctxvals_pos-offset)/8;
1275 /* Strand 5 */
1276 ctx->ctxvals_pos = offset + 5;
1277 nv50_graph_construct_gene_ropm2(ctx);
1278 nv50_graph_construct_gene_ropm1(ctx);
1279 /* per-ROP context */
1280 for (i = 0; i < 8; i++)
1281 if (units & (1<<(i+16)))
1282 nv50_graph_construct_gene_ropc(ctx);
1283 if ((ctx->ctxvals_pos-offset)/8 > size)
1284 size = (ctx->ctxvals_pos-offset)/8;
1286 /* Strand 6 */
1287 ctx->ctxvals_pos = offset + 6;
1288 nv50_graph_construct_gene_zcull(ctx);
1289 nv50_graph_construct_gene_clipid(ctx);
1290 nv50_graph_construct_gene_eng2d(ctx);
1291 if (units & (1 << 0))
1292 nv50_graph_construct_xfer_tp(ctx);
1293 if (units & (1 << 1))
1294 nv50_graph_construct_xfer_tp(ctx);
1295 if (units & (1 << 2))
1296 nv50_graph_construct_xfer_tp(ctx);
1297 if (units & (1 << 3))
1298 nv50_graph_construct_xfer_tp(ctx);
1299 if ((ctx->ctxvals_pos-offset)/8 > size)
1300 size = (ctx->ctxvals_pos-offset)/8;
1302 /* Strand 7 */
1303 ctx->ctxvals_pos = offset + 7;
1304 if (dev_priv->chipset == 0xa0) {
1305 if (units & (1 << 4))
1306 nv50_graph_construct_xfer_tp(ctx);
1307 if (units & (1 << 5))
1308 nv50_graph_construct_xfer_tp(ctx);
1309 if (units & (1 << 6))
1310 nv50_graph_construct_xfer_tp(ctx);
1311 if (units & (1 << 7))
1312 nv50_graph_construct_xfer_tp(ctx);
1313 if (units & (1 << 8))
1314 nv50_graph_construct_xfer_tp(ctx);
1315 if (units & (1 << 9))
1316 nv50_graph_construct_xfer_tp(ctx);
1317 } else {
1318 nv50_graph_construct_gene_unk14xx(ctx);
1320 if ((ctx->ctxvals_pos-offset)/8 > size)
1321 size = (ctx->ctxvals_pos-offset)/8;
1324 ctx->ctxvals_pos = offset + size * 8;
1325 ctx->ctxvals_pos = (ctx->ctxvals_pos+0x3f)&~0x3f;
1326 cp_lsr (ctx, offset);
1327 cp_out (ctx, CP_SET_XFER_POINTER);
1328 cp_lsr (ctx, size);
1329 cp_out (ctx, CP_SEEK_1);
1330 cp_out (ctx, CP_XFER_1);
1331 cp_wait(ctx, XFER, BUSY);
1335 * non-trivial demagiced parts of ctx init go here
1338 static void
1339 nv50_graph_construct_gene_dispatch(struct nouveau_grctx *ctx)
1341 /* start of strand 0 */
1342 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
1343 /* SEEK */
1344 if (dev_priv->chipset == 0x50)
1345 xf_emit(ctx, 5, 0);
1346 else if (!IS_NVA3F(dev_priv->chipset))
1347 xf_emit(ctx, 6, 0);
1348 else
1349 xf_emit(ctx, 4, 0);
1350 /* SEEK */
1351 /* the PGRAPH's internal FIFO */
1352 if (dev_priv->chipset == 0x50)
1353 xf_emit(ctx, 8*3, 0);
1354 else
1355 xf_emit(ctx, 0x100*3, 0);
1356 /* and another bonus slot?!? */
1357 xf_emit(ctx, 3, 0);
1358 /* and YET ANOTHER bonus slot? */
1359 if (IS_NVA3F(dev_priv->chipset))
1360 xf_emit(ctx, 3, 0);
1361 /* SEEK */
1362 /* CTX_SWITCH: caches of gr objects bound to subchannels. 8 values, last used index */
1363 xf_emit(ctx, 9, 0);
1364 /* SEEK */
1365 xf_emit(ctx, 9, 0);
1366 /* SEEK */
1367 xf_emit(ctx, 9, 0);
1368 /* SEEK */
1369 xf_emit(ctx, 9, 0);
1370 /* SEEK */
1371 if (dev_priv->chipset < 0x90)
1372 xf_emit(ctx, 4, 0);
1373 /* SEEK */
1374 xf_emit(ctx, 2, 0);
1375 /* SEEK */
1376 xf_emit(ctx, 6*2, 0);
1377 xf_emit(ctx, 2, 0);
1378 /* SEEK */
1379 xf_emit(ctx, 2, 0);
1380 /* SEEK */
1381 xf_emit(ctx, 6*2, 0);
1382 xf_emit(ctx, 2, 0);
1383 /* SEEK */
1384 if (dev_priv->chipset == 0x50)
1385 xf_emit(ctx, 0x1c, 0);
1386 else if (dev_priv->chipset < 0xa0)
1387 xf_emit(ctx, 0x1e, 0);
1388 else
1389 xf_emit(ctx, 0x22, 0);
1390 /* SEEK */
1391 xf_emit(ctx, 0x15, 0);
1394 static void
1395 nv50_graph_construct_gene_m2mf(struct nouveau_grctx *ctx)
1397 /* Strand 0, right after dispatch */
1398 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
1399 int smallm2mf = 0;
1400 if (dev_priv->chipset < 0x92 || dev_priv->chipset == 0x98)
1401 smallm2mf = 1;
1402 /* SEEK */
1403 xf_emit (ctx, 1, 0); /* DMA_NOTIFY instance >> 4 */
1404 xf_emit (ctx, 1, 0); /* DMA_BUFFER_IN instance >> 4 */
1405 xf_emit (ctx, 1, 0); /* DMA_BUFFER_OUT instance >> 4 */
1406 xf_emit (ctx, 1, 0); /* OFFSET_IN */
1407 xf_emit (ctx, 1, 0); /* OFFSET_OUT */
1408 xf_emit (ctx, 1, 0); /* PITCH_IN */
1409 xf_emit (ctx, 1, 0); /* PITCH_OUT */
1410 xf_emit (ctx, 1, 0); /* LINE_LENGTH */
1411 xf_emit (ctx, 1, 0); /* LINE_COUNT */
1412 xf_emit (ctx, 1, 0x21); /* FORMAT: bits 0-4 INPUT_INC, bits 5-9 OUTPUT_INC */
1413 xf_emit (ctx, 1, 1); /* LINEAR_IN */
1414 xf_emit (ctx, 1, 0x2); /* TILING_MODE_IN: bits 0-2 y tiling, bits 3-5 z tiling */
1415 xf_emit (ctx, 1, 0x100); /* TILING_PITCH_IN */
1416 xf_emit (ctx, 1, 0x100); /* TILING_HEIGHT_IN */
1417 xf_emit (ctx, 1, 1); /* TILING_DEPTH_IN */
1418 xf_emit (ctx, 1, 0); /* TILING_POSITION_IN_Z */
1419 xf_emit (ctx, 1, 0); /* TILING_POSITION_IN */
1420 xf_emit (ctx, 1, 1); /* LINEAR_OUT */
1421 xf_emit (ctx, 1, 0x2); /* TILING_MODE_OUT: bits 0-2 y tiling, bits 3-5 z tiling */
1422 xf_emit (ctx, 1, 0x100); /* TILING_PITCH_OUT */
1423 xf_emit (ctx, 1, 0x100); /* TILING_HEIGHT_OUT */
1424 xf_emit (ctx, 1, 1); /* TILING_DEPTH_OUT */
1425 xf_emit (ctx, 1, 0); /* TILING_POSITION_OUT_Z */
1426 xf_emit (ctx, 1, 0); /* TILING_POSITION_OUT */
1427 xf_emit (ctx, 1, 0); /* OFFSET_IN_HIGH */
1428 xf_emit (ctx, 1, 0); /* OFFSET_OUT_HIGH */
1429 /* SEEK */
1430 if (smallm2mf)
1431 xf_emit(ctx, 0x40, 0); /* 20 * ffffffff, 3ffff */
1432 else
1433 xf_emit(ctx, 0x100, 0); /* 80 * ffffffff, 3ffff */
1434 xf_emit(ctx, 4, 0); /* 1f/7f, 0, 1f/7f, 0 [1f for smallm2mf, 7f otherwise] */
1435 /* SEEK */
1436 if (smallm2mf)
1437 xf_emit(ctx, 0x400, 0); /* ffffffff */
1438 else
1439 xf_emit(ctx, 0x800, 0); /* ffffffff */
1440 xf_emit(ctx, 4, 0); /* ff/1ff, 0, 0, 0 [ff for smallm2mf, 1ff otherwise] */
1441 /* SEEK */
1442 xf_emit(ctx, 0x40, 0); /* 20 * bits ffffffff, 3ffff */
1443 xf_emit(ctx, 0x6, 0); /* 1f, 0, 1f, 0, 1f, 0 */
1446 static void
1447 nv50_graph_construct_gene_ccache(struct nouveau_grctx *ctx)
1449 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
1450 xf_emit(ctx, 2, 0); /* RO */
1451 xf_emit(ctx, 0x800, 0); /* ffffffff */
1452 switch (dev_priv->chipset) {
1453 case 0x50:
1454 case 0x92:
1455 case 0xa0:
1456 xf_emit(ctx, 0x2b, 0);
1457 break;
1458 case 0x84:
1459 xf_emit(ctx, 0x29, 0);
1460 break;
1461 case 0x94:
1462 case 0x96:
1463 case 0xa3:
1464 xf_emit(ctx, 0x27, 0);
1465 break;
1466 case 0x86:
1467 case 0x98:
1468 case 0xa5:
1469 case 0xa8:
1470 case 0xaa:
1471 case 0xac:
1472 case 0xaf:
1473 xf_emit(ctx, 0x25, 0);
1474 break;
1476 /* CB bindings, 0x80 of them. first word is address >> 8, second is
1477 * size >> 4 | valid << 24 */
1478 xf_emit(ctx, 0x100, 0); /* ffffffff CB_DEF */
1479 xf_emit(ctx, 1, 0); /* 0000007f CB_ADDR_BUFFER */
1480 xf_emit(ctx, 1, 0); /* 0 */
1481 xf_emit(ctx, 0x30, 0); /* ff SET_PROGRAM_CB */
1482 xf_emit(ctx, 1, 0); /* 3f last SET_PROGRAM_CB */
1483 xf_emit(ctx, 4, 0); /* RO */
1484 xf_emit(ctx, 0x100, 0); /* ffffffff */
1485 xf_emit(ctx, 8, 0); /* 1f, 0, 0, ... */
1486 xf_emit(ctx, 8, 0); /* ffffffff */
1487 xf_emit(ctx, 4, 0); /* ffffffff */
1488 xf_emit(ctx, 1, 0); /* 3 */
1489 xf_emit(ctx, 1, 0); /* ffffffff */
1490 xf_emit(ctx, 1, 0); /* 0000ffff DMA_CODE_CB */
1491 xf_emit(ctx, 1, 0); /* 0000ffff DMA_TIC */
1492 xf_emit(ctx, 1, 0); /* 0000ffff DMA_TSC */
1493 xf_emit(ctx, 1, 0); /* 00000001 LINKED_TSC */
1494 xf_emit(ctx, 1, 0); /* 000000ff TIC_ADDRESS_HIGH */
1495 xf_emit(ctx, 1, 0); /* ffffffff TIC_ADDRESS_LOW */
1496 xf_emit(ctx, 1, 0x3fffff); /* 003fffff TIC_LIMIT */
1497 xf_emit(ctx, 1, 0); /* 000000ff TSC_ADDRESS_HIGH */
1498 xf_emit(ctx, 1, 0); /* ffffffff TSC_ADDRESS_LOW */
1499 xf_emit(ctx, 1, 0x1fff); /* 000fffff TSC_LIMIT */
1500 xf_emit(ctx, 1, 0); /* 000000ff VP_ADDRESS_HIGH */
1501 xf_emit(ctx, 1, 0); /* ffffffff VP_ADDRESS_LOW */
1502 xf_emit(ctx, 1, 0); /* 00ffffff VP_START_ID */
1503 xf_emit(ctx, 1, 0); /* 000000ff CB_DEF_ADDRESS_HIGH */
1504 xf_emit(ctx, 1, 0); /* ffffffff CB_DEF_ADDRESS_LOW */
1505 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1506 xf_emit(ctx, 1, 0); /* 000000ff GP_ADDRESS_HIGH */
1507 xf_emit(ctx, 1, 0); /* ffffffff GP_ADDRESS_LOW */
1508 xf_emit(ctx, 1, 0); /* 00ffffff GP_START_ID */
1509 xf_emit(ctx, 1, 0); /* 000000ff FP_ADDRESS_HIGH */
1510 xf_emit(ctx, 1, 0); /* ffffffff FP_ADDRESS_LOW */
1511 xf_emit(ctx, 1, 0); /* 00ffffff FP_START_ID */
1514 static void
1515 nv50_graph_construct_gene_unk10xx(struct nouveau_grctx *ctx)
1517 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
1518 int i;
1519 /* end of area 2 on pre-NVA0, area 1 on NVAx */
1520 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
1521 xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
1522 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1523 xf_emit(ctx, 1, 0x80); /* 0000ffff GP_VERTEX_OUTPUT_COUNT */
1524 xf_emit(ctx, 1, 4); /* 000000ff GP_REG_ALLOC_RESULT */
1525 xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
1526 xf_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE */
1527 if (dev_priv->chipset == 0x50)
1528 xf_emit(ctx, 1, 0x3ff);
1529 else
1530 xf_emit(ctx, 1, 0x7ff); /* 000007ff */
1531 xf_emit(ctx, 1, 0); /* 111/113 */
1532 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
1533 for (i = 0; i < 8; i++) {
1534 switch (dev_priv->chipset) {
1535 case 0x50:
1536 case 0x86:
1537 case 0x98:
1538 case 0xaa:
1539 case 0xac:
1540 xf_emit(ctx, 0xa0, 0); /* ffffffff */
1541 break;
1542 case 0x84:
1543 case 0x92:
1544 case 0x94:
1545 case 0x96:
1546 xf_emit(ctx, 0x120, 0);
1547 break;
1548 case 0xa5:
1549 case 0xa8:
1550 xf_emit(ctx, 0x100, 0); /* ffffffff */
1551 break;
1552 case 0xa0:
1553 case 0xa3:
1554 case 0xaf:
1555 xf_emit(ctx, 0x400, 0); /* ffffffff */
1556 break;
1558 xf_emit(ctx, 4, 0); /* 3f, 0, 0, 0 */
1559 xf_emit(ctx, 4, 0); /* ffffffff */
1561 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
1562 xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
1563 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1564 xf_emit(ctx, 1, 0x80); /* 0000ffff GP_VERTEX_OUTPUT_COUNT */
1565 xf_emit(ctx, 1, 4); /* 000000ff GP_REG_ALLOC_TEMP */
1566 xf_emit(ctx, 1, 1); /* 00000001 RASTERIZE_ENABLE */
1567 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
1568 xf_emit(ctx, 1, 0x27); /* 000000ff UNK0FD4 */
1569 xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
1570 xf_emit(ctx, 1, 0x26); /* 000000ff SEMANTIC_LAYER */
1571 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
1574 static void
1575 nv50_graph_construct_gene_unk34xx(struct nouveau_grctx *ctx)
1577 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
1578 /* end of area 2 on pre-NVA0, area 1 on NVAx */
1579 xf_emit(ctx, 1, 0); /* 00000001 VIEWPORT_CLIP_RECTS_EN */
1580 xf_emit(ctx, 1, 0); /* 00000003 VIEWPORT_CLIP_MODE */
1581 xf_emit(ctx, 0x10, 0x04000000); /* 07ffffff VIEWPORT_CLIP_HORIZ*8, VIEWPORT_CLIP_VERT*8 */
1582 xf_emit(ctx, 1, 0); /* 00000001 POLYGON_STIPPLE_ENABLE */
1583 xf_emit(ctx, 0x20, 0); /* ffffffff POLYGON_STIPPLE */
1584 xf_emit(ctx, 2, 0); /* 00007fff WINDOW_OFFSET_XY */
1585 xf_emit(ctx, 1, 0); /* ffff0ff3 */
1586 xf_emit(ctx, 1, 0x04e3bfdf); /* ffffffff UNK0D64 */
1587 xf_emit(ctx, 1, 0x04e3bfdf); /* ffffffff UNK0DF4 */
1588 xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
1589 xf_emit(ctx, 1, 0); /* 00000007 */
1590 xf_emit(ctx, 1, 0x1fe21); /* 0001ffff tesla UNK0FAC */
1591 if (dev_priv->chipset >= 0xa0)
1592 xf_emit(ctx, 1, 0x0fac6881);
1593 if (IS_NVA3F(dev_priv->chipset)) {
1594 xf_emit(ctx, 1, 1);
1595 xf_emit(ctx, 3, 0);
1599 static void
1600 nv50_graph_construct_gene_unk14xx(struct nouveau_grctx *ctx)
1602 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
1603 /* middle of area 2 on pre-NVA0, beginning of area 2 on NVA0, area 7 on >NVA0 */
1604 if (dev_priv->chipset != 0x50) {
1605 xf_emit(ctx, 5, 0); /* ffffffff */
1606 xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
1607 xf_emit(ctx, 1, 0); /* 00000001 */
1608 xf_emit(ctx, 1, 0); /* 000003ff */
1609 xf_emit(ctx, 1, 0x804); /* 00000fff SEMANTIC_CLIP */
1610 xf_emit(ctx, 1, 0); /* 00000001 */
1611 xf_emit(ctx, 2, 4); /* 7f, ff */
1612 xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
1614 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
1615 xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
1616 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
1617 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1618 xf_emit(ctx, 1, 0x10); /* 7f/ff VIEW_VOLUME_CLIP_CTRL */
1619 xf_emit(ctx, 1, 0); /* 000000ff VP_CLIP_DISTANCE_ENABLE */
1620 if (dev_priv->chipset != 0x50)
1621 xf_emit(ctx, 1, 0); /* 3ff */
1622 xf_emit(ctx, 1, 0); /* 000000ff tesla UNK1940 */
1623 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0D7C */
1624 xf_emit(ctx, 1, 0x804); /* 00000fff SEMANTIC_CLIP */
1625 xf_emit(ctx, 1, 1); /* 00000001 VIEWPORT_TRANSFORM_EN */
1626 xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
1627 if (dev_priv->chipset != 0x50)
1628 xf_emit(ctx, 1, 0x7f); /* 000000ff tesla UNK0FFC */
1629 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
1630 xf_emit(ctx, 1, 1); /* 00000001 SHADE_MODEL */
1631 xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
1632 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
1633 xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
1634 xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
1635 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
1636 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1637 xf_emit(ctx, 1, 0x10); /* 7f/ff VIEW_VOLUME_CLIP_CTRL */
1638 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0D7C */
1639 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0F8C */
1640 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
1641 xf_emit(ctx, 1, 1); /* 00000001 VIEWPORT_TRANSFORM_EN */
1642 xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
1643 xf_emit(ctx, 4, 0); /* ffffffff NOPERSPECTIVE_BITMAP */
1644 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
1645 xf_emit(ctx, 1, 0); /* 0000000f */
1646 if (dev_priv->chipset == 0x50)
1647 xf_emit(ctx, 1, 0x3ff); /* 000003ff tesla UNK0D68 */
1648 else
1649 xf_emit(ctx, 1, 0x7ff); /* 000007ff tesla UNK0D68 */
1650 xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
1651 xf_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE */
1652 xf_emit(ctx, 0x30, 0); /* ffffffff VIEWPORT_SCALE: X0, Y0, Z0, X1, Y1, ... */
1653 xf_emit(ctx, 3, 0); /* f, 0, 0 */
1654 xf_emit(ctx, 3, 0); /* ffffffff last VIEWPORT_SCALE? */
1655 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
1656 xf_emit(ctx, 1, 1); /* 00000001 VIEWPORT_TRANSFORM_EN */
1657 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
1658 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1924 */
1659 xf_emit(ctx, 1, 0x10); /* 000000ff VIEW_VOLUME_CLIP_CTRL */
1660 xf_emit(ctx, 1, 0); /* 00000001 */
1661 xf_emit(ctx, 0x30, 0); /* ffffffff VIEWPORT_TRANSLATE */
1662 xf_emit(ctx, 3, 0); /* f, 0, 0 */
1663 xf_emit(ctx, 3, 0); /* ffffffff */
1664 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
1665 xf_emit(ctx, 2, 0x88); /* 000001ff tesla UNK19D8 */
1666 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1924 */
1667 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
1668 xf_emit(ctx, 1, 4); /* 0000000f CULL_MODE */
1669 xf_emit(ctx, 2, 0); /* 07ffffff SCREEN_SCISSOR */
1670 xf_emit(ctx, 2, 0); /* 00007fff WINDOW_OFFSET_XY */
1671 xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
1672 xf_emit(ctx, 0x10, 0); /* 00000001 SCISSOR_ENABLE */
1673 xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
1674 xf_emit(ctx, 1, 0x26); /* 000000ff SEMANTIC_LAYER */
1675 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
1676 xf_emit(ctx, 1, 0); /* 0000000f */
1677 xf_emit(ctx, 1, 0x3f800000); /* ffffffff LINE_WIDTH */
1678 xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
1679 xf_emit(ctx, 1, 0); /* 00000001 LINE_SMOOTH_ENABLE */
1680 xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
1681 if (IS_NVA3F(dev_priv->chipset))
1682 xf_emit(ctx, 1, 0); /* 00000001 */
1683 xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
1684 xf_emit(ctx, 1, 0x10); /* 000000ff VIEW_VOLUME_CLIP_CTRL */
1685 if (dev_priv->chipset != 0x50) {
1686 xf_emit(ctx, 1, 0); /* ffffffff */
1687 xf_emit(ctx, 1, 0); /* 00000001 */
1688 xf_emit(ctx, 1, 0); /* 000003ff */
1690 xf_emit(ctx, 0x20, 0); /* 10xbits ffffffff, 3fffff. SCISSOR_* */
1691 xf_emit(ctx, 1, 0); /* f */
1692 xf_emit(ctx, 1, 0); /* 0? */
1693 xf_emit(ctx, 1, 0); /* ffffffff */
1694 xf_emit(ctx, 1, 0); /* 003fffff */
1695 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
1696 xf_emit(ctx, 1, 0x52); /* 000001ff SEMANTIC_PTSZ */
1697 xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
1698 xf_emit(ctx, 1, 0x26); /* 000000ff SEMANTIC_LAYER */
1699 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
1700 xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
1701 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
1702 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1703 xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
1704 xf_emit(ctx, 1, 0); /* 00000001 LINE_SMOOTH_ENABLE */
1705 xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
1706 xf_emit(ctx, 1, 0x00ffff00); /* 00ffffff LINE_STIPPLE_PATTERN */
1707 xf_emit(ctx, 1, 0); /* 0000000f */
1710 static void
1711 nv50_graph_construct_gene_zcull(struct nouveau_grctx *ctx)
1713 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
1714 /* end of strand 0 on pre-NVA0, beginning of strand 6 on NVAx */
1715 /* SEEK */
1716 xf_emit(ctx, 1, 0x3f); /* 0000003f UNK1590 */
1717 xf_emit(ctx, 1, 0); /* 00000001 ALPHA_TEST_ENABLE */
1718 xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
1719 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
1720 xf_emit(ctx, 1, 0); /* 00000007 STENCIL_BACK_FUNC_FUNC */
1721 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_MASK */
1722 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_REF */
1723 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_MASK */
1724 xf_emit(ctx, 3, 0); /* 00000007 STENCIL_BACK_OP_FAIL, ZFAIL, ZPASS */
1725 xf_emit(ctx, 1, 2); /* 00000003 tesla UNK143C */
1726 xf_emit(ctx, 2, 0x04000000); /* 07ffffff tesla UNK0D6C */
1727 xf_emit(ctx, 1, 0); /* ffff0ff3 */
1728 xf_emit(ctx, 1, 0); /* 00000001 CLIPID_ENABLE */
1729 xf_emit(ctx, 2, 0); /* ffffffff DEPTH_BOUNDS */
1730 xf_emit(ctx, 1, 0); /* 00000001 */
1731 xf_emit(ctx, 1, 0); /* 00000007 DEPTH_TEST_FUNC */
1732 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
1733 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
1734 xf_emit(ctx, 1, 4); /* 0000000f CULL_MODE */
1735 xf_emit(ctx, 1, 0); /* 0000ffff */
1736 xf_emit(ctx, 1, 0); /* 00000001 UNK0FB0 */
1737 xf_emit(ctx, 1, 0); /* 00000001 POLYGON_STIPPLE_ENABLE */
1738 xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
1739 xf_emit(ctx, 1, 0); /* ffffffff */
1740 xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
1741 xf_emit(ctx, 1, 0); /* 000000ff CLEAR_STENCIL */
1742 xf_emit(ctx, 1, 0); /* 00000007 STENCIL_FRONT_FUNC_FUNC */
1743 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_MASK */
1744 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_REF */
1745 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
1746 xf_emit(ctx, 3, 0); /* 00000007 STENCIL_FRONT_OP_FAIL, ZFAIL, ZPASS */
1747 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
1748 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
1749 xf_emit(ctx, 1, 0); /* ffffffff CLEAR_DEPTH */
1750 xf_emit(ctx, 1, 0); /* 00000007 */
1751 if (dev_priv->chipset != 0x50)
1752 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1108 */
1753 xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
1754 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
1755 xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
1756 xf_emit(ctx, 1, 0x1001); /* 00001fff ZETA_ARRAY_MODE */
1757 /* SEEK */
1758 xf_emit(ctx, 4, 0xffff); /* 0000ffff MSAA_MASK */
1759 xf_emit(ctx, 0x10, 0); /* 00000001 SCISSOR_ENABLE */
1760 xf_emit(ctx, 0x10, 0); /* ffffffff DEPTH_RANGE_NEAR */
1761 xf_emit(ctx, 0x10, 0x3f800000); /* ffffffff DEPTH_RANGE_FAR */
1762 xf_emit(ctx, 1, 0x10); /* 7f/ff/3ff VIEW_VOLUME_CLIP_CTRL */
1763 xf_emit(ctx, 1, 0); /* 00000001 VIEWPORT_CLIP_RECTS_EN */
1764 xf_emit(ctx, 1, 3); /* 00000003 FP_CTRL_UNK196C */
1765 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1968 */
1766 if (dev_priv->chipset != 0x50)
1767 xf_emit(ctx, 1, 0); /* 0fffffff tesla UNK1104 */
1768 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK151C */
1771 static void
1772 nv50_graph_construct_gene_clipid(struct nouveau_grctx *ctx)
1774 /* middle of strand 0 on pre-NVA0 [after 24xx], middle of area 6 on NVAx */
1775 /* SEEK */
1776 xf_emit(ctx, 1, 0); /* 00000007 UNK0FB4 */
1777 /* SEEK */
1778 xf_emit(ctx, 4, 0); /* 07ffffff CLIPID_REGION_HORIZ */
1779 xf_emit(ctx, 4, 0); /* 07ffffff CLIPID_REGION_VERT */
1780 xf_emit(ctx, 2, 0); /* 07ffffff SCREEN_SCISSOR */
1781 xf_emit(ctx, 2, 0x04000000); /* 07ffffff UNK1508 */
1782 xf_emit(ctx, 1, 0); /* 00000001 CLIPID_ENABLE */
1783 xf_emit(ctx, 1, 0x80); /* 00003fff CLIPID_WIDTH */
1784 xf_emit(ctx, 1, 0); /* 000000ff CLIPID_ID */
1785 xf_emit(ctx, 1, 0); /* 000000ff CLIPID_ADDRESS_HIGH */
1786 xf_emit(ctx, 1, 0); /* ffffffff CLIPID_ADDRESS_LOW */
1787 xf_emit(ctx, 1, 0x80); /* 00003fff CLIPID_HEIGHT */
1788 xf_emit(ctx, 1, 0); /* 0000ffff DMA_CLIPID */
1791 static void
1792 nv50_graph_construct_gene_unk24xx(struct nouveau_grctx *ctx)
1794 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
1795 int i;
1796 /* middle of strand 0 on pre-NVA0 [after m2mf], end of strand 2 on NVAx */
1797 /* SEEK */
1798 xf_emit(ctx, 0x33, 0);
1799 /* SEEK */
1800 xf_emit(ctx, 2, 0);
1801 /* SEEK */
1802 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1803 xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
1804 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
1805 /* SEEK */
1806 if (IS_NVA3F(dev_priv->chipset)) {
1807 xf_emit(ctx, 4, 0); /* RO */
1808 xf_emit(ctx, 0xe10, 0); /* 190 * 9: 8*ffffffff, 7ff */
1809 xf_emit(ctx, 1, 0); /* 1ff */
1810 xf_emit(ctx, 8, 0); /* 0? */
1811 xf_emit(ctx, 9, 0); /* ffffffff, 7ff */
1813 xf_emit(ctx, 4, 0); /* RO */
1814 xf_emit(ctx, 0xe10, 0); /* 190 * 9: 8*ffffffff, 7ff */
1815 xf_emit(ctx, 1, 0); /* 1ff */
1816 xf_emit(ctx, 8, 0); /* 0? */
1817 xf_emit(ctx, 9, 0); /* ffffffff, 7ff */
1819 else
1821 xf_emit(ctx, 0xc, 0); /* RO */
1822 /* SEEK */
1823 xf_emit(ctx, 0xe10, 0); /* 190 * 9: 8*ffffffff, 7ff */
1824 xf_emit(ctx, 1, 0); /* 1ff */
1825 xf_emit(ctx, 8, 0); /* 0? */
1827 /* SEEK */
1828 xf_emit(ctx, 0xc, 0); /* RO */
1829 /* SEEK */
1830 xf_emit(ctx, 0xe10, 0); /* 190 * 9: 8*ffffffff, 7ff */
1831 xf_emit(ctx, 1, 0); /* 1ff */
1832 xf_emit(ctx, 8, 0); /* 0? */
1834 /* SEEK */
1835 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1836 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
1837 xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
1838 xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
1839 if (dev_priv->chipset != 0x50)
1840 xf_emit(ctx, 1, 3); /* 00000003 tesla UNK1100 */
1841 /* SEEK */
1842 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1843 xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
1844 xf_emit(ctx, 1, 0); /* 0000000f VP_GP_BUILTIN_ATTR_EN */
1845 xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
1846 xf_emit(ctx, 1, 1); /* 00000001 */
1847 /* SEEK */
1848 if (dev_priv->chipset >= 0xa0)
1849 xf_emit(ctx, 2, 4); /* 000000ff */
1850 xf_emit(ctx, 1, 0x80c14); /* 01ffffff SEMANTIC_COLOR */
1851 xf_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE */
1852 xf_emit(ctx, 1, 0); /* 00000001 POINT_SPRITE_ENABLE */
1853 xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
1854 xf_emit(ctx, 1, 0x27); /* 000000ff SEMANTIC_PRIM_ID */
1855 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1856 xf_emit(ctx, 1, 0); /* 0000000f */
1857 xf_emit(ctx, 1, 1); /* 00000001 */
1858 for (i = 0; i < 10; i++) {
1859 /* SEEK */
1860 xf_emit(ctx, 0x40, 0); /* ffffffff */
1861 xf_emit(ctx, 0x10, 0); /* 3, 0, 0.... */
1862 xf_emit(ctx, 0x10, 0); /* ffffffff */
1864 /* SEEK */
1865 xf_emit(ctx, 1, 0); /* 00000001 POINT_SPRITE_CTRL */
1866 xf_emit(ctx, 1, 1); /* 00000001 */
1867 xf_emit(ctx, 1, 0); /* ffffffff */
1868 xf_emit(ctx, 4, 0); /* ffffffff NOPERSPECTIVE_BITMAP */
1869 xf_emit(ctx, 0x10, 0); /* 00ffffff POINT_COORD_REPLACE_MAP */
1870 xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
1871 xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
1872 if (dev_priv->chipset != 0x50)
1873 xf_emit(ctx, 1, 0); /* 000003ff */
1876 static void
1877 nv50_graph_construct_gene_vfetch(struct nouveau_grctx *ctx)
1879 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
1880 int acnt = 0x10, rep, i;
1881 /* beginning of strand 1 on pre-NVA0, strand 3 on NVAx */
1882 if (IS_NVA3F(dev_priv->chipset))
1883 acnt = 0x20;
1884 /* SEEK */
1885 if (dev_priv->chipset >= 0xa0) {
1886 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK13A4 */
1887 xf_emit(ctx, 1, 1); /* 00000fff tesla UNK1318 */
1889 xf_emit(ctx, 1, 0); /* ffffffff VERTEX_BUFFER_FIRST */
1890 xf_emit(ctx, 1, 0); /* 00000001 PRIMITIVE_RESTART_ENABLE */
1891 xf_emit(ctx, 1, 0); /* 00000001 UNK0DE8 */
1892 xf_emit(ctx, 1, 0); /* ffffffff PRIMITIVE_RESTART_INDEX */
1893 xf_emit(ctx, 1, 0xf); /* ffffffff VP_ATTR_EN */
1894 xf_emit(ctx, (acnt/8)-1, 0); /* ffffffff VP_ATTR_EN */
1895 xf_emit(ctx, acnt/8, 0); /* ffffffff VTX_ATR_MASK_UNK0DD0 */
1896 xf_emit(ctx, 1, 0); /* 0000000f VP_GP_BUILTIN_ATTR_EN */
1897 xf_emit(ctx, 1, 0x20); /* 0000ffff tesla UNK129C */
1898 xf_emit(ctx, 1, 0); /* 000000ff turing UNK370??? */
1899 xf_emit(ctx, 1, 0); /* 0000ffff turing USER_PARAM_COUNT */
1900 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
1901 /* SEEK */
1902 if (IS_NVA3F(dev_priv->chipset))
1903 xf_emit(ctx, 0xb, 0); /* RO */
1904 else if (dev_priv->chipset >= 0xa0)
1905 xf_emit(ctx, 0x9, 0); /* RO */
1906 else
1907 xf_emit(ctx, 0x8, 0); /* RO */
1908 /* SEEK */
1909 xf_emit(ctx, 1, 0); /* 00000001 EDGE_FLAG */
1910 xf_emit(ctx, 1, 0); /* 00000001 PROVOKING_VERTEX_LAST */
1911 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1912 xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
1913 /* SEEK */
1914 xf_emit(ctx, 0xc, 0); /* RO */
1915 /* SEEK */
1916 xf_emit(ctx, 1, 0); /* 7f/ff */
1917 xf_emit(ctx, 1, 4); /* 7f/ff VP_REG_ALLOC_RESULT */
1918 xf_emit(ctx, 1, 4); /* 7f/ff VP_RESULT_MAP_SIZE */
1919 xf_emit(ctx, 1, 0); /* 0000000f VP_GP_BUILTIN_ATTR_EN */
1920 xf_emit(ctx, 1, 4); /* 000001ff UNK1A28 */
1921 xf_emit(ctx, 1, 8); /* 000001ff UNK0DF0 */
1922 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
1923 if (dev_priv->chipset == 0x50)
1924 xf_emit(ctx, 1, 0x3ff); /* 3ff tesla UNK0D68 */
1925 else
1926 xf_emit(ctx, 1, 0x7ff); /* 7ff tesla UNK0D68 */
1927 if (dev_priv->chipset == 0xa8)
1928 xf_emit(ctx, 1, 0x1e00); /* 7fff */
1929 /* SEEK */
1930 xf_emit(ctx, 0xc, 0); /* RO or close */
1931 /* SEEK */
1932 xf_emit(ctx, 1, 0xf); /* ffffffff VP_ATTR_EN */
1933 xf_emit(ctx, (acnt/8)-1, 0); /* ffffffff VP_ATTR_EN */
1934 xf_emit(ctx, 1, 0); /* 0000000f VP_GP_BUILTIN_ATTR_EN */
1935 if (dev_priv->chipset > 0x50 && dev_priv->chipset < 0xa0)
1936 xf_emit(ctx, 2, 0); /* ffffffff */
1937 else
1938 xf_emit(ctx, 1, 0); /* ffffffff */
1939 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK0FD8 */
1940 /* SEEK */
1941 if (IS_NVA3F(dev_priv->chipset)) {
1942 xf_emit(ctx, 0x10, 0); /* 0? */
1943 xf_emit(ctx, 2, 0); /* weird... */
1944 xf_emit(ctx, 2, 0); /* RO */
1945 } else {
1946 xf_emit(ctx, 8, 0); /* 0? */
1947 xf_emit(ctx, 1, 0); /* weird... */
1948 xf_emit(ctx, 2, 0); /* RO */
1950 /* SEEK */
1951 xf_emit(ctx, 1, 0); /* ffffffff VB_ELEMENT_BASE */
1952 xf_emit(ctx, 1, 0); /* ffffffff UNK1438 */
1953 xf_emit(ctx, acnt, 0); /* 1 tesla UNK1000 */
1954 if (dev_priv->chipset >= 0xa0)
1955 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1118? */
1956 /* SEEK */
1957 xf_emit(ctx, acnt, 0); /* ffffffff VERTEX_ARRAY_UNK90C */
1958 xf_emit(ctx, 1, 0); /* f/1f */
1959 /* SEEK */
1960 xf_emit(ctx, acnt, 0); /* ffffffff VERTEX_ARRAY_UNK90C */
1961 xf_emit(ctx, 1, 0); /* f/1f */
1962 /* SEEK */
1963 xf_emit(ctx, acnt, 0); /* RO */
1964 xf_emit(ctx, 2, 0); /* RO */
1965 /* SEEK */
1966 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK111C? */
1967 xf_emit(ctx, 1, 0); /* RO */
1968 /* SEEK */
1969 xf_emit(ctx, 1, 0); /* 000000ff UNK15F4_ADDRESS_HIGH */
1970 xf_emit(ctx, 1, 0); /* ffffffff UNK15F4_ADDRESS_LOW */
1971 xf_emit(ctx, 1, 0); /* 000000ff UNK0F84_ADDRESS_HIGH */
1972 xf_emit(ctx, 1, 0); /* ffffffff UNK0F84_ADDRESS_LOW */
1973 /* SEEK */
1974 xf_emit(ctx, acnt, 0); /* 00003fff VERTEX_ARRAY_ATTRIB_OFFSET */
1975 xf_emit(ctx, 3, 0); /* f/1f */
1976 /* SEEK */
1977 xf_emit(ctx, acnt, 0); /* 00000fff VERTEX_ARRAY_STRIDE */
1978 xf_emit(ctx, 3, 0); /* f/1f */
1979 /* SEEK */
1980 xf_emit(ctx, acnt, 0); /* ffffffff VERTEX_ARRAY_LOW */
1981 xf_emit(ctx, 3, 0); /* f/1f */
1982 /* SEEK */
1983 xf_emit(ctx, acnt, 0); /* 000000ff VERTEX_ARRAY_HIGH */
1984 xf_emit(ctx, 3, 0); /* f/1f */
1985 /* SEEK */
1986 xf_emit(ctx, acnt, 0); /* ffffffff VERTEX_LIMIT_LOW */
1987 xf_emit(ctx, 3, 0); /* f/1f */
1988 /* SEEK */
1989 xf_emit(ctx, acnt, 0); /* 000000ff VERTEX_LIMIT_HIGH */
1990 xf_emit(ctx, 3, 0); /* f/1f */
1991 /* SEEK */
1992 if (IS_NVA3F(dev_priv->chipset)) {
1993 xf_emit(ctx, acnt, 0); /* f */
1994 xf_emit(ctx, 3, 0); /* f/1f */
1996 /* SEEK */
1997 if (IS_NVA3F(dev_priv->chipset))
1998 xf_emit(ctx, 2, 0); /* RO */
1999 else
2000 xf_emit(ctx, 5, 0); /* RO */
2001 /* SEEK */
2002 xf_emit(ctx, 1, 0); /* ffff DMA_VTXBUF */
2003 /* SEEK */
2004 if (dev_priv->chipset < 0xa0) {
2005 xf_emit(ctx, 0x41, 0); /* RO */
2006 /* SEEK */
2007 xf_emit(ctx, 0x11, 0); /* RO */
2008 } else if (!IS_NVA3F(dev_priv->chipset))
2009 xf_emit(ctx, 0x50, 0); /* RO */
2010 else
2011 xf_emit(ctx, 0x58, 0); /* RO */
2012 /* SEEK */
2013 xf_emit(ctx, 1, 0xf); /* ffffffff VP_ATTR_EN */
2014 xf_emit(ctx, (acnt/8)-1, 0); /* ffffffff VP_ATTR_EN */
2015 xf_emit(ctx, 1, 1); /* 1 UNK0DEC */
2016 /* SEEK */
2017 xf_emit(ctx, acnt*4, 0); /* ffffffff VTX_ATTR */
2018 xf_emit(ctx, 4, 0); /* f/1f, 0, 0, 0 */
2019 /* SEEK */
2020 if (IS_NVA3F(dev_priv->chipset))
2021 xf_emit(ctx, 0x1d, 0); /* RO */
2022 else
2023 xf_emit(ctx, 0x16, 0); /* RO */
2024 /* SEEK */
2025 xf_emit(ctx, 1, 0xf); /* ffffffff VP_ATTR_EN */
2026 xf_emit(ctx, (acnt/8)-1, 0); /* ffffffff VP_ATTR_EN */
2027 /* SEEK */
2028 if (dev_priv->chipset < 0xa0)
2029 xf_emit(ctx, 8, 0); /* RO */
2030 else if (IS_NVA3F(dev_priv->chipset))
2031 xf_emit(ctx, 0xc, 0); /* RO */
2032 else
2033 xf_emit(ctx, 7, 0); /* RO */
2034 /* SEEK */
2035 xf_emit(ctx, 0xa, 0); /* RO */
2036 if (dev_priv->chipset == 0xa0)
2037 rep = 0xc;
2038 else
2039 rep = 4;
2040 for (i = 0; i < rep; i++) {
2041 /* SEEK */
2042 if (IS_NVA3F(dev_priv->chipset))
2043 xf_emit(ctx, 0x20, 0); /* ffffffff */
2044 xf_emit(ctx, 0x200, 0); /* ffffffff */
2045 xf_emit(ctx, 4, 0); /* 7f/ff, 0, 0, 0 */
2046 xf_emit(ctx, 4, 0); /* ffffffff */
2048 /* SEEK */
2049 xf_emit(ctx, 1, 0); /* 113/111 */
2050 xf_emit(ctx, 1, 0xf); /* ffffffff VP_ATTR_EN */
2051 xf_emit(ctx, (acnt/8)-1, 0); /* ffffffff VP_ATTR_EN */
2052 xf_emit(ctx, acnt/8, 0); /* ffffffff VTX_ATTR_MASK_UNK0DD0 */
2053 xf_emit(ctx, 1, 0); /* 0000000f VP_GP_BUILTIN_ATTR_EN */
2054 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2055 /* SEEK */
2056 if (IS_NVA3F(dev_priv->chipset))
2057 xf_emit(ctx, 7, 0); /* weird... */
2058 else
2059 xf_emit(ctx, 5, 0); /* weird... */
2062 static void
2063 nv50_graph_construct_gene_eng2d(struct nouveau_grctx *ctx)
2065 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
2066 /* middle of strand 1 on pre-NVA0 [after vfetch], middle of strand 6 on NVAx */
2067 /* SEEK */
2068 xf_emit(ctx, 2, 0); /* 0001ffff CLIP_X, CLIP_Y */
2069 xf_emit(ctx, 2, 0); /* 0000ffff CLIP_W, CLIP_H */
2070 xf_emit(ctx, 1, 0); /* 00000001 CLIP_ENABLE */
2071 if (dev_priv->chipset < 0xa0) {
2072 /* this is useless on everything but the original NV50,
2073 * guess they forgot to nuke it. Or just didn't bother. */
2074 xf_emit(ctx, 2, 0); /* 0000ffff IFC_CLIP_X, Y */
2075 xf_emit(ctx, 2, 1); /* 0000ffff IFC_CLIP_W, H */
2076 xf_emit(ctx, 1, 0); /* 00000001 IFC_CLIP_ENABLE */
2078 xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
2079 xf_emit(ctx, 1, 0x100); /* 0001ffff DST_WIDTH */
2080 xf_emit(ctx, 1, 0x100); /* 0001ffff DST_HEIGHT */
2081 xf_emit(ctx, 1, 0x11); /* 3f[NV50]/7f[NV84+] DST_FORMAT */
2082 xf_emit(ctx, 1, 0); /* 0001ffff DRAW_POINT_X */
2083 xf_emit(ctx, 1, 8); /* 0000000f DRAW_UNK58C */
2084 xf_emit(ctx, 1, 0); /* 000fffff SIFC_DST_X_FRACT */
2085 xf_emit(ctx, 1, 0); /* 0001ffff SIFC_DST_X_INT */
2086 xf_emit(ctx, 1, 0); /* 000fffff SIFC_DST_Y_FRACT */
2087 xf_emit(ctx, 1, 0); /* 0001ffff SIFC_DST_Y_INT */
2088 xf_emit(ctx, 1, 0); /* 000fffff SIFC_DX_DU_FRACT */
2089 xf_emit(ctx, 1, 1); /* 0001ffff SIFC_DX_DU_INT */
2090 xf_emit(ctx, 1, 0); /* 000fffff SIFC_DY_DV_FRACT */
2091 xf_emit(ctx, 1, 1); /* 0001ffff SIFC_DY_DV_INT */
2092 xf_emit(ctx, 1, 1); /* 0000ffff SIFC_WIDTH */
2093 xf_emit(ctx, 1, 1); /* 0000ffff SIFC_HEIGHT */
2094 xf_emit(ctx, 1, 0xcf); /* 000000ff SIFC_FORMAT */
2095 xf_emit(ctx, 1, 2); /* 00000003 SIFC_BITMAP_UNK808 */
2096 xf_emit(ctx, 1, 0); /* 00000003 SIFC_BITMAP_LINE_PACK_MODE */
2097 xf_emit(ctx, 1, 0); /* 00000001 SIFC_BITMAP_LSB_FIRST */
2098 xf_emit(ctx, 1, 0); /* 00000001 SIFC_BITMAP_ENABLE */
2099 xf_emit(ctx, 1, 0); /* 0000ffff BLIT_DST_X */
2100 xf_emit(ctx, 1, 0); /* 0000ffff BLIT_DST_Y */
2101 xf_emit(ctx, 1, 0); /* 000fffff BLIT_DU_DX_FRACT */
2102 xf_emit(ctx, 1, 1); /* 0001ffff BLIT_DU_DX_INT */
2103 xf_emit(ctx, 1, 0); /* 000fffff BLIT_DV_DY_FRACT */
2104 xf_emit(ctx, 1, 1); /* 0001ffff BLIT_DV_DY_INT */
2105 xf_emit(ctx, 1, 1); /* 0000ffff BLIT_DST_W */
2106 xf_emit(ctx, 1, 1); /* 0000ffff BLIT_DST_H */
2107 xf_emit(ctx, 1, 0); /* 000fffff BLIT_SRC_X_FRACT */
2108 xf_emit(ctx, 1, 0); /* 0001ffff BLIT_SRC_X_INT */
2109 xf_emit(ctx, 1, 0); /* 000fffff BLIT_SRC_Y_FRACT */
2110 xf_emit(ctx, 1, 0); /* 00000001 UNK888 */
2111 xf_emit(ctx, 1, 4); /* 0000003f UNK884 */
2112 xf_emit(ctx, 1, 0); /* 00000007 UNK880 */
2113 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK0FB8 */
2114 xf_emit(ctx, 1, 0x15); /* 000000ff tesla UNK128C */
2115 xf_emit(ctx, 2, 0); /* 00000007, ffff0ff3 */
2116 xf_emit(ctx, 1, 0); /* 00000001 UNK260 */
2117 xf_emit(ctx, 1, 0x4444480); /* 1fffffff UNK870 */
2118 /* SEEK */
2119 xf_emit(ctx, 0x10, 0);
2120 /* SEEK */
2121 xf_emit(ctx, 0x27, 0);
2124 static void
2125 nv50_graph_construct_gene_csched(struct nouveau_grctx *ctx)
2127 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
2128 /* middle of strand 1 on pre-NVA0 [after eng2d], middle of strand 0 on NVAx */
2129 /* SEEK */
2130 xf_emit(ctx, 2, 0); /* 00007fff WINDOW_OFFSET_XY... what is it doing here??? */
2131 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1924 */
2132 xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
2133 xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
2134 xf_emit(ctx, 1, 0); /* 000003ff */
2135 /* SEEK */
2136 xf_emit(ctx, 1, 0); /* ffffffff turing UNK364 */
2137 xf_emit(ctx, 1, 0); /* 0000000f turing UNK36C */
2138 xf_emit(ctx, 1, 0); /* 0000ffff USER_PARAM_COUNT */
2139 xf_emit(ctx, 1, 0x100); /* 00ffffff turing UNK384 */
2140 xf_emit(ctx, 1, 0); /* 0000000f turing UNK2A0 */
2141 xf_emit(ctx, 1, 0); /* 0000ffff GRIDID */
2142 xf_emit(ctx, 1, 0x10001); /* ffffffff GRIDDIM_XY */
2143 xf_emit(ctx, 1, 0); /* ffffffff */
2144 xf_emit(ctx, 1, 0x10001); /* ffffffff BLOCKDIM_XY */
2145 xf_emit(ctx, 1, 1); /* 0000ffff BLOCKDIM_Z */
2146 xf_emit(ctx, 1, 0x10001); /* 00ffffff BLOCK_ALLOC */
2147 xf_emit(ctx, 1, 1); /* 00000001 LANES32 */
2148 xf_emit(ctx, 1, 4); /* 000000ff FP_REG_ALLOC_TEMP */
2149 xf_emit(ctx, 1, 2); /* 00000003 REG_MODE */
2150 /* SEEK */
2151 xf_emit(ctx, 0x40, 0); /* ffffffff USER_PARAM */
2152 switch (dev_priv->chipset) {
2153 case 0x50:
2154 case 0x92:
2155 xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
2156 xf_emit(ctx, 0x80, 0); /* fff */
2157 xf_emit(ctx, 2, 0); /* ff, fff */
2158 xf_emit(ctx, 0x10*2, 0); /* ffffffff, 1f */
2159 break;
2160 case 0x84:
2161 xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
2162 xf_emit(ctx, 0x60, 0); /* fff */
2163 xf_emit(ctx, 2, 0); /* ff, fff */
2164 xf_emit(ctx, 0xc*2, 0); /* ffffffff, 1f */
2165 break;
2166 case 0x94:
2167 case 0x96:
2168 xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
2169 xf_emit(ctx, 0x40, 0); /* fff */
2170 xf_emit(ctx, 2, 0); /* ff, fff */
2171 xf_emit(ctx, 8*2, 0); /* ffffffff, 1f */
2172 break;
2173 case 0x86:
2174 case 0x98:
2175 xf_emit(ctx, 4, 0); /* f, 0, 0, 0 */
2176 xf_emit(ctx, 0x10, 0); /* fff */
2177 xf_emit(ctx, 2, 0); /* ff, fff */
2178 xf_emit(ctx, 2*2, 0); /* ffffffff, 1f */
2179 break;
2180 case 0xa0:
2181 xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
2182 xf_emit(ctx, 0xf0, 0); /* fff */
2183 xf_emit(ctx, 2, 0); /* ff, fff */
2184 xf_emit(ctx, 0x1e*2, 0); /* ffffffff, 1f */
2185 break;
2186 case 0xa3:
2187 xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
2188 xf_emit(ctx, 0x60, 0); /* fff */
2189 xf_emit(ctx, 2, 0); /* ff, fff */
2190 xf_emit(ctx, 0xc*2, 0); /* ffffffff, 1f */
2191 break;
2192 case 0xa5:
2193 case 0xaf:
2194 xf_emit(ctx, 8, 0); /* 7, 0, 0, 0, ... */
2195 xf_emit(ctx, 0x30, 0); /* fff */
2196 xf_emit(ctx, 2, 0); /* ff, fff */
2197 xf_emit(ctx, 6*2, 0); /* ffffffff, 1f */
2198 break;
2199 case 0xaa:
2200 xf_emit(ctx, 0x12, 0);
2201 break;
2202 case 0xa8:
2203 case 0xac:
2204 xf_emit(ctx, 4, 0); /* f, 0, 0, 0 */
2205 xf_emit(ctx, 0x10, 0); /* fff */
2206 xf_emit(ctx, 2, 0); /* ff, fff */
2207 xf_emit(ctx, 2*2, 0); /* ffffffff, 1f */
2208 break;
2210 xf_emit(ctx, 1, 0); /* 0000000f */
2211 xf_emit(ctx, 1, 0); /* 00000000 */
2212 xf_emit(ctx, 1, 0); /* ffffffff */
2213 xf_emit(ctx, 1, 0); /* 0000001f */
2214 xf_emit(ctx, 4, 0); /* ffffffff */
2215 xf_emit(ctx, 1, 0); /* 00000003 turing UNK35C */
2216 xf_emit(ctx, 1, 0); /* ffffffff */
2217 xf_emit(ctx, 4, 0); /* ffffffff */
2218 xf_emit(ctx, 1, 0); /* 00000003 turing UNK35C */
2219 xf_emit(ctx, 1, 0); /* ffffffff */
2220 xf_emit(ctx, 1, 0); /* 000000ff */
2223 static void
2224 nv50_graph_construct_gene_unk1cxx(struct nouveau_grctx *ctx)
2226 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
2227 xf_emit(ctx, 2, 0); /* 00007fff WINDOW_OFFSET_XY */
2228 xf_emit(ctx, 1, 0x3f800000); /* ffffffff LINE_WIDTH */
2229 xf_emit(ctx, 1, 0); /* 00000001 LINE_SMOOTH_ENABLE */
2230 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1658 */
2231 xf_emit(ctx, 1, 0); /* 00000001 POLYGON_SMOOTH_ENABLE */
2232 xf_emit(ctx, 3, 0); /* 00000001 POLYGON_OFFSET_*_ENABLE */
2233 xf_emit(ctx, 1, 4); /* 0000000f CULL_MODE */
2234 xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
2235 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2236 xf_emit(ctx, 1, 0); /* 00000001 POINT_SPRITE_ENABLE */
2237 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK165C */
2238 xf_emit(ctx, 0x10, 0); /* 00000001 SCISSOR_ENABLE */
2239 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
2240 xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
2241 xf_emit(ctx, 1, 0x00ffff00); /* 00ffffff LINE_STIPPLE_PATTERN */
2242 xf_emit(ctx, 1, 0); /* ffffffff POLYGON_OFFSET_UNITS */
2243 xf_emit(ctx, 1, 0); /* ffffffff POLYGON_OFFSET_FACTOR */
2244 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1668 */
2245 xf_emit(ctx, 2, 0); /* 07ffffff SCREEN_SCISSOR */
2246 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
2247 xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
2248 xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
2249 xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
2250 xf_emit(ctx, 1, 0x11); /* 0000007f RT_FORMAT */
2251 xf_emit(ctx, 7, 0); /* 0000007f RT_FORMAT */
2252 xf_emit(ctx, 8, 0); /* 00000001 RT_HORIZ_LINEAR */
2253 xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
2254 xf_emit(ctx, 1, 0); /* 00000001 ALPHA_TEST_ENABLE */
2255 xf_emit(ctx, 1, 0); /* 00000007 ALPHA_TEST_FUNC */
2256 if (IS_NVA3F(dev_priv->chipset))
2257 xf_emit(ctx, 1, 3); /* 00000003 UNK16B4 */
2258 else if (dev_priv->chipset >= 0xa0)
2259 xf_emit(ctx, 1, 1); /* 00000001 UNK16B4 */
2260 xf_emit(ctx, 1, 0); /* 00000003 MULTISAMPLE_CTRL */
2261 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK0F90 */
2262 xf_emit(ctx, 1, 2); /* 00000003 tesla UNK143C */
2263 xf_emit(ctx, 2, 0x04000000); /* 07ffffff tesla UNK0D6C */
2264 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
2265 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
2266 xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
2267 xf_emit(ctx, 1, 5); /* 0000000f UNK1408 */
2268 xf_emit(ctx, 1, 0x52); /* 000001ff SEMANTIC_PTSZ */
2269 xf_emit(ctx, 1, 0); /* ffffffff POINT_SIZE */
2270 xf_emit(ctx, 1, 0); /* 00000001 */
2271 xf_emit(ctx, 1, 0); /* 00000007 tesla UNK0FB4 */
2272 if (dev_priv->chipset != 0x50) {
2273 xf_emit(ctx, 1, 0); /* 3ff */
2274 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK1110 */
2276 if (IS_NVA3F(dev_priv->chipset))
2277 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1928 */
2278 xf_emit(ctx, 0x10, 0); /* ffffffff DEPTH_RANGE_NEAR */
2279 xf_emit(ctx, 0x10, 0x3f800000); /* ffffffff DEPTH_RANGE_FAR */
2280 xf_emit(ctx, 1, 0x10); /* 000000ff VIEW_VOLUME_CLIP_CTRL */
2281 xf_emit(ctx, 0x20, 0); /* 07ffffff VIEWPORT_HORIZ, then VIEWPORT_VERT. (W&0x3fff)<<13 | (X&0x1fff). */
2282 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK187C */
2283 xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
2284 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
2285 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
2286 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
2287 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_MASK */
2288 xf_emit(ctx, 1, 0x8100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
2289 xf_emit(ctx, 1, 5); /* 0000000f tesla UNK1220 */
2290 xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
2291 xf_emit(ctx, 1, 0); /* 000000ff tesla UNK1A20 */
2292 xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
2293 xf_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE */
2294 xf_emit(ctx, 4, 0xffff); /* 0000ffff MSAA_MASK */
2295 if (dev_priv->chipset != 0x50)
2296 xf_emit(ctx, 1, 3); /* 00000003 tesla UNK1100 */
2297 if (dev_priv->chipset < 0xa0)
2298 xf_emit(ctx, 0x1c, 0); /* RO */
2299 else if (IS_NVA3F(dev_priv->chipset))
2300 xf_emit(ctx, 0x9, 0);
2301 xf_emit(ctx, 1, 0); /* 00000001 UNK1534 */
2302 xf_emit(ctx, 1, 0); /* 00000001 LINE_SMOOTH_ENABLE */
2303 xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
2304 xf_emit(ctx, 1, 0x00ffff00); /* 00ffffff LINE_STIPPLE_PATTERN */
2305 xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
2306 xf_emit(ctx, 1, 0); /* 00000003 WINDOW_ORIGIN */
2307 if (dev_priv->chipset != 0x50) {
2308 xf_emit(ctx, 1, 3); /* 00000003 tesla UNK1100 */
2309 xf_emit(ctx, 1, 0); /* 3ff */
2311 /* XXX: the following block could belong either to unk1cxx, or
2312 * to STRMOUT. Rather hard to tell. */
2313 if (dev_priv->chipset < 0xa0)
2314 xf_emit(ctx, 0x25, 0);
2315 else
2316 xf_emit(ctx, 0x3b, 0);
2319 static void
2320 nv50_graph_construct_gene_strmout(struct nouveau_grctx *ctx)
2322 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
2323 xf_emit(ctx, 1, 0x102); /* 0000ffff STRMOUT_BUFFER_CTRL */
2324 xf_emit(ctx, 1, 0); /* ffffffff STRMOUT_PRIMITIVE_COUNT */
2325 xf_emit(ctx, 4, 4); /* 000000ff STRMOUT_NUM_ATTRIBS */
2326 if (dev_priv->chipset >= 0xa0) {
2327 xf_emit(ctx, 4, 0); /* ffffffff UNK1A8C */
2328 xf_emit(ctx, 4, 0); /* ffffffff UNK1780 */
2330 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
2331 xf_emit(ctx, 1, 4); /* 0000007f VP_RESULT_MAP_SIZE */
2332 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
2333 if (dev_priv->chipset == 0x50)
2334 xf_emit(ctx, 1, 0x3ff); /* 000003ff tesla UNK0D68 */
2335 else
2336 xf_emit(ctx, 1, 0x7ff); /* 000007ff tesla UNK0D68 */
2337 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2338 /* SEEK */
2339 xf_emit(ctx, 1, 0x102); /* 0000ffff STRMOUT_BUFFER_CTRL */
2340 xf_emit(ctx, 1, 0); /* ffffffff STRMOUT_PRIMITIVE_COUNT */
2341 xf_emit(ctx, 4, 0); /* 000000ff STRMOUT_ADDRESS_HIGH */
2342 xf_emit(ctx, 4, 0); /* ffffffff STRMOUT_ADDRESS_LOW */
2343 xf_emit(ctx, 4, 4); /* 000000ff STRMOUT_NUM_ATTRIBS */
2344 if (dev_priv->chipset >= 0xa0) {
2345 xf_emit(ctx, 4, 0); /* ffffffff UNK1A8C */
2346 xf_emit(ctx, 4, 0); /* ffffffff UNK1780 */
2348 xf_emit(ctx, 1, 0); /* 0000ffff DMA_STRMOUT */
2349 xf_emit(ctx, 1, 0); /* 0000ffff DMA_QUERY */
2350 xf_emit(ctx, 1, 0); /* 000000ff QUERY_ADDRESS_HIGH */
2351 xf_emit(ctx, 2, 0); /* ffffffff QUERY_ADDRESS_LOW QUERY_COUNTER */
2352 xf_emit(ctx, 2, 0); /* ffffffff */
2353 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2354 /* SEEK */
2355 xf_emit(ctx, 0x20, 0); /* ffffffff STRMOUT_MAP */
2356 xf_emit(ctx, 1, 0); /* 0000000f */
2357 xf_emit(ctx, 1, 0); /* 00000000? */
2358 xf_emit(ctx, 2, 0); /* ffffffff */
2361 static void
2362 nv50_graph_construct_gene_ropm1(struct nouveau_grctx *ctx)
2364 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
2365 xf_emit(ctx, 1, 0x4e3bfdf); /* ffffffff UNK0D64 */
2366 xf_emit(ctx, 1, 0x4e3bfdf); /* ffffffff UNK0DF4 */
2367 xf_emit(ctx, 1, 0); /* 00000007 */
2368 xf_emit(ctx, 1, 0); /* 000003ff */
2369 if (IS_NVA3F(dev_priv->chipset))
2370 xf_emit(ctx, 1, 0x11); /* 000000ff tesla UNK1968 */
2371 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2374 static void
2375 nv50_graph_construct_gene_ropm2(struct nouveau_grctx *ctx)
2377 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
2378 /* SEEK */
2379 xf_emit(ctx, 1, 0); /* 0000ffff DMA_QUERY */
2380 xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
2381 xf_emit(ctx, 2, 0); /* ffffffff */
2382 xf_emit(ctx, 1, 0); /* 000000ff QUERY_ADDRESS_HIGH */
2383 xf_emit(ctx, 2, 0); /* ffffffff QUERY_ADDRESS_LOW, COUNTER */
2384 xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
2385 xf_emit(ctx, 1, 0); /* 7 */
2386 /* SEEK */
2387 xf_emit(ctx, 1, 0); /* 0000ffff DMA_QUERY */
2388 xf_emit(ctx, 1, 0); /* 000000ff QUERY_ADDRESS_HIGH */
2389 xf_emit(ctx, 2, 0); /* ffffffff QUERY_ADDRESS_LOW, COUNTER */
2390 xf_emit(ctx, 1, 0x4e3bfdf); /* ffffffff UNK0D64 */
2391 xf_emit(ctx, 1, 0x4e3bfdf); /* ffffffff UNK0DF4 */
2392 xf_emit(ctx, 1, 0); /* 00000001 eng2d UNK260 */
2393 xf_emit(ctx, 1, 0); /* ff/3ff */
2394 xf_emit(ctx, 1, 0); /* 00000007 */
2395 if (IS_NVA3F(dev_priv->chipset))
2396 xf_emit(ctx, 1, 0x11); /* 000000ff tesla UNK1968 */
2397 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2400 static void
2401 nv50_graph_construct_gene_ropc(struct nouveau_grctx *ctx)
2403 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
2404 int magic2;
2405 if (dev_priv->chipset == 0x50) {
2406 magic2 = 0x00003e60;
2407 } else if (!IS_NVA3F(dev_priv->chipset)) {
2408 magic2 = 0x001ffe67;
2409 } else {
2410 magic2 = 0x00087e67;
2412 xf_emit(ctx, 1, 0); /* f/7 MUTISAMPLE_SAMPLES_LOG2 */
2413 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
2414 xf_emit(ctx, 1, 0); /* 00000007 STENCIL_BACK_FUNC_FUNC */
2415 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_MASK */
2416 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_MASK */
2417 xf_emit(ctx, 3, 0); /* 00000007 STENCIL_BACK_OP_FAIL, ZFAIL, ZPASS */
2418 xf_emit(ctx, 1, 2); /* 00000003 tesla UNK143C */
2419 xf_emit(ctx, 1, 0); /* ffff0ff3 */
2420 xf_emit(ctx, 1, magic2); /* 001fffff tesla UNK0F78 */
2421 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
2422 xf_emit(ctx, 1, 0); /* 00000007 DEPTH_TEST_FUNC */
2423 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
2424 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
2425 if (IS_NVA3F(dev_priv->chipset))
2426 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
2427 xf_emit(ctx, 1, 0); /* 00000007 STENCIL_FRONT_FUNC_FUNC */
2428 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_MASK */
2429 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
2430 xf_emit(ctx, 3, 0); /* 00000007 STENCIL_FRONT_OP_FAIL, ZFAIL, ZPASS */
2431 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
2432 if (dev_priv->chipset >= 0xa0 && !IS_NVAAF(dev_priv->chipset))
2433 xf_emit(ctx, 1, 0x15); /* 000000ff */
2434 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
2435 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
2436 xf_emit(ctx, 1, 0x10); /* 3ff/ff VIEW_VOLUME_CLIP_CTRL */
2437 xf_emit(ctx, 1, 0); /* ffffffff CLEAR_DEPTH */
2438 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2439 xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
2440 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2441 if (dev_priv->chipset == 0x86 || dev_priv->chipset == 0x92 || dev_priv->chipset == 0x98 || dev_priv->chipset >= 0xa0) {
2442 xf_emit(ctx, 3, 0); /* ff, ffffffff, ffffffff */
2443 xf_emit(ctx, 1, 4); /* 7 */
2444 xf_emit(ctx, 1, 0x400); /* fffffff */
2445 xf_emit(ctx, 1, 0x300); /* ffff */
2446 xf_emit(ctx, 1, 0x1001); /* 1fff */
2447 if (dev_priv->chipset != 0xa0) {
2448 if (IS_NVA3F(dev_priv->chipset))
2449 xf_emit(ctx, 1, 0); /* 0000000f UNK15C8 */
2450 else
2451 xf_emit(ctx, 1, 0x15); /* ff */
2454 xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
2455 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
2456 xf_emit(ctx, 1, 0); /* 00000007 STENCIL_BACK_FUNC_FUNC */
2457 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_MASK */
2458 xf_emit(ctx, 1, 0); /* ffff0ff3 */
2459 xf_emit(ctx, 1, 2); /* 00000003 tesla UNK143C */
2460 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
2461 xf_emit(ctx, 1, 0); /* 00000007 DEPTH_TEST_FUNC */
2462 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
2463 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
2464 xf_emit(ctx, 1, 0); /* 00000007 STENCIL_FRONT_FUNC_FUNC */
2465 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_MASK */
2466 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
2467 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
2468 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
2469 xf_emit(ctx, 1, 0x10); /* 7f/ff VIEW_VOLUME_CLIP_CTRL */
2470 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2471 xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
2472 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2473 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
2474 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1900 */
2475 xf_emit(ctx, 1, 0); /* 00000007 STENCIL_BACK_FUNC_FUNC */
2476 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_MASK */
2477 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_REF */
2478 xf_emit(ctx, 2, 0); /* ffffffff DEPTH_BOUNDS */
2479 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
2480 xf_emit(ctx, 1, 0); /* 00000007 DEPTH_TEST_FUNC */
2481 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
2482 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
2483 xf_emit(ctx, 1, 0); /* 0000000f */
2484 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0FB0 */
2485 xf_emit(ctx, 1, 0); /* 00000007 STENCIL_FRONT_FUNC_FUNC */
2486 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_MASK */
2487 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_REF */
2488 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
2489 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
2490 xf_emit(ctx, 1, 0x10); /* 7f/ff VIEW_VOLUME_CLIP_CTRL */
2491 xf_emit(ctx, 0x10, 0); /* ffffffff DEPTH_RANGE_NEAR */
2492 xf_emit(ctx, 0x10, 0x3f800000); /* ffffffff DEPTH_RANGE_FAR */
2493 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2494 xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
2495 xf_emit(ctx, 1, 0); /* 00000007 STENCIL_BACK_FUNC_FUNC */
2496 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_MASK */
2497 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_FUNC_REF */
2498 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_MASK */
2499 xf_emit(ctx, 3, 0); /* 00000007 STENCIL_BACK_OP_FAIL, ZFAIL, ZPASS */
2500 xf_emit(ctx, 2, 0); /* ffffffff DEPTH_BOUNDS */
2501 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
2502 xf_emit(ctx, 1, 0); /* 00000007 DEPTH_TEST_FUNC */
2503 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
2504 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
2505 xf_emit(ctx, 1, 0); /* 000000ff CLEAR_STENCIL */
2506 xf_emit(ctx, 1, 0); /* 00000007 STENCIL_FRONT_FUNC_FUNC */
2507 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_MASK */
2508 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_FUNC_REF */
2509 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
2510 xf_emit(ctx, 3, 0); /* 00000007 STENCIL_FRONT_OP_FAIL, ZFAIL, ZPASS */
2511 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
2512 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
2513 xf_emit(ctx, 1, 0x10); /* 7f/ff VIEW_VOLUME_CLIP_CTRL */
2514 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2515 xf_emit(ctx, 1, 0x3f); /* 0000003f UNK1590 */
2516 xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
2517 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
2518 xf_emit(ctx, 2, 0); /* ffff0ff3, ffff */
2519 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0FB0 */
2520 xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
2521 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
2522 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2523 xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
2524 xf_emit(ctx, 1, 0); /* ffffffff CLEAR_DEPTH */
2525 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK19CC */
2526 if (dev_priv->chipset >= 0xa0) {
2527 xf_emit(ctx, 2, 0);
2528 xf_emit(ctx, 1, 0x1001);
2529 xf_emit(ctx, 0xb, 0);
2530 } else {
2531 xf_emit(ctx, 1, 0); /* 00000007 */
2532 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
2533 xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
2534 xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
2535 xf_emit(ctx, 1, 0); /* ffff0ff3 */
2537 xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
2538 xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
2539 xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
2540 xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
2541 xf_emit(ctx, 1, 0x11); /* 3f/7f */
2542 xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
2543 if (dev_priv->chipset != 0x50) {
2544 xf_emit(ctx, 1, 0); /* 0000000f LOGIC_OP */
2545 xf_emit(ctx, 1, 0); /* 000000ff */
2547 xf_emit(ctx, 1, 0); /* 00000007 OPERATION */
2548 xf_emit(ctx, 1, 0); /* ff/3ff */
2549 xf_emit(ctx, 1, 0); /* 00000003 UNK0F90 */
2550 xf_emit(ctx, 2, 1); /* 00000007 BLEND_EQUATION_RGB, ALPHA */
2551 xf_emit(ctx, 1, 1); /* 00000001 UNK133C */
2552 xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_RGB */
2553 xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_RGB */
2554 xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_ALPHA */
2555 xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_ALPHA */
2556 xf_emit(ctx, 1, 0); /* 00000001 */
2557 xf_emit(ctx, 1, magic2); /* 001fffff tesla UNK0F78 */
2558 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2559 xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
2560 if (IS_NVA3F(dev_priv->chipset)) {
2561 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK12E4 */
2562 xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_RGB */
2563 xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_ALPHA */
2564 xf_emit(ctx, 8, 1); /* 00000001 IBLEND_UNK00 */
2565 xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_RGB */
2566 xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_RGB */
2567 xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_ALPHA */
2568 xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_ALPHA */
2569 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1140 */
2570 xf_emit(ctx, 2, 0); /* 00000001 */
2571 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
2572 xf_emit(ctx, 1, 0); /* 0000000f */
2573 xf_emit(ctx, 1, 0); /* 00000003 */
2574 xf_emit(ctx, 1, 0); /* ffffffff */
2575 xf_emit(ctx, 2, 0); /* 00000001 */
2576 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
2577 xf_emit(ctx, 1, 0); /* 00000001 */
2578 xf_emit(ctx, 1, 0); /* 000003ff */
2579 } else if (dev_priv->chipset >= 0xa0) {
2580 xf_emit(ctx, 2, 0); /* 00000001 */
2581 xf_emit(ctx, 1, 0); /* 00000007 */
2582 xf_emit(ctx, 1, 0); /* 00000003 */
2583 xf_emit(ctx, 1, 0); /* ffffffff */
2584 xf_emit(ctx, 2, 0); /* 00000001 */
2585 } else {
2586 xf_emit(ctx, 1, 0); /* 00000007 MULTISAMPLE_SAMPLES_LOG2 */
2587 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1430 */
2588 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2590 xf_emit(ctx, 4, 0); /* ffffffff CLEAR_COLOR */
2591 xf_emit(ctx, 4, 0); /* ffffffff BLEND_COLOR A R G B */
2592 xf_emit(ctx, 1, 0); /* 00000fff eng2d UNK2B0 */
2593 if (dev_priv->chipset >= 0xa0)
2594 xf_emit(ctx, 2, 0); /* 00000001 */
2595 xf_emit(ctx, 1, 0); /* 000003ff */
2596 xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
2597 xf_emit(ctx, 1, 1); /* 00000001 UNK133C */
2598 xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_RGB */
2599 xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_RGB */
2600 xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_RGB */
2601 xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_ALPHA */
2602 xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_ALPHA */
2603 xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_ALPHA */
2604 xf_emit(ctx, 1, 0); /* 00000001 UNK19C0 */
2605 xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
2606 xf_emit(ctx, 1, 0); /* 0000000f LOGIC_OP */
2607 if (dev_priv->chipset >= 0xa0)
2608 xf_emit(ctx, 1, 0); /* 00000001 UNK12E4? NVA3+ only? */
2609 if (IS_NVA3F(dev_priv->chipset)) {
2610 xf_emit(ctx, 8, 1); /* 00000001 IBLEND_UNK00 */
2611 xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_RGB */
2612 xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_RGB */
2613 xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_RGB */
2614 xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_ALPHA */
2615 xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_ALPHA */
2616 xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_ALPHA */
2617 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK15C4 */
2618 xf_emit(ctx, 1, 0); /* 00000001 */
2619 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1140 */
2621 xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
2622 xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
2623 xf_emit(ctx, 1, 0); /* 00000007 PATTERN_COLOR_FORMAT */
2624 xf_emit(ctx, 2, 0); /* ffffffff PATTERN_MONO_COLOR */
2625 xf_emit(ctx, 1, 0); /* 00000001 PATTERN_MONO_FORMAT */
2626 xf_emit(ctx, 2, 0); /* ffffffff PATTERN_MONO_BITMAP */
2627 xf_emit(ctx, 1, 0); /* 00000003 PATTERN_SELECT */
2628 xf_emit(ctx, 1, 0); /* 000000ff ROP */
2629 xf_emit(ctx, 1, 0); /* ffffffff BETA1 */
2630 xf_emit(ctx, 1, 0); /* ffffffff BETA4 */
2631 xf_emit(ctx, 1, 0); /* 00000007 OPERATION */
2632 xf_emit(ctx, 0x50, 0); /* 10x ffffff, ffffff, ffffff, ffffff, 3 PATTERN */
2635 static void
2636 nv50_graph_construct_xfer_unk84xx(struct nouveau_grctx *ctx)
2638 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
2639 int magic3;
2640 switch (dev_priv->chipset) {
2641 case 0x50:
2642 magic3 = 0x1000;
2643 break;
2644 case 0x86:
2645 case 0x98:
2646 case 0xa8:
2647 case 0xaa:
2648 case 0xac:
2649 case 0xaf:
2650 magic3 = 0x1e00;
2651 break;
2652 default:
2653 magic3 = 0;
2655 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
2656 xf_emit(ctx, 1, 4); /* 7f/ff[NVA0+] VP_REG_ALLOC_RESULT */
2657 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
2658 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2659 xf_emit(ctx, 1, 0); /* 111/113[NVA0+] */
2660 if (IS_NVA3F(dev_priv->chipset))
2661 xf_emit(ctx, 0x1f, 0); /* ffffffff */
2662 else if (dev_priv->chipset >= 0xa0)
2663 xf_emit(ctx, 0x0f, 0); /* ffffffff */
2664 else
2665 xf_emit(ctx, 0x10, 0); /* fffffff VP_RESULT_MAP_1 up */
2666 xf_emit(ctx, 2, 0); /* f/1f[NVA3], fffffff/ffffffff[NVA0+] */
2667 xf_emit(ctx, 1, 4); /* 7f/ff VP_REG_ALLOC_RESULT */
2668 xf_emit(ctx, 1, 4); /* 7f/ff VP_RESULT_MAP_SIZE */
2669 if (dev_priv->chipset >= 0xa0)
2670 xf_emit(ctx, 1, 0x03020100); /* ffffffff */
2671 else
2672 xf_emit(ctx, 1, 0x00608080); /* fffffff VP_RESULT_MAP_0 */
2673 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
2674 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2675 xf_emit(ctx, 2, 0); /* 111/113, 7f/ff */
2676 xf_emit(ctx, 1, 4); /* 7f/ff VP_RESULT_MAP_SIZE */
2677 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2678 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
2679 xf_emit(ctx, 1, 4); /* 000000ff GP_REG_ALLOC_RESULT */
2680 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
2681 xf_emit(ctx, 1, 0x80); /* 0000ffff GP_VERTEX_OUTPUT_COUNT */
2682 if (magic3)
2683 xf_emit(ctx, 1, magic3); /* 00007fff tesla UNK141C */
2684 xf_emit(ctx, 1, 4); /* 7f/ff VP_RESULT_MAP_SIZE */
2685 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2686 xf_emit(ctx, 1, 0); /* 111/113 */
2687 xf_emit(ctx, 0x1f, 0); /* ffffffff GP_RESULT_MAP_1 up */
2688 xf_emit(ctx, 1, 0); /* 0000001f */
2689 xf_emit(ctx, 1, 0); /* ffffffff */
2690 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
2691 xf_emit(ctx, 1, 4); /* 000000ff GP_REG_ALLOC_RESULT */
2692 xf_emit(ctx, 1, 0x80); /* 0000ffff GP_VERTEX_OUTPUT_COUNT */
2693 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
2694 xf_emit(ctx, 1, 0x03020100); /* ffffffff GP_RESULT_MAP_0 */
2695 xf_emit(ctx, 1, 3); /* 00000003 GP_OUTPUT_PRIMITIVE_TYPE */
2696 if (magic3)
2697 xf_emit(ctx, 1, magic3); /* 7fff tesla UNK141C */
2698 xf_emit(ctx, 1, 4); /* 7f/ff VP_RESULT_MAP_SIZE */
2699 xf_emit(ctx, 1, 0); /* 00000001 PROVOKING_VERTEX_LAST */
2700 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2701 xf_emit(ctx, 1, 0); /* 111/113 */
2702 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
2703 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
2704 xf_emit(ctx, 1, 3); /* 00000003 GP_OUTPUT_PRIMITIVE_TYPE */
2705 xf_emit(ctx, 1, 0); /* 00000001 PROVOKING_VERTEX_LAST */
2706 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2707 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK13A0 */
2708 xf_emit(ctx, 1, 4); /* 7f/ff VP_REG_ALLOC_RESULT */
2709 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
2710 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2711 xf_emit(ctx, 1, 0); /* 111/113 */
2712 if (dev_priv->chipset == 0x94 || dev_priv->chipset == 0x96)
2713 xf_emit(ctx, 0x1020, 0); /* 4 x (0x400 x 0xffffffff, ff, 0, 0, 0, 4 x ffffffff) */
2714 else if (dev_priv->chipset < 0xa0)
2715 xf_emit(ctx, 0xa20, 0); /* 4 x (0x280 x 0xffffffff, ff, 0, 0, 0, 4 x ffffffff) */
2716 else if (!IS_NVA3F(dev_priv->chipset))
2717 xf_emit(ctx, 0x210, 0); /* ffffffff */
2718 else
2719 xf_emit(ctx, 0x410, 0); /* ffffffff */
2720 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
2721 xf_emit(ctx, 1, 4); /* 000000ff GP_RESULT_MAP_SIZE */
2722 xf_emit(ctx, 1, 3); /* 00000003 GP_OUTPUT_PRIMITIVE_TYPE */
2723 xf_emit(ctx, 1, 0); /* 00000001 PROVOKING_VERTEX_LAST */
2724 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
2727 static void
2728 nv50_graph_construct_xfer_tprop(struct nouveau_grctx *ctx)
2730 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
2731 int magic1, magic2;
2732 if (dev_priv->chipset == 0x50) {
2733 magic1 = 0x3ff;
2734 magic2 = 0x00003e60;
2735 } else if (!IS_NVA3F(dev_priv->chipset)) {
2736 magic1 = 0x7ff;
2737 magic2 = 0x001ffe67;
2738 } else {
2739 magic1 = 0x7ff;
2740 magic2 = 0x00087e67;
2742 xf_emit(ctx, 1, 0); /* 00000007 ALPHA_TEST_FUNC */
2743 xf_emit(ctx, 1, 0); /* ffffffff ALPHA_TEST_REF */
2744 xf_emit(ctx, 1, 0); /* 00000001 ALPHA_TEST_ENABLE */
2745 if (IS_NVA3F(dev_priv->chipset))
2746 xf_emit(ctx, 1, 1); /* 0000000f UNK16A0 */
2747 xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
2748 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
2749 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_BACK_MASK */
2750 xf_emit(ctx, 3, 0); /* 00000007 STENCIL_BACK_OP_FAIL, ZFAIL, ZPASS */
2751 xf_emit(ctx, 4, 0); /* ffffffff BLEND_COLOR */
2752 xf_emit(ctx, 1, 0); /* 00000001 UNK19C0 */
2753 xf_emit(ctx, 1, 0); /* 00000001 UNK0FDC */
2754 xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
2755 xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
2756 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
2757 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
2758 xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
2759 xf_emit(ctx, 1, 0); /* ff[NV50]/3ff[NV84+] */
2760 xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
2761 xf_emit(ctx, 4, 0xffff); /* 0000ffff MSAA_MASK */
2762 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
2763 xf_emit(ctx, 3, 0); /* 00000007 STENCIL_FRONT_OP_FAIL, ZFAIL, ZPASS */
2764 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
2765 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_BACK_ENABLE */
2766 xf_emit(ctx, 2, 0); /* 00007fff WINDOW_OFFSET_XY */
2767 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK19CC */
2768 xf_emit(ctx, 1, 0); /* 7 */
2769 xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
2770 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2771 xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
2772 xf_emit(ctx, 1, 0); /* ffffffff COLOR_KEY */
2773 xf_emit(ctx, 1, 0); /* 00000001 COLOR_KEY_ENABLE */
2774 xf_emit(ctx, 1, 0); /* 00000007 COLOR_KEY_FORMAT */
2775 xf_emit(ctx, 2, 0); /* ffffffff SIFC_BITMAP_COLOR */
2776 xf_emit(ctx, 1, 1); /* 00000001 SIFC_BITMAP_WRITE_BIT0_ENABLE */
2777 xf_emit(ctx, 1, 0); /* 00000007 ALPHA_TEST_FUNC */
2778 xf_emit(ctx, 1, 0); /* 00000001 ALPHA_TEST_ENABLE */
2779 if (IS_NVA3F(dev_priv->chipset)) {
2780 xf_emit(ctx, 1, 3); /* 00000003 tesla UNK16B4 */
2781 xf_emit(ctx, 1, 0); /* 00000003 */
2782 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1298 */
2783 } else if (dev_priv->chipset >= 0xa0) {
2784 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK16B4 */
2785 xf_emit(ctx, 1, 0); /* 00000003 */
2786 } else {
2787 xf_emit(ctx, 1, 0); /* 00000003 MULTISAMPLE_CTRL */
2789 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
2790 xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
2791 xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_ALPHA */
2792 xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_ALPHA */
2793 xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_ALPHA */
2794 xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_RGB */
2795 xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_RGB */
2796 xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_RGB */
2797 if (IS_NVA3F(dev_priv->chipset)) {
2798 xf_emit(ctx, 1, 0); /* 00000001 UNK12E4 */
2799 xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_RGB */
2800 xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_ALPHA */
2801 xf_emit(ctx, 8, 1); /* 00000001 IBLEND_UNK00 */
2802 xf_emit(ctx, 8, 2); /* 0000001f IBLEND_SRC_RGB */
2803 xf_emit(ctx, 8, 1); /* 0000001f IBLEND_DST_RGB */
2804 xf_emit(ctx, 8, 2); /* 0000001f IBLEND_SRC_ALPHA */
2805 xf_emit(ctx, 8, 1); /* 0000001f IBLEND_DST_ALPHA */
2806 xf_emit(ctx, 1, 0); /* 00000001 UNK1140 */
2808 xf_emit(ctx, 1, 1); /* 00000001 UNK133C */
2809 xf_emit(ctx, 1, 0); /* ffff0ff3 */
2810 xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
2811 xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
2812 xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
2813 xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
2814 xf_emit(ctx, 1, 0); /* ff/3ff */
2815 xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
2816 xf_emit(ctx, 1, 0); /* 00000003 UNK0F90 */
2817 xf_emit(ctx, 1, 0); /* 00000001 FRAMEBUFFER_SRGB */
2818 xf_emit(ctx, 1, 0); /* 7 */
2819 xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
2820 xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
2821 xf_emit(ctx, 1, 0); /* 00000007 OPERATION */
2822 xf_emit(ctx, 1, 0xcf); /* 000000ff SIFC_FORMAT */
2823 xf_emit(ctx, 1, 0xcf); /* 000000ff DRAW_COLOR_FORMAT */
2824 xf_emit(ctx, 1, 0xcf); /* 000000ff SRC_FORMAT */
2825 if (IS_NVA3F(dev_priv->chipset))
2826 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
2827 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2828 xf_emit(ctx, 1, 0); /* 7/f[NVA3] MULTISAMPLE_SAMPLES_LOG2 */
2829 xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
2830 xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_ALPHA */
2831 xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_ALPHA */
2832 xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_ALPHA */
2833 xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_RGB */
2834 xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_RGB */
2835 xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_RGB */
2836 xf_emit(ctx, 1, 1); /* 00000001 UNK133C */
2837 xf_emit(ctx, 1, 0); /* ffff0ff3 */
2838 xf_emit(ctx, 8, 1); /* 00000001 UNK19E0 */
2839 xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
2840 xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
2841 xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
2842 xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
2843 xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
2844 xf_emit(ctx, 1, magic2); /* 001fffff tesla UNK0F78 */
2845 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
2846 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
2847 xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
2848 xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
2849 if (IS_NVA3F(dev_priv->chipset))
2850 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
2851 if(dev_priv->chipset == 0x50)
2852 xf_emit(ctx, 1, 0); /* ff */
2853 else
2854 xf_emit(ctx, 3, 0); /* 1, 7, 3ff */
2855 xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
2856 xf_emit(ctx, 1, 0); /* 00000003 UNK0F90 */
2857 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
2858 xf_emit(ctx, 1, 0); /* 00000007 */
2859 xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
2860 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2861 xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
2862 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2863 xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
2864 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
2865 xf_emit(ctx, 1, 0); /* ffff0ff3 */
2866 xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
2867 xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
2868 xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
2869 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
2870 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
2871 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
2872 xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
2873 xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
2874 xf_emit(ctx, 1, 0); /* 000fffff BLIT_DU_DX_FRACT */
2875 xf_emit(ctx, 1, 1); /* 0001ffff BLIT_DU_DX_INT */
2876 xf_emit(ctx, 1, 0); /* 000fffff BLIT_DV_DY_FRACT */
2877 xf_emit(ctx, 1, 1); /* 0001ffff BLIT_DV_DY_INT */
2878 xf_emit(ctx, 1, 0); /* ff/3ff */
2879 xf_emit(ctx, 1, magic1); /* 3ff/7ff tesla UNK0D68 */
2880 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
2881 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
2882 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2883 xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
2884 xf_emit(ctx, 1, 0); /* 00000007 */
2885 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2886 if (IS_NVA3F(dev_priv->chipset))
2887 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
2888 xf_emit(ctx, 8, 0); /* 0000ffff DMA_COLOR */
2889 xf_emit(ctx, 1, 0); /* 0000ffff DMA_GLOBAL */
2890 xf_emit(ctx, 1, 0); /* 0000ffff DMA_LOCAL */
2891 xf_emit(ctx, 1, 0); /* 0000ffff DMA_STACK */
2892 xf_emit(ctx, 1, 0); /* ff/3ff */
2893 xf_emit(ctx, 1, 0); /* 0000ffff DMA_DST */
2894 xf_emit(ctx, 1, 0); /* 7 */
2895 xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
2896 xf_emit(ctx, 1, 0); /* ffff0ff3 */
2897 xf_emit(ctx, 8, 0); /* 000000ff RT_ADDRESS_HIGH */
2898 xf_emit(ctx, 8, 0); /* ffffffff RT_LAYER_STRIDE */
2899 xf_emit(ctx, 8, 0); /* ffffffff RT_ADDRESS_LOW */
2900 xf_emit(ctx, 8, 8); /* 0000007f RT_TILE_MODE */
2901 xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
2902 xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
2903 xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
2904 xf_emit(ctx, 8, 0x400); /* 0fffffff RT_HORIZ */
2905 xf_emit(ctx, 8, 0x300); /* 0000ffff RT_VERT */
2906 xf_emit(ctx, 1, 1); /* 00001fff RT_ARRAY_MODE */
2907 xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
2908 xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
2909 xf_emit(ctx, 1, 0x20); /* 00000fff DST_TILE_MODE */
2910 xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
2911 xf_emit(ctx, 1, 0x100); /* 0001ffff DST_HEIGHT */
2912 xf_emit(ctx, 1, 0); /* 000007ff DST_LAYER */
2913 xf_emit(ctx, 1, 1); /* 00000001 DST_LINEAR */
2914 xf_emit(ctx, 1, 0); /* ffffffff DST_ADDRESS_LOW */
2915 xf_emit(ctx, 1, 0); /* 000000ff DST_ADDRESS_HIGH */
2916 xf_emit(ctx, 1, 0x40); /* 0007ffff DST_PITCH */
2917 xf_emit(ctx, 1, 0x100); /* 0001ffff DST_WIDTH */
2918 xf_emit(ctx, 1, 0); /* 0000ffff */
2919 xf_emit(ctx, 1, 3); /* 00000003 tesla UNK15AC */
2920 xf_emit(ctx, 1, 0); /* ff/3ff */
2921 xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
2922 xf_emit(ctx, 1, 0); /* 00000003 UNK0F90 */
2923 xf_emit(ctx, 1, 0); /* 00000007 */
2924 if (IS_NVA3F(dev_priv->chipset))
2925 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
2926 xf_emit(ctx, 1, magic2); /* 001fffff tesla UNK0F78 */
2927 xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
2928 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
2929 xf_emit(ctx, 1, 0); /* ffff0ff3 */
2930 xf_emit(ctx, 1, 2); /* 00000003 tesla UNK143C */
2931 xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
2932 xf_emit(ctx, 1, 0); /* 0000ffff DMA_ZETA */
2933 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
2934 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
2935 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
2936 xf_emit(ctx, 2, 0); /* ffff, ff/3ff */
2937 xf_emit(ctx, 1, 0); /* 0001ffff GP_BUILTIN_RESULT_EN */
2938 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
2939 xf_emit(ctx, 1, 0); /* 000000ff STENCIL_FRONT_MASK */
2940 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
2941 xf_emit(ctx, 1, 0); /* 00000007 */
2942 xf_emit(ctx, 1, 0); /* ffffffff ZETA_LAYER_STRIDE */
2943 xf_emit(ctx, 1, 0); /* 000000ff ZETA_ADDRESS_HIGH */
2944 xf_emit(ctx, 1, 0); /* ffffffff ZETA_ADDRESS_LOW */
2945 xf_emit(ctx, 1, 4); /* 00000007 ZETA_TILE_MODE */
2946 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2947 xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
2948 xf_emit(ctx, 1, 0x400); /* 0fffffff ZETA_HORIZ */
2949 xf_emit(ctx, 1, 0x300); /* 0000ffff ZETA_VERT */
2950 xf_emit(ctx, 1, 0x1001); /* 00001fff ZETA_ARRAY_MODE */
2951 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2952 xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
2953 if (IS_NVA3F(dev_priv->chipset))
2954 xf_emit(ctx, 1, 0); /* 00000001 */
2955 xf_emit(ctx, 1, 0); /* ffff0ff3 */
2956 xf_emit(ctx, 1, 0x11); /* 3f/7f RT_FORMAT */
2957 xf_emit(ctx, 7, 0); /* 3f/7f RT_FORMAT */
2958 xf_emit(ctx, 1, 0x0fac6881); /* 0fffffff RT_CONTROL */
2959 xf_emit(ctx, 1, 0xf); /* 0000000f COLOR_MASK */
2960 xf_emit(ctx, 7, 0); /* 0000000f COLOR_MASK */
2961 xf_emit(ctx, 1, 0); /* ff/3ff */
2962 xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
2963 xf_emit(ctx, 1, 0); /* 00000003 UNK0F90 */
2964 xf_emit(ctx, 1, 0); /* 00000001 FRAMEBUFFER_SRGB */
2965 xf_emit(ctx, 1, 0); /* 7 */
2966 xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
2967 if (IS_NVA3F(dev_priv->chipset)) {
2968 xf_emit(ctx, 1, 0); /* 00000001 UNK1140 */
2969 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
2971 xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
2972 xf_emit(ctx, 1, 0); /* 00000001 UNK1534 */
2973 xf_emit(ctx, 1, 0); /* ffff0ff3 */
2974 if (dev_priv->chipset >= 0xa0)
2975 xf_emit(ctx, 1, 0x0fac6881); /* fffffff */
2976 xf_emit(ctx, 1, magic2); /* 001fffff tesla UNK0F78 */
2977 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_BOUNDS_EN */
2978 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
2979 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE_ENABLE */
2980 xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
2981 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK0FB0 */
2982 xf_emit(ctx, 1, 0); /* ff/3ff */
2983 xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
2984 xf_emit(ctx, 1, 0); /* 00000001 STENCIL_FRONT_ENABLE */
2985 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK15B4 */
2986 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK19CC */
2987 xf_emit(ctx, 1, 0); /* 00000007 */
2988 xf_emit(ctx, 1, 0); /* 00000001 SAMPLECNT_ENABLE */
2989 xf_emit(ctx, 1, 0); /* 0000000f ZETA_FORMAT */
2990 xf_emit(ctx, 1, 1); /* 00000001 ZETA_ENABLE */
2991 if (IS_NVA3F(dev_priv->chipset)) {
2992 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
2993 xf_emit(ctx, 1, 0); /* 0000000f tesla UNK15C8 */
2995 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A3C */
2996 if (dev_priv->chipset >= 0xa0) {
2997 xf_emit(ctx, 3, 0); /* 7/f, 1, ffff0ff3 */
2998 xf_emit(ctx, 1, 0xfac6881); /* fffffff */
2999 xf_emit(ctx, 4, 0); /* 1, 1, 1, 3ff */
3000 xf_emit(ctx, 1, 4); /* 7 */
3001 xf_emit(ctx, 1, 0); /* 1 */
3002 xf_emit(ctx, 2, 1); /* 1 */
3003 xf_emit(ctx, 2, 0); /* 7, f */
3004 xf_emit(ctx, 1, 1); /* 1 */
3005 xf_emit(ctx, 1, 0); /* 7/f */
3006 if (IS_NVA3F(dev_priv->chipset))
3007 xf_emit(ctx, 0x9, 0); /* 1 */
3008 else
3009 xf_emit(ctx, 0x8, 0); /* 1 */
3010 xf_emit(ctx, 1, 0); /* ffff0ff3 */
3011 xf_emit(ctx, 8, 1); /* 1 */
3012 xf_emit(ctx, 1, 0x11); /* 7f */
3013 xf_emit(ctx, 7, 0); /* 7f */
3014 xf_emit(ctx, 1, 0xfac6881); /* fffffff */
3015 xf_emit(ctx, 1, 0xf); /* f */
3016 xf_emit(ctx, 7, 0); /* f */
3017 xf_emit(ctx, 1, 0x11); /* 7f */
3018 xf_emit(ctx, 1, 1); /* 1 */
3019 xf_emit(ctx, 5, 0); /* 1, 7, 3ff, 3, 7 */
3020 if (IS_NVA3F(dev_priv->chipset)) {
3021 xf_emit(ctx, 1, 0); /* 00000001 UNK1140 */
3022 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
3027 static void
3028 nv50_graph_construct_xfer_tex(struct nouveau_grctx *ctx)
3030 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
3031 xf_emit(ctx, 2, 0); /* 1 LINKED_TSC. yes, 2. */
3032 if (dev_priv->chipset != 0x50)
3033 xf_emit(ctx, 1, 0); /* 3 */
3034 xf_emit(ctx, 1, 1); /* 1ffff BLIT_DU_DX_INT */
3035 xf_emit(ctx, 1, 0); /* fffff BLIT_DU_DX_FRACT */
3036 xf_emit(ctx, 1, 1); /* 1ffff BLIT_DV_DY_INT */
3037 xf_emit(ctx, 1, 0); /* fffff BLIT_DV_DY_FRACT */
3038 if (dev_priv->chipset == 0x50)
3039 xf_emit(ctx, 1, 0); /* 3 BLIT_CONTROL */
3040 else
3041 xf_emit(ctx, 2, 0); /* 3ff, 1 */
3042 xf_emit(ctx, 1, 0x2a712488); /* ffffffff SRC_TIC_0 */
3043 xf_emit(ctx, 1, 0); /* ffffffff SRC_TIC_1 */
3044 xf_emit(ctx, 1, 0x4085c000); /* ffffffff SRC_TIC_2 */
3045 xf_emit(ctx, 1, 0x40); /* ffffffff SRC_TIC_3 */
3046 xf_emit(ctx, 1, 0x100); /* ffffffff SRC_TIC_4 */
3047 xf_emit(ctx, 1, 0x10100); /* ffffffff SRC_TIC_5 */
3048 xf_emit(ctx, 1, 0x02800000); /* ffffffff SRC_TIC_6 */
3049 xf_emit(ctx, 1, 0); /* ffffffff SRC_TIC_7 */
3050 if (dev_priv->chipset == 0x50) {
3051 xf_emit(ctx, 1, 0); /* 00000001 turing UNK358 */
3052 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A34? */
3053 xf_emit(ctx, 1, 0); /* 00000003 turing UNK37C tesla UNK1690 */
3054 xf_emit(ctx, 1, 0); /* 00000003 BLIT_CONTROL */
3055 xf_emit(ctx, 1, 0); /* 00000001 turing UNK32C tesla UNK0F94 */
3056 } else if (!IS_NVAAF(dev_priv->chipset)) {
3057 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A34? */
3058 xf_emit(ctx, 1, 0); /* 00000003 */
3059 xf_emit(ctx, 1, 0); /* 000003ff */
3060 xf_emit(ctx, 1, 0); /* 00000003 */
3061 xf_emit(ctx, 1, 0); /* 000003ff */
3062 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1664 / turing UNK03E8 */
3063 xf_emit(ctx, 1, 0); /* 00000003 */
3064 xf_emit(ctx, 1, 0); /* 000003ff */
3065 } else {
3066 xf_emit(ctx, 0x6, 0);
3068 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A34 */
3069 xf_emit(ctx, 1, 0); /* 0000ffff DMA_TEXTURE */
3070 xf_emit(ctx, 1, 0); /* 0000ffff DMA_SRC */
3073 static void
3074 nv50_graph_construct_xfer_unk8cxx(struct nouveau_grctx *ctx)
3076 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
3077 xf_emit(ctx, 1, 0); /* 00000001 UNK1534 */
3078 xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
3079 xf_emit(ctx, 2, 0); /* 7, ffff0ff3 */
3080 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
3081 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE */
3082 xf_emit(ctx, 1, 0x04e3bfdf); /* ffffffff UNK0D64 */
3083 xf_emit(ctx, 1, 0x04e3bfdf); /* ffffffff UNK0DF4 */
3084 xf_emit(ctx, 1, 1); /* 00000001 UNK15B4 */
3085 xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
3086 xf_emit(ctx, 1, 0x00ffff00); /* 00ffffff LINE_STIPPLE_PATTERN */
3087 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK0F98 */
3088 if (IS_NVA3F(dev_priv->chipset))
3089 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
3090 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1668 */
3091 xf_emit(ctx, 1, 0); /* 00000001 LINE_STIPPLE_ENABLE */
3092 xf_emit(ctx, 1, 0x00ffff00); /* 00ffffff LINE_STIPPLE_PATTERN */
3093 xf_emit(ctx, 1, 0); /* 00000001 POLYGON_SMOOTH_ENABLE */
3094 xf_emit(ctx, 1, 0); /* 00000001 UNK1534 */
3095 xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
3096 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1658 */
3097 xf_emit(ctx, 1, 0); /* 00000001 LINE_SMOOTH_ENABLE */
3098 xf_emit(ctx, 1, 0); /* ffff0ff3 */
3099 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_TEST_ENABLE */
3100 xf_emit(ctx, 1, 0); /* 00000001 DEPTH_WRITE */
3101 xf_emit(ctx, 1, 1); /* 00000001 UNK15B4 */
3102 xf_emit(ctx, 1, 0); /* 00000001 POINT_SPRITE_ENABLE */
3103 xf_emit(ctx, 1, 1); /* 00000001 tesla UNK165C */
3104 xf_emit(ctx, 1, 0x30201000); /* ffffffff tesla UNK1670 */
3105 xf_emit(ctx, 1, 0x70605040); /* ffffffff tesla UNK1670 */
3106 xf_emit(ctx, 1, 0xb8a89888); /* ffffffff tesla UNK1670 */
3107 xf_emit(ctx, 1, 0xf8e8d8c8); /* ffffffff tesla UNK1670 */
3108 xf_emit(ctx, 1, 0); /* 00000001 VERTEX_TWO_SIDE_ENABLE */
3109 xf_emit(ctx, 1, 0x1a); /* 0000001f POLYGON_MODE */
3112 static void
3113 nv50_graph_construct_xfer_tp(struct nouveau_grctx *ctx)
3115 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
3116 if (dev_priv->chipset < 0xa0) {
3117 nv50_graph_construct_xfer_unk84xx(ctx);
3118 nv50_graph_construct_xfer_tprop(ctx);
3119 nv50_graph_construct_xfer_tex(ctx);
3120 nv50_graph_construct_xfer_unk8cxx(ctx);
3121 } else {
3122 nv50_graph_construct_xfer_tex(ctx);
3123 nv50_graph_construct_xfer_tprop(ctx);
3124 nv50_graph_construct_xfer_unk8cxx(ctx);
3125 nv50_graph_construct_xfer_unk84xx(ctx);
3129 static void
3130 nv50_graph_construct_xfer_mpc(struct nouveau_grctx *ctx)
3132 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
3133 int i, mpcnt = 2;
3134 switch (dev_priv->chipset) {
3135 case 0x98:
3136 case 0xaa:
3137 mpcnt = 1;
3138 break;
3139 case 0x50:
3140 case 0x84:
3141 case 0x86:
3142 case 0x92:
3143 case 0x94:
3144 case 0x96:
3145 case 0xa8:
3146 case 0xac:
3147 mpcnt = 2;
3148 break;
3149 case 0xa0:
3150 case 0xa3:
3151 case 0xa5:
3152 case 0xaf:
3153 mpcnt = 3;
3154 break;
3156 for (i = 0; i < mpcnt; i++) {
3157 xf_emit(ctx, 1, 0); /* ff */
3158 xf_emit(ctx, 1, 0x80); /* ffffffff tesla UNK1404 */
3159 xf_emit(ctx, 1, 0x80007004); /* ffffffff tesla UNK12B0 */
3160 xf_emit(ctx, 1, 0x04000400); /* ffffffff */
3161 if (dev_priv->chipset >= 0xa0)
3162 xf_emit(ctx, 1, 0xc0); /* 00007fff tesla UNK152C */
3163 xf_emit(ctx, 1, 0x1000); /* 0000ffff tesla UNK0D60 */
3164 xf_emit(ctx, 1, 0); /* ff/3ff */
3165 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A30 */
3166 if (dev_priv->chipset == 0x86 || dev_priv->chipset == 0x98 || dev_priv->chipset == 0xa8 || IS_NVAAF(dev_priv->chipset)) {
3167 xf_emit(ctx, 1, 0xe00); /* 7fff */
3168 xf_emit(ctx, 1, 0x1e00); /* 7fff */
3170 xf_emit(ctx, 1, 1); /* 000000ff VP_REG_ALLOC_TEMP */
3171 xf_emit(ctx, 1, 0); /* 00000001 LINKED_TSC */
3172 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
3173 if (dev_priv->chipset == 0x50)
3174 xf_emit(ctx, 2, 0x1000); /* 7fff tesla UNK141C */
3175 xf_emit(ctx, 1, 1); /* 000000ff GP_REG_ALLOC_TEMP */
3176 xf_emit(ctx, 1, 0); /* 00000001 GP_ENABLE */
3177 xf_emit(ctx, 1, 4); /* 000000ff FP_REG_ALLOC_TEMP */
3178 xf_emit(ctx, 1, 2); /* 00000003 REG_MODE */
3179 if (IS_NVAAF(dev_priv->chipset))
3180 xf_emit(ctx, 0xb, 0); /* RO */
3181 else if (dev_priv->chipset >= 0xa0)
3182 xf_emit(ctx, 0xc, 0); /* RO */
3183 else
3184 xf_emit(ctx, 0xa, 0); /* RO */
3186 xf_emit(ctx, 1, 0x08100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
3187 xf_emit(ctx, 1, 0); /* ff/3ff */
3188 if (dev_priv->chipset >= 0xa0) {
3189 xf_emit(ctx, 1, 0x1fe21); /* 0003ffff tesla UNK0FAC */
3191 xf_emit(ctx, 3, 0); /* 7fff, 0, 0 */
3192 xf_emit(ctx, 1, 0); /* 00000001 tesla UNK1534 */
3193 xf_emit(ctx, 1, 0); /* 7/f MULTISAMPLE_SAMPLES_LOG2 */
3194 xf_emit(ctx, 4, 0xffff); /* 0000ffff MSAA_MASK */
3195 xf_emit(ctx, 1, 1); /* 00000001 LANES32 */
3196 xf_emit(ctx, 1, 0x10001); /* 00ffffff BLOCK_ALLOC */
3197 xf_emit(ctx, 1, 0x10001); /* ffffffff BLOCKDIM_XY */
3198 xf_emit(ctx, 1, 1); /* 0000ffff BLOCKDIM_Z */
3199 xf_emit(ctx, 1, 0); /* ffffffff SHARED_SIZE */
3200 xf_emit(ctx, 1, 0x1fe21); /* 1ffff/3ffff[NVA0+] tesla UNk0FAC */
3201 xf_emit(ctx, 1, 0); /* ffffffff tesla UNK1A34 */
3202 if (IS_NVA3F(dev_priv->chipset))
3203 xf_emit(ctx, 1, 1); /* 0000001f tesla UNK169C */
3204 xf_emit(ctx, 1, 0); /* ff/3ff */
3205 xf_emit(ctx, 1, 0); /* 1 LINKED_TSC */
3206 xf_emit(ctx, 1, 0); /* ff FP_ADDRESS_HIGH */
3207 xf_emit(ctx, 1, 0); /* ffffffff FP_ADDRESS_LOW */
3208 xf_emit(ctx, 1, 0x08100c12); /* 1fffffff FP_INTERPOLANT_CTRL */
3209 xf_emit(ctx, 1, 4); /* 00000007 FP_CONTROL */
3210 xf_emit(ctx, 1, 0); /* 000000ff FRAG_COLOR_CLAMP_EN */
3211 xf_emit(ctx, 1, 2); /* 00000003 REG_MODE */
3212 xf_emit(ctx, 1, 0x11); /* 0000007f RT_FORMAT */
3213 xf_emit(ctx, 7, 0); /* 0000007f RT_FORMAT */
3214 xf_emit(ctx, 1, 0); /* 00000007 */
3215 xf_emit(ctx, 1, 0xfac6881); /* 0fffffff RT_CONTROL */
3216 xf_emit(ctx, 1, 0); /* 00000003 MULTISAMPLE_CTRL */
3217 if (IS_NVA3F(dev_priv->chipset))
3218 xf_emit(ctx, 1, 3); /* 00000003 tesla UNK16B4 */
3219 xf_emit(ctx, 1, 0); /* 00000001 ALPHA_TEST_ENABLE */
3220 xf_emit(ctx, 1, 0); /* 00000007 ALPHA_TEST_FUNC */
3221 xf_emit(ctx, 1, 0); /* 00000001 FRAMEBUFFER_SRGB */
3222 xf_emit(ctx, 1, 4); /* ffffffff tesla UNK1400 */
3223 xf_emit(ctx, 8, 0); /* 00000001 BLEND_ENABLE */
3224 xf_emit(ctx, 1, 0); /* 00000001 LOGIC_OP_ENABLE */
3225 xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_RGB */
3226 xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_RGB */
3227 xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_RGB */
3228 xf_emit(ctx, 1, 2); /* 0000001f BLEND_FUNC_SRC_ALPHA */
3229 xf_emit(ctx, 1, 1); /* 0000001f BLEND_FUNC_DST_ALPHA */
3230 xf_emit(ctx, 1, 1); /* 00000007 BLEND_EQUATION_ALPHA */
3231 xf_emit(ctx, 1, 1); /* 00000001 UNK133C */
3232 if (IS_NVA3F(dev_priv->chipset)) {
3233 xf_emit(ctx, 1, 0); /* 00000001 UNK12E4 */
3234 xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_RGB */
3235 xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_RGB */
3236 xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_RGB */
3237 xf_emit(ctx, 8, 2); /* 0000001f IBLEND_FUNC_SRC_ALPHA */
3238 xf_emit(ctx, 8, 1); /* 0000001f IBLEND_FUNC_DST_ALPHA */
3239 xf_emit(ctx, 8, 1); /* 00000007 IBLEND_EQUATION_ALPHA */
3240 xf_emit(ctx, 8, 1); /* 00000001 IBLEND_UNK00 */
3241 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK1928 */
3242 xf_emit(ctx, 1, 0); /* 00000001 UNK1140 */
3244 xf_emit(ctx, 1, 0); /* 00000003 tesla UNK0F90 */
3245 xf_emit(ctx, 1, 4); /* 000000ff FP_RESULT_COUNT */
3246 /* XXX: demagic this part some day */
3247 if (dev_priv->chipset == 0x50)
3248 xf_emit(ctx, 0x3a0, 0);
3249 else if (dev_priv->chipset < 0x94)
3250 xf_emit(ctx, 0x3a2, 0);
3251 else if (dev_priv->chipset == 0x98 || dev_priv->chipset == 0xaa)
3252 xf_emit(ctx, 0x39f, 0);
3253 else
3254 xf_emit(ctx, 0x3a3, 0);
3255 xf_emit(ctx, 1, 0x11); /* 3f/7f DST_FORMAT */
3256 xf_emit(ctx, 1, 0); /* 7 OPERATION */
3257 xf_emit(ctx, 1, 1); /* 1 DST_LINEAR */
3258 xf_emit(ctx, 0x2d, 0);
3261 static void
3262 nv50_graph_construct_xfer2(struct nouveau_grctx *ctx)
3264 struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
3265 int i;
3266 uint32_t offset;
3267 uint32_t units = nv_rd32 (ctx->dev, 0x1540);
3268 int size = 0;
3270 offset = (ctx->ctxvals_pos+0x3f)&~0x3f;
3272 if (dev_priv->chipset < 0xa0) {
3273 for (i = 0; i < 8; i++) {
3274 ctx->ctxvals_pos = offset + i;
3275 /* that little bugger belongs to csched. No idea
3276 * what it's doing here. */
3277 if (i == 0)
3278 xf_emit(ctx, 1, 0x08100c12); /* FP_INTERPOLANT_CTRL */
3279 if (units & (1 << i))
3280 nv50_graph_construct_xfer_mpc(ctx);
3281 if ((ctx->ctxvals_pos-offset)/8 > size)
3282 size = (ctx->ctxvals_pos-offset)/8;
3284 } else {
3285 /* Strand 0: TPs 0, 1 */
3286 ctx->ctxvals_pos = offset;
3287 /* that little bugger belongs to csched. No idea
3288 * what it's doing here. */
3289 xf_emit(ctx, 1, 0x08100c12); /* FP_INTERPOLANT_CTRL */
3290 if (units & (1 << 0))
3291 nv50_graph_construct_xfer_mpc(ctx);
3292 if (units & (1 << 1))
3293 nv50_graph_construct_xfer_mpc(ctx);
3294 if ((ctx->ctxvals_pos-offset)/8 > size)
3295 size = (ctx->ctxvals_pos-offset)/8;
3297 /* Strand 1: TPs 2, 3 */
3298 ctx->ctxvals_pos = offset + 1;
3299 if (units & (1 << 2))
3300 nv50_graph_construct_xfer_mpc(ctx);
3301 if (units & (1 << 3))
3302 nv50_graph_construct_xfer_mpc(ctx);
3303 if ((ctx->ctxvals_pos-offset)/8 > size)
3304 size = (ctx->ctxvals_pos-offset)/8;
3306 /* Strand 2: TPs 4, 5, 6 */
3307 ctx->ctxvals_pos = offset + 2;
3308 if (units & (1 << 4))
3309 nv50_graph_construct_xfer_mpc(ctx);
3310 if (units & (1 << 5))
3311 nv50_graph_construct_xfer_mpc(ctx);
3312 if (units & (1 << 6))
3313 nv50_graph_construct_xfer_mpc(ctx);
3314 if ((ctx->ctxvals_pos-offset)/8 > size)
3315 size = (ctx->ctxvals_pos-offset)/8;
3317 /* Strand 3: TPs 7, 8, 9 */
3318 ctx->ctxvals_pos = offset + 3;
3319 if (units & (1 << 7))
3320 nv50_graph_construct_xfer_mpc(ctx);
3321 if (units & (1 << 8))
3322 nv50_graph_construct_xfer_mpc(ctx);
3323 if (units & (1 << 9))
3324 nv50_graph_construct_xfer_mpc(ctx);
3325 if ((ctx->ctxvals_pos-offset)/8 > size)
3326 size = (ctx->ctxvals_pos-offset)/8;
3328 ctx->ctxvals_pos = offset + size * 8;
3329 ctx->ctxvals_pos = (ctx->ctxvals_pos+0x3f)&~0x3f;
3330 cp_lsr (ctx, offset);
3331 cp_out (ctx, CP_SET_XFER_POINTER);
3332 cp_lsr (ctx, size);
3333 cp_out (ctx, CP_SEEK_2);
3334 cp_out (ctx, CP_XFER_2);
3335 cp_wait(ctx, XFER, BUSY);