1ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
2ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *
3ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Redistribution and use in source and binary forms, with or without
4ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * modification, are permitted provided that the following conditions are
5ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * met:
6ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *     * Redistributions of source code must retain the above copyright
7ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *       notice, this list of conditions and the following disclaimer.
8ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *     * Redistributions in binary form must reproduce the above
9ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *       copyright notice, this list of conditions and the following
10ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *       disclaimer in the documentation and/or other materials provided
11ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *       with the distribution.
12ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *     * Neither the name of The Linux Foundation. nor the names of its
13ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *       contributors may be used to endorse or promote products derived
14ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *       from this software without specific prior written permission.
15ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *
16ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson *
28ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson */
29ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#ifndef __c2d2_h_
30ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define __c2d2_h_
31ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
32ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#ifdef __cplusplus
33ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonextern "C" {
34ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#endif
35ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
36ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#ifndef C2D_API
37ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define C2D_API /* define API export as needed */
38ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#endif
39ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#if !defined(int32) && !defined(_INT32_DEFINED)
40ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef int                     int32;
41ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define _INT32_DEFINED
42ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#endif
43ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#if !defined(uint32) && !defined(_UINT32_DEFINED)
44ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef unsigned int            uint32;
45ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define _UINT32_DEFINED
46ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#endif
47ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
48ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*****************************************************************************/
49ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*********************** Blit definitions *****************************/
50ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*****************************************************************************/
51ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
52ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Status codes, returned by any blit function */
53ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
54ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_STATUS_OK              = 0,
55ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_STATUS_NOT_SUPPORTED   = 1,
56ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_STATUS_OUT_OF_MEMORY   = 2,
57ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_STATUS_INVALID_PARAM   = 3,
58ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_STATUS_SURFACE_IN_USE  = 4,
59ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_STATUS;
60ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
61ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
62ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Definitions of color format modes, used together with color formats */
63ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
64ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_PACK_INTO_32BIT   = (1 <<  8), /* pack into dword if set */
65ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_SWAP_ENDIANNESS   = (1 <<  9), /* swaps the order */
66ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_LINEAR_SPACE      = (1 << 10), /* linear color space */
67ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_PREMULTIPLIED     = (1 << 11), /* alpha premultiplied */
68ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_INVERT_ALPHA      = (1 << 12), /* inverts alpha */
69ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_DISABLE_ALPHA     = (1 << 13), /* disables alpha */
70ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_INTERLACED        = (1 << 14), /* YUV line-interlaced */
71ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_TRANSPARENT       = (1 << 15), /* YUV 1-bit alpha in Y */
72ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_MACROTILED        = (1 << 16), /* tiled in macro level */
73ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_TILED_4x4         = (1 << 17), /* 4x4 tiled format */
74ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_FORMAT_SWAP_RB           = (1 << 18), /* Swap R & B color components */
75ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_FORMAT_MODE;
76ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
77ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Definitions of supported RGB formats, used in C2D_RGB_SURFACE_DEF.
78ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The bits of each color channel are packed into a machine word
79ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * representing a single pixel from left to right (MSB to LSB) in the
80ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * order indicated by format name. For the sub-byte formats the pixels
81ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * are packed into bytes from left to right (MSbit to LSBit).
82ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If the C2D_FORMAT_PACK_INTO_32BIT bit is set, the minimal
83ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * machine word used for pixel storage is 32-bit and the whole word
84ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * is reversed if endianness is swapped.
85ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If the C2D_FORMAT_SWAP_ENDIANNESS bit is set, the order within a
86ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * minimal machine word representing a pixel
87ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * is reversed for both sub-byte and multi-byte formats.
88ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If the C2D_FORMAT_LINEAR_SPACE bit is set, the color space of
89ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * the formats below is considered linear, if applicable.
90ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If the C2D_FORMAT_PREMULTIPLIED bit is set, the color channels
91ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * are premultiplied with the alpha, if applicable.
92ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If the C2D_FORMAT_INVERT_ALPHA bit is set, the alpha interpretation
93ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * is inverted: 0 - opaque, 1 - transparent, if applicable.
94ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If the C2D_FORMAT_DISABLE_ALPHA bit is set, the alpha channel serves
95ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * as a placeholder and is ignored during blit, if applicable.
96ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If the C2D_FORMAT_MACROTILED bit is set, the surface is in the
97ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * tiled format : 64x32 for 8bpp, 32x32 for 16bpp formats  */
98ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
99ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_1            = 0,   /* 1-bit alpha/color expansion */
100ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
101ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_2_PALETTE    = 1,   /* 2-bit indices for palette */
102ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_4_PALETTE    = 2,   /* 4-bit indices for palette */
103ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_8_PALETTE    = 3,   /* 8-bit indices for palette */
104ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
105ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_2_L          = 4,   /* 2-bit grayscale */
106ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_4_L          = 5,   /* 4-bit grayscale */
107ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_8_L          = 6,   /* 8-bit grayscale */
108ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
109ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_2_A          = 7,   /* 2-bit alpha only */
110ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_4_A          = 8,   /* 4-bit alpha only */
111ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_8_A          = 9,   /* 8-bit alpha only */
112ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
113ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_444_RGB      = 10,  /* 12-bit colors */
114ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_565_RGB      = 11,  /* 16-bit colors */
115ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_888_RGB      = 12,  /* 24-bit colors */
116ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
117ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_1555_ARGB    = 13,  /* 16-bit colors (1-bit alpha) */
118ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_4444_ARGB    = 14,  /* 16-bit colors (4-bit alpha) */
119ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_8565_ARGB    = 15,  /* 24-bit colors (8-bit alpha) */
120ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_8888_ARGB    = 16,  /* 32-bit colors (8-bit alpha) */
121ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
122ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_5551_RGBA    = 17,  /* 16-bit colors (1-bit alpha) */
123ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_4444_RGBA    = 18,  /* 16-bit colors (4-bit alpha) */
124ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_5658_RGBA    = 19,  /* 24-bit colors (8-bit alpha) */
125ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_8888_RGBA    = 20,  /* 32-bit colors (8-bit alpha) */
126ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
127ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* derived RGB color formats (base format + mode bits) */
128ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
129ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_RGB_FORMAT;
130ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
131ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Definitions of supported YUV formats, used in C2D_YUV_SURFACE_DEF.
132ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Each of Y,U,V channels usually takes 1 byte and therefore is
133ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * individually addressable. The definitions below show how Y,U,V
134ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * channels are packed into macropixels for each particular format.
135ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The order is from left (smaller byte addresses) to right (larger
136ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * byte addresses). The first three digits (4xx) denote the chroma
137ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * subsampling in standard YUV notation. The digits in the macropixel
138ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * denote that the whole block (from the previous digit or from the
139ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * beginning) has to be repeated the number of times. Underscores
140ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * between Y,U,V channels are used to describe separate planes for
141ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * planar YUV formats. Formats are mapped to numbers so that future
142ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * versions with various YUV permutations are easy to add.
143ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If the C2D_FORMAT_INTERLACED bit is set, the line order is
144ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * interlaced: 0,2,4,...1,3,5... if applicable.
145ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If the C2D_FORMAT_TRANSPARENT bit is set, the least significant
146ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * bit of Y channel serves as alpha: 0 - transparent, 1 - opaque. */
147ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
148ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_YYUYYV   = 110, /* packed, 12-bit         */
149ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_YUYYVY   = 111, /* packed, 12-bit         */
150ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_UYYVYY   = 112, /* packed, 12-bit, "Y411" */
151ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_YUYV2Y4  = 116, /* packed, 12-bit         */
152ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_UYVY2Y4  = 117, /* packed, 12-bit, "Y41P" */
153ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
154ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_YUYV     = 120, /* packed, 16-bit, "YUY2" */
155ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_UYVY     = 121, /* packed, 16-bit, "UYVY" */
156ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_YVYU     = 122, /* packed, 16-bit, "YVYU" */
157ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_VYUY     = 123, /* packed, 16-bit         */
158ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
159ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_444_YUV      = 130, /* packed, 24-bit         */
160ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_444_UYV      = 131, /* packed, 24-bit, "IYU2" */
161ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_444_AYUV     = 136, /* packed, 24-bit, "AYUV" */
162ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
163ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_410_Y_UV     = 150, /* planar, Y + interleaved UV */
164ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_Y_UV     = 151, /* planar, Y + interleaved UV */
165ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_420_Y_UV     = 152, /* planar, Y + interleaved UV */
166ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_Y_UV     = 153, /* planar, Y + interleaved UV */
167ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_444_Y_UV     = 154, /* planar, Y + interleaved UV */
168ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
169ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_410_Y_VU     = 160, /* planar, Y + interleaved VU */
170ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_Y_VU     = 161, /* planar, Y + interleaved VU */
171ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_420_Y_VU     = 162, /* planar, Y + interleaved VU */
172ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_Y_VU     = 163, /* planar, Y + interleaved VU */
173ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_444_Y_VU     = 164, /* planar, Y + interleaved VU */
174ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
175ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_410_Y_U_V    = 170, /* planar, Y + U + V separate */
176ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_Y_U_V    = 171, /* planar, Y + U + V separate */
177ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_420_Y_V_U    = 172, /* planar, Y + V + U separate */
178ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_420_Y_U_V    = 173, /* planar, Y + U + V separate */
179ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_Y_U_V    = 174, /* planar, Y + U + V separate */
180ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_444_Y_U_V    = 175, /* planar, Y + U + V separate */
181ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
182ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_800_Y        = 190, /* planar, Y only, grayscale */
183ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
184ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* derived YUV color formats (base format + mode bits), FOURCC */
185ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
186ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_Y411     = 112,
187ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_Y41P     = 117,
188ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_IY41     = 117 | (1 << 14),
189ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_Y41T     = 117 | (1 << 15),
190ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
191ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_YUY2     = 120,
192ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_IUYV     = 121 | (1 << 14),
193ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_Y42T     = 121 | (1 << 15),
194ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_444_IYU2     = 131,
195ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
196ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_420_NV12     = 152,
197ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_420_NV21     = 162,
198ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
199ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_410_YUV9     = 170,
200ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_410_YVU9     = 170,
201ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_411_Y41B     = 171,
202ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_420_YV12     = 172,
203ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_420_IYUV     = 173,
204ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_420_I420     = 173,
205ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_YV16     = 174,
206ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_422_Y42B     = 174,
207ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
208ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_FORMAT_800_Y800     = 190,
209ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
210ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_YUV_FORMAT;
211ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
212ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
213ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Configuration bits, used in the config_mask field of C2D_OBJECT struct */
214ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
215ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_SOURCE_RECT_BIT      = (1 <<  0), /* enables source_rect field */
216ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_MIRROR_H_BIT         = (1 <<  1), /* enables horizontal flipping */
217ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_MIRROR_V_BIT         = (1 <<  2), /* enables vertical flipping */
218ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_SOURCE_TILE_BIT      = (1 <<  3), /* enables source surface tiling */
219ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_RECT_BIT      = (1 <<  4), /* enables target_rect field */
220ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ROTATE_BIT           = (1 <<  5), /* enables all rotation fields */
221ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_SCISSOR_RECT_BIT     = (1 <<  6), /* enables scissor_rect field */
222ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_MASK_SURFACE_BIT     = (1 <<  7), /* enables mask_surface_id field */
223ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_MASK_ALIGN_BIT       = (1 <<  8), /* aligns mask to source_rect */
224ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_MASK_SCALE_BIT       = (1 <<  9), /* enables mask surface scaling */
225ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_MASK_TILE_BIT        = (1 << 10), /* enables mask surface tiling */
226ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_GLOBAL_ALPHA_BIT     = (1 << 11), /* enables global_alpha field */
227ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_COLOR_KEY_BIT        = (1 << 12), /* enables color_key field */
228ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_NO_PIXEL_ALPHA_BIT   = (1 << 13), /* disables source alpha channel */
229ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_NO_BILINEAR_BIT      = (1 << 14), /* disables bilinear on scaling */
230ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_NO_ANTIALIASING_BIT  = (1 << 15), /* disables antialiasing on edges */
231ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRAW_LINE_BIT        = (1 << 16), /* enables line drawing with source rectangle */
232ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRAW_LINE_NOLAST     = (1 << 17), /* disable last pixel draw for line */
233ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_SOURCE_CONFIG;
234ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
235ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
236ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Target configuration bits, defines rotation + mirroring.
237ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Mirror is applied prior to rotation if enabled. */
238ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
239ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_MIRROR_H        = (1 << 0), /* horizontal flip */
240ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_MIRROR_V        = (1 << 1), /* vertical flip */
241ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_ROTATE_0        = (0 << 2), /* no rotation */
242ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_ROTATE_90       = (1 << 2), /* 90 degree rotation */
243ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_ROTATE_180      = (2 << 2), /* 180 degree rotation */
244ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_ROTATE_270      = (3 << 2), /* 270 degree rotation, 90 + 180 */
245ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_MASK_ALIGN      = (1 << 4), /* aligns mask to target scissor */
246ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_MASK_SCALE      = (1 << 5), /* enables mask scaling */
247ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_MASK_TILE       = (1 << 6), /* enables mask tiling */
248ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_COLOR_KEY       = (1 << 7), /* enables target_color_key */
249ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET_NO_PIXEL_ALPHA  = (1 << 8), /* disables target alpha channel */
250ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_TARGET_CONFIG;
251ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
252ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define C2D_TARGET_ROTATION_MASK  (C2D_TARGET_ROTATE_90*3)
253ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
254ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Additional blend modes, can be used with both source and target configs.
255ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson   If none of the below is set, the default "SRC over DST" is applied. */
256ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
257ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_SRC_OVER   = (0  << 20), /* Default, Porter-Duff "SRC over DST" */
258ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_SRC        = (1  << 20), /* Porter-Duff "SRC" */
259ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_SRC_IN     = (2  << 20), /* Porter-Duff "SRC in DST" */
260ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_DST_IN     = (3  << 20), /* Porter-Duff "DST in SRC" */
261ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_SRC_OUT    = (4  << 20), /* Porter-Duff "SRC out DST" */
262ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_DST_OUT    = (5  << 20), /* Porter-Duff "DST out SRC" */
263ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_DST_OVER   = (6  << 20), /* Porter-Duff "DST over SRC" */
264ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_SRC_ATOP   = (7  << 20), /* Porter-Duff "SRC ATOP" */
265ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_DST_ATOP   = (8  << 20), /* Porter-Duff "DST ATOP" */
266ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_XOR        = (9  << 20), /* Xor */
267ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_MULTIPLY   = (10 << 20), /* OpenVG "MULTIPLY" */
268ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_SCREEN     = (11 << 20), /* OpenVG "SCREEN" */
269ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_DARKEN     = (12 << 20), /* OpenVG "DARKEN" */
270ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_LIGHTEN    = (13 << 20), /* OpenVG "LIGHTEN" */
271ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_ADDITIVE   = (14 << 20), /* OpenVG "ADDITIVE" */
272ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_DIRECT     = (15 << 20), /* Direct alpha blitting */
273ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_INVERTC    = (16 << 20), /* Invert color */
274ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_ALPHA_BLEND_NONE       = (1  << 25), /* disables alpha blending */
275ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_ALPHA_BLEND_MODE;
276ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
277ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Configuration bits, used in the config_mask field of C2D_OBJECT struct */
278ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
279ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_OVERRIDE_GLOBAL_TARGET_ROTATE_CONFIG = (1 << 27), /* Overrides TARGET Config */
280ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_OVERRIDE_TARGET_ROTATE_0             = (0 << 28), /* no rotation             */
281ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_OVERRIDE_TARGET_ROTATE_90            = (1 << 28), /* 90 degree rotation      */
282ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_OVERRIDE_TARGET_ROTATE_180           = (2 << 28), /* 180 degree rotation     */
283ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_OVERRIDE_TARGET_ROTATE_270           = (3 << 28), /* 270 degree rotation     */
284ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_SOURCE_TARGET_CONFIG;
285ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
286ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define C2D_OVERRIDE_SOURCE_CONFIG_TARGET_ROTATION_SHIFT_MASK  28
287ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define C2D_OVERRIDE_TARGET_CONFIG_TARGET_ROTATION_SHIFT_MASK  2
288ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
289ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
290ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Surface caps enumeration */
291ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
292ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_SOURCE          = (1 << 0), /* allows to use as a source */
293ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_TARGET          = (1 << 1), /* allows to use as a target */
294ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_MASK            = (1 << 2), /* allows to use as a mask */
295ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_PALETTE         = (1 << 3), /* allows to use as a palette */
296ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_SURFACE_BITS;
297ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
298ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Surface type enumeration */
299ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
300ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_SURFACE_RGB_HOST        = 1, /* Host memory RGB surface */
301ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_SURFACE_RGB_EXT         = 2, /* External memory RGB surface */
302ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_SURFACE_YUV_HOST        = 3, /* Host memory YUV surface */
303ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_SURFACE_YUV_EXT         = 4, /* External memory YUV surface */
304ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_SURFACE_WITH_PHYS       = (1<<3), /* physical address already mapped */
305ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                                        /* this bit is valid with HOST types */
306ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_SURFACE_WITH_PHYS_DUMMY = (1<<4), /* physical address already mapped */
307ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                                        /* this bit is valid with HOST types */
308ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_SURFACE_TYPE;
309ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
310ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Structure for registering a RGB buffer as a blit surface */
311ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef struct {
312ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 format;   /* RGB color format plus additional mode bits */
313ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 width;    /* defines width in pixels */
314ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 height;   /* defines height in pixels */
315ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void  *buffer;   /* pointer to the RGB buffer */
316ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void  *phys;     /* physical address */
317ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32  stride;   /* defines stride in bytes, negative stride is allowed */
318ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_RGB_SURFACE_DEF;
319ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
320ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Structure for registering a YUV plane(s) as a blit surface */
321ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef struct {
322ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 format;   /* YUV color format plus additional mode bits */
323ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 width;    /* defines width in pixels */
324ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 height;   /* defines height in pixels */
325ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void  *plane0;  /* holds the whole buffer if YUV format is not planar */
326ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void  *phys0;   /* physical address */
327ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32  stride0; /* stride in bytes if YUV format is not planar */
328ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void  *plane1;  /* holds UV or VU plane for planar interleaved */
329ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void  *phys1;   /* physical address */
330ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32  stride1; /* stride for UV or VU plane for planar interleaved */
331ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void  *plane2;  /* holds the 3. plane, ignored if YUV format is not planar */
332ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void  *phys2;    /* physical address */
333ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32  stride2; /* stride for the 3. plane, ignored if YUV format is not planar */
334ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_YUV_SURFACE_DEF;
335ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
336ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
337ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Rectangle definition */
338ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef struct {
339ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32 x;        /* upper-left x */
340ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32 y;        /* upper-left y */
341ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32 width;    /* width */
342ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32 height;   /* height */
343ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_RECT;
344ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
345ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* C2D_OBJECT encapsulates the blit parameters for a source surface.
346ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The fg_color defines color in target format for bits equal to 1
347ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * in the source C2D_COLOR_FORMAT_1 format. It also defines rendering
348ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * color for all alpha-only source formats. If the surface_id is 0
349ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * the fg_color defines a constant fill color used instead of the surface.
350ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The bg_color defines color in target format for bits equal to 0
351ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * in the source C2D_COLOR_FORMAT_1 format, otherwise both are ignored.
352ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The palette_id is used for all palette source formats, otherwise ignored.
353ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
354ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The source_rect first defines the content of the source surface,
355ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * it is then horizontally/vertically flipped if C2D_MIRROR_*_BIT is set,
356ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * then scaled with bilinear interpolation to exactly fit target_rect
357ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * or repeated across target_rect if C2D_SOURCE_TILE_BIT is set,
358ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * target_rect is then rotated clockwise by an arbitrary angle in degrees
359ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * around the rot_orig_x/y, defined relative to target_rect's top left point,
360ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * and then clipped to scissor_rect defined in target coordinate system.
361ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
362ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Finally alpha blending is applied before pixels get written into the target.
363ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Surface's pixel alpha is combined with mask alpha and with global alpha.
364ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Mask surface follows all transformations applied to the source surface.
365ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Source color key defines transparent color, applied together with alpha. */
366ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef struct C2D_OBJECT_STR {
367ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 surface_id;      /* source surface */
368ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
369ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 fg_color;        /* foreground color */
370ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 bg_color;        /* background color */
371ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 palette_id;      /* one-dimensional horizontal palette surface */
372ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
373ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 config_mask;     /* defines which fields below are enabled */
374ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
375ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_RECT source_rect;  /* region of the source surface,   16.16 fp */
376ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_RECT target_rect;  /* position and scaling in target, 16.16 fp */
377ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
378ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32 rot_orig_x;       /* rotation origin relative to target_rect's... */
379ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32 rot_orig_y;       /* ...top left point,     both are 16.16 fp */
380ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int32 rotation;         /* clock-wise rotation in degrees, 16.16 fp */
381ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
382ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_RECT scissor_rect; /* defines the clip rectangle in target surface */
383ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
384ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 mask_surface_id; /* source alpha-mask surface */
385ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 global_alpha;    /* 0 = fully transparent, 255 = fully opaque */
386ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 color_key;       /* transparent color for the source surface */
387ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
388ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    struct C2D_OBJECT_STR *next; /* pointer to the next object or NULL */
389ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_OBJECT;
390ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
391ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Configuration bits, driver capabilities used by 2Dapplications */
392ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
393ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_GLOBAL_ALPHA_OP           = (1 << 0),
394ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_TILE_OP                   = (1 << 1),
395ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_COLOR_KEY_OP              = (1 << 2),
396ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_NO_PIXEL_ALPHA_OP         = (1 << 3),
397ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_TARGET_ROTATE_OP          = (1 << 4),
398ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_ANTI_ALIASING_OP          = (1 << 5), /* antialiasing */
399ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_BILINEAR_FILTER_OP        = (1 << 6),
400ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_LENS_CORRECTION_OP        = (1 << 7),
401ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_OVERRIDE_TARGET_ROTATE_OP = (1 << 8),
402ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_SHADER_BLOB_OP            = (1 << 9),
403ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_MASK_SURFACE_OP           = (1 << 10), /* mask surface */
404ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_MIRROR_H_OP               = (1 << 11), /* horizontal flip */
405ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_MIRROR_V_OP               = (1 << 12), /* vertical flip */
406ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_SCISSOR_RECT_OP           = (1 << 13),
407ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_SOURCE_RECT_OP            = (1 << 14),
408ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_TARGET_RECT_OP            = (1 << 15),
409ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_ROTATE_OP                 = (1 << 16), /* all rotations */
410ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_FLUSH_WITH_FENCE_FD_OP    = (1 << 17), /* all rotations */
411ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_SUPPORTS_ALL_CAPABILITIES_OP       = ((0xFFFFFFFF) >> (31 - 17)) /* mask for all capabilities supported */
412ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_DRIVER_CAPABILITIES;
413ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
414ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* 2D driver workaround bits used by the 2D applications */
415ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
416ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_WORKAROUND_NONE  = 0, /* NO workaround */
417ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DRIVER_WORKAROUND_SWAP_UV_FOR_YUV_TARGET  = (1 << 0), /* Swap UV when this flag set */
418ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_DRIVER_WORKAROUND;
419ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
420ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Structure to query Driver information */
421ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef struct {
422ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 capabilities_mask;
423ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 workaround_mask;
424ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 reserved1;
425ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 reserved2;
426ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32 reserved3;
427ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_DRIVER_INFO;
428ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
429ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Structure to query Driver information */
430ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef struct {
431ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32          max_surface_template_needed;
432ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32          reserved1;
433ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32          reserved2;
434ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32          reserved3;
435ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_DRIVER_SETUP_INFO;
436ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
437ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*****************************************************************************/
438ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/**************************** C2D API 2.0 ********************************/
439ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*****************************************************************************/
440ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
441ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/******************************************************************************
442ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Functions to create/destroy surfaces */
443ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
444ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Creates a generic blit surface according to its type.
445ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Pass a combination of desired surface bits according to planned usage.
446ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Accepted values for surface_bits may include bits from C2D_SURFACE_BITS,
447ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * and also from C2D_DISPLAY for compatibility with HW display controller.
448ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * For host memory types the memory is preallocated outside the API
449ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * and should remain valid until surface is destroyed.
450ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * For external memory types the memory is allocated within API.
451ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * On success, the non-zero surface identifier is returned.
452ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * All numbers greater that 0 are valid surface identifiers, 0 is invalid.
453ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
454ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Host memory RGB surface:
455ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface_type       = C2D_SURFACE_RGB_HOST
456ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface_definition = C2D_RGB_SURFACE_DEF
457ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * all fields in definition structure should be set
458ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
459ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * External memory RGB surface:
460ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface_type       = C2D_SURFACE_RGB_EXT
461ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface_definition = C2D_RGB_SURFACE_DEF
462ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * buffer field in definition structure is ignored
463ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
464ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Host memory YUV surface:
465ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface_type       = C2D_SURFACE_YUV_HOST
466ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface_definition = C2D_YUV_SURFACE_DEF
467ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * one or all plane and stride fields in definition structure
468ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * should be set depending on whether the format is planar or not
469ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
470ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * External memory YUV surface:
471ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface_type       = C2D_SURFACE_YUV_EXT
472ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface_definition = C2D_YUV_SURFACE_DEF
473ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * all plane and stride fields in definition structure are ignored */
474ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dCreateSurface( uint32 *surface_id,
475ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 surface_bits,
476ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         C2D_SURFACE_TYPE surface_type,
477ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         void *surface_definition );
478ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
479ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Requests properties of the specified surface. */
480ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dQuerySurface( uint32 surface_id,
481ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 *surface_bits,
482ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         C2D_SURFACE_TYPE *surface_type,
483ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 *width, uint32 *height,
484ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 *format );
485ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
486ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Destroys a generic blit surface.
487ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * For external memory surfaces also deallocates the memory.
488ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * It is safe to free any external resources associated with a given
489ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface on c2dCreateSurface call after this function returns. */
490ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dDestroySurface( uint32 surface_id );
491ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
492ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
493ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/******************************************************************************
494ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Functions to modify/exchange surface data */
495ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
496ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* The format of fill_color is the same as color format being used
497ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * for specified surface. If fill_rect is NULL the whole surface is filled.
498ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Alpha-blending is not performed while filling.
499ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The operation is complete when function returns. */
500ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dFillSurface( uint32 surface_id,
501ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 fill_color,
502ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         C2D_RECT *fill_rect );
503ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
504ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Writes data located in host memory into the specified surface.
505ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The chunk of host memory is identified with surface_type and
506ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface_definition, no surface registration needed in this case.
507ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Only C2D_SURFACE_RGB_HOST, C2D_SURFACE_YUV_HOST are accepted.
508ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If only part of the host memory buffer should be loaded, it should
509ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * be configured in surface_definition using width, height and stride.
510ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The x and y are defined in target surface coordinate space.
511ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Color conversion has to be done, if color formats differ.
512ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Alpha-blending is not performed while writing.
513ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The operation is complete when function returns. */
514ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dWriteSurface( uint32 surface_id,
515ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         C2D_SURFACE_TYPE surface_type,
516ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         void *surface_definition,
517ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         int32 x, int32 y );
518ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
519ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Reads data from the specified surface into the host memory.
520ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The chunk of host memory is identified with surface_type and
521ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * surface_definition, no surface registration needed in this case.
522ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Only C2D_SURFACE_RGB_HOST, C2D_SURFACE_YUV_HOST are accepted.
523ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If only part of the surface should be read, it should
524ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * be configured in surface_definition using width, height and stride.
525ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The x and y are defined in source surface coordinate space.
526ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Color conversion has to be done, if color formats differ.
527ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Alpha-blending is not performed while reading.
528ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The operation is complete when function returns. */
529ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dReadSurface( uint32 surface_id,
530ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         C2D_SURFACE_TYPE surface_type,
531ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         void *surface_definition,
532ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         int32 x, int32 y );
533ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
534ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Notifies c2d imlementation that surface has been updated from outside the API,
535ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * if updated_rect is NULL then the whole surface has been updated. */
536ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dSurfaceUpdated( uint32 surface_id,
537ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         C2D_RECT *updated_rect );
538ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
539ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Updates surface information.
540ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Could be called only for host surfaces set with parameter "C2D_SURFACE_WITH_PHYS".
541ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Count for surface planes have to be same than for already allocated surface */
542ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dUpdateSurface( uint32 surface_id,
543ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 surface_bits,
544ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         C2D_SURFACE_TYPE surface_type,
545ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         void *surface_definition );
546ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
547ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/******************************************************************************
548ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Functions to do actual blit */
549ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
550ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Draw a list of blit objects into the given target.
551ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The target_config is a bitwise OR of values from C2D_TARGET_CONFIG.
552ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The target transformation creates the effect that target surface
553ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * is transformed before the blit and then transformed back
554ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * after blit, however no physical target transform is performed.
555ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The objects_list is a linked list of blit objects, no more
556ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * than num_objects is drawn from the given list.
557ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * If num_objects is 0, the whole list is drawn.
558ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The blit is not guaranteed to complete after function returns. */
559ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dDraw( uint32 target_id,
560ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 target_config, C2D_RECT *target_scissor,
561ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 target_mask_id, uint32 target_color_key,
562ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         C2D_OBJECT *objects_list, uint32 num_objects );
563ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
564ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
565ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* timstamp set in the blit commands flush */
566ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef void*                   c2d_ts_handle;
567ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
568ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Forces any pending blit to complete for a given target.
569ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Non-blocking. All input surfaces for this target except those
570ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * which are shared with other targets are expected to be immediately
571ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * writable after client has been waiting returned timestamp with
572ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * c2dWaitTimestamp funtion or c2dFinish has been called for same target */
573ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dFlush( uint32 target_id, c2d_ts_handle *timestamp);
574ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
575ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
576ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Waits the pending timestamp */
577ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dWaitTimestamp( c2d_ts_handle timestamp );
578ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
579ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
580ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Forces any pending blit to complete for a given target.
581ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Blocking version, returns when blit is done.
582ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * All input surfaces for this target except those which are shared with
583ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * other targets are expected to be immediately
584ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * writable after this function returns. */
585ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dFinish( uint32 target_id );
586ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
587ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
588ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*****************************************************************************/
589ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/****************************** Display API **********************************/
590ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*****************************************************************************/
591ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
592ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
593ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Display input enumeration */
594ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
595ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DISPLAY_INPUT_0      = 0,       /*!< default input */
596ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DISPLAY_INPUT_1      = (1<<16), /*!< Overlay 1     */
597ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DISPLAY_INPUT_2      = (1<<17), /*!< Overlay 2...    */
598ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_DISPLAY_INPUT;
599ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
600ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
601ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/******************************************************************************
602ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Functions for display output. */
603ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
604ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Functionality described in this section is optional and is
605ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * provided only for the cases when blit HW
606ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * is tightly bound to the display controller. */
607ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
608ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Display enumeration, may also be used in surface caps */
609ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
610ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DISPLAY_MAIN         = (1 << 10), /* main display */
611ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DISPLAY_SECONDARY    = (1 << 11), /* secondary display */
612ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DISPLAY_TV_OUT       = (1 << 12), /* tv-out */
613ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_DISPLAY;
614ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
615ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Display window enumeration */
616ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
617ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DISPLAY_OVERLAY      = C2D_DISPLAY_INPUT_1, /*!< Overlay window bit. This defines display input.
618ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                                                When defined the surface is set on the overlay window
619ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                                                otherwise the surface is set on the background window. */
620ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_DISPLAY_WINDOW;                    /*!< Window bit set with display parameter */
621ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
622ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
623ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Display update modes */
624ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsontypedef enum {
625ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DISPLAY_MODE_TEAR_SYNC   = (1 << 0), /* enables tearing sync */
626ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    C2D_DISPLAY_MODE_SURF_REMOVE = (1 << 1), /* Remove surface from given display + input */
627ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} C2D_DISPLAY_MODE;
628ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
629ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
630ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Sets the given surface as a current display front buffer.
631ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Several displays can be specified as an output if supported.
632ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Still only one input can be specified at a time fro display/displays.
633ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The surface remains shown until it gets replaced with another one. */
634ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dDisplaySetSurface( uint32 display,
635ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 surface_id, uint32 mode );
636ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
637ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Returns the current surface for a particular display.
638ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Only one display can be specified at a time.
639ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * The latest surface set with compDisplaySetSurface or
640ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * the default pre-allocated surface is returned. */
641ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dDisplayGetSurface( uint32 display,
642ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 *surface_id );
643ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
644ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Returns the properties for a particular display.
645ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Only one display can be specified at a time. */
646ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dDisplayGetProperties( uint32 display,
647ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 *width, uint32 *height,
648ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 *format );
649ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
650ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* Sets the properties for a particular display input.
651ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Only one display + input can be specified at a time.
652ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * C2D_OBJECT used to set input rect(target rect),
653ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * blending operations, rotation...etc for display source */
654ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dDisplaySetObject( uint32 display,
655ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         uint32 target_config, uint32 target_color_key,
656ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson                         C2D_OBJECT * c2dObject, uint32 mode);
657ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
658ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* allows user to map a memory region to the gpu. only supported on linux
659ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * mem_fd is the fd of the memory region, hostptr is the host pointer to the region,
660ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * len and offset are the size and offset of the memory.
661ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * flags is one of the memory types supported by gsl
662ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * gpaddr is passed by refernce back to the user
663ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson */
664ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dMapAddr ( int mem_fd, void * hostptr, uint32 len, uint32 offset, uint32 flags, void ** gpuaddr);
665ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
666ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* allows user to unmap memory region mapped by c2dMapAddr.
667ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * gpaddr is the gpuaddr to unmap */
668ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dUnMapAddr (void * gpuaddr);
669ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
670ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* allows user to query driver capabilities.
671ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * driver_info is the information about driver */
672ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dGetDriverCapabilities( C2D_DRIVER_INFO * driver_info);
673ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
674ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* create a fence fd for the timestamp */
675ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon WilsonC2D_API C2D_STATUS c2dCreateFenceFD( uint32 target_id, c2d_ts_handle timestamp, int32 *fd);
676ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
677ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*****************************************************************************/
678ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
679ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#ifdef __cplusplus
680ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson}
681ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#endif
682ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
683ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#endif /* __c2d2_h_ */
684