msm8226.c 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067
  1. /* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/clk.h>
  13. #include <linux/delay.h>
  14. #include <linux/gpio.h>
  15. #include <linux/of_gpio.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/slab.h>
  18. #include <linux/mfd/pm8xxx/pm8921.h>
  19. #include <linux/io.h>
  20. #include <sound/core.h>
  21. #include <sound/soc.h>
  22. #include <sound/soc-dapm.h>
  23. #include <sound/pcm.h>
  24. #include <sound/jack.h>
  25. #include <sound/q6afe-v2.h>
  26. #include <asm/mach-types.h>
  27. #include <mach/socinfo.h>
  28. #include <mach/subsystem_notif.h>
  29. #include <sound/q6core.h>
  30. #include <qdsp6v2/msm-pcm-routing-v2.h>
  31. #include "../codecs/wcd9xxx-common.h"
  32. #include "../codecs/wcd9306.h"
  33. #define SAMPLING_RATE_48KHZ 48000
  34. #define SAMPLING_RATE_96KHZ 96000
  35. #define SAMPLING_RATE_192KHZ 192000
  36. #ifdef CONFIG_SND_SOC_ES325_ATLANTIC
  37. #include "../codecs/es325-export.h"
  38. #endif
  39. #define DRV_NAME "msm8226-asoc-tapan"
  40. #define MSM_SLIM_0_RX_MAX_CHANNELS 2
  41. #define MSM_SLIM_0_TX_MAX_CHANNELS 4
  42. #define BTSCO_RATE_8KHZ 8000
  43. #define BTSCO_RATE_16KHZ 16000
  44. /* It takes about 13ms for Class-D PAs to ramp-up */
  45. #define EXT_CLASS_D_EN_DELAY 13000
  46. #define EXT_CLASS_D_DIS_DELAY 3000
  47. #define EXT_CLASS_D_DELAY_DELTA 2000
  48. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  49. #define WCD9XXX_MBHC_DEF_RLOADS 5
  50. #define TAPAN_EXT_CLK_RATE 9600000
  51. #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98505)
  52. #define GPIO_TERTIARY_MI2S_SCK 49
  53. #define GPIO_TERTIARY_MI2S_WS 50
  54. #define GPIO_TERTIARY_MI2S_DATA0 51
  55. #define GPIO_TERTIARY_MI2S_DATA1 52
  56. #else
  57. #endif
  58. #define NUM_OF_AUXPCM_GPIOS 4
  59. #define LO_1_SPK_AMP 0x1
  60. #define LO_2_SPK_AMP 0x2
  61. #define ADSP_STATE_READY_TIMEOUT_MS 50
  62. static void *adsp_state_notifier;
  63. static int msm8226_auxpcm_rate = 8000;
  64. static atomic_t auxpcm_rsc_ref;
  65. static const char *const auxpcm_rate_text[] = {"8000", "16000"};
  66. static const struct soc_enum msm8226_auxpcm_enum[] = {
  67. SOC_ENUM_SINGLE_EXT(2, auxpcm_rate_text),
  68. };
  69. #define LPAIF_OFFSET 0xFE000000
  70. #define LPAIF_PRI_MODE_MUXSEL (LPAIF_OFFSET + 0x2B000)
  71. #define LPAIF_SEC_MODE_MUXSEL (LPAIF_OFFSET + 0x2C000)
  72. #define LPAIF_TER_MODE_MUXSEL (LPAIF_OFFSET + 0x2D000)
  73. #define LPAIF_QUAD_MODE_MUXSEL (LPAIF_OFFSET + 0x2E000)
  74. #define I2S_PCM_SEL 1
  75. #define I2S_PCM_SEL_OFFSET 1
  76. void *def_tapan_mbhc_cal(void);
  77. static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
  78. bool dapm);
  79. static struct wcd9xxx_mbhc_config mbhc_cfg = {
  80. .read_fw_bin = false,
  81. .calibration = NULL,
  82. .micbias = MBHC_MICBIAS2,
  83. .anc_micbias = MBHC_MICBIAS2,
  84. .mclk_cb_fn = msm_snd_enable_codec_ext_clk,
  85. .mclk_rate = TAPAN_EXT_CLK_RATE,
  86. .gpio = 0,
  87. .gpio_irq = 0,
  88. .gpio_level_insert = 0,
  89. .detect_extn_cable = true,
  90. .micbias_enable_flags = 1 << MBHC_MICBIAS_ENABLE_THRESHOLD_HEADSET,
  91. .insert_detect = true,
  92. .swap_gnd_mic = NULL,
  93. .cs_enable_flags = (1 << MBHC_CS_ENABLE_POLLING |
  94. 1 << MBHC_CS_ENABLE_INSERTION |
  95. 1 << MBHC_CS_ENABLE_REMOVAL |
  96. 1 << MBHC_CS_ENABLE_DET_ANC),
  97. .do_recalibration = true,
  98. .use_vddio_meas = true,
  99. .enable_anc_mic_detect = false,
  100. .hw_jack_type = FOUR_POLE_JACK,
  101. };
  102. struct msm_auxpcm_gpio {
  103. unsigned gpio_no;
  104. const char *gpio_name;
  105. };
  106. struct msm_auxpcm_ctrl {
  107. struct msm_auxpcm_gpio *pin_data;
  108. u32 cnt;
  109. };
  110. struct msm8226_asoc_mach_data {
  111. int mclk_gpio;
  112. u32 mclk_freq;
  113. struct msm_auxpcm_ctrl *auxpcm_ctrl;
  114. u32 us_euro_gpio;
  115. };
  116. #define GPIO_NAME_INDEX 0
  117. #define DT_PARSE_INDEX 1
  118. static char *msm_auxpcm_gpio_name[][2] = {
  119. {"PRIM_AUXPCM_CLK", "qcom,prim-auxpcm-gpio-clk"},
  120. {"PRIM_AUXPCM_SYNC", "qcom,prim-auxpcm-gpio-sync"},
  121. {"PRIM_AUXPCM_DIN", "qcom,prim-auxpcm-gpio-din"},
  122. {"PRIM_AUXPCM_DOUT", "qcom,prim-auxpcm-gpio-dout"},
  123. };
  124. void *lpaif_pri_muxsel_virt_addr;
  125. /* Shared channel numbers for Slimbus ports that connect APQ to MDM. */
  126. enum {
  127. SLIM_1_RX_1 = 145, /* BT-SCO and USB TX */
  128. SLIM_1_TX_1 = 146, /* BT-SCO and USB RX */
  129. SLIM_2_RX_1 = 147, /* HDMI RX */
  130. SLIM_3_RX_1 = 148, /* In-call recording RX */
  131. SLIM_3_RX_2 = 149, /* In-call recording RX */
  132. SLIM_4_TX_1 = 150, /* In-call musid delivery TX */
  133. };
  134. static int msm8226_ext_spk_pamp;
  135. static int msm_slim_0_rx_ch = 1;
  136. static int msm_slim_0_tx_ch = 1;
  137. static int msm_btsco_rate = BTSCO_RATE_8KHZ;
  138. static int msm_btsco_ch = 1;
  139. static struct mutex cdc_mclk_mutex;
  140. static struct mutex jack_mutex;
  141. static struct clk *codec_clk;
  142. static int clk_users;
  143. static int lineout_en_gpio = -1;
  144. static int vdd_spkr_gpio = -1;
  145. static struct regulator* earjack_ldo;
  146. static struct regulator* earadc_ldo;
  147. static int msm_proxy_rx_ch = 2;
  148. static int slim0_rx_sample_rate = SAMPLING_RATE_48KHZ;
  149. static int slim0_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  150. #if defined (CONFIG_GPIO_MAINMIC_BIAS)
  151. static int mainmic_bias_gpio;
  152. #endif //CONFIG_GPIO_MAINMIC_BIAS
  153. static inline int param_is_mask(int p)
  154. {
  155. return ((p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  156. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK));
  157. }
  158. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p, int n)
  159. {
  160. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  161. }
  162. static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned bit)
  163. {
  164. if (bit >= SNDRV_MASK_MAX)
  165. return;
  166. if (param_is_mask(n)) {
  167. struct snd_mask *m = param_to_mask(p, n);
  168. m->bits[0] = 0;
  169. m->bits[1] = 0;
  170. m->bits[bit >> 5] |= (1 << (bit & 31));
  171. }
  172. }
  173. //Enabling the MIC Bias Voltage of Earmic
  174. #ifdef CONFIG_SAMSUNG_JACK
  175. static struct snd_soc_jack hs_jack;
  176. #endif
  177. #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98505)
  178. struct request_gpio {
  179. unsigned gpio_no;
  180. char *gpio_name;
  181. };
  182. static struct request_gpio pri_mi2s_gpio[] = {
  183. {
  184. .gpio_no = GPIO_TERTIARY_MI2S_SCK,
  185. .gpio_name = "TERTIARY_MI2S_SCK",
  186. },
  187. {
  188. .gpio_no = GPIO_TERTIARY_MI2S_WS,
  189. .gpio_name = "TERTIARY_MI2S_WS",
  190. },
  191. {
  192. .gpio_no = GPIO_TERTIARY_MI2S_DATA0,
  193. .gpio_name = "TERTIARY_MI2S_DATA0",
  194. },
  195. {
  196. .gpio_no = GPIO_TERTIARY_MI2S_DATA1,
  197. .gpio_name = "TERTIARY_MI2S_DATA1",
  198. },
  199. };
  200. /* MI2S clock */
  201. struct mi2s_clk {
  202. struct clk *core_clk;
  203. struct clk *osr_clk;
  204. struct clk *bit_clk;
  205. atomic_t mi2s_rsc_ref;
  206. };
  207. static struct mi2s_clk pri_mi2s_clk;
  208. #endif
  209. static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
  210. bool dapm)
  211. {
  212. int ret = 0;
  213. pr_debug("%s: enable = %d clk_users = %d\n",
  214. __func__, enable, clk_users);
  215. mutex_lock(&cdc_mclk_mutex);
  216. if (enable) {
  217. if (!codec_clk) {
  218. dev_err(codec->dev, "%s: did not get Taiko MCLK\n",
  219. __func__);
  220. ret = -EINVAL;
  221. goto exit;
  222. }
  223. clk_users++;
  224. if (clk_users != 1)
  225. goto exit;
  226. if (codec_clk) {
  227. clk_prepare_enable(codec_clk);
  228. tapan_mclk_enable(codec, 1, dapm);
  229. } else {
  230. pr_err("%s: Error setting Tapan MCLK\n", __func__);
  231. clk_users--;
  232. ret = -EINVAL;
  233. goto exit;
  234. }
  235. } else {
  236. if (clk_users > 0) {
  237. clk_users--;
  238. if (clk_users == 0) {
  239. tapan_mclk_enable(codec, 0, dapm);
  240. clk_disable_unprepare(codec_clk);
  241. }
  242. } else {
  243. pr_err("%s: Error releasing Tapan MCLK\n", __func__);
  244. ret = -EINVAL;
  245. goto exit;
  246. }
  247. }
  248. exit:
  249. mutex_unlock(&cdc_mclk_mutex);
  250. return ret;
  251. }
  252. static int msm8226_mclk_event(struct snd_soc_dapm_widget *w,
  253. struct snd_kcontrol *kcontrol, int event)
  254. {
  255. pr_debug("%s: event = %d\n", __func__, event);
  256. switch (event) {
  257. case SND_SOC_DAPM_PRE_PMU:
  258. return msm_snd_enable_codec_ext_clk(w->codec, 1, true);
  259. case SND_SOC_DAPM_POST_PMD:
  260. return msm_snd_enable_codec_ext_clk(w->codec, 0, true);
  261. }
  262. return 0;
  263. }
  264. static void msm8226_ext_spk_power_amp_enable(u32 enable)
  265. {
  266. if (enable) {
  267. gpio_direction_output(lineout_en_gpio, enable);
  268. /* time takes enable the external power amplifier */
  269. usleep_range(EXT_CLASS_D_EN_DELAY,
  270. EXT_CLASS_D_EN_DELAY + EXT_CLASS_D_DELAY_DELTA);
  271. } else {
  272. gpio_direction_output(lineout_en_gpio, enable);
  273. /* time takes disable the external power amplifier */
  274. usleep_range(EXT_CLASS_D_DIS_DELAY,
  275. EXT_CLASS_D_DIS_DELAY + EXT_CLASS_D_DELAY_DELTA);
  276. }
  277. pr_debug("%s: %s external speaker PAs.\n", __func__,
  278. enable ? "Enable" : "Disable");
  279. }
  280. static void msm8226_ext_spk_power_amp_on(u32 spk)
  281. {
  282. if (gpio_is_valid(lineout_en_gpio)) {
  283. if (spk & (LO_1_SPK_AMP | LO_2_SPK_AMP)) {
  284. pr_debug("%s:Enable left and right speakers case spk = 0x%x\n",
  285. __func__, spk);
  286. msm8226_ext_spk_pamp |= spk;
  287. if ((msm8226_ext_spk_pamp & LO_1_SPK_AMP) &&
  288. (msm8226_ext_spk_pamp & LO_2_SPK_AMP))
  289. if (lineout_en_gpio >= 0) {
  290. pr_debug("%s enable power", __func__);
  291. msm8226_ext_spk_power_amp_enable(1);
  292. }
  293. } else {
  294. pr_err("%s: Invalid external speaker ampl. spk = 0x%x\n",
  295. __func__, spk);
  296. }
  297. }
  298. }
  299. static void msm8226_ext_spk_power_amp_off(u32 spk)
  300. {
  301. if (gpio_is_valid(lineout_en_gpio)) {
  302. if (spk & (LO_1_SPK_AMP | LO_2_SPK_AMP)) {
  303. pr_debug("%s Disable left and right speakers case spk = 0x%08x",
  304. __func__, spk);
  305. msm8226_ext_spk_pamp &= ~spk;
  306. if (!msm8226_ext_spk_pamp) {
  307. if (lineout_en_gpio >= 0) {
  308. pr_debug("%s disable power", __func__);
  309. msm8226_ext_spk_power_amp_enable(0);
  310. }
  311. msm8226_ext_spk_pamp = 0;
  312. }
  313. } else {
  314. pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n",
  315. __func__, spk);
  316. }
  317. }
  318. }
  319. static int msm8226_ext_spkramp_event(struct snd_soc_dapm_widget *w,
  320. struct snd_kcontrol *k, int event)
  321. {
  322. pr_debug("%s()\n", __func__);
  323. if (SND_SOC_DAPM_EVENT_ON(event)) {
  324. if (!strncmp(w->name, "Lineout_1 amp", 14))
  325. msm8226_ext_spk_power_amp_on(LO_1_SPK_AMP);
  326. else if (!strncmp(w->name, "Lineout_2 amp", 14))
  327. msm8226_ext_spk_power_amp_on(LO_2_SPK_AMP);
  328. else {
  329. pr_err("%s() Invalid Speaker Widget = %s\n",
  330. __func__, w->name);
  331. return -EINVAL;
  332. }
  333. } else {
  334. if (!strncmp(w->name, "Lineout_1 amp", 14))
  335. msm8226_ext_spk_power_amp_off(LO_1_SPK_AMP);
  336. else if (!strncmp(w->name, "Lineout_2 amp", 14))
  337. msm8226_ext_spk_power_amp_off(LO_2_SPK_AMP);
  338. else {
  339. pr_err("%s() Invalid Speaker Widget = %s\n",
  340. __func__, w->name);
  341. return -EINVAL;
  342. }
  343. }
  344. return 0;
  345. }
  346. static int msm8226_vdd_spkr_event(struct snd_soc_dapm_widget *w,
  347. struct snd_kcontrol *kcontrol, int event)
  348. {
  349. pr_debug("%s: event = %d\n", __func__, event);
  350. if (SND_SOC_DAPM_EVENT_ON(event)) {
  351. if (vdd_spkr_gpio >= 0) {
  352. gpio_direction_output(vdd_spkr_gpio, 1);
  353. pr_debug("%s: Enabled 5V external supply for speaker\n",
  354. __func__);
  355. }
  356. }else
  357. {
  358. if (vdd_spkr_gpio >= 0) {
  359. gpio_direction_output(vdd_spkr_gpio, 0);
  360. pr_debug("%s: Disabled 5V external supply for speaker\n",
  361. __func__);
  362. }
  363. }
  364. return 0;
  365. }
  366. #if defined(CONFIG_GPIO_MAINMIC_BIAS)
  367. static int msm8226_prepare_mainmic(void)
  368. {
  369. int ret = 0;
  370. if (mainmic_bias_gpio) {
  371. pr_debug("%s : mainmic bias gpio request %d", __func__,
  372. mainmic_bias_gpio);
  373. ret = gpio_request(mainmic_bias_gpio, "TAPAN_MAINMIC_BIAS");
  374. if (ret) {
  375. pr_debug("%s: Failed to request tapan mainmic bias gpio %d error %d\n",
  376. __func__, mainmic_bias_gpio, ret);
  377. return ret;
  378. }
  379. gpio_direction_output(mainmic_bias_gpio, 0);
  380. }
  381. return ret;
  382. }
  383. static int msm_mainmic_bias_event(struct snd_soc_dapm_widget *w,
  384. struct snd_kcontrol *k, int event)
  385. {
  386. pr_info("%s : Event %d, SND_SOC_DAPM:%d\n",
  387. __func__, (event), SND_SOC_DAPM_EVENT_ON(event));
  388. if (mainmic_bias_gpio > 0) {
  389. gpio_direction_output(mainmic_bias_gpio,
  390. SND_SOC_DAPM_EVENT_ON(event));
  391. }else{
  392. pr_err("%s : Failed to Enable MainMic Bias,s gpio value not initialized \n",
  393. __func__);
  394. }
  395. return 0;
  396. }
  397. #endif //CONFIG_GPIO_MAINMIC_BIAS
  398. static const struct snd_soc_dapm_widget msm8226_dapm_widgets[] = {
  399. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  400. msm8226_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  401. #if defined(CONFIG_GPIO_MAINMIC_BIAS)
  402. SND_SOC_DAPM_MIC("Handset Mic", msm_mainmic_bias_event),
  403. #else
  404. SND_SOC_DAPM_MIC("Handset Mic", NULL),
  405. #endif //CONFIG_GPIO_MAINMIC_BIAS
  406. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  407. SND_SOC_DAPM_MIC("Sub Mic", NULL),
  408. SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
  409. SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
  410. SND_SOC_DAPM_MIC("Digital Mic1", NULL),
  411. SND_SOC_DAPM_MIC("Digital Mic2", NULL),
  412. SND_SOC_DAPM_MIC("Digital Mic3", NULL),
  413. SND_SOC_DAPM_MIC("Digital Mic4", NULL),
  414. SND_SOC_DAPM_MIC("Digital Mic5", NULL),
  415. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  416. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  417. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  418. SND_SOC_DAPM_SPK("Lineout_1 amp", msm8226_ext_spkramp_event),
  419. SND_SOC_DAPM_SPK("Lineout_2 amp", msm8226_ext_spkramp_event),
  420. SND_SOC_DAPM_SPK("EXT_VDD_SPKR",msm8226_vdd_spkr_event),
  421. };
  422. static const char *const slim0_rx_ch_text[] = {"One", "Two"};
  423. static const char *const slim0_tx_ch_text[] = {"One", "Two", "Three", "Four"};
  424. static const char *const proxy_rx_ch_text[] = {"One", "Two", "Three", "Four",
  425. "Five", "Six", "Seven", "Eight"};
  426. static char const *rx_bit_format_text[] = {"S16_LE", "S24_LE"};
  427. static char const *slim0_rx_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  428. "KHZ_192"};
  429. static const struct soc_enum msm_enum[] = {
  430. SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text),
  431. SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text),
  432. };
  433. static const char *const btsco_rate_text[] = {"BTSCO_RATE_8KHZ", "BTSCO_RATE_16KHZ"};
  434. static const struct soc_enum msm_btsco_enum[] = {
  435. SOC_ENUM_SINGLE_EXT(2, btsco_rate_text),
  436. };
  437. static int slim0_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  438. struct snd_ctl_elem_value *ucontrol)
  439. {
  440. int sample_rate_val = 0;
  441. switch (slim0_rx_sample_rate) {
  442. case SAMPLING_RATE_192KHZ:
  443. sample_rate_val = 2;
  444. break;
  445. case SAMPLING_RATE_96KHZ:
  446. sample_rate_val = 1;
  447. break;
  448. case SAMPLING_RATE_48KHZ:
  449. default:
  450. sample_rate_val = 0;
  451. break;
  452. }
  453. ucontrol->value.integer.value[0] = sample_rate_val;
  454. pr_debug("%s: slim0_rx_sample_rate = %d\n", __func__,
  455. slim0_rx_sample_rate);
  456. return 0;
  457. }
  458. static int slim0_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  459. struct snd_ctl_elem_value *ucontrol)
  460. {
  461. pr_debug("%s: ucontrol value = %ld\n", __func__,
  462. ucontrol->value.integer.value[0]);
  463. switch (ucontrol->value.integer.value[0]) {
  464. case 2:
  465. slim0_rx_sample_rate = SAMPLING_RATE_192KHZ;
  466. break;
  467. case 1:
  468. slim0_rx_sample_rate = SAMPLING_RATE_96KHZ;
  469. break;
  470. case 0:
  471. default:
  472. slim0_rx_sample_rate = SAMPLING_RATE_48KHZ;
  473. break;
  474. }
  475. pr_debug("%s: slim0_rx_sample_rate = %d\n", __func__,
  476. slim0_rx_sample_rate);
  477. return 0;
  478. }
  479. static int msm_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol,
  480. struct snd_ctl_elem_value *ucontrol)
  481. {
  482. pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
  483. msm_slim_0_rx_ch);
  484. ucontrol->value.integer.value[0] = msm_slim_0_rx_ch - 1;
  485. return 0;
  486. }
  487. static int msm_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol,
  488. struct snd_ctl_elem_value *ucontrol)
  489. {
  490. msm_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1;
  491. pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
  492. msm_slim_0_rx_ch);
  493. return 1;
  494. }
  495. static int msm_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol,
  496. struct snd_ctl_elem_value *ucontrol)
  497. {
  498. pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__,
  499. msm_slim_0_tx_ch);
  500. ucontrol->value.integer.value[0] = msm_slim_0_tx_ch - 1;
  501. return 0;
  502. }
  503. static int msm_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol,
  504. struct snd_ctl_elem_value *ucontrol)
  505. {
  506. msm_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1;
  507. pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, msm_slim_0_tx_ch);
  508. return 1;
  509. }
  510. static int msm_btsco_rate_get(struct snd_kcontrol *kcontrol,
  511. struct snd_ctl_elem_value *ucontrol)
  512. {
  513. pr_debug("%s: msm_btsco_rate = %d", __func__, msm_btsco_rate);
  514. ucontrol->value.integer.value[0] = msm_btsco_rate;
  515. return 0;
  516. }
  517. static int msm_btsco_rate_put(struct snd_kcontrol *kcontrol,
  518. struct snd_ctl_elem_value *ucontrol)
  519. {
  520. switch (ucontrol->value.integer.value[0]) {
  521. case 0:
  522. msm_btsco_rate = BTSCO_RATE_8KHZ;
  523. break;
  524. case 1:
  525. msm_btsco_rate = BTSCO_RATE_16KHZ;
  526. break;
  527. default:
  528. msm_btsco_rate = BTSCO_RATE_8KHZ;
  529. break;
  530. }
  531. pr_debug("%s: msm_btsco_rate = %d\n", __func__, msm_btsco_rate);
  532. return 0;
  533. }
  534. static int msm_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  535. struct snd_pcm_hw_params *params)
  536. {
  537. struct snd_interval *rate = hw_param_interval(params,
  538. SNDRV_PCM_HW_PARAM_RATE);
  539. struct snd_interval *channels = hw_param_interval(params,
  540. SNDRV_PCM_HW_PARAM_CHANNELS);
  541. rate->min = rate->max = msm_btsco_rate;
  542. channels->min = channels->max = msm_btsco_ch;
  543. return 0;
  544. }
  545. static int msm8226_auxpcm_rate_get(struct snd_kcontrol *kcontrol,
  546. struct snd_ctl_elem_value *ucontrol)
  547. {
  548. ucontrol->value.integer.value[0] = msm8226_auxpcm_rate;
  549. return 0;
  550. }
  551. static int msm8226_auxpcm_rate_put(struct snd_kcontrol *kcontrol,
  552. struct snd_ctl_elem_value *ucontrol)
  553. {
  554. switch (ucontrol->value.integer.value[0]) {
  555. case 0:
  556. msm8226_auxpcm_rate = 8000;
  557. break;
  558. case 1:
  559. msm8226_auxpcm_rate = 16000;
  560. break;
  561. default:
  562. msm8226_auxpcm_rate = 8000;
  563. break;
  564. }
  565. return 0;
  566. }
  567. static int msm_proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  568. struct snd_ctl_elem_value *ucontrol)
  569. {
  570. pr_debug("%s: msm_proxy_rx_ch = %d\n", __func__,
  571. msm_proxy_rx_ch);
  572. ucontrol->value.integer.value[0] = msm_proxy_rx_ch - 1;
  573. return 0;
  574. }
  575. static int msm_proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  576. struct snd_ctl_elem_value *ucontrol)
  577. {
  578. msm_proxy_rx_ch = ucontrol->value.integer.value[0] + 1;
  579. pr_debug("%s: msm_proxy_rx_ch = %d\n", __func__,
  580. msm_proxy_rx_ch);
  581. return 1;
  582. }
  583. static int slim0_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  584. struct snd_ctl_elem_value *ucontrol)
  585. {
  586. switch (slim0_rx_bit_format) {
  587. case SNDRV_PCM_FORMAT_S24_LE:
  588. ucontrol->value.integer.value[0] = 1;
  589. break;
  590. case SNDRV_PCM_FORMAT_S16_LE:
  591. default:
  592. ucontrol->value.integer.value[0] = 0;
  593. break;
  594. }
  595. pr_debug("%s: slim0_rx_bit_format = %d, ucontrol value = %ld\n",
  596. __func__, slim0_rx_bit_format,
  597. ucontrol->value.integer.value[0]);
  598. return 0;
  599. }
  600. static int slim0_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  601. struct snd_ctl_elem_value *ucontrol)
  602. {
  603. switch (ucontrol->value.integer.value[0]) {
  604. case 1:
  605. slim0_rx_bit_format = SNDRV_PCM_FORMAT_S24_LE;
  606. break;
  607. case 0:
  608. default:
  609. slim0_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  610. break;
  611. }
  612. return 0;
  613. }
  614. static int msm_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd,
  615. struct snd_pcm_hw_params *params)
  616. {
  617. struct snd_interval *rate =
  618. hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
  619. struct snd_interval *channels =
  620. hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  621. rate->min = rate->max = msm8226_auxpcm_rate;
  622. channels->min = channels->max = 1;
  623. return 0;
  624. }
  625. static int msm_proxy_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  626. struct snd_pcm_hw_params *params)
  627. {
  628. struct snd_interval *rate = hw_param_interval(params,
  629. SNDRV_PCM_HW_PARAM_RATE);
  630. struct snd_interval *channels = hw_param_interval(params,
  631. SNDRV_PCM_HW_PARAM_CHANNELS);
  632. pr_debug("%s: msm_proxy_rx_ch =%d\n", __func__, msm_proxy_rx_ch);
  633. if (channels->max < 2)
  634. channels->min = channels->max = 2;
  635. channels->min = channels->max = msm_proxy_rx_ch;
  636. rate->min = rate->max = 48000;
  637. return 0;
  638. }
  639. static int msm_proxy_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  640. struct snd_pcm_hw_params *params)
  641. {
  642. struct snd_interval *rate = hw_param_interval(params,
  643. SNDRV_PCM_HW_PARAM_RATE);
  644. rate->min = rate->max = 48000;
  645. return 0;
  646. }
  647. static int msm_aux_pcm_get_gpios(struct msm_auxpcm_ctrl *auxpcm_ctrl)
  648. {
  649. struct msm_auxpcm_gpio *pin_data = NULL;
  650. int ret = 0;
  651. int i;
  652. int j;
  653. pin_data = auxpcm_ctrl->pin_data;
  654. if (!pin_data) {
  655. pr_err("%s: Invalid control data for AUXPCM\n", __func__);
  656. ret = -EINVAL;
  657. goto err;
  658. }
  659. for (i = 0; i < auxpcm_ctrl->cnt; i++, pin_data++) {
  660. ret = gpio_request(pin_data->gpio_no,
  661. pin_data->gpio_name);
  662. pr_debug("%s: gpio = %d, gpio name = %s\n"
  663. "ret = %d\n", __func__,
  664. pin_data->gpio_no,
  665. pin_data->gpio_name,
  666. ret);
  667. if (ret) {
  668. pr_err("%s: Failed to request gpio %d\n",
  669. __func__, pin_data->gpio_no);
  670. /* Release all GPIOs on failure */
  671. if (i > 0) {
  672. for (j = i; j >= 0; j--)
  673. gpio_free(pin_data->gpio_no);
  674. }
  675. goto err;
  676. }
  677. }
  678. err:
  679. return ret;
  680. }
  681. static int msm_aux_pcm_free_gpios(struct msm_auxpcm_ctrl *auxpcm_ctrl)
  682. {
  683. struct msm_auxpcm_gpio *pin_data = NULL;
  684. int i;
  685. int ret = 0;
  686. if (auxpcm_ctrl == NULL || auxpcm_ctrl->pin_data == NULL) {
  687. pr_err("%s: Invalid control data for AUXPCM\n", __func__);
  688. ret = -EINVAL;
  689. goto err;
  690. }
  691. pin_data = auxpcm_ctrl->pin_data;
  692. for (i = 0; i < auxpcm_ctrl->cnt; i++, pin_data++) {
  693. gpio_free(pin_data->gpio_no);
  694. pr_debug("%s: gpio = %d, gpio_name = %s\n",
  695. __func__, pin_data->gpio_no,
  696. pin_data->gpio_name);
  697. }
  698. err:
  699. return ret;
  700. }
  701. static int msm_auxpcm_startup(struct snd_pcm_substream *substream)
  702. {
  703. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  704. struct snd_soc_card *card = rtd->card;
  705. struct msm8226_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  706. struct msm_auxpcm_ctrl *auxpcm_ctrl = NULL;
  707. int ret = 0;
  708. pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n",
  709. __func__, substream->name, atomic_read(&auxpcm_rsc_ref));
  710. auxpcm_ctrl = pdata->auxpcm_ctrl;
  711. if (auxpcm_ctrl == NULL || auxpcm_ctrl->pin_data == NULL ||
  712. lpaif_pri_muxsel_virt_addr == NULL) {
  713. pr_err("%s: Invalid control data for AUXPCM\n", __func__);
  714. ret = -EINVAL;
  715. goto err;
  716. }
  717. if (atomic_inc_return(&auxpcm_rsc_ref) == 1) {
  718. iowrite32(I2S_PCM_SEL << I2S_PCM_SEL_OFFSET,
  719. lpaif_pri_muxsel_virt_addr);
  720. ret = msm_aux_pcm_get_gpios(auxpcm_ctrl);
  721. }
  722. if (ret < 0) {
  723. pr_err("%s: Aux PCM GPIO request failed\n", __func__);
  724. return -EINVAL;
  725. }
  726. err:
  727. return ret;
  728. }
  729. static void msm_auxpcm_shutdown(struct snd_pcm_substream *substream)
  730. {
  731. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  732. struct snd_soc_card *card = rtd->card;
  733. struct msm8226_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  734. struct msm_auxpcm_ctrl *auxpcm_ctrl = NULL;
  735. pr_debug("%s(): substream = %s, auxpcm_rsc_ref counter = %d\n",
  736. __func__, substream->name, atomic_read(&auxpcm_rsc_ref));
  737. auxpcm_ctrl = pdata->auxpcm_ctrl;
  738. if (atomic_dec_return(&auxpcm_rsc_ref) == 0)
  739. msm_aux_pcm_free_gpios(auxpcm_ctrl);
  740. }
  741. static struct snd_soc_ops msm_auxpcm_be_ops = {
  742. .startup = msm_auxpcm_startup,
  743. .shutdown = msm_auxpcm_shutdown,
  744. };
  745. static int msm_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  746. struct snd_pcm_hw_params *params)
  747. {
  748. struct snd_interval *rate = hw_param_interval(params,
  749. SNDRV_PCM_HW_PARAM_RATE);
  750. struct snd_interval *channels =
  751. hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  752. pr_debug("%s()\n", __func__);
  753. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  754. slim0_rx_bit_format);
  755. rate->min = rate->max = slim0_rx_sample_rate;
  756. channels->min = channels->max = msm_slim_0_rx_ch;
  757. return 0;
  758. }
  759. static int msm_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  760. struct snd_pcm_hw_params *params)
  761. {
  762. struct snd_interval *rate = hw_param_interval(params,
  763. SNDRV_PCM_HW_PARAM_RATE);
  764. struct snd_interval *channels = hw_param_interval(params,
  765. SNDRV_PCM_HW_PARAM_CHANNELS);
  766. pr_debug("%s()\n", __func__);
  767. rate->min = rate->max = 48000;
  768. channels->min = channels->max = msm_slim_0_tx_ch;
  769. return 0;
  770. }
  771. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  772. struct snd_pcm_hw_params *params)
  773. {
  774. struct snd_interval *rate = hw_param_interval(params,
  775. SNDRV_PCM_HW_PARAM_RATE);
  776. pr_debug("%s()\n", __func__);
  777. rate->min = rate->max = 48000;
  778. return 0;
  779. }
  780. #ifdef CONFIG_SND_SOC_MAX98505
  781. static int msm_mi2s_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  782. struct snd_pcm_hw_params *params)
  783. {
  784. struct snd_interval *rate = hw_param_interval(params,
  785. SNDRV_PCM_HW_PARAM_RATE);
  786. struct snd_interval *channels =
  787. hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  788. pr_debug("%s()\n", __func__);
  789. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  790. slim0_rx_bit_format);
  791. channels->min = channels->max = 2;
  792. rate->min = rate->max = 48000;
  793. return 0;
  794. }
  795. #endif
  796. static int msm_be_fm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  797. struct snd_pcm_hw_params *params)
  798. {
  799. struct snd_interval *rate = hw_param_interval(params,
  800. SNDRV_PCM_HW_PARAM_RATE);
  801. struct snd_interval *channels = hw_param_interval(params,
  802. SNDRV_PCM_HW_PARAM_CHANNELS);
  803. pr_debug("%s()\n", __func__);
  804. rate->min = rate->max = 48000;
  805. channels->min = channels->max = 2;
  806. return 0;
  807. }
  808. static const struct soc_enum msm_snd_enum[] = {
  809. SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text),
  810. SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text),
  811. SOC_ENUM_SINGLE_EXT(8, proxy_rx_ch_text),
  812. SOC_ENUM_SINGLE_EXT(2, rx_bit_format_text),
  813. SOC_ENUM_SINGLE_EXT(3, slim0_rx_sample_rate_text),
  814. };
  815. #if defined (CONFIG_SEC_MATISSE_PROJECT) || defined (CONFIG_SEC_T10_PROJECT)
  816. static const char *const cradle_switch_text[] = {"0", "1"};
  817. static const struct soc_enum cradle_switch_enum[] = {
  818. SOC_ENUM_SINGLE_EXT(2, cradle_switch_text),
  819. };
  820. static int cradle_switch_enum_get(struct snd_kcontrol *kcontrol,
  821. struct snd_ctl_elem_value *ucontrol)
  822. {
  823. pr_debug("%s:\n", __func__);
  824. return 0;
  825. }
  826. static int cradle_switch_enum_put(struct snd_kcontrol *kcontrol,
  827. struct snd_ctl_elem_value *ucontrol)
  828. {
  829. int val = ucontrol->value.integer.value[0];
  830. pr_debug("%s: %d\n",__func__,val);
  831. if(val == 0 || val == 1)
  832. {
  833. if (lineout_en_gpio >= 0) {
  834. gpio_direction_output(lineout_en_gpio,val);
  835. pr_info("%s:Lineout EN GPIO state %d\n",
  836. __func__,val);
  837. }
  838. else
  839. pr_err("%s Lineout EN GPIO not defined\n",__func__);
  840. }
  841. else
  842. pr_err("%s Invalid CRADLE Switch Value\n",__func__);
  843. return 0;
  844. }
  845. #endif
  846. static const struct snd_kcontrol_new msm_snd_controls[] = {
  847. SOC_ENUM_EXT("SLIM_0_RX Channels", msm_snd_enum[0],
  848. msm_slim_0_rx_ch_get, msm_slim_0_rx_ch_put),
  849. SOC_ENUM_EXT("SLIM_0_TX Channels", msm_snd_enum[1],
  850. msm_slim_0_tx_ch_get, msm_slim_0_tx_ch_put),
  851. SOC_ENUM_EXT("AUX PCM SampleRate", msm8226_auxpcm_enum[0],
  852. msm8226_auxpcm_rate_get, msm8226_auxpcm_rate_put),
  853. SOC_ENUM_EXT("Internal BTSCO SampleRate", msm_btsco_enum[0],
  854. msm_btsco_rate_get, msm_btsco_rate_put),
  855. SOC_ENUM_EXT("PROXY_RX Channels", msm_snd_enum[2],
  856. msm_proxy_rx_ch_get, msm_proxy_rx_ch_put),
  857. SOC_ENUM_EXT("SLIM_0_RX Format", msm_snd_enum[3],
  858. slim0_rx_bit_format_get, slim0_rx_bit_format_put),
  859. SOC_ENUM_EXT("SLIM_0_RX SampleRate", msm_snd_enum[4],
  860. slim0_rx_sample_rate_get, slim0_rx_sample_rate_put),
  861. #if defined (CONFIG_SEC_MATISSE_PROJECT) || defined (CONFIG_SEC_T10_PROJECT)
  862. SOC_ENUM_EXT("CRADLE Switch", cradle_switch_enum[0],
  863. cradle_switch_enum_get, cradle_switch_enum_put),
  864. #endif
  865. };
  866. static int msm_afe_set_config(struct snd_soc_codec *codec)
  867. {
  868. int rc;
  869. void *config_data;
  870. pr_debug("%s: enter\n", __func__);
  871. config_data = tapan_get_afe_config(codec, AFE_CDC_REGISTERS_CONFIG);
  872. rc = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
  873. if (rc) {
  874. pr_err("%s: Failed to set codec registers config %d\n",
  875. __func__, rc);
  876. return rc;
  877. }
  878. config_data = tapan_get_afe_config(codec, AFE_SLIMBUS_SLAVE_CONFIG);
  879. rc = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
  880. if (rc) {
  881. pr_err("%s: Failed to set slimbus slave config %d\n", __func__,
  882. rc);
  883. return rc;
  884. }
  885. config_data = tapan_get_afe_config(codec, AFE_AANC_VERSION);
  886. rc = afe_set_config(AFE_AANC_VERSION, config_data, 0);
  887. if (rc) {
  888. pr_err("%s: Failed to set AANC version %d\n", __func__,
  889. rc);
  890. return rc;
  891. }
  892. return 0;
  893. }
  894. static void msm_afe_clear_config(void)
  895. {
  896. afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
  897. afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
  898. afe_clear_config(AFE_AANC_VERSION);
  899. }
  900. static int msm8226_adsp_state_callback(struct notifier_block *nb,
  901. unsigned long value, void *priv)
  902. {
  903. if (value == SUBSYS_BEFORE_SHUTDOWN) {
  904. pr_debug("%s: ADSP is about to shutdown. Clearing AFE config\n",
  905. __func__);
  906. msm_afe_clear_config();
  907. } else if (value == SUBSYS_AFTER_POWERUP) {
  908. pr_debug("%s: ADSP is up\n", __func__);
  909. }
  910. return NOTIFY_OK;
  911. }
  912. static struct notifier_block adsp_state_notifier_block = {
  913. .notifier_call = msm8226_adsp_state_callback,
  914. .priority = -INT_MAX,
  915. };
  916. static int msm8226_tapan_codec_up(struct snd_soc_codec *codec)
  917. {
  918. int err;
  919. unsigned long timeout;
  920. int adsp_ready = 0;
  921. pr_debug("%s\n", __func__);
  922. timeout = jiffies +
  923. msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
  924. do {
  925. if (!q6core_is_adsp_ready()) {
  926. pr_err("%s: ADSP Audio isn't ready\n", __func__);
  927. } else {
  928. pr_debug("%s: ADSP Audio is ready\n", __func__);
  929. adsp_ready = 1;
  930. break;
  931. }
  932. } while (time_after(timeout, jiffies));
  933. if (!adsp_ready) {
  934. pr_err("%s: timed out waiting for ADSP Audio\n", __func__);
  935. return -ETIMEDOUT;
  936. }
  937. err = msm_afe_set_config(codec);
  938. if (err)
  939. pr_err("%s: Failed to set AFE config. err %d\n",
  940. __func__, err);
  941. return err;
  942. }
  943. static int msm8226_tapan_event_cb(struct snd_soc_codec *codec,
  944. enum wcd9xxx_codec_event codec_event)
  945. {
  946. switch (codec_event) {
  947. case WCD9XXX_CODEC_EVENT_CODEC_UP:
  948. return msm8226_tapan_codec_up(codec);
  949. default:
  950. pr_err("%s: UnSupported codec event %d\n",
  951. __func__, codec_event);
  952. return -EINVAL;
  953. }
  954. }
  955. static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
  956. {
  957. int err;
  958. struct snd_soc_codec *codec = rtd->codec;
  959. struct snd_soc_dapm_context *dapm = &codec->dapm;
  960. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  961. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  962. /*
  963. * Tapan SLIMBUS configuration
  964. * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13
  965. * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
  966. * TX14, TX15, TX16
  967. */
  968. unsigned int rx_ch[TAPAN_RX_MAX] = {144, 145, 146, 147, 148};
  969. unsigned int tx_ch[TAPAN_TX_MAX] = {128, 129, 130, 131, 132};
  970. pr_debug("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev));
  971. rtd->pmdown_time = 0;
  972. err = snd_soc_add_codec_controls(codec, msm_snd_controls,
  973. ARRAY_SIZE(msm_snd_controls));
  974. if (err < 0)
  975. return err;
  976. snd_soc_dapm_new_controls(dapm, msm8226_dapm_widgets,
  977. ARRAY_SIZE(msm8226_dapm_widgets));
  978. snd_soc_dapm_sync(dapm);
  979. #ifdef CONFIG_SAMSUNG_JACK
  980. // Need to remove this code in future
  981. // Below lines has been added only because in need to codec ptr in order to enable
  982. //MIC BIAS2 Internal1 dapm widget of Codec
  983. err = snd_soc_jack_new(codec, "Ear Jack",
  984. (SND_JACK_HEADSET | SND_JACK_OC_HPHL | SND_JACK_OC_HPHR),
  985. &hs_jack);
  986. if (err) {
  987. pr_err("failed to create new jack\n");
  988. return err;
  989. }
  990. #endif
  991. codec_clk = clk_get(cpu_dai->dev, "osr_clk");
  992. if (codec_clk < 0)
  993. pr_err("%s() Failed to get clock for %s\n",
  994. __func__, dev_name(cpu_dai->dev));
  995. snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  996. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  997. err = msm_afe_set_config(codec);
  998. if (err) {
  999. pr_err("%s: Failed to set AFE config %d\n",
  1000. __func__, err);
  1001. return err;
  1002. }
  1003. #ifndef CONFIG_SAMSUNG_JACK //Comment Disable MBHC
  1004. /* start mbhc */
  1005. mbhc_cfg.calibration = def_tapan_mbhc_cal();
  1006. if (mbhc_cfg.calibration) {
  1007. err = tapan_hs_detect(codec, &mbhc_cfg);
  1008. } else {
  1009. err = -ENOMEM;
  1010. goto out;
  1011. }
  1012. #endif
  1013. adsp_state_notifier =
  1014. subsys_notif_register_notifier("adsp",
  1015. &adsp_state_notifier_block);
  1016. if (!adsp_state_notifier) {
  1017. pr_err("%s: Failed to register adsp state notifier\n",
  1018. __func__);
  1019. err = -EFAULT;
  1020. goto out;
  1021. }
  1022. tapan_event_register(msm8226_tapan_event_cb, rtd->codec);
  1023. tapan_register_mclk_cb(codec, msm_snd_enable_codec_ext_clk);
  1024. return 0;
  1025. out:
  1026. return err;
  1027. }
  1028. static int msm_snd_startup(struct snd_pcm_substream *substream)
  1029. {
  1030. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  1031. substream->name, substream->stream);
  1032. return 0;
  1033. }
  1034. void *def_tapan_mbhc_cal(void)
  1035. {
  1036. void *tapan_cal;
  1037. struct wcd9xxx_mbhc_btn_detect_cfg *btn_cfg;
  1038. u16 *btn_low, *btn_high;
  1039. u8 *n_ready, *n_cic, *gain;
  1040. tapan_cal = kzalloc(WCD9XXX_MBHC_CAL_SIZE(WCD9XXX_MBHC_DEF_BUTTONS,
  1041. WCD9XXX_MBHC_DEF_RLOADS),
  1042. GFP_KERNEL);
  1043. if (!tapan_cal) {
  1044. pr_err("%s: out of memory\n", __func__);
  1045. return NULL;
  1046. }
  1047. #define S(X, Y) ((WCD9XXX_MBHC_CAL_GENERAL_PTR(tapan_cal)->X) = (Y))
  1048. S(t_ldoh, 100);
  1049. S(t_bg_fast_settle, 100);
  1050. S(t_shutdown_plug_rem, 255);
  1051. S(mbhc_nsa, 2);
  1052. S(mbhc_navg, 128);
  1053. #undef S
  1054. #define S(X, Y) ((WCD9XXX_MBHC_CAL_PLUG_DET_PTR(tapan_cal)->X) = (Y))
  1055. S(mic_current, TAPAN_PID_MIC_5_UA);
  1056. S(hph_current, TAPAN_PID_MIC_5_UA);
  1057. S(t_mic_pid, 100);
  1058. S(t_ins_complete, 250);
  1059. S(t_ins_retry, 200);
  1060. #undef S
  1061. #define S(X, Y) ((WCD9XXX_MBHC_CAL_PLUG_TYPE_PTR(tapan_cal)->X) = (Y))
  1062. S(v_no_mic, 30);
  1063. S(v_hs_max, 2450);
  1064. #undef S
  1065. #define S(X, Y) ((WCD9XXX_MBHC_CAL_BTN_DET_PTR(tapan_cal)->X) = (Y))
  1066. S(c[0], 62);
  1067. S(c[1], 124);
  1068. S(nc, 1);
  1069. S(n_meas, 5);
  1070. S(mbhc_nsc, 10);
  1071. S(n_btn_meas, 1);
  1072. S(n_btn_con, 2);
  1073. S(num_btn, WCD9XXX_MBHC_DEF_BUTTONS);
  1074. S(v_btn_press_delta_sta, 100);
  1075. S(v_btn_press_delta_cic, 50);
  1076. #undef S
  1077. btn_cfg = WCD9XXX_MBHC_CAL_BTN_DET_PTR(tapan_cal);
  1078. btn_low = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_V_BTN_LOW);
  1079. btn_high = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg,
  1080. MBHC_BTN_DET_V_BTN_HIGH);
  1081. btn_low[0] = -50;
  1082. btn_high[0] = 20;
  1083. btn_low[1] = 21;
  1084. btn_high[1] = 61;
  1085. btn_low[2] = 62;
  1086. btn_high[2] = 104;
  1087. btn_low[3] = 105;
  1088. btn_high[3] = 148;
  1089. btn_low[4] = 149;
  1090. btn_high[4] = 189;
  1091. btn_low[5] = 190;
  1092. btn_high[5] = 228;
  1093. btn_low[6] = 229;
  1094. btn_high[6] = 269;
  1095. btn_low[7] = 270;
  1096. btn_high[7] = 500;
  1097. n_ready = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_N_READY);
  1098. n_ready[0] = 80;
  1099. n_ready[1] = 12;
  1100. n_cic = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_N_CIC);
  1101. n_cic[0] = 60;
  1102. n_cic[1] = 47;
  1103. gain = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_GAIN);
  1104. gain[0] = 11;
  1105. gain[1] = 14;
  1106. return tapan_cal;
  1107. }
  1108. static int msm_snd_hw_params(struct snd_pcm_substream *substream,
  1109. struct snd_pcm_hw_params *params)
  1110. {
  1111. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1112. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  1113. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1114. int ret = 0;
  1115. unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  1116. unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
  1117. unsigned int user_set_tx_ch = 0;
  1118. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1119. pr_debug("%s: rx_0_ch=%d\n", __func__, msm_slim_0_rx_ch);
  1120. ret = snd_soc_dai_get_channel_map(codec_dai,
  1121. &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
  1122. if (ret < 0) {
  1123. pr_err("%s: failed to get codec chan map\n", __func__);
  1124. goto end;
  1125. }
  1126. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  1127. msm_slim_0_rx_ch, rx_ch);
  1128. if (ret < 0) {
  1129. pr_err("%s: failed to set cpu chan map\n", __func__);
  1130. goto end;
  1131. }
  1132. } else {
  1133. pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
  1134. codec_dai->name, codec_dai->id, user_set_tx_ch);
  1135. ret = snd_soc_dai_get_channel_map(codec_dai,
  1136. &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
  1137. if (ret < 0) {
  1138. pr_err("%s: failed to get codec chan map\n", __func__);
  1139. goto end;
  1140. }
  1141. #ifdef CONFIG_SND_SOC_ES325_ATLANTIC
  1142. /* For tabla_tx1 case */
  1143. if ((codec_dai->id == 1) ||(codec_dai->id == 11))
  1144. #else
  1145. if (codec_dai->id == 1)
  1146. #endif
  1147. user_set_tx_ch = msm_slim_0_tx_ch;
  1148. /* For tabla_tx2 case */
  1149. else if (codec_dai->id == 3)
  1150. user_set_tx_ch = params_channels(params);
  1151. else
  1152. user_set_tx_ch = tx_ch_cnt;
  1153. pr_debug("%s: msm_slim_0_tx_ch(%d)user_set_tx_ch(%d)tx_ch_cnt(%d)\n",
  1154. __func__, msm_slim_0_tx_ch, user_set_tx_ch, tx_ch_cnt);
  1155. ret = snd_soc_dai_set_channel_map(cpu_dai,
  1156. user_set_tx_ch, tx_ch, 0 , 0);
  1157. if (ret < 0) {
  1158. pr_err("%s: failed to set cpu chan map\n", __func__);
  1159. goto end;
  1160. }
  1161. }
  1162. end:
  1163. return ret;
  1164. }
  1165. static void msm_snd_shutdown(struct snd_pcm_substream *substream)
  1166. {
  1167. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  1168. substream->name, substream->stream);
  1169. }
  1170. #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98505)
  1171. static int msm226_pri_mi2s_free_gpios(void)
  1172. {
  1173. int i;
  1174. for (i = 0; i < ARRAY_SIZE(pri_mi2s_gpio); i++)
  1175. gpio_free(pri_mi2s_gpio[i].gpio_no);
  1176. return 0;
  1177. }
  1178. static struct afe_clk_cfg lpass_mi2s_enable = {
  1179. AFE_API_VERSION_I2S_CONFIG,
  1180. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  1181. Q6AFE_LPASS_OSR_CLK_12_P288_MHZ,
  1182. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  1183. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  1184. Q6AFE_LPASS_MODE_BOTH_VALID,
  1185. 0,
  1186. };
  1187. static struct afe_clk_cfg lpass_mi2s_disable = {
  1188. AFE_API_VERSION_I2S_CONFIG,
  1189. 0,
  1190. 0,
  1191. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  1192. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  1193. Q6AFE_LPASS_MODE_BOTH_VALID,
  1194. 0,
  1195. };
  1196. static void msm8226_mi2s_shutdown(struct snd_pcm_substream *substream)
  1197. {
  1198. if (atomic_dec_return(&pri_mi2s_clk.mi2s_rsc_ref) == 0) {
  1199. int ret =0;
  1200. pr_err("[MAX98504_DEBUG] %s: free mi2s resources\n", __func__);
  1201. if(substream->stream==0)
  1202. ret = afe_set_lpass_clock(AFE_PORT_ID_TERTIARY_MI2S_RX, &lpass_mi2s_disable);
  1203. else if(substream->stream==1)
  1204. ret = afe_set_lpass_clock(AFE_PORT_ID_TERTIARY_MI2S_TX, &lpass_mi2s_disable);
  1205. if (ret < 0) {
  1206. pr_err("%s: afe_set_lpass_clock failed\n", __func__);
  1207. }
  1208. msm226_pri_mi2s_free_gpios();
  1209. }
  1210. }
  1211. static int msm8226_configure_pri_mi2s_gpio(void)
  1212. {
  1213. int rtn;
  1214. int i;
  1215. for (i = 0; i < ARRAY_SIZE(pri_mi2s_gpio); i++) {
  1216. rtn = gpio_request(pri_mi2s_gpio[i].gpio_no,
  1217. pri_mi2s_gpio[i].gpio_name);
  1218. pr_info("%s: gpio = %d, gpio name = %s, rtn = %d\n", __func__,
  1219. pri_mi2s_gpio[i].gpio_no, pri_mi2s_gpio[i].gpio_name, rtn);
  1220. if (rtn) {
  1221. pr_err("%s: Failed to request gpio %d\n",
  1222. __func__,
  1223. pri_mi2s_gpio[i].gpio_no);
  1224. while( i >= 0) {
  1225. gpio_free(pri_mi2s_gpio[i].gpio_no);
  1226. i--;
  1227. }
  1228. break;
  1229. }
  1230. }
  1231. return rtn;
  1232. }
  1233. static int msm8226_mi2s_startup(struct snd_pcm_substream *substream)
  1234. {
  1235. int ret = 0;
  1236. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1237. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1238. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  1239. pr_err("%s: dai name %s %p\n", __func__, cpu_dai->name, cpu_dai->dev);
  1240. if (atomic_inc_return(&pri_mi2s_clk.mi2s_rsc_ref) == 1) {
  1241. pr_info("%s: acquire mi2s resources\n", __func__);
  1242. msm8226_configure_pri_mi2s_gpio();
  1243. if(substream->stream==0)
  1244. ret = afe_set_lpass_clock(AFE_PORT_ID_TERTIARY_MI2S_RX, &lpass_mi2s_enable);
  1245. else if(substream->stream==1)
  1246. ret = afe_set_lpass_clock(AFE_PORT_ID_TERTIARY_MI2S_TX, &lpass_mi2s_enable);
  1247. if (ret < 0) {
  1248. pr_err("%s: afe_set_lpass_clock failed\n", __func__);
  1249. return ret;
  1250. }
  1251. ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
  1252. if (ret < 0)
  1253. dev_err(cpu_dai->dev, "set format for CPU dai"
  1254. " failed\n");
  1255. ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS);
  1256. if (ret < 0)
  1257. dev_err(codec_dai->dev, "set format for codec dai"
  1258. " failed\n");
  1259. ret = 0;
  1260. }
  1261. return ret;
  1262. }
  1263. static struct snd_soc_ops msm8226_mi2s_be_ops = {
  1264. .startup = msm8226_mi2s_startup,
  1265. .shutdown = msm8226_mi2s_shutdown
  1266. };
  1267. #endif
  1268. static struct snd_soc_ops msm8226_be_ops = {
  1269. .startup = msm_snd_startup,
  1270. .hw_params = msm_snd_hw_params,
  1271. .shutdown = msm_snd_shutdown,
  1272. };
  1273. /* Digital audio interface glue - connects codec <---> CPU */
  1274. static struct snd_soc_dai_link msm8226_common_dai[] = {
  1275. /* FrontEnd DAI Links */
  1276. {
  1277. .name = "MSM8226 Media1",
  1278. .stream_name = "MultiMedia1",
  1279. .cpu_dai_name = "MultiMedia1",
  1280. .platform_name = "msm-pcm-dsp.0",
  1281. .dynamic = 1,
  1282. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1283. SND_SOC_DPCM_TRIGGER_POST},
  1284. .codec_dai_name = "snd-soc-dummy-dai",
  1285. .codec_name = "snd-soc-dummy",
  1286. .ignore_suspend = 1,
  1287. /* This dainlink has playback support */
  1288. .ignore_pmdown_time = 1,
  1289. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1
  1290. },
  1291. {
  1292. .name = "MSM8226 Media2",
  1293. .stream_name = "MultiMedia2",
  1294. .cpu_dai_name = "MultiMedia2",
  1295. .platform_name = "msm-pcm-dsp.0",
  1296. .dynamic = 1,
  1297. .codec_dai_name = "snd-soc-dummy-dai",
  1298. .codec_name = "snd-soc-dummy",
  1299. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1300. SND_SOC_DPCM_TRIGGER_POST},
  1301. .ignore_suspend = 1,
  1302. /* This dainlink has playback support */
  1303. .ignore_pmdown_time = 1,
  1304. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  1305. },
  1306. {
  1307. .name = "Circuit-Switch Voice",
  1308. .stream_name = "CS-Voice",
  1309. .cpu_dai_name = "CS-VOICE",
  1310. .platform_name = "msm-pcm-voice",
  1311. .dynamic = 1,
  1312. .codec_dai_name = "snd-soc-dummy-dai",
  1313. .codec_name = "snd-soc-dummy",
  1314. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1315. SND_SOC_DPCM_TRIGGER_POST},
  1316. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1317. .ignore_suspend = 1,
  1318. /* this dainlink has playback support */
  1319. .ignore_pmdown_time = 1,
  1320. .be_id = MSM_FRONTEND_DAI_CS_VOICE,
  1321. },
  1322. {
  1323. .name = "MSM VoIP",
  1324. .stream_name = "VoIP",
  1325. .cpu_dai_name = "VoIP",
  1326. .platform_name = "msm-voip-dsp",
  1327. .dynamic = 1,
  1328. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1329. SND_SOC_DPCM_TRIGGER_POST},
  1330. .codec_dai_name = "snd-soc-dummy-dai",
  1331. .codec_name = "snd-soc-dummy",
  1332. .ignore_suspend = 1,
  1333. /* this dainlink has playback support */
  1334. .ignore_pmdown_time = 1,
  1335. .be_id = MSM_FRONTEND_DAI_VOIP,
  1336. },
  1337. {
  1338. .name = "MSM8226 LPA",
  1339. .stream_name = "LPA",
  1340. .cpu_dai_name = "MultiMedia3",
  1341. .platform_name = "msm-pcm-lpa",
  1342. .dynamic = 1,
  1343. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1344. SND_SOC_DPCM_TRIGGER_POST},
  1345. .codec_dai_name = "snd-soc-dummy-dai",
  1346. .codec_name = "snd-soc-dummy",
  1347. .ignore_suspend = 1,
  1348. /* this dainlink has playback support */
  1349. .ignore_pmdown_time = 1,
  1350. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  1351. },
  1352. /* Hostless PCM purpose */
  1353. {
  1354. .name = "SLIMBUS_0 Hostless",
  1355. .stream_name = "SLIMBUS_0 Hostless",
  1356. .cpu_dai_name = "SLIMBUS0_HOSTLESS",
  1357. .platform_name = "msm-pcm-hostless",
  1358. .dynamic = 1,
  1359. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1360. SND_SOC_DPCM_TRIGGER_POST},
  1361. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1362. .ignore_suspend = 1,
  1363. .ignore_pmdown_time = 1, /* dai link has playback support */
  1364. .codec_dai_name = "snd-soc-dummy-dai",
  1365. .codec_name = "snd-soc-dummy",
  1366. },
  1367. {
  1368. .name = "INT_FM Hostless",
  1369. .stream_name = "INT_FM Hostless",
  1370. .cpu_dai_name = "INT_FM_HOSTLESS",
  1371. .platform_name = "msm-pcm-hostless",
  1372. .dynamic = 1,
  1373. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1374. SND_SOC_DPCM_TRIGGER_POST},
  1375. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1376. .ignore_suspend = 1,
  1377. /* this dainlink has playback support */
  1378. .ignore_pmdown_time = 1,
  1379. .codec_dai_name = "snd-soc-dummy-dai",
  1380. .codec_name = "snd-soc-dummy",
  1381. },
  1382. {
  1383. .name = "MSM AFE-PCM RX",
  1384. .stream_name = "AFE-PROXY RX",
  1385. .cpu_dai_name = "msm-dai-q6-dev.241",
  1386. .codec_name = "msm-stub-codec.1",
  1387. .codec_dai_name = "msm-stub-rx",
  1388. .platform_name = "msm-pcm-afe",
  1389. .ignore_suspend = 1,
  1390. /* this dainlink has playback support */
  1391. .ignore_pmdown_time = 1,
  1392. },
  1393. {
  1394. .name = "MSM AFE-PCM TX",
  1395. .stream_name = "AFE-PROXY TX",
  1396. .cpu_dai_name = "msm-dai-q6-dev.240",
  1397. .codec_name = "msm-stub-codec.1",
  1398. .codec_dai_name = "msm-stub-tx",
  1399. .platform_name = "msm-pcm-afe",
  1400. .ignore_suspend = 1,
  1401. },
  1402. {
  1403. .name = "MSM8226 Compr",
  1404. .stream_name = "COMPR",
  1405. .cpu_dai_name = "MultiMedia4",
  1406. .platform_name = "msm-compress-dsp",
  1407. .dynamic = 1,
  1408. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1409. SND_SOC_DPCM_TRIGGER_POST},
  1410. .codec_dai_name = "snd-soc-dummy-dai",
  1411. .codec_name = "snd-soc-dummy",
  1412. .ignore_suspend = 1,
  1413. .ignore_pmdown_time = 1,
  1414. /* this dainlink has playback support */
  1415. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  1416. },
  1417. {
  1418. .name = "AUXPCM Hostless",
  1419. .stream_name = "AUXPCM Hostless",
  1420. .cpu_dai_name = "AUXPCM_HOSTLESS",
  1421. .platform_name = "msm-pcm-hostless",
  1422. .dynamic = 1,
  1423. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1424. SND_SOC_DPCM_TRIGGER_POST},
  1425. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1426. .ignore_suspend = 1,
  1427. /* this dainlink has playback support */
  1428. .ignore_pmdown_time = 1,
  1429. .codec_dai_name = "snd-soc-dummy-dai",
  1430. .codec_name = "snd-soc-dummy",
  1431. },
  1432. {
  1433. .name = "SLIMBUS_1 Hostless",
  1434. .stream_name = "SLIMBUS_1 Hostless",
  1435. .cpu_dai_name = "SLIMBUS1_HOSTLESS",
  1436. .platform_name = "msm-pcm-hostless",
  1437. .dynamic = 1,
  1438. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1439. SND_SOC_DPCM_TRIGGER_POST},
  1440. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1441. .ignore_suspend = 1,
  1442. .ignore_pmdown_time = 1, /* dai link has playback support */
  1443. .codec_dai_name = "snd-soc-dummy-dai",
  1444. .codec_name = "snd-soc-dummy",
  1445. },
  1446. {
  1447. .name = "SLIMBUS_3 Hostless",
  1448. .stream_name = "SLIMBUS_3 Hostless",
  1449. .cpu_dai_name = "SLIMBUS3_HOSTLESS",
  1450. .platform_name = "msm-pcm-hostless",
  1451. .dynamic = 1,
  1452. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1453. SND_SOC_DPCM_TRIGGER_POST},
  1454. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1455. .ignore_suspend = 1,
  1456. .ignore_pmdown_time = 1, /* dai link has playback support */
  1457. .codec_dai_name = "snd-soc-dummy-dai",
  1458. .codec_name = "snd-soc-dummy",
  1459. },
  1460. {
  1461. .name = "SLIMBUS_4 Hostless",
  1462. .stream_name = "SLIMBUS_4 Hostless",
  1463. .cpu_dai_name = "SLIMBUS4_HOSTLESS",
  1464. .platform_name = "msm-pcm-hostless",
  1465. .dynamic = 1,
  1466. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1467. SND_SOC_DPCM_TRIGGER_POST},
  1468. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1469. .ignore_suspend = 1,
  1470. .ignore_pmdown_time = 1, /* dai link has playback support */
  1471. .codec_dai_name = "snd-soc-dummy-dai",
  1472. .codec_name = "snd-soc-dummy",
  1473. },
  1474. {
  1475. .name = "Voice2",
  1476. .stream_name = "Voice2",
  1477. .cpu_dai_name = "Voice2",
  1478. .platform_name = "msm-pcm-voice",
  1479. .dynamic = 1,
  1480. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1481. SND_SOC_DPCM_TRIGGER_POST},
  1482. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1483. .ignore_suspend = 1,
  1484. /* this dainlink has playback support */
  1485. .ignore_pmdown_time = 1,
  1486. .codec_dai_name = "snd-soc-dummy-dai",
  1487. .codec_name = "snd-soc-dummy",
  1488. },
  1489. {
  1490. .name = "MSM8226 LowLatency",
  1491. .stream_name = "MultiMedia5",
  1492. .cpu_dai_name = "MultiMedia5",
  1493. .platform_name = "msm-pcm-dsp.1",
  1494. .dynamic = 1,
  1495. .codec_dai_name = "snd-soc-dummy-dai",
  1496. .codec_name = "snd-soc-dummy",
  1497. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1498. SND_SOC_DPCM_TRIGGER_POST},
  1499. .ignore_suspend = 1,
  1500. /* this dainlink has playback support */
  1501. .ignore_pmdown_time = 1,
  1502. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  1503. },
  1504. {
  1505. .name = "MSM8226 Media9",
  1506. .stream_name = "MultiMedia9",
  1507. .cpu_dai_name = "MultiMedia9",
  1508. .platform_name = "msm-pcm-dsp.0",
  1509. .dynamic = 1,
  1510. .codec_dai_name = "snd-soc-dummy-dai",
  1511. .codec_name = "snd-soc-dummy",
  1512. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1513. SND_SOC_DPCM_TRIGGER_POST},
  1514. .ignore_suspend = 1,
  1515. /* This dailink has playback support */
  1516. .ignore_pmdown_time = 1,
  1517. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  1518. },
  1519. {
  1520. .name = "VoLTE",
  1521. .stream_name = "VoLTE",
  1522. .cpu_dai_name = "VoLTE",
  1523. .platform_name = "msm-pcm-voice",
  1524. .dynamic = 1,
  1525. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1526. SND_SOC_DPCM_TRIGGER_POST},
  1527. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1528. .ignore_suspend = 1,
  1529. /* this dainlink has playback support */
  1530. .ignore_pmdown_time = 1,
  1531. .codec_dai_name = "snd-soc-dummy-dai",
  1532. .codec_name = "snd-soc-dummy",
  1533. .be_id = MSM_FRONTEND_DAI_VOLTE,
  1534. },
  1535. {
  1536. .name = "QCHAT",
  1537. .stream_name = "QCHAT",
  1538. .cpu_dai_name = "QCHAT",
  1539. .platform_name = "msm-pcm-voice",
  1540. .dynamic = 1,
  1541. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1542. SND_SOC_DPCM_TRIGGER_POST},
  1543. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1544. .ignore_suspend = 1,
  1545. /* this dainlink has playback support */
  1546. .ignore_pmdown_time = 1,
  1547. .codec_dai_name = "snd-soc-dummy-dai",
  1548. .codec_name = "snd-soc-dummy",
  1549. .be_id = MSM_FRONTEND_DAI_QCHAT,
  1550. },
  1551. /* LSM FE */
  1552. {
  1553. .name = "Listen 1 Audio Service",
  1554. .stream_name = "Listen 1 Audio Service",
  1555. .cpu_dai_name = "LSM1",
  1556. .platform_name = "msm-lsm-client",
  1557. .dynamic = 1,
  1558. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1559. SND_SOC_DPCM_TRIGGER_POST },
  1560. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1561. .ignore_suspend = 1,
  1562. .ignore_pmdown_time = 1,
  1563. .codec_dai_name = "snd-soc-dummy-dai",
  1564. .codec_name = "snd-soc-dummy",
  1565. .be_id = MSM_FRONTEND_DAI_LSM1,
  1566. },
  1567. {
  1568. .name = "MSM8226 Compr8",
  1569. .stream_name = "COMPR8",
  1570. .cpu_dai_name = "MultiMedia8",
  1571. .platform_name = "msm-compress-dsp",
  1572. .dynamic = 1,
  1573. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1574. SND_SOC_DPCM_TRIGGER_POST},
  1575. .codec_dai_name = "snd-soc-dummy-dai",
  1576. .codec_name = "snd-soc-dummy",
  1577. .ignore_suspend = 1,
  1578. .ignore_pmdown_time = 1,
  1579. /* this dainlink has playback support */
  1580. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  1581. },
  1582. {
  1583. .name = "Listen 2 Audio Service",
  1584. .stream_name = "Listen 2 Audio Service",
  1585. .cpu_dai_name = "LSM2",
  1586. .platform_name = "msm-lsm-client",
  1587. .dynamic = 1,
  1588. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1589. SND_SOC_DPCM_TRIGGER_POST },
  1590. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1591. .ignore_suspend = 1,
  1592. .ignore_pmdown_time = 1,
  1593. .codec_dai_name = "snd-soc-dummy-dai",
  1594. .codec_name = "snd-soc-dummy",
  1595. .be_id = MSM_FRONTEND_DAI_LSM2,
  1596. },
  1597. {
  1598. .name = "Listen 3 Audio Service",
  1599. .stream_name = "Listen 3 Audio Service",
  1600. .cpu_dai_name = "LSM3",
  1601. .platform_name = "msm-lsm-client",
  1602. .dynamic = 1,
  1603. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1604. SND_SOC_DPCM_TRIGGER_POST },
  1605. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1606. .ignore_suspend = 1,
  1607. .ignore_pmdown_time = 1,
  1608. .codec_dai_name = "snd-soc-dummy-dai",
  1609. .codec_name = "snd-soc-dummy",
  1610. .be_id = MSM_FRONTEND_DAI_LSM3,
  1611. },
  1612. {
  1613. .name = "Listen 4 Audio Service",
  1614. .stream_name = "Listen 4 Audio Service",
  1615. .cpu_dai_name = "LSM4",
  1616. .platform_name = "msm-lsm-client",
  1617. .dynamic = 1,
  1618. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1619. SND_SOC_DPCM_TRIGGER_POST },
  1620. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1621. .ignore_suspend = 1,
  1622. .ignore_pmdown_time = 1,
  1623. .codec_dai_name = "snd-soc-dummy-dai",
  1624. .codec_name = "snd-soc-dummy",
  1625. .be_id = MSM_FRONTEND_DAI_LSM4,
  1626. },
  1627. {
  1628. .name = "Listen 5 Audio Service",
  1629. .stream_name = "Listen 5 Audio Service",
  1630. .cpu_dai_name = "LSM5",
  1631. .platform_name = "msm-lsm-client",
  1632. .dynamic = 1,
  1633. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1634. SND_SOC_DPCM_TRIGGER_POST },
  1635. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1636. .ignore_suspend = 1,
  1637. .ignore_pmdown_time = 1,
  1638. .codec_dai_name = "snd-soc-dummy-dai",
  1639. .codec_name = "snd-soc-dummy",
  1640. .be_id = MSM_FRONTEND_DAI_LSM5,
  1641. },
  1642. {
  1643. .name = "Listen 6 Audio Service",
  1644. .stream_name = "Listen 6 Audio Service",
  1645. .cpu_dai_name = "LSM6",
  1646. .platform_name = "msm-lsm-client",
  1647. .dynamic = 1,
  1648. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1649. SND_SOC_DPCM_TRIGGER_POST },
  1650. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1651. .ignore_suspend = 1,
  1652. .ignore_pmdown_time = 1,
  1653. .codec_dai_name = "snd-soc-dummy-dai",
  1654. .codec_name = "snd-soc-dummy",
  1655. .be_id = MSM_FRONTEND_DAI_LSM6,
  1656. },
  1657. {
  1658. .name = "Listen 7 Audio Service",
  1659. .stream_name = "Listen 7 Audio Service",
  1660. .cpu_dai_name = "LSM7",
  1661. .platform_name = "msm-lsm-client",
  1662. .dynamic = 1,
  1663. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1664. SND_SOC_DPCM_TRIGGER_POST },
  1665. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1666. .ignore_suspend = 1,
  1667. .ignore_pmdown_time = 1,
  1668. .codec_dai_name = "snd-soc-dummy-dai",
  1669. .codec_name = "snd-soc-dummy",
  1670. .be_id = MSM_FRONTEND_DAI_LSM7,
  1671. },
  1672. {
  1673. .name = "Listen 8 Audio Service",
  1674. .stream_name = "Listen 8 Audio Service",
  1675. .cpu_dai_name = "LSM8",
  1676. .platform_name = "msm-lsm-client",
  1677. .dynamic = 1,
  1678. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1679. SND_SOC_DPCM_TRIGGER_POST },
  1680. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1681. .ignore_suspend = 1,
  1682. .ignore_pmdown_time = 1,
  1683. .codec_dai_name = "snd-soc-dummy-dai",
  1684. .codec_name = "snd-soc-dummy",
  1685. .be_id = MSM_FRONTEND_DAI_LSM8,
  1686. },
  1687. {/* hw:x,28 */
  1688. .name = "INT_HFP_BT Hostless",
  1689. .stream_name = "INT_HFP_BT Hostless",
  1690. .cpu_dai_name = "INT_HFP_BT_HOSTLESS",
  1691. .platform_name = "msm-pcm-hostless",
  1692. .dynamic = 1,
  1693. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1694. SND_SOC_DPCM_TRIGGER_POST},
  1695. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1696. .ignore_suspend = 1,
  1697. /* this dai link has playback support */
  1698. .ignore_pmdown_time = 1,
  1699. .codec_dai_name = "snd-soc-dummy-dai",
  1700. .codec_name = "snd-soc-dummy",
  1701. },
  1702. {/* hw:x,29 */
  1703. .name = "MSM8226 HFP TX",
  1704. .stream_name = "MultiMedia6",
  1705. .cpu_dai_name = "MultiMedia6",
  1706. .platform_name = "msm-pcm-loopback",
  1707. .dynamic = 1,
  1708. .codec_dai_name = "snd-soc-dummy-dai",
  1709. .codec_name = "snd-soc-dummy",
  1710. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1711. SND_SOC_DPCM_TRIGGER_POST},
  1712. .ignore_suspend = 1,
  1713. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1714. /* this dai link has playback support */
  1715. .ignore_pmdown_time = 1,
  1716. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  1717. },
  1718. {/* hw:x,30 */
  1719. .name = "VoWLAN",
  1720. .stream_name = "VoWLAN",
  1721. .cpu_dai_name = "VoWLAN",
  1722. .platform_name = "msm-pcm-voice",
  1723. .dynamic = 1,
  1724. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1725. SND_SOC_DPCM_TRIGGER_POST},
  1726. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1727. .ignore_suspend = 1,
  1728. .ignore_pmdown_time = 1,
  1729. .codec_dai_name = "snd-soc-dummy-dai",
  1730. .codec_name = "snd-soc-dummy",
  1731. .be_id = MSM_FRONTEND_DAI_VOWLAN,
  1732. },
  1733. /* Backend BT/FM DAI Links */
  1734. {
  1735. .name = LPASS_BE_INT_BT_SCO_RX,
  1736. .stream_name = "Internal BT-SCO Playback",
  1737. .cpu_dai_name = "msm-dai-q6-dev.12288",
  1738. .platform_name = "msm-pcm-routing",
  1739. .codec_name = "msm-stub-codec.1",
  1740. .codec_dai_name = "msm-stub-rx",
  1741. .no_pcm = 1,
  1742. .be_id = MSM_BACKEND_DAI_INT_BT_SCO_RX,
  1743. .be_hw_params_fixup = msm_btsco_be_hw_params_fixup,
  1744. /* this dainlink has playback support */
  1745. .ignore_pmdown_time = 1,
  1746. .ignore_suspend = 1,
  1747. },
  1748. {
  1749. .name = LPASS_BE_INT_BT_SCO_TX,
  1750. .stream_name = "Internal BT-SCO Capture",
  1751. .cpu_dai_name = "msm-dai-q6-dev.12289",
  1752. .platform_name = "msm-pcm-routing",
  1753. .codec_name = "msm-stub-codec.1",
  1754. .codec_dai_name = "msm-stub-tx",
  1755. .no_pcm = 1,
  1756. .be_id = MSM_BACKEND_DAI_INT_BT_SCO_TX,
  1757. .be_hw_params_fixup = msm_btsco_be_hw_params_fixup,
  1758. .ignore_suspend = 1,
  1759. },
  1760. {
  1761. .name = LPASS_BE_INT_FM_RX,
  1762. .stream_name = "Internal FM Playback",
  1763. .cpu_dai_name = "msm-dai-q6-dev.12292",
  1764. .platform_name = "msm-pcm-routing",
  1765. .codec_name = "msm-stub-codec.1",
  1766. .codec_dai_name = "msm-stub-rx",
  1767. .no_pcm = 1,
  1768. .be_id = MSM_BACKEND_DAI_INT_FM_RX,
  1769. .be_hw_params_fixup = msm_be_fm_hw_params_fixup,
  1770. /* this dainlink has playback support */
  1771. .ignore_pmdown_time = 1,
  1772. .ignore_suspend = 1,
  1773. },
  1774. {
  1775. .name = LPASS_BE_INT_FM_TX,
  1776. .stream_name = "Internal FM Capture",
  1777. .cpu_dai_name = "msm-dai-q6-dev.12293",
  1778. .platform_name = "msm-pcm-routing",
  1779. .codec_name = "msm-stub-codec.1",
  1780. .codec_dai_name = "msm-stub-tx",
  1781. .no_pcm = 1,
  1782. .be_id = MSM_BACKEND_DAI_INT_FM_TX,
  1783. .be_hw_params_fixup = msm_be_hw_params_fixup,
  1784. .ignore_suspend = 1,
  1785. },
  1786. /* Backend AFE DAI Links */
  1787. {
  1788. .name = LPASS_BE_AFE_PCM_RX,
  1789. .stream_name = "AFE Playback",
  1790. .cpu_dai_name = "msm-dai-q6-dev.224",
  1791. .platform_name = "msm-pcm-routing",
  1792. .codec_name = "msm-stub-codec.1",
  1793. .codec_dai_name = "msm-stub-rx",
  1794. .no_pcm = 1,
  1795. .be_id = MSM_BACKEND_DAI_AFE_PCM_RX,
  1796. .be_hw_params_fixup = msm_proxy_rx_be_hw_params_fixup,
  1797. /* this dainlink has playback support */
  1798. .ignore_pmdown_time = 1,
  1799. .ignore_suspend = 1,
  1800. },
  1801. {
  1802. .name = LPASS_BE_AFE_PCM_TX,
  1803. .stream_name = "AFE Capture",
  1804. .cpu_dai_name = "msm-dai-q6-dev.225",
  1805. .platform_name = "msm-pcm-routing",
  1806. .codec_name = "msm-stub-codec.1",
  1807. .codec_dai_name = "msm-stub-tx",
  1808. .no_pcm = 1,
  1809. .be_id = MSM_BACKEND_DAI_AFE_PCM_TX,
  1810. .be_hw_params_fixup = msm_proxy_tx_be_hw_params_fixup,
  1811. .ignore_suspend = 1,
  1812. },
  1813. #ifdef CONFIG_JACK_AUDIO
  1814. {
  1815. .name = "MSM8974 JACK LowLatency",
  1816. .stream_name = "MultiMedia10",
  1817. .cpu_dai_name = "MultiMedia10",
  1818. .platform_name = "msm-pcm-dsp.1",
  1819. .dynamic = 1,
  1820. .codec_dai_name = "snd-soc-dummy-dai",
  1821. .codec_name = "snd-soc-dummy",
  1822. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1823. SND_SOC_DPCM_TRIGGER_POST},
  1824. .ignore_suspend = 1,
  1825. /* this dainlink has playback support */
  1826. .ignore_pmdown_time = 1,
  1827. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  1828. },
  1829. #endif
  1830. /* HDMI Hostless */
  1831. {
  1832. .name = "HDMI_RX_HOSTLESS",
  1833. .stream_name = "HDMI_RX_HOSTLESS",
  1834. .cpu_dai_name = "HDMI_HOSTLESS",
  1835. .platform_name = "msm-pcm-hostless",
  1836. .dynamic = 1,
  1837. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1838. SND_SOC_DPCM_TRIGGER_POST},
  1839. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1840. .ignore_suspend = 1,
  1841. .ignore_pmdown_time = 1,
  1842. .codec_dai_name = "snd-soc-dummy-dai",
  1843. .codec_name = "snd-soc-dummy",
  1844. },
  1845. /* AUX PCM Backend DAI Links */
  1846. {
  1847. .name = LPASS_BE_AUXPCM_RX,
  1848. .stream_name = "AUX PCM Playback",
  1849. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  1850. .platform_name = "msm-pcm-routing",
  1851. .codec_name = "msm-stub-codec.1",
  1852. .codec_dai_name = "msm-stub-rx",
  1853. .no_pcm = 1,
  1854. .be_id = MSM_BACKEND_DAI_AUXPCM_RX,
  1855. .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
  1856. .ops = &msm_auxpcm_be_ops,
  1857. .ignore_pmdown_time = 1,
  1858. .ignore_suspend = 1
  1859. /* this dainlink has playback support */
  1860. },
  1861. {
  1862. .name = LPASS_BE_AUXPCM_TX,
  1863. .stream_name = "AUX PCM Capture",
  1864. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  1865. .platform_name = "msm-pcm-routing",
  1866. .codec_name = "msm-stub-codec.1",
  1867. .codec_dai_name = "msm-stub-tx",
  1868. .no_pcm = 1,
  1869. .be_id = MSM_BACKEND_DAI_AUXPCM_TX,
  1870. .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
  1871. .ops = &msm_auxpcm_be_ops,
  1872. .ignore_suspend = 1
  1873. },
  1874. /* Incall Record Uplink BACK END DAI Link */
  1875. {
  1876. .name = LPASS_BE_INCALL_RECORD_TX,
  1877. .stream_name = "Voice Uplink Capture",
  1878. .cpu_dai_name = "msm-dai-q6-dev.32772",
  1879. .platform_name = "msm-pcm-routing",
  1880. .codec_name = "msm-stub-codec.1",
  1881. .codec_dai_name = "msm-stub-tx",
  1882. .no_pcm = 1,
  1883. .be_id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  1884. .be_hw_params_fixup = msm_be_hw_params_fixup,
  1885. .ignore_suspend = 1,
  1886. },
  1887. /* Incall Record Downlink BACK END DAI Link */
  1888. {
  1889. .name = LPASS_BE_INCALL_RECORD_RX,
  1890. .stream_name = "Voice Downlink Capture",
  1891. .cpu_dai_name = "msm-dai-q6-dev.32771",
  1892. .platform_name = "msm-pcm-routing",
  1893. .codec_name = "msm-stub-codec.1",
  1894. .codec_dai_name = "msm-stub-tx",
  1895. .no_pcm = 1,
  1896. .be_id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  1897. .be_hw_params_fixup = msm_be_hw_params_fixup,
  1898. .ignore_suspend = 1,
  1899. },
  1900. /* Incall Music BACK END DAI Link */
  1901. {
  1902. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  1903. .stream_name = "Voice Farend Playback",
  1904. .cpu_dai_name = "msm-dai-q6-dev.32773",
  1905. .platform_name = "msm-pcm-routing",
  1906. .codec_name = "msm-stub-codec.1",
  1907. .codec_dai_name = "msm-stub-rx",
  1908. .no_pcm = 1,
  1909. .be_id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  1910. .be_hw_params_fixup = msm_be_hw_params_fixup,
  1911. .ignore_suspend = 1,
  1912. },
  1913. /* Incall Music 2 BACK END DAI Link */
  1914. {
  1915. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  1916. .stream_name = "Voice2 Farend Playback",
  1917. .cpu_dai_name = "msm-dai-q6-dev.32770",
  1918. .platform_name = "msm-pcm-routing",
  1919. .codec_name = "msm-stub-codec.1",
  1920. .codec_dai_name = "msm-stub-rx",
  1921. .no_pcm = 1,
  1922. .be_id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  1923. .be_hw_params_fixup = msm_be_hw_params_fixup,
  1924. .ignore_suspend = 1,
  1925. },
  1926. };
  1927. static struct snd_soc_dai_link msm8226_9306_dai[] = {
  1928. /* Backend DAI Links */
  1929. {
  1930. .name = LPASS_BE_SLIMBUS_0_RX,
  1931. .stream_name = "Slimbus Playback",
  1932. .cpu_dai_name = "msm-dai-q6-dev.16384",
  1933. .platform_name = "msm-pcm-routing",
  1934. .codec_name = "tapan_codec",
  1935. .codec_dai_name = "tapan_rx1",
  1936. .no_pcm = 1,
  1937. .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  1938. .init = &msm_audrx_init,
  1939. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  1940. .ops = &msm8226_be_ops,
  1941. .ignore_pmdown_time = 1, /* dai link has playback support */
  1942. .ignore_suspend = 1,
  1943. },
  1944. {
  1945. .name = LPASS_BE_SLIMBUS_0_TX,
  1946. .stream_name = "Slimbus Capture",
  1947. .cpu_dai_name = "msm-dai-q6-dev.16385",
  1948. .platform_name = "msm-pcm-routing",
  1949. .codec_name = "tapan_codec",
  1950. .codec_dai_name = "tapan_tx1",
  1951. .no_pcm = 1,
  1952. .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  1953. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  1954. .ops = &msm8226_be_ops,
  1955. .ignore_suspend = 1,
  1956. },
  1957. {
  1958. .name = LPASS_BE_SLIMBUS_1_RX,
  1959. .stream_name = "Slimbus1 Playback",
  1960. .cpu_dai_name = "msm-dai-q6-dev.16386",
  1961. .platform_name = "msm-pcm-routing",
  1962. .codec_name = "tapan_codec",
  1963. .codec_dai_name = "tapan_rx1",
  1964. .no_pcm = 1,
  1965. .be_id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  1966. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  1967. .ops = &msm8226_be_ops,
  1968. /* dai link has playback support */
  1969. .ignore_pmdown_time = 1,
  1970. .ignore_suspend = 1,
  1971. },
  1972. {
  1973. .name = LPASS_BE_SLIMBUS_1_TX,
  1974. .stream_name = "Slimbus1 Capture",
  1975. .cpu_dai_name = "msm-dai-q6-dev.16387",
  1976. .platform_name = "msm-pcm-routing",
  1977. .codec_name = "tapan_codec",
  1978. .codec_dai_name = "tapan_tx1",
  1979. .no_pcm = 1,
  1980. .be_id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  1981. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  1982. .ops = &msm8226_be_ops,
  1983. .ignore_suspend = 1,
  1984. },
  1985. {
  1986. .name = LPASS_BE_SLIMBUS_3_RX,
  1987. .stream_name = "Slimbus3 Playback",
  1988. .cpu_dai_name = "msm-dai-q6-dev.16390",
  1989. .platform_name = "msm-pcm-routing",
  1990. .codec_name = "tapan_codec",
  1991. .codec_dai_name = "tapan_rx1",
  1992. .no_pcm = 1,
  1993. .be_id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  1994. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  1995. .ops = &msm8226_be_ops,
  1996. /* dai link has playback support */
  1997. .ignore_pmdown_time = 1,
  1998. .ignore_suspend = 1,
  1999. },
  2000. {
  2001. .name = LPASS_BE_SLIMBUS_3_TX,
  2002. .stream_name = "Slimbus3 Capture",
  2003. .cpu_dai_name = "msm-dai-q6-dev.16391",
  2004. .platform_name = "msm-pcm-routing",
  2005. .codec_name = "tapan_codec",
  2006. .codec_dai_name = "tapan_tx1",
  2007. .no_pcm = 1,
  2008. .be_id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  2009. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2010. .ops = &msm8226_be_ops,
  2011. .ignore_suspend = 1,
  2012. },
  2013. {
  2014. .name = LPASS_BE_SLIMBUS_4_RX,
  2015. .stream_name = "Slimbus4 Playback",
  2016. .cpu_dai_name = "msm-dai-q6-dev.16392",
  2017. .platform_name = "msm-pcm-routing",
  2018. .codec_name = "tapan_codec",
  2019. .codec_dai_name = "tapan_rx1",
  2020. .no_pcm = 1,
  2021. .be_id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  2022. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2023. .ops = &msm8226_be_ops,
  2024. /* dai link has playback support */
  2025. .ignore_pmdown_time = 1,
  2026. .ignore_suspend = 1,
  2027. },
  2028. {
  2029. .name = LPASS_BE_SLIMBUS_4_TX,
  2030. .stream_name = "Slimbus4 Capture",
  2031. .cpu_dai_name = "msm-dai-q6-dev.16393",
  2032. .platform_name = "msm-pcm-routing",
  2033. .codec_name = "tapan_codec",
  2034. .codec_dai_name = "tapan_tx1",
  2035. .no_pcm = 1,
  2036. .be_id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  2037. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2038. .ops = &msm8226_be_ops,
  2039. .ignore_suspend = 1,
  2040. },
  2041. {
  2042. .name = LPASS_BE_SLIMBUS_5_TX,
  2043. .stream_name = "Slimbus5 Capture",
  2044. .cpu_dai_name = "msm-dai-q6-dev.16395",
  2045. .platform_name = "msm-pcm-routing",
  2046. .codec_name = "tapan_codec",
  2047. .codec_dai_name = "tapan_tx1",
  2048. .no_pcm = 1,
  2049. .be_id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
  2050. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2051. .ops = &msm8226_be_ops,
  2052. .ignore_suspend = 1,
  2053. },
  2054. };
  2055. static struct snd_soc_dai_link msm8226_9302_dai[] = {
  2056. /* Backend DAI Links */
  2057. {
  2058. .name = LPASS_BE_SLIMBUS_0_RX,
  2059. .stream_name = "Slimbus Playback",
  2060. .cpu_dai_name = "msm-dai-q6-dev.16384",
  2061. .platform_name = "msm-pcm-routing",
  2062. .codec_name = "tapan_codec",
  2063. .codec_dai_name = "tapan9302_rx1",
  2064. .no_pcm = 1,
  2065. .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  2066. .init = &msm_audrx_init,
  2067. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2068. .ops = &msm8226_be_ops,
  2069. .ignore_pmdown_time = 1, /* dai link has playback support */
  2070. .ignore_suspend = 1,
  2071. },
  2072. {
  2073. .name = LPASS_BE_SLIMBUS_0_TX,
  2074. .stream_name = "Slimbus Capture",
  2075. .cpu_dai_name = "msm-dai-q6-dev.16385",
  2076. .platform_name = "msm-pcm-routing",
  2077. .codec_name = "tapan_codec",
  2078. .codec_dai_name = "tapan9302_tx1",
  2079. .no_pcm = 1,
  2080. .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  2081. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2082. .ops = &msm8226_be_ops,
  2083. .ignore_suspend = 1,
  2084. },
  2085. {
  2086. .name = LPASS_BE_SLIMBUS_1_RX,
  2087. .stream_name = "Slimbus1 Playback",
  2088. .cpu_dai_name = "msm-dai-q6-dev.16386",
  2089. .platform_name = "msm-pcm-routing",
  2090. .codec_name = "tapan_codec",
  2091. .codec_dai_name = "tapan9302_rx1",
  2092. .no_pcm = 1,
  2093. .be_id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  2094. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2095. .ops = &msm8226_be_ops,
  2096. /* dai link has playback support */
  2097. .ignore_pmdown_time = 1,
  2098. .ignore_suspend = 1,
  2099. },
  2100. {
  2101. .name = LPASS_BE_SLIMBUS_1_TX,
  2102. .stream_name = "Slimbus1 Capture",
  2103. .cpu_dai_name = "msm-dai-q6-dev.16387",
  2104. .platform_name = "msm-pcm-routing",
  2105. .codec_name = "tapan_codec",
  2106. .codec_dai_name = "tapan9302_tx1",
  2107. .no_pcm = 1,
  2108. .be_id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  2109. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2110. .ops = &msm8226_be_ops,
  2111. .ignore_suspend = 1,
  2112. },
  2113. {
  2114. .name = LPASS_BE_SLIMBUS_3_RX,
  2115. .stream_name = "Slimbus3 Playback",
  2116. .cpu_dai_name = "msm-dai-q6-dev.16390",
  2117. .platform_name = "msm-pcm-routing",
  2118. .codec_name = "tapan_codec",
  2119. .codec_dai_name = "tapan9302_rx1",
  2120. .no_pcm = 1,
  2121. .be_id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  2122. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2123. .ops = &msm8226_be_ops,
  2124. /* dai link has playback support */
  2125. .ignore_pmdown_time = 1,
  2126. .ignore_suspend = 1,
  2127. },
  2128. {
  2129. .name = LPASS_BE_SLIMBUS_3_TX,
  2130. .stream_name = "Slimbus3 Capture",
  2131. .cpu_dai_name = "msm-dai-q6-dev.16391",
  2132. .platform_name = "msm-pcm-routing",
  2133. .codec_name = "tapan_codec",
  2134. .codec_dai_name = "tapan9302_tx1",
  2135. .no_pcm = 1,
  2136. .be_id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  2137. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2138. .ops = &msm8226_be_ops,
  2139. .ignore_suspend = 1,
  2140. },
  2141. {
  2142. .name = LPASS_BE_SLIMBUS_4_RX,
  2143. .stream_name = "Slimbus4 Playback",
  2144. .cpu_dai_name = "msm-dai-q6-dev.16392",
  2145. .platform_name = "msm-pcm-routing",
  2146. .codec_name = "tapan_codec",
  2147. .codec_dai_name = "tapan9302_rx1",
  2148. .no_pcm = 1,
  2149. .be_id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  2150. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2151. .ops = &msm8226_be_ops,
  2152. /* dai link has playback support */
  2153. .ignore_pmdown_time = 1,
  2154. .ignore_suspend = 1,
  2155. },
  2156. {
  2157. .name = LPASS_BE_SLIMBUS_4_TX,
  2158. .stream_name = "Slimbus4 Capture",
  2159. .cpu_dai_name = "msm-dai-q6-dev.16393",
  2160. .platform_name = "msm-pcm-routing",
  2161. .codec_name = "tapan_codec",
  2162. .codec_dai_name = "tapan9302_tx1",
  2163. .no_pcm = 1,
  2164. .be_id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  2165. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2166. .ops = &msm8226_be_ops,
  2167. .ignore_suspend = 1,
  2168. },
  2169. {
  2170. .name = LPASS_BE_SLIMBUS_5_TX,
  2171. .stream_name = "Slimbus5 Capture",
  2172. .cpu_dai_name = "msm-dai-q6-dev.16395",
  2173. .platform_name = "msm-pcm-routing",
  2174. .codec_name = "tapan_codec",
  2175. .codec_dai_name = "tapan9302_tx1",
  2176. .no_pcm = 1,
  2177. .be_id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
  2178. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2179. .ops = &msm8226_be_ops,
  2180. .ignore_suspend = 1,
  2181. },
  2182. };
  2183. static struct snd_soc_dai_link msm8226_9306_dai_links[
  2184. ARRAY_SIZE(msm8226_common_dai) +
  2185. ARRAY_SIZE(msm8226_9306_dai)];
  2186. static struct snd_soc_dai_link msm8226_9302_dai_links[
  2187. ARRAY_SIZE(msm8226_common_dai) +
  2188. ARRAY_SIZE(msm8226_9302_dai)];
  2189. #ifdef CONFIG_SND_SOC_MAX98504
  2190. static struct snd_soc_dai_link msm8226_max98504_dai[] = {
  2191. {
  2192. .name = LPASS_BE_TERT_MI2S_TX,
  2193. .stream_name = "Tertiary MI2S Capture",
  2194. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  2195. .platform_name = "msm-pcm-routing",
  2196. .codec_name = "max98504.6-0031",//"msm-stub-codec.1",
  2197. .codec_dai_name = "max98504-aif1",//"msm-stub-tx",
  2198. .no_pcm = 1,
  2199. .be_id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  2200. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2201. .ops = &msm8226_mi2s_be_ops,
  2202. },
  2203. };
  2204. static struct snd_soc_dai_link msm8226_9306_98504_dai_links[
  2205. ARRAY_SIZE(msm8226_common_dai) +
  2206. ARRAY_SIZE(msm8226_9306_dai) +
  2207. ARRAY_SIZE(msm8226_max98504_dai)];
  2208. struct snd_soc_card snd_soc_card_msm8226_new = {
  2209. .name = "msm8226-tapan-snd-card",
  2210. .dai_link = msm8226_9306_98504_dai_links,
  2211. .num_links = ARRAY_SIZE(msm8226_9306_98504_dai_links),
  2212. };
  2213. #endif
  2214. #ifdef CONFIG_SND_SOC_MAX98505
  2215. static struct snd_soc_dai_link msm8226_max98505_dai[] = {
  2216. {
  2217. .name = LPASS_BE_TERT_MI2S_TX,
  2218. .stream_name = "Tertiary MI2S Capture",
  2219. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  2220. .platform_name = "msm-pcm-routing",
  2221. .codec_name = "max98505.3-0031",//"msm-stub-codec.1"
  2222. .codec_dai_name = "max98505-aif1",//"msm-stub-tx",
  2223. .no_pcm = 1,
  2224. .be_id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  2225. .be_hw_params_fixup = msm_mi2s_be_hw_params_fixup,
  2226. .ops = &msm8226_mi2s_be_ops,
  2227. },
  2228. {
  2229. .name = LPASS_BE_TERT_MI2S_RX,
  2230. .stream_name = "Tertiary MI2S Playback",
  2231. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  2232. .platform_name = "msm-pcm-routing",
  2233. .codec_name = "max98505.3-0031",//"msm-stub-codec.1"
  2234. .codec_dai_name = "max98505-aif1",//"msm-stub-tx",
  2235. .no_pcm = 1,
  2236. .be_id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  2237. .be_hw_params_fixup = msm_mi2s_be_hw_params_fixup,
  2238. .ops = &msm8226_mi2s_be_ops,
  2239. },
  2240. };
  2241. static struct snd_soc_dai_link msm8226_9306_98505_dai_links[
  2242. ARRAY_SIZE(msm8226_common_dai) +
  2243. ARRAY_SIZE(msm8226_9306_dai) +
  2244. ARRAY_SIZE(msm8226_max98505_dai)];
  2245. struct snd_soc_card snd_soc_card_msm8226_new = {
  2246. .name = "msm8226-tapan-snd-card",
  2247. .dai_link = msm8226_9306_98505_dai_links,
  2248. .num_links = ARRAY_SIZE(msm8226_9306_98505_dai_links),
  2249. };
  2250. #endif
  2251. struct snd_soc_card snd_soc_card_msm8226 = {
  2252. .name = "msm8226-tapan-snd-card",
  2253. .dai_link = msm8226_9306_dai_links,
  2254. .num_links = ARRAY_SIZE(msm8226_9306_dai_links),
  2255. };
  2256. struct snd_soc_card snd_soc_card_9302_msm8226 = {
  2257. .name = "msm8226-tapan9302-snd-card",
  2258. .dai_link = msm8226_9302_dai_links,
  2259. .num_links = ARRAY_SIZE(msm8226_9302_dai_links),
  2260. };
  2261. static int msm8226_dtparse_auxpcm(struct platform_device *pdev,
  2262. struct msm_auxpcm_ctrl **auxpcm_ctrl,
  2263. char *msm_auxpcm_gpio_name[][2])
  2264. {
  2265. int ret = 0;
  2266. int i = 0;
  2267. struct msm_auxpcm_gpio *pin_data = NULL;
  2268. struct msm_auxpcm_ctrl *ctrl;
  2269. unsigned int gpio_no[NUM_OF_AUXPCM_GPIOS];
  2270. enum of_gpio_flags flags = OF_GPIO_ACTIVE_LOW;
  2271. int auxpcm_cnt = 0;
  2272. pin_data = devm_kzalloc(&pdev->dev, (ARRAY_SIZE(gpio_no) *
  2273. sizeof(struct msm_auxpcm_gpio)),
  2274. GFP_KERNEL);
  2275. if (!pin_data) {
  2276. dev_err(&pdev->dev, "No memory for gpio\n");
  2277. ret = -ENOMEM;
  2278. goto err;
  2279. }
  2280. for (i = 0; i < ARRAY_SIZE(gpio_no); i++) {
  2281. gpio_no[i] = of_get_named_gpio_flags(pdev->dev.of_node,
  2282. msm_auxpcm_gpio_name[i][DT_PARSE_INDEX],
  2283. 0, &flags);
  2284. if (gpio_no[i] > 0) {
  2285. pin_data[i].gpio_name =
  2286. msm_auxpcm_gpio_name[auxpcm_cnt][GPIO_NAME_INDEX];
  2287. pin_data[i].gpio_no = gpio_no[i];
  2288. dev_dbg(&pdev->dev, "%s:GPIO gpio[%s] =\n"
  2289. "0x%x\n", __func__,
  2290. pin_data[i].gpio_name,
  2291. pin_data[i].gpio_no);
  2292. auxpcm_cnt++;
  2293. } else {
  2294. dev_err(&pdev->dev, "%s:Invalid AUXPCM GPIO[%s]= %x\n",
  2295. __func__,
  2296. msm_auxpcm_gpio_name[i][GPIO_NAME_INDEX],
  2297. gpio_no[i]);
  2298. ret = -ENODEV;
  2299. goto err;
  2300. }
  2301. }
  2302. ctrl = devm_kzalloc(&pdev->dev,
  2303. sizeof(struct msm_auxpcm_ctrl), GFP_KERNEL);
  2304. if (!ctrl) {
  2305. dev_err(&pdev->dev, "No memory for gpio\n");
  2306. ret = -ENOMEM;
  2307. goto err;
  2308. }
  2309. ctrl->pin_data = pin_data;
  2310. ctrl->cnt = auxpcm_cnt;
  2311. *auxpcm_ctrl = ctrl;
  2312. return ret;
  2313. err:
  2314. if (pin_data)
  2315. devm_kfree(&pdev->dev, pin_data);
  2316. return ret;
  2317. }
  2318. static int msm8226_prepare_codec_mclk(struct snd_soc_card *card)
  2319. {
  2320. struct msm8226_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  2321. if (pdata->mclk_gpio) {
  2322. int ret;
  2323. ret = gpio_request(pdata->mclk_gpio, "TAPAN_CODEC_PMIC_MCLK");
  2324. if (ret) {
  2325. dev_err(card->dev,
  2326. "%s: Failed to request tapan mclk gpio %d\n",
  2327. __func__, pdata->mclk_gpio);
  2328. return ret;
  2329. }
  2330. }
  2331. return 0;
  2332. }
  2333. //Enabling the MIC Bias Voltage of Earmic
  2334. #ifdef CONFIG_SAMSUNG_JACK
  2335. static bool dapm_force_enable_flag = false;
  2336. static struct snd_soc_jack hs_jack;
  2337. void msm8226_enable_ear_micbias(bool state)
  2338. {
  2339. int nRetVal = 0;
  2340. struct snd_soc_jack *jack = &hs_jack;
  2341. struct snd_soc_codec *codec;
  2342. struct snd_soc_dapm_context *dapm;
  2343. char *str
  2344. #ifdef CONFIG_EXT_EARMIC_BIAS
  2345. = "Headset Mic";
  2346. #else
  2347. = "MIC BIAS2 Power External";
  2348. #endif
  2349. printk("%s : str: %s\n", __func__, str);
  2350. if (jack->codec == NULL) { /* audrx_init not yet called */
  2351. pr_err("%s codec==NULL\n", __func__);
  2352. return;
  2353. }
  2354. codec = jack->codec;
  2355. dapm = &codec->dapm;
  2356. mutex_lock(&jack_mutex);
  2357. if (state == 1) {
  2358. if(!dapm_force_enable_flag){
  2359. nRetVal = snd_soc_dapm_force_enable_pin(dapm, str);
  2360. pr_info("%s enable the codec pin : %d with state :%d\n"
  2361. , __func__, nRetVal, state);
  2362. dapm_force_enable_flag = true;
  2363. }else {
  2364. pr_err ("snd_soc_dapm_force_enable_pin(MIC BIAS2 Power External) already enabled, ref_count = %d \n"
  2365. ,dapm_force_enable_flag);
  2366. }
  2367. } else{
  2368. if (dapm_force_enable_flag) {
  2369. nRetVal = snd_soc_dapm_disable_pin(dapm, str);
  2370. pr_info("%s disable the codec pin : %d with state :%d\n"
  2371. , __func__, nRetVal, state);
  2372. dapm_force_enable_flag = false;
  2373. } else {
  2374. pr_err ("snd_soc_dapm_force_enable_pin is still needed, do not turn off\n");
  2375. }
  2376. }
  2377. snd_soc_dapm_sync(dapm);
  2378. mutex_unlock(&jack_mutex);
  2379. }
  2380. EXPORT_SYMBOL(msm8226_enable_ear_micbias);
  2381. #endif
  2382. #ifndef CONFIG_SAMSUNG_JACK //ms01 mbhc not used
  2383. static bool msm8226_swap_gnd_mic(struct snd_soc_codec *codec)
  2384. {
  2385. struct snd_soc_card *card = codec->card;
  2386. struct msm8226_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  2387. int value = gpio_get_value_cansleep(pdata->us_euro_gpio);
  2388. pr_debug("%s: swap select switch %d to %d\n", __func__, value, !value);
  2389. gpio_direction_output(pdata->us_euro_gpio, !value);
  2390. return true;
  2391. }
  2392. #endif //CONFIG_SAMSUNG_JACK
  2393. static int msm8226_setup_hs_jack(struct platform_device *pdev,
  2394. struct msm8226_asoc_mach_data *pdata)
  2395. {
  2396. #ifndef CONFIG_SAMSUNG_JACK //ms01 mbhc not used
  2397. pdata->us_euro_gpio = of_get_named_gpio(pdev->dev.of_node,
  2398. "qcom,cdc-us-euro-gpios", 0);
  2399. if (pdata->us_euro_gpio < 0) {
  2400. dev_dbg(&pdev->dev,
  2401. "property %s in node %s not found %d\n",
  2402. "qcom,cdc-us-euro-gpios", pdev->dev.of_node->full_name,
  2403. pdata->us_euro_gpio);
  2404. } else {
  2405. int rc;
  2406. rc = gpio_request(pdata->us_euro_gpio,
  2407. "TAPAN_CODEC_US_EURO_GPIO");
  2408. if (rc) {
  2409. dev_err(&pdev->dev,
  2410. "%s: Failed to request tapan us-euro gpio %d\n",
  2411. __func__, pdata->us_euro_gpio);
  2412. } else {
  2413. mbhc_cfg.swap_gnd_mic = msm8226_swap_gnd_mic;
  2414. }
  2415. }
  2416. #endif
  2417. return 0;
  2418. }
  2419. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  2420. {
  2421. struct snd_soc_card *card;
  2422. if (of_property_read_bool(dev->of_node,
  2423. "qcom,tapan-codec-9302")) {
  2424. card = &snd_soc_card_9302_msm8226;
  2425. memcpy(msm8226_9302_dai_links, msm8226_common_dai,
  2426. sizeof(msm8226_common_dai));
  2427. memcpy(msm8226_9302_dai_links + ARRAY_SIZE(msm8226_common_dai),
  2428. msm8226_9302_dai, sizeof(msm8226_9302_dai));
  2429. } else {
  2430. #ifdef CONFIG_SND_SOC_MAX98504
  2431. extern int system_rev;
  2432. #if defined(CONFIG_MACH_MILLETLTE_OPEN) || defined(CONFIG_MACH_MILLETLTE_KOR)
  2433. if ( system_rev >= 0 && system_rev < 3)
  2434. #elif defined (CONFIG_MACH_MILLET3G_EUR) || defined (CONFIG_MACH_BERLUTI3G_EUR)
  2435. if ( system_rev >= 2 && system_rev < 4)
  2436. #elif defined(CONFIG_MACH_MILLETWIFI_OPEN) || defined (CONFIG_MACH_VICTORLTE_CMCC)
  2437. if ( system_rev >= 0 && system_rev < 5)
  2438. #endif
  2439. {
  2440. card = &snd_soc_card_msm8226_new;
  2441. memcpy(msm8226_9306_98504_dai_links, msm8226_common_dai,
  2442. sizeof(msm8226_common_dai));
  2443. memcpy(msm8226_9306_98504_dai_links + ARRAY_SIZE(msm8226_common_dai),
  2444. msm8226_9306_dai, sizeof(msm8226_9306_dai));
  2445. memcpy(msm8226_9306_98504_dai_links + ARRAY_SIZE(msm8226_common_dai)+ ARRAY_SIZE(msm8226_9306_dai),
  2446. msm8226_max98504_dai, sizeof(msm8226_max98504_dai));
  2447. }
  2448. else {
  2449. #endif
  2450. #ifdef CONFIG_SND_SOC_MAX98505
  2451. card = &snd_soc_card_msm8226_new;
  2452. memcpy(msm8226_9306_98505_dai_links, msm8226_common_dai,
  2453. sizeof(msm8226_common_dai));
  2454. memcpy(msm8226_9306_98505_dai_links + ARRAY_SIZE(msm8226_common_dai),
  2455. msm8226_9306_dai, sizeof(msm8226_9306_dai));
  2456. memcpy(msm8226_9306_98505_dai_links + ARRAY_SIZE(msm8226_common_dai)+ ARRAY_SIZE(msm8226_9306_dai),
  2457. msm8226_max98505_dai, sizeof(msm8226_max98505_dai));
  2458. #else
  2459. card = &snd_soc_card_msm8226;
  2460. memcpy(msm8226_9306_dai_links, msm8226_common_dai,
  2461. sizeof(msm8226_common_dai));
  2462. memcpy(msm8226_9306_dai_links + ARRAY_SIZE(msm8226_common_dai),
  2463. msm8226_9306_dai, sizeof(msm8226_9306_dai));
  2464. #endif
  2465. #ifdef CONFIG_SND_SOC_MAX98504
  2466. }
  2467. #endif
  2468. }
  2469. return card;
  2470. }
  2471. static __devinit int msm8226_asoc_machine_probe(struct platform_device *pdev)
  2472. {
  2473. struct snd_soc_card *card;
  2474. struct msm8226_asoc_mach_data *pdata;
  2475. int ret;
  2476. const char *auxpcm_pri_gpio_set = NULL;
  2477. const char *mbhc_audio_jack_type = NULL;
  2478. size_t n = strlen("4-pole-jack");
  2479. struct device_node *reg_node = NULL;
  2480. if (!pdev->dev.of_node) {
  2481. dev_err(&pdev->dev, "No platform supplied from device tree\n");
  2482. return -EINVAL;
  2483. }
  2484. pdata = devm_kzalloc(&pdev->dev,
  2485. sizeof(struct msm8226_asoc_mach_data), GFP_KERNEL);
  2486. if (!pdata) {
  2487. dev_err(&pdev->dev, "Can't allocate msm8226_asoc_mach_data\n");
  2488. ret = -ENOMEM;
  2489. goto err1;
  2490. }
  2491. card = populate_snd_card_dailinks(&pdev->dev);
  2492. card->dev = &pdev->dev;
  2493. platform_set_drvdata(pdev, card);
  2494. snd_soc_card_set_drvdata(card, pdata);
  2495. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  2496. if (ret)
  2497. goto err;
  2498. ret = snd_soc_of_parse_audio_routing(card,
  2499. "qcom,audio-routing");
  2500. if (ret)
  2501. goto err;
  2502. ret = of_property_read_u32(pdev->dev.of_node,
  2503. "qcom,tapan-mclk-clk-freq", &pdata->mclk_freq);
  2504. if (ret) {
  2505. dev_err(&pdev->dev, "Looking up %s property in node %s failed",
  2506. "qcom,tapan-mclk-clk-freq",
  2507. pdev->dev.of_node->full_name);
  2508. goto err;
  2509. }
  2510. if (pdata->mclk_freq != 9600000) {
  2511. dev_err(&pdev->dev, "unsupported tapan mclk freq %u\n",
  2512. pdata->mclk_freq);
  2513. ret = -EINVAL;
  2514. goto err;
  2515. }
  2516. pdata->mclk_gpio = of_get_named_gpio(pdev->dev.of_node,
  2517. "qcom,cdc-mclk-gpios", 0);
  2518. if (pdata->mclk_gpio < 0) {
  2519. dev_err(&pdev->dev,
  2520. "Looking up %s property in node %s failed %d\n",
  2521. "qcom, cdc-mclk-gpios", pdev->dev.of_node->full_name,
  2522. pdata->mclk_gpio);
  2523. ret = -ENODEV;
  2524. goto err;
  2525. }
  2526. ret = msm8226_prepare_codec_mclk(card);
  2527. if (ret)
  2528. goto err;
  2529. mutex_init(&cdc_mclk_mutex);
  2530. mutex_init(&jack_mutex);
  2531. mbhc_cfg.gpio_level_insert = of_property_read_bool(pdev->dev.of_node,
  2532. "qcom,headset-jack-type-NC");
  2533. ret = of_property_read_string(pdev->dev.of_node,
  2534. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  2535. if (ret) {
  2536. dev_dbg(&pdev->dev, "Looking up %s property in node %s failed",
  2537. "qcom,mbhc-audio-jack-type",
  2538. pdev->dev.of_node->full_name);
  2539. mbhc_cfg.hw_jack_type = FOUR_POLE_JACK;
  2540. mbhc_cfg.enable_anc_mic_detect = false;
  2541. dev_dbg(&pdev->dev, "Jack type properties set to default");
  2542. } else {
  2543. if (!strncmp(mbhc_audio_jack_type, "4-pole-jack", n)) {
  2544. mbhc_cfg.hw_jack_type = FOUR_POLE_JACK;
  2545. mbhc_cfg.enable_anc_mic_detect = false;
  2546. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  2547. } else if (!strncmp(mbhc_audio_jack_type, "5-pole-jack", n)) {
  2548. mbhc_cfg.hw_jack_type = FIVE_POLE_JACK;
  2549. mbhc_cfg.enable_anc_mic_detect = true;
  2550. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  2551. } else if (!strncmp(mbhc_audio_jack_type, "6-pole-jack", n)) {
  2552. mbhc_cfg.hw_jack_type = SIX_POLE_JACK;
  2553. mbhc_cfg.enable_anc_mic_detect = true;
  2554. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  2555. } else {
  2556. mbhc_cfg.hw_jack_type = FOUR_POLE_JACK;
  2557. mbhc_cfg.enable_anc_mic_detect = false;
  2558. dev_dbg(&pdev->dev, "Unknown value, hence setting to default");
  2559. }
  2560. }
  2561. ret = snd_soc_register_card(card);
  2562. if (ret == -EPROBE_DEFER)
  2563. goto err;
  2564. else if (ret) {
  2565. dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
  2566. ret);
  2567. goto err;
  2568. }
  2569. /* Parse AUXPCM info from DT */
  2570. ret = msm8226_dtparse_auxpcm(pdev, &pdata->auxpcm_ctrl,
  2571. msm_auxpcm_gpio_name);
  2572. if (ret) {
  2573. dev_err(&pdev->dev,
  2574. "%s: Auxpcm pin data parse failed\n", __func__);
  2575. goto err;
  2576. }
  2577. vdd_spkr_gpio = of_get_named_gpio(pdev->dev.of_node,
  2578. "qcom,cdc-vdd-spkr-gpios", 0);
  2579. if (vdd_spkr_gpio < 0) {
  2580. dev_dbg(&pdev->dev,
  2581. "Looking up %s property in node %s failed %d\n",
  2582. "qcom, cdc-vdd-spkr-gpios",
  2583. pdev->dev.of_node->full_name, vdd_spkr_gpio);
  2584. } else {
  2585. ret = gpio_request(vdd_spkr_gpio, "TAPAN_CODEC_VDD_SPKR");
  2586. if (ret) {
  2587. /* GPIO to enable EXT VDD exists, but failed request */
  2588. dev_err(card->dev,
  2589. "%s: Failed to request tapan vdd spkr gpio %d\n",
  2590. __func__, vdd_spkr_gpio);
  2591. goto err;
  2592. }
  2593. }
  2594. lineout_en_gpio = of_get_named_gpio(pdev->dev.of_node,
  2595. "qcom,cdc-lineout-spkr-gpios", 0);
  2596. if (lineout_en_gpio < 0) {
  2597. dev_err(&pdev->dev,
  2598. "Looking up %s property in node %s failed %d\n",
  2599. "qcom, cdc-lineout-spkr-gpios",
  2600. pdev->dev.of_node->full_name, lineout_en_gpio);
  2601. } else {
  2602. ret = gpio_request(lineout_en_gpio,
  2603. "TAPAN_CODEC_LINEOUT_SPKR");
  2604. if (ret) {
  2605. /* GPIO to enable EXT AMP exists, but failed request */
  2606. dev_err(card->dev,
  2607. "%s: Failed to request tapan amp spkr gpio %d\n",
  2608. __func__, lineout_en_gpio);
  2609. goto err_vdd_spkr;
  2610. }
  2611. }
  2612. reg_node = of_parse_phandle(pdev->dev.of_node, "vdd-earjack-supply", 0);
  2613. if(reg_node)
  2614. {
  2615. earjack_ldo = regulator_get(&pdev->dev, "vdd-earjack");
  2616. if (IS_ERR(earjack_ldo)) {
  2617. pr_err("[%s] could not get earjack_ldo, %ld\n", __func__, PTR_ERR(earjack_ldo));
  2618. }
  2619. else
  2620. {
  2621. ret = regulator_enable(earjack_ldo);
  2622. if(ret < 0) {
  2623. pr_err("%s: Failed to enable regulator.\n",
  2624. __func__);
  2625. goto err_reg_enable;
  2626. } else
  2627. regulator_set_mode(earjack_ldo, REGULATOR_MODE_NORMAL);
  2628. }
  2629. }else
  2630. pr_err("%s Ear jack LDO node not available\n",__func__);
  2631. reg_node = of_parse_phandle(pdev->dev.of_node, "vdd-earadc-supply", 0);
  2632. if(reg_node)
  2633. {
  2634. earadc_ldo = regulator_get(&pdev->dev, "vdd-earadc");
  2635. if (IS_ERR(earadc_ldo)) {
  2636. pr_err("[%s] could not get earadc_ldo, %ld\n", __func__, PTR_ERR(earadc_ldo));
  2637. }
  2638. else
  2639. {
  2640. ret = regulator_enable(earadc_ldo);
  2641. if(ret < 0) {
  2642. pr_err("%s: Failed to enable regulator.\n",
  2643. __func__);
  2644. goto err_reg_enable;
  2645. } else
  2646. regulator_set_mode(earadc_ldo, REGULATOR_MODE_NORMAL);
  2647. }
  2648. pr_err("[%s] got earadc_ldo, %ld\n", __func__, PTR_ERR(earadc_ldo));
  2649. }else
  2650. pr_err("%s Ear adc LDO node not available\n",__func__);
  2651. msm8226_setup_hs_jack(pdev, pdata);
  2652. #if defined(CONFIG_GPIO_MAINMIC_BIAS)
  2653. /* the ldo of main mic bias */
  2654. mainmic_bias_gpio = of_get_named_gpio(pdev->dev.of_node,
  2655. "qcom,mainmic-bias-gpio", 0);
  2656. if (mainmic_bias_gpio < 0) {
  2657. dev_err(&pdev->dev, "Looking up %s property in node %s failed",
  2658. "qcom,mainmic-bias-gpio",
  2659. pdev->dev.of_node->full_name);
  2660. } else {
  2661. pr_info("%s : mic bias = %d\n", __func__, mainmic_bias_gpio);
  2662. ret = msm8226_prepare_mainmic();
  2663. if (ret) {
  2664. dev_err(&pdev->dev, "msm8226_prepare_mainmic failed (%d)\n",
  2665. ret);
  2666. gpio_free(mainmic_bias_gpio);
  2667. mainmic_bias_gpio = 0;
  2668. }
  2669. }
  2670. #endif //CONFIG_GPIO_MAINMIC_BIAS
  2671. ret = of_property_read_string(pdev->dev.of_node,
  2672. "qcom,prim-auxpcm-gpio-set", &auxpcm_pri_gpio_set);
  2673. if (ret) {
  2674. dev_err(&pdev->dev, "Looking up %s property in node %s failed",
  2675. "qcom,prim-auxpcm-gpio-set",
  2676. pdev->dev.of_node->full_name);
  2677. goto err_lineout_spkr;
  2678. }
  2679. if (!strcmp(auxpcm_pri_gpio_set, "prim-gpio-prim")) {
  2680. lpaif_pri_muxsel_virt_addr = ioremap(LPAIF_PRI_MODE_MUXSEL, 4);
  2681. } else if (!strcmp(auxpcm_pri_gpio_set, "prim-gpio-tert")) {
  2682. lpaif_pri_muxsel_virt_addr = ioremap(LPAIF_TER_MODE_MUXSEL, 4);
  2683. } else {
  2684. dev_err(&pdev->dev, "Invalid value %s for AUXPCM GPIO set\n",
  2685. auxpcm_pri_gpio_set);
  2686. ret = -EINVAL;
  2687. goto err_lineout_spkr;
  2688. }
  2689. if (lpaif_pri_muxsel_virt_addr == NULL) {
  2690. pr_err("%s Pri muxsel virt addr is null\n", __func__);
  2691. ret = -EINVAL;
  2692. goto err_lineout_spkr;
  2693. }
  2694. #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98505)
  2695. atomic_set(&pri_mi2s_clk.mi2s_rsc_ref, 0);
  2696. #endif
  2697. return 0;
  2698. err_lineout_spkr:
  2699. if (earjack_ldo)
  2700. regulator_disable(earjack_ldo);
  2701. if(earadc_ldo)
  2702. regulator_disable(earadc_ldo);
  2703. if (lineout_en_gpio >= 0) {
  2704. gpio_free(lineout_en_gpio);
  2705. lineout_en_gpio = -1;
  2706. }
  2707. err_reg_enable:
  2708. if(earjack_ldo)
  2709. regulator_put(earjack_ldo);
  2710. if(earadc_ldo)
  2711. regulator_put(earadc_ldo);
  2712. err_vdd_spkr:
  2713. if (vdd_spkr_gpio >= 0) {
  2714. gpio_free(vdd_spkr_gpio);
  2715. vdd_spkr_gpio = -1;
  2716. }
  2717. err:
  2718. if (pdata->mclk_gpio > 0) {
  2719. dev_dbg(&pdev->dev, "%s free gpio %d\n",
  2720. __func__, pdata->mclk_gpio);
  2721. gpio_free(pdata->mclk_gpio);
  2722. pdata->mclk_gpio = 0;
  2723. }
  2724. err1:
  2725. devm_kfree(&pdev->dev, pdata);
  2726. return ret;
  2727. }
  2728. static int __devexit msm8226_asoc_machine_remove(struct platform_device *pdev)
  2729. {
  2730. struct snd_soc_card *card = platform_get_drvdata(pdev);
  2731. struct msm8226_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  2732. gpio_free(pdata->mclk_gpio);
  2733. if (vdd_spkr_gpio >= 0)
  2734. gpio_free(vdd_spkr_gpio);
  2735. if (lineout_en_gpio >= 0)
  2736. gpio_free(lineout_en_gpio);
  2737. if (pdata->us_euro_gpio > 0)
  2738. gpio_free(pdata->us_euro_gpio);
  2739. if(earjack_ldo)
  2740. {
  2741. int ret;
  2742. ret = regulator_disable(earjack_ldo);
  2743. if(ret < 0) {
  2744. pr_err("%s: Failed to disable regulator.\n",__func__);
  2745. }
  2746. regulator_put(earjack_ldo);
  2747. }
  2748. if(earadc_ldo)
  2749. {
  2750. int ret;
  2751. ret = regulator_disable(earadc_ldo);
  2752. if(ret < 0)
  2753. pr_err("%s: Failed to diasable regulator.\n", __func__);
  2754. regulator_put(earadc_ldo);
  2755. }
  2756. vdd_spkr_gpio = -1;
  2757. lineout_en_gpio = -1;
  2758. snd_soc_unregister_card(card);
  2759. return 0;
  2760. }
  2761. static const struct of_device_id msm8226_asoc_machine_of_match[] = {
  2762. { .compatible = "qcom,msm8226-audio-tapan", },
  2763. {},
  2764. };
  2765. static struct platform_driver msm8226_asoc_machine_driver = {
  2766. .driver = {
  2767. .name = DRV_NAME,
  2768. .owner = THIS_MODULE,
  2769. .pm = &snd_soc_pm_ops,
  2770. .of_match_table = msm8226_asoc_machine_of_match,
  2771. },
  2772. .probe = msm8226_asoc_machine_probe,
  2773. .remove = __devexit_p(msm8226_asoc_machine_remove),
  2774. };
  2775. module_platform_driver(msm8226_asoc_machine_driver);
  2776. MODULE_DESCRIPTION("ALSA SoC msm");
  2777. MODULE_LICENSE("GPL v2");
  2778. MODULE_ALIAS("platform:" DRV_NAME);
  2779. MODULE_DEVICE_TABLE(of, msm8226_asoc_machine_of_match);