public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [patch] fix easylogo on big endian dev systems
@ 2007-12-18  9:29 Mike Frysinger
  2008-01-09 14:15 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Frysinger @ 2007-12-18  9:29 UTC (permalink / raw)
  To: u-boot

didnt realize how out of shape easylogo actually was until i tried using it.
this patch does byte swapping as need be on the input tga header since the tga
is in little endian but the host could just as well be big endian.  i didnt
bother using bswap macros or such stuff from system headers as nothing in
POSIX dictates byte swapping functionality.

Signed-Off-By: Mike Frysinger <vapier@gentoo.org>
---
--- a/tools/easylogo/easylogo.c
+++ b/tools/easylogo/easylogo.c
@@ -125,6 +127,16 @@ void printlogo_yuyv (unsigned short *data, int w, int h)
     }
 }
 
+static inline unsigned short le16_to_cpu (unsigned short val)
+{
+    union {
+	unsigned char pval[2];
+	unsigned short val;
+    } swapped;
+    swapped.val = val;
+    return (swapped.pval[1] << 8) + swapped.pval[0];
+}
+
 int image_load_tga (image_t *image, char *filename)
 {
     FILE *file ;
@@ -138,6 +150,14 @@ int image_load_tga (image_t *image, char *filename)
 
     fread(&header, sizeof(header), 1, file);
 
+    /* byte swap: tga is little endian, host is ??? */
+    header.ColorMapOrigin = le16_to_cpu (header.ColorMapOrigin);
+    header.ColorMapLenght = le16_to_cpu (header.ColorMapLenght);
+    header.ImageXOrigin = le16_to_cpu (header.ImageXOrigin);
+    header.ImageYOrigin = le16_to_cpu (header.ImageYOrigin);
+    header.ImageWidth = le16_to_cpu (header.ImageWidth);
+    header.ImageHeight = le16_to_cpu (header.ImageHeight);
+
     image->width 	= header.ImageWidth ;
     image->height 	= header.ImageHeight ;
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [U-Boot-Users] [patch] fix easylogo on big endian dev systems
  2007-12-18  9:29 [U-Boot-Users] [patch] fix easylogo on big endian dev systems Mike Frysinger
@ 2008-01-09 14:15 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2008-01-09 14:15 UTC (permalink / raw)
  To: u-boot

In message <200712180429.55400.vapier@gentoo.org> you wrote:
> didnt realize how out of shape easylogo actually was until i tried using it.
> this patch does byte swapping as need be on the input tga header since the tga
> is in little endian but the host could just as well be big endian.  i didnt
> bother using bswap macros or such stuff from system headers as nothing in
> POSIX dictates byte swapping functionality.
> 
> Signed-Off-By: Mike Frysinger <vapier@gentoo.org>

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Quantum particles: The dreams that stuff is made of.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-09 14:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-18  9:29 [U-Boot-Users] [patch] fix easylogo on big endian dev systems Mike Frysinger
2008-01-09 14:15 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox