modify fb win1 buf alloc
authorzyw <zyw@rock-chips.com>
Mon, 13 Dec 2010 04:42:51 +0000 (12:42 +0800)
committerzyw <zyw@rock-chips.com>
Mon, 13 Dec 2010 04:42:51 +0000 (12:42 +0800)
arch/arm/mach-rk29/board-rk29sdk.c
arch/arm/mach-rk29/devices.c
drivers/video/rk29_fb.c

index af60e0c6004f550212b51441201777ae5226e2c3..7169de7eed16b19aba1295edbd78df78e83d3129 100755 (executable)
 #define PMEM_UI_SIZE        SZ_32M\r
 #define PMEM_VPU_SIZE       SZ_32M\r
 #define PMEM_CAM_SIZE       SZ_16M\r
+#define MEM_FB_SIZE         SZ_4M\r
 \r
 #define PMEM_GPU_BASE       ((u32)RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)\r
 #define PMEM_UI_BASE        (PMEM_GPU_BASE - PMEM_UI_SIZE)\r
 #define PMEM_VPU_BASE       (PMEM_UI_BASE - PMEM_VPU_SIZE)\r
 #define PMEM_CAM_BASE       (PMEM_VPU_BASE - PMEM_CAM_SIZE)\r
-#define LINUX_SIZE          (PMEM_CAM_BASE - RK29_SDRAM_PHYS)\r
+#define MEM_FB_BASE         (PMEM_CAM_BASE - MEM_FB_SIZE)\r
+#define LINUX_SIZE          (MEM_FB_BASE - RK29_SDRAM_PHYS)\r
 \r
 extern struct sys_timer rk29_timer;\r
 \r
@@ -113,6 +115,7 @@ static struct rk29_gpio_bank rk29_gpiobankinit[] = {
        },\r
 };\r
 \r
+#ifdef CONFIG_FB_RK29\r
 /*****************************************************************************************\r
  * lcd  devices\r
  * author: zyw@rock-chips.com\r
@@ -215,6 +218,40 @@ struct rk29fb_info rk29_fb_info = {
     .io_init   = rk29_fb_io_init,\r
 };\r
 \r
+/* rk29 fb resource */\r
+struct resource rk29_fb_resource[] = {\r
+       [0] = {\r
+        .name  = "lcdc reg",\r
+               .start = RK29_LCDC_PHYS,\r
+               .end   = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,\r
+               .flags = IORESOURCE_MEM,\r
+       },\r
+       [1] = {\r
+           .name  = "lcdc irq",\r
+               .start = IRQ_LCDC,\r
+               .end   = IRQ_LCDC,\r
+               .flags = IORESOURCE_IRQ,\r
+       },\r
+       [2] = {\r
+           .name   = "win1 buf",\r
+        .start  = MEM_FB_BASE,\r
+        .end    = MEM_FB_BASE + MEM_FB_SIZE,\r
+        .flags  = IORESOURCE_MEM,\r
+    },\r
+};\r
+\r
+/*platform_device*/\r
+struct platform_device rk29_device_fb = {\r
+       .name             = "rk29-fb",\r
+       .id               = 4,\r
+       .num_resources    = ARRAY_SIZE(rk29_fb_resource),\r
+       .resource         = rk29_fb_resource,\r
+       .dev            = {\r
+               .platform_data  = &rk29_fb_info,\r
+       }\r
+};\r
+#endif\r
+\r
 static struct android_pmem_platform_data android_pmem_pdata = {\r
        .name           = "pmem",\r
        .start          = PMEM_UI_BASE,\r
index d587c28238e392edb0eb6df6f31d734ed5fa02ed..412b4fd81f7d0aa52998dd2daf9b9964fddb937e 100755 (executable)
@@ -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[] = {
index 9835c861b98c0881e621d2eea90020540fc0515d..ec855acf24836be654c80102840def2c3f4488d8 100755 (executable)
@@ -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;