123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807 |
- // SPDX-License-Identifier: GPL-2.0-only
- /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
- */
- #include <linux/module.h>
- #include <linux/init.h>
- #include <linux/bitops.h>
- #include <linux/clk.h>
- #include <linux/io.h>
- #include <linux/platform_device.h>
- #include <linux/regmap.h>
- #include <linux/pm_runtime.h>
- #include <sound/soc.h>
- #include <sound/soc-dapm.h>
- #include <sound/tlv.h>
- #include <soc/swr-common.h>
- #include <soc/swr-wcd.h>
- #include <asoc/msm-cdc-pinctrl.h>
- #include "bolero-cdc.h"
- #include "bolero-cdc-registers.h"
- #include "bolero-clk-rsc.h"
- #define AUTO_SUSPEND_DELAY 50 /* delay in msec */
- #define TX_MACRO_MAX_OFFSET 0x1000
- #define NUM_DECIMATORS 8
- #define TX_MACRO_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
- SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
- SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
- #define TX_MACRO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
- SNDRV_PCM_FMTBIT_S24_LE |\
- SNDRV_PCM_FMTBIT_S24_3LE)
- #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
- #define CF_MIN_3DB_4HZ 0x0
- #define CF_MIN_3DB_75HZ 0x1
- #define CF_MIN_3DB_150HZ 0x2
- #define TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED 0
- #define TX_MACRO_MCLK_FREQ 9600000
- #define TX_MACRO_TX_PATH_OFFSET 0x80
- #define TX_MACRO_SWR_MIC_MUX_SEL_MASK 0xF
- #define TX_MACRO_ADC_MUX_CFG_OFFSET 0x8
- #define TX_MACRO_ADC_MODE_CFG0_SHIFT 1
- #define TX_MACRO_DMIC_UNMUTE_DELAY_MS 40
- #define TX_MACRO_AMIC_UNMUTE_DELAY_MS 100
- #define TX_MACRO_DMIC_HPF_DELAY_MS 300
- #define TX_MACRO_AMIC_HPF_DELAY_MS 300
- static int tx_unmute_delay = TX_MACRO_DMIC_UNMUTE_DELAY_MS;
- module_param(tx_unmute_delay, int, 0664);
- MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
- static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
- static int tx_macro_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai);
- static int tx_macro_get_channel_map(struct snd_soc_dai *dai,
- unsigned int *tx_num, unsigned int *tx_slot,
- unsigned int *rx_num, unsigned int *rx_slot);
- #define TX_MACRO_SWR_STRING_LEN 80
- #define TX_MACRO_CHILD_DEVICES_MAX 3
- /* Hold instance to soundwire platform device */
- struct tx_macro_swr_ctrl_data {
- struct platform_device *tx_swr_pdev;
- };
- struct tx_macro_swr_ctrl_platform_data {
- void *handle; /* holds codec private data */
- int (*read)(void *handle, int reg);
- int (*write)(void *handle, int reg, int val);
- int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
- int (*clk)(void *handle, bool enable);
- int (*core_vote)(void *handle, bool enable);
- int (*handle_irq)(void *handle,
- irqreturn_t (*swrm_irq_handler)(int irq,
- void *data),
- void *swrm_handle,
- int action);
- };
- enum {
- TX_MACRO_AIF_INVALID = 0,
- TX_MACRO_AIF1_CAP,
- TX_MACRO_AIF2_CAP,
- TX_MACRO_AIF3_CAP,
- TX_MACRO_MAX_DAIS
- };
- enum {
- TX_MACRO_DEC0,
- TX_MACRO_DEC1,
- TX_MACRO_DEC2,
- TX_MACRO_DEC3,
- TX_MACRO_DEC4,
- TX_MACRO_DEC5,
- TX_MACRO_DEC6,
- TX_MACRO_DEC7,
- TX_MACRO_DEC_MAX,
- };
- enum {
- TX_MACRO_CLK_DIV_2,
- TX_MACRO_CLK_DIV_3,
- TX_MACRO_CLK_DIV_4,
- TX_MACRO_CLK_DIV_6,
- TX_MACRO_CLK_DIV_8,
- TX_MACRO_CLK_DIV_16,
- };
- enum {
- MSM_DMIC,
- SWR_MIC,
- ANC_FB_TUNE1
- };
- enum {
- TX_MCLK,
- VA_MCLK,
- };
- struct tx_macro_reg_mask_val {
- u16 reg;
- u8 mask;
- u8 val;
- };
- struct tx_mute_work {
- struct tx_macro_priv *tx_priv;
- u32 decimator;
- struct delayed_work dwork;
- };
- struct hpf_work {
- struct tx_macro_priv *tx_priv;
- u8 decimator;
- u8 hpf_cut_off_freq;
- struct delayed_work dwork;
- };
- struct tx_macro_priv {
- struct device *dev;
- bool dec_active[NUM_DECIMATORS];
- int tx_mclk_users;
- int swr_clk_users;
- bool dapm_mclk_enable;
- bool reset_swr;
- struct mutex mclk_lock;
- struct mutex swr_clk_lock;
- struct snd_soc_component *component;
- struct device_node *tx_swr_gpio_p;
- struct tx_macro_swr_ctrl_data *swr_ctrl_data;
- struct tx_macro_swr_ctrl_platform_data swr_plat_data;
- struct work_struct tx_macro_add_child_devices_work;
- struct hpf_work tx_hpf_work[NUM_DECIMATORS];
- struct tx_mute_work tx_mute_dwork[NUM_DECIMATORS];
- u16 dmic_clk_div;
- u32 version;
- u32 is_used_tx_swr_gpio;
- unsigned long active_ch_mask[TX_MACRO_MAX_DAIS];
- char __iomem *tx_io_base;
- struct platform_device *pdev_child_devices
- [TX_MACRO_CHILD_DEVICES_MAX];
- int child_count;
- int tx_swr_clk_cnt;
- int va_swr_clk_cnt;
- int va_clk_status;
- int tx_clk_status;
- bool bcs_enable;
- int dec_mode[NUM_DECIMATORS];
- int bcs_ch;
- bool bcs_clk_en;
- bool hs_slow_insert_complete;
- int pcm_rate[NUM_DECIMATORS];
- bool lpi_enable;
- bool register_event_listener;
- u16 current_clk_id;
- int disable_afe_wakeup_event_listener;
- };
- static bool tx_macro_get_data(struct snd_soc_component *component,
- struct device **tx_dev,
- struct tx_macro_priv **tx_priv,
- const char *func_name)
- {
- *tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
- if (!(*tx_dev)) {
- dev_err(component->dev,
- "%s: null device for macro!\n", func_name);
- return false;
- }
- *tx_priv = dev_get_drvdata((*tx_dev));
- if (!(*tx_priv)) {
- dev_err(component->dev,
- "%s: priv is null for macro!\n", func_name);
- return false;
- }
- if (!(*tx_priv)->component) {
- dev_err(component->dev,
- "%s: tx_priv->component not initialized!\n", func_name);
- return false;
- }
- return true;
- }
- static int tx_macro_mclk_enable(struct tx_macro_priv *tx_priv,
- bool mclk_enable)
- {
- struct regmap *regmap = dev_get_regmap(tx_priv->dev->parent, NULL);
- int ret = 0;
- if (regmap == NULL) {
- dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
- return -EINVAL;
- }
- dev_dbg(tx_priv->dev, "%s: mclk_enable = %u,clk_users= %d\n",
- __func__, mclk_enable, tx_priv->tx_mclk_users);
- mutex_lock(&tx_priv->mclk_lock);
- if (mclk_enable) {
- ret = bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- TX_CORE_CLK,
- true);
- if (ret < 0) {
- dev_err_ratelimited(tx_priv->dev,
- "%s: request clock enable failed\n",
- __func__);
- goto exit;
- }
- bolero_clk_rsc_fs_gen_request(tx_priv->dev,
- true);
- regcache_mark_dirty(regmap);
- regcache_sync_region(regmap,
- TX_START_OFFSET,
- TX_MAX_OFFSET);
- if (tx_priv->tx_mclk_users == 0) {
- /* 9.6MHz MCLK, set value 0x00 if other frequency */
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_TOP_CSR_FREQ_MCLK, 0x01, 0x01);
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
- 0x01, 0x01);
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
- 0x01, 0x01);
- }
- tx_priv->tx_mclk_users++;
- } else {
- if (tx_priv->tx_mclk_users <= 0) {
- dev_err(tx_priv->dev, "%s: clock already disabled\n",
- __func__);
- tx_priv->tx_mclk_users = 0;
- goto exit;
- }
- tx_priv->tx_mclk_users--;
- if (tx_priv->tx_mclk_users == 0) {
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
- 0x01, 0x00);
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
- 0x01, 0x00);
- }
- bolero_clk_rsc_fs_gen_request(tx_priv->dev,
- false);
- bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- TX_CORE_CLK,
- false);
- }
- exit:
- mutex_unlock(&tx_priv->mclk_lock);
- return ret;
- }
- static int __tx_macro_mclk_enable(struct snd_soc_component *component,
- bool enable)
- {
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- return tx_macro_mclk_enable(tx_priv, enable);
- }
- static int tx_macro_va_swr_clk_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(w->dapm);
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- if (SND_SOC_DAPM_EVENT_ON(event))
- ++tx_priv->va_swr_clk_cnt;
- if (SND_SOC_DAPM_EVENT_OFF(event))
- --tx_priv->va_swr_clk_cnt;
- return 0;
- }
- static int tx_macro_tx_swr_clk_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(w->dapm);
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- if (SND_SOC_DAPM_EVENT_ON(event))
- ++tx_priv->tx_swr_clk_cnt;
- if (SND_SOC_DAPM_EVENT_OFF(event))
- --tx_priv->tx_swr_clk_cnt;
- return 0;
- }
- static int tx_macro_swr_pwr_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(w->dapm);
- int ret = 0;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- dev_dbg(tx_dev, "%s: event = %d, lpi_enable = %d\n",
- __func__, event, tx_priv->lpi_enable);
- if (!tx_priv->lpi_enable)
- return ret;
- switch (event) {
- case SND_SOC_DAPM_PRE_PMU:
- if (tx_priv->lpi_enable) {
- bolero_register_event_listener(component, true);
- tx_priv->register_event_listener = true;
- }
- break;
- case SND_SOC_DAPM_POST_PMD:
- if (tx_priv->register_event_listener) {
- tx_priv->register_event_listener = false;
- bolero_register_event_listener(component, false);
- }
- break;
- default:
- dev_err(tx_priv->dev,
- "%s: invalid DAPM event %d\n", __func__, event);
- ret = -EINVAL;
- }
- return ret;
- }
- static int tx_macro_mclk_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(w->dapm);
- int ret = 0;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- dev_dbg(tx_dev, "%s: event = %d\n", __func__, event);
- switch (event) {
- case SND_SOC_DAPM_PRE_PMU:
- ret = tx_macro_mclk_enable(tx_priv, 1);
- if (ret)
- tx_priv->dapm_mclk_enable = false;
- else
- tx_priv->dapm_mclk_enable = true;
- break;
- case SND_SOC_DAPM_POST_PMD:
- if (tx_priv->dapm_mclk_enable)
- ret = tx_macro_mclk_enable(tx_priv, 0);
- break;
- default:
- dev_err(tx_priv->dev,
- "%s: invalid DAPM event %d\n", __func__, event);
- ret = -EINVAL;
- }
- return ret;
- }
- static int tx_macro_event_handler(struct snd_soc_component *component,
- u16 event, u32 data)
- {
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- int ret = 0;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- switch (event) {
- case BOLERO_MACRO_EVT_SSR_DOWN:
- if (tx_priv->swr_ctrl_data) {
- swrm_wcd_notify(
- tx_priv->swr_ctrl_data[0].tx_swr_pdev,
- SWR_DEVICE_SSR_DOWN, NULL);
- }
- if ((!pm_runtime_enabled(tx_dev) ||
- !pm_runtime_suspended(tx_dev))) {
- ret = bolero_runtime_suspend(tx_dev);
- if (!ret) {
- pm_runtime_disable(tx_dev);
- pm_runtime_set_suspended(tx_dev);
- pm_runtime_enable(tx_dev);
- }
- }
- break;
- case BOLERO_MACRO_EVT_SSR_UP:
- /* reset swr after ssr/pdr */
- tx_priv->reset_swr = true;
- if (tx_priv->swr_ctrl_data)
- swrm_wcd_notify(
- tx_priv->swr_ctrl_data[0].tx_swr_pdev,
- SWR_DEVICE_SSR_UP, NULL);
- break;
- case BOLERO_MACRO_EVT_CLK_RESET:
- bolero_rsc_clk_reset(tx_dev, TX_CORE_CLK);
- break;
- case BOLERO_MACRO_EVT_BCS_CLK_OFF:
- if (tx_priv->bcs_clk_en)
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40, data << 6);
- if (data)
- tx_priv->hs_slow_insert_complete = true;
- else
- tx_priv->hs_slow_insert_complete = false;
- break;
- default:
- pr_debug("%s Invalid Event\n", __func__);
- break;
- }
- return 0;
- }
- static int tx_macro_reg_wake_irq(struct snd_soc_component *component,
- u32 data)
- {
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- u32 ipc_wakeup = data;
- int ret = 0;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- if (tx_priv->swr_ctrl_data)
- ret = swrm_wcd_notify(
- tx_priv->swr_ctrl_data[0].tx_swr_pdev,
- SWR_REGISTER_WAKE_IRQ, &ipc_wakeup);
- return ret;
- }
- static bool is_amic_enabled(struct snd_soc_component *component, int decimator)
- {
- u16 adc_mux_reg = 0, adc_reg = 0;
- u16 adc_n = BOLERO_ADC_MAX;
- bool ret = false;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return ret;
- adc_mux_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
- TX_MACRO_ADC_MUX_CFG_OFFSET * decimator;
- if (snd_soc_component_read(component, adc_mux_reg) & SWR_MIC) {
- if (tx_priv->version == BOLERO_VERSION_2_1)
- return true;
- adc_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
- TX_MACRO_ADC_MUX_CFG_OFFSET * decimator;
- adc_n = snd_soc_component_read(component, adc_reg) &
- TX_MACRO_SWR_MIC_MUX_SEL_MASK;
- if (adc_n < BOLERO_ADC_MAX)
- return true;
- }
- return ret;
- }
- static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work)
- {
- struct delayed_work *hpf_delayed_work = NULL;
- struct hpf_work *hpf_work = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- struct snd_soc_component *component = NULL;
- u16 dec_cfg_reg = 0, hpf_gate_reg = 0;
- u8 hpf_cut_off_freq = 0;
- u16 adc_reg = 0, adc_n = 0;
- hpf_delayed_work = to_delayed_work(work);
- hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
- tx_priv = hpf_work->tx_priv;
- component = tx_priv->component;
- hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
- dec_cfg_reg = BOLERO_CDC_TX0_TX_PATH_CFG0 +
- TX_MACRO_TX_PATH_OFFSET * hpf_work->decimator;
- hpf_gate_reg = BOLERO_CDC_TX0_TX_PATH_SEC2 +
- TX_MACRO_TX_PATH_OFFSET * hpf_work->decimator;
- dev_dbg(component->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
- __func__, hpf_work->decimator, hpf_cut_off_freq);
- if (is_amic_enabled(component, hpf_work->decimator)) {
- adc_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
- TX_MACRO_ADC_MUX_CFG_OFFSET * hpf_work->decimator;
- adc_n = snd_soc_component_read(component, adc_reg) &
- TX_MACRO_SWR_MIC_MUX_SEL_MASK;
- /* analog mic clear TX hold */
- bolero_clear_amic_tx_hold(component->dev, adc_n);
- snd_soc_component_update_bits(component,
- dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
- hpf_cut_off_freq << 5);
- snd_soc_component_update_bits(component, hpf_gate_reg,
- 0x03, 0x02);
- /* Add delay between toggle hpf gate based on sample rate */
- switch (tx_priv->pcm_rate[hpf_work->decimator]) {
- case 0:
- usleep_range(125, 130);
- break;
- case 1:
- usleep_range(62, 65);
- break;
- case 3:
- usleep_range(31, 32);
- break;
- case 4:
- usleep_range(20, 21);
- break;
- case 5:
- usleep_range(10, 11);
- break;
- case 6:
- usleep_range(5, 6);
- break;
- default:
- usleep_range(125, 130);
- }
- snd_soc_component_update_bits(component, hpf_gate_reg,
- 0x03, 0x01);
- } else {
- snd_soc_component_update_bits(component,
- dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
- hpf_cut_off_freq << 5);
- snd_soc_component_update_bits(component, hpf_gate_reg,
- 0x02, 0x02);
- /* Minimum 1 clk cycle delay is required as per HW spec */
- usleep_range(1000, 1010);
- snd_soc_component_update_bits(component, hpf_gate_reg,
- 0x02, 0x00);
- }
- }
- static void tx_macro_mute_update_callback(struct work_struct *work)
- {
- struct tx_mute_work *tx_mute_dwork = NULL;
- struct snd_soc_component *component = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- struct delayed_work *delayed_work = NULL;
- u16 tx_vol_ctl_reg = 0;
- u8 decimator = 0;
- delayed_work = to_delayed_work(work);
- tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
- tx_priv = tx_mute_dwork->tx_priv;
- component = tx_priv->component;
- decimator = tx_mute_dwork->decimator;
- tx_vol_ctl_reg =
- BOLERO_CDC_TX0_TX_PATH_CTL +
- TX_MACRO_TX_PATH_OFFSET * decimator;
- snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00);
- dev_dbg(tx_priv->dev, "%s: decimator %u unmute\n",
- __func__, decimator);
- }
- static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_dapm_widget *widget =
- snd_soc_dapm_kcontrol_widget(kcontrol);
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(widget->dapm);
- struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
- unsigned int val = 0;
- u16 mic_sel_reg = 0;
- u16 dmic_clk_reg = 0;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- val = ucontrol->value.enumerated.item[0];
- if (val > e->items - 1)
- return -EINVAL;
- dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__,
- widget->name, val);
- switch (e->reg) {
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0:
- mic_sel_reg = BOLERO_CDC_TX0_TX_PATH_CFG0;
- break;
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0:
- mic_sel_reg = BOLERO_CDC_TX1_TX_PATH_CFG0;
- break;
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0:
- mic_sel_reg = BOLERO_CDC_TX2_TX_PATH_CFG0;
- break;
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0:
- mic_sel_reg = BOLERO_CDC_TX3_TX_PATH_CFG0;
- break;
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
- mic_sel_reg = BOLERO_CDC_TX4_TX_PATH_CFG0;
- break;
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
- mic_sel_reg = BOLERO_CDC_TX5_TX_PATH_CFG0;
- break;
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
- mic_sel_reg = BOLERO_CDC_TX6_TX_PATH_CFG0;
- break;
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
- mic_sel_reg = BOLERO_CDC_TX7_TX_PATH_CFG0;
- break;
- default:
- dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
- __func__, e->reg);
- return -EINVAL;
- }
- if (strnstr(widget->name, "SMIC", strlen(widget->name))) {
- if (val != 0) {
- if (val < 5) {
- snd_soc_component_update_bits(component,
- mic_sel_reg,
- 1 << 7, 0x0 << 7);
- } else {
- snd_soc_component_update_bits(component,
- mic_sel_reg,
- 1 << 7, 0x1 << 7);
- snd_soc_component_update_bits(component,
- BOLERO_CDC_VA_TOP_CSR_DMIC_CFG,
- 0x80, 0x00);
- dmic_clk_reg =
- BOLERO_CDC_TX_TOP_CSR_SWR_DMIC0_CTL +
- ((val - 5)/2) * 4;
- snd_soc_component_update_bits(component,
- dmic_clk_reg,
- 0x0E, tx_priv->dmic_clk_div << 0x1);
- }
- }
- } else {
- /* DMIC selected */
- if (val != 0)
- snd_soc_component_update_bits(component, mic_sel_reg,
- 1 << 7, 1 << 7);
- }
- return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
- }
- static int tx_macro_put_dec_enum_v2(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_dapm_widget *widget =
- snd_soc_dapm_kcontrol_widget(kcontrol);
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(widget->dapm);
- struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
- unsigned int val = 0;
- u16 mic_sel_reg = 0;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- val = ucontrol->value.enumerated.item[0];
- if (val > e->items - 1)
- return -EINVAL;
- dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__,
- widget->name, val);
- switch (e->reg) {
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0:
- mic_sel_reg = BOLERO_CDC_TX0_TX_PATH_CFG0;
- break;
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0:
- mic_sel_reg = BOLERO_CDC_TX1_TX_PATH_CFG0;
- break;
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0:
- mic_sel_reg = BOLERO_CDC_TX2_TX_PATH_CFG0;
- break;
- case BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0:
- mic_sel_reg = BOLERO_CDC_TX3_TX_PATH_CFG0;
- break;
- default:
- dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
- __func__, e->reg);
- return -EINVAL;
- }
- if (strnstr(widget->name, "SMIC", strlen(widget->name))) {
- if (val != 0) {
- snd_soc_component_update_bits(component,
- mic_sel_reg,
- 1 << 7, 0x0 << 7);
- }
- } else {
- /* DMIC selected */
- if (val != 0)
- snd_soc_component_update_bits(component, mic_sel_reg,
- 1 << 7, 1 << 7);
- }
- return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
- }
- static int tx_macro_put_pcm_in_enum(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_dapm_widget *widget =
- snd_soc_dapm_kcontrol_widget(kcontrol);
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(widget->dapm);
- struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
- unsigned int val = 0;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- val = ucontrol->value.enumerated.item[0];
- if (val > e->items - 1)
- return -EINVAL;
- dev_dbg(component->dev, "%s: wname: %s\n", __func__, widget->name);
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_I2S_CLK,
- 0x1, val);
- return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
- }
- static int tx_macro_tx_mixer_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_dapm_widget *widget =
- snd_soc_dapm_kcontrol_widget(kcontrol);
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(widget->dapm);
- struct soc_multi_mixer_control *mixer =
- ((struct soc_multi_mixer_control *)kcontrol->private_value);
- u32 dai_id = widget->shift;
- u32 dec_id = mixer->shift;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- if (test_bit(dec_id, &tx_priv->active_ch_mask[dai_id]))
- ucontrol->value.integer.value[0] = 1;
- else
- ucontrol->value.integer.value[0] = 0;
- return 0;
- }
- static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_dapm_widget *widget =
- snd_soc_dapm_kcontrol_widget(kcontrol);
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(widget->dapm);
- struct snd_soc_dapm_update *update = NULL;
- struct soc_multi_mixer_control *mixer =
- ((struct soc_multi_mixer_control *)kcontrol->private_value);
- u32 dai_id = widget->shift;
- u32 dec_id = mixer->shift;
- u32 enable = ucontrol->value.integer.value[0];
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- if (enable)
- set_bit(dec_id, &tx_priv->active_ch_mask[dai_id]);
- else
- clear_bit(dec_id, &tx_priv->active_ch_mask[dai_id]);
- snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
- return 0;
- }
- static inline int tx_macro_path_get(const char *wname,
- unsigned int *path_num)
- {
- int ret = 0;
- char *widget_name = NULL;
- char *w_name = NULL;
- char *path_num_char = NULL;
- char *path_name = NULL;
- widget_name = kstrndup(wname, 10, GFP_KERNEL);
- if (!widget_name)
- return -EINVAL;
- w_name = widget_name;
- path_name = strsep(&widget_name, " ");
- if (!path_name) {
- pr_err("%s: Invalid widget name = %s\n",
- __func__, widget_name);
- ret = -EINVAL;
- goto err;
- }
- path_num_char = strpbrk(path_name, "01234567");
- if (!path_num_char) {
- pr_err("%s: tx path index not found\n",
- __func__);
- ret = -EINVAL;
- goto err;
- }
- ret = kstrtouint(path_num_char, 10, path_num);
- if (ret < 0)
- pr_err("%s: Invalid tx path = %s\n",
- __func__, w_name);
- err:
- kfree(w_name);
- return ret;
- }
- static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct tx_macro_priv *tx_priv = NULL;
- struct device *tx_dev = NULL;
- int ret = 0;
- int path = 0;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- ret = tx_macro_path_get(kcontrol->id.name, &path);
- if (ret)
- return ret;
- ucontrol->value.integer.value[0] = tx_priv->dec_mode[path];
- return 0;
- }
- static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct tx_macro_priv *tx_priv = NULL;
- struct device *tx_dev = NULL;
- int value = ucontrol->value.integer.value[0];
- int ret = 0;
- int path = 0;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- ret = tx_macro_path_get(kcontrol->id.name, &path);
- if (ret)
- return ret;
- tx_priv->dec_mode[path] = value;
- return 0;
- }
- static int tx_macro_lpi_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- ucontrol->value.integer.value[0] = tx_priv->lpi_enable;
- return 0;
- }
- static int tx_macro_lpi_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- tx_priv->lpi_enable = ucontrol->value.integer.value[0];
- return 0;
- }
- static int tx_macro_bcs_ch_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct tx_macro_priv *tx_priv = NULL;
- struct device *tx_dev = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- ucontrol->value.enumerated.item[0] = tx_priv->bcs_ch;
- return 0;
- }
- static int tx_macro_bcs_ch_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct tx_macro_priv *tx_priv = NULL;
- struct device *tx_dev = NULL;
- int value = ucontrol->value.enumerated.item[0];
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- tx_priv->bcs_ch = value;
- return 0;
- }
- static int tx_macro_get_bcs(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct tx_macro_priv *tx_priv = NULL;
- struct device *tx_dev = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- ucontrol->value.integer.value[0] = tx_priv->bcs_enable;
- return 0;
- }
- static int tx_macro_set_bcs(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct tx_macro_priv *tx_priv = NULL;
- struct device *tx_dev = NULL;
- int value = ucontrol->value.integer.value[0];
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- tx_priv->bcs_enable = value;
- return 0;
- }
- static const char * const bcs_ch_sel_mux_text[] = {
- "SWR_MIC0", "SWR_MIC1", "SWR_MIC2", "SWR_MIC3",
- "SWR_MIC4", "SWR_MIC5", "SWR_MIC6", "SWR_MIC7",
- "SWR_MIC8", "SWR_MIC9", "SWR_MIC10", "SWR_MIC11",
- };
- static const struct soc_enum bcs_ch_sel_mux_enum =
- SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(bcs_ch_sel_mux_text),
- bcs_ch_sel_mux_text);
- static int tx_macro_get_bcs_ch_sel(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct tx_macro_priv *tx_priv = NULL;
- struct device *tx_dev = NULL;
- int value = 0;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- if ((tx_priv->version == BOLERO_VERSION_2_1) ||
- (tx_priv->version == BOLERO_VERSION_2_2))
- value = (snd_soc_component_read(component,
- BOLERO_CDC_VA_TOP_CSR_SWR_CTRL)) & 0x0F;
- else if (tx_priv->version == BOLERO_VERSION_2_0)
- value = (snd_soc_component_read(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_CTRL)) & 0x0F;
- ucontrol->value.integer.value[0] = value;
- return 0;
- }
- static int tx_macro_put_bcs_ch_sel(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_component *component =
- snd_soc_kcontrol_component(kcontrol);
- struct tx_macro_priv *tx_priv = NULL;
- struct device *tx_dev = NULL;
- int value;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- if (ucontrol->value.integer.value[0] < 0 ||
- ucontrol->value.integer.value[0] > ARRAY_SIZE(bcs_ch_sel_mux_text))
- return -EINVAL;
- value = ucontrol->value.integer.value[0];
- if ((tx_priv->version == BOLERO_VERSION_2_1) ||
- (tx_priv->version == BOLERO_VERSION_2_2))
- snd_soc_component_update_bits(component,
- BOLERO_CDC_VA_TOP_CSR_SWR_CTRL, 0x0F, value);
- else if (tx_priv->version == BOLERO_VERSION_2_0)
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_CTRL, 0x0F, value);
- return 0;
- }
- static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(w->dapm);
- unsigned int dmic = 0;
- int ret = 0;
- char *wname = NULL;
- wname = strpbrk(w->name, "01234567");
- if (!wname) {
- dev_err(component->dev, "%s: widget not found\n", __func__);
- return -EINVAL;
- }
- ret = kstrtouint(wname, 10, &dmic);
- if (ret < 0) {
- dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
- __func__);
- return -EINVAL;
- }
- dev_dbg(component->dev, "%s: event %d DMIC%d\n",
- __func__, event, dmic);
- switch (event) {
- case SND_SOC_DAPM_PRE_PMU:
- bolero_dmic_clk_enable(component, dmic, DMIC_TX, true);
- break;
- case SND_SOC_DAPM_POST_PMD:
- bolero_dmic_clk_enable(component, dmic, DMIC_TX, false);
- break;
- }
- return 0;
- }
- static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct snd_soc_component *component =
- snd_soc_dapm_to_component(w->dapm);
- unsigned int decimator = 0;
- u16 tx_vol_ctl_reg = 0;
- u16 dec_cfg_reg = 0;
- u16 hpf_gate_reg = 0;
- u16 tx_gain_ctl_reg = 0;
- u16 tx_fs_reg = 0;
- u8 hpf_cut_off_freq = 0;
- u16 adc_mux_reg = 0;
- int hpf_delay = TX_MACRO_DMIC_HPF_DELAY_MS;
- int unmute_delay = TX_MACRO_DMIC_UNMUTE_DELAY_MS;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- decimator = w->shift;
- dev_dbg(component->dev, "%s(): widget = %s decimator = %u\n", __func__,
- w->name, decimator);
- tx_vol_ctl_reg = BOLERO_CDC_TX0_TX_PATH_CTL +
- TX_MACRO_TX_PATH_OFFSET * decimator;
- hpf_gate_reg = BOLERO_CDC_TX0_TX_PATH_SEC2 +
- TX_MACRO_TX_PATH_OFFSET * decimator;
- dec_cfg_reg = BOLERO_CDC_TX0_TX_PATH_CFG0 +
- TX_MACRO_TX_PATH_OFFSET * decimator;
- tx_gain_ctl_reg = BOLERO_CDC_TX0_TX_VOL_CTL +
- TX_MACRO_TX_PATH_OFFSET * decimator;
- adc_mux_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
- TX_MACRO_ADC_MUX_CFG_OFFSET * decimator;
- tx_fs_reg = BOLERO_CDC_TX0_TX_PATH_CTL +
- TX_MACRO_TX_PATH_OFFSET * decimator;
- tx_priv->pcm_rate[decimator] = (snd_soc_component_read(component,
- tx_fs_reg) & 0x0F);
- switch (event) {
- case SND_SOC_DAPM_PRE_PMU:
- snd_soc_component_update_bits(component,
- dec_cfg_reg, 0x06, tx_priv->dec_mode[decimator] <<
- TX_MACRO_ADC_MODE_CFG0_SHIFT);
- /* Enable TX PGA Mute */
- snd_soc_component_update_bits(component,
- tx_vol_ctl_reg, 0x10, 0x10);
- break;
- case SND_SOC_DAPM_POST_PMU:
- snd_soc_component_update_bits(component,
- tx_vol_ctl_reg, 0x20, 0x20);
- if (!is_amic_enabled(component, decimator)) {
- snd_soc_component_update_bits(component,
- hpf_gate_reg, 0x01, 0x00);
- /*
- * Minimum 1 clk cycle delay is required as per HW spec
- */
- usleep_range(1000, 1010);
- }
- hpf_cut_off_freq = (
- snd_soc_component_read(component, dec_cfg_reg) &
- TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
- tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq =
- hpf_cut_off_freq;
- if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
- snd_soc_component_update_bits(component, dec_cfg_reg,
- TX_HPF_CUT_OFF_FREQ_MASK,
- CF_MIN_3DB_150HZ << 5);
- if (is_amic_enabled(component, decimator)) {
- hpf_delay = TX_MACRO_AMIC_HPF_DELAY_MS;
- unmute_delay = TX_MACRO_AMIC_UNMUTE_DELAY_MS;
- }
- if (tx_unmute_delay < unmute_delay)
- tx_unmute_delay = unmute_delay;
- /* schedule work queue to Remove Mute */
- queue_delayed_work(system_freezable_wq,
- &tx_priv->tx_mute_dwork[decimator].dwork,
- msecs_to_jiffies(tx_unmute_delay));
- if (tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq !=
- CF_MIN_3DB_150HZ) {
- queue_delayed_work(system_freezable_wq,
- &tx_priv->tx_hpf_work[decimator].dwork,
- msecs_to_jiffies(hpf_delay));
- snd_soc_component_update_bits(component,
- hpf_gate_reg, 0x03, 0x02);
- if (!is_amic_enabled(component, decimator))
- snd_soc_component_update_bits(component,
- hpf_gate_reg, 0x03, 0x00);
- snd_soc_component_update_bits(component,
- hpf_gate_reg, 0x03, 0x01);
- /*
- * 6ms delay is required as per HW spec
- */
- usleep_range(6000, 6010);
- }
- /* apply gain after decimator is enabled */
- snd_soc_component_write(component, tx_gain_ctl_reg,
- snd_soc_component_read(component,
- tx_gain_ctl_reg));
- if (tx_priv->bcs_enable) {
- if ((tx_priv->version == BOLERO_VERSION_2_1) ||
- (tx_priv->version == BOLERO_VERSION_2_2))
- snd_soc_component_update_bits(component,
- BOLERO_CDC_VA_TOP_CSR_SWR_CTRL, 0x0F,
- tx_priv->bcs_ch);
- else if (tx_priv->version == BOLERO_VERSION_2_0)
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_CTRL, 0xF0,
- (tx_priv->bcs_ch << 4));
- snd_soc_component_update_bits(component, dec_cfg_reg,
- 0x01, 0x01);
- tx_priv->bcs_clk_en = true;
- if (tx_priv->hs_slow_insert_complete)
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40,
- 0x40);
- }
- if (tx_priv->version == BOLERO_VERSION_2_0) {
- if (snd_soc_component_read(component, adc_mux_reg)
- & SWR_MIC) {
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_CTRL,
- 0x01, 0x01);
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_MIC0_CTL,
- 0x0E, 0x0C);
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_MIC1_CTL,
- 0x0E, 0x0C);
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_MIC2_CTL,
- 0x0E, 0x00);
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_MIC3_CTL,
- 0x0E, 0x00);
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_MIC4_CTL,
- 0x0E, 0x00);
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_MIC5_CTL,
- 0x0E, 0x00);
- }
- }
- break;
- case SND_SOC_DAPM_PRE_PMD:
- hpf_cut_off_freq =
- tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq;
- snd_soc_component_update_bits(component,
- tx_vol_ctl_reg, 0x10, 0x10);
- if (cancel_delayed_work_sync(
- &tx_priv->tx_hpf_work[decimator].dwork)) {
- if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
- snd_soc_component_update_bits(
- component, dec_cfg_reg,
- TX_HPF_CUT_OFF_FREQ_MASK,
- hpf_cut_off_freq << 5);
- if (is_amic_enabled(component, decimator))
- snd_soc_component_update_bits(component,
- hpf_gate_reg,
- 0x03, 0x02);
- else
- snd_soc_component_update_bits(component,
- hpf_gate_reg,
- 0x03, 0x03);
- /*
- * Minimum 1 clk cycle delay is required
- * as per HW spec
- */
- usleep_range(1000, 1010);
- snd_soc_component_update_bits(component,
- hpf_gate_reg,
- 0x03, 0x01);
- }
- }
- cancel_delayed_work_sync(
- &tx_priv->tx_mute_dwork[decimator].dwork);
- if (tx_priv->version == BOLERO_VERSION_2_0) {
- if (snd_soc_component_read(component, adc_mux_reg)
- & SWR_MIC)
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_CTRL,
- 0x01, 0x00);
- }
- break;
- case SND_SOC_DAPM_POST_PMD:
- snd_soc_component_update_bits(component, tx_vol_ctl_reg,
- 0x20, 0x00);
- snd_soc_component_update_bits(component,
- dec_cfg_reg, 0x06, 0x00);
- snd_soc_component_update_bits(component, tx_vol_ctl_reg,
- 0x40, 0x40);
- snd_soc_component_update_bits(component, tx_vol_ctl_reg,
- 0x40, 0x00);
- snd_soc_component_update_bits(component, tx_vol_ctl_reg,
- 0x10, 0x00);
- if (tx_priv->bcs_enable) {
- snd_soc_component_update_bits(component, dec_cfg_reg,
- 0x01, 0x00);
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40, 0x00);
- tx_priv->bcs_clk_en = false;
- if ((tx_priv->version == BOLERO_VERSION_2_1) ||
- (tx_priv->version == BOLERO_VERSION_2_2))
- snd_soc_component_update_bits(component,
- BOLERO_CDC_VA_TOP_CSR_SWR_CTRL, 0x0F,
- 0x00);
- else if (tx_priv->version == BOLERO_VERSION_2_0)
- snd_soc_component_update_bits(component,
- BOLERO_CDC_TX_TOP_CSR_SWR_CTRL, 0xF0,
- 0x00);
- }
- break;
- }
- return 0;
- }
- static int tx_macro_enable_micbias(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- return 0;
- }
- /* Cutoff frequency for high pass filter */
- static const char * const cf_text[] = {
- "CF_NEG_3DB_4HZ", "CF_NEG_3DB_75HZ", "CF_NEG_3DB_150HZ"
- };
- static SOC_ENUM_SINGLE_DECL(cf_dec0_enum, BOLERO_CDC_TX0_TX_PATH_CFG0, 5,
- cf_text);
- static SOC_ENUM_SINGLE_DECL(cf_dec1_enum, BOLERO_CDC_TX1_TX_PATH_CFG0, 5,
- cf_text);
- static SOC_ENUM_SINGLE_DECL(cf_dec2_enum, BOLERO_CDC_TX2_TX_PATH_CFG0, 5,
- cf_text);
- static SOC_ENUM_SINGLE_DECL(cf_dec3_enum, BOLERO_CDC_TX3_TX_PATH_CFG0, 5,
- cf_text);
- static SOC_ENUM_SINGLE_DECL(cf_dec4_enum, BOLERO_CDC_TX4_TX_PATH_CFG0, 5,
- cf_text);
- static SOC_ENUM_SINGLE_DECL(cf_dec5_enum, BOLERO_CDC_TX5_TX_PATH_CFG0, 5,
- cf_text);
- static SOC_ENUM_SINGLE_DECL(cf_dec6_enum, BOLERO_CDC_TX6_TX_PATH_CFG0, 5,
- cf_text);
- static SOC_ENUM_SINGLE_DECL(cf_dec7_enum, BOLERO_CDC_TX7_TX_PATH_CFG0, 5,
- cf_text);
- static int tx_macro_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai)
- {
- int tx_fs_rate = -EINVAL;
- struct snd_soc_component *component = dai->component;
- u32 decimator = 0;
- u32 sample_rate = 0;
- u16 tx_fs_reg = 0;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
- dai->name, dai->id, params_rate(params),
- params_channels(params));
- sample_rate = params_rate(params);
- switch (sample_rate) {
- case 8000:
- tx_fs_rate = 0;
- break;
- case 16000:
- tx_fs_rate = 1;
- break;
- case 32000:
- tx_fs_rate = 3;
- break;
- case 48000:
- tx_fs_rate = 4;
- break;
- case 96000:
- tx_fs_rate = 5;
- break;
- case 192000:
- tx_fs_rate = 6;
- break;
- case 384000:
- tx_fs_rate = 7;
- break;
- default:
- dev_err(component->dev, "%s: Invalid TX sample rate: %d\n",
- __func__, params_rate(params));
- return -EINVAL;
- }
- for_each_set_bit(decimator, &tx_priv->active_ch_mask[dai->id],
- TX_MACRO_DEC_MAX) {
- if (decimator >= 0) {
- tx_fs_reg = BOLERO_CDC_TX0_TX_PATH_CTL +
- TX_MACRO_TX_PATH_OFFSET * decimator;
- dev_dbg(component->dev, "%s: set DEC%u rate to %u\n",
- __func__, decimator, sample_rate);
- snd_soc_component_update_bits(component, tx_fs_reg,
- 0x0F, tx_fs_rate);
- } else {
- dev_err(component->dev,
- "%s: ERROR: Invalid decimator: %d\n",
- __func__, decimator);
- return -EINVAL;
- }
- }
- return 0;
- }
- static int tx_macro_get_channel_map(struct snd_soc_dai *dai,
- unsigned int *tx_num, unsigned int *tx_slot,
- unsigned int *rx_num, unsigned int *rx_slot)
- {
- struct snd_soc_component *component = dai->component;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- switch (dai->id) {
- case TX_MACRO_AIF1_CAP:
- case TX_MACRO_AIF2_CAP:
- case TX_MACRO_AIF3_CAP:
- *tx_slot = tx_priv->active_ch_mask[dai->id];
- *tx_num = hweight_long(tx_priv->active_ch_mask[dai->id]);
- break;
- default:
- dev_err(tx_dev, "%s: Invalid AIF\n", __func__);
- break;
- }
- return 0;
- }
- static struct snd_soc_dai_ops tx_macro_dai_ops = {
- .hw_params = tx_macro_hw_params,
- .get_channel_map = tx_macro_get_channel_map,
- };
- static struct snd_soc_dai_driver tx_macro_dai[] = {
- {
- .name = "tx_macro_tx1",
- .id = TX_MACRO_AIF1_CAP,
- .capture = {
- .stream_name = "TX_AIF1 Capture",
- .rates = TX_MACRO_RATES,
- .formats = TX_MACRO_FORMATS,
- .rate_max = 192000,
- .rate_min = 8000,
- .channels_min = 1,
- .channels_max = 8,
- },
- .ops = &tx_macro_dai_ops,
- },
- {
- .name = "tx_macro_tx2",
- .id = TX_MACRO_AIF2_CAP,
- .capture = {
- .stream_name = "TX_AIF2 Capture",
- .rates = TX_MACRO_RATES,
- .formats = TX_MACRO_FORMATS,
- .rate_max = 192000,
- .rate_min = 8000,
- .channels_min = 1,
- .channels_max = 8,
- },
- .ops = &tx_macro_dai_ops,
- },
- {
- .name = "tx_macro_tx3",
- .id = TX_MACRO_AIF3_CAP,
- .capture = {
- .stream_name = "TX_AIF3 Capture",
- .rates = TX_MACRO_RATES,
- .formats = TX_MACRO_FORMATS,
- .rate_max = 192000,
- .rate_min = 8000,
- .channels_min = 1,
- .channels_max = 8,
- },
- .ops = &tx_macro_dai_ops,
- },
- };
- #define STRING(name) #name
- #define TX_MACRO_DAPM_ENUM(name, reg, offset, text) \
- static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
- static const struct snd_kcontrol_new name##_mux = \
- SOC_DAPM_ENUM(STRING(name), name##_enum)
- #define TX_MACRO_DAPM_ENUM_EXT(name, reg, offset, text, getname, putname) \
- static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
- static const struct snd_kcontrol_new name##_mux = \
- SOC_DAPM_ENUM_EXT(STRING(name), name##_enum, getname, putname)
- #define TX_MACRO_DAPM_MUX(name, shift, kctl) \
- SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, shift, 0, &kctl##_mux)
- static const char * const adc_mux_text[] = {
- "MSM_DMIC", "SWR_MIC", "ANC_FB_TUNE1"
- };
- TX_MACRO_DAPM_ENUM(tx_dec0, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG1,
- 0, adc_mux_text);
- TX_MACRO_DAPM_ENUM(tx_dec1, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG1,
- 0, adc_mux_text);
- TX_MACRO_DAPM_ENUM(tx_dec2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG1,
- 0, adc_mux_text);
- TX_MACRO_DAPM_ENUM(tx_dec3, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG1,
- 0, adc_mux_text);
- TX_MACRO_DAPM_ENUM(tx_dec4, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG1,
- 0, adc_mux_text);
- TX_MACRO_DAPM_ENUM(tx_dec5, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG1,
- 0, adc_mux_text);
- TX_MACRO_DAPM_ENUM(tx_dec6, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG1,
- 0, adc_mux_text);
- TX_MACRO_DAPM_ENUM(tx_dec7, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG1,
- 0, adc_mux_text);
- static const char * const dmic_mux_text[] = {
- "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3",
- "DMIC4", "DMIC5", "DMIC6", "DMIC7"
- };
- TX_MACRO_DAPM_ENUM_EXT(tx_dmic0, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0,
- 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_dmic1, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0,
- 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_dmic2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0,
- 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_dmic3, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0,
- 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_dmic4, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0,
- 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_dmic5, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0,
- 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_dmic6, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0,
- 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_dmic7, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0,
- 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- static const char * const smic_mux_text[] = {
- "ZERO", "ADC0", "ADC1", "ADC2", "ADC3", "SWR_DMIC0",
- "SWR_DMIC1", "SWR_DMIC2", "SWR_DMIC3", "SWR_DMIC4",
- "SWR_DMIC5", "SWR_DMIC6", "SWR_DMIC7"
- };
- TX_MACRO_DAPM_ENUM_EXT(tx_smic0, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0,
- 0, smic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic1, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0,
- 0, smic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0,
- 0, smic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic3, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0,
- 0, smic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic4, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0,
- 0, smic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic5, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0,
- 0, smic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic6, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0,
- 0, smic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic7, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0,
- 0, smic_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- static const char * const smic_mux_text_v2[] = {
- "ZERO", "SWR_MIC0", "SWR_MIC1", "SWR_MIC2", "SWR_MIC3",
- "SWR_MIC4", "SWR_MIC5", "SWR_MIC6", "SWR_MIC7",
- "SWR_MIC8", "SWR_MIC9", "SWR_MIC10", "SWR_MIC11"
- };
- TX_MACRO_DAPM_ENUM_EXT(tx_smic0_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic1_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic2_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic3_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic4_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic5_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic6_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic7_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic0_v4, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum_v2);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic1_v4, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum_v2);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic2_v4, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum_v2);
- TX_MACRO_DAPM_ENUM_EXT(tx_smic3_v4, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0,
- 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
- tx_macro_put_dec_enum_v2);
- static const char * const pcm_in0_mux_text[] = {
- "SWR_MIC", "RX_SWR_TX_PCM_IN0",
- };
- static const char * const pcm_in1_mux_text[] = {
- "SWR_MIC", "RX_SWR_TX_PCM_IN1",
- };
- TX_MACRO_DAPM_ENUM_EXT(rx_swr_tx_pcm_in0, SND_SOC_NOPM,
- 0, pcm_in0_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_pcm_in_enum);
- TX_MACRO_DAPM_ENUM_EXT(rx_swr_tx_pcm_in1, SND_SOC_NOPM,
- 0, pcm_in1_mux_text, snd_soc_dapm_get_enum_double,
- tx_macro_put_pcm_in_enum);
- static const char * const dec_mode_mux_text[] = {
- "ADC_DEFAULT", "ADC_LOW_PWR", "ADC_HIGH_PERF",
- };
- static const struct soc_enum dec_mode_mux_enum =
- SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(dec_mode_mux_text),
- dec_mode_mux_text);
- static const char * const bcs_ch_enum_text[] = {
- "CH0", "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8", "CH9",
- "CH10", "CH11",
- };
- static const struct soc_enum bcs_ch_enum =
- SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(bcs_ch_enum_text),
- bcs_ch_enum_text);
- static const struct snd_kcontrol_new tx_aif1_cap_mixer[] = {
- SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, TX_MACRO_DEC4, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, TX_MACRO_DEC5, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, TX_MACRO_DEC6, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, TX_MACRO_DEC7, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- };
- static const struct snd_kcontrol_new tx_aif2_cap_mixer[] = {
- SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, TX_MACRO_DEC4, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, TX_MACRO_DEC5, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, TX_MACRO_DEC6, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, TX_MACRO_DEC7, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- };
- static const struct snd_kcontrol_new tx_aif3_cap_mixer[] = {
- SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, TX_MACRO_DEC4, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, TX_MACRO_DEC5, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, TX_MACRO_DEC6, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, TX_MACRO_DEC7, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- };
- static const struct snd_kcontrol_new tx_aif1_cap_mixer_v2[] = {
- SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- };
- static const struct snd_kcontrol_new tx_aif2_cap_mixer_v2[] = {
- SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- };
- static const struct snd_kcontrol_new tx_aif3_cap_mixer_v2[] = {
- SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
- tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
- };
- static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_common[] = {
- SND_SOC_DAPM_AIF_OUT("TX_AIF1 CAP", "TX_AIF1 Capture", 0,
- SND_SOC_NOPM, TX_MACRO_AIF1_CAP, 0),
- SND_SOC_DAPM_AIF_OUT("TX_AIF2 CAP", "TX_AIF2 Capture", 0,
- SND_SOC_NOPM, TX_MACRO_AIF2_CAP, 0),
- SND_SOC_DAPM_AIF_OUT("TX_AIF3 CAP", "TX_AIF3 Capture", 0,
- SND_SOC_NOPM, TX_MACRO_AIF3_CAP, 0),
- TX_MACRO_DAPM_MUX("TX DMIC MUX0", 0, tx_dmic0),
- TX_MACRO_DAPM_MUX("TX DMIC MUX1", 0, tx_dmic1),
- TX_MACRO_DAPM_MUX("TX DMIC MUX2", 0, tx_dmic2),
- TX_MACRO_DAPM_MUX("TX DMIC MUX3", 0, tx_dmic3),
- SND_SOC_DAPM_SUPPLY("TX MIC BIAS1", SND_SOC_NOPM, 0, 0,
- tx_macro_enable_micbias,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC0", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC1", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC2", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC3", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC4", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC5", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC6", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC7", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_INPUT("TX SWR_INPUT"),
- SND_SOC_DAPM_MUX_E("TX DEC0 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC0, 0,
- &tx_dec0_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC1 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC1, 0,
- &tx_dec1_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC2 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC2, 0,
- &tx_dec2_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC3 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC3, 0,
- &tx_dec3_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY_S("TX_MCLK", 0, SND_SOC_NOPM, 0, 0,
- tx_macro_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY_S("TX_SWR_PWR", -1, SND_SOC_NOPM, 0, 0,
- tx_macro_swr_pwr_event,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- };
- static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_v2[] = {
- SND_SOC_DAPM_MIXER("TX_AIF1_CAP Mixer", SND_SOC_NOPM,
- TX_MACRO_AIF1_CAP, 0,
- tx_aif1_cap_mixer_v2, ARRAY_SIZE(tx_aif1_cap_mixer_v2)),
- SND_SOC_DAPM_MIXER("TX_AIF2_CAP Mixer", SND_SOC_NOPM,
- TX_MACRO_AIF2_CAP, 0,
- tx_aif2_cap_mixer_v2, ARRAY_SIZE(tx_aif2_cap_mixer_v2)),
- SND_SOC_DAPM_MIXER("TX_AIF3_CAP Mixer", SND_SOC_NOPM,
- TX_MACRO_AIF3_CAP, 0,
- tx_aif3_cap_mixer_v2, ARRAY_SIZE(tx_aif3_cap_mixer_v2)),
- TX_MACRO_DAPM_MUX("TX SMIC MUX0", 0, tx_smic0_v2),
- TX_MACRO_DAPM_MUX("TX SMIC MUX1", 0, tx_smic1_v2),
- TX_MACRO_DAPM_MUX("TX SMIC MUX2", 0, tx_smic2_v2),
- TX_MACRO_DAPM_MUX("TX SMIC MUX3", 0, tx_smic3_v2),
- };
- static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_v3[] = {
- SND_SOC_DAPM_MIXER("TX_AIF1_CAP Mixer", SND_SOC_NOPM,
- TX_MACRO_AIF1_CAP, 0,
- tx_aif1_cap_mixer, ARRAY_SIZE(tx_aif1_cap_mixer)),
- SND_SOC_DAPM_MIXER("TX_AIF2_CAP Mixer", SND_SOC_NOPM,
- TX_MACRO_AIF2_CAP, 0,
- tx_aif2_cap_mixer, ARRAY_SIZE(tx_aif2_cap_mixer)),
- SND_SOC_DAPM_MIXER("TX_AIF3_CAP Mixer", SND_SOC_NOPM,
- TX_MACRO_AIF3_CAP, 0,
- tx_aif3_cap_mixer, ARRAY_SIZE(tx_aif3_cap_mixer)),
- TX_MACRO_DAPM_MUX("TX DMIC MUX4", 0, tx_dmic4),
- TX_MACRO_DAPM_MUX("TX DMIC MUX5", 0, tx_dmic5),
- TX_MACRO_DAPM_MUX("TX DMIC MUX6", 0, tx_dmic6),
- TX_MACRO_DAPM_MUX("TX DMIC MUX7", 0, tx_dmic7),
- TX_MACRO_DAPM_MUX("TX SMIC MUX0", 0, tx_smic0_v2),
- TX_MACRO_DAPM_MUX("TX SMIC MUX1", 0, tx_smic1_v2),
- TX_MACRO_DAPM_MUX("TX SMIC MUX2", 0, tx_smic2_v2),
- TX_MACRO_DAPM_MUX("TX SMIC MUX3", 0, tx_smic3_v2),
- TX_MACRO_DAPM_MUX("TX SMIC MUX4", 0, tx_smic4_v3),
- TX_MACRO_DAPM_MUX("TX SMIC MUX5", 0, tx_smic5_v3),
- TX_MACRO_DAPM_MUX("TX SMIC MUX6", 0, tx_smic6_v3),
- TX_MACRO_DAPM_MUX("TX SMIC MUX7", 0, tx_smic7_v3),
- SND_SOC_DAPM_MUX_E("TX DEC4 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC4, 0,
- &tx_dec4_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC5 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC5, 0,
- &tx_dec5_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC6 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC6, 0,
- &tx_dec6_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC7 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC7, 0,
- &tx_dec7_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY_S("TX_SWR_CLK", -1, SND_SOC_NOPM, 0, 0,
- tx_macro_tx_swr_clk_event,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY_S("VA_SWR_CLK", -1, SND_SOC_NOPM, 0, 0,
- tx_macro_va_swr_clk_event,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- };
- static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_v4[] = {
- SND_SOC_DAPM_MIXER("TX_AIF1_CAP Mixer", SND_SOC_NOPM,
- TX_MACRO_AIF1_CAP, 0,
- tx_aif1_cap_mixer_v2, ARRAY_SIZE(tx_aif1_cap_mixer_v2)),
- SND_SOC_DAPM_MIXER("TX_AIF2_CAP Mixer", SND_SOC_NOPM,
- TX_MACRO_AIF2_CAP, 0,
- tx_aif2_cap_mixer_v2, ARRAY_SIZE(tx_aif2_cap_mixer_v2)),
- SND_SOC_DAPM_MIXER("TX_AIF3_CAP Mixer", SND_SOC_NOPM,
- TX_MACRO_AIF3_CAP, 0,
- tx_aif3_cap_mixer_v2, ARRAY_SIZE(tx_aif3_cap_mixer_v2)),
- TX_MACRO_DAPM_MUX("TX SMIC MUX0", 0, tx_smic0_v4),
- TX_MACRO_DAPM_MUX("TX SMIC MUX1", 0, tx_smic1_v4),
- TX_MACRO_DAPM_MUX("TX SMIC MUX2", 0, tx_smic2_v4),
- TX_MACRO_DAPM_MUX("TX SMIC MUX3", 0, tx_smic3_v4),
- TX_MACRO_DAPM_MUX("RX SWR TX MUX0", 0, rx_swr_tx_pcm_in0),
- TX_MACRO_DAPM_MUX("RX SWR TX MUX1", 0, rx_swr_tx_pcm_in1),
- SND_SOC_DAPM_INPUT("RX_SWR_TX_PCM_IN0"),
- SND_SOC_DAPM_INPUT("RX_SWR_TX_PCM_IN1"),
- };
- static const struct snd_soc_dapm_widget tx_macro_dapm_widgets[] = {
- SND_SOC_DAPM_AIF_OUT("TX_AIF1 CAP", "TX_AIF1 Capture", 0,
- SND_SOC_NOPM, TX_MACRO_AIF1_CAP, 0),
- SND_SOC_DAPM_AIF_OUT("TX_AIF2 CAP", "TX_AIF2 Capture", 0,
- SND_SOC_NOPM, TX_MACRO_AIF2_CAP, 0),
- SND_SOC_DAPM_AIF_OUT("TX_AIF3 CAP", "TX_AIF3 Capture", 0,
- SND_SOC_NOPM, TX_MACRO_AIF3_CAP, 0),
- SND_SOC_DAPM_MIXER("TX_AIF1_CAP Mixer", SND_SOC_NOPM, TX_MACRO_AIF1_CAP, 0,
- tx_aif1_cap_mixer, ARRAY_SIZE(tx_aif1_cap_mixer)),
- SND_SOC_DAPM_MIXER("TX_AIF2_CAP Mixer", SND_SOC_NOPM, TX_MACRO_AIF2_CAP, 0,
- tx_aif2_cap_mixer, ARRAY_SIZE(tx_aif2_cap_mixer)),
- SND_SOC_DAPM_MIXER("TX_AIF3_CAP Mixer", SND_SOC_NOPM, TX_MACRO_AIF3_CAP, 0,
- tx_aif3_cap_mixer, ARRAY_SIZE(tx_aif3_cap_mixer)),
- TX_MACRO_DAPM_MUX("TX DMIC MUX0", 0, tx_dmic0),
- TX_MACRO_DAPM_MUX("TX DMIC MUX1", 0, tx_dmic1),
- TX_MACRO_DAPM_MUX("TX DMIC MUX2", 0, tx_dmic2),
- TX_MACRO_DAPM_MUX("TX DMIC MUX3", 0, tx_dmic3),
- TX_MACRO_DAPM_MUX("TX DMIC MUX4", 0, tx_dmic4),
- TX_MACRO_DAPM_MUX("TX DMIC MUX5", 0, tx_dmic5),
- TX_MACRO_DAPM_MUX("TX DMIC MUX6", 0, tx_dmic6),
- TX_MACRO_DAPM_MUX("TX DMIC MUX7", 0, tx_dmic7),
- TX_MACRO_DAPM_MUX("TX SMIC MUX0", 0, tx_smic0),
- TX_MACRO_DAPM_MUX("TX SMIC MUX1", 0, tx_smic1),
- TX_MACRO_DAPM_MUX("TX SMIC MUX2", 0, tx_smic2),
- TX_MACRO_DAPM_MUX("TX SMIC MUX3", 0, tx_smic3),
- TX_MACRO_DAPM_MUX("TX SMIC MUX4", 0, tx_smic4),
- TX_MACRO_DAPM_MUX("TX SMIC MUX5", 0, tx_smic5),
- TX_MACRO_DAPM_MUX("TX SMIC MUX6", 0, tx_smic6),
- TX_MACRO_DAPM_MUX("TX SMIC MUX7", 0, tx_smic7),
- SND_SOC_DAPM_SUPPLY("TX MIC BIAS1", SND_SOC_NOPM, 0, 0,
- tx_macro_enable_micbias,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC0", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC1", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC2", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC3", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC4", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC5", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC6", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_ADC_E("TX DMIC7", NULL, SND_SOC_NOPM, 0, 0,
- tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
- SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_INPUT("TX SWR_ADC0"),
- SND_SOC_DAPM_INPUT("TX SWR_ADC1"),
- SND_SOC_DAPM_INPUT("TX SWR_ADC2"),
- SND_SOC_DAPM_INPUT("TX SWR_ADC3"),
- SND_SOC_DAPM_INPUT("TX SWR_DMIC0"),
- SND_SOC_DAPM_INPUT("TX SWR_DMIC1"),
- SND_SOC_DAPM_INPUT("TX SWR_DMIC2"),
- SND_SOC_DAPM_INPUT("TX SWR_DMIC3"),
- SND_SOC_DAPM_INPUT("TX SWR_DMIC4"),
- SND_SOC_DAPM_INPUT("TX SWR_DMIC5"),
- SND_SOC_DAPM_INPUT("TX SWR_DMIC6"),
- SND_SOC_DAPM_INPUT("TX SWR_DMIC7"),
- SND_SOC_DAPM_MUX_E("TX DEC0 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC0, 0,
- &tx_dec0_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC1 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC1, 0,
- &tx_dec1_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC2 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC2, 0,
- &tx_dec2_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC3 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC3, 0,
- &tx_dec3_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC4 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC4, 0,
- &tx_dec4_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC5 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC5, 0,
- &tx_dec5_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC6 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC6, 0,
- &tx_dec6_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_MUX_E("TX DEC7 MUX", SND_SOC_NOPM,
- TX_MACRO_DEC7, 0,
- &tx_dec7_mux, tx_macro_enable_dec,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
- SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY_S("TX_MCLK", 0, SND_SOC_NOPM, 0, 0,
- tx_macro_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY_S("TX_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
- tx_macro_tx_swr_clk_event,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY_S("VA_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
- tx_macro_va_swr_clk_event,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- };
- static const struct snd_soc_dapm_route tx_audio_map_common[] = {
- {"TX_AIF1 CAP", NULL, "TX_MCLK"},
- {"TX_AIF2 CAP", NULL, "TX_MCLK"},
- {"TX_AIF3 CAP", NULL, "TX_MCLK"},
- {"TX_AIF1 CAP", NULL, "TX_AIF1_CAP Mixer"},
- {"TX_AIF2 CAP", NULL, "TX_AIF2_CAP Mixer"},
- {"TX_AIF3 CAP", NULL, "TX_AIF3_CAP Mixer"},
- {"TX_AIF1_CAP Mixer", "DEC0", "TX DEC0 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC1", "TX DEC1 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC2", "TX DEC2 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC3", "TX DEC3 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC0", "TX DEC0 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC1", "TX DEC1 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC2", "TX DEC2 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC3", "TX DEC3 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC0", "TX DEC0 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC1", "TX DEC1 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC2", "TX DEC2 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC3", "TX DEC3 MUX"},
- {"TX DEC0 MUX", NULL, "TX_MCLK"},
- {"TX DEC1 MUX", NULL, "TX_MCLK"},
- {"TX DEC2 MUX", NULL, "TX_MCLK"},
- {"TX DEC3 MUX", NULL, "TX_MCLK"},
- {"TX DEC0 MUX", "MSM_DMIC", "TX DMIC MUX0"},
- {"TX DMIC MUX0", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX0", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX0", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX0", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX0", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX0", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX0", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX0", "DMIC7", "TX DMIC7"},
- {"TX DEC0 MUX", "SWR_MIC", "TX SMIC MUX0"},
- {"TX SMIC MUX0", "SWR_MIC0", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC1", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC2", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC3", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC4", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC5", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC6", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC7", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC8", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC9", "TX SWR_INPUT"},
- {"TX DEC1 MUX", "MSM_DMIC", "TX DMIC MUX1"},
- {"TX DMIC MUX1", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX1", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX1", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX1", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX1", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX1", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX1", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX1", "DMIC7", "TX DMIC7"},
- {"TX DEC1 MUX", "SWR_MIC", "TX SMIC MUX1"},
- {"TX SMIC MUX1", "SWR_MIC0", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC1", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC2", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC3", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC4", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC5", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC6", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC7", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC8", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC9", "TX SWR_INPUT"},
- {"TX DEC2 MUX", "MSM_DMIC", "TX DMIC MUX2"},
- {"TX DMIC MUX2", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX2", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX2", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX2", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX2", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX2", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX2", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX2", "DMIC7", "TX DMIC7"},
- {"TX DEC2 MUX", "SWR_MIC", "TX SMIC MUX2"},
- {"TX SMIC MUX2", "SWR_MIC0", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC1", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC2", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC3", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC4", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC5", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC6", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC7", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC8", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC9", "TX SWR_INPUT"},
- {"TX DEC3 MUX", "MSM_DMIC", "TX DMIC MUX3"},
- {"TX DMIC MUX3", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX3", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX3", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX3", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX3", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX3", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX3", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX3", "DMIC7", "TX DMIC7"},
- {"TX DEC3 MUX", "SWR_MIC", "TX SMIC MUX3"},
- {"TX SMIC MUX3", "SWR_MIC0", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC1", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC2", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC3", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC4", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC5", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC6", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC7", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC8", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC9", "TX SWR_INPUT"},
- };
- static const struct snd_soc_dapm_route tx_audio_map_v2[] = {
- {"TX SMIC MUX0", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC11", "TX SWR_INPUT"},
- };
- static const struct snd_soc_dapm_route tx_audio_map_v3[] = {
- {"TX SMIC MUX0", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX0", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX1", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX2", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX3", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX_AIF1_CAP Mixer", "DEC4", "TX DEC4 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC5", "TX DEC5 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC6", "TX DEC6 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC7", "TX DEC7 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC4", "TX DEC4 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC5", "TX DEC5 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC6", "TX DEC6 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC7", "TX DEC7 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC4", "TX DEC4 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC5", "TX DEC5 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC6", "TX DEC6 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC7", "TX DEC7 MUX"},
- {"TX DEC4 MUX", NULL, "TX_MCLK"},
- {"TX DEC5 MUX", NULL, "TX_MCLK"},
- {"TX DEC6 MUX", NULL, "TX_MCLK"},
- {"TX DEC7 MUX", NULL, "TX_MCLK"},
- {"TX DEC4 MUX", "MSM_DMIC", "TX DMIC MUX4"},
- {"TX DMIC MUX4", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX4", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX4", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX4", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX4", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX4", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX4", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX4", "DMIC7", "TX DMIC7"},
- {"TX DEC4 MUX", "SWR_MIC", "TX SMIC MUX4"},
- {"TX SMIC MUX4", "SWR_MIC0", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC1", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC2", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC3", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC4", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC5", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC6", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC7", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC8", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC9", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX4", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX DEC5 MUX", "MSM_DMIC", "TX DMIC MUX5"},
- {"TX DMIC MUX5", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX5", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX5", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX5", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX5", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX5", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX5", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX5", "DMIC7", "TX DMIC7"},
- {"TX DEC5 MUX", "SWR_MIC", "TX SMIC MUX5"},
- {"TX SMIC MUX5", "SWR_MIC0", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC1", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC2", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC3", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC4", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC5", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC6", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC7", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC8", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC9", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX5", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX DEC6 MUX", "MSM_DMIC", "TX DMIC MUX6"},
- {"TX DMIC MUX6", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX6", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX6", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX6", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX6", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX6", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX6", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX6", "DMIC7", "TX DMIC7"},
- {"TX DEC6 MUX", "SWR_MIC", "TX SMIC MUX6"},
- {"TX SMIC MUX6", "SWR_MIC0", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC1", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC2", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC3", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC4", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC5", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC6", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC7", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC8", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC9", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX6", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX DEC7 MUX", "MSM_DMIC", "TX DMIC MUX7"},
- {"TX DMIC MUX7", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX7", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX7", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX7", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX7", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX7", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX7", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX7", "DMIC7", "TX DMIC7"},
- {"TX DEC7 MUX", "SWR_MIC", "TX SMIC MUX7"},
- {"TX SMIC MUX7", "SWR_MIC0", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC1", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC2", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC3", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC4", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC5", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC6", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC7", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC8", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC9", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC10", "TX SWR_INPUT"},
- {"TX SMIC MUX7", "SWR_MIC11", "TX SWR_INPUT"},
- {"TX SMIC MUX0", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX1", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX2", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX3", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX4", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX5", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX6", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX7", NULL, "TX_SWR_CLK"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- {"TX SWR_INPUT", NULL, "TX_SWR_PWR"},
- };
- static const struct snd_soc_dapm_route tx_audio_map_v4[] = {
- {"TX SMIC MUX0", "SWR_MIC10", "RX SWR TX MUX0"},
- {"RX SWR TX MUX0", "SWR_MIC", "TX SWR_INPUT"},
- {"RX SWR TX MUX0", "RX_SWR_TX_PCM_IN0", "RX_SWR_TX_PCM_IN0"},
- {"TX SMIC MUX0", "SWR_MIC11", "RX SWR TX MUX1"},
- {"RX SWR TX MUX1", "SWR_MIC", "TX SWR_INPUT"},
- {"RX SWR TX MUX1", "RX_SWR_TX_PCM_IN1", "RX_SWR_TX_PCM_IN1"},
- {"TX SMIC MUX1", "SWR_MIC10", "RX SWR TX MUX0"},
- {"RX SWR TX MUX0", "SWR_MIC", "TX SWR_INPUT"},
- {"RX SWR TX MUX0", "RX_SWR_TX_PCM_IN0", "RX_SWR_TX_PCM_IN0"},
- {"TX SMIC MUX1", "SWR_MIC11", "RX SWR TX MUX1"},
- {"RX SWR TX MUX1", "SWR_MIC", "TX SWR_INPUT"},
- {"RX SWR TX MUX1", "RX_SWR_TX_PCM_IN1", "RX_SWR_TX_PCM_IN1"},
- {"TX SMIC MUX2", "SWR_MIC10", "RX SWR TX MUX0"},
- {"RX SWR TX MUX0", "SWR_MIC", "TX SWR_INPUT"},
- {"RX SWR TX MUX0", "RX_SWR_TX_PCM_IN0", "RX_SWR_TX_PCM_IN0"},
- {"TX SMIC MUX2", "SWR_MIC11", "RX SWR TX MUX1"},
- {"RX SWR TX MUX1", "SWR_MIC", "TX SWR_INPUT"},
- {"RX SWR TX MUX1", "RX_SWR_TX_PCM_IN1", "RX_SWR_TX_PCM_IN1"},
- {"TX SMIC MUX3", "SWR_MIC10", "RX SWR TX MUX0"},
- {"RX SWR TX MUX0", "SWR_MIC", "TX SWR_INPUT"},
- {"RX SWR TX MUX0", "RX_SWR_TX_PCM_IN0", "RX_SWR_TX_PCM_IN0"},
- {"TX SMIC MUX3", "SWR_MIC11", "RX SWR TX MUX1"},
- {"RX SWR TX MUX1", "SWR_MIC", "TX SWR_INPUT"},
- {"RX SWR TX MUX1", "RX_SWR_TX_PCM_IN1", "RX_SWR_TX_PCM_IN1"},
- {"RX SWR TX MUX0", NULL, "TX_MCLK"},
- {"RX SWR TX MUX1", NULL, "TX_MCLK"},
- };
- static const struct snd_soc_dapm_route tx_audio_map[] = {
- {"TX_AIF1 CAP", NULL, "TX_MCLK"},
- {"TX_AIF2 CAP", NULL, "TX_MCLK"},
- {"TX_AIF3 CAP", NULL, "TX_MCLK"},
- {"TX_AIF1 CAP", NULL, "TX_AIF1_CAP Mixer"},
- {"TX_AIF2 CAP", NULL, "TX_AIF2_CAP Mixer"},
- {"TX_AIF3 CAP", NULL, "TX_AIF3_CAP Mixer"},
- {"TX_AIF1_CAP Mixer", "DEC0", "TX DEC0 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC1", "TX DEC1 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC2", "TX DEC2 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC3", "TX DEC3 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC4", "TX DEC4 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC5", "TX DEC5 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC6", "TX DEC6 MUX"},
- {"TX_AIF1_CAP Mixer", "DEC7", "TX DEC7 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC0", "TX DEC0 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC1", "TX DEC1 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC2", "TX DEC2 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC3", "TX DEC3 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC4", "TX DEC4 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC5", "TX DEC5 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC6", "TX DEC6 MUX"},
- {"TX_AIF2_CAP Mixer", "DEC7", "TX DEC7 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC0", "TX DEC0 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC1", "TX DEC1 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC2", "TX DEC2 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC3", "TX DEC3 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC4", "TX DEC4 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC5", "TX DEC5 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC6", "TX DEC6 MUX"},
- {"TX_AIF3_CAP Mixer", "DEC7", "TX DEC7 MUX"},
- {"TX DEC0 MUX", NULL, "TX_MCLK"},
- {"TX DEC1 MUX", NULL, "TX_MCLK"},
- {"TX DEC2 MUX", NULL, "TX_MCLK"},
- {"TX DEC3 MUX", NULL, "TX_MCLK"},
- {"TX DEC4 MUX", NULL, "TX_MCLK"},
- {"TX DEC5 MUX", NULL, "TX_MCLK"},
- {"TX DEC6 MUX", NULL, "TX_MCLK"},
- {"TX DEC7 MUX", NULL, "TX_MCLK"},
- {"TX DEC0 MUX", "MSM_DMIC", "TX DMIC MUX0"},
- {"TX DMIC MUX0", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX0", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX0", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX0", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX0", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX0", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX0", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX0", "DMIC7", "TX DMIC7"},
- {"TX DEC0 MUX", "SWR_MIC", "TX SMIC MUX0"},
- {"TX SMIC MUX0", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX0", "ADC0", "TX SWR_ADC0"},
- {"TX SMIC MUX0", "ADC1", "TX SWR_ADC1"},
- {"TX SMIC MUX0", "ADC2", "TX SWR_ADC2"},
- {"TX SMIC MUX0", "ADC3", "TX SWR_ADC3"},
- {"TX SMIC MUX0", "SWR_DMIC0", "TX SWR_DMIC0"},
- {"TX SMIC MUX0", "SWR_DMIC1", "TX SWR_DMIC1"},
- {"TX SMIC MUX0", "SWR_DMIC2", "TX SWR_DMIC2"},
- {"TX SMIC MUX0", "SWR_DMIC3", "TX SWR_DMIC3"},
- {"TX SMIC MUX0", "SWR_DMIC4", "TX SWR_DMIC4"},
- {"TX SMIC MUX0", "SWR_DMIC5", "TX SWR_DMIC5"},
- {"TX SMIC MUX0", "SWR_DMIC6", "TX SWR_DMIC6"},
- {"TX SMIC MUX0", "SWR_DMIC7", "TX SWR_DMIC7"},
- {"TX DEC1 MUX", "MSM_DMIC", "TX DMIC MUX1"},
- {"TX DMIC MUX1", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX1", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX1", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX1", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX1", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX1", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX1", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX1", "DMIC7", "TX DMIC7"},
- {"TX DEC1 MUX", "SWR_MIC", "TX SMIC MUX1"},
- {"TX SMIC MUX1", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX1", "ADC0", "TX SWR_ADC0"},
- {"TX SMIC MUX1", "ADC1", "TX SWR_ADC1"},
- {"TX SMIC MUX1", "ADC2", "TX SWR_ADC2"},
- {"TX SMIC MUX1", "ADC3", "TX SWR_ADC3"},
- {"TX SMIC MUX1", "SWR_DMIC0", "TX SWR_DMIC0"},
- {"TX SMIC MUX1", "SWR_DMIC1", "TX SWR_DMIC1"},
- {"TX SMIC MUX1", "SWR_DMIC2", "TX SWR_DMIC2"},
- {"TX SMIC MUX1", "SWR_DMIC3", "TX SWR_DMIC3"},
- {"TX SMIC MUX1", "SWR_DMIC4", "TX SWR_DMIC4"},
- {"TX SMIC MUX1", "SWR_DMIC5", "TX SWR_DMIC5"},
- {"TX SMIC MUX1", "SWR_DMIC6", "TX SWR_DMIC6"},
- {"TX SMIC MUX1", "SWR_DMIC7", "TX SWR_DMIC7"},
- {"TX DEC2 MUX", "MSM_DMIC", "TX DMIC MUX2"},
- {"TX DMIC MUX2", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX2", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX2", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX2", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX2", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX2", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX2", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX2", "DMIC7", "TX DMIC7"},
- {"TX DEC2 MUX", "SWR_MIC", "TX SMIC MUX2"},
- {"TX SMIC MUX2", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX2", "ADC0", "TX SWR_ADC0"},
- {"TX SMIC MUX2", "ADC1", "TX SWR_ADC1"},
- {"TX SMIC MUX2", "ADC2", "TX SWR_ADC2"},
- {"TX SMIC MUX2", "ADC3", "TX SWR_ADC3"},
- {"TX SMIC MUX2", "SWR_DMIC0", "TX SWR_DMIC0"},
- {"TX SMIC MUX2", "SWR_DMIC1", "TX SWR_DMIC1"},
- {"TX SMIC MUX2", "SWR_DMIC2", "TX SWR_DMIC2"},
- {"TX SMIC MUX2", "SWR_DMIC3", "TX SWR_DMIC3"},
- {"TX SMIC MUX2", "SWR_DMIC4", "TX SWR_DMIC4"},
- {"TX SMIC MUX2", "SWR_DMIC5", "TX SWR_DMIC5"},
- {"TX SMIC MUX2", "SWR_DMIC6", "TX SWR_DMIC6"},
- {"TX SMIC MUX2", "SWR_DMIC7", "TX SWR_DMIC7"},
- {"TX DEC3 MUX", "MSM_DMIC", "TX DMIC MUX3"},
- {"TX DMIC MUX3", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX3", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX3", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX3", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX3", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX3", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX3", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX3", "DMIC7", "TX DMIC7"},
- {"TX DEC3 MUX", "SWR_MIC", "TX SMIC MUX3"},
- {"TX SMIC MUX3", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX3", "ADC0", "TX SWR_ADC0"},
- {"TX SMIC MUX3", "ADC1", "TX SWR_ADC1"},
- {"TX SMIC MUX3", "ADC2", "TX SWR_ADC2"},
- {"TX SMIC MUX3", "ADC3", "TX SWR_ADC3"},
- {"TX SMIC MUX3", "SWR_DMIC0", "TX SWR_DMIC0"},
- {"TX SMIC MUX3", "SWR_DMIC1", "TX SWR_DMIC1"},
- {"TX SMIC MUX3", "SWR_DMIC2", "TX SWR_DMIC2"},
- {"TX SMIC MUX3", "SWR_DMIC3", "TX SWR_DMIC3"},
- {"TX SMIC MUX3", "SWR_DMIC4", "TX SWR_DMIC4"},
- {"TX SMIC MUX3", "SWR_DMIC5", "TX SWR_DMIC5"},
- {"TX SMIC MUX3", "SWR_DMIC6", "TX SWR_DMIC6"},
- {"TX SMIC MUX3", "SWR_DMIC7", "TX SWR_DMIC7"},
- {"TX DEC4 MUX", "MSM_DMIC", "TX DMIC MUX4"},
- {"TX DMIC MUX4", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX4", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX4", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX4", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX4", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX4", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX4", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX4", "DMIC7", "TX DMIC7"},
- {"TX DEC4 MUX", "SWR_MIC", "TX SMIC MUX4"},
- {"TX SMIC MUX4", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX4", "ADC0", "TX SWR_ADC0"},
- {"TX SMIC MUX4", "ADC1", "TX SWR_ADC1"},
- {"TX SMIC MUX4", "ADC2", "TX SWR_ADC2"},
- {"TX SMIC MUX4", "ADC3", "TX SWR_ADC3"},
- {"TX SMIC MUX4", "SWR_DMIC0", "TX SWR_DMIC0"},
- {"TX SMIC MUX4", "SWR_DMIC1", "TX SWR_DMIC1"},
- {"TX SMIC MUX4", "SWR_DMIC2", "TX SWR_DMIC2"},
- {"TX SMIC MUX4", "SWR_DMIC3", "TX SWR_DMIC3"},
- {"TX SMIC MUX4", "SWR_DMIC4", "TX SWR_DMIC4"},
- {"TX SMIC MUX4", "SWR_DMIC5", "TX SWR_DMIC5"},
- {"TX SMIC MUX4", "SWR_DMIC6", "TX SWR_DMIC6"},
- {"TX SMIC MUX4", "SWR_DMIC7", "TX SWR_DMIC7"},
- {"TX DEC5 MUX", "MSM_DMIC", "TX DMIC MUX5"},
- {"TX DMIC MUX5", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX5", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX5", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX5", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX5", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX5", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX5", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX5", "DMIC7", "TX DMIC7"},
- {"TX DEC5 MUX", "SWR_MIC", "TX SMIC MUX5"},
- {"TX SMIC MUX5", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX5", "ADC0", "TX SWR_ADC0"},
- {"TX SMIC MUX5", "ADC1", "TX SWR_ADC1"},
- {"TX SMIC MUX5", "ADC2", "TX SWR_ADC2"},
- {"TX SMIC MUX5", "ADC3", "TX SWR_ADC3"},
- {"TX SMIC MUX5", "SWR_DMIC0", "TX SWR_DMIC0"},
- {"TX SMIC MUX5", "SWR_DMIC1", "TX SWR_DMIC1"},
- {"TX SMIC MUX5", "SWR_DMIC2", "TX SWR_DMIC2"},
- {"TX SMIC MUX5", "SWR_DMIC3", "TX SWR_DMIC3"},
- {"TX SMIC MUX5", "SWR_DMIC4", "TX SWR_DMIC4"},
- {"TX SMIC MUX5", "SWR_DMIC5", "TX SWR_DMIC5"},
- {"TX SMIC MUX5", "SWR_DMIC6", "TX SWR_DMIC6"},
- {"TX SMIC MUX5", "SWR_DMIC7", "TX SWR_DMIC7"},
- {"TX DEC6 MUX", "MSM_DMIC", "TX DMIC MUX6"},
- {"TX DMIC MUX6", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX6", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX6", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX6", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX6", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX6", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX6", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX6", "DMIC7", "TX DMIC7"},
- {"TX DEC6 MUX", "SWR_MIC", "TX SMIC MUX6"},
- {"TX SMIC MUX6", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX6", "ADC0", "TX SWR_ADC0"},
- {"TX SMIC MUX6", "ADC1", "TX SWR_ADC1"},
- {"TX SMIC MUX6", "ADC2", "TX SWR_ADC2"},
- {"TX SMIC MUX6", "ADC3", "TX SWR_ADC3"},
- {"TX SMIC MUX6", "SWR_DMIC0", "TX SWR_DMIC0"},
- {"TX SMIC MUX6", "SWR_DMIC1", "TX SWR_DMIC1"},
- {"TX SMIC MUX6", "SWR_DMIC2", "TX SWR_DMIC2"},
- {"TX SMIC MUX6", "SWR_DMIC3", "TX SWR_DMIC3"},
- {"TX SMIC MUX6", "SWR_DMIC4", "TX SWR_DMIC4"},
- {"TX SMIC MUX6", "SWR_DMIC5", "TX SWR_DMIC5"},
- {"TX SMIC MUX6", "SWR_DMIC6", "TX SWR_DMIC6"},
- {"TX SMIC MUX6", "SWR_DMIC7", "TX SWR_DMIC7"},
- {"TX DEC7 MUX", "MSM_DMIC", "TX DMIC MUX7"},
- {"TX DMIC MUX7", "DMIC0", "TX DMIC0"},
- {"TX DMIC MUX7", "DMIC1", "TX DMIC1"},
- {"TX DMIC MUX7", "DMIC2", "TX DMIC2"},
- {"TX DMIC MUX7", "DMIC3", "TX DMIC3"},
- {"TX DMIC MUX7", "DMIC4", "TX DMIC4"},
- {"TX DMIC MUX7", "DMIC5", "TX DMIC5"},
- {"TX DMIC MUX7", "DMIC6", "TX DMIC6"},
- {"TX DMIC MUX7", "DMIC7", "TX DMIC7"},
- {"TX DEC7 MUX", "SWR_MIC", "TX SMIC MUX7"},
- {"TX SMIC MUX7", NULL, "TX_SWR_CLK"},
- {"TX SMIC MUX7", "ADC0", "TX SWR_ADC0"},
- {"TX SMIC MUX7", "ADC1", "TX SWR_ADC1"},
- {"TX SMIC MUX7", "ADC2", "TX SWR_ADC2"},
- {"TX SMIC MUX7", "ADC3", "TX SWR_ADC3"},
- {"TX SMIC MUX7", "SWR_DMIC0", "TX SWR_DMIC0"},
- {"TX SMIC MUX7", "SWR_DMIC1", "TX SWR_DMIC1"},
- {"TX SMIC MUX7", "SWR_DMIC2", "TX SWR_DMIC2"},
- {"TX SMIC MUX7", "SWR_DMIC3", "TX SWR_DMIC3"},
- {"TX SMIC MUX7", "SWR_DMIC4", "TX SWR_DMIC4"},
- {"TX SMIC MUX7", "SWR_DMIC5", "TX SWR_DMIC5"},
- {"TX SMIC MUX7", "SWR_DMIC6", "TX SWR_DMIC6"},
- {"TX SMIC MUX7", "SWR_DMIC7", "TX SWR_DMIC7"},
- };
- static const struct snd_kcontrol_new tx_macro_snd_controls_common[] = {
- SOC_SINGLE_S8_TLV("TX_DEC0 Volume",
- BOLERO_CDC_TX0_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC1 Volume",
- BOLERO_CDC_TX1_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC2 Volume",
- BOLERO_CDC_TX2_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC3 Volume",
- BOLERO_CDC_TX3_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_EXT("TX LPI Enable", 0, 0, 1, 0,
- tx_macro_lpi_get, tx_macro_lpi_put),
- SOC_ENUM_EXT("DEC0 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC1 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC2 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC3 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_SINGLE_EXT("DEC0_BCS Switch", SND_SOC_NOPM, 0, 1, 0,
- tx_macro_get_bcs, tx_macro_set_bcs),
- SOC_ENUM_EXT("BCS Channel", bcs_ch_enum,
- tx_macro_bcs_ch_get, tx_macro_bcs_ch_put),
- SOC_ENUM_EXT("BCS CH_SEL", bcs_ch_sel_mux_enum,
- tx_macro_get_bcs_ch_sel, tx_macro_put_bcs_ch_sel),
- };
- static const struct snd_kcontrol_new tx_macro_snd_controls_v3[] = {
- SOC_SINGLE_S8_TLV("TX_DEC4 Volume",
- BOLERO_CDC_TX4_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC5 Volume",
- BOLERO_CDC_TX5_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC6 Volume",
- BOLERO_CDC_TX6_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC7 Volume",
- BOLERO_CDC_TX7_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_ENUM_EXT("DEC4 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC5 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC6 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC7 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- };
- static const struct snd_kcontrol_new tx_macro_snd_controls[] = {
- SOC_SINGLE_S8_TLV("TX_DEC0 Volume",
- BOLERO_CDC_TX0_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC1 Volume",
- BOLERO_CDC_TX1_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC2 Volume",
- BOLERO_CDC_TX2_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC3 Volume",
- BOLERO_CDC_TX3_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC4 Volume",
- BOLERO_CDC_TX4_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC5 Volume",
- BOLERO_CDC_TX5_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC6 Volume",
- BOLERO_CDC_TX6_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_SINGLE_S8_TLV("TX_DEC7 Volume",
- BOLERO_CDC_TX7_TX_VOL_CTL,
- -84, 40, digital_gain),
- SOC_ENUM_EXT("DEC0 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC1 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC2 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC3 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC4 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC5 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC6 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM_EXT("DEC7 MODE", dec_mode_mux_enum,
- tx_macro_dec_mode_get, tx_macro_dec_mode_put),
- SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
- SOC_ENUM("TX1 HPF cut off", cf_dec1_enum),
- SOC_ENUM("TX2 HPF cut off", cf_dec2_enum),
- SOC_ENUM("TX3 HPF cut off", cf_dec3_enum),
- SOC_ENUM("TX4 HPF cut off", cf_dec4_enum),
- SOC_ENUM("TX5 HPF cut off", cf_dec5_enum),
- SOC_ENUM("TX6 HPF cut off", cf_dec6_enum),
- SOC_ENUM("TX7 HPF cut off", cf_dec7_enum),
- SOC_SINGLE_EXT("DEC0_BCS Switch", SND_SOC_NOPM, 0, 1, 0,
- tx_macro_get_bcs, tx_macro_set_bcs),
- };
- static int tx_macro_register_event_listener(struct snd_soc_component *component,
- bool enable)
- {
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- int ret = 0;
- if (!component)
- return -EINVAL;
- tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
- if (!tx_dev) {
- dev_err(component->dev,
- "%s: null device for macro!\n", __func__);
- return -EINVAL;
- }
- tx_priv = dev_get_drvdata(tx_dev);
- if (!tx_priv) {
- dev_err(component->dev,
- "%s: priv is null for macro!\n", __func__);
- return -EINVAL;
- }
- if (tx_priv->swr_ctrl_data &&
- (!tx_priv->tx_swr_clk_cnt || !tx_priv->va_swr_clk_cnt)) {
- if (enable) {
- if (!tx_priv->disable_afe_wakeup_event_listener)
- ret = swrm_wcd_notify(
- tx_priv->swr_ctrl_data[0].tx_swr_pdev,
- SWR_REGISTER_WAKEUP, NULL);
- } else {
- if (!tx_priv->disable_afe_wakeup_event_listener)
- ret = swrm_wcd_notify(
- tx_priv->swr_ctrl_data[0].tx_swr_pdev,
- SWR_DEREGISTER_WAKEUP, NULL);
- }
- }
- return ret;
- }
- static int tx_macro_tx_va_mclk_enable(struct tx_macro_priv *tx_priv,
- struct regmap *regmap, int clk_type,
- bool enable)
- {
- int ret = 0, clk_tx_ret = 0;
- dev_dbg(tx_priv->dev,
- "%s: clock type %s, enable: %s tx_mclk_users: %d\n",
- __func__, (clk_type ? "VA_MCLK" : "TX_MCLK"),
- (enable ? "enable" : "disable"), tx_priv->tx_mclk_users);
- if (enable) {
- if (tx_priv->swr_clk_users == 0) {
- ret = msm_cdc_pinctrl_select_active_state(
- tx_priv->tx_swr_gpio_p);
- if (ret < 0) {
- dev_err_ratelimited(tx_priv->dev,
- "%s: tx swr pinctrl enable failed\n",
- __func__);
- goto exit;
- }
- msm_cdc_pinctrl_set_wakeup_capable(
- tx_priv->tx_swr_gpio_p, false);
- }
- clk_tx_ret = bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- TX_CORE_CLK,
- true);
- if (clk_type == TX_MCLK) {
- ret = tx_macro_mclk_enable(tx_priv, 1);
- if (ret < 0) {
- if (tx_priv->swr_clk_users == 0)
- msm_cdc_pinctrl_select_sleep_state(
- tx_priv->tx_swr_gpio_p);
- dev_err_ratelimited(tx_priv->dev,
- "%s: request clock enable failed\n",
- __func__);
- goto done;
- }
- }
- if (clk_type == VA_MCLK) {
- ret = bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- VA_CORE_CLK,
- true);
- if (ret < 0) {
- if (tx_priv->swr_clk_users == 0)
- msm_cdc_pinctrl_select_sleep_state(
- tx_priv->tx_swr_gpio_p);
- dev_err_ratelimited(tx_priv->dev,
- "%s: swr request clk failed\n",
- __func__);
- goto done;
- }
- bolero_clk_rsc_fs_gen_request(tx_priv->dev,
- true);
- mutex_lock(&tx_priv->mclk_lock);
- if (tx_priv->tx_mclk_users == 0) {
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_TOP_CSR_FREQ_MCLK,
- 0x01, 0x01);
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
- 0x01, 0x01);
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
- 0x01, 0x01);
- }
- tx_priv->tx_mclk_users++;
- mutex_unlock(&tx_priv->mclk_lock);
- }
- if (tx_priv->swr_clk_users == 0) {
- dev_dbg(tx_priv->dev, "%s: reset_swr: %d\n",
- __func__, tx_priv->reset_swr);
- if (tx_priv->reset_swr)
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
- 0x02, 0x02);
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
- 0x01, 0x01);
- if (tx_priv->reset_swr)
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
- 0x02, 0x00);
- tx_priv->reset_swr = false;
- }
- if (!clk_tx_ret)
- ret = bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- TX_CORE_CLK,
- false);
- tx_priv->swr_clk_users++;
- } else {
- if (tx_priv->swr_clk_users <= 0) {
- dev_err_ratelimited(tx_priv->dev,
- "tx swrm clock users already 0\n");
- tx_priv->swr_clk_users = 0;
- return 0;
- }
- clk_tx_ret = bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- TX_CORE_CLK,
- true);
- tx_priv->swr_clk_users--;
- if (tx_priv->swr_clk_users == 0)
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
- 0x01, 0x00);
- if (clk_type == TX_MCLK)
- tx_macro_mclk_enable(tx_priv, 0);
- if (clk_type == VA_MCLK) {
- mutex_lock(&tx_priv->mclk_lock);
- if (tx_priv->tx_mclk_users <= 0) {
- dev_err(tx_priv->dev, "%s: clock already disabled\n",
- __func__);
- tx_priv->tx_mclk_users = 0;
- mutex_unlock(&tx_priv->mclk_lock);
- goto tx_clk;
- }
- tx_priv->tx_mclk_users--;
- if (tx_priv->tx_mclk_users == 0) {
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
- 0x01, 0x00);
- regmap_update_bits(regmap,
- BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
- 0x01, 0x00);
- }
- mutex_unlock(&tx_priv->mclk_lock);
- bolero_clk_rsc_fs_gen_request(tx_priv->dev,
- false);
- ret = bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- VA_CORE_CLK,
- false);
- if (ret < 0) {
- dev_err_ratelimited(tx_priv->dev,
- "%s: swr request clk failed\n",
- __func__);
- goto done;
- }
- }
- tx_clk:
- if (!clk_tx_ret)
- ret = bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- TX_CORE_CLK,
- false);
- if (tx_priv->swr_clk_users == 0) {
- msm_cdc_pinctrl_set_wakeup_capable(
- tx_priv->tx_swr_gpio_p, true);
- ret = msm_cdc_pinctrl_select_sleep_state(
- tx_priv->tx_swr_gpio_p);
- if (ret < 0) {
- dev_err_ratelimited(tx_priv->dev,
- "%s: tx swr pinctrl disable failed\n",
- __func__);
- goto exit;
- }
- }
- }
- return 0;
- done:
- if (!clk_tx_ret)
- bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- TX_CORE_CLK,
- false);
- exit:
- return ret;
- }
- static int tx_macro_clk_div_get(struct snd_soc_component *component)
- {
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- return tx_priv->dmic_clk_div;
- }
- static int tx_macro_clk_switch(struct snd_soc_component *component, int clk_src)
- {
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- int ret = 0;
- if (!component)
- return -EINVAL;
- tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
- if (!tx_dev) {
- dev_err(component->dev,
- "%s: null device for macro!\n", __func__);
- return -EINVAL;
- }
- tx_priv = dev_get_drvdata(tx_dev);
- if (!tx_priv) {
- dev_err(component->dev,
- "%s: priv is null for macro!\n", __func__);
- return -EINVAL;
- }
- dev_dbg(component->dev,
- "%s: va_swr_clk_cnt %d, tx_swr_clk_cnt %d, tx_clk_status %d\n",
- __func__, tx_priv->va_swr_clk_cnt,
- tx_priv->tx_swr_clk_cnt, tx_priv->tx_clk_status);
- if (tx_priv->current_clk_id == clk_src) {
- dev_dbg(component->dev,
- "%s: requested clk %d is same as current\n",
- __func__, clk_src);
- return 0;
- } else if (tx_priv->va_swr_clk_cnt != 0 && tx_priv->tx_clk_status) {
- ret = bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- clk_src,
- true);
- if (ret) {
- dev_dbg(component->dev,
- "%s: request clock %d enable failed\n",
- __func__, clk_src);
- goto ret;
- }
- ret = bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- tx_priv->current_clk_id,
- false);
- if (ret) {
- dev_dbg(component->dev,
- "%s: request clock disable failed\n",
- __func__);
- bolero_clk_rsc_request_clock(tx_priv->dev,
- TX_CORE_CLK,
- clk_src,
- false);
- goto ret;
- }
- tx_priv->current_clk_id = clk_src;
- } else {
- ret = -EBUSY;
- }
- ret:
- return ret;
- }
- static int tx_macro_core_vote(void *handle, bool enable)
- {
- int rc = 0;
- struct tx_macro_priv *tx_priv = (struct tx_macro_priv *) handle;
- if (tx_priv == NULL) {
- pr_err("%s: tx priv data is NULL\n", __func__);
- return -EINVAL;
- }
- if (enable) {
- pm_runtime_get_sync(tx_priv->dev);
- if (bolero_check_core_votes(tx_priv->dev))
- rc = 0;
- else
- rc = -ENOTSYNC;
- } else {
- pm_runtime_put_autosuspend(tx_priv->dev);
- pm_runtime_mark_last_busy(tx_priv->dev);
- }
- return rc;
- }
- static int tx_macro_swrm_clock(void *handle, bool enable)
- {
- struct tx_macro_priv *tx_priv = (struct tx_macro_priv *) handle;
- struct regmap *regmap = dev_get_regmap(tx_priv->dev->parent, NULL);
- int ret = 0;
- if (regmap == NULL) {
- dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
- return -EINVAL;
- }
- mutex_lock(&tx_priv->swr_clk_lock);
- dev_dbg(tx_priv->dev,
- "%s: swrm clock %s tx_swr_clk_cnt: %d va_swr_clk_cnt: %d\n",
- __func__, (enable ? "enable" : "disable"),
- tx_priv->tx_swr_clk_cnt, tx_priv->va_swr_clk_cnt);
- if (enable) {
- pm_runtime_get_sync(tx_priv->dev);
- if (tx_priv->va_swr_clk_cnt && !tx_priv->tx_swr_clk_cnt) {
- ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
- VA_MCLK, enable);
- if (ret) {
- pm_runtime_mark_last_busy(tx_priv->dev);
- pm_runtime_put_autosuspend(tx_priv->dev);
- goto done;
- }
- tx_priv->va_clk_status++;
- } else {
- ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
- TX_MCLK, enable);
- if (ret) {
- pm_runtime_mark_last_busy(tx_priv->dev);
- pm_runtime_put_autosuspend(tx_priv->dev);
- goto done;
- }
- tx_priv->tx_clk_status++;
- }
- pm_runtime_mark_last_busy(tx_priv->dev);
- pm_runtime_put_autosuspend(tx_priv->dev);
- } else {
- if (tx_priv->va_clk_status && !tx_priv->tx_clk_status) {
- ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
- VA_MCLK, enable);
- if (ret)
- goto done;
- --tx_priv->va_clk_status;
- } else if (!tx_priv->va_clk_status && tx_priv->tx_clk_status) {
- ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
- TX_MCLK, enable);
- if (ret)
- goto done;
- --tx_priv->tx_clk_status;
- } else if (tx_priv->va_clk_status && tx_priv->tx_clk_status) {
- if (!tx_priv->va_swr_clk_cnt && tx_priv->tx_swr_clk_cnt) {
- ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
- VA_MCLK, enable);
- if (ret)
- goto done;
- --tx_priv->va_clk_status;
- } else {
- ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
- TX_MCLK, enable);
- if (ret)
- goto done;
- --tx_priv->tx_clk_status;
- }
- } else {
- dev_dbg(tx_priv->dev,
- "%s: Both clocks are disabled\n", __func__);
- }
- }
- dev_dbg(tx_priv->dev,
- "%s: swrm clock users %d tx_clk_sts_cnt: %d va_clk_sts_cnt: %d\n",
- __func__, tx_priv->swr_clk_users, tx_priv->tx_clk_status,
- tx_priv->va_clk_status);
- done:
- mutex_unlock(&tx_priv->swr_clk_lock);
- return ret;
- }
- static int tx_macro_validate_dmic_sample_rate(u32 dmic_sample_rate,
- struct tx_macro_priv *tx_priv)
- {
- u32 div_factor = TX_MACRO_CLK_DIV_2;
- u32 mclk_rate = TX_MACRO_MCLK_FREQ;
- if (dmic_sample_rate == TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED ||
- mclk_rate % dmic_sample_rate != 0)
- goto undefined_rate;
- div_factor = mclk_rate / dmic_sample_rate;
- switch (div_factor) {
- case 2:
- tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_2;
- break;
- case 3:
- tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_3;
- break;
- case 4:
- tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_4;
- break;
- case 6:
- tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_6;
- break;
- case 8:
- tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_8;
- break;
- case 16:
- tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_16;
- break;
- default:
- /* Any other DIV factor is invalid */
- goto undefined_rate;
- }
- /* Valid dmic DIV factors */
- dev_dbg(tx_priv->dev, "%s: DMIC_DIV = %u, mclk_rate = %u\n",
- __func__, div_factor, mclk_rate);
- return dmic_sample_rate;
- undefined_rate:
- dev_dbg(tx_priv->dev, "%s: Invalid rate %d, for mclk %d\n",
- __func__, dmic_sample_rate, mclk_rate);
- dmic_sample_rate = TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED;
- return dmic_sample_rate;
- }
- static const struct tx_macro_reg_mask_val tx_macro_reg_init[] = {
- {BOLERO_CDC_TX0_TX_PATH_SEC7, 0x3F, 0x0A},
- };
- static int tx_macro_init(struct snd_soc_component *component)
- {
- struct snd_soc_dapm_context *dapm =
- snd_soc_component_get_dapm(component);
- int ret = 0, i = 0;
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
- if (!tx_dev) {
- dev_err(component->dev,
- "%s: null device for macro!\n", __func__);
- return -EINVAL;
- }
- tx_priv = dev_get_drvdata(tx_dev);
- if (!tx_priv) {
- dev_err(component->dev,
- "%s: priv is null for macro!\n", __func__);
- return -EINVAL;
- }
- tx_priv->lpi_enable = false;
- tx_priv->register_event_listener = false;
- tx_priv->version = bolero_get_version(tx_dev);
- if (tx_priv->version >= BOLERO_VERSION_2_0) {
- ret = snd_soc_dapm_new_controls(dapm,
- tx_macro_dapm_widgets_common,
- ARRAY_SIZE(tx_macro_dapm_widgets_common));
- if (ret < 0) {
- dev_err(tx_dev, "%s: Failed to add controls\n",
- __func__);
- return ret;
- }
- if (tx_priv->version == BOLERO_VERSION_2_1)
- ret = snd_soc_dapm_new_controls(dapm,
- tx_macro_dapm_widgets_v2,
- ARRAY_SIZE(tx_macro_dapm_widgets_v2));
- else if (tx_priv->version == BOLERO_VERSION_2_0)
- ret = snd_soc_dapm_new_controls(dapm,
- tx_macro_dapm_widgets_v3,
- ARRAY_SIZE(tx_macro_dapm_widgets_v3));
- else if (tx_priv->version == BOLERO_VERSION_2_2)
- ret = snd_soc_dapm_new_controls(dapm,
- tx_macro_dapm_widgets_v4,
- ARRAY_SIZE(tx_macro_dapm_widgets_v4));
- if (ret < 0) {
- dev_err(tx_dev, "%s: Failed to add controls\n",
- __func__);
- return ret;
- }
- } else {
- ret = snd_soc_dapm_new_controls(dapm, tx_macro_dapm_widgets,
- ARRAY_SIZE(tx_macro_dapm_widgets));
- if (ret < 0) {
- dev_err(tx_dev, "%s: Failed to add controls\n",
- __func__);
- return ret;
- }
- }
- if (tx_priv->version >= BOLERO_VERSION_2_0) {
- ret = snd_soc_dapm_add_routes(dapm,
- tx_audio_map_common,
- ARRAY_SIZE(tx_audio_map_common));
- if (ret < 0) {
- dev_err(tx_dev, "%s: Failed to add routes\n",
- __func__);
- return ret;
- }
- if (tx_priv->version == BOLERO_VERSION_2_1)
- ret = snd_soc_dapm_add_routes(dapm,
- tx_audio_map_v2,
- ARRAY_SIZE(tx_audio_map_v2));
- if (tx_priv->version == BOLERO_VERSION_2_0)
- ret = snd_soc_dapm_add_routes(dapm,
- tx_audio_map_v3,
- ARRAY_SIZE(tx_audio_map_v3));
- if (tx_priv->version == BOLERO_VERSION_2_2)
- ret = snd_soc_dapm_add_routes(dapm,
- tx_audio_map_v4,
- ARRAY_SIZE(tx_audio_map_v4));
- if (ret < 0) {
- dev_err(tx_dev, "%s: Failed to add routes\n",
- __func__);
- return ret;
- }
- } else {
- ret = snd_soc_dapm_add_routes(dapm, tx_audio_map,
- ARRAY_SIZE(tx_audio_map));
- if (ret < 0) {
- dev_err(tx_dev, "%s: Failed to add routes\n",
- __func__);
- return ret;
- }
- }
- ret = snd_soc_dapm_new_widgets(dapm->card);
- if (ret < 0) {
- dev_err(tx_dev, "%s: Failed to add widgets\n", __func__);
- return ret;
- }
- if (tx_priv->version >= BOLERO_VERSION_2_0) {
- ret = snd_soc_add_component_controls(component,
- tx_macro_snd_controls_common,
- ARRAY_SIZE(tx_macro_snd_controls_common));
- if (ret < 0) {
- dev_err(tx_dev, "%s: Failed to add snd_ctls\n",
- __func__);
- return ret;
- }
- if (tx_priv->version == BOLERO_VERSION_2_0)
- ret = snd_soc_add_component_controls(component,
- tx_macro_snd_controls_v3,
- ARRAY_SIZE(tx_macro_snd_controls_v3));
- if (ret < 0) {
- dev_err(tx_dev, "%s: Failed to add snd_ctls\n",
- __func__);
- return ret;
- }
- } else {
- ret = snd_soc_add_component_controls(component,
- tx_macro_snd_controls,
- ARRAY_SIZE(tx_macro_snd_controls));
- if (ret < 0) {
- dev_err(tx_dev, "%s: Failed to add snd_ctls\n",
- __func__);
- return ret;
- }
- }
- snd_soc_dapm_ignore_suspend(dapm, "TX_AIF1 Capture");
- snd_soc_dapm_ignore_suspend(dapm, "TX_AIF2 Capture");
- snd_soc_dapm_ignore_suspend(dapm, "TX_AIF3 Capture");
- if (tx_priv->version >= BOLERO_VERSION_2_0) {
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_INPUT");
- } else {
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC0");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC1");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC2");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC3");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC0");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC1");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC2");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC3");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC4");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC5");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC6");
- snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC7");
- }
- snd_soc_dapm_sync(dapm);
- for (i = 0; i < NUM_DECIMATORS; i++) {
- tx_priv->tx_hpf_work[i].tx_priv = tx_priv;
- tx_priv->tx_hpf_work[i].decimator = i;
- INIT_DELAYED_WORK(&tx_priv->tx_hpf_work[i].dwork,
- tx_macro_tx_hpf_corner_freq_callback);
- }
- for (i = 0; i < NUM_DECIMATORS; i++) {
- tx_priv->tx_mute_dwork[i].tx_priv = tx_priv;
- tx_priv->tx_mute_dwork[i].decimator = i;
- INIT_DELAYED_WORK(&tx_priv->tx_mute_dwork[i].dwork,
- tx_macro_mute_update_callback);
- }
- tx_priv->component = component;
- for (i = 0; i < ARRAY_SIZE(tx_macro_reg_init); i++)
- snd_soc_component_update_bits(component,
- tx_macro_reg_init[i].reg,
- tx_macro_reg_init[i].mask,
- tx_macro_reg_init[i].val);
- return 0;
- }
- static int tx_macro_deinit(struct snd_soc_component *component)
- {
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- tx_priv->component = NULL;
- return 0;
- }
- static void tx_macro_add_child_devices(struct work_struct *work)
- {
- struct tx_macro_priv *tx_priv = NULL;
- struct platform_device *pdev = NULL;
- struct device_node *node = NULL;
- struct tx_macro_swr_ctrl_data *swr_ctrl_data = NULL, *temp = NULL;
- int ret = 0;
- u16 count = 0, ctrl_num = 0;
- struct tx_macro_swr_ctrl_platform_data *platdata = NULL;
- char plat_dev_name[TX_MACRO_SWR_STRING_LEN] = "";
- bool tx_swr_master_node = false;
- tx_priv = container_of(work, struct tx_macro_priv,
- tx_macro_add_child_devices_work);
- if (!tx_priv) {
- pr_err("%s: Memory for tx_priv does not exist\n",
- __func__);
- return;
- }
- if (!tx_priv->dev) {
- pr_err("%s: tx dev does not exist\n", __func__);
- return;
- }
- if (!tx_priv->dev->of_node) {
- dev_err(tx_priv->dev,
- "%s: DT node for tx_priv does not exist\n", __func__);
- return;
- }
- platdata = &tx_priv->swr_plat_data;
- tx_priv->child_count = 0;
- for_each_available_child_of_node(tx_priv->dev->of_node, node) {
- tx_swr_master_node = false;
- if (strnstr(node->name, "tx_swr_master",
- strlen("tx_swr_master")) != NULL)
- tx_swr_master_node = true;
- if (tx_swr_master_node)
- strlcpy(plat_dev_name, "tx_swr_ctrl",
- (TX_MACRO_SWR_STRING_LEN - 1));
- else
- strlcpy(plat_dev_name, node->name,
- (TX_MACRO_SWR_STRING_LEN - 1));
- pdev = platform_device_alloc(plat_dev_name, -1);
- if (!pdev) {
- dev_err(tx_priv->dev, "%s: pdev memory alloc failed\n",
- __func__);
- ret = -ENOMEM;
- goto err;
- }
- pdev->dev.parent = tx_priv->dev;
- pdev->dev.of_node = node;
- if (tx_swr_master_node) {
- ret = platform_device_add_data(pdev, platdata,
- sizeof(*platdata));
- if (ret) {
- dev_err(&pdev->dev,
- "%s: cannot add plat data ctrl:%d\n",
- __func__, ctrl_num);
- goto fail_pdev_add;
- }
- temp = krealloc(swr_ctrl_data,
- (ctrl_num + 1) * sizeof(
- struct tx_macro_swr_ctrl_data),
- GFP_KERNEL);
- if (!temp) {
- ret = -ENOMEM;
- goto fail_pdev_add;
- }
- swr_ctrl_data = temp;
- swr_ctrl_data[ctrl_num].tx_swr_pdev = pdev;
- ctrl_num++;
- dev_dbg(&pdev->dev,
- "%s: Adding soundwire ctrl device(s)\n",
- __func__);
- tx_priv->swr_ctrl_data = swr_ctrl_data;
- }
- ret = platform_device_add(pdev);
- if (ret) {
- dev_err(&pdev->dev,
- "%s: Cannot add platform device\n",
- __func__);
- goto fail_pdev_add;
- }
- if (tx_priv->child_count < TX_MACRO_CHILD_DEVICES_MAX)
- tx_priv->pdev_child_devices[
- tx_priv->child_count++] = pdev;
- else
- goto err;
- }
- return;
- fail_pdev_add:
- for (count = 0; count < tx_priv->child_count; count++)
- platform_device_put(tx_priv->pdev_child_devices[count]);
- err:
- return;
- }
- static int tx_macro_set_port_map(struct snd_soc_component *component,
- u32 usecase, u32 size, void *data)
- {
- struct device *tx_dev = NULL;
- struct tx_macro_priv *tx_priv = NULL;
- struct swrm_port_config port_cfg;
- int ret = 0;
- if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
- return -EINVAL;
- memset(&port_cfg, 0, sizeof(port_cfg));
- port_cfg.uc = usecase;
- port_cfg.size = size;
- port_cfg.params = data;
- if (tx_priv->swr_ctrl_data)
- ret = swrm_wcd_notify(
- tx_priv->swr_ctrl_data[0].tx_swr_pdev,
- SWR_SET_PORT_MAP, &port_cfg);
- return ret;
- }
- static void tx_macro_init_ops(struct macro_ops *ops,
- char __iomem *tx_io_base)
- {
- memset(ops, 0, sizeof(struct macro_ops));
- ops->init = tx_macro_init;
- ops->exit = tx_macro_deinit;
- ops->io_base = tx_io_base;
- ops->dai_ptr = tx_macro_dai;
- ops->num_dais = ARRAY_SIZE(tx_macro_dai);
- ops->event_handler = tx_macro_event_handler;
- ops->reg_wake_irq = tx_macro_reg_wake_irq;
- ops->set_port_map = tx_macro_set_port_map;
- ops->clk_div_get = tx_macro_clk_div_get;
- ops->clk_switch = tx_macro_clk_switch;
- ops->reg_evt_listener = tx_macro_register_event_listener;
- ops->clk_enable = __tx_macro_mclk_enable;
- }
- static int tx_macro_probe(struct platform_device *pdev)
- {
- struct macro_ops ops = {0};
- struct tx_macro_priv *tx_priv = NULL;
- u32 tx_base_addr = 0, sample_rate = 0;
- char __iomem *tx_io_base = NULL;
- int ret = 0;
- const char *dmic_sample_rate = "qcom,tx-dmic-sample-rate";
- u32 is_used_tx_swr_gpio = 1;
- const char *is_used_tx_swr_gpio_dt = "qcom,is-used-swr-gpio";
- u32 disable_afe_wakeup_event_listener = 0;
- const char *disable_afe_wakeup_event_listener_dt =
- "qcom,disable-afe-wakeup-event-listener";
- if (!bolero_is_va_macro_registered(&pdev->dev)) {
- dev_err(&pdev->dev,
- "%s: va-macro not registered yet, defer\n", __func__);
- return -EPROBE_DEFER;
- }
- tx_priv = devm_kzalloc(&pdev->dev, sizeof(struct tx_macro_priv),
- GFP_KERNEL);
- if (!tx_priv)
- return -ENOMEM;
- platform_set_drvdata(pdev, tx_priv);
- tx_priv->dev = &pdev->dev;
- ret = of_property_read_u32(pdev->dev.of_node, "reg",
- &tx_base_addr);
- if (ret) {
- dev_err(&pdev->dev, "%s: could not find %s entry in dt\n",
- __func__, "reg");
- return ret;
- }
- dev_set_drvdata(&pdev->dev, tx_priv);
- if (of_find_property(pdev->dev.of_node, is_used_tx_swr_gpio_dt,
- NULL)) {
- ret = of_property_read_u32(pdev->dev.of_node,
- is_used_tx_swr_gpio_dt,
- &is_used_tx_swr_gpio);
- if (ret) {
- dev_err(&pdev->dev, "%s: error reading %s in dt\n",
- __func__, is_used_tx_swr_gpio_dt);
- is_used_tx_swr_gpio = 1;
- }
- }
- tx_priv->tx_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
- "qcom,tx-swr-gpios", 0);
- if (!tx_priv->tx_swr_gpio_p && is_used_tx_swr_gpio) {
- dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
- __func__);
- return -EINVAL;
- }
- if (msm_cdc_pinctrl_get_state(tx_priv->tx_swr_gpio_p) < 0 &&
- is_used_tx_swr_gpio) {
- dev_err(&pdev->dev, "%s: failed to get swr pin state\n",
- __func__);
- return -EPROBE_DEFER;
- }
- tx_io_base = devm_ioremap(&pdev->dev,
- tx_base_addr, TX_MACRO_MAX_OFFSET);
- if (!tx_io_base) {
- dev_err(&pdev->dev, "%s: ioremap failed\n", __func__);
- return -ENOMEM;
- }
- tx_priv->tx_io_base = tx_io_base;
- ret = of_property_read_u32(pdev->dev.of_node, dmic_sample_rate,
- &sample_rate);
- if (ret) {
- dev_err(&pdev->dev,
- "%s: could not find sample_rate entry in dt\n",
- __func__);
- tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_2;
- } else {
- if (tx_macro_validate_dmic_sample_rate(
- sample_rate, tx_priv) == TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED)
- return -EINVAL;
- }
- if (of_find_property(pdev->dev.of_node,
- disable_afe_wakeup_event_listener_dt, NULL)) {
- ret = of_property_read_u32(pdev->dev.of_node,
- disable_afe_wakeup_event_listener_dt,
- &disable_afe_wakeup_event_listener);
- if (ret)
- dev_dbg(&pdev->dev, "%s: error reading %s in dt\n",
- __func__, disable_afe_wakeup_event_listener_dt);
- }
- tx_priv->disable_afe_wakeup_event_listener =
- disable_afe_wakeup_event_listener;
- if (is_used_tx_swr_gpio) {
- tx_priv->reset_swr = true;
- INIT_WORK(&tx_priv->tx_macro_add_child_devices_work,
- tx_macro_add_child_devices);
- tx_priv->swr_plat_data.handle = (void *) tx_priv;
- tx_priv->swr_plat_data.read = NULL;
- tx_priv->swr_plat_data.write = NULL;
- tx_priv->swr_plat_data.bulk_write = NULL;
- tx_priv->swr_plat_data.clk = tx_macro_swrm_clock;
- tx_priv->swr_plat_data.core_vote = tx_macro_core_vote;
- tx_priv->swr_plat_data.handle_irq = NULL;
- mutex_init(&tx_priv->swr_clk_lock);
- }
- tx_priv->is_used_tx_swr_gpio = is_used_tx_swr_gpio;
- mutex_init(&tx_priv->mclk_lock);
- tx_macro_init_ops(&ops, tx_io_base);
- ops.clk_id_req = TX_CORE_CLK;
- ops.default_clk_id = TX_CORE_CLK;
- tx_priv->current_clk_id = TX_CORE_CLK;
- ret = bolero_register_macro(&pdev->dev, TX_MACRO, &ops);
- if (ret) {
- dev_err(&pdev->dev,
- "%s: register macro failed\n", __func__);
- goto err_reg_macro;
- }
- pm_runtime_set_autosuspend_delay(&pdev->dev, AUTO_SUSPEND_DELAY);
- pm_runtime_use_autosuspend(&pdev->dev);
- pm_runtime_set_suspended(&pdev->dev);
- pm_suspend_ignore_children(&pdev->dev, true);
- pm_runtime_enable(&pdev->dev);
- if (is_used_tx_swr_gpio)
- schedule_work(&tx_priv->tx_macro_add_child_devices_work);
- return 0;
- err_reg_macro:
- mutex_destroy(&tx_priv->mclk_lock);
- if (is_used_tx_swr_gpio)
- mutex_destroy(&tx_priv->swr_clk_lock);
- return ret;
- }
- static int tx_macro_remove(struct platform_device *pdev)
- {
- struct tx_macro_priv *tx_priv = NULL;
- u16 count = 0;
- tx_priv = platform_get_drvdata(pdev);
- if (!tx_priv)
- return -EINVAL;
- if (tx_priv->is_used_tx_swr_gpio) {
- if (tx_priv->swr_ctrl_data)
- kfree(tx_priv->swr_ctrl_data);
- for (count = 0; count < tx_priv->child_count &&
- count < TX_MACRO_CHILD_DEVICES_MAX; count++)
- platform_device_unregister(
- tx_priv->pdev_child_devices[count]);
- }
- pm_runtime_disable(&pdev->dev);
- pm_runtime_set_suspended(&pdev->dev);
- mutex_destroy(&tx_priv->mclk_lock);
- if (tx_priv->is_used_tx_swr_gpio)
- mutex_destroy(&tx_priv->swr_clk_lock);
- bolero_unregister_macro(&pdev->dev, TX_MACRO);
- return 0;
- }
- static const struct of_device_id tx_macro_dt_match[] = {
- {.compatible = "qcom,tx-macro"},
- {}
- };
- static const struct dev_pm_ops bolero_dev_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(
- pm_runtime_force_suspend,
- pm_runtime_force_resume
- )
- SET_RUNTIME_PM_OPS(
- bolero_runtime_suspend,
- bolero_runtime_resume,
- NULL
- )
- };
- static struct platform_driver tx_macro_driver = {
- .driver = {
- .name = "tx_macro",
- .owner = THIS_MODULE,
- .pm = &bolero_dev_pm_ops,
- .of_match_table = tx_macro_dt_match,
- .suppress_bind_attrs = true,
- },
- .probe = tx_macro_probe,
- .remove = tx_macro_remove,
- };
- module_platform_driver(tx_macro_driver);
- MODULE_DESCRIPTION("TX macro driver");
- MODULE_LICENSE("GPL v2");
|