Skip to content

Commit 7a7899f

Browse files
dwlsalmeidamchehab
authored andcommitted
media: vidtv: psi: Implement an Event Information Table (EIT)
Implement an Event Information Table (EIT) as per EN 300 468 5.2.4. The EIT provides information in chronological order regarding the events contained within each service. For now only present event information is supported. [mchehab+huawei@kernel.org: removed an extra blank line] Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent c2f78f0 commit 7a7899f

7 files changed

Lines changed: 523 additions & 9 deletions

File tree

‎Documentation/driver-api/media/drivers/vidtv.rst‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ vidtv_psi.[ch]
149149
Because the generator is implemented in a separate file, it can be
150150
reused elsewhere in the media subsystem.
151151

152-
Currently vidtv supports working with 4 PSI tables: PAT, PMT,
153-
SDT and NIT.
152+
Currently vidtv supports working with 5 PSI tables: PAT, PMT,
153+
SDT, NIT and EIT.
154154

155155
The specification for PAT and PMT can be found in *ISO 13818-1:
156-
Systems*, while the specification for the SDT, NIT can be found in *ETSI
156+
Systems*, while the specification for the SDT, NIT, EIT can be found in *ETSI
157157
EN 300 468: Specification for Service Information (SI) in DVB
158158
systems*.
159159

@@ -197,6 +197,8 @@ vidtv_channel.[ch]
197197

198198
#. Their programs will be concatenated to populate the PAT
199199

200+
#. Their events will be concatenated to populate the EIT
201+
200202
#. For each program in the PAT, a PMT section will be created
201203

202204
#. The PMT section for a channel will be assigned its streams.

‎drivers/media/test-drivers/vidtv/vidtv_channel.c‎

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* When vidtv boots, it will create some hardcoded channels.
1010
* Their services will be concatenated to populate the SDT.
1111
* Their programs will be concatenated to populate the PAT
12+
* Their events will be concatenated to populate the EIT
1213
* For each program in the PAT, a PMT section will be created
1314
* The PMT section for a channel will be assigned its streams.
1415
* Every stream will have its corresponding encoder polled to produce TS packets
@@ -59,13 +60,17 @@ struct vidtv_channel
5960

6061
char *name = ENCODING_ISO8859_15 "Beethoven";
6162
char *provider = ENCODING_ISO8859_15 "LinuxTV.org";
63+
char *iso_language_code = ENCODING_ISO8859_15 "eng";
64+
char *event_name = ENCODING_ISO8859_15 "Beethoven Music";
65+
char *event_text = ENCODING_ISO8859_15 "Beethoven's 5th Symphony";
66+
const u16 s302m_beethoven_event_id = 1;
6267

6368
struct vidtv_channel *s302m = kzalloc(sizeof(*s302m), GFP_KERNEL);
6469
struct vidtv_s302m_encoder_init_args encoder_args = {};
6570

6671
s302m->name = kstrdup(name, GFP_KERNEL);
6772

68-
s302m->service = vidtv_psi_sdt_service_init(NULL, s302m_service_id);
73+
s302m->service = vidtv_psi_sdt_service_init(NULL, s302m_service_id, false, true);
6974

7075
s302m->service->descriptor = (struct vidtv_psi_desc *)
7176
vidtv_psi_service_desc_init(NULL,
@@ -94,6 +99,13 @@ struct vidtv_channel
9499

95100
s302m->encoders = vidtv_s302m_encoder_init(encoder_args);
96101

102+
s302m->events = vidtv_psi_eit_event_init(NULL, s302m_beethoven_event_id);
103+
s302m->events->descriptor = (struct vidtv_psi_desc *)
104+
vidtv_psi_short_event_desc_init(NULL,
105+
iso_language_code,
106+
event_name,
107+
event_text);
108+
97109
if (head) {
98110
while (head->next)
99111
head = head->next;
@@ -104,6 +116,48 @@ struct vidtv_channel
104116
return s302m;
105117
}
106118

119+
static struct vidtv_psi_table_eit_event
120+
*vidtv_channel_eit_event_cat_into_new(struct vidtv_mux *m)
121+
{
122+
/* Concatenate the events */
123+
const struct vidtv_channel *cur_chnl = m->channels;
124+
125+
struct vidtv_psi_table_eit_event *curr = NULL;
126+
struct vidtv_psi_table_eit_event *head = NULL;
127+
struct vidtv_psi_table_eit_event *tail = NULL;
128+
129+
struct vidtv_psi_desc *desc = NULL;
130+
u16 event_id;
131+
132+
if (!cur_chnl)
133+
return NULL;
134+
135+
while (cur_chnl) {
136+
curr = cur_chnl->events;
137+
138+
if (!curr)
139+
dev_warn_ratelimited(m->dev,
140+
"No events found for channel %s\n", cur_chnl->name);
141+
142+
while (curr) {
143+
event_id = be16_to_cpu(curr->event_id);
144+
tail = vidtv_psi_eit_event_init(tail, event_id);
145+
146+
desc = vidtv_psi_desc_clone(curr->descriptor);
147+
vidtv_psi_desc_assign(&tail->descriptor, desc);
148+
149+
if (!head)
150+
head = tail;
151+
152+
curr = curr->next;
153+
}
154+
155+
cur_chnl = cur_chnl->next;
156+
}
157+
158+
return head;
159+
}
160+
107161
static struct vidtv_psi_table_sdt_service
108162
*vidtv_channel_sdt_serv_cat_into_new(struct vidtv_mux *m)
109163
{
@@ -129,7 +183,10 @@ static struct vidtv_psi_table_sdt_service
129183

130184
while (curr) {
131185
service_id = be16_to_cpu(curr->service_id);
132-
tail = vidtv_psi_sdt_service_init(tail, service_id);
186+
tail = vidtv_psi_sdt_service_init(tail,
187+
service_id,
188+
curr->EIT_schedule,
189+
curr->EIT_present_following);
133190

134191
desc = vidtv_psi_desc_clone(curr->descriptor);
135192
vidtv_psi_desc_assign(&tail->descriptor, desc);
@@ -297,6 +354,7 @@ void vidtv_channel_si_init(struct vidtv_mux *m)
297354
struct vidtv_psi_table_pat_program *programs = NULL;
298355
struct vidtv_psi_table_sdt_service *services = NULL;
299356
struct vidtv_psi_desc_service_list_entry *service_list = NULL;
357+
struct vidtv_psi_table_eit_event *events = NULL;
300358

301359
m->si.pat = vidtv_psi_pat_table_init(m->transport_stream_id);
302360

@@ -305,6 +363,8 @@ void vidtv_channel_si_init(struct vidtv_mux *m)
305363
programs = vidtv_channel_pat_prog_cat_into_new(m);
306364
services = vidtv_channel_sdt_serv_cat_into_new(m);
307365

366+
events = vidtv_channel_eit_event_cat_into_new(m);
367+
308368
/* look for a service descriptor for every service */
309369
service_list = vidtv_channel_build_service_list(services);
310370

@@ -314,12 +374,17 @@ void vidtv_channel_si_init(struct vidtv_mux *m)
314374
m->network_name,
315375
service_list);
316376

377+
m->si.eit = vidtv_psi_eit_table_init(m->network_id, m->transport_stream_id);
378+
317379
/* assemble all programs and assign to PAT */
318380
vidtv_psi_pat_program_assign(m->si.pat, programs);
319381

320382
/* assemble all services and assign to SDT */
321383
vidtv_psi_sdt_service_assign(m->si.sdt, services);
322384

385+
/* assemble all events and assign to EIT */
386+
vidtv_psi_eit_event_assign(m->si.eit, events);
387+
323388
m->si.pmt_secs = vidtv_psi_pmt_create_sec_for_each_pat_entry(m->si.pat, m->pcr_pid);
324389

325390
vidtv_channel_pmt_match_sections(m->channels,
@@ -342,6 +407,7 @@ void vidtv_channel_si_destroy(struct vidtv_mux *m)
342407
kfree(m->si.pmt_secs);
343408
vidtv_psi_sdt_table_destroy(m->si.sdt);
344409
vidtv_psi_nit_table_destroy(m->si.nit);
410+
vidtv_psi_eit_table_destroy(m->si.eit);
345411
}
346412

347413
void vidtv_channels_init(struct vidtv_mux *m)
@@ -361,6 +427,7 @@ void vidtv_channels_destroy(struct vidtv_mux *m)
361427
vidtv_psi_pat_program_destroy(curr->program);
362428
vidtv_psi_pmt_stream_destroy(curr->streams);
363429
vidtv_channel_encoder_destroy(curr->encoders);
430+
vidtv_psi_eit_event_destroy(curr->events);
364431

365432
tmp = curr;
366433
curr = curr->next;

‎drivers/media/test-drivers/vidtv/vidtv_channel.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* When vidtv boots, it will create some hardcoded channels.
1010
* Their services will be concatenated to populate the SDT.
1111
* Their programs will be concatenated to populate the PAT
12+
* Their events will be concatenated to populate the EIT
1213
* For each program in the PAT, a PMT section will be created
1314
* The PMT section for a channel will be assigned its streams.
1415
* Every stream will have its corresponding encoder polled to produce TS packets
@@ -44,6 +45,7 @@
4445
* Will be concatenated into the PAT.
4546
* @streams: A stream loop used to populate the PMT section for 'program'
4647
* @encoders: A encoder loop. There must be one encoder for each stream.
48+
* @events: Optional event information. This will feed into the EIT.
4749
* @next: Optionally chain this channel.
4850
*/
4951
struct vidtv_channel {
@@ -54,6 +56,7 @@ struct vidtv_channel {
5456
struct vidtv_psi_table_pat_program *program;
5557
struct vidtv_psi_table_pmt_stream *streams;
5658
struct vidtv_encoder *encoders;
59+
struct vidtv_psi_table_eit_event *events;
5760
struct vidtv_channel *next;
5861
};
5962

‎drivers/media/test-drivers/vidtv/vidtv_mux.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ static void vidtv_mux_pid_ctx_init(struct vidtv_mux *m)
7676
vidtv_mux_create_pid_ctx_once(m, VIDTV_SDT_PID);
7777
/* push the NIT pid ctx */
7878
vidtv_mux_create_pid_ctx_once(m, VIDTV_NIT_PID);
79+
/* push the EIT pid ctx */
80+
vidtv_mux_create_pid_ctx_once(m, VIDTV_EIT_PID);
7981

8082
/* add a ctx for all PMT sections */
8183
while (p) {
@@ -120,11 +122,13 @@ static u32 vidtv_mux_push_si(struct vidtv_mux *m)
120122
struct vidtv_mux_pid_ctx *pmt_ctx;
121123
struct vidtv_mux_pid_ctx *sdt_ctx;
122124
struct vidtv_mux_pid_ctx *nit_ctx;
125+
struct vidtv_mux_pid_ctx *eit_ctx;
123126

124127
struct vidtv_psi_pat_write_args pat_args = {};
125128
struct vidtv_psi_pmt_write_args pmt_args = {};
126129
struct vidtv_psi_sdt_write_args sdt_args = {};
127130
struct vidtv_psi_nit_write_args nit_args = {};
131+
struct vidtv_psi_eit_write_args eit_args = {};
128132

129133
u32 nbytes; /* the number of bytes written by this function */
130134
u16 pmt_pid;
@@ -133,6 +137,7 @@ static u32 vidtv_mux_push_si(struct vidtv_mux *m)
133137
pat_ctx = vidtv_mux_get_pid_ctx(m, VIDTV_PAT_PID);
134138
sdt_ctx = vidtv_mux_get_pid_ctx(m, VIDTV_SDT_PID);
135139
nit_ctx = vidtv_mux_get_pid_ctx(m, VIDTV_NIT_PID);
140+
eit_ctx = vidtv_mux_get_pid_ctx(m, VIDTV_EIT_PID);
136141

137142
pat_args.buf = m->mux_buf;
138143
pat_args.offset = m->mux_buf_offset;
@@ -182,6 +187,14 @@ static u32 vidtv_mux_push_si(struct vidtv_mux *m)
182187

183188
m->mux_buf_offset += vidtv_psi_nit_write_into(nit_args);
184189

190+
eit_args.buf = m->mux_buf;
191+
eit_args.offset = m->mux_buf_offset;
192+
eit_args.eit = m->si.eit;
193+
eit_args.buf_sz = m->mux_buf_sz;
194+
eit_args.continuity_counter = &eit_ctx->cc;
195+
196+
m->mux_buf_offset += vidtv_psi_eit_write_into(eit_args);
197+
185198
nbytes = m->mux_buf_offset - initial_offset;
186199

187200
m->num_streamed_si++;

‎drivers/media/test-drivers/vidtv/vidtv_mux.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ struct vidtv_mux_timing {
5858
* @pat: The PAT in use by the muxer.
5959
* @pmt_secs: The PMT sections in use by the muxer. One for each program in the PAT.
6060
* @sdt: The SDT in use by the muxer.
61+
* @eit: the EIT in use by the muxer.
6162
*/
6263
struct vidtv_mux_si {
6364
/* the SI tables */
6465
struct vidtv_psi_table_pat *pat;
6566
struct vidtv_psi_table_pmt **pmt_secs; /* the PMT sections */
6667
struct vidtv_psi_table_sdt *sdt;
6768
struct vidtv_psi_table_nit *nit;
69+
struct vidtv_psi_table_eit *eit;
6870
};
6971

7072
/**

0 commit comments

Comments
 (0)