msm8996.c 110 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007
  1. /*
  2. * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/clk.h>
  14. #include <linux/delay.h>
  15. #include <linux/gpio.h>
  16. #include <linux/of_gpio.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/slab.h>
  19. #include <linux/regulator/consumer.h>
  20. #include <linux/io.h>
  21. #include <linux/module.h>
  22. #include <linux/switch.h>
  23. #include <linux/input.h>
  24. #include <sound/core.h>
  25. #include <sound/soc.h>
  26. #include <sound/soc-dapm.h>
  27. #include <sound/pcm.h>
  28. #include <sound/jack.h>
  29. #include <sound/q6afe-v2.h>
  30. #include <sound/q6core.h>
  31. #include <sound/pcm_params.h>
  32. #include <sound/info.h>
  33. #include <device_event.h>
  34. #include "qdsp6v2/msm-pcm-routing-v2.h"
  35. #include "../codecs/wcd9xxx-common.h"
  36. #include "../codecs/wcd9330.h"
  37. #include "../codecs/wcd9335.h"
  38. #include "../codecs/wsa881x.h"
  39. #define DRV_NAME "msm8996-asoc-snd"
  40. #define SAMPLING_RATE_8KHZ 8000
  41. #define SAMPLING_RATE_16KHZ 16000
  42. #define SAMPLING_RATE_32KHZ 32000
  43. #define SAMPLING_RATE_48KHZ 48000
  44. #define SAMPLING_RATE_96KHZ 96000
  45. #define SAMPLING_RATE_192KHZ 192000
  46. #define SAMPLING_RATE_44P1KHZ 44100
  47. #define MSM8996_SPK_ON 1
  48. #define MSM8996_HIFI_ON 1
  49. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  50. #define WCD9XXX_MBHC_DEF_RLOADS 5
  51. #define CODEC_EXT_CLK_RATE 9600000
  52. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  53. #define DEV_NAME_STR_LEN 32
  54. #define WSA8810_NAME_1 "wsa881x.20170211"
  55. #define WSA8810_NAME_2 "wsa881x.20170212"
  56. static int slim0_rx_sample_rate = SAMPLING_RATE_48KHZ;
  57. static int slim0_tx_sample_rate = SAMPLING_RATE_48KHZ;
  58. static int slim1_tx_sample_rate = SAMPLING_RATE_48KHZ;
  59. static int slim0_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  60. static int slim0_tx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  61. static int slim1_tx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  62. static int hdmi_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  63. static int msm8996_auxpcm_rate = SAMPLING_RATE_8KHZ;
  64. static int slim5_rx_sample_rate = SAMPLING_RATE_48KHZ;
  65. static int slim5_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  66. static int slim6_rx_sample_rate = SAMPLING_RATE_48KHZ;
  67. static int slim6_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  68. static struct platform_device *spdev;
  69. static int ext_us_amp_gpio = -1;
  70. static int msm8996_spk_control = 1;
  71. static int msm_slim_0_rx_ch = 1;
  72. static int msm_slim_0_tx_ch = 1;
  73. static int msm_slim_1_tx_ch = 1;
  74. static int msm_slim_5_rx_ch = 1;
  75. static int msm_slim_6_rx_ch = 1;
  76. static int msm_hifi_control;
  77. static int msm_vi_feed_tx_ch = 2;
  78. static int msm_hdmi_rx_ch = 2;
  79. static int msm_proxy_rx_ch = 2;
  80. static int hdmi_rx_sample_rate = SAMPLING_RATE_48KHZ;
  81. static int msm_tert_mi2s_tx_ch = 2;
  82. static bool codec_reg_done;
  83. static const char *const hifi_function[] = {"Off", "On"};
  84. static const char *const pin_states[] = {"Disable", "active"};
  85. static const char *const spk_function[] = {"Off", "On"};
  86. static const char *const slim0_rx_ch_text[] = {"One", "Two"};
  87. static const char *const slim5_rx_ch_text[] = {"One", "Two"};
  88. static const char *const slim6_rx_ch_text[] = {"One", "Two"};
  89. static const char *const slim0_tx_ch_text[] = {"One", "Two", "Three", "Four",
  90. "Five", "Six", "Seven",
  91. "Eight"};
  92. static const char *const vi_feed_ch_text[] = {"One", "Two"};
  93. static char const *hdmi_rx_ch_text[] = {"Two", "Three", "Four", "Five",
  94. "Six", "Seven", "Eight"};
  95. static char const *rx_bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE"};
  96. static char const *slim5_rx_bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE"};
  97. static char const *slim6_rx_bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE"};
  98. static char const *slim0_rx_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  99. "KHZ_192", "KHZ_44P1", "KHZ_8",
  100. "KHZ_16", "KHZ_32"};
  101. static char const *slim5_rx_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  102. "KHZ_192", "KHZ_44P1"};
  103. static char const *slim6_rx_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  104. "KHZ_192", "KHZ_44P1"};
  105. static const char *const proxy_rx_ch_text[] = {"One", "Two", "Three", "Four",
  106. "Five", "Six", "Seven", "Eight"};
  107. static char const *hdmi_rx_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  108. "KHZ_192"};
  109. static const char *const auxpcm_rate_text[] = {"8000", "16000"};
  110. static const struct soc_enum msm8996_auxpcm_enum[] = {
  111. SOC_ENUM_SINGLE_EXT(2, auxpcm_rate_text),
  112. };
  113. static struct afe_clk_set mi2s_tx_clk = {
  114. AFE_API_VERSION_I2S_CONFIG,
  115. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  116. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  117. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  118. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  119. 0,
  120. };
  121. struct msm8996_wsa881x_dev_info {
  122. struct device_node *of_node;
  123. u32 index;
  124. };
  125. static struct snd_soc_aux_dev *msm8996_aux_dev;
  126. static struct snd_soc_codec_conf *msm8996_codec_conf;
  127. struct msm8996_asoc_mach_data {
  128. u32 mclk_freq;
  129. int us_euro_gpio;
  130. int hph_en1_gpio;
  131. int hph_en0_gpio;
  132. struct snd_info_entry *codec_root;
  133. };
  134. struct msm8996_asoc_wcd93xx_codec {
  135. void* (*get_afe_config_fn)(struct snd_soc_codec *codec,
  136. enum afe_config_type config_type);
  137. void (*mbhc_hs_detect_exit)(struct snd_soc_codec *codec);
  138. };
  139. static struct msm8996_asoc_wcd93xx_codec msm8996_codec_fn;
  140. struct msm8996_liquid_dock_dev {
  141. int dock_plug_gpio;
  142. int dock_plug_irq;
  143. int dock_plug_det;
  144. struct work_struct irq_work;
  145. struct switch_dev audio_sdev;
  146. };
  147. static struct msm8996_liquid_dock_dev *msm8996_liquid_dock_dev;
  148. static void *adsp_state_notifier;
  149. static void *def_tasha_mbhc_cal(void);
  150. static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
  151. int enable, bool dapm);
  152. static int msm8996_wsa881x_init(struct snd_soc_component *component);
  153. /*
  154. * Need to report LINEIN
  155. * if R/L channel impedance is larger than 5K ohm
  156. */
  157. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  158. .read_fw_bin = false,
  159. .calibration = NULL,
  160. .detect_extn_cable = true,
  161. .mono_stero_detection = false,
  162. .swap_gnd_mic = NULL,
  163. .hs_ext_micbias = true,
  164. .key_code[0] = KEY_MEDIA,
  165. .key_code[1] = KEY_VOICECOMMAND,
  166. .key_code[2] = KEY_VOLUMEUP,
  167. .key_code[3] = KEY_VOLUMEDOWN,
  168. .key_code[4] = 0,
  169. .key_code[5] = 0,
  170. .key_code[6] = 0,
  171. .key_code[7] = 0,
  172. .linein_th = 5000,
  173. .moisture_en = true,
  174. .mbhc_micbias = MIC_BIAS_2,
  175. .anc_micbias = MIC_BIAS_2,
  176. .enable_anc_mic_detect = false,
  177. };
  178. static inline int param_is_mask(int p)
  179. {
  180. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  181. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  182. }
  183. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  184. int n)
  185. {
  186. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  187. }
  188. static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned int bit)
  189. {
  190. if (bit >= SNDRV_MASK_MAX)
  191. return;
  192. if (param_is_mask(n)) {
  193. struct snd_mask *m = param_to_mask(p, n);
  194. m->bits[0] = 0;
  195. m->bits[1] = 0;
  196. m->bits[bit >> 5] |= (1 << (bit & 31));
  197. }
  198. }
  199. static void msm8996_liquid_docking_irq_work(struct work_struct *work)
  200. {
  201. struct msm8996_liquid_dock_dev *dock_dev =
  202. container_of(work, struct msm8996_liquid_dock_dev,
  203. irq_work);
  204. dock_dev->dock_plug_det =
  205. gpio_get_value(dock_dev->dock_plug_gpio);
  206. switch_set_state(&dock_dev->audio_sdev, dock_dev->dock_plug_det);
  207. /* notify to audio daemon */
  208. sysfs_notify(&dock_dev->audio_sdev.dev->kobj, NULL, "state");
  209. }
  210. static irqreturn_t msm8996_liquid_docking_irq_handler(int irq, void *dev)
  211. {
  212. struct msm8996_liquid_dock_dev *dock_dev = dev;
  213. /* switch speakers should not run in interrupt context */
  214. schedule_work(&dock_dev->irq_work);
  215. return IRQ_HANDLED;
  216. }
  217. static int msm8996_liquid_init_docking(void)
  218. {
  219. int ret = 0;
  220. int dock_plug_gpio = 0;
  221. /* plug in docking speaker+plug in device OR unplug one of them */
  222. u32 dock_plug_irq_flags = IRQF_TRIGGER_RISING |
  223. IRQF_TRIGGER_FALLING |
  224. IRQF_SHARED;
  225. dock_plug_gpio = of_get_named_gpio(spdev->dev.of_node,
  226. "qcom,dock-plug-det-irq", 0);
  227. if (dock_plug_gpio >= 0) {
  228. msm8996_liquid_dock_dev =
  229. kzalloc(sizeof(*msm8996_liquid_dock_dev), GFP_KERNEL);
  230. if (!msm8996_liquid_dock_dev) {
  231. ret = -ENOMEM;
  232. goto exit;
  233. }
  234. msm8996_liquid_dock_dev->dock_plug_gpio = dock_plug_gpio;
  235. ret = gpio_request(msm8996_liquid_dock_dev->dock_plug_gpio,
  236. "dock-plug-det-irq");
  237. if (ret) {
  238. pr_err("%s:failed request msm8996_liquid_dock_plug_gpio err = %d\n",
  239. __func__, ret);
  240. ret = -EINVAL;
  241. goto fail_dock_gpio;
  242. }
  243. msm8996_liquid_dock_dev->dock_plug_det =
  244. gpio_get_value(
  245. msm8996_liquid_dock_dev->dock_plug_gpio);
  246. msm8996_liquid_dock_dev->dock_plug_irq =
  247. gpio_to_irq(
  248. msm8996_liquid_dock_dev->dock_plug_gpio);
  249. ret = request_irq(msm8996_liquid_dock_dev->dock_plug_irq,
  250. msm8996_liquid_docking_irq_handler,
  251. dock_plug_irq_flags,
  252. "liquid_dock_plug_irq",
  253. msm8996_liquid_dock_dev);
  254. if (ret < 0) {
  255. pr_err("%s: Request Irq Failed err = %d\n",
  256. __func__, ret);
  257. goto fail_dock_gpio;
  258. }
  259. msm8996_liquid_dock_dev->audio_sdev.name =
  260. QC_AUDIO_EXTERNAL_SPK_1_EVENT;
  261. if (switch_dev_register(
  262. &msm8996_liquid_dock_dev->audio_sdev) < 0) {
  263. pr_err("%s: dock device register in switch diretory failed\n",
  264. __func__);
  265. goto fail_switch_dev;
  266. }
  267. INIT_WORK(
  268. &msm8996_liquid_dock_dev->irq_work,
  269. msm8996_liquid_docking_irq_work);
  270. }
  271. return 0;
  272. fail_switch_dev:
  273. free_irq(msm8996_liquid_dock_dev->dock_plug_irq,
  274. msm8996_liquid_dock_dev);
  275. fail_dock_gpio:
  276. gpio_free(msm8996_liquid_dock_dev->dock_plug_gpio);
  277. exit:
  278. kfree(msm8996_liquid_dock_dev);
  279. msm8996_liquid_dock_dev = NULL;
  280. return ret;
  281. }
  282. static void msm8996_ext_control(struct snd_soc_codec *codec)
  283. {
  284. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  285. pr_debug("%s: msm8996_spk_control = %d", __func__,
  286. msm8996_spk_control);
  287. if (msm8996_spk_control == MSM8996_SPK_ON) {
  288. snd_soc_dapm_enable_pin(dapm, "Lineout_1 amp");
  289. snd_soc_dapm_enable_pin(dapm, "Lineout_2 amp");
  290. } else {
  291. snd_soc_dapm_disable_pin(dapm, "Lineout_1 amp");
  292. snd_soc_dapm_disable_pin(dapm, "Lineout_2 amp");
  293. }
  294. snd_soc_dapm_sync(dapm);
  295. }
  296. static int msm8996_get_spk(struct snd_kcontrol *kcontrol,
  297. struct snd_ctl_elem_value *ucontrol)
  298. {
  299. pr_debug("%s: msm8996_spk_control = %d\n",
  300. __func__, msm8996_spk_control);
  301. ucontrol->value.integer.value[0] = msm8996_spk_control;
  302. return 0;
  303. }
  304. static int msm8996_set_spk(struct snd_kcontrol *kcontrol,
  305. struct snd_ctl_elem_value *ucontrol)
  306. {
  307. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  308. pr_debug("%s() ucontrol->value.integer.value[0] = %ld\n",
  309. __func__, ucontrol->value.integer.value[0]);
  310. if (msm8996_spk_control == ucontrol->value.integer.value[0])
  311. return 0;
  312. msm8996_spk_control = ucontrol->value.integer.value[0];
  313. msm8996_ext_control(codec);
  314. return 1;
  315. }
  316. static int msm8996_hifi_ctrl(struct snd_soc_codec *codec)
  317. {
  318. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  319. struct snd_soc_card *card = codec->component.card;
  320. struct msm8996_asoc_mach_data *pdata =
  321. snd_soc_card_get_drvdata(card);
  322. pr_debug("%s: msm_hifi_control = %d", __func__,
  323. msm_hifi_control);
  324. if (pdata->hph_en1_gpio < 0) {
  325. pr_err("%s: hph_en1_gpio is invalid\n", __func__);
  326. return -EINVAL;
  327. }
  328. if (msm_hifi_control == MSM8996_HIFI_ON) {
  329. gpio_direction_output(pdata->hph_en1_gpio, 1);
  330. /* 5msec delay needed as per HW requirement */
  331. usleep_range(5000, 5010);
  332. } else {
  333. gpio_direction_output(pdata->hph_en1_gpio, 0);
  334. }
  335. snd_soc_dapm_sync(dapm);
  336. return 0;
  337. }
  338. static int msm8996_hifi_get(struct snd_kcontrol *kcontrol,
  339. struct snd_ctl_elem_value *ucontrol)
  340. {
  341. pr_debug("%s: msm_hifi_control = %d\n",
  342. __func__, msm_hifi_control);
  343. ucontrol->value.integer.value[0] = msm_hifi_control;
  344. return 0;
  345. }
  346. static int msm8996_hifi_put(struct snd_kcontrol *kcontrol,
  347. struct snd_ctl_elem_value *ucontrol)
  348. {
  349. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  350. pr_debug("%s() ucontrol->value.integer.value[0] = %ld\n",
  351. __func__, ucontrol->value.integer.value[0]);
  352. msm_hifi_control = ucontrol->value.integer.value[0];
  353. msm8996_hifi_ctrl(codec);
  354. return 1;
  355. }
  356. static int msm8996_ext_us_amp_init(void)
  357. {
  358. int ret = 0;
  359. ext_us_amp_gpio = of_get_named_gpio(spdev->dev.of_node,
  360. "qcom,ext-ult-spk-amp-gpio", 0);
  361. if (ext_us_amp_gpio >= 0) {
  362. ret = gpio_request(ext_us_amp_gpio, "ext_us_amp_gpio");
  363. if (ret) {
  364. pr_err("%s: ext_us_amp_gpio request failed, ret:%d\n",
  365. __func__, ret);
  366. return ret;
  367. }
  368. gpio_direction_output(ext_us_amp_gpio, 0);
  369. }
  370. return ret;
  371. }
  372. static void msm8996_ext_us_amp_enable(u32 on)
  373. {
  374. if (on)
  375. gpio_direction_output(ext_us_amp_gpio, 1);
  376. else
  377. gpio_direction_output(ext_us_amp_gpio, 0);
  378. pr_debug("%s: US Emitter GPIO enable:%s\n", __func__,
  379. on ? "Enable" : "Disable");
  380. }
  381. static int msm_ext_ultrasound_event(struct snd_soc_dapm_widget *w,
  382. struct snd_kcontrol *k, int event)
  383. {
  384. pr_debug("%s()\n", __func__);
  385. if (strcmp(w->name, "ultrasound amp")) {
  386. if (!gpio_is_valid(ext_us_amp_gpio)) {
  387. pr_err("%s: ext_us_amp_gpio isn't configured\n",
  388. __func__);
  389. return -EINVAL;
  390. }
  391. if (SND_SOC_DAPM_EVENT_ON(event))
  392. msm8996_ext_us_amp_enable(1);
  393. else
  394. msm8996_ext_us_amp_enable(0);
  395. } else {
  396. pr_err("%s() Invalid Widget = %s\n",
  397. __func__, w->name);
  398. return -EINVAL;
  399. }
  400. return 0;
  401. }
  402. static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
  403. int enable, bool dapm)
  404. {
  405. int ret = 0;
  406. if (!strcmp(dev_name(codec->dev), "tasha_codec")) {
  407. ret = tasha_cdc_mclk_enable(codec, enable, dapm);
  408. } else {
  409. dev_err(codec->dev, "%s: unknown codec to enable ext clk\n",
  410. __func__);
  411. ret = -EINVAL;
  412. }
  413. return ret;
  414. }
  415. static int msm8996_mclk_event(struct snd_soc_dapm_widget *w,
  416. struct snd_kcontrol *kcontrol, int event)
  417. {
  418. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  419. pr_debug("%s: event = %d\n", __func__, event);
  420. switch (event) {
  421. case SND_SOC_DAPM_PRE_PMU:
  422. return msm_snd_enable_codec_ext_clk(codec, 1, true);
  423. case SND_SOC_DAPM_POST_PMD:
  424. return msm_snd_enable_codec_ext_clk(codec, 0, true);
  425. }
  426. return 0;
  427. }
  428. static int msm_snd_enable_codec_ext_tx_clk(struct snd_soc_codec *codec,
  429. int enable, bool dapm)
  430. {
  431. int ret = 0;
  432. if (!strcmp(dev_name(codec->dev), "tasha_codec"))
  433. ret = tasha_cdc_mclk_tx_enable(codec, enable, dapm);
  434. else {
  435. dev_err(codec->dev, "%s: unknown codec to enable ext clk\n",
  436. __func__);
  437. ret = -EINVAL;
  438. }
  439. return ret;
  440. }
  441. static int msm8996_mclk_tx_event(struct snd_soc_dapm_widget *w,
  442. struct snd_kcontrol *kcontrol, int event)
  443. {
  444. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  445. pr_debug("%s: event = %d\n", __func__, event);
  446. switch (event) {
  447. case SND_SOC_DAPM_PRE_PMU:
  448. return msm_snd_enable_codec_ext_tx_clk(codec, 1, true);
  449. case SND_SOC_DAPM_POST_PMD:
  450. return msm_snd_enable_codec_ext_tx_clk(codec, 0, true);
  451. }
  452. return 0;
  453. }
  454. static int msm_hifi_ctrl_event(struct snd_soc_dapm_widget *w,
  455. struct snd_kcontrol *k, int event)
  456. {
  457. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  458. struct snd_soc_card *card = codec->component.card;
  459. struct msm8996_asoc_mach_data *pdata =
  460. snd_soc_card_get_drvdata(card);
  461. int ret = 0;
  462. pr_debug("%s: msm_hifi_control = %d", __func__,
  463. msm_hifi_control);
  464. switch (event) {
  465. case SND_SOC_DAPM_POST_PMU:
  466. if (msm_hifi_control == MSM8996_HIFI_ON) {
  467. if (pdata->hph_en0_gpio < 0) {
  468. pr_err("%s: hph_en0_gpio is invalid\n",
  469. __func__);
  470. ret = -EINVAL;
  471. goto err;
  472. }
  473. gpio_direction_output(pdata->hph_en0_gpio, 1);
  474. }
  475. break;
  476. case SND_SOC_DAPM_PRE_PMD:
  477. if (msm_hifi_control == MSM8996_HIFI_ON) {
  478. if (pdata->hph_en0_gpio < 0) {
  479. pr_err("%s: hph_en0_gpio is invalid\n",
  480. __func__);
  481. ret = -EINVAL;
  482. goto err;
  483. }
  484. gpio_direction_output(pdata->hph_en0_gpio, 0);
  485. }
  486. break;
  487. }
  488. err:
  489. return ret;
  490. }
  491. static const struct snd_soc_dapm_widget msm8996_dapm_widgets[] = {
  492. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  493. msm8996_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  494. SND_SOC_DAPM_SUPPLY("MCLK TX", SND_SOC_NOPM, 0, 0,
  495. msm8996_mclk_tx_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  496. SND_SOC_DAPM_SPK("Lineout_1 amp", NULL),
  497. SND_SOC_DAPM_SPK("Lineout_3 amp", NULL),
  498. SND_SOC_DAPM_SPK("Lineout_2 amp", NULL),
  499. SND_SOC_DAPM_SPK("Lineout_4 amp", NULL),
  500. SND_SOC_DAPM_SPK("ultrasound amp", msm_ext_ultrasound_event),
  501. SND_SOC_DAPM_SPK("hifi amp", msm_hifi_ctrl_event),
  502. SND_SOC_DAPM_MIC("Handset Mic", NULL),
  503. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  504. SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
  505. SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
  506. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  507. SND_SOC_DAPM_MIC("Analog Mic6", NULL),
  508. SND_SOC_DAPM_MIC("Analog Mic7", NULL),
  509. SND_SOC_DAPM_MIC("Analog Mic8", NULL),
  510. SND_SOC_DAPM_MIC("Digital Mic0", NULL),
  511. SND_SOC_DAPM_MIC("Digital Mic1", NULL),
  512. SND_SOC_DAPM_MIC("Digital Mic2", NULL),
  513. SND_SOC_DAPM_MIC("Digital Mic3", NULL),
  514. SND_SOC_DAPM_MIC("Digital Mic4", NULL),
  515. SND_SOC_DAPM_MIC("Digital Mic5", NULL),
  516. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  517. };
  518. static struct snd_soc_dapm_route wcd9335_audio_paths[] = {
  519. {"MIC BIAS1", NULL, "MCLK TX"},
  520. {"MIC BIAS2", NULL, "MCLK TX"},
  521. {"MIC BIAS3", NULL, "MCLK TX"},
  522. {"MIC BIAS4", NULL, "MCLK TX"},
  523. };
  524. static int slim5_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  525. struct snd_ctl_elem_value *ucontrol)
  526. {
  527. int sample_rate_val = 0;
  528. switch (slim5_rx_sample_rate) {
  529. case SAMPLING_RATE_44P1KHZ:
  530. sample_rate_val = 3;
  531. break;
  532. case SAMPLING_RATE_192KHZ:
  533. sample_rate_val = 2;
  534. break;
  535. case SAMPLING_RATE_96KHZ:
  536. sample_rate_val = 1;
  537. break;
  538. case SAMPLING_RATE_48KHZ:
  539. default:
  540. sample_rate_val = 0;
  541. break;
  542. }
  543. ucontrol->value.integer.value[0] = sample_rate_val;
  544. pr_debug("%s: slim5_rx_sample_rate = %d\n", __func__,
  545. slim5_rx_sample_rate);
  546. return 0;
  547. }
  548. static int slim5_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  549. struct snd_ctl_elem_value *ucontrol)
  550. {
  551. pr_debug("%s: ucontrol value = %ld\n", __func__,
  552. ucontrol->value.integer.value[0]);
  553. switch (ucontrol->value.integer.value[0]) {
  554. case 3:
  555. slim5_rx_sample_rate = SAMPLING_RATE_44P1KHZ;
  556. break;
  557. case 2:
  558. slim5_rx_sample_rate = SAMPLING_RATE_192KHZ;
  559. break;
  560. case 1:
  561. slim5_rx_sample_rate = SAMPLING_RATE_96KHZ;
  562. break;
  563. case 0:
  564. default:
  565. slim5_rx_sample_rate = SAMPLING_RATE_48KHZ;
  566. }
  567. pr_debug("%s: slim5_rx_sample_rate = %d\n", __func__,
  568. slim5_rx_sample_rate);
  569. return 0;
  570. }
  571. static int slim6_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  572. struct snd_ctl_elem_value *ucontrol)
  573. {
  574. int sample_rate_val = 0;
  575. switch (slim6_rx_sample_rate) {
  576. case SAMPLING_RATE_44P1KHZ:
  577. sample_rate_val = 3;
  578. break;
  579. case SAMPLING_RATE_192KHZ:
  580. sample_rate_val = 2;
  581. break;
  582. case SAMPLING_RATE_96KHZ:
  583. sample_rate_val = 1;
  584. break;
  585. case SAMPLING_RATE_48KHZ:
  586. default:
  587. sample_rate_val = 0;
  588. break;
  589. }
  590. ucontrol->value.integer.value[0] = sample_rate_val;
  591. pr_debug("%s: slim6_rx_sample_rate = %d\n", __func__,
  592. slim6_rx_sample_rate);
  593. return 0;
  594. }
  595. static int slim6_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  596. struct snd_ctl_elem_value *ucontrol)
  597. {
  598. switch (ucontrol->value.integer.value[0]) {
  599. case 3:
  600. slim6_rx_sample_rate = SAMPLING_RATE_44P1KHZ;
  601. break;
  602. case 2:
  603. slim6_rx_sample_rate = SAMPLING_RATE_192KHZ;
  604. break;
  605. case 1:
  606. slim6_rx_sample_rate = SAMPLING_RATE_96KHZ;
  607. break;
  608. case 0:
  609. default:
  610. slim6_rx_sample_rate = SAMPLING_RATE_48KHZ;
  611. break;
  612. }
  613. pr_debug("%s: ucontrol value = %ld, slim6_rx_sample_rate = %d\n",
  614. __func__, ucontrol->value.integer.value[0],
  615. slim6_rx_sample_rate);
  616. return 0;
  617. }
  618. static int slim0_tx_bit_format_get(struct snd_kcontrol *kcontrol,
  619. struct snd_ctl_elem_value *ucontrol)
  620. {
  621. switch (slim0_tx_bit_format) {
  622. case SNDRV_PCM_FORMAT_S24_3LE:
  623. ucontrol->value.integer.value[0] = 2;
  624. break;
  625. case SNDRV_PCM_FORMAT_S24_LE:
  626. ucontrol->value.integer.value[0] = 1;
  627. break;
  628. case SNDRV_PCM_FORMAT_S16_LE:
  629. default:
  630. ucontrol->value.integer.value[0] = 0;
  631. break;
  632. }
  633. pr_debug("%s: slim0_tx_bit_format = %d, ucontrol value = %ld\n",
  634. __func__, slim0_tx_bit_format,
  635. ucontrol->value.integer.value[0]);
  636. return 0;
  637. }
  638. static int slim0_tx_bit_format_put(struct snd_kcontrol *kcontrol,
  639. struct snd_ctl_elem_value *ucontrol)
  640. {
  641. int rc = 0;
  642. switch (ucontrol->value.integer.value[0]) {
  643. case 2:
  644. slim0_tx_bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  645. break;
  646. case 1:
  647. slim0_tx_bit_format = SNDRV_PCM_FORMAT_S24_LE;
  648. break;
  649. case 0:
  650. slim0_tx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  651. break;
  652. default:
  653. pr_err("%s: invalid value %ld\n", __func__,
  654. ucontrol->value.integer.value[0]);
  655. rc = -EINVAL;
  656. break;
  657. }
  658. pr_debug("%s: ucontrol value = %ld, slim0_tx_bit_format = %d\n",
  659. __func__, ucontrol->value.integer.value[0],
  660. slim0_tx_bit_format);
  661. return rc;
  662. }
  663. static int slim0_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  664. struct snd_ctl_elem_value *ucontrol)
  665. {
  666. int sample_rate_val = 0;
  667. switch (slim0_rx_sample_rate) {
  668. case SAMPLING_RATE_32KHZ:
  669. sample_rate_val = 6;
  670. break;
  671. case SAMPLING_RATE_16KHZ:
  672. sample_rate_val = 5;
  673. break;
  674. case SAMPLING_RATE_8KHZ:
  675. sample_rate_val = 4;
  676. break;
  677. case SAMPLING_RATE_44P1KHZ:
  678. sample_rate_val = 3;
  679. break;
  680. case SAMPLING_RATE_192KHZ:
  681. sample_rate_val = 2;
  682. break;
  683. case SAMPLING_RATE_96KHZ:
  684. sample_rate_val = 1;
  685. break;
  686. case SAMPLING_RATE_48KHZ:
  687. default:
  688. sample_rate_val = 0;
  689. break;
  690. }
  691. ucontrol->value.integer.value[0] = sample_rate_val;
  692. pr_debug("%s: slim0_rx_sample_rate = %d\n", __func__,
  693. slim0_rx_sample_rate);
  694. return 0;
  695. }
  696. static int slim0_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  697. struct snd_ctl_elem_value *ucontrol)
  698. {
  699. pr_debug("%s: ucontrol value = %ld\n", __func__,
  700. ucontrol->value.integer.value[0]);
  701. switch (ucontrol->value.integer.value[0]) {
  702. case 6:
  703. slim0_rx_sample_rate = SAMPLING_RATE_32KHZ;
  704. break;
  705. case 5:
  706. slim0_rx_sample_rate = SAMPLING_RATE_16KHZ;
  707. break;
  708. case 4:
  709. slim0_rx_sample_rate = SAMPLING_RATE_8KHZ;
  710. break;
  711. case 3:
  712. slim0_rx_sample_rate = SAMPLING_RATE_44P1KHZ;
  713. break;
  714. case 2:
  715. slim0_rx_sample_rate = SAMPLING_RATE_192KHZ;
  716. break;
  717. case 1:
  718. slim0_rx_sample_rate = SAMPLING_RATE_96KHZ;
  719. break;
  720. case 0:
  721. default:
  722. slim0_rx_sample_rate = SAMPLING_RATE_48KHZ;
  723. }
  724. pr_debug("%s: slim0_rx_sample_rate = %d\n", __func__,
  725. slim0_rx_sample_rate);
  726. return 0;
  727. }
  728. static int slim0_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  729. struct snd_ctl_elem_value *ucontrol)
  730. {
  731. int sample_rate_val = 0;
  732. switch (slim0_tx_sample_rate) {
  733. case SAMPLING_RATE_192KHZ:
  734. sample_rate_val = 2;
  735. break;
  736. case SAMPLING_RATE_96KHZ:
  737. sample_rate_val = 1;
  738. break;
  739. case SAMPLING_RATE_48KHZ:
  740. default:
  741. sample_rate_val = 0;
  742. break;
  743. }
  744. ucontrol->value.integer.value[0] = sample_rate_val;
  745. pr_debug("%s: slim0_tx_sample_rate = %d\n", __func__,
  746. slim0_tx_sample_rate);
  747. return 0;
  748. }
  749. static int slim0_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  750. struct snd_ctl_elem_value *ucontrol)
  751. {
  752. int rc = 0;
  753. pr_debug("%s: ucontrol value = %ld\n", __func__,
  754. ucontrol->value.integer.value[0]);
  755. switch (ucontrol->value.integer.value[0]) {
  756. case 2:
  757. slim0_tx_sample_rate = SAMPLING_RATE_192KHZ;
  758. break;
  759. case 1:
  760. slim0_tx_sample_rate = SAMPLING_RATE_96KHZ;
  761. break;
  762. case 0:
  763. slim0_tx_sample_rate = SAMPLING_RATE_48KHZ;
  764. break;
  765. default:
  766. rc = -EINVAL;
  767. pr_err("%s: invalid sample rate being passed\n", __func__);
  768. break;
  769. }
  770. pr_debug("%s: slim0_tx_sample_rate = %d\n", __func__,
  771. slim0_tx_sample_rate);
  772. return rc;
  773. }
  774. static int slim5_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  775. struct snd_ctl_elem_value *ucontrol)
  776. {
  777. switch (slim5_rx_bit_format) {
  778. case SNDRV_PCM_FORMAT_S24_3LE:
  779. ucontrol->value.integer.value[0] = 2;
  780. break;
  781. case SNDRV_PCM_FORMAT_S24_LE:
  782. ucontrol->value.integer.value[0] = 1;
  783. break;
  784. case SNDRV_PCM_FORMAT_S16_LE:
  785. default:
  786. ucontrol->value.integer.value[0] = 0;
  787. break;
  788. }
  789. pr_debug("%s: slim5_rx_bit_format = %d, ucontrol value = %ld\n",
  790. __func__, slim5_rx_bit_format,
  791. ucontrol->value.integer.value[0]);
  792. return 0;
  793. }
  794. static int slim5_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  795. struct snd_ctl_elem_value *ucontrol)
  796. {
  797. switch (ucontrol->value.integer.value[0]) {
  798. case 2:
  799. slim5_rx_bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  800. break;
  801. case 1:
  802. slim5_rx_bit_format = SNDRV_PCM_FORMAT_S24_LE;
  803. break;
  804. case 0:
  805. default:
  806. slim5_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  807. break;
  808. }
  809. return 0;
  810. }
  811. static int slim6_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  812. struct snd_ctl_elem_value *ucontrol)
  813. {
  814. switch (slim6_rx_bit_format) {
  815. case SNDRV_PCM_FORMAT_S24_3LE:
  816. ucontrol->value.integer.value[0] = 2;
  817. break;
  818. case SNDRV_PCM_FORMAT_S24_LE:
  819. ucontrol->value.integer.value[0] = 1;
  820. break;
  821. case SNDRV_PCM_FORMAT_S16_LE:
  822. default:
  823. ucontrol->value.integer.value[0] = 0;
  824. break;
  825. }
  826. pr_debug("%s: slim6_rx_bit_format = %d, ucontrol value = %ld\n",
  827. __func__, slim6_rx_bit_format,
  828. ucontrol->value.integer.value[0]);
  829. return 0;
  830. }
  831. static int slim6_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  832. struct snd_ctl_elem_value *ucontrol)
  833. {
  834. switch (ucontrol->value.integer.value[0]) {
  835. case 2:
  836. slim6_rx_bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  837. break;
  838. case 1:
  839. slim6_rx_bit_format = SNDRV_PCM_FORMAT_S24_LE;
  840. break;
  841. case 0:
  842. default:
  843. slim6_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  844. break;
  845. }
  846. return 0;
  847. }
  848. static int slim0_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  849. struct snd_ctl_elem_value *ucontrol)
  850. {
  851. switch (slim0_rx_bit_format) {
  852. case SNDRV_PCM_FORMAT_S24_3LE:
  853. ucontrol->value.integer.value[0] = 2;
  854. break;
  855. case SNDRV_PCM_FORMAT_S24_LE:
  856. ucontrol->value.integer.value[0] = 1;
  857. break;
  858. case SNDRV_PCM_FORMAT_S16_LE:
  859. default:
  860. ucontrol->value.integer.value[0] = 0;
  861. break;
  862. }
  863. pr_debug("%s: slim0_rx_bit_format = %d, ucontrol value = %ld\n",
  864. __func__, slim0_rx_bit_format,
  865. ucontrol->value.integer.value[0]);
  866. return 0;
  867. }
  868. static int slim0_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  869. struct snd_ctl_elem_value *ucontrol)
  870. {
  871. switch (ucontrol->value.integer.value[0]) {
  872. case 2:
  873. slim0_rx_bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  874. break;
  875. case 1:
  876. slim0_rx_bit_format = SNDRV_PCM_FORMAT_S24_LE;
  877. break;
  878. case 0:
  879. default:
  880. slim0_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  881. break;
  882. }
  883. return 0;
  884. }
  885. static int msm_slim_5_rx_ch_get(struct snd_kcontrol *kcontrol,
  886. struct snd_ctl_elem_value *ucontrol)
  887. {
  888. pr_debug("%s: msm_slim_5_rx_ch = %d\n", __func__,
  889. msm_slim_5_rx_ch);
  890. ucontrol->value.integer.value[0] = msm_slim_5_rx_ch - 1;
  891. return 0;
  892. }
  893. static int msm_slim_5_rx_ch_put(struct snd_kcontrol *kcontrol,
  894. struct snd_ctl_elem_value *ucontrol)
  895. {
  896. msm_slim_5_rx_ch = ucontrol->value.integer.value[0] + 1;
  897. pr_debug("%s: msm_slim_5_rx_ch = %d\n", __func__,
  898. msm_slim_5_rx_ch);
  899. return 1;
  900. }
  901. static int msm_slim_6_rx_ch_get(struct snd_kcontrol *kcontrol,
  902. struct snd_ctl_elem_value *ucontrol)
  903. {
  904. pr_debug("%s: msm_slim_6_rx_ch = %d\n", __func__,
  905. msm_slim_6_rx_ch);
  906. ucontrol->value.integer.value[0] = msm_slim_6_rx_ch - 1;
  907. return 0;
  908. }
  909. static int msm_slim_6_rx_ch_put(struct snd_kcontrol *kcontrol,
  910. struct snd_ctl_elem_value *ucontrol)
  911. {
  912. msm_slim_6_rx_ch = ucontrol->value.integer.value[0] + 1;
  913. pr_debug("%s: msm_slim_6_rx_ch = %d\n", __func__,
  914. msm_slim_6_rx_ch);
  915. return 1;
  916. }
  917. static int msm_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol,
  918. struct snd_ctl_elem_value *ucontrol)
  919. {
  920. pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
  921. msm_slim_0_rx_ch);
  922. ucontrol->value.integer.value[0] = msm_slim_0_rx_ch - 1;
  923. return 0;
  924. }
  925. static int msm_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol,
  926. struct snd_ctl_elem_value *ucontrol)
  927. {
  928. msm_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1;
  929. pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
  930. msm_slim_0_rx_ch);
  931. return 1;
  932. }
  933. static int msm_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol,
  934. struct snd_ctl_elem_value *ucontrol)
  935. {
  936. pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__,
  937. msm_slim_0_tx_ch);
  938. ucontrol->value.integer.value[0] = msm_slim_0_tx_ch - 1;
  939. return 0;
  940. }
  941. static int msm_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol,
  942. struct snd_ctl_elem_value *ucontrol)
  943. {
  944. msm_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1;
  945. pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, msm_slim_0_tx_ch);
  946. return 1;
  947. }
  948. static int msm_slim_1_tx_ch_get(struct snd_kcontrol *kcontrol,
  949. struct snd_ctl_elem_value *ucontrol)
  950. {
  951. pr_debug("%s: msm_slim_1_tx_ch = %d\n", __func__,
  952. msm_slim_1_tx_ch);
  953. ucontrol->value.integer.value[0] = msm_slim_1_tx_ch - 1;
  954. return 0;
  955. }
  956. static int msm_slim_1_tx_ch_put(struct snd_kcontrol *kcontrol,
  957. struct snd_ctl_elem_value *ucontrol)
  958. {
  959. msm_slim_1_tx_ch = ucontrol->value.integer.value[0] + 1;
  960. pr_debug("%s: msm_slim_1_tx_ch = %d\n", __func__, msm_slim_1_tx_ch);
  961. return 1;
  962. }
  963. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  964. struct snd_ctl_elem_value *ucontrol)
  965. {
  966. ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
  967. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  968. ucontrol->value.integer.value[0]);
  969. return 0;
  970. }
  971. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  972. struct snd_ctl_elem_value *ucontrol)
  973. {
  974. msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
  975. pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
  976. return 1;
  977. }
  978. static int hdmi_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  979. struct snd_ctl_elem_value *ucontrol)
  980. {
  981. switch (hdmi_rx_bit_format) {
  982. case SNDRV_PCM_FORMAT_S24_3LE:
  983. ucontrol->value.integer.value[0] = 2;
  984. break;
  985. case SNDRV_PCM_FORMAT_S24_LE:
  986. ucontrol->value.integer.value[0] = 1;
  987. break;
  988. case SNDRV_PCM_FORMAT_S16_LE:
  989. default:
  990. ucontrol->value.integer.value[0] = 0;
  991. break;
  992. }
  993. pr_debug("%s: hdmi_rx_bit_format = %d, ucontrol value = %ld\n",
  994. __func__, hdmi_rx_bit_format,
  995. ucontrol->value.integer.value[0]);
  996. return 0;
  997. }
  998. static int hdmi_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  999. struct snd_ctl_elem_value *ucontrol)
  1000. {
  1001. switch (ucontrol->value.integer.value[0]) {
  1002. case 2:
  1003. hdmi_rx_bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1004. break;
  1005. case 1:
  1006. hdmi_rx_bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1007. break;
  1008. case 0:
  1009. default:
  1010. hdmi_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1011. break;
  1012. }
  1013. pr_debug("%s: hdmi_rx_bit_format = %d, ucontrol value = %ld\n",
  1014. __func__, hdmi_rx_bit_format,
  1015. ucontrol->value.integer.value[0]);
  1016. return 0;
  1017. }
  1018. static int msm_hdmi_rx_ch_get(struct snd_kcontrol *kcontrol,
  1019. struct snd_ctl_elem_value *ucontrol)
  1020. {
  1021. pr_debug("%s: msm_hdmi_rx_ch = %d\n", __func__,
  1022. msm_hdmi_rx_ch);
  1023. ucontrol->value.integer.value[0] = msm_hdmi_rx_ch - 2;
  1024. return 0;
  1025. }
  1026. static int msm_hdmi_rx_ch_put(struct snd_kcontrol *kcontrol,
  1027. struct snd_ctl_elem_value *ucontrol)
  1028. {
  1029. msm_hdmi_rx_ch = ucontrol->value.integer.value[0] + 2;
  1030. if (msm_hdmi_rx_ch > 8) {
  1031. pr_err("%s: channels %d exceeded 8.Limiting to max chs-8\n",
  1032. __func__, msm_hdmi_rx_ch);
  1033. msm_hdmi_rx_ch = 8;
  1034. }
  1035. pr_debug("%s: msm_hdmi_rx_ch = %d\n", __func__, msm_hdmi_rx_ch);
  1036. return 1;
  1037. }
  1038. static int hdmi_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1039. struct snd_ctl_elem_value *ucontrol)
  1040. {
  1041. int sample_rate_val = 0;
  1042. switch (hdmi_rx_sample_rate) {
  1043. case SAMPLING_RATE_192KHZ:
  1044. sample_rate_val = 2;
  1045. break;
  1046. case SAMPLING_RATE_96KHZ:
  1047. sample_rate_val = 1;
  1048. break;
  1049. case SAMPLING_RATE_48KHZ:
  1050. default:
  1051. sample_rate_val = 0;
  1052. break;
  1053. }
  1054. ucontrol->value.integer.value[0] = sample_rate_val;
  1055. pr_debug("%s: hdmi_rx_sample_rate = %d\n", __func__,
  1056. hdmi_rx_sample_rate);
  1057. return 0;
  1058. }
  1059. static int hdmi_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1060. struct snd_ctl_elem_value *ucontrol)
  1061. {
  1062. pr_debug("%s: ucontrol value = %ld\n", __func__,
  1063. ucontrol->value.integer.value[0]);
  1064. switch (ucontrol->value.integer.value[0]) {
  1065. case 2:
  1066. hdmi_rx_sample_rate = SAMPLING_RATE_192KHZ;
  1067. break;
  1068. case 1:
  1069. hdmi_rx_sample_rate = SAMPLING_RATE_96KHZ;
  1070. break;
  1071. case 0:
  1072. default:
  1073. hdmi_rx_sample_rate = SAMPLING_RATE_48KHZ;
  1074. }
  1075. pr_debug("%s: hdmi_rx_sample_rate = %d\n", __func__,
  1076. hdmi_rx_sample_rate);
  1077. return 0;
  1078. }
  1079. static int msm8996_auxpcm_rate_get(struct snd_kcontrol *kcontrol,
  1080. struct snd_ctl_elem_value *ucontrol)
  1081. {
  1082. ucontrol->value.integer.value[0] = msm8996_auxpcm_rate;
  1083. return 0;
  1084. }
  1085. static int msm8996_auxpcm_rate_put(struct snd_kcontrol *kcontrol,
  1086. struct snd_ctl_elem_value *ucontrol)
  1087. {
  1088. switch (ucontrol->value.integer.value[0]) {
  1089. case 0:
  1090. msm8996_auxpcm_rate = SAMPLING_RATE_8KHZ;
  1091. break;
  1092. case 1:
  1093. msm8996_auxpcm_rate = SAMPLING_RATE_16KHZ;
  1094. break;
  1095. default:
  1096. msm8996_auxpcm_rate = SAMPLING_RATE_8KHZ;
  1097. break;
  1098. }
  1099. return 0;
  1100. }
  1101. static int msm_proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1102. struct snd_ctl_elem_value *ucontrol)
  1103. {
  1104. pr_debug("%s: msm_proxy_rx_ch = %d\n", __func__, msm_proxy_rx_ch);
  1105. ucontrol->value.integer.value[0] = msm_proxy_rx_ch - 1;
  1106. return 0;
  1107. }
  1108. static int msm_proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1109. struct snd_ctl_elem_value *ucontrol)
  1110. {
  1111. msm_proxy_rx_ch = ucontrol->value.integer.value[0] + 1;
  1112. pr_debug("%s: msm_proxy_rx_ch = %d\n", __func__, msm_proxy_rx_ch);
  1113. return 1;
  1114. }
  1115. static int msm_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1116. struct snd_pcm_hw_params *params)
  1117. {
  1118. struct snd_interval *rate =
  1119. hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
  1120. struct snd_interval *channels =
  1121. hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
  1122. rate->min = rate->max = msm8996_auxpcm_rate;
  1123. channels->min = channels->max = 1;
  1124. return 0;
  1125. }
  1126. static int msm_proxy_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1127. struct snd_pcm_hw_params *params)
  1128. {
  1129. struct snd_interval *rate = hw_param_interval(params,
  1130. SNDRV_PCM_HW_PARAM_RATE);
  1131. struct snd_interval *channels = hw_param_interval(params,
  1132. SNDRV_PCM_HW_PARAM_CHANNELS);
  1133. pr_debug("%s: msm_proxy_rx_ch =%d\n", __func__, msm_proxy_rx_ch);
  1134. if (channels->max < 2)
  1135. channels->min = channels->max = 2;
  1136. channels->min = channels->max = msm_proxy_rx_ch;
  1137. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  1138. return 0;
  1139. }
  1140. static int msm_proxy_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1141. struct snd_pcm_hw_params *params)
  1142. {
  1143. struct snd_interval *rate = hw_param_interval(params,
  1144. SNDRV_PCM_HW_PARAM_RATE);
  1145. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  1146. return 0;
  1147. }
  1148. static int msm8996_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1149. struct snd_pcm_hw_params *params)
  1150. {
  1151. struct snd_interval *rate = hw_param_interval(params,
  1152. SNDRV_PCM_HW_PARAM_RATE);
  1153. struct snd_interval *channels = hw_param_interval(params,
  1154. SNDRV_PCM_HW_PARAM_CHANNELS);
  1155. pr_debug("%s channels->min %u channels->max %u ()\n", __func__,
  1156. channels->min, channels->max);
  1157. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  1158. hdmi_rx_bit_format);
  1159. if (channels->max < 2)
  1160. channels->min = channels->max = 2;
  1161. rate->min = rate->max = hdmi_rx_sample_rate;
  1162. channels->min = channels->max = msm_hdmi_rx_ch;
  1163. return 0;
  1164. }
  1165. static int msm_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1166. struct snd_pcm_hw_params *params)
  1167. {
  1168. struct snd_interval *rate = hw_param_interval(params,
  1169. SNDRV_PCM_HW_PARAM_RATE);
  1170. struct snd_interval *channels = hw_param_interval(params,
  1171. SNDRV_PCM_HW_PARAM_CHANNELS);
  1172. pr_debug("%s: channel:%d\n", __func__, msm_tert_mi2s_tx_ch);
  1173. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  1174. channels->min = channels->max = msm_tert_mi2s_tx_ch;
  1175. return 0;
  1176. }
  1177. static int msm8996_mi2s_snd_startup(struct snd_pcm_substream *substream)
  1178. {
  1179. int ret = 0;
  1180. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1181. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1182. pr_debug("%s: substream = %s stream = %d\n", __func__,
  1183. substream->name, substream->stream);
  1184. mi2s_tx_clk.enable = 1;
  1185. ret = afe_set_lpass_clock_v2(AFE_PORT_ID_TERTIARY_MI2S_TX,
  1186. &mi2s_tx_clk);
  1187. if (ret < 0) {
  1188. pr_err("%s: afe lpass clock failed, err:%d\n", __func__, ret);
  1189. goto err;
  1190. }
  1191. ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
  1192. if (ret < 0)
  1193. pr_err("%s: set fmt cpu dai failed, err:%d\n", __func__, ret);
  1194. err:
  1195. return ret;
  1196. }
  1197. static void msm8996_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  1198. {
  1199. int ret = 0;
  1200. pr_debug("%s: substream = %s stream = %d\n", __func__,
  1201. substream->name, substream->stream);
  1202. mi2s_tx_clk.enable = 0;
  1203. ret = afe_set_lpass_clock_v2(AFE_PORT_ID_TERTIARY_MI2S_TX,
  1204. &mi2s_tx_clk);
  1205. if (ret < 0)
  1206. pr_err("%s: afe lpass clock failed, err:%d\n", __func__, ret);
  1207. }
  1208. static struct snd_soc_ops msm8996_mi2s_be_ops = {
  1209. .startup = msm8996_mi2s_snd_startup,
  1210. .shutdown = msm8996_mi2s_snd_shutdown,
  1211. };
  1212. static int msm_slim_5_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1213. struct snd_pcm_hw_params *params)
  1214. {
  1215. struct snd_interval *rate = hw_param_interval(params,
  1216. SNDRV_PCM_HW_PARAM_RATE);
  1217. struct snd_interval *channels = hw_param_interval(params,
  1218. SNDRV_PCM_HW_PARAM_CHANNELS);
  1219. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  1220. slim5_rx_bit_format);
  1221. rate->min = rate->max = slim5_rx_sample_rate;
  1222. channels->min = channels->max = msm_slim_5_rx_ch;
  1223. pr_debug("%s: format = %d, rate = %d, channels = %d\n",
  1224. __func__, params_format(params), params_rate(params),
  1225. msm_slim_5_rx_ch);
  1226. return 0;
  1227. }
  1228. static int msm_slim_6_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1229. struct snd_pcm_hw_params *params)
  1230. {
  1231. struct snd_interval *rate = hw_param_interval(params,
  1232. SNDRV_PCM_HW_PARAM_RATE);
  1233. struct snd_interval *channels = hw_param_interval(params,
  1234. SNDRV_PCM_HW_PARAM_CHANNELS);
  1235. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  1236. slim6_rx_bit_format);
  1237. rate->min = rate->max = slim6_rx_sample_rate;
  1238. channels->min = channels->max = msm_slim_6_rx_ch;
  1239. pr_debug("%s: format = %d, rate = %d, channels = %d\n",
  1240. __func__, params_format(params), params_rate(params),
  1241. msm_slim_6_rx_ch);
  1242. return 0;
  1243. }
  1244. static int msm_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1245. struct snd_pcm_hw_params *params)
  1246. {
  1247. struct snd_interval *rate = hw_param_interval(params,
  1248. SNDRV_PCM_HW_PARAM_RATE);
  1249. struct snd_interval *channels = hw_param_interval(params,
  1250. SNDRV_PCM_HW_PARAM_CHANNELS);
  1251. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  1252. slim0_rx_bit_format);
  1253. rate->min = rate->max = slim0_rx_sample_rate;
  1254. channels->min = channels->max = msm_slim_0_rx_ch;
  1255. pr_debug("%s: format = %d, rate = %d, channels = %d\n",
  1256. __func__, params_format(params), params_rate(params),
  1257. msm_slim_0_rx_ch);
  1258. return 0;
  1259. }
  1260. static int msm_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1261. struct snd_pcm_hw_params *params)
  1262. {
  1263. struct snd_interval *rate = hw_param_interval(params,
  1264. SNDRV_PCM_HW_PARAM_RATE);
  1265. struct snd_interval *channels = hw_param_interval(params,
  1266. SNDRV_PCM_HW_PARAM_CHANNELS);
  1267. pr_debug("%s()\n", __func__);
  1268. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT, slim0_tx_bit_format);
  1269. rate->min = rate->max = slim0_tx_sample_rate;
  1270. channels->min = channels->max = msm_slim_0_tx_ch;
  1271. return 0;
  1272. }
  1273. static int msm_slim_1_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1274. struct snd_pcm_hw_params *params)
  1275. {
  1276. struct snd_interval *rate = hw_param_interval(params,
  1277. SNDRV_PCM_HW_PARAM_RATE);
  1278. struct snd_interval *channels = hw_param_interval(params,
  1279. SNDRV_PCM_HW_PARAM_CHANNELS);
  1280. pr_debug("%s()\n", __func__);
  1281. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT, slim1_tx_bit_format);
  1282. rate->min = rate->max = slim1_tx_sample_rate;
  1283. channels->min = channels->max = msm_slim_1_tx_ch;
  1284. return 0;
  1285. }
  1286. static int msm_slim_4_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1287. struct snd_pcm_hw_params *params)
  1288. {
  1289. struct snd_interval *rate = hw_param_interval(params,
  1290. SNDRV_PCM_HW_PARAM_RATE);
  1291. struct snd_interval *channels = hw_param_interval(params,
  1292. SNDRV_PCM_HW_PARAM_CHANNELS);
  1293. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  1294. SNDRV_PCM_FORMAT_S32_LE);
  1295. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  1296. channels->min = channels->max = msm_vi_feed_tx_ch;
  1297. pr_debug("%s: msm_vi_feed_tx_ch: %d\n", __func__, msm_vi_feed_tx_ch);
  1298. return 0;
  1299. }
  1300. static int msm_slim_5_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1301. struct snd_pcm_hw_params *params)
  1302. {
  1303. int rc = 0;
  1304. void *config = NULL;
  1305. struct snd_soc_codec *codec = rtd->codec;
  1306. struct snd_interval *rate = hw_param_interval(params,
  1307. SNDRV_PCM_HW_PARAM_RATE);
  1308. struct snd_interval *channels = hw_param_interval(params,
  1309. SNDRV_PCM_HW_PARAM_CHANNELS);
  1310. pr_debug("%s: enter\n", __func__);
  1311. rate->min = rate->max = SAMPLING_RATE_16KHZ;
  1312. channels->min = channels->max = 1;
  1313. config = msm8996_codec_fn.get_afe_config_fn(codec,
  1314. AFE_SLIMBUS_SLAVE_PORT_CONFIG);
  1315. if (config) {
  1316. rc = afe_set_config(AFE_SLIMBUS_SLAVE_PORT_CONFIG, config,
  1317. SLIMBUS_5_TX);
  1318. if (rc) {
  1319. pr_err("%s: Failed to set slimbus slave port config %d\n",
  1320. __func__, rc);
  1321. }
  1322. }
  1323. return rc;
  1324. }
  1325. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  1326. struct snd_pcm_hw_params *params)
  1327. {
  1328. struct snd_interval *rate = hw_param_interval(params,
  1329. SNDRV_PCM_HW_PARAM_RATE);
  1330. pr_debug("%s:\n", __func__);
  1331. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  1332. return 0;
  1333. }
  1334. static const struct soc_enum msm_snd_enum[] = {
  1335. SOC_ENUM_SINGLE_EXT(2, spk_function),
  1336. SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text),
  1337. SOC_ENUM_SINGLE_EXT(8, slim0_tx_ch_text),
  1338. SOC_ENUM_SINGLE_EXT(7, hdmi_rx_ch_text),
  1339. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_bit_format_text),
  1340. rx_bit_format_text),
  1341. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim0_rx_sample_rate_text),
  1342. slim0_rx_sample_rate_text),
  1343. SOC_ENUM_SINGLE_EXT(8, proxy_rx_ch_text),
  1344. SOC_ENUM_SINGLE_EXT(3, hdmi_rx_sample_rate_text),
  1345. SOC_ENUM_SINGLE_EXT(4, slim5_rx_sample_rate_text),
  1346. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim5_rx_bit_format_text),
  1347. slim5_rx_bit_format_text),
  1348. SOC_ENUM_SINGLE_EXT(2, slim5_rx_ch_text),
  1349. SOC_ENUM_SINGLE_EXT(2, hifi_function),
  1350. SOC_ENUM_SINGLE_EXT(2, vi_feed_ch_text),
  1351. SOC_ENUM_SINGLE_EXT(4, slim6_rx_sample_rate_text),
  1352. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(slim6_rx_bit_format_text),
  1353. slim6_rx_bit_format_text),
  1354. SOC_ENUM_SINGLE_EXT(2, slim6_rx_ch_text),
  1355. };
  1356. static const struct snd_kcontrol_new msm_snd_controls[] = {
  1357. SOC_ENUM_EXT("Speaker Function", msm_snd_enum[0], msm8996_get_spk,
  1358. msm8996_set_spk),
  1359. SOC_ENUM_EXT("SLIM_0_RX Channels", msm_snd_enum[1],
  1360. msm_slim_0_rx_ch_get, msm_slim_0_rx_ch_put),
  1361. SOC_ENUM_EXT("SLIM_5_RX Channels", msm_snd_enum[10],
  1362. msm_slim_5_rx_ch_get, msm_slim_5_rx_ch_put),
  1363. SOC_ENUM_EXT("SLIM_6_RX Channels", msm_snd_enum[15],
  1364. msm_slim_6_rx_ch_get, msm_slim_6_rx_ch_put),
  1365. SOC_ENUM_EXT("SLIM_0_TX Channels", msm_snd_enum[2],
  1366. msm_slim_0_tx_ch_get, msm_slim_0_tx_ch_put),
  1367. SOC_ENUM_EXT("SLIM_1_TX Channels", msm_snd_enum[2],
  1368. msm_slim_1_tx_ch_get, msm_slim_1_tx_ch_put),
  1369. SOC_ENUM_EXT("AUX PCM SampleRate", msm8996_auxpcm_enum[0],
  1370. msm8996_auxpcm_rate_get,
  1371. msm8996_auxpcm_rate_put),
  1372. SOC_ENUM_EXT("HDMI_RX Channels", msm_snd_enum[3],
  1373. msm_hdmi_rx_ch_get, msm_hdmi_rx_ch_put),
  1374. SOC_ENUM_EXT("SLIM_0_RX Format", msm_snd_enum[4],
  1375. slim0_rx_bit_format_get, slim0_rx_bit_format_put),
  1376. SOC_ENUM_EXT("SLIM_5_RX Format", msm_snd_enum[9],
  1377. slim5_rx_bit_format_get, slim5_rx_bit_format_put),
  1378. SOC_ENUM_EXT("SLIM_6_RX Format", msm_snd_enum[14],
  1379. slim6_rx_bit_format_get, slim6_rx_bit_format_put),
  1380. SOC_ENUM_EXT("SLIM_0_RX SampleRate", msm_snd_enum[5],
  1381. slim0_rx_sample_rate_get, slim0_rx_sample_rate_put),
  1382. SOC_ENUM_EXT("SLIM_5_RX SampleRate", msm_snd_enum[8],
  1383. slim5_rx_sample_rate_get, slim5_rx_sample_rate_put),
  1384. SOC_ENUM_EXT("SLIM_6_RX SampleRate", msm_snd_enum[13],
  1385. slim6_rx_sample_rate_get, slim6_rx_sample_rate_put),
  1386. SOC_ENUM_EXT("HDMI_RX Bit Format", msm_snd_enum[4],
  1387. hdmi_rx_bit_format_get, hdmi_rx_bit_format_put),
  1388. SOC_ENUM_EXT("PROXY_RX Channels", msm_snd_enum[6],
  1389. msm_proxy_rx_ch_get, msm_proxy_rx_ch_put),
  1390. SOC_ENUM_EXT("HDMI_RX SampleRate", msm_snd_enum[7],
  1391. hdmi_rx_sample_rate_get, hdmi_rx_sample_rate_put),
  1392. SOC_ENUM_EXT("SLIM_0_TX SampleRate", msm_snd_enum[5],
  1393. slim0_tx_sample_rate_get, slim0_tx_sample_rate_put),
  1394. SOC_ENUM_EXT("SLIM_0_TX Format", msm_snd_enum[4],
  1395. slim0_tx_bit_format_get, slim0_tx_bit_format_put),
  1396. SOC_ENUM_EXT("HiFi Function", msm_snd_enum[11], msm8996_hifi_get,
  1397. msm8996_hifi_put),
  1398. SOC_ENUM_EXT("VI_FEED_TX Channels", msm_snd_enum[12],
  1399. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  1400. };
  1401. static bool msm8996_swap_gnd_mic(struct snd_soc_codec *codec)
  1402. {
  1403. struct snd_soc_card *card = codec->component.card;
  1404. struct msm8996_asoc_mach_data *pdata =
  1405. snd_soc_card_get_drvdata(card);
  1406. int value = gpio_get_value_cansleep(pdata->us_euro_gpio);
  1407. pr_debug("%s: swap select switch %d to %d\n", __func__, value, !value);
  1408. gpio_set_value_cansleep(pdata->us_euro_gpio, !value);
  1409. return true;
  1410. }
  1411. static int msm_afe_set_config(struct snd_soc_codec *codec)
  1412. {
  1413. int rc;
  1414. void *config_data = NULL;
  1415. pr_debug("%s: enter\n", __func__);
  1416. if (!msm8996_codec_fn.get_afe_config_fn) {
  1417. dev_err(codec->dev, "%s: codec get afe config not init'ed\n",
  1418. __func__);
  1419. return -EINVAL;
  1420. }
  1421. config_data = msm8996_codec_fn.get_afe_config_fn(codec,
  1422. AFE_CDC_REGISTERS_CONFIG);
  1423. if (config_data) {
  1424. rc = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
  1425. if (rc) {
  1426. pr_err("%s: Failed to set codec registers config %d\n",
  1427. __func__, rc);
  1428. return rc;
  1429. }
  1430. }
  1431. config_data = msm8996_codec_fn.get_afe_config_fn(codec,
  1432. AFE_CDC_REGISTER_PAGE_CONFIG);
  1433. if (config_data) {
  1434. rc = afe_set_config(AFE_CDC_REGISTER_PAGE_CONFIG, config_data,
  1435. 0);
  1436. if (rc)
  1437. pr_err("%s: Failed to set cdc register page config\n",
  1438. __func__);
  1439. }
  1440. config_data = msm8996_codec_fn.get_afe_config_fn(codec,
  1441. AFE_SLIMBUS_SLAVE_CONFIG);
  1442. if (config_data) {
  1443. rc = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
  1444. if (rc) {
  1445. pr_err("%s: Failed to set slimbus slave config %d\n",
  1446. __func__, rc);
  1447. return rc;
  1448. }
  1449. }
  1450. return 0;
  1451. }
  1452. static void msm_afe_clear_config(void)
  1453. {
  1454. afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
  1455. afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
  1456. }
  1457. static int msm8996_adsp_state_callback(struct notifier_block *nb,
  1458. unsigned long value, void *priv)
  1459. {
  1460. if (value == SUBSYS_BEFORE_SHUTDOWN) {
  1461. pr_debug("%s: ADSP is about to shutdown. Clearing AFE config\n",
  1462. __func__);
  1463. msm_afe_clear_config();
  1464. } else if (value == SUBSYS_AFTER_POWERUP) {
  1465. pr_debug("%s: ADSP is up\n", __func__);
  1466. }
  1467. return NOTIFY_OK;
  1468. }
  1469. static struct notifier_block adsp_state_notifier_block = {
  1470. .notifier_call = msm8996_adsp_state_callback,
  1471. .priority = -INT_MAX,
  1472. };
  1473. static int msm8996_wcd93xx_codec_up(struct snd_soc_codec *codec)
  1474. {
  1475. int err;
  1476. unsigned long timeout;
  1477. int adsp_ready = 0;
  1478. timeout = jiffies +
  1479. msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
  1480. do {
  1481. if (!q6core_is_adsp_ready()) {
  1482. pr_err_ratelimited("%s: ADSP Audio isn't ready\n",
  1483. __func__);
  1484. /*
  1485. * ADSP will be coming up after subsystem restart and
  1486. * it might not be fully up when the control reaches
  1487. * here. So, wait for 50msec before checking ADSP state
  1488. */
  1489. msleep(50);
  1490. } else {
  1491. pr_debug("%s: ADSP Audio is ready\n", __func__);
  1492. adsp_ready = 1;
  1493. break;
  1494. }
  1495. } while (time_after(timeout, jiffies));
  1496. if (!adsp_ready) {
  1497. pr_err("%s: timed out waiting for ADSP Audio\n", __func__);
  1498. return -ETIMEDOUT;
  1499. }
  1500. err = msm_afe_set_config(codec);
  1501. if (err)
  1502. pr_err("%s: Failed to set AFE config. err %d\n",
  1503. __func__, err);
  1504. return err;
  1505. }
  1506. static int msm8996_tasha_codec_event_cb(struct snd_soc_codec *codec,
  1507. enum wcd9335_codec_event codec_event)
  1508. {
  1509. switch (codec_event) {
  1510. case WCD9335_CODEC_EVENT_CODEC_UP:
  1511. return msm8996_wcd93xx_codec_up(codec);
  1512. default:
  1513. pr_err("%s: UnSupported codec event %d\n",
  1514. __func__, codec_event);
  1515. return -EINVAL;
  1516. }
  1517. }
  1518. static int msm8996_config_hph_en0_gpio(struct snd_soc_codec *codec, bool high)
  1519. {
  1520. struct snd_soc_card *card = codec->component.card;
  1521. struct msm8996_asoc_mach_data *pdata;
  1522. int val;
  1523. if (!card)
  1524. return 0;
  1525. pdata = snd_soc_card_get_drvdata(card);
  1526. if (!pdata || !gpio_is_valid(pdata->hph_en0_gpio))
  1527. return 0;
  1528. val = gpio_get_value_cansleep(pdata->hph_en0_gpio);
  1529. if ((!!val) == high)
  1530. return 0;
  1531. gpio_direction_output(pdata->hph_en0_gpio, (int)high);
  1532. return 1;
  1533. }
  1534. static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
  1535. {
  1536. int err;
  1537. void *config_data;
  1538. struct snd_soc_codec *codec = rtd->codec;
  1539. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  1540. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1541. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  1542. struct snd_soc_component *aux_comp;
  1543. void *mbhc_calibration;
  1544. struct snd_card *card;
  1545. struct snd_info_entry *entry;
  1546. struct msm8996_asoc_mach_data *pdata =
  1547. snd_soc_card_get_drvdata(rtd->card);
  1548. /* Codec SLIMBUS configuration
  1549. * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13
  1550. * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
  1551. * TX14, TX15, TX16
  1552. */
  1553. unsigned int rx_ch[TASHA_RX_MAX] = {144, 145, 146, 147, 148, 149, 150,
  1554. 151, 152, 153, 154, 155, 156};
  1555. unsigned int tx_ch[TASHA_TX_MAX] = {128, 129, 130, 131, 132, 133,
  1556. 134, 135, 136, 137, 138, 139,
  1557. 140, 141, 142, 143};
  1558. pr_info("%s: dev_name%s\n", __func__, dev_name(cpu_dai->dev));
  1559. rtd->pmdown_time = 0;
  1560. err = snd_soc_add_codec_controls(codec, msm_snd_controls,
  1561. ARRAY_SIZE(msm_snd_controls));
  1562. if (err < 0) {
  1563. pr_err("%s: add_codec_controls failed, err %d\n",
  1564. __func__, err);
  1565. return err;
  1566. }
  1567. err = msm8996_liquid_init_docking();
  1568. if (err) {
  1569. pr_err("%s: 8996 init Docking stat IRQ failed (%d)\n",
  1570. __func__, err);
  1571. return err;
  1572. }
  1573. err = msm8996_ext_us_amp_init();
  1574. if (err) {
  1575. pr_err("%s: 8996 US Emitter GPIO init failed (%d)\n",
  1576. __func__, err);
  1577. return err;
  1578. }
  1579. snd_soc_dapm_new_controls(dapm, msm8996_dapm_widgets,
  1580. ARRAY_SIZE(msm8996_dapm_widgets));
  1581. snd_soc_dapm_add_routes(dapm, wcd9335_audio_paths,
  1582. ARRAY_SIZE(wcd9335_audio_paths));
  1583. snd_soc_dapm_enable_pin(dapm, "Lineout_1 amp");
  1584. snd_soc_dapm_enable_pin(dapm, "Lineout_3 amp");
  1585. snd_soc_dapm_enable_pin(dapm, "Lineout_2 amp");
  1586. snd_soc_dapm_enable_pin(dapm, "Lineout_4 amp");
  1587. snd_soc_dapm_ignore_suspend(dapm, "Lineout_1 amp");
  1588. snd_soc_dapm_ignore_suspend(dapm, "Lineout_3 amp");
  1589. snd_soc_dapm_ignore_suspend(dapm, "Lineout_2 amp");
  1590. snd_soc_dapm_ignore_suspend(dapm, "Lineout_4 amp");
  1591. snd_soc_dapm_ignore_suspend(dapm, "ultrasound amp");
  1592. snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
  1593. snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
  1594. snd_soc_dapm_ignore_suspend(dapm, "ANCRight Headset Mic");
  1595. snd_soc_dapm_ignore_suspend(dapm, "ANCLeft Headset Mic");
  1596. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  1597. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  1598. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  1599. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  1600. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  1601. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  1602. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic6");
  1603. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic7");
  1604. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic8");
  1605. snd_soc_dapm_ignore_suspend(dapm, "MADINPUT");
  1606. snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_INPUT");
  1607. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  1608. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT1");
  1609. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT2");
  1610. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT3");
  1611. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT4");
  1612. snd_soc_dapm_ignore_suspend(dapm, "ANC EAR");
  1613. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  1614. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  1615. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  1616. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  1617. snd_soc_dapm_ignore_suspend(dapm, "AMIC5");
  1618. snd_soc_dapm_ignore_suspend(dapm, "AMIC6");
  1619. snd_soc_dapm_ignore_suspend(dapm, "DMIC1");
  1620. snd_soc_dapm_ignore_suspend(dapm, "DMIC2");
  1621. snd_soc_dapm_ignore_suspend(dapm, "DMIC3");
  1622. snd_soc_dapm_ignore_suspend(dapm, "DMIC4");
  1623. snd_soc_dapm_ignore_suspend(dapm, "DMIC5");
  1624. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  1625. snd_soc_dapm_ignore_suspend(dapm, "DMIC0");
  1626. snd_soc_dapm_ignore_suspend(dapm, "SPK1 OUT");
  1627. snd_soc_dapm_ignore_suspend(dapm, "SPK2 OUT");
  1628. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  1629. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  1630. snd_soc_dapm_ignore_suspend(dapm, "ANC HPHL");
  1631. snd_soc_dapm_ignore_suspend(dapm, "ANC HPHR");
  1632. snd_soc_dapm_ignore_suspend(dapm, "ANC LINEOUT1");
  1633. snd_soc_dapm_ignore_suspend(dapm, "ANC LINEOUT2");
  1634. snd_soc_dapm_ignore_suspend(dapm, "AIF4 VI");
  1635. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT");
  1636. snd_soc_dapm_sync(dapm);
  1637. snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  1638. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  1639. msm8996_codec_fn.get_afe_config_fn = tasha_get_afe_config;
  1640. msm8996_codec_fn.mbhc_hs_detect_exit = tasha_mbhc_hs_detect_exit;
  1641. err = msm_afe_set_config(codec);
  1642. if (err) {
  1643. pr_err("%s: Failed to set AFE config %d\n", __func__, err);
  1644. goto out;
  1645. }
  1646. config_data = msm8996_codec_fn.get_afe_config_fn(codec,
  1647. AFE_AANC_VERSION);
  1648. if (config_data) {
  1649. err = afe_set_config(AFE_AANC_VERSION, config_data, 0);
  1650. if (err) {
  1651. pr_err("%s: Failed to set aanc version %d\n",
  1652. __func__, err);
  1653. goto out;
  1654. }
  1655. }
  1656. config_data = msm8996_codec_fn.get_afe_config_fn(codec,
  1657. AFE_CDC_CLIP_REGISTERS_CONFIG);
  1658. if (config_data) {
  1659. err = afe_set_config(AFE_CDC_CLIP_REGISTERS_CONFIG,
  1660. config_data, 0);
  1661. if (err) {
  1662. pr_err("%s: Failed to set clip registers %d\n",
  1663. __func__, err);
  1664. goto out;
  1665. }
  1666. }
  1667. config_data = msm8996_codec_fn.get_afe_config_fn(codec,
  1668. AFE_CLIP_BANK_SEL);
  1669. if (config_data) {
  1670. err = afe_set_config(AFE_CLIP_BANK_SEL, config_data, 0);
  1671. if (err) {
  1672. pr_err("%s: Failed to set AFE bank selection %d\n",
  1673. __func__, err);
  1674. goto out;
  1675. }
  1676. }
  1677. /* Start mbhc */
  1678. tasha_mbhc_zdet_gpio_ctrl(msm8996_config_hph_en0_gpio, rtd->codec);
  1679. mbhc_calibration = def_tasha_mbhc_cal();
  1680. if (mbhc_calibration) {
  1681. wcd_mbhc_cfg.calibration = mbhc_calibration;
  1682. err = tasha_mbhc_hs_detect(codec, &wcd_mbhc_cfg);
  1683. if (err) {
  1684. pr_err("%s: mbhc hs detect failed, err:%d\n",
  1685. __func__, err);
  1686. goto out;
  1687. }
  1688. } else {
  1689. pr_err("%s: mbhc_cfg calibration is NULL\n", __func__);
  1690. err = -ENOMEM;
  1691. goto out;
  1692. }
  1693. adsp_state_notifier = subsys_notif_register_notifier("adsp",
  1694. &adsp_state_notifier_block);
  1695. if (!adsp_state_notifier) {
  1696. pr_err("%s: Failed to register adsp state notifier\n",
  1697. __func__);
  1698. err = -EFAULT;
  1699. msm8996_codec_fn.mbhc_hs_detect_exit(codec);
  1700. goto out;
  1701. }
  1702. tasha_event_register(msm8996_tasha_codec_event_cb, rtd->codec);
  1703. /*
  1704. * Send speaker configuration only for WSA8810.
  1705. * Defalut configuration is for WSA8815.
  1706. */
  1707. if (!list_empty(&rtd->card->aux_comp_list)) {
  1708. aux_comp = list_first_entry(&rtd->card->aux_comp_list,
  1709. struct snd_soc_component, list_aux);
  1710. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  1711. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  1712. tasha_set_spkr_mode(rtd->codec, SPKR_MODE_1);
  1713. tasha_set_spkr_gain_offset(rtd->codec,
  1714. RX_GAIN_OFFSET_M1P5_DB);
  1715. }
  1716. }
  1717. codec_reg_done = true;
  1718. card = rtd->card->snd_card;
  1719. entry = snd_info_create_subdir(card->module, "codecs",
  1720. card->proc_root);
  1721. if (!entry) {
  1722. pr_debug("%s: Cannot create codecs module entry\n",
  1723. __func__);
  1724. err = 0;
  1725. goto out;
  1726. }
  1727. pdata->codec_root = entry;
  1728. tasha_codec_info_create_codec_entry(pdata->codec_root, codec);
  1729. return 0;
  1730. out:
  1731. return err;
  1732. }
  1733. static void *def_tasha_mbhc_cal(void)
  1734. {
  1735. void *tasha_wcd_cal;
  1736. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  1737. u16 *btn_high;
  1738. tasha_wcd_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  1739. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  1740. if (!tasha_wcd_cal)
  1741. return NULL;
  1742. #define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(tasha_wcd_cal)->X) = (Y))
  1743. S(v_hs_max, 1500);
  1744. #undef S
  1745. #define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(tasha_wcd_cal)->X) = (Y))
  1746. S(num_btn, WCD_MBHC_DEF_BUTTONS);
  1747. #undef S
  1748. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(tasha_wcd_cal);
  1749. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  1750. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  1751. btn_high[0] = 75;
  1752. btn_high[1] = 150;
  1753. btn_high[2] = 237;
  1754. btn_high[3] = 500;
  1755. btn_high[4] = 500;
  1756. btn_high[5] = 500;
  1757. btn_high[6] = 500;
  1758. btn_high[7] = 500;
  1759. return tasha_wcd_cal;
  1760. }
  1761. static int msm_snd_hw_params(struct snd_pcm_substream *substream,
  1762. struct snd_pcm_hw_params *params)
  1763. {
  1764. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1765. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  1766. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1767. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  1768. int ret = 0;
  1769. u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  1770. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  1771. u32 user_set_tx_ch = 0;
  1772. u32 rx_ch_count;
  1773. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1774. ret = snd_soc_dai_get_channel_map(codec_dai,
  1775. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  1776. if (ret < 0) {
  1777. pr_err("%s: failed to get codec chan map, err:%d\n",
  1778. __func__, ret);
  1779. goto end;
  1780. }
  1781. if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_5_RX) {
  1782. pr_debug("%s: rx_5_ch=%d\n", __func__,
  1783. msm_slim_5_rx_ch);
  1784. rx_ch_count = msm_slim_5_rx_ch;
  1785. } else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_6_RX) {
  1786. pr_debug("%s: rx_6_ch=%d\n", __func__,
  1787. msm_slim_6_rx_ch);
  1788. rx_ch_count = msm_slim_6_rx_ch;
  1789. } else {
  1790. pr_debug("%s: rx_0_ch=%d\n", __func__,
  1791. msm_slim_0_rx_ch);
  1792. rx_ch_count = msm_slim_0_rx_ch;
  1793. }
  1794. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  1795. rx_ch_count, rx_ch);
  1796. if (ret < 0) {
  1797. pr_err("%s: failed to set cpu chan map, err:%d\n",
  1798. __func__, ret);
  1799. goto end;
  1800. }
  1801. } else {
  1802. pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
  1803. codec_dai->name, codec_dai->id, user_set_tx_ch);
  1804. ret = snd_soc_dai_get_channel_map(codec_dai,
  1805. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  1806. if (ret < 0) {
  1807. pr_err("%s: failed to get codec chan map\n, err:%d\n",
  1808. __func__, ret);
  1809. goto end;
  1810. }
  1811. /* For <codec>_tx1 case */
  1812. if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_0_TX)
  1813. user_set_tx_ch = msm_slim_0_tx_ch;
  1814. /* For <codec>_tx3 case */
  1815. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_1_TX)
  1816. user_set_tx_ch = msm_slim_1_tx_ch;
  1817. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_3_TX)
  1818. /* DAI 5 is used for external EC reference from codec.
  1819. * Since Rx is fed as reference for EC, the config of
  1820. * this DAI is based on that of the Rx path.
  1821. */
  1822. user_set_tx_ch = msm_slim_0_rx_ch;
  1823. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_4_TX)
  1824. user_set_tx_ch = msm_vi_feed_tx_ch;
  1825. else
  1826. user_set_tx_ch = tx_ch_cnt;
  1827. pr_debug("%s: msm_slim_0_tx_ch(%d) user_set_tx_ch(%d) tx_ch_cnt(%d), BE id (%d)\n",
  1828. __func__, msm_slim_0_tx_ch, user_set_tx_ch,
  1829. tx_ch_cnt, dai_link->id);
  1830. ret = snd_soc_dai_set_channel_map(cpu_dai,
  1831. user_set_tx_ch, tx_ch, 0, 0);
  1832. if (ret < 0) {
  1833. pr_err("%s: failed to set cpu chan map, err:%d\n",
  1834. __func__, ret);
  1835. goto end;
  1836. }
  1837. }
  1838. end:
  1839. return ret;
  1840. }
  1841. static int msm_snd_cpe_hw_params(struct snd_pcm_substream *substream,
  1842. struct snd_pcm_hw_params *params)
  1843. {
  1844. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1845. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  1846. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1847. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  1848. int ret = 0;
  1849. u32 tx_ch[SLIM_MAX_TX_PORTS];
  1850. u32 tx_ch_cnt = 0;
  1851. u32 user_set_tx_ch = 0;
  1852. if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) {
  1853. pr_err("%s: Invalid stream type %d\n",
  1854. __func__, substream->stream);
  1855. ret = -EINVAL;
  1856. goto end;
  1857. }
  1858. pr_debug("%s: %s_tx_dai_id_%d\n", __func__,
  1859. codec_dai->name, codec_dai->id);
  1860. ret = snd_soc_dai_get_channel_map(codec_dai,
  1861. &tx_ch_cnt, tx_ch, NULL, NULL);
  1862. if (ret < 0) {
  1863. pr_err("%s: failed to get codec chan map\n, err:%d\n",
  1864. __func__, ret);
  1865. goto end;
  1866. }
  1867. user_set_tx_ch = tx_ch_cnt;
  1868. pr_debug("%s: tx_ch_cnt(%d) BE id %d\n",
  1869. __func__, tx_ch_cnt, dai_link->id);
  1870. ret = snd_soc_dai_set_channel_map(cpu_dai,
  1871. user_set_tx_ch, tx_ch, 0, 0);
  1872. if (ret < 0)
  1873. pr_err("%s: failed to set cpu chan map, err:%d\n",
  1874. __func__, ret);
  1875. end:
  1876. return ret;
  1877. }
  1878. static struct snd_soc_ops msm8996_be_ops = {
  1879. .hw_params = msm_snd_hw_params,
  1880. };
  1881. static struct snd_soc_ops msm8996_cpe_ops = {
  1882. .hw_params = msm_snd_cpe_hw_params,
  1883. };
  1884. static int msm8996_slimbus_2_hw_params(struct snd_pcm_substream *substream,
  1885. struct snd_pcm_hw_params *params)
  1886. {
  1887. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1888. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  1889. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1890. int ret = 0;
  1891. unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  1892. unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
  1893. unsigned int num_tx_ch = 0;
  1894. unsigned int num_rx_ch = 0;
  1895. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1896. num_rx_ch = params_channels(params);
  1897. pr_debug("%s: %s rx_dai_id = %d num_ch = %d\n", __func__,
  1898. codec_dai->name, codec_dai->id, num_rx_ch);
  1899. ret = snd_soc_dai_get_channel_map(codec_dai,
  1900. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  1901. if (ret < 0) {
  1902. pr_err("%s: failed to get codec chan map, err:%d\n",
  1903. __func__, ret);
  1904. goto end;
  1905. }
  1906. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  1907. num_rx_ch, rx_ch);
  1908. if (ret < 0) {
  1909. pr_err("%s: failed to set cpu chan map, err:%d\n",
  1910. __func__, ret);
  1911. goto end;
  1912. }
  1913. } else {
  1914. num_tx_ch = params_channels(params);
  1915. pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__,
  1916. codec_dai->name, codec_dai->id, num_tx_ch);
  1917. ret = snd_soc_dai_get_channel_map(codec_dai,
  1918. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  1919. if (ret < 0) {
  1920. pr_err("%s: failed to get codec chan map, err:%d\n",
  1921. __func__, ret);
  1922. goto end;
  1923. }
  1924. ret = snd_soc_dai_set_channel_map(cpu_dai,
  1925. num_tx_ch, tx_ch, 0, 0);
  1926. if (ret < 0) {
  1927. pr_err("%s: failed to set cpu chan map, err:%d\n",
  1928. __func__, ret);
  1929. goto end;
  1930. }
  1931. }
  1932. end:
  1933. return ret;
  1934. }
  1935. static struct snd_soc_ops msm8996_slimbus_2_be_ops = {
  1936. .hw_params = msm8996_slimbus_2_hw_params,
  1937. };
  1938. static int msm8996_get_ll_qos_val(struct snd_pcm_runtime *runtime)
  1939. {
  1940. int usecs;
  1941. /* take 10% of period time as the deadline */
  1942. usecs = (100000 / runtime->rate) * runtime->period_size;
  1943. usecs += ((100000 % runtime->rate) * runtime->period_size) /
  1944. runtime->rate;
  1945. return usecs;
  1946. }
  1947. static int msm8996_mm5_prepare(struct snd_pcm_substream *substream)
  1948. {
  1949. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  1950. pm_qos_remove_request(&substream->latency_pm_qos_req);
  1951. pm_qos_add_request(&substream->latency_pm_qos_req,
  1952. PM_QOS_CPU_DMA_LATENCY,
  1953. msm8996_get_ll_qos_val(substream->runtime));
  1954. return 0;
  1955. }
  1956. static struct snd_soc_ops msm8996_mm5_ops = {
  1957. .prepare = msm8996_mm5_prepare,
  1958. };
  1959. /* Digital audio interface glue - connects codec <---> CPU */
  1960. static struct snd_soc_dai_link msm8996_common_dai_links[] = {
  1961. /* FrontEnd DAI Links */
  1962. {
  1963. .name = "MSM8996 Media1",
  1964. .stream_name = "MultiMedia1",
  1965. .cpu_dai_name = "MultiMedia1",
  1966. .platform_name = "msm-pcm-dsp.0",
  1967. .dynamic = 1,
  1968. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  1969. .dpcm_playback = 1,
  1970. .dpcm_capture = 1,
  1971. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1972. SND_SOC_DPCM_TRIGGER_POST},
  1973. .codec_dai_name = "snd-soc-dummy-dai",
  1974. .codec_name = "snd-soc-dummy",
  1975. .ignore_suspend = 1,
  1976. /* this dainlink has playback support */
  1977. .ignore_pmdown_time = 1,
  1978. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  1979. },
  1980. {
  1981. .name = "MSM8996 Media2",
  1982. .stream_name = "MultiMedia2",
  1983. .cpu_dai_name = "MultiMedia2",
  1984. .platform_name = "msm-pcm-dsp.0",
  1985. .dynamic = 1,
  1986. .dpcm_playback = 1,
  1987. .dpcm_capture = 1,
  1988. .codec_dai_name = "snd-soc-dummy-dai",
  1989. .codec_name = "snd-soc-dummy",
  1990. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1991. SND_SOC_DPCM_TRIGGER_POST},
  1992. .ignore_suspend = 1,
  1993. /* this dainlink has playback support */
  1994. .ignore_pmdown_time = 1,
  1995. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  1996. },
  1997. {
  1998. .name = "VoiceMMode1",
  1999. .stream_name = "VoiceMMode1",
  2000. .cpu_dai_name = "VoiceMMode1",
  2001. .platform_name = "msm-pcm-voice",
  2002. .dynamic = 1,
  2003. .dpcm_playback = 1,
  2004. .dpcm_capture = 1,
  2005. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2006. SND_SOC_DPCM_TRIGGER_POST},
  2007. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2008. .ignore_suspend = 1,
  2009. .ignore_pmdown_time = 1,
  2010. .codec_dai_name = "snd-soc-dummy-dai",
  2011. .codec_name = "snd-soc-dummy",
  2012. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  2013. },
  2014. {
  2015. .name = "MSM VoIP",
  2016. .stream_name = "VoIP",
  2017. .cpu_dai_name = "VoIP",
  2018. .platform_name = "msm-voip-dsp",
  2019. .dynamic = 1,
  2020. .dpcm_playback = 1,
  2021. .dpcm_capture = 1,
  2022. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2023. SND_SOC_DPCM_TRIGGER_POST},
  2024. .codec_dai_name = "snd-soc-dummy-dai",
  2025. .codec_name = "snd-soc-dummy",
  2026. .ignore_suspend = 1,
  2027. /* this dainlink has playback support */
  2028. .ignore_pmdown_time = 1,
  2029. .id = MSM_FRONTEND_DAI_VOIP,
  2030. },
  2031. {
  2032. .name = "MSM8996 ULL",
  2033. .stream_name = "MultiMedia3",
  2034. .cpu_dai_name = "MultiMedia3",
  2035. .platform_name = "msm-pcm-dsp.2",
  2036. .dynamic = 1,
  2037. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  2038. .dpcm_playback = 1,
  2039. .dpcm_capture = 1,
  2040. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2041. SND_SOC_DPCM_TRIGGER_POST},
  2042. .codec_dai_name = "snd-soc-dummy-dai",
  2043. .codec_name = "snd-soc-dummy",
  2044. .ignore_suspend = 1,
  2045. /* this dainlink has playback support */
  2046. .ignore_pmdown_time = 1,
  2047. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  2048. },
  2049. /* Hostless PCM purpose */
  2050. {
  2051. .name = "SLIMBUS_0 Hostless",
  2052. .stream_name = "SLIMBUS_0 Hostless",
  2053. .cpu_dai_name = "SLIMBUS0_HOSTLESS",
  2054. .platform_name = "msm-pcm-hostless",
  2055. .dynamic = 1,
  2056. .dpcm_playback = 1,
  2057. .dpcm_capture = 1,
  2058. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2059. SND_SOC_DPCM_TRIGGER_POST},
  2060. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2061. .ignore_suspend = 1,
  2062. /* this dailink has playback support */
  2063. .ignore_pmdown_time = 1,
  2064. .codec_dai_name = "snd-soc-dummy-dai",
  2065. .codec_name = "snd-soc-dummy",
  2066. },
  2067. {
  2068. .name = "Tertiary MI2S TX_Hostless",
  2069. .stream_name = "Tertiary MI2S_TX Hostless Capture",
  2070. .cpu_dai_name = "TERT_MI2S_TX_HOSTLESS",
  2071. .platform_name = "msm-pcm-hostless",
  2072. .dynamic = 1,
  2073. .dpcm_capture = 1,
  2074. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2075. SND_SOC_DPCM_TRIGGER_POST},
  2076. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2077. .ignore_suspend = 1,
  2078. .ignore_pmdown_time = 1,
  2079. .codec_dai_name = "snd-soc-dummy-dai",
  2080. .codec_name = "snd-soc-dummy",
  2081. },
  2082. {
  2083. .name = "MSM AFE-PCM RX",
  2084. .stream_name = "AFE-PROXY RX",
  2085. .cpu_dai_name = "msm-dai-q6-dev.241",
  2086. .codec_name = "msm-stub-codec.1",
  2087. .codec_dai_name = "msm-stub-rx",
  2088. .platform_name = "msm-pcm-afe",
  2089. .ignore_suspend = 1,
  2090. /* this dainlink has playback support */
  2091. .ignore_pmdown_time = 1,
  2092. },
  2093. {
  2094. .name = "MSM AFE-PCM TX",
  2095. .stream_name = "AFE-PROXY TX",
  2096. .cpu_dai_name = "msm-dai-q6-dev.240",
  2097. .codec_name = "msm-stub-codec.1",
  2098. .codec_dai_name = "msm-stub-tx",
  2099. .platform_name = "msm-pcm-afe",
  2100. .ignore_suspend = 1,
  2101. },
  2102. {
  2103. .name = "MSM8996 Compress1",
  2104. .stream_name = "Compress1",
  2105. .cpu_dai_name = "MultiMedia4",
  2106. .platform_name = "msm-compress-dsp",
  2107. .dynamic = 1,
  2108. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  2109. .dpcm_playback = 1,
  2110. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2111. SND_SOC_DPCM_TRIGGER_POST},
  2112. .codec_dai_name = "snd-soc-dummy-dai",
  2113. .codec_name = "snd-soc-dummy",
  2114. .ignore_suspend = 1,
  2115. .ignore_pmdown_time = 1,
  2116. /* this dainlink has playback support */
  2117. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  2118. },
  2119. {
  2120. .name = "AUXPCM Hostless",
  2121. .stream_name = "AUXPCM Hostless",
  2122. .cpu_dai_name = "AUXPCM_HOSTLESS",
  2123. .platform_name = "msm-pcm-hostless",
  2124. .dynamic = 1,
  2125. .dpcm_playback = 1,
  2126. .dpcm_capture = 1,
  2127. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2128. SND_SOC_DPCM_TRIGGER_POST},
  2129. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2130. .ignore_suspend = 1,
  2131. /* this dainlink has playback support */
  2132. .ignore_pmdown_time = 1,
  2133. .codec_dai_name = "snd-soc-dummy-dai",
  2134. .codec_name = "snd-soc-dummy",
  2135. },
  2136. {
  2137. .name = "SLIMBUS_1 Hostless",
  2138. .stream_name = "SLIMBUS_1 Hostless",
  2139. .cpu_dai_name = "SLIMBUS1_HOSTLESS",
  2140. .platform_name = "msm-pcm-hostless",
  2141. .dynamic = 1,
  2142. .dpcm_playback = 1,
  2143. .dpcm_capture = 1,
  2144. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2145. SND_SOC_DPCM_TRIGGER_POST},
  2146. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2147. .ignore_suspend = 1,
  2148. /* this dailink has playback support */
  2149. .ignore_pmdown_time = 1,
  2150. .codec_dai_name = "snd-soc-dummy-dai",
  2151. .codec_name = "snd-soc-dummy",
  2152. },
  2153. {
  2154. .name = "SLIMBUS_3 Hostless",
  2155. .stream_name = "SLIMBUS_3 Hostless",
  2156. .cpu_dai_name = "SLIMBUS3_HOSTLESS",
  2157. .platform_name = "msm-pcm-hostless",
  2158. .dynamic = 1,
  2159. .dpcm_playback = 1,
  2160. .dpcm_capture = 1,
  2161. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2162. SND_SOC_DPCM_TRIGGER_POST},
  2163. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2164. .ignore_suspend = 1,
  2165. /* this dailink has playback support */
  2166. .ignore_pmdown_time = 1,
  2167. .codec_dai_name = "snd-soc-dummy-dai",
  2168. .codec_name = "snd-soc-dummy",
  2169. },
  2170. {
  2171. .name = "SLIMBUS_4 Hostless",
  2172. .stream_name = "SLIMBUS_4 Hostless",
  2173. .cpu_dai_name = "SLIMBUS4_HOSTLESS",
  2174. .platform_name = "msm-pcm-hostless",
  2175. .dynamic = 1,
  2176. .dpcm_playback = 1,
  2177. .dpcm_capture = 1,
  2178. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2179. SND_SOC_DPCM_TRIGGER_POST},
  2180. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2181. .ignore_suspend = 1,
  2182. /* this dailink has playback support */
  2183. .ignore_pmdown_time = 1,
  2184. .codec_dai_name = "snd-soc-dummy-dai",
  2185. .codec_name = "snd-soc-dummy",
  2186. },
  2187. {
  2188. .name = "VoLTE",
  2189. .stream_name = "VoLTE",
  2190. .cpu_dai_name = "VoLTE",
  2191. .platform_name = "msm-pcm-voice",
  2192. .dynamic = 1,
  2193. .dpcm_playback = 1,
  2194. .dpcm_capture = 1,
  2195. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2196. SND_SOC_DPCM_TRIGGER_POST},
  2197. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2198. .ignore_suspend = 1,
  2199. /* this dainlink has playback support */
  2200. .ignore_pmdown_time = 1,
  2201. .codec_dai_name = "snd-soc-dummy-dai",
  2202. .codec_name = "snd-soc-dummy",
  2203. .id = MSM_FRONTEND_DAI_VOLTE,
  2204. },
  2205. {
  2206. .name = "MSM8996 LowLatency",
  2207. .stream_name = "MultiMedia5",
  2208. .cpu_dai_name = "MultiMedia5",
  2209. .platform_name = "msm-pcm-dsp.1",
  2210. .dynamic = 1,
  2211. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  2212. .dpcm_playback = 1,
  2213. .dpcm_capture = 1,
  2214. .codec_dai_name = "snd-soc-dummy-dai",
  2215. .codec_name = "snd-soc-dummy",
  2216. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2217. SND_SOC_DPCM_TRIGGER_POST},
  2218. .ignore_suspend = 1,
  2219. /* this dainlink has playback support */
  2220. .ignore_pmdown_time = 1,
  2221. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  2222. .ops = &msm8996_mm5_ops,
  2223. },
  2224. {
  2225. .name = "Listen 1 Audio Service",
  2226. .stream_name = "Listen 1 Audio Service",
  2227. .cpu_dai_name = "LSM1",
  2228. .platform_name = "msm-lsm-client",
  2229. .dynamic = 1,
  2230. .dpcm_capture = 1,
  2231. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2232. SND_SOC_DPCM_TRIGGER_POST },
  2233. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2234. .ignore_suspend = 1,
  2235. .ignore_pmdown_time = 1,
  2236. .codec_dai_name = "snd-soc-dummy-dai",
  2237. .codec_name = "snd-soc-dummy",
  2238. .id = MSM_FRONTEND_DAI_LSM1,
  2239. },
  2240. /* Multiple Tunnel instances */
  2241. {
  2242. .name = "MSM8996 Compress2",
  2243. .stream_name = "Compress2",
  2244. .cpu_dai_name = "MultiMedia7",
  2245. .platform_name = "msm-compress-dsp",
  2246. .dynamic = 1,
  2247. .dpcm_playback = 1,
  2248. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2249. SND_SOC_DPCM_TRIGGER_POST},
  2250. .codec_dai_name = "snd-soc-dummy-dai",
  2251. .codec_name = "snd-soc-dummy",
  2252. .ignore_suspend = 1,
  2253. .ignore_pmdown_time = 1,
  2254. /* this dainlink has playback support */
  2255. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  2256. },
  2257. {
  2258. .name = "MSM8996 Compress3",
  2259. .stream_name = "Compress3",
  2260. .cpu_dai_name = "MultiMedia10",
  2261. .platform_name = "msm-compress-dsp",
  2262. .dynamic = 1,
  2263. .dpcm_playback = 1,
  2264. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2265. SND_SOC_DPCM_TRIGGER_POST},
  2266. .codec_dai_name = "snd-soc-dummy-dai",
  2267. .codec_name = "snd-soc-dummy",
  2268. .ignore_suspend = 1,
  2269. .ignore_pmdown_time = 1,
  2270. /* this dainlink has playback support */
  2271. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  2272. },
  2273. {
  2274. .name = "MSM8996 ULL NOIRQ",
  2275. .stream_name = "MM_NOIRQ",
  2276. .cpu_dai_name = "MultiMedia8",
  2277. .platform_name = "msm-pcm-dsp-noirq",
  2278. .dynamic = 1,
  2279. .dpcm_playback = 1,
  2280. .dpcm_capture = 1,
  2281. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2282. SND_SOC_DPCM_TRIGGER_POST},
  2283. .codec_dai_name = "snd-soc-dummy-dai",
  2284. .codec_name = "snd-soc-dummy",
  2285. .ignore_suspend = 1,
  2286. .ignore_pmdown_time = 1,
  2287. /* this dainlink has playback support */
  2288. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  2289. },
  2290. {
  2291. .name = "QCHAT",
  2292. .stream_name = "QCHAT",
  2293. .cpu_dai_name = "QCHAT",
  2294. .platform_name = "msm-pcm-voice",
  2295. .dynamic = 1,
  2296. .dpcm_capture = 1,
  2297. .dpcm_playback = 1,
  2298. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2299. SND_SOC_DPCM_TRIGGER_POST},
  2300. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2301. .ignore_suspend = 1,
  2302. /* this dainlink has playback support */
  2303. .ignore_pmdown_time = 1,
  2304. .codec_dai_name = "snd-soc-dummy-dai",
  2305. .codec_name = "snd-soc-dummy",
  2306. .id = MSM_FRONTEND_DAI_QCHAT,
  2307. },
  2308. /* HDMI Hostless */
  2309. {
  2310. .name = "HDMI_RX_HOSTLESS",
  2311. .stream_name = "HDMI_RX_HOSTLESS",
  2312. .cpu_dai_name = "HDMI_HOSTLESS",
  2313. .platform_name = "msm-pcm-hostless",
  2314. .dynamic = 1,
  2315. .dpcm_playback = 1,
  2316. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2317. SND_SOC_DPCM_TRIGGER_POST},
  2318. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2319. .ignore_suspend = 1,
  2320. .ignore_pmdown_time = 1,
  2321. .codec_dai_name = "snd-soc-dummy-dai",
  2322. .codec_name = "snd-soc-dummy",
  2323. },
  2324. {
  2325. .name = "VoiceMMode2",
  2326. .stream_name = "VoiceMMode2",
  2327. .cpu_dai_name = "VoiceMMode2",
  2328. .platform_name = "msm-pcm-voice",
  2329. .dynamic = 1,
  2330. .dpcm_playback = 1,
  2331. .dpcm_capture = 1,
  2332. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2333. SND_SOC_DPCM_TRIGGER_POST},
  2334. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2335. .ignore_suspend = 1,
  2336. .ignore_pmdown_time = 1,
  2337. .codec_dai_name = "snd-soc-dummy-dai",
  2338. .codec_name = "snd-soc-dummy",
  2339. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  2340. },
  2341. {
  2342. .name = "INT_HFP_BT Hostless",
  2343. .stream_name = "INT_HFP_BT Hostless",
  2344. .cpu_dai_name = "INT_HFP_BT_HOSTLESS",
  2345. .platform_name = "msm-pcm-hostless",
  2346. .dynamic = 1,
  2347. .dpcm_playback = 1,
  2348. .dpcm_capture = 1,
  2349. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2350. SND_SOC_DPCM_TRIGGER_POST},
  2351. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2352. .ignore_suspend = 1,
  2353. /* this dainlink has playback support */
  2354. .ignore_pmdown_time = 1,
  2355. .codec_dai_name = "snd-soc-dummy-dai",
  2356. .codec_name = "snd-soc-dummy",
  2357. },
  2358. {
  2359. .name = "MSM8996 HFP TX",
  2360. .stream_name = "MultiMedia6",
  2361. .cpu_dai_name = "MultiMedia6",
  2362. .platform_name = "msm-pcm-loopback",
  2363. .dynamic = 1,
  2364. .dpcm_playback = 1,
  2365. .dpcm_capture = 1,
  2366. .codec_dai_name = "snd-soc-dummy-dai",
  2367. .codec_name = "snd-soc-dummy",
  2368. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2369. SND_SOC_DPCM_TRIGGER_POST},
  2370. .ignore_suspend = 1,
  2371. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2372. /* this dainlink has playback support */
  2373. .ignore_pmdown_time = 1,
  2374. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  2375. },
  2376. /* LSM FE */
  2377. {
  2378. .name = "Listen 2 Audio Service",
  2379. .stream_name = "Listen 2 Audio Service",
  2380. .cpu_dai_name = "LSM2",
  2381. .platform_name = "msm-lsm-client",
  2382. .dynamic = 1,
  2383. .dpcm_capture = 1,
  2384. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2385. SND_SOC_DPCM_TRIGGER_POST },
  2386. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2387. .ignore_suspend = 1,
  2388. .ignore_pmdown_time = 1,
  2389. .codec_dai_name = "snd-soc-dummy-dai",
  2390. .codec_name = "snd-soc-dummy",
  2391. .id = MSM_FRONTEND_DAI_LSM2,
  2392. },
  2393. {
  2394. .name = "Listen 3 Audio Service",
  2395. .stream_name = "Listen 3 Audio Service",
  2396. .cpu_dai_name = "LSM3",
  2397. .platform_name = "msm-lsm-client",
  2398. .dynamic = 1,
  2399. .dpcm_capture = 1,
  2400. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2401. SND_SOC_DPCM_TRIGGER_POST },
  2402. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2403. .ignore_suspend = 1,
  2404. .ignore_pmdown_time = 1,
  2405. .codec_dai_name = "snd-soc-dummy-dai",
  2406. .codec_name = "snd-soc-dummy",
  2407. .id = MSM_FRONTEND_DAI_LSM3,
  2408. },
  2409. {
  2410. .name = "Listen 4 Audio Service",
  2411. .stream_name = "Listen 4 Audio Service",
  2412. .cpu_dai_name = "LSM4",
  2413. .platform_name = "msm-lsm-client",
  2414. .dynamic = 1,
  2415. .dpcm_capture = 1,
  2416. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2417. SND_SOC_DPCM_TRIGGER_POST },
  2418. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2419. .ignore_suspend = 1,
  2420. .ignore_pmdown_time = 1,
  2421. .codec_dai_name = "snd-soc-dummy-dai",
  2422. .codec_name = "snd-soc-dummy",
  2423. .id = MSM_FRONTEND_DAI_LSM4,
  2424. },
  2425. {
  2426. .name = "Listen 5 Audio Service",
  2427. .stream_name = "Listen 5 Audio Service",
  2428. .cpu_dai_name = "LSM5",
  2429. .platform_name = "msm-lsm-client",
  2430. .dynamic = 1,
  2431. .dpcm_capture = 1,
  2432. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2433. SND_SOC_DPCM_TRIGGER_POST },
  2434. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2435. .ignore_suspend = 1,
  2436. .ignore_pmdown_time = 1,
  2437. .codec_dai_name = "snd-soc-dummy-dai",
  2438. .codec_name = "snd-soc-dummy",
  2439. .id = MSM_FRONTEND_DAI_LSM5,
  2440. },
  2441. {
  2442. .name = "Listen 6 Audio Service",
  2443. .stream_name = "Listen 6 Audio Service",
  2444. .cpu_dai_name = "LSM6",
  2445. .platform_name = "msm-lsm-client",
  2446. .dynamic = 1,
  2447. .dpcm_capture = 1,
  2448. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2449. SND_SOC_DPCM_TRIGGER_POST },
  2450. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2451. .ignore_suspend = 1,
  2452. .ignore_pmdown_time = 1,
  2453. .codec_dai_name = "snd-soc-dummy-dai",
  2454. .codec_name = "snd-soc-dummy",
  2455. .id = MSM_FRONTEND_DAI_LSM6,
  2456. },
  2457. {
  2458. .name = "Listen 7 Audio Service",
  2459. .stream_name = "Listen 7 Audio Service",
  2460. .cpu_dai_name = "LSM7",
  2461. .platform_name = "msm-lsm-client",
  2462. .dynamic = 1,
  2463. .dpcm_capture = 1,
  2464. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2465. SND_SOC_DPCM_TRIGGER_POST },
  2466. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2467. .ignore_suspend = 1,
  2468. .ignore_pmdown_time = 1,
  2469. .codec_dai_name = "snd-soc-dummy-dai",
  2470. .codec_name = "snd-soc-dummy",
  2471. .id = MSM_FRONTEND_DAI_LSM7,
  2472. },
  2473. {
  2474. .name = "Listen 8 Audio Service",
  2475. .stream_name = "Listen 8 Audio Service",
  2476. .cpu_dai_name = "LSM8",
  2477. .platform_name = "msm-lsm-client",
  2478. .dynamic = 1,
  2479. .dpcm_capture = 1,
  2480. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  2481. SND_SOC_DPCM_TRIGGER_POST },
  2482. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2483. .ignore_suspend = 1,
  2484. .ignore_pmdown_time = 1,
  2485. .codec_dai_name = "snd-soc-dummy-dai",
  2486. .codec_name = "snd-soc-dummy",
  2487. .id = MSM_FRONTEND_DAI_LSM8,
  2488. },
  2489. {
  2490. .name = "MSM8996 Media9",
  2491. .stream_name = "MultiMedia9",
  2492. .cpu_dai_name = "MultiMedia9",
  2493. .platform_name = "msm-pcm-dsp.0",
  2494. .dynamic = 1,
  2495. .dpcm_playback = 1,
  2496. .dpcm_capture = 1,
  2497. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2498. SND_SOC_DPCM_TRIGGER_POST},
  2499. .codec_dai_name = "snd-soc-dummy-dai",
  2500. .codec_name = "snd-soc-dummy",
  2501. .ignore_suspend = 1,
  2502. /* this dainlink has playback support */
  2503. .ignore_pmdown_time = 1,
  2504. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  2505. },
  2506. {
  2507. .name = "VoWLAN",
  2508. .stream_name = "VoWLAN",
  2509. .cpu_dai_name = "VoWLAN",
  2510. .platform_name = "msm-pcm-voice",
  2511. .dynamic = 1,
  2512. .dpcm_playback = 1,
  2513. .dpcm_capture = 1,
  2514. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2515. SND_SOC_DPCM_TRIGGER_POST},
  2516. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2517. .ignore_suspend = 1,
  2518. .ignore_pmdown_time = 1,
  2519. .codec_dai_name = "snd-soc-dummy-dai",
  2520. .codec_name = "snd-soc-dummy",
  2521. .id = MSM_FRONTEND_DAI_VOWLAN,
  2522. },
  2523. {
  2524. .name = "MSM8996 Compress4",
  2525. .stream_name = "Compress4",
  2526. .cpu_dai_name = "MultiMedia11",
  2527. .platform_name = "msm-compress-dsp",
  2528. .dynamic = 1,
  2529. .dpcm_playback = 1,
  2530. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2531. SND_SOC_DPCM_TRIGGER_POST},
  2532. .codec_dai_name = "snd-soc-dummy-dai",
  2533. .codec_name = "snd-soc-dummy",
  2534. .ignore_suspend = 1,
  2535. .ignore_pmdown_time = 1,
  2536. /* this dainlink has playback support */
  2537. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  2538. },
  2539. {
  2540. .name = "MSM8996 Compress5",
  2541. .stream_name = "Compress5",
  2542. .cpu_dai_name = "MultiMedia12",
  2543. .platform_name = "msm-compress-dsp",
  2544. .dynamic = 1,
  2545. .dpcm_playback = 1,
  2546. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2547. SND_SOC_DPCM_TRIGGER_POST},
  2548. .codec_dai_name = "snd-soc-dummy-dai",
  2549. .codec_name = "snd-soc-dummy",
  2550. .ignore_suspend = 1,
  2551. .ignore_pmdown_time = 1,
  2552. /* this dainlink has playback support */
  2553. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  2554. },
  2555. {
  2556. .name = "MSM8996 Compress6",
  2557. .stream_name = "Compress6",
  2558. .cpu_dai_name = "MultiMedia13",
  2559. .platform_name = "msm-compress-dsp",
  2560. .dynamic = 1,
  2561. .dpcm_playback = 1,
  2562. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2563. SND_SOC_DPCM_TRIGGER_POST},
  2564. .codec_dai_name = "snd-soc-dummy-dai",
  2565. .codec_name = "snd-soc-dummy",
  2566. .ignore_suspend = 1,
  2567. .ignore_pmdown_time = 1,
  2568. /* this dainlink has playback support */
  2569. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  2570. },
  2571. {
  2572. .name = "MSM8996 Compress7",
  2573. .stream_name = "Compress7",
  2574. .cpu_dai_name = "MultiMedia14",
  2575. .platform_name = "msm-compress-dsp",
  2576. .dynamic = 1,
  2577. .dpcm_playback = 1,
  2578. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2579. SND_SOC_DPCM_TRIGGER_POST},
  2580. .codec_dai_name = "snd-soc-dummy-dai",
  2581. .codec_name = "snd-soc-dummy",
  2582. .ignore_suspend = 1,
  2583. .ignore_pmdown_time = 1,
  2584. /* this dainlink has playback support */
  2585. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  2586. },
  2587. {
  2588. .name = "MSM8996 Compress8",
  2589. .stream_name = "Compress8",
  2590. .cpu_dai_name = "MultiMedia15",
  2591. .platform_name = "msm-compress-dsp",
  2592. .dynamic = 1,
  2593. .dpcm_playback = 1,
  2594. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2595. SND_SOC_DPCM_TRIGGER_POST},
  2596. .codec_dai_name = "snd-soc-dummy-dai",
  2597. .codec_name = "snd-soc-dummy",
  2598. .ignore_suspend = 1,
  2599. .ignore_pmdown_time = 1,
  2600. /* this dainlink has playback support */
  2601. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  2602. },
  2603. {
  2604. .name = "MSM8996 ULL NOIRQ_2",
  2605. .stream_name = "MM_NOIRQ_2",
  2606. .cpu_dai_name = "MultiMedia16",
  2607. .platform_name = "msm-pcm-dsp-noirq",
  2608. .dynamic = 1,
  2609. .dpcm_playback = 1,
  2610. .dpcm_capture = 1,
  2611. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2612. SND_SOC_DPCM_TRIGGER_POST},
  2613. .codec_dai_name = "snd-soc-dummy-dai",
  2614. .codec_name = "snd-soc-dummy",
  2615. .ignore_suspend = 1,
  2616. .ignore_pmdown_time = 1,
  2617. /* this dainlink has playback support */
  2618. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  2619. },
  2620. {
  2621. .name = "Circuit-Switch Voice",
  2622. .stream_name = "CS-Voice",
  2623. .cpu_dai_name = "CS-VOICE",
  2624. .platform_name = "msm-pcm-voice",
  2625. .dynamic = 1,
  2626. .dpcm_playback = 1,
  2627. .dpcm_capture = 1,
  2628. .codec_dai_name = "snd-soc-dummy-dai",
  2629. .codec_name = "snd-soc-dummy",
  2630. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2631. SND_SOC_DPCM_TRIGGER_POST},
  2632. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2633. .ignore_suspend = 1,
  2634. /* this dainlink has playback support */
  2635. .ignore_pmdown_time = 1,
  2636. .id = MSM_FRONTEND_DAI_CS_VOICE,
  2637. },
  2638. {
  2639. .name = "Voice2",
  2640. .stream_name = "Voice2",
  2641. .cpu_dai_name = "Voice2",
  2642. .platform_name = "msm-pcm-voice",
  2643. .dynamic = 1,
  2644. .dpcm_playback = 1,
  2645. .dpcm_capture = 1,
  2646. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2647. SND_SOC_DPCM_TRIGGER_POST},
  2648. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2649. .ignore_suspend = 1,
  2650. /* this dainlink has playback support */
  2651. .ignore_pmdown_time = 1,
  2652. .codec_dai_name = "snd-soc-dummy-dai",
  2653. .codec_name = "snd-soc-dummy",
  2654. .id = MSM_FRONTEND_DAI_VOICE2,
  2655. },
  2656. };
  2657. static struct snd_soc_dai_link msm8996_tasha_fe_dai_links[] = {
  2658. {
  2659. .name = LPASS_BE_SLIMBUS_4_TX,
  2660. .stream_name = "Slimbus4 Capture",
  2661. .cpu_dai_name = "msm-dai-q6-dev.16393",
  2662. .platform_name = "msm-pcm-hostless",
  2663. .codec_name = "tasha_codec",
  2664. .codec_dai_name = "tasha_vifeedback",
  2665. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  2666. .be_hw_params_fixup = msm_slim_4_tx_be_hw_params_fixup,
  2667. .ops = &msm8996_be_ops,
  2668. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2669. .ignore_suspend = 1,
  2670. },
  2671. /* Ultrasound RX DAI Link */
  2672. {
  2673. .name = "SLIMBUS_2 Hostless Playback",
  2674. .stream_name = "SLIMBUS_2 Hostless Playback",
  2675. .cpu_dai_name = "msm-dai-q6-dev.16388",
  2676. .platform_name = "msm-pcm-hostless",
  2677. .codec_name = "tasha_codec",
  2678. .codec_dai_name = "tasha_rx2",
  2679. .ignore_suspend = 1,
  2680. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2681. .ops = &msm8996_slimbus_2_be_ops,
  2682. },
  2683. /* Ultrasound TX DAI Link */
  2684. {
  2685. .name = "SLIMBUS_2 Hostless Capture",
  2686. .stream_name = "SLIMBUS_2 Hostless Capture",
  2687. .cpu_dai_name = "msm-dai-q6-dev.16389",
  2688. .platform_name = "msm-pcm-hostless",
  2689. .codec_name = "tasha_codec",
  2690. .codec_dai_name = "tasha_tx2",
  2691. .ignore_suspend = 1,
  2692. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2693. .ops = &msm8996_slimbus_2_be_ops,
  2694. },
  2695. /* CPE LSM direct dai-link */
  2696. {
  2697. .name = "CPE Listen service",
  2698. .stream_name = "CPE Listen Audio Service",
  2699. .cpu_dai_name = "msm-dai-slim",
  2700. .platform_name = "msm-cpe-lsm",
  2701. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2702. SND_SOC_DPCM_TRIGGER_POST},
  2703. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2704. .ignore_suspend = 1,
  2705. .ignore_pmdown_time = 1,
  2706. .codec_dai_name = "tasha_mad1",
  2707. .codec_name = "tasha_codec",
  2708. .ops = &msm8996_cpe_ops,
  2709. },
  2710. /* slimbus rx 6 hostless */
  2711. {
  2712. .name = "SLIMBUS_6 Hostless Playback",
  2713. .stream_name = "SLIMBUS_6 Hostless",
  2714. .cpu_dai_name = "SLIMBUS6_HOSTLESS",
  2715. .platform_name = "msm-pcm-hostless",
  2716. .dynamic = 1,
  2717. .dpcm_playback = 1,
  2718. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2719. SND_SOC_DPCM_TRIGGER_POST},
  2720. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2721. .ignore_suspend = 1,
  2722. /* this dailink has playback support */
  2723. .ignore_pmdown_time = 1,
  2724. .codec_dai_name = "snd-soc-dummy-dai",
  2725. .codec_name = "snd-soc-dummy",
  2726. },
  2727. /* CPE LSM EC PP direct dai-link */
  2728. {
  2729. .name = "CPE Listen service ECPP",
  2730. .stream_name = "CPE Listen Audio Service ECPP",
  2731. .cpu_dai_name = "CPE_LSM_NOHOST",
  2732. .platform_name = "msm-cpe-lsm.3",
  2733. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2734. SND_SOC_DPCM_TRIGGER_POST},
  2735. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2736. .ignore_suspend = 1,
  2737. .ignore_pmdown_time = 1,
  2738. .codec_dai_name = "tasha_cpe",
  2739. .codec_name = "tasha_codec",
  2740. },
  2741. };
  2742. static struct snd_soc_dai_link msm8996_common_be_dai_links[] = {
  2743. /* Backend AFE DAI Links */
  2744. {
  2745. .name = LPASS_BE_AFE_PCM_RX,
  2746. .stream_name = "AFE Playback",
  2747. .cpu_dai_name = "msm-dai-q6-dev.224",
  2748. .platform_name = "msm-pcm-routing",
  2749. .codec_name = "msm-stub-codec.1",
  2750. .codec_dai_name = "msm-stub-rx",
  2751. .no_pcm = 1,
  2752. .dpcm_playback = 1,
  2753. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  2754. .be_hw_params_fixup = msm_proxy_rx_be_hw_params_fixup,
  2755. /* this dainlink has playback support */
  2756. .ignore_pmdown_time = 1,
  2757. .ignore_suspend = 1,
  2758. },
  2759. {
  2760. .name = LPASS_BE_AFE_PCM_TX,
  2761. .stream_name = "AFE Capture",
  2762. .cpu_dai_name = "msm-dai-q6-dev.225",
  2763. .platform_name = "msm-pcm-routing",
  2764. .codec_name = "msm-stub-codec.1",
  2765. .codec_dai_name = "msm-stub-tx",
  2766. .no_pcm = 1,
  2767. .dpcm_capture = 1,
  2768. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  2769. .be_hw_params_fixup = msm_proxy_tx_be_hw_params_fixup,
  2770. .ignore_suspend = 1,
  2771. },
  2772. /* Primary AUX PCM Backend DAI Links */
  2773. {
  2774. .name = LPASS_BE_AUXPCM_RX,
  2775. .stream_name = "AUX PCM Playback",
  2776. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  2777. .platform_name = "msm-pcm-routing",
  2778. .codec_name = "msm-stub-codec.1",
  2779. .codec_dai_name = "msm-stub-rx",
  2780. .no_pcm = 1,
  2781. .dpcm_playback = 1,
  2782. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  2783. .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
  2784. .ignore_pmdown_time = 1,
  2785. .ignore_suspend = 1,
  2786. /* this dainlink has playback support */
  2787. },
  2788. {
  2789. .name = LPASS_BE_AUXPCM_TX,
  2790. .stream_name = "AUX PCM Capture",
  2791. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  2792. .platform_name = "msm-pcm-routing",
  2793. .codec_name = "msm-stub-codec.1",
  2794. .codec_dai_name = "msm-stub-tx",
  2795. .no_pcm = 1,
  2796. .dpcm_capture = 1,
  2797. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  2798. .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
  2799. .ignore_suspend = 1,
  2800. },
  2801. /* Incall Record Uplink BACK END DAI Link */
  2802. {
  2803. .name = LPASS_BE_INCALL_RECORD_TX,
  2804. .stream_name = "Voice Uplink Capture",
  2805. .cpu_dai_name = "msm-dai-q6-dev.32772",
  2806. .platform_name = "msm-pcm-routing",
  2807. .codec_name = "msm-stub-codec.1",
  2808. .codec_dai_name = "msm-stub-tx",
  2809. .no_pcm = 1,
  2810. .dpcm_capture = 1,
  2811. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  2812. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2813. .ignore_suspend = 1,
  2814. },
  2815. /* Incall Record Downlink BACK END DAI Link */
  2816. {
  2817. .name = LPASS_BE_INCALL_RECORD_RX,
  2818. .stream_name = "Voice Downlink Capture",
  2819. .cpu_dai_name = "msm-dai-q6-dev.32771",
  2820. .platform_name = "msm-pcm-routing",
  2821. .codec_name = "msm-stub-codec.1",
  2822. .codec_dai_name = "msm-stub-tx",
  2823. .no_pcm = 1,
  2824. .dpcm_capture = 1,
  2825. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  2826. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2827. .ignore_suspend = 1,
  2828. },
  2829. /* Incall Music BACK END DAI Link */
  2830. {
  2831. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  2832. .stream_name = "Voice Farend Playback",
  2833. .cpu_dai_name = "msm-dai-q6-dev.32773",
  2834. .platform_name = "msm-pcm-routing",
  2835. .codec_name = "msm-stub-codec.1",
  2836. .codec_dai_name = "msm-stub-rx",
  2837. .no_pcm = 1,
  2838. .dpcm_playback = 1,
  2839. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  2840. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2841. .ignore_suspend = 1,
  2842. },
  2843. /* Incall Music 2 BACK END DAI Link */
  2844. {
  2845. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  2846. .stream_name = "Voice2 Farend Playback",
  2847. .cpu_dai_name = "msm-dai-q6-dev.32770",
  2848. .platform_name = "msm-pcm-routing",
  2849. .codec_name = "msm-stub-codec.1",
  2850. .codec_dai_name = "msm-stub-rx",
  2851. .no_pcm = 1,
  2852. .dpcm_playback = 1,
  2853. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  2854. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2855. .ignore_suspend = 1,
  2856. },
  2857. {
  2858. .name = LPASS_BE_TERT_MI2S_TX,
  2859. .stream_name = "Tertiary MI2S Capture",
  2860. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  2861. .platform_name = "msm-pcm-routing",
  2862. .codec_name = "msm-stub-codec.1",
  2863. .codec_dai_name = "msm-stub-tx",
  2864. .no_pcm = 1,
  2865. .dpcm_capture = 1,
  2866. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  2867. .be_hw_params_fixup = msm_tx_be_hw_params_fixup,
  2868. .ops = &msm8996_mi2s_be_ops,
  2869. .ignore_suspend = 1,
  2870. }
  2871. };
  2872. static struct snd_soc_dai_link msm8996_tasha_be_dai_links[] = {
  2873. /* Backend DAI Links */
  2874. {
  2875. .name = LPASS_BE_SLIMBUS_0_RX,
  2876. .stream_name = "Slimbus Playback",
  2877. .cpu_dai_name = "msm-dai-q6-dev.16384",
  2878. .platform_name = "msm-pcm-routing",
  2879. .codec_name = "tasha_codec",
  2880. .codec_dai_name = "tasha_mix_rx1",
  2881. .no_pcm = 1,
  2882. .dpcm_playback = 1,
  2883. .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  2884. .init = &msm_audrx_init,
  2885. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2886. /* this dainlink has playback support */
  2887. .ignore_pmdown_time = 1,
  2888. .ignore_suspend = 1,
  2889. .ops = &msm8996_be_ops,
  2890. },
  2891. {
  2892. .name = LPASS_BE_SLIMBUS_0_TX,
  2893. .stream_name = "Slimbus Capture",
  2894. .cpu_dai_name = "msm-dai-q6-dev.16385",
  2895. .platform_name = "msm-pcm-routing",
  2896. .codec_name = "tasha_codec",
  2897. .codec_dai_name = "tasha_tx1",
  2898. .no_pcm = 1,
  2899. .dpcm_capture = 1,
  2900. .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  2901. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2902. .ignore_suspend = 1,
  2903. .ops = &msm8996_be_ops,
  2904. },
  2905. {
  2906. .name = LPASS_BE_SLIMBUS_1_RX,
  2907. .stream_name = "Slimbus1 Playback",
  2908. .cpu_dai_name = "msm-dai-q6-dev.16386",
  2909. .platform_name = "msm-pcm-routing",
  2910. .codec_name = "tasha_codec",
  2911. .codec_dai_name = "tasha_mix_rx1",
  2912. .no_pcm = 1,
  2913. .dpcm_playback = 1,
  2914. .id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  2915. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2916. .ops = &msm8996_be_ops,
  2917. /* dai link has playback support */
  2918. .ignore_pmdown_time = 1,
  2919. .ignore_suspend = 1,
  2920. },
  2921. {
  2922. .name = LPASS_BE_SLIMBUS_1_TX,
  2923. .stream_name = "Slimbus1 Capture",
  2924. .cpu_dai_name = "msm-dai-q6-dev.16387",
  2925. .platform_name = "msm-pcm-routing",
  2926. .codec_name = "tasha_codec",
  2927. .codec_dai_name = "tasha_tx3",
  2928. .no_pcm = 1,
  2929. .dpcm_capture = 1,
  2930. .id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  2931. .be_hw_params_fixup = msm_slim_1_tx_be_hw_params_fixup,
  2932. .ops = &msm8996_be_ops,
  2933. .ignore_suspend = 1,
  2934. },
  2935. {
  2936. .name = LPASS_BE_SLIMBUS_3_RX,
  2937. .stream_name = "Slimbus3 Playback",
  2938. .cpu_dai_name = "msm-dai-q6-dev.16390",
  2939. .platform_name = "msm-pcm-routing",
  2940. .codec_name = "tasha_codec",
  2941. .codec_dai_name = "tasha_mix_rx1",
  2942. .no_pcm = 1,
  2943. .dpcm_playback = 1,
  2944. .id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  2945. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2946. .ops = &msm8996_be_ops,
  2947. /* dai link has playback support */
  2948. .ignore_pmdown_time = 1,
  2949. .ignore_suspend = 1,
  2950. },
  2951. {
  2952. .name = LPASS_BE_SLIMBUS_3_TX,
  2953. .stream_name = "Slimbus3 Capture",
  2954. .cpu_dai_name = "msm-dai-q6-dev.16391",
  2955. .platform_name = "msm-pcm-routing",
  2956. .codec_name = "tasha_codec",
  2957. .codec_dai_name = "tasha_tx1",
  2958. .no_pcm = 1,
  2959. .dpcm_capture = 1,
  2960. .id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  2961. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2962. .ops = &msm8996_be_ops,
  2963. .ignore_suspend = 1,
  2964. },
  2965. {
  2966. .name = LPASS_BE_SLIMBUS_4_RX,
  2967. .stream_name = "Slimbus4 Playback",
  2968. .cpu_dai_name = "msm-dai-q6-dev.16392",
  2969. .platform_name = "msm-pcm-routing",
  2970. .codec_name = "tasha_codec",
  2971. .codec_dai_name = "tasha_mix_rx1",
  2972. .no_pcm = 1,
  2973. .dpcm_playback = 1,
  2974. .id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  2975. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2976. .ops = &msm8996_be_ops,
  2977. /* dai link has playback support */
  2978. .ignore_pmdown_time = 1,
  2979. .ignore_suspend = 1,
  2980. },
  2981. {
  2982. .name = LPASS_BE_SLIMBUS_5_RX,
  2983. .stream_name = "Slimbus5 Playback",
  2984. .cpu_dai_name = "msm-dai-q6-dev.16394",
  2985. .platform_name = "msm-pcm-routing",
  2986. .codec_name = "tasha_codec",
  2987. .codec_dai_name = "tasha_rx3",
  2988. .no_pcm = 1,
  2989. .dpcm_playback = 1,
  2990. .id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
  2991. .be_hw_params_fixup = msm_slim_5_rx_be_hw_params_fixup,
  2992. .ops = &msm8996_be_ops,
  2993. /* dai link has playback support */
  2994. .ignore_pmdown_time = 1,
  2995. .ignore_suspend = 1,
  2996. },
  2997. /* MAD BE */
  2998. {
  2999. .name = LPASS_BE_SLIMBUS_5_TX,
  3000. .stream_name = "Slimbus5 Capture",
  3001. .cpu_dai_name = "msm-dai-q6-dev.16395",
  3002. .platform_name = "msm-pcm-routing",
  3003. .codec_name = "tasha_codec",
  3004. .codec_dai_name = "tasha_mad1",
  3005. .no_pcm = 1,
  3006. .dpcm_capture = 1,
  3007. .id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
  3008. .be_hw_params_fixup = msm_slim_5_tx_be_hw_params_fixup,
  3009. .ops = &msm8996_be_ops,
  3010. .ignore_suspend = 1,
  3011. },
  3012. {
  3013. .name = LPASS_BE_SLIMBUS_6_RX,
  3014. .stream_name = "Slimbus6 Playback",
  3015. .cpu_dai_name = "msm-dai-q6-dev.16396",
  3016. .platform_name = "msm-pcm-routing",
  3017. .codec_name = "tasha_codec",
  3018. .codec_dai_name = "tasha_rx4",
  3019. .no_pcm = 1,
  3020. .dpcm_playback = 1,
  3021. .id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
  3022. .be_hw_params_fixup = msm_slim_6_rx_be_hw_params_fixup,
  3023. .ops = &msm8996_be_ops,
  3024. /* dai link has playback support */
  3025. .ignore_pmdown_time = 1,
  3026. .ignore_suspend = 1,
  3027. },
  3028. };
  3029. static struct snd_soc_dai_link msm8996_hdmi_dai_link[] = {
  3030. /* HDMI BACK END DAI Link */
  3031. {
  3032. .name = LPASS_BE_HDMI,
  3033. .stream_name = "HDMI Playback",
  3034. .cpu_dai_name = "msm-dai-q6-hdmi.8",
  3035. .platform_name = "msm-pcm-routing",
  3036. .codec_name = "msm-hdmi-audio-codec-rx",
  3037. .codec_dai_name = "msm_hdmi_audio_codec_rx_dai",
  3038. .no_pcm = 1,
  3039. .dpcm_playback = 1,
  3040. .id = MSM_BACKEND_DAI_HDMI_RX,
  3041. .be_hw_params_fixup = msm8996_hdmi_be_hw_params_fixup,
  3042. .ignore_pmdown_time = 1,
  3043. .ignore_suspend = 1,
  3044. },
  3045. };
  3046. static struct snd_soc_dai_link msm8996_tasha_dai_links[
  3047. ARRAY_SIZE(msm8996_common_dai_links) +
  3048. ARRAY_SIZE(msm8996_tasha_fe_dai_links) +
  3049. ARRAY_SIZE(msm8996_common_be_dai_links) +
  3050. ARRAY_SIZE(msm8996_tasha_be_dai_links) +
  3051. ARRAY_SIZE(msm8996_hdmi_dai_link)];
  3052. static int msm8996_wsa881x_init(struct snd_soc_component *component)
  3053. {
  3054. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {100, 101, 102, 106};
  3055. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {103, 104, 105, 107};
  3056. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  3057. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  3058. struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
  3059. struct msm8996_asoc_mach_data *pdata;
  3060. struct snd_soc_dapm_context *dapm;
  3061. if (!codec) {
  3062. pr_err("%s codec is NULL\n", __func__);
  3063. return -EINVAL;
  3064. }
  3065. dapm = snd_soc_codec_get_dapm(codec);
  3066. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  3067. dev_dbg(codec->dev, "%s: setting left ch map to codec %s\n",
  3068. __func__, codec->component.name);
  3069. wsa881x_set_channel_map(codec, &spkleft_ports[0],
  3070. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  3071. &ch_rate[0]);
  3072. if (dapm->component) {
  3073. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  3074. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  3075. }
  3076. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  3077. dev_dbg(codec->dev, "%s: setting right ch map to codec %s\n",
  3078. __func__, codec->component.name);
  3079. wsa881x_set_channel_map(codec, &spkright_ports[0],
  3080. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  3081. &ch_rate[0]);
  3082. if (dapm->component) {
  3083. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  3084. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  3085. }
  3086. } else {
  3087. dev_err(codec->dev, "%s: wrong codec name %s\n", __func__,
  3088. codec->component.name);
  3089. return -EINVAL;
  3090. }
  3091. pdata = snd_soc_card_get_drvdata(component->card);
  3092. if (pdata && pdata->codec_root)
  3093. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  3094. codec);
  3095. return 0;
  3096. }
  3097. struct snd_soc_card snd_soc_card_tasha_msm8996 = {
  3098. .name = "msm8996-tasha-snd-card",
  3099. };
  3100. static int msm8996_populate_dai_link_component_of_node(
  3101. struct snd_soc_card *card)
  3102. {
  3103. int i, index, ret = 0;
  3104. struct device *cdev = card->dev;
  3105. struct snd_soc_dai_link *dai_link = card->dai_link;
  3106. struct device_node *np;
  3107. if (!cdev) {
  3108. pr_err("%s: Sound card device memory NULL\n", __func__);
  3109. return -ENODEV;
  3110. }
  3111. for (i = 0; i < card->num_links; i++) {
  3112. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  3113. continue;
  3114. /* populate platform_of_node for snd card dai links */
  3115. if (dai_link[i].platform_name &&
  3116. !dai_link[i].platform_of_node) {
  3117. index = of_property_match_string(cdev->of_node,
  3118. "asoc-platform-names",
  3119. dai_link[i].platform_name);
  3120. if (index < 0) {
  3121. pr_err("%s: No match found for platform name: %s\n",
  3122. __func__, dai_link[i].platform_name);
  3123. ret = index;
  3124. goto err;
  3125. }
  3126. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  3127. index);
  3128. if (!np) {
  3129. pr_err("%s: retrieving phandle for platform %s, index %d failed\n",
  3130. __func__, dai_link[i].platform_name,
  3131. index);
  3132. ret = -ENODEV;
  3133. goto err;
  3134. }
  3135. dai_link[i].platform_of_node = np;
  3136. dai_link[i].platform_name = NULL;
  3137. }
  3138. /* populate cpu_of_node for snd card dai links */
  3139. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  3140. index = of_property_match_string(cdev->of_node,
  3141. "asoc-cpu-names",
  3142. dai_link[i].cpu_dai_name);
  3143. if (index >= 0) {
  3144. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  3145. index);
  3146. if (!np) {
  3147. pr_err("%s: retrieving phandle for cpu dai %s failed\n",
  3148. __func__,
  3149. dai_link[i].cpu_dai_name);
  3150. ret = -ENODEV;
  3151. goto err;
  3152. }
  3153. dai_link[i].cpu_of_node = np;
  3154. dai_link[i].cpu_dai_name = NULL;
  3155. }
  3156. }
  3157. /* populate codec_of_node for snd card dai links */
  3158. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  3159. index = of_property_match_string(cdev->of_node,
  3160. "asoc-codec-names",
  3161. dai_link[i].codec_name);
  3162. if (index < 0)
  3163. continue;
  3164. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  3165. index);
  3166. if (!np) {
  3167. pr_err("%s: retrieving phandle for codec %s failed\n",
  3168. __func__, dai_link[i].codec_name);
  3169. ret = -ENODEV;
  3170. goto err;
  3171. }
  3172. dai_link[i].codec_of_node = np;
  3173. dai_link[i].codec_name = NULL;
  3174. }
  3175. }
  3176. err:
  3177. return ret;
  3178. }
  3179. static int msm8996_prepare_us_euro(struct snd_soc_card *card)
  3180. {
  3181. struct msm8996_asoc_mach_data *pdata =
  3182. snd_soc_card_get_drvdata(card);
  3183. int ret;
  3184. if (pdata->us_euro_gpio >= 0) {
  3185. dev_dbg(card->dev, "%s: us_euro gpio request %d", __func__,
  3186. pdata->us_euro_gpio);
  3187. ret = gpio_request(pdata->us_euro_gpio, "TASHA_CODEC_US_EURO");
  3188. if (ret) {
  3189. dev_err(card->dev,
  3190. "%s: Failed to request codec US/EURO gpio %d error %d\n",
  3191. __func__, pdata->us_euro_gpio, ret);
  3192. return ret;
  3193. }
  3194. }
  3195. return 0;
  3196. }
  3197. static int msm8996_prepare_hifi(struct snd_soc_card *card)
  3198. {
  3199. struct msm8996_asoc_mach_data *pdata =
  3200. snd_soc_card_get_drvdata(card);
  3201. int ret;
  3202. if (gpio_is_valid(pdata->hph_en1_gpio)) {
  3203. dev_dbg(card->dev, "%s: hph_en1_gpio request %d\n", __func__,
  3204. pdata->hph_en1_gpio);
  3205. ret = gpio_request(pdata->hph_en1_gpio, "hph_en1_gpio");
  3206. if (ret) {
  3207. dev_err(card->dev,
  3208. "%s: hph_en1_gpio request failed, ret:%d\n",
  3209. __func__, ret);
  3210. return ret;
  3211. }
  3212. }
  3213. if (gpio_is_valid(pdata->hph_en0_gpio)) {
  3214. dev_dbg(card->dev, "%s: hph_en0_gpio request %d\n", __func__,
  3215. pdata->hph_en0_gpio);
  3216. ret = gpio_request(pdata->hph_en0_gpio, "hph_en0_gpio");
  3217. if (ret) {
  3218. dev_err(card->dev,
  3219. "%s: hph_en0_gpio request failed, ret:%d\n",
  3220. __func__, ret);
  3221. return ret;
  3222. }
  3223. }
  3224. return 0;
  3225. }
  3226. static const struct of_device_id msm8996_asoc_machine_of_match[] = {
  3227. { .compatible = "qcom,msm8996-asoc-snd-tasha",
  3228. .data = "tasha_codec"},
  3229. {},
  3230. };
  3231. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  3232. {
  3233. struct snd_soc_card *card = NULL;
  3234. struct snd_soc_dai_link *dailink;
  3235. int len_1, len_2, len_3, len_4;
  3236. const struct of_device_id *match;
  3237. match = of_match_node(msm8996_asoc_machine_of_match, dev->of_node);
  3238. if (!match) {
  3239. dev_err(dev, "%s: No DT match found for sound card\n",
  3240. __func__);
  3241. return NULL;
  3242. }
  3243. if (!strcmp(match->data, "tasha_codec")) {
  3244. card = &snd_soc_card_tasha_msm8996;
  3245. len_1 = ARRAY_SIZE(msm8996_common_dai_links);
  3246. len_2 = len_1 + ARRAY_SIZE(msm8996_tasha_fe_dai_links);
  3247. len_3 = len_2 + ARRAY_SIZE(msm8996_common_be_dai_links);
  3248. memcpy(msm8996_tasha_dai_links,
  3249. msm8996_common_dai_links,
  3250. sizeof(msm8996_common_dai_links));
  3251. memcpy(msm8996_tasha_dai_links + len_1,
  3252. msm8996_tasha_fe_dai_links,
  3253. sizeof(msm8996_tasha_fe_dai_links));
  3254. memcpy(msm8996_tasha_dai_links + len_2,
  3255. msm8996_common_be_dai_links,
  3256. sizeof(msm8996_common_be_dai_links));
  3257. memcpy(msm8996_tasha_dai_links + len_3,
  3258. msm8996_tasha_be_dai_links,
  3259. sizeof(msm8996_tasha_be_dai_links));
  3260. dailink = msm8996_tasha_dai_links;
  3261. len_4 = len_3 + ARRAY_SIZE(msm8996_tasha_be_dai_links);
  3262. }
  3263. if (of_property_read_bool(dev->of_node, "qcom,hdmi-audio-rx")) {
  3264. dev_dbg(dev, "%s(): hdmi audio support present\n",
  3265. __func__);
  3266. memcpy(dailink + len_4, msm8996_hdmi_dai_link,
  3267. sizeof(msm8996_hdmi_dai_link));
  3268. len_4 += ARRAY_SIZE(msm8996_hdmi_dai_link);
  3269. } else {
  3270. dev_dbg(dev, "%s(): No hdmi audio support\n", __func__);
  3271. }
  3272. if (card) {
  3273. card->dai_link = dailink;
  3274. card->num_links = len_4;
  3275. }
  3276. return card;
  3277. }
  3278. static int msm8996_init_wsa_dev(struct platform_device *pdev,
  3279. struct snd_soc_card *card)
  3280. {
  3281. struct device_node *wsa_of_node;
  3282. u32 wsa_max_devs;
  3283. u32 wsa_dev_cnt;
  3284. char *dev_name_str = NULL;
  3285. struct msm8996_wsa881x_dev_info *wsa881x_dev_info;
  3286. const char *wsa_auxdev_name_prefix[1];
  3287. int found = 0;
  3288. int i;
  3289. int ret;
  3290. /* Get maximum WSA device count for this platform */
  3291. ret = of_property_read_u32(pdev->dev.of_node,
  3292. "qcom,wsa-max-devs", &wsa_max_devs);
  3293. if (ret) {
  3294. dev_dbg(&pdev->dev,
  3295. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  3296. __func__, pdev->dev.of_node->full_name, ret);
  3297. return 0;
  3298. }
  3299. if (wsa_max_devs == 0) {
  3300. dev_warn(&pdev->dev,
  3301. "%s: Max WSA devices is 0 for this target?\n",
  3302. __func__);
  3303. return 0;
  3304. }
  3305. /* Get count of WSA device phandles for this platform */
  3306. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  3307. "qcom,wsa-devs", NULL);
  3308. if (wsa_dev_cnt == -ENOENT) {
  3309. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  3310. __func__);
  3311. return 0;
  3312. } else if (wsa_dev_cnt <= 0) {
  3313. dev_err(&pdev->dev,
  3314. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  3315. __func__, wsa_dev_cnt);
  3316. return -EINVAL;
  3317. }
  3318. /*
  3319. * Expect total phandles count to be NOT less than maximum possible
  3320. * WSA count. However, if it is less, then assign same value to
  3321. * max count as well.
  3322. */
  3323. if (wsa_dev_cnt < wsa_max_devs) {
  3324. dev_dbg(&pdev->dev,
  3325. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  3326. __func__, wsa_max_devs, wsa_dev_cnt);
  3327. wsa_max_devs = wsa_dev_cnt;
  3328. }
  3329. /* Make sure prefix string passed for each WSA device */
  3330. ret = of_property_count_strings(pdev->dev.of_node,
  3331. "qcom,wsa-aux-dev-prefix");
  3332. if (ret != wsa_dev_cnt) {
  3333. dev_err(&pdev->dev,
  3334. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  3335. __func__, wsa_dev_cnt, ret);
  3336. return -EINVAL;
  3337. }
  3338. /*
  3339. * Alloc mem to store phandle and index info of WSA device, if already
  3340. * registered with ALSA core
  3341. */
  3342. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  3343. sizeof(struct msm8996_wsa881x_dev_info),
  3344. GFP_KERNEL);
  3345. if (!wsa881x_dev_info)
  3346. return -ENOMEM;
  3347. /*
  3348. * search and check whether all WSA devices are already
  3349. * registered with ALSA core or not. If found a node, store
  3350. * the node and the index in a local array of struct for later
  3351. * use.
  3352. */
  3353. for (i = 0; i < wsa_dev_cnt; i++) {
  3354. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  3355. "qcom,wsa-devs", i);
  3356. if (unlikely(!wsa_of_node)) {
  3357. /* we should not be here */
  3358. dev_err(&pdev->dev,
  3359. "%s: wsa dev node is not present\n",
  3360. __func__);
  3361. return -EINVAL;
  3362. }
  3363. if (soc_find_component(wsa_of_node, NULL)) {
  3364. /* WSA device registered with ALSA core */
  3365. wsa881x_dev_info[found].of_node = wsa_of_node;
  3366. wsa881x_dev_info[found].index = i;
  3367. found++;
  3368. if (found == wsa_max_devs)
  3369. break;
  3370. }
  3371. }
  3372. if (found < wsa_max_devs) {
  3373. dev_dbg(&pdev->dev,
  3374. "%s: failed to find %d components. Found only %d\n",
  3375. __func__, wsa_max_devs, found);
  3376. return -EPROBE_DEFER;
  3377. }
  3378. dev_info(&pdev->dev,
  3379. "%s: found %d wsa881x devices registered with ALSA core\n",
  3380. __func__, found);
  3381. card->num_aux_devs = wsa_max_devs;
  3382. card->num_configs = wsa_max_devs;
  3383. /* Alloc array of AUX devs struct */
  3384. msm8996_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  3385. sizeof(struct snd_soc_aux_dev),
  3386. GFP_KERNEL);
  3387. if (!msm8996_aux_dev)
  3388. return -ENOMEM;
  3389. /* Alloc array of codec conf struct */
  3390. msm8996_codec_conf = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  3391. sizeof(struct snd_soc_codec_conf),
  3392. GFP_KERNEL);
  3393. if (!msm8996_codec_conf)
  3394. return -ENOMEM;
  3395. for (i = 0; i < card->num_aux_devs; i++) {
  3396. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  3397. GFP_KERNEL);
  3398. if (!dev_name_str)
  3399. return -ENOMEM;
  3400. ret = of_property_read_string_index(pdev->dev.of_node,
  3401. "qcom,wsa-aux-dev-prefix",
  3402. wsa881x_dev_info[i].index,
  3403. wsa_auxdev_name_prefix);
  3404. if (ret) {
  3405. dev_err(&pdev->dev,
  3406. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  3407. __func__, ret);
  3408. return -EINVAL;
  3409. }
  3410. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  3411. msm8996_aux_dev[i].name = dev_name_str;
  3412. msm8996_aux_dev[i].codec_name = NULL;
  3413. msm8996_aux_dev[i].codec_of_node =
  3414. wsa881x_dev_info[i].of_node;
  3415. msm8996_aux_dev[i].init = msm8996_wsa881x_init;
  3416. msm8996_codec_conf[i].dev_name = NULL;
  3417. msm8996_codec_conf[i].name_prefix = wsa_auxdev_name_prefix[0];
  3418. msm8996_codec_conf[i].of_node =
  3419. wsa881x_dev_info[i].of_node;
  3420. }
  3421. card->codec_conf = msm8996_codec_conf;
  3422. card->aux_dev = msm8996_aux_dev;
  3423. return 0;
  3424. }
  3425. static int msm8996_asoc_machine_probe(struct platform_device *pdev)
  3426. {
  3427. struct snd_soc_card *card;
  3428. struct msm8996_asoc_mach_data *pdata;
  3429. const char *mbhc_audio_jack_type = NULL;
  3430. char *mclk_freq_prop_name;
  3431. const struct of_device_id *match;
  3432. int ret;
  3433. if (!pdev->dev.of_node) {
  3434. dev_err(&pdev->dev, "No platform supplied from device tree\n");
  3435. return -EINVAL;
  3436. }
  3437. pdata = devm_kzalloc(&pdev->dev,
  3438. sizeof(struct msm8996_asoc_mach_data), GFP_KERNEL);
  3439. if (!pdata)
  3440. return -ENOMEM;
  3441. card = populate_snd_card_dailinks(&pdev->dev);
  3442. if (!card) {
  3443. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  3444. ret = -EINVAL;
  3445. goto err;
  3446. }
  3447. card->dev = &pdev->dev;
  3448. platform_set_drvdata(pdev, card);
  3449. snd_soc_card_set_drvdata(card, pdata);
  3450. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  3451. if (ret) {
  3452. dev_err(&pdev->dev, "parse card name failed, err:%d\n",
  3453. ret);
  3454. goto err;
  3455. }
  3456. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  3457. if (ret) {
  3458. dev_err(&pdev->dev, "parse audio routing failed, err:%d\n",
  3459. ret);
  3460. goto err;
  3461. }
  3462. match = of_match_node(msm8996_asoc_machine_of_match,
  3463. pdev->dev.of_node);
  3464. if (!match) {
  3465. dev_err(&pdev->dev, "%s: no matched codec is found.\n",
  3466. __func__);
  3467. goto err;
  3468. }
  3469. mclk_freq_prop_name = "qcom,tasha-mclk-clk-freq";
  3470. ret = of_property_read_u32(pdev->dev.of_node,
  3471. mclk_freq_prop_name, &pdata->mclk_freq);
  3472. if (ret) {
  3473. dev_err(&pdev->dev,
  3474. "Looking up %s property in node %s failed, err%d\n",
  3475. mclk_freq_prop_name,
  3476. pdev->dev.of_node->full_name, ret);
  3477. goto err;
  3478. }
  3479. if (pdata->mclk_freq != CODEC_EXT_CLK_RATE) {
  3480. dev_err(&pdev->dev, "unsupported mclk freq %u\n",
  3481. pdata->mclk_freq);
  3482. ret = -EINVAL;
  3483. goto err;
  3484. }
  3485. spdev = pdev;
  3486. ret = msm8996_populate_dai_link_component_of_node(card);
  3487. if (ret) {
  3488. ret = -EPROBE_DEFER;
  3489. goto err;
  3490. }
  3491. ret = msm8996_init_wsa_dev(pdev, card);
  3492. if (ret)
  3493. goto err;
  3494. pdata->hph_en1_gpio = of_get_named_gpio(pdev->dev.of_node,
  3495. "qcom,hph-en1-gpio", 0);
  3496. if (pdata->hph_en1_gpio < 0) {
  3497. dev_dbg(&pdev->dev, "%s: %s property not found %d\n",
  3498. __func__, "qcom,hph-en1-gpio", pdata->hph_en1_gpio);
  3499. }
  3500. pdata->hph_en0_gpio = of_get_named_gpio(pdev->dev.of_node,
  3501. "qcom,hph-en0-gpio", 0);
  3502. if (pdata->hph_en0_gpio < 0) {
  3503. dev_dbg(&pdev->dev, "%s: %s property not found %d\n",
  3504. __func__, "qcom,hph-en0-gpio", pdata->hph_en0_gpio);
  3505. }
  3506. ret = msm8996_prepare_hifi(card);
  3507. if (ret)
  3508. dev_dbg(&pdev->dev, "msm8996_prepare_hifi failed (%d)\n",
  3509. ret);
  3510. ret = snd_soc_register_card(card);
  3511. if (ret == -EPROBE_DEFER) {
  3512. if (codec_reg_done)
  3513. ret = -EINVAL;
  3514. goto err;
  3515. } else if (ret) {
  3516. dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
  3517. ret);
  3518. goto err;
  3519. }
  3520. dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
  3521. ret = of_property_read_string(pdev->dev.of_node,
  3522. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  3523. if (ret) {
  3524. dev_dbg(&pdev->dev, "Looking up %s property in node %s failed",
  3525. "qcom,mbhc-audio-jack-type",
  3526. pdev->dev.of_node->full_name);
  3527. dev_dbg(&pdev->dev, "Jack type properties set to default");
  3528. } else {
  3529. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack"))
  3530. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  3531. else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack"))
  3532. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  3533. else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack"))
  3534. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  3535. else
  3536. dev_dbg(&pdev->dev, "Unknown value, set to default");
  3537. }
  3538. /*
  3539. * Parse US-Euro gpio info from DT. Report no error if us-euro
  3540. * entry is not found in DT file as some targets do not support
  3541. * US-Euro detection
  3542. */
  3543. pdata->us_euro_gpio = of_get_named_gpio(pdev->dev.of_node,
  3544. "qcom,us-euro-gpios", 0);
  3545. if (pdata->us_euro_gpio < 0) {
  3546. dev_info(&pdev->dev, "property %s not detected in node %s",
  3547. "qcom,us-euro-gpios",
  3548. pdev->dev.of_node->full_name);
  3549. } else {
  3550. dev_dbg(&pdev->dev, "%s detected %d",
  3551. "qcom,us-euro-gpios", pdata->us_euro_gpio);
  3552. wcd_mbhc_cfg.swap_gnd_mic = msm8996_swap_gnd_mic;
  3553. }
  3554. ret = msm8996_prepare_us_euro(card);
  3555. if (ret)
  3556. dev_info(&pdev->dev, "msm8996_prepare_us_euro failed (%d)\n",
  3557. ret);
  3558. return 0;
  3559. err:
  3560. if (pdata->us_euro_gpio > 0) {
  3561. dev_dbg(&pdev->dev, "%s free us_euro gpio %d\n",
  3562. __func__, pdata->us_euro_gpio);
  3563. gpio_free(pdata->us_euro_gpio);
  3564. pdata->us_euro_gpio = 0;
  3565. }
  3566. if (pdata->hph_en1_gpio > 0) {
  3567. dev_dbg(&pdev->dev, "%s free hph_en1_gpio %d\n",
  3568. __func__, pdata->hph_en1_gpio);
  3569. gpio_free(pdata->hph_en1_gpio);
  3570. pdata->hph_en1_gpio = 0;
  3571. }
  3572. if (pdata->hph_en0_gpio > 0) {
  3573. dev_dbg(&pdev->dev, "%s free hph_en0_gpio %d\n",
  3574. __func__, pdata->hph_en0_gpio);
  3575. gpio_free(pdata->hph_en0_gpio);
  3576. pdata->hph_en0_gpio = 0;
  3577. }
  3578. devm_kfree(&pdev->dev, pdata);
  3579. return ret;
  3580. }
  3581. static int msm8996_asoc_machine_remove(struct platform_device *pdev)
  3582. {
  3583. struct snd_soc_card *card = platform_get_drvdata(pdev);
  3584. struct msm8996_asoc_mach_data *pdata =
  3585. snd_soc_card_get_drvdata(card);
  3586. if (gpio_is_valid(ext_us_amp_gpio))
  3587. gpio_free(ext_us_amp_gpio);
  3588. gpio_free(pdata->us_euro_gpio);
  3589. gpio_free(pdata->hph_en1_gpio);
  3590. gpio_free(pdata->hph_en0_gpio);
  3591. if (msm8996_liquid_dock_dev != NULL) {
  3592. switch_dev_unregister(&msm8996_liquid_dock_dev->audio_sdev);
  3593. if (msm8996_liquid_dock_dev->dock_plug_irq)
  3594. free_irq(msm8996_liquid_dock_dev->dock_plug_irq,
  3595. msm8996_liquid_dock_dev);
  3596. if (msm8996_liquid_dock_dev->dock_plug_gpio)
  3597. gpio_free(msm8996_liquid_dock_dev->dock_plug_gpio);
  3598. kfree(msm8996_liquid_dock_dev);
  3599. msm8996_liquid_dock_dev = NULL;
  3600. }
  3601. snd_soc_unregister_card(card);
  3602. return 0;
  3603. }
  3604. static struct platform_driver msm8996_asoc_machine_driver = {
  3605. .driver = {
  3606. .name = DRV_NAME,
  3607. .owner = THIS_MODULE,
  3608. .pm = &snd_soc_pm_ops,
  3609. .of_match_table = msm8996_asoc_machine_of_match,
  3610. },
  3611. .probe = msm8996_asoc_machine_probe,
  3612. .remove = msm8996_asoc_machine_remove,
  3613. };
  3614. module_platform_driver(msm8996_asoc_machine_driver);
  3615. MODULE_DESCRIPTION("ALSA SoC msm");
  3616. MODULE_LICENSE("GPL v2");
  3617. MODULE_ALIAS("platform:" DRV_NAME);
  3618. MODULE_DEVICE_TABLE(of, msm8996_asoc_machine_of_match);