From patchwork Mon Feb 6 10:29:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 9557477 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2370360242 for ; Mon, 6 Feb 2017 10:30:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F2C2269DA for ; Mon, 6 Feb 2017 10:30:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1417127F93; Mon, 6 Feb 2017 10:30:11 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE145269DA for ; Mon, 6 Feb 2017 10:30:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AEC766E3B3; Mon, 6 Feb 2017 10:30:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lb2-smtp-cloud3.xs4all.net (lb2-smtp-cloud3.xs4all.net [194.109.24.26]) by gabe.freedesktop.org (Postfix) with ESMTPS id 13E986E3B3 for ; Mon, 6 Feb 2017 10:30:07 +0000 (UTC) Received: from tschai.lan ([46.9.235.119]) by smtp-cloud3.xs4all.net with ESMTP id hNW01u00H2bEJta01NW5NR; Mon, 06 Feb 2017 11:30:06 +0100 Received: from tschai.fritz.box (localhost [127.0.0.1]) by tschai.lan (Postfix) with ESMTPSA id AE8CA180FF0; Mon, 6 Feb 2017 11:29:51 +0100 (CET) From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [PATCHv4 2/9] exynos_hdmi: add HPD notifier support Date: Mon, 6 Feb 2017 11:29:44 +0100 Message-Id: <20170206102951.12623-3-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170206102951.12623-1-hverkuil@xs4all.nl> References: <20170206102951.12623-1-hverkuil@xs4all.nl> Cc: linux-samsung-soc@vger.kernel.org, Russell King , Krzysztof Kozlowski , Javier Martinez Canillas , Hans Verkuil , dri-devel@lists.freedesktop.org, Daniel Vetter , Marek Szyprowski X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Implement the HPD notifier support to allow CEC drivers to be informed when there is a new EDID and when a connect or disconnect happens. Signed-off-by: Hans Verkuil Tested-by: Marek Szyprowski --- drivers/gpu/drm/exynos/Kconfig | 1 + drivers/gpu/drm/exynos/exynos_hdmi.c | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig index d706ca4e2f02..50309409d450 100644 --- a/drivers/gpu/drm/exynos/Kconfig +++ b/drivers/gpu/drm/exynos/Kconfig @@ -77,6 +77,7 @@ config DRM_EXYNOS_DP config DRM_EXYNOS_HDMI bool "HDMI" depends on DRM_EXYNOS_MIXER || DRM_EXYNOS5433_DECON + select HPD_NOTIFIER help Choose this option if you want to use Exynos HDMI for DRM. diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 5ed8b1effe71..8d48a0a21565 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -118,6 +119,7 @@ struct hdmi_context { bool dvi_mode; struct delayed_work hotplug_work; struct drm_display_mode current_mode; + struct hpd_notifier *notifier; const struct hdmi_driver_data *drv_data; void __iomem *regs; @@ -807,9 +809,12 @@ static enum drm_connector_status hdmi_detect(struct drm_connector *connector, { struct hdmi_context *hdata = connector_to_hdmi(connector); - if (gpiod_get_value(hdata->hpd_gpio)) + if (gpiod_get_value(hdata->hpd_gpio)) { + hpd_event_connect(hdata->notifier); return connector_status_connected; + } + hpd_event_disconnect(hdata->notifier); return connector_status_disconnected; } @@ -848,6 +853,8 @@ static int hdmi_get_modes(struct drm_connector *connector) edid->width_cm, edid->height_cm); drm_mode_connector_update_edid_property(connector, edid); + hpd_event_new_edid(hdata->notifier, edid, + EDID_LENGTH * (1 + edid->extensions)); ret = drm_add_edid_modes(connector, edid); @@ -1483,6 +1490,7 @@ static void hdmi_disable(struct drm_encoder *encoder) if (funcs && funcs->disable) (*funcs->disable)(crtc); + hpd_event_disconnect(hdata->notifier); cancel_delayed_work(&hdata->hotplug_work); hdmiphy_disable(hdata); @@ -1832,15 +1840,22 @@ static int hdmi_probe(struct platform_device *pdev) } } + hdata->notifier = hpd_notifier_get(&pdev->dev); + if (hdata->notifier == NULL) { + ret = -ENOMEM; + goto err_hdmiphy; + } + pm_runtime_enable(dev); ret = component_add(&pdev->dev, &hdmi_component_ops); if (ret) - goto err_disable_pm_runtime; + goto err_notifier_put; return ret; -err_disable_pm_runtime: +err_notifier_put: + hpd_notifier_put(hdata->notifier); pm_runtime_disable(dev); err_hdmiphy: @@ -1859,9 +1874,11 @@ static int hdmi_remove(struct platform_device *pdev) struct hdmi_context *hdata = platform_get_drvdata(pdev); cancel_delayed_work_sync(&hdata->hotplug_work); + hpd_event_disconnect(hdata->notifier); component_del(&pdev->dev, &hdmi_component_ops); + hpd_notifier_put(hdata->notifier); pm_runtime_disable(&pdev->dev); if (!IS_ERR(hdata->reg_hdmi_en))