blob: 81aba097ef950c08047bf8e975dba9d699a4d691 [file] [log] [blame]
Ben Skeggs6ee73862009-12-11 19:24:15 +10001/*
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
25#include "drmP.h"
26#include "drm.h"
27#include "nouveau_drm.h"
28#include "nouveau_drv.h"
29
Ben Skeggsb8c157d2010-10-20 10:39:35 +100030static int nv04_graph_register(struct drm_device *dev);
31
Ben Skeggs6ee73862009-12-11 19:24:15 +100032static uint32_t nv04_graph_ctx_regs[] = {
Francisco Jerezea911a12009-12-26 14:39:46 +010033 0x0040053c,
34 0x00400544,
35 0x00400540,
36 0x00400548,
Ben Skeggs6ee73862009-12-11 19:24:15 +100037 NV04_PGRAPH_CTX_SWITCH1,
38 NV04_PGRAPH_CTX_SWITCH2,
39 NV04_PGRAPH_CTX_SWITCH3,
40 NV04_PGRAPH_CTX_SWITCH4,
41 NV04_PGRAPH_CTX_CACHE1,
42 NV04_PGRAPH_CTX_CACHE2,
43 NV04_PGRAPH_CTX_CACHE3,
44 NV04_PGRAPH_CTX_CACHE4,
45 0x00400184,
46 0x004001a4,
47 0x004001c4,
48 0x004001e4,
49 0x00400188,
50 0x004001a8,
51 0x004001c8,
52 0x004001e8,
53 0x0040018c,
54 0x004001ac,
55 0x004001cc,
56 0x004001ec,
57 0x00400190,
58 0x004001b0,
59 0x004001d0,
60 0x004001f0,
61 0x00400194,
62 0x004001b4,
63 0x004001d4,
64 0x004001f4,
65 0x00400198,
66 0x004001b8,
67 0x004001d8,
68 0x004001f8,
69 0x0040019c,
70 0x004001bc,
71 0x004001dc,
72 0x004001fc,
73 0x00400174,
74 NV04_PGRAPH_DMA_START_0,
75 NV04_PGRAPH_DMA_START_1,
76 NV04_PGRAPH_DMA_LENGTH,
77 NV04_PGRAPH_DMA_MISC,
78 NV04_PGRAPH_DMA_PITCH,
79 NV04_PGRAPH_BOFFSET0,
80 NV04_PGRAPH_BBASE0,
81 NV04_PGRAPH_BLIMIT0,
82 NV04_PGRAPH_BOFFSET1,
83 NV04_PGRAPH_BBASE1,
84 NV04_PGRAPH_BLIMIT1,
85 NV04_PGRAPH_BOFFSET2,
86 NV04_PGRAPH_BBASE2,
87 NV04_PGRAPH_BLIMIT2,
88 NV04_PGRAPH_BOFFSET3,
89 NV04_PGRAPH_BBASE3,
90 NV04_PGRAPH_BLIMIT3,
91 NV04_PGRAPH_BOFFSET4,
92 NV04_PGRAPH_BBASE4,
93 NV04_PGRAPH_BLIMIT4,
94 NV04_PGRAPH_BOFFSET5,
95 NV04_PGRAPH_BBASE5,
96 NV04_PGRAPH_BLIMIT5,
97 NV04_PGRAPH_BPITCH0,
98 NV04_PGRAPH_BPITCH1,
99 NV04_PGRAPH_BPITCH2,
100 NV04_PGRAPH_BPITCH3,
101 NV04_PGRAPH_BPITCH4,
102 NV04_PGRAPH_SURFACE,
103 NV04_PGRAPH_STATE,
104 NV04_PGRAPH_BSWIZZLE2,
105 NV04_PGRAPH_BSWIZZLE5,
106 NV04_PGRAPH_BPIXEL,
107 NV04_PGRAPH_NOTIFY,
108 NV04_PGRAPH_PATT_COLOR0,
109 NV04_PGRAPH_PATT_COLOR1,
110 NV04_PGRAPH_PATT_COLORRAM+0x00,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000111 NV04_PGRAPH_PATT_COLORRAM+0x04,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000112 NV04_PGRAPH_PATT_COLORRAM+0x08,
Francisco Jerezea911a12009-12-26 14:39:46 +0100113 NV04_PGRAPH_PATT_COLORRAM+0x0c,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000114 NV04_PGRAPH_PATT_COLORRAM+0x10,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000115 NV04_PGRAPH_PATT_COLORRAM+0x14,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000116 NV04_PGRAPH_PATT_COLORRAM+0x18,
Francisco Jerezea911a12009-12-26 14:39:46 +0100117 NV04_PGRAPH_PATT_COLORRAM+0x1c,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000118 NV04_PGRAPH_PATT_COLORRAM+0x20,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000119 NV04_PGRAPH_PATT_COLORRAM+0x24,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000120 NV04_PGRAPH_PATT_COLORRAM+0x28,
Francisco Jerezea911a12009-12-26 14:39:46 +0100121 NV04_PGRAPH_PATT_COLORRAM+0x2c,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000122 NV04_PGRAPH_PATT_COLORRAM+0x30,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000123 NV04_PGRAPH_PATT_COLORRAM+0x34,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000124 NV04_PGRAPH_PATT_COLORRAM+0x38,
Francisco Jerezea911a12009-12-26 14:39:46 +0100125 NV04_PGRAPH_PATT_COLORRAM+0x3c,
126 NV04_PGRAPH_PATT_COLORRAM+0x40,
127 NV04_PGRAPH_PATT_COLORRAM+0x44,
128 NV04_PGRAPH_PATT_COLORRAM+0x48,
129 NV04_PGRAPH_PATT_COLORRAM+0x4c,
130 NV04_PGRAPH_PATT_COLORRAM+0x50,
131 NV04_PGRAPH_PATT_COLORRAM+0x54,
132 NV04_PGRAPH_PATT_COLORRAM+0x58,
133 NV04_PGRAPH_PATT_COLORRAM+0x5c,
134 NV04_PGRAPH_PATT_COLORRAM+0x60,
135 NV04_PGRAPH_PATT_COLORRAM+0x64,
136 NV04_PGRAPH_PATT_COLORRAM+0x68,
137 NV04_PGRAPH_PATT_COLORRAM+0x6c,
138 NV04_PGRAPH_PATT_COLORRAM+0x70,
139 NV04_PGRAPH_PATT_COLORRAM+0x74,
140 NV04_PGRAPH_PATT_COLORRAM+0x78,
141 NV04_PGRAPH_PATT_COLORRAM+0x7c,
142 NV04_PGRAPH_PATT_COLORRAM+0x80,
143 NV04_PGRAPH_PATT_COLORRAM+0x84,
144 NV04_PGRAPH_PATT_COLORRAM+0x88,
145 NV04_PGRAPH_PATT_COLORRAM+0x8c,
146 NV04_PGRAPH_PATT_COLORRAM+0x90,
147 NV04_PGRAPH_PATT_COLORRAM+0x94,
148 NV04_PGRAPH_PATT_COLORRAM+0x98,
149 NV04_PGRAPH_PATT_COLORRAM+0x9c,
150 NV04_PGRAPH_PATT_COLORRAM+0xa0,
151 NV04_PGRAPH_PATT_COLORRAM+0xa4,
152 NV04_PGRAPH_PATT_COLORRAM+0xa8,
153 NV04_PGRAPH_PATT_COLORRAM+0xac,
154 NV04_PGRAPH_PATT_COLORRAM+0xb0,
155 NV04_PGRAPH_PATT_COLORRAM+0xb4,
156 NV04_PGRAPH_PATT_COLORRAM+0xb8,
157 NV04_PGRAPH_PATT_COLORRAM+0xbc,
158 NV04_PGRAPH_PATT_COLORRAM+0xc0,
159 NV04_PGRAPH_PATT_COLORRAM+0xc4,
160 NV04_PGRAPH_PATT_COLORRAM+0xc8,
161 NV04_PGRAPH_PATT_COLORRAM+0xcc,
162 NV04_PGRAPH_PATT_COLORRAM+0xd0,
163 NV04_PGRAPH_PATT_COLORRAM+0xd4,
164 NV04_PGRAPH_PATT_COLORRAM+0xd8,
165 NV04_PGRAPH_PATT_COLORRAM+0xdc,
166 NV04_PGRAPH_PATT_COLORRAM+0xe0,
167 NV04_PGRAPH_PATT_COLORRAM+0xe4,
168 NV04_PGRAPH_PATT_COLORRAM+0xe8,
169 NV04_PGRAPH_PATT_COLORRAM+0xec,
170 NV04_PGRAPH_PATT_COLORRAM+0xf0,
171 NV04_PGRAPH_PATT_COLORRAM+0xf4,
172 NV04_PGRAPH_PATT_COLORRAM+0xf8,
173 NV04_PGRAPH_PATT_COLORRAM+0xfc,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000174 NV04_PGRAPH_PATTERN,
175 0x0040080c,
176 NV04_PGRAPH_PATTERN_SHAPE,
177 0x00400600,
178 NV04_PGRAPH_ROP3,
179 NV04_PGRAPH_CHROMA,
180 NV04_PGRAPH_BETA_AND,
181 NV04_PGRAPH_BETA_PREMULT,
182 NV04_PGRAPH_CONTROL0,
183 NV04_PGRAPH_CONTROL1,
184 NV04_PGRAPH_CONTROL2,
185 NV04_PGRAPH_BLEND,
186 NV04_PGRAPH_STORED_FMT,
187 NV04_PGRAPH_SOURCE_COLOR,
188 0x00400560,
189 0x00400568,
190 0x00400564,
191 0x0040056c,
192 0x00400400,
193 0x00400480,
194 0x00400404,
195 0x00400484,
196 0x00400408,
197 0x00400488,
198 0x0040040c,
199 0x0040048c,
200 0x00400410,
201 0x00400490,
202 0x00400414,
203 0x00400494,
204 0x00400418,
205 0x00400498,
206 0x0040041c,
207 0x0040049c,
208 0x00400420,
209 0x004004a0,
210 0x00400424,
211 0x004004a4,
212 0x00400428,
213 0x004004a8,
214 0x0040042c,
215 0x004004ac,
216 0x00400430,
217 0x004004b0,
218 0x00400434,
219 0x004004b4,
220 0x00400438,
221 0x004004b8,
222 0x0040043c,
223 0x004004bc,
224 0x00400440,
225 0x004004c0,
226 0x00400444,
227 0x004004c4,
228 0x00400448,
229 0x004004c8,
230 0x0040044c,
231 0x004004cc,
232 0x00400450,
233 0x004004d0,
234 0x00400454,
235 0x004004d4,
236 0x00400458,
237 0x004004d8,
238 0x0040045c,
239 0x004004dc,
240 0x00400460,
241 0x004004e0,
242 0x00400464,
243 0x004004e4,
244 0x00400468,
245 0x004004e8,
246 0x0040046c,
247 0x004004ec,
248 0x00400470,
249 0x004004f0,
250 0x00400474,
251 0x004004f4,
252 0x00400478,
253 0x004004f8,
254 0x0040047c,
255 0x004004fc,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000256 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,
Francisco Jerezea911a12009-12-26 14:39:46 +0100342 NV04_PGRAPH_VALID2,
343 NV04_PGRAPH_DEBUG_3
Ben Skeggs6ee73862009-12-11 19:24:15 +1000344};
345
346struct graph_state {
Francisco Jerez6e86e042010-07-03 18:36:39 +0200347 uint32_t nv04[ARRAY_SIZE(nv04_graph_ctx_regs)];
Ben Skeggs6ee73862009-12-11 19:24:15 +1000348};
349
350struct nouveau_channel *
351nv04_graph_channel(struct drm_device *dev)
352{
353 struct drm_nouveau_private *dev_priv = dev->dev_private;
354 int chid = dev_priv->engine.fifo.channels;
355
356 if (nv_rd32(dev, NV04_PGRAPH_CTX_CONTROL) & 0x00010000)
357 chid = nv_rd32(dev, NV04_PGRAPH_CTX_USER) >> 24;
358
359 if (chid >= dev_priv->engine.fifo.channels)
360 return NULL;
361
Ben Skeggscff5c132010-10-06 16:16:59 +1000362 return dev_priv->channels.ptr[chid];
Ben Skeggs6ee73862009-12-11 19:24:15 +1000363}
364
365void
366nv04_graph_context_switch(struct drm_device *dev)
367{
368 struct drm_nouveau_private *dev_priv = dev->dev_private;
369 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
370 struct nouveau_channel *chan = NULL;
371 int chid;
372
373 pgraph->fifo_access(dev, false);
374 nouveau_wait_for_idle(dev);
375
376 /* If previous context is valid, we need to save it */
377 pgraph->unload_context(dev);
378
379 /* Load context for next channel */
380 chid = dev_priv->engine.fifo.channel_id(dev);
Ben Skeggscff5c132010-10-06 16:16:59 +1000381 chan = dev_priv->channels.ptr[chid];
Ben Skeggs6ee73862009-12-11 19:24:15 +1000382 if (chan)
383 nv04_graph_load_context(chan);
384
385 pgraph->fifo_access(dev, true);
386}
387
Francisco Jerezea911a12009-12-26 14:39:46 +0100388static uint32_t *ctx_reg(struct graph_state *ctx, uint32_t reg)
389{
390 int i;
391
392 for (i = 0; i < ARRAY_SIZE(nv04_graph_ctx_regs); i++) {
393 if (nv04_graph_ctx_regs[i] == reg)
394 return &ctx->nv04[i];
395 }
396
397 return NULL;
398}
399
Ben Skeggs6ee73862009-12-11 19:24:15 +1000400int nv04_graph_create_context(struct nouveau_channel *chan)
401{
402 struct graph_state *pgraph_ctx;
403 NV_DEBUG(chan->dev, "nv04_graph_context_create %d\n", chan->id);
404
405 chan->pgraph_ctx = pgraph_ctx = kzalloc(sizeof(*pgraph_ctx),
406 GFP_KERNEL);
407 if (pgraph_ctx == NULL)
408 return -ENOMEM;
409
Francisco Jerezea911a12009-12-26 14:39:46 +0100410 *ctx_reg(pgraph_ctx, NV04_PGRAPH_DEBUG_3) = 0xfad4ff31;
411
Ben Skeggs6ee73862009-12-11 19:24:15 +1000412 return 0;
413}
414
415void nv04_graph_destroy_context(struct nouveau_channel *chan)
416{
Francisco Jerez3945e472010-10-18 03:53:39 +0200417 struct drm_device *dev = chan->dev;
418 struct drm_nouveau_private *dev_priv = dev->dev_private;
419 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000420 struct graph_state *pgraph_ctx = chan->pgraph_ctx;
Francisco Jerez3945e472010-10-18 03:53:39 +0200421 unsigned long flags;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000422
Francisco Jerez3945e472010-10-18 03:53:39 +0200423 spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
424 pgraph->fifo_access(dev, false);
425
426 /* Unload the context if it's the currently active one */
427 if (pgraph->channel(dev) == chan)
428 pgraph->unload_context(dev);
429
430 /* Free the context resources */
Ben Skeggs6ee73862009-12-11 19:24:15 +1000431 kfree(pgraph_ctx);
432 chan->pgraph_ctx = NULL;
Francisco Jerez3945e472010-10-18 03:53:39 +0200433
434 pgraph->fifo_access(dev, true);
435 spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000436}
437
438int nv04_graph_load_context(struct nouveau_channel *chan)
439{
440 struct drm_device *dev = chan->dev;
441 struct graph_state *pgraph_ctx = chan->pgraph_ctx;
442 uint32_t tmp;
443 int i;
444
445 for (i = 0; i < ARRAY_SIZE(nv04_graph_ctx_regs); i++)
446 nv_wr32(dev, nv04_graph_ctx_regs[i], pgraph_ctx->nv04[i]);
447
448 nv_wr32(dev, NV04_PGRAPH_CTX_CONTROL, 0x10010100);
Francisco Jerezea911a12009-12-26 14:39:46 +0100449
450 tmp = nv_rd32(dev, NV04_PGRAPH_CTX_USER) & 0x00ffffff;
451 nv_wr32(dev, NV04_PGRAPH_CTX_USER, tmp | chan->id << 24);
452
Ben Skeggs6ee73862009-12-11 19:24:15 +1000453 tmp = nv_rd32(dev, NV04_PGRAPH_FFINTFC_ST2);
454 nv_wr32(dev, NV04_PGRAPH_FFINTFC_ST2, tmp & 0x000fffff);
Francisco Jerezea911a12009-12-26 14:39:46 +0100455
Ben Skeggs6ee73862009-12-11 19:24:15 +1000456 return 0;
457}
458
459int
460nv04_graph_unload_context(struct drm_device *dev)
461{
462 struct drm_nouveau_private *dev_priv = dev->dev_private;
463 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
464 struct nouveau_channel *chan = NULL;
465 struct graph_state *ctx;
466 uint32_t tmp;
467 int i;
468
469 chan = pgraph->channel(dev);
470 if (!chan)
471 return 0;
472 ctx = chan->pgraph_ctx;
473
474 for (i = 0; i < ARRAY_SIZE(nv04_graph_ctx_regs); i++)
475 ctx->nv04[i] = nv_rd32(dev, nv04_graph_ctx_regs[i]);
476
477 nv_wr32(dev, NV04_PGRAPH_CTX_CONTROL, 0x10000000);
478 tmp = nv_rd32(dev, NV04_PGRAPH_CTX_USER) & 0x00ffffff;
479 tmp |= (dev_priv->engine.fifo.channels - 1) << 24;
480 nv_wr32(dev, NV04_PGRAPH_CTX_USER, tmp);
481 return 0;
482}
483
484int nv04_graph_init(struct drm_device *dev)
485{
486 struct drm_nouveau_private *dev_priv = dev->dev_private;
487 uint32_t tmp;
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000488 int ret;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000489
490 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) &
491 ~NV_PMC_ENABLE_PGRAPH);
492 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) |
493 NV_PMC_ENABLE_PGRAPH);
494
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000495 ret = nv04_graph_register(dev);
496 if (ret)
497 return ret;
498
Ben Skeggs6ee73862009-12-11 19:24:15 +1000499 /* Enable PGRAPH interrupts */
500 nv_wr32(dev, NV03_PGRAPH_INTR, 0xFFFFFFFF);
501 nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
502
503 nv_wr32(dev, NV04_PGRAPH_VALID1, 0);
504 nv_wr32(dev, NV04_PGRAPH_VALID2, 0);
505 /*nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x000001FF);
506 nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x001FFFFF);*/
507 nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x1231c000);
508 /*1231C000 blob, 001 haiku*/
509 //*V_WRITE(NV04_PGRAPH_DEBUG_1, 0xf2d91100);*/
510 nv_wr32(dev, NV04_PGRAPH_DEBUG_1, 0x72111100);
511 /*0x72111100 blob , 01 haiku*/
512 /*nv_wr32(dev, NV04_PGRAPH_DEBUG_2, 0x11d5f870);*/
513 nv_wr32(dev, NV04_PGRAPH_DEBUG_2, 0x11d5f071);
514 /*haiku same*/
515
516 /*nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xfad4ff31);*/
517 nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xf0d4ff31);
518 /*haiku and blob 10d4*/
519
520 nv_wr32(dev, NV04_PGRAPH_STATE , 0xFFFFFFFF);
521 nv_wr32(dev, NV04_PGRAPH_CTX_CONTROL , 0x10000100);
522 tmp = nv_rd32(dev, NV04_PGRAPH_CTX_USER) & 0x00ffffff;
Francisco Jerezea911a12009-12-26 14:39:46 +0100523 tmp |= (dev_priv->engine.fifo.channels - 1) << 24;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000524 nv_wr32(dev, NV04_PGRAPH_CTX_USER, tmp);
525
526 /* These don't belong here, they're part of a per-channel context */
527 nv_wr32(dev, NV04_PGRAPH_PATTERN_SHAPE, 0x00000000);
528 nv_wr32(dev, NV04_PGRAPH_BETA_AND , 0xFFFFFFFF);
529
530 return 0;
531}
532
533void nv04_graph_takedown(struct drm_device *dev)
534{
535}
536
537void
538nv04_graph_fifo_access(struct drm_device *dev, bool enabled)
539{
540 if (enabled)
541 nv_wr32(dev, NV04_PGRAPH_FIFO,
542 nv_rd32(dev, NV04_PGRAPH_FIFO) | 1);
543 else
544 nv_wr32(dev, NV04_PGRAPH_FIFO,
545 nv_rd32(dev, NV04_PGRAPH_FIFO) & ~1);
546}
547
548static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000549nv04_graph_mthd_set_ref(struct nouveau_channel *chan,
550 u32 class, u32 mthd, u32 data)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000551{
Ben Skeggs047d1d32010-05-31 12:00:43 +1000552 atomic_set(&chan->fence.last_sequence_irq, data);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000553 return 0;
554}
555
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000556/*
557 * Software methods, why they are needed, and how they all work:
558 *
559 * NV04 and NV05 keep most of the state in PGRAPH context itself, but some
560 * 2d engine settings are kept inside the grobjs themselves. The grobjs are
561 * 3 words long on both. grobj format on NV04 is:
562 *
563 * word 0:
564 * - bits 0-7: class
565 * - bit 12: color key active
566 * - bit 13: clip rect active
567 * - bit 14: if set, destination surface is swizzled and taken from buffer 5
568 * [set by NV04_SWIZZLED_SURFACE], otherwise it's linear and taken
569 * from buffer 0 [set by NV04_CONTEXT_SURFACES_2D or
570 * NV03_CONTEXT_SURFACE_DST].
571 * - bits 15-17: 2d operation [aka patch config]
572 * - bit 24: patch valid [enables rendering using this object]
573 * - bit 25: surf3d valid [for tex_tri and multitex_tri only]
574 * word 1:
575 * - bits 0-1: mono format
576 * - bits 8-13: color format
577 * - bits 16-31: DMA_NOTIFY instance
578 * word 2:
579 * - bits 0-15: DMA_A instance
580 * - bits 16-31: DMA_B instance
581 *
582 * On NV05 it's:
583 *
584 * word 0:
585 * - bits 0-7: class
586 * - bit 12: color key active
587 * - bit 13: clip rect active
588 * - bit 14: if set, destination surface is swizzled and taken from buffer 5
589 * [set by NV04_SWIZZLED_SURFACE], otherwise it's linear and taken
590 * from buffer 0 [set by NV04_CONTEXT_SURFACES_2D or
591 * NV03_CONTEXT_SURFACE_DST].
592 * - bits 15-17: 2d operation [aka patch config]
593 * - bits 20-22: dither mode
594 * - bit 24: patch valid [enables rendering using this object]
595 * - bit 25: surface_dst/surface_color/surf2d/surf3d valid
596 * - bit 26: surface_src/surface_zeta valid
597 * - bit 27: pattern valid
598 * - bit 28: rop valid
599 * - bit 29: beta1 valid
600 * - bit 30: beta4 valid
601 * word 1:
602 * - bits 0-1: mono format
603 * - bits 8-13: color format
604 * - bits 16-31: DMA_NOTIFY instance
605 * word 2:
606 * - bits 0-15: DMA_A instance
607 * - bits 16-31: DMA_B instance
608 *
609 * NV05 will set/unset the relevant valid bits when you poke the relevant
610 * object-binding methods with object of the proper type, or with the NULL
611 * type. It'll only allow rendering using the grobj if all needed objects
612 * are bound. The needed set of objects depends on selected operation: for
613 * example rop object is needed by ROP_AND, but not by SRCCOPY_AND.
614 *
615 * NV04 doesn't have these methods implemented at all, and doesn't have the
616 * relevant bits in grobj. Instead, it'll allow rendering whenever bit 24
617 * is set. So we have to emulate them in software, internally keeping the
618 * same bits as NV05 does. Since grobjs are aligned to 16 bytes on nv04,
619 * but the last word isn't actually used for anything, we abuse it for this
620 * purpose.
621 *
622 * Actually, NV05 can optionally check bit 24 too, but we disable this since
623 * there's no use for it.
624 *
625 * For unknown reasons, NV04 implements surf3d binding in hardware as an
626 * exception. Also for unknown reasons, NV04 doesn't implement the clipping
627 * methods on the surf3d object, so we have to emulate them too.
628 */
629
630static void
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000631nv04_graph_set_ctx1(struct nouveau_channel *chan, u32 mask, u32 value)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000632{
633 struct drm_device *dev = chan->dev;
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000634 u32 instance = (nv_rd32(dev, NV04_PGRAPH_CTX_SWITCH4) & 0xffff) << 4;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000635 int subc = (nv_rd32(dev, NV04_PGRAPH_TRAPPED_ADDR) >> 13) & 0x7;
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000636 u32 tmp;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000637
638 tmp = nv_ri32(dev, instance);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000639 tmp &= ~mask;
640 tmp |= value;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000641
642 nv_wi32(dev, instance, tmp);
643 nv_wr32(dev, NV04_PGRAPH_CTX_SWITCH1, tmp);
Marcin Koƛcielnicki13c54432009-12-14 20:38:17 +0000644 nv_wr32(dev, NV04_PGRAPH_CTX_CACHE1 + (subc<<2), tmp);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000645}
646
647static void
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000648nv04_graph_set_ctx_val(struct nouveau_channel *chan, u32 mask, u32 value)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000649{
650 struct drm_device *dev = chan->dev;
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000651 u32 instance = (nv_rd32(dev, NV04_PGRAPH_CTX_SWITCH4) & 0xffff) << 4;
652 u32 tmp, ctx1;
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000653 int class, op, valid = 1;
654
655 ctx1 = nv_ri32(dev, instance);
656 class = ctx1 & 0xff;
657 op = (ctx1 >> 15) & 7;
658 tmp = nv_ri32(dev, instance + 0xc);
659 tmp &= ~mask;
660 tmp |= value;
661 nv_wi32(dev, instance + 0xc, tmp);
662
663 /* check for valid surf2d/surf_dst/surf_color */
664 if (!(tmp & 0x02000000))
665 valid = 0;
666 /* check for valid surf_src/surf_zeta */
667 if ((class == 0x1f || class == 0x48) && !(tmp & 0x04000000))
668 valid = 0;
669
670 switch (op) {
671 /* SRCCOPY_AND, SRCCOPY: no extra objects required */
672 case 0:
673 case 3:
674 break;
675 /* ROP_AND: requires pattern and rop */
676 case 1:
677 if (!(tmp & 0x18000000))
678 valid = 0;
679 break;
680 /* BLEND_AND: requires beta1 */
681 case 2:
682 if (!(tmp & 0x20000000))
683 valid = 0;
684 break;
685 /* SRCCOPY_PREMULT, BLEND_PREMULT: beta4 required */
686 case 4:
687 case 5:
688 if (!(tmp & 0x40000000))
689 valid = 0;
690 break;
691 }
692
693 nv04_graph_set_ctx1(chan, 0x01000000, valid << 24);
694}
695
696static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000697nv04_graph_mthd_set_operation(struct nouveau_channel *chan,
698 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000699{
700 if (data > 5)
701 return 1;
702 /* Old versions of the objects only accept first three operations. */
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000703 if (data > 2 && class < 0x40)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000704 return 1;
705 nv04_graph_set_ctx1(chan, 0x00038000, data << 15);
706 /* changing operation changes set of objects needed for validation */
707 nv04_graph_set_ctx_val(chan, 0, 0);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000708 return 0;
709}
710
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000711static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000712nv04_graph_mthd_surf3d_clip_h(struct nouveau_channel *chan,
713 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000714{
715 uint32_t min = data & 0xffff, max;
716 uint32_t w = data >> 16;
717 if (min & 0x8000)
718 /* too large */
719 return 1;
720 if (w & 0x8000)
721 /* yes, it accepts negative for some reason. */
722 w |= 0xffff0000;
723 max = min + w;
724 max &= 0x3ffff;
725 nv_wr32(chan->dev, 0x40053c, min);
726 nv_wr32(chan->dev, 0x400544, max);
727 return 0;
728}
729
730static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000731nv04_graph_mthd_surf3d_clip_v(struct nouveau_channel *chan,
732 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000733{
734 uint32_t min = data & 0xffff, max;
735 uint32_t w = data >> 16;
736 if (min & 0x8000)
737 /* too large */
738 return 1;
739 if (w & 0x8000)
740 /* yes, it accepts negative for some reason. */
741 w |= 0xffff0000;
742 max = min + w;
743 max &= 0x3ffff;
744 nv_wr32(chan->dev, 0x400540, min);
745 nv_wr32(chan->dev, 0x400548, max);
746 return 0;
747}
748
749static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000750nv04_graph_mthd_bind_surf2d(struct nouveau_channel *chan,
751 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000752{
753 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
754 case 0x30:
755 nv04_graph_set_ctx1(chan, 0x00004000, 0);
756 nv04_graph_set_ctx_val(chan, 0x02000000, 0);
757 return 0;
758 case 0x42:
759 nv04_graph_set_ctx1(chan, 0x00004000, 0);
760 nv04_graph_set_ctx_val(chan, 0x02000000, 0x02000000);
761 return 0;
762 }
763 return 1;
764}
765
766static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000767nv04_graph_mthd_bind_surf2d_swzsurf(struct nouveau_channel *chan,
768 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000769{
770 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
771 case 0x30:
772 nv04_graph_set_ctx1(chan, 0x00004000, 0);
773 nv04_graph_set_ctx_val(chan, 0x02000000, 0);
774 return 0;
775 case 0x42:
776 nv04_graph_set_ctx1(chan, 0x00004000, 0);
777 nv04_graph_set_ctx_val(chan, 0x02000000, 0x02000000);
778 return 0;
779 case 0x52:
780 nv04_graph_set_ctx1(chan, 0x00004000, 0x00004000);
781 nv04_graph_set_ctx_val(chan, 0x02000000, 0x02000000);
782 return 0;
783 }
784 return 1;
785}
786
787static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000788nv04_graph_mthd_bind_nv01_patt(struct nouveau_channel *chan,
789 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000790{
791 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
792 case 0x30:
793 nv04_graph_set_ctx_val(chan, 0x08000000, 0);
794 return 0;
795 case 0x18:
796 nv04_graph_set_ctx_val(chan, 0x08000000, 0x08000000);
797 return 0;
798 }
799 return 1;
800}
801
802static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000803nv04_graph_mthd_bind_nv04_patt(struct nouveau_channel *chan,
804 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000805{
806 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
807 case 0x30:
808 nv04_graph_set_ctx_val(chan, 0x08000000, 0);
809 return 0;
810 case 0x44:
811 nv04_graph_set_ctx_val(chan, 0x08000000, 0x08000000);
812 return 0;
813 }
814 return 1;
815}
816
817static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000818nv04_graph_mthd_bind_rop(struct nouveau_channel *chan,
819 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000820{
821 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
822 case 0x30:
823 nv04_graph_set_ctx_val(chan, 0x10000000, 0);
824 return 0;
825 case 0x43:
826 nv04_graph_set_ctx_val(chan, 0x10000000, 0x10000000);
827 return 0;
828 }
829 return 1;
830}
831
832static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000833nv04_graph_mthd_bind_beta1(struct nouveau_channel *chan,
834 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000835{
836 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
837 case 0x30:
838 nv04_graph_set_ctx_val(chan, 0x20000000, 0);
839 return 0;
840 case 0x12:
841 nv04_graph_set_ctx_val(chan, 0x20000000, 0x20000000);
842 return 0;
843 }
844 return 1;
845}
846
847static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000848nv04_graph_mthd_bind_beta4(struct nouveau_channel *chan,
849 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000850{
851 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
852 case 0x30:
853 nv04_graph_set_ctx_val(chan, 0x40000000, 0);
854 return 0;
855 case 0x72:
856 nv04_graph_set_ctx_val(chan, 0x40000000, 0x40000000);
857 return 0;
858 }
859 return 1;
860}
861
862static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000863nv04_graph_mthd_bind_surf_dst(struct nouveau_channel *chan,
864 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000865{
866 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
867 case 0x30:
868 nv04_graph_set_ctx_val(chan, 0x02000000, 0);
869 return 0;
870 case 0x58:
871 nv04_graph_set_ctx_val(chan, 0x02000000, 0x02000000);
872 return 0;
873 }
874 return 1;
875}
876
877static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000878nv04_graph_mthd_bind_surf_src(struct nouveau_channel *chan,
879 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000880{
881 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
882 case 0x30:
883 nv04_graph_set_ctx_val(chan, 0x04000000, 0);
884 return 0;
885 case 0x59:
886 nv04_graph_set_ctx_val(chan, 0x04000000, 0x04000000);
887 return 0;
888 }
889 return 1;
890}
891
892static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000893nv04_graph_mthd_bind_surf_color(struct nouveau_channel *chan,
894 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000895{
896 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
897 case 0x30:
898 nv04_graph_set_ctx_val(chan, 0x02000000, 0);
899 return 0;
900 case 0x5a:
901 nv04_graph_set_ctx_val(chan, 0x02000000, 0x02000000);
902 return 0;
903 }
904 return 1;
905}
906
907static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000908nv04_graph_mthd_bind_surf_zeta(struct nouveau_channel *chan,
909 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000910{
911 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
912 case 0x30:
913 nv04_graph_set_ctx_val(chan, 0x04000000, 0);
914 return 0;
915 case 0x5b:
916 nv04_graph_set_ctx_val(chan, 0x04000000, 0x04000000);
917 return 0;
918 }
919 return 1;
920}
921
922static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000923nv04_graph_mthd_bind_clip(struct nouveau_channel *chan,
924 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000925{
926 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
927 case 0x30:
928 nv04_graph_set_ctx1(chan, 0x2000, 0);
929 return 0;
930 case 0x19:
931 nv04_graph_set_ctx1(chan, 0x2000, 0x2000);
932 return 0;
933 }
934 return 1;
935}
936
937static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000938nv04_graph_mthd_bind_chroma(struct nouveau_channel *chan,
939 u32 class, u32 mthd, u32 data)
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000940{
941 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
942 case 0x30:
943 nv04_graph_set_ctx1(chan, 0x1000, 0);
944 return 0;
945 /* Yes, for some reason even the old versions of objects
946 * accept 0x57 and not 0x17. Consistency be damned.
947 */
948 case 0x57:
949 nv04_graph_set_ctx1(chan, 0x1000, 0x1000);
950 return 0;
951 }
952 return 1;
953}
954
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000955static int
956nv04_graph_register(struct drm_device *dev)
957{
958 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000959
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000960 if (dev_priv->engine.graph.registered)
961 return 0;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000962
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000963 /* dvd subpicture */
964 NVOBJ_CLASS(dev, 0x0038, GR);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000965
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000966 /* m2mf */
967 NVOBJ_CLASS(dev, 0x0039, GR);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000968
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000969 /* nv03 gdirect */
970 NVOBJ_CLASS(dev, 0x004b, GR);
971 NVOBJ_MTHD (dev, 0x004b, 0x0184, nv04_graph_mthd_bind_nv01_patt);
972 NVOBJ_MTHD (dev, 0x004b, 0x0188, nv04_graph_mthd_bind_rop);
973 NVOBJ_MTHD (dev, 0x004b, 0x018c, nv04_graph_mthd_bind_beta1);
974 NVOBJ_MTHD (dev, 0x004b, 0x0190, nv04_graph_mthd_bind_surf_dst);
975 NVOBJ_MTHD (dev, 0x004b, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000976
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000977 /* nv04 gdirect */
978 NVOBJ_CLASS(dev, 0x004a, GR);
979 NVOBJ_MTHD (dev, 0x004a, 0x0188, nv04_graph_mthd_bind_nv04_patt);
980 NVOBJ_MTHD (dev, 0x004a, 0x018c, nv04_graph_mthd_bind_rop);
981 NVOBJ_MTHD (dev, 0x004a, 0x0190, nv04_graph_mthd_bind_beta1);
982 NVOBJ_MTHD (dev, 0x004a, 0x0194, nv04_graph_mthd_bind_beta4);
983 NVOBJ_MTHD (dev, 0x004a, 0x0198, nv04_graph_mthd_bind_surf2d);
984 NVOBJ_MTHD (dev, 0x004a, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000985
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000986 /* nv01 imageblit */
987 NVOBJ_CLASS(dev, 0x001f, GR);
988 NVOBJ_MTHD (dev, 0x001f, 0x0184, nv04_graph_mthd_bind_chroma);
989 NVOBJ_MTHD (dev, 0x001f, 0x0188, nv04_graph_mthd_bind_clip);
990 NVOBJ_MTHD (dev, 0x001f, 0x018c, nv04_graph_mthd_bind_nv01_patt);
991 NVOBJ_MTHD (dev, 0x001f, 0x0190, nv04_graph_mthd_bind_rop);
992 NVOBJ_MTHD (dev, 0x001f, 0x0194, nv04_graph_mthd_bind_beta1);
993 NVOBJ_MTHD (dev, 0x001f, 0x0198, nv04_graph_mthd_bind_surf_dst);
994 NVOBJ_MTHD (dev, 0x001f, 0x019c, nv04_graph_mthd_bind_surf_src);
995 NVOBJ_MTHD (dev, 0x001f, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +0000996
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000997 /* nv04 imageblit */
998 NVOBJ_CLASS(dev, 0x005f, GR);
999 NVOBJ_MTHD (dev, 0x005f, 0x0184, nv04_graph_mthd_bind_chroma);
1000 NVOBJ_MTHD (dev, 0x005f, 0x0188, nv04_graph_mthd_bind_clip);
1001 NVOBJ_MTHD (dev, 0x005f, 0x018c, nv04_graph_mthd_bind_nv04_patt);
1002 NVOBJ_MTHD (dev, 0x005f, 0x0190, nv04_graph_mthd_bind_rop);
1003 NVOBJ_MTHD (dev, 0x005f, 0x0194, nv04_graph_mthd_bind_beta1);
1004 NVOBJ_MTHD (dev, 0x005f, 0x0198, nv04_graph_mthd_bind_beta4);
1005 NVOBJ_MTHD (dev, 0x005f, 0x019c, nv04_graph_mthd_bind_surf2d);
1006 NVOBJ_MTHD (dev, 0x005f, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +00001007
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001008 /* nv04 iifc */
1009 NVOBJ_CLASS(dev, 0x0060, GR);
1010 NVOBJ_MTHD (dev, 0x0060, 0x0188, nv04_graph_mthd_bind_chroma);
1011 NVOBJ_MTHD (dev, 0x0060, 0x018c, nv04_graph_mthd_bind_clip);
1012 NVOBJ_MTHD (dev, 0x0060, 0x0190, nv04_graph_mthd_bind_nv04_patt);
1013 NVOBJ_MTHD (dev, 0x0060, 0x0194, nv04_graph_mthd_bind_rop);
1014 NVOBJ_MTHD (dev, 0x0060, 0x0198, nv04_graph_mthd_bind_beta1);
1015 NVOBJ_MTHD (dev, 0x0060, 0x019c, nv04_graph_mthd_bind_beta4);
1016 NVOBJ_MTHD (dev, 0x0060, 0x01a0, nv04_graph_mthd_bind_surf2d_swzsurf);
1017 NVOBJ_MTHD (dev, 0x0060, 0x03e4, nv04_graph_mthd_set_operation);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +00001018
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001019 /* nv05 iifc */
1020 NVOBJ_CLASS(dev, 0x0064, GR);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +00001021
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001022 /* nv01 ifc */
1023 NVOBJ_CLASS(dev, 0x0021, GR);
1024 NVOBJ_MTHD (dev, 0x0021, 0x0184, nv04_graph_mthd_bind_chroma);
1025 NVOBJ_MTHD (dev, 0x0021, 0x0188, nv04_graph_mthd_bind_clip);
1026 NVOBJ_MTHD (dev, 0x0021, 0x018c, nv04_graph_mthd_bind_nv01_patt);
1027 NVOBJ_MTHD (dev, 0x0021, 0x0190, nv04_graph_mthd_bind_rop);
1028 NVOBJ_MTHD (dev, 0x0021, 0x0194, nv04_graph_mthd_bind_beta1);
1029 NVOBJ_MTHD (dev, 0x0021, 0x0198, nv04_graph_mthd_bind_surf_dst);
1030 NVOBJ_MTHD (dev, 0x0021, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +00001031
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001032 /* nv04 ifc */
1033 NVOBJ_CLASS(dev, 0x0061, GR);
1034 NVOBJ_MTHD (dev, 0x0061, 0x0184, nv04_graph_mthd_bind_chroma);
1035 NVOBJ_MTHD (dev, 0x0061, 0x0188, nv04_graph_mthd_bind_clip);
1036 NVOBJ_MTHD (dev, 0x0061, 0x018c, nv04_graph_mthd_bind_nv04_patt);
1037 NVOBJ_MTHD (dev, 0x0061, 0x0190, nv04_graph_mthd_bind_rop);
1038 NVOBJ_MTHD (dev, 0x0061, 0x0194, nv04_graph_mthd_bind_beta1);
1039 NVOBJ_MTHD (dev, 0x0061, 0x0198, nv04_graph_mthd_bind_beta4);
1040 NVOBJ_MTHD (dev, 0x0061, 0x019c, nv04_graph_mthd_bind_surf2d);
1041 NVOBJ_MTHD (dev, 0x0061, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +00001042
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001043 /* nv05 ifc */
1044 NVOBJ_CLASS(dev, 0x0065, GR);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +00001045
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001046 /* nv03 sifc */
1047 NVOBJ_CLASS(dev, 0x0036, GR);
1048 NVOBJ_MTHD (dev, 0x0036, 0x0184, nv04_graph_mthd_bind_chroma);
1049 NVOBJ_MTHD (dev, 0x0036, 0x0188, nv04_graph_mthd_bind_nv01_patt);
1050 NVOBJ_MTHD (dev, 0x0036, 0x018c, nv04_graph_mthd_bind_rop);
1051 NVOBJ_MTHD (dev, 0x0036, 0x0190, nv04_graph_mthd_bind_beta1);
1052 NVOBJ_MTHD (dev, 0x0036, 0x0194, nv04_graph_mthd_bind_surf_dst);
1053 NVOBJ_MTHD (dev, 0x0036, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +00001054
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001055 /* nv04 sifc */
1056 NVOBJ_CLASS(dev, 0x0076, GR);
1057 NVOBJ_MTHD (dev, 0x0076, 0x0184, nv04_graph_mthd_bind_chroma);
1058 NVOBJ_MTHD (dev, 0x0076, 0x0188, nv04_graph_mthd_bind_nv04_patt);
1059 NVOBJ_MTHD (dev, 0x0076, 0x018c, nv04_graph_mthd_bind_rop);
1060 NVOBJ_MTHD (dev, 0x0076, 0x0190, nv04_graph_mthd_bind_beta1);
1061 NVOBJ_MTHD (dev, 0x0076, 0x0194, nv04_graph_mthd_bind_beta4);
1062 NVOBJ_MTHD (dev, 0x0076, 0x0198, nv04_graph_mthd_bind_surf2d);
1063 NVOBJ_MTHD (dev, 0x0076, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Koƛcielnickif23d4cf2010-04-11 18:41:38 +00001064
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001065 /* nv05 sifc */
1066 NVOBJ_CLASS(dev, 0x0066, GR);
Ben Skeggs6ee73862009-12-11 19:24:15 +10001067
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001068 /* nv03 sifm */
1069 NVOBJ_CLASS(dev, 0x0037, GR);
1070 NVOBJ_MTHD (dev, 0x0037, 0x0188, nv04_graph_mthd_bind_nv01_patt);
1071 NVOBJ_MTHD (dev, 0x0037, 0x018c, nv04_graph_mthd_bind_rop);
1072 NVOBJ_MTHD (dev, 0x0037, 0x0190, nv04_graph_mthd_bind_beta1);
1073 NVOBJ_MTHD (dev, 0x0037, 0x0194, nv04_graph_mthd_bind_surf_dst);
1074 NVOBJ_MTHD (dev, 0x0037, 0x0304, nv04_graph_mthd_set_operation);
1075
1076 /* nv04 sifm */
1077 NVOBJ_CLASS(dev, 0x0077, GR);
1078 NVOBJ_MTHD (dev, 0x0077, 0x0188, nv04_graph_mthd_bind_nv04_patt);
1079 NVOBJ_MTHD (dev, 0x0077, 0x018c, nv04_graph_mthd_bind_rop);
1080 NVOBJ_MTHD (dev, 0x0077, 0x0190, nv04_graph_mthd_bind_beta1);
1081 NVOBJ_MTHD (dev, 0x0077, 0x0194, nv04_graph_mthd_bind_beta4);
1082 NVOBJ_MTHD (dev, 0x0077, 0x0198, nv04_graph_mthd_bind_surf2d_swzsurf);
1083 NVOBJ_MTHD (dev, 0x0077, 0x0304, nv04_graph_mthd_set_operation);
1084
1085 /* null */
1086 NVOBJ_CLASS(dev, 0x0030, GR);
1087
1088 /* surf2d */
1089 NVOBJ_CLASS(dev, 0x0042, GR);
1090
1091 /* rop */
1092 NVOBJ_CLASS(dev, 0x0043, GR);
1093
1094 /* beta1 */
1095 NVOBJ_CLASS(dev, 0x0012, GR);
1096
1097 /* beta4 */
1098 NVOBJ_CLASS(dev, 0x0072, GR);
1099
1100 /* cliprect */
1101 NVOBJ_CLASS(dev, 0x0019, GR);
1102
1103 /* nv01 pattern */
1104 NVOBJ_CLASS(dev, 0x0018, GR);
1105
1106 /* nv04 pattern */
1107 NVOBJ_CLASS(dev, 0x0044, GR);
1108
1109 /* swzsurf */
1110 NVOBJ_CLASS(dev, 0x0052, GR);
1111
1112 /* surf3d */
1113 NVOBJ_CLASS(dev, 0x0053, GR);
1114 NVOBJ_MTHD (dev, 0x0053, 0x02f8, nv04_graph_mthd_surf3d_clip_h);
1115 NVOBJ_MTHD (dev, 0x0053, 0x02fc, nv04_graph_mthd_surf3d_clip_v);
1116
1117 /* nv03 tex_tri */
1118 NVOBJ_CLASS(dev, 0x0048, GR);
1119 NVOBJ_MTHD (dev, 0x0048, 0x0188, nv04_graph_mthd_bind_clip);
1120 NVOBJ_MTHD (dev, 0x0048, 0x018c, nv04_graph_mthd_bind_surf_color);
1121 NVOBJ_MTHD (dev, 0x0048, 0x0190, nv04_graph_mthd_bind_surf_zeta);
1122
1123 /* tex_tri */
1124 NVOBJ_CLASS(dev, 0x0054, GR);
1125
1126 /* multitex_tri */
1127 NVOBJ_CLASS(dev, 0x0055, GR);
1128
1129 /* nv01 chroma */
1130 NVOBJ_CLASS(dev, 0x0017, GR);
1131
1132 /* nv04 chroma */
1133 NVOBJ_CLASS(dev, 0x0057, GR);
1134
1135 /* surf_dst */
1136 NVOBJ_CLASS(dev, 0x0058, GR);
1137
1138 /* surf_src */
1139 NVOBJ_CLASS(dev, 0x0059, GR);
1140
1141 /* surf_color */
1142 NVOBJ_CLASS(dev, 0x005a, GR);
1143
1144 /* surf_zeta */
1145 NVOBJ_CLASS(dev, 0x005b, GR);
1146
1147 /* nv01 line */
1148 NVOBJ_CLASS(dev, 0x001c, GR);
1149 NVOBJ_MTHD (dev, 0x001c, 0x0184, nv04_graph_mthd_bind_clip);
1150 NVOBJ_MTHD (dev, 0x001c, 0x0188, nv04_graph_mthd_bind_nv01_patt);
1151 NVOBJ_MTHD (dev, 0x001c, 0x018c, nv04_graph_mthd_bind_rop);
1152 NVOBJ_MTHD (dev, 0x001c, 0x0190, nv04_graph_mthd_bind_beta1);
1153 NVOBJ_MTHD (dev, 0x001c, 0x0194, nv04_graph_mthd_bind_surf_dst);
1154 NVOBJ_MTHD (dev, 0x001c, 0x02fc, nv04_graph_mthd_set_operation);
1155
1156 /* nv04 line */
1157 NVOBJ_CLASS(dev, 0x005c, GR);
1158 NVOBJ_MTHD (dev, 0x005c, 0x0184, nv04_graph_mthd_bind_clip);
1159 NVOBJ_MTHD (dev, 0x005c, 0x0188, nv04_graph_mthd_bind_nv04_patt);
1160 NVOBJ_MTHD (dev, 0x005c, 0x018c, nv04_graph_mthd_bind_rop);
1161 NVOBJ_MTHD (dev, 0x005c, 0x0190, nv04_graph_mthd_bind_beta1);
1162 NVOBJ_MTHD (dev, 0x005c, 0x0194, nv04_graph_mthd_bind_beta4);
1163 NVOBJ_MTHD (dev, 0x005c, 0x0198, nv04_graph_mthd_bind_surf2d);
1164 NVOBJ_MTHD (dev, 0x005c, 0x02fc, nv04_graph_mthd_set_operation);
1165
1166 /* nv01 tri */
1167 NVOBJ_CLASS(dev, 0x001d, GR);
1168 NVOBJ_MTHD (dev, 0x001d, 0x0184, nv04_graph_mthd_bind_clip);
1169 NVOBJ_MTHD (dev, 0x001d, 0x0188, nv04_graph_mthd_bind_nv01_patt);
1170 NVOBJ_MTHD (dev, 0x001d, 0x018c, nv04_graph_mthd_bind_rop);
1171 NVOBJ_MTHD (dev, 0x001d, 0x0190, nv04_graph_mthd_bind_beta1);
1172 NVOBJ_MTHD (dev, 0x001d, 0x0194, nv04_graph_mthd_bind_surf_dst);
1173 NVOBJ_MTHD (dev, 0x001d, 0x02fc, nv04_graph_mthd_set_operation);
1174
1175 /* nv04 tri */
1176 NVOBJ_CLASS(dev, 0x005d, GR);
1177 NVOBJ_MTHD (dev, 0x005d, 0x0184, nv04_graph_mthd_bind_clip);
1178 NVOBJ_MTHD (dev, 0x005d, 0x0188, nv04_graph_mthd_bind_nv04_patt);
1179 NVOBJ_MTHD (dev, 0x005d, 0x018c, nv04_graph_mthd_bind_rop);
1180 NVOBJ_MTHD (dev, 0x005d, 0x0190, nv04_graph_mthd_bind_beta1);
1181 NVOBJ_MTHD (dev, 0x005d, 0x0194, nv04_graph_mthd_bind_beta4);
1182 NVOBJ_MTHD (dev, 0x005d, 0x0198, nv04_graph_mthd_bind_surf2d);
1183 NVOBJ_MTHD (dev, 0x005d, 0x02fc, nv04_graph_mthd_set_operation);
1184
1185 /* nv01 rect */
1186 NVOBJ_CLASS(dev, 0x001e, GR);
1187 NVOBJ_MTHD (dev, 0x001e, 0x0184, nv04_graph_mthd_bind_clip);
1188 NVOBJ_MTHD (dev, 0x001e, 0x0188, nv04_graph_mthd_bind_nv01_patt);
1189 NVOBJ_MTHD (dev, 0x001e, 0x018c, nv04_graph_mthd_bind_rop);
1190 NVOBJ_MTHD (dev, 0x001e, 0x0190, nv04_graph_mthd_bind_beta1);
1191 NVOBJ_MTHD (dev, 0x001e, 0x0194, nv04_graph_mthd_bind_surf_dst);
1192 NVOBJ_MTHD (dev, 0x001e, 0x02fc, nv04_graph_mthd_set_operation);
1193
1194 /* nv04 rect */
1195 NVOBJ_CLASS(dev, 0x005e, GR);
1196 NVOBJ_MTHD (dev, 0x005e, 0x0184, nv04_graph_mthd_bind_clip);
1197 NVOBJ_MTHD (dev, 0x005e, 0x0188, nv04_graph_mthd_bind_nv04_patt);
1198 NVOBJ_MTHD (dev, 0x005e, 0x018c, nv04_graph_mthd_bind_rop);
1199 NVOBJ_MTHD (dev, 0x005e, 0x0190, nv04_graph_mthd_bind_beta1);
1200 NVOBJ_MTHD (dev, 0x005e, 0x0194, nv04_graph_mthd_bind_beta4);
1201 NVOBJ_MTHD (dev, 0x005e, 0x0198, nv04_graph_mthd_bind_surf2d);
1202 NVOBJ_MTHD (dev, 0x005e, 0x02fc, nv04_graph_mthd_set_operation);
1203
1204 /* nvsw */
1205 NVOBJ_CLASS(dev, 0x506e, SW);
1206 NVOBJ_MTHD (dev, 0x506e, 0x0150, nv04_graph_mthd_set_ref);
1207
1208 dev_priv->engine.graph.registered = true;
1209 return 0;
1210};