sm6150.c 261 KB

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