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"); }