12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572 |
- // SPDX-License-Identifier: GPL-2.0-only
- /*
- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
- */
- #include <linux/clk.h>
- #include <linux/delay.h>
- #include <linux/gpio.h>
- #include <linux/of_gpio.h>
- #include <linux/platform_device.h>
- #include <linux/slab.h>
- #include <linux/io.h>
- #include <linux/module.h>
- #include <linux/input.h>
- #include <linux/of_device.h>
- #include <linux/soc/qcom/fsa4480-i2c.h>
- #if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
- #include <linux/soc/qcom/wcd939x-i2c.h>
- #endif
- #include <linux/pm_qos.h>
- #include <linux/nvmem-consumer.h>
- #include <sound/control.h>
- #include <sound/core.h>
- #include <sound/soc.h>
- #include <sound/soc-dapm.h>
- #include <sound/pcm.h>
- #include <sound/pcm_params.h>
- #include <sound/info.h>
- #include <soc/snd_event.h>
- #include <soc/qcom/socinfo.h>
- #include <dsp/audio_prm.h>
- #include <soc/swr-common.h>
- #include <soc/soundwire.h>
- #include "device_event.h"
- #include "asoc/msm-cdc-pinctrl.h"
- #include "asoc/wcd-mbhc-v2.h"
- #include "codecs/wcd937x/wcd937x-mbhc.h"
- #include "codecs/wcd9378/wcd9378-mbhc.h"
- #include "codecs/wcd939x/wcd939x-mbhc.h"
- #include "codecs/wsa884x/wsa884x.h"
- #include "codecs/wsa883x/wsa883x.h"
- #include "codecs/wcd937x/wcd937x.h"
- #include "codecs/wcd9378/wcd9378.h"
- #include "codecs/wcd939x/wcd939x.h"
- #include "codecs/lpass-cdc/lpass-cdc.h"
- #include <bindings/audio-codec-port-types.h>
- #include "codecs/lpass-cdc/lpass-cdc-wsa-macro.h"
- #include "pineapple-port-config.h"
- #include "msm-audio-defs.h"
- #include "msm_common.h"
- #include "msm_dailink.h"
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- #include <sound/cirrus/big_data.h>
- #include <sound/samsung/bigdata_cirrus_sysfs_cb.h>
- #include <sound/cirrus/core.h>
- #endif
- #if IS_ENABLED(CONFIG_SND_SOC_SAMSUNG_AUDIO)
- #include <sound/samsung/snd_debug_proc.h>
- #include <sound/samsung/sec_audio_sysfs.h>
- #if defined(CONFIG_SND_SOC_TAS25XX)
- #include "codecs/tas25xx/inc/tas25xx-ext.h"
- #endif
- #endif
- #if IS_ENABLED(CONFIG_SEC_ABC)
- #include <linux/sti/abc_common.h>
- #endif
- #define DRV_NAME "pineapple-asoc-snd"
- #define __CHIPSET__ "PINEAPPLE "
- #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
- #define WCD9XXX_MBHC_DEF_RLOADS 5
- #define WCD9XXX_MBHC_DEF_BUTTONS 8
- #define CODEC_EXT_CLK_RATE 9600000
- #define DEV_NAME_STR_LEN 32
- #define WCD_MBHC_HS_V_MAX 1600
- #define WCN_CDC_SLIM_RX_CH_MAX 2
- #define WCN_CDC_SLIM_TX_CH_MAX 2
- #define WCN_CDC_SLIM_TX_CH_MAX_LITO 3
- #define WCN_CDC_SLIM_TX_CH_MAX_FM 3
- /* Number of WSAs */
- #define MONO_SPEAKER 1
- #define STEREO_SPEAKER 2
- #define QUAD_SPEAKER 4
- #if IS_ENABLED(CONFIG_SND_SOC_SAMSUNG_AUDIO)
- #define MAX_DEFER_COUNT 10
- #define AMP_INIT_SUCCESS 1
- #define AMP_INIT_FAIL 0
- #define AMP_CHECK_NOT_SUPPORT -1
- #endif
- enum {
- WCD937X_DEV_INDEX,
- WCD939X_DEV_INDEX,
- WCD9378_DEV_INDEX,
- };
- struct msm_asoc_mach_data {
- struct snd_info_entry *codec_root;
- struct msm_common_pdata *common_pdata;
- int usbc_en2_gpio; /* used by gpio driver API */
- struct device_node *dmic01_gpio_p; /* used by pinctrl API */
- struct device_node *dmic23_gpio_p; /* used by pinctrl API */
- struct device_node *dmic45_gpio_p; /* used by pinctrl API */
- struct device_node *dmic67_gpio_p; /* used by pinctrl API */
- struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
- bool is_afe_config_done;
- struct device_node *fsa_handle;
- struct device_node *wcd_usbss_handle;
- struct clk *lpass_audio_hw_vote;
- int core_audio_vote_count;
- u32 wsa_max_devs;
- int wcd_disabled;
- int (*get_dev_num)(struct snd_soc_component *);
- int backend_used;
- struct prm_earpa_hw_intf_config upd_config;
- bool dedicated_wsa2; /* used to define how wsa2 slave devices are used */
- int wcd_used;
- };
- static bool is_initial_boot;
- static bool codec_reg_done;
- static struct snd_soc_card snd_soc_card_pineapple_msm;
- static int dmic_0_1_gpio_cnt;
- static int dmic_2_3_gpio_cnt;
- static int dmic_4_5_gpio_cnt;
- static int dmic_6_7_gpio_cnt;
- static int sub_pcb_conn;
- #if IS_ENABLED(CONFIG_SND_SOC_SAMSUNG_AUDIO)
- static int defer_count;
- static struct snd_soc_dai_link_component dummy_compononet = {
- .name = "snd-soc-dummy",
- .dai_name = "snd-soc-dummy-dai",
- };
- #endif
- static void *def_wcd_mbhc_cal(void);
- static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime*);
- static int msm_int_wsa_init(struct snd_soc_pcm_runtime*);
- static int msm_int_wsa881x_init(struct snd_soc_pcm_runtime *);
- static int msm_int_wsa884x_init(struct snd_soc_pcm_runtime*);
- static int msm_int_wsa883x_init(struct snd_soc_pcm_runtime*);
- static int msm_int_wsa2_init(struct snd_soc_pcm_runtime *);
- static int msm_int_wsa884x_2_init(struct snd_soc_pcm_runtime *);
- static int msm_int_wsa883x_2_init(struct snd_soc_pcm_runtime *);
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- static const struct snd_soc_dapm_route cirrus_mono_routes[] = {
- { "AMP0 SPK", NULL, "Mono SPK" },
- };
- static const struct snd_soc_dapm_route cirrus_stereo_routes[] = {
- { "AMP0 SPK", NULL, "Left AMP SPK" },
- { "AMP1 SPK", NULL, "Right AMP SPK" },
- };
- static const struct snd_soc_dapm_route cirrus_quad_routes[] = {
- { "AMP0 SPK", NULL, "FL SPK" },
- { "AMP1 SPK", NULL, "FR SPK" },
- { "AMP2 SPK", NULL, "RL SPK" },
- { "AMP3 SPK", NULL, "RR SPK" },
- };
- static struct snd_soc_codec_conf cs35l43_mono_conf[] = {
- {
- .dlc.name = "cs35l43.18-0040",
- .name_prefix = "Mono",
- }
- };
- static struct snd_soc_codec_conf cs35l43_stereo_conf[] = {
- {
- .dlc.name = "cs35l43.18-0040",
- .name_prefix = "Right",
- },
- {
- .dlc.name = "cs35l43.18-0041",
- .name_prefix = "Left",
- }
- };
- static struct snd_soc_codec_conf cs35l43_quad_conf[] = {
- {
- .dlc.name = "cs35l43.18-0040",
- .name_prefix = "RL",
- },
- {
- .dlc.name = "cs35l43.18-0041",
- .name_prefix = "FL",
- },
- {
- .dlc.name = "cs35l43.18-0042",
- .name_prefix = "RR",
- },
- {
- .dlc.name = "cs35l43.18-0043",
- .name_prefix = "FR",
- }
- };
- static struct snd_soc_codec_conf cs35l45_mono_conf[] = {
- {
- .dlc.name = "cs35l45.18-0030",
- .name_prefix = "Mono",
- }
- };
- static struct snd_soc_codec_conf cs35l45_stereo_conf[] = {
- {
- .dlc.name = "cs35l45.18-0030",
- .name_prefix = "Right",
- },
- {
- .dlc.name = "cs35l45.18-0031",
- .name_prefix = "Left",
- }
- };
- static struct snd_soc_codec_conf cs35l45_quad_conf[] = {
- {
- .dlc.name = "cs35l45.18-0030",
- .name_prefix = "RL",
- },
- {
- .dlc.name = "cs35l45.18-0031",
- .name_prefix = "FL",
- },
- {
- .dlc.name = "cs35l45.18-0032",
- .name_prefix = "RR",
- },
- {
- .dlc.name = "cs35l45.18-0033",
- .name_prefix = "FR",
- }
- };
- /*
- * We want to configure these at runtime for testing
- */
- static unsigned int codec_clk_src = CLK_SRC_MCLK;
- static const char *const codec_src_clocks[] = {"SCLK", "LRCLK", "PDM",
- "MCLK", "SELF", "SWIRE"};
- static unsigned int dai_clks = SND_SOC_DAIFMT_CBS_CFS;
- static const char *const dai_sub_clocks[] = {"Codec Slave", "Codec Master",
- "CODEC BMFS", "CODEC BSFM"
- };
- static unsigned int dai_bit_fmt = SND_SOC_DAIFMT_NB_NF;
- static const char *const dai_bit_config[] = {"NormalBF", "NormalB INVF",
- "INVB NormalF", "INVB INVF"
- };
- static unsigned int dai_mode_fmt = SND_SOC_DAIFMT_I2S;
- static const char *const dai_mode_config[] = {"I2S", "Right J",
- "Left J", "DSP A", "DSP B",
- "PDM"
- };
- static unsigned int sys_clk_static;
- static const char *const static_clk_mode[] = {"Off", "5P6", "6P1", "11P2",
- "12", "12P2", "13", "22P5", "24", "24P5", "26"
- };
- unsigned int dai_force_frame32;
- static const char *const dai_force_frame32_config[] = {"Off", "On"};
- static u32 cirrus_amp_conf;
- static u32 cirrus_amp_count;
- #endif
- /*
- * Need to report LINEIN
- * if R/L channel impedance is larger than 5K ohm
- */
- static struct wcd_mbhc_config wcd_mbhc_cfg = {
- .read_fw_bin = false,
- .calibration = NULL,
- .detect_extn_cable = true,
- .mono_stero_detection = false,
- .swap_gnd_mic = NULL,
- .hs_ext_micbias = true,
- .key_code[0] = KEY_MEDIA,
- .key_code[1] = KEY_VOICECOMMAND,
- .key_code[2] = KEY_VOLUMEUP,
- .key_code[3] = KEY_VOLUMEDOWN,
- .key_code[4] = 0,
- .key_code[5] = 0,
- .key_code[6] = 0,
- .key_code[7] = 0,
- .linein_th = 5000,
- .moisture_en = false,
- .mbhc_micbias = MIC_BIAS_2,
- .anc_micbias = MIC_BIAS_2,
- .enable_anc_mic_detect = false,
- .moisture_duty_cycle_en = true,
- };
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- static int codec_clk_src_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int codec_clk_src_val = 0;
- switch (codec_clk_src) {
- case CLK_SRC_SCLK:
- codec_clk_src_val = 0;
- break;
- case CLK_SRC_LRCLK:
- codec_clk_src_val = 1;
- break;
- case CLK_SRC_PDM:
- codec_clk_src_val = 2;
- break;
- case CLK_SRC_MCLK:
- codec_clk_src_val = 3;
- break;
- case CLK_SRC_SELF:
- codec_clk_src_val = 4;
- break;
- case CLK_SRC_SWIRE:
- codec_clk_src_val = 5;
- break;
- }
- ucontrol->value.integer.value[0] = codec_clk_src_val;
- return 0;
- }
- static int codec_clk_src_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_info("%s: ucontrol value = %ld\n", __func__,
- ucontrol->value.integer.value[0]);
- switch (ucontrol->value.integer.value[0]) {
- case 0:
- codec_clk_src = CLK_SRC_SCLK;
- break;
- case 1:
- codec_clk_src = CLK_SRC_LRCLK;
- break;
- case 2:
- codec_clk_src = CLK_SRC_PDM;
- break;
- case 3:
- codec_clk_src = CLK_SRC_MCLK;
- break;
- case 4:
- codec_clk_src = CLK_SRC_SELF;
- break;
- case 5:
- codec_clk_src = CLK_SRC_SWIRE;
- break;
- }
- return 0;
- }
- static int dai_clks_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int dai_clks_val = 0;
- switch (dai_clks) {
- case SND_SOC_DAIFMT_CBS_CFS:
- dai_clks_val = 0;
- break;
- case SND_SOC_DAIFMT_CBM_CFM:
- dai_clks_val = 1;
- break;
- case SND_SOC_DAIFMT_CBM_CFS:
- dai_clks_val = 2;
- break;
- case SND_SOC_DAIFMT_CBS_CFM:
- dai_clks_val = 3;
- break;
- }
- ucontrol->value.integer.value[0] = dai_clks_val;
- return 0;
- }
- static int dai_clks_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_info("%s: ucontrol value = %ld\n", __func__,
- ucontrol->value.integer.value[0]);
- switch (ucontrol->value.integer.value[0]) {
- case 0:
- dai_clks = SND_SOC_DAIFMT_CBS_CFS;
- break;
- case 1:
- dai_clks = SND_SOC_DAIFMT_CBM_CFM;
- break;
- case 2:
- dai_clks = SND_SOC_DAIFMT_CBM_CFS;
- break;
- case 3:
- dai_clks = SND_SOC_DAIFMT_CBS_CFM;
- break;
- }
- return 0;
- }
- static int dai_bitfmt_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int dai_bits_val = 0;
- switch (dai_bit_fmt) {
- case SND_SOC_DAIFMT_NB_NF:
- dai_bits_val = 0;
- break;
- case SND_SOC_DAIFMT_NB_IF:
- dai_bits_val = 1;
- break;
- case SND_SOC_DAIFMT_IB_NF:
- dai_bits_val = 2;
- break;
- case SND_SOC_DAIFMT_IB_IF:
- dai_bits_val = 3;
- break;
- }
- ucontrol->value.integer.value[0] = dai_bits_val;
- return 0;
- }
- static int dai_bitfmt_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_info("%s: ucontrol value = %ld\n", __func__,
- ucontrol->value.integer.value[0]);
- switch (ucontrol->value.integer.value[0]) {
- case 0:
- dai_bit_fmt = SND_SOC_DAIFMT_NB_NF;
- break;
- case 1:
- dai_bit_fmt = SND_SOC_DAIFMT_NB_IF;
- break;
- case 2:
- dai_bit_fmt = SND_SOC_DAIFMT_IB_NF;
- break;
- case 3:
- dai_bit_fmt = SND_SOC_DAIFMT_IB_IF;
- break;
- }
- return 0;
- }
- static int dai_mode_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int dai_mode_val = 0;
- switch (dai_mode_fmt) {
- case SND_SOC_DAIFMT_I2S:
- dai_mode_val = 0;
- break;
- case SND_SOC_DAIFMT_RIGHT_J:
- dai_mode_val = 1;
- break;
- case SND_SOC_DAIFMT_LEFT_J:
- dai_mode_val = 2;
- break;
- case SND_SOC_DAIFMT_DSP_A:
- dai_mode_val = 3;
- break;
- case SND_SOC_DAIFMT_DSP_B:
- dai_mode_val = 4;
- break;
- case SND_SOC_DAIFMT_PDM:
- dai_mode_val = 5;
- break;
- }
- ucontrol->value.integer.value[0] = dai_mode_val;
- return 0;
- }
- static int dai_mode_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_info("%s: ucontrol value = %ld\n", __func__,
- ucontrol->value.integer.value[0]);
- switch (ucontrol->value.integer.value[0]) {
- case 0:
- dai_mode_fmt = SND_SOC_DAIFMT_I2S;
- break;
- case 1:
- dai_mode_fmt = SND_SOC_DAIFMT_RIGHT_J;
- break;
- case 2:
- dai_mode_fmt = SND_SOC_DAIFMT_LEFT_J;
- break;
- case 3:
- dai_mode_fmt = SND_SOC_DAIFMT_DSP_A;
- break;
- case 4:
- dai_mode_fmt = SND_SOC_DAIFMT_DSP_B;
- break;
- case 5:
- dai_mode_fmt = SND_SOC_DAIFMT_PDM;
- break;
- }
- return 0;
- }
- static int static_clk_mode_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int static_mode_val = 0;
- switch (sys_clk_static) {
- case 0:
- static_mode_val = 0;
- break;
- case 5644800:
- static_mode_val = 1;
- break;
- case 6144000:
- static_mode_val = 2;
- break;
- case 11289600:
- static_mode_val = 3;
- break;
- case 12000000:
- static_mode_val = 4;
- break;
- case 12288000:
- static_mode_val = 5;
- break;
- case 13000000:
- static_mode_val = 6;
- break;
- case 22579200:
- static_mode_val = 7;
- break;
- case 24000000:
- static_mode_val = 8;
- break;
- case 24576000:
- static_mode_val = 9;
- break;
- case 26000000:
- static_mode_val = 10;
- break;
- }
- ucontrol->value.integer.value[0] = static_mode_val;
- return 0;
- }
- static int static_clk_mode_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (ucontrol->value.integer.value[0]) {
- case 0:
- sys_clk_static = 0;
- break;
- case 1:
- sys_clk_static = 5644800;
- break;
- case 2:
- sys_clk_static = 6144000;
- break;
- case 3:
- sys_clk_static = 11289600;
- break;
- case 4:
- sys_clk_static = 12000000;
- break;
- case 5:
- sys_clk_static = 12288000;
- break;
- case 6:
- sys_clk_static = 13000000;
- break;
- case 7:
- sys_clk_static = 22579200;
- break;
- case 8:
- sys_clk_static = 24000000;
- break;
- case 9:
- sys_clk_static = 24576000;
- break;
- case 10:
- sys_clk_static = 26000000;
- break;
- }
- return 0;
- }
- static int dai_force_frame32_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int dai_force_frame32_val = 0;
- switch (dai_force_frame32) {
- case 0:
- dai_force_frame32_val = 0;
- break;
- case 1:
- dai_force_frame32_val = 1;
- break;
- }
- ucontrol->value.integer.value[0] = dai_force_frame32_val;
- return 0;
- }
- static int dai_force_frame32_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (ucontrol->value.integer.value[0]) {
- case 0:
- dai_force_frame32 = 0;
- break;
- case 1:
- dai_force_frame32 = 1;
- break;
- }
- return 0;
- }
- static const struct soc_enum cirrus_snd_enum[] = {
- SOC_ENUM_SINGLE_EXT(4, dai_sub_clocks),
- SOC_ENUM_SINGLE_EXT(4, dai_bit_config),
- SOC_ENUM_SINGLE_EXT(6, dai_mode_config),
- SOC_ENUM_SINGLE_EXT(11, static_clk_mode),
- SOC_ENUM_SINGLE_EXT(5, codec_src_clocks),
- SOC_ENUM_SINGLE_EXT(2, dai_force_frame32_config),
- };
- static const struct snd_kcontrol_new msm_cirrus_snd_controls[] = {
- SOC_ENUM_EXT("DAI Clocks", cirrus_snd_enum[0], dai_clks_get,
- dai_clks_put),
- SOC_ENUM_EXT("DAI Polarity", cirrus_snd_enum[1], dai_bitfmt_get,
- dai_bitfmt_put),
- SOC_ENUM_EXT("DAI Mode", cirrus_snd_enum[2], dai_mode_get,
- dai_mode_put),
- SOC_ENUM_EXT("Static MCLK Mode", cirrus_snd_enum[3],
- static_clk_mode_get, static_clk_mode_put),
- SOC_ENUM_EXT("Codec CLK Source", cirrus_snd_enum[4], codec_clk_src_get,
- codec_clk_src_put),
- SOC_ENUM_EXT("Force Frame32", cirrus_snd_enum[5], dai_force_frame32_get,
- dai_force_frame32_put),
- };
- static int cirrus_amp_0_speaker(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- dev_info(component->dev, "%s ev: %d\n", __func__, event);
- switch (event) {
- case SND_SOC_DAPM_PRE_PMD:
- cirrus_bd_store_values("_0");
- break;
- }
- return 0;
- }
- static int cirrus_amp_1_speaker(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- dev_info(component->dev, "%s ev: %d\n", __func__, event);
- switch (event) {
- case SND_SOC_DAPM_PRE_PMD:
- cirrus_bd_store_values("_1");
- break;
- }
- return 0;
- }
- static int cirrus_amp_2_speaker(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- dev_info(component->dev, "%s ev: %d\n", __func__, event);
- switch (event) {
- case SND_SOC_DAPM_PRE_PMD:
- cirrus_bd_store_values("_2");
- break;
- }
- return 0;
- }
- static int cirrus_amp_3_speaker(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- dev_info(component->dev, "%s ev: %d\n", __func__, event);
- switch (event) {
- case SND_SOC_DAPM_PRE_PMD:
- cirrus_bd_store_values("_3");
- break;
- }
- return 0;
- }
- #endif
- static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
- {
- int ret = 0;
- struct snd_soc_card *card = component->card;
- struct msm_asoc_mach_data *pdata =
- snd_soc_card_get_drvdata(card);
- if (!pdata->fsa_handle && !pdata->wcd_usbss_handle)
- return false;
- if (pdata->fsa_handle) {
- ret = fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
- } else {
- #if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
- if (wcd_mbhc_cfg.usbss_hsj_connect_enable)
- ret = wcd_usbss_switch_update(WCD_USBSS_GND_MIC_SWAP_HSJ,
- WCD_USBSS_CABLE_CONNECT);
- else if (wcd_mbhc_cfg.enable_usbc_analog)
- ret = wcd_usbss_switch_update(WCD_USBSS_GND_MIC_SWAP_AATC,
- WCD_USBSS_CABLE_CONNECT);
- #endif
- }
- if (ret == 0)
- return true;
- else
- return false;
- }
- static void msm_parse_upd_configuration(struct platform_device *pdev,
- struct msm_asoc_mach_data *pdata)
- {
- int ret = 0;
- u32 dt_values[2];
- if (!pdev || !pdata)
- return;
- ret = of_property_read_string(pdev->dev.of_node,
- "qcom,upd_backends_used", &pdata->upd_config.backend_used);
- if (ret) {
- pr_debug("%s:could not find %s entry in dt\n",
- __func__, "qcom,upd_backends_used");
- return;
- }
- ret = of_property_read_u32_array(pdev->dev.of_node,
- "qcom,upd_lpass_reg_addr", dt_values, MAX_EARPA_REG);
- if (ret) {
- pr_debug("%s: could not find %s entry in dt\n",
- __func__, "qcom,upd_lpass_reg_addr");
- return;
- } else {
- pdata->upd_config.ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr =
- dt_values[0];
- pdata->upd_config.ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr =
- dt_values[1];
- }
- ret = of_property_read_u32(pdev->dev.of_node,
- "qcom,upd_ear_pa_reg_addr", &pdata->upd_config.ear_pa_pkd_reg_addr);
- if (ret) {
- pr_debug("%s: could not find %s entry in dt\n",
- __func__, "qcom,upd_ear_pa_reg_addr");
- }
- }
- static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
- {
- int val1 = 0, val2 = 0, ret = 0;
- u8 dev_num = 0;
- struct snd_soc_component *component = NULL;
- struct msm_asoc_mach_data *pdata = NULL;
- char wcd_name[20];
- if (!rtd) {
- pr_err_ratelimited("%s: rtd is NULL\n", __func__);
- return;
- }
- pdata = snd_soc_card_get_drvdata(rtd->card);
- if (!pdata) {
- pr_err_ratelimited("%s: pdata is NULL\n", __func__);
- return;
- }
- if (!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr ||
- !pdata->upd_config.ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr ||
- !pdata->upd_config.ear_pa_pkd_reg_addr) {
- pr_err_ratelimited("%s: upd static configuration is not set\n", __func__);
- return;
- }
- if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
- if (pdata->wsa_max_devs > 0) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
- if (!component) {
- pr_err("%s: %s component is NULL\n", __func__,
- "wsa-codec.1");
- return;
- }
- } else {
- pr_err("%s wsa_max_devs are NULL\n", __func__);
- return;
- }
- } else {
- if (pdata->wcd_used == WCD937X_DEV_INDEX)
- strscpy(wcd_name, WCD937X_DRV_NAME, sizeof(WCD937X_DRV_NAME));
- else if (pdata->wcd_used == WCD9378_DEV_INDEX)
- strscpy(wcd_name, WCD9378_DRV_NAME, sizeof(WCD9378_DRV_NAME));
- else
- strscpy(wcd_name, WCD939X_DRV_NAME, sizeof(WCD939X_DRV_NAME));
- component = snd_soc_rtdcom_lookup(rtd, wcd_name);
- if (!component) {
- pr_err("%s component is NULL\n", __func__);
- return;
- }
- }
- if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
- if (strstr(rtd->card->name, "wsa883x"))
- pdata->get_dev_num = wsa883x_codec_get_dev_num;
- else
- pdata->get_dev_num = wsa884x_codec_get_dev_num;
- } else {
- if (pdata->wcd_used == WCD937X_DEV_INDEX) {
- pdata->get_dev_num = wcd937x_codec_get_dev_num;
- } else if (pdata->wcd_used == WCD9378_DEV_INDEX) {
- pdata->get_dev_num = wcd9378_codec_get_dev_num;
- } else {
- pdata->get_dev_num = wcd939x_codec_get_dev_num;
- }
- }
- if (!pdata->get_dev_num) {
- pr_err("%s: get_dev_num is NULL\n", __func__);
- return;
- }
- dev_num = pdata->get_dev_num(component);
- if (dev_num < 0 || dev_num > 6) {
- pr_err_ratelimited("%s: invalid slave dev num : %d\n", __func__,
- dev_num);
- return;
- }
- pdata->upd_config.ear_pa_pkd_cfg.ear_pa_enable_pkd_reg_addr =
- pdata->upd_config.ear_pa_pkd_reg_addr & 0xFFFF;
- pdata->upd_config.ear_pa_pkd_cfg.ear_pa_disable_pkd_reg_addr =
- pdata->upd_config.ear_pa_pkd_reg_addr & 0xFFFF;
- val1 = val2 = 0;
- /* bits 16:19 carry command id */
- val1 |= 1 << 16;
- /* bits 20:23 carry swr device number */
- val1 |= dev_num << 20;
- /*
- * bits 24:31 carry 8 bit data to disable or enable ear pa
- * for wcd 7bit is global enable bit - 1 -enable. 0 - disable
- * for wsa 0bit is global enable bit - 1 -enable, 0 - disable
- */
- val2 = val1;
- if (!strcmp(pdata->upd_config.backend_used, "wsa"))
- val1 |= 1 << 24;
- else
- val1 |= 1 << 31;
- pdata->upd_config.ear_pa_pkd_cfg.ear_pa_enable_pkd_reg_addr |= val1;
- pdata->upd_config.ear_pa_pkd_cfg.ear_pa_disable_pkd_reg_addr |= val2;
- ret = audio_prm_set_cdc_earpa_duty_cycling_req(&pdata->upd_config, 1);
- if (ret < 0) {
- pr_err_ratelimited("%s: upd cdc duty cycling registration failed\n", __func__);
- return;
- }
- pr_debug("%s: upd cdc duty cycling registration done successfully!\n", __func__);
- }
- static struct snd_soc_ops msm_common_be_ops = {
- .hw_params = msm_common_snd_hw_params,
- .startup = msm_common_snd_startup,
- .shutdown = msm_common_snd_shutdown,
- };
- static int msm_dmic_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- struct msm_asoc_mach_data *pdata = NULL;
- struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- int ret = 0;
- u32 dmic_idx;
- int *dmic_gpio_cnt;
- struct device_node *dmic_gpio;
- char *wname;
- wname = strpbrk(w->name, "01234567");
- if (!wname) {
- dev_err_ratelimited(component->dev, "%s: widget not found\n", __func__);
- return -EINVAL;
- }
- ret = kstrtouint(wname, 10, &dmic_idx);
- if (ret < 0) {
- dev_err_ratelimited(component->dev, "%s: Invalid DMIC line on the codec\n",
- __func__);
- return -EINVAL;
- }
- pdata = snd_soc_card_get_drvdata(component->card);
- switch (dmic_idx) {
- case 0:
- case 1:
- dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
- dmic_gpio = pdata->dmic01_gpio_p;
- break;
- case 2:
- case 3:
- dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
- dmic_gpio = pdata->dmic23_gpio_p;
- break;
- case 4:
- case 5:
- dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
- dmic_gpio = pdata->dmic45_gpio_p;
- break;
- case 6:
- case 7:
- dmic_gpio_cnt = &dmic_6_7_gpio_cnt;
- dmic_gpio = pdata->dmic67_gpio_p;
- break;
- default:
- dev_err_ratelimited(component->dev, "%s: Invalid DMIC Selection\n",
- __func__);
- return -EINVAL;
- }
- dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
- __func__, event, dmic_idx, *dmic_gpio_cnt);
- switch (event) {
- case SND_SOC_DAPM_PRE_PMU:
- (*dmic_gpio_cnt)++;
- if (*dmic_gpio_cnt == 1) {
- ret = msm_cdc_pinctrl_select_active_state(
- dmic_gpio);
- if (ret < 0) {
- pr_err_ratelimited("%s: gpio set cannot be activated %sd",
- __func__, "dmic_gpio");
- return ret;
- }
- }
- break;
- case SND_SOC_DAPM_POST_PMD:
- (*dmic_gpio_cnt)--;
- if (*dmic_gpio_cnt == 0) {
- ret = msm_cdc_pinctrl_select_sleep_state(
- dmic_gpio);
- if (ret < 0) {
- pr_err_ratelimited("%s: gpio set cannot be de-activated %sd",
- __func__, "dmic_gpio");
- return ret;
- }
- }
- break;
- default:
- pr_err_ratelimited("%s: invalid DAPM event %d\n", __func__, event);
- return -EINVAL;
- }
- return 0;
- }
- static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
- SND_SOC_DAPM_MIC("Analog Mic1", NULL),
- SND_SOC_DAPM_MIC("Analog Mic2", NULL),
- SND_SOC_DAPM_MIC("Analog Mic3", NULL),
- SND_SOC_DAPM_MIC("Analog Mic4", NULL),
- SND_SOC_DAPM_MIC("Analog Mic5", NULL),
- SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
- SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
- SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
- SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
- SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
- SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
- SND_SOC_DAPM_MIC("Digital Mic6", NULL),
- SND_SOC_DAPM_MIC("Digital Mic7", NULL),
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- SND_SOC_DAPM_SPK("AMP0 SPK", cirrus_amp_0_speaker),
- SND_SOC_DAPM_SPK("AMP1 SPK", cirrus_amp_1_speaker),
- SND_SOC_DAPM_SPK("AMP2 SPK", cirrus_amp_2_speaker),
- SND_SOC_DAPM_SPK("AMP3 SPK", cirrus_amp_3_speaker),
- #endif
- };
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- #if IS_ENABLED(CONFIG_SEC_ABC)
- void cirrus_i2c_fail_log(const char *suffix)
- {
- pr_info("%s(%s)\n", __func__, suffix);
- #if IS_ENABLED(CONFIG_SEC_FACTORY)
- sec_abc_send_event("MODULE=audio@INFO=spk_amp");
- #else
- sec_abc_send_event("MODULE=audio@WARN=spk_amp");
- #endif
- }
- void cirrus_amp_fail_event(const char *suffix)
- {
- pr_info("%s(%s)\n", __func__, suffix);
- #if IS_ENABLED(CONFIG_SEC_FACTORY)
- sec_abc_send_event("MODULE=audio@INFO=spk_amp_short");
- #else
- sec_abc_send_event("MODULE=audio@WARN=spk_amp_short");
- #endif
- }
- #endif
- static int pineapple_tdm_cirrus_init(struct snd_soc_pcm_runtime *rtd)
- {
- int i;
- struct snd_soc_dai *codec_dai_amp;
- struct snd_soc_dapm_context *amp_dapm;
- if (cirrus_amp_count < 1 || cirrus_amp_count > 4) {
- pr_err("%s: out of range\n", __func__);
- return 0;
- }
- for (i = 0 ; i < cirrus_amp_count; i++) {
- codec_dai_amp = asoc_rtd_to_codec(rtd, i);
- amp_dapm = snd_soc_component_get_dapm(codec_dai_amp->component);
- switch (cirrus_amp_conf) {
- case CS35L43_MONO:
- case CS35L43_STEREO:
- case CS35L43_QUAD:
- snd_soc_dapm_ignore_suspend(amp_dapm, "AMP Capture");
- snd_soc_dapm_ignore_suspend(amp_dapm, "AMP Playback");
- snd_soc_dapm_ignore_suspend(amp_dapm, "AMP SPK");
- snd_soc_dapm_sync(amp_dapm);
- break;
- case CS35L45_MONO:
- case CS35L45_STEREO:
- case CS35L45_QUAD:
- snd_soc_dapm_ignore_suspend(amp_dapm, "Capture");
- snd_soc_dapm_ignore_suspend(amp_dapm, "Playback");
- snd_soc_dapm_ignore_suspend(amp_dapm, "SPK");
- snd_soc_dapm_ignore_suspend(amp_dapm, "AP");
- snd_soc_dapm_ignore_suspend(amp_dapm, "AMP Enable");
- snd_soc_dapm_ignore_suspend(amp_dapm, "Entry");
- snd_soc_dapm_ignore_suspend(amp_dapm, "Exit");
- snd_soc_dapm_sync(amp_dapm);
- break;
- default:
- pr_err("%s: cirrus amp conf is not defined\n",
- __func__);
- break;
- }
- }
- #if IS_ENABLED(CONFIG_SEC_ABC)
- cirrus_amp_register_i2c_error_callback("", cirrus_i2c_fail_log);
- cirrus_amp_register_i2c_error_callback("_r", cirrus_i2c_fail_log);
- cirrus_amp_register_error_callback("", cirrus_amp_fail_event);
- cirrus_amp_register_error_callback("_r", cirrus_amp_fail_event);
- #endif
- register_cirrus_bigdata_cb(amp_dapm->component);
- pr_info("%s end\n", __func__);
- return 0;
- }
- #endif
- #if defined(CONFIG_SND_SOC_TAS25XX)
- #if IS_ENABLED(CONFIG_SEC_ABC)
- void tas_i2c_fail_log(uint32_t i2caddr)
- {
- pr_info("%s(%x)\n", __func__, i2caddr);
- #if IS_ENABLED(CONFIG_SEC_FACTORY)
- sec_abc_send_event("MODULE=audio@INFO=spk_amp");
- #else
- sec_abc_send_event("MODULE=audio@WARN=spk_amp");
- #endif
- }
- void tas_amp_fail_log(int32_t ch, int32_t err)
- {
- pr_info("%s(ch : %d , error : %d)\n", __func__, ch, err);
- #if IS_ENABLED(CONFIG_SEC_FACTORY)
- sec_abc_send_event("MODULE=audio@INFO=spk_amp_short");
- #else
- sec_abc_send_event("MODULE=audio@WARN=spk_amp_short");
- #endif
- }
- #endif
- static int pineapple_tdm_tas_init(struct snd_soc_pcm_runtime *rtd)
- {
- #if IS_ENABLED(CONFIG_SEC_ABC)
- tas25xx_register_i2c_error_callback(tas_i2c_fail_log);
- tas25xx_register_amp_error_callback(tas_amp_fail_log);
- #endif
- return 0;
- }
- #endif
- #ifndef CONFIG_AUDIO_BTFM_PROXY
- static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
- {
- unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
- unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
- struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
- int ret = 0;
- ret = snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
- tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
- if (ret)
- return ret;
- msm_common_dai_link_init(rtd);
- return ret;
- }
- static int msm_wcn_init_btfm(struct snd_soc_pcm_runtime *rtd)
- {
- unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
- unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX_FM] = {159, 160, 161};
- struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
- int ret = 0;
- ret = snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
- tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
- if (ret)
- return ret;
- msm_common_dai_link_init(rtd);
- return ret;
- }
- #endif
- static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
- const char *name,
- struct snd_info_entry *parent)
- {
- struct snd_info_entry *entry;
- entry = snd_info_create_module_entry(mod, name, parent);
- if (!entry)
- return NULL;
- entry->mode = S_IFDIR | 0555;
- if (snd_info_register(entry) < 0) {
- snd_info_free_entry(entry);
- return NULL;
- }
- return entry;
- }
- static void *def_wcd_mbhc_cal(void)
- {
- void *wcd_mbhc_cal;
- struct wcd_mbhc_btn_detect_cfg *btn_cfg;
- u16 *btn_high;
- wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
- WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
- if (!wcd_mbhc_cal)
- return NULL;
- WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
- WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
- btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
- btn_high = ((void *)&btn_cfg->_v_btn_low) +
- (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
- btn_high[0] = 75;
- btn_high[1] = 150;
- btn_high[2] = 237;
- btn_high[3] = 500;
- btn_high[4] = 500;
- btn_high[5] = 500;
- btn_high[6] = 500;
- btn_high[7] = 500;
- return wcd_mbhc_cal;
- }
- /* Digital audio interface glue - connects codec <---> CPU */
- static struct snd_soc_dai_link msm_common_be_dai_links[] = {
- /* Proxy Tx BACK END DAI Link */
- {
- .name = LPASS_BE_RT_PROXY_PCM_TX,
- .stream_name = LPASS_BE_RT_PROXY_PCM_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(proxy_tx),
- },
- {
- .name = LPASS_BE_RT_PROXY_PCM_TX_2,
- .stream_name = LPASS_BE_RT_PROXY_PCM_TX_2,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(proxy_tx2),
- },
- /* Proxy Rx BACK END DAI Link */
- {
- .name = LPASS_BE_RT_PROXY_PCM_RX,
- .stream_name = LPASS_BE_RT_PROXY_PCM_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(proxy_rx),
- },
- {
- .name = LPASS_BE_RT_PROXY_PCM_RX_2,
- .stream_name = LPASS_BE_RT_PROXY_PCM_RX_2,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(proxy_rx2),
- },
- {
- .name = LPASS_BE_USB_AUDIO_RX,
- .stream_name = LPASS_BE_USB_AUDIO_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(usb_audio_rx),
- },
- {
- .name = LPASS_BE_USB_AUDIO_TX,
- .stream_name = LPASS_BE_USB_AUDIO_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(usb_audio_tx),
- },
- {
- .name = LPASS_BE_PCM_DUMMY_TX_0,
- .stream_name = LPASS_BE_PCM_DUMMY_TX_0,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(pcm_dummy_tx0),
- },
- /* Dummy Dev Rx BACK END DAI Link */
- {
- .name = LPASS_BE_PCM_DUMMY_RX_0,
- .stream_name = LPASS_BE_PCM_DUMMY_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(pcm_dummy_rx0),
- },
- /* Dummy Dev Tx BACK END DAI Link */
- {
- .name = LPASS_BE_PCM_DUMMY_TX_1,
- .stream_name = LPASS_BE_PCM_DUMMY_TX_1,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(pcm_dummy_tx1),
- },
- };
- #ifndef CONFIG_AUDIO_BTFM_PROXY
- static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
- {
- .name = LPASS_BE_SLIMBUS_7_RX,
- .stream_name = LPASS_BE_SLIMBUS_7_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .init = &msm_wcn_init,
- .ops = &msm_common_be_ops,
- /* dai link has playback support */
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(slimbus_7_rx),
- },
- {
- .name = LPASS_BE_SLIMBUS_7_TX,
- .stream_name = LPASS_BE_SLIMBUS_7_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(slimbus_7_tx),
- },
- };
- static struct snd_soc_dai_link msm_wcn_btfm_be_dai_links[] = {
- {
- .name = LPASS_BE_SLIMBUS_7_RX,
- .stream_name = LPASS_BE_SLIMBUS_7_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .init = &msm_wcn_init_btfm,
- .ops = &msm_common_be_ops,
- /* dai link has playback support */
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(slimbus_7_rx),
- },
- {
- .name = LPASS_BE_SLIMBUS_7_TX,
- .stream_name = LPASS_BE_SLIMBUS_7_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(slimbus_7_tx),
- },
- {
- .name = LPASS_BE_SLIMBUS_8_TX,
- .stream_name = LPASS_BE_SLIMBUS_8_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .init = &msm_wcn_init,
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(slimbus_8_tx),
- },
- };
- #else
- static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
- {
- .name = LPASS_BE_BTFM_PROXY_RX_0,
- .stream_name = LPASS_BE_BTFM_PROXY_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- /* dai link has playback support */
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(btfm_0_rx),
- },
- {
- .name = LPASS_BE_BTFM_PROXY_TX_0,
- .stream_name = LPASS_BE_BTFM_PROXY_TX_0,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(btfm_0_tx),
- },
- };
- #endif
- static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
- /* DISP PORT BACK END DAI Link */
- {
- .name = LPASS_BE_DISPLAY_PORT_RX,
- .stream_name = LPASS_BE_DISPLAY_PORT_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(display_port),
- },
- };
- static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
- /* WSA CDC DMA Backend DAI Links */
- {
- .name = LPASS_BE_WSA_CDC_DMA_RX_0,
- .stream_name = LPASS_BE_WSA_CDC_DMA_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(wsa_dma_rx0),
- .init = &msm_int_wsa_init,
- },
- {
- .name = LPASS_BE_WSA_CDC_DMA_RX_1,
- .stream_name = LPASS_BE_WSA_CDC_DMA_RX_1,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(wsa_dma_rx1),
- },
- {
- .name = LPASS_BE_WSA_CDC_DMA_TX_1,
- .stream_name = LPASS_BE_WSA_CDC_DMA_TX_1,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(wsa_dma_tx1),
- },
- {
- .name = LPASS_BE_WSA_CDC_DMA_TX_0,
- .stream_name = LPASS_BE_WSA_CDC_DMA_TX_0,
- .capture_only = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
- SND_SOC_DAILINK_REG(vi_feedback),
- },
- {
- .name = LPASS_BE_WSA_CDC_DMA_TX_2,
- .stream_name = LPASS_BE_WSA_CDC_DMA_TX_2,
- .capture_only = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
- SND_SOC_DAILINK_REG(cps_feedback),
- },
- {
- .name = LPASS_BE_WSA_CDC_DMA_RX_0_VIRT,
- .stream_name = LPASS_BE_WSA_CDC_DMA_RX_0_VIRT,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(wsa_dma_rx0),
- .init = &msm_int_wsa_init,
- },
- };
- static struct snd_soc_dai_link msm_wsa2_cdc_dma_be_dai_links[] = {
- /* WSA2 CDC DMA Backend DAI Links */
- {
- .name = LPASS_BE_WSA2_CDC_DMA_RX_0,
- .stream_name = LPASS_BE_WSA2_CDC_DMA_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(wsa2_dma_rx0),
- .init = &msm_int_wsa2_init,
- },
- {
- .name = LPASS_BE_WSA2_CDC_DMA_RX_1,
- .stream_name = LPASS_BE_WSA2_CDC_DMA_RX_1,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(wsa2_dma_rx1),
- },
- {
- .name = LPASS_BE_WSA2_CDC_DMA_TX_1,
- .stream_name = LPASS_BE_WSA2_CDC_DMA_TX_1,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(wsa2_dma_tx1),
- },
- {
- .name = LPASS_BE_WSA2_CDC_DMA_TX_0,
- .stream_name = LPASS_BE_WSA2_CDC_DMA_TX_0,
- .capture_only = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
- SND_SOC_DAILINK_REG(wsa2_vi_feedback),
- },
- {
- .name = LPASS_BE_WSA2_CDC_DMA_TX_2,
- .stream_name = LPASS_BE_WSA2_CDC_DMA_TX_2,
- .capture_only = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
- SND_SOC_DAILINK_REG(wsa2_cps_feedback),
- },
- };
- static struct snd_soc_dai_link msm_wsa_wsa2_cdc_dma_be_dai_links[] = {
- /* WSA CDC DMA Backend DAI Links */
- {
- .name = LPASS_BE_WSA_CDC_DMA_RX_0,
- .stream_name = LPASS_BE_WSA_CDC_DMA_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(wsa_wsa2_dma_rx0),
- .init = &msm_int_wsa_init,
- },
- {
- .name = LPASS_BE_WSA_CDC_DMA_RX_1,
- .stream_name = LPASS_BE_WSA_CDC_DMA_RX_1,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(wsa_wsa2_dma_rx1),
- },
- {
- .name = LPASS_BE_WSA_CDC_DMA_TX_1,
- .stream_name = LPASS_BE_WSA_CDC_DMA_TX_1,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(wsa_wsa2_dma_tx1),
- },
- {
- .name = LPASS_BE_WSA_CDC_DMA_TX_0,
- .stream_name = LPASS_BE_WSA_CDC_DMA_TX_0,
- .capture_only = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
- SND_SOC_DAILINK_REG(wsa_wsa2_vi_feedback),
- },
- {
- .name = LPASS_BE_WSA_CDC_DMA_TX_2,
- .stream_name = LPASS_BE_WSA_CDC_DMA_TX_2,
- .capture_only = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
- SND_SOC_DAILINK_REG(wsa_wsa2_cps_feedback),
- },
- };
- static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
- /* RX CDC DMA Backend DAI Links */
- {
- .name = LPASS_BE_RX_CDC_DMA_RX_0,
- .stream_name = LPASS_BE_RX_CDC_DMA_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(rx_dma_rx0),
- .init = &msm_rx_tx_codec_init,
- },
- {
- .name = LPASS_BE_RX_CDC_DMA_RX_1,
- .stream_name = LPASS_BE_RX_CDC_DMA_RX_1,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(rx_dma_rx1),
- .init = &msm_int_wsa881x_init,
- },
- {
- .name = LPASS_BE_RX_CDC_DMA_RX_2,
- .stream_name = LPASS_BE_RX_CDC_DMA_RX_2,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(rx_dma_rx2),
- },
- {
- .name = LPASS_BE_RX_CDC_DMA_RX_3,
- .stream_name = LPASS_BE_RX_CDC_DMA_RX_3,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(rx_dma_rx3),
- },
- {
- .name = LPASS_BE_RX_CDC_DMA_RX_5,
- .stream_name = LPASS_BE_RX_CDC_DMA_RX_5,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(rx_dma_rx5),
- },
- {
- .name = LPASS_BE_RX_CDC_DMA_RX_6,
- .stream_name = LPASS_BE_RX_CDC_DMA_RX_6,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(rx_dma_rx6),
- },
- /* TX CDC DMA Backend DAI Links */
- {
- .name = LPASS_BE_TX_CDC_DMA_TX_3,
- .stream_name = LPASS_BE_TX_CDC_DMA_TX_3,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(tx_dma_tx3),
- },
- {
- .name = LPASS_BE_TX_CDC_DMA_TX_4,
- .stream_name = LPASS_BE_TX_CDC_DMA_TX_4,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(tx_dma_tx4),
- },
- {
- .name = LPASS_BE_RX_CDC_DMA_RX_1_VIRT,
- .stream_name = LPASS_BE_RX_CDC_DMA_RX_1_VIRT,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(rx_dma_rx1),
- .init = &msm_int_wsa881x_init,
- },
- };
- static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
- {
- .name = LPASS_BE_VA_CDC_DMA_TX_0,
- .stream_name = LPASS_BE_VA_CDC_DMA_TX_0,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(va_dma_tx0),
- },
- {
- .name = LPASS_BE_VA_CDC_DMA_TX_1,
- .stream_name = LPASS_BE_VA_CDC_DMA_TX_1,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(va_dma_tx1),
- },
- {
- .name = LPASS_BE_VA_CDC_DMA_TX_2,
- .stream_name = LPASS_BE_VA_CDC_DMA_TX_2,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .ops = &msm_common_be_ops,
- SND_SOC_DAILINK_REG(va_dma_tx2),
- },
- };
- /*
- * I2S interface pinctrl mapping
- * ------------------------------------
- * Primary - pri_mi2s
- * Secondary - lpi_i2s3
- * Tertiary - tert_mi2s
- * Quaternary - quat_mi2s (lpi_i2s0)
- * Quinary - lpi_i2s1
- * Senary - lpi_i2s2
- * ------------------------------------
- */
- static struct snd_soc_dai_link msm_mi2s_dai_links[] = {
- {
- .name = LPASS_BE_PRI_MI2S_RX,
- .stream_name = LPASS_BE_PRI_MI2S_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(pri_mi2s_rx),
- },
- {
- .name = LPASS_BE_PRI_MI2S_TX,
- .stream_name = LPASS_BE_PRI_MI2S_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(pri_mi2s_tx),
- },
- {
- .name = LPASS_BE_SEC_MI2S_RX,
- .stream_name = LPASS_BE_SEC_MI2S_RX,
- .playback_only = 1,
- #ifdef CONFIG_USE_CS40L26
- .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS
- | SND_SOC_DAIFMT_NB_NF,
- #endif
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(sec_mi2s_rx),
- },
- {
- .name = LPASS_BE_SEC_MI2S_TX,
- .stream_name = LPASS_BE_SEC_MI2S_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(sec_mi2s_tx),
- },
- {
- .name = LPASS_BE_TERT_MI2S_RX,
- .stream_name = LPASS_BE_TERT_MI2S_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(tert_mi2s_rx),
- },
- {
- .name = LPASS_BE_TERT_MI2S_TX,
- .stream_name = LPASS_BE_TERT_MI2S_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(tert_mi2s_tx),
- },
- {
- .name = LPASS_BE_QUAT_MI2S_RX,
- .stream_name = LPASS_BE_QUAT_MI2S_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(quat_mi2s_rx),
- },
- {
- .name = LPASS_BE_QUAT_MI2S_TX,
- .stream_name = LPASS_BE_QUAT_MI2S_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(quat_mi2s_tx),
- },
- {
- .name = LPASS_BE_QUIN_MI2S_RX,
- .stream_name = LPASS_BE_QUIN_MI2S_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(quin_mi2s_rx),
- },
- {
- .name = LPASS_BE_QUIN_MI2S_TX,
- .stream_name = LPASS_BE_QUIN_MI2S_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(quin_mi2s_tx),
- },
- {
- .name = LPASS_BE_SEN_MI2S_RX,
- .stream_name = LPASS_BE_SEN_MI2S_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(sen_mi2s_rx),
- },
- {
- .name = LPASS_BE_SEN_MI2S_TX,
- .stream_name = LPASS_BE_SEN_MI2S_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(sen_mi2s_tx),
- },
- {
- .name = LPASS_BE_SEP_MI2S_RX,
- .stream_name = LPASS_BE_SEP_MI2S_RX,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(sep_mi2s_rx),
- },
- {
- .name = LPASS_BE_SEP_MI2S_TX,
- .stream_name = LPASS_BE_SEP_MI2S_TX,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(sep_mi2s_tx),
- },
- };
- static struct snd_soc_dai_link msm_tdm_dai_links[] = {
- {
- .name = LPASS_BE_PRI_TDM_RX_0,
- .stream_name = LPASS_BE_PRI_TDM_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBS_CFS
- | SND_SOC_DAIFMT_IB_NF,
- .init = &pineapple_tdm_cirrus_init,
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(cirrus_pri_tdm_rx_0),
- #elif defined(CONFIG_SND_SOC_TAS25XX)
- .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBS_CFS
- | SND_SOC_DAIFMT_IB_NF,
- .init = &pineapple_tdm_tas_init,
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(tas25xx_pri_tdm_rx_0),
- #else
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(pri_tdm_rx_0),
- #endif
- },
- {
- .name = LPASS_BE_PRI_TDM_TX_0,
- .stream_name = LPASS_BE_PRI_TDM_TX_0,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBS_CFS
- | SND_SOC_DAIFMT_IB_NF,
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(cirrus_pri_tdm_tx_0),
- #elif defined(CONFIG_SND_SOC_TAS25XX)
- .dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBS_CFS
- | SND_SOC_DAIFMT_IB_NF,
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(tas25xx_pri_tdm_tx_0),
- #else
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(pri_tdm_tx_0),
- #endif
- },
- {
- .name = LPASS_BE_SEC_TDM_RX_0,
- .stream_name = LPASS_BE_SEC_TDM_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(sec_tdm_rx_0),
- },
- {
- .name = LPASS_BE_SEC_TDM_TX_0,
- .stream_name = LPASS_BE_SEC_TDM_TX_0,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(sec_tdm_tx_0),
- },
- {
- .name = LPASS_BE_TERT_TDM_RX_0,
- .stream_name = LPASS_BE_TERT_TDM_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(tert_tdm_rx_0),
- },
- {
- .name = LPASS_BE_TERT_TDM_TX_0,
- .stream_name = LPASS_BE_TERT_TDM_TX_0,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(tert_tdm_tx_0),
- },
- {
- .name = LPASS_BE_QUAT_TDM_RX_0,
- .stream_name = LPASS_BE_QUAT_TDM_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(quat_tdm_rx_0),
- },
- {
- .name = LPASS_BE_QUAT_TDM_TX_0,
- .stream_name = LPASS_BE_QUAT_TDM_TX_0,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(quat_tdm_tx_0),
- },
- {
- .name = LPASS_BE_QUIN_TDM_RX_0,
- .stream_name = LPASS_BE_QUIN_TDM_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(quin_tdm_rx_0),
- },
- {
- .name = LPASS_BE_QUIN_TDM_TX_0,
- .stream_name = LPASS_BE_QUIN_TDM_TX_0,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(quin_tdm_tx_0),
- },
- {
- .name = LPASS_BE_SEN_TDM_RX_0,
- .stream_name = LPASS_BE_SEN_TDM_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(sen_tdm_rx_0),
- },
- {
- .name = LPASS_BE_SEN_TDM_TX_0,
- .stream_name = LPASS_BE_SEN_TDM_TX_0,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(sen_tdm_tx_0),
- },
- {
- .name = LPASS_BE_SEP_TDM_RX_0,
- .stream_name = LPASS_BE_SEP_TDM_RX_0,
- .playback_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- SND_SOC_DAILINK_REG(sep_tdm_rx_0),
- },
- {
- .name = LPASS_BE_SEP_TDM_TX_0,
- .stream_name = LPASS_BE_SEP_TDM_TX_0,
- .capture_only = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ops = &msm_common_be_ops,
- .ignore_suspend = 1,
- SND_SOC_DAILINK_REG(sep_tdm_tx_0),
- },
- };
- static struct snd_soc_dai_link msm_pineapple_dai_links[
- ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
- ARRAY_SIZE(msm_wsa2_cdc_dma_be_dai_links) +
- ARRAY_SIZE(msm_wsa_wsa2_cdc_dma_be_dai_links) +
- ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
- ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
- ARRAY_SIZE(ext_disp_be_dai_link) +
- ARRAY_SIZE(msm_common_be_dai_links) +
- #ifndef CONFIG_AUDIO_BTFM_PROXY
- ARRAY_SIZE(msm_wcn_btfm_be_dai_links) +
- #endif
- ARRAY_SIZE(msm_wcn_be_dai_links) +
- ARRAY_SIZE(msm_mi2s_dai_links) +
- ARRAY_SIZE(msm_tdm_dai_links)];
- static int msm_populate_dai_link_component_of_node(
- struct snd_soc_card *card)
- {
- int i, j, index, ret = 0;
- struct device *cdev = card->dev;
- struct snd_soc_dai_link *dai_link = card->dai_link;
- struct device_node *np = NULL;
- int codecs_enabled = 0;
- struct snd_soc_dai_link_component *codecs_comp = NULL;
- if (!cdev) {
- dev_err_ratelimited(cdev, "%s: Sound card device memory NULL\n", __func__);
- return -ENODEV;
- }
- for (i = 0; i < card->num_links; i++) {
- if (dai_link[i].init == NULL)
- dai_link[i].init = &msm_common_dai_link_init;
- /* populate codec_of_node for snd card dai links */
- if (dai_link[i].num_codecs > 0) {
- for (j = 0; j < dai_link[i].num_codecs; j++) {
- if (dai_link[i].codecs[j].of_node ||
- !dai_link[i].codecs[j].name)
- continue;
- index = of_property_match_string(cdev->of_node,
- "asoc-codec-names",
- dai_link[i].codecs[j].name);
- if (index < 0)
- continue;
- np = of_parse_phandle(cdev->of_node,
- "asoc-codec",
- index);
- if (!np) {
- dev_err_ratelimited(cdev,
- "%s: retrieving phandle for codec %s failed\n",
- __func__,
- dai_link[i].codecs[j].name);
- ret = -ENODEV;
- goto err;
- }
- dai_link[i].codecs[j].of_node = np;
- dai_link[i].codecs[j].name = NULL;
- }
- }
- }
- /* In multi-codec scenario, check if codecs are enabled for this platform */
- for (i = 0; i < card->num_links; i++) {
- codecs_enabled = 0;
- if (dai_link[i].num_codecs > 1) {
- for (j = 0; j < dai_link[i].num_codecs; j++) {
- if (!dai_link[i].codecs[j].of_node)
- continue;
- np = dai_link[i].codecs[j].of_node;
- if (!of_device_is_available(np)) {
- dev_err_ratelimited(cdev, "%s: codec is disabled: %s\n",
- __func__,
- np->full_name);
- dai_link[i].codecs[j].of_node = NULL;
- continue;
- }
- codecs_enabled++;
- }
- if (codecs_enabled > 0 &&
- codecs_enabled < dai_link[i].num_codecs) {
- codecs_comp = devm_kzalloc(cdev,
- sizeof(struct snd_soc_dai_link_component)
- * codecs_enabled, GFP_KERNEL);
- if (!codecs_comp) {
- dev_err_ratelimited(cdev,
- "%s: %s dailink codec component alloc failed\n",
- __func__, dai_link[i].name);
- ret = -ENOMEM;
- goto err;
- }
- index = 0;
- for (j = 0; j < dai_link[i].num_codecs; j++) {
- if(dai_link[i].codecs[j].of_node) {
- codecs_comp[index].of_node =
- dai_link[i].codecs[j].of_node;
- codecs_comp[index].dai_name =
- dai_link[i].codecs[j].dai_name;
- codecs_comp[index].name = NULL;
- index++;
- }
- }
- dai_link[i].codecs = codecs_comp;
- dai_link[i].num_codecs = codecs_enabled;
- }
- }
- }
- err:
- return ret;
- }
- static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
- {
- return 0;
- }
- static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
- {
- return 0;
- }
- static struct snd_soc_ops msm_stub_be_ops = {
- .hw_params = msm_snd_stub_hw_params,
- };
- struct snd_soc_card snd_soc_card_stub_msm = {
- .name = "pineapple-stub-snd-card",
- };
- static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
- /* Backend DAI Links */
- {
- .name = LPASS_BE_PRI_AUXPCM_RX,
- .stream_name = LPASS_BE_PRI_AUXPCM_RX,
- .playback_only = 1,
- .init = &msm_audrx_stub_init,
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- .ops = &msm_stub_be_ops,
- SND_SOC_DAILINK_REG(auxpcm_rx),
- },
- {
- .name = LPASS_BE_PRI_AUXPCM_TX,
- .stream_name = LPASS_BE_PRI_AUXPCM_TX,
- .capture_only = 1,
- .ignore_suspend = 1,
- .ops = &msm_stub_be_ops,
- SND_SOC_DAILINK_REG(auxpcm_tx),
- },
- };
- static struct snd_soc_dai_link msm_stub_dai_links[
- ARRAY_SIZE(msm_stub_be_dai_links)];
- static const struct of_device_id pineapple_asoc_machine_of_match[] = {
- { .compatible = "qcom,pineapple-asoc-snd",
- .data = "codec"},
- { .compatible = "qcom,pineapple-asoc-snd-stub",
- .data = "stub_codec"},
- {},
- };
- static int msm_snd_card_late_probe(struct snd_soc_card *card)
- {
- struct snd_soc_component *component = NULL;
- struct snd_soc_pcm_runtime *rtd;
- struct msm_asoc_mach_data *pdata;
- int ret = 0;
- void *mbhc_calibration;
- char wcd_name[20];
- pdata = snd_soc_card_get_drvdata(card);
- if (!pdata)
- return -EINVAL;
- if (pdata->wcd_disabled)
- return 0;
- rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
- if (!rtd) {
- dev_err(card->dev,
- "%s: snd_soc_get_pcm_runtime for %s failed!\n",
- __func__, card->dai_link[0]);
- return -EINVAL;
- }
- if (pdata->wcd_used == WCD937X_DEV_INDEX)
- strscpy(wcd_name, WCD937X_DRV_NAME, sizeof(WCD937X_DRV_NAME));
- else if (pdata->wcd_used == WCD9378_DEV_INDEX)
- strscpy(wcd_name, WCD9378_DRV_NAME, sizeof(WCD9378_DRV_NAME));
- else
- strscpy(wcd_name, WCD939X_DRV_NAME, sizeof(WCD939X_DRV_NAME));
- component = snd_soc_rtdcom_lookup(rtd, wcd_name);
- if (!component) {
- pr_err("%s component is NULL\n", __func__);
- return -EINVAL;
- }
- mbhc_calibration = def_wcd_mbhc_cal();
- if (!mbhc_calibration)
- return -ENOMEM;
- wcd_mbhc_cfg.calibration = mbhc_calibration;
- #if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C)
- if (of_find_property(card->dev->of_node,
- "qcom,usbss-hsj-connect-enabled", NULL))
- wcd_mbhc_cfg.usbss_hsj_connect_enable = true;
- #endif
- switch (pdata->wcd_used) {
- case WCD937X_DEV_INDEX:
- ret = wcd937x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
- break;
- case WCD9378_DEV_INDEX:
- ret = wcd9378_mbhc_hs_detect(component, &wcd_mbhc_cfg);
- break;
- case WCD939X_DEV_INDEX:
- ret = wcd939x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
- break;
- default:
- return -EINVAL;
- }
- if (ret) {
- dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
- __func__, ret);
- goto err_hs_detect;
- }
- return 0;
- err_hs_detect:
- kfree(mbhc_calibration);
- return ret;
- }
- static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev, int wsa_max_devs)
- {
- struct snd_soc_card *card = NULL;
- struct snd_soc_dai_link *dailink = NULL;
- int total_links = 0;
- int rc = 0;
- u32 val = 0;
- const struct of_device_id *match;
- match = of_match_node(pineapple_asoc_machine_of_match, dev->of_node);
- if (!match) {
- dev_err_ratelimited(dev, "%s: No DT match found for sound card\n",
- __func__);
- return NULL;
- }
- if (!strcmp(match->data, "codec")) {
- card = &snd_soc_card_pineapple_msm;
- /* late probe uses dai link at index '0' to get wcd component */
- memcpy(msm_pineapple_dai_links + total_links,
- msm_rx_tx_cdc_dma_be_dai_links,
- sizeof(msm_rx_tx_cdc_dma_be_dai_links));
- total_links +=
- ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
- switch (wsa_max_devs) {
- case MONO_SPEAKER:
- case STEREO_SPEAKER:
- memcpy(msm_pineapple_dai_links + total_links,
- msm_wsa_cdc_dma_be_dai_links,
- sizeof(msm_wsa_cdc_dma_be_dai_links));
- total_links += ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
- break;
- case QUAD_SPEAKER:
- if (of_find_property(dev->of_node,
- "qcom,dedicated-wsa2", NULL)) {
- memcpy(msm_pineapple_dai_links + total_links,
- msm_wsa_cdc_dma_be_dai_links,
- sizeof(msm_wsa_cdc_dma_be_dai_links));
- total_links += ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
- memcpy(msm_pineapple_dai_links + total_links,
- msm_wsa2_cdc_dma_be_dai_links,
- sizeof(msm_wsa2_cdc_dma_be_dai_links));
- total_links += ARRAY_SIZE(msm_wsa2_cdc_dma_be_dai_links);
- } else {
- memcpy(msm_pineapple_dai_links + total_links,
- msm_wsa2_cdc_dma_be_dai_links,
- sizeof(msm_wsa2_cdc_dma_be_dai_links));
- total_links += ARRAY_SIZE(msm_wsa2_cdc_dma_be_dai_links);
- memcpy(msm_pineapple_dai_links + total_links,
- msm_wsa_wsa2_cdc_dma_be_dai_links,
- sizeof(msm_wsa_wsa2_cdc_dma_be_dai_links));
- total_links += ARRAY_SIZE(msm_wsa_wsa2_cdc_dma_be_dai_links);
- }
- break;
- default:
- dev_dbg(dev,
- "%s: Unexpected number of WSAs, wsa_max_devs: %d\n",
- __func__, wsa_max_devs);
- break;
- }
- memcpy(msm_pineapple_dai_links + total_links,
- msm_va_cdc_dma_be_dai_links,
- sizeof(msm_va_cdc_dma_be_dai_links));
- total_links += ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
- memcpy(msm_pineapple_dai_links + total_links,
- msm_common_be_dai_links,
- sizeof(msm_common_be_dai_links));
- total_links += ARRAY_SIZE(msm_common_be_dai_links);
- rc = of_property_read_u32(dev->of_node,
- "qcom,mi2s-audio-intf", &val);
- if (!rc && val) {
- memcpy(msm_pineapple_dai_links + total_links,
- msm_mi2s_dai_links,
- sizeof(msm_mi2s_dai_links));
- total_links += ARRAY_SIZE(msm_mi2s_dai_links);
- }
- rc = of_property_read_u32(dev->of_node,
- "qcom,tdm-audio-intf", &val);
- if (!rc && val) {
- memcpy(msm_pineapple_dai_links + total_links,
- msm_tdm_dai_links,
- sizeof(msm_tdm_dai_links));
- total_links += ARRAY_SIZE(msm_tdm_dai_links);
- }
- rc = of_property_read_u32(dev->of_node,
- "qcom,ext-disp-audio-rx", &val);
- if (!rc && val) {
- if (!socinfo_get_part_info(PART_DISPLAY)) {
- dev_dbg(dev, "%s(): ext disp audio support present\n",
- __func__);
- memcpy(msm_pineapple_dai_links + total_links,
- ext_disp_be_dai_link,
- sizeof(ext_disp_be_dai_link));
- total_links += ARRAY_SIZE(ext_disp_be_dai_link);
- }
- }
- rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
- if (!rc && val) {
- dev_dbg(dev, "%s(): WCN BT support present\n",
- __func__);
- memcpy(msm_pineapple_dai_links + total_links,
- msm_wcn_be_dai_links,
- sizeof(msm_wcn_be_dai_links));
- total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
- #ifndef CONFIG_AUDIO_BTFM_PROXY
- } else {
- rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm", &val);
- if (!rc && val) {
- dev_dbg(dev, "%s(): WCN BT FM support present\n",
- __func__);
- memcpy(msm_pineapple_dai_links + total_links,
- msm_wcn_btfm_be_dai_links,
- sizeof(msm_wcn_btfm_be_dai_links));
- total_links += ARRAY_SIZE(msm_wcn_btfm_be_dai_links);
- }
- #endif
- }
- dailink = msm_pineapple_dai_links;
- } else if(!strcmp(match->data, "stub_codec")) {
- card = &snd_soc_card_stub_msm;
- memcpy(msm_stub_dai_links,
- msm_stub_be_dai_links,
- sizeof(msm_stub_be_dai_links));
- dailink = msm_stub_dai_links;
- total_links = ARRAY_SIZE(msm_stub_be_dai_links);
- }
- if (card) {
- card->dai_link = dailink;
- card->num_links = total_links;
- if (!strcmp(match->data, "codec"))
- card->late_probe = msm_snd_card_late_probe;
- }
- return card;
- }
- static int msm_int_wsa883x_init(struct snd_soc_pcm_runtime *rtd)
- {
- u8 spkleft_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
- u8 spkright_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
- u8 spkleft_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
- SPKR_L_BOOST, SPKR_L_VI};
- u8 spkright_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
- SPKR_R_BOOST, SPKR_R_VI};
- unsigned int ch_rate[WSA883X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
- SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_1P2MHZ};
- unsigned int ch_mask[WSA883X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
- struct snd_soc_component *component = NULL;
- struct msm_asoc_mach_data *pdata =
- snd_soc_card_get_drvdata(rtd->card);
- if (pdata->wsa_max_devs > 0) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
- if (!component) {
- pr_err("%s: wsa-codec.1 component is NULL\n", __func__);
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
- if (!component) {
- pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa883x_set_channel_map(component, &spkright_ports[0],
- WSA883X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkright_port_types[0]);
- wsa883x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- } else {
- wsa883x_set_channel_map(component, &spkleft_ports[0],
- WSA883X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkleft_port_types[0]);
- wsa883x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- }
- /* If current platform has more than one WSA */
- if (pdata->wsa_max_devs > 1) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
- if (!component) {
- pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa883x_set_channel_map(component, &spkright_ports[0],
- WSA883X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkright_port_types[0]);
- wsa883x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- if (!pdata->dedicated_wsa2) {
- if (pdata->wsa_max_devs > 2) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
- if (!component) {
- pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa883x_set_channel_map(component, &spkleft_ports[0],
- WSA883X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkleft_port_types[0]);
- wsa883x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- if (pdata->wsa_max_devs > 3) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
- if (!component) {
- pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa883x_set_channel_map(component, &spkright_ports[0],
- WSA883X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkright_port_types[0]);
- wsa883x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- }
- msm_common_dai_link_init(rtd);
- return 0;
- }
- static int msm_int_wsa884x_init(struct snd_soc_pcm_runtime *rtd)
- {
- u8 spkleft_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
- u8 spkright_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
- u8 spkleft_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
- SPKR_L_BOOST, PBR, SPKR_L_VI, CPS};
- u8 spkright_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
- SPKR_R_BOOST, PBR, SPKR_R_VI, CPS};
- unsigned int ch_rate[WSA884X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
- SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_48KHZ,
- SWR_CLK_RATE_1P2MHZ, SWR_CLK_RATE_24KHZ};
- unsigned int ch_mask[WSA884X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x1, 0x3, 0x3};
- struct snd_soc_component *component = NULL;
- struct msm_asoc_mach_data *pdata =
- snd_soc_card_get_drvdata(rtd->card);
- if (pdata->wsa_max_devs > 0) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
- if (!component) {
- pr_err("%s: wsa-codec.1 component is NULL\n", __func__);
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
- if (!component) {
- pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa884x_set_channel_map(component, &spkright_ports[0],
- WSA884X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkright_port_types[0]);
- wsa884x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- } else {
- wsa884x_set_channel_map(component, &spkleft_ports[0],
- WSA884X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkleft_port_types[0]);
- wsa884x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- }
- /* If current platform has more than one WSA */
- if (pdata->wsa_max_devs > 1) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
- if (!component) {
- pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa884x_set_channel_map(component, &spkright_ports[0],
- WSA884X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkright_port_types[0]);
- wsa884x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- if (!pdata->dedicated_wsa2) {
- if (pdata->wsa_max_devs > 2) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
- if (!component) {
- pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa884x_set_channel_map(component, &spkleft_ports[0],
- WSA884X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkleft_port_types[0]);
- wsa884x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- if (pdata->wsa_max_devs > 3) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
- if (!component) {
- pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa884x_set_channel_map(component, &spkright_ports[0],
- WSA884X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkright_port_types[0]);
- wsa884x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- }
- msm_common_dai_link_init(rtd);
- return 0;
- }
- static int msm_int_wsa881x_init(struct snd_soc_pcm_runtime *rtd)
- {
- struct msm_asoc_mach_data *pdata =
- snd_soc_card_get_drvdata(rtd->card);
- if (pdata->wsa_max_devs == 0)
- pr_info("%s: WSA is not enabled\n", __func__);
- msm_common_dai_link_init(rtd);
- return 0;
- }
- static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd)
- {
- if (strstr(rtd->card->name, "wsa883x"))
- return msm_int_wsa883x_init(rtd);
- return msm_int_wsa884x_init(rtd);
- }
- static int msm_int_wsa883x_2_init(struct snd_soc_pcm_runtime *rtd)
- {
- u8 spkleft_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
- u8 spkright_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
- u8 spkleft_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
- SPKR_L_BOOST, SPKR_L_VI};
- u8 spkright_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
- SPKR_R_BOOST, SPKR_R_VI};
- unsigned int ch_rate[WSA883X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
- SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_1P2MHZ};
- unsigned int ch_mask[WSA883X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
- struct snd_soc_component *component = NULL;
- struct msm_asoc_mach_data *pdata =
- snd_soc_card_get_drvdata(rtd->card);
- if (pdata->dedicated_wsa2) {
- if (pdata->wsa_max_devs > 2) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
- if (!component) {
- pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa883x_set_channel_map(component, &spkleft_ports[0],
- WSA883X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkleft_port_types[0]);
- wsa883x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- if (pdata->wsa_max_devs > 3) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
- if (!component) {
- pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa883x_set_channel_map(component, &spkright_ports[0],
- WSA883X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkright_port_types[0]);
- wsa883x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- msm_common_dai_link_init(rtd);
- }
- return 0;
- }
- static int msm_int_wsa884x_2_init(struct snd_soc_pcm_runtime *rtd)
- {
- u8 spkleft_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
- u8 spkright_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
- u8 spkleft_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
- SPKR_L_BOOST, PBR, SPKR_L_VI, CPS};
- u8 spkright_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
- SPKR_R_BOOST, PBR, SPKR_R_VI, CPS};
- unsigned int ch_rate[WSA884X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
- SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_48KHZ,
- SWR_CLK_RATE_1P2MHZ, SWR_CLK_RATE_24KHZ};
- unsigned int ch_mask[WSA884X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x1, 0x3, 0x3};
- struct snd_soc_component *component = NULL;
- struct msm_asoc_mach_data *pdata =
- snd_soc_card_get_drvdata(rtd->card);
- if (pdata->dedicated_wsa2) {
- if (pdata->wsa_max_devs > 2) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
- if (!component) {
- pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa884x_set_channel_map(component, &spkleft_ports[0],
- WSA884X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkleft_port_types[0]);
- wsa884x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- if (pdata->wsa_max_devs > 3) {
- component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
- if (!component) {
- pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
- return -EINVAL;
- }
- wsa884x_set_channel_map(component, &spkright_ports[0],
- WSA884X_MAX_SWR_PORTS, &ch_mask[0],
- &ch_rate[0], &spkright_port_types[0]);
- wsa884x_codec_info_create_codec_entry(pdata->codec_root,
- component);
- }
- msm_common_dai_link_init(rtd);
- }
- return 0;
- }
- static int msm_int_wsa2_init(struct snd_soc_pcm_runtime *rtd)
- {
- if (strstr(rtd->card->name, "wsa883x"))
- return msm_int_wsa883x_2_init(rtd);
- return msm_int_wsa884x_2_init(rtd);
- }
- static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
- {
- int codec_variant = -1;
- struct snd_soc_component *component = NULL;
- struct snd_soc_component *lpass_cdc_component = NULL;
- struct snd_soc_dapm_context *dapm = NULL;
- struct snd_info_entry *entry = NULL;
- struct snd_card *card = NULL;
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- struct snd_soc_card *rtd_card = rtd->card;
- #endif
- struct msm_asoc_mach_data *pdata =
- snd_soc_card_get_drvdata(rtd->card);
- int ret = 0;
- lpass_cdc_component = snd_soc_rtdcom_lookup(rtd, "lpass-cdc");
- if (!lpass_cdc_component) {
- pr_err("%s: could not find component for lpass-cdc\n",
- __func__);
- return ret;
- }
- dapm = snd_soc_component_get_dapm(lpass_cdc_component);
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- ret = snd_soc_add_component_controls(lpass_cdc_component, msm_cirrus_snd_controls,
- ARRAY_SIZE(msm_cirrus_snd_controls));
- if (ret < 0) {
- pr_err("%s: add_component_controls failed: %d\n",
- __func__, ret);
- return ret;
- }
- #endif
- snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
- ARRAY_SIZE(msm_int_dapm_widgets));
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- if(!sub_pcb_conn) {
- switch (cirrus_amp_conf) {
- case CS35L43_MONO:
- case CS35L45_MONO:
- snd_soc_dapm_add_routes(&rtd_card->dapm, cirrus_mono_routes,
- ARRAY_SIZE(cirrus_mono_routes));
- break;
- case CS35L43_STEREO:
- case CS35L45_STEREO:
- snd_soc_dapm_add_routes(&rtd_card->dapm, cirrus_stereo_routes,
- ARRAY_SIZE(cirrus_stereo_routes));
- break;
- case CS35L43_QUAD:
- case CS35L45_QUAD:
- snd_soc_dapm_add_routes(&rtd_card->dapm, cirrus_quad_routes,
- ARRAY_SIZE(cirrus_quad_routes));
- break;
- default:
- pr_err("%s: cirrus amp conf is not defined\n",
- __func__);
- break;
- }
- }
- #endif
- snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
- snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
- snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
- snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
- snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
- snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
- snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
- snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
- snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
- snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
- snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
- snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
- snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- snd_soc_dapm_ignore_suspend(dapm, "AMP0 SPK");
- snd_soc_dapm_ignore_suspend(dapm, "AMP1 SPK");
- snd_soc_dapm_ignore_suspend(dapm, "AMP2 SPK");
- snd_soc_dapm_ignore_suspend(dapm, "AMP3 SPK");
- #endif
- lpass_cdc_set_port_map(lpass_cdc_component, ARRAY_SIZE(sm_port_map), sm_port_map);
- card = rtd->card->snd_card;
- if (!pdata->codec_root) {
- entry = msm_snd_info_create_subdir(card->module, "codecs",
- card->proc_root);
- if (!entry) {
- pr_debug("%s: Cannot create codecs module entry\n",
- __func__);
- return ret;
- }
- pdata->codec_root = entry;
- }
- lpass_cdc_info_create_codec_entry(pdata->codec_root, lpass_cdc_component);
- lpass_cdc_register_wake_irq(lpass_cdc_component, false);
- if (pdata->wcd_disabled)
- goto done;
- component = snd_soc_rtdcom_lookup(rtd, WCD939X_DRV_NAME);
- if (!component) {
- component = snd_soc_rtdcom_lookup(rtd, WCD937X_DRV_NAME);
- if (!component) {
- component = snd_soc_rtdcom_lookup(rtd, WCD9378_DRV_NAME);
- if (!component) {
- pr_err("%s component is NULL\n", __func__);
- ret = -EINVAL;
- goto exit;
- } else {
- pdata->wcd_used = WCD9378_DEV_INDEX;
- }
- } else {
- pdata->wcd_used = WCD937X_DEV_INDEX;
- }
- } else {
- pdata->wcd_used = WCD939X_DEV_INDEX;
- }
- dapm = snd_soc_component_get_dapm(component);
- card = component->card->snd_card;
- snd_soc_dapm_ignore_suspend(dapm, "EAR");
- if (pdata->wcd_used != WCD939X_DEV_INDEX)
- snd_soc_dapm_ignore_suspend(dapm, "AUX");
- snd_soc_dapm_ignore_suspend(dapm, "HPHL");
- snd_soc_dapm_ignore_suspend(dapm, "HPHR");
- snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
- snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
- snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
- snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
- snd_soc_dapm_sync(dapm);
- pdata = snd_soc_card_get_drvdata(component->card);
- if (!pdata->codec_root) {
- entry = msm_snd_info_create_subdir(card->module, "codecs",
- card->proc_root);
- if (!entry) {
- dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
- __func__);
- return 0;
- }
- pdata->codec_root = entry;
- }
- if (pdata->wcd_used == WCD937X_DEV_INDEX) {
- wcd937x_info_create_codec_entry(pdata->codec_root, component);
- codec_variant = wcd937x_get_codec_variant(component);
- dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
- } else if (pdata->wcd_used == WCD9378_DEV_INDEX) {
- wcd9378_info_create_codec_entry(pdata->codec_root, component);
- } else {
- wcd939x_info_create_codec_entry(pdata->codec_root, component);
- codec_variant = wcd939x_get_codec_variant(component);
- dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
- #ifdef CONFIG_BOLERO_VER_2P6
- if (codec_variant == WCD9395)
- ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, true);
- else
- ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, false);
- #endif
- }
- if (ret < 0) {
- dev_err_ratelimited(component->dev, "%s: set fir capability failed: %d\n",
- __func__, ret);
- return ret;
- }
- done:
- codec_reg_done = true;
- msm_common_dai_link_init(rtd);
- exit:
- return ret;
- }
- static int pineapple_ssr_enable(struct device *dev, void *data)
- {
- struct platform_device *pdev = to_platform_device(dev);
- struct snd_soc_card *card = platform_get_drvdata(pdev);
- struct snd_soc_pcm_runtime *rtd = NULL, *rtd_wcd = NULL, *rtd_wsa = NULL;
- struct msm_asoc_mach_data *pdata = NULL;
- int ret = 0;
- if (!card) {
- dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
- ret = -EINVAL;
- goto err;
- }
- if (!strcmp(card->name, "pineapple-stub-snd-card")) {
- /* TODO */
- dev_dbg(dev, "%s: TODO \n", __func__);
- }
- snd_card_notify_user(SND_CARD_STATUS_ONLINE);
- dev_err(dev, "%s: setting snd_card to ONLINE\n", __func__);
- pdata = snd_soc_card_get_drvdata(card);
- if (!pdata) {
- dev_dbg(dev, "%s: pdata is NULL \n", __func__);
- goto err;
- }
- rtd_wcd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
- if (!rtd_wcd) {
- dev_dbg(dev,
- "%s: snd_soc_get_pcm_runtime for %s failed!\n",
- __func__, card->dai_link[0]);
- }
- if (pdata->wsa_max_devs > 0) {
- rtd_wsa = snd_soc_get_pcm_runtime(card,
- &card->dai_link[ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)]);
- if (!rtd_wsa) {
- dev_dbg(dev,
- "%s: snd_soc_get_pcm_runtime for %s failed!\n",
- __func__, card->dai_link[ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)]);
- }
- }
- /* set UPD configuration */
- if(!pdata->upd_config.backend_used) {
- dev_dbg(dev,
- "%s: upd- backend_used is NULL\n", __func__);
- goto err;
- }
- if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
- if (!rtd_wsa)
- goto err;
- else
- rtd = rtd_wsa;
- } else if(!strcmp(pdata->upd_config.backend_used, "wcd")) {
- if (!rtd_wcd &&!pdata->wcd_disabled)
- goto err;
- else
- rtd = rtd_wcd;
- } else {
- dev_err_ratelimited(card->dev, "%s: Invalid backend to set UPD config\n",
- __func__);
- goto err;
- }
- msm_set_upd_config(rtd);
- err:
- return ret;
- }
- static void pineapple_ssr_disable(struct device *dev, void *data)
- {
- struct platform_device *pdev = to_platform_device(dev);
- struct snd_soc_card *card = platform_get_drvdata(pdev);
- if (!card) {
- dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
- return;
- }
- dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
- snd_card_notify_user(SND_CARD_STATUS_OFFLINE);
- if (!strcmp(card->name, "pineapple-stub-snd-card")) {
- /* TODO */
- dev_dbg(dev, "%s: TODO \n", __func__);
- }
- }
- static const struct snd_event_ops pineapple_ssr_ops = {
- .enable = pineapple_ssr_enable,
- .disable = pineapple_ssr_disable,
- };
- static int msm_audio_ssr_compare(struct device *dev, void *data)
- {
- struct device_node *node = data;
- dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
- __func__, dev->of_node, node);
- return (dev->of_node && dev->of_node == node);
- }
- static int msm_audio_ssr_register(struct device *dev)
- {
- struct device_node *np = dev->of_node;
- struct snd_event_clients *ssr_clients = NULL;
- struct device_node *node = NULL;
- int ret = 0;
- int i = 0;
- for (i = 0; ; i++) {
- node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
- if (!node)
- break;
- snd_event_mstr_add_client(&ssr_clients,
- msm_audio_ssr_compare, node);
- }
- ret = snd_event_master_register(dev, &pineapple_ssr_ops,
- ssr_clients, NULL);
- if (!ret)
- snd_event_notify(dev, SND_EVENT_UP);
- return ret;
- }
- struct msm_common_pdata *msm_common_get_pdata(struct snd_soc_card *card)
- {
- struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
- if (!pdata)
- return NULL;
- return pdata->common_pdata;
- }
- void msm_common_set_pdata(struct snd_soc_card *card,
- struct msm_common_pdata *common_pdata)
- {
- struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
- if (!pdata)
- return;
- pdata->common_pdata = common_pdata;
- }
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- /*
- * update codec name and dai name in runtime
- * to support multiple cirrus amp with one binary.
- */
- static void update_cirrus_dai_link(struct device *dev)
- {
- struct snd_soc_dai_link_component cirrus_dai_link[] = {
- { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", },
- { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", },
- { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", },
- { .name = "snd-soc-dummy", .dai_name = "snd-soc-dummy-dai", },
- };
- struct snd_soc_dai_link *dai_link = msm_tdm_dai_links;
- const char *codec_name = "cirrus-codec-name";
- const char *codec_dai_name = "cirrus-codec-dai-name";
- int i, ret = 0;
- #if IS_ENABLED(CONFIG_SND_SOC_SAMSUNG_AUDIO)
- if (defer_count > MAX_DEFER_COUNT)
- return;
- #endif
- dev_info(dev, "%s:\n", __func__);
- for (i = 0; i < cirrus_amp_count; i++) {
- ret = of_property_read_string_index(dev->of_node,
- codec_name, i, &cirrus_dai_link[i].name);
- if (ret) {
- dev_err(dev, "Property '%s' does not exist(%d).\n",
- codec_name, ret);
- return;
- }
- ret = of_property_read_string_index(dev->of_node,
- codec_dai_name, i, &cirrus_dai_link[i].dai_name);
- if (ret) {
- dev_err(dev, "Property '%s' does not exist(%d).\n",
- codec_dai_name, ret);
- return;
- }
- /* 0 : Rx, 1 : Tx */
- dai_link[0].codecs[i].name = cirrus_dai_link[i].name;
- dai_link[1].codecs[i].name = cirrus_dai_link[i].name;
- dai_link[0].codecs[i].dai_name = cirrus_dai_link[i].dai_name;
- dai_link[1].codecs[i].dai_name = cirrus_dai_link[i].dai_name;
- }
- dai_link[0].num_codecs = dai_link[1].num_codecs = cirrus_amp_count;
- }
- #endif
- #if IS_ENABLED(CONFIG_SND_SOC_SAMSUNG_AUDIO)
- /*
- * change codec component to dummy in dailinks
- * when soundcard does not registered several times.
- */
- static void change_snd_card_dailinks(struct snd_soc_card *card)
- {
- int i, j = 0;
- struct snd_soc_dai *dai = NULL;
- sdp_boot_print("%s\n", __func__);
- for (i = 0; i < card->num_links; i++) {
- for (j = 0; j < card->dai_link[i].num_codecs; j++) {
- dai = snd_soc_find_dai(&card->dai_link[i].codecs[j]);
- if(!dai) {
- sdp_boot_print("%s: CANNOT find dai %s\n",
- __func__, card->dai_link[i].codecs[j].name);
- card->dai_link[i].codecs[j].name =
- dummy_compononet.name;
- card->dai_link[i].codecs[j].dai_name =
- dummy_compononet.dai_name;
- card->dai_link[i].init = NULL;
- pr_info("%s: Change codec_dai of %s to DUMMY\n",
- __func__, card->dai_link[i].name);
- }
- }
- }
- return;
- }
- #endif
- #if IS_ENABLED(CONFIG_SND_SOC_SAMSUNG_AUDIO)
- static int get_audio_amp_ready(enum amp_id id)
- {
- #if defined(CONFIG_SND_SOC_TAS25XX)
- int ret = 0;
- ret = tas25xx_get_state(id);
- if (ret > 0) /* amp first i2c successful or amp fully initialized for playback */
- return AMP_INIT_SUCCESS;
- else
- return AMP_INIT_FAIL;
- #endif
- return AMP_CHECK_NOT_SUPPORT;
- }
- #endif
- static int msm_asoc_parse_soundcard_name(struct platform_device *pdev,
- struct snd_soc_card *card)
- {
- struct nvmem_cell *cell = NULL;
- size_t len = 0;
- u32 *buf = NULL;
- u32 adsp_var_idx = 0;
- int ret = 0;
- /* get adsp variant idx */
- cell = nvmem_cell_get(&pdev->dev, "adsp_variant");
- if (IS_ERR_OR_NULL(cell)) {
- dev_dbg(&pdev->dev, "%s: FAILED to get nvmem cell\n", __func__);
- goto parse;
- }
- buf = nvmem_cell_read(cell, &len);
- nvmem_cell_put(cell);
- if (IS_ERR_OR_NULL(buf)) {
- dev_dbg(&pdev->dev, "%s: FAILED to read nvmem cell\n", __func__);
- goto parse;
- }
- if (len <= 0 || len > sizeof(u32)) {
- dev_dbg(&pdev->dev, "%s: nvmem cell length out of range: %d\n",
- __func__, len);
- kfree(buf);
- goto parse;
- }
- memcpy(&adsp_var_idx, buf, len);
- kfree(buf);
- parse:
- if (adsp_var_idx)
- ret = snd_soc_of_parse_card_name(card, "qcom,sku-model");
- else
- ret = snd_soc_of_parse_card_name(card, "qcom,model");
- if (ret)
- dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
- __func__, ret);
- return ret;
- }
- static int msm_asoc_machine_probe(struct platform_device *pdev)
- {
- struct snd_soc_card *card = NULL;
- struct msm_asoc_mach_data *pdata = NULL;
- int ret = 0;
- struct clk *lpass_audio_hw_vote = NULL;
- const struct of_device_id *match;
- pr_info("%s enter\n", __func__);
- if (!pdev->dev.of_node) {
- dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
- return -EINVAL;
- }
- pdata = devm_kzalloc(&pdev->dev,
- sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
- if (!pdata)
- return -ENOMEM;
- of_property_read_u32(pdev->dev.of_node,
- "qcom,wcd-disabled",
- &pdata->wcd_disabled);
- /* Get maximum WSA device count for this platform */
- ret = of_property_read_u32(pdev->dev.of_node,
- "qcom,wsa-max-devs", &pdata->wsa_max_devs);
- if (ret) {
- dev_info(&pdev->dev,
- "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
- __func__, pdev->dev.of_node->full_name, ret);
- pdata->wsa_max_devs = 0;
- }
- /* Check if WSA2 Backends were used for dedicated usecase */
- pdata->dedicated_wsa2 = of_find_property(pdev->dev.of_node,
- "qcom,dedicated-wsa2", NULL);
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- ret = of_property_read_u32(pdev->dev.of_node,
- "cirrus-amp-conf", &cirrus_amp_conf);
- if (ret) {
- dev_dbg(&pdev->dev,
- "%s: codec_conf property missing in DT %s, ret = %d\n",
- __func__, pdev->dev.of_node->full_name, ret);
- cirrus_amp_conf = 0x32;
- }
- cirrus_amp_count = cirrus_amp_conf & 0x0F;
- dev_info(&pdev->dev, "%s: cirrus amp conf=0x%x\n",
- __func__, cirrus_amp_conf);
- if (cirrus_amp_count > 0 && cirrus_amp_count < 5)
- update_cirrus_dai_link(&pdev->dev);
- #endif
- card = populate_snd_card_dailinks(&pdev->dev, pdata->wsa_max_devs);
- if (!card) {
- dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
- ret = -EINVAL;
- goto err;
- }
- match = of_match_node(pineapple_asoc_machine_of_match, pdev->dev.of_node);
- if (!match) {
- dev_err(&pdev->dev, "%s: No DT match found for sound card\n",
- __func__);
- ret = -EINVAL;
- goto err;
- }
- card->dev = &pdev->dev;
- platform_set_drvdata(pdev, card);
- snd_soc_card_set_drvdata(card, pdata);
- ret = msm_asoc_parse_soundcard_name(pdev, card);
- if (ret) {
- dev_err(&pdev->dev, "%s: parse soundcard name failed, err:%d\n",
- __func__, ret);
- goto err;
- }
- if(!strcmp(match->data, "codec")) {
- ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
- if (ret) {
- dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
- __func__, ret);
- goto err;
- }
- }
- ret = msm_populate_dai_link_component_of_node(card);
- if (ret) {
- ret = -EPROBE_DEFER;
- goto err;
- }
- /* parse upd configuration */
- msm_parse_upd_configuration(pdev, pdata);
- //#ifdef CONFIG_COMMON_AMP_CIRRUS
- #if 1
- switch (cirrus_amp_conf) {
- case CS35L43_MONO:
- card->codec_conf = cs35l43_mono_conf;
- card->num_configs = ARRAY_SIZE(cs35l43_mono_conf);
- break;
- case CS35L43_STEREO:
- card->codec_conf = cs35l43_stereo_conf;
- card->num_configs = ARRAY_SIZE(cs35l43_stereo_conf);
- break;
- case CS35L43_QUAD:
- card->codec_conf = cs35l43_quad_conf;
- card->num_configs = ARRAY_SIZE(cs35l43_quad_conf);
- break;
- case CS35L45_MONO:
- card->codec_conf = cs35l45_mono_conf;
- card->num_configs = ARRAY_SIZE(cs35l45_mono_conf);
- break;
- case CS35L45_STEREO:
- card->codec_conf = cs35l45_stereo_conf;
- card->num_configs = ARRAY_SIZE(cs35l45_stereo_conf);
- break;
- case CS35L45_QUAD:
- card->codec_conf = cs35l45_quad_conf;
- card->num_configs = ARRAY_SIZE(cs35l45_quad_conf);
- break;
- default:
- dev_err(&pdev->dev, "%s: cirrus amp conf is not defined\n",
- __func__);
- break;
- }
- #endif
- #if IS_ENABLED(CONFIG_SND_SOC_SAMSUNG_AUDIO)
- if (++defer_count > MAX_DEFER_COUNT)
- change_snd_card_dailinks(card);
- #endif
- ret = devm_snd_soc_register_card(&pdev->dev, card);
- if (ret == -EPROBE_DEFER) {
- if (codec_reg_done)
- ret = -EINVAL;
- goto err;
- } else if (ret) {
- dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
- __func__, ret);
- goto err;
- }
- dev_info(&pdev->dev, "%s: Sound card %s registered\n",
- __func__, card->name);
- if (wcd_mbhc_cfg.enable_usbc_analog ||
- wcd_mbhc_cfg.usbss_hsj_connect_enable)
- wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
- pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
- "fsa4480-i2c-handle", 0);
- if (!pdata->fsa_handle)
- dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
- "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
- pdata->wcd_usbss_handle = of_parse_phandle(pdev->dev.of_node,
- "wcd939x-i2c-handle", 0);
- if (!pdata->wcd_usbss_handle)
- dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
- "wcd939x-i2c-handle", pdev->dev.of_node->full_name);
- pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
- "qcom,cdc-dmic01-gpios",
- 0);
- pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
- "qcom,cdc-dmic23-gpios",
- 0);
- pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
- "qcom,cdc-dmic45-gpios",
- 0);
- pdata->dmic67_gpio_p = of_parse_phandle(pdev->dev.of_node,
- "qcom,cdc-dmic67-gpios",
- 0);
- if (pdata->dmic01_gpio_p)
- msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
- if (pdata->dmic23_gpio_p)
- msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
- if (pdata->dmic45_gpio_p)
- msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
- if (pdata->dmic67_gpio_p)
- msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic67_gpio_p, false);
- msm_common_snd_init(pdev, card);
- /* Register LPASS audio hw vote */
- lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
- if (IS_ERR(lpass_audio_hw_vote)) {
- ret = PTR_ERR(lpass_audio_hw_vote);
- dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
- __func__, "lpass_audio_hw_vote", ret);
- lpass_audio_hw_vote = NULL;
- ret = 0;
- }
- pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
- pdata->core_audio_vote_count = 0;
- ret = msm_audio_ssr_register(&pdev->dev);
- if (ret)
- pr_err("%s: Registration with SND event FWK failed ret = %d\n",
- __func__, ret);
- is_initial_boot = true;
- #if IS_ENABLED(CONFIG_SND_SOC_SAMSUNG_AUDIO)
- audio_register_ready_cb(get_audio_amp_ready);
- #endif
- /* change card status to ONLINE */
- dev_err(&pdev->dev, "%s: setting snd_card to ONLINE\n", __func__);
- snd_card_set_card_status(SND_CARD_STATUS_ONLINE);
- sdp_boot_print("%s: snd_card is ONLINE\n", __func__);
- return 0;
- err:
- devm_kfree(&pdev->dev, pdata);
- return ret;
- }
- static int msm_asoc_machine_remove(struct platform_device *pdev)
- {
- struct snd_soc_card *card = platform_get_drvdata(pdev);
- struct msm_asoc_mach_data *pdata = NULL;
- struct msm_common_pdata *common_pdata = NULL;
- pr_info("%s: Enter", __func__);
- if (card)
- pdata = snd_soc_card_get_drvdata(card);
- if (pdata)
- common_pdata = pdata->common_pdata;
- msm_common_snd_deinit(common_pdata);
- snd_event_master_deregister(&pdev->dev);
- snd_soc_unregister_card(card);
- return 0;
- }
- static struct platform_driver pineapple_asoc_machine_driver = {
- .driver = {
- .name = DRV_NAME,
- .owner = THIS_MODULE,
- .pm = &snd_soc_pm_ops,
- .of_match_table = pineapple_asoc_machine_of_match,
- .suppress_bind_attrs = true,
- },
- .probe = msm_asoc_machine_probe,
- .remove = msm_asoc_machine_remove,
- };
- static int __init msm_asoc_machine_init(void)
- {
- snd_card_sysfs_init();
- pr_info("%s: Enter", __func__);
- return platform_driver_register(&pineapple_asoc_machine_driver);
- }
- module_init(msm_asoc_machine_init);
- static void __exit msm_asoc_machine_exit(void)
- {
- pr_info("%s: Enter", __func__);
- platform_driver_unregister(&pineapple_asoc_machine_driver);
- }
- module_exit(msm_asoc_machine_exit);
- #ifndef CONFIG_AUDIO_BTFM_PROXY
- MODULE_SOFTDEP("pre: bt_fm_slim");
- #else
- MODULE_SOFTDEP("pre: btfmcodec");
- #endif
- MODULE_DESCRIPTION("ALSA SoC msm");
- MODULE_LICENSE("GPL v2");
- MODULE_ALIAS("platform:" DRV_NAME);
- MODULE_DEVICE_TABLE(of, pineapple_asoc_machine_of_match);
|