From patchwork Wed Aug 5 08:36:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6buE5a626ZKX?= X-Patchwork-Id: 11701543 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 0F95D1510 for ; Wed, 5 Aug 2020 08:37:21 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 DE0F821744 for ; Wed, 5 Aug 2020 08:37:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QlNIeU+I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE0F821744 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=YHaV2CK5aoKBtgHj2y7VZCgsKfCWmTESkK+Vj3VrMzw=; b=QlNIeU+IeG/K/mFu8TTldoqHko R645BQx217Mo9S1ZDZaHiKfjMg4uqSNLV6TCfBor68ljN/EuWTkR7V5OILt9rM8VSVO0ME+UVY5P1 gRhiQpO79bzQ1rJYWl/jn0J7AhQCjdtB6fRM6XUPJLNA0KxwLlE2bRBbf+KsNqee4qwJ1a3o+SFFk o76nEcUM0u/i4agqZLZbQdtkCKSuRWtp0gjhboKBNW+1GldhGec/ibk6JyQrL1hYEqylkfIGfOJ4u PCgNYyVvbqYVDY1a9vVf6pogtQLT71ZfpHUpkgZdOmUdGafendwDomhn59ozJdcNFtrm/F48JYdwf kUwebTsQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3EvG-0000rJ-SD; Wed, 05 Aug 2020 08:37:18 +0000 Received: from lucky1.263xmail.com ([211.157.147.131]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3Ev3-0000jN-OQ for linux-rockchip@lists.infradead.org; Wed, 05 Aug 2020 08:37:07 +0000 Received: from localhost (unknown [192.168.167.209]) by lucky1.263xmail.com (Postfix) with ESMTP id E6688B0743; Wed, 5 Aug 2020 16:36:50 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P12030T139956846577408S1596616609190052_; Wed, 05 Aug 2020 16:36:50 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <8e8bd938e45a208ef8604a951d9c156f> X-RL-SENDER: hjc@rock-chips.com X-SENDER: hjc@rock-chips.com X-LOGIN-NAME: hjc@rock-chips.com X-FST-TO: heiko@sntech.de X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: Sandy Huang To: heiko@sntech.de, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH] drm: sysfs: Add to get current mode Date: Wed, 5 Aug 2020 16:36:46 +0800 Message-Id: <20200805083646.4123-1-hjc@rock-chips.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200805_043706_094401_8891423F X-CRM114-Status: GOOD ( 14.27 ) X-Spam-Score: 1.5 (+) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (1.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [211.157.147.131 listed in list.dnswl.org] 1.5 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [58.22.7.114 listed in dnsbl.sorbs.net] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [211.157.147.131 listed in wl.mailspike.net] 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangtao@rock-chips.com, linux-kernel@vger.kernel.org, Sandy Huang , dri-devel@lists.freedesktop.org, kever.yang@rock-chips.com, linux-rockchip@lists.infradead.org, andy.yan@rock-chips.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org add this node to get the current true mode. Signed-off-by: Sandy Huang --- drivers/gpu/drm/drm_sysfs.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 939f0032aab1..f39bcd34853b 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -236,16 +237,45 @@ static ssize_t modes_show(struct device *device, return written; } +static ssize_t current_mode_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct drm_connector *connector = to_drm_connector(device); + struct drm_display_mode *mode; + struct drm_crtc_state *crtc_state; + bool interlaced; + int written = 0; + + if (!connector->state || !connector->state->crtc) + return written; + + crtc_state = connector->state->crtc->state; + if (!crtc_state) + return written; + + mode = &crtc_state->mode; + + interlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE); + written += snprintf(buf + written, PAGE_SIZE - written, "%dx%d%s%d\n", + mode->hdisplay, mode->vdisplay, + interlaced ? "i" : "p", drm_mode_vrefresh(mode)); + + return written; +} + static DEVICE_ATTR_RW(status); static DEVICE_ATTR_RO(enabled); static DEVICE_ATTR_RO(dpms); static DEVICE_ATTR_RO(modes); +static DEVICE_ATTR_RO(current_mode); static struct attribute *connector_dev_attrs[] = { &dev_attr_status.attr, &dev_attr_enabled.attr, &dev_attr_dpms.attr, &dev_attr_modes.attr, + &dev_attr_current_mode.attr, NULL };