]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/ipu/arm/imx/v1_0/include/ipu_common.h
TX53 Release 2011-06-16
[karo-tx-redboot.git] / packages / devs / ipu / arm / imx / v1_0 / include / ipu_common.h
1 //==========================================================================
2 //
3 //      IPU_COMMON.h
4 //
5 //      common functions declaration and macro definitions for IPUv3d
6 //
7 //==========================================================================
8 //#####DESCRIPTIONBEGIN####
9 //
10 // Author(s):       Ray Sun <Yanfei.Sun@freescale.com>
11 // Create Date: 2008-07-31
12 //
13 //####DESCRIPTIONEND####
14 //
15 //==========================================================================
16
17 #ifndef IPU_COMMON_H_
18 #define IPU_COMMON_H_
19
20 // System-wide configuration info
21 #include <pkgconf/system.h>
22 #include <cyg/infra/cyg_type.h>
23 #include <cyg/infra/diag.h>
24 #ifdef CYGBLD_HAL_PLF_DEFS_H
25 #include CYGBLD_HAL_PLF_DEFS_H
26 #else
27 #include <cyg/hal/fsl_board.h>
28 #endif
29
30 #ifdef IMX_IPU_VER_3_EX
31 #include "ipuv3ex_reg_def.h"
32 #endif
33
34 #ifdef IMX_IPU_VER_3_D
35 #include "ipuv3d_reg_def.h"
36 #endif
37
38 #define IPU_DEBUG
39 #undef IPU_DEBUG
40 #ifdef IPU_DEBUG
41 #define DP(fmt,args...) diag_printf(fmt, ## args)
42 #else
43 #define DP(fmt,args...)
44 #endif
45 #define ERRDP(fmt, arg...) diag_printf("[ERR] " fmt, ## arg)
46 #define WARNDP(fmt, arg...) diag_printf("[WARN] " fmt, ## arg)
47 #define INFODP(fmt, arg...) diag_printf("[INFO] " fmt, ## arg)
48
49
50 #define TIMEOUT_VALUE 0x1000
51
52 #define T_VALUE 2
53
54 /* Epson LCD command definitions */
55 #define DISON 0x29
56 #define DISOFF 0x28
57 #define GAMSET 0x26
58 #define SLPIN 0x10
59 #define SLPOUT 0x11
60 #define PASET 0x2b
61 #define CASET 0x2a
62 #define MADCTL 0x36
63 #define COLMOD 0x3a
64 #define RAMWR 0x2c
65 #define PTLON 0x12
66 #define PTLAR 0x30
67 #define NORON 0x13
68
69 /* DI counter definitions */
70 #define DI_COUNTER_BASECLK              0
71 #define DI_COUNTER_IHSYNC               1
72 #define DI_COUNTER_OHSYNC               2
73 #define DI_COUNTER_OVSYNC               3
74 #define DI_COUNTER_ALINE                4
75 #define DI_COUNTER_ACLOCK               5
76
77 /* IDMAC defines */
78 #define INTERLEAVED_MODE 0
79 #define NON_INTERLEAVED_MODE 1
80
81 #define SHIFT_DISABLE 0
82 #define SHIFT_ENABLE  1
83
84 #define GET_LSB(bit, val)  (((unsigned int)(val)) & ((0x1<<(bit)) - 1))
85
86 #include CYGHWR_MEMORY_LAYOUT_H
87
88 /* Display buffer starts at the end of DDR */
89 #define DISPLAY_BUFFER_ADDR (void *)(SDRAM_BASE_ADDR + CYGMEM_REGION_ram_SIZE - 0x400000)
90
91 typedef struct {
92         unsigned int lowmask;           // low mask inorder to find the correct masking in case of splitted data
93         unsigned int ID_mask;           // ID mask of the current field
94         unsigned int ID_addrs;          // ID address of the current channel
95         unsigned int data_high_sh;      // High data shift if needed
96 } idmac_bpp_STC;
97
98 typedef struct display_buffer_info {
99         CYG_ADDRESS startAddr;
100         unsigned int width;
101         unsigned int height;
102         int dataFormat;
103         int bpp;
104         int channel;
105 } display_buffer_info_t;
106
107 typedef struct {
108         unsigned int channel;
109         unsigned int xv;
110         unsigned int yv;
111         unsigned int xb;
112         unsigned int yb;
113         unsigned int nsb_b;
114         unsigned int cf;
115         unsigned int sx;
116         unsigned int sy;
117         unsigned int ns;
118         unsigned int sdx;
119         unsigned int sm;
120         unsigned int scc;
121         unsigned int sce;
122         unsigned int sdy;
123         unsigned int sdrx;
124         unsigned int sdry;
125         unsigned int bpp;
126         unsigned int dec_sel;
127         unsigned int dim;
128         unsigned int so;
129         unsigned int bndm;
130         unsigned int bm;
131         unsigned int rot;
132         unsigned int hf;
133         unsigned int vf;
134         unsigned int the;
135         unsigned int cap;
136         unsigned int cae;
137         unsigned int fw;
138         unsigned int fh;
139         unsigned int eba0;
140         unsigned int eba1;
141         unsigned int ilo;
142         unsigned int npb;
143         unsigned int pfs;
144         unsigned int alu;
145         unsigned int albm;
146         unsigned int id;
147         unsigned int th;
148         unsigned int sl;
149         unsigned int wid0;
150         unsigned int wid1;
151         unsigned int wid2;
152         unsigned int wid3;
153         unsigned int ofs0;
154         unsigned int ofs1;
155         unsigned int ofs2;
156         unsigned int ofs3;
157         unsigned int cre;
158         unsigned int ubo;
159         unsigned int vbo;
160         unsigned int sly;
161         unsigned int sluv;
162 } ipu_channel_parameter_t;
163
164 typedef struct ipu_res_info {
165         int taskType;
166         unsigned int inAddr0;
167         unsigned int inAddr1;
168         unsigned int outAddr0;
169         unsigned int outAddr1;
170         int inWidth;
171         int inHeight;
172         int outWidth;
173         int outHeight;
174         int xSplitParts;
175         int ySplitParts;
176         int stridelineIn;
177         int stridelineOut;
178         int uOffsetIn;
179         int uOffsetOut;
180         int inDataFormat;
181         int outDataFormat;
182 } ipu_res_info_t;
183
184 typedef struct ipu_rot_info {
185         int taskType;
186         unsigned int inAddr0;
187         unsigned int inAddr1;
188         unsigned int outAddr0;
189         unsigned int outAddr1;
190         int inWidth;
191         int inHeight;
192         int outWidth;
193         int outHeight;
194         int stridelineIn;
195         int stridelineOut;
196         int uOffsetIn;
197         int uOffsetOut;
198         int inDataFormat;
199         int outDataFormat;
200         int HorizFlip;
201         int VertFlip;
202         int rotation;
203 } ipu_rot_info_t;
204
205 typedef struct display_device {
206         unsigned int type;
207         int width;
208         int height;
209 } display_device_t;
210
211 enum icTaskType {
212         PrP_ENC_TASK = 0,
213         PrP_VF_TASK,
214         PP_TASK,
215         IC_CMB,
216         IC_CSC1,
217         IC_CSC2,
218         IC_PP,
219         IC_PRPENC,
220         IC_PRPVF,
221 };
222
223 enum colorSpace {
224         RGB = 0,
225         YCbCr,
226         RGB565,
227         RGB666,
228         RGB888,
229         RGBA8888,
230         YUV888,
231         YUVA8888,
232         GRAY,
233 };
234
235 enum dest {
236         DMA_CH0 = 0,
237         DMA_CH22,
238         DMA_CH23,
239         DMA_CH28,
240 };
241
242 enum tv_display_mode {
243         TVNTSC = 0,
244         TVPALM,
245         TVPALN,
246         TVPAL,
247         TV720P60,
248         TV720P50,
249         TV720P30,
250         TV720P25,
251         TV720P24,
252         TV1080I60,
253         TV1080I50,
254         TV1035I60,
255         TV1080P30,
256         TV1080P25,
257         TV1080P24,
258         TVNONE
259 };
260
261 typedef struct alpha_chan_params {
262         unsigned int alphaChanBaseAddr;
263         int alphaWidth;
264         int alphaHeight;
265         int alphaStrideline;
266 } alpha_chan_params_t;
267
268 typedef struct ic_comb_params {
269         int taskType;
270         unsigned int baseAddr;
271         int width;
272         int height;
273         int alpha;
274         int inDataformat;
275         alpha_chan_params_t alphaChan;
276 } ic_comb_params_t;
277
278 typedef struct ic_csc_params {
279         int taskType;
280         int inFormat;
281         int outFormat;
282 } ic_csc_params_t;
283
284 typedef struct ipu_task_params {
285         int taskType;
286         int resEnable;
287         int rotEnable;
288         ipu_res_info_t resInfo;
289         ipu_rot_info_t rotInfo;
290 } ipu_task_params_t;
291
292 typedef struct dp_csc_param {
293         int mode;
294         int **coeff;
295 } dp_csc_param_t;
296
297 typedef struct dp_fg_param {
298         int fgEnable;
299         int opaque;
300         int offsetVert;
301         int offsetHoriz;
302         int cursorEnable;
303         int colorKeyEnable;
304         int graphicSelect;
305         int alphaMode;
306 } dp_fg_param_t;
307
308 typedef struct cam_caputure_params {
309         int camMode;
310         int camRate;
311         int camInWidth;
312         int camInHeight;
313         int camOutWidth;
314         int camOutHeight;
315 } cam_capture_params_t;
316
317 typedef struct dc_microcode {
318         int addr;
319         int stop;
320         char *opcode;
321         int lf;
322         int af;
323         int operand;
324         int mapping;
325         int waveform;
326         int gluelogic;
327         int sync;
328 } dc_microcode_t;
329
330 typedef struct di_sync_wave_gen {
331         int runValue;
332         int runResolution;
333         int offsetValue;
334         int offsetResolution;
335         int cntAutoReload;
336         int stepRepeat;
337         int cntClrSel;
338         int cntPolarityGenEn;
339         int cntPolarityTrigSel;
340         int cntPolarityClrSel;
341         int cntUp;
342         int cntDown;
343 } di_sync_wave_gen_t;
344
345 //common API functions for IPU
346 void ipu_write_field(unsigned int id_addr, unsigned int id_mask, unsigned int data);
347 void ipu_enable_display(void);
348 void ipu_disable_display(void);
349 void ipu_csi_config(int width, int height);
350
351 //dma API functions for IPU
352 void ipu_idmac_params_init(ipu_channel_parameter_t * ipu_channel_params_ptr);
353 void ipu_idmac_cpmem_param_update(int ch_number, int int_mode, char field_name[10], int data);
354 void ipu_idmac_interleaved_channel_config(ipu_channel_parameter_t ipu_channel_params);
355 void ipu_idmac_non_interleaved_channel_config(ipu_channel_parameter_t ipu_channel_params);
356 void ipu_idmac_cpmem_param_set(int ch_number, unsigned int id_addr,
357                                                         unsigned int id_mask, int sh_en, idmac_bpp_STC * idmac_bpp);
358 void ipu_idmac_channel_buf_ready(int channel, int buf);
359 void ipu_idmac_channel_buf_not_ready(int channel, int buf);
360 void ipu_idmac_channel_mode_sel(int channel, int double_buf_en);
361 void ipu_idmac_channel_enable(int channel, int enable);
362 int ipu_idmac_channel_busy(int channel);
363 int ipu_idmac_chan_cur_buff(int channel);
364 int ipu_idamc_chan_eof_int(int channel);
365 int ipu_idmac_chan_till_idle(int channel, int timeout);
366 int ipu_dmfc_fifo_allocate(int channel, int fifo_size, int burst_size, int offset_addr);
367 int ipu_smfc_fifo_allocate(int channel, int map, int burst_size);
368
369 /* processing API functions for IPU */
370 void ipu_ic_enable(int ic_enable, int irt_enable);
371 void ipu_ic_task_config(ipu_task_params_t task_params);
372 void ipu_ic_calc_resize_coeffs(unsigned int in_size, unsigned int out_size,
373                                                         unsigned int *resize_coeff, unsigned int *downsize_coeff);
374 int ipu_ic_config_resize_rate(char *task_type, unsigned int res_vert,
375                                                         unsigned int down_vert, unsigned int res_horiz,
376                                                         unsigned int down_horiz);
377 void ipu_ic_calc_vout_size(ipu_res_info_t * info, display_device_t disp_dev, int rotation,
378                                                 int full_screen_enable);
379 int ipu_ic_combine_config(ic_comb_params_t comb_params);
380 int ipu_ic_csc_config(int csc_index, ic_csc_params_t csc_params);
381 int ipu_ic_task_enable(int task_type, int task, int enable);
382 void ipu_dp_csc_config(int dp, dp_csc_param_t dp_csc_params, bool srm_mode_update);
383 void ipu_dp_fg_config(dp_fg_param_t foreground_params);
384 void ipu_dp_fg_config(dp_fg_param_t foreground_params);
385 void ipu_dc_microcode_config(dc_microcode_t microcode);
386 void ipu_dc_microcode_event(int channel, char event[8], int priority, int address);
387 int ipu_dc_map(int map, int format);
388 int ipu_dc_display_config(int disp_port, int type, int increment, int strideline);
389 int ipu_dc_write_channel_config(int dma_channel, int disp_port, int link_di_index,
390                                                                 int field_mode_enable);
391
392 /* display API functions for IPU */
393 void ipu_di_sync_config(int di, int pointer, di_sync_wave_gen_t sync_wave_gen);
394 void ipu_di_pointer_config(int di, int pointer, int access, int component, int cst,
395                                                 int pt0, int pt1, int pt2, int pt3, int pt4, int pt5, int pt6);
396 void ipu_di_waveform_config(int di, int pointer, int set, int up, int down);
397 int ipu_di_bsclk_gen(int di, int division, int up, int down);
398 int ipu_di_screen_set(int di, int screen_height);
399 int ipu_di_general_set(int di, int line_prediction, int vsync_sel, int hsync_sel, int clk_sel);
400
401 void fastlogo_init(display_buffer_info_t *di);
402 void fastlogo_dma(void);
403 void fastlogo_dmfc(void);
404 void fastlogo_dc(void);
405 void fastlogo_di(void);
406
407 #endif