drivers/media/i2c/dw9714.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/dw9714.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/dw9714.c- Extension
.c- Size
- 9082 bytes
- Lines
- 346
- 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/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/pm_runtime.hlinux/regulator/consumer.hmedia/v4l2-ctrls.hmedia/v4l2-device.hmedia/v4l2-event.h
Detected Declarations
struct dw9714_devicefunction dw9714_i2c_writefunction dw9714_t_focus_vcmfunction dw9714_set_ctrlfunction dw9714_openfunction dw9714_closefunction dw9714_subdev_cleanupfunction dw9714_init_controlsfunction dw9714_power_upfunction dw9714_power_downfunction dw9714_probefunction dw9714_removefunction dw9714_vcm_suspendfunction dw9714_vcm_resume
Annotated Snippet
struct dw9714_device {
struct v4l2_ctrl_handler ctrls_vcm;
struct v4l2_subdev sd;
u16 current_val;
struct regulator *vcc;
struct gpio_desc *powerdown_gpio;
};
static inline struct dw9714_device *to_dw9714_vcm(struct v4l2_ctrl *ctrl)
{
return container_of(ctrl->handler, struct dw9714_device, ctrls_vcm);
}
static inline struct dw9714_device *sd_to_dw9714_vcm(struct v4l2_subdev *subdev)
{
return container_of(subdev, struct dw9714_device, sd);
}
static int dw9714_i2c_write(struct i2c_client *client, u16 data)
{
int ret;
__be16 val = cpu_to_be16(data);
ret = i2c_master_send(client, (const char *)&val, sizeof(val));
if (ret != sizeof(val)) {
dev_err(&client->dev, "I2C write fail\n");
return -EIO;
}
return 0;
}
static int dw9714_t_focus_vcm(struct dw9714_device *dw9714_dev, u16 val)
{
struct i2c_client *client = v4l2_get_subdevdata(&dw9714_dev->sd);
dw9714_dev->current_val = val;
return dw9714_i2c_write(client, DW9714_VAL(val, DW9714_DEFAULT_S));
}
static int dw9714_set_ctrl(struct v4l2_ctrl *ctrl)
{
struct dw9714_device *dev_vcm = to_dw9714_vcm(ctrl);
if (ctrl->id == V4L2_CID_FOCUS_ABSOLUTE)
return dw9714_t_focus_vcm(dev_vcm, ctrl->val);
return -EINVAL;
}
static const struct v4l2_ctrl_ops dw9714_vcm_ctrl_ops = {
.s_ctrl = dw9714_set_ctrl,
};
static int dw9714_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
return pm_runtime_resume_and_get(sd->dev);
}
static int dw9714_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
pm_runtime_put(sd->dev);
return 0;
}
static const struct v4l2_subdev_internal_ops dw9714_int_ops = {
.open = dw9714_open,
.close = dw9714_close,
};
static const struct v4l2_subdev_core_ops dw9714_core_ops = {
.log_status = v4l2_ctrl_subdev_log_status,
.subscribe_event = v4l2_ctrl_subdev_subscribe_event,
.unsubscribe_event = v4l2_event_subdev_unsubscribe,
};
static const struct v4l2_subdev_ops dw9714_ops = {
.core = &dw9714_core_ops,
};
static void dw9714_subdev_cleanup(struct dw9714_device *dw9714_dev)
{
v4l2_async_unregister_subdev(&dw9714_dev->sd);
v4l2_ctrl_handler_free(&dw9714_dev->ctrls_vcm);
media_entity_cleanup(&dw9714_dev->sd.entity);
}
static int dw9714_init_controls(struct dw9714_device *dev_vcm)
{
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.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 dw9714_device`, `function dw9714_i2c_write`, `function dw9714_t_focus_vcm`, `function dw9714_set_ctrl`, `function dw9714_open`, `function dw9714_close`, `function dw9714_subdev_cleanup`, `function dw9714_init_controls`, `function dw9714_power_up`, `function dw9714_power_down`.
- 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.