blob: a26b456080d3e04bf705cd31238d7e92c7aae6c2 [file] [log] [blame]
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -08001/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/clk.h>
14#include <linux/delay.h>
15#include <linux/gpio.h>
16#include <linux/mfd/pm8xxx/pm8921.h>
17#include <linux/platform_device.h>
18#include <linux/gpio.h>
19#include <linux/mfd/pm8xxx/pm8921.h>
Joonwoo Park0976d012011-12-22 11:48:18 -080020#include <linux/slab.h>
Neema Shettya58b9a22012-06-18 19:03:23 -070021#include <linux/pm_runtime.h>
22#include <linux/slimbus/slimbus.h>
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -080023#include <sound/core.h>
24#include <sound/soc.h>
25#include <sound/soc-dapm.h>
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -080026#include <sound/pcm.h>
27#include <sound/jack.h>
28#include <asm/mach-types.h>
29#include <mach/socinfo.h>
30#include "msm-pcm-routing.h"
31#include "../codecs/wcd9310.h"
32
33/* 8064 machine driver */
34
35#define PM8921_GPIO_BASE NR_GPIO_IRQS
36#define PM8921_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio - 1 + PM8921_GPIO_BASE)
37
38#define MSM8064_SPK_ON 1
39#define MSM8064_SPK_OFF 0
40
41#define MSM_SLIM_0_RX_MAX_CHANNELS 2
42#define MSM_SLIM_0_TX_MAX_CHANNELS 4
43
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -080044#define SAMPLE_RATE_8KHZ 8000
45#define SAMPLE_RATE_16KHZ 16000
46#define SAMPLE_RATE_48KHZ 48000
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -080047
48#define BOTTOM_SPK_AMP_POS 0x1
49#define BOTTOM_SPK_AMP_NEG 0x2
50#define TOP_SPK_AMP_POS 0x4
51#define TOP_SPK_AMP_NEG 0x8
Kiran Kandi97fe19d2012-05-20 22:34:04 -070052#define TOP_SPK_AMP 0x10
53
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -080054
55#define GPIO_AUX_PCM_DOUT 43
56#define GPIO_AUX_PCM_DIN 44
57#define GPIO_AUX_PCM_SYNC 45
58#define GPIO_AUX_PCM_CLK 46
59
Joonwoo Park0976d012011-12-22 11:48:18 -080060#define TABLA_EXT_CLK_RATE 12288000
61
Swaminathan Sathappan4ea7f1a02012-02-29 12:55:55 -080062#define TABLA_MBHC_DEF_BUTTONS 8
Joonwoo Park0976d012011-12-22 11:48:18 -080063#define TABLA_MBHC_DEF_RLOADS 5
64
Joonwoo Parkca1516f2012-05-08 13:59:37 -070065#define JACK_DETECT_GPIO 38
66
Neema Shetty3c9d2862012-03-11 01:25:32 -080067/* Shared channel numbers for Slimbus ports that connect APQ to MDM. */
68enum {
69 SLIM_1_RX_1 = 145, /* BT-SCO and USB TX */
70 SLIM_1_TX_1 = 146, /* BT-SCO and USB RX */
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -080071 SLIM_1_TX_2 = 147, /* USB RX */
Neema Shetty74131ac2012-05-09 13:35:26 -070072 SLIM_3_RX_1 = 151, /* External echo-cancellation ref */
73 SLIM_3_RX_2 = 152, /* External echo-cancellation ref */
Helen Zeng38c3c962012-05-17 14:56:20 -070074 SLIM_3_TX_1 = 153, /* HDMI RX */
75 SLIM_3_TX_2 = 154, /* HDMI RX */
Helen Zeng8f925502012-03-05 16:50:17 -080076 SLIM_4_TX_1 = 148, /* In-call recording RX */
77 SLIM_4_TX_2 = 149, /* In-call recording RX */
78 SLIM_4_RX_1 = 150, /* In-call music delivery TX */
79};
80
81enum {
82 INCALL_REC_MONO,
83 INCALL_REC_STEREO,
Neema Shetty3c9d2862012-03-11 01:25:32 -080084};
85
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -080086static u32 top_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(18);
87static u32 bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(19);
88static int msm_spk_control;
89static int msm_ext_bottom_spk_pamp;
90static int msm_ext_top_spk_pamp;
91static int msm_slim_0_rx_ch = 1;
92static int msm_slim_0_tx_ch = 1;
Neema Shetty74131ac2012-05-09 13:35:26 -070093static int msm_slim_3_rx_ch = 1;
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -080094
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -080095static int msm_slim_1_rate = SAMPLE_RATE_8KHZ;
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -080096static int msm_btsco_ch = 1;
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -080097static int msm_slim_1_rx_ch = 1;
98static int msm_slim_1_tx_ch = 1;
99
Vicky Sehrawat45204132012-11-05 17:54:13 -0800100static int hdmi_rate_variable;
Helen Zeng8f925502012-03-05 16:50:17 -0800101static int rec_mode = INCALL_REC_MONO;
102
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800103static struct clk *codec_clk;
104static int clk_users;
105
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800106static struct snd_soc_jack hs_jack;
107static struct snd_soc_jack button_jack;
Kuirong Wangae395b02012-09-20 11:43:17 -0700108static atomic_t auxpcm_rsc_ref;
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800109
Joonwoo Park26998702012-05-09 10:10:06 -0700110static int apq8064_hs_detect_use_gpio = -1;
111module_param(apq8064_hs_detect_use_gpio, int, 0444);
112MODULE_PARM_DESC(apq8064_hs_detect_use_gpio, "Use GPIO for headset detection");
113
Ravi Kumar Alamanda07b6bd62012-08-15 18:39:47 -0700114static bool apq8064_hs_detect_extn_cable;
115module_param(apq8064_hs_detect_extn_cable, bool, 0444);
116MODULE_PARM_DESC(apq8064_hs_detect_extn_cable, "Enable extension cable feature");
117
Joonwoo Park26998702012-05-09 10:10:06 -0700118static bool apq8064_hs_detect_use_firmware;
119module_param(apq8064_hs_detect_use_firmware, bool, 0444);
120MODULE_PARM_DESC(apq8064_hs_detect_use_firmware, "Use firmware for headset "
121 "detection");
Joonwoo Parkca1516f2012-05-08 13:59:37 -0700122
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700123static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
124 bool dapm);
125
126static struct tabla_mbhc_config mbhc_cfg = {
127 .headset_jack = &hs_jack,
128 .button_jack = &button_jack,
129 .read_fw_bin = false,
130 .calibration = NULL,
131 .micbias = TABLA_MICBIAS2,
132 .mclk_cb_fn = msm_enable_codec_ext_clk,
133 .mclk_rate = TABLA_EXT_CLK_RATE,
Joonwoo Parkca1516f2012-05-08 13:59:37 -0700134 .gpio = 0,
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700135 .gpio_irq = 0,
136 .gpio_level_insert = 1,
Ravi Kumar Alamanda07b6bd62012-08-15 18:39:47 -0700137 .detect_extn_cable = false,
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700138};
Joonwoo Park0976d012011-12-22 11:48:18 -0800139
Joonwoo Park9db5fb7a2012-06-15 12:10:46 -0700140static struct mutex cdc_mclk_mutex;
141
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800142static void msm_enable_ext_spk_amp_gpio(u32 spk_amp_gpio)
143{
144 int ret = 0;
145
146 struct pm_gpio param = {
147 .direction = PM_GPIO_DIR_OUT,
148 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
149 .output_value = 1,
150 .pull = PM_GPIO_PULL_NO,
151 .vin_sel = PM_GPIO_VIN_S4,
152 .out_strength = PM_GPIO_STRENGTH_MED,
153 .
154 function = PM_GPIO_FUNC_NORMAL,
155 };
156
157 if (spk_amp_gpio == bottom_spk_pamp_gpio) {
158
159 ret = gpio_request(bottom_spk_pamp_gpio, "BOTTOM_SPK_AMP");
160 if (ret) {
161 pr_err("%s: Error requesting BOTTOM SPK AMP GPIO %u\n",
162 __func__, bottom_spk_pamp_gpio);
163 return;
164 }
165 ret = pm8xxx_gpio_config(bottom_spk_pamp_gpio, &param);
166 if (ret)
167 pr_err("%s: Failed to configure Bottom Spk Ampl"
168 " gpio %u\n", __func__, bottom_spk_pamp_gpio);
169 else {
170 pr_debug("%s: enable Bottom spkr amp gpio\n", __func__);
171 gpio_direction_output(bottom_spk_pamp_gpio, 1);
172 }
173
174 } else if (spk_amp_gpio == top_spk_pamp_gpio) {
175
176 ret = gpio_request(top_spk_pamp_gpio, "TOP_SPK_AMP");
177 if (ret) {
178 pr_err("%s: Error requesting GPIO %d\n", __func__,
179 top_spk_pamp_gpio);
180 return;
181 }
182 ret = pm8xxx_gpio_config(top_spk_pamp_gpio, &param);
183 if (ret)
184 pr_err("%s: Failed to configure Top Spk Ampl"
185 " gpio %u\n", __func__, top_spk_pamp_gpio);
186 else {
187 pr_debug("%s: enable Top spkr amp gpio\n", __func__);
188 gpio_direction_output(top_spk_pamp_gpio, 1);
189 }
190 } else {
191 pr_err("%s: ERROR : Invalid External Speaker Ampl GPIO."
192 " gpio = %u\n", __func__, spk_amp_gpio);
193 return;
194 }
195}
196
197static void msm_ext_spk_power_amp_on(u32 spk)
198{
199 if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) {
200
201 if ((msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) &&
202 (msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) {
203
204 pr_debug("%s() External Bottom Speaker Ampl already "
205 "turned on. spk = 0x%08x\n", __func__, spk);
206 return;
207 }
208
209 msm_ext_bottom_spk_pamp |= spk;
210
211 if ((msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) &&
212 (msm_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) {
213
214 msm_enable_ext_spk_amp_gpio(bottom_spk_pamp_gpio);
215 pr_debug("%s: slepping 4 ms after turning on external "
216 " Bottom Speaker Ampl\n", __func__);
217 usleep_range(4000, 4000);
218 }
219
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700220 } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) {
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800221
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700222 pr_debug("%s():top_spk_amp_state = 0x%x spk_event = 0x%x\n",
223 __func__, msm_ext_top_spk_pamp, spk);
224
225 if (((msm_ext_top_spk_pamp & TOP_SPK_AMP_POS) &&
226 (msm_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) ||
227 (msm_ext_top_spk_pamp & TOP_SPK_AMP)) {
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800228
229 pr_debug("%s() External Top Speaker Ampl already"
230 "turned on. spk = 0x%08x\n", __func__, spk);
231 return;
232 }
233
234 msm_ext_top_spk_pamp |= spk;
235
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700236 if (((msm_ext_top_spk_pamp & TOP_SPK_AMP_POS) &&
237 (msm_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) ||
238 (msm_ext_top_spk_pamp & TOP_SPK_AMP)) {
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800239
240 msm_enable_ext_spk_amp_gpio(top_spk_pamp_gpio);
241 pr_debug("%s: sleeping 4 ms after turning on "
242 " external Top Speaker Ampl\n", __func__);
243 usleep_range(4000, 4000);
244 }
245 } else {
246
247 pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n",
248 __func__, spk);
249 return;
250 }
251}
252
253static void msm_ext_spk_power_amp_off(u32 spk)
254{
255 if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) {
256
257 if (!msm_ext_bottom_spk_pamp)
258 return;
259
260 gpio_direction_output(bottom_spk_pamp_gpio, 0);
261 gpio_free(bottom_spk_pamp_gpio);
262 msm_ext_bottom_spk_pamp = 0;
263
264 pr_debug("%s: sleeping 4 ms after turning off external Bottom"
265 " Speaker Ampl\n", __func__);
266
267 usleep_range(4000, 4000);
268
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700269 } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) {
270
271 pr_debug("%s: top_spk_amp_state = 0x%x spk_event = 0x%x\n",
272 __func__, msm_ext_top_spk_pamp, spk);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800273
274 if (!msm_ext_top_spk_pamp)
275 return;
276
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700277 if ((spk & TOP_SPK_AMP_POS) || (spk & TOP_SPK_AMP_NEG)) {
278
279 msm_ext_top_spk_pamp &= (~(TOP_SPK_AMP_POS |
280 TOP_SPK_AMP_NEG));
281 } else if (spk & TOP_SPK_AMP) {
282 msm_ext_top_spk_pamp &= ~TOP_SPK_AMP;
283 }
284
285 if (msm_ext_top_spk_pamp)
286 return;
287
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800288 gpio_direction_output(top_spk_pamp_gpio, 0);
289 gpio_free(top_spk_pamp_gpio);
290 msm_ext_top_spk_pamp = 0;
291
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700292 pr_debug("%s: sleeping 4 ms after ext Top Spek Ampl is off\n",
293 __func__);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800294
295 usleep_range(4000, 4000);
296 } else {
297
298 pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n",
299 __func__, spk);
300 return;
301 }
302}
303
304static void msm_ext_control(struct snd_soc_codec *codec)
305{
306 struct snd_soc_dapm_context *dapm = &codec->dapm;
307
308 pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control);
309 if (msm_spk_control == MSM8064_SPK_ON) {
310 snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos");
311 snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg");
312 snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos");
313 snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg");
314 } else {
315 snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Pos");
316 snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Neg");
317 snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Pos");
318 snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Neg");
319 }
320
321 snd_soc_dapm_sync(dapm);
322}
323
324static int msm_get_spk(struct snd_kcontrol *kcontrol,
325 struct snd_ctl_elem_value *ucontrol)
326{
327 pr_debug("%s: msm_spk_control = %d", __func__, msm_spk_control);
328 ucontrol->value.integer.value[0] = msm_spk_control;
329 return 0;
330}
331static int msm_set_spk(struct snd_kcontrol *kcontrol,
332 struct snd_ctl_elem_value *ucontrol)
333{
334 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
335
336 pr_debug("%s()\n", __func__);
337 if (msm_spk_control == ucontrol->value.integer.value[0])
338 return 0;
339
340 msm_spk_control = ucontrol->value.integer.value[0];
341 msm_ext_control(codec);
342 return 1;
343}
344static int msm_spkramp_event(struct snd_soc_dapm_widget *w,
345 struct snd_kcontrol *k, int event)
346{
347 pr_debug("%s() %x\n", __func__, SND_SOC_DAPM_EVENT_ON(event));
348
349 if (SND_SOC_DAPM_EVENT_ON(event)) {
350 if (!strncmp(w->name, "Ext Spk Bottom Pos", 18))
351 msm_ext_spk_power_amp_on(BOTTOM_SPK_AMP_POS);
352 else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18))
353 msm_ext_spk_power_amp_on(BOTTOM_SPK_AMP_NEG);
354 else if (!strncmp(w->name, "Ext Spk Top Pos", 15))
355 msm_ext_spk_power_amp_on(TOP_SPK_AMP_POS);
356 else if (!strncmp(w->name, "Ext Spk Top Neg", 15))
357 msm_ext_spk_power_amp_on(TOP_SPK_AMP_NEG);
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700358 else if (!strncmp(w->name, "Ext Spk Top", 12))
359 msm_ext_spk_power_amp_on(TOP_SPK_AMP);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800360 else {
361 pr_err("%s() Invalid Speaker Widget = %s\n",
362 __func__, w->name);
363 return -EINVAL;
364 }
365
366 } else {
367 if (!strncmp(w->name, "Ext Spk Bottom Pos", 18))
368 msm_ext_spk_power_amp_off(BOTTOM_SPK_AMP_POS);
369 else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18))
370 msm_ext_spk_power_amp_off(BOTTOM_SPK_AMP_NEG);
371 else if (!strncmp(w->name, "Ext Spk Top Pos", 15))
372 msm_ext_spk_power_amp_off(TOP_SPK_AMP_POS);
373 else if (!strncmp(w->name, "Ext Spk Top Neg", 15))
374 msm_ext_spk_power_amp_off(TOP_SPK_AMP_NEG);
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700375 else if (!strncmp(w->name, "Ext Spk Top", 12))
376 msm_ext_spk_power_amp_off(TOP_SPK_AMP);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800377 else {
378 pr_err("%s() Invalid Speaker Widget = %s\n",
379 __func__, w->name);
380 return -EINVAL;
381 }
382 }
383 return 0;
384}
385
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700386static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
387 bool dapm)
Joonwoo Park0976d012011-12-22 11:48:18 -0800388{
Joonwoo Park9db5fb7a2012-06-15 12:10:46 -0700389 int r = 0;
Joonwoo Park0976d012011-12-22 11:48:18 -0800390 pr_debug("%s: enable = %d\n", __func__, enable);
Joonwoo Park9db5fb7a2012-06-15 12:10:46 -0700391
392 mutex_lock(&cdc_mclk_mutex);
Joonwoo Park0976d012011-12-22 11:48:18 -0800393 if (enable) {
394 clk_users++;
395 pr_debug("%s: clk_users = %d\n", __func__, clk_users);
Joonwoo Park9db5fb7a2012-06-15 12:10:46 -0700396 if (clk_users == 1) {
397 if (codec_clk) {
398 clk_set_rate(codec_clk, TABLA_EXT_CLK_RATE);
399 clk_prepare_enable(codec_clk);
400 tabla_mclk_enable(codec, 1, dapm);
401 } else {
402 pr_err("%s: Error setting Tabla MCLK\n",
403 __func__);
404 clk_users--;
405 r = -EINVAL;
406 }
Joonwoo Park0976d012011-12-22 11:48:18 -0800407 }
408 } else {
Joonwoo Park9db5fb7a2012-06-15 12:10:46 -0700409 if (clk_users > 0) {
410 clk_users--;
411 pr_debug("%s: clk_users = %d\n", __func__, clk_users);
412 if (clk_users == 0) {
413 pr_debug("%s: disabling MCLK. clk_users = %d\n",
Joonwoo Park0976d012011-12-22 11:48:18 -0800414 __func__, clk_users);
Joonwoo Park9db5fb7a2012-06-15 12:10:46 -0700415 tabla_mclk_enable(codec, 0, dapm);
416 clk_disable_unprepare(codec_clk);
417 }
418 } else {
419 pr_err("%s: Error releasing Tabla MCLK\n", __func__);
420 r = -EINVAL;
Joonwoo Park0976d012011-12-22 11:48:18 -0800421 }
422 }
Joonwoo Park9db5fb7a2012-06-15 12:10:46 -0700423 mutex_unlock(&cdc_mclk_mutex);
424 return r;
Joonwoo Park0976d012011-12-22 11:48:18 -0800425}
426
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800427static int msm_mclk_event(struct snd_soc_dapm_widget *w,
428 struct snd_kcontrol *kcontrol, int event)
429{
430 pr_debug("%s: event = %d\n", __func__, event);
431
432 switch (event) {
433 case SND_SOC_DAPM_PRE_PMU:
434
435 clk_users++;
436 pr_debug("%s: clk_users = %d\n", __func__, clk_users);
437
438 if (clk_users != 1)
439 return 0;
440
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800441 if (codec_clk) {
442 clk_set_rate(codec_clk, 12288000);
Asish Bhattacharya4776d962012-04-25 12:08:09 +0530443 clk_prepare_enable(codec_clk);
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700444 tabla_mclk_enable(w->codec, 1, true);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800445
446 } else {
447 pr_err("%s: Error setting Tabla MCLK\n", __func__);
448 clk_users--;
449 return -EINVAL;
450 }
451 break;
452 case SND_SOC_DAPM_POST_PMD:
453
454 pr_debug("%s: clk_users = %d\n", __func__, clk_users);
455
456 if (clk_users == 0)
457 return 0;
458
459 clk_users--;
460
461 if (!clk_users) {
462 pr_debug("%s: disabling MCLK. clk_users = %d\n",
463 __func__, clk_users);
464
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -0700465 tabla_mclk_enable(w->codec, 0, true);
Asish Bhattacharya4776d962012-04-25 12:08:09 +0530466 clk_disable_unprepare(codec_clk);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800467 }
468 break;
469 }
470 return 0;
471}
472
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700473static const struct snd_soc_dapm_widget apq8064_dapm_widgets[] = {
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800474
475 SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
476 msm_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
477
478 SND_SOC_DAPM_SPK("Ext Spk Bottom Pos", msm_spkramp_event),
479 SND_SOC_DAPM_SPK("Ext Spk Bottom Neg", msm_spkramp_event),
480
481 SND_SOC_DAPM_SPK("Ext Spk Top Pos", msm_spkramp_event),
482 SND_SOC_DAPM_SPK("Ext Spk Top Neg", msm_spkramp_event),
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700483 SND_SOC_DAPM_SPK("Ext Spk Top", msm_spkramp_event),
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800484
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700485 /************ Analog MICs ************/
486 /**
487 * Analog mic7 (Front Top) on Liquid.
488 * Used as Handset mic on CDP.
489 */
490 SND_SOC_DAPM_MIC("Analog mic7", NULL),
491
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800492 SND_SOC_DAPM_MIC("Headset Mic", NULL),
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800493 SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
494 SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
495
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700496 /*********** Digital Mics ***************/
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800497 SND_SOC_DAPM_MIC("Digital Mic1", NULL),
498 SND_SOC_DAPM_MIC("Digital Mic2", NULL),
499 SND_SOC_DAPM_MIC("Digital Mic3", NULL),
500 SND_SOC_DAPM_MIC("Digital Mic4", NULL),
501 SND_SOC_DAPM_MIC("Digital Mic5", NULL),
502 SND_SOC_DAPM_MIC("Digital Mic6", NULL),
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800503};
504
Kiran Kandi323d7102012-04-18 19:56:14 -0700505static const struct snd_soc_dapm_route apq8064_common_audio_map[] = {
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800506
507 {"RX_BIAS", NULL, "MCLK"},
508 {"LDO_H", NULL, "MCLK"},
509
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700510 {"HEADPHONE", NULL, "LDO_H"},
511
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800512 /* Speaker path */
513 {"Ext Spk Bottom Pos", NULL, "LINEOUT1"},
514 {"Ext Spk Bottom Neg", NULL, "LINEOUT3"},
515
516 {"Ext Spk Top Pos", NULL, "LINEOUT2"},
517 {"Ext Spk Top Neg", NULL, "LINEOUT4"},
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700518 {"Ext Spk Top", NULL, "LINEOUT5"},
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800519
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700520 /************ Analog MIC Paths ************/
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800521
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700522 /* Headset Mic */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800523 {"AMIC2", NULL, "MIC BIAS2 External"},
524 {"MIC BIAS2 External", NULL, "Headset Mic"},
525
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700526 /* Headset ANC microphones */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800527 {"AMIC3", NULL, "MIC BIAS3 Internal1"},
528 {"MIC BIAS3 Internal1", NULL, "ANCRight Headset Mic"},
529
530 {"AMIC4", NULL, "MIC BIAS1 Internal2"},
531 {"MIC BIAS1 Internal2", NULL, "ANCLeft Headset Mic"},
Kiran Kandi323d7102012-04-18 19:56:14 -0700532};
533
534static const struct snd_soc_dapm_route apq8064_mtp_audio_map[] = {
535
536 /************ Digital MIC Paths ************/
537
538 /*
539 * Digital Mic1 (Front bottom Left) on MTP.
540 * Conncted to DMIC1 Input on Tabla codec.
541 */
542 {"DMIC1", NULL, "MIC BIAS1 External"},
543 {"MIC BIAS1 External", NULL, "Digital Mic1"},
544
545 /**
546 * Digital Mic2 (Front bottom right) on MTP.
547 * Conncted to DMIC2 Input on Tabla codec.
548 */
549 {"DMIC2", NULL, "MIC BIAS1 External"},
550 {"MIC BIAS1 External", NULL, "Digital Mic2"},
551
552 /**
553 * Digital Mic3 (Back bottom) on MTP.
554 * Conncted to DMIC3 Input on Tabla codec.
555 */
556 {"DMIC3", NULL, "MIC BIAS3 External"},
557 {"MIC BIAS3 External", NULL, "Digital Mic3"},
558
559 /**
560 * Digital Mic4 (Back top) on MTP.
561 * Conncted to DMIC4 Input on Tabla codec.
562 */
563 {"DMIC4", NULL, "MIC BIAS3 External"},
564 {"MIC BIAS3 External", NULL, "Digital Mic4"},
565
566 /**
567 * Digital Mic5 (Top front Mic) on MTP.
568 * Conncted to DMIC6 Input on Tabla codec.
569 */
570 {"DMIC6", NULL, "MIC BIAS4 External"},
571 {"MIC BIAS4 External", NULL, "Digital Mic5"},
572
573};
574
575static const struct snd_soc_dapm_route apq8064_liquid_cdp_audio_map[] = {
576
577 /************ Analog MIC Paths ************/
578 /**
579 * Analog mic7 (Front Top Mic) on Liquid.
580 * Used as Handset mic on CDP.
581 * Not there on MTP.
582 */
583 {"AMIC1", NULL, "MIC BIAS1 External"},
584 {"MIC BIAS1 External", NULL, "Analog mic7"},
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800585
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800586
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700587 /************ Digital MIC Paths ************/
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800588 /**
589 * The digital Mic routes are setup considering
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700590 * Liquid as default device.
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800591 */
592
593 /**
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700594 * Digital Mic1 (Front bottom left corner) on Liquid.
595 * Digital Mic2 (Front bottom right) on MTP.
596 * Digital Mic GM1 on CDP mainboard.
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800597 * Conncted to DMIC2 Input on Tabla codec.
598 */
599 {"DMIC2", NULL, "MIC BIAS1 External"},
600 {"MIC BIAS1 External", NULL, "Digital Mic1"},
601
602 /**
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700603 * Digital Mic2 (Front left side) on Liquid.
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800604 * Digital Mic GM2 on CDP mainboard.
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700605 * Not there on MTP.
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800606 * Conncted to DMIC3 Input on Tabla codec.
607 */
608 {"DMIC3", NULL, "MIC BIAS3 External"},
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700609 {"MIC BIAS3 External", NULL, "Digital Mic2"},
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800610
611 /**
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700612 * Digital Mic3. Front bottom left of middle on Liquid.
613 * Digital Mic5 (Top front Mic) on MTP.
614 * Digital Mic GM5 on CDP mainboard.
615 * Conncted to DMIC6 Input on Tabla codec.
616 */
617 {"DMIC6", NULL, "MIC BIAS4 External"},
618 {"MIC BIAS4 External", NULL, "Digital Mic3"},
619
620 /**
621 * Digital Mic4. Back bottom on Liquid.
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800622 * Digital Mic GM3 on CDP mainboard.
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700623 * Top Front Mic on MTP.
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800624 * Conncted to DMIC5 Input on Tabla codec.
625 */
626 {"DMIC5", NULL, "MIC BIAS4 External"},
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700627 {"MIC BIAS4 External", NULL, "Digital Mic4"},
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800628
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700629 /**
630 * Digital Mic5. Front bottom right of middle on Liquid.
631 * Digital Mic GM6 on CDP mainboard.
632 * Not there on MTP.
633 * Conncted to DMIC4 Input on Tabla codec.
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800634 */
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700635 {"DMIC4", NULL, "MIC BIAS3 External"},
636 {"MIC BIAS3 External", NULL, "Digital Mic5"},
637
638 /* Digital Mic6 (Front bottom right corner) on Liquid.
639 * Digital Mic1 (Front bottom Left) on MTP.
640 * Digital Mic GM4 on CDP.
641 * Conncted to DMIC1 Input on Tabla codec.
642 */
643 {"DMIC1", NULL, "MIC BIAS1 External"},
644 {"MIC BIAS1 External", NULL, "Digital Mic6"},
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800645};
646
647static const char *spk_function[] = {"Off", "On"};
648static const char *slim0_rx_ch_text[] = {"One", "Two"};
649static const char *slim0_tx_ch_text[] = {"One", "Two", "Three", "Four"};
Vicky Sehrawat45204132012-11-05 17:54:13 -0800650static const char * const hdmi_rate[] = {"Default", "Variable"};
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800651
652static const struct soc_enum msm_enum[] = {
653 SOC_ENUM_SINGLE_EXT(2, spk_function),
654 SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text),
655 SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text),
Vicky Sehrawat45204132012-11-05 17:54:13 -0800656 SOC_ENUM_SINGLE_EXT(2, hdmi_rate),
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800657};
658
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800659static const char * const slim1_rate_text[] = {"8000", "16000", "48000"};
660static const struct soc_enum msm_slim_1_rate_enum[] = {
661 SOC_ENUM_SINGLE_EXT(3, slim1_rate_text),
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800662};
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800663static const char * const slim1_tx_ch_text[] = {"One", "Two"};
664static const struct soc_enum msm_slim_1_tx_ch_enum[] = {
665 SOC_ENUM_SINGLE_EXT(2, slim1_tx_ch_text),
666};
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800667static int msm_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol,
668 struct snd_ctl_elem_value *ucontrol)
669{
670 pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
671 msm_slim_0_rx_ch);
672 ucontrol->value.integer.value[0] = msm_slim_0_rx_ch - 1;
673 return 0;
674}
675
676static int msm_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol,
677 struct snd_ctl_elem_value *ucontrol)
678{
679 msm_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1;
680
681 pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800682 msm_slim_0_rx_ch);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800683 return 1;
684}
685
686static int msm_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol,
687 struct snd_ctl_elem_value *ucontrol)
688{
689 pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__,
690 msm_slim_0_tx_ch);
691 ucontrol->value.integer.value[0] = msm_slim_0_tx_ch - 1;
692 return 0;
693}
694
695static int msm_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol,
696 struct snd_ctl_elem_value *ucontrol)
697{
698 msm_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1;
699
700 pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__,
701 msm_slim_0_tx_ch);
702 return 1;
703}
704
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800705static int msm_slim_1_tx_ch_get(struct snd_kcontrol *kcontrol,
706 struct snd_ctl_elem_value *ucontrol)
707{
708 pr_debug("%s: msm_slim_1_tx_ch = %d\n", __func__,
709 msm_slim_1_tx_ch);
710
711 ucontrol->value.integer.value[0] = msm_slim_1_tx_ch - 1;
712 return 0;
713}
714
715static int msm_slim_1_tx_ch_put(struct snd_kcontrol *kcontrol,
716 struct snd_ctl_elem_value *ucontrol)
717{
718 msm_slim_1_tx_ch = ucontrol->value.integer.value[0] + 1;
719
720 pr_debug("%s: msm_slim_1_tx_ch = %d\n", __func__,
721 msm_slim_1_tx_ch);
722
723 return 1;
724}
725
Neema Shetty74131ac2012-05-09 13:35:26 -0700726static int msm_slim_3_rx_ch_get(struct snd_kcontrol *kcontrol,
727 struct snd_ctl_elem_value *ucontrol)
728{
729 pr_debug("%s: msm_slim_3_rx_ch = %d\n", __func__,
730 msm_slim_3_rx_ch);
731 ucontrol->value.integer.value[0] = msm_slim_3_rx_ch - 1;
732 return 0;
733}
734
735static int msm_slim_3_rx_ch_put(struct snd_kcontrol *kcontrol,
736 struct snd_ctl_elem_value *ucontrol)
737{
738 msm_slim_3_rx_ch = ucontrol->value.integer.value[0] + 1;
739
740 pr_debug("%s: msm_slim_3_rx_ch = %d\n", __func__,
741 msm_slim_3_rx_ch);
742 return 1;
743}
744
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800745static int msm_slim_1_rate_get(struct snd_kcontrol *kcontrol,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800746 struct snd_ctl_elem_value *ucontrol)
747{
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800748 pr_debug("%s: msm_slim_1_rate = %d", __func__,
749 msm_slim_1_rate);
750
751 ucontrol->value.integer.value[0] = msm_slim_1_rate;
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800752 return 0;
753}
754
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800755static int msm_slim_1_rate_put(struct snd_kcontrol *kcontrol,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800756 struct snd_ctl_elem_value *ucontrol)
757{
758 switch (ucontrol->value.integer.value[0]) {
Kuirong Wangfd8e0b32012-05-30 19:45:04 -0700759 case 8000:
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800760 msm_slim_1_rate = SAMPLE_RATE_8KHZ;
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800761 break;
Kuirong Wangfd8e0b32012-05-30 19:45:04 -0700762 case 16000:
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800763 msm_slim_1_rate = SAMPLE_RATE_16KHZ;
764 break;
765 case 48000:
766 msm_slim_1_rate = SAMPLE_RATE_48KHZ;
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800767 break;
768 default:
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800769 msm_slim_1_rate = SAMPLE_RATE_8KHZ;
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800770 break;
771 }
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800772 pr_debug("%s: msm_slim_1_rate = %d\n", __func__,
773 msm_slim_1_rate);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800774 return 0;
775}
776
Helen Zeng8f925502012-03-05 16:50:17 -0800777static int msm_incall_rec_mode_get(struct snd_kcontrol *kcontrol,
778 struct snd_ctl_elem_value *ucontrol)
779{
780 ucontrol->value.integer.value[0] = rec_mode;
781 return 0;
782}
783
784static int msm_incall_rec_mode_put(struct snd_kcontrol *kcontrol,
785 struct snd_ctl_elem_value *ucontrol)
786{
787
788 rec_mode = ucontrol->value.integer.value[0];
789 pr_debug("%s: rec_mode:%d\n", __func__, rec_mode);
790
791 return 0;
792}
793
Vicky Sehrawat45204132012-11-05 17:54:13 -0800794static int msm_hdmi_rate_put(struct snd_kcontrol *kcontrol,
795 struct snd_ctl_elem_value *ucontrol)
796{
797 hdmi_rate_variable = ucontrol->value.integer.value[0];
798 pr_debug("%s: hdmi_rate_variable = %d\n", __func__, hdmi_rate_variable);
799 return 0;
800}
801
802static int msm_hdmi_rate_get(struct snd_kcontrol *kcontrol,
803 struct snd_ctl_elem_value *ucontrol)
804{
805 ucontrol->value.integer.value[0] = hdmi_rate_variable;
806 return 0;
807}
808
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -0800809static const struct snd_kcontrol_new tabla_msm_controls[] = {
810 SOC_ENUM_EXT("Speaker Function", msm_enum[0], msm_get_spk,
811 msm_set_spk),
812 SOC_ENUM_EXT("SLIM_0_RX Channels", msm_enum[1],
813 msm_slim_0_rx_ch_get, msm_slim_0_rx_ch_put),
814 SOC_ENUM_EXT("SLIM_0_TX Channels", msm_enum[2],
815 msm_slim_0_tx_ch_get, msm_slim_0_tx_ch_put),
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -0800816 SOC_ENUM_EXT("SLIM_1_TX Channels", msm_slim_1_tx_ch_enum[0],
817 msm_slim_1_tx_ch_get, msm_slim_1_tx_ch_put),
818 SOC_ENUM_EXT("SLIM_1 SampleRate", msm_slim_1_rate_enum[0],
819 msm_slim_1_rate_get, msm_slim_1_rate_put),
Steve Mucklef132c6c2012-06-06 18:30:57 -0700820 SOC_SINGLE_EXT("Incall Rec Mode", SND_SOC_NOPM, 0, 1, 0,
Helen Zeng8f925502012-03-05 16:50:17 -0800821 msm_incall_rec_mode_get, msm_incall_rec_mode_put),
Neema Shetty74131ac2012-05-09 13:35:26 -0700822 SOC_ENUM_EXT("SLIM_3_RX Channels", msm_enum[1],
823 msm_slim_3_rx_ch_get, msm_slim_3_rx_ch_put),
Vicky Sehrawat45204132012-11-05 17:54:13 -0800824 SOC_ENUM_EXT("HDMI RX Rate", msm_enum[3],
825 msm_hdmi_rate_get,
826 msm_hdmi_rate_put),
Neema Shetty74131ac2012-05-09 13:35:26 -0700827};
828
Joonwoo Park0976d012011-12-22 11:48:18 -0800829static void *def_tabla_mbhc_cal(void)
830{
831 void *tabla_cal;
832 struct tabla_mbhc_btn_detect_cfg *btn_cfg;
833 u16 *btn_low, *btn_high;
Swaminathan Sathappan4ea7f1a02012-02-29 12:55:55 -0800834 u8 *n_ready, *n_cic, *gain;
Joonwoo Park0976d012011-12-22 11:48:18 -0800835
836 tabla_cal = kzalloc(TABLA_MBHC_CAL_SIZE(TABLA_MBHC_DEF_BUTTONS,
837 TABLA_MBHC_DEF_RLOADS),
838 GFP_KERNEL);
839 if (!tabla_cal) {
840 pr_err("%s: out of memory\n", __func__);
841 return NULL;
842 }
843
844#define S(X, Y) ((TABLA_MBHC_CAL_GENERAL_PTR(tabla_cal)->X) = (Y))
845 S(t_ldoh, 100);
846 S(t_bg_fast_settle, 100);
847 S(t_shutdown_plug_rem, 255);
848 S(mbhc_nsa, 4);
849 S(mbhc_navg, 4);
850#undef S
851#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_DET_PTR(tabla_cal)->X) = (Y))
852 S(mic_current, TABLA_PID_MIC_5_UA);
853 S(hph_current, TABLA_PID_MIC_5_UA);
854 S(t_mic_pid, 100);
Swaminathan Sathappan4ea7f1a02012-02-29 12:55:55 -0800855 S(t_ins_complete, 250);
Joonwoo Park0976d012011-12-22 11:48:18 -0800856 S(t_ins_retry, 200);
857#undef S
858#define S(X, Y) ((TABLA_MBHC_CAL_PLUG_TYPE_PTR(tabla_cal)->X) = (Y))
859 S(v_no_mic, 30);
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -0700860 S(v_hs_max, 2400);
Joonwoo Park0976d012011-12-22 11:48:18 -0800861#undef S
862#define S(X, Y) ((TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal)->X) = (Y))
Swaminathan Sathappan4ea7f1a02012-02-29 12:55:55 -0800863 S(c[0], 62);
864 S(c[1], 124);
865 S(nc, 1);
866 S(n_meas, 3);
Joonwoo Park0976d012011-12-22 11:48:18 -0800867 S(mbhc_nsc, 11);
Swaminathan Sathappan4ea7f1a02012-02-29 12:55:55 -0800868 S(n_btn_meas, 1);
869 S(n_btn_con, 2);
Joonwoo Park0976d012011-12-22 11:48:18 -0800870 S(num_btn, TABLA_MBHC_DEF_BUTTONS);
871 S(v_btn_press_delta_sta, 100);
872 S(v_btn_press_delta_cic, 50);
873#undef S
874 btn_cfg = TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal);
875 btn_low = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_LOW);
876 btn_high = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_HIGH);
Swaminathan Sathappan4ea7f1a02012-02-29 12:55:55 -0800877 btn_low[0] = -50;
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -0700878 btn_high[0] = 20;
879 btn_low[1] = 21;
880 btn_high[1] = 62;
881 btn_low[2] = 62;
882 btn_high[2] = 104;
883 btn_low[3] = 105;
884 btn_high[3] = 143;
885 btn_low[4] = 144;
886 btn_high[4] = 181;
887 btn_low[5] = 182;
888 btn_high[5] = 218;
889 btn_low[6] = 219;
890 btn_high[6] = 254;
891 btn_low[7] = 255;
892 btn_high[7] = 330;
Swaminathan Sathappan4ea7f1a02012-02-29 12:55:55 -0800893 n_ready = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_READY);
Bhalchandra Gajare975c53a2012-08-10 12:16:49 -0700894 n_ready[0] = 80;
895 n_ready[1] = 68;
Joonwoo Park0976d012011-12-22 11:48:18 -0800896 n_cic = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_CIC);
Swaminathan Sathappan4ea7f1a02012-02-29 12:55:55 -0800897 n_cic[0] = 60;
898 n_cic[1] = 47;
Joonwoo Park0976d012011-12-22 11:48:18 -0800899 gain = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_GAIN);
900 gain[0] = 11;
901 gain[1] = 9;
902
903 return tabla_cal;
904}
905
Bharath Ramachandramurthy9c79f132011-11-28 11:18:57 -0800906static int msm_hw_params(struct snd_pcm_substream *substream,
907 struct snd_pcm_hw_params *params)
908{
909 struct snd_soc_pcm_runtime *rtd = substream->private_data;
910 struct snd_soc_dai *codec_dai = rtd->codec_dai;
911 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
912 int ret = 0;
913 unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
914 unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700915 unsigned int num_tx_ch = 0;
Bharath Ramachandramurthy9c79f132011-11-28 11:18:57 -0800916
Bharath Ramachandramurthy9c79f132011-11-28 11:18:57 -0800917 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700918
919 pr_debug("%s: rx_0_ch=%d\n", __func__, msm_slim_0_rx_ch);
920
Bharath Ramachandramurthy9c79f132011-11-28 11:18:57 -0800921 ret = snd_soc_dai_get_channel_map(codec_dai,
922 &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
923 if (ret < 0) {
924 pr_err("%s: failed to get codec chan map\n", __func__);
925 goto end;
926 }
927
928 ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
929 msm_slim_0_rx_ch, rx_ch);
930 if (ret < 0) {
931 pr_err("%s: failed to set cpu chan map\n", __func__);
932 goto end;
933 }
Bharath Ramachandramurthy9c79f132011-11-28 11:18:57 -0800934 } else {
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700935 pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700936 codec_dai->name, codec_dai->id, num_tx_ch);
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700937
Bharath Ramachandramurthy9c79f132011-11-28 11:18:57 -0800938 ret = snd_soc_dai_get_channel_map(codec_dai,
939 &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
940 if (ret < 0) {
941 pr_err("%s: failed to get codec chan map\n", __func__);
942 goto end;
943 }
Kuirong Wang906ac472012-07-09 12:54:44 -0700944 /* For tabla_tx1 case */
945 if (codec_dai->id == 1)
946 num_tx_ch = msm_slim_0_tx_ch;
947 /* For tabla_tx3 case */
948 else if (codec_dai->id == 4) {
949 /* DAI 5 is used for external EC reference from codec.
950 * Since Rx is fed as reference for EC, the config of
951 * this DAI is based on that of the Rx path.
952 */
953 num_tx_ch = msm_slim_0_rx_ch;
954 } else {
955 num_tx_ch = tx_ch_cnt;
956 }
Kiran Kandi1e6371d2012-03-29 11:48:57 -0700957
Bharath Ramachandramurthy9c79f132011-11-28 11:18:57 -0800958 ret = snd_soc_dai_set_channel_map(cpu_dai,
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700959 num_tx_ch, tx_ch, 0 , 0);
Bharath Ramachandramurthy9c79f132011-11-28 11:18:57 -0800960 if (ret < 0) {
961 pr_err("%s: failed to set cpu chan map\n", __func__);
962 goto end;
963 }
Bharath Ramachandramurthy9c79f132011-11-28 11:18:57 -0800964 }
965end:
966 return ret;
967}
968
Helen Zengf3b17fb2012-02-28 15:07:38 -0800969static int msm_stubrx_init(struct snd_soc_pcm_runtime *rtd)
970{
971 rtd->pmdown_time = 0;
972
973 return 0;
974}
975
Kiran Kandi97fe19d2012-05-20 22:34:04 -0700976static int msm_slimbus_2_hw_params(struct snd_pcm_substream *substream,
977 struct snd_pcm_hw_params *params)
978{
979 struct snd_soc_pcm_runtime *rtd = substream->private_data;
980 struct snd_soc_dai *codec_dai = rtd->codec_dai;
981 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
982 int ret = 0;
983 unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
984 unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
985 unsigned int num_tx_ch = 0;
986 unsigned int num_rx_ch = 0;
987
988 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
989
990 num_rx_ch = params_channels(params);
991
992 pr_debug("%s: %s rx_dai_id = %d num_ch = %d\n", __func__,
993 codec_dai->name, codec_dai->id, num_rx_ch);
994
995 ret = snd_soc_dai_get_channel_map(codec_dai,
996 &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
997 if (ret < 0) {
998 pr_err("%s: failed to get codec chan map\n", __func__);
999 goto end;
1000 }
1001
1002 ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
1003 num_rx_ch, rx_ch);
1004 if (ret < 0) {
1005 pr_err("%s: failed to set cpu chan map\n", __func__);
1006 goto end;
1007 }
Kiran Kandi97fe19d2012-05-20 22:34:04 -07001008 } else {
1009
1010 num_tx_ch = params_channels(params);
1011
1012 pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__,
1013 codec_dai->name, codec_dai->id, num_tx_ch);
1014
1015 ret = snd_soc_dai_get_channel_map(codec_dai,
1016 &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
1017 if (ret < 0) {
1018 pr_err("%s: failed to get codec chan map\n", __func__);
1019 goto end;
1020 }
1021
1022 ret = snd_soc_dai_set_channel_map(cpu_dai,
1023 num_tx_ch, tx_ch, 0 , 0);
1024 if (ret < 0) {
1025 pr_err("%s: failed to set cpu chan map\n", __func__);
1026 goto end;
1027 }
Kiran Kandi97fe19d2012-05-20 22:34:04 -07001028 }
1029end:
1030 return ret;
1031}
1032
Neema Shetty3c9d2862012-03-11 01:25:32 -08001033static int msm_slimbus_1_hw_params(struct snd_pcm_substream *substream,
1034 struct snd_pcm_hw_params *params)
1035{
1036 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1037 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
1038 int ret = 0;
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -08001039 unsigned int rx_ch = SLIM_1_RX_1, tx_ch[2] = {SLIM_1_TX_1, SLIM_1_TX_2};
Neema Shetty3c9d2862012-03-11 01:25:32 -08001040
1041 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1042 pr_debug("%s: APQ BT/USB TX -> SLIMBUS_1_RX -> MDM TX shared ch %d\n",
1043 __func__, rx_ch);
1044
1045 ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, 1, &rx_ch);
1046 if (ret < 0) {
1047 pr_err("%s: Erorr %d setting SLIM_1 RX channel map\n",
1048 __func__, ret);
1049
1050 goto end;
1051 }
1052 } else {
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -08001053 pr_debug("%s: MDM RX ->SLIMBUS_1_TX ->APQ BT/USB Rx shared ch %d %d\n",
1054 __func__, tx_ch[0], tx_ch[1]);
Neema Shetty3c9d2862012-03-11 01:25:32 -08001055
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -08001056 ret = snd_soc_dai_set_channel_map(cpu_dai, msm_slim_1_tx_ch,
1057 tx_ch, 0, 0);
Neema Shetty3c9d2862012-03-11 01:25:32 -08001058 if (ret < 0) {
1059 pr_err("%s: Erorr %d setting SLIM_1 TX channel map\n",
1060 __func__, ret);
1061
1062 goto end;
1063 }
1064 }
1065
1066end:
1067 return ret;
1068}
1069
Neema Shetty74131ac2012-05-09 13:35:26 -07001070static int msm_slimbus_3_hw_params(struct snd_pcm_substream *substream,
1071 struct snd_pcm_hw_params *params)
1072{
1073 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1074 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
1075 int ret = 0;
1076 unsigned int rx_ch[2] = {SLIM_3_RX_1, SLIM_3_RX_2};
Helen Zeng38c3c962012-05-17 14:56:20 -07001077 unsigned int tx_ch[2] = {SLIM_3_TX_1, SLIM_3_TX_2};
Neema Shetty74131ac2012-05-09 13:35:26 -07001078
1079 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1080 pr_debug("%s: slim_3_rx_ch %d, sch %d %d\n",
1081 __func__, msm_slim_3_rx_ch,
1082 rx_ch[0], rx_ch[1]);
1083
1084 ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
1085 msm_slim_3_rx_ch, rx_ch);
1086 if (ret < 0) {
1087 pr_err("%s: Erorr %d setting SLIM_3 RX channel map\n",
1088 __func__, ret);
1089
1090 goto end;
1091 }
1092 } else {
Helen Zeng38c3c962012-05-17 14:56:20 -07001093 pr_debug("%s: MDM RX -> SLIMBUS_3_TX -> APQ HDMI ch: %d, %d\n",
1094 __func__, tx_ch[0], tx_ch[1]);
1095
1096 ret = snd_soc_dai_set_channel_map(cpu_dai, 2, tx_ch, 0, 0);
1097 if (ret < 0) {
1098 pr_err("%s: Erorr %d setting SLIM_3 TX channel map\n",
1099 __func__, ret);
1100
1101 goto end;
1102 }
Neema Shetty74131ac2012-05-09 13:35:26 -07001103 }
1104
1105end:
1106 return ret;
1107}
1108
Helen Zeng8f925502012-03-05 16:50:17 -08001109static int msm_slimbus_4_hw_params(struct snd_pcm_substream *substream,
1110 struct snd_pcm_hw_params *params)
1111{
1112 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1113 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
1114 int ret = 0;
1115 unsigned int rx_ch = SLIM_4_RX_1, tx_ch[2];
1116
1117 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1118 pr_debug("%s: APQ Incall Playback SLIMBUS_4_RX -> MDM TX shared ch %d\n",
1119 __func__, rx_ch);
1120
1121 ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0, 1, &rx_ch);
1122 if (ret < 0) {
1123 pr_err("%s: Erorr %d setting SLIM_4 RX channel map\n",
1124 __func__, ret);
1125
1126 }
1127 } else {
1128 if (rec_mode == INCALL_REC_STEREO) {
1129 tx_ch[0] = SLIM_4_TX_1;
1130 tx_ch[1] = SLIM_4_TX_2;
1131 ret = snd_soc_dai_set_channel_map(cpu_dai, 2,
1132 tx_ch, 0, 0);
1133 } else {
1134 tx_ch[0] = SLIM_4_TX_1;
1135 ret = snd_soc_dai_set_channel_map(cpu_dai, 1,
1136 tx_ch, 0, 0);
1137 }
1138 pr_debug("%s: Incall Record shared tx_ch[0]:%d, tx_ch[1]:%d\n",
1139 __func__, tx_ch[0], tx_ch[1]);
1140
1141 if (ret < 0) {
1142 pr_err("%s: Erorr %d setting SLIM_4 TX channel map\n",
1143 __func__, ret);
1144
1145 }
1146 }
1147
1148 return ret;
1149}
1150
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001151static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
1152{
1153 int err;
Joonwoo Park26998702012-05-09 10:10:06 -07001154 uint32_t revision;
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001155 struct snd_soc_codec *codec = rtd->codec;
1156 struct snd_soc_dapm_context *dapm = &codec->dapm;
Kuirong Wanga9c3acc2012-02-09 17:00:45 -08001157 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
Kuirong Wang906ac472012-07-09 12:54:44 -07001158 struct snd_soc_dai *codec_dai = rtd->codec_dai;
1159 unsigned int rx_ch[TABLA_RX_MAX] = {138, 139, 140, 141, 142, 143, 144};
1160 unsigned int tx_ch[TABLA_TX_MAX] = {128, 129, 130, 131, 132, 133, 134,
1161 135, 136, 137};
1162
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001163
Kuirong Wanga9c3acc2012-02-09 17:00:45 -08001164 pr_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev));
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001165
Kiran Kandi1e6371d2012-03-29 11:48:57 -07001166 snd_soc_dapm_new_controls(dapm, apq8064_dapm_widgets,
1167 ARRAY_SIZE(apq8064_dapm_widgets));
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001168
Kiran Kandi323d7102012-04-18 19:56:14 -07001169 snd_soc_dapm_add_routes(dapm, apq8064_common_audio_map,
1170 ARRAY_SIZE(apq8064_common_audio_map));
1171
1172 if (machine_is_apq8064_mtp()) {
1173 snd_soc_dapm_add_routes(dapm, apq8064_mtp_audio_map,
1174 ARRAY_SIZE(apq8064_mtp_audio_map));
1175 } else {
1176 snd_soc_dapm_add_routes(dapm, apq8064_liquid_cdp_audio_map,
1177 ARRAY_SIZE(apq8064_liquid_cdp_audio_map));
1178 }
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001179
1180 snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos");
1181 snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg");
1182 snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos");
1183 snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg");
1184
1185 snd_soc_dapm_sync(dapm);
1186
1187 err = snd_soc_jack_new(codec, "Headset Jack",
Ravi Kumar Alamanda07b6bd62012-08-15 18:39:47 -07001188 (SND_JACK_HEADSET | SND_JACK_LINEOUT |
1189 SND_JACK_OC_HPHL | SND_JACK_OC_HPHR |
1190 SND_JACK_UNSUPPORTED),
Joonwoo Parkcca30bb2012-07-11 13:31:55 -07001191 &hs_jack);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001192 if (err) {
1193 pr_err("failed to create new jack\n");
1194 return err;
1195 }
1196
1197 err = snd_soc_jack_new(codec, "Button Jack",
Swaminathan Sathappan4ea7f1a02012-02-29 12:55:55 -08001198 TABLA_JACK_BUTTON_MASK, &button_jack);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001199 if (err) {
1200 pr_err("failed to create new jack\n");
1201 return err;
1202 }
1203
Kuirong Wanga9c3acc2012-02-09 17:00:45 -08001204 codec_clk = clk_get(cpu_dai->dev, "osr_clk");
1205
Joonwoo Park26998702012-05-09 10:10:06 -07001206 /* APQ8064 Rev 1.1 CDP and Liquid have mechanical switch */
1207 revision = socinfo_get_version();
1208 if (apq8064_hs_detect_use_gpio != -1) {
1209 if (apq8064_hs_detect_use_gpio == 1)
1210 pr_debug("%s: MBHC mechanical is enabled by request\n",
1211 __func__);
1212 else if (apq8064_hs_detect_use_gpio == 0)
1213 pr_debug("%s: MBHC mechanical is disabled by request\n",
1214 __func__);
1215 else
1216 pr_warn("%s: Invalid hs_detect_use_gpio %d\n", __func__,
1217 apq8064_hs_detect_use_gpio);
1218 } else if (SOCINFO_VERSION_MAJOR(revision) == 0) {
1219 pr_warn("%s: Unknown HW revision detected %d.%d\n", __func__,
1220 SOCINFO_VERSION_MAJOR(revision),
1221 SOCINFO_VERSION_MINOR(revision));
1222 } else if ((SOCINFO_VERSION_MAJOR(revision) == 1 &&
1223 SOCINFO_VERSION_MINOR(revision) >= 1 &&
1224 (machine_is_apq8064_cdp() ||
1225 machine_is_apq8064_liquid())) ||
1226 SOCINFO_VERSION_MAJOR(revision) > 1) {
1227 pr_debug("%s: MBHC mechanical switch available APQ8064 "
1228 "detected\n", __func__);
1229 apq8064_hs_detect_use_gpio = 1;
1230 }
1231
1232 if (apq8064_hs_detect_use_gpio == 1) {
1233 pr_debug("%s: Using MBHC mechanical switch\n", __func__);
Joonwoo Parkca1516f2012-05-08 13:59:37 -07001234 mbhc_cfg.gpio = JACK_DETECT_GPIO;
1235 mbhc_cfg.gpio_irq = gpio_to_irq(JACK_DETECT_GPIO);
1236 err = gpio_request(mbhc_cfg.gpio, "MBHC_HS_DETECT");
1237 if (err < 0) {
1238 pr_err("%s: gpio_request %d failed %d\n", __func__,
1239 mbhc_cfg.gpio, err);
1240 return err;
1241 }
1242 gpio_direction_input(JACK_DETECT_GPIO);
Ravi Kumar Alamanda07b6bd62012-08-15 18:39:47 -07001243 if (apq8064_hs_detect_extn_cable)
1244 mbhc_cfg.detect_extn_cable = true;
Joonwoo Park26998702012-05-09 10:10:06 -07001245 } else
1246 pr_debug("%s: Not using MBHC mechanical switch\n", __func__);
1247
1248 mbhc_cfg.read_fw_bin = apq8064_hs_detect_use_firmware;
Joonwoo Parkca1516f2012-05-08 13:59:37 -07001249
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -07001250 err = tabla_hs_detect(codec, &mbhc_cfg);
Kuirong Wang906ac472012-07-09 12:54:44 -07001251 snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
1252 tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001253
Joonwoo Park03324832012-03-19 19:36:16 -07001254 return err;
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001255}
1256
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001257static int msm_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1258 struct snd_pcm_hw_params *params)
1259{
1260 struct snd_interval *rate = hw_param_interval(params,
1261 SNDRV_PCM_HW_PARAM_RATE);
1262
1263 struct snd_interval *channels = hw_param_interval(params,
1264 SNDRV_PCM_HW_PARAM_CHANNELS);
1265
1266 pr_debug("%s()\n", __func__);
1267 rate->min = rate->max = 48000;
1268 channels->min = channels->max = msm_slim_0_rx_ch;
1269
1270 return 0;
1271}
1272
1273static int msm_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1274 struct snd_pcm_hw_params *params)
1275{
1276 struct snd_interval *rate = hw_param_interval(params,
1277 SNDRV_PCM_HW_PARAM_RATE);
1278
1279 struct snd_interval *channels = hw_param_interval(params,
1280 SNDRV_PCM_HW_PARAM_CHANNELS);
1281
1282 pr_debug("%s()\n", __func__);
1283 rate->min = rate->max = 48000;
1284 channels->min = channels->max = msm_slim_0_tx_ch;
1285
1286 return 0;
1287}
1288
Neema Shetty74131ac2012-05-09 13:35:26 -07001289static int msm_slim_3_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1290 struct snd_pcm_hw_params *params)
1291{
1292 struct snd_interval *rate = hw_param_interval(params,
1293 SNDRV_PCM_HW_PARAM_RATE);
1294
1295 struct snd_interval *channels = hw_param_interval(params,
1296 SNDRV_PCM_HW_PARAM_CHANNELS);
1297
1298 pr_debug("%s()\n", __func__);
1299 rate->min = rate->max = 48000;
1300 channels->min = channels->max = msm_slim_3_rx_ch;
1301
1302 return 0;
1303}
1304
Helen Zeng38c3c962012-05-17 14:56:20 -07001305static int msm_slim_3_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1306 struct snd_pcm_hw_params *params)
1307{
1308 struct snd_interval *rate = hw_param_interval(params,
1309 SNDRV_PCM_HW_PARAM_RATE);
1310
1311 struct snd_interval *channels = hw_param_interval(params,
1312 SNDRV_PCM_HW_PARAM_CHANNELS);
1313
1314 pr_debug("%s()\n", __func__);
1315 rate->min = rate->max = 48000;
1316 channels->min = channels->max = 2;
1317
1318 return 0;
1319}
1320
Helen Zengffd89f62012-08-17 17:35:32 -07001321static int msm_slim_4_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1322 struct snd_pcm_hw_params *params)
1323{
1324 struct snd_interval *rate = hw_param_interval(params,
1325 SNDRV_PCM_HW_PARAM_RATE);
1326
1327 struct snd_interval *channels = hw_param_interval(params,
1328 SNDRV_PCM_HW_PARAM_CHANNELS);
1329
1330 pr_debug("%s()\n", __func__);
1331
1332 rate->min = rate->max = 48000;
1333 if (rec_mode == INCALL_REC_STEREO)
1334 channels->min = channels->max = 2;
1335 else
1336 channels->min = channels->max = 1;
1337
1338 pr_debug("%s channels->min %u channels->max %u ()\n", __func__,
1339 channels->min, channels->max);
1340 return 0;
1341}
1342
Helen Zeng548741e2012-09-11 18:32:24 -07001343static int msm_slim_4_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1344 struct snd_pcm_hw_params *params)
1345{
1346 struct snd_interval *rate = hw_param_interval(params,
1347 SNDRV_PCM_HW_PARAM_RATE);
1348
1349 struct snd_interval *channels = hw_param_interval(params,
1350 SNDRV_PCM_HW_PARAM_CHANNELS);
1351
1352 rate->min = rate->max = 48000;
1353 channels->min = channels->max = 1;
1354
1355 pr_debug("%s channels->min %u channels->max %u ()\n", __func__,
1356 channels->min, channels->max);
1357 return 0;
1358}
1359
1360
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001361static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1362 struct snd_pcm_hw_params *params)
1363{
1364 struct snd_interval *rate = hw_param_interval(params,
1365 SNDRV_PCM_HW_PARAM_RATE);
1366
1367 pr_debug("%s()\n", __func__);
1368 rate->min = rate->max = 48000;
1369
1370 return 0;
1371}
1372
Swaminathan Sathappanfd9dbad2012-02-15 16:56:44 -08001373static int msm_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1374 struct snd_pcm_hw_params *params)
1375{
1376 struct snd_interval *rate = hw_param_interval(params,
1377 SNDRV_PCM_HW_PARAM_RATE);
1378
1379 struct snd_interval *channels = hw_param_interval(params,
1380 SNDRV_PCM_HW_PARAM_CHANNELS);
1381
1382 pr_debug("%s channels->min %u channels->max %u ()\n", __func__,
1383 channels->min, channels->max);
1384
Helen Zeng12123a12012-09-26 15:57:43 -07001385 if (channels->max < 2)
1386 channels->min = channels->max = 2;
Vicky Sehrawat45204132012-11-05 17:54:13 -08001387 if (!hdmi_rate_variable)
1388 rate->min = rate->max = 48000;
Swaminathan Sathappanfd9dbad2012-02-15 16:56:44 -08001389
1390 return 0;
1391}
1392
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001393static int msm_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1394 struct snd_pcm_hw_params *params)
1395{
1396 struct snd_interval *rate = hw_param_interval(params,
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -08001397 SNDRV_PCM_HW_PARAM_RATE);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001398
1399 struct snd_interval *channels = hw_param_interval(params,
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -08001400 SNDRV_PCM_HW_PARAM_CHANNELS);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001401
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -08001402 rate->min = rate->max = msm_slim_1_rate;
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001403 channels->min = channels->max = msm_btsco_ch;
1404
1405 return 0;
1406}
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -08001407static int msm_slim_1_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1408 struct snd_pcm_hw_params *params)
1409{
1410 struct snd_interval *rate = hw_param_interval(params,
1411 SNDRV_PCM_HW_PARAM_RATE);
1412
1413 struct snd_interval *channels = hw_param_interval(params,
1414 SNDRV_PCM_HW_PARAM_CHANNELS);
1415
1416 rate->min = rate->max = msm_slim_1_rate;
1417 channels->min = channels->max = msm_slim_1_rx_ch;
1418
1419 return 0;
1420}
1421
1422static int msm_slim_1_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1423 struct snd_pcm_hw_params *params)
1424{
1425 struct snd_interval *rate = hw_param_interval(params,
1426 SNDRV_PCM_HW_PARAM_RATE);
1427
1428 struct snd_interval *channels = hw_param_interval(params,
1429 SNDRV_PCM_HW_PARAM_CHANNELS);
1430
1431 rate->min = rate->max = msm_slim_1_rate;
1432 channels->min = channels->max = msm_slim_1_tx_ch;
1433
1434 return 0;
1435}
1436
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001437static int msm_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd,
1438 struct snd_pcm_hw_params *params)
1439{
1440 struct snd_interval *rate = hw_param_interval(params,
1441 SNDRV_PCM_HW_PARAM_RATE);
1442
1443 struct snd_interval *channels = hw_param_interval(params,
1444 SNDRV_PCM_HW_PARAM_CHANNELS);
1445
1446 /* PCM only supports mono output with 8khz sample rate */
1447 rate->min = rate->max = 8000;
1448 channels->min = channels->max = 1;
1449
1450 return 0;
1451}
Jayasena Sangaraboina66bd39d2012-06-29 18:10:23 -07001452static int msm_proxy_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
1453 struct snd_pcm_hw_params *params)
1454{
1455 struct snd_interval *rate = hw_param_interval(params,
1456 SNDRV_PCM_HW_PARAM_RATE);
1457
1458 pr_debug("%s()\n", __func__);
1459 rate->min = rate->max = 48000;
1460
1461 return 0;
1462}
Neema Shetty3c9d2862012-03-11 01:25:32 -08001463
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001464static int msm_aux_pcm_get_gpios(void)
1465{
1466 int ret = 0;
1467
1468 pr_debug("%s\n", __func__);
1469
1470 ret = gpio_request(GPIO_AUX_PCM_DOUT, "AUX PCM DOUT");
1471 if (ret < 0) {
1472 pr_err("%s: Failed to request gpio(%d): AUX PCM DOUT",
1473 __func__, GPIO_AUX_PCM_DOUT);
1474 goto fail_dout;
1475 }
1476
1477 ret = gpio_request(GPIO_AUX_PCM_DIN, "AUX PCM DIN");
1478 if (ret < 0) {
1479 pr_err("%s: Failed to request gpio(%d): AUX PCM DIN",
1480 __func__, GPIO_AUX_PCM_DIN);
1481 goto fail_din;
1482 }
1483
1484 ret = gpio_request(GPIO_AUX_PCM_SYNC, "AUX PCM SYNC");
1485 if (ret < 0) {
1486 pr_err("%s: Failed to request gpio(%d): AUX PCM SYNC",
1487 __func__, GPIO_AUX_PCM_SYNC);
1488 goto fail_sync;
1489 }
1490 ret = gpio_request(GPIO_AUX_PCM_CLK, "AUX PCM CLK");
1491 if (ret < 0) {
1492 pr_err("%s: Failed to request gpio(%d): AUX PCM CLK",
1493 __func__, GPIO_AUX_PCM_CLK);
1494 goto fail_clk;
1495 }
1496
1497 return 0;
1498
1499fail_clk:
1500 gpio_free(GPIO_AUX_PCM_SYNC);
1501fail_sync:
1502 gpio_free(GPIO_AUX_PCM_DIN);
1503fail_din:
1504 gpio_free(GPIO_AUX_PCM_DOUT);
1505fail_dout:
1506
1507 return ret;
1508}
1509
1510static int msm_aux_pcm_free_gpios(void)
1511{
1512 gpio_free(GPIO_AUX_PCM_DIN);
1513 gpio_free(GPIO_AUX_PCM_DOUT);
1514 gpio_free(GPIO_AUX_PCM_SYNC);
1515 gpio_free(GPIO_AUX_PCM_CLK);
1516
1517 return 0;
1518}
1519static int msm_startup(struct snd_pcm_substream *substream)
1520{
Kiran Kandi97fe19d2012-05-20 22:34:04 -07001521 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1522
1523 pr_debug("%s(): dai_link_str_name = %s cpu_dai = %s codec_dai = %s\n",
1524 __func__, rtd->dai_link->stream_name,
1525 rtd->dai_link->cpu_dai_name,
1526 rtd->dai_link->codec_dai_name);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001527 return 0;
1528}
1529
1530static int msm_auxpcm_startup(struct snd_pcm_substream *substream)
1531{
1532 int ret = 0;
1533
Kuirong Wangae395b02012-09-20 11:43:17 -07001534 pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n",
1535 __func__, substream->name, atomic_read(&auxpcm_rsc_ref));
1536 if (atomic_inc_return(&auxpcm_rsc_ref) == 1)
1537 ret = msm_aux_pcm_get_gpios();
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001538 if (ret < 0) {
1539 pr_err("%s: Aux PCM GPIO request failed\n", __func__);
1540 return -EINVAL;
1541 }
1542 return 0;
1543}
1544
Neema Shettya58b9a22012-06-18 19:03:23 -07001545static int msm_slimbus_1_startup(struct snd_pcm_substream *substream)
1546{
1547 struct slim_controller *slim = slim_busnum_to_ctrl(1);
1548
1549 pr_debug("%s(): substream = %s stream = %d\n", __func__,
1550 substream->name, substream->stream);
1551
1552 if (slim != NULL)
1553 pm_runtime_get_sync(slim->dev.parent);
1554
1555 return 0;
1556}
1557
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001558static void msm_auxpcm_shutdown(struct snd_pcm_substream *substream)
1559{
1560
Kuirong Wangae395b02012-09-20 11:43:17 -07001561 pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n",
1562 __func__, substream->name, atomic_read(&auxpcm_rsc_ref));
1563 if (atomic_dec_return(&auxpcm_rsc_ref) == 0)
1564 msm_aux_pcm_free_gpios();
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001565}
1566
1567static void msm_shutdown(struct snd_pcm_substream *substream)
1568{
Kiran Kandi97fe19d2012-05-20 22:34:04 -07001569 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1570
1571 pr_debug("%s(): dai_link_str_name = %s cpu_dai = %s codec_dai = %s\n",
1572 __func__, rtd->dai_link->stream_name,
1573 rtd->dai_link->cpu_dai_name, rtd->dai_link->codec_dai_name);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001574}
1575
Neema Shettya58b9a22012-06-18 19:03:23 -07001576static void msm_slimbus_1_shutdown(struct snd_pcm_substream *substream)
1577{
1578 struct slim_controller *slim = slim_busnum_to_ctrl(1);
1579
1580 pr_debug("%s(): substream = %s stream = %d\n", __func__,
1581 substream->name, substream->stream);
1582
1583 if (slim != NULL) {
1584 pm_runtime_mark_last_busy(slim->dev.parent);
1585 pm_runtime_put(slim->dev.parent);
1586 }
1587}
1588
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001589static struct snd_soc_ops msm_be_ops = {
1590 .startup = msm_startup,
Bharath Ramachandramurthy9c79f132011-11-28 11:18:57 -08001591 .hw_params = msm_hw_params,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001592 .shutdown = msm_shutdown,
1593};
1594
1595static struct snd_soc_ops msm_auxpcm_be_ops = {
1596 .startup = msm_auxpcm_startup,
1597 .shutdown = msm_auxpcm_shutdown,
1598};
1599
Neema Shetty3c9d2862012-03-11 01:25:32 -08001600static struct snd_soc_ops msm_slimbus_1_be_ops = {
Neema Shettya58b9a22012-06-18 19:03:23 -07001601 .startup = msm_slimbus_1_startup,
Neema Shetty3c9d2862012-03-11 01:25:32 -08001602 .hw_params = msm_slimbus_1_hw_params,
Neema Shettya58b9a22012-06-18 19:03:23 -07001603 .shutdown = msm_slimbus_1_shutdown,
Neema Shetty3c9d2862012-03-11 01:25:32 -08001604};
1605
Neema Shetty74131ac2012-05-09 13:35:26 -07001606static struct snd_soc_ops msm_slimbus_3_be_ops = {
1607 .startup = msm_startup,
1608 .hw_params = msm_slimbus_3_hw_params,
1609 .shutdown = msm_shutdown,
1610};
1611
Helen Zeng8f925502012-03-05 16:50:17 -08001612static struct snd_soc_ops msm_slimbus_4_be_ops = {
1613 .startup = msm_startup,
1614 .hw_params = msm_slimbus_4_hw_params,
1615 .shutdown = msm_shutdown,
1616};
1617
Kiran Kandi97fe19d2012-05-20 22:34:04 -07001618static struct snd_soc_ops msm_slimbus_2_be_ops = {
1619 .startup = msm_startup,
1620 .hw_params = msm_slimbus_2_hw_params,
1621 .shutdown = msm_shutdown,
1622};
1623
1624
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001625/* Digital audio interface glue - connects codec <---> CPU */
1626static struct snd_soc_dai_link msm_dai[] = {
1627 /* FrontEnd DAI Links */
1628 {
1629 .name = "MSM8960 Media1",
1630 .stream_name = "MultiMedia1",
1631 .cpu_dai_name = "MultiMedia1",
1632 .platform_name = "msm-pcm-dsp",
1633 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001634 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
1635 .codec_dai_name = "snd-soc-dummy-dai",
1636 .codec_name = "snd-soc-dummy",
1637 .ignore_suspend = 1,
1638 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001639 .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1
1640 },
1641 {
1642 .name = "MSM8960 Media2",
1643 .stream_name = "MultiMedia2",
1644 .cpu_dai_name = "MultiMedia2",
Bharath Ramachandramurthyf79f92b2012-03-29 12:11:54 -07001645 .platform_name = "msm-multi-ch-pcm-dsp",
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001646 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001647 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
1648 .codec_dai_name = "snd-soc-dummy-dai",
1649 .codec_name = "snd-soc-dummy",
1650 .ignore_suspend = 1,
1651 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001652 .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2,
1653 },
1654 {
1655 .name = "Circuit-Switch Voice",
1656 .stream_name = "CS-Voice",
1657 .cpu_dai_name = "CS-VOICE",
1658 .platform_name = "msm-pcm-voice",
1659 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001660 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001661 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
1662 .ignore_suspend = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001663 .codec_dai_name = "snd-soc-dummy-dai",
1664 .codec_name = "snd-soc-dummy",
1665 .ignore_suspend = 1,
1666 .ignore_pmdown_time = 1, /* this dainlink has playback support */
1667 .be_id = MSM_FRONTEND_DAI_CS_VOICE,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001668 },
1669 {
1670 .name = "MSM VoIP",
1671 .stream_name = "VoIP",
1672 .cpu_dai_name = "VoIP",
1673 .platform_name = "msm-voip-dsp",
1674 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001675 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
1676 .codec_dai_name = "snd-soc-dummy-dai",
1677 .codec_name = "snd-soc-dummy",
1678 .ignore_suspend = 1,
1679 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001680 .be_id = MSM_FRONTEND_DAI_VOIP,
1681 },
1682 {
1683 .name = "MSM8960 LPA",
1684 .stream_name = "LPA",
1685 .cpu_dai_name = "MultiMedia3",
1686 .platform_name = "msm-pcm-lpa",
1687 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001688 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
1689 .codec_dai_name = "snd-soc-dummy-dai",
1690 .codec_name = "snd-soc-dummy",
1691 .ignore_suspend = 1,
1692 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001693 .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3,
1694 },
1695 /* Hostless PMC purpose */
1696 {
1697 .name = "SLIMBUS_0 Hostless",
1698 .stream_name = "SLIMBUS_0 Hostless",
1699 .cpu_dai_name = "SLIMBUS0_HOSTLESS",
1700 .platform_name = "msm-pcm-hostless",
1701 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001702 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001703 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
1704 .ignore_suspend = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001705 .ignore_pmdown_time = 1, /* this dainlink has playback support */
1706 .codec_dai_name = "snd-soc-dummy-dai",
1707 .codec_name = "snd-soc-dummy",
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001708 /* .be_id = do not care */
1709 },
1710 {
1711 .name = "INT_FM Hostless",
1712 .stream_name = "INT_FM Hostless",
1713 .cpu_dai_name = "INT_FM_HOSTLESS",
1714 .platform_name = "msm-pcm-hostless",
1715 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001716 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001717 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
1718 .ignore_suspend = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001719 .ignore_pmdown_time = 1, /* this dainlink has playback support */
1720 .codec_dai_name = "snd-soc-dummy-dai",
1721 .codec_name = "snd-soc-dummy",
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001722 /* .be_id = do not care */
1723 },
1724 {
1725 .name = "MSM AFE-PCM RX",
1726 .stream_name = "AFE-PROXY RX",
1727 .cpu_dai_name = "msm-dai-q6.241",
1728 .codec_name = "msm-stub-codec.1",
1729 .codec_dai_name = "msm-stub-rx",
1730 .platform_name = "msm-pcm-afe",
1731 .ignore_suspend = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001732 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001733 },
1734 {
1735 .name = "MSM AFE-PCM TX",
1736 .stream_name = "AFE-PROXY TX",
1737 .cpu_dai_name = "msm-dai-q6.240",
1738 .codec_name = "msm-stub-codec.1",
1739 .codec_dai_name = "msm-stub-tx",
1740 .platform_name = "msm-pcm-afe",
1741 .ignore_suspend = 1,
1742 },
Neema Shettyb9451242012-02-16 15:37:59 -08001743 {
Bharath Ramachandramurthyf79f92b2012-03-29 12:11:54 -07001744 .name = "MSM8960 Compr",
1745 .stream_name = "COMPR",
1746 .cpu_dai_name = "MultiMedia4",
Xiaojun Sang43f3d3b2017-04-27 14:44:25 +08001747 .platform_name = "msm-compress-dsp",
Bharath Ramachandramurthyf79f92b2012-03-29 12:11:54 -07001748 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001749 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
1750 .codec_dai_name = "snd-soc-dummy-dai",
1751 .codec_name = "snd-soc-dummy",
1752 .ignore_suspend = 1,
1753 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyf79f92b2012-03-29 12:11:54 -07001754 .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4,
1755 },
1756 {
1757 .name = "AUXPCM Hostless",
1758 .stream_name = "AUXPCM Hostless",
1759 .cpu_dai_name = "AUXPCM_HOSTLESS",
1760 .platform_name = "msm-pcm-hostless",
1761 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001762 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
Bharath Ramachandramurthyf79f92b2012-03-29 12:11:54 -07001763 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
1764 .ignore_suspend = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001765 .ignore_pmdown_time = 1, /* this dainlink has playback support */
1766 .codec_dai_name = "snd-soc-dummy-dai",
1767 .codec_name = "snd-soc-dummy",
Bharath Ramachandramurthyf79f92b2012-03-29 12:11:54 -07001768 },
1769 /* HDMI Hostless */
1770 {
1771 .name = "HDMI_RX_HOSTLESS",
1772 .stream_name = "HDMI_RX_HOSTLESS",
1773 .cpu_dai_name = "HDMI_HOSTLESS",
1774 .platform_name = "msm-pcm-hostless",
1775 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001776 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
Bharath Ramachandramurthyf79f92b2012-03-29 12:11:54 -07001777 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001778 .codec_dai_name = "snd-soc-dummy-dai",
1779 .codec_name = "snd-soc-dummy",
Bharath Ramachandramurthyf79f92b2012-03-29 12:11:54 -07001780 .ignore_suspend = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001781 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyf79f92b2012-03-29 12:11:54 -07001782 },
1783 {
Neema Shettyb9451242012-02-16 15:37:59 -08001784 .name = "Voice Stub",
1785 .stream_name = "Voice Stub",
1786 .cpu_dai_name = "VOICE_STUB",
1787 .platform_name = "msm-pcm-hostless",
1788 .dynamic = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001789 .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
Neema Shettyb9451242012-02-16 15:37:59 -08001790 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
1791 .ignore_suspend = 1,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001792 .ignore_pmdown_time = 1, /* this dainlink has playback support */
1793 .codec_dai_name = "snd-soc-dummy-dai",
1794 .codec_name = "snd-soc-dummy",
Neema Shettyb9451242012-02-16 15:37:59 -08001795 },
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07001796 {
Helen Zeng6b0a1b62013-03-01 18:03:09 -08001797 .name = "VoLTE Stub",
1798 .stream_name = "VoLTE Stub",
1799 .cpu_dai_name = "VOLTE_STUB",
1800 .platform_name = "msm-pcm-hostless",
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07001801 .dynamic = 1,
1802 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
Helen Zeng6b0a1b62013-03-01 18:03:09 -08001803 SND_SOC_DPCM_TRIGGER_POST},
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07001804 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
1805 .ignore_suspend = 1,
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07001806 .ignore_pmdown_time = 1,
1807 .codec_dai_name = "snd-soc-dummy-dai",
1808 .codec_name = "snd-soc-dummy",
Jayasena Sangaraboina99bf09c2012-07-17 12:03:08 -07001809 },
1810 {
1811 .name = "MSM8960 LowLatency",
1812 .stream_name = "MultiMedia5",
1813 .cpu_dai_name = "MultiMedia5",
1814 .platform_name = "msm-lowlatency-pcm-dsp",
1815 .dynamic = 1,
1816 .codec_dai_name = "snd-soc-dummy-dai",
1817 .codec_name = "snd-soc-dummy",
1818 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
1819 SND_SOC_DPCM_TRIGGER_POST},
1820 .ignore_suspend = 1,
1821 /* this dainlink has playback support */
1822 .ignore_pmdown_time = 1,
1823 .be_id = MSM_FRONTEND_DAI_MULTIMEDIA5,
1824 },
Krishnankutty Kolathappillyf059e972012-07-16 12:06:28 -07001825 {
1826 .name = "MSM8960 Media6",
1827 .stream_name = "MultiMedia6",
1828 .cpu_dai_name = "MultiMedia6",
1829 .platform_name = "msm-multi-ch-pcm-dsp",
1830 .dynamic = 1,
1831 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
1832 SND_SOC_DPCM_TRIGGER_POST},
1833 .codec_dai_name = "snd-soc-dummy-dai",
1834 .codec_name = "snd-soc-dummy",
1835 .ignore_suspend = 1,
1836 .ignore_pmdown_time = 1, /* this dailink has playback support */
1837 .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6
1838 },
1839 {
1840 .name = "MSM8960 Compr2",
1841 .stream_name = "COMPR2",
1842 .cpu_dai_name = "MultiMedia7",
Xiaojun Sang43f3d3b2017-04-27 14:44:25 +08001843 .platform_name = "msm-compress-dsp",
Krishnankutty Kolathappillyf059e972012-07-16 12:06:28 -07001844 .dynamic = 1,
1845 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
1846 SND_SOC_DPCM_TRIGGER_POST},
1847 .codec_dai_name = "snd-soc-dummy-dai",
1848 .codec_name = "snd-soc-dummy",
1849 .ignore_suspend = 1,
1850 .ignore_pmdown_time = 1, /* this dailink has playback support */
1851 .be_id = MSM_FRONTEND_DAI_MULTIMEDIA7,
1852 },
1853 {
1854 .name = "MSM8960 Compr3",
1855 .stream_name = "COMPR3",
1856 .cpu_dai_name = "MultiMedia8",
Xiaojun Sang43f3d3b2017-04-27 14:44:25 +08001857 .platform_name = "msm-compress-dsp",
Krishnankutty Kolathappillyf059e972012-07-16 12:06:28 -07001858 .dynamic = 1,
1859 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
1860 SND_SOC_DPCM_TRIGGER_POST},
1861 .codec_dai_name = "snd-soc-dummy-dai",
1862 .codec_name = "snd-soc-dummy",
1863 .ignore_suspend = 1,
1864 .ignore_pmdown_time = 1, /* this dailink has playback support */
1865 .be_id = MSM_FRONTEND_DAI_MULTIMEDIA8,
1866 },
Helen Zengc6e3d852013-03-06 11:34:14 -08001867 {
1868 .name = "Voice2 Stub",
1869 .stream_name = "Voice2 Stub",
1870 .cpu_dai_name = "VOICE2_STUB",
1871 .platform_name = "msm-pcm-hostless",
1872 .dynamic = 1,
1873 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
1874 SND_SOC_DPCM_TRIGGER_POST},
1875 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
1876 .ignore_suspend = 1,
1877 .ignore_pmdown_time = 1,
1878 /* this dainlink has playback support */
1879 .codec_dai_name = "snd-soc-dummy-dai",
1880 .codec_name = "snd-soc-dummy",
1881 },
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001882 /* Backend DAI Links */
1883 {
1884 .name = LPASS_BE_SLIMBUS_0_RX,
1885 .stream_name = "Slimbus Playback",
1886 .cpu_dai_name = "msm-dai-q6.16384",
1887 .platform_name = "msm-pcm-routing",
1888 .codec_name = "tabla_codec",
1889 .codec_dai_name = "tabla_rx1",
1890 .no_pcm = 1,
1891 .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
1892 .init = &msm_audrx_init,
1893 .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
1894 .ops = &msm_be_ops,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001895 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001896 },
1897 {
1898 .name = LPASS_BE_SLIMBUS_0_TX,
1899 .stream_name = "Slimbus Capture",
1900 .cpu_dai_name = "msm-dai-q6.16385",
1901 .platform_name = "msm-pcm-routing",
1902 .codec_name = "tabla_codec",
1903 .codec_dai_name = "tabla_tx1",
1904 .no_pcm = 1,
1905 .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
1906 .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
1907 .ops = &msm_be_ops,
1908 },
1909 /* Backend BT/FM DAI Links */
1910 {
1911 .name = LPASS_BE_INT_BT_SCO_RX,
1912 .stream_name = "Internal BT-SCO Playback",
1913 .cpu_dai_name = "msm-dai-q6.12288",
1914 .platform_name = "msm-pcm-routing",
1915 .codec_name = "msm-stub-codec.1",
1916 .codec_dai_name = "msm-stub-rx",
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001917 .no_pcm = 1,
1918 .be_id = MSM_BACKEND_DAI_INT_BT_SCO_RX,
1919 .be_hw_params_fixup = msm_btsco_be_hw_params_fixup,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001920 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001921 },
1922 {
1923 .name = LPASS_BE_INT_BT_SCO_TX,
1924 .stream_name = "Internal BT-SCO Capture",
1925 .cpu_dai_name = "msm-dai-q6.12289",
1926 .platform_name = "msm-pcm-routing",
1927 .codec_name = "msm-stub-codec.1",
1928 .codec_dai_name = "msm-stub-tx",
1929 .no_pcm = 1,
1930 .be_id = MSM_BACKEND_DAI_INT_BT_SCO_TX,
1931 .be_hw_params_fixup = msm_btsco_be_hw_params_fixup,
1932 },
1933 {
1934 .name = LPASS_BE_INT_FM_RX,
1935 .stream_name = "Internal FM Playback",
1936 .cpu_dai_name = "msm-dai-q6.12292",
1937 .platform_name = "msm-pcm-routing",
1938 .codec_name = "msm-stub-codec.1",
1939 .codec_dai_name = "msm-stub-rx",
1940 .no_pcm = 1,
1941 .be_id = MSM_BACKEND_DAI_INT_FM_RX,
1942 .be_hw_params_fixup = msm_be_hw_params_fixup,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001943 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001944 },
1945 {
1946 .name = LPASS_BE_INT_FM_TX,
1947 .stream_name = "Internal FM Capture",
1948 .cpu_dai_name = "msm-dai-q6.12293",
1949 .platform_name = "msm-pcm-routing",
1950 .codec_name = "msm-stub-codec.1",
1951 .codec_dai_name = "msm-stub-tx",
1952 .no_pcm = 1,
1953 .be_id = MSM_BACKEND_DAI_INT_FM_TX,
1954 .be_hw_params_fixup = msm_be_hw_params_fixup,
1955 },
1956 /* HDMI BACK END DAI Link */
1957 {
1958 .name = LPASS_BE_HDMI,
1959 .stream_name = "HDMI Playback",
Swaminathan Sathappanfd9dbad2012-02-15 16:56:44 -08001960 .cpu_dai_name = "msm-dai-q6-hdmi.8",
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001961 .platform_name = "msm-pcm-routing",
1962 .codec_name = "msm-stub-codec.1",
1963 .codec_dai_name = "msm-stub-rx",
1964 .no_pcm = 1,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001965 .be_id = MSM_BACKEND_DAI_HDMI_RX,
Swaminathan Sathappanfd9dbad2012-02-15 16:56:44 -08001966 .be_hw_params_fixup = msm_hdmi_be_hw_params_fixup,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001967 },
1968 /* Backend AFE DAI Links */
1969 {
1970 .name = LPASS_BE_AFE_PCM_RX,
1971 .stream_name = "AFE Playback",
1972 .cpu_dai_name = "msm-dai-q6.224",
1973 .platform_name = "msm-pcm-routing",
1974 .codec_name = "msm-stub-codec.1",
1975 .codec_dai_name = "msm-stub-rx",
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001976 .no_pcm = 1,
1977 .be_id = MSM_BACKEND_DAI_AFE_PCM_RX,
Jayasena Sangaraboina66bd39d2012-06-29 18:10:23 -07001978 .be_hw_params_fixup = msm_proxy_be_hw_params_fixup,
Steve Mucklef132c6c2012-06-06 18:30:57 -07001979 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001980 },
1981 {
1982 .name = LPASS_BE_AFE_PCM_TX,
1983 .stream_name = "AFE Capture",
1984 .cpu_dai_name = "msm-dai-q6.225",
1985 .platform_name = "msm-pcm-routing",
1986 .codec_name = "msm-stub-codec.1",
1987 .codec_dai_name = "msm-stub-tx",
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001988 .no_pcm = 1,
1989 .be_id = MSM_BACKEND_DAI_AFE_PCM_TX,
Jayasena Sangaraboina66bd39d2012-06-29 18:10:23 -07001990 .be_hw_params_fixup = msm_proxy_be_hw_params_fixup,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08001991 },
1992 /* AUX PCM Backend DAI Links */
1993 {
1994 .name = LPASS_BE_AUXPCM_RX,
1995 .stream_name = "AUX PCM Playback",
1996 .cpu_dai_name = "msm-dai-q6.2",
1997 .platform_name = "msm-pcm-routing",
1998 .codec_name = "msm-stub-codec.1",
1999 .codec_dai_name = "msm-stub-rx",
2000 .no_pcm = 1,
2001 .be_id = MSM_BACKEND_DAI_AUXPCM_RX,
2002 .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
2003 .ops = &msm_auxpcm_be_ops,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002004 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002005 },
2006 {
2007 .name = LPASS_BE_AUXPCM_TX,
2008 .stream_name = "AUX PCM Capture",
2009 .cpu_dai_name = "msm-dai-q6.3",
2010 .platform_name = "msm-pcm-routing",
2011 .codec_name = "msm-stub-codec.1",
2012 .codec_dai_name = "msm-stub-tx",
2013 .no_pcm = 1,
2014 .be_id = MSM_BACKEND_DAI_AUXPCM_TX,
2015 .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
Kuirong Wangae395b02012-09-20 11:43:17 -07002016 .ops = &msm_auxpcm_be_ops,
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002017 },
Neema Shettyb9451242012-02-16 15:37:59 -08002018 {
2019 .name = LPASS_BE_STUB_RX,
2020 .stream_name = "Stub Playback",
2021 .cpu_dai_name = "msm-dai-stub",
2022 .platform_name = "msm-pcm-routing",
2023 .codec_name = "tabla_codec",
2024 .codec_dai_name = "tabla_rx2",
2025 .no_pcm = 1,
Neema Shettye5cae8e2012-04-27 18:07:37 -07002026 .be_id = MSM_BACKEND_DAI_EXTPROC_RX,
Neema Shettyb9451242012-02-16 15:37:59 -08002027 .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
Helen Zengf3b17fb2012-02-28 15:07:38 -08002028 .init = &msm_stubrx_init,
Neema Shettyb9451242012-02-16 15:37:59 -08002029 .ops = &msm_be_ops,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002030 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Neema Shettyb9451242012-02-16 15:37:59 -08002031 },
2032 {
2033 .name = LPASS_BE_STUB_TX,
2034 .stream_name = "Stub Capture",
2035 .cpu_dai_name = "msm-dai-stub",
2036 .platform_name = "msm-pcm-routing",
2037 .codec_name = "tabla_codec",
2038 .codec_dai_name = "tabla_tx1",
2039 .no_pcm = 1,
Neema Shettye5cae8e2012-04-27 18:07:37 -07002040 .be_id = MSM_BACKEND_DAI_EXTPROC_TX,
Neema Shettyb9451242012-02-16 15:37:59 -08002041 .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
2042 .ops = &msm_be_ops,
2043 },
Neema Shetty3c9d2862012-03-11 01:25:32 -08002044 {
2045 .name = LPASS_BE_SLIMBUS_1_RX,
2046 .stream_name = "Slimbus1 Playback",
2047 .cpu_dai_name = "msm-dai-q6.16386",
2048 .platform_name = "msm-pcm-routing",
2049 .codec_name = "msm-stub-codec.1",
2050 .codec_dai_name = "msm-stub-rx",
2051 .no_pcm = 1,
2052 .be_id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -08002053 .be_hw_params_fixup = msm_slim_1_rx_be_hw_params_fixup,
Neema Shetty3c9d2862012-03-11 01:25:32 -08002054 .ops = &msm_slimbus_1_be_ops,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002055 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Neema Shetty3c9d2862012-03-11 01:25:32 -08002056
2057 },
2058 {
2059 .name = LPASS_BE_SLIMBUS_1_TX,
2060 .stream_name = "Slimbus1 Capture",
2061 .cpu_dai_name = "msm-dai-q6.16387",
2062 .platform_name = "msm-pcm-routing",
2063 .codec_name = "msm-stub-codec.1",
2064 .codec_dai_name = "msm-stub-tx",
2065 .no_pcm = 1,
2066 .be_id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
Vidyakumar Athota472f1ac2013-03-05 10:51:32 -08002067 .be_hw_params_fixup = msm_slim_1_tx_be_hw_params_fixup,
Neema Shetty3c9d2862012-03-11 01:25:32 -08002068 .ops = &msm_slimbus_1_be_ops,
2069 },
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002070 /* Ultrasound TX Back End DAI Link */
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002071 {
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002072 .name = "SLIMBUS_2 Hostless Capture",
2073 .stream_name = "SLIMBUS_2 Hostless Capture",
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002074 .cpu_dai_name = "msm-dai-q6.16389",
2075 .platform_name = "msm-pcm-hostless",
2076 .codec_name = "tabla_codec",
2077 .codec_dai_name = "tabla_tx2",
Swaminathan Sathappan630c5a42012-05-10 17:33:01 -07002078 .ignore_suspend = 1,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002079 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002080 .ops = &msm_slimbus_2_be_ops,
Kiran Kandi1e6371d2012-03-29 11:48:57 -07002081 },
Kiran Kandi97fe19d2012-05-20 22:34:04 -07002082 /* Ultrasound RX Back End DAI Link */
2083 {
2084 .name = "SLIMBUS_2 Hostless Playback",
2085 .stream_name = "SLIMBUS_2 Hostless Playback",
2086 .cpu_dai_name = "msm-dai-q6.16388",
2087 .platform_name = "msm-pcm-hostless",
2088 .codec_name = "tabla_codec",
2089 .codec_dai_name = "tabla_rx3",
2090 .ignore_suspend = 1,
2091 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
2092 .ops = &msm_slimbus_2_be_ops,
2093 },
Helen Zeng8f925502012-03-05 16:50:17 -08002094 /* Incall Music Back End DAI Link */
2095 {
2096 .name = LPASS_BE_SLIMBUS_4_RX,
2097 .stream_name = "Slimbus4 Playback",
2098 .cpu_dai_name = "msm-dai-q6.16392",
2099 .platform_name = "msm-pcm-routing",
2100 .codec_name = "msm-stub-codec.1",
2101 .codec_dai_name = "msm-stub-rx",
2102 .no_pcm = 1,
Helen Zeng8f925502012-03-05 16:50:17 -08002103 .be_id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
Helen Zeng548741e2012-09-11 18:32:24 -07002104 .be_hw_params_fixup = msm_slim_4_rx_be_hw_params_fixup,
Helen Zeng8f925502012-03-05 16:50:17 -08002105 .ops = &msm_slimbus_4_be_ops,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002106 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Helen Zeng8f925502012-03-05 16:50:17 -08002107 },
2108 /* Incall Record Back End DAI Link */
2109 {
2110 .name = LPASS_BE_SLIMBUS_4_TX,
2111 .stream_name = "Slimbus4 Capture",
2112 .cpu_dai_name = "msm-dai-q6.16393",
2113 .platform_name = "msm-pcm-routing",
2114 .codec_name = "msm-stub-codec.1",
2115 .codec_dai_name = "msm-stub-tx",
2116 .no_pcm = 1,
Helen Zeng8f925502012-03-05 16:50:17 -08002117 .be_id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
Helen Zengffd89f62012-08-17 17:35:32 -07002118 .be_hw_params_fixup = msm_slim_4_tx_be_hw_params_fixup,
Helen Zeng8f925502012-03-05 16:50:17 -08002119 .ops = &msm_slimbus_4_be_ops,
2120 },
Neema Shettye5cae8e2012-04-27 18:07:37 -07002121 {
2122 .name = LPASS_BE_STUB_1_TX,
2123 .stream_name = "Stub1 Capture",
2124 .cpu_dai_name = "msm-dai-stub",
2125 .platform_name = "msm-pcm-routing",
2126 .codec_name = "tabla_codec",
2127 .codec_dai_name = "tabla_tx3",
2128 .no_pcm = 1,
2129 .be_id = MSM_BACKEND_DAI_EXTPROC_EC_TX,
2130 /* This BE is used for external EC reference from codec. Since
2131 * Rx is fed as reference for EC, the config of this DAI is
2132 * based on that of the Rx path.
2133 */
2134 .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
2135 .ops = &msm_be_ops,
2136 },
Neema Shetty74131ac2012-05-09 13:35:26 -07002137 {
2138
2139 .name = LPASS_BE_SLIMBUS_3_RX,
2140 .stream_name = "Slimbus3 Playback",
2141 .cpu_dai_name = "msm-dai-q6.16390",
2142 .platform_name = "msm-pcm-routing",
2143 .codec_name = "msm-stub-codec.1",
2144 .codec_dai_name = "msm-stub-rx",
Neema Shetty74131ac2012-05-09 13:35:26 -07002145 .no_pcm = 1,
2146 .be_id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
2147 .be_hw_params_fixup = msm_slim_3_rx_be_hw_params_fixup,
2148 .ops = &msm_slimbus_3_be_ops,
Steve Mucklef132c6c2012-06-06 18:30:57 -07002149 .ignore_pmdown_time = 1, /* this dainlink has playback support */
Neema Shetty74131ac2012-05-09 13:35:26 -07002150 },
Helen Zeng38c3c962012-05-17 14:56:20 -07002151 {
2152 .name = LPASS_BE_SLIMBUS_3_TX,
2153 .stream_name = "Slimbus3 Capture",
2154 .cpu_dai_name = "msm-dai-q6.16391",
2155 .platform_name = "msm-pcm-routing",
2156 .codec_name = "msm-stub-codec.1",
2157 .codec_dai_name = "msm-stub-tx",
2158 .no_pcm = 1,
2159 .be_id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
2160 .be_hw_params_fixup = msm_slim_3_tx_be_hw_params_fixup,
2161 .ops = &msm_slimbus_3_be_ops,
2162 },
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002163};
2164
Kuirong Wang80f8ec42012-06-21 17:27:43 -07002165static struct snd_soc_card snd_soc_card_msm = {
Swaminathan Sathappanc165a3a2012-02-29 12:44:31 -08002166 .name = "apq8064-tabla-snd-card",
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002167 .dai_link = msm_dai,
2168 .num_links = ARRAY_SIZE(msm_dai),
Steve Mucklef132c6c2012-06-06 18:30:57 -07002169 .controls = tabla_msm_controls,
2170 .num_controls = ARRAY_SIZE(tabla_msm_controls),
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002171};
2172
2173static struct platform_device *msm_snd_device;
2174
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002175static int __init msm_audio_init(void)
2176{
2177 int ret;
Kuirong Wang80f8ec42012-06-21 17:27:43 -07002178 u32 version = socinfo_get_platform_version();
Stepan Moskovchenko5b9e7762012-09-21 20:32:17 -07002179 if (!soc_class_is_apq8064() ||
Jay Chokshi11abd8b2012-09-20 14:35:17 -07002180 (socinfo_get_id() == 130) ||
Kuirong Wangf993eac2012-09-11 11:47:45 -07002181 (machine_is_apq8064_mtp() &&
2182 (SOCINFO_VERSION_MINOR(version) == 1))) {
Kuirong Wang80f8ec42012-06-21 17:27:43 -07002183 pr_info("%s: Not APQ8064 in SLIMBUS mode\n", __func__);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002184 return -ENODEV;
2185 }
2186
David Collinsd49a1c52012-08-22 13:18:06 -07002187 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917)
2188 bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(16);
2189
Simmi Pateriya95746512013-01-16 00:17:02 +05302190 mutex_init(&cdc_mclk_mutex);
2191
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -07002192 mbhc_cfg.calibration = def_tabla_mbhc_cal();
2193 if (!mbhc_cfg.calibration) {
Joonwoo Park0976d012011-12-22 11:48:18 -08002194 pr_err("Calibration data allocation failed\n");
2195 return -ENOMEM;
2196 }
2197
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002198 msm_snd_device = platform_device_alloc("soc-audio", 0);
2199 if (!msm_snd_device) {
2200 pr_err("Platform device allocation failed\n");
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -07002201 kfree(mbhc_cfg.calibration);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002202 return -ENOMEM;
2203 }
2204
2205 platform_set_drvdata(msm_snd_device, &snd_soc_card_msm);
2206 ret = platform_device_add(msm_snd_device);
2207 if (ret) {
2208 platform_device_put(msm_snd_device);
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -07002209 kfree(mbhc_cfg.calibration);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002210 return ret;
2211 }
2212
Kuirong Wangae395b02012-09-20 11:43:17 -07002213 atomic_set(&auxpcm_rsc_ref, 0);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002214 return ret;
2215
2216}
2217module_init(msm_audio_init);
2218
2219static void __exit msm_audio_exit(void)
2220{
Stepan Moskovchenko5b9e7762012-09-21 20:32:17 -07002221 if (!soc_class_is_apq8064() || socinfo_get_id() == 130) {
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002222 pr_err("%s: Not the right machine type\n", __func__);
2223 return ;
2224 }
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002225 platform_device_unregister(msm_snd_device);
Joonwoo Parkca1516f2012-05-08 13:59:37 -07002226 if (mbhc_cfg.gpio)
2227 gpio_free(mbhc_cfg.gpio);
Joonwoo Parkd7cf2e92012-03-19 19:38:23 -07002228 kfree(mbhc_cfg.calibration);
Joonwoo Park9db5fb7a2012-06-15 12:10:46 -07002229 mutex_destroy(&cdc_mclk_mutex);
Bharath Ramachandramurthyb8e797f2011-11-30 12:08:42 -08002230}
2231module_exit(msm_audio_exit);
2232
2233MODULE_DESCRIPTION("ALSA SoC msm");
2234MODULE_LICENSE("GPL v2");