lahaina.c 219 KB

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