drivers/media/test-drivers/vivid/vivid-sdr-cap.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vivid/vivid-sdr-cap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/vivid/vivid-sdr-cap.c- Extension
.c- Size
- 15710 bytes
- Lines
- 583
- 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/errno.hlinux/kernel.hlinux/delay.hlinux/kthread.hlinux/freezer.hlinux/math64.hlinux/videodev2.hlinux/v4l2-dv-timings.hmedia/v4l2-common.hmedia/v4l2-event.hmedia/v4l2-dv-timings.hlinux/fixp-arith.hlinux/jiffies.hvivid-core.hvivid-ctrls.hvivid-sdr-cap.h
Detected Declarations
struct vivid_formatfunction vivid_thread_sdr_cap_tickfunction vivid_thread_sdr_capfunction sdr_cap_queue_setupfunction sdr_cap_buf_preparefunction sdr_cap_buf_queuefunction sdr_cap_start_streamingfunction list_for_each_entry_safefunction sdr_cap_stop_streamingfunction sdr_cap_buf_request_completefunction vivid_sdr_enum_freq_bandsfunction vivid_sdr_g_frequencyfunction vivid_sdr_s_frequencyfunction vivid_sdr_g_tunerfunction vivid_sdr_s_tunerfunction vidioc_enum_fmt_sdr_capfunction vidioc_g_fmt_sdr_capfunction vidioc_s_fmt_sdr_capfunction vidioc_try_fmt_sdr_capfunction vivid_sdr_cap_process
Annotated Snippet
struct vivid_format {
u32 pixelformat;
u32 buffersize;
};
/* format descriptions for capture and preview */
static const struct vivid_format formats[] = {
{
.pixelformat = V4L2_SDR_FMT_CU8,
.buffersize = SDR_CAP_SAMPLES_PER_BUF * 2,
}, {
.pixelformat = V4L2_SDR_FMT_CS8,
.buffersize = SDR_CAP_SAMPLES_PER_BUF * 2,
},
};
static const struct v4l2_frequency_band bands_adc[] = {
{
.tuner = 0,
.type = V4L2_TUNER_ADC,
.index = 0,
.capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
.rangelow = 300000,
.rangehigh = 300000,
},
{
.tuner = 0,
.type = V4L2_TUNER_ADC,
.index = 1,
.capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
.rangelow = 900001,
.rangehigh = 2800000,
},
{
.tuner = 0,
.type = V4L2_TUNER_ADC,
.index = 2,
.capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
.rangelow = 3200000,
.rangehigh = 3200000,
},
};
/* ADC band midpoints */
#define BAND_ADC_0 ((bands_adc[0].rangehigh + bands_adc[1].rangelow) / 2)
#define BAND_ADC_1 ((bands_adc[1].rangehigh + bands_adc[2].rangelow) / 2)
static const struct v4l2_frequency_band bands_fm[] = {
{
.tuner = 1,
.type = V4L2_TUNER_RF,
.index = 0,
.capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
.rangelow = 50000000,
.rangehigh = 2000000000,
},
};
static void vivid_thread_sdr_cap_tick(struct vivid_dev *dev)
{
struct vivid_buffer *sdr_cap_buf = NULL;
dprintk(dev, 1, "SDR Capture Thread Tick\n");
/* Drop a certain percentage of buffers. */
if (dev->perc_dropped_buffers &&
get_random_u32_below(100) < dev->perc_dropped_buffers)
return;
spin_lock(&dev->slock);
if (!list_empty(&dev->sdr_cap_active)) {
sdr_cap_buf = list_entry(dev->sdr_cap_active.next,
struct vivid_buffer, list);
list_del(&sdr_cap_buf->list);
}
spin_unlock(&dev->slock);
if (sdr_cap_buf) {
sdr_cap_buf->vb.sequence = dev->sdr_cap_with_seq_wrap_count;
v4l2_ctrl_request_setup(sdr_cap_buf->vb.vb2_buf.req_obj.req,
&dev->ctrl_hdl_sdr_cap);
v4l2_ctrl_request_complete(sdr_cap_buf->vb.vb2_buf.req_obj.req,
&dev->ctrl_hdl_sdr_cap);
vivid_sdr_cap_process(dev, sdr_cap_buf);
sdr_cap_buf->vb.vb2_buf.timestamp =
ktime_get_ns() + dev->time_wrap_offset;
vb2_buffer_done(&sdr_cap_buf->vb.vb2_buf, dev->dqbuf_error ?
VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
dev->dqbuf_error = false;
}
Annotation
- Immediate include surface: `linux/errno.h`, `linux/kernel.h`, `linux/delay.h`, `linux/kthread.h`, `linux/freezer.h`, `linux/math64.h`, `linux/videodev2.h`, `linux/v4l2-dv-timings.h`.
- Detected declarations: `struct vivid_format`, `function vivid_thread_sdr_cap_tick`, `function vivid_thread_sdr_cap`, `function sdr_cap_queue_setup`, `function sdr_cap_buf_prepare`, `function sdr_cap_buf_queue`, `function sdr_cap_start_streaming`, `function list_for_each_entry_safe`, `function sdr_cap_stop_streaming`, `function sdr_cap_buf_request_complete`.
- 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.