drivers/media/usb/gspca/m5602/m5602_s5k4aa.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/m5602/m5602_s5k4aa.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/m5602/m5602_s5k4aa.c- Extension
.c- Size
- 21266 bytes
- Lines
- 760
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
m5602_s5k4aa.h
Detected Declarations
function s5k4aa_probefunction s5k4aa_startfunction s5k4aa_initfunction s5k4aa_init_controlsfunction s5k4aa_set_exposurefunction s5k4aa_set_hvflipfunction s5k4aa_set_gainfunction s5k4aa_set_brightnessfunction s5k4aa_set_noisefunction s5k4aa_s_ctrlfunction s5k4aa_disconnectfunction s5k4aa_dump_registers
Annotated Snippet
if (force_sensor == S5K4AA_SENSOR) {
pr_info("Forcing a %s sensor\n", s5k4aa.name);
goto sensor_found;
}
/* If we want to force another sensor, don't try to probe this
* one */
return -ENODEV;
}
gspca_dbg(gspca_dev, D_PROBE, "Probing for a s5k4aa sensor\n");
/* Preinit the sensor */
for (i = 0; i < ARRAY_SIZE(preinit_s5k4aa) && !err; i++) {
u8 data[2] = {0x00, 0x00};
switch (preinit_s5k4aa[i][0]) {
case BRIDGE:
err = m5602_write_bridge(sd,
preinit_s5k4aa[i][1],
preinit_s5k4aa[i][2]);
break;
case SENSOR:
data[0] = preinit_s5k4aa[i][2];
err = m5602_write_sensor(sd,
preinit_s5k4aa[i][1],
data, 1);
break;
case SENSOR_LONG:
data[0] = preinit_s5k4aa[i][2];
data[1] = preinit_s5k4aa[i][3];
err = m5602_write_sensor(sd,
preinit_s5k4aa[i][1],
data, 2);
break;
default:
pr_info("Invalid stream command, exiting init\n");
return -EINVAL;
}
}
/* Test some registers, but we don't know their exact meaning yet */
if (m5602_read_sensor(sd, 0x00, prod_id, 2))
return -ENODEV;
if (m5602_read_sensor(sd, 0x02, prod_id+2, 2))
return -ENODEV;
if (m5602_read_sensor(sd, 0x04, prod_id+4, 2))
return -ENODEV;
if (memcmp(prod_id, expected_prod_id, sizeof(prod_id)))
return -ENODEV;
else
pr_info("Detected a s5k4aa sensor\n");
sensor_found:
sd->gspca_dev.cam.cam_mode = s5k4aa_modes;
sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k4aa_modes);
return 0;
}
int s5k4aa_start(struct sd *sd)
{
int i, err = 0;
u8 data[2];
struct cam *cam = &sd->gspca_dev.cam;
struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
switch (cam->cam_mode[sd->gspca_dev.curr_mode].width) {
case 1280:
gspca_dbg(gspca_dev, D_CONF, "Configuring camera for SXGA mode\n");
for (i = 0; i < ARRAY_SIZE(SXGA_s5k4aa); i++) {
switch (SXGA_s5k4aa[i][0]) {
case BRIDGE:
err = m5602_write_bridge(sd,
SXGA_s5k4aa[i][1],
SXGA_s5k4aa[i][2]);
break;
case SENSOR:
data[0] = SXGA_s5k4aa[i][2];
err = m5602_write_sensor(sd,
SXGA_s5k4aa[i][1],
data, 1);
break;
case SENSOR_LONG:
data[0] = SXGA_s5k4aa[i][2];
Annotation
- Immediate include surface: `m5602_s5k4aa.h`.
- Detected declarations: `function s5k4aa_probe`, `function s5k4aa_start`, `function s5k4aa_init`, `function s5k4aa_init_controls`, `function s5k4aa_set_exposure`, `function s5k4aa_set_hvflip`, `function s5k4aa_set_gain`, `function s5k4aa_set_brightness`, `function s5k4aa_set_noise`, `function s5k4aa_s_ctrl`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.