drivers/media/test-drivers/vidtv/vidtv_pes.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vidtv/vidtv_pes.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/vidtv/vidtv_pes.c- Extension
.c- Size
- 11962 bytes
- Lines
- 427
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/math64.hlinux/printk.hlinux/ratelimit.hvidtv_pes.hvidtv_common.hvidtv_encoder.hvidtv_ts.h
Detected Declarations
function Copyrightfunction vidtv_pes_h_get_lenfunction vidtv_pes_write_header_stuffingfunction vidtv_pes_write_pts_dtsfunction vidtv_pes_write_hfunction vidtv_pes_write_pcr_bitsfunction vidtv_pes_write_stuffingfunction vidtv_pes_write_ts_hfunction vidtv_pes_write_into
Annotated Snippet
if (need_pcr) {
available_space -= SIZE_PCR;
stuff_bytes = SIZE_PCR;
} else {
stuff_bytes = 0;
}
/*
* how much of the _actual_ payload should be written in this
* packet.
*/
if (remaining_len >= available_space) {
payload_size = available_space;
} else {
/* Last frame should ensure 188-bytes PS alignment */
payload_size = remaining_len;
stuff_bytes += available_space - payload_size;
/*
* Ensure that the stuff bytes will be within the
* allowed range, decrementing the number of payload
* bytes to write if needed.
*/
if (stuff_bytes > PES_TS_HEADER_MAX_STUFFING_BYTES) {
u32 tmp = stuff_bytes - PES_TS_HEADER_MAX_STUFFING_BYTES;
stuff_bytes = PES_TS_HEADER_MAX_STUFFING_BYTES;
payload_size -= tmp;
}
}
/* write ts header */
ts_header_args.dest_offset = args->dest_offset + nbytes;
ts_header_args.wrote_pes_header = wrote_pes_header;
ts_header_args.n_stuffing_bytes = stuff_bytes;
nbytes += vidtv_pes_write_ts_h(ts_header_args, need_pcr,
&last_pcr);
need_pcr = false;
if (!wrote_pes_header) {
/* write the PES header only once */
pes_header_args.dest_offset = args->dest_offset +
nbytes;
nbytes += vidtv_pes_write_h(&pes_header_args);
wrote_pes_header = true;
}
/* write as much of the payload as we possibly can */
nbytes += vidtv_memcpy(args->dest_buf,
args->dest_offset + nbytes,
args->dest_buf_sz,
args->from,
payload_size);
args->from += payload_size;
remaining_len -= payload_size;
}
return nbytes;
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/math64.h`, `linux/printk.h`, `linux/ratelimit.h`, `vidtv_pes.h`, `vidtv_common.h`, `vidtv_encoder.h`, `vidtv_ts.h`.
- Detected declarations: `function Copyright`, `function vidtv_pes_h_get_len`, `function vidtv_pes_write_header_stuffing`, `function vidtv_pes_write_pts_dts`, `function vidtv_pes_write_h`, `function vidtv_pes_write_pcr_bits`, `function vidtv_pes_write_stuffing`, `function vidtv_pes_write_ts_h`, `function vidtv_pes_write_into`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.