drivers/media/usb/gspca/sonixb.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/gspca/sonixb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/gspca/sonixb.c- Extension
.c- Size
- 44755 bytes
- Lines
- 1470
- 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/input.hgspca.h
Detected Declarations
struct sdstruct sensor_datafunction reg_rfunction reg_wfunction i2c_wfunction i2c_w_vectorfunction setbrightnessfunction setgainfunction setexposurefunction frameratefunction setfreqfunction do_autogainfunction sd_configfunction sd_initfunction sd_s_ctrlfunction sd_init_controlsfunction sd_startfunction Mhzfunction sd_stopNfunction find_soffunction sd_probe
Annotated Snippet
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
struct v4l2_ctrl *brightness;
struct v4l2_ctrl *plfreq;
atomic_t avg_lum;
int prev_avg_lum;
int exposure_knee;
int header_read;
u8 header[12]; /* Header without sof marker */
unsigned char autogain_ignore_frames;
unsigned char frames_to_drop;
__u8 bridge; /* Type of bridge */
#define BRIDGE_101 0
#define BRIDGE_102 0 /* We make no difference between 101 and 102 */
#define BRIDGE_103 1
__u8 sensor; /* Type of image sensor chip */
#define SENSOR_HV7131D 0
#define SENSOR_HV7131R 1
#define SENSOR_OV6650 2
#define SENSOR_OV7630 3
#define SENSOR_PAS106 4
#define SENSOR_PAS202 5
#define SENSOR_TAS5110C 6
#define SENSOR_TAS5110D 7
#define SENSOR_TAS5130CXX 8
__u8 reg11;
};
typedef const __u8 sensor_init_t[8];
struct sensor_data {
const __u8 *bridge_init;
sensor_init_t *sensor_init;
int sensor_init_size;
int flags;
__u8 sensor_addr;
};
/* sensor_data flags */
#define F_SIF 0x01 /* sif or vga */
/* priv field of struct v4l2_pix_format flags (do not use low nibble!) */
#define MODE_RAW 0x10 /* raw bayer mode */
#define MODE_REDUCED_SIF 0x20 /* vga mode (320x240 / 160x120) on sif cam */
#define COMP 0xc7 /* 0x87 //0x07 */
#define COMP1 0xc9 /* 0x89 //0x09 */
#define MCK_INIT 0x63
#define MCK_INIT1 0x20 /*fixme: Bayer - 0x50 for JPEG ??*/
#define SYS_CLK 0x04
#define SENS(bridge, sensor, _flags, _sensor_addr) \
{ \
.bridge_init = bridge, \
.sensor_init = sensor, \
.sensor_init_size = sizeof(sensor), \
.flags = _flags, .sensor_addr = _sensor_addr \
}
/* We calculate the autogain at the end of the transfer of a frame, at this
moment a frame with the old settings is being captured and transmitted. So
if we adjust the gain or exposure we must ignore at least the next frame for
the new settings to come into effect before doing any other adjustments. */
#define AUTOGAIN_IGNORE_FRAMES 1
static const struct v4l2_pix_format vga_mode[] = {
{160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
.bytesperline = 160,
.sizeimage = 160 * 120,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 2 | MODE_RAW},
{160, 120, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE,
.bytesperline = 160,
.sizeimage = 160 * 120 * 5 / 4,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 2},
{320, 240, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE,
.bytesperline = 320,
.sizeimage = 320 * 240 * 5 / 4,
.colorspace = V4L2_COLORSPACE_SRGB,
.priv = 1},
{640, 480, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE,
.bytesperline = 640,
Annotation
- Immediate include surface: `linux/input.h`, `gspca.h`.
- Detected declarations: `struct sd`, `struct sensor_data`, `function reg_r`, `function reg_w`, `function i2c_w`, `function i2c_w_vector`, `function setbrightness`, `function setgain`, `function setexposure`, `function framerate`.
- 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.