From f6916789d5d71456bca9a96c14c86dd994941b0b Mon Sep 17 00:00:00 2001 From: Mark Yao Date: Tue, 19 Jan 2016 12:53:34 +0800 Subject: [PATCH] video: rk_fb: align 24bit data format 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 --- drivers/video/rockchip/bmp_helper.c | 10 ++++++---- drivers/video/rockchip/rk_fb.c | 11 +++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/video/rockchip/bmp_helper.c b/drivers/video/rockchip/bmp_helper.c index a50fd58729ea..11b1e5e4461d 100755 --- a/drivers/video/rockchip/bmp_helper.c +++ b/drivers/video/rockchip/bmp_helper.c @@ -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; diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index fa5c8a1c36f5..66aecd006d6f 100644 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -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(); -- 2.34.1