123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863 |
- /* Copyright (c) 2011-2013, 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/pm8921.h>
- #include <linux/platform_device.h>
- #include <linux/mfd/pm8xxx/pm8921.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 <linux/mfd/wcd9xxx/core.h>
- #include "msm-pcm-routing.h"
- #include "../codecs/wcd9310.h"
- /* 8960 machine driver */
- #define PM8921_GPIO_BASE NR_GPIO_IRQS
- #define PM8921_IRQ_BASE (NR_MSM_IRQS + NR_GPIO_IRQS)
- #define PM8921_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio - 1 + PM8921_GPIO_BASE)
- #define MSM8960_SPK_ON 1
- #define MSM8960_SPK_OFF 0
- #define msm8960_SLIM_0_RX_MAX_CHANNELS 2
- #define msm8960_SLIM_0_TX_MAX_CHANNELS 4
- #define SAMPLE_RATE_8KHZ 8000
- #define SAMPLE_RATE_16KHZ 16000
- #define BOTTOM_SPK_AMP_POS 0x1
- #define BOTTOM_SPK_AMP_NEG 0x2
- #define TOP_SPK_AMP_POS 0x4
- #define TOP_SPK_AMP_NEG 0x8
- #define TOP_SPK_AMP 0x10
- #define GPIO_AUX_PCM_DOUT 63
- #define GPIO_AUX_PCM_DIN 64
- #define GPIO_AUX_PCM_SYNC 65
- #define GPIO_AUX_PCM_CLK 66
- #define TABLA_EXT_CLK_RATE 12288000
- #define TABLA_MBHC_DEF_BUTTONS 8
- #define TABLA_MBHC_DEF_RLOADS 5
- #define JACK_DETECT_GPIO 38
- #define JACK_DETECT_INT PM8921_GPIO_IRQ(PM8921_IRQ_BASE, JACK_DETECT_GPIO)
- #define JACK_US_EURO_SEL_GPIO 35
- static u32 top_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(18);
- static u32 bottom_spk_pamp_gpio = PM8921_GPIO_PM_TO_SYS(19);
- static int msm8960_spk_control;
- static int msm8960_ext_bottom_spk_pamp;
- static int msm8960_ext_top_spk_pamp;
- static int msm8960_slim_0_rx_ch = 1;
- static int msm8960_slim_0_tx_ch = 1;
- static int msm8960_btsco_rate = SAMPLE_RATE_8KHZ;
- static int msm8960_btsco_ch = 1;
- static int hdmi_rate_variable;
- static int msm8960_auxpcm_rate = SAMPLE_RATE_8KHZ;
- static struct clk *codec_clk;
- static int clk_users;
- static int msm8960_headset_gpios_configured;
- static struct snd_soc_jack hs_jack;
- static struct snd_soc_jack button_jack;
- static atomic_t auxpcm_rsc_ref;
- static bool hs_micbias_always_on;
- module_param(hs_micbias_always_on, bool, 0444);
- MODULE_PARM_DESC(hs_micbias_always_on, "Keep micbias always on if headset is inserted");
- static bool hs_detect_use_gpio;
- module_param(hs_detect_use_gpio, bool, 0444);
- MODULE_PARM_DESC(hs_detect_use_gpio, "Use GPIO for headset detection");
- static bool hs_detect_extn_cable;
- module_param(hs_detect_extn_cable, bool, 0444);
- MODULE_PARM_DESC(hs_detect_extn_cable, "Enable extension cable feature");
- static bool hs_detect_use_firmware;
- module_param(hs_detect_use_firmware, bool, 0444);
- MODULE_PARM_DESC(hs_detect_use_firmware, "Use firmware for headset detection");
- static int msm8960_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
- bool dapm);
- static bool msm8960_swap_gnd_mic(struct snd_soc_codec *codec);
- static struct tabla_mbhc_config mbhc_cfg = {
- .headset_jack = &hs_jack,
- .button_jack = &button_jack,
- .read_fw_bin = false,
- .calibration = NULL,
- .micbias = TABLA_MICBIAS2,
- .mclk_cb_fn = msm8960_enable_codec_ext_clk,
- .mclk_rate = TABLA_EXT_CLK_RATE,
- .gpio = 0,
- .gpio_irq = 0,
- .gpio_level_insert = 1,
- .swap_gnd_mic = NULL,
- .detect_extn_cable = false,
- .micbias_always_on = false
- };
- static u32 us_euro_sel_gpio = PM8921_GPIO_PM_TO_SYS(JACK_US_EURO_SEL_GPIO);
- static struct mutex cdc_mclk_mutex;
- static void msm8960_enable_ext_spk_amp_gpio(u32 spk_amp_gpio)
- {
- int ret = 0;
- struct pm_gpio param = {
- .direction = PM_GPIO_DIR_OUT,
- .output_buffer = PM_GPIO_OUT_BUF_CMOS,
- .output_value = 1,
- .pull = PM_GPIO_PULL_NO,
- .vin_sel = PM_GPIO_VIN_S4,
- .out_strength = PM_GPIO_STRENGTH_MED,
- .
- function = PM_GPIO_FUNC_NORMAL,
- };
- if (spk_amp_gpio == bottom_spk_pamp_gpio) {
- ret = gpio_request(bottom_spk_pamp_gpio, "BOTTOM_SPK_AMP");
- if (ret) {
- pr_err("%s: Error requesting BOTTOM SPK AMP GPIO %u\n",
- __func__, bottom_spk_pamp_gpio);
- return;
- }
- ret = pm8xxx_gpio_config(bottom_spk_pamp_gpio, ¶m);
- if (ret)
- pr_err("%s: Failed to configure Bottom Spk Ampl"
- " gpio %u\n", __func__, bottom_spk_pamp_gpio);
- else {
- pr_debug("%s: enable Bottom spkr amp gpio\n", __func__);
- gpio_direction_output(bottom_spk_pamp_gpio, 1);
- }
- } else if (spk_amp_gpio == top_spk_pamp_gpio) {
- ret = gpio_request(top_spk_pamp_gpio, "TOP_SPK_AMP");
- if (ret) {
- pr_err("%s: Error requesting GPIO %d\n", __func__,
- top_spk_pamp_gpio);
- return;
- }
- ret = pm8xxx_gpio_config(top_spk_pamp_gpio, ¶m);
- if (ret)
- pr_err("%s: Failed to configure Top Spk Ampl"
- " gpio %u\n", __func__, top_spk_pamp_gpio);
- else {
- pr_debug("%s: enable Top spkr amp gpio\n", __func__);
- gpio_direction_output(top_spk_pamp_gpio, 1);
- }
- } else {
- pr_err("%s: ERROR : Invalid External Speaker Ampl GPIO."
- " gpio = %u\n", __func__, spk_amp_gpio);
- return;
- }
- }
- static void msm8960_ext_spk_power_amp_on(u32 spk)
- {
- if (spk & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) {
- if ((msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) &&
- (msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) {
- pr_debug("%s() External Bottom Speaker Ampl already "
- "turned on. spk = 0x%08x\n", __func__, spk);
- return;
- }
- msm8960_ext_bottom_spk_pamp |= spk;
- if ((msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_POS) &&
- (msm8960_ext_bottom_spk_pamp & BOTTOM_SPK_AMP_NEG)) {
- msm8960_enable_ext_spk_amp_gpio(bottom_spk_pamp_gpio);
- pr_debug("%s: slepping 4 ms after turning on external "
- " Bottom Speaker Ampl\n", __func__);
- usleep_range(4000, 4000);
- }
- } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) {
- pr_debug("%s: top_spk_amp_state = 0x%x spk_event = 0x%x\n",
- __func__, msm8960_ext_top_spk_pamp, spk);
- if (((msm8960_ext_top_spk_pamp & TOP_SPK_AMP_POS) &&
- (msm8960_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) ||
- (msm8960_ext_top_spk_pamp & TOP_SPK_AMP)) {
- pr_debug("%s() External Top Speaker Ampl already"
- "turned on. spk = 0x%08x\n", __func__, spk);
- return;
- }
- msm8960_ext_top_spk_pamp |= spk;
- if (((msm8960_ext_top_spk_pamp & TOP_SPK_AMP_POS) &&
- (msm8960_ext_top_spk_pamp & TOP_SPK_AMP_NEG)) ||
- (msm8960_ext_top_spk_pamp & TOP_SPK_AMP)) {
- msm8960_enable_ext_spk_amp_gpio(top_spk_pamp_gpio);
- pr_debug("%s: sleeping 4 ms after turning on "
- " external Top Speaker Ampl\n", __func__);
- usleep_range(4000, 4000);
- }
- } 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 & (BOTTOM_SPK_AMP_POS | BOTTOM_SPK_AMP_NEG)) {
- if (!msm8960_ext_bottom_spk_pamp)
- return;
- gpio_direction_output(bottom_spk_pamp_gpio, 0);
- gpio_free(bottom_spk_pamp_gpio);
- msm8960_ext_bottom_spk_pamp = 0;
- pr_debug("%s: sleeping 4 ms after turning off external Bottom"
- " Speaker Ampl\n", __func__);
- usleep_range(4000, 4000);
- } else if (spk & (TOP_SPK_AMP_POS | TOP_SPK_AMP_NEG | TOP_SPK_AMP)) {
- pr_debug("%s: top_spk_amp_state = 0x%x spk_event = 0x%x\n",
- __func__, msm8960_ext_top_spk_pamp, spk);
- if (!msm8960_ext_top_spk_pamp)
- return;
- if ((spk & TOP_SPK_AMP_POS) || (spk & TOP_SPK_AMP_NEG)) {
- msm8960_ext_top_spk_pamp &= (~(TOP_SPK_AMP_POS |
- TOP_SPK_AMP_NEG));
- } else if (spk & TOP_SPK_AMP) {
- msm8960_ext_top_spk_pamp &= ~TOP_SPK_AMP;
- }
- if (msm8960_ext_top_spk_pamp)
- return;
- gpio_direction_output(top_spk_pamp_gpio, 0);
- gpio_free(top_spk_pamp_gpio);
- msm8960_ext_top_spk_pamp = 0;
- pr_debug("%s: sleeping 4 ms after ext Top Spek Ampl is off\n",
- __func__);
- usleep_range(4000, 4000);
- } else {
- pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n",
- __func__, spk);
- return;
- }
- }
- static void msm8960_ext_control(struct snd_soc_codec *codec)
- {
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- mutex_lock(&dapm->codec->mutex);
- pr_debug("%s: msm8960_spk_control = %d", __func__, msm8960_spk_control);
- if (msm8960_spk_control == MSM8960_SPK_ON) {
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos");
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg");
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos");
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg");
- } else {
- snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Pos");
- snd_soc_dapm_disable_pin(dapm, "Ext Spk Bottom Neg");
- snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Pos");
- snd_soc_dapm_disable_pin(dapm, "Ext Spk Top Neg");
- }
- snd_soc_dapm_sync(dapm);
- mutex_unlock(&dapm->codec->mutex);
- }
- static int msm8960_get_spk(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8960_spk_control = %d", __func__, msm8960_spk_control);
- ucontrol->value.integer.value[0] = msm8960_spk_control;
- return 0;
- }
- static int msm8960_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 (msm8960_spk_control == ucontrol->value.integer.value[0])
- return 0;
- msm8960_spk_control = ucontrol->value.integer.value[0];
- msm8960_ext_control(codec);
- return 1;
- }
- static int msm8960_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 Bottom Pos", 18))
- msm8960_ext_spk_power_amp_on(BOTTOM_SPK_AMP_POS);
- else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18))
- msm8960_ext_spk_power_amp_on(BOTTOM_SPK_AMP_NEG);
- else if (!strncmp(w->name, "Ext Spk Top Pos", 15))
- msm8960_ext_spk_power_amp_on(TOP_SPK_AMP_POS);
- else if (!strncmp(w->name, "Ext Spk Top Neg", 15))
- msm8960_ext_spk_power_amp_on(TOP_SPK_AMP_NEG);
- else if (!strncmp(w->name, "Ext Spk Top", 12))
- msm8960_ext_spk_power_amp_on(TOP_SPK_AMP);
- else {
- pr_err("%s() Invalid Speaker Widget = %s\n",
- __func__, w->name);
- return -EINVAL;
- }
- } else {
- if (!strncmp(w->name, "Ext Spk Bottom Pos", 18))
- msm8960_ext_spk_power_amp_off(BOTTOM_SPK_AMP_POS);
- else if (!strncmp(w->name, "Ext Spk Bottom Neg", 18))
- msm8960_ext_spk_power_amp_off(BOTTOM_SPK_AMP_NEG);
- else if (!strncmp(w->name, "Ext Spk Top Pos", 15))
- msm8960_ext_spk_power_amp_off(TOP_SPK_AMP_POS);
- else if (!strncmp(w->name, "Ext Spk Top Neg", 15))
- msm8960_ext_spk_power_amp_off(TOP_SPK_AMP_NEG);
- else if (!strncmp(w->name, "Ext Spk Top", 12))
- msm8960_ext_spk_power_amp_off(TOP_SPK_AMP);
- else {
- pr_err("%s() Invalid Speaker Widget = %s\n",
- __func__, w->name);
- return -EINVAL;
- }
- }
- return 0;
- }
- static int msm8960_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, TABLA_EXT_CLK_RATE);
- clk_prepare_enable(codec_clk);
- tabla_mclk_enable(codec, 1, dapm);
- } else {
- pr_err("%s: Error setting Tabla 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);
- tabla_mclk_enable(codec, 0, dapm);
- clk_disable_unprepare(codec_clk);
- }
- } else {
- pr_err("%s: Error releasing Tabla MCLK\n", __func__);
- r = -EINVAL;
- }
- }
- mutex_unlock(&cdc_mclk_mutex);
- return r;
- }
- static bool msm8960_swap_gnd_mic(struct snd_soc_codec *codec)
- {
- int value = gpio_get_value_cansleep(us_euro_sel_gpio);
- pr_debug("%s: US EURO select switch %d to %d\n", __func__, value,
- !value);
- gpio_set_value_cansleep(us_euro_sel_gpio, !value);
- return true;
- }
- static int msm8960_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 msm8960_enable_codec_ext_clk(w->codec, 1, true);
- case SND_SOC_DAPM_POST_PMD:
- return msm8960_enable_codec_ext_clk(w->codec, 0, true);
- }
- return 0;
- }
- static const struct snd_soc_dapm_widget msm8960_dapm_widgets[] = {
- SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
- msm8960_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SPK("Ext Spk Bottom Pos", msm8960_spkramp_event),
- SND_SOC_DAPM_SPK("Ext Spk Bottom Neg", msm8960_spkramp_event),
- SND_SOC_DAPM_SPK("Ext Spk Top Pos", msm8960_spkramp_event),
- SND_SOC_DAPM_SPK("Ext Spk Top Neg", msm8960_spkramp_event),
- SND_SOC_DAPM_SPK("Ext Spk Top", msm8960_spkramp_event),
- SND_SOC_DAPM_MIC("Handset Mic", NULL),
- 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),
- SND_SOC_DAPM_MIC("Digital Mic5", NULL),
- SND_SOC_DAPM_MIC("Digital Mic6", NULL),
- };
- static const struct snd_soc_dapm_route common_audio_map[] = {
- {"RX_BIAS", NULL, "MCLK"},
- {"LDO_H", NULL, "MCLK"},
- /* Speaker path */
- {"Ext Spk Bottom Pos", NULL, "LINEOUT1"},
- {"Ext Spk Bottom Neg", NULL, "LINEOUT3"},
- {"Ext Spk Top Pos", NULL, "LINEOUT2"},
- {"Ext Spk Top Neg", NULL, "LINEOUT4"},
- {"Ext Spk Top", NULL, "LINEOUT5"},
- /* Microphone path */
- {"AMIC1", NULL, "MIC BIAS1 Internal1"},
- {"MIC BIAS1 Internal1", NULL, "Handset Mic"},
- {"AMIC2", NULL, "MIC BIAS2 External"},
- {"MIC BIAS2 External", NULL, "Headset Mic"},
- /**
- * AMIC3 and AMIC4 inputs are connected to ANC microphones
- * These mics are biased differently on CDP and FLUID
- * routing entries below are based on bias arrangement
- * on FLUID.
- */
- {"AMIC3", NULL, "MIC BIAS3 Internal1"},
- {"MIC BIAS3 Internal1", NULL, "MIC BIAS2 External"},
- {"MIC BIAS2 External", NULL, "ANCRight Headset Mic"},
- {"AMIC4", NULL, "MIC BIAS1 Internal2"},
- {"MIC BIAS1 Internal2", NULL, "MIC BIAS2 External"},
- {"MIC BIAS2 External", NULL, "ANCLeft Headset Mic"},
- {"HEADPHONE", NULL, "LDO_H"},
- /**
- * The digital Mic routes are setup considering
- * fluid as default device.
- */
- /**
- * Digital Mic1. Front Bottom left Digital Mic on Fluid and MTP.
- * Digital Mic GM5 on CDP mainboard.
- * Conncted to DMIC2 Input on Tabla codec.
- */
- {"DMIC2", NULL, "MIC BIAS1 External"},
- {"MIC BIAS1 External", NULL, "Digital Mic1"},
- /**
- * Digital Mic2. Front Bottom right Digital Mic on Fluid and MTP.
- * Digital Mic GM6 on CDP mainboard.
- * Conncted to DMIC1 Input on Tabla codec.
- */
- {"DMIC1", 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 Tabla codec.
- */
- {"DMIC4", NULL, "MIC BIAS3 External"},
- {"MIC BIAS3 External", NULL, "Digital Mic3"},
- /**
- * Digital Mic4. Back top Digital Mic on Fluid.
- * Digital Mic GM2 on CDP mainboard.
- * Conncted to DMIC3 Input on Tabla codec.
- */
- {"DMIC3", NULL, "MIC BIAS3 External"},
- {"MIC BIAS3 External", NULL, "Digital Mic4"},
- /**
- * Digital Mic5. Front top Digital Mic on Fluid.
- * Digital Mic GM3 on CDP mainboard.
- * Conncted to DMIC5 Input on Tabla codec.
- */
- {"DMIC5", NULL, "MIC BIAS4 External"},
- {"MIC BIAS4 External", NULL, "Digital Mic5"},
- /* Tabla digital Mic6 - back bottom digital Mic on Liquid and
- * bottom mic on CDP. FLUID/MTP do not have dmic6 installed.
- */
- {"DMIC6", NULL, "MIC BIAS4 External"},
- {"MIC BIAS4 External", NULL, "Digital Mic6"},
- };
- 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 msm8960_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 msm8960_btsco_enum[] = {
- SOC_ENUM_SINGLE_EXT(2, btsco_rate_text),
- };
- static const char *auxpcm_rate_text[] = {"rate_8000", "rate_16000"};
- static const struct soc_enum msm8960_auxpcm_enum[] = {
- SOC_ENUM_SINGLE_EXT(2, auxpcm_rate_text),
- };
- static int msm8960_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8960_slim_0_rx_ch = %d\n", __func__,
- msm8960_slim_0_rx_ch);
- ucontrol->value.integer.value[0] = msm8960_slim_0_rx_ch - 1;
- return 0;
- }
- static int msm8960_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- msm8960_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1;
- pr_debug("%s: msm8960_slim_0_rx_ch = %d\n", __func__,
- msm8960_slim_0_rx_ch);
- return 1;
- }
- static int msm8960_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8960_slim_0_tx_ch = %d\n", __func__,
- msm8960_slim_0_tx_ch);
- ucontrol->value.integer.value[0] = msm8960_slim_0_tx_ch - 1;
- return 0;
- }
- static int msm8960_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- msm8960_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1;
- pr_debug("%s: msm8960_slim_0_tx_ch = %d\n", __func__,
- msm8960_slim_0_tx_ch);
- return 1;
- }
- static int msm8960_btsco_rate_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8960_btsco_rate = %d", __func__, msm8960_btsco_rate);
- ucontrol->value.integer.value[0] = msm8960_btsco_rate;
- return 0;
- }
- static int msm8960_btsco_rate_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (ucontrol->value.integer.value[0]) {
- case 8000:
- msm8960_btsco_rate = SAMPLE_RATE_8KHZ;
- break;
- case 16000:
- msm8960_btsco_rate = SAMPLE_RATE_16KHZ;
- break;
- default:
- msm8960_btsco_rate = SAMPLE_RATE_8KHZ;
- break;
- }
- pr_debug("%s: msm8960_btsco_rate = %d\n", __func__, msm8960_btsco_rate);
- return 0;
- }
- static int msm8960_auxpcm_rate_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8960_auxpcm_rate = %d", __func__,
- msm8960_auxpcm_rate);
- ucontrol->value.integer.value[0] = msm8960_auxpcm_rate;
- return 0;
- }
- static int msm8960_auxpcm_rate_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (ucontrol->value.integer.value[0]) {
- case 0:
- msm8960_auxpcm_rate = SAMPLE_RATE_8KHZ;
- break;
- case 1:
- msm8960_auxpcm_rate = SAMPLE_RATE_16KHZ;
- break;
- default:
- msm8960_auxpcm_rate = SAMPLE_RATE_8KHZ;
- break;
- }
- pr_debug("%s: msm8960_auxpcm_rate = %d"
- "ucontrol->value.integer.value[0] = %d\n", __func__,
- msm8960_auxpcm_rate,
- (int)ucontrol->value.integer.value[0]);
- return 0;
- }
- static int msm8960_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 msm8960_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 tabla_msm8960_controls[] = {
- SOC_ENUM_EXT("Speaker Function", msm8960_enum[0], msm8960_get_spk,
- msm8960_set_spk),
- SOC_ENUM_EXT("SLIM_0_RX Channels", msm8960_enum[1],
- msm8960_slim_0_rx_ch_get, msm8960_slim_0_rx_ch_put),
- SOC_ENUM_EXT("SLIM_0_TX Channels", msm8960_enum[2],
- msm8960_slim_0_tx_ch_get, msm8960_slim_0_tx_ch_put),
- SOC_ENUM_EXT("Internal BTSCO SampleRate", msm8960_btsco_enum[0],
- msm8960_btsco_rate_get, msm8960_btsco_rate_put),
- SOC_ENUM_EXT("AUX PCM SampleRate", msm8960_auxpcm_enum[0],
- msm8960_auxpcm_rate_get, msm8960_auxpcm_rate_put),
- SOC_ENUM_EXT("HDMI RX Rate", msm8960_enum[3],
- msm8960_hdmi_rate_get,
- msm8960_hdmi_rate_put),
- };
- static void *def_tabla_mbhc_cal(void)
- {
- void *tabla_cal;
- struct tabla_mbhc_btn_detect_cfg *btn_cfg;
- u16 *btn_low, *btn_high;
- u8 *n_ready, *n_cic, *gain;
- tabla_cal = kzalloc(TABLA_MBHC_CAL_SIZE(TABLA_MBHC_DEF_BUTTONS,
- TABLA_MBHC_DEF_RLOADS),
- GFP_KERNEL);
- if (!tabla_cal) {
- pr_err("%s: out of memory\n", __func__);
- return NULL;
- }
- #define S(X, Y) ((TABLA_MBHC_CAL_GENERAL_PTR(tabla_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) ((TABLA_MBHC_CAL_PLUG_DET_PTR(tabla_cal)->X) = (Y))
- S(mic_current, TABLA_PID_MIC_5_UA);
- S(hph_current, TABLA_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) ((TABLA_MBHC_CAL_PLUG_TYPE_PTR(tabla_cal)->X) = (Y))
- S(v_no_mic, 30);
- S(v_hs_max, 2400);
- #undef S
- #define S(X, Y) ((TABLA_MBHC_CAL_BTN_DET_PTR(tabla_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, TABLA_MBHC_DEF_BUTTONS);
- S(v_btn_press_delta_sta, 100);
- S(v_btn_press_delta_cic, 50);
- #undef S
- btn_cfg = TABLA_MBHC_CAL_BTN_DET_PTR(tabla_cal);
- btn_low = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_LOW);
- btn_high = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_V_BTN_HIGH);
- btn_low[0] = -50;
- btn_high[0] = 21;
- btn_low[1] = 22;
- btn_high[1] = 67;
- btn_low[2] = 68;
- btn_high[2] = 111;
- btn_low[3] = 112;
- btn_high[3] = 153;
- btn_low[4] = 154;
- btn_high[4] = 191;
- btn_low[5] = 192;
- btn_high[5] = 233;
- btn_low[6] = 234;
- btn_high[6] = 272;
- btn_low[7] = 273;
- btn_high[7] = 400;
- n_ready = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_READY);
- n_ready[0] = 80;
- n_ready[1] = 68;
- n_cic = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_N_CIC);
- n_cic[0] = 60;
- n_cic[1] = 47;
- gain = tabla_mbhc_cal_btn_det_mp(btn_cfg, TABLA_BTN_DET_GAIN);
- gain[0] = 11;
- gain[1] = 9;
- return tabla_cal;
- }
- static int msm8960_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;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- pr_debug("%s: rx_0_ch=%d\n", __func__, msm8960_slim_0_rx_ch);
- 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,
- msm8960_slim_0_rx_ch, rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to set cpu chan map\n", __func__);
- goto end;
- }
- } else {
- pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__,
- codec_dai->name, codec_dai->id, msm8960_slim_0_tx_ch);
- 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,
- msm8960_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 msm8960_slimbus_2_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;
- unsigned int num_tx_ch = 0;
- unsigned int num_rx_ch = 0;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- num_rx_ch = params_channels(params);
- pr_debug("%s: %s rx_dai_id = %d num_ch = %d\n", __func__,
- codec_dai->name, codec_dai->id, num_rx_ch);
- 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,
- num_rx_ch, rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to set cpu chan map\n", __func__);
- goto end;
- }
- } else {
- num_tx_ch = params_channels(params);
- pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__,
- codec_dai->name, codec_dai->id, num_tx_ch);
- 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,
- num_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 msm8960_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 pm_gpio jack_gpio_cfg = {
- .direction = PM_GPIO_DIR_IN,
- .pull = PM_GPIO_PULL_UP_1P5,
- .function = PM_GPIO_FUNC_NORMAL,
- .vin_sel = 2,
- .inv_int_pol = 0,
- };
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
- /* Tabla SLIMBUS configuration
- * RX1, RX2, RX3, RX4, RX5, RX6, RX7
- * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8
- */
- unsigned int rx_ch[TABLA_RX_MAX] = {138, 139, 140, 141, 142, 143, 144};
- unsigned int tx_ch[TABLA_TX_MAX] = {128, 129, 130, 131, 132, 133, 134,
- 135, 136, 137};
- pr_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev));
- if (machine_is_msm8960_liquid()) {
- top_spk_pamp_gpio = (PM8921_GPIO_PM_TO_SYS(19));
- bottom_spk_pamp_gpio = (PM8921_GPIO_PM_TO_SYS(18));
- }
- snd_soc_dapm_new_controls(dapm, msm8960_dapm_widgets,
- ARRAY_SIZE(msm8960_dapm_widgets));
- snd_soc_dapm_add_routes(dapm, common_audio_map,
- ARRAY_SIZE(common_audio_map));
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Pos");
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Bottom Neg");
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Pos");
- snd_soc_dapm_enable_pin(dapm, "Ext Spk Top Neg");
- snd_soc_dapm_sync(dapm);
- err = snd_soc_jack_new(codec, "Headset Jack",
- (SND_JACK_HEADSET | SND_JACK_LINEOUT |
- SND_JACK_OC_HPHL | SND_JACK_OC_HPHR |
- SND_JACK_UNSUPPORTED),
- &hs_jack);
- if (err) {
- pr_err("failed to create new jack\n");
- return err;
- }
- err = snd_soc_jack_new(codec, "Button Jack",
- TABLA_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");
- if (machine_is_msm8960_cdp())
- mbhc_cfg.swap_gnd_mic = msm8960_swap_gnd_mic;
- if (hs_micbias_always_on)
- mbhc_cfg.micbias_always_on = true;
- if (hs_detect_use_gpio) {
- mbhc_cfg.gpio = PM8921_GPIO_PM_TO_SYS(JACK_DETECT_GPIO);
- mbhc_cfg.gpio_irq = JACK_DETECT_INT;
- if (hs_detect_extn_cable)
- mbhc_cfg.detect_extn_cable = true;
- }
- if (mbhc_cfg.gpio) {
- err = pm8xxx_gpio_config(mbhc_cfg.gpio, &jack_gpio_cfg);
- if (err) {
- pr_err("%s: pm8xxx_gpio_config JACK_DETECT failed %d\n",
- __func__, err);
- return err;
- }
- }
- mbhc_cfg.read_fw_bin = hs_detect_use_firmware;
- err = tabla_hs_detect(codec, &mbhc_cfg);
- snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
- tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
- return err;
- }
- static int msm8960_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 = msm8960_slim_0_rx_ch;
- return 0;
- }
- static int msm8960_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 = msm8960_slim_0_tx_ch;
- return 0;
- }
- static int msm8960_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 msm8960_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);
- pr_debug("%s channels->min %u channels->max %u ()\n", __func__,
- channels->min, channels->max);
- if (channels->max < 2)
- channels->min = channels->max = 2;
- if (!hdmi_rate_variable)
- rate->min = rate->max = 48000;
- return 0;
- }
- static int msm8960_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 = msm8960_btsco_rate;
- channels->min = channels->max = msm8960_btsco_ch;
- return 0;
- }
- static int msm8960_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);
- rate->min = rate->max = msm8960_auxpcm_rate;
- /* PCM only supports mono output */
- channels->min = channels->max = 1;
- return 0;
- }
- static int msm8960_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 msm8960_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 msm8960_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 msm8960_startup(struct snd_pcm_substream *substream)
- {
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- pr_debug("%s(): dai_link_str_name = %s cpu_dai = %s codec_dai = %s\n",
- __func__, rtd->dai_link->stream_name,
- rtd->dai_link->cpu_dai_name, rtd->dai_link->codec_dai_name);
- return 0;
- }
- static int msm8960_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 = msm8960_aux_pcm_get_gpios();
- if (ret < 0) {
- pr_err("%s: Aux PCM GPIO request failed\n", __func__);
- return -EINVAL;
- }
- return 0;
- }
- static void msm8960_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)
- msm8960_aux_pcm_free_gpios();
- }
- static void msm8960_shutdown(struct snd_pcm_substream *substream)
- {
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- pr_debug("%s(): dai_link str_name = %s cpu_dai = %s codec_dai = %s\n",
- __func__, rtd->dai_link->stream_name,
- rtd->dai_link->cpu_dai_name, rtd->dai_link->codec_dai_name);
- }
- static struct snd_soc_ops msm8960_be_ops = {
- .startup = msm8960_startup,
- .hw_params = msm8960_hw_params,
- .shutdown = msm8960_shutdown,
- };
- static struct snd_soc_ops msm8960_auxpcm_be_ops = {
- .startup = msm8960_auxpcm_startup,
- .shutdown = msm8960_auxpcm_shutdown,
- };
- static struct snd_soc_ops msm8960_slimbus_2_be_ops = {
- .startup = msm8960_startup,
- .hw_params = msm8960_slimbus_2_hw_params,
- .shutdown = msm8960_shutdown,
- };
- /* Digital audio interface glue - connects codec <---> CPU */
- static struct snd_soc_dai_link msm8960_dai_common[] = {
- /* FrontEnd DAI Links */
- {
- .name = "MSM8960 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 = "MSM8960 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},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- .be_id = MSM_FRONTEND_DAI_CS_VOICE,
- },
- {
- .name = "MSM VoIP",
- .stream_name = "VoIP",
- .cpu_dai_name = "VoIP",
- .platform_name = "msm-voip-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_VOIP,
- },
- {
- .name = "MSM8960 LPA",
- .stream_name = "LPA",
- .cpu_dai_name = "MultiMedia3",
- .platform_name = "msm-pcm-lpa",
- .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_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,
- .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 = "INT_FM Hostless",
- .stream_name = "INT_FM Hostless",
- .cpu_dai_name = "INT_FM_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 = "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 = "MSM8960 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,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- .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,
- .ignore_pmdown_time = 1,/* this dainlink has playback support */
- .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 Media6",
- .stream_name = "MultiMedia6",
- .cpu_dai_name = "MultiMedia6",
- .platform_name = "msm-multi-ch-pcm-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 dailink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6
- },
- {
- .name = "MSM8960 Compr2",
- .stream_name = "COMPR2",
- .cpu_dai_name = "MultiMedia7",
- .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 dailink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA7,
- },
- {
- .name = "MSM8960 Compr3",
- .stream_name = "COMPR3",
- .cpu_dai_name = "MultiMedia8",
- .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 dailink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA8,
- },
- /* 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 = msm8960_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 = msm8960_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 = msm8960_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 = msm8960_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 = msm8960_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 = msm8960_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 = msm8960_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 = msm8960_auxpcm_be_params_fixup,
- .ops = &msm8960_auxpcm_be_ops,
- .ignore_pmdown_time = 1,
- },
- {
- .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 = msm8960_auxpcm_be_params_fixup,
- .ops = &msm8960_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 = msm8960_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 = msm8960_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 = msm8960_be_hw_params_fixup,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- },
- };
- static struct snd_soc_dai_link msm8960_dai_delta_tabla1x[] = {
- /* 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 = "tabla1x_codec",
- .codec_dai_name = "tabla_rx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
- .init = &msm8960_audrx_init,
- .be_hw_params_fixup = msm8960_slim_0_rx_be_hw_params_fixup,
- .ops = &msm8960_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 = "tabla1x_codec",
- .codec_dai_name = "tabla_tx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
- .be_hw_params_fixup = msm8960_slim_0_tx_be_hw_params_fixup,
- .ops = &msm8960_be_ops,
- },
- /* Ultrasound TX Back End DAI Link */
- {
- .name = "SLIMBUS_2 Hostless Capture",
- .stream_name = "SLIMBUS_2 Hostless Capture",
- .cpu_dai_name = "msm-dai-q6.16389",
- .platform_name = "msm-pcm-hostless",
- .codec_name = "tabla1x_codec",
- .codec_dai_name = "tabla_tx2",
- .ignore_suspend = 1,
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ops = &msm8960_slimbus_2_be_ops,
- },
- /* Ultrasound RX Back End DAI Link */
- {
- .name = "SLIMBUS_2 Hostless Playback",
- .stream_name = "SLIMBUS_2 Hostless Playback",
- .cpu_dai_name = "msm-dai-q6.16388",
- .platform_name = "msm-pcm-hostless",
- .codec_name = "tabla1x_codec",
- .codec_dai_name = "tabla_rx3",
- .ignore_suspend = 1,
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ops = &msm8960_slimbus_2_be_ops,
- },
- };
- static struct snd_soc_dai_link msm8960_dai_delta_tabla2x[] = {
- /* 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 = "tabla_codec",
- .codec_dai_name = "tabla_rx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
- .init = &msm8960_audrx_init,
- .be_hw_params_fixup = msm8960_slim_0_rx_be_hw_params_fixup,
- .ops = &msm8960_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 = "tabla_codec",
- .codec_dai_name = "tabla_tx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
- .be_hw_params_fixup = msm8960_slim_0_tx_be_hw_params_fixup,
- .ops = &msm8960_be_ops,
- },
- /* Ultrasound TX Back End DAI Link */
- {
- .name = "SLIMBUS_2 Hostless Capture",
- .stream_name = "SLIMBUS_2 Hostless Capture",
- .cpu_dai_name = "msm-dai-q6.16389",
- .platform_name = "msm-pcm-hostless",
- .codec_name = "tabla_codec",
- .codec_dai_name = "tabla_tx2",
- .ignore_suspend = 1,
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ops = &msm8960_slimbus_2_be_ops,
- },
- /* Ultrasound RX Back End DAI Link */
- {
- .name = "SLIMBUS_2 Hostless Playback",
- .stream_name = "SLIMBUS_2 Hostless Playback",
- .cpu_dai_name = "msm-dai-q6.16388",
- .platform_name = "msm-pcm-hostless",
- .codec_name = "tabla_codec",
- .codec_dai_name = "tabla_rx3",
- .ignore_suspend = 1,
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ops = &msm8960_slimbus_2_be_ops,
- },
- };
- static struct snd_soc_dai_link msm8960_tabla1x_dai[
- ARRAY_SIZE(msm8960_dai_common) +
- ARRAY_SIZE(msm8960_dai_delta_tabla1x)];
- static struct snd_soc_dai_link msm8960_dai[
- ARRAY_SIZE(msm8960_dai_common) +
- ARRAY_SIZE(msm8960_dai_delta_tabla2x)];
- static struct snd_soc_card snd_soc_tabla1x_card_msm8960 = {
- .name = "msm8960-tabla1x-snd-card",
- .dai_link = msm8960_tabla1x_dai,
- .num_links = ARRAY_SIZE(msm8960_tabla1x_dai),
- .controls = tabla_msm8960_controls,
- .num_controls = ARRAY_SIZE(tabla_msm8960_controls),
- };
- static struct snd_soc_card snd_soc_card_msm8960 = {
- .name = "msm8960-snd-card",
- .dai_link = msm8960_dai,
- .num_links = ARRAY_SIZE(msm8960_dai),
- .controls = tabla_msm8960_controls,
- .num_controls = ARRAY_SIZE(tabla_msm8960_controls),
- };
- static struct platform_device *msm8960_snd_device;
- static struct platform_device *msm8960_snd_tabla1x_device;
- static int msm8960_configure_headset_mic_gpios(void)
- {
- int ret;
- struct pm_gpio param = {
- .direction = PM_GPIO_DIR_OUT,
- .output_buffer = PM_GPIO_OUT_BUF_CMOS,
- .output_value = 1,
- .pull = PM_GPIO_PULL_NO,
- .vin_sel = PM_GPIO_VIN_S4,
- .out_strength = PM_GPIO_STRENGTH_MED,
- .function = PM_GPIO_FUNC_NORMAL,
- };
- ret = gpio_request(PM8921_GPIO_PM_TO_SYS(23), "AV_SWITCH");
- if (ret) {
- pr_err("%s: Failed to request gpio %d\n", __func__,
- PM8921_GPIO_PM_TO_SYS(23));
- return ret;
- }
- ret = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(23), ¶m);
- if (ret)
- pr_err("%s: Failed to configure gpio %d\n", __func__,
- PM8921_GPIO_PM_TO_SYS(23));
- else
- gpio_direction_output(PM8921_GPIO_PM_TO_SYS(23), 0);
- ret = gpio_request(us_euro_sel_gpio, "US_EURO_SWITCH");
- if (ret) {
- pr_err("%s: Failed to request gpio %d\n", __func__,
- us_euro_sel_gpio);
- gpio_free(PM8921_GPIO_PM_TO_SYS(23));
- return ret;
- }
- ret = pm8xxx_gpio_config(us_euro_sel_gpio, ¶m);
- if (ret)
- pr_err("%s: Failed to configure gpio %d\n", __func__,
- us_euro_sel_gpio);
- else
- gpio_direction_output(us_euro_sel_gpio, 0);
- return 0;
- }
- static void msm8960_free_headset_mic_gpios(void)
- {
- if (msm8960_headset_gpios_configured) {
- gpio_free(PM8921_GPIO_PM_TO_SYS(23));
- gpio_free(us_euro_sel_gpio);
- }
- }
- static int __init msm8960_audio_init(void)
- {
- int ret;
- if (!soc_class_is_msm8960()) {
- pr_debug("%s: Not the right machine type\n", __func__);
- return -ENODEV ;
- }
- mutex_init(&cdc_mclk_mutex);
- mbhc_cfg.calibration = def_tabla_mbhc_cal();
- if (!mbhc_cfg.calibration) {
- pr_err("Calibration data allocation failed\n");
- return -ENOMEM;
- }
- msm8960_snd_device = platform_device_alloc("soc-audio", 0);
- if (!msm8960_snd_device) {
- pr_err("Platform device allocation failed\n");
- kfree(mbhc_cfg.calibration);
- return -ENOMEM;
- }
- memcpy(msm8960_dai, msm8960_dai_common, sizeof(msm8960_dai_common));
- memcpy(msm8960_dai + ARRAY_SIZE(msm8960_dai_common),
- msm8960_dai_delta_tabla2x, sizeof(msm8960_dai_delta_tabla2x));
- platform_set_drvdata(msm8960_snd_device, &snd_soc_card_msm8960);
- ret = platform_device_add(msm8960_snd_device);
- if (ret) {
- platform_device_put(msm8960_snd_device);
- kfree(mbhc_cfg.calibration);
- return ret;
- }
- msm8960_snd_tabla1x_device = platform_device_alloc("soc-audio", 1);
- if (!msm8960_snd_tabla1x_device) {
- pr_err("Platform device allocation failed\n");
- kfree(mbhc_cfg.calibration);
- return -ENOMEM;
- }
- memcpy(msm8960_tabla1x_dai, msm8960_dai_common,
- sizeof(msm8960_dai_common));
- memcpy(msm8960_tabla1x_dai + ARRAY_SIZE(msm8960_dai_common),
- msm8960_dai_delta_tabla1x, sizeof(msm8960_dai_delta_tabla1x));
- platform_set_drvdata(msm8960_snd_tabla1x_device,
- &snd_soc_tabla1x_card_msm8960);
- ret = platform_device_add(msm8960_snd_tabla1x_device);
- if (ret) {
- platform_device_put(msm8960_snd_tabla1x_device);
- kfree(mbhc_cfg.calibration);
- return ret;
- }
- if (cpu_is_msm8960()) {
- if (msm8960_configure_headset_mic_gpios()) {
- pr_err("%s Fail to configure headset mic gpios\n",
- __func__);
- msm8960_headset_gpios_configured = 0;
- } else
- msm8960_headset_gpios_configured = 1;
- } else {
- msm8960_headset_gpios_configured = 0;
- pr_debug("%s headset GPIO 23 and 35 not configured msm960ab",
- __func__);
- }
- atomic_set(&auxpcm_rsc_ref, 0);
- return ret;
- }
- module_init(msm8960_audio_init);
- static void __exit msm8960_audio_exit(void)
- {
- if (!soc_class_is_msm8960()) {
- pr_debug("%s: Not the right machine type\n", __func__);
- return ;
- }
- msm8960_free_headset_mic_gpios();
- platform_device_unregister(msm8960_snd_device);
- platform_device_unregister(msm8960_snd_tabla1x_device);
- kfree(mbhc_cfg.calibration);
- mutex_destroy(&cdc_mclk_mutex);
- }
- module_exit(msm8960_audio_exit);
- MODULE_DESCRIPTION("ALSA SoC MSM8960");
- MODULE_LICENSE("GPL v2");
|