From patchwork Mon Sep 11 12:29:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 9947307 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 50D6A602C9 for ; Mon, 11 Sep 2017 12:30:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 316C328BDC for ; Mon, 11 Sep 2017 12:30:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 264F728BE9; Mon, 11 Sep 2017 12:30:05 +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 CCBFE28BDC for ; Mon, 11 Sep 2017 12:30:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CDFB86E3A8; Mon, 11 Sep 2017 12:30:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lb2-smtp-cloud8.xs4all.net (lb2-smtp-cloud8.xs4all.net [194.109.24.25]) by gabe.freedesktop.org (Postfix) with ESMTPS id 654526E342 for ; Mon, 11 Sep 2017 12:29:59 +0000 (UTC) Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud8.xs4all.net with ESMTPA id rNqaddCkGcQyLrNqfdpGhp; Mon, 11 Sep 2017 14:29:58 +0200 From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [PATCHv4 4/4] drm/tegra: add cec-notifier support Date: Mon, 11 Sep 2017 14:29:52 +0200 Message-Id: <20170911122952.33980-5-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170911122952.33980-1-hverkuil@xs4all.nl> References: <20170911122952.33980-1-hverkuil@xs4all.nl> X-CMAE-Envelope: MS4wfBpIIhJRwv/I8E+YNqb0chtY0ELz2cPBzvM75FRZUzINqLhlaNLBjeavPaejqXfkBf/RL0+Xq7TVrCUiBE8MXhsdHHkfSIL5HB1ncEYLgLltXjbuELka ICLZeQtiP602M7U6uTSukYMcdkVHBKPBsgBOTqvb7KPtabBwv0FLRMSQKAUkYnkfYVTvit73BKClbnSG3byoUGdh2c4X7kg4K3IHhQgiD5Im1KH/ZgogI0cw uboc4T4uIc/cB1thz8qAcGeWs0PhwyRbzS89xoe9OJx74aeP5f513Wj+/AvnLjSqX4q5JJ8/puZnTVV3XnBtYXmBZErn5DyO5QgQHwXkYdqa78gsLyHEFV9w lD/vLZCl Cc: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, thierry.reding@gmail.com, Hans Verkuil , dri-devel@lists.freedesktop.org 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 In order to support CEC the HDMI driver has to inform the CEC driver whenever the physical address changes. So when the EDID is read the CEC driver has to be informed and whenever the hotplug detect goes away. This is done through the cec-notifier framework. The link between the HDMI driver and the CEC driver is done through the hdmi_phandle in the tegra-cec node in the device tree. Signed-off-by: Hans Verkuil --- drivers/gpu/drm/tegra/Kconfig | 1 + drivers/gpu/drm/tegra/drm.h | 3 +++ drivers/gpu/drm/tegra/hdmi.c | 9 +++++++++ drivers/gpu/drm/tegra/output.c | 6 ++++++ 4 files changed, 19 insertions(+) diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig index 2db29d67193d..c882918c2024 100644 --- a/drivers/gpu/drm/tegra/Kconfig +++ b/drivers/gpu/drm/tegra/Kconfig @@ -8,6 +8,7 @@ config DRM_TEGRA select DRM_PANEL select TEGRA_HOST1X select IOMMU_IOVA if IOMMU_SUPPORT + select CEC_CORE if CEC_NOTIFIER help Choose this option if you have an NVIDIA Tegra SoC. diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index 6d6da01282f3..c0a18b60caf1 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -212,6 +212,8 @@ int tegra_dc_state_setup_clock(struct tegra_dc *dc, struct clk *clk, unsigned long pclk, unsigned int div); +struct cec_notifier; + struct tegra_output { struct device_node *of_node; struct device *dev; @@ -219,6 +221,7 @@ struct tegra_output { struct drm_panel *panel; struct i2c_adapter *ddc; const struct edid *edid; + struct cec_notifier *notifier; unsigned int hpd_irq; int hpd_gpio; enum of_gpio_flags hpd_gpio_flags; diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c index cda0491ed6bf..fbf14e1efd0e 100644 --- a/drivers/gpu/drm/tegra/hdmi.c +++ b/drivers/gpu/drm/tegra/hdmi.c @@ -21,6 +21,8 @@ #include +#include + #include "hdmi.h" #include "drm.h" #include "dc.h" @@ -1720,6 +1722,10 @@ static int tegra_hdmi_probe(struct platform_device *pdev) return PTR_ERR(hdmi->vdd); } + hdmi->output.notifier = cec_notifier_get(&pdev->dev); + if (hdmi->output.notifier == NULL) + return -ENOMEM; + hdmi->output.dev = &pdev->dev; err = tegra_output_probe(&hdmi->output); @@ -1778,6 +1784,9 @@ static int tegra_hdmi_remove(struct platform_device *pdev) tegra_output_remove(&hdmi->output); + if (hdmi->output.notifier) + cec_notifier_put(hdmi->output.notifier); + return 0; } diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c index 595d1ec3e02e..57c052521a44 100644 --- a/drivers/gpu/drm/tegra/output.c +++ b/drivers/gpu/drm/tegra/output.c @@ -11,6 +11,8 @@ #include #include "drm.h" +#include + int tegra_output_connector_get_modes(struct drm_connector *connector) { struct tegra_output *output = connector_to_output(connector); @@ -33,6 +35,7 @@ int tegra_output_connector_get_modes(struct drm_connector *connector) edid = drm_get_edid(connector, output->ddc); drm_mode_connector_update_edid_property(connector, edid); + cec_notifier_set_phys_addr_from_edid(output->notifier, edid); if (edid) { err = drm_add_edid_modes(connector, edid); @@ -68,6 +71,9 @@ tegra_output_connector_detect(struct drm_connector *connector, bool force) status = connector_status_connected; } + if (status != connector_status_connected) + cec_notifier_phys_addr_invalidate(output->notifier); + return status; }