From patchwork Sun Nov 19 09:49:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wladimir J. van der Laan" X-Patchwork-Id: 10065103 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 11FBE602B8 for ; Sun, 19 Nov 2017 09:49:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7B7E29346 for ; Sun, 19 Nov 2017 09:49:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DACDE29352; Sun, 19 Nov 2017 09:49: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=-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 6D7E529346 for ; Sun, 19 Nov 2017 09:49:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB8376E52E; Sun, 19 Nov 2017 09:49:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id B86726E520 for ; Sun, 19 Nov 2017 09:49:40 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id 5so12359734wmk.1 for ; Sun, 19 Nov 2017 01:49:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WmXj+GpbjfRHVLWsegOeWNAx691TvfbV19RHR4BRqoE=; b=PzcXtI1ZLAMa9KRLKWbg39jGKta6JVi1OoWN8YFOW9baytq2bFiFTYZHxg0TcZTawp UeoWlffoo+N7Jyy5f32x6HzgaeciUUctN5Nz6Y5ZTHToWO9ealK0/enurPL/9FjDtoez f5axvpjy8/jvSl/uwKxQEQpkT8Y7fmlhRx/oRjLVjFG8cpQ5PX1k978Iv3OmwywwmRNK DoL33PPk5V5YVk4XeJQCxH45UVDm8k6VHy4KBF/u4D5lFyAxF0oeGBXppoB5bT1bcg7A 35hdHtk7ZiY2XeEiVSQ3SYJqZh0an/RAFpzrIvAZc9RndEzAe5YZKNh1DDCwT2DDckuq bnLQ== 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:in-reply-to :references; bh=WmXj+GpbjfRHVLWsegOeWNAx691TvfbV19RHR4BRqoE=; b=mylH587aDVCyOPEPjZwDTu+qscEboPGOC8A0Hjmm19OscZLaA90hbrtqvhhbGAqBnr 1vi0wJJu8D7JvzyWctU4GCTpXZzvpHsg0YsH+JoVdw8+ngizkhiqvj9h2dT4KLv29ObO Dp/kfQQr520PGEVOZVbeKDwnWVomUI44MuTgCzDVJtU190Tk8byowxNgVYXGMhhATddd WL9oS/5dBgwkTm0pkPUxrsJwDKqdWuJy1ggWmGKCpUmCYlZQY81c9RSpxqrXAyqO542+ wu1JmvgMNgcWPa7fQvwrzlLNNAz3GqShTifpicUypZlrp1L336O28nUwPopTAkMVAAmr Ptpw== X-Gm-Message-State: AJaThX6UWHWrfLkS3egz2F/xUBFT0hNEtGCTyBe1JbJG8BSQeYJivshR vgFSTr0Oma1MyplFuota8bOYa1V+B1Q= X-Google-Smtp-Source: AGs4zMYR88rzFmWWxNUobn3LPJmfV2m9AbuwWVBI1167Cjn9T2gEMGRBm4W1HKUQNu2qymLk23kBbw== X-Received: by 10.80.135.86 with SMTP id 22mr2504484edv.266.1511084978940; Sun, 19 Nov 2017 01:49:38 -0800 (PST) Received: from amethyst.lan (92-110-144-95.cable.dynamic.v4.ziggo.nl. [92.110.144.95]) by smtp.gmail.com with ESMTPSA id 33sm98327edt.57.2017.11.19.01.49.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 Nov 2017 01:49:38 -0800 (PST) From: "Wladimir J. van der Laan" To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 1/2] tests/modeprint: Print plane and other object properties Date: Sun, 19 Nov 2017 10:49:30 +0100 Message-Id: <1511084971-7638-2-git-send-email-laanwj@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511084971-7638-1-git-send-email-laanwj@gmail.com> References: <1511084971-7638-1-git-send-email-laanwj@gmail.com> Cc: Alex Deucher , "Wladimir J. van der Laan" , Emil Velikov 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 Make it possible to print plane properties, and the properties of other DRM mode objects, if available. Signed-off-by: Wladimir J. van der Laan --- tests/modeprint/modeprint.c | 100 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-) diff --git a/tests/modeprint/modeprint.c b/tests/modeprint/modeprint.c index 0d85410..42c0a1b 100644 --- a/tests/modeprint/modeprint.c +++ b/tests/modeprint/modeprint.c @@ -52,6 +52,7 @@ int full_modes; int encoders; int crtcs; int fbs; +int planes; char *module_name; static const char* getConnectionText(drmModeConnection conn) @@ -92,7 +93,7 @@ static int printMode(struct drm_mode_modeinfo *mode) return 0; } -static int printProperty(int fd, drmModeResPtr res, drmModePropertyPtr props, uint64_t value) +static int printProperty(int fd, drmModePropertyPtr props, uint64_t value) { const char *name = NULL; int j; @@ -141,6 +142,25 @@ static int printProperty(int fd, drmModeResPtr res, drmModePropertyPtr props, ui return 0; } +static int printObjectProps(int fd, uint32_t object_id, uint32_t object_type) +{ + uint32_t i; + + drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(fd, object_id, object_type); + if (props) { + for (i = 0; i < props->count_props; i++) { + drmModePropertyPtr prop = drmModeGetProperty(fd, props->props[i]); + if (prop) { + printProperty(fd, prop, props->prop_values[i]); + drmModeFreeProperty(prop); + } + } + drmModeFreeObjectProperties(props); + } + + return 0; +} + static const char * const output_names[] = { "None", "VGA", "DVI-I", @@ -204,7 +224,7 @@ static int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connect for (i = 0; i < connector->count_props; i++) { props = drmModeGetProperty(fd, connector->props[i]); if (props) { - printProperty(fd, res, props, connector->prop_values[i]); + printProperty(fd, props, connector->prop_values[i]); drmModeFreeProperty(props); } } @@ -221,6 +241,11 @@ static int printEncoder(int fd, drmModeResPtr res, drmModeEncoderPtr encoder, ui printf("\ttype :%d\n", encoder->encoder_type); printf("\tpossible_crtcs :0x%x\n", encoder->possible_crtcs); printf("\tpossible_clones :0x%x\n", encoder->possible_clones); + + if (full_props) { + printObjectProps(fd, encoder->crtc_id, DRM_MODE_OBJECT_ENCODER); + } + return 0; } @@ -235,6 +260,10 @@ static int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id printf("\tmode : %p\n", &crtc->mode); printf("\tgamma size : %d\n", crtc->gamma_size); + if (full_props) { + printObjectProps(fd, crtc->crtc_id, DRM_MODE_OBJECT_CRTC); + } + return 0; } @@ -249,16 +278,50 @@ static int printFrameBuffer(int fd, drmModeResPtr res, drmModeFBPtr fb) printf("\tdepth : %i\n", fb->depth); printf("\tbuffer_id : %i\n", fb->handle); + if (full_props) { + printObjectProps(fd, fb->fb_id, DRM_MODE_OBJECT_FB); + } + + return 0; +} + +static int printPlane(int fd, drmModePlanePtr plane) +{ + uint32_t i; + + printf("Plane\n"); + printf("\tcount_formats : %i\n", plane->count_formats); + if (plane->count_formats) { + printf("\tformats :"); + for (i = 0; i < plane->count_formats; i++) + printf(" %c%c%c%c", plane->formats[i] >> 24, plane->formats[i] >> 16, plane->formats[i] >> 8, plane->formats[i] >> 0); + printf("\n"); + } + printf("\tplane_id : %i\n", plane->plane_id); + printf("\tcrtc_id : %i\n", plane->crtc_id); + printf("\tfb_id : %i\n", plane->fb_id);; + printf("\tcrtc_x : %i\n", plane->crtc_x); + printf("\tcrtc_y : %i\n", plane->crtc_y); + printf("\tx : %i\n", plane->x); + printf("\ty : %i\n", plane->y); + printf("\tpossible_crtcs : 0x%x\n", plane->possible_crtcs); + printf("\tgamma_size : %i\n", plane->gamma_size); + + if (full_props) { + printObjectProps(fd, plane->plane_id, DRM_MODE_OBJECT_PLANE); + } + return 0; } -static int printRes(int fd, drmModeResPtr res) +static int printRes(int fd, drmModeResPtr res, drmModePlaneResPtr pres) { int i; drmModeFBPtr fb; drmModeCrtcPtr crtc; drmModeEncoderPtr encoder; drmModeConnectorPtr connector; + drmModePlanePtr plane; printf("Resources\n\n"); @@ -266,6 +329,7 @@ static int printRes(int fd, drmModeResPtr res) printf("count_encoders : %i\n", res->count_encoders); printf("count_crtcs : %i\n", res->count_crtcs); printf("count_fbs : %i\n", res->count_fbs); + printf("count_planes : %i\n", pres->count_planes); printf("\n"); @@ -325,6 +389,19 @@ static int printRes(int fd, drmModeResPtr res) } } + if (planes) { + for (i = 0; i < (int)pres->count_planes; i++) { + plane = drmModeGetPlane(fd, pres->planes[i]); + + if (!plane) + printf("Could not get plane %i\n", pres->planes[i]); + else { + printPlane(fd, plane); + drmModeFreePlane(plane); + } + } + } + return 0; } @@ -338,6 +415,7 @@ static void args(int argc, char **argv) crtcs = 0; modes = 0; encoders = 0; + planes = 0; full_modes = 0; full_props = 0; connectors = 0; @@ -376,12 +454,16 @@ static void args(int argc, char **argv) } else if (strcmp(argv[i], "-encoders") == 0) { encoders = 1; defaults = 0; + } else if (strcmp(argv[i], "-planes") == 0) { + planes = 1; + defaults = 0; } else if (strcmp(argv[i], "-v") == 0) { fbs = 1; edid = 1; crtcs = 1; modes = 1; encoders = 1; + planes = 1; full_modes = 1; full_props = 1; connectors = 1; @@ -397,6 +479,7 @@ static void args(int argc, char **argv) crtcs = 1; modes = 1; encoders = 1; + planes = 1; full_modes = 0; full_props = 0; connectors = 1; @@ -407,6 +490,7 @@ int main(int argc, char **argv) { int fd; drmModeResPtr res; + drmModePlaneResPtr pres; if (argc == 1) { printf("Please add modulename as first argument\n"); @@ -430,9 +514,17 @@ int main(int argc, char **argv) drmClose(fd); return 1; } + pres = drmModeGetPlaneResources(fd); + if (pres == 0) { + printf("Failed to get plane resources from card\n"); + drmModeFreeResources(res); + drmClose(fd); + return 1; + } - printRes(fd, res); + printRes(fd, res, pres); + drmModeFreePlaneResources(pres); drmModeFreeResources(res); printf("Ok\n");