drivers/media/usb/gspca/spca1528.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/spca1528.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/spca1528.c- Extension
.c- Size
- 10294 bytes
- Lines
- 439
- 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
gspca.hjpeg.h
Detected Declarations
struct sdfunction reg_rfunction reg_wfunction reg_wbfunction wait_status_0function wait_status_1function setbrightnessfunction setcontrastfunction sethuefunction setcolorfunction setsharpnessfunction sd_configfunction sd_initfunction sd_isoc_initfunction sd_startfunction sd_stopNfunction add_packetfunction sd_s_ctrlfunction sd_init_controlsfunction sd_probe
Annotated Snippet
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
u8 pkt_seq;
u8 jpeg_hdr[JPEG_HDR_SZ];
};
static const struct v4l2_pix_format vga_mode[] = {
/* (does not work correctly)
{176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
.bytesperline = 176,
.sizeimage = 176 * 144 * 5 / 8 + 590,
.colorspace = V4L2_COLORSPACE_JPEG,
.priv = 3},
*/
{320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
.bytesperline = 320,
.sizeimage = 320 * 240 * 4 / 8 + 590,
.colorspace = V4L2_COLORSPACE_JPEG,
.priv = 2},
{640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
.bytesperline = 640,
.sizeimage = 640 * 480 * 3 / 8 + 590,
.colorspace = V4L2_COLORSPACE_JPEG,
.priv = 1},
};
/* read <len> bytes to gspca usb_buf */
static void reg_r(struct gspca_dev *gspca_dev,
u8 req,
u16 index,
int len)
{
#if USB_BUF_SZ < 64
#error "USB buffer too small"
#endif
struct usb_device *dev = gspca_dev->dev;
int ret;
if (gspca_dev->usb_err < 0)
return;
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
req,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x0000, /* value */
index,
gspca_dev->usb_buf, len,
500);
gspca_dbg(gspca_dev, D_USBI, "GET %02x 0000 %04x %02x\n", req, index,
gspca_dev->usb_buf[0]);
if (ret < 0) {
pr_err("reg_r err %d\n", ret);
gspca_dev->usb_err = ret;
/*
* Make sure the buffer is zeroed to avoid uninitialized
* values.
*/
memset(gspca_dev->usb_buf, 0, USB_BUF_SZ);
}
}
static void reg_w(struct gspca_dev *gspca_dev,
u8 req,
u16 value,
u16 index)
{
struct usb_device *dev = gspca_dev->dev;
int ret;
if (gspca_dev->usb_err < 0)
return;
gspca_dbg(gspca_dev, D_USBO, "SET %02x %04x %04x\n", req, value, index);
ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
req,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index,
NULL, 0, 500);
if (ret < 0) {
pr_err("reg_w err %d\n", ret);
gspca_dev->usb_err = ret;
}
}
static void reg_wb(struct gspca_dev *gspca_dev,
u8 req,
u16 value,
u16 index,
u8 byte)
{
Annotation
- Immediate include surface: `gspca.h`, `jpeg.h`.
- Detected declarations: `struct sd`, `function reg_r`, `function reg_w`, `function reg_wb`, `function wait_status_0`, `function wait_status_1`, `function setbrightness`, `function setcontrast`, `function sethue`, `function setcolor`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.