kona.c 230 KB

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