1 /* SPDX-License-Identifier: GPL-2.0 */
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
7 * This file contains the code for an AES3 (also known as AES/EBU) encoder.
8 * It is based on EBU Tech 3250 and SMPTE 302M technical documents.
10 * This encoder currently supports 16bit AES3 subframes using 16bit signed
13 * Note: AU stands for Access Unit, and AAU stands for Audio Access Unit
15 * Copyright (C) 2020 Daniel W. S. Almeida
21 #include <linux/types.h>
23 #include "vidtv_encoder.h"
25 /* see SMPTE 302M 2007 clause 7.3 */
26 #define VIDTV_S302M_BUF_SZ 65024
28 /* see ETSI TS 102 154 v.1.2.1 clause 7.3.5 */
29 #define VIDTV_S302M_FORMAT_IDENTIFIER 0x42535344
32 * struct vidtv_s302m_ctx - s302m encoder context.
33 * @enc: A pointer to the containing encoder structure.
34 * @frame_index: The current frame in a block
35 * @au_count: The total number of access units encoded up to now
36 * @last_duration: Duration of the tone currently being played
37 * @note_offset: Position at the music tone array
38 * @last_tone: Tone currently being played
40 struct vidtv_s302m_ctx
{
41 struct vidtv_encoder
*enc
;
45 unsigned int note_offset
;
46 enum musical_notes last_tone
;
50 * struct vidtv_smpte_s302m_es - s302m MPEG Elementary Stream header.
52 * See SMPTE 302M 2007 table 1.
54 struct vidtv_smpte_s302m_es
{
57 * audio_packet_size:16;
59 * channel_identification:8;
60 * bits_per_sample:2; // 0x0 for 16bits
66 struct vidtv_s302m_frame_16
{
71 * struct vidtv_s302m_encoder_init_args - Args for the s302m encoder.
73 * @name: A name to identify this particular instance
74 * @src_buf: The source buffer, encoder will default to a sine wave if this is NULL.
75 * @src_buf_sz: The size of the source buffer.
76 * @es_pid: The MPEG Elementary Stream PID to use.
77 * @sync: Attempt to synchronize audio with this video encoder, if not NULL.
78 * @last_sample_cb: A callback called when the encoder runs out of data.
79 * @head: Add to this chain
81 struct vidtv_s302m_encoder_init_args
{
86 struct vidtv_encoder
*sync
;
87 void (*last_sample_cb
)(u32 sample_no
);
89 struct vidtv_encoder
*head
;
93 *vidtv_s302m_encoder_init(struct vidtv_s302m_encoder_init_args args
);
95 void vidtv_s302m_encoder_destroy(struct vidtv_encoder
*encoder
);
97 #endif /* VIDTV_S302M_H */