diff mbox

[U-Boot,4/7] common lcd: simplify lcd_logo

Message ID 1337859764-16086-5-git-send-email-grinberg@compulab.co.il
State Superseded
Delegated to: Anatolij Gustschin
Headers show

Commit Message

Igor Grinberg May 24, 2012, 11:42 a.m. UTC
From: Nikita Kiryanov <nikita@compulab.co.il>

Simplify lcd_logo by extracting bmp unzip into its own function.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
 common/lcd.c |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)

Comments

Anatolij Gustschin June 8, 2012, 3:35 p.m. UTC | #1
Hi,

On Thu, 24 May 2012 14:42:41 +0300
Igor Grinberg <grinberg@compulab.co.il> wrote:

> From: Nikita Kiryanov <nikita@compulab.co.il>
> 
> Simplify lcd_logo by extracting bmp unzip into its own function.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> ---
>  common/lcd.c |   30 ++++++++++++++++++++----------
>  1 files changed, 20 insertions(+), 10 deletions(-)
> 
> diff --git a/common/lcd.c b/common/lcd.c
> index 448e0f0..855d3df 100644
> --- a/common/lcd.c
> +++ b/common/lcd.c
> @@ -810,6 +810,25 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
>  }
>  #endif
>  
> +#ifdef CONFIG_VIDEO_BMP_GZIP
> +static inline ulong __gunzip_bmp(ulong addr)
> +{
> +	bmp_image_t *bmp = (bmp_image_t *)addr;
> +	unsigned long len;
> +
> +	if (!((bmp->header.signature[0] == 'B') &&
> +			(bmp->header.signature[1] == 'M')))
> +		addr = (ulong)gunzip_bmp(addr, &len);
> +
> +	return addr;
> +}
> +#else
> +static inline ulong __gunzip_bmp(ulong addr)
> +{
> +	return addr;
> +}
> +#endif
> +
>  static void *lcd_logo(void)
>  {
>  #ifdef CONFIG_SPLASH_SCREEN
> @@ -840,16 +859,7 @@ static void *lcd_logo(void)
>  		}
>  #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
>  
> -#ifdef CONFIG_VIDEO_BMP_GZIP
> -		bmp_image_t *bmp = (bmp_image_t *)addr;
> -		unsigned long len;
> -
> -		if (!((bmp->header.signature[0] == 'B') &&
> -			(bmp->header.signature[1] == 'M'))) {
> -			addr = (ulong)gunzip_bmp(addr, &len);
> -		}
> -#endif
> -
> +		addr = __gunzip_bmp(addr);
>  		if (lcd_display_bitmap(addr, x, y) == 0)
>  			return (void *)lcd_base;

We can simplify it even more by using existing code here:

                if (bmp_display(addr, x, y) == 0)
                        return (void *)lcd_base;

bmp_display() will check and gunzip if needed.

Thanks,

Anatolij
diff mbox

Patch

diff --git a/common/lcd.c b/common/lcd.c
index 448e0f0..855d3df 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -810,6 +810,25 @@  int lcd_display_bitmap(ulong bmp_image, int x, int y)
 }
 #endif
 
+#ifdef CONFIG_VIDEO_BMP_GZIP
+static inline ulong __gunzip_bmp(ulong addr)
+{
+	bmp_image_t *bmp = (bmp_image_t *)addr;
+	unsigned long len;
+
+	if (!((bmp->header.signature[0] == 'B') &&
+			(bmp->header.signature[1] == 'M')))
+		addr = (ulong)gunzip_bmp(addr, &len);
+
+	return addr;
+}
+#else
+static inline ulong __gunzip_bmp(ulong addr)
+{
+	return addr;
+}
+#endif
+
 static void *lcd_logo(void)
 {
 #ifdef CONFIG_SPLASH_SCREEN
@@ -840,16 +859,7 @@  static void *lcd_logo(void)
 		}
 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
 
-#ifdef CONFIG_VIDEO_BMP_GZIP
-		bmp_image_t *bmp = (bmp_image_t *)addr;
-		unsigned long len;
-
-		if (!((bmp->header.signature[0] == 'B') &&
-			(bmp->header.signature[1] == 'M'))) {
-			addr = (ulong)gunzip_bmp(addr, &len);
-		}
-#endif
-
+		addr = __gunzip_bmp(addr);
 		if (lcd_display_bitmap(addr, x, y) == 0)
 			return (void *)lcd_base;
 	}