blob: e6abbc3988b106ee7c54cf5d755c1d2c27876761 [file] [log] [blame]
/*
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes from Qualcomm Innovation Center are provided under the following license:
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
/** \file pal_defs.h
* \brief struture, enum constant defintions of the
* PAL(Platform Audio Layer).
*
* This file contains macros, constants, or global variables
* exposed to the client of PAL(Platform Audio Layer).
*/
#ifndef PAL_DEFS_H
#define PAL_DEFS_H
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#ifdef __cplusplus
#include <map>
#include <string>
extern "C" {
#endif
#define MIXER_PATH_MAX_LENGTH 100
#define PAL_MAX_CHANNELS_SUPPORTED 64
#define MAX_KEYWORD_SUPPORTED 8
#define PAL_VERSION "1.0"
/** Audio stream handle */
typedef uint64_t pal_stream_handle_t;
/** Sound Trigger handle */
typedef uint64_t pal_st_handle_t;
/** PAL Audio format enumeration */
typedef enum {
PAL_AUDIO_FMT_DEFAULT_PCM = 0x1, /**< PCM*/
PAL_AUDIO_FMT_PCM_S16_LE = PAL_AUDIO_FMT_DEFAULT_PCM, /**< 16 bit little endian PCM*/
PAL_AUDIO_FMT_DEFAULT_COMPRESSED = 0x2, /**< Default Compressed*/
PAL_AUDIO_FMT_MP3 = PAL_AUDIO_FMT_DEFAULT_COMPRESSED,
PAL_AUDIO_FMT_AAC = 0x3,
PAL_AUDIO_FMT_AAC_ADTS = 0x4,
PAL_AUDIO_FMT_AAC_ADIF = 0x5,
PAL_AUDIO_FMT_AAC_LATM = 0x6,
PAL_AUDIO_FMT_WMA_STD = 0x7,
PAL_AUDIO_FMT_ALAC = 0x8,
PAL_AUDIO_FMT_APE = 0x9,
PAL_AUDIO_FMT_WMA_PRO = 0xA,
PAL_AUDIO_FMT_FLAC = 0xB,
PAL_AUDIO_FMT_FLAC_OGG = 0xC,
PAL_AUDIO_FMT_VORBIS = 0xD,
PAL_AUDIO_FMT_AMR_NB = 0xE,
PAL_AUDIO_FMT_AMR_WB = 0xF,
PAL_AUDIO_FMT_AMR_WB_PLUS = 0x10,
PAL_AUDIO_FMT_EVRC = 0x11,
PAL_AUDIO_FMT_G711 = 0x12,
PAL_AUDIO_FMT_QCELP = 0x13,
PAL_AUDIO_FMT_PCM_S8 = 0x14, /**< 8 Bit PCM*/
PAL_AUDIO_FMT_PCM_S24_3LE = 0x15, /**<24 bit packed little endian PCM*/
PAL_AUDIO_FMT_PCM_S24_LE = 0x16, /**<24bit in 32bit word (LSB aligned) little endian PCM*/
PAL_AUDIO_FMT_PCM_S32_LE = 0x17, /**< 32bit little endian PCM*/
PAL_AUDIO_FMT_NON_PCM = 0xE0000000, /* Internal Constant used for Non PCM format identification */
PAL_AUDIO_FMT_COMPRESSED_RANGE_BEGIN = 0xF0000000, /* Reserved for beginning of compressed codecs */
PAL_AUDIO_FMT_COMPRESSED_EXTENDED_RANGE_BEGIN = 0xF0000F00, /* Reserved for beginning of 3rd party codecs */
PAL_AUDIO_FMT_COMPRESSED_EXTENDED_RANGE_END = 0xF0000FFF, /* Reserved for beginning of 3rd party codecs */
PAL_AUDIO_FMT_COMPRESSED_RANGE_END = PAL_AUDIO_FMT_COMPRESSED_EXTENDED_RANGE_END /* Reserved for beginning of 3rd party codecs */
} pal_audio_fmt_t;
#define PCM_24_BIT_PACKED (0x6u)
#define PCM_32_BIT (0x3u)
#define PCM_16_BIT (0x1u)
#define SAMPLE_RATE_192000 192000
#ifdef __cplusplus
static const std::map<std::string, pal_audio_fmt_t> PalAudioFormatMap
{
{ "PCM", PAL_AUDIO_FMT_PCM_S16_LE},
{ "PCM_S8", PAL_AUDIO_FMT_PCM_S8},
{ "PCM_S16_LE", PAL_AUDIO_FMT_PCM_S16_LE},
{ "PCM_S24_3LE", PAL_AUDIO_FMT_PCM_S24_3LE},
{ "PCM_S24_LE", PAL_AUDIO_FMT_PCM_S24_LE},
{ "PCM_S32_LE", PAL_AUDIO_FMT_PCM_S32_LE},
{ "MP3", PAL_AUDIO_FMT_MP3},
{ "AAC", PAL_AUDIO_FMT_AAC},
{ "AAC_ADTS", PAL_AUDIO_FMT_AAC_ADTS},
{ "AAC_ADIF", PAL_AUDIO_FMT_AAC_ADIF},
{ "AAC_LATM", PAL_AUDIO_FMT_AAC_LATM},
{ "WMA_STD", PAL_AUDIO_FMT_WMA_STD},
{ "ALAC", PAL_AUDIO_FMT_ALAC},
{ "APE", PAL_AUDIO_FMT_APE},
{ "WMA_PRO", PAL_AUDIO_FMT_WMA_PRO},
{ "FLAC", PAL_AUDIO_FMT_FLAC},
{ "FLAC_OGG", PAL_AUDIO_FMT_FLAC_OGG},
{ "VORBIS", PAL_AUDIO_FMT_VORBIS},
{ "AMR_NB", PAL_AUDIO_FMT_AMR_NB},
{ "AMR_WB", PAL_AUDIO_FMT_AMR_WB},
{ "AMR_WB_PLUS", PAL_AUDIO_FMT_AMR_WB_PLUS},
{ "EVRC", PAL_AUDIO_FMT_EVRC},
{ "G711", PAL_AUDIO_FMT_G711},
{ "QCELP", PAL_AUDIO_FMT_QCELP}
};
#endif
struct aac_enc_cfg {
uint16_t aac_enc_mode; /**< AAC encoder mode */
uint16_t aac_fmt_flag; /**< AAC format flag */
};
struct pal_snd_enc_aac {
uint32_t aac_bit_rate;
struct aac_enc_cfg enc_cfg;
};
struct pal_snd_dec_aac {
uint16_t audio_obj_type;
uint16_t pce_bits_size;
};
struct pal_snd_dec_wma {
uint32_t fmt_tag;
uint32_t super_block_align;
uint32_t bits_per_sample;
uint32_t channelmask;
uint32_t encodeopt;
uint32_t encodeopt1;
uint32_t encodeopt2;
uint32_t avg_bit_rate;
};
struct pal_snd_dec_alac {
uint32_t frame_length;
uint8_t compatible_version;
uint8_t bit_depth;
uint8_t pb;
uint8_t mb;
uint8_t kb;
uint8_t num_channels;
uint16_t max_run;
uint32_t max_frame_bytes;
uint32_t avg_bit_rate;
uint32_t sample_rate;
uint32_t channel_layout_tag;
};
struct pal_snd_dec_ape {
uint16_t compatible_version;
uint16_t compression_level;
uint32_t format_flags;
uint32_t blocks_per_frame;
uint32_t final_frame_blocks;
uint32_t total_frames;
uint16_t bits_per_sample;
uint16_t num_channels;
uint32_t sample_rate;
uint32_t seek_table_present;
};
struct pal_snd_dec_flac {
uint16_t sample_size;
uint16_t min_blk_size;
uint16_t max_blk_size;
uint16_t min_frame_size;
uint16_t max_frame_size;
};
struct pal_snd_dec_vorbis {
uint32_t bit_stream_fmt;
};
typedef struct pal_key_value_pair_s {
uint32_t key; /**< key */
uint32_t value; /**< value */
} pal_key_value_pair_t;
typedef struct pal_key_vector_s {
size_t num_tkvs; /**< number of key value pairs */
pal_key_value_pair_t kvp[]; /**< vector of key value pairs */
} pal_key_vector_t;
typedef enum {
PARAM_NONTKV,
PARAM_TKV,
} pal_param_type_t;
typedef struct pal_effect_custom_payload_s {
uint32_t paramId;
uint32_t data[];
} pal_effect_custom_payload_t;
typedef struct effect_pal_payload_s {
pal_param_type_t isTKV; /* payload type: 0->non-tkv 1->tkv*/
uint32_t tag;
uint32_t payloadSize;
uint32_t payload[]; /* TKV uses pal_key_vector_t, while nonTKV uses pal_effect_custom_payload_t */
} effect_pal_payload_t;
/* Type of Modes for Speaker Protection */
typedef enum {
PAL_SP_MODE_DYNAMIC_CAL = 1,
PAL_SP_MODE_FACTORY_TEST,
PAL_SP_MODE_V_VALIDATION,
} pal_spkr_prot_mode;
/* Payload For ID: PAL_PARAM_ID_SP_MODE
* Description : Values for Speaker protection modes
*/
typedef struct pal_spkr_prot_payload {
uint32_t spkrHeatupTime; /* Wait time in mili seconds to heat up the
* speaker before collecting statistics */
uint32_t operationModeRunTime; /* Time period in milli seconds when
* statistics are collected */
pal_spkr_prot_mode operationMode;/* Type of mode for which request is raised */
} pal_spkr_prot_payload;
typedef enum {
GEF_PARAM_READ = 0,
GEF_PARAM_WRITE,
} gef_param_rw_t;
/** Audio parameter data*/
typedef union {
struct pal_snd_dec_aac aac_dec;
struct pal_snd_dec_wma wma_dec;
struct pal_snd_dec_alac alac_dec;
struct pal_snd_dec_ape ape_dec;
struct pal_snd_dec_flac flac_dec;
struct pal_snd_dec_vorbis vorbis_dec;
} pal_snd_dec_t;
/** Audio encoder parameter data*/
typedef union {
struct pal_snd_enc_aac aac_enc;
} pal_snd_enc_t;
/** Audio parameter data*/
typedef struct pal_param_payload_s {
uint32_t payload_size;
uint8_t payload[];
} pal_param_payload;
typedef struct gef_payload_s {
pal_key_vector_t *graph;
bool persist;
effect_pal_payload_t data;
} gef_payload_t;
typedef enum {
LPI_VOTE,
NLPI_VOTE,
AVOID_VOTE,
} vote_type_t;
/** Audio channel map enumeration*/
typedef enum {
PAL_CHMAP_CHANNEL_FL = 1, /**< Front right channel. */
PAL_CHMAP_CHANNEL_FR = 2, /**< Front center channel. */
PAL_CHMAP_CHANNEL_C = 3, /**< Left surround channel. */
PAL_CHMAP_CHANNEL_LS = 4, /** Right surround channel. */
PAL_CHMAP_CHANNEL_RS = 5, /** Low frequency effect channel. */
PAL_CHMAP_CHANNEL_LFE = 6, /** Center surround channel; */
PAL_CHMAP_CHANNEL_RC = 7, /**< rear center channel. */
PAL_CHMAP_CHANNEL_CB = PAL_CHMAP_CHANNEL_RC, /**< center back channel. */
PAL_CHMAP_CHANNEL_LB = 8, /**< rear left channel. */
PAL_CHMAP_CHANNEL_RB = 9, /**< rear right channel. */
PAL_CHMAP_CHANNEL_TS = 10, /**< Top surround channel. */
PAL_CHMAP_CHANNEL_CVH = 11, /**< Center vertical height channel.*/
PAL_CHMAP_CHANNEL_TFC = PAL_CHMAP_CHANNEL_CVH, /**< Top front center channel. */
PAL_CHMAP_CHANNEL_MS = 12, /**< Mono surround channel. */
PAL_CHMAP_CHANNEL_FLC = 13, /**< Front left of center channel. */
PAL_CHMAP_CHANNEL_FRC = 14, /**< Front right of center channel. */
PAL_CHMAP_CHANNEL_RLC = 15, /**< Rear left of center channel. */
PAL_CHMAP_CHANNEL_RRC = 16, /**< Rear right of center channel. */
PAL_CHMAP_CHANNEL_LFE2 = 17, /**< Secondary low frequency effect channel. */
PAL_CHMAP_CHANNEL_SL = 18, /**< Side left channel. */
PAL_CHMAP_CHANNEL_SR = 19, /**< Side right channel. */
PAL_CHMAP_CHANNEL_TFL = 20, /**< Top front left channel. */
PAL_CHMAP_CHANNEL_LVH = PAL_CHMAP_CHANNEL_TFL, /**< Right vertical height channel */
PAL_CHMAP_CHANNEL_TFR = 21, /**< Top front right channel. */
PAL_CHMAP_CHANNEL_RVH = PAL_CHMAP_CHANNEL_TFR, /**< Right vertical height channel. */
PAL_CHMAP_CHANNEL_TC = 22, /**< Top center channel. */
PAL_CHMAP_CHANNEL_TBL = 23, /**< Top back left channel. */
PAL_CHMAP_CHANNEL_TBR = 24, /**< Top back right channel. */
PAL_CHMAP_CHANNEL_TSL = 25, /**< Top side left channel. */
PAL_CHMAP_CHANNEL_TSR = 26, /**< Top side right channel. */
PAL_CHMAP_CHANNEL_TBC = 27, /**< Top back center channel. */
PAL_CHMAP_CHANNEL_BFC = 28, /**< Bottom front center channel. */
PAL_CHMAP_CHANNEL_BFL = 29, /**< Bottom front left channel. */
PAL_CHMAP_CHANNEL_BFR = 30, /**< Bottom front right channel. */
PAL_CHMAP_CHANNEL_LW = 31, /**< Left wide channel. */
PAL_CHMAP_CHANNEL_RW = 32, /**< Right wide channel. */
PAL_CHMAP_CHANNEL_LSD = 33, /**< Left side direct channel. */
PAL_CHMAP_CHANNEL_RSD = 34, /**< Left side direct channel. */
} pal_channel_map;
/** Audio channel info data structure */
struct pal_channel_info {
uint16_t channels; /**< number of channels*/
uint8_t ch_map[PAL_MAX_CHANNELS_SUPPORTED]; /**< ch_map value per channel. */
};
/** Audio stream direction enumeration */
typedef enum {
PAL_AUDIO_OUTPUT = 0x1, /**< playback usecases*/
PAL_AUDIO_INPUT = 0x2, /**< capture/voice activation usecases*/
PAL_AUDIO_INPUT_OUTPUT = 0x3, /**< transcode usecases*/
} pal_stream_direction_t;
/** Audio Voip TX Effect enumeration */
typedef enum {
PAL_AUDIO_EFFECT_NONE = 0x0, /**< No audio effect ie., EC_OFF_NS_OFF*/
PAL_AUDIO_EFFECT_EC = 0x1, /**< Echo Cancellation ie., EC_ON_NS_OFF*/
PAL_AUDIO_EFFECT_NS = 0x2, /**< Noise Suppression ie., NS_ON_EC_OFF*/
PAL_AUDIO_EFFECT_ECNS = 0x3, /**< EC + NS*/
} pal_audio_effect_t;
/** Audio stream types */
typedef enum {
PAL_STREAM_LOW_LATENCY = 1, /**< :low latency, higher power*/
PAL_STREAM_DEEP_BUFFER = 2, /**< :low power, higher latency*/
PAL_STREAM_COMPRESSED = 3, /**< :compresssed audio*/
PAL_STREAM_VOIP = 4, /**< :pcm voip audio*/
PAL_STREAM_VOIP_RX = 5, /**< :pcm voip audio downlink*/
PAL_STREAM_VOIP_TX = 6, /**< :pcm voip audio uplink*/
PAL_STREAM_VOICE_CALL_MUSIC = 7, /**< :incall music */
PAL_STREAM_GENERIC = 8, /**< :generic playback audio*/
PAL_STREAM_RAW = 9, /**< pcm no post processing*/
PAL_STREAM_VOICE_RECOGNITION = 10, /**< voice recognition*/
PAL_STREAM_VOICE_CALL_RECORD = 11, /**< incall record */
PAL_STREAM_VOICE_CALL_TX = 12, /**< incall record, uplink */
PAL_STREAM_VOICE_CALL_RX_TX = 13, /**< incall record, uplink & Downlink */
PAL_STREAM_VOICE_CALL = 14, /**< voice call */
PAL_STREAM_LOOPBACK = 15, /**< loopback */
PAL_STREAM_TRANSCODE = 16, /**< audio transcode */
PAL_STREAM_VOICE_UI = 17, /**< voice ui */
PAL_STREAM_PCM_OFFLOAD = 18, /**< pcm offload audio */
PAL_STREAM_ULTRA_LOW_LATENCY = 19, /**< pcm ULL audio */
PAL_STREAM_PROXY = 20, /**< pcm proxy audio */
PAL_STREAM_NON_TUNNEL = 21, /**< NT Mode session */
PAL_STREAM_HAPTICS = 22, /**< Haptics Stream */
PAL_STREAM_ACD = 23, /**< ACD Stream */
PAL_STREAM_CONTEXT_PROXY = 24, /**< Context Proxy Stream */
PAL_STREAM_SENSOR_PCM_DATA = 25, /**< Sensor Pcm Data Stream */
PAL_STREAM_ULTRASOUND = 26, /**< Ultrasound Proximity detection */
PAL_STREAM_SPATIAL_AUDIO = 27, /**< Spatial audio playback */
PAL_STREAM_MAX, /**< max stream types - add new ones above */
} pal_stream_type_t;
/** Audio devices available for enabling streams */
typedef enum {
//OUTPUT DEVICES
PAL_DEVICE_OUT_MIN = 0,
PAL_DEVICE_NONE = 1, /**< for transcode usecases*/
PAL_DEVICE_OUT_HANDSET = 2,
PAL_DEVICE_OUT_SPEAKER = 3,
PAL_DEVICE_OUT_WIRED_HEADSET = 4,
PAL_DEVICE_OUT_WIRED_HEADPHONE = 5, /**< Wired headphones without mic*/
PAL_DEVICE_OUT_LINE = 6,
PAL_DEVICE_OUT_BLUETOOTH_SCO = 7,
PAL_DEVICE_OUT_BLUETOOTH_A2DP = 8,
PAL_DEVICE_OUT_AUX_DIGITAL = 9,
PAL_DEVICE_OUT_HDMI = 10,
PAL_DEVICE_OUT_USB_DEVICE = 11,
PAL_DEVICE_OUT_USB_HEADSET = 12,
PAL_DEVICE_OUT_SPDIF = 13,
PAL_DEVICE_OUT_FM = 14,
PAL_DEVICE_OUT_AUX_LINE = 15,
PAL_DEVICE_OUT_PROXY = 16,
PAL_DEVICE_OUT_AUX_DIGITAL_1 = 17,
PAL_DEVICE_OUT_HEARING_AID = 18,
PAL_DEVICE_OUT_HAPTICS_DEVICE = 19,
PAL_DEVICE_OUT_ULTRASOUND = 20,
PAL_DEVICE_OUT_ULTRASOUND_DEDICATED = 21,
PAL_DEVICE_OUT_BLUETOOTH_BLE = 22,
PAL_DEVICE_OUT_BLUETOOTH_BLE_BROADCAST = 23,
// Add new OUT devices here, increment MAX and MIN below when you do so
PAL_DEVICE_OUT_MAX = 24,
//INPUT DEVICES
PAL_DEVICE_IN_MIN = PAL_DEVICE_OUT_MAX,
PAL_DEVICE_IN_HANDSET_MIC = PAL_DEVICE_IN_MIN +1,
PAL_DEVICE_IN_SPEAKER_MIC = PAL_DEVICE_IN_MIN + 2,
PAL_DEVICE_IN_BLUETOOTH_SCO_HEADSET = PAL_DEVICE_IN_MIN + 3,
PAL_DEVICE_IN_WIRED_HEADSET = PAL_DEVICE_IN_MIN + 4,
PAL_DEVICE_IN_AUX_DIGITAL = PAL_DEVICE_IN_MIN + 5,
PAL_DEVICE_IN_HDMI = PAL_DEVICE_IN_MIN + 6,
PAL_DEVICE_IN_USB_ACCESSORY = PAL_DEVICE_IN_MIN + 7,
PAL_DEVICE_IN_USB_DEVICE = PAL_DEVICE_IN_MIN + 8,
PAL_DEVICE_IN_USB_HEADSET = PAL_DEVICE_IN_MIN + 9,
PAL_DEVICE_IN_FM_TUNER = PAL_DEVICE_IN_MIN + 10,
PAL_DEVICE_IN_LINE = PAL_DEVICE_IN_MIN + 11,
PAL_DEVICE_IN_SPDIF = PAL_DEVICE_IN_MIN + 12,
PAL_DEVICE_IN_PROXY = PAL_DEVICE_IN_MIN + 13,
PAL_DEVICE_IN_HANDSET_VA_MIC = PAL_DEVICE_IN_MIN + 14,
PAL_DEVICE_IN_BLUETOOTH_A2DP = PAL_DEVICE_IN_MIN + 15,
PAL_DEVICE_IN_HEADSET_VA_MIC = PAL_DEVICE_IN_MIN + 16,
PAL_DEVICE_IN_VI_FEEDBACK = PAL_DEVICE_IN_MIN + 17,
PAL_DEVICE_IN_TELEPHONY_RX = PAL_DEVICE_IN_MIN + 18,
PAL_DEVICE_IN_ULTRASOUND_MIC = PAL_DEVICE_IN_MIN +19,
PAL_DEVICE_IN_EXT_EC_REF = PAL_DEVICE_IN_MIN + 20,
PAL_DEVICE_IN_ECHO_REF = PAL_DEVICE_IN_MIN + 21,
PAL_DEVICE_IN_HAPTICS_VI_FEEDBACK = PAL_DEVICE_IN_MIN + 22,
PAL_DEVICE_IN_BLUETOOTH_BLE = PAL_DEVICE_IN_MIN + 23,
PAL_DEVICE_IN_CPS_FEEDBACK = PAL_DEVICE_IN_MIN + 24,
PAL_DEVICE_IN_CPS2_FEEDBACK = PAL_DEVICE_IN_MIN + 25,
// Add new IN devices here, increment MAX and MIN below when you do so
PAL_DEVICE_IN_MAX = PAL_DEVICE_IN_MIN + 26,
} pal_device_id_t;
typedef enum {
VOICEMMODE1 = 0x11C05000,
VOICEMMODE2 = 0x11DC5000,
VOICELBMMODE1 = 0x12006000,
VOICELBMMODE2 = 0x121C6000,
} pal_VSID_t;
typedef enum {
PAL_STREAM_LOOPBACK_PCM,
PAL_STREAM_LOOPBACK_HFP_RX,
PAL_STREAM_LOOPBACK_HFP_TX,
PAL_STREAM_LOOPBACK_COMPRESS,
PAL_STREAM_LOOPBACK_FM,
PAL_STREAM_LOOPBACK_KARAOKE,
PAL_STREAM_LOOPBACK_PLAYBACK_ONLY,
PAL_STREAM_LOOPBACK_CAPTURE_ONLY,
} pal_stream_loopback_type_t;
typedef enum {
PAL_STREAM_PROXY_TX_VISUALIZER,
PAL_STREAM_PROXY_TX_WFD,
PAL_STREAM_PROXY_TX_TELEPHONY_RX,
} pal_stream_proxy_tx_type_t;
typedef enum {
PAL_STREAM_HAPTICS_TOUCH = 1,
PAL_STREAM_HAPTICS_RINGTONE,
} pal_stream_haptics_type_t;
#ifdef __cplusplus
static const std::map<std::string, pal_device_id_t> deviceIdLUT {
{std::string{ "PAL_DEVICE_OUT_MIN" }, PAL_DEVICE_OUT_MIN},
{std::string{ "PAL_DEVICE_NONE" }, PAL_DEVICE_NONE},
{std::string{ "PAL_DEVICE_OUT_HANDSET" }, PAL_DEVICE_OUT_HANDSET},
{std::string{ "PAL_DEVICE_OUT_SPEAKER" }, PAL_DEVICE_OUT_SPEAKER},
{std::string{ "PAL_DEVICE_OUT_WIRED_HEADSET" }, PAL_DEVICE_OUT_WIRED_HEADSET},
{std::string{ "PAL_DEVICE_OUT_WIRED_HEADPHONE" }, PAL_DEVICE_OUT_WIRED_HEADPHONE},
{std::string{ "PAL_DEVICE_OUT_LINE" }, PAL_DEVICE_OUT_LINE},
{std::string{ "PAL_DEVICE_OUT_BLUETOOTH_SCO" }, PAL_DEVICE_OUT_BLUETOOTH_SCO},
{std::string{ "PAL_DEVICE_OUT_BLUETOOTH_A2DP" }, PAL_DEVICE_OUT_BLUETOOTH_A2DP},
{std::string{ "PAL_DEVICE_OUT_BLUETOOTH_BLE" }, PAL_DEVICE_OUT_BLUETOOTH_BLE},
{std::string{ "PAL_DEVICE_OUT_BLUETOOTH_BLE_BROADCAST" }, PAL_DEVICE_OUT_BLUETOOTH_BLE_BROADCAST},
{std::string{ "PAL_DEVICE_OUT_AUX_DIGITAL" }, PAL_DEVICE_OUT_AUX_DIGITAL},
{std::string{ "PAL_DEVICE_OUT_HDMI" }, PAL_DEVICE_OUT_HDMI},
{std::string{ "PAL_DEVICE_OUT_USB_DEVICE" }, PAL_DEVICE_OUT_USB_DEVICE},
{std::string{ "PAL_DEVICE_OUT_USB_HEADSET" }, PAL_DEVICE_OUT_USB_HEADSET},
{std::string{ "PAL_DEVICE_OUT_SPDIF" }, PAL_DEVICE_OUT_SPDIF},
{std::string{ "PAL_DEVICE_OUT_FM" }, PAL_DEVICE_OUT_FM},
{std::string{ "PAL_DEVICE_OUT_AUX_LINE" }, PAL_DEVICE_OUT_AUX_LINE},
{std::string{ "PAL_DEVICE_OUT_PROXY" }, PAL_DEVICE_OUT_PROXY},
{std::string{ "PAL_DEVICE_OUT_AUX_DIGITAL_1" }, PAL_DEVICE_OUT_AUX_DIGITAL_1},
{std::string{ "PAL_DEVICE_OUT_HEARING_AID" }, PAL_DEVICE_OUT_HEARING_AID},
{std::string{ "PAL_DEVICE_OUT_HAPTICS_DEVICE" }, PAL_DEVICE_OUT_HAPTICS_DEVICE},
{std::string{ "PAL_DEVICE_OUT_ULTRASOUND" }, PAL_DEVICE_OUT_ULTRASOUND},
{std::string{ "PAL_DEVICE_OUT_ULTRASOUND_DEDICATED" }, PAL_DEVICE_OUT_ULTRASOUND_DEDICATED},
{std::string{ "PAL_DEVICE_OUT_MAX" }, PAL_DEVICE_OUT_MAX},
{std::string{ "PAL_DEVICE_IN_HANDSET_MIC" }, PAL_DEVICE_IN_HANDSET_MIC},
{std::string{ "PAL_DEVICE_IN_SPEAKER_MIC" }, PAL_DEVICE_IN_SPEAKER_MIC},
{std::string{ "PAL_DEVICE_IN_BLUETOOTH_SCO_HEADSET" }, PAL_DEVICE_IN_BLUETOOTH_SCO_HEADSET},
{std::string{ "PAL_DEVICE_IN_WIRED_HEADSET" }, PAL_DEVICE_IN_WIRED_HEADSET},
{std::string{ "PAL_DEVICE_IN_AUX_DIGITAL" }, PAL_DEVICE_IN_AUX_DIGITAL},
{std::string{ "PAL_DEVICE_IN_HDMI" }, PAL_DEVICE_IN_HDMI},
{std::string{ "PAL_DEVICE_IN_USB_ACCESSORY" }, PAL_DEVICE_IN_USB_ACCESSORY},
{std::string{ "PAL_DEVICE_IN_USB_DEVICE" }, PAL_DEVICE_IN_USB_DEVICE},
{std::string{ "PAL_DEVICE_IN_USB_HEADSET" }, PAL_DEVICE_IN_USB_HEADSET},
{std::string{ "PAL_DEVICE_IN_FM_TUNER" }, PAL_DEVICE_IN_FM_TUNER},
{std::string{ "PAL_DEVICE_IN_LINE" }, PAL_DEVICE_IN_LINE},
{std::string{ "PAL_DEVICE_IN_SPDIF" }, PAL_DEVICE_IN_SPDIF},
{std::string{ "PAL_DEVICE_IN_PROXY" }, PAL_DEVICE_IN_PROXY},
{std::string{ "PAL_DEVICE_IN_HANDSET_VA_MIC" }, PAL_DEVICE_IN_HANDSET_VA_MIC},
{std::string{ "PAL_DEVICE_IN_BLUETOOTH_A2DP" }, PAL_DEVICE_IN_BLUETOOTH_A2DP},
{std::string{ "PAL_DEVICE_IN_BLUETOOTH_BLE" }, PAL_DEVICE_IN_BLUETOOTH_BLE},
{std::string{ "PAL_DEVICE_IN_HEADSET_VA_MIC" }, PAL_DEVICE_IN_HEADSET_VA_MIC},
{std::string{ "PAL_DEVICE_IN_VI_FEEDBACK" }, PAL_DEVICE_IN_VI_FEEDBACK},
{std::string{ "PAL_DEVICE_IN_TELEPHONY_RX" }, PAL_DEVICE_IN_TELEPHONY_RX},
{std::string{ "PAL_DEVICE_IN_ULTRASOUND_MIC" }, PAL_DEVICE_IN_ULTRASOUND_MIC},
{std::string{ "PAL_DEVICE_IN_EXT_EC_REF" }, PAL_DEVICE_IN_EXT_EC_REF},
{std::string{ "PAL_DEVICE_IN_ECHO_REF" }, PAL_DEVICE_IN_ECHO_REF},
{std::string{ "PAL_DEVICE_IN_HAPTICS_VI_FEEDBACK" }, PAL_DEVICE_IN_HAPTICS_VI_FEEDBACK},
{std::string{ "PAL_DEVICE_IN_CPS_FEEDBACK" }, PAL_DEVICE_IN_CPS_FEEDBACK},
{std::string{ "PAL_DEVICE_IN_CPS2_FEEDBACK" }, PAL_DEVICE_IN_CPS2_FEEDBACK},
};
//reverse mapping
static const std::map<uint32_t, std::string> deviceNameLUT {
{PAL_DEVICE_OUT_MIN, std::string{"PAL_DEVICE_OUT_MIN"}},
{PAL_DEVICE_NONE, std::string{"PAL_DEVICE_NONE"}},
{PAL_DEVICE_OUT_HANDSET, std::string{"PAL_DEVICE_OUT_HANDSET"}},
{PAL_DEVICE_OUT_SPEAKER, std::string{"PAL_DEVICE_OUT_SPEAKER"}},
{PAL_DEVICE_OUT_WIRED_HEADSET, std::string{"PAL_DEVICE_OUT_WIRED_HEADSET"}},
{PAL_DEVICE_OUT_WIRED_HEADPHONE, std::string{"PAL_DEVICE_OUT_WIRED_HEADPHONE"}},
{PAL_DEVICE_OUT_LINE, std::string{"PAL_DEVICE_OUT_LINE"}},
{PAL_DEVICE_OUT_BLUETOOTH_SCO, std::string{"PAL_DEVICE_OUT_BLUETOOTH_SCO"}},
{PAL_DEVICE_OUT_BLUETOOTH_A2DP, std::string{"PAL_DEVICE_OUT_BLUETOOTH_A2DP"}},
{PAL_DEVICE_OUT_BLUETOOTH_BLE, std::string{"PAL_DEVICE_OUT_BLUETOOTH_BLE"}},
{PAL_DEVICE_OUT_BLUETOOTH_BLE_BROADCAST, std::string{"PAL_DEVICE_OUT_BLUETOOTH_BLE_BROADCAST"}},
{PAL_DEVICE_OUT_AUX_DIGITAL, std::string{"PAL_DEVICE_OUT_AUX_DIGITAL"}},
{PAL_DEVICE_OUT_HDMI, std::string{"PAL_DEVICE_OUT_HDMI"}},
{PAL_DEVICE_OUT_USB_DEVICE, std::string{"PAL_DEVICE_OUT_USB_DEVICE"}},
{PAL_DEVICE_OUT_USB_HEADSET, std::string{"PAL_DEVICE_OUT_USB_HEADSET"}},
{PAL_DEVICE_OUT_SPDIF, std::string{"PAL_DEVICE_OUT_SPDIF"}},
{PAL_DEVICE_OUT_FM, std::string{"PAL_DEVICE_OUT_FM"}},
{PAL_DEVICE_OUT_AUX_LINE, std::string{"PAL_DEVICE_OUT_AUX_LINE"}},
{PAL_DEVICE_OUT_PROXY, std::string{"PAL_DEVICE_OUT_PROXY"}},
{PAL_DEVICE_OUT_AUX_DIGITAL_1, std::string{"PAL_DEVICE_OUT_AUX_DIGITAL_1"}},
{PAL_DEVICE_OUT_HEARING_AID, std::string{"PAL_DEVICE_OUT_HEARING_AID"}},
{PAL_DEVICE_OUT_HAPTICS_DEVICE, std::string{"PAL_DEVICE_OUT_HAPTICS_DEVICE"}},
{PAL_DEVICE_OUT_ULTRASOUND, std::string{"PAL_DEVICE_OUT_ULTRASOUND"}},
{PAL_DEVICE_OUT_ULTRASOUND_DEDICATED, std::string{"PAL_DEVICE_OUT_ULTRASOUND_DEDICATED"}},
{PAL_DEVICE_OUT_MAX, std::string{"PAL_DEVICE_OUT_MAX"}},
{PAL_DEVICE_IN_HANDSET_MIC, std::string{"PAL_DEVICE_IN_HANDSET_MIC"}},
{PAL_DEVICE_IN_SPEAKER_MIC, std::string{"PAL_DEVICE_IN_SPEAKER_MIC"}},
{PAL_DEVICE_IN_BLUETOOTH_SCO_HEADSET, std::string{"PAL_DEVICE_IN_BLUETOOTH_SCO_HEADSET"}},
{PAL_DEVICE_IN_WIRED_HEADSET, std::string{"PAL_DEVICE_IN_WIRED_HEADSET"}},
{PAL_DEVICE_IN_AUX_DIGITAL, std::string{"PAL_DEVICE_IN_AUX_DIGITAL"}},
{PAL_DEVICE_IN_HDMI, std::string{"PAL_DEVICE_IN_HDMI"}},
{PAL_DEVICE_IN_USB_ACCESSORY, std::string{"PAL_DEVICE_IN_USB_ACCESSORY"}},
{PAL_DEVICE_IN_USB_DEVICE, std::string{"PAL_DEVICE_IN_USB_DEVICE"}},
{PAL_DEVICE_IN_USB_HEADSET, std::string{"PAL_DEVICE_IN_USB_HEADSET"}},
{PAL_DEVICE_IN_FM_TUNER, std::string{"PAL_DEVICE_IN_FM_TUNER"}},
{PAL_DEVICE_IN_LINE, std::string{"PAL_DEVICE_IN_LINE"}},
{PAL_DEVICE_IN_SPDIF, std::string{"PAL_DEVICE_IN_SPDIF"}},
{PAL_DEVICE_IN_PROXY, std::string{"PAL_DEVICE_IN_PROXY"}},
{PAL_DEVICE_IN_HANDSET_VA_MIC, std::string{"PAL_DEVICE_IN_HANDSET_VA_MIC"}},
{PAL_DEVICE_IN_BLUETOOTH_A2DP, std::string{"PAL_DEVICE_IN_BLUETOOTH_A2DP"}},
{PAL_DEVICE_IN_BLUETOOTH_BLE, std::string{"PAL_DEVICE_IN_BLUETOOTH_BLE"}},
{PAL_DEVICE_IN_HEADSET_VA_MIC, std::string{"PAL_DEVICE_IN_HEADSET_VA_MIC"}},
{PAL_DEVICE_IN_VI_FEEDBACK, std::string{"PAL_DEVICE_IN_VI_FEEDBACK"}},
{PAL_DEVICE_IN_TELEPHONY_RX, std::string{"PAL_DEVICE_IN_TELEPHONY_RX"}},
{PAL_DEVICE_IN_ULTRASOUND_MIC, std::string{"PAL_DEVICE_IN_ULTRASOUND_MIC"}},
{PAL_DEVICE_IN_EXT_EC_REF, std::string{"PAL_DEVICE_IN_EXT_EC_REF"}},
{PAL_DEVICE_IN_ECHO_REF, std::string{"PAL_DEVICE_IN_ECHO_REF"}},
{PAL_DEVICE_IN_HAPTICS_VI_FEEDBACK, std::string{"PAL_DEVICE_IN_HAPTICS_VI_FEEDBACK"}},
{PAL_DEVICE_IN_CPS_FEEDBACK, std::string{"PAL_DEVICE_IN_CPS_FEEDBACK"}},
{PAL_DEVICE_IN_CPS2_FEEDBACK, std::string{"PAL_DEVICE_IN_CPS2_FEEDBACK"}}
};
const std::map<std::string, uint32_t> usecaseIdLUT {
{std::string{ "PAL_STREAM_LOW_LATENCY" }, PAL_STREAM_LOW_LATENCY},
{std::string{ "PAL_STREAM_DEEP_BUFFER" }, PAL_STREAM_DEEP_BUFFER},
{std::string{ "PAL_STREAM_COMPRESSED" }, PAL_STREAM_COMPRESSED},
{std::string{ "PAL_STREAM_VOIP" }, PAL_STREAM_VOIP},
{std::string{ "PAL_STREAM_VOIP_RX" }, PAL_STREAM_VOIP_RX},
{std::string{ "PAL_STREAM_VOIP_TX" }, PAL_STREAM_VOIP_TX},
{std::string{ "PAL_STREAM_VOICE_CALL_MUSIC" }, PAL_STREAM_VOICE_CALL_MUSIC},
{std::string{ "PAL_STREAM_GENERIC" }, PAL_STREAM_GENERIC},
{std::string{ "PAL_STREAM_RAW" }, PAL_STREAM_RAW},
{std::string{ "PAL_STREAM_VOICE_RECOGNITION" }, PAL_STREAM_VOICE_RECOGNITION},
{std::string{ "PAL_STREAM_VOICE_CALL_RECORD" }, PAL_STREAM_VOICE_CALL_RECORD},
{std::string{ "PAL_STREAM_VOICE_CALL_TX" }, PAL_STREAM_VOICE_CALL_TX},
{std::string{ "PAL_STREAM_VOICE_CALL_RX_TX" }, PAL_STREAM_VOICE_CALL_RX_TX},
{std::string{ "PAL_STREAM_VOICE_CALL" }, PAL_STREAM_VOICE_CALL},
{std::string{ "PAL_STREAM_LOOPBACK" }, PAL_STREAM_LOOPBACK},
{std::string{ "PAL_STREAM_TRANSCODE" }, PAL_STREAM_TRANSCODE},
{std::string{ "PAL_STREAM_VOICE_UI" }, PAL_STREAM_VOICE_UI},
{std::string{ "PAL_STREAM_PCM_OFFLOAD" }, PAL_STREAM_PCM_OFFLOAD},
{std::string{ "PAL_STREAM_ULTRA_LOW_LATENCY" }, PAL_STREAM_ULTRA_LOW_LATENCY},
{std::string{ "PAL_STREAM_PROXY" }, PAL_STREAM_PROXY},
{std::string{ "PAL_STREAM_NON_TUNNEL" }, PAL_STREAM_NON_TUNNEL},
{std::string{ "PAL_STREAM_HAPTICS" }, PAL_STREAM_HAPTICS},
{std::string{ "PAL_STREAM_ACD" }, PAL_STREAM_ACD},
{std::string{ "PAL_STREAM_ULTRASOUND" }, PAL_STREAM_ULTRASOUND},
{std::string{ "PAL_STREAM_SENSOR_PCM_DATA" }, PAL_STREAM_SENSOR_PCM_DATA},
{std::string{ "PAL_STREAM_SPATIAL_AUDIO" }, PAL_STREAM_SPATIAL_AUDIO},
{std::string{ "PAL_STREAM_CONTEXT_PROXY" }, PAL_STREAM_CONTEXT_PROXY},
};
/* Update the reverse mapping as well when new stream is added */
const std::map<uint32_t, std::string> streamNameLUT {
{PAL_STREAM_LOW_LATENCY, std::string{ "PAL_STREAM_LOW_LATENCY" } },
{PAL_STREAM_DEEP_BUFFER, std::string{ "PAL_STREAM_DEEP_BUFFER" } },
{PAL_STREAM_COMPRESSED, std::string{ "PAL_STREAM_COMPRESSED" } },
{PAL_STREAM_VOIP, std::string{ "PAL_STREAM_VOIP" } },
{PAL_STREAM_VOIP_RX, std::string{ "PAL_STREAM_VOIP_RX" } },
{PAL_STREAM_VOIP_TX, std::string{ "PAL_STREAM_VOIP_TX" } },
{PAL_STREAM_VOICE_CALL_MUSIC, std::string{ "PAL_STREAM_VOICE_CALL_MUSIC" } },
{PAL_STREAM_GENERIC, std::string{ "PAL_STREAM_GENERIC" } },
{PAL_STREAM_RAW, std::string{ "PAL_STREAM_RAW" } },
{PAL_STREAM_VOICE_RECOGNITION, std::string{ "PAL_STREAM_VOICE_RECOGNITION" } },
{PAL_STREAM_VOICE_CALL_RECORD, std::string{ "PAL_STREAM_VOICE_CALL_RECORD" } },
{PAL_STREAM_VOICE_CALL_TX, std::string{ "PAL_STREAM_VOICE_CALL_TX" } },
{PAL_STREAM_VOICE_CALL_RX_TX, std::string{ "PAL_STREAM_VOICE_CALL_RX_TX" } },
{PAL_STREAM_VOICE_CALL, std::string{ "PAL_STREAM_VOICE_CALL" } },
{PAL_STREAM_LOOPBACK, std::string{ "PAL_STREAM_LOOPBACK" } },
{PAL_STREAM_TRANSCODE, std::string{ "PAL_STREAM_TRANSCODE" } },
{PAL_STREAM_VOICE_UI, std::string{ "PAL_STREAM_VOICE_UI" } },
{PAL_STREAM_PCM_OFFLOAD, std::string{ "PAL_STREAM_PCM_OFFLOAD" } },
{PAL_STREAM_ULTRA_LOW_LATENCY, std::string{ "PAL_STREAM_ULTRA_LOW_LATENCY" } },
{PAL_STREAM_PROXY, std::string{ "PAL_STREAM_PROXY" } },
{PAL_STREAM_NON_TUNNEL, std::string{ "PAL_STREAM_NON_TUNNEL" } },
{PAL_STREAM_HAPTICS, std::string{ "PAL_STREAM_HAPTICS" } },
{PAL_STREAM_ACD, std::string{ "PAL_STREAM_ACD" } },
{PAL_STREAM_ULTRASOUND, std::string{ "PAL_STREAM_ULTRASOUND" } },
{PAL_STREAM_SENSOR_PCM_DATA, std::string{ "PAL_STREAM_SENSOR_PCM_DATA" } },
{PAL_STREAM_SPATIAL_AUDIO, std::string{ "PAL_STREAM_SPATIAL_AUDIO" } },
};
const std::map<uint32_t, std::string> vsidLUT {
{VOICEMMODE1, std::string{ "VOICEMMODE1" } },
{VOICEMMODE2, std::string{ "VOICEMMODE2" } },
{VOICELBMMODE1, std::string{ "VOICELBMMODE1" } },
{VOICELBMMODE2, std::string{ "VOICELBMMODE2" } },
};
const std::map<uint32_t, std::string> loopbackLUT {
{PAL_STREAM_LOOPBACK_PCM, std::string{ "PAL_STREAM_LOOPBACK_PCM" } },
{PAL_STREAM_LOOPBACK_HFP_RX, std::string{ "PAL_STREAM_LOOPBACK_HFP_RX" } },
{PAL_STREAM_LOOPBACK_HFP_TX, std::string{ "PAL_STREAM_LOOPBACK_HFP_TX" } },
{PAL_STREAM_LOOPBACK_COMPRESS, std::string{ "PAL_STREAM_LOOPBACK_COMPRESS" } },
{PAL_STREAM_LOOPBACK_FM, std::string{ "PAL_STREAM_LOOPBACK_FM" } },
{PAL_STREAM_LOOPBACK_KARAOKE, std::string{ "PAL_STREAM_LOOPBACK_KARAOKE" }},
{PAL_STREAM_LOOPBACK_PLAYBACK_ONLY, std::string{ "PAL_STREAM_LOOPBACK_PLAYBACK_ONLY" } },
{PAL_STREAM_LOOPBACK_CAPTURE_ONLY, std::string{ "PAL_STREAM_LOOPBACK_CAPTURE_ONLY" } },
};
const std::map<uint32_t, std::string> hapticsLUT {
{PAL_STREAM_HAPTICS_TOUCH, std::string{ "PAL_STREAM_HAPTICS_TOUCH" } },
{PAL_STREAM_HAPTICS_RINGTONE, std::string{ "PAL_STREAM_HAPTICS_RINGTONE" } },
};
#endif
/* type of asynchronous write callback events. Mutually exclusive */
typedef enum {
PAL_STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */
PAL_STREAM_CBK_EVENT_DRAIN_READY, /* drain completed */
PAL_STREAM_CBK_EVENT_PARTIAL_DRAIN_READY, /* partial drain completed */
PAL_STREAM_CBK_EVENT_READ_DONE, /* stream hit some error, let AF take action */
PAL_STREAM_CBK_EVENT_ERROR, /* stream hit some error, let AF take action */
} pal_stream_callback_event_t;
/* type of global callback events. */
typedef enum {
PAL_SND_CARD_STATE,
} pal_global_callback_event_t;
struct pal_stream_info {
int64_t version; /** version of structure*/
int64_t size; /** size of structure*/
int64_t duration_us; /** duration in microseconds, -1 if unknown */
bool has_video; /** optional, true if stream is tied to a video stream */
bool is_streaming; /** true if streaming, false if local playback */
int32_t loopback_type; /** used only if stream_type is LOOPBACK. One of the */
/** enums defined in enum pal_stream_loopback_type */
int32_t tx_proxy_type; /** enums defined in enum pal_stream_proxy_tx_types */
int32_t haptics_type; /** enums defined in enum pal_sream_haptics_types */
//pal_audio_attributes_t usage; /** Not sure if we make use of this */
};
typedef enum {
INCALL_RECORD_VOICE_UPLINK = 1,
INCALL_RECORD_VOICE_DOWNLINK,
INCALL_RECORD_VOICE_UPLINK_DOWNLINK,
} pal_incall_record_direction;
struct pal_voice_record_info {
int64_t version; /** version of structure*/
int64_t size; /** size of structure*/
pal_incall_record_direction record_direction; /** use direction enum to indicate content to be record */
};
struct pal_voice_call_info {
uint32_t VSID;
uint32_t tty_mode;
};
typedef enum {
PAL_TTY_OFF = 0,
PAL_TTY_HCO = 1,
PAL_TTY_VCO = 2,
PAL_TTY_FULL = 3,
} pal_tty_t;
typedef union {
struct pal_stream_info opt_stream_info; /* optional */
struct pal_voice_record_info voice_rec_info; /* mandatory */
struct pal_voice_call_info voice_call_info; /* manatory for voice call*/
} pal_stream_info_t;
/** Media configuraiton */
struct pal_media_config {
uint32_t sample_rate; /**< sample rate */
uint32_t bit_width; /**< bit width */
pal_audio_fmt_t aud_fmt_id; /**< audio format id*/
struct pal_channel_info ch_info; /**< channel info */
};
/** Android Media configuraiton */
/* dynamic media config for plugin devices, +1 so that the last entry is always 0 */
#define MAX_SUPPORTED_CHANNEL_MASKS (2 * 8)
#define MAX_SUPPORTED_FORMATS 15
#define MAX_SUPPORTED_SAMPLE_RATES 7
typedef struct dynamic_media_config {
uint32_t sample_rate[MAX_SUPPORTED_SAMPLE_RATES+1]; /**< sample rate */
uint32_t format[MAX_SUPPORTED_FORMATS+1]; /**< format */
uint32_t mask[MAX_SUPPORTED_CHANNEL_MASKS + 1]; /**< channel mask */
bool jack_status; /**< input/output jack status*/
} dynamic_media_config_t;
/** Available stream flags of an audio session*/
typedef enum {
PAL_STREAM_FLAG_TIMESTAMP = 0x1, /**< Enable time stamps associated to audio buffers */
PAL_STREAM_FLAG_NON_BLOCKING = 0x2, /**< Stream IO operations are non blocking */
PAL_STREAM_FLAG_MMAP = 0x4, /**< Stream Mode should be in MMAP*/
PAL_STREAM_FLAG_MMAP_NO_IRQ = 0x8, /**< Stream Mode should be No IRQ */
PAL_STREAM_FLAG_EXTERN_MEM = 0x10, /**< Shared memory buffers allocated by client*/
PAL_STREAM_FLAG_SRCM_INBAND = 0x20, /**< MediaFormat change event inband with data buffers*/
PAL_STREAM_FLAG_EOF = 0x40, /**< MediaFormat change event inband with data buffers*/
} pal_stream_flags_t;
#define PAL_STREAM_FLAG_NON_BLOCKING_MASK 0x2
#define PAL_STREAM_FLAG_MMAP_MASK 0x4
#define PAL_STREAM_FLAG_MMAP_NO_IRQ_MASK 0x8
/**< PAL stream attributes to be specified, used in pal_stream_open cmd */
struct pal_stream_attributes {
pal_stream_type_t type; /**< stream type */
pal_stream_info_t info; /**< stream info */
pal_stream_flags_t flags; /**< stream flags */
pal_stream_direction_t direction; /**< direction of the streams */
struct pal_media_config in_media_config; /**< media config of the input audio samples */
struct pal_media_config out_media_config; /**< media config of the output audio samples */
};
/**< Key value pair to identify the topology of a usecase from default */
struct modifier_kv {
uint32_t key;
uint32_t value;
};
/** Metadata flags */
enum {
PAL_META_DATA_FLAGS_NONE = 0,
};
/** metadata flags, can be OR'able */
typedef uint32_t pal_meta_data_flags_t;
typedef struct pal_extern_alloc_buff_info {
int alloc_handle;/**< unique memory handle identifying extern mem allocation */
uint32_t alloc_size; /**< size of external allocation */
uint32_t offset; /**< offset of buffer within extern allocation */
} pal_extern_alloc_buff_info_t;
/** PAL buffer structure used for reading/writing buffers from/to the stream */
struct pal_buffer {
uint8_t *buffer; /**< buffer pointer */
size_t size; /**< number of bytes */
size_t offset; /**< offset in buffer from where valid byte starts */
struct timespec *ts; /**< timestmap */
uint32_t flags; /**< flags */
size_t metadata_size; /**< size of metadata buffer in bytes */
uint8_t *metadata; /**< metadata buffer. Can contain multiple metadata*/
pal_extern_alloc_buff_info_t alloc_info; /**< holds info for extern buff */
uint64_t frame_index; /**< frame index of the buffer */
};
struct pal_clbk_buffer_info {
uint64_t frame_index; /**< frame index of the buffer */
uint32_t sample_rate; /**< updated sample rate */
uint32_t bit_width; /**< updated bit width */
uint16_t channel_count; /**< updated channel count */
};
struct pal_callback_buffer {
uint8_t *buffer; /**< buffer pointer */
size_t size; /**< filled length of the buffer */
struct timespec *ts; /**< timestamp */
uint32_t status; /**< status of callback payload */
struct pal_clbk_buffer_info cb_buf_info; /**< callback buffer info */
};
/** pal_mmap_buffer flags */
enum {
PAL_MMMAP_BUFF_FLAGS_NONE = 0,
/**
* Only set this flag if applications can access the audio buffer memory
* shared with the backend (usually DSP) _without_ security issue.
*
* Setting this flag also implies that Binder will allow passing the shared memory FD
* to applications.
*
* That usually implies that the kernel will prevent any access to the
* memory surrounding the audio buffer as it could lead to a security breach.
*
* For example, a "/dev/snd/" file descriptor generally is not shareable,
* but an "anon_inode:dmabuffer" file descriptor is shareable.
* See also Linux kernel's dma_buf.
*
*/
PAL_MMMAP_BUFF_FLAGS_APP_SHAREABLE = 1,
};
/** pal_mmap_buffer flags, can be OR'able */
typedef uint32_t pal_mmap_buffer_flags_t;
/** PAL buffer structure used for reading/writing buffers from/to the stream */
struct pal_mmap_buffer {
void* buffer; /**< base address of mmap memory buffer,
for use by local proces only */
int32_t fd; /**< fd for mmap memory buffer */
uint32_t buffer_size_frames; /**< total buffer size in frames */
uint32_t burst_size_frames; /**< transfer size granularity in frames */
pal_mmap_buffer_flags_t flags; /**< Attributes describing the buffer. */
};
/**
* Mmap buffer read/write position returned by GetMmapPosition.
* note\ Used by streams opened in mmap mode.
*/
struct pal_mmap_position {
int64_t time_nanoseconds; /**< timestamp in ns, CLOCK_MONOTONIC */
int32_t position_frames; /**< increasing 32 bit frame count reset when stop()
is called */
};
/** channel mask and volume pair */
struct pal_channel_vol_kv {
uint32_t channel_mask; /**< channel mask */
float vol; /**< gain of the channel mask */
};
/** Volume data strucutre defintion used as argument for volume command */
struct pal_volume_data {
uint32_t no_of_volpair; /**< no of volume pairs*/
struct pal_channel_vol_kv volume_pair[]; /**< channel mask and volume pair */
};
struct pal_time_us {
uint32_t value_lsw; /** Lower 32 bits of 64 bit time value in microseconds */
uint32_t value_msw; /** Upper 32 bits of 64 bit time value in microseconds */
};
/** Timestamp strucutre defintion used as argument for
* gettimestamp api */
struct pal_session_time {
struct pal_time_us session_time; /** Value of the current session time in microseconds */
struct pal_time_us absolute_time; /** Value of the absolute time in microseconds */
struct pal_time_us timestamp; /** Value of the last processed time stamp in microseconds */
};
/** EVENT configurations data strucutre defintion used as
* argument for mute command */
//typedef union {
//} pal_event_cfg_t;
/** event id of the event generated*/
typedef uint32_t pal_event_id;
typedef enum {
/** request notification when all accumlated data has be
* drained.*/
PAL_DRAIN,
/** request notification when drain completes shortly before all
* accumlated data of the current track has been played out */
PAL_DRAIN_PARTIAL,
} pal_drain_type_t;
typedef enum {
PAL_PARAM_ID_LOAD_SOUND_MODEL = 0,
PAL_PARAM_ID_RECOGNITION_CONFIG = 1,
PAL_PARAM_ID_ECNS_ON_OFF = 2,
PAL_PARAM_ID_DIRECTION_OF_ARRIVAL = 3,
PAL_PARAM_ID_UIEFFECT = 4,
PAL_PARAM_ID_STOP_BUFFERING = 5,
PAL_PARAM_ID_CODEC_CONFIGURATION = 6,
/* Non-Stream Specific Parameters*/
PAL_PARAM_ID_DEVICE_CONNECTION = 7,
PAL_PARAM_ID_SCREEN_STATE = 8,
PAL_PARAM_ID_CHARGING_STATE = 9,
PAL_PARAM_ID_DEVICE_ROTATION = 10,
PAL_PARAM_ID_BT_SCO = 11,
PAL_PARAM_ID_BT_SCO_WB = 12,
PAL_PARAM_ID_BT_SCO_SWB = 13,
PAL_PARAM_ID_BT_A2DP_RECONFIG = 14,
PAL_PARAM_ID_BT_A2DP_RECONFIG_SUPPORTED = 15,
PAL_PARAM_ID_BT_A2DP_SUSPENDED = 16,
PAL_PARAM_ID_BT_A2DP_TWS_CONFIG = 17,
PAL_PARAM_ID_BT_A2DP_ENCODER_LATENCY = 18,
PAL_PARAM_ID_DEVICE_CAPABILITY = 19,
PAL_PARAM_ID_GET_SOUND_TRIGGER_PROPERTIES = 20,
PAL_PARAM_ID_TTY_MODE = 21,
PAL_PARAM_ID_VOLUME_BOOST = 22,
PAL_PARAM_ID_SLOW_TALK = 23,
PAL_PARAM_ID_SPEAKER_RAS = 24,
PAL_PARAM_ID_SP_MODE = 25,
PAL_PARAM_ID_GAIN_LVL_MAP = 26,
PAL_PARAM_ID_GAIN_LVL_CAL = 27,
PAL_PARAM_ID_GAPLESS_MDATA = 28,
PAL_PARAM_ID_HD_VOICE = 29,
PAL_PARAM_ID_WAKEUP_ENGINE_CONFIG = 30,
PAL_PARAM_ID_WAKEUP_BUFFERING_CONFIG = 31,
PAL_PARAM_ID_WAKEUP_ENGINE_RESET = 32,
PAL_PARAM_ID_WAKEUP_MODULE_VERSION = 33,
PAL_PARAM_ID_WAKEUP_CUSTOM_CONFIG = 34,
PAL_PARAM_ID_UNLOAD_SOUND_MODEL = 35,
PAL_PARAM_ID_MODULE_CONFIG = 36, /*Clients directly configure DSP modules*/
PAL_PARAM_ID_BT_A2DP_LC3_CONFIG = 37,
PAL_PARAM_ID_PROXY_CHANNEL_CONFIG = 38,
PAL_PARAM_ID_CONTEXT_LIST = 39,
PAL_PARAM_ID_HAPTICS_INTENSITY = 40,
PAL_PARAM_ID_HAPTICS_VOLUME = 41,
PAL_PARAM_ID_BT_A2DP_DECODER_LATENCY = 42,
PAL_PARAM_ID_CUSTOM_CONFIGURATION = 43,
PAL_PARAM_ID_KW_TRANSFER_LATENCY = 44,
PAL_PARAM_ID_BT_A2DP_FORCE_SWITCH = 45,
PAL_PARAM_ID_BT_SCO_LC3 = 46,
PAL_PARAM_ID_DEVICE_MUTE = 47,
PAL_PARAM_ID_UPD_REGISTER_FOR_EVENTS = 48,
PAL_PARAM_ID_SP_GET_CAL = 49,
PAL_PARAM_ID_BT_A2DP_CAPTURE_SUSPENDED = 50,
PAL_PARAM_ID_SNDCARD_STATE = 51,
PAL_PARAM_ID_HIFI_PCM_FILTER = 52,
PAL_PARAM_ID_CHARGER_STATE = 53,
PAL_PARAM_ID_BT_SCO_NREC = 54,
PAL_PARAM_ID_VOLUME_USING_SET_PARAM = 55,
PAL_PARAM_ID_UHQA_FLAG = 56,
PAL_PARAM_ID_STREAM_ATTRIBUTES = 57,
PAL_PARAM_ID_SET_UPD_DUTY_CYCLE = 58,
PAL_PARAM_ID_MSPP_LINEAR_GAIN = 59,
PAL_PARAM_ID_SET_SOURCE_METADATA = 60,
PAL_PARAM_ID_SET_SINK_METADATA = 61,
PAL_PARAM_ID_ULTRASOUND_RAMPDOWN = 62,
PAL_PARAM_ID_VOLUME_CTRL_RAMP = 63,
PAL_PARAM_ID_ULTRASOUND_SET_GAIN = 64,
} pal_param_id_type_t;
/** HDMI/DP */
// START: MST ==================================================
#define MAX_CONTROLLERS 1
#define MAX_STREAMS_PER_CONTROLLER 2
// END: MST ==================================================
/** Audio parameter data*/
typedef struct pal_param_proxy_channel_config {
uint32_t num_proxy_channels;
} pal_param_proxy_channel_config_t;
struct pal_param_context_list {
uint32_t num_contexts;
uint32_t context_id[]; /* list of num_contexts context_id */
};
struct pal_param_disp_port_config_params {
int controller;
int stream;
};
struct pal_usb_device_address {
int card_id;
int device_num;
};
typedef union {
struct pal_param_disp_port_config_params dp_config;
struct pal_usb_device_address usb_addr;
} pal_device_config_t;
struct pal_amp_db_and_gain_table {
float amp;
float db;
uint32_t level;
};
struct pal_vol_ctrl_ramp_param {
uint32_t ramp_period_ms;
};
/* Payload For ID: PAL_PARAM_ID_DEVICE_CONNECTION
* Description : Device Connection
*/
typedef struct pal_param_device_connection {
pal_device_id_t id;
bool connection_state;
pal_device_config_t device_config;
} pal_param_device_connection_t;
/* Payload For ID: PAL_PARAM_ID_GAIN_LVL_MAP
* Description : get gain level mapping
*/
typedef struct pal_param_gain_lvl_map {
struct pal_amp_db_and_gain_table *mapping_tbl;
int table_size;
int filled_size;
} pal_param_gain_lvl_map_t;
/* Payload For ID: PAL_PARAM_ID_GAIN_LVL_CAL
* Description : set gain level calibration
*/
typedef struct pal_param_gain_lvl_cal {
int level;
} pal_param_gain_lvl_cal_t;
/* Payload For ID: PAL_PARAM_ID_MSPP_LINEAR_GAIN
* Description : set linear gain for MSPP
*/
typedef struct pal_param_mspp_linear_gain {
int32_t gain;
} pal_param_mspp_linear_gain_t;
/* Payload For ID: PAL_PARAM_ID_DEVICE_CAPABILITY
* Description : get Device Capability
*/
typedef struct pal_param_device_capability {
pal_device_id_t id;
struct pal_usb_device_address addr;
bool is_playback;
struct dynamic_media_config *config;
} pal_param_device_capability_t;
/* Payload For ID: PAL_PARAM_ID_SCREEN_STATE
* Description : Screen State
*/
typedef struct pal_param_screen_state {
bool screen_state;
} pal_param_screen_state_t;
/* Payload For ID: PAL_PARAM_ID_CHARGING_STATE
* Description : Charging State
*/
typedef struct pal_param_charging_state {
bool charging_state;
} pal_param_charging_state_t;
/* Payload For ID: PAL_PARAM_ID_CHARGER_STATE
* Description : Charger State
*/
typedef struct pal_param_charger_state {
bool is_charger_online;
bool is_concurrent_boost_enable;
} pal_param_charger_state_t;
/*
* Used to identify the swapping type
*/
typedef enum {
PAL_SPEAKER_ROTATION_LR, /* Default position. It will be set when device
* is at angle 0, 90 or 180 degree.
*/
PAL_SPEAKER_ROTATION_RL /* This will be set if device is rotated by 270
* degree
*/
} pal_speaker_rotation_type;
/* Payload For ID: PAL_PARAM_ID_DEVICE_ROTATION
* Description : Device Rotation
*/
typedef struct pal_param_device_rotation {
pal_speaker_rotation_type rotation_type;
} pal_param_device_rotation_t;
/* Payload For ID: PAL_PARAM_ID_UHQA_FLAG
* Description : use to enable/disable USB high quality audio from userend
*/
typedef struct pal_param_uhqa_state {
bool uhqa_state;
} pal_param_uhqa_t;
/* Payload For ID: PAL_PARAM_ID_BT_SCO*
* Description : BT SCO related device parameters
*/
static const char* lc3_reserved_params[] = {
"StreamMap",
"Codec",
"FrameDuration",
"rxconfig_index",
"txconfig_index",
"version",
"Blocks_forSDU",
"vendor",
};
enum {
LC3_STREAM_MAP_BIT = 0x1,
LC3_CODEC_BIT = 0x1 << 1,
LC3_FRAME_DURATION_BIT = 0x1 << 2,
LC3_RXCFG_IDX_BIT = 0x1 << 3,
LC3_TXCFG_IDX_BIT = 0x1 << 4,
LC3_VERSION_BIT = 0x1 << 5,
LC3_BLOCKS_FORSDU_BIT = 0x1 << 6,
LC3_VENDOR_BIT = 0x1 << 7,
LC3_BIT_ALL = LC3_STREAM_MAP_BIT |
LC3_CODEC_BIT |
LC3_FRAME_DURATION_BIT |
LC3_RXCFG_IDX_BIT |
LC3_TXCFG_IDX_BIT |
LC3_VERSION_BIT |
LC3_BLOCKS_FORSDU_BIT |
LC3_VENDOR_BIT,
LC3_BIT_MASK = LC3_BIT_ALL & ~LC3_FRAME_DURATION_BIT, // frame duration is optional
LC3_BIT_VALID = LC3_BIT_MASK,
};
/* max length of streamMap string, up to 16 stream id supported */
#define PAL_LC3_MAX_STRING_LEN 200
typedef struct btsco_lc3_cfg {
uint32_t fields_map;
uint32_t rxconfig_index;
uint32_t txconfig_index;
uint32_t api_version;
uint32_t frame_duration;
uint32_t num_blocks;
char streamMap[PAL_LC3_MAX_STRING_LEN];
char vendor[PAL_LC3_MAX_STRING_LEN];
} btsco_lc3_cfg_t;
typedef struct pal_param_btsco {
bool bt_sco_on;
bool bt_wb_speech_enabled;
bool bt_sco_nrec;
int bt_swb_speech_mode;
bool bt_lc3_speech_enabled;
btsco_lc3_cfg_t lc3_cfg;
bool is_bt_hfp;
} pal_param_btsco_t;
/* Payload For ID: PAL_PARAM_ID_BT_A2DP*
* Description : A2DP related device setParameters
*/
typedef struct pal_param_bta2dp {
int32_t reconfig_supported;
bool reconfig;
bool a2dp_suspended;
bool a2dp_capture_suspended;
bool is_tws_mono_mode_on;
bool is_lc3_mono_mode_on;
bool is_force_switch;
uint32_t latency;
pal_device_id_t dev_id;
} pal_param_bta2dp_t;
typedef struct pal_param_upd_event_detection {
bool register_status;
} pal_param_upd_event_detection_t;
typedef struct pal_bt_tws_payload_s {
bool isTwsMonoModeOn;
uint32_t codecFormat;
} pal_bt_tws_payload;
/* Payload For Custom Config
* Description : Used by PAL client to customize
* the device related information.
*/
#define PAL_MAX_CUSTOM_KEY_SIZE 128
typedef struct pal_device_custom_config {
char custom_key[PAL_MAX_CUSTOM_KEY_SIZE];
} pal_device_custom_config_t;
typedef struct pal_bt_lc3_payload_s {
bool isLC3MonoModeOn;
} pal_bt_lc3_payload;
typedef struct pal_param_haptics_intensity {
int intensity;
} pal_param_haptics_intensity_t;
/* Type of Ultrasound Gain */
typedef enum {
PAL_ULTRASOUND_GAIN_MUTE = 0,
PAL_ULTRASOUND_GAIN_LOW,
PAL_ULTRASOUND_GAIN_HIGH,
} pal_ultrasound_gain_t;
/**< PAL device */
#define DEVICE_NAME_MAX_SIZE 128
struct pal_device {
pal_device_id_t id; /**< device id */
struct pal_media_config config; /**< media config of the device */
struct pal_usb_device_address address;
char sndDevName[DEVICE_NAME_MAX_SIZE];
pal_device_custom_config_t custom_config; /**< Optional */
};
/**
* Maps the modules instance id to module id for a single module
*/
struct module_info {
uint32_t module_id; /**< module id */
uint32_t module_iid; /**< globally unique module instance id */
};
/**
* Structure mapping the tag_id to module info (mid and miid)
*/
struct pal_tag_module_mapping {
uint32_t tag_id; /**< tag id of the module */
uint32_t num_modules; /**< number of modules matching the tag_id */
struct module_info mod_list[]; /**< module list */
};
/**
* Used to return tags and module info data to client given a graph key vector
*/
struct pal_tag_module_info {
/**< number of tags */
uint32_t num_tags;
/**< variable payload of type struct pal_tag_module_mapping*/
uint8_t pal_tag_module_list[];
};
#define PAL_SOUND_TRIGGER_MAX_STRING_LEN 64 /* max length of strings in properties or descriptor structs */
#define PAL_SOUND_TRIGGER_MAX_LOCALE_LEN 6 /* max length of locale string. e.g en_US */
#define PAL_SOUND_TRIGGER_MAX_USERS 10 /* max number of concurrent users */
#define PAL_SOUND_TRIGGER_MAX_PHRASES 10 /* max number of concurrent phrases */
#define PAL_RECOGNITION_MODE_VOICE_TRIGGER 0x1 /* simple voice trigger */
#define PAL_RECOGNITION_MODE_USER_IDENTIFICATION 0x2 /* trigger only if one user in model identified */
#define PAL_RECOGNITION_MODE_USER_AUTHENTICATION 0x4 /* trigger only if one user in mode authenticated */
#define PAL_RECOGNITION_MODE_GENERIC_TRIGGER 0x8 /* generic sound trigger */
#define PAL_RECOGNITION_STATUS_SUCCESS 0
#define PAL_RECOGNITION_STATUS_ABORT 1
#define PAL_RECOGNITION_STATUS_FAILURE 2
#define PAL_RECOGNITION_STATUS_GET_STATE_RESPONSE 3 /* Indicates that the recognition event is in
response to a state request and was not
triggered by a real DSP recognition */
/** used to identify the sound model type for the session */
typedef enum {
PAL_SOUND_MODEL_TYPE_UNKNOWN = -1, /* use for unspecified sound model type */
PAL_SOUND_MODEL_TYPE_KEYPHRASE = 0, /* use for key phrase sound models */
PAL_SOUND_MODEL_TYPE_GENERIC = 1 /* use for all models other than keyphrase */
} pal_st_sound_model_type_t;
struct st_uuid {
uint32_t timeLow;
uint16_t timeMid;
uint16_t timeHiAndVersion;
uint16_t clockSeq;
uint8_t node[6];
};
/**
* sound trigger implementation descriptor read by the framework via get_properties().
* Used by SoundTrigger service to report to applications and manage concurrency and policy.
*/
struct pal_st_properties {
int8_t implementor[PAL_SOUND_TRIGGER_MAX_STRING_LEN]; /* implementor name */
int8_t description[PAL_SOUND_TRIGGER_MAX_STRING_LEN]; /* implementation description */
uint32_t version; /* implementation version */
struct st_uuid uuid; /* unique implementation ID.
Must change with version each version */
uint32_t max_sound_models; /* maximum number of concurrent sound models
loaded */
uint32_t max_key_phrases; /* maximum number of key phrases */
uint32_t max_users; /* maximum number of concurrent users detected */
uint32_t recognition_modes; /* all supported modes.
e.g PAL_RECOGNITION_MODE_VOICE_TRIGGER */
bool capture_transition; /* supports seamless transition from detection
to capture */
uint32_t max_buffer_ms; /* maximum buffering capacity in ms if
capture_transition is true*/
bool concurrent_capture; /* supports capture by other use cases while
detection is active */
bool trigger_in_event; /* returns the trigger capture in event */
uint32_t power_consumption_mw; /* Rated power consumption when detection is active
with TDB silence/sound/speech ratio */
};
/** sound model structure passed in by ST Client during pal_st_load_sound_model() */
struct pal_st_sound_model {
pal_st_sound_model_type_t type; /* model type. e.g. PAL_SOUND_MODEL_TYPE_KEYPHRASE */
struct st_uuid uuid; /* unique sound model ID. */
struct st_uuid vendor_uuid; /* unique vendor ID. Identifies the engine the
sound model was build for */
uint32_t data_size; /* size of opaque model data */
uint32_t data_offset; /* offset of opaque data start from head of struct
e.g sizeof struct pal_st_sound_model) */
};
/** key phrase descriptor */
struct pal_st_phrase {
uint32_t id; /**< keyphrase ID */
uint32_t recognition_mode; /**< recognition modes supported by this key phrase */
uint32_t num_users; /**< number of users in the key phrase */
uint32_t users[PAL_SOUND_TRIGGER_MAX_USERS]; /**< users ids: (not uid_t but sound trigger
specific IDs */
char locale[PAL_SOUND_TRIGGER_MAX_LOCALE_LEN]; /**< locale - JAVA Locale style (e.g. en_US) */
char text[PAL_SOUND_TRIGGER_MAX_STRING_LEN]; /**< phrase text in UTF-8 format. */
};
/**
* Specialized sound model for key phrase detection.
* Proprietary representation of key phrases in binary data must match information indicated
* by phrases field use this when not sending
*/
struct pal_st_phrase_sound_model {
struct pal_st_sound_model common; /** common sound model */
uint32_t num_phrases; /** number of key phrases in model */
struct pal_st_phrase phrases[PAL_SOUND_TRIGGER_MAX_PHRASES];
};
struct pal_st_confidence_level {
uint32_t user_id; /* user ID */
uint32_t level; /* confidence level in percent (0 - 100).
- min level for recognition configuration
- detected level for recognition event */
};
/** Specialized recognition event for key phrase detection */
struct pal_st_phrase_recognition_extra {
uint32_t id; /* keyphrase ID */
uint32_t recognition_modes; /* recognition modes used for this keyphrase */
uint32_t confidence_level; /* confidence level for mode RECOGNITION_MODE_VOICE_TRIGGER */
uint32_t num_levels; /* number of user confidence levels */
struct pal_st_confidence_level levels[PAL_SOUND_TRIGGER_MAX_USERS];
};
struct pal_st_recognition_event {
int32_t status; /**< recognition status e.g.
RECOGNITION_STATUS_SUCCESS */
pal_st_sound_model_type_t type; /**< event type, same as sound model type.
e.g. SOUND_MODEL_TYPE_KEYPHRASE */
pal_st_handle_t *st_handle; /**< handle of sound trigger session */
bool capture_available; /**< it is possible to capture audio from this
utterance buffered by the
implementation */
int32_t capture_session; /**< audio session ID. framework use */
int32_t capture_delay_ms; /**< delay in ms between end of model
detection and start of audio available
for capture. A negative value is possible
(e.g. if key phrase is also available for
capture */
int32_t capture_preamble_ms; /**< duration in ms of audio captured
before the start of the trigger.
0 if none. */
bool trigger_in_data; /**< the opaque data is the capture of
the trigger sound */
struct pal_media_config media_config; /**< media format of either the trigger in
event data or to use for capture of the
rest of the utterance */
uint32_t data_size; /**< size of opaque event data */
uint32_t data_offset; /**< offset of opaque data start from start of
this struct (e.g sizeof struct
sound_trigger_phrase_recognition_event) */
};
typedef void(*pal_st_recognition_callback_t)(struct pal_st_recognition_event *event,
uint8_t *cookie);
/* Payload for pal_st_start_recognition() */
struct pal_st_recognition_config {
int32_t capture_handle; /**< IO handle that will be used for capture.
N/A if capture_requested is false */
uint32_t capture_device; /**< input device requested for detection capture */
bool capture_requested; /**< capture and buffer audio for this recognition
instance */
uint32_t num_phrases; /**< number of key phrases recognition extras */
struct pal_st_phrase_recognition_extra phrases[PAL_SOUND_TRIGGER_MAX_PHRASES];
/**< configuration for each key phrase */
pal_st_recognition_callback_t callback; /**< callback for recognition events */
uint8_t * cookie; /**< cookie set from client*/
uint32_t data_size; /**< size of opaque capture configuration data */
uint32_t data_offset; /**< offset of opaque data start from start of this struct
(e.g sizeof struct sound_trigger_recognition_config) */
};
struct pal_st_phrase_recognition_event {
struct pal_st_recognition_event common;
uint32_t num_phrases;
struct pal_st_phrase_recognition_extra phrase_extras[PAL_SOUND_TRIGGER_MAX_PHRASES];
};
struct pal_st_generic_recognition_event {
struct pal_st_recognition_event common;
};
struct detection_engine_config_voice_wakeup {
uint16_t mode;
uint16_t custom_payload_size;
uint8_t num_active_models;
uint8_t reserved;
uint8_t confidence_levels[PAL_SOUND_TRIGGER_MAX_USERS];
uint8_t keyword_user_enables[PAL_SOUND_TRIGGER_MAX_USERS];
};
struct detection_engine_config_stage1_pdk {
uint16_t mode;
uint16_t custom_payload_size;
uint32_t model_id;
uint32_t num_keywords;
uint32_t confidence_levels[MAX_KEYWORD_SUPPORTED];
};
struct detection_engine_multi_model_buffering_config {
uint32_t model_id;
uint32_t hist_buffer_duration_in_ms;
uint32_t pre_roll_duration_in_ms;
};
struct ffv_doa_tracking_monitor_t
{
int16_t target_angle_L16[2];
int16_t interf_angle_L16[2];
int8_t polarActivityGUI[360];
};
struct __attribute__((__packed__)) version_arch_payload {
unsigned int version;
char arch[64];
};
struct pal_compr_gapless_mdata {
uint32_t encoderDelay;
uint32_t encoderPadding;
};
typedef struct pal_device_mute_t {
pal_stream_direction_t dir;
bool mute;
}pal_device_mute_t;
/**
* Event payload passed to client with PAL_STREAM_CBK_EVENT_READ_DONE and
* PAL_STREAM_CBK_EVENT_WRITE_READY events
*/
struct pal_event_read_write_done_payload {
uint32_t tag; /**< tag that was used to read/write this buffer */
uint32_t status; /**< data buffer status as defined in ar_osal_error.h */
uint32_t md_status; /**< meta-data status as defined in ar_osal_error.h */
struct pal_buffer buff; /**< buffer that was passed to pal_stream_read/pal_stream_write */
};
/** @brief Callback function prototype to be given for
* pal_open_stream.
*
* \param[in] stream_handle - stream handle associated with the
* callback event.
* \param[in] event_id - event id of the event raised on the
* stream.
* \param[in] event_data - event_data specific to the event
* raised.
* \param[in] cookie - cookie speificied in the
* pal_stream_open()
*/
typedef int32_t (*pal_stream_callback)(pal_stream_handle_t *stream_handle,
uint32_t event_id, uint32_t *event_data,
uint32_t event_data_size,
uint64_t cookie);
/** @brief Callback function prototype to be given for
* pal_register_callback.
*
* \param[in] event_id - event id of the event raised on the
* stream.
* \param[in] event_data - event_data specific to the event
* raised.
* \param[in] cookie - cookie specified in the
* pal_register_global_callback.
*/
typedef int32_t (*pal_global_callback)(uint32_t event_id, uint32_t *event_data, uint64_t cookie);
/** Sound card state */
typedef enum card_status_t {
CARD_STATUS_OFFLINE = 0,
CARD_STATUS_ONLINE,
CARD_STATUS_NONE,
} card_status_t;
typedef struct pal_buffer_config {
size_t buf_count; /**< number of buffers*/
size_t buf_size; /**< This would be the size of each buffer*/
size_t max_metadata_size; /** < max metadata size associated with each buffer*/
} pal_buffer_config_t;
#define PAL_GENERIC_PLATFORM_DELAY (29*1000LL)
#define PAL_DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
#define PAL_SPATIAL_AUDIO_PLATFORM_DELAY (13*1000LL)
#define PAL_PCM_OFFLOAD_PLATFORM_DELAY (30*1000LL)
#define PAL_LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
#define PAL_MMAP_PLATFORM_DELAY (3*1000LL)
#define PAL_ULL_PLATFORM_DELAY (4*1000LL)
#define PAL_VOIP_PLATFORM_DELAY (29*1000LL)
#define PAL_GENERIC_OUTPUT_PERIOD_DURATION 40
#define PAL_DEEP_BUFFER_OUTPUT_PERIOD_DURATION 40
#define PAL_PCM_OFFLOAD_OUTPUT_PERIOD_DURATION 80
#define PAL_LOW_LATENCY_OUTPUT_PERIOD_DURATION 5
#define PAL_SPATIAL_AUDIO_PERIOD_DURATION 10
#define PAL_VOIP_OUTPUT_PERIOD_DURATION 20
#define PAL_GENERIC_PLAYBACK_PERIOD_COUNT 2
#define PAL_DEEP_BUFFER_PLAYBACK_PERIOD_COUNT 2
#define PAL_PCM_OFFLOAD_PLAYBACK_PERIOD_COUNT 2
#define PAL_LOW_LATENCY_PLAYBACK_PERIOD_COUNT 2
#define PAL_SPATIAL_AUDIO_PLAYBACK_PERIOD_COUNT 2
#define PAL_VOIP_PLAYBACK_PERIOD_COUNT 2
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*PAL_DEFS_H*/