drivers/media/usb/gspca/stk1135.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/stk1135.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/stk1135.c- Extension
.c- Size
- 19551 bytes
- Lines
- 677
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
gspca.hstk1135.h
Detected Declarations
struct sdstruct sensor_valfunction reg_rfunction reg_wfunction reg_w_maskfunction sd_configfunction stk1135_serial_wait_readyfunction sensor_read_8function sensor_read_16function sensor_write_8function sensor_write_16function sensor_set_pagefunction sensor_readfunction sensor_writefunction sensor_write_maskfunction stk1135_configure_mt9m112function stk1135_configure_clockfunction stk1135_camera_disablefunction sd_initfunction sd_startfunction sd_stopNfunction sethflipfunction setvflipfunction stk1135_dq_callbackfunction sd_s_ctrlfunction sd_init_controlsfunction stk1135_try_fmtfunction stk1135_enum_framesizesfunction sd_probe
Annotated Snippet
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
u8 pkt_seq;
u8 sensor_page;
bool flip_status;
u8 flip_debounce;
struct v4l2_ctrl *hflip;
struct v4l2_ctrl *vflip;
};
static const struct v4l2_pix_format stk1135_modes[] = {
/* default mode (this driver supports variable resolution) */
{640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
.bytesperline = 640,
.sizeimage = 640 * 480,
.colorspace = V4L2_COLORSPACE_SRGB},
};
/* -- read a register -- */
static u8 reg_r(struct gspca_dev *gspca_dev, u16 index)
{
struct usb_device *dev = gspca_dev->dev;
int ret;
if (gspca_dev->usb_err < 0)
return 0;
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
0x00,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0x00,
index,
gspca_dev->usb_buf, 1,
500);
gspca_dbg(gspca_dev, D_USBI, "reg_r 0x%x=0x%02x\n",
index, gspca_dev->usb_buf[0]);
if (ret < 0) {
pr_err("reg_r 0x%x err %d\n", index, ret);
gspca_dev->usb_err = ret;
return 0;
}
return gspca_dev->usb_buf[0];
}
/* -- write a register -- */
static void reg_w(struct gspca_dev *gspca_dev, u16 index, u8 val)
{
int ret;
struct usb_device *dev = gspca_dev->dev;
if (gspca_dev->usb_err < 0)
return;
ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
0x01,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
val,
index,
NULL,
0,
500);
gspca_dbg(gspca_dev, D_USBO, "reg_w 0x%x:=0x%02x\n", index, val);
if (ret < 0) {
pr_err("reg_w 0x%x err %d\n", index, ret);
gspca_dev->usb_err = ret;
}
}
static void reg_w_mask(struct gspca_dev *gspca_dev, u16 index, u8 val, u8 mask)
{
val = (reg_r(gspca_dev, index) & ~mask) | (val & mask);
reg_w(gspca_dev, index, val);
}
/* this function is called at probe time */
static int sd_config(struct gspca_dev *gspca_dev,
const struct usb_device_id *id)
{
gspca_dev->cam.cam_mode = stk1135_modes;
gspca_dev->cam.nmodes = ARRAY_SIZE(stk1135_modes);
return 0;
}
static int stk1135_serial_wait_ready(struct gspca_dev *gspca_dev)
{
int i = 0;
u8 val;
Annotation
- Immediate include surface: `gspca.h`, `stk1135.h`.
- Detected declarations: `struct sd`, `struct sensor_val`, `function reg_r`, `function reg_w`, `function reg_w_mask`, `function sd_config`, `function stk1135_serial_wait_ready`, `function sensor_read_8`, `function sensor_read_16`, `function sensor_write_8`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.