Commit 83505028 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] vivid: support monitor all mode

Just pass the transmitted CEC message to all CEC adapters.
This implements the Monitor All mode for vivid.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 58ecc29b
......@@ -40,19 +40,18 @@ void vivid_cec_bus_free_work(struct vivid_dev *dev)
spin_unlock(&dev->cec_slock);
}
static struct cec_adapter *vivid_cec_find_dest_adap(struct vivid_dev *dev,
struct cec_adapter *adap,
u8 dest)
static bool vivid_cec_find_dest_adap(struct vivid_dev *dev,
struct cec_adapter *adap, u8 dest)
{
unsigned int i;
if (dest >= 0xf)
return NULL;
return false;
if (adap != dev->cec_rx_adap && dev->cec_rx_adap &&
dev->cec_rx_adap->is_configured &&
cec_has_log_addr(dev->cec_rx_adap, dest))
return dev->cec_rx_adap;
return true;
for (i = 0; i < MAX_OUTPUTS && dev->cec_tx_adap[i]; i++) {
if (adap == dev->cec_tx_adap[i])
......@@ -60,9 +59,9 @@ static struct cec_adapter *vivid_cec_find_dest_adap(struct vivid_dev *dev,
if (!dev->cec_tx_adap[i]->is_configured)
continue;
if (cec_has_log_addr(dev->cec_tx_adap[i], dest))
return dev->cec_tx_adap[i];
return true;
}
return NULL;
return false;
}
static void vivid_cec_xfer_done_worker(struct work_struct *work)
......@@ -71,18 +70,14 @@ static void vivid_cec_xfer_done_worker(struct work_struct *work)
container_of(work, struct vivid_cec_work, work.work);
struct vivid_dev *dev = cw->dev;
struct cec_adapter *adap = cw->adap;
bool is_poll = cw->msg.len == 1;
u8 dest = cec_msg_destination(&cw->msg);
struct cec_adapter *dest_adap = NULL;
bool valid_dest;
unsigned int i;
valid_dest = cec_msg_is_broadcast(&cw->msg);
if (!valid_dest) {
dest_adap = vivid_cec_find_dest_adap(dev, adap, dest);
if (dest_adap)
valid_dest = true;
}
if (!valid_dest)
valid_dest = vivid_cec_find_dest_adap(dev, adap, dest);
cw->tx_status = valid_dest ? CEC_TX_STATUS_OK : CEC_TX_STATUS_NACK;
spin_lock(&dev->cec_slock);
dev->cec_xfer_time_jiffies = 0;
......@@ -91,21 +86,12 @@ static void vivid_cec_xfer_done_worker(struct work_struct *work)
spin_unlock(&dev->cec_slock);
cec_transmit_done(cw->adap, cw->tx_status, 0, valid_dest ? 0 : 1, 0, 0);
if (!is_poll && dest_adap) {
/* Directed message */
cec_received_msg(dest_adap, &cw->msg);
} else if (!is_poll && valid_dest) {
/* Broadcast message */
if (adap != dev->cec_rx_adap &&
dev->cec_rx_adap->log_addrs.log_addr_mask)
if (adap != dev->cec_rx_adap)
cec_received_msg(dev->cec_rx_adap, &cw->msg);
for (i = 0; i < MAX_OUTPUTS && dev->cec_tx_adap[i]; i++) {
if (adap == dev->cec_tx_adap[i] ||
!dev->cec_tx_adap[i]->log_addrs.log_addr_mask)
continue;
for (i = 0; i < MAX_OUTPUTS && dev->cec_tx_adap[i]; i++)
if (adap != dev->cec_tx_adap[i])
cec_received_msg(dev->cec_tx_adap[i], &cw->msg);
}
}
kfree(cw);
}
......@@ -245,7 +231,7 @@ struct cec_adapter *vivid_cec_alloc_adap(struct vivid_dev *dev,
{
char name[sizeof(dev->vid_out_dev.name) + 2];
u32 caps = CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS |
CEC_CAP_PASSTHROUGH | CEC_CAP_RC;
CEC_CAP_PASSTHROUGH | CEC_CAP_RC | CEC_CAP_MONITOR_ALL;
snprintf(name, sizeof(name), "%s%d",
is_source ? dev->vid_out_dev.name : dev->vid_cap_dev.name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment