From patchwork Fri May 16 09:51:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 30321 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 35CD920A25 for ; Fri, 16 May 2014 09:52:13 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id rl12sf11687700iec.10 for ; Fri, 16 May 2014 02:52:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=aiu4+T3wcRAzLP+a35rbd8qrwRH9bXJdxlZooGxluc0=; b=V2RwPvUKi2v1s9jH9k8Hmcc6CvdN6k/aMYeOFXgVCETLr+hcqrRdAthkOlFV6SQ37d rHOxRKL+K+mgVfa28M/6g+kZoUmUh6+iEwTAJkzir2Y5TalKOHNVBtNGMZeP/DJay17+ sJ94Tz+UHj1Je/v2W74SdtVa2LqJEYht3vFuFV5Cfobmu77z4Kgusw06Sy26bP7wMlip tif9EacXkzf4ZlZEnn7LMBVahe8jP0RPXwreJRbUA/sojSPTEsJ4jB75s1C13HCQUIjs 6vcK/uJKnyjJrivErh2JH8Sj2uIHoZShlUi9j/sPUKEdPmGaHnViyLa808/tT+Xu1CwZ 79nw== X-Gm-Message-State: ALoCoQlzaIpYr8PsnbyXeNFLZoRiddG+7jDssaMgFHBhm1YTH+XgNN00LyVIouFIX0ULdNaCoCAa X-Received: by 10.182.213.5 with SMTP id no5mr7711286obc.15.1400233932304; Fri, 16 May 2014 02:52:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.85 with SMTP id 79ls621200qgk.41.gmail; Fri, 16 May 2014 02:52:12 -0700 (PDT) X-Received: by 10.58.178.70 with SMTP id cw6mr140711vec.24.1400233932165; Fri, 16 May 2014 02:52:12 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id 2si1460612vcb.16.2014.05.16.02.52.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 02:52:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id lg15so5801066vcb.7 for ; Fri, 16 May 2014 02:52:12 -0700 (PDT) X-Received: by 10.221.7.71 with SMTP id on7mr13294130vcb.18.1400233932088; Fri, 16 May 2014 02:52:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp38524vcb; Fri, 16 May 2014 02:52:11 -0700 (PDT) X-Received: by 10.140.44.34 with SMTP id f31mr22298977qga.73.1400233931176; Fri, 16 May 2014 02:52:11 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a30si3914549qge.89.2014.05.16.02.52.11 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 16 May 2014 02:52:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:34490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlEoE-0003ev-T8 for patch@linaro.org; Fri, 16 May 2014 05:52:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlEno-0003Dh-SL for qemu-devel@nongnu.org; Fri, 16 May 2014 05:51:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WlEnn-0005qV-Tt for qemu-devel@nongnu.org; Fri, 16 May 2014 05:51:44 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:48160) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WlEnn-0005pR-Md for qemu-devel@nongnu.org; Fri, 16 May 2014 05:51:43 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WlEnl-0008H8-M5; Fri, 16 May 2014 10:51:41 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 16 May 2014 10:51:41 +0100 Message-Id: <1400233901-31785-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: Peter Crosthwaite Subject: [Qemu-devel] [PATCH v2] hw/display/pxa2xx_lcd: Fix 16bpp+alpha and 18bpp+alpha palette formats X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 Reviewed-by: Peter Crosthwaite --- This is the remaining uncommitted patch from the set of 8 random coverity fixes I sent a little while back. Changes v1->v2: * use correct mask/shift for R component in 16bpp+transparency * we need to add 4 to the src ptr, not 2, for the 16bpp+transparency format, since each palette entry is 32 bits hw/display/pxa2xx_lcd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c index 80edb70..611fb17 100644 --- a/hw/display/pxa2xx_lcd.c +++ b/hw/display/pxa2xx_lcd.c @@ -620,24 +620,24 @@ 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 & 0xf80000) >> 16; + g = (*(uint32_t *) src & 0x00fc00) >> 8; + b = (*(uint32_t *) src & 0x0000f8); } - src += 2; + src += 4; break; case 2: /* 18 bpp plus transparency */ alpha = *(uint32_t *) src & (1 << 24); 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;