sdm855.c 185 KB

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