drivers/media/i2c/mt9v032.c

Source file repositories/reference/linux-study-clean/drivers/media/i2c/mt9v032.c

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/mt9v032.c
Extension
.c
Size
36669 bytes
Lines
1296
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 mt9v032_model_version {
	unsigned int version;
	const char *name;
};

struct mt9v032_model_data {
	unsigned int min_row_time;
	unsigned int min_hblank;
	unsigned int min_vblank;
	unsigned int max_vblank;
	unsigned int min_shutter;
	unsigned int max_shutter;
	unsigned int pclk_reg;
	unsigned int aec_max_shutter_reg;
	const struct v4l2_ctrl_config * const aec_max_shutter_v4l2_ctrl;
};

struct mt9v032_model_info {
	const struct mt9v032_model_data *data;
	bool color;
};

static const struct mt9v032_model_version mt9v032_versions[] = {
	{ MT9V032_CHIP_ID_REV1, "MT9V022/MT9V032 rev1/2" },
	{ MT9V032_CHIP_ID_REV3, "MT9V022/MT9V032 rev3" },
	{ MT9V034_CHIP_ID_REV1, "MT9V024/MT9V034 rev1" },
};

struct mt9v032_platform_data {
	unsigned int clk_pol:1;

	const s64 *link_freqs;
	s64 link_def_freq;
};

struct mt9v032 {
	struct device *dev;

	struct v4l2_subdev subdev;
	struct media_pad pad;

	struct v4l2_mbus_framefmt format;
	struct v4l2_rect crop;
	unsigned int hratio;
	unsigned int vratio;

	struct v4l2_ctrl_handler ctrls;
	struct {
		struct v4l2_ctrl *link_freq;
		struct v4l2_ctrl *pixel_rate;
	};

	struct mutex power_lock;
	int power_count;

	struct regmap *regmap;
	struct clk *clk;
	struct gpio_desc *reset_gpio;
	struct gpio_desc *standby_gpio;

	struct mt9v032_platform_data pdata;
	const struct mt9v032_model_info *model;
	const struct mt9v032_model_version *version;

	u32 sysclk;
	u16 aec_agc;
	u16 hblank;
	struct {
		struct v4l2_ctrl *test_pattern;
		struct v4l2_ctrl *test_pattern_color;
	};
};

static struct mt9v032 *to_mt9v032(struct v4l2_subdev *sd)
{
	return container_of(sd, struct mt9v032, subdev);
}

static int
mt9v032_update_aec_agc(struct mt9v032 *mt9v032, u16 which, int enable)
{
	struct regmap *map = mt9v032->regmap;
	u16 value = mt9v032->aec_agc;
	int ret;

	if (enable)
		value |= which;
	else
		value &= ~which;

Annotation

Implementation Notes