Home | History | Annotate | Download | only in msm8974
      1 /*
      2  * Copyright (C) 2013-2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef QCOM_AUDIO_PLATFORM_H
     18 #define QCOM_AUDIO_PLATFORM_H
     19 
     20 enum {
     21     FLUENCE_DISABLE,                  /* Target dosent support fluence */
     22     FLUENCE_ENABLE      = 0x1,        /* Target supports fluence */
     23     FLUENCE_PRO_ENABLE  = 0x2,        /* Target supports fluence pro */
     24 };
     25 
     26 enum {
     27     SOURCE_MONO_MIC  = 0x1,            /* Target contains 1 mic */
     28     SOURCE_DUAL_MIC  = 0x2,            /* Target contains 2 mics */
     29     SOURCE_THREE_MIC = 0x4,            /* Target contains 3 mics */
     30     SOURCE_QUAD_MIC  = 0x8,            /* Target contains 4 mics */
     31 };
     32 
     33 /*
     34  * Below are the devices for which is back end is same, SLIMBUS_0_RX.
     35  * All these devices are handled by the internal HW codec. We can
     36  * enable any one of these devices at any time
     37  */
     38 #define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \
     39     (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \
     40      AUDIO_DEVICE_OUT_SPEAKER_SAFE | \
     41      AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE | \
     42      AUDIO_DEVICE_OUT_LINE)
     43 
     44 /* Sound devices specific to the platform
     45  * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound
     46  * devices to enable corresponding mixer paths
     47  */
     48 enum {
     49     SND_DEVICE_NONE = 0,
     50 
     51     /* Playback devices */
     52     SND_DEVICE_MIN,
     53     SND_DEVICE_OUT_BEGIN = SND_DEVICE_MIN,
     54     SND_DEVICE_OUT_HANDSET = SND_DEVICE_OUT_BEGIN,
     55     SND_DEVICE_OUT_SPEAKER,
     56     SND_DEVICE_OUT_SPEAKER_REVERSE,
     57     SND_DEVICE_OUT_SPEAKER_SAFE,
     58     SND_DEVICE_OUT_HEADPHONES,
     59     SND_DEVICE_OUT_LINE,
     60     SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES,
     61     SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES,
     62     SND_DEVICE_OUT_SPEAKER_AND_LINE,
     63     SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE,
     64     SND_DEVICE_OUT_VOICE_HANDSET,
     65     SND_DEVICE_OUT_VOICE_SPEAKER,
     66     SND_DEVICE_OUT_VOICE_HEADPHONES,
     67     SND_DEVICE_OUT_VOICE_LINE,
     68     SND_DEVICE_OUT_HDMI,
     69     SND_DEVICE_OUT_SPEAKER_AND_HDMI,
     70     SND_DEVICE_OUT_BT_SCO,
     71     SND_DEVICE_OUT_BT_SCO_WB,
     72     SND_DEVICE_OUT_VOICE_HANDSET_TMUS,
     73     SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES,
     74     SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES,
     75     SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET,
     76     SND_DEVICE_OUT_VOICE_HAC_HANDSET,
     77     SND_DEVICE_OUT_VOICE_TX,
     78     SND_DEVICE_OUT_SPEAKER_PROTECTED,
     79     SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED,
     80     SND_DEVICE_OUT_VOICE_SPEAKER_HFP,
     81     SND_DEVICE_OUT_END,
     82 
     83     /*
     84      * Note: IN_BEGIN should be same as OUT_END because total number of devices
     85      * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices.
     86      */
     87     /* Capture devices */
     88     SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END,
     89     SND_DEVICE_IN_HANDSET_MIC  = SND_DEVICE_IN_BEGIN,
     90     SND_DEVICE_IN_HANDSET_MIC_AEC,
     91     SND_DEVICE_IN_HANDSET_MIC_NS,
     92     SND_DEVICE_IN_HANDSET_MIC_AEC_NS,
     93     SND_DEVICE_IN_HANDSET_DMIC,
     94     SND_DEVICE_IN_HANDSET_DMIC_AEC,
     95     SND_DEVICE_IN_HANDSET_DMIC_NS,
     96     SND_DEVICE_IN_HANDSET_DMIC_AEC_NS,
     97     SND_DEVICE_IN_HANDSET_DMIC_STEREO,
     98 
     99     SND_DEVICE_IN_SPEAKER_MIC,
    100     SND_DEVICE_IN_SPEAKER_MIC_AEC,
    101     SND_DEVICE_IN_SPEAKER_MIC_NS,
    102     SND_DEVICE_IN_SPEAKER_MIC_AEC_NS,
    103     SND_DEVICE_IN_SPEAKER_DMIC,
    104     SND_DEVICE_IN_SPEAKER_DMIC_AEC,
    105     SND_DEVICE_IN_SPEAKER_DMIC_NS,
    106     SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS,
    107     SND_DEVICE_IN_SPEAKER_DMIC_STEREO,
    108 
    109     SND_DEVICE_IN_HEADSET_MIC,
    110     SND_DEVICE_IN_HEADSET_MIC_AEC,
    111 
    112     SND_DEVICE_IN_HDMI_MIC,
    113     SND_DEVICE_IN_BT_SCO_MIC,
    114     SND_DEVICE_IN_BT_SCO_MIC_NREC,
    115     SND_DEVICE_IN_BT_SCO_MIC_WB,
    116     SND_DEVICE_IN_BT_SCO_MIC_WB_NREC,
    117     SND_DEVICE_IN_CAMCORDER_MIC,
    118 
    119     SND_DEVICE_IN_VOICE_DMIC,
    120     SND_DEVICE_IN_VOICE_DMIC_TMUS,
    121     SND_DEVICE_IN_VOICE_SPEAKER_MIC,
    122     SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP,
    123     SND_DEVICE_IN_VOICE_SPEAKER_DMIC,
    124     SND_DEVICE_IN_VOICE_HEADSET_MIC,
    125     SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC,
    126     SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC,
    127     SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC,
    128 
    129     SND_DEVICE_IN_VOICE_REC_MIC,
    130     SND_DEVICE_IN_VOICE_REC_MIC_NS,
    131     SND_DEVICE_IN_VOICE_REC_MIC_AEC,
    132     SND_DEVICE_IN_VOICE_REC_MIC_AEC_NS,
    133     SND_DEVICE_IN_VOICE_REC_DMIC_STEREO,
    134     SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE,
    135     SND_DEVICE_IN_VOICE_REC_HEADSET_MIC,
    136 
    137     SND_DEVICE_IN_UNPROCESSED_MIC,
    138     SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC,
    139     SND_DEVICE_IN_UNPROCESSED_STEREO_MIC,
    140     SND_DEVICE_IN_UNPROCESSED_THREE_MIC,
    141     SND_DEVICE_IN_UNPROCESSED_QUAD_MIC,
    142 
    143     SND_DEVICE_IN_VOICE_RX,
    144 
    145     SND_DEVICE_IN_THREE_MIC,
    146     SND_DEVICE_IN_QUAD_MIC,
    147     SND_DEVICE_IN_CAPTURE_VI_FEEDBACK,
    148 
    149     SND_DEVICE_IN_HANDSET_TMIC,
    150     SND_DEVICE_IN_HANDSET_QMIC,
    151     SND_DEVICE_IN_HANDSET_TMIC_AEC,
    152     SND_DEVICE_IN_HANDSET_QMIC_AEC,
    153     SND_DEVICE_IN_END,
    154 
    155     SND_DEVICE_MAX = SND_DEVICE_IN_END,
    156 
    157 };
    158 
    159 #define DEVICE_NAME_MAX_SIZE   128
    160 #define HW_INFO_ARRAY_MAX_SIZE 32
    161 
    162 #define DEFAULT_OUTPUT_SAMPLING_RATE 48000
    163 
    164 #define ALL_SESSION_VSID                0xFFFFFFFF
    165 #define DEFAULT_MUTE_RAMP_DURATION_MS   20
    166 #define DEFAULT_VOLUME_RAMP_DURATION_MS 20
    167 #define MIXER_PATH_MAX_LENGTH 100
    168 
    169 #define ACDB_ID_VOICE_SPEAKER 15
    170 #define ACDB_ID_VOICE_HANDSET 7
    171 #define ACDB_ID_VOICE_HANDSET_TMUS 88
    172 #define ACDB_ID_VOICE_DMIC_EF_TMUS 89
    173 #define ACDB_ID_HEADSET_MIC_AEC 8
    174 #define ACDB_ID_VOICE_REC_MIC 62
    175 
    176 #define MAX_VOL_INDEX 5
    177 #define MIN_VOL_INDEX 0
    178 #define percent_to_index(val, min, max) \
    179             ((val) * ((max) - (min)) * 0.01 + (min) + .5)
    180 
    181 /*
    182  * tinyAlsa library interprets period size as number of frames
    183  * one frame = channel_count * sizeof (pcm sample)
    184  * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes
    185  * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes
    186  * We should take care of returning proper size when AudioFlinger queries for
    187  * the buffer size of an input/output stream
    188  */
    189 
    190 /* 1920 frames(40ms) at 2 buffers gives a good tradeoff between power and latency */
    191 #define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 1920
    192 #define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 2
    193 
    194 #define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240
    195 #define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2
    196 
    197 #define HDMI_MULTI_PERIOD_SIZE  336
    198 #define HDMI_MULTI_PERIOD_COUNT 8
    199 #define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6
    200 #define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2)
    201 
    202 #define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
    203 #define AUDIO_CAPTURE_PERIOD_COUNT 2
    204 
    205 #define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000
    206 #define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240
    207 #define LOW_LATENCY_CAPTURE_USE_CASE 1
    208 
    209 #define DEEP_BUFFER_PCM_DEVICE 0
    210 #define AUDIO_RECORD_PCM_DEVICE 0
    211 #define MULTIMEDIA2_PCM_DEVICE 1
    212 
    213 #define SPKR_PROT_CALIB_RX_PCM_DEVICE 5
    214 #define SPKR_PROT_CALIB_TX_PCM_DEVICE 25
    215 
    216 #define MULTIMEDIA3_PCM_DEVICE 4
    217 
    218 #define QUAT_MI2S_PCM_DEVICE    44
    219 #define PLAYBACK_OFFLOAD_DEVICE 9
    220 #define LOWLATENCY_PCM_DEVICE 15
    221 #define VOICE_VSID  0x10C01000
    222 
    223 #ifdef PLATFORM_MSM8x26
    224 #define VOICE_CALL_PCM_DEVICE 2
    225 #define VOICE2_CALL_PCM_DEVICE 14
    226 #define VOLTE_CALL_PCM_DEVICE 17
    227 #define QCHAT_CALL_PCM_DEVICE 18
    228 #define VOWLAN_CALL_PCM_DEVICE 30
    229 #elif PLATFORM_MSM8084
    230 #define VOICE_CALL_PCM_DEVICE 20
    231 #define VOICE2_CALL_PCM_DEVICE 25
    232 #define VOLTE_CALL_PCM_DEVICE 21
    233 #define QCHAT_CALL_PCM_DEVICE 33
    234 #define VOWLAN_CALL_PCM_DEVICE -1
    235 #elif PLATFORM_MSM8996
    236 #define VOICE_CALL_PCM_DEVICE 40
    237 #define VOICE2_CALL_PCM_DEVICE 41
    238 #define VOLTE_CALL_PCM_DEVICE 14
    239 #define QCHAT_CALL_PCM_DEVICE 20
    240 #define VOWLAN_CALL_PCM_DEVICE 33
    241 #else
    242 #define VOICE_CALL_PCM_DEVICE 2
    243 #define VOICE2_CALL_PCM_DEVICE 22
    244 #define VOLTE_CALL_PCM_DEVICE 14
    245 #define QCHAT_CALL_PCM_DEVICE 20
    246 #define VOWLAN_CALL_PCM_DEVICE 36
    247 #endif
    248 
    249 #ifdef PLATFORM_MSM8996
    250 #define VOICEMMODE1_CALL_PCM_DEVICE 2
    251 #define VOICEMMODE2_CALL_PCM_DEVICE 22
    252 #else
    253 #define VOICEMMODE1_CALL_PCM_DEVICE 44
    254 #define VOICEMMODE2_CALL_PCM_DEVICE 45
    255 #endif
    256 
    257 #define AFE_PROXY_PLAYBACK_PCM_DEVICE 7
    258 #define AFE_PROXY_RECORD_PCM_DEVICE 8
    259 
    260 #define HFP_PCM_RX 5
    261 #ifdef PLATFORM_MSM8x26
    262 #ifdef EXTERNAL_BT_SUPPORTED
    263 #define HFP_SCO_RX 10 // AUXPCM Hostless
    264 #else
    265 #define HFP_SCO_RX 28 // INT_HFP_BT Hostless
    266 #endif
    267 #define HFP_ASM_RX_TX 29
    268 #else
    269 #define HFP_SCO_RX 23
    270 #define HFP_ASM_RX_TX 24
    271 #endif
    272 
    273 #define LIB_CSD_CLIENT "libcsd-client.so"
    274 #define LIB_MDM_DETECT "libmdmdetect.so"
    275 
    276 #define PLATFORM_CONFIG_KEY_SOUNDCARD_NAME "snd_card_name"
    277 #define PLATFORM_CONFIG_KEY_MAX_MIC_COUNT "input_mic_max_count"
    278 #define PLATFORM_DEFAULT_MIC_COUNT 2
    279 
    280 /* CSD-CLIENT related functions */
    281 typedef int (*init_t)(bool);
    282 typedef int (*deinit_t)();
    283 typedef int (*disable_device_t)();
    284 typedef int (*enable_device_config_t)(int, int);
    285 typedef int (*enable_device_t)(int, int, uint32_t);
    286 typedef int (*volume_t)(uint32_t, int, uint16_t);
    287 typedef int (*mic_mute_t)(uint32_t, int, uint16_t);
    288 typedef int (*slow_talk_t)(uint32_t, uint8_t);
    289 typedef int (*start_voice_t)(uint32_t);
    290 typedef int (*stop_voice_t)(uint32_t);
    291 typedef int (*start_playback_t)(uint32_t);
    292 typedef int (*stop_playback_t)(uint32_t);
    293 typedef int (*start_record_t)(uint32_t, int);
    294 typedef int (*stop_record_t)(uint32_t);
    295 typedef int (*get_sample_rate_t)(uint32_t *);
    296 /* CSD Client structure */
    297 struct csd_data {
    298     void *csd_client;
    299     init_t init;
    300     deinit_t deinit;
    301     disable_device_t disable_device;
    302     enable_device_config_t enable_device_config;
    303     enable_device_t enable_device;
    304     volume_t volume;
    305     mic_mute_t mic_mute;
    306     slow_talk_t slow_talk;
    307     start_voice_t start_voice;
    308     stop_voice_t stop_voice;
    309     start_playback_t start_playback;
    310     stop_playback_t stop_playback;
    311     start_record_t start_record;
    312     stop_record_t stop_record;
    313     get_sample_rate_t get_sample_rate;
    314 };
    315 
    316 #define PLATFORM_INFO_XML_PATH          "/system/etc/audio_platform_info.xml"
    317 #define PLATFORM_INFO_XML_BASE_STRING   "/system/etc/audio_platform_info"
    318 #endif // QCOM_AUDIO_PLATFORM_H
    319