From patchwork Tue Dec 13 15:08:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 9472569 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 CCED76021C for ; Tue, 13 Dec 2016 15:12:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEBA4284F7 for ; Tue, 13 Dec 2016 15:12:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3BF0285DC; Tue, 13 Dec 2016 15:12:34 +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=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 13D20284F7 for ; Tue, 13 Dec 2016 15:12:34 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cGojH-0007DE-Kj; Tue, 13 Dec 2016 15:10:55 +0000 Received: from lb1-smtp-cloud3.xs4all.net ([194.109.24.22]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cGohA-0004Xq-GZ for linux-arm-kernel@lists.infradead.org; Tue, 13 Dec 2016 15:08:54 +0000 Received: from marune.fritz.box ([IPv6:2001:983:e9a7:1:ef31:4dcf:822e:7392]) by smtp-cloud3.xs4all.net with ESMTP id KT8D1u00W3YS7uB01T8MeL; Tue, 13 Dec 2016 16:08:21 +0100 From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [PATCH 4/4] s5p-cec: add hdmi-notifier support, move out of staging Date: Tue, 13 Dec 2016 16:08:13 +0100 Message-Id: <20161213150813.37966-5-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161213150813.37966-1-hverkuil@xs4all.nl> References: <20161213150813.37966-1-hverkuil@xs4all.nl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161213_070844_926527_0FD3A786 X-CRM114-Status: GOOD ( 19.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Russell King , dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Hans Verkuil , Benjamin Gaignard , linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil By using the HDMI notifier framework there is no longer any reason to manually set the physical address. This was the one blocking issue that prevented this driver from going out of staging, so do this move as well. Update the bindings documenting the new hdmi phandle and update exynos4.dtsi accordingly. Tested with my Odroid U3. Signed-off-by: Hans Verkuil --- .../devicetree/bindings/media/s5p-cec.txt | 2 ++ arch/arm/boot/dts/exynos4.dtsi | 1 + drivers/media/platform/Kconfig | 18 +++++++++++ drivers/media/platform/Makefile | 1 + .../media => media/platform}/s5p-cec/Makefile | 0 .../platform}/s5p-cec/exynos_hdmi_cec.h | 0 .../platform}/s5p-cec/exynos_hdmi_cecctrl.c | 0 .../media => media/platform}/s5p-cec/regs-cec.h | 0 .../media => media/platform}/s5p-cec/s5p_cec.c | 35 ++++++++++++++++++---- .../media => media/platform}/s5p-cec/s5p_cec.h | 3 ++ drivers/staging/media/Kconfig | 2 -- drivers/staging/media/Makefile | 1 - drivers/staging/media/s5p-cec/Kconfig | 9 ------ drivers/staging/media/s5p-cec/TODO | 7 ----- 14 files changed, 55 insertions(+), 24 deletions(-) rename drivers/{staging/media => media/platform}/s5p-cec/Makefile (100%) rename drivers/{staging/media => media/platform}/s5p-cec/exynos_hdmi_cec.h (100%) rename drivers/{staging/media => media/platform}/s5p-cec/exynos_hdmi_cecctrl.c (100%) rename drivers/{staging/media => media/platform}/s5p-cec/regs-cec.h (100%) rename drivers/{staging/media => media/platform}/s5p-cec/s5p_cec.c (89%) rename drivers/{staging/media => media/platform}/s5p-cec/s5p_cec.h (97%) delete mode 100644 drivers/staging/media/s5p-cec/Kconfig delete mode 100644 drivers/staging/media/s5p-cec/TODO diff --git a/Documentation/devicetree/bindings/media/s5p-cec.txt b/Documentation/devicetree/bindings/media/s5p-cec.txt index 925ab4d..710fc00 100644 --- a/Documentation/devicetree/bindings/media/s5p-cec.txt +++ b/Documentation/devicetree/bindings/media/s5p-cec.txt @@ -15,6 +15,7 @@ Required properties: - clock-names : from common clock binding: must contain "hdmicec", corresponding to entry in the clocks property. - samsung,syscon-phandle - phandle to the PMU system controller + - samsung,hdmi-phandle - phandle to the HDMI controller Example: @@ -25,6 +26,7 @@ hdmicec: cec@100B0000 { clocks = <&clock CLK_HDMI_CEC>; clock-names = "hdmicec"; samsung,syscon-phandle = <&pmu_system_controller>; + samsung,hdmi-phandle = <&hdmi>; pinctrl-names = "default"; pinctrl-0 = <&hdmi_cec>; status = "okay"; diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi index 5f034eb..48ab7fc 100644 --- a/arch/arm/boot/dts/exynos4.dtsi +++ b/arch/arm/boot/dts/exynos4.dtsi @@ -750,6 +750,7 @@ clocks = <&clock CLK_HDMI_CEC>; clock-names = "hdmicec"; samsung,syscon-phandle = <&pmu_system_controller>; + samsung,hdmi-phandle = <&hdmi>; pinctrl-names = "default"; pinctrl-0 = <&hdmi_cec>; status = "disabled"; diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index d944421..42f747a 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -392,6 +392,24 @@ config VIDEO_TI_SC config VIDEO_TI_CSC tristate +menuconfig V4L_CEC_DRIVERS + bool "Platform HDMI CEC drivers" + depends on MEDIA_CEC_SUPPORT + +if V4L_CEC_DRIVERS + +config VIDEO_SAMSUNG_S5P_CEC + tristate "Samsung S5P CEC driver" + depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST) + select HDMI_NOTIFIERS + ---help--- + This is a driver for Samsung S5P HDMI CEC interface. It uses the + generic CEC framework interface. + CEC bus is present in the HDMI connector and enables communication + between compatible devices. + +endif #V4L_CEC_DRIVERS + menuconfig V4L_TEST_DRIVERS bool "Media test drivers" depends on MEDIA_CAMERA_SUPPORT diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile index 5b3cb27..ad3bf22 100644 --- a/drivers/media/platform/Makefile +++ b/drivers/media/platform/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg/ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC) += s5p-mfc/ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D) += s5p-g2d/ +obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC) += s5p-cec/ obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/ obj-$(CONFIG_VIDEO_STI_BDISP) += sti/bdisp/ diff --git a/drivers/staging/media/s5p-cec/Makefile b/drivers/media/platform/s5p-cec/Makefile similarity index 100% rename from drivers/staging/media/s5p-cec/Makefile rename to drivers/media/platform/s5p-cec/Makefile diff --git a/drivers/staging/media/s5p-cec/exynos_hdmi_cec.h b/drivers/media/platform/s5p-cec/exynos_hdmi_cec.h similarity index 100% rename from drivers/staging/media/s5p-cec/exynos_hdmi_cec.h rename to drivers/media/platform/s5p-cec/exynos_hdmi_cec.h diff --git a/drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c b/drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c similarity index 100% rename from drivers/staging/media/s5p-cec/exynos_hdmi_cecctrl.c rename to drivers/media/platform/s5p-cec/exynos_hdmi_cecctrl.c diff --git a/drivers/staging/media/s5p-cec/regs-cec.h b/drivers/media/platform/s5p-cec/regs-cec.h similarity index 100% rename from drivers/staging/media/s5p-cec/regs-cec.h rename to drivers/media/platform/s5p-cec/regs-cec.h diff --git a/drivers/staging/media/s5p-cec/s5p_cec.c b/drivers/media/platform/s5p-cec/s5p_cec.c similarity index 89% rename from drivers/staging/media/s5p-cec/s5p_cec.c rename to drivers/media/platform/s5p-cec/s5p_cec.c index 2a07968..565ee92 100644 --- a/drivers/staging/media/s5p-cec/s5p_cec.c +++ b/drivers/media/platform/s5p-cec/s5p_cec.c @@ -14,15 +14,18 @@ */ #include +#include #include #include #include #include #include +#include #include #include #include #include +#include #include #include "exynos_hdmi_cec.h" @@ -167,10 +170,22 @@ static const struct cec_adap_ops s5p_cec_adap_ops = { static int s5p_cec_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct device_node *np; + struct platform_device *hdmi_dev; struct resource *res; struct s5p_cec_dev *cec; int ret; + np = of_parse_phandle(pdev->dev.of_node, "samsung,hdmi-phandle", 0); + + if (!np) { + dev_err(&pdev->dev, "Failed to find hdmi node in device tree\n"); + return -ENODEV; + } + hdmi_dev = of_find_device_by_node(np); + if (hdmi_dev == NULL) + return -EPROBE_DEFER; + cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL); if (!cec) return -ENOMEM; @@ -200,24 +215,33 @@ static int s5p_cec_probe(struct platform_device *pdev) if (IS_ERR(cec->reg)) return PTR_ERR(cec->reg); + cec->notifier = hdmi_notifier_get(&hdmi_dev->dev); + if (cec->notifier == NULL) + return -ENOMEM; + cec->adap = cec_allocate_adapter(&s5p_cec_adap_ops, cec, CEC_NAME, - CEC_CAP_PHYS_ADDR | CEC_CAP_LOG_ADDRS | CEC_CAP_TRANSMIT | + CEC_CAP_LOG_ADDRS | CEC_CAP_TRANSMIT | CEC_CAP_PASSTHROUGH | CEC_CAP_RC, 1); ret = PTR_ERR_OR_ZERO(cec->adap); if (ret) return ret; + ret = cec_register_adapter(cec->adap, &pdev->dev); - if (ret) { - cec_delete_adapter(cec->adap); - return ret; - } + if (ret) + goto err_delete_adapter; + + cec_register_hdmi_notifier(cec->adap, cec->notifier); platform_set_drvdata(pdev, cec); pm_runtime_enable(dev); dev_dbg(dev, "successfuly probed\n"); return 0; + +err_delete_adapter: + cec_delete_adapter(cec->adap); + return ret; } static int s5p_cec_remove(struct platform_device *pdev) @@ -225,6 +249,7 @@ static int s5p_cec_remove(struct platform_device *pdev) struct s5p_cec_dev *cec = platform_get_drvdata(pdev); cec_unregister_adapter(cec->adap); + hdmi_notifier_put(cec->notifier); pm_runtime_disable(&pdev->dev); return 0; } diff --git a/drivers/staging/media/s5p-cec/s5p_cec.h b/drivers/media/platform/s5p-cec/s5p_cec.h similarity index 97% rename from drivers/staging/media/s5p-cec/s5p_cec.h rename to drivers/media/platform/s5p-cec/s5p_cec.h index 03732c1..69856b1 100644 --- a/drivers/staging/media/s5p-cec/s5p_cec.h +++ b/drivers/media/platform/s5p-cec/s5p_cec.h @@ -59,12 +59,15 @@ enum cec_state { STATE_ERROR }; +struct hdmi_notifier; + struct s5p_cec_dev { struct cec_adapter *adap; struct clk *clk; struct device *dev; struct mutex lock; struct regmap *pmu; + struct hdmi_notifier *notifier; int irq; void __iomem *reg; diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig index ffb8fa7..1b7804c 100644 --- a/drivers/staging/media/Kconfig +++ b/drivers/staging/media/Kconfig @@ -27,8 +27,6 @@ source "drivers/staging/media/davinci_vpfe/Kconfig" source "drivers/staging/media/omap4iss/Kconfig" -source "drivers/staging/media/s5p-cec/Kconfig" - # Keep LIRC at the end, as it has sub-menus source "drivers/staging/media/lirc/Kconfig" diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile index a28e82c..e11afbf 100644 --- a/drivers/staging/media/Makefile +++ b/drivers/staging/media/Makefile @@ -1,5 +1,4 @@ obj-$(CONFIG_I2C_BCM2048) += bcm2048/ -obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC) += s5p-cec/ obj-$(CONFIG_DVB_CXD2099) += cxd2099/ obj-$(CONFIG_LIRC_STAGING) += lirc/ obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/ diff --git a/drivers/staging/media/s5p-cec/Kconfig b/drivers/staging/media/s5p-cec/Kconfig deleted file mode 100644 index ddfd955..0000000 --- a/drivers/staging/media/s5p-cec/Kconfig +++ /dev/null @@ -1,9 +0,0 @@ -config VIDEO_SAMSUNG_S5P_CEC - tristate "Samsung S5P CEC driver" - depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST) - ---help--- - This is a driver for Samsung S5P HDMI CEC interface. It uses the - generic CEC framework interface. - CEC bus is present in the HDMI connector and enables communication - between compatible devices. - diff --git a/drivers/staging/media/s5p-cec/TODO b/drivers/staging/media/s5p-cec/TODO deleted file mode 100644 index 64f21ba..0000000 --- a/drivers/staging/media/s5p-cec/TODO +++ /dev/null @@ -1,7 +0,0 @@ -This driver requires that userspace sets the physical address. -However, this should be passed on from the corresponding -Samsung HDMI driver. - -We have to wait until the HDMI notifier framework has been merged -in order to handle this gracefully, until that time this driver -has to remain in staging.