1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) AND MIT) */
2 /*
3  *  compress_params.h - codec types and parameters for compressed data
4  *  streaming interface
5  *
6  *  Copyright (C) 2011 Intel Corporation
7  *  Authors:	Pierre-Louis Bossart <[email protected]>
8  *              Vinod Koul <[email protected]>
9  *
10  *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11  *
12  *  This program is free software; you can redistribute it and/or modify
13  *  it under the terms of the GNU General Public License as published by
14  *  the Free Software Foundation; version 2 of the License.
15  *
16  *  This program is distributed in the hope that it will be useful, but
17  *  WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  *  General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License along
22  *  with this program; if not, write to the Free Software Foundation, Inc.,
23  *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24  *
25  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26  *
27  * The definitions in this file are derived from the OpenMAX AL version 1.1
28  * and OpenMAX IL v 1.1.2 header files which contain the copyright notice below.
29  *
30  * Copyright (c) 2007-2010 The Khronos Group Inc.
31  *
32  * Permission is hereby granted, free of charge, to any person obtaining
33  * a copy of this software and/or associated documentation files (the
34  * "Materials "), to deal in the Materials without restriction, including
35  * without limitation the rights to use, copy, modify, merge, publish,
36  * distribute, sublicense, and/or sell copies of the Materials, and to
37  * permit persons to whom the Materials are furnished to do so, subject to
38  * the following conditions:
39  *
40  * The above copyright notice and this permission notice shall be included
41  * in all copies or substantial portions of the Materials.
42  *
43  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
44  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
47  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
48  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
49  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
50  *
51  */
52 #ifndef __SND_COMPRESS_PARAMS_H
53 #define __SND_COMPRESS_PARAMS_H
54 
55 #include <linux/types.h>
56 
57 #define SND_DEC_DDP_MAX_PARAMS 18
58 
59 /* Maximum PCM channels */
60 #define MAX_PCM_DECODE_CHANNELS 32
61 
62 /* AUDIO CODECS SUPPORTED */
63 #define MAX_NUM_CODECS 32
64 #define MAX_NUM_CODEC_DESCRIPTORS 32
65 #define MAX_NUM_BITRATES 32
66 #define MAX_NUM_SAMPLE_RATES 32
67 
68 /* compressed TX */
69 #define MAX_NUM_FRAMES_PER_BUFFER 1
70 #define COMPRESSED_META_DATA_MODE 0x10
71 #define META_DATA_LEN_BYTES 36
72 #define Q6_AC3_DECODER	0x00010BF6
73 #define Q6_EAC3_DECODER 0x00010C3C
74 #define Q6_DTS		0x00010D88
75 #define Q6_DTS_LBR	0x00010DBB
76 
77 /* Timestamp flsg */
78 /* Bit-0 - 1 : Enable Timestamp mode */
79 /* Bit-0 - 0 : Disable Timestamp mode */
80 #define COMPRESSED_TIMESTAMP_FLAG 0x0001
81 
82 /* Perf mode flag */
83 /* Bit-1 - 1 : Enable perf mode */
84 /* Bit-1 - 0 : Disable perf mode */
85 #define COMPRESSED_PERF_MODE_FLAG 0x0002
86 
87 /* Codecs are listed linearly to allow for extensibility */
88 #define SND_AUDIOCODEC_PCM                   ((__u32) 0x00000001)
89 #define SND_AUDIOCODEC_MP3                   ((__u32) 0x00000002)
90 #define SND_AUDIOCODEC_AMR                   ((__u32) 0x00000003)
91 #define SND_AUDIOCODEC_AMRWB                 ((__u32) 0x00000004)
92 #define SND_AUDIOCODEC_AMRWBPLUS             ((__u32) 0x00000005)
93 #define SND_AUDIOCODEC_AAC                   ((__u32) 0x00000006)
94 #define SND_AUDIOCODEC_WMA                   ((__u32) 0x00000007)
95 #define SND_AUDIOCODEC_REAL                  ((__u32) 0x00000008)
96 #define SND_AUDIOCODEC_VORBIS                ((__u32) 0x00000009)
97 #define SND_AUDIOCODEC_FLAC                  ((__u32) 0x0000000A)
98 #define SND_AUDIOCODEC_IEC61937              ((__u32) 0x0000000B)
99 #define SND_AUDIOCODEC_G723_1                ((__u32) 0x0000000C)
100 #define SND_AUDIOCODEC_G729                  ((__u32) 0x0000000D)
101 #define SND_AUDIOCODEC_BESPOKE               ((__u32) 0x0000000E)
102 #define SND_AUDIOCODEC_DTS_PASS_THROUGH      ((__u32) 0x0000000F)
103 #define SND_AUDIOCODEC_DTS_LBR               ((__u32) 0x00000010)
104 #define SND_AUDIOCODEC_DTS_TRANSCODE_LOOPBACK ((__u32) 0x00000011)
105 #define SND_AUDIOCODEC_PASS_THROUGH          ((__u32) 0x00000012)
106 #define SND_AUDIOCODEC_MP2                   ((__u32) 0x00000013)
107 #define SND_AUDIOCODEC_DTS_LBR_PASS_THROUGH  ((__u32) 0x00000014)
108 #define SND_AUDIOCODEC_AC3                   ((__u32) 0x00000015)
109 #define SND_AUDIOCODEC_AC3_PASS_THROUGH      ((__u32) 0x00000016)
110 #define SND_AUDIOCODEC_WMA_PRO               ((__u32) 0x00000017)
111 #define SND_AUDIOCODEC_DTS                   ((__u32) 0x00000018)
112 #define SND_AUDIOCODEC_EAC3                  ((__u32) 0x00000019)
113 #define SND_AUDIOCODEC_ALAC                  ((__u32) 0x00000020)
114 #define SND_AUDIOCODEC_APE                   ((__u32) 0x00000021)
115 #define SND_AUDIOCODEC_DSD                   ((__u32) 0x00000022)
116 #define SND_AUDIOCODEC_APTX                  ((__u32) 0x00000023)
117 #define SND_AUDIOCODEC_TRUEHD                ((__u32) 0x00000024)
118 #define SND_AUDIOCODEC_MAT                   ((__u32) 0x00000025)
119 #define SND_AUDIOCODEC_THD                   ((__u32) 0x00000026)
120 #define SND_AUDIOCODEC_MAX                   SND_AUDIOCODEC_THD
121 
122 /*
123  * Profile and modes are listed with bit masks. This allows for a
124  * more compact representation of fields that will not evolve
125  * (in contrast to the list of codecs)
126  */
127 
128 #define SND_AUDIOPROFILE_PCM                 ((__u32) 0x00000001)
129 
130 /* MP3 modes are only useful for encoders */
131 #define SND_AUDIOCHANMODE_MP3_MONO           ((__u32) 0x00000001)
132 #define SND_AUDIOCHANMODE_MP3_STEREO         ((__u32) 0x00000002)
133 #define SND_AUDIOCHANMODE_MP3_JOINTSTEREO    ((__u32) 0x00000004)
134 #define SND_AUDIOCHANMODE_MP3_DUAL           ((__u32) 0x00000008)
135 
136 #define SND_AUDIOPROFILE_AMR                 ((__u32) 0x00000001)
137 
138 /* AMR modes are only useful for encoders */
139 #define SND_AUDIOMODE_AMR_DTX_OFF            ((__u32) 0x00000001)
140 #define SND_AUDIOMODE_AMR_VAD1               ((__u32) 0x00000002)
141 #define SND_AUDIOMODE_AMR_VAD2               ((__u32) 0x00000004)
142 
143 #define SND_AUDIOSTREAMFORMAT_UNDEFINED	     ((__u32) 0x00000000)
144 #define SND_AUDIOSTREAMFORMAT_CONFORMANCE    ((__u32) 0x00000001)
145 #define SND_AUDIOSTREAMFORMAT_IF1            ((__u32) 0x00000002)
146 #define SND_AUDIOSTREAMFORMAT_IF2            ((__u32) 0x00000004)
147 #define SND_AUDIOSTREAMFORMAT_FSF            ((__u32) 0x00000008)
148 #define SND_AUDIOSTREAMFORMAT_RTPPAYLOAD     ((__u32) 0x00000010)
149 #define SND_AUDIOSTREAMFORMAT_ITU            ((__u32) 0x00000020)
150 
151 #define SND_AUDIOPROFILE_AMRWB               ((__u32) 0x00000001)
152 
153 /* AMRWB modes are only useful for encoders */
154 #define SND_AUDIOMODE_AMRWB_DTX_OFF          ((__u32) 0x00000001)
155 #define SND_AUDIOMODE_AMRWB_VAD1             ((__u32) 0x00000002)
156 #define SND_AUDIOMODE_AMRWB_VAD2             ((__u32) 0x00000004)
157 
158 #define SND_AUDIOPROFILE_AMRWBPLUS           ((__u32) 0x00000001)
159 
160 #define SND_AUDIOPROFILE_AAC                 ((__u32) 0x00000001)
161 
162 /* AAC modes are required for encoders and decoders */
163 #define SND_AUDIOMODE_AAC_MAIN               ((__u32) 0x00000001)
164 #define SND_AUDIOMODE_AAC_LC                 ((__u32) 0x00000002)
165 #define SND_AUDIOMODE_AAC_SSR                ((__u32) 0x00000004)
166 #define SND_AUDIOMODE_AAC_LTP                ((__u32) 0x00000008)
167 #define SND_AUDIOMODE_AAC_HE                 ((__u32) 0x00000010)
168 #define SND_AUDIOMODE_AAC_SCALABLE           ((__u32) 0x00000020)
169 #define SND_AUDIOMODE_AAC_ERLC               ((__u32) 0x00000040)
170 #define SND_AUDIOMODE_AAC_LD                 ((__u32) 0x00000080)
171 #define SND_AUDIOMODE_AAC_HE_PS              ((__u32) 0x00000100)
172 #define SND_AUDIOMODE_AAC_HE_MPS             ((__u32) 0x00000200)
173 
174 /* AAC formats are required for encoders and decoders */
175 #define SND_AUDIOSTREAMFORMAT_MP2ADTS        ((__u32) 0x00000001)
176 #define SND_AUDIOSTREAMFORMAT_MP4ADTS        ((__u32) 0x00000002)
177 #define SND_AUDIOSTREAMFORMAT_MP4LOAS        ((__u32) 0x00000004)
178 #define SND_AUDIOSTREAMFORMAT_MP4LATM        ((__u32) 0x00000008)
179 #define SND_AUDIOSTREAMFORMAT_ADIF           ((__u32) 0x00000010)
180 #define SND_AUDIOSTREAMFORMAT_MP4FF          ((__u32) 0x00000020)
181 #define SND_AUDIOSTREAMFORMAT_RAW            ((__u32) 0x00000040)
182 
183 #define SND_AUDIOPROFILE_WMA7                ((__u32) 0x00000001)
184 #define SND_AUDIOPROFILE_WMA8                ((__u32) 0x00000002)
185 #define SND_AUDIOPROFILE_WMA9                ((__u32) 0x00000004)
186 #define SND_AUDIOPROFILE_WMA10               ((__u32) 0x00000008)
187 
188 #define SND_AUDIOMODE_WMA_LEVEL1             ((__u32) 0x00000001)
189 #define SND_AUDIOMODE_WMA_LEVEL2             ((__u32) 0x00000002)
190 #define SND_AUDIOMODE_WMA_LEVEL3             ((__u32) 0x00000004)
191 #define SND_AUDIOMODE_WMA_LEVEL4             ((__u32) 0x00000008)
192 #define SND_AUDIOMODE_WMAPRO_LEVELM0         ((__u32) 0x00000010)
193 #define SND_AUDIOMODE_WMAPRO_LEVELM1         ((__u32) 0x00000020)
194 #define SND_AUDIOMODE_WMAPRO_LEVELM2         ((__u32) 0x00000040)
195 #define SND_AUDIOMODE_WMAPRO_LEVELM3         ((__u32) 0x00000080)
196 
197 #define SND_AUDIOSTREAMFORMAT_WMA_ASF        ((__u32) 0x00000001)
198 /*
199  * Some implementations strip the ASF header and only send ASF packets
200  * to the DSP
201  */
202 #define SND_AUDIOSTREAMFORMAT_WMA_NOASF_HDR  ((__u32) 0x00000002)
203 
204 #define SND_AUDIOPROFILE_REALAUDIO           ((__u32) 0x00000001)
205 
206 #define SND_AUDIOMODE_REALAUDIO_G2           ((__u32) 0x00000001)
207 #define SND_AUDIOMODE_REALAUDIO_8            ((__u32) 0x00000002)
208 #define SND_AUDIOMODE_REALAUDIO_10           ((__u32) 0x00000004)
209 #define SND_AUDIOMODE_REALAUDIO_SURROUND     ((__u32) 0x00000008)
210 
211 #define SND_AUDIOPROFILE_VORBIS              ((__u32) 0x00000001)
212 
213 #define SND_AUDIOMODE_VORBIS                 ((__u32) 0x00000001)
214 
215 #define SND_AUDIOPROFILE_FLAC                ((__u32) 0x00000001)
216 
217 /*
218  * Define quality levels for FLAC encoders, from LEVEL0 (fast)
219  * to LEVEL8 (best)
220  */
221 #define SND_AUDIOMODE_FLAC_LEVEL0            ((__u32) 0x00000001)
222 #define SND_AUDIOMODE_FLAC_LEVEL1            ((__u32) 0x00000002)
223 #define SND_AUDIOMODE_FLAC_LEVEL2            ((__u32) 0x00000004)
224 #define SND_AUDIOMODE_FLAC_LEVEL3            ((__u32) 0x00000008)
225 #define SND_AUDIOMODE_FLAC_LEVEL4            ((__u32) 0x00000010)
226 #define SND_AUDIOMODE_FLAC_LEVEL5            ((__u32) 0x00000020)
227 #define SND_AUDIOMODE_FLAC_LEVEL6            ((__u32) 0x00000040)
228 #define SND_AUDIOMODE_FLAC_LEVEL7            ((__u32) 0x00000080)
229 #define SND_AUDIOMODE_FLAC_LEVEL8            ((__u32) 0x00000100)
230 
231 #define SND_AUDIOSTREAMFORMAT_FLAC           ((__u32) 0x00000001)
232 #define SND_AUDIOSTREAMFORMAT_FLAC_OGG       ((__u32) 0x00000002)
233 
234 /* IEC61937 payloads without CUVP and preambles */
235 #define SND_AUDIOPROFILE_IEC61937            ((__u32) 0x00000001)
236 /* IEC61937 with S/PDIF preambles+CUVP bits in 32-bit containers */
237 #define SND_AUDIOPROFILE_IEC61937_SPDIF      ((__u32) 0x00000002)
238 
239 /*
240  * IEC modes are mandatory for decoders. Format autodetection
241  * will only happen on the DSP side with mode 0. The PCM mode should
242  * not be used, the PCM codec should be used instead.
243  */
244 #define SND_AUDIOMODE_IEC_REF_STREAM_HEADER  ((__u32) 0x00000000)
245 #define SND_AUDIOMODE_IEC_LPCM		     ((__u32) 0x00000001)
246 #define SND_AUDIOMODE_IEC_AC3		     ((__u32) 0x00000002)
247 #define SND_AUDIOMODE_IEC_MPEG1		     ((__u32) 0x00000004)
248 #define SND_AUDIOMODE_IEC_MP3		     ((__u32) 0x00000008)
249 #define SND_AUDIOMODE_IEC_MPEG2		     ((__u32) 0x00000010)
250 #define SND_AUDIOMODE_IEC_AACLC		     ((__u32) 0x00000020)
251 #define SND_AUDIOMODE_IEC_DTS		     ((__u32) 0x00000040)
252 #define SND_AUDIOMODE_IEC_ATRAC		     ((__u32) 0x00000080)
253 #define SND_AUDIOMODE_IEC_SACD		     ((__u32) 0x00000100)
254 #define SND_AUDIOMODE_IEC_EAC3		     ((__u32) 0x00000200)
255 #define SND_AUDIOMODE_IEC_DTS_HD	     ((__u32) 0x00000400)
256 #define SND_AUDIOMODE_IEC_MLP		     ((__u32) 0x00000800)
257 #define SND_AUDIOMODE_IEC_DST		     ((__u32) 0x00001000)
258 #define SND_AUDIOMODE_IEC_WMAPRO	     ((__u32) 0x00002000)
259 #define SND_AUDIOMODE_IEC_REF_CXT            ((__u32) 0x00004000)
260 #define SND_AUDIOMODE_IEC_HE_AAC	     ((__u32) 0x00008000)
261 #define SND_AUDIOMODE_IEC_HE_AAC2	     ((__u32) 0x00010000)
262 #define SND_AUDIOMODE_IEC_MPEG_SURROUND	     ((__u32) 0x00020000)
263 
264 #define SND_AUDIOPROFILE_G723_1              ((__u32) 0x00000001)
265 
266 #define SND_AUDIOMODE_G723_1_ANNEX_A         ((__u32) 0x00000001)
267 #define SND_AUDIOMODE_G723_1_ANNEX_B         ((__u32) 0x00000002)
268 #define SND_AUDIOMODE_G723_1_ANNEX_C         ((__u32) 0x00000004)
269 
270 #define SND_AUDIOPROFILE_G729                ((__u32) 0x00000001)
271 
272 #define SND_AUDIOMODE_G729_ANNEX_A           ((__u32) 0x00000001)
273 #define SND_AUDIOMODE_G729_ANNEX_B           ((__u32) 0x00000002)
274 
275 /* <FIXME: multichannel encoders aren't supported for now. Would need
276    an additional definition of channel arrangement> */
277 
278 /* VBR/CBR definitions */
279 #define SND_RATECONTROLMODE_CONSTANTBITRATE  ((__u32) 0x00000001)
280 #define SND_RATECONTROLMODE_VARIABLEBITRATE  ((__u32) 0x00000002)
281 
282 /* Encoder options */
283 
284 struct snd_enc_wma {
285 	__u32 super_block_align; /* WMA Type-specific data */
286 	__u32 bits_per_sample;
287 	__u32 channelmask;
288 	__u32 encodeopt;
289 	__u32 encodeopt1;
290 	__u32 encodeopt2;
291 	__u32 avg_bit_rate;
292 };
293 
294 
295 /**
296  * struct snd_enc_vorbis
297  * @quality: Sets encoding quality to n, between -1 (low) and 10 (high).
298  * In the default mode of operation, the quality level is 3.
299  * Normal quality range is 0 - 10.
300  * @managed: Boolean. Set  bitrate  management  mode. This turns off the
301  * normal VBR encoding, but allows hard or soft bitrate constraints to be
302  * enforced by the encoder. This mode can be slower, and may also be
303  * lower quality. It is primarily useful for streaming.
304  * @max_bit_rate: Enabled only if managed is TRUE
305  * @min_bit_rate: Enabled only if managed is TRUE
306  * @downmix: Boolean. Downmix input from stereo to mono (has no effect on
307  * non-stereo streams). Useful for lower-bitrate encoding.
308  *
309  * These options were extracted from the OpenMAX IL spec and Gstreamer vorbisenc
310  * properties
311  *
312  * For best quality users should specify VBR mode and set quality levels.
313  */
314 
315 struct snd_enc_vorbis {
316 	__s32 quality;
317 	__u32 managed;
318 	__u32 max_bit_rate;
319 	__u32 min_bit_rate;
320 	__u32 downmix;
321 } __attribute__((packed, aligned(4)));
322 
323 
324 /**
325  * struct snd_enc_real
326  * @quant_bits: number of coupling quantization bits in the stream
327  * @start_region: coupling start region in the stream
328  * @num_regions: number of regions value
329  *
330  * These options were extracted from the OpenMAX IL spec
331  */
332 
333 struct snd_enc_real {
334 	__u32 quant_bits;
335 	__u32 start_region;
336 	__u32 num_regions;
337 } __attribute__((packed, aligned(4)));
338 
339 /**
340  * struct snd_enc_flac
341  * @num: serial number, valid only for OGG formats
342  *	needs to be set by application
343  * @gain: Add replay gain tags
344  *
345  * These options were extracted from the FLAC online documentation
346  * at http://flac.sourceforge.net/documentation_tools_flac.html
347  *
348  * To make the API simpler, it is assumed that the user will select quality
349  * profiles. Additional options that affect encoding quality and speed can
350  * be added at a later stage if needed.
351  *
352  * By default the Subset format is used by encoders.
353  *
354  * TAGS such as pictures, etc, cannot be handled by an offloaded encoder and are
355  * not supported in this API.
356  */
357 
358 struct snd_enc_flac {
359 	__u32 num;
360 	__u32 gain;
361 } __attribute__((packed, aligned(4)));
362 
363 struct snd_enc_generic {
364 	__u32 bw;	/* encoder bandwidth */
365 	__s32 reserved[15];	/* Can be used for SND_AUDIOCODEC_BESPOKE */
366 } __attribute__((packed, aligned(4)));
367 
368 struct snd_dec_ddp {
369 	__u32 params_length;
370 	__u32 params_id[SND_DEC_DDP_MAX_PARAMS];
371 	__u32 params_value[SND_DEC_DDP_MAX_PARAMS];
372 } __attribute__((packed, aligned(4)));
373 
374 #define SND_DEC_THD_MAX_PARAMS 8
375 struct snd_dec_thd {
376 	__u32 params_length;
377 	__u32 params_id[SND_DEC_THD_MAX_PARAMS];
378 	__u32 params_value[SND_DEC_THD_MAX_PARAMS];
379 } __attribute__((packed, aligned(4)));
380 
381 struct snd_dec_flac {
382 	__u16 sample_size;
383 	__u16 min_blk_size;
384 	__u16 max_blk_size;
385 	__u16 min_frame_size;
386 	__u16 max_frame_size;
387 } __attribute__((packed, aligned(4)));
388 
389 struct snd_dec_vorbis {
390 	__u32 bit_stream_fmt;
391 };
392 
393 struct snd_dec_alac {
394 	__u32 frame_length;
395 	__u8 compatible_version;
396 	__u8 bit_depth;
397 	__u8 pb;
398 	__u8 mb;
399 	__u8 kb;
400 	__u8 num_channels;
401 	__u16 max_run;
402 	__u32 max_frame_bytes;
403 	__u32 avg_bit_rate;
404 	__u32 sample_rate;
405 	__u32 channel_layout_tag;
406 };
407 
408 struct snd_dec_ape {
409 	__u16 compatible_version;
410 	__u16 compression_level;
411 	__u32 format_flags;
412 	__u32 blocks_per_frame;
413 	__u32 final_frame_blocks;
414 	__u32 total_frames;
415 	__u16 bits_per_sample;
416 	__u16 num_channels;
417 	__u32 sample_rate;
418 	__u32 seek_table_present;
419 };
420 
421 struct snd_dec_aptx {
422 	__u32 lap;
423 	__u32 uap;
424 	__u32 nap;
425 };
426 
427 /** struct snd_dec_dsd - codec for DSD format
428  * @blk_size - dsd channel block size
429  */
430 struct snd_dec_dsd {
431 	__u32 blk_size;
432 };
433 
434 /** struct snd_dec_pcm - codec options for PCM format
435  * @num_channels: Number of channels
436  * @ch_map: Channel map for the above corresponding channels
437  */
438 struct snd_dec_pcm {
439 	__u32 num_channels;
440 	__u8 ch_map[MAX_PCM_DECODE_CHANNELS];
441 } __attribute__((packed, aligned(4)));
442 
443 struct snd_dec_amrwb_plus {
444 	__u32 bit_stream_fmt;
445 };
446 
447 union snd_codec_options {
448 	struct snd_enc_wma wma;
449 	struct snd_enc_vorbis vorbis;
450 	struct snd_enc_real real;
451 	struct snd_enc_flac flac;
452 	struct snd_enc_generic generic;
453 	struct snd_dec_ddp ddp;
454 	struct snd_dec_flac flac_dec;
455 	struct snd_dec_vorbis vorbis_dec;
456 	struct snd_dec_alac alac;
457 	struct snd_dec_ape ape;
458 	struct snd_dec_aptx aptx_dec;
459 	struct snd_dec_thd truehd;
460 	struct snd_dec_pcm pcm_dec;
461 	struct snd_dec_amrwb_plus amrwbplus;
462 	struct snd_dec_dsd dsd_dec;
463 };
464 
465 /** struct snd_codec_desc - description of codec capabilities
466  * @max_ch: Maximum number of audio channels
467  * @sample_rates: Sampling rates in Hz, use values like 48000 for this
468  * @num_sample_rates: Number of valid values in sample_rates array
469  * @bit_rate: Indexed array containing supported bit rates
470  * @num_bitrates: Number of valid values in bit_rate array
471  * @rate_control: value is specified by SND_RATECONTROLMODE defines.
472  * @profiles: Supported profiles. See SND_AUDIOPROFILE defines.
473  * @modes: Supported modes. See SND_AUDIOMODE defines
474  * @formats: Supported formats. See SND_AUDIOSTREAMFORMAT defines
475  * @min_buffer: Minimum buffer size handled by codec implementation
476  * @reserved: reserved for future use
477  *
478  * This structure provides a scalar value for profiles, modes and stream
479  * format fields.
480  * If an implementation supports multiple combinations, they will be listed as
481  * codecs with different descriptors, for example there would be 2 descriptors
482  * for AAC-RAW and AAC-ADTS.
483  * This entails some redundancy but makes it easier to avoid invalid
484  * configurations.
485  *
486  */
487 
488 struct snd_codec_desc {
489 	__u32 max_ch;
490 	__u32 sample_rates[MAX_NUM_SAMPLE_RATES];
491 	__u32 num_sample_rates;
492 	__u32 bit_rate[MAX_NUM_BITRATES];
493 	__u32 num_bitrates;
494 	__u32 rate_control;
495 	__u32 profiles;
496 	__u32 modes;
497 	__u32 formats;
498 	__u32 min_buffer;
499 	__u32 reserved[15];
500 } __attribute__((packed, aligned(4)));
501 
502 /** struct snd_codec
503  * @id: Identifies the supported audio encoder/decoder.
504  *		See SND_AUDIOCODEC macros.
505  * @ch_in: Number of input audio channels
506  * @ch_out: Number of output channels. In case of contradiction between
507  *		this field and the channelMode field, the channelMode field
508  *		overrides.
509  * @sample_rate: Audio sample rate of input data in Hz, use values like 48000
510  *		for this.
511  * @bit_rate: Bitrate of encoded data. May be ignored by decoders
512  * @rate_control: Encoding rate control. See SND_RATECONTROLMODE defines.
513  *               Encoders may rely on profiles for quality levels.
514  *		 May be ignored by decoders.
515  * @profile: Mandatory for encoders, can be mandatory for specific
516  *		decoders as well. See SND_AUDIOPROFILE defines.
517  * @level: Supported level (Only used by WMA at the moment)
518  * @ch_mode: Channel mode for encoder. See SND_AUDIOCHANMODE defines
519  * @format: Format of encoded bistream. Mandatory when defined.
520  *		See SND_AUDIOSTREAMFORMAT defines.
521  * @align: Block alignment in bytes of an audio sample.
522  *		Only required for PCM or IEC formats.
523  * @options: encoder-specific settings
524  * @compr_passthr: compressed bitstream passthrough
525  * @reserved: reserved for future use
526  */
527 
528 struct snd_codec {
529 	__u32 id;
530 	__u32 ch_in;
531 	__u32 ch_out;
532 	__u32 sample_rate;
533 	__u32 bit_rate;
534 	__u32 rate_control;
535 	__u32 profile;
536 	__u32 level;
537 	__u32 ch_mode;
538 	__u32 format;
539 	__u32 align;
540 	union snd_codec_options options;
541 	__u32 compr_passthr;
542 	__u32 flags;
543 	__u32 reserved[1];
544 } __attribute__((packed, aligned(4)));
545 
546 
547 /** struct snd_codec_metadata
548  * @length: Length of the encoded buffer.
549  * @offset: Offset from the buffer address to the first byte of the first
550  *		encoded frame. All encoded frames are consecutive starting
551  *		from this offset.
552  * @timestamp: Session time in microseconds of the first sample in the buffer.
553  * @reserved: Reserved for future use.
554  */
555 struct snd_codec_metadata {
556 	__u32 length;
557 	__u32 offset;
558 	__u64 timestamp;
559 	__u32 flags;
560 	__u32 reserved[3];
561 };
562 
563 #endif
564