lahaina.c 223 KB

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