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