49 static int nv10_graph_ctx_regs[] = {
371 static int nv17_graph_ctx_regs[] = {
411 return (
void *)nv_object(chan)->engine;
418 #define PIPE_SAVE(priv, state, addr) \
421 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, addr); \
422 for (__i = 0; __i < ARRAY_SIZE(state); __i++) \
423 state[__i] = nv_rd32(priv, NV10_PGRAPH_PIPE_DATA); \
426 #define PIPE_RESTORE(priv, state, addr) \
429 nv_wr32(priv, NV10_PGRAPH_PIPE_ADDRESS, addr); \
430 for (__i = 0; __i < ARRAY_SIZE(state); __i++) \
431 nv_wr32(priv, NV10_PGRAPH_PIPE_DATA, state[__i]); \
435 nv10_graph_sclass[] = {
458 nv15_graph_sclass[] = {
487 u32 pipe_0x0040[1], pipe_0x64c0[8], pipe_0x6a80[3], pipe_0x6ab0[3];
488 u32 xfmode0, xfmode1;
519 for (i = 0; i < 4; i++)
521 for (i = 0; i < 4; i++)
525 for (i = 0; i < 3; i++)
529 for (i = 0; i < 3; i++)
559 void *args,
u32 size)
567 nv_mask(
priv, 0x4006b0, 0x08000000, 0x08000000);
572 nv17_celcius_omthds[] = {
573 { 0x1638, nv17_graph_mthd_lma_window },
574 { 0x163c, nv17_graph_mthd_lma_window },
575 { 0x1640, nv17_graph_mthd_lma_window },
576 { 0x1644, nv17_graph_mthd_lma_window },
577 { 0x1658, nv17_graph_mthd_lma_enable },
582 nv17_graph_sclass[] = {
612 if (nv_rd32(priv, 0x400144) & 0x00010000) {
613 int chid = nv_rd32(priv, 0x400148) >> 24;
643 u32 xfmode0, xfmode1;
653 for (i = 0; i < 4; i++)
655 for (i = 0; i < 4; i++)
659 for (i = 0; i < 3; i++)
663 for (i = 0; i < 3; i++)
693 u32 *pipe_state_addr;
695 #define PIPE_INIT(addr) \
697 pipe_state_addr = pipe_state->pipe_##addr; \
699 #define PIPE_INIT_END(addr) \
701 u32 *__end_addr = pipe_state->pipe_##addr + \
702 ARRAY_SIZE(pipe_state->pipe_##addr); \
703 if (pipe_state_addr != __end_addr) \
704 nv_error(priv, "incomplete pipe init for 0x%x : %p/%p\n", \
705 addr, pipe_state_addr, __end_addr); \
707 #define NV_WRITE_PIPE_INIT(value) *(pipe_state_addr++) = value
710 for (i = 0; i < 48; i++)
715 for (i = 0; i < 211; i++)
745 for (i = 0; i < 162; i++)
748 for (i = 0; i < 25; i++)
809 for (i = 0; i < 35; i++)
814 for (i = 0; i < 48; i++)
819 for (i = 0; i < 48; i++)
824 for (i = 0; i < 32; i++)
829 for (i = 0; i < 16; i++)
834 for (i = 0; i < 4; i++)
840 #undef NV_WRITE_PIPE_INIT
847 for (i = 0; i <
ARRAY_SIZE(nv10_graph_ctx_regs); i++) {
848 if (nv10_graph_ctx_regs[i] == reg)
851 nv_error(priv,
"unknow offset nv10_ctx_regs %d\n", reg);
859 for (i = 0; i <
ARRAY_SIZE(nv17_graph_ctx_regs); i++) {
860 if (nv17_graph_ctx_regs[i] == reg)
863 nv_error(priv,
"unknow offset nv17_ctx_regs %d\n", reg);
871 u32 st2, st2_dl, st2_dh, fifo_ptr,
fifo[0x60/4];
872 u32 ctx_user, ctx_switch[5];
881 for (i = 0; i < 8; i++) {
884 if (
class == 0x56 ||
class == 0x96 ||
class == 0x99) {
890 if (subchan < 0 || !inst)
895 for (i = 0; i < 5; i++)
905 fifo[i] = nv_rd32(priv, 0x4007a0 + 4 * i);
908 for (i = 0; i < 5; i++)
916 0x2c000000 | chid << 20 | subchan << 16 | 0x18c);
924 nv_wr32(priv, 0x4007a0 + 4 * i, fifo[i]);
932 for (i = 0; i < 5; i++)
944 for (i = 0; i <
ARRAY_SIZE(nv10_graph_ctx_regs); i++)
945 nv_wr32(priv, nv10_graph_ctx_regs[i], chan->
nv10[i]);
947 if (nv_device(priv)->chipset >= 0x17) {
948 for (i = 0; i <
ARRAY_SIZE(nv17_graph_ctx_regs); i++)
949 nv_wr32(priv, nv17_graph_ctx_regs[i], chan->
nv17[i]);
952 nv10_graph_load_pipe(chan);
955 nv10_graph_load_dma_vtxbuf(chan, chid, inst);
969 for (i = 0; i <
ARRAY_SIZE(nv10_graph_ctx_regs); i++)
970 chan->
nv10[i] = nv_rd32(priv, nv10_graph_ctx_regs[i]);
972 if (nv_device(priv)->chipset >= 0x17) {
973 for (i = 0; i <
ARRAY_SIZE(nv17_graph_ctx_regs); i++)
974 chan->
nv17[i] = nv_rd32(priv, nv17_graph_ctx_regs[i]);
977 nv10_graph_save_pipe(chan);
996 prev = nv10_graph_channel(priv);
998 nv10_graph_unload_context(prev);
1004 nv10_graph_load_context(next, chid);
1006 spin_unlock_irqrestore(&priv->
lock, flags);
1009 #define NV_WRITE_CTX(reg, val) do { \
1010 int offset = nv10_graph_ctx_regs_find_offset(priv, reg); \
1012 chan->nv10[offset] = val; \
1015 #define NV17_WRITE_CTX(reg, val) do { \
1016 int offset = nv17_graph_ctx_regs_find_offset(priv, reg); \
1018 chan->nv17[offset] = val; \
1030 unsigned long flags;
1034 *pobject = nv_object(chan);
1040 *pobject = nv_object(priv->
chan[fifo->
chid]);
1042 spin_unlock_irqrestore(&priv->
lock, flags);
1054 if (nv_device(priv)->
chipset >= 0x17) {
1066 nv10_graph_create_pipe(chan);
1070 spin_unlock_irqrestore(&priv->
lock, flags);
1079 unsigned long flags;
1083 spin_unlock_irqrestore(&priv->
lock, flags);
1093 unsigned long flags;
1097 if (nv10_graph_channel(priv) == chan)
1098 nv10_graph_unload_context(chan);
1100 spin_unlock_irqrestore(&priv->
lock, flags);
1106 nv10_graph_cclass = {
1109 .ctor = nv10_graph_context_ctor,
1110 .dtor = nv10_graph_context_dtor,
1112 .fini = nv10_graph_context_fini,
1126 unsigned long flags;
1128 pfifo->
pause(pfifo, &flags);
1135 pfifo->
start(pfifo, &flags);
1163 u32 chid = (addr & 0x01f00000) >> 20;
1164 u32 subc = (addr & 0x00070000) >> 16;
1165 u32 mthd = (addr & 0x00001ffc);
1167 u32 class = nv_rd32(priv, 0x400160 + subc * 4) & 0xfff;
1169 unsigned long flags;
1172 chan = priv->
chan[chid];
1175 spin_unlock_irqrestore(&priv->
lock, flags);
1180 if (handle && !nv_call(handle->
object, mthd, data))
1181 show &= ~NV_PGRAPH_INTR_ERROR;
1187 stat &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH;
1188 show &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH;
1189 nv10_graph_context_switch(priv);
1203 nv_error(priv,
"ch %d/%d class 0x%04x "
1204 "mthd 0x%04x data 0x%08x\n",
1205 chid, subc,
class, mthd, data);
1220 *pobject = nv_object(priv);
1224 nv_subdev(priv)->unit = 0x00001000;
1225 nv_subdev(priv)->intr = nv10_graph_intr;
1226 nv_engine(priv)->cclass = &nv10_graph_cclass;
1228 if (nv_device(priv)->
chipset <= 0x10)
1229 nv_engine(priv)->sclass = nv10_graph_sclass;
1231 if (nv_device(priv)->
chipset < 0x17 ||
1232 nv_device(priv)->
chipset == 0x1a)
1233 nv_engine(priv)->sclass = nv15_graph_sclass;
1235 nv_engine(priv)->sclass = nv17_graph_sclass;
1237 nv_engine(priv)->tile_prog = nv10_graph_tile_prog;
1271 if (nv_device(priv)->
chipset >= 0x17) {
1273 nv_wr32(priv, 0x400a10, 0x03ff3fb6);
1274 nv_wr32(priv, 0x400838, 0x002f8684);
1275 nv_wr32(priv, 0x40083c, 0x00115f3f);
1276 nv_wr32(priv, 0x4006b0, 0x40000020);
1282 for (i = 0; i < pfb->
tile.regions; i++)
1309 .ctor = nv10_graph_ctor,
1310 .dtor = nv10_graph_dtor,
1311 .init = nv10_graph_init,
1312 .fini = nv10_graph_fini,