nv04_graph.c 14 KB

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