drivers/media/usb/gspca/sn9c2028.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/sn9c2028.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/sn9c2028.c- Extension
.c- Size
- 31928 bytes
- Lines
- 964
- 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.hsn9c2028.h
Detected Declarations
struct sdstruct init_commandfunction sn9c2028_commandfunction sn9c2028_read1function sn9c2028_read4function sn9c2028_long_commandfunction sn9c2028_short_commandfunction sd_configfunction sd_initfunction run_start_commandsfunction set_gainfunction sd_s_ctrlfunction sd_init_controlsfunction start_spy_camfunction start_cif_camfunction start_ms350_camfunction start_genius_camfunction start_genius_videocam_livefunction start_vivitar_camfunction sd_startfunction sd_stopNfunction do_autogainfunction sd_dqcallbackfunction sd_probe
Annotated Snippet
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
u8 sof_read;
u16 model;
#define MIN_AVG_LUM 8500
#define MAX_AVG_LUM 10000
int avg_lum;
u8 avg_lum_l;
struct { /* autogain and gain control cluster */
struct v4l2_ctrl *autogain;
struct v4l2_ctrl *gain;
};
};
struct init_command {
unsigned char instruction[6];
unsigned char to_read; /* length to read. 0 means no reply requested */
};
/* How to change the resolution of any of the VGA cams is unknown */
static const struct v4l2_pix_format vga_mode[] = {
{640, 480, V4L2_PIX_FMT_SN9C2028, V4L2_FIELD_NONE,
.bytesperline = 640,
.sizeimage = 640 * 480 * 3 / 4,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 0},
};
/* No way to change the resolution of the CIF cams is known */
static const struct v4l2_pix_format cif_mode[] = {
{352, 288, V4L2_PIX_FMT_SN9C2028, V4L2_FIELD_NONE,
.bytesperline = 352,
.sizeimage = 352 * 288 * 3 / 4,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 0},
};
/* the bytes to write are in gspca_dev->usb_buf */
static int sn9c2028_command(struct gspca_dev *gspca_dev, u8 *command)
{
int rc;
gspca_dbg(gspca_dev, D_USBO, "sending command %02x%02x%02x%02x%02x%02x\n",
command[0], command[1], command[2],
command[3], command[4], command[5]);
memcpy(gspca_dev->usb_buf, command, 6);
rc = usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0),
USB_REQ_GET_CONFIGURATION,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2, 0, gspca_dev->usb_buf, 6, 500);
if (rc < 0) {
pr_err("command write [%02x] error %d\n",
gspca_dev->usb_buf[0], rc);
return rc;
}
return 0;
}
static int sn9c2028_read1(struct gspca_dev *gspca_dev)
{
int rc;
rc = usb_control_msg(gspca_dev->dev,
usb_rcvctrlpipe(gspca_dev->dev, 0),
USB_REQ_GET_STATUS,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1, 0, gspca_dev->usb_buf, 1, 500);
if (rc != 1) {
pr_err("read1 error %d\n", rc);
return (rc < 0) ? rc : -EIO;
}
gspca_dbg(gspca_dev, D_USBI, "read1 response %02x\n",
gspca_dev->usb_buf[0]);
return gspca_dev->usb_buf[0];
}
static int sn9c2028_read4(struct gspca_dev *gspca_dev, u8 *reading)
{
int rc;
rc = usb_control_msg(gspca_dev->dev,
usb_rcvctrlpipe(gspca_dev->dev, 0),
USB_REQ_GET_STATUS,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
4, 0, gspca_dev->usb_buf, 4, 500);
if (rc != 4) {
Annotation
- Immediate include surface: `gspca.h`, `sn9c2028.h`.
- Detected declarations: `struct sd`, `struct init_command`, `function sn9c2028_command`, `function sn9c2028_read1`, `function sn9c2028_read4`, `function sn9c2028_long_command`, `function sn9c2028_short_command`, `function sd_config`, `function sd_init`, `function run_start_commands`.
- 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.