drivers/media/dvb-core/dvb_demux.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-core/dvb_demux.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-core/dvb_demux.c- Extension
.c- Size
- 32472 bytes
- Lines
- 1325
- 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.
- 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/signal.hlinux/spinlock.hlinux/slab.hlinux/vmalloc.hlinux/module.hlinux/poll.hlinux/string.hlinux/crc32.hlinux/uaccess.hasm/div64.hmedia/dvb_demux.h
Detected Declarations
function section_lengthfunction ts_pidfunction payloadfunction dvb_dmx_crc32function dvb_dmx_memcopyfunction dvb_dmx_swfilter_payloadfunction dvb_dmx_swfilter_sectionfilterfunction dvb_dmx_swfilter_section_feedfunction dvb_dmx_swfilter_section_newfunction dvb_dmx_swfilter_section_copy_dumpfunction dvb_dmx_swfilter_section_packetfunction dvb_dmx_swfilter_packet_typefunction dvb_dmx_swfilter_packetfunction list_for_each_entryfunction dvb_dmx_swfilter_packetsfunction find_next_packetfunction _dvb_dmx_swfilterfunction dvb_dmx_swfilterfunction dvb_dmx_swfilter_204function dvb_dmx_swfilter_rawfunction dvb_demux_feed_findfunction dvb_demux_feed_addfunction dvb_demux_feed_delfunction dmx_ts_feed_setfunction dmx_ts_feed_start_filteringfunction dmx_ts_feed_stop_filteringfunction dvbdmx_allocate_ts_feedfunction dvbdmx_release_ts_feedfunction dmx_section_feed_allocate_filterfunction dmx_section_feed_setfunction prepare_secfiltersfunction dmx_section_feed_start_filteringfunction dmx_section_feed_stop_filteringfunction dmx_section_feed_release_filterfunction dvbdmx_allocate_section_feedfunction dvbdmx_release_section_feedfunction dvbdmx_openfunction dvbdmx_closefunction dvbdmx_writefunction dvbdmx_add_frontendfunction dvbdmx_remove_frontendfunction list_for_each_safefunction dvbdmx_connect_frontendfunction dvbdmx_disconnect_frontendfunction dvbdmx_get_pes_pidsfunction dvb_dmx_initfunction dvb_dmx_releaseexport dvb_dmx_swfilter_packets
Annotated Snippet
if (sec->secbuf[0] != 0xff || sec->secbuf[n - 1] != 0xff) {
set_buf_flags(feed,
DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED);
dprintk_sect_loss("section ts padding loss: %d/%d\n",
n, sec->tsfeedp);
dprintk_sect_loss("pad data: %*ph\n", n, sec->secbuf);
}
}
sec->tsfeedp = sec->secbufp = sec->seclen = 0;
sec->secbuf = sec->secbuf_base;
}
/*
* Losless Section Demux 1.4.1 by Emard
* Valsecchi Patrick:
* - middle of section A (no PUSI)
* - end of section A and start of section B
* (with PUSI pointing to the start of the second section)
*
* In this case, without feed->pusi_seen you'll receive a garbage section
* consisting of the end of section A. Basically because tsfeedp
* is incemented and the use=0 condition is not raised
* when the second packet arrives.
*
* Fix:
* when demux is started, let feed->pusi_seen = false to
* prevent initial feeding of garbage from the end of
* previous section. When you for the first time see PUSI=1
* then set feed->pusi_seen = true
*/
static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
const u8 *buf, u8 len)
{
struct dvb_demux *demux = feed->demux;
struct dmx_section_feed *sec = &feed->feed.sec;
u16 limit, seclen;
if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE)
return 0;
if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) {
set_buf_flags(feed, DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED);
dprintk_sect_loss("section buffer full loss: %d/%d\n",
sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE,
DMX_MAX_SECFEED_SIZE);
len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp;
}
if (len <= 0)
return 0;
demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len);
sec->tsfeedp += len;
/*
* Dump all the sections we can find in the data (Emard)
*/
limit = sec->tsfeedp;
if (limit > DMX_MAX_SECFEED_SIZE)
return -1; /* internal error should never happen */
/* to be sure always set secbuf */
sec->secbuf = sec->secbuf_base + sec->secbufp;
while (sec->secbufp + 2 < limit) {
seclen = section_length(sec->secbuf);
if (seclen <= 0 || seclen > DMX_MAX_SECTION_SIZE
|| seclen + sec->secbufp > limit)
return 0;
sec->seclen = seclen;
sec->crc_val = ~0;
/* dump [secbuf .. secbuf+seclen) */
if (feed->pusi_seen) {
dvb_dmx_swfilter_section_feed(feed);
} else {
set_buf_flags(feed,
DMX_BUFFER_FLAG_DISCONTINUITY_DETECTED);
dprintk_sect_loss("pusi not seen, discarding section data\n");
}
sec->secbufp += seclen; /* secbufp and secbuf moving together is */
sec->secbuf += seclen; /* redundant but saves pointer arithmetic */
}
return 0;
}
static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed,
const u8 *buf)
{
Annotation
- Immediate include surface: `linux/sched/signal.h`, `linux/spinlock.h`, `linux/slab.h`, `linux/vmalloc.h`, `linux/module.h`, `linux/poll.h`, `linux/string.h`, `linux/crc32.h`.
- Detected declarations: `function section_length`, `function ts_pid`, `function payload`, `function dvb_dmx_crc32`, `function dvb_dmx_memcopy`, `function dvb_dmx_swfilter_payload`, `function dvb_dmx_swfilter_sectionfilter`, `function dvb_dmx_swfilter_section_feed`, `function dvb_dmx_swfilter_section_new`, `function dvb_dmx_swfilter_section_copy_dump`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.