1 //==========================================================================
5 // common functions declaration and macro definitions for IPUv3d
7 //==========================================================================
8 //#####DESCRIPTIONBEGIN####
10 // Author(s): Ray Sun <Yanfei.Sun@freescale.com>
11 // Create Date: 2008-07-31
13 //####DESCRIPTIONEND####
15 //==========================================================================
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
26 #include <cyg/hal/fsl_board.h>
29 #ifdef IMX_IPU_VER_3_EX
30 #include "ipuv3ex_reg_def.h"
33 #ifdef IMX_IPU_VER_3_D
34 #include "ipuv3d_reg_def.h"
40 #define DP(fmt,args...) diag_printf(fmt, ## args)
42 #define DP(fmt,args...)
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)
49 #define TIMEOUT_VALUE 0x1000
53 /* Epson LCD command definitions */
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
77 #define INTERLEAVED_MODE 0
78 #define NON_INTERLEAVED_MODE 1
80 #define SHIFT_DISABLE 0
81 #define SHIFT_ENABLE 1
83 #define GET_LSB(bit, val) (((unsigned int)(val)) & ((0x1<<(bit)) - 1))
85 #include CYGHWR_MEMORY_LAYOUT_H
87 /* Display buffer starts at the end of DDR */
88 #define DISPLAY_BUFFER_ADDR (void *)(SDRAM_BASE_ADDR + CYGMEM_REGION_ram_SIZE - 0x400000)
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
97 typedef struct display_buffer_info {
98 CYG_ADDRESS startAddr;
104 } display_buffer_info_t;
107 unsigned int channel;
125 unsigned int dec_sel;
161 } ipu_channel_parameter_t;
163 typedef struct ipu_res_info {
165 unsigned int inAddr0;
166 unsigned int inAddr1;
167 unsigned int outAddr0;
168 unsigned int outAddr1;
183 typedef struct ipu_rot_info {
185 unsigned int inAddr0;
186 unsigned int inAddr1;
187 unsigned int outAddr0;
188 unsigned int outAddr1;
204 typedef struct display_device {
241 enum tv_display_mode {
260 typedef struct alpha_chan_params {
261 unsigned int alphaChanBaseAddr;
265 } alpha_chan_params_t;
267 typedef struct ic_comb_params {
269 unsigned int baseAddr;
274 alpha_chan_params_t alphaChan;
277 typedef struct ic_csc_params {
283 typedef struct ipu_task_params {
287 ipu_res_info_t resInfo;
288 ipu_rot_info_t rotInfo;
291 typedef struct dp_csc_param {
296 typedef struct dp_fg_param {
307 typedef struct cam_caputure_params {
314 } cam_capture_params_t;
316 typedef struct dc_microcode {
329 typedef struct di_sync_wave_gen {
333 int offsetResolution;
337 int cntPolarityGenEn;
338 int cntPolarityTrigSel;
339 int cntPolarityClrSel;
342 } di_sync_wave_gen_t;
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);
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);
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);
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);
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);