1 /* 2 * Allwinner SoCs display driver. 3 * 4 * Copyright (C) 2016 Allwinner. 5 * 6 * This file is licensed under the terms of the GNU General Public 7 * License version 2. This program is licensed "as is" without any 8 * warranty of any kind, whether express or implied. 9 */ 10 11 #ifndef __DE_LCD_H_ 12 #define __DE_LCD_H_ 13 14 #include "../../include.h" 15 #include "../tcon_feat.h" 16 17 enum __lcd_irq_id_t { 18 LCD_IRQ_TCON0_VBLK = 15, 19 LCD_IRQ_TCON1_VBLK = 14, 20 LCD_IRQ_TCON0_LINE = 13, 21 LCD_IRQ_TCON1_LINE = 12, 22 LCD_IRQ_TCON0_TRIF = 11, 23 LCD_IRQ_TCON0_CNTR = 10, 24 LCD_IRQ_FSYNC_INT = 9, 25 LCD_IRQ_DATA_EN_INT = 8, 26 }; 27 28 enum __dsi_irq_id_t { 29 DSI_IRQ_VIDEO_LINE = 3, 30 DSI_IRQ_VIDEO_VBLK = 2, 31 DSI_IRQ_INSTR_STEP = 1, 32 DSI_IRQ_INSTR_END = 0, 33 }; 34 35 enum __edp_irq_id_t { 36 EDP_IRQ_VBLK = 0, 37 EDP_IRQ_LINE1 = 1, 38 }; 39 40 enum __lcd_src_t { 41 LCD_SRC_DE = 0, 42 LCD_SRC_COLOR_BAR = 1, 43 LCD_SRC_GRAYSCALE = 2, 44 LCD_SRC_BLACK_BY_WHITE = 3, 45 LCD_SRC_BLACK = 4, 46 LCD_SRC_WHITE = 5, 47 LCD_SRC_GRID = 7, 48 LCD_SRC_BLUE = 8 49 }; 50 51 enum __tv_set_t { 52 TV_TO_GPIO = 1, 53 LCD_TO_GPIO = 0, 54 TV_CLK_F_CCU = 0, 55 TV_CLK_F_TVE = 1 56 }; 57 58 enum __de_perh_t { 59 LCD0 = 0, 60 LCD1 = 1, 61 TV0 = 2, 62 TV1 = 3 63 }; 64 65 s32 tcon0_out_to_gpio(u32 sel); 66 s32 tcon1_out_to_gpio(u32 sel); 67 s32 tcon1_tv_clk_enable(u32 sel, u32 en); 68 s32 tcon1_hdmi_clk_enable(u32 sel, u32 en); 69 s32 tcon0_dsi_clk_enable(u32 sel, u32 en); 70 s32 tcon_de_attach(u32 tcon_index, u32 de_index); 71 s32 tcon_get_attach_by_de_index(u32 de_index); 72 s32 tcon_top_set_reg_base(u32 sel, uintptr_t base); 73 uintptr_t tcon_top_get_reg_base(u32 sel); 74 s32 lvds_open(u32 sel, struct disp_panel_para *panel); 75 s32 lvds_close(u32 sel); 76 u32 tcon_get_cur_field(u32 sel, u32 tcon_index); 77 s32 tcon_irq_enable(u32 sel, enum __lcd_irq_id_t id); 78 s32 tcon_irq_disable(u32 sel, enum __lcd_irq_id_t id); 79 s32 tcon_set_reg_base(u32 sel, uintptr_t address); 80 uintptr_t tcon_get_reg_base(u32 sel); 81 s32 tcon_init(u32 sel); 82 s32 tcon_exit(u32 sel); 83 s32 tcon_get_timing(u32 sel, u32 index, struct disp_video_timings *tt); 84 u32 tcon_irq_query(u32 sel, enum __lcd_irq_id_t id); 85 u32 tcon_get_start_delay(u32 sel, u32 tcon_index); 86 u32 tcon_get_cur_line(u32 sel, u32 tcon_index); 87 s32 tcon_gamma(u32 sel, u32 en, u32 *gamma_tbl); 88 s32 tcon_get_status(u32 sel, u32 tcon_index); 89 90 s32 tcon0_cfg(u32 sel, struct disp_panel_para *panel, u32 de_use_rcq); 91 s32 tcon0_cfg_ext(u32 sel, struct panel_extend_para *extend_panel); 92 s32 tcon0_src_select(u32 sel, enum __lcd_src_t src, u32 de_no); 93 s32 tcon0_src_get(u32 sel); 94 s32 tcon0_open(u32 sel, struct disp_panel_para *panel); 95 s32 tcon0_close(u32 sel); 96 s32 tcon0_set_dclk_div(u32 sel, u8 div); 97 u32 tcon0_get_dclk_div(u32 sel); 98 s32 tcon0_tri_busy(u32 sel); 99 s32 tcon0_cpu_set_auto_mode(u32 sel); 100 s32 tcon0_tri_start(u32 sel); 101 u32 tcon0_cpu_16b_to_24b(u32 value); 102 u32 tcon0_cpu_24b_to_16b(u32 value); 103 u32 tcon0_cpu_busy(u32 sel); 104 s32 tcon0_cpu_wr_24b(u32 sel, u32 index, u32 data); 105 s32 tcon0_cpu_wr_24b_index(u32 sel, u32 index); 106 s32 tcon0_cpu_wr_24b_data(u32 sel, u32 data); 107 s32 tcon0_cpu_rd_24b(u32 sel, u32 index, u32 *data); 108 s32 tcon0_cpu_wr_16b(u32 sel, u32 index, u32 data); 109 s32 tcon0_cpu_wr_16b_index(u32 sel, u32 index); 110 s32 tcon0_cpu_wr_16b_data(u32 sel, u32 data); 111 s32 tcon0_cpu_rd_16b(u32 sel, u32 index, u32 *data); 112 113 s32 tcon_pan_sel(u32 sel, u32 pad); 114 u32 tcon_pad_get(u32 sel); 115 116 s32 tcon1_open(u32 sel); 117 s32 tcon1_close(u32 sel); 118 s32 tcon1_src_select(u32 sel, enum __lcd_src_t src, enum __de_perh_t de_no); 119 s32 tcon1_src_get(u32 sel); 120 s32 tcon1_cfg_ex(u32 sel, struct disp_panel_para *panel); 121 s32 tcon1_set_timming(u32 sel, struct disp_video_timings *timming); 122 s32 tcon1_cfg(u32 sel, struct disp_video_timings *timing); 123 s32 tcon1_set_tv_mode(u32 sel, enum disp_output_type mode); 124 s32 hmdi_src_sel(u32 sel); 125 s32 tcon1_hdmi_color_remap(u32 sel, u32 onoff); 126 s32 tcon1_yuv_range(u32 sel, u32 onoff); 127 u32 tcon0_get_cpu_tri2_start_delay(u32 sel); 128 s32 rgb_src_sel(u32 src); 129 s32 dsi_src_sel(u32 sel, u32 src); 130 s32 tcon1_black_src(u32 sel, u32 on_off, u32 color); 131 s32 edp_de_attach(u32 edp_index, u32 de_index); 132 void tcon0_cpu_wr_16b_multi(u32 sel, u8 cmd, u8 *para, u32 para_num); 133 void tcon0_cpu_wr_24b_multi(u32 sel, u8 cmd, u8 *para, u32 para_num); 134 135 #if defined(SUPPORT_DSI) 136 extern __u32 dsi_pixel_bits[4]; 137 extern __u32 tcon_div; 138 #endif 139 extern s32 disp_delay_us(u32 us); 140 extern s32 disp_delay_ms(u32 ms); 141 extern int de_get_clk_rate(void); 142 void tcon_show_builtin_patten(u32 sel, u32 patten); 143 144 /** 145 * @name :tcon_fsync_set_pol 146 * @brief :set fsync's polarity 147 * @param[IN] :sel:tcon index 148 * @param[IN] :pol:polarity. 1:positive;0:negetive 149 * positive: 150 * +---------+ 151 * ---------+ +----------- 152 * 153 * negative: 154 * ---------+ +------------ 155 * +---------+ 156 * 157 * @return :always 0 158 */ 159 s32 tcon_set_fsync_pol(u32 sel, u32 pol); 160 161 /** 162 * @name :tcon_set_fsync_active_time 163 * @brief :set tcon fsync's active time 164 * @param[IN] :sel:tcon index 165 * @param[IN] :pixel_num:number of pixel time(Tpixel) to set 166 * 167 * Tpixel = 1/fps*1e9/vt/ht, unit:ns 168 * 169 * @return :0 if success 170 */ 171 s32 tcon_set_fsync_active_time(u32 sel, u32 pixel_num); 172 173 174 #endif 175