drivers/media/i2c/saa7110.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/saa7110.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/saa7110.c- Extension
.c- Size
- 12620 bytes
- Lines
- 457
- 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/types.hlinux/delay.hlinux/slab.hlinux/wait.hlinux/uaccess.hlinux/i2c.hlinux/videodev2.hmedia/v4l2-device.hmedia/v4l2-ctrls.h
Detected Declarations
struct saa7110function saa7110_writefunction saa7110_write_blockfunction saa7110_readfunction saa7110_selmuxfunction determine_normfunction saa7110_g_input_statusfunction saa7110_querystdfunction saa7110_s_stdfunction saa7110_s_routingfunction saa7110_s_streamfunction saa7110_s_ctrlfunction saa7110_probefunction saa7110_remove
Annotated Snippet
struct saa7110 {
struct v4l2_subdev sd;
struct v4l2_ctrl_handler hdl;
u8 reg[SAA7110_NR_REG];
v4l2_std_id norm;
int input;
int enable;
wait_queue_head_t wq;
};
static inline struct saa7110 *to_saa7110(struct v4l2_subdev *sd)
{
return container_of(sd, struct saa7110, sd);
}
static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
{
return &container_of(ctrl->handler, struct saa7110, hdl)->sd;
}
/* ----------------------------------------------------------------------- */
/* I2C support functions */
/* ----------------------------------------------------------------------- */
static int saa7110_write(struct v4l2_subdev *sd, u8 reg, u8 value)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct saa7110 *decoder = to_saa7110(sd);
decoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
static int saa7110_write_block(struct v4l2_subdev *sd, const u8 *data, unsigned int len)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct saa7110 *decoder = to_saa7110(sd);
int ret = -1;
u8 reg = *data; /* first register to write to */
/* Sanity check */
if (reg + (len - 1) > SAA7110_NR_REG)
return ret;
/* the saa7110 has an autoincrement function, use it if
* the adapter understands raw I2C */
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
ret = i2c_master_send(client, data, len);
/* Cache the written data */
memcpy(decoder->reg + reg, data + 1, len - 1);
} else {
for (++data, --len; len; len--) {
ret = saa7110_write(sd, reg++, *data++);
if (ret < 0)
break;
}
}
return ret;
}
static inline int saa7110_read(struct v4l2_subdev *sd)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
return i2c_smbus_read_byte(client);
}
/* ----------------------------------------------------------------------- */
/* SAA7110 functions */
/* ----------------------------------------------------------------------- */
#define FRESP_06H_COMPST 0x03 /*0x13*/
#define FRESP_06H_SVIDEO 0x83 /*0xC0*/
static int saa7110_selmux(struct v4l2_subdev *sd, int chan)
{
static const unsigned char modes[9][8] = {
/* mode 0 */
{FRESP_06H_COMPST, 0xD9, 0x17, 0x40, 0x03,
0x44, 0x75, 0x16},
/* mode 1 */
{FRESP_06H_COMPST, 0xD8, 0x17, 0x40, 0x03,
0x44, 0x75, 0x16},
/* mode 2 */
{FRESP_06H_COMPST, 0xBA, 0x07, 0x91, 0x03,
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/types.h`, `linux/delay.h`, `linux/slab.h`, `linux/wait.h`, `linux/uaccess.h`, `linux/i2c.h`.
- Detected declarations: `struct saa7110`, `function saa7110_write`, `function saa7110_write_block`, `function saa7110_read`, `function saa7110_selmux`, `function determine_norm`, `function saa7110_g_input_status`, `function saa7110_querystd`, `function saa7110_s_std`, `function saa7110_s_routing`.
- 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.