From patchwork Fri Jun 22 04:24:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 10481229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6B70860380 for ; Fri, 22 Jun 2018 04:29:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B35428E52 for ; Fri, 22 Jun 2018 04:29:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EC0B28E58; Fri, 22 Jun 2018 04:29:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE31828E52 for ; Fri, 22 Jun 2018 04:29:18 +0000 (UTC) Received: from localhost ([::1]:59148 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWDhG-0002gz-1T for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 Jun 2018 00:29:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWDd2-0007ld-0p for qemu-devel@nongnu.org; Fri, 22 Jun 2018 00:24:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWDd0-0003c5-K3 for qemu-devel@nongnu.org; Fri, 22 Jun 2018 00:24:55 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:41251) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fWDd0-0003aE-2L; Fri, 22 Jun 2018 00:24:54 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41BlpP4ZxCz9sBK; Fri, 22 Jun 2018 14:24:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1529641485; bh=SmVfq5yUdFq/bu5sn9/D0HT0S5QmwzDMGsMchaU99C8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hWb/8ndXoWWhzf4byAa+H0/ErkMhP20l3KxKnHpVizrP7wuHVoIfRNwWDehh+qqyE An4LaWV5noYcPXUKqerQluoYFEX/Gp42IYDx90qYg8buxtRfATy+f9ZDxxtlOGXoFq 7raIJRloYxbic0GVfKpxv318AtUODn8lT5bBh8D0= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 22 Jun 2018 14:24:28 +1000 Message-Id: <20180622042437.14259-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180622042437.14259-1-david@gibson.dropbear.id.au> References: <20180622042437.14259-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PATCH 14/23] sm501: Fix hardware cursor color conversion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, aik@ozlabs.ru, Sebastian Bauer , qemu-devel@nongnu.org, agraf@suse.de, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sebastian Bauer According to the sm501 specs the hardware cursor colors are to be given in the rgb565 format, but the code currently interprets them as bgr565. Therefore, the colors of the hardware cursors are wrong in the QEMU display, e.g., the standard mouse pointer of AmigaOS appears blue instead of red. This change fixes this issue by replacing the existing naive bgr565 => rgb888 conversion with a standard rgb565 => rgb888 one that also scales the color component values properly. Signed-off-by: Sebastian Bauer Signed-off-by: David Gibson --- hw/display/sm501.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index ca0840f6fa..8206ae81a1 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -652,9 +652,9 @@ static inline void get_hwc_palette(SM501State *state, int crt, uint8_t *palette) } else { rgb565 = color_reg & 0xFFFF; } - palette[i * 3 + 0] = (rgb565 << 3) & 0xf8; /* red */ - palette[i * 3 + 1] = (rgb565 >> 3) & 0xfc; /* green */ - palette[i * 3 + 2] = (rgb565 >> 8) & 0xf8; /* blue */ + palette[i * 3 + 0] = ((rgb565 >> 11) * 527 + 23) >> 6; /* r */ + palette[i * 3 + 1] = (((rgb565 >> 5) & 0x3f) * 259 + 33) >> 6; /* g */ + palette[i * 3 + 2] = ((rgb565 & 0x1f) * 527 + 23) >> 6; /* b */ } }