diff mbox

[U-Boot,3/7] common lcd: simplify bitmap_plot

Message ID 1337859764-16086-4-git-send-email-grinberg@compulab.co.il
State Changes Requested
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 bitmap_plot in terms of number of #ifdefs by making some of the
code into an external macro

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

Comments

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

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

> From: Nikita Kiryanov <nikita@compulab.co.il>
> 
> Simplify bitmap_plot in terms of number of #ifdefs by making some of the
> code into an external macro
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> ---
>  common/lcd.c |   26 ++++++++++++++------------
>  1 files changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/common/lcd.c b/common/lcd.c
> index 3b2f25f..448e0f0 100644
> --- a/common/lcd.c
> +++ b/common/lcd.c
> @@ -498,6 +498,18 @@ static int lcd_getbgcolor(void)
>  /************************************************************************/
>  /* ** Chipset depending Bitmap / Logo stuff...                          */
>  /************************************************************************/
> +#ifdef CONFIG_ATMEL_LCD
> +#ifdef CONFIG_ATMEL_LCD_BGR555
> +#define LUT_ENTRY(colreg) (((colreg) & 0x000F) << 11) | \
> +			(((colreg) & 0x00F0) <<  2) | \
> +			(((colreg) & 0x0F00) >>  7);
> +#else /* CONFIG_ATMEL_LCD_RGB565 */
> +#define LUT_ENTRY(colreg) (((colreg) & 0x000F) << 1) | \
> +			(((colreg) & 0x00F0) <<  3) | \
> +			(((colreg) & 0x0F00) >>  4);
> +#endif
> +#endif
> +
>  #ifdef CONFIG_LCD_LOGO
>  void bitmap_plot(int x, int y)
>  {
> @@ -545,19 +557,9 @@ void bitmap_plot(int x, int y)
>  		for (i = 0; i < ARRAY_SIZE(bmp_logo_palette); ++i) {
>  			ushort colreg = bmp_logo_palette[i];
>  #ifdef CONFIG_ATMEL_LCD
> -			uint lut_entry;
> -#ifdef CONFIG_ATMEL_LCD_BGR555
> -			lut_entry = ((colreg & 0x000F) << 11) |
> -					((colreg & 0x00F0) <<  2) |
> -					((colreg & 0x0F00) >>  7);
> -#else /* CONFIG_ATMEL_LCD_RGB565 */
> -			lut_entry = ((colreg & 0x000F) << 1) |
> -					((colreg & 0x00F0) << 3) |
> -					((colreg & 0x0F00) << 4);
> -#endif
> -			*(cmap + BMP_LOGO_OFFSET) = lut_entry;
> +			*(cmap + BMP_LOGO_OFFSET) = LUT_ENTRY(colreg);
>  			cmap++;
> -#else /* !CONFIG_ATMEL_LCD */
> +#else
>  #ifdef  CONFIG_SYS_INVERT_COLORS
>  			*cmap++ = 0xffff - colreg;
>  #else

Here it should be possible to use lcd_setcolreg() in the for loop,
too. I would prefer this approach instead of adding LUT_ENTRY macro.

Thanks,

Anatolij
diff mbox

Patch

diff --git a/common/lcd.c b/common/lcd.c
index 3b2f25f..448e0f0 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -498,6 +498,18 @@  static int lcd_getbgcolor(void)
 /************************************************************************/
 /* ** Chipset depending Bitmap / Logo stuff...                          */
 /************************************************************************/
+#ifdef CONFIG_ATMEL_LCD
+#ifdef CONFIG_ATMEL_LCD_BGR555
+#define LUT_ENTRY(colreg) (((colreg) & 0x000F) << 11) | \
+			(((colreg) & 0x00F0) <<  2) | \
+			(((colreg) & 0x0F00) >>  7);
+#else /* CONFIG_ATMEL_LCD_RGB565 */
+#define LUT_ENTRY(colreg) (((colreg) & 0x000F) << 1) | \
+			(((colreg) & 0x00F0) <<  3) | \
+			(((colreg) & 0x0F00) >>  4);
+#endif
+#endif
+
 #ifdef CONFIG_LCD_LOGO
 void bitmap_plot(int x, int y)
 {
@@ -545,19 +557,9 @@  void bitmap_plot(int x, int y)
 		for (i = 0; i < ARRAY_SIZE(bmp_logo_palette); ++i) {
 			ushort colreg = bmp_logo_palette[i];
 #ifdef CONFIG_ATMEL_LCD
-			uint lut_entry;
-#ifdef CONFIG_ATMEL_LCD_BGR555
-			lut_entry = ((colreg & 0x000F) << 11) |
-					((colreg & 0x00F0) <<  2) |
-					((colreg & 0x0F00) >>  7);
-#else /* CONFIG_ATMEL_LCD_RGB565 */
-			lut_entry = ((colreg & 0x000F) << 1) |
-					((colreg & 0x00F0) << 3) |
-					((colreg & 0x0F00) << 4);
-#endif
-			*(cmap + BMP_LOGO_OFFSET) = lut_entry;
+			*(cmap + BMP_LOGO_OFFSET) = LUT_ENTRY(colreg);
 			cmap++;
-#else /* !CONFIG_ATMEL_LCD */
+#else
 #ifdef  CONFIG_SYS_INVERT_COLORS
 			*cmap++ = 0xffff - colreg;
 #else