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.
24 #include <engine/gr.h>
27 #include <core/client.h>
28 #include <engine/fifo.h>
29 #include <subdev/instmem.h>
30 #include <subdev/timer.h>
33 nv04_gr_ctx_regs
[] = {
38 NV04_PGRAPH_CTX_SWITCH1
,
39 NV04_PGRAPH_CTX_SWITCH2
,
40 NV04_PGRAPH_CTX_SWITCH3
,
41 NV04_PGRAPH_CTX_SWITCH4
,
42 NV04_PGRAPH_CTX_CACHE1
,
43 NV04_PGRAPH_CTX_CACHE2
,
44 NV04_PGRAPH_CTX_CACHE3
,
45 NV04_PGRAPH_CTX_CACHE4
,
75 NV04_PGRAPH_DMA_START_0
,
76 NV04_PGRAPH_DMA_START_1
,
77 NV04_PGRAPH_DMA_LENGTH
,
79 NV04_PGRAPH_DMA_PITCH
,
105 NV04_PGRAPH_BSWIZZLE2
,
106 NV04_PGRAPH_BSWIZZLE5
,
109 NV04_PGRAPH_PATT_COLOR0
,
110 NV04_PGRAPH_PATT_COLOR1
,
111 NV04_PGRAPH_PATT_COLORRAM
+0x00,
112 NV04_PGRAPH_PATT_COLORRAM
+0x04,
113 NV04_PGRAPH_PATT_COLORRAM
+0x08,
114 NV04_PGRAPH_PATT_COLORRAM
+0x0c,
115 NV04_PGRAPH_PATT_COLORRAM
+0x10,
116 NV04_PGRAPH_PATT_COLORRAM
+0x14,
117 NV04_PGRAPH_PATT_COLORRAM
+0x18,
118 NV04_PGRAPH_PATT_COLORRAM
+0x1c,
119 NV04_PGRAPH_PATT_COLORRAM
+0x20,
120 NV04_PGRAPH_PATT_COLORRAM
+0x24,
121 NV04_PGRAPH_PATT_COLORRAM
+0x28,
122 NV04_PGRAPH_PATT_COLORRAM
+0x2c,
123 NV04_PGRAPH_PATT_COLORRAM
+0x30,
124 NV04_PGRAPH_PATT_COLORRAM
+0x34,
125 NV04_PGRAPH_PATT_COLORRAM
+0x38,
126 NV04_PGRAPH_PATT_COLORRAM
+0x3c,
127 NV04_PGRAPH_PATT_COLORRAM
+0x40,
128 NV04_PGRAPH_PATT_COLORRAM
+0x44,
129 NV04_PGRAPH_PATT_COLORRAM
+0x48,
130 NV04_PGRAPH_PATT_COLORRAM
+0x4c,
131 NV04_PGRAPH_PATT_COLORRAM
+0x50,
132 NV04_PGRAPH_PATT_COLORRAM
+0x54,
133 NV04_PGRAPH_PATT_COLORRAM
+0x58,
134 NV04_PGRAPH_PATT_COLORRAM
+0x5c,
135 NV04_PGRAPH_PATT_COLORRAM
+0x60,
136 NV04_PGRAPH_PATT_COLORRAM
+0x64,
137 NV04_PGRAPH_PATT_COLORRAM
+0x68,
138 NV04_PGRAPH_PATT_COLORRAM
+0x6c,
139 NV04_PGRAPH_PATT_COLORRAM
+0x70,
140 NV04_PGRAPH_PATT_COLORRAM
+0x74,
141 NV04_PGRAPH_PATT_COLORRAM
+0x78,
142 NV04_PGRAPH_PATT_COLORRAM
+0x7c,
143 NV04_PGRAPH_PATT_COLORRAM
+0x80,
144 NV04_PGRAPH_PATT_COLORRAM
+0x84,
145 NV04_PGRAPH_PATT_COLORRAM
+0x88,
146 NV04_PGRAPH_PATT_COLORRAM
+0x8c,
147 NV04_PGRAPH_PATT_COLORRAM
+0x90,
148 NV04_PGRAPH_PATT_COLORRAM
+0x94,
149 NV04_PGRAPH_PATT_COLORRAM
+0x98,
150 NV04_PGRAPH_PATT_COLORRAM
+0x9c,
151 NV04_PGRAPH_PATT_COLORRAM
+0xa0,
152 NV04_PGRAPH_PATT_COLORRAM
+0xa4,
153 NV04_PGRAPH_PATT_COLORRAM
+0xa8,
154 NV04_PGRAPH_PATT_COLORRAM
+0xac,
155 NV04_PGRAPH_PATT_COLORRAM
+0xb0,
156 NV04_PGRAPH_PATT_COLORRAM
+0xb4,
157 NV04_PGRAPH_PATT_COLORRAM
+0xb8,
158 NV04_PGRAPH_PATT_COLORRAM
+0xbc,
159 NV04_PGRAPH_PATT_COLORRAM
+0xc0,
160 NV04_PGRAPH_PATT_COLORRAM
+0xc4,
161 NV04_PGRAPH_PATT_COLORRAM
+0xc8,
162 NV04_PGRAPH_PATT_COLORRAM
+0xcc,
163 NV04_PGRAPH_PATT_COLORRAM
+0xd0,
164 NV04_PGRAPH_PATT_COLORRAM
+0xd4,
165 NV04_PGRAPH_PATT_COLORRAM
+0xd8,
166 NV04_PGRAPH_PATT_COLORRAM
+0xdc,
167 NV04_PGRAPH_PATT_COLORRAM
+0xe0,
168 NV04_PGRAPH_PATT_COLORRAM
+0xe4,
169 NV04_PGRAPH_PATT_COLORRAM
+0xe8,
170 NV04_PGRAPH_PATT_COLORRAM
+0xec,
171 NV04_PGRAPH_PATT_COLORRAM
+0xf0,
172 NV04_PGRAPH_PATT_COLORRAM
+0xf4,
173 NV04_PGRAPH_PATT_COLORRAM
+0xf8,
174 NV04_PGRAPH_PATT_COLORRAM
+0xfc,
177 NV04_PGRAPH_PATTERN_SHAPE
,
181 NV04_PGRAPH_BETA_AND
,
182 NV04_PGRAPH_BETA_PREMULT
,
183 NV04_PGRAPH_CONTROL0
,
184 NV04_PGRAPH_CONTROL1
,
185 NV04_PGRAPH_CONTROL2
,
187 NV04_PGRAPH_STORED_FMT
,
188 NV04_PGRAPH_SOURCE_COLOR
,
332 NV04_PGRAPH_PASSTHRU_0
,
333 NV04_PGRAPH_PASSTHRU_1
,
334 NV04_PGRAPH_PASSTHRU_2
,
335 NV04_PGRAPH_DVD_COLORFMT
,
336 NV04_PGRAPH_SCALED_FORMAT
,
337 NV04_PGRAPH_MISC24_0
,
338 NV04_PGRAPH_MISC24_1
,
339 NV04_PGRAPH_MISC24_2
,
349 struct nv04_gr_chan
*chan
[16];
353 struct nv04_gr_chan
{
354 struct nvkm_object base
;
356 u32 nv04
[ARRAY_SIZE(nv04_gr_ctx_regs
)];
360 static inline struct nv04_gr
*
361 nv04_gr(struct nv04_gr_chan
*chan
)
363 return (void *)nv_object(chan
)->engine
;
366 /*******************************************************************************
367 * Graphics object classes
368 ******************************************************************************/
371 * Software methods, why they are needed, and how they all work:
373 * NV04 and NV05 keep most of the state in PGRAPH context itself, but some
374 * 2d engine settings are kept inside the grobjs themselves. The grobjs are
375 * 3 words long on both. grobj format on NV04 is:
379 * - bit 12: color key active
380 * - bit 13: clip rect active
381 * - bit 14: if set, destination surface is swizzled and taken from buffer 5
382 * [set by NV04_SWIZZLED_SURFACE], otherwise it's linear and taken
383 * from buffer 0 [set by NV04_CONTEXT_SURFACES_2D or
384 * NV03_CONTEXT_SURFACE_DST].
385 * - bits 15-17: 2d operation [aka patch config]
386 * - bit 24: patch valid [enables rendering using this object]
387 * - bit 25: surf3d valid [for tex_tri and multitex_tri only]
389 * - bits 0-1: mono format
390 * - bits 8-13: color format
391 * - bits 16-31: DMA_NOTIFY instance
393 * - bits 0-15: DMA_A instance
394 * - bits 16-31: DMA_B instance
400 * - bit 12: color key active
401 * - bit 13: clip rect active
402 * - bit 14: if set, destination surface is swizzled and taken from buffer 5
403 * [set by NV04_SWIZZLED_SURFACE], otherwise it's linear and taken
404 * from buffer 0 [set by NV04_CONTEXT_SURFACES_2D or
405 * NV03_CONTEXT_SURFACE_DST].
406 * - bits 15-17: 2d operation [aka patch config]
407 * - bits 20-22: dither mode
408 * - bit 24: patch valid [enables rendering using this object]
409 * - bit 25: surface_dst/surface_color/surf2d/surf3d valid
410 * - bit 26: surface_src/surface_zeta valid
411 * - bit 27: pattern valid
412 * - bit 28: rop valid
413 * - bit 29: beta1 valid
414 * - bit 30: beta4 valid
416 * - bits 0-1: mono format
417 * - bits 8-13: color format
418 * - bits 16-31: DMA_NOTIFY instance
420 * - bits 0-15: DMA_A instance
421 * - bits 16-31: DMA_B instance
423 * NV05 will set/unset the relevant valid bits when you poke the relevant
424 * object-binding methods with object of the proper type, or with the NULL
425 * type. It'll only allow rendering using the grobj if all needed objects
426 * are bound. The needed set of objects depends on selected operation: for
427 * example rop object is needed by ROP_AND, but not by SRCCOPY_AND.
429 * NV04 doesn't have these methods implemented at all, and doesn't have the
430 * relevant bits in grobj. Instead, it'll allow rendering whenever bit 24
431 * is set. So we have to emulate them in software, internally keeping the
432 * same bits as NV05 does. Since grobjs are aligned to 16 bytes on nv04,
433 * but the last word isn't actually used for anything, we abuse it for this
436 * Actually, NV05 can optionally check bit 24 too, but we disable this since
437 * there's no use for it.
439 * For unknown reasons, NV04 implements surf3d binding in hardware as an
440 * exception. Also for unknown reasons, NV04 doesn't implement the clipping
441 * methods on the surf3d object, so we have to emulate them too.
445 nv04_gr_set_ctx1(struct nvkm_device
*device
, u32 inst
, u32 mask
, u32 value
)
447 int subc
= (nvkm_rd32(device
, NV04_PGRAPH_TRAPPED_ADDR
) >> 13) & 0x7;
450 tmp
= nvkm_rd32(device
, 0x700000 + inst
);
453 nvkm_wr32(device
, 0x700000 + inst
, tmp
);
455 nvkm_wr32(device
, NV04_PGRAPH_CTX_SWITCH1
, tmp
);
456 nvkm_wr32(device
, NV04_PGRAPH_CTX_CACHE1
+ (subc
<< 2), tmp
);
460 nv04_gr_set_ctx_val(struct nvkm_device
*device
, u32 inst
, u32 mask
, u32 value
)
462 int class, op
, valid
= 1;
465 ctx1
= nvkm_rd32(device
, 0x700000 + inst
);
467 op
= (ctx1
>> 15) & 7;
469 tmp
= nvkm_rd32(device
, 0x70000c + inst
);
472 nvkm_wr32(device
, 0x70000c + inst
, tmp
);
474 /* check for valid surf2d/surf_dst/surf_color */
475 if (!(tmp
& 0x02000000))
477 /* check for valid surf_src/surf_zeta */
478 if ((class == 0x1f || class == 0x48) && !(tmp
& 0x04000000))
482 /* SRCCOPY_AND, SRCCOPY: no extra objects required */
486 /* ROP_AND: requires pattern and rop */
488 if (!(tmp
& 0x18000000))
491 /* BLEND_AND: requires beta1 */
493 if (!(tmp
& 0x20000000))
496 /* SRCCOPY_PREMULT, BLEND_PREMULT: beta4 required */
499 if (!(tmp
& 0x40000000))
504 nv04_gr_set_ctx1(device
, inst
, 0x01000000, valid
<< 24);
508 nv04_gr_mthd_set_operation(struct nvkm_device
*device
, u32 inst
, u32 data
)
510 u8
class = nvkm_rd32(device
, 0x700000) & 0x000000ff;
513 /* Old versions of the objects only accept first three operations. */
514 if (data
> 2 && class < 0x40)
516 nv04_gr_set_ctx1(device
, inst
, 0x00038000, data
<< 15);
517 /* changing operation changes set of objects needed for validation */
518 nv04_gr_set_ctx_val(device
, inst
, 0, 0);
523 nv04_gr_mthd_surf3d_clip_h(struct nvkm_device
*device
, u32 inst
, u32 data
)
525 u32 min
= data
& 0xffff, max
;
531 /* yes, it accepts negative for some reason. */
535 nvkm_wr32(device
, 0x40053c, min
);
536 nvkm_wr32(device
, 0x400544, max
);
541 nv04_gr_mthd_surf3d_clip_v(struct nvkm_device
*device
, u32 inst
, u32 data
)
543 u32 min
= data
& 0xffff, max
;
549 /* yes, it accepts negative for some reason. */
553 nvkm_wr32(device
, 0x400540, min
);
554 nvkm_wr32(device
, 0x400548, max
);
559 nv04_gr_mthd_bind_class(struct nvkm_device
*device
, u32 inst
)
561 return nvkm_rd32(device
, 0x700000 + (inst
<< 4));
565 nv04_gr_mthd_bind_surf2d(struct nvkm_device
*device
, u32 inst
, u32 data
)
567 switch (nv04_gr_mthd_bind_class(device
, data
)) {
569 nv04_gr_set_ctx1(device
, inst
, 0x00004000, 0);
570 nv04_gr_set_ctx_val(device
, inst
, 0x02000000, 0);
573 nv04_gr_set_ctx1(device
, inst
, 0x00004000, 0);
574 nv04_gr_set_ctx_val(device
, inst
, 0x02000000, 0x02000000);
581 nv04_gr_mthd_bind_surf2d_swzsurf(struct nvkm_device
*device
, u32 inst
, u32 data
)
583 switch (nv04_gr_mthd_bind_class(device
, data
)) {
585 nv04_gr_set_ctx1(device
, inst
, 0x00004000, 0);
586 nv04_gr_set_ctx_val(device
, inst
, 0x02000000, 0);
589 nv04_gr_set_ctx1(device
, inst
, 0x00004000, 0);
590 nv04_gr_set_ctx_val(device
, inst
, 0x02000000, 0x02000000);
593 nv04_gr_set_ctx1(device
, inst
, 0x00004000, 0x00004000);
594 nv04_gr_set_ctx_val(device
, inst
, 0x02000000, 0x02000000);
601 nv01_gr_mthd_bind_patt(struct nvkm_device
*device
, u32 inst
, u32 data
)
603 switch (nv04_gr_mthd_bind_class(device
, data
)) {
605 nv04_gr_set_ctx_val(device
, inst
, 0x08000000, 0);
608 nv04_gr_set_ctx_val(device
, inst
, 0x08000000, 0x08000000);
615 nv04_gr_mthd_bind_patt(struct nvkm_device
*device
, u32 inst
, u32 data
)
617 switch (nv04_gr_mthd_bind_class(device
, data
)) {
619 nv04_gr_set_ctx_val(device
, inst
, 0x08000000, 0);
622 nv04_gr_set_ctx_val(device
, inst
, 0x08000000, 0x08000000);
629 nv04_gr_mthd_bind_rop(struct nvkm_device
*device
, u32 inst
, u32 data
)
631 switch (nv04_gr_mthd_bind_class(device
, data
)) {
633 nv04_gr_set_ctx_val(device
, inst
, 0x10000000, 0);
636 nv04_gr_set_ctx_val(device
, inst
, 0x10000000, 0x10000000);
643 nv04_gr_mthd_bind_beta1(struct nvkm_device
*device
, u32 inst
, u32 data
)
645 switch (nv04_gr_mthd_bind_class(device
, data
)) {
647 nv04_gr_set_ctx_val(device
, inst
, 0x20000000, 0);
650 nv04_gr_set_ctx_val(device
, inst
, 0x20000000, 0x20000000);
657 nv04_gr_mthd_bind_beta4(struct nvkm_device
*device
, u32 inst
, u32 data
)
659 switch (nv04_gr_mthd_bind_class(device
, data
)) {
661 nv04_gr_set_ctx_val(device
, inst
, 0x40000000, 0);
664 nv04_gr_set_ctx_val(device
, inst
, 0x40000000, 0x40000000);
671 nv04_gr_mthd_bind_surf_dst(struct nvkm_device
*device
, u32 inst
, u32 data
)
673 switch (nv04_gr_mthd_bind_class(device
, data
)) {
675 nv04_gr_set_ctx_val(device
, inst
, 0x02000000, 0);
678 nv04_gr_set_ctx_val(device
, inst
, 0x02000000, 0x02000000);
685 nv04_gr_mthd_bind_surf_src(struct nvkm_device
*device
, u32 inst
, u32 data
)
687 switch (nv04_gr_mthd_bind_class(device
, data
)) {
689 nv04_gr_set_ctx_val(device
, inst
, 0x04000000, 0);
692 nv04_gr_set_ctx_val(device
, inst
, 0x04000000, 0x04000000);
699 nv04_gr_mthd_bind_surf_color(struct nvkm_device
*device
, u32 inst
, u32 data
)
701 switch (nv04_gr_mthd_bind_class(device
, data
)) {
703 nv04_gr_set_ctx_val(device
, inst
, 0x02000000, 0);
706 nv04_gr_set_ctx_val(device
, inst
, 0x02000000, 0x02000000);
713 nv04_gr_mthd_bind_surf_zeta(struct nvkm_device
*device
, u32 inst
, u32 data
)
715 switch (nv04_gr_mthd_bind_class(device
, data
)) {
717 nv04_gr_set_ctx_val(device
, inst
, 0x04000000, 0);
720 nv04_gr_set_ctx_val(device
, inst
, 0x04000000, 0x04000000);
727 nv01_gr_mthd_bind_clip(struct nvkm_device
*device
, u32 inst
, u32 data
)
729 switch (nv04_gr_mthd_bind_class(device
, data
)) {
731 nv04_gr_set_ctx1(device
, inst
, 0x2000, 0);
734 nv04_gr_set_ctx1(device
, inst
, 0x2000, 0x2000);
741 nv01_gr_mthd_bind_chroma(struct nvkm_device
*device
, u32 inst
, u32 data
)
743 switch (nv04_gr_mthd_bind_class(device
, data
)) {
745 nv04_gr_set_ctx1(device
, inst
, 0x1000, 0);
747 /* Yes, for some reason even the old versions of objects
748 * accept 0x57 and not 0x17. Consistency be damned.
751 nv04_gr_set_ctx1(device
, inst
, 0x1000, 0x1000);
758 nv03_gr_mthd_gdi(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
760 bool (*func
)(struct nvkm_device
*, u32
, u32
);
762 case 0x0184: func
= nv01_gr_mthd_bind_patt
; break;
763 case 0x0188: func
= nv04_gr_mthd_bind_rop
; break;
764 case 0x018c: func
= nv04_gr_mthd_bind_beta1
; break;
765 case 0x0190: func
= nv04_gr_mthd_bind_surf_dst
; break;
766 case 0x02fc: func
= nv04_gr_mthd_set_operation
; break;
770 return func(device
, inst
, data
);
774 nv04_gr_mthd_gdi(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
776 bool (*func
)(struct nvkm_device
*, u32
, u32
);
778 case 0x0188: func
= nv04_gr_mthd_bind_patt
; break;
779 case 0x018c: func
= nv04_gr_mthd_bind_rop
; break;
780 case 0x0190: func
= nv04_gr_mthd_bind_beta1
; break;
781 case 0x0194: func
= nv04_gr_mthd_bind_beta4
; break;
782 case 0x0198: func
= nv04_gr_mthd_bind_surf2d
; break;
783 case 0x02fc: func
= nv04_gr_mthd_set_operation
; break;
787 return func(device
, inst
, data
);
791 nv01_gr_mthd_blit(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
793 bool (*func
)(struct nvkm_device
*, u32
, u32
);
795 case 0x0184: func
= nv01_gr_mthd_bind_chroma
; break;
796 case 0x0188: func
= nv01_gr_mthd_bind_clip
; break;
797 case 0x018c: func
= nv01_gr_mthd_bind_patt
; break;
798 case 0x0190: func
= nv04_gr_mthd_bind_rop
; break;
799 case 0x0194: func
= nv04_gr_mthd_bind_beta1
; break;
800 case 0x0198: func
= nv04_gr_mthd_bind_surf_dst
; break;
801 case 0x019c: func
= nv04_gr_mthd_bind_surf_src
; break;
802 case 0x02fc: func
= nv04_gr_mthd_set_operation
; break;
806 return func(device
, inst
, data
);
810 nv04_gr_mthd_blit(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
812 bool (*func
)(struct nvkm_device
*, u32
, u32
);
814 case 0x0184: func
= nv01_gr_mthd_bind_chroma
; break;
815 case 0x0188: func
= nv01_gr_mthd_bind_clip
; break;
816 case 0x018c: func
= nv04_gr_mthd_bind_patt
; break;
817 case 0x0190: func
= nv04_gr_mthd_bind_rop
; break;
818 case 0x0194: func
= nv04_gr_mthd_bind_beta1
; break;
819 case 0x0198: func
= nv04_gr_mthd_bind_beta4
; break;
820 case 0x019c: func
= nv04_gr_mthd_bind_surf2d
; break;
821 case 0x02fc: func
= nv04_gr_mthd_set_operation
; break;
825 return func(device
, inst
, data
);
829 nv04_gr_mthd_iifc(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
831 bool (*func
)(struct nvkm_device
*, u32
, u32
);
833 case 0x0188: func
= nv01_gr_mthd_bind_chroma
; break;
834 case 0x018c: func
= nv01_gr_mthd_bind_clip
; break;
835 case 0x0190: func
= nv04_gr_mthd_bind_patt
; break;
836 case 0x0194: func
= nv04_gr_mthd_bind_rop
; break;
837 case 0x0198: func
= nv04_gr_mthd_bind_beta1
; break;
838 case 0x019c: func
= nv04_gr_mthd_bind_beta4
; break;
839 case 0x01a0: func
= nv04_gr_mthd_bind_surf2d_swzsurf
; break;
840 case 0x03e4: func
= nv04_gr_mthd_set_operation
; break;
844 return func(device
, inst
, data
);
848 nv01_gr_mthd_ifc(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
850 bool (*func
)(struct nvkm_device
*, u32
, u32
);
852 case 0x0184: func
= nv01_gr_mthd_bind_chroma
; break;
853 case 0x0188: func
= nv01_gr_mthd_bind_clip
; break;
854 case 0x018c: func
= nv01_gr_mthd_bind_patt
; break;
855 case 0x0190: func
= nv04_gr_mthd_bind_rop
; break;
856 case 0x0194: func
= nv04_gr_mthd_bind_beta1
; break;
857 case 0x0198: func
= nv04_gr_mthd_bind_surf_dst
; break;
858 case 0x02fc: func
= nv04_gr_mthd_set_operation
; break;
862 return func(device
, inst
, data
);
866 nv04_gr_mthd_ifc(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
868 bool (*func
)(struct nvkm_device
*, u32
, u32
);
870 case 0x0184: func
= nv01_gr_mthd_bind_chroma
; break;
871 case 0x0188: func
= nv01_gr_mthd_bind_clip
; break;
872 case 0x018c: func
= nv04_gr_mthd_bind_patt
; break;
873 case 0x0190: func
= nv04_gr_mthd_bind_rop
; break;
874 case 0x0194: func
= nv04_gr_mthd_bind_beta1
; break;
875 case 0x0198: func
= nv04_gr_mthd_bind_beta4
; break;
876 case 0x019c: func
= nv04_gr_mthd_bind_surf2d
; break;
877 case 0x02fc: func
= nv04_gr_mthd_set_operation
; break;
881 return func(device
, inst
, data
);
885 nv03_gr_mthd_sifc(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
887 bool (*func
)(struct nvkm_device
*, u32
, u32
);
889 case 0x0184: func
= nv01_gr_mthd_bind_chroma
; break;
890 case 0x0188: func
= nv01_gr_mthd_bind_patt
; break;
891 case 0x018c: func
= nv04_gr_mthd_bind_rop
; break;
892 case 0x0190: func
= nv04_gr_mthd_bind_beta1
; break;
893 case 0x0194: func
= nv04_gr_mthd_bind_surf_dst
; break;
894 case 0x02fc: func
= nv04_gr_mthd_set_operation
; break;
898 return func(device
, inst
, data
);
902 nv04_gr_mthd_sifc(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
904 bool (*func
)(struct nvkm_device
*, u32
, u32
);
906 case 0x0184: func
= nv01_gr_mthd_bind_chroma
; break;
907 case 0x0188: func
= nv04_gr_mthd_bind_patt
; break;
908 case 0x018c: func
= nv04_gr_mthd_bind_rop
; break;
909 case 0x0190: func
= nv04_gr_mthd_bind_beta1
; break;
910 case 0x0194: func
= nv04_gr_mthd_bind_beta4
; break;
911 case 0x0198: func
= nv04_gr_mthd_bind_surf2d
; break;
912 case 0x02fc: func
= nv04_gr_mthd_set_operation
; break;
916 return func(device
, inst
, data
);
920 nv03_gr_mthd_sifm(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
922 bool (*func
)(struct nvkm_device
*, u32
, u32
);
924 case 0x0188: func
= nv01_gr_mthd_bind_patt
; break;
925 case 0x018c: func
= nv04_gr_mthd_bind_rop
; break;
926 case 0x0190: func
= nv04_gr_mthd_bind_beta1
; break;
927 case 0x0194: func
= nv04_gr_mthd_bind_surf_dst
; break;
928 case 0x0304: func
= nv04_gr_mthd_set_operation
; break;
932 return func(device
, inst
, data
);
936 nv04_gr_mthd_sifm(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
938 bool (*func
)(struct nvkm_device
*, u32
, u32
);
940 case 0x0188: func
= nv04_gr_mthd_bind_patt
; break;
941 case 0x018c: func
= nv04_gr_mthd_bind_rop
; break;
942 case 0x0190: func
= nv04_gr_mthd_bind_beta1
; break;
943 case 0x0194: func
= nv04_gr_mthd_bind_beta4
; break;
944 case 0x0198: func
= nv04_gr_mthd_bind_surf2d
; break;
945 case 0x0304: func
= nv04_gr_mthd_set_operation
; break;
949 return func(device
, inst
, data
);
953 nv04_gr_mthd_surf3d(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
955 bool (*func
)(struct nvkm_device
*, u32
, u32
);
957 case 0x02f8: func
= nv04_gr_mthd_surf3d_clip_h
; break;
958 case 0x02fc: func
= nv04_gr_mthd_surf3d_clip_v
; break;
962 return func(device
, inst
, data
);
966 nv03_gr_mthd_ttri(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
968 bool (*func
)(struct nvkm_device
*, u32
, u32
);
970 case 0x0188: func
= nv01_gr_mthd_bind_clip
; break;
971 case 0x018c: func
= nv04_gr_mthd_bind_surf_color
; break;
972 case 0x0190: func
= nv04_gr_mthd_bind_surf_zeta
; break;
976 return func(device
, inst
, data
);
980 nv01_gr_mthd_prim(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
982 bool (*func
)(struct nvkm_device
*, u32
, u32
);
984 case 0x0184: func
= nv01_gr_mthd_bind_clip
; break;
985 case 0x0188: func
= nv01_gr_mthd_bind_patt
; break;
986 case 0x018c: func
= nv04_gr_mthd_bind_rop
; break;
987 case 0x0190: func
= nv04_gr_mthd_bind_beta1
; break;
988 case 0x0194: func
= nv04_gr_mthd_bind_surf_dst
; break;
989 case 0x02fc: func
= nv04_gr_mthd_set_operation
; break;
993 return func(device
, inst
, data
);
997 nv04_gr_mthd_prim(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
999 bool (*func
)(struct nvkm_device
*, u32
, u32
);
1001 case 0x0184: func
= nv01_gr_mthd_bind_clip
; break;
1002 case 0x0188: func
= nv04_gr_mthd_bind_patt
; break;
1003 case 0x018c: func
= nv04_gr_mthd_bind_rop
; break;
1004 case 0x0190: func
= nv04_gr_mthd_bind_beta1
; break;
1005 case 0x0194: func
= nv04_gr_mthd_bind_beta4
; break;
1006 case 0x0198: func
= nv04_gr_mthd_bind_surf2d
; break;
1007 case 0x02fc: func
= nv04_gr_mthd_set_operation
; break;
1011 return func(device
, inst
, data
);
1015 nv04_gr_mthd(struct nvkm_device
*device
, u32 inst
, u32 mthd
, u32 data
)
1017 bool (*func
)(struct nvkm_device
*, u32
, u32
, u32
);
1018 switch (nvkm_rd32(device
, 0x700000 + inst
) & 0x000000ff) {
1020 func
= nv01_gr_mthd_prim
; break;
1021 case 0x1f: func
= nv01_gr_mthd_blit
; break;
1022 case 0x21: func
= nv01_gr_mthd_ifc
; break;
1023 case 0x36: func
= nv03_gr_mthd_sifc
; break;
1024 case 0x37: func
= nv03_gr_mthd_sifm
; break;
1025 case 0x48: func
= nv03_gr_mthd_ttri
; break;
1026 case 0x4a: func
= nv04_gr_mthd_gdi
; break;
1027 case 0x4b: func
= nv03_gr_mthd_gdi
; break;
1028 case 0x53: func
= nv04_gr_mthd_surf3d
; break;
1030 func
= nv04_gr_mthd_prim
; break;
1031 case 0x5f: func
= nv04_gr_mthd_blit
; break;
1032 case 0x60: func
= nv04_gr_mthd_iifc
; break;
1033 case 0x61: func
= nv04_gr_mthd_ifc
; break;
1034 case 0x76: func
= nv04_gr_mthd_sifc
; break;
1035 case 0x77: func
= nv04_gr_mthd_sifm
; break;
1039 return func(device
, inst
, mthd
, data
);
1043 nv04_gr_object_ctor(struct nvkm_object
*parent
, struct nvkm_object
*engine
,
1044 struct nvkm_oclass
*oclass
, void *data
, u32 size
,
1045 struct nvkm_object
**pobject
)
1047 struct nvkm_gpuobj
*obj
;
1050 ret
= nvkm_gpuobj_create(parent
, engine
, oclass
, 0, parent
,
1052 *pobject
= nv_object(obj
);
1057 nvkm_wo32(obj
, 0x00, nv_mclass(obj
));
1059 nvkm_mo32(obj
, 0x00, 0x00080000, 0x00080000);
1061 nvkm_wo32(obj
, 0x04, 0x00000000);
1062 nvkm_wo32(obj
, 0x08, 0x00000000);
1063 nvkm_wo32(obj
, 0x0c, 0x00000000);
1070 .ctor
= nv04_gr_object_ctor
,
1071 .dtor
= _nvkm_gpuobj_dtor
,
1072 .init
= _nvkm_gpuobj_init
,
1073 .fini
= _nvkm_gpuobj_fini
,
1074 .rd32
= _nvkm_gpuobj_rd32
,
1075 .wr32
= _nvkm_gpuobj_wr32
,
1078 static struct nvkm_oclass
1079 nv04_gr_sclass
[] = {
1080 { 0x0012, &nv04_gr_ofuncs
}, /* beta1 */
1081 { 0x0017, &nv04_gr_ofuncs
}, /* chroma */
1082 { 0x0018, &nv04_gr_ofuncs
}, /* pattern (nv01) */
1083 { 0x0019, &nv04_gr_ofuncs
}, /* clip */
1084 { 0x001c, &nv04_gr_ofuncs
}, /* line */
1085 { 0x001d, &nv04_gr_ofuncs
}, /* tri */
1086 { 0x001e, &nv04_gr_ofuncs
}, /* rect */
1087 { 0x001f, &nv04_gr_ofuncs
},
1088 { 0x0021, &nv04_gr_ofuncs
},
1089 { 0x0030, &nv04_gr_ofuncs
}, /* null */
1090 { 0x0036, &nv04_gr_ofuncs
},
1091 { 0x0037, &nv04_gr_ofuncs
},
1092 { 0x0038, &nv04_gr_ofuncs
}, /* dvd subpicture */
1093 { 0x0039, &nv04_gr_ofuncs
}, /* m2mf */
1094 { 0x0042, &nv04_gr_ofuncs
}, /* surf2d */
1095 { 0x0043, &nv04_gr_ofuncs
}, /* rop */
1096 { 0x0044, &nv04_gr_ofuncs
}, /* pattern */
1097 { 0x0048, &nv04_gr_ofuncs
},
1098 { 0x004a, &nv04_gr_ofuncs
},
1099 { 0x004b, &nv04_gr_ofuncs
},
1100 { 0x0052, &nv04_gr_ofuncs
}, /* swzsurf */
1101 { 0x0053, &nv04_gr_ofuncs
},
1102 { 0x0054, &nv04_gr_ofuncs
}, /* ttri */
1103 { 0x0055, &nv04_gr_ofuncs
}, /* mtri */
1104 { 0x0057, &nv04_gr_ofuncs
}, /* chroma */
1105 { 0x0058, &nv04_gr_ofuncs
}, /* surf_dst */
1106 { 0x0059, &nv04_gr_ofuncs
}, /* surf_src */
1107 { 0x005a, &nv04_gr_ofuncs
}, /* surf_color */
1108 { 0x005b, &nv04_gr_ofuncs
}, /* surf_zeta */
1109 { 0x005c, &nv04_gr_ofuncs
}, /* line */
1110 { 0x005d, &nv04_gr_ofuncs
}, /* tri */
1111 { 0x005e, &nv04_gr_ofuncs
}, /* rect */
1112 { 0x005f, &nv04_gr_ofuncs
},
1113 { 0x0060, &nv04_gr_ofuncs
},
1114 { 0x0061, &nv04_gr_ofuncs
},
1115 { 0x0064, &nv04_gr_ofuncs
}, /* iifc (nv05) */
1116 { 0x0065, &nv04_gr_ofuncs
}, /* ifc (nv05) */
1117 { 0x0066, &nv04_gr_ofuncs
}, /* sifc (nv05) */
1118 { 0x0072, &nv04_gr_ofuncs
}, /* beta4 */
1119 { 0x0076, &nv04_gr_ofuncs
},
1120 { 0x0077, &nv04_gr_ofuncs
},
1124 /*******************************************************************************
1126 ******************************************************************************/
1128 static struct nv04_gr_chan
*
1129 nv04_gr_channel(struct nv04_gr
*gr
)
1131 struct nvkm_device
*device
= gr
->base
.engine
.subdev
.device
;
1132 struct nv04_gr_chan
*chan
= NULL
;
1133 if (nvkm_rd32(device
, NV04_PGRAPH_CTX_CONTROL
) & 0x00010000) {
1134 int chid
= nvkm_rd32(device
, NV04_PGRAPH_CTX_USER
) >> 24;
1135 if (chid
< ARRAY_SIZE(gr
->chan
))
1136 chan
= gr
->chan
[chid
];
1142 nv04_gr_load_context(struct nv04_gr_chan
*chan
, int chid
)
1144 struct nv04_gr
*gr
= nv04_gr(chan
);
1145 struct nvkm_device
*device
= gr
->base
.engine
.subdev
.device
;
1148 for (i
= 0; i
< ARRAY_SIZE(nv04_gr_ctx_regs
); i
++)
1149 nvkm_wr32(device
, nv04_gr_ctx_regs
[i
], chan
->nv04
[i
]);
1151 nvkm_wr32(device
, NV04_PGRAPH_CTX_CONTROL
, 0x10010100);
1152 nvkm_mask(device
, NV04_PGRAPH_CTX_USER
, 0xff000000, chid
<< 24);
1153 nvkm_mask(device
, NV04_PGRAPH_FFINTFC_ST2
, 0xfff00000, 0x00000000);
1158 nv04_gr_unload_context(struct nv04_gr_chan
*chan
)
1160 struct nv04_gr
*gr
= nv04_gr(chan
);
1161 struct nvkm_device
*device
= gr
->base
.engine
.subdev
.device
;
1164 for (i
= 0; i
< ARRAY_SIZE(nv04_gr_ctx_regs
); i
++)
1165 chan
->nv04
[i
] = nvkm_rd32(device
, nv04_gr_ctx_regs
[i
]);
1167 nvkm_wr32(device
, NV04_PGRAPH_CTX_CONTROL
, 0x10000000);
1168 nvkm_mask(device
, NV04_PGRAPH_CTX_USER
, 0xff000000, 0x0f000000);
1173 nv04_gr_context_switch(struct nv04_gr
*gr
)
1175 struct nvkm_device
*device
= gr
->base
.engine
.subdev
.device
;
1176 struct nv04_gr_chan
*prev
= NULL
;
1177 struct nv04_gr_chan
*next
= NULL
;
1182 /* If previous context is valid, we need to save it */
1183 prev
= nv04_gr_channel(gr
);
1185 nv04_gr_unload_context(prev
);
1187 /* load context for next channel */
1188 chid
= (nvkm_rd32(device
, NV04_PGRAPH_TRAPPED_ADDR
) >> 24) & 0x0f;
1189 next
= gr
->chan
[chid
];
1191 nv04_gr_load_context(next
, chid
);
1194 static u32
*ctx_reg(struct nv04_gr_chan
*chan
, u32 reg
)
1198 for (i
= 0; i
< ARRAY_SIZE(nv04_gr_ctx_regs
); i
++) {
1199 if (nv04_gr_ctx_regs
[i
] == reg
)
1200 return &chan
->nv04
[i
];
1207 nv04_gr_context_ctor(struct nvkm_object
*parent
,
1208 struct nvkm_object
*engine
,
1209 struct nvkm_oclass
*oclass
, void *data
, u32 size
,
1210 struct nvkm_object
**pobject
)
1212 struct nvkm_fifo_chan
*fifo
= (void *)parent
;
1213 struct nv04_gr
*gr
= (void *)engine
;
1214 struct nv04_gr_chan
*chan
;
1215 unsigned long flags
;
1218 ret
= nvkm_object_create(parent
, engine
, oclass
, 0, &chan
);
1219 *pobject
= nv_object(chan
);
1223 spin_lock_irqsave(&gr
->lock
, flags
);
1224 if (gr
->chan
[fifo
->chid
]) {
1225 *pobject
= nv_object(gr
->chan
[fifo
->chid
]);
1226 atomic_inc(&(*pobject
)->refcount
);
1227 spin_unlock_irqrestore(&gr
->lock
, flags
);
1228 nvkm_object_destroy(&chan
->base
);
1232 *ctx_reg(chan
, NV04_PGRAPH_DEBUG_3
) = 0xfad4ff31;
1234 gr
->chan
[fifo
->chid
] = chan
;
1235 chan
->chid
= fifo
->chid
;
1236 spin_unlock_irqrestore(&gr
->lock
, flags
);
1241 nv04_gr_context_dtor(struct nvkm_object
*object
)
1243 struct nv04_gr
*gr
= (void *)object
->engine
;
1244 struct nv04_gr_chan
*chan
= (void *)object
;
1245 unsigned long flags
;
1247 spin_lock_irqsave(&gr
->lock
, flags
);
1248 gr
->chan
[chan
->chid
] = NULL
;
1249 spin_unlock_irqrestore(&gr
->lock
, flags
);
1251 nvkm_object_destroy(&chan
->base
);
1255 nv04_gr_context_fini(struct nvkm_object
*object
, bool suspend
)
1257 struct nv04_gr
*gr
= (void *)object
->engine
;
1258 struct nv04_gr_chan
*chan
= (void *)object
;
1259 struct nvkm_device
*device
= gr
->base
.engine
.subdev
.device
;
1260 unsigned long flags
;
1262 spin_lock_irqsave(&gr
->lock
, flags
);
1263 nvkm_mask(device
, NV04_PGRAPH_FIFO
, 0x00000001, 0x00000000);
1264 if (nv04_gr_channel(gr
) == chan
)
1265 nv04_gr_unload_context(chan
);
1266 nvkm_mask(device
, NV04_PGRAPH_FIFO
, 0x00000001, 0x00000001);
1267 spin_unlock_irqrestore(&gr
->lock
, flags
);
1269 return _nvkm_object_fini(&chan
->base
, suspend
);
1272 static struct nvkm_oclass
1274 .handle
= NV_ENGCTX(GR
, 0x04),
1275 .ofuncs
= &(struct nvkm_ofuncs
) {
1276 .ctor
= nv04_gr_context_ctor
,
1277 .dtor
= nv04_gr_context_dtor
,
1278 .init
= _nvkm_object_init
,
1279 .fini
= nv04_gr_context_fini
,
1283 /*******************************************************************************
1284 * PGRAPH engine/subdev functions
1285 ******************************************************************************/
1288 nv04_gr_idle(void *obj
)
1290 struct nvkm_gr
*gr
= nvkm_gr(obj
);
1291 struct nvkm_subdev
*subdev
= &gr
->engine
.subdev
;
1292 struct nvkm_device
*device
= subdev
->device
;
1293 u32 mask
= 0xffffffff;
1295 if (nv_device(obj
)->card_type
== NV_40
)
1296 mask
&= ~NV40_PGRAPH_STATUS_SYNC_STALL
;
1298 if (nvkm_msec(device
, 2000,
1299 if (!(nvkm_rd32(device
, NV04_PGRAPH_STATUS
) & mask
))
1302 nvkm_error(subdev
, "idle timed out with status %08x\n",
1303 nvkm_rd32(device
, NV04_PGRAPH_STATUS
));
1310 static const struct nvkm_bitfield
1311 nv04_gr_intr_name
[] = {
1312 { NV_PGRAPH_INTR_NOTIFY
, "NOTIFY" },
1316 static const struct nvkm_bitfield
1317 nv04_gr_nstatus
[] = {
1318 { NV04_PGRAPH_NSTATUS_STATE_IN_USE
, "STATE_IN_USE" },
1319 { NV04_PGRAPH_NSTATUS_INVALID_STATE
, "INVALID_STATE" },
1320 { NV04_PGRAPH_NSTATUS_BAD_ARGUMENT
, "BAD_ARGUMENT" },
1321 { NV04_PGRAPH_NSTATUS_PROTECTION_FAULT
, "PROTECTION_FAULT" },
1325 const struct nvkm_bitfield
1326 nv04_gr_nsource
[] = {
1327 { NV03_PGRAPH_NSOURCE_NOTIFICATION
, "NOTIFICATION" },
1328 { NV03_PGRAPH_NSOURCE_DATA_ERROR
, "DATA_ERROR" },
1329 { NV03_PGRAPH_NSOURCE_PROTECTION_ERROR
, "PROTECTION_ERROR" },
1330 { NV03_PGRAPH_NSOURCE_RANGE_EXCEPTION
, "RANGE_EXCEPTION" },
1331 { NV03_PGRAPH_NSOURCE_LIMIT_COLOR
, "LIMIT_COLOR" },
1332 { NV03_PGRAPH_NSOURCE_LIMIT_ZETA
, "LIMIT_ZETA" },
1333 { NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD
, "ILLEGAL_MTHD" },
1334 { NV03_PGRAPH_NSOURCE_DMA_R_PROTECTION
, "DMA_R_PROTECTION" },
1335 { NV03_PGRAPH_NSOURCE_DMA_W_PROTECTION
, "DMA_W_PROTECTION" },
1336 { NV03_PGRAPH_NSOURCE_FORMAT_EXCEPTION
, "FORMAT_EXCEPTION" },
1337 { NV03_PGRAPH_NSOURCE_PATCH_EXCEPTION
, "PATCH_EXCEPTION" },
1338 { NV03_PGRAPH_NSOURCE_STATE_INVALID
, "STATE_INVALID" },
1339 { NV03_PGRAPH_NSOURCE_DOUBLE_NOTIFY
, "DOUBLE_NOTIFY" },
1340 { NV03_PGRAPH_NSOURCE_NOTIFY_IN_USE
, "NOTIFY_IN_USE" },
1341 { NV03_PGRAPH_NSOURCE_METHOD_CNT
, "METHOD_CNT" },
1342 { NV03_PGRAPH_NSOURCE_BFR_NOTIFICATION
, "BFR_NOTIFICATION" },
1343 { NV03_PGRAPH_NSOURCE_DMA_VTX_PROTECTION
, "DMA_VTX_PROTECTION" },
1344 { NV03_PGRAPH_NSOURCE_DMA_WIDTH_A
, "DMA_WIDTH_A" },
1345 { NV03_PGRAPH_NSOURCE_DMA_WIDTH_B
, "DMA_WIDTH_B" },
1350 nv04_gr_intr(struct nvkm_subdev
*subdev
)
1352 struct nv04_gr
*gr
= (void *)subdev
;
1353 struct nv04_gr_chan
*chan
= NULL
;
1354 struct nvkm_device
*device
= gr
->base
.engine
.subdev
.device
;
1355 u32 stat
= nvkm_rd32(device
, NV03_PGRAPH_INTR
);
1356 u32 nsource
= nvkm_rd32(device
, NV03_PGRAPH_NSOURCE
);
1357 u32 nstatus
= nvkm_rd32(device
, NV03_PGRAPH_NSTATUS
);
1358 u32 addr
= nvkm_rd32(device
, NV04_PGRAPH_TRAPPED_ADDR
);
1359 u32 chid
= (addr
& 0x0f000000) >> 24;
1360 u32 subc
= (addr
& 0x0000e000) >> 13;
1361 u32 mthd
= (addr
& 0x00001ffc);
1362 u32 data
= nvkm_rd32(device
, NV04_PGRAPH_TRAPPED_DATA
);
1363 u32
class = nvkm_rd32(device
, 0x400180 + subc
* 4) & 0xff;
1364 u32 inst
= (nvkm_rd32(device
, 0x40016c) & 0xffff) << 4;
1366 char msg
[128], src
[128], sta
[128];
1367 unsigned long flags
;
1369 spin_lock_irqsave(&gr
->lock
, flags
);
1370 chan
= gr
->chan
[chid
];
1372 if (stat
& NV_PGRAPH_INTR_NOTIFY
) {
1373 if (chan
&& (nsource
& NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD
)) {
1374 if (!nv04_gr_mthd(device
, inst
, mthd
, data
))
1375 show
&= ~NV_PGRAPH_INTR_NOTIFY
;
1379 if (stat
& NV_PGRAPH_INTR_CONTEXT_SWITCH
) {
1380 nvkm_wr32(device
, NV03_PGRAPH_INTR
, NV_PGRAPH_INTR_CONTEXT_SWITCH
);
1381 stat
&= ~NV_PGRAPH_INTR_CONTEXT_SWITCH
;
1382 show
&= ~NV_PGRAPH_INTR_CONTEXT_SWITCH
;
1383 nv04_gr_context_switch(gr
);
1386 nvkm_wr32(device
, NV03_PGRAPH_INTR
, stat
);
1387 nvkm_wr32(device
, NV04_PGRAPH_FIFO
, 0x00000001);
1390 nvkm_snprintbf(msg
, sizeof(msg
), nv04_gr_intr_name
, show
);
1391 nvkm_snprintbf(src
, sizeof(src
), nv04_gr_nsource
, nsource
);
1392 nvkm_snprintbf(sta
, sizeof(sta
), nv04_gr_nstatus
, nstatus
);
1393 nvkm_error(subdev
, "intr %08x [%s] nsource %08x [%s] "
1394 "nstatus %08x [%s] ch %d [%s] subc %d "
1395 "class %04x mthd %04x data %08x\n",
1396 show
, msg
, nsource
, src
, nstatus
, sta
, chid
,
1397 nvkm_client_name(chan
), subc
, class, mthd
, data
);
1400 spin_unlock_irqrestore(&gr
->lock
, flags
);
1404 nv04_gr_ctor(struct nvkm_object
*parent
, struct nvkm_object
*engine
,
1405 struct nvkm_oclass
*oclass
, void *data
, u32 size
,
1406 struct nvkm_object
**pobject
)
1411 ret
= nvkm_gr_create(parent
, engine
, oclass
, true, &gr
);
1412 *pobject
= nv_object(gr
);
1416 nv_subdev(gr
)->unit
= 0x00001000;
1417 nv_subdev(gr
)->intr
= nv04_gr_intr
;
1418 nv_engine(gr
)->cclass
= &nv04_gr_cclass
;
1419 nv_engine(gr
)->sclass
= nv04_gr_sclass
;
1420 spin_lock_init(&gr
->lock
);
1425 nv04_gr_init(struct nvkm_object
*object
)
1427 struct nvkm_engine
*engine
= nv_engine(object
);
1428 struct nv04_gr
*gr
= (void *)engine
;
1429 struct nvkm_device
*device
= gr
->base
.engine
.subdev
.device
;
1432 ret
= nvkm_gr_init(&gr
->base
);
1436 /* Enable PGRAPH interrupts */
1437 nvkm_wr32(device
, NV03_PGRAPH_INTR
, 0xFFFFFFFF);
1438 nvkm_wr32(device
, NV03_PGRAPH_INTR_EN
, 0xFFFFFFFF);
1440 nvkm_wr32(device
, NV04_PGRAPH_VALID1
, 0);
1441 nvkm_wr32(device
, NV04_PGRAPH_VALID2
, 0);
1442 /*nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0x000001FF);
1443 nvkm_wr32(device, NV04_PGRAPH_DEBUG_0, 0x001FFFFF);*/
1444 nvkm_wr32(device
, NV04_PGRAPH_DEBUG_0
, 0x1231c000);
1445 /*1231C000 blob, 001 haiku*/
1446 /*V_WRITE(NV04_PGRAPH_DEBUG_1, 0xf2d91100);*/
1447 nvkm_wr32(device
, NV04_PGRAPH_DEBUG_1
, 0x72111100);
1448 /*0x72111100 blob , 01 haiku*/
1449 /*nvkm_wr32(device, NV04_PGRAPH_DEBUG_2, 0x11d5f870);*/
1450 nvkm_wr32(device
, NV04_PGRAPH_DEBUG_2
, 0x11d5f071);
1453 /*nvkm_wr32(device, NV04_PGRAPH_DEBUG_3, 0xfad4ff31);*/
1454 nvkm_wr32(device
, NV04_PGRAPH_DEBUG_3
, 0xf0d4ff31);
1455 /*haiku and blob 10d4*/
1457 nvkm_wr32(device
, NV04_PGRAPH_STATE
, 0xFFFFFFFF);
1458 nvkm_wr32(device
, NV04_PGRAPH_CTX_CONTROL
, 0x10000100);
1459 nvkm_mask(device
, NV04_PGRAPH_CTX_USER
, 0xff000000, 0x0f000000);
1461 /* These don't belong here, they're part of a per-channel context */
1462 nvkm_wr32(device
, NV04_PGRAPH_PATTERN_SHAPE
, 0x00000000);
1463 nvkm_wr32(device
, NV04_PGRAPH_BETA_AND
, 0xFFFFFFFF);
1469 .handle
= NV_ENGINE(GR
, 0x04),
1470 .ofuncs
= &(struct nvkm_ofuncs
) {
1471 .ctor
= nv04_gr_ctor
,
1472 .dtor
= _nvkm_gr_dtor
,
1473 .init
= nv04_gr_init
,
1474 .fini
= _nvkm_gr_fini
,