summaryrefslogtreecommitdiff
path: root/common/lcd.c
diff options
context:
space:
mode:
authorNikita Kiryanov <nikita@compulab.co.il>2012-08-09 00:14:51 +0000
committerAnatolij Gustschin <agust@denx.de>2012-09-05 10:27:57 +0200
commit7c7e280aa6766ac34c6dbf4a5a2c6b14554ccc3f (patch)
tree2a5d8b63ab9a5548d744f2c084e3ec9425c80f3f /common/lcd.c
parentd3a555eddb019ae4a0db7ab9c0c2297f0215a12f (diff)
downloadu-boot-imx-7c7e280aa6766ac34c6dbf4a5a2c6b14554ccc3f.zip
u-boot-imx-7c7e280aa6766ac34c6dbf4a5a2c6b14554ccc3f.tar.gz
u-boot-imx-7c7e280aa6766ac34c6dbf4a5a2c6b14554ccc3f.tar.bz2
common lcd: simplify lcd_display
Simplify lcd_display by centralizing code into a funciton Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Diffstat (limited to 'common/lcd.c')
-rw-r--r--common/lcd.c27
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)