drivers/media/i2c/vpx3220.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/vpx3220.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/vpx3220.c- Extension
.c- Size
- 13940 bytes
- Lines
- 555
- 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/types.hlinux/slab.hlinux/uaccess.hlinux/i2c.hlinux/videodev2.hmedia/v4l2-device.hmedia/v4l2-ctrls.h
Detected Declarations
struct vpx3220function vpx3220_writefunction vpx3220_readfunction vpx3220_fp_statusfunction vpx3220_fp_writefunction vpx3220_fp_readfunction vpx3220_write_blockfunction vpx3220_write_fp_blockfunction vpx3220_initfunction vpx3220_statusfunction vpx3220_querystdfunction vpx3220_g_input_statusfunction vpx3220_s_stdfunction vpx3220_s_routingfunction vpx3220_s_streamfunction vpx3220_s_ctrlfunction vpx3220_probefunction vpx3220_remove
Annotated Snippet
struct vpx3220 {
struct v4l2_subdev sd;
struct v4l2_ctrl_handler hdl;
unsigned char reg[255];
v4l2_std_id norm;
int input;
int enable;
};
static inline struct vpx3220 *to_vpx3220(struct v4l2_subdev *sd)
{
return container_of(sd, struct vpx3220, sd);
}
static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
{
return &container_of(ctrl->handler, struct vpx3220, hdl)->sd;
}
static char *inputs[] = { "internal", "composite", "svideo" };
/* ----------------------------------------------------------------------- */
static inline int vpx3220_write(struct v4l2_subdev *sd, u8 reg, u8 value)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct vpx3220 *decoder = i2c_get_clientdata(client);
decoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
static inline int vpx3220_read(struct v4l2_subdev *sd, u8 reg)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
return i2c_smbus_read_byte_data(client, reg);
}
static int vpx3220_fp_status(struct v4l2_subdev *sd)
{
unsigned char status;
unsigned int i;
for (i = 0; i < VPX_TIMEOUT_COUNT; i++) {
status = vpx3220_read(sd, 0x29);
if (!(status & 4))
return 0;
udelay(10);
if (need_resched())
cond_resched();
}
return -1;
}
static int vpx3220_fp_write(struct v4l2_subdev *sd, u8 fpaddr, u16 data)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
/* Write the 16-bit address to the FPWR register */
if (i2c_smbus_write_word_data(client, 0x27, swab16(fpaddr)) == -1) {
v4l2_dbg(1, debug, sd, "%s: failed\n", __func__);
return -1;
}
if (vpx3220_fp_status(sd) < 0)
return -1;
/* Write the 16-bit data to the FPDAT register */
if (i2c_smbus_write_word_data(client, 0x28, swab16(data)) == -1) {
v4l2_dbg(1, debug, sd, "%s: failed\n", __func__);
return -1;
}
return 0;
}
static int vpx3220_fp_read(struct v4l2_subdev *sd, u16 fpaddr)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
s16 data;
/* Write the 16-bit address to the FPRD register */
if (i2c_smbus_write_word_data(client, 0x26, swab16(fpaddr)) == -1) {
v4l2_dbg(1, debug, sd, "%s: failed\n", __func__);
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/delay.h`, `linux/types.h`, `linux/slab.h`, `linux/uaccess.h`, `linux/i2c.h`, `linux/videodev2.h`.
- Detected declarations: `struct vpx3220`, `function vpx3220_write`, `function vpx3220_read`, `function vpx3220_fp_status`, `function vpx3220_fp_write`, `function vpx3220_fp_read`, `function vpx3220_write_block`, `function vpx3220_write_fp_block`, `function vpx3220_init`, `function vpx3220_status`.
- 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.