drivers/media/dvb-core/dvb_ringbuffer.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-core/dvb_ringbuffer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-core/dvb_ringbuffer.c- Extension
.c- Size
- 10160 bytes
- Lines
- 378
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/kernel.hlinux/module.hlinux/sched.hlinux/string.hlinux/uaccess.hmedia/dvb_ringbuffer.h
Detected Declarations
function dvb_ringbuffer_initfunction dvb_ringbuffer_emptyfunction dvb_ringbuffer_freefunction dvb_ringbuffer_availfunction dvb_ringbuffer_flushfunction dvb_ringbuffer_resetfunction dvb_ringbuffer_flush_spinlock_wakeupfunction dvb_ringbuffer_read_userfunction dvb_ringbuffer_readfunction dvb_ringbuffer_writefunction dvb_ringbuffer_write_userfunction dvb_ringbuffer_pkt_writefunction dvb_ringbuffer_pkt_read_userfunction dvb_ringbuffer_pkt_readfunction dvb_ringbuffer_pkt_disposefunction dvb_ringbuffer_pkt_nextexport dvb_ringbuffer_flushexport dvb_ringbuffer_initexport dvb_ringbuffer_emptyexport dvb_ringbuffer_freeexport dvb_ringbuffer_availexport dvb_ringbuffer_flush_spinlock_wakeupexport dvb_ringbuffer_read_userexport dvb_ringbuffer_readexport dvb_ringbuffer_writeexport dvb_ringbuffer_write_user
Annotated Snippet
if (DVB_RINGBUFFER_PEEK(rbuf, 2) == PKT_DISPOSED) {
pktlen = DVB_RINGBUFFER_PEEK(rbuf, 0) << 8;
pktlen |= DVB_RINGBUFFER_PEEK(rbuf, 1);
DVB_RINGBUFFER_SKIP(rbuf, pktlen + DVB_RINGBUFFER_PKTHDRSIZE);
} else {
// first packet is not disposed, so we stop cleaning now
break;
}
}
}
ssize_t dvb_ringbuffer_pkt_next(struct dvb_ringbuffer *rbuf, size_t idx, size_t *pktlen)
{
int consumed;
int curpktlen;
int curpktstatus;
if (idx == -1) {
idx = rbuf->pread;
} else {
curpktlen = rbuf->data[idx] << 8;
curpktlen |= rbuf->data[(idx + 1) % rbuf->size];
idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size;
}
consumed = (idx - rbuf->pread);
if (consumed < 0)
consumed += rbuf->size;
while ((dvb_ringbuffer_avail(rbuf) - consumed) > DVB_RINGBUFFER_PKTHDRSIZE) {
curpktlen = rbuf->data[idx] << 8;
curpktlen |= rbuf->data[(idx + 1) % rbuf->size];
curpktstatus = rbuf->data[(idx + 2) % rbuf->size];
if (curpktstatus == PKT_READY) {
*pktlen = curpktlen;
return idx;
}
consumed += curpktlen + DVB_RINGBUFFER_PKTHDRSIZE;
idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size;
}
// no packets available
return -1;
}
EXPORT_SYMBOL(dvb_ringbuffer_init);
EXPORT_SYMBOL(dvb_ringbuffer_empty);
EXPORT_SYMBOL(dvb_ringbuffer_free);
EXPORT_SYMBOL(dvb_ringbuffer_avail);
EXPORT_SYMBOL(dvb_ringbuffer_flush_spinlock_wakeup);
EXPORT_SYMBOL(dvb_ringbuffer_read_user);
EXPORT_SYMBOL(dvb_ringbuffer_read);
EXPORT_SYMBOL(dvb_ringbuffer_write);
EXPORT_SYMBOL(dvb_ringbuffer_write_user);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/kernel.h`, `linux/module.h`, `linux/sched.h`, `linux/string.h`, `linux/uaccess.h`, `media/dvb_ringbuffer.h`.
- Detected declarations: `function dvb_ringbuffer_init`, `function dvb_ringbuffer_empty`, `function dvb_ringbuffer_free`, `function dvb_ringbuffer_avail`, `function dvb_ringbuffer_flush`, `function dvb_ringbuffer_reset`, `function dvb_ringbuffer_flush_spinlock_wakeup`, `function dvb_ringbuffer_read_user`, `function dvb_ringbuffer_read`, `function dvb_ringbuffer_write`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.