]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
media: cec: add support for 5V signal testing
authorHans Verkuil <hans.verkuil@cisco.com>
Thu, 28 Jun 2018 11:43:46 +0000 (07:43 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Wed, 25 Jul 2018 11:11:48 +0000 (07:11 -0400)
Add support for the new 5V CEC events

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/cec/cec-adap.c
drivers/media/cec/cec-api.c
include/media/cec-pin.h
include/media/cec.h

index b7fad0ec57108f9b2bf3f19bc316e8fe2f6b5be8..030b2602faf0c322ad0483cd5f0f29e565b06497 100644 (file)
@@ -74,7 +74,7 @@ void cec_queue_event_fh(struct cec_fh *fh,
                        const struct cec_event *new_ev, u64 ts)
 {
        static const u16 max_events[CEC_NUM_EVENTS] = {
-               1, 1, 800, 800, 8, 8,
+               1, 1, 800, 800, 8, 8, 8, 8
        };
        struct cec_event_entry *entry;
        unsigned int ev_idx = new_ev->event - 1;
@@ -176,6 +176,22 @@ void cec_queue_pin_hpd_event(struct cec_adapter *adap, bool is_high, ktime_t ts)
 }
 EXPORT_SYMBOL_GPL(cec_queue_pin_hpd_event);
 
+/* Notify userspace that the 5V pin changed state at the given time. */
+void cec_queue_pin_5v_event(struct cec_adapter *adap, bool is_high, ktime_t ts)
+{
+       struct cec_event ev = {
+               .event = is_high ? CEC_EVENT_PIN_5V_HIGH :
+                                  CEC_EVENT_PIN_5V_LOW,
+       };
+       struct cec_fh *fh;
+
+       mutex_lock(&adap->devnode.lock);
+       list_for_each_entry(fh, &adap->devnode.fhs, list)
+               cec_queue_event_fh(fh, &ev, ktime_to_ns(ts));
+       mutex_unlock(&adap->devnode.lock);
+}
+EXPORT_SYMBOL_GPL(cec_queue_pin_5v_event);
+
 /*
  * Queue a new message for this filehandle.
  *
index 10b67fc40318e7b9497216f5843ba017305c9514..b6536bbad530c6b2bed6af16a9a4b1a41b32726a 100644 (file)
@@ -579,6 +579,14 @@ static int cec_open(struct inode *inode, struct file *filp)
                        cec_queue_event_fh(fh, &ev, 0);
                }
        }
+       if (adap->pin && adap->pin->ops->read_5v) {
+               err = adap->pin->ops->read_5v(adap);
+               if (err >= 0) {
+                       ev.event = err ? CEC_EVENT_PIN_5V_HIGH :
+                                        CEC_EVENT_PIN_5V_LOW;
+                       cec_queue_event_fh(fh, &ev, 0);
+               }
+       }
 #endif
 
        list_add(&fh->list, &devnode->fhs);
index ed16c6dde0ba2117e3fd01ab60462af214b22f7b..604e79cb6cbfaf418989e65ec9cbc07f4d9872ab 100644 (file)
@@ -25,6 +25,9 @@
  * @read_hpd:  read the HPD pin. Return true if high, false if low or
  *             an error if negative. If NULL or -ENOTTY is returned,
  *             then this is not supported.
+ * @read_5v:   read the 5V pin. Return true if high, false if low or
+ *             an error if negative. If NULL or -ENOTTY is returned,
+ *             then this is not supported.
  *
  * These operations are used by the cec pin framework to manipulate
  * the CEC pin.
@@ -38,6 +41,7 @@ struct cec_pin_ops {
        void (*free)(struct cec_adapter *adap);
        void (*status)(struct cec_adapter *adap, struct seq_file *file);
        int  (*read_hpd)(struct cec_adapter *adap);
+       int  (*read_5v)(struct cec_adapter *adap);
 };
 
 /**
index 580ab1042898169a24cf9c26062b10f5e4f583c4..ff9847f7f99d28f83af74d832b1a2d604ccb0657 100644 (file)
@@ -79,7 +79,7 @@ struct cec_event_entry {
 };
 
 #define CEC_NUM_CORE_EVENTS 2
-#define CEC_NUM_EVENTS CEC_EVENT_PIN_HPD_HIGH
+#define CEC_NUM_EVENTS CEC_EVENT_PIN_5V_HIGH
 
 struct cec_fh {
        struct list_head        list;
@@ -308,6 +308,16 @@ void cec_queue_pin_cec_event(struct cec_adapter *adap, bool is_high,
  */
 void cec_queue_pin_hpd_event(struct cec_adapter *adap, bool is_high, ktime_t ts);
 
+/**
+ * cec_queue_pin_5v_event() - queue a pin event with a given timestamp.
+ *
+ * @adap:      pointer to the cec adapter
+ * @is_high:   when true the 5V pin is high, otherwise it is low
+ * @ts:                the timestamp for this event
+ *
+ */
+void cec_queue_pin_5v_event(struct cec_adapter *adap, bool is_high, ktime_t ts);
+
 /**
  * cec_get_edid_phys_addr() - find and return the physical address
  *