From patchwork Thu Jan 29 11:21:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryanov X-Patchwork-Id: 434518 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 412881402B1 for ; Thu, 29 Jan 2015 22:23:57 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 91A464B76B; Thu, 29 Jan 2015 12:23:20 +0100 (CET) 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 NTWyJH_YiA_P; Thu, 29 Jan 2015 12:23:20 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CDA904B83C; Thu, 29 Jan 2015 12:22:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7C87A4B62A for ; Thu, 29 Jan 2015 12:22:06 +0100 (CET) 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 qGGLGPtKtKi5 for ; Thu, 29 Jan 2015 12:22:06 +0100 (CET) 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 7F38A4B782 for ; Thu, 29 Jan 2015 12:22:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=compulab.co.il; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=6ypoE1KQyoBh8z8s0exeOYBuJZLsss6PzihIjJ+bbus=; b=zQQ3uBKL/MqywMOYHcW6c7higsg+3sl2wEnB1PNUbW5mWyKq1fPqn8aG51mX+GNwORKuYUqbE52N76xxbbcfFNhmonIz4EODtOKhXTqUTW54Be2B5zqXR8Tt+UlkOb9WuxWIvjLKnB/hfqsoEuE7jiFUwE3mMc3B2jnGyuIalu0=; Received: from [82.166.188.245] (port=19236 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.84) (envelope-from ) id 1YGnAe-0002Pj-Jt; Thu, 29 Jan 2015 13:22:00 +0200 Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 7B272488AB6; Thu, 29 Jan 2015 13:21:59 +0200 (IST) 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 10032) with ESMTP id EA0yFrTi8Et7; Thu, 29 Jan 2015 13:21:59 +0200 (IST) Received: from localhost (localhost [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 88AEF488AB9; Thu, 29 Jan 2015 13:21:58 +0200 (IST) X-Virus-Scanned: amavisd-new at zimbra-mta.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 10026) with ESMTP id HZRKwf0eoKH0; Thu, 29 Jan 2015 13:21:58 +0200 (IST) Received: from skynet.compulab.local (nikita-pc.compulab.local [192.168.11.211]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 6656E488AB7; Thu, 29 Jan 2015 13:21:58 +0200 (IST) From: Nikita Kiryanov To: u-boot@lists.denx.de Date: Thu, 29 Jan 2015 13:21:40 +0200 Message-Id: <1422530505-19054-9-git-send-email-nikita@compulab.co.il> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422530505-19054-1-git-send-email-nikita@compulab.co.il> References: <1422530505-19054-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 X-Get-Message-Sender-Via: softlayer.compulab.co.il: acl_c_relayhosts_text_entry: nikita@compulab.co.il|compulab.co.il Subject: [U-Boot] [PATCH 08/13] lcd: introduce lcd_set_cmap 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" Reduce the lcd_display_bitmap #ifdef complexity by extracting Atmel specific code for setting cmap for bitmap images into a new function lcd_set_cmap(). A default version is implemented with the remainder of the code. Signed-off-by: Nikita Kiryanov Cc: Bo Shen Cc: Simon Glass Cc: Anatolij Gustschin Reviewed-by: Simon Glass --- common/lcd.c | 46 ++++++++++++++++++++++----------------------- drivers/video/atmel_lcdfb.c | 11 +++++++++++ 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/common/lcd.c b/common/lcd.c index dcee3c0..8a8d6c3 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -613,9 +613,27 @@ __weak void fb_put_word(uchar **fb, uchar **from) } #endif /* CONFIG_BMP_16BPP */ +__weak void lcd_set_cmap(bmp_image_t *bmp, unsigned colors) +{ + int i; + bmp_color_table_entry_t cte; + ushort *cmap = configuration_get_cmap(); + + for (i = 0; i < colors; ++i) { + cte = bmp->color_table[i]; + *cmap = (((cte.red) << 8) & 0xf800) | + (((cte.green) << 3) & 0x07e0) | + (((cte.blue) >> 3) & 0x001f); +#if defined(CONFIG_MPC823) + cmap--; +#else + cmap++; +#endif + } +} + int lcd_display_bitmap(ulong bmp_image, int x, int y) { - ushort *cmap = NULL; ushort *cmap_base = NULL; ushort i, j; uchar *fb; @@ -663,29 +681,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) debug("Display-bmp: %d x %d with %d colors\n", (int)width, (int)height, (int)colors); - if (bmp_bpix == 8) { - cmap = configuration_get_cmap(); - cmap_base = cmap; - - /* Set color map */ - for (i = 0; i < colors; ++i) { - bmp_color_table_entry_t cte = bmp->color_table[i]; -#if !defined(CONFIG_ATMEL_LCD) - ushort colreg = - ( ((cte.red) << 8) & 0xf800) | - ( ((cte.green) << 3) & 0x07e0) | - ( ((cte.blue) >> 3) & 0x001f) ; - *cmap = colreg; -#if defined(CONFIG_MPC823) - cmap--; -#else - cmap++; -#endif -#else /* CONFIG_ATMEL_LCD */ - lcd_setcolreg(i, cte.red, cte.green, cte.blue); -#endif - } - } + if (bmp_bpix == 8) + lcd_set_cmap(bmp, colors); padded_width = (width & 0x3 ? (width & ~0x3) + 4 : width); @@ -706,6 +703,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) switch (bmp_bpix) { case 1: /* pass through */ case 8: { + cmap_base = configuration_get_cmap(); #ifdef CONFIG_LCD_BMP_RLE8 u32 compression = get_unaligned_le32(&bmp->header.compression); if (compression == BMP_BI_RLE8) { diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 2a71eba..5add136 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c @@ -11,6 +11,7 @@ #include #include #include +#include #include /* configurable parameters */ @@ -80,6 +81,16 @@ void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue) #endif } +void lcd_set_cmap(bmp_image_t *bmp, unsigned colors) +{ + int i; + + for (i = 0; i < colors; ++i) { + bmp_color_table_entry_t cte = bmp->color_table[i]; + lcd_setcolreg(i, cte.red, cte.green, cte.blue); + } +} + void lcd_ctrl_init(void *lcdbase) { unsigned long value;