blob: 6a5df69ea01f904a539e30829eee3e0c2944a773 [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
22
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053023enum {
24 FLUENCE_NONE,
25 FLUENCE_DUAL_MIC = 0x1,
26 FLUENCE_QUAD_MIC = 0x2,
27};
28
Karthik Reddy Kattad9fff862014-07-21 21:07:21 +053029enum {
30 FLUENCE_ENDFIRE = 0x1,
31 FLUENCE_BROADSIDE = 0x2,
32};
33
Naresh Tannirue3b18452014-03-04 14:44:27 +053034/*
35 * Below are the devices for which is back end is same, SLIMBUS_0_RX.
36 * All these devices are handled by the internal HW codec. We can
37 * enable any one of these devices at any time
38 */
39#define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \
40 (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \
41 AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE)
42
43/* Sound devices specific to the platform
44 * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound
45 * devices to enable corresponding mixer paths
46 */
47enum {
48 SND_DEVICE_NONE = 0,
49
50 /* Playback devices */
51 SND_DEVICE_MIN,
52 SND_DEVICE_OUT_BEGIN = SND_DEVICE_MIN,
53 SND_DEVICE_OUT_HANDSET = SND_DEVICE_OUT_BEGIN,
54 SND_DEVICE_OUT_SPEAKER,
55 SND_DEVICE_OUT_SPEAKER_REVERSE,
56 SND_DEVICE_OUT_HEADPHONES,
57 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES,
58 SND_DEVICE_OUT_VOICE_HANDSET,
59 SND_DEVICE_OUT_VOICE_SPEAKER,
60 SND_DEVICE_OUT_VOICE_HEADPHONES,
61 SND_DEVICE_OUT_HDMI,
62 SND_DEVICE_OUT_SPEAKER_AND_HDMI,
63 SND_DEVICE_OUT_BT_SCO,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053064 SND_DEVICE_OUT_BT_SCO_WB,
Naresh Tannirue3b18452014-03-04 14:44:27 +053065 SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES,
66 SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES,
67 SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053068 SND_DEVICE_OUT_AFE_PROXY,
69 SND_DEVICE_OUT_USB_HEADSET,
70 SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET,
71 SND_DEVICE_OUT_TRANSMISSION_FM,
72 SND_DEVICE_OUT_ANC_HEADSET,
73 SND_DEVICE_OUT_ANC_FB_HEADSET,
74 SND_DEVICE_OUT_VOICE_ANC_HEADSET,
75 SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET,
76 SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET,
77 SND_DEVICE_OUT_ANC_HANDSET,
78 SND_DEVICE_OUT_SPEAKER_PROTECTED,
Naresh Tannirue3b18452014-03-04 14:44:27 +053079 SND_DEVICE_OUT_END,
80
81 /*
82 * Note: IN_BEGIN should be same as OUT_END because total number of devices
83 * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices.
84 */
85 /* Capture devices */
86 SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END,
87 SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN,
Naresh Tannirue3b18452014-03-04 14:44:27 +053088 SND_DEVICE_IN_HANDSET_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053089 SND_DEVICE_IN_HANDSET_MIC_NS,
90 SND_DEVICE_IN_HANDSET_MIC_AEC_NS,
91 SND_DEVICE_IN_HANDSET_DMIC,
92 SND_DEVICE_IN_HANDSET_DMIC_AEC,
93 SND_DEVICE_IN_HANDSET_DMIC_NS,
94 SND_DEVICE_IN_HANDSET_DMIC_AEC_NS,
95 SND_DEVICE_IN_SPEAKER_MIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +053096 SND_DEVICE_IN_SPEAKER_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053097 SND_DEVICE_IN_SPEAKER_MIC_NS,
98 SND_DEVICE_IN_SPEAKER_MIC_AEC_NS,
99 SND_DEVICE_IN_SPEAKER_DMIC,
100 SND_DEVICE_IN_SPEAKER_DMIC_AEC,
101 SND_DEVICE_IN_SPEAKER_DMIC_NS,
102 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS,
103 SND_DEVICE_IN_HEADSET_MIC,
104 SND_DEVICE_IN_HEADSET_MIC_FLUENCE,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530105 SND_DEVICE_IN_VOICE_SPEAKER_MIC,
106 SND_DEVICE_IN_VOICE_HEADSET_MIC,
107 SND_DEVICE_IN_HDMI_MIC,
108 SND_DEVICE_IN_BT_SCO_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530109 SND_DEVICE_IN_BT_SCO_MIC_WB,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530110 SND_DEVICE_IN_CAMCORDER_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530111 SND_DEVICE_IN_VOICE_DMIC,
112 SND_DEVICE_IN_VOICE_SPEAKER_DMIC,
113 SND_DEVICE_IN_VOICE_SPEAKER_QMIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530114 SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC,
115 SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC,
116 SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC,
117 SND_DEVICE_IN_VOICE_REC_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530118 SND_DEVICE_IN_VOICE_REC_MIC_NS,
119 SND_DEVICE_IN_VOICE_REC_DMIC_STEREO,
120 SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE,
121 SND_DEVICE_IN_USB_HEADSET_MIC,
122 SND_DEVICE_IN_CAPTURE_FM,
123 SND_DEVICE_IN_AANC_HANDSET_MIC,
124 SND_DEVICE_IN_QUAD_MIC,
125 SND_DEVICE_IN_HANDSET_STEREO_DMIC,
126 SND_DEVICE_IN_SPEAKER_STEREO_DMIC,
127 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK,
Karthik Reddy Kattad9fff862014-07-21 21:07:21 +0530128 SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE,
129 SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE,
130 SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE,
131 SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE,
132 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530133 SND_DEVICE_IN_END,
134
135 SND_DEVICE_MAX = SND_DEVICE_IN_END,
136
137};
138
Naresh Tannirue3b18452014-03-04 14:44:27 +0530139#define DEFAULT_OUTPUT_SAMPLING_RATE 48000
140
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530141#define ALL_SESSION_VSID 0xFFFFFFFF
142#define DEFAULT_MUTE_RAMP_DURATION 500
143#define DEFAULT_VOLUME_RAMP_DURATION_MS 20
144#define MIXER_PATH_MAX_LENGTH 100
145
146#define MAX_VOL_INDEX 5
147#define MIN_VOL_INDEX 0
148#define percent_to_index(val, min, max) \
149 ((val) * ((max) - (min)) * 0.01 + (min) + .5)
150
Naresh Tannirue3b18452014-03-04 14:44:27 +0530151/*
152 * tinyAlsa library interprets period size as number of frames
153 * one frame = channel_count * sizeof (pcm sample)
154 * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes
155 * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes
156 * We should take care of returning proper size when AudioFlinger queries for
157 * the buffer size of an input/output stream
158 */
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530159#define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 960
160#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 4
161#define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240
Naresh Tannirue3b18452014-03-04 14:44:27 +0530162#define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2
163
164#define HDMI_MULTI_PERIOD_SIZE 336
165#define HDMI_MULTI_PERIOD_COUNT 8
166#define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6
167#define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2)
168
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530169#define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
170#define AUDIO_CAPTURE_PERIOD_COUNT 2
171
172#define DEVICE_NAME_MAX_SIZE 128
173#define HW_INFO_ARRAY_MAX_SIZE 32
174
175#define DEEP_BUFFER_PCM_DEVICE 0
176#define AUDIO_RECORD_PCM_DEVICE 0
177#define MULTIMEDIA2_PCM_DEVICE 1
178#define FM_PLAYBACK_PCM_DEVICE 5
179#define FM_CAPTURE_PCM_DEVICE 6
180#define HFP_PCM_RX 5
Satya Krishna Pindiproli640c91e2014-03-14 11:09:09 +0530181#define HFP_SCO_RX 17
182#define HFP_ASM_RX_TX 18
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530183
184#define INCALL_MUSIC_UPLINK_PCM_DEVICE 1
185#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16
186#define SPKR_PROT_CALIB_RX_PCM_DEVICE 5
187#define SPKR_PROT_CALIB_TX_PCM_DEVICE 22
188#define PLAYBACK_OFFLOAD_DEVICE 9
189#define COMPRESS_VOIP_CALL_PCM_DEVICE 3
190
Banajit Goswami88d6cc52014-04-10 17:59:02 -0700191/* Define macro for Internal FM volume mixer */
192#define FM_RX_VOLUME "Internal FM RX Volume"
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530193
194#define LOWLATENCY_PCM_DEVICE 12
195#define EC_REF_RX "I2S_RX"
196#define COMPRESS_CAPTURE_DEVICE 19
197
198#define VOICE_CALL_PCM_DEVICE 2
199#define VOICE2_CALL_PCM_DEVICE 13
200#define VOLTE_CALL_PCM_DEVICE 15
201#define QCHAT_CALL_PCM_DEVICE 14
Karthik Reddy Katta3b0a60c2014-04-06 14:52:37 +0530202#define VOWLAN_CALL_PCM_DEVICE 16
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530203
204#define LIB_CSD_CLIENT "libcsd-client.so"
205/* CSD-CLIENT related functions */
206typedef int (*init_t)();
207typedef int (*deinit_t)();
208typedef int (*disable_device_t)();
209typedef int (*enable_device_config_t)(int, int);
210typedef int (*enable_device_t)(int, int, uint32_t);
211typedef int (*volume_t)(uint32_t, int);
212typedef int (*mic_mute_t)(uint32_t, int);
213typedef int (*slow_talk_t)(uint32_t, uint8_t);
214typedef int (*start_voice_t)(uint32_t);
215typedef int (*stop_voice_t)(uint32_t);
216typedef int (*start_playback_t)(uint32_t);
217typedef int (*stop_playback_t)(uint32_t);
218typedef int (*start_record_t)(uint32_t, int);
219typedef int (*stop_record_t)(uint32_t);
220/* CSD Client structure */
221struct csd_data {
222 void *csd_client;
223 init_t init;
224 deinit_t deinit;
225 disable_device_t disable_device;
226 enable_device_config_t enable_device_config;
227 enable_device_t enable_device;
228 volume_t volume;
229 mic_mute_t mic_mute;
230 slow_talk_t slow_talk;
231 start_voice_t start_voice;
232 stop_voice_t stop_voice;
233 start_playback_t start_playback;
234 stop_playback_t stop_playback;
235 start_record_t start_record;
236 stop_record_t stop_record;
237};
Naresh Tannirue3b18452014-03-04 14:44:27 +0530238
239#endif // QCOM_AUDIO_PLATFORM_H