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