[media] cec: integrate CEC notifier support
authorHans Verkuil <hans.verkuil@cisco.com>
Tue, 13 Dec 2016 14:15:57 +0000 (12:15 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 10 Apr 2017 15:49:19 +0000 (12:49 -0300)
Support the CEC notifier framework, simplifying drivers that
depend on this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/cec/cec-core.c
include/media/cec.h

index 37217e2..e5070b3 100644 (file)
@@ -195,6 +195,24 @@ static void cec_devnode_unregister(struct cec_devnode *devnode)
        put_device(&devnode->dev);
 }
 
+#ifdef CONFIG_MEDIA_CEC_NOTIFIER
+static void cec_cec_notify(struct cec_adapter *adap, u16 pa)
+{
+       cec_s_phys_addr(adap, pa, false);
+}
+
+void cec_register_cec_notifier(struct cec_adapter *adap,
+                              struct cec_notifier *notifier)
+{
+       if (WARN_ON(!adap->devnode.registered))
+               return;
+
+       adap->notifier = notifier;
+       cec_notifier_register(adap->notifier, adap, cec_cec_notify);
+}
+EXPORT_SYMBOL_GPL(cec_register_cec_notifier);
+#endif
+
 struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
                                         void *priv, const char *name, u32 caps,
                                         u8 available_las)
@@ -343,6 +361,10 @@ void cec_unregister_adapter(struct cec_adapter *adap)
        adap->rc = NULL;
 #endif
        debugfs_remove_recursive(adap->cec_dir);
+#ifdef CONFIG_MEDIA_CEC_NOTIFIER
+       if (adap->notifier)
+               cec_notifier_unregister(adap->notifier);
+#endif
        cec_devnode_unregister(&adap->devnode);
 }
 EXPORT_SYMBOL_GPL(cec_unregister_adapter);
index 0daff8c..b313e3e 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/cec-funcs.h>
 #include <media/rc-core.h>
 #include <media/cec-edid.h>
+#include <media/cec-notifier.h>
 
 /**
  * struct cec_devnode - cec device node
@@ -173,6 +174,10 @@ struct cec_adapter {
        bool passthrough;
        struct cec_log_addrs log_addrs;
 
+#ifdef CONFIG_MEDIA_CEC_NOTIFIER
+       struct cec_notifier *notifier;
+#endif
+
        struct dentry *cec_dir;
        struct dentry *status_file;
 
@@ -218,6 +223,11 @@ void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt,
                       u8 nack_cnt, u8 low_drive_cnt, u8 error_cnt);
 void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg);
 
+#ifdef CONFIG_MEDIA_CEC_NOTIFIER
+void cec_register_cec_notifier(struct cec_adapter *adap,
+                              struct cec_notifier *notifier);
+#endif
+
 #else
 
 static inline int cec_register_adapter(struct cec_adapter *adap,