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