drivers/media/usb/gspca/m5602/m5602_po1030.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/m5602/m5602_po1030.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/m5602/m5602_po1030.c- Extension
.c- Size
- 16024 bytes
- Lines
- 624
- 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_po1030.h
Detected Declarations
function po1030_probefunction po1030_initfunction po1030_init_controlsfunction po1030_startfunction po1030_set_exposurefunction po1030_set_gainfunction po1030_set_hvflipfunction po1030_set_red_balancefunction po1030_set_blue_balancefunction po1030_set_green_balancefunction po1030_set_auto_white_balancefunction po1030_set_auto_exposurefunction po1030_disconnectfunction po1030_s_ctrlfunction po1030_dump_registers
Annotated Snippet
if (force_sensor == PO1030_SENSOR) {
pr_info("Forcing a %s sensor\n", po1030.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 po1030 sensor\n");
/* Run the pre-init to actually probe the unit */
for (i = 0; i < ARRAY_SIZE(preinit_po1030); i++) {
u8 data = preinit_po1030[i][2];
if (preinit_po1030[i][0] == SENSOR)
err = m5602_write_sensor(sd, preinit_po1030[i][1],
&data, 1);
else
err = m5602_write_bridge(sd, preinit_po1030[i][1],
data);
if (err < 0)
return err;
}
if (m5602_read_sensor(sd, PO1030_DEVID_H, &dev_id_h, 1))
return -ENODEV;
if (dev_id_h == 0x30) {
pr_info("Detected a po1030 sensor\n");
goto sensor_found;
}
return -ENODEV;
sensor_found:
sd->gspca_dev.cam.cam_mode = po1030_modes;
sd->gspca_dev.cam.nmodes = ARRAY_SIZE(po1030_modes);
return 0;
}
int po1030_init(struct sd *sd)
{
int i, err = 0;
/* Init the sensor */
for (i = 0; i < ARRAY_SIZE(init_po1030) && !err; i++) {
u8 data[2] = {0x00, 0x00};
switch (init_po1030[i][0]) {
case BRIDGE:
err = m5602_write_bridge(sd,
init_po1030[i][1],
init_po1030[i][2]);
break;
case SENSOR:
data[0] = init_po1030[i][2];
err = m5602_write_sensor(sd,
init_po1030[i][1], data, 1);
break;
default:
pr_info("Invalid stream command, exiting init\n");
return -EINVAL;
}
}
if (err < 0)
return err;
if (dump_sensor)
po1030_dump_registers(sd);
return 0;
}
int po1030_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, 9);
sd->auto_white_bal = v4l2_ctrl_new_std(hdl, &po1030_ctrl_ops,
V4L2_CID_AUTO_WHITE_BALANCE,
0, 1, 1, 0);
sd->green_bal = v4l2_ctrl_new_custom(hdl, &po1030_greenbal_cfg, NULL);
sd->red_bal = v4l2_ctrl_new_std(hdl, &po1030_ctrl_ops,
V4L2_CID_RED_BALANCE, 0, 255, 1,
PO1030_RED_GAIN_DEFAULT);
sd->blue_bal = v4l2_ctrl_new_std(hdl, &po1030_ctrl_ops,
Annotation
- Immediate include surface: `m5602_po1030.h`.
- Detected declarations: `function po1030_probe`, `function po1030_init`, `function po1030_init_controls`, `function po1030_start`, `function po1030_set_exposure`, `function po1030_set_gain`, `function po1030_set_hvflip`, `function po1030_set_red_balance`, `function po1030_set_blue_balance`, `function po1030_set_green_balance`.
- 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.