summaryrefslogtreecommitdiffstats
path: root/exynos4/hal/libfimg4x/sec_g2d_4x.h
blob: b9ddbb2ebb59ba7f06b17cff57db995734c457e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/*
 * Copyright 2011, Samsung Electronics Co. LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef __SEC_G2D_4X_H
#define __SEC_G2D_4X_H __FILE__

#define SEC_G2D_DEV_NAME             "/dev/fimg2d"

/* ioctl commands */
#define FIMG2D_IOCTL_MAGIC           'F'
#define FIMG2D_BITBLT_BLIT           _IOWR(FIMG2D_IOCTL_MAGIC, 0, struct fimg2d_blit)
#define FIMG2D_BITBLT_SYNC           _IO(FIMG2D_IOCTL_MAGIC, 1)
#define FIMG2D_BITBLT_VERSION        _IOR(FIMG2D_IOCTL_MAGIC, 2, struct fimg2d_version)

#define G2D_ALPHA_VALUE_MAX          (255)

enum addr_space {
    ADDR_UNKNOWN,
    ADDR_PHYS,
    ADDR_KERN,
    ADDR_USER,
    ADDR_DEVICE,
};

/**
 * DO NOT CHANGE THIS ORDER
 */
enum pixel_order {
    AX_RGB = 0,
    RGB_AX,
    AX_BGR,
    BGR_AX,
    ARGB_ORDER_END,

    P1_CRY1CBY0,
    P1_CBY1CRY0,
    P1_Y1CRY0CB,
    P1_Y1CBY0CR,
    P1_ORDER_END,

    P2_CRCB,
    P2_CBCR,
    P2_ORDER_END,
};

/**
 * DO NOT CHANGE THIS ORDER
 */
enum color_format {
    CF_XRGB_8888 = 0,
    CF_ARGB_8888,
    CF_RGB_565,
    CF_XRGB_1555,
    CF_ARGB_1555,
    CF_XRGB_4444,
    CF_ARGB_4444,
    CF_RGB_888,
    CF_YCBCR_444,
    CF_YCBCR_422,
    CF_YCBCR_420,
    CF_A8,
    CF_L8,
    SRC_DST_FORMAT_END,

    CF_MSK_1BIT,
    CF_MSK_4BIT,
    CF_MSK_8BIT,
    CF_MSK_16BIT_565,
    CF_MSK_16BIT_1555,
    CF_MSK_16BIT_4444,
    CF_MSK_32BIT_8888,
    MSK_FORMAT_END,
};

enum rotation {
    ORIGIN,
    ROT_90,    /* clockwise */
    ROT_180,
    ROT_270,
    XFLIP,    /* x-axis flip */
    YFLIP,    /* y-axis flip */
};

/**
 * @NO_REPEAT: no effect
 * @REPEAT_NORMAL: repeat horizontally and vertically
 * @REPEAT_PAD: pad with pad color
 * @REPEAT_REFLECT: reflect horizontally and vertically
 * @REPEAT_CLAMP: pad with edge color of original image
 *
 * DO NOT CHANGE THIS ORDER
 */
enum repeat {
    NO_REPEAT = 0,
    REPEAT_NORMAL,    /* default setting */
    REPEAT_PAD,
    REPEAT_REFLECT, REPEAT_MIRROR = REPEAT_REFLECT,
    REPEAT_CLAMP,
};

enum scaling {
    NO_SCALING,
    SCALING_NEAREST,
    SCALING_BILINEAR,
};

/**
 * @SCALING_PERCENTAGE: percentage of width, height
 * @SCALING_PIXELS: coordinate of src, dest
 */
enum scaling_factor {
    SCALING_PERCENTAGE,
    SCALING_PIXELS,
};

/**
 * premultiplied alpha
 */
enum premultiplied {
    PREMULTIPLIED,
    NON_PREMULTIPLIED,
};

/**
 * @TRANSP: discard bluescreen color
 * @BLUSCR: replace bluescreen color with background color
 */
enum bluescreen {
    OPAQUE,
    TRANSP,
    BLUSCR,
};

/**
 * DO NOT CHANGE THIS ORDER
 */
enum blit_op {
    BLIT_OP_SOLID_FILL = 0,

    BLIT_OP_CLR,
    BLIT_OP_SRC, BLIT_OP_SRC_COPY = BLIT_OP_SRC,
    BLIT_OP_DST,
    BLIT_OP_SRC_OVER,
    BLIT_OP_DST_OVER, BLIT_OP_OVER_REV = BLIT_OP_DST_OVER,
    BLIT_OP_SRC_IN,
    BLIT_OP_DST_IN, BLIT_OP_IN_REV = BLIT_OP_DST_IN,
    BLIT_OP_SRC_OUT,
    BLIT_OP_DST_OUT, BLIT_OP_OUT_REV = BLIT_OP_DST_OUT,
    BLIT_OP_SRC_ATOP,
    BLIT_OP_DST_ATOP, BLIT_OP_ATOP_REV = BLIT_OP_DST_ATOP,
    BLIT_OP_XOR,

    BLIT_OP_ADD,
    BLIT_OP_MULTIPLY,
    BLIT_OP_SCREEN,
    BLIT_OP_DARKEN,
    BLIT_OP_LIGHTEN,

    BLIT_OP_DISJ_SRC_OVER,
    BLIT_OP_DISJ_DST_OVER, BLIT_OP_SATURATE = BLIT_OP_DISJ_DST_OVER,
    BLIT_OP_DISJ_SRC_IN,
    BLIT_OP_DISJ_DST_IN, BLIT_OP_DISJ_IN_REV = BLIT_OP_DISJ_DST_IN,
    BLIT_OP_DISJ_SRC_OUT,
    BLIT_OP_DISJ_DST_OUT, BLIT_OP_DISJ_OUT_REV = BLIT_OP_DISJ_DST_OUT,
    BLIT_OP_DISJ_SRC_ATOP,
    BLIT_OP_DISJ_DST_ATOP, BLIT_OP_DISJ_ATOP_REV = BLIT_OP_DISJ_DST_ATOP,
    BLIT_OP_DISJ_XOR,

    BLIT_OP_CONJ_SRC_OVER,
    BLIT_OP_CONJ_DST_OVER, BLIT_OP_CONJ_OVER_REV = BLIT_OP_CONJ_DST_OVER,
    BLIT_OP_CONJ_SRC_IN,
    BLIT_OP_CONJ_DST_IN, BLIT_OP_CONJ_IN_REV = BLIT_OP_CONJ_DST_IN,
    BLIT_OP_CONJ_SRC_OUT,
    BLIT_OP_CONJ_DST_OUT, BLIT_OP_CONJ_OUT_REV = BLIT_OP_CONJ_DST_OUT,
    BLIT_OP_CONJ_SRC_ATOP,
    BLIT_OP_CONJ_DST_ATOP, BLIT_OP_CONJ_ATOP_REV = BLIT_OP_CONJ_DST_ATOP,
    BLIT_OP_CONJ_XOR,

    /* Add new operation type here */

    /* user select coefficient manually */
    BLIT_OP_USER_COEFF,

    /* end of blit operation */
    BLIT_OP_END,

    /* driver not supporting format */
    BLIT_OP_NOT_SUPPORTED
};

#define MAX_FIMG2D_BLIT_OP (int)BLIT_OP_END

struct fimg2d_version {
    unsigned int hw;
    unsigned int sw;
};

/**
 * @start: start address or unique id of image
 * @size: whole length of allocated image
 * @cacheable: memory is cacheable
 * @pinnable: memory is pinnable. currently not supported.
 */
struct fimg2d_addr {
    enum addr_space type;
    unsigned long start;
    size_t size;
    int cacheable;
    int pinnable;
};

struct fimg2d_rect {
    int x1;
    int y1;
    int x2;    /* x1 + width */
    int y2; /* y1 + height */
};

/**
 * if factor is percentage, scale_w and scale_h are valid
 * if factor is pixels, src_w, src_h, dst_w, dst_h are valid
 */
struct fimg2d_scale {
    enum scaling mode;
    enum scaling_factor factor;

    /* percentage */
    int scale_w;
    int scale_h;

    /* pixels */
    int src_w, src_h;
    int dst_w, dst_h;
};

/**
 * coordinate from start address(0,0) of image
 */
struct fimg2d_clip {
    bool enable;
    int x1;
    int y1;
    int x2;    /* x1 + width */
    int y2; /* y1 + height */
};

struct fimg2d_repeat {
    enum repeat mode;
    unsigned long pad_color;
};

/**
 * @bg_color: bg_color is valid only if bluescreen mode is BLUSCR.
 */
struct fimg2d_bluscr {
    enum bluescreen mode;
    unsigned long bs_color;
    unsigned long bg_color;
};

/**
 * @plane2: address info for CbCr in YCbCr 2plane mode
 */
struct fimg2d_image {
    struct fimg2d_addr addr;
    struct fimg2d_addr plane2;
    int width;
    int height;
    int stride;
    enum pixel_order order;
    enum color_format fmt;
};

struct fimg2d_param {
    enum blit_op op;
    unsigned long fillcolor;
    unsigned char g_alpha;
    enum premultiplied premult;
    bool dither;
    enum rotation rotate;
    struct fimg2d_scale *scaling;
    struct fimg2d_repeat *repeat;
    struct fimg2d_bluscr *bluscr;
    struct fimg2d_clip *clipping;
};

/**
 * @g_alpha: 0xff is opaque, 0x0 is transparnet
 * @seq_no: used for debugging
 */
struct fimg2d_blit {
    enum blit_op op;

    enum premultiplied premult;
    unsigned char g_alpha;
    bool dither;
    enum rotation rotate;
    struct fimg2d_scale *scaling;
    struct fimg2d_repeat *repeat;
    struct fimg2d_bluscr *bluscr;
    struct fimg2d_clip *clipping;

    unsigned long solid_color;
    struct fimg2d_image *src;
    struct fimg2d_image *dst;
    struct fimg2d_image *msk;

    struct fimg2d_rect *src_rect;
    struct fimg2d_rect *dst_rect;
    struct fimg2d_rect *msk_rect;

    unsigned int seq_no;
};
#endif /* __SEC_G2D_4X_H__ */