From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiTLb-0000YQ-O0 for qemu-devel@nongnu.org; Thu, 08 May 2014 14:47:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiTLS-0006F1-Vq for qemu-devel@nongnu.org; Thu, 08 May 2014 14:47:11 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:48064) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiTLS-0006Dw-IE for qemu-devel@nongnu.org; Thu, 08 May 2014 14:47:02 -0400 From: Peter Maydell Date: Thu, 8 May 2014 19:46:53 +0100 Message-Id: <1399574818-19349-4-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1399574818-19349-1-git-send-email-peter.maydell@linaro.org> References: <1399574818-19349-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 3/8] hw/display/pxa2xx_lcd: Fix 16bpp+alpha and 18bpp+alpha palette formats List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Crosthwaite , patches@linaro.org The pxa2xx palette entry "16bpp plus transparency" format is xxxxxxxTRRRRR000GGGGGG00BBBBB000, and "18bpp plus transparency" is xxxxxxxTRRRRRR00GGGGGG00BBBBBB00. Correct errors in the code for reading these and converting them to the internal format. In particular, the buggy code was attempting to mask out bit 24 of a uint16_t, which Coverity spotted as an error. Signed-off-by: Peter Maydell --- hw/display/pxa2xx_lcd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c index 09cdf17..fce013d 100644 --- a/hw/display/pxa2xx_lcd.c +++ b/hw/display/pxa2xx_lcd.c @@ -620,13 +620,13 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) src += 2; break; case 1: /* 16 bpp plus transparency */ - alpha = *(uint16_t *) src & (1 << 24); + alpha = *(uint32_t *) src & (1 << 24); if (s->control[0] & LCCR0_CMS) - r = g = b = *(uint16_t *) src & 0xff; + r = g = b = *(uint32_t *) src & 0xff; else { - r = (*(uint16_t *) src & 0xf800) >> 8; - g = (*(uint16_t *) src & 0x07e0) >> 3; - b = (*(uint16_t *) src & 0x001f) << 3; + r = (*(uint32_t *) src & 0x7c0000) >> 15; + g = (*(uint32_t *) src & 0x00fc00) >> 8; + b = (*(uint32_t *) src & 0x0000f8); } src += 2; break; @@ -635,9 +635,9 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) if (s->control[0] & LCCR0_CMS) r = g = b = *(uint32_t *) src & 0xff; else { - r = (*(uint32_t *) src & 0xf80000) >> 16; + r = (*(uint32_t *) src & 0xfc0000) >> 16; g = (*(uint32_t *) src & 0x00fc00) >> 8; - b = (*(uint32_t *) src & 0x0000f8); + b = (*(uint32_t *) src & 0x0000fc); } src += 4; break; -- 1.9.2