blob: 731b890362e8dbb5dc2dcbacc560ce5996815012 [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
Preetam Singh Ranawat2d0e4632015-02-02 12:40:59 +053035#define PLATFORM_IMAGE_NAME "modem"
36
Naresh Tannirue3b18452014-03-04 14:44:27 +053037/*
38 * Below are the devices for which is back end is same, SLIMBUS_0_RX.
39 * All these devices are handled by the internal HW codec. We can
40 * enable any one of these devices at any time
41 */
42#define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \
43 (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \
44 AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE)
45
46/* Sound devices specific to the platform
47 * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound
48 * devices to enable corresponding mixer paths
49 */
50enum {
51 SND_DEVICE_NONE = 0,
52
53 /* Playback devices */
54 SND_DEVICE_MIN,
55 SND_DEVICE_OUT_BEGIN = SND_DEVICE_MIN,
56 SND_DEVICE_OUT_HANDSET = SND_DEVICE_OUT_BEGIN,
57 SND_DEVICE_OUT_SPEAKER,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +053058 SND_DEVICE_OUT_SPEAKER_EXTERNAL_1,
59 SND_DEVICE_OUT_SPEAKER_EXTERNAL_2,
Naresh Tannirue3b18452014-03-04 14:44:27 +053060 SND_DEVICE_OUT_SPEAKER_REVERSE,
Preetam Singh Ranawatc7f7f5c2015-04-02 12:19:58 +053061 SND_DEVICE_OUT_SPEAKER_WSA,
Naresh Tannirue3b18452014-03-04 14:44:27 +053062 SND_DEVICE_OUT_HEADPHONES,
Apoorv Raghuvanshi21492162015-02-19 18:19:36 -080063 SND_DEVICE_OUT_HEADPHONES_44_1,
Naresh Tannirue3b18452014-03-04 14:44:27 +053064 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +053065 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1,
66 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2,
Naresh Tannirue3b18452014-03-04 14:44:27 +053067 SND_DEVICE_OUT_VOICE_HANDSET,
68 SND_DEVICE_OUT_VOICE_SPEAKER,
Preetam Singh Ranawatc7f7f5c2015-04-02 12:19:58 +053069 SND_DEVICE_OUT_VOICE_SPEAKER_WSA,
Naresh Tannirue3b18452014-03-04 14:44:27 +053070 SND_DEVICE_OUT_VOICE_HEADPHONES,
71 SND_DEVICE_OUT_HDMI,
72 SND_DEVICE_OUT_SPEAKER_AND_HDMI,
73 SND_DEVICE_OUT_BT_SCO,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053074 SND_DEVICE_OUT_BT_SCO_WB,
Naresh Tannirue3b18452014-03-04 14:44:27 +053075 SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES,
76 SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES,
77 SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET,
Preetam Singh Ranawat7112f3b2015-02-26 16:51:58 +053078 SND_DEVICE_OUT_VOICE_TX,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053079 SND_DEVICE_OUT_AFE_PROXY,
80 SND_DEVICE_OUT_USB_HEADSET,
81 SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET,
82 SND_DEVICE_OUT_TRANSMISSION_FM,
83 SND_DEVICE_OUT_ANC_HEADSET,
84 SND_DEVICE_OUT_ANC_FB_HEADSET,
85 SND_DEVICE_OUT_VOICE_ANC_HEADSET,
86 SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET,
87 SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET,
88 SND_DEVICE_OUT_ANC_HANDSET,
89 SND_DEVICE_OUT_SPEAKER_PROTECTED,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +053090 SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED,
Naresh Tanniruc0517bc2014-10-26 15:30:55 +053091#ifdef RECORD_PLAY_CONCURRENCY
92 SND_DEVICE_OUT_VOIP_HANDSET,
93 SND_DEVICE_OUT_VOIP_SPEAKER,
94 SND_DEVICE_OUT_VOIP_HEADPHONES,
95#endif
Naresh Tannirue3b18452014-03-04 14:44:27 +053096 SND_DEVICE_OUT_END,
97
98 /*
99 * Note: IN_BEGIN should be same as OUT_END because total number of devices
100 * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices.
101 */
102 /* Capture devices */
103 SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END,
104 SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530105 SND_DEVICE_IN_HANDSET_MIC_EXTERNAL,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530106 SND_DEVICE_IN_HANDSET_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530107 SND_DEVICE_IN_HANDSET_MIC_NS,
108 SND_DEVICE_IN_HANDSET_MIC_AEC_NS,
109 SND_DEVICE_IN_HANDSET_DMIC,
110 SND_DEVICE_IN_HANDSET_DMIC_AEC,
111 SND_DEVICE_IN_HANDSET_DMIC_NS,
112 SND_DEVICE_IN_HANDSET_DMIC_AEC_NS,
113 SND_DEVICE_IN_SPEAKER_MIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530114 SND_DEVICE_IN_SPEAKER_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530115 SND_DEVICE_IN_SPEAKER_MIC_NS,
116 SND_DEVICE_IN_SPEAKER_MIC_AEC_NS,
117 SND_DEVICE_IN_SPEAKER_DMIC,
118 SND_DEVICE_IN_SPEAKER_DMIC_AEC,
119 SND_DEVICE_IN_SPEAKER_DMIC_NS,
120 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS,
121 SND_DEVICE_IN_HEADSET_MIC,
122 SND_DEVICE_IN_HEADSET_MIC_FLUENCE,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530123 SND_DEVICE_IN_VOICE_SPEAKER_MIC,
124 SND_DEVICE_IN_VOICE_HEADSET_MIC,
125 SND_DEVICE_IN_HDMI_MIC,
126 SND_DEVICE_IN_BT_SCO_MIC,
Vicky Sehrawate240e5d2014-08-12 17:17:04 -0700127 SND_DEVICE_IN_BT_SCO_MIC_NREC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530128 SND_DEVICE_IN_BT_SCO_MIC_WB,
Vicky Sehrawate240e5d2014-08-12 17:17:04 -0700129 SND_DEVICE_IN_BT_SCO_MIC_WB_NREC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530130 SND_DEVICE_IN_CAMCORDER_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530131 SND_DEVICE_IN_VOICE_DMIC,
132 SND_DEVICE_IN_VOICE_SPEAKER_DMIC,
133 SND_DEVICE_IN_VOICE_SPEAKER_QMIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530134 SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC,
135 SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC,
136 SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC,
137 SND_DEVICE_IN_VOICE_REC_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530138 SND_DEVICE_IN_VOICE_REC_MIC_NS,
139 SND_DEVICE_IN_VOICE_REC_DMIC_STEREO,
140 SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE,
Preetam Singh Ranawat7112f3b2015-02-26 16:51:58 +0530141 SND_DEVICE_IN_VOICE_RX,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530142 SND_DEVICE_IN_USB_HEADSET_MIC,
143 SND_DEVICE_IN_CAPTURE_FM,
144 SND_DEVICE_IN_AANC_HANDSET_MIC,
145 SND_DEVICE_IN_QUAD_MIC,
146 SND_DEVICE_IN_HANDSET_STEREO_DMIC,
147 SND_DEVICE_IN_SPEAKER_STEREO_DMIC,
148 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK,
Karthik Reddy Kattad9fff862014-07-21 21:07:21 +0530149 SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE,
150 SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE,
151 SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE,
152 SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE,
153 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE,
Sidipotu Ashok3bcca232014-11-07 14:41:58 +0530154 SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC,
Karthik Reddy Kattad71b94b2015-01-19 14:06:53 +0530155 SND_DEVICE_IN_HANDSET_QMIC,
156 SND_DEVICE_IN_SPEAKER_QMIC_AEC,
157 SND_DEVICE_IN_SPEAKER_QMIC_NS,
158 SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530159 SND_DEVICE_IN_END,
160
161 SND_DEVICE_MAX = SND_DEVICE_IN_END,
162
163};
164
Naresh Tannirue3b18452014-03-04 14:44:27 +0530165#define DEFAULT_OUTPUT_SAMPLING_RATE 48000
Apoorv Raghuvanshi21492162015-02-19 18:19:36 -0800166#define OUTPUT_SAMPLING_RATE_44100 44100
167
168enum {
169 DEFAULT_CODEC_BACKEND,
170 HEADPHONE_44_1_BACKEND,
171 MAX_CODEC_BACKENDS
172};
Naresh Tannirue3b18452014-03-04 14:44:27 +0530173
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530174#define ALL_SESSION_VSID 0xFFFFFFFF
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530175#define DEFAULT_MUTE_RAMP_DURATION_MS 20
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530176#define DEFAULT_VOLUME_RAMP_DURATION_MS 20
177#define MIXER_PATH_MAX_LENGTH 100
178
179#define MAX_VOL_INDEX 5
180#define MIN_VOL_INDEX 0
181#define percent_to_index(val, min, max) \
182 ((val) * ((max) - (min)) * 0.01 + (min) + .5)
183
Naresh Tannirue3b18452014-03-04 14:44:27 +0530184/*
185 * tinyAlsa library interprets period size as number of frames
186 * one frame = channel_count * sizeof (pcm sample)
187 * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes
188 * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes
189 * We should take care of returning proper size when AudioFlinger queries for
190 * the buffer size of an input/output stream
191 */
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530192#define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530193#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 5
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530194#define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240
Naresh Tannirue3b18452014-03-04 14:44:27 +0530195#define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2
196
Ravi Kumar Alamandadc9bb152014-09-08 15:59:58 -0700197#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000
198#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240
Sharad Sangle896e7b12014-11-07 17:06:29 +0530199#define LOW_LATENCY_CAPTURE_USE_CASE 1
Ravi Kumar Alamandadc9bb152014-09-08 15:59:58 -0700200
Naresh Tannirue3b18452014-03-04 14:44:27 +0530201#define HDMI_MULTI_PERIOD_SIZE 336
202#define HDMI_MULTI_PERIOD_COUNT 8
203#define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6
204#define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2)
205
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530206#define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
207#define AUDIO_CAPTURE_PERIOD_COUNT 2
208
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530209#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000
210#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240
211#define LOW_LATENCY_CAPTURE_USE_CASE 1
212
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530213#define DEVICE_NAME_MAX_SIZE 128
214#define HW_INFO_ARRAY_MAX_SIZE 32
215
216#define DEEP_BUFFER_PCM_DEVICE 0
217#define AUDIO_RECORD_PCM_DEVICE 0
218#define MULTIMEDIA2_PCM_DEVICE 1
219#define FM_PLAYBACK_PCM_DEVICE 5
220#define FM_CAPTURE_PCM_DEVICE 6
221#define HFP_PCM_RX 5
Satya Krishna Pindiproli640c91e2014-03-14 11:09:09 +0530222#define HFP_SCO_RX 17
223#define HFP_ASM_RX_TX 18
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530224
225#define INCALL_MUSIC_UPLINK_PCM_DEVICE 1
226#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16
227#define SPKR_PROT_CALIB_RX_PCM_DEVICE 5
Laxminath Kasam999caa42015-05-08 18:17:23 +0530228#define SPKR_PROT_CALIB_TX_PCM_DEVICE 26
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530229#define PLAYBACK_OFFLOAD_DEVICE 9
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530230
231#ifdef MULTIPLE_OFFLOAD_ENABLED
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530232#define PLAYBACK_OFFLOAD_DEVICE2 17
233#define PLAYBACK_OFFLOAD_DEVICE3 18
234#define PLAYBACK_OFFLOAD_DEVICE4 37
235#define PLAYBACK_OFFLOAD_DEVICE5 38
236#define PLAYBACK_OFFLOAD_DEVICE6 39
237#define PLAYBACK_OFFLOAD_DEVICE7 40
238#define PLAYBACK_OFFLOAD_DEVICE8 41
239#define PLAYBACK_OFFLOAD_DEVICE9 42
240#endif
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530241
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530242#define COMPRESS_VOIP_CALL_PCM_DEVICE 3
243
Banajit Goswami88d6cc52014-04-10 17:59:02 -0700244/* Define macro for Internal FM volume mixer */
245#define FM_RX_VOLUME "Internal FM RX Volume"
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530246
247#define LOWLATENCY_PCM_DEVICE 12
248#define EC_REF_RX "I2S_RX"
249#define COMPRESS_CAPTURE_DEVICE 19
250
251#define VOICE_CALL_PCM_DEVICE 2
252#define VOICE2_CALL_PCM_DEVICE 13
253#define VOLTE_CALL_PCM_DEVICE 15
Venkata Narendra Kumar Gutta90bef992015-01-28 15:32:45 +0530254#define QCHAT_CALL_PCM_DEVICE 26
Venkata Narendra Kumar Guttaed408a12015-03-31 20:24:04 +0530255#define QCHAT_CALL_PCM_DEVICE_OF_EXT_CODEC 28
Karthik Reddy Katta3b0a60c2014-04-06 14:52:37 +0530256#define VOWLAN_CALL_PCM_DEVICE 16
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530257
Preetam Singh Ranawat7112f3b2015-02-26 16:51:58 +0530258#define AFE_PROXY_PLAYBACK_PCM_DEVICE 7
259#define AFE_PROXY_RECORD_PCM_DEVICE 8
260
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530261#define LIB_CSD_CLIENT "libcsd-client.so"
262/* CSD-CLIENT related functions */
263typedef int (*init_t)();
264typedef int (*deinit_t)();
265typedef int (*disable_device_t)();
266typedef int (*enable_device_config_t)(int, int);
267typedef int (*enable_device_t)(int, int, uint32_t);
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530268typedef int (*volume_t)(uint32_t, int, uint16_t);
269typedef int (*mic_mute_t)(uint32_t, int, uint16_t);
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530270typedef int (*slow_talk_t)(uint32_t, uint8_t);
271typedef int (*start_voice_t)(uint32_t);
272typedef int (*stop_voice_t)(uint32_t);
273typedef int (*start_playback_t)(uint32_t);
274typedef int (*stop_playback_t)(uint32_t);
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -0700275typedef int (*set_lch_t)(uint32_t, enum voice_lch_mode);
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530276typedef int (*start_record_t)(uint32_t, int);
277typedef int (*stop_record_t)(uint32_t);
278/* CSD Client structure */
279struct csd_data {
280 void *csd_client;
281 init_t init;
282 deinit_t deinit;
283 disable_device_t disable_device;
284 enable_device_config_t enable_device_config;
285 enable_device_t enable_device;
286 volume_t volume;
287 mic_mute_t mic_mute;
288 slow_talk_t slow_talk;
289 start_voice_t start_voice;
290 stop_voice_t stop_voice;
291 start_playback_t start_playback;
292 stop_playback_t stop_playback;
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -0700293 set_lch_t set_lch;
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530294 start_record_t start_record;
295 stop_record_t stop_record;
296};
Naresh Tannirue3b18452014-03-04 14:44:27 +0530297
Preetam Singh Ranawat2d0e4632015-02-02 12:40:59 +0530298int platform_get_subsys_image_name (char *buf);
299
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530300/* HDMI Passthrough defines */
301enum {
302 LEGACY_PCM = 0,
303 PASSTHROUGH,
304 PASSTHROUGH_CONVERT
305};
306/*
307 * ID for setting mute and lateny on the device side
308 * through Device PP Params mixer control.
309 */
310#define DEVICE_PARAM_MUTE_ID 0
311#define DEVICE_PARAM_LATENCY_ID 1
Karthik Reddy Kattae4078ed2015-04-21 11:46:15 +0530312
313#define ENUM_TO_STRING(X) #X
314
315struct audio_device_to_audio_interface {
316 audio_devices_t device;
317 char device_name[100];
318 char interface_name[100];
319};
Naresh Tannirue3b18452014-03-04 14:44:27 +0530320#endif // QCOM_AUDIO_PLATFORM_H