drivers/media/usb/s2255/s2255drv.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/s2255/s2255drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/s2255/s2255drv.c- Extension
.c- Size
- 67707 bytes
- Lines
- 2375
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
linux/module.hlinux/firmware.hlinux/kernel.hlinux/mutex.hlinux/slab.hlinux/videodev2.hlinux/mm.hlinux/vmalloc.hlinux/usb.hmedia/videobuf2-v4l2.hmedia/videobuf2-vmalloc.hmedia/v4l2-common.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/v4l2-ctrls.hmedia/v4l2-event.h
Detected Declarations
struct s2255_modestruct s2255_frameistruct s2255_bufferistruct s2255_fwstruct s2255_pipeinfostruct s2255_fmtstruct s2255_devstruct s2255_vcstruct s2255_devstruct s2255_fmtstruct s2255_bufferfunction norm_maxwfunction norm_maxhfunction norm_minwfunction norm_minhfunction planar422p_to_yuv_packedfunction s2255_reset_dsppowerfunction s2255_timerfunction s2255_fwchunk_completefunction s2255_got_framefunction Copyrightfunction queue_setupfunction buffer_preparefunction buffer_queuefunction vidioc_querycapfunction vidioc_enum_fmt_vid_capfunction vidioc_g_fmt_vid_capfunction vidioc_try_fmt_vid_capfunction vidioc_s_fmt_vid_capfunction s2255_write_configfunction get_transfer_sizefunction s2255_print_cfgfunction s2255_set_modefunction s2255_cmd_statusfunction start_streamingfunction stop_streamingfunction vidioc_s_stdfunction vidioc_g_stdfunction colorfunction vidioc_g_inputfunction vidioc_s_inputfunction s2255_s_ctrlfunction vidioc_g_jpegcompfunction vidioc_s_jpegcompfunction vidioc_g_parmfunction vidioc_s_parmfunction vidioc_enum_framesizesfunction vidioc_enum_frameintervals
Annotated Snippet
struct s2255_mode {
u32 format; /* input video format (NTSC, PAL) */
u32 scale; /* output video scale */
u32 color; /* output video color format */
u32 fdec; /* frame decimation */
u32 bright; /* brightness */
u32 contrast; /* contrast */
u32 saturation; /* saturation */
u32 hue; /* hue (NTSC only)*/
u32 single; /* capture 1 frame at a time (!=0), continuously (==0)*/
u32 usb_block; /* block size. should be 4096 of DEF_USB_BLOCK */
u32 restart; /* if DSP requires restart */
};
#define S2255_READ_IDLE 0
#define S2255_READ_FRAME 1
/* frame structure */
struct s2255_framei {
unsigned long size;
unsigned long ulState; /* ulState:S2255_READ_IDLE, S2255_READ_FRAME*/
void *lpvbits; /* image data */
unsigned long cur_size; /* current data copied to it */
};
/* image buffer structure */
struct s2255_bufferi {
unsigned long dwFrames; /* number of frames in buffer */
struct s2255_framei frame[SYS_FRAMES]; /* array of FRAME structures */
};
#define DEF_MODEI_NTSC_CONT {FORMAT_NTSC, DEF_SCALE, DEF_COLOR, \
DEF_FDEC, DEF_BRIGHT, DEF_CONTRAST, DEF_SATURATION, \
DEF_HUE, 0, DEF_USB_BLOCK, 0}
/* for firmware loading, fw_state */
#define S2255_FW_NOTLOADED 0
#define S2255_FW_LOADED_DSPWAIT 1
#define S2255_FW_SUCCESS 2
#define S2255_FW_FAILED 3
#define S2255_FW_DISCONNECTING 4
#define S2255_FW_MARKER cpu_to_le32(0x22552f2f)
/* 2255 read states */
#define S2255_READ_IDLE 0
#define S2255_READ_FRAME 1
struct s2255_fw {
int fw_loaded;
int fw_size;
struct urb *fw_urb;
atomic_t fw_state;
void *pfw_data;
wait_queue_head_t wait_fw;
const struct firmware *fw;
};
struct s2255_pipeinfo {
u32 max_transfer_size;
u32 cur_transfer_size;
u8 *transfer_buffer;
u32 state;
void *stream_urb;
void *dev; /* back pointer to s2255_dev struct*/
u32 err_count;
u32 idx;
};
struct s2255_fmt; /*forward declaration */
struct s2255_dev;
/* 2255 video channel */
struct s2255_vc {
struct s2255_dev *dev;
struct video_device vdev;
struct v4l2_ctrl_handler hdl;
struct v4l2_ctrl *jpegqual_ctrl;
int resources;
struct list_head buf_list;
struct s2255_bufferi buffer;
struct s2255_mode mode;
v4l2_std_id std;
/* jpeg compression */
unsigned jpegqual;
/* capture parameters (for high quality mode full size) */
struct v4l2_captureparm cap_parm;
int cur_frame;
int last_frame;
/* allocated image size */
unsigned long req_image_size;
/* received packet size */
Annotation
- Immediate include surface: `linux/module.h`, `linux/firmware.h`, `linux/kernel.h`, `linux/mutex.h`, `linux/slab.h`, `linux/videodev2.h`, `linux/mm.h`, `linux/vmalloc.h`.
- Detected declarations: `struct s2255_mode`, `struct s2255_framei`, `struct s2255_bufferi`, `struct s2255_fw`, `struct s2255_pipeinfo`, `struct s2255_fmt`, `struct s2255_dev`, `struct s2255_vc`, `struct s2255_dev`, `struct s2255_fmt`.
- 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.
- 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.