drivers/media/i2c/saa7185.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/saa7185.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/saa7185.c- Extension
.c- Size
- 9178 bytes
- Lines
- 352
- 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/types.hlinux/slab.hlinux/ioctl.hlinux/uaccess.hlinux/i2c.hlinux/videodev2.hmedia/v4l2-device.h
Detected Declarations
struct saa7185function saa7185_readfunction saa7185_writefunction saa7185_write_blockfunction saa7185_initfunction saa7185_s_std_outputfunction saa7185_s_routingfunction saa7185_probefunction saa7185_remove
Annotated Snippet
struct saa7185 {
struct v4l2_subdev sd;
unsigned char reg[128];
v4l2_std_id norm;
};
static inline struct saa7185 *to_saa7185(struct v4l2_subdev *sd)
{
return container_of(sd, struct saa7185, sd);
}
/* ----------------------------------------------------------------------- */
static inline int saa7185_read(struct v4l2_subdev *sd)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
return i2c_smbus_read_byte(client);
}
static int saa7185_write(struct v4l2_subdev *sd, u8 reg, u8 value)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct saa7185 *encoder = to_saa7185(sd);
v4l2_dbg(1, debug, sd, "%02x set to %02x\n", reg, value);
encoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
static int saa7185_write_block(struct v4l2_subdev *sd,
const u8 *data, unsigned int len)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct saa7185 *encoder = to_saa7185(sd);
int ret = -1;
u8 reg;
/* the adv7175 has an autoincrement function, use it if
* the adapter understands raw I2C */
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
u8 block_data[32];
int block_len;
while (len >= 2) {
block_len = 0;
block_data[block_len++] = reg = data[0];
do {
block_data[block_len++] =
encoder->reg[reg++] = data[1];
len -= 2;
data += 2;
} while (len >= 2 && data[0] == reg && block_len < 32);
ret = i2c_master_send(client, block_data, block_len);
if (ret < 0)
break;
}
} else {
/* do some slow I2C emulation kind of thing */
while (len >= 2) {
reg = *data++;
ret = saa7185_write(sd, reg, *data++);
if (ret < 0)
break;
len -= 2;
}
}
return ret;
}
/* ----------------------------------------------------------------------- */
static const unsigned char init_common[] = {
0x3a, 0x0f, /* CBENB=0, V656=0, VY2C=1,
* YUV2C=1, MY2C=1, MUV2C=1 */
0x42, 0x6b, /* OVLY0=107 */
0x43, 0x00, /* OVLU0=0 white */
0x44, 0x00, /* OVLV0=0 */
0x45, 0x22, /* OVLY1=34 */
0x46, 0xac, /* OVLU1=172 yellow */
0x47, 0x0e, /* OVLV1=14 */
0x48, 0x03, /* OVLY2=3 */
0x49, 0x1d, /* OVLU2=29 cyan */
0x4a, 0xac, /* OVLV2=172 */
0x4b, 0xf0, /* OVLY3=240 */
0x4c, 0xc8, /* OVLU3=200 green */
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/slab.h`, `linux/ioctl.h`, `linux/uaccess.h`, `linux/i2c.h`, `linux/videodev2.h`, `media/v4l2-device.h`.
- Detected declarations: `struct saa7185`, `function saa7185_read`, `function saa7185_write`, `function saa7185_write_block`, `function saa7185_init`, `function saa7185_s_std_output`, `function saa7185_s_routing`, `function saa7185_probe`, `function saa7185_remove`.
- 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.