drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/stv06xx/stv06xx_hdcs.c- Extension
.c- Size
- 12129 bytes
- Lines
- 533
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stv06xx_hdcs.h
Detected Declarations
struct hdcsenum hdcs_power_statefunction hdcs_reg_write_seqfunction hdcs_set_statefunction hdcs_resetfunction hdcs_set_exposurefunction hdcs_set_gainsfunction hdcs_set_gainfunction hdcs_set_sizefunction hdcs_s_ctrlfunction hdcs_init_controlsfunction hdcs_probe_1x00function hdcs_probe_1020function hdcs_startfunction hdcs_stopfunction hdcs_initfunction hdcs_dump
Annotated Snippet
struct hdcs {
enum hdcs_power_state state;
int w, h;
/* visible area of the sensor array */
struct {
int left, top;
int width, height;
int border;
} array;
struct {
/* Column timing overhead */
u8 cto;
/* Column processing overhead */
u8 cpo;
/* Row sample period constant */
u16 rs;
/* Exposure reset duration */
u16 er;
} exp;
int psmp;
};
static int hdcs_reg_write_seq(struct sd *sd, u8 reg, u8 *vals, u8 len)
{
u8 regs[I2C_MAX_BYTES * 2];
int i;
if (unlikely((len <= 0) || (len >= I2C_MAX_BYTES) ||
(reg + len > 0xff)))
return -EINVAL;
for (i = 0; i < len; i++) {
regs[2 * i] = reg;
regs[2 * i + 1] = vals[i];
/* All addresses are shifted left one bit
* as bit 0 toggles r/w */
reg += 2;
}
return stv06xx_write_sensor_bytes(sd, regs, len);
}
static int hdcs_set_state(struct sd *sd, enum hdcs_power_state state)
{
struct hdcs *hdcs = sd->sensor_priv;
u8 val;
int ret;
if (hdcs->state == state)
return 0;
/* we need to go idle before running or sleeping */
if (hdcs->state != HDCS_STATE_IDLE) {
ret = stv06xx_write_sensor(sd, HDCS_REG_CONTROL(sd), 0);
if (ret)
return ret;
}
hdcs->state = HDCS_STATE_IDLE;
if (state == HDCS_STATE_IDLE)
return 0;
switch (state) {
case HDCS_STATE_SLEEP:
val = HDCS_SLEEP_MODE;
break;
case HDCS_STATE_RUN:
val = HDCS_RUN_ENABLE;
break;
default:
return -EINVAL;
}
ret = stv06xx_write_sensor(sd, HDCS_REG_CONTROL(sd), val);
/* Update the state if the write succeeded */
if (!ret)
hdcs->state = state;
return ret;
}
static int hdcs_reset(struct sd *sd)
{
Annotation
- Immediate include surface: `stv06xx_hdcs.h`.
- Detected declarations: `struct hdcs`, `enum hdcs_power_state`, `function hdcs_reg_write_seq`, `function hdcs_set_state`, `function hdcs_reset`, `function hdcs_set_exposure`, `function hdcs_set_gains`, `function hdcs_set_gain`, `function hdcs_set_size`, `function hdcs_s_ctrl`.
- 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.