msm8974.c 113 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105
  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/qpnp/clkdiv.h>
  20. #include <linux/regulator/consumer.h>
  21. #include <linux/io.h>
  22. #include <sound/core.h>
  23. #include <sound/soc.h>
  24. #include <sound/soc-dapm.h>
  25. #include <sound/pcm.h>
  26. #include <sound/jack.h>
  27. #include <sound/q6afe-v2.h>
  28. #include <sound/q6core.h>
  29. #include <sound/pcm_params.h>
  30. #include <asm/mach-types.h>
  31. #include <mach/subsystem_notif.h>
  32. #include "qdsp6v2/msm-pcm-routing-v2.h"
  33. #include "../codecs/wcd9xxx-common.h"
  34. #include "../codecs/wcd9320.h"
  35. #if defined(CONFIG_SND_SOC_ES705)
  36. #include "../codecs/audience/es705-export.h"
  37. #elif defined(CONFIG_SND_SOC_ES325)
  38. #include "../codecs/es325-export.h"
  39. #endif
  40. #define DRV_NAME "msm8974-asoc-taiko"
  41. #define MSM8974_SPK_ON 1
  42. #define MSM8974_SPK_OFF 0
  43. #define MSM_SLIM_0_RX_MAX_CHANNELS 2
  44. #define MSM_SLIM_0_TX_MAX_CHANNELS 4
  45. #define BTSCO_RATE_8KHZ 8000
  46. #define BTSCO_RATE_16KHZ 16000
  47. static int slim0_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  48. static int slim0_tx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  49. static int hdmi_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  50. #define SAMPLING_RATE_48KHZ 48000
  51. #define SAMPLING_RATE_96KHZ 96000
  52. #define SAMPLING_RATE_192KHZ 192000
  53. static int msm8974_auxpcm_rate = 8000;
  54. #define LO_1_SPK_AMP 0x1
  55. #define LO_3_SPK_AMP 0x2
  56. #define LO_2_SPK_AMP 0x4
  57. #define LO_4_SPK_AMP 0x8
  58. #define I2S_PCM_SEL 1
  59. #define I2S_PCM_SEL_OFFSET 1
  60. #define WCD9XXX_MBHC_DEF_BUTTONS 3
  61. #define WCD9XXX_MBHC_DEF_RLOADS 5
  62. #define TAIKO_EXT_CLK_RATE 9600000
  63. /* It takes about 13ms for Class-D PAs to ramp-up */
  64. #define EXT_CLASS_D_EN_DELAY 13000
  65. #define EXT_CLASS_D_DIS_DELAY 3000
  66. #define EXT_CLASS_D_DELAY_DELTA 2000
  67. /* It takes about 13ms for Class-AB PAs to ramp-up */
  68. #define EXT_CLASS_AB_EN_DELAY 10000
  69. #define EXT_CLASS_AB_DIS_DELAY 1000
  70. #define EXT_CLASS_AB_DELAY_DELTA 1000
  71. #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98506)
  72. #if defined (CONFIG_TERT_MI2S_ENABLE)
  73. #define GPIO_TERT_MI2S_SCK 74
  74. #define GPIO_TERT_MI2S_WS 75
  75. #define GPIO_TERT_MI2S_DATA0 76
  76. #define GPIO_TERT_MI2S_DATA1 77
  77. #else
  78. #define GPIO_SECOND_MI2S_SCK 79
  79. #define GPIO_SECOND_MI2S_WS 80
  80. #define GPIO_SECOND_MI2S_DATA0 81
  81. #define GPIO_SECOND_MI2S_DATA1 82
  82. #endif
  83. #endif
  84. #define NUM_OF_AUXPCM_GPIOS 4
  85. static void *adsp_state_notifier;
  86. #define ADSP_STATE_READY_TIMEOUT_MS 50
  87. static inline int param_is_mask(int p)
  88. {
  89. return ((p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  90. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK));
  91. }
  92. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p, int n)
  93. {
  94. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  95. }
  96. static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned bit)
  97. {
  98. if (bit >= SNDRV_MASK_MAX)
  99. return;
  100. if (param_is_mask(n)) {
  101. struct snd_mask *m = param_to_mask(p, n);
  102. m->bits[0] = 0;
  103. m->bits[1] = 0;
  104. m->bits[bit >> 5] |= (1 << (bit & 31));
  105. }
  106. }
  107. static const char *const auxpcm_rate_text[] = {"8000", "16000"};
  108. static const struct soc_enum msm8974_auxpcm_enum[] = {
  109. SOC_ENUM_SINGLE_EXT(2, auxpcm_rate_text),
  110. };
  111. void *def_taiko_mbhc_cal(void);
  112. static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
  113. bool dapm);
  114. static struct wcd9xxx_mbhc_config mbhc_cfg = {
  115. #if defined(CONFIG_MACH_KS01EUR) || defined(CONFIG_MACH_KS01SKT) || \
  116. defined(CONFIG_MACH_KS01KTT) || defined(CONFIG_MACH_KS01LGT)
  117. .read_fw_bin = false,
  118. #else
  119. .read_fw_bin = true,
  120. #endif
  121. .calibration = NULL,
  122. .micbias = MBHC_MICBIAS2,
  123. .anc_micbias = MBHC_MICBIAS2,
  124. .mclk_cb_fn = msm_snd_enable_codec_ext_clk,
  125. .mclk_rate = TAIKO_EXT_CLK_RATE,
  126. .gpio = 0,
  127. .gpio_irq = 0,
  128. .gpio_level_insert = 0,
  129. .detect_extn_cable = true,
  130. #if defined(CONFIG_SEC_FACTORY)
  131. /* Micbias for MBHC is always on in factory test */
  132. .micbias_enable_flags = (1 << MBHC_MICBIAS_ENABLE_THRESHOLD_HEADSET |
  133. 1 << MBHC_MICBIAS_ENABLE_REGULAR_HEADSET),
  134. #else
  135. .micbias_enable_flags = 1 << MBHC_MICBIAS_ENABLE_THRESHOLD_HEADSET,
  136. #endif
  137. .insert_detect = true,
  138. .swap_gnd_mic = NULL,
  139. #if (defined(CONFIG_MACH_KLTE_KOR) || defined(CONFIG_MACH_KLTE_JPN) || defined(CONFIG_MACH_KACTIVELTE_DCM) || defined(CONFIG_MACH_CHAGALL_KDI) || defined(CONFIG_MACH_KLIMT_LTE_DCM)) && !defined(CONFIG_SEC_FACTORY)
  140. .cs_enable_flags = (1 << MBHC_CS_ENABLE_POLLING),
  141. #else
  142. .cs_enable_flags = 0,
  143. #endif
  144. .do_recalibration = false,
  145. .use_vddio_meas = true,
  146. .enable_anc_mic_detect = false,
  147. .hw_jack_type = SIX_POLE_JACK,
  148. };
  149. struct msm_auxpcm_gpio {
  150. unsigned gpio_no;
  151. const char *gpio_name;
  152. };
  153. struct msm_auxpcm_ctrl {
  154. struct msm_auxpcm_gpio *pin_data;
  155. u32 cnt;
  156. void __iomem *mux;
  157. };
  158. struct msm8974_asoc_mach_data {
  159. int mclk_gpio;
  160. u32 mclk_freq;
  161. int us_euro_gpio;
  162. struct msm_auxpcm_ctrl *pri_auxpcm_ctrl;
  163. struct msm_auxpcm_ctrl *sec_auxpcm_ctrl;
  164. };
  165. #define GPIO_NAME_INDEX 0
  166. #define DT_PARSE_INDEX 1
  167. static char *msm_prim_auxpcm_gpio_name[][2] = {
  168. {"PRIM_AUXPCM_CLK", "qcom,prim-auxpcm-gpio-clk"},
  169. {"PRIM_AUXPCM_SYNC", "qcom,prim-auxpcm-gpio-sync"},
  170. {"PRIM_AUXPCM_DIN", "qcom,prim-auxpcm-gpio-din"},
  171. {"PRIM_AUXPCM_DOUT", "qcom,prim-auxpcm-gpio-dout"},
  172. };
  173. static char *msm_sec_auxpcm_gpio_name[][2] = {
  174. {"SEC_AUXPCM_CLK", "qcom,sec-auxpcm-gpio-clk"},
  175. {"SEC_AUXPCM_SYNC", "qcom,sec-auxpcm-gpio-sync"},
  176. {"SEC_AUXPCM_DIN", "qcom,sec-auxpcm-gpio-din"},
  177. {"SEC_AUXPCM_DOUT", "qcom,sec-auxpcm-gpio-dout"},
  178. };
  179. struct msm8974_liquid_dock_dev {
  180. int dock_plug_gpio;
  181. int dock_plug_irq;
  182. int dock_plug_det;
  183. struct snd_soc_dapm_context *dapm;
  184. struct work_struct irq_work;
  185. };
  186. static struct msm8974_liquid_dock_dev *msm8974_liquid_dock_dev;
  187. /* Shared channel numbers for Slimbus ports that connect APQ to MDM. */
  188. enum {
  189. SLIM_1_RX_1 = 145, /* BT-SCO and USB TX */
  190. SLIM_1_TX_1 = 146, /* BT-SCO and USB RX */
  191. SLIM_2_RX_1 = 147, /* HDMI RX */
  192. SLIM_3_RX_1 = 148, /* In-call recording RX */
  193. SLIM_3_RX_2 = 149, /* In-call recording RX */
  194. SLIM_4_TX_1 = 150, /* In-call musid delivery TX */
  195. };
  196. static struct platform_device *spdev;
  197. static struct regulator *ext_spk_amp_regulator;
  198. static int ext_spk_amp_gpio = -1;
  199. static int ext_ult_spk_amp_gpio = -1;
  200. static int ext_ult_lo_amp_gpio = -1;
  201. static int msm8974_spk_control = 1;
  202. static int msm8974_ext_spk_pamp;
  203. static int msm_slim_0_rx_ch = 1;
  204. static int msm_slim_0_tx_ch = 1;
  205. static int msm_btsco_rate = BTSCO_RATE_8KHZ;
  206. static int msm_btsco_ch = 1;
  207. static int msm_hdmi_rx_ch = 2;
  208. static int slim0_rx_sample_rate = SAMPLING_RATE_48KHZ;
  209. static int msm_proxy_rx_ch = 2;
  210. static int hdmi_rx_sample_rate = SAMPLING_RATE_48KHZ;
  211. static struct mutex cdc_mclk_mutex;
  212. static struct clk *codec_clk;
  213. static int clk_users;
  214. static atomic_t prim_auxpcm_rsc_ref;
  215. static atomic_t sec_auxpcm_rsc_ref;
  216. static int mainmic_bias_gpio = 0;
  217. static int micbias_en_msm_gpio = 0;
  218. #if defined(CONFIG_LDO_SUBMIC_BIAS)
  219. static int submic_bias_gpio = 0;
  220. #endif
  221. #if defined(CONFIG_LDO_EARMIC_BIAS)
  222. static int earmic_bias_gpio = 0;
  223. #endif
  224. static int spkamp_en_gpio = 0;
  225. static int main_mic_delay = 0;
  226. #ifdef CONFIG_SEC_JACTIVE_PROJECT
  227. static int ear_jack_fsa8038_en = 0;
  228. #endif
  229. #if defined(CONFIG_SEC_H_PROJECT)
  230. int speaker_status = 0;
  231. EXPORT_SYMBOL(speaker_status);
  232. #endif
  233. #if defined(CONFIG_MACH_KLTE_KOR) || defined(CONFIG_MACH_KLTE_JPN) || defined(CONFIG_MACH_KACTIVELTE_DCM) \
  234. || defined(CONFIG_MACH_CHAGALL_KDI) || defined(CONFIG_MACH_KLIMT_LTE_DCM) || defined(CONFIG_MACH_KACTIVELTE_KOR)
  235. static int fsa_en_gpio;
  236. #endif
  237. #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98506)
  238. struct request_gpio {
  239. unsigned gpio_no;
  240. char *gpio_name;
  241. };
  242. static struct request_gpio pri_mi2s_gpio[] = {
  243. #if defined (CONFIG_TERT_MI2S_ENABLE)
  244. {
  245. .gpio_no = GPIO_TERT_MI2S_SCK,
  246. .gpio_name = "TERT_MI2S_SCK",
  247. },
  248. {
  249. .gpio_no = GPIO_TERT_MI2S_WS,
  250. .gpio_name = "TERT_MI2S_WS",
  251. },
  252. {
  253. .gpio_no = GPIO_TERT_MI2S_DATA0,
  254. .gpio_name = "TERT_MI2S_DATA0",
  255. },
  256. {
  257. .gpio_no = GPIO_TERT_MI2S_DATA1,
  258. .gpio_name = "TERT_MI2S_DATA1",
  259. },
  260. #else
  261. {
  262. .gpio_no = GPIO_SECOND_MI2S_SCK,
  263. .gpio_name = "SECOND_MI2S_SCK",
  264. },
  265. {
  266. .gpio_no = GPIO_SECOND_MI2S_WS,
  267. .gpio_name = "SECOND_MI2S_WS",
  268. },
  269. {
  270. .gpio_no = GPIO_SECOND_MI2S_DATA0,
  271. .gpio_name = "SECOND_MI2S_DATA0",
  272. },
  273. {
  274. .gpio_no = GPIO_SECOND_MI2S_DATA1,
  275. .gpio_name = "SECOND_MI2S_DATA1",
  276. },
  277. #endif
  278. };
  279. /* MI2S clock */
  280. struct mi2s_clk {
  281. struct clk *core_clk;
  282. struct clk *osr_clk;
  283. struct clk *bit_clk;
  284. atomic_t mi2s_rsc_ref;
  285. };
  286. static struct mi2s_clk pri_mi2s_clk;
  287. #endif
  288. static int msm8974_liquid_ext_spk_power_amp_init(void)
  289. {
  290. int ret = 0;
  291. ext_spk_amp_gpio = of_get_named_gpio(spdev->dev.of_node,
  292. "qcom,ext-spk-amp-gpio", 0);
  293. if (ext_spk_amp_gpio >= 0) {
  294. ret = gpio_request(ext_spk_amp_gpio, "ext_spk_amp_gpio");
  295. if (ret) {
  296. pr_err("%s: gpio_request failed for ext_spk_amp_gpio.\n",
  297. __func__);
  298. return -EINVAL;
  299. }
  300. gpio_direction_output(ext_spk_amp_gpio, 0);
  301. if (ext_spk_amp_regulator == NULL) {
  302. ext_spk_amp_regulator = regulator_get(&spdev->dev,
  303. "qcom,ext-spk-amp");
  304. if (IS_ERR(ext_spk_amp_regulator)) {
  305. pr_err("%s: Cannot get regulator %s.\n",
  306. __func__, "qcom,ext-spk-amp");
  307. gpio_free(ext_spk_amp_gpio);
  308. return PTR_ERR(ext_spk_amp_regulator);
  309. }
  310. }
  311. }
  312. ext_ult_spk_amp_gpio = of_get_named_gpio(spdev->dev.of_node,
  313. "qcom,ext-ult-spk-amp-gpio", 0);
  314. if (ext_ult_spk_amp_gpio >= 0) {
  315. ret = gpio_request(ext_ult_spk_amp_gpio,
  316. "ext_ult_spk_amp_gpio");
  317. if (ret) {
  318. pr_err("%s: gpio_request failed for ext-ult_spk-amp-gpio.\n",
  319. __func__);
  320. return -EINVAL;
  321. }
  322. gpio_direction_output(ext_ult_spk_amp_gpio, 0);
  323. }
  324. return 0;
  325. }
  326. static void msm8974_liquid_ext_ult_spk_power_amp_enable(u32 on)
  327. {
  328. if (on) {
  329. if (regulator_enable(ext_spk_amp_regulator))
  330. pr_err("%s: enable failed ext_spk_amp_reg\n",
  331. __func__);
  332. gpio_direction_output(ext_ult_spk_amp_gpio, 1);
  333. /* time takes enable the external power class AB amplifier */
  334. usleep_range(EXT_CLASS_AB_EN_DELAY,
  335. EXT_CLASS_AB_EN_DELAY + EXT_CLASS_AB_DELAY_DELTA);
  336. } else {
  337. gpio_direction_output(ext_ult_spk_amp_gpio, 0);
  338. regulator_disable(ext_spk_amp_regulator);
  339. /* time takes disable the external power class AB amplifier */
  340. usleep_range(EXT_CLASS_AB_DIS_DELAY,
  341. EXT_CLASS_AB_DIS_DELAY + EXT_CLASS_AB_DELAY_DELTA);
  342. }
  343. pr_debug("%s: %s external ultrasound SPKR_DRV PAs.\n", __func__,
  344. on ? "Enable" : "Disable");
  345. }
  346. static void msm8974_liquid_ext_spk_power_amp_enable(u32 on)
  347. {
  348. if (on) {
  349. if (regulator_enable(ext_spk_amp_regulator))
  350. pr_err("%s: enable failed ext_spk_amp_reg\n",
  351. __func__);
  352. gpio_direction_output(ext_spk_amp_gpio, on);
  353. /*time takes enable the external power amplifier*/
  354. usleep_range(EXT_CLASS_D_EN_DELAY,
  355. EXT_CLASS_D_EN_DELAY + EXT_CLASS_D_DELAY_DELTA);
  356. } else {
  357. gpio_direction_output(ext_spk_amp_gpio, on);
  358. regulator_disable(ext_spk_amp_regulator);
  359. /*time takes disable the external power amplifier*/
  360. usleep_range(EXT_CLASS_D_DIS_DELAY,
  361. EXT_CLASS_D_DIS_DELAY + EXT_CLASS_D_DELAY_DELTA);
  362. }
  363. pr_debug("%s: %s external speaker PAs.\n", __func__,
  364. on ? "Enable" : "Disable");
  365. }
  366. static void msm8974_liquid_docking_irq_work(struct work_struct *work)
  367. {
  368. struct msm8974_liquid_dock_dev *dock_dev =
  369. container_of(work,
  370. struct msm8974_liquid_dock_dev,
  371. irq_work);
  372. struct snd_soc_dapm_context *dapm = dock_dev->dapm;
  373. mutex_lock(&dapm->codec->mutex);
  374. dock_dev->dock_plug_det =
  375. gpio_get_value(dock_dev->dock_plug_gpio);
  376. if (0 == dock_dev->dock_plug_det) {
  377. if ((msm8974_ext_spk_pamp & LO_1_SPK_AMP) &&
  378. (msm8974_ext_spk_pamp & LO_3_SPK_AMP) &&
  379. (msm8974_ext_spk_pamp & LO_2_SPK_AMP) &&
  380. (msm8974_ext_spk_pamp & LO_4_SPK_AMP))
  381. msm8974_liquid_ext_spk_power_amp_enable(1);
  382. } else {
  383. if ((msm8974_ext_spk_pamp & LO_1_SPK_AMP) &&
  384. (msm8974_ext_spk_pamp & LO_3_SPK_AMP) &&
  385. (msm8974_ext_spk_pamp & LO_2_SPK_AMP) &&
  386. (msm8974_ext_spk_pamp & LO_4_SPK_AMP))
  387. msm8974_liquid_ext_spk_power_amp_enable(0);
  388. }
  389. mutex_unlock(&dapm->codec->mutex);
  390. }
  391. static irqreturn_t msm8974_liquid_docking_irq_handler(int irq, void *dev)
  392. {
  393. struct msm8974_liquid_dock_dev *dock_dev = dev;
  394. /* switch speakers should not run in interrupt context */
  395. schedule_work(&dock_dev->irq_work);
  396. return IRQ_HANDLED;
  397. }
  398. static int msm8974_liquid_init_docking(struct snd_soc_dapm_context *dapm)
  399. {
  400. int ret = 0;
  401. int dock_plug_gpio = 0;
  402. /* plug in docking speaker+plug in device OR unplug one of them */
  403. u32 dock_plug_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
  404. dock_plug_gpio = of_get_named_gpio(spdev->dev.of_node,
  405. "qcom,dock-plug-det-irq", 0);
  406. if (dock_plug_gpio >= 0) {
  407. msm8974_liquid_dock_dev =
  408. kzalloc(sizeof(*msm8974_liquid_dock_dev), GFP_KERNEL);
  409. if (!msm8974_liquid_dock_dev) {
  410. pr_err("msm8974_liquid_dock_dev alloc fail.\n");
  411. return -ENOMEM;
  412. }
  413. msm8974_liquid_dock_dev->dock_plug_gpio = dock_plug_gpio;
  414. ret = gpio_request(msm8974_liquid_dock_dev->dock_plug_gpio,
  415. "dock-plug-det-irq");
  416. if (ret) {
  417. pr_err("%s:failed request msm8974_liquid_dock_plug_gpio.\n",
  418. __func__);
  419. return -EINVAL;
  420. }
  421. msm8974_liquid_dock_dev->dock_plug_det =
  422. gpio_get_value(msm8974_liquid_dock_dev->dock_plug_gpio);
  423. msm8974_liquid_dock_dev->dock_plug_irq =
  424. gpio_to_irq(msm8974_liquid_dock_dev->dock_plug_gpio);
  425. msm8974_liquid_dock_dev->dapm = dapm;
  426. INIT_WORK(
  427. &msm8974_liquid_dock_dev->irq_work,
  428. msm8974_liquid_docking_irq_work);
  429. ret = request_irq(msm8974_liquid_dock_dev->dock_plug_irq,
  430. msm8974_liquid_docking_irq_handler,
  431. dock_plug_irq_flags,
  432. "liquid_dock_plug_irq",
  433. msm8974_liquid_dock_dev);
  434. }
  435. return 0;
  436. }
  437. #if !defined(CONFIG_MACH_VIENNA_LTE) && !defined(CONFIG_MACH_V2_LTE) && !defined(CONFIG_MACH_LT03_LTE) && !defined(CONFIG_MACH_PICASSO_LTE) && !defined(CONFIG_MACH_MONDRIAN) && !defined(CONFIG_MACH_CHAGALL) && !defined(CONFIG_MACH_KLIMT)
  438. static int msm8974_liquid_ext_spk_power_amp_on(u32 spk)
  439. {
  440. int rc;
  441. if (spk & (LO_1_SPK_AMP | LO_3_SPK_AMP | LO_2_SPK_AMP | LO_4_SPK_AMP)) {
  442. pr_debug("%s: External speakers are already on. spk = 0x%x\n",
  443. __func__, spk);
  444. msm8974_ext_spk_pamp |= spk;
  445. if ((msm8974_ext_spk_pamp & LO_1_SPK_AMP) &&
  446. (msm8974_ext_spk_pamp & LO_3_SPK_AMP) &&
  447. (msm8974_ext_spk_pamp & LO_2_SPK_AMP) &&
  448. (msm8974_ext_spk_pamp & LO_4_SPK_AMP))
  449. if (ext_spk_amp_gpio >= 0 &&
  450. msm8974_liquid_dock_dev &&
  451. msm8974_liquid_dock_dev->dock_plug_det == 0)
  452. msm8974_liquid_ext_spk_power_amp_enable(1);
  453. rc = 0;
  454. } else {
  455. pr_err("%s: Invalid external speaker ampl. spk = 0x%x\n",
  456. __func__, spk);
  457. rc = -EINVAL;
  458. }
  459. return rc;
  460. }
  461. static void msm8974_fluid_ext_us_amp_on(u32 spk)
  462. {
  463. if (!gpio_is_valid(ext_ult_lo_amp_gpio)) {
  464. pr_err("%s: ext_ult_lo_amp_gpio isn't configured\n", __func__);
  465. } else if (spk & (LO_1_SPK_AMP | LO_3_SPK_AMP)) {
  466. pr_debug("%s: External US amp is already on. spk = 0x%x\n",
  467. __func__, spk);
  468. msm8974_ext_spk_pamp |= spk;
  469. if ((msm8974_ext_spk_pamp & LO_1_SPK_AMP) &&
  470. (msm8974_ext_spk_pamp & LO_3_SPK_AMP))
  471. pr_debug("%s: Turn on US amp. spk = 0x%x\n",
  472. __func__, spk);
  473. gpio_direction_output(ext_ult_lo_amp_gpio, 1);
  474. } else {
  475. pr_err("%s: Invalid external speaker ampl. spk = 0x%x\n",
  476. __func__, spk);
  477. }
  478. }
  479. static void msm8974_fluid_ext_us_amp_off(u32 spk)
  480. {
  481. if (!gpio_is_valid(ext_ult_lo_amp_gpio)) {
  482. pr_err("%s: ext_ult_lo_amp_gpio isn't configured\n", __func__);
  483. } else if (spk & (LO_1_SPK_AMP | LO_3_SPK_AMP)) {
  484. pr_debug("%s LO1 and LO3. spk = 0x%x", __func__, spk);
  485. if (!msm8974_ext_spk_pamp) {
  486. pr_debug("%s: Turn off US amp. spk = 0x%x\n",
  487. __func__, spk);
  488. gpio_direction_output(ext_ult_lo_amp_gpio, 0);
  489. msm8974_ext_spk_pamp = 0;
  490. }
  491. } else {
  492. pr_err("%s: Invalid external speaker ampl. spk = 0x%x\n",
  493. __func__, spk);
  494. }
  495. }
  496. static void msm8974_ext_spk_power_amp_on(u32 spk)
  497. {
  498. if (gpio_is_valid(ext_spk_amp_gpio))
  499. msm8974_liquid_ext_spk_power_amp_on(spk);
  500. else if (gpio_is_valid(ext_ult_lo_amp_gpio))
  501. msm8974_fluid_ext_us_amp_on(spk);
  502. }
  503. static void msm8974_liquid_ext_spk_power_amp_off(u32 spk)
  504. {
  505. if (spk & (LO_1_SPK_AMP |
  506. LO_3_SPK_AMP |
  507. LO_2_SPK_AMP |
  508. LO_4_SPK_AMP)) {
  509. pr_debug("%s Left and right speakers case spk = 0x%08x",
  510. __func__, spk);
  511. msm8974_ext_spk_pamp &= ~spk;
  512. if (!msm8974_ext_spk_pamp) {
  513. if (ext_spk_amp_gpio >= 0 &&
  514. msm8974_liquid_dock_dev != NULL &&
  515. msm8974_liquid_dock_dev->dock_plug_det == 0)
  516. msm8974_liquid_ext_spk_power_amp_enable(0);
  517. }
  518. } else {
  519. pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n",
  520. __func__, spk);
  521. return;
  522. }
  523. }
  524. static void msm8974_ext_spk_power_amp_off(u32 spk)
  525. {
  526. if (gpio_is_valid(ext_spk_amp_gpio))
  527. msm8974_liquid_ext_spk_power_amp_off(spk);
  528. else if (gpio_is_valid(ext_ult_lo_amp_gpio))
  529. msm8974_fluid_ext_us_amp_off(spk);
  530. }
  531. #endif
  532. static void msm8974_ext_control(struct snd_soc_codec *codec)
  533. {
  534. struct snd_soc_dapm_context *dapm = &codec->dapm;
  535. mutex_lock(&dapm->codec->mutex);
  536. pr_debug("%s: msm8974_spk_control = %d", __func__, msm8974_spk_control);
  537. if (msm8974_spk_control == MSM8974_SPK_ON) {
  538. snd_soc_dapm_enable_pin(dapm, "Lineout_1 amp");
  539. snd_soc_dapm_enable_pin(dapm, "Lineout_3 amp");
  540. snd_soc_dapm_enable_pin(dapm, "Lineout_2 amp");
  541. snd_soc_dapm_enable_pin(dapm, "Lineout_4 amp");
  542. } else {
  543. snd_soc_dapm_disable_pin(dapm, "Lineout_1 amp");
  544. snd_soc_dapm_disable_pin(dapm, "Lineout_3 amp");
  545. snd_soc_dapm_disable_pin(dapm, "Lineout_2 amp");
  546. snd_soc_dapm_disable_pin(dapm, "Lineout_4 amp");
  547. }
  548. snd_soc_dapm_sync(dapm);
  549. mutex_unlock(&dapm->codec->mutex);
  550. }
  551. static int msm8974_get_spk(struct snd_kcontrol *kcontrol,
  552. struct snd_ctl_elem_value *ucontrol)
  553. {
  554. pr_debug("%s: msm8974_spk_control = %d", __func__, msm8974_spk_control);
  555. ucontrol->value.integer.value[0] = msm8974_spk_control;
  556. return 0;
  557. }
  558. static int msm8974_set_spk(struct snd_kcontrol *kcontrol,
  559. struct snd_ctl_elem_value *ucontrol)
  560. {
  561. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  562. pr_debug("%s()\n", __func__);
  563. if (msm8974_spk_control == ucontrol->value.integer.value[0])
  564. return 0;
  565. msm8974_spk_control = ucontrol->value.integer.value[0];
  566. msm8974_ext_control(codec);
  567. return 1;
  568. }
  569. #if !defined(CONFIG_MACH_VIENNA_LTE) && !defined(CONFIG_MACH_V2_LTE) && !defined(CONFIG_MACH_LT03_LTE) && !defined(CONFIG_MACH_PICASSO_LTE) && !defined(CONFIG_MACH_MONDRIAN) && !defined(CONFIG_MACH_CHAGALL) && !defined(CONFIG_MACH_KLIMT)
  570. static int msm_ext_spkramp_event(struct snd_soc_dapm_widget *w,
  571. struct snd_kcontrol *k, int event)
  572. {
  573. pr_debug("%s()\n", __func__);
  574. if (SND_SOC_DAPM_EVENT_ON(event)) {
  575. if (!strncmp(w->name, "Lineout_1 amp", 14))
  576. msm8974_ext_spk_power_amp_on(LO_1_SPK_AMP);
  577. else if (!strncmp(w->name, "Lineout_3 amp", 14))
  578. msm8974_ext_spk_power_amp_on(LO_3_SPK_AMP);
  579. else if (!strncmp(w->name, "Lineout_2 amp", 14))
  580. msm8974_ext_spk_power_amp_on(LO_2_SPK_AMP);
  581. else if (!strncmp(w->name, "Lineout_4 amp", 14))
  582. msm8974_ext_spk_power_amp_on(LO_4_SPK_AMP);
  583. else {
  584. pr_err("%s() Invalid Speaker Widget = %s\n",
  585. __func__, w->name);
  586. return -EINVAL;
  587. }
  588. } else {
  589. if (!strncmp(w->name, "Lineout_1 amp", 14))
  590. msm8974_ext_spk_power_amp_off(LO_1_SPK_AMP);
  591. else if (!strncmp(w->name, "Lineout_3 amp", 14))
  592. msm8974_ext_spk_power_amp_off(LO_3_SPK_AMP);
  593. else if (!strncmp(w->name, "Lineout_2 amp", 14))
  594. msm8974_ext_spk_power_amp_off(LO_2_SPK_AMP);
  595. else if (!strncmp(w->name, "Lineout_4 amp", 14))
  596. msm8974_ext_spk_power_amp_off(LO_4_SPK_AMP);
  597. else {
  598. pr_err("%s() Invalid Speaker Widget = %s\n",
  599. __func__, w->name);
  600. return -EINVAL;
  601. }
  602. }
  603. return 0;
  604. }
  605. #else
  606. static int msm_ext_spkramp_event(struct snd_soc_dapm_widget *w,
  607. struct snd_kcontrol *k, int event)
  608. {
  609. pr_info("%s() : control =%d\n", __func__, event);
  610. gpio_direction_output(spkamp_en_gpio,
  611. SND_SOC_DAPM_EVENT_ON(event));
  612. return 0;
  613. }
  614. #endif
  615. static int msm_ext_spkramp_ultrasound_event(struct snd_soc_dapm_widget *w,
  616. struct snd_kcontrol *k, int event)
  617. {
  618. pr_debug("%s()\n", __func__);
  619. if (!strncmp(w->name, "SPK_ultrasound amp", 19)) {
  620. if (!gpio_is_valid(ext_ult_spk_amp_gpio)) {
  621. pr_err("%s: ext_ult_spk_amp_gpio isn't configured\n",
  622. __func__);
  623. return -EINVAL;
  624. }
  625. if (SND_SOC_DAPM_EVENT_ON(event))
  626. msm8974_liquid_ext_ult_spk_power_amp_enable(1);
  627. else
  628. msm8974_liquid_ext_ult_spk_power_amp_enable(0);
  629. } else {
  630. pr_err("%s() Invalid Speaker Widget = %s\n",
  631. __func__, w->name);
  632. return -EINVAL;
  633. }
  634. return 0;
  635. }
  636. static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
  637. bool dapm)
  638. {
  639. int ret = 0;
  640. pr_debug("%s: enable = %d clk_users = %d\n",
  641. __func__, enable, clk_users);
  642. mutex_lock(&cdc_mclk_mutex);
  643. if (enable) {
  644. if (!codec_clk) {
  645. dev_err(codec->dev, "%s: did not get Taiko MCLK\n",
  646. __func__);
  647. ret = -EINVAL;
  648. goto exit;
  649. }
  650. clk_users++;
  651. if (clk_users != 1)
  652. goto exit;
  653. if (codec_clk) {
  654. clk_prepare_enable(codec_clk);
  655. taiko_mclk_enable(codec, 1, dapm);
  656. } else {
  657. pr_err("%s: Error setting Taiko MCLK\n", __func__);
  658. clk_users--;
  659. goto exit;
  660. }
  661. } else {
  662. if (clk_users > 0) {
  663. clk_users--;
  664. if (clk_users == 0) {
  665. taiko_mclk_enable(codec, 0, dapm);
  666. clk_disable_unprepare(codec_clk);
  667. }
  668. } else {
  669. pr_err("%s: Error releasing Taiko MCLK\n", __func__);
  670. ret = -EINVAL;
  671. goto exit;
  672. }
  673. }
  674. exit:
  675. mutex_unlock(&cdc_mclk_mutex);
  676. return ret;
  677. }
  678. static int msm8974_mclk_event(struct snd_soc_dapm_widget *w,
  679. struct snd_kcontrol *kcontrol, int event)
  680. {
  681. pr_debug("%s: event = %d\n", __func__, event);
  682. switch (event) {
  683. case SND_SOC_DAPM_PRE_PMU:
  684. return msm_snd_enable_codec_ext_clk(w->codec, 1, true);
  685. case SND_SOC_DAPM_POST_PMD:
  686. return msm_snd_enable_codec_ext_clk(w->codec, 0, true);
  687. }
  688. return 0;
  689. }
  690. #if !defined(CONFIG_SEC_KS01_PROJECT)
  691. static int msm_mainmic_bias_event(struct snd_soc_dapm_widget *w,
  692. struct snd_kcontrol *k, int event)
  693. {
  694. pr_info("%s : Event %d, SND_SOC_DAPM:%d\n",
  695. __func__, (event), SND_SOC_DAPM_EVENT_ON(event));
  696. if (mainmic_bias_gpio < 0) {
  697. gpio_set_value_cansleep(micbias_en_msm_gpio,
  698. SND_SOC_DAPM_EVENT_ON(event));
  699. } else {
  700. gpio_direction_output(mainmic_bias_gpio,
  701. SND_SOC_DAPM_EVENT_ON(event));
  702. }
  703. if(main_mic_delay) {
  704. if(main_mic_delay != 100)
  705. main_mic_delay *= 50;
  706. msleep(main_mic_delay);
  707. pr_info("%s: main_mic_delay = %d\n", __func__, main_mic_delay);
  708. main_mic_delay = 0;
  709. }
  710. return 0;
  711. }
  712. #endif
  713. #if defined(CONFIG_LDO_SUBMIC_BIAS)
  714. static int msm_submic_bias_event(struct snd_soc_dapm_widget *w,
  715. struct snd_kcontrol *k, int event)
  716. {
  717. pr_info("%s : Event %d, SND_SOC_DAPM:%d\n",
  718. __func__, (event), SND_SOC_DAPM_EVENT_ON(event));
  719. gpio_direction_output(submic_bias_gpio,
  720. SND_SOC_DAPM_EVENT_ON(event));
  721. return 0;
  722. }
  723. #endif
  724. #if defined(CONFIG_LDO_EARMIC_BIAS)
  725. static int msm_earmic_bias_event(struct snd_soc_dapm_widget *w,
  726. struct snd_kcontrol *k, int event)
  727. {
  728. pr_info("%s : Event %d, SND_SOC_DAPM:%d\n",
  729. __func__, (event), SND_SOC_DAPM_EVENT_ON(event));
  730. gpio_direction_output(earmic_bias_gpio,
  731. SND_SOC_DAPM_EVENT_ON(event));
  732. return 0;
  733. }
  734. #endif
  735. #ifdef CONFIG_SEC_K_PROJECT
  736. static const struct snd_soc_dapm_widget msm8974_dapm_widgets[] = {
  737. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  738. msm8974_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  739. SND_SOC_DAPM_SPK("Lineout_1 amp", msm_ext_spkramp_event),
  740. SND_SOC_DAPM_SPK("Lineout_3 amp", msm_ext_spkramp_event),
  741. SND_SOC_DAPM_SPK("Lineout_2 amp", msm_ext_spkramp_event),
  742. SND_SOC_DAPM_SPK("Lineout_4 amp", msm_ext_spkramp_event),
  743. SND_SOC_DAPM_SPK("SPK_ultrasound amp",
  744. msm_ext_spkramp_ultrasound_event),
  745. SND_SOC_DAPM_MIC("Handset Mic", NULL),
  746. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  747. SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
  748. SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
  749. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  750. SND_SOC_DAPM_MIC("Analog Mic6", NULL),
  751. SND_SOC_DAPM_MIC("Analog Mic7", NULL),
  752. SND_SOC_DAPM_MIC("Digital Mic1", NULL),
  753. SND_SOC_DAPM_MIC("Main Mic", msm_mainmic_bias_event),
  754. SND_SOC_DAPM_MIC("Digital Mic3", NULL),
  755. SND_SOC_DAPM_MIC("Sub Mic", NULL),
  756. SND_SOC_DAPM_MIC("Digital Mic5", NULL),
  757. SND_SOC_DAPM_MIC("Third Mic", NULL),
  758. };
  759. #elif defined (CONFIG_SEC_JACTIVE_PROJECT)
  760. static const struct snd_soc_dapm_widget msm8974_dapm_widgets_01[] = {
  761. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  762. msm8974_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  763. SND_SOC_DAPM_SPK("Lineout_1 amp", msm_ext_spkramp_event),
  764. SND_SOC_DAPM_SPK("Lineout_3 amp", msm_ext_spkramp_event),
  765. SND_SOC_DAPM_SPK("Lineout_2 amp", msm_ext_spkramp_event),
  766. SND_SOC_DAPM_SPK("Lineout_4 amp", msm_ext_spkramp_event),
  767. SND_SOC_DAPM_SPK("SPK_ultrasound amp",
  768. msm_ext_spkramp_ultrasound_event),
  769. SND_SOC_DAPM_MIC("Main Mic", NULL),
  770. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  771. SND_SOC_DAPM_MIC("Sub Mic", NULL),
  772. SND_SOC_DAPM_MIC("Third Mic", NULL),
  773. SND_SOC_DAPM_MIC("Digital Mic1", NULL),
  774. SND_SOC_DAPM_MIC("Digital Mic2", NULL),
  775. SND_SOC_DAPM_MIC("Digital Mic3", NULL),
  776. SND_SOC_DAPM_MIC("Digital Mic4", NULL),
  777. SND_SOC_DAPM_MIC("Digital Mic5", NULL),
  778. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  779. };
  780. static const struct snd_soc_dapm_widget msm8974_dapm_widgets[] = {
  781. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  782. msm8974_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  783. SND_SOC_DAPM_SPK("Lineout_1 amp", msm_ext_spkramp_event),
  784. SND_SOC_DAPM_SPK("Lineout_3 amp", msm_ext_spkramp_event),
  785. SND_SOC_DAPM_SPK("Lineout_2 amp", msm_ext_spkramp_event),
  786. SND_SOC_DAPM_SPK("Lineout_4 amp", msm_ext_spkramp_event),
  787. SND_SOC_DAPM_SPK("SPK_ultrasound amp",
  788. msm_ext_spkramp_ultrasound_event),
  789. SND_SOC_DAPM_MIC("Main Mic", msm_mainmic_bias_event),
  790. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  791. SND_SOC_DAPM_MIC("Sub Mic", NULL),
  792. SND_SOC_DAPM_MIC("Third Mic", NULL),
  793. SND_SOC_DAPM_MIC("Digital Mic1", NULL),
  794. SND_SOC_DAPM_MIC("Digital Mic2", NULL),
  795. SND_SOC_DAPM_MIC("Digital Mic3", NULL),
  796. SND_SOC_DAPM_MIC("Digital Mic4", NULL),
  797. SND_SOC_DAPM_MIC("Digital Mic5", NULL),
  798. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  799. };
  800. #else
  801. static const struct snd_soc_dapm_widget msm8974_dapm_widgets[] = {
  802. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  803. msm8974_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  804. SND_SOC_DAPM_SPK("Lineout_1 amp", msm_ext_spkramp_event),
  805. SND_SOC_DAPM_SPK("Lineout_3 amp", msm_ext_spkramp_event),
  806. SND_SOC_DAPM_SPK("Lineout_2 amp", msm_ext_spkramp_event),
  807. SND_SOC_DAPM_SPK("Lineout_4 amp", msm_ext_spkramp_event),
  808. SND_SOC_DAPM_SPK("SPK_ultrasound amp",
  809. msm_ext_spkramp_ultrasound_event),
  810. #if defined(CONFIG_SEC_KS01_PROJECT)
  811. SND_SOC_DAPM_MIC("Main Mic", NULL),
  812. #else
  813. SND_SOC_DAPM_MIC("Main Mic", msm_mainmic_bias_event),
  814. #endif
  815. #if defined(CONFIG_LDO_EARMIC_BIAS)
  816. SND_SOC_DAPM_MIC("Headset Mic", msm_earmic_bias_event),
  817. #else
  818. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  819. #endif
  820. #if defined(CONFIG_LDO_SUBMIC_BIAS)
  821. SND_SOC_DAPM_MIC("Sub Mic", msm_submic_bias_event),
  822. #else
  823. SND_SOC_DAPM_MIC("Sub Mic", NULL),
  824. #endif
  825. SND_SOC_DAPM_MIC("Third Mic", NULL),
  826. SND_SOC_DAPM_MIC("Digital Mic1", NULL),
  827. SND_SOC_DAPM_MIC("Digital Mic2", NULL),
  828. SND_SOC_DAPM_MIC("Digital Mic3", NULL),
  829. SND_SOC_DAPM_MIC("Digital Mic4", NULL),
  830. SND_SOC_DAPM_MIC("Digital Mic5", NULL),
  831. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  832. };
  833. #endif
  834. static const char *const spk_function[] = {"Off", "On"};
  835. static const char *const slim0_rx_ch_text[] = {"One", "Two"};
  836. static const char *const slim0_tx_ch_text[] = {"One", "Two", "Three", "Four",
  837. "Five", "Six", "Seven",
  838. "Eight"};
  839. static char const *hdmi_rx_ch_text[] = {"Two", "Three", "Four", "Five",
  840. "Six", "Seven", "Eight"};
  841. static char const *rx_bit_format_text[] = {"S16_LE", "S24_LE"};
  842. static char const *slim0_rx_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  843. "KHZ_192"};
  844. static const char *const proxy_rx_ch_text[] = {"One", "Two", "Three", "Four",
  845. "Five", "Six", "Seven", "Eight"};
  846. static char const *hdmi_rx_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  847. "KHZ_192"};
  848. static const char *const btsco_rate_text[] = {"8000", "16000"};
  849. static const struct soc_enum msm_btsco_enum[] = {
  850. SOC_ENUM_SINGLE_EXT(2, btsco_rate_text),
  851. };
  852. static int slim0_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  853. struct snd_ctl_elem_value *ucontrol)
  854. {
  855. int sample_rate_val = 0;
  856. switch (slim0_rx_sample_rate) {
  857. case SAMPLING_RATE_192KHZ:
  858. sample_rate_val = 2;
  859. break;
  860. case SAMPLING_RATE_96KHZ:
  861. sample_rate_val = 1;
  862. break;
  863. case SAMPLING_RATE_48KHZ:
  864. default:
  865. sample_rate_val = 0;
  866. break;
  867. }
  868. ucontrol->value.integer.value[0] = sample_rate_val;
  869. pr_debug("%s: slim0_rx_sample_rate = %d\n", __func__,
  870. slim0_rx_sample_rate);
  871. return 0;
  872. }
  873. static int slim0_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  874. struct snd_ctl_elem_value *ucontrol)
  875. {
  876. pr_debug("%s: ucontrol value = %ld\n", __func__,
  877. ucontrol->value.integer.value[0]);
  878. switch (ucontrol->value.integer.value[0]) {
  879. case 2:
  880. slim0_rx_sample_rate = SAMPLING_RATE_192KHZ;
  881. break;
  882. case 1:
  883. slim0_rx_sample_rate = SAMPLING_RATE_96KHZ;
  884. break;
  885. case 0:
  886. default:
  887. slim0_rx_sample_rate = SAMPLING_RATE_48KHZ;
  888. }
  889. pr_info("%s: slim0_rx_sample_rate = %d\n", __func__,
  890. slim0_rx_sample_rate);
  891. return 0;
  892. }
  893. static int slim0_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  894. struct snd_ctl_elem_value *ucontrol)
  895. {
  896. switch (slim0_rx_bit_format) {
  897. case SNDRV_PCM_FORMAT_S24_LE:
  898. ucontrol->value.integer.value[0] = 1;
  899. break;
  900. case SNDRV_PCM_FORMAT_S16_LE:
  901. default:
  902. ucontrol->value.integer.value[0] = 0;
  903. break;
  904. }
  905. pr_debug("%s: slim0_rx_bit_format = %d, ucontrol value = %ld\n",
  906. __func__, slim0_rx_bit_format,
  907. ucontrol->value.integer.value[0]);
  908. return 0;
  909. }
  910. static int slim0_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  911. struct snd_ctl_elem_value *ucontrol)
  912. {
  913. switch (ucontrol->value.integer.value[0]) {
  914. case 1:
  915. slim0_rx_bit_format = SNDRV_PCM_FORMAT_S24_LE;
  916. break;
  917. case 0:
  918. default:
  919. slim0_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  920. break;
  921. }
  922. return 0;
  923. }
  924. static int msm_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol,
  925. struct snd_ctl_elem_value *ucontrol)
  926. {
  927. pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
  928. msm_slim_0_rx_ch);
  929. ucontrol->value.integer.value[0] = msm_slim_0_rx_ch - 1;
  930. return 0;
  931. }
  932. static int msm_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol,
  933. struct snd_ctl_elem_value *ucontrol)
  934. {
  935. msm_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1;
  936. pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
  937. msm_slim_0_rx_ch);
  938. return 1;
  939. }
  940. static int msm_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol,
  941. struct snd_ctl_elem_value *ucontrol)
  942. {
  943. pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__,
  944. msm_slim_0_tx_ch);
  945. ucontrol->value.integer.value[0] = msm_slim_0_tx_ch - 1;
  946. return 0;
  947. }
  948. static int msm_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol,
  949. struct snd_ctl_elem_value *ucontrol)
  950. {
  951. msm_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1;
  952. pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, msm_slim_0_tx_ch);
  953. return 1;
  954. }
  955. static int msm_btsco_rate_get(struct snd_kcontrol *kcontrol,
  956. struct snd_ctl_elem_value *ucontrol)
  957. {
  958. pr_debug("%s: msm_btsco_rate = %d", __func__, msm_btsco_rate);
  959. ucontrol->value.integer.value[0] = msm_btsco_rate;
  960. return 0;
  961. }
  962. static int msm_btsco_rate_put(struct snd_kcontrol *kcontrol,
  963. struct snd_ctl_elem_value *ucontrol)
  964. {
  965. switch (ucontrol->value.integer.value[0]) {
  966. case 0:
  967. msm_btsco_rate = BTSCO_RATE_8KHZ;
  968. break;
  969. case 1:
  970. msm_btsco_rate = BTSCO_RATE_16KHZ;
  971. break;
  972. default:
  973. msm_btsco_rate = BTSCO_RATE_8KHZ;
  974. break;
  975. }
  976. pr_debug("%s: msm_btsco_rate = %d\n", __func__, msm_btsco_rate);
  977. return 0;
  978. }
  979. static int hdmi_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  980. struct snd_ctl_elem_value *ucontrol)
  981. {
  982. switch (hdmi_rx_bit_format) {
  983. case SNDRV_PCM_FORMAT_S24_LE:
  984. ucontrol->value.integer.value[0] = 1;
  985. break;
  986. case SNDRV_PCM_FORMAT_S16_LE:
  987. default:
  988. ucontrol->value.integer.value[0] = 0;
  989. break;
  990. }
  991. pr_debug("%s: hdmi_rx_bit_format = %d, ucontrol value = %ld\n",
  992. __func__, hdmi_rx_bit_format,
  993. ucontrol->value.integer.value[0]);
  994. return 0;
  995. }
  996. static int hdmi_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  997. struct snd_ctl_elem_value *ucontrol)
  998. {
  999. switch (ucontrol->value.integer.value[0]) {
  1000. case 1:
  1001. hdmi_rx_bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1002. break;
  1003. case 0:
  1004. default:
  1005. hdmi_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1006. break;
  1007. }
  1008. pr_debug("%s: hdmi_rx_bit_format = %d, ucontrol value = %ld\n",
  1009. __func__, hdmi_rx_bit_format,
  1010. ucontrol->value.integer.value[0]);
  1011. return 0;
  1012. }
  1013. static int msm_hdmi_rx_ch_get(struct snd_kcontrol *kcontrol,
  1014. struct snd_ctl_elem_value *ucontrol)
  1015. {
  1016. pr_debug("%s: msm_hdmi_rx_ch = %d\n", __func__,
  1017. msm_hdmi_rx_ch);
  1018. ucontrol->value.integer.value[0] = msm_hdmi_rx_ch - 2;
  1019. return 0;
  1020. }
  1021. static int msm_hdmi_rx_ch_put(struct snd_kcontrol *kcontrol,
  1022. struct snd_ctl_elem_value *ucontrol)
  1023. {
  1024. msm_hdmi_rx_ch = ucontrol->value.integer.value[0] + 2;
  1025. if (msm_hdmi_rx_ch > 8) {
  1026. pr_err("%s: channels exceeded 8.Limiting to max channels-8\n",
  1027. __func__);
  1028. msm_hdmi_rx_ch = 8;
  1029. }
  1030. pr_debug("%s: msm_hdmi_rx_ch = %d\n", __func__, msm_hdmi_rx_ch);
  1031. return 1;
  1032. }
  1033. static int hdmi_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1034. struct snd_ctl_elem_value *ucontrol)
  1035. {
  1036. int sample_rate_val = 0;
  1037. switch (hdmi_rx_sample_rate) {
  1038. case SAMPLING_RATE_192KHZ:
  1039. sample_rate_val = 2;
  1040. break;
  1041. case SAMPLING_RATE_96KHZ:
  1042. sample_rate_val = 1;
  1043. break;
  1044. case SAMPLING_RATE_48KHZ:
  1045. default:
  1046. sample_rate_val = 0;
  1047. break;
  1048. }
  1049. ucontrol->value.integer.value[0] = sample_rate_val;
  1050. pr_debug("%s: hdmi_rx_sample_rate = %d\n", __func__,
  1051. hdmi_rx_sample_rate);
  1052. return 0;
  1053. }
  1054. static int hdmi_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1055. struct snd_ctl_elem_value *ucontrol)
  1056. {
  1057. pr_debug("%s: ucontrol value = %ld\n", __func__,
  1058. ucontrol->value.integer.value[0]);
  1059. switch (ucontrol->value.integer.value[0]) {
  1060. case 2:
  1061. hdmi_rx_sample_rate = SAMPLING_RATE_192KHZ;
  1062. break;
  1063. case 1:
  1064. hdmi_rx_sample_rate = SAMPLING_RATE_96KHZ;
  1065. break;
  1066. case 0:
  1067. default:
  1068. hdmi_rx_sample_rate = SAMPLING_RATE_48KHZ;
  1069. }
  1070. pr_debug("%s: hdmi_rx_sample_rate = %d\n", __func__,
  1071. hdmi_rx_sample_rate);
  1072. return 0;
  1073. }
  1074. static const struct snd_kcontrol_new int_btsco_rate_mixer_controls[] = {
  1075. SOC_ENUM_EXT("Internal BTSCO SampleRate", msm_btsco_enum[0],
  1076. msm_btsco_rate_get, msm_btsco_rate_put),
  1077. };
  1078. static int msm_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1079. struct snd_pcm_hw_params *params)
  1080. {
  1081. struct snd_interval *rate = hw_param_interval(params,
  1082. SNDRV_PCM_HW_PARAM_RATE);
  1083. struct snd_interval *channels = hw_param_interval(params,
  1084. SNDRV_PCM_HW_PARAM_CHANNELS);
  1085. rate->min = rate->max = msm_btsco_rate;
  1086. channels->min = channels->max = msm_btsco_ch;
  1087. return 0;
  1088. }
  1089. static int msm8974_auxpcm_rate_get(struct snd_kcontrol *kcontrol,
  1090. struct snd_ctl_elem_value *ucontrol)
  1091. {
  1092. ucontrol->value.integer.value[0] = msm8974_auxpcm_rate;
  1093. return 0;
  1094. }
  1095. static int msm8974_auxpcm_rate_put(struct snd_kcontrol *kcontrol,
  1096. struct snd_ctl_elem_value *ucontrol)
  1097. {
  1098. switch (ucontrol->value.integer.value[0]) {
  1099. case 0:
  1100. msm8974_auxpcm_rate = 8000;
  1101. msm_btsco_rate = BTSCO_RATE_8KHZ;
  1102. break;
  1103. case 1:
  1104. msm8974_auxpcm_rate = 16000;
  1105. msm_btsco_rate = BTSCO_RATE_16KHZ;
  1106. break;
  1107. default:
  1108. msm8974_auxpcm_rate = 8000;
  1109. msm_btsco_rate = BTSCO_RATE_8KHZ;
  1110. break;
  1111. }
  1112. pr_info("%s: BT sample rate = %d ====\n",__func__, msm8974_auxpcm_rate);
  1113. return 0;
  1114. }
  1115. static int main_mic_delay_get(struct snd_kcontrol *kcontrol,
  1116. struct snd_ctl_elem_value *ucontrol)
  1117. {
  1118. pr_debug("%s: main_mic_delay = %d\n", __func__,
  1119. main_mic_delay);
  1120. ucontrol->value.integer.value[0] = main_mic_delay;
  1121. return 0;
  1122. }
  1123. static int main_mic_delay_put(struct snd_kcontrol *kcontrol,
  1124. struct snd_ctl_elem_value *ucontrol)
  1125. {
  1126. main_mic_delay = ucontrol->value.integer.value[0];
  1127. pr_debug("%s: main_mic_delay = %d\n", __func__,
  1128. main_mic_delay);
  1129. return 1;
  1130. }
  1131. #if defined(CONFIG_SEC_H_PROJECT)
  1132. static int speaker_status_get(struct snd_kcontrol *kcontrol,
  1133. struct snd_ctl_elem_value *ucontrol)
  1134. {
  1135. pr_info("%s: speaker_status = %d\n", __func__, speaker_status);
  1136. ucontrol->value.integer.value[0] = speaker_status;
  1137. return 0;
  1138. }
  1139. static int speaker_status_put(struct snd_kcontrol *kcontrol,
  1140. struct snd_ctl_elem_value *ucontrol)
  1141. {
  1142. speaker_status = ucontrol->value.integer.value[0];
  1143. pr_info("%s: speaker_status = %d\n", __func__, speaker_status);
  1144. return 1;
  1145. }
  1146. #endif
  1147. static int msm_proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1148. struct snd_ctl_elem_value *ucontrol)
  1149. {
  1150. pr_debug("%s: msm_proxy_rx_ch = %d\n", __func__,
  1151. msm_proxy_rx_ch);
  1152. ucontrol->value.integer.value[0] = msm_proxy_rx_ch - 1;
  1153. return 0;
  1154. }
  1155. static int msm_proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1156. struct snd_ctl_elem_value *ucontrol)
  1157. {
  1158. msm_proxy_rx_ch = ucontrol->value.integer.value[0] + 1;
  1159. pr_debug("%s: msm_proxy_rx_ch = %d\n", __func__,
  1160. msm_proxy_rx_ch);
  1161. return 1;
  1162. }
  1163. static int msm_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1164. struct snd_pcm_hw_params *params)
  1165. {
  1166. struct snd_interval *rate =
  1167. hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
  1168. struct snd_interval *channels =
  1169. hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  1170. rate->min = rate->max = msm8974_auxpcm_rate;
  1171. channels->min = channels->max = 1;
  1172. return 0;
  1173. }
  1174. #if defined( CONFIG_PCM_ROUTE_VOICE_STUB ) || defined(CONFIG_BT_CALL_FORWARDING)
  1175. static int msm_auxpcm2_be_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1176. struct snd_pcm_hw_params *params)
  1177. {
  1178. struct snd_interval *rate =
  1179. hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
  1180. struct snd_interval *channels =
  1181. hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  1182. rate->min = rate->max = 8000;
  1183. channels->min = channels->max = 1;
  1184. return 0;
  1185. }
  1186. #endif
  1187. static int msm_proxy_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1188. struct snd_pcm_hw_params *params)
  1189. {
  1190. struct snd_interval *rate = hw_param_interval(params,
  1191. SNDRV_PCM_HW_PARAM_RATE);
  1192. struct snd_interval *channels = hw_param_interval(params,
  1193. SNDRV_PCM_HW_PARAM_CHANNELS);
  1194. pr_debug("%s: msm_proxy_rx_ch =%d\n", __func__, msm_proxy_rx_ch);
  1195. if (channels->max < 2)
  1196. channels->min = channels->max = 2;
  1197. channels->min = channels->max = msm_proxy_rx_ch;
  1198. rate->min = rate->max = 48000;
  1199. return 0;
  1200. }
  1201. static int msm_proxy_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1202. struct snd_pcm_hw_params *params)
  1203. {
  1204. struct snd_interval *rate = hw_param_interval(params,
  1205. SNDRV_PCM_HW_PARAM_RATE);
  1206. rate->min = rate->max = 48000;
  1207. return 0;
  1208. }
  1209. static int msm8974_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1210. struct snd_pcm_hw_params *params)
  1211. {
  1212. struct snd_interval *rate = hw_param_interval(params,
  1213. SNDRV_PCM_HW_PARAM_RATE);
  1214. struct snd_interval *channels = hw_param_interval(params,
  1215. SNDRV_PCM_HW_PARAM_CHANNELS);
  1216. pr_info("%s channels->min %u channels->max %u ()\n", __func__,
  1217. channels->min, channels->max);
  1218. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  1219. hdmi_rx_bit_format);
  1220. if (channels->max < 2)
  1221. channels->min = channels->max = 2;
  1222. rate->min = rate->max = hdmi_rx_sample_rate;
  1223. if (channels->min != channels->max)
  1224. channels->min = channels->max;
  1225. return 0;
  1226. }
  1227. static int msm_aux_pcm_get_gpios(struct msm_auxpcm_ctrl *auxpcm_ctrl)
  1228. {
  1229. struct msm_auxpcm_gpio *pin_data = NULL;
  1230. int ret = 0;
  1231. int i;
  1232. int j;
  1233. pin_data = auxpcm_ctrl->pin_data;
  1234. for (i = 0; i < auxpcm_ctrl->cnt; i++, pin_data++) {
  1235. ret = gpio_request(pin_data->gpio_no,
  1236. pin_data->gpio_name);
  1237. pr_debug("%s: gpio = %d, gpio name = %s\n"
  1238. "ret = %d\n", __func__,
  1239. pin_data->gpio_no,
  1240. pin_data->gpio_name,
  1241. ret);
  1242. if (ret) {
  1243. pr_err("%s: Failed to request gpio %d\n",
  1244. __func__, pin_data->gpio_no);
  1245. /* Release all GPIOs on failure */
  1246. for (j = i; j >= 0; j--)
  1247. gpio_free(pin_data->gpio_no);
  1248. return ret;
  1249. }
  1250. }
  1251. return 0;
  1252. }
  1253. static int msm_aux_pcm_free_gpios(struct msm_auxpcm_ctrl *auxpcm_ctrl)
  1254. {
  1255. struct msm_auxpcm_gpio *pin_data = NULL;
  1256. int i;
  1257. int ret = 0;
  1258. if (auxpcm_ctrl == NULL || auxpcm_ctrl->pin_data == NULL) {
  1259. pr_err("%s: Ctrl pointers are NULL\n", __func__);
  1260. ret = -EINVAL;
  1261. goto err;
  1262. }
  1263. pin_data = auxpcm_ctrl->pin_data;
  1264. for (i = 0; i < auxpcm_ctrl->cnt; i++, pin_data++) {
  1265. gpio_free(pin_data->gpio_no);
  1266. pr_debug("%s: gpio = %d, gpio_name = %s\n",
  1267. __func__, pin_data->gpio_no,
  1268. pin_data->gpio_name);
  1269. }
  1270. err:
  1271. return ret;
  1272. }
  1273. static int msm_prim_auxpcm_startup(struct snd_pcm_substream *substream)
  1274. {
  1275. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1276. struct snd_soc_card *card = rtd->card;
  1277. struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  1278. struct msm_auxpcm_ctrl *auxpcm_ctrl = NULL;
  1279. int ret = 0;
  1280. pr_debug("%s(): substream = %s, prim_auxpcm_rsc_ref counter = %d\n",
  1281. __func__, substream->name, atomic_read(&prim_auxpcm_rsc_ref));
  1282. auxpcm_ctrl = pdata->pri_auxpcm_ctrl;
  1283. if (auxpcm_ctrl == NULL || auxpcm_ctrl->pin_data == NULL) {
  1284. pr_err("%s: Ctrl pointers are NULL\n", __func__);
  1285. ret = -EINVAL;
  1286. goto err;
  1287. }
  1288. if (atomic_inc_return(&prim_auxpcm_rsc_ref) == 1) {
  1289. if (auxpcm_ctrl->mux != NULL) {
  1290. iowrite32(I2S_PCM_SEL << I2S_PCM_SEL_OFFSET,
  1291. auxpcm_ctrl->mux);
  1292. } else {
  1293. pr_err("%s: Pri AUXPCM MUX addr is NULL\n", __func__);
  1294. ret = -EINVAL;
  1295. goto err;
  1296. }
  1297. ret = msm_aux_pcm_get_gpios(auxpcm_ctrl);
  1298. }
  1299. if (ret < 0) {
  1300. pr_err("%s: Aux PCM GPIO request failed\n", __func__);
  1301. return -EINVAL;
  1302. }
  1303. err:
  1304. return ret;
  1305. }
  1306. static void msm_prim_auxpcm_shutdown(struct snd_pcm_substream *substream)
  1307. {
  1308. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1309. struct snd_soc_card *card = rtd->card;
  1310. struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  1311. struct msm_auxpcm_ctrl *auxpcm_ctrl = NULL;
  1312. pr_debug("%s(): substream = %s, prim_auxpcm_rsc_ref counter = %d\n",
  1313. __func__, substream->name, atomic_read(&prim_auxpcm_rsc_ref));
  1314. auxpcm_ctrl = pdata->pri_auxpcm_ctrl;
  1315. if (atomic_dec_return(&prim_auxpcm_rsc_ref) == 0)
  1316. msm_aux_pcm_free_gpios(auxpcm_ctrl);
  1317. }
  1318. static struct snd_soc_ops msm_pri_auxpcm_be_ops = {
  1319. .startup = msm_prim_auxpcm_startup,
  1320. .shutdown = msm_prim_auxpcm_shutdown,
  1321. };
  1322. static int msm_sec_auxpcm_startup(struct snd_pcm_substream *substream)
  1323. {
  1324. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1325. struct snd_soc_card *card = rtd->card;
  1326. struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  1327. struct msm_auxpcm_ctrl *auxpcm_ctrl = NULL;
  1328. int ret = 0;
  1329. pr_debug("%s(): substream = %s, sec_auxpcm_rsc_ref counter = %d\n",
  1330. __func__, substream->name, atomic_read(&sec_auxpcm_rsc_ref));
  1331. auxpcm_ctrl = pdata->sec_auxpcm_ctrl;
  1332. if (auxpcm_ctrl == NULL || auxpcm_ctrl->pin_data == NULL) {
  1333. pr_err("%s: Ctrl pointers are NULL\n", __func__);
  1334. ret = -EINVAL;
  1335. goto err;
  1336. }
  1337. if (atomic_inc_return(&sec_auxpcm_rsc_ref) == 1) {
  1338. if (auxpcm_ctrl->mux != NULL) {
  1339. iowrite32(I2S_PCM_SEL << I2S_PCM_SEL_OFFSET,
  1340. auxpcm_ctrl->mux);
  1341. } else {
  1342. pr_err("%s Sec AUXPCM MUX addr is NULL\n", __func__);
  1343. ret = -EINVAL;
  1344. goto err;
  1345. }
  1346. ret = msm_aux_pcm_get_gpios(auxpcm_ctrl);
  1347. }
  1348. if (ret < 0) {
  1349. pr_err("%s: Aux PCM GPIO request failed\n", __func__);
  1350. return -EINVAL;
  1351. }
  1352. err:
  1353. return ret;
  1354. }
  1355. static void msm_sec_auxpcm_shutdown(struct snd_pcm_substream *substream)
  1356. {
  1357. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1358. struct snd_soc_card *card = rtd->card;
  1359. struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  1360. struct msm_auxpcm_ctrl *auxpcm_ctrl = NULL;
  1361. pr_debug("%s(): substream = %s, sec_auxpcm_rsc_ref counter = %d\n",
  1362. __func__, substream->name, atomic_read(&sec_auxpcm_rsc_ref));
  1363. auxpcm_ctrl = pdata->sec_auxpcm_ctrl;
  1364. if (atomic_dec_return(&sec_auxpcm_rsc_ref) == 0)
  1365. msm_aux_pcm_free_gpios(auxpcm_ctrl);
  1366. }
  1367. static struct snd_soc_ops msm_sec_auxpcm_be_ops = {
  1368. .startup = msm_sec_auxpcm_startup,
  1369. .shutdown = msm_sec_auxpcm_shutdown,
  1370. };
  1371. static int msm_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1372. struct snd_pcm_hw_params *params)
  1373. {
  1374. struct snd_interval *rate = hw_param_interval(params,
  1375. SNDRV_PCM_HW_PARAM_RATE);
  1376. struct snd_interval *channels =
  1377. hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  1378. pr_debug("%s()\n", __func__);
  1379. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  1380. slim0_rx_bit_format);
  1381. rate->min = rate->max = slim0_rx_sample_rate;
  1382. channels->min = channels->max = msm_slim_0_rx_ch;
  1383. pr_info("%s: format = %d, rate = %d, channels = %d\n",
  1384. __func__, params_format(params), params_rate(params),
  1385. msm_slim_0_rx_ch);
  1386. return 0;
  1387. }
  1388. static int msm_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1389. struct snd_pcm_hw_params *params)
  1390. {
  1391. struct snd_interval *rate = hw_param_interval(params,
  1392. SNDRV_PCM_HW_PARAM_RATE);
  1393. struct snd_interval *channels = hw_param_interval(params,
  1394. SNDRV_PCM_HW_PARAM_CHANNELS);
  1395. pr_debug("%s()\n", __func__);
  1396. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  1397. slim0_tx_bit_format);
  1398. rate->min = rate->max = 48000;
  1399. channels->min = channels->max = msm_slim_0_tx_ch;
  1400. pr_info("%s: format = %d, rate = %d, channels = %d\n",
  1401. __func__, params_format(params), params_rate(params),
  1402. msm_slim_0_tx_ch);
  1403. return 0;
  1404. }
  1405. static int msm_slim_4_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1406. struct snd_pcm_hw_params *params)
  1407. {
  1408. struct snd_interval *rate = hw_param_interval(params,
  1409. SNDRV_PCM_HW_PARAM_RATE);
  1410. struct snd_interval *channels = hw_param_interval(params,
  1411. SNDRV_PCM_HW_PARAM_CHANNELS);
  1412. pr_debug("%s()\n", __func__);
  1413. rate->min = rate->max = 48000;
  1414. channels->min = channels->max = 2;
  1415. return 0;
  1416. }
  1417. static int msm_slim_5_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1418. struct snd_pcm_hw_params *params)
  1419. {
  1420. int rc;
  1421. void *config;
  1422. struct snd_soc_codec *codec = rtd->codec;
  1423. struct snd_interval *rate =
  1424. hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
  1425. struct snd_interval *channels =
  1426. hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  1427. pr_debug("%s enter\n", __func__);
  1428. rate->min = rate->max = 16000;
  1429. channels->min = channels->max = 1;
  1430. config = taiko_get_afe_config(codec, AFE_SLIMBUS_SLAVE_PORT_CONFIG);
  1431. rc = afe_set_config(AFE_SLIMBUS_SLAVE_PORT_CONFIG, config,
  1432. SLIMBUS_5_TX);
  1433. if (rc) {
  1434. pr_err("%s: Failed to set slimbus slave port config %d\n",
  1435. __func__, rc);
  1436. return rc;
  1437. }
  1438. return 0;
  1439. }
  1440. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1441. struct snd_pcm_hw_params *params)
  1442. {
  1443. struct snd_interval *rate = hw_param_interval(params,
  1444. SNDRV_PCM_HW_PARAM_RATE);
  1445. pr_debug("%s()\n", __func__);
  1446. rate->min = rate->max = 48000;
  1447. return 0;
  1448. }
  1449. #if defined (CONFIG_SND_SOC_MAX98504) || defined(CONFIG_SND_SOC_MAX98505) \
  1450. || defined (CONFIG_SND_SOC_MAX98506)
  1451. static int msm8974_mi2s_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1452. struct snd_pcm_hw_params *params)
  1453. {
  1454. struct snd_interval *rate =
  1455. hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
  1456. struct snd_interval *channels =
  1457. hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  1458. pr_debug("%s: enter\n", __func__);
  1459. rate->min = rate->max = 48000;
  1460. channels->min = channels->max = 2;
  1461. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  1462. SNDRV_PCM_FORMAT_S16_LE);
  1463. return 0;
  1464. }
  1465. #endif
  1466. static int msm_be_fm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1467. struct snd_pcm_hw_params *params)
  1468. {
  1469. struct snd_interval *rate =
  1470. hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
  1471. struct snd_interval *channels =
  1472. hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  1473. pr_debug("%s()\n", __func__);
  1474. rate->min = rate->max = 48000;
  1475. channels->min = channels->max = 2;
  1476. return 0;
  1477. }
  1478. static const struct soc_enum msm_snd_enum[] = {
  1479. SOC_ENUM_SINGLE_EXT(2, spk_function),
  1480. SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text),
  1481. SOC_ENUM_SINGLE_EXT(8, slim0_tx_ch_text),
  1482. SOC_ENUM_SINGLE_EXT(7, hdmi_rx_ch_text),
  1483. SOC_ENUM_SINGLE_EXT(2, rx_bit_format_text),
  1484. SOC_ENUM_SINGLE_EXT(3, slim0_rx_sample_rate_text),
  1485. SOC_ENUM_SINGLE_EXT(8, proxy_rx_ch_text),
  1486. SOC_ENUM_SINGLE_EXT(3, hdmi_rx_sample_rate_text),
  1487. };
  1488. static const struct snd_kcontrol_new msm_snd_controls[] = {
  1489. SOC_ENUM_EXT("Speaker Function", msm_snd_enum[0], msm8974_get_spk,
  1490. msm8974_set_spk),
  1491. SOC_ENUM_EXT("SLIM_0_RX Channels", msm_snd_enum[1],
  1492. msm_slim_0_rx_ch_get, msm_slim_0_rx_ch_put),
  1493. SOC_ENUM_EXT("SLIM_0_TX Channels", msm_snd_enum[2],
  1494. msm_slim_0_tx_ch_get, msm_slim_0_tx_ch_put),
  1495. SOC_ENUM_EXT("AUX PCM SampleRate", msm8974_auxpcm_enum[0],
  1496. msm8974_auxpcm_rate_get, msm8974_auxpcm_rate_put),
  1497. SOC_ENUM_EXT("HDMI_RX Channels", msm_snd_enum[3],
  1498. msm_hdmi_rx_ch_get, msm_hdmi_rx_ch_put),
  1499. SOC_ENUM_EXT("SLIM_0_RX Format", msm_snd_enum[4],
  1500. slim0_rx_bit_format_get, slim0_rx_bit_format_put),
  1501. SOC_ENUM_EXT("SLIM_0_RX SampleRate", msm_snd_enum[5],
  1502. slim0_rx_sample_rate_get, slim0_rx_sample_rate_put),
  1503. SOC_ENUM_EXT("HDMI_RX Bit Format", msm_snd_enum[4],
  1504. hdmi_rx_bit_format_get, hdmi_rx_bit_format_put),
  1505. SOC_ENUM_EXT("PROXY_RX Channels", msm_snd_enum[6],
  1506. msm_proxy_rx_ch_get, msm_proxy_rx_ch_put),
  1507. SOC_ENUM_EXT("Internal BTSCO SampleRate", msm_btsco_enum[0],
  1508. msm_btsco_rate_get, msm_btsco_rate_put),
  1509. SOC_ENUM_EXT("HDMI_RX SampleRate", msm_snd_enum[7],
  1510. hdmi_rx_sample_rate_get, hdmi_rx_sample_rate_put),
  1511. SOC_SINGLE_EXT("Main Mic Delay",SND_SOC_NOPM, 0, 100, 0,
  1512. main_mic_delay_get, main_mic_delay_put),
  1513. #if defined(CONFIG_SEC_H_PROJECT)
  1514. SOC_SINGLE_EXT("SPK Status",SND_SOC_NOPM, 0, 1, 0,
  1515. speaker_status_get, speaker_status_put),
  1516. #endif
  1517. };
  1518. static bool msm8974_swap_gnd_mic(struct snd_soc_codec *codec)
  1519. {
  1520. struct snd_soc_card *card = codec->card;
  1521. struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  1522. int value = gpio_get_value_cansleep(pdata->us_euro_gpio);
  1523. pr_debug("%s: swap select switch %d to %d\n", __func__, value, !value);
  1524. gpio_set_value_cansleep(pdata->us_euro_gpio, !value);
  1525. return true;
  1526. }
  1527. static int msm_afe_set_config(struct snd_soc_codec *codec)
  1528. {
  1529. int rc;
  1530. void *config_data;
  1531. pr_debug("%s: enter\n", __func__);
  1532. config_data = taiko_get_afe_config(codec, AFE_CDC_REGISTERS_CONFIG);
  1533. rc = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
  1534. if (rc) {
  1535. pr_err("%s: Failed to set codec registers config %d\n",
  1536. __func__, rc);
  1537. return rc;
  1538. }
  1539. config_data = taiko_get_afe_config(codec, AFE_SLIMBUS_SLAVE_CONFIG);
  1540. rc = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
  1541. if (rc) {
  1542. pr_err("%s: Failed to set slimbus slave config %d\n", __func__,
  1543. rc);
  1544. return rc;
  1545. }
  1546. return 0;
  1547. }
  1548. static void msm_afe_clear_config(void)
  1549. {
  1550. afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
  1551. afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
  1552. }
  1553. static int msm8974_adsp_state_callback(struct notifier_block *nb,
  1554. unsigned long value, void *priv)
  1555. {
  1556. if (value == SUBSYS_BEFORE_SHUTDOWN) {
  1557. pr_debug("%s: ADSP is about to shutdown. Clearing AFE config\n",
  1558. __func__);
  1559. msm_afe_clear_config();
  1560. } else if (value == SUBSYS_AFTER_POWERUP) {
  1561. pr_debug("%s: ADSP is up\n", __func__);
  1562. }
  1563. return NOTIFY_OK;
  1564. }
  1565. static struct notifier_block adsp_state_notifier_block = {
  1566. .notifier_call = msm8974_adsp_state_callback,
  1567. .priority = -INT_MAX,
  1568. };
  1569. static int msm8974_taiko_codec_up(struct snd_soc_codec *codec)
  1570. {
  1571. int err;
  1572. unsigned long timeout;
  1573. int adsp_ready = 0;
  1574. timeout = jiffies +
  1575. msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
  1576. do {
  1577. if (!q6core_is_adsp_ready()) {
  1578. pr_err("%s: ADSP Audio isn't ready\n", __func__);
  1579. } else {
  1580. pr_debug("%s: ADSP Audio is ready\n", __func__);
  1581. adsp_ready = 1;
  1582. break;
  1583. }
  1584. } while (time_after(timeout, jiffies));
  1585. if (!adsp_ready) {
  1586. pr_err("%s: timed out waiting for ADSP Audio\n", __func__);
  1587. return -ETIMEDOUT;
  1588. }
  1589. err = msm_afe_set_config(codec);
  1590. if (err)
  1591. pr_err("%s: Failed to set AFE config. err %d\n",
  1592. __func__, err);
  1593. return err;
  1594. }
  1595. static int msm8974_taiko_event_cb(struct snd_soc_codec *codec,
  1596. enum wcd9xxx_codec_event codec_event)
  1597. {
  1598. switch (codec_event) {
  1599. case WCD9XXX_CODEC_EVENT_CODEC_UP:
  1600. return msm8974_taiko_codec_up(codec);
  1601. break;
  1602. default:
  1603. pr_err("%s: UnSupported codec event %d\n",
  1604. __func__, codec_event);
  1605. return -EINVAL;
  1606. }
  1607. }
  1608. #if defined(CONFIG_MACH_KLTE_KOR) || defined(CONFIG_MACH_KLTE_JPN) || defined(CONFIG_MACH_KACTIVELTE_DCM) || defined(CONFIG_MACH_CHAGALL_KDI) || defined(CONFIG_MACH_KLIMT_LTE_DCM)
  1609. extern unsigned int system_rev;
  1610. #endif
  1611. static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
  1612. {
  1613. int err;
  1614. void *config_data;
  1615. struct snd_soc_codec *codec = rtd->codec;
  1616. struct snd_soc_dapm_context *dapm = &codec->dapm;
  1617. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1618. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  1619. #if defined(CONFIG_SEC_JACTIVE_PROJECT)
  1620. extern unsigned int system_rev;
  1621. #endif
  1622. /* Taiko SLIMBUS configuration
  1623. * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13
  1624. * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
  1625. * TX14, TX15, TX16
  1626. */
  1627. unsigned int rx_ch[TAIKO_RX_MAX] = {144, 145, 146, 147, 148, 149, 150,
  1628. 151, 152, 153, 154, 155, 156};
  1629. unsigned int tx_ch[TAIKO_TX_MAX] = {128, 129, 130, 131, 132, 133,
  1630. 134, 135, 136, 137, 138, 139,
  1631. 140, 141, 142, 143};
  1632. pr_info("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev));
  1633. rtd->pmdown_time = 0;
  1634. err = snd_soc_add_codec_controls(codec, msm_snd_controls,
  1635. ARRAY_SIZE(msm_snd_controls));
  1636. if (err < 0)
  1637. return err;
  1638. err = msm8974_liquid_ext_spk_power_amp_init();
  1639. if (err) {
  1640. pr_err("%s: LiQUID 8974 CLASS_D PAs init failed (%d)\n",
  1641. __func__, err);
  1642. return err;
  1643. }
  1644. err = msm8974_liquid_init_docking(dapm);
  1645. if (err) {
  1646. pr_err("%s: LiQUID 8974 init Docking stat IRQ failed (%d)\n",
  1647. __func__, err);
  1648. return err;
  1649. }
  1650. #if defined(CONFIG_SEC_JACTIVE_PROJECT)
  1651. pr_info("1. msm_audrx_init system_rev %d",system_rev);
  1652. if(system_rev < 3) {
  1653. snd_soc_dapm_new_controls(dapm, msm8974_dapm_widgets_01,
  1654. ARRAY_SIZE(msm8974_dapm_widgets_01));
  1655. }
  1656. else
  1657. {
  1658. snd_soc_dapm_new_controls(dapm, msm8974_dapm_widgets,
  1659. ARRAY_SIZE(msm8974_dapm_widgets));
  1660. }
  1661. #else
  1662. snd_soc_dapm_new_controls(dapm, msm8974_dapm_widgets,
  1663. ARRAY_SIZE(msm8974_dapm_widgets));
  1664. #endif
  1665. snd_soc_dapm_enable_pin(dapm, "Lineout_1 amp");
  1666. snd_soc_dapm_enable_pin(dapm, "Lineout_3 amp");
  1667. snd_soc_dapm_enable_pin(dapm, "Lineout_2 amp");
  1668. snd_soc_dapm_enable_pin(dapm, "Lineout_4 amp");
  1669. snd_soc_dapm_sync(dapm);
  1670. codec_clk = clk_get(cpu_dai->dev, "osr_clk");
  1671. snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  1672. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  1673. err = msm_afe_set_config(codec);
  1674. if (err) {
  1675. pr_err("%s: Failed to set AFE config %d\n", __func__, err);
  1676. goto out;
  1677. }
  1678. config_data = taiko_get_afe_config(codec, AFE_AANC_VERSION);
  1679. err = afe_set_config(AFE_AANC_VERSION, config_data, 0);
  1680. if (err) {
  1681. pr_err("%s: Failed to set aanc version %d\n",
  1682. __func__, err);
  1683. goto out;
  1684. }
  1685. config_data = taiko_get_afe_config(codec,
  1686. AFE_CDC_CLIP_REGISTERS_CONFIG);
  1687. if (config_data) {
  1688. err = afe_set_config(AFE_CDC_CLIP_REGISTERS_CONFIG,
  1689. config_data, 0);
  1690. if (err) {
  1691. pr_err("%s: Failed to set clip registers %d\n",
  1692. __func__, err);
  1693. return err;
  1694. }
  1695. }
  1696. config_data = taiko_get_afe_config(codec, AFE_CLIP_BANK_SEL);
  1697. if (config_data) {
  1698. err = afe_set_config(AFE_CLIP_BANK_SEL, config_data, 0);
  1699. if (err) {
  1700. pr_err("%s: Failed to set AFE bank selection %d\n",
  1701. __func__, err);
  1702. return err;
  1703. }
  1704. }
  1705. #if defined(CONFIG_MACH_KLTE_KOR)
  1706. if (system_rev >= 13) {
  1707. pr_info("%s: USE MBHC revision %d\n", __func__, system_rev);
  1708. /* start mbhc */
  1709. mbhc_cfg.calibration = def_taiko_mbhc_cal();
  1710. if (mbhc_cfg.calibration) {
  1711. err = taiko_hs_detect(codec, &mbhc_cfg);
  1712. if (err)
  1713. goto out;
  1714. } else {
  1715. err = -ENOMEM;
  1716. goto out;
  1717. }
  1718. }
  1719. #elif defined(CONFIG_MACH_KLTE_JPN)
  1720. if (system_rev >= 11) {
  1721. pr_info("%s: USE MBHC revision %d\n", __func__, system_rev);
  1722. /* start mbhc */
  1723. mbhc_cfg.calibration = def_taiko_mbhc_cal();
  1724. if (mbhc_cfg.calibration) {
  1725. err = taiko_hs_detect(codec, &mbhc_cfg);
  1726. if (err)
  1727. goto out;
  1728. } else {
  1729. err = -ENOMEM;
  1730. goto out;
  1731. }
  1732. }
  1733. #else
  1734. #if !defined(CONFIG_SAMSUNG_JACK) && !defined(CONFIG_MUIC_DET_JACK)
  1735. /* start mbhc */
  1736. mbhc_cfg.calibration = def_taiko_mbhc_cal();
  1737. if (mbhc_cfg.calibration) {
  1738. err = taiko_hs_detect(codec, &mbhc_cfg);
  1739. if (err)
  1740. goto out;
  1741. } else {
  1742. err = -ENOMEM;
  1743. goto out;
  1744. }
  1745. #elif defined(CONFIG_SEC_JACTIVE_PROJECT)
  1746. pr_info("2. msm_audrx_init system_rev %d",system_rev);
  1747. if(system_rev < 3) {
  1748. mbhc_cfg.calibration = def_taiko_mbhc_cal();
  1749. if (mbhc_cfg.calibration) {
  1750. err = taiko_hs_detect(codec, &mbhc_cfg);
  1751. if (err)
  1752. goto out;
  1753. else
  1754. return err;
  1755. } else {
  1756. err = -ENOMEM;
  1757. goto out;
  1758. }
  1759. }
  1760. #endif
  1761. #endif /* CONFIG_MACH_KLTE_KOR */
  1762. adsp_state_notifier =
  1763. subsys_notif_register_notifier("adsp",
  1764. &adsp_state_notifier_block);
  1765. if (!adsp_state_notifier) {
  1766. pr_err("%s: Failed to register adsp state notifier\n",
  1767. __func__);
  1768. err = -EFAULT;
  1769. #if defined(CONFIG_MACH_KLTE_KOR)
  1770. if (system_rev >= 13) {
  1771. taiko_hs_detect_exit(codec);
  1772. }
  1773. #elif defined(CONFIG_MACH_KLTE_JPN)
  1774. if (system_rev >= 11) {
  1775. taiko_hs_detect_exit(codec);
  1776. }
  1777. #else
  1778. #if !defined(CONFIG_SAMSUNG_JACK) && !defined(CONFIG_MUIC_DET_JACK)
  1779. taiko_hs_detect_exit(codec);
  1780. #endif
  1781. #endif /* CONFIG_MACH_KLTE_KOR */
  1782. goto out;
  1783. }
  1784. taiko_event_register(msm8974_taiko_event_cb, rtd->codec);
  1785. return 0;
  1786. out:
  1787. clk_put(codec_clk);
  1788. return err;
  1789. }
  1790. static int msm8974_snd_startup(struct snd_pcm_substream *substream)
  1791. {
  1792. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  1793. substream->name, substream->stream);
  1794. return 0;
  1795. }
  1796. void *def_taiko_mbhc_cal(void)
  1797. {
  1798. void *taiko_cal;
  1799. struct wcd9xxx_mbhc_btn_detect_cfg *btn_cfg;
  1800. u16 *btn_low, *btn_high;
  1801. u8 *n_ready, *n_cic, *gain;
  1802. taiko_cal = kzalloc(WCD9XXX_MBHC_CAL_SIZE(WCD9XXX_MBHC_DEF_BUTTONS,
  1803. WCD9XXX_MBHC_DEF_RLOADS),
  1804. GFP_KERNEL);
  1805. if (!taiko_cal) {
  1806. pr_err("%s: out of memory\n", __func__);
  1807. return NULL;
  1808. }
  1809. #define S(X, Y) ((WCD9XXX_MBHC_CAL_GENERAL_PTR(taiko_cal)->X) = (Y))
  1810. S(t_ldoh, 100);
  1811. S(t_bg_fast_settle, 100);
  1812. S(t_shutdown_plug_rem, 255);
  1813. S(mbhc_nsa, 4);
  1814. S(mbhc_navg, 4);
  1815. #undef S
  1816. #define S(X, Y) ((WCD9XXX_MBHC_CAL_PLUG_DET_PTR(taiko_cal)->X) = (Y))
  1817. S(mic_current, TAIKO_PID_MIC_5_UA);
  1818. S(hph_current, TAIKO_PID_MIC_5_UA);
  1819. S(t_mic_pid, 100);
  1820. S(t_ins_complete, 250);
  1821. S(t_ins_retry, 200);
  1822. #undef S
  1823. #define S(X, Y) ((WCD9XXX_MBHC_CAL_PLUG_TYPE_PTR(taiko_cal)->X) = (Y))
  1824. S(v_no_mic, 950);
  1825. S(v_hs_max, 3000);
  1826. #undef S
  1827. #define S(X, Y) ((WCD9XXX_MBHC_CAL_BTN_DET_PTR(taiko_cal)->X) = (Y))
  1828. S(c[0], 62);
  1829. S(c[1], 124);
  1830. S(nc, 1);
  1831. S(n_meas, 3);
  1832. S(mbhc_nsc, 11);
  1833. S(n_btn_meas, 1);
  1834. S(n_btn_con, 2);
  1835. S(num_btn, WCD9XXX_MBHC_DEF_BUTTONS);
  1836. S(v_btn_press_delta_sta, 100);
  1837. S(v_btn_press_delta_cic, 50);
  1838. #undef S
  1839. btn_cfg = WCD9XXX_MBHC_CAL_BTN_DET_PTR(taiko_cal);
  1840. btn_low = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_V_BTN_LOW);
  1841. btn_high = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg,
  1842. MBHC_BTN_DET_V_BTN_HIGH);
  1843. btn_low[0] = -50;
  1844. btn_high[0] = 160;
  1845. btn_low[1] = 161;
  1846. btn_high[1] = 330;
  1847. btn_low[2] = 331;
  1848. btn_high[2] = 730;
  1849. n_ready = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_N_READY);
  1850. n_ready[0] = 80;
  1851. n_ready[1] = 68;
  1852. n_cic = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_N_CIC);
  1853. n_cic[0] = 60;
  1854. n_cic[1] = 47;
  1855. gain = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_GAIN);
  1856. gain[0] = 11;
  1857. gain[1] = 9;
  1858. return taiko_cal;
  1859. }
  1860. static int msm_snd_hw_params(struct snd_pcm_substream *substream,
  1861. struct snd_pcm_hw_params *params)
  1862. {
  1863. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1864. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  1865. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1866. int ret = 0;
  1867. unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  1868. unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
  1869. unsigned int user_set_tx_ch = 0;
  1870. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1871. pr_debug("%s: rx_0_ch=%d\n", __func__, msm_slim_0_rx_ch);
  1872. ret = snd_soc_dai_get_channel_map(codec_dai,
  1873. &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
  1874. if (ret < 0) {
  1875. pr_err("%s: failed to get codec chan map\n", __func__);
  1876. goto end;
  1877. }
  1878. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  1879. msm_slim_0_rx_ch, rx_ch);
  1880. if (ret < 0) {
  1881. pr_err("%s: failed to set cpu chan map\n", __func__);
  1882. goto end;
  1883. }
  1884. } else {
  1885. pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
  1886. codec_dai->name, codec_dai->id, user_set_tx_ch);
  1887. ret = snd_soc_dai_get_channel_map(codec_dai,
  1888. &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
  1889. if (ret < 0) {
  1890. pr_err("%s: failed to get codec chan map\n", __func__);
  1891. goto end;
  1892. }
  1893. /* For tabla_tx1 case */
  1894. #if defined(CONFIG_SND_SOC_ES705)
  1895. if (codec_dai->id == 1)
  1896. user_set_tx_ch = msm_slim_0_tx_ch;
  1897. #elif defined(CONFIG_SND_SOC_ES325)
  1898. if ((codec_dai->id == 1) ||(codec_dai->id == 11)) {
  1899. user_set_tx_ch = msm_slim_0_tx_ch;
  1900. }
  1901. #else
  1902. if (codec_dai->id == 1)
  1903. user_set_tx_ch = msm_slim_0_tx_ch;
  1904. #endif
  1905. /* For tabla_tx2 case */
  1906. else if (codec_dai->id == 3)
  1907. user_set_tx_ch = params_channels(params);
  1908. else
  1909. user_set_tx_ch = tx_ch_cnt;
  1910. pr_info("%s: msm_slim_0_tx_ch(%d)user_set_tx_ch(%d)tx_ch_cnt(%d)\n",
  1911. __func__, msm_slim_0_tx_ch, user_set_tx_ch, tx_ch_cnt);
  1912. ret = snd_soc_dai_set_channel_map(cpu_dai,
  1913. user_set_tx_ch, tx_ch, 0 , 0);
  1914. if (ret < 0) {
  1915. pr_err("%s: failed to set cpu chan map\n", __func__);
  1916. goto end;
  1917. }
  1918. }
  1919. end:
  1920. return ret;
  1921. }
  1922. static void msm8974_snd_shudown(struct snd_pcm_substream *substream)
  1923. {
  1924. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  1925. substream->name, substream->stream);
  1926. }
  1927. #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98506)
  1928. static int msm8974_pri_mi2s_free_gpios(void)
  1929. {
  1930. int i;
  1931. for (i = 0; i < ARRAY_SIZE(pri_mi2s_gpio); i++)
  1932. gpio_free(pri_mi2s_gpio[i].gpio_no);
  1933. return 0;
  1934. }
  1935. static struct afe_clk_cfg lpass_mi2s_enable = {
  1936. AFE_API_VERSION_I2S_CONFIG,
  1937. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  1938. Q6AFE_LPASS_OSR_CLK_12_P288_MHZ,
  1939. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  1940. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  1941. Q6AFE_LPASS_MODE_BOTH_VALID,
  1942. 0,
  1943. };
  1944. static struct afe_clk_cfg lpass_mi2s_disable = {
  1945. AFE_API_VERSION_I2S_CONFIG,
  1946. 0,
  1947. 0,
  1948. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  1949. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  1950. Q6AFE_LPASS_MODE_BOTH_VALID,
  1951. 0,
  1952. };
  1953. static void msm8974_mi2s_shutdown(struct snd_pcm_substream *substream)
  1954. {
  1955. if (atomic_dec_return(&pri_mi2s_clk.mi2s_rsc_ref) == 0) {
  1956. int ret = 0;
  1957. u16 port_id = 0;
  1958. pr_debug("[MAX9850x_DEBUG] %s: free mi2s resources\n", __func__);
  1959. #if defined (CONFIG_TERT_MI2S_ENABLE)
  1960. port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  1961. #else
  1962. port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  1963. #endif
  1964. if(substream->stream == 0)
  1965. ret = afe_set_lpass_clock(port_id, &lpass_mi2s_disable);
  1966. else if(substream->stream == 1)
  1967. ret = afe_set_lpass_clock(port_id, &lpass_mi2s_disable);
  1968. if (ret < 0) {
  1969. pr_err("%s: afe_set_lpass_clock failed\n", __func__);
  1970. }
  1971. msm8974_pri_mi2s_free_gpios();
  1972. }
  1973. }
  1974. static int msm8974_configure_pri_mi2s_gpio(void)
  1975. {
  1976. int rtn;
  1977. int i;
  1978. for (i = 0; i < ARRAY_SIZE(pri_mi2s_gpio); i++) {
  1979. rtn = gpio_request(pri_mi2s_gpio[i].gpio_no,
  1980. pri_mi2s_gpio[i].gpio_name);
  1981. pr_debug("%s: gpio = %d, gpio name = %s, rtn = %d\n", __func__,
  1982. pri_mi2s_gpio[i].gpio_no, pri_mi2s_gpio[i].gpio_name, rtn);
  1983. if (rtn) {
  1984. pr_err("%s: Failed to request gpio %d\n",
  1985. __func__,
  1986. pri_mi2s_gpio[i].gpio_no);
  1987. while( i >= 0) {
  1988. gpio_free(pri_mi2s_gpio[i].gpio_no);
  1989. i--;
  1990. }
  1991. break;
  1992. }
  1993. }
  1994. return rtn;
  1995. }
  1996. static int msm8974_mi2s_startup(struct snd_pcm_substream *substream)
  1997. {
  1998. int ret = 0;
  1999. u16 port_id = 0;
  2000. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2001. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  2002. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  2003. pr_debug("%s: dai name %s %p\n", __func__, cpu_dai->name, cpu_dai->dev);
  2004. if (atomic_inc_return(&pri_mi2s_clk.mi2s_rsc_ref) == 1) {
  2005. pr_info("%s: acquire mi2s resources\n", __func__);
  2006. msm8974_configure_pri_mi2s_gpio();
  2007. #if defined (CONFIG_TERT_MI2S_ENABLE)
  2008. port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  2009. #else
  2010. port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  2011. #endif
  2012. if(substream->stream == 0)
  2013. ret = afe_set_lpass_clock(port_id, &lpass_mi2s_enable);
  2014. else if(substream->stream == 1)
  2015. ret = afe_set_lpass_clock(port_id, &lpass_mi2s_enable);
  2016. if (ret < 0) {
  2017. pr_err("%s: afe_set_lpass_clock failed\n", __func__);
  2018. return ret;
  2019. }
  2020. ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
  2021. if (ret < 0)
  2022. dev_err(cpu_dai->dev, "set format for CPU dai"
  2023. " failed\n");
  2024. ret = snd_soc_dai_set_fmt(codec_dai,
  2025. SND_SOC_DAIFMT_I2S |
  2026. SND_SOC_DAIFMT_NB_NF |
  2027. SND_SOC_DAIFMT_CBS_CFS);
  2028. if (ret < 0)
  2029. dev_err(codec_dai->dev, "set format for codec dai"
  2030. " failed\n");
  2031. ret = 0;
  2032. }
  2033. return ret;
  2034. }
  2035. static struct snd_soc_ops msm8974_mi2s_be_ops = {
  2036. .startup = msm8974_mi2s_startup,
  2037. .shutdown = msm8974_mi2s_shutdown
  2038. };
  2039. #endif
  2040. static struct snd_soc_ops msm8974_be_ops = {
  2041. .startup = msm8974_snd_startup,
  2042. .hw_params = msm_snd_hw_params,
  2043. .shutdown = msm8974_snd_shudown,
  2044. };
  2045. static int msm8974_slimbus_2_hw_params(struct snd_pcm_substream *substream,
  2046. struct snd_pcm_hw_params *params)
  2047. {
  2048. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2049. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  2050. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  2051. int ret = 0;
  2052. unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  2053. unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
  2054. unsigned int num_tx_ch = 0;
  2055. unsigned int num_rx_ch = 0;
  2056. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  2057. num_rx_ch = params_channels(params);
  2058. pr_debug("%s: %s rx_dai_id = %d num_ch = %d\n", __func__,
  2059. codec_dai->name, codec_dai->id, num_rx_ch);
  2060. ret = snd_soc_dai_get_channel_map(codec_dai,
  2061. &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
  2062. if (ret < 0) {
  2063. pr_err("%s: failed to get codec chan map\n", __func__);
  2064. goto end;
  2065. }
  2066. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  2067. num_rx_ch, rx_ch);
  2068. if (ret < 0) {
  2069. pr_err("%s: failed to set cpu chan map\n", __func__);
  2070. goto end;
  2071. }
  2072. } else {
  2073. num_tx_ch = params_channels(params);
  2074. pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__,
  2075. codec_dai->name, codec_dai->id, num_tx_ch);
  2076. ret = snd_soc_dai_get_channel_map(codec_dai,
  2077. &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
  2078. if (ret < 0) {
  2079. pr_err("%s: failed to get codec chan map\n", __func__);
  2080. goto end;
  2081. }
  2082. ret = snd_soc_dai_set_channel_map(cpu_dai,
  2083. num_tx_ch, tx_ch, 0 , 0);
  2084. if (ret < 0) {
  2085. pr_err("%s: failed to set cpu chan map\n", __func__);
  2086. goto end;
  2087. }
  2088. }
  2089. end:
  2090. return ret;
  2091. }
  2092. static struct snd_soc_ops msm8974_slimbus_2_be_ops = {
  2093. .startup = msm8974_snd_startup,
  2094. .hw_params = msm8974_slimbus_2_hw_params,
  2095. .shutdown = msm8974_snd_shudown,
  2096. };
  2097. /* Digital audio interface glue - connects codec <---> CPU */
  2098. static struct snd_soc_dai_link msm8974_common_dai_links[] = {
  2099. /* FrontEnd DAI Links */
  2100. {
  2101. .name = "MSM8974 Media1",
  2102. .stream_name = "MultiMedia1",
  2103. .cpu_dai_name = "MultiMedia1",
  2104. .platform_name = "msm-pcm-dsp.0",
  2105. .dynamic = 1,
  2106. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2107. SND_SOC_DPCM_TRIGGER_POST},
  2108. .codec_dai_name = "snd-soc-dummy-dai",
  2109. .codec_name = "snd-soc-dummy",
  2110. .ignore_suspend = 1,
  2111. /* this dainlink has playback support */
  2112. .ignore_pmdown_time = 1,
  2113. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1
  2114. },
  2115. {
  2116. .name = "MSM8974 Media2",
  2117. .stream_name = "MultiMedia2",
  2118. .cpu_dai_name = "MultiMedia2",
  2119. .platform_name = "msm-pcm-dsp.0",
  2120. .dynamic = 1,
  2121. .codec_dai_name = "snd-soc-dummy-dai",
  2122. .codec_name = "snd-soc-dummy",
  2123. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2124. SND_SOC_DPCM_TRIGGER_POST},
  2125. .ignore_suspend = 1,
  2126. /* this dainlink has playback support */
  2127. .ignore_pmdown_time = 1,
  2128. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  2129. },
  2130. {
  2131. .name = "Circuit-Switch Voice",
  2132. .stream_name = "CS-Voice",
  2133. .cpu_dai_name = "CS-VOICE",
  2134. .platform_name = "msm-pcm-voice",
  2135. .dynamic = 1,
  2136. .codec_dai_name = "snd-soc-dummy-dai",
  2137. .codec_name = "snd-soc-dummy",
  2138. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2139. SND_SOC_DPCM_TRIGGER_POST},
  2140. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2141. .ignore_suspend = 1,
  2142. /* this dainlink has playback support */
  2143. .ignore_pmdown_time = 1,
  2144. .be_id = MSM_FRONTEND_DAI_CS_VOICE,
  2145. },
  2146. {
  2147. .name = "MSM VoIP",
  2148. .stream_name = "VoIP",
  2149. .cpu_dai_name = "VoIP",
  2150. .platform_name = "msm-voip-dsp",
  2151. .dynamic = 1,
  2152. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2153. SND_SOC_DPCM_TRIGGER_POST},
  2154. .codec_dai_name = "snd-soc-dummy-dai",
  2155. .codec_name = "snd-soc-dummy",
  2156. .ignore_suspend = 1,
  2157. /* this dainlink has playback support */
  2158. .ignore_pmdown_time = 1,
  2159. .be_id = MSM_FRONTEND_DAI_VOIP,
  2160. },
  2161. {
  2162. .name = "MSM8974 LPA",
  2163. .stream_name = "LPA",
  2164. .cpu_dai_name = "MultiMedia3",
  2165. .platform_name = "msm-pcm-lpa",
  2166. .dynamic = 1,
  2167. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2168. SND_SOC_DPCM_TRIGGER_POST},
  2169. .codec_dai_name = "snd-soc-dummy-dai",
  2170. .codec_name = "snd-soc-dummy",
  2171. .ignore_suspend = 1,
  2172. /* this dainlink has playback support */
  2173. .ignore_pmdown_time = 1,
  2174. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  2175. },
  2176. /* Hostless PCM purpose */
  2177. {
  2178. .name = "SLIMBUS_0 Hostless",
  2179. .stream_name = "SLIMBUS_0 Hostless",
  2180. .cpu_dai_name = "SLIMBUS0_HOSTLESS",
  2181. .platform_name = "msm-pcm-hostless",
  2182. .dynamic = 1,
  2183. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2184. SND_SOC_DPCM_TRIGGER_POST},
  2185. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2186. .ignore_suspend = 1,
  2187. .ignore_pmdown_time = 1, /* dai link has playback support */
  2188. .codec_dai_name = "snd-soc-dummy-dai",
  2189. .codec_name = "snd-soc-dummy",
  2190. },
  2191. {
  2192. .name = "INT_FM Hostless",
  2193. .stream_name = "INT_FM Hostless",
  2194. .cpu_dai_name = "INT_FM_HOSTLESS",
  2195. .platform_name = "msm-pcm-hostless",
  2196. .dynamic = 1,
  2197. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2198. SND_SOC_DPCM_TRIGGER_POST},
  2199. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2200. .ignore_suspend = 1,
  2201. /* this dainlink has playback support */
  2202. .ignore_pmdown_time = 1,
  2203. .codec_dai_name = "snd-soc-dummy-dai",
  2204. .codec_name = "snd-soc-dummy",
  2205. },
  2206. {
  2207. .name = "MSM AFE-PCM RX",
  2208. .stream_name = "AFE-PROXY RX",
  2209. .cpu_dai_name = "msm-dai-q6-dev.241",
  2210. .codec_name = "msm-stub-codec.1",
  2211. .codec_dai_name = "msm-stub-rx",
  2212. .platform_name = "msm-pcm-afe",
  2213. .ignore_suspend = 1,
  2214. /* this dainlink has playback support */
  2215. .ignore_pmdown_time = 1,
  2216. },
  2217. {
  2218. .name = "MSM AFE-PCM TX",
  2219. .stream_name = "AFE-PROXY TX",
  2220. .cpu_dai_name = "msm-dai-q6-dev.240",
  2221. .codec_name = "msm-stub-codec.1",
  2222. .codec_dai_name = "msm-stub-tx",
  2223. .platform_name = "msm-pcm-afe",
  2224. .ignore_suspend = 1,
  2225. },
  2226. {
  2227. .name = "MSM8974 Compr",
  2228. .stream_name = "COMPR",
  2229. .cpu_dai_name = "MultiMedia4",
  2230. .platform_name = "msm-compress-dsp",
  2231. .dynamic = 1,
  2232. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2233. SND_SOC_DPCM_TRIGGER_POST},
  2234. .codec_dai_name = "snd-soc-dummy-dai",
  2235. .codec_name = "snd-soc-dummy",
  2236. .ignore_suspend = 1,
  2237. .ignore_pmdown_time = 1,
  2238. /* this dainlink has playback support */
  2239. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  2240. },
  2241. {
  2242. .name = "AUXPCM Hostless",
  2243. .stream_name = "AUXPCM Hostless",
  2244. .cpu_dai_name = "AUXPCM_HOSTLESS",
  2245. .platform_name = "msm-pcm-hostless",
  2246. .dynamic = 1,
  2247. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2248. SND_SOC_DPCM_TRIGGER_POST},
  2249. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2250. .ignore_suspend = 1,
  2251. /* this dainlink has playback support */
  2252. .ignore_pmdown_time = 1,
  2253. .codec_dai_name = "snd-soc-dummy-dai",
  2254. .codec_name = "snd-soc-dummy",
  2255. },
  2256. {
  2257. .name = "SLIMBUS_1 Hostless",
  2258. .stream_name = "SLIMBUS_1 Hostless",
  2259. .cpu_dai_name = "SLIMBUS1_HOSTLESS",
  2260. .platform_name = "msm-pcm-hostless",
  2261. .dynamic = 1,
  2262. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2263. SND_SOC_DPCM_TRIGGER_POST},
  2264. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2265. .ignore_suspend = 1,
  2266. .ignore_pmdown_time = 1, /* dai link has playback support */
  2267. .codec_dai_name = "snd-soc-dummy-dai",
  2268. .codec_name = "snd-soc-dummy",
  2269. },
  2270. {
  2271. .name = "SLIMBUS_3 Hostless",
  2272. .stream_name = "SLIMBUS_3 Hostless",
  2273. .cpu_dai_name = "SLIMBUS3_HOSTLESS",
  2274. .platform_name = "msm-pcm-hostless",
  2275. .dynamic = 1,
  2276. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2277. SND_SOC_DPCM_TRIGGER_POST},
  2278. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2279. .ignore_suspend = 1,
  2280. .ignore_pmdown_time = 1, /* dai link has playback support */
  2281. .codec_dai_name = "snd-soc-dummy-dai",
  2282. .codec_name = "snd-soc-dummy",
  2283. },
  2284. {
  2285. .name = "SLIMBUS_4 Hostless",
  2286. .stream_name = "SLIMBUS_4 Hostless",
  2287. .cpu_dai_name = "SLIMBUS4_HOSTLESS",
  2288. .platform_name = "msm-pcm-hostless",
  2289. .dynamic = 1,
  2290. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2291. SND_SOC_DPCM_TRIGGER_POST},
  2292. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2293. .ignore_suspend = 1,
  2294. .ignore_pmdown_time = 1, /* dai link has playback support */
  2295. .codec_dai_name = "snd-soc-dummy-dai",
  2296. .codec_name = "snd-soc-dummy",
  2297. },
  2298. {
  2299. .name = "VoLTE",
  2300. .stream_name = "VoLTE",
  2301. .cpu_dai_name = "VoLTE",
  2302. .platform_name = "msm-pcm-voice",
  2303. .dynamic = 1,
  2304. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2305. SND_SOC_DPCM_TRIGGER_POST},
  2306. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2307. .ignore_suspend = 1,
  2308. /* this dainlink has playback support */
  2309. .ignore_pmdown_time = 1,
  2310. .codec_dai_name = "snd-soc-dummy-dai",
  2311. .codec_name = "snd-soc-dummy",
  2312. .be_id = MSM_FRONTEND_DAI_VOLTE,
  2313. },
  2314. {
  2315. .name = "MSM8974 LowLatency",
  2316. .stream_name = "MultiMedia5",
  2317. .cpu_dai_name = "MultiMedia5",
  2318. .platform_name = "msm-pcm-dsp.1",
  2319. .dynamic = 1,
  2320. .codec_dai_name = "snd-soc-dummy-dai",
  2321. .codec_name = "snd-soc-dummy",
  2322. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2323. SND_SOC_DPCM_TRIGGER_POST},
  2324. .ignore_suspend = 1,
  2325. /* this dainlink has playback support */
  2326. .ignore_pmdown_time = 1,
  2327. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  2328. },
  2329. /* LSM FE */
  2330. {
  2331. .name = "Listen 1 Audio Service",
  2332. .stream_name = "Listen 1 Audio Service",
  2333. .cpu_dai_name = "LSM1",
  2334. .platform_name = "msm-lsm-client",
  2335. .dynamic = 1,
  2336. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2337. SND_SOC_DPCM_TRIGGER_POST },
  2338. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2339. .ignore_suspend = 1,
  2340. .ignore_pmdown_time = 1,
  2341. .codec_dai_name = "snd-soc-dummy-dai",
  2342. .codec_name = "snd-soc-dummy",
  2343. .be_id = MSM_FRONTEND_DAI_LSM1,
  2344. },
  2345. /* Multiple Tunnel instances */
  2346. {
  2347. .name = "MSM8974 Compr2",
  2348. .stream_name = "COMPR2",
  2349. .cpu_dai_name = "MultiMedia6",
  2350. .platform_name = "msm-compress-dsp",
  2351. .dynamic = 1,
  2352. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2353. SND_SOC_DPCM_TRIGGER_POST},
  2354. .codec_dai_name = "snd-soc-dummy-dai",
  2355. .codec_name = "snd-soc-dummy",
  2356. .ignore_suspend = 1,
  2357. .ignore_pmdown_time = 1,
  2358. /* this dainlink has playback support */
  2359. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  2360. },
  2361. {
  2362. .name = "MSM8974 Compr3",
  2363. .stream_name = "COMPR3",
  2364. .cpu_dai_name = "MultiMedia7",
  2365. .platform_name = "msm-compress-dsp",
  2366. .dynamic = 1,
  2367. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2368. SND_SOC_DPCM_TRIGGER_POST},
  2369. .codec_dai_name = "snd-soc-dummy-dai",
  2370. .codec_name = "snd-soc-dummy",
  2371. .ignore_suspend = 1,
  2372. .ignore_pmdown_time = 1,
  2373. /* this dainlink has playback support */
  2374. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  2375. },
  2376. {
  2377. .name = "MSM8974 Compr4",
  2378. .stream_name = "COMPR4",
  2379. .cpu_dai_name = "MultiMedia8",
  2380. .platform_name = "msm-compress-dsp",
  2381. .dynamic = 1,
  2382. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2383. SND_SOC_DPCM_TRIGGER_POST},
  2384. .codec_dai_name = "snd-soc-dummy-dai",
  2385. .codec_name = "snd-soc-dummy",
  2386. .ignore_suspend = 1,
  2387. .ignore_pmdown_time = 1,
  2388. /* this dainlink has playback support */
  2389. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  2390. },
  2391. {
  2392. .name = "QCHAT",
  2393. .stream_name = "QCHAT",
  2394. .cpu_dai_name = "QCHAT",
  2395. .platform_name = "msm-pcm-voice",
  2396. .dynamic = 1,
  2397. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2398. SND_SOC_DPCM_TRIGGER_POST},
  2399. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2400. .ignore_suspend = 1,
  2401. /* this dainlink has playback support */
  2402. .ignore_pmdown_time = 1,
  2403. .codec_dai_name = "snd-soc-dummy-dai",
  2404. .codec_name = "snd-soc-dummy",
  2405. .be_id = MSM_FRONTEND_DAI_QCHAT,
  2406. },
  2407. /* HDMI Hostless */
  2408. {
  2409. .name = "HDMI_RX_HOSTLESS",
  2410. .stream_name = "HDMI_RX_HOSTLESS",
  2411. .cpu_dai_name = "HDMI_HOSTLESS",
  2412. .platform_name = "msm-pcm-hostless",
  2413. .dynamic = 1,
  2414. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2415. SND_SOC_DPCM_TRIGGER_POST},
  2416. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2417. .ignore_suspend = 1,
  2418. .ignore_pmdown_time = 1,
  2419. .codec_dai_name = "snd-soc-dummy-dai",
  2420. .codec_name = "snd-soc-dummy",
  2421. },
  2422. {
  2423. .name = "Voice2",
  2424. .stream_name = "Voice2",
  2425. .cpu_dai_name = "Voice2",
  2426. .platform_name = "msm-pcm-voice",
  2427. .dynamic = 1,
  2428. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2429. SND_SOC_DPCM_TRIGGER_POST},
  2430. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2431. .ignore_suspend = 1,
  2432. /* this dainlink has playback support */
  2433. .ignore_pmdown_time = 1,
  2434. .codec_dai_name = "snd-soc-dummy-dai",
  2435. .codec_name = "snd-soc-dummy",
  2436. .be_id = MSM_FRONTEND_DAI_VOICE2,
  2437. },
  2438. {
  2439. .name = "INT_HFP_BT Hostless",
  2440. .stream_name = "INT_HFP_BT Hostless",
  2441. .cpu_dai_name = "INT_HFP_BT_HOSTLESS",
  2442. .platform_name = "msm-pcm-hostless",
  2443. .dynamic = 1,
  2444. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2445. SND_SOC_DPCM_TRIGGER_POST},
  2446. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2447. .ignore_suspend = 1,
  2448. /* this dai link has playback support */
  2449. .ignore_pmdown_time = 1,
  2450. .codec_dai_name = "snd-soc-dummy-dai",
  2451. .codec_name = "snd-soc-dummy",
  2452. },
  2453. {
  2454. .name = "MSM8974 HFP TX",
  2455. .stream_name = "MultiMedia6",
  2456. .cpu_dai_name = "MultiMedia6",
  2457. .platform_name = "msm-pcm-loopback",
  2458. .dynamic = 1,
  2459. .codec_dai_name = "snd-soc-dummy-dai",
  2460. .codec_name = "snd-soc-dummy",
  2461. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2462. SND_SOC_DPCM_TRIGGER_POST},
  2463. .ignore_suspend = 1,
  2464. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2465. /* this dainlink has playback support */
  2466. .ignore_pmdown_time = 1,
  2467. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  2468. },
  2469. {
  2470. .name = "Listen 2 Audio Service",
  2471. .stream_name = "Listen 2 Audio Service",
  2472. .cpu_dai_name = "LSM2",
  2473. .platform_name = "msm-lsm-client",
  2474. .dynamic = 1,
  2475. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2476. SND_SOC_DPCM_TRIGGER_POST },
  2477. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2478. .ignore_suspend = 1,
  2479. .ignore_pmdown_time = 1,
  2480. .codec_dai_name = "snd-soc-dummy-dai",
  2481. .codec_name = "snd-soc-dummy",
  2482. .be_id = MSM_FRONTEND_DAI_LSM2,
  2483. },
  2484. {
  2485. .name = "Listen 3 Audio Service",
  2486. .stream_name = "Listen 3 Audio Service",
  2487. .cpu_dai_name = "LSM3",
  2488. .platform_name = "msm-lsm-client",
  2489. .dynamic = 1,
  2490. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2491. SND_SOC_DPCM_TRIGGER_POST },
  2492. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2493. .ignore_suspend = 1,
  2494. .ignore_pmdown_time = 1,
  2495. .codec_dai_name = "snd-soc-dummy-dai",
  2496. .codec_name = "snd-soc-dummy",
  2497. .be_id = MSM_FRONTEND_DAI_LSM3,
  2498. },
  2499. {
  2500. .name = "Listen 4 Audio Service",
  2501. .stream_name = "Listen 4 Audio Service",
  2502. .cpu_dai_name = "LSM4",
  2503. .platform_name = "msm-lsm-client",
  2504. .dynamic = 1,
  2505. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2506. SND_SOC_DPCM_TRIGGER_POST },
  2507. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2508. .ignore_suspend = 1,
  2509. .ignore_pmdown_time = 1,
  2510. .codec_dai_name = "snd-soc-dummy-dai",
  2511. .codec_name = "snd-soc-dummy",
  2512. .be_id = MSM_FRONTEND_DAI_LSM4,
  2513. },
  2514. {
  2515. .name = "Listen 5 Audio Service",
  2516. .stream_name = "Listen 5 Audio Service",
  2517. .cpu_dai_name = "LSM5",
  2518. .platform_name = "msm-lsm-client",
  2519. .dynamic = 1,
  2520. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2521. SND_SOC_DPCM_TRIGGER_POST },
  2522. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2523. .ignore_suspend = 1,
  2524. .ignore_pmdown_time = 1,
  2525. .codec_dai_name = "snd-soc-dummy-dai",
  2526. .codec_name = "snd-soc-dummy",
  2527. .be_id = MSM_FRONTEND_DAI_LSM5,
  2528. },
  2529. {
  2530. .name = "Listen 6 Audio Service",
  2531. .stream_name = "Listen 6 Audio Service",
  2532. .cpu_dai_name = "LSM6",
  2533. .platform_name = "msm-lsm-client",
  2534. .dynamic = 1,
  2535. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2536. SND_SOC_DPCM_TRIGGER_POST },
  2537. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2538. .ignore_suspend = 1,
  2539. .ignore_pmdown_time = 1,
  2540. .codec_dai_name = "snd-soc-dummy-dai",
  2541. .codec_name = "snd-soc-dummy",
  2542. .be_id = MSM_FRONTEND_DAI_LSM6,
  2543. },
  2544. {
  2545. .name = "Listen 7 Audio Service",
  2546. .stream_name = "Listen 7 Audio Service",
  2547. .cpu_dai_name = "LSM7",
  2548. .platform_name = "msm-lsm-client",
  2549. .dynamic = 1,
  2550. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2551. SND_SOC_DPCM_TRIGGER_POST },
  2552. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2553. .ignore_suspend = 1,
  2554. .ignore_pmdown_time = 1,
  2555. .codec_dai_name = "snd-soc-dummy-dai",
  2556. .codec_name = "snd-soc-dummy",
  2557. .be_id = MSM_FRONTEND_DAI_LSM7,
  2558. },
  2559. {
  2560. .name = "Listen 8 Audio Service",
  2561. .stream_name = "Listen 8 Audio Service",
  2562. .cpu_dai_name = "LSM8",
  2563. .platform_name = "msm-lsm-client",
  2564. .dynamic = 1,
  2565. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2566. SND_SOC_DPCM_TRIGGER_POST },
  2567. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2568. .ignore_suspend = 1,
  2569. .ignore_pmdown_time = 1,
  2570. .codec_dai_name = "snd-soc-dummy-dai",
  2571. .codec_name = "snd-soc-dummy",
  2572. .be_id = MSM_FRONTEND_DAI_LSM8,
  2573. },
  2574. {
  2575. .name = LPASS_BE_SLIMBUS_4_TX,
  2576. .stream_name = "Slimbus4 Capture",
  2577. .cpu_dai_name = "msm-dai-q6-dev.16393",
  2578. .platform_name = "msm-pcm-hostless",
  2579. .codec_name = "taiko_codec",
  2580. .codec_dai_name = "taiko_vifeedback",
  2581. .be_id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  2582. .be_hw_params_fixup = msm_slim_4_tx_be_hw_params_fixup,
  2583. .ops = &msm8974_be_ops,
  2584. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2585. .ignore_suspend = 1,
  2586. },
  2587. /* Ultrasound RX Back End DAI Link */
  2588. {
  2589. .name = "SLIMBUS_2 Hostless Playback",
  2590. .stream_name = "SLIMBUS_2 Hostless Playback",
  2591. .cpu_dai_name = "msm-dai-q6-dev.16388",
  2592. .platform_name = "msm-pcm-hostless",
  2593. .codec_name = "taiko_codec",
  2594. .codec_dai_name = "taiko_rx2",
  2595. .ignore_suspend = 1,
  2596. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2597. .ops = &msm8974_slimbus_2_be_ops,
  2598. },
  2599. /* Ultrasound TX Back End DAI Link */
  2600. {
  2601. .name = "SLIMBUS_2 Hostless Capture",
  2602. .stream_name = "SLIMBUS_2 Hostless Capture",
  2603. .cpu_dai_name = "msm-dai-q6-dev.16389",
  2604. .platform_name = "msm-pcm-hostless",
  2605. .codec_name = "taiko_codec",
  2606. .codec_dai_name = "taiko_tx2",
  2607. .ignore_suspend = 1,
  2608. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2609. .ops = &msm8974_slimbus_2_be_ops,
  2610. },
  2611. {
  2612. .name = "MSM8974 Media9",
  2613. .stream_name = "MultiMedia9",
  2614. .cpu_dai_name = "MultiMedia9",
  2615. .platform_name = "msm-pcm-dsp.0",
  2616. .dynamic = 1,
  2617. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2618. SND_SOC_DPCM_TRIGGER_POST},
  2619. .codec_dai_name = "snd-soc-dummy-dai",
  2620. .codec_name = "snd-soc-dummy",
  2621. .ignore_suspend = 1,
  2622. /* this dainlink has playback support */
  2623. .ignore_pmdown_time = 1,
  2624. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  2625. },
  2626. {
  2627. .name = "VoWLAN",
  2628. .stream_name = "VoWLAN",
  2629. .cpu_dai_name = "VoWLAN",
  2630. .platform_name = "msm-pcm-voice",
  2631. .dynamic = 1,
  2632. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2633. SND_SOC_DPCM_TRIGGER_POST},
  2634. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2635. .ignore_suspend = 1,
  2636. .ignore_pmdown_time = 1,
  2637. .codec_dai_name = "snd-soc-dummy-dai",
  2638. .codec_name = "snd-soc-dummy",
  2639. .be_id = MSM_FRONTEND_DAI_VOWLAN,
  2640. },
  2641. /* Backend BT/FM DAI Links */
  2642. {
  2643. .name = LPASS_BE_INT_BT_SCO_RX,
  2644. .stream_name = "Internal BT-SCO Playback",
  2645. .cpu_dai_name = "msm-dai-q6-dev.12288",
  2646. .platform_name = "msm-pcm-routing",
  2647. .codec_name = "msm-stub-codec.1",
  2648. .codec_dai_name = "msm-stub-rx",
  2649. .no_pcm = 1,
  2650. .be_id = MSM_BACKEND_DAI_INT_BT_SCO_RX,
  2651. .be_hw_params_fixup = msm_btsco_be_hw_params_fixup,
  2652. /* this dainlink has playback support */
  2653. .ignore_pmdown_time = 1,
  2654. .ignore_suspend = 1,
  2655. },
  2656. {
  2657. .name = LPASS_BE_INT_BT_SCO_TX,
  2658. .stream_name = "Internal BT-SCO Capture",
  2659. .cpu_dai_name = "msm-dai-q6-dev.12289",
  2660. .platform_name = "msm-pcm-routing",
  2661. .codec_name = "msm-stub-codec.1",
  2662. .codec_dai_name = "msm-stub-tx",
  2663. .no_pcm = 1,
  2664. .be_id = MSM_BACKEND_DAI_INT_BT_SCO_TX,
  2665. .be_hw_params_fixup = msm_btsco_be_hw_params_fixup,
  2666. .ignore_suspend = 1,
  2667. },
  2668. {
  2669. .name = LPASS_BE_INT_FM_RX,
  2670. .stream_name = "Internal FM Playback",
  2671. .cpu_dai_name = "msm-dai-q6-dev.12292",
  2672. .platform_name = "msm-pcm-routing",
  2673. .codec_name = "msm-stub-codec.1",
  2674. .codec_dai_name = "msm-stub-rx",
  2675. .no_pcm = 1,
  2676. .be_id = MSM_BACKEND_DAI_INT_FM_RX,
  2677. .be_hw_params_fixup = msm_be_fm_hw_params_fixup,
  2678. /* this dainlink has playback support */
  2679. .ignore_pmdown_time = 1,
  2680. .ignore_suspend = 1,
  2681. },
  2682. {
  2683. .name = LPASS_BE_INT_FM_TX,
  2684. .stream_name = "Internal FM Capture",
  2685. .cpu_dai_name = "msm-dai-q6-dev.12293",
  2686. .platform_name = "msm-pcm-routing",
  2687. .codec_name = "msm-stub-codec.1",
  2688. .codec_dai_name = "msm-stub-tx",
  2689. .no_pcm = 1,
  2690. .be_id = MSM_BACKEND_DAI_INT_FM_TX,
  2691. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2692. .ignore_suspend = 1,
  2693. },
  2694. /* Backend AFE DAI Links */
  2695. {
  2696. .name = LPASS_BE_AFE_PCM_RX,
  2697. .stream_name = "AFE Playback",
  2698. .cpu_dai_name = "msm-dai-q6-dev.224",
  2699. .platform_name = "msm-pcm-routing",
  2700. .codec_name = "msm-stub-codec.1",
  2701. .codec_dai_name = "msm-stub-rx",
  2702. .no_pcm = 1,
  2703. .be_id = MSM_BACKEND_DAI_AFE_PCM_RX,
  2704. .be_hw_params_fixup = msm_proxy_rx_be_hw_params_fixup,
  2705. /* this dainlink has playback support */
  2706. .ignore_pmdown_time = 1,
  2707. .ignore_suspend = 1,
  2708. },
  2709. {
  2710. .name = LPASS_BE_AFE_PCM_TX,
  2711. .stream_name = "AFE Capture",
  2712. .cpu_dai_name = "msm-dai-q6-dev.225",
  2713. .platform_name = "msm-pcm-routing",
  2714. .codec_name = "msm-stub-codec.1",
  2715. .codec_dai_name = "msm-stub-tx",
  2716. .no_pcm = 1,
  2717. .be_id = MSM_BACKEND_DAI_AFE_PCM_TX,
  2718. .be_hw_params_fixup = msm_proxy_tx_be_hw_params_fixup,
  2719. .ignore_suspend = 1,
  2720. },
  2721. #if defined( CONFIG_PCM_ROUTE_VOICE_STUB ) || defined(CONFIG_BT_CALL_FORWARDING)
  2722. {
  2723. .name = "Voice Stub",
  2724. .stream_name = "Voice Stub",
  2725. .cpu_dai_name = "VOICE_STUB",
  2726. .platform_name = "msm-pcm-hostless",
  2727. .dynamic = 1,
  2728. .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
  2729. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2730. .ignore_suspend = 1,
  2731. .ignore_pmdown_time = 1, /* this dainlink has playback support */
  2732. .codec_dai_name = "snd-soc-dummy-dai",
  2733. .codec_name = "snd-soc-dummy",
  2734. },
  2735. #endif /* CONFIG_PCM_ROUTE_VOICE_STUB || CONFIG_BT_CALL_FORWARDING */
  2736. #ifdef CONFIG_JACK_AUDIO
  2737. {
  2738. .name = "MSM8974 JACK LowLatency",
  2739. .stream_name = "MultiMedia10",
  2740. .cpu_dai_name = "MultiMedia10",
  2741. .platform_name = "msm-pcm-dsp.1",
  2742. .dynamic = 1,
  2743. .codec_dai_name = "snd-soc-dummy-dai",
  2744. .codec_name = "snd-soc-dummy",
  2745. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2746. SND_SOC_DPCM_TRIGGER_POST},
  2747. .ignore_suspend = 1,
  2748. /* this dainlink has playback support */
  2749. .ignore_pmdown_time = 1,
  2750. .be_id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  2751. },
  2752. #endif
  2753. /* Primary AUX PCM Backend DAI Links */
  2754. {
  2755. .name = LPASS_BE_AUXPCM_RX,
  2756. .stream_name = "AUX PCM Playback",
  2757. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  2758. .platform_name = "msm-pcm-routing",
  2759. .codec_name = "msm-stub-codec.1",
  2760. .codec_dai_name = "msm-stub-rx",
  2761. .no_pcm = 1,
  2762. .be_id = MSM_BACKEND_DAI_AUXPCM_RX,
  2763. .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
  2764. .ops = &msm_pri_auxpcm_be_ops,
  2765. .ignore_pmdown_time = 1,
  2766. .ignore_suspend = 1,
  2767. /* this dainlink has playback support */
  2768. },
  2769. {
  2770. .name = LPASS_BE_AUXPCM_TX,
  2771. .stream_name = "AUX PCM Capture",
  2772. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  2773. .platform_name = "msm-pcm-routing",
  2774. .codec_name = "msm-stub-codec.1",
  2775. .codec_dai_name = "msm-stub-tx",
  2776. .no_pcm = 1,
  2777. .be_id = MSM_BACKEND_DAI_AUXPCM_TX,
  2778. .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
  2779. .ops = &msm_pri_auxpcm_be_ops,
  2780. .ignore_suspend = 1,
  2781. },
  2782. #if defined( CONFIG_PCM_ROUTE_VOICE_STUB ) || defined(CONFIG_BT_CALL_FORWARDING)
  2783. /* Secondary AUX PCM Backend DAI Links */
  2784. {
  2785. .name = LPASS_BE_SEC_AUXPCM_RX,
  2786. .stream_name = "Sec AUX PCM Playback",
  2787. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  2788. .platform_name = "msm-pcm-routing",
  2789. .codec_name = "msm-stub-codec.1",
  2790. .codec_dai_name = "msm-stub-rx",
  2791. .no_pcm = 1,
  2792. .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  2793. .be_hw_params_fixup = msm_auxpcm2_be_params_fixup,
  2794. .ops = &msm_sec_auxpcm_be_ops,
  2795. .ignore_pmdown_time = 1,
  2796. .ignore_suspend = 1,
  2797. /* this dainlink has playback support */
  2798. },
  2799. {
  2800. .name = LPASS_BE_SEC_AUXPCM_TX,
  2801. .stream_name = "Sec AUX PCM Capture",
  2802. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  2803. .platform_name = "msm-pcm-routing",
  2804. .codec_name = "msm-stub-codec.1",
  2805. .codec_dai_name = "msm-stub-tx",
  2806. .no_pcm = 1,
  2807. .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  2808. .be_hw_params_fixup = msm_auxpcm2_be_params_fixup,
  2809. .ops = &msm_sec_auxpcm_be_ops,
  2810. .ignore_suspend = 1,
  2811. },
  2812. #else
  2813. /* Secondary AUX PCM Backend DAI Links */
  2814. {
  2815. .name = LPASS_BE_SEC_AUXPCM_RX,
  2816. .stream_name = "Sec AUX PCM Playback",
  2817. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  2818. .platform_name = "msm-pcm-routing",
  2819. .codec_name = "msm-stub-codec.1",
  2820. .codec_dai_name = "msm-stub-rx",
  2821. .no_pcm = 1,
  2822. .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  2823. .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
  2824. .ops = &msm_sec_auxpcm_be_ops,
  2825. .ignore_pmdown_time = 1,
  2826. .ignore_suspend = 1,
  2827. /* this dainlink has playback support */
  2828. },
  2829. {
  2830. .name = LPASS_BE_SEC_AUXPCM_TX,
  2831. .stream_name = "Sec AUX PCM Capture",
  2832. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  2833. .platform_name = "msm-pcm-routing",
  2834. .codec_name = "msm-stub-codec.1",
  2835. .codec_dai_name = "msm-stub-tx",
  2836. .no_pcm = 1,
  2837. .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  2838. .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
  2839. .ops = &msm_sec_auxpcm_be_ops,
  2840. .ignore_suspend = 1,
  2841. },
  2842. #endif
  2843. /* Backend DAI Links */
  2844. {
  2845. .name = LPASS_BE_SLIMBUS_0_RX,
  2846. .stream_name = "Slimbus Playback",
  2847. .cpu_dai_name = "msm-dai-q6-dev.16384",
  2848. .platform_name = "msm-pcm-routing",
  2849. .codec_name = "taiko_codec",
  2850. .codec_dai_name = "taiko_rx1",
  2851. .no_pcm = 1,
  2852. .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  2853. .init = &msm_audrx_init,
  2854. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2855. .ops = &msm8974_be_ops,
  2856. .ignore_pmdown_time = 1, /* dai link has playback support */
  2857. .ignore_suspend = 1,
  2858. },
  2859. {
  2860. .name = LPASS_BE_SLIMBUS_0_TX,
  2861. .stream_name = "Slimbus Capture",
  2862. .cpu_dai_name = "msm-dai-q6-dev.16385",
  2863. .platform_name = "msm-pcm-routing",
  2864. .codec_name = "taiko_codec",
  2865. .codec_dai_name = "taiko_tx1",
  2866. .no_pcm = 1,
  2867. .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  2868. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2869. .ops = &msm8974_be_ops,
  2870. .ignore_suspend = 1,
  2871. },
  2872. {
  2873. .name = LPASS_BE_SLIMBUS_1_RX,
  2874. .stream_name = "Slimbus1 Playback",
  2875. .cpu_dai_name = "msm-dai-q6-dev.16386",
  2876. .platform_name = "msm-pcm-routing",
  2877. .codec_name = "taiko_codec",
  2878. .codec_dai_name = "taiko_rx1",
  2879. .no_pcm = 1,
  2880. .be_id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  2881. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2882. .ops = &msm8974_be_ops,
  2883. /* dai link has playback support */
  2884. .ignore_pmdown_time = 1,
  2885. .ignore_suspend = 1,
  2886. },
  2887. {
  2888. .name = LPASS_BE_SLIMBUS_1_TX,
  2889. .stream_name = "Slimbus1 Capture",
  2890. .cpu_dai_name = "msm-dai-q6-dev.16387",
  2891. .platform_name = "msm-pcm-routing",
  2892. .codec_name = "taiko_codec",
  2893. .codec_dai_name = "taiko_tx1",
  2894. .no_pcm = 1,
  2895. .be_id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  2896. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2897. .ops = &msm8974_be_ops,
  2898. .ignore_suspend = 1,
  2899. },
  2900. {
  2901. .name = LPASS_BE_SLIMBUS_3_RX,
  2902. .stream_name = "Slimbus3 Playback",
  2903. .cpu_dai_name = "msm-dai-q6-dev.16390",
  2904. .platform_name = "msm-pcm-routing",
  2905. .codec_name = "taiko_codec",
  2906. .codec_dai_name = "taiko_rx1",
  2907. .no_pcm = 1,
  2908. .be_id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  2909. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2910. .ops = &msm8974_be_ops,
  2911. /* dai link has playback support */
  2912. .ignore_pmdown_time = 1,
  2913. .ignore_suspend = 1,
  2914. },
  2915. {
  2916. .name = LPASS_BE_SLIMBUS_3_TX,
  2917. .stream_name = "Slimbus3 Capture",
  2918. .cpu_dai_name = "msm-dai-q6-dev.16391",
  2919. .platform_name = "msm-pcm-routing",
  2920. .codec_name = "taiko_codec",
  2921. .codec_dai_name = "taiko_tx1",
  2922. .no_pcm = 1,
  2923. .be_id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  2924. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2925. .ops = &msm8974_be_ops,
  2926. .ignore_suspend = 1,
  2927. },
  2928. {
  2929. .name = LPASS_BE_SLIMBUS_4_RX,
  2930. .stream_name = "Slimbus4 Playback",
  2931. .cpu_dai_name = "msm-dai-q6-dev.16392",
  2932. .platform_name = "msm-pcm-routing",
  2933. .codec_name = "taiko_codec",
  2934. .codec_dai_name = "taiko_rx1",
  2935. .no_pcm = 1,
  2936. .be_id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  2937. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2938. .ops = &msm8974_be_ops,
  2939. /* dai link has playback support */
  2940. .ignore_pmdown_time = 1,
  2941. .ignore_suspend = 1,
  2942. },
  2943. /* Incall Record Uplink BACK END DAI Link */
  2944. {
  2945. .name = LPASS_BE_INCALL_RECORD_TX,
  2946. .stream_name = "Voice Uplink Capture",
  2947. .cpu_dai_name = "msm-dai-q6-dev.32772",
  2948. .platform_name = "msm-pcm-routing",
  2949. .codec_name = "msm-stub-codec.1",
  2950. .codec_dai_name = "msm-stub-tx",
  2951. .no_pcm = 1,
  2952. .be_id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  2953. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2954. .ignore_suspend = 1,
  2955. },
  2956. /* Incall Record Downlink BACK END DAI Link */
  2957. {
  2958. .name = LPASS_BE_INCALL_RECORD_RX,
  2959. .stream_name = "Voice Downlink Capture",
  2960. .cpu_dai_name = "msm-dai-q6-dev.32771",
  2961. .platform_name = "msm-pcm-routing",
  2962. .codec_name = "msm-stub-codec.1",
  2963. .codec_dai_name = "msm-stub-tx",
  2964. .no_pcm = 1,
  2965. .be_id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  2966. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2967. .ignore_suspend = 1,
  2968. },
  2969. /* MAD BE */
  2970. {
  2971. .name = LPASS_BE_SLIMBUS_5_TX,
  2972. .stream_name = "Slimbus5 Capture",
  2973. .cpu_dai_name = "msm-dai-q6-dev.16395",
  2974. .platform_name = "msm-pcm-routing",
  2975. .codec_name = "taiko_codec",
  2976. .codec_dai_name = "taiko_mad1",
  2977. .no_pcm = 1,
  2978. .be_id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
  2979. .be_hw_params_fixup = msm_slim_5_tx_be_hw_params_fixup,
  2980. .ops = &msm8974_be_ops,
  2981. },
  2982. /* Incall Music BACK END DAI Link */
  2983. {
  2984. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  2985. .stream_name = "Voice Farend Playback",
  2986. .cpu_dai_name = "msm-dai-q6-dev.32773",
  2987. .platform_name = "msm-pcm-routing",
  2988. .codec_name = "msm-stub-codec.1",
  2989. .codec_dai_name = "msm-stub-rx",
  2990. .no_pcm = 1,
  2991. .be_id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  2992. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2993. .ignore_suspend = 1,
  2994. },
  2995. /* Incall Music 2 BACK END DAI Link */
  2996. {
  2997. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  2998. .stream_name = "Voice2 Farend Playback",
  2999. .cpu_dai_name = "msm-dai-q6-dev.32770",
  3000. .platform_name = "msm-pcm-routing",
  3001. .codec_name = "msm-stub-codec.1",
  3002. .codec_dai_name = "msm-stub-rx",
  3003. .no_pcm = 1,
  3004. .be_id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  3005. .be_hw_params_fixup = msm_be_hw_params_fixup,
  3006. .ignore_suspend = 1,
  3007. },
  3008. #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98506)
  3009. #if defined (CONFIG_TERT_MI2S_ENABLE)
  3010. {
  3011. .name = LPASS_BE_TERT_MI2S_TX,
  3012. .stream_name = "Tertiary MI2S Capture",
  3013. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  3014. .platform_name = "msm-pcm-routing",
  3015. #if defined (CONFIG_SND_SOC_MAX98504)
  3016. .codec_name = "max98504.18-0031",//"msm-stub-codec.1",
  3017. .codec_dai_name = "max98504-aif1",//"msm-stub-tx",
  3018. #elif defined (CONFIG_SND_SOC_MAX98506)
  3019. .codec_name = "max98506.18-0031",
  3020. .codec_dai_name = "max98506-aif1",
  3021. #endif
  3022. .no_pcm = 1,
  3023. .be_id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  3024. .be_hw_params_fixup = msm8974_mi2s_be_hw_params_fixup,
  3025. .ops = &msm8974_mi2s_be_ops,
  3026. .ignore_suspend = 1,
  3027. },
  3028. #else
  3029. {
  3030. .name = LPASS_BE_SEC_MI2S_TX,
  3031. .stream_name = "Secondary MI2S Capture",
  3032. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  3033. .platform_name = "msm-pcm-routing",
  3034. #if defined (CONFIG_SND_SOC_MAX98504)
  3035. .codec_name = "max98504.18-0031",//"msm-stub-codec.1",
  3036. .codec_dai_name = "max98504-aif1",//"msm-stub-tx",
  3037. #elif defined (CONFIG_SND_SOC_MAX98506)
  3038. .codec_name = "max98506.18-0031",
  3039. .codec_dai_name = "max98506-aif1",
  3040. #endif
  3041. .no_pcm = 1,
  3042. .be_id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  3043. .be_hw_params_fixup = msm8974_mi2s_be_hw_params_fixup,
  3044. .ops = &msm8974_mi2s_be_ops,
  3045. },
  3046. #endif
  3047. #endif
  3048. };
  3049. static struct snd_soc_dai_link msm8974_hdmi_dai_link[] = {
  3050. /* HDMI BACK END DAI Link */
  3051. {
  3052. .name = LPASS_BE_HDMI,
  3053. .stream_name = "HDMI Playback",
  3054. .cpu_dai_name = "msm-dai-q6-hdmi.8",
  3055. .platform_name = "msm-pcm-routing",
  3056. .codec_name = "msm-hdmi-audio-codec-rx",
  3057. .codec_dai_name = "msm_hdmi_audio_codec_rx_dai",
  3058. .no_pcm = 1,
  3059. .be_id = MSM_BACKEND_DAI_HDMI_RX,
  3060. .be_hw_params_fixup = msm8974_hdmi_be_hw_params_fixup,
  3061. .ignore_pmdown_time = 1,
  3062. .ignore_suspend = 1,
  3063. },
  3064. };
  3065. static struct snd_soc_dai_link msm8974_dai_links[
  3066. ARRAY_SIZE(msm8974_common_dai_links) +
  3067. ARRAY_SIZE(msm8974_hdmi_dai_link)];
  3068. struct snd_soc_card snd_soc_card_msm8974 = {
  3069. .name = "msm8974-taiko-snd-card",
  3070. };
  3071. static int msm8974_dtparse_auxpcm(struct platform_device *pdev,
  3072. struct msm_auxpcm_ctrl **auxpcm_ctrl,
  3073. char *msm_auxpcm_gpio_name[][2])
  3074. {
  3075. int ret = 0;
  3076. int i = 0;
  3077. struct msm_auxpcm_gpio *pin_data = NULL;
  3078. struct msm_auxpcm_ctrl *ctrl;
  3079. unsigned int gpio_no[NUM_OF_AUXPCM_GPIOS];
  3080. enum of_gpio_flags flags = OF_GPIO_ACTIVE_LOW;
  3081. int auxpcm_cnt = 0;
  3082. pin_data = devm_kzalloc(&pdev->dev, (ARRAY_SIZE(gpio_no) *
  3083. sizeof(struct msm_auxpcm_gpio)),
  3084. GFP_KERNEL);
  3085. if (!pin_data) {
  3086. dev_err(&pdev->dev, "No memory for gpio\n");
  3087. ret = -ENOMEM;
  3088. goto err;
  3089. }
  3090. for (i = 0; i < ARRAY_SIZE(gpio_no); i++) {
  3091. gpio_no[i] = of_get_named_gpio_flags(pdev->dev.of_node,
  3092. msm_auxpcm_gpio_name[i][DT_PARSE_INDEX],
  3093. 0, &flags);
  3094. if (gpio_no[i] > 0) {
  3095. pin_data[i].gpio_name =
  3096. msm_auxpcm_gpio_name[auxpcm_cnt][GPIO_NAME_INDEX];
  3097. pin_data[i].gpio_no = gpio_no[i];
  3098. dev_dbg(&pdev->dev, "%s:GPIO gpio[%s] =\n"
  3099. "0x%x\n", __func__,
  3100. pin_data[i].gpio_name,
  3101. pin_data[i].gpio_no);
  3102. auxpcm_cnt++;
  3103. } else {
  3104. dev_err(&pdev->dev, "%s:Invalid AUXPCM GPIO[%s]= %x\n",
  3105. __func__,
  3106. msm_auxpcm_gpio_name[i][GPIO_NAME_INDEX],
  3107. gpio_no[i]);
  3108. ret = -ENODEV;
  3109. goto err;
  3110. }
  3111. }
  3112. ctrl = devm_kzalloc(&pdev->dev,
  3113. sizeof(struct msm_auxpcm_ctrl), GFP_KERNEL);
  3114. if (!ctrl) {
  3115. dev_err(&pdev->dev, "No memory for gpio\n");
  3116. ret = -ENOMEM;
  3117. goto err;
  3118. }
  3119. ctrl->pin_data = pin_data;
  3120. ctrl->cnt = auxpcm_cnt;
  3121. *auxpcm_ctrl = ctrl;
  3122. return ret;
  3123. err:
  3124. if (pin_data)
  3125. devm_kfree(&pdev->dev, pin_data);
  3126. return ret;
  3127. }
  3128. static int msm8974_prepare_codec_mclk(struct snd_soc_card *card)
  3129. {
  3130. struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  3131. int ret;
  3132. if (pdata->mclk_gpio) {
  3133. ret = gpio_request(pdata->mclk_gpio, "TAIKO_CODEC_PMIC_MCLK");
  3134. if (ret) {
  3135. dev_err(card->dev,
  3136. "%s: Failed to request taiko mclk gpio %d\n",
  3137. __func__, pdata->mclk_gpio);
  3138. return ret;
  3139. }
  3140. }
  3141. return 0;
  3142. }
  3143. static int msm8974_prepare_us_euro(struct snd_soc_card *card)
  3144. {
  3145. struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  3146. int ret;
  3147. if (pdata->us_euro_gpio >= 0) {
  3148. dev_dbg(card->dev, "%s : us_euro gpio request %d", __func__,
  3149. pdata->us_euro_gpio);
  3150. ret = gpio_request(pdata->us_euro_gpio, "TAIKO_CODEC_US_EURO");
  3151. if (ret) {
  3152. dev_err(card->dev,
  3153. "%s: Failed to request taiko US/EURO gpio %d error %d\n",
  3154. __func__, pdata->us_euro_gpio, ret);
  3155. return ret;
  3156. }
  3157. }
  3158. return 0;
  3159. }
  3160. static int msm8974_prepare_mainmic(void)
  3161. {
  3162. int ret;
  3163. if (mainmic_bias_gpio) {
  3164. pr_debug("%s : mainmic bias gpio request %d", __func__,
  3165. mainmic_bias_gpio);
  3166. ret = gpio_request(mainmic_bias_gpio, "TAIKO_MAINMIC_BIAS");
  3167. if (ret) {
  3168. pr_debug("%s: Failed to request taiko mainmic bias gpio %d error %d\n",
  3169. __func__, mainmic_bias_gpio, ret);
  3170. return ret;
  3171. }
  3172. gpio_direction_output(mainmic_bias_gpio, 0);
  3173. }
  3174. return 0;
  3175. }
  3176. #if defined(CONFIG_LDO_SUBMIC_BIAS)
  3177. static int msm8974_prepare_submic(void)
  3178. {
  3179. int ret;
  3180. if (submic_bias_gpio) {
  3181. pr_debug("%s : submic bias gpio request %d", __func__,
  3182. submic_bias_gpio);
  3183. ret = gpio_request(submic_bias_gpio, "TAIKO_SUBMIC_BIAS");
  3184. if (ret) {
  3185. pr_debug("%s: Failed to request taiko submic bias gpio %d error %d\n",
  3186. __func__, submic_bias_gpio, ret);
  3187. return ret;
  3188. }
  3189. gpio_direction_output(submic_bias_gpio, 0);
  3190. }
  3191. return 0;
  3192. }
  3193. #endif
  3194. #if defined(CONFIG_LDO_EARMIC_BIAS)
  3195. static int msm8974_prepare_earmic(void)
  3196. {
  3197. int ret;
  3198. if (earmic_bias_gpio) {
  3199. pr_debug("%s : earmic bias gpio request %d", __func__,
  3200. earmic_bias_gpio);
  3201. ret = gpio_request(earmic_bias_gpio, "TAIKO_EARMIC_BIAS");
  3202. if (ret) {
  3203. pr_debug("%s: Failed to request taiko earmic bias gpio %d error %d\n",
  3204. __func__, earmic_bias_gpio, ret);
  3205. return ret;
  3206. }
  3207. gpio_direction_output(earmic_bias_gpio, 0);
  3208. }
  3209. return 0;
  3210. }
  3211. #endif
  3212. static int msm8974_prepare_spkamp(void)
  3213. {
  3214. int ret;
  3215. if (spkamp_en_gpio) {
  3216. pr_debug("%s : spkamp en gpio request %d", __func__,
  3217. spkamp_en_gpio);
  3218. ret = gpio_request(spkamp_en_gpio, "SPKAMP_EN");
  3219. if (ret) {
  3220. pr_debug("%s: Failed to request spkamp en gpio %d error %d\n",
  3221. __func__, spkamp_en_gpio, ret);
  3222. return ret;
  3223. }
  3224. gpio_direction_output(spkamp_en_gpio, 0);
  3225. }
  3226. return 0;
  3227. }
  3228. static int msm8974_prepare_micbias_to_codec(void)
  3229. {
  3230. int ret;
  3231. if (micbias_en_msm_gpio) {
  3232. pr_debug("%s : micbias en msm gpio request %d", __func__,
  3233. micbias_en_msm_gpio);
  3234. ret = gpio_request(micbias_en_msm_gpio, "MICBIAS_TO_CODEC");
  3235. if (ret) {
  3236. pr_debug("%s: Failed to request taiko micbias en msm gpio %d error %d\n",
  3237. __func__, micbias_en_msm_gpio, ret);
  3238. return ret;
  3239. }
  3240. gpio_direction_output(micbias_en_msm_gpio, 0);
  3241. }
  3242. return 0;
  3243. }
  3244. static __devinit int msm8974_asoc_machine_probe(struct platform_device *pdev)
  3245. {
  3246. struct snd_soc_card *card = &snd_soc_card_msm8974;
  3247. struct msm8974_asoc_mach_data *pdata;
  3248. int ret;
  3249. const char *auxpcm_pri_gpio_set = NULL;
  3250. const char *prop_name_ult_lo_gpio = "qcom,ext-ult-lo-amp-gpio";
  3251. const char *mbhc_audio_jack_type = NULL;
  3252. size_t n = strlen("4-pole-jack");
  3253. struct resource *pri_muxsel;
  3254. struct resource *sec_muxsel;
  3255. #if defined(CONFIG_SEC_JACTIVE_PROJECT)
  3256. extern unsigned int system_rev;
  3257. #endif
  3258. if (!pdev->dev.of_node) {
  3259. dev_err(&pdev->dev, "No platform supplied from device tree\n");
  3260. return -EINVAL;
  3261. }
  3262. pdata = devm_kzalloc(&pdev->dev,
  3263. sizeof(struct msm8974_asoc_mach_data), GFP_KERNEL);
  3264. if (!pdata) {
  3265. dev_err(&pdev->dev, "Can't allocate msm8974_asoc_mach_data\n");
  3266. return -ENOMEM;
  3267. }
  3268. card->dev = &pdev->dev;
  3269. platform_set_drvdata(pdev, card);
  3270. snd_soc_card_set_drvdata(card, pdata);
  3271. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  3272. if (ret)
  3273. goto err;
  3274. ret = snd_soc_of_parse_audio_routing(card,
  3275. "qcom,audio-routing");
  3276. if (ret)
  3277. goto err;
  3278. ret = of_property_read_u32(pdev->dev.of_node,
  3279. "qcom,taiko-mclk-clk-freq", &pdata->mclk_freq);
  3280. if (ret) {
  3281. dev_err(&pdev->dev, "Looking up %s property in node %s failed",
  3282. "qcom,taiko-mclk-clk-freq",
  3283. pdev->dev.of_node->full_name);
  3284. goto err;
  3285. }
  3286. if (pdata->mclk_freq != 9600000) {
  3287. dev_err(&pdev->dev, "unsupported taiko mclk freq %u\n",
  3288. pdata->mclk_freq);
  3289. ret = -EINVAL;
  3290. goto err;
  3291. }
  3292. pdata->mclk_gpio = of_get_named_gpio(pdev->dev.of_node,
  3293. "qcom,cdc-mclk-gpios", 0);
  3294. if (pdata->mclk_gpio < 0) {
  3295. dev_err(&pdev->dev,
  3296. "Looking up %s property in node %s failed %d\n",
  3297. "qcom, cdc-mclk-gpios", pdev->dev.of_node->full_name,
  3298. pdata->mclk_gpio);
  3299. ret = -ENODEV;
  3300. goto err;
  3301. }
  3302. ret = msm8974_prepare_codec_mclk(card);
  3303. if (ret)
  3304. goto err;
  3305. ret = of_property_read_string(pdev->dev.of_node,
  3306. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  3307. if (ret) {
  3308. dev_dbg(&pdev->dev, "Looking up %s property in node %s failed",
  3309. "qcom,mbhc-audio-jack-type",
  3310. pdev->dev.of_node->full_name);
  3311. mbhc_cfg.hw_jack_type = FOUR_POLE_JACK;
  3312. mbhc_cfg.enable_anc_mic_detect = false;
  3313. dev_dbg(&pdev->dev, "Jack type properties set to default");
  3314. } else {
  3315. if (!strncmp(mbhc_audio_jack_type, "4-pole-jack", n)) {
  3316. mbhc_cfg.hw_jack_type = FOUR_POLE_JACK;
  3317. mbhc_cfg.enable_anc_mic_detect = false;
  3318. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  3319. } else if (!strncmp(mbhc_audio_jack_type, "5-pole-jack", n)) {
  3320. mbhc_cfg.hw_jack_type = FIVE_POLE_JACK;
  3321. mbhc_cfg.enable_anc_mic_detect = true;
  3322. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  3323. } else if (!strncmp(mbhc_audio_jack_type, "6-pole-jack", n)) {
  3324. mbhc_cfg.hw_jack_type = SIX_POLE_JACK;
  3325. mbhc_cfg.enable_anc_mic_detect = true;
  3326. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  3327. } else {
  3328. mbhc_cfg.hw_jack_type = FOUR_POLE_JACK;
  3329. mbhc_cfg.enable_anc_mic_detect = false;
  3330. dev_dbg(&pdev->dev, "Unknown value, hence setting to default");
  3331. }
  3332. }
  3333. if (of_property_read_bool(pdev->dev.of_node, "qcom,hdmi-audio-rx")) {
  3334. dev_info(&pdev->dev, "%s(): hdmi audio support present\n",
  3335. __func__);
  3336. memcpy(msm8974_dai_links, msm8974_common_dai_links,
  3337. sizeof(msm8974_common_dai_links));
  3338. memcpy(msm8974_dai_links + ARRAY_SIZE(msm8974_common_dai_links),
  3339. msm8974_hdmi_dai_link, sizeof(msm8974_hdmi_dai_link));
  3340. card->dai_link = msm8974_dai_links;
  3341. card->num_links = ARRAY_SIZE(msm8974_dai_links);
  3342. } else {
  3343. dev_info(&pdev->dev, "%s(): No hdmi audio support\n", __func__);
  3344. card->dai_link = msm8974_common_dai_links;
  3345. card->num_links = ARRAY_SIZE(msm8974_common_dai_links);
  3346. }
  3347. mutex_init(&cdc_mclk_mutex);
  3348. atomic_set(&prim_auxpcm_rsc_ref, 0);
  3349. atomic_set(&sec_auxpcm_rsc_ref, 0);
  3350. spdev = pdev;
  3351. ext_spk_amp_regulator = NULL;
  3352. msm8974_liquid_dock_dev = NULL;
  3353. ret = snd_soc_register_card(card);
  3354. if (ret == -EPROBE_DEFER)
  3355. goto err;
  3356. else if (ret) {
  3357. dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
  3358. ret);
  3359. goto err;
  3360. }
  3361. /* Parse Primary AUXPCM info from DT */
  3362. ret = msm8974_dtparse_auxpcm(pdev, &pdata->pri_auxpcm_ctrl,
  3363. msm_prim_auxpcm_gpio_name);
  3364. if (ret) {
  3365. dev_err(&pdev->dev,
  3366. "%s: Primary Auxpcm pin data parse failed\n", __func__);
  3367. goto err;
  3368. }
  3369. /* Parse Secondary AUXPCM info from DT */
  3370. ret = msm8974_dtparse_auxpcm(pdev, &pdata->sec_auxpcm_ctrl,
  3371. msm_sec_auxpcm_gpio_name);
  3372. if (ret) {
  3373. dev_err(&pdev->dev,
  3374. "%s: Secondary Auxpcm pin data parse failed\n", __func__);
  3375. goto err;
  3376. }
  3377. ext_ult_lo_amp_gpio = of_get_named_gpio(pdev->dev.of_node,
  3378. prop_name_ult_lo_gpio, 0);
  3379. if (!gpio_is_valid(ext_ult_lo_amp_gpio)) {
  3380. dev_dbg(&pdev->dev,
  3381. "Couldn't find %s property in node %s, %d\n",
  3382. prop_name_ult_lo_gpio, pdev->dev.of_node->full_name,
  3383. ext_ult_lo_amp_gpio);
  3384. } else {
  3385. ret = gpio_request(ext_ult_lo_amp_gpio, "US_AMP_GPIO");
  3386. if (ret) {
  3387. dev_err(card->dev,
  3388. "%s: Failed to request US amp gpio %d\n",
  3389. __func__, ext_ult_lo_amp_gpio);
  3390. goto err;
  3391. }
  3392. }
  3393. pdata->us_euro_gpio = of_get_named_gpio(pdev->dev.of_node,
  3394. "qcom,us-euro-gpios", 0);
  3395. if (pdata->us_euro_gpio < 0) {
  3396. dev_info(&pdev->dev, "property %s not detected in node %s",
  3397. "qcom,us-euro-gpios",
  3398. pdev->dev.of_node->full_name);
  3399. } else {
  3400. dev_dbg(&pdev->dev, "%s detected %d",
  3401. "qcom,us-euro-gpios", pdata->us_euro_gpio);
  3402. mbhc_cfg.swap_gnd_mic = msm8974_swap_gnd_mic;
  3403. }
  3404. ret = msm8974_prepare_us_euro(card);
  3405. if (ret)
  3406. dev_err(&pdev->dev, "msm8974_prepare_us_euro failed (%d)\n",
  3407. ret);
  3408. #ifdef CONFIG_SEC_JACTIVE_PROJECT
  3409. if(system_rev < 3) {
  3410. ear_jack_fsa8038_en = of_get_named_gpio(pdev->dev.of_node, "qcom,fsa8038_enable", 0);
  3411. if (ear_jack_fsa8038_en < 0) {
  3412. dev_err(&pdev->dev, "Looking up %s property in node %s failed",
  3413. "qcom,fsa8038_enable",
  3414. pdev->dev.of_node->full_name);
  3415. } else {
  3416. ret = gpio_request(ear_jack_fsa8038_en, "fsa8038 enable");
  3417. if (ret) {
  3418. dev_err(&pdev->dev, "Looking up %s property in node %s failed",
  3419. "qcom,fsa8038_enable",
  3420. pdev->dev.of_node->full_name);
  3421. gpio_free(ear_jack_fsa8038_en);
  3422. } else {
  3423. gpio_direction_output(ear_jack_fsa8038_en, 1);
  3424. }
  3425. }
  3426. }
  3427. #endif
  3428. /* the ldo of main mic bias */
  3429. mainmic_bias_gpio = of_get_named_gpio(pdev->dev.of_node,
  3430. "qcom,mainmic-bias-gpio", 0);
  3431. if (mainmic_bias_gpio < 0) {
  3432. dev_err(&pdev->dev, "Looking up %s property in node %s failed",
  3433. "qcom,mainmic-bias-gpio",
  3434. pdev->dev.of_node->full_name);
  3435. } else {
  3436. pr_info("%s : mic bias = %d\n", __func__, mainmic_bias_gpio);
  3437. ret = msm8974_prepare_mainmic();
  3438. if (ret) {
  3439. dev_err(&pdev->dev, "msm8974_prepare_mainmic failed (%d)\n",
  3440. ret);
  3441. gpio_free(mainmic_bias_gpio);
  3442. mainmic_bias_gpio = 0;
  3443. }
  3444. }
  3445. #if defined(CONFIG_LDO_SUBMIC_BIAS)
  3446. /* the ldo of sub mic bias */
  3447. submic_bias_gpio = of_get_named_gpio(pdev->dev.of_node,
  3448. "qcom,submic-bias-gpio", 0);
  3449. pr_info("%s :sub mic bias = %d\n", __func__, submic_bias_gpio);
  3450. ret = msm8974_prepare_submic();
  3451. if (ret) {
  3452. dev_err(&pdev->dev, "msm8974_prepare_submic failed (%d)\n",
  3453. ret);
  3454. gpio_free(submic_bias_gpio);
  3455. submic_bias_gpio = 0;
  3456. }
  3457. #endif
  3458. #if defined(CONFIG_LDO_EARMIC_BIAS)
  3459. /* the ldo of ear mic bias */
  3460. earmic_bias_gpio = of_get_named_gpio(pdev->dev.of_node,
  3461. "qcom,earmic-bias-gpio", 0);
  3462. pr_info("%s :ear mic bias = %d\n", __func__, earmic_bias_gpio);
  3463. ret = msm8974_prepare_earmic();
  3464. if (ret) {
  3465. dev_err(&pdev->dev, "msm8974_prepare_earmic failed (%d)\n",
  3466. ret);
  3467. gpio_free(earmic_bias_gpio);
  3468. earmic_bias_gpio = 0;
  3469. }
  3470. #endif
  3471. #if defined(CONFIG_MACH_KLTE_KOR) || defined(CONFIG_MACH_KLTE_JPN) || defined(CONFIG_MACH_KACTIVELTE_DCM) \
  3472. || defined(CONFIG_MACH_CHAGALL_KDI) || defined(CONFIG_MACH_KLIMT_LTE_DCM) || defined(CONFIG_MACH_KACTIVELTE_KOR)
  3473. /* enable FSA8039 for jack detection */
  3474. pr_info("%s: Check to enable FSA8039\n", __func__);
  3475. fsa_en_gpio = of_get_named_gpio(pdev->dev.of_node,
  3476. "qcom,earjack-fsa_en-gpio", 0);
  3477. if (fsa_en_gpio < 0)
  3478. of_property_read_u32(pdev->dev.of_node,
  3479. "qcom,earjack-fsa_en-expander-gpio", &fsa_en_gpio);
  3480. if (fsa_en_gpio < 0)
  3481. pr_info("%s: No support FSA8039 chip\n", __func__);
  3482. else
  3483. pr_info("%s: earjack-fsa_en-gpio =%d\n",
  3484. __func__, fsa_en_gpio);
  3485. if (fsa_en_gpio > 0) {
  3486. ret = gpio_request(fsa_en_gpio, "fsa_en");
  3487. if (ret) {
  3488. pr_err("%s : gpio_request failed for %d, ret %d\n",
  3489. __func__, fsa_en_gpio, ret);
  3490. goto err;
  3491. }
  3492. gpio_direction_output(fsa_en_gpio, 1);
  3493. }
  3494. #endif
  3495. /* the switch to connect the main mic to the codec or es705 */
  3496. #if defined(CONFIG_MACH_KLTE_JPN) || defined(CONFIG_MACH_KACTIVELTE_DCM) || defined(CONFIG_MACH_CHAGALL_KDI) || defined(CONFIG_MACH_KLIMT_LTE_DCM)
  3497. #if defined(CONFIG_MACH_KLTE_MAX77828_JPN)
  3498. micbias_en_msm_gpio = of_get_named_gpio(pdev->dev.of_node,
  3499. "qcom,micbias-en-msm-gpio", 0);
  3500. #else
  3501. micbias_en_msm_gpio = of_get_named_gpio(pdev->dev.of_node,
  3502. "qcom,micbias-en-msm-jpn-gpio", 0);
  3503. #endif
  3504. #else
  3505. micbias_en_msm_gpio = of_get_named_gpio(pdev->dev.of_node,
  3506. "qcom,micbias-en-msm-gpio", 0);
  3507. #endif
  3508. if (micbias_en_msm_gpio < 0) {
  3509. dev_err(&pdev->dev, "Looking up %s property in node %s failed",
  3510. "qcom,micbias-en-msm-gpio",
  3511. pdev->dev.of_node->full_name);
  3512. } else {
  3513. pr_info("%s : micbias en msm = %d\n", __func__, micbias_en_msm_gpio);
  3514. ret = msm8974_prepare_micbias_to_codec();
  3515. if (ret) {
  3516. dev_err(&pdev->dev, "msm8974_prepare_micbias_to_codec failed (%d)\n",
  3517. ret);
  3518. gpio_free(micbias_en_msm_gpio);
  3519. micbias_en_msm_gpio = 0;
  3520. }
  3521. }
  3522. spkamp_en_gpio = of_get_named_gpio(pdev->dev.of_node,
  3523. "qcom,spkamp-en-gpio", 0);
  3524. if (spkamp_en_gpio < 0) {
  3525. dev_err(&pdev->dev, "Looking up %s property in node %s failed",
  3526. "qcom,spkamp-en-gpio",
  3527. pdev->dev.of_node->full_name);
  3528. } else {
  3529. pr_info("%s : spkamp_en_ gpio = %d\n", __func__, spkamp_en_gpio);
  3530. ret = msm8974_prepare_spkamp();
  3531. if (ret) {
  3532. dev_err(&pdev->dev, "msm8974_prepare_spkamp_en_ gpio failed (%d)\n",
  3533. ret);
  3534. gpio_free(spkamp_en_gpio);
  3535. spkamp_en_gpio = 0;
  3536. }
  3537. }
  3538. ret = of_property_read_string(pdev->dev.of_node,
  3539. "qcom,prim-auxpcm-gpio-set", &auxpcm_pri_gpio_set);
  3540. if (ret) {
  3541. dev_err(&pdev->dev, "Looking up %s property in node %s failed",
  3542. "qcom,prim-auxpcm-gpio-set",
  3543. pdev->dev.of_node->full_name);
  3544. goto err1;
  3545. }
  3546. if (!strcmp(auxpcm_pri_gpio_set, "prim-gpio-prim")) {
  3547. pri_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
  3548. "lpaif_pri_mode_muxsel");
  3549. } else if (!strcmp(auxpcm_pri_gpio_set, "prim-gpio-tert")) {
  3550. pri_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
  3551. "lpaif_tert_mode_muxsel");
  3552. } else {
  3553. dev_err(&pdev->dev, "Invalid value %s for AUXPCM GPIO set\n",
  3554. auxpcm_pri_gpio_set);
  3555. ret = -EINVAL;
  3556. goto err1;
  3557. }
  3558. if (!pri_muxsel) {
  3559. dev_err(&pdev->dev, "MUX addr invalid for primary AUXPCM\n");
  3560. ret = -ENODEV;
  3561. goto err1;
  3562. } else {
  3563. pdata->pri_auxpcm_ctrl->mux = ioremap(pri_muxsel->start,
  3564. resource_size(pri_muxsel));
  3565. if (pdata->pri_auxpcm_ctrl->mux == NULL) {
  3566. pr_err("%s Pri muxsel virt addr is null\n", __func__);
  3567. ret = -EINVAL;
  3568. goto err1;
  3569. }
  3570. }
  3571. #if defined( CONFIG_PCM_ROUTE_VOICE_STUB ) || defined(CONFIG_BT_CALL_FORWARDING)
  3572. sec_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
  3573. "lpaif_quat_mode_muxsel");
  3574. #else
  3575. sec_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
  3576. "lpaif_sec_mode_muxsel");
  3577. #endif /* CONFIG_PCM_ROUTE_VOICE_STUB || CONFIG_BT_CALL_FORWARDING*/
  3578. if (!sec_muxsel) {
  3579. dev_err(&pdev->dev, "MUX addr invalid for secondary AUXPCM\n");
  3580. ret = -ENODEV;
  3581. goto err2;
  3582. }
  3583. pdata->sec_auxpcm_ctrl->mux = ioremap(sec_muxsel->start,
  3584. resource_size(sec_muxsel));
  3585. if (pdata->sec_auxpcm_ctrl->mux == NULL) {
  3586. pr_err("%s Sec muxsel virt addr is null\n", __func__);
  3587. ret = -EINVAL;
  3588. goto err2;
  3589. }
  3590. #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98506)
  3591. atomic_set(&pri_mi2s_clk.mi2s_rsc_ref, 0);
  3592. #endif
  3593. return 0;
  3594. err2:
  3595. iounmap(pdata->pri_auxpcm_ctrl->mux);
  3596. err1:
  3597. if (ext_ult_lo_amp_gpio >= 0)
  3598. gpio_free(ext_ult_lo_amp_gpio);
  3599. ext_ult_lo_amp_gpio = -1;
  3600. err:
  3601. if (pdata->mclk_gpio > 0) {
  3602. dev_dbg(&pdev->dev, "%s free gpio %d\n",
  3603. __func__, pdata->mclk_gpio);
  3604. gpio_free(pdata->mclk_gpio);
  3605. pdata->mclk_gpio = 0;
  3606. }
  3607. if (pdata->us_euro_gpio > 0) {
  3608. dev_dbg(&pdev->dev, "%s free us_euro gpio %d\n",
  3609. __func__, pdata->us_euro_gpio);
  3610. gpio_free(pdata->us_euro_gpio);
  3611. pdata->us_euro_gpio = 0;
  3612. }
  3613. mutex_destroy(&cdc_mclk_mutex);
  3614. devm_kfree(&pdev->dev, pdata);
  3615. return ret;
  3616. }
  3617. static int __devexit msm8974_asoc_machine_remove(struct platform_device *pdev)
  3618. {
  3619. struct snd_soc_card *card = platform_get_drvdata(pdev);
  3620. struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  3621. if (ext_spk_amp_regulator)
  3622. regulator_put(ext_spk_amp_regulator);
  3623. if (gpio_is_valid(ext_ult_spk_amp_gpio))
  3624. gpio_free(ext_ult_spk_amp_gpio);
  3625. if (gpio_is_valid(ext_ult_lo_amp_gpio))
  3626. gpio_free(ext_ult_lo_amp_gpio);
  3627. gpio_free(pdata->mclk_gpio);
  3628. gpio_free(pdata->us_euro_gpio);
  3629. if (gpio_is_valid(ext_spk_amp_gpio))
  3630. gpio_free(ext_spk_amp_gpio);
  3631. if (msm8974_liquid_dock_dev != NULL) {
  3632. if (msm8974_liquid_dock_dev->dock_plug_gpio)
  3633. gpio_free(msm8974_liquid_dock_dev->dock_plug_gpio);
  3634. if (msm8974_liquid_dock_dev->dock_plug_irq)
  3635. free_irq(msm8974_liquid_dock_dev->dock_plug_irq,
  3636. msm8974_liquid_dock_dev);
  3637. kfree(msm8974_liquid_dock_dev);
  3638. msm8974_liquid_dock_dev = NULL;
  3639. }
  3640. iounmap(pdata->pri_auxpcm_ctrl->mux);
  3641. iounmap(pdata->sec_auxpcm_ctrl->mux);
  3642. snd_soc_unregister_card(card);
  3643. return 0;
  3644. }
  3645. static const struct of_device_id msm8974_asoc_machine_of_match[] = {
  3646. { .compatible = "qcom,msm8974-audio-taiko", },
  3647. {},
  3648. };
  3649. static struct platform_driver msm8974_asoc_machine_driver = {
  3650. .driver = {
  3651. .name = DRV_NAME,
  3652. .owner = THIS_MODULE,
  3653. .pm = &snd_soc_pm_ops,
  3654. .of_match_table = msm8974_asoc_machine_of_match,
  3655. },
  3656. .probe = msm8974_asoc_machine_probe,
  3657. .remove = __devexit_p(msm8974_asoc_machine_remove),
  3658. };
  3659. module_platform_driver(msm8974_asoc_machine_driver);
  3660. MODULE_DESCRIPTION("ALSA SoC msm");
  3661. MODULE_LICENSE("GPL v2");
  3662. MODULE_ALIAS("platform:" DRV_NAME);
  3663. MODULE_DEVICE_TABLE(of, msm8974_asoc_machine_of_match);