drivers/media/i2c/dw9719.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/dw9719.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/dw9719.c- Extension
.c- Size
- 12911 bytes
- Lines
- 478
- 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/delay.hlinux/i2c.hlinux/pm_runtime.hlinux/regulator/consumer.hlinux/types.hmedia/v4l2-cci.hmedia/v4l2-common.hmedia/v4l2-ctrls.hmedia/v4l2-subdev.h
Detected Declarations
struct dw9719_devicestruct dw9719_v4l2_ctrlsenum dw9719_modelfunction dw9719_power_downfunction dw9719_power_upfunction dw9719_t_focus_absfunction dw9719_set_ctrlfunction dw9719_suspendfunction dw9719_resumefunction dw9719_openfunction dw9719_closefunction dw9719_init_controlsfunction dw9719_probefunction dw9719_remove
Annotated Snippet
struct dw9719_device {
struct v4l2_subdev sd;
struct device *dev;
struct regmap *regmap;
struct regulator *regulator;
enum dw9719_model model;
u32 mode_low_bits;
u32 sac_mode;
u32 vcm_freq;
struct dw9719_v4l2_ctrls {
struct v4l2_ctrl_handler handler;
struct v4l2_ctrl *focus;
} ctrls;
};
static int dw9719_power_down(struct dw9719_device *dw9719)
{
u32 reg_pwr = dw9719->model == DW9718S ? DW9718S_PD : DW9719_CONTROL;
/*
* Worth engaging the internal SHUTDOWN mode especially due to the
* regulator being potentially shared with other devices.
*/
if (cci_write(dw9719->regmap, reg_pwr, DW9719_SHUTDOWN, NULL))
dev_err(dw9719->dev, "Error writing to power register\n");
return regulator_disable(dw9719->regulator);
}
static int dw9719_power_up(struct dw9719_device *dw9719, bool detect)
{
u32 reg_pwr = dw9719->model == DW9718S ? DW9718S_PD : DW9719_CONTROL;
u64 val;
int ret;
int err;
ret = regulator_enable(dw9719->regulator);
if (ret)
return ret;
/*
* Need 100us to transition from SHUTDOWN to STANDBY.
* Jiggle the SCL pin to wake up the device (even when the regulator is
* shared) and wait double the time to be sure, as 100us is not enough
* at least on the DW9718S as found on the motorola-nora smartphone,
* then retry the write.
*/
cci_write(dw9719->regmap, reg_pwr, DW9719_STANDBY, NULL);
/* the jiggle is expected to fail, don't even log that as error */
fsleep(200);
cci_write(dw9719->regmap, reg_pwr, DW9719_STANDBY, &ret);
if (detect) {
/* These models do not have an INFO register */
switch (dw9719->model) {
case DW9718S:
dw9719->sac_mode = DW9718S_DEFAULT_SAC;
dw9719->vcm_freq = DW9718S_DEFAULT_VCM_FREQ;
goto props;
case DW9800K:
dw9719->sac_mode = DW9800K_DEFAULT_SAC;
dw9719->vcm_freq = DW9800K_DEFAULT_VCM_FREQ;
goto props;
default:
break;
}
ret = cci_read(dw9719->regmap, DW9719_INFO, &val, NULL);
if (ret < 0)
return ret;
switch (val) {
case DW9719_ID:
dw9719->model = DW9719;
dw9719->mode_low_bits = 0x00;
dw9719->sac_mode = DW9719_DEFAULT_SAC;
dw9719->vcm_freq = DW9719_DEFAULT_VCM_FREQ;
break;
case DW9761_ID:
dw9719->model = DW9761;
dw9719->mode_low_bits = 0x01;
dw9719->sac_mode = DW9761_DEFAULT_SAC;
dw9719->vcm_freq = DW9761_DEFAULT_VCM_FREQ;
break;
default:
dev_err(dw9719->dev,
"Error unknown device id 0x%02llx\n", val);
return -ENXIO;
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/pm_runtime.h`, `linux/regulator/consumer.h`, `linux/types.h`, `media/v4l2-cci.h`, `media/v4l2-common.h`, `media/v4l2-ctrls.h`.
- Detected declarations: `struct dw9719_device`, `struct dw9719_v4l2_ctrls`, `enum dw9719_model`, `function dw9719_power_down`, `function dw9719_power_up`, `function dw9719_t_focus_abs`, `function dw9719_set_ctrl`, `function dw9719_suspend`, `function dw9719_resume`, `function dw9719_open`.
- 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.