drivers/media/usb/gspca/m5602/m5602_mt9m111.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/m5602/m5602_mt9m111.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/m5602/m5602_mt9m111.c- Extension
.c- Size
- 16485 bytes
- Lines
- 601
- 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_mt9m111.h
Detected Declarations
function mt9m111_probefunction mt9m111_initfunction mt9m111_init_controlsfunction mt9m111_startfunction mt9m111_disconnectfunction mt9m111_set_hvflipfunction mt9m111_set_auto_white_balancefunction mt9m111_set_gainfunction mt9m111_set_green_balancefunction mt9m111_set_blue_balancefunction mt9m111_set_red_balancefunction mt9m111_s_ctrlfunction mt9m111_dump_registers
Annotated Snippet
if (force_sensor == MT9M111_SENSOR) {
pr_info("Forcing a %s sensor\n", mt9m111.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 mt9m111 sensor\n");
/* Do the preinit */
for (i = 0; i < ARRAY_SIZE(preinit_mt9m111); i++) {
if (preinit_mt9m111[i][0] == BRIDGE) {
err = m5602_write_bridge(sd,
preinit_mt9m111[i][1],
preinit_mt9m111[i][2]);
} else {
data[0] = preinit_mt9m111[i][2];
data[1] = preinit_mt9m111[i][3];
err = m5602_write_sensor(sd,
preinit_mt9m111[i][1], data, 2);
}
if (err < 0)
return err;
}
if (m5602_read_sensor(sd, MT9M111_SC_CHIPVER, data, 2))
return -ENODEV;
if ((data[0] == 0x14) && (data[1] == 0x3a)) {
pr_info("Detected a mt9m111 sensor\n");
goto sensor_found;
}
return -ENODEV;
sensor_found:
sd->gspca_dev.cam.cam_mode = mt9m111_modes;
sd->gspca_dev.cam.nmodes = ARRAY_SIZE(mt9m111_modes);
return 0;
}
int mt9m111_init(struct sd *sd)
{
int i, err = 0;
/* Init the sensor */
for (i = 0; i < ARRAY_SIZE(init_mt9m111) && !err; i++) {
u8 data[2];
if (init_mt9m111[i][0] == BRIDGE) {
err = m5602_write_bridge(sd,
init_mt9m111[i][1],
init_mt9m111[i][2]);
} else {
data[0] = init_mt9m111[i][2];
data[1] = init_mt9m111[i][3];
err = m5602_write_sensor(sd,
init_mt9m111[i][1], data, 2);
}
}
if (dump_sensor)
mt9m111_dump_registers(sd);
return 0;
}
int mt9m111_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, 7);
sd->auto_white_bal = v4l2_ctrl_new_std(hdl, &mt9m111_ctrl_ops,
V4L2_CID_AUTO_WHITE_BALANCE,
0, 1, 1, 0);
sd->green_bal = v4l2_ctrl_new_custom(hdl, &mt9m111_greenbal_cfg, NULL);
sd->red_bal = v4l2_ctrl_new_std(hdl, &mt9m111_ctrl_ops,
V4L2_CID_RED_BALANCE, 0, 0x7ff, 1,
MT9M111_RED_GAIN_DEFAULT);
sd->blue_bal = v4l2_ctrl_new_std(hdl, &mt9m111_ctrl_ops,
V4L2_CID_BLUE_BALANCE, 0, 0x7ff, 1,
MT9M111_BLUE_GAIN_DEFAULT);
v4l2_ctrl_new_std(hdl, &mt9m111_ctrl_ops, V4L2_CID_GAIN, 0,
(INITIAL_MAX_GAIN - 1) * 2 * 2 * 2, 1,
Annotation
- Immediate include surface: `m5602_mt9m111.h`.
- Detected declarations: `function mt9m111_probe`, `function mt9m111_init`, `function mt9m111_init_controls`, `function mt9m111_start`, `function mt9m111_disconnect`, `function mt9m111_set_hvflip`, `function mt9m111_set_auto_white_balance`, `function mt9m111_set_gain`, `function mt9m111_set_green_balance`, `function mt9m111_set_blue_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.