From 45cf62bd9c3d74595969e04c7db7804af9226df9 Mon Sep 17 00:00:00 2001 From: luowei Date: Tue, 9 Oct 2012 20:01:43 +0800 Subject: [PATCH] rk30_phonepad:add auto lcd support --- drivers/video/display/screen/Kconfig | 3 + drivers/video/display/screen/Makefile | 3 +- drivers/video/display/screen/lcd_auto.c | 274 ++++++++++++++++++++++++ 3 files changed, 279 insertions(+), 1 deletion(-) create mode 100644 drivers/video/display/screen/lcd_auto.c diff --git a/drivers/video/display/screen/Kconfig b/drivers/video/display/screen/Kconfig index 4f91721ad150..f482e78ac80a 100755 --- a/drivers/video/display/screen/Kconfig +++ b/drivers/video/display/screen/Kconfig @@ -100,6 +100,9 @@ config LCD_HJ080NA config LCD_HJ101NA bool "HJ101NA_4J 1280X800" +config LCD_AUTO + bool "auto select lcd" + config LCD_HSD07PFW1 depends on MFD_RK610 bool "RGB lcd panel HSD07PFW1" diff --git a/drivers/video/display/screen/Makefile b/drivers/video/display/screen/Makefile index 553a45d80e1e..43e3c71dc5d6 100755 --- a/drivers/video/display/screen/Makefile +++ b/drivers/video/display/screen/Makefile @@ -43,7 +43,8 @@ obj-$(CONFIG_LCD_HSD100PXN_FOR_TDW851) += lcd_hsd100pxn_for_tdw851.o obj-$(CONFIG_LCD_HV070WSA100) += lcd_hv070wsa.o obj-$(CONFIG_LCD_COMMON) += lcd_common.o obj-$(CONFIG_LCD_RK2928_A720) += lcd_YQ70CPT9160.o -obj-$(CONFIG_LCD_HSD07PFW1) += lcd_hsd07pfw1.o +obj-$(CONFIG_LCD_HSD07PFW1) += lcd_hsd07pfw1.o obj-$(CONFIG_LCD_HJ080NA) += lcd_hj080na.o obj-$(CONFIG_LCD_HJ101NA) += lcd_hj101na.o +obj-$(CONFIG_LCD_AUTO) += lcd_auto.o obj-$(CONFIG_LCD_I30_800X480) += lcd_I30_800x480.o diff --git a/drivers/video/display/screen/lcd_auto.c b/drivers/video/display/screen/lcd_auto.c new file mode 100644 index 000000000000..dfec50c830bd --- /dev/null +++ b/drivers/video/display/screen/lcd_auto.c @@ -0,0 +1,274 @@ +#include +#include +#include "../../rk29_fb.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_HAS_EARLYSUSPEND +#include +#endif +#include +#include "screen.h" + + +//FOR ID0 +/* Base */ +#define OUT_TYPE_ID0 SCREEN_RGB + +#define OUT_FACE_ID0 OUT_P888 +#define OUT_CLK_ID0 50000000 +#define LCDC_ACLK_ID0 500000000 + +/* Timing */ +#define H_PW_ID0 100 +#define H_BP_ID0 100 +#define H_VD_ID0 1024 +#define H_FP_ID0 120 + +#define V_PW_ID0 10 +#define V_BP_ID0 10 +#define V_VD_ID0 600 +#define V_FP_ID0 15 + +#define LCD_WIDTH_ID0 202 +#define LCD_HEIGHT_ID0 152 +/* Other */ +#define DCLK_POL_ID0 0 +#define SWAP_RB_ID0 0 + +//FOR ID2 +#define OUT_TYPE_ID2 SCREEN_RGB + +#define OUT_FACE_ID2 OUT_P888 +#define OUT_CLK_ID2 65000000 +#define LCDC_ACLK_ID2 500000000 + +/* Timing */ +#define H_PW_ID2 100 +#define H_BP_ID2 100 +#define H_VD_ID2 1024 +#define H_FP_ID2 120 + +#define V_PW_ID2 10 +#define V_BP_ID2 10 +#define V_VD_ID2 768 +#define V_FP_ID2 15 + +#define LCD_WIDTH_ID2 216 +#define LCD_HEIGHT_ID2 162 +/* Other */ +#define DCLK_POL_ID2 0 +#define SWAP_RB_ID2 0 + +//FOR ID2 +/* Base */ +#define OUT_TYPE_ID3 SCREEN_RGB +#define OUT_FACE_ID3 OUT_P888 +#define OUT_CLK_ID3 71000000 +#define LCDC_ACLK_ID3 500000000 + +/* Timing */ +#define H_PW_ID3 10 +#define H_BP_ID3 160 +#define H_VD_ID3 1280 +#define H_FP_ID3 16 + +#define V_PW_ID3 3 +#define V_BP_ID3 23 +#define V_VD_ID3 800 +#define V_FP_ID3 12 + + +/* Other */ +#define DCLK_POL_ID3 0 +#define SWAP_RB_ID3 0 + +#define LCD_WIDTH_ID3 270 +#define LCD_HEIGHT_ID3 202 + + +extern struct ts_private_data *g_ts; +extern int rk_get_board_id(void); + +static int lcd_get_id(void) +{ + int id = -1; +#if 0 + id = rk_get_board_id(); + +#else + struct ts_max_pixel pixel; + + if(!g_ts) + return -1; + + pixel = g_ts->ops->pixel; + if((pixel.max_x == 1024)&&(pixel.max_y == 600)) + id = 0; + else if((pixel.max_x == 1024)&&(pixel.max_y == 768)) + id = 2; + else if((pixel.max_x == 1280)&&(pixel.max_y == 800)) + id = 3; +#endif + return id; +} + + +void set_lcd_info(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info ) +{ + int id; + id = lcd_get_id(); + + switch(id) + { + case 0: + + /* screen type & face */ + screen->type = OUT_TYPE_ID0; + screen->face = OUT_FACE_ID0; + + /* Screen size */ + screen->x_res = H_VD_ID0; + screen->y_res = V_VD_ID0; + + screen->width = LCD_WIDTH_ID0; + screen->height = LCD_HEIGHT_ID0; + + /* Timing */ + screen->lcdc_aclk = LCDC_ACLK_ID0; + screen->pixclock = OUT_CLK_ID0; + screen->left_margin = H_BP_ID0; + screen->right_margin = H_FP_ID0; + screen->hsync_len = H_PW_ID0; + screen->upper_margin = V_BP_ID0; + screen->lower_margin = V_FP_ID0; + screen->vsync_len = V_PW_ID0; + + /* Pin polarity */ + screen->pin_hsync = 0; + screen->pin_vsync = 0; + screen->pin_den = 0; + screen->pin_dclk = DCLK_POL_ID0; + + /* Swap rule */ + screen->swap_rb = SWAP_RB_ID0; + screen->swap_rg = 0; + screen->swap_gb = 0; + screen->swap_delta = 0; + screen->swap_dumy = 0; + + /* Operation function*/ + screen->init = NULL; + screen->standby = NULL; + + break; + + case 2: + + /* screen type & face */ + screen->type = OUT_TYPE_ID2; + screen->face = OUT_FACE_ID2; + + /* Screen size */ + screen->x_res = H_VD_ID2; + screen->y_res = V_VD_ID2; + + screen->width = LCD_WIDTH_ID2; + screen->height = LCD_HEIGHT_ID2; + + /* Timing */ + screen->lcdc_aclk = LCDC_ACLK_ID2; + screen->pixclock = OUT_CLK_ID2; + screen->left_margin = H_BP_ID2; + screen->right_margin = H_FP_ID2; + screen->hsync_len = H_PW_ID2; + screen->upper_margin = V_BP_ID2; + screen->lower_margin = V_FP_ID2; + screen->vsync_len = V_PW_ID2; + + /* Pin polarity */ + screen->pin_hsync = 0; + screen->pin_vsync = 0; + screen->pin_den = 0; + screen->pin_dclk = DCLK_POL_ID2; + + /* Swap rule */ + screen->swap_rb = SWAP_RB_ID2; + screen->swap_rg = 0; + screen->swap_gb = 0; + screen->swap_delta = 0; + screen->swap_dumy = 0; + + /* Operation function*/ + screen->init = NULL; + screen->standby = NULL; + + break; + + case 3: + default: + + /* screen type & face */ + screen->type = OUT_TYPE_ID3; + screen->face = OUT_FACE_ID3; + + /* Screen size */ + screen->x_res = H_VD_ID3; + screen->y_res = V_VD_ID3; + + screen->width = LCD_WIDTH_ID3; + screen->height = LCD_HEIGHT_ID3; + + /* Timing */ + screen->lcdc_aclk = LCDC_ACLK_ID3; + screen->pixclock = OUT_CLK_ID3; + screen->left_margin = H_BP_ID3; + screen->right_margin = H_FP_ID3; + screen->hsync_len = H_PW_ID3; + screen->upper_margin = V_BP_ID3; + screen->lower_margin = V_FP_ID3; + screen->vsync_len = V_PW_ID3; + + /* Pin polarity */ + screen->pin_hsync = 0; + screen->pin_vsync = 0; + screen->pin_den = 0; + screen->pin_dclk = DCLK_POL_ID3; + + /* Swap rule */ + screen->swap_rb = SWAP_RB_ID3; + screen->swap_rg = 0; + screen->swap_gb = 0; + screen->swap_delta = 0; + screen->swap_dumy = 0; + + /* Operation function*/ + screen->init = NULL; + screen->standby = NULL; + + break; + + } + + + printk("%s:board_id=%d\n",__func__,id); + +} + + + -- 2.34.1