From patchwork Tue Jun 25 09:46:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11015171 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 C5A5E14E5 for ; Tue, 25 Jun 2019 09:46:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8E05205F8 for ; Tue, 25 Jun 2019 09:46:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACE7B28ABA; Tue, 25 Jun 2019 09:46:58 +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 4F654286EC for ; Tue, 25 Jun 2019 09:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729693AbfFYJqt (ORCPT ); Tue, 25 Jun 2019 05:46:49 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:55848 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727932AbfFYJqs (ORCPT ); Tue, 25 Jun 2019 05:46:48 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 90928260A37 From: Andrzej Pietrasiewicz 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 , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 1/2] drm: Include ddc adapter pointer in struct drm_connector Date: Tue, 25 Jun 2019 11:46:35 +0200 Message-Id: <04382593e44ac3f69cd63adfe0dd0660dc32a722.1561452052.git.andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: To: unlisted-recipients:; (no To-header on input) 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/i2c-2 lrwxrwxrwx 1 root root 0 Jun 24 10:42 /sys/class/drm/card0-HDMI-A-1/i2c-2 \ -> ../../../../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 --- drivers/gpu/drm/drm_sysfs.c | 9 +++++++++ include/drm/drm_connector.h | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index ad10810bc972..627f8ebfc87a 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -294,6 +294,10 @@ 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, + connector->ddc->dev.kobj.name); return 0; } @@ -301,6 +305,11 @@ void drm_sysfs_connector_remove(struct drm_connector *connector) { if (!connector->kdev) return; + + if (connector->ddc) + sysfs_remove_link(&connector->kdev->kobj, + connector->ddc->dev.kobj.name); + 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 09:46:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11015169 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 224EE924 for ; Tue, 25 Jun 2019 09:46:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1405F28451 for ; Tue, 25 Jun 2019 09:46:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 082162875E; Tue, 25 Jun 2019 09:46:58 +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 9103F286EC for ; Tue, 25 Jun 2019 09:46:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728272AbfFYJqx (ORCPT ); Tue, 25 Jun 2019 05:46:53 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:55868 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727729AbfFYJqt (ORCPT ); Tue, 25 Jun 2019 05:46:49 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 81C05263A26 From: Andrzej Pietrasiewicz 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 , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 2/2] drm/exynos: Provide ddc symlink in connector's sysfs Date: Tue, 25 Jun 2019 11:46:36 +0200 Message-Id: <2bc41fb24348c7c3c89e9f653e694f8ae9b36e20.1561452052.git.andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: To: unlisted-recipients:; (no To-header on input) 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);