From f5e236f400b8af4ae5fa237be684b011d67d41b9 Mon Sep 17 00:00:00 2001 From: yxj Date: Mon, 23 Apr 2012 19:14:21 +0800 Subject: [PATCH] rk30fb: move set_lcd_info to board add rk_disp_info in struct rk29fb_info to distinguish primary display device and extend display device --- arch/arm/mach-rk30/board-rk30-phone.c | 22 ++++++++++--- arch/arm/mach-rk30/board-rk30-sdk.c | 24 ++++++++++++--- arch/arm/mach-rk30/devices.c | 8 +++++ arch/arm/plat-rk/include/plat/board.h | 12 +++----- drivers/video/rockchip/chips/rk30_lcdc.c | 7 +++-- drivers/video/rockchip/hdmi/rk30_hdmi.h | 3 +- drivers/video/rockchip/rk_fb.c | 39 +++++++++++++----------- drivers/video/rockchip/rkfb_sysfs.c | 2 +- include/linux/rk_fb.h | 2 +- include/linux/rk_screen.h | 14 ++++++++- 10 files changed, 93 insertions(+), 40 deletions(-) diff --git a/arch/arm/mach-rk30/board-rk30-phone.c b/arch/arm/mach-rk30/board-rk30-phone.c index 25257fdff646..5188ed38e0a4 100755 --- a/arch/arm/mach-rk30/board-rk30-phone.c +++ b/arch/arm/mach-rk30/board-rk30-phone.c @@ -41,6 +41,10 @@ #include #include #include +#include +#if defined(CONFIG_HDMI_RK30) + #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h" +#endif #include #include @@ -1169,14 +1173,27 @@ static int rk_fb_io_enable(void) } -static struct rk29fb_info rk_fb_info = { +#if defined(CONFIG_LCDC0_RK30) +struct rk29fb_info lcdc0_screen_info = { .fb_id = FB_ID, + .prop = PRMRY, .mcu_fmk_pin = FB_MCU_FMK_PIN, .lcd_info = &rk29_lcd_info, .io_init = rk_fb_io_init, .io_disable = rk_fb_io_disable, .io_enable = rk_fb_io_enable, + .set_screen_info = set_lcd_info, +}; +#endif +#if defined(CONFIG_LCDC1_RK30) +struct rk29fb_info lcdc1_screen_info = { + #if defined(CONFIG_HDMI_RK30) + .prop = EXTEND, + .lcd_info = NULL, + .set_screen_info = hdmi_set_info, + #endif }; +#endif static struct resource resource_fb[] = { [0] = { @@ -1204,9 +1221,6 @@ static struct platform_device device_fb = { .id = -1, .num_resources = ARRAY_SIZE(resource_fb), .resource = resource_fb, - .dev = { - .platform_data = &rk_fb_info, - } }; #endif diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index d633e70f96ae..b1986841a479 100644 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -40,6 +40,10 @@ #include #include #include +#include +#if defined(CONFIG_HDMI_RK30) + #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h" +#endif #if defined(CONFIG_SPIM_RK29) #include "../../../drivers/spi/rk29_spim.h" @@ -796,12 +800,25 @@ static int rk_fb_io_enable(void) return 0; } - -static struct rk29fb_info rk_fb_info = { +#if defined(CONFIG_LCDC0_RK30) +struct rk29fb_info lcdc0_screen_info = { + .prop = PRMRY, //primary display device .io_init = rk_fb_io_init, .io_disable = rk_fb_io_disable, .io_enable = rk_fb_io_enable, + .set_screen_info = set_lcd_info, +}; +#endif + +#if defined(CONFIG_LCDC1_RK30) +struct rk29fb_info lcdc1_screen_info = { + #if defined(CONFIG_HDMI_RK30) + .prop = EXTEND, //extend display device + .lcd_info = NULL, + .set_screen_info = hdmi_set_info, + #endif }; +#endif static struct resource resource_fb[] = { [0] = { @@ -829,9 +846,6 @@ static struct platform_device device_fb = { .id = -1, .num_resources = ARRAY_SIZE(resource_fb), .resource = resource_fb, - .dev = { - .platform_data = &rk_fb_info, - } }; #endif diff --git a/arch/arm/mach-rk30/devices.c b/arch/arm/mach-rk30/devices.c index c0bde30d7651..57937c0976d8 100755 --- a/arch/arm/mach-rk30/devices.c +++ b/arch/arm/mach-rk30/devices.c @@ -748,6 +748,7 @@ static struct platform_device device_nand = { #endif #ifdef CONFIG_LCDC0_RK30 +extern struct rk29fb_info lcdc0_screen_info; static struct resource resource_lcdc0[] = { [0] = { .name = "lcdc0 reg", @@ -769,9 +770,13 @@ static struct platform_device device_lcdc0 = { .id = 0, .num_resources = ARRAY_SIZE(resource_lcdc0), .resource = resource_lcdc0, + .dev = { + .platform_data = &lcdc0_screen_info, + }, }; #endif #ifdef CONFIG_LCDC1_RK30 +extern struct rk29fb_info lcdc1_screen_info; static struct resource resource_lcdc1[] = { [0] = { .name = "lcdc1 reg", @@ -792,6 +797,9 @@ static struct platform_device device_lcdc1 = { .id = 1, .num_resources = ARRAY_SIZE(resource_lcdc1), .resource = resource_lcdc1, + .dev = { + .platform_data = &lcdc1_screen_info, + }, }; #endif diff --git a/arch/arm/plat-rk/include/plat/board.h b/arch/arm/plat-rk/include/plat/board.h index bb34d0ba5a99..5d69a91e1932 100755 --- a/arch/arm/plat-rk/include/plat/board.h +++ b/arch/arm/plat-rk/include/plat/board.h @@ -4,6 +4,7 @@ #include #include #include +#include struct spi_cs_gpio { const char *name; @@ -39,14 +40,7 @@ struct rk29_io_t { int (*io_init)(void); }; -struct rk29lcd_info { - u32 lcd_id; - u32 txd_pin; - u32 clk_pin; - u32 cs_pin; - int (*io_init)(void); - int (*io_deinit)(void); -}; + struct rk29_fb_setting_info { u8 data_num; @@ -59,12 +53,14 @@ struct rk29_fb_setting_info { struct rk29fb_info { u32 fb_id; + enum rk_disp_prop prop; //display device property,like PRMRY,EXTEND u32 mcu_fmk_pin; struct rk29lcd_info *lcd_info; int (*io_init)(struct rk29_fb_setting_info *fb_setting); int (*io_deinit)(void); int (*io_enable)(void); int (*io_disable)(void); + void (*set_screen_info)(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info ); }; struct rk29_sdmmc_platform_data { diff --git a/drivers/video/rockchip/chips/rk30_lcdc.c b/drivers/video/rockchip/chips/rk30_lcdc.c index 2ad128f2dd94..f845a761fed0 100644 --- a/drivers/video/rockchip/chips/rk30_lcdc.c +++ b/drivers/video/rockchip/chips/rk30_lcdc.c @@ -683,6 +683,7 @@ static int __devinit rk30_lcdc_probe (struct platform_device *pdev) { struct rk30_lcdc_device *lcdc_dev=NULL; rk_screen *screen; + struct rk29fb_info *screen_ctr_info; struct resource *res = NULL; struct resource *mem; int ret = 0; @@ -696,6 +697,7 @@ static int __devinit rk30_lcdc_probe (struct platform_device *pdev) } platform_set_drvdata(pdev, lcdc_dev); lcdc_dev->id = pdev->id; + screen_ctr_info = (struct rk29fb_info * )pdev->dev.platform_data; screen = kzalloc(sizeof(rk_screen), GFP_KERNEL); if(!screen) { @@ -736,6 +738,7 @@ static int __devinit rk30_lcdc_probe (struct platform_device *pdev) printk("lcdc%d:reg_phy_base = 0x%08x,reg_vir_base:0x%p\n",pdev->id,lcdc_dev->reg_phy_base, lcdc_dev->preg); lcdc_dev->driver.dev=&pdev->dev; lcdc_dev->driver.screen = screen; + lcdc_dev->driver.screen_ctr_info = screen_ctr_info; spin_lock_init(&lcdc_dev->reg_lock); lcdc_dev->irq = platform_get_irq(pdev, 0); if(lcdc_dev->irq < 0) @@ -753,7 +756,7 @@ static int __devinit rk30_lcdc_probe (struct platform_device *pdev) ret = rk_fb_register(&(lcdc_dev->driver),&lcdc_driver,lcdc_dev->id); if(ret < 0) { - printk(KERN_ERR "registe fb for lcdc0 failed!\n"); + printk(KERN_ERR "register fb for lcdc%d failed!\n",lcdc_dev->id); goto err4; } printk("rk30 lcdc%d probe ok!\n",lcdc_dev->id); @@ -761,7 +764,7 @@ static int __devinit rk30_lcdc_probe (struct platform_device *pdev) return 0; err4: - free_irq(lcdc_dev->irq, pdev); + free_irq(lcdc_dev->irq,lcdc_dev); err3: iounmap(lcdc_dev->reg_vir_base); err2: diff --git a/drivers/video/rockchip/hdmi/rk30_hdmi.h b/drivers/video/rockchip/hdmi/rk30_hdmi.h index 6852d936ab07..c54a63d48644 100755 --- a/drivers/video/rockchip/hdmi/rk30_hdmi.h +++ b/drivers/video/rockchip/hdmi/rk30_hdmi.h @@ -11,7 +11,8 @@ #include #endif -#include "../../display/screen/screen.h" +//#include "../../display/screen/screen.h" +#include #include #include "rk_hdmi.h" diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index ccbdcc17745e..9a55b68fbd3a 100644 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -649,13 +649,18 @@ void rk_fb_switch_screen(rk_screen *screen ,int enable ,int lcdc_id) { info = inf->fb[2] ; } - pmy_var = &inf->fb[0]->var; - pmy_fix = &inf->fb[0]->fix; + hdmi_var = &info->var; hdmi_fix = &info->fix; - hdmi_var->xres = pmy_var->xres; - hdmi_var->yres = pmy_var->yres; - hdmi_var->nonstd = pmy_var->nonstd; + #if defined(CONFIG_DUAL_DISP_IN_KERNEL) + pmy_var = &inf->fb[0]->var; + pmy_fix = &inf->fb[0]->fix; + hdmi_var->xres = pmy_var->xres; + hdmi_var->yres = pmy_var->yres; + hdmi_var->xres_virtual = pmy_var->xres_virtual; + hdmi_var->yres_virtual = pmy_var->yres_virtual; + hdmi_var->nonstd = pmy_var->nonstd; + #endif //hdmi_fix->smem_start = pmy_fix->smem_start; dev_drv = (struct rk_lcdc_device_driver * )info->par; ret = dev_drv->load_screen(dev_drv,1); @@ -828,15 +833,17 @@ int rk_fb_register(struct rk_lcdc_device_driver *dev_drv, } lcdc_id = i; init_lcdc_device_driver(dev_drv, def_drv,id); - if(id == 0) //default use lcdc0 as primary dispaly controller + if(dev_drv->screen_ctr_info->set_screen_info) { - set_lcd_info(dev_drv->screen, fb_inf->mach_info->lcd_info); + dev_drv->screen_ctr_info->set_screen_info(dev_drv->screen, + dev_drv->screen_ctr_info->lcd_info); + if(dev_drv->screen_ctr_info->io_init) + dev_drv->screen_ctr_info->io_init(NULL); } - else if(id == 1) + else { - memcpy(dev_drv->screen,fb_inf->lcdc_dev_drv[0]->screen,sizeof(rk_screen)); - dev_drv->screen->init = NULL; - dev_drv->screen->standby = NULL; + printk(KERN_WARNING "no display device on lcdc%d!?\n",dev_drv->id); + return -ENODEV; } dev_drv->init_lcdc(dev_drv); @@ -948,10 +955,11 @@ static void rkfb_early_suspend(struct early_suspend *h) early_suspend); struct rk_fb_inf *inf = info->inf; int i; - inf->mach_info->io_disable(); for(i = 0; i < inf->num_lcdc; i++) { atomic_set(&inf->lcdc_dev_drv[i]->in_suspend,1); + if(inf->lcdc_dev_drv[i]->screen_ctr_info->io_disable) + inf->lcdc_dev_drv[i]->screen_ctr_info->io_disable(); if(inf->lcdc_dev_drv[i]->screen->standby) inf->lcdc_dev_drv[i]->screen->standby(1); @@ -964,9 +972,10 @@ static void rkfb_early_resume(struct early_suspend *h) early_suspend); struct rk_fb_inf *inf = info->inf; int i; - inf->mach_info->io_enable(); for(i = 0; i < inf->num_lcdc; i++) { + if(inf->lcdc_dev_drv[i]->screen_ctr_info->io_enable) + inf->lcdc_dev_drv[i]->screen_ctr_info->io_enable(); if(inf->lcdc_dev_drv[i]->screen->standby) inf->lcdc_dev_drv[i]->screen->standby(0); @@ -999,10 +1008,6 @@ static int __devinit rk_fb_probe (struct platform_device *pdev) ret = -ENOMEM; } platform_set_drvdata(pdev,fb_inf); - mach_info = pdev->dev.platform_data; - fb_inf->mach_info = mach_info; - if(mach_info->io_init) - mach_info->io_init(NULL); #if defined(CONFIG_HDMI_RK30) #if defined(CONFIG_DUAL_DISP_IN_KERNEL) fb_inf->workqueue = create_singlethread_workqueue("hdmi_post"); diff --git a/drivers/video/rockchip/rkfb_sysfs.c b/drivers/video/rockchip/rkfb_sysfs.c index 915ab77538f6..ed73d4366da6 100644 --- a/drivers/video/rockchip/rkfb_sysfs.c +++ b/drivers/video/rockchip/rkfb_sysfs.c @@ -30,7 +30,7 @@ #include #include #include -#include "../display/screen/screen.h" +#include #include diff --git a/include/linux/rk_fb.h b/include/linux/rk_fb.h index 72d6c2a261bf..982951707bed 100644 --- a/include/linux/rk_fb.h +++ b/include/linux/rk_fb.h @@ -21,7 +21,6 @@ #include #include #include -#include #define RK30_MAX_LCDC_SUPPORT 4 @@ -200,6 +199,7 @@ struct rk_lcdc_device_driver{ atomic_t in_suspend; //when enter suspend write or read lcdc register are forbidden + struct rk29fb_info *screen_ctr_info; int (*open)(struct rk_lcdc_device_driver *dev_drv,int layer_id,bool open); int (*init_lcdc)(struct rk_lcdc_device_driver *dev_drv); int (*ioctl)(struct rk_lcdc_device_driver *dev_drv, unsigned int cmd,unsigned long arg,int layer_id); diff --git a/include/linux/rk_screen.h b/include/linux/rk_screen.h index 5096d7cda698..d6ebe7bcfea2 100644 --- a/include/linux/rk_screen.h +++ b/include/linux/rk_screen.h @@ -1,6 +1,5 @@ #ifndef _SCREEN_H #define _SCREEN_H -#include #ifdef CONFIG_HDMI_DUAL_DISP /* Scaler PLL CONFIG */ @@ -76,6 +75,19 @@ typedef enum _MCU_STATUS { } MCU_STATUS; +enum rk_disp_prop{ //display device property + PRMRY = 0, //primary display device ,like LCD screen + EXTEND, //extend display device ,like hdmi ,tv out +}; + +struct rk29lcd_info { + u32 lcd_id; + u32 txd_pin; + u32 clk_pin; + u32 cs_pin; + int (*io_init)(void); + int (*io_deinit)(void); +}; /* Screen description */ -- 2.34.1