msm8996.c 110 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006
  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 Compress9",
  2605. .stream_name = "Compress9",
  2606. .cpu_dai_name = "MultiMedia16",
  2607. .platform_name = "msm-compress-dsp",
  2608. .dynamic = 1,
  2609. .dpcm_playback = 1,
  2610. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2611. SND_SOC_DPCM_TRIGGER_POST},
  2612. .codec_dai_name = "snd-soc-dummy-dai",
  2613. .codec_name = "snd-soc-dummy",
  2614. .ignore_suspend = 1,
  2615. .ignore_pmdown_time = 1,
  2616. /* this dainlink has playback support */
  2617. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  2618. },
  2619. {
  2620. .name = "Circuit-Switch Voice",
  2621. .stream_name = "CS-Voice",
  2622. .cpu_dai_name = "CS-VOICE",
  2623. .platform_name = "msm-pcm-voice",
  2624. .dynamic = 1,
  2625. .dpcm_playback = 1,
  2626. .dpcm_capture = 1,
  2627. .codec_dai_name = "snd-soc-dummy-dai",
  2628. .codec_name = "snd-soc-dummy",
  2629. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2630. SND_SOC_DPCM_TRIGGER_POST},
  2631. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2632. .ignore_suspend = 1,
  2633. /* this dainlink has playback support */
  2634. .ignore_pmdown_time = 1,
  2635. .id = MSM_FRONTEND_DAI_CS_VOICE,
  2636. },
  2637. {
  2638. .name = "Voice2",
  2639. .stream_name = "Voice2",
  2640. .cpu_dai_name = "Voice2",
  2641. .platform_name = "msm-pcm-voice",
  2642. .dynamic = 1,
  2643. .dpcm_playback = 1,
  2644. .dpcm_capture = 1,
  2645. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2646. SND_SOC_DPCM_TRIGGER_POST},
  2647. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2648. .ignore_suspend = 1,
  2649. /* this dainlink has playback support */
  2650. .ignore_pmdown_time = 1,
  2651. .codec_dai_name = "snd-soc-dummy-dai",
  2652. .codec_name = "snd-soc-dummy",
  2653. .id = MSM_FRONTEND_DAI_VOICE2,
  2654. },
  2655. };
  2656. static struct snd_soc_dai_link msm8996_tasha_fe_dai_links[] = {
  2657. {
  2658. .name = LPASS_BE_SLIMBUS_4_TX,
  2659. .stream_name = "Slimbus4 Capture",
  2660. .cpu_dai_name = "msm-dai-q6-dev.16393",
  2661. .platform_name = "msm-pcm-hostless",
  2662. .codec_name = "tasha_codec",
  2663. .codec_dai_name = "tasha_vifeedback",
  2664. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  2665. .be_hw_params_fixup = msm_slim_4_tx_be_hw_params_fixup,
  2666. .ops = &msm8996_be_ops,
  2667. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2668. .ignore_suspend = 1,
  2669. },
  2670. /* Ultrasound RX DAI Link */
  2671. {
  2672. .name = "SLIMBUS_2 Hostless Playback",
  2673. .stream_name = "SLIMBUS_2 Hostless Playback",
  2674. .cpu_dai_name = "msm-dai-q6-dev.16388",
  2675. .platform_name = "msm-pcm-hostless",
  2676. .codec_name = "tasha_codec",
  2677. .codec_dai_name = "tasha_rx2",
  2678. .ignore_suspend = 1,
  2679. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2680. .ops = &msm8996_slimbus_2_be_ops,
  2681. },
  2682. /* Ultrasound TX DAI Link */
  2683. {
  2684. .name = "SLIMBUS_2 Hostless Capture",
  2685. .stream_name = "SLIMBUS_2 Hostless Capture",
  2686. .cpu_dai_name = "msm-dai-q6-dev.16389",
  2687. .platform_name = "msm-pcm-hostless",
  2688. .codec_name = "tasha_codec",
  2689. .codec_dai_name = "tasha_tx2",
  2690. .ignore_suspend = 1,
  2691. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2692. .ops = &msm8996_slimbus_2_be_ops,
  2693. },
  2694. /* CPE LSM direct dai-link */
  2695. {
  2696. .name = "CPE Listen service",
  2697. .stream_name = "CPE Listen Audio Service",
  2698. .cpu_dai_name = "msm-dai-slim",
  2699. .platform_name = "msm-cpe-lsm",
  2700. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2701. SND_SOC_DPCM_TRIGGER_POST},
  2702. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2703. .ignore_suspend = 1,
  2704. .ignore_pmdown_time = 1,
  2705. .codec_dai_name = "tasha_mad1",
  2706. .codec_name = "tasha_codec",
  2707. .ops = &msm8996_cpe_ops,
  2708. },
  2709. /* slimbus rx 6 hostless */
  2710. {
  2711. .name = "SLIMBUS_6 Hostless Playback",
  2712. .stream_name = "SLIMBUS_6 Hostless",
  2713. .cpu_dai_name = "SLIMBUS6_HOSTLESS",
  2714. .platform_name = "msm-pcm-hostless",
  2715. .dynamic = 1,
  2716. .dpcm_playback = 1,
  2717. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2718. SND_SOC_DPCM_TRIGGER_POST},
  2719. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2720. .ignore_suspend = 1,
  2721. /* this dailink has playback support */
  2722. .ignore_pmdown_time = 1,
  2723. .codec_dai_name = "snd-soc-dummy-dai",
  2724. .codec_name = "snd-soc-dummy",
  2725. },
  2726. /* CPE LSM EC PP direct dai-link */
  2727. {
  2728. .name = "CPE Listen service ECPP",
  2729. .stream_name = "CPE Listen Audio Service ECPP",
  2730. .cpu_dai_name = "CPE_LSM_NOHOST",
  2731. .platform_name = "msm-cpe-lsm.3",
  2732. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2733. SND_SOC_DPCM_TRIGGER_POST},
  2734. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2735. .ignore_suspend = 1,
  2736. .ignore_pmdown_time = 1,
  2737. .codec_dai_name = "tasha_cpe",
  2738. .codec_name = "tasha_codec",
  2739. },
  2740. };
  2741. static struct snd_soc_dai_link msm8996_common_be_dai_links[] = {
  2742. /* Backend AFE DAI Links */
  2743. {
  2744. .name = LPASS_BE_AFE_PCM_RX,
  2745. .stream_name = "AFE Playback",
  2746. .cpu_dai_name = "msm-dai-q6-dev.224",
  2747. .platform_name = "msm-pcm-routing",
  2748. .codec_name = "msm-stub-codec.1",
  2749. .codec_dai_name = "msm-stub-rx",
  2750. .no_pcm = 1,
  2751. .dpcm_playback = 1,
  2752. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  2753. .be_hw_params_fixup = msm_proxy_rx_be_hw_params_fixup,
  2754. /* this dainlink has playback support */
  2755. .ignore_pmdown_time = 1,
  2756. .ignore_suspend = 1,
  2757. },
  2758. {
  2759. .name = LPASS_BE_AFE_PCM_TX,
  2760. .stream_name = "AFE Capture",
  2761. .cpu_dai_name = "msm-dai-q6-dev.225",
  2762. .platform_name = "msm-pcm-routing",
  2763. .codec_name = "msm-stub-codec.1",
  2764. .codec_dai_name = "msm-stub-tx",
  2765. .no_pcm = 1,
  2766. .dpcm_capture = 1,
  2767. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  2768. .be_hw_params_fixup = msm_proxy_tx_be_hw_params_fixup,
  2769. .ignore_suspend = 1,
  2770. },
  2771. /* Primary AUX PCM Backend DAI Links */
  2772. {
  2773. .name = LPASS_BE_AUXPCM_RX,
  2774. .stream_name = "AUX PCM Playback",
  2775. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  2776. .platform_name = "msm-pcm-routing",
  2777. .codec_name = "msm-stub-codec.1",
  2778. .codec_dai_name = "msm-stub-rx",
  2779. .no_pcm = 1,
  2780. .dpcm_playback = 1,
  2781. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  2782. .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
  2783. .ignore_pmdown_time = 1,
  2784. .ignore_suspend = 1,
  2785. /* this dainlink has playback support */
  2786. },
  2787. {
  2788. .name = LPASS_BE_AUXPCM_TX,
  2789. .stream_name = "AUX PCM Capture",
  2790. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  2791. .platform_name = "msm-pcm-routing",
  2792. .codec_name = "msm-stub-codec.1",
  2793. .codec_dai_name = "msm-stub-tx",
  2794. .no_pcm = 1,
  2795. .dpcm_capture = 1,
  2796. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  2797. .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
  2798. .ignore_suspend = 1,
  2799. },
  2800. /* Incall Record Uplink BACK END DAI Link */
  2801. {
  2802. .name = LPASS_BE_INCALL_RECORD_TX,
  2803. .stream_name = "Voice Uplink Capture",
  2804. .cpu_dai_name = "msm-dai-q6-dev.32772",
  2805. .platform_name = "msm-pcm-routing",
  2806. .codec_name = "msm-stub-codec.1",
  2807. .codec_dai_name = "msm-stub-tx",
  2808. .no_pcm = 1,
  2809. .dpcm_capture = 1,
  2810. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  2811. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2812. .ignore_suspend = 1,
  2813. },
  2814. /* Incall Record Downlink BACK END DAI Link */
  2815. {
  2816. .name = LPASS_BE_INCALL_RECORD_RX,
  2817. .stream_name = "Voice Downlink Capture",
  2818. .cpu_dai_name = "msm-dai-q6-dev.32771",
  2819. .platform_name = "msm-pcm-routing",
  2820. .codec_name = "msm-stub-codec.1",
  2821. .codec_dai_name = "msm-stub-tx",
  2822. .no_pcm = 1,
  2823. .dpcm_capture = 1,
  2824. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  2825. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2826. .ignore_suspend = 1,
  2827. },
  2828. /* Incall Music BACK END DAI Link */
  2829. {
  2830. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  2831. .stream_name = "Voice Farend Playback",
  2832. .cpu_dai_name = "msm-dai-q6-dev.32773",
  2833. .platform_name = "msm-pcm-routing",
  2834. .codec_name = "msm-stub-codec.1",
  2835. .codec_dai_name = "msm-stub-rx",
  2836. .no_pcm = 1,
  2837. .dpcm_playback = 1,
  2838. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  2839. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2840. .ignore_suspend = 1,
  2841. },
  2842. /* Incall Music 2 BACK END DAI Link */
  2843. {
  2844. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  2845. .stream_name = "Voice2 Farend Playback",
  2846. .cpu_dai_name = "msm-dai-q6-dev.32770",
  2847. .platform_name = "msm-pcm-routing",
  2848. .codec_name = "msm-stub-codec.1",
  2849. .codec_dai_name = "msm-stub-rx",
  2850. .no_pcm = 1,
  2851. .dpcm_playback = 1,
  2852. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  2853. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2854. .ignore_suspend = 1,
  2855. },
  2856. {
  2857. .name = LPASS_BE_TERT_MI2S_TX,
  2858. .stream_name = "Tertiary MI2S Capture",
  2859. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  2860. .platform_name = "msm-pcm-routing",
  2861. .codec_name = "msm-stub-codec.1",
  2862. .codec_dai_name = "msm-stub-tx",
  2863. .no_pcm = 1,
  2864. .dpcm_capture = 1,
  2865. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  2866. .be_hw_params_fixup = msm_tx_be_hw_params_fixup,
  2867. .ops = &msm8996_mi2s_be_ops,
  2868. .ignore_suspend = 1,
  2869. }
  2870. };
  2871. static struct snd_soc_dai_link msm8996_tasha_be_dai_links[] = {
  2872. /* Backend DAI Links */
  2873. {
  2874. .name = LPASS_BE_SLIMBUS_0_RX,
  2875. .stream_name = "Slimbus Playback",
  2876. .cpu_dai_name = "msm-dai-q6-dev.16384",
  2877. .platform_name = "msm-pcm-routing",
  2878. .codec_name = "tasha_codec",
  2879. .codec_dai_name = "tasha_mix_rx1",
  2880. .no_pcm = 1,
  2881. .dpcm_playback = 1,
  2882. .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  2883. .init = &msm_audrx_init,
  2884. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2885. /* this dainlink has playback support */
  2886. .ignore_pmdown_time = 1,
  2887. .ignore_suspend = 1,
  2888. .ops = &msm8996_be_ops,
  2889. },
  2890. {
  2891. .name = LPASS_BE_SLIMBUS_0_TX,
  2892. .stream_name = "Slimbus Capture",
  2893. .cpu_dai_name = "msm-dai-q6-dev.16385",
  2894. .platform_name = "msm-pcm-routing",
  2895. .codec_name = "tasha_codec",
  2896. .codec_dai_name = "tasha_tx1",
  2897. .no_pcm = 1,
  2898. .dpcm_capture = 1,
  2899. .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  2900. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2901. .ignore_suspend = 1,
  2902. .ops = &msm8996_be_ops,
  2903. },
  2904. {
  2905. .name = LPASS_BE_SLIMBUS_1_RX,
  2906. .stream_name = "Slimbus1 Playback",
  2907. .cpu_dai_name = "msm-dai-q6-dev.16386",
  2908. .platform_name = "msm-pcm-routing",
  2909. .codec_name = "tasha_codec",
  2910. .codec_dai_name = "tasha_mix_rx1",
  2911. .no_pcm = 1,
  2912. .dpcm_playback = 1,
  2913. .id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  2914. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2915. .ops = &msm8996_be_ops,
  2916. /* dai link has playback support */
  2917. .ignore_pmdown_time = 1,
  2918. .ignore_suspend = 1,
  2919. },
  2920. {
  2921. .name = LPASS_BE_SLIMBUS_1_TX,
  2922. .stream_name = "Slimbus1 Capture",
  2923. .cpu_dai_name = "msm-dai-q6-dev.16387",
  2924. .platform_name = "msm-pcm-routing",
  2925. .codec_name = "tasha_codec",
  2926. .codec_dai_name = "tasha_tx3",
  2927. .no_pcm = 1,
  2928. .dpcm_capture = 1,
  2929. .id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  2930. .be_hw_params_fixup = msm_slim_1_tx_be_hw_params_fixup,
  2931. .ops = &msm8996_be_ops,
  2932. .ignore_suspend = 1,
  2933. },
  2934. {
  2935. .name = LPASS_BE_SLIMBUS_3_RX,
  2936. .stream_name = "Slimbus3 Playback",
  2937. .cpu_dai_name = "msm-dai-q6-dev.16390",
  2938. .platform_name = "msm-pcm-routing",
  2939. .codec_name = "tasha_codec",
  2940. .codec_dai_name = "tasha_mix_rx1",
  2941. .no_pcm = 1,
  2942. .dpcm_playback = 1,
  2943. .id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  2944. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2945. .ops = &msm8996_be_ops,
  2946. /* dai link has playback support */
  2947. .ignore_pmdown_time = 1,
  2948. .ignore_suspend = 1,
  2949. },
  2950. {
  2951. .name = LPASS_BE_SLIMBUS_3_TX,
  2952. .stream_name = "Slimbus3 Capture",
  2953. .cpu_dai_name = "msm-dai-q6-dev.16391",
  2954. .platform_name = "msm-pcm-routing",
  2955. .codec_name = "tasha_codec",
  2956. .codec_dai_name = "tasha_tx1",
  2957. .no_pcm = 1,
  2958. .dpcm_capture = 1,
  2959. .id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  2960. .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
  2961. .ops = &msm8996_be_ops,
  2962. .ignore_suspend = 1,
  2963. },
  2964. {
  2965. .name = LPASS_BE_SLIMBUS_4_RX,
  2966. .stream_name = "Slimbus4 Playback",
  2967. .cpu_dai_name = "msm-dai-q6-dev.16392",
  2968. .platform_name = "msm-pcm-routing",
  2969. .codec_name = "tasha_codec",
  2970. .codec_dai_name = "tasha_mix_rx1",
  2971. .no_pcm = 1,
  2972. .dpcm_playback = 1,
  2973. .id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  2974. .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
  2975. .ops = &msm8996_be_ops,
  2976. /* dai link has playback support */
  2977. .ignore_pmdown_time = 1,
  2978. .ignore_suspend = 1,
  2979. },
  2980. {
  2981. .name = LPASS_BE_SLIMBUS_5_RX,
  2982. .stream_name = "Slimbus5 Playback",
  2983. .cpu_dai_name = "msm-dai-q6-dev.16394",
  2984. .platform_name = "msm-pcm-routing",
  2985. .codec_name = "tasha_codec",
  2986. .codec_dai_name = "tasha_rx3",
  2987. .no_pcm = 1,
  2988. .dpcm_playback = 1,
  2989. .id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
  2990. .be_hw_params_fixup = msm_slim_5_rx_be_hw_params_fixup,
  2991. .ops = &msm8996_be_ops,
  2992. /* dai link has playback support */
  2993. .ignore_pmdown_time = 1,
  2994. .ignore_suspend = 1,
  2995. },
  2996. /* MAD BE */
  2997. {
  2998. .name = LPASS_BE_SLIMBUS_5_TX,
  2999. .stream_name = "Slimbus5 Capture",
  3000. .cpu_dai_name = "msm-dai-q6-dev.16395",
  3001. .platform_name = "msm-pcm-routing",
  3002. .codec_name = "tasha_codec",
  3003. .codec_dai_name = "tasha_mad1",
  3004. .no_pcm = 1,
  3005. .dpcm_capture = 1,
  3006. .id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
  3007. .be_hw_params_fixup = msm_slim_5_tx_be_hw_params_fixup,
  3008. .ops = &msm8996_be_ops,
  3009. .ignore_suspend = 1,
  3010. },
  3011. {
  3012. .name = LPASS_BE_SLIMBUS_6_RX,
  3013. .stream_name = "Slimbus6 Playback",
  3014. .cpu_dai_name = "msm-dai-q6-dev.16396",
  3015. .platform_name = "msm-pcm-routing",
  3016. .codec_name = "tasha_codec",
  3017. .codec_dai_name = "tasha_rx4",
  3018. .no_pcm = 1,
  3019. .dpcm_playback = 1,
  3020. .id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
  3021. .be_hw_params_fixup = msm_slim_6_rx_be_hw_params_fixup,
  3022. .ops = &msm8996_be_ops,
  3023. /* dai link has playback support */
  3024. .ignore_pmdown_time = 1,
  3025. .ignore_suspend = 1,
  3026. },
  3027. };
  3028. static struct snd_soc_dai_link msm8996_hdmi_dai_link[] = {
  3029. /* HDMI BACK END DAI Link */
  3030. {
  3031. .name = LPASS_BE_HDMI,
  3032. .stream_name = "HDMI Playback",
  3033. .cpu_dai_name = "msm-dai-q6-hdmi.8",
  3034. .platform_name = "msm-pcm-routing",
  3035. .codec_name = "msm-hdmi-audio-codec-rx",
  3036. .codec_dai_name = "msm_hdmi_audio_codec_rx_dai",
  3037. .no_pcm = 1,
  3038. .dpcm_playback = 1,
  3039. .id = MSM_BACKEND_DAI_HDMI_RX,
  3040. .be_hw_params_fixup = msm8996_hdmi_be_hw_params_fixup,
  3041. .ignore_pmdown_time = 1,
  3042. .ignore_suspend = 1,
  3043. },
  3044. };
  3045. static struct snd_soc_dai_link msm8996_tasha_dai_links[
  3046. ARRAY_SIZE(msm8996_common_dai_links) +
  3047. ARRAY_SIZE(msm8996_tasha_fe_dai_links) +
  3048. ARRAY_SIZE(msm8996_common_be_dai_links) +
  3049. ARRAY_SIZE(msm8996_tasha_be_dai_links) +
  3050. ARRAY_SIZE(msm8996_hdmi_dai_link)];
  3051. static int msm8996_wsa881x_init(struct snd_soc_component *component)
  3052. {
  3053. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {100, 101, 102, 106};
  3054. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {103, 104, 105, 107};
  3055. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  3056. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  3057. struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
  3058. struct msm8996_asoc_mach_data *pdata;
  3059. struct snd_soc_dapm_context *dapm;
  3060. if (!codec) {
  3061. pr_err("%s codec is NULL\n", __func__);
  3062. return -EINVAL;
  3063. }
  3064. dapm = snd_soc_codec_get_dapm(codec);
  3065. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  3066. dev_dbg(codec->dev, "%s: setting left ch map to codec %s\n",
  3067. __func__, codec->component.name);
  3068. wsa881x_set_channel_map(codec, &spkleft_ports[0],
  3069. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  3070. &ch_rate[0]);
  3071. if (dapm->component) {
  3072. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  3073. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  3074. }
  3075. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  3076. dev_dbg(codec->dev, "%s: setting right ch map to codec %s\n",
  3077. __func__, codec->component.name);
  3078. wsa881x_set_channel_map(codec, &spkright_ports[0],
  3079. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  3080. &ch_rate[0]);
  3081. if (dapm->component) {
  3082. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  3083. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  3084. }
  3085. } else {
  3086. dev_err(codec->dev, "%s: wrong codec name %s\n", __func__,
  3087. codec->component.name);
  3088. return -EINVAL;
  3089. }
  3090. pdata = snd_soc_card_get_drvdata(component->card);
  3091. if (pdata && pdata->codec_root)
  3092. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  3093. codec);
  3094. return 0;
  3095. }
  3096. struct snd_soc_card snd_soc_card_tasha_msm8996 = {
  3097. .name = "msm8996-tasha-snd-card",
  3098. };
  3099. static int msm8996_populate_dai_link_component_of_node(
  3100. struct snd_soc_card *card)
  3101. {
  3102. int i, index, ret = 0;
  3103. struct device *cdev = card->dev;
  3104. struct snd_soc_dai_link *dai_link = card->dai_link;
  3105. struct device_node *np;
  3106. if (!cdev) {
  3107. pr_err("%s: Sound card device memory NULL\n", __func__);
  3108. return -ENODEV;
  3109. }
  3110. for (i = 0; i < card->num_links; i++) {
  3111. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  3112. continue;
  3113. /* populate platform_of_node for snd card dai links */
  3114. if (dai_link[i].platform_name &&
  3115. !dai_link[i].platform_of_node) {
  3116. index = of_property_match_string(cdev->of_node,
  3117. "asoc-platform-names",
  3118. dai_link[i].platform_name);
  3119. if (index < 0) {
  3120. pr_err("%s: No match found for platform name: %s\n",
  3121. __func__, dai_link[i].platform_name);
  3122. ret = index;
  3123. goto err;
  3124. }
  3125. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  3126. index);
  3127. if (!np) {
  3128. pr_err("%s: retrieving phandle for platform %s, index %d failed\n",
  3129. __func__, dai_link[i].platform_name,
  3130. index);
  3131. ret = -ENODEV;
  3132. goto err;
  3133. }
  3134. dai_link[i].platform_of_node = np;
  3135. dai_link[i].platform_name = NULL;
  3136. }
  3137. /* populate cpu_of_node for snd card dai links */
  3138. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  3139. index = of_property_match_string(cdev->of_node,
  3140. "asoc-cpu-names",
  3141. dai_link[i].cpu_dai_name);
  3142. if (index >= 0) {
  3143. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  3144. index);
  3145. if (!np) {
  3146. pr_err("%s: retrieving phandle for cpu dai %s failed\n",
  3147. __func__,
  3148. dai_link[i].cpu_dai_name);
  3149. ret = -ENODEV;
  3150. goto err;
  3151. }
  3152. dai_link[i].cpu_of_node = np;
  3153. dai_link[i].cpu_dai_name = NULL;
  3154. }
  3155. }
  3156. /* populate codec_of_node for snd card dai links */
  3157. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  3158. index = of_property_match_string(cdev->of_node,
  3159. "asoc-codec-names",
  3160. dai_link[i].codec_name);
  3161. if (index < 0)
  3162. continue;
  3163. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  3164. index);
  3165. if (!np) {
  3166. pr_err("%s: retrieving phandle for codec %s failed\n",
  3167. __func__, dai_link[i].codec_name);
  3168. ret = -ENODEV;
  3169. goto err;
  3170. }
  3171. dai_link[i].codec_of_node = np;
  3172. dai_link[i].codec_name = NULL;
  3173. }
  3174. }
  3175. err:
  3176. return ret;
  3177. }
  3178. static int msm8996_prepare_us_euro(struct snd_soc_card *card)
  3179. {
  3180. struct msm8996_asoc_mach_data *pdata =
  3181. snd_soc_card_get_drvdata(card);
  3182. int ret;
  3183. if (pdata->us_euro_gpio >= 0) {
  3184. dev_dbg(card->dev, "%s: us_euro gpio request %d", __func__,
  3185. pdata->us_euro_gpio);
  3186. ret = gpio_request(pdata->us_euro_gpio, "TASHA_CODEC_US_EURO");
  3187. if (ret) {
  3188. dev_err(card->dev,
  3189. "%s: Failed to request codec US/EURO gpio %d error %d\n",
  3190. __func__, pdata->us_euro_gpio, ret);
  3191. return ret;
  3192. }
  3193. }
  3194. return 0;
  3195. }
  3196. static int msm8996_prepare_hifi(struct snd_soc_card *card)
  3197. {
  3198. struct msm8996_asoc_mach_data *pdata =
  3199. snd_soc_card_get_drvdata(card);
  3200. int ret;
  3201. if (gpio_is_valid(pdata->hph_en1_gpio)) {
  3202. dev_dbg(card->dev, "%s: hph_en1_gpio request %d\n", __func__,
  3203. pdata->hph_en1_gpio);
  3204. ret = gpio_request(pdata->hph_en1_gpio, "hph_en1_gpio");
  3205. if (ret) {
  3206. dev_err(card->dev,
  3207. "%s: hph_en1_gpio request failed, ret:%d\n",
  3208. __func__, ret);
  3209. return ret;
  3210. }
  3211. }
  3212. if (gpio_is_valid(pdata->hph_en0_gpio)) {
  3213. dev_dbg(card->dev, "%s: hph_en0_gpio request %d\n", __func__,
  3214. pdata->hph_en0_gpio);
  3215. ret = gpio_request(pdata->hph_en0_gpio, "hph_en0_gpio");
  3216. if (ret) {
  3217. dev_err(card->dev,
  3218. "%s: hph_en0_gpio request failed, ret:%d\n",
  3219. __func__, ret);
  3220. return ret;
  3221. }
  3222. }
  3223. return 0;
  3224. }
  3225. static const struct of_device_id msm8996_asoc_machine_of_match[] = {
  3226. { .compatible = "qcom,msm8996-asoc-snd-tasha",
  3227. .data = "tasha_codec"},
  3228. {},
  3229. };
  3230. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  3231. {
  3232. struct snd_soc_card *card = NULL;
  3233. struct snd_soc_dai_link *dailink;
  3234. int len_1, len_2, len_3, len_4;
  3235. const struct of_device_id *match;
  3236. match = of_match_node(msm8996_asoc_machine_of_match, dev->of_node);
  3237. if (!match) {
  3238. dev_err(dev, "%s: No DT match found for sound card\n",
  3239. __func__);
  3240. return NULL;
  3241. }
  3242. if (!strcmp(match->data, "tasha_codec")) {
  3243. card = &snd_soc_card_tasha_msm8996;
  3244. len_1 = ARRAY_SIZE(msm8996_common_dai_links);
  3245. len_2 = len_1 + ARRAY_SIZE(msm8996_tasha_fe_dai_links);
  3246. len_3 = len_2 + ARRAY_SIZE(msm8996_common_be_dai_links);
  3247. memcpy(msm8996_tasha_dai_links,
  3248. msm8996_common_dai_links,
  3249. sizeof(msm8996_common_dai_links));
  3250. memcpy(msm8996_tasha_dai_links + len_1,
  3251. msm8996_tasha_fe_dai_links,
  3252. sizeof(msm8996_tasha_fe_dai_links));
  3253. memcpy(msm8996_tasha_dai_links + len_2,
  3254. msm8996_common_be_dai_links,
  3255. sizeof(msm8996_common_be_dai_links));
  3256. memcpy(msm8996_tasha_dai_links + len_3,
  3257. msm8996_tasha_be_dai_links,
  3258. sizeof(msm8996_tasha_be_dai_links));
  3259. dailink = msm8996_tasha_dai_links;
  3260. len_4 = len_3 + ARRAY_SIZE(msm8996_tasha_be_dai_links);
  3261. }
  3262. if (of_property_read_bool(dev->of_node, "qcom,hdmi-audio-rx")) {
  3263. dev_dbg(dev, "%s(): hdmi audio support present\n",
  3264. __func__);
  3265. memcpy(dailink + len_4, msm8996_hdmi_dai_link,
  3266. sizeof(msm8996_hdmi_dai_link));
  3267. len_4 += ARRAY_SIZE(msm8996_hdmi_dai_link);
  3268. } else {
  3269. dev_dbg(dev, "%s(): No hdmi audio support\n", __func__);
  3270. }
  3271. if (card) {
  3272. card->dai_link = dailink;
  3273. card->num_links = len_4;
  3274. }
  3275. return card;
  3276. }
  3277. static int msm8996_init_wsa_dev(struct platform_device *pdev,
  3278. struct snd_soc_card *card)
  3279. {
  3280. struct device_node *wsa_of_node;
  3281. u32 wsa_max_devs;
  3282. u32 wsa_dev_cnt;
  3283. char *dev_name_str = NULL;
  3284. struct msm8996_wsa881x_dev_info *wsa881x_dev_info;
  3285. const char *wsa_auxdev_name_prefix[1];
  3286. int found = 0;
  3287. int i;
  3288. int ret;
  3289. /* Get maximum WSA device count for this platform */
  3290. ret = of_property_read_u32(pdev->dev.of_node,
  3291. "qcom,wsa-max-devs", &wsa_max_devs);
  3292. if (ret) {
  3293. dev_dbg(&pdev->dev,
  3294. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  3295. __func__, pdev->dev.of_node->full_name, ret);
  3296. return 0;
  3297. }
  3298. if (wsa_max_devs == 0) {
  3299. dev_warn(&pdev->dev,
  3300. "%s: Max WSA devices is 0 for this target?\n",
  3301. __func__);
  3302. return 0;
  3303. }
  3304. /* Get count of WSA device phandles for this platform */
  3305. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  3306. "qcom,wsa-devs", NULL);
  3307. if (wsa_dev_cnt == -ENOENT) {
  3308. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  3309. __func__);
  3310. return 0;
  3311. } else if (wsa_dev_cnt <= 0) {
  3312. dev_err(&pdev->dev,
  3313. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  3314. __func__, wsa_dev_cnt);
  3315. return -EINVAL;
  3316. }
  3317. /*
  3318. * Expect total phandles count to be NOT less than maximum possible
  3319. * WSA count. However, if it is less, then assign same value to
  3320. * max count as well.
  3321. */
  3322. if (wsa_dev_cnt < wsa_max_devs) {
  3323. dev_dbg(&pdev->dev,
  3324. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  3325. __func__, wsa_max_devs, wsa_dev_cnt);
  3326. wsa_max_devs = wsa_dev_cnt;
  3327. }
  3328. /* Make sure prefix string passed for each WSA device */
  3329. ret = of_property_count_strings(pdev->dev.of_node,
  3330. "qcom,wsa-aux-dev-prefix");
  3331. if (ret != wsa_dev_cnt) {
  3332. dev_err(&pdev->dev,
  3333. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  3334. __func__, wsa_dev_cnt, ret);
  3335. return -EINVAL;
  3336. }
  3337. /*
  3338. * Alloc mem to store phandle and index info of WSA device, if already
  3339. * registered with ALSA core
  3340. */
  3341. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  3342. sizeof(struct msm8996_wsa881x_dev_info),
  3343. GFP_KERNEL);
  3344. if (!wsa881x_dev_info)
  3345. return -ENOMEM;
  3346. /*
  3347. * search and check whether all WSA devices are already
  3348. * registered with ALSA core or not. If found a node, store
  3349. * the node and the index in a local array of struct for later
  3350. * use.
  3351. */
  3352. for (i = 0; i < wsa_dev_cnt; i++) {
  3353. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  3354. "qcom,wsa-devs", i);
  3355. if (unlikely(!wsa_of_node)) {
  3356. /* we should not be here */
  3357. dev_err(&pdev->dev,
  3358. "%s: wsa dev node is not present\n",
  3359. __func__);
  3360. return -EINVAL;
  3361. }
  3362. if (soc_find_component(wsa_of_node, NULL)) {
  3363. /* WSA device registered with ALSA core */
  3364. wsa881x_dev_info[found].of_node = wsa_of_node;
  3365. wsa881x_dev_info[found].index = i;
  3366. found++;
  3367. if (found == wsa_max_devs)
  3368. break;
  3369. }
  3370. }
  3371. if (found < wsa_max_devs) {
  3372. dev_dbg(&pdev->dev,
  3373. "%s: failed to find %d components. Found only %d\n",
  3374. __func__, wsa_max_devs, found);
  3375. return -EPROBE_DEFER;
  3376. }
  3377. dev_info(&pdev->dev,
  3378. "%s: found %d wsa881x devices registered with ALSA core\n",
  3379. __func__, found);
  3380. card->num_aux_devs = wsa_max_devs;
  3381. card->num_configs = wsa_max_devs;
  3382. /* Alloc array of AUX devs struct */
  3383. msm8996_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  3384. sizeof(struct snd_soc_aux_dev),
  3385. GFP_KERNEL);
  3386. if (!msm8996_aux_dev)
  3387. return -ENOMEM;
  3388. /* Alloc array of codec conf struct */
  3389. msm8996_codec_conf = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  3390. sizeof(struct snd_soc_codec_conf),
  3391. GFP_KERNEL);
  3392. if (!msm8996_codec_conf)
  3393. return -ENOMEM;
  3394. for (i = 0; i < card->num_aux_devs; i++) {
  3395. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  3396. GFP_KERNEL);
  3397. if (!dev_name_str)
  3398. return -ENOMEM;
  3399. ret = of_property_read_string_index(pdev->dev.of_node,
  3400. "qcom,wsa-aux-dev-prefix",
  3401. wsa881x_dev_info[i].index,
  3402. wsa_auxdev_name_prefix);
  3403. if (ret) {
  3404. dev_err(&pdev->dev,
  3405. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  3406. __func__, ret);
  3407. return -EINVAL;
  3408. }
  3409. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  3410. msm8996_aux_dev[i].name = dev_name_str;
  3411. msm8996_aux_dev[i].codec_name = NULL;
  3412. msm8996_aux_dev[i].codec_of_node =
  3413. wsa881x_dev_info[i].of_node;
  3414. msm8996_aux_dev[i].init = msm8996_wsa881x_init;
  3415. msm8996_codec_conf[i].dev_name = NULL;
  3416. msm8996_codec_conf[i].name_prefix = wsa_auxdev_name_prefix[0];
  3417. msm8996_codec_conf[i].of_node =
  3418. wsa881x_dev_info[i].of_node;
  3419. }
  3420. card->codec_conf = msm8996_codec_conf;
  3421. card->aux_dev = msm8996_aux_dev;
  3422. return 0;
  3423. }
  3424. static int msm8996_asoc_machine_probe(struct platform_device *pdev)
  3425. {
  3426. struct snd_soc_card *card;
  3427. struct msm8996_asoc_mach_data *pdata;
  3428. const char *mbhc_audio_jack_type = NULL;
  3429. char *mclk_freq_prop_name;
  3430. const struct of_device_id *match;
  3431. int ret;
  3432. if (!pdev->dev.of_node) {
  3433. dev_err(&pdev->dev, "No platform supplied from device tree\n");
  3434. return -EINVAL;
  3435. }
  3436. pdata = devm_kzalloc(&pdev->dev,
  3437. sizeof(struct msm8996_asoc_mach_data), GFP_KERNEL);
  3438. if (!pdata)
  3439. return -ENOMEM;
  3440. card = populate_snd_card_dailinks(&pdev->dev);
  3441. if (!card) {
  3442. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  3443. ret = -EINVAL;
  3444. goto err;
  3445. }
  3446. card->dev = &pdev->dev;
  3447. platform_set_drvdata(pdev, card);
  3448. snd_soc_card_set_drvdata(card, pdata);
  3449. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  3450. if (ret) {
  3451. dev_err(&pdev->dev, "parse card name failed, err:%d\n",
  3452. ret);
  3453. goto err;
  3454. }
  3455. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  3456. if (ret) {
  3457. dev_err(&pdev->dev, "parse audio routing failed, err:%d\n",
  3458. ret);
  3459. goto err;
  3460. }
  3461. match = of_match_node(msm8996_asoc_machine_of_match,
  3462. pdev->dev.of_node);
  3463. if (!match) {
  3464. dev_err(&pdev->dev, "%s: no matched codec is found.\n",
  3465. __func__);
  3466. goto err;
  3467. }
  3468. mclk_freq_prop_name = "qcom,tasha-mclk-clk-freq";
  3469. ret = of_property_read_u32(pdev->dev.of_node,
  3470. mclk_freq_prop_name, &pdata->mclk_freq);
  3471. if (ret) {
  3472. dev_err(&pdev->dev,
  3473. "Looking up %s property in node %s failed, err%d\n",
  3474. mclk_freq_prop_name,
  3475. pdev->dev.of_node->full_name, ret);
  3476. goto err;
  3477. }
  3478. if (pdata->mclk_freq != CODEC_EXT_CLK_RATE) {
  3479. dev_err(&pdev->dev, "unsupported mclk freq %u\n",
  3480. pdata->mclk_freq);
  3481. ret = -EINVAL;
  3482. goto err;
  3483. }
  3484. spdev = pdev;
  3485. ret = msm8996_populate_dai_link_component_of_node(card);
  3486. if (ret) {
  3487. ret = -EPROBE_DEFER;
  3488. goto err;
  3489. }
  3490. ret = msm8996_init_wsa_dev(pdev, card);
  3491. if (ret)
  3492. goto err;
  3493. pdata->hph_en1_gpio = of_get_named_gpio(pdev->dev.of_node,
  3494. "qcom,hph-en1-gpio", 0);
  3495. if (pdata->hph_en1_gpio < 0) {
  3496. dev_dbg(&pdev->dev, "%s: %s property not found %d\n",
  3497. __func__, "qcom,hph-en1-gpio", pdata->hph_en1_gpio);
  3498. }
  3499. pdata->hph_en0_gpio = of_get_named_gpio(pdev->dev.of_node,
  3500. "qcom,hph-en0-gpio", 0);
  3501. if (pdata->hph_en0_gpio < 0) {
  3502. dev_dbg(&pdev->dev, "%s: %s property not found %d\n",
  3503. __func__, "qcom,hph-en0-gpio", pdata->hph_en0_gpio);
  3504. }
  3505. ret = msm8996_prepare_hifi(card);
  3506. if (ret)
  3507. dev_dbg(&pdev->dev, "msm8996_prepare_hifi failed (%d)\n",
  3508. ret);
  3509. ret = snd_soc_register_card(card);
  3510. if (ret == -EPROBE_DEFER) {
  3511. if (codec_reg_done)
  3512. ret = -EINVAL;
  3513. goto err;
  3514. } else if (ret) {
  3515. dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
  3516. ret);
  3517. goto err;
  3518. }
  3519. dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
  3520. ret = of_property_read_string(pdev->dev.of_node,
  3521. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  3522. if (ret) {
  3523. dev_dbg(&pdev->dev, "Looking up %s property in node %s failed",
  3524. "qcom,mbhc-audio-jack-type",
  3525. pdev->dev.of_node->full_name);
  3526. dev_dbg(&pdev->dev, "Jack type properties set to default");
  3527. } else {
  3528. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack"))
  3529. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  3530. else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack"))
  3531. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  3532. else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack"))
  3533. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  3534. else
  3535. dev_dbg(&pdev->dev, "Unknown value, set to default");
  3536. }
  3537. /*
  3538. * Parse US-Euro gpio info from DT. Report no error if us-euro
  3539. * entry is not found in DT file as some targets do not support
  3540. * US-Euro detection
  3541. */
  3542. pdata->us_euro_gpio = of_get_named_gpio(pdev->dev.of_node,
  3543. "qcom,us-euro-gpios", 0);
  3544. if (pdata->us_euro_gpio < 0) {
  3545. dev_info(&pdev->dev, "property %s not detected in node %s",
  3546. "qcom,us-euro-gpios",
  3547. pdev->dev.of_node->full_name);
  3548. } else {
  3549. dev_dbg(&pdev->dev, "%s detected %d",
  3550. "qcom,us-euro-gpios", pdata->us_euro_gpio);
  3551. wcd_mbhc_cfg.swap_gnd_mic = msm8996_swap_gnd_mic;
  3552. }
  3553. ret = msm8996_prepare_us_euro(card);
  3554. if (ret)
  3555. dev_info(&pdev->dev, "msm8996_prepare_us_euro failed (%d)\n",
  3556. ret);
  3557. return 0;
  3558. err:
  3559. if (pdata->us_euro_gpio > 0) {
  3560. dev_dbg(&pdev->dev, "%s free us_euro gpio %d\n",
  3561. __func__, pdata->us_euro_gpio);
  3562. gpio_free(pdata->us_euro_gpio);
  3563. pdata->us_euro_gpio = 0;
  3564. }
  3565. if (pdata->hph_en1_gpio > 0) {
  3566. dev_dbg(&pdev->dev, "%s free hph_en1_gpio %d\n",
  3567. __func__, pdata->hph_en1_gpio);
  3568. gpio_free(pdata->hph_en1_gpio);
  3569. pdata->hph_en1_gpio = 0;
  3570. }
  3571. if (pdata->hph_en0_gpio > 0) {
  3572. dev_dbg(&pdev->dev, "%s free hph_en0_gpio %d\n",
  3573. __func__, pdata->hph_en0_gpio);
  3574. gpio_free(pdata->hph_en0_gpio);
  3575. pdata->hph_en0_gpio = 0;
  3576. }
  3577. devm_kfree(&pdev->dev, pdata);
  3578. return ret;
  3579. }
  3580. static int msm8996_asoc_machine_remove(struct platform_device *pdev)
  3581. {
  3582. struct snd_soc_card *card = platform_get_drvdata(pdev);
  3583. struct msm8996_asoc_mach_data *pdata =
  3584. snd_soc_card_get_drvdata(card);
  3585. if (gpio_is_valid(ext_us_amp_gpio))
  3586. gpio_free(ext_us_amp_gpio);
  3587. gpio_free(pdata->us_euro_gpio);
  3588. gpio_free(pdata->hph_en1_gpio);
  3589. gpio_free(pdata->hph_en0_gpio);
  3590. if (msm8996_liquid_dock_dev != NULL) {
  3591. switch_dev_unregister(&msm8996_liquid_dock_dev->audio_sdev);
  3592. if (msm8996_liquid_dock_dev->dock_plug_irq)
  3593. free_irq(msm8996_liquid_dock_dev->dock_plug_irq,
  3594. msm8996_liquid_dock_dev);
  3595. if (msm8996_liquid_dock_dev->dock_plug_gpio)
  3596. gpio_free(msm8996_liquid_dock_dev->dock_plug_gpio);
  3597. kfree(msm8996_liquid_dock_dev);
  3598. msm8996_liquid_dock_dev = NULL;
  3599. }
  3600. snd_soc_unregister_card(card);
  3601. return 0;
  3602. }
  3603. static struct platform_driver msm8996_asoc_machine_driver = {
  3604. .driver = {
  3605. .name = DRV_NAME,
  3606. .owner = THIS_MODULE,
  3607. .pm = &snd_soc_pm_ops,
  3608. .of_match_table = msm8996_asoc_machine_of_match,
  3609. },
  3610. .probe = msm8996_asoc_machine_probe,
  3611. .remove = msm8996_asoc_machine_remove,
  3612. };
  3613. module_platform_driver(msm8996_asoc_machine_driver);
  3614. MODULE_DESCRIPTION("ALSA SoC msm");
  3615. MODULE_LICENSE("GPL v2");
  3616. MODULE_ALIAS("platform:" DRV_NAME);
  3617. MODULE_DEVICE_TABLE(of, msm8996_asoc_machine_of_match);