drivers/media/test-drivers/vivid/vivid-cec.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vivid/vivid-cec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/vivid/vivid-cec.c- Extension
.c- Size
- 12142 bytes
- Lines
- 416
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hmedia/cec.hvivid-core.hvivid-cec.h
Detected Declarations
struct xfer_on_busfunction find_dest_adapfunction xfer_readyfunction adjust_sftsfunction cec_transmit_attempt_donefunction vivid_cec_adap_enablefunction vivid_cec_adap_log_addrfunction vivid_cec_adap_transmitfunction vivid_received
Annotated Snippet
struct xfer_on_bus {
struct cec_adapter *adap;
u8 status;
};
static bool find_dest_adap(struct vivid_dev *dev,
struct cec_adapter *adap, u8 dest)
{
unsigned int i, j;
if (dest >= 0xf)
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 true;
for (i = 0, j = 0; i < dev->num_inputs; i++) {
unsigned int menu_idx =
dev->input_is_connected_to_output[i];
if (dev->input_type[i] != HDMI)
continue;
j++;
if (menu_idx < FIXED_MENU_ITEMS)
continue;
struct vivid_dev *dev_tx = vivid_ctrl_hdmi_to_output_instance[menu_idx];
unsigned int output = vivid_ctrl_hdmi_to_output_index[menu_idx];
if (!dev_tx)
continue;
unsigned int hdmi_output = dev_tx->output_to_iface_index[output];
if (adap == dev_tx->cec_tx_adap[hdmi_output])
continue;
if (!dev_tx->cec_tx_adap[hdmi_output]->is_configured)
continue;
if (cec_has_log_addr(dev_tx->cec_tx_adap[hdmi_output], dest))
return true;
}
return false;
}
static bool xfer_ready(struct vivid_dev *dev)
{
unsigned int i;
bool ready = false;
spin_lock(&dev->cec_xfers_slock);
for (i = 0; i < ARRAY_SIZE(dev->xfers); i++) {
if (dev->xfers[i].sft &&
dev->xfers[i].sft <= dev->cec_sft) {
ready = true;
break;
}
}
spin_unlock(&dev->cec_xfers_slock);
return ready;
}
/*
* If an adapter tries to send successive messages, it must wait for the
* longest signal-free time between its transmissions. But, if another
* adapter sends a message in the interim, then the wait can be reduced
* because the messages are no longer successive. Make these adjustments
* if necessary. Should be called holding cec_xfers_slock.
*/
static void adjust_sfts(struct vivid_dev *dev)
{
unsigned int i;
u8 initiator;
for (i = 0; i < ARRAY_SIZE(dev->xfers); i++) {
if (dev->xfers[i].sft <= CEC_SIGNAL_FREE_TIME_RETRY)
continue;
initiator = dev->xfers[i].msg[0] >> 4;
if (initiator == dev->last_initiator)
dev->xfers[i].sft = CEC_SIGNAL_FREE_TIME_NEXT_XFER;
else
dev->xfers[i].sft = CEC_SIGNAL_FREE_TIME_NEW_INITIATOR;
}
}
/*
* The main emulation of the bus on which CEC adapters attempt to send
* messages to each other. The bus keeps track of how long it has been
Annotation
- Immediate include surface: `linux/delay.h`, `media/cec.h`, `vivid-core.h`, `vivid-cec.h`.
- Detected declarations: `struct xfer_on_bus`, `function find_dest_adap`, `function xfer_ready`, `function adjust_sfts`, `function cec_transmit_attempt_done`, `function vivid_cec_adap_enable`, `function vivid_cec_adap_log_addr`, `function vivid_cec_adap_transmit`, `function vivid_received`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.