drivers/media/i2c/ak7375.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ak7375.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ak7375.c- Extension
.c- Size
- 9272 bytes
- Lines
- 358
- 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/acpi.hlinux/delay.hlinux/i2c.hlinux/module.hlinux/pm_runtime.hlinux/regulator/consumer.hmedia/v4l2-ctrls.hmedia/v4l2-device.h
Detected Declarations
struct ak73xx_chipdefstruct ak7375_devicefunction ak7375_i2c_writefunction ak7375_set_ctrlfunction ak7375_openfunction ak7375_closefunction ak7375_subdev_cleanupfunction ak7375_init_controlsfunction ak7375_probefunction ak7375_removefunction ak7375_vcm_suspendfunction ak7375_vcm_resume
Annotated Snippet
struct ak73xx_chipdef {
u8 reg_position;
u8 reg_cont;
u8 shift_pos;
u8 mode_active;
u8 mode_standby;
bool has_standby; /* Some chips may not have standby mode */
u16 focus_pos_max;
/*
* This sets the minimum granularity for the focus positions.
* A value of 1 gives maximum accuracy for a desired focus position
*/
u16 focus_steps;
/*
* This acts as the minimum granularity of lens movement.
* Keep this value power of 2, so the control steps can be
* uniformly adjusted for gradual lens movement, with desired
* number of control steps.
*/
u16 ctrl_steps;
u16 ctrl_delay_us;
/*
* The vcm may take time (tDELAY) to power on and start taking
* I2C messages.
*/
u16 power_delay_us;
};
static const struct ak73xx_chipdef ak7345_cdef = {
.reg_position = 0x0,
.reg_cont = 0x2,
.shift_pos = 7, /* 9 bits position values, need to << 7 */
.mode_active = 0x0,
.has_standby = false,
.focus_pos_max = 511,
.focus_steps = 1,
.ctrl_steps = 16,
.ctrl_delay_us = 1000,
.power_delay_us = 20000,
};
static const struct ak73xx_chipdef ak7375_cdef = {
.reg_position = 0x0,
.reg_cont = 0x2,
.shift_pos = 4, /* 12 bits position values, need to << 4 */
.mode_active = 0x0,
.mode_standby = 0x40,
.has_standby = true,
.focus_pos_max = 4095,
.focus_steps = 1,
.ctrl_steps = 64,
.ctrl_delay_us = 1000,
.power_delay_us = 10000,
};
static const char * const ak7375_supply_names[] = {
"vdd",
"vio",
};
/* ak7375 device structure */
struct ak7375_device {
const struct ak73xx_chipdef *cdef;
struct v4l2_ctrl_handler ctrls_vcm;
struct v4l2_subdev sd;
struct v4l2_ctrl *focus;
struct regulator_bulk_data supplies[ARRAY_SIZE(ak7375_supply_names)];
/* active or standby mode */
bool active;
};
static inline struct ak7375_device *to_ak7375_vcm(struct v4l2_ctrl *ctrl)
{
return container_of(ctrl->handler, struct ak7375_device, ctrls_vcm);
}
static inline struct ak7375_device *sd_to_ak7375_vcm(struct v4l2_subdev *subdev)
{
return container_of(subdev, struct ak7375_device, sd);
}
static int ak7375_i2c_write(struct ak7375_device *ak7375,
u8 addr, u16 data, u8 size)
{
struct i2c_client *client = v4l2_get_subdevdata(&ak7375->sd);
u8 buf[3];
int ret;
if (size != 1 && size != 2)
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/delay.h`, `linux/i2c.h`, `linux/module.h`, `linux/pm_runtime.h`, `linux/regulator/consumer.h`, `media/v4l2-ctrls.h`, `media/v4l2-device.h`.
- Detected declarations: `struct ak73xx_chipdef`, `struct ak7375_device`, `function ak7375_i2c_write`, `function ak7375_set_ctrl`, `function ak7375_open`, `function ak7375_close`, `function ak7375_subdev_cleanup`, `function ak7375_init_controls`, `function ak7375_probe`, `function ak7375_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.