From 87d1cf42e90e6b29c7b117325a4ec3ed85793a15 Mon Sep 17 00:00:00 2001 From: zyw Date: Mon, 13 Dec 2010 12:42:51 +0800 Subject: [PATCH] modify fb win1 buf alloc --- arch/arm/mach-rk29/board-rk29sdk.c | 39 +++++++++++++++++++- arch/arm/mach-rk29/devices.c | 27 -------------- drivers/video/rk29_fb.c | 57 +++++++++++------------------- 3 files changed, 59 insertions(+), 64 deletions(-) diff --git a/arch/arm/mach-rk29/board-rk29sdk.c b/arch/arm/mach-rk29/board-rk29sdk.c index af60e0c6004f..7169de7eed16 100755 --- a/arch/arm/mach-rk29/board-rk29sdk.c +++ b/arch/arm/mach-rk29/board-rk29sdk.c @@ -61,12 +61,14 @@ #define PMEM_UI_SIZE SZ_32M #define PMEM_VPU_SIZE SZ_32M #define PMEM_CAM_SIZE SZ_16M +#define MEM_FB_SIZE SZ_4M #define PMEM_GPU_BASE ((u32)RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE) #define PMEM_UI_BASE (PMEM_GPU_BASE - PMEM_UI_SIZE) #define PMEM_VPU_BASE (PMEM_UI_BASE - PMEM_VPU_SIZE) #define PMEM_CAM_BASE (PMEM_VPU_BASE - PMEM_CAM_SIZE) -#define LINUX_SIZE (PMEM_CAM_BASE - RK29_SDRAM_PHYS) +#define MEM_FB_BASE (PMEM_CAM_BASE - MEM_FB_SIZE) +#define LINUX_SIZE (MEM_FB_BASE - RK29_SDRAM_PHYS) extern struct sys_timer rk29_timer; @@ -113,6 +115,7 @@ static struct rk29_gpio_bank rk29_gpiobankinit[] = { }, }; +#ifdef CONFIG_FB_RK29 /***************************************************************************************** * lcd devices * author: zyw@rock-chips.com @@ -215,6 +218,40 @@ struct rk29fb_info rk29_fb_info = { .io_init = rk29_fb_io_init, }; +/* rk29 fb resource */ +struct resource rk29_fb_resource[] = { + [0] = { + .name = "lcdc reg", + .start = RK29_LCDC_PHYS, + .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1, + .flags = IORESOURCE_MEM, + }, + [1] = { + .name = "lcdc irq", + .start = IRQ_LCDC, + .end = IRQ_LCDC, + .flags = IORESOURCE_IRQ, + }, + [2] = { + .name = "win1 buf", + .start = MEM_FB_BASE, + .end = MEM_FB_BASE + MEM_FB_SIZE, + .flags = IORESOURCE_MEM, + }, +}; + +/*platform_device*/ +struct platform_device rk29_device_fb = { + .name = "rk29-fb", + .id = 4, + .num_resources = ARRAY_SIZE(rk29_fb_resource), + .resource = rk29_fb_resource, + .dev = { + .platform_data = &rk29_fb_info, + } +}; +#endif + static struct android_pmem_platform_data android_pmem_pdata = { .name = "pmem", .start = PMEM_UI_BASE, diff --git a/arch/arm/mach-rk29/devices.c b/arch/arm/mach-rk29/devices.c index d587c28238e3..412b4fd81f7d 100755 --- a/arch/arm/mach-rk29/devices.c +++ b/arch/arm/mach-rk29/devices.c @@ -408,33 +408,6 @@ struct platform_device rk29_device_camera = { } }; #endif -#ifdef CONFIG_FB_RK29 -/* rk29 fb resource */ -static struct resource rk29_fb_resource[] = { - [0] = { - .start = RK29_LCDC_PHYS, - .end = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_LCDC, - .end = IRQ_LCDC, - .flags = IORESOURCE_IRQ, - }, -}; - -/*platform_device*/ -extern struct rk29fb_info rk29_fb_info; -struct platform_device rk29_device_fb = { - .name = "rk29-fb", - .id = 4, - .num_resources = ARRAY_SIZE(rk29_fb_resource), - .resource = rk29_fb_resource, - .dev = { - .platform_data = &rk29_fb_info, - } -}; -#endif #if defined(CONFIG_MTD_NAND_RK29XX) static struct resource rk29xxnand_resources[] = { diff --git a/drivers/video/rk29_fb.c b/drivers/video/rk29_fb.c index 9835c861b98c..ec855acf2483 100755 --- a/drivers/video/rk29_fb.c +++ b/drivers/video/rk29_fb.c @@ -53,7 +53,6 @@ #include "./display/screen/screen.h" -#define ANDROID_USE_THREE_BUFS 0 //android use three buffers to accelerate UI display in rgb plane #if 0 #define fbprintk(msg...) printk(msg); @@ -191,10 +190,6 @@ static int win1fb_set_par(struct fb_info *info); static DECLARE_WAIT_QUEUE_HEAD(wq); static int wq_condition = 0; -#if ANDROID_USE_THREE_BUFS -static int new_frame_seted = 1; -#endif - void set_lcd_pin(struct platform_device *pdev, int enable) { struct rk29fb_info *mach_info = pdev->dev.platform_data; @@ -425,7 +420,6 @@ void load_screen(struct fb_info *info, bool initscreen) u16 mcu_total, mcu_rwstart, mcu_csstart, mcu_rwend, mcu_csend; u16 right_margin = screen->right_margin, lower_margin = screen->lower_margin; u16 x_res = screen->x_res, y_res = screen->y_res; - u32 clk_rate = 0; u32 aclk_rate = 150000000; if(!g_pdev){ @@ -1319,7 +1313,6 @@ static int win1fb_set_par(struct fb_info *info) struct rk29fb_screen *screen = inf->cur_screen; u8 format = 0; - dma_addr_t map_dma; u32 offset=0, addr=0, map_size=0, smem_len=0; u16 xres_virtual = var->xres_virtual; //virtual screen size @@ -1357,8 +1350,10 @@ static int win1fb_set_par(struct fb_info *info) smem_len = fix->line_length * var->yres_virtual; //cursor buf also alloc here map_size = PAGE_ALIGN(smem_len); - if (smem_len != fix->smem_len) // buffer need realloc + if (smem_len > fix->smem_len) // buffer need realloc { + printk("%s win1 buf \n",__FUNCTION__); + #if 0 fbprintk(">>>>>> win1 buffer size is change(%d->%d)! remap memory!\n",fix->smem_len, smem_len); fbprintk(">>>>>> smem_len %d = %d * %d \n", smem_len, fix->line_length, var->yres_virtual); fbprintk(">>>>>> map_size = %d\n", map_size); @@ -1381,18 +1376,13 @@ static int win1fb_set_par(struct fb_info *info) memset(info->screen_base, 0, map_size); fix->smem_start = map_dma; fix->smem_len = smem_len; + fbprintk(">>>>>> alloc succ, mem=%08x, len=%d!\n", (u32)fix->smem_start, fix->smem_len); + #endif } - addr = fix->smem_start + offset; -#if ANDROID_USE_THREE_BUFS - if(0==new_frame_seted) { - wq_condition = 0; - wait_event_interruptible_timeout(wq, wq_condition, HZ/20); - } - new_frame_seted = 0; -#endif + addr = fix->smem_start + offset; LcdMskReg(inf, SYS_CONFIG, m_W1_ENABLE|m_W1_FORMAT, v_W1_ENABLE(1)|v_W1_FORMAT(format)); @@ -1464,7 +1454,6 @@ static int win1fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *inf mcu_refresh(inf); -#if !ANDROID_USE_THREE_BUFS // flush end when wq_condition=1 in mcu panel, but not in rgb panel if(SCREEN_MCU == inf->cur_screen->type) { wait_event_interruptible_timeout(wq, wq_condition, HZ/20); @@ -1473,19 +1462,6 @@ static int win1fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *inf wq_condition = 0; wait_event_interruptible_timeout(wq, wq_condition, HZ/20); } -#endif - -#if 0 - int i; - for(i=0;i<=(0xc0/4);i+=4) - { - fbprintk("0x%02X: 0x%08X 0x%08X 0x%08X 0x%08X \n", i*4, - *((u32*)inf->reg_vir_base+i), - *((u32*)inf->reg_vir_base+i+1), - *((u32*)inf->reg_vir_base+i+2), - *((u32*)inf->reg_vir_base+i+3)); - } -#endif return 0; } @@ -1620,10 +1596,6 @@ static irqreturn_t rk29fb_irq(int irq, void *dev_id) } } -#if ANDROID_USE_THREE_BUFS - new_frame_seted = 1; -#endif - wq_condition = 1; wake_up_interruptible(&wq); @@ -1766,7 +1738,7 @@ static int __init rk29fb_probe (struct platform_device *pdev) /* get virtual basic address of lcdc register */ fbprintk(">> get virtual basic address of lcdc register \n"); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lcdc reg"); if (res == NULL) { dev_err(&pdev->dev, "failed to get memory registers\n"); @@ -1850,6 +1822,19 @@ static int __init rk29fb_probe (struct platform_device *pdev) if (ret < 0) goto release_cmap; + /* alloc win1 buf */ + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "win1 buf"); + if (res == NULL) + { + dev_err(&pdev->dev, "failed to get win1 memory \n"); + ret = -ENOENT; + goto release_win1fb; + } + inf->win1fb->fix.smem_start = res->start; + inf->win1fb->fix.smem_len = res->end - res->start; + inf->win1fb->screen_base = ioremap(res->start, inf->win1fb->fix.smem_len); + memset(inf->win1fb->screen_base, 0, inf->win1fb->fix.smem_len); + /* Prepare win0 info */ fbprintk(">> Prepare win0 info \n"); inf->win0fb = framebuffer_alloc(sizeof(struct win0_par), &pdev->dev); @@ -2082,7 +2067,7 @@ static int rk29fb_remove(struct platform_device *pdev) if(inf->win1fb) { info = inf->win1fb; if (info->screen_base) { - dma_free_writecombine(NULL, PAGE_ALIGN(info->fix.smem_len),info->screen_base, info->fix.smem_start); + // dma_free_writecombine(NULL, PAGE_ALIGN(info->fix.smem_len),info->screen_base, info->fix.smem_start); info->screen_base = 0; info->fix.smem_start = 0; info->fix.smem_len = 0; -- 2.34.1