drivers/media/rc/fintek-cir.c
Source file repositories/reference/linux-study-clean/drivers/media/rc/fintek-cir.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/rc/fintek-cir.c- Extension
.c- Size
- 17866 bytes
- Lines
- 670
- 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/kernel.hlinux/module.hlinux/pnp.hlinux/io.hlinux/interrupt.hlinux/sched.hlinux/slab.hmedia/rc-core.hfintek-cir.h
Detected Declarations
function Copyrightfunction fintek_cr_readfunction fintek_set_reg_bitfunction fintek_config_mode_enablefunction fintek_config_mode_disablefunction fintek_select_logical_devfunction fintek_cir_reg_writefunction fintek_cir_reg_readfunction cir_dump_regsfunction fintek_hw_detectfunction fintek_cir_ldev_initfunction fintek_enable_cir_irqfunction fintek_cir_regs_initfunction fintek_enable_wakefunction fintek_cmdsizefunction fintek_process_rx_ir_datafunction fintek_get_rx_ir_datafunction fintek_cir_log_irqsfunction fintek_cir_isrfunction fintek_enable_cirfunction fintek_disable_cirfunction fintek_openfunction fintek_closefunction fintek_probefunction fintek_removefunction fintek_suspendfunction fintek_resumefunction fintek_shutdown
Annotated Snippet
switch (subcmd) {
case BUF_CMD_S_CARRIER:
case BUF_CMD_S_TIMEOUT:
case BUF_RSP_PULSE_COUNT:
datasize = 2;
break;
case BUF_CMD_SIG_END:
case BUF_CMD_S_TXMASK:
case BUF_CMD_S_RXSENSOR:
datasize = 1;
break;
}
}
return datasize;
}
/* process ir data stored in driver buffer */
static void fintek_process_rx_ir_data(struct fintek_dev *fintek)
{
struct ir_raw_event rawir = {};
u8 sample;
bool event = false;
int i;
for (i = 0; i < fintek->pkts; i++) {
sample = fintek->buf[i];
switch (fintek->parser_state) {
case CMD_HEADER:
fintek->cmd = sample;
if ((fintek->cmd == BUF_COMMAND_HEADER) ||
((fintek->cmd & BUF_COMMAND_MASK) !=
BUF_PULSE_BIT)) {
fintek->parser_state = SUBCMD;
continue;
}
fintek->rem = (fintek->cmd & BUF_LEN_MASK);
fit_dbg("%s: rem: 0x%02x", __func__, fintek->rem);
if (fintek->rem)
fintek->parser_state = PARSE_IRDATA;
else
ir_raw_event_overflow(fintek->rdev);
break;
case SUBCMD:
fintek->rem = fintek_cmdsize(fintek->cmd, sample);
fintek->parser_state = CMD_DATA;
break;
case CMD_DATA:
fintek->rem--;
break;
case PARSE_IRDATA:
fintek->rem--;
rawir.pulse = ((sample & BUF_PULSE_BIT) != 0);
rawir.duration = (sample & BUF_SAMPLE_MASK)
* CIR_SAMPLE_PERIOD;
fit_dbg("Storing %s with duration %d",
rawir.pulse ? "pulse" : "space",
rawir.duration);
if (ir_raw_event_store_with_filter(fintek->rdev,
&rawir))
event = true;
break;
}
if ((fintek->parser_state != CMD_HEADER) && !fintek->rem)
fintek->parser_state = CMD_HEADER;
}
fintek->pkts = 0;
if (event) {
fit_dbg("Calling ir_raw_event_handle");
ir_raw_event_handle(fintek->rdev);
}
}
/* copy data from hardware rx register into driver buffer */
static void fintek_get_rx_ir_data(struct fintek_dev *fintek, u8 rx_irqs)
{
unsigned long flags;
u8 sample, status;
spin_lock_irqsave(&fintek->fintek_lock, flags);
/*
* We must read data from CIR_RX_DATA until the hardware IR buffer
* is empty and clears the RX_TIMEOUT and/or RX_RECEIVE flags in
* the CIR_STATUS register
*/
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/pnp.h`, `linux/io.h`, `linux/interrupt.h`, `linux/sched.h`, `linux/slab.h`, `media/rc-core.h`.
- Detected declarations: `function Copyright`, `function fintek_cr_read`, `function fintek_set_reg_bit`, `function fintek_config_mode_enable`, `function fintek_config_mode_disable`, `function fintek_select_logical_dev`, `function fintek_cir_reg_write`, `function fintek_cir_reg_read`, `function cir_dump_regs`, `function fintek_hw_detect`.
- 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.