1 #include "nv_include.h"
3 #define NV50EXA_LOCALS(p) \
4 ScrnInfoPtr pScrn = xf86Screens[(p)->drawable.pScreen->myNum]; \
5 NVPtr pNv = NVPTR(pScrn); \
9 NV50EXA2DSurfaceFormat(PixmapPtr pPix, uint32_t *fmt)
13 switch (pPix->drawable.depth) {
14 case 8 : *fmt = NV50_2D_SRC_FORMAT_8BPP; break;
15 case 15: *fmt = NV50_2D_SRC_FORMAT_15BPP; break;
16 case 16: *fmt = NV50_2D_SRC_FORMAT_16BPP; break;
17 case 24: *fmt = NV50_2D_SRC_FORMAT_24BPP; break;
18 case 32: *fmt = NV50_2D_SRC_FORMAT_32BPP; break;
20 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
21 "Unknown surface format for bpp=%d\n",
22 pPix->drawable.depth);
30 NV50EXAAcquireSurface2D(PixmapPtr pPix, int is_src)
33 int mthd = is_src ? NV50_2D_SRC_FORMAT : NV50_2D_DST_FORMAT;
36 if (!NV50EXA2DSurfaceFormat(pPix, &fmt))
39 BEGIN_RING(Nv2D, mthd, 2);
43 BEGIN_RING(Nv2D, mthd + 0x14, 5);
44 OUT_RING ((uint32_t)exaGetPixmapPitch(pPix));
45 OUT_RING (pPix->drawable.width);
46 OUT_RING (pPix->drawable.height);
48 OUT_RING (NVAccelGetPixmapOffset(pPix));
51 BEGIN_RING(Nv2D, NV50_2D_CLIP_X, 4);
54 OUT_RING (pPix->drawable.width);
55 OUT_RING (pPix->drawable.height);
62 NV50EXAAcquireSurfaces(PixmapPtr pdPix)
64 NV50EXA_LOCALS(pdPix);
70 NV50EXAReleaseSurfaces(PixmapPtr pdPix)
72 NV50EXA_LOCALS(pdPix);
74 BEGIN_RING(Nv2D, NV50_2D_NOP, 1);
80 NV50EXASetPattern(PixmapPtr pdPix, int col0, int col1, int pat0, int pat1)
82 NV50EXA_LOCALS(pdPix);
84 BEGIN_RING(Nv2D, NV50_2D_PATTERN_COLOR(0), 4);
91 extern const int NVCopyROP[16];
93 NV50EXASetROP(PixmapPtr pdPix, int alu, Pixel planemask)
95 NV50EXA_LOCALS(pdPix);
96 int rop = NVCopyROP[alu];
98 BEGIN_RING(Nv2D, NV50_2D_OPERATION, 1);
99 if(alu == GXcopy && planemask == ~0) {
100 OUT_RING (NV50_2D_OPERATION_SRCCOPY);
103 OUT_RING (NV50_2D_OPERATION_ROP_AND);
106 BEGIN_RING(Nv2D, NV50_2D_PATTERN_FORMAT, 1);
107 switch (pdPix->drawable.depth) {
108 case 8: OUT_RING (3); break;
109 case 15: OUT_RING (1); break;
110 case 16: OUT_RING (0); break;
118 if(planemask != ~0) {
119 NV50EXASetPattern(pdPix, 0, planemask, ~0, ~0);
120 rop = (rop & 0xf0) | 0x0a;
122 if((pNv->currentRop & 0x0f) == 0x0a) {
123 NV50EXASetPattern(pdPix, ~0, ~0, ~0, ~0);
126 if (pNv->currentRop != rop) {
127 BEGIN_RING(Nv2D, NV50_2D_ROP, 1);
129 pNv->currentRop = rop;
134 NV50EXAPrepareSolid(PixmapPtr pdPix, int alu, Pixel planemask, Pixel fg)
136 NV50EXA_LOCALS(pdPix);
139 if(pdPix->drawable.depth > 24)
141 if (!NV50EXA2DSurfaceFormat(pdPix, &fmt))
144 if (!NV50EXAAcquireSurface2D(pdPix, 0))
146 if (!NV50EXAAcquireSurfaces(pdPix))
148 NV50EXASetROP(pdPix, alu, planemask);
150 BEGIN_RING(Nv2D, 0x580, 3);
159 NV50EXASolid(PixmapPtr pdPix, int x1, int y1, int x2, int y2)
161 NV50EXA_LOCALS(pdPix);
163 BEGIN_RING(Nv2D, NV50_2D_RECT_X1, 4);
169 if((x2 - x1) * (y2 - y1) >= 512)
174 NV50EXADoneSolid(PixmapPtr pdPix)
176 NV50EXA_LOCALS(pdPix);
178 NV50EXAReleaseSurfaces(pdPix);
182 NV50EXAPrepareCopy(PixmapPtr psPix, PixmapPtr pdPix, int dx, int dy,
183 int alu, Pixel planemask)
185 NV50EXA_LOCALS(pdPix);
187 if (!NV50EXAAcquireSurface2D(psPix, 1))
189 if (!NV50EXAAcquireSurface2D(pdPix, 0))
191 if (!NV50EXAAcquireSurfaces(pdPix))
193 NV50EXASetROP(pdPix, alu, planemask);
199 NV50EXACopy(PixmapPtr pdPix, int srcX , int srcY,
201 int width, int height)
203 NV50EXA_LOCALS(pdPix);
205 BEGIN_RING(Nv2D, 0x0110, 1);
207 BEGIN_RING(Nv2D, NV50_2D_BLIT_DST_X, 12);
221 if(width * height >= 512)
226 NV50EXADoneCopy(PixmapPtr pdPix)
228 NV50EXA_LOCALS(pdPix);
230 NV50EXAReleaseSurfaces(pdPix);