drivers/media/usb/gspca/topro.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/gspca/topro.c
Extension
.c
Size
196347 bytes
Lines
4973
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 sd {
	struct gspca_dev gspca_dev;	/* !! must be the first item */
	struct v4l2_ctrl *jpegqual;
	struct v4l2_ctrl *sharpness;
	struct v4l2_ctrl *gamma;
	struct v4l2_ctrl *blue;
	struct v4l2_ctrl *red;

	u8 framerate;
	u8 quality;		/* webcam current JPEG quality (0..16) */
	s8 ag_cnt;		/* autogain / start counter for tp6810 */
#define AG_CNT_START 13		/* check gain every N frames */

	u8 bridge;
	u8 sensor;

	u8 jpeg_hdr[JPEG_HDR_SZ];
};

enum bridges {
	BRIDGE_TP6800,
	BRIDGE_TP6810,
};

enum sensors {
	SENSOR_CX0342,
	SENSOR_SOI763A,		/* ~= ov7630 / ov7648 */
	NSENSORS
};

static const struct v4l2_pix_format vga_mode[] = {
	{320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
		.bytesperline = 320,
		.sizeimage = 320 * 240 * 4 / 8 + 590,
		.colorspace = V4L2_COLORSPACE_JPEG},
	{640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
		.bytesperline = 640,
		.sizeimage = 640 * 480 * 3 / 8 + 590,
		.colorspace = V4L2_COLORSPACE_JPEG}
};

/*
 * JPEG quality
 * index: webcam compression
 * value: JPEG quality in %
 */
static const u8 jpeg_q[17] = {
	88, 77, 67, 57, 55, 55, 45, 45, 36, 36, 30, 30, 26, 26, 22, 22, 94
};

#define BULK_OUT_SIZE		0x20
#if BULK_OUT_SIZE > USB_BUF_SZ
#error "USB buffer too small"
#endif

#define DEFAULT_FRAME_RATE 30

static const u8 rates[] = {30, 20, 15, 10, 7, 5};
static const struct framerates framerates[] = {
	{
		.rates = rates,
		.nrates = ARRAY_SIZE(rates)
	},
	{
		.rates = rates,
		.nrates = ARRAY_SIZE(rates)
	}
};
static const u8 rates_6810[] = {30, 15, 10, 7, 5};
static const struct framerates framerates_6810[] = {
	{
		.rates = rates_6810,
		.nrates = ARRAY_SIZE(rates_6810)
	},
	{
		.rates = rates_6810,
		.nrates = ARRAY_SIZE(rates_6810)
	}
};

/*
 * webcam quality in %
 * the last value is the ultra fine quality
 */

/* TP6800 register offsets */
#define TP6800_R10_SIF_TYPE		0x10
#define TP6800_R11_SIF_CONTROL		0x11
#define TP6800_R12_SIF_ADDR_S		0x12
#define TP6800_R13_SIF_TX_DATA		0x13

Annotation

Implementation Notes