drivers/media/rc/img-ir/img-ir-hw.c
Source file repositories/reference/linux-study-clean/drivers/media/rc/img-ir/img-ir-hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/rc/img-ir/img-ir-hw.c- Extension
.c- Size
- 33447 bytes
- Lines
- 1150
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/clk.hlinux/interrupt.hlinux/spinlock.hlinux/timer.hmedia/rc-core.himg-ir.h
Detected Declarations
function img_ir_timing_preprocessfunction img_ir_symbol_timing_preprocessfunction img_ir_timings_preprocessfunction img_ir_timing_defaultsfunction img_ir_symbol_timing_defaultsfunction img_ir_timings_defaultsfunction img_ir_controlfunction img_ir_timing_range_convertfunction img_ir_symbol_timingfunction img_ir_free_timingfunction img_ir_free_timing_dynamicfunction img_ir_timings_convertfunction img_ir_decoder_preprocessfunction img_ir_decoder_convertfunction img_ir_write_timingsfunction img_ir_write_filterfunction _img_ir_set_filterfunction _img_ir_set_wake_filterfunction img_ir_set_filterfunction img_ir_set_normal_filterfunction img_ir_set_wakeup_filterfunction img_ir_set_decoderfunction img_ir_decoder_compatiblefunction img_ir_allowed_protosfunction img_ir_change_protocolfunction img_ir_set_protocolfunction img_ir_init_decodersfunction img_ir_enable_wakefunction img_ir_disable_wakefunction img_ir_begin_repeatfunction img_ir_end_repeatfunction img_ir_handle_datafunction img_ir_end_timerfunction img_ir_suspend_timerfunction img_ir_change_frequencyfunction img_ir_clk_notifyfunction img_ir_isr_hwfunction img_ir_setup_hwfunction img_ir_probe_hw_capsfunction img_ir_probe_hwfunction img_ir_remove_hwfunction img_ir_suspendfunction img_ir_resume
Annotated Snippet
if (*ir_type & dec->type) {
*ir_type &= dec->type;
img_ir_set_decoder(priv, dec, *ir_type);
goto success;
}
}
return -EINVAL;
success:
/*
* Only allow matching wakeup protocols for now, and only if filtering
* is supported.
*/
wakeup_protocols = *ir_type;
if (!hw->decoder || !hw->decoder->filter)
wakeup_protocols = 0;
rdev->allowed_wakeup_protocols = wakeup_protocols;
return 0;
}
/* Changes ir-core protocol device attribute */
static void img_ir_set_protocol(struct img_ir_priv *priv, u64 proto)
{
struct rc_dev *rdev = priv->hw.rdev;
mutex_lock(&rdev->lock);
rdev->enabled_protocols = proto;
rdev->allowed_wakeup_protocols = proto;
mutex_unlock(&rdev->lock);
}
/* Set up IR decoders */
static void img_ir_init_decoders(void)
{
struct img_ir_decoder **decp;
spin_lock(&img_ir_decoders_lock);
if (!img_ir_decoders_preprocessed) {
for (decp = img_ir_decoders; *decp; ++decp)
img_ir_decoder_preprocess(*decp);
img_ir_decoders_preprocessed = true;
}
spin_unlock(&img_ir_decoders_lock);
}
#ifdef CONFIG_PM_SLEEP
/**
* img_ir_enable_wake() - Switch to wake mode.
* @priv: IR private data.
*
* Returns: non-zero if the IR can wake the system.
*/
static int img_ir_enable_wake(struct img_ir_priv *priv)
{
struct img_ir_priv_hw *hw = &priv->hw;
int ret = 0;
spin_lock_irq(&priv->lock);
if (hw->flags & IMG_IR_F_WAKE) {
/* interrupt only on a match */
hw->suspend_irqen = img_ir_read(priv, IMG_IR_IRQ_ENABLE);
img_ir_write(priv, IMG_IR_IRQ_ENABLE, IMG_IR_IRQ_DATA_MATCH);
img_ir_write_filter(priv, &hw->filters[RC_FILTER_WAKEUP]);
img_ir_write_timings(priv, &hw->reg_timings.timings,
RC_FILTER_WAKEUP);
hw->mode = IMG_IR_M_WAKE;
ret = 1;
}
spin_unlock_irq(&priv->lock);
return ret;
}
/**
* img_ir_disable_wake() - Switch out of wake mode.
* @priv: IR private data
*
* Returns: 1 if the hardware should be allowed to wake from a sleep state.
* 0 otherwise.
*/
static int img_ir_disable_wake(struct img_ir_priv *priv)
{
struct img_ir_priv_hw *hw = &priv->hw;
int ret = 0;
spin_lock_irq(&priv->lock);
if (hw->flags & IMG_IR_F_WAKE) {
/* restore normal filtering */
if (hw->flags & IMG_IR_F_FILTER) {
img_ir_write(priv, IMG_IR_IRQ_ENABLE,
(hw->suspend_irqen & IMG_IR_IRQ_EDGE) |
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/interrupt.h`, `linux/spinlock.h`, `linux/timer.h`, `media/rc-core.h`, `img-ir.h`.
- Detected declarations: `function img_ir_timing_preprocess`, `function img_ir_symbol_timing_preprocess`, `function img_ir_timings_preprocess`, `function img_ir_timing_defaults`, `function img_ir_symbol_timing_defaults`, `function img_ir_timings_defaults`, `function img_ir_control`, `function img_ir_timing_range_convert`, `function img_ir_symbol_timing`, `function img_ir_free_timing`.
- 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.