2 * Copyright 2007 Matthieu CASTET <castet.matthieu@free.fr>
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 <core/device.h>
29 #include <core/handle.h>
30 #include <engine/fifo.h>
31 #include <subdev/fb.h>
34 u32 pipe_0x0000[0x040/4];
35 u32 pipe_0x0040[0x010/4];
36 u32 pipe_0x0200[0x0c0/4];
37 u32 pipe_0x4400[0x080/4];
38 u32 pipe_0x6400[0x3b0/4];
39 u32 pipe_0x6800[0x2f0/4];
40 u32 pipe_0x6c00[0x030/4];
41 u32 pipe_0x7000[0x130/4];
42 u32 pipe_0x7400[0x0c0/4];
43 u32 pipe_0x7800[0x0c0/4];
46 static int nv10_gr_ctx_regs[] = {
47 NV10_PGRAPH_CTX_SWITCH(0),
48 NV10_PGRAPH_CTX_SWITCH(1),
49 NV10_PGRAPH_CTX_SWITCH(2),
50 NV10_PGRAPH_CTX_SWITCH(3),
51 NV10_PGRAPH_CTX_SWITCH(4),
52 NV10_PGRAPH_CTX_CACHE(0, 0),
53 NV10_PGRAPH_CTX_CACHE(0, 1),
54 NV10_PGRAPH_CTX_CACHE(0, 2),
55 NV10_PGRAPH_CTX_CACHE(0, 3),
56 NV10_PGRAPH_CTX_CACHE(0, 4),
57 NV10_PGRAPH_CTX_CACHE(1, 0),
58 NV10_PGRAPH_CTX_CACHE(1, 1),
59 NV10_PGRAPH_CTX_CACHE(1, 2),
60 NV10_PGRAPH_CTX_CACHE(1, 3),
61 NV10_PGRAPH_CTX_CACHE(1, 4),
62 NV10_PGRAPH_CTX_CACHE(2, 0),
63 NV10_PGRAPH_CTX_CACHE(2, 1),
64 NV10_PGRAPH_CTX_CACHE(2, 2),
65 NV10_PGRAPH_CTX_CACHE(2, 3),
66 NV10_PGRAPH_CTX_CACHE(2, 4),
67 NV10_PGRAPH_CTX_CACHE(3, 0),
68 NV10_PGRAPH_CTX_CACHE(3, 1),
69 NV10_PGRAPH_CTX_CACHE(3, 2),
70 NV10_PGRAPH_CTX_CACHE(3, 3),
71 NV10_PGRAPH_CTX_CACHE(3, 4),
72 NV10_PGRAPH_CTX_CACHE(4, 0),
73 NV10_PGRAPH_CTX_CACHE(4, 1),
74 NV10_PGRAPH_CTX_CACHE(4, 2),
75 NV10_PGRAPH_CTX_CACHE(4, 3),
76 NV10_PGRAPH_CTX_CACHE(4, 4),
77 NV10_PGRAPH_CTX_CACHE(5, 0),
78 NV10_PGRAPH_CTX_CACHE(5, 1),
79 NV10_PGRAPH_CTX_CACHE(5, 2),
80 NV10_PGRAPH_CTX_CACHE(5, 3),
81 NV10_PGRAPH_CTX_CACHE(5, 4),
82 NV10_PGRAPH_CTX_CACHE(6, 0),
83 NV10_PGRAPH_CTX_CACHE(6, 1),
84 NV10_PGRAPH_CTX_CACHE(6, 2),
85 NV10_PGRAPH_CTX_CACHE(6, 3),
86 NV10_PGRAPH_CTX_CACHE(6, 4),
87 NV10_PGRAPH_CTX_CACHE(7, 0),
88 NV10_PGRAPH_CTX_CACHE(7, 1),
89 NV10_PGRAPH_CTX_CACHE(7, 2),
90 NV10_PGRAPH_CTX_CACHE(7, 3),
91 NV10_PGRAPH_CTX_CACHE(7, 4),
93 NV04_PGRAPH_DMA_START_0,
94 NV04_PGRAPH_DMA_START_1,
95 NV04_PGRAPH_DMA_LENGTH,
97 NV10_PGRAPH_DMA_PITCH,
101 NV04_PGRAPH_BOFFSET1,
104 NV04_PGRAPH_BOFFSET2,
107 NV04_PGRAPH_BOFFSET3,
110 NV04_PGRAPH_BOFFSET4,
113 NV04_PGRAPH_BOFFSET5,
123 NV04_PGRAPH_BSWIZZLE2,
124 NV04_PGRAPH_BSWIZZLE5,
127 NV04_PGRAPH_PATT_COLOR0,
128 NV04_PGRAPH_PATT_COLOR1,
129 NV04_PGRAPH_PATT_COLORRAM, /* 64 values from 0x400900 to 0x4009fc */
193 NV04_PGRAPH_PATTERN, /* 2 values from 0x400808 to 0x40080c */
195 NV04_PGRAPH_PATTERN_SHAPE,
196 NV03_PGRAPH_MONO_COLOR0,
199 NV04_PGRAPH_BETA_AND,
200 NV04_PGRAPH_BETA_PREMULT,
216 NV10_PGRAPH_WINDOWCLIP_HORIZONTAL, /* 8 values from 0x400f00-0x400f1c */
217 NV10_PGRAPH_WINDOWCLIP_VERTICAL, /* 8 values from 0x400f20-0x400f3c */
234 NV10_PGRAPH_GLOBALSTATE0,
235 NV10_PGRAPH_GLOBALSTATE1,
236 NV04_PGRAPH_STORED_FMT,
237 NV04_PGRAPH_SOURCE_COLOR,
238 NV03_PGRAPH_ABS_X_RAM, /* 32 values from 0x400400 to 0x40047c */
239 NV03_PGRAPH_ABS_Y_RAM, /* 32 values from 0x400480 to 0x4004fc */
302 NV03_PGRAPH_ABS_UCLIP_XMIN,
303 NV03_PGRAPH_ABS_UCLIP_XMAX,
304 NV03_PGRAPH_ABS_UCLIP_YMIN,
305 NV03_PGRAPH_ABS_UCLIP_YMAX,
310 NV03_PGRAPH_ABS_UCLIPA_XMIN,
311 NV03_PGRAPH_ABS_UCLIPA_XMAX,
312 NV03_PGRAPH_ABS_UCLIPA_YMIN,
313 NV03_PGRAPH_ABS_UCLIPA_YMAX,
314 NV03_PGRAPH_ABS_ICLIP_XMAX,
315 NV03_PGRAPH_ABS_ICLIP_YMAX,
316 NV03_PGRAPH_XY_LOGIC_MISC0,
317 NV03_PGRAPH_XY_LOGIC_MISC1,
318 NV03_PGRAPH_XY_LOGIC_MISC2,
319 NV03_PGRAPH_XY_LOGIC_MISC3,
324 NV10_PGRAPH_COMBINER0_IN_ALPHA,
325 NV10_PGRAPH_COMBINER1_IN_ALPHA,
326 NV10_PGRAPH_COMBINER0_IN_RGB,
327 NV10_PGRAPH_COMBINER1_IN_RGB,
328 NV10_PGRAPH_COMBINER_COLOR0,
329 NV10_PGRAPH_COMBINER_COLOR1,
330 NV10_PGRAPH_COMBINER0_OUT_ALPHA,
331 NV10_PGRAPH_COMBINER1_OUT_ALPHA,
332 NV10_PGRAPH_COMBINER0_OUT_RGB,
333 NV10_PGRAPH_COMBINER1_OUT_RGB,
334 NV10_PGRAPH_COMBINER_FINAL0,
335 NV10_PGRAPH_COMBINER_FINAL1,
352 NV04_PGRAPH_PASSTHRU_0,
353 NV04_PGRAPH_PASSTHRU_1,
354 NV04_PGRAPH_PASSTHRU_2,
355 NV10_PGRAPH_DIMX_TEXTURE,
356 NV10_PGRAPH_WDIMX_TEXTURE,
357 NV10_PGRAPH_DVD_COLORFMT,
358 NV10_PGRAPH_SCALED_FORMAT,
359 NV04_PGRAPH_MISC24_0,
360 NV04_PGRAPH_MISC24_1,
361 NV04_PGRAPH_MISC24_2,
368 static int nv17_gr_ctx_regs[] = {
389 struct nv10_gr_priv {
391 struct nv10_gr_chan *chan[32];
395 struct nv10_gr_chan {
396 struct nvkm_object base;
398 int nv10[ARRAY_SIZE(nv10_gr_ctx_regs)];
399 int nv17[ARRAY_SIZE(nv17_gr_ctx_regs)];
400 struct pipe_state pipe_state;
405 static inline struct nv10_gr_priv *
406 nv10_gr_priv(struct nv10_gr_chan *chan)
408 return (void *)nv_object(chan)->engine;
411 /*******************************************************************************
412 * Graphics object classes
413 ******************************************************************************/
415 #define PIPE_SAVE(priv, state, addr) \
418 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, addr); \
419 for (__i = 0; __i < ARRAY_SIZE(state); __i++) \
420 state[__i] = nv_rd32(priv, NV10_PGRAPH_PIPE_DATA); \
423 #define PIPE_RESTORE(priv, state, addr) \
426 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, addr); \
427 for (__i = 0; __i < ARRAY_SIZE(state); __i++) \
428 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, state[__i]); \
431 static struct nvkm_oclass
433 { 0x0012, &nv04_gr_ofuncs }, /* beta1 */
434 { 0x0019, &nv04_gr_ofuncs }, /* clip */
435 { 0x0030, &nv04_gr_ofuncs }, /* null */
436 { 0x0039, &nv04_gr_ofuncs }, /* m2mf */
437 { 0x0043, &nv04_gr_ofuncs }, /* rop */
438 { 0x0044, &nv04_gr_ofuncs }, /* pattern */
439 { 0x004a, &nv04_gr_ofuncs }, /* gdi */
440 { 0x0052, &nv04_gr_ofuncs }, /* swzsurf */
441 { 0x005f, &nv04_gr_ofuncs }, /* blit */
442 { 0x0062, &nv04_gr_ofuncs }, /* surf2d */
443 { 0x0072, &nv04_gr_ofuncs }, /* beta4 */
444 { 0x0089, &nv04_gr_ofuncs }, /* sifm */
445 { 0x008a, &nv04_gr_ofuncs }, /* ifc */
446 { 0x009f, &nv04_gr_ofuncs }, /* blit */
447 { 0x0093, &nv04_gr_ofuncs }, /* surf3d */
448 { 0x0094, &nv04_gr_ofuncs }, /* ttri */
449 { 0x0095, &nv04_gr_ofuncs }, /* mtri */
450 { 0x0056, &nv04_gr_ofuncs }, /* celcius */
454 static struct nvkm_oclass
456 { 0x0012, &nv04_gr_ofuncs }, /* beta1 */
457 { 0x0019, &nv04_gr_ofuncs }, /* clip */
458 { 0x0030, &nv04_gr_ofuncs }, /* null */
459 { 0x0039, &nv04_gr_ofuncs }, /* m2mf */
460 { 0x0043, &nv04_gr_ofuncs }, /* rop */
461 { 0x0044, &nv04_gr_ofuncs }, /* pattern */
462 { 0x004a, &nv04_gr_ofuncs }, /* gdi */
463 { 0x0052, &nv04_gr_ofuncs }, /* swzsurf */
464 { 0x005f, &nv04_gr_ofuncs }, /* blit */
465 { 0x0062, &nv04_gr_ofuncs }, /* surf2d */
466 { 0x0072, &nv04_gr_ofuncs }, /* beta4 */
467 { 0x0089, &nv04_gr_ofuncs }, /* sifm */
468 { 0x008a, &nv04_gr_ofuncs }, /* ifc */
469 { 0x009f, &nv04_gr_ofuncs }, /* blit */
470 { 0x0093, &nv04_gr_ofuncs }, /* surf3d */
471 { 0x0094, &nv04_gr_ofuncs }, /* ttri */
472 { 0x0095, &nv04_gr_ofuncs }, /* mtri */
473 { 0x0096, &nv04_gr_ofuncs }, /* celcius */
478 nv17_gr_mthd_lma_window(struct nvkm_object *object, u32 mthd,
479 void *args, u32 size)
481 struct nv10_gr_chan *chan = (void *)object->parent;
482 struct nv10_gr_priv *priv = nv10_gr_priv(chan);
483 struct pipe_state *pipe = &chan->pipe_state;
484 u32 pipe_0x0040[1], pipe_0x64c0[8], pipe_0x6a80[3], pipe_0x6ab0[3];
485 u32 xfmode0, xfmode1;
486 u32 data = *(u32 *)args;
489 chan->lma_window[(mthd - 0x1638) / 4] = data;
496 PIPE_SAVE(priv, pipe_0x0040, 0x0040);
497 PIPE_SAVE(priv, pipe->pipe_0x0200, 0x0200);
499 PIPE_RESTORE(priv, chan->lma_window, 0x6790);
503 xfmode0 = nv_rd32(priv, NV10_PGRAPH_XFMODE0);
504 xfmode1 = nv_rd32(priv, NV10_PGRAPH_XFMODE1);
506 PIPE_SAVE(priv, pipe->pipe_0x4400, 0x4400);
507 PIPE_SAVE(priv, pipe_0x64c0, 0x64c0);
508 PIPE_SAVE(priv, pipe_0x6ab0, 0x6ab0);
509 PIPE_SAVE(priv, pipe_0x6a80, 0x6a80);
513 nv_wr32(priv, NV10_PGRAPH_XFMODE0, 0x10000000);
514 nv_wr32(priv, NV10_PGRAPH_XFMODE1, 0x00000000);
515 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, 0x000064c0);
516 for (i = 0; i < 4; i++)
517 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x3f800000);
518 for (i = 0; i < 4; i++)
519 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x00000000);
521 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, 0x00006ab0);
522 for (i = 0; i < 3; i++)
523 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x3f800000);
525 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, 0x00006a80);
526 for (i = 0; i < 3; i++)
527 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x00000000);
529 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, 0x00000040);
530 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x00000008);
532 PIPE_RESTORE(priv, pipe->pipe_0x0200, 0x0200);
536 PIPE_RESTORE(priv, pipe_0x0040, 0x0040);
538 nv_wr32(priv, NV10_PGRAPH_XFMODE0, xfmode0);
539 nv_wr32(priv, NV10_PGRAPH_XFMODE1, xfmode1);
541 PIPE_RESTORE(priv, pipe_0x64c0, 0x64c0);
542 PIPE_RESTORE(priv, pipe_0x6ab0, 0x6ab0);
543 PIPE_RESTORE(priv, pipe_0x6a80, 0x6a80);
544 PIPE_RESTORE(priv, pipe->pipe_0x4400, 0x4400);
546 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, 0x000000c0);
547 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x00000000);
555 nv17_gr_mthd_lma_enable(struct nvkm_object *object, u32 mthd,
556 void *args, u32 size)
558 struct nv10_gr_chan *chan = (void *)object->parent;
559 struct nv10_gr_priv *priv = nv10_gr_priv(chan);
563 nv_mask(priv, NV10_PGRAPH_DEBUG_4, 0x00000100, 0x00000100);
564 nv_mask(priv, 0x4006b0, 0x08000000, 0x08000000);
568 static struct nvkm_omthds
569 nv17_celcius_omthds[] = {
570 { 0x1638, 0x1638, nv17_gr_mthd_lma_window },
571 { 0x163c, 0x163c, nv17_gr_mthd_lma_window },
572 { 0x1640, 0x1640, nv17_gr_mthd_lma_window },
573 { 0x1644, 0x1644, nv17_gr_mthd_lma_window },
574 { 0x1658, 0x1658, nv17_gr_mthd_lma_enable },
578 static struct nvkm_oclass
580 { 0x0012, &nv04_gr_ofuncs }, /* beta1 */
581 { 0x0019, &nv04_gr_ofuncs }, /* clip */
582 { 0x0030, &nv04_gr_ofuncs }, /* null */
583 { 0x0039, &nv04_gr_ofuncs }, /* m2mf */
584 { 0x0043, &nv04_gr_ofuncs }, /* rop */
585 { 0x0044, &nv04_gr_ofuncs }, /* pattern */
586 { 0x004a, &nv04_gr_ofuncs }, /* gdi */
587 { 0x0052, &nv04_gr_ofuncs }, /* swzsurf */
588 { 0x005f, &nv04_gr_ofuncs }, /* blit */
589 { 0x0062, &nv04_gr_ofuncs }, /* surf2d */
590 { 0x0072, &nv04_gr_ofuncs }, /* beta4 */
591 { 0x0089, &nv04_gr_ofuncs }, /* sifm */
592 { 0x008a, &nv04_gr_ofuncs }, /* ifc */
593 { 0x009f, &nv04_gr_ofuncs }, /* blit */
594 { 0x0093, &nv04_gr_ofuncs }, /* surf3d */
595 { 0x0094, &nv04_gr_ofuncs }, /* ttri */
596 { 0x0095, &nv04_gr_ofuncs }, /* mtri */
597 { 0x0099, &nv04_gr_ofuncs, nv17_celcius_omthds },
601 /*******************************************************************************
603 ******************************************************************************/
605 static struct nv10_gr_chan *
606 nv10_gr_channel(struct nv10_gr_priv *priv)
608 struct nv10_gr_chan *chan = NULL;
609 if (nv_rd32(priv, 0x400144) & 0x00010000) {
610 int chid = nv_rd32(priv, 0x400148) >> 24;
611 if (chid < ARRAY_SIZE(priv->chan))
612 chan = priv->chan[chid];
618 nv10_gr_save_pipe(struct nv10_gr_chan *chan)
620 struct nv10_gr_priv *priv = nv10_gr_priv(chan);
621 struct pipe_state *pipe = &chan->pipe_state;
623 PIPE_SAVE(priv, pipe->pipe_0x4400, 0x4400);
624 PIPE_SAVE(priv, pipe->pipe_0x0200, 0x0200);
625 PIPE_SAVE(priv, pipe->pipe_0x6400, 0x6400);
626 PIPE_SAVE(priv, pipe->pipe_0x6800, 0x6800);
627 PIPE_SAVE(priv, pipe->pipe_0x6c00, 0x6c00);
628 PIPE_SAVE(priv, pipe->pipe_0x7000, 0x7000);
629 PIPE_SAVE(priv, pipe->pipe_0x7400, 0x7400);
630 PIPE_SAVE(priv, pipe->pipe_0x7800, 0x7800);
631 PIPE_SAVE(priv, pipe->pipe_0x0040, 0x0040);
632 PIPE_SAVE(priv, pipe->pipe_0x0000, 0x0000);
636 nv10_gr_load_pipe(struct nv10_gr_chan *chan)
638 struct nv10_gr_priv *priv = nv10_gr_priv(chan);
639 struct pipe_state *pipe = &chan->pipe_state;
640 u32 xfmode0, xfmode1;
644 /* XXX check haiku comments */
645 xfmode0 = nv_rd32(priv, NV10_PGRAPH_XFMODE0);
646 xfmode1 = nv_rd32(priv, NV10_PGRAPH_XFMODE1);
647 nv_wr32(priv, NV10_PGRAPH_XFMODE0, 0x10000000);
648 nv_wr32(priv, NV10_PGRAPH_XFMODE1, 0x00000000);
649 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, 0x000064c0);
650 for (i = 0; i < 4; i++)
651 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x3f800000);
652 for (i = 0; i < 4; i++)
653 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x00000000);
655 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, 0x00006ab0);
656 for (i = 0; i < 3; i++)
657 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x3f800000);
659 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, 0x00006a80);
660 for (i = 0; i < 3; i++)
661 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x00000000);
663 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, 0x00000040);
664 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, 0x00000008);
667 PIPE_RESTORE(priv, pipe->pipe_0x0200, 0x0200);
671 nv_wr32(priv, NV10_PGRAPH_XFMODE0, xfmode0);
672 nv_wr32(priv, NV10_PGRAPH_XFMODE1, xfmode1);
673 PIPE_RESTORE(priv, pipe->pipe_0x6400, 0x6400);
674 PIPE_RESTORE(priv, pipe->pipe_0x6800, 0x6800);
675 PIPE_RESTORE(priv, pipe->pipe_0x6c00, 0x6c00);
676 PIPE_RESTORE(priv, pipe->pipe_0x7000, 0x7000);
677 PIPE_RESTORE(priv, pipe->pipe_0x7400, 0x7400);
678 PIPE_RESTORE(priv, pipe->pipe_0x7800, 0x7800);
679 PIPE_RESTORE(priv, pipe->pipe_0x4400, 0x4400);
680 PIPE_RESTORE(priv, pipe->pipe_0x0000, 0x0000);
681 PIPE_RESTORE(priv, pipe->pipe_0x0040, 0x0040);
686 nv10_gr_create_pipe(struct nv10_gr_chan *chan)
688 struct nv10_gr_priv *priv = nv10_gr_priv(chan);
689 struct pipe_state *pipe_state = &chan->pipe_state;
690 u32 *pipe_state_addr;
692 #define PIPE_INIT(addr) \
694 pipe_state_addr = pipe_state->pipe_##addr; \
696 #define PIPE_INIT_END(addr) \
698 u32 *__end_addr = pipe_state->pipe_##addr + \
699 ARRAY_SIZE(pipe_state->pipe_##addr); \
700 if (pipe_state_addr != __end_addr) \
701 nv_error(priv, "incomplete pipe init for 0x%x : %p/%p\n", \
702 addr, pipe_state_addr, __end_addr); \
704 #define NV_WRITE_PIPE_INIT(value) *(pipe_state_addr++) = value
707 for (i = 0; i < 48; i++)
708 NV_WRITE_PIPE_INIT(0x00000000);
709 PIPE_INIT_END(0x0200);
712 for (i = 0; i < 211; i++)
713 NV_WRITE_PIPE_INIT(0x00000000);
714 NV_WRITE_PIPE_INIT(0x3f800000);
715 NV_WRITE_PIPE_INIT(0x40000000);
716 NV_WRITE_PIPE_INIT(0x40000000);
717 NV_WRITE_PIPE_INIT(0x40000000);
718 NV_WRITE_PIPE_INIT(0x40000000);
719 NV_WRITE_PIPE_INIT(0x00000000);
720 NV_WRITE_PIPE_INIT(0x00000000);
721 NV_WRITE_PIPE_INIT(0x3f800000);
722 NV_WRITE_PIPE_INIT(0x00000000);
723 NV_WRITE_PIPE_INIT(0x3f000000);
724 NV_WRITE_PIPE_INIT(0x3f000000);
725 NV_WRITE_PIPE_INIT(0x00000000);
726 NV_WRITE_PIPE_INIT(0x00000000);
727 NV_WRITE_PIPE_INIT(0x00000000);
728 NV_WRITE_PIPE_INIT(0x00000000);
729 NV_WRITE_PIPE_INIT(0x3f800000);
730 NV_WRITE_PIPE_INIT(0x00000000);
731 NV_WRITE_PIPE_INIT(0x00000000);
732 NV_WRITE_PIPE_INIT(0x00000000);
733 NV_WRITE_PIPE_INIT(0x00000000);
734 NV_WRITE_PIPE_INIT(0x00000000);
735 NV_WRITE_PIPE_INIT(0x3f800000);
736 NV_WRITE_PIPE_INIT(0x3f800000);
737 NV_WRITE_PIPE_INIT(0x3f800000);
738 NV_WRITE_PIPE_INIT(0x3f800000);
739 PIPE_INIT_END(0x6400);
742 for (i = 0; i < 162; i++)
743 NV_WRITE_PIPE_INIT(0x00000000);
744 NV_WRITE_PIPE_INIT(0x3f800000);
745 for (i = 0; i < 25; i++)
746 NV_WRITE_PIPE_INIT(0x00000000);
747 PIPE_INIT_END(0x6800);
750 NV_WRITE_PIPE_INIT(0x00000000);
751 NV_WRITE_PIPE_INIT(0x00000000);
752 NV_WRITE_PIPE_INIT(0x00000000);
753 NV_WRITE_PIPE_INIT(0x00000000);
754 NV_WRITE_PIPE_INIT(0xbf800000);
755 NV_WRITE_PIPE_INIT(0x00000000);
756 NV_WRITE_PIPE_INIT(0x00000000);
757 NV_WRITE_PIPE_INIT(0x00000000);
758 NV_WRITE_PIPE_INIT(0x00000000);
759 NV_WRITE_PIPE_INIT(0x00000000);
760 NV_WRITE_PIPE_INIT(0x00000000);
761 NV_WRITE_PIPE_INIT(0x00000000);
762 PIPE_INIT_END(0x6c00);
765 NV_WRITE_PIPE_INIT(0x00000000);
766 NV_WRITE_PIPE_INIT(0x00000000);
767 NV_WRITE_PIPE_INIT(0x00000000);
768 NV_WRITE_PIPE_INIT(0x00000000);
769 NV_WRITE_PIPE_INIT(0x00000000);
770 NV_WRITE_PIPE_INIT(0x00000000);
771 NV_WRITE_PIPE_INIT(0x00000000);
772 NV_WRITE_PIPE_INIT(0x00000000);
773 NV_WRITE_PIPE_INIT(0x00000000);
774 NV_WRITE_PIPE_INIT(0x00000000);
775 NV_WRITE_PIPE_INIT(0x00000000);
776 NV_WRITE_PIPE_INIT(0x00000000);
777 NV_WRITE_PIPE_INIT(0x7149f2ca);
778 NV_WRITE_PIPE_INIT(0x00000000);
779 NV_WRITE_PIPE_INIT(0x00000000);
780 NV_WRITE_PIPE_INIT(0x00000000);
781 NV_WRITE_PIPE_INIT(0x7149f2ca);
782 NV_WRITE_PIPE_INIT(0x00000000);
783 NV_WRITE_PIPE_INIT(0x00000000);
784 NV_WRITE_PIPE_INIT(0x00000000);
785 NV_WRITE_PIPE_INIT(0x7149f2ca);
786 NV_WRITE_PIPE_INIT(0x00000000);
787 NV_WRITE_PIPE_INIT(0x00000000);
788 NV_WRITE_PIPE_INIT(0x00000000);
789 NV_WRITE_PIPE_INIT(0x7149f2ca);
790 NV_WRITE_PIPE_INIT(0x00000000);
791 NV_WRITE_PIPE_INIT(0x00000000);
792 NV_WRITE_PIPE_INIT(0x00000000);
793 NV_WRITE_PIPE_INIT(0x7149f2ca);
794 NV_WRITE_PIPE_INIT(0x00000000);
795 NV_WRITE_PIPE_INIT(0x00000000);
796 NV_WRITE_PIPE_INIT(0x00000000);
797 NV_WRITE_PIPE_INIT(0x7149f2ca);
798 NV_WRITE_PIPE_INIT(0x00000000);
799 NV_WRITE_PIPE_INIT(0x00000000);
800 NV_WRITE_PIPE_INIT(0x00000000);
801 NV_WRITE_PIPE_INIT(0x7149f2ca);
802 NV_WRITE_PIPE_INIT(0x00000000);
803 NV_WRITE_PIPE_INIT(0x00000000);
804 NV_WRITE_PIPE_INIT(0x00000000);
805 NV_WRITE_PIPE_INIT(0x7149f2ca);
806 for (i = 0; i < 35; i++)
807 NV_WRITE_PIPE_INIT(0x00000000);
808 PIPE_INIT_END(0x7000);
811 for (i = 0; i < 48; i++)
812 NV_WRITE_PIPE_INIT(0x00000000);
813 PIPE_INIT_END(0x7400);
816 for (i = 0; i < 48; i++)
817 NV_WRITE_PIPE_INIT(0x00000000);
818 PIPE_INIT_END(0x7800);
821 for (i = 0; i < 32; i++)
822 NV_WRITE_PIPE_INIT(0x00000000);
823 PIPE_INIT_END(0x4400);
826 for (i = 0; i < 16; i++)
827 NV_WRITE_PIPE_INIT(0x00000000);
828 PIPE_INIT_END(0x0000);
831 for (i = 0; i < 4; i++)
832 NV_WRITE_PIPE_INIT(0x00000000);
833 PIPE_INIT_END(0x0040);
837 #undef NV_WRITE_PIPE_INIT
841 nv10_gr_ctx_regs_find_offset(struct nv10_gr_priv *priv, int reg)
844 for (i = 0; i < ARRAY_SIZE(nv10_gr_ctx_regs); i++) {
845 if (nv10_gr_ctx_regs[i] == reg)
848 nv_error(priv, "unknow offset nv10_ctx_regs %d\n", reg);
853 nv17_gr_ctx_regs_find_offset(struct nv10_gr_priv *priv, int reg)
856 for (i = 0; i < ARRAY_SIZE(nv17_gr_ctx_regs); i++) {
857 if (nv17_gr_ctx_regs[i] == reg)
860 nv_error(priv, "unknow offset nv17_ctx_regs %d\n", reg);
865 nv10_gr_load_dma_vtxbuf(struct nv10_gr_chan *chan, int chid, u32 inst)
867 struct nv10_gr_priv *priv = nv10_gr_priv(chan);
868 u32 st2, st2_dl, st2_dh, fifo_ptr, fifo[0x60/4];
869 u32 ctx_user, ctx_switch[5];
872 /* NV10TCL_DMA_VTXBUF (method 0x18c) modifies hidden state
873 * that cannot be restored via MMIO. Do it through the FIFO
877 /* Look for a celsius object */
878 for (i = 0; i < 8; i++) {
879 int class = nv_rd32(priv, NV10_PGRAPH_CTX_CACHE(i, 0)) & 0xfff;
881 if (class == 0x56 || class == 0x96 || class == 0x99) {
887 if (subchan < 0 || !inst)
890 /* Save the current ctx object */
891 ctx_user = nv_rd32(priv, NV10_PGRAPH_CTX_USER);
892 for (i = 0; i < 5; i++)
893 ctx_switch[i] = nv_rd32(priv, NV10_PGRAPH_CTX_SWITCH(i));
895 /* Save the FIFO state */
896 st2 = nv_rd32(priv, NV10_PGRAPH_FFINTFC_ST2);
897 st2_dl = nv_rd32(priv, NV10_PGRAPH_FFINTFC_ST2_DL);
898 st2_dh = nv_rd32(priv, NV10_PGRAPH_FFINTFC_ST2_DH);
899 fifo_ptr = nv_rd32(priv, NV10_PGRAPH_FFINTFC_FIFO_PTR);
901 for (i = 0; i < ARRAY_SIZE(fifo); i++)
902 fifo[i] = nv_rd32(priv, 0x4007a0 + 4 * i);
904 /* Switch to the celsius subchannel */
905 for (i = 0; i < 5; i++)
906 nv_wr32(priv, NV10_PGRAPH_CTX_SWITCH(i),
907 nv_rd32(priv, NV10_PGRAPH_CTX_CACHE(subchan, i)));
908 nv_mask(priv, NV10_PGRAPH_CTX_USER, 0xe000, subchan << 13);
910 /* Inject NV10TCL_DMA_VTXBUF */
911 nv_wr32(priv, NV10_PGRAPH_FFINTFC_FIFO_PTR, 0);
912 nv_wr32(priv, NV10_PGRAPH_FFINTFC_ST2,
913 0x2c000000 | chid << 20 | subchan << 16 | 0x18c);
914 nv_wr32(priv, NV10_PGRAPH_FFINTFC_ST2_DL, inst);
915 nv_mask(priv, NV10_PGRAPH_CTX_CONTROL, 0, 0x10000);
916 nv_mask(priv, NV04_PGRAPH_FIFO, 0x00000001, 0x00000001);
917 nv_mask(priv, NV04_PGRAPH_FIFO, 0x00000001, 0x00000000);
919 /* Restore the FIFO state */
920 for (i = 0; i < ARRAY_SIZE(fifo); i++)
921 nv_wr32(priv, 0x4007a0 + 4 * i, fifo[i]);
923 nv_wr32(priv, NV10_PGRAPH_FFINTFC_FIFO_PTR, fifo_ptr);
924 nv_wr32(priv, NV10_PGRAPH_FFINTFC_ST2, st2);
925 nv_wr32(priv, NV10_PGRAPH_FFINTFC_ST2_DL, st2_dl);
926 nv_wr32(priv, NV10_PGRAPH_FFINTFC_ST2_DH, st2_dh);
928 /* Restore the current ctx object */
929 for (i = 0; i < 5; i++)
930 nv_wr32(priv, NV10_PGRAPH_CTX_SWITCH(i), ctx_switch[i]);
931 nv_wr32(priv, NV10_PGRAPH_CTX_USER, ctx_user);
935 nv10_gr_load_context(struct nv10_gr_chan *chan, int chid)
937 struct nv10_gr_priv *priv = nv10_gr_priv(chan);
941 for (i = 0; i < ARRAY_SIZE(nv10_gr_ctx_regs); i++)
942 nv_wr32(priv, nv10_gr_ctx_regs[i], chan->nv10[i]);
944 if (nv_device(priv)->card_type >= NV_11 &&
945 nv_device(priv)->chipset >= 0x17) {
946 for (i = 0; i < ARRAY_SIZE(nv17_gr_ctx_regs); i++)
947 nv_wr32(priv, nv17_gr_ctx_regs[i], chan->nv17[i]);
950 nv10_gr_load_pipe(chan);
952 inst = nv_rd32(priv, NV10_PGRAPH_GLOBALSTATE1) & 0xffff;
953 nv10_gr_load_dma_vtxbuf(chan, chid, inst);
955 nv_wr32(priv, NV10_PGRAPH_CTX_CONTROL, 0x10010100);
956 nv_mask(priv, NV10_PGRAPH_CTX_USER, 0xff000000, chid << 24);
957 nv_mask(priv, NV10_PGRAPH_FFINTFC_ST2, 0x30000000, 0x00000000);
962 nv10_gr_unload_context(struct nv10_gr_chan *chan)
964 struct nv10_gr_priv *priv = nv10_gr_priv(chan);
967 for (i = 0; i < ARRAY_SIZE(nv10_gr_ctx_regs); i++)
968 chan->nv10[i] = nv_rd32(priv, nv10_gr_ctx_regs[i]);
970 if (nv_device(priv)->card_type >= NV_11 &&
971 nv_device(priv)->chipset >= 0x17) {
972 for (i = 0; i < ARRAY_SIZE(nv17_gr_ctx_regs); i++)
973 chan->nv17[i] = nv_rd32(priv, nv17_gr_ctx_regs[i]);
976 nv10_gr_save_pipe(chan);
978 nv_wr32(priv, NV10_PGRAPH_CTX_CONTROL, 0x10000000);
979 nv_mask(priv, NV10_PGRAPH_CTX_USER, 0xff000000, 0x1f000000);
984 nv10_gr_context_switch(struct nv10_gr_priv *priv)
986 struct nv10_gr_chan *prev = NULL;
987 struct nv10_gr_chan *next = NULL;
991 spin_lock_irqsave(&priv->lock, flags);
994 /* If previous context is valid, we need to save it */
995 prev = nv10_gr_channel(priv);
997 nv10_gr_unload_context(prev);
999 /* load context for next channel */
1000 chid = (nv_rd32(priv, NV04_PGRAPH_TRAPPED_ADDR) >> 20) & 0x1f;
1001 next = priv->chan[chid];
1003 nv10_gr_load_context(next, chid);
1005 spin_unlock_irqrestore(&priv->lock, flags);
1008 #define NV_WRITE_CTX(reg, val) do { \
1009 int offset = nv10_gr_ctx_regs_find_offset(priv, reg); \
1011 chan->nv10[offset] = val; \
1014 #define NV17_WRITE_CTX(reg, val) do { \
1015 int offset = nv17_gr_ctx_regs_find_offset(priv, reg); \
1017 chan->nv17[offset] = val; \
1021 nv10_gr_context_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
1022 struct nvkm_oclass *oclass, void *data, u32 size,
1023 struct nvkm_object **pobject)
1025 struct nvkm_fifo_chan *fifo = (void *)parent;
1026 struct nv10_gr_priv *priv = (void *)engine;
1027 struct nv10_gr_chan *chan;
1028 unsigned long flags;
1031 ret = nvkm_object_create(parent, engine, oclass, 0, &chan);
1032 *pobject = nv_object(chan);
1036 spin_lock_irqsave(&priv->lock, flags);
1037 if (priv->chan[fifo->chid]) {
1038 *pobject = nv_object(priv->chan[fifo->chid]);
1039 atomic_inc(&(*pobject)->refcount);
1040 spin_unlock_irqrestore(&priv->lock, flags);
1041 nvkm_object_destroy(&chan->base);
1045 NV_WRITE_CTX(0x00400e88, 0x08000000);
1046 NV_WRITE_CTX(0x00400e9c, 0x4b7fffff);
1047 NV_WRITE_CTX(NV03_PGRAPH_XY_LOGIC_MISC0, 0x0001ffff);
1048 NV_WRITE_CTX(0x00400e10, 0x00001000);
1049 NV_WRITE_CTX(0x00400e14, 0x00001000);
1050 NV_WRITE_CTX(0x00400e30, 0x00080008);
1051 NV_WRITE_CTX(0x00400e34, 0x00080008);
1052 if (nv_device(priv)->card_type >= NV_11 &&
1053 nv_device(priv)->chipset >= 0x17) {
1054 /* is it really needed ??? */
1055 NV17_WRITE_CTX(NV10_PGRAPH_DEBUG_4,
1056 nv_rd32(priv, NV10_PGRAPH_DEBUG_4));
1057 NV17_WRITE_CTX(0x004006b0, nv_rd32(priv, 0x004006b0));
1058 NV17_WRITE_CTX(0x00400eac, 0x0fff0000);
1059 NV17_WRITE_CTX(0x00400eb0, 0x0fff0000);
1060 NV17_WRITE_CTX(0x00400ec0, 0x00000080);
1061 NV17_WRITE_CTX(0x00400ed0, 0x00000080);
1063 NV_WRITE_CTX(NV10_PGRAPH_CTX_USER, chan->chid << 24);
1065 nv10_gr_create_pipe(chan);
1067 priv->chan[fifo->chid] = chan;
1068 chan->chid = fifo->chid;
1069 spin_unlock_irqrestore(&priv->lock, flags);
1074 nv10_gr_context_dtor(struct nvkm_object *object)
1076 struct nv10_gr_priv *priv = (void *)object->engine;
1077 struct nv10_gr_chan *chan = (void *)object;
1078 unsigned long flags;
1080 spin_lock_irqsave(&priv->lock, flags);
1081 priv->chan[chan->chid] = NULL;
1082 spin_unlock_irqrestore(&priv->lock, flags);
1084 nvkm_object_destroy(&chan->base);
1088 nv10_gr_context_fini(struct nvkm_object *object, bool suspend)
1090 struct nv10_gr_priv *priv = (void *)object->engine;
1091 struct nv10_gr_chan *chan = (void *)object;
1092 unsigned long flags;
1094 spin_lock_irqsave(&priv->lock, flags);
1095 nv_mask(priv, NV04_PGRAPH_FIFO, 0x00000001, 0x00000000);
1096 if (nv10_gr_channel(priv) == chan)
1097 nv10_gr_unload_context(chan);
1098 nv_mask(priv, NV04_PGRAPH_FIFO, 0x00000001, 0x00000001);
1099 spin_unlock_irqrestore(&priv->lock, flags);
1101 return nvkm_object_fini(&chan->base, suspend);
1104 static struct nvkm_oclass
1106 .handle = NV_ENGCTX(GR, 0x10),
1107 .ofuncs = &(struct nvkm_ofuncs) {
1108 .ctor = nv10_gr_context_ctor,
1109 .dtor = nv10_gr_context_dtor,
1110 .init = nvkm_object_init,
1111 .fini = nv10_gr_context_fini,
1115 /*******************************************************************************
1116 * PGRAPH engine/subdev functions
1117 ******************************************************************************/
1120 nv10_gr_tile_prog(struct nvkm_engine *engine, int i)
1122 struct nvkm_fb_tile *tile = &nvkm_fb(engine)->tile.region[i];
1123 struct nvkm_fifo *pfifo = nvkm_fifo(engine);
1124 struct nv10_gr_priv *priv = (void *)engine;
1125 unsigned long flags;
1127 pfifo->pause(pfifo, &flags);
1130 nv_wr32(priv, NV10_PGRAPH_TLIMIT(i), tile->limit);
1131 nv_wr32(priv, NV10_PGRAPH_TSIZE(i), tile->pitch);
1132 nv_wr32(priv, NV10_PGRAPH_TILE(i), tile->addr);
1134 pfifo->start(pfifo, &flags);
1137 const struct nvkm_bitfield nv10_gr_intr_name[] = {
1138 { NV_PGRAPH_INTR_NOTIFY, "NOTIFY" },
1139 { NV_PGRAPH_INTR_ERROR, "ERROR" },
1143 const struct nvkm_bitfield nv10_gr_nstatus[] = {
1144 { NV10_PGRAPH_NSTATUS_STATE_IN_USE, "STATE_IN_USE" },
1145 { NV10_PGRAPH_NSTATUS_INVALID_STATE, "INVALID_STATE" },
1146 { NV10_PGRAPH_NSTATUS_BAD_ARGUMENT, "BAD_ARGUMENT" },
1147 { NV10_PGRAPH_NSTATUS_PROTECTION_FAULT, "PROTECTION_FAULT" },
1152 nv10_gr_intr(struct nvkm_subdev *subdev)
1154 struct nv10_gr_priv *priv = (void *)subdev;
1155 struct nv10_gr_chan *chan = NULL;
1156 struct nvkm_namedb *namedb = NULL;
1157 struct nvkm_handle *handle = NULL;
1158 u32 stat = nv_rd32(priv, NV03_PGRAPH_INTR);
1159 u32 nsource = nv_rd32(priv, NV03_PGRAPH_NSOURCE);
1160 u32 nstatus = nv_rd32(priv, NV03_PGRAPH_NSTATUS);
1161 u32 addr = nv_rd32(priv, NV04_PGRAPH_TRAPPED_ADDR);
1162 u32 chid = (addr & 0x01f00000) >> 20;
1163 u32 subc = (addr & 0x00070000) >> 16;
1164 u32 mthd = (addr & 0x00001ffc);
1165 u32 data = nv_rd32(priv, NV04_PGRAPH_TRAPPED_DATA);
1166 u32 class = nv_rd32(priv, 0x400160 + subc * 4) & 0xfff;
1168 unsigned long flags;
1170 spin_lock_irqsave(&priv->lock, flags);
1171 chan = priv->chan[chid];
1173 namedb = (void *)nv_pclass(nv_object(chan), NV_NAMEDB_CLASS);
1174 spin_unlock_irqrestore(&priv->lock, flags);
1176 if (stat & NV_PGRAPH_INTR_ERROR) {
1177 if (chan && (nsource & NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD)) {
1178 handle = nvkm_namedb_get_class(namedb, class);
1179 if (handle && !nv_call(handle->object, mthd, data))
1180 show &= ~NV_PGRAPH_INTR_ERROR;
1184 if (stat & NV_PGRAPH_INTR_CONTEXT_SWITCH) {
1185 nv_wr32(priv, NV03_PGRAPH_INTR, NV_PGRAPH_INTR_CONTEXT_SWITCH);
1186 stat &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH;
1187 show &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH;
1188 nv10_gr_context_switch(priv);
1191 nv_wr32(priv, NV03_PGRAPH_INTR, stat);
1192 nv_wr32(priv, NV04_PGRAPH_FIFO, 0x00000001);
1195 nv_error(priv, "%s", "");
1196 nvkm_bitfield_print(nv10_gr_intr_name, show);
1197 pr_cont(" nsource:");
1198 nvkm_bitfield_print(nv04_gr_nsource, nsource);
1199 pr_cont(" nstatus:");
1200 nvkm_bitfield_print(nv10_gr_nstatus, nstatus);
1203 "ch %d [%s] subc %d class 0x%04x mthd 0x%04x data 0x%08x\n",
1204 chid, nvkm_client_name(chan), subc, class, mthd,
1208 nvkm_namedb_put(handle);
1212 nv10_gr_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
1213 struct nvkm_oclass *oclass, void *data, u32 size,
1214 struct nvkm_object **pobject)
1216 struct nv10_gr_priv *priv;
1219 ret = nvkm_gr_create(parent, engine, oclass, true, &priv);
1220 *pobject = nv_object(priv);
1224 nv_subdev(priv)->unit = 0x00001000;
1225 nv_subdev(priv)->intr = nv10_gr_intr;
1226 nv_engine(priv)->cclass = &nv10_gr_cclass;
1228 if (nv_device(priv)->chipset <= 0x10)
1229 nv_engine(priv)->sclass = nv10_gr_sclass;
1231 if (nv_device(priv)->chipset < 0x17 ||
1232 nv_device(priv)->card_type < NV_11)
1233 nv_engine(priv)->sclass = nv15_gr_sclass;
1235 nv_engine(priv)->sclass = nv17_gr_sclass;
1237 nv_engine(priv)->tile_prog = nv10_gr_tile_prog;
1238 spin_lock_init(&priv->lock);
1243 nv10_gr_dtor(struct nvkm_object *object)
1245 struct nv10_gr_priv *priv = (void *)object;
1246 nvkm_gr_destroy(&priv->base);
1250 nv10_gr_init(struct nvkm_object *object)
1252 struct nvkm_engine *engine = nv_engine(object);
1253 struct nvkm_fb *pfb = nvkm_fb(object);
1254 struct nv10_gr_priv *priv = (void *)engine;
1257 ret = nvkm_gr_init(&priv->base);
1261 nv_wr32(priv, NV03_PGRAPH_INTR , 0xFFFFFFFF);
1262 nv_wr32(priv, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
1264 nv_wr32(priv, NV04_PGRAPH_DEBUG_0, 0xFFFFFFFF);
1265 nv_wr32(priv, NV04_PGRAPH_DEBUG_0, 0x00000000);
1266 nv_wr32(priv, NV04_PGRAPH_DEBUG_1, 0x00118700);
1267 /* nv_wr32(priv, NV04_PGRAPH_DEBUG_2, 0x24E00810); */ /* 0x25f92ad9 */
1268 nv_wr32(priv, NV04_PGRAPH_DEBUG_2, 0x25f92ad9);
1269 nv_wr32(priv, NV04_PGRAPH_DEBUG_3, 0x55DE0830 | (1 << 29) | (1 << 31));
1271 if (nv_device(priv)->card_type >= NV_11 &&
1272 nv_device(priv)->chipset >= 0x17) {
1273 nv_wr32(priv, NV10_PGRAPH_DEBUG_4, 0x1f000000);
1274 nv_wr32(priv, 0x400a10, 0x03ff3fb6);
1275 nv_wr32(priv, 0x400838, 0x002f8684);
1276 nv_wr32(priv, 0x40083c, 0x00115f3f);
1277 nv_wr32(priv, 0x4006b0, 0x40000020);
1279 nv_wr32(priv, NV10_PGRAPH_DEBUG_4, 0x00000000);
1282 /* Turn all the tiling regions off. */
1283 for (i = 0; i < pfb->tile.regions; i++)
1284 engine->tile_prog(engine, i);
1286 nv_wr32(priv, NV10_PGRAPH_CTX_SWITCH(0), 0x00000000);
1287 nv_wr32(priv, NV10_PGRAPH_CTX_SWITCH(1), 0x00000000);
1288 nv_wr32(priv, NV10_PGRAPH_CTX_SWITCH(2), 0x00000000);
1289 nv_wr32(priv, NV10_PGRAPH_CTX_SWITCH(3), 0x00000000);
1290 nv_wr32(priv, NV10_PGRAPH_CTX_SWITCH(4), 0x00000000);
1291 nv_wr32(priv, NV10_PGRAPH_STATE, 0xFFFFFFFF);
1293 nv_mask(priv, NV10_PGRAPH_CTX_USER, 0xff000000, 0x1f000000);
1294 nv_wr32(priv, NV10_PGRAPH_CTX_CONTROL, 0x10000100);
1295 nv_wr32(priv, NV10_PGRAPH_FFINTFC_ST2, 0x08000000);
1300 nv10_gr_fini(struct nvkm_object *object, bool suspend)
1302 struct nv10_gr_priv *priv = (void *)object;
1303 return nvkm_gr_fini(&priv->base, suspend);
1308 .handle = NV_ENGINE(GR, 0x10),
1309 .ofuncs = &(struct nvkm_ofuncs) {
1310 .ctor = nv10_gr_ctor,
1311 .dtor = nv10_gr_dtor,
1312 .init = nv10_gr_init,
1313 .fini = nv10_gr_fini,