drivers/media/rc/imon_raw.c
Source file repositories/reference/linux-study-clean/drivers/media/rc/imon_raw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/rc/imon_raw.c- Extension
.c- Size
- 4717 bytes
- Lines
- 208
- 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.
- 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/module.hlinux/usb.hlinux/usb/input.hmedia/rc-core.h
Detected Declarations
struct imonfunction imon_ir_datafunction imon_ir_rxfunction imon_probefunction imon_disconnect
Annotated Snippet
struct imon {
struct device *dev;
struct urb *ir_urb;
struct rc_dev *rcdev;
__be64 *ir_buf;
char phys[64];
};
/*
* The first 5 bytes of data represent IR pulse or space. Each bit, starting
* from highest bit in the first byte, represents 250µs of data. It is 1
* for space and 0 for pulse.
*
* The station sends 10 packets, and the 7th byte will be number 1 to 10, so
* when we receive 10 we assume all the data has arrived.
*/
static void imon_ir_data(struct imon *imon)
{
struct ir_raw_event rawir = {};
u64 data = be64_to_cpup(imon->ir_buf);
u8 packet_no = data & 0xff;
int offset = 40;
int bit;
if (packet_no == 0xff)
return;
dev_dbg(imon->dev, "data: %8ph", imon->ir_buf);
/*
* Only the first 5 bytes contain IR data. Right shift so we move
* the IR bits to the lower 40 bits.
*/
data >>= 24;
do {
/*
* Find highest set bit which is less or equal to offset
*
* offset is the bit above (base 0) where we start looking.
*
* data & (BIT_ULL(offset) - 1) masks off any unwanted bits,
* so we have just bits less than offset.
*
* fls will tell us the highest bit set plus 1 (or 0 if no
* bits are set).
*/
rawir.pulse = !rawir.pulse;
bit = fls64(data & (BIT_ULL(offset) - 1));
if (bit < offset) {
dev_dbg(imon->dev, "%s: %d bits",
rawir.pulse ? "pulse" : "space", offset - bit);
rawir.duration = (offset - bit) * BIT_DURATION;
ir_raw_event_store_with_filter(imon->rcdev, &rawir);
offset = bit;
}
data = ~data;
} while (offset > 0);
if (packet_no == 0x0a && !imon->rcdev->idle) {
ir_raw_event_set_idle(imon->rcdev, true);
ir_raw_event_handle(imon->rcdev);
}
}
static void imon_ir_rx(struct urb *urb)
{
struct imon *imon = urb->context;
int ret;
switch (urb->status) {
case 0:
imon_ir_data(imon);
break;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
usb_unlink_urb(urb);
return;
case -EPIPE:
default:
dev_dbg(imon->dev, "error: urb status = %d", urb->status);
break;
}
ret = usb_submit_urb(urb, GFP_ATOMIC);
if (ret && ret != -ENODEV)
dev_warn(imon->dev, "failed to resubmit urb: %d", ret);
Annotation
- Immediate include surface: `linux/module.h`, `linux/usb.h`, `linux/usb/input.h`, `media/rc-core.h`.
- Detected declarations: `struct imon`, `function imon_ir_data`, `function imon_ir_rx`, `function imon_probe`, `function imon_disconnect`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
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.