From patchwork Mon Jun 3 00:40:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10972059 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 4D5BC13AD for ; Mon, 3 Jun 2019 00:40:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E48C28800 for ; Mon, 3 Jun 2019 00:40:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32CC32883A; Mon, 3 Jun 2019 00:40:37 +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 C58D628800 for ; Mon, 3 Jun 2019 00:40:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4C54897D7; Mon, 3 Jun 2019 00:40:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by gabe.freedesktop.org (Postfix) with ESMTPS id DC842897C5 for ; Mon, 3 Jun 2019 00:40:27 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id i34so7503781qta.6 for ; Sun, 02 Jun 2019 17:40:27 -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=mVL1WCiSjeLzl8BTmIYztgHEm9zwtBHSZil94Z8BG+8=; b=EJXQzYHbE/eQoXNDjGUXu8dTYxGlqUedW+LvKlLr6jzYFWl2h4jtwBq+I0g+s6BODp 2ji8Jz2z2uXNDmJLkKVUTlPyQBDqN5oXfPbpv5rp2Ok6O/LFh9Z4uSj0UCtGPa8GKZmb MBY/wFH/J4ZPZjSBHIWwMzJ5qbVUy0CBn7t1eBPAnQ5asBpsnggULrJJQBo15ENcwIBY tYGl/psNhrkJNP0yC46JBjAYTnq6dLdjiFOZFPzjN9/qo3k5OctjpNxd4EaGbqv4sxM7 oCCxNn8J19ACAgTW9gGaBci1okxIY+ZNgepXqGalXba6CJaiN+gAd3n9AQVQeX4zs1+p tamg== X-Gm-Message-State: APjAAAVr3H2KjZ6ltvJVQCgaqf/RMFdCCO9s700M3lUXZxTSMaDWKnfx o01+PDukdFiZ0MfdOmSg4W7QUVWsvok= X-Google-Smtp-Source: APXvYqwpDis5eoQhId3RdaHIeGbKOSmZp5OgNq2yDDNhxfcGdNXbJCwRcjMSunHjayCiuNEZHe3SUQ== X-Received: by 2002:a0c:ae4c:: with SMTP id z12mr5414135qvc.162.1559522426872; Sun, 02 Jun 2019 17:40:26 -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.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 17:40:26 -0700 (PDT) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 01/10] util: add C8 format, support it with SMPTE pattern Date: Sun, 2 Jun 2019 20:40:09 -0400 Message-Id: <20190603004017.7114-2-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=mVL1WCiSjeLzl8BTmIYztgHEm9zwtBHSZil94Z8BG+8=; b=NpGMKPZ3VBACN9jn5tdd97DKuYTVOVx1A3D4hT1CL5PIp/Tm25H9H3AmHfc6LfjSVq IO4OYgP0j7Gy9Kvnhdgjm+cJuXVMwredh/BbNs97hZ90qgi1w0WEZt3p5Ec1Qh0iKii7 ABoYa1W4E4SsnVGZAN6sfucAwGx9HbD3JEy09ppoCkwblJoyWYZKBMKchcZVm8ht/LaV uCLY2Cxtgr2r/0C8674C4akiHavMPyWulQJLgOOYuaaGkIWC+7IGGYg+Q7RgMHBhjIcy fEMazREUkZamwsBoxaGl4NJTglhaPu8c8jNIfIHodhvLjfjc8O4pJzBBo/m67HLPzDpp Ja2g== 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 This also adds a helper to generate a color LUT, which has to be used in conjunction with the C8 indexed format. Signed-off-by: Ilia Mirkin --- tests/util/format.c | 2 ++ tests/util/pattern.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ tests/util/pattern.h | 4 +++ 3 files changed, 81 insertions(+) diff --git a/tests/util/format.c b/tests/util/format.c index 15ac5e1e..e52213bb 100644 --- a/tests/util/format.c +++ b/tests/util/format.c @@ -39,6 +39,8 @@ .yuv = { (order), (xsub), (ysub), (chroma_stride) } static const struct util_format_info format_info[] = { + /* Indexed */ + { DRM_FORMAT_C8, "C8" }, /* YUV packed */ { DRM_FORMAT_UYVY, "UYVY", MAKE_YUV_INFO(YUV_YCbCr | YUV_CY, 2, 2, 2) }, { DRM_FORMAT_VYUY, "VYUY", MAKE_YUV_INFO(YUV_YCrCb | YUV_CY, 2, 2, 2) }, diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 9fa0a417..c84fee5a 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -457,6 +457,79 @@ static void fill_smpte_rgb32(const struct util_rgb_info *rgb, void *mem, } } +static void fill_smpte_c8(void *mem, unsigned int width, unsigned int height, + unsigned int stride) +{ + unsigned int x; + unsigned int y; + + for (y = 0; y < height * 6 / 9; ++y) { + for (x = 0; x < width; ++x) + ((uint8_t *)mem)[x] = x * 7 / width; + mem += stride; + } + + for (; y < height * 7 / 9; ++y) { + for (x = 0; x < width; ++x) + ((uint8_t *)mem)[x] = 7 + (x * 7 / width); + mem += stride; + } + + for (; y < height; ++y) { + for (x = 0; x < width * 5 / 7; ++x) + ((uint8_t *)mem)[x] = + 14 + (x * 4 / (width * 5 / 7)); + for (; x < width * 6 / 7; ++x) + ((uint8_t *)mem)[x] = + 14 + ((x - width * 5 / 7) * 3 + / (width / 7) + 4); + for (; x < width; ++x) + ((uint8_t *)mem)[x] = 14 + 7; + mem += stride; + } +} + +void util_smpte_c8_gamma(unsigned size, struct drm_color_lut *lut) +{ + if (size < 7 + 7 + 8) { + printf("Error: gamma too small: %d < %d\n", size, 7 + 7 + 8); + return; + } + memset(lut, size * sizeof(struct drm_color_lut), 0); + +#define FILL_COLOR(idx, r, g, b) \ + lut[idx].red = (r) << 8; \ + lut[idx].green = (g) << 8; \ + lut[idx].blue = (b) << 8 + + FILL_COLOR( 0, 192, 192, 192); /* grey */ + FILL_COLOR( 1, 192, 192, 0 ); /* yellow */ + FILL_COLOR( 2, 0, 192, 192); /* cyan */ + FILL_COLOR( 3, 0, 192, 0 ); /* green */ + FILL_COLOR( 4, 192, 0, 192); /* magenta */ + FILL_COLOR( 5, 192, 0, 0 ); /* red */ + FILL_COLOR( 6, 0, 0, 192); /* blue */ + + FILL_COLOR( 7, 0, 0, 192); /* blue */ + FILL_COLOR( 8, 19, 19, 19 ); /* black */ + FILL_COLOR( 9, 192, 0, 192); /* magenta */ + FILL_COLOR(10, 19, 19, 19 ); /* black */ + FILL_COLOR(11, 0, 192, 192); /* cyan */ + FILL_COLOR(12, 19, 19, 19 ); /* black */ + FILL_COLOR(13, 192, 192, 192); /* grey */ + + FILL_COLOR(14, 0, 33, 76); /* in-phase */ + FILL_COLOR(15, 255, 255, 255); /* super white */ + FILL_COLOR(16, 50, 0, 106); /* quadrature */ + FILL_COLOR(17, 19, 19, 19); /* black */ + FILL_COLOR(18, 9, 9, 9); /* 3.5% */ + FILL_COLOR(19, 19, 19, 19); /* 7.5% */ + FILL_COLOR(20, 29, 29, 29); /* 11.5% */ + FILL_COLOR(21, 19, 19, 19); /* black */ + +#undef FILL_COLOR +} + static void fill_smpte(const struct util_format_info *info, void *planes[3], unsigned int width, unsigned int height, unsigned int stride) @@ -464,6 +537,8 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3], unsigned char *u, *v; switch (info->format) { + case DRM_FORMAT_C8: + return fill_smpte_c8(planes[0], width, height, stride); case DRM_FORMAT_UYVY: case DRM_FORMAT_VYUY: case DRM_FORMAT_YUYV: diff --git a/tests/util/pattern.h b/tests/util/pattern.h index d5c4260c..c8708d02 100644 --- a/tests/util/pattern.h +++ b/tests/util/pattern.h @@ -26,6 +26,8 @@ #ifndef UTIL_PATTERN_H #define UTIL_PATTERN_H +#include + enum util_fill_pattern { UTIL_PATTERN_TILES, UTIL_PATTERN_PLAIN, @@ -36,4 +38,6 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, void *planes[3], unsigned int width, unsigned int height, unsigned int stride); +void util_smpte_c8_gamma(unsigned size, struct drm_color_lut *lut); + #endif /* UTIL_PATTERN_H */ 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) } From patchwork Mon Jun 3 00:40:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10972061 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 34F3F14C0 for ; Mon, 3 Jun 2019 00:40:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2521C28800 for ; Mon, 3 Jun 2019 00:40:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 195C52883A; Mon, 3 Jun 2019 00:40:39 +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 9755A28800 for ; Mon, 3 Jun 2019 00:40:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9AA1E89146; Mon, 3 Jun 2019 00:40:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by gabe.freedesktop.org (Postfix) with ESMTPS id B1AFF897D4 for ; Mon, 3 Jun 2019 00:40:29 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id z24so375398qtj.10 for ; Sun, 02 Jun 2019 17:40:29 -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=Jl08X09J5WaG5rButew5EplcjqlT6CYTrRnJ2xlwRL0=; b=Kjo7QlGxL2BGB03P8SNOgWBxwIxnhRlEGwhARBIAhbalBfP6JEnG7Yyq8ywyowm1To zEaH7T00tgoeP2xVHv1/S7V08STGcw17MD2xv/K9HwW+FUgAOlNeVNStY9AzaWuyjL95 EEdGloGnRMF2NSrq0IooD4H/fbRL4rUVFCYZZeh164R19CO3iJJZah+JjyWixZLZpYVA MotBjdz1WLjHT6kyfPd64kJkM+sYpzIW4SkrwLJK+pd7Sjsg1pzvq36ft5Ar2W97iMFk Asm5cgk/Z3zDPYgFad9/GNx4u2YH2bk7y7ZsJvOip/ufL5qhhwy8f3Xau2Ng31+aVGqq mcaA== X-Gm-Message-State: APjAAAUYCUjd5kKH/av6APYBOPpUqOBrhiGLO/5Joh2qaMON3E6HZWDz ZRE8u6dKRFjipFN2jOjUbj7C2dbnPsQ= X-Google-Smtp-Source: APXvYqyZCCKILabXXc3/sZpwxd0fCIKDf05qvdNZx25q9O0yecRA+lfmcnf64Rl9V9XrnPHyeFvnxg== X-Received: by 2002:a0c:f68e:: with SMTP id p14mr7754142qvn.172.1559522428698; Sun, 02 Jun 2019 17:40:28 -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.27 (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 03/10] util: add gradient pattern Date: Sun, 2 Jun 2019 20:40:11 -0400 Message-Id: <20190603004017.7114-4-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=Jl08X09J5WaG5rButew5EplcjqlT6CYTrRnJ2xlwRL0=; b=oL4f8Nu5iZ3AadDSgsbeE94jg0yuaLfAqilnGk4KyNE70BQdCrRiJEPsjw3AVVcBRY acAI9+NH/9KQaeMWbWmULxEWhuKP+WQg0HxP8KAERajAR8qXDz6toic4TqG/75eETmw2 /aFPO84I2rYslA2DJvdec+uax0pmU3wMyXQYqzovtWvZ5sAJxMdJX8USHKVSbvG7I+Nl oOe/6McRNv36OGqyezRL+1OLZsNxmMyNnouUkN76LDg0mg6gV0DxU0SBc9neMLJJRnht XVzqoTatJnUE8PJY9CHlRK22wGLaSnYaFAVjx0m7FfeGsGuB+qGv3PrE/xzQzatgOUMs xV+g== 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 The idea is to have a horizontal pattern split into two with the top and bottom halves having different precision. This allows one to see whether 10bpc support is working properly or not, as there are many pieces to the puzzle beyond the basic format support (gamma ramps, bpc encodings, etc). This is really only useful on 10bpc formats, but we also add support for 8bpc formats to ease testing. In the future, this could be applied to 16bpc formats as well. Signed-off-by: Ilia Mirkin --- tests/util/pattern.c | 113 +++++++++++++++++++++++++++++++++++++++++-- tests/util/pattern.h | 1 + 2 files changed, 109 insertions(+), 5 deletions(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 8bdebd2c..ff110fd7 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -60,9 +60,11 @@ 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, +/* This function takes 8-bit color values */ +static inline uint32_t shiftcolor8(const struct util_color_component *comp, uint32_t value) { + value &= 0xff; /* Fill the low bits with the high bits. */ value = (value << 8) | value; /* Shift down to remove unwanted low bits */ @@ -71,11 +73,30 @@ static inline uint32_t shiftcolor(const struct util_color_component *comp, return value << comp->offset; } +/* This function takes 10-bit color values */ +static inline uint32_t shiftcolor10(const struct util_color_component *comp, + uint32_t value) +{ + value &= 0x3ff; + /* Fill the low bits with the high bits. */ + value = (value << 6) | (value >> 4); + /* 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_RGBA10(rgb, r, g, b, a) \ + (shiftcolor10(&(rgb)->red, (r)) | \ + shiftcolor10(&(rgb)->green, (g)) | \ + shiftcolor10(&(rgb)->blue, (b)) | \ + shiftcolor10(&(rgb)->alpha, (a))) + #define MAKE_RGBA(rgb, r, g, b, a) \ - (shiftcolor(&(rgb)->red, (r)) | \ - shiftcolor(&(rgb)->green, (g)) | \ - shiftcolor(&(rgb)->blue, (b)) | \ - shiftcolor(&(rgb)->alpha, (a))) + (shiftcolor8(&(rgb)->red, (r)) | \ + shiftcolor8(&(rgb)->green, (g)) | \ + shiftcolor8(&(rgb)->blue, (b)) | \ + shiftcolor8(&(rgb)->alpha, (a))) #define MAKE_RGB24(rgb, r, g, b) \ { .value = MAKE_RGBA(rgb, r, g, b, 0) } @@ -912,6 +933,85 @@ static void fill_plain(void *planes[3], memset(planes[0], 0x77, stride * height); } +static void fill_gradient_rgb32(const struct util_rgb_info *rgb, + void *mem, + unsigned int width, unsigned int height, + unsigned int stride) +{ + int i, j; + + for (i = 0; i < height / 2; i++) { + uint32_t *row = mem; + + for (j = 0; j < width / 2; j++) { + uint32_t value = MAKE_RGBA10(rgb, j & 0x3ff, j & 0x3ff, j & 0x3ff, 0); + row[2*j] = row[2*j+1] = value; + } + mem += stride; + } + + for (; i < height; i++) { + uint32_t *row = mem; + + for (j = 0; j < width / 2; j++) { + uint32_t value = MAKE_RGBA10(rgb, j & 0x3fc, j & 0x3fc, j & 0x3fc, 0); + row[2*j] = row[2*j+1] = value; + } + mem += stride; + } +} + +/* The gradient pattern creates two horizontal gray gradients, split + * into two halves. The top half has 10bpc precision, the bottom half + * has 8bpc precision. When using with a 10bpc fb format, there are 3 + * possible outcomes: + * + * - Pixel data is encoded as 8bpc to the display, no dithering. This + * would lead to the top and bottom halves looking identical. + * + * - Pixel data is encoded as 8bpc to the display, with dithering. This + * would lead to there being a visible difference between the two halves, + * but the top half would look a little speck-y due to the dithering. + * + * - Pixel data is encoded at 10bpc+ to the display (which implies + * the display is able to show this level of depth). This should + * lead to the top half being a very clean gradient, and visibly different + * from the bottom half. + * + * Once we support additional fb formats, this approach could be extended + * to distinguish even higher bpc precisions. + * + * Note that due to practical size considerations, for the screens + * where this matters, the pattern actually emits stripes 2-pixels + * wide for each gradient color. Otherwise the difference may be a bit + * hard to notice. + */ +static void fill_gradient(const struct util_format_info *info, void *planes[3], + unsigned int width, unsigned int height, + unsigned int stride) +{ + switch (info->format) { + case DRM_FORMAT_ARGB8888: + case DRM_FORMAT_XRGB8888: + case DRM_FORMAT_ABGR8888: + case DRM_FORMAT_XBGR8888: + case DRM_FORMAT_RGBA8888: + case DRM_FORMAT_RGBX8888: + case DRM_FORMAT_BGRA8888: + case DRM_FORMAT_BGRX8888: + case DRM_FORMAT_ARGB2101010: + case DRM_FORMAT_XRGB2101010: + case DRM_FORMAT_ABGR2101010: + case DRM_FORMAT_XBGR2101010: + case DRM_FORMAT_RGBA1010102: + case DRM_FORMAT_RGBX1010102: + case DRM_FORMAT_BGRA1010102: + case DRM_FORMAT_BGRX1010102: + return fill_gradient_rgb32(&info->rgb, planes[0], + width, height, stride); + } +} + /* * util_fill_pattern - Fill a buffer with a test pattern * @format: Pixel format @@ -944,6 +1044,9 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, case UTIL_PATTERN_PLAIN: return fill_plain(planes, height, stride); + case UTIL_PATTERN_GRADIENT: + return fill_gradient(info, planes, width, height, stride); + default: printf("Error: unsupported test pattern %u.\n", pattern); break; diff --git a/tests/util/pattern.h b/tests/util/pattern.h index c8708d02..feac903a 100644 --- a/tests/util/pattern.h +++ b/tests/util/pattern.h @@ -32,6 +32,7 @@ enum util_fill_pattern { UTIL_PATTERN_TILES, UTIL_PATTERN_PLAIN, UTIL_PATTERN_SMPTE, + UTIL_PATTERN_GRADIENT, }; void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, From patchwork Mon Jun 3 00:40:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10972063 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 01BB314C0 for ; Mon, 3 Jun 2019 00:40:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5E5D28800 for ; Mon, 3 Jun 2019 00:40:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8FFD2883A; Mon, 3 Jun 2019 00:40:40 +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 2351528800 for ; Mon, 3 Jun 2019 00:40:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A81489182; Mon, 3 Jun 2019 00:40:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6A65897D4 for ; Mon, 3 Jun 2019 00:40:30 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id z24so375433qtj.10 for ; Sun, 02 Jun 2019 17:40:30 -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=YzAv3mAvLxprkb9QX0h51MolPj18jWcuQkJBtxJRZnQ=; b=tu8Xe0pT7u3PVVug85Avzqfx8FbG7a8dK7eEKJEXEFGs8qFGCm/gfS6Fia4lUXrTd0 MXV/I3WFV8Z0BtSJhzI5rufHRoec6i8I32gih/tOmPEa5kCC4aUzKJ8gOmb4Mnch54xk u/hXFh4m8vRcA5R/Ish3xPPw6M73UqvgdpvRRBgxxopPhF+u42RdO0uI8hhd/j2UMt9F 7+i1/3GDvmJ3O/SuXTq6c0YREeieP6Qs34tZM70o4i0udGMsNpjt4lpsEHLuw9MLccxx Ip0fZ8x/uvZum44suMu3vQ22PMIhGcVeJlA6I4tvbSDDtYVtDtZUW4Gyf7dpcksQErX4 GJwg== X-Gm-Message-State: APjAAAWmvJbP+gemffG5e5/SaQVT5bYaeJnVoptZMta6obyech7OL+fv sKQ7WUkDKolUHs63RW9YOa7n5ov/oK4= X-Google-Smtp-Source: APXvYqyeWm4Gpbuo44KEHTJvexaqU9256bfTuIHEHcJpDmaEN4aGZMqfItHaOzCQzG/yGFHe16z4Yw== X-Received: by 2002:ac8:5315:: with SMTP id t21mr10833470qtn.229.1559522429547; Sun, 02 Jun 2019 17:40:29 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 17:40:28 -0700 (PDT) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 04/10] util: add fp16 format support Date: Sun, 2 Jun 2019 20:40:12 -0400 Message-Id: <20190603004017.7114-5-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=YzAv3mAvLxprkb9QX0h51MolPj18jWcuQkJBtxJRZnQ=; b=GVkE/fs41IFOjtCNxmfxz7s+LySQZ7q33WVQGRav66h63/m8MREtQzfTr1AMZKf3AX uMHmOCR19wsKKTZgc5Gmn45kLhtyJDLoLUCn5gbTUaai90aP6MPjo232f94Wxp1/4f7s W81PaBIkVydUPs7os2PKR8MQG2A85xfadFvS7EfORC5nIRL/BE+eAph4ctemA22noXDB rYZvbicnPnz1/8njb1TmRevhxZNgidSCCOUhiglD7iAewLkdS+uZJIm5nqYfEuQKcZSE 1FTwNSEpUsC5mR70KSuFXT537bKlu7RJ4n+cYgpOqMWxHOFd8xYRJXZ9I6d7DcMJnc+i NYDA== 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 This change adds support for all current patterns. Signed-off-by: Ilia Mirkin --- tests/util/format.c | 5 ++ tests/util/pattern.c | 207 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 209 insertions(+), 3 deletions(-) diff --git a/tests/util/format.c b/tests/util/format.c index e52213bb..1ca1b82c 100644 --- a/tests/util/format.c +++ b/tests/util/format.c @@ -93,6 +93,11 @@ static const struct util_format_info format_info[] = { { DRM_FORMAT_RGBX1010102, "RX30", MAKE_RGB_INFO(10, 22, 10, 12, 10, 2, 0, 0) }, { DRM_FORMAT_BGRA1010102, "BA30", MAKE_RGB_INFO(10, 2, 10, 12, 10, 22, 2, 0) }, { DRM_FORMAT_BGRX1010102, "BX30", MAKE_RGB_INFO(10, 2, 10, 12, 10, 22, 0, 0) }, + { DRM_FORMAT_XRGB16161616F, "XR4H", MAKE_RGB_INFO(16, 32, 16, 16, 16, 0, 0, 0) }, + { DRM_FORMAT_XBGR16161616F, "XB4H", MAKE_RGB_INFO(16, 0, 16, 16, 16, 32, 0, 0) }, + { DRM_FORMAT_ARGB16161616F, "AR4H", MAKE_RGB_INFO(16, 32, 16, 16, 16, 0, 16, 48) }, + { DRM_FORMAT_ABGR16161616F, "AB4H", MAKE_RGB_INFO(16, 0, 16, 16, 16, 32, 16, 48) }, + }; uint32_t util_format_fourcc(const char *name) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index ff110fd7..37796dbf 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -86,6 +86,17 @@ static inline uint32_t shiftcolor10(const struct util_color_component *comp, return value << comp->offset; } +/* This function takes 16-bit color values */ +static inline uint64_t shiftcolor16(const struct util_color_component *comp, + uint64_t value) +{ + value &= 0xffff; + /* 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_RGBA10(rgb, r, g, b, a) \ (shiftcolor10(&(rgb)->red, (r)) | \ shiftcolor10(&(rgb)->green, (g)) | \ @@ -101,6 +112,49 @@ static inline uint32_t shiftcolor10(const struct util_color_component *comp, #define MAKE_RGB24(rgb, r, g, b) \ { .value = MAKE_RGBA(rgb, r, g, b, 0) } + +/** + * Takes a uint16_t, divides by 65536, converts the infinite-precision + * result to fp16 with round-to-zero. + * + * Copied from mesa:src/util/half_float.c + */ +static uint16_t uint16_div_64k_to_half(uint16_t v) +{ + /* Zero or subnormal. Set the mantissa to (v << 8) and return. */ + if (v < 4) + return v << 8; + + /* Count the leading 0s in the uint16_t */ + int n = __builtin_clz(v) - 16; + + /* Shift the mantissa up so bit 16 is the hidden 1 bit, + * mask it off, then shift back down to 10 bits + */ + int m = ( ((uint32_t)v << (n + 1)) & 0xffff ) >> 6; + + /* (0{n} 1 X{15-n}) * 2^-16 + * = 1.X * 2^(15-n-16) + * = 1.X * 2^(14-n - 15) + * which is the FP16 form with e = 14 - n + */ + int e = 14 - n; + + return (e << 10) | m; +} + +#define MAKE_RGBA8FP16(rgb, r, g, b, a) \ + (shiftcolor16(&(rgb)->red, uint16_div_64k_to_half((r) << 8)) | \ + shiftcolor16(&(rgb)->green, uint16_div_64k_to_half((g) << 8)) | \ + shiftcolor16(&(rgb)->blue, uint16_div_64k_to_half((b) << 8)) | \ + shiftcolor16(&(rgb)->alpha, uint16_div_64k_to_half((a) << 8))) + +#define MAKE_RGBA10FP16(rgb, r, g, b, a) \ + (shiftcolor16(&(rgb)->red, uint16_div_64k_to_half((r) << 6)) | \ + shiftcolor16(&(rgb)->green, uint16_div_64k_to_half((g) << 6)) | \ + shiftcolor16(&(rgb)->blue, uint16_div_64k_to_half((b) << 6)) | \ + shiftcolor16(&(rgb)->alpha, uint16_div_64k_to_half((a) << 6))) + static void fill_smpte_yuv_planar(const struct util_yuv_info *yuv, unsigned char *y_mem, unsigned char *u_mem, unsigned char *v_mem, unsigned int width, @@ -489,6 +543,67 @@ static void fill_smpte_rgb32(const struct util_rgb_info *rgb, void *mem, } } +static void fill_smpte_rgb16fp(const struct util_rgb_info *rgb, void *mem, + unsigned int width, unsigned int height, + unsigned int stride) +{ + const uint64_t colors_top[] = { + MAKE_RGBA8FP16(rgb, 192, 192, 192, 255),/* grey */ + MAKE_RGBA8FP16(rgb, 192, 192, 0, 255), /* yellow */ + MAKE_RGBA8FP16(rgb, 0, 192, 192, 255), /* cyan */ + MAKE_RGBA8FP16(rgb, 0, 192, 0, 255), /* green */ + MAKE_RGBA8FP16(rgb, 192, 0, 192, 255), /* magenta */ + MAKE_RGBA8FP16(rgb, 192, 0, 0, 255), /* red */ + MAKE_RGBA8FP16(rgb, 0, 0, 192, 255), /* blue */ + }; + const uint64_t colors_middle[] = { + MAKE_RGBA8FP16(rgb, 0, 0, 192, 127), /* blue */ + MAKE_RGBA8FP16(rgb, 19, 19, 19, 127), /* black */ + MAKE_RGBA8FP16(rgb, 192, 0, 192, 127), /* magenta */ + MAKE_RGBA8FP16(rgb, 19, 19, 19, 127), /* black */ + MAKE_RGBA8FP16(rgb, 0, 192, 192, 127), /* cyan */ + MAKE_RGBA8FP16(rgb, 19, 19, 19, 127), /* black */ + MAKE_RGBA8FP16(rgb, 192, 192, 192, 127),/* grey */ + }; + const uint64_t colors_bottom[] = { + MAKE_RGBA8FP16(rgb, 0, 33, 76, 255), /* in-phase */ + MAKE_RGBA8FP16(rgb, 255, 255, 255, 255),/* super white */ + MAKE_RGBA8FP16(rgb, 50, 0, 106, 255), /* quadrature */ + MAKE_RGBA8FP16(rgb, 19, 19, 19, 255), /* black */ + MAKE_RGBA8FP16(rgb, 9, 9, 9, 255), /* 3.5% */ + MAKE_RGBA8FP16(rgb, 19, 19, 19, 255), /* 7.5% */ + MAKE_RGBA8FP16(rgb, 29, 29, 29, 255), /* 11.5% */ + MAKE_RGBA8FP16(rgb, 19, 19, 19, 255), /* black */ + }; + unsigned int x; + unsigned int y; + + for (y = 0; y < height * 6 / 9; ++y) { + for (x = 0; x < width; ++x) + ((uint64_t *)mem)[x] = colors_top[x * 7 / width]; + mem += stride; + } + + for (; y < height * 7 / 9; ++y) { + for (x = 0; x < width; ++x) + ((uint64_t *)mem)[x] = colors_middle[x * 7 / width]; + mem += stride; + } + + for (; y < height; ++y) { + for (x = 0; x < width * 5 / 7; ++x) + ((uint64_t *)mem)[x] = + colors_bottom[x * 4 / (width * 5 / 7)]; + for (; x < width * 6 / 7; ++x) + ((uint64_t *)mem)[x] = + colors_bottom[(x - width * 5 / 7) * 3 + / (width / 7) + 4]; + for (; x < width; ++x) + ((uint64_t *)mem)[x] = colors_bottom[7]; + mem += stride; + } +} + static void fill_smpte_c8(void *mem, unsigned int width, unsigned int height, unsigned int stride) { @@ -638,6 +753,13 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_BGRX1010102: return fill_smpte_rgb32(&info->rgb, planes[0], width, height, stride); + + case DRM_FORMAT_XRGB16161616F: + case DRM_FORMAT_XBGR16161616F: + case DRM_FORMAT_ARGB16161616F: + case DRM_FORMAT_ABGR16161616F: + return fill_smpte_rgb16fp(&info->rgb, planes[0], + width, height, stride); } } @@ -849,6 +971,32 @@ static void fill_tiles_rgb32(const struct util_format_info *info, void *mem, make_pwetty(mem_base, width, height, stride, info->format); } +static void fill_tiles_rgb16fp(const struct util_format_info *info, void *mem, + unsigned int width, unsigned int height, + unsigned int stride) +{ + const struct util_rgb_info *rgb = &info->rgb; + void *mem_base = mem; + unsigned int x, y; + + /* TODO: Give this actual fp16 precision */ + for (y = 0; y < height; ++y) { + for (x = 0; x < width; ++x) { + div_t d = div(x+y, width); + uint32_t rgb32 = 0x00130502 * (d.quot >> 6) + + 0x000a1120 * (d.rem >> 6); + uint32_t alpha = ((y < height/2) && (x < width/2)) ? 127 : 255; + uint64_t color = + MAKE_RGBA8FP16(rgb, (rgb32 >> 16) & 0xff, + (rgb32 >> 8) & 0xff, rgb32 & 0xff, + alpha); + + ((uint64_t *)mem)[x] = color; + } + mem += stride; + } +} + static void fill_tiles(const struct util_format_info *info, void *planes[3], unsigned int width, unsigned int height, unsigned int stride) @@ -923,14 +1071,32 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_BGRX1010102: return fill_tiles_rgb32(info, planes[0], width, height, stride); + + case DRM_FORMAT_XRGB16161616F: + case DRM_FORMAT_XBGR16161616F: + case DRM_FORMAT_ARGB16161616F: + case DRM_FORMAT_ABGR16161616F: + return fill_tiles_rgb16fp(info, planes[0], + width, height, stride); } } -static void fill_plain(void *planes[3], +static void fill_plain(const struct util_format_info *info, void *planes[3], unsigned int height, unsigned int stride) { - memset(planes[0], 0x77, stride * height); + switch (info->format) { + case DRM_FORMAT_XRGB16161616F: + case DRM_FORMAT_XBGR16161616F: + case DRM_FORMAT_ARGB16161616F: + case DRM_FORMAT_ABGR16161616F: + /* 0x3838 = 0.5273 */ + memset(planes[0], 0x38, stride * height); + break; + default: + memset(planes[0], 0x77, stride * height); + break; + } } static void fill_gradient_rgb32(const struct util_rgb_info *rgb, @@ -961,6 +1127,34 @@ static void fill_gradient_rgb32(const struct util_rgb_info *rgb, } } +static void fill_gradient_rgb16fp(const struct util_rgb_info *rgb, + void *mem, + unsigned int width, unsigned int height, + unsigned int stride) +{ + int i, j; + + for (i = 0; i < height / 2; i++) { + uint64_t *row = mem; + + for (j = 0; j < width / 2; j++) { + uint64_t value = MAKE_RGBA10FP16(rgb, j & 0x3ff, j & 0x3ff, j & 0x3ff, 0); + row[2*j] = row[2*j+1] = value; + } + mem += stride; + } + + for (; i < height; i++) { + uint64_t *row = mem; + + for (j = 0; j < width / 2; j++) { + uint64_t value = MAKE_RGBA10FP16(rgb, j & 0x3fc, j & 0x3fc, j & 0x3fc, 0); + row[2*j] = row[2*j+1] = value; + } + mem += stride; + } +} + /* The gradient pattern creates two horizontal gray gradients, split * into two halves. The top half has 10bpc precision, the bottom half * has 8bpc precision. When using with a 10bpc fb format, there are 3 @@ -1009,6 +1203,13 @@ static void fill_gradient(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_BGRX1010102: return fill_gradient_rgb32(&info->rgb, planes[0], width, height, stride); + + case DRM_FORMAT_XRGB16161616F: + case DRM_FORMAT_XBGR16161616F: + case DRM_FORMAT_ARGB16161616F: + case DRM_FORMAT_ABGR16161616F: + return fill_gradient_rgb16fp(&info->rgb, planes[0], + width, height, stride); } } @@ -1042,7 +1243,7 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, return fill_smpte(info, planes, width, height, stride); case UTIL_PATTERN_PLAIN: - return fill_plain(planes, height, stride); + return fill_plain(info, planes, height, stride); case UTIL_PATTERN_GRADIENT: return fill_gradient(info, planes, width, height, stride); From patchwork Mon Jun 3 00:40:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10972065 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 E228513AD for ; Mon, 3 Jun 2019 00:40:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D42AC28800 for ; Mon, 3 Jun 2019 00:40:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C87F12883A; Mon, 3 Jun 2019 00:40:41 +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 932EF28832 for ; Mon, 3 Jun 2019 00:40:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EE64891AD; Mon, 3 Jun 2019 00:40:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D4F788E38 for ; Mon, 3 Jun 2019 00:40:31 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id z19so7474330qtz.13 for ; Sun, 02 Jun 2019 17:40:31 -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=lIh61OjDuOcWtLUnuz9frfgmzrtE9Yjc5UwT3oKcfeo=; b=X+1Xoz57t2YxYAQX6sDfbiVbXSiT2cFRX5BQxqQKgkWyO42NyaHkai364JZv7CPVSB Lj22gP3Ja9a+FmjGDshEdbIl2HQ+9+hWdKfdPsBsXmZylJSgSpRKEO7Zx1quJuOlITnk I/WqO87LCm6h1nC7DF6DktHB4K6kjLrSHH+yCM1n+wD9W7fv3QX0JYTRF+zzFxdPGa0i cB9UpouYhxgvnI7YnVes7CNFhBjYnprOVLWAcfLZsbQeUM5jxJ1qtTfFXuS69c5b6WgT WBojUeyg9CkbZaPDRBjy7IJQED7baiOE/wnhN5Womf20rWrmq3oGfVInid4RGWOu0woH Y69Q== X-Gm-Message-State: APjAAAXeFukvjTni2r+Pgaah6mqZhh+Bfn4eGi5SCS3wI7ne/EZKgWgx 1Ws8wYS+kKAKcwSKvu4o3YByvA5OVnE= X-Google-Smtp-Source: APXvYqxOlLn+OjDDZts83x+KSZgz9X415NmGXvJPtAntoBiNxySHhlQ+22AEdeSzIqk8yohMq5rVqQ== X-Received: by 2002:ac8:23f2:: with SMTP id r47mr9786979qtr.261.1559522430149; Sun, 02 Jun 2019 17:40:30 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 17:40:29 -0700 (PDT) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 05/10] util: add cairo drawing for 30bpp formats when available Date: Sun, 2 Jun 2019 20:40:13 -0400 Message-Id: <20190603004017.7114-6-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=lIh61OjDuOcWtLUnuz9frfgmzrtE9Yjc5UwT3oKcfeo=; b=GLsPv2b8esLRJF7FSPIzGWYpotdwGtXTjRCYSeOwNcCzyF4la9KJ31FhVhZJQe1n+I 3WHYv6km78ZbYzoxMrmj/8QScIiuYsPhfU5rq8etw7aR0VYlyNncWGUOigQIMVg3Od0h aFnookZx1omk1vZMor3TJCG/oa+zgAPCOUg5//wxuGhuI0OVD7/r6t5ldQIiXNDSui9/ 94DltlVp3ZF/9ZNnNSLQrEpVqVNIbzCXBu2LVkK7Yqb6C2W7waJ7+aC98jmP27yDhg/M rjDMmj4jwR8gM16WvFftIksilOwME7VuI0enHVFjfispuIScMftWwgYKJGYGWURMr/er cnJA== 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 Signed-off-by: Ilia Mirkin --- tests/util/pattern.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 37796dbf..d197c444 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -788,6 +788,14 @@ static void make_pwetty(void *data, unsigned int width, unsigned int height, case DRM_FORMAT_BGR565: cairo_format = CAIRO_FORMAT_RGB16_565; break; +#if CAIRO_VERSION_MAJOR > 1 || (CAIRO_VERSION_MAJOR == 1 && CAIRO_VERSION_MINOR >= 12) + case DRM_FORMAT_ARGB2101010: + case DRM_FORMAT_XRGB2101010: + case DRM_FORMAT_ABGR2101010: + case DRM_FORMAT_XBGR2101010: + cairo_format = CAIRO_FORMAT_RGB30; + break; +#endif default: return; } From patchwork Mon Jun 3 00:40:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10972067 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 75FD714C0 for ; Mon, 3 Jun 2019 00:40:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66D3228800 for ; Mon, 3 Jun 2019 00:40:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B27B2883A; Mon, 3 Jun 2019 00:40:43 +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 ECA6428800 for ; Mon, 3 Jun 2019 00:40:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF92E89179; Mon, 3 Jun 2019 00:40:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B71689179 for ; Mon, 3 Jun 2019 00:40:32 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id d23so7550390qto.2 for ; Sun, 02 Jun 2019 17:40:32 -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=/qqj0h+CJDx/iXGnddF9PrbfGue2/uZ3W4VUzaUVLgM=; b=XtgNyn1nhAATYi0GMax22//KBlCw/L9COJqFyAJFZmyLyb7YLzSd0mOhebFnc6BDWb Y+ivl50W8+bR7UriDzH2Ztxib8HqW/Yc/zVyjjwZpo8KPG/DDCmSzffT++dH+KSI6Sgc bca8k9czcjKX9raY5dT/5mlFz8ayVKAWJ3pM0aQeNFuzj1ssFV+vKaeRn4cBVIxXG2/g fYq2L4f2irQVjkB+1CuwC36pc2EROT96oV7HcJRb/T2EUnY5CExQ75hC1B1OX8htYl68 jnOucsFyGAziMdwK9H6BK0f9LCtP1I7EvpgHsgPpBgwAUU80ueNx34lTn0coaJ76kGI5 vpkw== X-Gm-Message-State: APjAAAUnZ+ixd8fRfatTz747G0s0Qrc6XLASkAv7h+ILAf0HcUHBpxmc kYFUhiuhuWdvc5TNs1VFNVVaJDYuXrg= X-Google-Smtp-Source: APXvYqx93DDKX9/PNXf6txNmTBFL2AZOUiZBTLm6EXmSLQFLwGH0I06+/Xi6dxJLuFNTTnqts537WA== X-Received: by 2002:ac8:19d8:: with SMTP id s24mr20714452qtk.44.1559522430847; Sun, 02 Jun 2019 17:40:30 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 17:40:30 -0700 (PDT) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 06/10] modetest: don't pretend that atomic mode includes a format Date: Sun, 2 Jun 2019 20:40:14 -0400 Message-Id: <20190603004017.7114-7-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=/qqj0h+CJDx/iXGnddF9PrbfGue2/uZ3W4VUzaUVLgM=; b=FABnQR/smP5+5h5dK2DnbFZi2mHjcKFtmjy+dWMqnrxn6Rumff8NWQpFozhaXp5Dv+ ue+MOxZ637B5wfqcy+Hfk09vRWXGTANhegOX0AR4Sz+aPwE80LhhdmUk4dHwEg4Mxmec 0vNhkK+3WTNIDQ/iKQICRlCc+X3bHGBBoyy/mr3Cif2GzdmixMaw7XnbuIF2suDpfJq4 qkMW0BiZiI9tx6zZ7rhdcwQHLErErJHLjGOVPRygADDGhHPlCp8ttl47FfNBpyBcU5pU MSf9aljZ3nTfCUmVj18QKgkiicMbE2kVEZa9rAW5/IVQmkCFFXjA8oIrePUZPBhLCg0b K4cQ== 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 Signed-off-by: Ilia Mirkin --- tests/modetest/modetest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 9c85c07b..a1c81f6c 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -1335,8 +1335,8 @@ static void atomic_set_mode(struct device *dev, struct pipe_arg *pipes, unsigned if (pipe->mode == NULL) continue; - printf("setting mode %s-%dHz@%s on connectors ", - pipe->mode_str, pipe->mode->vrefresh, pipe->format_str); + printf("setting mode %s-%dHz on connectors ", + pipe->mode_str, pipe->mode->vrefresh); for (j = 0; j < pipe->num_cons; ++j) { printf("%s, ", pipe->cons[j]); add_property(dev, pipe->con_ids[j], "CRTC_ID", pipe->crtc->crtc->crtc_id); From patchwork Mon Jun 3 00:40:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10972069 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 C59FF14C0 for ; Mon, 3 Jun 2019 00:40:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B664828800 for ; Mon, 3 Jun 2019 00:40:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A943128882; Mon, 3 Jun 2019 00:40:44 +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 51FF328800 for ; Mon, 3 Jun 2019 00:40:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A0FF89247; Mon, 3 Jun 2019 00:40:34 +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 124F989191 for ; Mon, 3 Jun 2019 00:40:33 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id z24so375476qtj.10 for ; Sun, 02 Jun 2019 17:40:33 -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=ATWiCr8lL4fTBAk1C1cfAB0esHAAvcQDcst3yVIin4s=; b=iXoNdMrQhgKoE4WsbAFiQb3jxAeAGCFTyjjAK0iNjPbzhpeUt3CYUuhAsnzHBebDNh /JG1EuFV8OdngMZuhwEZidNaCx1y6ZaJdtXldUP4/Ss5wmoQnlrrcUAyQK4c0ZvAE65V sAm4iD4fESVQ0vPwlFM4A1oKC3fM1Pe8Bdn+AjJki9dQS08RSQLW82RYIxuA97E6iEAW CzhKWwrRtfR2RAk/+RtrIcYpnc4uiyn2991WZ914FjzYgJKYuna0rmtQuIN3nePTA3wy LBRIXZkhuBzKhxy9zxb++bjPc4EwIolwbqf7v06YQmt7X9dZpsLiZ8ABzQtpz2FHjXJ8 nWxQ== X-Gm-Message-State: APjAAAUoRIn3PsNUmTfoNbwcLdHZPvQY/gPWgHxMtdTO+70CNKv3vJg+ XSS6TftVblJd/RP/+PEYtGqmuDDPbP0= X-Google-Smtp-Source: APXvYqyzACUPR7Clco4dekYjpFQJbxhdd1JBtX5hjwADJBD562x61O/Jbs14DPv0YEmuZnBC8zXg8A== X-Received: by 2002:ac8:1018:: with SMTP id z24mr20248871qti.206.1559522431921; Sun, 02 Jun 2019 17:40:31 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 17:40:31 -0700 (PDT) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 07/10] modetest: add an add_property_optional variant that does not print errors Date: Sun, 2 Jun 2019 20:40:15 -0400 Message-Id: <20190603004017.7114-8-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=ATWiCr8lL4fTBAk1C1cfAB0esHAAvcQDcst3yVIin4s=; b=sy0hDuxR+fyW1cz43WbymETqZgaKrj3XDPyUB1kJCTX0MqWq4bkEaz1E1LEmRAHnGz 6RIqOONbQ5v+yRWIEUUjvehD97u+1a9FWiNzl3Hkcj5siwsrvItHbHUldqyO3ZJqzhgR BzZO9hdpv0Jufd4WOOY3PNOvh4hz4gSVp95zANsxMf1OpEOpnnS+5e1AAIbT1+NvSRPW 03TBUxg/epCnxqAMF/UE3DrKdblc7qCdgb2fkEN3i0/iL/ad3jkbN9ynRob16wuoqf87 IIgX0N1DlIzBcs2BJlSIzMJXhuOGxNLJ77y94/eP7tX8VmYiKkNMFk1Q1/RGc2AMo//x mS2A== 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 As new features are added and others are declared to be legacy, it's nice to be able to implement fallbacks. As such, create a property-setting variant that does not generate errors which can very well be entirely expected. Will be used for gamma control in a future change. Signed-off-by: Ilia Mirkin --- tests/modetest/modetest.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index a1c81f6c..71ddc861 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -948,9 +948,10 @@ struct property_arg { char name[DRM_PROP_NAME_LEN+1]; uint32_t prop_id; uint64_t value; + bool optional; }; -static void set_property(struct device *dev, struct property_arg *p) +static bool set_property(struct device *dev, struct property_arg *p) { drmModeObjectProperties *props = NULL; drmModePropertyRes **props_info = NULL; @@ -982,13 +983,13 @@ static void set_property(struct device *dev, struct property_arg *p) if (p->obj_type == 0) { fprintf(stderr, "Object %i not found, can't set property\n", p->obj_id); - return; + return false; } if (!props) { fprintf(stderr, "%s %i has no properties\n", obj_type, p->obj_id); - return; + return false; } for (i = 0; i < (int)props->count_props; ++i) { @@ -999,9 +1000,10 @@ static void set_property(struct device *dev, struct property_arg *p) } if (i == (int)props->count_props) { - fprintf(stderr, "%s %i has no %s property\n", - obj_type, p->obj_id, p->name); - return; + if (!p->optional) + fprintf(stderr, "%s %i has no %s property\n", + obj_type, p->obj_id, p->name); + return false; } p->prop_id = props->props[i]; @@ -1015,6 +1017,8 @@ static void set_property(struct device *dev, struct property_arg *p) if (ret < 0) fprintf(stderr, "failed to set %s %i property %s to %" PRIu64 ": %s\n", obj_type, p->obj_id, p->name, p->value, strerror(errno)); + + return true; } /* -------------------------------------------------------------------------- */ @@ -1072,6 +1076,19 @@ static void add_property(struct device *dev, uint32_t obj_id, set_property(dev, &p); } +static bool add_property_optional(struct device *dev, uint32_t obj_id, + const char *name, uint64_t value) +{ + struct property_arg p; + + p.obj_id = obj_id; + strcpy(p.name, name); + p.value = value; + p.optional = true; + + return set_property(dev, &p); +} + static int atomic_set_plane(struct device *dev, struct plane_arg *p, int pattern, bool update) { From patchwork Mon Jun 3 00:40:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10972073 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 6D4D713AD for ; Mon, 3 Jun 2019 00:40:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E80328800 for ; Mon, 3 Jun 2019 00:40:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5303228882; Mon, 3 Jun 2019 00:40:47 +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 E5D0528800 for ; Mon, 3 Jun 2019 00:40:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3908D896C7; Mon, 3 Jun 2019 00:40:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by gabe.freedesktop.org (Postfix) with ESMTPS id E68F689191 for ; Mon, 3 Jun 2019 00:40:33 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id z19so7474399qtz.13 for ; Sun, 02 Jun 2019 17:40:33 -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=nWm8E/BeSenKr1NgV4JwOOHvVRgb/u/ID6zKIMb2uag=; b=SS3+odtz1UahicDZHL/6CIX2wYrqbRoMgNkUG1mh405QUdy7074hPXajY1Oh9Pzhr0 p+qNhmEjFhcoCICqqk+sZWF4X/vtKT1Tf0MVm1qAnx/Yc1kCl/95AosNaQoMXrq3m/16 Ne+GVv7m8Ky0gaLmEKDaDnBxtk7KuSAS6wtTy1sYIhQEuR0FAMmWspwv73iNx/e9l6W2 PDHRfEVdRziFaKGZX8AQgLGOpaxp7NLXOXMF6v+EWhC68DC8TLBctkN0KY0tRdJ3idiv VxhzfvMiItEp+czIoBxIflGbwEmdZL+1hIyr5Pms3f/nnviIjpcW15wjaUuxln/V6B6h e85w== X-Gm-Message-State: APjAAAUygIpHjimpjSrimNtCZT6dLa/WuC3q2aYvx+r30cpemGQmtrhd DZWHQgImnYUcwQSA4TTxbh4ikdMqOtI= X-Google-Smtp-Source: APXvYqzVcPkreytfev99vJXBJaU+m4i77zt2TcYHlWg1tCAbIergR34KDSHBHlA2jZxVGpZbIq2tBw== X-Received: by 2002:a0c:8c0c:: with SMTP id n12mr19771929qvb.43.1559522432753; Sun, 02 Jun 2019 17:40:32 -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.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 17:40:32 -0700 (PDT) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 08/10] modetest: add C8 support to generate SMPTE pattern Date: Sun, 2 Jun 2019 20:40:16 -0400 Message-Id: <20190603004017.7114-9-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=nWm8E/BeSenKr1NgV4JwOOHvVRgb/u/ID6zKIMb2uag=; b=D8HuW5p2+FSRqok2u2gxvkrfiIiPfEkkRXG7AkcEo6uHts1pueqGrTJErADlOUqJRg CYQWVvrP31lm+eHHLS/nvbAt0HCNZrJq67fGG+8rarPkcrbJ7I9G3BpPpCqNejuJjYyp ntGe7y8iWSLIi+gHIAUWSjGfEy1JNhSLKDRMcF7HI6trPPrrLwRypjTDvrQrCCcbtKf3 Jp4tl0gZ/LBQLrwJ2BzS56dxSkC0xCNa9V9qoTdXY9lVX2NQbwiEV/DjGFtbrd2sPQ8R otdEN8pEhpEPIya7WmtY4hvfPOosx67A36xxOulZ0TYaVPnDdkn8qq2aU4TtWu9nXVAo EpCw== 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 This includes logic to configure the LUT accordingly. Signed-off-by: Ilia Mirkin --- tests/modetest/buffers.c | 2 ++ tests/modetest/modetest.c | 47 ++++++++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c index 9b635c0c..5ec4ec8e 100644 --- a/tests/modetest/buffers.c +++ b/tests/modetest/buffers.c @@ -135,6 +135,7 @@ bo_create(int fd, unsigned int format, int ret; switch (format) { + case DRM_FORMAT_C8: case DRM_FORMAT_NV12: case DRM_FORMAT_NV21: case DRM_FORMAT_NV16: @@ -275,6 +276,7 @@ bo_create(int fd, unsigned int format, planes[2] = virtual + offsets[2]; break; + case DRM_FORMAT_C8: case DRM_FORMAT_ARGB4444: case DRM_FORMAT_XRGB4444: case DRM_FORMAT_ABGR4444: diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 71ddc861..7bb21d17 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -1089,6 +1089,42 @@ static bool add_property_optional(struct device *dev, uint32_t obj_id, return set_property(dev, &p); } +static void set_gamma(struct device *dev, unsigned crtc_id, unsigned fourcc) +{ + unsigned blob_id = 0; + /* TODO: support 1024-sized LUTs, when the use-case arises */ + struct drm_color_lut gamma_lut[256]; + int i, ret; + + if (fourcc == DRM_FORMAT_C8) { + /* TODO: Add C8 support for more patterns */ + util_smpte_c8_gamma(256, gamma_lut); + drmModeCreatePropertyBlob(dev->fd, gamma_lut, sizeof(gamma_lut), &blob_id); + } else { + for (i = 0; i < 256; i++) { + gamma_lut[i].red = + gamma_lut[i].green = + gamma_lut[i].blue = i << 8; + } + } + + add_property_optional(dev, crtc_id, "DEGAMMA_LUT", 0); + add_property_optional(dev, crtc_id, "CTM", 0); + if (!add_property_optional(dev, crtc_id, "GAMMA_LUT", blob_id)) { + uint16_t r[256], g[256], b[256]; + + for (i = 0; i < 256; i++) { + r[i] = gamma_lut[i].red; + g[i] = gamma_lut[i].green; + b[i] = gamma_lut[i].blue; + } + + ret = drmModeCrtcSetGamma(dev->fd, crtc_id, 256, r, g, b); + if (ret) + fprintf(stderr, "failed to set gamma: %s\n", strerror(errno)); + } +} + static int atomic_set_plane(struct device *dev, struct plane_arg *p, int pattern, bool update) { @@ -1270,6 +1306,8 @@ static void atomic_set_planes(struct device *dev, struct plane_arg *p, for (i = 0; i < count; i++) { if (i > 0) pattern = UTIL_PATTERN_TILES; + else + set_gamma(dev, p[i].crtc_id, p[i].fourcc); if (atomic_set_plane(dev, &p[i], pattern, update)) return; @@ -1454,6 +1492,8 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co fprintf(stderr, "failed to set mode: %s\n", strerror(errno)); return; } + + set_gamma(dev, pipe->crtc->crtc->crtc_id, pipe->fourcc); } } @@ -1728,11 +1768,8 @@ static int parse_plane(struct plane_arg *plane, const char *p) } if (*end == '@') { - p = end + 1; - if (strlen(p) != 4) - return -EINVAL; - - strcpy(plane->format_str, p); + strncpy(plane->format_str, end + 1, 4); + plane->format_str[4] = '\0'; } else { strcpy(plane->format_str, "XR24"); } From patchwork Mon Jun 3 00:40:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10972071 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 3D65D13AD for ; Mon, 3 Jun 2019 00:40:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D30028800 for ; Mon, 3 Jun 2019 00:40:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2188028882; Mon, 3 Jun 2019 00:40:46 +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 AD4C928800 for ; Mon, 3 Jun 2019 00:40:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0795A895F5; Mon, 3 Jun 2019 00:40:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by gabe.freedesktop.org (Postfix) with ESMTPS id 401E989191 for ; Mon, 3 Jun 2019 00:40:35 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id l128so10035622qke.2 for ; Sun, 02 Jun 2019 17:40:35 -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=6k/rE/AjJNEW/cdGQYufjnJB3quuN87G5qOJJmgzuho=; b=NvJ80odWGCl/GQsBD2qilI9FApYbFkLzQHatXKBr4+j/pxeWSlXR6AdsTAdmHD88YC TVKZ1b78JpnxmscR21OXVja0auDGZvBvsh+eZ522BzCdvt9EE7S/n3Mm8n7dYEAF3gRj eAy4rEuTDJsU/5iCsVVEjusqOsEtklFmSm93DfTUOczZ2770e8eNYz9OYwkx0MzHDaK6 Ypjg6JmQN2F9vqY3ALDGJEhi6X8wzZ+LCtr74zzyugPA0x642hve4TqWwqtzI9SzDlIt J9/fFFOq16WQS9PDzZyq2QOUz/nF0JwyKIm4mjYQK2smKRPobG6mH7Nwv/Yej5Ha6eif 4zNQ== X-Gm-Message-State: APjAAAU775weDMxxlZmqx0rfsJWwEZxebUI2zPJAs8GFPTr49UyTET3w OrJi27l1zhmG/BMLS0z0HtaMASdlr1c= X-Google-Smtp-Source: APXvYqxUdVTZIRA4jIM19cd66Y8OC1vC4ctzlacA9uIiG24R5yVy8VSKx43e9Pi0TAe+X3/VoXynkw== X-Received: by 2002:a37:b546:: with SMTP id e67mr611727qkf.61.1559522433622; Sun, 02 Jun 2019 17:40:33 -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.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 17:40:33 -0700 (PDT) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 09/10] modetest: add the ability to specify fill patterns on the commandline Date: Sun, 2 Jun 2019 20:40:17 -0400 Message-Id: <20190603004017.7114-10-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=6k/rE/AjJNEW/cdGQYufjnJB3quuN87G5qOJJmgzuho=; b=NccBQISscYFyIAVSWvwBupxsLkdhbLyppl75Zqggg9v+MwtnENcwBxQhDT72fnZcpT Q7WKzU7OpCp2UTotuaiCUS2S9UZmPR6xeMco1PG0aLNyOcrRDc1d6bTwF3eUh64ArreJ xuJe+fzEf3Z1hk8HyIe8gp33sa4Osac+eT84iIHNWCFUZzanR1k+tzxA78VeEui0sQii O+n2nCLFZiQJmf91YBlCsQZo9UuHVo98KbZCp7vlMFlnUneXqBvzMwJM9L0SQ/G9+235 9dvvKjqWpz+nLAK9/tzNRzZUtY91e/hA887cYLPQSPua3ygbAc8CiuiPDHCLepZOwfyf 4bdw== 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 Instead of hacking the binary every time, we can now specify directly. Signed-off-by: Ilia Mirkin --- tests/modetest/modetest.c | 29 ++++++++++++++++++++++++----- tests/util/pattern.c | 20 ++++++++++++++++++++ tests/util/pattern.h | 2 ++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 7bb21d17..e66be660 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -67,6 +67,9 @@ #include "buffers.h" #include "cursor.h" +static enum util_fill_pattern primary_fill = UTIL_PATTERN_SMPTE; +static enum util_fill_pattern secondary_fill = UTIL_PATTERN_TILES; + struct crtc { drmModeCrtc *crtc; drmModeObjectProperties *props; @@ -1259,7 +1262,7 @@ static int set_plane(struct device *dev, struct plane_arg *p) p->w, p->h, p->format_str, plane_id); plane_bo = bo_create(dev->fd, p->fourcc, p->w, p->h, handles, - pitches, offsets, UTIL_PATTERN_TILES); + pitches, offsets, secondary_fill); if (plane_bo == NULL) return -1; @@ -1300,12 +1303,12 @@ static int set_plane(struct device *dev, struct plane_arg *p) static void atomic_set_planes(struct device *dev, struct plane_arg *p, unsigned int count, bool update) { - unsigned int i, pattern = UTIL_PATTERN_SMPTE; + unsigned int i, pattern = primary_fill; /* set up planes */ for (i = 0; i < count; i++) { if (i > 0) - pattern = UTIL_PATTERN_TILES; + pattern = secondary_fill; else set_gamma(dev, p[i].crtc_id, p[i].fourcc); @@ -1450,7 +1453,7 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co bo = bo_create(dev->fd, pipes[0].fourcc, dev->mode.width, dev->mode.height, handles, pitches, offsets, - UTIL_PATTERN_SMPTE); + primary_fill); if (bo == NULL) return; @@ -1794,6 +1797,18 @@ static int parse_property(struct property_arg *p, const char *arg) return 0; } +static void parse_fill_patterns(char *arg) +{ + char *fill = strtok(arg, ","); + if (!fill) + return; + primary_fill = util_pattern_enum(fill); + fill = strtok(NULL, ","); + if (!fill) + return; + secondary_fill = util_pattern_enum(fill); +} + static void usage(char *name) { fprintf(stderr, "usage: %s [-acDdefMPpsCvw]\n", name); @@ -1811,6 +1826,7 @@ static void usage(char *name) fprintf(stderr, "\t-v\ttest vsynced page flipping\n"); fprintf(stderr, "\t-w ::\tset property\n"); fprintf(stderr, "\t-a \tuse atomic API\n"); + fprintf(stderr, "\t-F pattern1,pattern2\tspecify fill patterns\n"); fprintf(stderr, "\n Generic options:\n\n"); fprintf(stderr, "\t-d\tdrop master after mode set\n"); @@ -1874,7 +1890,7 @@ static int pipe_resolve_connectors(struct device *dev, struct pipe_arg *pipe) return 0; } -static char optstr[] = "acdD:efM:P:ps:Cvw:"; +static char optstr[] = "acdD:efF:M:P:ps:Cvw:"; int main(int argc, char **argv) { @@ -1923,6 +1939,9 @@ int main(int argc, char **argv) case 'f': framebuffers = 1; break; + case 'F': + parse_fill_patterns(optarg); + break; case 'M': module = optarg; /* Preserve the default behaviour of dumping all information. */ diff --git a/tests/util/pattern.c b/tests/util/pattern.c index d197c444..42a0e5c7 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -35,6 +35,7 @@ #include #endif +#include "common.h" #include "format.h" #include "pattern.h" @@ -1261,3 +1262,22 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, break; } } + +static const char *pattern_names[] = { + [UTIL_PATTERN_TILES] = "tiles", + [UTIL_PATTERN_SMPTE] = "smpte", + [UTIL_PATTERN_PLAIN] = "plain", + [UTIL_PATTERN_GRADIENT] = "gradient", +}; + +enum util_fill_pattern util_pattern_enum(const char *name) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(pattern_names); i++) + if (!strcmp(pattern_names[i], name)) + return (enum util_fill_pattern)i; + + printf("Error: unsupported test pattern %s.\n", name); + return UTIL_PATTERN_SMPTE; +} diff --git a/tests/util/pattern.h b/tests/util/pattern.h index feac903a..424b0e19 100644 --- a/tests/util/pattern.h +++ b/tests/util/pattern.h @@ -41,4 +41,6 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, void util_smpte_c8_gamma(unsigned size, struct drm_color_lut *lut); +enum util_fill_pattern util_pattern_enum(const char *name); + #endif /* UTIL_PATTERN_H */