1 #include "nv_include.h"
4 NVAccelInitNullObject(NVPtr pNv)
6 static int have_object = FALSE;
9 if (!NVDmaCreateContextObject(pNv, NvNullObject,
19 NVAccelInitDmaFB(NVPtr pNv)
21 static int have_object = FALSE;
24 if (!NVDmaCreateDMAObject(pNv, NvDmaFB, NV_DMA_IN_MEMORY,
27 NOUVEAU_MEM_ACCESS_RW))
36 NVAccelGetPixmapOffset(NVPtr pNv, PixmapPtr pPix)
40 if (pPix->drawable.type == DRAWABLE_WINDOW) {
41 offset = pNv->FB->offset - pNv->VRAMPhysical;
43 offset = (uint32_t)((unsigned long)pPix->devPrivate.ptr -
44 (unsigned long)pNv->FB->map);
45 offset += pNv->FB->offset - pNv->VRAMPhysical;
52 NVAccelInitDmaAGP(NVPtr pNv)
54 static int have_object = FALSE;
60 if (!NVDmaCreateDMAObject(pNv, NvDmaAGP, NV_DMA_IN_MEMORY,
63 NOUVEAU_MEM_ACCESS_RW)) {
64 ErrorF("Couldn't create AGP object, disabling AGP\n");
65 NVFreeMemory(pNv, pNv->AGPScratch);
66 pNv->AGPScratch = NULL;
75 NVAccelInitDmaNotifier0(NVPtr pNv)
77 static int have_object = FALSE;
80 pNv->Notifier0 = NVDmaCreateNotifier(pNv, NvDmaNotifier0);
89 /* FLAGS_ROP_AND, DmaFB, DmaFB, 0 */
91 NVAccelInitContextSurfaces(NVPtr pNv)
93 static int have_object = FALSE;
96 class = (pNv->Architecture >= NV_10) ? NV10_CONTEXT_SURFACES_2D :
100 if (!NVDmaCreateContextObject(pNv, NvContextSurfaces, class))
105 NVDmaSetObjectOnSubchannel(pNv, NvSubContextSurfaces,
107 NVDmaStart(pNv, NvSubContextSurfaces, NV04_SURFACE_DMA_NOTIFY, 1);
108 NVDmaNext (pNv, NvNullObject);
109 NVDmaStart(pNv, NvSubContextSurfaces, NV04_SURFACE_DMA_IMAGE_SOURCE, 2);
110 NVDmaNext (pNv, NvDmaFB);
111 NVDmaNext (pNv, NvDmaFB);
117 NVAccelGetCtxSurf2DFormatFromPixmap(PixmapPtr pPix, int *fmt_ret)
119 switch (pPix->drawable.bitsPerPixel) {
121 *fmt_ret = SURFACE_FORMAT_A8R8G8B8;
124 *fmt_ret = SURFACE_FORMAT_X8R8G8B8;
127 *fmt_ret = SURFACE_FORMAT_R5G6B5;
130 *fmt_ret = SURFACE_FORMAT_Y8;
140 NVAccelGetCtxSurf2DFormatFromPicture(PicturePtr pPict, int *fmt_ret)
142 switch (pPict->format) {
144 *fmt_ret = SURFACE_FORMAT_A8R8G8B8;
147 *fmt_ret = SURFACE_FORMAT_X8R8G8B8;
150 *fmt_ret = SURFACE_FORMAT_R5G6B5;
153 *fmt_ret = SURFACE_FORMAT_Y8;
163 NVAccelSetCtxSurf2D(NVPtr pNv, PixmapPtr psPix, PixmapPtr pdPix, int format)
165 NVDmaStart(pNv, NvSubContextSurfaces, SURFACE_FORMAT, 4);
166 NVDmaNext (pNv, format);
167 NVDmaNext (pNv, ((uint32_t)exaGetPixmapPitch(pdPix) << 16) |
168 (uint32_t)exaGetPixmapPitch(psPix));
169 NVDmaNext (pNv, NVAccelGetPixmapOffset(pNv, psPix));
170 NVDmaNext (pNv, NVAccelGetPixmapOffset(pNv, pdPix));
175 /* FLAGS_ROP_AND|FLAGS_MONO, 0, 0, 0 */
177 NVAccelInitImagePattern(NVPtr pNv)
179 static int have_object = FALSE;
182 class = NV04_IMAGE_PATTERN;
185 if (!NVDmaCreateContextObject(pNv, NvImagePattern, class))
190 NVDmaSetObjectOnSubchannel(pNv, NvSubImagePattern,
192 NVDmaStart(pNv, NvSubImagePattern,
193 0x180, /*NV04_IMAGE_PATTERN_SET_DMA_NOTIFY*/ 1);
194 NVDmaNext (pNv, NvNullObject);
195 NVDmaStart(pNv, NvSubImagePattern, NV04_IMAGE_PATTERN_MONO_FORMAT, 3);
196 #if X_BYTE_ORDER == X_BIG_ENDIAN
197 NVDmaNext (pNv, 2 /* NV04_IMAGE_PATTERN_BIGENDIAN/LE_M1 */);
199 NVDmaNext (pNv, 1 /* NV04_IMAGE_PATTERN_LOWENDIAN/CGA6_M1 */);
201 NVDmaNext (pNv, 0 /* NV04_IMAGE_PATTERN_MONOCHROME_SHAPE_8X8 */);
202 NVDmaNext (pNv, 1 /* NV04_IMAGE_PATTERN_SELECT_MONOCHROME */);
207 /* FLAGS_ROP_AND, 0, 0, 0 */
209 NVAccelInitRasterOp(NVPtr pNv)
211 static int have_object = FALSE;
214 class = NV03_PRIMITIVE_RASTER_OP;
217 if (!NVDmaCreateContextObject(pNv, NvRop, class))
222 NVDmaSetObjectOnSubchannel(pNv, NvSubRop, NvRop);
223 NVDmaStart(pNv, NvSubRop, NV03_PRIMITIVE_RASTER_OP_DMA_NOTIFY, 1);
224 NVDmaNext (pNv, NvNullObject);
229 /* FLAGS_ROP_AND | FLAGS_MONO, 0, 0, 0 */
231 NVAccelInitRectangle(NVPtr pNv)
233 static int have_object = FALSE;
236 class = NV04_GDI_RECTANGLE_TEXT;
239 if (!NVDmaCreateContextObject(pNv, NvRectangle, class))
244 NVDmaSetObjectOnSubchannel(pNv, NvSubRectangle, NvRectangle);
245 NVDmaStart(pNv, NvSubRectangle,
246 NV04_GDI_RECTANGLE_TEXT_SET_DMA_NOTIFY, 1);
247 NVDmaNext (pNv, NvDmaNotifier0);
248 NVDmaStart(pNv, NvSubRectangle,
249 0x184 /*NV04_GDI_RECTANGLE_TEXT_SET_DMA_FONTS*/, 1);
250 NVDmaNext (pNv, NvNullObject);
251 NVDmaStart(pNv, NvSubRectangle, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1);
252 NVDmaNext (pNv, NvContextSurfaces);
253 NVDmaStart(pNv, NvSubRectangle, NV04_GDI_RECTANGLE_TEXT_ROP5, 1);
254 NVDmaNext (pNv, NvRop);
255 NVDmaStart(pNv, NvSubRectangle, NV04_GDI_RECTANGLE_TEXT_PATTERN, 1);
256 NVDmaNext (pNv, NvImagePattern);
257 NVDmaStart(pNv, NvSubRectangle, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1);
258 NVDmaNext (pNv, 1 /* ROP_AND */);
263 /* FLAGS_ROP_AND, DmaFB, DmaFB, 0 */
265 NVAccelInitImageBlit(NVPtr pNv)
267 static int have_object = FALSE;
270 class = (pNv->WaitVSyncPossible) ? NV10_IMAGE_BLIT : NV_IMAGE_BLIT;
273 if (!NVDmaCreateContextObject(pNv, NvImageBlit, class))
278 NVDmaSetObjectOnSubchannel(pNv, NvSubImageBlit, NvImageBlit);
279 NVDmaStart(pNv, NvSubImageBlit, NV_IMAGE_BLIT_DMA_NOTIFY, 1);
280 NVDmaNext (pNv, NvDmaNotifier0);
281 NVDmaStart(pNv, NvSubImageBlit, NV_IMAGE_BLIT_COLOR_KEY, 1);
282 NVDmaNext (pNv, NvNullObject);
283 NVDmaStart(pNv, NvSubImageBlit, NV_IMAGE_BLIT_SURFACE, 1);
284 NVDmaNext (pNv, NvContextSurfaces);
285 NVDmaStart(pNv, NvSubImageBlit, NV_IMAGE_BLIT_CLIP_RECTANGLE, 3);
286 NVDmaNext (pNv, NvNullObject);
287 NVDmaNext (pNv, NvImagePattern);
288 NVDmaNext (pNv, NvRop);
289 NVDmaStart(pNv, NvSubImageBlit, NV_IMAGE_BLIT_OPERATION, 1);
290 NVDmaNext (pNv, 1 /* NV_IMAGE_BLIT_OPERATION_ROP_AND */);
295 /* FLAGS_SRCCOPY, DmaFB, DmaFB, 0 */
297 NVAccelInitScaledImage(NVPtr pNv)
299 static int have_object = FALSE;
302 switch (pNv->Architecture) {
304 class = NV04_SCALED_IMAGE_FROM_MEMORY;
309 class = NV10_SCALED_IMAGE_FROM_MEMORY;
313 class = NV10_SCALED_IMAGE_FROM_MEMORY | 0x3000;
318 if (!NVDmaCreateContextObject(pNv, NvScaledImage, class))
323 NVDmaSetObjectOnSubchannel(pNv, NvSubScaledImage, NvScaledImage);
324 NVDmaStart(pNv, NvSubScaledImage,
325 NV04_SCALED_IMAGE_FROM_MEMORY_DMA_NOTIFY, 1);
326 NVDmaNext (pNv, NvDmaNotifier0);
327 NVDmaStart(pNv, NvSubScaledImage,
328 NV04_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1);
329 NVDmaNext (pNv, NvDmaFB); /* source object */
330 NVDmaStart(pNv, NvSubScaledImage,
331 NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1);
332 NVDmaNext (pNv, NvContextSurfaces);
333 NVDmaStart(pNv, NvSubScaledImage, 0x188, 1); /* PATTERN */
334 NVDmaNext (pNv, NvNullObject);
335 NVDmaStart(pNv, NvSubScaledImage, 0x18c, 1); /* ROP */
336 NVDmaNext (pNv, NvNullObject);
337 NVDmaStart(pNv, NvSubScaledImage, 0x190, 1); /* BETA1 */
338 NVDmaNext (pNv, NvNullObject);
339 NVDmaStart(pNv, NvSubScaledImage, 0x194, 1); /* BETA4 */
340 NVDmaNext (pNv, NvNullObject);
341 NVDmaStart(pNv, NvSubScaledImage,
342 NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION, 1);
343 NVDmaNext (pNv, 3 /* SRCCOPY */);
348 /* FLAGS_NONE, 0, 0, 0 */
350 NVAccelInitClipRectangle(NVPtr pNv)
352 static int have_object = FALSE;
353 int class = NV01_CONTEXT_CLIP_RECTANGLE;
356 if (!NVDmaCreateContextObject(pNv, NvClipRectangle, class))
361 NVDmaSetObjectOnSubchannel(pNv, NvSubClipRectangle, NvClipRectangle);
362 NVDmaStart(pNv, NvSubClipRectangle, 0x180, 1); /* DMA_NOTIFY */
363 NVDmaNext (pNv, NvNullObject);
368 /* FLAGS_ROP_AND | FLAGS_CLIP_ENABLE, 0, 0, 0 */
370 NVAccelInitSolidLine(NVPtr pNv)
372 static int have_object = FALSE;
373 int class = NV04_SOLID_LINE;
376 if (!NVDmaCreateContextObject(pNv, NvSolidLine, class))
381 NVDmaSetObjectOnSubchannel(pNv, NvSubSolidLine, NvSolidLine);
382 NVDmaStart(pNv, NvSubSolidLine, NV04_SOLID_LINE_CLIP_RECTANGLE, 3);
383 NVDmaNext (pNv, NvClipRectangle);
384 NVDmaNext (pNv, NvImagePattern);
385 NVDmaNext (pNv, NvRop);
386 NVDmaStart(pNv, NvSubSolidLine, NV04_SOLID_LINE_SURFACE, 1);
387 NVDmaNext (pNv, NvContextSurfaces);
388 NVDmaStart(pNv, NvSubSolidLine, NV04_SOLID_LINE_OPERATION, 1);
389 NVDmaNext (pNv, 1); /* ROP_AND */
394 /* FLAGS_NONE, NvDmaFB, NvDmaAGP, NvDmaNotifier0 */
396 NVAccelInitMemFormat(NVPtr pNv)
398 static int have_object = FALSE;
401 class = NV_MEMORY_TO_MEMORY_FORMAT;
404 if (!NVDmaCreateContextObject(pNv, NvMemFormat, class))
409 NVDmaSetObjectOnSubchannel(pNv, NvSubMemFormat, NvMemFormat);
410 NVDmaStart(pNv, NvSubMemFormat,
411 NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1);
412 NVDmaNext (pNv, NvDmaNotifier0);
413 NVDmaStart(pNv, NvSubMemFormat,
414 NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_IN, 2);
415 NVDmaNext (pNv, NvDmaFB);
416 NVDmaNext (pNv, NvDmaFB);
418 pNv->M2MFDirection = -1;
422 #define INIT_CONTEXT_OBJECT(name) do { \
423 ret = NVAccelInit##name(pNv); \
425 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \
426 "Failed to initialise context object: "#name \
433 NVAccelCommonInit(ScrnInfoPtr pScrn)
435 NVPtr pNv = NVPTR(pScrn);
438 INIT_CONTEXT_OBJECT(NullObject);
439 INIT_CONTEXT_OBJECT(DmaFB);
440 INIT_CONTEXT_OBJECT(DmaAGP);
441 INIT_CONTEXT_OBJECT(DmaNotifier0);
443 INIT_CONTEXT_OBJECT(ContextSurfaces);
444 INIT_CONTEXT_OBJECT(ImagePattern);
445 INIT_CONTEXT_OBJECT(RasterOp);
446 INIT_CONTEXT_OBJECT(Rectangle);
447 INIT_CONTEXT_OBJECT(ImageBlit);
448 INIT_CONTEXT_OBJECT(ScaledImage);
451 INIT_CONTEXT_OBJECT(ClipRectangle);
452 INIT_CONTEXT_OBJECT(SolidLine);
455 INIT_CONTEXT_OBJECT(MemFormat);