From d581aec7ad715fb8b95a7702532a4e0d8e221cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Voltz?= Date: Thu, 17 Mar 2011 06:20:17 +0100 Subject: [PATCH] big endian fixes for gl847/gl124 based scanners --- ChangeLog | 4 ++++ backend/genesys_low.c | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index df3252aec..561602f16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-17 Stéphane Voltz + * backend/genesys_low.c: big endian fixes for gl847/gl124 based + scanners. Patch by Olaf Zimmermann . + 2011-03-15 Stéphane Voltz * backend/Makefile.in backend/canon_dr.[ch]: fixes to allow full static build under cygwin diff --git a/backend/genesys_low.c b/backend/genesys_low.c index e8ee20c6e..3351d2561 100644 --- a/backend/genesys_low.c +++ b/backend/genesys_low.c @@ -65,6 +65,15 @@ #include "../include/_stdint.h" #include "genesys_low.h" +uint16_t bsuint16(uint16_t v) +{ +#ifdef WORDS_BIGENDIAN + return (v << 8) | (v >> 8); +#else + return(v); +#endif +} + /* ------------------------------------------------------------------------ */ /* functions calling ASIC specific functions */ /* ------------------------------------------------------------------------ */ @@ -262,11 +271,11 @@ sanei_genesys_read_hregister (Genesys_Device * dev, uint8_t reg, uint8_t * val) reg, sane_strstatus (status)); return status; } - *val=value & 0xff; + *val=bsuint16(value) & 0xff; DBG( DBG_io2, "sanei_genesys_read_hregister(0x%02x)=0x%02x\n",reg,value & 0xff); /* check usb link status */ - if((value & 0xff00) != 0x5500) + if((bsuint16(value) & 0xff00) != 0x5500) { DBG (DBG_error,"sanei_genesys_read_hregister: invalid read, scanner unplugged ?\n"); status=SANE_STATUS_IO_ERROR; @@ -384,11 +393,11 @@ sanei_genesys_read_gl847_register (Genesys_Device * dev, uint8_t reg, uint8_t * reg, sane_strstatus (status)); return status; } - *val=value & 0xff; + *val=bsuint16(value) & 0xff; DBG( DBG_io2, "sanei_genesys_read_gl847_register(0x%02x)=0x%02x\n",reg,value & 0xff); /* check usb link status */ - if((value & 0xff00) != 0x5500) + if((bsuint16(value) & 0xff00) != 0x5500) { DBG (DBG_error,"sanei_genesys_read_gl847_register: invalid read, scanner unplugged ?\n"); status=SANE_STATUS_IO_ERROR;