kona.c 221 KB

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