summaryrefslogtreecommitdiff
path: root/v3/fake-pipeline2/ge2d_wq.h (plain)
blob: 9bcfba33a98c176d8428f983074288edae913b11
1#ifndef BITBLT_H_
2#define BITBLT_H_
3
4#ifdef __KERNEL__
5#include <linux/mutex.h>
6#include <linux/semaphore.h>
7#include <linux/list.h>
8#include <linux/amlogic/osd/osd.h>
9#include <linux/interrupt.h>
10#include <linux/sched.h>
11#include <linux/spinlock.h>
12#include <linux/wait.h>
13#include <linux/slab.h>
14#endif
15#define GE2D_HIGHEST_PRIORITY 0
16#define GE2D_LOWEST_PRIORITY 255
17
18#define FLAG_CONFIG_UPDATE_ONLY 0
19#define FLAG_CONFIG_ALL 1
20
21#define UPDATE_SRC_DATA 0x01
22#define UPDATE_SRC_GEN 0x02
23#define UPDATE_DST_DATA 0x04
24#define UPDATE_DST_GEN 0x08
25#define UPDATE_DP_GEN 0x10
26#define UPDATE_SCALE_COEF 0x20
27#define UPDATE_ALL 0x3f
28#define GE2D_ATTR_MAX 2
29#define GE2D_MAX_WORK_QUEUE_NUM 4
30#define GE2D_IRQ_NO INT_GE2D
31#define FILE_NAME "[GE2D_WQ]"
32typedef enum
33{
34 OSD0_OSD0 =0,
35 OSD0_OSD1,
36 OSD1_OSD1,
37 OSD1_OSD0,
38 ALLOC_OSD0,
39 ALLOC_OSD1,
40 ALLOC_ALLOC,
41 TYPE_INVALID,
42}ge2d_src_dst_t;
43typedef enum
44{
45 CANVAS_OSD0 =0,
46 CANVAS_OSD1,
47 CANVAS_ALLOC,
48 CANVAS_TYPE_INVALID,
49}ge2d_src_canvas_type;
50#ifdef __KERNEL__
51typedef struct {
52 struct list_head list;
53 ge2d_cmd_t cmd ;
54 ge2d_config_t config;
55
56}ge2d_queue_item_t;
57
58typedef struct{
59 struct list_head list; //connect all process in one queue for RR process.
60 ge2d_config_t config; //current wq configuration
61 ge2d_cmd_t cmd;
62 struct list_head work_queue;
63 struct list_head free_queue;
64 wait_queue_head_t cmd_complete;
65 int queue_dirty;
66 int queue_need_recycle;
67 spinlock_t lock; // for get and release item.
68} ge2d_context_t;
69
70typedef struct {
71 wait_queue_head_t cmd_complete;
72 struct completion process_complete;
73 spinlock_t sem_lock; //for queue switch and create destroy queue.
74 struct semaphore cmd_in_sem;
75}ge2d_event_t;
76
77
78
79typedef struct {
80 struct list_head process_queue;
81 ge2d_context_t* current_wq;
82 ge2d_context_t* last_wq;
83 struct task_struct* ge2d_thread;
84 ge2d_event_t event ;
85 int irq_num;
86 int ge2d_state;
87 int process_queue_state;
88}ge2d_manager_t ;
89#endif
90typedef struct {
91 int xres;
92 int yres ;
93 int canvas_index;
94 int bpp;
95 int ge2d_color_index;
96}src_dst_para_t ;
97
98typedef enum {
99 COLOR_INDEX_02_PAL4 = 2, // 0
100 COLOR_INDEX_04_PAL16 = 4, // 0
101 COLOR_INDEX_08_PAL256=8,
102 COLOR_INDEX_16_655 =9,
103 COLOR_INDEX_16_844 =10,
104 COLOR_INDEX_16_6442 =11 ,
105 COLOR_INDEX_16_4444_R = 12,
106 COLOR_INDEX_16_4642_R = 13,
107 COLOR_INDEX_16_1555_A=14,
108 COLOR_INDEX_16_4444_A = 15,
109 COLOR_INDEX_16_565 =16,
110
111 COLOR_INDEX_24_6666_A=19,
112 COLOR_INDEX_24_6666_R=20,
113 COLOR_INDEX_24_8565 =21,
114 COLOR_INDEX_24_5658 = 22,
115 COLOR_INDEX_24_888_B = 23,
116 COLOR_INDEX_24_RGB = 24,
117
118 COLOR_INDEX_32_BGRA=29,
119 COLOR_INDEX_32_ABGR = 30,
120 COLOR_INDEX_32_RGBA=31,
121 COLOR_INDEX_32_ARGB=32,
122
123 COLOR_INDEX_YUV_422=33,
124
125}color_index_t;
126
127static const int bpp_type_lut[]={
128 //16bit
129 COLOR_INDEX_16_655, // 0
130 COLOR_INDEX_16_844, // 1
131 COLOR_INDEX_16_6442, // 2
132 COLOR_INDEX_16_4444_R, // 3
133 COLOR_INDEX_16_565, // 4
134 COLOR_INDEX_16_4444_A, // 5
135 COLOR_INDEX_16_1555_A, // 6
136 COLOR_INDEX_16_4642_R, // 7
137 //24bit
138 COLOR_INDEX_24_RGB, // 0
139 COLOR_INDEX_24_5658, // 1
140 COLOR_INDEX_24_8565, // 2
141 COLOR_INDEX_24_6666_R, // 3
142 COLOR_INDEX_24_6666_A, // 4
143 COLOR_INDEX_24_888_B, // 5
144 0,
145 0,
146 //32bit
147 COLOR_INDEX_32_RGBA, // 0
148 COLOR_INDEX_32_ARGB, // 1
149 COLOR_INDEX_32_ABGR, // 2
150 COLOR_INDEX_32_BGRA, // 3
151 0,0,0,0
152};
153
154static const int default_ge2d_color_lut[]={
155 0,
156 0,
157 0,//BPP_TYPE_02_PAL4 = 2,
158 0,
159 0,//BPP_TYPE_04_PAL16 = 4,
160 0,
161 0,
162 0,
163 0,//BPP_TYPE_08_PAL256=8,
164 GE2D_FORMAT_S16_RGB_655,//BPP_TYPE_16_655 =9,
165 GE2D_FORMAT_S16_RGB_844,//BPP_TYPE_16_844 =10,
166 GE2D_FORMAT_S16_RGBA_6442,//BPP_TYPE_16_6442 =11 ,
167 GE2D_FORMAT_S16_RGBA_4444,//BPP_TYPE_16_4444_R = 12,
168 GE2D_FORMAT_S16_RGBA_4642,//BPP_TYPE_16_4642_R = 13,
169 GE2D_FORMAT_S16_ARGB_1555,//BPP_TYPE_16_1555_A=14,
170 GE2D_FORMAT_S16_ARGB_4444,//BPP_TYPE_16_4444_A = 15,
171 GE2D_FORMAT_S16_RGB_565,//BPP_TYPE_16_565 =16,
172 0,
173 0,
174 GE2D_FORMAT_S24_ARGB_6666,//BPP_TYPE_24_6666_A=19,
175 GE2D_FORMAT_S24_RGBA_6666,//BPP_TYPE_24_6666_R=20,
176 GE2D_FORMAT_S24_ARGB_8565,//BPP_TYPE_24_8565 =21,
177 GE2D_FORMAT_S24_RGBA_5658,//BPP_TYPE_24_5658 = 22,
178 GE2D_FORMAT_S24_BGR,//BPP_TYPE_24_888_B = 23,
179 GE2D_FORMAT_S24_RGB,//BPP_TYPE_24_RGB = 24,
180 0,
181 0,
182 0,
183 0,
184 GE2D_FORMAT_S32_BGRA,//BPP_TYPE_32_BGRA=29,
185 GE2D_FORMAT_S32_ABGR,//BPP_TYPE_32_ABGR = 30,
186 GE2D_FORMAT_S32_RGBA,//BPP_TYPE_32_RGBA=31,
187 GE2D_FORMAT_S32_ARGB,//BPP_TYPE_32_ARGB=32,
188};
189typedef enum{
190 GE2D_OP_DEFAULT=0,
191 GE2D_OP_FILLRECT,
192 GE2D_OP_BLIT,
193 GE2D_OP_STRETCHBLIT,
194 GE2D_OP_BLEND,
195 GE2D_OP_MAXNUM
196}ge2d_op_type_t;
197
198//the same as config_planes_t's member addr
199typedef unsigned long ge2d_phys_addr_t;
200
201typedef struct {
202 unsigned long addr;
203 unsigned int w;
204 unsigned int h;
205}config_planes_t;
206
207typedef struct{
208 int key_enable;
209 int key_color;
210 int key_mask;
211 int key_mode;
212}src_key_ctrl_t;
213typedef struct {
214 int src_dst_type;
215 int alu_const_color;
216 unsigned int src_format;
217 unsigned int dst_format ; //add for src&dst all in user space.
218
219 config_planes_t src_planes[4];
220 config_planes_t dst_planes[4];
221 src_key_ctrl_t src_key;
222}config_para_t;
223
224typedef struct {
225 int canvas_index;
226 int top;
227 int left;
228 int width;
229 int height;
230 int format;
231 int mem_type;
232 int color;
233 unsigned char x_rev;
234 unsigned char y_rev;
235 unsigned char fill_color_en;
236 unsigned char fill_mode;
237}src_dst_para_ex_t ;
238
239
240typedef enum ge2d_addr_type_e {
241 GE2D_ADDR_TYPE_NONE,
242 GE2D_ADDR_TYPE_PHY_ADDR,
243 GE2D_ADDR_TYPE_SHARE_FD,
244}ge2d_addr_type_t;
245
246typedef struct {
247 src_dst_para_ex_t src_para;
248 src_dst_para_ex_t src2_para;
249 src_dst_para_ex_t dst_para;
250
251//key mask
252 src_key_ctrl_t src_key;
253 src_key_ctrl_t src2_key;
254
255 int alu_const_color;
256 unsigned src1_gb_alpha;
257 unsigned op_mode;
258 unsigned char bitmask_en;
259 unsigned char bytemask_only;
260 unsigned int bitmask;
261 unsigned char dst_xy_swap;
262
263// scaler and phase releated
264 unsigned hf_init_phase;
265 int hf_rpt_num;
266 unsigned hsc_start_phase_step;
267 int hsc_phase_slope;
268 unsigned vf_init_phase;
269 int vf_rpt_num;
270 unsigned vsc_start_phase_step;
271 int vsc_phase_slope;
272 unsigned char src1_vsc_phase0_always_en;
273 unsigned char src1_hsc_phase0_always_en;
274 unsigned char src1_hsc_rpt_ctrl; //1bit, 0: using minus, 1: using repeat data
275 unsigned char src1_vsc_rpt_ctrl; //1bit, 0: using minus 1: using repeat data
276
277//canvas info
278 config_planes_t src_planes[4];
279 config_planes_t src2_planes[4];
280 config_planes_t dst_planes[4];
281
282 enum ge2d_addr_type_e src_addr_type;
283 enum ge2d_addr_type_e dst_addr_type;
284}config_para_ex_t;
285#ifdef __KERNEL__
286extern int ge2d_setup(void);
287extern int ge2d_deinit(void);
288extern int ge2d_context_config(ge2d_context_t *context, config_para_t *ge2d_config);
289extern int ge2d_context_config_ex(ge2d_context_t *context, config_para_ex_t *ge2d_config);
290
291extern int ge2d_wq_init(void);
292extern int destroy_ge2d_work_queue(ge2d_context_t* ) ;
293extern ge2d_context_t* create_ge2d_work_queue(void) ;
294
295extern int ge2d_wq_remove_config(ge2d_context_t *wq);
296
297extern void ge2d_wq_set_scale_coef(ge2d_context_t *wq, unsigned v_scale_coef, unsigned h_scale_coef);
298extern int ge2d_antiflicker_enable(ge2d_context_t *context,unsigned long enable);
299extern ge2d_src1_data_t * ge2d_wq_get_src_data(ge2d_context_t *wq);
300extern ge2d_src1_gen_t * ge2d_wq_get_src_gen(ge2d_context_t *wq);
301extern ge2d_src2_dst_data_t * ge2d_wq_get_dst_data(ge2d_context_t *wq);
302extern ge2d_src2_dst_gen_t * ge2d_wq_get_dst_gen(ge2d_context_t *wq);
303extern ge2d_dp_gen_t * ge2d_wq_get_dp_gen(ge2d_context_t *wq);
304extern ge2d_cmd_t * ge2d_wq_get_cmd(ge2d_context_t *wq);
305
306extern int ge2d_wq_add_work(ge2d_context_t *wq);
307#endif
308
309
310#endif // BITBLT_H
311