drivers/media/usb/msi2500/msi2500.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/msi2500/msi2500.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/msi2500/msi2500.c- Extension
.c- Size
- 36926 bytes
- Lines
- 1325
- 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/slab.hasm/div64.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/v4l2-ctrls.hmedia/v4l2-event.hlinux/usb.hmedia/videobuf2-v4l2.hmedia/videobuf2-vmalloc.hlinux/spi/spi.h
Detected Declarations
struct msi2500_formatstruct msi2500_frame_bufstruct msi2500_devfunction msi2500_convert_streamfunction pipefunction msi2500_iso_stopfunction msi2500_iso_freefunction msi2500_isoc_cleanupfunction msi2500_isoc_initfunction msi2500_cleanup_queued_bufsfunction msi2500_disconnectfunction msi2500_querycapfunction msi2500_queue_setupfunction msi2500_buf_queuefunction msi2500_ctrl_msgfunction msi2500_set_usb_adcfunction msi2500_start_streamingfunction msi2500_stop_streamingfunction msi2500_enum_fmt_sdr_capfunction msi2500_g_fmt_sdr_capfunction msi2500_s_fmt_sdr_capfunction msi2500_try_fmt_sdr_capfunction msi2500_s_tunerfunction msi2500_g_tunerfunction msi2500_g_frequencyfunction msi2500_s_frequencyfunction msi2500_enum_freq_bandsfunction msi2500_video_releasefunction msi2500_transfer_one_messagefunction list_for_each_entryfunction msi2500_probe
Annotated Snippet
struct msi2500_format {
u32 pixelformat;
u32 buffersize;
};
/* format descriptions for capture and preview */
static struct msi2500_format formats[] = {
{
.pixelformat = V4L2_SDR_FMT_CS8,
.buffersize = 3 * 1008,
#if 0
}, {
.pixelformat = MSI2500_PIX_FMT_SDR_MSI2500_384,
}, {
.pixelformat = MSI2500_PIX_FMT_SDR_S12,
#endif
}, {
.pixelformat = V4L2_SDR_FMT_CS14LE,
.buffersize = 3 * 1008,
}, {
.pixelformat = V4L2_SDR_FMT_CU8,
.buffersize = 3 * 1008,
}, {
.pixelformat = V4L2_SDR_FMT_CU16LE,
.buffersize = 3 * 1008,
},
};
static const unsigned int NUM_FORMATS = ARRAY_SIZE(formats);
/* intermediate buffers with raw data from the USB device */
struct msi2500_frame_buf {
/* common v4l buffer stuff -- must be first */
struct vb2_v4l2_buffer vb;
struct list_head list;
};
struct msi2500_dev {
struct device *dev;
struct video_device vdev;
struct v4l2_device v4l2_dev;
struct v4l2_subdev *v4l2_subdev;
struct spi_controller *ctlr;
/* videobuf2 queue and queued buffers list */
struct vb2_queue vb_queue;
struct list_head queued_bufs;
spinlock_t queued_bufs_lock; /* Protects queued_bufs */
/* Note if taking both locks v4l2_lock must always be locked first! */
struct mutex v4l2_lock; /* Protects everything else */
struct mutex vb_queue_lock; /* Protects vb_queue and capt_file */
/* Pointer to our usb_device, will be NULL after unplug */
struct usb_device *udev; /* Both mutexes most be hold when setting! */
unsigned int f_adc;
u32 pixelformat;
u32 buffersize;
unsigned int num_formats;
unsigned int isoc_errors; /* number of contiguous ISOC errors */
unsigned int vb_full; /* vb is full and packets dropped */
struct urb *urbs[MAX_ISO_BUFS];
/* Controls */
struct v4l2_ctrl_handler hdl;
u32 next_sample; /* for track lost packets */
u32 sample; /* for sample rate calc */
unsigned long jiffies_next;
};
/* Private functions */
static struct msi2500_frame_buf *msi2500_get_next_fill_buf(
struct msi2500_dev *dev)
{
unsigned long flags;
struct msi2500_frame_buf *buf = NULL;
spin_lock_irqsave(&dev->queued_bufs_lock, flags);
if (list_empty(&dev->queued_bufs))
goto leave;
buf = list_entry(dev->queued_bufs.next, struct msi2500_frame_buf, list);
list_del(&buf->list);
leave:
spin_unlock_irqrestore(&dev->queued_bufs_lock, flags);
return buf;
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `asm/div64.h`, `media/v4l2-device.h`, `media/v4l2-ioctl.h`, `media/v4l2-ctrls.h`, `media/v4l2-event.h`, `linux/usb.h`.
- Detected declarations: `struct msi2500_format`, `struct msi2500_frame_buf`, `struct msi2500_dev`, `function msi2500_convert_stream`, `function pipe`, `function msi2500_iso_stop`, `function msi2500_iso_free`, `function msi2500_isoc_cleanup`, `function msi2500_isoc_init`, `function msi2500_cleanup_queued_bufs`.
- 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.