From patchwork Tue Dec 3 14:37:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devarsh Thakkar X-Patchwork-Id: 11272253 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89CA413B6 for ; Wed, 4 Dec 2019 08:01:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7012720640 for ; Wed, 4 Dec 2019 08:01:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7012720640 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F6BF6F44C; Wed, 4 Dec 2019 08:01:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-eopbgr750058.outbound.protection.outlook.com [40.107.75.58]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4434589D83 for ; Tue, 3 Dec 2019 14:38:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gIY0L2Psx1ekdrqd2+RaUBTv/5fg53TjuAcxs5NbisMDyvLjb0pMamXCHiJ8RKajfmwZ+37Wl9I2xS6fyqBtiA+96Upte+HAWeH3JJiwp67rUdHf8d9beTgv5trpGGRSQdamyaBTsolIYZKwtQhyW0akjAdeijh7QsCbHAEqqpuJxY/5f/TftQ+aAD9EWSAOQ2eRdzjmNSRbNJiBdDEJ3Ihegpon2z+QYl6JM1vuzetttUHEJtJ62gYz2XL/Yk8pMnK9vcqIYV1+9ujsiEYyWiYSrJrKkBFY/IhT+3K5gPINADAyFTeKeNaq8A7niWTwepYPbpYk1FUhDCbclVaiQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sZR6WShsqO1HrSKB29dfX8BwtbJ9FSPXFUMnkWXDpFQ=; b=a+B2eZsP27fyySgNseaDhWhKsK3KmiSQHDDPv+KBLx4ExG+PHJilyFe4rwGtgQxl5hztPtC8XyU5E4lbyHk2/FpGwIxhQ3dQhp+K8ZRNEN9Jk23FwzNEw5Ersgf+H7lq5lFv9eAVPiDqtC4NMWsCBHh18zkpwEut2gyPAbdxlPJv7b8FvJugUruF34mpyokn8/bScahGvlHoe8zbnehMdYln/btM+6OgIUxAKVNuEnVL99lzY6bpfjFXmiJE895FLnTZNH/ieUTfcew1B5wHkr+eXj9hPps/V9NWXdOnexdjymQJ6W7gQz9ompZA0I6MQLraSeG9IpUmklXU05TbkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=baylibre.com smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from BL0PR02CA0052.namprd02.prod.outlook.com (2603:10b6:207:3d::29) by DM6PR02MB6155.namprd02.prod.outlook.com (2603:10b6:5:1fb::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2495.18; Tue, 3 Dec 2019 14:38:02 +0000 Received: from BL2NAM02FT041.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::200) by BL0PR02CA0052.outlook.office365.com (2603:10b6:207:3d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.30 via Frontend Transport; Tue, 3 Dec 2019 14:38:02 +0000 Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BL2NAM02FT041.mail.protection.outlook.com (10.152.77.122) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2474.17 via Frontend Transport; Tue, 3 Dec 2019 14:38:02 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1ic9JR-0007Oi-G6; Tue, 03 Dec 2019 06:38:01 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1ic9JM-0001U8-Bu; Tue, 03 Dec 2019 06:37:56 -0800 Received: from xsj-pvapsmtp01 (smtp2.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id xB3Ebn2X005810; Tue, 3 Dec 2019 06:37:50 -0800 Received: from [172.19.2.102] (helo=xsjanandash50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1ic9JF-0001Sk-N2; Tue, 03 Dec 2019 06:37:49 -0800 From: Devarsh Thakkar To: dri-devel@lists.freedesktop.org, ville.syrjala@linux.intel.com, narmstrong@baylibre.com Subject: [PATCH libdrm v4] modetest: Use floating vrefresh while dumping mode Date: Tue, 3 Dec 2019 06:37:36 -0800 Message-Id: <1575383856-29959-1-git-send-email-devarsh.thakkar@xilinx.com> X-Mailer: git-send-email 2.7.4 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(136003)(396003)(376002)(346002)(39860400002)(199004)(189003)(2616005)(50466002)(26005)(186003)(81156014)(305945005)(81166006)(478600001)(6666004)(426003)(356004)(50226002)(44832011)(316002)(48376002)(14444005)(51416003)(36386004)(336012)(8676002)(16586007)(106002)(9786002)(7696005)(8936002)(5660300002)(36756003)(107886003)(4326008)(2906002)(70586007)(70206006); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR02MB6155; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; LANG:en; PTR:unknown-60-83.xilinx.com; A:1; MX:1; MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ea7f8de-3fb3-4a73-d1d1-08d777fe669c X-MS-TrafficTypeDiagnostic: DM6PR02MB6155: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:1186; X-Forefront-PRVS: 02408926C4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j7MhbxJB5ypbzJfLlzgFiJwxozuQoLP/4neEKF+EYI+vxrT+986cZB6YgCMqzS4V5ytUlZJ2MVHX+AJwRALUdfy5jlL/4d+WNLtF1bwTZKHSYQhFn9xaUzVs1NE1zumVSi/RKxaIEjy45p09gXnGyfnEbjxEXat5zKgiy/gxFgcYAWdcPYaZSaUOJkvT0xJc/vuplulghg8gGUGA2ddTMCF7bGxypfDIIDzjxXTRAP/CIUloDMbp647u2fdYUz/9e5EsrdZ9f9g2x7UVATW+lctzfetLOfzkgrgV5tn2VjaWjZ4Ahg/crGIY0WCXGzvW4cfo0duA0SV0gEW8ZiL8PknFeK53Rl8+AWaM7Xacq6aLy7g91eN2eKN9P6s26N03mvaDNgc2n/sZ7HNLfnLLR8yA40C3ySHrhzNywfAqZ0CWoLsEDMzOTIV05vBHUkhK X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2019 14:38:02.0744 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ea7f8de-3fb3-4a73-d1d1-08d777fe669c X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR02MB6155 X-Mailman-Approved-At: Wed, 04 Dec 2019 08:01:16 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sZR6WShsqO1HrSKB29dfX8BwtbJ9FSPXFUMnkWXDpFQ=; b=WghV7+u0peJXAtjAPn4P6M2nh7NyRV8KqJs7hdU8bknKdMw/OdOB8O/eMmE+Wfrb4vBnUyUNAxJ6F6JPu1UM5GHE231q6YUOU9pGoMoQ3DsJaDaN8/NjntvXiwV5V2wcR9+xoKtlf1xew3zKnAoy6VLFGfI+jRUJVUcQMzVwWxc= X-Mailman-Original-Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; baylibre.com; dkim=none (message not signed) header.d=none;baylibre.com; dmarc=bestguesspass action=none header.from=xilinx.com; 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: , Cc: rsk@xilinx.com, vcu-team@xilinx.com, dshah@xilinx.com, devarsh.thakkar@xilinx.com, varunkum@xilinx.com, rvisaval@xilinx.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add function to derive floating value of vertical refresh rate from drm mode using pixel clock, horizontal total size and vertical total size. Use this function to find suitable mode having vrefresh value which is matching with user provided vrefresh value. If user doesn't provide any vrefresh value in args then update vertical refresh rate value in pipe args using this function. Also use this function for printing floating vrefresh while dumping all available modes. This will give more accurate picture to user for available modes differentiated by floating vertical refresh rate and help user select more appropriate mode using suitable refresh rate value. V4: 1) While setting mode, print mode name and vrefresh using struct drmModeModeInfo instead of struct pipe_args. 2) Revert back to using a float value instead of float * for vrefresh arg in connector_find_mode(). V3: 1) Change name of function used to derive refresh rate. V2: 1) Don't use inline function for deriving refresh rate from mode. 2) If requested mode not found, print refresh rate only if user had provided it in args. Signed-off-by: Devarsh Thakkar Reviewed-by: Neil Armstrong --- tests/modetest/modetest.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index b4edfcb..e998e8e 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -133,6 +133,12 @@ static inline int64_t U642I64(uint64_t val) return (int64_t)*((int64_t *)&val); } +static float mode_vrefresh(drmModeModeInfo *mode) +{ + return mode->clock * 1000.00 + / (mode->htotal * mode->vtotal); +} + #define bit_name_fn(res) \ const char * res##_str(int type) { \ unsigned int i; \ @@ -210,9 +216,9 @@ static void dump_encoders(struct device *dev) static void dump_mode(drmModeModeInfo *mode) { - printf(" %s %d %d %d %d %d %d %d %d %d %d", + printf(" %s %.2f %d %d %d %d %d %d %d %d %d", mode->name, - mode->vrefresh, + mode_vrefresh(mode), mode->hdisplay, mode->hsync_start, mode->hsync_end, @@ -828,7 +834,6 @@ connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str, drmModeConnector *connector; drmModeModeInfo *mode; int i; - float mode_vrefresh; connector = get_connector_by_id(dev, con_id); if (!connector || !connector->count_modes) @@ -837,15 +842,14 @@ connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str, for (i = 0; i < connector->count_modes; i++) { mode = &connector->modes[i]; if (!strcmp(mode->name, mode_str)) { - /* If the vertical refresh frequency is not specified then return the - * first mode that match with the name. Else, return the mode that match - * the name and the specified vertical refresh frequency. + /* If the vertical refresh frequency is not specified + * then return the first mode that match with the name. + * Else, return the mode that match the name and + * the specified vertical refresh frequency. */ - mode_vrefresh = mode->clock * 1000.00 - / (mode->htotal * mode->vtotal); if (vrefresh == 0) return mode; - else if (fabs(mode_vrefresh - vrefresh) < 0.005) + else if (fabs(mode_vrefresh(mode) - vrefresh) < 0.005) return mode; } } @@ -911,7 +915,13 @@ static int pipe_find_crtc_and_mode(struct device *dev, struct pipe_arg *pipe) mode = connector_find_mode(dev, pipe->con_ids[i], pipe->mode_str, pipe->vrefresh); if (mode == NULL) { - fprintf(stderr, + if (pipe->vrefresh) + fprintf(stderr, + "failed to find mode " + "\"%s-%.2fHz\" for connector %s\n", + pipe->mode_str, pipe->vrefresh, pipe->cons[i]); + else + fprintf(stderr, "failed to find mode \"%s\" for connector %s\n", pipe->mode_str, pipe->cons[i]); return -EINVAL; @@ -1398,7 +1408,7 @@ static void atomic_set_mode(struct device *dev, struct pipe_arg *pipes, unsigned continue; printf("setting mode %s-%.2fHz on connectors ", - pipe->mode_str, pipe->vrefresh); + pipe->mode->name, mode_vrefresh(pipe->mode)); 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); @@ -1481,7 +1491,8 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co continue; printf("setting mode %s-%.2fHz@%s on connectors ", - pipe->mode_str, pipe->vrefresh, pipe->format_str); + pipe->mode->name, mode_vrefresh(pipe->mode), + pipe->format_str); for (j = 0; j < pipe->num_cons; ++j) printf("%s, ", pipe->cons[j]); printf("crtc %d\n", pipe->crtc->crtc->crtc_id);