drivers/media/rc/ene_ir.c
Source file repositories/reference/linux-study-clean/drivers/media/rc/ene_ir.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/rc/ene_ir.c- Extension
.c- Size
- 31266 bytes
- Lines
- 1200
- 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.hene_ir.h
Detected Declarations
function ene_set_reg_addrfunction ene_read_regfunction ene_write_regfunction ene_set_reg_maskfunction ene_clear_reg_maskfunction ene_set_clear_reg_maskfunction ene_hw_detectfunction ene_rx_setup_hw_bufferfunction ene_rx_restore_hw_bufferfunction ene_rx_read_hw_pointerfunction ene_rx_get_sample_regfunction ene_rx_sense_carrierfunction ene_rx_enable_cir_enginefunction ene_rx_select_inputfunction ene_rx_enable_fan_inputfunction ene_rx_setupfunction ene_rx_enable_hwfunction ene_rx_enablefunction ene_rx_disable_hwfunction ene_rx_disablefunction ene_rx_resetfunction ene_tx_set_carrierfunction ene_tx_set_transmittersfunction ene_tx_enablefunction ene_tx_disablefunction ene_tx_samplefunction ene_tx_irqsimfunction ene_irq_statusfunction ene_isrfunction ene_setup_default_settingsfunction ene_setup_hw_settingsfunction ene_openfunction ene_closefunction ene_set_tx_maskfunction ene_set_tx_carrierfunction ene_set_tx_duty_cyclefunction ene_set_learning_modefunction ene_set_carrier_reportfunction ene_set_idlefunction ene_transmitfunction ene_probefunction ene_removefunction ene_enable_wakefunction ene_suspendfunction ene_resumefunction ene_shutdown
Annotated Snippet
if (dev->tx_pos == dev->tx_len) {
if (!dev->tx_done) {
dbg("TX: no more data to send");
dev->tx_done = true;
goto exit;
} else {
dbg("TX: last sample sent by hardware");
ene_tx_disable(dev);
complete(&dev->tx_complete);
return;
}
}
sample = dev->tx_buffer[dev->tx_pos++];
dev->tx_sample_pulse = !dev->tx_sample_pulse;
dev->tx_sample = DIV_ROUND_CLOSEST(sample, sample_period);
if (!dev->tx_sample)
dev->tx_sample = 1;
}
raw_tx = min(dev->tx_sample , (unsigned int)ENE_CIRRLC_OUT_MASK);
dev->tx_sample -= raw_tx;
dbg("TX: sample %8d (%s)", raw_tx * sample_period,
pulse ? "pulse" : "space");
if (pulse)
raw_tx |= ENE_CIRRLC_OUT_PULSE;
ene_write_reg(dev,
dev->tx_reg ? ENE_CIRRLC_OUT1 : ENE_CIRRLC_OUT0, raw_tx);
dev->tx_reg = !dev->tx_reg;
exit:
/* simulate TX done interrupt */
if (txsim)
mod_timer(&dev->tx_sim_timer, jiffies + HZ / 500);
}
/* timer to simulate tx done interrupt */
static void ene_tx_irqsim(struct timer_list *t)
{
struct ene_device *dev = timer_container_of(dev, t, tx_sim_timer);
unsigned long flags;
spin_lock_irqsave(&dev->hw_lock, flags);
ene_tx_sample(dev);
spin_unlock_irqrestore(&dev->hw_lock, flags);
}
/* read irq status and ack it */
static int ene_irq_status(struct ene_device *dev)
{
u8 irq_status;
u8 fw_flags1, fw_flags2;
int retval = 0;
fw_flags2 = ene_read_reg(dev, ENE_FW2);
if (dev->hw_revision < ENE_HW_C) {
irq_status = ene_read_reg(dev, ENEB_IRQ_STATUS);
if (!(irq_status & ENEB_IRQ_STATUS_IR))
return 0;
ene_clear_reg_mask(dev, ENEB_IRQ_STATUS, ENEB_IRQ_STATUS_IR);
return ENE_IRQ_RX;
}
irq_status = ene_read_reg(dev, ENE_IRQ);
if (!(irq_status & ENE_IRQ_STATUS))
return 0;
/* original driver does that twice - a workaround ? */
ene_write_reg(dev, ENE_IRQ, irq_status & ~ENE_IRQ_STATUS);
ene_write_reg(dev, ENE_IRQ, irq_status & ~ENE_IRQ_STATUS);
/* check RX interrupt */
if (fw_flags2 & ENE_FW2_RXIRQ) {
retval |= ENE_IRQ_RX;
ene_write_reg(dev, ENE_FW2, fw_flags2 & ~ENE_FW2_RXIRQ);
}
/* check TX interrupt */
fw_flags1 = ene_read_reg(dev, ENE_FW1);
if (fw_flags1 & ENE_FW1_TXIRQ) {
ene_write_reg(dev, ENE_FW1, fw_flags1 & ~ENE_FW1_TXIRQ);
retval |= ENE_IRQ_TX;
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 ene_set_reg_addr`, `function ene_read_reg`, `function ene_write_reg`, `function ene_set_reg_mask`, `function ene_clear_reg_mask`, `function ene_set_clear_reg_mask`, `function ene_hw_detect`, `function ene_rx_setup_hw_buffer`, `function ene_rx_restore_hw_buffer`, `function ene_rx_read_hw_pointer`.
- 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.