drivers/media/usb/gspca/pac207.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/pac207.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/pac207.c- Extension
.c- Size
- 12921 bytes
- Lines
- 476
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/input.hgspca.hpac_common.h
Detected Declarations
struct sdfunction pac207_write_regsfunction pac207_write_regfunction pac207_read_regfunction sd_configfunction sd_initfunction setcontrolfunction sd_s_ctrlfunction sd_init_controlsfunction sd_startfunction sd_stopNfunction pac207_do_auto_gainfunction sd_pkt_scanfunction sd_probe
Annotated Snippet
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
struct v4l2_ctrl *brightness;
u8 mode;
u8 sof_read;
u8 header_read;
u8 autogain_ignore_frames;
atomic_t avg_lum;
};
static const struct v4l2_pix_format sif_mode[] = {
{176, 144, V4L2_PIX_FMT_PAC207, V4L2_FIELD_NONE,
.bytesperline = 176,
.sizeimage = (176 + 2) * 144,
/* uncompressed, add 2 bytes / line for line header */
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 1},
{352, 288, V4L2_PIX_FMT_PAC207, V4L2_FIELD_NONE,
.bytesperline = 352,
/* compressed, but only when needed (not compressed
when the framerate is low) */
.sizeimage = (352 + 2) * 288,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 0},
};
static const __u8 pac207_sensor_init[][8] = {
{0x10, 0x12, 0x0d, 0x12, 0x0c, 0x01, 0x29, 0x84},
{0x49, 0x64, 0x64, 0x64, 0x04, 0x10, 0xf0, 0x30},
{0x00, 0x00, 0x00, 0x70, 0xa0, 0xf8, 0x00, 0x00},
{0x32, 0x00, 0x96, 0x00, 0xa2, 0x02, 0xaf, 0x00},
};
static void pac207_write_regs(struct gspca_dev *gspca_dev, u16 index,
const u8 *buffer, u16 length)
{
struct usb_device *udev = gspca_dev->dev;
int err;
if (gspca_dev->usb_err < 0)
return;
memcpy(gspca_dev->usb_buf, buffer, length);
err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x01,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
0x00, index,
gspca_dev->usb_buf, length, PAC207_CTRL_TIMEOUT);
if (err < 0) {
pr_err("Failed to write registers to index 0x%04X, error %d\n",
index, err);
gspca_dev->usb_err = err;
}
}
static void pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value)
{
struct usb_device *udev = gspca_dev->dev;
int err;
if (gspca_dev->usb_err < 0)
return;
err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
value, index, NULL, 0, PAC207_CTRL_TIMEOUT);
if (err) {
pr_err("Failed to write a register (index 0x%04X, value 0x%02X, error %d)\n",
index, value, err);
gspca_dev->usb_err = err;
}
}
static int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index)
{
struct usb_device *udev = gspca_dev->dev;
int res;
if (gspca_dev->usb_err < 0)
return 0;
res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
0x00, index,
gspca_dev->usb_buf, 1, PAC207_CTRL_TIMEOUT);
if (res < 0) {
pr_err("Failed to read a register (index 0x%04X, error %d)\n",
Annotation
- Immediate include surface: `linux/input.h`, `gspca.h`, `pac_common.h`.
- Detected declarations: `struct sd`, `function pac207_write_regs`, `function pac207_write_reg`, `function pac207_read_reg`, `function sd_config`, `function sd_init`, `function setcontrol`, `function sd_s_ctrl`, `function sd_init_controls`, `function sd_start`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.