Commit | Line | Data |
---|---|---|
91884734 KD |
1 | /* |
2 | * Samsung S5P G2D - 2D Graphics Accelerator Driver | |
3 | * | |
4 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. | |
5 | * Kamil Debski, <k.debski@samsung.com> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2 of the | |
10 | * License, or (at your option) any later version | |
11 | */ | |
12 | ||
62ce272d | 13 | #include <linux/platform_device.h> |
91884734 KD |
14 | #include <media/v4l2-device.h> |
15 | #include <media/v4l2-ctrls.h> | |
16 | ||
17 | #define G2D_NAME "s5p-g2d" | |
62ce272d SK |
18 | #define TYPE_G2D_3X 3 |
19 | #define TYPE_G2D_4X 4 | |
91884734 KD |
20 | |
21 | struct g2d_dev { | |
22 | struct v4l2_device v4l2_dev; | |
23 | struct v4l2_m2m_dev *m2m_dev; | |
24 | struct video_device *vfd; | |
25 | struct mutex mutex; | |
27dda973 | 26 | spinlock_t ctrl_lock; |
91884734 KD |
27 | atomic_t num_inst; |
28 | struct vb2_alloc_ctx *alloc_ctx; | |
91884734 KD |
29 | void __iomem *regs; |
30 | struct clk *clk; | |
31 | struct clk *gate; | |
32 | struct g2d_ctx *curr; | |
62ce272d | 33 | struct g2d_variant *variant; |
91884734 KD |
34 | int irq; |
35 | wait_queue_head_t irq_queue; | |
36 | }; | |
37 | ||
38 | struct g2d_frame { | |
39 | /* Original dimensions */ | |
40 | u32 width; | |
41 | u32 height; | |
42 | /* Crop size */ | |
43 | u32 c_width; | |
44 | u32 c_height; | |
45 | /* Offset */ | |
46 | u32 o_width; | |
47 | u32 o_height; | |
48 | /* Image format */ | |
49 | struct g2d_fmt *fmt; | |
50 | /* Variables that can calculated once and reused */ | |
51 | u32 stride; | |
52 | u32 bottom; | |
53 | u32 right; | |
54 | u32 size; | |
55 | }; | |
56 | ||
57 | struct g2d_ctx { | |
58 | struct v4l2_fh fh; | |
59 | struct g2d_dev *dev; | |
91884734 KD |
60 | struct g2d_frame in; |
61 | struct g2d_frame out; | |
d0d28326 SK |
62 | struct v4l2_ctrl *ctrl_hflip; |
63 | struct v4l2_ctrl *ctrl_vflip; | |
91884734 KD |
64 | struct v4l2_ctrl_handler ctrl_handler; |
65 | u32 rop; | |
d0d28326 | 66 | u32 flip; |
91884734 KD |
67 | }; |
68 | ||
69 | struct g2d_fmt { | |
70 | char *name; | |
71 | u32 fourcc; | |
72 | int depth; | |
73 | u32 hw; | |
74 | }; | |
75 | ||
62ce272d SK |
76 | struct g2d_variant { |
77 | unsigned short hw_rev; | |
78 | }; | |
91884734 KD |
79 | |
80 | void g2d_reset(struct g2d_dev *d); | |
81 | void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame *f); | |
82 | void g2d_set_src_addr(struct g2d_dev *d, dma_addr_t a); | |
83 | void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame *f); | |
84 | void g2d_set_dst_addr(struct g2d_dev *d, dma_addr_t a); | |
85 | void g2d_start(struct g2d_dev *d); | |
86 | void g2d_clear_int(struct g2d_dev *d); | |
87 | void g2d_set_rop4(struct g2d_dev *d, u32 r); | |
d0d28326 | 88 | void g2d_set_flip(struct g2d_dev *d, u32 r); |
62ce272d SK |
89 | void g2d_set_v41_stretch(struct g2d_dev *d, |
90 | struct g2d_frame *src, struct g2d_frame *dst); | |
91884734 KD |
91 | void g2d_set_cmd(struct g2d_dev *d, u32 c); |
92 | ||
62ce272d SK |
93 | static inline struct g2d_variant *g2d_get_drv_data(struct platform_device *pdev) |
94 | { | |
95 | return (struct g2d_variant *)platform_get_device_id(pdev)->driver_data; | |
96 | } |