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