blob: d5648396a749cb2b9352cb403a887c06e349a34d [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,
63 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +053064 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1,
65 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2,
Naresh Tannirue3b18452014-03-04 14:44:27 +053066 SND_DEVICE_OUT_VOICE_HANDSET,
67 SND_DEVICE_OUT_VOICE_SPEAKER,
Preetam Singh Ranawatc7f7f5c2015-04-02 12:19:58 +053068 SND_DEVICE_OUT_VOICE_SPEAKER_WSA,
Naresh Tannirue3b18452014-03-04 14:44:27 +053069 SND_DEVICE_OUT_VOICE_HEADPHONES,
70 SND_DEVICE_OUT_HDMI,
71 SND_DEVICE_OUT_SPEAKER_AND_HDMI,
72 SND_DEVICE_OUT_BT_SCO,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053073 SND_DEVICE_OUT_BT_SCO_WB,
Naresh Tannirue3b18452014-03-04 14:44:27 +053074 SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES,
75 SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES,
76 SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET,
Preetam Singh Ranawat7112f3b2015-02-26 16:51:58 +053077 SND_DEVICE_OUT_VOICE_TX,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053078 SND_DEVICE_OUT_AFE_PROXY,
79 SND_DEVICE_OUT_USB_HEADSET,
80 SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET,
81 SND_DEVICE_OUT_TRANSMISSION_FM,
82 SND_DEVICE_OUT_ANC_HEADSET,
83 SND_DEVICE_OUT_ANC_FB_HEADSET,
84 SND_DEVICE_OUT_VOICE_ANC_HEADSET,
85 SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET,
86 SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET,
87 SND_DEVICE_OUT_ANC_HANDSET,
88 SND_DEVICE_OUT_SPEAKER_PROTECTED,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +053089 SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED,
Naresh Tanniruc0517bc2014-10-26 15:30:55 +053090#ifdef RECORD_PLAY_CONCURRENCY
91 SND_DEVICE_OUT_VOIP_HANDSET,
92 SND_DEVICE_OUT_VOIP_SPEAKER,
93 SND_DEVICE_OUT_VOIP_HEADPHONES,
94#endif
Naresh Tannirue3b18452014-03-04 14:44:27 +053095 SND_DEVICE_OUT_END,
96
97 /*
98 * Note: IN_BEGIN should be same as OUT_END because total number of devices
99 * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices.
100 */
101 /* Capture devices */
102 SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END,
103 SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530104 SND_DEVICE_IN_HANDSET_MIC_EXTERNAL,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530105 SND_DEVICE_IN_HANDSET_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530106 SND_DEVICE_IN_HANDSET_MIC_NS,
107 SND_DEVICE_IN_HANDSET_MIC_AEC_NS,
108 SND_DEVICE_IN_HANDSET_DMIC,
109 SND_DEVICE_IN_HANDSET_DMIC_AEC,
110 SND_DEVICE_IN_HANDSET_DMIC_NS,
111 SND_DEVICE_IN_HANDSET_DMIC_AEC_NS,
112 SND_DEVICE_IN_SPEAKER_MIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530113 SND_DEVICE_IN_SPEAKER_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530114 SND_DEVICE_IN_SPEAKER_MIC_NS,
115 SND_DEVICE_IN_SPEAKER_MIC_AEC_NS,
116 SND_DEVICE_IN_SPEAKER_DMIC,
117 SND_DEVICE_IN_SPEAKER_DMIC_AEC,
118 SND_DEVICE_IN_SPEAKER_DMIC_NS,
119 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS,
120 SND_DEVICE_IN_HEADSET_MIC,
121 SND_DEVICE_IN_HEADSET_MIC_FLUENCE,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530122 SND_DEVICE_IN_VOICE_SPEAKER_MIC,
123 SND_DEVICE_IN_VOICE_HEADSET_MIC,
124 SND_DEVICE_IN_HDMI_MIC,
125 SND_DEVICE_IN_BT_SCO_MIC,
Vicky Sehrawate240e5d2014-08-12 17:17:04 -0700126 SND_DEVICE_IN_BT_SCO_MIC_NREC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530127 SND_DEVICE_IN_BT_SCO_MIC_WB,
Vicky Sehrawate240e5d2014-08-12 17:17:04 -0700128 SND_DEVICE_IN_BT_SCO_MIC_WB_NREC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530129 SND_DEVICE_IN_CAMCORDER_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530130 SND_DEVICE_IN_VOICE_DMIC,
131 SND_DEVICE_IN_VOICE_SPEAKER_DMIC,
132 SND_DEVICE_IN_VOICE_SPEAKER_QMIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530133 SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC,
134 SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC,
135 SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC,
136 SND_DEVICE_IN_VOICE_REC_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530137 SND_DEVICE_IN_VOICE_REC_MIC_NS,
138 SND_DEVICE_IN_VOICE_REC_DMIC_STEREO,
139 SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE,
Preetam Singh Ranawat7112f3b2015-02-26 16:51:58 +0530140 SND_DEVICE_IN_VOICE_RX,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530141 SND_DEVICE_IN_USB_HEADSET_MIC,
142 SND_DEVICE_IN_CAPTURE_FM,
143 SND_DEVICE_IN_AANC_HANDSET_MIC,
144 SND_DEVICE_IN_QUAD_MIC,
145 SND_DEVICE_IN_HANDSET_STEREO_DMIC,
146 SND_DEVICE_IN_SPEAKER_STEREO_DMIC,
147 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK,
Karthik Reddy Kattad9fff862014-07-21 21:07:21 +0530148 SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE,
149 SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE,
150 SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE,
151 SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE,
152 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE,
Sidipotu Ashok3bcca232014-11-07 14:41:58 +0530153 SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC,
Karthik Reddy Kattad71b94b2015-01-19 14:06:53 +0530154 SND_DEVICE_IN_HANDSET_QMIC,
155 SND_DEVICE_IN_SPEAKER_QMIC_AEC,
156 SND_DEVICE_IN_SPEAKER_QMIC_NS,
157 SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530158 SND_DEVICE_IN_END,
159
160 SND_DEVICE_MAX = SND_DEVICE_IN_END,
161
162};
163
Naresh Tannirue3b18452014-03-04 14:44:27 +0530164#define DEFAULT_OUTPUT_SAMPLING_RATE 48000
165
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530166#define ALL_SESSION_VSID 0xFFFFFFFF
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530167#define DEFAULT_MUTE_RAMP_DURATION_MS 20
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530168#define DEFAULT_VOLUME_RAMP_DURATION_MS 20
169#define MIXER_PATH_MAX_LENGTH 100
170
171#define MAX_VOL_INDEX 5
172#define MIN_VOL_INDEX 0
173#define percent_to_index(val, min, max) \
174 ((val) * ((max) - (min)) * 0.01 + (min) + .5)
175
Naresh Tannirue3b18452014-03-04 14:44:27 +0530176/*
177 * tinyAlsa library interprets period size as number of frames
178 * one frame = channel_count * sizeof (pcm sample)
179 * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes
180 * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes
181 * We should take care of returning proper size when AudioFlinger queries for
182 * the buffer size of an input/output stream
183 */
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530184#define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530185#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 5
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530186#define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240
Naresh Tannirue3b18452014-03-04 14:44:27 +0530187#define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2
188
Ravi Kumar Alamandadc9bb152014-09-08 15:59:58 -0700189#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000
190#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240
Sharad Sangle896e7b12014-11-07 17:06:29 +0530191#define LOW_LATENCY_CAPTURE_USE_CASE 1
Ravi Kumar Alamandadc9bb152014-09-08 15:59:58 -0700192
Naresh Tannirue3b18452014-03-04 14:44:27 +0530193#define HDMI_MULTI_PERIOD_SIZE 336
194#define HDMI_MULTI_PERIOD_COUNT 8
195#define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6
196#define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2)
197
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530198#define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
199#define AUDIO_CAPTURE_PERIOD_COUNT 2
200
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530201#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000
202#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240
203#define LOW_LATENCY_CAPTURE_USE_CASE 1
204
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530205#define DEVICE_NAME_MAX_SIZE 128
206#define HW_INFO_ARRAY_MAX_SIZE 32
207
208#define DEEP_BUFFER_PCM_DEVICE 0
209#define AUDIO_RECORD_PCM_DEVICE 0
210#define MULTIMEDIA2_PCM_DEVICE 1
211#define FM_PLAYBACK_PCM_DEVICE 5
212#define FM_CAPTURE_PCM_DEVICE 6
213#define HFP_PCM_RX 5
Satya Krishna Pindiproli640c91e2014-03-14 11:09:09 +0530214#define HFP_SCO_RX 17
215#define HFP_ASM_RX_TX 18
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530216
217#define INCALL_MUSIC_UPLINK_PCM_DEVICE 1
218#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16
219#define SPKR_PROT_CALIB_RX_PCM_DEVICE 5
Laxminath Kasam999caa42015-05-08 18:17:23 +0530220#define SPKR_PROT_CALIB_TX_PCM_DEVICE 26
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530221#define PLAYBACK_OFFLOAD_DEVICE 9
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530222
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530223#define COMPRESS_VOIP_CALL_PCM_DEVICE 3
224
Banajit Goswami88d6cc52014-04-10 17:59:02 -0700225/* Define macro for Internal FM volume mixer */
226#define FM_RX_VOLUME "Internal FM RX Volume"
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530227
228#define LOWLATENCY_PCM_DEVICE 12
229#define EC_REF_RX "I2S_RX"
230#define COMPRESS_CAPTURE_DEVICE 19
231
232#define VOICE_CALL_PCM_DEVICE 2
233#define VOICE2_CALL_PCM_DEVICE 13
234#define VOLTE_CALL_PCM_DEVICE 15
Venkata Narendra Kumar Gutta90bef992015-01-28 15:32:45 +0530235#define QCHAT_CALL_PCM_DEVICE 26
Venkata Narendra Kumar Guttaed408a12015-03-31 20:24:04 +0530236#define QCHAT_CALL_PCM_DEVICE_OF_EXT_CODEC 28
Karthik Reddy Katta3b0a60c2014-04-06 14:52:37 +0530237#define VOWLAN_CALL_PCM_DEVICE 16
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530238
Preetam Singh Ranawat7112f3b2015-02-26 16:51:58 +0530239#define AFE_PROXY_PLAYBACK_PCM_DEVICE 7
240#define AFE_PROXY_RECORD_PCM_DEVICE 8
241
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530242#define LIB_CSD_CLIENT "libcsd-client.so"
243/* CSD-CLIENT related functions */
244typedef int (*init_t)();
245typedef int (*deinit_t)();
246typedef int (*disable_device_t)();
247typedef int (*enable_device_config_t)(int, int);
248typedef int (*enable_device_t)(int, int, uint32_t);
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530249typedef int (*volume_t)(uint32_t, int, uint16_t);
250typedef int (*mic_mute_t)(uint32_t, int, uint16_t);
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530251typedef int (*slow_talk_t)(uint32_t, uint8_t);
252typedef int (*start_voice_t)(uint32_t);
253typedef int (*stop_voice_t)(uint32_t);
254typedef int (*start_playback_t)(uint32_t);
255typedef int (*stop_playback_t)(uint32_t);
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -0700256typedef int (*set_lch_t)(uint32_t, enum voice_lch_mode);
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530257typedef int (*start_record_t)(uint32_t, int);
258typedef int (*stop_record_t)(uint32_t);
259/* CSD Client structure */
260struct csd_data {
261 void *csd_client;
262 init_t init;
263 deinit_t deinit;
264 disable_device_t disable_device;
265 enable_device_config_t enable_device_config;
266 enable_device_t enable_device;
267 volume_t volume;
268 mic_mute_t mic_mute;
269 slow_talk_t slow_talk;
270 start_voice_t start_voice;
271 stop_voice_t stop_voice;
272 start_playback_t start_playback;
273 stop_playback_t stop_playback;
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -0700274 set_lch_t set_lch;
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530275 start_record_t start_record;
276 stop_record_t stop_record;
277};
Naresh Tannirue3b18452014-03-04 14:44:27 +0530278
Preetam Singh Ranawat2d0e4632015-02-02 12:40:59 +0530279int platform_get_subsys_image_name (char *buf);
280
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530281/* HDMI Passthrough defines */
282enum {
283 LEGACY_PCM = 0,
284 PASSTHROUGH,
285 PASSTHROUGH_CONVERT
286};
287/*
288 * ID for setting mute and lateny on the device side
289 * through Device PP Params mixer control.
290 */
291#define DEVICE_PARAM_MUTE_ID 0
292#define DEVICE_PARAM_LATENCY_ID 1
Karthik Reddy Kattae4078ed2015-04-21 11:46:15 +0530293
294#define ENUM_TO_STRING(X) #X
295
296struct audio_device_to_audio_interface {
297 audio_devices_t device;
298 char device_name[100];
299 char interface_name[100];
300};
Laxminath Kasam44f49402015-05-29 18:37:11 +0530301
302struct speaker_device_to_tz_names {
303 snd_device_t snd_device;
304 char spkr_1_tz_name[100];
305 char spkr_2_tz_name[100];
306};
Naresh Tannirue3b18452014-03-04 14:44:27 +0530307#endif // QCOM_AUDIO_PLATFORM_H