From patchwork Thu Sep 28 23:44:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Kristian_H=C3=B8gsberg?= X-Patchwork-Id: 9976907 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 D0E1160375 for ; Thu, 28 Sep 2017 23:44:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C266F29772 for ; Thu, 28 Sep 2017 23:44:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5DC42977A; Thu, 28 Sep 2017 23:44: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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 3DBCD29772 for ; Thu, 28 Sep 2017 23:44:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 93DDB6EA01; Thu, 28 Sep 2017 23:44:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg0-x243.google.com (mail-pg0-x243.google.com [IPv6:2607:f8b0:400e:c05::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id C0A376EA01 for ; Thu, 28 Sep 2017 23:44:35 +0000 (UTC) Received: by mail-pg0-x243.google.com with SMTP id u18so3425644pgo.1 for ; Thu, 28 Sep 2017 16:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=wTwSzN39IMdRczaTdT4ouR8fRH92AxXxaSxMRQkszXk=; b=DDJ7pHePLC3Qhw+9sUZ7tKbfCIBnn1PYurzodlIZAIdSwclNpsS3qS+KcREiuuL1XP 7oRiS5gUIMJEDlnZKyZ4sY8jje8ya/JfqcSsrjgUPs5SLJ/R1BRp4R1ReaNVHrAB1tb3 mzNe0isRYkZhEFOYaZ9hRpAVtr30pSUAs2sVlruGRUDcSYNMzTIEYFL2A50LezU5+3Qr cgRJwSOpMVgeKiYV7GCj2cqc8Vzc5WihMAO24d5H3q3aG2s/uOZPnHFWBSKj4rvGmFGH JlUe3VkXSy8etAasDV01U9OUajn6RiwXm1QdLMsH1NyPuOPzpCfiEuIERNx1KOCKq2FH ZH8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wTwSzN39IMdRczaTdT4ouR8fRH92AxXxaSxMRQkszXk=; b=jILLT9JQUWd65JYBsizFml9FxU0AwKN3/RFSar0IzYUkAYaS/wNkqNbwMHM5bcVtS8 lMm1cDKQIwqiW+EYaKSF2gtzpMf88UHHAC+98LN5nFS6uRKxls+/R84YPuFyTXB+Rj/e d7q5+rQg4XDYRVZzbZzibQG9CkoePGrNazOmf8YfdcYLWHL1NNzUDWQ6BkCkKzYK5E9Y BHhnkO6mLNteTIa2tInzhtUHoLCfkf3D4SuSfj5YK86giLcNYz4zB4q7iTKVZhoPf0tn d/NeAnLLp0rGLKGryQ+plUU1dNx0R2GXjLMfEAEm1w8V+2WIkvfBFvtrX+Tz5k+fJFRK J87A== X-Gm-Message-State: AHPjjUhD/s3y+rceXFYHkskX9kAk+FxI3OBjoyp7VMX/vxETKWvGP6Ao 9Z2K5BSzHHoBXeNIyXkOJsHxY694 X-Google-Smtp-Source: AOwi7QCoKJWPx6K7jUWfVknf0vE8n5tRWv9NMhuPzK4ySGunqHhGIbA9vKixhhu478ovjUQbQFPKjQ== X-Received: by 10.84.253.23 with SMTP id z23mr5113377pll.210.1506642274864; Thu, 28 Sep 2017 16:44:34 -0700 (PDT) Received: from hawkmoon.pdx.corp.google.com ([2620:15c:f:0:c819:73ff:b58:a64c]) by smtp.gmail.com with ESMTPSA id j68sm4500257pfa.93.2017.09.28.16.44.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 16:44:33 -0700 (PDT) From: "Kristian H. Kristensen" X-Google-Original-From: "Kristian H. Kristensen" To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm] modetest: Decode IN_FORMATS plane blob property Date: Thu, 28 Sep 2017 16:44:32 -0700 Message-Id: <20170928234432.25869-1-hoegsberg@chromium.org> X-Mailer: git-send-email 2.14.2.822.g60be5d43e6-goog Cc: "Kristian H. Kristensen" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This teaches modetest about the new IN_FORMATS blob and decodes the blob to show supported formats and modifiers. Signed-off-by: Kristian H. Kristensen --- tests/modetest/modetest.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index b8891ff5..8ad4766f 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -251,6 +251,89 @@ static void dump_blob(struct device *dev, uint32_t blob_id) drmModeFreePropertyBlob(blob); } +static const char *modifier_to_string(uint64_t modifier) +{ + switch (modifier) { + case DRM_FORMAT_MOD_INVALID: + return "INVALID"; + case DRM_FORMAT_MOD_LINEAR: + return "LINEAR"; + case I915_FORMAT_MOD_X_TILED: + return "X_TILED"; + case I915_FORMAT_MOD_Y_TILED: + return "Y_TILED"; + case I915_FORMAT_MOD_Yf_TILED: + return "Yf_TILED"; + case I915_FORMAT_MOD_Y_TILED_CCS: + return "Y_TILED_CCS"; + case I915_FORMAT_MOD_Yf_TILED_CCS: + return "Yf_TILED_CCS"; + case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE: + return "SAMSUNG_64_32_TILE"; + case DRM_FORMAT_MOD_VIVANTE_TILED: + return "VIVANTE_TILED"; + case DRM_FORMAT_MOD_VIVANTE_SUPER_TILED: + return "VIVANTE_SUPER_TILED"; + case DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED: + return "VIVANTE_SPLIT_TILED"; + case DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED: + return "VIVANTE_SPLIT_SUPER_TILED"; + case NV_FORMAT_MOD_TEGRA_TILED: + return "MOD_TEGRA_TILED"; + case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(0): + return "MOD_TEGRA_16BX2_BLOCK(0)"; + case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(1): + return "MOD_TEGRA_16BX2_BLOCK(1)"; + case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(2): + return "MOD_TEGRA_16BX2_BLOCK(2)"; + case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(3): + return "MOD_TEGRA_16BX2_BLOCK(3)"; + case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(4): + return "MOD_TEGRA_16BX2_BLOCK(4)"; + case NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(5): + return "MOD_TEGRA_16BX2_BLOCK(5)"; + case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED: + return "MOD_BROADCOM_VC4_T_TILED"; + default: + return "(UNKNOWN MODIFIER)"; + } +} + +static void dump_in_formats(struct device *dev, uint32_t blob_id) +{ + uint32_t i, j; + drmModePropertyBlobPtr blob; + struct drm_format_modifier_blob *header; + uint32_t *formats; + struct drm_format_modifier *modifiers; + + printf("\t\tin_formats blob decoded:\n"); + blob = drmModeGetPropertyBlob(dev->fd, blob_id); + if (!blob) { + printf("\n"); + return; + } + + header = blob->data; + formats = (uint32_t *) ((char *) header + header->formats_offset); + modifiers = (struct drm_format_modifier *) + ((char *) header + header->modifiers_offset); + + for (i = 0; i < header->count_formats; i++) { + printf("\t\t\t"); + dump_fourcc(formats[i]); + printf(": "); + for (j = 0; j < header->count_modifiers; j++) { + uint64_t mask = 1ULL << i; + if (modifiers[j].formats & mask) + printf(" %s", modifier_to_string(modifiers[j].modifier)); + } + printf("\n"); + } + + drmModeFreePropertyBlob(blob); +} + static void dump_prop(struct device *dev, drmModePropertyPtr prop, uint32_t prop_id, uint64_t value) { @@ -328,6 +411,9 @@ static void dump_prop(struct device *dev, drmModePropertyPtr prop, printf(" %"PRId64"\n", value); else printf(" %"PRIu64"\n", value); + + if (strcmp(prop->name, "IN_FORMATS") == 0) + dump_in_formats(dev, value); } static void dump_connectors(struct device *dev)