drivers/media/usb/gspca/mr97310a.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/mr97310a.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/mr97310a.c- Extension
.c- Size
- 30015 bytes
- Lines
- 1078
- 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.hpac_common.h
Detected Declarations
struct sdstruct sensor_w_datafunction mr_writefunction mr_readfunction sensor_write_regfunction sensor_write_regsfunction sensor_write1function cam_get_response16function zero_the_pointerfunction stream_startfunction stream_stopfunction lcd_stopfunction isoc_enablefunction sd_configfunction sd_initfunction start_cif_camfunction start_vga_camfunction sd_startfunction sd_stopNfunction setbrightnessfunction setexposurefunction setgainfunction setcontrastfunction sd_s_ctrlfunction sd_init_controlsfunction sd_probe
Annotated Snippet
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
struct { /* exposure/min_clockdiv control cluster */
struct v4l2_ctrl *exposure;
struct v4l2_ctrl *min_clockdiv;
};
u8 sof_read;
u8 cam_type; /* 0 is CIF and 1 is VGA */
u8 sensor_type; /* We use 0 and 1 here, too. */
u8 do_lcd_stop;
u8 adj_colors;
};
struct sensor_w_data {
u8 reg;
u8 flags;
u8 data[16];
int len;
};
static void sd_stopN(struct gspca_dev *gspca_dev);
static const struct v4l2_pix_format vga_mode[] = {
{160, 120, V4L2_PIX_FMT_MR97310A, V4L2_FIELD_NONE,
.bytesperline = 160,
.sizeimage = 160 * 120,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 4},
{176, 144, V4L2_PIX_FMT_MR97310A, V4L2_FIELD_NONE,
.bytesperline = 176,
.sizeimage = 176 * 144,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 3},
{320, 240, V4L2_PIX_FMT_MR97310A, V4L2_FIELD_NONE,
.bytesperline = 320,
.sizeimage = 320 * 240,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 2},
{352, 288, V4L2_PIX_FMT_MR97310A, V4L2_FIELD_NONE,
.bytesperline = 352,
.sizeimage = 352 * 288,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 1},
{640, 480, V4L2_PIX_FMT_MR97310A, V4L2_FIELD_NONE,
.bytesperline = 640,
.sizeimage = 640 * 480,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 0},
};
/* the bytes to write are in gspca_dev->usb_buf */
static int mr_write(struct gspca_dev *gspca_dev, int len)
{
int rc;
rc = usb_bulk_msg(gspca_dev->dev,
usb_sndbulkpipe(gspca_dev->dev, 4),
gspca_dev->usb_buf, len, NULL, 500);
if (rc < 0)
pr_err("reg write [%02x] error %d\n",
gspca_dev->usb_buf[0], rc);
return rc;
}
/* the bytes are read into gspca_dev->usb_buf */
static int mr_read(struct gspca_dev *gspca_dev, int len)
{
int rc;
rc = usb_bulk_msg(gspca_dev->dev,
usb_rcvbulkpipe(gspca_dev->dev, 3),
gspca_dev->usb_buf, len, NULL, 500);
if (rc < 0)
pr_err("reg read [%02x] error %d\n",
gspca_dev->usb_buf[0], rc);
return rc;
}
static int sensor_write_reg(struct gspca_dev *gspca_dev, u8 reg, u8 flags,
const u8 *data, int len)
{
gspca_dev->usb_buf[0] = 0x1f;
gspca_dev->usb_buf[1] = flags;
gspca_dev->usb_buf[2] = reg;
memcpy(gspca_dev->usb_buf + 3, data, len);
return mr_write(gspca_dev, len + 3);
}
static int sensor_write_regs(struct gspca_dev *gspca_dev,
Annotation
- Immediate include surface: `gspca.h`, `pac_common.h`.
- Detected declarations: `struct sd`, `struct sensor_w_data`, `function mr_write`, `function mr_read`, `function sensor_write_reg`, `function sensor_write_regs`, `function sensor_write1`, `function cam_get_response16`, `function zero_the_pointer`, `function stream_start`.
- 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.