From patchwork Wed Nov 6 15:25:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devarsh Thakkar X-Patchwork-Id: 11231959 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 1B3AD139A for ; Thu, 7 Nov 2019 07:44:00 +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 01A2B21882 for ; Thu, 7 Nov 2019 07:44:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01A2B21882 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 CAEF66EEAF; Thu, 7 Nov 2019 07:43:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-SN1-obe.outbound.protection.outlook.com (mail-eopbgr700068.outbound.protection.outlook.com [40.107.70.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CD696EDA8 for ; Wed, 6 Nov 2019 15:26:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nP/0MCcRNUhksqTQ3wxVgQX9mT6dG4QAHrvbI8/+7+GzRBFjtdRS+WxPL/cmewhftn3SwzDH9pcYpF43FwJJhC+woGCBiKjMiLynAWDfhe3BmUULH+4s5FFdk5NeJ8Hx8r2nQWm2RogQa+4IGebxb8UaO7cfssGkux42QJpA+gIkc0JxPNV2XmuAjCbijluuwKU5IyVAGOuMe0juJI5S4T2xIh47+8zsxmU337pWLerOt1M4Pw+IgXZRK1zBSJcCcmUpEh/JzhMOJD9GsZXcBqCHDHh/cjSGmq4MqmrVkU+mqUvbQR439d4NofqI3TyxDF5CNQGnUyxt9FfMz8FuYA== 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=K8Y1x6184jGPf2KjIN1G9mfbYEr3TLS1s1c0LR5fAwI=; b=f0OrWrq5AWRCRhJMt58oHp31JFhZ5z1vbTRxN/4cu6mm31piPigts6VKf8K47b68WCsnTwXyXm08ZueP5iCSBbCkuTPD5idIn4YlwM6rTVTeux2sJKToIJvud/8U6gv60xqeeB0gxKNC8HnN7DJtgk6cFwFyUIVUZa4F2nfsd8q7OA1sk7BobT8+o1ZQxnaURrAjcdJ3b7dONjU+jWcgiQVyWSTxOW4lODSnmHE1wu4sExNax0MVTxNa7k+FavciMnJcz7jJWCvGeSsJCDc9uiULXhSmTD3aOvAAdXmE2AlFb3kroNrjCWdWN3q1f9qwovdCVxp8uL/29sQtn6LK0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass action=none header.from=xilinx.com; dkim=none (message not signed); arc=none Received: from MN2PR02CA0010.namprd02.prod.outlook.com (2603:10b6:208:fc::23) by DM5PR02MB2396.namprd02.prod.outlook.com (2603:10b6:3:4f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2408.24; Wed, 6 Nov 2019 15:26:22 +0000 Received: from BL2NAM02FT005.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::209) by MN2PR02CA0010.outlook.office365.com (2603:10b6:208:fc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2430.20 via Frontend Transport; Wed, 6 Nov 2019 15:26:22 +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 BL2NAM02FT005.mail.protection.outlook.com (10.152.76.252) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.2387.20 via Frontend Transport; Wed, 6 Nov 2019 15:26:21 +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 1iSNCO-0005MW-Q0 for dri-devel@lists.freedesktop.org; Wed, 06 Nov 2019 07:26:20 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1iSNCJ-00048J-OA for dri-devel@lists.freedesktop.org; Wed, 06 Nov 2019 07:26:15 -0800 Received: from xsj-pvapsmtp01 (xsj-pvapsmtp01.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id xA6FQ91l012272; Wed, 6 Nov 2019 07:26:09 -0800 Received: from [172.19.2.102] (helo=xsjanandash50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1iSNCD-00047v-Mp; Wed, 06 Nov 2019 07:26:09 -0800 From: Devarsh Thakkar To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm] modetest: Add support for setting mode having floating vertical refresh rate Date: Wed, 6 Nov 2019 07:25:44 -0800 Message-Id: <1573053944-4933-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)(376002)(396003)(136003)(39860400002)(346002)(189003)(199004)(8746002)(2351001)(50226002)(5024004)(14444005)(8936002)(36386004)(2906002)(356004)(9786002)(81156014)(81166006)(6666004)(8676002)(2361001)(4326008)(305945005)(50466002)(26005)(5660300002)(6916009)(107886003)(48376002)(316002)(126002)(2616005)(36756003)(7696005)(44832011)(486006)(426003)(476003)(106002)(70206006)(336012)(478600001)(70586007)(51416003)(186003)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR02MB2396; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; LANG:en; PTR:unknown-60-83.xilinx.com; MX:1; A:1; MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c9b958de-ae61-48da-4d27-08d762cdad90 X-MS-TrafficTypeDiagnostic: DM5PR02MB2396: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-Forefront-PRVS: 02135EB356 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zLaPi78rvcFUg+jm07ZkW+xIoEx04qCv3f1ZBlXZ2jv2AwCzsYSQ72FmB8KKGcwiAiZARCpp0Ixh54OBE7LkUf7QbX7YnfaRSRUyLwca3nzL1uqKChI/Ur+LxP+0s7FfTGrU07SfB7v7EqfQ+CN7xI4jwbj2+LUNbdcRXdS1+j2nG06jhd1rDUbriWWhXDgDAkfUqlCGqSZa5N9WBUTnnnq6hGtFC7EsR7YnVtFg0KcrChx0kpVBOXS+G8+VM0dUb405BYUlF72uXQCN55YtOtPY+1OAYLF/Ca4hjGEOlzVzxRkUWBuF8wTq1OUOitknSke/zbMX9LvKuH1U/5Ft/LRFj1/Yt6ARVU4JAYBl3GP6iaufDSnmS611gpMnwBl9WcQIdQyvy+3COdS+/HdGRSiIMRz96pVYrCwv3VpjlUFE+PpP7fAlcAtvoV+v2M+v X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2019 15:26:21.3535 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c9b958de-ae61-48da-4d27-08d762cdad90 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: DM5PR02MB2396 X-Mailman-Approved-At: Thu, 07 Nov 2019 07:43:23 +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=K8Y1x6184jGPf2KjIN1G9mfbYEr3TLS1s1c0LR5fAwI=; b=YScGF6XPxv51+Vc/E7fQmlWmx4lidqTdBPWLw+2koCjcozGUnnDD3k+mO7VDpH56yZTJOCTW5rpKOBhunXeWnAK4n5OA58tqXw2eDXnKH/vk6/+OVVNceLfVs98J/njd4LMlQ7Sx9RSoHr0Hdyms17cnMLLAjmahk3fBc/yvNUk= X-Mailman-Original-Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; 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, satishna@xilinx.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" For the scenario where user may require to modeset with a mode supporting a fractional value for vertical refresh-rate, appropriate mode can be selected by searching for mode having matching fractional vertical refresh rate using below equation. vrefresh = 1000 * (pixel clock) / (htotal * vtotal) Khz. We do this way since driver doesn't return float value of vrefresh as it use int for vrefresh in struct drm_mode_info, but we derive the actual value using pixel clock, htotal and vtotal values. So for e.g. if user want to select mode having 59.94 Hz as refresh rate then with this patch it be can done as shown in below command, given there is an appropriate mode is available : modetest -M xlnx -s 39:1920x1080-59.94@BG24 -v NOTE: Above command was tested on xilinx DRM driver with DP monitor which was supporting mode having 59.94 Hz refresh rate. Signed-off-by: Devarsh Thakkar --- tests/modetest/modetest.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) -- 2.7.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately. diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index e66be66..9b3e410 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -795,7 +795,7 @@ struct pipe_arg { uint32_t crtc_id; char mode_str[64]; char format_str[5]; - unsigned int vrefresh; + float vrefresh; unsigned int fourcc; drmModeModeInfo *mode; struct crtc *crtc; @@ -822,11 +822,12 @@ struct plane_arg { static drmModeModeInfo * connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str, - const unsigned int vrefresh) + const float vrefresh) { drmModeConnector *connector; drmModeModeInfo *mode; int i; + float mode_vrefresh; connector = get_connector_by_id(dev, con_id); if (!connector || !connector->count_modes) @@ -839,9 +840,19 @@ connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str, * first mode that match with the name. Else, return the mode that match * the name and the specified vertical refresh frequency. */ + float temp; + + mode_vrefresh = ((float)(mode->clock) * 1000.00) + / ((float)(mode->htotal) + * (float)mode->vtotal); + /* Round off to 2 decimal places to match with user + * provided value + */ + temp = (int) (mode_vrefresh * 100 + 0.5); + mode_vrefresh = (float) temp / 100; if (vrefresh == 0) return mode; - else if (mode->vrefresh == vrefresh) + else if (mode_vrefresh == vrefresh) return mode; } } @@ -1393,8 +1404,8 @@ static void atomic_set_mode(struct device *dev, struct pipe_arg *pipes, unsigned if (pipe->mode == NULL) continue; - printf("setting mode %s-%dHz on connectors ", - pipe->mode_str, pipe->mode->vrefresh); + printf("setting mode %s-%.2fHz on connectors ", + pipe->mode_str, pipe->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); @@ -1476,8 +1487,8 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co 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-%.2fHz@%s on connectors ", + pipe->mode_str, pipe->vrefresh, 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); @@ -1713,8 +1724,13 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg) pipe->mode_str[len] = '\0'; if (*p == '-') { - pipe->vrefresh = strtoul(p + 1, &endp, 10); + float temp; + + pipe->vrefresh = strtof(p + 1, &endp); p = endp; + /* Round off to 2 decimal places */ + temp = (int) (pipe->vrefresh * 100 + 0.5); + pipe->vrefresh = (float) temp / 100; } if (*p == '@') {