kona.c 226 KB

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