drivers/media/usb/gspca/m5602/m5602_ov7660.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/m5602/m5602_ov7660.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/m5602/m5602_ov7660.c- Extension
.c- Size
- 12442 bytes
- Lines
- 469
- 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
m5602_ov7660.h
Detected Declarations
function ov7660_probefunction ov7660_initfunction ov7660_init_controlsfunction ov7660_startfunction ov7660_stopfunction ov7660_disconnectfunction ov7660_set_gainfunction ov7660_set_auto_white_balancefunction ov7660_set_auto_gainfunction ov7660_set_auto_exposurefunction ov7660_set_hvflipfunction ov7660_s_ctrlfunction ov7660_dump_registers
Annotated Snippet
if (force_sensor == OV7660_SENSOR) {
pr_info("Forcing an %s sensor\n", ov7660.name);
goto sensor_found;
}
/* If we want to force another sensor,
don't try to probe this one */
return -ENODEV;
}
/* Do the preinit */
for (i = 0; i < ARRAY_SIZE(preinit_ov7660) && !err; i++) {
u8 data[2];
if (preinit_ov7660[i][0] == BRIDGE) {
err = m5602_write_bridge(sd,
preinit_ov7660[i][1],
preinit_ov7660[i][2]);
} else {
data[0] = preinit_ov7660[i][2];
err = m5602_write_sensor(sd,
preinit_ov7660[i][1], data, 1);
}
}
if (err < 0)
return err;
if (m5602_read_sensor(sd, OV7660_PID, &prod_id, 1))
return -ENODEV;
if (m5602_read_sensor(sd, OV7660_VER, &ver_id, 1))
return -ENODEV;
pr_info("Sensor reported 0x%x%x\n", prod_id, ver_id);
if ((prod_id == 0x76) && (ver_id == 0x60)) {
pr_info("Detected a ov7660 sensor\n");
goto sensor_found;
}
return -ENODEV;
sensor_found:
sd->gspca_dev.cam.cam_mode = ov7660_modes;
sd->gspca_dev.cam.nmodes = ARRAY_SIZE(ov7660_modes);
return 0;
}
int ov7660_init(struct sd *sd)
{
int i, err;
/* Init the sensor */
for (i = 0; i < ARRAY_SIZE(init_ov7660); i++) {
u8 data[2];
if (init_ov7660[i][0] == BRIDGE) {
err = m5602_write_bridge(sd,
init_ov7660[i][1],
init_ov7660[i][2]);
} else {
data[0] = init_ov7660[i][2];
err = m5602_write_sensor(sd,
init_ov7660[i][1], data, 1);
}
if (err < 0)
return err;
}
if (dump_sensor)
ov7660_dump_registers(sd);
return 0;
}
int ov7660_init_controls(struct sd *sd)
{
struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler;
sd->gspca_dev.vdev.ctrl_handler = hdl;
v4l2_ctrl_handler_init(hdl, 6);
v4l2_ctrl_new_std(hdl, &ov7660_ctrl_ops, V4L2_CID_AUTO_WHITE_BALANCE,
0, 1, 1, 1);
v4l2_ctrl_new_std_menu(hdl, &ov7660_ctrl_ops,
V4L2_CID_EXPOSURE_AUTO, 1, 0, V4L2_EXPOSURE_AUTO);
sd->autogain = v4l2_ctrl_new_std(hdl, &ov7660_ctrl_ops,
V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
sd->gain = v4l2_ctrl_new_std(hdl, &ov7660_ctrl_ops, V4L2_CID_GAIN, 0,
255, 1, OV7660_DEFAULT_GAIN);
Annotation
- Immediate include surface: `m5602_ov7660.h`.
- Detected declarations: `function ov7660_probe`, `function ov7660_init`, `function ov7660_init_controls`, `function ov7660_start`, `function ov7660_stop`, `function ov7660_disconnect`, `function ov7660_set_gain`, `function ov7660_set_auto_white_balance`, `function ov7660_set_auto_gain`, `function ov7660_set_auto_exposure`.
- 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.