drivers/media/usb/gspca/spca505.c

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

File Facts

System
Linux kernel
Corpus path
drivers/media/usb/gspca/spca505.c
Extension
.c
Size
18160 bytes
Lines
792
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 */

	u8 subtype;
#define IntelPCCameraPro 0
#define Nxultra 1
};

static const struct v4l2_pix_format vga_mode[] = {
	{160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
		.bytesperline = 160,
		.sizeimage = 160 * 120 * 3 / 2,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 4},
	{176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
		.bytesperline = 176,
		.sizeimage = 176 * 144 * 3 / 2,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 3},
	{320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
		.bytesperline = 320,
		.sizeimage = 320 * 240 * 3 / 2,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 2},
	{352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
		.bytesperline = 352,
		.sizeimage = 352 * 288 * 3 / 2,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 1},
	{640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
		.bytesperline = 640,
		.sizeimage = 640 * 480 * 3 / 2,
		.colorspace = V4L2_COLORSPACE_SRGB,
		.priv = 0},
};

#define SPCA50X_OFFSET_DATA 10

#define SPCA50X_REG_USB 0x02	/* spca505 501 */

#define SPCA50X_USB_CTRL 0x00	/* spca505 */
#define SPCA50X_CUSB_ENABLE 0x01 /* spca505 */

#define SPCA50X_REG_GLOBAL 0x03	/* spca505 */
#define SPCA50X_GMISC0_IDSEL 0x01 /* Global control device ID select spca505 */
#define SPCA50X_GLOBAL_MISC0 0x00 /* Global control miscellaneous 0 spca505 */

#define SPCA50X_GLOBAL_MISC1 0x01 /* 505 */
#define SPCA50X_GLOBAL_MISC3 0x03 /* 505 */
#define SPCA50X_GMISC3_SAA7113RST 0x20	/* Not sure about this one spca505 */

/* Image format and compression control */
#define SPCA50X_REG_COMPRESS 0x04

/*
 * Data to initialize a SPCA505. Common to the CCD and external modes
 */
static const u8 spca505_init_data[][3] = {
	/* bmRequest,value,index */
	{SPCA50X_REG_GLOBAL, SPCA50X_GMISC3_SAA7113RST, SPCA50X_GLOBAL_MISC3},
	/* Sensor reset */
	{SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC3},
	{SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC1},
	/* Block USB reset */
	{SPCA50X_REG_GLOBAL, SPCA50X_GMISC0_IDSEL, SPCA50X_GLOBAL_MISC0},

	{0x05, 0x01, 0x10},
					/* Maybe power down some stuff */
	{0x05, 0x0f, 0x11},

	/* Setup internal CCD  ? */
	{0x06, 0x10, 0x08},
	{0x06, 0x00, 0x09},
	{0x06, 0x00, 0x0a},
	{0x06, 0x00, 0x0b},
	{0x06, 0x10, 0x0c},
	{0x06, 0x00, 0x0d},
	{0x06, 0x00, 0x0e},
	{0x06, 0x00, 0x0f},
	{0x06, 0x10, 0x10},
	{0x06, 0x02, 0x11},
	{0x06, 0x00, 0x12},
	{0x06, 0x04, 0x13},
	{0x06, 0x02, 0x14},
	{0x06, 0x8a, 0x51},
	{0x06, 0x40, 0x52},
	{0x06, 0xb6, 0x53},
	{0x06, 0x3d, 0x54},
	{}
};

Annotation

Implementation Notes