From patchwork Thu Aug 9 10:14:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryanov X-Patchwork-Id: 176061 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 8BD672C007F for ; Thu, 9 Aug 2012 21:24:17 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9E0A8280DD; Thu, 9 Aug 2012 13:24:05 +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 UReK06D2wdnQ; Thu, 9 Aug 2012 13:24:05 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0695F280DE; Thu, 9 Aug 2012 13:23:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C405B280C7 for ; Thu, 9 Aug 2012 13:23:42 +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 5Zy2TueY-E0r for ; Thu, 9 Aug 2012 13:23:42 +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 B6B89280B3 for ; Thu, 9 Aug 2012 13:23:39 +0200 (CEST) Received: from [62.90.235.247] (port=48295 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.77) (envelope-from ) id 1SzPlY-0003kT-Gv; Thu, 09 Aug 2012 13:14:56 +0300 Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id CB54E64419E; Thu, 9 Aug 2012 13:14:55 +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 AAN6lnAJ+5ji; 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 D29C8644198; Thu, 9 Aug 2012 13:14:54 +0300 (IDT) Received: by compulab.co.il (Postfix, from userid 1000) id 9F676FC23A2; 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:51 +0300 Message-Id: <1344507293-10579-3-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 2/4] common lcd: simplify lcd_display 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 Simplify lcd_display by centralizing code into a funciton Signed-off-by: Nikita Kiryanov Signed-off-by: Igor Grinberg --- common/lcd.c | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-) diff --git a/common/lcd.c b/common/lcd.c index 8890635..4a5c8d5 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -607,6 +607,22 @@ static inline void bitmap_plot(int x, int y) {} #ifdef CONFIG_SPLASH_SCREEN_ALIGN #define BMP_ALIGN_CENTER 0x7FFF + +static void splash_align_axis(int *axis, unsigned long panel_size, + unsigned long picture_size) +{ + unsigned long panel_picture_delta = panel_size - picture_size; + unsigned long axis_alignment; + + if (*axis == BMP_ALIGN_CENTER) + axis_alignment = panel_picture_delta / 2; + else if (*axis < 0) + axis_alignment = panel_picture_delta + *axis + 1; + else + return; + + *axis = max(0, axis_alignment); +} #endif int lcd_display_bitmap(ulong bmp_image, int x, int y) @@ -722,15 +738,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) padded_line = (width&0x3) ? ((width&~0x3)+4) : (width); #ifdef CONFIG_SPLASH_SCREEN_ALIGN - if (x == BMP_ALIGN_CENTER) - x = max(0, (pwidth - width) / 2); - else if (x < 0) - x = max(0, pwidth - width + x + 1); - - if (y == BMP_ALIGN_CENTER) - y = max(0, (panel_info.vl_row - height) / 2); - else if (y < 0) - y = max(0, panel_info.vl_row - height + y + 1); + splash_align_axis(&x, pwidth, width); + splash_align_axis(&y, panel_info.vl_row, height); #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ if ((x + width) > pwidth)