drivers/media/usb/gspca/mars.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/mars.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/mars.c- Extension
.c- Size
- 10847 bytes
- Lines
- 428
- 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_wfunction mi_wfunction setbrightnessfunction setcolorsfunction setgammafunction setsharpnessfunction setilluminatorsfunction mars_s_ctrlfunction sd_init_controlsfunction sd_configfunction sd_initfunction sd_startfunction sd_stopNfunction sd_probe
Annotated Snippet
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
struct v4l2_ctrl *brightness;
struct v4l2_ctrl *saturation;
struct v4l2_ctrl *sharpness;
struct v4l2_ctrl *gamma;
struct { /* illuminator control cluster */
struct v4l2_ctrl *illum_top;
struct v4l2_ctrl *illum_bottom;
};
u8 jpeg_hdr[JPEG_HDR_SZ];
};
/* V4L2 controls supported by the driver */
static void setbrightness(struct gspca_dev *gspca_dev, s32 val);
static void setcolors(struct gspca_dev *gspca_dev, s32 val);
static void setgamma(struct gspca_dev *gspca_dev, s32 val);
static void setsharpness(struct gspca_dev *gspca_dev, s32 val);
static const struct v4l2_pix_format vga_mode[] = {
{320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
.bytesperline = 320,
.sizeimage = 320 * 240 * 3 / 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},
};
static const __u8 mi_data[0x20] = {
/* 01 02 03 04 05 06 07 08 */
0x48, 0x22, 0x01, 0x47, 0x10, 0x00, 0x00, 0x00,
/* 09 0a 0b 0c 0d 0e 0f 10 */
0x00, 0x01, 0x30, 0x01, 0x30, 0x01, 0x30, 0x01,
/* 11 12 13 14 15 16 17 18 */
0x30, 0x00, 0x04, 0x00, 0x06, 0x01, 0xe2, 0x02,
/* 19 1a 1b 1c 1d 1e 1f 20 */
0x82, 0x00, 0x20, 0x17, 0x80, 0x08, 0x0c, 0x00
};
/* write <len> bytes from gspca_dev->usb_buf */
static void reg_w(struct gspca_dev *gspca_dev,
int len)
{
int alen, ret;
if (gspca_dev->usb_err < 0)
return;
ret = usb_bulk_msg(gspca_dev->dev,
usb_sndbulkpipe(gspca_dev->dev, 4),
gspca_dev->usb_buf,
len,
&alen,
500); /* timeout in milliseconds */
if (ret < 0) {
pr_err("reg write [%02x] error %d\n",
gspca_dev->usb_buf[0], ret);
gspca_dev->usb_err = ret;
}
}
static void mi_w(struct gspca_dev *gspca_dev,
u8 addr,
u8 value)
{
gspca_dev->usb_buf[0] = 0x1f;
gspca_dev->usb_buf[1] = 0; /* control byte */
gspca_dev->usb_buf[2] = addr;
gspca_dev->usb_buf[3] = value;
reg_w(gspca_dev, 4);
}
static void setbrightness(struct gspca_dev *gspca_dev, s32 val)
{
gspca_dev->usb_buf[0] = 0x61;
gspca_dev->usb_buf[1] = val;
reg_w(gspca_dev, 2);
}
static void setcolors(struct gspca_dev *gspca_dev, s32 val)
{
gspca_dev->usb_buf[0] = 0x5f;
gspca_dev->usb_buf[1] = val << 3;
gspca_dev->usb_buf[2] = ((val >> 2) & 0xf8) | 0x04;
Annotation
- Immediate include surface: `gspca.h`, `jpeg.h`.
- Detected declarations: `struct sd`, `function reg_w`, `function mi_w`, `function setbrightness`, `function setcolors`, `function setgamma`, `function setsharpness`, `function setilluminators`, `function mars_s_ctrl`, `function sd_init_controls`.
- 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.