drivers/media/test-drivers/vidtv/vidtv_psi.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vidtv/vidtv_psi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/vidtv/vidtv_psi.c- Extension
.c- Size
- 53340 bytes
- Lines
- 1997
- 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.
- 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/bcd.hlinux/crc32.hlinux/kernel.hlinux/ktime.hlinux/printk.hlinux/ratelimit.hlinux/slab.hlinux/string.hlinux/time.hlinux/types.hvidtv_common.hvidtv_psi.hvidtv_ts.h
Detected Declarations
function Copyrightfunction vidtv_psi_get_sec_lenfunction vidtv_psi_get_pat_program_pidfunction vidtv_psi_pmt_stream_get_elem_pidfunction vidtv_psi_set_desc_loop_lenfunction vidtv_psi_set_sec_lenfunction headerfunction table_section_crc32_write_intofunction vidtv_psi_desc_chainfunction vidtv_psi_desc_destroyfunction vidtv_psi_desc_comp_loop_lenfunction vidtv_psi_desc_assignfunction vidtv_pmt_desc_assignfunction vidtv_sdt_desc_assignfunction vidtv_psi_desc_write_intofunction vidtv_psi_table_header_write_intofunction vidtv_psi_pat_table_update_sec_lenfunction vidtv_psi_pmt_table_update_sec_lenfunction vidtv_psi_sdt_table_update_sec_lenfunction vidtv_psi_pat_program_initfunction vidtv_psi_pat_program_destroyfunction vidtv_psi_pat_program_assignfunction vidtv_psi_pat_write_intofunction vidtv_psi_pat_table_destroyfunction vidtv_psi_pmt_stream_initfunction vidtv_psi_pmt_stream_destroyfunction vidtv_psi_pmt_stream_assignfunction vidtv_psi_pmt_get_pidfunction vidtv_psi_pmt_write_intofunction vidtv_psi_pmt_table_destroyfunction vidtv_psi_sdt_write_intofunction vidtv_psi_sdt_table_destroyfunction vidtv_psi_sdt_service_destroyfunction vidtv_psi_sdt_service_assignfunction vidtv_psi_pmt_create_sec_for_each_pat_entryfunction vidtv_psi_nit_table_update_sec_lenfunction vidtv_psi_nit_write_intofunction vidtv_psi_transport_destroyfunction vidtv_psi_nit_table_destroyfunction vidtv_psi_eit_table_update_sec_lenfunction vidtv_psi_eit_event_assignfunction vidtv_psi_eit_write_intofunction vidtv_psi_eit_event_destroyfunction vidtv_psi_eit_table_destroy
Annotated Snippet
if (aligned) {
/* if at a packet boundary, write a new TS header */
ts_header.continuity_counter = *args->continuity_counter;
nbytes += vidtv_memcpy(args->dest_buf,
args->dest_offset + nbytes,
args->dest_buf_sz,
&ts_header,
sizeof(ts_header));
/*
* This will trigger a discontinuity if the buffer is full,
* effectively dropping the packet.
*/
vidtv_ts_inc_cc(args->continuity_counter);
}
/* write the pointer_field in the first byte of the payload */
if (args->new_psi_section)
nbytes += vidtv_memset(args->dest_buf,
args->dest_offset + nbytes,
args->dest_buf_sz,
0x0,
1);
/* write as much of the payload as possible */
nbytes_past_boundary = (args->dest_offset + nbytes) % TS_PACKET_LEN;
payload_write_len = min(TS_PACKET_LEN - nbytes_past_boundary, remaining_len);
nbytes += vidtv_memcpy(args->dest_buf,
args->dest_offset + nbytes,
args->dest_buf_sz,
args->from + payload_offset,
payload_write_len);
/* 'payload_write_len' written from a total of 'len' requested*/
remaining_len -= payload_write_len;
payload_offset += payload_write_len;
}
/*
* fill the rest of the packet if there is any remaining space unused
*/
nbytes_past_boundary = (args->dest_offset + nbytes) % TS_PACKET_LEN;
if (args->is_crc)
nbytes += vidtv_memset(args->dest_buf,
args->dest_offset + nbytes,
args->dest_buf_sz,
TS_FILL_BYTE,
TS_PACKET_LEN - nbytes_past_boundary);
return nbytes;
}
static u32 table_section_crc32_write_into(struct crc32_write_args *args)
{
struct psi_write_args psi_args = {
.dest_buf = args->dest_buf,
.from = &args->crc,
.len = CRC_SIZE_IN_BYTES,
.dest_offset = args->dest_offset,
.pid = args->pid,
.new_psi_section = false,
.continuity_counter = args->continuity_counter,
.is_crc = true,
.dest_buf_sz = args->dest_buf_sz,
};
/* the CRC is the last entry in the section */
return vidtv_psi_ts_psi_write_into(&psi_args);
}
static void vidtv_psi_desc_chain(struct vidtv_psi_desc *head, struct vidtv_psi_desc *desc)
{
if (head) {
while (head->next)
head = head->next;
head->next = desc;
}
}
struct vidtv_psi_desc_service *vidtv_psi_service_desc_init(struct vidtv_psi_desc *head,
enum service_type service_type,
char *service_name,
char *provider_name)
{
struct vidtv_psi_desc_service *desc;
Annotation
- Immediate include surface: `linux/bcd.h`, `linux/crc32.h`, `linux/kernel.h`, `linux/ktime.h`, `linux/printk.h`, `linux/ratelimit.h`, `linux/slab.h`, `linux/string.h`.
- Detected declarations: `function Copyright`, `function vidtv_psi_get_sec_len`, `function vidtv_psi_get_pat_program_pid`, `function vidtv_psi_pmt_stream_get_elem_pid`, `function vidtv_psi_set_desc_loop_len`, `function vidtv_psi_set_sec_len`, `function header`, `function table_section_crc32_write_into`, `function vidtv_psi_desc_chain`, `function vidtv_psi_desc_destroy`.
- 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.