blob: 472d0ac3659163680aabaa357d4f7db018a45f56 [file] [log] [blame]
Vinod Koul12ac0b562011-09-02 11:36:22 +05301/*
2 * snd_compress_params.h - codec types and parameters for compressed data
3 * streaming interface
4 *
5 * Copyright (C) 2011 Intel Corporation
Vinod Koulf15a95c2011-09-09 06:03:51 +05306 * Authors: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Vinod Koul12ac0b562011-09-02 11:36:22 +05307 * Vinod Koul <vinod.koul@linux.intel.com>
8 *
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2 of the License.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 *
26 * The definitions in this file are derived from the OpenMAX AL version 1.1
27 * and OpenMAX IL v 1.1.2 header files which contain the copyright notice below.
28 *
29 * Copyright (c) 2007-2010 The Khronos Group Inc.
30 *
31 * Permission is hereby granted, free of charge, to any person obtaining
32 * a copy of this software and/or associated documentation files (the
33 * "Materials "), to deal in the Materials without restriction, including
34 * without limitation the rights to use, copy, modify, merge, publish,
35 * distribute, sublicense, and/or sell copies of the Materials, and to
36 * permit persons to whom the Materials are furnished to do so, subject to
37 * the following conditions:
38 *
39 * The above copyright notice and this permission notice shall be included
40 * in all copies or substantial portions of the Materials.
41 *
42 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
43 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
49 *
50 */
51
52
53/* AUDIO CODECS SUPPORTED */
54#define MAX_NUM_CODECS 32
55#define MAX_NUM_CODEC_DESCRIPTORS 32
Vinod Koul12ac0b562011-09-02 11:36:22 +053056#define MAX_NUM_BITRATES 32
57
58/* Codecs are listed linearly to allow for extensibility */
59#define SND_AUDIOCODEC_PCM ((__u32) 0x00000001)
60#define SND_AUDIOCODEC_MP3 ((__u32) 0x00000002)
61#define SND_AUDIOCODEC_AMR ((__u32) 0x00000003)
62#define SND_AUDIOCODEC_AMRWB ((__u32) 0x00000004)
63#define SND_AUDIOCODEC_AMRWBPLUS ((__u32) 0x00000005)
64#define SND_AUDIOCODEC_AAC ((__u32) 0x00000006)
65#define SND_AUDIOCODEC_WMA ((__u32) 0x00000007)
66#define SND_AUDIOCODEC_REAL ((__u32) 0x00000008)
67#define SND_AUDIOCODEC_VORBIS ((__u32) 0x00000009)
68#define SND_AUDIOCODEC_FLAC ((__u32) 0x0000000A)
69#define SND_AUDIOCODEC_IEC61937 ((__u32) 0x0000000B)
Pierre-Louis Bossart4b065d42011-09-21 17:20:24 -050070#define SND_AUDIOCODEC_G723_1 ((__u32) 0x0000000C)
71#define SND_AUDIOCODEC_G729 ((__u32) 0x0000000D)
Santosh Mardi23321202012-03-22 04:33:25 +053072#define SND_AUDIOCODEC_AC3 ((__u32) 0x0000000E)
73#define SND_AUDIOCODEC_DTS ((__u32) 0x0000000F)
Santosh Mardie27ed782012-03-29 04:20:38 +053074#define SND_AUDIOCODEC_AC3_PASS_THROUGH ((__u32) 0x00000010)
Vinod Koul12ac0b562011-09-02 11:36:22 +053075/*
76 * Profile and modes are listed with bit masks. This allows for a
77 * more compact representation of fields that will not evolve
78 * (in contrast to the list of codecs)
79 */
80
81#define SND_AUDIOPROFILE_PCM ((__u32) 0x00000001)
82
83/* MP3 modes are only useful for encoders */
84#define SND_AUDIOCHANMODE_MP3_MONO ((__u32) 0x00000001)
85#define SND_AUDIOCHANMODE_MP3_STEREO ((__u32) 0x00000002)
86#define SND_AUDIOCHANMODE_MP3_JOINTSTEREO ((__u32) 0x00000004)
87#define SND_AUDIOCHANMODE_MP3_DUAL ((__u32) 0x00000008)
88
89#define SND_AUDIOPROFILE_AMR ((__u32) 0x00000001)
90
91/* AMR modes are only useful for encoders */
92#define SND_AUDIOMODE_AMR_DTX_OFF ((__u32) 0x00000001)
93#define SND_AUDIOMODE_AMR_VAD1 ((__u32) 0x00000002)
94#define SND_AUDIOMODE_AMR_VAD2 ((__u32) 0x00000004)
95
96#define SND_AUDIOSTREAMFORMAT_UNDEFINED ((__u32) 0x00000000)
97#define SND_AUDIOSTREAMFORMAT_CONFORMANCE ((__u32) 0x00000001)
98#define SND_AUDIOSTREAMFORMAT_IF1 ((__u32) 0x00000002)
99#define SND_AUDIOSTREAMFORMAT_IF2 ((__u32) 0x00000004)
100#define SND_AUDIOSTREAMFORMAT_FSF ((__u32) 0x00000008)
101#define SND_AUDIOSTREAMFORMAT_RTPPAYLOAD ((__u32) 0x00000010)
102#define SND_AUDIOSTREAMFORMAT_ITU ((__u32) 0x00000020)
103
104#define SND_AUDIOPROFILE_AMRWB ((__u32) 0x00000001)
105
106/* AMRWB modes are only useful for encoders */
107#define SND_AUDIOMODE_AMRWB_DTX_OFF ((__u32) 0x00000001)
108#define SND_AUDIOMODE_AMRWB_VAD1 ((__u32) 0x00000002)
109#define SND_AUDIOMODE_AMRWB_VAD2 ((__u32) 0x00000004)
110
111#define SND_AUDIOPROFILE_AMRWBPLUS ((__u32) 0x00000001)
112
113#define SND_AUDIOPROFILE_AAC ((__u32) 0x00000001)
114
115/* AAC modes are required for encoders and decoders */
116#define SND_AUDIOMODE_AAC_MAIN ((__u32) 0x00000001)
117#define SND_AUDIOMODE_AAC_LC ((__u32) 0x00000002)
118#define SND_AUDIOMODE_AAC_SSR ((__u32) 0x00000004)
119#define SND_AUDIOMODE_AAC_LTP ((__u32) 0x00000008)
120#define SND_AUDIOMODE_AAC_HE ((__u32) 0x00000010)
121#define SND_AUDIOMODE_AAC_SCALABLE ((__u32) 0x00000020)
122#define SND_AUDIOMODE_AAC_ERLC ((__u32) 0x00000040)
123#define SND_AUDIOMODE_AAC_LD ((__u32) 0x00000080)
124#define SND_AUDIOMODE_AAC_HE_PS ((__u32) 0x00000100)
125#define SND_AUDIOMODE_AAC_HE_MPS ((__u32) 0x00000200)
126
127/* AAC formats are required for encoders and decoders */
128#define SND_AUDIOSTREAMFORMAT_MP2ADTS ((__u32) 0x00000001)
129#define SND_AUDIOSTREAMFORMAT_MP4ADTS ((__u32) 0x00000002)
130#define SND_AUDIOSTREAMFORMAT_MP4LOAS ((__u32) 0x00000004)
131#define SND_AUDIOSTREAMFORMAT_MP4LATM ((__u32) 0x00000008)
132#define SND_AUDIOSTREAMFORMAT_ADIF ((__u32) 0x00000010)
133#define SND_AUDIOSTREAMFORMAT_MP4FF ((__u32) 0x00000020)
134#define SND_AUDIOSTREAMFORMAT_RAW ((__u32) 0x00000040)
135
136#define SND_AUDIOPROFILE_WMA7 ((__u32) 0x00000001)
137#define SND_AUDIOPROFILE_WMA8 ((__u32) 0x00000002)
138#define SND_AUDIOPROFILE_WMA9 ((__u32) 0x00000004)
139#define SND_AUDIOPROFILE_WMA10 ((__u32) 0x00000008)
140
141#define SND_AUDIOMODE_WMA_LEVEL1 ((__u32) 0x00000001)
142#define SND_AUDIOMODE_WMA_LEVEL2 ((__u32) 0x00000002)
143#define SND_AUDIOMODE_WMA_LEVEL3 ((__u32) 0x00000004)
144#define SND_AUDIOMODE_WMA_LEVEL4 ((__u32) 0x00000008)
145#define SND_AUDIOMODE_WMAPRO_LEVELM0 ((__u32) 0x00000010)
146#define SND_AUDIOMODE_WMAPRO_LEVELM1 ((__u32) 0x00000020)
147#define SND_AUDIOMODE_WMAPRO_LEVELM2 ((__u32) 0x00000040)
148#define SND_AUDIOMODE_WMAPRO_LEVELM3 ((__u32) 0x00000080)
149
150#define SND_AUDIOSTREAMFORMAT_WMA_ASF ((__u32) 0x00000001)
151/*
152 * Some implementations strip the ASF header and only send ASF packets
153 * to the DSP
154 */
155#define SND_AUDIOSTREAMFORMAT_WMA_NOASF_HDR ((__u32) 0x00000002)
156
157#define SND_AUDIOPROFILE_REALAUDIO ((__u32) 0x00000001)
158
159#define SND_AUDIOMODE_REALAUDIO_G2 ((__u32) 0x00000001)
160#define SND_AUDIOMODE_REALAUDIO_8 ((__u32) 0x00000002)
161#define SND_AUDIOMODE_REALAUDIO_10 ((__u32) 0x00000004)
162#define SND_AUDIOMODE_REALAUDIO_SURROUND ((__u32) 0x00000008)
163
164#define SND_AUDIOPROFILE_VORBIS ((__u32) 0x00000001)
165
166#define SND_AUDIOMODE_VORBIS ((__u32) 0x00000001)
167
168#define SND_AUDIOPROFILE_FLAC ((__u32) 0x00000001)
169
170/*
171 * Define quality levels for FLAC encoders, from LEVEL0 (fast)
172 * to LEVEL8 (best)
173 */
174#define SND_AUDIOMODE_FLAC_LEVEL0 ((__u32) 0x00000001)
175#define SND_AUDIOMODE_FLAC_LEVEL1 ((__u32) 0x00000002)
176#define SND_AUDIOMODE_FLAC_LEVEL2 ((__u32) 0x00000004)
177#define SND_AUDIOMODE_FLAC_LEVEL3 ((__u32) 0x00000008)
178#define SND_AUDIOMODE_FLAC_LEVEL4 ((__u32) 0x00000010)
179#define SND_AUDIOMODE_FLAC_LEVEL5 ((__u32) 0x00000020)
180#define SND_AUDIOMODE_FLAC_LEVEL6 ((__u32) 0x00000040)
181#define SND_AUDIOMODE_FLAC_LEVEL7 ((__u32) 0x00000080)
182#define SND_AUDIOMODE_FLAC_LEVEL8 ((__u32) 0x00000100)
183
184#define SND_AUDIOSTREAMFORMAT_FLAC ((__u32) 0x00000001)
185#define SND_AUDIOSTREAMFORMAT_FLAC_OGG ((__u32) 0x00000002)
186
187/* IEC61937 payloads without CUVP and preambles */
188#define SND_AUDIOPROFILE_IEC61937 ((__u32) 0x00000001)
189/* IEC61937 with S/PDIF preambles+CUVP bits in 32-bit containers */
190#define SND_AUDIOPROFILE_IEC61937_SPDIF ((__u32) 0x00000002)
191
192/*
193 * IEC modes are mandatory for decoders. Format autodetection
Vinod Koulf15a95c2011-09-09 06:03:51 +0530194 * will only happen on the DSP side with mode 0. The PCM mode should
195 * not be used, the PCM codec should be used instead.
Vinod Koul12ac0b562011-09-02 11:36:22 +0530196 */
197#define SND_AUDIOMODE_IEC_REF_STREAM_HEADER ((__u32) 0x00000000)
198#define SND_AUDIOMODE_IEC_LPCM ((__u32) 0x00000001)
199#define SND_AUDIOMODE_IEC_AC3 ((__u32) 0x00000002)
200#define SND_AUDIOMODE_IEC_MPEG1 ((__u32) 0x00000004)
201#define SND_AUDIOMODE_IEC_MP3 ((__u32) 0x00000008)
202#define SND_AUDIOMODE_IEC_MPEG2 ((__u32) 0x00000010)
203#define SND_AUDIOMODE_IEC_AACLC ((__u32) 0x00000020)
204#define SND_AUDIOMODE_IEC_DTS ((__u32) 0x00000040)
205#define SND_AUDIOMODE_IEC_ATRAC ((__u32) 0x00000080)
206#define SND_AUDIOMODE_IEC_SACD ((__u32) 0x00000100)
207#define SND_AUDIOMODE_IEC_EAC3 ((__u32) 0x00000200)
208#define SND_AUDIOMODE_IEC_DTS_HD ((__u32) 0x00000400)
209#define SND_AUDIOMODE_IEC_MLP ((__u32) 0x00000800)
210#define SND_AUDIOMODE_IEC_DST ((__u32) 0x00001000)
211#define SND_AUDIOMODE_IEC_WMAPRO ((__u32) 0x00002000)
212#define SND_AUDIOMODE_IEC_REF_CXT ((__u32) 0x00004000)
213#define SND_AUDIOMODE_IEC_HE_AAC ((__u32) 0x00008000)
214#define SND_AUDIOMODE_IEC_HE_AAC2 ((__u32) 0x00010000)
215#define SND_AUDIOMODE_IEC_MPEG_SURROUND ((__u32) 0x00020000)
216
Pierre-Louis Bossart4b065d42011-09-21 17:20:24 -0500217#define SND_AUDIOPROFILE_G723_1 ((__u32) 0x00000001)
218
219#define SND_AUDIOMODE_G723_1_ANNEX_A ((__u32) 0x00000001)
220#define SND_AUDIOMODE_G723_1_ANNEX_B ((__u32) 0x00000002)
221#define SND_AUDIOMODE_G723_1_ANNEX_C ((__u32) 0x00000004)
222
223#define SND_AUDIOPROFILE_G729 ((__u32) 0x00000001)
224
225#define SND_AUDIOMODE_G729_ANNEX_A ((__u32) 0x00000001)
226#define SND_AUDIOMODE_G729_ANNEX_B ((__u32) 0x00000002)
227
Vinod Koul12ac0b562011-09-02 11:36:22 +0530228/* <FIXME: multichannel encoders aren't supported for now. Would need
229 an additional definition of channel arrangement> */
230
231/* VBR/CBR definitions */
232#define SND_RATECONTROLMODE_CONSTANTBITRATE ((__u32) 0x00000001)
233#define SND_RATECONTROLMODE_VARIABLEBITRATE ((__u32) 0x00000002)
234
235/* Encoder options */
236
Vinod Koulf15a95c2011-09-09 06:03:51 +0530237struct snd_enc_wma {
Vinod Koul12ac0b562011-09-02 11:36:22 +0530238 __u32 super_block_align; /* WMA Type-specific data */
239};
240
241
242/**
Vinod Koulf15a95c2011-09-09 06:03:51 +0530243 * struct snd_enc_vorbis
Vinod Koul12ac0b562011-09-02 11:36:22 +0530244 * @quality: Sets encoding quality to n, between -1 (low) and 10 (high).
245 * In the default mode of operation, the quality level is 3.
246 * Normal quality range is 0 - 10.
247 * @managed: Boolean. Set bitrate management mode. This turns off the
248 * normal VBR encoding, but allows hard or soft bitrate constraints to be
249 * enforced by the encoder. This mode can be slower, and may also be
250 * lower quality. It is primarily useful for streaming.
Vinod Koulf15a95c2011-09-09 06:03:51 +0530251 * @max_bit_rate: Enabled only if managed is TRUE
252 * @min_bit_rate: Enabled only if managed is TRUE
Vinod Koul12ac0b562011-09-02 11:36:22 +0530253 * @downmix: Boolean. Downmix input from stereo to mono (has no effect on
254 * non-stereo streams). Useful for lower-bitrate encoding.
255 *
Vinod Koulf15a95c2011-09-09 06:03:51 +0530256 * These options were extracted from the OpenMAX IL spec and Gstreamer vorbisenc
Vinod Koul12ac0b562011-09-02 11:36:22 +0530257 * properties
258 *
259 * For best quality users should specify VBR mode and set quality levels.
260 */
261
Vinod Koulf15a95c2011-09-09 06:03:51 +0530262struct snd_enc_vorbis {
Vinod Koul12ac0b562011-09-02 11:36:22 +0530263 int quality;
264 __u32 managed;
Vinod Koulf15a95c2011-09-09 06:03:51 +0530265 __u32 max_bit_rate;
266 __u32 min_bit_rate;
Vinod Koul12ac0b562011-09-02 11:36:22 +0530267 __u32 downmix;
268};
269
270
271/**
Vinod Koulf15a95c2011-09-09 06:03:51 +0530272 * struct snd_enc_real
273 * @quant_bits: number of coupling quantization bits in the stream
274 * @start_region: coupling start region in the stream
275 * @num_regions: number of regions value
Vinod Koul12ac0b562011-09-02 11:36:22 +0530276 *
277 * These options were extracted from the OpenMAX IL spec
278 */
279
Vinod Koulf15a95c2011-09-09 06:03:51 +0530280struct snd_enc_real {
281 __u32 quant_bits;
282 __u32 start_region;
Vinod Koul12ac0b562011-09-02 11:36:22 +0530283 __u32 num_regions;
284};
285
286/**
Vinod Koulf15a95c2011-09-09 06:03:51 +0530287 * struct snd_enc_flac
288 * @num: serial number, valid only for OGG formats
289 * needs to be set by application
290 * @gain: Add replay gain tags
Vinod Koul12ac0b562011-09-02 11:36:22 +0530291 *
292 * These options were extracted from the FLAC online documentation
293 * at http://flac.sourceforge.net/documentation_tools_flac.html
294 *
295 * To make the API simpler, it is assumed that the user will select quality
296 * profiles. Additional options that affect encoding quality and speed can
Vinod Koulf15a95c2011-09-09 06:03:51 +0530297 * be added at a later stage if needed.
Vinod Koul12ac0b562011-09-02 11:36:22 +0530298 *
299 * By default the Subset format is used by encoders.
300 *
301 * TAGS such as pictures, etc, cannot be handled by an offloaded encoder and are
302 * not supported in this API.
303 */
304
Vinod Koulf15a95c2011-09-09 06:03:51 +0530305struct snd_enc_flac {
306 __u32 num;
307 __u32 gain;
Vinod Koul12ac0b562011-09-02 11:36:22 +0530308};
309
Vinod Koulf15a95c2011-09-09 06:03:51 +0530310struct snd_enc_generic {
311 __u32 bw; /* encoder bandwidth */
Vinod Koul12ac0b562011-09-02 11:36:22 +0530312 int reserved[15];
313};
314
Vinod Koulf15a95c2011-09-09 06:03:51 +0530315union snd_codec_options {
316 struct snd_enc_wma wma;
317 struct snd_enc_vorbis vorbis;
318 struct snd_enc_real real;
319 struct snd_enc_flac flac;
320 struct snd_enc_generic generic;
Vinod Koul12ac0b562011-09-02 11:36:22 +0530321};
322
Vinod Koulf15a95c2011-09-09 06:03:51 +0530323/** struct snd_codec_desc - description of codec capabilities
324 * @max_ch: Maximum number of audio channels
325 * @sample_rates: Sampling rates in Hz, use SNDRV_PCM_RATE_xxx for this
326 * @bit_rate: Indexed array containing supported bit rates
327 * @num_bitrates: Number of valid values in bit_rate array
328 * @rate_control: value is specified by SND_RATECONTROLMODE defines.
329 * @profiles: Supported profiles. See SND_AUDIOPROFILE defines.
330 * @modes: Supported modes. See SND_AUDIOMODE defines
331 * @formats: Supported formats. See SND_AUDIOSTREAMFORMAT defines
Vinod Koul12ac0b562011-09-02 11:36:22 +0530332 * @reserved: reserved for future use
333 *
Vinod Koulf15a95c2011-09-09 06:03:51 +0530334 * This structure provides a scalar value for profiles, modes and stream
335 * format fields.
336 * If an implementation supports multiple combinations, they will be listed as
337 * codecs with different descriptors, for example there would be 2 descriptors
338 * for AAC-RAW and AAC-ADTS.
339 * This entails some redundancy but makes it easier to avoid invalid
340 * configurations.
Vinod Koul12ac0b562011-09-02 11:36:22 +0530341 *
342 */
343
Vinod Koulf15a95c2011-09-09 06:03:51 +0530344struct snd_codec_desc {
345 __u32 max_ch;
346 __u32 sample_rates;
347 __u32 bit_rate[MAX_NUM_BITRATES];
348 __u32 num_bitrates;
349 __u32 rate_control;
350 __u32 profiles;
351 __u32 modes;
352 __u32 formats;
Vinod Koul12ac0b562011-09-02 11:36:22 +0530353 __u32 reserved[16];
354};
355
Vinod Koulf15a95c2011-09-09 06:03:51 +0530356/** struct snd_codec
357 * @id: Identifies the supported audio encoder/decoder.
358 * See SND_AUDIOCODEC macros.
359 * @ch_in: Number of input audio channels
360 * @ch_out: Number of output channels. In case of contradiction between
361 * this field and the channelMode field, the channelMode field
362 * overrides.
363 * @sample_rate: Audio sample rate of input data
364 * @bit_rate: Bitrate of encoded data. May be ignored by decoders
365 * @rate_control: Encoding rate control. See SND_RATECONTROLMODE defines.
Vinod Koul12ac0b562011-09-02 11:36:22 +0530366 * Encoders may rely on profiles for quality levels.
367 * May be ignored by decoders.
Vinod Koulf15a95c2011-09-09 06:03:51 +0530368 * @profile: Mandatory for encoders, can be mandatory for specific
369 * decoders as well. See SND_AUDIOPROFILE defines.
370 * @level: Supported level (Only used by WMA at the moment)
371 * @ch_mode: Channel mode for encoder. See SND_AUDIOCHANMODE defines
372 * @format: Format of encoded bistream. Mandatory when defined.
373 * See SND_AUDIOSTREAMFORMAT defines.
374 * @align: Block alignment in bytes of an audio sample.
375 * Only required for PCM or IEC formats.
Vinod Koul12ac0b562011-09-02 11:36:22 +0530376 * @options: encoder-specific settings
377 * @reserved: reserved for future use
378 */
379
Vinod Koulf15a95c2011-09-09 06:03:51 +0530380struct snd_codec {
381 __u32 id;
382 __u32 ch_in;
383 __u32 ch_out;
384 __u32 sample_rate;
385 __u32 bit_rate;
386 __u32 rate_control;
387 __u32 profile;
388 __u32 level;
389 __u32 ch_mode;
390 __u32 format;
391 __u32 align;
392 union snd_codec_options options;
Vinod Koul12ac0b562011-09-02 11:36:22 +0530393 __u32 reserved[3];
394};