Skip to content

Commit 4786b0d

Browse files
Hans Verkuilmchehab
authored andcommitted
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>
1 parent f48a534 commit 4786b0d

4 files changed

Lines changed: 40 additions & 2 deletions

File tree

‎drivers/media/cec/cec-adap.c‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void cec_queue_event_fh(struct cec_fh *fh,
7474
const struct cec_event *new_ev, u64 ts)
7575
{
7676
static const u16 max_events[CEC_NUM_EVENTS] = {
77-
1, 1, 800, 800, 8, 8,
77+
1, 1, 800, 800, 8, 8, 8, 8
7878
};
7979
struct cec_event_entry *entry;
8080
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)
176176
}
177177
EXPORT_SYMBOL_GPL(cec_queue_pin_hpd_event);
178178

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);
194+
179195
/*
180196
* Queue a new message for this filehandle.
181197
*

‎drivers/media/cec/cec-api.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,14 @@ static int cec_open(struct inode *inode, struct file *filp)
579579
cec_queue_event_fh(fh, &ev, 0);
580580
}
581581
}
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+
}
582590
#endif
583591

584592
list_add(&fh->list, &devnode->fhs);

‎include/media/cec-pin.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
* @read_hpd: read the HPD pin. Return true if high, false if low or
2626
* an error if negative. If NULL or -ENOTTY is returned,
2727
* 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.
2831
*
2932
* These operations are used by the cec pin framework to manipulate
3033
* the CEC pin.
@@ -38,6 +41,7 @@ struct cec_pin_ops {
3841
void (*free)(struct cec_adapter *adap);
3942
void (*status)(struct cec_adapter *adap, struct seq_file *file);
4043
int (*read_hpd)(struct cec_adapter *adap);
44+
int (*read_5v)(struct cec_adapter *adap);
4145
};
4246

4347
/**

‎include/media/cec.h‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct cec_event_entry {
7979
};
8080

8181
#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
8383

8484
struct cec_fh {
8585
struct list_head list;
@@ -308,6 +308,16 @@ void cec_queue_pin_cec_event(struct cec_adapter *adap, bool is_high,
308308
*/
309309
void cec_queue_pin_hpd_event(struct cec_adapter *adap, bool is_high, ktime_t ts);
310310

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);
320+
311321
/**
312322
* cec_get_edid_phys_addr() - find and return the physical address
313323
*

0 commit comments

Comments
 (0)