drivers/media/usb/gspca/m5602/m5602_s5k83a.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/m5602/m5602_s5k83a.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/m5602/m5602_s5k83a.c- Extension
.c- Size
- 15649 bytes
- Lines
- 577
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kthread.hm5602_s5k83a.h
Detected Declarations
function s5k83a_probefunction s5k83a_initfunction s5k83a_init_controlsfunction rotation_thread_functionfunction s5k83a_startfunction s5k83a_stopfunction s5k83a_disconnectfunction s5k83a_set_gainfunction s5k83a_set_brightnessfunction s5k83a_set_exposurefunction s5k83a_set_flip_realfunction s5k83a_set_hvflipfunction s5k83a_s_ctrlfunction s5k83a_set_led_indicationfunction s5k83a_get_rotationfunction s5k83a_dump_registers
Annotated Snippet
if (force_sensor == S5K83A_SENSOR) {
pr_info("Forcing a %s sensor\n", s5k83a.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 s5k83a sensor\n");
/* Preinit the sensor */
for (i = 0; i < ARRAY_SIZE(preinit_s5k83a) && !err; i++) {
u8 data[2] = {preinit_s5k83a[i][2], preinit_s5k83a[i][3]};
if (preinit_s5k83a[i][0] == SENSOR)
err = m5602_write_sensor(sd, preinit_s5k83a[i][1],
data, 2);
else
err = m5602_write_bridge(sd, preinit_s5k83a[i][1],
data[0]);
}
/* We don't know what register (if any) that contain the product id
* Just pick the first addresses that seem to produce the same results
* on multiple machines */
if (m5602_read_sensor(sd, 0x00, &prod_id, 1))
return -ENODEV;
if (m5602_read_sensor(sd, 0x01, &ver_id, 1))
return -ENODEV;
if ((prod_id == 0xff) || (ver_id == 0xff))
return -ENODEV;
else
pr_info("Detected a s5k83a sensor\n");
sensor_found:
sd->gspca_dev.cam.cam_mode = s5k83a_modes;
sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k83a_modes);
/* null the pointer! thread is't running now */
sd->rotation_thread = NULL;
return 0;
}
int s5k83a_init(struct sd *sd)
{
int i, err = 0;
for (i = 0; i < ARRAY_SIZE(init_s5k83a) && !err; i++) {
u8 data[2] = {0x00, 0x00};
switch (init_s5k83a[i][0]) {
case BRIDGE:
err = m5602_write_bridge(sd,
init_s5k83a[i][1],
init_s5k83a[i][2]);
break;
case SENSOR:
data[0] = init_s5k83a[i][2];
err = m5602_write_sensor(sd,
init_s5k83a[i][1], data, 1);
break;
case SENSOR_LONG:
data[0] = init_s5k83a[i][2];
data[1] = init_s5k83a[i][3];
err = m5602_write_sensor(sd,
init_s5k83a[i][1], data, 2);
break;
default:
pr_info("Invalid stream command, exiting init\n");
return -EINVAL;
}
}
if (dump_sensor)
s5k83a_dump_registers(sd);
return err;
}
int s5k83a_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);
Annotation
- Immediate include surface: `linux/kthread.h`, `m5602_s5k83a.h`.
- Detected declarations: `function s5k83a_probe`, `function s5k83a_init`, `function s5k83a_init_controls`, `function rotation_thread_function`, `function s5k83a_start`, `function s5k83a_stop`, `function s5k83a_disconnect`, `function s5k83a_set_gain`, `function s5k83a_set_brightness`, `function s5k83a_set_exposure`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.