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