drivers/media/dvb-core/dmxdev.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-core/dmxdev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-core/dmxdev.c- Extension
.c- Size
- 36046 bytes
- Lines
- 1475
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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
linux/sched.hlinux/spinlock.hlinux/slab.hlinux/vmalloc.hlinux/module.hlinux/poll.hlinux/ioctl.hlinux/wait.hlinux/uaccess.hmedia/dmxdev.hmedia/dvb_vb2.h
Detected Declarations
function dvb_dmxdev_buffer_writefunction dvb_dmxdev_buffer_readfunction dvb_dvr_openfunction dvb_dvr_releasefunction dvb_dvr_writefunction dvb_dvr_readfunction dvb_dvr_set_buffer_sizefunction dvb_dmxdev_filter_state_setfunction dvb_dmxdev_set_buffer_sizefunction dvb_dmxdev_filter_timeoutfunction dvb_dmxdev_filter_timerfunction dvb_dmxdev_section_callbackfunction dvb_dmxdev_ts_callbackfunction dvb_dmxdev_feed_stopfunction dvb_dmxdev_feed_startfunction list_for_each_entryfunction dvb_dmxdev_feed_restartfunction dvb_dmxdev_filter_stopfunction list_for_each_entryfunction dvb_dmxdev_delete_pidsfunction dvb_dmxdev_filter_resetfunction dvb_dmxdev_start_feedfunction dvb_dmxdev_filter_startfunction list_for_each_entryfunction dvb_demux_openfunction dvb_dmxdev_filter_freefunction invert_modefunction dvb_dmxdev_add_pidfunction dvb_dmxdev_remove_pidfunction list_for_each_entry_safefunction dvb_dmxdev_filter_setfunction dvb_dmxdev_pes_filter_setfunction dvb_dmxdev_read_secfunction dvb_demux_readfunction dvb_demux_do_ioctlfunction dvb_demux_ioctlfunction dvb_demux_pollfunction dvb_demux_mmapfunction dvb_demux_releasefunction dvb_dvr_do_ioctlfunction dvb_dvr_ioctlfunction dvb_dvr_pollfunction dvb_dvr_mmapfunction dvb_dmxdev_initfunction dvb_dmxdev_releaseexport dvb_dmxdev_initexport dvb_dmxdev_release
Annotated Snippet
static const struct file_operations dvb_demux_fops = {
.owner = THIS_MODULE,
.read = dvb_demux_read,
.unlocked_ioctl = dvb_demux_ioctl,
.compat_ioctl = dvb_demux_ioctl,
.open = dvb_demux_open,
.release = dvb_demux_release,
.poll = dvb_demux_poll,
.llseek = default_llseek,
#ifdef CONFIG_DVB_MMAP
.mmap = dvb_demux_mmap,
#endif
};
static const struct dvb_device dvbdev_demux = {
.priv = NULL,
.users = 1,
.writers = 1,
#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
.name = "dvb-demux",
#endif
.fops = &dvb_demux_fops
};
static int dvb_dvr_do_ioctl(struct file *file,
unsigned int cmd, void *parg)
{
struct dvb_device *dvbdev = file->private_data;
struct dmxdev *dmxdev = dvbdev->priv;
unsigned long arg = (unsigned long)parg;
int ret;
if (mutex_lock_interruptible(&dmxdev->mutex))
return -ERESTARTSYS;
switch (cmd) {
case DMX_SET_BUFFER_SIZE:
ret = dvb_dvr_set_buffer_size(dmxdev, arg);
break;
#ifdef CONFIG_DVB_MMAP
case DMX_REQBUFS:
ret = dvb_vb2_reqbufs(&dmxdev->dvr_vb2_ctx, parg);
break;
case DMX_QUERYBUF:
ret = dvb_vb2_querybuf(&dmxdev->dvr_vb2_ctx, parg);
break;
case DMX_EXPBUF:
ret = dvb_vb2_expbuf(&dmxdev->dvr_vb2_ctx, parg);
break;
case DMX_QBUF:
ret = dvb_vb2_qbuf(&dmxdev->dvr_vb2_ctx, parg);
if (ret == 0 && !dvb_vb2_is_streaming(&dmxdev->dvr_vb2_ctx))
ret = dvb_vb2_stream_on(&dmxdev->dvr_vb2_ctx);
break;
case DMX_DQBUF:
ret = dvb_vb2_dqbuf(&dmxdev->dvr_vb2_ctx, parg);
break;
#endif
default:
ret = -ENOTTY;
break;
}
mutex_unlock(&dmxdev->mutex);
return ret;
}
static long dvb_dvr_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
return dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);
}
static __poll_t dvb_dvr_poll(struct file *file, poll_table *wait)
{
struct dvb_device *dvbdev = file->private_data;
struct dmxdev *dmxdev = dvbdev->priv;
__poll_t mask = 0;
dprintk("%s\n", __func__);
poll_wait(file, &dmxdev->dvr_buffer.queue, wait);
if (dmxdev->exit)
return EPOLLERR;
if (dvb_vb2_is_streaming(&dmxdev->dvr_vb2_ctx))
Annotation
- Immediate include surface: `linux/sched.h`, `linux/spinlock.h`, `linux/slab.h`, `linux/vmalloc.h`, `linux/module.h`, `linux/poll.h`, `linux/ioctl.h`, `linux/wait.h`.
- Detected declarations: `function dvb_dmxdev_buffer_write`, `function dvb_dmxdev_buffer_read`, `function dvb_dvr_open`, `function dvb_dvr_release`, `function dvb_dvr_write`, `function dvb_dvr_read`, `function dvb_dvr_set_buffer_size`, `function dvb_dmxdev_filter_state_set`, `function dvb_dmxdev_set_buffer_size`, `function dvb_dmxdev_filter_timeout`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: pattern 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.