tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8810 / lcd.h
1 /******************************************************************************
2  ** File Name:       lcd.h                                                    *
3  ** Author:          Jim zhang                                                *
4  ** DATE:            08/21/2003                                               *
5  ** Copyright:      2003 Spreatrum, Incoporated. All Rights Reserved.         *
6  ** Description:                                                              *
7  ******************************************************************************
8
9  ******************************************************************************
10  **                        Edit History                                       *
11  ** ------------------------------------------------------------------------- *
12  ** DATE              NAME             DESCRIPTION                            *
13  ** 08/21/2003     Jim zhang        Create.                                   *
14  ******************************************************************************/
15
16
17 #ifndef _LCD_H_
18 #define _LCD_H_
19
20 /**---------------------------------------------------------------------------*
21  **                         Dependencies                                      *
22  **---------------------------------------------------------------------------*/
23
24 #include "sci_types.h"
25 #include "com_drvapi.h"
26 #include "chip.h"
27
28 #if defined(PLATFORM_SC6800H) || defined(PLATFORM_SC8800G)|| defined(CONFIG_SC8810)
29 #include "lcdc_types.h"
30 #endif
31 /**---------------------------------------------------------------------------*
32  **                         Compiler Flag                                     *
33  **---------------------------------------------------------------------------*/
34 #ifdef __cplusplus
35 extern   "C"
36 {
37 #endif
38
39 //error code define
40 //TV size .
41 #define TV_WIDTH    360
42 #define TV_HEIGHT   288
43 typedef enum
44 {
45     LCD_ROT_MODE_LCD = 0x00,
46     LCD_ROT_MODE_DMA,
47
48     LCD_ROT_MODE_MAX
49
50 }
51 LCD_ROT_MODE_E;
52
53 typedef enum
54 {
55     ERR_LCD_NONE = 0,       // Success,no error
56     ERR_LCD_FUNC_NOT_SUPPORT,       // LCD not support this function
57     ERR_LCD_PARAMETER_WRONG,        // Parameter is wrong
58     ERR_LCD_POINTER_NULL,           // Input pointer is PNULL
59     ERR_LCD_OPERATE_FAIL,           // Operate fail
60     ERR_LCD_NOT_FOUND,              // LCD not found
61     ERR_LCD_SELPIN_WRONG,           // LCD SELPIN WRONG
62     ERR_LCD_SPEC_WRONG              // LCD SPEC WRONG
63 } ERR_LCD_E;
64
65 typedef enum
66 {
67     CMD_LEVEL   = 0,                //command:0, data:1. nomal
68     DATA_LEVEL  = 1             //command:1, data:0.
69 } LCD_CD_LEVEL_E;
70
71 typedef enum
72 {
73     LCD_RGB = 0,
74     LCD_MCU
75 } LCD_MODE_T;
76
77
78 typedef enum
79 {
80     BUS_MODE_8080   = 0,
81     BUS_MODE_6800 ,
82     BUS_MODE_SPI
83 } LCD_BUS_MODE_T;
84
85 typedef enum
86 {
87     WIDTH_16  =0,
88     WIDTH_18 ,
89     WIDTH_8  ,
90     WIDTH_9
91 } LCD_BUS_WIDTH_T;
92
93 // LCD Contrller type
94 typedef enum
95 {
96     LCD_CTRL_MODULE_LCDC = 0   ,    //LCDC
97     LCD_CTRL_MODULE_LCM        ,    //LCM
98     LCD_CTRL_MODULE_LCDC_LCM0,      //LCDC+LCM0
99     LCD_CTRL_MODULE_EMC
100 } LCD_CTRL_MODULE_E;
101
102
103 typedef enum
104 {
105     LCD_ANGLE_0   ,
106     LCD_ANGLE_90  ,
107     LCD_ANGLE_180 ,
108     LCD_ANGLE_270
109 } LCD_ANGLE_E;
110
111 typedef enum
112 {
113     LCD_DIRECT_NORMAL = 0x00,
114     LCD_DIRECT_ROT_90,      // Rotation 90
115     LCD_DIRECT_ROT_180,     // Rotation 180
116     LCD_DIRECT_ROT_270,     // Rotation 270
117     LCD_DIRECT_MIR_H,       // Mirror horizontal
118     LCD_DIRECT_MIR_V,       // Mirror vertical
119     LCD_DIRECT_MIR_HV,      // Mirror horizontal and vertical
120
121     LCD_DIRECT_MAX
122
123 } LCD_DIRECT_E;
124
125 typedef enum
126 {
127     LCD_ID_0 = 0,
128     LCD_ID_1    ,
129     LCD_ID_2    ,
130     LCD_ID_3    ,
131     LCD_ID_4    ,
132     LCD_ID_5    ,
133     LCD_ID_6    ,
134     LCD_ID_7    ,
135     TV_ID       ,                   //be used for TVOUT
136     MAX_LCD_ID                      //Reserved, can not be used by user.
137 } LCD_ID_E;
138
139 /**---------------------------------------------------------------------------*
140  **                         Struct defines.
141  **---------------------------------------------------------------------------*/
142
143
144 // lcd information struct, which will be useful for upper layer.
145 typedef union _LCD_TIMING_U
146 {
147     struct RGB_LCD_TIMING_tag
148     {
149         uint16 bfw;    //Beginning-of-Frame Horizontal Sync Clock Wait Count-1
150         uint16 efw;    //End-of-Frame Horizontal Sync Clock Wait Count-1
151         uint16 vsw;    //Vertical Sync Pulse Width - 1
152         uint16 blw;    //Beginning-of-Line Pixel Clock Wait Count -1
153         uint16 elw;    //End-of-Line Pixel Clock Wait Count -1
154         uint16 hsw;    //Horizontal Sync Pulse Width - 1
155     } rgb_mode_timing;
156     struct MCU_LCD_TIMING_tag
157     {
158         uint16 rcss;// CS setup time for LCM read (optional)
159         uint16 rlpw;// low pulse width for LCM read (according spec)
160         uint16 rhpw;// high pulse width for LCM read (according spec)
161         uint16 wcss;// CS setup time for LCM write  (optional)
162         uint16 wlpw;// low pulse width for LCM write (according spec)
163         uint16 whpw;// high pulse width for LCM write (according spec)
164     } mcu_mode_timing;
165 } LCD_TIMING_U;
166
167
168
169 typedef struct lcd_operations_tag
170 {
171     ERR_LCD_E (*lcd_Init) (void);
172     ERR_LCD_E (*lcd_EnterSleep) (BOOLEAN is_sleep);
173     ERR_LCD_E (*lcd_SetContrast) (uint16 contrast);
174     ERR_LCD_E (*lcd_SetBrightness) (uint16 brightness);
175     ERR_LCD_E (*lcd_SetDisplayWindow) (uint16 left, uint16 top, uint16 right, uint16 bottom);
176     ERR_LCD_E (*lcd_InvalidateRect) (uint16 left, uint16 top, uint16 right, uint16 bottom);
177     ERR_LCD_E (*lcd_Invalidate) (void);
178     void (*lcd_Close) (void);
179     ERR_LCD_E (*lcd_RotationInvalidateRect) (uint16 left, uint16 top, uint16 right, uint16 bottom, LCD_ANGLE_E angle);
180     ERR_LCD_E (*lcd_SetBrushDirection) (LCD_DIRECT_E direct_type);
181     void (*lcd_Rst) (void);
182 } LCD_OPERATIONS_T;
183
184 typedef struct lcd_spec_tag
185 {
186     uint32                  width;
187     uint32                  height;
188     LCD_MODE_T          mode;       // rgb or mcu
189     LCD_BUS_MODE_T        bus_mode;
190     LCD_BUS_WIDTH_T      bus_width;
191     LCD_TIMING_U           *timing;         // lcd read/write timing parameter
192     LCD_OPERATIONS_T   *operation;
193 } LCD_SPEC_T, *LCD_SPEC_T_PTR;
194
195 typedef struct
196 {
197     uint16                      cs_pin;                // cs pin connected with LCM
198     uint16                      cd_pin;               // cd pin connected with LCM
199     LCD_CTRL_MODULE_E                 controller;
200     LCD_SPEC_T_PTR                       spec_ptr;
201 } LCD_SPEC_INFO_T,*LCD_SPEC_INFO_T_PTR;
202
203 typedef struct _lcd_simple_init_param_tag
204 {
205     uint32 lcd_id;
206     uint32 cs_id;
207     uint32 interface_type;  // 0: 8080;1: 6800
208     uint32 cd_pol;
209     uint32 lcd_bits;//0£º16bit ;1£º18bit;2: 8bit;3: 9bit
210     LCD_TIMING_U timing;
211     LCD_CTRL_MODULE_E controller;
212 } LCD_SIMPLE_INIT_PARAM_T;
213 /**---------------------------------------------------------------------------*
214  **                         Function Prototypes
215  **---------------------------------------------------------------------------*/
216
217 /******************************************************************************/
218 //  Description:  return the lcd driver funtion pointer
219 //  Global resource dependence:
220 //  Author: Jim.zhang
221 //  Note:
222 /******************************************************************************/
223 PUBLIC LCD_OPERATIONS_T **LCD_GetOperations (void);
224
225 /******************************************************************************/
226 //  Description:  return the sub lcd buffer pointer
227 //  Global resource dependence:
228 //  Author: Jim.zhang
229 //  Note:
230 /******************************************************************************/
231 PUBLIC void *LCD_GetSubLCDBuffer (void);
232
233 /******************************************************************************/
234 //  Description:  return the main lcd buffer  pointer
235 //  Global resource dependence:
236 //  Author: Jim.zhang
237 //  Note:
238 /******************************************************************************/
239 PUBLIC void *LCD_GetLCDBuffer (void);
240
241 /******************************************************************************/
242 //  Description:  let the main lcd display on to display assert information
243 //  Global resource dependence:
244 //  Author: Jim.zhang
245 //  Note:
246 /******************************************************************************/
247 PUBLIC void LCD_DisplayOn (void);
248
249 /*****************************************************************************/
250 //  Description:  Get LCD number int the system.
251 //    Global resource dependence:
252 //  Author: Younger.Yang
253 //    Note:
254 /*****************************************************************************/
255 PUBLIC uint32 LCD_GetUsedNum (void);
256
257 /*******************************************************************************/
258 // Description:
259 // Global resource dependence:
260 // Author: Younger.yang
261 // Note:
262 /********************************************************************************/
263 PUBLIC uint32 LCD_GetBusRatio (void);
264 /*******************************************************************************/
265 // Description:
266 // Global resource dependence:
267 // Author: Ming.zhang & Younger.yang
268 // Note:
269 /********************************************************************************/
270
271 PUBLIC void LCD_Wait (uint32 ms);
272
273 /*********************************************************************/
274 //  Description:   Read LCD ID
275 //  Global resource dependence:
276 //  Author: Younger.Yang
277 //  Note: You may read LCD ID before lcd init,otherwise
278 //  the read data may be incorrect.
279 /*********************************************************************/
280 PUBLIC uint32 LCD_Read_ID (uint32 lcd_cs, uint32 lcd_cd);
281
282
283 /*****************************************************************************/
284 //  Description:  LCD Reg Info
285 //    Global resource dependence:
286 //  Author: Younger.Yang
287 //    Note:
288 /*****************************************************************************/
289
290 PUBLIC void LCD_RegInfo (LCD_ID_E lcd_id, LCD_SPEC_INFO_T_PTR lcd_spec_ptr);
291
292 /*****************************************************************************/
293 //  Description:  clear the whole lcd to one color.
294 //    Global resource dependence:
295 //  Author: Jim.zhang
296 //    Note:
297 /*****************************************************************************/
298 PUBLIC void LCD_Clear (
299     LCD_ID_E lcd_id,     //id of lcd to operate.
300     uint32 color        //color to fill the whole lcd.
301 );
302
303 /**********************************************************************************************************/
304 // Description: send command to lcd
305 // Global resource dependence: g_lcdc_mode
306 // Author: Jianping.wang
307 // Note:
308 //      lcd_id parameter is used when lcdc mcu mode
309 //      input:
310 //          cmd - lcd command
311 //          lcd_id - LCD ID
312 //      return:
313 //          LCD_OK,if success
314 //          other,if fail
315 /**********************************************************************************************************/
316 PUBLIC int32 LCD_SendCmd (uint32 cmd,uint32 lcd_id);
317
318 /**********************************************************************************************************/
319 // Description: send display data to LCD
320 // Global resource dependence: g_lcdc_mode
321 // Author: Jianping.wang
322 // Note:
323 //      this interface is used in lcdc mcu mode
324 //      input:
325 //          lcd_data - display data
326 //          lcd_id - LCD ID
327 //      return:
328 //          LCD_OK,if success
329 //          other,if fail
330 /**********************************************************************************************************/
331 PUBLIC int32 LCD_SendData (uint32 lcd_data,uint32 lcd_id);
332
333 /**********************************************************************************************************/
334 // Description: send the command and data to LCD
335 // Global resource dependence: g_lcdc_mode
336 // Author: Jianping.wang
337 // Note:
338 //      input:
339 //          cmd - lcd command
340 //          lcd_data - lcd command data
341 //          lcd_id - only is used for lcdc mcu mode
342 //      return:
343 //          LCD_OK,if success
344 //          other,if fail
345 /**********************************************************************************************************/
346 PUBLIC int32 LCD_SendCmdData (uint32 cmd,uint32 lcd_data,uint32 lcd_id);
347
348 /**********************************************************************************************************/
349 // Description:Read data from lcm
350 // Global resource dependence: NONE
351 // Author: Younger.yang
352 // Note:
353 //      this interface is read data from lcm
354 //      input:
355 //            index_value - cd value
356 //                  lcd_id-MAIN_LCD_ID/SUB_LCD_ID
357 //      return:
358 //          LCD_OK,if success
359 //          other,if fail
360 /**********************************************************************************************************/
361 PUBLIC uint32 LCD_ReadRegVal (uint32 lcd_id,uint32 reg_addr);
362
363
364 /*****************************************************************************/
365 //  Description:  Set LCD invalidate direction
366 //  Input:
367 //      lcd_id,lcd_angle
368 //  Return:
369 //      None.
370 //  Note: Application should correct invalidate direction right after current
371 //        image displayed
372 //  Author: Younger.Yang
373 //    Note:
374 /*****************************************************************************/
375
376 PUBLIC ERR_LCD_E  LCD_SetDirection (
377     LCD_ID_E lcd_id,//ID of lcd to operate
378     LCD_DIRECT_E     direct_type
379 );
380
381 /*****************************************************************************/
382 //  Description:    LCD delay
383 //  Global resource dependence:
384 //  Author:
385 //  Note:
386 /*****************************************************************************/
387 PUBLIC void LCD_Delayms (uint32 ms);
388
389
390 PUBLIC ERR_LCD_E LCD_Init (void);
391 /**********************************************************************************************************/
392 // Description:Read data from lcm
393 // Global resource dependence: NONE
394 // Author: Jianping.Wang
395 // Note:
396 //      this interface is read data from lcm
397 //      input:
398 //            param_ptr - parameter pointer
399 //      return:
400 //          ERR_LCD_NONE,if success
401 //          other,if fail
402 /**********************************************************************************************************/
403 PUBLIC ERR_LCD_E LCD_SimpleInit (LCD_SIMPLE_INIT_PARAM_T *param_ptr);
404 #if defined(PLATFORM_SC6800H) || defined(PLATFORM_SC8800G)|| defined(CONFIG_SC8810)
405 /*****************************************************************************/
406 //  Description: config lcd block of 6800h
407 //  Global resource dependence:
408 //  Author: Shan.he
409 //  Note:
410 /*****************************************************************************/
411 PUBLIC ERR_LCD_E LCD_ConfigBlockEx (LCD_ID_E lcd_id, LCD_LAYER_ID_E layer_id,
412                                     void *blk_param_ptr);
413
414
415 /*****************************************************************************/
416 //  Description: config capture parameters of 6800h
417 //  Global resource dependence:
418 //  Author: Jianping.wang
419 //  Note:
420 /*****************************************************************************/
421 //PUBLIC ERR_LCD_E LCD_ConfigCapture(LCD_ID_E lcd_id, LCD_CAP_PARAM_T *param_ptr);
422
423 #endif
424 /**---------------------------------------------------------------------------*
425  **                         Compiler Flag                                     *
426  **---------------------------------------------------------------------------*/
427
428 #ifdef __cplusplus
429 }
430 #endif
431
432 #endif // _LCD_H