drivers/media/dvb-frontends/rtl2832_sdr.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/rtl2832_sdr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/rtl2832_sdr.c- Extension
.c- Size
- 42021 bytes
- Lines
- 1504
- 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.
- 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
rtl2832_sdr.hdvb_usb.hmedia/v4l2-device.hmedia/v4l2-ioctl.hmedia/v4l2-ctrls.hmedia/v4l2-event.hmedia/videobuf2-v4l2.hmedia/videobuf2-vmalloc.hlinux/platform_device.hlinux/jiffies.hlinux/math64.hlinux/regmap.h
Detected Declarations
struct rtl2832_sdr_formatstruct rtl2832_sdr_frame_bufstruct rtl2832_sdr_devfunction rtl2832_sdr_convert_streamfunction rtl2832_sdr_urb_completefunction rtl2832_sdr_kill_urbsfunction rtl2832_sdr_submit_urbsfunction rtl2832_sdr_free_stream_bufsfunction rtl2832_sdr_alloc_stream_bufsfunction rtl2832_sdr_free_urbsfunction rtl2832_sdr_alloc_urbsfunction rtl2832_sdr_cleanup_queued_bufsfunction rtl2832_sdr_querycapfunction rtl2832_sdr_queue_setupfunction rtl2832_sdr_buf_preparefunction rtl2832_sdr_buf_queuefunction rtl2832_sdr_set_adcfunction rtl2832_sdr_unset_adcfunction rtl2832_sdr_set_tuner_freqfunction rtl2832_sdr_set_tunerfunction rtl2832_sdr_unset_tunerfunction rtl2832_sdr_start_streamingfunction rtl2832_sdr_stop_streamingfunction rtl2832_sdr_g_tunerfunction V4L2_SUBDEV_HAS_OPfunction rtl2832_sdr_s_tunerfunction V4L2_SUBDEV_HAS_OPfunction rtl2832_sdr_enum_freq_bandsfunction V4L2_SUBDEV_HAS_OPfunction rtl2832_sdr_g_frequencyfunction V4L2_SUBDEV_HAS_OPfunction rtl2832_sdr_s_frequencyfunction V4L2_SUBDEV_HAS_OPfunction rtl2832_sdr_enum_fmt_sdr_capfunction rtl2832_sdr_g_fmt_sdr_capfunction rtl2832_sdr_s_fmt_sdr_capfunction rtl2832_sdr_try_fmt_sdr_capfunction rtl2832_sdr_s_ctrlfunction rtl2832_sdr_video_releasefunction rtl2832_sdr_probefunction rtl2832_sdr_remove
Annotated Snippet
struct rtl2832_sdr_format {
char *name;
u32 pixelformat;
u32 buffersize;
};
static struct rtl2832_sdr_format formats[] = {
{
.pixelformat = V4L2_SDR_FMT_CU8,
.buffersize = BULK_BUFFER_SIZE,
}, {
.pixelformat = V4L2_SDR_FMT_CU16LE,
.buffersize = BULK_BUFFER_SIZE * 2,
},
};
static const unsigned int NUM_FORMATS = ARRAY_SIZE(formats);
/* intermediate buffers with raw data from the USB device */
struct rtl2832_sdr_frame_buf {
/* common v4l buffer stuff -- must be first */
struct vb2_v4l2_buffer vb;
struct list_head list;
};
struct rtl2832_sdr_dev {
#define POWER_ON 0 /* BIT(0) */
#define URB_BUF 1 /* BIT(1) */
unsigned long flags;
struct platform_device *pdev;
struct regmap *regmap;
struct video_device vdev;
struct v4l2_device v4l2_dev;
struct v4l2_subdev *v4l2_subdev;
/* videobuf2 queue and queued buffers list */
struct vb2_queue vb_queue;
struct list_head queued_bufs;
spinlock_t queued_bufs_lock; /* Protects queued_bufs */
unsigned sequence; /* buffer sequence counter */
/* 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 vb_full; /* vb is full and packets dropped */
struct urb *urb_list[MAX_BULK_BUFS];
int buf_num;
unsigned long buf_size;
u8 *buf_list[MAX_BULK_BUFS];
dma_addr_t dma_addr[MAX_BULK_BUFS];
int urbs_initialized;
int urbs_submitted;
unsigned int f_adc, f_tuner;
u32 pixelformat;
u32 buffersize;
unsigned int num_formats;
/* Controls */
struct v4l2_ctrl_handler hdl;
struct v4l2_ctrl *bandwidth_auto;
struct v4l2_ctrl *bandwidth;
/* for sample rate calc */
unsigned int sample;
unsigned int sample_measured;
unsigned long jiffies_next;
};
/* Private functions */
static struct rtl2832_sdr_frame_buf *rtl2832_sdr_get_next_fill_buf(
struct rtl2832_sdr_dev *dev)
{
unsigned long flags;
struct rtl2832_sdr_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 rtl2832_sdr_frame_buf, list);
list_del(&buf->list);
Annotation
- Immediate include surface: `rtl2832_sdr.h`, `dvb_usb.h`, `media/v4l2-device.h`, `media/v4l2-ioctl.h`, `media/v4l2-ctrls.h`, `media/v4l2-event.h`, `media/videobuf2-v4l2.h`, `media/videobuf2-vmalloc.h`.
- Detected declarations: `struct rtl2832_sdr_format`, `struct rtl2832_sdr_frame_buf`, `struct rtl2832_sdr_dev`, `function rtl2832_sdr_convert_stream`, `function rtl2832_sdr_urb_complete`, `function rtl2832_sdr_kill_urbs`, `function rtl2832_sdr_submit_urbs`, `function rtl2832_sdr_free_stream_bufs`, `function rtl2832_sdr_alloc_stream_bufs`, `function rtl2832_sdr_free_urbs`.
- 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.