• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  compress_params.h - codec types and parameters for compressed data
3  *  streaming interface
4  *
5  *  Copyright (C) 2011 Intel Corporation
6  *  Authors:	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
7  *              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 #ifndef __SND_COMPRESS_PARAMS_H
52 #define __SND_COMPRESS_PARAMS_H
53 
54 /* AUDIO CODECS SUPPORTED */
55 #define MAX_NUM_CODECS 32
56 #define MAX_NUM_CODEC_DESCRIPTORS 32
57 #define MAX_NUM_BITRATES 32
58 
59 /* compressed TX */
60 #define MAX_NUM_FRAMES_PER_BUFFER 1
61 #define COMPRESSED_META_DATA_MODE 0x10
62 #define META_DATA_LEN_BYTES 36
63 #define Q6_AC3_DECODER	0x00010BF6
64 #define Q6_EAC3_DECODER 0x00010C3C
65 #define Q6_DTS		0x00010D88
66 #define Q6_DTS_LBR	0x00010DBB
67 
68 /* Codecs are listed linearly to allow for extensibility */
69 #define SND_AUDIOCODEC_PCM                   ((__u32) 0x00000001)
70 #define SND_AUDIOCODEC_MP3                   ((__u32) 0x00000002)
71 #define SND_AUDIOCODEC_AMR                   ((__u32) 0x00000003)
72 #define SND_AUDIOCODEC_AMRWB                 ((__u32) 0x00000004)
73 #define SND_AUDIOCODEC_AMRWBPLUS             ((__u32) 0x00000005)
74 #define SND_AUDIOCODEC_AAC                   ((__u32) 0x00000006)
75 #define SND_AUDIOCODEC_WMA                   ((__u32) 0x00000007)
76 #define SND_AUDIOCODEC_REAL                  ((__u32) 0x00000008)
77 #define SND_AUDIOCODEC_VORBIS                ((__u32) 0x00000009)
78 #define SND_AUDIOCODEC_FLAC                  ((__u32) 0x0000000A)
79 #define SND_AUDIOCODEC_IEC61937              ((__u32) 0x0000000B)
80 #define SND_AUDIOCODEC_G723_1                ((__u32) 0x0000000C)
81 #define SND_AUDIOCODEC_G729                  ((__u32) 0x0000000D)
82 #define SND_AUDIOCODEC_AC3                   ((__u32) 0x0000000E)
83 #define SND_AUDIOCODEC_DTS                   ((__u32) 0x0000000F)
84 #define SND_AUDIOCODEC_AC3_PASS_THROUGH      ((__u32) 0x00000010)
85 #define SND_AUDIOCODEC_WMA_PRO               ((__u32) 0x00000011)
86 #define SND_AUDIOCODEC_DTS_PASS_THROUGH      ((__u32) 0x00000012)
87 #define SND_AUDIOCODEC_DTS_LBR               ((__u32) 0x00000013)
88 #define SND_AUDIOCODEC_DTS_TRANSCODE_LOOPBACK ((__u32) 0x00000014)
89 #define SND_AUDIOCODEC_MAX                   SND_AUDIOCODEC_DTS_TRANSCODE_LOOPBACK
90 
91 /*
92  * Profile and modes are listed with bit masks. This allows for a
93  * more compact representation of fields that will not evolve
94  * (in contrast to the list of codecs)
95  */
96 
97 #define SND_AUDIOPROFILE_PCM                 ((__u32) 0x00000001)
98 
99 /* MP3 modes are only useful for encoders */
100 #define SND_AUDIOCHANMODE_MP3_MONO           ((__u32) 0x00000001)
101 #define SND_AUDIOCHANMODE_MP3_STEREO         ((__u32) 0x00000002)
102 #define SND_AUDIOCHANMODE_MP3_JOINTSTEREO    ((__u32) 0x00000004)
103 #define SND_AUDIOCHANMODE_MP3_DUAL           ((__u32) 0x00000008)
104 
105 #define SND_AUDIOPROFILE_AMR                 ((__u32) 0x00000001)
106 
107 /* AMR modes are only useful for encoders */
108 #define SND_AUDIOMODE_AMR_DTX_OFF            ((__u32) 0x00000001)
109 #define SND_AUDIOMODE_AMR_VAD1               ((__u32) 0x00000002)
110 #define SND_AUDIOMODE_AMR_VAD2               ((__u32) 0x00000004)
111 
112 #define SND_AUDIOSTREAMFORMAT_UNDEFINED	     ((__u32) 0x00000000)
113 #define SND_AUDIOSTREAMFORMAT_CONFORMANCE    ((__u32) 0x00000001)
114 #define SND_AUDIOSTREAMFORMAT_IF1            ((__u32) 0x00000002)
115 #define SND_AUDIOSTREAMFORMAT_IF2            ((__u32) 0x00000004)
116 #define SND_AUDIOSTREAMFORMAT_FSF            ((__u32) 0x00000008)
117 #define SND_AUDIOSTREAMFORMAT_RTPPAYLOAD     ((__u32) 0x00000010)
118 #define SND_AUDIOSTREAMFORMAT_ITU            ((__u32) 0x00000020)
119 
120 #define SND_AUDIOPROFILE_AMRWB               ((__u32) 0x00000001)
121 
122 /* AMRWB modes are only useful for encoders */
123 #define SND_AUDIOMODE_AMRWB_DTX_OFF          ((__u32) 0x00000001)
124 #define SND_AUDIOMODE_AMRWB_VAD1             ((__u32) 0x00000002)
125 #define SND_AUDIOMODE_AMRWB_VAD2             ((__u32) 0x00000004)
126 
127 #define SND_AUDIOPROFILE_AMRWBPLUS           ((__u32) 0x00000001)
128 
129 #define SND_AUDIOPROFILE_AAC                 ((__u32) 0x00000001)
130 
131 /* AAC modes are required for encoders and decoders */
132 #define SND_AUDIOMODE_AAC_MAIN               ((__u32) 0x00000001)
133 #define SND_AUDIOMODE_AAC_LC                 ((__u32) 0x00000002)
134 #define SND_AUDIOMODE_AAC_SSR                ((__u32) 0x00000004)
135 #define SND_AUDIOMODE_AAC_LTP                ((__u32) 0x00000008)
136 #define SND_AUDIOMODE_AAC_HE                 ((__u32) 0x00000010)
137 #define SND_AUDIOMODE_AAC_SCALABLE           ((__u32) 0x00000020)
138 #define SND_AUDIOMODE_AAC_ERLC               ((__u32) 0x00000040)
139 #define SND_AUDIOMODE_AAC_LD                 ((__u32) 0x00000080)
140 #define SND_AUDIOMODE_AAC_HE_PS              ((__u32) 0x00000100)
141 #define SND_AUDIOMODE_AAC_HE_MPS             ((__u32) 0x00000200)
142 
143 /* AAC formats are required for encoders and decoders */
144 #define SND_AUDIOSTREAMFORMAT_MP2ADTS        ((__u32) 0x00000001)
145 #define SND_AUDIOSTREAMFORMAT_MP4ADTS        ((__u32) 0x00000002)
146 #define SND_AUDIOSTREAMFORMAT_MP4LOAS        ((__u32) 0x00000004)
147 #define SND_AUDIOSTREAMFORMAT_MP4LATM        ((__u32) 0x00000008)
148 #define SND_AUDIOSTREAMFORMAT_ADIF           ((__u32) 0x00000010)
149 #define SND_AUDIOSTREAMFORMAT_MP4FF          ((__u32) 0x00000020)
150 #define SND_AUDIOSTREAMFORMAT_RAW            ((__u32) 0x00000040)
151 
152 #define SND_AUDIOPROFILE_WMA7                ((__u32) 0x00000001)
153 #define SND_AUDIOPROFILE_WMA8                ((__u32) 0x00000002)
154 #define SND_AUDIOPROFILE_WMA9                ((__u32) 0x00000004)
155 #define SND_AUDIOPROFILE_WMA10               ((__u32) 0x00000008)
156 
157 #define SND_AUDIOMODE_WMA_LEVEL1             ((__u32) 0x00000001)
158 #define SND_AUDIOMODE_WMA_LEVEL2             ((__u32) 0x00000002)
159 #define SND_AUDIOMODE_WMA_LEVEL3             ((__u32) 0x00000004)
160 #define SND_AUDIOMODE_WMA_LEVEL4             ((__u32) 0x00000008)
161 #define SND_AUDIOMODE_WMAPRO_LEVELM0         ((__u32) 0x00000010)
162 #define SND_AUDIOMODE_WMAPRO_LEVELM1         ((__u32) 0x00000020)
163 #define SND_AUDIOMODE_WMAPRO_LEVELM2         ((__u32) 0x00000040)
164 #define SND_AUDIOMODE_WMAPRO_LEVELM3         ((__u32) 0x00000080)
165 
166 #define SND_AUDIOSTREAMFORMAT_WMA_ASF        ((__u32) 0x00000001)
167 /*
168  * Some implementations strip the ASF header and only send ASF packets
169  * to the DSP
170  */
171 #define SND_AUDIOSTREAMFORMAT_WMA_NOASF_HDR  ((__u32) 0x00000002)
172 
173 #define SND_AUDIOPROFILE_REALAUDIO           ((__u32) 0x00000001)
174 
175 #define SND_AUDIOMODE_REALAUDIO_G2           ((__u32) 0x00000001)
176 #define SND_AUDIOMODE_REALAUDIO_8            ((__u32) 0x00000002)
177 #define SND_AUDIOMODE_REALAUDIO_10           ((__u32) 0x00000004)
178 #define SND_AUDIOMODE_REALAUDIO_SURROUND     ((__u32) 0x00000008)
179 
180 #define SND_AUDIOPROFILE_VORBIS              ((__u32) 0x00000001)
181 
182 #define SND_AUDIOMODE_VORBIS                 ((__u32) 0x00000001)
183 
184 #define SND_AUDIOPROFILE_FLAC                ((__u32) 0x00000001)
185 
186 /*
187  * Define quality levels for FLAC encoders, from LEVEL0 (fast)
188  * to LEVEL8 (best)
189  */
190 #define SND_AUDIOMODE_FLAC_LEVEL0            ((__u32) 0x00000001)
191 #define SND_AUDIOMODE_FLAC_LEVEL1            ((__u32) 0x00000002)
192 #define SND_AUDIOMODE_FLAC_LEVEL2            ((__u32) 0x00000004)
193 #define SND_AUDIOMODE_FLAC_LEVEL3            ((__u32) 0x00000008)
194 #define SND_AUDIOMODE_FLAC_LEVEL4            ((__u32) 0x00000010)
195 #define SND_AUDIOMODE_FLAC_LEVEL5            ((__u32) 0x00000020)
196 #define SND_AUDIOMODE_FLAC_LEVEL6            ((__u32) 0x00000040)
197 #define SND_AUDIOMODE_FLAC_LEVEL7            ((__u32) 0x00000080)
198 #define SND_AUDIOMODE_FLAC_LEVEL8            ((__u32) 0x00000100)
199 
200 #define SND_AUDIOSTREAMFORMAT_FLAC           ((__u32) 0x00000001)
201 #define SND_AUDIOSTREAMFORMAT_FLAC_OGG       ((__u32) 0x00000002)
202 
203 /* IEC61937 payloads without CUVP and preambles */
204 #define SND_AUDIOPROFILE_IEC61937            ((__u32) 0x00000001)
205 /* IEC61937 with S/PDIF preambles+CUVP bits in 32-bit containers */
206 #define SND_AUDIOPROFILE_IEC61937_SPDIF      ((__u32) 0x00000002)
207 
208 /*
209  * IEC modes are mandatory for decoders. Format autodetection
210  * will only happen on the DSP side with mode 0. The PCM mode should
211  * not be used, the PCM codec should be used instead.
212  */
213 #define SND_AUDIOMODE_IEC_REF_STREAM_HEADER  ((__u32) 0x00000000)
214 #define SND_AUDIOMODE_IEC_LPCM		     ((__u32) 0x00000001)
215 #define SND_AUDIOMODE_IEC_AC3		     ((__u32) 0x00000002)
216 #define SND_AUDIOMODE_IEC_MPEG1		     ((__u32) 0x00000004)
217 #define SND_AUDIOMODE_IEC_MP3		     ((__u32) 0x00000008)
218 #define SND_AUDIOMODE_IEC_MPEG2		     ((__u32) 0x00000010)
219 #define SND_AUDIOMODE_IEC_AACLC		     ((__u32) 0x00000020)
220 #define SND_AUDIOMODE_IEC_DTS		     ((__u32) 0x00000040)
221 #define SND_AUDIOMODE_IEC_ATRAC		     ((__u32) 0x00000080)
222 #define SND_AUDIOMODE_IEC_SACD		     ((__u32) 0x00000100)
223 #define SND_AUDIOMODE_IEC_EAC3		     ((__u32) 0x00000200)
224 #define SND_AUDIOMODE_IEC_DTS_HD	     ((__u32) 0x00000400)
225 #define SND_AUDIOMODE_IEC_MLP		     ((__u32) 0x00000800)
226 #define SND_AUDIOMODE_IEC_DST		     ((__u32) 0x00001000)
227 #define SND_AUDIOMODE_IEC_WMAPRO	     ((__u32) 0x00002000)
228 #define SND_AUDIOMODE_IEC_REF_CXT            ((__u32) 0x00004000)
229 #define SND_AUDIOMODE_IEC_HE_AAC	     ((__u32) 0x00008000)
230 #define SND_AUDIOMODE_IEC_HE_AAC2	     ((__u32) 0x00010000)
231 #define SND_AUDIOMODE_IEC_MPEG_SURROUND	     ((__u32) 0x00020000)
232 
233 #define SND_AUDIOPROFILE_G723_1              ((__u32) 0x00000001)
234 
235 #define SND_AUDIOMODE_G723_1_ANNEX_A         ((__u32) 0x00000001)
236 #define SND_AUDIOMODE_G723_1_ANNEX_B         ((__u32) 0x00000002)
237 #define SND_AUDIOMODE_G723_1_ANNEX_C         ((__u32) 0x00000004)
238 
239 #define SND_AUDIOPROFILE_G729                ((__u32) 0x00000001)
240 
241 #define SND_AUDIOMODE_G729_ANNEX_A           ((__u32) 0x00000001)
242 #define SND_AUDIOMODE_G729_ANNEX_B           ((__u32) 0x00000002)
243 
244 /* <FIXME: multichannel encoders aren't supported for now. Would need
245    an additional definition of channel arrangement> */
246 
247 /* VBR/CBR definitions */
248 #define SND_RATECONTROLMODE_CONSTANTBITRATE  ((__u32) 0x00000001)
249 #define SND_RATECONTROLMODE_VARIABLEBITRATE  ((__u32) 0x00000002)
250 
251 /* Encoder options */
252 
253 struct snd_enc_wma {
254 	__u32 super_block_align; /* WMA Type-specific data */
255 	__u32 bits_per_sample;
256 	__u32 channelmask;
257 	__u32 encodeopt;
258 	__u32 encodeopt1;
259 	__u32 encodeopt2;
260 };
261 
262 
263 /**
264  * struct snd_enc_vorbis
265  * @quality: Sets encoding quality to n, between -1 (low) and 10 (high).
266  * In the default mode of operation, the quality level is 3.
267  * Normal quality range is 0 - 10.
268  * @managed: Boolean. Set  bitrate  management  mode. This turns off the
269  * normal VBR encoding, but allows hard or soft bitrate constraints to be
270  * enforced by the encoder. This mode can be slower, and may also be
271  * lower quality. It is primarily useful for streaming.
272  * @max_bit_rate: Enabled only if managed is TRUE
273  * @min_bit_rate: Enabled only if managed is TRUE
274  * @downmix: Boolean. Downmix input from stereo to mono (has no effect on
275  * non-stereo streams). Useful for lower-bitrate encoding.
276  *
277  * These options were extracted from the OpenMAX IL spec and Gstreamer vorbisenc
278  * properties
279  *
280  * For best quality users should specify VBR mode and set quality levels.
281  */
282 
283 struct snd_enc_vorbis {
284 	__s32 quality;
285 	__u32 managed;
286 	__u32 max_bit_rate;
287 	__u32 min_bit_rate;
288 	__u32 downmix;
289 };
290 
291 
292 /**
293  * struct snd_enc_real
294  * @quant_bits: number of coupling quantization bits in the stream
295  * @start_region: coupling start region in the stream
296  * @num_regions: number of regions value
297  *
298  * These options were extracted from the OpenMAX IL spec
299  */
300 
301 struct snd_enc_real {
302 	__u32 quant_bits;
303 	__u32 start_region;
304 	__u32 num_regions;
305 };
306 
307 /**
308  * struct snd_enc_flac
309  * @num: serial number, valid only for OGG formats
310  *	needs to be set by application
311  * @gain: Add replay gain tags
312  *
313  * These options were extracted from the FLAC online documentation
314  * at http://flac.sourceforge.net/documentation_tools_flac.html
315  *
316  * To make the API simpler, it is assumed that the user will select quality
317  * profiles. Additional options that affect encoding quality and speed can
318  * be added at a later stage if needed.
319  *
320  * By default the Subset format is used by encoders.
321  *
322  * TAGS such as pictures, etc, cannot be handled by an offloaded encoder and are
323  * not supported in this API.
324  */
325 
326 struct snd_enc_flac {
327 	__u32 num;
328 	__u32 gain;
329 };
330 
331 struct snd_enc_generic {
332 	__u32 bw;	/* encoder bandwidth */
333 	__s32 reserved[15];
334 };
335 
336 union snd_codec_options {
337 	struct snd_enc_wma wma;
338 	struct snd_enc_vorbis vorbis;
339 	struct snd_enc_real real;
340 	struct snd_enc_flac flac;
341 	struct snd_enc_generic generic;
342 };
343 
344 /** struct snd_codec_desc - description of codec capabilities
345  * @max_ch: Maximum number of audio channels
346  * @sample_rates: Sampling rates in Hz, use SNDRV_PCM_RATE_xxx for this
347  * @bit_rate: Indexed array containing supported bit rates
348  * @num_bitrates: Number of valid values in bit_rate array
349  * @rate_control: value is specified by SND_RATECONTROLMODE defines.
350  * @profiles: Supported profiles. See SND_AUDIOPROFILE defines.
351  * @modes: Supported modes. See SND_AUDIOMODE defines
352  * @formats: Supported formats. See SND_AUDIOSTREAMFORMAT defines
353  * @min_buffer: Minimum buffer size handled by codec implementation
354  * @reserved: reserved for future use
355  *
356  * This structure provides a scalar value for profiles, modes and stream
357  * format fields.
358  * If an implementation supports multiple combinations, they will be listed as
359  * codecs with different descriptors, for example there would be 2 descriptors
360  * for AAC-RAW and AAC-ADTS.
361  * This entails some redundancy but makes it easier to avoid invalid
362  * configurations.
363  *
364  */
365 
366 struct snd_codec_desc {
367 	__u32 max_ch;
368 	__u32 sample_rates;
369 	__u32 bit_rate[MAX_NUM_BITRATES];
370 	__u32 num_bitrates;
371 	__u32 rate_control;
372 	__u32 profiles;
373 	__u32 modes;
374 	__u32 formats;
375 	__u32 min_buffer;
376 	__u32 reserved[15];
377 };
378 
379 /** struct snd_codec
380  * @id: Identifies the supported audio encoder/decoder.
381  *		See SND_AUDIOCODEC macros.
382  * @ch_in: Number of input audio channels
383  * @ch_out: Number of output channels. In case of contradiction between
384  *		this field and the channelMode field, the channelMode field
385  *		overrides.
386  * @sample_rate: Audio sample rate of input data
387  * @bit_rate: Bitrate of encoded data. May be ignored by decoders
388  * @rate_control: Encoding rate control. See SND_RATECONTROLMODE defines.
389  *               Encoders may rely on profiles for quality levels.
390  *		 May be ignored by decoders.
391  * @profile: Mandatory for encoders, can be mandatory for specific
392  *		decoders as well. See SND_AUDIOPROFILE defines.
393  * @level: Supported level (Only used by WMA at the moment)
394  * @ch_mode: Channel mode for encoder. See SND_AUDIOCHANMODE defines
395  * @format: Format of encoded bistream. Mandatory when defined.
396  *		See SND_AUDIOSTREAMFORMAT defines.
397  * @align: Block alignment in bytes of an audio sample.
398  *		Only required for PCM or IEC formats.
399  * @options: encoder-specific settings
400  * @reserved: reserved for future use
401  */
402 
403 struct snd_codec {
404 	__u32 id;
405 	__u32 ch_in;
406 	__u32 ch_out;
407 	__u32 sample_rate;
408 	__u32 bit_rate;
409 	__u32 rate_control;
410 	__u32 profile;
411 	__u32 level;
412 	__u32 ch_mode;
413 	__u32 format;
414 	__u32 align;
415 	union snd_codec_options options;
416 	__u32 reserved[3];
417 };
418 
419 #endif
420