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.

Dependency Surface

Detected Declarations

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

Implementation Notes