From patchwork Wed Aug 5 15:17:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 504049 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 48B9A140280 for ; Thu, 6 Aug 2015 01:18:27 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0D96F4BE99; Wed, 5 Aug 2015 17:18:19 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VSSn-h2WddDi; Wed, 5 Aug 2015 17:18:18 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D1A9939AB; Wed, 5 Aug 2015 17:17:53 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C91524BCB2 for ; Wed, 5 Aug 2015 17:17:44 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0F-LGGUP8zzu for ; Wed, 5 Aug 2015 17:17:44 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id A30E539AB for ; Wed, 5 Aug 2015 17:17:38 +0200 (CEST) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 18A59461EC; Wed, 5 Aug 2015 15:17:37 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-6-225.ams2.redhat.com [10.36.6.225]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t75FHWvZ027484; Wed, 5 Aug 2015 11:17:35 -0400 From: Hans de Goede To: Ian Campbell , Anatolij Gustschin Date: Wed, 5 Aug 2015 17:17:30 +0200 Message-Id: <1438787851-31814-3-git-send-email-hdegoede@redhat.com> In-Reply-To: <1438787851-31814-1-git-send-email-hdegoede@redhat.com> References: <1438787851-31814-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 2/3] cfbconsole: Add support for stride != width X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" cfbconsole currently assumes that the width and stride of the framebuffer are the same, in most places where stride matters it uses a VIDEO_LINE_LEN helper macro. This commit changes the few places not using VIDEO_LINE_LEN to also use VIDEO_LINE_LEN, and protects the default VIDEO_LINE_LEN with a #ifndef guard, allowing the boards config.h to override and, and thus support cases where stride != width. Signed-off-by: Hans de Goede Acked-by: Anatolij Gustschin --- drivers/video/cfb_console.c | 72 +++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c index d122ef7..30e0317 100644 --- a/drivers/video/cfb_console.c +++ b/drivers/video/cfb_console.c @@ -283,9 +283,10 @@ void console_cursor(int state); #define VIDEO_COLS VIDEO_VISIBLE_COLS #define VIDEO_ROWS VIDEO_VISIBLE_ROWS -#define VIDEO_SIZE (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE) -#define VIDEO_PIX_BLOCKS (VIDEO_SIZE >> 2) -#define VIDEO_LINE_LEN (VIDEO_COLS*VIDEO_PIXEL_SIZE) +#ifndef VIDEO_LINE_LEN +#define VIDEO_LINE_LEN (VIDEO_COLS * VIDEO_PIXEL_SIZE) +#endif +#define VIDEO_SIZE (VIDEO_ROWS * VIDEO_LINE_LEN) #define VIDEO_BURST_LEN (VIDEO_COLS/8) #ifdef CONFIG_VIDEO_LOGO @@ -1306,7 +1307,7 @@ static int display_rle8_bitmap(struct bmp_image *img, int xoff, int yoff, struct palette p[256]; struct bmp_color_table_entry cte; int green_shift, red_off; - int limit = VIDEO_COLS * VIDEO_ROWS; + int limit = (VIDEO_LINE_LEN / VIDEO_PIXEL_SIZE) * VIDEO_ROWS; int pixels = 0; x = 0; @@ -1314,7 +1315,8 @@ static int display_rle8_bitmap(struct bmp_image *img, int xoff, int yoff, ncolors = __le32_to_cpu(img->header.colors_used); bpp = VIDEO_PIXEL_SIZE; fbp = (unsigned char *) ((unsigned int) video_fb_address + - (((y + yoff) * VIDEO_COLS) + xoff) * bpp); + (y + yoff) * VIDEO_LINE_LEN + + xoff * bpp); bm = (uchar *) img + __le32_to_cpu(img->header.data_offset); @@ -1368,8 +1370,8 @@ static int display_rle8_bitmap(struct bmp_image *img, int xoff, int yoff, y--; fbp = (unsigned char *) ((unsigned int) video_fb_address + - (((y + yoff) * VIDEO_COLS) + - xoff) * bpp); + (y + yoff) * VIDEO_LINE_LEN + + xoff * bpp); continue; case 1: /* end of bitmap data marker */ @@ -1381,8 +1383,8 @@ static int display_rle8_bitmap(struct bmp_image *img, int xoff, int yoff, y -= bm[3]; fbp = (unsigned char *) ((unsigned int) video_fb_address + - (((y + yoff) * VIDEO_COLS) + - x + xoff) * bpp); + (y + yoff) * VIDEO_LINE_LEN + + xoff * bpp); bm += 4; break; default: @@ -1561,7 +1563,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y) bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset); fb = (uchar *) (video_fb_address + - ((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) + + ((y + height - 1) * VIDEO_LINE_LEN) + x * VIDEO_PIXEL_SIZE); #ifdef CONFIG_VIDEO_BMP_RLE8 @@ -1597,7 +1599,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y) cte.blue); } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * + fb -= VIDEO_LINE_LEN + width * VIDEO_PIXEL_SIZE; } break; @@ -1628,8 +1630,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) *fb++ = *bmap++; } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; case GDF__8BIT_332RGB: @@ -1642,8 +1644,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) cte.blue); } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; case GDF_15BIT_555RGB: @@ -1666,8 +1668,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) #endif } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; case GDF_16BIT_565RGB: @@ -1680,8 +1682,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) cte.blue); } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; case GDF_32BIT_X888RGB: @@ -1694,8 +1696,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) cte.blue); } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; case GDF_24BIT_888RGB: @@ -1708,8 +1710,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) cte.blue); } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; } @@ -1728,8 +1730,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) bmap += 3; } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; case GDF_15BIT_555RGB: @@ -1751,8 +1753,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) bmap += 3; } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; case GDF_16BIT_565RGB: @@ -1765,8 +1767,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) bmap += 3; } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; case GDF_32BIT_X888RGB: @@ -1779,8 +1781,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) bmap += 3; } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; case GDF_24BIT_888RGB: @@ -1793,8 +1795,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y) bmap += 3; } bmap += padded_line; - fb -= (VIDEO_VISIBLE_COLS + width) * - VIDEO_PIXEL_SIZE; + fb -= VIDEO_LINE_LEN + width * + VIDEO_PIXEL_SIZE; } break; default: @@ -1858,7 +1860,7 @@ static void plot_logo_or_black(void *screen, int x, int y, int black) { int xcount, i; - int skip = (VIDEO_COLS - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE; + int skip = VIDEO_LINE_LEN - VIDEO_LOGO_WIDTH * VIDEO_PIXEL_SIZE; int ycount = video_logo_height; unsigned char r, g, b, *logo_red, *logo_blue, *logo_green; unsigned char *source; @@ -1876,7 +1878,7 @@ static void plot_logo_or_black(void *screen, int x, int y, int black) y = max(0, (int)(VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT + y + 1)); #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ - dest = (unsigned char *)screen + (y * VIDEO_COLS + x) * VIDEO_PIXEL_SIZE; + dest = (unsigned char *)screen + y * VIDEO_LINE_LEN + x * VIDEO_PIXEL_SIZE; #ifdef CONFIG_VIDEO_BMP_LOGO source = bmp_logo_bitmap;