]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
[media] stih-cec: add CEC notifier support
authorBenjamin Gaignard <benjamin.gaignard@linaro.org>
Tue, 3 Jan 2017 14:54:56 +0000 (12:54 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 10 Apr 2017 15:53:51 +0000 (12:53 -0300)
By using the CEC 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.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/Kconfig
drivers/media/platform/Makefile
drivers/media/platform/sti/cec/Makefile [moved from drivers/staging/media/st-cec/Makefile with 100% similarity]
drivers/media/platform/sti/cec/stih-cec.c [moved from drivers/staging/media/st-cec/stih-cec.c with 93% similarity]
drivers/staging/media/Kconfig
drivers/staging/media/Makefile
drivers/staging/media/st-cec/Kconfig [deleted file]
drivers/staging/media/st-cec/TODO [deleted file]

index ab0bb4879b540b01c2c1fc07349b516c480d077d..e252b27742918c84de4c296120f1896060bf6eb0 100644 (file)
@@ -460,6 +460,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_STI_HDMI_CEC
+       tristate "STMicroelectronics STiH4xx HDMI CEC driver"
+       depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (ARCH_STI || COMPILE_TEST)
+       select MEDIA_CEC_NOTIFIER
+       ---help---
+         This is a driver for STIH4xx 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
index c491731f5909342a9c24168f732e3abf2b777deb..057422cd803e7090d4f4ea1a8f6a2f143d7097fd 100644 (file)
@@ -38,6 +38,7 @@ obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC)        += exynos-gsc/
 obj-$(CONFIG_VIDEO_STI_BDISP)          += sti/bdisp/
 obj-$(CONFIG_VIDEO_STI_HVA)            += sti/hva/
 obj-$(CONFIG_DVB_C8SECTPFE)            += sti/c8sectpfe/
+obj-$(CONFIG_VIDEO_STI_HDMI_CEC)       += sti/cec/
 
 obj-$(CONFIG_VIDEO_STI_DELTA)          += sti/delta/
 
similarity index 93%
rename from drivers/staging/media/st-cec/stih-cec.c
rename to drivers/media/platform/sti/cec/stih-cec.c
index 521206d7aea6060335b8a003cd5dd519556f9d6e..39ff55145a82130806baecddb4bb1b060f922090 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * drivers/staging/media/st-cec/stih-cec.c
- *
  * STIH4xx CEC driver
  * Copyright (C) STMicroelectronic SA 2016
  *
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_platform.h>
 #include <linux/platform_device.h>
 
 #include <media/cec.h>
+#include <media/cec-notifier.h>
 
 #define CEC_NAME       "stih-cec"
 
@@ -129,6 +129,7 @@ struct stih_cec {
        void __iomem            *regs;
        int                     irq;
        u32                     irq_status;
+       struct cec_notifier     *notifier;
 };
 
 static int stih_cec_adap_enable(struct cec_adapter *adap, bool enable)
@@ -303,12 +304,29 @@ static int stih_cec_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct resource *res;
        struct stih_cec *cec;
+       struct device_node *np;
+       struct platform_device *hdmi_dev;
        int ret;
 
        cec = devm_kzalloc(dev, sizeof(*cec), GFP_KERNEL);
        if (!cec)
                return -ENOMEM;
 
+       np = of_parse_phandle(pdev->dev.of_node, "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)
+               return -EPROBE_DEFER;
+
+       cec->notifier = cec_notifier_get(&hdmi_dev->dev);
+       if (!cec->notifier)
+               return -ENOMEM;
+
        cec->dev = dev;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -335,7 +353,7 @@ static int stih_cec_probe(struct platform_device *pdev)
        cec->adap = cec_allocate_adapter(&sti_cec_adap_ops, cec,
                        CEC_NAME,
                        CEC_CAP_LOG_ADDRS | CEC_CAP_PASSTHROUGH |
-                       CEC_CAP_PHYS_ADDR | CEC_CAP_TRANSMIT, 1);
+                       CEC_CAP_TRANSMIT, 1);
        ret = PTR_ERR_OR_ZERO(cec->adap);
        if (ret)
                return ret;
@@ -346,12 +364,19 @@ static int stih_cec_probe(struct platform_device *pdev)
                return ret;
        }
 
+       cec_register_cec_notifier(cec->adap, cec->notifier);
+
        platform_set_drvdata(pdev, cec);
        return 0;
 }
 
 static int stih_cec_remove(struct platform_device *pdev)
 {
+       struct stih_cec *cec = platform_get_drvdata(pdev);
+
+       cec_unregister_adapter(cec->adap);
+       cec_notifier_put(cec->notifier);
+
        return 0;
 }
 
index abd0e2d57c203084a5f4c43c6a23896f5b57822b..28088de6ddd02ac9a858cb3be5b9d5ec379cc18b 100644 (file)
@@ -34,6 +34,4 @@ source "drivers/staging/media/s5p-cec/Kconfig"
 # Keep LIRC at the end, as it has sub-menus
 source "drivers/staging/media/lirc/Kconfig"
 
-source "drivers/staging/media/st-cec/Kconfig"
-
 endif
index dc89325c463d5f35e129c4c94d2aeb3483a803ec..75e47dcdddd6f552a2d1afe936e88cee87681659 100644 (file)
@@ -5,4 +5,3 @@ obj-$(CONFIG_LIRC_STAGING)      += lirc/
 obj-$(CONFIG_VIDEO_BCM2835)    += platform/bcm2835/
 obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/
 obj-$(CONFIG_VIDEO_OMAP4)      += omap4iss/
-obj-$(CONFIG_VIDEO_STI_HDMI_CEC) += st-cec/
diff --git a/drivers/staging/media/st-cec/Kconfig b/drivers/staging/media/st-cec/Kconfig
deleted file mode 100644 (file)
index c04283d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-config VIDEO_STI_HDMI_CEC
-       tristate "STMicroelectronics STiH4xx HDMI CEC driver"
-       depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (ARCH_STI || COMPILE_TEST)
-       ---help---
-         This is a driver for STIH4xx 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/st-cec/TODO b/drivers/staging/media/st-cec/TODO
deleted file mode 100644 (file)
index c612897..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-This driver requires that userspace sets the physical address.
-However, this should be passed on from the corresponding
-ST 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.