blob: 239519aefce6208da8bd0120356855ea71ef97f1 [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"
Francisco Jerez332b2422010-10-20 23:35:40 +020029#include "nouveau_hw.h"
Ben Skeggs6ee73862009-12-11 19:24:15 +100030
Ben Skeggsb8c157d2010-10-20 10:39:35 +100031static int nv04_graph_register(struct drm_device *dev);
32
Ben Skeggs6ee73862009-12-11 19:24:15 +100033static uint32_t nv04_graph_ctx_regs[] = {
Francisco Jerezea911a12009-12-26 14:39:46 +010034 0x0040053c,
35 0x00400544,
36 0x00400540,
37 0x00400548,
Ben Skeggs6ee73862009-12-11 19:24:15 +100038 NV04_PGRAPH_CTX_SWITCH1,
39 NV04_PGRAPH_CTX_SWITCH2,
40 NV04_PGRAPH_CTX_SWITCH3,
41 NV04_PGRAPH_CTX_SWITCH4,
42 NV04_PGRAPH_CTX_CACHE1,
43 NV04_PGRAPH_CTX_CACHE2,
44 NV04_PGRAPH_CTX_CACHE3,
45 NV04_PGRAPH_CTX_CACHE4,
46 0x00400184,
47 0x004001a4,
48 0x004001c4,
49 0x004001e4,
50 0x00400188,
51 0x004001a8,
52 0x004001c8,
53 0x004001e8,
54 0x0040018c,
55 0x004001ac,
56 0x004001cc,
57 0x004001ec,
58 0x00400190,
59 0x004001b0,
60 0x004001d0,
61 0x004001f0,
62 0x00400194,
63 0x004001b4,
64 0x004001d4,
65 0x004001f4,
66 0x00400198,
67 0x004001b8,
68 0x004001d8,
69 0x004001f8,
70 0x0040019c,
71 0x004001bc,
72 0x004001dc,
73 0x004001fc,
74 0x00400174,
75 NV04_PGRAPH_DMA_START_0,
76 NV04_PGRAPH_DMA_START_1,
77 NV04_PGRAPH_DMA_LENGTH,
78 NV04_PGRAPH_DMA_MISC,
79 NV04_PGRAPH_DMA_PITCH,
80 NV04_PGRAPH_BOFFSET0,
81 NV04_PGRAPH_BBASE0,
82 NV04_PGRAPH_BLIMIT0,
83 NV04_PGRAPH_BOFFSET1,
84 NV04_PGRAPH_BBASE1,
85 NV04_PGRAPH_BLIMIT1,
86 NV04_PGRAPH_BOFFSET2,
87 NV04_PGRAPH_BBASE2,
88 NV04_PGRAPH_BLIMIT2,
89 NV04_PGRAPH_BOFFSET3,
90 NV04_PGRAPH_BBASE3,
91 NV04_PGRAPH_BLIMIT3,
92 NV04_PGRAPH_BOFFSET4,
93 NV04_PGRAPH_BBASE4,
94 NV04_PGRAPH_BLIMIT4,
95 NV04_PGRAPH_BOFFSET5,
96 NV04_PGRAPH_BBASE5,
97 NV04_PGRAPH_BLIMIT5,
98 NV04_PGRAPH_BPITCH0,
99 NV04_PGRAPH_BPITCH1,
100 NV04_PGRAPH_BPITCH2,
101 NV04_PGRAPH_BPITCH3,
102 NV04_PGRAPH_BPITCH4,
103 NV04_PGRAPH_SURFACE,
104 NV04_PGRAPH_STATE,
105 NV04_PGRAPH_BSWIZZLE2,
106 NV04_PGRAPH_BSWIZZLE5,
107 NV04_PGRAPH_BPIXEL,
108 NV04_PGRAPH_NOTIFY,
109 NV04_PGRAPH_PATT_COLOR0,
110 NV04_PGRAPH_PATT_COLOR1,
111 NV04_PGRAPH_PATT_COLORRAM+0x00,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000112 NV04_PGRAPH_PATT_COLORRAM+0x04,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000113 NV04_PGRAPH_PATT_COLORRAM+0x08,
Francisco Jerezea911a12009-12-26 14:39:46 +0100114 NV04_PGRAPH_PATT_COLORRAM+0x0c,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000115 NV04_PGRAPH_PATT_COLORRAM+0x10,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000116 NV04_PGRAPH_PATT_COLORRAM+0x14,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000117 NV04_PGRAPH_PATT_COLORRAM+0x18,
Francisco Jerezea911a12009-12-26 14:39:46 +0100118 NV04_PGRAPH_PATT_COLORRAM+0x1c,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000119 NV04_PGRAPH_PATT_COLORRAM+0x20,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000120 NV04_PGRAPH_PATT_COLORRAM+0x24,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000121 NV04_PGRAPH_PATT_COLORRAM+0x28,
Francisco Jerezea911a12009-12-26 14:39:46 +0100122 NV04_PGRAPH_PATT_COLORRAM+0x2c,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000123 NV04_PGRAPH_PATT_COLORRAM+0x30,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000124 NV04_PGRAPH_PATT_COLORRAM+0x34,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000125 NV04_PGRAPH_PATT_COLORRAM+0x38,
Francisco Jerezea911a12009-12-26 14:39:46 +0100126 NV04_PGRAPH_PATT_COLORRAM+0x3c,
127 NV04_PGRAPH_PATT_COLORRAM+0x40,
128 NV04_PGRAPH_PATT_COLORRAM+0x44,
129 NV04_PGRAPH_PATT_COLORRAM+0x48,
130 NV04_PGRAPH_PATT_COLORRAM+0x4c,
131 NV04_PGRAPH_PATT_COLORRAM+0x50,
132 NV04_PGRAPH_PATT_COLORRAM+0x54,
133 NV04_PGRAPH_PATT_COLORRAM+0x58,
134 NV04_PGRAPH_PATT_COLORRAM+0x5c,
135 NV04_PGRAPH_PATT_COLORRAM+0x60,
136 NV04_PGRAPH_PATT_COLORRAM+0x64,
137 NV04_PGRAPH_PATT_COLORRAM+0x68,
138 NV04_PGRAPH_PATT_COLORRAM+0x6c,
139 NV04_PGRAPH_PATT_COLORRAM+0x70,
140 NV04_PGRAPH_PATT_COLORRAM+0x74,
141 NV04_PGRAPH_PATT_COLORRAM+0x78,
142 NV04_PGRAPH_PATT_COLORRAM+0x7c,
143 NV04_PGRAPH_PATT_COLORRAM+0x80,
144 NV04_PGRAPH_PATT_COLORRAM+0x84,
145 NV04_PGRAPH_PATT_COLORRAM+0x88,
146 NV04_PGRAPH_PATT_COLORRAM+0x8c,
147 NV04_PGRAPH_PATT_COLORRAM+0x90,
148 NV04_PGRAPH_PATT_COLORRAM+0x94,
149 NV04_PGRAPH_PATT_COLORRAM+0x98,
150 NV04_PGRAPH_PATT_COLORRAM+0x9c,
151 NV04_PGRAPH_PATT_COLORRAM+0xa0,
152 NV04_PGRAPH_PATT_COLORRAM+0xa4,
153 NV04_PGRAPH_PATT_COLORRAM+0xa8,
154 NV04_PGRAPH_PATT_COLORRAM+0xac,
155 NV04_PGRAPH_PATT_COLORRAM+0xb0,
156 NV04_PGRAPH_PATT_COLORRAM+0xb4,
157 NV04_PGRAPH_PATT_COLORRAM+0xb8,
158 NV04_PGRAPH_PATT_COLORRAM+0xbc,
159 NV04_PGRAPH_PATT_COLORRAM+0xc0,
160 NV04_PGRAPH_PATT_COLORRAM+0xc4,
161 NV04_PGRAPH_PATT_COLORRAM+0xc8,
162 NV04_PGRAPH_PATT_COLORRAM+0xcc,
163 NV04_PGRAPH_PATT_COLORRAM+0xd0,
164 NV04_PGRAPH_PATT_COLORRAM+0xd4,
165 NV04_PGRAPH_PATT_COLORRAM+0xd8,
166 NV04_PGRAPH_PATT_COLORRAM+0xdc,
167 NV04_PGRAPH_PATT_COLORRAM+0xe0,
168 NV04_PGRAPH_PATT_COLORRAM+0xe4,
169 NV04_PGRAPH_PATT_COLORRAM+0xe8,
170 NV04_PGRAPH_PATT_COLORRAM+0xec,
171 NV04_PGRAPH_PATT_COLORRAM+0xf0,
172 NV04_PGRAPH_PATT_COLORRAM+0xf4,
173 NV04_PGRAPH_PATT_COLORRAM+0xf8,
174 NV04_PGRAPH_PATT_COLORRAM+0xfc,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000175 NV04_PGRAPH_PATTERN,
176 0x0040080c,
177 NV04_PGRAPH_PATTERN_SHAPE,
178 0x00400600,
179 NV04_PGRAPH_ROP3,
180 NV04_PGRAPH_CHROMA,
181 NV04_PGRAPH_BETA_AND,
182 NV04_PGRAPH_BETA_PREMULT,
183 NV04_PGRAPH_CONTROL0,
184 NV04_PGRAPH_CONTROL1,
185 NV04_PGRAPH_CONTROL2,
186 NV04_PGRAPH_BLEND,
187 NV04_PGRAPH_STORED_FMT,
188 NV04_PGRAPH_SOURCE_COLOR,
189 0x00400560,
190 0x00400568,
191 0x00400564,
192 0x0040056c,
193 0x00400400,
194 0x00400480,
195 0x00400404,
196 0x00400484,
197 0x00400408,
198 0x00400488,
199 0x0040040c,
200 0x0040048c,
201 0x00400410,
202 0x00400490,
203 0x00400414,
204 0x00400494,
205 0x00400418,
206 0x00400498,
207 0x0040041c,
208 0x0040049c,
209 0x00400420,
210 0x004004a0,
211 0x00400424,
212 0x004004a4,
213 0x00400428,
214 0x004004a8,
215 0x0040042c,
216 0x004004ac,
217 0x00400430,
218 0x004004b0,
219 0x00400434,
220 0x004004b4,
221 0x00400438,
222 0x004004b8,
223 0x0040043c,
224 0x004004bc,
225 0x00400440,
226 0x004004c0,
227 0x00400444,
228 0x004004c4,
229 0x00400448,
230 0x004004c8,
231 0x0040044c,
232 0x004004cc,
233 0x00400450,
234 0x004004d0,
235 0x00400454,
236 0x004004d4,
237 0x00400458,
238 0x004004d8,
239 0x0040045c,
240 0x004004dc,
241 0x00400460,
242 0x004004e0,
243 0x00400464,
244 0x004004e4,
245 0x00400468,
246 0x004004e8,
247 0x0040046c,
248 0x004004ec,
249 0x00400470,
250 0x004004f0,
251 0x00400474,
252 0x004004f4,
253 0x00400478,
254 0x004004f8,
255 0x0040047c,
256 0x004004fc,
Ben Skeggs6ee73862009-12-11 19:24:15 +1000257 0x00400534,
258 0x00400538,
259 0x00400514,
260 0x00400518,
261 0x0040051c,
262 0x00400520,
263 0x00400524,
264 0x00400528,
265 0x0040052c,
266 0x00400530,
267 0x00400d00,
268 0x00400d40,
269 0x00400d80,
270 0x00400d04,
271 0x00400d44,
272 0x00400d84,
273 0x00400d08,
274 0x00400d48,
275 0x00400d88,
276 0x00400d0c,
277 0x00400d4c,
278 0x00400d8c,
279 0x00400d10,
280 0x00400d50,
281 0x00400d90,
282 0x00400d14,
283 0x00400d54,
284 0x00400d94,
285 0x00400d18,
286 0x00400d58,
287 0x00400d98,
288 0x00400d1c,
289 0x00400d5c,
290 0x00400d9c,
291 0x00400d20,
292 0x00400d60,
293 0x00400da0,
294 0x00400d24,
295 0x00400d64,
296 0x00400da4,
297 0x00400d28,
298 0x00400d68,
299 0x00400da8,
300 0x00400d2c,
301 0x00400d6c,
302 0x00400dac,
303 0x00400d30,
304 0x00400d70,
305 0x00400db0,
306 0x00400d34,
307 0x00400d74,
308 0x00400db4,
309 0x00400d38,
310 0x00400d78,
311 0x00400db8,
312 0x00400d3c,
313 0x00400d7c,
314 0x00400dbc,
315 0x00400590,
316 0x00400594,
317 0x00400598,
318 0x0040059c,
319 0x004005a8,
320 0x004005ac,
321 0x004005b0,
322 0x004005b4,
323 0x004005c0,
324 0x004005c4,
325 0x004005c8,
326 0x004005cc,
327 0x004005d0,
328 0x004005d4,
329 0x004005d8,
330 0x004005dc,
331 0x004005e0,
332 NV04_PGRAPH_PASSTHRU_0,
333 NV04_PGRAPH_PASSTHRU_1,
334 NV04_PGRAPH_PASSTHRU_2,
335 NV04_PGRAPH_DVD_COLORFMT,
336 NV04_PGRAPH_SCALED_FORMAT,
337 NV04_PGRAPH_MISC24_0,
338 NV04_PGRAPH_MISC24_1,
339 NV04_PGRAPH_MISC24_2,
340 0x00400500,
341 0x00400504,
342 NV04_PGRAPH_VALID1,
Francisco Jerezea911a12009-12-26 14:39:46 +0100343 NV04_PGRAPH_VALID2,
344 NV04_PGRAPH_DEBUG_3
Ben Skeggs6ee73862009-12-11 19:24:15 +1000345};
346
347struct graph_state {
Francisco Jerez6e86e042010-07-03 18:36:39 +0200348 uint32_t nv04[ARRAY_SIZE(nv04_graph_ctx_regs)];
Ben Skeggs6ee73862009-12-11 19:24:15 +1000349};
350
351struct nouveau_channel *
352nv04_graph_channel(struct drm_device *dev)
353{
354 struct drm_nouveau_private *dev_priv = dev->dev_private;
355 int chid = dev_priv->engine.fifo.channels;
356
357 if (nv_rd32(dev, NV04_PGRAPH_CTX_CONTROL) & 0x00010000)
358 chid = nv_rd32(dev, NV04_PGRAPH_CTX_USER) >> 24;
359
360 if (chid >= dev_priv->engine.fifo.channels)
361 return NULL;
362
Ben Skeggscff5c132010-10-06 16:16:59 +1000363 return dev_priv->channels.ptr[chid];
Ben Skeggs6ee73862009-12-11 19:24:15 +1000364}
365
366void
367nv04_graph_context_switch(struct drm_device *dev)
368{
369 struct drm_nouveau_private *dev_priv = dev->dev_private;
370 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
371 struct nouveau_channel *chan = NULL;
372 int chid;
373
374 pgraph->fifo_access(dev, false);
375 nouveau_wait_for_idle(dev);
376
377 /* If previous context is valid, we need to save it */
378 pgraph->unload_context(dev);
379
380 /* Load context for next channel */
381 chid = dev_priv->engine.fifo.channel_id(dev);
Ben Skeggscff5c132010-10-06 16:16:59 +1000382 chan = dev_priv->channels.ptr[chid];
Ben Skeggs6ee73862009-12-11 19:24:15 +1000383 if (chan)
384 nv04_graph_load_context(chan);
385
386 pgraph->fifo_access(dev, true);
387}
388
Francisco Jerezea911a12009-12-26 14:39:46 +0100389static uint32_t *ctx_reg(struct graph_state *ctx, uint32_t reg)
390{
391 int i;
392
393 for (i = 0; i < ARRAY_SIZE(nv04_graph_ctx_regs); i++) {
394 if (nv04_graph_ctx_regs[i] == reg)
395 return &ctx->nv04[i];
396 }
397
398 return NULL;
399}
400
Ben Skeggs6ee73862009-12-11 19:24:15 +1000401int nv04_graph_create_context(struct nouveau_channel *chan)
402{
403 struct graph_state *pgraph_ctx;
404 NV_DEBUG(chan->dev, "nv04_graph_context_create %d\n", chan->id);
405
406 chan->pgraph_ctx = pgraph_ctx = kzalloc(sizeof(*pgraph_ctx),
407 GFP_KERNEL);
408 if (pgraph_ctx == NULL)
409 return -ENOMEM;
410
Francisco Jerezea911a12009-12-26 14:39:46 +0100411 *ctx_reg(pgraph_ctx, NV04_PGRAPH_DEBUG_3) = 0xfad4ff31;
412
Ben Skeggs6ee73862009-12-11 19:24:15 +1000413 return 0;
414}
415
416void nv04_graph_destroy_context(struct nouveau_channel *chan)
417{
Francisco Jerez3945e472010-10-18 03:53:39 +0200418 struct drm_device *dev = chan->dev;
419 struct drm_nouveau_private *dev_priv = dev->dev_private;
420 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000421 struct graph_state *pgraph_ctx = chan->pgraph_ctx;
Francisco Jerez3945e472010-10-18 03:53:39 +0200422 unsigned long flags;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000423
Francisco Jerez3945e472010-10-18 03:53:39 +0200424 spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
425 pgraph->fifo_access(dev, false);
426
427 /* Unload the context if it's the currently active one */
428 if (pgraph->channel(dev) == chan)
429 pgraph->unload_context(dev);
430
431 /* Free the context resources */
Ben Skeggs6ee73862009-12-11 19:24:15 +1000432 kfree(pgraph_ctx);
433 chan->pgraph_ctx = NULL;
Francisco Jerez3945e472010-10-18 03:53:39 +0200434
435 pgraph->fifo_access(dev, true);
436 spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000437}
438
439int nv04_graph_load_context(struct nouveau_channel *chan)
440{
441 struct drm_device *dev = chan->dev;
442 struct graph_state *pgraph_ctx = chan->pgraph_ctx;
443 uint32_t tmp;
444 int i;
445
446 for (i = 0; i < ARRAY_SIZE(nv04_graph_ctx_regs); i++)
447 nv_wr32(dev, nv04_graph_ctx_regs[i], pgraph_ctx->nv04[i]);
448
449 nv_wr32(dev, NV04_PGRAPH_CTX_CONTROL, 0x10010100);
Francisco Jerezea911a12009-12-26 14:39:46 +0100450
451 tmp = nv_rd32(dev, NV04_PGRAPH_CTX_USER) & 0x00ffffff;
452 nv_wr32(dev, NV04_PGRAPH_CTX_USER, tmp | chan->id << 24);
453
Ben Skeggs6ee73862009-12-11 19:24:15 +1000454 tmp = nv_rd32(dev, NV04_PGRAPH_FFINTFC_ST2);
455 nv_wr32(dev, NV04_PGRAPH_FFINTFC_ST2, tmp & 0x000fffff);
Francisco Jerezea911a12009-12-26 14:39:46 +0100456
Ben Skeggs6ee73862009-12-11 19:24:15 +1000457 return 0;
458}
459
460int
461nv04_graph_unload_context(struct drm_device *dev)
462{
463 struct drm_nouveau_private *dev_priv = dev->dev_private;
464 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
465 struct nouveau_channel *chan = NULL;
466 struct graph_state *ctx;
467 uint32_t tmp;
468 int i;
469
470 chan = pgraph->channel(dev);
471 if (!chan)
472 return 0;
473 ctx = chan->pgraph_ctx;
474
475 for (i = 0; i < ARRAY_SIZE(nv04_graph_ctx_regs); i++)
476 ctx->nv04[i] = nv_rd32(dev, nv04_graph_ctx_regs[i]);
477
478 nv_wr32(dev, NV04_PGRAPH_CTX_CONTROL, 0x10000000);
479 tmp = nv_rd32(dev, NV04_PGRAPH_CTX_USER) & 0x00ffffff;
480 tmp |= (dev_priv->engine.fifo.channels - 1) << 24;
481 nv_wr32(dev, NV04_PGRAPH_CTX_USER, tmp);
482 return 0;
483}
484
485int nv04_graph_init(struct drm_device *dev)
486{
487 struct drm_nouveau_private *dev_priv = dev->dev_private;
488 uint32_t tmp;
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000489 int ret;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000490
491 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) &
492 ~NV_PMC_ENABLE_PGRAPH);
493 nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) |
494 NV_PMC_ENABLE_PGRAPH);
495
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000496 ret = nv04_graph_register(dev);
497 if (ret)
498 return ret;
499
Ben Skeggs6ee73862009-12-11 19:24:15 +1000500 /* Enable PGRAPH interrupts */
501 nv_wr32(dev, NV03_PGRAPH_INTR, 0xFFFFFFFF);
502 nv_wr32(dev, NV03_PGRAPH_INTR_EN, 0xFFFFFFFF);
503
504 nv_wr32(dev, NV04_PGRAPH_VALID1, 0);
505 nv_wr32(dev, NV04_PGRAPH_VALID2, 0);
506 /*nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x000001FF);
507 nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x001FFFFF);*/
508 nv_wr32(dev, NV04_PGRAPH_DEBUG_0, 0x1231c000);
509 /*1231C000 blob, 001 haiku*/
510 //*V_WRITE(NV04_PGRAPH_DEBUG_1, 0xf2d91100);*/
511 nv_wr32(dev, NV04_PGRAPH_DEBUG_1, 0x72111100);
512 /*0x72111100 blob , 01 haiku*/
513 /*nv_wr32(dev, NV04_PGRAPH_DEBUG_2, 0x11d5f870);*/
514 nv_wr32(dev, NV04_PGRAPH_DEBUG_2, 0x11d5f071);
515 /*haiku same*/
516
517 /*nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xfad4ff31);*/
518 nv_wr32(dev, NV04_PGRAPH_DEBUG_3, 0xf0d4ff31);
519 /*haiku and blob 10d4*/
520
521 nv_wr32(dev, NV04_PGRAPH_STATE , 0xFFFFFFFF);
522 nv_wr32(dev, NV04_PGRAPH_CTX_CONTROL , 0x10000100);
523 tmp = nv_rd32(dev, NV04_PGRAPH_CTX_USER) & 0x00ffffff;
Francisco Jerezea911a12009-12-26 14:39:46 +0100524 tmp |= (dev_priv->engine.fifo.channels - 1) << 24;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000525 nv_wr32(dev, NV04_PGRAPH_CTX_USER, tmp);
526
527 /* These don't belong here, they're part of a per-channel context */
528 nv_wr32(dev, NV04_PGRAPH_PATTERN_SHAPE, 0x00000000);
529 nv_wr32(dev, NV04_PGRAPH_BETA_AND , 0xFFFFFFFF);
530
531 return 0;
532}
533
534void nv04_graph_takedown(struct drm_device *dev)
535{
536}
537
538void
539nv04_graph_fifo_access(struct drm_device *dev, bool enabled)
540{
541 if (enabled)
542 nv_wr32(dev, NV04_PGRAPH_FIFO,
543 nv_rd32(dev, NV04_PGRAPH_FIFO) | 1);
544 else
545 nv_wr32(dev, NV04_PGRAPH_FIFO,
546 nv_rd32(dev, NV04_PGRAPH_FIFO) & ~1);
547}
548
549static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000550nv04_graph_mthd_set_ref(struct nouveau_channel *chan,
551 u32 class, u32 mthd, u32 data)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000552{
Ben Skeggs047d1d32010-05-31 12:00:43 +1000553 atomic_set(&chan->fence.last_sequence_irq, data);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000554 return 0;
555}
556
Francisco Jerez332b2422010-10-20 23:35:40 +0200557int
558nv04_graph_mthd_page_flip(struct nouveau_channel *chan,
559 u32 class, u32 mthd, u32 data)
560{
561 struct drm_device *dev = chan->dev;
562 struct nouveau_page_flip_state s;
563
564 if (!nouveau_finish_page_flip(chan, &s))
565 nv_set_crtc_base(dev, s.crtc,
566 s.offset + s.y * s.pitch + s.x * s.bpp / 8);
567
568 return 0;
569}
570
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000571/*
572 * Software methods, why they are needed, and how they all work:
573 *
574 * NV04 and NV05 keep most of the state in PGRAPH context itself, but some
575 * 2d engine settings are kept inside the grobjs themselves. The grobjs are
576 * 3 words long on both. grobj format on NV04 is:
577 *
578 * word 0:
579 * - bits 0-7: class
580 * - bit 12: color key active
581 * - bit 13: clip rect active
582 * - bit 14: if set, destination surface is swizzled and taken from buffer 5
583 * [set by NV04_SWIZZLED_SURFACE], otherwise it's linear and taken
584 * from buffer 0 [set by NV04_CONTEXT_SURFACES_2D or
585 * NV03_CONTEXT_SURFACE_DST].
586 * - bits 15-17: 2d operation [aka patch config]
587 * - bit 24: patch valid [enables rendering using this object]
588 * - bit 25: surf3d valid [for tex_tri and multitex_tri only]
589 * word 1:
590 * - bits 0-1: mono format
591 * - bits 8-13: color format
592 * - bits 16-31: DMA_NOTIFY instance
593 * word 2:
594 * - bits 0-15: DMA_A instance
595 * - bits 16-31: DMA_B instance
596 *
597 * On NV05 it's:
598 *
599 * word 0:
600 * - bits 0-7: class
601 * - bit 12: color key active
602 * - bit 13: clip rect active
603 * - bit 14: if set, destination surface is swizzled and taken from buffer 5
604 * [set by NV04_SWIZZLED_SURFACE], otherwise it's linear and taken
605 * from buffer 0 [set by NV04_CONTEXT_SURFACES_2D or
606 * NV03_CONTEXT_SURFACE_DST].
607 * - bits 15-17: 2d operation [aka patch config]
608 * - bits 20-22: dither mode
609 * - bit 24: patch valid [enables rendering using this object]
610 * - bit 25: surface_dst/surface_color/surf2d/surf3d valid
611 * - bit 26: surface_src/surface_zeta valid
612 * - bit 27: pattern valid
613 * - bit 28: rop valid
614 * - bit 29: beta1 valid
615 * - bit 30: beta4 valid
616 * word 1:
617 * - bits 0-1: mono format
618 * - bits 8-13: color format
619 * - bits 16-31: DMA_NOTIFY instance
620 * word 2:
621 * - bits 0-15: DMA_A instance
622 * - bits 16-31: DMA_B instance
623 *
624 * NV05 will set/unset the relevant valid bits when you poke the relevant
625 * object-binding methods with object of the proper type, or with the NULL
626 * type. It'll only allow rendering using the grobj if all needed objects
627 * are bound. The needed set of objects depends on selected operation: for
628 * example rop object is needed by ROP_AND, but not by SRCCOPY_AND.
629 *
630 * NV04 doesn't have these methods implemented at all, and doesn't have the
631 * relevant bits in grobj. Instead, it'll allow rendering whenever bit 24
632 * is set. So we have to emulate them in software, internally keeping the
633 * same bits as NV05 does. Since grobjs are aligned to 16 bytes on nv04,
634 * but the last word isn't actually used for anything, we abuse it for this
635 * purpose.
636 *
637 * Actually, NV05 can optionally check bit 24 too, but we disable this since
638 * there's no use for it.
639 *
640 * For unknown reasons, NV04 implements surf3d binding in hardware as an
641 * exception. Also for unknown reasons, NV04 doesn't implement the clipping
642 * methods on the surf3d object, so we have to emulate them too.
643 */
644
645static void
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000646nv04_graph_set_ctx1(struct nouveau_channel *chan, u32 mask, u32 value)
Ben Skeggs6ee73862009-12-11 19:24:15 +1000647{
648 struct drm_device *dev = chan->dev;
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000649 u32 instance = (nv_rd32(dev, NV04_PGRAPH_CTX_SWITCH4) & 0xffff) << 4;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000650 int subc = (nv_rd32(dev, NV04_PGRAPH_TRAPPED_ADDR) >> 13) & 0x7;
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000651 u32 tmp;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000652
653 tmp = nv_ri32(dev, instance);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000654 tmp &= ~mask;
655 tmp |= value;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000656
657 nv_wi32(dev, instance, tmp);
658 nv_wr32(dev, NV04_PGRAPH_CTX_SWITCH1, tmp);
Marcin Kościelnicki13c54432009-12-14 20:38:17 +0000659 nv_wr32(dev, NV04_PGRAPH_CTX_CACHE1 + (subc<<2), tmp);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000660}
661
662static void
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000663nv04_graph_set_ctx_val(struct nouveau_channel *chan, u32 mask, u32 value)
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000664{
665 struct drm_device *dev = chan->dev;
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000666 u32 instance = (nv_rd32(dev, NV04_PGRAPH_CTX_SWITCH4) & 0xffff) << 4;
667 u32 tmp, ctx1;
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000668 int class, op, valid = 1;
669
670 ctx1 = nv_ri32(dev, instance);
671 class = ctx1 & 0xff;
672 op = (ctx1 >> 15) & 7;
673 tmp = nv_ri32(dev, instance + 0xc);
674 tmp &= ~mask;
675 tmp |= value;
676 nv_wi32(dev, instance + 0xc, tmp);
677
678 /* check for valid surf2d/surf_dst/surf_color */
679 if (!(tmp & 0x02000000))
680 valid = 0;
681 /* check for valid surf_src/surf_zeta */
682 if ((class == 0x1f || class == 0x48) && !(tmp & 0x04000000))
683 valid = 0;
684
685 switch (op) {
686 /* SRCCOPY_AND, SRCCOPY: no extra objects required */
687 case 0:
688 case 3:
689 break;
690 /* ROP_AND: requires pattern and rop */
691 case 1:
692 if (!(tmp & 0x18000000))
693 valid = 0;
694 break;
695 /* BLEND_AND: requires beta1 */
696 case 2:
697 if (!(tmp & 0x20000000))
698 valid = 0;
699 break;
700 /* SRCCOPY_PREMULT, BLEND_PREMULT: beta4 required */
701 case 4:
702 case 5:
703 if (!(tmp & 0x40000000))
704 valid = 0;
705 break;
706 }
707
708 nv04_graph_set_ctx1(chan, 0x01000000, valid << 24);
709}
710
711static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000712nv04_graph_mthd_set_operation(struct nouveau_channel *chan,
713 u32 class, u32 mthd, u32 data)
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000714{
715 if (data > 5)
716 return 1;
717 /* Old versions of the objects only accept first three operations. */
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000718 if (data > 2 && class < 0x40)
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000719 return 1;
720 nv04_graph_set_ctx1(chan, 0x00038000, data << 15);
721 /* changing operation changes set of objects needed for validation */
722 nv04_graph_set_ctx_val(chan, 0, 0);
Ben Skeggs6ee73862009-12-11 19:24:15 +1000723 return 0;
724}
725
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000726static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000727nv04_graph_mthd_surf3d_clip_h(struct nouveau_channel *chan,
728 u32 class, u32 mthd, u32 data)
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000729{
730 uint32_t min = data & 0xffff, max;
731 uint32_t w = data >> 16;
732 if (min & 0x8000)
733 /* too large */
734 return 1;
735 if (w & 0x8000)
736 /* yes, it accepts negative for some reason. */
737 w |= 0xffff0000;
738 max = min + w;
739 max &= 0x3ffff;
740 nv_wr32(chan->dev, 0x40053c, min);
741 nv_wr32(chan->dev, 0x400544, max);
742 return 0;
743}
744
745static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000746nv04_graph_mthd_surf3d_clip_v(struct nouveau_channel *chan,
747 u32 class, u32 mthd, u32 data)
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000748{
749 uint32_t min = data & 0xffff, max;
750 uint32_t w = data >> 16;
751 if (min & 0x8000)
752 /* too large */
753 return 1;
754 if (w & 0x8000)
755 /* yes, it accepts negative for some reason. */
756 w |= 0xffff0000;
757 max = min + w;
758 max &= 0x3ffff;
759 nv_wr32(chan->dev, 0x400540, min);
760 nv_wr32(chan->dev, 0x400548, max);
761 return 0;
762}
763
764static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000765nv04_graph_mthd_bind_surf2d(struct nouveau_channel *chan,
766 u32 class, u32 mthd, u32 data)
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000767{
768 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
769 case 0x30:
770 nv04_graph_set_ctx1(chan, 0x00004000, 0);
771 nv04_graph_set_ctx_val(chan, 0x02000000, 0);
772 return 0;
773 case 0x42:
774 nv04_graph_set_ctx1(chan, 0x00004000, 0);
775 nv04_graph_set_ctx_val(chan, 0x02000000, 0x02000000);
776 return 0;
777 }
778 return 1;
779}
780
781static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000782nv04_graph_mthd_bind_surf2d_swzsurf(struct nouveau_channel *chan,
783 u32 class, u32 mthd, u32 data)
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000784{
785 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
786 case 0x30:
787 nv04_graph_set_ctx1(chan, 0x00004000, 0);
788 nv04_graph_set_ctx_val(chan, 0x02000000, 0);
789 return 0;
790 case 0x42:
791 nv04_graph_set_ctx1(chan, 0x00004000, 0);
792 nv04_graph_set_ctx_val(chan, 0x02000000, 0x02000000);
793 return 0;
794 case 0x52:
795 nv04_graph_set_ctx1(chan, 0x00004000, 0x00004000);
796 nv04_graph_set_ctx_val(chan, 0x02000000, 0x02000000);
797 return 0;
798 }
799 return 1;
800}
801
802static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000803nv04_graph_mthd_bind_nv01_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 0x18:
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_nv04_patt(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, 0x08000000, 0);
824 return 0;
825 case 0x44:
826 nv04_graph_set_ctx_val(chan, 0x08000000, 0x08000000);
827 return 0;
828 }
829 return 1;
830}
831
832static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000833nv04_graph_mthd_bind_rop(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, 0x10000000, 0);
839 return 0;
840 case 0x43:
841 nv04_graph_set_ctx_val(chan, 0x10000000, 0x10000000);
842 return 0;
843 }
844 return 1;
845}
846
847static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000848nv04_graph_mthd_bind_beta1(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, 0x20000000, 0);
854 return 0;
855 case 0x12:
856 nv04_graph_set_ctx_val(chan, 0x20000000, 0x20000000);
857 return 0;
858 }
859 return 1;
860}
861
862static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000863nv04_graph_mthd_bind_beta4(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, 0x40000000, 0);
869 return 0;
870 case 0x72:
871 nv04_graph_set_ctx_val(chan, 0x40000000, 0x40000000);
872 return 0;
873 }
874 return 1;
875}
876
877static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000878nv04_graph_mthd_bind_surf_dst(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, 0x02000000, 0);
884 return 0;
885 case 0x58:
886 nv04_graph_set_ctx_val(chan, 0x02000000, 0x02000000);
887 return 0;
888 }
889 return 1;
890}
891
892static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000893nv04_graph_mthd_bind_surf_src(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, 0x04000000, 0);
899 return 0;
900 case 0x59:
901 nv04_graph_set_ctx_val(chan, 0x04000000, 0x04000000);
902 return 0;
903 }
904 return 1;
905}
906
907static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000908nv04_graph_mthd_bind_surf_color(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, 0x02000000, 0);
914 return 0;
915 case 0x5a:
916 nv04_graph_set_ctx_val(chan, 0x02000000, 0x02000000);
917 return 0;
918 }
919 return 1;
920}
921
922static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000923nv04_graph_mthd_bind_surf_zeta(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_ctx_val(chan, 0x04000000, 0);
929 return 0;
930 case 0x5b:
931 nv04_graph_set_ctx_val(chan, 0x04000000, 0x04000000);
932 return 0;
933 }
934 return 1;
935}
936
937static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000938nv04_graph_mthd_bind_clip(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, 0x2000, 0);
944 return 0;
945 case 0x19:
946 nv04_graph_set_ctx1(chan, 0x2000, 0x2000);
947 return 0;
948 }
949 return 1;
950}
951
952static int
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000953nv04_graph_mthd_bind_chroma(struct nouveau_channel *chan,
954 u32 class, u32 mthd, u32 data)
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000955{
956 switch (nv_ri32(chan->dev, data << 4) & 0xff) {
957 case 0x30:
958 nv04_graph_set_ctx1(chan, 0x1000, 0);
959 return 0;
960 /* Yes, for some reason even the old versions of objects
961 * accept 0x57 and not 0x17. Consistency be damned.
962 */
963 case 0x57:
964 nv04_graph_set_ctx1(chan, 0x1000, 0x1000);
965 return 0;
966 }
967 return 1;
968}
969
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000970static int
971nv04_graph_register(struct drm_device *dev)
972{
973 struct drm_nouveau_private *dev_priv = dev->dev_private;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000974
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000975 if (dev_priv->engine.graph.registered)
976 return 0;
Ben Skeggs6ee73862009-12-11 19:24:15 +1000977
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000978 /* dvd subpicture */
979 NVOBJ_CLASS(dev, 0x0038, GR);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000980
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000981 /* m2mf */
982 NVOBJ_CLASS(dev, 0x0039, GR);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000983
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000984 /* nv03 gdirect */
985 NVOBJ_CLASS(dev, 0x004b, GR);
986 NVOBJ_MTHD (dev, 0x004b, 0x0184, nv04_graph_mthd_bind_nv01_patt);
987 NVOBJ_MTHD (dev, 0x004b, 0x0188, nv04_graph_mthd_bind_rop);
988 NVOBJ_MTHD (dev, 0x004b, 0x018c, nv04_graph_mthd_bind_beta1);
989 NVOBJ_MTHD (dev, 0x004b, 0x0190, nv04_graph_mthd_bind_surf_dst);
990 NVOBJ_MTHD (dev, 0x004b, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +0000991
Ben Skeggsb8c157d2010-10-20 10:39:35 +1000992 /* nv04 gdirect */
993 NVOBJ_CLASS(dev, 0x004a, GR);
994 NVOBJ_MTHD (dev, 0x004a, 0x0188, nv04_graph_mthd_bind_nv04_patt);
995 NVOBJ_MTHD (dev, 0x004a, 0x018c, nv04_graph_mthd_bind_rop);
996 NVOBJ_MTHD (dev, 0x004a, 0x0190, nv04_graph_mthd_bind_beta1);
997 NVOBJ_MTHD (dev, 0x004a, 0x0194, nv04_graph_mthd_bind_beta4);
998 NVOBJ_MTHD (dev, 0x004a, 0x0198, nv04_graph_mthd_bind_surf2d);
999 NVOBJ_MTHD (dev, 0x004a, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +00001000
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001001 /* nv01 imageblit */
1002 NVOBJ_CLASS(dev, 0x001f, GR);
1003 NVOBJ_MTHD (dev, 0x001f, 0x0184, nv04_graph_mthd_bind_chroma);
1004 NVOBJ_MTHD (dev, 0x001f, 0x0188, nv04_graph_mthd_bind_clip);
1005 NVOBJ_MTHD (dev, 0x001f, 0x018c, nv04_graph_mthd_bind_nv01_patt);
1006 NVOBJ_MTHD (dev, 0x001f, 0x0190, nv04_graph_mthd_bind_rop);
1007 NVOBJ_MTHD (dev, 0x001f, 0x0194, nv04_graph_mthd_bind_beta1);
1008 NVOBJ_MTHD (dev, 0x001f, 0x0198, nv04_graph_mthd_bind_surf_dst);
1009 NVOBJ_MTHD (dev, 0x001f, 0x019c, nv04_graph_mthd_bind_surf_src);
1010 NVOBJ_MTHD (dev, 0x001f, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +00001011
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001012 /* nv04 imageblit */
1013 NVOBJ_CLASS(dev, 0x005f, GR);
1014 NVOBJ_MTHD (dev, 0x005f, 0x0184, nv04_graph_mthd_bind_chroma);
1015 NVOBJ_MTHD (dev, 0x005f, 0x0188, nv04_graph_mthd_bind_clip);
1016 NVOBJ_MTHD (dev, 0x005f, 0x018c, nv04_graph_mthd_bind_nv04_patt);
1017 NVOBJ_MTHD (dev, 0x005f, 0x0190, nv04_graph_mthd_bind_rop);
1018 NVOBJ_MTHD (dev, 0x005f, 0x0194, nv04_graph_mthd_bind_beta1);
1019 NVOBJ_MTHD (dev, 0x005f, 0x0198, nv04_graph_mthd_bind_beta4);
1020 NVOBJ_MTHD (dev, 0x005f, 0x019c, nv04_graph_mthd_bind_surf2d);
1021 NVOBJ_MTHD (dev, 0x005f, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +00001022
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001023 /* nv04 iifc */
1024 NVOBJ_CLASS(dev, 0x0060, GR);
1025 NVOBJ_MTHD (dev, 0x0060, 0x0188, nv04_graph_mthd_bind_chroma);
1026 NVOBJ_MTHD (dev, 0x0060, 0x018c, nv04_graph_mthd_bind_clip);
1027 NVOBJ_MTHD (dev, 0x0060, 0x0190, nv04_graph_mthd_bind_nv04_patt);
1028 NVOBJ_MTHD (dev, 0x0060, 0x0194, nv04_graph_mthd_bind_rop);
1029 NVOBJ_MTHD (dev, 0x0060, 0x0198, nv04_graph_mthd_bind_beta1);
1030 NVOBJ_MTHD (dev, 0x0060, 0x019c, nv04_graph_mthd_bind_beta4);
1031 NVOBJ_MTHD (dev, 0x0060, 0x01a0, nv04_graph_mthd_bind_surf2d_swzsurf);
1032 NVOBJ_MTHD (dev, 0x0060, 0x03e4, nv04_graph_mthd_set_operation);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +00001033
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001034 /* nv05 iifc */
1035 NVOBJ_CLASS(dev, 0x0064, GR);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +00001036
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001037 /* nv01 ifc */
1038 NVOBJ_CLASS(dev, 0x0021, GR);
1039 NVOBJ_MTHD (dev, 0x0021, 0x0184, nv04_graph_mthd_bind_chroma);
1040 NVOBJ_MTHD (dev, 0x0021, 0x0188, nv04_graph_mthd_bind_clip);
1041 NVOBJ_MTHD (dev, 0x0021, 0x018c, nv04_graph_mthd_bind_nv01_patt);
1042 NVOBJ_MTHD (dev, 0x0021, 0x0190, nv04_graph_mthd_bind_rop);
1043 NVOBJ_MTHD (dev, 0x0021, 0x0194, nv04_graph_mthd_bind_beta1);
1044 NVOBJ_MTHD (dev, 0x0021, 0x0198, nv04_graph_mthd_bind_surf_dst);
1045 NVOBJ_MTHD (dev, 0x0021, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +00001046
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001047 /* nv04 ifc */
1048 NVOBJ_CLASS(dev, 0x0061, GR);
1049 NVOBJ_MTHD (dev, 0x0061, 0x0184, nv04_graph_mthd_bind_chroma);
1050 NVOBJ_MTHD (dev, 0x0061, 0x0188, nv04_graph_mthd_bind_clip);
1051 NVOBJ_MTHD (dev, 0x0061, 0x018c, nv04_graph_mthd_bind_nv04_patt);
1052 NVOBJ_MTHD (dev, 0x0061, 0x0190, nv04_graph_mthd_bind_rop);
1053 NVOBJ_MTHD (dev, 0x0061, 0x0194, nv04_graph_mthd_bind_beta1);
1054 NVOBJ_MTHD (dev, 0x0061, 0x0198, nv04_graph_mthd_bind_beta4);
1055 NVOBJ_MTHD (dev, 0x0061, 0x019c, nv04_graph_mthd_bind_surf2d);
1056 NVOBJ_MTHD (dev, 0x0061, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +00001057
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001058 /* nv05 ifc */
1059 NVOBJ_CLASS(dev, 0x0065, GR);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +00001060
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001061 /* nv03 sifc */
1062 NVOBJ_CLASS(dev, 0x0036, GR);
1063 NVOBJ_MTHD (dev, 0x0036, 0x0184, nv04_graph_mthd_bind_chroma);
1064 NVOBJ_MTHD (dev, 0x0036, 0x0188, nv04_graph_mthd_bind_nv01_patt);
1065 NVOBJ_MTHD (dev, 0x0036, 0x018c, nv04_graph_mthd_bind_rop);
1066 NVOBJ_MTHD (dev, 0x0036, 0x0190, nv04_graph_mthd_bind_beta1);
1067 NVOBJ_MTHD (dev, 0x0036, 0x0194, nv04_graph_mthd_bind_surf_dst);
1068 NVOBJ_MTHD (dev, 0x0036, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +00001069
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001070 /* nv04 sifc */
1071 NVOBJ_CLASS(dev, 0x0076, GR);
1072 NVOBJ_MTHD (dev, 0x0076, 0x0184, nv04_graph_mthd_bind_chroma);
1073 NVOBJ_MTHD (dev, 0x0076, 0x0188, nv04_graph_mthd_bind_nv04_patt);
1074 NVOBJ_MTHD (dev, 0x0076, 0x018c, nv04_graph_mthd_bind_rop);
1075 NVOBJ_MTHD (dev, 0x0076, 0x0190, nv04_graph_mthd_bind_beta1);
1076 NVOBJ_MTHD (dev, 0x0076, 0x0194, nv04_graph_mthd_bind_beta4);
1077 NVOBJ_MTHD (dev, 0x0076, 0x0198, nv04_graph_mthd_bind_surf2d);
1078 NVOBJ_MTHD (dev, 0x0076, 0x02fc, nv04_graph_mthd_set_operation);
Marcin Kościelnickif23d4cf2010-04-11 18:41:38 +00001079
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001080 /* nv05 sifc */
1081 NVOBJ_CLASS(dev, 0x0066, GR);
Ben Skeggs6ee73862009-12-11 19:24:15 +10001082
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001083 /* nv03 sifm */
1084 NVOBJ_CLASS(dev, 0x0037, GR);
1085 NVOBJ_MTHD (dev, 0x0037, 0x0188, nv04_graph_mthd_bind_nv01_patt);
1086 NVOBJ_MTHD (dev, 0x0037, 0x018c, nv04_graph_mthd_bind_rop);
1087 NVOBJ_MTHD (dev, 0x0037, 0x0190, nv04_graph_mthd_bind_beta1);
1088 NVOBJ_MTHD (dev, 0x0037, 0x0194, nv04_graph_mthd_bind_surf_dst);
1089 NVOBJ_MTHD (dev, 0x0037, 0x0304, nv04_graph_mthd_set_operation);
1090
1091 /* nv04 sifm */
1092 NVOBJ_CLASS(dev, 0x0077, GR);
1093 NVOBJ_MTHD (dev, 0x0077, 0x0188, nv04_graph_mthd_bind_nv04_patt);
1094 NVOBJ_MTHD (dev, 0x0077, 0x018c, nv04_graph_mthd_bind_rop);
1095 NVOBJ_MTHD (dev, 0x0077, 0x0190, nv04_graph_mthd_bind_beta1);
1096 NVOBJ_MTHD (dev, 0x0077, 0x0194, nv04_graph_mthd_bind_beta4);
1097 NVOBJ_MTHD (dev, 0x0077, 0x0198, nv04_graph_mthd_bind_surf2d_swzsurf);
1098 NVOBJ_MTHD (dev, 0x0077, 0x0304, nv04_graph_mthd_set_operation);
1099
1100 /* null */
1101 NVOBJ_CLASS(dev, 0x0030, GR);
1102
1103 /* surf2d */
1104 NVOBJ_CLASS(dev, 0x0042, GR);
1105
1106 /* rop */
1107 NVOBJ_CLASS(dev, 0x0043, GR);
1108
1109 /* beta1 */
1110 NVOBJ_CLASS(dev, 0x0012, GR);
1111
1112 /* beta4 */
1113 NVOBJ_CLASS(dev, 0x0072, GR);
1114
1115 /* cliprect */
1116 NVOBJ_CLASS(dev, 0x0019, GR);
1117
1118 /* nv01 pattern */
1119 NVOBJ_CLASS(dev, 0x0018, GR);
1120
1121 /* nv04 pattern */
1122 NVOBJ_CLASS(dev, 0x0044, GR);
1123
1124 /* swzsurf */
1125 NVOBJ_CLASS(dev, 0x0052, GR);
1126
1127 /* surf3d */
1128 NVOBJ_CLASS(dev, 0x0053, GR);
1129 NVOBJ_MTHD (dev, 0x0053, 0x02f8, nv04_graph_mthd_surf3d_clip_h);
1130 NVOBJ_MTHD (dev, 0x0053, 0x02fc, nv04_graph_mthd_surf3d_clip_v);
1131
1132 /* nv03 tex_tri */
1133 NVOBJ_CLASS(dev, 0x0048, GR);
1134 NVOBJ_MTHD (dev, 0x0048, 0x0188, nv04_graph_mthd_bind_clip);
1135 NVOBJ_MTHD (dev, 0x0048, 0x018c, nv04_graph_mthd_bind_surf_color);
1136 NVOBJ_MTHD (dev, 0x0048, 0x0190, nv04_graph_mthd_bind_surf_zeta);
1137
1138 /* tex_tri */
1139 NVOBJ_CLASS(dev, 0x0054, GR);
1140
1141 /* multitex_tri */
1142 NVOBJ_CLASS(dev, 0x0055, GR);
1143
1144 /* nv01 chroma */
1145 NVOBJ_CLASS(dev, 0x0017, GR);
1146
1147 /* nv04 chroma */
1148 NVOBJ_CLASS(dev, 0x0057, GR);
1149
1150 /* surf_dst */
1151 NVOBJ_CLASS(dev, 0x0058, GR);
1152
1153 /* surf_src */
1154 NVOBJ_CLASS(dev, 0x0059, GR);
1155
1156 /* surf_color */
1157 NVOBJ_CLASS(dev, 0x005a, GR);
1158
1159 /* surf_zeta */
1160 NVOBJ_CLASS(dev, 0x005b, GR);
1161
1162 /* nv01 line */
1163 NVOBJ_CLASS(dev, 0x001c, GR);
1164 NVOBJ_MTHD (dev, 0x001c, 0x0184, nv04_graph_mthd_bind_clip);
1165 NVOBJ_MTHD (dev, 0x001c, 0x0188, nv04_graph_mthd_bind_nv01_patt);
1166 NVOBJ_MTHD (dev, 0x001c, 0x018c, nv04_graph_mthd_bind_rop);
1167 NVOBJ_MTHD (dev, 0x001c, 0x0190, nv04_graph_mthd_bind_beta1);
1168 NVOBJ_MTHD (dev, 0x001c, 0x0194, nv04_graph_mthd_bind_surf_dst);
1169 NVOBJ_MTHD (dev, 0x001c, 0x02fc, nv04_graph_mthd_set_operation);
1170
1171 /* nv04 line */
1172 NVOBJ_CLASS(dev, 0x005c, GR);
1173 NVOBJ_MTHD (dev, 0x005c, 0x0184, nv04_graph_mthd_bind_clip);
1174 NVOBJ_MTHD (dev, 0x005c, 0x0188, nv04_graph_mthd_bind_nv04_patt);
1175 NVOBJ_MTHD (dev, 0x005c, 0x018c, nv04_graph_mthd_bind_rop);
1176 NVOBJ_MTHD (dev, 0x005c, 0x0190, nv04_graph_mthd_bind_beta1);
1177 NVOBJ_MTHD (dev, 0x005c, 0x0194, nv04_graph_mthd_bind_beta4);
1178 NVOBJ_MTHD (dev, 0x005c, 0x0198, nv04_graph_mthd_bind_surf2d);
1179 NVOBJ_MTHD (dev, 0x005c, 0x02fc, nv04_graph_mthd_set_operation);
1180
1181 /* nv01 tri */
1182 NVOBJ_CLASS(dev, 0x001d, GR);
1183 NVOBJ_MTHD (dev, 0x001d, 0x0184, nv04_graph_mthd_bind_clip);
1184 NVOBJ_MTHD (dev, 0x001d, 0x0188, nv04_graph_mthd_bind_nv01_patt);
1185 NVOBJ_MTHD (dev, 0x001d, 0x018c, nv04_graph_mthd_bind_rop);
1186 NVOBJ_MTHD (dev, 0x001d, 0x0190, nv04_graph_mthd_bind_beta1);
1187 NVOBJ_MTHD (dev, 0x001d, 0x0194, nv04_graph_mthd_bind_surf_dst);
1188 NVOBJ_MTHD (dev, 0x001d, 0x02fc, nv04_graph_mthd_set_operation);
1189
1190 /* nv04 tri */
1191 NVOBJ_CLASS(dev, 0x005d, GR);
1192 NVOBJ_MTHD (dev, 0x005d, 0x0184, nv04_graph_mthd_bind_clip);
1193 NVOBJ_MTHD (dev, 0x005d, 0x0188, nv04_graph_mthd_bind_nv04_patt);
1194 NVOBJ_MTHD (dev, 0x005d, 0x018c, nv04_graph_mthd_bind_rop);
1195 NVOBJ_MTHD (dev, 0x005d, 0x0190, nv04_graph_mthd_bind_beta1);
1196 NVOBJ_MTHD (dev, 0x005d, 0x0194, nv04_graph_mthd_bind_beta4);
1197 NVOBJ_MTHD (dev, 0x005d, 0x0198, nv04_graph_mthd_bind_surf2d);
1198 NVOBJ_MTHD (dev, 0x005d, 0x02fc, nv04_graph_mthd_set_operation);
1199
1200 /* nv01 rect */
1201 NVOBJ_CLASS(dev, 0x001e, GR);
1202 NVOBJ_MTHD (dev, 0x001e, 0x0184, nv04_graph_mthd_bind_clip);
1203 NVOBJ_MTHD (dev, 0x001e, 0x0188, nv04_graph_mthd_bind_nv01_patt);
1204 NVOBJ_MTHD (dev, 0x001e, 0x018c, nv04_graph_mthd_bind_rop);
1205 NVOBJ_MTHD (dev, 0x001e, 0x0190, nv04_graph_mthd_bind_beta1);
1206 NVOBJ_MTHD (dev, 0x001e, 0x0194, nv04_graph_mthd_bind_surf_dst);
1207 NVOBJ_MTHD (dev, 0x001e, 0x02fc, nv04_graph_mthd_set_operation);
1208
1209 /* nv04 rect */
1210 NVOBJ_CLASS(dev, 0x005e, GR);
1211 NVOBJ_MTHD (dev, 0x005e, 0x0184, nv04_graph_mthd_bind_clip);
1212 NVOBJ_MTHD (dev, 0x005e, 0x0188, nv04_graph_mthd_bind_nv04_patt);
1213 NVOBJ_MTHD (dev, 0x005e, 0x018c, nv04_graph_mthd_bind_rop);
1214 NVOBJ_MTHD (dev, 0x005e, 0x0190, nv04_graph_mthd_bind_beta1);
1215 NVOBJ_MTHD (dev, 0x005e, 0x0194, nv04_graph_mthd_bind_beta4);
1216 NVOBJ_MTHD (dev, 0x005e, 0x0198, nv04_graph_mthd_bind_surf2d);
1217 NVOBJ_MTHD (dev, 0x005e, 0x02fc, nv04_graph_mthd_set_operation);
1218
1219 /* nvsw */
1220 NVOBJ_CLASS(dev, 0x506e, SW);
1221 NVOBJ_MTHD (dev, 0x506e, 0x0150, nv04_graph_mthd_set_ref);
Francisco Jerez332b2422010-10-20 23:35:40 +02001222 NVOBJ_MTHD (dev, 0x506e, 0x0500, nv04_graph_mthd_page_flip);
Ben Skeggsb8c157d2010-10-20 10:39:35 +10001223
1224 dev_priv->engine.graph.registered = true;
1225 return 0;
1226};