diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2017-11-05 13:36:36 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-08 17:10:00 +0100 |
commit | 48ea2e926b5ad29c0747fbd90e605cc56fb78298 (patch) | |
tree | 368c7d86ad1cf8640a99f31df7fd5970e14a5ee2 /drivers/media/cec/cec-adap.c | |
parent | media: pulse8-cec: print time using time64_t (diff) | |
download | linux-48ea2e926b5ad29c0747fbd90e605cc56fb78298.tar.xz linux-48ea2e926b5ad29c0747fbd90e605cc56fb78298.zip |
media: cec: add the adap_monitor_pin_enable op
Some devices can monitor the CEC pin using an interrupt, but you
only want to enable the interrupt if you actually switch to pin
monitoring mode.
So add a new op that is called when pin monitoring needs to be
switched on or off.
Also fix a small bug where the initial CEC pin event was sent
again when calling S_MODE twice with the same CEC_MODE_MONITOR_PIN
mode.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/cec/cec-adap.c')
-rw-r--r-- | drivers/media/cec/cec-adap.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c index 91d72805ee59..2a097e016414 100644 --- a/drivers/media/cec/cec-adap.c +++ b/drivers/media/cec/cec-adap.c @@ -2053,6 +2053,29 @@ void cec_monitor_all_cnt_dec(struct cec_adapter *adap) WARN_ON(call_op(adap, adap_monitor_all_enable, 0)); } +/* + * Helper functions to keep track of the 'monitor pin' use count. + * + * These functions are called with adap->lock held. + */ +int cec_monitor_pin_cnt_inc(struct cec_adapter *adap) +{ + int ret = 0; + + if (adap->monitor_pin_cnt == 0) + ret = call_op(adap, adap_monitor_pin_enable, 1); + if (ret == 0) + adap->monitor_pin_cnt++; + return ret; +} + +void cec_monitor_pin_cnt_dec(struct cec_adapter *adap) +{ + adap->monitor_pin_cnt--; + if (adap->monitor_pin_cnt == 0) + WARN_ON(call_op(adap, adap_monitor_pin_enable, 0)); +} + #ifdef CONFIG_DEBUG_FS /* * Log the current state of the CEC adapter. |