drivers/media/pci/saa7164/saa7164-vbi.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/saa7164/saa7164-vbi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/saa7164/saa7164-vbi.c- Extension
.c- Size
- 19655 bytes
- Lines
- 766
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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
saa7164.h
Detected Declarations
function Copyrightfunction saa7164_vbi_buffers_deallocfunction saa7164_vbi_buffers_allocfunction saa7164_vbi_initializefunction vidioc_s_stdfunction vidioc_g_stdfunction vidioc_g_inputfunction vidioc_s_inputfunction vidioc_g_frequencyfunction vidioc_s_frequencyfunction vidioc_querycapfunction saa7164_vbi_stop_portfunction saa7164_vbi_acquire_portfunction saa7164_vbi_pause_portfunction cfg_postfunction list_for_each_safefunction saa7164_vbi_start_streamingfunction saa7164_vbi_fmtfunction fops_openfunction fops_releasefunction fops_readfunction fops_pollfunction saa7164_vbi_registerfunction saa7164_vbi_unregister
Annotated Snippet
if (!buf) {
printk(KERN_ERR "%s() failed (errno = %d), unable to allocate buffer\n",
__func__, result);
result = -ENOMEM;
goto failed;
} else {
mutex_lock(&port->dmaqueue_lock);
list_add_tail(&buf->list, &port->dmaqueue.list);
mutex_unlock(&port->dmaqueue_lock);
}
}
/* Allocate some kernel buffers for copying
* to userpsace.
*/
len = params->numberoflines * params->pitch;
if (vbi_buffers < 16)
vbi_buffers = 16;
if (vbi_buffers > 512)
vbi_buffers = 512;
for (i = 0; i < vbi_buffers; i++) {
ubuf = saa7164_buffer_alloc_user(dev, len);
if (ubuf) {
mutex_lock(&port->dmaqueue_lock);
list_add_tail(&ubuf->list, &port->list_buf_free.list);
mutex_unlock(&port->dmaqueue_lock);
}
}
result = 0;
failed:
return result;
}
static int saa7164_vbi_initialize(struct saa7164_port *port)
{
saa7164_vbi_configure(port);
return 0;
}
/* -- V4L2 --------------------------------------------------------- */
static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id)
{
struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
return saa7164_s_std(fh->port->enc_port, id);
}
static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id)
{
struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
return saa7164_g_std(fh->port->enc_port, id);
}
static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
{
struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
return saa7164_g_input(fh->port->enc_port, i);
}
static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
{
struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
return saa7164_s_input(fh->port->enc_port, i);
}
static int vidioc_g_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
{
struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
return saa7164_g_frequency(fh->port->enc_port, f);
}
static int vidioc_s_frequency(struct file *file, void *priv,
const struct v4l2_frequency *f)
{
struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
int ret = saa7164_s_frequency(fh->port->enc_port, f);
Annotation
- Immediate include surface: `saa7164.h`.
- Detected declarations: `function Copyright`, `function saa7164_vbi_buffers_dealloc`, `function saa7164_vbi_buffers_alloc`, `function saa7164_vbi_initialize`, `function vidioc_s_std`, `function vidioc_g_std`, `function vidioc_g_input`, `function vidioc_s_input`, `function vidioc_g_frequency`, `function vidioc_s_frequency`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.