kona.c 230 KB

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