drivers/media/rc/meson-ir.c
Source file repositories/reference/linux-study-clean/drivers/media/rc/meson-ir.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/rc/meson-ir.c- Extension
.c- Size
- 20107 bytes
- Lines
- 645
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/device.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/spinlock.hlinux/bitfield.hlinux/regmap.hmedia/rc-core.h
Detected Declarations
struct meson_ir_protocolstruct meson_ir_paramstruct meson_irfunction meson_ir_nec_handlerfunction meson_ir_hw_handlerfunction meson_ir_irqfunction meson_ir_hw_decoder_initfunction meson_ir_sw_decoder_initfunction meson_ir_probefunction meson_ir_removefunction meson_ir_shutdownfunction meson_ir_resumefunction meson_ir_suspend
Annotated Snippet
struct meson_ir_protocol {
u8 hw_protocol;
bool repeat_counter_enable;
bool repeat_check_enable;
bool repeat_compare_enable;
bool bit_order;
bool bit1_match_enable;
bool hold_code_enable;
bool count_tick_mode;
u8 code_length;
u16 frame_time_max;
u16 leader_active_max;
u16 leader_active_min;
u16 leader_idle_max;
u16 leader_idle_min;
u16 repeat_leader_max;
u16 repeat_leader_min;
u16 bit0_max;
u16 bit0_min;
u16 bit1_max;
u16 bit1_min;
u16 duration2_max;
u16 duration2_min;
u16 duration3_max;
u16 duration3_min;
};
struct meson_ir_param {
bool support_hw_decoder;
unsigned int max_register;
};
struct meson_ir {
const struct meson_ir_param *param;
struct regmap *reg;
struct rc_dev *rc;
spinlock_t lock;
};
static struct regmap_config meson_ir_regmap_config = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
};
static const struct meson_ir_protocol protocol_timings[] = {
/* protocol, repeat counter, repeat check, repeat compare, order */
{DEC_MODE_NEC, false, false, false, FRAME_LSB_FIRST,
/* bit 1 match, hold code, count tick, len, frame time */
true, false, false, 32, 4000,
/* leader active max/min, leader idle max/min, repeat leader max/min */
500, 400, 300, 200, 150, 80,
/* bit0 max/min, bit1 max/min, duration2 max/min, duration3 max/min */
72, 40, 134, 90, 0, 0, 0, 0}
};
static void meson_ir_nec_handler(struct meson_ir *ir)
{
u32 code = 0;
u32 status = 0;
enum rc_proto proto;
regmap_read(ir->reg, IR_DEC_STATUS, &status);
if (status & DEC_STATUS_REPEAT) {
rc_repeat(ir->rc);
} else {
regmap_read(ir->reg, IR_DEC_FRAME, &code);
code = ir_nec_bytes_to_scancode(code, code >> 8,
code >> 16, code >> 24, &proto);
rc_keydown(ir->rc, proto, code, 0);
}
}
static void meson_ir_hw_handler(struct meson_ir *ir)
{
if (ir->rc->enabled_protocols & RC_PROTO_BIT_NEC)
meson_ir_nec_handler(ir);
}
static irqreturn_t meson_ir_irq(int irqno, void *dev_id)
{
struct meson_ir *ir = dev_id;
u32 duration, status;
struct ir_raw_event rawir = {};
spin_lock(&ir->lock);
regmap_read(ir->reg, IR_DEC_STATUS, &status);
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/spinlock.h`.
- Detected declarations: `struct meson_ir_protocol`, `struct meson_ir_param`, `struct meson_ir`, `function meson_ir_nec_handler`, `function meson_ir_hw_handler`, `function meson_ir_irq`, `function meson_ir_hw_decoder_init`, `function meson_ir_sw_decoder_init`, `function meson_ir_probe`, `function meson_ir_remove`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.