sm8150.c 206 KB

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