nv04_graph.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*
  2. * Copyright 2007 Stephane Marchesin
  3. * All Rights Reserved.
  4. *
  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:
  11. *
  12. * The above copyright notice and this permission notice (including the next
  13. * paragraph) shall be included in all copies or substantial portions of the
  14. * Software.
  15. *
  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.
  23. */
  24. #include "drmP.h"
  25. #include "drm.h"
  26. #include "nouveau_drm.h"
  27. #include "nouveau_drv.h"
  28. static uint32_t nv04_graph_ctx_regs[] = {
  29. 0x0040053c,
  30. 0x00400544,
  31. 0x00400540,
  32. 0x00400548,
  33. NV04_PGRAPH_CTX_SWITCH1,
  34. NV04_PGRAPH_CTX_SWITCH2,
  35. NV04_PGRAPH_CTX_SWITCH3,
  36. NV04_PGRAPH_CTX_SWITCH4,
  37. NV04_PGRAPH_CTX_CACHE1,
  38. NV04_PGRAPH_CTX_CACHE2,
  39. NV04_PGRAPH_CTX_CACHE3,
  40. NV04_PGRAPH_CTX_CACHE4,
  41. 0x00400184,
  42. 0x004001a4,
  43. 0x004001c4,
  44. 0x004001e4,
  45. 0x00400188,
  46. 0x004001a8,
  47. 0x004001c8,
  48. 0x004001e8,
  49. 0x0040018c,
  50. 0x004001ac,
  51. 0x004001cc,
  52. 0x004001ec,
  53. 0x00400190,
  54. 0x004001b0,
  55. 0x004001d0,
  56. 0x004001f0,
  57. 0x00400194,
  58. 0x004001b4,
  59. 0x004001d4,
  60. 0x004001f4,
  61. 0x00400198,
  62. 0x004001b8,
  63. 0x004001d8,
  64. 0x004001f8,
  65. 0x0040019c,
  66. 0x004001bc,
  67. 0x004001dc,
  68. 0x004001fc,
  69. 0x00400174,
  70. NV04_PGRAPH_DMA_START_0,
  71. NV04_PGRAPH_DMA_START_1,
  72. NV04_PGRAPH_DMA_LENGTH,
  73. NV04_PGRAPH_DMA_MISC,
  74. NV04_PGRAPH_DMA_PITCH,
  75. NV04_PGRAPH_BOFFSET0,
  76. NV04_PGRAPH_BBASE0,
  77. NV04_PGRAPH_BLIMIT0,
  78. NV04_PGRAPH_BOFFSET1,
  79. NV04_PGRAPH_BBASE1,
  80. NV04_PGRAPH_BLIMIT1,
  81. NV04_PGRAPH_BOFFSET2,
  82. NV04_PGRAPH_BBASE2,
  83. NV04_PGRAPH_BLIMIT2,
  84. NV04_PGRAPH_BOFFSET3,
  85. NV04_PGRAPH_BBASE3,
  86. NV04_PGRAPH_BLIMIT3,
  87. NV04_PGRAPH_BOFFSET4,
  88. NV04_PGRAPH_BBASE4,
  89. NV04_PGRAPH_BLIMIT4,
  90. NV04_PGRAPH_BOFFSET5,
  91. NV04_PGRAPH_BBASE5,
  92. NV04_PGRAPH_BLIMIT5,
  93. NV04_PGRAPH_BPITCH0,
  94. NV04_PGRAPH_BPITCH1,
  95. NV04_PGRAPH_BPITCH2,
  96. NV04_PGRAPH_BPITCH3,
  97. NV04_PGRAPH_BPITCH4,
  98. NV04_PGRAPH_SURFACE,
  99. NV04_PGRAPH_STATE,
  100. NV04_PGRAPH_BSWIZZLE2,
  101. NV04_PGRAPH_BSWIZZLE5,
  102. NV04_PGRAPH_BPIXEL,
  103. NV04_PGRAPH_NOTIFY,
  104. NV04_PGRAPH_PATT_COLOR0,
  105. NV04_PGRAPH_PATT_COLOR1,
  106. NV04_PGRAPH_PATT_COLORRAM+0x00,
  107. NV04_PGRAPH_PATT_COLORRAM+0x04,
  108. NV04_PGRAPH_PATT_COLORRAM+0x08,
  109. NV04_PGRAPH_PATT_COLORRAM+0x0c,
  110. NV04_PGRAPH_PATT_COLORRAM+0x10,
  111. NV04_PGRAPH_PATT_COLORRAM+0x14,
  112. NV04_PGRAPH_PATT_COLORRAM+0x18,
  113. NV04_PGRAPH_PATT_COLORRAM+0x1c,
  114. NV04_PGRAPH_PATT_COLORRAM+0x20,
  115. NV04_PGRAPH_PATT_COLORRAM+0x24,
  116. NV04_PGRAPH_PATT_COLORRAM+0x28,
  117. NV04_PGRAPH_PATT_COLORRAM+0x2c,
  118. NV04_PGRAPH_PATT_COLORRAM+0x30,
  119. NV04_PGRAPH_PATT_COLORRAM+0x34,
  120. NV04_PGRAPH_PATT_COLORRAM+0x38,
  121. NV04_PGRAPH_PATT_COLORRAM+0x3c,
  122. NV04_PGRAPH_PATT_COLORRAM+0x40,
  123. NV04_PGRAPH_PATT_COLORRAM+0x44,
  124. NV04_PGRAPH_PATT_COLORRAM+0x48,
  125. NV04_PGRAPH_PATT_COLORRAM+0x4c,
  126. NV04_PGRAPH_PATT_COLORRAM+0x50,
  127. NV04_PGRAPH_PATT_COLORRAM+0x54,
  128. NV04_PGRAPH_PATT_COLORRAM+0x58,
  129. NV04_PGRAPH_PATT_COLORRAM+0x5c,
  130. NV04_PGRAPH_PATT_COLORRAM+0x60,
  131. NV04_PGRAPH_PATT_COLORRAM+0x64,
  132. NV04_PGRAPH_PATT_COLORRAM+0x68,
  133. NV04_PGRAPH_PATT_COLORRAM+0x6c,
  134. NV04_PGRAPH_PATT_COLORRAM+0x70,
  135. NV04_PGRAPH_PATT_COLORRAM+0x74,
  136. NV04_PGRAPH_PATT_COLORRAM+0x78,
  137. NV04_PGRAPH_PATT_COLORRAM+0x7c,
  138. NV04_PGRAPH_PATT_COLORRAM+0x80,
  139. NV04_PGRAPH_PATT_COLORRAM+0x84,
  140. NV04_PGRAPH_PATT_COLORRAM+0x88,
  141. NV04_PGRAPH_PATT_COLORRAM+0x8c,
  142. NV04_PGRAPH_PATT_COLORRAM+0x90,
  143. NV04_PGRAPH_PATT_COLORRAM+0x94,
  144. NV04_PGRAPH_PATT_COLORRAM+0x98,
  145. NV04_PGRAPH_PATT_COLORRAM+0x9c,
  146. NV04_PGRAPH_PATT_COLORRAM+0xa0,
  147. NV04_PGRAPH_PATT_COLORRAM+0xa4,
  148. NV04_PGRAPH_PATT_COLORRAM+0xa8,
  149. NV04_PGRAPH_PATT_COLORRAM+0xac,
  150. NV04_PGRAPH_PATT_COLORRAM+0xb0,
  151. NV04_PGRAPH_PATT_COLORRAM+0xb4,
  152. NV04_PGRAPH_PATT_COLORRAM+0xb8,
  153. NV04_PGRAPH_PATT_COLORRAM+0xbc,
  154. NV04_PGRAPH_PATT_COLORRAM+0xc0,
  155. NV04_PGRAPH_PATT_COLORRAM+0xc4,
  156. NV04_PGRAPH_PATT_COLORRAM+0xc8,
  157. NV04_PGRAPH_PATT_COLORRAM+0xcc,
  158. NV04_PGRAPH_PATT_COLORRAM+0xd0,
  159. NV04_PGRAPH_PATT_COLORRAM+0xd4,
  160. NV04_PGRAPH_PATT_COLORRAM+0xd8,
  161. NV04_PGRAPH_PATT_COLORRAM+0xdc,
  162. NV04_PGRAPH_PATT_COLORRAM+0xe0,
  163. NV04_PGRAPH_PATT_COLORRAM+0xe4,
  164. NV04_PGRAPH_PATT_COLORRAM+0xe8,
  165. NV04_PGRAPH_PATT_COLORRAM+0xec,
  166. NV04_PGRAPH_PATT_COLORRAM+0xf0,
  167. NV04_PGRAPH_PATT_COLORRAM+0xf4,
  168. NV04_PGRAPH_PATT_COLORRAM+0xf8,
  169. NV04_PGRAPH_PATT_COLORRAM+0xfc,
  170. NV04_PGRAPH_PATTERN,
  171. 0x0040080c,
  172. NV04_PGRAPH_PATTERN_SHAPE,
  173. 0x00400600,
  174. NV04_PGRAPH_ROP3,
  175. NV04_PGRAPH_CHROMA,
  176. NV04_PGRAPH_BETA_AND,
  177. NV04_PGRAPH_BETA_PREMULT,
  178. NV04_PGRAPH_CONTROL0,
  179. NV04_PGRAPH_CONTROL1,
  180. NV04_PGRAPH_CONTROL2,
  181. NV04_PGRAPH_BLEND,
  182. NV04_PGRAPH_STORED_FMT,
  183. NV04_PGRAPH_SOURCE_COLOR,
  184. 0x00400560,
  185. 0x00400568,
  186. 0x00400564,
  187. 0x0040056c,
  188. 0x00400400,
  189. 0x00400480,
  190. 0x00400404,
  191. 0x00400484,
  192. 0x00400408,
  193. 0x00400488,
  194. 0x0040040c,
  195. 0x0040048c,
  196. 0x00400410,
  197. 0x00400490,
  198. 0x00400414,
  199. 0x00400494,
  200. 0x00400418,
  201. 0x00400498,
  202. 0x0040041c,
  203. 0x0040049c,
  204. 0x00400420,
  205. 0x004004a0,
  206. 0x00400424,
  207. 0x004004a4,
  208. 0x00400428,
  209. 0x004004a8,
  210. 0x0040042c,
  211. 0x004004ac,
  212. 0x00400430,
  213. 0x004004b0,
  214. 0x00400434,
  215. 0x004004b4,
  216. 0x00400438,
  217. 0x004004b8,
  218. 0x0040043c,
  219. 0x004004bc,
  220. 0x00400440,
  221. 0x004004c0,
  222. 0x00400444,
  223. 0x004004c4,
  224. 0x00400448,
  225. 0x004004c8,
  226. 0x0040044c,
  227. 0x004004cc,
  228. 0x00400450,
  229. 0x004004d0,
  230. 0x00400454,
  231. 0x004004d4,
  232. 0x00400458,
  233. 0x004004d8,
  234. 0x0040045c,
  235. 0x004004dc,
  236. 0x00400460,
  237. 0x004004e0,
  238. 0x00400464,
  239. 0x004004e4,
  240. 0x00400468,
  241. 0x004004e8,
  242. 0x0040046c,
  243. 0x004004ec,
  244. 0x00400470,
  245. 0x004004f0,
  246. 0x00400474,
  247. 0x004004f4,
  248. 0x00400478,
  249. 0x004004f8,
  250. 0x0040047c,
  251. 0x004004fc,
  252. 0x00400534,
  253. 0x00400538,
  254. 0x00400514,
  255. 0x00400518,
  256. 0x0040051c,
  257. 0x00400520,
  258. 0x00400524,
  259. 0x00400528,
  260. 0x0040052c,
  261. 0x00400530,
  262. 0x00400d00,
  263. 0x00400d40,
  264. 0x00400d80,
  265. 0x00400d04,
  266. 0x00400d44,
  267. 0x00400d84,
  268. 0x00400d08,
  269. 0x00400d48,
  270. 0x00400d88,
  271. 0x00400d0c,
  272. 0x00400d4c,
  273. 0x00400d8c,
  274. 0x00400d10,
  275. 0x00400d50,
  276. 0x00400d90,
  277. 0x00400d14,
  278. 0x00400d54,
  279. 0x00400d94,
  280. 0x00400d18,
  281. 0x00400d58,
  282. 0x00400d98,
  283. 0x00400d1c,
  284. 0x00400d5c,
  285. 0x00400d9c,
  286. 0x00400d20,
  287. 0x00400d60,
  288. 0x00400da0,
  289. 0x00400d24,
  290. 0x00400d64,
  291. 0x00400da4,
  292. 0x00400d28,
  293. 0x00400d68,
  294. 0x00400da8,
  295. 0x00400d2c,
  296. 0x00400d6c,
  297. 0x00400dac,
  298. 0x00400d30,
  299. 0x00400d70,
  300. 0x00400db0,
  301. 0x00400d34,
  302. 0x00400d74,
  303. 0x00400db4,
  304. 0x00400d38,
  305. 0x00400d78,
  306. 0x00400db8,
  307. 0x00400d3c,
  308. 0x00400d7c,
  309. 0x00400dbc,
  310. 0x00400590,
  311. 0x00400594,
  312. 0x00400598,
  313. 0x0040059c,
  314. 0x004005a8,
  315. 0x004005ac,
  316. 0x004005b0,
  317. 0x004005b4,
  318. 0x004005c0,
  319. 0x004005c4,
  320. 0x004005c8,
  321. 0x004005cc,
  322. 0x004005d0,
  323. 0x004005d4,
  324. 0x004005d8,
  325. 0x004005dc,
  326. 0x004005e0,
  327. NV04_PGRAPH_PASSTHRU_0,
  328. NV04_PGRAPH_PASSTHRU_1,
  329. NV04_PGRAPH_PASSTHRU_2,
  330. NV04_PGRAPH_DVD_COLORFMT,
  331. NV04_PGRAPH_SCALED_FORMAT,
  332. NV04_PGRAPH_MISC24_0,
  333. NV04_PGRAPH_MISC24_1,
  334. NV04_PGRAPH_MISC24_2,
  335. 0x00400500,
  336. 0x00400504,
  337. NV04_PGRAPH_VALID1,
  338. NV04_PGRAPH_VALID2,
  339. NV04_PGRAPH_DEBUG_3
  340. };
  341. struct graph_state {
  342. int nv04[ARRAY_SIZE(nv04_graph_ctx_regs)];
  343. };
  344. struct nouveau_channel *
  345. nv04_graph_channel(struct drm_device *dev)
  346. {
  347. struct drm_nouveau_private *dev_priv = dev->dev_private;
  348. int chid = dev_priv->engine.fifo.channels;
  349. if (nv_rd32(dev, NV04_PGRAPH_CTX_CONTROL) & 0x00010000)
  350. chid = nv_rd32(dev, NV04_PGRAPH_CTX_USER) >> 24;
  351. if (chid >= dev_priv->engine.fifo.channels)
  352. return NULL;
  353. return dev_priv->fifos[chid];
  354. }
  355. void
  356. nv04_graph_context_switch(struct drm_device *dev)
  357. {
  358. struct drm_nouveau_private *dev_priv = dev->dev_private;
  359. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  360. struct nouveau_channel *chan = NULL;
  361. int chid;
  362. pgraph->fifo_access(dev, false);
  363. nouveau_wait_for_idle(dev);
  364. /* If previous context is valid, we need to save it */
  365. pgraph->unload_context(dev);
  366. /* Load context for next channel */
  367. chid = dev_priv->engine.fifo.channel_id(dev);
  368. chan = dev_priv->fifos[chid];
  369. if (chan)
  370. nv04_graph_load_context(chan);
  371. pgraph->fifo_access(dev, true);
  372. }
  373. static uint32_t *ctx_reg(struct graph_state *ctx, uint32_t reg)
  374. {
  375. int i;
  376. for (i = 0; i < ARRAY_SIZE(nv04_graph_ctx_regs); i++) {
  377. if (nv04_graph_ctx_regs[i] == reg)
  378. return &ctx->nv04[i];
  379. }
  380. return NULL;
  381. }
  382. int nv04_graph_create_context(struct nouveau_channel *chan)
  383. {
  384. struct graph_state *pgraph_ctx;
  385. NV_DEBUG(chan->dev, "nv04_graph_context_create %d\n", chan->id);
  386. chan->pgraph_ctx = pgraph_ctx = kzalloc(sizeof(*pgraph_ctx),
  387. GFP_KERNEL);
  388. if (pgraph_ctx == NULL)
  389. return -ENOMEM;
  390. *ctx_reg(pgraph_ctx, NV04_PGRAPH_DEBUG_3) = 0xfad4ff31;
  391. return 0;
  392. }
  393. void nv04_graph_destroy_context(struct nouveau_channel *chan)
  394. {
  395. struct graph_state *pgraph_ctx = chan->pgraph_ctx;
  396. kfree(pgraph_ctx);
  397. chan->pgraph_ctx = NULL;
  398. }
  399. int nv04_graph_load_context(struct nouveau_channel *chan)
  400. {
  401. struct drm_device *dev = chan->dev;
  402. struct graph_state *pgraph_ctx = chan->pgraph_ctx;
  403. uint32_t tmp;
  404. int i;
  405. for (i = 0; i < ARRAY_SIZE(nv04_graph_ctx_regs); i++)
  406. nv_wr32(dev, nv04_graph_ctx_regs[i], pgraph_ctx->nv04[i]);
  407. nv_wr32(dev, NV04_PGRAPH_CTX_CONTROL, 0x10010100);
  408. tmp = nv_rd32(dev, NV04_PGRAPH_CTX_USER) & 0x00ffffff;
  409. nv_wr32(dev, NV04_PGRAPH_CTX_USER, tmp | chan->id << 24);
  410. tmp = nv_rd32(dev, NV04_PGRAPH_FFINTFC_ST2);
  411. nv_wr32(dev, NV04_PGRAPH_FFINTFC_ST2, tmp & 0x000fffff);
  412. return 0;
  413. }
  414. int
  415. nv04_graph_unload_context(struct drm_device *dev)
  416. {
  417. struct drm_nouveau_private *dev_priv = dev->dev_private;
  418. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  419. struct nouveau_channel *chan = NULL;
  420. struct graph_state *ctx;
  421. uint32_t tmp;
  422. int i;
  423. chan = pgraph->channel(dev);
  424. if (!chan)
  425. return 0;
  426. ctx = chan->pgraph_ctx;
  427. for (i = 0; i < ARRAY_SIZE(nv04_graph_ctx_regs); i++)
  428. ctx->nv04[i] = nv_rd32(dev, nv04_graph_ctx_regs[i]);
  429. nv_wr32(dev, NV04_PGRAPH_CTX_CONTROL, 0x10000000);
  430. tmp = nv_rd32(dev, NV04_PGRAPH_CTX_USER) & 0x00ffffff;
  431. tmp |= (dev_priv->engine.fifo.channels - 1) << 24;
  432. nv_wr32(dev, NV04_PGRAPH_CTX_USER, tmp);
  433. return 0;
  434. }
  435. int nv04_graph_init(struct drm_device *dev)
  436. {
  437. struct drm_nouveau_private *dev_priv = dev->dev_private;
  438. uint32_t tmp;
  439. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) &
  440. ~NV_PMC_ENABLE_PGRAPH);
  441. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) |
  442. NV_PMC_ENABLE_PGRAPH);
  443. /* Enable PGRAPH interrupts */
  444. nv_wr32(dev, NV03_PGRAPH_INTR, 0xFFFFFFFF);
  445. nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
  446. nv_wr32(dev, NV04_PGRAPH_VALID1, 0);
  447. nv_wr32(dev, NV04_PGRAPH_VALID2, 0);
  448. /*nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x000001FF);
  449. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x001FFFFF);*/
  450. nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x1231c000);
  451. /*1231C000 blob, 001 haiku*/
  452. //*V_WRITE(NV04_PGRAPH_DEBUG_1, 0xf2d91100);*/
  453. nv_wr32(dev, NV04_PGRAPH_DEBUG_1, 0x72111100);
  454. /*0x72111100 blob , 01 haiku*/
  455. /*nv_wr32(dev, NV04_PGRAPH_DEBUG_2, 0x11d5f870);*/
  456. nv_wr32(dev, NV04_PGRAPH_DEBUG_2, 0x11d5f071);
  457. /*haiku same*/
  458. /*nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xfad4ff31);*/
  459. nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xf0d4ff31);
  460. /*haiku and blob 10d4*/
  461. nv_wr32(dev, NV04_PGRAPH_STATE , 0xFFFFFFFF);
  462. nv_wr32(dev, NV04_PGRAPH_CTX_CONTROL , 0x10000100);
  463. tmp = nv_rd32(dev, NV04_PGRAPH_CTX_USER) & 0x00ffffff;
  464. tmp |= (dev_priv->engine.fifo.channels - 1) << 24;
  465. nv_wr32(dev, NV04_PGRAPH_CTX_USER, tmp);
  466. /* These don't belong here, they're part of a per-channel context */
  467. nv_wr32(dev, NV04_PGRAPH_PATTERN_SHAPE, 0x00000000);
  468. nv_wr32(dev, NV04_PGRAPH_BETA_AND , 0xFFFFFFFF);
  469. return 0;
  470. }
  471. void nv04_graph_takedown(struct drm_device *dev)
  472. {
  473. }
  474. void
  475. nv04_graph_fifo_access(struct drm_device *dev, bool enabled)
  476. {
  477. if (enabled)
  478. nv_wr32(dev, NV04_PGRAPH_FIFO,
  479. nv_rd32(dev, NV04_PGRAPH_FIFO) | 1);
  480. else
  481. nv_wr32(dev, NV04_PGRAPH_FIFO,
  482. nv_rd32(dev, NV04_PGRAPH_FIFO) & ~1);
  483. }
  484. static int
  485. nv04_graph_mthd_set_ref(struct nouveau_channel *chan, int grclass,
  486. int mthd, uint32_t data)
  487. {
  488. chan->fence.last_sequence_irq = data;
  489. nouveau_fence_handler(chan->dev, chan->id);
  490. return 0;
  491. }
  492. static int
  493. nv04_graph_mthd_set_operation(struct nouveau_channel *chan, int grclass,
  494. int mthd, uint32_t data)
  495. {
  496. struct drm_device *dev = chan->dev;
  497. uint32_t instance = (nv_rd32(dev, NV04_PGRAPH_CTX_SWITCH4) & 0xffff) << 4;
  498. int subc = (nv_rd32(dev, NV04_PGRAPH_TRAPPED_ADDR) >> 13) & 0x7;
  499. uint32_t tmp;
  500. tmp = nv_ri32(dev, instance);
  501. tmp &= ~0x00038000;
  502. tmp |= ((data & 7) << 15);
  503. nv_wi32(dev, instance, tmp);
  504. nv_wr32(dev, NV04_PGRAPH_CTX_SWITCH1, tmp);
  505. nv_wr32(dev, NV04_PGRAPH_CTX_CACHE1 + (subc<<2), tmp);
  506. return 0;
  507. }
  508. static struct nouveau_pgraph_object_method nv04_graph_mthds_sw[] = {
  509. { 0x0150, nv04_graph_mthd_set_ref },
  510. {}
  511. };
  512. static struct nouveau_pgraph_object_method nv04_graph_mthds_set_operation[] = {
  513. { 0x02fc, nv04_graph_mthd_set_operation },
  514. {},
  515. };
  516. struct nouveau_pgraph_object_class nv04_graph_grclass[] = {
  517. { 0x0039, false, NULL },
  518. { 0x004a, false, nv04_graph_mthds_set_operation }, /* gdirect */
  519. { 0x005f, false, nv04_graph_mthds_set_operation }, /* imageblit */
  520. { 0x0061, false, nv04_graph_mthds_set_operation }, /* ifc */
  521. { 0x0077, false, nv04_graph_mthds_set_operation }, /* sifm */
  522. { 0x0030, false, NULL }, /* null */
  523. { 0x0042, false, NULL }, /* surf2d */
  524. { 0x0043, false, NULL }, /* rop */
  525. { 0x0012, false, NULL }, /* beta1 */
  526. { 0x0072, false, NULL }, /* beta4 */
  527. { 0x0019, false, NULL }, /* cliprect */
  528. { 0x0044, false, NULL }, /* pattern */
  529. { 0x0052, false, NULL }, /* swzsurf */
  530. { 0x0053, false, NULL }, /* surf3d */
  531. { 0x0054, false, NULL }, /* tex_tri */
  532. { 0x0055, false, NULL }, /* multitex_tri */
  533. { 0x506e, true, nv04_graph_mthds_sw },
  534. {}
  535. };