blob: 6c81b95c0eac5946f66f6de0fa2cc188b1d584b1 [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,
58 SND_DEVICE_OUT_SPEAKER_REVERSE,
59 SND_DEVICE_OUT_HEADPHONES,
60 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES,
61 SND_DEVICE_OUT_VOICE_HANDSET,
62 SND_DEVICE_OUT_VOICE_SPEAKER,
63 SND_DEVICE_OUT_VOICE_HEADPHONES,
64 SND_DEVICE_OUT_HDMI,
65 SND_DEVICE_OUT_SPEAKER_AND_HDMI,
66 SND_DEVICE_OUT_BT_SCO,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053067 SND_DEVICE_OUT_BT_SCO_WB,
Naresh Tannirue3b18452014-03-04 14:44:27 +053068 SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES,
69 SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES,
70 SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053071 SND_DEVICE_OUT_AFE_PROXY,
72 SND_DEVICE_OUT_USB_HEADSET,
73 SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET,
74 SND_DEVICE_OUT_TRANSMISSION_FM,
75 SND_DEVICE_OUT_ANC_HEADSET,
76 SND_DEVICE_OUT_ANC_FB_HEADSET,
77 SND_DEVICE_OUT_VOICE_ANC_HEADSET,
78 SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET,
79 SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET,
80 SND_DEVICE_OUT_ANC_HANDSET,
81 SND_DEVICE_OUT_SPEAKER_PROTECTED,
Naresh Tanniruc0517bc2014-10-26 15:30:55 +053082#ifdef RECORD_PLAY_CONCURRENCY
83 SND_DEVICE_OUT_VOIP_HANDSET,
84 SND_DEVICE_OUT_VOIP_SPEAKER,
85 SND_DEVICE_OUT_VOIP_HEADPHONES,
86#endif
Naresh Tannirue3b18452014-03-04 14:44:27 +053087 SND_DEVICE_OUT_END,
88
89 /*
90 * Note: IN_BEGIN should be same as OUT_END because total number of devices
91 * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices.
92 */
93 /* Capture devices */
94 SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END,
95 SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN,
Naresh Tannirue3b18452014-03-04 14:44:27 +053096 SND_DEVICE_IN_HANDSET_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053097 SND_DEVICE_IN_HANDSET_MIC_NS,
98 SND_DEVICE_IN_HANDSET_MIC_AEC_NS,
99 SND_DEVICE_IN_HANDSET_DMIC,
100 SND_DEVICE_IN_HANDSET_DMIC_AEC,
101 SND_DEVICE_IN_HANDSET_DMIC_NS,
102 SND_DEVICE_IN_HANDSET_DMIC_AEC_NS,
103 SND_DEVICE_IN_SPEAKER_MIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530104 SND_DEVICE_IN_SPEAKER_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530105 SND_DEVICE_IN_SPEAKER_MIC_NS,
106 SND_DEVICE_IN_SPEAKER_MIC_AEC_NS,
107 SND_DEVICE_IN_SPEAKER_DMIC,
108 SND_DEVICE_IN_SPEAKER_DMIC_AEC,
109 SND_DEVICE_IN_SPEAKER_DMIC_NS,
110 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS,
111 SND_DEVICE_IN_HEADSET_MIC,
112 SND_DEVICE_IN_HEADSET_MIC_FLUENCE,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530113 SND_DEVICE_IN_VOICE_SPEAKER_MIC,
114 SND_DEVICE_IN_VOICE_HEADSET_MIC,
115 SND_DEVICE_IN_HDMI_MIC,
116 SND_DEVICE_IN_BT_SCO_MIC,
Vicky Sehrawate240e5d2014-08-12 17:17:04 -0700117 SND_DEVICE_IN_BT_SCO_MIC_NREC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530118 SND_DEVICE_IN_BT_SCO_MIC_WB,
Vicky Sehrawate240e5d2014-08-12 17:17:04 -0700119 SND_DEVICE_IN_BT_SCO_MIC_WB_NREC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530120 SND_DEVICE_IN_CAMCORDER_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530121 SND_DEVICE_IN_VOICE_DMIC,
122 SND_DEVICE_IN_VOICE_SPEAKER_DMIC,
123 SND_DEVICE_IN_VOICE_SPEAKER_QMIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530124 SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC,
125 SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC,
126 SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC,
127 SND_DEVICE_IN_VOICE_REC_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530128 SND_DEVICE_IN_VOICE_REC_MIC_NS,
129 SND_DEVICE_IN_VOICE_REC_DMIC_STEREO,
130 SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE,
131 SND_DEVICE_IN_USB_HEADSET_MIC,
132 SND_DEVICE_IN_CAPTURE_FM,
133 SND_DEVICE_IN_AANC_HANDSET_MIC,
134 SND_DEVICE_IN_QUAD_MIC,
135 SND_DEVICE_IN_HANDSET_STEREO_DMIC,
136 SND_DEVICE_IN_SPEAKER_STEREO_DMIC,
137 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK,
Karthik Reddy Kattad9fff862014-07-21 21:07:21 +0530138 SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE,
139 SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE,
140 SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE,
141 SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE,
142 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE,
Sidipotu Ashok3bcca232014-11-07 14:41:58 +0530143 SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC,
Karthik Reddy Kattad71b94b2015-01-19 14:06:53 +0530144 SND_DEVICE_IN_HANDSET_QMIC,
145 SND_DEVICE_IN_SPEAKER_QMIC_AEC,
146 SND_DEVICE_IN_SPEAKER_QMIC_NS,
147 SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530148 SND_DEVICE_IN_END,
149
150 SND_DEVICE_MAX = SND_DEVICE_IN_END,
151
152};
153
Naresh Tannirue3b18452014-03-04 14:44:27 +0530154#define DEFAULT_OUTPUT_SAMPLING_RATE 48000
155
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530156#define ALL_SESSION_VSID 0xFFFFFFFF
157#define DEFAULT_MUTE_RAMP_DURATION 500
158#define DEFAULT_VOLUME_RAMP_DURATION_MS 20
159#define MIXER_PATH_MAX_LENGTH 100
160
161#define MAX_VOL_INDEX 5
162#define MIN_VOL_INDEX 0
163#define percent_to_index(val, min, max) \
164 ((val) * ((max) - (min)) * 0.01 + (min) + .5)
165
Naresh Tannirue3b18452014-03-04 14:44:27 +0530166/*
167 * tinyAlsa library interprets period size as number of frames
168 * one frame = channel_count * sizeof (pcm sample)
169 * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes
170 * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes
171 * We should take care of returning proper size when AudioFlinger queries for
172 * the buffer size of an input/output stream
173 */
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530174#define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960
175#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 4
176#define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240
Naresh Tannirue3b18452014-03-04 14:44:27 +0530177#define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2
178
Ravi Kumar Alamandadc9bb152014-09-08 15:59:58 -0700179#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000
180#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240
Sharad Sangle896e7b12014-11-07 17:06:29 +0530181#define LOW_LATENCY_CAPTURE_USE_CASE 1
Ravi Kumar Alamandadc9bb152014-09-08 15:59:58 -0700182
Naresh Tannirue3b18452014-03-04 14:44:27 +0530183#define HDMI_MULTI_PERIOD_SIZE 336
184#define HDMI_MULTI_PERIOD_COUNT 8
185#define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6
186#define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2)
187
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530188#define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
189#define AUDIO_CAPTURE_PERIOD_COUNT 2
190
191#define DEVICE_NAME_MAX_SIZE 128
192#define HW_INFO_ARRAY_MAX_SIZE 32
193
194#define DEEP_BUFFER_PCM_DEVICE 0
195#define AUDIO_RECORD_PCM_DEVICE 0
196#define MULTIMEDIA2_PCM_DEVICE 1
197#define FM_PLAYBACK_PCM_DEVICE 5
198#define FM_CAPTURE_PCM_DEVICE 6
199#define HFP_PCM_RX 5
Satya Krishna Pindiproli640c91e2014-03-14 11:09:09 +0530200#define HFP_SCO_RX 17
201#define HFP_ASM_RX_TX 18
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530202
203#define INCALL_MUSIC_UPLINK_PCM_DEVICE 1
204#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16
205#define SPKR_PROT_CALIB_RX_PCM_DEVICE 5
206#define SPKR_PROT_CALIB_TX_PCM_DEVICE 22
207#define PLAYBACK_OFFLOAD_DEVICE 9
208#define COMPRESS_VOIP_CALL_PCM_DEVICE 3
209
Banajit Goswami88d6cc52014-04-10 17:59:02 -0700210/* Define macro for Internal FM volume mixer */
211#define FM_RX_VOLUME "Internal FM RX Volume"
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530212
213#define LOWLATENCY_PCM_DEVICE 12
214#define EC_REF_RX "I2S_RX"
215#define COMPRESS_CAPTURE_DEVICE 19
216
217#define VOICE_CALL_PCM_DEVICE 2
218#define VOICE2_CALL_PCM_DEVICE 13
219#define VOLTE_CALL_PCM_DEVICE 15
220#define QCHAT_CALL_PCM_DEVICE 14
Karthik Reddy Katta3b0a60c2014-04-06 14:52:37 +0530221#define VOWLAN_CALL_PCM_DEVICE 16
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530222
223#define LIB_CSD_CLIENT "libcsd-client.so"
224/* CSD-CLIENT related functions */
225typedef int (*init_t)();
226typedef int (*deinit_t)();
227typedef int (*disable_device_t)();
228typedef int (*enable_device_config_t)(int, int);
229typedef int (*enable_device_t)(int, int, uint32_t);
230typedef int (*volume_t)(uint32_t, int);
231typedef int (*mic_mute_t)(uint32_t, int);
232typedef int (*slow_talk_t)(uint32_t, uint8_t);
233typedef int (*start_voice_t)(uint32_t);
234typedef int (*stop_voice_t)(uint32_t);
235typedef int (*start_playback_t)(uint32_t);
236typedef int (*stop_playback_t)(uint32_t);
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -0700237typedef int (*set_lch_t)(uint32_t, enum voice_lch_mode);
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530238typedef int (*start_record_t)(uint32_t, int);
239typedef int (*stop_record_t)(uint32_t);
240/* CSD Client structure */
241struct csd_data {
242 void *csd_client;
243 init_t init;
244 deinit_t deinit;
245 disable_device_t disable_device;
246 enable_device_config_t enable_device_config;
247 enable_device_t enable_device;
248 volume_t volume;
249 mic_mute_t mic_mute;
250 slow_talk_t slow_talk;
251 start_voice_t start_voice;
252 stop_voice_t stop_voice;
253 start_playback_t start_playback;
254 stop_playback_t stop_playback;
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -0700255 set_lch_t set_lch;
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530256 start_record_t start_record;
257 stop_record_t stop_record;
258};
Naresh Tannirue3b18452014-03-04 14:44:27 +0530259
Preetam Singh Ranawat2d0e4632015-02-02 12:40:59 +0530260int platform_get_subsys_image_name (char *buf);
261
Naresh Tannirue3b18452014-03-04 14:44:27 +0530262#endif // QCOM_AUDIO_PLATFORM_H