[U-Boot] [PATCH 4/5] video/cfb_console: use bmp_layout API
Nikita Kiryanov
nikita at compulab.co.il
Mon Feb 4 12:39:38 CET 2013
If the BMP headers are located in unaligned addresses, accessing them
directly may lead to a data abort on some architectures. Use the safer
bmp_layout API instead.
Signed-off-by: Nikita Kiryanov <nikita at compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg at compulab.co.il>
Cc: Anatolij Gustschin <agust at denx.de>
Cc: Wolfgang Denk <wd at denx.de>
Cc: Albert ARIBAUD <albert.u.boot at aribaud.net>
Cc: Jeroen Hofstee <jeroen at myspectrum.nl>
---
drivers/video/cfb_console.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index 26f673a..6d4e2c5 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -1446,8 +1446,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
WATCHDOG_RESET();
- if (!((bmp->header.signature[0] == 'B') &&
- (bmp->header.signature[1] == 'M'))) {
+ if (!bmp_signature_valid(bmp)) {
#ifdef CONFIG_VIDEO_BMP_GZIP
/*
@@ -1477,8 +1476,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
*/
bmp = (bmp_image_t *) dst;
- if (!((bmp->header.signature[0] == 'B') &&
- (bmp->header.signature[1] == 'M'))) {
+ if (!bmp_signature_valid(bmp)) {
printf("Error: no valid bmp.gz image at %lx\n",
bmp_image);
free(dst);
@@ -1490,11 +1488,11 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
#endif /* CONFIG_VIDEO_BMP_GZIP */
}
- width = le32_to_cpu(bmp->header.width);
- height = le32_to_cpu(bmp->header.height);
- bpp = le16_to_cpu(bmp->header.bit_count);
- colors = le32_to_cpu(bmp->header.colors_used);
- compression = le32_to_cpu(bmp->header.compression);
+ width = bmp_get_width(bmp);
+ height = bmp_get_height(bmp);
+ bpp = bmp_get_bit_count(bmp);
+ colors = bmp_get_colors_used(bmp);
+ compression = bmp_get_compression(bmp);
debug("Display-bmp: %ld x %ld with %d colors\n",
width, height, colors);
@@ -1539,7 +1537,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
if ((y + height) > VIDEO_VISIBLE_ROWS)
height = VIDEO_VISIBLE_ROWS - y;
- bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset);
+ bmap = (uchar *) bmp + bmp_get_data_offset(bmp);
fb = (uchar *) (video_fb_address +
((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) +
x * VIDEO_PIXEL_SIZE);
@@ -1551,7 +1549,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
#endif
/* We handle only 4, 8, or 24 bpp bitmaps */
- switch (le16_to_cpu(bmp->header.bit_count)) {
+ switch (bmp_get_bit_count(bmp)) {
case 4:
padded_line -= width / 2;
ycount = height;
@@ -1785,7 +1783,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
break;
default:
printf("Error: %d bit/pixel bitmaps not supported by U-Boot\n",
- le16_to_cpu(bmp->header.bit_count));
+ bmp_get_bit_count(bmp));
break;
}
--
1.7.10.4
More information about the U-Boot
mailing list