3ecaa16d149617c0fe6eafade360caa91f43668d
[firefly-linux-kernel-4.4.55.git] / include / linux / rk_screen.h
1 #ifndef _SCREEN_H
2 #define _SCREEN_H
3
4 #define LVDS_8BIT_1     0
5 #define LVDS_8BIT_2     1
6 #define LVDS_8BIT_3     2
7 #define LVDS_6BIT       3
8 /*              lvds connect config       
9  *                                        
10  *              LVDS_8BIT_1    LVDS_8BIT_2     LVDS_8BIT_3     LVDS_6BIT
11 ----------------------------------------------------------------------
12         TX0     R0              R2              R2              R0
13         TX1     R1              R3              R3              R1
14         TX2     R2              R4              R4              R2
15 Y       TX3     R3              R5              R5              R3
16 0       TX4     R4              R6              R6              R4
17         TX6     R5              R7              R7              R5      
18         TX7     G0              G2              G2              G0
19 ----------------------------------------------------------------------
20         TX8     G1              G3              G3              G1
21         TX9     G2              G4              G4              G2
22 Y       TX12    G3              G5              G5              G3
23 1       TX13    G4              G6              G6              G4
24         TX14    G5              G7              G7              G5
25         TX15    B0              B2              B2              B0
26         TX18    B1              B3              B3              B1
27 ----------------------------------------------------------------------
28         TX19    B2              B4              B4              B2
29         TX20    B3              B5              B5              B3
30         TX21    B4              B6              B6              B4
31 Y       TX22    B5              B7              B7              B5
32 2       TX24    HSYNC           HSYNC           HSYNC           HSYNC
33         TX25    VSYNC           VSYNC           VSYNC           VSYNC
34         TX26    ENABLE          ENABLE          ENABLE          ENABLE
35 ----------------------------------------------------------------------    
36         TX27    R6              R0              GND             GND
37         TX5     R7              R1              GND             GND
38         TX10    G6              G0              GND             GND
39 Y       TX11    G7              G1              GND             GND
40 3       TX16    B6              B0              GND             GND
41         TX17    B7              B1              GND             GND
42         TX23    RSVD            RSVD            RSVD            RSVD
43 ----------------------------------------------------------------------
44 */
45
46 typedef enum _SCREEN_TYPE {
47         SCREEN_NULL = 0,
48         SCREEN_RGB,
49         SCREEN_LVDS,
50         SCREEN_MCU,
51         SCREEN_TVOUT,
52         SCREEN_HDMI,
53         SCREEN_MIPI,
54 } SCREEN_TYPE;
55
56 typedef enum _REFRESH_STAGE {
57     REFRESH_PRE = 0,
58     REFRESH_END,
59
60 } REFRESH_STAGE;
61
62
63 typedef enum _MCU_IOCTL {
64     MCU_WRCMD = 0,
65     MCU_WRDATA,
66     MCU_SETBYPASS,
67
68 } MCU_IOCTL;
69
70
71 typedef enum _MCU_STATUS {
72     MS_IDLE = 0,
73     MS_MCU,
74     MS_EBOOK,
75     MS_EWAITSTART,
76     MS_EWAITEND,
77     MS_EEND,
78
79 } MCU_STATUS;
80
81 struct rk29_fb_setting_info {
82         u8 data_num;
83         u8 vsync_en;
84         u8 den_en;
85         u8 mcu_fmk_en;
86         u8 disp_on_en;
87         u8 standby_en;
88 };
89
90 struct rk29lcd_info {
91         u32 lcd_id;
92         u32 txd_pin;
93         u32 clk_pin;
94         u32 cs_pin;
95         u32     reset_pin;
96         int (*io_init)(void);
97         int (*io_deinit)(void);
98         int (*io_enable)(void);
99         int (*io_disable)(void);
100 };
101
102
103 /* Screen description 
104 *type:LVDS,RGB,MIPI,MCU
105 *lvds_fromat:lvds data format,set it if the screen is lvds
106 *face:thi display output face,18bit,24bit,etc
107 *ft: the time need to display one frame time
108 */
109 struct rk_screen {
110         u16 type;
111         u16 lvds_format; 
112         u16 face;
113         u8 lcdc_id;   
114         u8 screen_id; 
115         struct fb_videomode mode;
116         u16 width;
117         u16 height;
118         u8  ft;
119         int *dsp_lut; 
120
121 #if defined(CONFIG_MFD_RK616)
122         u32 pll_cfg_val;  //bellow are for jettaB
123         u32 frac;
124         u16 scl_vst;
125         u16 scl_hst;
126         u16 vif_vst;
127         u16 vif_hst;
128 #endif
129         u8 hdmi_resolution;
130         u8 mcu_wrperiod;
131         u8 mcu_usefmk;
132         u8 mcu_frmrate;
133
134         u8 pin_hsync;
135         u8 pin_vsync;
136         u8 pin_den;
137         u8 pin_dclk;
138
139         /* Swap rule */
140         u8 swap_gb;
141         u8 swap_rg;
142         u8 swap_rb;
143         u8 swap_delta;
144         u8 swap_dumy;
145         
146 #if defined(CONFIG_MIPI_DSI)
147         /* MIPI DSI */
148         u8 dsi_lane;
149         u8 dsi_video_mode;
150         u32 hs_tx_clk;
151 #endif
152
153         int xpos;  //horizontal display start position on the sceen ,then can be changed by application
154         int ypos;
155         int xsize; //horizontal and vertical display size on he screen,they can be changed by application
156         int ysize;
157         struct rk_screen *ext_screen;
158         /* Operation function*/
159         int (*init)(void);
160         int (*standby)(u8 enable);
161         int (*refresh)(u8 arg);
162         int (*scandir)(u16 dir);
163         int (*disparea)(u8 area);
164         int (*sscreen_get)(struct rk_screen *screen, u8 resolution);
165         int (*sscreen_set)(struct rk_screen *screen, bool type);// 1: use scaler 0:bypass
166 };
167
168 struct rk29fb_info {
169         u32 fb_id;
170         int prop;               //display device property,like PRMRY,EXTEND
171         u32 mcu_fmk_pin;
172         struct rk29lcd_info *lcd_info;
173         int (*io_init)(struct rk29_fb_setting_info *fb_setting);
174         int (*io_deinit)(void);
175         int (*io_enable)(void);
176         int (*io_disable)(void);
177         void (*set_screen_info)(struct rk_screen *screen, struct rk29lcd_info *lcd_info );
178 };
179
180 extern void set_lcd_info(struct rk_screen *screen, struct rk29lcd_info *lcd_info);
181 extern size_t get_fb_size(void);
182
183 extern void set_tv_info(struct rk_screen *screen);
184 extern void set_hdmi_info(struct rk_screen *screen);
185
186 #endif