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