1 /* SPDX-License-Identifier: GPL-2.0 */
3 * The Virtual DVB test driver serves as a reference DVB driver and helps
4 * validate the existing APIs in the media subsystem. It can also aid
5 * developers working on userspace applications.
7 * Copyright (C) 2020 Daniel W. S. Almeida
13 #include <linux/types.h>
15 #define TS_SYNC_BYTE 0x47
16 #define TS_PACKET_LEN 188
17 #define TS_PAYLOAD_LEN 184
18 #define TS_NULL_PACKET_PID 0x1fff
19 #define TS_CC_MAX_VAL 0x0f /* 4 bits */
20 #define TS_LAST_VALID_PID 8191
21 #define TS_FILL_BYTE 0xff /* the byte used in packet stuffing */
23 struct vidtv_mpeg_ts_adaption
{
38 struct vidtv_mpeg_ts
{
40 __be16 bitfield
; /* tei: 1, payload_start:1 priority: 1, pid:13 */
42 u8 continuity_counter
:4;
44 u8 adaptation_field
:1;
47 struct vidtv_mpeg_ts_adaption
*adaption
;
51 * struct pcr_write_args - Arguments for the pcr_write_into function.
52 * @dest_buf: The buffer to write into.
53 * @dest_offset: The byte offset into the buffer.
54 * @pid: The TS PID for the PCR packets.
55 * @buf_sz: The size of the buffer in bytes.
56 * @continuity_counter: The TS continuity_counter.
57 * @pcr: A sample from the system clock.
59 struct pcr_write_args
{
64 u8
*continuity_counter
;
69 * struct null_packet_write_args - Arguments for the null_write_into function
70 * @dest_buf: The buffer to write into.
71 * @dest_offset: The byte offset into the buffer.
72 * @buf_sz: The size of the buffer in bytes.
73 * @continuity_counter: The TS continuity_counter.
75 struct null_packet_write_args
{
79 u8
*continuity_counter
;
82 /* Increment the continuity counter */
83 void vidtv_ts_inc_cc(u8
*continuity_counter
);
86 * vidtv_ts_null_write_into - Write a TS null packet into a buffer.
87 * @args: the arguments to use when writing.
89 * This function will write a null packet into a buffer. This is usually used to
92 * Return: The number of bytes written into the buffer.
94 u32
vidtv_ts_null_write_into(struct null_packet_write_args args
);
97 * vidtv_ts_pcr_write_into - Write a PCR packet into a buffer.
98 * @args: the arguments to use when writing.
100 * This function will write a PCR packet into a buffer. This is used to
101 * synchronize the clocks between encoders and decoders.
103 * Return: The number of bytes written into the buffer.
105 u32
vidtv_ts_pcr_write_into(struct pcr_write_args args
);