drivers/media/usb/gspca/w996Xcf.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/w996Xcf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/w996Xcf.c- Extension
.c- Size
- 18264 bytes
- Lines
- 570
- 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
- No C-style include directives detected by the generator.
Detected Declarations
function w9968cf_write_fsbfunction w9968cf_write_sbfunction w9968cf_read_sbfunction w9968cf_start_transferfunction i2c_adap_fastwrite_byte_datafunction w9968cf_smbus_stopfunction w9968cf_smbus_write_bytefunction w9968cf_smbus_read_bytefunction w9968cf_smbus_write_nackfunction w9968cf_smbus_read_ackfunction w9968cf_i2c_wfunction w9968cf_i2c_rfunction w9968cf_configurefunction w9968cf_initfunction w9968cf_set_crop_windowfunction w9968cf_mode_init_regsfunction compressionfunction w9968cf_stop0
Annotated Snippet
if (sd->freq->val == 1) {
start_cropx = 277;
start_cropy = 37;
} else {
start_cropx = 105;
start_cropy = 37;
}
} else {
start_cropx = 320;
start_cropy = 35;
}
/* Work around to avoid FP arithmetic */
#define SC(x) ((x) << 10)
/* Scaling factors */
fw = SC(sd->gspca_dev.pixfmt.width) / max_width;
fh = SC(sd->gspca_dev.pixfmt.height) / max_height;
cw = (fw >= fh) ? max_width : SC(sd->gspca_dev.pixfmt.width) / fh;
ch = (fw >= fh) ? SC(sd->gspca_dev.pixfmt.height) / fw : max_height;
sd->sensor_width = max_width;
sd->sensor_height = max_height;
x = (max_width - cw) / 2;
y = (max_height - ch) / 2;
reg_w(sd, 0x10, start_cropx + x);
reg_w(sd, 0x11, start_cropy + y);
reg_w(sd, 0x12, start_cropx + x + cw);
reg_w(sd, 0x13, start_cropy + y + ch);
}
static void w9968cf_mode_init_regs(struct sd *sd)
{
int val, vs_polarity, hs_polarity;
w9968cf_set_crop_window(sd);
reg_w(sd, 0x14, sd->gspca_dev.pixfmt.width);
reg_w(sd, 0x15, sd->gspca_dev.pixfmt.height);
/* JPEG width & height */
reg_w(sd, 0x30, sd->gspca_dev.pixfmt.width);
reg_w(sd, 0x31, sd->gspca_dev.pixfmt.height);
/* Y & UV frame buffer strides (in WORD) */
if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat ==
V4L2_PIX_FMT_JPEG) {
reg_w(sd, 0x2c, sd->gspca_dev.pixfmt.width / 2);
reg_w(sd, 0x2d, sd->gspca_dev.pixfmt.width / 4);
} else
reg_w(sd, 0x2c, sd->gspca_dev.pixfmt.width);
reg_w(sd, 0x00, 0xbf17); /* reset everything */
reg_w(sd, 0x00, 0xbf10); /* normal operation */
/* Transfer size in WORDS (for UYVY format only) */
val = sd->gspca_dev.pixfmt.width * sd->gspca_dev.pixfmt.height;
reg_w(sd, 0x3d, val & 0xffff); /* low bits */
reg_w(sd, 0x3e, val >> 16); /* high bits */
if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat ==
V4L2_PIX_FMT_JPEG) {
/* We may get called multiple times (usb isoc bw negotiat.) */
jpeg_define(sd->jpeg_hdr, sd->gspca_dev.pixfmt.height,
sd->gspca_dev.pixfmt.width, 0x22); /* JPEG 420 */
jpeg_set_qual(sd->jpeg_hdr, v4l2_ctrl_g_ctrl(sd->jpegqual));
w9968cf_upload_quantizationtables(sd);
v4l2_ctrl_grab(sd->jpegqual, true);
}
/* Video Capture Control Register */
if (sd->sensor == SEN_OV7620) {
/* Seems to work around a bug in the image sensor */
vs_polarity = 1;
hs_polarity = 1;
} else {
vs_polarity = 1;
hs_polarity = 0;
}
val = (vs_polarity << 12) | (hs_polarity << 11);
/* NOTE: We may not have enough memory to do double buffering while
doing compression (amount of memory differs per model cam).
So we use the second image buffer also as jpeg stream buffer
(see w9968cf_init), and disable double buffering. */
if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat ==
Annotation
- Detected declarations: `function w9968cf_write_fsb`, `function w9968cf_write_sb`, `function w9968cf_read_sb`, `function w9968cf_start_transfer`, `function i2c_adap_fastwrite_byte_data`, `function w9968cf_smbus_stop`, `function w9968cf_smbus_write_byte`, `function w9968cf_smbus_read_byte`, `function w9968cf_smbus_write_nack`, `function w9968cf_smbus_read_ack`.
- 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.