drivers/media/cec/core/cec-adap.c
Source file repositories/reference/linux-study-clean/drivers/media/cec/core/cec-adap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/cec/core/cec-adap.c- Extension
.c- Size
- 69646 bytes
- Lines
- 2374
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/init.hlinux/kernel.hlinux/kmod.hlinux/ktime.hlinux/mm.hlinux/module.hlinux/seq_file.hlinux/slab.hlinux/string.hlinux/types.hdrm/drm_connector.hdrm/drm_device.hdrm/drm_edid.hdrm/drm_file.hcec-priv.h
Detected Declarations
function cec_log_addr2idxfunction cec_log_addr2devfunction cec_get_edid_phys_addrfunction cec_fill_conn_info_from_drmfunction cec_queue_event_fhfunction cec_queue_eventfunction cec_queue_pin_cec_eventfunction cec_queue_pin_hpd_eventfunction cec_queue_pin_5v_eventfunction cec_queue_msg_fhfunction truefunction cec_queue_msg_followersfunction cec_post_state_eventfunction transmitfunction cec_data_cancelfunction cec_flushfunction cec_transmit_donefunction cec_msg_initiatorfunction cec_transmit_done_tsfunction cec_transmit_attempt_done_tsfunction cec_wait_timeoutfunction cec_transmit_msg_fhfunction cec_transmit_msgfunction cec_received_msg_tsfunction list_for_each_entryfunction cec_config_log_addrfunction cec_adap_unconfigurefunction cec_config_thread_funcfunction cec_claim_log_addrsfunction cec_adap_enablefunction __cec_s_phys_addrfunction cec_s_phys_addrfunction cec_s_phys_addr_from_edidfunction cec_s_conn_infofunction __cec_s_log_addrsfunction cec_s_log_addrsfunction cec_fill_msg_report_featuresfunction cec_feature_abort_reasonfunction cec_feature_abortfunction cec_feature_refusedfunction cec_receive_notifyfunction cec_monitor_all_cnt_incfunction cec_monitor_all_cnt_decfunction cec_monitor_pin_cnt_incfunction cec_monitor_pin_cnt_decfunction cec_adap_statusexport cec_get_edid_phys_addrexport cec_fill_conn_info_from_drm
Annotated Snippet
if (fh->queued_events[ev_idx] < max_events[ev_idx]) {
/* Add new msg at the end of the queue */
list_add_tail(&entry->list, &fh->events[ev_idx]);
fh->queued_events[ev_idx]++;
fh->total_queued_events++;
goto unlock;
}
if (ev_idx >= CEC_NUM_CORE_EVENTS) {
list_add_tail(&entry->list, &fh->events[ev_idx]);
/* drop the oldest event */
entry = list_first_entry(&fh->events[ev_idx],
struct cec_event_entry, list);
list_del(&entry->list);
kfree(entry);
}
}
/* Mark that events were lost */
entry = list_first_entry_or_null(&fh->events[ev_idx],
struct cec_event_entry, list);
if (entry)
entry->ev.flags |= CEC_EVENT_FL_DROPPED_EVENTS;
unlock:
mutex_unlock(&fh->lock);
wake_up_interruptible(&fh->wait);
}
/* Queue a new event for all open filehandles. */
static void cec_queue_event(struct cec_adapter *adap,
const struct cec_event *ev)
{
u64 ts = ktime_get_ns();
struct cec_fh *fh;
mutex_lock(&adap->devnode.lock_fhs);
list_for_each_entry(fh, &adap->devnode.fhs, list)
cec_queue_event_fh(fh, ev, ts);
mutex_unlock(&adap->devnode.lock_fhs);
}
/* Notify userspace that the CEC pin changed state at the given time. */
void cec_queue_pin_cec_event(struct cec_adapter *adap, bool is_high,
bool dropped_events, ktime_t ts)
{
struct cec_event ev = {
.event = is_high ? CEC_EVENT_PIN_CEC_HIGH :
CEC_EVENT_PIN_CEC_LOW,
.flags = dropped_events ? CEC_EVENT_FL_DROPPED_EVENTS : 0,
};
struct cec_fh *fh;
mutex_lock(&adap->devnode.lock_fhs);
list_for_each_entry(fh, &adap->devnode.fhs, list) {
if (fh->mode_follower == CEC_MODE_MONITOR_PIN)
cec_queue_event_fh(fh, &ev, ktime_to_ns(ts));
}
mutex_unlock(&adap->devnode.lock_fhs);
}
EXPORT_SYMBOL_GPL(cec_queue_pin_cec_event);
/* Notify userspace that the HPD pin changed state at the given time. */
void cec_queue_pin_hpd_event(struct cec_adapter *adap, bool is_high, ktime_t ts)
{
struct cec_event ev = {
.event = is_high ? CEC_EVENT_PIN_HPD_HIGH :
CEC_EVENT_PIN_HPD_LOW,
};
struct cec_fh *fh;
mutex_lock(&adap->devnode.lock_fhs);
list_for_each_entry(fh, &adap->devnode.fhs, list)
cec_queue_event_fh(fh, &ev, ktime_to_ns(ts));
mutex_unlock(&adap->devnode.lock_fhs);
}
EXPORT_SYMBOL_GPL(cec_queue_pin_hpd_event);
/* Notify userspace that the 5V pin changed state at the given time. */
void cec_queue_pin_5v_event(struct cec_adapter *adap, bool is_high, ktime_t ts)
{
struct cec_event ev = {
.event = is_high ? CEC_EVENT_PIN_5V_HIGH :
CEC_EVENT_PIN_5V_LOW,
};
struct cec_fh *fh;
mutex_lock(&adap->devnode.lock_fhs);
list_for_each_entry(fh, &adap->devnode.fhs, list)
cec_queue_event_fh(fh, &ev, ktime_to_ns(ts));
mutex_unlock(&adap->devnode.lock_fhs);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/init.h`, `linux/kernel.h`, `linux/kmod.h`, `linux/ktime.h`, `linux/mm.h`, `linux/module.h`, `linux/seq_file.h`.
- Detected declarations: `function cec_log_addr2idx`, `function cec_log_addr2dev`, `function cec_get_edid_phys_addr`, `function cec_fill_conn_info_from_drm`, `function cec_queue_event_fh`, `function cec_queue_event`, `function cec_queue_pin_cec_event`, `function cec_queue_pin_hpd_event`, `function cec_queue_pin_5v_event`, `function cec_queue_msg_fh`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.