From patchwork Mon Jun 3 00:40:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10972057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34E8413AD for ; Mon, 3 Jun 2019 00:40:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 265F928800 for ; Mon, 3 Jun 2019 00:40:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A98E2883A; Mon, 3 Jun 2019 00:40:34 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D02AA28800 for ; Mon, 3 Jun 2019 00:40:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF34F897C8; Mon, 3 Jun 2019 00:40:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB46E897C8 for ; Mon, 3 Jun 2019 00:40:28 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id s57so376410qte.8 for ; Sun, 02 Jun 2019 17:40:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=sbi5g+zu+1YF3iHGyrsGAgMJlNj3i2840gu1pAJKyYY=; b=kT7lL37IL0jTLC/sWStX7FtcphusZi0MvNHfP8/113kOiMyzxBy9pMMKMpDWvV+Qpc nzua3ti0VSP8WVUP6S1ocG6Qb2WngYs78zRp4a1CgiTN72my8PTGCDwDlI2MpdWuURON JHaq/xEuLZ6NHO3uUBxamD+xybJNEisxRjq8DbHi7+/f5X/GdwkftoCyXvLNvg81SJXK 4JWn36Lew8+UpEq78C0ttA7EOriJZgJt+wflVpQ7cT0TcIE/M0/CodzGO5epEImcBF0t f/DL/vd9wcsrwygoyHBalZdYPNy0SCH4wEBhvUZWV6g/DKVqmojswClMGPE09HAkqn2k FcdQ== X-Gm-Message-State: APjAAAV+9XDtJWAjoiMgw75nL3LQeERKcrErRq/6GDtpqqOHHUggL3tG wM1CceIXBvdqE049Mz3/9so0YeJFsYY= X-Google-Smtp-Source: APXvYqxqSh628yfh64NLhxk+mPVIsmdm0l4RmMq0TlfQJLI8nwChLYIdm0nNeCPvAXK2KDhnuySv1Q== X-Received: by 2002:ac8:2454:: with SMTP id d20mr20443776qtd.266.1559522427705; Sun, 02 Jun 2019 17:40:27 -0700 (PDT) Received: from athos.fios-router.home (pool-173-68-20-215.nycmny.fios.verizon.net. [173.68.20.215]) by smtp.gmail.com with ESMTPSA id t8sm1432609qtc.80.2019.06.02.17.40.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 17:40:27 -0700 (PDT) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 02/10] util: fix MAKE_RGBA macro for 10bpp modes Date: Sun, 2 Jun 2019 20:40:10 -0400 Message-Id: <20190603004017.7114-3-imirkin@alum.mit.edu> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190603004017.7114-1-imirkin@alum.mit.edu> References: <20190603004017.7114-1-imirkin@alum.mit.edu> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sbi5g+zu+1YF3iHGyrsGAgMJlNj3i2840gu1pAJKyYY=; b=in74wzX28yYO6R8SGDWtah9NzId5JwkvlqDUJeU5jYu4zJF4NVMnKE84T4qcsa/8iJ fcTeMY3I/fKo9H6IJ4XMwKbUI064zbm9jWHoRtIdPn3v9hz0lFsflkEQpiFowbj7mrUM dWmU6PmugMbL17/F1LpDFhtbfcOtRfa3hlDtfJL6mGSHBv1v+U/GLteFl/FvkYC9ZdJ3 3eiIu7RJyA+/Bx2fDh5J4HSkBus3wbM6poGvU2hjzmPCuCFKyW1Q95JqGLBvXmmuM9Tk nuxuKl16N6FdozNuMA07dg/dcgLuPucpWhynvjUjx3HsLm6ArXuSdkqTdpSuBVxGxWvi WHEg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We need to shift the values up, otherwise we'd end up with a negative shift. This works for up-to 16-bit components, which is fine for now. Signed-off-by: Ilia Mirkin --- tests/util/pattern.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index c84fee5a..8bdebd2c 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -60,11 +60,22 @@ struct color_yuv { .u = MAKE_YUV_601_U(r, g, b), \ .v = MAKE_YUV_601_V(r, g, b) } +static inline uint32_t shiftcolor(const struct util_color_component *comp, + uint32_t value) +{ + /* Fill the low bits with the high bits. */ + value = (value << 8) | value; + /* Shift down to remove unwanted low bits */ + value = value >> (16 - comp->length); + /* Shift back up to where the value should be */ + return value << comp->offset; +} + #define MAKE_RGBA(rgb, r, g, b, a) \ - ((((r) >> (8 - (rgb)->red.length)) << (rgb)->red.offset) | \ - (((g) >> (8 - (rgb)->green.length)) << (rgb)->green.offset) | \ - (((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \ - (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset)) + (shiftcolor(&(rgb)->red, (r)) | \ + shiftcolor(&(rgb)->green, (g)) | \ + shiftcolor(&(rgb)->blue, (b)) | \ + shiftcolor(&(rgb)->alpha, (a))) #define MAKE_RGB24(rgb, r, g, b) \ { .value = MAKE_RGBA(rgb, r, g, b, 0) }