drivers/media/i2c/upd64083.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/upd64083.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/upd64083.c- Extension
.c- Size
- 5294 bytes
- Lines
- 208
- 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/kernel.hlinux/i2c.hlinux/videodev2.hlinux/slab.hmedia/v4l2-device.hmedia/i2c/upd64083.h
Detected Declarations
struct upd64083_statefunction upd64083_writefunction upd64083_readfunction upd64083_s_routingfunction upd64083_g_registerfunction upd64083_s_registerfunction upd64083_log_statusfunction upd64083_probefunction upd64083_remove
Annotated Snippet
struct upd64083_state {
struct v4l2_subdev sd;
u8 mode;
u8 ext_y_adc;
u8 regs[TOT_REGS];
};
static inline struct upd64083_state *to_state(struct v4l2_subdev *sd)
{
return container_of(sd, struct upd64083_state, sd);
}
/* Initial values when used in combination with the
NEC upd64031a ghost reduction chip. */
static u8 upd64083_init[] = {
0x1f, 0x01, 0xa0, 0x2d, 0x29, /* we use EXCSS=0 */
0x36, 0xdd, 0x05, 0x56, 0x48,
0x00, 0x3a, 0xa0, 0x05, 0x08,
0x44, 0x60, 0x08, 0x52, 0xf8,
0x53, 0x60, 0x10
};
/* ------------------------------------------------------------------------ */
static void upd64083_write(struct v4l2_subdev *sd, u8 reg, u8 val)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
u8 buf[2];
buf[0] = reg;
buf[1] = val;
v4l2_dbg(1, debug, sd, "write reg: %02x val: %02x\n", reg, val);
if (i2c_master_send(client, buf, 2) != 2)
v4l2_err(sd, "I/O error write 0x%02x/0x%02x\n", reg, val);
}
/* ------------------------------------------------------------------------ */
#ifdef CONFIG_VIDEO_ADV_DEBUG
static u8 upd64083_read(struct v4l2_subdev *sd, u8 reg)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
u8 buf[7];
if (reg >= sizeof(buf))
return 0xff;
i2c_master_recv(client, buf, sizeof(buf));
return buf[reg];
}
#endif
/* ------------------------------------------------------------------------ */
static int upd64083_s_routing(struct v4l2_subdev *sd,
u32 input, u32 output, u32 config)
{
struct upd64083_state *state = to_state(sd);
u8 r00, r02;
if (input > 7 || (input & 6) == 6)
return -EINVAL;
state->mode = (input & 3) << 6;
state->ext_y_adc = (input & UPD64083_EXT_Y_ADC) << 3;
r00 = (state->regs[R00] & ~(3 << 6)) | state->mode;
r02 = (state->regs[R02] & ~(1 << 5)) | state->ext_y_adc;
upd64083_write(sd, R00, r00);
upd64083_write(sd, R02, r02);
return 0;
}
#ifdef CONFIG_VIDEO_ADV_DEBUG
static int upd64083_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
{
reg->val = upd64083_read(sd, reg->reg & 0xff);
reg->size = 1;
return 0;
}
static int upd64083_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg)
{
upd64083_write(sd, reg->reg & 0xff, reg->val & 0xff);
return 0;
}
#endif
static int upd64083_log_status(struct v4l2_subdev *sd)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
u8 buf[7];
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/i2c.h`, `linux/videodev2.h`, `linux/slab.h`, `media/v4l2-device.h`, `media/i2c/upd64083.h`.
- Detected declarations: `struct upd64083_state`, `function upd64083_write`, `function upd64083_read`, `function upd64083_s_routing`, `function upd64083_g_register`, `function upd64083_s_register`, `function upd64083_log_status`, `function upd64083_probe`, `function upd64083_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.