kona.c 225 KB

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