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