video: rockchip: only vop big support 8x2560 linebuffer
[firefly-linux-kernel-4.4.55.git] / drivers / video / rockchip / lcdc / rk2928_lcdc.h
1 #ifndef RK2928_LCDC_H_
2 #define RK2928_LCDC_H_
3
4 #include<linux/rk_fb.h>
5
6 #define LcdReadBit(inf, addr, msk)      ((inf->regbak.addr=inf->preg->addr)&(msk))
7 #define LcdWrReg(inf, addr, val)        inf->preg->addr=inf->regbak.addr=(val)
8 #define LcdRdReg(inf, addr)             (inf->preg->addr)
9 #define LcdSetBit(inf, addr, msk)       inf->preg->addr=((inf->regbak.addr) |= (msk))
10 #define LcdClrBit(inf, addr, msk)       inf->preg->addr=((inf->regbak.addr) &= ~(msk))
11 #define LcdSetRegBit(inf, addr, msk)    inf->preg->addr=((inf->preg->addr) |= (msk))
12 #define LcdMskReg(inf, addr, msk, val)  (inf->regbak.addr)&=~(msk);   inf->preg->addr=(inf->regbak.addr|=(val))
13 #define LCDC_REG_CFG_DONE()             LcdWrReg(lcdc_dev, REG_CFG_DONE, 0x01); dsb()
14
15 /********************************************************************
16 **                          ½á¹¹¶¨Òå                                *
17 ********************************************************************/
18 /* LCDCµÄ¼Ä´æÆ÷½á¹¹ */
19
20 typedef volatile struct tagLCDC_REG
21 {
22     /* offset 0x00~0xc0 */
23         unsigned int SYS_CFG;                           //0x00 system config register
24         unsigned int DSP_CTRL;                          //0x0c display control register 
25         unsigned int BG_COLOR;                          //back ground color register
26         unsigned int ALPHA_CTRL;                                //alpha control register
27         unsigned int INT_STATUS;                        //0x10 Interrupt status register
28         unsigned int WIN0_COLOR_KEY_CTRL;     //0x1c Win0 blending control register
29         unsigned int WIN1_COLOR_KEY_CTRL;     //0x20 Win1 blending control register
30         unsigned int WIN0_YRGB_MST;           //0x28 Win0 active YRGB memory start address0
31         unsigned int WIN0_CBR_MST;            //0x2c Win0 active Cbr memory start address0
32         unsigned int WIN_VIR;                //0x38 WIN0 virtual display width/height
33         unsigned int WIN0_ACT_INFO;           //0x3C Win0 active window width/height
34         unsigned int WIN0_DSP_INFO;           //0x40 Win0 display width/height on panel
35         unsigned int WIN0_DSP_ST;             //0x44 Win0 display start point on panel
36         unsigned int WIN0_SCL_FACTOR_YRGB;    //0x48Win0 YRGB scaling  factor setting
37         unsigned int WIN0_SCL_FACTOR_CBR;     //0x4c Win0 YRGB scaling factor setting
38         unsigned int WIN0_SCL_OFFSET;         //0x50 Win0 Cbr scaling start point offset
39         unsigned int WIN1_RGB_MST;           //0x54 Win1 active YRGB memory start address
40         unsigned int WIN1_DSP_INFO;           //0x64 Win1 display width/height on panel
41         unsigned int WIN1_DSP_ST;             //0x68 Win1 display start point on panel
42         unsigned int HWC_MST;                 //0x88 HWC memory start address
43         unsigned int HWC_DSP_ST;              //0x8C HWC display start point on panel
44         unsigned int HWC_COLOR_LUT0;          //0x90 Hardware cursor color 2¡¯b01 look up table 0
45         unsigned int HWC_COLOR_LUT1;          //0x94 Hardware cursor color 2¡¯b10 look up table 1
46         unsigned int HWC_COLOR_LUT2;          //0x98 Hardware cursor color 2¡¯b11 look up table 2
47         unsigned int DSP_HTOTAL_HS_END;       //0x9c Panel scanning horizontal width and hsync pulse end point
48         unsigned int DSP_HACT_ST_END;         //0xa0 Panel active horizontal scanning start/end point
49         unsigned int DSP_VTOTAL_VS_END;       //0xa4 Panel scanning vertical height and vsync pulse end point
50         unsigned int DSP_VACT_ST_END;         //0xa8 Panel active vertical scanning start/end point
51         unsigned int SCL_REG0;                //scaler register
52         unsigned int SCL_REG1;
53         unsigned int SCL_REG2;
54         unsigned int SCL_REG3;
55         unsigned int SCL_REG4;
56         unsigned int SCL_REG5;
57         unsigned int SCL_REG6;
58         unsigned int SCL_REG7;
59         unsigned int SCL_REG8;
60         unsigned int reserve[3];
61         unsigned int REG_CFG_DONE;            //0xc0 REGISTER CONFIG FINISH
62   
63 } LCDC_REG, *pLCDC_REG;
64
65
66 /* SYS_CONFIG */
67
68 #define  m_W0_EN              (1<<0)
69 #define  m_W1_EN              (1<<1)
70 #define  m_HWC_EN             (1<<2)
71 #define  m_W0_FORMAT          (7<<3)
72 #define  m_W1_FORMAT          (7<<6)
73 #define  m_W0_RGB_RB_SWAP     (1<<10)
74 #define  m_W1_RGB_RB_SWAP     (1<<14)
75
76 #define m_W0_AXI_OUTSTANDING_DISABLE (1<<16) 
77 #define m_W1_AXI_OUTSTANDING_DISABLE (1<<17)
78 #define m_DMA_BURST_LENGTH           (3<<18)
79 #define m_LCDC_STANDBY               (1<<22)
80
81 #define m_LCDC_AXICLK_AUTO_ENABLE    (1<<24) //eanble for low power
82 #define m_DSP_OUT_ZERO               (1<<25)
83
84 #define v_W0_EN(x)                      (((x)&1)<<0)
85 #define v_W1_EN(x)                      (((x)&1)<<1)
86 #define v_HWC_EN(x)                     (((x)&1)<<2)
87 #define v_W0_FORMAT(x)                  (((x)&7)<<3)
88 #define v_W1_FORMAT(x)                  (((x)&7)<<6)
89 #define v_W0_RGB_RB_SWAP(x)             (((x)&1)<<10)   
90 #define v_W1_RGB_RB_SWAP(x)             (((x)&1)<<14)
91
92 #define v_LCDC_STANDBY(x)               (((x)&1)<<22)
93 #define v_LCDC_AXICLK_AUTO_ENABLE(x)    (((x)&1)<<24)
94 #define v_DSP_OUT_ZERO(x)               (((x)&1)<<25)
95
96
97 #define v_LCDC_DMA_STOP(x)              (((x)&1)<<0)
98 #define v_HWC_RELOAD_EN(x)             (((x)&1)<<2)
99 #define v_W0_AXI_OUTSTANDING_DISABLE(x) (((x)&1)<<3)
100 #define v_W1_AXI_OUTSTANDING_DISABLE(x) (((x)&1)<<4)
101 #define v_W2_AXI_OUTSTANDING_DISABLE(x) (((x)&1)<<5)
102 #define v_DMA_BURST_LENGTH(x)           (((x)&3)<<6)
103 #define v_WIN0_YRGB_CHANNEL0_ID(x)      (((x)&7)<<8)
104 #define v_WIN0_CBR_CHANNEL0_ID(x)       (((x)&7)<<11)
105 #define v_WIN0_YRGB_CHANNEL1_ID(x)      (((x)&7)<<14)
106 #define v_WIN0_CBR_CHANNEL1_ID(x)       (((x)&7)<<17)
107 #define v_WIN1_YRGB_CHANNEL_ID(x)       (((x)&7)<<20)
108 #define v_WIN1_CBR_CHANNEL_ID(x)        (((x)&7)<<23)
109 #define v_WIN2_CHANNEL_ID(x)            (((x)&7)<<26)
110 #define v_HWC_CHANNEL_ID(x)             (((x)&7)<<29)
111
112
113
114 //LCDC_DSP_CTRL_REG
115 #define m_DISPLAY_FORMAT             (3<<0)
116 #define m_BLANK_MODE                 (1<<2)
117 #define m_BLACK_MODE                 (1<<3)
118 #define m_HSYNC_POLARITY             (1<<4)
119 #define m_VSYNC_POLARITY             (1<<5)
120 #define m_DEN_POLARITY               (1<<6)
121 #define m_DCLK_POLARITY              (1<<7)
122 #define m_W0W1_POSITION_SWAP         (1<<8)
123 #define m_OUTPUT_BG_SWAP             (1<<9)
124 #define m_OUTPUT_RB_SWAP             (1<<10)
125 #define m_OUTPUT_RG_SWAP             (1<<11)
126 #define m_DITHER_UP_EN               (1<<12)
127 #define m_DITHER_DOWN_MODE           (1<<13)
128 #define m_DITHER_DOWN_EN             (1<<14)
129
130
131 #define m_W1_INTERLACE_READ_MODE     (1<<15)
132 #define m_W2_INTERLACE_READ_MODE     (1<<16)
133 #define m_W0_YRGB_DEFLICK_MODE       (1<<17)
134 #define m_W0_CBR_DEFLICK_MODE        (1<<18)
135 #define m_W1_YRGB_DEFLICK_MODE       (1<<19)
136 #define m_W1_CBR_DEFLICK_MODE        (1<<20)
137 #define m_W0_ALPHA_MODE              (1<<21)
138 #define m_W1_ALPHA_MODE              (1<<22)
139 #define m_W2_ALPHA_MODE              (1<<23)
140 #define m_W0_COLOR_SPACE_CONVERSION  (3<<24)
141 #define m_W1_COLOR_SPACE_CONVERSION  (3<<26)
142 #define m_W2_COLOR_SPACE_CONVERSION  (1<<28)
143 #define m_YCRCB_CLIP_EN              (1<<29)
144 #define m_CBR_FILTER_656             (1<<30)
145
146 #define v_DISPLAY_FORMAT(x)           (((x)&0x3)<<0)
147 #define v_BLANK_MODE(x)               (((x)&1)<<2)
148 #define v_BLACK_MODE(x)               (((x)&1)<<3)
149 #define v_HSYNC_POLARITY(x)           (((x)&1)<<4)
150 #define v_VSYNC_POLARITY(x)           (((x)&1)<<5)
151 #define v_DEN_POLARITY(x)             (((x)&1)<<6)
152 #define v_DCLK_POLARITY(x)            (((x)&1)<<7)
153 #define v_W0W1_POSITION_SWAP(x)       (((x)&1)<<8)
154 #define v_OUTPUT_BG_SWAP(x)           (((x)&1)<<9)
155 #define v_OUTPUT_RB_SWAP(x)           (((x)&1)<<10)
156 #define v_OUTPUT_RG_SWAP(x)           (((x)&1)<<11)
157 #define v_DITHER_UP_EN(x)               (((x)&1)<<12)
158 #define v_DITHER_DOWN_MODE(x)           (((x)&1)<<13)
159 #define v_DITHER_DOWN_EN(x)             (((x)&1)<<14)
160
161 #define v_INTERLACE_DSP_EN(x)             (((x)&1)<<12)
162 #define v_INTERLACE_FIELD_POLARITY(x)   (((x)&1)<<13)
163 #define v_W0_INTERLACE_READ_MODE(x)     (((x)&1)<<14)
164 #define v_W1_INTERLACE_READ_MODE(x)     (((x)&1)<<15)
165 #define v_W2_INTERLACE_READ_MODE(x)     (((x)&1)<<16)
166 #define v_W0_YRGB_DEFLICK_MODE(x)       (((x)&1)<<17)
167 #define v_W0_CBR_DEFLICK_MODE(x)        (((x)&1)<<18)
168 #define v_W1_YRGB_DEFLICK_MODE(x)       (((x)&1)<<19)
169 #define v_W1_CBR_DEFLICK_MODE(x)        (((x)&1)<<20)
170 #define v_W0_ALPHA_MODE(x)             (((x)&1)<<21)
171 #define v_W1_ALPHA_MODE(x)              (((x)&1)<<22)
172 #define v_W2_ALPHA_MODE(x)             (((x)&1)<<23)
173 #define v_W0_COLOR_SPACE_CONVERSION(x)  (((x)&3)<<24)
174 #define v_W1_COLOR_SPACE_CONVERSION(x)  (((x)&3)<<26)
175 #define v_W2_COLOR_SPACE_CONVERSION(x)  (((x)&1)<<28)
176 #define v_YCRCB_CLIP_EN(x)            (((x)&1)<<29)
177 #define v_CBR_FILTER_656(x)             (((x)&1)<<30)
178
179 //LCDC_BG_COLOR
180 #define m_BG_COLOR                    (0xffffff<<0)
181 #define m_BG_B                        (0xff<<0)
182 #define m_BG_G                        (0xff<<8)
183 #define m_BG_R                        (0xff<<16)
184 #define v_BG_COLOR(x)                 (((x)&0xffffff)<<0)
185 #define v_BG_B(x)                     (((x)&0xff)<<0)
186 #define v_BG_G(x)                     (((x)&0xff)<<8)
187 #define v_BG_R(x)                     (((x)&0xff)<<16)
188
189
190
191
192 //LCDC_ BLEND_CTRL
193 #define m_HWC_BLEND_EN         (1<<0)
194 #define m_W2_BLEND_EN          (1<<1)
195 #define m_W1_BLEND_EN          (1<<2)
196 #define m_W0_BLEND_EN          (1<<3)
197 #define m_HWC_BLEND_FACTOR     (15<<4)
198 #define m_W2_BLEND_FACTOR     (0xff<<8)
199 #define m_W1_BLEND_FACTOR     (0xff<<16)
200 #define m_W0_BLEND_FACTOR     (0xff<<24)
201
202 #define v_HWC_BLEND_EN(x)         (((x)&1)<<0)
203 #define v_W2_BLEND_EN(x)          (((x)&1)<<1)
204 #define v_W1_BLEND_EN(x)          (((x)&1)<<2)
205 #define v_W0_BLEND_EN(x)          (((x)&1)<<3)
206 #define v_HWC_BLEND_FACTOR(x)    (((x)&15)<<4)
207 #define v_W2_BLEND_FACTOR(x)     (((x)&0xff)<<8)
208 #define v_W1_BLEND_FACTOR(x)     (((x)&0xff)<<16)
209 #define v_W0_BLEND_FACTOR(x)     (((x)&0xff)<<24)
210
211 //LCDC_INT_STATUS
212 #define v_HOR_START_INT_STA        (1<<0)  //status
213 #define v_FRM_START_INT_STA        (1<<1)
214 #define v_LINE_FLAG_INT_STA        (1<<2)
215 #define v_BUS_ERR_INT_STA          (1<<3)
216 #define m_HOR_START_INT_EN         (1<<4)  //enable
217 #define m_FRM_START_INT_EN          (1<<5)
218 #define m_LINE_FLAG_INT_EN         (1<<6)
219 #define m_BUS_ERR_INT_EN           (1<<7)
220 #define m_HOR_START_INT_CLEAR      (1<<8) //auto clear
221 #define m_FRM_START_INT_CLEAR      (1<<9)
222 #define m_LINE_FLAG_INT_CLEAR      (1<<10)
223 #define m_BUS_ERR_INT_CLEAR        (1<<11)
224 #define m_LINE_FLAG_NUM            (0xfff<<12)
225 #define v_HOR_START_INT_EN(x)      (((x)&1)<<4)
226 #define v_FRM_START_INT_EN(x)      (((x)&1)<<5)
227 #define v_LINE_FLAG_INT_EN(x)      (((x)&1)<<6)
228 #define v_BUS_ERR_INT_EN(x)        (((x)&1)<<7)
229 #define v_HOR_START_INT_CLEAR(x)      (((x)&1)<<8)
230 #define v_FRM_START_INT_CLEAR(x)     (((x)&1)<<9)
231 #define v_LINE_FLAG_INT_CLEAR(x)     (((x)&1)<<10)
232 #define v_BUS_ERR_INT_CLEAR(x)        (((x)&1)<<11)
233 #define v_LINE_FLAG_NUM(x)         (((x)&0xfff)<<12)
234
235
236 //LCDC_WIN_VIR
237 #define m_WIN0_VIR   (0xfff << 0)
238 #define m_WIN1_VIR   (0xfff << 16)
239 //LCDC_WINx_VIR ,x is number of words of win0 virtual width
240 #define v_WIN0_ARGB888_VIRWIDTH(x) (x)
241 #define v_WIN0_RGB888_VIRWIDTH(x) (((x*3)>>2)+((x)%3))
242 #define v_WIN0_RGB565_VIRWIDTH(x) (((x)>>1) + ((x%2)?1:0))
243 #define v_WIN0_YUV_VIRWIDTH(x)    (((x)>>2) +((x%4)?1:0))
244
245 #define v_WIN1_ARGB888_VIRWIDTH(x) (x << 16)
246 #define v_WIN1_RGB888_VIRWIDTH(x)  ((((x*3)>>2)+((x)%3)) << 16)
247 #define v_WIN1_RGB565_VIRWIDTH(x)  ((((x)>>1) + ((x%2)?1:0)) << 16)
248 #define v_WIN1_YUV_VIRWIDTH(x)     ((((x)>>2) +((x%4)?1:0)) << 16 )
249
250
251 //LCDC_WIN0_COLOR_KEY_CTRL / LCDC_WIN1_COLOR_KEY_CTRL
252 #define m_KEYCOLOR          (0xffffff<<0)
253 #define m_KEYCOLOR_B          (0xff<<0)
254 #define m_KEYCOLOR_G          (0xff<<8)
255 #define m_KEYCOLOR_R          (0xff<<16)
256 #define m_COLORKEY_EN         (1<<24)
257 #define v_KEYCOLOR(x)          (((x)&0xffffff)<<0)
258 #define v_KEYCOLOR_B(x)          (((x)&0xff)<<0)
259 #define v_KEYCOLOR_G(x)         (((x)&0xff)<<8)
260 #define v_KEYCOLOR_R(x)          (((x)&0xff)<<16)
261 #define v_COLORKEY_EN(x)         (((x)&1)<<24)
262
263 //LCDC_DEFLICKER_SCL_OFFSET
264 #define m_W0_YRGB_VSD_OFFSET      (0xff<<0)
265 #define m_W0_YRGB_VSP_OFFSET      (0xff<<8)
266 #define m_W1_VSD_OFFSET           (0xff<<16)
267 #define m_W1_VSP_OFFSET           (0xff<<24)
268 #define v_W0_YRGB_VSD_OFFSET(x)      (((x)&0xff)<<0)
269 #define v_W0_YRGB_VSP_OFFSET(x)      (((x)&0xff)<<8)
270 #define v_W1_VSD_OFFSET(x)           (((x)&0xff)<<16)
271 #define v_W1_VSP_OFFSET(x)           (((x)&0xff)<<24)
272
273
274
275
276
277 //AXI MS ID
278 #define m_W0_YRGB_CH_ID        (0xF<<0)
279 #define m_W0_CBR_CH_ID         (0xF<<4)
280 #define m_W1_YRGB_CH_ID        (0xF<<8)
281 #define m_W2_CH_ID             (0xF<<12)
282 #define m_HWC_CH_ID            (0xF<<16)
283 #define v_W0_YRGB_CH_ID(x)        (((x)&0xF)<<0)
284 #define v_W0_CBR_CH_ID(x)         (((x)&0xF)<<4)
285 #define v_W1_YRGB_CH_ID(x)        (((x)&0xF)<<8)
286 #define v_W2_CH_ID(x)             (((x)&0xF)<<12)
287 #define v_HWC_CH_ID(x)            (((x)&0xF)<<16)
288
289
290 /* Low Bits Mask */
291 #define m_WORDLO            (0xffff<<0)
292 #define m_WORDHI            (0xffff<<16)
293 #define v_WORDLO(x)         (((x)&0xffff)<<0)
294 #define v_WORDHI(x)         (((x)&0xffff)<<16)
295
296
297 //LCDC_WINx_SCL_FACTOR_Y/CBCR
298 #define v_X_SCL_FACTOR(x)  ((x)<<0)
299 #define v_Y_SCL_FACTOR(x)  ((x)<<16)
300
301 //LCDC_DSP_HTOTAL_HS_END
302 #define v_HSYNC(x)  ((x)<<0)   //hsync pulse width
303 #define v_HORPRD(x) ((x)<<16)   //horizontal period
304
305
306 //LCDC_DSP_HACT_ST_END
307 #define v_HAEP(x) ((x)<<0)  //horizontal active end point
308 #define v_HASP(x) ((x)<<16) //horizontal active start point
309
310 //LCDC_DSP_VTOTAL_VS_END
311 #define v_VSYNC(x) ((x)<<0)
312 #define v_VERPRD(x) ((x)<<16)
313
314 //LCDC_DSP_VACT_ST_END
315 #define v_VAEP(x) ((x)<<0)
316 #define v_VASP(x) ((x)<<16)
317
318
319
320 #define m_ACTWIDTH       (0xffff<<0)
321 #define m_ACTHEIGHT      (0xffff<<16)
322 #define v_ACTWIDTH(x)       (((x)&0xffff)<<0)
323 #define v_ACTHEIGHT(x)      (((x)&0xffff)<<16)
324
325 #define m_VIRST_X      (0xffff<<0)
326 #define m_VIRST_Y      (0xffff<<16)
327 #define v_VIRST_X(x)      (((x)&0xffff)<<0)
328 #define v_VIRST_Y(x)      (((x)&0xffff)<<16)
329
330 #define m_PANELST_X      (0x3ff<<0)
331 #define m_PANELST_Y      (0x3ff<<16)
332 #define v_PANELST_X(x)      (((x)&0x3ff)<<0)
333 #define v_PANELST_Y(x)      (((x)&0x3ff)<<16)
334
335 #define m_PANELWIDTH       (0x3ff<<0)
336 #define m_PANELHEIGHT      (0x3ff<<16)
337 #define v_PANELWIDTH(x)       (((x)&0x3ff)<<0)
338 #define v_PANELHEIGHT(x)      (((x)&0x3ff)<<16)
339
340 #define m_HWC_B                 (0xff<<0)
341 #define m_HWC_G                 (0xff<<8)
342 #define m_HWC_R                 (0xff<<16)
343 #define m_W0_YRGB_HSP_OFFSET    (0xff<<24)
344 #define m_W0_YRGB_HSD_OFFSET    (0xff<<24)
345 #define v_HWC_B(x)                 (((x)&0xff)<<0)
346 #define v_HWC_G(x)                 (((x)&0xff)<<8)
347 #define v_HWC_R(x)                 (((x)&0xff)<<16)
348 #define v_W0_YRGB_HSP_OFFSET(x)    (((x)&0xff)<<24)
349 #define v_W0_YRGB_HSD_OFFSET(x)    (((x)&0xff)<<24)
350
351 //LCDC_WIN0_ACT_INFO
352 #define v_ACT_WIDTH(x)     ((x-1)<<0)
353 #define v_ACT_HEIGHT(x)    ((x-1)<<16)
354
355 //LCDC_WIN0_DSP_INFO
356 #define v_DSP_WIDTH(x)     ((x-1)<<0)
357 #define v_DSP_HEIGHT(x)    ((x-1)<<16)
358
359 //LCDC_WIN0_DSP_ST    //x,y start point of the panel scanning
360 #define v_DSP_STX(x)      (x<<0)
361 #define v_DSP_STY(x)      (x<<16)
362
363 //Panel display scanning
364 #define m_PANEL_HSYNC_WIDTH             (0x3ff<<0)
365 #define m_PANEL_HORIZONTAL_PERIOD       (0x3ff<<16)
366 #define v_PANEL_HSYNC_WIDTH(x)             (((x)&0x3ff)<<0)
367 #define v_PANEL_HORIZONTAL_PERIOD(x)       (((x)&0x3ff)<<16)
368
369 #define m_PANEL_END              (0x3ff<<0)
370 #define m_PANEL_START            (0x3ff<<16)
371 #define v_PANEL_END(x)              (((x)&0x3ff)<<0)
372 #define v_PANEL_START(x)            (((x)&0x3ff)<<16)
373
374 #define m_PANEL_VSYNC_WIDTH             (0x3ff<<0)
375 #define m_PANEL_VERTICAL_PERIOD       (0x3ff<<16)
376 #define v_PANEL_VSYNC_WIDTH(x)             (((x)&0x3ff)<<0)
377 #define v_PANEL_VERTICAL_PERIOD(x)       (((x)&0x3ff)<<16)
378 //-----------
379
380 #define m_HSCALE_FACTOR        (0xffff<<0)
381 #define m_VSCALE_FACTOR        (0xffff<<16)
382 #define v_HSCALE_FACTOR(x)        (((x)&0xffff)<<0)
383 #define v_VSCALE_FACTOR(x)        (((x)&0xffff)<<16)
384
385 #define m_W0_CBR_HSD_OFFSET   (0xff<<0)
386 #define m_W0_CBR_HSP_OFFSET   (0xff<<8)
387 #define m_W0_CBR_VSD_OFFSET   (0xff<<16)
388 #define m_W0_CBR_VSP_OFFSET   (0xff<<24)
389 #define v_W0_CBR_HSD_OFFSET(x)   (((x)&0xff)<<0)
390 #define v_W0_CBR_HSP_OFFSET(x)   (((x)&0xff)<<8)
391 #define v_W0_CBR_VSD_OFFSET(x)   (((x)&0xff)<<16)
392 #define v_W0_CBR_VSP_OFFSET(x)   (((x)&0xff)<<24)
393
394
395 //LCDC_SCL_REG0
396 #define m_SCL_DSP_ZERO           (1<<4)
397 #define m_SCL_DEN_INVERT         (1<<3)
398 #define m_SCL_SYNC_INVERT        (1<<2)
399 #define m_SCL_DCLK_INVERT        (1<<1)
400 #define m_SCL_EN                 (1<<0)
401 #define v_SCL_DSP_ZERO(x)        (((x)&1)<<4)
402 #define v_SCL_DEN_INVERT(x)      (((x)&1)<<3)
403 #define v_SCL_SYNC_INVERT(x)     (((x)&1)<<2)
404 #define v_SCL_DCLK_INVERT(x)     (((x)&1)<<1)
405 #define v_SCL_EN(x)              (((x)&1)<<0)
406
407 //LCDC_SCL_REG1
408 #define m_SCL_V_FACTOR           (0x3fff<<16)
409 #define m_SCL_H_FACTOR           (0x3fff<<0)
410 #define v_SCL_V_FACTOR(x)                (((x)&0x3fff)<<16)
411 #define v_SCL_H_FACTOR(x)                (((x)&0x3fff)<<0)
412
413
414 //LCDC_SCL_REG2
415 #define m_SCL_DSP_FRAME_VST     (0xfff<<16)
416 #define m_SCL_DSP_FRAME_HST     (0xfff<<0)
417 #define v_SCL_DSP_FRAME_VST(x)  (((x)&0xfff)<<16)
418 #define v_SCL_DSP_FRAME_HST(x)  (((x)&0xfff)<<0)
419
420 //LCDC_SCL_REG3
421 #define m_SCL_DSP_HS_END        (0xff<<16)
422 #define m_SCL_DSP_HTOTAL        (0xfff<<0)
423 #define v_SCL_DSP_HS_END(x)     (((x)&0xff)<<16)
424 #define v_SCL_DSP_HTOTAL(x)     (((x)&0xfff)<<0)
425
426 //LCDC_SCL_REG4
427 #define m_SCL_DSP_HACT_ST       (0x3ff<<16)
428 #define m_SCL_DSP_HACT_END      (0xfff<<0)
429 #define v_SCL_DSP_HACT_ST(x)    (((x)&0x3ff)<<16)
430 #define v_SCL_DSP_HACT_END(x)   (((x)&0xfff)<<0)
431
432 //LCDC_SCL_REG5
433 #define m_SCL_DSP_VS_END        (0xff<<16)
434 #define m_SCL_DSP_VTOTAL        (0xfff<<0)
435 #define v_SCL_DSP_VS_END(x)     (((x)&0xff)<<16)
436 #define v_SCL_DSP_VTOTAL(x)     (((x)&0xfff)<<0)
437
438 //LCDC_SCL_REG6
439 #define m_SCL_DSP_VACT_ST       (0xff<<16)
440 #define m_SCL_DSP_VACT_END      (0xfff<<0)
441 #define v_SCL_DSP_VACT_ST(x)    (((x)&0xff)<<16)
442 #define v_SCL_DSP_VACT_END(x)   (((x)&0xfff)<<0)
443
444
445 //LCDC_SCL_REG7
446 #define m_SCL_DSP_HBOR_ST       (0x3ff<<16)
447 #define m_SCL_DSP_HBOR_END      (0xfff<<0)
448 #define v_SCL_DSP_HBOR_ST(x)    (((x)&0x3ff)<<16)
449 #define v_SCL_DSP_HBOR_END(x)   (((x)&0xfff)<<0)
450
451 //LCDC_SCL_REG8
452
453 #define m_SCL_DSP_VBOR_ST       (0xff<<16)
454 #define m_SCL_DSP_VBOR_END      (0xfff<<0)
455 #define v_SCL_DSP_VBOR_ST(x)    (((x)&0xff)<<16)
456 #define v_SCL_DSP_VBOR_END(x)   (((x)&0xfff)<<0)
457
458
459
460
461
462 #define CalScale(x, y)               (((u32)(x)*0x1000)/(y))
463 struct rk2928_lcdc_device{
464         int id;
465         struct rk_lcdc_device_driver driver;
466         rk_screen *screen;
467         
468         LCDC_REG *preg;         // LCDC reg base address and backup reg 
469         LCDC_REG regbak;
470
471         void __iomem *reg_vir_base;     // virtual basic address of lcdc register
472         u32 reg_phy_base;               // physical basic address of lcdc register
473         u32 len;                        // physical map length of lcdc register
474         spinlock_t  reg_lock;           //one time only one process allowed to config the register
475         bool clk_on;                    //if aclk or hclk is closed ,acess to register is not allowed
476         u8 atv_layer_cnt;               //active layer counter,when  atv_layer_cnt = 0,disable lcdc
477         unsigned int            irq;
478         
479         struct clk              *pd;                            //lcdc power domain     
480         struct clk              *hclk;                          //lcdc AHP clk
481         struct clk              *dclk;                          //lcdc dclk
482         struct clk              *aclk;                          //lcdc share memory frequency
483         struct clk              *sclk;                          //scale clk
484         struct clk              *aclk_parent;           //lcdc aclk divider frequency source
485         struct clk              *aclk_ddr_lcdc;         //DDR LCDC AXI clock disable.
486         struct clk              *aclk_disp_matrix;      //DISPLAY matrix AXI clock disable.
487         struct clk              *hclk_cpu_display;      //CPU DISPLAY AHB bus clock disable.
488         struct clk              *pd_display;            // display power domain
489         u32     pixclock;
490 };
491
492 struct lcdc_info{
493 /*LCD CLK*/
494         struct rk2928_lcdc_device lcdc0;
495
496 };
497
498
499 struct win_set {
500         volatile u32 y_offset;
501         volatile u32 c_offset;
502 };
503
504 struct win0_par {
505     u32 refcount;
506     u32 pseudo_pal[16];
507     u32 y_offset;
508     u32 c_offset;
509     u32 xpos;         //size in panel
510     u32 ypos;
511     u32 xsize;        //start point in panel
512     u32 ysize;
513     enum data_format format;
514
515     wait_queue_head_t wait;
516     struct win_set mirror;
517     struct win_set displ;
518     struct win_set done;
519
520     u8 par_seted;
521     u8 addr_seted;
522 };
523
524 #endif
525
526