drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c

Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
Extension
.c
Size
12243 bytes
Lines
433
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 pb0100_ctrls {
	struct { /* one big happy control cluster... */
		struct v4l2_ctrl *autogain;
		struct v4l2_ctrl *gain;
		struct v4l2_ctrl *exposure;
		struct v4l2_ctrl *red;
		struct v4l2_ctrl *blue;
		struct v4l2_ctrl *natural;
	};
	struct v4l2_ctrl *target;
};

static struct v4l2_pix_format pb0100_mode[] = {
/* low res / subsample modes disabled as they are only half res horizontal,
   halving the vertical resolution does not seem to work */
	{
		320,
		240,
		V4L2_PIX_FMT_SGRBG8,
		V4L2_FIELD_NONE,
		.sizeimage = 320 * 240,
		.bytesperline = 320,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = PB0100_CROP_TO_VGA
	},
	{
		352,
		288,
		V4L2_PIX_FMT_SGRBG8,
		V4L2_FIELD_NONE,
		.sizeimage = 352 * 288,
		.bytesperline = 352,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 0
	}
};

static int pb0100_s_ctrl(struct v4l2_ctrl *ctrl)
{
	struct gspca_dev *gspca_dev =
		container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
	struct sd *sd = (struct sd *)gspca_dev;
	struct pb0100_ctrls *ctrls = sd->sensor_priv;
	int err = -EINVAL;

	switch (ctrl->id) {
	case V4L2_CID_AUTOGAIN:
		err = pb0100_set_autogain(gspca_dev, ctrl->val);
		if (err)
			break;
		if (ctrl->val)
			break;
		err = pb0100_set_gain(gspca_dev, ctrls->gain->val);
		if (err)
			break;
		err = pb0100_set_exposure(gspca_dev, ctrls->exposure->val);
		break;
	case V4L2_CTRL_CLASS_USER + 0x1001:
		err = pb0100_set_autogain_target(gspca_dev, ctrl->val);
		break;
	}
	return err;
}

static const struct v4l2_ctrl_ops pb0100_ctrl_ops = {
	.s_ctrl = pb0100_s_ctrl,
};

static int pb0100_init_controls(struct sd *sd)
{
	struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler;
	struct pb0100_ctrls *ctrls;
	static const struct v4l2_ctrl_config autogain_target = {
		.ops = &pb0100_ctrl_ops,
		.id = V4L2_CTRL_CLASS_USER + 0x1000,
		.type = V4L2_CTRL_TYPE_INTEGER,
		.name = "Automatic Gain Target",
		.max = 255,
		.step = 1,
		.def = 128,
	};
	static const struct v4l2_ctrl_config natural_light = {
		.ops = &pb0100_ctrl_ops,
		.id = V4L2_CTRL_CLASS_USER + 0x1001,
		.type = V4L2_CTRL_TYPE_BOOLEAN,
		.name = "Natural Light Source",
		.max = 1,
		.step = 1,
		.def = 1,
	};

Annotation

Implementation Notes