summaryrefslogtreecommitdiff
path: root/drivers/media/cec/cec-api.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2017-02-10 13:02:31 -0200
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-03-22 11:11:17 -0300
commit533a3f7bc7919f8f5462d6b921532cf1d1ccf6cd (patch)
tree4873aeebb01cdfa84504bacd748b47acbe950398 /drivers/media/cec/cec-api.c
parentb39f93efc698fadc94a5fa273798f9e317089c72 (diff)
[media] cec: allow specific messages even when unconfigured
The CEC specifications explicitly allows you to send poll messages and Image/Text View On messages to a TV, even when unconfigured (i.e. there is no hotplug signal detected). Some TVs will pull the HPD low when switching to another input, or when going into standby, but CEC should still be allowed to wake up such a display. Add support for sending messages with initiator 0xf (Unregistered) and destination 0 (TV) when no physical address is present. This also required another change: the CEC adapter has to stay enabled as long as 1) the CEC device is configured or 2) at least one filehandle is open for the CEC device. 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-api.c')
-rw-r--r--drivers/media/cec/cec-api.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c
index 8950b6c9d6a9..627cdf7b12d1 100644
--- a/drivers/media/cec/cec-api.c
+++ b/drivers/media/cec/cec-api.c
@@ -198,7 +198,9 @@ static long cec_transmit(struct cec_adapter *adap, struct cec_fh *fh,
return -EINVAL;
mutex_lock(&adap->lock);
- if (!adap->is_configured)
+ if (adap->is_configuring)
+ err = -ENONET;
+ else if (!adap->is_configured && (msg.msg[0] != 0xf0 || msg.reply))
err = -ENONET;
else if (cec_is_busy(adap, fh))
err = -EBUSY;
@@ -515,9 +517,18 @@ static int cec_open(struct inode *inode, struct file *filp)
return err;
}
+ mutex_lock(&devnode->lock);
+ if (list_empty(&devnode->fhs) &&
+ adap->phys_addr == CEC_PHYS_ADDR_INVALID) {
+ err = adap->ops->adap_enable(adap, true);
+ if (err) {
+ mutex_unlock(&devnode->lock);
+ kfree(fh);
+ return err;
+ }
+ }
filp->private_data = fh;
- mutex_lock(&devnode->lock);
/* Queue up initial state events */
ev_state.state_change.phys_addr = adap->phys_addr;
ev_state.state_change.log_addr_mask = adap->log_addrs.log_addr_mask;
@@ -551,6 +562,10 @@ static int cec_release(struct inode *inode, struct file *filp)
mutex_lock(&devnode->lock);
list_del(&fh->list);
+ if (list_empty(&devnode->fhs) &&
+ adap->phys_addr == CEC_PHYS_ADDR_INVALID) {
+ WARN_ON(adap->ops->adap_enable(adap, false));
+ }
mutex_unlock(&devnode->lock);
/* Unhook pending transmits from this filehandle. */