From patchwork Thu Aug 9 10:14:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryanov X-Patchwork-Id: 176059 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 15E282C007F for ; Thu, 9 Aug 2012 21:23:57 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 047D8280D6; Thu, 9 Aug 2012 13:23:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 TAL5NvPHTSpc; Thu, 9 Aug 2012 13:23:51 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 25AF2280C3; Thu, 9 Aug 2012 13:23:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C116A280B6 for ; Thu, 9 Aug 2012 13:23:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 Wd+LwVKnTXw7 for ; Thu, 9 Aug 2012 13:23:35 +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 compulab.co.il (softlayer.compulab.co.il [50.23.254.55]) by theia.denx.de (Postfix) with ESMTPS id 6D217280B7 for ; Thu, 9 Aug 2012 13:23:34 +0200 (CEST) Received: from [62.90.235.247] (port=38590 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.77) (envelope-from ) id 1SzPlY-0003kU-Rd; Thu, 09 Aug 2012 13:14:57 +0300 Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 32929644198; Thu, 9 Aug 2012 13:14:56 +0300 (IDT) X-Virus-Scanned: amavisd-new at compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OFtL7jE0wfvg; Thu, 9 Aug 2012 13:14:55 +0300 (IDT) Received: from compulab.co.il (nikita-pc.compulab.local [192.168.11.211]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 260A064419A; Thu, 9 Aug 2012 13:14:55 +0300 (IDT) Received: by compulab.co.il (Postfix, from userid 1000) id E7946FC23A5; Thu, 9 Aug 2012 13:14:54 +0300 (IDT) From: Nikita Kiryanov To: u-boot@lists.denx.de Date: Thu, 9 Aug 2012 13:14:53 +0300 Message-Id: <1344507293-10579-5-git-send-email-nikita@compulab.co.il> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1344507293-10579-1-git-send-email-nikita@compulab.co.il> References: <1344507293-10579-1-git-send-email-nikita@compulab.co.il> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - lists.denx.de X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il Subject: [U-Boot] [PATCH V3 4/4] common lcd: simplify lcd_display_bitmap X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Move highly platform dependant code into its own functions to reduce the number of #ifdefs in lcd_display_bitmap To avoid breaking the mcc200 board which does not #define CONFIG_CMD_BMP, this patch also implements bmp_display() for mcc200. Signed-off-by: Nikita Kiryanov Signed-off-by: Igor Grinberg --- Changes in V2: - fixed pointer increment error - change to simplify lcd_logo breaks MCC200 board because it does not #define CONFIG_CMD_BMP. Added a local implementation of bitmap_display(). board/mcc200/lcd.c | 20 ++++++++++++++++++++ common/lcd.c | 44 +++++++++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/board/mcc200/lcd.c b/board/mcc200/lcd.c index d8f754c..893f4b7 100644 --- a/board/mcc200/lcd.c +++ b/board/mcc200/lcd.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef CONFIG_LCD @@ -210,4 +211,23 @@ void show_progress (int size, int tot) } #endif + +int bmp_display(ulong addr, int x, int y) +{ + int ret; + bmp_image_t *bmp = (bmp_image_t *)addr; + + if (!bmp) { + printf("There is no valid bmp file at the given address\n"); + return 1; + } + + ret = lcd_display_bitmap((ulong)bmp, x, y); + + if ((unsigned long)bmp != addr) + free(bmp); + + return ret; +} + #endif /* CONFIG_LCD */ diff --git a/common/lcd.c b/common/lcd.c index 0f93eae..88dfa51 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -636,6 +636,29 @@ static void splash_align_axis(int *axis, unsigned long panel_size, } #endif +#if defined CONFIG_CPU_PXA || defined(CONFIG_ATMEL_LCD) +#define FB_PUT_BYTE(fb, from) *(fb)++ = *(from)++ +#elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200) +#define FB_PUT_BYTE(fb, from) *(fb)++ = (255 - *(from)++) +#endif + +#if defined(CONFIG_BMP_16BPP) +#if defined(CONFIG_ATMEL_LCD_BGR555) +static inline void fb_put_word(uchar **fb, uchar **from) +{ + *(*fb)++ = (((*from)[0] & 0x1f) << 2) | ((*from)[1] & 0x03); + *(*fb)++ = ((*from)[0] & 0xe0) | (((*from)[1] & 0x7c) >> 2); + *from += 2; +} +#else +static inline void fb_put_word(uchar **fb, uchar **from) +{ + *(*fb)++ = *(*from)++; + *(*fb)++ = *(*from)++; +} +#endif +#endif /* CONFIG_BMP_16BPP */ + int lcd_display_bitmap(ulong bmp_image, int x, int y) { #if !defined(CONFIG_MCC200) @@ -761,11 +784,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) WATCHDOG_RESET(); for (j = 0; j < width; j++) { if (bpix != 16) { -#if defined(CONFIG_CPU_PXA) || defined(CONFIG_ATMEL_LCD) - *(fb++) = *(bmap++); -#elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200) - *(fb++) = 255 - *(bmap++); -#endif + FB_PUT_BYTE(fb, bmap); } else { *(uint16_t *)fb = cmap_base[*(bmap++)]; fb += sizeof(uint16_t) / sizeof(*fb); @@ -780,18 +799,9 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) case 16: for (i = 0; i < height; ++i) { WATCHDOG_RESET(); - for (j = 0; j < width; j++) { -#if defined(CONFIG_ATMEL_LCD_BGR555) - *(fb++) = ((bmap[0] & 0x1f) << 2) | - (bmap[1] & 0x03); - *(fb++) = (bmap[0] & 0xe0) | - ((bmap[1] & 0x7c) >> 2); - bmap += 2; -#else - *(fb++) = *(bmap++); - *(fb++) = *(bmap++); -#endif - } + for (j = 0; j < width; j++) + fb_put_word(&fb, &bmap); + bmap += (padded_line - width) * 2; fb -= (width * 2 + lcd_line_length); }