video: rk_fb: align 24bit data format
authorMark Yao <mark.yao@rock-chips.com>
Tue, 19 Jan 2016 04:53:34 +0000 (12:53 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 25 Jan 2016 10:45:13 +0000 (18:45 +0800)
Vop hardware only support the 4 byte align stride, but
if logo's stride is not align with 4 byte, will get
error display.

Change-Id: I543bbbea98f14702ae0e5f058075c39b8fd6fd68
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/video/rockchip/bmp_helper.c
drivers/video/rockchip/rk_fb.c

index a50fd58729ea1a8edaa44570db74d82b565f1ebb..11b1e5e4461d512bd5ce61721b40154a493120f3 100755 (executable)
@@ -303,6 +303,7 @@ int bmpdecoder(void *bmp_addr, void *pdst, int *width, int *height, int *bits)
        uint16_t *bmp_logo_palette;
        uint32_t size;
        uint16_t linesize;
+       int stride;
        char *cmap_base;
        char *src = bmp_addr;
        char *dst = pdst;
@@ -359,15 +360,16 @@ int bmpdecoder(void *bmp_addr, void *pdst, int *width, int *height, int *bits)
                pr_info("unsupport bit=%d now\n", infoheader.bitcount);
                break;
        case 24:
+               stride = ALIGN(*width * 3, 4);
                if (flip)
-                       src += (*width) * (*height - 1) * 3;
+                       src += stride * (*height - 1);
 
                for (i = 0; i < *height; i++) {
                        memcpy(dst, src, 3 * (*width));
-                       dst += *width * 3;
-                       src += *width * 3;
+                       dst += stride;
+                       src += stride;
                        if (flip)
-                               src -= *width * 3 * 2;
+                               src -= stride * 2;
                }
 
                *bits = 24;
index fa5c8a1c36f590aa679ed5bc2861036fc0d11d42..66aecd006d6f2d303a5ed1357cc623be2a5101f3 100644 (file)
@@ -4147,7 +4147,7 @@ int rk_fb_register(struct rk_lcdc_driver *dev_drv,
 
                if (dev_drv->uboot_logo &&
                    uboot_logo_offset && uboot_logo_base) {
-                       int width, height, bits;
+                       int width, height, bits, xvir;
                        phys_addr_t start = uboot_logo_base + uboot_logo_offset;
                        unsigned int size = uboot_logo_size - uboot_logo_offset;
                        unsigned int nr_pages;
@@ -4190,6 +4190,7 @@ int rk_fb_register(struct rk_lcdc_driver *dev_drv,
                                       xact, yact, width, height);
                                return 0;
                        }
+                       xvir = ALIGN(width * bits, 1 << 5) >> 5;
                        ymirror = 0;
                        local_irq_save(flags);
                        if (dev_drv->ops->wait_frame_start)
@@ -4198,7 +4199,7 @@ int rk_fb_register(struct rk_lcdc_driver *dev_drv,
                                dev_drv->ops->post_dspbuf(dev_drv,
                                        main_fbi->fix.smem_start,
                                        rk_fb_data_fmt(0, bits),
-                                       width, height, width * bits >> 5,
+                                       width, height, xvir,
                                        ymirror);
                        }
                        if (dev_drv->iommu_enabled) {
@@ -4216,7 +4217,7 @@ int rk_fb_register(struct rk_lcdc_driver *dev_drv,
                        unsigned int nr_pages;
                        struct page **pages;
                        char *vaddr;
-                       int align = 0;
+                       int align = 0, xvir;
 
                        dev_drv->ops->get_dspbuf_info(dev_drv, &xact,
                                                      &yact, &format,
@@ -4253,6 +4254,8 @@ int rk_fb_register(struct rk_lcdc_driver *dev_drv,
 
                        kfree(pages);
                        vunmap(vaddr);
+                       xvir = ALIGN(xact * rk_fb_pixel_width(format),
+                                    1 << 5) >> 5;
                        local_irq_save(flags);
                        if (dev_drv->ops->wait_frame_start)
                                dev_drv->ops->wait_frame_start(dev_drv, 0);
@@ -4260,7 +4263,7 @@ int rk_fb_register(struct rk_lcdc_driver *dev_drv,
                                        main_fbi->fix.smem_start +
                                        (y_mirror ? logo_len : 0),
                                        format, xact, yact,
-                                       xact * rk_fb_pixel_width(format) >> 5,
+                                       xvir,
                                        y_mirror);
                        if (dev_drv->iommu_enabled) {
                                rk_fb_poll_wait_frame_complete();