blob: 58c48b6c5777a16f4153a07c5b7ee1b5e2359d11 [file] [log] [blame]
Naresh Tannirue3b18452014-03-04 14:44:27 +05301/*
Naresh Tannirudb72d1e2014-03-05 17:33:47 +05302 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
3 * Not a Contribution.
4 *
Naresh Tannirue3b18452014-03-04 14:44:27 +05305 * Copyright (C) 2013 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#ifndef QCOM_AUDIO_PLATFORM_H
21#define QCOM_AUDIO_PLATFORM_H
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -070022#include <sound/voice_params.h>
Naresh Tannirue3b18452014-03-04 14:44:27 +053023
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053024enum {
25 FLUENCE_NONE,
26 FLUENCE_DUAL_MIC = 0x1,
27 FLUENCE_QUAD_MIC = 0x2,
28};
29
Karthik Reddy Kattad9fff862014-07-21 21:07:21 +053030enum {
31 FLUENCE_ENDFIRE = 0x1,
32 FLUENCE_BROADSIDE = 0x2,
33};
34
Naresh Tannirue3b18452014-03-04 14:44:27 +053035/*
36 * Below are the devices for which is back end is same, SLIMBUS_0_RX.
37 * All these devices are handled by the internal HW codec. We can
38 * enable any one of these devices at any time
39 */
40#define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \
41 (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \
42 AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE)
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 */
48enum {
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_HEADPHONES,
58 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES,
59 SND_DEVICE_OUT_VOICE_HANDSET,
60 SND_DEVICE_OUT_VOICE_SPEAKER,
61 SND_DEVICE_OUT_VOICE_HEADPHONES,
62 SND_DEVICE_OUT_HDMI,
63 SND_DEVICE_OUT_SPEAKER_AND_HDMI,
64 SND_DEVICE_OUT_BT_SCO,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053065 SND_DEVICE_OUT_BT_SCO_WB,
Naresh Tannirue3b18452014-03-04 14:44:27 +053066 SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES,
67 SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES,
68 SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053069 SND_DEVICE_OUT_AFE_PROXY,
70 SND_DEVICE_OUT_USB_HEADSET,
71 SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET,
72 SND_DEVICE_OUT_TRANSMISSION_FM,
73 SND_DEVICE_OUT_ANC_HEADSET,
74 SND_DEVICE_OUT_ANC_FB_HEADSET,
75 SND_DEVICE_OUT_VOICE_ANC_HEADSET,
76 SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET,
77 SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET,
78 SND_DEVICE_OUT_ANC_HANDSET,
79 SND_DEVICE_OUT_SPEAKER_PROTECTED,
Naresh Tanniruc0517bc2014-10-26 15:30:55 +053080#ifdef RECORD_PLAY_CONCURRENCY
81 SND_DEVICE_OUT_VOIP_HANDSET,
82 SND_DEVICE_OUT_VOIP_SPEAKER,
83 SND_DEVICE_OUT_VOIP_HEADPHONES,
84#endif
Naresh Tannirue3b18452014-03-04 14:44:27 +053085 SND_DEVICE_OUT_END,
86
87 /*
88 * Note: IN_BEGIN should be same as OUT_END because total number of devices
89 * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices.
90 */
91 /* Capture devices */
92 SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END,
93 SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN,
Naresh Tannirue3b18452014-03-04 14:44:27 +053094 SND_DEVICE_IN_HANDSET_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053095 SND_DEVICE_IN_HANDSET_MIC_NS,
96 SND_DEVICE_IN_HANDSET_MIC_AEC_NS,
97 SND_DEVICE_IN_HANDSET_DMIC,
98 SND_DEVICE_IN_HANDSET_DMIC_AEC,
99 SND_DEVICE_IN_HANDSET_DMIC_NS,
100 SND_DEVICE_IN_HANDSET_DMIC_AEC_NS,
101 SND_DEVICE_IN_SPEAKER_MIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530102 SND_DEVICE_IN_SPEAKER_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530103 SND_DEVICE_IN_SPEAKER_MIC_NS,
104 SND_DEVICE_IN_SPEAKER_MIC_AEC_NS,
105 SND_DEVICE_IN_SPEAKER_DMIC,
106 SND_DEVICE_IN_SPEAKER_DMIC_AEC,
107 SND_DEVICE_IN_SPEAKER_DMIC_NS,
108 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS,
109 SND_DEVICE_IN_HEADSET_MIC,
110 SND_DEVICE_IN_HEADSET_MIC_FLUENCE,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530111 SND_DEVICE_IN_VOICE_SPEAKER_MIC,
112 SND_DEVICE_IN_VOICE_HEADSET_MIC,
113 SND_DEVICE_IN_HDMI_MIC,
114 SND_DEVICE_IN_BT_SCO_MIC,
Vicky Sehrawate240e5d2014-08-12 17:17:04 -0700115 SND_DEVICE_IN_BT_SCO_MIC_NREC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530116 SND_DEVICE_IN_BT_SCO_MIC_WB,
Vicky Sehrawate240e5d2014-08-12 17:17:04 -0700117 SND_DEVICE_IN_BT_SCO_MIC_WB_NREC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530118 SND_DEVICE_IN_CAMCORDER_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530119 SND_DEVICE_IN_VOICE_DMIC,
120 SND_DEVICE_IN_VOICE_SPEAKER_DMIC,
121 SND_DEVICE_IN_VOICE_SPEAKER_QMIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530122 SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC,
123 SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC,
124 SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC,
125 SND_DEVICE_IN_VOICE_REC_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530126 SND_DEVICE_IN_VOICE_REC_MIC_NS,
127 SND_DEVICE_IN_VOICE_REC_DMIC_STEREO,
128 SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE,
129 SND_DEVICE_IN_USB_HEADSET_MIC,
130 SND_DEVICE_IN_CAPTURE_FM,
131 SND_DEVICE_IN_AANC_HANDSET_MIC,
132 SND_DEVICE_IN_QUAD_MIC,
133 SND_DEVICE_IN_HANDSET_STEREO_DMIC,
134 SND_DEVICE_IN_SPEAKER_STEREO_DMIC,
135 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK,
Karthik Reddy Kattad9fff862014-07-21 21:07:21 +0530136 SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE,
137 SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE,
138 SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE,
139 SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE,
140 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE,
Sidipotu Ashok3bcca232014-11-07 14:41:58 +0530141 SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530142 SND_DEVICE_IN_END,
143
144 SND_DEVICE_MAX = SND_DEVICE_IN_END,
145
146};
147
Naresh Tannirue3b18452014-03-04 14:44:27 +0530148#define DEFAULT_OUTPUT_SAMPLING_RATE 48000
149
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530150#define ALL_SESSION_VSID 0xFFFFFFFF
151#define DEFAULT_MUTE_RAMP_DURATION 500
152#define DEFAULT_VOLUME_RAMP_DURATION_MS 20
153#define MIXER_PATH_MAX_LENGTH 100
154
155#define MAX_VOL_INDEX 5
156#define MIN_VOL_INDEX 0
157#define percent_to_index(val, min, max) \
158 ((val) * ((max) - (min)) * 0.01 + (min) + .5)
159
Naresh Tannirue3b18452014-03-04 14:44:27 +0530160/*
161 * tinyAlsa library interprets period size as number of frames
162 * one frame = channel_count * sizeof (pcm sample)
163 * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes
164 * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes
165 * We should take care of returning proper size when AudioFlinger queries for
166 * the buffer size of an input/output stream
167 */
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530168#define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960
169#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 4
170#define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240
Naresh Tannirue3b18452014-03-04 14:44:27 +0530171#define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2
172
Ravi Kumar Alamandadc9bb152014-09-08 15:59:58 -0700173#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000
174#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240
175#define LOW_LATENCY_CAPTURE_USE_CASE 0
176
Naresh Tannirue3b18452014-03-04 14:44:27 +0530177#define HDMI_MULTI_PERIOD_SIZE 336
178#define HDMI_MULTI_PERIOD_COUNT 8
179#define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6
180#define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2)
181
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530182#define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
183#define AUDIO_CAPTURE_PERIOD_COUNT 2
184
185#define DEVICE_NAME_MAX_SIZE 128
186#define HW_INFO_ARRAY_MAX_SIZE 32
187
188#define DEEP_BUFFER_PCM_DEVICE 0
189#define AUDIO_RECORD_PCM_DEVICE 0
190#define MULTIMEDIA2_PCM_DEVICE 1
191#define FM_PLAYBACK_PCM_DEVICE 5
192#define FM_CAPTURE_PCM_DEVICE 6
193#define HFP_PCM_RX 5
Satya Krishna Pindiproli640c91e2014-03-14 11:09:09 +0530194#define HFP_SCO_RX 17
195#define HFP_ASM_RX_TX 18
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530196
197#define INCALL_MUSIC_UPLINK_PCM_DEVICE 1
198#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16
199#define SPKR_PROT_CALIB_RX_PCM_DEVICE 5
200#define SPKR_PROT_CALIB_TX_PCM_DEVICE 22
201#define PLAYBACK_OFFLOAD_DEVICE 9
202#define COMPRESS_VOIP_CALL_PCM_DEVICE 3
203
Banajit Goswami88d6cc52014-04-10 17:59:02 -0700204/* Define macro for Internal FM volume mixer */
205#define FM_RX_VOLUME "Internal FM RX Volume"
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530206
207#define LOWLATENCY_PCM_DEVICE 12
208#define EC_REF_RX "I2S_RX"
209#define COMPRESS_CAPTURE_DEVICE 19
210
211#define VOICE_CALL_PCM_DEVICE 2
212#define VOICE2_CALL_PCM_DEVICE 13
213#define VOLTE_CALL_PCM_DEVICE 15
214#define QCHAT_CALL_PCM_DEVICE 14
Karthik Reddy Katta3b0a60c2014-04-06 14:52:37 +0530215#define VOWLAN_CALL_PCM_DEVICE 16
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530216
217#define LIB_CSD_CLIENT "libcsd-client.so"
218/* CSD-CLIENT related functions */
219typedef int (*init_t)();
220typedef int (*deinit_t)();
221typedef int (*disable_device_t)();
222typedef int (*enable_device_config_t)(int, int);
223typedef int (*enable_device_t)(int, int, uint32_t);
224typedef int (*volume_t)(uint32_t, int);
225typedef int (*mic_mute_t)(uint32_t, int);
226typedef int (*slow_talk_t)(uint32_t, uint8_t);
227typedef int (*start_voice_t)(uint32_t);
228typedef int (*stop_voice_t)(uint32_t);
229typedef int (*start_playback_t)(uint32_t);
230typedef int (*stop_playback_t)(uint32_t);
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -0700231typedef int (*set_lch_t)(uint32_t, enum voice_lch_mode);
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530232typedef int (*start_record_t)(uint32_t, int);
233typedef int (*stop_record_t)(uint32_t);
234/* CSD Client structure */
235struct csd_data {
236 void *csd_client;
237 init_t init;
238 deinit_t deinit;
239 disable_device_t disable_device;
240 enable_device_config_t enable_device_config;
241 enable_device_t enable_device;
242 volume_t volume;
243 mic_mute_t mic_mute;
244 slow_talk_t slow_talk;
245 start_voice_t start_voice;
246 stop_voice_t stop_voice;
247 start_playback_t start_playback;
248 stop_playback_t stop_playback;
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -0700249 set_lch_t set_lch;
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530250 start_record_t start_record;
251 stop_record_t stop_record;
252};
Naresh Tannirue3b18452014-03-04 14:44:27 +0530253
254#endif // QCOM_AUDIO_PLATFORM_H