drivers/media/i2c/os05b10.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/i2c/os05b10.c
Extension
.c
Size
30008 bytes
Lines
1131
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 os05b10 {
	struct device *dev;
	struct regmap *cci;
	struct v4l2_subdev sd;
	struct media_pad pad;
	struct clk *xclk;
	struct i2c_client *client;
	struct gpio_desc *reset_gpio;
	struct regulator_bulk_data supplies[ARRAY_SIZE(os05b10_supply_name)];

	/* V4L2 Controls */
	struct v4l2_ctrl_handler handler;
	struct v4l2_ctrl *link_freq;
	struct v4l2_ctrl *hblank;
	struct v4l2_ctrl *vblank;
	struct v4l2_ctrl *gain;
	struct v4l2_ctrl *exposure;

	u32 link_freq_index;
	u32 data_lanes;
};

struct os05b10_mode {
	u32 width;
	u32 height;
	u32 vts;
	u32 hts;
	u32 exp;
	u8 bpp;
};

static const struct os05b10_mode supported_modes_10bit[] = {
	{
		.width = 2592,
		.height = 1944,
		.vts = 2006,
		.hts = 1744,
		.exp = 1944,
		.bpp = 10,
	},
};

static const s64 link_frequencies[] = {
	OS05B10_LINK_FREQ_600MHZ,
};

static const u32 os05b10_mbus_codes[] = {
	MEDIA_BUS_FMT_SBGGR10_1X10,
};

static inline struct os05b10 *to_os05b10(struct v4l2_subdev *sd)
{
	return container_of_const(sd, struct os05b10, sd);
};

static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
{
	struct os05b10 *os05b10 = container_of_const(ctrl->handler,
						     struct os05b10, handler);
	struct v4l2_subdev_state *state;
	struct v4l2_mbus_framefmt *fmt;
	int vmax, ret;

	state = v4l2_subdev_get_locked_active_state(&os05b10->sd);
	fmt = v4l2_subdev_state_get_format(state, 0);

	if (ctrl->id == V4L2_CID_VBLANK) {
		/* Honour the VBLANK limits when setting exposure. */
		s64 max = fmt->height + ctrl->val - OS05B10_EXPOSURE_MARGIN;

		ret = __v4l2_ctrl_modify_range(os05b10->exposure,
					       os05b10->exposure->minimum, max,
					       os05b10->exposure->step,
					       os05b10->exposure->default_value);
		if (ret)
			return ret;
	}

	if (pm_runtime_get_if_in_use(os05b10->dev) == 0)
		return 0;

	switch (ctrl->id) {
	case V4L2_CID_VBLANK:
		vmax = fmt->height + ctrl->val;
		ret = cci_write(os05b10->cci, OS05B10_REG_VTS, vmax, NULL);
		break;
	case V4L2_CID_ANALOGUE_GAIN:
		ret = cci_write(os05b10->cci, OS05B10_REG_ANALOG_GAIN,
				ctrl->val, NULL);
		break;

Annotation

Implementation Notes