2 * Copyright 2007 Stephane Marchesin
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragr) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
27 #include <core/client.h>
28 #include <engine/fifo.h>
29 #include <engine/fifo/chan.h>
30 #include <subdev/instmem.h>
31 #include <subdev/timer.h>
34 nv04_gr_ctx_regs[] = {
39 NV04_PGRAPH_CTX_SWITCH1,
40 NV04_PGRAPH_CTX_SWITCH2,
41 NV04_PGRAPH_CTX_SWITCH3,
42 NV04_PGRAPH_CTX_SWITCH4,
43 NV04_PGRAPH_CTX_CACHE1,
44 NV04_PGRAPH_CTX_CACHE2,
45 NV04_PGRAPH_CTX_CACHE3,
46 NV04_PGRAPH_CTX_CACHE4,
76 NV04_PGRAPH_DMA_START_0,
77 NV04_PGRAPH_DMA_START_1,
78 NV04_PGRAPH_DMA_LENGTH,
80 NV04_PGRAPH_DMA_PITCH,
106 NV04_PGRAPH_BSWIZZLE2,
107 NV04_PGRAPH_BSWIZZLE5,
110 NV04_PGRAPH_PATT_COLOR0,
111 NV04_PGRAPH_PATT_COLOR1,
112 NV04_PGRAPH_PATT_COLORRAM+0x00,
113 NV04_PGRAPH_PATT_COLORRAM+0x04,
114 NV04_PGRAPH_PATT_COLORRAM+0x08,
115 NV04_PGRAPH_PATT_COLORRAM+0x0c,
116 NV04_PGRAPH_PATT_COLORRAM+0x10,
117 NV04_PGRAPH_PATT_COLORRAM+0x14,
118 NV04_PGRAPH_PATT_COLORRAM+0x18,
119 NV04_PGRAPH_PATT_COLORRAM+0x1c,
120 NV04_PGRAPH_PATT_COLORRAM+0x20,
121 NV04_PGRAPH_PATT_COLORRAM+0x24,
122 NV04_PGRAPH_PATT_COLORRAM+0x28,
123 NV04_PGRAPH_PATT_COLORRAM+0x2c,
124 NV04_PGRAPH_PATT_COLORRAM+0x30,
125 NV04_PGRAPH_PATT_COLORRAM+0x34,
126 NV04_PGRAPH_PATT_COLORRAM+0x38,
127 NV04_PGRAPH_PATT_COLORRAM+0x3c,
128 NV04_PGRAPH_PATT_COLORRAM+0x40,
129 NV04_PGRAPH_PATT_COLORRAM+0x44,
130 NV04_PGRAPH_PATT_COLORRAM+0x48,
131 NV04_PGRAPH_PATT_COLORRAM+0x4c,
132 NV04_PGRAPH_PATT_COLORRAM+0x50,
133 NV04_PGRAPH_PATT_COLORRAM+0x54,
134 NV04_PGRAPH_PATT_COLORRAM+0x58,
135 NV04_PGRAPH_PATT_COLORRAM+0x5c,
136 NV04_PGRAPH_PATT_COLORRAM+0x60,
137 NV04_PGRAPH_PATT_COLORRAM+0x64,
138 NV04_PGRAPH_PATT_COLORRAM+0x68,
139 NV04_PGRAPH_PATT_COLORRAM+0x6c,
140 NV04_PGRAPH_PATT_COLORRAM+0x70,
141 NV04_PGRAPH_PATT_COLORRAM+0x74,
142 NV04_PGRAPH_PATT_COLORRAM+0x78,
143 NV04_PGRAPH_PATT_COLORRAM+0x7c,
144 NV04_PGRAPH_PATT_COLORRAM+0x80,
145 NV04_PGRAPH_PATT_COLORRAM+0x84,
146 NV04_PGRAPH_PATT_COLORRAM+0x88,
147 NV04_PGRAPH_PATT_COLORRAM+0x8c,
148 NV04_PGRAPH_PATT_COLORRAM+0x90,
149 NV04_PGRAPH_PATT_COLORRAM+0x94,
150 NV04_PGRAPH_PATT_COLORRAM+0x98,
151 NV04_PGRAPH_PATT_COLORRAM+0x9c,
152 NV04_PGRAPH_PATT_COLORRAM+0xa0,
153 NV04_PGRAPH_PATT_COLORRAM+0xa4,
154 NV04_PGRAPH_PATT_COLORRAM+0xa8,
155 NV04_PGRAPH_PATT_COLORRAM+0xac,
156 NV04_PGRAPH_PATT_COLORRAM+0xb0,
157 NV04_PGRAPH_PATT_COLORRAM+0xb4,
158 NV04_PGRAPH_PATT_COLORRAM+0xb8,
159 NV04_PGRAPH_PATT_COLORRAM+0xbc,
160 NV04_PGRAPH_PATT_COLORRAM+0xc0,
161 NV04_PGRAPH_PATT_COLORRAM+0xc4,
162 NV04_PGRAPH_PATT_COLORRAM+0xc8,
163 NV04_PGRAPH_PATT_COLORRAM+0xcc,
164 NV04_PGRAPH_PATT_COLORRAM+0xd0,
165 NV04_PGRAPH_PATT_COLORRAM+0xd4,
166 NV04_PGRAPH_PATT_COLORRAM+0xd8,
167 NV04_PGRAPH_PATT_COLORRAM+0xdc,
168 NV04_PGRAPH_PATT_COLORRAM+0xe0,
169 NV04_PGRAPH_PATT_COLORRAM+0xe4,
170 NV04_PGRAPH_PATT_COLORRAM+0xe8,
171 NV04_PGRAPH_PATT_COLORRAM+0xec,
172 NV04_PGRAPH_PATT_COLORRAM+0xf0,
173 NV04_PGRAPH_PATT_COLORRAM+0xf4,
174 NV04_PGRAPH_PATT_COLORRAM+0xf8,
175 NV04_PGRAPH_PATT_COLORRAM+0xfc,
178 NV04_PGRAPH_PATTERN_SHAPE,
182 NV04_PGRAPH_BETA_AND,
183 NV04_PGRAPH_BETA_PREMULT,
184 NV04_PGRAPH_CONTROL0,
185 NV04_PGRAPH_CONTROL1,
186 NV04_PGRAPH_CONTROL2,
188 NV04_PGRAPH_STORED_FMT,
189 NV04_PGRAPH_SOURCE_COLOR,
333 NV04_PGRAPH_PASSTHRU_0,
334 NV04_PGRAPH_PASSTHRU_1,
335 NV04_PGRAPH_PASSTHRU_2,
336 NV04_PGRAPH_DVD_COLORFMT,
337 NV04_PGRAPH_SCALED_FORMAT,
338 NV04_PGRAPH_MISC24_0,
339 NV04_PGRAPH_MISC24_1,
340 NV04_PGRAPH_MISC24_2,
348 #define nv04_gr(p) container_of((p), struct nv04_gr, base)
352 struct nv04_gr_chan *chan[16];
356 #define nv04_gr_chan(p) container_of((p), struct nv04_gr_chan, object)
358 struct nv04_gr_chan {
359 struct nvkm_object object;
362 u32 nv04[ARRAY_SIZE(nv04_gr_ctx_regs)];
365 /*******************************************************************************
366 * Graphics object classes
367 ******************************************************************************/
370 * Software methods, why they are needed, and how they all work:
372 * NV04 and NV05 keep most of the state in PGRAPH context itself, but some
373 * 2d engine settings are kept inside the grobjs themselves. The grobjs are
374 * 3 words long on both. grobj format on NV04 is:
378 * - bit 12: color key active
379 * - bit 13: clip rect active
380 * - bit 14: if set, destination surface is swizzled and taken from buffer 5
381 * [set by NV04_SWIZZLED_SURFACE], otherwise it's linear and taken
382 * from buffer 0 [set by NV04_CONTEXT_SURFACES_2D or
383 * NV03_CONTEXT_SURFACE_DST].
384 * - bits 15-17: 2d operation [aka patch config]
385 * - bit 24: patch valid [enables rendering using this object]
386 * - bit 25: surf3d valid [for tex_tri and multitex_tri only]
388 * - bits 0-1: mono format
389 * - bits 8-13: color format
390 * - bits 16-31: DMA_NOTIFY instance
392 * - bits 0-15: DMA_A instance
393 * - bits 16-31: DMA_B instance
399 * - bit 12: color key active
400 * - bit 13: clip rect active
401 * - bit 14: if set, destination surface is swizzled and taken from buffer 5
402 * [set by NV04_SWIZZLED_SURFACE], otherwise it's linear and taken
403 * from buffer 0 [set by NV04_CONTEXT_SURFACES_2D or
404 * NV03_CONTEXT_SURFACE_DST].
405 * - bits 15-17: 2d operation [aka patch config]
406 * - bits 20-22: dither mode
407 * - bit 24: patch valid [enables rendering using this object]
408 * - bit 25: surface_dst/surface_color/surf2d/surf3d valid
409 * - bit 26: surface_src/surface_zeta valid
410 * - bit 27: pattern valid
411 * - bit 28: rop valid
412 * - bit 29: beta1 valid
413 * - bit 30: beta4 valid
415 * - bits 0-1: mono format
416 * - bits 8-13: color format
417 * - bits 16-31: DMA_NOTIFY instance
419 * - bits 0-15: DMA_A instance
420 * - bits 16-31: DMA_B instance
422 * NV05 will set/unset the relevant valid bits when you poke the relevant
423 * object-binding methods with object of the proper type, or with the NULL
424 * type. It'll only allow rendering using the grobj if all needed objects
425 * are bound. The needed set of objects depends on selected operation: for
426 * example rop object is needed by ROP_AND, but not by SRCCOPY_AND.
428 * NV04 doesn't have these methods implemented at all, and doesn't have the
429 * relevant bits in grobj. Instead, it'll allow rendering whenever bit 24
430 * is set. So we have to emulate them in software, internally keeping the
431 * same bits as NV05 does. Since grobjs are aligned to 16 bytes on nv04,
432 * but the last word isn't actually used for anything, we abuse it for this
435 * Actually, NV05 can optionally check bit 24 too, but we disable this since
436 * there's no use for it.
438 * For unknown reasons, NV04 implements surf3d binding in hardware as an
439 * exception. Also for unknown reasons, NV04 doesn't implement the clipping
440 * methods on the surf3d object, so we have to emulate them too.
444 nv04_gr_set_ctx1(struct nvkm_device *device, u32 inst, u32 mask, u32 value)
446 int subc = (nvkm_rd32(device, NV04_PGRAPH_TRAPPED_ADDR) >> 13) & 0x7;
449 tmp = nvkm_rd32(device, 0x700000 + inst);
452 nvkm_wr32(device, 0x700000 + inst, tmp);
454 nvkm_wr32(device, NV04_PGRAPH_CTX_SWITCH1, tmp);
455 nvkm_wr32(device, NV04_PGRAPH_CTX_CACHE1 + (subc << 2), tmp);
459 nv04_gr_set_ctx_val(struct nvkm_device *device, u32 inst, u32 mask, u32 value)
461 int class, op, valid = 1;
464 ctx1 = nvkm_rd32(device, 0x700000 + inst);
466 op = (ctx1 >> 15) & 7;
468 tmp = nvkm_rd32(device, 0x70000c + inst);
471 nvkm_wr32(device, 0x70000c + inst, tmp);
473 /* check for valid surf2d/surf_dst/surf_color */
474 if (!(tmp & 0x02000000))
476 /* check for valid surf_src/surf_zeta */
477 if ((class == 0x1f || class == 0x48) && !(tmp & 0x04000000))
481 /* SRCCOPY_AND, SRCCOPY: no extra objects required */
485 /* ROP_AND: requires pattern and rop */
487 if (!(tmp & 0x18000000))
490 /* BLEND_AND: requires beta1 */
492 if (!(tmp & 0x20000000))
495 /* SRCCOPY_PREMULT, BLEND_PREMULT: beta4 required */
498 if (!(tmp & 0x40000000))
503 nv04_gr_set_ctx1(device, inst, 0x01000000, valid << 24);
507 nv04_gr_mthd_set_operation(struct nvkm_device *device, u32 inst, u32 data)
509 u8 class = nvkm_rd32(device, 0x700000) & 0x000000ff;
512 /* Old versions of the objects only accept first three operations. */
513 if (data > 2 && class < 0x40)
515 nv04_gr_set_ctx1(device, inst, 0x00038000, data << 15);
516 /* changing operation changes set of objects needed for validation */
517 nv04_gr_set_ctx_val(device, inst, 0, 0);
522 nv04_gr_mthd_surf3d_clip_h(struct nvkm_device *device, u32 inst, u32 data)
524 u32 min = data & 0xffff, max;
530 /* yes, it accepts negative for some reason. */
534 nvkm_wr32(device, 0x40053c, min);
535 nvkm_wr32(device, 0x400544, max);
540 nv04_gr_mthd_surf3d_clip_v(struct nvkm_device *device, u32 inst, u32 data)
542 u32 min = data & 0xffff, max;
548 /* yes, it accepts negative for some reason. */
552 nvkm_wr32(device, 0x400540, min);
553 nvkm_wr32(device, 0x400548, max);
558 nv04_gr_mthd_bind_class(struct nvkm_device *device, u32 inst)
560 return nvkm_rd32(device, 0x700000 + (inst << 4));
564 nv04_gr_mthd_bind_surf2d(struct nvkm_device *device, u32 inst, u32 data)
566 switch (nv04_gr_mthd_bind_class(device, data)) {
568 nv04_gr_set_ctx1(device, inst, 0x00004000, 0);
569 nv04_gr_set_ctx_val(device, inst, 0x02000000, 0);
572 nv04_gr_set_ctx1(device, inst, 0x00004000, 0);
573 nv04_gr_set_ctx_val(device, inst, 0x02000000, 0x02000000);
580 nv04_gr_mthd_bind_surf2d_swzsurf(struct nvkm_device *device, u32 inst, u32 data)
582 switch (nv04_gr_mthd_bind_class(device, data)) {
584 nv04_gr_set_ctx1(device, inst, 0x00004000, 0);
585 nv04_gr_set_ctx_val(device, inst, 0x02000000, 0);
588 nv04_gr_set_ctx1(device, inst, 0x00004000, 0);
589 nv04_gr_set_ctx_val(device, inst, 0x02000000, 0x02000000);
592 nv04_gr_set_ctx1(device, inst, 0x00004000, 0x00004000);
593 nv04_gr_set_ctx_val(device, inst, 0x02000000, 0x02000000);
600 nv01_gr_mthd_bind_patt(struct nvkm_device *device, u32 inst, u32 data)
602 switch (nv04_gr_mthd_bind_class(device, data)) {
604 nv04_gr_set_ctx_val(device, inst, 0x08000000, 0);
607 nv04_gr_set_ctx_val(device, inst, 0x08000000, 0x08000000);
614 nv04_gr_mthd_bind_patt(struct nvkm_device *device, u32 inst, u32 data)
616 switch (nv04_gr_mthd_bind_class(device, data)) {
618 nv04_gr_set_ctx_val(device, inst, 0x08000000, 0);
621 nv04_gr_set_ctx_val(device, inst, 0x08000000, 0x08000000);
628 nv04_gr_mthd_bind_rop(struct nvkm_device *device, u32 inst, u32 data)
630 switch (nv04_gr_mthd_bind_class(device, data)) {
632 nv04_gr_set_ctx_val(device, inst, 0x10000000, 0);
635 nv04_gr_set_ctx_val(device, inst, 0x10000000, 0x10000000);
642 nv04_gr_mthd_bind_beta1(struct nvkm_device *device, u32 inst, u32 data)
644 switch (nv04_gr_mthd_bind_class(device, data)) {
646 nv04_gr_set_ctx_val(device, inst, 0x20000000, 0);
649 nv04_gr_set_ctx_val(device, inst, 0x20000000, 0x20000000);
656 nv04_gr_mthd_bind_beta4(struct nvkm_device *device, u32 inst, u32 data)
658 switch (nv04_gr_mthd_bind_class(device, data)) {
660 nv04_gr_set_ctx_val(device, inst, 0x40000000, 0);
663 nv04_gr_set_ctx_val(device, inst, 0x40000000, 0x40000000);
670 nv04_gr_mthd_bind_surf_dst(struct nvkm_device *device, u32 inst, u32 data)
672 switch (nv04_gr_mthd_bind_class(device, data)) {
674 nv04_gr_set_ctx_val(device, inst, 0x02000000, 0);
677 nv04_gr_set_ctx_val(device, inst, 0x02000000, 0x02000000);
684 nv04_gr_mthd_bind_surf_src(struct nvkm_device *device, u32 inst, u32 data)
686 switch (nv04_gr_mthd_bind_class(device, data)) {
688 nv04_gr_set_ctx_val(device, inst, 0x04000000, 0);
691 nv04_gr_set_ctx_val(device, inst, 0x04000000, 0x04000000);
698 nv04_gr_mthd_bind_surf_color(struct nvkm_device *device, u32 inst, u32 data)
700 switch (nv04_gr_mthd_bind_class(device, data)) {
702 nv04_gr_set_ctx_val(device, inst, 0x02000000, 0);
705 nv04_gr_set_ctx_val(device, inst, 0x02000000, 0x02000000);
712 nv04_gr_mthd_bind_surf_zeta(struct nvkm_device *device, u32 inst, u32 data)
714 switch (nv04_gr_mthd_bind_class(device, data)) {
716 nv04_gr_set_ctx_val(device, inst, 0x04000000, 0);
719 nv04_gr_set_ctx_val(device, inst, 0x04000000, 0x04000000);
726 nv01_gr_mthd_bind_clip(struct nvkm_device *device, u32 inst, u32 data)
728 switch (nv04_gr_mthd_bind_class(device, data)) {
730 nv04_gr_set_ctx1(device, inst, 0x2000, 0);
733 nv04_gr_set_ctx1(device, inst, 0x2000, 0x2000);
740 nv01_gr_mthd_bind_chroma(struct nvkm_device *device, u32 inst, u32 data)
742 switch (nv04_gr_mthd_bind_class(device, data)) {
744 nv04_gr_set_ctx1(device, inst, 0x1000, 0);
746 /* Yes, for some reason even the old versions of objects
747 * accept 0x57 and not 0x17. Consistency be damned.
750 nv04_gr_set_ctx1(device, inst, 0x1000, 0x1000);
757 nv03_gr_mthd_gdi(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
759 bool (*func)(struct nvkm_device *, u32, u32);
761 case 0x0184: func = nv01_gr_mthd_bind_patt; break;
762 case 0x0188: func = nv04_gr_mthd_bind_rop; break;
763 case 0x018c: func = nv04_gr_mthd_bind_beta1; break;
764 case 0x0190: func = nv04_gr_mthd_bind_surf_dst; break;
765 case 0x02fc: func = nv04_gr_mthd_set_operation; break;
769 return func(device, inst, data);
773 nv04_gr_mthd_gdi(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
775 bool (*func)(struct nvkm_device *, u32, u32);
777 case 0x0188: func = nv04_gr_mthd_bind_patt; break;
778 case 0x018c: func = nv04_gr_mthd_bind_rop; break;
779 case 0x0190: func = nv04_gr_mthd_bind_beta1; break;
780 case 0x0194: func = nv04_gr_mthd_bind_beta4; break;
781 case 0x0198: func = nv04_gr_mthd_bind_surf2d; break;
782 case 0x02fc: func = nv04_gr_mthd_set_operation; break;
786 return func(device, inst, data);
790 nv01_gr_mthd_blit(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
792 bool (*func)(struct nvkm_device *, u32, u32);
794 case 0x0184: func = nv01_gr_mthd_bind_chroma; break;
795 case 0x0188: func = nv01_gr_mthd_bind_clip; break;
796 case 0x018c: func = nv01_gr_mthd_bind_patt; break;
797 case 0x0190: func = nv04_gr_mthd_bind_rop; break;
798 case 0x0194: func = nv04_gr_mthd_bind_beta1; break;
799 case 0x0198: func = nv04_gr_mthd_bind_surf_dst; break;
800 case 0x019c: func = nv04_gr_mthd_bind_surf_src; break;
801 case 0x02fc: func = nv04_gr_mthd_set_operation; break;
805 return func(device, inst, data);
809 nv04_gr_mthd_blit(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
811 bool (*func)(struct nvkm_device *, u32, u32);
813 case 0x0184: func = nv01_gr_mthd_bind_chroma; break;
814 case 0x0188: func = nv01_gr_mthd_bind_clip; break;
815 case 0x018c: func = nv04_gr_mthd_bind_patt; break;
816 case 0x0190: func = nv04_gr_mthd_bind_rop; break;
817 case 0x0194: func = nv04_gr_mthd_bind_beta1; break;
818 case 0x0198: func = nv04_gr_mthd_bind_beta4; break;
819 case 0x019c: func = nv04_gr_mthd_bind_surf2d; break;
820 case 0x02fc: func = nv04_gr_mthd_set_operation; break;
824 return func(device, inst, data);
828 nv04_gr_mthd_iifc(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
830 bool (*func)(struct nvkm_device *, u32, u32);
832 case 0x0188: func = nv01_gr_mthd_bind_chroma; break;
833 case 0x018c: func = nv01_gr_mthd_bind_clip; break;
834 case 0x0190: func = nv04_gr_mthd_bind_patt; break;
835 case 0x0194: func = nv04_gr_mthd_bind_rop; break;
836 case 0x0198: func = nv04_gr_mthd_bind_beta1; break;
837 case 0x019c: func = nv04_gr_mthd_bind_beta4; break;
838 case 0x01a0: func = nv04_gr_mthd_bind_surf2d_swzsurf; break;
839 case 0x03e4: func = nv04_gr_mthd_set_operation; break;
843 return func(device, inst, data);
847 nv01_gr_mthd_ifc(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
849 bool (*func)(struct nvkm_device *, u32, u32);
851 case 0x0184: func = nv01_gr_mthd_bind_chroma; break;
852 case 0x0188: func = nv01_gr_mthd_bind_clip; break;
853 case 0x018c: func = nv01_gr_mthd_bind_patt; break;
854 case 0x0190: func = nv04_gr_mthd_bind_rop; break;
855 case 0x0194: func = nv04_gr_mthd_bind_beta1; break;
856 case 0x0198: func = nv04_gr_mthd_bind_surf_dst; break;
857 case 0x02fc: func = nv04_gr_mthd_set_operation; break;
861 return func(device, inst, data);
865 nv04_gr_mthd_ifc(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
867 bool (*func)(struct nvkm_device *, u32, u32);
869 case 0x0184: func = nv01_gr_mthd_bind_chroma; break;
870 case 0x0188: func = nv01_gr_mthd_bind_clip; break;
871 case 0x018c: func = nv04_gr_mthd_bind_patt; break;
872 case 0x0190: func = nv04_gr_mthd_bind_rop; break;
873 case 0x0194: func = nv04_gr_mthd_bind_beta1; break;
874 case 0x0198: func = nv04_gr_mthd_bind_beta4; break;
875 case 0x019c: func = nv04_gr_mthd_bind_surf2d; break;
876 case 0x02fc: func = nv04_gr_mthd_set_operation; break;
880 return func(device, inst, data);
884 nv03_gr_mthd_sifc(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
886 bool (*func)(struct nvkm_device *, u32, u32);
888 case 0x0184: func = nv01_gr_mthd_bind_chroma; break;
889 case 0x0188: func = nv01_gr_mthd_bind_patt; break;
890 case 0x018c: func = nv04_gr_mthd_bind_rop; break;
891 case 0x0190: func = nv04_gr_mthd_bind_beta1; break;
892 case 0x0194: func = nv04_gr_mthd_bind_surf_dst; break;
893 case 0x02fc: func = nv04_gr_mthd_set_operation; break;
897 return func(device, inst, data);
901 nv04_gr_mthd_sifc(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
903 bool (*func)(struct nvkm_device *, u32, u32);
905 case 0x0184: func = nv01_gr_mthd_bind_chroma; break;
906 case 0x0188: func = nv04_gr_mthd_bind_patt; break;
907 case 0x018c: func = nv04_gr_mthd_bind_rop; break;
908 case 0x0190: func = nv04_gr_mthd_bind_beta1; break;
909 case 0x0194: func = nv04_gr_mthd_bind_beta4; break;
910 case 0x0198: func = nv04_gr_mthd_bind_surf2d; break;
911 case 0x02fc: func = nv04_gr_mthd_set_operation; break;
915 return func(device, inst, data);
919 nv03_gr_mthd_sifm(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
921 bool (*func)(struct nvkm_device *, u32, u32);
923 case 0x0188: func = nv01_gr_mthd_bind_patt; break;
924 case 0x018c: func = nv04_gr_mthd_bind_rop; break;
925 case 0x0190: func = nv04_gr_mthd_bind_beta1; break;
926 case 0x0194: func = nv04_gr_mthd_bind_surf_dst; break;
927 case 0x0304: func = nv04_gr_mthd_set_operation; break;
931 return func(device, inst, data);
935 nv04_gr_mthd_sifm(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
937 bool (*func)(struct nvkm_device *, u32, u32);
939 case 0x0188: func = nv04_gr_mthd_bind_patt; break;
940 case 0x018c: func = nv04_gr_mthd_bind_rop; break;
941 case 0x0190: func = nv04_gr_mthd_bind_beta1; break;
942 case 0x0194: func = nv04_gr_mthd_bind_beta4; break;
943 case 0x0198: func = nv04_gr_mthd_bind_surf2d; break;
944 case 0x0304: func = nv04_gr_mthd_set_operation; break;
948 return func(device, inst, data);
952 nv04_gr_mthd_surf3d(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
954 bool (*func)(struct nvkm_device *, u32, u32);
956 case 0x02f8: func = nv04_gr_mthd_surf3d_clip_h; break;
957 case 0x02fc: func = nv04_gr_mthd_surf3d_clip_v; break;
961 return func(device, inst, data);
965 nv03_gr_mthd_ttri(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
967 bool (*func)(struct nvkm_device *, u32, u32);
969 case 0x0188: func = nv01_gr_mthd_bind_clip; break;
970 case 0x018c: func = nv04_gr_mthd_bind_surf_color; break;
971 case 0x0190: func = nv04_gr_mthd_bind_surf_zeta; break;
975 return func(device, inst, data);
979 nv01_gr_mthd_prim(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
981 bool (*func)(struct nvkm_device *, u32, u32);
983 case 0x0184: func = nv01_gr_mthd_bind_clip; break;
984 case 0x0188: func = nv01_gr_mthd_bind_patt; break;
985 case 0x018c: func = nv04_gr_mthd_bind_rop; break;
986 case 0x0190: func = nv04_gr_mthd_bind_beta1; break;
987 case 0x0194: func = nv04_gr_mthd_bind_surf_dst; break;
988 case 0x02fc: func = nv04_gr_mthd_set_operation; break;
992 return func(device, inst, data);
996 nv04_gr_mthd_prim(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
998 bool (*func)(struct nvkm_device *, u32, u32);
1000 case 0x0184: func = nv01_gr_mthd_bind_clip; break;
1001 case 0x0188: func = nv04_gr_mthd_bind_patt; break;
1002 case 0x018c: func = nv04_gr_mthd_bind_rop; break;
1003 case 0x0190: func = nv04_gr_mthd_bind_beta1; break;
1004 case 0x0194: func = nv04_gr_mthd_bind_beta4; break;
1005 case 0x0198: func = nv04_gr_mthd_bind_surf2d; break;
1006 case 0x02fc: func = nv04_gr_mthd_set_operation; break;
1010 return func(device, inst, data);
1014 nv04_gr_mthd(struct nvkm_device *device, u32 inst, u32 mthd, u32 data)
1016 bool (*func)(struct nvkm_device *, u32, u32, u32);
1017 switch (nvkm_rd32(device, 0x700000 + inst) & 0x000000ff) {
1019 func = nv01_gr_mthd_prim; break;
1020 case 0x1f: func = nv01_gr_mthd_blit; break;
1021 case 0x21: func = nv01_gr_mthd_ifc; break;
1022 case 0x36: func = nv03_gr_mthd_sifc; break;
1023 case 0x37: func = nv03_gr_mthd_sifm; break;
1024 case 0x48: func = nv03_gr_mthd_ttri; break;
1025 case 0x4a: func = nv04_gr_mthd_gdi; break;
1026 case 0x4b: func = nv03_gr_mthd_gdi; break;
1027 case 0x53: func = nv04_gr_mthd_surf3d; break;
1029 func = nv04_gr_mthd_prim; break;
1030 case 0x5f: func = nv04_gr_mthd_blit; break;
1031 case 0x60: func = nv04_gr_mthd_iifc; break;
1032 case 0x61: func = nv04_gr_mthd_ifc; break;
1033 case 0x76: func = nv04_gr_mthd_sifc; break;
1034 case 0x77: func = nv04_gr_mthd_sifm; break;
1038 return func(device, inst, mthd, data);
1042 nv04_gr_object_bind(struct nvkm_object *object, struct nvkm_gpuobj *parent,
1043 int align, struct nvkm_gpuobj **pgpuobj)
1045 int ret = nvkm_gpuobj_new(object->engine->subdev.device, 16, align,
1046 false, parent, pgpuobj);
1048 nvkm_kmap(*pgpuobj);
1049 nvkm_wo32(*pgpuobj, 0x00, object->oclass_name);
1050 nvkm_wo32(*pgpuobj, 0x04, 0x00000000);
1051 nvkm_wo32(*pgpuobj, 0x08, 0x00000000);
1053 nvkm_mo32(*pgpuobj, 0x08, 0x00080000, 0x00080000);
1055 nvkm_wo32(*pgpuobj, 0x0c, 0x00000000);
1056 nvkm_done(*pgpuobj);
1061 const struct nvkm_object_func
1063 .bind = nv04_gr_object_bind,
1066 /*******************************************************************************
1068 ******************************************************************************/
1070 static struct nv04_gr_chan *
1071 nv04_gr_channel(struct nv04_gr *gr)
1073 struct nvkm_device *device = gr->base.engine.subdev.device;
1074 struct nv04_gr_chan *chan = NULL;
1075 if (nvkm_rd32(device, NV04_PGRAPH_CTX_CONTROL) & 0x00010000) {
1076 int chid = nvkm_rd32(device, NV04_PGRAPH_CTX_USER) >> 24;
1077 if (chid < ARRAY_SIZE(gr->chan))
1078 chan = gr->chan[chid];
1084 nv04_gr_load_context(struct nv04_gr_chan *chan, int chid)
1086 struct nvkm_device *device = chan->gr->base.engine.subdev.device;
1089 for (i = 0; i < ARRAY_SIZE(nv04_gr_ctx_regs); i++)
1090 nvkm_wr32(device, nv04_gr_ctx_regs[i], chan->nv04[i]);
1092 nvkm_wr32(device, NV04_PGRAPH_CTX_CONTROL, 0x10010100);
1093 nvkm_mask(device, NV04_PGRAPH_CTX_USER, 0xff000000, chid << 24);
1094 nvkm_mask(device, NV04_PGRAPH_FFINTFC_ST2, 0xfff00000, 0x00000000);
1099 nv04_gr_unload_context(struct nv04_gr_chan *chan)
1101 struct nvkm_device *device = chan->gr->base.engine.subdev.device;
1104 for (i = 0; i < ARRAY_SIZE(nv04_gr_ctx_regs); i++)
1105 chan->nv04[i] = nvkm_rd32(device, nv04_gr_ctx_regs[i]);
1107 nvkm_wr32(device, NV04_PGRAPH_CTX_CONTROL, 0x10000000);
1108 nvkm_mask(device, NV04_PGRAPH_CTX_USER, 0xff000000, 0x0f000000);
1113 nv04_gr_context_switch(struct nv04_gr *gr)
1115 struct nvkm_device *device = gr->base.engine.subdev.device;
1116 struct nv04_gr_chan *prev = NULL;
1117 struct nv04_gr_chan *next = NULL;
1120 nv04_gr_idle(&gr->base);
1122 /* If previous context is valid, we need to save it */
1123 prev = nv04_gr_channel(gr);
1125 nv04_gr_unload_context(prev);
1127 /* load context for next channel */
1128 chid = (nvkm_rd32(device, NV04_PGRAPH_TRAPPED_ADDR) >> 24) & 0x0f;
1129 next = gr->chan[chid];
1131 nv04_gr_load_context(next, chid);
1134 static u32 *ctx_reg(struct nv04_gr_chan *chan, u32 reg)
1138 for (i = 0; i < ARRAY_SIZE(nv04_gr_ctx_regs); i++) {
1139 if (nv04_gr_ctx_regs[i] == reg)
1140 return &chan->nv04[i];
1147 nv04_gr_chan_dtor(struct nvkm_object *object)
1149 struct nv04_gr_chan *chan = nv04_gr_chan(object);
1150 struct nv04_gr *gr = chan->gr;
1151 unsigned long flags;
1153 spin_lock_irqsave(&gr->lock, flags);
1154 gr->chan[chan->chid] = NULL;
1155 spin_unlock_irqrestore(&gr->lock, flags);
1160 nv04_gr_chan_fini(struct nvkm_object *object, bool suspend)
1162 struct nv04_gr_chan *chan = nv04_gr_chan(object);
1163 struct nv04_gr *gr = chan->gr;
1164 struct nvkm_device *device = gr->base.engine.subdev.device;
1165 unsigned long flags;
1167 spin_lock_irqsave(&gr->lock, flags);
1168 nvkm_mask(device, NV04_PGRAPH_FIFO, 0x00000001, 0x00000000);
1169 if (nv04_gr_channel(gr) == chan)
1170 nv04_gr_unload_context(chan);
1171 nvkm_mask(device, NV04_PGRAPH_FIFO, 0x00000001, 0x00000001);
1172 spin_unlock_irqrestore(&gr->lock, flags);
1176 static const struct nvkm_object_func
1178 .dtor = nv04_gr_chan_dtor,
1179 .fini = nv04_gr_chan_fini,
1183 nv04_gr_chan_new(struct nvkm_gr *base, struct nvkm_fifo_chan *fifoch,
1184 const struct nvkm_oclass *oclass, struct nvkm_object **pobject)
1186 struct nv04_gr *gr = nv04_gr(base);
1187 struct nv04_gr_chan *chan;
1188 unsigned long flags;
1190 if (!(chan = kzalloc(sizeof(*chan), GFP_KERNEL)))
1192 nvkm_object_ctor(&nv04_gr_chan, oclass, &chan->object);
1194 chan->chid = fifoch->chid;
1195 *pobject = &chan->object;
1197 *ctx_reg(chan, NV04_PGRAPH_DEBUG_3) = 0xfad4ff31;
1199 spin_lock_irqsave(&gr->lock, flags);
1200 gr->chan[chan->chid] = chan;
1201 spin_unlock_irqrestore(&gr->lock, flags);
1205 /*******************************************************************************
1206 * PGRAPH engine/subdev functions
1207 ******************************************************************************/
1210 nv04_gr_idle(struct nvkm_gr *gr)
1212 struct nvkm_subdev *subdev = &gr->engine.subdev;
1213 struct nvkm_device *device = subdev->device;
1214 u32 mask = 0xffffffff;
1216 if (device->card_type == NV_40)
1217 mask &= ~NV40_PGRAPH_STATUS_SYNC_STALL;
1219 if (nvkm_msec(device, 2000,
1220 if (!(nvkm_rd32(device, NV04_PGRAPH_STATUS) & mask))
1223 nvkm_error(subdev, "idle timed out with status %08x\n",
1224 nvkm_rd32(device, NV04_PGRAPH_STATUS));
1231 static const struct nvkm_bitfield
1232 nv04_gr_intr_name[] = {
1233 { NV_PGRAPH_INTR_NOTIFY, "NOTIFY" },
1237 static const struct nvkm_bitfield
1238 nv04_gr_nstatus[] = {
1239 { NV04_PGRAPH_NSTATUS_STATE_IN_USE, "STATE_IN_USE" },
1240 { NV04_PGRAPH_NSTATUS_INVALID_STATE, "INVALID_STATE" },
1241 { NV04_PGRAPH_NSTATUS_BAD_ARGUMENT, "BAD_ARGUMENT" },
1242 { NV04_PGRAPH_NSTATUS_PROTECTION_FAULT, "PROTECTION_FAULT" },
1246 const struct nvkm_bitfield
1247 nv04_gr_nsource[] = {
1248 { NV03_PGRAPH_NSOURCE_NOTIFICATION, "NOTIFICATION" },
1249 { NV03_PGRAPH_NSOURCE_DATA_ERROR, "DATA_ERROR" },
1250 { NV03_PGRAPH_NSOURCE_PROTECTION_ERROR, "PROTECTION_ERROR" },
1251 { NV03_PGRAPH_NSOURCE_RANGE_EXCEPTION, "RANGE_EXCEPTION" },
1252 { NV03_PGRAPH_NSOURCE_LIMIT_COLOR, "LIMIT_COLOR" },
1253 { NV03_PGRAPH_NSOURCE_LIMIT_ZETA, "LIMIT_ZETA" },
1254 { NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD, "ILLEGAL_MTHD" },
1255 { NV03_PGRAPH_NSOURCE_DMA_R_PROTECTION, "DMA_R_PROTECTION" },
1256 { NV03_PGRAPH_NSOURCE_DMA_W_PROTECTION, "DMA_W_PROTECTION" },
1257 { NV03_PGRAPH_NSOURCE_FORMAT_EXCEPTION, "FORMAT_EXCEPTION" },
1258 { NV03_PGRAPH_NSOURCE_PATCH_EXCEPTION, "PATCH_EXCEPTION" },
1259 { NV03_PGRAPH_NSOURCE_STATE_INVALID, "STATE_INVALID" },
1260 { NV03_PGRAPH_NSOURCE_DOUBLE_NOTIFY, "DOUBLE_NOTIFY" },
1261 { NV03_PGRAPH_NSOURCE_NOTIFY_IN_USE, "NOTIFY_IN_USE" },
1262 { NV03_PGRAPH_NSOURCE_METHOD_CNT, "METHOD_CNT" },
1263 { NV03_PGRAPH_NSOURCE_BFR_NOTIFICATION, "BFR_NOTIFICATION" },
1264 { NV03_PGRAPH_NSOURCE_DMA_VTX_PROTECTION, "DMA_VTX_PROTECTION" },
1265 { NV03_PGRAPH_NSOURCE_DMA_WIDTH_A, "DMA_WIDTH_A" },
1266 { NV03_PGRAPH_NSOURCE_DMA_WIDTH_B, "DMA_WIDTH_B" },
1271 nv04_gr_intr(struct nvkm_subdev *subdev)
1273 struct nv04_gr *gr = (void *)subdev;
1274 struct nv04_gr_chan *chan = NULL;
1275 struct nvkm_device *device = gr->base.engine.subdev.device;
1276 u32 stat = nvkm_rd32(device, NV03_PGRAPH_INTR);
1277 u32 nsource = nvkm_rd32(device, NV03_PGRAPH_NSOURCE);
1278 u32 nstatus = nvkm_rd32(device, NV03_PGRAPH_NSTATUS);
1279 u32 addr = nvkm_rd32(device, NV04_PGRAPH_TRAPPED_ADDR);
1280 u32 chid = (addr & 0x0f000000) >> 24;
1281 u32 subc = (addr & 0x0000e000) >> 13;
1282 u32 mthd = (addr & 0x00001ffc);
1283 u32 data = nvkm_rd32(device, NV04_PGRAPH_TRAPPED_DATA);
1284 u32 class = nvkm_rd32(device, 0x400180 + subc * 4) & 0xff;
1285 u32 inst = (nvkm_rd32(device, 0x40016c) & 0xffff) << 4;
1287 char msg[128], src[128], sta[128];
1288 unsigned long flags;
1290 spin_lock_irqsave(&gr->lock, flags);
1291 chan = gr->chan[chid];
1293 if (stat & NV_PGRAPH_INTR_NOTIFY) {
1294 if (chan && (nsource & NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD)) {
1295 if (!nv04_gr_mthd(device, inst, mthd, data))
1296 show &= ~NV_PGRAPH_INTR_NOTIFY;
1300 if (stat & NV_PGRAPH_INTR_CONTEXT_SWITCH) {
1301 nvkm_wr32(device, NV03_PGRAPH_INTR, NV_PGRAPH_INTR_CONTEXT_SWITCH);
1302 stat &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH;
1303 show &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH;
1304 nv04_gr_context_switch(gr);
1307 nvkm_wr32(device, NV03_PGRAPH_INTR, stat);
1308 nvkm_wr32(device, NV04_PGRAPH_FIFO, 0x00000001);
1311 nvkm_snprintbf(msg, sizeof(msg), nv04_gr_intr_name, show);
1312 nvkm_snprintbf(src, sizeof(src), nv04_gr_nsource, nsource);
1313 nvkm_snprintbf(sta, sizeof(sta), nv04_gr_nstatus, nstatus);
1314 nvkm_error(subdev, "intr %08x [%s] nsource %08x [%s] "
1315 "nstatus %08x [%s] ch %d [%s] subc %d "
1316 "class %04x mthd %04x data %08x\n",
1317 show, msg, nsource, src, nstatus, sta, chid,
1318 chan ? chan->object.client->name : "unknown",
1319 subc, class, mthd, data);
1322 spin_unlock_irqrestore(&gr->lock, flags);
1325 static const struct nvkm_gr_func
1327 .chan_new = nv04_gr_chan_new,
1329 { -1, -1, 0x0012, &nv04_gr_object }, /* beta1 */
1330 { -1, -1, 0x0017, &nv04_gr_object }, /* chroma */
1331 { -1, -1, 0x0018, &nv04_gr_object }, /* pattern (nv01) */
1332 { -1, -1, 0x0019, &nv04_gr_object }, /* clip */
1333 { -1, -1, 0x001c, &nv04_gr_object }, /* line */
1334 { -1, -1, 0x001d, &nv04_gr_object }, /* tri */
1335 { -1, -1, 0x001e, &nv04_gr_object }, /* rect */
1336 { -1, -1, 0x001f, &nv04_gr_object },
1337 { -1, -1, 0x0021, &nv04_gr_object },
1338 { -1, -1, 0x0030, &nv04_gr_object }, /* null */
1339 { -1, -1, 0x0036, &nv04_gr_object },
1340 { -1, -1, 0x0037, &nv04_gr_object },
1341 { -1, -1, 0x0038, &nv04_gr_object }, /* dvd subpicture */
1342 { -1, -1, 0x0039, &nv04_gr_object }, /* m2mf */
1343 { -1, -1, 0x0042, &nv04_gr_object }, /* surf2d */
1344 { -1, -1, 0x0043, &nv04_gr_object }, /* rop */
1345 { -1, -1, 0x0044, &nv04_gr_object }, /* pattern */
1346 { -1, -1, 0x0048, &nv04_gr_object },
1347 { -1, -1, 0x004a, &nv04_gr_object },
1348 { -1, -1, 0x004b, &nv04_gr_object },
1349 { -1, -1, 0x0052, &nv04_gr_object }, /* swzsurf */
1350 { -1, -1, 0x0053, &nv04_gr_object },
1351 { -1, -1, 0x0054, &nv04_gr_object }, /* ttri */
1352 { -1, -1, 0x0055, &nv04_gr_object }, /* mtri */
1353 { -1, -1, 0x0057, &nv04_gr_object }, /* chroma */
1354 { -1, -1, 0x0058, &nv04_gr_object }, /* surf_dst */
1355 { -1, -1, 0x0059, &nv04_gr_object }, /* surf_src */
1356 { -1, -1, 0x005a, &nv04_gr_object }, /* surf_color */
1357 { -1, -1, 0x005b, &nv04_gr_object }, /* surf_zeta */
1358 { -1, -1, 0x005c, &nv04_gr_object }, /* line */
1359 { -1, -1, 0x005d, &nv04_gr_object }, /* tri */
1360 { -1, -1, 0x005e, &nv04_gr_object }, /* rect */
1361 { -1, -1, 0x005f, &nv04_gr_object },
1362 { -1, -1, 0x0060, &nv04_gr_object },
1363 { -1, -1, 0x0061, &nv04_gr_object },
1364 { -1, -1, 0x0064, &nv04_gr_object }, /* iifc (nv05) */
1365 { -1, -1, 0x0065, &nv04_gr_object }, /* ifc (nv05) */
1366 { -1, -1, 0x0066, &nv04_gr_object }, /* sifc (nv05) */
1367 { -1, -1, 0x0072, &nv04_gr_object }, /* beta4 */
1368 { -1, -1, 0x0076, &nv04_gr_object },
1369 { -1, -1, 0x0077, &nv04_gr_object },
1375 nv04_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
1376 struct nvkm_oclass *oclass, void *data, u32 size,
1377 struct nvkm_object **pobject)
1382 ret = nvkm_gr_create(parent, engine, oclass, true, &gr);
1383 *pobject = nv_object(gr);
1387 gr->base.func = &nv04_gr;
1388 nv_subdev(gr)->unit = 0x00001000;
1389 nv_subdev(gr)->intr = nv04_gr_intr;
1390 spin_lock_init(&gr->lock);
1395 nv04_gr_init(struct nvkm_object *object)
1397 struct nvkm_engine *engine = nv_engine(object);
1398 struct nv04_gr *gr = (void *)engine;
1399 struct nvkm_device *device = gr->base.engine.subdev.device;
1402 ret = nvkm_gr_init(&gr->base);
1406 /* Enable PGRAPH interrupts */
1407 nvkm_wr32(device, NV03_PGRAPH_INTR, 0xFFFFFFFF);
1408 nvkm_wr32(device, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
1410 nvkm_wr32(device, NV04_PGRAPH_VALID1, 0);
1411 nvkm_wr32(device, NV04_PGRAPH_VALID2, 0);
1412 /*nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0x000001FF);
1413 nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0x001FFFFF);*/
1414 nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0x1231c000);
1415 /*1231C000 blob, 001 haiku*/
1416 /*V_WRITE(NV04_PGRAPH_DEBUG_1, 0xf2d91100);*/
1417 nvkm_wr32(device, NV04_PGRAPH_DEBUG_1, 0x72111100);
1418 /*0x72111100 blob , 01 haiku*/
1419 /*nvkm_wr32(device, NV04_PGRAPH_DEBUG_2, 0x11d5f870);*/
1420 nvkm_wr32(device, NV04_PGRAPH_DEBUG_2, 0x11d5f071);
1423 /*nvkm_wr32(device, NV04_PGRAPH_DEBUG_3, 0xfad4ff31);*/
1424 nvkm_wr32(device, NV04_PGRAPH_DEBUG_3, 0xf0d4ff31);
1425 /*haiku and blob 10d4*/
1427 nvkm_wr32(device, NV04_PGRAPH_STATE , 0xFFFFFFFF);
1428 nvkm_wr32(device, NV04_PGRAPH_CTX_CONTROL , 0x10000100);
1429 nvkm_mask(device, NV04_PGRAPH_CTX_USER, 0xff000000, 0x0f000000);
1431 /* These don't belong here, they're part of a per-channel context */
1432 nvkm_wr32(device, NV04_PGRAPH_PATTERN_SHAPE, 0x00000000);
1433 nvkm_wr32(device, NV04_PGRAPH_BETA_AND , 0xFFFFFFFF);
1439 .handle = NV_ENGINE(GR, 0x04),
1440 .ofuncs = &(struct nvkm_ofuncs) {
1441 .ctor = nv04_gr_ctor,
1442 .dtor = _nvkm_gr_dtor,
1443 .init = nv04_gr_init,
1444 .fini = _nvkm_gr_fini,