video: rockchip: hdmi: add dts property rockchip,defaultdepth
[firefly-linux-kernel-4.4.55.git] / drivers / video / rockchip / bmp_helper.c
index a50fd58729ea1a8edaa44570db74d82b565f1ebb..e8f74b7da4f441286625fe0485021bb7c262b2af 100755 (executable)
@@ -74,9 +74,9 @@ static void yuv_to_rgb(int y, int u, int v, int *r, int *g, int *b)
 int bmpencoder(void *__iomem *vaddr, int width, int height, u8 data_format,
               void *data, void (*fn)(void *, void *, int))
 {
-       uint32_t *d, *d1, *d2;
-       uint8_t *dst, *yrgb, *uv, *y1, *y2;
-       int y, u, v, r, g, b;
+       uint32_t *d = NULL, *d1 = NULL, *d2 = NULL;
+       uint8_t *dst = NULL, *yrgb = NULL, *uv = NULL, *y1 = NULL, *y2 = NULL;
+       int y = 0, u = 0, v = 0, r = 0, g = 0, b = 0;
 
        int yu = width * 4 % 4;
        int byteperline;
@@ -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;