drivers/media/pci/cx23885/cx23888-ir.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/cx23885/cx23888-ir.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/cx23885/cx23888-ir.c- Extension
.c- Size
- 34652 bytes
- Lines
- 1206
- 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.
- 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
cx23885.hcx23888-ir.hlinux/kfifo.hlinux/slab.hmedia/v4l2-device.hmedia/rc-core.h
Detected Declarations
struct cx23888_ir_stateenum tx_fifo_watermarkenum rx_fifo_watermarkfunction cx23888_ir_write4function cx23888_ir_read4function cx23888_ir_and_or4function count_to_clock_dividerfunction carrier_freq_to_clock_dividerfunction clock_divider_to_carrier_freqfunction clock_divider_to_freqfunction count_to_lpf_countfunction ns_to_lpf_countfunction lpf_count_to_nsfunction lpf_count_to_usfunction clock_divider_to_resolutionfunction pulse_width_count_to_nsfunction pulse_width_count_to_usfunction andfunction pulse_clocks_to_clock_dividerfunction control_tx_irq_watermarkfunction control_rx_irq_watermarkfunction control_tx_enablefunction control_rx_enablefunction control_tx_modulation_enablefunction control_rx_demodulation_enablefunction control_rx_s_edge_detectionfunction control_rx_s_carrier_windowfunction control_tx_polarity_invertfunction control_tx_level_invertfunction txclk_tx_s_carrierfunction rxclk_rx_s_carrierfunction txclk_tx_s_max_pulse_widthfunction rxclk_rx_s_max_pulse_widthfunction cduty_tx_s_duty_cyclefunction filter_rx_s_min_widthfunction irqenable_rxfunction irqenable_txfunction cx23888_ir_irq_handlerfunction cx23888_ir_rx_readfunction cx23888_ir_rx_g_parametersfunction cx23888_ir_rx_shutdownfunction cx23888_ir_rx_s_parametersfunction cx23888_ir_tx_writefunction cx23888_ir_tx_g_parametersfunction cx23888_ir_tx_shutdownfunction cx23888_ir_tx_s_parametersfunction cx23888_ir_log_statusfunction cx23888_ir_g_register
Annotated Snippet
struct cx23888_ir_state {
struct v4l2_subdev sd;
struct cx23885_dev *dev;
struct v4l2_subdev_ir_parameters rx_params;
struct mutex rx_params_lock;
atomic_t rxclk_divider;
atomic_t rx_invert;
struct kfifo rx_kfifo;
spinlock_t rx_kfifo_lock;
struct v4l2_subdev_ir_parameters tx_params;
struct mutex tx_params_lock;
atomic_t txclk_divider;
};
static inline struct cx23888_ir_state *to_state(struct v4l2_subdev *sd)
{
return v4l2_get_subdevdata(sd);
}
/*
* IR register block read and write functions
*/
static
inline int cx23888_ir_write4(struct cx23885_dev *dev, u32 addr, u32 value)
{
cx_write(addr, value);
return 0;
}
static inline u32 cx23888_ir_read4(struct cx23885_dev *dev, u32 addr)
{
return cx_read(addr);
}
static inline int cx23888_ir_and_or4(struct cx23885_dev *dev, u32 addr,
u32 and_mask, u32 or_value)
{
cx_andor(addr, ~and_mask, or_value);
return 0;
}
/*
* Rx and Tx Clock Divider register computations
*
* Note the largest clock divider value of 0xffff corresponds to:
* (0xffff + 1) * 1000 / 108/2 MHz = 1,213,629.629... ns
* which fits in 21 bits, so we'll use unsigned int for time arguments.
*/
static inline u16 count_to_clock_divider(unsigned int d)
{
if (d > RXCLK_RCD + 1)
d = RXCLK_RCD;
else if (d < 2)
d = 1;
else
d--;
return (u16) d;
}
static inline u16 carrier_freq_to_clock_divider(unsigned int freq)
{
return count_to_clock_divider(
DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ, freq * 16));
}
static inline unsigned int clock_divider_to_carrier_freq(unsigned int divider)
{
return DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ, (divider + 1) * 16);
}
static inline unsigned int clock_divider_to_freq(unsigned int divider,
unsigned int rollovers)
{
return DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ,
(divider + 1) * rollovers);
}
/*
* Low Pass Filter register calculations
*
* Note the largest count value of 0xffff corresponds to:
* 0xffff * 1000 / 108/2 MHz = 1,213,611.11... ns
* which fits in 21 bits, so we'll use unsigned int for time arguments.
*/
static inline u16 count_to_lpf_count(unsigned int d)
{
if (d > FILTR_LPF)
Annotation
- Immediate include surface: `cx23885.h`, `cx23888-ir.h`, `linux/kfifo.h`, `linux/slab.h`, `media/v4l2-device.h`, `media/rc-core.h`.
- Detected declarations: `struct cx23888_ir_state`, `enum tx_fifo_watermark`, `enum rx_fifo_watermark`, `function cx23888_ir_write4`, `function cx23888_ir_read4`, `function cx23888_ir_and_or4`, `function count_to_clock_divider`, `function carrier_freq_to_clock_divider`, `function clock_divider_to_carrier_freq`, `function clock_divider_to_freq`.
- 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.
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.