tx-macro.c 101 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  3. */
  4. #include <linux/module.h>
  5. #include <linux/init.h>
  6. #include <linux/clk.h>
  7. #include <linux/io.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/regmap.h>
  10. #include <linux/pm_runtime.h>
  11. #include <sound/soc.h>
  12. #include <sound/soc-dapm.h>
  13. #include <sound/tlv.h>
  14. #include <soc/swr-common.h>
  15. #include <soc/swr-wcd.h>
  16. #include <asoc/msm-cdc-pinctrl.h>
  17. #include "bolero-cdc.h"
  18. #include "bolero-cdc-registers.h"
  19. #include "bolero-clk-rsc.h"
  20. #define AUTO_SUSPEND_DELAY 50 /* delay in msec */
  21. #define TX_MACRO_MAX_OFFSET 0x1000
  22. #define NUM_DECIMATORS 8
  23. #define TX_MACRO_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
  24. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
  25. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  26. #define TX_MACRO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
  27. SNDRV_PCM_FMTBIT_S24_LE |\
  28. SNDRV_PCM_FMTBIT_S24_3LE)
  29. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  30. #define CF_MIN_3DB_4HZ 0x0
  31. #define CF_MIN_3DB_75HZ 0x1
  32. #define CF_MIN_3DB_150HZ 0x2
  33. #define TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED 0
  34. #define TX_MACRO_MCLK_FREQ 9600000
  35. #define TX_MACRO_TX_PATH_OFFSET 0x80
  36. #define TX_MACRO_SWR_MIC_MUX_SEL_MASK 0xF
  37. #define TX_MACRO_ADC_MUX_CFG_OFFSET 0x8
  38. #define TX_MACRO_ADC_MODE_CFG0_SHIFT 1
  39. #define TX_MACRO_DMIC_UNMUTE_DELAY_MS 40
  40. #define TX_MACRO_AMIC_UNMUTE_DELAY_MS 100
  41. #define TX_MACRO_DMIC_HPF_DELAY_MS 300
  42. #define TX_MACRO_AMIC_HPF_DELAY_MS 300
  43. static int tx_unmute_delay = TX_MACRO_DMIC_UNMUTE_DELAY_MS;
  44. module_param(tx_unmute_delay, int, 0664);
  45. MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
  46. static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
  47. static int tx_macro_hw_params(struct snd_pcm_substream *substream,
  48. struct snd_pcm_hw_params *params,
  49. struct snd_soc_dai *dai);
  50. static int tx_macro_get_channel_map(struct snd_soc_dai *dai,
  51. unsigned int *tx_num, unsigned int *tx_slot,
  52. unsigned int *rx_num, unsigned int *rx_slot);
  53. #define TX_MACRO_SWR_STRING_LEN 80
  54. #define TX_MACRO_CHILD_DEVICES_MAX 3
  55. /* Hold instance to soundwire platform device */
  56. struct tx_macro_swr_ctrl_data {
  57. struct platform_device *tx_swr_pdev;
  58. };
  59. struct tx_macro_swr_ctrl_platform_data {
  60. void *handle; /* holds codec private data */
  61. int (*read)(void *handle, int reg);
  62. int (*write)(void *handle, int reg, int val);
  63. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  64. int (*clk)(void *handle, bool enable);
  65. int (*core_vote)(void *handle, bool enable);
  66. int (*handle_irq)(void *handle,
  67. irqreturn_t (*swrm_irq_handler)(int irq,
  68. void *data),
  69. void *swrm_handle,
  70. int action);
  71. };
  72. enum {
  73. TX_MACRO_AIF_INVALID = 0,
  74. TX_MACRO_AIF1_CAP,
  75. TX_MACRO_AIF2_CAP,
  76. TX_MACRO_AIF3_CAP,
  77. TX_MACRO_MAX_DAIS
  78. };
  79. enum {
  80. TX_MACRO_DEC0,
  81. TX_MACRO_DEC1,
  82. TX_MACRO_DEC2,
  83. TX_MACRO_DEC3,
  84. TX_MACRO_DEC4,
  85. TX_MACRO_DEC5,
  86. TX_MACRO_DEC6,
  87. TX_MACRO_DEC7,
  88. TX_MACRO_DEC_MAX,
  89. };
  90. enum {
  91. TX_MACRO_CLK_DIV_2,
  92. TX_MACRO_CLK_DIV_3,
  93. TX_MACRO_CLK_DIV_4,
  94. TX_MACRO_CLK_DIV_6,
  95. TX_MACRO_CLK_DIV_8,
  96. TX_MACRO_CLK_DIV_16,
  97. };
  98. enum {
  99. MSM_DMIC,
  100. SWR_MIC,
  101. ANC_FB_TUNE1
  102. };
  103. enum {
  104. TX_MCLK,
  105. VA_MCLK,
  106. };
  107. struct tx_macro_reg_mask_val {
  108. u16 reg;
  109. u8 mask;
  110. u8 val;
  111. };
  112. struct tx_mute_work {
  113. struct tx_macro_priv *tx_priv;
  114. u32 decimator;
  115. struct delayed_work dwork;
  116. };
  117. struct hpf_work {
  118. struct tx_macro_priv *tx_priv;
  119. u8 decimator;
  120. u8 hpf_cut_off_freq;
  121. struct delayed_work dwork;
  122. };
  123. struct tx_macro_priv {
  124. struct device *dev;
  125. bool dec_active[NUM_DECIMATORS];
  126. int tx_mclk_users;
  127. int swr_clk_users;
  128. bool dapm_mclk_enable;
  129. bool reset_swr;
  130. struct mutex mclk_lock;
  131. struct mutex swr_clk_lock;
  132. struct snd_soc_component *component;
  133. struct device_node *tx_swr_gpio_p;
  134. struct tx_macro_swr_ctrl_data *swr_ctrl_data;
  135. struct tx_macro_swr_ctrl_platform_data swr_plat_data;
  136. struct work_struct tx_macro_add_child_devices_work;
  137. struct hpf_work tx_hpf_work[NUM_DECIMATORS];
  138. struct tx_mute_work tx_mute_dwork[NUM_DECIMATORS];
  139. u16 dmic_clk_div;
  140. u32 version;
  141. u32 is_used_tx_swr_gpio;
  142. unsigned long active_ch_mask[TX_MACRO_MAX_DAIS];
  143. unsigned long active_ch_cnt[TX_MACRO_MAX_DAIS];
  144. char __iomem *tx_io_base;
  145. struct platform_device *pdev_child_devices
  146. [TX_MACRO_CHILD_DEVICES_MAX];
  147. int child_count;
  148. int tx_swr_clk_cnt;
  149. int va_swr_clk_cnt;
  150. int va_clk_status;
  151. int tx_clk_status;
  152. bool bcs_enable;
  153. int dec_mode[NUM_DECIMATORS];
  154. int bcs_ch;
  155. bool bcs_clk_en;
  156. bool hs_slow_insert_complete;
  157. };
  158. static bool tx_macro_get_data(struct snd_soc_component *component,
  159. struct device **tx_dev,
  160. struct tx_macro_priv **tx_priv,
  161. const char *func_name)
  162. {
  163. *tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
  164. if (!(*tx_dev)) {
  165. dev_err(component->dev,
  166. "%s: null device for macro!\n", func_name);
  167. return false;
  168. }
  169. *tx_priv = dev_get_drvdata((*tx_dev));
  170. if (!(*tx_priv)) {
  171. dev_err(component->dev,
  172. "%s: priv is null for macro!\n", func_name);
  173. return false;
  174. }
  175. if (!(*tx_priv)->component) {
  176. dev_err(component->dev,
  177. "%s: tx_priv->component not initialized!\n", func_name);
  178. return false;
  179. }
  180. return true;
  181. }
  182. static int tx_macro_mclk_enable(struct tx_macro_priv *tx_priv,
  183. bool mclk_enable)
  184. {
  185. struct regmap *regmap = dev_get_regmap(tx_priv->dev->parent, NULL);
  186. int ret = 0;
  187. if (regmap == NULL) {
  188. dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
  189. return -EINVAL;
  190. }
  191. dev_dbg(tx_priv->dev, "%s: mclk_enable = %u,clk_users= %d\n",
  192. __func__, mclk_enable, tx_priv->tx_mclk_users);
  193. mutex_lock(&tx_priv->mclk_lock);
  194. if (mclk_enable) {
  195. ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  196. TX_CORE_CLK,
  197. TX_CORE_CLK,
  198. true);
  199. if (ret < 0) {
  200. dev_err_ratelimited(tx_priv->dev,
  201. "%s: request clock enable failed\n",
  202. __func__);
  203. goto exit;
  204. }
  205. bolero_clk_rsc_fs_gen_request(tx_priv->dev,
  206. true);
  207. if (tx_priv->tx_mclk_users == 0) {
  208. regcache_mark_dirty(regmap);
  209. regcache_sync_region(regmap,
  210. TX_START_OFFSET,
  211. TX_MAX_OFFSET);
  212. /* 9.6MHz MCLK, set value 0x00 if other frequency */
  213. regmap_update_bits(regmap,
  214. BOLERO_CDC_TX_TOP_CSR_FREQ_MCLK, 0x01, 0x01);
  215. regmap_update_bits(regmap,
  216. BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
  217. 0x01, 0x01);
  218. regmap_update_bits(regmap,
  219. BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
  220. 0x01, 0x01);
  221. }
  222. tx_priv->tx_mclk_users++;
  223. } else {
  224. if (tx_priv->tx_mclk_users <= 0) {
  225. dev_err(tx_priv->dev, "%s: clock already disabled\n",
  226. __func__);
  227. tx_priv->tx_mclk_users = 0;
  228. goto exit;
  229. }
  230. tx_priv->tx_mclk_users--;
  231. if (tx_priv->tx_mclk_users == 0) {
  232. regmap_update_bits(regmap,
  233. BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
  234. 0x01, 0x00);
  235. regmap_update_bits(regmap,
  236. BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
  237. 0x01, 0x00);
  238. }
  239. bolero_clk_rsc_fs_gen_request(tx_priv->dev,
  240. false);
  241. bolero_clk_rsc_request_clock(tx_priv->dev,
  242. TX_CORE_CLK,
  243. TX_CORE_CLK,
  244. false);
  245. }
  246. exit:
  247. mutex_unlock(&tx_priv->mclk_lock);
  248. return ret;
  249. }
  250. static int __tx_macro_mclk_enable(struct snd_soc_component *component,
  251. bool enable)
  252. {
  253. struct device *tx_dev = NULL;
  254. struct tx_macro_priv *tx_priv = NULL;
  255. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  256. return -EINVAL;
  257. return tx_macro_mclk_enable(tx_priv, enable);
  258. }
  259. static int tx_macro_va_swr_clk_event(struct snd_soc_dapm_widget *w,
  260. struct snd_kcontrol *kcontrol, int event)
  261. {
  262. struct device *tx_dev = NULL;
  263. struct tx_macro_priv *tx_priv = NULL;
  264. struct snd_soc_component *component =
  265. snd_soc_dapm_to_component(w->dapm);
  266. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  267. return -EINVAL;
  268. if (SND_SOC_DAPM_EVENT_ON(event))
  269. ++tx_priv->va_swr_clk_cnt;
  270. if (SND_SOC_DAPM_EVENT_OFF(event))
  271. --tx_priv->va_swr_clk_cnt;
  272. return 0;
  273. }
  274. static int tx_macro_tx_swr_clk_event(struct snd_soc_dapm_widget *w,
  275. struct snd_kcontrol *kcontrol, int event)
  276. {
  277. struct device *tx_dev = NULL;
  278. struct tx_macro_priv *tx_priv = NULL;
  279. struct snd_soc_component *component =
  280. snd_soc_dapm_to_component(w->dapm);
  281. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  282. return -EINVAL;
  283. if (SND_SOC_DAPM_EVENT_ON(event))
  284. ++tx_priv->tx_swr_clk_cnt;
  285. if (SND_SOC_DAPM_EVENT_OFF(event))
  286. --tx_priv->tx_swr_clk_cnt;
  287. return 0;
  288. }
  289. static int tx_macro_mclk_event(struct snd_soc_dapm_widget *w,
  290. struct snd_kcontrol *kcontrol, int event)
  291. {
  292. struct snd_soc_component *component =
  293. snd_soc_dapm_to_component(w->dapm);
  294. int ret = 0;
  295. struct device *tx_dev = NULL;
  296. struct tx_macro_priv *tx_priv = NULL;
  297. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  298. return -EINVAL;
  299. dev_dbg(tx_dev, "%s: event = %d\n", __func__, event);
  300. switch (event) {
  301. case SND_SOC_DAPM_PRE_PMU:
  302. ret = tx_macro_mclk_enable(tx_priv, 1);
  303. if (ret)
  304. tx_priv->dapm_mclk_enable = false;
  305. else
  306. tx_priv->dapm_mclk_enable = true;
  307. break;
  308. case SND_SOC_DAPM_POST_PMD:
  309. if (tx_priv->dapm_mclk_enable)
  310. ret = tx_macro_mclk_enable(tx_priv, 0);
  311. break;
  312. default:
  313. dev_err(tx_priv->dev,
  314. "%s: invalid DAPM event %d\n", __func__, event);
  315. ret = -EINVAL;
  316. }
  317. return ret;
  318. }
  319. static int tx_macro_event_handler(struct snd_soc_component *component,
  320. u16 event, u32 data)
  321. {
  322. struct device *tx_dev = NULL;
  323. struct tx_macro_priv *tx_priv = NULL;
  324. int ret = 0;
  325. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  326. return -EINVAL;
  327. switch (event) {
  328. case BOLERO_MACRO_EVT_SSR_DOWN:
  329. if (tx_priv->swr_ctrl_data) {
  330. swrm_wcd_notify(
  331. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  332. SWR_DEVICE_DOWN, NULL);
  333. swrm_wcd_notify(
  334. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  335. SWR_DEVICE_SSR_DOWN, NULL);
  336. }
  337. if ((!pm_runtime_enabled(tx_dev) ||
  338. !pm_runtime_suspended(tx_dev))) {
  339. ret = bolero_runtime_suspend(tx_dev);
  340. if (!ret) {
  341. pm_runtime_disable(tx_dev);
  342. pm_runtime_set_suspended(tx_dev);
  343. pm_runtime_enable(tx_dev);
  344. }
  345. }
  346. break;
  347. case BOLERO_MACRO_EVT_SSR_UP:
  348. /* reset swr after ssr/pdr */
  349. tx_priv->reset_swr = true;
  350. if (tx_priv->swr_ctrl_data)
  351. swrm_wcd_notify(
  352. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  353. SWR_DEVICE_SSR_UP, NULL);
  354. break;
  355. case BOLERO_MACRO_EVT_CLK_RESET:
  356. bolero_rsc_clk_reset(tx_dev, TX_CORE_CLK);
  357. break;
  358. case BOLERO_MACRO_EVT_BCS_CLK_OFF:
  359. if (tx_priv->bcs_clk_en)
  360. snd_soc_component_update_bits(component,
  361. BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40, data << 6);
  362. if (data)
  363. tx_priv->hs_slow_insert_complete = true;
  364. else
  365. tx_priv->hs_slow_insert_complete = false;
  366. break;
  367. }
  368. return 0;
  369. }
  370. static int tx_macro_reg_wake_irq(struct snd_soc_component *component,
  371. u32 data)
  372. {
  373. struct device *tx_dev = NULL;
  374. struct tx_macro_priv *tx_priv = NULL;
  375. u32 ipc_wakeup = data;
  376. int ret = 0;
  377. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  378. return -EINVAL;
  379. if (tx_priv->swr_ctrl_data)
  380. ret = swrm_wcd_notify(
  381. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  382. SWR_REGISTER_WAKE_IRQ, &ipc_wakeup);
  383. return ret;
  384. }
  385. static int is_amic_enabled(struct snd_soc_component *component, int decimator)
  386. {
  387. u16 adc_mux_reg = 0, adc_reg = 0;
  388. u16 adc_n = BOLERO_ADC_MAX;
  389. adc_mux_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
  390. TX_MACRO_ADC_MUX_CFG_OFFSET * decimator;
  391. if (snd_soc_component_read32(component, adc_mux_reg) & SWR_MIC) {
  392. adc_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  393. TX_MACRO_ADC_MUX_CFG_OFFSET * decimator;
  394. adc_n = snd_soc_component_read32(component, adc_reg) &
  395. TX_MACRO_SWR_MIC_MUX_SEL_MASK;
  396. if (adc_n >= BOLERO_ADC_MAX)
  397. adc_n = BOLERO_ADC_MAX;
  398. }
  399. return adc_n;
  400. }
  401. static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work)
  402. {
  403. struct delayed_work *hpf_delayed_work = NULL;
  404. struct hpf_work *hpf_work = NULL;
  405. struct tx_macro_priv *tx_priv = NULL;
  406. struct snd_soc_component *component = NULL;
  407. u16 dec_cfg_reg = 0, hpf_gate_reg = 0;
  408. u8 hpf_cut_off_freq = 0;
  409. u16 adc_n = 0;
  410. hpf_delayed_work = to_delayed_work(work);
  411. hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
  412. tx_priv = hpf_work->tx_priv;
  413. component = tx_priv->component;
  414. hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
  415. dec_cfg_reg = BOLERO_CDC_TX0_TX_PATH_CFG0 +
  416. TX_MACRO_TX_PATH_OFFSET * hpf_work->decimator;
  417. hpf_gate_reg = BOLERO_CDC_TX0_TX_PATH_SEC2 +
  418. TX_MACRO_TX_PATH_OFFSET * hpf_work->decimator;
  419. dev_dbg(component->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
  420. __func__, hpf_work->decimator, hpf_cut_off_freq);
  421. adc_n = is_amic_enabled(component, hpf_work->decimator);
  422. if (adc_n < BOLERO_ADC_MAX) {
  423. /* analog mic clear TX hold */
  424. bolero_clear_amic_tx_hold(component->dev, adc_n);
  425. snd_soc_component_update_bits(component,
  426. dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  427. hpf_cut_off_freq << 5);
  428. snd_soc_component_update_bits(component, hpf_gate_reg,
  429. 0x03, 0x02);
  430. /* Minimum 1 clk cycle delay is required as per HW spec */
  431. usleep_range(1000, 1010);
  432. snd_soc_component_update_bits(component, hpf_gate_reg,
  433. 0x03, 0x01);
  434. } else {
  435. snd_soc_component_update_bits(component,
  436. dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  437. hpf_cut_off_freq << 5);
  438. snd_soc_component_update_bits(component, hpf_gate_reg,
  439. 0x02, 0x02);
  440. /* Minimum 1 clk cycle delay is required as per HW spec */
  441. usleep_range(1000, 1010);
  442. snd_soc_component_update_bits(component, hpf_gate_reg,
  443. 0x02, 0x00);
  444. }
  445. }
  446. static void tx_macro_mute_update_callback(struct work_struct *work)
  447. {
  448. struct tx_mute_work *tx_mute_dwork = NULL;
  449. struct snd_soc_component *component = NULL;
  450. struct tx_macro_priv *tx_priv = NULL;
  451. struct delayed_work *delayed_work = NULL;
  452. u16 tx_vol_ctl_reg = 0;
  453. u8 decimator = 0;
  454. delayed_work = to_delayed_work(work);
  455. tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
  456. tx_priv = tx_mute_dwork->tx_priv;
  457. component = tx_priv->component;
  458. decimator = tx_mute_dwork->decimator;
  459. tx_vol_ctl_reg =
  460. BOLERO_CDC_TX0_TX_PATH_CTL +
  461. TX_MACRO_TX_PATH_OFFSET * decimator;
  462. snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00);
  463. dev_dbg(tx_priv->dev, "%s: decimator %u unmute\n",
  464. __func__, decimator);
  465. }
  466. static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
  467. struct snd_ctl_elem_value *ucontrol)
  468. {
  469. struct snd_soc_dapm_widget *widget =
  470. snd_soc_dapm_kcontrol_widget(kcontrol);
  471. struct snd_soc_component *component =
  472. snd_soc_dapm_to_component(widget->dapm);
  473. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  474. unsigned int val = 0;
  475. u16 mic_sel_reg = 0;
  476. u16 dmic_clk_reg = 0;
  477. struct device *tx_dev = NULL;
  478. struct tx_macro_priv *tx_priv = NULL;
  479. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  480. return -EINVAL;
  481. val = ucontrol->value.enumerated.item[0];
  482. if (val > e->items - 1)
  483. return -EINVAL;
  484. dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  485. widget->name, val);
  486. switch (e->reg) {
  487. case BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0:
  488. mic_sel_reg = BOLERO_CDC_TX0_TX_PATH_CFG0;
  489. break;
  490. case BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0:
  491. mic_sel_reg = BOLERO_CDC_TX1_TX_PATH_CFG0;
  492. break;
  493. case BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0:
  494. mic_sel_reg = BOLERO_CDC_TX2_TX_PATH_CFG0;
  495. break;
  496. case BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0:
  497. mic_sel_reg = BOLERO_CDC_TX3_TX_PATH_CFG0;
  498. break;
  499. case BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
  500. mic_sel_reg = BOLERO_CDC_TX4_TX_PATH_CFG0;
  501. break;
  502. case BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
  503. mic_sel_reg = BOLERO_CDC_TX5_TX_PATH_CFG0;
  504. break;
  505. case BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
  506. mic_sel_reg = BOLERO_CDC_TX6_TX_PATH_CFG0;
  507. break;
  508. case BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
  509. mic_sel_reg = BOLERO_CDC_TX7_TX_PATH_CFG0;
  510. break;
  511. default:
  512. dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
  513. __func__, e->reg);
  514. return -EINVAL;
  515. }
  516. if (strnstr(widget->name, "SMIC", strlen(widget->name))) {
  517. if (val != 0) {
  518. if (val < 5) {
  519. snd_soc_component_update_bits(component,
  520. mic_sel_reg,
  521. 1 << 7, 0x0 << 7);
  522. } else {
  523. snd_soc_component_update_bits(component,
  524. mic_sel_reg,
  525. 1 << 7, 0x1 << 7);
  526. snd_soc_component_update_bits(component,
  527. BOLERO_CDC_VA_TOP_CSR_DMIC_CFG,
  528. 0x80, 0x00);
  529. dmic_clk_reg =
  530. BOLERO_CDC_TX_TOP_CSR_SWR_DMIC0_CTL +
  531. ((val - 5)/2) * 4;
  532. snd_soc_component_update_bits(component,
  533. dmic_clk_reg,
  534. 0x0E, tx_priv->dmic_clk_div << 0x1);
  535. }
  536. }
  537. } else {
  538. /* DMIC selected */
  539. if (val != 0)
  540. snd_soc_component_update_bits(component, mic_sel_reg,
  541. 1 << 7, 1 << 7);
  542. }
  543. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  544. }
  545. static int tx_macro_tx_mixer_get(struct snd_kcontrol *kcontrol,
  546. struct snd_ctl_elem_value *ucontrol)
  547. {
  548. struct snd_soc_dapm_widget *widget =
  549. snd_soc_dapm_kcontrol_widget(kcontrol);
  550. struct snd_soc_component *component =
  551. snd_soc_dapm_to_component(widget->dapm);
  552. struct soc_multi_mixer_control *mixer =
  553. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  554. u32 dai_id = widget->shift;
  555. u32 dec_id = mixer->shift;
  556. struct device *tx_dev = NULL;
  557. struct tx_macro_priv *tx_priv = NULL;
  558. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  559. return -EINVAL;
  560. if (test_bit(dec_id, &tx_priv->active_ch_mask[dai_id]))
  561. ucontrol->value.integer.value[0] = 1;
  562. else
  563. ucontrol->value.integer.value[0] = 0;
  564. return 0;
  565. }
  566. static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
  567. struct snd_ctl_elem_value *ucontrol)
  568. {
  569. struct snd_soc_dapm_widget *widget =
  570. snd_soc_dapm_kcontrol_widget(kcontrol);
  571. struct snd_soc_component *component =
  572. snd_soc_dapm_to_component(widget->dapm);
  573. struct snd_soc_dapm_update *update = NULL;
  574. struct soc_multi_mixer_control *mixer =
  575. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  576. u32 dai_id = widget->shift;
  577. u32 dec_id = mixer->shift;
  578. u32 enable = ucontrol->value.integer.value[0];
  579. struct device *tx_dev = NULL;
  580. struct tx_macro_priv *tx_priv = NULL;
  581. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  582. return -EINVAL;
  583. if (enable) {
  584. set_bit(dec_id, &tx_priv->active_ch_mask[dai_id]);
  585. tx_priv->active_ch_cnt[dai_id]++;
  586. } else {
  587. tx_priv->active_ch_cnt[dai_id]--;
  588. clear_bit(dec_id, &tx_priv->active_ch_mask[dai_id]);
  589. }
  590. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
  591. return 0;
  592. }
  593. static inline int tx_macro_path_get(const char *wname,
  594. unsigned int *path_num)
  595. {
  596. int ret = 0;
  597. char *widget_name = NULL;
  598. char *w_name = NULL;
  599. char *path_num_char = NULL;
  600. char *path_name = NULL;
  601. widget_name = kstrndup(wname, 10, GFP_KERNEL);
  602. if (!widget_name)
  603. return -EINVAL;
  604. w_name = widget_name;
  605. path_name = strsep(&widget_name, " ");
  606. if (!path_name) {
  607. pr_err("%s: Invalid widget name = %s\n",
  608. __func__, widget_name);
  609. ret = -EINVAL;
  610. goto err;
  611. }
  612. path_num_char = strpbrk(path_name, "01234567");
  613. if (!path_num_char) {
  614. pr_err("%s: tx path index not found\n",
  615. __func__);
  616. ret = -EINVAL;
  617. goto err;
  618. }
  619. ret = kstrtouint(path_num_char, 10, path_num);
  620. if (ret < 0)
  621. pr_err("%s: Invalid tx path = %s\n",
  622. __func__, w_name);
  623. err:
  624. kfree(w_name);
  625. return ret;
  626. }
  627. static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol,
  628. struct snd_ctl_elem_value *ucontrol)
  629. {
  630. struct snd_soc_component *component =
  631. snd_soc_kcontrol_component(kcontrol);
  632. struct tx_macro_priv *tx_priv = NULL;
  633. struct device *tx_dev = NULL;
  634. int ret = 0;
  635. int path = 0;
  636. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  637. return -EINVAL;
  638. ret = tx_macro_path_get(kcontrol->id.name, &path);
  639. if (ret)
  640. return ret;
  641. ucontrol->value.integer.value[0] = tx_priv->dec_mode[path];
  642. return 0;
  643. }
  644. static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol,
  645. struct snd_ctl_elem_value *ucontrol)
  646. {
  647. struct snd_soc_component *component =
  648. snd_soc_kcontrol_component(kcontrol);
  649. struct tx_macro_priv *tx_priv = NULL;
  650. struct device *tx_dev = NULL;
  651. int value = ucontrol->value.integer.value[0];
  652. int ret = 0;
  653. int path = 0;
  654. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  655. return -EINVAL;
  656. ret = tx_macro_path_get(kcontrol->id.name, &path);
  657. if (ret)
  658. return ret;
  659. tx_priv->dec_mode[path] = value;
  660. return 0;
  661. }
  662. static int tx_macro_bcs_ch_get(struct snd_kcontrol *kcontrol,
  663. struct snd_ctl_elem_value *ucontrol)
  664. {
  665. struct snd_soc_component *component =
  666. snd_soc_kcontrol_component(kcontrol);
  667. struct tx_macro_priv *tx_priv = NULL;
  668. struct device *tx_dev = NULL;
  669. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  670. return -EINVAL;
  671. ucontrol->value.enumerated.item[0] = tx_priv->bcs_ch;
  672. return 0;
  673. }
  674. static int tx_macro_bcs_ch_put(struct snd_kcontrol *kcontrol,
  675. struct snd_ctl_elem_value *ucontrol)
  676. {
  677. struct snd_soc_component *component =
  678. snd_soc_kcontrol_component(kcontrol);
  679. struct tx_macro_priv *tx_priv = NULL;
  680. struct device *tx_dev = NULL;
  681. int value = ucontrol->value.enumerated.item[0];
  682. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  683. return -EINVAL;
  684. tx_priv->bcs_ch = value;
  685. return 0;
  686. }
  687. static int tx_macro_get_bcs(struct snd_kcontrol *kcontrol,
  688. struct snd_ctl_elem_value *ucontrol)
  689. {
  690. struct snd_soc_component *component =
  691. snd_soc_kcontrol_component(kcontrol);
  692. struct tx_macro_priv *tx_priv = NULL;
  693. struct device *tx_dev = NULL;
  694. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  695. return -EINVAL;
  696. ucontrol->value.integer.value[0] = tx_priv->bcs_enable;
  697. return 0;
  698. }
  699. static int tx_macro_set_bcs(struct snd_kcontrol *kcontrol,
  700. struct snd_ctl_elem_value *ucontrol)
  701. {
  702. struct snd_soc_component *component =
  703. snd_soc_kcontrol_component(kcontrol);
  704. struct tx_macro_priv *tx_priv = NULL;
  705. struct device *tx_dev = NULL;
  706. int value = ucontrol->value.integer.value[0];
  707. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  708. return -EINVAL;
  709. tx_priv->bcs_enable = value;
  710. return 0;
  711. }
  712. static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w,
  713. struct snd_kcontrol *kcontrol, int event)
  714. {
  715. struct snd_soc_component *component =
  716. snd_soc_dapm_to_component(w->dapm);
  717. unsigned int dmic = 0;
  718. int ret = 0;
  719. char *wname = NULL;
  720. wname = strpbrk(w->name, "01234567");
  721. if (!wname) {
  722. dev_err(component->dev, "%s: widget not found\n", __func__);
  723. return -EINVAL;
  724. }
  725. ret = kstrtouint(wname, 10, &dmic);
  726. if (ret < 0) {
  727. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  728. __func__);
  729. return -EINVAL;
  730. }
  731. dev_dbg(component->dev, "%s: event %d DMIC%d\n",
  732. __func__, event, dmic);
  733. switch (event) {
  734. case SND_SOC_DAPM_PRE_PMU:
  735. bolero_dmic_clk_enable(component, dmic, DMIC_TX, true);
  736. break;
  737. case SND_SOC_DAPM_POST_PMD:
  738. bolero_dmic_clk_enable(component, dmic, DMIC_TX, false);
  739. break;
  740. }
  741. return 0;
  742. }
  743. static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
  744. struct snd_kcontrol *kcontrol, int event)
  745. {
  746. struct snd_soc_component *component =
  747. snd_soc_dapm_to_component(w->dapm);
  748. unsigned int decimator = 0;
  749. u16 tx_vol_ctl_reg = 0;
  750. u16 dec_cfg_reg = 0;
  751. u16 hpf_gate_reg = 0;
  752. u16 tx_gain_ctl_reg = 0;
  753. u8 hpf_cut_off_freq = 0;
  754. u16 adc_mux_reg = 0;
  755. int hpf_delay = TX_MACRO_DMIC_HPF_DELAY_MS;
  756. int unmute_delay = TX_MACRO_DMIC_UNMUTE_DELAY_MS;
  757. struct device *tx_dev = NULL;
  758. struct tx_macro_priv *tx_priv = NULL;
  759. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  760. return -EINVAL;
  761. decimator = w->shift;
  762. dev_dbg(component->dev, "%s(): widget = %s decimator = %u\n", __func__,
  763. w->name, decimator);
  764. tx_vol_ctl_reg = BOLERO_CDC_TX0_TX_PATH_CTL +
  765. TX_MACRO_TX_PATH_OFFSET * decimator;
  766. hpf_gate_reg = BOLERO_CDC_TX0_TX_PATH_SEC2 +
  767. TX_MACRO_TX_PATH_OFFSET * decimator;
  768. dec_cfg_reg = BOLERO_CDC_TX0_TX_PATH_CFG0 +
  769. TX_MACRO_TX_PATH_OFFSET * decimator;
  770. tx_gain_ctl_reg = BOLERO_CDC_TX0_TX_VOL_CTL +
  771. TX_MACRO_TX_PATH_OFFSET * decimator;
  772. adc_mux_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
  773. TX_MACRO_ADC_MUX_CFG_OFFSET * decimator;
  774. switch (event) {
  775. case SND_SOC_DAPM_PRE_PMU:
  776. snd_soc_component_update_bits(component,
  777. dec_cfg_reg, 0x06, tx_priv->dec_mode[decimator] <<
  778. TX_MACRO_ADC_MODE_CFG0_SHIFT);
  779. /* Enable TX PGA Mute */
  780. snd_soc_component_update_bits(component,
  781. tx_vol_ctl_reg, 0x10, 0x10);
  782. break;
  783. case SND_SOC_DAPM_POST_PMU:
  784. snd_soc_component_update_bits(component,
  785. tx_vol_ctl_reg, 0x20, 0x20);
  786. if (!(is_amic_enabled(component, decimator) < BOLERO_ADC_MAX)) {
  787. snd_soc_component_update_bits(component,
  788. hpf_gate_reg, 0x01, 0x00);
  789. /*
  790. * Minimum 1 clk cycle delay is required as per HW spec
  791. */
  792. usleep_range(1000, 1010);
  793. }
  794. hpf_cut_off_freq = (
  795. snd_soc_component_read32(component, dec_cfg_reg) &
  796. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  797. tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq =
  798. hpf_cut_off_freq;
  799. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
  800. snd_soc_component_update_bits(component, dec_cfg_reg,
  801. TX_HPF_CUT_OFF_FREQ_MASK,
  802. CF_MIN_3DB_150HZ << 5);
  803. if (is_amic_enabled(component, decimator) < BOLERO_ADC_MAX) {
  804. hpf_delay = TX_MACRO_AMIC_HPF_DELAY_MS;
  805. unmute_delay = TX_MACRO_AMIC_UNMUTE_DELAY_MS;
  806. }
  807. if (tx_unmute_delay < unmute_delay)
  808. tx_unmute_delay = unmute_delay;
  809. /* schedule work queue to Remove Mute */
  810. queue_delayed_work(system_freezable_wq,
  811. &tx_priv->tx_mute_dwork[decimator].dwork,
  812. msecs_to_jiffies(tx_unmute_delay));
  813. if (tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq !=
  814. CF_MIN_3DB_150HZ) {
  815. queue_delayed_work(system_freezable_wq,
  816. &tx_priv->tx_hpf_work[decimator].dwork,
  817. msecs_to_jiffies(hpf_delay));
  818. snd_soc_component_update_bits(component,
  819. hpf_gate_reg, 0x03, 0x02);
  820. if (!(is_amic_enabled(component, decimator)
  821. < BOLERO_ADC_MAX))
  822. snd_soc_component_update_bits(component,
  823. hpf_gate_reg, 0x03, 0x00);
  824. /*
  825. * Minimum 1 clk cycle delay is required as per HW spec
  826. */
  827. usleep_range(1000, 1010);
  828. snd_soc_component_update_bits(component,
  829. hpf_gate_reg, 0x03, 0x01);
  830. /*
  831. * 6ms delay is required as per HW spec
  832. */
  833. usleep_range(6000, 6010);
  834. }
  835. /* apply gain after decimator is enabled */
  836. snd_soc_component_write(component, tx_gain_ctl_reg,
  837. snd_soc_component_read32(component,
  838. tx_gain_ctl_reg));
  839. if (tx_priv->bcs_enable) {
  840. if (tx_priv->version == BOLERO_VERSION_2_1)
  841. snd_soc_component_update_bits(component,
  842. BOLERO_CDC_VA_TOP_CSR_SWR_CTRL, 0x0F,
  843. tx_priv->bcs_ch);
  844. else if (tx_priv->version == BOLERO_VERSION_2_0)
  845. snd_soc_component_update_bits(component,
  846. BOLERO_CDC_TX_TOP_CSR_SWR_CTRL, 0xF0,
  847. (tx_priv->bcs_ch << 4));
  848. snd_soc_component_update_bits(component, dec_cfg_reg,
  849. 0x01, 0x01);
  850. tx_priv->bcs_clk_en = true;
  851. if (tx_priv->hs_slow_insert_complete)
  852. snd_soc_component_update_bits(component,
  853. BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40,
  854. 0x40);
  855. }
  856. if (tx_priv->version == BOLERO_VERSION_2_0) {
  857. if (snd_soc_component_read32(component, adc_mux_reg)
  858. & SWR_MIC) {
  859. snd_soc_component_update_bits(component,
  860. BOLERO_CDC_TX_TOP_CSR_SWR_CTRL,
  861. 0x01, 0x01);
  862. snd_soc_component_update_bits(component,
  863. BOLERO_CDC_TX_TOP_CSR_SWR_MIC0_CTL,
  864. 0x0E, 0x0C);
  865. snd_soc_component_update_bits(component,
  866. BOLERO_CDC_TX_TOP_CSR_SWR_MIC1_CTL,
  867. 0x0E, 0x0C);
  868. snd_soc_component_update_bits(component,
  869. BOLERO_CDC_TX_TOP_CSR_SWR_MIC2_CTL,
  870. 0x0E, 0x00);
  871. snd_soc_component_update_bits(component,
  872. BOLERO_CDC_TX_TOP_CSR_SWR_MIC3_CTL,
  873. 0x0E, 0x00);
  874. snd_soc_component_update_bits(component,
  875. BOLERO_CDC_TX_TOP_CSR_SWR_MIC4_CTL,
  876. 0x0E, 0x00);
  877. snd_soc_component_update_bits(component,
  878. BOLERO_CDC_TX_TOP_CSR_SWR_MIC5_CTL,
  879. 0x0E, 0x00);
  880. }
  881. }
  882. break;
  883. case SND_SOC_DAPM_PRE_PMD:
  884. hpf_cut_off_freq =
  885. tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq;
  886. snd_soc_component_update_bits(component,
  887. tx_vol_ctl_reg, 0x10, 0x10);
  888. if (cancel_delayed_work_sync(
  889. &tx_priv->tx_hpf_work[decimator].dwork)) {
  890. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  891. snd_soc_component_update_bits(
  892. component, dec_cfg_reg,
  893. TX_HPF_CUT_OFF_FREQ_MASK,
  894. hpf_cut_off_freq << 5);
  895. if (is_amic_enabled(component, decimator) < BOLERO_ADC_MAX)
  896. snd_soc_component_update_bits(component,
  897. hpf_gate_reg,
  898. 0x03, 0x02);
  899. else
  900. snd_soc_component_update_bits(component,
  901. hpf_gate_reg,
  902. 0x03, 0x03);
  903. /*
  904. * Minimum 1 clk cycle delay is required
  905. * as per HW spec
  906. */
  907. usleep_range(1000, 1010);
  908. snd_soc_component_update_bits(component,
  909. hpf_gate_reg,
  910. 0x03, 0x01);
  911. }
  912. }
  913. cancel_delayed_work_sync(
  914. &tx_priv->tx_mute_dwork[decimator].dwork);
  915. if (tx_priv->version == BOLERO_VERSION_2_0) {
  916. if (snd_soc_component_read32(component, adc_mux_reg)
  917. & SWR_MIC)
  918. snd_soc_component_update_bits(component,
  919. BOLERO_CDC_TX_TOP_CSR_SWR_CTRL,
  920. 0x01, 0x00);
  921. }
  922. break;
  923. case SND_SOC_DAPM_POST_PMD:
  924. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  925. 0x20, 0x00);
  926. snd_soc_component_update_bits(component,
  927. dec_cfg_reg, 0x06, 0x00);
  928. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  929. 0x10, 0x00);
  930. if (tx_priv->bcs_enable) {
  931. snd_soc_component_update_bits(component, dec_cfg_reg,
  932. 0x01, 0x00);
  933. snd_soc_component_update_bits(component,
  934. BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40, 0x00);
  935. tx_priv->bcs_clk_en = false;
  936. if (tx_priv->version == BOLERO_VERSION_2_1)
  937. snd_soc_component_update_bits(component,
  938. BOLERO_CDC_VA_TOP_CSR_SWR_CTRL, 0x0F,
  939. 0x00);
  940. else if (tx_priv->version == BOLERO_VERSION_2_0)
  941. snd_soc_component_update_bits(component,
  942. BOLERO_CDC_TX_TOP_CSR_SWR_CTRL, 0xF0,
  943. 0x00);
  944. }
  945. break;
  946. }
  947. return 0;
  948. }
  949. static int tx_macro_enable_micbias(struct snd_soc_dapm_widget *w,
  950. struct snd_kcontrol *kcontrol, int event)
  951. {
  952. return 0;
  953. }
  954. /* Cutoff frequency for high pass filter */
  955. static const char * const cf_text[] = {
  956. "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
  957. };
  958. static SOC_ENUM_SINGLE_DECL(cf_dec0_enum, BOLERO_CDC_TX0_TX_PATH_CFG0, 5,
  959. cf_text);
  960. static SOC_ENUM_SINGLE_DECL(cf_dec1_enum, BOLERO_CDC_TX1_TX_PATH_CFG0, 5,
  961. cf_text);
  962. static SOC_ENUM_SINGLE_DECL(cf_dec2_enum, BOLERO_CDC_TX2_TX_PATH_CFG0, 5,
  963. cf_text);
  964. static SOC_ENUM_SINGLE_DECL(cf_dec3_enum, BOLERO_CDC_TX3_TX_PATH_CFG0, 5,
  965. cf_text);
  966. static SOC_ENUM_SINGLE_DECL(cf_dec4_enum, BOLERO_CDC_TX4_TX_PATH_CFG0, 5,
  967. cf_text);
  968. static SOC_ENUM_SINGLE_DECL(cf_dec5_enum, BOLERO_CDC_TX5_TX_PATH_CFG0, 5,
  969. cf_text);
  970. static SOC_ENUM_SINGLE_DECL(cf_dec6_enum, BOLERO_CDC_TX6_TX_PATH_CFG0, 5,
  971. cf_text);
  972. static SOC_ENUM_SINGLE_DECL(cf_dec7_enum, BOLERO_CDC_TX7_TX_PATH_CFG0, 5,
  973. cf_text);
  974. static int tx_macro_hw_params(struct snd_pcm_substream *substream,
  975. struct snd_pcm_hw_params *params,
  976. struct snd_soc_dai *dai)
  977. {
  978. int tx_fs_rate = -EINVAL;
  979. struct snd_soc_component *component = dai->component;
  980. u32 decimator = 0;
  981. u32 sample_rate = 0;
  982. u16 tx_fs_reg = 0;
  983. struct device *tx_dev = NULL;
  984. struct tx_macro_priv *tx_priv = NULL;
  985. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  986. return -EINVAL;
  987. pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  988. dai->name, dai->id, params_rate(params),
  989. params_channels(params));
  990. sample_rate = params_rate(params);
  991. switch (sample_rate) {
  992. case 8000:
  993. tx_fs_rate = 0;
  994. break;
  995. case 16000:
  996. tx_fs_rate = 1;
  997. break;
  998. case 32000:
  999. tx_fs_rate = 3;
  1000. break;
  1001. case 48000:
  1002. tx_fs_rate = 4;
  1003. break;
  1004. case 96000:
  1005. tx_fs_rate = 5;
  1006. break;
  1007. case 192000:
  1008. tx_fs_rate = 6;
  1009. break;
  1010. case 384000:
  1011. tx_fs_rate = 7;
  1012. break;
  1013. default:
  1014. dev_err(component->dev, "%s: Invalid TX sample rate: %d\n",
  1015. __func__, params_rate(params));
  1016. return -EINVAL;
  1017. }
  1018. for_each_set_bit(decimator, &tx_priv->active_ch_mask[dai->id],
  1019. TX_MACRO_DEC_MAX) {
  1020. if (decimator >= 0) {
  1021. tx_fs_reg = BOLERO_CDC_TX0_TX_PATH_CTL +
  1022. TX_MACRO_TX_PATH_OFFSET * decimator;
  1023. dev_dbg(component->dev, "%s: set DEC%u rate to %u\n",
  1024. __func__, decimator, sample_rate);
  1025. snd_soc_component_update_bits(component, tx_fs_reg,
  1026. 0x0F, tx_fs_rate);
  1027. } else {
  1028. dev_err(component->dev,
  1029. "%s: ERROR: Invalid decimator: %d\n",
  1030. __func__, decimator);
  1031. return -EINVAL;
  1032. }
  1033. }
  1034. return 0;
  1035. }
  1036. static int tx_macro_get_channel_map(struct snd_soc_dai *dai,
  1037. unsigned int *tx_num, unsigned int *tx_slot,
  1038. unsigned int *rx_num, unsigned int *rx_slot)
  1039. {
  1040. struct snd_soc_component *component = dai->component;
  1041. struct device *tx_dev = NULL;
  1042. struct tx_macro_priv *tx_priv = NULL;
  1043. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  1044. return -EINVAL;
  1045. switch (dai->id) {
  1046. case TX_MACRO_AIF1_CAP:
  1047. case TX_MACRO_AIF2_CAP:
  1048. case TX_MACRO_AIF3_CAP:
  1049. *tx_slot = tx_priv->active_ch_mask[dai->id];
  1050. *tx_num = tx_priv->active_ch_cnt[dai->id];
  1051. break;
  1052. default:
  1053. dev_err(tx_dev, "%s: Invalid AIF\n", __func__);
  1054. break;
  1055. }
  1056. return 0;
  1057. }
  1058. static struct snd_soc_dai_ops tx_macro_dai_ops = {
  1059. .hw_params = tx_macro_hw_params,
  1060. .get_channel_map = tx_macro_get_channel_map,
  1061. };
  1062. static struct snd_soc_dai_driver tx_macro_dai[] = {
  1063. {
  1064. .name = "tx_macro_tx1",
  1065. .id = TX_MACRO_AIF1_CAP,
  1066. .capture = {
  1067. .stream_name = "TX_AIF1 Capture",
  1068. .rates = TX_MACRO_RATES,
  1069. .formats = TX_MACRO_FORMATS,
  1070. .rate_max = 192000,
  1071. .rate_min = 8000,
  1072. .channels_min = 1,
  1073. .channels_max = 8,
  1074. },
  1075. .ops = &tx_macro_dai_ops,
  1076. },
  1077. {
  1078. .name = "tx_macro_tx2",
  1079. .id = TX_MACRO_AIF2_CAP,
  1080. .capture = {
  1081. .stream_name = "TX_AIF2 Capture",
  1082. .rates = TX_MACRO_RATES,
  1083. .formats = TX_MACRO_FORMATS,
  1084. .rate_max = 192000,
  1085. .rate_min = 8000,
  1086. .channels_min = 1,
  1087. .channels_max = 8,
  1088. },
  1089. .ops = &tx_macro_dai_ops,
  1090. },
  1091. {
  1092. .name = "tx_macro_tx3",
  1093. .id = TX_MACRO_AIF3_CAP,
  1094. .capture = {
  1095. .stream_name = "TX_AIF3 Capture",
  1096. .rates = TX_MACRO_RATES,
  1097. .formats = TX_MACRO_FORMATS,
  1098. .rate_max = 192000,
  1099. .rate_min = 8000,
  1100. .channels_min = 1,
  1101. .channels_max = 8,
  1102. },
  1103. .ops = &tx_macro_dai_ops,
  1104. },
  1105. };
  1106. #define STRING(name) #name
  1107. #define TX_MACRO_DAPM_ENUM(name, reg, offset, text) \
  1108. static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
  1109. static const struct snd_kcontrol_new name##_mux = \
  1110. SOC_DAPM_ENUM(STRING(name), name##_enum)
  1111. #define TX_MACRO_DAPM_ENUM_EXT(name, reg, offset, text, getname, putname) \
  1112. static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
  1113. static const struct snd_kcontrol_new name##_mux = \
  1114. SOC_DAPM_ENUM_EXT(STRING(name), name##_enum, getname, putname)
  1115. #define TX_MACRO_DAPM_MUX(name, shift, kctl) \
  1116. SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, shift, 0, &kctl##_mux)
  1117. static const char * const adc_mux_text[] = {
  1118. "MSM_DMIC", "SWR_MIC", "ANC_FB_TUNE1"
  1119. };
  1120. TX_MACRO_DAPM_ENUM(tx_dec0, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG1,
  1121. 0, adc_mux_text);
  1122. TX_MACRO_DAPM_ENUM(tx_dec1, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG1,
  1123. 0, adc_mux_text);
  1124. TX_MACRO_DAPM_ENUM(tx_dec2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG1,
  1125. 0, adc_mux_text);
  1126. TX_MACRO_DAPM_ENUM(tx_dec3, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG1,
  1127. 0, adc_mux_text);
  1128. TX_MACRO_DAPM_ENUM(tx_dec4, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG1,
  1129. 0, adc_mux_text);
  1130. TX_MACRO_DAPM_ENUM(tx_dec5, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG1,
  1131. 0, adc_mux_text);
  1132. TX_MACRO_DAPM_ENUM(tx_dec6, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG1,
  1133. 0, adc_mux_text);
  1134. TX_MACRO_DAPM_ENUM(tx_dec7, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG1,
  1135. 0, adc_mux_text);
  1136. static const char * const dmic_mux_text[] = {
  1137. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3",
  1138. "DMIC4", "DMIC5", "DMIC6", "DMIC7"
  1139. };
  1140. TX_MACRO_DAPM_ENUM_EXT(tx_dmic0, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0,
  1141. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1142. tx_macro_put_dec_enum);
  1143. TX_MACRO_DAPM_ENUM_EXT(tx_dmic1, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0,
  1144. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1145. tx_macro_put_dec_enum);
  1146. TX_MACRO_DAPM_ENUM_EXT(tx_dmic2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0,
  1147. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1148. tx_macro_put_dec_enum);
  1149. TX_MACRO_DAPM_ENUM_EXT(tx_dmic3, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0,
  1150. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1151. tx_macro_put_dec_enum);
  1152. TX_MACRO_DAPM_ENUM_EXT(tx_dmic4, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0,
  1153. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1154. tx_macro_put_dec_enum);
  1155. TX_MACRO_DAPM_ENUM_EXT(tx_dmic5, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0,
  1156. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1157. tx_macro_put_dec_enum);
  1158. TX_MACRO_DAPM_ENUM_EXT(tx_dmic6, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0,
  1159. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1160. tx_macro_put_dec_enum);
  1161. TX_MACRO_DAPM_ENUM_EXT(tx_dmic7, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0,
  1162. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1163. tx_macro_put_dec_enum);
  1164. static const char * const smic_mux_text[] = {
  1165. "ZERO", "ADC0", "ADC1", "ADC2", "ADC3", "SWR_DMIC0",
  1166. "SWR_DMIC1", "SWR_DMIC2", "SWR_DMIC3", "SWR_DMIC4",
  1167. "SWR_DMIC5", "SWR_DMIC6", "SWR_DMIC7"
  1168. };
  1169. TX_MACRO_DAPM_ENUM_EXT(tx_smic0, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0,
  1170. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1171. tx_macro_put_dec_enum);
  1172. TX_MACRO_DAPM_ENUM_EXT(tx_smic1, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0,
  1173. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1174. tx_macro_put_dec_enum);
  1175. TX_MACRO_DAPM_ENUM_EXT(tx_smic2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0,
  1176. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1177. tx_macro_put_dec_enum);
  1178. TX_MACRO_DAPM_ENUM_EXT(tx_smic3, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0,
  1179. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1180. tx_macro_put_dec_enum);
  1181. TX_MACRO_DAPM_ENUM_EXT(tx_smic4, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0,
  1182. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1183. tx_macro_put_dec_enum);
  1184. TX_MACRO_DAPM_ENUM_EXT(tx_smic5, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0,
  1185. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1186. tx_macro_put_dec_enum);
  1187. TX_MACRO_DAPM_ENUM_EXT(tx_smic6, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0,
  1188. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1189. tx_macro_put_dec_enum);
  1190. TX_MACRO_DAPM_ENUM_EXT(tx_smic7, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0,
  1191. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1192. tx_macro_put_dec_enum);
  1193. static const char * const smic_mux_text_v2[] = {
  1194. "ZERO", "SWR_MIC0", "SWR_MIC1", "SWR_MIC2", "SWR_MIC3",
  1195. "SWR_MIC4", "SWR_MIC5", "SWR_MIC6", "SWR_MIC7",
  1196. "SWR_MIC8", "SWR_MIC9", "SWR_MIC10", "SWR_MIC11"
  1197. };
  1198. TX_MACRO_DAPM_ENUM_EXT(tx_smic0_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0,
  1199. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1200. tx_macro_put_dec_enum);
  1201. TX_MACRO_DAPM_ENUM_EXT(tx_smic1_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0,
  1202. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1203. tx_macro_put_dec_enum);
  1204. TX_MACRO_DAPM_ENUM_EXT(tx_smic2_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0,
  1205. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1206. tx_macro_put_dec_enum);
  1207. TX_MACRO_DAPM_ENUM_EXT(tx_smic3_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0,
  1208. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1209. tx_macro_put_dec_enum);
  1210. TX_MACRO_DAPM_ENUM_EXT(tx_smic4_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0,
  1211. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1212. tx_macro_put_dec_enum);
  1213. TX_MACRO_DAPM_ENUM_EXT(tx_smic5_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0,
  1214. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1215. tx_macro_put_dec_enum);
  1216. TX_MACRO_DAPM_ENUM_EXT(tx_smic6_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0,
  1217. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1218. tx_macro_put_dec_enum);
  1219. TX_MACRO_DAPM_ENUM_EXT(tx_smic7_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0,
  1220. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1221. tx_macro_put_dec_enum);
  1222. static const char * const dec_mode_mux_text[] = {
  1223. "ADC_DEFAULT", "ADC_LOW_PWR", "ADC_HIGH_PERF",
  1224. };
  1225. static const struct soc_enum dec_mode_mux_enum =
  1226. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(dec_mode_mux_text),
  1227. dec_mode_mux_text);
  1228. static const char * const bcs_ch_enum_text[] = {
  1229. "CH0", "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8", "CH9",
  1230. "CH10", "CH11",
  1231. };
  1232. static const struct soc_enum bcs_ch_enum =
  1233. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(bcs_ch_enum_text),
  1234. bcs_ch_enum_text);
  1235. static const struct snd_kcontrol_new tx_aif1_cap_mixer[] = {
  1236. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1237. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1238. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1239. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1240. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1241. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1242. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1243. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1244. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, TX_MACRO_DEC4, 1, 0,
  1245. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1246. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, TX_MACRO_DEC5, 1, 0,
  1247. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1248. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, TX_MACRO_DEC6, 1, 0,
  1249. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1250. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, TX_MACRO_DEC7, 1, 0,
  1251. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1252. };
  1253. static const struct snd_kcontrol_new tx_aif2_cap_mixer[] = {
  1254. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1255. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1256. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1257. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1258. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1259. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1260. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1261. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1262. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, TX_MACRO_DEC4, 1, 0,
  1263. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1264. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, TX_MACRO_DEC5, 1, 0,
  1265. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1266. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, TX_MACRO_DEC6, 1, 0,
  1267. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1268. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, TX_MACRO_DEC7, 1, 0,
  1269. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1270. };
  1271. static const struct snd_kcontrol_new tx_aif3_cap_mixer[] = {
  1272. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1273. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1274. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1275. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1276. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1277. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1278. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1279. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1280. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, TX_MACRO_DEC4, 1, 0,
  1281. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1282. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, TX_MACRO_DEC5, 1, 0,
  1283. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1284. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, TX_MACRO_DEC6, 1, 0,
  1285. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1286. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, TX_MACRO_DEC7, 1, 0,
  1287. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1288. };
  1289. static const struct snd_kcontrol_new tx_aif1_cap_mixer_v2[] = {
  1290. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1291. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1292. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1293. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1294. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1295. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1296. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1297. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1298. };
  1299. static const struct snd_kcontrol_new tx_aif2_cap_mixer_v2[] = {
  1300. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1301. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1302. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1303. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1304. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1305. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1306. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1307. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1308. };
  1309. static const struct snd_kcontrol_new tx_aif3_cap_mixer_v2[] = {
  1310. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1311. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1312. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1313. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1314. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1315. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1316. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1317. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1318. };
  1319. static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_common[] = {
  1320. SND_SOC_DAPM_AIF_OUT("TX_AIF1 CAP", "TX_AIF1 Capture", 0,
  1321. SND_SOC_NOPM, TX_MACRO_AIF1_CAP, 0),
  1322. SND_SOC_DAPM_AIF_OUT("TX_AIF2 CAP", "TX_AIF2 Capture", 0,
  1323. SND_SOC_NOPM, TX_MACRO_AIF2_CAP, 0),
  1324. SND_SOC_DAPM_AIF_OUT("TX_AIF3 CAP", "TX_AIF3 Capture", 0,
  1325. SND_SOC_NOPM, TX_MACRO_AIF3_CAP, 0),
  1326. TX_MACRO_DAPM_MUX("TX DMIC MUX0", 0, tx_dmic0),
  1327. TX_MACRO_DAPM_MUX("TX DMIC MUX1", 0, tx_dmic1),
  1328. TX_MACRO_DAPM_MUX("TX DMIC MUX2", 0, tx_dmic2),
  1329. TX_MACRO_DAPM_MUX("TX DMIC MUX3", 0, tx_dmic3),
  1330. TX_MACRO_DAPM_MUX("TX SMIC MUX0", 0, tx_smic0_v2),
  1331. TX_MACRO_DAPM_MUX("TX SMIC MUX1", 0, tx_smic1_v2),
  1332. TX_MACRO_DAPM_MUX("TX SMIC MUX2", 0, tx_smic2_v2),
  1333. TX_MACRO_DAPM_MUX("TX SMIC MUX3", 0, tx_smic3_v2),
  1334. SND_SOC_DAPM_SUPPLY("TX MIC BIAS1", SND_SOC_NOPM, 0, 0,
  1335. tx_macro_enable_micbias,
  1336. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1337. SND_SOC_DAPM_ADC_E("TX DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  1338. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1339. SND_SOC_DAPM_POST_PMD),
  1340. SND_SOC_DAPM_ADC_E("TX DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  1341. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1342. SND_SOC_DAPM_POST_PMD),
  1343. SND_SOC_DAPM_ADC_E("TX DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  1344. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1345. SND_SOC_DAPM_POST_PMD),
  1346. SND_SOC_DAPM_ADC_E("TX DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  1347. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1348. SND_SOC_DAPM_POST_PMD),
  1349. SND_SOC_DAPM_ADC_E("TX DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  1350. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1351. SND_SOC_DAPM_POST_PMD),
  1352. SND_SOC_DAPM_ADC_E("TX DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  1353. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1354. SND_SOC_DAPM_POST_PMD),
  1355. SND_SOC_DAPM_ADC_E("TX DMIC6", NULL, SND_SOC_NOPM, 0, 0,
  1356. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1357. SND_SOC_DAPM_POST_PMD),
  1358. SND_SOC_DAPM_ADC_E("TX DMIC7", NULL, SND_SOC_NOPM, 0, 0,
  1359. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1360. SND_SOC_DAPM_POST_PMD),
  1361. SND_SOC_DAPM_INPUT("TX SWR_INPUT"),
  1362. SND_SOC_DAPM_MUX_E("TX DEC0 MUX", SND_SOC_NOPM,
  1363. TX_MACRO_DEC0, 0,
  1364. &tx_dec0_mux, tx_macro_enable_dec,
  1365. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1366. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1367. SND_SOC_DAPM_MUX_E("TX DEC1 MUX", SND_SOC_NOPM,
  1368. TX_MACRO_DEC1, 0,
  1369. &tx_dec1_mux, tx_macro_enable_dec,
  1370. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1371. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1372. SND_SOC_DAPM_MUX_E("TX DEC2 MUX", SND_SOC_NOPM,
  1373. TX_MACRO_DEC2, 0,
  1374. &tx_dec2_mux, tx_macro_enable_dec,
  1375. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1376. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1377. SND_SOC_DAPM_MUX_E("TX DEC3 MUX", SND_SOC_NOPM,
  1378. TX_MACRO_DEC3, 0,
  1379. &tx_dec3_mux, tx_macro_enable_dec,
  1380. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1381. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1382. SND_SOC_DAPM_SUPPLY_S("TX_MCLK", 0, SND_SOC_NOPM, 0, 0,
  1383. tx_macro_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1384. };
  1385. static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_v2[] = {
  1386. SND_SOC_DAPM_MIXER("TX_AIF1_CAP Mixer", SND_SOC_NOPM,
  1387. TX_MACRO_AIF1_CAP, 0,
  1388. tx_aif1_cap_mixer_v2, ARRAY_SIZE(tx_aif1_cap_mixer_v2)),
  1389. SND_SOC_DAPM_MIXER("TX_AIF2_CAP Mixer", SND_SOC_NOPM,
  1390. TX_MACRO_AIF2_CAP, 0,
  1391. tx_aif2_cap_mixer_v2, ARRAY_SIZE(tx_aif2_cap_mixer_v2)),
  1392. SND_SOC_DAPM_MIXER("TX_AIF3_CAP Mixer", SND_SOC_NOPM,
  1393. TX_MACRO_AIF3_CAP, 0,
  1394. tx_aif3_cap_mixer_v2, ARRAY_SIZE(tx_aif3_cap_mixer_v2)),
  1395. };
  1396. static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_v3[] = {
  1397. SND_SOC_DAPM_MIXER("TX_AIF1_CAP Mixer", SND_SOC_NOPM,
  1398. TX_MACRO_AIF1_CAP, 0,
  1399. tx_aif1_cap_mixer, ARRAY_SIZE(tx_aif1_cap_mixer)),
  1400. SND_SOC_DAPM_MIXER("TX_AIF2_CAP Mixer", SND_SOC_NOPM,
  1401. TX_MACRO_AIF2_CAP, 0,
  1402. tx_aif2_cap_mixer, ARRAY_SIZE(tx_aif2_cap_mixer)),
  1403. SND_SOC_DAPM_MIXER("TX_AIF3_CAP Mixer", SND_SOC_NOPM,
  1404. TX_MACRO_AIF3_CAP, 0,
  1405. tx_aif3_cap_mixer, ARRAY_SIZE(tx_aif3_cap_mixer)),
  1406. TX_MACRO_DAPM_MUX("TX DMIC MUX4", 0, tx_dmic4),
  1407. TX_MACRO_DAPM_MUX("TX DMIC MUX5", 0, tx_dmic5),
  1408. TX_MACRO_DAPM_MUX("TX DMIC MUX6", 0, tx_dmic6),
  1409. TX_MACRO_DAPM_MUX("TX DMIC MUX7", 0, tx_dmic7),
  1410. TX_MACRO_DAPM_MUX("TX SMIC MUX4", 0, tx_smic4_v3),
  1411. TX_MACRO_DAPM_MUX("TX SMIC MUX5", 0, tx_smic5_v3),
  1412. TX_MACRO_DAPM_MUX("TX SMIC MUX6", 0, tx_smic6_v3),
  1413. TX_MACRO_DAPM_MUX("TX SMIC MUX7", 0, tx_smic7_v3),
  1414. SND_SOC_DAPM_MUX_E("TX DEC4 MUX", SND_SOC_NOPM,
  1415. TX_MACRO_DEC4, 0,
  1416. &tx_dec4_mux, tx_macro_enable_dec,
  1417. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1418. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1419. SND_SOC_DAPM_MUX_E("TX DEC5 MUX", SND_SOC_NOPM,
  1420. TX_MACRO_DEC5, 0,
  1421. &tx_dec5_mux, tx_macro_enable_dec,
  1422. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1423. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1424. SND_SOC_DAPM_MUX_E("TX DEC6 MUX", SND_SOC_NOPM,
  1425. TX_MACRO_DEC6, 0,
  1426. &tx_dec6_mux, tx_macro_enable_dec,
  1427. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1428. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1429. SND_SOC_DAPM_MUX_E("TX DEC7 MUX", SND_SOC_NOPM,
  1430. TX_MACRO_DEC7, 0,
  1431. &tx_dec7_mux, tx_macro_enable_dec,
  1432. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1433. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1434. SND_SOC_DAPM_SUPPLY_S("TX_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
  1435. tx_macro_tx_swr_clk_event,
  1436. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1437. SND_SOC_DAPM_SUPPLY_S("VA_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
  1438. tx_macro_va_swr_clk_event,
  1439. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1440. };
  1441. static const struct snd_soc_dapm_widget tx_macro_dapm_widgets[] = {
  1442. SND_SOC_DAPM_AIF_OUT("TX_AIF1 CAP", "TX_AIF1 Capture", 0,
  1443. SND_SOC_NOPM, TX_MACRO_AIF1_CAP, 0),
  1444. SND_SOC_DAPM_AIF_OUT("TX_AIF2 CAP", "TX_AIF2 Capture", 0,
  1445. SND_SOC_NOPM, TX_MACRO_AIF2_CAP, 0),
  1446. SND_SOC_DAPM_AIF_OUT("TX_AIF3 CAP", "TX_AIF3 Capture", 0,
  1447. SND_SOC_NOPM, TX_MACRO_AIF3_CAP, 0),
  1448. SND_SOC_DAPM_MIXER("TX_AIF1_CAP Mixer", SND_SOC_NOPM, TX_MACRO_AIF1_CAP, 0,
  1449. tx_aif1_cap_mixer, ARRAY_SIZE(tx_aif1_cap_mixer)),
  1450. SND_SOC_DAPM_MIXER("TX_AIF2_CAP Mixer", SND_SOC_NOPM, TX_MACRO_AIF2_CAP, 0,
  1451. tx_aif2_cap_mixer, ARRAY_SIZE(tx_aif2_cap_mixer)),
  1452. SND_SOC_DAPM_MIXER("TX_AIF3_CAP Mixer", SND_SOC_NOPM, TX_MACRO_AIF3_CAP, 0,
  1453. tx_aif3_cap_mixer, ARRAY_SIZE(tx_aif3_cap_mixer)),
  1454. TX_MACRO_DAPM_MUX("TX DMIC MUX0", 0, tx_dmic0),
  1455. TX_MACRO_DAPM_MUX("TX DMIC MUX1", 0, tx_dmic1),
  1456. TX_MACRO_DAPM_MUX("TX DMIC MUX2", 0, tx_dmic2),
  1457. TX_MACRO_DAPM_MUX("TX DMIC MUX3", 0, tx_dmic3),
  1458. TX_MACRO_DAPM_MUX("TX DMIC MUX4", 0, tx_dmic4),
  1459. TX_MACRO_DAPM_MUX("TX DMIC MUX5", 0, tx_dmic5),
  1460. TX_MACRO_DAPM_MUX("TX DMIC MUX6", 0, tx_dmic6),
  1461. TX_MACRO_DAPM_MUX("TX DMIC MUX7", 0, tx_dmic7),
  1462. TX_MACRO_DAPM_MUX("TX SMIC MUX0", 0, tx_smic0),
  1463. TX_MACRO_DAPM_MUX("TX SMIC MUX1", 0, tx_smic1),
  1464. TX_MACRO_DAPM_MUX("TX SMIC MUX2", 0, tx_smic2),
  1465. TX_MACRO_DAPM_MUX("TX SMIC MUX3", 0, tx_smic3),
  1466. TX_MACRO_DAPM_MUX("TX SMIC MUX4", 0, tx_smic4),
  1467. TX_MACRO_DAPM_MUX("TX SMIC MUX5", 0, tx_smic5),
  1468. TX_MACRO_DAPM_MUX("TX SMIC MUX6", 0, tx_smic6),
  1469. TX_MACRO_DAPM_MUX("TX SMIC MUX7", 0, tx_smic7),
  1470. SND_SOC_DAPM_SUPPLY("TX MIC BIAS1", SND_SOC_NOPM, 0, 0,
  1471. tx_macro_enable_micbias,
  1472. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1473. SND_SOC_DAPM_ADC_E("TX DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  1474. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1475. SND_SOC_DAPM_POST_PMD),
  1476. SND_SOC_DAPM_ADC_E("TX DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  1477. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1478. SND_SOC_DAPM_POST_PMD),
  1479. SND_SOC_DAPM_ADC_E("TX DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  1480. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1481. SND_SOC_DAPM_POST_PMD),
  1482. SND_SOC_DAPM_ADC_E("TX DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  1483. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1484. SND_SOC_DAPM_POST_PMD),
  1485. SND_SOC_DAPM_ADC_E("TX DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  1486. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1487. SND_SOC_DAPM_POST_PMD),
  1488. SND_SOC_DAPM_ADC_E("TX DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  1489. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1490. SND_SOC_DAPM_POST_PMD),
  1491. SND_SOC_DAPM_ADC_E("TX DMIC6", NULL, SND_SOC_NOPM, 0, 0,
  1492. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1493. SND_SOC_DAPM_POST_PMD),
  1494. SND_SOC_DAPM_ADC_E("TX DMIC7", NULL, SND_SOC_NOPM, 0, 0,
  1495. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1496. SND_SOC_DAPM_POST_PMD),
  1497. SND_SOC_DAPM_INPUT("TX SWR_ADC0"),
  1498. SND_SOC_DAPM_INPUT("TX SWR_ADC1"),
  1499. SND_SOC_DAPM_INPUT("TX SWR_ADC2"),
  1500. SND_SOC_DAPM_INPUT("TX SWR_ADC3"),
  1501. SND_SOC_DAPM_INPUT("TX SWR_DMIC0"),
  1502. SND_SOC_DAPM_INPUT("TX SWR_DMIC1"),
  1503. SND_SOC_DAPM_INPUT("TX SWR_DMIC2"),
  1504. SND_SOC_DAPM_INPUT("TX SWR_DMIC3"),
  1505. SND_SOC_DAPM_INPUT("TX SWR_DMIC4"),
  1506. SND_SOC_DAPM_INPUT("TX SWR_DMIC5"),
  1507. SND_SOC_DAPM_INPUT("TX SWR_DMIC6"),
  1508. SND_SOC_DAPM_INPUT("TX SWR_DMIC7"),
  1509. SND_SOC_DAPM_MUX_E("TX DEC0 MUX", SND_SOC_NOPM,
  1510. TX_MACRO_DEC0, 0,
  1511. &tx_dec0_mux, tx_macro_enable_dec,
  1512. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1513. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1514. SND_SOC_DAPM_MUX_E("TX DEC1 MUX", SND_SOC_NOPM,
  1515. TX_MACRO_DEC1, 0,
  1516. &tx_dec1_mux, tx_macro_enable_dec,
  1517. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1518. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1519. SND_SOC_DAPM_MUX_E("TX DEC2 MUX", SND_SOC_NOPM,
  1520. TX_MACRO_DEC2, 0,
  1521. &tx_dec2_mux, tx_macro_enable_dec,
  1522. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1523. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1524. SND_SOC_DAPM_MUX_E("TX DEC3 MUX", SND_SOC_NOPM,
  1525. TX_MACRO_DEC3, 0,
  1526. &tx_dec3_mux, tx_macro_enable_dec,
  1527. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1528. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1529. SND_SOC_DAPM_MUX_E("TX DEC4 MUX", SND_SOC_NOPM,
  1530. TX_MACRO_DEC4, 0,
  1531. &tx_dec4_mux, tx_macro_enable_dec,
  1532. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1533. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1534. SND_SOC_DAPM_MUX_E("TX DEC5 MUX", SND_SOC_NOPM,
  1535. TX_MACRO_DEC5, 0,
  1536. &tx_dec5_mux, tx_macro_enable_dec,
  1537. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1538. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1539. SND_SOC_DAPM_MUX_E("TX DEC6 MUX", SND_SOC_NOPM,
  1540. TX_MACRO_DEC6, 0,
  1541. &tx_dec6_mux, tx_macro_enable_dec,
  1542. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1543. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1544. SND_SOC_DAPM_MUX_E("TX DEC7 MUX", SND_SOC_NOPM,
  1545. TX_MACRO_DEC7, 0,
  1546. &tx_dec7_mux, tx_macro_enable_dec,
  1547. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1548. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1549. SND_SOC_DAPM_SUPPLY_S("TX_MCLK", 0, SND_SOC_NOPM, 0, 0,
  1550. tx_macro_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1551. SND_SOC_DAPM_SUPPLY_S("TX_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
  1552. tx_macro_tx_swr_clk_event,
  1553. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1554. SND_SOC_DAPM_SUPPLY_S("VA_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
  1555. tx_macro_va_swr_clk_event,
  1556. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1557. };
  1558. static const struct snd_soc_dapm_route tx_audio_map_common[] = {
  1559. {"TX_AIF1 CAP", NULL, "TX_MCLK"},
  1560. {"TX_AIF2 CAP", NULL, "TX_MCLK"},
  1561. {"TX_AIF3 CAP", NULL, "TX_MCLK"},
  1562. {"TX_AIF1 CAP", NULL, "TX_AIF1_CAP Mixer"},
  1563. {"TX_AIF2 CAP", NULL, "TX_AIF2_CAP Mixer"},
  1564. {"TX_AIF3 CAP", NULL, "TX_AIF3_CAP Mixer"},
  1565. {"TX_AIF1_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1566. {"TX_AIF1_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1567. {"TX_AIF1_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1568. {"TX_AIF1_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1569. {"TX_AIF2_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1570. {"TX_AIF2_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1571. {"TX_AIF2_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1572. {"TX_AIF2_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1573. {"TX_AIF3_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1574. {"TX_AIF3_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1575. {"TX_AIF3_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1576. {"TX_AIF3_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1577. {"TX DEC0 MUX", NULL, "TX_MCLK"},
  1578. {"TX DEC1 MUX", NULL, "TX_MCLK"},
  1579. {"TX DEC2 MUX", NULL, "TX_MCLK"},
  1580. {"TX DEC3 MUX", NULL, "TX_MCLK"},
  1581. {"TX DEC0 MUX", "MSM_DMIC", "TX DMIC MUX0"},
  1582. {"TX DMIC MUX0", "DMIC0", "TX DMIC0"},
  1583. {"TX DMIC MUX0", "DMIC1", "TX DMIC1"},
  1584. {"TX DMIC MUX0", "DMIC2", "TX DMIC2"},
  1585. {"TX DMIC MUX0", "DMIC3", "TX DMIC3"},
  1586. {"TX DMIC MUX0", "DMIC4", "TX DMIC4"},
  1587. {"TX DMIC MUX0", "DMIC5", "TX DMIC5"},
  1588. {"TX DMIC MUX0", "DMIC6", "TX DMIC6"},
  1589. {"TX DMIC MUX0", "DMIC7", "TX DMIC7"},
  1590. {"TX DEC0 MUX", "SWR_MIC", "TX SMIC MUX0"},
  1591. {"TX SMIC MUX0", "SWR_MIC0", "TX SWR_INPUT"},
  1592. {"TX SMIC MUX0", "SWR_MIC1", "TX SWR_INPUT"},
  1593. {"TX SMIC MUX0", "SWR_MIC2", "TX SWR_INPUT"},
  1594. {"TX SMIC MUX0", "SWR_MIC3", "TX SWR_INPUT"},
  1595. {"TX SMIC MUX0", "SWR_MIC4", "TX SWR_INPUT"},
  1596. {"TX SMIC MUX0", "SWR_MIC5", "TX SWR_INPUT"},
  1597. {"TX SMIC MUX0", "SWR_MIC6", "TX SWR_INPUT"},
  1598. {"TX SMIC MUX0", "SWR_MIC7", "TX SWR_INPUT"},
  1599. {"TX SMIC MUX0", "SWR_MIC8", "TX SWR_INPUT"},
  1600. {"TX SMIC MUX0", "SWR_MIC9", "TX SWR_INPUT"},
  1601. {"TX SMIC MUX0", "SWR_MIC10", "TX SWR_INPUT"},
  1602. {"TX SMIC MUX0", "SWR_MIC11", "TX SWR_INPUT"},
  1603. {"TX DEC1 MUX", "MSM_DMIC", "TX DMIC MUX1"},
  1604. {"TX DMIC MUX1", "DMIC0", "TX DMIC0"},
  1605. {"TX DMIC MUX1", "DMIC1", "TX DMIC1"},
  1606. {"TX DMIC MUX1", "DMIC2", "TX DMIC2"},
  1607. {"TX DMIC MUX1", "DMIC3", "TX DMIC3"},
  1608. {"TX DMIC MUX1", "DMIC4", "TX DMIC4"},
  1609. {"TX DMIC MUX1", "DMIC5", "TX DMIC5"},
  1610. {"TX DMIC MUX1", "DMIC6", "TX DMIC6"},
  1611. {"TX DMIC MUX1", "DMIC7", "TX DMIC7"},
  1612. {"TX DEC1 MUX", "SWR_MIC", "TX SMIC MUX1"},
  1613. {"TX SMIC MUX1", "SWR_MIC0", "TX SWR_INPUT"},
  1614. {"TX SMIC MUX1", "SWR_MIC1", "TX SWR_INPUT"},
  1615. {"TX SMIC MUX1", "SWR_MIC2", "TX SWR_INPUT"},
  1616. {"TX SMIC MUX1", "SWR_MIC3", "TX SWR_INPUT"},
  1617. {"TX SMIC MUX1", "SWR_MIC4", "TX SWR_INPUT"},
  1618. {"TX SMIC MUX1", "SWR_MIC5", "TX SWR_INPUT"},
  1619. {"TX SMIC MUX1", "SWR_MIC6", "TX SWR_INPUT"},
  1620. {"TX SMIC MUX1", "SWR_MIC7", "TX SWR_INPUT"},
  1621. {"TX SMIC MUX1", "SWR_MIC8", "TX SWR_INPUT"},
  1622. {"TX SMIC MUX1", "SWR_MIC9", "TX SWR_INPUT"},
  1623. {"TX SMIC MUX1", "SWR_MIC10", "TX SWR_INPUT"},
  1624. {"TX SMIC MUX1", "SWR_MIC11", "TX SWR_INPUT"},
  1625. {"TX DEC2 MUX", "MSM_DMIC", "TX DMIC MUX2"},
  1626. {"TX DMIC MUX2", "DMIC0", "TX DMIC0"},
  1627. {"TX DMIC MUX2", "DMIC1", "TX DMIC1"},
  1628. {"TX DMIC MUX2", "DMIC2", "TX DMIC2"},
  1629. {"TX DMIC MUX2", "DMIC3", "TX DMIC3"},
  1630. {"TX DMIC MUX2", "DMIC4", "TX DMIC4"},
  1631. {"TX DMIC MUX2", "DMIC5", "TX DMIC5"},
  1632. {"TX DMIC MUX2", "DMIC6", "TX DMIC6"},
  1633. {"TX DMIC MUX2", "DMIC7", "TX DMIC7"},
  1634. {"TX DEC2 MUX", "SWR_MIC", "TX SMIC MUX2"},
  1635. {"TX SMIC MUX2", "SWR_MIC0", "TX SWR_INPUT"},
  1636. {"TX SMIC MUX2", "SWR_MIC1", "TX SWR_INPUT"},
  1637. {"TX SMIC MUX2", "SWR_MIC2", "TX SWR_INPUT"},
  1638. {"TX SMIC MUX2", "SWR_MIC3", "TX SWR_INPUT"},
  1639. {"TX SMIC MUX2", "SWR_MIC4", "TX SWR_INPUT"},
  1640. {"TX SMIC MUX2", "SWR_MIC5", "TX SWR_INPUT"},
  1641. {"TX SMIC MUX2", "SWR_MIC6", "TX SWR_INPUT"},
  1642. {"TX SMIC MUX2", "SWR_MIC7", "TX SWR_INPUT"},
  1643. {"TX SMIC MUX2", "SWR_MIC8", "TX SWR_INPUT"},
  1644. {"TX SMIC MUX2", "SWR_MIC9", "TX SWR_INPUT"},
  1645. {"TX SMIC MUX2", "SWR_MIC10", "TX SWR_INPUT"},
  1646. {"TX SMIC MUX2", "SWR_MIC11", "TX SWR_INPUT"},
  1647. {"TX DEC3 MUX", "MSM_DMIC", "TX DMIC MUX3"},
  1648. {"TX DMIC MUX3", "DMIC0", "TX DMIC0"},
  1649. {"TX DMIC MUX3", "DMIC1", "TX DMIC1"},
  1650. {"TX DMIC MUX3", "DMIC2", "TX DMIC2"},
  1651. {"TX DMIC MUX3", "DMIC3", "TX DMIC3"},
  1652. {"TX DMIC MUX3", "DMIC4", "TX DMIC4"},
  1653. {"TX DMIC MUX3", "DMIC5", "TX DMIC5"},
  1654. {"TX DMIC MUX3", "DMIC6", "TX DMIC6"},
  1655. {"TX DMIC MUX3", "DMIC7", "TX DMIC7"},
  1656. {"TX DEC3 MUX", "SWR_MIC", "TX SMIC MUX3"},
  1657. {"TX SMIC MUX3", "SWR_MIC0", "TX SWR_INPUT"},
  1658. {"TX SMIC MUX3", "SWR_MIC1", "TX SWR_INPUT"},
  1659. {"TX SMIC MUX3", "SWR_MIC2", "TX SWR_INPUT"},
  1660. {"TX SMIC MUX3", "SWR_MIC3", "TX SWR_INPUT"},
  1661. {"TX SMIC MUX3", "SWR_MIC4", "TX SWR_INPUT"},
  1662. {"TX SMIC MUX3", "SWR_MIC5", "TX SWR_INPUT"},
  1663. {"TX SMIC MUX3", "SWR_MIC6", "TX SWR_INPUT"},
  1664. {"TX SMIC MUX3", "SWR_MIC7", "TX SWR_INPUT"},
  1665. {"TX SMIC MUX3", "SWR_MIC8", "TX SWR_INPUT"},
  1666. {"TX SMIC MUX3", "SWR_MIC9", "TX SWR_INPUT"},
  1667. {"TX SMIC MUX3", "SWR_MIC10", "TX SWR_INPUT"},
  1668. {"TX SMIC MUX3", "SWR_MIC11", "TX SWR_INPUT"},
  1669. };
  1670. static const struct snd_soc_dapm_route tx_audio_map_v3[] = {
  1671. {"TX_AIF1_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1672. {"TX_AIF1_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1673. {"TX_AIF1_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1674. {"TX_AIF1_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1675. {"TX_AIF2_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1676. {"TX_AIF2_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1677. {"TX_AIF2_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1678. {"TX_AIF2_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1679. {"TX_AIF3_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1680. {"TX_AIF3_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1681. {"TX_AIF3_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1682. {"TX_AIF3_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1683. {"TX DEC4 MUX", NULL, "TX_MCLK"},
  1684. {"TX DEC5 MUX", NULL, "TX_MCLK"},
  1685. {"TX DEC6 MUX", NULL, "TX_MCLK"},
  1686. {"TX DEC7 MUX", NULL, "TX_MCLK"},
  1687. {"TX DEC4 MUX", "MSM_DMIC", "TX DMIC MUX4"},
  1688. {"TX DMIC MUX4", "DMIC0", "TX DMIC0"},
  1689. {"TX DMIC MUX4", "DMIC1", "TX DMIC1"},
  1690. {"TX DMIC MUX4", "DMIC2", "TX DMIC2"},
  1691. {"TX DMIC MUX4", "DMIC3", "TX DMIC3"},
  1692. {"TX DMIC MUX4", "DMIC4", "TX DMIC4"},
  1693. {"TX DMIC MUX4", "DMIC5", "TX DMIC5"},
  1694. {"TX DMIC MUX4", "DMIC6", "TX DMIC6"},
  1695. {"TX DMIC MUX4", "DMIC7", "TX DMIC7"},
  1696. {"TX DEC4 MUX", "SWR_MIC", "TX SMIC MUX4"},
  1697. {"TX SMIC MUX4", "SWR_MIC0", "TX SWR_INPUT"},
  1698. {"TX SMIC MUX4", "SWR_MIC1", "TX SWR_INPUT"},
  1699. {"TX SMIC MUX4", "SWR_MIC2", "TX SWR_INPUT"},
  1700. {"TX SMIC MUX4", "SWR_MIC3", "TX SWR_INPUT"},
  1701. {"TX SMIC MUX4", "SWR_MIC4", "TX SWR_INPUT"},
  1702. {"TX SMIC MUX4", "SWR_MIC5", "TX SWR_INPUT"},
  1703. {"TX SMIC MUX4", "SWR_MIC6", "TX SWR_INPUT"},
  1704. {"TX SMIC MUX4", "SWR_MIC7", "TX SWR_INPUT"},
  1705. {"TX SMIC MUX4", "SWR_MIC8", "TX SWR_INPUT"},
  1706. {"TX SMIC MUX4", "SWR_MIC9", "TX SWR_INPUT"},
  1707. {"TX SMIC MUX4", "SWR_MIC10", "TX SWR_INPUT"},
  1708. {"TX SMIC MUX4", "SWR_MIC11", "TX SWR_INPUT"},
  1709. {"TX DEC5 MUX", "MSM_DMIC", "TX DMIC MUX5"},
  1710. {"TX DMIC MUX5", "DMIC0", "TX DMIC0"},
  1711. {"TX DMIC MUX5", "DMIC1", "TX DMIC1"},
  1712. {"TX DMIC MUX5", "DMIC2", "TX DMIC2"},
  1713. {"TX DMIC MUX5", "DMIC3", "TX DMIC3"},
  1714. {"TX DMIC MUX5", "DMIC4", "TX DMIC4"},
  1715. {"TX DMIC MUX5", "DMIC5", "TX DMIC5"},
  1716. {"TX DMIC MUX5", "DMIC6", "TX DMIC6"},
  1717. {"TX DMIC MUX5", "DMIC7", "TX DMIC7"},
  1718. {"TX DEC5 MUX", "SWR_MIC", "TX SMIC MUX5"},
  1719. {"TX SMIC MUX5", "SWR_MIC0", "TX SWR_INPUT"},
  1720. {"TX SMIC MUX5", "SWR_MIC1", "TX SWR_INPUT"},
  1721. {"TX SMIC MUX5", "SWR_MIC2", "TX SWR_INPUT"},
  1722. {"TX SMIC MUX5", "SWR_MIC3", "TX SWR_INPUT"},
  1723. {"TX SMIC MUX5", "SWR_MIC4", "TX SWR_INPUT"},
  1724. {"TX SMIC MUX5", "SWR_MIC5", "TX SWR_INPUT"},
  1725. {"TX SMIC MUX5", "SWR_MIC6", "TX SWR_INPUT"},
  1726. {"TX SMIC MUX5", "SWR_MIC7", "TX SWR_INPUT"},
  1727. {"TX SMIC MUX5", "SWR_MIC8", "TX SWR_INPUT"},
  1728. {"TX SMIC MUX5", "SWR_MIC9", "TX SWR_INPUT"},
  1729. {"TX SMIC MUX5", "SWR_MIC10", "TX SWR_INPUT"},
  1730. {"TX SMIC MUX5", "SWR_MIC11", "TX SWR_INPUT"},
  1731. {"TX DEC6 MUX", "MSM_DMIC", "TX DMIC MUX6"},
  1732. {"TX DMIC MUX6", "DMIC0", "TX DMIC0"},
  1733. {"TX DMIC MUX6", "DMIC1", "TX DMIC1"},
  1734. {"TX DMIC MUX6", "DMIC2", "TX DMIC2"},
  1735. {"TX DMIC MUX6", "DMIC3", "TX DMIC3"},
  1736. {"TX DMIC MUX6", "DMIC4", "TX DMIC4"},
  1737. {"TX DMIC MUX6", "DMIC5", "TX DMIC5"},
  1738. {"TX DMIC MUX6", "DMIC6", "TX DMIC6"},
  1739. {"TX DMIC MUX6", "DMIC7", "TX DMIC7"},
  1740. {"TX DEC6 MUX", "SWR_MIC", "TX SMIC MUX6"},
  1741. {"TX SMIC MUX6", "SWR_MIC0", "TX SWR_INPUT"},
  1742. {"TX SMIC MUX6", "SWR_MIC1", "TX SWR_INPUT"},
  1743. {"TX SMIC MUX6", "SWR_MIC2", "TX SWR_INPUT"},
  1744. {"TX SMIC MUX6", "SWR_MIC3", "TX SWR_INPUT"},
  1745. {"TX SMIC MUX6", "SWR_MIC4", "TX SWR_INPUT"},
  1746. {"TX SMIC MUX6", "SWR_MIC5", "TX SWR_INPUT"},
  1747. {"TX SMIC MUX6", "SWR_MIC6", "TX SWR_INPUT"},
  1748. {"TX SMIC MUX6", "SWR_MIC7", "TX SWR_INPUT"},
  1749. {"TX SMIC MUX6", "SWR_MIC8", "TX SWR_INPUT"},
  1750. {"TX SMIC MUX6", "SWR_MIC9", "TX SWR_INPUT"},
  1751. {"TX SMIC MUX6", "SWR_MIC10", "TX SWR_INPUT"},
  1752. {"TX SMIC MUX6", "SWR_MIC11", "TX SWR_INPUT"},
  1753. {"TX DEC7 MUX", "MSM_DMIC", "TX DMIC MUX7"},
  1754. {"TX DMIC MUX7", "DMIC0", "TX DMIC0"},
  1755. {"TX DMIC MUX7", "DMIC1", "TX DMIC1"},
  1756. {"TX DMIC MUX7", "DMIC2", "TX DMIC2"},
  1757. {"TX DMIC MUX7", "DMIC3", "TX DMIC3"},
  1758. {"TX DMIC MUX7", "DMIC4", "TX DMIC4"},
  1759. {"TX DMIC MUX7", "DMIC5", "TX DMIC5"},
  1760. {"TX DMIC MUX7", "DMIC6", "TX DMIC6"},
  1761. {"TX DMIC MUX7", "DMIC7", "TX DMIC7"},
  1762. {"TX DEC7 MUX", "SWR_MIC", "TX SMIC MUX7"},
  1763. {"TX SMIC MUX7", "SWR_MIC0", "TX SWR_INPUT"},
  1764. {"TX SMIC MUX7", "SWR_MIC1", "TX SWR_INPUT"},
  1765. {"TX SMIC MUX7", "SWR_MIC2", "TX SWR_INPUT"},
  1766. {"TX SMIC MUX7", "SWR_MIC3", "TX SWR_INPUT"},
  1767. {"TX SMIC MUX7", "SWR_MIC4", "TX SWR_INPUT"},
  1768. {"TX SMIC MUX7", "SWR_MIC5", "TX SWR_INPUT"},
  1769. {"TX SMIC MUX7", "SWR_MIC6", "TX SWR_INPUT"},
  1770. {"TX SMIC MUX7", "SWR_MIC7", "TX SWR_INPUT"},
  1771. {"TX SMIC MUX7", "SWR_MIC8", "TX SWR_INPUT"},
  1772. {"TX SMIC MUX7", "SWR_MIC9", "TX SWR_INPUT"},
  1773. {"TX SMIC MUX7", "SWR_MIC10", "TX SWR_INPUT"},
  1774. {"TX SMIC MUX7", "SWR_MIC11", "TX SWR_INPUT"},
  1775. {"TX SMIC MUX0", NULL, "TX_SWR_CLK"},
  1776. {"TX SMIC MUX1", NULL, "TX_SWR_CLK"},
  1777. {"TX SMIC MUX2", NULL, "TX_SWR_CLK"},
  1778. {"TX SMIC MUX3", NULL, "TX_SWR_CLK"},
  1779. {"TX SMIC MUX4", NULL, "TX_SWR_CLK"},
  1780. {"TX SMIC MUX5", NULL, "TX_SWR_CLK"},
  1781. {"TX SMIC MUX6", NULL, "TX_SWR_CLK"},
  1782. {"TX SMIC MUX7", NULL, "TX_SWR_CLK"},
  1783. };
  1784. static const struct snd_soc_dapm_route tx_audio_map[] = {
  1785. {"TX_AIF1 CAP", NULL, "TX_MCLK"},
  1786. {"TX_AIF2 CAP", NULL, "TX_MCLK"},
  1787. {"TX_AIF3 CAP", NULL, "TX_MCLK"},
  1788. {"TX_AIF1 CAP", NULL, "TX_AIF1_CAP Mixer"},
  1789. {"TX_AIF2 CAP", NULL, "TX_AIF2_CAP Mixer"},
  1790. {"TX_AIF3 CAP", NULL, "TX_AIF3_CAP Mixer"},
  1791. {"TX_AIF1_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1792. {"TX_AIF1_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1793. {"TX_AIF1_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1794. {"TX_AIF1_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1795. {"TX_AIF1_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1796. {"TX_AIF1_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1797. {"TX_AIF1_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1798. {"TX_AIF1_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1799. {"TX_AIF2_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1800. {"TX_AIF2_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1801. {"TX_AIF2_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1802. {"TX_AIF2_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1803. {"TX_AIF2_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1804. {"TX_AIF2_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1805. {"TX_AIF2_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1806. {"TX_AIF2_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1807. {"TX_AIF3_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1808. {"TX_AIF3_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1809. {"TX_AIF3_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1810. {"TX_AIF3_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1811. {"TX_AIF3_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1812. {"TX_AIF3_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1813. {"TX_AIF3_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1814. {"TX_AIF3_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1815. {"TX DEC0 MUX", NULL, "TX_MCLK"},
  1816. {"TX DEC1 MUX", NULL, "TX_MCLK"},
  1817. {"TX DEC2 MUX", NULL, "TX_MCLK"},
  1818. {"TX DEC3 MUX", NULL, "TX_MCLK"},
  1819. {"TX DEC4 MUX", NULL, "TX_MCLK"},
  1820. {"TX DEC5 MUX", NULL, "TX_MCLK"},
  1821. {"TX DEC6 MUX", NULL, "TX_MCLK"},
  1822. {"TX DEC7 MUX", NULL, "TX_MCLK"},
  1823. {"TX DEC0 MUX", "MSM_DMIC", "TX DMIC MUX0"},
  1824. {"TX DMIC MUX0", "DMIC0", "TX DMIC0"},
  1825. {"TX DMIC MUX0", "DMIC1", "TX DMIC1"},
  1826. {"TX DMIC MUX0", "DMIC2", "TX DMIC2"},
  1827. {"TX DMIC MUX0", "DMIC3", "TX DMIC3"},
  1828. {"TX DMIC MUX0", "DMIC4", "TX DMIC4"},
  1829. {"TX DMIC MUX0", "DMIC5", "TX DMIC5"},
  1830. {"TX DMIC MUX0", "DMIC6", "TX DMIC6"},
  1831. {"TX DMIC MUX0", "DMIC7", "TX DMIC7"},
  1832. {"TX DEC0 MUX", "SWR_MIC", "TX SMIC MUX0"},
  1833. {"TX SMIC MUX0", NULL, "TX_SWR_CLK"},
  1834. {"TX SMIC MUX0", "ADC0", "TX SWR_ADC0"},
  1835. {"TX SMIC MUX0", "ADC1", "TX SWR_ADC1"},
  1836. {"TX SMIC MUX0", "ADC2", "TX SWR_ADC2"},
  1837. {"TX SMIC MUX0", "ADC3", "TX SWR_ADC3"},
  1838. {"TX SMIC MUX0", "SWR_DMIC0", "TX SWR_DMIC0"},
  1839. {"TX SMIC MUX0", "SWR_DMIC1", "TX SWR_DMIC1"},
  1840. {"TX SMIC MUX0", "SWR_DMIC2", "TX SWR_DMIC2"},
  1841. {"TX SMIC MUX0", "SWR_DMIC3", "TX SWR_DMIC3"},
  1842. {"TX SMIC MUX0", "SWR_DMIC4", "TX SWR_DMIC4"},
  1843. {"TX SMIC MUX0", "SWR_DMIC5", "TX SWR_DMIC5"},
  1844. {"TX SMIC MUX0", "SWR_DMIC6", "TX SWR_DMIC6"},
  1845. {"TX SMIC MUX0", "SWR_DMIC7", "TX SWR_DMIC7"},
  1846. {"TX DEC1 MUX", "MSM_DMIC", "TX DMIC MUX1"},
  1847. {"TX DMIC MUX1", "DMIC0", "TX DMIC0"},
  1848. {"TX DMIC MUX1", "DMIC1", "TX DMIC1"},
  1849. {"TX DMIC MUX1", "DMIC2", "TX DMIC2"},
  1850. {"TX DMIC MUX1", "DMIC3", "TX DMIC3"},
  1851. {"TX DMIC MUX1", "DMIC4", "TX DMIC4"},
  1852. {"TX DMIC MUX1", "DMIC5", "TX DMIC5"},
  1853. {"TX DMIC MUX1", "DMIC6", "TX DMIC6"},
  1854. {"TX DMIC MUX1", "DMIC7", "TX DMIC7"},
  1855. {"TX DEC1 MUX", "SWR_MIC", "TX SMIC MUX1"},
  1856. {"TX SMIC MUX1", NULL, "TX_SWR_CLK"},
  1857. {"TX SMIC MUX1", "ADC0", "TX SWR_ADC0"},
  1858. {"TX SMIC MUX1", "ADC1", "TX SWR_ADC1"},
  1859. {"TX SMIC MUX1", "ADC2", "TX SWR_ADC2"},
  1860. {"TX SMIC MUX1", "ADC3", "TX SWR_ADC3"},
  1861. {"TX SMIC MUX1", "SWR_DMIC0", "TX SWR_DMIC0"},
  1862. {"TX SMIC MUX1", "SWR_DMIC1", "TX SWR_DMIC1"},
  1863. {"TX SMIC MUX1", "SWR_DMIC2", "TX SWR_DMIC2"},
  1864. {"TX SMIC MUX1", "SWR_DMIC3", "TX SWR_DMIC3"},
  1865. {"TX SMIC MUX1", "SWR_DMIC4", "TX SWR_DMIC4"},
  1866. {"TX SMIC MUX1", "SWR_DMIC5", "TX SWR_DMIC5"},
  1867. {"TX SMIC MUX1", "SWR_DMIC6", "TX SWR_DMIC6"},
  1868. {"TX SMIC MUX1", "SWR_DMIC7", "TX SWR_DMIC7"},
  1869. {"TX DEC2 MUX", "MSM_DMIC", "TX DMIC MUX2"},
  1870. {"TX DMIC MUX2", "DMIC0", "TX DMIC0"},
  1871. {"TX DMIC MUX2", "DMIC1", "TX DMIC1"},
  1872. {"TX DMIC MUX2", "DMIC2", "TX DMIC2"},
  1873. {"TX DMIC MUX2", "DMIC3", "TX DMIC3"},
  1874. {"TX DMIC MUX2", "DMIC4", "TX DMIC4"},
  1875. {"TX DMIC MUX2", "DMIC5", "TX DMIC5"},
  1876. {"TX DMIC MUX2", "DMIC6", "TX DMIC6"},
  1877. {"TX DMIC MUX2", "DMIC7", "TX DMIC7"},
  1878. {"TX DEC2 MUX", "SWR_MIC", "TX SMIC MUX2"},
  1879. {"TX SMIC MUX2", NULL, "TX_SWR_CLK"},
  1880. {"TX SMIC MUX2", "ADC0", "TX SWR_ADC0"},
  1881. {"TX SMIC MUX2", "ADC1", "TX SWR_ADC1"},
  1882. {"TX SMIC MUX2", "ADC2", "TX SWR_ADC2"},
  1883. {"TX SMIC MUX2", "ADC3", "TX SWR_ADC3"},
  1884. {"TX SMIC MUX2", "SWR_DMIC0", "TX SWR_DMIC0"},
  1885. {"TX SMIC MUX2", "SWR_DMIC1", "TX SWR_DMIC1"},
  1886. {"TX SMIC MUX2", "SWR_DMIC2", "TX SWR_DMIC2"},
  1887. {"TX SMIC MUX2", "SWR_DMIC3", "TX SWR_DMIC3"},
  1888. {"TX SMIC MUX2", "SWR_DMIC4", "TX SWR_DMIC4"},
  1889. {"TX SMIC MUX2", "SWR_DMIC5", "TX SWR_DMIC5"},
  1890. {"TX SMIC MUX2", "SWR_DMIC6", "TX SWR_DMIC6"},
  1891. {"TX SMIC MUX2", "SWR_DMIC7", "TX SWR_DMIC7"},
  1892. {"TX DEC3 MUX", "MSM_DMIC", "TX DMIC MUX3"},
  1893. {"TX DMIC MUX3", "DMIC0", "TX DMIC0"},
  1894. {"TX DMIC MUX3", "DMIC1", "TX DMIC1"},
  1895. {"TX DMIC MUX3", "DMIC2", "TX DMIC2"},
  1896. {"TX DMIC MUX3", "DMIC3", "TX DMIC3"},
  1897. {"TX DMIC MUX3", "DMIC4", "TX DMIC4"},
  1898. {"TX DMIC MUX3", "DMIC5", "TX DMIC5"},
  1899. {"TX DMIC MUX3", "DMIC6", "TX DMIC6"},
  1900. {"TX DMIC MUX3", "DMIC7", "TX DMIC7"},
  1901. {"TX DEC3 MUX", "SWR_MIC", "TX SMIC MUX3"},
  1902. {"TX SMIC MUX3", NULL, "TX_SWR_CLK"},
  1903. {"TX SMIC MUX3", "ADC0", "TX SWR_ADC0"},
  1904. {"TX SMIC MUX3", "ADC1", "TX SWR_ADC1"},
  1905. {"TX SMIC MUX3", "ADC2", "TX SWR_ADC2"},
  1906. {"TX SMIC MUX3", "ADC3", "TX SWR_ADC3"},
  1907. {"TX SMIC MUX3", "SWR_DMIC0", "TX SWR_DMIC0"},
  1908. {"TX SMIC MUX3", "SWR_DMIC1", "TX SWR_DMIC1"},
  1909. {"TX SMIC MUX3", "SWR_DMIC2", "TX SWR_DMIC2"},
  1910. {"TX SMIC MUX3", "SWR_DMIC3", "TX SWR_DMIC3"},
  1911. {"TX SMIC MUX3", "SWR_DMIC4", "TX SWR_DMIC4"},
  1912. {"TX SMIC MUX3", "SWR_DMIC5", "TX SWR_DMIC5"},
  1913. {"TX SMIC MUX3", "SWR_DMIC6", "TX SWR_DMIC6"},
  1914. {"TX SMIC MUX3", "SWR_DMIC7", "TX SWR_DMIC7"},
  1915. {"TX DEC4 MUX", "MSM_DMIC", "TX DMIC MUX4"},
  1916. {"TX DMIC MUX4", "DMIC0", "TX DMIC0"},
  1917. {"TX DMIC MUX4", "DMIC1", "TX DMIC1"},
  1918. {"TX DMIC MUX4", "DMIC2", "TX DMIC2"},
  1919. {"TX DMIC MUX4", "DMIC3", "TX DMIC3"},
  1920. {"TX DMIC MUX4", "DMIC4", "TX DMIC4"},
  1921. {"TX DMIC MUX4", "DMIC5", "TX DMIC5"},
  1922. {"TX DMIC MUX4", "DMIC6", "TX DMIC6"},
  1923. {"TX DMIC MUX4", "DMIC7", "TX DMIC7"},
  1924. {"TX DEC4 MUX", "SWR_MIC", "TX SMIC MUX4"},
  1925. {"TX SMIC MUX4", NULL, "TX_SWR_CLK"},
  1926. {"TX SMIC MUX4", "ADC0", "TX SWR_ADC0"},
  1927. {"TX SMIC MUX4", "ADC1", "TX SWR_ADC1"},
  1928. {"TX SMIC MUX4", "ADC2", "TX SWR_ADC2"},
  1929. {"TX SMIC MUX4", "ADC3", "TX SWR_ADC3"},
  1930. {"TX SMIC MUX4", "SWR_DMIC0", "TX SWR_DMIC0"},
  1931. {"TX SMIC MUX4", "SWR_DMIC1", "TX SWR_DMIC1"},
  1932. {"TX SMIC MUX4", "SWR_DMIC2", "TX SWR_DMIC2"},
  1933. {"TX SMIC MUX4", "SWR_DMIC3", "TX SWR_DMIC3"},
  1934. {"TX SMIC MUX4", "SWR_DMIC4", "TX SWR_DMIC4"},
  1935. {"TX SMIC MUX4", "SWR_DMIC5", "TX SWR_DMIC5"},
  1936. {"TX SMIC MUX4", "SWR_DMIC6", "TX SWR_DMIC6"},
  1937. {"TX SMIC MUX4", "SWR_DMIC7", "TX SWR_DMIC7"},
  1938. {"TX DEC5 MUX", "MSM_DMIC", "TX DMIC MUX5"},
  1939. {"TX DMIC MUX5", "DMIC0", "TX DMIC0"},
  1940. {"TX DMIC MUX5", "DMIC1", "TX DMIC1"},
  1941. {"TX DMIC MUX5", "DMIC2", "TX DMIC2"},
  1942. {"TX DMIC MUX5", "DMIC3", "TX DMIC3"},
  1943. {"TX DMIC MUX5", "DMIC4", "TX DMIC4"},
  1944. {"TX DMIC MUX5", "DMIC5", "TX DMIC5"},
  1945. {"TX DMIC MUX5", "DMIC6", "TX DMIC6"},
  1946. {"TX DMIC MUX5", "DMIC7", "TX DMIC7"},
  1947. {"TX DEC5 MUX", "SWR_MIC", "TX SMIC MUX5"},
  1948. {"TX SMIC MUX5", NULL, "TX_SWR_CLK"},
  1949. {"TX SMIC MUX5", "ADC0", "TX SWR_ADC0"},
  1950. {"TX SMIC MUX5", "ADC1", "TX SWR_ADC1"},
  1951. {"TX SMIC MUX5", "ADC2", "TX SWR_ADC2"},
  1952. {"TX SMIC MUX5", "ADC3", "TX SWR_ADC3"},
  1953. {"TX SMIC MUX5", "SWR_DMIC0", "TX SWR_DMIC0"},
  1954. {"TX SMIC MUX5", "SWR_DMIC1", "TX SWR_DMIC1"},
  1955. {"TX SMIC MUX5", "SWR_DMIC2", "TX SWR_DMIC2"},
  1956. {"TX SMIC MUX5", "SWR_DMIC3", "TX SWR_DMIC3"},
  1957. {"TX SMIC MUX5", "SWR_DMIC4", "TX SWR_DMIC4"},
  1958. {"TX SMIC MUX5", "SWR_DMIC5", "TX SWR_DMIC5"},
  1959. {"TX SMIC MUX5", "SWR_DMIC6", "TX SWR_DMIC6"},
  1960. {"TX SMIC MUX5", "SWR_DMIC7", "TX SWR_DMIC7"},
  1961. {"TX DEC6 MUX", "MSM_DMIC", "TX DMIC MUX6"},
  1962. {"TX DMIC MUX6", "DMIC0", "TX DMIC0"},
  1963. {"TX DMIC MUX6", "DMIC1", "TX DMIC1"},
  1964. {"TX DMIC MUX6", "DMIC2", "TX DMIC2"},
  1965. {"TX DMIC MUX6", "DMIC3", "TX DMIC3"},
  1966. {"TX DMIC MUX6", "DMIC4", "TX DMIC4"},
  1967. {"TX DMIC MUX6", "DMIC5", "TX DMIC5"},
  1968. {"TX DMIC MUX6", "DMIC6", "TX DMIC6"},
  1969. {"TX DMIC MUX6", "DMIC7", "TX DMIC7"},
  1970. {"TX DEC6 MUX", "SWR_MIC", "TX SMIC MUX6"},
  1971. {"TX SMIC MUX6", NULL, "TX_SWR_CLK"},
  1972. {"TX SMIC MUX6", "ADC0", "TX SWR_ADC0"},
  1973. {"TX SMIC MUX6", "ADC1", "TX SWR_ADC1"},
  1974. {"TX SMIC MUX6", "ADC2", "TX SWR_ADC2"},
  1975. {"TX SMIC MUX6", "ADC3", "TX SWR_ADC3"},
  1976. {"TX SMIC MUX6", "SWR_DMIC0", "TX SWR_DMIC0"},
  1977. {"TX SMIC MUX6", "SWR_DMIC1", "TX SWR_DMIC1"},
  1978. {"TX SMIC MUX6", "SWR_DMIC2", "TX SWR_DMIC2"},
  1979. {"TX SMIC MUX6", "SWR_DMIC3", "TX SWR_DMIC3"},
  1980. {"TX SMIC MUX6", "SWR_DMIC4", "TX SWR_DMIC4"},
  1981. {"TX SMIC MUX6", "SWR_DMIC5", "TX SWR_DMIC5"},
  1982. {"TX SMIC MUX6", "SWR_DMIC6", "TX SWR_DMIC6"},
  1983. {"TX SMIC MUX6", "SWR_DMIC7", "TX SWR_DMIC7"},
  1984. {"TX DEC7 MUX", "MSM_DMIC", "TX DMIC MUX7"},
  1985. {"TX DMIC MUX7", "DMIC0", "TX DMIC0"},
  1986. {"TX DMIC MUX7", "DMIC1", "TX DMIC1"},
  1987. {"TX DMIC MUX7", "DMIC2", "TX DMIC2"},
  1988. {"TX DMIC MUX7", "DMIC3", "TX DMIC3"},
  1989. {"TX DMIC MUX7", "DMIC4", "TX DMIC4"},
  1990. {"TX DMIC MUX7", "DMIC5", "TX DMIC5"},
  1991. {"TX DMIC MUX7", "DMIC6", "TX DMIC6"},
  1992. {"TX DMIC MUX7", "DMIC7", "TX DMIC7"},
  1993. {"TX DEC7 MUX", "SWR_MIC", "TX SMIC MUX7"},
  1994. {"TX SMIC MUX7", NULL, "TX_SWR_CLK"},
  1995. {"TX SMIC MUX7", "ADC0", "TX SWR_ADC0"},
  1996. {"TX SMIC MUX7", "ADC1", "TX SWR_ADC1"},
  1997. {"TX SMIC MUX7", "ADC2", "TX SWR_ADC2"},
  1998. {"TX SMIC MUX7", "ADC3", "TX SWR_ADC3"},
  1999. {"TX SMIC MUX7", "SWR_DMIC0", "TX SWR_DMIC0"},
  2000. {"TX SMIC MUX7", "SWR_DMIC1", "TX SWR_DMIC1"},
  2001. {"TX SMIC MUX7", "SWR_DMIC2", "TX SWR_DMIC2"},
  2002. {"TX SMIC MUX7", "SWR_DMIC3", "TX SWR_DMIC3"},
  2003. {"TX SMIC MUX7", "SWR_DMIC4", "TX SWR_DMIC4"},
  2004. {"TX SMIC MUX7", "SWR_DMIC5", "TX SWR_DMIC5"},
  2005. {"TX SMIC MUX7", "SWR_DMIC6", "TX SWR_DMIC6"},
  2006. {"TX SMIC MUX7", "SWR_DMIC7", "TX SWR_DMIC7"},
  2007. };
  2008. static const struct snd_kcontrol_new tx_macro_snd_controls_common[] = {
  2009. SOC_SINGLE_SX_TLV("TX_DEC0 Volume",
  2010. BOLERO_CDC_TX0_TX_VOL_CTL,
  2011. 0, -84, 40, digital_gain),
  2012. SOC_SINGLE_SX_TLV("TX_DEC1 Volume",
  2013. BOLERO_CDC_TX1_TX_VOL_CTL,
  2014. 0, -84, 40, digital_gain),
  2015. SOC_SINGLE_SX_TLV("TX_DEC2 Volume",
  2016. BOLERO_CDC_TX2_TX_VOL_CTL,
  2017. 0, -84, 40, digital_gain),
  2018. SOC_SINGLE_SX_TLV("TX_DEC3 Volume",
  2019. BOLERO_CDC_TX3_TX_VOL_CTL,
  2020. 0, -84, 40, digital_gain),
  2021. SOC_ENUM_EXT("DEC0 MODE", dec_mode_mux_enum,
  2022. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2023. SOC_ENUM_EXT("DEC1 MODE", dec_mode_mux_enum,
  2024. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2025. SOC_ENUM_EXT("DEC2 MODE", dec_mode_mux_enum,
  2026. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2027. SOC_ENUM_EXT("DEC3 MODE", dec_mode_mux_enum,
  2028. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2029. SOC_SINGLE_EXT("DEC0_BCS Switch", SND_SOC_NOPM, 0, 1, 0,
  2030. tx_macro_get_bcs, tx_macro_set_bcs),
  2031. SOC_ENUM_EXT("BCS Channel", bcs_ch_enum,
  2032. tx_macro_bcs_ch_get, tx_macro_bcs_ch_put),
  2033. };
  2034. static const struct snd_kcontrol_new tx_macro_snd_controls_v3[] = {
  2035. SOC_SINGLE_SX_TLV("TX_DEC4 Volume",
  2036. BOLERO_CDC_TX4_TX_VOL_CTL,
  2037. 0, -84, 40, digital_gain),
  2038. SOC_SINGLE_SX_TLV("TX_DEC5 Volume",
  2039. BOLERO_CDC_TX5_TX_VOL_CTL,
  2040. 0, -84, 40, digital_gain),
  2041. SOC_SINGLE_SX_TLV("TX_DEC6 Volume",
  2042. BOLERO_CDC_TX6_TX_VOL_CTL,
  2043. 0, -84, 40, digital_gain),
  2044. SOC_SINGLE_SX_TLV("TX_DEC7 Volume",
  2045. BOLERO_CDC_TX7_TX_VOL_CTL,
  2046. 0, -84, 40, digital_gain),
  2047. SOC_ENUM_EXT("DEC4 MODE", dec_mode_mux_enum,
  2048. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2049. SOC_ENUM_EXT("DEC5 MODE", dec_mode_mux_enum,
  2050. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2051. SOC_ENUM_EXT("DEC6 MODE", dec_mode_mux_enum,
  2052. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2053. SOC_ENUM_EXT("DEC7 MODE", dec_mode_mux_enum,
  2054. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2055. };
  2056. static const struct snd_kcontrol_new tx_macro_snd_controls[] = {
  2057. SOC_SINGLE_SX_TLV("TX_DEC0 Volume",
  2058. BOLERO_CDC_TX0_TX_VOL_CTL,
  2059. 0, -84, 40, digital_gain),
  2060. SOC_SINGLE_SX_TLV("TX_DEC1 Volume",
  2061. BOLERO_CDC_TX1_TX_VOL_CTL,
  2062. 0, -84, 40, digital_gain),
  2063. SOC_SINGLE_SX_TLV("TX_DEC2 Volume",
  2064. BOLERO_CDC_TX2_TX_VOL_CTL,
  2065. 0, -84, 40, digital_gain),
  2066. SOC_SINGLE_SX_TLV("TX_DEC3 Volume",
  2067. BOLERO_CDC_TX3_TX_VOL_CTL,
  2068. 0, -84, 40, digital_gain),
  2069. SOC_SINGLE_SX_TLV("TX_DEC4 Volume",
  2070. BOLERO_CDC_TX4_TX_VOL_CTL,
  2071. 0, -84, 40, digital_gain),
  2072. SOC_SINGLE_SX_TLV("TX_DEC5 Volume",
  2073. BOLERO_CDC_TX5_TX_VOL_CTL,
  2074. 0, -84, 40, digital_gain),
  2075. SOC_SINGLE_SX_TLV("TX_DEC6 Volume",
  2076. BOLERO_CDC_TX6_TX_VOL_CTL,
  2077. 0, -84, 40, digital_gain),
  2078. SOC_SINGLE_SX_TLV("TX_DEC7 Volume",
  2079. BOLERO_CDC_TX7_TX_VOL_CTL,
  2080. 0, -84, 40, digital_gain),
  2081. SOC_ENUM_EXT("DEC0 MODE", dec_mode_mux_enum,
  2082. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2083. SOC_ENUM_EXT("DEC1 MODE", dec_mode_mux_enum,
  2084. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2085. SOC_ENUM_EXT("DEC2 MODE", dec_mode_mux_enum,
  2086. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2087. SOC_ENUM_EXT("DEC3 MODE", dec_mode_mux_enum,
  2088. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2089. SOC_ENUM_EXT("DEC4 MODE", dec_mode_mux_enum,
  2090. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2091. SOC_ENUM_EXT("DEC5 MODE", dec_mode_mux_enum,
  2092. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2093. SOC_ENUM_EXT("DEC6 MODE", dec_mode_mux_enum,
  2094. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2095. SOC_ENUM_EXT("DEC7 MODE", dec_mode_mux_enum,
  2096. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2097. SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
  2098. SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
  2099. SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
  2100. SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
  2101. SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
  2102. SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
  2103. SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
  2104. SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
  2105. SOC_SINGLE_EXT("DEC0_BCS Switch", SND_SOC_NOPM, 0, 1, 0,
  2106. tx_macro_get_bcs, tx_macro_set_bcs),
  2107. };
  2108. static int tx_macro_register_event_listener(struct snd_soc_component *component,
  2109. bool enable)
  2110. {
  2111. struct device *tx_dev = NULL;
  2112. struct tx_macro_priv *tx_priv = NULL;
  2113. int ret = 0;
  2114. if (!component)
  2115. return -EINVAL;
  2116. tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
  2117. if (!tx_dev) {
  2118. dev_err(component->dev,
  2119. "%s: null device for macro!\n", __func__);
  2120. return -EINVAL;
  2121. }
  2122. tx_priv = dev_get_drvdata(tx_dev);
  2123. if (!tx_priv) {
  2124. dev_err(component->dev,
  2125. "%s: priv is null for macro!\n", __func__);
  2126. return -EINVAL;
  2127. }
  2128. if (tx_priv->swr_ctrl_data && !tx_priv->tx_swr_clk_cnt) {
  2129. if (enable) {
  2130. ret = swrm_wcd_notify(
  2131. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  2132. SWR_REGISTER_WAKEUP, NULL);
  2133. msm_cdc_pinctrl_set_wakeup_capable(
  2134. tx_priv->tx_swr_gpio_p, false);
  2135. } else {
  2136. msm_cdc_pinctrl_set_wakeup_capable(
  2137. tx_priv->tx_swr_gpio_p, true);
  2138. ret = swrm_wcd_notify(
  2139. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  2140. SWR_DEREGISTER_WAKEUP, NULL);
  2141. }
  2142. }
  2143. return ret;
  2144. }
  2145. static int tx_macro_tx_va_mclk_enable(struct tx_macro_priv *tx_priv,
  2146. struct regmap *regmap, int clk_type,
  2147. bool enable)
  2148. {
  2149. int ret = 0, clk_tx_ret = 0;
  2150. dev_dbg(tx_priv->dev,
  2151. "%s: clock type %s, enable: %s tx_mclk_users: %d\n",
  2152. __func__, (clk_type ? "VA_MCLK" : "TX_MCLK"),
  2153. (enable ? "enable" : "disable"), tx_priv->tx_mclk_users);
  2154. if (enable) {
  2155. if (tx_priv->swr_clk_users == 0) {
  2156. ret = msm_cdc_pinctrl_select_active_state(
  2157. tx_priv->tx_swr_gpio_p);
  2158. if (ret < 0) {
  2159. dev_err_ratelimited(tx_priv->dev,
  2160. "%s: tx swr pinctrl enable failed\n",
  2161. __func__);
  2162. goto exit;
  2163. }
  2164. }
  2165. clk_tx_ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2166. TX_CORE_CLK,
  2167. TX_CORE_CLK,
  2168. true);
  2169. if (clk_type == TX_MCLK) {
  2170. ret = tx_macro_mclk_enable(tx_priv, 1);
  2171. if (ret < 0) {
  2172. if (tx_priv->swr_clk_users == 0)
  2173. msm_cdc_pinctrl_select_sleep_state(
  2174. tx_priv->tx_swr_gpio_p);
  2175. dev_err_ratelimited(tx_priv->dev,
  2176. "%s: request clock enable failed\n",
  2177. __func__);
  2178. goto done;
  2179. }
  2180. }
  2181. if (clk_type == VA_MCLK) {
  2182. ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2183. TX_CORE_CLK,
  2184. VA_CORE_CLK,
  2185. true);
  2186. if (ret < 0) {
  2187. if (tx_priv->swr_clk_users == 0)
  2188. msm_cdc_pinctrl_select_sleep_state(
  2189. tx_priv->tx_swr_gpio_p);
  2190. dev_err_ratelimited(tx_priv->dev,
  2191. "%s: swr request clk failed\n",
  2192. __func__);
  2193. goto done;
  2194. }
  2195. bolero_clk_rsc_fs_gen_request(tx_priv->dev,
  2196. true);
  2197. if (tx_priv->tx_mclk_users == 0) {
  2198. regmap_update_bits(regmap,
  2199. BOLERO_CDC_TX_TOP_CSR_FREQ_MCLK,
  2200. 0x01, 0x01);
  2201. regmap_update_bits(regmap,
  2202. BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
  2203. 0x01, 0x01);
  2204. regmap_update_bits(regmap,
  2205. BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
  2206. 0x01, 0x01);
  2207. }
  2208. tx_priv->tx_mclk_users++;
  2209. }
  2210. if (tx_priv->swr_clk_users == 0) {
  2211. dev_dbg(tx_priv->dev, "%s: reset_swr: %d\n",
  2212. __func__, tx_priv->reset_swr);
  2213. if (tx_priv->reset_swr)
  2214. regmap_update_bits(regmap,
  2215. BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
  2216. 0x02, 0x02);
  2217. regmap_update_bits(regmap,
  2218. BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
  2219. 0x01, 0x01);
  2220. if (tx_priv->reset_swr)
  2221. regmap_update_bits(regmap,
  2222. BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
  2223. 0x02, 0x00);
  2224. tx_priv->reset_swr = false;
  2225. }
  2226. if (!clk_tx_ret)
  2227. ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2228. TX_CORE_CLK,
  2229. TX_CORE_CLK,
  2230. false);
  2231. tx_priv->swr_clk_users++;
  2232. } else {
  2233. if (tx_priv->swr_clk_users <= 0) {
  2234. dev_err_ratelimited(tx_priv->dev,
  2235. "tx swrm clock users already 0\n");
  2236. tx_priv->swr_clk_users = 0;
  2237. return 0;
  2238. }
  2239. clk_tx_ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2240. TX_CORE_CLK,
  2241. TX_CORE_CLK,
  2242. true);
  2243. tx_priv->swr_clk_users--;
  2244. if (tx_priv->swr_clk_users == 0)
  2245. regmap_update_bits(regmap,
  2246. BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
  2247. 0x01, 0x00);
  2248. if (clk_type == TX_MCLK)
  2249. tx_macro_mclk_enable(tx_priv, 0);
  2250. if (clk_type == VA_MCLK) {
  2251. if (tx_priv->tx_mclk_users <= 0) {
  2252. dev_err(tx_priv->dev, "%s: clock already disabled\n",
  2253. __func__);
  2254. tx_priv->tx_mclk_users = 0;
  2255. goto tx_clk;
  2256. }
  2257. tx_priv->tx_mclk_users--;
  2258. if (tx_priv->tx_mclk_users == 0) {
  2259. regmap_update_bits(regmap,
  2260. BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
  2261. 0x01, 0x00);
  2262. regmap_update_bits(regmap,
  2263. BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
  2264. 0x01, 0x00);
  2265. }
  2266. bolero_clk_rsc_fs_gen_request(tx_priv->dev,
  2267. false);
  2268. ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2269. TX_CORE_CLK,
  2270. VA_CORE_CLK,
  2271. false);
  2272. if (ret < 0) {
  2273. dev_err_ratelimited(tx_priv->dev,
  2274. "%s: swr request clk failed\n",
  2275. __func__);
  2276. goto done;
  2277. }
  2278. }
  2279. tx_clk:
  2280. if (!clk_tx_ret)
  2281. ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2282. TX_CORE_CLK,
  2283. TX_CORE_CLK,
  2284. false);
  2285. if (tx_priv->swr_clk_users == 0) {
  2286. ret = msm_cdc_pinctrl_select_sleep_state(
  2287. tx_priv->tx_swr_gpio_p);
  2288. if (ret < 0) {
  2289. dev_err_ratelimited(tx_priv->dev,
  2290. "%s: tx swr pinctrl disable failed\n",
  2291. __func__);
  2292. goto exit;
  2293. }
  2294. }
  2295. }
  2296. return 0;
  2297. done:
  2298. if (!clk_tx_ret)
  2299. bolero_clk_rsc_request_clock(tx_priv->dev,
  2300. TX_CORE_CLK,
  2301. TX_CORE_CLK,
  2302. false);
  2303. exit:
  2304. return ret;
  2305. }
  2306. static int tx_macro_clk_div_get(struct snd_soc_component *component)
  2307. {
  2308. struct device *tx_dev = NULL;
  2309. struct tx_macro_priv *tx_priv = NULL;
  2310. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  2311. return -EINVAL;
  2312. return tx_priv->dmic_clk_div;
  2313. }
  2314. static int tx_macro_clk_switch(struct snd_soc_component *component)
  2315. {
  2316. struct device *tx_dev = NULL;
  2317. struct tx_macro_priv *tx_priv = NULL;
  2318. int ret = 0;
  2319. if (!component)
  2320. return -EINVAL;
  2321. tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
  2322. if (!tx_dev) {
  2323. dev_err(component->dev,
  2324. "%s: null device for macro!\n", __func__);
  2325. return -EINVAL;
  2326. }
  2327. tx_priv = dev_get_drvdata(tx_dev);
  2328. if (!tx_priv) {
  2329. dev_err(component->dev,
  2330. "%s: priv is null for macro!\n", __func__);
  2331. return -EINVAL;
  2332. }
  2333. if (tx_priv->swr_ctrl_data) {
  2334. ret = swrm_wcd_notify(
  2335. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  2336. SWR_REQ_CLK_SWITCH, NULL);
  2337. }
  2338. return ret;
  2339. }
  2340. static int tx_macro_core_vote(void *handle, bool enable)
  2341. {
  2342. struct tx_macro_priv *tx_priv = (struct tx_macro_priv *) handle;
  2343. if (tx_priv == NULL) {
  2344. pr_err("%s: tx priv data is NULL\n", __func__);
  2345. return -EINVAL;
  2346. }
  2347. if (enable) {
  2348. pm_runtime_get_sync(tx_priv->dev);
  2349. pm_runtime_put_autosuspend(tx_priv->dev);
  2350. pm_runtime_mark_last_busy(tx_priv->dev);
  2351. }
  2352. if (bolero_check_core_votes(tx_priv->dev))
  2353. return 0;
  2354. else
  2355. return -EINVAL;
  2356. }
  2357. static int tx_macro_swrm_clock(void *handle, bool enable)
  2358. {
  2359. struct tx_macro_priv *tx_priv = (struct tx_macro_priv *) handle;
  2360. struct regmap *regmap = dev_get_regmap(tx_priv->dev->parent, NULL);
  2361. int ret = 0;
  2362. if (regmap == NULL) {
  2363. dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
  2364. return -EINVAL;
  2365. }
  2366. mutex_lock(&tx_priv->swr_clk_lock);
  2367. dev_dbg(tx_priv->dev,
  2368. "%s: swrm clock %s tx_swr_clk_cnt: %d va_swr_clk_cnt: %d\n",
  2369. __func__, (enable ? "enable" : "disable"),
  2370. tx_priv->tx_swr_clk_cnt, tx_priv->va_swr_clk_cnt);
  2371. if (enable) {
  2372. pm_runtime_get_sync(tx_priv->dev);
  2373. if (tx_priv->va_swr_clk_cnt && !tx_priv->tx_swr_clk_cnt) {
  2374. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2375. VA_MCLK, enable);
  2376. if (ret) {
  2377. pm_runtime_mark_last_busy(tx_priv->dev);
  2378. pm_runtime_put_autosuspend(tx_priv->dev);
  2379. goto done;
  2380. }
  2381. tx_priv->va_clk_status++;
  2382. } else {
  2383. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2384. TX_MCLK, enable);
  2385. if (ret) {
  2386. pm_runtime_mark_last_busy(tx_priv->dev);
  2387. pm_runtime_put_autosuspend(tx_priv->dev);
  2388. goto done;
  2389. }
  2390. tx_priv->tx_clk_status++;
  2391. }
  2392. pm_runtime_mark_last_busy(tx_priv->dev);
  2393. pm_runtime_put_autosuspend(tx_priv->dev);
  2394. } else {
  2395. if (tx_priv->va_clk_status && !tx_priv->tx_clk_status) {
  2396. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2397. VA_MCLK, enable);
  2398. if (ret)
  2399. goto done;
  2400. --tx_priv->va_clk_status;
  2401. } else if (!tx_priv->va_clk_status && tx_priv->tx_clk_status) {
  2402. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2403. TX_MCLK, enable);
  2404. if (ret)
  2405. goto done;
  2406. --tx_priv->tx_clk_status;
  2407. } else if (tx_priv->va_clk_status && tx_priv->tx_clk_status) {
  2408. if (!tx_priv->va_swr_clk_cnt && tx_priv->tx_swr_clk_cnt) {
  2409. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2410. VA_MCLK, enable);
  2411. if (ret)
  2412. goto done;
  2413. --tx_priv->va_clk_status;
  2414. } else {
  2415. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2416. TX_MCLK, enable);
  2417. if (ret)
  2418. goto done;
  2419. --tx_priv->tx_clk_status;
  2420. }
  2421. } else {
  2422. dev_dbg(tx_priv->dev,
  2423. "%s: Both clocks are disabled\n", __func__);
  2424. }
  2425. }
  2426. dev_dbg(tx_priv->dev,
  2427. "%s: swrm clock users %d tx_clk_sts_cnt: %d va_clk_sts_cnt: %d\n",
  2428. __func__, tx_priv->swr_clk_users, tx_priv->tx_clk_status,
  2429. tx_priv->va_clk_status);
  2430. done:
  2431. mutex_unlock(&tx_priv->swr_clk_lock);
  2432. return ret;
  2433. }
  2434. static int tx_macro_validate_dmic_sample_rate(u32 dmic_sample_rate,
  2435. struct tx_macro_priv *tx_priv)
  2436. {
  2437. u32 div_factor = TX_MACRO_CLK_DIV_2;
  2438. u32 mclk_rate = TX_MACRO_MCLK_FREQ;
  2439. if (dmic_sample_rate == TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED ||
  2440. mclk_rate % dmic_sample_rate != 0)
  2441. goto undefined_rate;
  2442. div_factor = mclk_rate / dmic_sample_rate;
  2443. switch (div_factor) {
  2444. case 2:
  2445. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_2;
  2446. break;
  2447. case 3:
  2448. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_3;
  2449. break;
  2450. case 4:
  2451. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_4;
  2452. break;
  2453. case 6:
  2454. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_6;
  2455. break;
  2456. case 8:
  2457. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_8;
  2458. break;
  2459. case 16:
  2460. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_16;
  2461. break;
  2462. default:
  2463. /* Any other DIV factor is invalid */
  2464. goto undefined_rate;
  2465. }
  2466. /* Valid dmic DIV factors */
  2467. dev_dbg(tx_priv->dev, "%s: DMIC_DIV = %u, mclk_rate = %u\n",
  2468. __func__, div_factor, mclk_rate);
  2469. return dmic_sample_rate;
  2470. undefined_rate:
  2471. dev_dbg(tx_priv->dev, "%s: Invalid rate %d, for mclk %d\n",
  2472. __func__, dmic_sample_rate, mclk_rate);
  2473. dmic_sample_rate = TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED;
  2474. return dmic_sample_rate;
  2475. }
  2476. static const struct tx_macro_reg_mask_val tx_macro_reg_init[] = {
  2477. {BOLERO_CDC_TX0_TX_PATH_SEC7, 0x3F, 0x02},
  2478. };
  2479. static int tx_macro_init(struct snd_soc_component *component)
  2480. {
  2481. struct snd_soc_dapm_context *dapm =
  2482. snd_soc_component_get_dapm(component);
  2483. int ret = 0, i = 0;
  2484. struct device *tx_dev = NULL;
  2485. struct tx_macro_priv *tx_priv = NULL;
  2486. tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
  2487. if (!tx_dev) {
  2488. dev_err(component->dev,
  2489. "%s: null device for macro!\n", __func__);
  2490. return -EINVAL;
  2491. }
  2492. tx_priv = dev_get_drvdata(tx_dev);
  2493. if (!tx_priv) {
  2494. dev_err(component->dev,
  2495. "%s: priv is null for macro!\n", __func__);
  2496. return -EINVAL;
  2497. }
  2498. tx_priv->version = bolero_get_version(tx_dev);
  2499. if (tx_priv->version >= BOLERO_VERSION_2_0) {
  2500. ret = snd_soc_dapm_new_controls(dapm,
  2501. tx_macro_dapm_widgets_common,
  2502. ARRAY_SIZE(tx_macro_dapm_widgets_common));
  2503. if (ret < 0) {
  2504. dev_err(tx_dev, "%s: Failed to add controls\n",
  2505. __func__);
  2506. return ret;
  2507. }
  2508. if (tx_priv->version == BOLERO_VERSION_2_1)
  2509. ret = snd_soc_dapm_new_controls(dapm,
  2510. tx_macro_dapm_widgets_v2,
  2511. ARRAY_SIZE(tx_macro_dapm_widgets_v2));
  2512. else if (tx_priv->version == BOLERO_VERSION_2_0)
  2513. ret = snd_soc_dapm_new_controls(dapm,
  2514. tx_macro_dapm_widgets_v3,
  2515. ARRAY_SIZE(tx_macro_dapm_widgets_v3));
  2516. if (ret < 0) {
  2517. dev_err(tx_dev, "%s: Failed to add controls\n",
  2518. __func__);
  2519. return ret;
  2520. }
  2521. } else {
  2522. ret = snd_soc_dapm_new_controls(dapm, tx_macro_dapm_widgets,
  2523. ARRAY_SIZE(tx_macro_dapm_widgets));
  2524. if (ret < 0) {
  2525. dev_err(tx_dev, "%s: Failed to add controls\n",
  2526. __func__);
  2527. return ret;
  2528. }
  2529. }
  2530. if (tx_priv->version >= BOLERO_VERSION_2_0) {
  2531. ret = snd_soc_dapm_add_routes(dapm,
  2532. tx_audio_map_common,
  2533. ARRAY_SIZE(tx_audio_map_common));
  2534. if (ret < 0) {
  2535. dev_err(tx_dev, "%s: Failed to add routes\n",
  2536. __func__);
  2537. return ret;
  2538. }
  2539. if (tx_priv->version == BOLERO_VERSION_2_0)
  2540. ret = snd_soc_dapm_add_routes(dapm,
  2541. tx_audio_map_v3,
  2542. ARRAY_SIZE(tx_audio_map_v3));
  2543. if (ret < 0) {
  2544. dev_err(tx_dev, "%s: Failed to add routes\n",
  2545. __func__);
  2546. return ret;
  2547. }
  2548. } else {
  2549. ret = snd_soc_dapm_add_routes(dapm, tx_audio_map,
  2550. ARRAY_SIZE(tx_audio_map));
  2551. if (ret < 0) {
  2552. dev_err(tx_dev, "%s: Failed to add routes\n",
  2553. __func__);
  2554. return ret;
  2555. }
  2556. }
  2557. ret = snd_soc_dapm_new_widgets(dapm->card);
  2558. if (ret < 0) {
  2559. dev_err(tx_dev, "%s: Failed to add widgets\n", __func__);
  2560. return ret;
  2561. }
  2562. if (tx_priv->version >= BOLERO_VERSION_2_0) {
  2563. ret = snd_soc_add_component_controls(component,
  2564. tx_macro_snd_controls_common,
  2565. ARRAY_SIZE(tx_macro_snd_controls_common));
  2566. if (ret < 0) {
  2567. dev_err(tx_dev, "%s: Failed to add snd_ctls\n",
  2568. __func__);
  2569. return ret;
  2570. }
  2571. if (tx_priv->version == BOLERO_VERSION_2_0)
  2572. ret = snd_soc_add_component_controls(component,
  2573. tx_macro_snd_controls_v3,
  2574. ARRAY_SIZE(tx_macro_snd_controls_v3));
  2575. if (ret < 0) {
  2576. dev_err(tx_dev, "%s: Failed to add snd_ctls\n",
  2577. __func__);
  2578. return ret;
  2579. }
  2580. } else {
  2581. ret = snd_soc_add_component_controls(component,
  2582. tx_macro_snd_controls,
  2583. ARRAY_SIZE(tx_macro_snd_controls));
  2584. if (ret < 0) {
  2585. dev_err(tx_dev, "%s: Failed to add snd_ctls\n",
  2586. __func__);
  2587. return ret;
  2588. }
  2589. }
  2590. snd_soc_dapm_ignore_suspend(dapm, "TX_AIF1 Capture");
  2591. snd_soc_dapm_ignore_suspend(dapm, "TX_AIF2 Capture");
  2592. snd_soc_dapm_ignore_suspend(dapm, "TX_AIF3 Capture");
  2593. if (tx_priv->version >= BOLERO_VERSION_2_0) {
  2594. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_INPUT");
  2595. } else {
  2596. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC0");
  2597. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC1");
  2598. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC2");
  2599. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC3");
  2600. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC0");
  2601. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC1");
  2602. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC2");
  2603. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC3");
  2604. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC4");
  2605. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC5");
  2606. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC6");
  2607. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC7");
  2608. }
  2609. snd_soc_dapm_sync(dapm);
  2610. for (i = 0; i < NUM_DECIMATORS; i++) {
  2611. tx_priv->tx_hpf_work[i].tx_priv = tx_priv;
  2612. tx_priv->tx_hpf_work[i].decimator = i;
  2613. INIT_DELAYED_WORK(&tx_priv->tx_hpf_work[i].dwork,
  2614. tx_macro_tx_hpf_corner_freq_callback);
  2615. }
  2616. for (i = 0; i < NUM_DECIMATORS; i++) {
  2617. tx_priv->tx_mute_dwork[i].tx_priv = tx_priv;
  2618. tx_priv->tx_mute_dwork[i].decimator = i;
  2619. INIT_DELAYED_WORK(&tx_priv->tx_mute_dwork[i].dwork,
  2620. tx_macro_mute_update_callback);
  2621. }
  2622. tx_priv->component = component;
  2623. for (i = 0; i < ARRAY_SIZE(tx_macro_reg_init); i++)
  2624. snd_soc_component_update_bits(component,
  2625. tx_macro_reg_init[i].reg,
  2626. tx_macro_reg_init[i].mask,
  2627. tx_macro_reg_init[i].val);
  2628. return 0;
  2629. }
  2630. static int tx_macro_deinit(struct snd_soc_component *component)
  2631. {
  2632. struct device *tx_dev = NULL;
  2633. struct tx_macro_priv *tx_priv = NULL;
  2634. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  2635. return -EINVAL;
  2636. tx_priv->component = NULL;
  2637. return 0;
  2638. }
  2639. static void tx_macro_add_child_devices(struct work_struct *work)
  2640. {
  2641. struct tx_macro_priv *tx_priv = NULL;
  2642. struct platform_device *pdev = NULL;
  2643. struct device_node *node = NULL;
  2644. struct tx_macro_swr_ctrl_data *swr_ctrl_data = NULL, *temp = NULL;
  2645. int ret = 0;
  2646. u16 count = 0, ctrl_num = 0;
  2647. struct tx_macro_swr_ctrl_platform_data *platdata = NULL;
  2648. char plat_dev_name[TX_MACRO_SWR_STRING_LEN] = "";
  2649. bool tx_swr_master_node = false;
  2650. tx_priv = container_of(work, struct tx_macro_priv,
  2651. tx_macro_add_child_devices_work);
  2652. if (!tx_priv) {
  2653. pr_err("%s: Memory for tx_priv does not exist\n",
  2654. __func__);
  2655. return;
  2656. }
  2657. if (!tx_priv->dev) {
  2658. pr_err("%s: tx dev does not exist\n", __func__);
  2659. return;
  2660. }
  2661. if (!tx_priv->dev->of_node) {
  2662. dev_err(tx_priv->dev,
  2663. "%s: DT node for tx_priv does not exist\n", __func__);
  2664. return;
  2665. }
  2666. platdata = &tx_priv->swr_plat_data;
  2667. tx_priv->child_count = 0;
  2668. for_each_available_child_of_node(tx_priv->dev->of_node, node) {
  2669. tx_swr_master_node = false;
  2670. if (strnstr(node->name, "tx_swr_master",
  2671. strlen("tx_swr_master")) != NULL)
  2672. tx_swr_master_node = true;
  2673. if (tx_swr_master_node)
  2674. strlcpy(plat_dev_name, "tx_swr_ctrl",
  2675. (TX_MACRO_SWR_STRING_LEN - 1));
  2676. else
  2677. strlcpy(plat_dev_name, node->name,
  2678. (TX_MACRO_SWR_STRING_LEN - 1));
  2679. pdev = platform_device_alloc(plat_dev_name, -1);
  2680. if (!pdev) {
  2681. dev_err(tx_priv->dev, "%s: pdev memory alloc failed\n",
  2682. __func__);
  2683. ret = -ENOMEM;
  2684. goto err;
  2685. }
  2686. pdev->dev.parent = tx_priv->dev;
  2687. pdev->dev.of_node = node;
  2688. if (tx_swr_master_node) {
  2689. ret = platform_device_add_data(pdev, platdata,
  2690. sizeof(*platdata));
  2691. if (ret) {
  2692. dev_err(&pdev->dev,
  2693. "%s: cannot add plat data ctrl:%d\n",
  2694. __func__, ctrl_num);
  2695. goto fail_pdev_add;
  2696. }
  2697. }
  2698. ret = platform_device_add(pdev);
  2699. if (ret) {
  2700. dev_err(&pdev->dev,
  2701. "%s: Cannot add platform device\n",
  2702. __func__);
  2703. goto fail_pdev_add;
  2704. }
  2705. if (tx_swr_master_node) {
  2706. temp = krealloc(swr_ctrl_data,
  2707. (ctrl_num + 1) * sizeof(
  2708. struct tx_macro_swr_ctrl_data),
  2709. GFP_KERNEL);
  2710. if (!temp) {
  2711. ret = -ENOMEM;
  2712. goto fail_pdev_add;
  2713. }
  2714. swr_ctrl_data = temp;
  2715. swr_ctrl_data[ctrl_num].tx_swr_pdev = pdev;
  2716. ctrl_num++;
  2717. dev_dbg(&pdev->dev,
  2718. "%s: Added soundwire ctrl device(s)\n",
  2719. __func__);
  2720. tx_priv->swr_ctrl_data = swr_ctrl_data;
  2721. }
  2722. if (tx_priv->child_count < TX_MACRO_CHILD_DEVICES_MAX)
  2723. tx_priv->pdev_child_devices[
  2724. tx_priv->child_count++] = pdev;
  2725. else
  2726. goto err;
  2727. }
  2728. return;
  2729. fail_pdev_add:
  2730. for (count = 0; count < tx_priv->child_count; count++)
  2731. platform_device_put(tx_priv->pdev_child_devices[count]);
  2732. err:
  2733. return;
  2734. }
  2735. static int tx_macro_set_port_map(struct snd_soc_component *component,
  2736. u32 usecase, u32 size, void *data)
  2737. {
  2738. struct device *tx_dev = NULL;
  2739. struct tx_macro_priv *tx_priv = NULL;
  2740. struct swrm_port_config port_cfg;
  2741. int ret = 0;
  2742. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  2743. return -EINVAL;
  2744. memset(&port_cfg, 0, sizeof(port_cfg));
  2745. port_cfg.uc = usecase;
  2746. port_cfg.size = size;
  2747. port_cfg.params = data;
  2748. if (tx_priv->swr_ctrl_data)
  2749. ret = swrm_wcd_notify(
  2750. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  2751. SWR_SET_PORT_MAP, &port_cfg);
  2752. return ret;
  2753. }
  2754. static void tx_macro_init_ops(struct macro_ops *ops,
  2755. char __iomem *tx_io_base)
  2756. {
  2757. memset(ops, 0, sizeof(struct macro_ops));
  2758. ops->init = tx_macro_init;
  2759. ops->exit = tx_macro_deinit;
  2760. ops->io_base = tx_io_base;
  2761. ops->dai_ptr = tx_macro_dai;
  2762. ops->num_dais = ARRAY_SIZE(tx_macro_dai);
  2763. ops->event_handler = tx_macro_event_handler;
  2764. ops->reg_wake_irq = tx_macro_reg_wake_irq;
  2765. ops->set_port_map = tx_macro_set_port_map;
  2766. ops->clk_div_get = tx_macro_clk_div_get;
  2767. ops->clk_switch = tx_macro_clk_switch;
  2768. ops->reg_evt_listener = tx_macro_register_event_listener;
  2769. ops->clk_enable = __tx_macro_mclk_enable;
  2770. }
  2771. static int tx_macro_probe(struct platform_device *pdev)
  2772. {
  2773. struct macro_ops ops = {0};
  2774. struct tx_macro_priv *tx_priv = NULL;
  2775. u32 tx_base_addr = 0, sample_rate = 0;
  2776. char __iomem *tx_io_base = NULL;
  2777. int ret = 0;
  2778. const char *dmic_sample_rate = "qcom,tx-dmic-sample-rate";
  2779. u32 is_used_tx_swr_gpio = 1;
  2780. const char *is_used_tx_swr_gpio_dt = "qcom,is-used-swr-gpio";
  2781. tx_priv = devm_kzalloc(&pdev->dev, sizeof(struct tx_macro_priv),
  2782. GFP_KERNEL);
  2783. if (!tx_priv)
  2784. return -ENOMEM;
  2785. platform_set_drvdata(pdev, tx_priv);
  2786. tx_priv->dev = &pdev->dev;
  2787. ret = of_property_read_u32(pdev->dev.of_node, "reg",
  2788. &tx_base_addr);
  2789. if (ret) {
  2790. dev_err(&pdev->dev, "%s: could not find %s entry in dt\n",
  2791. __func__, "reg");
  2792. return ret;
  2793. }
  2794. dev_set_drvdata(&pdev->dev, tx_priv);
  2795. if (of_find_property(pdev->dev.of_node, is_used_tx_swr_gpio_dt,
  2796. NULL)) {
  2797. ret = of_property_read_u32(pdev->dev.of_node,
  2798. is_used_tx_swr_gpio_dt,
  2799. &is_used_tx_swr_gpio);
  2800. if (ret) {
  2801. dev_err(&pdev->dev, "%s: error reading %s in dt\n",
  2802. __func__, is_used_tx_swr_gpio_dt);
  2803. is_used_tx_swr_gpio = 1;
  2804. }
  2805. }
  2806. tx_priv->tx_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2807. "qcom,tx-swr-gpios", 0);
  2808. if (!tx_priv->tx_swr_gpio_p && is_used_tx_swr_gpio) {
  2809. dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
  2810. __func__);
  2811. return -EINVAL;
  2812. }
  2813. if (msm_cdc_pinctrl_get_state(tx_priv->tx_swr_gpio_p) < 0 &&
  2814. is_used_tx_swr_gpio) {
  2815. dev_err(&pdev->dev, "%s: failed to get swr pin state\n",
  2816. __func__);
  2817. return -EPROBE_DEFER;
  2818. }
  2819. tx_io_base = devm_ioremap(&pdev->dev,
  2820. tx_base_addr, TX_MACRO_MAX_OFFSET);
  2821. if (!tx_io_base) {
  2822. dev_err(&pdev->dev, "%s: ioremap failed\n", __func__);
  2823. return -ENOMEM;
  2824. }
  2825. tx_priv->tx_io_base = tx_io_base;
  2826. ret = of_property_read_u32(pdev->dev.of_node, dmic_sample_rate,
  2827. &sample_rate);
  2828. if (ret) {
  2829. dev_err(&pdev->dev,
  2830. "%s: could not find sample_rate entry in dt\n",
  2831. __func__);
  2832. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_2;
  2833. } else {
  2834. if (tx_macro_validate_dmic_sample_rate(
  2835. sample_rate, tx_priv) == TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED)
  2836. return -EINVAL;
  2837. }
  2838. if (is_used_tx_swr_gpio) {
  2839. tx_priv->reset_swr = true;
  2840. INIT_WORK(&tx_priv->tx_macro_add_child_devices_work,
  2841. tx_macro_add_child_devices);
  2842. tx_priv->swr_plat_data.handle = (void *) tx_priv;
  2843. tx_priv->swr_plat_data.read = NULL;
  2844. tx_priv->swr_plat_data.write = NULL;
  2845. tx_priv->swr_plat_data.bulk_write = NULL;
  2846. tx_priv->swr_plat_data.clk = tx_macro_swrm_clock;
  2847. tx_priv->swr_plat_data.core_vote = tx_macro_core_vote;
  2848. tx_priv->swr_plat_data.handle_irq = NULL;
  2849. mutex_init(&tx_priv->swr_clk_lock);
  2850. }
  2851. tx_priv->is_used_tx_swr_gpio = is_used_tx_swr_gpio;
  2852. mutex_init(&tx_priv->mclk_lock);
  2853. tx_macro_init_ops(&ops, tx_io_base);
  2854. ops.clk_id_req = TX_CORE_CLK;
  2855. ops.default_clk_id = TX_CORE_CLK;
  2856. ret = bolero_register_macro(&pdev->dev, TX_MACRO, &ops);
  2857. if (ret) {
  2858. dev_err(&pdev->dev,
  2859. "%s: register macro failed\n", __func__);
  2860. goto err_reg_macro;
  2861. }
  2862. if (is_used_tx_swr_gpio)
  2863. schedule_work(&tx_priv->tx_macro_add_child_devices_work);
  2864. pm_runtime_set_autosuspend_delay(&pdev->dev, AUTO_SUSPEND_DELAY);
  2865. pm_runtime_use_autosuspend(&pdev->dev);
  2866. pm_runtime_set_suspended(&pdev->dev);
  2867. pm_suspend_ignore_children(&pdev->dev, true);
  2868. pm_runtime_enable(&pdev->dev);
  2869. return 0;
  2870. err_reg_macro:
  2871. mutex_destroy(&tx_priv->mclk_lock);
  2872. if (is_used_tx_swr_gpio)
  2873. mutex_destroy(&tx_priv->swr_clk_lock);
  2874. return ret;
  2875. }
  2876. static int tx_macro_remove(struct platform_device *pdev)
  2877. {
  2878. struct tx_macro_priv *tx_priv = NULL;
  2879. u16 count = 0;
  2880. tx_priv = platform_get_drvdata(pdev);
  2881. if (!tx_priv)
  2882. return -EINVAL;
  2883. if (tx_priv->is_used_tx_swr_gpio) {
  2884. if (tx_priv->swr_ctrl_data)
  2885. kfree(tx_priv->swr_ctrl_data);
  2886. for (count = 0; count < tx_priv->child_count &&
  2887. count < TX_MACRO_CHILD_DEVICES_MAX; count++)
  2888. platform_device_unregister(
  2889. tx_priv->pdev_child_devices[count]);
  2890. }
  2891. pm_runtime_disable(&pdev->dev);
  2892. pm_runtime_set_suspended(&pdev->dev);
  2893. mutex_destroy(&tx_priv->mclk_lock);
  2894. if (tx_priv->is_used_tx_swr_gpio)
  2895. mutex_destroy(&tx_priv->swr_clk_lock);
  2896. bolero_unregister_macro(&pdev->dev, TX_MACRO);
  2897. return 0;
  2898. }
  2899. static const struct of_device_id tx_macro_dt_match[] = {
  2900. {.compatible = "qcom,tx-macro"},
  2901. {}
  2902. };
  2903. static const struct dev_pm_ops bolero_dev_pm_ops = {
  2904. SET_SYSTEM_SLEEP_PM_OPS(
  2905. pm_runtime_force_suspend,
  2906. pm_runtime_force_resume
  2907. )
  2908. SET_RUNTIME_PM_OPS(
  2909. bolero_runtime_suspend,
  2910. bolero_runtime_resume,
  2911. NULL
  2912. )
  2913. };
  2914. static struct platform_driver tx_macro_driver = {
  2915. .driver = {
  2916. .name = "tx_macro",
  2917. .owner = THIS_MODULE,
  2918. .pm = &bolero_dev_pm_ops,
  2919. .of_match_table = tx_macro_dt_match,
  2920. .suppress_bind_attrs = true,
  2921. },
  2922. .probe = tx_macro_probe,
  2923. .remove = tx_macro_remove,
  2924. };
  2925. module_platform_driver(tx_macro_driver);
  2926. MODULE_DESCRIPTION("TX macro driver");
  2927. MODULE_LICENSE("GPL v2");