2 * Copyright 2011, Samsung Electronics Co. LTD
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef _SEC_G2D_DRIVER_H_
18 #define _SEC_G2D_DRIVER_H_
20 #define SEC_G2D_DEV_NAME "/dev/fimg2d"
21 #define G2D_ALPHA_VALUE_MAX (255)
24 #define FIMG2D_IOCTL_MAGIC 'F'
25 #define FIMG2D_BITBLT_BLIT _IOWR(FIMG2D_IOCTL_MAGIC, 0, struct fimg2d_blit)
26 #define FIMG2D_BITBLT_SYNC _IOW(FIMG2D_IOCTL_MAGIC, 1, int)
27 #define FIMG2D_BITBLT_VERSION _IOR(FIMG2D_IOCTL_MAGIC, 2, struct fimg2d_version)
28 #define FIMG2D_BITBLT_ACTIVATE _IOW(FIMG2D_IOCTL_MAGIC, 3, enum driver_act)
35 struct fimg2d_version
{
40 enum fimg2d_qos_level
{
50 * @BLIT_SYNC: sync mode, to wait for blit done irq
51 * @BLIT_ASYNC: async mode, not to wait for blit done irq
60 * @ADDR_PHYS: physical address
61 * @ADDR_USER: user virtual address (physically Non-contiguous)
62 * @ADDR_USER_RSVD: user virtual address (physically Contiguous)
63 * @ADDR_DEVICE: specific device virtual address
75 * Pixel order complies with little-endian style
77 * DO NOT CHANGE THIS ORDER
98 * DO NOT CHANGE THIS ORDER
128 ROT_90
, /* clockwise */
131 XFLIP
, /* x-axis flip */
132 YFLIP
, /* y-axis flip */
136 * @NO_REPEAT: no effect
137 * @REPEAT_NORMAL: repeat horizontally and vertically
138 * @REPEAT_PAD: pad with pad color
139 * @REPEAT_REFLECT: reflect horizontally and vertically
140 * @REPEAT_CLAMP: pad with edge color of original image
142 * DO NOT CHANGE THIS ORDER
146 REPEAT_NORMAL
, /* default setting */
148 REPEAT_REFLECT
, REPEAT_MIRROR
= REPEAT_REFLECT
,
159 * @SCALING_PIXELS: ratio in pixels
160 * @SCALING_RATIO: ratio in fixed point 16
162 enum scaling_factor
{
168 * premultiplied alpha
176 * @TRANSP: discard bluescreen color
177 * @BLUSCR: replace bluescreen color with background color
186 * DO NOT CHANGE THIS ORDER
189 BLIT_OP_SOLID_FILL
= 0,
192 BLIT_OP_SRC
, BLIT_OP_SRC_COPY
= BLIT_OP_SRC
,
195 BLIT_OP_DST_OVER
, BLIT_OP_OVER_REV
= BLIT_OP_DST_OVER
,
197 BLIT_OP_DST_IN
, BLIT_OP_IN_REV
= BLIT_OP_DST_IN
,
199 BLIT_OP_DST_OUT
, BLIT_OP_OUT_REV
= BLIT_OP_DST_OUT
,
201 BLIT_OP_DST_ATOP
, BLIT_OP_ATOP_REV
= BLIT_OP_DST_ATOP
,
210 BLIT_OP_DISJ_SRC_OVER
,
211 BLIT_OP_DISJ_DST_OVER
, BLIT_OP_SATURATE
= BLIT_OP_DISJ_DST_OVER
,
213 BLIT_OP_DISJ_DST_IN
, BLIT_OP_DISJ_IN_REV
= BLIT_OP_DISJ_DST_IN
,
214 BLIT_OP_DISJ_SRC_OUT
,
215 BLIT_OP_DISJ_DST_OUT
, BLIT_OP_DISJ_OUT_REV
= BLIT_OP_DISJ_DST_OUT
,
216 BLIT_OP_DISJ_SRC_ATOP
,
217 BLIT_OP_DISJ_DST_ATOP
, BLIT_OP_DISJ_ATOP_REV
= BLIT_OP_DISJ_DST_ATOP
,
220 BLIT_OP_CONJ_SRC_OVER
,
221 BLIT_OP_CONJ_DST_OVER
, BLIT_OP_CONJ_OVER_REV
= BLIT_OP_CONJ_DST_OVER
,
223 BLIT_OP_CONJ_DST_IN
, BLIT_OP_CONJ_IN_REV
= BLIT_OP_CONJ_DST_IN
,
224 BLIT_OP_CONJ_SRC_OUT
,
225 BLIT_OP_CONJ_DST_OUT
, BLIT_OP_CONJ_OUT_REV
= BLIT_OP_CONJ_DST_OUT
,
226 BLIT_OP_CONJ_SRC_ATOP
,
227 BLIT_OP_CONJ_DST_ATOP
, BLIT_OP_CONJ_ATOP_REV
= BLIT_OP_CONJ_DST_ATOP
,
230 /* user select coefficient manually */
235 /* Add new operation type here */
237 /* end of blit operation */
240 /* driver not supporting format */
241 BLIT_OP_NOT_SUPPORTED
245 * @start: start address or unique id of image
248 enum addr_space type
;
255 int x2
; /* x1 + width */
256 int y2
; /* y1 + height */
260 * pixels can be different from src, dst or clip rect
262 struct fimg2d_scale
{
265 /* ratio in pixels */
274 int x2
; /* x1 + width */
275 int y2
; /* y1 + height */
278 struct fimg2d_repeat
{
280 unsigned long pad_color
;
284 * @bg_color: bg_color is valid only if bluescreen mode is BLUSCR.
286 struct fimg2d_bluscr
{
287 enum bluescreen mode
;
288 unsigned long bs_color
;
289 unsigned long bg_color
;
293 * @plane2: address info for CbCr in YCbCr 2plane mode
294 * @rect: crop/clip rect
295 * @need_cacheopr: true if cache coherency is required
297 struct fimg2d_image
{
301 enum pixel_order order
;
302 enum color_format fmt
;
303 struct fimg2d_addr addr
;
304 struct fimg2d_addr plane2
;
305 struct fimg2d_rect rect
;
311 * src color instead of src image / dst color instead of dst read image.
312 * color format and order must be ARGB8888(A is MSB).
313 * premultiplied format must be same to 'premult' of this struct.
314 * @g_alpha: global(constant) alpha. 0xff is opaque, 0 is transparnet
316 * @rotate: rotation degree in clockwise
317 * @premult: alpha premultiplied mode for read & write
318 * @scaling: common scaling info for src and mask image.
319 * @repeat: repeat type (tile mode)
320 * @bluscr: blue screen and transparent mode
322 struct fimg2d_param
{
323 unsigned long solid_color
;
324 unsigned char g_alpha
;
326 enum rotation rotate
;
327 enum premultiplied premult
;
328 struct fimg2d_scale scaling
;
329 struct fimg2d_repeat repeat
;
330 struct fimg2d_bluscr bluscr
;
331 struct fimg2d_clip clipping
;
335 * @op: blit operation mode
336 * @src: set when using src image
337 * @msk: set when using mask image
338 * @tmp: set when using 2-step blit at a single command
339 * @dst: dst must not be null
340 * * tmp image must be the same to dst except memory address
341 * @seq_no: user debugging info.
342 * for example, user can set sequence number or pid.
346 struct fimg2d_param param
;
347 struct fimg2d_image
*src
;
348 struct fimg2d_image
*msk
;
349 struct fimg2d_image
*tmp
;
350 struct fimg2d_image
*dst
;
353 enum fimg2d_qos_level qos_lv
;
356 struct fimg2d_blit_raw
{
358 struct fimg2d_param param
;
359 struct fimg2d_image src
;
360 struct fimg2d_image msk
;
361 struct fimg2d_image tmp
;
362 struct fimg2d_image dst
;
365 enum fimg2d_qos_level qos_lv
;
371 * @pgd: base address of arm mmu pagetable
372 * @ncmd: request count in blit command queue
373 * @wait_q: conext wait queue head
375 struct fimg2d_context
{
376 struct mm_struct
*mm
;
378 wait_queue_head_t wait_q
;
382 * @seq_no: used for debugging
383 * @node: list head of blit command queue
385 struct fimg2d_bltcmd
{
388 enum premultiplied premult
;
389 unsigned char g_alpha
;
391 enum rotation rotate
;
392 struct fimg2d_scale scaling
;
393 struct fimg2d_repeat repeat
;
394 struct fimg2d_bluscr bluscr
;
395 struct fimg2d_clip clipping
;
401 unsigned long solid_color
;
402 struct fimg2d_image src
;
403 struct fimg2d_image dst
;
404 struct fimg2d_image msk
;
406 struct fimg2d_rect src_rect
;
407 struct fimg2d_rect dst_rect
;
408 struct fimg2d_rect msk_rect
;
411 struct fimg2d_cache src_cache
;
412 struct fimg2d_cache dst_cache
;
413 struct fimg2d_cache msk_cache
;
416 struct fimg2d_context
*ctx
;
417 struct list_head node
;
421 * @pwron: power status for runtime pm
422 * @pwrlock: spinlock for runtime pm
423 * @mem: resource platform device
424 * @regs: base address of hardware
425 * @dev: pointer to device struct
426 * @err: true if hardware is timed out while blitting
428 * @nctx: context count
429 * @busy: 1 if hardware is running
430 * @bltlock: spinlock for blit
431 * @wait_q: blit wait queue head
432 * @cmd_q: blit command queue
433 * @workqueue: workqueue_struct for kfimg2dd
435 struct fimg2d_control
{
440 struct resource
*mem
;
449 wait_queue_head_t wait_q
;
450 struct list_head cmd_q
;
451 struct workqueue_struct
*work_q
;
453 void (*blit
)(struct fimg2d_control
*info
);
454 void (*configure
)(struct fimg2d_control
*info
, struct fimg2d_bltcmd
*cmd
);
455 void (*run
)(struct fimg2d_control
*info
);
456 void (*stop
)(struct fimg2d_control
*info
);
457 void (*finalize
)(struct fimg2d_control
*info
);
460 inline void fimg2d_enqueue(struct fimg2d_control
*info
,
461 struct list_head
*node
, struct list_head
*q
);
462 inline void fimg2d_dequeue(struct fimg2d_control
*info
, struct list_head
*node
);
463 inline int fimg2d_queue_is_empty(struct list_head
*q
);
464 inline struct fimg2d_bltcmd
* fimg2d_get_first_command(struct fimg2d_control
*info
);
465 int fimg2d_add_command(struct fimg2d_control
*info
, struct fimg2d_context
*ctx
,
466 struct fimg2d_blit __user
*u
);
467 inline void fimg2d_add_context(struct fimg2d_control
*info
, struct fimg2d_context
*ctx
);
468 inline void fimg2d_del_context(struct fimg2d_control
*info
, struct fimg2d_context
*ctx
);
469 int fimg2d_register_ops(struct fimg2d_control
*info
);
470 #if defined(CONFIG_OUTER_CACHE) && defined(CONFIG_ARM)
471 void fimg2d_clean_pagetable(struct mm_struct
*mm
, unsigned long addr
,
474 #define fimg2d_clean_pagetable(mm, addr, size) do { } while (0)
477 #endif /* __KERNEL__ */
479 #endif /*_SEC_G2D_DRIVER_H_*/