drivers/media/pci/bt8xx/bttv-input.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/bt8xx/bttv-input.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/bt8xx/bttv-input.c- Extension
.c- Size
- 13466 bytes
- Lines
- 581
- 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.
- 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/module.hlinux/init.hlinux/delay.hlinux/interrupt.hlinux/input.hlinux/slab.hbttv.hbttvp.h
Detected Declarations
function ir_handle_keyfunction ir_enltv_handle_keyfunction bttv_input_irqfunction bttv_input_timerfunction bttv_rc5_decodefunction bttv_rc5_timer_endfunction bttv_rc5_irqfunction bttv_ir_startfunction bttv_ir_stopfunction get_key_pv951function init_bttv_i2c_irfunction bttv_input_initfunction bttv_input_fini
Annotated Snippet
switch (pair) {
case 0:
case 2:
break;
case 1:
rc5 |= 1;
break;
case 3:
dprintk("rc5_decode(%x) bad code\n",
org_code);
return 0;
}
}
dprintk("code=%x, rc5=%x, start=%x, toggle=%x, address=%x, instr=%x\n",
rc5, org_code, RC5_START(rc5),
RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5));
return rc5;
}
static void bttv_rc5_timer_end(struct timer_list *t)
{
struct bttv_ir *ir = timer_container_of(ir, t, timer);
ktime_t tv;
u32 gap, rc5, scancode;
u8 toggle, command, system;
/* get time */
tv = ktime_get();
gap = ktime_to_us(ktime_sub(tv, ir->base_time));
/* avoid overflow with gap >1s */
if (gap > USEC_PER_SEC) {
gap = 200000;
}
/* signal we're ready to start a new code */
ir->active = false;
/* Allow some timer jitter (RC5 is ~24ms anyway so this is ok) */
if (gap < 28000) {
dprintk("spurious timer_end\n");
return;
}
if (ir->last_bit < 20) {
/* ignore spurious codes (caused by light/other remotes) */
dprintk("short code: %x\n", ir->code);
return;
}
ir->code = (ir->code << ir->shift_by) | 1;
rc5 = bttv_rc5_decode(ir->code);
toggle = RC5_TOGGLE(rc5);
system = RC5_ADDR(rc5);
command = RC5_INSTR(rc5);
switch (RC5_START(rc5)) {
case 0x3:
break;
case 0x2:
command += 0x40;
break;
default:
return;
}
scancode = RC_SCANCODE_RC5(system, command);
rc_keydown(ir->dev, RC_PROTO_RC5, scancode, toggle);
dprintk("scancode %x, toggle %x\n", scancode, toggle);
}
static int bttv_rc5_irq(struct bttv *btv)
{
struct bttv_ir *ir = btv->remote;
ktime_t tv;
u32 gpio;
u32 gap;
unsigned long current_jiffies;
/* read gpio port */
gpio = bttv_gpio_read(&btv->c);
/* get time of bit */
current_jiffies = jiffies;
tv = ktime_get();
gap = ktime_to_us(ktime_sub(tv, ir->base_time));
/* avoid overflow with gap >1s */
if (gap > USEC_PER_SEC) {
gap = 200000;
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/input.h`, `linux/slab.h`, `bttv.h`, `bttvp.h`.
- Detected declarations: `function ir_handle_key`, `function ir_enltv_handle_key`, `function bttv_input_irq`, `function bttv_input_timer`, `function bttv_rc5_decode`, `function bttv_rc5_timer_end`, `function bttv_rc5_irq`, `function bttv_ir_start`, `function bttv_ir_stop`, `function get_key_pv951`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
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.