Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: cec: add support for 5V signal testing

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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
4786b0d6 f48a534a

+40 -2
+17 -1
drivers/media/cec/cec-adap.c
··· 74 74 const struct cec_event *new_ev, u64 ts) 75 75 { 76 76 static const u16 max_events[CEC_NUM_EVENTS] = { 77 - 1, 1, 800, 800, 8, 8, 77 + 1, 1, 800, 800, 8, 8, 8, 8 78 78 }; 79 79 struct cec_event_entry *entry; 80 80 unsigned int ev_idx = new_ev->event - 1; ··· 175 175 mutex_unlock(&adap->devnode.lock); 176 176 } 177 177 EXPORT_SYMBOL_GPL(cec_queue_pin_hpd_event); 178 + 179 + /* Notify userspace that the 5V pin changed state at the given time. */ 180 + void cec_queue_pin_5v_event(struct cec_adapter *adap, bool is_high, ktime_t ts) 181 + { 182 + struct cec_event ev = { 183 + .event = is_high ? CEC_EVENT_PIN_5V_HIGH : 184 + CEC_EVENT_PIN_5V_LOW, 185 + }; 186 + struct cec_fh *fh; 187 + 188 + mutex_lock(&adap->devnode.lock); 189 + list_for_each_entry(fh, &adap->devnode.fhs, list) 190 + cec_queue_event_fh(fh, &ev, ktime_to_ns(ts)); 191 + mutex_unlock(&adap->devnode.lock); 192 + } 193 + EXPORT_SYMBOL_GPL(cec_queue_pin_5v_event); 178 194 179 195 /* 180 196 * Queue a new message for this filehandle.
+8
drivers/media/cec/cec-api.c
··· 579 579 cec_queue_event_fh(fh, &ev, 0); 580 580 } 581 581 } 582 + if (adap->pin && adap->pin->ops->read_5v) { 583 + err = adap->pin->ops->read_5v(adap); 584 + if (err >= 0) { 585 + ev.event = err ? CEC_EVENT_PIN_5V_HIGH : 586 + CEC_EVENT_PIN_5V_LOW; 587 + cec_queue_event_fh(fh, &ev, 0); 588 + } 589 + } 582 590 #endif 583 591 584 592 list_add(&fh->list, &devnode->fhs);
+4
include/media/cec-pin.h
··· 25 25 * @read_hpd: read the HPD pin. Return true if high, false if low or 26 26 * an error if negative. If NULL or -ENOTTY is returned, 27 27 * then this is not supported. 28 + * @read_5v: read the 5V pin. Return true if high, false if low or 29 + * an error if negative. If NULL or -ENOTTY is returned, 30 + * then this is not supported. 28 31 * 29 32 * These operations are used by the cec pin framework to manipulate 30 33 * the CEC pin. ··· 41 38 void (*free)(struct cec_adapter *adap); 42 39 void (*status)(struct cec_adapter *adap, struct seq_file *file); 43 40 int (*read_hpd)(struct cec_adapter *adap); 41 + int (*read_5v)(struct cec_adapter *adap); 44 42 }; 45 43 46 44 /**
+11 -1
include/media/cec.h
··· 79 79 }; 80 80 81 81 #define CEC_NUM_CORE_EVENTS 2 82 - #define CEC_NUM_EVENTS CEC_EVENT_PIN_HPD_HIGH 82 + #define CEC_NUM_EVENTS CEC_EVENT_PIN_5V_HIGH 83 83 84 84 struct cec_fh { 85 85 struct list_head list; ··· 307 307 * 308 308 */ 309 309 void cec_queue_pin_hpd_event(struct cec_adapter *adap, bool is_high, ktime_t ts); 310 + 311 + /** 312 + * cec_queue_pin_5v_event() - queue a pin event with a given timestamp. 313 + * 314 + * @adap: pointer to the cec adapter 315 + * @is_high: when true the 5V pin is high, otherwise it is low 316 + * @ts: the timestamp for this event 317 + * 318 + */ 319 + void cec_queue_pin_5v_event(struct cec_adapter *adap, bool is_high, ktime_t ts); 310 320 311 321 /** 312 322 * cec_get_edid_phys_addr() - find and return the physical address