drivers/media/usb/au0828/au0828-input.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/au0828/au0828-input.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/au0828/au0828-input.c- Extension
.c- Size
- 8695 bytes
- Lines
- 401
- 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
au0828.hlinux/module.hlinux/init.hlinux/delay.hlinux/interrupt.hlinux/usb.hlinux/slab.hmedia/rc-core.h
Detected Declarations
struct au0828_rcfunction au8522_rc_writefunction au8522_rc_readfunction au8522_rc_andorfunction au0828_get_key_au8522function au0828_rc_workfunction au0828_rc_startfunction au0828_rc_stopfunction au0828_probe_i2c_irfunction au0828_rc_registerfunction au0828_rc_unregisterfunction au0828_rc_suspendfunction au0828_rc_resume
Annotated Snippet
struct au0828_rc {
struct au0828_dev *dev;
struct rc_dev *rc;
char name[32];
char phys[32];
/* poll decoder */
int polling;
struct delayed_work work;
/* i2c slave address of external device (if used) */
u16 i2c_dev_addr;
int (*get_key_i2c)(struct au0828_rc *ir);
};
/*
* AU8522 has a builtin IR receiver. Add functions to get IR from it
*/
static int au8522_rc_write(struct au0828_rc *ir, u16 reg, u8 data)
{
int rc;
char buf[] = { (reg >> 8) | 0x80, reg & 0xff, data };
struct i2c_msg msg = { .addr = ir->i2c_dev_addr, .flags = 0,
.buf = buf, .len = sizeof(buf) };
rc = i2c_transfer(ir->dev->i2c_client.adapter, &msg, 1);
if (rc < 0)
return rc;
return (rc == 1) ? 0 : -EIO;
}
static int au8522_rc_read(struct au0828_rc *ir, u16 reg, int val,
char *buf, int size)
{
int rc;
char obuf[3];
struct i2c_msg msg[2] = { { .addr = ir->i2c_dev_addr, .flags = 0,
.buf = obuf, .len = 2 },
{ .addr = ir->i2c_dev_addr, .flags = I2C_M_RD,
.buf = buf, .len = size } };
obuf[0] = 0x40 | reg >> 8;
obuf[1] = reg & 0xff;
if (val >= 0) {
obuf[2] = val;
msg[0].len++;
}
rc = i2c_transfer(ir->dev->i2c_client.adapter, msg, 2);
if (rc < 0)
return rc;
return (rc == 2) ? 0 : -EIO;
}
static int au8522_rc_andor(struct au0828_rc *ir, u16 reg, u8 mask, u8 value)
{
int rc;
char buf, oldbuf;
rc = au8522_rc_read(ir, reg, -1, &buf, 1);
if (rc < 0)
return rc;
oldbuf = buf;
buf = (buf & ~mask) | (value & mask);
/* Nothing to do, just return */
if (buf == oldbuf)
return 0;
return au8522_rc_write(ir, reg, buf);
}
#define au8522_rc_set(ir, reg, bit) au8522_rc_andor(ir, (reg), (bit), (bit))
#define au8522_rc_clear(ir, reg, bit) au8522_rc_andor(ir, (reg), (bit), 0)
/* Remote Controller time units */
#define AU8522_UNIT 200 /* us */
#define NEC_START_SPACE (4500 / AU8522_UNIT)
#define NEC_START_PULSE (563 * 16)
#define RC5_START_SPACE (4 * AU8522_UNIT)
#define RC5_START_PULSE 889
Annotation
- Immediate include surface: `au0828.h`, `linux/module.h`, `linux/init.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/usb.h`, `linux/slab.h`, `media/rc-core.h`.
- Detected declarations: `struct au0828_rc`, `function au8522_rc_write`, `function au8522_rc_read`, `function au8522_rc_andor`, `function au0828_get_key_au8522`, `function au0828_rc_work`, `function au0828_rc_start`, `function au0828_rc_stop`, `function au0828_probe_i2c_ir`, `function au0828_rc_register`.
- 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.