1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426 |
- /* Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- #include <linux/clk.h>
- #include <linux/delay.h>
- #include <linux/gpio.h>
- #include <linux/mfd/pm8xxx/spk.h>
- #include <linux/platform_device.h>
- #include <linux/gpio.h>
- #include <linux/slab.h>
- #include <sound/core.h>
- #include <sound/soc.h>
- #include <sound/soc-dapm.h>
- #include <sound/pcm.h>
- #include <sound/jack.h>
- #include <asm/mach-types.h>
- #include <mach/socinfo.h>
- #include "msm-pcm-routing.h"
- #include "../codecs/wcd9304.h"
- /* 8930 machine driver */
- #define MSM8930_SPK_ON 1
- #define MSM8930_SPK_OFF 0
- #define BTSCO_RATE_8KHZ 8000
- #define BTSCO_RATE_16KHZ 16000
- #define SPK_AMP_POS 0x1
- #define SPK_AMP_NEG 0x2
- #define SPKR_BOOST_GPIO 15
- #define LEFT_SPKR_AMPL_GPIO 15
- #define DEFAULT_PMIC_SPK_GAIN 0x0D
- #define SITAR_EXT_CLK_RATE 12288000
- #define SITAR_MBHC_DEF_BUTTONS 8
- #define SITAR_MBHC_DEF_RLOADS 5
- #define GPIO_AUX_PCM_DOUT 63
- #define GPIO_AUX_PCM_DIN 64
- #define GPIO_AUX_PCM_SYNC 65
- #define GPIO_AUX_PCM_CLK 66
- static int msm8930_spk_control;
- static int msm8930_slim_0_rx_ch = 1;
- static int msm8930_slim_0_tx_ch = 1;
- static int msm8930_pmic_spk_gain = DEFAULT_PMIC_SPK_GAIN;
- static int msm8930_ext_spk_pamp;
- static int msm8930_btsco_rate = BTSCO_RATE_8KHZ;
- static int msm8930_btsco_ch = 1;
- static int hdmi_rate_variable;
- static struct clk *codec_clk;
- static int clk_users;
- static int msm8930_headset_gpios_configured;
- static struct mutex cdc_mclk_mutex;
- static struct snd_soc_jack hs_jack;
- static struct snd_soc_jack button_jack;
- static atomic_t auxpcm_rsc_ref;
- static int msm8930_enable_codec_ext_clk(
- struct snd_soc_codec *codec, int enable,
- bool dapm);
- static struct sitar_mbhc_config mbhc_cfg = {
- .headset_jack = &hs_jack,
- .button_jack = &button_jack,
- .read_fw_bin = false,
- .calibration = NULL,
- .micbias = SITAR_MICBIAS2,
- .mclk_cb_fn = msm8930_enable_codec_ext_clk,
- .mclk_rate = SITAR_EXT_CLK_RATE,
- .gpio = 0,
- .gpio_irq = 0,
- .gpio_level_insert = 1,
- };
- static void msm8930_ext_control(struct snd_soc_codec *codec)
- {
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- pr_debug("%s: msm8930_spk_control = %d", __func__, msm8930_spk_control);
- if (msm8930_spk_control == MSM8930_SPK_ON) {
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Left Pos");
- snd_soc_dapm_enable_pin(dapm, "Ext Spk left Neg");
- } else {
- snd_soc_dapm_disable_pin(dapm, "Ext Spk Left Pos");
- snd_soc_dapm_disable_pin(dapm, "Ext Spk Left Neg");
- }
- snd_soc_dapm_sync(dapm);
- }
- static int msm8930_get_spk(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8930_spk_control = %d", __func__, msm8930_spk_control);
- ucontrol->value.integer.value[0] = msm8930_spk_control;
- return 0;
- }
- static int msm8930_set_spk(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
- pr_debug("%s()\n", __func__);
- if (msm8930_spk_control == ucontrol->value.integer.value[0])
- return 0;
- msm8930_spk_control = ucontrol->value.integer.value[0];
- msm8930_ext_control(codec);
- return 1;
- }
- static int msm8930_cfg_spkr_gpio(int gpio,
- int enable, const char *gpio_label)
- {
- int ret = 0;
- pr_debug("%s: Configure %s GPIO %u",
- __func__, gpio_label, gpio);
- ret = gpio_request(gpio, gpio_label);
- if (ret)
- return ret;
- pr_debug("%s: Enable %s gpio %u\n",
- __func__, gpio_label, gpio);
- gpio_direction_output(gpio, enable);
- return ret;
- }
- static void msm8960_ext_spk_power_amp_on(u32 spk)
- {
- int ret = 0;
- if (spk & (SPK_AMP_POS | SPK_AMP_NEG)) {
- if ((msm8930_ext_spk_pamp & SPK_AMP_POS) &&
- (msm8930_ext_spk_pamp & SPK_AMP_NEG)) {
- pr_debug("%s() External Bottom Speaker Ampl already "
- "turned on. spk = 0x%08x\n", __func__, spk);
- return;
- }
- msm8930_ext_spk_pamp |= spk;
- if ((msm8930_ext_spk_pamp & SPK_AMP_POS) &&
- (msm8930_ext_spk_pamp & SPK_AMP_NEG)) {
- if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) {
- ret = msm8930_cfg_spkr_gpio(
- LEFT_SPKR_AMPL_GPIO,
- 1, "LEFT_SPKR_AMPL");
- if (ret) {
- pr_err("%s: Failed to config ampl gpio %u\n",
- __func__, LEFT_SPKR_AMPL_GPIO);
- return;
- }
- } else {
- /*
- * 8930 CDP does not have a 5V speaker boost,
- * hence the GPIO enable for speaker boost is
- * only required for platforms other than CDP
- */
- if (!machine_is_msm8930_cdp()) {
- ret = msm8930_cfg_spkr_gpio(
- SPKR_BOOST_GPIO, 1, "SPKR_BOOST");
- if (ret) {
- pr_err("%s: Failure: spkr boost gpio %u\n",
- __func__, SPKR_BOOST_GPIO);
- return;
- }
- }
- pm8xxx_spk_enable(MSM8930_SPK_ON);
- }
- pr_debug("%s: sleeping 10 ms after turning on external "
- " Left Speaker Ampl\n", __func__);
- usleep_range(10000, 10000);
- }
- } else {
- pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n",
- __func__, spk);
- return;
- }
- }
- static void msm8960_ext_spk_power_amp_off(u32 spk)
- {
- if (spk & (SPK_AMP_POS | SPK_AMP_NEG)) {
- if (!msm8930_ext_spk_pamp)
- return;
- if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) {
- gpio_free(LEFT_SPKR_AMPL_GPIO);
- msm8930_ext_spk_pamp = 0;
- return;
- }
- if (!machine_is_msm8930_cdp()) {
- pr_debug("%s: Free speaker boost gpio %u\n",
- __func__, SPKR_BOOST_GPIO);
- gpio_direction_output(SPKR_BOOST_GPIO, 0);
- gpio_free(SPKR_BOOST_GPIO);
- }
- pm8xxx_spk_enable(MSM8930_SPK_OFF);
- msm8930_ext_spk_pamp = 0;
- pr_debug("%s: slepping 10 ms after turning on external "
- " Left Speaker Ampl\n", __func__);
- usleep_range(10000, 10000);
- } else {
- pr_err("%s: ERROR : Invalid External Speaker Ampl. spk = 0x%08x\n",
- __func__, spk);
- return;
- }
- }
- static int msm8930_spkramp_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *k, int event)
- {
- pr_debug("%s() %x\n", __func__, SND_SOC_DAPM_EVENT_ON(event));
- if (SND_SOC_DAPM_EVENT_ON(event)) {
- if (!strncmp(w->name, "Ext Spk Left Pos", 17))
- msm8960_ext_spk_power_amp_on(SPK_AMP_POS);
- else if (!strncmp(w->name, "Ext Spk Left Neg", 17))
- msm8960_ext_spk_power_amp_on(SPK_AMP_NEG);
- else {
- pr_err("%s() Invalid Speaker Widget = %s\n",
- __func__, w->name);
- return -EINVAL;
- }
- } else {
- if (!strncmp(w->name, "Ext Spk Left Pos", 17))
- msm8960_ext_spk_power_amp_off(SPK_AMP_POS);
- else if (!strncmp(w->name, "Ext Spk Left Neg", 17))
- msm8960_ext_spk_power_amp_off(SPK_AMP_NEG);
- else {
- pr_err("%s() Invalid Speaker Widget = %s\n",
- __func__, w->name);
- return -EINVAL;
- }
- }
- return 0;
- }
- static int msm8930_enable_codec_ext_clk(
- struct snd_soc_codec *codec, int enable,
- bool dapm)
- {
- int r = 0;
- pr_debug("%s: enable = %d\n", __func__, enable);
- mutex_lock(&cdc_mclk_mutex);
- if (enable) {
- clk_users++;
- pr_debug("%s: clk_users = %d\n", __func__, clk_users);
- if (clk_users == 1) {
- if (codec_clk) {
- clk_set_rate(codec_clk, SITAR_EXT_CLK_RATE);
- clk_prepare_enable(codec_clk);
- sitar_mclk_enable(codec, 1, dapm);
- } else {
- pr_err("%s: Error setting Sitar MCLK\n",
- __func__);
- clk_users--;
- r = -EINVAL;
- }
- }
- } else {
- if (clk_users > 0) {
- clk_users--;
- pr_debug("%s: clk_users = %d\n", __func__, clk_users);
- if (clk_users == 0) {
- pr_debug("%s: disabling MCLK. clk_users = %d\n",
- __func__, clk_users);
- sitar_mclk_enable(codec, 0, dapm);
- clk_disable_unprepare(codec_clk);
- }
- } else {
- pr_err("%s: Error releasing Sitar MCLK\n", __func__);
- r = -EINVAL;
- }
- }
- mutex_unlock(&cdc_mclk_mutex);
- return r;
- }
- static int msm8930_mclk_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- pr_debug("%s: event = %d\n", __func__, event);
- switch (event) {
- case SND_SOC_DAPM_PRE_PMU:
- return msm8930_enable_codec_ext_clk(w->codec, 1, true);
- case SND_SOC_DAPM_POST_PMD:
- return msm8930_enable_codec_ext_clk(w->codec, 0, true);
- }
- return 0;
- }
- static const struct snd_soc_dapm_widget msm8930_dapm_widgets[] = {
- SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
- msm8930_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SPK("Ext Spk Left Pos", msm8930_spkramp_event),
- SND_SOC_DAPM_SPK("Ext Spk Left Neg", msm8930_spkramp_event),
- SND_SOC_DAPM_MIC("Headset Mic", NULL),
- SND_SOC_DAPM_MIC("Digital Mic1", NULL),
- SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
- SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
- SND_SOC_DAPM_MIC("Digital Mic1", NULL),
- SND_SOC_DAPM_MIC("Digital Mic2", NULL),
- SND_SOC_DAPM_MIC("Digital Mic3", NULL),
- SND_SOC_DAPM_MIC("Digital Mic4", NULL),
- };
- static const struct snd_soc_dapm_route common_audio_map[] = {
- {"RX_BIAS", NULL, "MCLK"},
- {"LDO_H", NULL, "MCLK"},
- {"MIC BIAS1 Internal1", NULL, "MCLK"},
- {"MIC BIAS2 Internal1", NULL, "MCLK"},
- /* Speaker path */
- {"Ext Spk Left Pos", NULL, "LINEOUT1"},
- {"Ext Spk Left Neg", NULL, "LINEOUT2"},
- /* Headset Mic */
- {"AMIC2", NULL, "MIC BIAS2 External"},
- {"MIC BIAS2 External", NULL, "Headset Mic"},
- /* Microphone path */
- {"AMIC1", NULL, "MIC BIAS2 External"},
- {"MIC BIAS2 External", NULL, "ANCLeft Headset Mic"},
- {"AMIC3", NULL, "MIC BIAS2 External"},
- {"MIC BIAS2 External", NULL, "ANCRight Headset Mic"},
- {"HEADPHONE", NULL, "LDO_H"},
- /**
- * The digital Mic routes are setup considering
- * fluid as default device.
- */
- /**
- * Digital Mic1. Front Bottom left Mic on Fluid and MTP.
- * Digital Mic GM5 on CDP mainboard.
- * Conncted to DMIC1 Input on Sitar codec.
- */
- {"DMIC1", NULL, "MIC BIAS1 External"},
- {"MIC BIAS1 External", NULL, "Digital Mic1"},
- /**
- * Digital Mic2. Back top MIC on Fluid.
- * Digital Mic GM6 on CDP mainboard.
- * Conncted to DMIC2 Input on Sitar codec.
- */
- {"DMIC2", NULL, "MIC BIAS1 External"},
- {"MIC BIAS1 External", NULL, "Digital Mic2"},
- /**
- * Digital Mic3. Back Bottom Digital Mic on Fluid.
- * Digital Mic GM1 on CDP mainboard.
- * Conncted to DMIC4 Input on Sitar codec.
- */
- {"DMIC3", NULL, "MIC BIAS1 External"},
- {"MIC BIAS1 External", NULL, "Digital Mic3"},
- /**
- * Digital Mic4. Back top Digital Mic on Fluid.
- * Digital Mic GM2 on CDP mainboard.
- * Conncted to DMIC3 Input on Sitar codec.
- */
- {"DMIC4", NULL, "MIC BIAS1 External"},
- {"MIC BIAS1 External", NULL, "Digital Mic4"},
- };
- static const char *spk_function[] = {"Off", "On"};
- static const char *slim0_rx_ch_text[] = {"One", "Two"};
- static const char *slim0_tx_ch_text[] = {"One", "Two", "Three", "Four"};
- static const char * const hdmi_rate[] = {"Default", "Variable"};
- static const struct soc_enum msm8930_enum[] = {
- SOC_ENUM_SINGLE_EXT(2, spk_function),
- SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text),
- SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text),
- SOC_ENUM_SINGLE_EXT(2, hdmi_rate),
- };
- static const char *btsco_rate_text[] = {"8000", "16000"};
- static const struct soc_enum msm8930_btsco_enum[] = {
- SOC_ENUM_SINGLE_EXT(2, btsco_rate_text),
- };
- static int msm8930_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8930_slim_0_rx_ch = %d\n", __func__,
- msm8930_slim_0_rx_ch);
- ucontrol->value.integer.value[0] = msm8930_slim_0_rx_ch - 1;
- return 0;
- }
- static int msm8930_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- msm8930_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1;
- pr_debug("%s: msm8930_slim_0_rx_ch = %d\n", __func__,
- msm8930_slim_0_rx_ch);
- return 1;
- }
- static int msm8930_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8930_slim_0_tx_ch = %d\n", __func__,
- msm8930_slim_0_tx_ch);
- ucontrol->value.integer.value[0] = msm8930_slim_0_tx_ch - 1;
- return 0;
- }
- static int msm8930_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- msm8930_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1;
- pr_debug("%s: msm8930_slim_0_tx_ch = %d\n", __func__,
- msm8930_slim_0_tx_ch);
- return 1;
- }
- static int msm8930_btsco_rate_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8930_btsco_rate = %d", __func__, msm8930_btsco_rate);
- ucontrol->value.integer.value[0] = msm8930_btsco_rate;
- return 0;
- }
- static int msm8930_btsco_rate_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (ucontrol->value.integer.value[0]) {
- case 8000:
- msm8930_btsco_rate = BTSCO_RATE_8KHZ;
- break;
- case 16000:
- msm8930_btsco_rate = BTSCO_RATE_16KHZ;
- break;
- default:
- msm8930_btsco_rate = BTSCO_RATE_8KHZ;
- break;
- }
- pr_debug("%s: msm8930_btsco_rate = %d\n", __func__, msm8930_btsco_rate);
- return 0;
- }
- static const char *pmic_spk_gain_text[] = {
- "NEG_6_DB", "NEG_4_DB", "NEG_2_DB", "ZERO_DB", "POS_2_DB", "POS_4_DB",
- "POS_6_DB", "POS_8_DB", "POS_10_DB", "POS_12_DB", "POS_14_DB",
- "POS_16_DB", "POS_18_DB", "POS_20_DB", "POS_22_DB", "POS_24_DB"
- };
- static const struct soc_enum msm8960_pmic_spk_gain_enum[] = {
- SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(pmic_spk_gain_text),
- pmic_spk_gain_text),
- };
- static int msm8930_pmic_gain_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8930_pmic_spk_gain = %d\n", __func__,
- msm8930_pmic_spk_gain);
- ucontrol->value.integer.value[0] = msm8930_pmic_spk_gain;
- return 0;
- }
- static int msm8930_pmic_gain_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int ret = 0;
- msm8930_pmic_spk_gain = ucontrol->value.integer.value[0];
- if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917)
- ret = pm8xxx_spk_gain(msm8930_pmic_spk_gain);
- pr_debug("%s: msm8930_pmic_spk_gain = %d"
- " ucontrol->value.integer.value[0] = %d\n", __func__,
- msm8930_pmic_spk_gain,
- (int) ucontrol->value.integer.value[0]);
- return ret;
- }
- static int msm8930_hdmi_rate_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- hdmi_rate_variable = ucontrol->value.integer.value[0];
- pr_debug("%s: hdmi_rate_variable = %d\n", __func__, hdmi_rate_variable);
- return 0;
- }
- static int msm8930_hdmi_rate_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- ucontrol->value.integer.value[0] = hdmi_rate_variable;
- return 0;
- }
- static const struct snd_kcontrol_new sitar_msm8930_controls[] = {
- SOC_ENUM_EXT("Speaker Function", msm8930_enum[0], msm8930_get_spk,
- msm8930_set_spk),
- SOC_ENUM_EXT("SLIM_0_RX Channels", msm8930_enum[1],
- msm8930_slim_0_rx_ch_get, msm8930_slim_0_rx_ch_put),
- SOC_ENUM_EXT("SLIM_0_TX Channels", msm8930_enum[2],
- msm8930_slim_0_tx_ch_get, msm8930_slim_0_tx_ch_put),
- SOC_ENUM_EXT("PMIC SPK Gain", msm8960_pmic_spk_gain_enum[0],
- msm8930_pmic_gain_get, msm8930_pmic_gain_put),
- SOC_ENUM_EXT("Internal BTSCO SampleRate", msm8930_btsco_enum[0],
- msm8930_btsco_rate_get, msm8930_btsco_rate_put),
- SOC_ENUM_EXT("HDMI RX Rate", msm8930_enum[3],
- msm8930_hdmi_rate_get,
- msm8930_hdmi_rate_put),
- };
- static void *def_sitar_mbhc_cal(void)
- {
- void *sitar_cal;
- struct sitar_mbhc_btn_detect_cfg *btn_cfg;
- u16 *btn_low, *btn_high;
- u8 *n_ready, *n_cic, *gain;
- sitar_cal = kzalloc(SITAR_MBHC_CAL_SIZE(SITAR_MBHC_DEF_BUTTONS,
- SITAR_MBHC_DEF_RLOADS),
- GFP_KERNEL);
- if (!sitar_cal) {
- pr_err("%s: out of memory\n", __func__);
- return NULL;
- }
- #define S(X, Y) ((SITAR_MBHC_CAL_GENERAL_PTR(sitar_cal)->X) = (Y))
- S(t_ldoh, 100);
- S(t_bg_fast_settle, 100);
- S(t_shutdown_plug_rem, 255);
- S(mbhc_nsa, 4);
- S(mbhc_navg, 4);
- #undef S
- #define S(X, Y) ((SITAR_MBHC_CAL_PLUG_DET_PTR(sitar_cal)->X) = (Y))
- S(mic_current, SITAR_PID_MIC_5_UA);
- S(hph_current, SITAR_PID_MIC_5_UA);
- S(t_mic_pid, 100);
- S(t_ins_complete, 250);
- S(t_ins_retry, 200);
- #undef S
- #define S(X, Y) ((SITAR_MBHC_CAL_PLUG_TYPE_PTR(sitar_cal)->X) = (Y))
- S(v_no_mic, 30);
- S(v_hs_max, 1650);
- #undef S
- #define S(X, Y) ((SITAR_MBHC_CAL_BTN_DET_PTR(sitar_cal)->X) = (Y))
- S(c[0], 62);
- S(c[1], 124);
- S(nc, 1);
- S(n_meas, 3);
- S(mbhc_nsc, 11);
- S(n_btn_meas, 1);
- S(n_btn_con, 2);
- S(num_btn, SITAR_MBHC_DEF_BUTTONS);
- S(v_btn_press_delta_sta, 100);
- S(v_btn_press_delta_cic, 50);
- #undef S
- btn_cfg = SITAR_MBHC_CAL_BTN_DET_PTR(sitar_cal);
- btn_low = sitar_mbhc_cal_btn_det_mp(btn_cfg, SITAR_BTN_DET_V_BTN_LOW);
- btn_high = sitar_mbhc_cal_btn_det_mp(btn_cfg, SITAR_BTN_DET_V_BTN_HIGH);
- btn_low[0] = -50;
- btn_high[0] = 10;
- btn_low[1] = 11;
- btn_high[1] = 38;
- btn_low[2] = 39;
- btn_high[2] = 64;
- btn_low[3] = 65;
- btn_high[3] = 91;
- btn_low[4] = 92;
- btn_high[4] = 115;
- btn_low[5] = 116;
- btn_high[5] = 141;
- btn_low[6] = 142;
- btn_high[6] = 163;
- btn_low[7] = 164;
- btn_high[7] = 250;
- n_ready = sitar_mbhc_cal_btn_det_mp(btn_cfg, SITAR_BTN_DET_N_READY);
- n_ready[0] = 48;
- n_ready[1] = 38;
- n_cic = sitar_mbhc_cal_btn_det_mp(btn_cfg, SITAR_BTN_DET_N_CIC);
- n_cic[0] = 60;
- n_cic[1] = 47;
- gain = sitar_mbhc_cal_btn_det_mp(btn_cfg, SITAR_BTN_DET_GAIN);
- gain[0] = 11;
- gain[1] = 9;
- return sitar_cal;
- }
- static int msm8930_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
- {
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- int ret = 0;
- unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
- unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
- pr_debug("%s: ch=%d\n", __func__,
- msm8930_slim_0_rx_ch);
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- ret = snd_soc_dai_get_channel_map(codec_dai,
- &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to get codec chan map\n", __func__);
- goto end;
- }
- ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
- msm8930_slim_0_rx_ch, rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to set cpu chan map\n", __func__);
- goto end;
- }
- } else {
- ret = snd_soc_dai_get_channel_map(codec_dai,
- &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to get codec chan map\n", __func__);
- goto end;
- }
- ret = snd_soc_dai_set_channel_map(cpu_dai,
- msm8930_slim_0_tx_ch, tx_ch, 0 , 0);
- if (ret < 0) {
- pr_err("%s: failed to set cpu chan map\n", __func__);
- goto end;
- }
- }
- end:
- return ret;
- }
- static int msm8930_audrx_init(struct snd_soc_pcm_runtime *rtd)
- {
- int err;
- struct snd_soc_codec *codec = rtd->codec;
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
- /* Tabla SLIMBUS configuration
- * RX1, RX2, RX3, RX4, RX5
- * TX1, TX2, TX3, TX4, TX5
- */
- unsigned int rx_ch[SITAR_RX_MAX] = {138, 139, 140, 141, 142};
- unsigned int tx_ch[SITAR_TX_MAX] = {128, 129, 130, 131, 132};
- pr_debug("%s()\n", __func__);
- snd_soc_dapm_new_controls(dapm, msm8930_dapm_widgets,
- ARRAY_SIZE(msm8930_dapm_widgets));
- snd_soc_dapm_add_routes(dapm, common_audio_map,
- ARRAY_SIZE(common_audio_map));
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Left Pos");
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Left Neg");
- snd_soc_dapm_sync(dapm);
- err = snd_soc_jack_new(codec, "Headset Jack",
- (SND_JACK_HEADSET | SND_JACK_OC_HPHL | SND_JACK_OC_HPHR),
- &hs_jack);
- if (err) {
- pr_err("failed to create new jack\n");
- return err;
- }
- err = snd_soc_jack_new(codec, "Button Jack",
- SITAR_JACK_BUTTON_MASK, &button_jack);
- if (err) {
- pr_err("failed to create new jack\n");
- return err;
- }
- codec_clk = clk_get(cpu_dai->dev, "osr_clk");
- snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
- tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
- mbhc_cfg.gpio = 37;
- mbhc_cfg.gpio_irq = gpio_to_irq(mbhc_cfg.gpio);
- sitar_hs_detect(codec, &mbhc_cfg);
- if (socinfo_get_pmic_model() != PMIC_MODEL_PM8917) {
- /* Initialize default PMIC speaker gain */
- pm8xxx_spk_gain(DEFAULT_PMIC_SPK_GAIN);
- }
- return 0;
- }
- static int msm8930_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_CHANNELS);
- pr_debug("%s()\n", __func__);
- rate->min = rate->max = 48000;
- channels->min = channels->max = msm8930_slim_0_rx_ch;
- return 0;
- }
- static int msm8930_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_CHANNELS);
- pr_debug("%s()\n", __func__);
- rate->min = rate->max = 48000;
- channels->min = channels->max = msm8930_slim_0_tx_ch;
- return 0;
- }
- static int msm8930_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- pr_debug("%s()\n", __func__);
- rate->min = rate->max = 48000;
- return 0;
- }
- static int msm8930_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_CHANNELS);
- if (!hdmi_rate_variable)
- rate->min = rate->max = 48000;
- channels->min = channels->max = 2;
- return 0;
- }
- static int msm8930_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_CHANNELS);
- rate->min = rate->max = msm8930_btsco_rate;
- channels->min = channels->max = msm8930_btsco_ch;
- return 0;
- }
- static int msm8930_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_CHANNELS);
- /* PCM only supports mono output with 8khz sample rate */
- rate->min = rate->max = 8000;
- channels->min = channels->max = 1;
- return 0;
- }
- static int msm8930_proxy_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- pr_debug("%s()\n", __func__);
- rate->min = rate->max = 48000;
- return 0;
- }
- static int msm8930_aux_pcm_get_gpios(void)
- {
- int ret = 0;
- pr_debug("%s\n", __func__);
- ret = gpio_request(GPIO_AUX_PCM_DOUT, "AUX PCM DOUT");
- if (ret < 0) {
- pr_err("%s: Failed to request gpio(%d): AUX PCM DOUT",
- __func__, GPIO_AUX_PCM_DOUT);
- goto fail_dout;
- }
- ret = gpio_request(GPIO_AUX_PCM_DIN, "AUX PCM DIN");
- if (ret < 0) {
- pr_err("%s: Failed to request gpio(%d): AUX PCM DIN",
- __func__, GPIO_AUX_PCM_DIN);
- goto fail_din;
- }
- ret = gpio_request(GPIO_AUX_PCM_SYNC, "AUX PCM SYNC");
- if (ret < 0) {
- pr_err("%s: Failed to request gpio(%d): AUX PCM SYNC",
- __func__, GPIO_AUX_PCM_SYNC);
- goto fail_sync;
- }
- ret = gpio_request(GPIO_AUX_PCM_CLK, "AUX PCM CLK");
- if (ret < 0) {
- pr_err("%s: Failed to request gpio(%d): AUX PCM CLK",
- __func__, GPIO_AUX_PCM_CLK);
- goto fail_clk;
- }
- return 0;
- fail_clk:
- gpio_free(GPIO_AUX_PCM_SYNC);
- fail_sync:
- gpio_free(GPIO_AUX_PCM_DIN);
- fail_din:
- gpio_free(GPIO_AUX_PCM_DOUT);
- fail_dout:
- return ret;
- }
- static int msm8930_aux_pcm_free_gpios(void)
- {
- gpio_free(GPIO_AUX_PCM_DIN);
- gpio_free(GPIO_AUX_PCM_DOUT);
- gpio_free(GPIO_AUX_PCM_SYNC);
- gpio_free(GPIO_AUX_PCM_CLK);
- return 0;
- }
- static int msm8930_startup(struct snd_pcm_substream *substream)
- {
- pr_debug("%s(): substream = %s stream = %d\n", __func__,
- substream->name, substream->stream);
- return 0;
- }
- static int msm8930_auxpcm_startup(struct snd_pcm_substream *substream)
- {
- int ret = 0;
- pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n",
- __func__, substream->name, atomic_read(&auxpcm_rsc_ref));
- if (atomic_inc_return(&auxpcm_rsc_ref) == 1)
- ret = msm8930_aux_pcm_get_gpios();
- if (ret < 0) {
- pr_err("%s: Aux PCM GPIO request failed\n", __func__);
- return -EINVAL;
- }
- return 0;
- }
- static void msm8930_auxpcm_shutdown(struct snd_pcm_substream *substream)
- {
- pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n",
- __func__, substream->name, atomic_read(&auxpcm_rsc_ref));
- if (atomic_dec_return(&auxpcm_rsc_ref) == 0)
- msm8930_aux_pcm_free_gpios();
- }
- static void msm8930_shutdown(struct snd_pcm_substream *substream)
- {
- pr_debug("%s(): substream = %s stream = %d\n", __func__,
- substream->name, substream->stream);
- }
- static struct snd_soc_ops msm8930_be_ops = {
- .startup = msm8930_startup,
- .hw_params = msm8930_hw_params,
- .shutdown = msm8930_shutdown,
- };
- static struct snd_soc_ops msm8930_auxpcm_be_ops = {
- .startup = msm8930_auxpcm_startup,
- .shutdown = msm8930_auxpcm_shutdown,
- };
- /* Digital audio interface glue - connects codec <---> CPU */
- static struct snd_soc_dai_link msm8930_dai[] = {
- /* FrontEnd DAI Links */
- {
- .name = "MSM8930 Media1",
- .stream_name = "MultiMedia1",
- .cpu_dai_name = "MultiMedia1",
- .platform_name = "msm-pcm-dsp",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1
- },
- {
- .name = "MSM8930 Media2",
- .stream_name = "MultiMedia2",
- .cpu_dai_name = "MultiMedia2",
- .platform_name = "msm-multi-ch-pcm-dsp",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2,
- },
- {
- .name = "Circuit-Switch Voice",
- .stream_name = "CS-Voice",
- .cpu_dai_name = "CS-VOICE",
- .platform_name = "msm-pcm-voice",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .be_id = MSM_FRONTEND_DAI_CS_VOICE,
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- },
- {
- .name = "MSM VoIP",
- .stream_name = "VoIP",
- .cpu_dai_name = "VoIP",
- .platform_name = "msm-voip-dsp",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- .be_id = MSM_FRONTEND_DAI_VOIP,
- },
- {
- .name = "MSM8930 LPA",
- .stream_name = "LPA",
- .cpu_dai_name = "MultiMedia3",
- .platform_name = "msm-pcm-lpa",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3,
- },
- /* Hostless PMC purpose */
- {
- .name = "SLIMBUS_0 Hostless",
- .stream_name = "SLIMBUS_0 Hostless",
- .cpu_dai_name = "SLIMBUS0_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- /* .be_id = do not care */
- },
- {
- .name = "INT_FM Hostless",
- .stream_name = "INT_FM Hostless",
- .cpu_dai_name = "INT_FM_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- /* .be_id = do not care */
- },
- {
- .name = "MSM AFE-PCM RX",
- .stream_name = "AFE-PROXY RX",
- .cpu_dai_name = "msm-dai-q6.241",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .platform_name = "msm-pcm-afe",
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- },
- {
- .name = "MSM AFE-PCM TX",
- .stream_name = "AFE-PROXY TX",
- .cpu_dai_name = "msm-dai-q6.240",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .platform_name = "msm-pcm-afe",
- .ignore_suspend = 1,
- },
- {
- .name = "MSM8930 Compr",
- .stream_name = "COMPR",
- .cpu_dai_name = "MultiMedia4",
- .platform_name = "msm-compr-dsp",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4,
- },
- {
- .name = "AUXPCM Hostless",
- .stream_name = "AUXPCM Hostless",
- .cpu_dai_name = "AUXPCM_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- /* HDMI Hostless */
- {
- .name = "HDMI_RX_HOSTLESS",
- .stream_name = "HDMI_RX_HOSTLESS",
- .cpu_dai_name = "HDMI_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- {
- .name = "VoLTE",
- .stream_name = "VoLTE",
- .cpu_dai_name = "VoLTE",
- .platform_name = "msm-pcm-voice",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_VOLTE,
- },
- {
- .name = "Voice2",
- .stream_name = "Voice2",
- .cpu_dai_name = "Voice2",
- .platform_name = "msm-pcm-voice",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_VOICE2,
- },
- {
- .name = "MSM8960 LowLatency",
- .stream_name = "MultiMedia5",
- .cpu_dai_name = "MultiMedia5",
- .platform_name = "msm-lowlatency-pcm-dsp",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA5,
- },
- {
- .name = "MSM8960 FM",
- .stream_name = "MultiMedia6",
- .cpu_dai_name = "MultiMedia6",
- .platform_name = "msm-pcm-loopback",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6,
- },
- /* Backend DAI Links */
- {
- .name = LPASS_BE_SLIMBUS_0_RX,
- .stream_name = "Slimbus Playback",
- .cpu_dai_name = "msm-dai-q6.16384",
- .platform_name = "msm-pcm-routing",
- .codec_name = "sitar_codec",
- .codec_dai_name = "sitar_rx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
- .init = &msm8930_audrx_init,
- .be_hw_params_fixup = msm8930_slim_0_rx_be_hw_params_fixup,
- .ops = &msm8930_be_ops,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- },
- {
- .name = LPASS_BE_SLIMBUS_0_TX,
- .stream_name = "Slimbus Capture",
- .cpu_dai_name = "msm-dai-q6.16385",
- .platform_name = "msm-pcm-routing",
- .codec_name = "sitar_codec",
- .codec_dai_name = "sitar_tx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
- .be_hw_params_fixup = msm8930_slim_0_tx_be_hw_params_fixup,
- .ops = &msm8930_be_ops,
- },
- /* Backend BT/FM DAI Links */
- {
- .name = LPASS_BE_INT_BT_SCO_RX,
- .stream_name = "Internal BT-SCO Playback",
- .cpu_dai_name = "msm-dai-q6.12288",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INT_BT_SCO_RX,
- .be_hw_params_fixup = msm8930_btsco_be_hw_params_fixup,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- },
- {
- .name = LPASS_BE_INT_BT_SCO_TX,
- .stream_name = "Internal BT-SCO Capture",
- .cpu_dai_name = "msm-dai-q6.12289",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INT_BT_SCO_TX,
- .be_hw_params_fixup = msm8930_btsco_be_hw_params_fixup,
- },
- {
- .name = LPASS_BE_INT_FM_RX,
- .stream_name = "Internal FM Playback",
- .cpu_dai_name = "msm-dai-q6.12292",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INT_FM_RX,
- .be_hw_params_fixup = msm8930_be_hw_params_fixup,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- },
- {
- .name = LPASS_BE_INT_FM_TX,
- .stream_name = "Internal FM Capture",
- .cpu_dai_name = "msm-dai-q6.12293",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INT_FM_TX,
- .be_hw_params_fixup = msm8930_be_hw_params_fixup,
- },
- /* HDMI BACK END DAI Link */
- {
- .name = LPASS_BE_HDMI,
- .stream_name = "HDMI Playback",
- .cpu_dai_name = "msm-dai-q6-hdmi.8",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_HDMI_RX,
- .be_hw_params_fixup = msm8930_hdmi_be_hw_params_fixup,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- },
- /* Backend AFE DAI Links */
- {
- .name = LPASS_BE_AFE_PCM_RX,
- .stream_name = "AFE Playback",
- .cpu_dai_name = "msm-dai-q6.224",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_AFE_PCM_RX,
- .be_hw_params_fixup = msm8930_proxy_be_hw_params_fixup,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- },
- {
- .name = LPASS_BE_AFE_PCM_TX,
- .stream_name = "AFE Capture",
- .cpu_dai_name = "msm-dai-q6.225",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_AFE_PCM_TX,
- .be_hw_params_fixup = msm8930_proxy_be_hw_params_fixup,
- },
- /* AUX PCM Backend DAI Links */
- {
- .name = LPASS_BE_AUXPCM_RX,
- .stream_name = "AUX PCM Playback",
- .cpu_dai_name = "msm-dai-q6.2",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_AUXPCM_RX,
- .be_hw_params_fixup = msm8930_auxpcm_be_params_fixup,
- .ops = &msm8930_auxpcm_be_ops,
- },
- {
- .name = LPASS_BE_AUXPCM_TX,
- .stream_name = "AUX PCM Capture",
- .cpu_dai_name = "msm-dai-q6.3",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_AUXPCM_TX,
- .be_hw_params_fixup = msm8930_auxpcm_be_params_fixup,
- .ops = &msm8930_auxpcm_be_ops,
- },
- /* Incall Music BACK END DAI Link */
- {
- .name = LPASS_BE_VOICE_PLAYBACK_TX,
- .stream_name = "Voice Farend Playback",
- .cpu_dai_name = "msm-dai-q6.32773",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
- .be_hw_params_fixup = msm8930_be_hw_params_fixup,
- },
- /* Incall Record Uplink BACK END DAI Link */
- {
- .name = LPASS_BE_INCALL_RECORD_TX,
- .stream_name = "Voice Uplink Capture",
- .cpu_dai_name = "msm-dai-q6.32772",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
- .be_hw_params_fixup = msm8930_be_hw_params_fixup,
- },
- /* Incall Record Downlink BACK END DAI Link */
- {
- .name = LPASS_BE_INCALL_RECORD_RX,
- .stream_name = "Voice Downlink Capture",
- .cpu_dai_name = "msm-dai-q6.32771",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
- .be_hw_params_fixup = msm8930_be_hw_params_fixup,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- },
- };
- struct snd_soc_card snd_soc_card_msm8930 = {
- .name = "msm8930-sitar-snd-card",
- .dai_link = msm8930_dai,
- .num_links = ARRAY_SIZE(msm8930_dai),
- .controls = sitar_msm8930_controls,
- .num_controls = ARRAY_SIZE(sitar_msm8930_controls),
- };
- static struct platform_device *msm8930_snd_device;
- static int msm8930_configure_headset_mic_gpios(void)
- {
- int ret;
- ret = gpio_request(80, "US_EURO_SWITCH");
- if (ret) {
- pr_err("%s: Failed to request gpio 80\n", __func__);
- return ret;
- }
- ret = gpio_direction_output(80, 0);
- if (ret) {
- pr_err("%s: Unable to set direction\n", __func__);
- gpio_free(80);
- }
- msm8930_headset_gpios_configured = 0;
- return 0;
- }
- static void msm8930_free_headset_mic_gpios(void)
- {
- if (msm8930_headset_gpios_configured)
- gpio_free(80);
- }
- static int __init msm8930_audio_init(void)
- {
- int ret;
- if (!soc_class_is_msm8930()) {
- pr_err("%s: Not the right machine type\n", __func__);
- return -ENODEV ;
- }
- mbhc_cfg.calibration = def_sitar_mbhc_cal();
- if (!mbhc_cfg.calibration) {
- pr_err("Calibration data allocation failed\n");
- return -ENOMEM;
- }
- msm8930_snd_device = platform_device_alloc("soc-audio", 0);
- if (!msm8930_snd_device) {
- pr_err("Platform device allocation failed\n");
- kfree(mbhc_cfg.calibration);
- return -ENOMEM;
- }
- platform_set_drvdata(msm8930_snd_device, &snd_soc_card_msm8930);
- ret = platform_device_add(msm8930_snd_device);
- if (ret) {
- platform_device_put(msm8930_snd_device);
- kfree(mbhc_cfg.calibration);
- return ret;
- }
- if (msm8930_configure_headset_mic_gpios()) {
- pr_err("%s Fail to configure headset mic gpios\n", __func__);
- msm8930_headset_gpios_configured = 0;
- } else
- msm8930_headset_gpios_configured = 1;
- atomic_set(&auxpcm_rsc_ref, 0);
- mutex_init(&cdc_mclk_mutex);
- return ret;
- }
- module_init(msm8930_audio_init);
- static void __exit msm8930_audio_exit(void)
- {
- if (!soc_class_is_msm8930()) {
- pr_err("%s: Not the right machine type\n", __func__);
- return ;
- }
- msm8930_free_headset_mic_gpios();
- platform_device_unregister(msm8930_snd_device);
- kfree(mbhc_cfg.calibration);
- mutex_destroy(&cdc_mclk_mutex);
- }
- module_exit(msm8930_audio_exit);
- MODULE_DESCRIPTION("ALSA SoC MSM8930");
- MODULE_LICENSE("GPL v2");
|