drivers/media/pci/ngene/ngene-dvb.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/ngene/ngene-dvb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/ngene/ngene-dvb.c- Extension
.c- Size
- 8400 bytes
- Lines
- 341
- 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.
- 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/module.hlinux/init.hlinux/delay.hlinux/slab.hlinux/poll.hlinux/io.hasm/div64.hlinux/pci.hlinux/timer.hlinux/byteorder/generic.hlinux/firmware.hlinux/vmalloc.hngene.h
Detected Declarations
function ts_writefunction ts_readfunction ts_pollfunction swap_bufferfunction tsin_find_offsetfunction tsin_copy_strippedfunction tsin_exchangefunction ngene_start_feedfunction ngene_stop_feedfunction my_dvb_dmx_ts_card_initfunction my_dvb_dmxdev_ts_card_init
Annotated Snippet
static const struct file_operations ci_fops = {
.owner = THIS_MODULE,
.read = ts_read,
.write = ts_write,
.open = dvb_generic_open,
.release = dvb_generic_release,
.poll = ts_poll,
.mmap = NULL,
};
struct dvb_device ngene_dvbdev_ci = {
.priv = NULL,
.readers = 1,
.writers = 1,
.users = 2,
.fops = &ci_fops,
};
/****************************************************************************/
/* DVB functions and API interface ******************************************/
/****************************************************************************/
static void swap_buffer(u32 *p, u32 len)
{
while (len) {
*p = swab32(*p);
p++;
len -= 4;
}
}
/* start of filler packet */
static u8 fill_ts[] = { 0x47, 0x1f, 0xff, 0x10, TS_FILLER };
static int tsin_find_offset(void *buf, u32 len)
{
int i, l;
l = len - sizeof(fill_ts);
if (l <= 0)
return -1;
for (i = 0; i < l; i++) {
if (((char *)buf)[i] == 0x47) {
if (!memcmp(buf + i, fill_ts, sizeof(fill_ts)))
return i % 188;
}
}
return -1;
}
static inline void tsin_copy_stripped(struct ngene *dev, void *buf)
{
if (memcmp(buf, fill_ts, sizeof(fill_ts)) != 0) {
if (dvb_ringbuffer_free(&dev->tsin_rbuf) >= 188) {
dvb_ringbuffer_write(&dev->tsin_rbuf, buf, 188);
wake_up(&dev->tsin_rbuf.queue);
}
}
}
void *tsin_exchange(void *priv, void *buf, u32 len, u32 clock, u32 flags)
{
struct ngene_channel *chan = priv;
struct ngene *dev = chan->dev;
int tsoff;
if (flags & DF_SWAP32)
swap_buffer(buf, len);
if (dev->ci.en && chan->number == 2) {
/* blindly copy buffers if ci_tsfix is disabled */
if (!ci_tsfix) {
while (len >= 188) {
tsin_copy_stripped(dev, buf);
buf += 188;
len -= 188;
}
return NULL;
}
/* ci_tsfix = 1 */
/*
* since the remainder of the TS packet which got cut off
* in the previous tsin_exchange() run is at the beginning
* of the new TS buffer, append this to the temp buffer and
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/delay.h`, `linux/slab.h`, `linux/poll.h`, `linux/io.h`, `asm/div64.h`, `linux/pci.h`.
- Detected declarations: `function ts_write`, `function ts_read`, `function ts_poll`, `function swap_buffer`, `function tsin_find_offset`, `function tsin_copy_stripped`, `function tsin_exchange`, `function ngene_start_feed`, `function ngene_stop_feed`, `function my_dvb_dmx_ts_card_init`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: pattern implementation candidate.
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.