Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2 | * |
| 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 Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 20 | #include <linux/slab.h> |
Neema Shetty | a58b9a2 | 2012-06-18 19:03:23 -0700 | [diff] [blame] | 21 | #include <linux/pm_runtime.h> |
| 22 | #include <linux/slimbus/slimbus.h> |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 23 | #include <sound/core.h> |
| 24 | #include <sound/soc.h> |
| 25 | #include <sound/soc-dapm.h> |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 26 | #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 Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 44 | #define SAMPLE_RATE_8KHZ 8000 |
| 45 | #define SAMPLE_RATE_16KHZ 16000 |
| 46 | #define SAMPLE_RATE_48KHZ 48000 |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 47 | |
| 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 52 | #define TOP_SPK_AMP 0x10 |
| 53 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 54 | |
| 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 Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 60 | #define TABLA_EXT_CLK_RATE 12288000 |
| 61 | |
Swaminathan Sathappan | 4ea7f1a0 | 2012-02-29 12:55:55 -0800 | [diff] [blame] | 62 | #define TABLA_MBHC_DEF_BUTTONS 8 |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 63 | #define TABLA_MBHC_DEF_RLOADS 5 |
| 64 | |
Joonwoo Park | ca1516f | 2012-05-08 13:59:37 -0700 | [diff] [blame] | 65 | #define JACK_DETECT_GPIO 38 |
| 66 | |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 67 | /* Shared channel numbers for Slimbus ports that connect APQ to MDM. */ |
| 68 | enum { |
| 69 | SLIM_1_RX_1 = 145, /* BT-SCO and USB TX */ |
| 70 | SLIM_1_TX_1 = 146, /* BT-SCO and USB RX */ |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 71 | SLIM_1_TX_2 = 147, /* USB RX */ |
Neema Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 72 | SLIM_3_RX_1 = 151, /* External echo-cancellation ref */ |
| 73 | SLIM_3_RX_2 = 152, /* External echo-cancellation ref */ |
Helen Zeng | 38c3c96 | 2012-05-17 14:56:20 -0700 | [diff] [blame] | 74 | SLIM_3_TX_1 = 153, /* HDMI RX */ |
| 75 | SLIM_3_TX_2 = 154, /* HDMI RX */ |
Helen Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 76 | 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 | |
| 81 | enum { |
| 82 | INCALL_REC_MONO, |
| 83 | INCALL_REC_STEREO, |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 86 | static u32 top_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(18); |
| 87 | static u32 bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(19); |
| 88 | static int msm_spk_control; |
| 89 | static int msm_ext_bottom_spk_pamp; |
| 90 | static int msm_ext_top_spk_pamp; |
| 91 | static int msm_slim_0_rx_ch = 1; |
| 92 | static int msm_slim_0_tx_ch = 1; |
Neema Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 93 | static int msm_slim_3_rx_ch = 1; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 94 | |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 95 | static int msm_slim_1_rate = SAMPLE_RATE_8KHZ; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 96 | static int msm_btsco_ch = 1; |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 97 | static int msm_slim_1_rx_ch = 1; |
| 98 | static int msm_slim_1_tx_ch = 1; |
| 99 | |
Vicky Sehrawat | 4520413 | 2012-11-05 17:54:13 -0800 | [diff] [blame] | 100 | static int hdmi_rate_variable; |
Helen Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 101 | static int rec_mode = INCALL_REC_MONO; |
| 102 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 103 | static struct clk *codec_clk; |
| 104 | static int clk_users; |
| 105 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 106 | static struct snd_soc_jack hs_jack; |
| 107 | static struct snd_soc_jack button_jack; |
Kuirong Wang | ae395b0 | 2012-09-20 11:43:17 -0700 | [diff] [blame] | 108 | static atomic_t auxpcm_rsc_ref; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 109 | |
Joonwoo Park | 2699870 | 2012-05-09 10:10:06 -0700 | [diff] [blame] | 110 | static int apq8064_hs_detect_use_gpio = -1; |
| 111 | module_param(apq8064_hs_detect_use_gpio, int, 0444); |
| 112 | MODULE_PARM_DESC(apq8064_hs_detect_use_gpio, "Use GPIO for headset detection"); |
| 113 | |
Ravi Kumar Alamanda | 07b6bd6 | 2012-08-15 18:39:47 -0700 | [diff] [blame] | 114 | static bool apq8064_hs_detect_extn_cable; |
| 115 | module_param(apq8064_hs_detect_extn_cable, bool, 0444); |
| 116 | MODULE_PARM_DESC(apq8064_hs_detect_extn_cable, "Enable extension cable feature"); |
| 117 | |
Joonwoo Park | 2699870 | 2012-05-09 10:10:06 -0700 | [diff] [blame] | 118 | static bool apq8064_hs_detect_use_firmware; |
| 119 | module_param(apq8064_hs_detect_use_firmware, bool, 0444); |
| 120 | MODULE_PARM_DESC(apq8064_hs_detect_use_firmware, "Use firmware for headset " |
| 121 | "detection"); |
Joonwoo Park | ca1516f | 2012-05-08 13:59:37 -0700 | [diff] [blame] | 122 | |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 123 | static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, |
| 124 | bool dapm); |
| 125 | |
| 126 | static 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 Park | ca1516f | 2012-05-08 13:59:37 -0700 | [diff] [blame] | 134 | .gpio = 0, |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 135 | .gpio_irq = 0, |
| 136 | .gpio_level_insert = 1, |
Ravi Kumar Alamanda | 07b6bd6 | 2012-08-15 18:39:47 -0700 | [diff] [blame] | 137 | .detect_extn_cable = false, |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 138 | }; |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 139 | |
Joonwoo Park | 9db5fb7a | 2012-06-15 12:10:46 -0700 | [diff] [blame] | 140 | static struct mutex cdc_mclk_mutex; |
| 141 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 142 | static 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, ¶m); |
| 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, ¶m); |
| 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 | |
| 197 | static 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 220 | } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) { |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 221 | |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 222 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 228 | |
| 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 236 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 239 | |
| 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 | |
| 253 | static 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 269 | } 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 273 | |
| 274 | if (!msm_ext_top_spk_pamp) |
| 275 | return; |
| 276 | |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 277 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 288 | gpio_direction_output(top_spk_pamp_gpio, 0); |
| 289 | gpio_free(top_spk_pamp_gpio); |
| 290 | msm_ext_top_spk_pamp = 0; |
| 291 | |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 292 | pr_debug("%s: sleeping 4 ms after ext Top Spek Ampl is off\n", |
| 293 | __func__); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 294 | |
| 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 | |
| 304 | static 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 | |
| 324 | static 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 | } |
| 331 | static 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 | } |
| 344 | static 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 358 | else if (!strncmp(w->name, "Ext Spk Top", 12)) |
| 359 | msm_ext_spk_power_amp_on(TOP_SPK_AMP); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 360 | 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 375 | else if (!strncmp(w->name, "Ext Spk Top", 12)) |
| 376 | msm_ext_spk_power_amp_off(TOP_SPK_AMP); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 377 | 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 Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 386 | static int msm_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable, |
| 387 | bool dapm) |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 388 | { |
Joonwoo Park | 9db5fb7a | 2012-06-15 12:10:46 -0700 | [diff] [blame] | 389 | int r = 0; |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 390 | pr_debug("%s: enable = %d\n", __func__, enable); |
Joonwoo Park | 9db5fb7a | 2012-06-15 12:10:46 -0700 | [diff] [blame] | 391 | |
| 392 | mutex_lock(&cdc_mclk_mutex); |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 393 | if (enable) { |
| 394 | clk_users++; |
| 395 | pr_debug("%s: clk_users = %d\n", __func__, clk_users); |
Joonwoo Park | 9db5fb7a | 2012-06-15 12:10:46 -0700 | [diff] [blame] | 396 | 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 Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 407 | } |
| 408 | } else { |
Joonwoo Park | 9db5fb7a | 2012-06-15 12:10:46 -0700 | [diff] [blame] | 409 | 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 Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 414 | __func__, clk_users); |
Joonwoo Park | 9db5fb7a | 2012-06-15 12:10:46 -0700 | [diff] [blame] | 415 | 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 Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 421 | } |
| 422 | } |
Joonwoo Park | 9db5fb7a | 2012-06-15 12:10:46 -0700 | [diff] [blame] | 423 | mutex_unlock(&cdc_mclk_mutex); |
| 424 | return r; |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 425 | } |
| 426 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 427 | static 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 441 | if (codec_clk) { |
| 442 | clk_set_rate(codec_clk, 12288000); |
Asish Bhattacharya | 4776d96 | 2012-04-25 12:08:09 +0530 | [diff] [blame] | 443 | clk_prepare_enable(codec_clk); |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 444 | tabla_mclk_enable(w->codec, 1, true); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 445 | |
| 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 Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 465 | tabla_mclk_enable(w->codec, 0, true); |
Asish Bhattacharya | 4776d96 | 2012-04-25 12:08:09 +0530 | [diff] [blame] | 466 | clk_disable_unprepare(codec_clk); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 467 | } |
| 468 | break; |
| 469 | } |
| 470 | return 0; |
| 471 | } |
| 472 | |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 473 | static const struct snd_soc_dapm_widget apq8064_dapm_widgets[] = { |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 474 | |
| 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 483 | SND_SOC_DAPM_SPK("Ext Spk Top", msm_spkramp_event), |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 484 | |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 485 | /************ 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 492 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 493 | SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL), |
| 494 | SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL), |
| 495 | |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 496 | /*********** Digital Mics ***************/ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 497 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 503 | }; |
| 504 | |
Kiran Kandi | 323d710 | 2012-04-18 19:56:14 -0700 | [diff] [blame] | 505 | static const struct snd_soc_dapm_route apq8064_common_audio_map[] = { |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 506 | |
| 507 | {"RX_BIAS", NULL, "MCLK"}, |
| 508 | {"LDO_H", NULL, "MCLK"}, |
| 509 | |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 510 | {"HEADPHONE", NULL, "LDO_H"}, |
| 511 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 512 | /* 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 518 | {"Ext Spk Top", NULL, "LINEOUT5"}, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 519 | |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 520 | /************ Analog MIC Paths ************/ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 521 | |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 522 | /* Headset Mic */ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 523 | {"AMIC2", NULL, "MIC BIAS2 External"}, |
| 524 | {"MIC BIAS2 External", NULL, "Headset Mic"}, |
| 525 | |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 526 | /* Headset ANC microphones */ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 527 | {"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 Kandi | 323d710 | 2012-04-18 19:56:14 -0700 | [diff] [blame] | 532 | }; |
| 533 | |
| 534 | static 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 | |
| 575 | static 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 585 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 586 | |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 587 | /************ Digital MIC Paths ************/ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 588 | /** |
| 589 | * The digital Mic routes are setup considering |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 590 | * Liquid as default device. |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 591 | */ |
| 592 | |
| 593 | /** |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 594 | * Digital Mic1 (Front bottom left corner) on Liquid. |
| 595 | * Digital Mic2 (Front bottom right) on MTP. |
| 596 | * Digital Mic GM1 on CDP mainboard. |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 597 | * Conncted to DMIC2 Input on Tabla codec. |
| 598 | */ |
| 599 | {"DMIC2", NULL, "MIC BIAS1 External"}, |
| 600 | {"MIC BIAS1 External", NULL, "Digital Mic1"}, |
| 601 | |
| 602 | /** |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 603 | * Digital Mic2 (Front left side) on Liquid. |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 604 | * Digital Mic GM2 on CDP mainboard. |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 605 | * Not there on MTP. |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 606 | * Conncted to DMIC3 Input on Tabla codec. |
| 607 | */ |
| 608 | {"DMIC3", NULL, "MIC BIAS3 External"}, |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 609 | {"MIC BIAS3 External", NULL, "Digital Mic2"}, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 610 | |
| 611 | /** |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 612 | * 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 622 | * Digital Mic GM3 on CDP mainboard. |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 623 | * Top Front Mic on MTP. |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 624 | * Conncted to DMIC5 Input on Tabla codec. |
| 625 | */ |
| 626 | {"DMIC5", NULL, "MIC BIAS4 External"}, |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 627 | {"MIC BIAS4 External", NULL, "Digital Mic4"}, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 628 | |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 629 | /** |
| 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 634 | */ |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 635 | {"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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 645 | }; |
| 646 | |
| 647 | static const char *spk_function[] = {"Off", "On"}; |
| 648 | static const char *slim0_rx_ch_text[] = {"One", "Two"}; |
| 649 | static const char *slim0_tx_ch_text[] = {"One", "Two", "Three", "Four"}; |
Vicky Sehrawat | 4520413 | 2012-11-05 17:54:13 -0800 | [diff] [blame] | 650 | static const char * const hdmi_rate[] = {"Default", "Variable"}; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 651 | |
| 652 | static 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 Sehrawat | 4520413 | 2012-11-05 17:54:13 -0800 | [diff] [blame] | 656 | SOC_ENUM_SINGLE_EXT(2, hdmi_rate), |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 657 | }; |
| 658 | |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 659 | static const char * const slim1_rate_text[] = {"8000", "16000", "48000"}; |
| 660 | static const struct soc_enum msm_slim_1_rate_enum[] = { |
| 661 | SOC_ENUM_SINGLE_EXT(3, slim1_rate_text), |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 662 | }; |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 663 | static const char * const slim1_tx_ch_text[] = {"One", "Two"}; |
| 664 | static const struct soc_enum msm_slim_1_tx_ch_enum[] = { |
| 665 | SOC_ENUM_SINGLE_EXT(2, slim1_tx_ch_text), |
| 666 | }; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 667 | static 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 | |
| 676 | static 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 Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 682 | msm_slim_0_rx_ch); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 683 | return 1; |
| 684 | } |
| 685 | |
| 686 | static 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 | |
| 695 | static 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 Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 705 | static 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 | |
| 715 | static 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 Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 726 | static 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 | |
| 735 | static 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 Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 745 | static int msm_slim_1_rate_get(struct snd_kcontrol *kcontrol, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 746 | struct snd_ctl_elem_value *ucontrol) |
| 747 | { |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 748 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 752 | return 0; |
| 753 | } |
| 754 | |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 755 | static int msm_slim_1_rate_put(struct snd_kcontrol *kcontrol, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 756 | struct snd_ctl_elem_value *ucontrol) |
| 757 | { |
| 758 | switch (ucontrol->value.integer.value[0]) { |
Kuirong Wang | fd8e0b3 | 2012-05-30 19:45:04 -0700 | [diff] [blame] | 759 | case 8000: |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 760 | msm_slim_1_rate = SAMPLE_RATE_8KHZ; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 761 | break; |
Kuirong Wang | fd8e0b3 | 2012-05-30 19:45:04 -0700 | [diff] [blame] | 762 | case 16000: |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 763 | msm_slim_1_rate = SAMPLE_RATE_16KHZ; |
| 764 | break; |
| 765 | case 48000: |
| 766 | msm_slim_1_rate = SAMPLE_RATE_48KHZ; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 767 | break; |
| 768 | default: |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 769 | msm_slim_1_rate = SAMPLE_RATE_8KHZ; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 770 | break; |
| 771 | } |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 772 | pr_debug("%s: msm_slim_1_rate = %d\n", __func__, |
| 773 | msm_slim_1_rate); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 774 | return 0; |
| 775 | } |
| 776 | |
Helen Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 777 | static 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 | |
| 784 | static 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 Sehrawat | 4520413 | 2012-11-05 17:54:13 -0800 | [diff] [blame] | 794 | static 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 | |
| 802 | static 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 809 | static 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 Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 816 | 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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 820 | SOC_SINGLE_EXT("Incall Rec Mode", SND_SOC_NOPM, 0, 1, 0, |
Helen Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 821 | msm_incall_rec_mode_get, msm_incall_rec_mode_put), |
Neema Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 822 | SOC_ENUM_EXT("SLIM_3_RX Channels", msm_enum[1], |
| 823 | msm_slim_3_rx_ch_get, msm_slim_3_rx_ch_put), |
Vicky Sehrawat | 4520413 | 2012-11-05 17:54:13 -0800 | [diff] [blame] | 824 | SOC_ENUM_EXT("HDMI RX Rate", msm_enum[3], |
| 825 | msm_hdmi_rate_get, |
| 826 | msm_hdmi_rate_put), |
Neema Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 827 | }; |
| 828 | |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 829 | static 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 Sathappan | 4ea7f1a0 | 2012-02-29 12:55:55 -0800 | [diff] [blame] | 834 | u8 *n_ready, *n_cic, *gain; |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 835 | |
| 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 Sathappan | 4ea7f1a0 | 2012-02-29 12:55:55 -0800 | [diff] [blame] | 855 | S(t_ins_complete, 250); |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 856 | 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 Gajare | 975c53a | 2012-08-10 12:16:49 -0700 | [diff] [blame] | 860 | S(v_hs_max, 2400); |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 861 | #undef S |
| 862 | #define S(X, Y) ((TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal)->X) = (Y)) |
Swaminathan Sathappan | 4ea7f1a0 | 2012-02-29 12:55:55 -0800 | [diff] [blame] | 863 | S(c[0], 62); |
| 864 | S(c[1], 124); |
| 865 | S(nc, 1); |
| 866 | S(n_meas, 3); |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 867 | S(mbhc_nsc, 11); |
Swaminathan Sathappan | 4ea7f1a0 | 2012-02-29 12:55:55 -0800 | [diff] [blame] | 868 | S(n_btn_meas, 1); |
| 869 | S(n_btn_con, 2); |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 870 | 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 Sathappan | 4ea7f1a0 | 2012-02-29 12:55:55 -0800 | [diff] [blame] | 877 | btn_low[0] = -50; |
Bhalchandra Gajare | 975c53a | 2012-08-10 12:16:49 -0700 | [diff] [blame] | 878 | 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 Sathappan | 4ea7f1a0 | 2012-02-29 12:55:55 -0800 | [diff] [blame] | 893 | n_ready = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_READY); |
Bhalchandra Gajare | 975c53a | 2012-08-10 12:16:49 -0700 | [diff] [blame] | 894 | n_ready[0] = 80; |
| 895 | n_ready[1] = 68; |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 896 | n_cic = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_CIC); |
Swaminathan Sathappan | 4ea7f1a0 | 2012-02-29 12:55:55 -0800 | [diff] [blame] | 897 | n_cic[0] = 60; |
| 898 | n_cic[1] = 47; |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 899 | 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 Ramachandramurthy | 9c79f13 | 2011-11-28 11:18:57 -0800 | [diff] [blame] | 906 | static 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 915 | unsigned int num_tx_ch = 0; |
Bharath Ramachandramurthy | 9c79f13 | 2011-11-28 11:18:57 -0800 | [diff] [blame] | 916 | |
Bharath Ramachandramurthy | 9c79f13 | 2011-11-28 11:18:57 -0800 | [diff] [blame] | 917 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 918 | |
| 919 | pr_debug("%s: rx_0_ch=%d\n", __func__, msm_slim_0_rx_ch); |
| 920 | |
Bharath Ramachandramurthy | 9c79f13 | 2011-11-28 11:18:57 -0800 | [diff] [blame] | 921 | 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 Ramachandramurthy | 9c79f13 | 2011-11-28 11:18:57 -0800 | [diff] [blame] | 934 | } else { |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 935 | pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__, |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 936 | codec_dai->name, codec_dai->id, num_tx_ch); |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 937 | |
Bharath Ramachandramurthy | 9c79f13 | 2011-11-28 11:18:57 -0800 | [diff] [blame] | 938 | 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 Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 944 | /* 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 Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 957 | |
Bharath Ramachandramurthy | 9c79f13 | 2011-11-28 11:18:57 -0800 | [diff] [blame] | 958 | ret = snd_soc_dai_set_channel_map(cpu_dai, |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 959 | num_tx_ch, tx_ch, 0 , 0); |
Bharath Ramachandramurthy | 9c79f13 | 2011-11-28 11:18:57 -0800 | [diff] [blame] | 960 | if (ret < 0) { |
| 961 | pr_err("%s: failed to set cpu chan map\n", __func__); |
| 962 | goto end; |
| 963 | } |
Bharath Ramachandramurthy | 9c79f13 | 2011-11-28 11:18:57 -0800 | [diff] [blame] | 964 | } |
| 965 | end: |
| 966 | return ret; |
| 967 | } |
| 968 | |
Helen Zeng | f3b17fb | 2012-02-28 15:07:38 -0800 | [diff] [blame] | 969 | static int msm_stubrx_init(struct snd_soc_pcm_runtime *rtd) |
| 970 | { |
| 971 | rtd->pmdown_time = 0; |
| 972 | |
| 973 | return 0; |
| 974 | } |
| 975 | |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 976 | static 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 1008 | } 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 1028 | } |
| 1029 | end: |
| 1030 | return ret; |
| 1031 | } |
| 1032 | |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 1033 | static 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 Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 1039 | unsigned int rx_ch = SLIM_1_RX_1, tx_ch[2] = {SLIM_1_TX_1, SLIM_1_TX_2}; |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 1040 | |
| 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 Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 1053 | 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 Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 1055 | |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 1056 | ret = snd_soc_dai_set_channel_map(cpu_dai, msm_slim_1_tx_ch, |
| 1057 | tx_ch, 0, 0); |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 1058 | 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 | |
| 1066 | end: |
| 1067 | return ret; |
| 1068 | } |
| 1069 | |
Neema Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 1070 | static 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 Zeng | 38c3c96 | 2012-05-17 14:56:20 -0700 | [diff] [blame] | 1077 | unsigned int tx_ch[2] = {SLIM_3_TX_1, SLIM_3_TX_2}; |
Neema Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 1078 | |
| 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 Zeng | 38c3c96 | 2012-05-17 14:56:20 -0700 | [diff] [blame] | 1093 | 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 Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 1103 | } |
| 1104 | |
| 1105 | end: |
| 1106 | return ret; |
| 1107 | } |
| 1108 | |
Helen Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 1109 | static 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1151 | static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd) |
| 1152 | { |
| 1153 | int err; |
Joonwoo Park | 2699870 | 2012-05-09 10:10:06 -0700 | [diff] [blame] | 1154 | uint32_t revision; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1155 | struct snd_soc_codec *codec = rtd->codec; |
| 1156 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
Kuirong Wang | a9c3acc | 2012-02-09 17:00:45 -0800 | [diff] [blame] | 1157 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1158 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1163 | |
Kuirong Wang | a9c3acc | 2012-02-09 17:00:45 -0800 | [diff] [blame] | 1164 | pr_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev)); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1165 | |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 1166 | snd_soc_dapm_new_controls(dapm, apq8064_dapm_widgets, |
| 1167 | ARRAY_SIZE(apq8064_dapm_widgets)); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1168 | |
Kiran Kandi | 323d710 | 2012-04-18 19:56:14 -0700 | [diff] [blame] | 1169 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1179 | |
| 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 Alamanda | 07b6bd6 | 2012-08-15 18:39:47 -0700 | [diff] [blame] | 1188 | (SND_JACK_HEADSET | SND_JACK_LINEOUT | |
| 1189 | SND_JACK_OC_HPHL | SND_JACK_OC_HPHR | |
| 1190 | SND_JACK_UNSUPPORTED), |
Joonwoo Park | cca30bb | 2012-07-11 13:31:55 -0700 | [diff] [blame] | 1191 | &hs_jack); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1192 | 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 Sathappan | 4ea7f1a0 | 2012-02-29 12:55:55 -0800 | [diff] [blame] | 1198 | TABLA_JACK_BUTTON_MASK, &button_jack); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1199 | if (err) { |
| 1200 | pr_err("failed to create new jack\n"); |
| 1201 | return err; |
| 1202 | } |
| 1203 | |
Kuirong Wang | a9c3acc | 2012-02-09 17:00:45 -0800 | [diff] [blame] | 1204 | codec_clk = clk_get(cpu_dai->dev, "osr_clk"); |
| 1205 | |
Joonwoo Park | 2699870 | 2012-05-09 10:10:06 -0700 | [diff] [blame] | 1206 | /* 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 Park | ca1516f | 2012-05-08 13:59:37 -0700 | [diff] [blame] | 1234 | 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 Alamanda | 07b6bd6 | 2012-08-15 18:39:47 -0700 | [diff] [blame] | 1243 | if (apq8064_hs_detect_extn_cable) |
| 1244 | mbhc_cfg.detect_extn_cable = true; |
Joonwoo Park | 2699870 | 2012-05-09 10:10:06 -0700 | [diff] [blame] | 1245 | } 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 Park | ca1516f | 2012-05-08 13:59:37 -0700 | [diff] [blame] | 1249 | |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 1250 | err = tabla_hs_detect(codec, &mbhc_cfg); |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 1251 | snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), |
| 1252 | tx_ch, ARRAY_SIZE(rx_ch), rx_ch); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1253 | |
Joonwoo Park | 0332483 | 2012-03-19 19:36:16 -0700 | [diff] [blame] | 1254 | return err; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1255 | } |
| 1256 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1257 | static 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 | |
| 1273 | static 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 Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 1289 | static 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 Zeng | 38c3c96 | 2012-05-17 14:56:20 -0700 | [diff] [blame] | 1305 | static 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 Zeng | ffd89f6 | 2012-08-17 17:35:32 -0700 | [diff] [blame] | 1321 | static 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 Zeng | 548741e | 2012-09-11 18:32:24 -0700 | [diff] [blame] | 1343 | static 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1361 | static 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 Sathappan | fd9dbad | 2012-02-15 16:56:44 -0800 | [diff] [blame] | 1373 | static 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 Zeng | 12123a1 | 2012-09-26 15:57:43 -0700 | [diff] [blame] | 1385 | if (channels->max < 2) |
| 1386 | channels->min = channels->max = 2; |
Vicky Sehrawat | 4520413 | 2012-11-05 17:54:13 -0800 | [diff] [blame] | 1387 | if (!hdmi_rate_variable) |
| 1388 | rate->min = rate->max = 48000; |
Swaminathan Sathappan | fd9dbad | 2012-02-15 16:56:44 -0800 | [diff] [blame] | 1389 | |
| 1390 | return 0; |
| 1391 | } |
| 1392 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1393 | static 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 Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 1397 | SNDRV_PCM_HW_PARAM_RATE); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1398 | |
| 1399 | struct snd_interval *channels = hw_param_interval(params, |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 1400 | SNDRV_PCM_HW_PARAM_CHANNELS); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1401 | |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 1402 | rate->min = rate->max = msm_slim_1_rate; |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1403 | channels->min = channels->max = msm_btsco_ch; |
| 1404 | |
| 1405 | return 0; |
| 1406 | } |
Vidyakumar Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 1407 | static 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 | |
| 1422 | static 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1437 | static 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 Sangaraboina | 66bd39d | 2012-06-29 18:10:23 -0700 | [diff] [blame] | 1452 | static 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 Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 1463 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1464 | static 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 | |
| 1499 | fail_clk: |
| 1500 | gpio_free(GPIO_AUX_PCM_SYNC); |
| 1501 | fail_sync: |
| 1502 | gpio_free(GPIO_AUX_PCM_DIN); |
| 1503 | fail_din: |
| 1504 | gpio_free(GPIO_AUX_PCM_DOUT); |
| 1505 | fail_dout: |
| 1506 | |
| 1507 | return ret; |
| 1508 | } |
| 1509 | |
| 1510 | static 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 | } |
| 1519 | static int msm_startup(struct snd_pcm_substream *substream) |
| 1520 | { |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 1521 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1527 | return 0; |
| 1528 | } |
| 1529 | |
| 1530 | static int msm_auxpcm_startup(struct snd_pcm_substream *substream) |
| 1531 | { |
| 1532 | int ret = 0; |
| 1533 | |
Kuirong Wang | ae395b0 | 2012-09-20 11:43:17 -0700 | [diff] [blame] | 1534 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1538 | if (ret < 0) { |
| 1539 | pr_err("%s: Aux PCM GPIO request failed\n", __func__); |
| 1540 | return -EINVAL; |
| 1541 | } |
| 1542 | return 0; |
| 1543 | } |
| 1544 | |
Neema Shetty | a58b9a2 | 2012-06-18 19:03:23 -0700 | [diff] [blame] | 1545 | static 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1558 | static void msm_auxpcm_shutdown(struct snd_pcm_substream *substream) |
| 1559 | { |
| 1560 | |
Kuirong Wang | ae395b0 | 2012-09-20 11:43:17 -0700 | [diff] [blame] | 1561 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1565 | } |
| 1566 | |
| 1567 | static void msm_shutdown(struct snd_pcm_substream *substream) |
| 1568 | { |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 1569 | 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1574 | } |
| 1575 | |
Neema Shetty | a58b9a2 | 2012-06-18 19:03:23 -0700 | [diff] [blame] | 1576 | static 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1589 | static struct snd_soc_ops msm_be_ops = { |
| 1590 | .startup = msm_startup, |
Bharath Ramachandramurthy | 9c79f13 | 2011-11-28 11:18:57 -0800 | [diff] [blame] | 1591 | .hw_params = msm_hw_params, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1592 | .shutdown = msm_shutdown, |
| 1593 | }; |
| 1594 | |
| 1595 | static struct snd_soc_ops msm_auxpcm_be_ops = { |
| 1596 | .startup = msm_auxpcm_startup, |
| 1597 | .shutdown = msm_auxpcm_shutdown, |
| 1598 | }; |
| 1599 | |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 1600 | static struct snd_soc_ops msm_slimbus_1_be_ops = { |
Neema Shetty | a58b9a2 | 2012-06-18 19:03:23 -0700 | [diff] [blame] | 1601 | .startup = msm_slimbus_1_startup, |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 1602 | .hw_params = msm_slimbus_1_hw_params, |
Neema Shetty | a58b9a2 | 2012-06-18 19:03:23 -0700 | [diff] [blame] | 1603 | .shutdown = msm_slimbus_1_shutdown, |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 1604 | }; |
| 1605 | |
Neema Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 1606 | static 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 Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 1612 | static 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 Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 1618 | static 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1625 | /* Digital audio interface glue - connects codec <---> CPU */ |
| 1626 | static 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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1634 | .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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1639 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1 |
| 1640 | }, |
| 1641 | { |
| 1642 | .name = "MSM8960 Media2", |
| 1643 | .stream_name = "MultiMedia2", |
| 1644 | .cpu_dai_name = "MultiMedia2", |
Bharath Ramachandramurthy | f79f92b | 2012-03-29 12:11:54 -0700 | [diff] [blame] | 1645 | .platform_name = "msm-multi-ch-pcm-dsp", |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1646 | .dynamic = 1, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1647 | .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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1652 | .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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1660 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1661 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1662 | .ignore_suspend = 1, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1663 | .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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1668 | }, |
| 1669 | { |
| 1670 | .name = "MSM VoIP", |
| 1671 | .stream_name = "VoIP", |
| 1672 | .cpu_dai_name = "VoIP", |
| 1673 | .platform_name = "msm-voip-dsp", |
| 1674 | .dynamic = 1, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1675 | .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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1680 | .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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1688 | .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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1693 | .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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1702 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1703 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1704 | .ignore_suspend = 1, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1705 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
| 1706 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1707 | .codec_name = "snd-soc-dummy", |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1708 | /* .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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1716 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1717 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1718 | .ignore_suspend = 1, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1719 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
| 1720 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1721 | .codec_name = "snd-soc-dummy", |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1722 | /* .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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1732 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1733 | }, |
| 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 Shetty | b945124 | 2012-02-16 15:37:59 -0800 | [diff] [blame] | 1743 | { |
Bharath Ramachandramurthy | f79f92b | 2012-03-29 12:11:54 -0700 | [diff] [blame] | 1744 | .name = "MSM8960 Compr", |
| 1745 | .stream_name = "COMPR", |
| 1746 | .cpu_dai_name = "MultiMedia4", |
Xiaojun Sang | 43f3d3b | 2017-04-27 14:44:25 +0800 | [diff] [blame] | 1747 | .platform_name = "msm-compress-dsp", |
Bharath Ramachandramurthy | f79f92b | 2012-03-29 12:11:54 -0700 | [diff] [blame] | 1748 | .dynamic = 1, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1749 | .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 Ramachandramurthy | f79f92b | 2012-03-29 12:11:54 -0700 | [diff] [blame] | 1754 | .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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1762 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
Bharath Ramachandramurthy | f79f92b | 2012-03-29 12:11:54 -0700 | [diff] [blame] | 1763 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1764 | .ignore_suspend = 1, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1765 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
| 1766 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1767 | .codec_name = "snd-soc-dummy", |
Bharath Ramachandramurthy | f79f92b | 2012-03-29 12:11:54 -0700 | [diff] [blame] | 1768 | }, |
| 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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1776 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
Bharath Ramachandramurthy | f79f92b | 2012-03-29 12:11:54 -0700 | [diff] [blame] | 1777 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1778 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1779 | .codec_name = "snd-soc-dummy", |
Bharath Ramachandramurthy | f79f92b | 2012-03-29 12:11:54 -0700 | [diff] [blame] | 1780 | .ignore_suspend = 1, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1781 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Bharath Ramachandramurthy | f79f92b | 2012-03-29 12:11:54 -0700 | [diff] [blame] | 1782 | }, |
| 1783 | { |
Neema Shetty | b945124 | 2012-02-16 15:37:59 -0800 | [diff] [blame] | 1784 | .name = "Voice Stub", |
| 1785 | .stream_name = "Voice Stub", |
| 1786 | .cpu_dai_name = "VOICE_STUB", |
| 1787 | .platform_name = "msm-pcm-hostless", |
| 1788 | .dynamic = 1, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1789 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
Neema Shetty | b945124 | 2012-02-16 15:37:59 -0800 | [diff] [blame] | 1790 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1791 | .ignore_suspend = 1, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1792 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
| 1793 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1794 | .codec_name = "snd-soc-dummy", |
Neema Shetty | b945124 | 2012-02-16 15:37:59 -0800 | [diff] [blame] | 1795 | }, |
Jayasena Sangaraboina | 99bf09c | 2012-07-17 12:03:08 -0700 | [diff] [blame] | 1796 | { |
Helen Zeng | 6b0a1b6 | 2013-03-01 18:03:09 -0800 | [diff] [blame] | 1797 | .name = "VoLTE Stub", |
| 1798 | .stream_name = "VoLTE Stub", |
| 1799 | .cpu_dai_name = "VOLTE_STUB", |
| 1800 | .platform_name = "msm-pcm-hostless", |
Jayasena Sangaraboina | 99bf09c | 2012-07-17 12:03:08 -0700 | [diff] [blame] | 1801 | .dynamic = 1, |
| 1802 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
Helen Zeng | 6b0a1b6 | 2013-03-01 18:03:09 -0800 | [diff] [blame] | 1803 | SND_SOC_DPCM_TRIGGER_POST}, |
Jayasena Sangaraboina | 99bf09c | 2012-07-17 12:03:08 -0700 | [diff] [blame] | 1804 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1805 | .ignore_suspend = 1, |
Jayasena Sangaraboina | 99bf09c | 2012-07-17 12:03:08 -0700 | [diff] [blame] | 1806 | .ignore_pmdown_time = 1, |
| 1807 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1808 | .codec_name = "snd-soc-dummy", |
Jayasena Sangaraboina | 99bf09c | 2012-07-17 12:03:08 -0700 | [diff] [blame] | 1809 | }, |
| 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 Kolathappilly | f059e97 | 2012-07-16 12:06:28 -0700 | [diff] [blame] | 1825 | { |
| 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 Sang | 43f3d3b | 2017-04-27 14:44:25 +0800 | [diff] [blame] | 1843 | .platform_name = "msm-compress-dsp", |
Krishnankutty Kolathappilly | f059e97 | 2012-07-16 12:06:28 -0700 | [diff] [blame] | 1844 | .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 Sang | 43f3d3b | 2017-04-27 14:44:25 +0800 | [diff] [blame] | 1857 | .platform_name = "msm-compress-dsp", |
Krishnankutty Kolathappilly | f059e97 | 2012-07-16 12:06:28 -0700 | [diff] [blame] | 1858 | .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 Zeng | c6e3d85 | 2013-03-06 11:34:14 -0800 | [diff] [blame] | 1867 | { |
| 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1882 | /* 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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1895 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1896 | }, |
| 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1917 | .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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1920 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1921 | }, |
| 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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1943 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1944 | }, |
| 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 Sathappan | fd9dbad | 2012-02-15 16:56:44 -0800 | [diff] [blame] | 1960 | .cpu_dai_name = "msm-dai-q6-hdmi.8", |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1961 | .platform_name = "msm-pcm-routing", |
| 1962 | .codec_name = "msm-stub-codec.1", |
| 1963 | .codec_dai_name = "msm-stub-rx", |
| 1964 | .no_pcm = 1, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1965 | .be_id = MSM_BACKEND_DAI_HDMI_RX, |
Swaminathan Sathappan | fd9dbad | 2012-02-15 16:56:44 -0800 | [diff] [blame] | 1966 | .be_hw_params_fixup = msm_hdmi_be_hw_params_fixup, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1967 | }, |
| 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1976 | .no_pcm = 1, |
| 1977 | .be_id = MSM_BACKEND_DAI_AFE_PCM_RX, |
Jayasena Sangaraboina | 66bd39d | 2012-06-29 18:10:23 -0700 | [diff] [blame] | 1978 | .be_hw_params_fixup = msm_proxy_be_hw_params_fixup, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1979 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1980 | }, |
| 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1988 | .no_pcm = 1, |
| 1989 | .be_id = MSM_BACKEND_DAI_AFE_PCM_TX, |
Jayasena Sangaraboina | 66bd39d | 2012-06-29 18:10:23 -0700 | [diff] [blame] | 1990 | .be_hw_params_fixup = msm_proxy_be_hw_params_fixup, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 1991 | }, |
| 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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 2004 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2005 | }, |
| 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 Wang | ae395b0 | 2012-09-20 11:43:17 -0700 | [diff] [blame] | 2016 | .ops = &msm_auxpcm_be_ops, |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2017 | }, |
Neema Shetty | b945124 | 2012-02-16 15:37:59 -0800 | [diff] [blame] | 2018 | { |
| 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 Shetty | e5cae8e | 2012-04-27 18:07:37 -0700 | [diff] [blame] | 2026 | .be_id = MSM_BACKEND_DAI_EXTPROC_RX, |
Neema Shetty | b945124 | 2012-02-16 15:37:59 -0800 | [diff] [blame] | 2027 | .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup, |
Helen Zeng | f3b17fb | 2012-02-28 15:07:38 -0800 | [diff] [blame] | 2028 | .init = &msm_stubrx_init, |
Neema Shetty | b945124 | 2012-02-16 15:37:59 -0800 | [diff] [blame] | 2029 | .ops = &msm_be_ops, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 2030 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Neema Shetty | b945124 | 2012-02-16 15:37:59 -0800 | [diff] [blame] | 2031 | }, |
| 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 Shetty | e5cae8e | 2012-04-27 18:07:37 -0700 | [diff] [blame] | 2040 | .be_id = MSM_BACKEND_DAI_EXTPROC_TX, |
Neema Shetty | b945124 | 2012-02-16 15:37:59 -0800 | [diff] [blame] | 2041 | .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup, |
| 2042 | .ops = &msm_be_ops, |
| 2043 | }, |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 2044 | { |
| 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 Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 2053 | .be_hw_params_fixup = msm_slim_1_rx_be_hw_params_fixup, |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 2054 | .ops = &msm_slimbus_1_be_ops, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 2055 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 2056 | |
| 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 Athota | 472f1ac | 2013-03-05 10:51:32 -0800 | [diff] [blame] | 2067 | .be_hw_params_fixup = msm_slim_1_tx_be_hw_params_fixup, |
Neema Shetty | 3c9d286 | 2012-03-11 01:25:32 -0800 | [diff] [blame] | 2068 | .ops = &msm_slimbus_1_be_ops, |
| 2069 | }, |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 2070 | /* Ultrasound TX Back End DAI Link */ |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 2071 | { |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 2072 | .name = "SLIMBUS_2 Hostless Capture", |
| 2073 | .stream_name = "SLIMBUS_2 Hostless Capture", |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 2074 | .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 Sathappan | 630c5a4 | 2012-05-10 17:33:01 -0700 | [diff] [blame] | 2078 | .ignore_suspend = 1, |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 2079 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 2080 | .ops = &msm_slimbus_2_be_ops, |
Kiran Kandi | 1e6371d | 2012-03-29 11:48:57 -0700 | [diff] [blame] | 2081 | }, |
Kiran Kandi | 97fe19d | 2012-05-20 22:34:04 -0700 | [diff] [blame] | 2082 | /* 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 Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 2094 | /* 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 Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 2103 | .be_id = MSM_BACKEND_DAI_SLIMBUS_4_RX, |
Helen Zeng | 548741e | 2012-09-11 18:32:24 -0700 | [diff] [blame] | 2104 | .be_hw_params_fixup = msm_slim_4_rx_be_hw_params_fixup, |
Helen Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 2105 | .ops = &msm_slimbus_4_be_ops, |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 2106 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Helen Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 2107 | }, |
| 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 Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 2117 | .be_id = MSM_BACKEND_DAI_SLIMBUS_4_TX, |
Helen Zeng | ffd89f6 | 2012-08-17 17:35:32 -0700 | [diff] [blame] | 2118 | .be_hw_params_fixup = msm_slim_4_tx_be_hw_params_fixup, |
Helen Zeng | 8f92550 | 2012-03-05 16:50:17 -0800 | [diff] [blame] | 2119 | .ops = &msm_slimbus_4_be_ops, |
| 2120 | }, |
Neema Shetty | e5cae8e | 2012-04-27 18:07:37 -0700 | [diff] [blame] | 2121 | { |
| 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 Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 2137 | { |
| 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 Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 2145 | .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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 2149 | .ignore_pmdown_time = 1, /* this dainlink has playback support */ |
Neema Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 2150 | }, |
Helen Zeng | 38c3c96 | 2012-05-17 14:56:20 -0700 | [diff] [blame] | 2151 | { |
| 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 Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2163 | }; |
| 2164 | |
Kuirong Wang | 80f8ec4 | 2012-06-21 17:27:43 -0700 | [diff] [blame] | 2165 | static struct snd_soc_card snd_soc_card_msm = { |
Swaminathan Sathappan | c165a3a | 2012-02-29 12:44:31 -0800 | [diff] [blame] | 2166 | .name = "apq8064-tabla-snd-card", |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2167 | .dai_link = msm_dai, |
| 2168 | .num_links = ARRAY_SIZE(msm_dai), |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 2169 | .controls = tabla_msm_controls, |
| 2170 | .num_controls = ARRAY_SIZE(tabla_msm_controls), |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2171 | }; |
| 2172 | |
| 2173 | static struct platform_device *msm_snd_device; |
| 2174 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2175 | static int __init msm_audio_init(void) |
| 2176 | { |
| 2177 | int ret; |
Kuirong Wang | 80f8ec4 | 2012-06-21 17:27:43 -0700 | [diff] [blame] | 2178 | u32 version = socinfo_get_platform_version(); |
Stepan Moskovchenko | 5b9e776 | 2012-09-21 20:32:17 -0700 | [diff] [blame] | 2179 | if (!soc_class_is_apq8064() || |
Jay Chokshi | 11abd8b | 2012-09-20 14:35:17 -0700 | [diff] [blame] | 2180 | (socinfo_get_id() == 130) || |
Kuirong Wang | f993eac | 2012-09-11 11:47:45 -0700 | [diff] [blame] | 2181 | (machine_is_apq8064_mtp() && |
| 2182 | (SOCINFO_VERSION_MINOR(version) == 1))) { |
Kuirong Wang | 80f8ec4 | 2012-06-21 17:27:43 -0700 | [diff] [blame] | 2183 | pr_info("%s: Not APQ8064 in SLIMBUS mode\n", __func__); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2184 | return -ENODEV; |
| 2185 | } |
| 2186 | |
David Collins | d49a1c5 | 2012-08-22 13:18:06 -0700 | [diff] [blame] | 2187 | if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) |
| 2188 | bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(16); |
| 2189 | |
Simmi Pateriya | 9574651 | 2013-01-16 00:17:02 +0530 | [diff] [blame] | 2190 | mutex_init(&cdc_mclk_mutex); |
| 2191 | |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 2192 | mbhc_cfg.calibration = def_tabla_mbhc_cal(); |
| 2193 | if (!mbhc_cfg.calibration) { |
Joonwoo Park | 0976d01 | 2011-12-22 11:48:18 -0800 | [diff] [blame] | 2194 | pr_err("Calibration data allocation failed\n"); |
| 2195 | return -ENOMEM; |
| 2196 | } |
| 2197 | |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2198 | msm_snd_device = platform_device_alloc("soc-audio", 0); |
| 2199 | if (!msm_snd_device) { |
| 2200 | pr_err("Platform device allocation failed\n"); |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 2201 | kfree(mbhc_cfg.calibration); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2202 | 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 Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 2209 | kfree(mbhc_cfg.calibration); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2210 | return ret; |
| 2211 | } |
| 2212 | |
Kuirong Wang | ae395b0 | 2012-09-20 11:43:17 -0700 | [diff] [blame] | 2213 | atomic_set(&auxpcm_rsc_ref, 0); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2214 | return ret; |
| 2215 | |
| 2216 | } |
| 2217 | module_init(msm_audio_init); |
| 2218 | |
| 2219 | static void __exit msm_audio_exit(void) |
| 2220 | { |
Stepan Moskovchenko | 5b9e776 | 2012-09-21 20:32:17 -0700 | [diff] [blame] | 2221 | if (!soc_class_is_apq8064() || socinfo_get_id() == 130) { |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2222 | pr_err("%s: Not the right machine type\n", __func__); |
| 2223 | return ; |
| 2224 | } |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2225 | platform_device_unregister(msm_snd_device); |
Joonwoo Park | ca1516f | 2012-05-08 13:59:37 -0700 | [diff] [blame] | 2226 | if (mbhc_cfg.gpio) |
| 2227 | gpio_free(mbhc_cfg.gpio); |
Joonwoo Park | d7cf2e9 | 2012-03-19 19:38:23 -0700 | [diff] [blame] | 2228 | kfree(mbhc_cfg.calibration); |
Joonwoo Park | 9db5fb7a | 2012-06-15 12:10:46 -0700 | [diff] [blame] | 2229 | mutex_destroy(&cdc_mclk_mutex); |
Bharath Ramachandramurthy | b8e797f | 2011-11-30 12:08:42 -0800 | [diff] [blame] | 2230 | } |
| 2231 | module_exit(msm_audio_exit); |
| 2232 | |
| 2233 | MODULE_DESCRIPTION("ALSA SoC msm"); |
| 2234 | MODULE_LICENSE("GPL v2"); |