lahaina.c 218 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/clk.h>
  6. #include <linux/delay.h>
  7. #include <linux/gpio.h>
  8. #include <linux/of_gpio.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/slab.h>
  11. #include <linux/io.h>
  12. #include <linux/module.h>
  13. #include <linux/input.h>
  14. #include <linux/of_device.h>
  15. #include <linux/soc/qcom/fsa4480-i2c.h>
  16. #include <sound/core.h>
  17. #include <sound/soc.h>
  18. #include <sound/soc-dapm.h>
  19. #include <sound/pcm.h>
  20. #include <sound/pcm_params.h>
  21. #include <sound/info.h>
  22. #include <soc/snd_event.h>
  23. #include <dsp/audio_notifier.h>
  24. #include <soc/swr-common.h>
  25. #include <dsp/q6afe-v2.h>
  26. #include <dsp/q6core.h>
  27. #include <soc/soundwire.h>
  28. #include "device_event.h"
  29. #include "msm-pcm-routing-v2.h"
  30. #include "asoc/msm-cdc-pinctrl.h"
  31. #include "asoc/wcd-mbhc-v2.h"
  32. #include "codecs/wcd938x/wcd938x-mbhc.h"
  33. #include "codecs/wsa883x/wsa883x.h"
  34. #include "codecs/wcd938x/wcd938x.h"
  35. #include "codecs/bolero/bolero-cdc.h"
  36. #include <dt-bindings/sound/audio-codec-port-types.h>
  37. #include "codecs/bolero/wsa-macro.h"
  38. #include "lahaina-port-config.h"
  39. #include "msm_dailink.h"
  40. #define DRV_NAME "lahaina-asoc-snd"
  41. #define __CHIPSET__ "LAHAINA "
  42. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  43. #define SAMPLING_RATE_8KHZ 8000
  44. #define SAMPLING_RATE_11P025KHZ 11025
  45. #define SAMPLING_RATE_16KHZ 16000
  46. #define SAMPLING_RATE_22P05KHZ 22050
  47. #define SAMPLING_RATE_32KHZ 32000
  48. #define SAMPLING_RATE_44P1KHZ 44100
  49. #define SAMPLING_RATE_48KHZ 48000
  50. #define SAMPLING_RATE_88P2KHZ 88200
  51. #define SAMPLING_RATE_96KHZ 96000
  52. #define SAMPLING_RATE_176P4KHZ 176400
  53. #define SAMPLING_RATE_192KHZ 192000
  54. #define SAMPLING_RATE_352P8KHZ 352800
  55. #define SAMPLING_RATE_384KHZ 384000
  56. #define IS_FRACTIONAL(x) \
  57. ((x == SAMPLING_RATE_11P025KHZ) || (x == SAMPLING_RATE_22P05KHZ) || \
  58. (x == SAMPLING_RATE_44P1KHZ) || (x == SAMPLING_RATE_88P2KHZ) || \
  59. (x == SAMPLING_RATE_176P4KHZ) || (x == SAMPLING_RATE_352P8KHZ))
  60. #define IS_MSM_INTERFACE_MI2S(x) \
  61. ((x == PRIM_MI2S) || (x == SEC_MI2S) || (x == TERT_MI2S))
  62. #define WCD9XXX_MBHC_DEF_RLOADS 5
  63. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  64. #define CODEC_EXT_CLK_RATE 9600000
  65. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  66. #define DEV_NAME_STR_LEN 32
  67. #define WCD_MBHC_HS_V_MAX 1600
  68. #define TDM_CHANNEL_MAX 8
  69. #define DEV_NAME_STR_LEN 32
  70. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  71. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  72. #define WCN_CDC_SLIM_RX_CH_MAX 2
  73. #define WCN_CDC_SLIM_TX_CH_MAX 2
  74. #define WCN_CDC_SLIM_TX_CH_MAX_LITO 3
  75. enum {
  76. RX_PATH = 0,
  77. TX_PATH,
  78. MAX_PATH,
  79. };
  80. enum {
  81. TDM_0 = 0,
  82. TDM_1,
  83. TDM_2,
  84. TDM_3,
  85. TDM_4,
  86. TDM_5,
  87. TDM_6,
  88. TDM_7,
  89. TDM_PORT_MAX,
  90. };
  91. #define TDM_MAX_SLOTS 8
  92. #define TDM_SLOT_WIDTH_BITS 32
  93. enum {
  94. TDM_PRI = 0,
  95. TDM_SEC,
  96. TDM_TERT,
  97. TDM_QUAT,
  98. TDM_QUIN,
  99. TDM_SEN,
  100. TDM_INTERFACE_MAX,
  101. };
  102. enum {
  103. PRIM_AUX_PCM = 0,
  104. SEC_AUX_PCM,
  105. TERT_AUX_PCM,
  106. QUAT_AUX_PCM,
  107. QUIN_AUX_PCM,
  108. SEN_AUX_PCM,
  109. AUX_PCM_MAX,
  110. };
  111. enum {
  112. PRIM_MI2S = 0,
  113. SEC_MI2S,
  114. TERT_MI2S,
  115. QUAT_MI2S,
  116. QUIN_MI2S,
  117. SEN_MI2S,
  118. MI2S_MAX,
  119. };
  120. enum {
  121. WSA_CDC_DMA_RX_0 = 0,
  122. WSA_CDC_DMA_RX_1,
  123. RX_CDC_DMA_RX_0,
  124. RX_CDC_DMA_RX_1,
  125. RX_CDC_DMA_RX_2,
  126. RX_CDC_DMA_RX_3,
  127. RX_CDC_DMA_RX_5,
  128. CDC_DMA_RX_MAX,
  129. };
  130. enum {
  131. WSA_CDC_DMA_TX_0 = 0,
  132. WSA_CDC_DMA_TX_1,
  133. WSA_CDC_DMA_TX_2,
  134. TX_CDC_DMA_TX_0,
  135. TX_CDC_DMA_TX_3,
  136. TX_CDC_DMA_TX_4,
  137. VA_CDC_DMA_TX_0,
  138. VA_CDC_DMA_TX_1,
  139. VA_CDC_DMA_TX_2,
  140. CDC_DMA_TX_MAX,
  141. };
  142. enum {
  143. SLIM_RX_7 = 0,
  144. SLIM_RX_MAX,
  145. };
  146. enum {
  147. SLIM_TX_7 = 0,
  148. SLIM_TX_8,
  149. SLIM_TX_MAX,
  150. };
  151. enum {
  152. AFE_LOOPBACK_TX_IDX = 0,
  153. AFE_LOOPBACK_TX_IDX_MAX,
  154. };
  155. struct msm_asoc_mach_data {
  156. struct snd_info_entry *codec_root;
  157. int usbc_en2_gpio; /* used by gpio driver API */
  158. int lito_v2_enabled;
  159. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  160. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  161. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  162. struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
  163. atomic_t mi2s_gpio_ref_count[MI2S_MAX]; /* used by pinctrl API */
  164. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  165. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  166. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  167. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  168. bool is_afe_config_done;
  169. struct device_node *fsa_handle;
  170. struct clk *lpass_audio_hw_vote;
  171. int core_audio_vote_count;
  172. u32 wsa_max_devs;
  173. };
  174. struct tdm_port {
  175. u32 mode;
  176. u32 channel;
  177. };
  178. struct tdm_dev_config {
  179. unsigned int tdm_slot_offset[TDM_MAX_SLOTS];
  180. };
  181. enum {
  182. EXT_DISP_RX_IDX_DP = 0,
  183. EXT_DISP_RX_IDX_DP1,
  184. EXT_DISP_RX_IDX_MAX,
  185. };
  186. struct dev_config {
  187. u32 sample_rate;
  188. u32 bit_format;
  189. u32 channels;
  190. };
  191. /* Default configuration of slimbus channels */
  192. static struct dev_config slim_rx_cfg[] = {
  193. [SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  194. };
  195. static struct dev_config slim_tx_cfg[] = {
  196. [SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  197. [SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  198. };
  199. /* Default configuration of external display BE */
  200. static struct dev_config ext_disp_rx_cfg[] = {
  201. [EXT_DISP_RX_IDX_DP] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  202. [EXT_DISP_RX_IDX_DP1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  203. };
  204. static struct dev_config usb_rx_cfg = {
  205. .sample_rate = SAMPLING_RATE_48KHZ,
  206. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  207. .channels = 2,
  208. };
  209. static struct dev_config usb_tx_cfg = {
  210. .sample_rate = SAMPLING_RATE_48KHZ,
  211. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  212. .channels = 1,
  213. };
  214. static struct dev_config proxy_rx_cfg = {
  215. .sample_rate = SAMPLING_RATE_48KHZ,
  216. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  217. .channels = 2,
  218. };
  219. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  220. {
  221. AFE_API_VERSION_I2S_CONFIG,
  222. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  223. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  224. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  225. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  226. 0,
  227. },
  228. {
  229. AFE_API_VERSION_I2S_CONFIG,
  230. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  231. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  232. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  233. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  234. 0,
  235. },
  236. {
  237. AFE_API_VERSION_I2S_CONFIG,
  238. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  239. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  240. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  241. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  242. 0,
  243. },
  244. {
  245. AFE_API_VERSION_I2S_CONFIG,
  246. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
  247. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  248. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  249. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  250. 0,
  251. },
  252. {
  253. AFE_API_VERSION_I2S_CONFIG,
  254. Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT,
  255. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  256. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  257. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  258. 0,
  259. },
  260. {
  261. AFE_API_VERSION_I2S_CONFIG,
  262. Q6AFE_LPASS_CLK_ID_SEN_MI2S_IBIT,
  263. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  264. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  265. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  266. 0,
  267. },
  268. };
  269. struct mi2s_conf {
  270. struct mutex lock;
  271. u32 ref_cnt;
  272. u32 msm_is_mi2s_master;
  273. };
  274. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  275. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  276. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  277. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  278. };
  279. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  280. /* Default configuration of TDM channels */
  281. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  282. { /* PRI TDM */
  283. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  284. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  285. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  286. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  287. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  288. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  289. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  290. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  291. },
  292. { /* SEC TDM */
  293. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  294. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  295. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  296. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  297. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  298. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  299. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  300. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  301. },
  302. { /* TERT TDM */
  303. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  304. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  305. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  306. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  307. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  308. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  309. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  310. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  311. },
  312. { /* QUAT TDM */
  313. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  314. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  315. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  316. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  317. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  318. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  319. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  320. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  321. },
  322. { /* QUIN TDM */
  323. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  324. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  325. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  326. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  327. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  328. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  329. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  330. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  331. },
  332. { /* SEN TDM */
  333. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  334. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  335. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  336. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  337. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  338. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  339. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  340. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  341. },
  342. };
  343. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  344. { /* PRI TDM */
  345. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  346. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  347. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  348. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  349. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  350. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  351. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  352. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  353. },
  354. { /* SEC TDM */
  355. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  356. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  357. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  358. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  359. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  360. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  361. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  362. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  363. },
  364. { /* TERT TDM */
  365. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  366. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  367. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  368. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  369. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  370. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  371. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  372. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  373. },
  374. { /* QUAT TDM */
  375. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  376. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  377. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  378. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  379. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  380. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  381. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  382. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  383. },
  384. { /* QUIN TDM */
  385. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  386. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  387. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  388. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  389. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  390. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  391. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  392. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  393. },
  394. { /* SEN TDM */
  395. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  396. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  397. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  398. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  399. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  400. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  401. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  402. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  403. },
  404. };
  405. /* Default configuration of AUX PCM channels */
  406. static struct dev_config aux_pcm_rx_cfg[] = {
  407. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  408. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  409. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  410. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  411. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  412. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  413. };
  414. static struct dev_config aux_pcm_tx_cfg[] = {
  415. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  416. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  417. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  418. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  419. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  420. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  421. };
  422. /* Default configuration of MI2S channels */
  423. static struct dev_config mi2s_rx_cfg[] = {
  424. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  425. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  426. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  427. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  428. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  429. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  430. };
  431. static struct dev_config mi2s_tx_cfg[] = {
  432. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  433. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  434. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  435. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  436. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  437. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  438. };
  439. static struct tdm_dev_config pri_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  440. { /* PRI TDM */
  441. { {0, 4, 0xFFFF} }, /* RX_0 */
  442. { {8, 12, 0xFFFF} }, /* RX_1 */
  443. { {16, 20, 0xFFFF} }, /* RX_2 */
  444. { {24, 28, 0xFFFF} }, /* RX_3 */
  445. { {0xFFFF} }, /* RX_4 */
  446. { {0xFFFF} }, /* RX_5 */
  447. { {0xFFFF} }, /* RX_6 */
  448. { {0xFFFF} }, /* RX_7 */
  449. },
  450. {
  451. { {0, 4, 8, 12, 0xFFFF} }, /* TX_0 */
  452. { {8, 12, 0xFFFF} }, /* TX_1 */
  453. { {16, 20, 0xFFFF} }, /* TX_2 */
  454. { {24, 28, 0xFFFF} }, /* TX_3 */
  455. { {0xFFFF} }, /* TX_4 */
  456. { {0xFFFF} }, /* TX_5 */
  457. { {0xFFFF} }, /* TX_6 */
  458. { {0xFFFF} }, /* TX_7 */
  459. },
  460. };
  461. static struct tdm_dev_config sec_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  462. { /* SEC TDM */
  463. { {0, 4, 0xFFFF} }, /* RX_0 */
  464. { {8, 12, 0xFFFF} }, /* RX_1 */
  465. { {16, 20, 0xFFFF} }, /* RX_2 */
  466. { {24, 28, 0xFFFF} }, /* RX_3 */
  467. { {0xFFFF} }, /* RX_4 */
  468. { {0xFFFF} }, /* RX_5 */
  469. { {0xFFFF} }, /* RX_6 */
  470. { {0xFFFF} }, /* RX_7 */
  471. },
  472. {
  473. { {0, 4, 0xFFFF} }, /* TX_0 */
  474. { {8, 12, 0xFFFF} }, /* TX_1 */
  475. { {16, 20, 0xFFFF} }, /* TX_2 */
  476. { {24, 28, 0xFFFF} }, /* TX_3 */
  477. { {0xFFFF} }, /* TX_4 */
  478. { {0xFFFF} }, /* TX_5 */
  479. { {0xFFFF} }, /* TX_6 */
  480. { {0xFFFF} }, /* TX_7 */
  481. },
  482. };
  483. static struct tdm_dev_config tert_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  484. { /* TERT TDM */
  485. { {0, 4, 0xFFFF} }, /* RX_0 */
  486. { {8, 12, 0xFFFF} }, /* RX_1 */
  487. { {16, 20, 0xFFFF} }, /* RX_2 */
  488. { {24, 28, 0xFFFF} }, /* RX_3 */
  489. { {0xFFFF} }, /* RX_4 */
  490. { {0xFFFF} }, /* RX_5 */
  491. { {0xFFFF} }, /* RX_6 */
  492. { {0xFFFF} }, /* RX_7 */
  493. },
  494. {
  495. { {0, 4, 0xFFFF} }, /* TX_0 */
  496. { {8, 12, 0xFFFF} }, /* TX_1 */
  497. { {16, 20, 0xFFFF} }, /* TX_2 */
  498. { {24, 28, 0xFFFF} }, /* TX_3 */
  499. { {0xFFFF} }, /* TX_4 */
  500. { {0xFFFF} }, /* TX_5 */
  501. { {0xFFFF} }, /* TX_6 */
  502. { {0xFFFF} }, /* TX_7 */
  503. },
  504. };
  505. static struct tdm_dev_config quat_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  506. { /* QUAT TDM */
  507. { {0, 4, 0xFFFF} }, /* RX_0 */
  508. { {8, 12, 0xFFFF} }, /* RX_1 */
  509. { {16, 20, 0xFFFF} }, /* RX_2 */
  510. { {24, 28, 0xFFFF} }, /* RX_3 */
  511. { {0xFFFF} }, /* RX_4 */
  512. { {0xFFFF} }, /* RX_5 */
  513. { {0xFFFF} }, /* RX_6 */
  514. { {0xFFFF} }, /* RX_7 */
  515. },
  516. {
  517. { {0, 4, 0xFFFF} }, /* TX_0 */
  518. { {8, 12, 0xFFFF} }, /* TX_1 */
  519. { {16, 20, 0xFFFF} }, /* TX_2 */
  520. { {24, 28, 0xFFFF} }, /* TX_3 */
  521. { {0xFFFF} }, /* TX_4 */
  522. { {0xFFFF} }, /* TX_5 */
  523. { {0xFFFF} }, /* TX_6 */
  524. { {0xFFFF} }, /* TX_7 */
  525. },
  526. };
  527. static struct tdm_dev_config quin_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  528. { /* QUIN TDM */
  529. { {0, 4, 0xFFFF} }, /* RX_0 */
  530. { {8, 12, 0xFFFF} }, /* RX_1 */
  531. { {16, 20, 0xFFFF} }, /* RX_2 */
  532. { {24, 28, 0xFFFF} }, /* RX_3 */
  533. { {0xFFFF} }, /* RX_4 */
  534. { {0xFFFF} }, /* RX_5 */
  535. { {0xFFFF} }, /* RX_6 */
  536. { {0xFFFF} }, /* RX_7 */
  537. },
  538. {
  539. { {0, 4, 0xFFFF} }, /* TX_0 */
  540. { {8, 12, 0xFFFF} }, /* TX_1 */
  541. { {16, 20, 0xFFFF} }, /* TX_2 */
  542. { {24, 28, 0xFFFF} }, /* TX_3 */
  543. { {0xFFFF} }, /* TX_4 */
  544. { {0xFFFF} }, /* TX_5 */
  545. { {0xFFFF} }, /* TX_6 */
  546. { {0xFFFF} }, /* TX_7 */
  547. },
  548. };
  549. static struct tdm_dev_config sen_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  550. { /* SEN TDM */
  551. { {0, 4, 0xFFFF} }, /* RX_0 */
  552. { {8, 12, 0xFFFF} }, /* RX_1 */
  553. { {16, 20, 0xFFFF} }, /* RX_2 */
  554. { {24, 28, 0xFFFF} }, /* RX_3 */
  555. { {0xFFFF} }, /* RX_4 */
  556. { {0xFFFF} }, /* RX_5 */
  557. { {0xFFFF} }, /* RX_6 */
  558. { {0xFFFF} }, /* RX_7 */
  559. },
  560. {
  561. { {0, 4, 0xFFFF} }, /* TX_0 */
  562. { {8, 12, 0xFFFF} }, /* TX_1 */
  563. { {16, 20, 0xFFFF} }, /* TX_2 */
  564. { {24, 28, 0xFFFF} }, /* TX_3 */
  565. { {0xFFFF} }, /* TX_4 */
  566. { {0xFFFF} }, /* TX_5 */
  567. { {0xFFFF} }, /* TX_6 */
  568. { {0xFFFF} }, /* TX_7 */
  569. },
  570. };
  571. static void *tdm_cfg[TDM_INTERFACE_MAX] = {
  572. pri_tdm_dev_config,
  573. sec_tdm_dev_config,
  574. tert_tdm_dev_config,
  575. quat_tdm_dev_config,
  576. quin_tdm_dev_config,
  577. sen_tdm_dev_config,
  578. };
  579. /* Default configuration of Codec DMA Interface RX */
  580. static struct dev_config cdc_dma_rx_cfg[] = {
  581. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  582. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  583. [RX_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  584. [RX_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  585. [RX_CDC_DMA_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  586. [RX_CDC_DMA_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  587. [RX_CDC_DMA_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  588. };
  589. /* Default configuration of Codec DMA Interface TX */
  590. static struct dev_config cdc_dma_tx_cfg[] = {
  591. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  592. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  593. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  594. [TX_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  595. [TX_CDC_DMA_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  596. [TX_CDC_DMA_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  597. [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  598. [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  599. [VA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  600. };
  601. static struct dev_config afe_loopback_tx_cfg[] = {
  602. [AFE_LOOPBACK_TX_IDX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  603. };
  604. static int msm_vi_feed_tx_ch = 2;
  605. static const char *const vi_feed_ch_text[] = {"One", "Two"};
  606. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  607. "S32_LE"};
  608. static char const *cdc80_bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE"};
  609. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  610. "Six", "Seven", "Eight"};
  611. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  612. "KHZ_16", "KHZ_22P05",
  613. "KHZ_32", "KHZ_44P1", "KHZ_48",
  614. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  615. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  616. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  617. "Five", "Six", "Seven",
  618. "Eight"};
  619. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  620. "KHZ_48", "KHZ_176P4",
  621. "KHZ_352P8"};
  622. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  623. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  624. "Five", "Six", "Seven", "Eight"};
  625. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  626. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  627. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  628. "KHZ_48", "KHZ_88P2", "KHZ_96",
  629. "KHZ_176P4", "KHZ_192","KHZ_352P8",
  630. "KHZ_384"};
  631. static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
  632. "Five", "Six", "Seven",
  633. "Eight"};
  634. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  635. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  636. "Five", "Six", "Seven",
  637. "Eight"};
  638. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  639. "KHZ_16", "KHZ_22P05",
  640. "KHZ_32", "KHZ_44P1", "KHZ_48",
  641. "KHZ_88P2", "KHZ_96",
  642. "KHZ_176P4", "KHZ_192",
  643. "KHZ_352P8", "KHZ_384"};
  644. static char const *cdc80_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  645. "KHZ_16", "KHZ_22P05",
  646. "KHZ_32", "KHZ_44P1", "KHZ_48",
  647. "KHZ_88P2", "KHZ_96",
  648. "KHZ_176P4", "KHZ_192"};
  649. static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
  650. "S24_3LE"};
  651. static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  652. "KHZ_192", "KHZ_32", "KHZ_44P1",
  653. "KHZ_88P2", "KHZ_176P4"};
  654. static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  655. "KHZ_44P1", "KHZ_48",
  656. "KHZ_88P2", "KHZ_96"};
  657. static char const *bt_sample_rate_rx_text[] = {"KHZ_8", "KHZ_16",
  658. "KHZ_44P1", "KHZ_48",
  659. "KHZ_88P2", "KHZ_96"};
  660. static char const *bt_sample_rate_tx_text[] = {"KHZ_8", "KHZ_16",
  661. "KHZ_44P1", "KHZ_48",
  662. "KHZ_88P2", "KHZ_96"};
  663. static const char *const afe_loopback_tx_ch_text[] = {"One", "Two"};
  664. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  665. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  666. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  667. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  668. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  669. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  670. static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
  671. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  672. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  673. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  674. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  675. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  676. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  677. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  678. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  679. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  680. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  681. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  682. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  683. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  684. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  685. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  686. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  687. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  688. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  689. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  690. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  691. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  692. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  693. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  694. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  695. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
  696. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_sample_rate, mi2s_rate_text);
  697. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_sample_rate, mi2s_rate_text);
  698. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  699. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  700. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  701. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
  702. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_sample_rate, mi2s_rate_text);
  703. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_sample_rate, mi2s_rate_text);
  704. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  705. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  706. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  707. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  708. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  709. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
  710. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_chs, mi2s_ch_text);
  711. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_chs, mi2s_ch_text);
  712. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  713. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  714. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  715. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
  716. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_chs, mi2s_ch_text);
  717. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_chs, mi2s_ch_text);
  718. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  719. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  720. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  721. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  722. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_chs, cdc_dma_rx_ch_text);
  723. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_chs, cdc_dma_rx_ch_text);
  724. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_chs, cdc_dma_rx_ch_text);
  725. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  726. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  727. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  728. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  729. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_chs, cdc_dma_tx_ch_text);
  730. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_chs, cdc_dma_tx_ch_text);
  731. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  732. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  733. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  734. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  735. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  736. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  737. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  738. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_format, bit_format_text);
  739. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_format, bit_format_text);
  740. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_format, bit_format_text);
  741. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
  742. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
  743. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_format, bit_format_text);
  744. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  745. cdc_dma_sample_rate_text);
  746. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  747. cdc_dma_sample_rate_text);
  748. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  749. cdc_dma_sample_rate_text);
  750. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  751. cdc_dma_sample_rate_text);
  752. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  753. cdc_dma_sample_rate_text);
  754. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_sample_rate,
  755. cdc_dma_sample_rate_text);
  756. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_sample_rate,
  757. cdc_dma_sample_rate_text);
  758. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate,
  759. cdc_dma_sample_rate_text);
  760. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
  761. cdc_dma_sample_rate_text);
  762. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
  763. cdc_dma_sample_rate_text);
  764. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_sample_rate,
  765. cdc_dma_sample_rate_text);
  766. /* WCD9380 */
  767. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_0_format, cdc80_bit_format_text);
  768. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_1_format, cdc80_bit_format_text);
  769. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_2_format, cdc80_bit_format_text);
  770. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_3_format, cdc80_bit_format_text);
  771. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_5_format, cdc80_bit_format_text);
  772. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_0_sample_rate,
  773. cdc80_dma_sample_rate_text);
  774. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_1_sample_rate,
  775. cdc80_dma_sample_rate_text);
  776. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_2_sample_rate,
  777. cdc80_dma_sample_rate_text);
  778. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_3_sample_rate,
  779. cdc80_dma_sample_rate_text);
  780. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_5_sample_rate,
  781. cdc80_dma_sample_rate_text);
  782. /* WCD9385 */
  783. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_0_format, bit_format_text);
  784. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_1_format, bit_format_text);
  785. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_2_format, bit_format_text);
  786. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_3_format, bit_format_text);
  787. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_5_format, bit_format_text);
  788. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_0_sample_rate,
  789. cdc_dma_sample_rate_text);
  790. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_1_sample_rate,
  791. cdc_dma_sample_rate_text);
  792. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_2_sample_rate,
  793. cdc_dma_sample_rate_text);
  794. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_3_sample_rate,
  795. cdc_dma_sample_rate_text);
  796. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_5_sample_rate,
  797. cdc_dma_sample_rate_text);
  798. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
  799. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
  800. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
  801. ext_disp_sample_rate_text);
  802. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
  803. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_rx, bt_sample_rate_rx_text);
  804. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_tx, bt_sample_rate_tx_text);
  805. static SOC_ENUM_SINGLE_EXT_DECL(afe_loopback_tx_chs, afe_loopback_tx_ch_text);
  806. static bool is_initial_boot;
  807. static bool codec_reg_done;
  808. static struct snd_soc_card snd_soc_card_lahaina_msm;
  809. static int dmic_0_1_gpio_cnt;
  810. static int dmic_2_3_gpio_cnt;
  811. static int dmic_4_5_gpio_cnt;
  812. static void *def_wcd_mbhc_cal(void);
  813. static int msm_aux_codec_init(struct snd_soc_pcm_runtime*);
  814. static int msm_int_audrx_init(struct snd_soc_pcm_runtime*);
  815. /*
  816. * Need to report LINEIN
  817. * if R/L channel impedance is larger than 5K ohm
  818. */
  819. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  820. .read_fw_bin = false,
  821. .calibration = NULL,
  822. .detect_extn_cable = true,
  823. .mono_stero_detection = false,
  824. .swap_gnd_mic = NULL,
  825. .hs_ext_micbias = true,
  826. .key_code[0] = KEY_MEDIA,
  827. .key_code[1] = KEY_VOICECOMMAND,
  828. .key_code[2] = KEY_VOLUMEUP,
  829. .key_code[3] = KEY_VOLUMEDOWN,
  830. .key_code[4] = 0,
  831. .key_code[5] = 0,
  832. .key_code[6] = 0,
  833. .key_code[7] = 0,
  834. .linein_th = 5000,
  835. .moisture_en = false,
  836. .mbhc_micbias = MIC_BIAS_2,
  837. .anc_micbias = MIC_BIAS_2,
  838. .enable_anc_mic_detect = false,
  839. .moisture_duty_cycle_en = true,
  840. };
  841. static inline int param_is_mask(int p)
  842. {
  843. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  844. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  845. }
  846. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  847. int n)
  848. {
  849. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  850. }
  851. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  852. unsigned int bit)
  853. {
  854. if (bit >= SNDRV_MASK_MAX)
  855. return;
  856. if (param_is_mask(n)) {
  857. struct snd_mask *m = param_to_mask(p, n);
  858. m->bits[0] = 0;
  859. m->bits[1] = 0;
  860. m->bits[bit >> 5] |= (1 << (bit & 31));
  861. }
  862. }
  863. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  864. struct snd_ctl_elem_value *ucontrol)
  865. {
  866. int sample_rate_val = 0;
  867. switch (usb_rx_cfg.sample_rate) {
  868. case SAMPLING_RATE_384KHZ:
  869. sample_rate_val = 12;
  870. break;
  871. case SAMPLING_RATE_352P8KHZ:
  872. sample_rate_val = 11;
  873. break;
  874. case SAMPLING_RATE_192KHZ:
  875. sample_rate_val = 10;
  876. break;
  877. case SAMPLING_RATE_176P4KHZ:
  878. sample_rate_val = 9;
  879. break;
  880. case SAMPLING_RATE_96KHZ:
  881. sample_rate_val = 8;
  882. break;
  883. case SAMPLING_RATE_88P2KHZ:
  884. sample_rate_val = 7;
  885. break;
  886. case SAMPLING_RATE_48KHZ:
  887. sample_rate_val = 6;
  888. break;
  889. case SAMPLING_RATE_44P1KHZ:
  890. sample_rate_val = 5;
  891. break;
  892. case SAMPLING_RATE_32KHZ:
  893. sample_rate_val = 4;
  894. break;
  895. case SAMPLING_RATE_22P05KHZ:
  896. sample_rate_val = 3;
  897. break;
  898. case SAMPLING_RATE_16KHZ:
  899. sample_rate_val = 2;
  900. break;
  901. case SAMPLING_RATE_11P025KHZ:
  902. sample_rate_val = 1;
  903. break;
  904. case SAMPLING_RATE_8KHZ:
  905. default:
  906. sample_rate_val = 0;
  907. break;
  908. }
  909. ucontrol->value.integer.value[0] = sample_rate_val;
  910. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  911. usb_rx_cfg.sample_rate);
  912. return 0;
  913. }
  914. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  915. struct snd_ctl_elem_value *ucontrol)
  916. {
  917. switch (ucontrol->value.integer.value[0]) {
  918. case 12:
  919. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  920. break;
  921. case 11:
  922. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  923. break;
  924. case 10:
  925. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  926. break;
  927. case 9:
  928. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  929. break;
  930. case 8:
  931. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  932. break;
  933. case 7:
  934. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  935. break;
  936. case 6:
  937. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  938. break;
  939. case 5:
  940. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  941. break;
  942. case 4:
  943. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  944. break;
  945. case 3:
  946. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  947. break;
  948. case 2:
  949. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  950. break;
  951. case 1:
  952. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  953. break;
  954. case 0:
  955. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  956. break;
  957. default:
  958. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  959. break;
  960. }
  961. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  962. __func__, ucontrol->value.integer.value[0],
  963. usb_rx_cfg.sample_rate);
  964. return 0;
  965. }
  966. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  967. struct snd_ctl_elem_value *ucontrol)
  968. {
  969. int sample_rate_val = 0;
  970. switch (usb_tx_cfg.sample_rate) {
  971. case SAMPLING_RATE_384KHZ:
  972. sample_rate_val = 12;
  973. break;
  974. case SAMPLING_RATE_352P8KHZ:
  975. sample_rate_val = 11;
  976. break;
  977. case SAMPLING_RATE_192KHZ:
  978. sample_rate_val = 10;
  979. break;
  980. case SAMPLING_RATE_176P4KHZ:
  981. sample_rate_val = 9;
  982. break;
  983. case SAMPLING_RATE_96KHZ:
  984. sample_rate_val = 8;
  985. break;
  986. case SAMPLING_RATE_88P2KHZ:
  987. sample_rate_val = 7;
  988. break;
  989. case SAMPLING_RATE_48KHZ:
  990. sample_rate_val = 6;
  991. break;
  992. case SAMPLING_RATE_44P1KHZ:
  993. sample_rate_val = 5;
  994. break;
  995. case SAMPLING_RATE_32KHZ:
  996. sample_rate_val = 4;
  997. break;
  998. case SAMPLING_RATE_22P05KHZ:
  999. sample_rate_val = 3;
  1000. break;
  1001. case SAMPLING_RATE_16KHZ:
  1002. sample_rate_val = 2;
  1003. break;
  1004. case SAMPLING_RATE_11P025KHZ:
  1005. sample_rate_val = 1;
  1006. break;
  1007. case SAMPLING_RATE_8KHZ:
  1008. sample_rate_val = 0;
  1009. break;
  1010. default:
  1011. sample_rate_val = 6;
  1012. break;
  1013. }
  1014. ucontrol->value.integer.value[0] = sample_rate_val;
  1015. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  1016. usb_tx_cfg.sample_rate);
  1017. return 0;
  1018. }
  1019. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1020. struct snd_ctl_elem_value *ucontrol)
  1021. {
  1022. switch (ucontrol->value.integer.value[0]) {
  1023. case 12:
  1024. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1025. break;
  1026. case 11:
  1027. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1028. break;
  1029. case 10:
  1030. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1031. break;
  1032. case 9:
  1033. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1034. break;
  1035. case 8:
  1036. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1037. break;
  1038. case 7:
  1039. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1040. break;
  1041. case 6:
  1042. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1043. break;
  1044. case 5:
  1045. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1046. break;
  1047. case 4:
  1048. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1049. break;
  1050. case 3:
  1051. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1052. break;
  1053. case 2:
  1054. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1055. break;
  1056. case 1:
  1057. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1058. break;
  1059. case 0:
  1060. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1061. break;
  1062. default:
  1063. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1064. break;
  1065. }
  1066. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  1067. __func__, ucontrol->value.integer.value[0],
  1068. usb_tx_cfg.sample_rate);
  1069. return 0;
  1070. }
  1071. static int afe_loopback_tx_ch_get(struct snd_kcontrol *kcontrol,
  1072. struct snd_ctl_elem_value *ucontrol)
  1073. {
  1074. pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
  1075. afe_loopback_tx_cfg[0].channels);
  1076. ucontrol->value.enumerated.item[0] =
  1077. afe_loopback_tx_cfg[0].channels - 1;
  1078. return 0;
  1079. }
  1080. static int afe_loopback_tx_ch_put(struct snd_kcontrol *kcontrol,
  1081. struct snd_ctl_elem_value *ucontrol)
  1082. {
  1083. afe_loopback_tx_cfg[0].channels =
  1084. ucontrol->value.enumerated.item[0] + 1;
  1085. pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
  1086. afe_loopback_tx_cfg[0].channels);
  1087. return 1;
  1088. }
  1089. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  1090. struct snd_ctl_elem_value *ucontrol)
  1091. {
  1092. switch (usb_rx_cfg.bit_format) {
  1093. case SNDRV_PCM_FORMAT_S32_LE:
  1094. ucontrol->value.integer.value[0] = 3;
  1095. break;
  1096. case SNDRV_PCM_FORMAT_S24_3LE:
  1097. ucontrol->value.integer.value[0] = 2;
  1098. break;
  1099. case SNDRV_PCM_FORMAT_S24_LE:
  1100. ucontrol->value.integer.value[0] = 1;
  1101. break;
  1102. case SNDRV_PCM_FORMAT_S16_LE:
  1103. default:
  1104. ucontrol->value.integer.value[0] = 0;
  1105. break;
  1106. }
  1107. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1108. __func__, usb_rx_cfg.bit_format,
  1109. ucontrol->value.integer.value[0]);
  1110. return 0;
  1111. }
  1112. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  1113. struct snd_ctl_elem_value *ucontrol)
  1114. {
  1115. int rc = 0;
  1116. switch (ucontrol->value.integer.value[0]) {
  1117. case 3:
  1118. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1119. break;
  1120. case 2:
  1121. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1122. break;
  1123. case 1:
  1124. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1125. break;
  1126. case 0:
  1127. default:
  1128. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1129. break;
  1130. }
  1131. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1132. __func__, usb_rx_cfg.bit_format,
  1133. ucontrol->value.integer.value[0]);
  1134. return rc;
  1135. }
  1136. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  1137. struct snd_ctl_elem_value *ucontrol)
  1138. {
  1139. switch (usb_tx_cfg.bit_format) {
  1140. case SNDRV_PCM_FORMAT_S32_LE:
  1141. ucontrol->value.integer.value[0] = 3;
  1142. break;
  1143. case SNDRV_PCM_FORMAT_S24_3LE:
  1144. ucontrol->value.integer.value[0] = 2;
  1145. break;
  1146. case SNDRV_PCM_FORMAT_S24_LE:
  1147. ucontrol->value.integer.value[0] = 1;
  1148. break;
  1149. case SNDRV_PCM_FORMAT_S16_LE:
  1150. default:
  1151. ucontrol->value.integer.value[0] = 0;
  1152. break;
  1153. }
  1154. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1155. __func__, usb_tx_cfg.bit_format,
  1156. ucontrol->value.integer.value[0]);
  1157. return 0;
  1158. }
  1159. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  1160. struct snd_ctl_elem_value *ucontrol)
  1161. {
  1162. int rc = 0;
  1163. switch (ucontrol->value.integer.value[0]) {
  1164. case 3:
  1165. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1166. break;
  1167. case 2:
  1168. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1169. break;
  1170. case 1:
  1171. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1172. break;
  1173. case 0:
  1174. default:
  1175. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1176. break;
  1177. }
  1178. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1179. __func__, usb_tx_cfg.bit_format,
  1180. ucontrol->value.integer.value[0]);
  1181. return rc;
  1182. }
  1183. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  1184. struct snd_ctl_elem_value *ucontrol)
  1185. {
  1186. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  1187. usb_rx_cfg.channels);
  1188. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  1189. return 0;
  1190. }
  1191. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  1192. struct snd_ctl_elem_value *ucontrol)
  1193. {
  1194. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1195. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  1196. return 1;
  1197. }
  1198. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  1199. struct snd_ctl_elem_value *ucontrol)
  1200. {
  1201. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  1202. usb_tx_cfg.channels);
  1203. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  1204. return 0;
  1205. }
  1206. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  1207. struct snd_ctl_elem_value *ucontrol)
  1208. {
  1209. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1210. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  1211. return 1;
  1212. }
  1213. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  1214. struct snd_ctl_elem_value *ucontrol)
  1215. {
  1216. ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
  1217. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  1218. ucontrol->value.integer.value[0]);
  1219. return 0;
  1220. }
  1221. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  1222. struct snd_ctl_elem_value *ucontrol)
  1223. {
  1224. msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
  1225. pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
  1226. return 1;
  1227. }
  1228. static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
  1229. {
  1230. int idx = 0;
  1231. if (strnstr(kcontrol->id.name, "Display Port RX",
  1232. sizeof("Display Port RX"))) {
  1233. idx = EXT_DISP_RX_IDX_DP;
  1234. } else if (strnstr(kcontrol->id.name, "Display Port1 RX",
  1235. sizeof("Display Port1 RX"))) {
  1236. idx = EXT_DISP_RX_IDX_DP1;
  1237. } else {
  1238. pr_err("%s: unsupported BE: %s\n",
  1239. __func__, kcontrol->id.name);
  1240. idx = -EINVAL;
  1241. }
  1242. return idx;
  1243. }
  1244. static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
  1245. struct snd_ctl_elem_value *ucontrol)
  1246. {
  1247. int idx = ext_disp_get_port_idx(kcontrol);
  1248. if (idx < 0)
  1249. return idx;
  1250. switch (ext_disp_rx_cfg[idx].bit_format) {
  1251. case SNDRV_PCM_FORMAT_S24_3LE:
  1252. ucontrol->value.integer.value[0] = 2;
  1253. break;
  1254. case SNDRV_PCM_FORMAT_S24_LE:
  1255. ucontrol->value.integer.value[0] = 1;
  1256. break;
  1257. case SNDRV_PCM_FORMAT_S16_LE:
  1258. default:
  1259. ucontrol->value.integer.value[0] = 0;
  1260. break;
  1261. }
  1262. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  1263. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  1264. ucontrol->value.integer.value[0]);
  1265. return 0;
  1266. }
  1267. static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
  1268. struct snd_ctl_elem_value *ucontrol)
  1269. {
  1270. int idx = ext_disp_get_port_idx(kcontrol);
  1271. if (idx < 0)
  1272. return idx;
  1273. switch (ucontrol->value.integer.value[0]) {
  1274. case 2:
  1275. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1276. break;
  1277. case 1:
  1278. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1279. break;
  1280. case 0:
  1281. default:
  1282. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1283. break;
  1284. }
  1285. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  1286. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  1287. ucontrol->value.integer.value[0]);
  1288. return 0;
  1289. }
  1290. static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
  1291. struct snd_ctl_elem_value *ucontrol)
  1292. {
  1293. int idx = ext_disp_get_port_idx(kcontrol);
  1294. if (idx < 0)
  1295. return idx;
  1296. ucontrol->value.integer.value[0] =
  1297. ext_disp_rx_cfg[idx].channels - 2;
  1298. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1299. idx, ext_disp_rx_cfg[idx].channels);
  1300. return 0;
  1301. }
  1302. static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
  1303. struct snd_ctl_elem_value *ucontrol)
  1304. {
  1305. int idx = ext_disp_get_port_idx(kcontrol);
  1306. if (idx < 0)
  1307. return idx;
  1308. ext_disp_rx_cfg[idx].channels =
  1309. ucontrol->value.integer.value[0] + 2;
  1310. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1311. idx, ext_disp_rx_cfg[idx].channels);
  1312. return 1;
  1313. }
  1314. static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1315. struct snd_ctl_elem_value *ucontrol)
  1316. {
  1317. int sample_rate_val;
  1318. int idx = ext_disp_get_port_idx(kcontrol);
  1319. if (idx < 0)
  1320. return idx;
  1321. switch (ext_disp_rx_cfg[idx].sample_rate) {
  1322. case SAMPLING_RATE_176P4KHZ:
  1323. sample_rate_val = 6;
  1324. break;
  1325. case SAMPLING_RATE_88P2KHZ:
  1326. sample_rate_val = 5;
  1327. break;
  1328. case SAMPLING_RATE_44P1KHZ:
  1329. sample_rate_val = 4;
  1330. break;
  1331. case SAMPLING_RATE_32KHZ:
  1332. sample_rate_val = 3;
  1333. break;
  1334. case SAMPLING_RATE_192KHZ:
  1335. sample_rate_val = 2;
  1336. break;
  1337. case SAMPLING_RATE_96KHZ:
  1338. sample_rate_val = 1;
  1339. break;
  1340. case SAMPLING_RATE_48KHZ:
  1341. default:
  1342. sample_rate_val = 0;
  1343. break;
  1344. }
  1345. ucontrol->value.integer.value[0] = sample_rate_val;
  1346. pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
  1347. idx, ext_disp_rx_cfg[idx].sample_rate);
  1348. return 0;
  1349. }
  1350. static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1351. struct snd_ctl_elem_value *ucontrol)
  1352. {
  1353. int idx = ext_disp_get_port_idx(kcontrol);
  1354. if (idx < 0)
  1355. return idx;
  1356. switch (ucontrol->value.integer.value[0]) {
  1357. case 6:
  1358. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
  1359. break;
  1360. case 5:
  1361. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
  1362. break;
  1363. case 4:
  1364. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
  1365. break;
  1366. case 3:
  1367. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
  1368. break;
  1369. case 2:
  1370. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
  1371. break;
  1372. case 1:
  1373. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
  1374. break;
  1375. case 0:
  1376. default:
  1377. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
  1378. break;
  1379. }
  1380. pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
  1381. __func__, ucontrol->value.integer.value[0], idx,
  1382. ext_disp_rx_cfg[idx].sample_rate);
  1383. return 0;
  1384. }
  1385. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1386. struct snd_ctl_elem_value *ucontrol)
  1387. {
  1388. pr_debug("%s: proxy_rx channels = %d\n",
  1389. __func__, proxy_rx_cfg.channels);
  1390. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1391. return 0;
  1392. }
  1393. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1394. struct snd_ctl_elem_value *ucontrol)
  1395. {
  1396. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1397. pr_debug("%s: proxy_rx channels = %d\n",
  1398. __func__, proxy_rx_cfg.channels);
  1399. return 1;
  1400. }
  1401. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1402. struct tdm_port *port)
  1403. {
  1404. if (port) {
  1405. if (strnstr(kcontrol->id.name, "PRI",
  1406. sizeof(kcontrol->id.name))) {
  1407. port->mode = TDM_PRI;
  1408. } else if (strnstr(kcontrol->id.name, "SEC",
  1409. sizeof(kcontrol->id.name))) {
  1410. port->mode = TDM_SEC;
  1411. } else if (strnstr(kcontrol->id.name, "TERT",
  1412. sizeof(kcontrol->id.name))) {
  1413. port->mode = TDM_TERT;
  1414. } else if (strnstr(kcontrol->id.name, "QUAT",
  1415. sizeof(kcontrol->id.name))) {
  1416. port->mode = TDM_QUAT;
  1417. } else if (strnstr(kcontrol->id.name, "QUIN",
  1418. sizeof(kcontrol->id.name))) {
  1419. port->mode = TDM_QUIN;
  1420. } else if (strnstr(kcontrol->id.name, "SEN",
  1421. sizeof(kcontrol->id.name))) {
  1422. port->mode = TDM_SEN;
  1423. } else {
  1424. pr_err("%s: unsupported mode in: %s\n",
  1425. __func__, kcontrol->id.name);
  1426. return -EINVAL;
  1427. }
  1428. if (strnstr(kcontrol->id.name, "RX_0",
  1429. sizeof(kcontrol->id.name)) ||
  1430. strnstr(kcontrol->id.name, "TX_0",
  1431. sizeof(kcontrol->id.name))) {
  1432. port->channel = TDM_0;
  1433. } else if (strnstr(kcontrol->id.name, "RX_1",
  1434. sizeof(kcontrol->id.name)) ||
  1435. strnstr(kcontrol->id.name, "TX_1",
  1436. sizeof(kcontrol->id.name))) {
  1437. port->channel = TDM_1;
  1438. } else if (strnstr(kcontrol->id.name, "RX_2",
  1439. sizeof(kcontrol->id.name)) ||
  1440. strnstr(kcontrol->id.name, "TX_2",
  1441. sizeof(kcontrol->id.name))) {
  1442. port->channel = TDM_2;
  1443. } else if (strnstr(kcontrol->id.name, "RX_3",
  1444. sizeof(kcontrol->id.name)) ||
  1445. strnstr(kcontrol->id.name, "TX_3",
  1446. sizeof(kcontrol->id.name))) {
  1447. port->channel = TDM_3;
  1448. } else if (strnstr(kcontrol->id.name, "RX_4",
  1449. sizeof(kcontrol->id.name)) ||
  1450. strnstr(kcontrol->id.name, "TX_4",
  1451. sizeof(kcontrol->id.name))) {
  1452. port->channel = TDM_4;
  1453. } else if (strnstr(kcontrol->id.name, "RX_5",
  1454. sizeof(kcontrol->id.name)) ||
  1455. strnstr(kcontrol->id.name, "TX_5",
  1456. sizeof(kcontrol->id.name))) {
  1457. port->channel = TDM_5;
  1458. } else if (strnstr(kcontrol->id.name, "RX_6",
  1459. sizeof(kcontrol->id.name)) ||
  1460. strnstr(kcontrol->id.name, "TX_6",
  1461. sizeof(kcontrol->id.name))) {
  1462. port->channel = TDM_6;
  1463. } else if (strnstr(kcontrol->id.name, "RX_7",
  1464. sizeof(kcontrol->id.name)) ||
  1465. strnstr(kcontrol->id.name, "TX_7",
  1466. sizeof(kcontrol->id.name))) {
  1467. port->channel = TDM_7;
  1468. } else {
  1469. pr_err("%s: unsupported channel in: %s\n",
  1470. __func__, kcontrol->id.name);
  1471. return -EINVAL;
  1472. }
  1473. } else {
  1474. return -EINVAL;
  1475. }
  1476. return 0;
  1477. }
  1478. static int tdm_get_sample_rate(int value)
  1479. {
  1480. int sample_rate = 0;
  1481. switch (value) {
  1482. case 0:
  1483. sample_rate = SAMPLING_RATE_8KHZ;
  1484. break;
  1485. case 1:
  1486. sample_rate = SAMPLING_RATE_16KHZ;
  1487. break;
  1488. case 2:
  1489. sample_rate = SAMPLING_RATE_32KHZ;
  1490. break;
  1491. case 3:
  1492. sample_rate = SAMPLING_RATE_48KHZ;
  1493. break;
  1494. case 4:
  1495. sample_rate = SAMPLING_RATE_176P4KHZ;
  1496. break;
  1497. case 5:
  1498. sample_rate = SAMPLING_RATE_352P8KHZ;
  1499. break;
  1500. default:
  1501. sample_rate = SAMPLING_RATE_48KHZ;
  1502. break;
  1503. }
  1504. return sample_rate;
  1505. }
  1506. static int tdm_get_sample_rate_val(int sample_rate)
  1507. {
  1508. int sample_rate_val = 0;
  1509. switch (sample_rate) {
  1510. case SAMPLING_RATE_8KHZ:
  1511. sample_rate_val = 0;
  1512. break;
  1513. case SAMPLING_RATE_16KHZ:
  1514. sample_rate_val = 1;
  1515. break;
  1516. case SAMPLING_RATE_32KHZ:
  1517. sample_rate_val = 2;
  1518. break;
  1519. case SAMPLING_RATE_48KHZ:
  1520. sample_rate_val = 3;
  1521. break;
  1522. case SAMPLING_RATE_176P4KHZ:
  1523. sample_rate_val = 4;
  1524. break;
  1525. case SAMPLING_RATE_352P8KHZ:
  1526. sample_rate_val = 5;
  1527. break;
  1528. default:
  1529. sample_rate_val = 3;
  1530. break;
  1531. }
  1532. return sample_rate_val;
  1533. }
  1534. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1535. struct snd_ctl_elem_value *ucontrol)
  1536. {
  1537. struct tdm_port port;
  1538. int ret = tdm_get_port_idx(kcontrol, &port);
  1539. if (ret) {
  1540. pr_err("%s: unsupported control: %s\n",
  1541. __func__, kcontrol->id.name);
  1542. } else {
  1543. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1544. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  1545. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1546. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1547. ucontrol->value.enumerated.item[0]);
  1548. }
  1549. return ret;
  1550. }
  1551. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1552. struct snd_ctl_elem_value *ucontrol)
  1553. {
  1554. struct tdm_port port;
  1555. int ret = tdm_get_port_idx(kcontrol, &port);
  1556. if (ret) {
  1557. pr_err("%s: unsupported control: %s\n",
  1558. __func__, kcontrol->id.name);
  1559. } else {
  1560. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  1561. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1562. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1563. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1564. ucontrol->value.enumerated.item[0]);
  1565. }
  1566. return ret;
  1567. }
  1568. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1569. struct snd_ctl_elem_value *ucontrol)
  1570. {
  1571. struct tdm_port port;
  1572. int ret = tdm_get_port_idx(kcontrol, &port);
  1573. if (ret) {
  1574. pr_err("%s: unsupported control: %s\n",
  1575. __func__, kcontrol->id.name);
  1576. } else {
  1577. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1578. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  1579. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1580. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1581. ucontrol->value.enumerated.item[0]);
  1582. }
  1583. return ret;
  1584. }
  1585. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1586. struct snd_ctl_elem_value *ucontrol)
  1587. {
  1588. struct tdm_port port;
  1589. int ret = tdm_get_port_idx(kcontrol, &port);
  1590. if (ret) {
  1591. pr_err("%s: unsupported control: %s\n",
  1592. __func__, kcontrol->id.name);
  1593. } else {
  1594. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  1595. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1596. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1597. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1598. ucontrol->value.enumerated.item[0]);
  1599. }
  1600. return ret;
  1601. }
  1602. static int tdm_get_format(int value)
  1603. {
  1604. int format = 0;
  1605. switch (value) {
  1606. case 0:
  1607. format = SNDRV_PCM_FORMAT_S16_LE;
  1608. break;
  1609. case 1:
  1610. format = SNDRV_PCM_FORMAT_S24_LE;
  1611. break;
  1612. case 2:
  1613. format = SNDRV_PCM_FORMAT_S32_LE;
  1614. break;
  1615. default:
  1616. format = SNDRV_PCM_FORMAT_S16_LE;
  1617. break;
  1618. }
  1619. return format;
  1620. }
  1621. static int tdm_get_format_val(int format)
  1622. {
  1623. int value = 0;
  1624. switch (format) {
  1625. case SNDRV_PCM_FORMAT_S16_LE:
  1626. value = 0;
  1627. break;
  1628. case SNDRV_PCM_FORMAT_S24_LE:
  1629. value = 1;
  1630. break;
  1631. case SNDRV_PCM_FORMAT_S32_LE:
  1632. value = 2;
  1633. break;
  1634. default:
  1635. value = 0;
  1636. break;
  1637. }
  1638. return value;
  1639. }
  1640. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  1641. struct snd_ctl_elem_value *ucontrol)
  1642. {
  1643. struct tdm_port port;
  1644. int ret = tdm_get_port_idx(kcontrol, &port);
  1645. if (ret) {
  1646. pr_err("%s: unsupported control: %s\n",
  1647. __func__, kcontrol->id.name);
  1648. } else {
  1649. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1650. tdm_rx_cfg[port.mode][port.channel].bit_format);
  1651. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1652. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1653. ucontrol->value.enumerated.item[0]);
  1654. }
  1655. return ret;
  1656. }
  1657. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  1658. struct snd_ctl_elem_value *ucontrol)
  1659. {
  1660. struct tdm_port port;
  1661. int ret = tdm_get_port_idx(kcontrol, &port);
  1662. if (ret) {
  1663. pr_err("%s: unsupported control: %s\n",
  1664. __func__, kcontrol->id.name);
  1665. } else {
  1666. tdm_rx_cfg[port.mode][port.channel].bit_format =
  1667. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1668. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1669. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1670. ucontrol->value.enumerated.item[0]);
  1671. }
  1672. return ret;
  1673. }
  1674. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  1675. struct snd_ctl_elem_value *ucontrol)
  1676. {
  1677. struct tdm_port port;
  1678. int ret = tdm_get_port_idx(kcontrol, &port);
  1679. if (ret) {
  1680. pr_err("%s: unsupported control: %s\n",
  1681. __func__, kcontrol->id.name);
  1682. } else {
  1683. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1684. tdm_tx_cfg[port.mode][port.channel].bit_format);
  1685. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1686. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1687. ucontrol->value.enumerated.item[0]);
  1688. }
  1689. return ret;
  1690. }
  1691. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  1692. struct snd_ctl_elem_value *ucontrol)
  1693. {
  1694. struct tdm_port port;
  1695. int ret = tdm_get_port_idx(kcontrol, &port);
  1696. if (ret) {
  1697. pr_err("%s: unsupported control: %s\n",
  1698. __func__, kcontrol->id.name);
  1699. } else {
  1700. tdm_tx_cfg[port.mode][port.channel].bit_format =
  1701. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1702. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1703. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1704. ucontrol->value.enumerated.item[0]);
  1705. }
  1706. return ret;
  1707. }
  1708. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  1709. struct snd_ctl_elem_value *ucontrol)
  1710. {
  1711. struct tdm_port port;
  1712. int ret = tdm_get_port_idx(kcontrol, &port);
  1713. if (ret) {
  1714. pr_err("%s: unsupported control: %s\n",
  1715. __func__, kcontrol->id.name);
  1716. } else {
  1717. ucontrol->value.enumerated.item[0] =
  1718. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  1719. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1720. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  1721. ucontrol->value.enumerated.item[0]);
  1722. }
  1723. return ret;
  1724. }
  1725. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  1726. struct snd_ctl_elem_value *ucontrol)
  1727. {
  1728. struct tdm_port port;
  1729. int ret = tdm_get_port_idx(kcontrol, &port);
  1730. if (ret) {
  1731. pr_err("%s: unsupported control: %s\n",
  1732. __func__, kcontrol->id.name);
  1733. } else {
  1734. tdm_rx_cfg[port.mode][port.channel].channels =
  1735. ucontrol->value.enumerated.item[0] + 1;
  1736. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1737. tdm_rx_cfg[port.mode][port.channel].channels,
  1738. ucontrol->value.enumerated.item[0] + 1);
  1739. }
  1740. return ret;
  1741. }
  1742. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  1743. struct snd_ctl_elem_value *ucontrol)
  1744. {
  1745. struct tdm_port port;
  1746. int ret = tdm_get_port_idx(kcontrol, &port);
  1747. if (ret) {
  1748. pr_err("%s: unsupported control: %s\n",
  1749. __func__, kcontrol->id.name);
  1750. } else {
  1751. ucontrol->value.enumerated.item[0] =
  1752. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  1753. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1754. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  1755. ucontrol->value.enumerated.item[0]);
  1756. }
  1757. return ret;
  1758. }
  1759. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  1760. struct snd_ctl_elem_value *ucontrol)
  1761. {
  1762. struct tdm_port port;
  1763. int ret = tdm_get_port_idx(kcontrol, &port);
  1764. if (ret) {
  1765. pr_err("%s: unsupported control: %s\n",
  1766. __func__, kcontrol->id.name);
  1767. } else {
  1768. tdm_tx_cfg[port.mode][port.channel].channels =
  1769. ucontrol->value.enumerated.item[0] + 1;
  1770. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1771. tdm_tx_cfg[port.mode][port.channel].channels,
  1772. ucontrol->value.enumerated.item[0] + 1);
  1773. }
  1774. return ret;
  1775. }
  1776. static int tdm_slot_map_put(struct snd_kcontrol *kcontrol,
  1777. struct snd_ctl_elem_value *ucontrol)
  1778. {
  1779. int slot_index = 0;
  1780. int interface = ucontrol->value.integer.value[0];
  1781. int channel = ucontrol->value.integer.value[1];
  1782. unsigned int offset_val = 0;
  1783. unsigned int *slot_offset = NULL;
  1784. struct tdm_dev_config *config = NULL;
  1785. if (interface < 0 || interface >= (TDM_INTERFACE_MAX * MAX_PATH)) {
  1786. pr_err("%s: incorrect interface = %d\n", __func__, interface);
  1787. return -EINVAL;
  1788. }
  1789. if (channel < 0 || channel >= TDM_PORT_MAX) {
  1790. pr_err("%s: incorrect channel = %d\n", __func__, channel);
  1791. return -EINVAL;
  1792. }
  1793. pr_debug("%s: interface = %d, channel = %d\n", __func__,
  1794. interface, channel);
  1795. config = ((struct tdm_dev_config *) tdm_cfg[interface / MAX_PATH]) +
  1796. ((interface % MAX_PATH) * TDM_PORT_MAX) + channel;
  1797. slot_offset = config->tdm_slot_offset;
  1798. for (slot_index = 0; slot_index < TDM_MAX_SLOTS; slot_index++) {
  1799. offset_val = ucontrol->value.integer.value[MAX_PATH +
  1800. slot_index];
  1801. /* Offset value can only be 0, 4, 8, ..28 */
  1802. if (offset_val % 4 == 0 && offset_val <= 28)
  1803. slot_offset[slot_index] = offset_val;
  1804. pr_debug("%s: slot offset[%d] = %d\n", __func__,
  1805. slot_index, slot_offset[slot_index]);
  1806. }
  1807. return 0;
  1808. }
  1809. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  1810. {
  1811. int idx = 0;
  1812. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  1813. sizeof("PRIM_AUX_PCM"))) {
  1814. idx = PRIM_AUX_PCM;
  1815. } else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  1816. sizeof("SEC_AUX_PCM"))) {
  1817. idx = SEC_AUX_PCM;
  1818. } else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  1819. sizeof("TERT_AUX_PCM"))) {
  1820. idx = TERT_AUX_PCM;
  1821. } else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
  1822. sizeof("QUAT_AUX_PCM"))) {
  1823. idx = QUAT_AUX_PCM;
  1824. } else if (strnstr(kcontrol->id.name, "QUIN_AUX_PCM",
  1825. sizeof("QUIN_AUX_PCM"))) {
  1826. idx = QUIN_AUX_PCM;
  1827. } else if (strnstr(kcontrol->id.name, "SEN_AUX_PCM",
  1828. sizeof("SEN_AUX_PCM"))) {
  1829. idx = SEN_AUX_PCM;
  1830. } else {
  1831. pr_err("%s: unsupported port: %s\n",
  1832. __func__, kcontrol->id.name);
  1833. idx = -EINVAL;
  1834. }
  1835. return idx;
  1836. }
  1837. static int aux_pcm_get_sample_rate(int value)
  1838. {
  1839. int sample_rate = 0;
  1840. switch (value) {
  1841. case 1:
  1842. sample_rate = SAMPLING_RATE_16KHZ;
  1843. break;
  1844. case 0:
  1845. default:
  1846. sample_rate = SAMPLING_RATE_8KHZ;
  1847. break;
  1848. }
  1849. return sample_rate;
  1850. }
  1851. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1852. {
  1853. int sample_rate_val = 0;
  1854. switch (sample_rate) {
  1855. case SAMPLING_RATE_16KHZ:
  1856. sample_rate_val = 1;
  1857. break;
  1858. case SAMPLING_RATE_8KHZ:
  1859. default:
  1860. sample_rate_val = 0;
  1861. break;
  1862. }
  1863. return sample_rate_val;
  1864. }
  1865. static int mi2s_auxpcm_get_format(int value)
  1866. {
  1867. int format = 0;
  1868. switch (value) {
  1869. case 0:
  1870. format = SNDRV_PCM_FORMAT_S16_LE;
  1871. break;
  1872. case 1:
  1873. format = SNDRV_PCM_FORMAT_S24_LE;
  1874. break;
  1875. case 2:
  1876. format = SNDRV_PCM_FORMAT_S24_3LE;
  1877. break;
  1878. case 3:
  1879. format = SNDRV_PCM_FORMAT_S32_LE;
  1880. break;
  1881. default:
  1882. format = SNDRV_PCM_FORMAT_S16_LE;
  1883. break;
  1884. }
  1885. return format;
  1886. }
  1887. static int mi2s_auxpcm_get_format_value(int format)
  1888. {
  1889. int value = 0;
  1890. switch (format) {
  1891. case SNDRV_PCM_FORMAT_S16_LE:
  1892. value = 0;
  1893. break;
  1894. case SNDRV_PCM_FORMAT_S24_LE:
  1895. value = 1;
  1896. break;
  1897. case SNDRV_PCM_FORMAT_S24_3LE:
  1898. value = 2;
  1899. break;
  1900. case SNDRV_PCM_FORMAT_S32_LE:
  1901. value = 3;
  1902. break;
  1903. default:
  1904. value = 0;
  1905. break;
  1906. }
  1907. return value;
  1908. }
  1909. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1910. struct snd_ctl_elem_value *ucontrol)
  1911. {
  1912. int idx = aux_pcm_get_port_idx(kcontrol);
  1913. if (idx < 0)
  1914. return idx;
  1915. ucontrol->value.enumerated.item[0] =
  1916. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  1917. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1918. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1919. ucontrol->value.enumerated.item[0]);
  1920. return 0;
  1921. }
  1922. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1923. struct snd_ctl_elem_value *ucontrol)
  1924. {
  1925. int idx = aux_pcm_get_port_idx(kcontrol);
  1926. if (idx < 0)
  1927. return idx;
  1928. aux_pcm_rx_cfg[idx].sample_rate =
  1929. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1930. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1931. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1932. ucontrol->value.enumerated.item[0]);
  1933. return 0;
  1934. }
  1935. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1936. struct snd_ctl_elem_value *ucontrol)
  1937. {
  1938. int idx = aux_pcm_get_port_idx(kcontrol);
  1939. if (idx < 0)
  1940. return idx;
  1941. ucontrol->value.enumerated.item[0] =
  1942. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  1943. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1944. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1945. ucontrol->value.enumerated.item[0]);
  1946. return 0;
  1947. }
  1948. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1949. struct snd_ctl_elem_value *ucontrol)
  1950. {
  1951. int idx = aux_pcm_get_port_idx(kcontrol);
  1952. if (idx < 0)
  1953. return idx;
  1954. aux_pcm_tx_cfg[idx].sample_rate =
  1955. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1956. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1957. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1958. ucontrol->value.enumerated.item[0]);
  1959. return 0;
  1960. }
  1961. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  1962. struct snd_ctl_elem_value *ucontrol)
  1963. {
  1964. int idx = aux_pcm_get_port_idx(kcontrol);
  1965. if (idx < 0)
  1966. return idx;
  1967. ucontrol->value.enumerated.item[0] =
  1968. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  1969. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1970. idx, aux_pcm_rx_cfg[idx].bit_format,
  1971. ucontrol->value.enumerated.item[0]);
  1972. return 0;
  1973. }
  1974. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  1975. struct snd_ctl_elem_value *ucontrol)
  1976. {
  1977. int idx = aux_pcm_get_port_idx(kcontrol);
  1978. if (idx < 0)
  1979. return idx;
  1980. aux_pcm_rx_cfg[idx].bit_format =
  1981. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1982. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1983. idx, aux_pcm_rx_cfg[idx].bit_format,
  1984. ucontrol->value.enumerated.item[0]);
  1985. return 0;
  1986. }
  1987. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  1988. struct snd_ctl_elem_value *ucontrol)
  1989. {
  1990. int idx = aux_pcm_get_port_idx(kcontrol);
  1991. if (idx < 0)
  1992. return idx;
  1993. ucontrol->value.enumerated.item[0] =
  1994. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  1995. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1996. idx, aux_pcm_tx_cfg[idx].bit_format,
  1997. ucontrol->value.enumerated.item[0]);
  1998. return 0;
  1999. }
  2000. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  2001. struct snd_ctl_elem_value *ucontrol)
  2002. {
  2003. int idx = aux_pcm_get_port_idx(kcontrol);
  2004. if (idx < 0)
  2005. return idx;
  2006. aux_pcm_tx_cfg[idx].bit_format =
  2007. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2008. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2009. idx, aux_pcm_tx_cfg[idx].bit_format,
  2010. ucontrol->value.enumerated.item[0]);
  2011. return 0;
  2012. }
  2013. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  2014. {
  2015. int idx = 0;
  2016. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  2017. sizeof("PRIM_MI2S_RX"))) {
  2018. idx = PRIM_MI2S;
  2019. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  2020. sizeof("SEC_MI2S_RX"))) {
  2021. idx = SEC_MI2S;
  2022. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  2023. sizeof("TERT_MI2S_RX"))) {
  2024. idx = TERT_MI2S;
  2025. } else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
  2026. sizeof("QUAT_MI2S_RX"))) {
  2027. idx = QUAT_MI2S;
  2028. } else if (strnstr(kcontrol->id.name, "QUIN_MI2S_RX",
  2029. sizeof("QUIN_MI2S_RX"))) {
  2030. idx = QUIN_MI2S;
  2031. } else if (strnstr(kcontrol->id.name, "SEN_MI2S_RX",
  2032. sizeof("SEN_MI2S_RX"))) {
  2033. idx = SEN_MI2S;
  2034. } else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  2035. sizeof("PRIM_MI2S_TX"))) {
  2036. idx = PRIM_MI2S;
  2037. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  2038. sizeof("SEC_MI2S_TX"))) {
  2039. idx = SEC_MI2S;
  2040. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  2041. sizeof("TERT_MI2S_TX"))) {
  2042. idx = TERT_MI2S;
  2043. } else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
  2044. sizeof("QUAT_MI2S_TX"))) {
  2045. idx = QUAT_MI2S;
  2046. } else if (strnstr(kcontrol->id.name, "QUIN_MI2S_TX",
  2047. sizeof("QUIN_MI2S_TX"))) {
  2048. idx = QUIN_MI2S;
  2049. } else if (strnstr(kcontrol->id.name, "SEN_MI2S_TX",
  2050. sizeof("SEN_MI2S_TX"))) {
  2051. idx = SEN_MI2S;
  2052. } else {
  2053. pr_err("%s: unsupported channel: %s\n",
  2054. __func__, kcontrol->id.name);
  2055. idx = -EINVAL;
  2056. }
  2057. return idx;
  2058. }
  2059. static int mi2s_get_sample_rate(int value)
  2060. {
  2061. int sample_rate = 0;
  2062. switch (value) {
  2063. case 0:
  2064. sample_rate = SAMPLING_RATE_8KHZ;
  2065. break;
  2066. case 1:
  2067. sample_rate = SAMPLING_RATE_11P025KHZ;
  2068. break;
  2069. case 2:
  2070. sample_rate = SAMPLING_RATE_16KHZ;
  2071. break;
  2072. case 3:
  2073. sample_rate = SAMPLING_RATE_22P05KHZ;
  2074. break;
  2075. case 4:
  2076. sample_rate = SAMPLING_RATE_32KHZ;
  2077. break;
  2078. case 5:
  2079. sample_rate = SAMPLING_RATE_44P1KHZ;
  2080. break;
  2081. case 6:
  2082. sample_rate = SAMPLING_RATE_48KHZ;
  2083. break;
  2084. case 7:
  2085. sample_rate = SAMPLING_RATE_88P2KHZ;
  2086. break;
  2087. case 8:
  2088. sample_rate = SAMPLING_RATE_96KHZ;
  2089. break;
  2090. case 9:
  2091. sample_rate = SAMPLING_RATE_176P4KHZ;
  2092. break;
  2093. case 10:
  2094. sample_rate = SAMPLING_RATE_192KHZ;
  2095. break;
  2096. case 11:
  2097. sample_rate = SAMPLING_RATE_352P8KHZ;
  2098. break;
  2099. case 12:
  2100. sample_rate = SAMPLING_RATE_384KHZ;
  2101. break;
  2102. default:
  2103. sample_rate = SAMPLING_RATE_48KHZ;
  2104. break;
  2105. }
  2106. return sample_rate;
  2107. }
  2108. static int mi2s_get_sample_rate_val(int sample_rate)
  2109. {
  2110. int sample_rate_val = 0;
  2111. switch (sample_rate) {
  2112. case SAMPLING_RATE_8KHZ:
  2113. sample_rate_val = 0;
  2114. break;
  2115. case SAMPLING_RATE_11P025KHZ:
  2116. sample_rate_val = 1;
  2117. break;
  2118. case SAMPLING_RATE_16KHZ:
  2119. sample_rate_val = 2;
  2120. break;
  2121. case SAMPLING_RATE_22P05KHZ:
  2122. sample_rate_val = 3;
  2123. break;
  2124. case SAMPLING_RATE_32KHZ:
  2125. sample_rate_val = 4;
  2126. break;
  2127. case SAMPLING_RATE_44P1KHZ:
  2128. sample_rate_val = 5;
  2129. break;
  2130. case SAMPLING_RATE_48KHZ:
  2131. sample_rate_val = 6;
  2132. break;
  2133. case SAMPLING_RATE_88P2KHZ:
  2134. sample_rate_val = 7;
  2135. break;
  2136. case SAMPLING_RATE_96KHZ:
  2137. sample_rate_val = 8;
  2138. break;
  2139. case SAMPLING_RATE_176P4KHZ:
  2140. sample_rate_val = 9;
  2141. break;
  2142. case SAMPLING_RATE_192KHZ:
  2143. sample_rate_val = 10;
  2144. break;
  2145. case SAMPLING_RATE_352P8KHZ:
  2146. sample_rate_val = 11;
  2147. break;
  2148. case SAMPLING_RATE_384KHZ:
  2149. sample_rate_val = 12;
  2150. break;
  2151. default:
  2152. sample_rate_val = 6;
  2153. break;
  2154. }
  2155. return sample_rate_val;
  2156. }
  2157. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2158. struct snd_ctl_elem_value *ucontrol)
  2159. {
  2160. int idx = mi2s_get_port_idx(kcontrol);
  2161. if (idx < 0)
  2162. return idx;
  2163. ucontrol->value.enumerated.item[0] =
  2164. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  2165. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2166. idx, mi2s_rx_cfg[idx].sample_rate,
  2167. ucontrol->value.enumerated.item[0]);
  2168. return 0;
  2169. }
  2170. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2171. struct snd_ctl_elem_value *ucontrol)
  2172. {
  2173. int idx = mi2s_get_port_idx(kcontrol);
  2174. if (idx < 0)
  2175. return idx;
  2176. mi2s_rx_cfg[idx].sample_rate =
  2177. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2178. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2179. idx, mi2s_rx_cfg[idx].sample_rate,
  2180. ucontrol->value.enumerated.item[0]);
  2181. return 0;
  2182. }
  2183. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2184. struct snd_ctl_elem_value *ucontrol)
  2185. {
  2186. int idx = mi2s_get_port_idx(kcontrol);
  2187. if (idx < 0)
  2188. return idx;
  2189. ucontrol->value.enumerated.item[0] =
  2190. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  2191. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2192. idx, mi2s_tx_cfg[idx].sample_rate,
  2193. ucontrol->value.enumerated.item[0]);
  2194. return 0;
  2195. }
  2196. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2197. struct snd_ctl_elem_value *ucontrol)
  2198. {
  2199. int idx = mi2s_get_port_idx(kcontrol);
  2200. if (idx < 0)
  2201. return idx;
  2202. mi2s_tx_cfg[idx].sample_rate =
  2203. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2204. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2205. idx, mi2s_tx_cfg[idx].sample_rate,
  2206. ucontrol->value.enumerated.item[0]);
  2207. return 0;
  2208. }
  2209. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  2210. struct snd_ctl_elem_value *ucontrol)
  2211. {
  2212. int idx = mi2s_get_port_idx(kcontrol);
  2213. if (idx < 0)
  2214. return idx;
  2215. ucontrol->value.enumerated.item[0] =
  2216. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  2217. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2218. idx, mi2s_rx_cfg[idx].bit_format,
  2219. ucontrol->value.enumerated.item[0]);
  2220. return 0;
  2221. }
  2222. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  2223. struct snd_ctl_elem_value *ucontrol)
  2224. {
  2225. int idx = mi2s_get_port_idx(kcontrol);
  2226. if (idx < 0)
  2227. return idx;
  2228. mi2s_rx_cfg[idx].bit_format =
  2229. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2230. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2231. idx, mi2s_rx_cfg[idx].bit_format,
  2232. ucontrol->value.enumerated.item[0]);
  2233. return 0;
  2234. }
  2235. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  2236. struct snd_ctl_elem_value *ucontrol)
  2237. {
  2238. int idx = mi2s_get_port_idx(kcontrol);
  2239. if (idx < 0)
  2240. return idx;
  2241. ucontrol->value.enumerated.item[0] =
  2242. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  2243. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2244. idx, mi2s_tx_cfg[idx].bit_format,
  2245. ucontrol->value.enumerated.item[0]);
  2246. return 0;
  2247. }
  2248. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  2249. struct snd_ctl_elem_value *ucontrol)
  2250. {
  2251. int idx = mi2s_get_port_idx(kcontrol);
  2252. if (idx < 0)
  2253. return idx;
  2254. mi2s_tx_cfg[idx].bit_format =
  2255. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2256. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2257. idx, mi2s_tx_cfg[idx].bit_format,
  2258. ucontrol->value.enumerated.item[0]);
  2259. return 0;
  2260. }
  2261. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  2262. struct snd_ctl_elem_value *ucontrol)
  2263. {
  2264. int idx = mi2s_get_port_idx(kcontrol);
  2265. if (idx < 0)
  2266. return idx;
  2267. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2268. idx, mi2s_rx_cfg[idx].channels);
  2269. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  2270. return 0;
  2271. }
  2272. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  2273. struct snd_ctl_elem_value *ucontrol)
  2274. {
  2275. int idx = mi2s_get_port_idx(kcontrol);
  2276. if (idx < 0)
  2277. return idx;
  2278. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2279. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2280. idx, mi2s_rx_cfg[idx].channels);
  2281. return 1;
  2282. }
  2283. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  2284. struct snd_ctl_elem_value *ucontrol)
  2285. {
  2286. int idx = mi2s_get_port_idx(kcontrol);
  2287. if (idx < 0)
  2288. return idx;
  2289. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2290. idx, mi2s_tx_cfg[idx].channels);
  2291. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  2292. return 0;
  2293. }
  2294. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  2295. struct snd_ctl_elem_value *ucontrol)
  2296. {
  2297. int idx = mi2s_get_port_idx(kcontrol);
  2298. if (idx < 0)
  2299. return idx;
  2300. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2301. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2302. idx, mi2s_tx_cfg[idx].channels);
  2303. return 1;
  2304. }
  2305. static int msm_get_port_id(int be_id)
  2306. {
  2307. int afe_port_id = 0;
  2308. switch (be_id) {
  2309. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  2310. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  2311. break;
  2312. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  2313. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  2314. break;
  2315. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  2316. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  2317. break;
  2318. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  2319. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  2320. break;
  2321. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  2322. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  2323. break;
  2324. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  2325. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  2326. break;
  2327. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  2328. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  2329. break;
  2330. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  2331. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  2332. break;
  2333. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  2334. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  2335. break;
  2336. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  2337. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  2338. break;
  2339. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  2340. afe_port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  2341. break;
  2342. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  2343. afe_port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  2344. break;
  2345. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2346. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_0;
  2347. break;
  2348. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2349. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_1;
  2350. break;
  2351. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2352. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_2;
  2353. break;
  2354. default:
  2355. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  2356. afe_port_id = -EINVAL;
  2357. }
  2358. return afe_port_id;
  2359. }
  2360. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  2361. {
  2362. u32 bit_per_sample = 0;
  2363. switch (bit_format) {
  2364. case SNDRV_PCM_FORMAT_S32_LE:
  2365. case SNDRV_PCM_FORMAT_S24_3LE:
  2366. case SNDRV_PCM_FORMAT_S24_LE:
  2367. bit_per_sample = 32;
  2368. break;
  2369. case SNDRV_PCM_FORMAT_S16_LE:
  2370. default:
  2371. bit_per_sample = 16;
  2372. break;
  2373. }
  2374. return bit_per_sample;
  2375. }
  2376. static void update_mi2s_clk_val(int dai_id, int stream)
  2377. {
  2378. u32 bit_per_sample = 0;
  2379. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  2380. bit_per_sample =
  2381. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  2382. mi2s_clk[dai_id].clk_freq_in_hz =
  2383. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  2384. } else {
  2385. bit_per_sample =
  2386. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  2387. mi2s_clk[dai_id].clk_freq_in_hz =
  2388. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  2389. }
  2390. }
  2391. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  2392. {
  2393. int ret = 0;
  2394. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2395. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  2396. int port_id = 0;
  2397. int index = cpu_dai->id;
  2398. port_id = msm_get_port_id(rtd->dai_link->id);
  2399. if (port_id < 0) {
  2400. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  2401. ret = port_id;
  2402. goto err;
  2403. }
  2404. if (enable) {
  2405. update_mi2s_clk_val(index, substream->stream);
  2406. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  2407. mi2s_clk[index].clk_freq_in_hz);
  2408. }
  2409. mi2s_clk[index].enable = enable;
  2410. ret = afe_set_lpass_clock_v2(port_id,
  2411. &mi2s_clk[index]);
  2412. if (ret < 0) {
  2413. dev_err(rtd->card->dev,
  2414. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  2415. __func__, port_id, ret);
  2416. goto err;
  2417. }
  2418. err:
  2419. return ret;
  2420. }
  2421. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  2422. {
  2423. int idx = 0;
  2424. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  2425. sizeof("WSA_CDC_DMA_RX_0")))
  2426. idx = WSA_CDC_DMA_RX_0;
  2427. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  2428. sizeof("WSA_CDC_DMA_RX_0")))
  2429. idx = WSA_CDC_DMA_RX_1;
  2430. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
  2431. sizeof("RX_CDC_DMA_RX_0")))
  2432. idx = RX_CDC_DMA_RX_0;
  2433. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
  2434. sizeof("RX_CDC_DMA_RX_1")))
  2435. idx = RX_CDC_DMA_RX_1;
  2436. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
  2437. sizeof("RX_CDC_DMA_RX_2")))
  2438. idx = RX_CDC_DMA_RX_2;
  2439. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
  2440. sizeof("RX_CDC_DMA_RX_3")))
  2441. idx = RX_CDC_DMA_RX_3;
  2442. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
  2443. sizeof("RX_CDC_DMA_RX_5")))
  2444. idx = RX_CDC_DMA_RX_5;
  2445. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  2446. sizeof("WSA_CDC_DMA_TX_0")))
  2447. idx = WSA_CDC_DMA_TX_0;
  2448. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  2449. sizeof("WSA_CDC_DMA_TX_1")))
  2450. idx = WSA_CDC_DMA_TX_1;
  2451. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  2452. sizeof("WSA_CDC_DMA_TX_2")))
  2453. idx = WSA_CDC_DMA_TX_2;
  2454. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
  2455. sizeof("TX_CDC_DMA_TX_0")))
  2456. idx = TX_CDC_DMA_TX_0;
  2457. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
  2458. sizeof("TX_CDC_DMA_TX_3")))
  2459. idx = TX_CDC_DMA_TX_3;
  2460. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
  2461. sizeof("TX_CDC_DMA_TX_4")))
  2462. idx = TX_CDC_DMA_TX_4;
  2463. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  2464. sizeof("VA_CDC_DMA_TX_0")))
  2465. idx = VA_CDC_DMA_TX_0;
  2466. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  2467. sizeof("VA_CDC_DMA_TX_1")))
  2468. idx = VA_CDC_DMA_TX_1;
  2469. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_2",
  2470. sizeof("VA_CDC_DMA_TX_2")))
  2471. idx = VA_CDC_DMA_TX_2;
  2472. else {
  2473. pr_err("%s: unsupported channel: %s\n",
  2474. __func__, kcontrol->id.name);
  2475. return -EINVAL;
  2476. }
  2477. return idx;
  2478. }
  2479. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  2480. struct snd_ctl_elem_value *ucontrol)
  2481. {
  2482. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2483. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2484. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2485. return ch_num;
  2486. }
  2487. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2488. cdc_dma_rx_cfg[ch_num].channels - 1);
  2489. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  2490. return 0;
  2491. }
  2492. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  2493. struct snd_ctl_elem_value *ucontrol)
  2494. {
  2495. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2496. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2497. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2498. return ch_num;
  2499. }
  2500. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2501. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2502. cdc_dma_rx_cfg[ch_num].channels);
  2503. return 1;
  2504. }
  2505. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  2506. struct snd_ctl_elem_value *ucontrol)
  2507. {
  2508. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2509. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2510. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2511. return ch_num;
  2512. }
  2513. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  2514. case SNDRV_PCM_FORMAT_S32_LE:
  2515. ucontrol->value.integer.value[0] = 3;
  2516. break;
  2517. case SNDRV_PCM_FORMAT_S24_3LE:
  2518. ucontrol->value.integer.value[0] = 2;
  2519. break;
  2520. case SNDRV_PCM_FORMAT_S24_LE:
  2521. ucontrol->value.integer.value[0] = 1;
  2522. break;
  2523. case SNDRV_PCM_FORMAT_S16_LE:
  2524. default:
  2525. ucontrol->value.integer.value[0] = 0;
  2526. break;
  2527. }
  2528. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2529. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2530. ucontrol->value.integer.value[0]);
  2531. return 0;
  2532. }
  2533. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  2534. struct snd_ctl_elem_value *ucontrol)
  2535. {
  2536. int rc = 0;
  2537. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2538. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2539. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2540. return ch_num;
  2541. }
  2542. switch (ucontrol->value.integer.value[0]) {
  2543. case 3:
  2544. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2545. break;
  2546. case 2:
  2547. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2548. break;
  2549. case 1:
  2550. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2551. break;
  2552. case 0:
  2553. default:
  2554. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2555. break;
  2556. }
  2557. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2558. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2559. ucontrol->value.integer.value[0]);
  2560. return rc;
  2561. }
  2562. static int cdc_dma_get_sample_rate_val(int sample_rate)
  2563. {
  2564. int sample_rate_val = 0;
  2565. switch (sample_rate) {
  2566. case SAMPLING_RATE_8KHZ:
  2567. sample_rate_val = 0;
  2568. break;
  2569. case SAMPLING_RATE_11P025KHZ:
  2570. sample_rate_val = 1;
  2571. break;
  2572. case SAMPLING_RATE_16KHZ:
  2573. sample_rate_val = 2;
  2574. break;
  2575. case SAMPLING_RATE_22P05KHZ:
  2576. sample_rate_val = 3;
  2577. break;
  2578. case SAMPLING_RATE_32KHZ:
  2579. sample_rate_val = 4;
  2580. break;
  2581. case SAMPLING_RATE_44P1KHZ:
  2582. sample_rate_val = 5;
  2583. break;
  2584. case SAMPLING_RATE_48KHZ:
  2585. sample_rate_val = 6;
  2586. break;
  2587. case SAMPLING_RATE_88P2KHZ:
  2588. sample_rate_val = 7;
  2589. break;
  2590. case SAMPLING_RATE_96KHZ:
  2591. sample_rate_val = 8;
  2592. break;
  2593. case SAMPLING_RATE_176P4KHZ:
  2594. sample_rate_val = 9;
  2595. break;
  2596. case SAMPLING_RATE_192KHZ:
  2597. sample_rate_val = 10;
  2598. break;
  2599. case SAMPLING_RATE_352P8KHZ:
  2600. sample_rate_val = 11;
  2601. break;
  2602. case SAMPLING_RATE_384KHZ:
  2603. sample_rate_val = 12;
  2604. break;
  2605. default:
  2606. sample_rate_val = 6;
  2607. break;
  2608. }
  2609. return sample_rate_val;
  2610. }
  2611. static int cdc_dma_get_sample_rate(int value)
  2612. {
  2613. int sample_rate = 0;
  2614. switch (value) {
  2615. case 0:
  2616. sample_rate = SAMPLING_RATE_8KHZ;
  2617. break;
  2618. case 1:
  2619. sample_rate = SAMPLING_RATE_11P025KHZ;
  2620. break;
  2621. case 2:
  2622. sample_rate = SAMPLING_RATE_16KHZ;
  2623. break;
  2624. case 3:
  2625. sample_rate = SAMPLING_RATE_22P05KHZ;
  2626. break;
  2627. case 4:
  2628. sample_rate = SAMPLING_RATE_32KHZ;
  2629. break;
  2630. case 5:
  2631. sample_rate = SAMPLING_RATE_44P1KHZ;
  2632. break;
  2633. case 6:
  2634. sample_rate = SAMPLING_RATE_48KHZ;
  2635. break;
  2636. case 7:
  2637. sample_rate = SAMPLING_RATE_88P2KHZ;
  2638. break;
  2639. case 8:
  2640. sample_rate = SAMPLING_RATE_96KHZ;
  2641. break;
  2642. case 9:
  2643. sample_rate = SAMPLING_RATE_176P4KHZ;
  2644. break;
  2645. case 10:
  2646. sample_rate = SAMPLING_RATE_192KHZ;
  2647. break;
  2648. case 11:
  2649. sample_rate = SAMPLING_RATE_352P8KHZ;
  2650. break;
  2651. case 12:
  2652. sample_rate = SAMPLING_RATE_384KHZ;
  2653. break;
  2654. default:
  2655. sample_rate = SAMPLING_RATE_48KHZ;
  2656. break;
  2657. }
  2658. return sample_rate;
  2659. }
  2660. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2661. struct snd_ctl_elem_value *ucontrol)
  2662. {
  2663. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2664. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2665. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2666. return ch_num;
  2667. }
  2668. ucontrol->value.enumerated.item[0] =
  2669. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  2670. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  2671. cdc_dma_rx_cfg[ch_num].sample_rate);
  2672. return 0;
  2673. }
  2674. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2675. struct snd_ctl_elem_value *ucontrol)
  2676. {
  2677. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2678. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2679. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2680. return ch_num;
  2681. }
  2682. cdc_dma_rx_cfg[ch_num].sample_rate =
  2683. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2684. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  2685. __func__, ucontrol->value.enumerated.item[0],
  2686. cdc_dma_rx_cfg[ch_num].sample_rate);
  2687. return 0;
  2688. }
  2689. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  2690. struct snd_ctl_elem_value *ucontrol)
  2691. {
  2692. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2693. if (ch_num < 0) {
  2694. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2695. return ch_num;
  2696. }
  2697. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2698. cdc_dma_tx_cfg[ch_num].channels);
  2699. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  2700. return 0;
  2701. }
  2702. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  2703. struct snd_ctl_elem_value *ucontrol)
  2704. {
  2705. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2706. if (ch_num < 0) {
  2707. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2708. return ch_num;
  2709. }
  2710. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2711. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2712. cdc_dma_tx_cfg[ch_num].channels);
  2713. return 1;
  2714. }
  2715. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2716. struct snd_ctl_elem_value *ucontrol)
  2717. {
  2718. int sample_rate_val;
  2719. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2720. if (ch_num < 0) {
  2721. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2722. return ch_num;
  2723. }
  2724. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  2725. case SAMPLING_RATE_384KHZ:
  2726. sample_rate_val = 12;
  2727. break;
  2728. case SAMPLING_RATE_352P8KHZ:
  2729. sample_rate_val = 11;
  2730. break;
  2731. case SAMPLING_RATE_192KHZ:
  2732. sample_rate_val = 10;
  2733. break;
  2734. case SAMPLING_RATE_176P4KHZ:
  2735. sample_rate_val = 9;
  2736. break;
  2737. case SAMPLING_RATE_96KHZ:
  2738. sample_rate_val = 8;
  2739. break;
  2740. case SAMPLING_RATE_88P2KHZ:
  2741. sample_rate_val = 7;
  2742. break;
  2743. case SAMPLING_RATE_48KHZ:
  2744. sample_rate_val = 6;
  2745. break;
  2746. case SAMPLING_RATE_44P1KHZ:
  2747. sample_rate_val = 5;
  2748. break;
  2749. case SAMPLING_RATE_32KHZ:
  2750. sample_rate_val = 4;
  2751. break;
  2752. case SAMPLING_RATE_22P05KHZ:
  2753. sample_rate_val = 3;
  2754. break;
  2755. case SAMPLING_RATE_16KHZ:
  2756. sample_rate_val = 2;
  2757. break;
  2758. case SAMPLING_RATE_11P025KHZ:
  2759. sample_rate_val = 1;
  2760. break;
  2761. case SAMPLING_RATE_8KHZ:
  2762. sample_rate_val = 0;
  2763. break;
  2764. default:
  2765. sample_rate_val = 6;
  2766. break;
  2767. }
  2768. ucontrol->value.integer.value[0] = sample_rate_val;
  2769. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  2770. cdc_dma_tx_cfg[ch_num].sample_rate);
  2771. return 0;
  2772. }
  2773. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2774. struct snd_ctl_elem_value *ucontrol)
  2775. {
  2776. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2777. if (ch_num < 0) {
  2778. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2779. return ch_num;
  2780. }
  2781. switch (ucontrol->value.integer.value[0]) {
  2782. case 12:
  2783. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  2784. break;
  2785. case 11:
  2786. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  2787. break;
  2788. case 10:
  2789. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  2790. break;
  2791. case 9:
  2792. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  2793. break;
  2794. case 8:
  2795. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  2796. break;
  2797. case 7:
  2798. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  2799. break;
  2800. case 6:
  2801. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2802. break;
  2803. case 5:
  2804. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  2805. break;
  2806. case 4:
  2807. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  2808. break;
  2809. case 3:
  2810. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  2811. break;
  2812. case 2:
  2813. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  2814. break;
  2815. case 1:
  2816. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  2817. break;
  2818. case 0:
  2819. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  2820. break;
  2821. default:
  2822. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2823. break;
  2824. }
  2825. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  2826. __func__, ucontrol->value.integer.value[0],
  2827. cdc_dma_tx_cfg[ch_num].sample_rate);
  2828. return 0;
  2829. }
  2830. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  2831. struct snd_ctl_elem_value *ucontrol)
  2832. {
  2833. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2834. if (ch_num < 0) {
  2835. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2836. return ch_num;
  2837. }
  2838. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  2839. case SNDRV_PCM_FORMAT_S32_LE:
  2840. ucontrol->value.integer.value[0] = 3;
  2841. break;
  2842. case SNDRV_PCM_FORMAT_S24_3LE:
  2843. ucontrol->value.integer.value[0] = 2;
  2844. break;
  2845. case SNDRV_PCM_FORMAT_S24_LE:
  2846. ucontrol->value.integer.value[0] = 1;
  2847. break;
  2848. case SNDRV_PCM_FORMAT_S16_LE:
  2849. default:
  2850. ucontrol->value.integer.value[0] = 0;
  2851. break;
  2852. }
  2853. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2854. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2855. ucontrol->value.integer.value[0]);
  2856. return 0;
  2857. }
  2858. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  2859. struct snd_ctl_elem_value *ucontrol)
  2860. {
  2861. int rc = 0;
  2862. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2863. if (ch_num < 0) {
  2864. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2865. return ch_num;
  2866. }
  2867. switch (ucontrol->value.integer.value[0]) {
  2868. case 3:
  2869. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2870. break;
  2871. case 2:
  2872. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2873. break;
  2874. case 1:
  2875. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2876. break;
  2877. case 0:
  2878. default:
  2879. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2880. break;
  2881. }
  2882. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2883. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2884. ucontrol->value.integer.value[0]);
  2885. return rc;
  2886. }
  2887. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  2888. {
  2889. int idx = 0;
  2890. switch (be_id) {
  2891. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  2892. idx = WSA_CDC_DMA_RX_0;
  2893. break;
  2894. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  2895. idx = WSA_CDC_DMA_TX_0;
  2896. break;
  2897. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  2898. idx = WSA_CDC_DMA_RX_1;
  2899. break;
  2900. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  2901. idx = WSA_CDC_DMA_TX_1;
  2902. break;
  2903. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  2904. idx = WSA_CDC_DMA_TX_2;
  2905. break;
  2906. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  2907. idx = RX_CDC_DMA_RX_0;
  2908. break;
  2909. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  2910. idx = RX_CDC_DMA_RX_1;
  2911. break;
  2912. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  2913. idx = RX_CDC_DMA_RX_2;
  2914. break;
  2915. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  2916. idx = RX_CDC_DMA_RX_3;
  2917. break;
  2918. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  2919. idx = RX_CDC_DMA_RX_5;
  2920. break;
  2921. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  2922. idx = TX_CDC_DMA_TX_0;
  2923. break;
  2924. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  2925. idx = TX_CDC_DMA_TX_3;
  2926. break;
  2927. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  2928. idx = TX_CDC_DMA_TX_4;
  2929. break;
  2930. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2931. idx = VA_CDC_DMA_TX_0;
  2932. break;
  2933. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2934. idx = VA_CDC_DMA_TX_1;
  2935. break;
  2936. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2937. idx = VA_CDC_DMA_TX_2;
  2938. break;
  2939. default:
  2940. idx = RX_CDC_DMA_RX_0;
  2941. break;
  2942. }
  2943. return idx;
  2944. }
  2945. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  2946. struct snd_ctl_elem_value *ucontrol)
  2947. {
  2948. /*
  2949. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  2950. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  2951. * value.
  2952. */
  2953. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  2954. case SAMPLING_RATE_96KHZ:
  2955. ucontrol->value.integer.value[0] = 5;
  2956. break;
  2957. case SAMPLING_RATE_88P2KHZ:
  2958. ucontrol->value.integer.value[0] = 4;
  2959. break;
  2960. case SAMPLING_RATE_48KHZ:
  2961. ucontrol->value.integer.value[0] = 3;
  2962. break;
  2963. case SAMPLING_RATE_44P1KHZ:
  2964. ucontrol->value.integer.value[0] = 2;
  2965. break;
  2966. case SAMPLING_RATE_16KHZ:
  2967. ucontrol->value.integer.value[0] = 1;
  2968. break;
  2969. case SAMPLING_RATE_8KHZ:
  2970. default:
  2971. ucontrol->value.integer.value[0] = 0;
  2972. break;
  2973. }
  2974. pr_debug("%s: sample rate = %d\n", __func__,
  2975. slim_rx_cfg[SLIM_RX_7].sample_rate);
  2976. return 0;
  2977. }
  2978. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  2979. struct snd_ctl_elem_value *ucontrol)
  2980. {
  2981. switch (ucontrol->value.integer.value[0]) {
  2982. case 1:
  2983. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  2984. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  2985. break;
  2986. case 2:
  2987. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  2988. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  2989. break;
  2990. case 3:
  2991. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  2992. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  2993. break;
  2994. case 4:
  2995. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  2996. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  2997. break;
  2998. case 5:
  2999. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3000. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3001. break;
  3002. case 0:
  3003. default:
  3004. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3005. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3006. break;
  3007. }
  3008. pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
  3009. __func__,
  3010. slim_rx_cfg[SLIM_RX_7].sample_rate,
  3011. slim_tx_cfg[SLIM_TX_7].sample_rate,
  3012. ucontrol->value.enumerated.item[0]);
  3013. return 0;
  3014. }
  3015. static int msm_bt_sample_rate_rx_get(struct snd_kcontrol *kcontrol,
  3016. struct snd_ctl_elem_value *ucontrol)
  3017. {
  3018. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  3019. case SAMPLING_RATE_96KHZ:
  3020. ucontrol->value.integer.value[0] = 5;
  3021. break;
  3022. case SAMPLING_RATE_88P2KHZ:
  3023. ucontrol->value.integer.value[0] = 4;
  3024. break;
  3025. case SAMPLING_RATE_48KHZ:
  3026. ucontrol->value.integer.value[0] = 3;
  3027. break;
  3028. case SAMPLING_RATE_44P1KHZ:
  3029. ucontrol->value.integer.value[0] = 2;
  3030. break;
  3031. case SAMPLING_RATE_16KHZ:
  3032. ucontrol->value.integer.value[0] = 1;
  3033. break;
  3034. case SAMPLING_RATE_8KHZ:
  3035. default:
  3036. ucontrol->value.integer.value[0] = 0;
  3037. break;
  3038. }
  3039. pr_debug("%s: sample rate rx = %d\n", __func__,
  3040. slim_rx_cfg[SLIM_RX_7].sample_rate);
  3041. return 0;
  3042. }
  3043. static int msm_bt_sample_rate_rx_put(struct snd_kcontrol *kcontrol,
  3044. struct snd_ctl_elem_value *ucontrol)
  3045. {
  3046. switch (ucontrol->value.integer.value[0]) {
  3047. case 1:
  3048. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3049. break;
  3050. case 2:
  3051. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3052. break;
  3053. case 3:
  3054. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3055. break;
  3056. case 4:
  3057. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3058. break;
  3059. case 5:
  3060. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3061. break;
  3062. case 0:
  3063. default:
  3064. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3065. break;
  3066. }
  3067. pr_debug("%s: sample rate: slim7_rx = %d, value = %d\n",
  3068. __func__,
  3069. slim_rx_cfg[SLIM_RX_7].sample_rate,
  3070. ucontrol->value.enumerated.item[0]);
  3071. return 0;
  3072. }
  3073. static int msm_bt_sample_rate_tx_get(struct snd_kcontrol *kcontrol,
  3074. struct snd_ctl_elem_value *ucontrol)
  3075. {
  3076. switch (slim_tx_cfg[SLIM_TX_7].sample_rate) {
  3077. case SAMPLING_RATE_96KHZ:
  3078. ucontrol->value.integer.value[0] = 5;
  3079. break;
  3080. case SAMPLING_RATE_88P2KHZ:
  3081. ucontrol->value.integer.value[0] = 4;
  3082. break;
  3083. case SAMPLING_RATE_48KHZ:
  3084. ucontrol->value.integer.value[0] = 3;
  3085. break;
  3086. case SAMPLING_RATE_44P1KHZ:
  3087. ucontrol->value.integer.value[0] = 2;
  3088. break;
  3089. case SAMPLING_RATE_16KHZ:
  3090. ucontrol->value.integer.value[0] = 1;
  3091. break;
  3092. case SAMPLING_RATE_8KHZ:
  3093. default:
  3094. ucontrol->value.integer.value[0] = 0;
  3095. break;
  3096. }
  3097. pr_debug("%s: sample rate tx = %d\n", __func__,
  3098. slim_tx_cfg[SLIM_TX_7].sample_rate);
  3099. return 0;
  3100. }
  3101. static int msm_bt_sample_rate_tx_put(struct snd_kcontrol *kcontrol,
  3102. struct snd_ctl_elem_value *ucontrol)
  3103. {
  3104. switch (ucontrol->value.integer.value[0]) {
  3105. case 1:
  3106. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3107. break;
  3108. case 2:
  3109. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3110. break;
  3111. case 3:
  3112. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3113. break;
  3114. case 4:
  3115. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3116. break;
  3117. case 5:
  3118. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3119. break;
  3120. case 0:
  3121. default:
  3122. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3123. break;
  3124. }
  3125. pr_debug("%s: sample rate: slim7_tx = %d, value = %d\n",
  3126. __func__,
  3127. slim_tx_cfg[SLIM_TX_7].sample_rate,
  3128. ucontrol->value.enumerated.item[0]);
  3129. return 0;
  3130. }
  3131. static const struct snd_kcontrol_new msm_int_snd_controls[] = {
  3132. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  3133. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3134. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  3135. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3136. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
  3137. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3138. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
  3139. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3140. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
  3141. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3142. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
  3143. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3144. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
  3145. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3146. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  3147. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3148. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  3149. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3150. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  3151. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3152. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
  3153. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3154. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
  3155. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3156. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
  3157. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3158. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  3159. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3160. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  3161. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3162. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Channels", va_cdc_dma_tx_2_chs,
  3163. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3164. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  3165. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3166. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  3167. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3168. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  3169. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3170. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  3171. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3172. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
  3173. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3174. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
  3175. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3176. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
  3177. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3178. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  3179. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3180. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  3181. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3182. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Format", va_cdc_dma_tx_2_format,
  3183. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3184. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  3185. wsa_cdc_dma_rx_0_sample_rate,
  3186. cdc_dma_rx_sample_rate_get,
  3187. cdc_dma_rx_sample_rate_put),
  3188. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  3189. wsa_cdc_dma_rx_1_sample_rate,
  3190. cdc_dma_rx_sample_rate_get,
  3191. cdc_dma_rx_sample_rate_put),
  3192. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  3193. wsa_cdc_dma_tx_0_sample_rate,
  3194. cdc_dma_tx_sample_rate_get,
  3195. cdc_dma_tx_sample_rate_put),
  3196. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  3197. wsa_cdc_dma_tx_1_sample_rate,
  3198. cdc_dma_tx_sample_rate_get,
  3199. cdc_dma_tx_sample_rate_put),
  3200. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  3201. wsa_cdc_dma_tx_2_sample_rate,
  3202. cdc_dma_tx_sample_rate_get,
  3203. cdc_dma_tx_sample_rate_put),
  3204. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
  3205. tx_cdc_dma_tx_0_sample_rate,
  3206. cdc_dma_tx_sample_rate_get,
  3207. cdc_dma_tx_sample_rate_put),
  3208. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
  3209. tx_cdc_dma_tx_3_sample_rate,
  3210. cdc_dma_tx_sample_rate_get,
  3211. cdc_dma_tx_sample_rate_put),
  3212. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
  3213. tx_cdc_dma_tx_4_sample_rate,
  3214. cdc_dma_tx_sample_rate_get,
  3215. cdc_dma_tx_sample_rate_put),
  3216. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  3217. va_cdc_dma_tx_0_sample_rate,
  3218. cdc_dma_tx_sample_rate_get,
  3219. cdc_dma_tx_sample_rate_put),
  3220. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  3221. va_cdc_dma_tx_1_sample_rate,
  3222. cdc_dma_tx_sample_rate_get,
  3223. cdc_dma_tx_sample_rate_put),
  3224. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 SampleRate",
  3225. va_cdc_dma_tx_2_sample_rate,
  3226. cdc_dma_tx_sample_rate_get,
  3227. cdc_dma_tx_sample_rate_put),
  3228. };
  3229. static const struct snd_kcontrol_new msm_int_wcd9380_snd_controls[] = {
  3230. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc80_dma_rx_0_format,
  3231. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3232. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc80_dma_rx_1_format,
  3233. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3234. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc80_dma_rx_2_format,
  3235. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3236. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc80_dma_rx_3_format,
  3237. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3238. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc80_dma_rx_5_format,
  3239. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3240. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  3241. rx_cdc80_dma_rx_0_sample_rate,
  3242. cdc_dma_rx_sample_rate_get,
  3243. cdc_dma_rx_sample_rate_put),
  3244. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  3245. rx_cdc80_dma_rx_1_sample_rate,
  3246. cdc_dma_rx_sample_rate_get,
  3247. cdc_dma_rx_sample_rate_put),
  3248. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  3249. rx_cdc80_dma_rx_2_sample_rate,
  3250. cdc_dma_rx_sample_rate_get,
  3251. cdc_dma_rx_sample_rate_put),
  3252. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  3253. rx_cdc80_dma_rx_3_sample_rate,
  3254. cdc_dma_rx_sample_rate_get,
  3255. cdc_dma_rx_sample_rate_put),
  3256. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  3257. rx_cdc80_dma_rx_5_sample_rate,
  3258. cdc_dma_rx_sample_rate_get,
  3259. cdc_dma_rx_sample_rate_put),
  3260. };
  3261. static const struct snd_kcontrol_new msm_int_wcd9385_snd_controls[] = {
  3262. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc85_dma_rx_0_format,
  3263. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3264. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc85_dma_rx_1_format,
  3265. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3266. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc85_dma_rx_2_format,
  3267. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3268. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc85_dma_rx_3_format,
  3269. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3270. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc85_dma_rx_5_format,
  3271. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3272. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  3273. rx_cdc85_dma_rx_0_sample_rate,
  3274. cdc_dma_rx_sample_rate_get,
  3275. cdc_dma_rx_sample_rate_put),
  3276. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  3277. rx_cdc85_dma_rx_1_sample_rate,
  3278. cdc_dma_rx_sample_rate_get,
  3279. cdc_dma_rx_sample_rate_put),
  3280. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  3281. rx_cdc85_dma_rx_2_sample_rate,
  3282. cdc_dma_rx_sample_rate_get,
  3283. cdc_dma_rx_sample_rate_put),
  3284. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  3285. rx_cdc85_dma_rx_3_sample_rate,
  3286. cdc_dma_rx_sample_rate_get,
  3287. cdc_dma_rx_sample_rate_put),
  3288. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  3289. rx_cdc85_dma_rx_5_sample_rate,
  3290. cdc_dma_rx_sample_rate_get,
  3291. cdc_dma_rx_sample_rate_put),
  3292. };
  3293. static const struct snd_kcontrol_new msm_common_snd_controls[] = {
  3294. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  3295. usb_audio_rx_sample_rate_get,
  3296. usb_audio_rx_sample_rate_put),
  3297. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  3298. usb_audio_tx_sample_rate_get,
  3299. usb_audio_tx_sample_rate_put),
  3300. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3301. tdm_rx_sample_rate_get,
  3302. tdm_rx_sample_rate_put),
  3303. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3304. tdm_rx_sample_rate_get,
  3305. tdm_rx_sample_rate_put),
  3306. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3307. tdm_rx_sample_rate_get,
  3308. tdm_rx_sample_rate_put),
  3309. SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3310. tdm_rx_sample_rate_get,
  3311. tdm_rx_sample_rate_put),
  3312. SOC_ENUM_EXT("QUIN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3313. tdm_rx_sample_rate_get,
  3314. tdm_rx_sample_rate_put),
  3315. SOC_ENUM_EXT("SEN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3316. tdm_rx_sample_rate_get,
  3317. tdm_rx_sample_rate_put),
  3318. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3319. tdm_tx_sample_rate_get,
  3320. tdm_tx_sample_rate_put),
  3321. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3322. tdm_tx_sample_rate_get,
  3323. tdm_tx_sample_rate_put),
  3324. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3325. tdm_tx_sample_rate_get,
  3326. tdm_tx_sample_rate_put),
  3327. SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3328. tdm_tx_sample_rate_get,
  3329. tdm_tx_sample_rate_put),
  3330. SOC_ENUM_EXT("QUIN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3331. tdm_tx_sample_rate_get,
  3332. tdm_tx_sample_rate_put),
  3333. SOC_ENUM_EXT("SEN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3334. tdm_tx_sample_rate_get,
  3335. tdm_tx_sample_rate_put),
  3336. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3337. aux_pcm_rx_sample_rate_get,
  3338. aux_pcm_rx_sample_rate_put),
  3339. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  3340. aux_pcm_rx_sample_rate_get,
  3341. aux_pcm_rx_sample_rate_put),
  3342. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  3343. aux_pcm_rx_sample_rate_get,
  3344. aux_pcm_rx_sample_rate_put),
  3345. SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
  3346. aux_pcm_rx_sample_rate_get,
  3347. aux_pcm_rx_sample_rate_put),
  3348. SOC_ENUM_EXT("QUIN_AUX_PCM_RX SampleRate", quin_aux_pcm_rx_sample_rate,
  3349. aux_pcm_rx_sample_rate_get,
  3350. aux_pcm_rx_sample_rate_put),
  3351. SOC_ENUM_EXT("SEN_AUX_PCM_RX SampleRate", sen_aux_pcm_rx_sample_rate,
  3352. aux_pcm_rx_sample_rate_get,
  3353. aux_pcm_rx_sample_rate_put),
  3354. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3355. aux_pcm_tx_sample_rate_get,
  3356. aux_pcm_tx_sample_rate_put),
  3357. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  3358. aux_pcm_tx_sample_rate_get,
  3359. aux_pcm_tx_sample_rate_put),
  3360. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  3361. aux_pcm_tx_sample_rate_get,
  3362. aux_pcm_tx_sample_rate_put),
  3363. SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
  3364. aux_pcm_tx_sample_rate_get,
  3365. aux_pcm_tx_sample_rate_put),
  3366. SOC_ENUM_EXT("QUIN_AUX_PCM_TX SampleRate", quin_aux_pcm_tx_sample_rate,
  3367. aux_pcm_tx_sample_rate_get,
  3368. aux_pcm_tx_sample_rate_put),
  3369. SOC_ENUM_EXT("SEN_AUX_PCM_TX SampleRate", sen_aux_pcm_tx_sample_rate,
  3370. aux_pcm_tx_sample_rate_get,
  3371. aux_pcm_tx_sample_rate_put),
  3372. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  3373. mi2s_rx_sample_rate_get,
  3374. mi2s_rx_sample_rate_put),
  3375. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  3376. mi2s_rx_sample_rate_get,
  3377. mi2s_rx_sample_rate_put),
  3378. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  3379. mi2s_rx_sample_rate_get,
  3380. mi2s_rx_sample_rate_put),
  3381. SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
  3382. mi2s_rx_sample_rate_get,
  3383. mi2s_rx_sample_rate_put),
  3384. SOC_ENUM_EXT("QUIN_MI2S_RX SampleRate", quin_mi2s_rx_sample_rate,
  3385. mi2s_rx_sample_rate_get,
  3386. mi2s_rx_sample_rate_put),
  3387. SOC_ENUM_EXT("SEN_MI2S_RX SampleRate", sen_mi2s_rx_sample_rate,
  3388. mi2s_rx_sample_rate_get,
  3389. mi2s_rx_sample_rate_put),
  3390. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  3391. mi2s_tx_sample_rate_get,
  3392. mi2s_tx_sample_rate_put),
  3393. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  3394. mi2s_tx_sample_rate_get,
  3395. mi2s_tx_sample_rate_put),
  3396. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  3397. mi2s_tx_sample_rate_get,
  3398. mi2s_tx_sample_rate_put),
  3399. SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
  3400. mi2s_tx_sample_rate_get,
  3401. mi2s_tx_sample_rate_put),
  3402. SOC_ENUM_EXT("QUIN_MI2S_TX SampleRate", quin_mi2s_tx_sample_rate,
  3403. mi2s_tx_sample_rate_get,
  3404. mi2s_tx_sample_rate_put),
  3405. SOC_ENUM_EXT("SEN_MI2S_TX SampleRate", sen_mi2s_tx_sample_rate,
  3406. mi2s_tx_sample_rate_get,
  3407. mi2s_tx_sample_rate_put),
  3408. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  3409. usb_audio_rx_format_get, usb_audio_rx_format_put),
  3410. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  3411. usb_audio_tx_format_get, usb_audio_tx_format_put),
  3412. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  3413. tdm_rx_format_get,
  3414. tdm_rx_format_put),
  3415. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  3416. tdm_rx_format_get,
  3417. tdm_rx_format_put),
  3418. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  3419. tdm_rx_format_get,
  3420. tdm_rx_format_put),
  3421. SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
  3422. tdm_rx_format_get,
  3423. tdm_rx_format_put),
  3424. SOC_ENUM_EXT("QUIN_TDM_RX_0 Format", tdm_rx_format,
  3425. tdm_rx_format_get,
  3426. tdm_rx_format_put),
  3427. SOC_ENUM_EXT("SEN_TDM_RX_0 Format", tdm_rx_format,
  3428. tdm_rx_format_get,
  3429. tdm_rx_format_put),
  3430. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  3431. tdm_tx_format_get,
  3432. tdm_tx_format_put),
  3433. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  3434. tdm_tx_format_get,
  3435. tdm_tx_format_put),
  3436. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  3437. tdm_tx_format_get,
  3438. tdm_tx_format_put),
  3439. SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
  3440. tdm_tx_format_get,
  3441. tdm_tx_format_put),
  3442. SOC_ENUM_EXT("QUIN_TDM_TX_0 Format", tdm_tx_format,
  3443. tdm_tx_format_get,
  3444. tdm_tx_format_put),
  3445. SOC_ENUM_EXT("SEN_TDM_TX_0 Format", tdm_tx_format,
  3446. tdm_tx_format_get,
  3447. tdm_tx_format_put),
  3448. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3449. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3450. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  3451. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3452. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3453. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3454. SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3455. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3456. SOC_ENUM_EXT("QUIN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3457. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3458. SOC_ENUM_EXT("SEN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3459. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3460. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3461. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3462. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  3463. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3464. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3465. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3466. SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3467. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3468. SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3469. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3470. SOC_ENUM_EXT("SEN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3471. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3472. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  3473. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3474. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  3475. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3476. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  3477. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3478. SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
  3479. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3480. SOC_ENUM_EXT("QUIN_MI2S_RX Format", mi2s_rx_format,
  3481. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3482. SOC_ENUM_EXT("SEN_MI2S_RX Format", mi2s_rx_format,
  3483. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3484. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  3485. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3486. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  3487. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3488. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  3489. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3490. SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
  3491. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3492. SOC_ENUM_EXT("QUIN_MI2S_TX Format", mi2s_tx_format,
  3493. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3494. SOC_ENUM_EXT("SEN_MI2S_TX Format", mi2s_tx_format,
  3495. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3496. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  3497. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  3498. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  3499. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  3500. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  3501. proxy_rx_ch_get, proxy_rx_ch_put),
  3502. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  3503. tdm_rx_ch_get,
  3504. tdm_rx_ch_put),
  3505. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  3506. tdm_rx_ch_get,
  3507. tdm_rx_ch_put),
  3508. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  3509. tdm_rx_ch_get,
  3510. tdm_rx_ch_put),
  3511. SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
  3512. tdm_rx_ch_get,
  3513. tdm_rx_ch_put),
  3514. SOC_ENUM_EXT("QUIN_TDM_RX_0 Channels", tdm_rx_chs,
  3515. tdm_rx_ch_get,
  3516. tdm_rx_ch_put),
  3517. SOC_ENUM_EXT("SEN_TDM_RX_0 Channels", tdm_rx_chs,
  3518. tdm_rx_ch_get,
  3519. tdm_rx_ch_put),
  3520. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  3521. tdm_tx_ch_get,
  3522. tdm_tx_ch_put),
  3523. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  3524. tdm_tx_ch_get,
  3525. tdm_tx_ch_put),
  3526. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  3527. tdm_tx_ch_get,
  3528. tdm_tx_ch_put),
  3529. SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
  3530. tdm_tx_ch_get,
  3531. tdm_tx_ch_put),
  3532. SOC_ENUM_EXT("QUIN_TDM_TX_0 Channels", tdm_tx_chs,
  3533. tdm_tx_ch_get,
  3534. tdm_tx_ch_put),
  3535. SOC_ENUM_EXT("SEN_TDM_TX_0 Channels", tdm_tx_chs,
  3536. tdm_tx_ch_get,
  3537. tdm_tx_ch_put),
  3538. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  3539. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3540. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  3541. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3542. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  3543. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3544. SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
  3545. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3546. SOC_ENUM_EXT("QUIN_MI2S_RX Channels", quin_mi2s_rx_chs,
  3547. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3548. SOC_ENUM_EXT("SEN_MI2S_RX Channels", sen_mi2s_rx_chs,
  3549. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3550. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  3551. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3552. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  3553. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3554. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  3555. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3556. SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
  3557. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3558. SOC_ENUM_EXT("QUIN_MI2S_TX Channels", quin_mi2s_tx_chs,
  3559. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3560. SOC_ENUM_EXT("SEN_MI2S_TX Channels", sen_mi2s_tx_chs,
  3561. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3562. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  3563. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  3564. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  3565. ext_disp_rx_format_get, ext_disp_rx_format_put),
  3566. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  3567. ext_disp_rx_sample_rate_get,
  3568. ext_disp_rx_sample_rate_put),
  3569. SOC_ENUM_EXT("Display Port1 RX Channels", ext_disp_rx_chs,
  3570. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  3571. SOC_ENUM_EXT("Display Port1 RX Bit Format", ext_disp_rx_format,
  3572. ext_disp_rx_format_get, ext_disp_rx_format_put),
  3573. SOC_ENUM_EXT("Display Port1 RX SampleRate", ext_disp_rx_sample_rate,
  3574. ext_disp_rx_sample_rate_get,
  3575. ext_disp_rx_sample_rate_put),
  3576. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  3577. msm_bt_sample_rate_get,
  3578. msm_bt_sample_rate_put),
  3579. SOC_ENUM_EXT("BT SampleRate RX", bt_sample_rate_rx,
  3580. msm_bt_sample_rate_rx_get,
  3581. msm_bt_sample_rate_rx_put),
  3582. SOC_ENUM_EXT("BT SampleRate TX", bt_sample_rate_tx,
  3583. msm_bt_sample_rate_tx_get,
  3584. msm_bt_sample_rate_tx_put),
  3585. SOC_ENUM_EXT("AFE_LOOPBACK_TX Channels", afe_loopback_tx_chs,
  3586. afe_loopback_tx_ch_get, afe_loopback_tx_ch_put),
  3587. SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
  3588. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  3589. SOC_SINGLE_MULTI_EXT("TDM Slot Map", SND_SOC_NOPM, 0, 255, 0,
  3590. TDM_MAX_SLOTS + MAX_PATH, NULL, tdm_slot_map_put),
  3591. };
  3592. static const struct snd_kcontrol_new msm_snd_controls[] = {
  3593. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3594. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3595. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3596. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3597. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3598. aux_pcm_rx_sample_rate_get,
  3599. aux_pcm_rx_sample_rate_put),
  3600. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3601. aux_pcm_tx_sample_rate_get,
  3602. aux_pcm_tx_sample_rate_put),
  3603. };
  3604. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  3605. {
  3606. int idx;
  3607. switch (be_id) {
  3608. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3609. idx = EXT_DISP_RX_IDX_DP;
  3610. break;
  3611. case MSM_BACKEND_DAI_DISPLAY_PORT_RX_1:
  3612. idx = EXT_DISP_RX_IDX_DP1;
  3613. break;
  3614. default:
  3615. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  3616. idx = -EINVAL;
  3617. break;
  3618. }
  3619. return idx;
  3620. }
  3621. static int lahaina_send_island_va_config(int32_t be_id)
  3622. {
  3623. int rc = 0;
  3624. int port_id = 0xFFFF;
  3625. port_id = msm_get_port_id(be_id);
  3626. if (port_id < 0) {
  3627. pr_err("%s: Invalid island interface, be_id: %d\n",
  3628. __func__, be_id);
  3629. rc = -EINVAL;
  3630. } else {
  3631. /*
  3632. * send island mode config
  3633. * This should be the first configuration
  3634. */
  3635. rc = afe_send_port_island_mode(port_id);
  3636. if (rc)
  3637. pr_err("%s: afe send island mode failed %d\n",
  3638. __func__, rc);
  3639. }
  3640. return rc;
  3641. }
  3642. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  3643. struct snd_pcm_hw_params *params)
  3644. {
  3645. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3646. struct snd_interval *rate = hw_param_interval(params,
  3647. SNDRV_PCM_HW_PARAM_RATE);
  3648. struct snd_interval *channels = hw_param_interval(params,
  3649. SNDRV_PCM_HW_PARAM_CHANNELS);
  3650. int idx = 0, rc = 0;
  3651. pr_debug("%s: dai_id= %d, format = %d, rate = %d\n",
  3652. __func__, dai_link->id, params_format(params),
  3653. params_rate(params));
  3654. switch (dai_link->id) {
  3655. case MSM_BACKEND_DAI_USB_RX:
  3656. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3657. usb_rx_cfg.bit_format);
  3658. rate->min = rate->max = usb_rx_cfg.sample_rate;
  3659. channels->min = channels->max = usb_rx_cfg.channels;
  3660. break;
  3661. case MSM_BACKEND_DAI_USB_TX:
  3662. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3663. usb_tx_cfg.bit_format);
  3664. rate->min = rate->max = usb_tx_cfg.sample_rate;
  3665. channels->min = channels->max = usb_tx_cfg.channels;
  3666. break;
  3667. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3668. case MSM_BACKEND_DAI_DISPLAY_PORT_RX_1:
  3669. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  3670. if (idx < 0) {
  3671. pr_err("%s: Incorrect ext disp idx %d\n",
  3672. __func__, idx);
  3673. rc = idx;
  3674. goto done;
  3675. }
  3676. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3677. ext_disp_rx_cfg[idx].bit_format);
  3678. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  3679. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  3680. break;
  3681. case MSM_BACKEND_DAI_AFE_PCM_RX:
  3682. channels->min = channels->max = proxy_rx_cfg.channels;
  3683. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3684. break;
  3685. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  3686. channels->min = channels->max =
  3687. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  3688. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3689. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  3690. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  3691. break;
  3692. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  3693. channels->min = channels->max =
  3694. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3695. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3696. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  3697. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  3698. break;
  3699. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  3700. channels->min = channels->max =
  3701. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  3702. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3703. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  3704. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  3705. break;
  3706. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  3707. channels->min = channels->max =
  3708. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3709. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3710. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  3711. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  3712. break;
  3713. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  3714. channels->min = channels->max =
  3715. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  3716. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3717. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  3718. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  3719. break;
  3720. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  3721. channels->min = channels->max =
  3722. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3723. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3724. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  3725. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  3726. break;
  3727. case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
  3728. channels->min = channels->max =
  3729. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  3730. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3731. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  3732. rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3733. break;
  3734. case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
  3735. channels->min = channels->max =
  3736. tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  3737. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3738. tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
  3739. rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3740. break;
  3741. case MSM_BACKEND_DAI_QUIN_TDM_RX_0:
  3742. channels->min = channels->max =
  3743. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  3744. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3745. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  3746. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3747. break;
  3748. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  3749. channels->min = channels->max =
  3750. tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  3751. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3752. tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
  3753. rate->min = rate->max = tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3754. break;
  3755. case MSM_BACKEND_DAI_SEN_TDM_RX_0:
  3756. channels->min = channels->max =
  3757. tdm_rx_cfg[TDM_SEN][TDM_0].channels;
  3758. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3759. tdm_rx_cfg[TDM_SEN][TDM_0].bit_format);
  3760. rate->min = rate->max = tdm_rx_cfg[TDM_SEN][TDM_0].sample_rate;
  3761. break;
  3762. case MSM_BACKEND_DAI_SEN_TDM_TX_0:
  3763. channels->min = channels->max =
  3764. tdm_tx_cfg[TDM_SEN][TDM_0].channels;
  3765. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3766. tdm_tx_cfg[TDM_SEN][TDM_0].bit_format);
  3767. rate->min = rate->max = tdm_tx_cfg[TDM_SEN][TDM_0].sample_rate;
  3768. break;
  3769. case MSM_BACKEND_DAI_AUXPCM_RX:
  3770. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3771. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  3772. rate->min = rate->max =
  3773. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  3774. channels->min = channels->max =
  3775. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  3776. break;
  3777. case MSM_BACKEND_DAI_AUXPCM_TX:
  3778. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3779. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  3780. rate->min = rate->max =
  3781. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  3782. channels->min = channels->max =
  3783. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  3784. break;
  3785. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  3786. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3787. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  3788. rate->min = rate->max =
  3789. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  3790. channels->min = channels->max =
  3791. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  3792. break;
  3793. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  3794. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3795. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  3796. rate->min = rate->max =
  3797. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  3798. channels->min = channels->max =
  3799. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  3800. break;
  3801. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  3802. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3803. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  3804. rate->min = rate->max =
  3805. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  3806. channels->min = channels->max =
  3807. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  3808. break;
  3809. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  3810. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3811. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  3812. rate->min = rate->max =
  3813. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  3814. channels->min = channels->max =
  3815. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  3816. break;
  3817. case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
  3818. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3819. aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
  3820. rate->min = rate->max =
  3821. aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
  3822. channels->min = channels->max =
  3823. aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
  3824. break;
  3825. case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
  3826. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3827. aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
  3828. rate->min = rate->max =
  3829. aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
  3830. channels->min = channels->max =
  3831. aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
  3832. break;
  3833. case MSM_BACKEND_DAI_QUIN_AUXPCM_RX:
  3834. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3835. aux_pcm_rx_cfg[QUIN_AUX_PCM].bit_format);
  3836. rate->min = rate->max =
  3837. aux_pcm_rx_cfg[QUIN_AUX_PCM].sample_rate;
  3838. channels->min = channels->max =
  3839. aux_pcm_rx_cfg[QUIN_AUX_PCM].channels;
  3840. break;
  3841. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  3842. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3843. aux_pcm_tx_cfg[QUIN_AUX_PCM].bit_format);
  3844. rate->min = rate->max =
  3845. aux_pcm_tx_cfg[QUIN_AUX_PCM].sample_rate;
  3846. channels->min = channels->max =
  3847. aux_pcm_tx_cfg[QUIN_AUX_PCM].channels;
  3848. break;
  3849. case MSM_BACKEND_DAI_SEN_AUXPCM_RX:
  3850. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3851. aux_pcm_rx_cfg[SEN_AUX_PCM].bit_format);
  3852. rate->min = rate->max =
  3853. aux_pcm_rx_cfg[SEN_AUX_PCM].sample_rate;
  3854. channels->min = channels->max =
  3855. aux_pcm_rx_cfg[SEN_AUX_PCM].channels;
  3856. break;
  3857. case MSM_BACKEND_DAI_SEN_AUXPCM_TX:
  3858. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3859. aux_pcm_tx_cfg[SEN_AUX_PCM].bit_format);
  3860. rate->min = rate->max =
  3861. aux_pcm_tx_cfg[SEN_AUX_PCM].sample_rate;
  3862. channels->min = channels->max =
  3863. aux_pcm_tx_cfg[SEN_AUX_PCM].channels;
  3864. break;
  3865. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  3866. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3867. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  3868. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  3869. channels->min = channels->max =
  3870. mi2s_rx_cfg[PRIM_MI2S].channels;
  3871. break;
  3872. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  3873. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3874. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  3875. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  3876. channels->min = channels->max =
  3877. mi2s_tx_cfg[PRIM_MI2S].channels;
  3878. break;
  3879. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  3880. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3881. mi2s_rx_cfg[SEC_MI2S].bit_format);
  3882. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  3883. channels->min = channels->max =
  3884. mi2s_rx_cfg[SEC_MI2S].channels;
  3885. break;
  3886. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  3887. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3888. mi2s_tx_cfg[SEC_MI2S].bit_format);
  3889. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  3890. channels->min = channels->max =
  3891. mi2s_tx_cfg[SEC_MI2S].channels;
  3892. break;
  3893. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  3894. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3895. mi2s_rx_cfg[TERT_MI2S].bit_format);
  3896. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  3897. channels->min = channels->max =
  3898. mi2s_rx_cfg[TERT_MI2S].channels;
  3899. break;
  3900. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  3901. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3902. mi2s_tx_cfg[TERT_MI2S].bit_format);
  3903. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  3904. channels->min = channels->max =
  3905. mi2s_tx_cfg[TERT_MI2S].channels;
  3906. break;
  3907. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  3908. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3909. mi2s_rx_cfg[QUAT_MI2S].bit_format);
  3910. rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
  3911. channels->min = channels->max =
  3912. mi2s_rx_cfg[QUAT_MI2S].channels;
  3913. break;
  3914. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  3915. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3916. mi2s_tx_cfg[QUAT_MI2S].bit_format);
  3917. rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
  3918. channels->min = channels->max =
  3919. mi2s_tx_cfg[QUAT_MI2S].channels;
  3920. break;
  3921. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  3922. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3923. mi2s_rx_cfg[QUIN_MI2S].bit_format);
  3924. rate->min = rate->max = mi2s_rx_cfg[QUIN_MI2S].sample_rate;
  3925. channels->min = channels->max =
  3926. mi2s_rx_cfg[QUIN_MI2S].channels;
  3927. break;
  3928. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  3929. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3930. mi2s_tx_cfg[QUIN_MI2S].bit_format);
  3931. rate->min = rate->max = mi2s_tx_cfg[QUIN_MI2S].sample_rate;
  3932. channels->min = channels->max =
  3933. mi2s_tx_cfg[QUIN_MI2S].channels;
  3934. break;
  3935. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  3936. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3937. mi2s_rx_cfg[SEN_MI2S].bit_format);
  3938. rate->min = rate->max = mi2s_rx_cfg[SEN_MI2S].sample_rate;
  3939. channels->min = channels->max =
  3940. mi2s_rx_cfg[SEN_MI2S].channels;
  3941. break;
  3942. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  3943. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3944. mi2s_tx_cfg[SEN_MI2S].bit_format);
  3945. rate->min = rate->max = mi2s_tx_cfg[SEN_MI2S].sample_rate;
  3946. channels->min = channels->max =
  3947. mi2s_tx_cfg[SEN_MI2S].channels;
  3948. break;
  3949. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3950. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3951. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  3952. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  3953. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  3954. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  3955. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3956. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3957. cdc_dma_rx_cfg[idx].bit_format);
  3958. rate->min = rate->max = cdc_dma_rx_cfg[idx].sample_rate;
  3959. channels->min = channels->max = cdc_dma_rx_cfg[idx].channels;
  3960. break;
  3961. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3962. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3963. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  3964. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  3965. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  3966. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3967. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3968. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  3969. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3970. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3971. cdc_dma_tx_cfg[idx].bit_format);
  3972. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  3973. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  3974. break;
  3975. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3976. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3977. SNDRV_PCM_FORMAT_S32_LE);
  3978. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  3979. channels->min = channels->max = msm_vi_feed_tx_ch;
  3980. break;
  3981. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  3982. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3983. slim_rx_cfg[SLIM_RX_7].bit_format);
  3984. rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
  3985. channels->min = channels->max =
  3986. slim_rx_cfg[SLIM_RX_7].channels;
  3987. break;
  3988. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  3989. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3990. slim_tx_cfg[SLIM_TX_7].bit_format);
  3991. rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
  3992. channels->min = channels->max =
  3993. slim_tx_cfg[SLIM_TX_7].channels;
  3994. break;
  3995. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  3996. rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
  3997. channels->min = channels->max =
  3998. slim_tx_cfg[SLIM_TX_8].channels;
  3999. break;
  4000. case MSM_BACKEND_DAI_AFE_LOOPBACK_TX:
  4001. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4002. afe_loopback_tx_cfg[idx].bit_format);
  4003. rate->min = rate->max = afe_loopback_tx_cfg[idx].sample_rate;
  4004. channels->min = channels->max =
  4005. afe_loopback_tx_cfg[idx].channels;
  4006. break;
  4007. default:
  4008. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  4009. break;
  4010. }
  4011. done:
  4012. return rc;
  4013. }
  4014. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  4015. {
  4016. struct snd_soc_card *card = component->card;
  4017. struct msm_asoc_mach_data *pdata =
  4018. snd_soc_card_get_drvdata(card);
  4019. if (!pdata->fsa_handle)
  4020. return false;
  4021. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  4022. }
  4023. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  4024. {
  4025. int value = 0;
  4026. bool ret = false;
  4027. struct snd_soc_card *card;
  4028. struct msm_asoc_mach_data *pdata;
  4029. if (!component) {
  4030. pr_err("%s component is NULL\n", __func__);
  4031. return false;
  4032. }
  4033. card = component->card;
  4034. pdata = snd_soc_card_get_drvdata(card);
  4035. if (!pdata)
  4036. return false;
  4037. if (wcd_mbhc_cfg.enable_usbc_analog)
  4038. return msm_usbc_swap_gnd_mic(component, active);
  4039. /* if usbc is not defined, swap using us_euro_gpio_p */
  4040. if (pdata->us_euro_gpio_p) {
  4041. value = msm_cdc_pinctrl_get_state(
  4042. pdata->us_euro_gpio_p);
  4043. if (value)
  4044. msm_cdc_pinctrl_select_sleep_state(
  4045. pdata->us_euro_gpio_p);
  4046. else
  4047. msm_cdc_pinctrl_select_active_state(
  4048. pdata->us_euro_gpio_p);
  4049. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  4050. __func__, value, !value);
  4051. ret = true;
  4052. }
  4053. return ret;
  4054. }
  4055. static int lahaina_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  4056. struct snd_pcm_hw_params *params)
  4057. {
  4058. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4059. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4060. int ret = 0;
  4061. int slot_width = TDM_SLOT_WIDTH_BITS;
  4062. int channels, slots = TDM_MAX_SLOTS;
  4063. unsigned int slot_mask, rate, clk_freq;
  4064. unsigned int *slot_offset;
  4065. struct tdm_dev_config *config;
  4066. unsigned int path_dir = 0, interface = 0, channel_interface = 0;
  4067. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  4068. if (cpu_dai->id < AFE_PORT_ID_TDM_PORT_RANGE_START) {
  4069. pr_err("%s: dai id 0x%x not supported\n",
  4070. __func__, cpu_dai->id);
  4071. return -EINVAL;
  4072. }
  4073. /* RX or TX */
  4074. path_dir = cpu_dai->id % MAX_PATH;
  4075. /* PRI, SEC, TERT, QUAT, QUIN, ... */
  4076. interface = (cpu_dai->id - AFE_PORT_ID_TDM_PORT_RANGE_START)
  4077. / (MAX_PATH * TDM_PORT_MAX);
  4078. /* 0, 1, 2, .. 7 */
  4079. channel_interface =
  4080. ((cpu_dai->id - AFE_PORT_ID_TDM_PORT_RANGE_START) / MAX_PATH)
  4081. % TDM_PORT_MAX;
  4082. pr_debug("%s: path dir: %u, interface %u, channel interface %u\n",
  4083. __func__, path_dir, interface, channel_interface);
  4084. config = ((struct tdm_dev_config *) tdm_cfg[interface]) +
  4085. (path_dir * TDM_PORT_MAX) + channel_interface;
  4086. slot_offset = config->tdm_slot_offset;
  4087. if (path_dir)
  4088. channels = tdm_tx_cfg[interface][channel_interface].channels;
  4089. else
  4090. channels = tdm_rx_cfg[interface][channel_interface].channels;
  4091. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4092. /*2 slot config - bits 0 and 1 set for the first two slots */
  4093. slot_mask = 0x0000FFFF >> (16 - slots);
  4094. pr_debug("%s: tdm rx slot_width %d slots %d slot_mask %x\n",
  4095. __func__, slot_width, slots, slot_mask);
  4096. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  4097. slots, slot_width);
  4098. if (ret < 0) {
  4099. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  4100. __func__, ret);
  4101. goto end;
  4102. }
  4103. pr_debug("%s: tdm rx channels: %d\n", __func__, channels);
  4104. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4105. 0, NULL, channels, slot_offset);
  4106. if (ret < 0) {
  4107. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  4108. __func__, ret);
  4109. goto end;
  4110. }
  4111. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4112. /*2 slot config - bits 0 and 1 set for the first two slots */
  4113. slot_mask = 0x0000FFFF >> (16 - slots);
  4114. pr_debug("%s: tdm tx slot_width %d slots %d slot_mask %x\n",
  4115. __func__, slot_width, slots, slot_mask);
  4116. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  4117. slots, slot_width);
  4118. if (ret < 0) {
  4119. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  4120. __func__, ret);
  4121. goto end;
  4122. }
  4123. pr_debug("%s: tdm tx channels: %d\n", __func__, channels);
  4124. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4125. channels, slot_offset, 0, NULL);
  4126. if (ret < 0) {
  4127. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  4128. __func__, ret);
  4129. goto end;
  4130. }
  4131. } else {
  4132. ret = -EINVAL;
  4133. pr_err("%s: invalid use case, err:%d\n",
  4134. __func__, ret);
  4135. goto end;
  4136. }
  4137. rate = params_rate(params);
  4138. clk_freq = rate * slot_width * slots;
  4139. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  4140. if (ret < 0)
  4141. pr_err("%s: failed to set tdm clk, err:%d\n",
  4142. __func__, ret);
  4143. end:
  4144. return ret;
  4145. }
  4146. static int msm_get_tdm_mode(u32 port_id)
  4147. {
  4148. int tdm_mode;
  4149. switch (port_id) {
  4150. case AFE_PORT_ID_PRIMARY_TDM_RX:
  4151. case AFE_PORT_ID_PRIMARY_TDM_TX:
  4152. tdm_mode = TDM_PRI;
  4153. break;
  4154. case AFE_PORT_ID_SECONDARY_TDM_RX:
  4155. case AFE_PORT_ID_SECONDARY_TDM_TX:
  4156. tdm_mode = TDM_SEC;
  4157. break;
  4158. case AFE_PORT_ID_TERTIARY_TDM_RX:
  4159. case AFE_PORT_ID_TERTIARY_TDM_TX:
  4160. tdm_mode = TDM_TERT;
  4161. break;
  4162. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  4163. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  4164. tdm_mode = TDM_QUAT;
  4165. break;
  4166. case AFE_PORT_ID_QUINARY_TDM_RX:
  4167. case AFE_PORT_ID_QUINARY_TDM_TX:
  4168. tdm_mode = TDM_QUIN;
  4169. break;
  4170. case AFE_PORT_ID_SENARY_TDM_RX:
  4171. case AFE_PORT_ID_SENARY_TDM_TX:
  4172. tdm_mode = TDM_SEN;
  4173. break;
  4174. default:
  4175. pr_err("%s: Invalid port id: %d\n", __func__, port_id);
  4176. tdm_mode = -EINVAL;
  4177. }
  4178. return tdm_mode;
  4179. }
  4180. static int lahaina_tdm_snd_startup(struct snd_pcm_substream *substream)
  4181. {
  4182. int ret = 0;
  4183. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4184. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4185. struct snd_soc_card *card = rtd->card;
  4186. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4187. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  4188. if (tdm_mode >= TDM_INTERFACE_MAX || tdm_mode < 0) {
  4189. ret = -EINVAL;
  4190. pr_err("%s: Invalid TDM interface %d\n",
  4191. __func__, ret);
  4192. return ret;
  4193. }
  4194. if (pdata->mi2s_gpio_p[tdm_mode]) {
  4195. if (atomic_read(&(pdata->mi2s_gpio_ref_count[tdm_mode]))
  4196. == 0) {
  4197. ret = msm_cdc_pinctrl_select_active_state(
  4198. pdata->mi2s_gpio_p[tdm_mode]);
  4199. if (ret) {
  4200. pr_err("%s: TDM GPIO pinctrl set active failed with %d\n",
  4201. __func__, ret);
  4202. goto done;
  4203. }
  4204. }
  4205. atomic_inc(&(pdata->mi2s_gpio_ref_count[tdm_mode]));
  4206. }
  4207. done:
  4208. return ret;
  4209. }
  4210. static void lahaina_tdm_snd_shutdown(struct snd_pcm_substream *substream)
  4211. {
  4212. int ret = 0;
  4213. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4214. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4215. struct snd_soc_card *card = rtd->card;
  4216. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4217. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  4218. if (tdm_mode >= TDM_INTERFACE_MAX || tdm_mode < 0) {
  4219. ret = -EINVAL;
  4220. pr_err("%s: Invalid TDM interface %d\n",
  4221. __func__, ret);
  4222. return;
  4223. }
  4224. if (pdata->mi2s_gpio_p[tdm_mode]) {
  4225. atomic_dec(&(pdata->mi2s_gpio_ref_count[tdm_mode]));
  4226. if (atomic_read(&(pdata->mi2s_gpio_ref_count[tdm_mode]))
  4227. == 0) {
  4228. ret = msm_cdc_pinctrl_select_sleep_state(
  4229. pdata->mi2s_gpio_p[tdm_mode]);
  4230. if (ret)
  4231. pr_err("%s: TDM GPIO pinctrl set sleep failed with %d\n",
  4232. __func__, ret);
  4233. }
  4234. }
  4235. }
  4236. static int lahaina_aux_snd_startup(struct snd_pcm_substream *substream)
  4237. {
  4238. int ret = 0;
  4239. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4240. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4241. struct snd_soc_card *card = rtd->card;
  4242. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4243. u32 aux_mode = cpu_dai->id - 1;
  4244. if (aux_mode >= AUX_PCM_MAX) {
  4245. ret = -EINVAL;
  4246. pr_err("%s: Invalid AUX interface %d\n",
  4247. __func__, ret);
  4248. return ret;
  4249. }
  4250. if (pdata->mi2s_gpio_p[aux_mode]) {
  4251. if (atomic_read(&(pdata->mi2s_gpio_ref_count[aux_mode]))
  4252. == 0) {
  4253. ret = msm_cdc_pinctrl_select_active_state(
  4254. pdata->mi2s_gpio_p[aux_mode]);
  4255. if (ret) {
  4256. pr_err("%s: AUX GPIO pinctrl set active failed with %d\n",
  4257. __func__, ret);
  4258. goto done;
  4259. }
  4260. }
  4261. atomic_inc(&(pdata->mi2s_gpio_ref_count[aux_mode]));
  4262. }
  4263. done:
  4264. return ret;
  4265. }
  4266. static void lahaina_aux_snd_shutdown(struct snd_pcm_substream *substream)
  4267. {
  4268. int ret = 0;
  4269. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4270. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4271. struct snd_soc_card *card = rtd->card;
  4272. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4273. u32 aux_mode = cpu_dai->id - 1;
  4274. if (aux_mode >= AUX_PCM_MAX) {
  4275. pr_err("%s: Invalid AUX interface %d\n",
  4276. __func__, ret);
  4277. return;
  4278. }
  4279. if (pdata->mi2s_gpio_p[aux_mode]) {
  4280. atomic_dec(&(pdata->mi2s_gpio_ref_count[aux_mode]));
  4281. if (atomic_read(&(pdata->mi2s_gpio_ref_count[aux_mode]))
  4282. == 0) {
  4283. ret = msm_cdc_pinctrl_select_sleep_state(
  4284. pdata->mi2s_gpio_p[aux_mode]);
  4285. if (ret)
  4286. pr_err("%s: AUX GPIO pinctrl set sleep failed with %d\n",
  4287. __func__, ret);
  4288. }
  4289. }
  4290. }
  4291. static int msm_snd_cdc_dma_startup(struct snd_pcm_substream *substream)
  4292. {
  4293. int ret = 0;
  4294. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4295. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4296. switch (dai_link->id) {
  4297. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4298. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4299. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4300. ret = lahaina_send_island_va_config(dai_link->id);
  4301. if (ret)
  4302. pr_err("%s: send island va cfg failed, err: %d\n",
  4303. __func__, ret);
  4304. break;
  4305. }
  4306. return ret;
  4307. }
  4308. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  4309. struct snd_pcm_hw_params *params)
  4310. {
  4311. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4312. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4313. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4314. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4315. int ret = 0;
  4316. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  4317. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4318. u32 user_set_tx_ch = 0;
  4319. u32 user_set_rx_ch = 0;
  4320. u32 ch_id;
  4321. ret = snd_soc_dai_get_channel_map(codec_dai,
  4322. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  4323. &rx_ch_cdc_dma);
  4324. if (ret < 0) {
  4325. pr_err("%s: failed to get codec chan map, err:%d\n",
  4326. __func__, ret);
  4327. goto err;
  4328. }
  4329. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4330. switch (dai_link->id) {
  4331. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4332. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4333. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4334. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4335. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4336. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  4337. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  4338. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  4339. {
  4340. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4341. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  4342. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  4343. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  4344. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4345. user_set_rx_ch, &rx_ch_cdc_dma);
  4346. if (ret < 0) {
  4347. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4348. __func__, ret);
  4349. goto err;
  4350. }
  4351. }
  4352. break;
  4353. }
  4354. } else {
  4355. switch (dai_link->id) {
  4356. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4357. {
  4358. user_set_tx_ch = msm_vi_feed_tx_ch;
  4359. }
  4360. break;
  4361. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4362. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4363. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4364. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4365. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4366. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4367. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4368. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4369. {
  4370. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4371. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  4372. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  4373. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  4374. }
  4375. break;
  4376. }
  4377. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  4378. &tx_ch_cdc_dma, 0, 0);
  4379. if (ret < 0) {
  4380. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4381. __func__, ret);
  4382. goto err;
  4383. }
  4384. }
  4385. err:
  4386. return ret;
  4387. }
  4388. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  4389. {
  4390. pr_debug("%s: TODO: add new QOS implementation\n", __func__);
  4391. return 0;
  4392. }
  4393. void mi2s_disable_audio_vote(struct snd_pcm_substream *substream)
  4394. {
  4395. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4396. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4397. int index = cpu_dai->id;
  4398. struct snd_soc_card *card = rtd->card;
  4399. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4400. int sample_rate = 0;
  4401. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4402. sample_rate = mi2s_rx_cfg[index].sample_rate;
  4403. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4404. sample_rate = mi2s_tx_cfg[index].sample_rate;
  4405. } else {
  4406. pr_err("%s: invalid stream %d\n", __func__, substream->stream);
  4407. return;
  4408. }
  4409. if (IS_MSM_INTERFACE_MI2S(index) && IS_FRACTIONAL(sample_rate)) {
  4410. if (pdata->lpass_audio_hw_vote != NULL) {
  4411. if (--pdata->core_audio_vote_count == 0) {
  4412. clk_disable_unprepare(
  4413. pdata->lpass_audio_hw_vote);
  4414. } else if (pdata->core_audio_vote_count < 0) {
  4415. pr_err("%s: audio vote mismatch\n", __func__);
  4416. pdata->core_audio_vote_count = 0;
  4417. }
  4418. } else {
  4419. pr_err("%s: Invalid lpass audio hw node\n", __func__);
  4420. }
  4421. }
  4422. }
  4423. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  4424. {
  4425. int ret = 0;
  4426. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4427. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4428. int index = cpu_dai->id;
  4429. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  4430. struct snd_soc_card *card = rtd->card;
  4431. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4432. int sample_rate = 0;
  4433. dev_dbg(rtd->card->dev,
  4434. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  4435. __func__, substream->name, substream->stream,
  4436. cpu_dai->name, cpu_dai->id);
  4437. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4438. ret = -EINVAL;
  4439. dev_err(rtd->card->dev,
  4440. "%s: CPU DAI id (%d) out of range\n",
  4441. __func__, cpu_dai->id);
  4442. goto err;
  4443. }
  4444. /*
  4445. * Mutex protection in case the same MI2S
  4446. * interface using for both TX and RX so
  4447. * that the same clock won't be enable twice.
  4448. */
  4449. mutex_lock(&mi2s_intf_conf[index].lock);
  4450. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4451. sample_rate = mi2s_rx_cfg[index].sample_rate;
  4452. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4453. sample_rate = mi2s_tx_cfg[index].sample_rate;
  4454. } else {
  4455. pr_err("%s: invalid stream %d\n", __func__, substream->stream);
  4456. ret = -EINVAL;
  4457. goto vote_err;
  4458. }
  4459. if (IS_MSM_INTERFACE_MI2S(index) && IS_FRACTIONAL(sample_rate)) {
  4460. if (pdata->lpass_audio_hw_vote == NULL) {
  4461. dev_err(rtd->card->dev, "%s: Invalid lpass audio hw node\n",
  4462. __func__);
  4463. ret = -EINVAL;
  4464. goto vote_err;
  4465. }
  4466. if (pdata->core_audio_vote_count == 0) {
  4467. ret = clk_prepare_enable(pdata->lpass_audio_hw_vote);
  4468. if (ret < 0) {
  4469. dev_err(rtd->card->dev, "%s: audio vote error\n",
  4470. __func__);
  4471. goto vote_err;
  4472. }
  4473. }
  4474. pdata->core_audio_vote_count++;
  4475. }
  4476. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  4477. /* Check if msm needs to provide the clock to the interface */
  4478. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  4479. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  4480. fmt = SND_SOC_DAIFMT_CBM_CFM;
  4481. }
  4482. ret = msm_mi2s_set_sclk(substream, true);
  4483. if (ret < 0) {
  4484. dev_err(rtd->card->dev,
  4485. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  4486. __func__, ret);
  4487. goto clean_up;
  4488. }
  4489. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  4490. if (ret < 0) {
  4491. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  4492. __func__, index, ret);
  4493. goto clk_off;
  4494. }
  4495. if (pdata->mi2s_gpio_p[index]) {
  4496. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4497. == 0) {
  4498. ret = msm_cdc_pinctrl_select_active_state(
  4499. pdata->mi2s_gpio_p[index]);
  4500. if (ret) {
  4501. pr_err("%s: MI2S GPIO pinctrl set active failed with %d\n",
  4502. __func__, ret);
  4503. goto clk_off;
  4504. }
  4505. }
  4506. atomic_inc(&(pdata->mi2s_gpio_ref_count[index]));
  4507. }
  4508. }
  4509. clk_off:
  4510. if (ret < 0)
  4511. msm_mi2s_set_sclk(substream, false);
  4512. clean_up:
  4513. if (ret < 0) {
  4514. mi2s_intf_conf[index].ref_cnt--;
  4515. mi2s_disable_audio_vote(substream);
  4516. }
  4517. vote_err:
  4518. mutex_unlock(&mi2s_intf_conf[index].lock);
  4519. err:
  4520. return ret;
  4521. }
  4522. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  4523. {
  4524. int ret = 0;
  4525. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4526. int index = rtd->cpu_dai->id;
  4527. struct snd_soc_card *card = rtd->card;
  4528. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4529. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  4530. substream->name, substream->stream);
  4531. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4532. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  4533. return;
  4534. }
  4535. mutex_lock(&mi2s_intf_conf[index].lock);
  4536. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  4537. if (pdata->mi2s_gpio_p[index]) {
  4538. atomic_dec(&(pdata->mi2s_gpio_ref_count[index]));
  4539. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4540. == 0) {
  4541. ret = msm_cdc_pinctrl_select_sleep_state(
  4542. pdata->mi2s_gpio_p[index]);
  4543. if (ret)
  4544. pr_err("%s: MI2S GPIO pinctrl set sleep failed with %d\n",
  4545. __func__, ret);
  4546. }
  4547. }
  4548. ret = msm_mi2s_set_sclk(substream, false);
  4549. if (ret < 0)
  4550. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  4551. __func__, index, ret);
  4552. }
  4553. mi2s_disable_audio_vote(substream);
  4554. mutex_unlock(&mi2s_intf_conf[index].lock);
  4555. }
  4556. static int msm_wcn_hw_params_lito(struct snd_pcm_substream *substream,
  4557. struct snd_pcm_hw_params *params)
  4558. {
  4559. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4560. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4561. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4562. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4563. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO];
  4564. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4565. int ret = 0;
  4566. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4567. codec_dai->name, codec_dai->id);
  4568. ret = snd_soc_dai_get_channel_map(codec_dai,
  4569. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4570. if (ret) {
  4571. dev_err(rtd->dev,
  4572. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4573. __func__, ret);
  4574. goto err;
  4575. }
  4576. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4577. __func__, tx_ch_cnt, dai_link->id);
  4578. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4579. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4580. if (ret)
  4581. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4582. __func__, ret);
  4583. err:
  4584. return ret;
  4585. }
  4586. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  4587. struct snd_pcm_hw_params *params)
  4588. {
  4589. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4590. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4591. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4592. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4593. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  4594. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4595. int ret = 0;
  4596. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4597. codec_dai->name, codec_dai->id);
  4598. ret = snd_soc_dai_get_channel_map(codec_dai,
  4599. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4600. if (ret) {
  4601. dev_err(rtd->dev,
  4602. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4603. __func__, ret);
  4604. goto err;
  4605. }
  4606. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4607. __func__, tx_ch_cnt, dai_link->id);
  4608. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4609. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4610. if (ret)
  4611. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4612. __func__, ret);
  4613. err:
  4614. return ret;
  4615. }
  4616. static struct snd_soc_ops lahaina_aux_be_ops = {
  4617. .startup = lahaina_aux_snd_startup,
  4618. .shutdown = lahaina_aux_snd_shutdown
  4619. };
  4620. static struct snd_soc_ops lahaina_tdm_be_ops = {
  4621. .hw_params = lahaina_tdm_snd_hw_params,
  4622. .startup = lahaina_tdm_snd_startup,
  4623. .shutdown = lahaina_tdm_snd_shutdown
  4624. };
  4625. static struct snd_soc_ops msm_mi2s_be_ops = {
  4626. .startup = msm_mi2s_snd_startup,
  4627. .shutdown = msm_mi2s_snd_shutdown,
  4628. };
  4629. static struct snd_soc_ops msm_fe_qos_ops = {
  4630. .prepare = msm_fe_qos_prepare,
  4631. };
  4632. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  4633. .startup = msm_snd_cdc_dma_startup,
  4634. .hw_params = msm_snd_cdc_dma_hw_params,
  4635. };
  4636. static struct snd_soc_ops msm_wcn_ops = {
  4637. .hw_params = msm_wcn_hw_params,
  4638. };
  4639. static struct snd_soc_ops msm_wcn_ops_lito = {
  4640. .hw_params = msm_wcn_hw_params_lito,
  4641. };
  4642. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  4643. struct snd_kcontrol *kcontrol, int event)
  4644. {
  4645. struct msm_asoc_mach_data *pdata = NULL;
  4646. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  4647. int ret = 0;
  4648. u32 dmic_idx;
  4649. int *dmic_gpio_cnt;
  4650. struct device_node *dmic_gpio;
  4651. char *wname;
  4652. wname = strpbrk(w->name, "012345");
  4653. if (!wname) {
  4654. dev_err(component->dev, "%s: widget not found\n", __func__);
  4655. return -EINVAL;
  4656. }
  4657. ret = kstrtouint(wname, 10, &dmic_idx);
  4658. if (ret < 0) {
  4659. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  4660. __func__);
  4661. return -EINVAL;
  4662. }
  4663. pdata = snd_soc_card_get_drvdata(component->card);
  4664. switch (dmic_idx) {
  4665. case 0:
  4666. case 1:
  4667. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  4668. dmic_gpio = pdata->dmic01_gpio_p;
  4669. break;
  4670. case 2:
  4671. case 3:
  4672. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  4673. dmic_gpio = pdata->dmic23_gpio_p;
  4674. break;
  4675. case 4:
  4676. case 5:
  4677. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  4678. dmic_gpio = pdata->dmic45_gpio_p;
  4679. break;
  4680. default:
  4681. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  4682. __func__);
  4683. return -EINVAL;
  4684. }
  4685. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  4686. __func__, event, dmic_idx, *dmic_gpio_cnt);
  4687. switch (event) {
  4688. case SND_SOC_DAPM_PRE_PMU:
  4689. (*dmic_gpio_cnt)++;
  4690. if (*dmic_gpio_cnt == 1) {
  4691. ret = msm_cdc_pinctrl_select_active_state(
  4692. dmic_gpio);
  4693. if (ret < 0) {
  4694. pr_err("%s: gpio set cannot be activated %sd",
  4695. __func__, "dmic_gpio");
  4696. return ret;
  4697. }
  4698. }
  4699. break;
  4700. case SND_SOC_DAPM_POST_PMD:
  4701. (*dmic_gpio_cnt)--;
  4702. if (*dmic_gpio_cnt == 0) {
  4703. ret = msm_cdc_pinctrl_select_sleep_state(
  4704. dmic_gpio);
  4705. if (ret < 0) {
  4706. pr_err("%s: gpio set cannot be de-activated %sd",
  4707. __func__, "dmic_gpio");
  4708. return ret;
  4709. }
  4710. }
  4711. break;
  4712. default:
  4713. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  4714. return -EINVAL;
  4715. }
  4716. return 0;
  4717. }
  4718. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  4719. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  4720. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  4721. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  4722. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  4723. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  4724. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  4725. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  4726. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  4727. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  4728. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  4729. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  4730. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  4731. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  4732. };
  4733. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  4734. {
  4735. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  4736. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  4737. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4738. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4739. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4740. }
  4741. static int msm_wcn_init_lito(struct snd_soc_pcm_runtime *rtd)
  4742. {
  4743. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  4744. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO] = {159, 160, 161};
  4745. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4746. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4747. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4748. }
  4749. static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
  4750. const char *name,
  4751. struct snd_info_entry *parent)
  4752. {
  4753. struct snd_info_entry *entry;
  4754. entry = snd_info_create_module_entry(mod, name, parent);
  4755. if (!entry)
  4756. return NULL;
  4757. entry->mode = S_IFDIR | 0555;
  4758. if (snd_info_register(entry) < 0) {
  4759. snd_info_free_entry(entry);
  4760. return NULL;
  4761. }
  4762. return entry;
  4763. }
  4764. static void *def_wcd_mbhc_cal(void)
  4765. {
  4766. void *wcd_mbhc_cal;
  4767. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  4768. u16 *btn_high;
  4769. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  4770. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  4771. if (!wcd_mbhc_cal)
  4772. return NULL;
  4773. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  4774. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  4775. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  4776. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  4777. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  4778. btn_high[0] = 75;
  4779. btn_high[1] = 150;
  4780. btn_high[2] = 237;
  4781. btn_high[3] = 500;
  4782. btn_high[4] = 500;
  4783. btn_high[5] = 500;
  4784. btn_high[6] = 500;
  4785. btn_high[7] = 500;
  4786. return wcd_mbhc_cal;
  4787. }
  4788. /* Digital audio interface glue - connects codec <---> CPU */
  4789. static struct snd_soc_dai_link msm_common_dai_links[] = {
  4790. /* FrontEnd DAI Links */
  4791. {/* hw:x,0 */
  4792. .name = MSM_DAILINK_NAME(Media1),
  4793. .stream_name = "MultiMedia1",
  4794. .dynamic = 1,
  4795. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  4796. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4797. #endif /* CONFIG_AUDIO_QGKI */
  4798. .dpcm_playback = 1,
  4799. .dpcm_capture = 1,
  4800. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4801. SND_SOC_DPCM_TRIGGER_POST},
  4802. .ignore_suspend = 1,
  4803. /* this dainlink has playback support */
  4804. .ignore_pmdown_time = 1,
  4805. .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
  4806. SND_SOC_DAILINK_REG(multimedia1),
  4807. },
  4808. {/* hw:x,1 */
  4809. .name = MSM_DAILINK_NAME(Media2),
  4810. .stream_name = "MultiMedia2",
  4811. .dynamic = 1,
  4812. .dpcm_playback = 1,
  4813. .dpcm_capture = 1,
  4814. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4815. SND_SOC_DPCM_TRIGGER_POST},
  4816. .ignore_suspend = 1,
  4817. /* this dainlink has playback support */
  4818. .ignore_pmdown_time = 1,
  4819. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  4820. SND_SOC_DAILINK_REG(multimedia2),
  4821. },
  4822. {/* hw:x,2 */
  4823. .name = "VoiceMMode1",
  4824. .stream_name = "VoiceMMode1",
  4825. .dynamic = 1,
  4826. .dpcm_playback = 1,
  4827. .dpcm_capture = 1,
  4828. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4829. SND_SOC_DPCM_TRIGGER_POST},
  4830. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4831. .ignore_suspend = 1,
  4832. .ignore_pmdown_time = 1,
  4833. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  4834. SND_SOC_DAILINK_REG(voicemmode1),
  4835. },
  4836. {/* hw:x,3 */
  4837. .name = "MSM VoIP",
  4838. .stream_name = "VoIP",
  4839. .dynamic = 1,
  4840. .dpcm_playback = 1,
  4841. .dpcm_capture = 1,
  4842. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4843. SND_SOC_DPCM_TRIGGER_POST},
  4844. .ignore_suspend = 1,
  4845. /* this dainlink has playback support */
  4846. .ignore_pmdown_time = 1,
  4847. .id = MSM_FRONTEND_DAI_VOIP,
  4848. SND_SOC_DAILINK_REG(msmvoip),
  4849. },
  4850. {/* hw:x,4 */
  4851. .name = MSM_DAILINK_NAME(ULL),
  4852. .stream_name = "MultiMedia3",
  4853. .dynamic = 1,
  4854. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  4855. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4856. #endif /* CONFIG_AUDIO_QGKI */
  4857. .dpcm_playback = 1,
  4858. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4859. SND_SOC_DPCM_TRIGGER_POST},
  4860. .ignore_suspend = 1,
  4861. /* this dainlink has playback support */
  4862. .ignore_pmdown_time = 1,
  4863. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  4864. SND_SOC_DAILINK_REG(multimedia3),
  4865. },
  4866. {/* hw:x,5 */
  4867. .name = "MSM AFE-PCM RX",
  4868. .stream_name = "AFE-PROXY RX",
  4869. .dpcm_playback = 1,
  4870. .ignore_suspend = 1,
  4871. /* this dainlink has playback support */
  4872. .ignore_pmdown_time = 1,
  4873. SND_SOC_DAILINK_REG(afepcm_rx),
  4874. },
  4875. {/* hw:x,6 */
  4876. .name = "MSM AFE-PCM TX",
  4877. .stream_name = "AFE-PROXY TX",
  4878. .dpcm_capture = 1,
  4879. .ignore_suspend = 1,
  4880. SND_SOC_DAILINK_REG(afepcm_tx),
  4881. },
  4882. {/* hw:x,7 */
  4883. .name = MSM_DAILINK_NAME(Compress1),
  4884. .stream_name = "Compress1",
  4885. .dynamic = 1,
  4886. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  4887. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  4888. #endif /* CONFIG_AUDIO_QGKI */
  4889. .dpcm_playback = 1,
  4890. .dpcm_capture = 1,
  4891. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4892. SND_SOC_DPCM_TRIGGER_POST},
  4893. .ignore_suspend = 1,
  4894. .ignore_pmdown_time = 1,
  4895. /* this dainlink has playback support */
  4896. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  4897. SND_SOC_DAILINK_REG(multimedia4),
  4898. },
  4899. /* Hostless PCM purpose */
  4900. {/* hw:x,8 */
  4901. .name = "AUXPCM Hostless",
  4902. .stream_name = "AUXPCM Hostless",
  4903. .dynamic = 1,
  4904. .dpcm_playback = 1,
  4905. .dpcm_capture = 1,
  4906. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4907. SND_SOC_DPCM_TRIGGER_POST},
  4908. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4909. .ignore_suspend = 1,
  4910. /* this dainlink has playback support */
  4911. .ignore_pmdown_time = 1,
  4912. SND_SOC_DAILINK_REG(auxpcm_hostless),
  4913. },
  4914. {/* hw:x,9 */
  4915. .name = MSM_DAILINK_NAME(LowLatency),
  4916. .stream_name = "MultiMedia5",
  4917. .dynamic = 1,
  4918. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  4919. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4920. #endif /* CONFIG_AUDIO_QGKI */
  4921. .dpcm_playback = 1,
  4922. .dpcm_capture = 1,
  4923. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4924. SND_SOC_DPCM_TRIGGER_POST},
  4925. .ignore_suspend = 1,
  4926. /* this dainlink has playback support */
  4927. .ignore_pmdown_time = 1,
  4928. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  4929. .ops = &msm_fe_qos_ops,
  4930. SND_SOC_DAILINK_REG(multimedia5),
  4931. },
  4932. {/* hw:x,10 */
  4933. .name = "Listen 1 Audio Service",
  4934. .stream_name = "Listen 1 Audio Service",
  4935. .dynamic = 1,
  4936. .dpcm_capture = 1,
  4937. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  4938. SND_SOC_DPCM_TRIGGER_POST },
  4939. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4940. .ignore_suspend = 1,
  4941. .id = MSM_FRONTEND_DAI_LSM1,
  4942. SND_SOC_DAILINK_REG(listen1),
  4943. },
  4944. /* Multiple Tunnel instances */
  4945. {/* hw:x,11 */
  4946. .name = MSM_DAILINK_NAME(Compress2),
  4947. .stream_name = "Compress2",
  4948. .dynamic = 1,
  4949. .dpcm_playback = 1,
  4950. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4951. SND_SOC_DPCM_TRIGGER_POST},
  4952. .ignore_suspend = 1,
  4953. .ignore_pmdown_time = 1,
  4954. /* this dainlink has playback support */
  4955. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  4956. SND_SOC_DAILINK_REG(multimedia7),
  4957. },
  4958. {/* hw:x,12 */
  4959. .name = MSM_DAILINK_NAME(MultiMedia10),
  4960. .stream_name = "MultiMedia10",
  4961. .dynamic = 1,
  4962. .dpcm_playback = 1,
  4963. .dpcm_capture = 1,
  4964. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4965. SND_SOC_DPCM_TRIGGER_POST},
  4966. .ignore_suspend = 1,
  4967. .ignore_pmdown_time = 1,
  4968. /* this dainlink has playback support */
  4969. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  4970. SND_SOC_DAILINK_REG(multimedia10),
  4971. },
  4972. {/* hw:x,13 */
  4973. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  4974. .stream_name = "MM_NOIRQ",
  4975. .dynamic = 1,
  4976. .dpcm_playback = 1,
  4977. .dpcm_capture = 1,
  4978. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4979. SND_SOC_DPCM_TRIGGER_POST},
  4980. .ignore_suspend = 1,
  4981. .ignore_pmdown_time = 1,
  4982. /* this dainlink has playback support */
  4983. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  4984. .ops = &msm_fe_qos_ops,
  4985. SND_SOC_DAILINK_REG(multimedia8),
  4986. },
  4987. /* HDMI Hostless */
  4988. {/* hw:x,14 */
  4989. .name = "HDMI_RX_HOSTLESS",
  4990. .stream_name = "HDMI_RX_HOSTLESS",
  4991. .dynamic = 1,
  4992. .dpcm_playback = 1,
  4993. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4994. SND_SOC_DPCM_TRIGGER_POST},
  4995. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4996. .ignore_suspend = 1,
  4997. .ignore_pmdown_time = 1,
  4998. SND_SOC_DAILINK_REG(hdmi_rx_hostless),
  4999. },
  5000. {/* hw:x,15 */
  5001. .name = "VoiceMMode2",
  5002. .stream_name = "VoiceMMode2",
  5003. .dynamic = 1,
  5004. .dpcm_playback = 1,
  5005. .dpcm_capture = 1,
  5006. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5007. SND_SOC_DPCM_TRIGGER_POST},
  5008. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5009. .ignore_suspend = 1,
  5010. .ignore_pmdown_time = 1,
  5011. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  5012. SND_SOC_DAILINK_REG(voicemmode2),
  5013. },
  5014. /* LSM FE */
  5015. {/* hw:x,16 */
  5016. .name = "Listen 2 Audio Service",
  5017. .stream_name = "Listen 2 Audio Service",
  5018. .dynamic = 1,
  5019. .dpcm_capture = 1,
  5020. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5021. SND_SOC_DPCM_TRIGGER_POST },
  5022. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5023. .ignore_suspend = 1,
  5024. .id = MSM_FRONTEND_DAI_LSM2,
  5025. SND_SOC_DAILINK_REG(listen2),
  5026. },
  5027. {/* hw:x,17 */
  5028. .name = "Listen 3 Audio Service",
  5029. .stream_name = "Listen 3 Audio Service",
  5030. .dynamic = 1,
  5031. .dpcm_capture = 1,
  5032. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5033. SND_SOC_DPCM_TRIGGER_POST },
  5034. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5035. .ignore_suspend = 1,
  5036. .id = MSM_FRONTEND_DAI_LSM3,
  5037. SND_SOC_DAILINK_REG(listen3),
  5038. },
  5039. {/* hw:x,18 */
  5040. .name = "Listen 4 Audio Service",
  5041. .stream_name = "Listen 4 Audio Service",
  5042. .dynamic = 1,
  5043. .dpcm_capture = 1,
  5044. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5045. SND_SOC_DPCM_TRIGGER_POST },
  5046. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5047. .ignore_suspend = 1,
  5048. .id = MSM_FRONTEND_DAI_LSM4,
  5049. SND_SOC_DAILINK_REG(listen4),
  5050. },
  5051. {/* hw:x,19 */
  5052. .name = "Listen 5 Audio Service",
  5053. .stream_name = "Listen 5 Audio Service",
  5054. .dynamic = 1,
  5055. .dpcm_capture = 1,
  5056. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5057. SND_SOC_DPCM_TRIGGER_POST },
  5058. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5059. .ignore_suspend = 1,
  5060. .id = MSM_FRONTEND_DAI_LSM5,
  5061. SND_SOC_DAILINK_REG(listen5),
  5062. },
  5063. {/* hw:x,20 */
  5064. .name = "Listen 6 Audio Service",
  5065. .stream_name = "Listen 6 Audio Service",
  5066. .dynamic = 1,
  5067. .dpcm_capture = 1,
  5068. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5069. SND_SOC_DPCM_TRIGGER_POST },
  5070. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5071. .ignore_suspend = 1,
  5072. .id = MSM_FRONTEND_DAI_LSM6,
  5073. SND_SOC_DAILINK_REG(listen6),
  5074. },
  5075. {/* hw:x,21 */
  5076. .name = "Listen 7 Audio Service",
  5077. .stream_name = "Listen 7 Audio Service",
  5078. .dynamic = 1,
  5079. .dpcm_capture = 1,
  5080. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5081. SND_SOC_DPCM_TRIGGER_POST },
  5082. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5083. .ignore_suspend = 1,
  5084. .id = MSM_FRONTEND_DAI_LSM7,
  5085. SND_SOC_DAILINK_REG(listen7),
  5086. },
  5087. {/* hw:x,22 */
  5088. .name = "Listen 8 Audio Service",
  5089. .stream_name = "Listen 8 Audio Service",
  5090. .dynamic = 1,
  5091. .dpcm_capture = 1,
  5092. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5093. SND_SOC_DPCM_TRIGGER_POST },
  5094. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5095. .ignore_suspend = 1,
  5096. .id = MSM_FRONTEND_DAI_LSM8,
  5097. SND_SOC_DAILINK_REG(listen8),
  5098. },
  5099. {/* hw:x,23 */
  5100. .name = MSM_DAILINK_NAME(Media9),
  5101. .stream_name = "MultiMedia9",
  5102. .dynamic = 1,
  5103. .dpcm_playback = 1,
  5104. .dpcm_capture = 1,
  5105. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5106. SND_SOC_DPCM_TRIGGER_POST},
  5107. .ignore_suspend = 1,
  5108. /* this dainlink has playback support */
  5109. .ignore_pmdown_time = 1,
  5110. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  5111. SND_SOC_DAILINK_REG(multimedia9),
  5112. },
  5113. {/* hw:x,24 */
  5114. .name = MSM_DAILINK_NAME(Compress4),
  5115. .stream_name = "Compress4",
  5116. .dynamic = 1,
  5117. .dpcm_playback = 1,
  5118. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5119. SND_SOC_DPCM_TRIGGER_POST},
  5120. .ignore_suspend = 1,
  5121. .ignore_pmdown_time = 1,
  5122. /* this dainlink has playback support */
  5123. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  5124. SND_SOC_DAILINK_REG(multimedia11),
  5125. },
  5126. {/* hw:x,25 */
  5127. .name = MSM_DAILINK_NAME(Compress5),
  5128. .stream_name = "Compress5",
  5129. .dynamic = 1,
  5130. .dpcm_playback = 1,
  5131. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5132. SND_SOC_DPCM_TRIGGER_POST},
  5133. .ignore_suspend = 1,
  5134. .ignore_pmdown_time = 1,
  5135. /* this dainlink has playback support */
  5136. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  5137. SND_SOC_DAILINK_REG(multimedia12),
  5138. },
  5139. {/* hw:x,26 */
  5140. .name = MSM_DAILINK_NAME(Compress6),
  5141. .stream_name = "Compress6",
  5142. .dynamic = 1,
  5143. .dpcm_playback = 1,
  5144. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5145. SND_SOC_DPCM_TRIGGER_POST},
  5146. .ignore_suspend = 1,
  5147. .ignore_pmdown_time = 1,
  5148. /* this dainlink has playback support */
  5149. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  5150. SND_SOC_DAILINK_REG(multimedia13),
  5151. },
  5152. {/* hw:x,27 */
  5153. .name = MSM_DAILINK_NAME(Compress7),
  5154. .stream_name = "Compress7",
  5155. .dynamic = 1,
  5156. .dpcm_playback = 1,
  5157. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5158. SND_SOC_DPCM_TRIGGER_POST},
  5159. .ignore_suspend = 1,
  5160. .ignore_pmdown_time = 1,
  5161. /* this dainlink has playback support */
  5162. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  5163. SND_SOC_DAILINK_REG(multimedia14),
  5164. },
  5165. {/* hw:x,28 */
  5166. .name = MSM_DAILINK_NAME(Compress8),
  5167. .stream_name = "Compress8",
  5168. .dynamic = 1,
  5169. .dpcm_playback = 1,
  5170. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5171. SND_SOC_DPCM_TRIGGER_POST},
  5172. .ignore_suspend = 1,
  5173. .ignore_pmdown_time = 1,
  5174. /* this dainlink has playback support */
  5175. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  5176. SND_SOC_DAILINK_REG(multimedia15),
  5177. },
  5178. {/* hw:x,29 */
  5179. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  5180. .stream_name = "MM_NOIRQ_2",
  5181. .dynamic = 1,
  5182. .dpcm_playback = 1,
  5183. .dpcm_capture = 1,
  5184. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5185. SND_SOC_DPCM_TRIGGER_POST},
  5186. .ignore_suspend = 1,
  5187. .ignore_pmdown_time = 1,
  5188. /* this dainlink has playback support */
  5189. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  5190. .ops = &msm_fe_qos_ops,
  5191. SND_SOC_DAILINK_REG(multimedia16),
  5192. },
  5193. {/* hw:x,30 */
  5194. .name = "CDC_DMA Hostless",
  5195. .stream_name = "CDC_DMA Hostless",
  5196. .dynamic = 1,
  5197. .dpcm_playback = 1,
  5198. .dpcm_capture = 1,
  5199. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5200. SND_SOC_DPCM_TRIGGER_POST},
  5201. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5202. .ignore_suspend = 1,
  5203. /* this dailink has playback support */
  5204. .ignore_pmdown_time = 1,
  5205. SND_SOC_DAILINK_REG(cdcdma_hostless),
  5206. },
  5207. {/* hw:x,31 */
  5208. .name = "TX3_CDC_DMA Hostless",
  5209. .stream_name = "TX3_CDC_DMA Hostless",
  5210. .dynamic = 1,
  5211. .dpcm_capture = 1,
  5212. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5213. SND_SOC_DPCM_TRIGGER_POST},
  5214. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5215. .ignore_suspend = 1,
  5216. SND_SOC_DAILINK_REG(tx3_cdcdma_hostless),
  5217. },
  5218. {/* hw:x,32 */
  5219. .name = "Tertiary MI2S TX_Hostless",
  5220. .stream_name = "Tertiary MI2S_TX Hostless Capture",
  5221. .dynamic = 1,
  5222. .dpcm_capture = 1,
  5223. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5224. SND_SOC_DPCM_TRIGGER_POST},
  5225. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5226. .ignore_suspend = 1,
  5227. .ignore_pmdown_time = 1,
  5228. SND_SOC_DAILINK_REG(tert_mi2s_tx_hostless),
  5229. },
  5230. };
  5231. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  5232. {/* hw:x,33 */
  5233. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  5234. .stream_name = "WSA CDC DMA0 Capture",
  5235. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  5236. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5237. .ignore_suspend = 1,
  5238. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5239. .ops = &msm_cdc_dma_be_ops,
  5240. SND_SOC_DAILINK_REG(wsa_cdcdma0_capture),
  5241. },
  5242. };
  5243. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  5244. {/* hw:x,34 */
  5245. .name = MSM_DAILINK_NAME(ASM Loopback),
  5246. .stream_name = "MultiMedia6",
  5247. .dynamic = 1,
  5248. .dpcm_playback = 1,
  5249. .dpcm_capture = 1,
  5250. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5251. SND_SOC_DPCM_TRIGGER_POST},
  5252. .ignore_suspend = 1,
  5253. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5254. .ignore_pmdown_time = 1,
  5255. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  5256. SND_SOC_DAILINK_REG(multimedia6),
  5257. },
  5258. {/* hw:x,35 */
  5259. .name = "USB Audio Hostless",
  5260. .stream_name = "USB Audio Hostless",
  5261. .dynamic = 1,
  5262. .dpcm_playback = 1,
  5263. .dpcm_capture = 1,
  5264. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5265. SND_SOC_DPCM_TRIGGER_POST},
  5266. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5267. .ignore_suspend = 1,
  5268. .ignore_pmdown_time = 1,
  5269. SND_SOC_DAILINK_REG(usbaudio_hostless),
  5270. },
  5271. {/* hw:x,36 */
  5272. .name = "SLIMBUS_7 Hostless",
  5273. .stream_name = "SLIMBUS_7 Hostless",
  5274. .dynamic = 1,
  5275. .dpcm_capture = 1,
  5276. .dpcm_playback = 1,
  5277. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5278. SND_SOC_DPCM_TRIGGER_POST},
  5279. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5280. .ignore_suspend = 1,
  5281. .ignore_pmdown_time = 1,
  5282. SND_SOC_DAILINK_REG(slimbus7_hostless),
  5283. },
  5284. {/* hw:x,37 */
  5285. .name = "Compress Capture",
  5286. .stream_name = "Compress9",
  5287. .dynamic = 1,
  5288. .dpcm_capture = 1,
  5289. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5290. SND_SOC_DPCM_TRIGGER_POST},
  5291. .ignore_suspend = 1,
  5292. .ignore_pmdown_time = 1,
  5293. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  5294. SND_SOC_DAILINK_REG(multimedia17),
  5295. },
  5296. {/* hw:x,38 */
  5297. .name = "SLIMBUS_8 Hostless",
  5298. .stream_name = "SLIMBUS_8 Hostless",
  5299. .dynamic = 1,
  5300. .dpcm_capture = 1,
  5301. .dpcm_playback = 1,
  5302. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5303. SND_SOC_DPCM_TRIGGER_POST},
  5304. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5305. .ignore_suspend = 1,
  5306. .ignore_pmdown_time = 1,
  5307. SND_SOC_DAILINK_REG(slimbus8_hostless),
  5308. },
  5309. {/* hw:x,39 */
  5310. .name = LPASS_BE_TX_CDC_DMA_TX_5,
  5311. .stream_name = "TX CDC DMA5 Capture",
  5312. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_5,
  5313. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5314. .ignore_suspend = 1,
  5315. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5316. .ops = &msm_cdc_dma_be_ops,
  5317. SND_SOC_DAILINK_REG(tx_cdcdma5_tx),
  5318. },
  5319. {/* hw:x,40 */
  5320. .name = MSM_DAILINK_NAME(Media31),
  5321. .stream_name = "MultiMedia31",
  5322. .dynamic = 1,
  5323. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5324. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5325. #endif /* CONFIG_AUDIO_QGKI */
  5326. .dpcm_playback = 1,
  5327. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5328. SND_SOC_DPCM_TRIGGER_POST},
  5329. .ignore_suspend = 1,
  5330. /* this dainlink has playback support */
  5331. .ignore_pmdown_time = 1,
  5332. .id = MSM_FRONTEND_DAI_MULTIMEDIA31,
  5333. SND_SOC_DAILINK_REG(multimedia31),
  5334. },
  5335. {/* hw:x,41 */
  5336. .name = MSM_DAILINK_NAME(Media32),
  5337. .stream_name = "MultiMedia32",
  5338. .dynamic = 1,
  5339. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5340. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5341. #endif /* CONFIG_AUDIO_QGKI */
  5342. .dpcm_playback = 1,
  5343. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5344. SND_SOC_DPCM_TRIGGER_POST},
  5345. .ignore_suspend = 1,
  5346. /* this dainlink has playback support */
  5347. .ignore_pmdown_time = 1,
  5348. .id = MSM_FRONTEND_DAI_MULTIMEDIA32,
  5349. SND_SOC_DAILINK_REG(multimedia32),
  5350. },
  5351. };
  5352. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  5353. /* Backend AFE DAI Links */
  5354. {
  5355. .name = LPASS_BE_AFE_PCM_RX,
  5356. .stream_name = "AFE Playback",
  5357. .no_pcm = 1,
  5358. .dpcm_playback = 1,
  5359. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  5360. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5361. /* this dainlink has playback support */
  5362. .ignore_pmdown_time = 1,
  5363. .ignore_suspend = 1,
  5364. SND_SOC_DAILINK_REG(afe_pcm_rx),
  5365. },
  5366. {
  5367. .name = LPASS_BE_AFE_PCM_TX,
  5368. .stream_name = "AFE Capture",
  5369. .no_pcm = 1,
  5370. .dpcm_capture = 1,
  5371. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  5372. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5373. .ignore_suspend = 1,
  5374. SND_SOC_DAILINK_REG(afe_pcm_tx),
  5375. },
  5376. /* Incall Record Uplink BACK END DAI Link */
  5377. {
  5378. .name = LPASS_BE_INCALL_RECORD_TX,
  5379. .stream_name = "Voice Uplink Capture",
  5380. .no_pcm = 1,
  5381. .dpcm_capture = 1,
  5382. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  5383. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5384. .ignore_suspend = 1,
  5385. SND_SOC_DAILINK_REG(incall_record_tx),
  5386. },
  5387. /* Incall Record Downlink BACK END DAI Link */
  5388. {
  5389. .name = LPASS_BE_INCALL_RECORD_RX,
  5390. .stream_name = "Voice Downlink Capture",
  5391. .no_pcm = 1,
  5392. .dpcm_capture = 1,
  5393. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  5394. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5395. .ignore_suspend = 1,
  5396. SND_SOC_DAILINK_REG(incall_record_rx),
  5397. },
  5398. /* Incall Music BACK END DAI Link */
  5399. {
  5400. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  5401. .stream_name = "Voice Farend Playback",
  5402. .no_pcm = 1,
  5403. .dpcm_playback = 1,
  5404. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  5405. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5406. .ignore_suspend = 1,
  5407. .ignore_pmdown_time = 1,
  5408. SND_SOC_DAILINK_REG(voice_playback_tx),
  5409. },
  5410. /* Incall Music 2 BACK END DAI Link */
  5411. {
  5412. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  5413. .stream_name = "Voice2 Farend Playback",
  5414. .no_pcm = 1,
  5415. .dpcm_playback = 1,
  5416. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  5417. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5418. .ignore_suspend = 1,
  5419. .ignore_pmdown_time = 1,
  5420. SND_SOC_DAILINK_REG(voice2_playback_tx),
  5421. },
  5422. /* Proxy Tx BACK END DAI Link */
  5423. {
  5424. .name = LPASS_BE_PROXY_TX,
  5425. .stream_name = "Proxy Capture",
  5426. .no_pcm = 1,
  5427. .dpcm_capture = 1,
  5428. .id = MSM_BACKEND_DAI_PROXY_TX,
  5429. .ignore_suspend = 1,
  5430. SND_SOC_DAILINK_REG(proxy_tx),
  5431. },
  5432. /* Proxy Rx BACK END DAI Link */
  5433. {
  5434. .name = LPASS_BE_PROXY_RX,
  5435. .stream_name = "Proxy Playback",
  5436. .no_pcm = 1,
  5437. .dpcm_playback = 1,
  5438. .id = MSM_BACKEND_DAI_PROXY_RX,
  5439. .ignore_pmdown_time = 1,
  5440. .ignore_suspend = 1,
  5441. SND_SOC_DAILINK_REG(proxy_rx),
  5442. },
  5443. {
  5444. .name = LPASS_BE_USB_AUDIO_RX,
  5445. .stream_name = "USB Audio Playback",
  5446. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5447. .dynamic_be = 1,
  5448. #endif /* CONFIG_AUDIO_QGKI */
  5449. .no_pcm = 1,
  5450. .dpcm_playback = 1,
  5451. .id = MSM_BACKEND_DAI_USB_RX,
  5452. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5453. .ignore_pmdown_time = 1,
  5454. .ignore_suspend = 1,
  5455. SND_SOC_DAILINK_REG(usb_audio_rx),
  5456. },
  5457. {
  5458. .name = LPASS_BE_USB_AUDIO_TX,
  5459. .stream_name = "USB Audio Capture",
  5460. .no_pcm = 1,
  5461. .dpcm_capture = 1,
  5462. .id = MSM_BACKEND_DAI_USB_TX,
  5463. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5464. .ignore_suspend = 1,
  5465. SND_SOC_DAILINK_REG(usb_audio_tx),
  5466. },
  5467. {
  5468. .name = LPASS_BE_PRI_TDM_RX_0,
  5469. .stream_name = "Primary TDM0 Playback",
  5470. .no_pcm = 1,
  5471. .dpcm_playback = 1,
  5472. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  5473. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5474. .ops = &lahaina_tdm_be_ops,
  5475. .ignore_suspend = 1,
  5476. .ignore_pmdown_time = 1,
  5477. SND_SOC_DAILINK_REG(pri_tdm_rx_0),
  5478. },
  5479. {
  5480. .name = LPASS_BE_PRI_TDM_TX_0,
  5481. .stream_name = "Primary TDM0 Capture",
  5482. .no_pcm = 1,
  5483. .dpcm_capture = 1,
  5484. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  5485. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5486. .ops = &lahaina_tdm_be_ops,
  5487. .ignore_suspend = 1,
  5488. SND_SOC_DAILINK_REG(pri_tdm_tx_0),
  5489. },
  5490. {
  5491. .name = LPASS_BE_SEC_TDM_RX_0,
  5492. .stream_name = "Secondary TDM0 Playback",
  5493. .no_pcm = 1,
  5494. .dpcm_playback = 1,
  5495. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  5496. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5497. .ops = &lahaina_tdm_be_ops,
  5498. .ignore_suspend = 1,
  5499. .ignore_pmdown_time = 1,
  5500. SND_SOC_DAILINK_REG(sec_tdm_rx_0),
  5501. },
  5502. {
  5503. .name = LPASS_BE_SEC_TDM_TX_0,
  5504. .stream_name = "Secondary TDM0 Capture",
  5505. .no_pcm = 1,
  5506. .dpcm_capture = 1,
  5507. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  5508. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5509. .ops = &lahaina_tdm_be_ops,
  5510. .ignore_suspend = 1,
  5511. SND_SOC_DAILINK_REG(sec_tdm_tx_0),
  5512. },
  5513. {
  5514. .name = LPASS_BE_TERT_TDM_RX_0,
  5515. .stream_name = "Tertiary TDM0 Playback",
  5516. .no_pcm = 1,
  5517. .dpcm_playback = 1,
  5518. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  5519. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5520. .ops = &lahaina_tdm_be_ops,
  5521. .ignore_suspend = 1,
  5522. .ignore_pmdown_time = 1,
  5523. SND_SOC_DAILINK_REG(tert_tdm_rx_0),
  5524. },
  5525. {
  5526. .name = LPASS_BE_TERT_TDM_TX_0,
  5527. .stream_name = "Tertiary TDM0 Capture",
  5528. .no_pcm = 1,
  5529. .dpcm_capture = 1,
  5530. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  5531. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5532. .ops = &lahaina_tdm_be_ops,
  5533. .ignore_suspend = 1,
  5534. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  5535. },
  5536. {
  5537. .name = LPASS_BE_QUAT_TDM_RX_0,
  5538. .stream_name = "Quaternary TDM0 Playback",
  5539. .no_pcm = 1,
  5540. .dpcm_playback = 1,
  5541. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  5542. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5543. .ops = &lahaina_tdm_be_ops,
  5544. .ignore_suspend = 1,
  5545. .ignore_pmdown_time = 1,
  5546. SND_SOC_DAILINK_REG(quat_tdm_rx_0),
  5547. },
  5548. {
  5549. .name = LPASS_BE_QUAT_TDM_TX_0,
  5550. .stream_name = "Quaternary TDM0 Capture",
  5551. .no_pcm = 1,
  5552. .dpcm_capture = 1,
  5553. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  5554. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5555. .ops = &lahaina_tdm_be_ops,
  5556. .ignore_suspend = 1,
  5557. SND_SOC_DAILINK_REG(quat_tdm_tx_0),
  5558. },
  5559. {
  5560. .name = LPASS_BE_QUIN_TDM_RX_0,
  5561. .stream_name = "Quinary TDM0 Playback",
  5562. .no_pcm = 1,
  5563. .dpcm_playback = 1,
  5564. .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0,
  5565. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5566. .ops = &lahaina_tdm_be_ops,
  5567. .ignore_suspend = 1,
  5568. .ignore_pmdown_time = 1,
  5569. SND_SOC_DAILINK_REG(quin_tdm_rx_0),
  5570. },
  5571. {
  5572. .name = LPASS_BE_QUIN_TDM_TX_0,
  5573. .stream_name = "Quinary TDM0 Capture",
  5574. .no_pcm = 1,
  5575. .dpcm_capture = 1,
  5576. .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0,
  5577. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5578. .ops = &lahaina_tdm_be_ops,
  5579. .ignore_suspend = 1,
  5580. SND_SOC_DAILINK_REG(quin_tdm_tx_0),
  5581. },
  5582. {
  5583. .name = LPASS_BE_SEN_TDM_RX_0,
  5584. .stream_name = "Senary TDM0 Playback",
  5585. .no_pcm = 1,
  5586. .dpcm_playback = 1,
  5587. .id = MSM_BACKEND_DAI_SEN_TDM_RX_0,
  5588. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5589. .ops = &lahaina_tdm_be_ops,
  5590. .ignore_suspend = 1,
  5591. .ignore_pmdown_time = 1,
  5592. SND_SOC_DAILINK_REG(sen_tdm_rx_0),
  5593. },
  5594. {
  5595. .name = LPASS_BE_SEN_TDM_TX_0,
  5596. .stream_name = "Senary TDM0 Capture",
  5597. .no_pcm = 1,
  5598. .dpcm_capture = 1,
  5599. .id = MSM_BACKEND_DAI_SEN_TDM_TX_0,
  5600. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5601. .ops = &lahaina_tdm_be_ops,
  5602. .ignore_suspend = 1,
  5603. SND_SOC_DAILINK_REG(sen_tdm_tx_0),
  5604. },
  5605. };
  5606. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  5607. {
  5608. .name = LPASS_BE_SLIMBUS_7_RX,
  5609. .stream_name = "Slimbus7 Playback",
  5610. .no_pcm = 1,
  5611. .dpcm_playback = 1,
  5612. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5613. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5614. .init = &msm_wcn_init,
  5615. .ops = &msm_wcn_ops,
  5616. /* dai link has playback support */
  5617. .ignore_pmdown_time = 1,
  5618. .ignore_suspend = 1,
  5619. SND_SOC_DAILINK_REG(slimbus_7_rx),
  5620. },
  5621. {
  5622. .name = LPASS_BE_SLIMBUS_7_TX,
  5623. .stream_name = "Slimbus7 Capture",
  5624. .no_pcm = 1,
  5625. .dpcm_capture = 1,
  5626. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5627. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5628. .ops = &msm_wcn_ops,
  5629. .ignore_suspend = 1,
  5630. SND_SOC_DAILINK_REG(slimbus_7_tx),
  5631. },
  5632. };
  5633. static struct snd_soc_dai_link msm_wcn_btfm_be_dai_links[] = {
  5634. {
  5635. .name = LPASS_BE_SLIMBUS_7_RX,
  5636. .stream_name = "Slimbus7 Playback",
  5637. .no_pcm = 1,
  5638. .dpcm_playback = 1,
  5639. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5640. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5641. .init = &msm_wcn_init_lito,
  5642. .ops = &msm_wcn_ops_lito,
  5643. /* dai link has playback support */
  5644. .ignore_pmdown_time = 1,
  5645. .ignore_suspend = 1,
  5646. SND_SOC_DAILINK_REG(slimbus_7_rx),
  5647. },
  5648. {
  5649. .name = LPASS_BE_SLIMBUS_7_TX,
  5650. .stream_name = "Slimbus7 Capture",
  5651. .no_pcm = 1,
  5652. .dpcm_capture = 1,
  5653. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5654. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5655. .ops = &msm_wcn_ops_lito,
  5656. .ignore_suspend = 1,
  5657. SND_SOC_DAILINK_REG(slimbus_7_tx),
  5658. },
  5659. {
  5660. .name = LPASS_BE_SLIMBUS_8_TX,
  5661. .stream_name = "Slimbus8 Capture",
  5662. .no_pcm = 1,
  5663. .dpcm_capture = 1,
  5664. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  5665. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5666. .ops = &msm_wcn_ops_lito,
  5667. .ignore_suspend = 1,
  5668. SND_SOC_DAILINK_REG(slimbus_8_tx),
  5669. },
  5670. };
  5671. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5672. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  5673. /* DISP PORT BACK END DAI Link */
  5674. {
  5675. .name = LPASS_BE_DISPLAY_PORT,
  5676. .stream_name = "Display Port Playback",
  5677. .no_pcm = 1,
  5678. .dpcm_playback = 1,
  5679. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  5680. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5681. .ignore_pmdown_time = 1,
  5682. .ignore_suspend = 1,
  5683. SND_SOC_DAILINK_REG(display_port),
  5684. },
  5685. /* DISP PORT 1 BACK END DAI Link */
  5686. {
  5687. .name = LPASS_BE_DISPLAY_PORT1,
  5688. .stream_name = "Display Port1 Playback",
  5689. .no_pcm = 1,
  5690. .dpcm_playback = 1,
  5691. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  5692. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5693. .ignore_pmdown_time = 1,
  5694. .ignore_suspend = 1,
  5695. SND_SOC_DAILINK_REG(display_port1),
  5696. },
  5697. };
  5698. #endif
  5699. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  5700. {
  5701. .name = LPASS_BE_PRI_MI2S_RX,
  5702. .stream_name = "Primary MI2S Playback",
  5703. .no_pcm = 1,
  5704. .dpcm_playback = 1,
  5705. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  5706. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5707. .ops = &msm_mi2s_be_ops,
  5708. .ignore_suspend = 1,
  5709. .ignore_pmdown_time = 1,
  5710. SND_SOC_DAILINK_REG(pri_mi2s_rx),
  5711. },
  5712. {
  5713. .name = LPASS_BE_PRI_MI2S_TX,
  5714. .stream_name = "Primary MI2S Capture",
  5715. .no_pcm = 1,
  5716. .dpcm_capture = 1,
  5717. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  5718. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5719. .ops = &msm_mi2s_be_ops,
  5720. .ignore_suspend = 1,
  5721. SND_SOC_DAILINK_REG(pri_mi2s_tx),
  5722. },
  5723. {
  5724. .name = LPASS_BE_SEC_MI2S_RX,
  5725. .stream_name = "Secondary MI2S Playback",
  5726. .no_pcm = 1,
  5727. .dpcm_playback = 1,
  5728. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  5729. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5730. .ops = &msm_mi2s_be_ops,
  5731. .ignore_suspend = 1,
  5732. .ignore_pmdown_time = 1,
  5733. SND_SOC_DAILINK_REG(sec_mi2s_rx),
  5734. },
  5735. {
  5736. .name = LPASS_BE_SEC_MI2S_TX,
  5737. .stream_name = "Secondary MI2S Capture",
  5738. .no_pcm = 1,
  5739. .dpcm_capture = 1,
  5740. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  5741. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5742. .ops = &msm_mi2s_be_ops,
  5743. .ignore_suspend = 1,
  5744. SND_SOC_DAILINK_REG(sec_mi2s_tx),
  5745. },
  5746. {
  5747. .name = LPASS_BE_TERT_MI2S_RX,
  5748. .stream_name = "Tertiary MI2S Playback",
  5749. .no_pcm = 1,
  5750. .dpcm_playback = 1,
  5751. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  5752. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5753. .ops = &msm_mi2s_be_ops,
  5754. .ignore_suspend = 1,
  5755. .ignore_pmdown_time = 1,
  5756. SND_SOC_DAILINK_REG(tert_mi2s_rx),
  5757. },
  5758. {
  5759. .name = LPASS_BE_TERT_MI2S_TX,
  5760. .stream_name = "Tertiary MI2S Capture",
  5761. .no_pcm = 1,
  5762. .dpcm_capture = 1,
  5763. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  5764. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5765. .ops = &msm_mi2s_be_ops,
  5766. .ignore_suspend = 1,
  5767. SND_SOC_DAILINK_REG(tert_mi2s_tx),
  5768. },
  5769. {
  5770. .name = LPASS_BE_QUAT_MI2S_RX,
  5771. .stream_name = "Quaternary MI2S Playback",
  5772. .no_pcm = 1,
  5773. .dpcm_playback = 1,
  5774. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  5775. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5776. .ops = &msm_mi2s_be_ops,
  5777. .ignore_suspend = 1,
  5778. .ignore_pmdown_time = 1,
  5779. SND_SOC_DAILINK_REG(quat_mi2s_rx),
  5780. },
  5781. {
  5782. .name = LPASS_BE_QUAT_MI2S_TX,
  5783. .stream_name = "Quaternary MI2S Capture",
  5784. .no_pcm = 1,
  5785. .dpcm_capture = 1,
  5786. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  5787. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5788. .ops = &msm_mi2s_be_ops,
  5789. .ignore_suspend = 1,
  5790. SND_SOC_DAILINK_REG(quat_mi2s_tx),
  5791. },
  5792. {
  5793. .name = LPASS_BE_QUIN_MI2S_RX,
  5794. .stream_name = "Quinary MI2S Playback",
  5795. .no_pcm = 1,
  5796. .dpcm_playback = 1,
  5797. .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
  5798. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5799. .ops = &msm_mi2s_be_ops,
  5800. .ignore_suspend = 1,
  5801. .ignore_pmdown_time = 1,
  5802. SND_SOC_DAILINK_REG(quin_mi2s_rx),
  5803. },
  5804. {
  5805. .name = LPASS_BE_QUIN_MI2S_TX,
  5806. .stream_name = "Quinary MI2S Capture",
  5807. .no_pcm = 1,
  5808. .dpcm_capture = 1,
  5809. .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
  5810. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5811. .ops = &msm_mi2s_be_ops,
  5812. .ignore_suspend = 1,
  5813. SND_SOC_DAILINK_REG(quin_mi2s_tx),
  5814. },
  5815. {
  5816. .name = LPASS_BE_SENARY_MI2S_RX,
  5817. .stream_name = "Senary MI2S Playback",
  5818. .no_pcm = 1,
  5819. .dpcm_playback = 1,
  5820. .id = MSM_BACKEND_DAI_SENARY_MI2S_RX,
  5821. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5822. .ops = &msm_mi2s_be_ops,
  5823. .ignore_suspend = 1,
  5824. .ignore_pmdown_time = 1,
  5825. SND_SOC_DAILINK_REG(sen_mi2s_rx),
  5826. },
  5827. {
  5828. .name = LPASS_BE_SENARY_MI2S_TX,
  5829. .stream_name = "Senary MI2S Capture",
  5830. .no_pcm = 1,
  5831. .dpcm_capture = 1,
  5832. .id = MSM_BACKEND_DAI_SENARY_MI2S_TX,
  5833. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5834. .ops = &msm_mi2s_be_ops,
  5835. .ignore_suspend = 1,
  5836. SND_SOC_DAILINK_REG(sen_mi2s_tx),
  5837. },
  5838. };
  5839. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  5840. /* Primary AUX PCM Backend DAI Links */
  5841. {
  5842. .name = LPASS_BE_AUXPCM_RX,
  5843. .stream_name = "AUX PCM Playback",
  5844. .no_pcm = 1,
  5845. .dpcm_playback = 1,
  5846. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  5847. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5848. .ops = &lahaina_aux_be_ops,
  5849. .ignore_pmdown_time = 1,
  5850. .ignore_suspend = 1,
  5851. SND_SOC_DAILINK_REG(auxpcm_rx),
  5852. },
  5853. {
  5854. .name = LPASS_BE_AUXPCM_TX,
  5855. .stream_name = "AUX PCM Capture",
  5856. .no_pcm = 1,
  5857. .dpcm_capture = 1,
  5858. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  5859. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5860. .ops = &lahaina_aux_be_ops,
  5861. .ignore_suspend = 1,
  5862. SND_SOC_DAILINK_REG(auxpcm_tx),
  5863. },
  5864. /* Secondary AUX PCM Backend DAI Links */
  5865. {
  5866. .name = LPASS_BE_SEC_AUXPCM_RX,
  5867. .stream_name = "Sec AUX PCM Playback",
  5868. .no_pcm = 1,
  5869. .dpcm_playback = 1,
  5870. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  5871. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5872. .ops = &lahaina_aux_be_ops,
  5873. .ignore_pmdown_time = 1,
  5874. .ignore_suspend = 1,
  5875. SND_SOC_DAILINK_REG(sec_auxpcm_rx),
  5876. },
  5877. {
  5878. .name = LPASS_BE_SEC_AUXPCM_TX,
  5879. .stream_name = "Sec AUX PCM Capture",
  5880. .no_pcm = 1,
  5881. .dpcm_capture = 1,
  5882. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  5883. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5884. .ops = &lahaina_aux_be_ops,
  5885. .ignore_suspend = 1,
  5886. SND_SOC_DAILINK_REG(sec_auxpcm_tx),
  5887. },
  5888. /* Tertiary AUX PCM Backend DAI Links */
  5889. {
  5890. .name = LPASS_BE_TERT_AUXPCM_RX,
  5891. .stream_name = "Tert AUX PCM Playback",
  5892. .no_pcm = 1,
  5893. .dpcm_playback = 1,
  5894. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  5895. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5896. .ops = &lahaina_aux_be_ops,
  5897. .ignore_suspend = 1,
  5898. SND_SOC_DAILINK_REG(tert_auxpcm_rx),
  5899. },
  5900. {
  5901. .name = LPASS_BE_TERT_AUXPCM_TX,
  5902. .stream_name = "Tert AUX PCM Capture",
  5903. .no_pcm = 1,
  5904. .dpcm_capture = 1,
  5905. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  5906. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5907. .ops = &lahaina_aux_be_ops,
  5908. .ignore_suspend = 1,
  5909. SND_SOC_DAILINK_REG(tert_auxpcm_tx),
  5910. },
  5911. /* Quaternary AUX PCM Backend DAI Links */
  5912. {
  5913. .name = LPASS_BE_QUAT_AUXPCM_RX,
  5914. .stream_name = "Quat AUX PCM Playback",
  5915. .no_pcm = 1,
  5916. .dpcm_playback = 1,
  5917. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  5918. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5919. .ops = &lahaina_aux_be_ops,
  5920. .ignore_suspend = 1,
  5921. SND_SOC_DAILINK_REG(quat_auxpcm_rx),
  5922. },
  5923. {
  5924. .name = LPASS_BE_QUAT_AUXPCM_TX,
  5925. .stream_name = "Quat AUX PCM Capture",
  5926. .no_pcm = 1,
  5927. .dpcm_capture = 1,
  5928. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  5929. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5930. .ops = &lahaina_aux_be_ops,
  5931. .ignore_suspend = 1,
  5932. SND_SOC_DAILINK_REG(quat_auxpcm_tx),
  5933. },
  5934. /* Quinary AUX PCM Backend DAI Links */
  5935. {
  5936. .name = LPASS_BE_QUIN_AUXPCM_RX,
  5937. .stream_name = "Quin AUX PCM Playback",
  5938. .no_pcm = 1,
  5939. .dpcm_playback = 1,
  5940. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
  5941. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5942. .ops = &lahaina_aux_be_ops,
  5943. .ignore_suspend = 1,
  5944. SND_SOC_DAILINK_REG(quin_auxpcm_rx),
  5945. },
  5946. {
  5947. .name = LPASS_BE_QUIN_AUXPCM_TX,
  5948. .stream_name = "Quin AUX PCM Capture",
  5949. .no_pcm = 1,
  5950. .dpcm_capture = 1,
  5951. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
  5952. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5953. .ops = &lahaina_aux_be_ops,
  5954. .ignore_suspend = 1,
  5955. SND_SOC_DAILINK_REG(quin_auxpcm_tx),
  5956. },
  5957. /* Senary AUX PCM Backend DAI Links */
  5958. {
  5959. .name = LPASS_BE_SEN_AUXPCM_RX,
  5960. .stream_name = "Sen AUX PCM Playback",
  5961. .no_pcm = 1,
  5962. .dpcm_playback = 1,
  5963. .id = MSM_BACKEND_DAI_SEN_AUXPCM_RX,
  5964. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5965. .ops = &lahaina_aux_be_ops,
  5966. .ignore_suspend = 1,
  5967. SND_SOC_DAILINK_REG(sen_auxpcm_rx),
  5968. },
  5969. {
  5970. .name = LPASS_BE_SEN_AUXPCM_TX,
  5971. .stream_name = "Sen AUX PCM Capture",
  5972. .no_pcm = 1,
  5973. .dpcm_capture = 1,
  5974. .id = MSM_BACKEND_DAI_SEN_AUXPCM_TX,
  5975. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5976. .ops = &lahaina_aux_be_ops,
  5977. .ignore_suspend = 1,
  5978. SND_SOC_DAILINK_REG(sen_auxpcm_tx),
  5979. },
  5980. };
  5981. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  5982. /* WSA CDC DMA Backend DAI Links */
  5983. {
  5984. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  5985. .stream_name = "WSA CDC DMA0 Playback",
  5986. .no_pcm = 1,
  5987. .dpcm_playback = 1,
  5988. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  5989. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5990. .ignore_pmdown_time = 1,
  5991. .ignore_suspend = 1,
  5992. .ops = &msm_cdc_dma_be_ops,
  5993. SND_SOC_DAILINK_REG(wsa_dma_rx0),
  5994. .init = &msm_int_audrx_init,
  5995. },
  5996. {
  5997. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  5998. .stream_name = "WSA CDC DMA1 Playback",
  5999. .no_pcm = 1,
  6000. .dpcm_playback = 1,
  6001. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  6002. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6003. .ignore_pmdown_time = 1,
  6004. .ignore_suspend = 1,
  6005. .ops = &msm_cdc_dma_be_ops,
  6006. SND_SOC_DAILINK_REG(wsa_dma_rx1),
  6007. },
  6008. {
  6009. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  6010. .stream_name = "WSA CDC DMA1 Capture",
  6011. .no_pcm = 1,
  6012. .dpcm_capture = 1,
  6013. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  6014. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6015. .ignore_suspend = 1,
  6016. .ops = &msm_cdc_dma_be_ops,
  6017. SND_SOC_DAILINK_REG(wsa_dma_tx1),
  6018. },
  6019. };
  6020. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  6021. /* RX CDC DMA Backend DAI Links */
  6022. {
  6023. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  6024. .stream_name = "RX CDC DMA0 Playback",
  6025. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6026. .dynamic_be = 1,
  6027. #endif /* CONFIG_AUDIO_QGKI */
  6028. .no_pcm = 1,
  6029. .dpcm_playback = 1,
  6030. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  6031. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6032. .ignore_pmdown_time = 1,
  6033. .ignore_suspend = 1,
  6034. .ops = &msm_cdc_dma_be_ops,
  6035. SND_SOC_DAILINK_REG(rx_dma_rx0),
  6036. .init = &msm_aux_codec_init,
  6037. },
  6038. {
  6039. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  6040. .stream_name = "RX CDC DMA1 Playback",
  6041. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6042. .dynamic_be = 1,
  6043. #endif /* CONFIG_AUDIO_QGKI */
  6044. .no_pcm = 1,
  6045. .dpcm_playback = 1,
  6046. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  6047. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6048. .ignore_pmdown_time = 1,
  6049. .ignore_suspend = 1,
  6050. .ops = &msm_cdc_dma_be_ops,
  6051. SND_SOC_DAILINK_REG(rx_dma_rx1),
  6052. },
  6053. {
  6054. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  6055. .stream_name = "RX CDC DMA2 Playback",
  6056. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6057. .dynamic_be = 1,
  6058. #endif /* CONFIG_AUDIO_QGKI */
  6059. .no_pcm = 1,
  6060. .dpcm_playback = 1,
  6061. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  6062. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6063. .ignore_pmdown_time = 1,
  6064. .ignore_suspend = 1,
  6065. .ops = &msm_cdc_dma_be_ops,
  6066. SND_SOC_DAILINK_REG(rx_dma_rx2),
  6067. },
  6068. {
  6069. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  6070. .stream_name = "RX CDC DMA3 Playback",
  6071. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6072. .dynamic_be = 1,
  6073. #endif /* CONFIG_AUDIO_QGKI */
  6074. .no_pcm = 1,
  6075. .dpcm_playback = 1,
  6076. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  6077. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6078. .ignore_pmdown_time = 1,
  6079. .ignore_suspend = 1,
  6080. .ops = &msm_cdc_dma_be_ops,
  6081. SND_SOC_DAILINK_REG(rx_dma_rx3),
  6082. },
  6083. /* TX CDC DMA Backend DAI Links */
  6084. {
  6085. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  6086. .stream_name = "TX CDC DMA3 Capture",
  6087. .no_pcm = 1,
  6088. .dpcm_capture = 1,
  6089. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  6090. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6091. .ignore_suspend = 1,
  6092. .ops = &msm_cdc_dma_be_ops,
  6093. SND_SOC_DAILINK_REG(tx_dma_tx3),
  6094. },
  6095. {
  6096. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  6097. .stream_name = "TX CDC DMA4 Capture",
  6098. .no_pcm = 1,
  6099. .dpcm_capture = 1,
  6100. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  6101. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6102. .ignore_suspend = 1,
  6103. .ops = &msm_cdc_dma_be_ops,
  6104. SND_SOC_DAILINK_REG(tx_dma_tx4),
  6105. },
  6106. };
  6107. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  6108. {
  6109. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  6110. .stream_name = "VA CDC DMA0 Capture",
  6111. .no_pcm = 1,
  6112. .dpcm_capture = 1,
  6113. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  6114. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6115. .ignore_suspend = 1,
  6116. .ops = &msm_cdc_dma_be_ops,
  6117. SND_SOC_DAILINK_REG(va_dma_tx0),
  6118. },
  6119. {
  6120. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  6121. .stream_name = "VA CDC DMA1 Capture",
  6122. .no_pcm = 1,
  6123. .dpcm_capture = 1,
  6124. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  6125. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6126. .ignore_suspend = 1,
  6127. .ops = &msm_cdc_dma_be_ops,
  6128. SND_SOC_DAILINK_REG(va_dma_tx1),
  6129. },
  6130. {
  6131. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  6132. .stream_name = "VA CDC DMA2 Capture",
  6133. .no_pcm = 1,
  6134. .dpcm_capture = 1,
  6135. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
  6136. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6137. .ignore_suspend = 1,
  6138. .ops = &msm_cdc_dma_be_ops,
  6139. SND_SOC_DAILINK_REG(va_dma_tx2),
  6140. },
  6141. };
  6142. static struct snd_soc_dai_link msm_afe_rxtx_lb_be_dai_link[] = {
  6143. {
  6144. .name = LPASS_BE_AFE_LOOPBACK_TX,
  6145. .stream_name = "AFE Loopback Capture",
  6146. .no_pcm = 1,
  6147. .dpcm_capture = 1,
  6148. .id = MSM_BACKEND_DAI_AFE_LOOPBACK_TX,
  6149. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6150. .ignore_pmdown_time = 1,
  6151. .ignore_suspend = 1,
  6152. SND_SOC_DAILINK_REG(afe_loopback_tx),
  6153. },
  6154. };
  6155. static struct snd_soc_dai_link msm_lahaina_dai_links[
  6156. ARRAY_SIZE(msm_common_dai_links) +
  6157. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  6158. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  6159. ARRAY_SIZE(msm_common_be_dai_links) +
  6160. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  6161. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  6162. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  6163. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  6164. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  6165. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6166. ARRAY_SIZE(ext_disp_be_dai_link) +
  6167. #endif
  6168. ARRAY_SIZE(msm_wcn_be_dai_links) +
  6169. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link) +
  6170. ARRAY_SIZE(msm_wcn_btfm_be_dai_links)];
  6171. static int msm_populate_dai_link_component_of_node(
  6172. struct snd_soc_card *card)
  6173. {
  6174. int i, j, index, ret = 0;
  6175. struct device *cdev = card->dev;
  6176. struct snd_soc_dai_link *dai_link = card->dai_link;
  6177. struct device_node *np = NULL;
  6178. int codecs_enabled = 0;
  6179. struct snd_soc_dai_link_component *codecs_comp = NULL;
  6180. if (!cdev) {
  6181. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  6182. return -ENODEV;
  6183. }
  6184. for (i = 0; i < card->num_links; i++) {
  6185. if (dai_link[i].platforms->of_node && dai_link[i].cpus->of_node)
  6186. continue;
  6187. /* populate platform_of_node for snd card dai links */
  6188. if (dai_link[i].platforms->name &&
  6189. !dai_link[i].platforms->of_node) {
  6190. index = of_property_match_string(cdev->of_node,
  6191. "asoc-platform-names",
  6192. dai_link[i].platforms->name);
  6193. if (index < 0) {
  6194. dev_err(cdev, "%s: No match found for platform name: %s\n",
  6195. __func__, dai_link[i].platforms->name);
  6196. ret = index;
  6197. goto err;
  6198. }
  6199. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  6200. index);
  6201. if (!np) {
  6202. dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
  6203. __func__, dai_link[i].platforms->name,
  6204. index);
  6205. ret = -ENODEV;
  6206. goto err;
  6207. }
  6208. dai_link[i].platforms->of_node = np;
  6209. dai_link[i].platforms->name = NULL;
  6210. }
  6211. /* populate cpu_of_node for snd card dai links */
  6212. if (dai_link[i].cpus->dai_name && !dai_link[i].cpus->of_node) {
  6213. index = of_property_match_string(cdev->of_node,
  6214. "asoc-cpu-names",
  6215. dai_link[i].cpus->dai_name);
  6216. if (index >= 0) {
  6217. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  6218. index);
  6219. if (!np) {
  6220. dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
  6221. __func__,
  6222. dai_link[i].cpus->dai_name);
  6223. ret = -ENODEV;
  6224. goto err;
  6225. }
  6226. dai_link[i].cpus->of_node = np;
  6227. dai_link[i].cpus->dai_name = NULL;
  6228. }
  6229. }
  6230. /* populate codec_of_node for snd card dai links */
  6231. if (dai_link[i].num_codecs > 0) {
  6232. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6233. if (dai_link[i].codecs[j].of_node ||
  6234. !dai_link[i].codecs[j].name)
  6235. continue;
  6236. index = of_property_match_string(cdev->of_node,
  6237. "asoc-codec-names",
  6238. dai_link[i].codecs[j].name);
  6239. if (index < 0)
  6240. continue;
  6241. np = of_parse_phandle(cdev->of_node,
  6242. "asoc-codec",
  6243. index);
  6244. if (!np) {
  6245. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  6246. __func__,
  6247. dai_link[i].codecs[j].name);
  6248. ret = -ENODEV;
  6249. goto err;
  6250. }
  6251. dai_link[i].codecs[j].of_node = np;
  6252. dai_link[i].codecs[j].name = NULL;
  6253. }
  6254. }
  6255. }
  6256. /* In multi-codec scenario, check if codecs are enabled for this platform */
  6257. for (i = 0; i < card->num_links; i++) {
  6258. codecs_enabled = 0;
  6259. if (dai_link[i].num_codecs > 1) {
  6260. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6261. if (!dai_link[i].codecs[j].of_node)
  6262. continue;
  6263. np = dai_link[i].codecs[j].of_node;
  6264. if (!of_device_is_available(np)) {
  6265. dev_err(cdev, "%s: codec is disabled: %s\n",
  6266. __func__,
  6267. np->full_name);
  6268. dai_link[i].codecs[j].of_node = NULL;
  6269. continue;
  6270. }
  6271. codecs_enabled++;
  6272. }
  6273. if (codecs_enabled > 0 &&
  6274. codecs_enabled < dai_link[i].num_codecs) {
  6275. codecs_comp = devm_kzalloc(cdev,
  6276. sizeof(struct snd_soc_dai_link_component)
  6277. * codecs_enabled, GFP_KERNEL);
  6278. if (!codecs_comp) {
  6279. dev_err(cdev, "%s: %s dailink codec component alloc failed\n",
  6280. __func__, dai_link[i].name);
  6281. ret = -ENOMEM;
  6282. goto err;
  6283. }
  6284. index = 0;
  6285. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6286. if(dai_link[i].codecs[j].of_node) {
  6287. codecs_comp[index].of_node =
  6288. dai_link[i].codecs[j].of_node;
  6289. codecs_comp[index].dai_name =
  6290. dai_link[i].codecs[j].dai_name;
  6291. codecs_comp[index].name = NULL;
  6292. index++;
  6293. }
  6294. }
  6295. dai_link[i].codecs = codecs_comp;
  6296. dai_link[i].num_codecs = codecs_enabled;
  6297. }
  6298. }
  6299. }
  6300. err:
  6301. return ret;
  6302. }
  6303. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  6304. {
  6305. int ret = -EINVAL;
  6306. struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  6307. if (!component) {
  6308. pr_err("* %s: No match for msm-stub-codec component\n", __func__);
  6309. return ret;
  6310. }
  6311. ret = snd_soc_add_component_controls(component, msm_snd_controls,
  6312. ARRAY_SIZE(msm_snd_controls));
  6313. if (ret < 0) {
  6314. dev_err(component->dev,
  6315. "%s: add_codec_controls failed, err = %d\n",
  6316. __func__, ret);
  6317. return ret;
  6318. }
  6319. return ret;
  6320. }
  6321. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  6322. struct snd_pcm_hw_params *params)
  6323. {
  6324. return 0;
  6325. }
  6326. static struct snd_soc_ops msm_stub_be_ops = {
  6327. .hw_params = msm_snd_stub_hw_params,
  6328. };
  6329. struct snd_soc_card snd_soc_card_stub_msm = {
  6330. .name = "lahaina-stub-snd-card",
  6331. };
  6332. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  6333. /* FrontEnd DAI Links */
  6334. {
  6335. .name = "MSMSTUB Media1",
  6336. .stream_name = "MultiMedia1",
  6337. .dynamic = 1,
  6338. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6339. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  6340. #endif /* CONFIG_AUDIO_QGKI */
  6341. .dpcm_playback = 1,
  6342. .dpcm_capture = 1,
  6343. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6344. SND_SOC_DPCM_TRIGGER_POST},
  6345. .ignore_suspend = 1,
  6346. /* this dainlink has playback support */
  6347. .ignore_pmdown_time = 1,
  6348. .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
  6349. SND_SOC_DAILINK_REG(multimedia1),
  6350. },
  6351. };
  6352. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  6353. /* Backend DAI Links */
  6354. {
  6355. .name = LPASS_BE_AUXPCM_RX,
  6356. .stream_name = "AUX PCM Playback",
  6357. .no_pcm = 1,
  6358. .dpcm_playback = 1,
  6359. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  6360. .init = &msm_audrx_stub_init,
  6361. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6362. .ignore_pmdown_time = 1,
  6363. .ignore_suspend = 1,
  6364. .ops = &msm_stub_be_ops,
  6365. SND_SOC_DAILINK_REG(auxpcm_rx),
  6366. },
  6367. {
  6368. .name = LPASS_BE_AUXPCM_TX,
  6369. .stream_name = "AUX PCM Capture",
  6370. .no_pcm = 1,
  6371. .dpcm_capture = 1,
  6372. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  6373. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6374. .ignore_suspend = 1,
  6375. .ops = &msm_stub_be_ops,
  6376. SND_SOC_DAILINK_REG(auxpcm_tx),
  6377. },
  6378. };
  6379. static struct snd_soc_dai_link msm_stub_dai_links[
  6380. ARRAY_SIZE(msm_stub_fe_dai_links) +
  6381. ARRAY_SIZE(msm_stub_be_dai_links)];
  6382. static const struct of_device_id lahaina_asoc_machine_of_match[] = {
  6383. { .compatible = "qcom,lahaina-asoc-snd",
  6384. .data = "codec"},
  6385. { .compatible = "qcom,lahaina-asoc-snd-stub",
  6386. .data = "stub_codec"},
  6387. {},
  6388. };
  6389. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  6390. {
  6391. struct snd_soc_card *card = NULL;
  6392. struct snd_soc_dai_link *dailink = NULL;
  6393. int len_1 = 0;
  6394. int len_2 = 0;
  6395. int total_links = 0;
  6396. int rc = 0;
  6397. u32 mi2s_audio_intf = 0;
  6398. u32 auxpcm_audio_intf = 0;
  6399. u32 val = 0;
  6400. u32 wcn_btfm_intf = 0;
  6401. const struct of_device_id *match;
  6402. match = of_match_node(lahaina_asoc_machine_of_match, dev->of_node);
  6403. if (!match) {
  6404. dev_err(dev, "%s: No DT match found for sound card\n",
  6405. __func__);
  6406. return NULL;
  6407. }
  6408. if (!strcmp(match->data, "codec")) {
  6409. card = &snd_soc_card_lahaina_msm;
  6410. memcpy(msm_lahaina_dai_links + total_links,
  6411. msm_common_dai_links,
  6412. sizeof(msm_common_dai_links));
  6413. total_links += ARRAY_SIZE(msm_common_dai_links);
  6414. memcpy(msm_lahaina_dai_links + total_links,
  6415. msm_bolero_fe_dai_links,
  6416. sizeof(msm_bolero_fe_dai_links));
  6417. total_links +=
  6418. ARRAY_SIZE(msm_bolero_fe_dai_links);
  6419. memcpy(msm_lahaina_dai_links + total_links,
  6420. msm_common_misc_fe_dai_links,
  6421. sizeof(msm_common_misc_fe_dai_links));
  6422. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  6423. memcpy(msm_lahaina_dai_links + total_links,
  6424. msm_common_be_dai_links,
  6425. sizeof(msm_common_be_dai_links));
  6426. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  6427. memcpy(msm_lahaina_dai_links + total_links,
  6428. msm_rx_tx_cdc_dma_be_dai_links,
  6429. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  6430. total_links +=
  6431. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  6432. memcpy(msm_lahaina_dai_links + total_links,
  6433. msm_wsa_cdc_dma_be_dai_links,
  6434. sizeof(msm_wsa_cdc_dma_be_dai_links));
  6435. total_links +=
  6436. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  6437. memcpy(msm_lahaina_dai_links + total_links,
  6438. msm_va_cdc_dma_be_dai_links,
  6439. sizeof(msm_va_cdc_dma_be_dai_links));
  6440. total_links +=
  6441. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  6442. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  6443. &mi2s_audio_intf);
  6444. if (rc) {
  6445. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  6446. __func__);
  6447. } else {
  6448. if (mi2s_audio_intf) {
  6449. memcpy(msm_lahaina_dai_links + total_links,
  6450. msm_mi2s_be_dai_links,
  6451. sizeof(msm_mi2s_be_dai_links));
  6452. total_links +=
  6453. ARRAY_SIZE(msm_mi2s_be_dai_links);
  6454. }
  6455. }
  6456. rc = of_property_read_u32(dev->of_node,
  6457. "qcom,auxpcm-audio-intf",
  6458. &auxpcm_audio_intf);
  6459. if (rc) {
  6460. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  6461. __func__);
  6462. } else {
  6463. if (auxpcm_audio_intf) {
  6464. memcpy(msm_lahaina_dai_links + total_links,
  6465. msm_auxpcm_be_dai_links,
  6466. sizeof(msm_auxpcm_be_dai_links));
  6467. total_links +=
  6468. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  6469. }
  6470. }
  6471. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6472. rc = of_property_read_u32(dev->of_node,
  6473. "qcom,ext-disp-audio-rx", &val);
  6474. if (!rc && val) {
  6475. dev_dbg(dev, "%s(): ext disp audio support present\n",
  6476. __func__);
  6477. memcpy(msm_lahaina_dai_links + total_links,
  6478. ext_disp_be_dai_link,
  6479. sizeof(ext_disp_be_dai_link));
  6480. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  6481. }
  6482. #endif
  6483. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  6484. if (!rc && val) {
  6485. dev_dbg(dev, "%s(): WCN BT support present\n",
  6486. __func__);
  6487. memcpy(msm_lahaina_dai_links + total_links,
  6488. msm_wcn_be_dai_links,
  6489. sizeof(msm_wcn_be_dai_links));
  6490. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  6491. }
  6492. rc = of_property_read_u32(dev->of_node, "qcom,afe-rxtx-lb",
  6493. &val);
  6494. if (!rc && val) {
  6495. memcpy(msm_lahaina_dai_links + total_links,
  6496. msm_afe_rxtx_lb_be_dai_link,
  6497. sizeof(msm_afe_rxtx_lb_be_dai_link));
  6498. total_links +=
  6499. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link);
  6500. }
  6501. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  6502. &wcn_btfm_intf);
  6503. if (rc) {
  6504. dev_dbg(dev, "%s: No DT match wcn btfm interface\n",
  6505. __func__);
  6506. } else {
  6507. if (wcn_btfm_intf) {
  6508. memcpy(msm_lahaina_dai_links + total_links,
  6509. msm_wcn_btfm_be_dai_links,
  6510. sizeof(msm_wcn_btfm_be_dai_links));
  6511. total_links +=
  6512. ARRAY_SIZE(msm_wcn_btfm_be_dai_links);
  6513. }
  6514. }
  6515. dailink = msm_lahaina_dai_links;
  6516. } else if(!strcmp(match->data, "stub_codec")) {
  6517. card = &snd_soc_card_stub_msm;
  6518. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  6519. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  6520. memcpy(msm_stub_dai_links,
  6521. msm_stub_fe_dai_links,
  6522. sizeof(msm_stub_fe_dai_links));
  6523. memcpy(msm_stub_dai_links + len_1,
  6524. msm_stub_be_dai_links,
  6525. sizeof(msm_stub_be_dai_links));
  6526. dailink = msm_stub_dai_links;
  6527. total_links = len_2;
  6528. }
  6529. if (card) {
  6530. card->dai_link = dailink;
  6531. card->num_links = total_links;
  6532. }
  6533. return card;
  6534. }
  6535. static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
  6536. {
  6537. u8 spkleft_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6538. u8 spkright_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6539. u8 spkleft_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  6540. SPKR_L_BOOST, SPKR_L_VI};
  6541. u8 spkright_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  6542. SPKR_R_BOOST, SPKR_R_VI};
  6543. unsigned int ch_rate[WSA883X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  6544. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_1P2MHZ};
  6545. unsigned int ch_mask[WSA883X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  6546. struct snd_soc_component *component = NULL;
  6547. struct snd_soc_dapm_context *dapm = NULL;
  6548. struct snd_card *card = NULL;
  6549. struct snd_info_entry *entry = NULL;
  6550. struct msm_asoc_mach_data *pdata =
  6551. snd_soc_card_get_drvdata(rtd->card);
  6552. int ret = 0;
  6553. if (pdata->wsa_max_devs > 0) {
  6554. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
  6555. if (!component) {
  6556. pr_err("%s: wsa-codec.1 component is NULL\n", __func__);
  6557. return -EINVAL;
  6558. }
  6559. dapm = snd_soc_component_get_dapm(component);
  6560. wsa883x_set_channel_map(component, &spkleft_ports[0],
  6561. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  6562. &ch_rate[0], &spkleft_port_types[0]);
  6563. if (dapm->component) {
  6564. snd_soc_dapm_ignore_suspend(dapm, "spkrLeft IN");
  6565. snd_soc_dapm_ignore_suspend(dapm, "spkrLeft SPKR");
  6566. }
  6567. /*TODO: create codec entry for wsa1 */
  6568. }
  6569. /* If current platform has more than one WSA */
  6570. if (pdata->wsa_max_devs > 1) {
  6571. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
  6572. if (!component) {
  6573. pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
  6574. return -EINVAL;
  6575. }
  6576. dapm = snd_soc_component_get_dapm(component);
  6577. wsa883x_set_channel_map(component, &spkright_ports[0],
  6578. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  6579. &ch_rate[0], &spkright_port_types[0]);
  6580. if (dapm->component) {
  6581. snd_soc_dapm_ignore_suspend(dapm, "spkrRight IN");
  6582. snd_soc_dapm_ignore_suspend(dapm, "spkrRight SPKR");
  6583. }
  6584. /*TODO: create codec entry for wsa2 */
  6585. }
  6586. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  6587. if (!component) {
  6588. pr_err("%s: could not find component for bolero_codec\n",
  6589. __func__);
  6590. return ret;
  6591. }
  6592. dapm = snd_soc_component_get_dapm(component);
  6593. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  6594. ARRAY_SIZE(msm_int_snd_controls));
  6595. if (ret < 0) {
  6596. pr_err("%s: add_component_controls failed: %d\n",
  6597. __func__, ret);
  6598. return ret;
  6599. }
  6600. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  6601. ARRAY_SIZE(msm_common_snd_controls));
  6602. if (ret < 0) {
  6603. pr_err("%s: add common snd controls failed: %d\n",
  6604. __func__, ret);
  6605. return ret;
  6606. }
  6607. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  6608. ARRAY_SIZE(msm_int_dapm_widgets));
  6609. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  6610. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  6611. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  6612. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  6613. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  6614. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  6615. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  6616. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  6617. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  6618. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  6619. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  6620. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  6621. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  6622. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  6623. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  6624. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  6625. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  6626. snd_soc_dapm_sync(dapm);
  6627. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map), sm_port_map);
  6628. card = rtd->card->snd_card;
  6629. if (!pdata->codec_root) {
  6630. entry = msm_snd_info_create_subdir(card->module, "codecs",
  6631. card->proc_root);
  6632. if (!entry) {
  6633. pr_debug("%s: Cannot create codecs module entry\n",
  6634. __func__);
  6635. ret = 0;
  6636. goto err;
  6637. }
  6638. pdata->codec_root = entry;
  6639. }
  6640. bolero_info_create_codec_entry(pdata->codec_root, component);
  6641. bolero_register_wake_irq(component, false);
  6642. codec_reg_done = true;
  6643. err:
  6644. return ret;
  6645. }
  6646. static int msm_aux_codec_init(struct snd_soc_pcm_runtime *rtd)
  6647. {
  6648. struct snd_soc_component *component = NULL;
  6649. struct snd_soc_dapm_context *dapm = NULL;
  6650. int ret = 0;
  6651. int codec_variant = -1;
  6652. void *mbhc_calibration;
  6653. struct snd_info_entry *entry;
  6654. struct snd_card *card = NULL;
  6655. struct msm_asoc_mach_data *pdata;
  6656. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  6657. if (!component) {
  6658. pr_err("%s component is NULL\n", __func__);
  6659. return -EINVAL;
  6660. }
  6661. dapm = snd_soc_component_get_dapm(component);
  6662. card = component->card->snd_card;
  6663. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  6664. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  6665. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  6666. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  6667. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  6668. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  6669. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  6670. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  6671. snd_soc_dapm_sync(dapm);
  6672. pdata = snd_soc_card_get_drvdata(component->card);
  6673. if (!pdata->codec_root) {
  6674. entry = msm_snd_info_create_subdir(card->module, "codecs",
  6675. card->proc_root);
  6676. if (!entry) {
  6677. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  6678. __func__);
  6679. ret = 0;
  6680. goto mbhc_cfg_cal;
  6681. }
  6682. pdata->codec_root = entry;
  6683. }
  6684. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  6685. codec_variant = wcd938x_get_codec_variant(component);
  6686. dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
  6687. if (codec_variant == WCD9380)
  6688. ret = snd_soc_add_component_controls(component,
  6689. msm_int_wcd9380_snd_controls,
  6690. ARRAY_SIZE(msm_int_wcd9380_snd_controls));
  6691. else if (codec_variant == WCD9385)
  6692. ret = snd_soc_add_component_controls(component,
  6693. msm_int_wcd9385_snd_controls,
  6694. ARRAY_SIZE(msm_int_wcd9385_snd_controls));
  6695. if (ret < 0) {
  6696. dev_err(component->dev, "%s: add codec specific snd controls failed: %d\n",
  6697. __func__, ret);
  6698. return ret;
  6699. }
  6700. mbhc_cfg_cal:
  6701. mbhc_calibration = def_wcd_mbhc_cal();
  6702. if (!mbhc_calibration)
  6703. return -ENOMEM;
  6704. wcd_mbhc_cfg.calibration = mbhc_calibration;
  6705. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  6706. if (ret) {
  6707. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  6708. __func__, ret);
  6709. goto err_hs_detect;
  6710. }
  6711. return 0;
  6712. err_hs_detect:
  6713. kfree(mbhc_calibration);
  6714. return ret;
  6715. }
  6716. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  6717. {
  6718. int count = 0;
  6719. u32 mi2s_master_slave[MI2S_MAX];
  6720. int ret = 0;
  6721. for (count = 0; count < MI2S_MAX; count++) {
  6722. mutex_init(&mi2s_intf_conf[count].lock);
  6723. mi2s_intf_conf[count].ref_cnt = 0;
  6724. }
  6725. ret = of_property_read_u32_array(pdev->dev.of_node,
  6726. "qcom,msm-mi2s-master",
  6727. mi2s_master_slave, MI2S_MAX);
  6728. if (ret) {
  6729. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  6730. __func__);
  6731. } else {
  6732. for (count = 0; count < MI2S_MAX; count++) {
  6733. mi2s_intf_conf[count].msm_is_mi2s_master =
  6734. mi2s_master_slave[count];
  6735. }
  6736. }
  6737. }
  6738. static void msm_i2s_auxpcm_deinit(void)
  6739. {
  6740. int count = 0;
  6741. for (count = 0; count < MI2S_MAX; count++) {
  6742. mutex_destroy(&mi2s_intf_conf[count].lock);
  6743. mi2s_intf_conf[count].ref_cnt = 0;
  6744. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  6745. }
  6746. }
  6747. static int lahaina_ssr_enable(struct device *dev, void *data)
  6748. {
  6749. struct platform_device *pdev = to_platform_device(dev);
  6750. struct snd_soc_card *card = platform_get_drvdata(pdev);
  6751. int ret = 0;
  6752. if (!card) {
  6753. dev_err(dev, "%s: card is NULL\n", __func__);
  6754. ret = -EINVAL;
  6755. goto err;
  6756. }
  6757. if (!strcmp(card->name, "lahaina-stub-snd-card")) {
  6758. /* TODO */
  6759. dev_dbg(dev, "%s: TODO \n", __func__);
  6760. }
  6761. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6762. snd_soc_card_change_online_state(card, 1);
  6763. #endif /* CONFIG_AUDIO_QGKI */
  6764. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  6765. err:
  6766. return ret;
  6767. }
  6768. static void lahaina_ssr_disable(struct device *dev, void *data)
  6769. {
  6770. struct platform_device *pdev = to_platform_device(dev);
  6771. struct snd_soc_card *card = platform_get_drvdata(pdev);
  6772. if (!card) {
  6773. dev_err(dev, "%s: card is NULL\n", __func__);
  6774. return;
  6775. }
  6776. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  6777. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6778. snd_soc_card_change_online_state(card, 0);
  6779. #endif /* CONFIG_AUDIO_QGKI */
  6780. if (!strcmp(card->name, "lahaina-stub-snd-card")) {
  6781. /* TODO */
  6782. dev_dbg(dev, "%s: TODO \n", __func__);
  6783. }
  6784. }
  6785. static const struct snd_event_ops lahaina_ssr_ops = {
  6786. .enable = lahaina_ssr_enable,
  6787. .disable = lahaina_ssr_disable,
  6788. };
  6789. static int msm_audio_ssr_compare(struct device *dev, void *data)
  6790. {
  6791. struct device_node *node = data;
  6792. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  6793. __func__, dev->of_node, node);
  6794. return (dev->of_node && dev->of_node == node);
  6795. }
  6796. static int msm_audio_ssr_register(struct device *dev)
  6797. {
  6798. struct device_node *np = dev->of_node;
  6799. struct snd_event_clients *ssr_clients = NULL;
  6800. struct device_node *node = NULL;
  6801. int ret = 0;
  6802. int i = 0;
  6803. for (i = 0; ; i++) {
  6804. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  6805. if (!node)
  6806. break;
  6807. snd_event_mstr_add_client(&ssr_clients,
  6808. msm_audio_ssr_compare, node);
  6809. }
  6810. ret = snd_event_master_register(dev, &lahaina_ssr_ops,
  6811. ssr_clients, NULL);
  6812. if (!ret)
  6813. snd_event_notify(dev, SND_EVENT_UP);
  6814. return ret;
  6815. }
  6816. static int msm_asoc_machine_probe(struct platform_device *pdev)
  6817. {
  6818. struct snd_soc_card *card = NULL;
  6819. struct msm_asoc_mach_data *pdata = NULL;
  6820. const char *mbhc_audio_jack_type = NULL;
  6821. int ret = 0;
  6822. uint index = 0;
  6823. struct clk *lpass_audio_hw_vote = NULL;
  6824. if (!pdev->dev.of_node) {
  6825. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  6826. return -EINVAL;
  6827. }
  6828. pdata = devm_kzalloc(&pdev->dev,
  6829. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  6830. if (!pdata)
  6831. return -ENOMEM;
  6832. of_property_read_u32(pdev->dev.of_node,
  6833. "qcom,lito-is-v2-enabled",
  6834. &pdata->lito_v2_enabled);
  6835. card = populate_snd_card_dailinks(&pdev->dev);
  6836. if (!card) {
  6837. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  6838. ret = -EINVAL;
  6839. goto err;
  6840. }
  6841. card->dev = &pdev->dev;
  6842. platform_set_drvdata(pdev, card);
  6843. snd_soc_card_set_drvdata(card, pdata);
  6844. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  6845. if (ret) {
  6846. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  6847. __func__, ret);
  6848. goto err;
  6849. }
  6850. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  6851. if (ret) {
  6852. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  6853. __func__, ret);
  6854. goto err;
  6855. }
  6856. ret = msm_populate_dai_link_component_of_node(card);
  6857. if (ret) {
  6858. ret = -EPROBE_DEFER;
  6859. goto err;
  6860. }
  6861. /* Get maximum WSA device count for this platform */
  6862. ret = of_property_read_u32(pdev->dev.of_node,
  6863. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  6864. if (ret) {
  6865. dev_info(&pdev->dev,
  6866. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  6867. __func__, pdev->dev.of_node->full_name, ret);
  6868. pdata->wsa_max_devs = 0;
  6869. }
  6870. ret = devm_snd_soc_register_card(&pdev->dev, card);
  6871. if (ret == -EPROBE_DEFER) {
  6872. if (codec_reg_done)
  6873. ret = -EINVAL;
  6874. goto err;
  6875. } else if (ret) {
  6876. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  6877. __func__, ret);
  6878. goto err;
  6879. }
  6880. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  6881. __func__, card->name);
  6882. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6883. "qcom,hph-en1-gpio", 0);
  6884. if (!pdata->hph_en1_gpio_p) {
  6885. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  6886. __func__, "qcom,hph-en1-gpio",
  6887. pdev->dev.of_node->full_name);
  6888. }
  6889. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6890. "qcom,hph-en0-gpio", 0);
  6891. if (!pdata->hph_en0_gpio_p) {
  6892. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  6893. __func__, "qcom,hph-en0-gpio",
  6894. pdev->dev.of_node->full_name);
  6895. }
  6896. ret = of_property_read_string(pdev->dev.of_node,
  6897. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  6898. if (ret) {
  6899. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  6900. __func__, "qcom,mbhc-audio-jack-type",
  6901. pdev->dev.of_node->full_name);
  6902. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  6903. } else {
  6904. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  6905. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  6906. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  6907. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  6908. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  6909. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  6910. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  6911. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  6912. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  6913. } else {
  6914. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  6915. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  6916. }
  6917. }
  6918. /*
  6919. * Parse US-Euro gpio info from DT. Report no error if us-euro
  6920. * entry is not found in DT file as some targets do not support
  6921. * US-Euro detection
  6922. */
  6923. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6924. "qcom,us-euro-gpios", 0);
  6925. if (!pdata->us_euro_gpio_p) {
  6926. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  6927. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  6928. } else {
  6929. dev_dbg(&pdev->dev, "%s detected\n",
  6930. "qcom,us-euro-gpios");
  6931. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  6932. }
  6933. if (wcd_mbhc_cfg.enable_usbc_analog)
  6934. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  6935. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  6936. "fsa4480-i2c-handle", 0);
  6937. if (!pdata->fsa_handle)
  6938. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  6939. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  6940. msm_i2s_auxpcm_init(pdev);
  6941. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6942. "qcom,cdc-dmic01-gpios",
  6943. 0);
  6944. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6945. "qcom,cdc-dmic23-gpios",
  6946. 0);
  6947. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  6948. "qcom,cdc-dmic45-gpios",
  6949. 0);
  6950. if (pdata->dmic01_gpio_p)
  6951. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  6952. if (pdata->dmic23_gpio_p)
  6953. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  6954. if (pdata->dmic45_gpio_p)
  6955. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  6956. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  6957. "qcom,pri-mi2s-gpios", 0);
  6958. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  6959. "qcom,sec-mi2s-gpios", 0);
  6960. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  6961. "qcom,tert-mi2s-gpios", 0);
  6962. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  6963. "qcom,quat-mi2s-gpios", 0);
  6964. pdata->mi2s_gpio_p[QUIN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  6965. "qcom,quin-mi2s-gpios", 0);
  6966. pdata->mi2s_gpio_p[SEN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  6967. "qcom,sen-mi2s-gpios", 0);
  6968. for (index = PRIM_MI2S; index < MI2S_MAX; index++)
  6969. atomic_set(&(pdata->mi2s_gpio_ref_count[index]), 0);
  6970. /* Register LPASS audio hw vote */
  6971. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  6972. if (IS_ERR(lpass_audio_hw_vote)) {
  6973. ret = PTR_ERR(lpass_audio_hw_vote);
  6974. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  6975. __func__, "lpass_audio_hw_vote", ret);
  6976. lpass_audio_hw_vote = NULL;
  6977. ret = 0;
  6978. }
  6979. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  6980. pdata->core_audio_vote_count = 0;
  6981. ret = msm_audio_ssr_register(&pdev->dev);
  6982. if (ret)
  6983. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  6984. __func__, ret);
  6985. is_initial_boot = true;
  6986. return 0;
  6987. err:
  6988. devm_kfree(&pdev->dev, pdata);
  6989. return ret;
  6990. }
  6991. static int msm_asoc_machine_remove(struct platform_device *pdev)
  6992. {
  6993. struct snd_soc_card *card = platform_get_drvdata(pdev);
  6994. snd_event_master_deregister(&pdev->dev);
  6995. snd_soc_unregister_card(card);
  6996. msm_i2s_auxpcm_deinit();
  6997. return 0;
  6998. }
  6999. static struct platform_driver lahaina_asoc_machine_driver = {
  7000. .driver = {
  7001. .name = DRV_NAME,
  7002. .owner = THIS_MODULE,
  7003. .pm = &snd_soc_pm_ops,
  7004. .of_match_table = lahaina_asoc_machine_of_match,
  7005. .suppress_bind_attrs = true,
  7006. },
  7007. .probe = msm_asoc_machine_probe,
  7008. .remove = msm_asoc_machine_remove,
  7009. };
  7010. module_platform_driver(lahaina_asoc_machine_driver);
  7011. MODULE_DESCRIPTION("ALSA SoC msm");
  7012. MODULE_LICENSE("GPL v2");
  7013. MODULE_ALIAS("platform:" DRV_NAME);
  7014. MODULE_DEVICE_TABLE(of, lahaina_asoc_machine_of_match);