bengal.c 184 KB

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