drivers/media/radio/saa7706h.c
Source file repositories/reference/linux-study-clean/drivers/media/radio/saa7706h.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/radio/saa7706h.c- Extension
.c- Size
- 11146 bytes
- Lines
- 418
- 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/errno.hlinux/kernel.hlinux/interrupt.hlinux/i2c.hlinux/slab.hmedia/v4l2-device.hmedia/v4l2-ctrls.h
Detected Declarations
struct saa7706h_statefunction saa7706h_i2c_sendfunction saa7706h_i2c_transferfunction saa7706h_set_reg24function saa7706h_set_reg24_errfunction saa7706h_set_reg16function saa7706h_set_reg16_errfunction saa7706h_get_reg16function saa7706h_unmutefunction saa7706h_mutefunction saa7706h_s_ctrlfunction saa7706h_probefunction saa7706h_remove
Annotated Snippet
struct saa7706h_state {
struct v4l2_subdev sd;
struct v4l2_ctrl_handler hdl;
unsigned muted;
};
static inline struct saa7706h_state *to_state(struct v4l2_subdev *sd)
{
return container_of(sd, struct saa7706h_state, sd);
}
static int saa7706h_i2c_send(struct i2c_client *client, const u8 *data, int len)
{
int err = i2c_master_send(client, data, len);
if (err == len)
return 0;
return err > 0 ? -EIO : err;
}
static int saa7706h_i2c_transfer(struct i2c_client *client,
struct i2c_msg *msgs, int num)
{
int err = i2c_transfer(client->adapter, msgs, num);
if (err == num)
return 0;
return err > 0 ? -EIO : err;
}
static int saa7706h_set_reg24(struct v4l2_subdev *sd, u16 reg, u32 val)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
u8 buf[5];
int pos = 0;
buf[pos++] = reg >> 8;
buf[pos++] = reg;
buf[pos++] = val >> 16;
buf[pos++] = val >> 8;
buf[pos++] = val;
return saa7706h_i2c_send(client, buf, pos);
}
static int saa7706h_set_reg24_err(struct v4l2_subdev *sd, u16 reg, u32 val,
int *err)
{
return *err ? *err : saa7706h_set_reg24(sd, reg, val);
}
static int saa7706h_set_reg16(struct v4l2_subdev *sd, u16 reg, u16 val)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
u8 buf[4];
int pos = 0;
buf[pos++] = reg >> 8;
buf[pos++] = reg;
buf[pos++] = val >> 8;
buf[pos++] = val;
return saa7706h_i2c_send(client, buf, pos);
}
static int saa7706h_set_reg16_err(struct v4l2_subdev *sd, u16 reg, u16 val,
int *err)
{
return *err ? *err : saa7706h_set_reg16(sd, reg, val);
}
static int saa7706h_get_reg16(struct v4l2_subdev *sd, u16 reg)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
u8 buf[2];
int err;
u8 regaddr[] = {reg >> 8, reg};
struct i2c_msg msg[] = {
{
.addr = client->addr,
.len = sizeof(regaddr),
.buf = regaddr
},
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = sizeof(buf),
.buf = buf
}
};
err = saa7706h_i2c_transfer(client, msg, ARRAY_SIZE(msg));
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/delay.h`, `linux/errno.h`, `linux/kernel.h`, `linux/interrupt.h`, `linux/i2c.h`, `linux/slab.h`.
- Detected declarations: `struct saa7706h_state`, `function saa7706h_i2c_send`, `function saa7706h_i2c_transfer`, `function saa7706h_set_reg24`, `function saa7706h_set_reg24_err`, `function saa7706h_set_reg16`, `function saa7706h_set_reg16_err`, `function saa7706h_get_reg16`, `function saa7706h_unmute`, `function saa7706h_mute`.
- 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.