drivers/media/usb/gspca/gl860/gl860-ov2640.c

Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/gl860/gl860-ov2640.c

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/gspca/gl860/gl860-ov2640.c
Extension
.c
Size
17519 bytes
Lines
478
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

if (reso == IMAGE_1280) {
			n = fetch_validx(gspca_dev, tbl_big2,
					ARRAY_SIZE(tbl_big2));
		} else {
			ctrl_out(gspca_dev, 0x40, 1, 0x601d, 0x0086, 0, NULL);
			ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00d7, 0, NULL);
			ctrl_out(gspca_dev, 0x40, 1, 0x6082, 0x00d3, 0, NULL);
		}

		n = fetch_validx(gspca_dev, tbl_big3, ARRAY_SIZE(tbl_big3));

		if (reso == IMAGE_1280) {
			ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00ff, 0, NULL);
			ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
					12, dat_1280);
		} else {
			ctrl_out(gspca_dev, 0x40, 1, 0x6020, 0x008c, 0, NULL);
			ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00ff, 0, NULL);
			ctrl_out(gspca_dev, 0x40, 1, 0x6076, 0x0018, 0, NULL);
			ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
					12, dat_1600);
		}
		break;
	}

	n = fetch_validx(gspca_dev, tbl_sensor_settings_common2,
			ARRAY_SIZE(tbl_sensor_settings_common2));

	ov2640_camera_settings(gspca_dev);

	return 0;
}

static int ov2640_configure_alt(struct gspca_dev *gspca_dev)
{
	s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;

	switch (reso) {
	case IMAGE_640:
		gspca_dev->alt = 3 + 1;
		break;

	case IMAGE_800:
	case IMAGE_1280:
	case IMAGE_1600:
		gspca_dev->alt = 1 + 1;
		break;
	}
	return 0;
}

static int ov2640_camera_settings(struct gspca_dev *gspca_dev)
{
	struct sd *sd = (struct sd *) gspca_dev;

	s32 backlight = sd->vcur.backlight;
	s32 bright = sd->vcur.brightness;
	s32 sharp  = sd->vcur.sharpness;
	s32 gam    = sd->vcur.gamma;
	s32 cntr   = sd->vcur.contrast;
	s32 sat    = sd->vcur.saturation;
	s32 hue    = sd->vcur.hue;
	s32 wbal   = sd->vcur.whitebal;
	s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) == 0);
	s32 flip   = (((sd->vcur.flip   > 0) ^ sd->mirrorMask) == 0);

	if (backlight != sd->vold.backlight) {
		/* No sd->vold.backlight=backlight; (to be done again later) */
		if (backlight < 0 || backlight > sd->vmax.backlight)
			backlight = 0;

		ctrl_out(gspca_dev, 0x40, 1, 0x6001                 , 0x00ff,
				0, NULL);
		ctrl_out(gspca_dev, 0x40, 1, 0x601e + backlight     , 0x0024,
				0, NULL);
		ctrl_out(gspca_dev, 0x40, 1, 0x601e + backlight - 10, 0x0025,
				0, NULL);
	}

	if (bright != sd->vold.brightness) {
		sd->vold.brightness = bright;
		if (bright < 0 || bright > sd->vmax.brightness)
			bright = 0;

		ctrl_out(gspca_dev, 0x40, 1, 0x6000         , 0x00ff, 0, NULL);
		ctrl_out(gspca_dev, 0x40, 1, 0x6009         , 0x007c, 0, NULL);
		ctrl_out(gspca_dev, 0x40, 1, 0x6000 + bright, 0x007d, 0, NULL);
	}

	if (wbal != sd->vold.whitebal) {

Annotation

Implementation Notes