drivers/media/rc/rc-ir-raw.c
Source file repositories/reference/linux-study-clean/drivers/media/rc/rc-ir-raw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/rc/rc-ir-raw.c- Extension
.c- Size
- 19178 bytes
- Lines
- 714
- 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/export.hlinux/kthread.hlinux/mutex.hlinux/kmod.hlinux/sched.hrc-core-priv.h
Detected Declarations
function ir_raw_event_threadfunction ir_raw_event_storefunction ir_raw_event_store_edgefunction ir_raw_event_store_with_timeoutfunction time_afterfunction ir_raw_event_store_with_filterfunction ir_raw_event_set_idlefunction ir_raw_event_handlefunction ir_raw_get_allowed_protocolsfunction change_protocolfunction ir_raw_disable_protocolsfunction ir_raw_gen_manchesterfunction ir_raw_gen_pdfunction ir_raw_gen_plfunction ir_raw_encode_scancodefunction ir_raw_edge_handlefunction ir_raw_encode_carrierfunction tofunction ir_raw_event_registerfunction ir_raw_event_freefunction ir_raw_event_unregisterfunction ir_raw_handler_registerfunction ir_raw_handler_unregisterexport ir_raw_event_storeexport ir_raw_event_store_edgeexport ir_raw_event_store_with_timeoutexport ir_raw_event_store_with_filterexport ir_raw_event_set_idleexport ir_raw_event_handleexport ir_raw_gen_manchesterexport ir_raw_gen_pdexport ir_raw_gen_plexport ir_raw_encode_scancodeexport ir_raw_encode_carrierexport ir_raw_handler_registerexport ir_raw_handler_unregister
Annotated Snippet
while (kfifo_out(&raw->kfifo, &ev, 1)) {
if (is_timing_event(ev)) {
if (ev.duration == 0)
dev_warn_once(&dev->dev, "nonsensical timing event of duration 0");
if (is_timing_event(raw->prev_ev) &&
!is_transition(&ev, &raw->prev_ev))
dev_warn_once(&dev->dev, "two consecutive events of type %s",
TO_STR(ev.pulse));
}
list_for_each_entry(handler, &ir_raw_handler_list, list)
if (dev->enabled_protocols &
handler->protocols || !handler->protocols)
handler->decode(dev, ev);
lirc_raw_event(dev, ev);
raw->prev_ev = ev;
}
mutex_unlock(&ir_raw_handler_lock);
set_current_state(TASK_INTERRUPTIBLE);
if (kthread_should_stop()) {
__set_current_state(TASK_RUNNING);
break;
} else if (!kfifo_is_empty(&raw->kfifo))
set_current_state(TASK_RUNNING);
schedule();
}
return 0;
}
/**
* ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders
* @dev: the struct rc_dev device descriptor
* @ev: the struct ir_raw_event descriptor of the pulse/space
*
* This routine (which may be called from an interrupt context) stores a
* pulse/space duration for the raw ir decoding state machines. Pulses are
* signalled as positive values and spaces as negative values. A zero value
* will reset the decoding state machines.
*/
int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev)
{
if (!dev->raw)
return -EINVAL;
dev_dbg(&dev->dev, "sample: (%05dus %s)\n",
ev->duration, TO_STR(ev->pulse));
if (!kfifo_put(&dev->raw->kfifo, *ev)) {
dev_err(&dev->dev, "IR event FIFO is full!\n");
return -ENOSPC;
}
return 0;
}
EXPORT_SYMBOL_GPL(ir_raw_event_store);
/**
* ir_raw_event_store_edge() - notify raw ir decoders of the start of a pulse/space
* @dev: the struct rc_dev device descriptor
* @pulse: true for pulse, false for space
*
* This routine (which may be called from an interrupt context) is used to
* store the beginning of an ir pulse or space (or the start/end of ir
* reception) for the raw ir decoding state machines. This is used by
* hardware which does not provide durations directly but only interrupts
* (or similar events) on state change.
*/
int ir_raw_event_store_edge(struct rc_dev *dev, bool pulse)
{
ktime_t now;
struct ir_raw_event ev = {};
if (!dev->raw)
return -EINVAL;
now = ktime_get();
ev.duration = ktime_to_us(ktime_sub(now, dev->raw->last_event));
ev.pulse = !pulse;
return ir_raw_event_store_with_timeout(dev, &ev);
}
EXPORT_SYMBOL_GPL(ir_raw_event_store_edge);
/*
* ir_raw_event_store_with_timeout() - pass a pulse/space duration to the raw
* ir decoders, schedule decoding and
* timeout
Annotation
- Immediate include surface: `linux/export.h`, `linux/kthread.h`, `linux/mutex.h`, `linux/kmod.h`, `linux/sched.h`, `rc-core-priv.h`.
- Detected declarations: `function ir_raw_event_thread`, `function ir_raw_event_store`, `function ir_raw_event_store_edge`, `function ir_raw_event_store_with_timeout`, `function time_after`, `function ir_raw_event_store_with_filter`, `function ir_raw_event_set_idle`, `function ir_raw_event_handle`, `function ir_raw_get_allowed_protocols`, `function change_protocol`.
- 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.