1 #include "nv_include.h"
4 NVAccelInitNullObject(ScrnInfoPtr pScrn)
6 NVPtr pNv = NVPTR(pScrn);
7 static int have_object = FALSE;
10 if (!NVDmaCreateContextObject(pNv, NvNullObject, NV01_NULL))
19 NVAccelGetPixmapOffset(PixmapPtr pPix)
21 ScrnInfoPtr pScrn = xf86Screens[pPix->drawable.pScreen->myNum];
22 NVPtr pNv = NVPTR(pScrn);
25 offset = exaGetPixmapOffset(pPix);
26 if (offset >= pNv->FB->size) {
27 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
28 "AII, passed bad pixmap: offset 0x%lx\n", offset);
29 return pNv->FB->offset;
31 offset += pNv->FB->offset;
37 NVAccelInitDmaNotifier0(ScrnInfoPtr pScrn)
39 NVPtr pNv = NVPTR(pScrn);
40 static int have_object = FALSE;
43 pNv->Notifier0 = NVNotifierAlloc(pScrn, NvDmaNotifier0);
52 /* FLAGS_ROP_AND, DmaFB, DmaFB, 0 */
54 NVAccelInitContextSurfaces(ScrnInfoPtr pScrn)
56 NVPtr pNv = NVPTR(pScrn);
57 static int have_object = FALSE;
60 class = (pNv->Architecture >= NV_10) ? NV10_CONTEXT_SURFACES_2D :
61 NV04_CONTEXT_SURFACES_2D;
64 if (!NVDmaCreateContextObject(pNv, NvContextSurfaces, class))
69 BEGIN_RING(NvContextSurfaces, NV04_CONTEXT_SURFACES_2D_DMA_NOTIFY, 1);
70 OUT_RING (NvNullObject);
71 BEGIN_RING(NvContextSurfaces,
72 NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
79 /* FLAGS_ROP_AND, DmaFB, DmaFB, 0 */
81 NVAccelInitContextBeta1(ScrnInfoPtr pScrn)
83 NVPtr pNv = NVPTR(pScrn);
84 static int have_object = FALSE;
90 if (!NVDmaCreateContextObject(pNv, NvContextBeta1, class))
95 BEGIN_RING(NvContextBeta1, 0x300, 1); /*alpha factor*/
96 OUT_RING (0xff << 23);
103 NVAccelInitContextBeta4(ScrnInfoPtr pScrn)
105 NVPtr pNv = NVPTR(pScrn);
106 static int have_object = FALSE;
112 if (!NVDmaCreateContextObject(pNv, NvContextBeta4, class))
117 BEGIN_RING(NvContextBeta4, 0x300, 1); /*RGBA factor*/
118 OUT_RING (0xffff0000);
123 NVAccelGetCtxSurf2DFormatFromPixmap(PixmapPtr pPix, int *fmt_ret)
125 switch (pPix->drawable.bitsPerPixel) {
127 *fmt_ret = NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8;
130 *fmt_ret = NV04_CONTEXT_SURFACES_2D_FORMAT_X8R8G8B8_Z8R8G8B8;
133 *fmt_ret = NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
136 *fmt_ret = NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
146 NVAccelGetCtxSurf2DFormatFromPicture(PicturePtr pPict, int *fmt_ret)
148 switch (pPict->format) {
150 *fmt_ret = NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8;
153 *fmt_ret = NV04_CONTEXT_SURFACES_2D_FORMAT_X8R8G8B8_Z8R8G8B8;
156 *fmt_ret = NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
159 *fmt_ret = NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
169 NVAccelSetCtxSurf2D(PixmapPtr psPix, PixmapPtr pdPix, int format)
171 ScrnInfoPtr pScrn = xf86Screens[psPix->drawable.pScreen->myNum];
172 NVPtr pNv = NVPTR(pScrn);
174 BEGIN_RING(NvContextSurfaces, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
176 OUT_RING (((uint32_t)exaGetPixmapPitch(pdPix) << 16) |
177 (uint32_t)exaGetPixmapPitch(psPix));
178 OUT_RING (NVAccelGetPixmapOffset(psPix));
179 OUT_RING (NVAccelGetPixmapOffset(pdPix));
185 NVAccelInitImagePattern(ScrnInfoPtr pScrn)
187 NVPtr pNv = NVPTR(pScrn);
188 static int have_object = FALSE;
191 class = NV04_IMAGE_PATTERN;
194 if (!NVDmaCreateContextObject(pNv, NvImagePattern, class))
199 BEGIN_RING(NvImagePattern, NV04_IMAGE_PATTERN_DMA_NOTIFY, 1);
200 OUT_RING (NvNullObject);
201 BEGIN_RING(NvImagePattern, NV04_IMAGE_PATTERN_MONOCHROME_FORMAT, 3);
202 #if X_BYTE_ORDER == X_BIG_ENDIAN
203 OUT_RING (NV04_IMAGE_PATTERN_MONOCHROME_FORMAT_LE);
205 OUT_RING (NV04_IMAGE_PATTERN_MONOCHROME_FORMAT_CGA6);
207 OUT_RING (NV04_IMAGE_PATTERN_MONOCHROME_SHAPE_8X8);
208 OUT_RING (NV04_IMAGE_PATTERN_PATTERN_SELECT_MONO);
214 NVAccelInitRasterOp(ScrnInfoPtr pScrn)
216 NVPtr pNv = NVPTR(pScrn);
217 static int have_object = FALSE;
220 class = NV03_CONTEXT_ROP;
223 if (!NVDmaCreateContextObject(pNv, NvRop, class))
228 BEGIN_RING(NvRop, NV03_CONTEXT_ROP_DMA_NOTIFY, 1);
229 OUT_RING (NvNullObject);
231 pNv->currentRop = ~0;
236 NVAccelInitRectangle(ScrnInfoPtr pScrn)
238 NVPtr pNv = NVPTR(pScrn);
239 static int have_object = FALSE;
242 class = NV04_GDI_RECTANGLE_TEXT;
245 if (!NVDmaCreateContextObject(pNv, NvRectangle, class))
250 BEGIN_RING(NvRectangle, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1);
251 OUT_RING (NvDmaNotifier0);
252 BEGIN_RING(NvRectangle, NV04_GDI_RECTANGLE_TEXT_DMA_FONTS, 1);
253 OUT_RING (NvNullObject);
254 BEGIN_RING(NvRectangle, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1);
255 OUT_RING (NvContextSurfaces);
256 BEGIN_RING(NvRectangle, NV04_GDI_RECTANGLE_TEXT_ROP, 1);
258 BEGIN_RING(NvRectangle, NV04_GDI_RECTANGLE_TEXT_PATTERN, 1);
259 OUT_RING (NvImagePattern);
260 BEGIN_RING(NvRectangle, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1);
261 OUT_RING (NV04_GDI_RECTANGLE_TEXT_OPERATION_ROP_AND);
262 BEGIN_RING(NvRectangle, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT, 1);
263 /* XXX why putting 1 like renouveau dump, swap the text */
264 #if 1 || X_BYTE_ORDER == X_BIG_ENDIAN
265 OUT_RING (NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE);
267 OUT_RING (NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_CGA6);
274 NVAccelInitImageBlit(ScrnInfoPtr pScrn)
276 NVPtr pNv = NVPTR(pScrn);
277 static int have_object = FALSE;
280 class = (pNv->WaitVSyncPossible) ? NV12_IMAGE_BLIT : NV_IMAGE_BLIT;
283 if (!NVDmaCreateContextObject(pNv, NvImageBlit, class))
288 BEGIN_RING(NvImageBlit, NV_IMAGE_BLIT_DMA_NOTIFY, 1);
289 OUT_RING (NvDmaNotifier0);
290 BEGIN_RING(NvImageBlit, NV_IMAGE_BLIT_COLOR_KEY, 1);
291 OUT_RING (NvNullObject);
292 BEGIN_RING(NvImageBlit, NV_IMAGE_BLIT_SURFACE, 1);
293 OUT_RING (NvContextSurfaces);
294 BEGIN_RING(NvImageBlit, NV_IMAGE_BLIT_CLIP_RECTANGLE, 3);
295 OUT_RING (NvNullObject);
296 OUT_RING (NvImagePattern);
298 BEGIN_RING(NvImageBlit, NV_IMAGE_BLIT_OPERATION, 1);
299 OUT_RING (NV_IMAGE_BLIT_OPERATION_ROP_AND);
301 if (pNv->WaitVSyncPossible) {
302 BEGIN_RING(NvImageBlit, 0x0120, 3);
312 NVAccelInitScaledImage(ScrnInfoPtr pScrn)
314 NVPtr pNv = NVPTR(pScrn);
315 static int have_object = FALSE;
318 switch (pNv->Architecture) {
320 class = NV04_SCALED_IMAGE_FROM_MEMORY;
325 class = NV10_SCALED_IMAGE_FROM_MEMORY;
329 class = NV10_SCALED_IMAGE_FROM_MEMORY | 0x3000;
334 if (!NVDmaCreateContextObject(pNv, NvScaledImage, class))
339 BEGIN_RING(NvScaledImage,
340 NV04_SCALED_IMAGE_FROM_MEMORY_DMA_NOTIFY, 7);
341 OUT_RING (NvDmaNotifier0);
343 OUT_RING (NvNullObject);
344 OUT_RING (NvNullObject);
345 OUT_RING (NvContextBeta1);
346 OUT_RING (NvContextBeta4);
347 OUT_RING (NvContextSurfaces);
348 if (pNv->Architecture>=NV_ARCH_10) {
349 BEGIN_RING(NvScaledImage,
350 NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 1);
351 OUT_RING (NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_DITHER);
353 BEGIN_RING(NvScaledImage, NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION, 1);
354 OUT_RING (NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
360 NVAccelInitClipRectangle(ScrnInfoPtr pScrn)
362 NVPtr pNv = NVPTR(pScrn);
363 static int have_object = FALSE;
364 int class = NV01_CONTEXT_CLIP_RECTANGLE;
367 if (!NVDmaCreateContextObject(pNv, NvClipRectangle, class))
372 BEGIN_RING(NvClipRectangle, NV01_CONTEXT_CLIP_RECTANGLE_DMA_NOTIFY, 1);
373 OUT_RING (NvNullObject);
379 NVAccelInitSolidLine(ScrnInfoPtr pScrn)
381 NVPtr pNv = NVPTR(pScrn);
382 static int have_object = FALSE;
383 int class = NV04_RENDER_SOLID_LINE;
386 if (!NVDmaCreateContextObject(pNv, NvSolidLine, class))
391 BEGIN_RING(NvSolidLine, NV01_RENDER_SOLID_LINE_CLIP_RECTANGLE, 3);
392 OUT_RING (NvClipRectangle);
393 OUT_RING (NvImagePattern);
395 BEGIN_RING(NvSolidLine, NV04_RENDER_SOLID_LINE_SURFACE, 1);
396 OUT_RING (NvContextSurfaces);
397 BEGIN_RING(NvSolidLine, NV01_RENDER_SOLID_LINE_OPERATION, 1);
398 OUT_RING (NV01_RENDER_SOLID_LINE_OPERATION_ROP_AND);
403 /* FLAGS_NONE, NvDmaFB, NvDmaAGP, NvDmaNotifier0 */
405 NVAccelInitMemFormat(ScrnInfoPtr pScrn)
407 NVPtr pNv = NVPTR(pScrn);
408 static int have_object = FALSE;
411 if (pNv->Architecture < NV_ARCH_50)
412 class = NV_MEMORY_TO_MEMORY_FORMAT;
414 class = NV50_MEMORY_TO_MEMORY_FORMAT;
417 if (!NVDmaCreateContextObject(pNv, NvMemFormat, class))
422 BEGIN_RING(NvMemFormat, NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1);
423 OUT_RING (NvDmaNotifier0);
424 BEGIN_RING(NvMemFormat, NV_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2);
428 pNv->M2MFDirection = -1;
433 NVAccelInitImageFromCpu(ScrnInfoPtr pScrn)
435 NVPtr pNv = NVPTR(pScrn);
436 static int have_object = FALSE;
439 switch (pNv->Architecture) {
441 class = NV05_IMAGE_FROM_CPU;
448 class = NV10_IMAGE_FROM_CPU;
453 if (!NVDmaCreateContextObject(pNv, NvImageFromCpu, class))
458 BEGIN_RING(NvImageFromCpu, NV01_IMAGE_FROM_CPU_DMA_NOTIFY, 1);
459 OUT_RING (NvDmaNotifier0);
460 BEGIN_RING(NvImageFromCpu, NV01_IMAGE_FROM_CPU_CLIP_RECTANGLE, 1);
461 OUT_RING (NvNullObject);
462 BEGIN_RING(NvImageFromCpu, NV01_IMAGE_FROM_CPU_PATTERN, 1);
463 OUT_RING (NvNullObject);
464 BEGIN_RING(NvImageFromCpu, NV01_IMAGE_FROM_CPU_ROP, 1);
465 OUT_RING (NvNullObject);
466 if (pNv->Architecture >= NV_ARCH_10)
468 BEGIN_RING(NvImageFromCpu, NV01_IMAGE_FROM_CPU_BETA1, 1);
469 OUT_RING (NvNullObject);
470 BEGIN_RING(NvImageFromCpu, NV05_IMAGE_FROM_CPU_BETA4, 1);
471 OUT_RING (NvNullObject);
473 BEGIN_RING(NvImageFromCpu, NV05_IMAGE_FROM_CPU_SURFACE, 1);
474 OUT_RING (NvContextSurfaces);
475 BEGIN_RING(NvImageFromCpu, NV01_IMAGE_FROM_CPU_OPERATION, 1);
476 OUT_RING (NV01_IMAGE_FROM_CPU_OPERATION_SRCCOPY);
481 NVAccelInit2D_NV50(ScrnInfoPtr pScrn)
483 NVPtr pNv = NVPTR(pScrn);
484 static int have_object = FALSE;
487 if (!NVDmaCreateContextObject(pNv, Nv2D, 0x502d))
492 BEGIN_RING(Nv2D, 0x180, 3);
493 OUT_RING (NvDmaNotifier0);
497 /* Magics from nv, no clue what they do, but at least some
498 * of them are needed to avoid crashes.
500 BEGIN_RING(Nv2D, 0x260, 1);
502 BEGIN_RING(Nv2D, 0x290, 1);
504 BEGIN_RING(Nv2D, 0x29c, 1);
506 BEGIN_RING(Nv2D, 0x58c, 1);
509 pNv->currentRop = 0xfffffffa;
513 #define INIT_CONTEXT_OBJECT(name) do { \
514 ret = NVAccelInit##name(pScrn); \
516 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \
517 "Failed to initialise context object: "#name \
524 NVAccelCommonInit(ScrnInfoPtr pScrn)
526 NVPtr pNv = NVPTR(pScrn);
528 if(pNv->NoAccel) return TRUE;
530 /* General engine objects */
531 INIT_CONTEXT_OBJECT(NullObject);
532 INIT_CONTEXT_OBJECT(DmaNotifier0);
535 if (pNv->Architecture < NV_ARCH_50) {
536 INIT_CONTEXT_OBJECT(ContextSurfaces);
537 INIT_CONTEXT_OBJECT(ContextBeta1);
538 INIT_CONTEXT_OBJECT(ContextBeta4);
539 INIT_CONTEXT_OBJECT(ImagePattern);
540 INIT_CONTEXT_OBJECT(RasterOp);
541 INIT_CONTEXT_OBJECT(Rectangle);
542 INIT_CONTEXT_OBJECT(ImageBlit);
543 INIT_CONTEXT_OBJECT(ScaledImage);
544 INIT_CONTEXT_OBJECT(ClipRectangle);
545 INIT_CONTEXT_OBJECT(SolidLine);
546 INIT_CONTEXT_OBJECT(ImageFromCpu);
548 INIT_CONTEXT_OBJECT(2D_NV50);
550 INIT_CONTEXT_OBJECT(MemFormat);
553 switch (pNv->Architecture) {
555 INIT_CONTEXT_OBJECT(NV40TCL);
558 INIT_CONTEXT_OBJECT(NV30TCL);
562 INIT_CONTEXT_OBJECT(NV10TCL);