pvrvideosink: add filtering
[gstreamer-omap:gst-plugins-bad.git] / sys / pvr2d / pvr_includes / pvr2d.h
1 /**********************************************************************\r
2 *\r
3 * Copyright(c) Imagination Technologies Ltd.\r
4 *\r
5 * The contents of this file are subject to the MIT license as set out below.\r
6 *\r
7 * Permission is hereby granted, free of charge, to any person obtaining a copy\r
8 * of this software and associated documentation files (the "Software"),\r
9 * to deal in the Software without restriction, including without limitation\r
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
11 * and/or sell copies of the Software, and to permit persons to whom the\r
12 * Software is furnished to do so, subject to the following conditions:\r
13\r
14 * The above copyright notice and this permission notice shall be included\r
15 * in all copies or substantial portions of the Software.\r
16 *\r
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \r
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\r
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT\r
22 * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE\r
23 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
24\r
25 * This License is also included in this distribution in the file called \r
26 * "COPYING".\r
27\r
28 ******************************************************************************/\r
29 \r
30 \r
31 \r
32 /******************************************************************************\r
33 Modifications :-\r
34 $Log: pvr2d.h $\r
35 \r
36  --- Revision Logs Removed --- \r
37 ******************************************************************************/\r
38 \r
39 #ifndef _PVR2D_H_\r
40 #define _PVR2D_H_\r
41 \r
42 #ifdef __cplusplus\r
43 extern "C" {\r
44 #endif \r
45 \r
46 /* PVR2D Platform-specific definitions */\r
47 #if defined (__linux__)\r
48 #define PVR2D_EXPORT __attribute__((visibility("default")))\r
49 #define PVR2D_IMPORT\r
50 #else\r
51 #define PVR2D_EXPORT\r
52 #define PVR2D_IMPORT\r
53 #endif\r
54 \r
55 /* PVR2D header revision */\r
56 #define PVR2D_REV_MAJOR         3\r
57 #define PVR2D_REV_MINOR         5\r
58 \r
59 /* Basic types */\r
60 typedef enum\r
61 {\r
62         PVR2D_FALSE = 0,\r
63         PVR2D_TRUE\r
64 } PVR2D_BOOL;\r
65 \r
66 typedef void* PVR2D_HANDLE;\r
67 \r
68 typedef char             PVR2D_CHAR,    *PVR2D_PCHAR;\r
69 typedef unsigned char    PVR2D_UCHAR,   *PVR2D_PUCHAR;\r
70 typedef int              PVR2D_INT,             *PVR2D_PINT;\r
71 typedef unsigned int     PVR2D_UINT,    *PVR2D_PUINT;\r
72 typedef long             PVR2D_LONG,    *PVR2D_PLONG;\r
73 typedef unsigned long    PVR2D_ULONG,   *PVR2D_PULONG;\r
74 \r
75 typedef void             PVR2D_VOID,    *PVR2D_PVOID;\r
76 \r
77 \r
78 /* error codes */\r
79 typedef enum\r
80 {\r
81         PVR2D_OK = 0,\r
82         PVR2DERROR_INVALID_PARAMETER = -1,\r
83         PVR2DERROR_DEVICE_UNAVAILABLE = -2,\r
84         PVR2DERROR_INVALID_CONTEXT = -3,\r
85         PVR2DERROR_MEMORY_UNAVAILABLE = -4,\r
86         PVR2DERROR_DEVICE_NOT_PRESENT = -5,\r
87         PVR2DERROR_IOCTL_ERROR = -6,\r
88         PVR2DERROR_GENERIC_ERROR = -7,\r
89         PVR2DERROR_BLT_NOTCOMPLETE = -8,\r
90         PVR2DERROR_HW_FEATURE_NOT_SUPPORTED = -9,\r
91         PVR2DERROR_NOT_YET_IMPLEMENTED = -10,\r
92         PVR2DERROR_MAPPING_FAILED = -11\r
93 }PVR2DERROR;\r
94 \r
95 /* 32 bit PVR2D pixel format specifier */\r
96 typedef unsigned long PVR2DFORMAT;\r
97 \r
98 /* Standard PVR2D pixel formats */\r
99 #define PVR2D_1BPP                                              0x00UL // 1bpp mask surface or palletized 1 bit source with 2x32 bit CLUT\r
100 #define PVR2D_RGB565                                    0x01UL // Common rgb 565 format\r
101 #define PVR2D_ARGB4444                                  0x02UL // Common argb 4444 format\r
102 #define PVR2D_RGB888                                    0x03UL // Common rgb 888 format (not supported)\r
103 #define PVR2D_ARGB8888                                  0x04UL // Common argb 8888 format\r
104 #define PVR2D_ARGB1555                                  0x05UL // Common argb 1555 format\r
105 #define PVR2D_ALPHA8                                    0x06UL // Alpha-only 8 bit per pixel (used with a constant fill colour)\r
106 #define PVR2D_ALPHA4                                    0x07UL // Alpha-only 4 bits per pixel (used with a constant fill colour)\r
107 #define PVR2D_PAL2                                              0x08UL // Palletized 2 bit format (requires   4x32 bit CLUT)\r
108 #define PVR2D_PAL4                                              0x09UL // Palletized 4 bit format (requires  16x32 bit CLUT)\r
109 #define PVR2D_PAL8                                              0x0AUL // Palletized 8 bit format (requires 256x32 bit CLUT)\r
110 #define PVR2D_U8                                                0x10UL // monochrome unsigned 8 bit\r
111 #define PVR2D_U88                                               0x11UL // monochrome unsigned 16 bit\r
112 #define PVR2D_S8                                                0x12UL // signed 8 bit\r
113 #define PVR2D_YUV422_YUYV                               0x13UL // YUV 422 low-high byte order Y0UY1V\r
114 #define PVR2D_YUV422_UYVY                               0x14UL // YUV 422 low-high byte order UY0VY1\r
115 #define PVR2D_YUV422_YVYU                               0x15UL // YUV 422 low-high byte order Y0VY1U\r
116 #define PVR2D_YUV422_VYUY                               0x16UL // YUV 422 low-high byte order VY0UY1\r
117 #define PVR2D_YUV420_2PLANE                             0x17UL // YUV420 2 Plane\r
118 #define PVR2D_YUV420_3PLANE                             0x18UL // YUV420 3 Plane\r
119 #define PVR2D_2101010ARGB                               0x19UL // 32 bit 2 10 10 10 \r
120 #define PVR2D_888RSGSBS                                 0x1AUL\r
121 #define PVR2D_16BPP_RAW                                 0x1BUL // 16 bit raw (no format conversion)\r
122 #define PVR2D_32BPP_RAW                                 0x1CUL // 32 bit raw\r
123 #define PVR2D_64BPP_RAW                                 0x1DUL // 64 bit raw\r
124 #define PVR2D_128BPP_RAW                                0x1EUL // 128 bit raw\r
125 \r
126 #define PVR2D_NO_OF_FORMATS                             0x1FUL\r
127 \r
128 /* Format modifier bit field (DstFormat and SrcFormat bits 16..23) */\r
129 #define PVR2D_FORMAT_MASK                               0x0000FFFFUL    // PVR2D Format bits\r
130 #define PVR2D_FORMAT_LAYOUT_MASK                0x000F0000UL    // Format layout (strided / twiddled / tiled)\r
131 #define PVR2D_FORMAT_FLAGS_MASK                 0x0FF00000UL    // Surface Flags mask\r
132 \r
133 /* Layout */\r
134 #define PVR2D_FORMAT_LAYOUT_SHIFT               16\r
135 #define PVR2D_FORMAT_LAYOUT_STRIDED             0x00000000UL\r
136 #define PVR2D_FORMAT_LAYOUT_TILED               0x00010000UL\r
137 #define PVR2D_FORMAT_LAYOUT_TWIDDLED    0x00020000UL\r
138 \r
139 /*\r
140         PVR2D_SURFACE_PDUMP\r
141         This flag requests a surface pdump, to capture the pixel state after host writes.\r
142         Not needed if the surface state has resulted from previous SGX 2D/3D core writes.\r
143 */\r
144 #define PVR2D_SURFACE_PDUMP                             0x00100000UL    // calls PVRSRVPDumpMem to capture the surface (pdump builds only) \r
145 \r
146 /*\r
147         Low level 3D format extension - for blts via the 3D core only.\r
148         If the top bit of the format field is set then PVR2D reads it as a PVRSRV_PIXEL_FORMAT.\r
149         The outcome is hardware dependant.\r
150         There is no guarantee that any specific PVRSRV format will be supported.\r
151 */\r
152 #define PVR2D_FORMAT_PVRSRV                             0x80000000\r
153 \r
154 /* wrap surface type */\r
155 typedef enum\r
156 {\r
157         PVR2D_WRAPFLAG_NONCONTIGUOUS = 0,\r
158         PVR2D_WRAPFLAG_CONTIGUOUS = 1,\r
159 \r
160 }PVR2DWRAPFLAGS;\r
161 \r
162 #define PVR2D_CONTEXT_FLAGS_PRIORITY_MASK                       0x00000003\r
163 \r
164 #define PVR2D_CONTEXT_FLAGS_LOW_PRIORITY_CONTEXT        1\r
165 #define PVR2D_CONTEXT_FLAGS_NORMAL_PRIORITY_CONTEXT     0\r
166 #define PVR2D_CONTEXT_FLAGS_HIGH_PRIORITY_CONTEXT       2\r
167 \r
168 /* flags for control information of additional blits */\r
169 typedef enum\r
170 {\r
171         PVR2D_BLIT_DISABLE_ALL                                  = 0x00000000,   /* disable all additional controls */\r
172         PVR2D_BLIT_CK_ENABLE                                    = 0x00000001,   /* enable colour key */\r
173         PVR2D_BLIT_GLOBAL_ALPHA_ENABLE                  = 0x00000002,   /* enable standard global alpha */\r
174         PVR2D_BLIT_PERPIXEL_ALPHABLEND_ENABLE   = 0x00000004,   /* enable per-pixel alpha bleding */\r
175         PVR2D_BLIT_PAT_SURFACE_ENABLE                   = 0x00000008,   /* enable pattern surf (disable fill) */\r
176         PVR2D_BLIT_FULLY_SPECIFIED_ALPHA_ENABLE = 0x00000010,   /* enable fully specified alpha */\r
177         PVR2D_BLIT_ROT_90                                               = 0x00000020,   /* apply 90 degree rotation to the blt */\r
178         PVR2D_BLIT_ROT_180                                              = 0x00000040,   /* apply 180 degree rotation to the blt */\r
179         PVR2D_BLIT_ROT_270                                              = 0x00000080,   /* apply 270 degree rotation to the blt */\r
180         PVR2D_BLIT_COPYORDER_TL2BR                              = 0x00000100,   /* copy order overrides */\r
181         PVR2D_BLIT_COPYORDER_BR2TL                              = 0x00000200,\r
182         PVR2D_BLIT_COPYORDER_TR2BL                              = 0x00000400,\r
183         PVR2D_BLIT_COPYORDER_BL2TR                              = 0x00000800,\r
184         PVR2D_BLIT_COLKEY_SOURCE                                = 0x00001000,   /* Key colour is on the source surface */\r
185         PVR2D_BLIT_COLKEY_DEST                                  = 0x00002000,   /* Key colour is on the destination surface */\r
186         PVR2D_BLIT_COLKEY_MASKED                                = 0x00004000,   /* Mask enabled for colour key */\r
187         PVR2D_BLIT_COLKEY_OP_PASS                               = 0x00008000,   /* Colour key op = pass */\r
188         PVR2D_BLIT_COLKEY_OP_REJECT                             = 0x00010000,   /* Colour key op = reject */\r
189         PVR2D_BLIT_PATH_2DCORE                                  = 0x00100000,   /* Blt via dedicated 2D Core or PTLA */\r
190         PVR2D_BLIT_PATH_3DCORE                                  = 0x00200000,   /* Blt via 3D Core */\r
191         PVR2D_BLIT_PATH_SWBLT                                   = 0x00400000,   /* Blt via host software */\r
192         PVR2D_BLIT_NO_SRC_SYNC_INFO                             = 0x00800000,   /* Dont send a source sync info*/\r
193         PVR2D_BLIT_ISSUE_STATUS_UPDATES                 = 0x01000000,   /* Issue status updates */\r
194 \r
195 } PVR2DBLITFLAGS;\r
196 \r
197 /* standard alpha-blending functions, AlphaBlendingFunc field of PVR2DBLTINFO */\r
198 typedef enum\r
199 {\r
200         PVR2D_ALPHA_OP_SRC_DSTINV = 1,  /* source alpha : Cdst = Csrc*Asrc + Cdst*(1-Asrc) */\r
201         PVR2D_ALPHA_OP_SRCP_DSTINV = 2  /* premultiplied source alpha : Cdst = Csrc + Cdst*(1-Asrc) */\r
202 } PVR2D_ALPHABLENDFUNC;\r
203 \r
204 /* blend ops for fully specified alpha (SGX 2D Core only) */\r
205 typedef enum\r
206 {\r
207         PVR2D_BLEND_OP_ZERO = 0,\r
208         PVR2D_BLEND_OP_ONE = 1,\r
209         PVR2D_BLEND_OP_SRC = 2,\r
210         PVR2D_BLEND_OP_DST = 3,\r
211         PVR2D_BLEND_OP_GLOBAL = 4,\r
212         PVR2D_BLEND_OP_SRC_PLUS_GLOBAL = 5,\r
213         PVR2D_BLEND_OP_DST_PLUS_GLOBAL = 6\r
214 }PVR2D_BLEND_OP;\r
215 \r
216 /* SGX 2D Core Fully specified alpha blend :    pAlpha field of PVR2DBLTINFO structure          */\r
217 /* a fully specified Alpha Blend operation is defined as                                                                        */\r
218 /* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (ALPHA_3 * DST (ALPHA))                                                      */\r
219 /* DST (RGB)   = (ALPHA_2 * SRC (RGB)) + (ALPHA_4 * DST (RGB))                                                          */\r
220 /* if the pre-multiplication stage is enabled then the equations become the following:          */\r
221 /* PRE_MUL     = ((SRC(A)) * (Global Alpha Value))                                                                                      */\r
222 /* DST (ALPHA) = (ALPHA_1 * SRC (ALPHA)) + (PRE_MUL * DST (ALPHA))                                                      */\r
223 /* DST (RGB)   = (ALPHA_2 * SRC (RGB)) + (PRE_MUL * DST (RGB))                                                          */\r
224 /* if the transparent source alpha stage is enabled then a source alpha of zero forces the      */\r
225 /* source to be transparent for that pixel regardless of the blend equation being used.         */\r
226 typedef struct _PVR2D_ALPHABLT\r
227 {\r
228         PVR2D_BLEND_OP  eAlpha1;\r
229         PVR2D_BOOL              bAlpha1Invert;\r
230         PVR2D_BLEND_OP  eAlpha2;\r
231         PVR2D_BOOL              bAlpha2Invert;\r
232         PVR2D_BLEND_OP  eAlpha3;\r
233         PVR2D_BOOL              bAlpha3Invert;\r
234         PVR2D_BLEND_OP  eAlpha4;\r
235         PVR2D_BOOL              bAlpha4Invert;\r
236         PVR2D_BOOL              bPremulAlpha;                   /* enable pre-multiplication stage */\r
237         PVR2D_BOOL              bTransAlpha;                    /* enable transparent source alpha stage */\r
238         PVR2D_BOOL              bUpdateAlphaLookup;             /* enable and update the 1555-Lookup alpha table */\r
239         PVR2D_UCHAR             uAlphaLookup0;                  /* 8 bit alpha when A=0 in a 1555-Lookup surface */\r
240         PVR2D_UCHAR             uAlphaLookup1;                  /* 8 bit alpha when A=1 in a 1555-Lookup surface */\r
241         PVR2D_UCHAR             uGlobalRGB;                             /* Global Alpha Value for RGB, 0=transparent 255=opaque */\r
242         PVR2D_UCHAR             uGlobalA;                               /* Global Alpha Value for Alpha */\r
243 \r
244 } PVR2D_ALPHABLT, *PPVR2D_ALPHABLT;\r
245 \r
246 \r
247 /* surface memory info structure */\r
248 typedef struct _PVR2DMEMINFO\r
249 {\r
250         PVR2D_VOID                      *pBase;\r
251         PVR2D_ULONG                     ui32MemSize;\r
252         PVR2D_ULONG                     ui32DevAddr;\r
253         PVR2D_ULONG                     ulFlags;\r
254         PVR2D_VOID                      *hPrivateData;\r
255         PVR2D_VOID                      *hPrivateMapData;\r
256 \r
257 }PVR2DMEMINFO, *PPVR2DMEMINFO;\r
258 \r
259 \r
260 #define PVR2D_MAX_DEVICE_NAME 20\r
261 \r
262 typedef struct _PVR2DDEVICEINFO\r
263 {\r
264         PVR2D_ULONG             ulDevID;\r
265         PVR2D_CHAR              szDeviceName[PVR2D_MAX_DEVICE_NAME];\r
266 }PVR2DDEVICEINFO;\r
267 \r
268 \r
269 typedef struct _PVR2DISPLAYINFO\r
270 {\r
271         PVR2D_ULONG     ulMaxFlipChains;\r
272         PVR2D_ULONG     ulMaxBuffersInChain;\r
273         PVR2DFORMAT     eFormat;\r
274         PVR2D_ULONG     ulWidth;\r
275         PVR2D_ULONG     ulHeight;\r
276         PVR2D_LONG      lStride;\r
277         PVR2D_ULONG     ulMinFlipInterval;\r
278         PVR2D_ULONG     ulMaxFlipInterval;\r
279 \r
280 }PVR2DDISPLAYINFO;\r
281 \r
282 \r
283 typedef struct _PVR2MISCDISPLAYINFO\r
284 {\r
285         PVR2D_ULONG ulPhysicalWidthmm;\r
286         PVR2D_ULONG ulPhysicalHeightmm;\r
287         PVR2D_ULONG ulUnused[10];\r
288 \r
289 }PVR2DMISCDISPLAYINFO;\r
290 \r
291 \r
292 typedef struct _PVR2DBLTINFO\r
293 {\r
294         PVR2D_ULONG             CopyCode;                       /* rop code  */\r
295         PVR2D_ULONG             Colour;                         /* fill colour */\r
296         PVR2D_ULONG             ColourKey;                      /* colour key argb8888 (see CKEY_ defs below) */\r
297         PVR2D_UCHAR             GlobalAlphaValue;       /* global alpha blending */\r
298         PVR2D_UCHAR             AlphaBlendingFunc;      /* per-pixel alpha-blending function */\r
299 \r
300         PVR2DBLITFLAGS  BlitFlags;                      /* additional blit control information */\r
301 \r
302         PVR2DMEMINFO    *pDstMemInfo;           /* destination memory */\r
303         PVR2D_ULONG             DstOffset;                      /* byte offset from start of allocation to destination surface pixel 0,0 */\r
304         PVR2D_LONG              DstStride;                      /* signed stride, the number of bytes from pixel 0,0 to 0,1 */\r
305         PVR2D_LONG              DstX, DstY;                     /* pixel offset from start of dest surface to start of blt rectangle */\r
306         PVR2D_LONG              DSizeX,DSizeY;          /* blt size */\r
307         PVR2DFORMAT             DstFormat;                      /* dest format */\r
308         PVR2D_ULONG             DstSurfWidth;           /* size of dest surface in pixels */\r
309         PVR2D_ULONG             DstSurfHeight;          /* size of dest surface in pixels */\r
310 \r
311         PVR2DMEMINFO    *pSrcMemInfo;           /* source mem, (source fields are also used for patterns) */\r
312         PVR2D_ULONG             SrcOffset;                      /* byte offset from start of allocation to src/pat surface pixel 0,0 */\r
313         PVR2D_LONG              SrcStride;                      /* signed stride, the number of bytes from pixel 0,0 to 0,1 */\r
314         PVR2D_LONG              SrcX, SrcY;                     /* pixel offset from start of surface to start of source rectangle */\r
315                                                                                 /* for patterns this is the start offset within the pattern */\r
316         PVR2D_LONG              SizeX,SizeY;            /* source rectangle size or pattern size in pixels */\r
317         PVR2DFORMAT             SrcFormat;                      /* source/pattern format */\r
318         PVR2DMEMINFO    *pPalMemInfo;           /* source/pattern palette memory containing argb8888 colour table */\r
319         PVR2D_ULONG             PalOffset;                      /* byte offset from start of allocation to start of palette */\r
320         PVR2D_ULONG             SrcSurfWidth;           /* size of source surface in pixels */\r
321         PVR2D_ULONG             SrcSurfHeight;          /* size of source surface in pixels */\r
322 \r
323         PVR2DMEMINFO    *pMaskMemInfo;          /* mask memory, 1bpp format implied */\r
324         PVR2D_ULONG             MaskOffset;                     /* byte offset from start of allocation to mask surface pixel 0,0 */\r
325         PVR2D_LONG              MaskStride;                     /* signed stride, the number of bytes from pixel 0,0 to 0,1 */\r
326         PVR2D_LONG              MaskX, MaskY;           /* mask rect top left (mask size = blt size) */\r
327         PVR2D_ULONG             MaskSurfWidth;          /* size of mask surface in pixels */\r
328         PVR2D_ULONG             MaskSurfHeight;         /* size of mask surface in pixels */\r
329         \r
330         PPVR2D_ALPHABLT pAlpha;                         /* fully specified alpha blend (2DCore only) */\r
331         \r
332         PVR2D_ULONG             uSrcChromaPlane1;       /* mem offset from start of source alloc to chroma plane 1 */\r
333         PVR2D_ULONG             uSrcChromaPlane2;       /* mem offset from start of source alloc to chroma plane 2 */\r
334         PVR2D_ULONG             uDstChromaPlane1;       /* mem offset from start of dest alloc to chroma plane 1 */\r
335         PVR2D_ULONG             uDstChromaPlane2;       /* mem offset from start of dest alloc to chroma plane 2 */\r
336         \r
337         PVR2D_ULONG             ColourKeyMask;          /* 32 bit colour key mask, only valid when PVR2D_BLIT_COLKEY_MASKED is set */\r
338 \r
339 }PVR2DBLTINFO, *PPVR2DBLTINFO;\r
340 \r
341 typedef struct _PVR2DRECT\r
342 {\r
343         PVR2D_LONG left, top;\r
344         PVR2D_LONG right, bottom;\r
345 } PVR2DRECT;\r
346 \r
347 typedef struct\r
348 {\r
349         PVR2DMEMINFO    *pSurfMemInfo;          /* surface memory */\r
350         PVR2D_ULONG             SurfOffset;                     /* byte offset from start of allocation to destination surface pixel 0,0 */\r
351         PVR2D_LONG              Stride;                         /* signed stride */\r
352         PVR2DFORMAT             Format;                         /* format */\r
353         PVR2D_ULONG             SurfWidth;                      /* surface width in pixels */\r
354         PVR2D_ULONG             SurfHeight;                     /* surface height in pixels */\r
355 \r
356 } PVR2D_SURFACE, *PPVR2D_SURFACE;\r
357 \r
358 typedef struct\r
359 {\r
360         PVR2D_ULONG             uChromaPlane1;          /* YUV multiplane - byte offset from start of alloc to chroma plane 1 */\r
361         PVR2D_ULONG             uChromaPlane2;          /* YUV multiplane - byte offset from start of alloc to chroma plane 2 */\r
362         PVR2D_LONG              Reserved[2];            /* Reserved, must be zero */\r
363 \r
364 } PVR2D_SURFACE_EXT, *PPVR2D_SURFACE_EXT;\r
365 \r
366 typedef struct\r
367 {\r
368         PVR2D_ULONG             *pUseCode;                                      /* USSE code */\r
369         PVR2D_ULONG             UseCodeSize;                            /* usse code size in bytes */\r
370 \r
371 } PVR2D_USECODE, *PPVR2D_USECODE;\r
372 \r
373 typedef struct\r
374 {\r
375         PVR2D_SURFACE                   sDst;                           /* destination surface */\r
376         PVR2D_SURFACE                   sSrc;                           /* source surface */\r
377         PVR2DRECT                               rcDest;                         /* destination rectangle */\r
378         PVR2DRECT                               rcSource;                       /* source rectangle */\r
379         PVR2D_HANDLE                    hUseCode;                       /* custom USE code (NULL implies source copy) */\r
380         PVR2D_ULONG                             UseParams[2];           /* per-blt params for use code */\r
381 \r
382 } PVR2D_3DBLT, *PPVR2D_3DBLT;\r
383 \r
384 typedef struct\r
385 {\r
386         PVR2D_SURFACE                   sDst;                                           /* destination surface */\r
387         PVR2DRECT                               rcDest;                                         /* destination rectangle; scaling is supported */\r
388         PVR2D_SURFACE                   sSrc;                                           /* source surface */\r
389         PVR2DRECT                               rcSource;                                       /* source rectangle; scaling is supported */\r
390         PPVR2D_SURFACE                  pSrc2;                                          /* optional second source surface (NULL if not required) */\r
391         PVR2DRECT*                              prcSource2;                                     /* optional pSrc2 rectangle */\r
392         PVR2D_HANDLE                    hUseCode;                                       /* custom USSE shader code (NULL implies default source copy) */\r
393         PVR2D_ULONG                             UseParams[2];                           /* per-blt params for usse code */\r
394         PVR2D_ULONG                             uiNumTemporaryRegisters;        /* no. of temporary registers used in custom shader code */\r
395         PVR2D_BOOL                              bDisableDestInput;                      /* set true if the destination is output only */\r
396         PPVR2D_SURFACE_EXT              pDstExt;                                        /* Extended format params for dest */\r
397         PPVR2D_SURFACE_EXT              pSrcExt[2];                                     /* Extended format params for source 1 and 2 */\r
398         PVR2D_BOOL        bFilter;      /* set true to enable smoothing */\r
399         PVR2D_LONG                              Reserved[4];                            /* Reserved, must be zero */\r
400 \r
401 } PVR2D_3DBLT_EXT, *PPVR2D_3DBLT_EXT;\r
402 \r
403 \r
404 #define MAKE_COPY_BLIT(src,soff,dest,doff,sx,sy,dx,dy,sz)\r
405 \r
406 typedef void* PVR2DCONTEXTHANDLE;\r
407 typedef void* PVR2DFLIPCHAINHANDLE;\r
408 \r
409 \r
410 // CopyCode field of PVR2DBLTINFO structure:\r
411 // the CopyCode field of the PVR2DBLTINFO structure should contain a rop3 or rop4 code.\r
412 // a rop3 is an 8 bit code that describes a blt with three inputs : source dest and pattern\r
413 // rop4 is a 16 bit code that describes a blt with four inputs : source dest pattern and mask\r
414 // common rop3 codes are defined below\r
415 // a colour fill blt is processed in the pattern channel as a constant colour with a rop code of 0xF0\r
416 // PVR2D_BLIT_PAT_SURFACE_ENABLE defines whether the pattern channel is a surface or a fill colour.\r
417 // a rop4 is defined by two rop3 codes, and the 1 bit-per-pixel mask surface defines which is used.\r
418 // a common rop4 is 0xAAF0 which is the mask copy blt used for text glyphs.\r
419 // CopyCode is taken to be a rop4 when pMaskMemInfo is non zero, otherwise it is assumed to be a rop3\r
420 // use the PVR2DMASKROP4 macro below to construct a rop4 from two rop3's\r
421 // rop3a is the rop used when mask pixel = 1, and rop3b when mask = 0\r
422 #define PVR2DROP4(rop3b, rop3a)                 ((rop3b<<8)|rop3a)\r
423 \r
424 /* common rop codes */\r
425 #define PVR2DROPclear                           0x00       /* 0 (whiteness) */\r
426 #define PVR2DROPset                                     0xFF       /* 1 (blackness) */\r
427 #define PVR2DROPnoop                            0xAA       /* dst (used for masked blts) */\r
428 \r
429 /* source and  dest rop codes */\r
430 #define PVR2DROPand                                     0x88       /* src AND dst */\r
431 #define PVR2DROPandReverse                      0x44       /* src AND NOT dst */\r
432 #define PVR2DROPcopy                            0xCC       /* src (used for source copy and alpha blts) */\r
433 #define PVR2DROPandInverted                     0x22       /* NOT src AND dst */\r
434 #define PVR2DROPxor                                     0x66       /* src XOR dst */\r
435 #define PVR2DROPor                                      0xEE       /* src OR dst */\r
436 #define PVR2DROPnor                                     0x11       /* NOT src AND NOT dst */\r
437 #define PVR2DROPequiv                           0x99       /* NOT src XOR dst */\r
438 #define PVR2DROPinvert                          0x55       /* NOT dst */\r
439 #define PVR2DROPorReverse                       0xDD       /* src OR NOT dst */\r
440 #define PVR2DROPcopyInverted            0x33       /* NOT src */\r
441 #define PVR2DROPorInverted                      0xBB       /* NOT src OR dst */\r
442 #define PVR2DROPnand                            0x77       /* NOT src OR NOT dst */\r
443 \r
444 /* pattern rop codes */\r
445 #define PVR2DPATROPand                          0xA0       /* pat AND dst */\r
446 #define PVR2DPATROPandReverse           0x50       /* pat AND NOT dst */\r
447 #define PVR2DPATROPcopy                         0xF0       /* pat (used for solid color fills and pattern blts) */\r
448 #define PVR2DPATROPandInverted          0x0A       /* NOT pat AND dst */\r
449 #define PVR2DPATROPxor                          0x5A       /* pat XOR dst */\r
450 #define PVR2DPATROPor                           0xFA       /* pat OR dst */\r
451 #define PVR2DPATROPnor                          0x05       /* NOT pat AND NOT dst */\r
452 #define PVR2DPATROPequiv                        0xA5       /* NOT pat XOR dst */\r
453 #define PVR2DPATROPinvert                       0x55       /* NOT dst */\r
454 #define PVR2DPATROPorReverse            0xF5       /* pat OR NOT dst */\r
455 #define PVR2DPATROPcopyInverted         0x0F       /* NOT pat */\r
456 #define PVR2DPATROPorInverted           0xAF       /* NOT pat OR dst */\r
457 #define PVR2DPATROPnand                         0x5F       /* NOT pat OR NOT dst */\r
458 \r
459 /* common rop4 codes */\r
460 #define PVR2DROP4MaskedCopy              PVR2DROP4(PVR2DROPnoop,PVR2DROPcopy)           /* masked source copy blt (used for rounded window corners etc) */\r
461 #define PVR2DROP4MaskedFill              PVR2DROP4(PVR2DROPnoop,PVR2DPATROPcopy)        /* masked colour fill blt (used for text) */\r
462 \r
463 /* Legacy support */\r
464 #define PVR2DROP3_PATMASK                       PVR2DPATROPcopy\r
465 #define PVR2DROP3_SRCMASK                       PVR2DROPcopy\r
466 \r
467 /* pixmap memory alignment */\r
468 #define PVR2D_ALIGNMENT_4                       4                       /* DWORD alignment */\r
469 #define PVR2D_ALIGNMENT_ANY                     0                       /* no alignment    */\r
470 #define PVR2D_ALIGNMENT_PALETTE         16                      /* 16 byte alignment is required for palettes */\r
471 \r
472 /* Heap number for PVR2DGetFrameBuffer */\r
473 #define PVR2D_FB_PRIMARY_SURFACE 0\r
474 \r
475 #define PVR2D_PRESENT_PROPERTY_SRCSTRIDE        (1UL << 0)\r
476 #define PVR2D_PRESENT_PROPERTY_DSTSIZE          (1UL << 1)\r
477 #define PVR2D_PRESENT_PROPERTY_DSTPOS           (1UL << 2)\r
478 #define PVR2D_PRESENT_PROPERTY_CLIPRECTS        (1UL << 3)\r
479 #define PVR2D_PRESENT_PROPERTY_INTERVAL         (1UL << 4)\r
480 \r
481 #define PVR2D_CREATE_FLIPCHAIN_SHARED           (1UL << 0)\r
482 #define PVR2D_CREATE_FLIPCHAIN_QUERY            (1UL << 1)\r
483 #define PVR2D_CREATE_FLIPCHAIN_OEMOVERLAY   (1UL << 2)\r
484 #define PVR2D_CREATE_FLIPCHAIN_AS_BLITCHAIN (1UL << 3)\r
485 \r
486 /* Colour-key colour must be translated into argb8888 format */\r
487 #define CKEY_8888(P)            (P)\r
488 #define CKEY_4444(P)            (((P&0xF000UL)<<16) | ((P&0x0F00UL)<<12) | ((P&0x00F0UL)<<8) | ((P&0x000FUL)<<4))\r
489 #define CKEY_1555(P)            (((P&0x8000UL)<<16) | ((P&0x7C00UL)<<9)  | ((P&0x3E0UL)<<6)  | ((P&0x1FUL)<<3))\r
490 #define CKEY_565(P)                     (((P&0xF800UL)<<8)  | ((P&0x7E0UL)<<5)   | ((P&0x1FUL)<<3))\r
491 #define CKEY_MASK_8888          0x00FFFFFFUL\r
492 #define CKEY_MASK_4444          0x00F0F0F0UL\r
493 #define CKEY_MASK_1555          0x00F8F8F8UL    /* Alpha is not normally included in the key test */\r
494 #define CKEY_MASK_565           0x00F8FCF8UL\r
495 \r
496 /* Fill colours must be translated into argb8888 format */\r
497 #define CFILL_4444(P)           (((P&0xF000UL)<<16) | ((P&0x0F00UL)<<12) | ((P&0x00F0UL)<<8) | ((P&0x000FUL)<<4))\r
498 #define CFILL_1555(P)           (((P&0x8000UL)<<16) | ((P&0x7C00UL)<<9)  | ((P&0x3E0UL)<<6)  | ((P&0x1FUL)<<3))\r
499 #define CFILL_565(P)            (((P&0xF800UL)<<8)  | ((P&0x7E0UL)<<5)   | ((P&0x1FUL)<<3))\r
500 \r
501 /* PVR2DCreateDeviceContext flags */\r
502 #define PVR2D_XSERVER_PROC                      0x00000001UL            /*!< Set for the Xserver connection */\r
503 \r
504 /* PVR2DMemAlloc flags */\r
505 #define PVR2D_MEM_UNCACHED                      0x00000000UL    /* Default */\r
506 #define PVR2D_MEM_CACHED                        0x00000001UL    /* Caller must flush and sync when necessary */\r
507 #define PVR2D_MEM_WRITECOMBINE          0x00000002UL\r
508 \r
509 /* Functions that the library exports */\r
510 \r
511 PVR2D_IMPORT\r
512 int PVR2DEnumerateDevices(PVR2DDEVICEINFO *pDevInfo);\r
513 \r
514 PVR2D_IMPORT\r
515 PVR2DERROR PVR2DCreateDeviceContext(PVR2D_ULONG ulDevID,\r
516                                                                         PVR2DCONTEXTHANDLE* phContext,\r
517                                                                         PVR2D_ULONG ulFlags);\r
518 \r
519 PVR2D_IMPORT\r
520 PVR2DERROR PVR2DDestroyDeviceContext(PVR2DCONTEXTHANDLE hContext);\r
521 \r
522 PVR2D_IMPORT\r
523 PVR2DERROR PVR2DGetDeviceInfo(PVR2DCONTEXTHANDLE hContext,\r
524                                                           PVR2DDISPLAYINFO *pDisplayInfo);\r
525 \r
526 PVR2D_IMPORT\r
527 PVR2DERROR PVR2DGetMiscDisplayInfo(PVR2DCONTEXTHANDLE hContext,\r
528                                                           PVR2DMISCDISPLAYINFO *pMiscDisplayInfo);\r
529 \r
530 PVR2D_IMPORT\r
531 PVR2DERROR PVR2DGetScreenMode(PVR2DCONTEXTHANDLE hContext,\r
532                                                           PVR2DFORMAT *pFormat,\r
533                                                           PVR2D_LONG *plWidth,\r
534                                                           PVR2D_LONG *plHeight,\r
535                                                           PVR2D_LONG *plStride,\r
536                                                           PVR2D_INT *piRefreshRate);\r
537 \r
538 PVR2D_IMPORT\r
539 PVR2DERROR PVR2DGetFrameBuffer(PVR2DCONTEXTHANDLE hContext,\r
540                                                            PVR2D_INT nHeap,\r
541                                                            PVR2DMEMINFO **ppsMemInfo);\r
542 \r
543 PVR2D_IMPORT\r
544 PVR2DERROR PVR2DMemAlloc(PVR2DCONTEXTHANDLE hContext,\r
545                                                  PVR2D_ULONG ulBytes,\r
546                                                  PVR2D_ULONG ulAlign,\r
547                                                  PVR2D_ULONG ulFlags,\r
548                                                  PVR2DMEMINFO **ppsMemInfo);\r
549 \r
550 PVR2D_IMPORT\r
551 PVR2DERROR PVR2DMemExport(PVR2DCONTEXTHANDLE hContext,\r
552                                                  PVR2D_ULONG ulFlags,\r
553                                                  PVR2DMEMINFO *psMemInfo,\r
554                                                  PVR2D_HANDLE *phMemHandle);\r
555 \r
556 PVR2D_IMPORT\r
557 PVR2DERROR PVR2DMemWrap(PVR2DCONTEXTHANDLE hContext,\r
558                                                 PVR2D_VOID *pMem,\r
559                                                 PVR2D_ULONG ulFlags,\r
560                                                 PVR2D_ULONG ulBytes,\r
561                                                 PVR2D_ULONG alPageAddress[],\r
562                                                 PVR2DMEMINFO **ppsMemInfo);\r
563 \r
564 PVR2D_IMPORT\r
565 PVR2DERROR PVR2DMemMap(PVR2DCONTEXTHANDLE hContext,\r
566                                                 PVR2D_ULONG ulFlags,\r
567                                                 PVR2D_HANDLE hMemHandle,\r
568                                                 PVR2DMEMINFO **ppsDstMem);\r
569 \r
570 PVR2D_IMPORT\r
571 PVR2DERROR PVR2DMemFree(PVR2DCONTEXTHANDLE hContext,\r
572                                                 PVR2DMEMINFO *psMemInfo);\r
573 \r
574 PVR2D_IMPORT\r
575 PVR2DERROR PVR2DBlt(PVR2DCONTEXTHANDLE hContext,\r
576                                         PVR2DBLTINFO *pBltInfo);\r
577 \r
578 PVR2D_IMPORT\r
579 PVR2DERROR PVR2DBltClipped(PVR2DCONTEXTHANDLE hContext,\r
580                                                    PVR2DBLTINFO *pBltInfo,\r
581                                                    PVR2D_ULONG ulNumClipRects,\r
582                                                    PVR2DRECT *pClipRects);\r
583 \r
584 PVR2D_EXPORT\r
585 PVR2DERROR PVR2DSet1555Alpha (PVR2DCONTEXTHANDLE hContext,\r
586                                                           PVR2D_UCHAR Alpha0, PVR2D_UCHAR Alpha1);\r
587 \r
588 PVR2D_IMPORT\r
589 PVR2DERROR PVR2DQueryBlitsComplete(PVR2DCONTEXTHANDLE hContext,\r
590                                                                    const PVR2DMEMINFO *pMemInfo,\r
591                                                                    PVR2D_UINT uiWaitForComplete);\r
592 \r
593 PVR2D_IMPORT\r
594 PVR2DERROR PVR2DSetPresentBltProperties(PVR2DCONTEXTHANDLE hContext,\r
595                                                                                 PVR2D_ULONG ulPropertyMask,\r
596                                                                                 PVR2D_LONG lSrcStride,\r
597                                                                                 PVR2D_ULONG ulDstWidth,\r
598                                                                                 PVR2D_ULONG ulDstHeight,\r
599                                                                                 PVR2D_LONG lDstXPos,\r
600                                                                                 PVR2D_LONG lDstYPos,\r
601                                                                                 PVR2D_ULONG ulNumClipRects,\r
602                                                                                 PVR2DRECT *pClipRects,\r
603                                                                                 PVR2D_ULONG ulSwapInterval);\r
604 \r
605 PVR2D_IMPORT\r
606 PVR2DERROR PVR2DPresentBlt(PVR2DCONTEXTHANDLE hContext,\r
607                                                    PVR2DMEMINFO *pMemInfo,\r
608                                                    PVR2D_LONG lRenderID);\r
609 \r
610 PVR2D_IMPORT\r
611 PVR2DERROR PVR2DCreateFlipChain(PVR2DCONTEXTHANDLE hContext,\r
612                                                                 PVR2D_ULONG ulFlags,\r
613                                                                 PVR2D_ULONG ulNumBuffers,\r
614                                                                 PVR2D_ULONG ulWidth,\r
615                                                                 PVR2D_ULONG ulHeight,\r
616                                                                 PVR2DFORMAT eFormat,\r
617                                                                 PVR2D_LONG *plStride,\r
618                                                                 PVR2D_ULONG *pulFlipChainID,\r
619                                                                 PVR2DFLIPCHAINHANDLE *phFlipChain);\r
620 \r
621 PVR2D_IMPORT\r
622 PVR2DERROR PVR2DDestroyFlipChain(PVR2DCONTEXTHANDLE hContext,\r
623                                                                  PVR2DFLIPCHAINHANDLE hFlipChain);\r
624 \r
625 PVR2D_IMPORT\r
626 PVR2DERROR PVR2DGetFlipChainBuffers(PVR2DCONTEXTHANDLE hContext,\r
627                                                                         PVR2DFLIPCHAINHANDLE hFlipChain,\r
628                                                                         PVR2D_ULONG *pulNumBuffers,\r
629                                                                         PVR2DMEMINFO *psMemInfo[]);\r
630 \r
631 PVR2D_IMPORT\r
632 PVR2DERROR PVR2DSetPresentFlipProperties(PVR2DCONTEXTHANDLE hContext,\r
633                                                                                  PVR2DFLIPCHAINHANDLE hFlipChain,\r
634                                                                                  PVR2D_ULONG ulPropertyMask,\r
635                                                                                  PVR2D_LONG lDstXPos,\r
636                                                                                  PVR2D_LONG lDstYPos,\r
637                                                                                  PVR2D_ULONG ulNumClipRects, \r
638                                                                                  PVR2DRECT *pClipRects,\r
639                                                                                  PVR2D_ULONG ulSwapInterval);\r
640 \r
641 PVR2D_IMPORT\r
642 PVR2DERROR PVR2DPresentFlip(PVR2DCONTEXTHANDLE hContext,\r
643                                                         PVR2DFLIPCHAINHANDLE hFlipChain,\r
644                                                         PVR2DMEMINFO *psMemInfo,\r
645                                                         PVR2D_LONG lRenderID);\r
646 \r
647 PVR2D_IMPORT\r
648 PVR2DERROR PVR2DGetAPIRev(PVR2D_LONG *lRevMajor, PVR2D_LONG *lRevMinor);\r
649 \r
650 PVR2D_IMPORT\r
651 PVR2DERROR PVR2DLoadUseCode (const PVR2DCONTEXTHANDLE hContext, const PVR2D_UCHAR       *pUseCode,\r
652                                                                         const PVR2D_ULONG UseCodeSize, PVR2D_HANDLE *pUseCodeHandle);\r
653 PVR2D_IMPORT\r
654 PVR2DERROR PVR2DFreeUseCode (const PVR2DCONTEXTHANDLE hContext, const PVR2D_HANDLE hUseCodeHandle);\r
655 \r
656 PVR2D_IMPORT\r
657 PVR2DERROR PVR2DBlt3D (const PVR2DCONTEXTHANDLE hContext, const PPVR2D_3DBLT pBlt3D);\r
658 \r
659 PVR2D_IMPORT\r
660 PVR2DERROR PVR2DBlt3DExt (const PVR2DCONTEXTHANDLE hContext, const PPVR2D_3DBLT_EXT pBlt3D);\r
661 \r
662 #ifdef __cplusplus\r
663 }\r
664 #endif \r
665 \r
666 #endif /* _PVR2D_H_ */\r
667 \r
668 /******************************************************************************\r
669  End of file (pvr2d.h)\r
670 ******************************************************************************/\r