rk3368 lcdc: overlay mode depend on screen color mode
[firefly-linux-kernel-4.4.55.git] / drivers / video / rockchip / transmitter / rk610_lcd.h
1 #ifndef _RK610_LCD_H
2 #define _RK610_LCD_H
3 #include <linux/mfd/rk610_core.h>
4 #include <linux/earlysuspend.h>
5 #define ENABLE      1
6 #define DISABLE     0
7
8 //LVDS lane input format
9 #define DATA_D0_MSB         0
10 #define DATA_D7_MSB         1
11 //LVDS input source
12 #define FROM_LCD1           0
13 #define FROM_LCD0_OR_SCL    1
14
15 /*      LCD1 config         */
16 #define LCD1_AS_IN      0
17 #define LCD1_AS_OUT     1
18
19 //LCD1 output source
20 #define LCD1_FROM_LCD0  0
21 #define LCD1_FROM_SCL   1
22
23 //SCALER config
24 #define NOBYPASS    0
25 #define BYPASS      1
26
27 //SCALER PLL config
28 #define S_PLL_PWR_ON    0
29 #define S_PLL_PWR_DOWN  1
30
31 /*      clock config        */
32 #define S_PLL_FROM_DIV      0
33 #define S_PLL_FROM_CLKIN    1
34 #define S_PLL_DIV(x)        ((x)&0x7)
35 /*********S_PLL_CON************/
36 //S_PLL_CON0
37 #define S_DIV_N(x)              (((x)&0xf)<<4)
38 #define S_DIV_OD(x)             (((x)&3)<<0)
39 //S_PLL_CON1
40 #define S_DIV_M(x)              ((x)&0xff)
41 //S_PLL_CON2
42 #define S_PLL_UNLOCK            (0<<7)    //0:unlock 1:pll_lock
43 #define S_PLL_LOCK              (1<<7)    //0:unlock 1:pll_lock
44 #define S_PLL_PWR(x)            (((x)&1)<<2)    //0:POWER UP 1:POWER DOWN
45 #define S_PLL_RESET(x)          (((x)&1)<<1)    //0:normal  1:reset M/N dividers
46 #define S_PLL_BYPASS(x)          (((x)&1)<<0)    //0:normal  1:bypass
47 //LVDS_CON0
48 #define LVDS_OUT_CLK_PIN(x)     (((x)&1)<<7)    //clk enable pin, 0: enable
49 #define LVDS_OUT_CLK_PWR_PIN(x) (((x)&1)<<6)    //clk pwr enable pin, 1: enable 
50 #define LVDS_PLL_PWR_PIN(x)     (((x)&1)<<5)    //pll pwr enable pin, 0:enable 
51 #define LVDS_BIASE_PWR(x)       (((x)&1)<<4)    //0: power down     1: normal work
52 #define LVDS_LANE_IN_FORMAT(x)  (((x)&1)<<3)    //0: msb on D0  1:msb on D7
53 #define LVDS_INPUT_SOURCE(x)    (((x)&1)<<2)    //0: from lcd1  1:from lcd0 or scaler
54 #define LVDS_OUTPUT_FORMAT(x)   (((x)&3)<<0)    //00:8bit format-1  01:8bit format-2  10:8bit format-3   11:6bit format  
55 //LVDS_CON1
56 #define LVDS_OUT_ENABLE(x)      (((x)&0xf)<<4)  //0:output enable 1:output disable
57 #define LVDS_TX_PWR_ENABLE(x)   (((x)&0xf)<<0)  //0:working mode  1:power down
58 //LCD1_CON
59 #define LCD1_OUT_ENABLE(x)      (((x)&1)<<1)    //0:lcd1 as input 1:lcd1 as output
60 #define LCD1_OUT_SRC(x)         (((x)&1)<<0)    //0:from lcd0   1:from scaler
61 //SCL_CON0
62 #define SCL_BYPASS(x)           (((x)&1)<<4)    //0:not bypass  1:bypass
63 #define SCL_DEN_INV(x)          (((x)&1)<<3)    //scl_den_inv
64 #define SCL_H_V_SYNC_INV(x)     (((x)&1)<<2)    //scl_sync_inv
65 #define SCL_OUT_CLK_INV(x)      (((x)&1)<<1)    //scl_dclk_inv
66 #define SCL_ENABLE(x)           (((x)&1)<<0)    //scaler enable
67 //SCL_CON1
68 #define SCL_H_FACTOR_LSB(x)     ((x)&0xff)      //scl_h_factor[7:0]
69 //SCL_CON2
70 #define SCL_H_FACTOR_MSB(x)     (((x)>>8)&0x3f)      //scl_h_factor[13:8]
71 //SCL_CON3
72 #define SCL_V_FACTOR_LSB(x)     ((x)&0xff)      //scl_v_factor[7:0]
73 //SCL_CON4
74 #define SCL_V_FACTOR_MSB(x)     (((x)>>8)&0x3f)      //scl_v_factor[13:8]
75 //SCL_CON5
76 #define SCL_DSP_HST_LSB(x)      ((x)&0xff)      //dsp_frame_hst[7:0]
77 //SCL_CON6
78 #define SCL_DSP_HST_MSB(x)      (((x)>>8)&0xf)       //dsp_frame_hst[11:8]
79 //SCL_CON7
80 #define SCL_DSP_VST_LSB(x)      ((x)&0xff)      //dsp_frame_vst[7:0]
81 //SCL_CON8
82 #define SCL_DSP_VST_MSB(x)      (((x)>>8)&0xf)       //dsp_frame_vst[11:8]
83 //SCL_CON9
84 #define SCL_DSP_HTOTAL_LSB(x)   ((x)&0xff)      //dsp_frame_htotal[7:0]
85 //SCL_CON10
86 #define SCL_DSP_HTOTAL_MSB(x)   (((x)>>8)&0xf)       //dsp_frame_htotal[11:8]
87 //SCL_CON11
88 #define SCL_DSP_HS_END(x)       ((x)&0xff)      //dsp_hs_end
89 //SCL_CON12
90 #define SCL_DSP_HACT_ST_LSB(x)      ((x)&0xff)      //dsp_hact_st[7:0]
91 //SCL_CON13
92 #define SCL_DSP_HACT_ST_MSB(x)      (((x)>>8)&0x3)      //dsp_hact_st[9:8]
93 //SCL_CON14
94 #define SCL_DSP_HACT_END_LSB(x)   ((x)&0xff)      //dsp_hact_end[7:0]
95 //SCL_CON15
96 #define SCL_DSP_HACT_END_MSB(x)   (((x)>>8)&0xf)       //dsp_frame_htotal[11:8]
97 //SCL_CON16
98 #define SCL_DSP_VTOTAL_LSB(x)   ((x)&0xff)      //dsp_frame_vtotal[7:0]
99 //SCL_CON17
100 #define SCL_DSP_VTOTAL_MSB(x)   (((x)>>8)&0xf)       //dsp_frame_vtotal[11:8]
101 //SCL_CON18
102 #define SCL_DSP_VS_END(x)       ((x)&0xff)      //dsp_vs_end
103 //SCL_CON19
104 #define SCL_DSP_VACT_ST(x)      ((x)&0xff)      //dsp_vact_st[7:0]
105 //SCL_CON20
106 #define SCL_DSP_VACT_END_LSB(x)   ((x)&0xff)      //dsp_vact_end[7:0]
107 //SCL_CON21
108 #define SCL_DSP_VACT_END_MSB(x)   (((x)>>8)&0xf)       //dsp_frame_vtotal[11:8]
109 //SCL_CON22
110 #define SCL_H_BORD_ST_LSB(x)        ((x)&0xff)      //dsp_hbord_st[7:0]
111 //SCL_CON23
112 #define SCL_H_BORD_ST_MSB(x)        (((x)>>8)&0x3)      //dsp_hbord_st[9:8]
113 //SCL_CON24
114 #define SCL_H_BORD_END_LSB(x)        ((x)&0xff)      //dsp_hbord_end[7:0]
115 //SCL_CON25
116 #define SCL_H_BORD_END_MSB(x)        (((x)>>8)&0xf)      //dsp_hbord_end[11:8]
117 //SCL_CON26
118 #define SCL_V_BORD_ST(x)            ((x)&0xff)      //dsp_vbord_st[7:0]
119 //SCL_CON27
120 #define SCL_V_BORD_END_LSB(x)              ((x)&0xff)      //dsp_vbord_end[7:0]
121 //SCL_CON25
122 #define SCL_V_BORD_END_MSB(x)        (((x)>>8)&0xf)      //dsp_vbord_end[11:8]
123
124 /* Scaler PLL CONFIG */
125 #define S_PLL_NO_1      0
126 #define S_PLL_NO_2      1
127 #define S_PLL_NO_4      2
128 #define S_PLL_NO_8      3
129 #define S_PLL_M(x)  (((x)&0xff)<<8)
130 #define S_PLL_N(x)  (((x)&0xf)<<4)
131 #define S_PLL_NO(x) ((S_PLL_NO_##x)&0x3)
132
133 enum{
134     HDMI_RATE_148500000,
135     HDMI_RATE_74250000,
136     HDMI_RATE_27000000,
137 };
138 /*     Scaler   clk setting */
139 #define SCALE_PLL(_parent_rate,_rate,_m,_n,_no) \
140         HDMI_RATE_ ## _parent_rate ##_S_RATE_ ## _rate \
141         =  S_PLL_M(_m) | S_PLL_N(_n) | S_PLL_NO(_no)    
142 #define SCALE_RATE(_parent_rate , _rate) \
143         (HDMI_RATE_ ## _parent_rate ## _S_RATE_ ## _rate)
144         
145 enum{
146     SCALE_PLL(148500000,    66000000,   16, 9,  4),
147     SCALE_PLL(148500000,    57375000,   17, 11, 4),
148     SCALE_PLL(148500000,    54000000,   16, 11, 4),    
149     SCALE_PLL(148500000,    33000000,   16, 9,  8),
150     SCALE_PLL(148500000,    30375000,   18, 11, 8),
151     SCALE_PLL(148500000,    29700000,   16, 10, 8),
152     SCALE_PLL(148500000,    25312500,   15, 11, 8),
153     SCALE_PLL(148500000,    74250000,   12, 6, 4),
154     SCALE_PLL(148500000,    50625000,   15, 11, 4),
155      SCALE_PLL(148500000,    79199997,   32, 15,  4),
156     SCALE_PLL(148500000,    45375000,   22, 9, 8),
157
158     SCALE_PLL(74250000,     66000000,   32, 9,  4),
159     SCALE_PLL(74250000,     57375000,   34, 11, 4),
160     SCALE_PLL(74250000,     54000000,   32, 11, 4),
161     SCALE_PLL(74250000,     33000000,   32, 9,  8),
162     SCALE_PLL(74250000,     30375000,   36, 11, 8),
163     SCALE_PLL(74250000,     25312500,   30, 11, 8),
164     SCALE_PLL(74250000,     74250000,   12, 3, 4),
165     SCALE_PLL(74250000,    67500000,   40, 11, 4),
166     SCALE_PLL(74250000,    50625000,   30, 11, 4),
167     SCALE_PLL(74250000,     79199997,   64,15,4),
168     SCALE_PLL(74250000,    44343750,   43, 9, 8),
169
170     SCALE_PLL(27000000,     75000000,   100, 9,  4),
171     SCALE_PLL(27000000,     72000000,   32, 3,  4),
172     SCALE_PLL(27000000,     63281250,   75, 4,  8),
173         SCALE_PLL(27000000,     60000000,   80, 9,  4),
174     SCALE_PLL(27000000,     54375000,   145, 9,  8),
175     SCALE_PLL(27000000,     31500000,   28, 3,  8),
176     SCALE_PLL(27000000,     30000000,   80, 9,  8),
177     SCALE_PLL(27000000,     70312500,   125, 6,  8),
178     SCALE_PLL(27000000,     46875000,   125, 9,  8),
179     SCALE_PLL(27000000,     56250000,   25, 3,  4)
180 };
181
182 enum {
183     LCD_OUT_SCL,
184     LCD_OUT_BYPASS,
185     LCD_OUT_DISABLE,
186 };
187 struct rk610_pll_info{
188     u32 parent_rate;
189     u32 rate;
190     int m;
191     int n;
192     int od;
193 };
194 struct lcd_mode_inf{
195         int h_pw;
196         int h_bp;
197         int h_vd;
198         int h_fp;
199         int v_pw;
200         int v_bp;
201         int v_vd;
202         int v_fp;
203         int f_hst;
204         int f_vst;
205     struct rk610_pll_info pllclk;
206 };
207 struct scl_hv_info{
208     int scl_h ;
209     int scl_v;
210     };
211
212 struct scl_info{
213     bool pll_pwr;
214     bool scl_pwr;
215     struct scl_hv_info scl_hv;
216 };
217 struct rk610_lcd_info{
218     int disp_mode;
219     
220     struct rk_screen *screen;
221     struct scl_info scl_inf;
222     struct i2c_client *client;
223
224 #ifdef CONFIG_HAS_EARLYSUSPEND
225         struct early_suspend            early_suspend;
226 #endif
227 };
228 extern int rk610_lcd_init(struct rk610_core_info *rk610_core_info);
229 extern int rk610_lcd_scaler_set_param(struct rk_screen *screen,bool enable );
230 #endif