drivers/media/i2c/video-i2c.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/video-i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/video-i2c.c- Extension
.c- Size
- 23406 bytes
- Lines
- 954
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bits.hlinux/delay.hlinux/freezer.hlinux/hwmon.hlinux/kthread.hlinux/i2c.hlinux/list.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/pm_runtime.hlinux/nvmem-provider.hlinux/regmap.hlinux/sched.hlinux/slab.hlinux/videodev2.hmedia/v4l2-common.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-fh.hmedia/v4l2-ioctl.hmedia/videobuf2-v4l2.hmedia/videobuf2-vmalloc.h
Detected Declarations
struct video_i2c_chipstruct video_i2c_bufferstruct video_i2c_datastruct video_i2c_chipfunction mlx90640_nvram_readfunction amg88xx_xferfunction mlx90640_xferfunction amg88xx_setupfunction mlx90640_setupfunction amg88xx_set_power_onfunction amg88xx_set_power_offfunction amg88xx_set_powerfunction amg88xx_is_visiblefunction amg88xx_readfunction amg88xx_hwmon_initfunction queue_setupfunction buffer_preparefunction buffer_queuefunction video_i2c_thread_vid_capfunction video_i2c_del_listfunction list_for_each_entry_safefunction start_streamingfunction stop_streamingfunction video_i2c_querycapfunction video_i2c_g_inputfunction video_i2c_s_inputfunction video_i2c_enum_inputfunction video_i2c_enum_fmt_vid_capfunction video_i2c_enum_framesizesfunction video_i2c_enum_frameintervalsfunction video_i2c_try_fmt_vid_capfunction video_i2c_s_fmt_vid_capfunction video_i2c_g_parmfunction video_i2c_s_parmfunction video_i2c_releasefunction video_i2c_probefunction video_i2c_removefunction video_i2c_pm_runtime_suspendfunction video_i2c_pm_runtime_resume
Annotated Snippet
struct video_i2c_buffer {
struct vb2_v4l2_buffer vb;
struct list_head list;
};
struct video_i2c_data {
struct regmap *regmap;
const struct video_i2c_chip *chip;
struct mutex lock;
spinlock_t slock;
unsigned int sequence;
struct mutex queue_lock;
struct v4l2_device v4l2_dev;
struct video_device vdev;
struct vb2_queue vb_vidq;
struct task_struct *kthread_vid_cap;
struct list_head vid_cap_active;
struct v4l2_fract frame_interval;
};
static const struct v4l2_fmtdesc amg88xx_format = {
.pixelformat = V4L2_PIX_FMT_Y12,
};
static const struct v4l2_frmsize_discrete amg88xx_size = {
.width = 8,
.height = 8,
};
static const struct v4l2_fmtdesc mlx90640_format = {
.pixelformat = V4L2_PIX_FMT_Y16_BE,
};
static const struct v4l2_frmsize_discrete mlx90640_size = {
.width = 32,
.height = 26, /* 24 lines of pixel data + 2 lines of processing data */
};
static const struct regmap_config amg88xx_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0xff
};
static const struct regmap_config mlx90640_regmap_config = {
.reg_bits = 16,
.val_bits = 16,
};
struct video_i2c_chip {
/* video dimensions */
const struct v4l2_fmtdesc *format;
const struct v4l2_frmsize_discrete *size;
/* available frame intervals */
const struct v4l2_fract *frame_intervals;
unsigned int num_frame_intervals;
/* pixel buffer size */
unsigned int buffer_size;
/* pixel size in bits */
unsigned int bpp;
const struct regmap_config *regmap_config;
struct nvmem_config *nvmem_config;
/* setup function */
int (*setup)(struct video_i2c_data *data);
/* xfer function */
int (*xfer)(struct video_i2c_data *data, char *buf);
/* power control function */
int (*set_power)(struct video_i2c_data *data, bool on);
/* hwmon init function */
int (*hwmon_init)(struct video_i2c_data *data);
};
static int mlx90640_nvram_read(void *priv, unsigned int offset, void *val,
size_t bytes)
{
struct video_i2c_data *data = priv;
return regmap_bulk_read(data->regmap, MLX90640_EEPROM_START_ADDR + offset, val, bytes);
}
Annotation
- Immediate include surface: `linux/bits.h`, `linux/delay.h`, `linux/freezer.h`, `linux/hwmon.h`, `linux/kthread.h`, `linux/i2c.h`, `linux/list.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct video_i2c_chip`, `struct video_i2c_buffer`, `struct video_i2c_data`, `struct video_i2c_chip`, `function mlx90640_nvram_read`, `function amg88xx_xfer`, `function mlx90640_xfer`, `function amg88xx_setup`, `function mlx90640_setup`, `function amg88xx_set_power_on`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.