drivers/media/i2c/max9286.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/max9286.c
Extension
.c
Size
43214 bytes
Lines
1685
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 max9286_format_info {
	u32 code;
	u8 datatype;
};

struct max9286_i2c_speed {
	u32 rate;
	u8 mstbt;
};

struct max9286_source {
	struct v4l2_subdev *sd;
	struct fwnode_handle *fwnode;
	struct regulator *regulator;
};

struct max9286_asd {
	struct v4l2_async_connection base;
	struct max9286_source *source;
};

static inline struct max9286_asd *
to_max9286_asd(struct v4l2_async_connection *asd)
{
	return container_of(asd, struct max9286_asd, base);
}

struct max9286_priv {
	struct i2c_client *client;
	struct gpio_desc *gpiod_pwdn;
	struct v4l2_subdev sd;
	struct media_pad pads[MAX9286_N_PADS];
	struct regulator *regulator;

	struct gpio_chip gpio;
	u8 gpio_state;

	struct i2c_mux_core *mux;
	unsigned int mux_channel;
	bool mux_open;

	/* The initial reverse control channel amplitude. */
	u32 init_rev_chan_mv;
	u32 rev_chan_mv;
	u8 i2c_mstbt;
	u32 bus_width;

	bool use_gpio_poc;
	u32 gpio_poc[2];

	struct v4l2_ctrl_handler ctrls;
	struct v4l2_ctrl *pixelrate_ctrl;
	unsigned int pixelrate;

	unsigned int nsources;
	unsigned int source_mask;
	unsigned int route_mask;
	unsigned int bound_sources;
	unsigned int csi2_data_lanes;
	struct max9286_source sources[MAX9286_NUM_GMSL];
	struct v4l2_async_notifier notifier;
};

static struct max9286_source *next_source(struct max9286_priv *priv,
					  struct max9286_source *source)
{
	if (!source)
		source = &priv->sources[0];
	else
		source++;

	for (; source < &priv->sources[MAX9286_NUM_GMSL]; source++) {
		if (source->fwnode)
			return source;
	}

	return NULL;
}

#define for_each_source(priv, source) \
	for ((source) = NULL; ((source) = next_source((priv), (source))); )

#define to_index(priv, source) ((source) - &(priv)->sources[0])

static inline struct max9286_priv *sd_to_max9286(struct v4l2_subdev *sd)
{
	return container_of(sd, struct max9286_priv, sd);
}

static const struct max9286_format_info max9286_formats[] = {

Annotation

Implementation Notes