4bc2a4c0980dc1d46a1e358701c1661451908e61
[linux-2.6-microblaze.git] / drivers / media / test-drivers / vidtv / vidtv_channel.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Vidtv serves as a reference DVB driver and helps validate the existing APIs
4  * in the media subsystem. It can also aid developers working on userspace
5  * applications.
6  *
7  * This file contains the code for a 'channel' abstraction.
8  *
9  * When vidtv boots, it will create some hardcoded channels.
10  * Their services will be concatenated to populate the SDT.
11  * Their programs will be concatenated to populate the PAT
12  * Their events will be concatenated to populate the EIT
13  * For each program in the PAT, a PMT section will be created
14  * The PMT section for a channel will be assigned its streams.
15  * Every stream will have its corresponding encoder polled to produce TS packets
16  * These packets may be interleaved by the mux and then delivered to the bridge
17  *
18  *
19  * Copyright (C) 2020 Daniel W. S. Almeida
20  */
21
22 #ifndef VIDTV_CHANNEL_H
23 #define VIDTV_CHANNEL_H
24
25 #include <linux/types.h>
26
27 #include "vidtv_encoder.h"
28 #include "vidtv_mux.h"
29 #include "vidtv_psi.h"
30
31 /**
32  * struct vidtv_channel - A 'channel' abstraction
33  *
34  * When vidtv boots, it will create some hardcoded channels.
35  * Their services will be concatenated to populate the SDT.
36  * Their programs will be concatenated to populate the PAT
37  * For each program in the PAT, a PMT section will be created
38  * The PMT section for a channel will be assigned its streams.
39  * Every stream will have its corresponding encoder polled to produce TS packets
40  * These packets may be interleaved by the mux and then delivered to the bridge
41  *
42  * @transport_stream_id: a number to identify the TS, chosen at will.
43  * @service: A _single_ service. Will be concatenated into the SDT.
44  * @program_num: The link between PAT, PMT and SDT.
45  * @program: A _single_ program with one or more streams associated with it.
46  * Will be concatenated into the PAT.
47  * @streams: A stream loop used to populate the PMT section for 'program'
48  * @encoders: A encoder loop. There must be one encoder for each stream.
49  * @events: Optional event information. This will feed into the EIT.
50  * @next: Optionally chain this channel.
51  */
52 struct vidtv_channel {
53         char *name;
54         u16 transport_stream_id;
55         struct vidtv_psi_table_sdt_service *service;
56         u16 program_num;
57         struct vidtv_psi_table_pat_program *program;
58         struct vidtv_psi_table_pmt_stream *streams;
59         struct vidtv_encoder *encoders;
60         struct vidtv_psi_table_eit_event *events;
61         struct vidtv_channel *next;
62 };
63
64 /**
65  * vidtv_channel_si_init - Init the PSI tables from the channels in the mux
66  * @m: The mux containing the channels.
67  */
68 int vidtv_channel_si_init(struct vidtv_mux *m);
69 void vidtv_channel_si_destroy(struct vidtv_mux *m);
70
71 /**
72  * vidtv_channels_init - Init hardcoded, fake 'channels'.
73  * @m: The mux to store the channels into.
74  */
75 int vidtv_channels_init(struct vidtv_mux *m);
76 struct vidtv_channel
77 *vidtv_channel_s302m_init(struct vidtv_channel *head, u16 transport_stream_id);
78 void vidtv_channels_destroy(struct vidtv_mux *m);
79
80 #endif //VIDTV_CHANNEL_H