sm8150.c 211 KB

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