From patchwork Tue Jun 25 10:24:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11015217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82A381580 for ; Tue, 25 Jun 2019 10:24:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7342528BDA for ; Tue, 25 Jun 2019 10:24:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6594828BE5; Tue, 25 Jun 2019 10:24:53 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0789628BDA for ; Tue, 25 Jun 2019 10:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731611AbfFYKYv (ORCPT ); Tue, 25 Jun 2019 06:24:51 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56384 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727102AbfFYKYu (ORCPT ); Tue, 25 Jun 2019 06:24:50 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 69E98288E1F From: Andrzej Pietrasiewicz To: dri-devel@lists.freedesktop.org Cc: kernel@collabora.com, m.szyprowski@samsung.com, Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Kukjin Kim , Krzysztof Kozlowski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH v2 1/2] drm: Include ddc adapter pointer in struct drm_connector Date: Tue, 25 Jun 2019 12:24:40 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: <20190625101655.n246vbwtupb4eoyz@shell.armlinux.org.uk> In-Reply-To: References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add generic code which creates symbolic links in sysfs, pointing to ddc interface used by a particular video output. For example: ls -l /sys/class/drm/card0-HDMI-A-1/ddc lrwxrwxrwx 1 root root 0 Jun 24 10:42 /sys/class/drm/card0-HDMI-A-1/ddc \ -> ../../../../soc/13880000.i2c/i2c-2 This makes it easy for user to associate a display with its ddc adapter and use e.g. ddcutil to control the chosen monitor. This patch adds an i2c_adapter pointer to struct drm_connector. Particular drivers can then use it instead of using their own private instance. If a connector contains a ddc, then create a symbolic link in sysfs. Signed-off-by: Andrzej Pietrasiewicz Acked-by: Daniel Vetter --- drivers/gpu/drm/drm_sysfs.c | 7 +++++++ include/drm/drm_connector.h | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index ad10810bc972..26d359b39785 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -294,6 +294,9 @@ int drm_sysfs_connector_add(struct drm_connector *connector) /* Let userspace know we have a new connector */ drm_sysfs_hotplug_event(dev); + if (connector->ddc) + return sysfs_create_link(&connector->kdev->kobj, + &connector->ddc->dev.kobj, "ddc"); return 0; } @@ -301,6 +304,10 @@ void drm_sysfs_connector_remove(struct drm_connector *connector) { if (!connector->kdev) return; + + if (connector->ddc) + sysfs_remove_link(&connector->kdev->kobj, "ddc"); + DRM_DEBUG("removing \"%s\" from sysfs\n", connector->name); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index ca745d9feaf5..1ad3d1d54ba7 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -23,6 +23,7 @@ #ifndef __DRM_CONNECTOR_H__ #define __DRM_CONNECTOR_H__ +#include #include #include #include @@ -1308,6 +1309,16 @@ struct drm_connector { * [0]: progressive, [1]: interlaced */ int audio_latency[2]; + + /** + * @ddc: associated ddc adapter. + * A connector usually has its associated ddc adapter. If a driver uses + * this field, then an appropriate symbolic link is created in connector + * sysfs directory to make it easy for the user to tell which i2c + * adapter is for a particular display. + */ + struct i2c_adapter *ddc; + /** * @null_edid_counter: track sinks that give us all zeros for the EDID. * Needed to workaround some HW bugs where we get all 0s From patchwork Tue Jun 25 10:24:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11015219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B112514B6 for ; Tue, 25 Jun 2019 10:25:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A351C1FFB1 for ; Tue, 25 Jun 2019 10:25:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9592B28BCE; Tue, 25 Jun 2019 10:25:03 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40F191FFB1 for ; Tue, 25 Jun 2019 10:25:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727102AbfFYKY4 (ORCPT ); Tue, 25 Jun 2019 06:24:56 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56404 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726301AbfFYKYv (ORCPT ); Tue, 25 Jun 2019 06:24:51 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 5B0F2288E52 From: Andrzej Pietrasiewicz To: dri-devel@lists.freedesktop.org Cc: kernel@collabora.com, m.szyprowski@samsung.com, Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Kukjin Kim , Krzysztof Kozlowski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH v2 2/2] drm/exynos: Provide ddc symlink in connector's sysfs Date: Tue, 25 Jun 2019 12:24:41 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: <20190625101655.n246vbwtupb4eoyz@shell.armlinux.org.uk> In-Reply-To: References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch to using the ddc provided by the generic connector. Signed-off-by: Andrzej Pietrasiewicz --- drivers/gpu/drm/exynos/exynos_hdmi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 894a99793633..6816e37861b7 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -126,7 +126,6 @@ struct hdmi_context { void __iomem *regs; void __iomem *regs_hdmiphy; struct i2c_client *hdmiphy_port; - struct i2c_adapter *ddc_adpt; struct gpio_desc *hpd_gpio; int irq; struct regmap *pmureg; @@ -872,10 +871,10 @@ static int hdmi_get_modes(struct drm_connector *connector) struct edid *edid; int ret; - if (!hdata->ddc_adpt) + if (!connector->ddc) return -ENODEV; - edid = drm_get_edid(connector, hdata->ddc_adpt); + edid = drm_get_edid(connector, connector->ddc); if (!edid) return -ENODEV; @@ -1893,7 +1892,7 @@ static int hdmi_get_ddc_adapter(struct hdmi_context *hdata) return -EPROBE_DEFER; } - hdata->ddc_adpt = adpt; + hdata->connector.ddc = adpt; return 0; } @@ -2045,7 +2044,7 @@ static int hdmi_probe(struct platform_device *pdev) if (hdata->regs_hdmiphy) iounmap(hdata->regs_hdmiphy); err_ddc: - put_device(&hdata->ddc_adpt->dev); + put_device(&hdata->connector.ddc->dev); return ret; } @@ -2072,7 +2071,7 @@ static int hdmi_remove(struct platform_device *pdev) if (hdata->regs_hdmiphy) iounmap(hdata->regs_hdmiphy); - put_device(&hdata->ddc_adpt->dev); + put_device(&hdata->connector.ddc->dev); mutex_destroy(&hdata->mutex);