drivers/media/rc/ite-cir.c
Source file repositories/reference/linux-study-clean/drivers/media/rc/ite-cir.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/rc/ite-cir.c- Extension
.c- Size
- 41654 bytes
- Lines
- 1511
- 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/delay.hlinux/slab.hlinux/input.hlinux/bitops.hmedia/rc-core.hlinux/pci_ids.hite-cir.h
Detected Declarations
function ite_is_high_carrier_freqfunction ite_get_carrier_freq_bitsfunction ite_get_pulse_width_bitsfunction ite_decode_bytesfunction ite_set_carrier_paramsfunction ite_cir_isrfunction ite_set_rx_carrier_rangefunction ite_set_tx_carrierfunction ite_set_tx_duty_cyclefunction ite_tx_irfunction ite_s_idlefunction it87_get_irq_causesfunction it87_set_carrier_paramsfunction it87_get_rx_bytesfunction it87_get_tx_used_slotsfunction it87_put_tx_bytefunction it87_idle_rxfunction it87_disable_rxfunction it87_enable_rxfunction it87_disable_tx_interruptfunction it87_enable_tx_interruptfunction it87_disablefunction it87_init_hardwarefunction it8708_get_irq_causesfunction it8708_set_carrier_paramsfunction it8708_get_rx_bytesfunction it8708_get_tx_used_slotsfunction it8708_put_tx_bytefunction it8708_idle_rxfunction it8708_disable_rxfunction it8708_enable_rxfunction it8708_disable_tx_interruptfunction it8708_enable_tx_interruptfunction it8708_disablefunction it8708_init_hardwarefunction it8709_rmfunction it8709_wmfunction it8709_waitfunction it8709_rrfunction it8709_wrfunction it8709_get_irq_causesfunction it8709_set_carrier_paramsfunction it8709_get_rx_bytesfunction it8709_get_tx_used_slotsfunction it8709_put_tx_bytefunction it8709_idle_rxfunction it8709_disable_rxfunction it8709_enable_rx
Annotated Snippet
if (next_zero < size) {
next_one = find_next_bit_le(ldata, size, next_zero + 1);
ev.pulse = true;
ev.duration = ITE_BITS_TO_US(next_one - next_zero,
sample_period);
ir_raw_event_store_with_filter(dev->rdev, &ev);
} else
next_one = size;
}
ir_raw_event_handle(dev->rdev);
dev_dbg(&dev->rdev->dev, "decoded %d bytes\n", length);
}
/* set all the rx/tx carrier parameters; this must be called with the device
* spinlock held */
static void ite_set_carrier_params(struct ite_dev *dev)
{
unsigned int freq, low_freq, high_freq;
int allowance;
bool use_demodulator;
bool for_tx = dev->transmitting;
if (for_tx) {
/* we don't need no stinking calculations */
freq = dev->tx_carrier_freq;
allowance = ITE_RXDCR_DEFAULT;
use_demodulator = false;
} else {
low_freq = dev->rx_low_carrier_freq;
high_freq = dev->rx_high_carrier_freq;
if (low_freq == 0) {
/* don't demodulate */
freq = ITE_DEFAULT_CARRIER_FREQ;
allowance = ITE_RXDCR_DEFAULT;
use_demodulator = false;
} else {
/* calculate the middle freq */
freq = (low_freq + high_freq) / 2;
/* calculate the allowance */
allowance =
DIV_ROUND_CLOSEST(10000 * (high_freq - low_freq),
ITE_RXDCR_PER_10000_STEP
* (high_freq + low_freq));
if (allowance < 1)
allowance = 1;
if (allowance > ITE_RXDCR_MAX)
allowance = ITE_RXDCR_MAX;
use_demodulator = true;
}
}
/* set the carrier parameters in a device-dependent way */
dev->params->set_carrier_params(dev, ite_is_high_carrier_freq(freq),
use_demodulator, ite_get_carrier_freq_bits(freq), allowance,
ite_get_pulse_width_bits(freq, dev->tx_duty_cycle));
}
/* interrupt service routine for incoming and outgoing CIR data */
static irqreturn_t ite_cir_isr(int irq, void *data)
{
struct ite_dev *dev = data;
irqreturn_t ret = IRQ_RETVAL(IRQ_NONE);
u8 rx_buf[ITE_RX_FIFO_LEN];
int rx_bytes;
int iflags;
/* grab the spinlock */
spin_lock(&dev->lock);
/* read the interrupt flags */
iflags = dev->params->get_irq_causes(dev);
/* Check for RX overflow */
if (iflags & ITE_IRQ_RX_FIFO_OVERRUN) {
dev_warn(&dev->rdev->dev, "receive overflow\n");
ir_raw_event_overflow(dev->rdev);
}
/* check for the receive interrupt */
if (iflags & (ITE_IRQ_RX_FIFO | ITE_IRQ_RX_FIFO_OVERRUN)) {
/* read the FIFO bytes */
rx_bytes = dev->params->get_rx_bytes(dev, rx_buf,
ITE_RX_FIFO_LEN);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/pnp.h`, `linux/io.h`, `linux/interrupt.h`, `linux/sched.h`, `linux/delay.h`, `linux/slab.h`.
- Detected declarations: `function ite_is_high_carrier_freq`, `function ite_get_carrier_freq_bits`, `function ite_get_pulse_width_bits`, `function ite_decode_bytes`, `function ite_set_carrier_params`, `function ite_cir_isr`, `function ite_set_rx_carrier_range`, `function ite_set_tx_carrier`, `function ite_set_tx_duty_cycle`, `function ite_tx_ir`.
- 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.