sm6150.c 261 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/clk.h>
  6. #include <linux/delay.h>
  7. #include <linux/gpio.h>
  8. #include <linux/of_gpio.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/slab.h>
  11. #include <linux/io.h>
  12. #include <linux/module.h>
  13. #include <linux/input.h>
  14. #include <linux/of_device.h>
  15. #include <linux/pm_qos.h>
  16. #include <linux/soc/qcom/fsa4480-i2c.h>
  17. #include <sound/core.h>
  18. #include <sound/soc.h>
  19. #include <sound/soc-dapm.h>
  20. #include <sound/pcm.h>
  21. #include <sound/pcm_params.h>
  22. #include <sound/info.h>
  23. #include <soc/snd_event.h>
  24. #include <soc/qcom/socinfo.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 "codecs/wcd934x/wcd934x.h"
  31. #include "codecs/wcd9335.h"
  32. #include "codecs/wcd934x/wcd934x-mbhc.h"
  33. #include "codecs/wcd937x/wcd937x-mbhc.h"
  34. #include "codecs/wsa881x.h"
  35. #include "codecs/bolero/bolero-cdc.h"
  36. #include <dt-bindings/sound/audio-codec-port-types.h>
  37. #include "codecs/bolero/wsa-macro.h"
  38. #include "codecs/wcd937x/wcd937x.h"
  39. #define DRV_NAME "sm6150-asoc-snd"
  40. #define __CHIPSET__ "SM6150 "
  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 WCD9XXX_MBHC_DEF_BUTTONS 8
  56. #define WCD9XXX_MBHC_DEF_RLOADS 5
  57. #define CODEC_EXT_CLK_RATE 9600000
  58. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  59. #define DEV_NAME_STR_LEN 32
  60. #define WSA8810_NAME_1 "wsa881x.20170211"
  61. #define WSA8810_NAME_2 "wsa881x.20170212"
  62. #define WCN_CDC_SLIM_RX_CH_MAX 2
  63. #define WCN_CDC_SLIM_TX_CH_MAX 3
  64. #define TDM_CHANNEL_MAX 8
  65. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  66. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  67. #define MSM_HIFI_ON 1
  68. #define SM6150_SOC_VERSION_1_0 0x00010000
  69. #define SM6150_SOC_MSM_ID 0x163
  70. enum {
  71. SLIM_RX_0 = 0,
  72. SLIM_RX_1,
  73. SLIM_RX_2,
  74. SLIM_RX_3,
  75. SLIM_RX_4,
  76. SLIM_RX_5,
  77. SLIM_RX_6,
  78. SLIM_RX_7,
  79. SLIM_RX_MAX,
  80. };
  81. enum {
  82. SLIM_TX_0 = 0,
  83. SLIM_TX_1,
  84. SLIM_TX_2,
  85. SLIM_TX_3,
  86. SLIM_TX_4,
  87. SLIM_TX_5,
  88. SLIM_TX_6,
  89. SLIM_TX_7,
  90. SLIM_TX_8,
  91. SLIM_TX_MAX,
  92. };
  93. enum {
  94. PRIM_MI2S = 0,
  95. SEC_MI2S,
  96. TERT_MI2S,
  97. QUAT_MI2S,
  98. QUIN_MI2S,
  99. MI2S_MAX,
  100. };
  101. enum {
  102. PRIM_AUX_PCM = 0,
  103. SEC_AUX_PCM,
  104. TERT_AUX_PCM,
  105. QUAT_AUX_PCM,
  106. QUIN_AUX_PCM,
  107. AUX_PCM_MAX,
  108. };
  109. enum {
  110. TDM_0 = 0,
  111. TDM_1,
  112. TDM_2,
  113. TDM_3,
  114. TDM_4,
  115. TDM_5,
  116. TDM_6,
  117. TDM_7,
  118. TDM_PORT_MAX,
  119. };
  120. enum {
  121. TDM_PRI = 0,
  122. TDM_SEC,
  123. TDM_TERT,
  124. TDM_QUAT,
  125. TDM_QUIN,
  126. TDM_INTERFACE_MAX,
  127. };
  128. struct tdm_port {
  129. u32 mode;
  130. u32 channel;
  131. };
  132. enum {
  133. WSA_CDC_DMA_RX_0 = 0,
  134. WSA_CDC_DMA_RX_1,
  135. RX_CDC_DMA_RX_0,
  136. RX_CDC_DMA_RX_1,
  137. RX_CDC_DMA_RX_2,
  138. RX_CDC_DMA_RX_3,
  139. RX_CDC_DMA_RX_5,
  140. CDC_DMA_RX_MAX,
  141. };
  142. enum {
  143. WSA_CDC_DMA_TX_0 = 0,
  144. WSA_CDC_DMA_TX_1,
  145. WSA_CDC_DMA_TX_2,
  146. TX_CDC_DMA_TX_0,
  147. TX_CDC_DMA_TX_3,
  148. TX_CDC_DMA_TX_4,
  149. CDC_DMA_TX_MAX,
  150. };
  151. struct mi2s_conf {
  152. struct mutex lock;
  153. u32 ref_cnt;
  154. u32 msm_is_mi2s_master;
  155. u32 msm_is_ext_mclk;
  156. };
  157. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  158. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  159. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  160. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  161. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT,
  162. Q6AFE_LPASS_CLK_ID_QUI_MI2S_EBIT
  163. };
  164. struct dev_config {
  165. u32 sample_rate;
  166. u32 bit_format;
  167. u32 channels;
  168. };
  169. enum {
  170. DP_RX_IDX = 0,
  171. EXT_DISP_RX_IDX_MAX,
  172. };
  173. struct msm_wsa881x_dev_info {
  174. struct device_node *of_node;
  175. u32 index;
  176. };
  177. struct aux_codec_dev_info {
  178. struct device_node *of_node;
  179. u32 index;
  180. };
  181. struct msm_asoc_mach_data {
  182. struct snd_info_entry *codec_root;
  183. int usbc_en2_gpio; /* used by gpio driver API */
  184. struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
  185. int hph_en1_gpio;
  186. int hph_en0_gpio;
  187. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  188. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  189. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  190. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  191. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  192. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  193. bool is_afe_config_done;
  194. struct device_node *fsa_handle;
  195. };
  196. struct msm_asoc_wcd93xx_codec {
  197. void* (*get_afe_config_fn)(struct snd_soc_component *component,
  198. enum afe_config_type config_type);
  199. };
  200. static struct snd_soc_card snd_soc_card_sm6150_msm;
  201. /* TDM default config */
  202. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  203. { /* PRI TDM */
  204. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  205. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  206. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  207. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  208. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  209. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  210. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  211. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  212. },
  213. { /* SEC TDM */
  214. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  215. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  216. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  217. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  218. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  219. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  220. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  221. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  222. },
  223. { /* TERT TDM */
  224. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  225. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  226. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  227. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  228. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  229. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  230. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  231. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  232. },
  233. { /* QUAT TDM */
  234. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  235. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  236. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  237. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  238. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  239. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  240. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  241. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  242. },
  243. { /* QUIN TDM */
  244. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  245. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  246. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  247. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  248. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  249. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  250. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  251. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  252. }
  253. };
  254. /* TDM default config */
  255. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  256. { /* PRI TDM */
  257. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  258. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  259. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  260. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  261. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  262. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  263. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  264. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  265. },
  266. { /* SEC TDM */
  267. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  268. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  269. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  270. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  271. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  272. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  273. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  274. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  275. },
  276. { /* TERT TDM */
  277. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  278. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  279. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  280. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  281. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  282. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  283. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  284. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  285. },
  286. { /* QUAT TDM */
  287. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  288. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  289. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  290. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  291. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  292. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  293. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  294. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  295. },
  296. { /* QUIN TDM */
  297. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  298. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  299. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  300. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  301. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  302. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  303. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  304. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  305. }
  306. };
  307. /* Default configuration of slimbus channels */
  308. static struct dev_config slim_rx_cfg[] = {
  309. [SLIM_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  310. [SLIM_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  311. [SLIM_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  312. [SLIM_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  313. [SLIM_RX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  314. [SLIM_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  315. [SLIM_RX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  316. [SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  317. };
  318. static struct dev_config slim_tx_cfg[] = {
  319. [SLIM_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  320. [SLIM_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  321. [SLIM_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  322. [SLIM_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  323. [SLIM_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  324. [SLIM_TX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  325. [SLIM_TX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  326. [SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  327. [SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  328. };
  329. /* Default configuration of Codec DMA Interface Tx */
  330. static struct dev_config cdc_dma_rx_cfg[] = {
  331. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  332. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  333. [RX_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  334. [RX_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  335. [RX_CDC_DMA_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  336. [RX_CDC_DMA_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  337. [RX_CDC_DMA_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  338. };
  339. /* Default configuration of Codec DMA Interface Rx */
  340. static struct dev_config cdc_dma_tx_cfg[] = {
  341. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  342. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  343. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  344. [TX_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  345. [TX_CDC_DMA_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  346. [TX_CDC_DMA_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  347. };
  348. /* Default configuration of external display BE */
  349. static struct dev_config ext_disp_rx_cfg[] = {
  350. [DP_RX_IDX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  351. };
  352. static struct dev_config usb_rx_cfg = {
  353. .sample_rate = SAMPLING_RATE_48KHZ,
  354. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  355. .channels = 2,
  356. };
  357. static struct dev_config usb_tx_cfg = {
  358. .sample_rate = SAMPLING_RATE_48KHZ,
  359. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  360. .channels = 1,
  361. };
  362. static struct dev_config proxy_rx_cfg = {
  363. .sample_rate = SAMPLING_RATE_48KHZ,
  364. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  365. .channels = 2,
  366. };
  367. /* Default configuration of MI2S channels */
  368. static struct dev_config mi2s_rx_cfg[] = {
  369. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  370. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  371. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  372. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  373. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  374. };
  375. static struct dev_config mi2s_tx_cfg[] = {
  376. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  377. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  378. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  379. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  380. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  381. };
  382. static struct dev_config aux_pcm_rx_cfg[] = {
  383. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  384. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  385. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  386. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  387. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  388. };
  389. static struct dev_config aux_pcm_tx_cfg[] = {
  390. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  391. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  392. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  393. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  394. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  395. };
  396. static int msm_vi_feed_tx_ch = 2;
  397. static const char *const slim_rx_ch_text[] = {"One", "Two"};
  398. static const char *const slim_tx_ch_text[] = {"One", "Two", "Three", "Four",
  399. "Five", "Six", "Seven",
  400. "Eight"};
  401. static const char *const vi_feed_ch_text[] = {"One", "Two"};
  402. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  403. "S32_LE"};
  404. static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
  405. "S24_3LE"};
  406. static char const *slim_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  407. "KHZ_32", "KHZ_44P1", "KHZ_48",
  408. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  409. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  410. static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  411. "KHZ_44P1", "KHZ_48",
  412. "KHZ_88P2", "KHZ_96"};
  413. static char const *bt_sample_rate_rx_text[] = {"KHZ_8", "KHZ_16",
  414. "KHZ_44P1", "KHZ_48",
  415. "KHZ_88P2", "KHZ_96"};
  416. static char const *bt_sample_rate_tx_text[] = {"KHZ_8", "KHZ_16",
  417. "KHZ_44P1", "KHZ_48",
  418. "KHZ_88P2", "KHZ_96"};
  419. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  420. "Five", "Six", "Seven",
  421. "Eight"};
  422. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  423. "Six", "Seven", "Eight"};
  424. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  425. "KHZ_16", "KHZ_22P05",
  426. "KHZ_32", "KHZ_44P1", "KHZ_48",
  427. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  428. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  429. static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  430. "KHZ_192", "KHZ_32", "KHZ_44P1",
  431. "KHZ_88P2", "KHZ_176P4" };
  432. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  433. "Five", "Six", "Seven", "Eight"};
  434. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  435. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  436. "KHZ_48", "KHZ_176P4",
  437. "KHZ_352P8"};
  438. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  439. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  440. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  441. "KHZ_48", "KHZ_96", "KHZ_192"};
  442. static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
  443. "Five", "Six", "Seven",
  444. "Eight"};
  445. static const char *const hifi_text[] = {"Off", "On"};
  446. static const char *const qos_text[] = {"Disable", "Enable"};
  447. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  448. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  449. "Five", "Six", "Seven",
  450. "Eight"};
  451. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  452. "KHZ_16", "KHZ_22P05",
  453. "KHZ_32", "KHZ_44P1", "KHZ_48",
  454. "KHZ_88P2", "KHZ_96",
  455. "KHZ_176P4", "KHZ_192",
  456. "KHZ_352P8", "KHZ_384"};
  457. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_chs, slim_rx_ch_text);
  458. static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_chs, slim_rx_ch_text);
  459. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_chs, slim_tx_ch_text);
  460. static SOC_ENUM_SINGLE_EXT_DECL(slim_1_tx_chs, slim_tx_ch_text);
  461. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_chs, slim_rx_ch_text);
  462. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_chs, slim_rx_ch_text);
  463. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  464. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  465. static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
  466. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
  467. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  468. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_format, bit_format_text);
  469. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_format, bit_format_text);
  470. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_format, bit_format_text);
  471. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_format, bit_format_text);
  472. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  473. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  474. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
  475. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_rx_sample_rate, slim_sample_rate_text);
  476. static SOC_ENUM_SINGLE_EXT_DECL(slim_2_rx_sample_rate, slim_sample_rate_text);
  477. static SOC_ENUM_SINGLE_EXT_DECL(slim_0_tx_sample_rate, slim_sample_rate_text);
  478. static SOC_ENUM_SINGLE_EXT_DECL(slim_5_rx_sample_rate, slim_sample_rate_text);
  479. static SOC_ENUM_SINGLE_EXT_DECL(slim_6_rx_sample_rate, slim_sample_rate_text);
  480. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
  481. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_rx, bt_sample_rate_rx_text);
  482. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_tx, bt_sample_rate_tx_text);
  483. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  484. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  485. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
  486. ext_disp_sample_rate_text);
  487. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  488. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  489. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  490. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  491. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  492. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  493. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  494. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  495. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  496. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  497. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  498. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  499. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  500. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  501. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  502. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  503. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  504. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  505. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  506. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
  507. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_sample_rate, mi2s_rate_text);
  508. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  509. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  510. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  511. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
  512. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_sample_rate, mi2s_rate_text);
  513. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  514. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  515. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  516. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  517. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  518. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  519. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
  520. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
  521. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_chs, mi2s_ch_text);
  522. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_chs, mi2s_ch_text);
  523. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  524. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  525. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  526. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  527. static SOC_ENUM_SINGLE_EXT_DECL(hifi_function, hifi_text);
  528. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  529. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  530. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  531. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  532. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_chs, cdc_dma_rx_ch_text);
  533. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_chs, cdc_dma_rx_ch_text);
  534. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_chs, cdc_dma_rx_ch_text);
  535. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  536. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  537. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  538. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  539. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_chs, cdc_dma_tx_ch_text);
  540. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_chs, cdc_dma_tx_ch_text);
  541. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  542. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  543. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_format, bit_format_text);
  544. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_format, bit_format_text);
  545. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_format, bit_format_text);
  546. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_format, bit_format_text);
  547. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_format, bit_format_text);
  548. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  549. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  550. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_format, bit_format_text);
  551. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_format, bit_format_text);
  552. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_format, bit_format_text);
  553. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  554. cdc_dma_sample_rate_text);
  555. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  556. cdc_dma_sample_rate_text);
  557. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_sample_rate,
  558. cdc_dma_sample_rate_text);
  559. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_sample_rate,
  560. cdc_dma_sample_rate_text);
  561. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_sample_rate,
  562. cdc_dma_sample_rate_text);
  563. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_sample_rate,
  564. cdc_dma_sample_rate_text);
  565. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_sample_rate,
  566. cdc_dma_sample_rate_text);
  567. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  568. cdc_dma_sample_rate_text);
  569. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  570. cdc_dma_sample_rate_text);
  571. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  572. cdc_dma_sample_rate_text);
  573. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_sample_rate,
  574. cdc_dma_sample_rate_text);
  575. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_sample_rate,
  576. cdc_dma_sample_rate_text);
  577. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate,
  578. cdc_dma_sample_rate_text);
  579. static int msm_hifi_control;
  580. static bool codec_reg_done;
  581. static struct snd_soc_aux_dev *msm_aux_dev;
  582. static struct snd_soc_codec_conf *msm_codec_conf;
  583. static struct msm_asoc_wcd93xx_codec msm_codec_fn;
  584. static int dmic_0_1_gpio_cnt;
  585. static int dmic_2_3_gpio_cnt;
  586. static void *def_wcd_mbhc_cal(void);
  587. static int msm_snd_enable_codec_ext_clk(struct snd_soc_component *component,
  588. int enable, bool dapm);
  589. static int msm_wsa881x_init(struct snd_soc_component *component);
  590. static int msm_aux_codec_init(struct snd_soc_component *component);
  591. /*
  592. * Need to report LINEIN
  593. * if R/L channel impedance is larger than 5K ohm
  594. */
  595. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  596. .read_fw_bin = false,
  597. .calibration = NULL,
  598. .detect_extn_cable = true,
  599. .mono_stero_detection = false,
  600. .swap_gnd_mic = NULL,
  601. .hs_ext_micbias = true,
  602. .key_code[0] = KEY_MEDIA,
  603. .key_code[1] = KEY_VOICECOMMAND,
  604. .key_code[2] = KEY_VOLUMEUP,
  605. .key_code[3] = KEY_VOLUMEDOWN,
  606. .key_code[4] = 0,
  607. .key_code[5] = 0,
  608. .key_code[6] = 0,
  609. .key_code[7] = 0,
  610. .linein_th = 5000,
  611. .moisture_en = false,
  612. .mbhc_micbias = MIC_BIAS_2,
  613. .anc_micbias = MIC_BIAS_2,
  614. .enable_anc_mic_detect = false,
  615. .moisture_duty_cycle_en = true,
  616. };
  617. static struct snd_soc_dapm_route wcd_audio_paths[] = {
  618. {"MIC BIAS1", NULL, "MCLK TX"},
  619. {"MIC BIAS2", NULL, "MCLK TX"},
  620. {"MIC BIAS3", NULL, "MCLK TX"},
  621. {"MIC BIAS4", NULL, "MCLK TX"},
  622. };
  623. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  624. {
  625. AFE_API_VERSION_I2S_CONFIG,
  626. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  627. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  628. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  629. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  630. 0,
  631. },
  632. {
  633. AFE_API_VERSION_I2S_CONFIG,
  634. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  635. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  636. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  637. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  638. 0,
  639. },
  640. {
  641. AFE_API_VERSION_I2S_CONFIG,
  642. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  643. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  644. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  645. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  646. 0,
  647. },
  648. {
  649. AFE_API_VERSION_I2S_CONFIG,
  650. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
  651. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  652. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  653. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  654. 0,
  655. },
  656. {
  657. AFE_API_VERSION_I2S_CONFIG,
  658. Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT,
  659. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  660. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  661. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  662. 0,
  663. }
  664. };
  665. static struct afe_clk_set mi2s_mclk[MI2S_MAX] = {
  666. {
  667. AFE_API_VERSION_I2S_CONFIG,
  668. Q6AFE_LPASS_CLK_ID_MCLK_3,
  669. Q6AFE_LPASS_OSR_CLK_9_P600_MHZ,
  670. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  671. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  672. 0,
  673. },
  674. {
  675. AFE_API_VERSION_I2S_CONFIG,
  676. Q6AFE_LPASS_CLK_ID_MCLK_2,
  677. Q6AFE_LPASS_OSR_CLK_9_P600_MHZ,
  678. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  679. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  680. 0,
  681. },
  682. {
  683. AFE_API_VERSION_I2S_CONFIG,
  684. Q6AFE_LPASS_CLK_ID_MCLK_1,
  685. Q6AFE_LPASS_OSR_CLK_9_P600_MHZ,
  686. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  687. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  688. 0,
  689. },
  690. {
  691. AFE_API_VERSION_I2S_CONFIG,
  692. Q6AFE_LPASS_CLK_ID_MCLK_1,
  693. Q6AFE_LPASS_OSR_CLK_9_P600_MHZ,
  694. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  695. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  696. 0,
  697. },
  698. {
  699. AFE_API_VERSION_I2S_CONFIG,
  700. Q6AFE_LPASS_CLK_ID_QUI_MI2S_OSR,
  701. Q6AFE_LPASS_OSR_CLK_9_P600_MHZ,
  702. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  703. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  704. 0,
  705. }
  706. };
  707. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  708. static int slim_get_sample_rate_val(int sample_rate)
  709. {
  710. int sample_rate_val = 0;
  711. switch (sample_rate) {
  712. case SAMPLING_RATE_8KHZ:
  713. sample_rate_val = 0;
  714. break;
  715. case SAMPLING_RATE_16KHZ:
  716. sample_rate_val = 1;
  717. break;
  718. case SAMPLING_RATE_32KHZ:
  719. sample_rate_val = 2;
  720. break;
  721. case SAMPLING_RATE_44P1KHZ:
  722. sample_rate_val = 3;
  723. break;
  724. case SAMPLING_RATE_48KHZ:
  725. sample_rate_val = 4;
  726. break;
  727. case SAMPLING_RATE_88P2KHZ:
  728. sample_rate_val = 5;
  729. break;
  730. case SAMPLING_RATE_96KHZ:
  731. sample_rate_val = 6;
  732. break;
  733. case SAMPLING_RATE_176P4KHZ:
  734. sample_rate_val = 7;
  735. break;
  736. case SAMPLING_RATE_192KHZ:
  737. sample_rate_val = 8;
  738. break;
  739. case SAMPLING_RATE_352P8KHZ:
  740. sample_rate_val = 9;
  741. break;
  742. case SAMPLING_RATE_384KHZ:
  743. sample_rate_val = 10;
  744. break;
  745. default:
  746. sample_rate_val = 4;
  747. break;
  748. }
  749. return sample_rate_val;
  750. }
  751. static int slim_get_sample_rate(int value)
  752. {
  753. int sample_rate = 0;
  754. switch (value) {
  755. case 0:
  756. sample_rate = SAMPLING_RATE_8KHZ;
  757. break;
  758. case 1:
  759. sample_rate = SAMPLING_RATE_16KHZ;
  760. break;
  761. case 2:
  762. sample_rate = SAMPLING_RATE_32KHZ;
  763. break;
  764. case 3:
  765. sample_rate = SAMPLING_RATE_44P1KHZ;
  766. break;
  767. case 4:
  768. sample_rate = SAMPLING_RATE_48KHZ;
  769. break;
  770. case 5:
  771. sample_rate = SAMPLING_RATE_88P2KHZ;
  772. break;
  773. case 6:
  774. sample_rate = SAMPLING_RATE_96KHZ;
  775. break;
  776. case 7:
  777. sample_rate = SAMPLING_RATE_176P4KHZ;
  778. break;
  779. case 8:
  780. sample_rate = SAMPLING_RATE_192KHZ;
  781. break;
  782. case 9:
  783. sample_rate = SAMPLING_RATE_352P8KHZ;
  784. break;
  785. case 10:
  786. sample_rate = SAMPLING_RATE_384KHZ;
  787. break;
  788. default:
  789. sample_rate = SAMPLING_RATE_48KHZ;
  790. break;
  791. }
  792. return sample_rate;
  793. }
  794. static int slim_get_bit_format_val(int bit_format)
  795. {
  796. int val = 0;
  797. switch (bit_format) {
  798. case SNDRV_PCM_FORMAT_S32_LE:
  799. val = 3;
  800. break;
  801. case SNDRV_PCM_FORMAT_S24_3LE:
  802. val = 2;
  803. break;
  804. case SNDRV_PCM_FORMAT_S24_LE:
  805. val = 1;
  806. break;
  807. case SNDRV_PCM_FORMAT_S16_LE:
  808. default:
  809. val = 0;
  810. break;
  811. }
  812. return val;
  813. }
  814. static int slim_get_bit_format(int val)
  815. {
  816. int bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  817. switch (val) {
  818. case 0:
  819. bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  820. break;
  821. case 1:
  822. bit_fmt = SNDRV_PCM_FORMAT_S24_LE;
  823. break;
  824. case 2:
  825. bit_fmt = SNDRV_PCM_FORMAT_S24_3LE;
  826. break;
  827. case 3:
  828. bit_fmt = SNDRV_PCM_FORMAT_S32_LE;
  829. break;
  830. default:
  831. bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  832. break;
  833. }
  834. return bit_fmt;
  835. }
  836. static int slim_get_port_idx(struct snd_kcontrol *kcontrol)
  837. {
  838. int port_id = 0;
  839. if (strnstr(kcontrol->id.name, "SLIM_0_RX", sizeof("SLIM_0_RX"))) {
  840. port_id = SLIM_RX_0;
  841. } else if (strnstr(kcontrol->id.name,
  842. "SLIM_2_RX", sizeof("SLIM_2_RX"))) {
  843. port_id = SLIM_RX_2;
  844. } else if (strnstr(kcontrol->id.name,
  845. "SLIM_5_RX", sizeof("SLIM_5_RX"))) {
  846. port_id = SLIM_RX_5;
  847. } else if (strnstr(kcontrol->id.name,
  848. "SLIM_6_RX", sizeof("SLIM_6_RX"))) {
  849. port_id = SLIM_RX_6;
  850. } else if (strnstr(kcontrol->id.name,
  851. "SLIM_0_TX", sizeof("SLIM_0_TX"))) {
  852. port_id = SLIM_TX_0;
  853. } else if (strnstr(kcontrol->id.name,
  854. "SLIM_1_TX", sizeof("SLIM_1_TX"))) {
  855. port_id = SLIM_TX_1;
  856. } else {
  857. pr_err("%s: unsupported channel: %s\n",
  858. __func__, kcontrol->id.name);
  859. return -EINVAL;
  860. }
  861. return port_id;
  862. }
  863. static int slim_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  864. struct snd_ctl_elem_value *ucontrol)
  865. {
  866. int ch_num = slim_get_port_idx(kcontrol);
  867. if (ch_num < 0)
  868. return ch_num;
  869. ucontrol->value.enumerated.item[0] =
  870. slim_get_sample_rate_val(slim_rx_cfg[ch_num].sample_rate);
  871. pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  872. ch_num, slim_rx_cfg[ch_num].sample_rate,
  873. ucontrol->value.enumerated.item[0]);
  874. return 0;
  875. }
  876. static int slim_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  877. struct snd_ctl_elem_value *ucontrol)
  878. {
  879. int ch_num = slim_get_port_idx(kcontrol);
  880. if (ch_num < 0)
  881. return ch_num;
  882. slim_rx_cfg[ch_num].sample_rate =
  883. slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
  884. pr_debug("%s: slim[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  885. ch_num, slim_rx_cfg[ch_num].sample_rate,
  886. ucontrol->value.enumerated.item[0]);
  887. return 0;
  888. }
  889. static int slim_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  890. struct snd_ctl_elem_value *ucontrol)
  891. {
  892. int ch_num = slim_get_port_idx(kcontrol);
  893. if (ch_num < 0)
  894. return ch_num;
  895. ucontrol->value.enumerated.item[0] =
  896. slim_get_sample_rate_val(slim_tx_cfg[ch_num].sample_rate);
  897. pr_debug("%s: slim[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  898. ch_num, slim_tx_cfg[ch_num].sample_rate,
  899. ucontrol->value.enumerated.item[0]);
  900. return 0;
  901. }
  902. static int slim_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  903. struct snd_ctl_elem_value *ucontrol)
  904. {
  905. int sample_rate = 0;
  906. int ch_num = slim_get_port_idx(kcontrol);
  907. if (ch_num < 0)
  908. return ch_num;
  909. sample_rate = slim_get_sample_rate(ucontrol->value.enumerated.item[0]);
  910. if (sample_rate == SAMPLING_RATE_44P1KHZ) {
  911. pr_err("%s: Unsupported sample rate %d: for Tx path\n",
  912. __func__, sample_rate);
  913. return -EINVAL;
  914. }
  915. slim_tx_cfg[ch_num].sample_rate = sample_rate;
  916. pr_debug("%s: slim[%d]_tx_sample_rate = %d, value = %d\n", __func__,
  917. ch_num, slim_tx_cfg[ch_num].sample_rate,
  918. ucontrol->value.enumerated.item[0]);
  919. return 0;
  920. }
  921. static int slim_rx_bit_format_get(struct snd_kcontrol *kcontrol,
  922. struct snd_ctl_elem_value *ucontrol)
  923. {
  924. int ch_num = slim_get_port_idx(kcontrol);
  925. if (ch_num < 0)
  926. return ch_num;
  927. ucontrol->value.enumerated.item[0] =
  928. slim_get_bit_format_val(slim_rx_cfg[ch_num].bit_format);
  929. pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
  930. __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
  931. ucontrol->value.enumerated.item[0]);
  932. return 0;
  933. }
  934. static int slim_rx_bit_format_put(struct snd_kcontrol *kcontrol,
  935. struct snd_ctl_elem_value *ucontrol)
  936. {
  937. int ch_num = slim_get_port_idx(kcontrol);
  938. if (ch_num < 0)
  939. return ch_num;
  940. slim_rx_cfg[ch_num].bit_format =
  941. slim_get_bit_format(ucontrol->value.enumerated.item[0]);
  942. pr_debug("%s: slim[%d]_rx_bit_format = %d, ucontrol value = %d\n",
  943. __func__, ch_num, slim_rx_cfg[ch_num].bit_format,
  944. ucontrol->value.enumerated.item[0]);
  945. return 0;
  946. }
  947. static int slim_tx_bit_format_get(struct snd_kcontrol *kcontrol,
  948. struct snd_ctl_elem_value *ucontrol)
  949. {
  950. int ch_num = slim_get_port_idx(kcontrol);
  951. if (ch_num < 0)
  952. return ch_num;
  953. ucontrol->value.enumerated.item[0] =
  954. slim_get_bit_format_val(slim_tx_cfg[ch_num].bit_format);
  955. pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
  956. __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
  957. ucontrol->value.enumerated.item[0]);
  958. return 0;
  959. }
  960. static int slim_tx_bit_format_put(struct snd_kcontrol *kcontrol,
  961. struct snd_ctl_elem_value *ucontrol)
  962. {
  963. int ch_num = slim_get_port_idx(kcontrol);
  964. if (ch_num < 0)
  965. return ch_num;
  966. slim_tx_cfg[ch_num].bit_format =
  967. slim_get_bit_format(ucontrol->value.enumerated.item[0]);
  968. pr_debug("%s: slim[%d]_tx_bit_format = %d, ucontrol value = %d\n",
  969. __func__, ch_num, slim_tx_cfg[ch_num].bit_format,
  970. ucontrol->value.enumerated.item[0]);
  971. return 0;
  972. }
  973. static int slim_rx_ch_get(struct snd_kcontrol *kcontrol,
  974. struct snd_ctl_elem_value *ucontrol)
  975. {
  976. int ch_num = slim_get_port_idx(kcontrol);
  977. if (ch_num < 0)
  978. return ch_num;
  979. pr_debug("%s: msm_slim_[%d]_rx_ch = %d\n", __func__,
  980. ch_num, slim_rx_cfg[ch_num].channels);
  981. ucontrol->value.enumerated.item[0] = slim_rx_cfg[ch_num].channels - 1;
  982. return 0;
  983. }
  984. static int slim_rx_ch_put(struct snd_kcontrol *kcontrol,
  985. struct snd_ctl_elem_value *ucontrol)
  986. {
  987. int ch_num = slim_get_port_idx(kcontrol);
  988. if (ch_num < 0)
  989. return ch_num;
  990. slim_rx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
  991. pr_debug("%s: msm_slim_[%d]_rx_ch = %d\n", __func__,
  992. ch_num, slim_rx_cfg[ch_num].channels);
  993. return 1;
  994. }
  995. static int slim_tx_ch_get(struct snd_kcontrol *kcontrol,
  996. struct snd_ctl_elem_value *ucontrol)
  997. {
  998. int ch_num = slim_get_port_idx(kcontrol);
  999. if (ch_num < 0)
  1000. return ch_num;
  1001. pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
  1002. ch_num, slim_tx_cfg[ch_num].channels);
  1003. ucontrol->value.enumerated.item[0] = slim_tx_cfg[ch_num].channels - 1;
  1004. return 0;
  1005. }
  1006. static int slim_tx_ch_put(struct snd_kcontrol *kcontrol,
  1007. struct snd_ctl_elem_value *ucontrol)
  1008. {
  1009. int ch_num = slim_get_port_idx(kcontrol);
  1010. if (ch_num < 0)
  1011. return ch_num;
  1012. slim_tx_cfg[ch_num].channels = ucontrol->value.enumerated.item[0] + 1;
  1013. pr_debug("%s: msm_slim_[%d]_tx_ch = %d\n", __func__,
  1014. ch_num, slim_tx_cfg[ch_num].channels);
  1015. return 1;
  1016. }
  1017. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  1018. struct snd_ctl_elem_value *ucontrol)
  1019. {
  1020. ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
  1021. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  1022. ucontrol->value.integer.value[0]);
  1023. return 0;
  1024. }
  1025. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  1026. struct snd_ctl_elem_value *ucontrol)
  1027. {
  1028. msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
  1029. pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
  1030. return 1;
  1031. }
  1032. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  1033. struct snd_ctl_elem_value *ucontrol)
  1034. {
  1035. /*
  1036. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  1037. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  1038. * value.
  1039. */
  1040. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  1041. case SAMPLING_RATE_96KHZ:
  1042. ucontrol->value.integer.value[0] = 5;
  1043. break;
  1044. case SAMPLING_RATE_88P2KHZ:
  1045. ucontrol->value.integer.value[0] = 4;
  1046. break;
  1047. case SAMPLING_RATE_48KHZ:
  1048. ucontrol->value.integer.value[0] = 3;
  1049. break;
  1050. case SAMPLING_RATE_44P1KHZ:
  1051. ucontrol->value.integer.value[0] = 2;
  1052. break;
  1053. case SAMPLING_RATE_16KHZ:
  1054. ucontrol->value.integer.value[0] = 1;
  1055. break;
  1056. case SAMPLING_RATE_8KHZ:
  1057. default:
  1058. ucontrol->value.integer.value[0] = 0;
  1059. break;
  1060. }
  1061. pr_debug("%s: sample rate = %d\n", __func__,
  1062. slim_rx_cfg[SLIM_RX_7].sample_rate);
  1063. return 0;
  1064. }
  1065. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  1066. struct snd_ctl_elem_value *ucontrol)
  1067. {
  1068. switch (ucontrol->value.integer.value[0]) {
  1069. case 1:
  1070. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  1071. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  1072. break;
  1073. case 2:
  1074. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  1075. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  1076. break;
  1077. case 3:
  1078. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  1079. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  1080. break;
  1081. case 4:
  1082. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  1083. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  1084. break;
  1085. case 5:
  1086. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  1087. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  1088. break;
  1089. case 0:
  1090. default:
  1091. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  1092. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  1093. break;
  1094. }
  1095. pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
  1096. __func__,
  1097. slim_rx_cfg[SLIM_RX_7].sample_rate,
  1098. slim_tx_cfg[SLIM_TX_7].sample_rate,
  1099. ucontrol->value.enumerated.item[0]);
  1100. return 0;
  1101. }
  1102. static int msm_bt_sample_rate_rx_get(struct snd_kcontrol *kcontrol,
  1103. struct snd_ctl_elem_value *ucontrol)
  1104. {
  1105. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  1106. case SAMPLING_RATE_96KHZ:
  1107. ucontrol->value.integer.value[0] = 5;
  1108. break;
  1109. case SAMPLING_RATE_88P2KHZ:
  1110. ucontrol->value.integer.value[0] = 4;
  1111. break;
  1112. case SAMPLING_RATE_48KHZ:
  1113. ucontrol->value.integer.value[0] = 3;
  1114. break;
  1115. case SAMPLING_RATE_44P1KHZ:
  1116. ucontrol->value.integer.value[0] = 2;
  1117. break;
  1118. case SAMPLING_RATE_16KHZ:
  1119. ucontrol->value.integer.value[0] = 1;
  1120. break;
  1121. case SAMPLING_RATE_8KHZ:
  1122. default:
  1123. ucontrol->value.integer.value[0] = 0;
  1124. break;
  1125. }
  1126. pr_debug("%s: sample rate rx = %d", __func__,
  1127. slim_rx_cfg[SLIM_RX_7].sample_rate);
  1128. return 0;
  1129. }
  1130. static int msm_bt_sample_rate_rx_put(struct snd_kcontrol *kcontrol,
  1131. struct snd_ctl_elem_value *ucontrol)
  1132. {
  1133. switch (ucontrol->value.integer.value[0]) {
  1134. case 1:
  1135. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  1136. break;
  1137. case 2:
  1138. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  1139. break;
  1140. case 3:
  1141. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  1142. break;
  1143. case 4:
  1144. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  1145. break;
  1146. case 5:
  1147. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  1148. break;
  1149. case 0:
  1150. default:
  1151. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  1152. break;
  1153. }
  1154. pr_debug("%s: sample rate: slim7_rx = %d, value = %d\n",
  1155. __func__,
  1156. slim_rx_cfg[SLIM_RX_7].sample_rate,
  1157. ucontrol->value.enumerated.item[0]);
  1158. return 0;
  1159. }
  1160. static int msm_bt_sample_rate_tx_get(struct snd_kcontrol *kcontrol,
  1161. struct snd_ctl_elem_value *ucontrol)
  1162. {
  1163. switch (slim_tx_cfg[SLIM_TX_7].sample_rate) {
  1164. case SAMPLING_RATE_96KHZ:
  1165. ucontrol->value.integer.value[0] = 5;
  1166. break;
  1167. case SAMPLING_RATE_88P2KHZ:
  1168. ucontrol->value.integer.value[0] = 4;
  1169. break;
  1170. case SAMPLING_RATE_48KHZ:
  1171. ucontrol->value.integer.value[0] = 3;
  1172. break;
  1173. case SAMPLING_RATE_44P1KHZ:
  1174. ucontrol->value.integer.value[0] = 2;
  1175. break;
  1176. case SAMPLING_RATE_16KHZ:
  1177. ucontrol->value.integer.value[0] = 1;
  1178. break;
  1179. case SAMPLING_RATE_8KHZ:
  1180. default:
  1181. ucontrol->value.integer.value[0] = 0;
  1182. break;
  1183. }
  1184. pr_debug("%s: sample rate tx = %d", __func__,
  1185. slim_tx_cfg[SLIM_TX_7].sample_rate);
  1186. return 0;
  1187. }
  1188. static int msm_bt_sample_rate_tx_put(struct snd_kcontrol *kcontrol,
  1189. struct snd_ctl_elem_value *ucontrol)
  1190. {
  1191. switch (ucontrol->value.integer.value[0]) {
  1192. case 1:
  1193. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  1194. break;
  1195. case 2:
  1196. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  1197. break;
  1198. case 3:
  1199. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  1200. break;
  1201. case 4:
  1202. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  1203. break;
  1204. case 5:
  1205. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  1206. break;
  1207. case 0:
  1208. default:
  1209. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  1210. break;
  1211. }
  1212. pr_debug("%s: sample rate: slim7_tx = %d, value = %d\n",
  1213. __func__,
  1214. slim_tx_cfg[SLIM_TX_7].sample_rate,
  1215. ucontrol->value.enumerated.item[0]);
  1216. return 0;
  1217. }
  1218. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  1219. {
  1220. int idx = 0;
  1221. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  1222. sizeof("WSA_CDC_DMA_RX_0")))
  1223. idx = WSA_CDC_DMA_RX_0;
  1224. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  1225. sizeof("WSA_CDC_DMA_RX_0")))
  1226. idx = WSA_CDC_DMA_RX_1;
  1227. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
  1228. sizeof("RX_CDC_DMA_RX_0")))
  1229. idx = RX_CDC_DMA_RX_0;
  1230. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
  1231. sizeof("RX_CDC_DMA_RX_1")))
  1232. idx = RX_CDC_DMA_RX_1;
  1233. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
  1234. sizeof("RX_CDC_DMA_RX_2")))
  1235. idx = RX_CDC_DMA_RX_2;
  1236. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
  1237. sizeof("RX_CDC_DMA_RX_3")))
  1238. idx = RX_CDC_DMA_RX_3;
  1239. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
  1240. sizeof("RX_CDC_DMA_RX_5")))
  1241. idx = RX_CDC_DMA_RX_5;
  1242. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  1243. sizeof("WSA_CDC_DMA_TX_0")))
  1244. idx = WSA_CDC_DMA_TX_0;
  1245. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  1246. sizeof("WSA_CDC_DMA_TX_1")))
  1247. idx = WSA_CDC_DMA_TX_1;
  1248. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  1249. sizeof("WSA_CDC_DMA_TX_2")))
  1250. idx = WSA_CDC_DMA_TX_2;
  1251. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
  1252. sizeof("TX_CDC_DMA_TX_0")))
  1253. idx = TX_CDC_DMA_TX_0;
  1254. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
  1255. sizeof("TX_CDC_DMA_TX_3")))
  1256. idx = TX_CDC_DMA_TX_3;
  1257. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
  1258. sizeof("TX_CDC_DMA_TX_4")))
  1259. idx = TX_CDC_DMA_TX_4;
  1260. else {
  1261. pr_err("%s: unsupported channel: %s\n",
  1262. __func__, kcontrol->id.name);
  1263. return -EINVAL;
  1264. }
  1265. return idx;
  1266. }
  1267. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  1268. struct snd_ctl_elem_value *ucontrol)
  1269. {
  1270. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1271. if (ch_num < 0) {
  1272. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1273. return ch_num;
  1274. }
  1275. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  1276. cdc_dma_rx_cfg[ch_num].channels - 1);
  1277. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  1278. return 0;
  1279. }
  1280. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  1281. struct snd_ctl_elem_value *ucontrol)
  1282. {
  1283. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1284. if (ch_num < 0) {
  1285. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1286. return ch_num;
  1287. }
  1288. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  1289. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  1290. cdc_dma_rx_cfg[ch_num].channels);
  1291. return 1;
  1292. }
  1293. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  1294. struct snd_ctl_elem_value *ucontrol)
  1295. {
  1296. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1297. if (ch_num < 0) {
  1298. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1299. return ch_num;
  1300. }
  1301. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  1302. case SNDRV_PCM_FORMAT_S32_LE:
  1303. ucontrol->value.integer.value[0] = 3;
  1304. break;
  1305. case SNDRV_PCM_FORMAT_S24_3LE:
  1306. ucontrol->value.integer.value[0] = 2;
  1307. break;
  1308. case SNDRV_PCM_FORMAT_S24_LE:
  1309. ucontrol->value.integer.value[0] = 1;
  1310. break;
  1311. case SNDRV_PCM_FORMAT_S16_LE:
  1312. default:
  1313. ucontrol->value.integer.value[0] = 0;
  1314. break;
  1315. }
  1316. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  1317. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  1318. ucontrol->value.integer.value[0]);
  1319. return 0;
  1320. }
  1321. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  1322. struct snd_ctl_elem_value *ucontrol)
  1323. {
  1324. int rc = 0;
  1325. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1326. if (ch_num < 0) {
  1327. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1328. return ch_num;
  1329. }
  1330. switch (ucontrol->value.integer.value[0]) {
  1331. case 3:
  1332. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1333. break;
  1334. case 2:
  1335. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1336. break;
  1337. case 1:
  1338. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1339. break;
  1340. case 0:
  1341. default:
  1342. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1343. break;
  1344. }
  1345. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  1346. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  1347. ucontrol->value.integer.value[0]);
  1348. return rc;
  1349. }
  1350. static int cdc_dma_get_sample_rate_val(int sample_rate)
  1351. {
  1352. int sample_rate_val = 0;
  1353. switch (sample_rate) {
  1354. case SAMPLING_RATE_8KHZ:
  1355. sample_rate_val = 0;
  1356. break;
  1357. case SAMPLING_RATE_11P025KHZ:
  1358. sample_rate_val = 1;
  1359. break;
  1360. case SAMPLING_RATE_16KHZ:
  1361. sample_rate_val = 2;
  1362. break;
  1363. case SAMPLING_RATE_22P05KHZ:
  1364. sample_rate_val = 3;
  1365. break;
  1366. case SAMPLING_RATE_32KHZ:
  1367. sample_rate_val = 4;
  1368. break;
  1369. case SAMPLING_RATE_44P1KHZ:
  1370. sample_rate_val = 5;
  1371. break;
  1372. case SAMPLING_RATE_48KHZ:
  1373. sample_rate_val = 6;
  1374. break;
  1375. case SAMPLING_RATE_88P2KHZ:
  1376. sample_rate_val = 7;
  1377. break;
  1378. case SAMPLING_RATE_96KHZ:
  1379. sample_rate_val = 8;
  1380. break;
  1381. case SAMPLING_RATE_176P4KHZ:
  1382. sample_rate_val = 9;
  1383. break;
  1384. case SAMPLING_RATE_192KHZ:
  1385. sample_rate_val = 10;
  1386. break;
  1387. case SAMPLING_RATE_352P8KHZ:
  1388. sample_rate_val = 11;
  1389. break;
  1390. case SAMPLING_RATE_384KHZ:
  1391. sample_rate_val = 12;
  1392. break;
  1393. default:
  1394. sample_rate_val = 6;
  1395. break;
  1396. }
  1397. return sample_rate_val;
  1398. }
  1399. static int cdc_dma_get_sample_rate(int value)
  1400. {
  1401. int sample_rate = 0;
  1402. switch (value) {
  1403. case 0:
  1404. sample_rate = SAMPLING_RATE_8KHZ;
  1405. break;
  1406. case 1:
  1407. sample_rate = SAMPLING_RATE_11P025KHZ;
  1408. break;
  1409. case 2:
  1410. sample_rate = SAMPLING_RATE_16KHZ;
  1411. break;
  1412. case 3:
  1413. sample_rate = SAMPLING_RATE_22P05KHZ;
  1414. break;
  1415. case 4:
  1416. sample_rate = SAMPLING_RATE_32KHZ;
  1417. break;
  1418. case 5:
  1419. sample_rate = SAMPLING_RATE_44P1KHZ;
  1420. break;
  1421. case 6:
  1422. sample_rate = SAMPLING_RATE_48KHZ;
  1423. break;
  1424. case 7:
  1425. sample_rate = SAMPLING_RATE_88P2KHZ;
  1426. break;
  1427. case 8:
  1428. sample_rate = SAMPLING_RATE_96KHZ;
  1429. break;
  1430. case 9:
  1431. sample_rate = SAMPLING_RATE_176P4KHZ;
  1432. break;
  1433. case 10:
  1434. sample_rate = SAMPLING_RATE_192KHZ;
  1435. break;
  1436. case 11:
  1437. sample_rate = SAMPLING_RATE_352P8KHZ;
  1438. break;
  1439. case 12:
  1440. sample_rate = SAMPLING_RATE_384KHZ;
  1441. break;
  1442. default:
  1443. sample_rate = SAMPLING_RATE_48KHZ;
  1444. break;
  1445. }
  1446. return sample_rate;
  1447. }
  1448. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1449. struct snd_ctl_elem_value *ucontrol)
  1450. {
  1451. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1452. if (ch_num < 0) {
  1453. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1454. return ch_num;
  1455. }
  1456. ucontrol->value.enumerated.item[0] =
  1457. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  1458. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  1459. cdc_dma_rx_cfg[ch_num].sample_rate);
  1460. return 0;
  1461. }
  1462. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1463. struct snd_ctl_elem_value *ucontrol)
  1464. {
  1465. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1466. if (ch_num < 0) {
  1467. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1468. return ch_num;
  1469. }
  1470. cdc_dma_rx_cfg[ch_num].sample_rate =
  1471. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1472. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  1473. __func__, ucontrol->value.enumerated.item[0],
  1474. cdc_dma_rx_cfg[ch_num].sample_rate);
  1475. return 0;
  1476. }
  1477. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  1478. struct snd_ctl_elem_value *ucontrol)
  1479. {
  1480. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1481. if (ch_num < 0) {
  1482. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1483. return ch_num;
  1484. }
  1485. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  1486. cdc_dma_tx_cfg[ch_num].channels);
  1487. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  1488. return 0;
  1489. }
  1490. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  1491. struct snd_ctl_elem_value *ucontrol)
  1492. {
  1493. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1494. if (ch_num < 0) {
  1495. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1496. return ch_num;
  1497. }
  1498. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  1499. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  1500. cdc_dma_tx_cfg[ch_num].channels);
  1501. return 1;
  1502. }
  1503. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1504. struct snd_ctl_elem_value *ucontrol)
  1505. {
  1506. int sample_rate_val;
  1507. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1508. if (ch_num < 0) {
  1509. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1510. return ch_num;
  1511. }
  1512. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  1513. case SAMPLING_RATE_384KHZ:
  1514. sample_rate_val = 12;
  1515. break;
  1516. case SAMPLING_RATE_352P8KHZ:
  1517. sample_rate_val = 11;
  1518. break;
  1519. case SAMPLING_RATE_192KHZ:
  1520. sample_rate_val = 10;
  1521. break;
  1522. case SAMPLING_RATE_176P4KHZ:
  1523. sample_rate_val = 9;
  1524. break;
  1525. case SAMPLING_RATE_96KHZ:
  1526. sample_rate_val = 8;
  1527. break;
  1528. case SAMPLING_RATE_88P2KHZ:
  1529. sample_rate_val = 7;
  1530. break;
  1531. case SAMPLING_RATE_48KHZ:
  1532. sample_rate_val = 6;
  1533. break;
  1534. case SAMPLING_RATE_44P1KHZ:
  1535. sample_rate_val = 5;
  1536. break;
  1537. case SAMPLING_RATE_32KHZ:
  1538. sample_rate_val = 4;
  1539. break;
  1540. case SAMPLING_RATE_22P05KHZ:
  1541. sample_rate_val = 3;
  1542. break;
  1543. case SAMPLING_RATE_16KHZ:
  1544. sample_rate_val = 2;
  1545. break;
  1546. case SAMPLING_RATE_11P025KHZ:
  1547. sample_rate_val = 1;
  1548. break;
  1549. case SAMPLING_RATE_8KHZ:
  1550. sample_rate_val = 0;
  1551. break;
  1552. default:
  1553. sample_rate_val = 6;
  1554. break;
  1555. }
  1556. ucontrol->value.integer.value[0] = sample_rate_val;
  1557. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  1558. cdc_dma_tx_cfg[ch_num].sample_rate);
  1559. return 0;
  1560. }
  1561. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1562. struct snd_ctl_elem_value *ucontrol)
  1563. {
  1564. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1565. if (ch_num < 0) {
  1566. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1567. return ch_num;
  1568. }
  1569. switch (ucontrol->value.integer.value[0]) {
  1570. case 12:
  1571. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  1572. break;
  1573. case 11:
  1574. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  1575. break;
  1576. case 10:
  1577. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  1578. break;
  1579. case 9:
  1580. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  1581. break;
  1582. case 8:
  1583. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  1584. break;
  1585. case 7:
  1586. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  1587. break;
  1588. case 6:
  1589. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  1590. break;
  1591. case 5:
  1592. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  1593. break;
  1594. case 4:
  1595. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  1596. break;
  1597. case 3:
  1598. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  1599. break;
  1600. case 2:
  1601. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  1602. break;
  1603. case 1:
  1604. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  1605. break;
  1606. case 0:
  1607. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  1608. break;
  1609. default:
  1610. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  1611. break;
  1612. }
  1613. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  1614. __func__, ucontrol->value.integer.value[0],
  1615. cdc_dma_tx_cfg[ch_num].sample_rate);
  1616. return 0;
  1617. }
  1618. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  1619. struct snd_ctl_elem_value *ucontrol)
  1620. {
  1621. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1622. if (ch_num < 0) {
  1623. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1624. return ch_num;
  1625. }
  1626. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  1627. case SNDRV_PCM_FORMAT_S32_LE:
  1628. ucontrol->value.integer.value[0] = 3;
  1629. break;
  1630. case SNDRV_PCM_FORMAT_S24_3LE:
  1631. ucontrol->value.integer.value[0] = 2;
  1632. break;
  1633. case SNDRV_PCM_FORMAT_S24_LE:
  1634. ucontrol->value.integer.value[0] = 1;
  1635. break;
  1636. case SNDRV_PCM_FORMAT_S16_LE:
  1637. default:
  1638. ucontrol->value.integer.value[0] = 0;
  1639. break;
  1640. }
  1641. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  1642. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  1643. ucontrol->value.integer.value[0]);
  1644. return 0;
  1645. }
  1646. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  1647. struct snd_ctl_elem_value *ucontrol)
  1648. {
  1649. int rc = 0;
  1650. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1651. if (ch_num < 0) {
  1652. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1653. return ch_num;
  1654. }
  1655. switch (ucontrol->value.integer.value[0]) {
  1656. case 3:
  1657. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1658. break;
  1659. case 2:
  1660. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1661. break;
  1662. case 1:
  1663. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1664. break;
  1665. case 0:
  1666. default:
  1667. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1668. break;
  1669. }
  1670. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  1671. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  1672. ucontrol->value.integer.value[0]);
  1673. return rc;
  1674. }
  1675. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  1676. struct snd_ctl_elem_value *ucontrol)
  1677. {
  1678. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  1679. usb_rx_cfg.channels);
  1680. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  1681. return 0;
  1682. }
  1683. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  1684. struct snd_ctl_elem_value *ucontrol)
  1685. {
  1686. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1687. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  1688. return 1;
  1689. }
  1690. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1691. struct snd_ctl_elem_value *ucontrol)
  1692. {
  1693. int sample_rate_val;
  1694. switch (usb_rx_cfg.sample_rate) {
  1695. case SAMPLING_RATE_384KHZ:
  1696. sample_rate_val = 12;
  1697. break;
  1698. case SAMPLING_RATE_352P8KHZ:
  1699. sample_rate_val = 11;
  1700. break;
  1701. case SAMPLING_RATE_192KHZ:
  1702. sample_rate_val = 10;
  1703. break;
  1704. case SAMPLING_RATE_176P4KHZ:
  1705. sample_rate_val = 9;
  1706. break;
  1707. case SAMPLING_RATE_96KHZ:
  1708. sample_rate_val = 8;
  1709. break;
  1710. case SAMPLING_RATE_88P2KHZ:
  1711. sample_rate_val = 7;
  1712. break;
  1713. case SAMPLING_RATE_48KHZ:
  1714. sample_rate_val = 6;
  1715. break;
  1716. case SAMPLING_RATE_44P1KHZ:
  1717. sample_rate_val = 5;
  1718. break;
  1719. case SAMPLING_RATE_32KHZ:
  1720. sample_rate_val = 4;
  1721. break;
  1722. case SAMPLING_RATE_22P05KHZ:
  1723. sample_rate_val = 3;
  1724. break;
  1725. case SAMPLING_RATE_16KHZ:
  1726. sample_rate_val = 2;
  1727. break;
  1728. case SAMPLING_RATE_11P025KHZ:
  1729. sample_rate_val = 1;
  1730. break;
  1731. case SAMPLING_RATE_8KHZ:
  1732. default:
  1733. sample_rate_val = 0;
  1734. break;
  1735. }
  1736. ucontrol->value.integer.value[0] = sample_rate_val;
  1737. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  1738. usb_rx_cfg.sample_rate);
  1739. return 0;
  1740. }
  1741. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1742. struct snd_ctl_elem_value *ucontrol)
  1743. {
  1744. switch (ucontrol->value.integer.value[0]) {
  1745. case 12:
  1746. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1747. break;
  1748. case 11:
  1749. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1750. break;
  1751. case 10:
  1752. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1753. break;
  1754. case 9:
  1755. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1756. break;
  1757. case 8:
  1758. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1759. break;
  1760. case 7:
  1761. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1762. break;
  1763. case 6:
  1764. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1765. break;
  1766. case 5:
  1767. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1768. break;
  1769. case 4:
  1770. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1771. break;
  1772. case 3:
  1773. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1774. break;
  1775. case 2:
  1776. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1777. break;
  1778. case 1:
  1779. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1780. break;
  1781. case 0:
  1782. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1783. break;
  1784. default:
  1785. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1786. break;
  1787. }
  1788. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  1789. __func__, ucontrol->value.integer.value[0],
  1790. usb_rx_cfg.sample_rate);
  1791. return 0;
  1792. }
  1793. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  1794. struct snd_ctl_elem_value *ucontrol)
  1795. {
  1796. switch (usb_rx_cfg.bit_format) {
  1797. case SNDRV_PCM_FORMAT_S32_LE:
  1798. ucontrol->value.integer.value[0] = 3;
  1799. break;
  1800. case SNDRV_PCM_FORMAT_S24_3LE:
  1801. ucontrol->value.integer.value[0] = 2;
  1802. break;
  1803. case SNDRV_PCM_FORMAT_S24_LE:
  1804. ucontrol->value.integer.value[0] = 1;
  1805. break;
  1806. case SNDRV_PCM_FORMAT_S16_LE:
  1807. default:
  1808. ucontrol->value.integer.value[0] = 0;
  1809. break;
  1810. }
  1811. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1812. __func__, usb_rx_cfg.bit_format,
  1813. ucontrol->value.integer.value[0]);
  1814. return 0;
  1815. }
  1816. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  1817. struct snd_ctl_elem_value *ucontrol)
  1818. {
  1819. int rc = 0;
  1820. switch (ucontrol->value.integer.value[0]) {
  1821. case 3:
  1822. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1823. break;
  1824. case 2:
  1825. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1826. break;
  1827. case 1:
  1828. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1829. break;
  1830. case 0:
  1831. default:
  1832. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1833. break;
  1834. }
  1835. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1836. __func__, usb_rx_cfg.bit_format,
  1837. ucontrol->value.integer.value[0]);
  1838. return rc;
  1839. }
  1840. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  1841. struct snd_ctl_elem_value *ucontrol)
  1842. {
  1843. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  1844. usb_tx_cfg.channels);
  1845. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  1846. return 0;
  1847. }
  1848. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  1849. struct snd_ctl_elem_value *ucontrol)
  1850. {
  1851. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1852. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  1853. return 1;
  1854. }
  1855. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1856. struct snd_ctl_elem_value *ucontrol)
  1857. {
  1858. int sample_rate_val;
  1859. switch (usb_tx_cfg.sample_rate) {
  1860. case SAMPLING_RATE_384KHZ:
  1861. sample_rate_val = 12;
  1862. break;
  1863. case SAMPLING_RATE_352P8KHZ:
  1864. sample_rate_val = 11;
  1865. break;
  1866. case SAMPLING_RATE_192KHZ:
  1867. sample_rate_val = 10;
  1868. break;
  1869. case SAMPLING_RATE_176P4KHZ:
  1870. sample_rate_val = 9;
  1871. break;
  1872. case SAMPLING_RATE_96KHZ:
  1873. sample_rate_val = 8;
  1874. break;
  1875. case SAMPLING_RATE_88P2KHZ:
  1876. sample_rate_val = 7;
  1877. break;
  1878. case SAMPLING_RATE_48KHZ:
  1879. sample_rate_val = 6;
  1880. break;
  1881. case SAMPLING_RATE_44P1KHZ:
  1882. sample_rate_val = 5;
  1883. break;
  1884. case SAMPLING_RATE_32KHZ:
  1885. sample_rate_val = 4;
  1886. break;
  1887. case SAMPLING_RATE_22P05KHZ:
  1888. sample_rate_val = 3;
  1889. break;
  1890. case SAMPLING_RATE_16KHZ:
  1891. sample_rate_val = 2;
  1892. break;
  1893. case SAMPLING_RATE_11P025KHZ:
  1894. sample_rate_val = 1;
  1895. break;
  1896. case SAMPLING_RATE_8KHZ:
  1897. sample_rate_val = 0;
  1898. break;
  1899. default:
  1900. sample_rate_val = 6;
  1901. break;
  1902. }
  1903. ucontrol->value.integer.value[0] = sample_rate_val;
  1904. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  1905. usb_tx_cfg.sample_rate);
  1906. return 0;
  1907. }
  1908. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1909. struct snd_ctl_elem_value *ucontrol)
  1910. {
  1911. switch (ucontrol->value.integer.value[0]) {
  1912. case 12:
  1913. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1914. break;
  1915. case 11:
  1916. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1917. break;
  1918. case 10:
  1919. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1920. break;
  1921. case 9:
  1922. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1923. break;
  1924. case 8:
  1925. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1926. break;
  1927. case 7:
  1928. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1929. break;
  1930. case 6:
  1931. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1932. break;
  1933. case 5:
  1934. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1935. break;
  1936. case 4:
  1937. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1938. break;
  1939. case 3:
  1940. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1941. break;
  1942. case 2:
  1943. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1944. break;
  1945. case 1:
  1946. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1947. break;
  1948. case 0:
  1949. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1950. break;
  1951. default:
  1952. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1953. break;
  1954. }
  1955. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  1956. __func__, ucontrol->value.integer.value[0],
  1957. usb_tx_cfg.sample_rate);
  1958. return 0;
  1959. }
  1960. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  1961. struct snd_ctl_elem_value *ucontrol)
  1962. {
  1963. switch (usb_tx_cfg.bit_format) {
  1964. case SNDRV_PCM_FORMAT_S32_LE:
  1965. ucontrol->value.integer.value[0] = 3;
  1966. break;
  1967. case SNDRV_PCM_FORMAT_S24_3LE:
  1968. ucontrol->value.integer.value[0] = 2;
  1969. break;
  1970. case SNDRV_PCM_FORMAT_S24_LE:
  1971. ucontrol->value.integer.value[0] = 1;
  1972. break;
  1973. case SNDRV_PCM_FORMAT_S16_LE:
  1974. default:
  1975. ucontrol->value.integer.value[0] = 0;
  1976. break;
  1977. }
  1978. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1979. __func__, usb_tx_cfg.bit_format,
  1980. ucontrol->value.integer.value[0]);
  1981. return 0;
  1982. }
  1983. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  1984. struct snd_ctl_elem_value *ucontrol)
  1985. {
  1986. int rc = 0;
  1987. switch (ucontrol->value.integer.value[0]) {
  1988. case 3:
  1989. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1990. break;
  1991. case 2:
  1992. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1993. break;
  1994. case 1:
  1995. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1996. break;
  1997. case 0:
  1998. default:
  1999. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2000. break;
  2001. }
  2002. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  2003. __func__, usb_tx_cfg.bit_format,
  2004. ucontrol->value.integer.value[0]);
  2005. return rc;
  2006. }
  2007. static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
  2008. {
  2009. int idx;
  2010. if (strnstr(kcontrol->id.name, "Display Port RX",
  2011. sizeof("Display Port RX"))) {
  2012. idx = DP_RX_IDX;
  2013. } else {
  2014. pr_err("%s: unsupported BE: %s\n",
  2015. __func__, kcontrol->id.name);
  2016. idx = -EINVAL;
  2017. }
  2018. return idx;
  2019. }
  2020. static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
  2021. struct snd_ctl_elem_value *ucontrol)
  2022. {
  2023. int idx = ext_disp_get_port_idx(kcontrol);
  2024. if (idx < 0)
  2025. return idx;
  2026. switch (ext_disp_rx_cfg[idx].bit_format) {
  2027. case SNDRV_PCM_FORMAT_S24_3LE:
  2028. ucontrol->value.integer.value[0] = 2;
  2029. break;
  2030. case SNDRV_PCM_FORMAT_S24_LE:
  2031. ucontrol->value.integer.value[0] = 1;
  2032. break;
  2033. case SNDRV_PCM_FORMAT_S16_LE:
  2034. default:
  2035. ucontrol->value.integer.value[0] = 0;
  2036. break;
  2037. }
  2038. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  2039. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  2040. ucontrol->value.integer.value[0]);
  2041. return 0;
  2042. }
  2043. static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
  2044. struct snd_ctl_elem_value *ucontrol)
  2045. {
  2046. int idx = ext_disp_get_port_idx(kcontrol);
  2047. if (idx < 0)
  2048. return idx;
  2049. switch (ucontrol->value.integer.value[0]) {
  2050. case 2:
  2051. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2052. break;
  2053. case 1:
  2054. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2055. break;
  2056. case 0:
  2057. default:
  2058. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2059. break;
  2060. }
  2061. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  2062. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  2063. ucontrol->value.integer.value[0]);
  2064. return 0;
  2065. }
  2066. static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
  2067. struct snd_ctl_elem_value *ucontrol)
  2068. {
  2069. int idx = ext_disp_get_port_idx(kcontrol);
  2070. if (idx < 0)
  2071. return idx;
  2072. ucontrol->value.integer.value[0] =
  2073. ext_disp_rx_cfg[idx].channels - 2;
  2074. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  2075. idx, ext_disp_rx_cfg[idx].channels);
  2076. return 0;
  2077. }
  2078. static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
  2079. struct snd_ctl_elem_value *ucontrol)
  2080. {
  2081. int idx = ext_disp_get_port_idx(kcontrol);
  2082. if (idx < 0)
  2083. return idx;
  2084. ext_disp_rx_cfg[idx].channels =
  2085. ucontrol->value.integer.value[0] + 2;
  2086. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  2087. idx, ext_disp_rx_cfg[idx].channels);
  2088. return 1;
  2089. }
  2090. static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2091. struct snd_ctl_elem_value *ucontrol)
  2092. {
  2093. int sample_rate_val;
  2094. int idx = ext_disp_get_port_idx(kcontrol);
  2095. if (idx < 0)
  2096. return idx;
  2097. switch (ext_disp_rx_cfg[idx].sample_rate) {
  2098. case SAMPLING_RATE_176P4KHZ:
  2099. sample_rate_val = 6;
  2100. break;
  2101. case SAMPLING_RATE_88P2KHZ:
  2102. sample_rate_val = 5;
  2103. break;
  2104. case SAMPLING_RATE_44P1KHZ:
  2105. sample_rate_val = 4;
  2106. break;
  2107. case SAMPLING_RATE_32KHZ:
  2108. sample_rate_val = 3;
  2109. break;
  2110. case SAMPLING_RATE_192KHZ:
  2111. sample_rate_val = 2;
  2112. break;
  2113. case SAMPLING_RATE_96KHZ:
  2114. sample_rate_val = 1;
  2115. break;
  2116. case SAMPLING_RATE_48KHZ:
  2117. default:
  2118. sample_rate_val = 0;
  2119. break;
  2120. }
  2121. ucontrol->value.integer.value[0] = sample_rate_val;
  2122. pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
  2123. idx, ext_disp_rx_cfg[idx].sample_rate);
  2124. return 0;
  2125. }
  2126. static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2127. struct snd_ctl_elem_value *ucontrol)
  2128. {
  2129. int idx = ext_disp_get_port_idx(kcontrol);
  2130. if (idx < 0)
  2131. return idx;
  2132. switch (ucontrol->value.integer.value[0]) {
  2133. case 6:
  2134. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
  2135. break;
  2136. case 5:
  2137. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
  2138. break;
  2139. case 4:
  2140. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
  2141. break;
  2142. case 3:
  2143. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
  2144. break;
  2145. case 2:
  2146. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
  2147. break;
  2148. case 1:
  2149. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
  2150. break;
  2151. case 0:
  2152. default:
  2153. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
  2154. break;
  2155. }
  2156. pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
  2157. __func__, ucontrol->value.integer.value[0], idx,
  2158. ext_disp_rx_cfg[idx].sample_rate);
  2159. return 0;
  2160. }
  2161. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  2162. struct snd_ctl_elem_value *ucontrol)
  2163. {
  2164. pr_debug("%s: proxy_rx channels = %d\n",
  2165. __func__, proxy_rx_cfg.channels);
  2166. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  2167. return 0;
  2168. }
  2169. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  2170. struct snd_ctl_elem_value *ucontrol)
  2171. {
  2172. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  2173. pr_debug("%s: proxy_rx channels = %d\n",
  2174. __func__, proxy_rx_cfg.channels);
  2175. return 1;
  2176. }
  2177. static int tdm_get_sample_rate(int value)
  2178. {
  2179. int sample_rate = 0;
  2180. switch (value) {
  2181. case 0:
  2182. sample_rate = SAMPLING_RATE_8KHZ;
  2183. break;
  2184. case 1:
  2185. sample_rate = SAMPLING_RATE_16KHZ;
  2186. break;
  2187. case 2:
  2188. sample_rate = SAMPLING_RATE_32KHZ;
  2189. break;
  2190. case 3:
  2191. sample_rate = SAMPLING_RATE_48KHZ;
  2192. break;
  2193. case 4:
  2194. sample_rate = SAMPLING_RATE_176P4KHZ;
  2195. break;
  2196. case 5:
  2197. sample_rate = SAMPLING_RATE_352P8KHZ;
  2198. break;
  2199. default:
  2200. sample_rate = SAMPLING_RATE_48KHZ;
  2201. break;
  2202. }
  2203. return sample_rate;
  2204. }
  2205. static int aux_pcm_get_sample_rate(int value)
  2206. {
  2207. int sample_rate;
  2208. switch (value) {
  2209. case 1:
  2210. sample_rate = SAMPLING_RATE_16KHZ;
  2211. break;
  2212. case 0:
  2213. default:
  2214. sample_rate = SAMPLING_RATE_8KHZ;
  2215. break;
  2216. }
  2217. return sample_rate;
  2218. }
  2219. static int tdm_get_sample_rate_val(int sample_rate)
  2220. {
  2221. int sample_rate_val = 0;
  2222. switch (sample_rate) {
  2223. case SAMPLING_RATE_8KHZ:
  2224. sample_rate_val = 0;
  2225. break;
  2226. case SAMPLING_RATE_16KHZ:
  2227. sample_rate_val = 1;
  2228. break;
  2229. case SAMPLING_RATE_32KHZ:
  2230. sample_rate_val = 2;
  2231. break;
  2232. case SAMPLING_RATE_48KHZ:
  2233. sample_rate_val = 3;
  2234. break;
  2235. case SAMPLING_RATE_176P4KHZ:
  2236. sample_rate_val = 4;
  2237. break;
  2238. case SAMPLING_RATE_352P8KHZ:
  2239. sample_rate_val = 5;
  2240. break;
  2241. default:
  2242. sample_rate_val = 3;
  2243. break;
  2244. }
  2245. return sample_rate_val;
  2246. }
  2247. static int aux_pcm_get_sample_rate_val(int sample_rate)
  2248. {
  2249. int sample_rate_val;
  2250. switch (sample_rate) {
  2251. case SAMPLING_RATE_16KHZ:
  2252. sample_rate_val = 1;
  2253. break;
  2254. case SAMPLING_RATE_8KHZ:
  2255. default:
  2256. sample_rate_val = 0;
  2257. break;
  2258. }
  2259. return sample_rate_val;
  2260. }
  2261. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  2262. struct tdm_port *port)
  2263. {
  2264. if (port) {
  2265. if (strnstr(kcontrol->id.name, "PRI",
  2266. sizeof(kcontrol->id.name))) {
  2267. port->mode = TDM_PRI;
  2268. } else if (strnstr(kcontrol->id.name, "SEC",
  2269. sizeof(kcontrol->id.name))) {
  2270. port->mode = TDM_SEC;
  2271. } else if (strnstr(kcontrol->id.name, "TERT",
  2272. sizeof(kcontrol->id.name))) {
  2273. port->mode = TDM_TERT;
  2274. } else if (strnstr(kcontrol->id.name, "QUAT",
  2275. sizeof(kcontrol->id.name))) {
  2276. port->mode = TDM_QUAT;
  2277. } else if (strnstr(kcontrol->id.name, "QUIN",
  2278. sizeof(kcontrol->id.name))) {
  2279. port->mode = TDM_QUIN;
  2280. } else {
  2281. pr_err("%s: unsupported mode in: %s\n",
  2282. __func__, kcontrol->id.name);
  2283. return -EINVAL;
  2284. }
  2285. if (strnstr(kcontrol->id.name, "RX_0",
  2286. sizeof(kcontrol->id.name)) ||
  2287. strnstr(kcontrol->id.name, "TX_0",
  2288. sizeof(kcontrol->id.name))) {
  2289. port->channel = TDM_0;
  2290. } else if (strnstr(kcontrol->id.name, "RX_1",
  2291. sizeof(kcontrol->id.name)) ||
  2292. strnstr(kcontrol->id.name, "TX_1",
  2293. sizeof(kcontrol->id.name))) {
  2294. port->channel = TDM_1;
  2295. } else if (strnstr(kcontrol->id.name, "RX_2",
  2296. sizeof(kcontrol->id.name)) ||
  2297. strnstr(kcontrol->id.name, "TX_2",
  2298. sizeof(kcontrol->id.name))) {
  2299. port->channel = TDM_2;
  2300. } else if (strnstr(kcontrol->id.name, "RX_3",
  2301. sizeof(kcontrol->id.name)) ||
  2302. strnstr(kcontrol->id.name, "TX_3",
  2303. sizeof(kcontrol->id.name))) {
  2304. port->channel = TDM_3;
  2305. } else if (strnstr(kcontrol->id.name, "RX_4",
  2306. sizeof(kcontrol->id.name)) ||
  2307. strnstr(kcontrol->id.name, "TX_4",
  2308. sizeof(kcontrol->id.name))) {
  2309. port->channel = TDM_4;
  2310. } else if (strnstr(kcontrol->id.name, "RX_5",
  2311. sizeof(kcontrol->id.name)) ||
  2312. strnstr(kcontrol->id.name, "TX_5",
  2313. sizeof(kcontrol->id.name))) {
  2314. port->channel = TDM_5;
  2315. } else if (strnstr(kcontrol->id.name, "RX_6",
  2316. sizeof(kcontrol->id.name)) ||
  2317. strnstr(kcontrol->id.name, "TX_6",
  2318. sizeof(kcontrol->id.name))) {
  2319. port->channel = TDM_6;
  2320. } else if (strnstr(kcontrol->id.name, "RX_7",
  2321. sizeof(kcontrol->id.name)) ||
  2322. strnstr(kcontrol->id.name, "TX_7",
  2323. sizeof(kcontrol->id.name))) {
  2324. port->channel = TDM_7;
  2325. } else {
  2326. pr_err("%s: unsupported channel in: %s\n",
  2327. __func__, kcontrol->id.name);
  2328. return -EINVAL;
  2329. }
  2330. } else {
  2331. return -EINVAL;
  2332. }
  2333. return 0;
  2334. }
  2335. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2336. struct snd_ctl_elem_value *ucontrol)
  2337. {
  2338. struct tdm_port port;
  2339. int ret = tdm_get_port_idx(kcontrol, &port);
  2340. if (ret) {
  2341. pr_err("%s: unsupported control: %s\n",
  2342. __func__, kcontrol->id.name);
  2343. } else {
  2344. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  2345. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  2346. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  2347. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  2348. ucontrol->value.enumerated.item[0]);
  2349. }
  2350. return ret;
  2351. }
  2352. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2353. struct snd_ctl_elem_value *ucontrol)
  2354. {
  2355. struct tdm_port port;
  2356. int ret = tdm_get_port_idx(kcontrol, &port);
  2357. if (ret) {
  2358. pr_err("%s: unsupported control: %s\n",
  2359. __func__, kcontrol->id.name);
  2360. } else {
  2361. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  2362. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2363. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  2364. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  2365. ucontrol->value.enumerated.item[0]);
  2366. }
  2367. return ret;
  2368. }
  2369. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2370. struct snd_ctl_elem_value *ucontrol)
  2371. {
  2372. struct tdm_port port;
  2373. int ret = tdm_get_port_idx(kcontrol, &port);
  2374. if (ret) {
  2375. pr_err("%s: unsupported control: %s\n",
  2376. __func__, kcontrol->id.name);
  2377. } else {
  2378. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  2379. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  2380. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  2381. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  2382. ucontrol->value.enumerated.item[0]);
  2383. }
  2384. return ret;
  2385. }
  2386. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2387. struct snd_ctl_elem_value *ucontrol)
  2388. {
  2389. struct tdm_port port;
  2390. int ret = tdm_get_port_idx(kcontrol, &port);
  2391. if (ret) {
  2392. pr_err("%s: unsupported control: %s\n",
  2393. __func__, kcontrol->id.name);
  2394. } else {
  2395. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  2396. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2397. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  2398. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  2399. ucontrol->value.enumerated.item[0]);
  2400. }
  2401. return ret;
  2402. }
  2403. static int tdm_get_format(int value)
  2404. {
  2405. int format = 0;
  2406. switch (value) {
  2407. case 0:
  2408. format = SNDRV_PCM_FORMAT_S16_LE;
  2409. break;
  2410. case 1:
  2411. format = SNDRV_PCM_FORMAT_S24_LE;
  2412. break;
  2413. case 2:
  2414. format = SNDRV_PCM_FORMAT_S32_LE;
  2415. break;
  2416. default:
  2417. format = SNDRV_PCM_FORMAT_S16_LE;
  2418. break;
  2419. }
  2420. return format;
  2421. }
  2422. static int tdm_get_format_val(int format)
  2423. {
  2424. int value = 0;
  2425. switch (format) {
  2426. case SNDRV_PCM_FORMAT_S16_LE:
  2427. value = 0;
  2428. break;
  2429. case SNDRV_PCM_FORMAT_S24_LE:
  2430. value = 1;
  2431. break;
  2432. case SNDRV_PCM_FORMAT_S32_LE:
  2433. value = 2;
  2434. break;
  2435. default:
  2436. value = 0;
  2437. break;
  2438. }
  2439. return value;
  2440. }
  2441. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  2442. struct snd_ctl_elem_value *ucontrol)
  2443. {
  2444. struct tdm_port port;
  2445. int ret = tdm_get_port_idx(kcontrol, &port);
  2446. if (ret) {
  2447. pr_err("%s: unsupported control: %s\n",
  2448. __func__, kcontrol->id.name);
  2449. } else {
  2450. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  2451. tdm_rx_cfg[port.mode][port.channel].bit_format);
  2452. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  2453. tdm_rx_cfg[port.mode][port.channel].bit_format,
  2454. ucontrol->value.enumerated.item[0]);
  2455. }
  2456. return ret;
  2457. }
  2458. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  2459. struct snd_ctl_elem_value *ucontrol)
  2460. {
  2461. struct tdm_port port;
  2462. int ret = tdm_get_port_idx(kcontrol, &port);
  2463. if (ret) {
  2464. pr_err("%s: unsupported control: %s\n",
  2465. __func__, kcontrol->id.name);
  2466. } else {
  2467. tdm_rx_cfg[port.mode][port.channel].bit_format =
  2468. tdm_get_format(ucontrol->value.enumerated.item[0]);
  2469. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  2470. tdm_rx_cfg[port.mode][port.channel].bit_format,
  2471. ucontrol->value.enumerated.item[0]);
  2472. }
  2473. return ret;
  2474. }
  2475. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  2476. struct snd_ctl_elem_value *ucontrol)
  2477. {
  2478. struct tdm_port port;
  2479. int ret = tdm_get_port_idx(kcontrol, &port);
  2480. if (ret) {
  2481. pr_err("%s: unsupported control: %s\n",
  2482. __func__, kcontrol->id.name);
  2483. } else {
  2484. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  2485. tdm_tx_cfg[port.mode][port.channel].bit_format);
  2486. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  2487. tdm_tx_cfg[port.mode][port.channel].bit_format,
  2488. ucontrol->value.enumerated.item[0]);
  2489. }
  2490. return ret;
  2491. }
  2492. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  2493. struct snd_ctl_elem_value *ucontrol)
  2494. {
  2495. struct tdm_port port;
  2496. int ret = tdm_get_port_idx(kcontrol, &port);
  2497. if (ret) {
  2498. pr_err("%s: unsupported control: %s\n",
  2499. __func__, kcontrol->id.name);
  2500. } else {
  2501. tdm_tx_cfg[port.mode][port.channel].bit_format =
  2502. tdm_get_format(ucontrol->value.enumerated.item[0]);
  2503. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  2504. tdm_tx_cfg[port.mode][port.channel].bit_format,
  2505. ucontrol->value.enumerated.item[0]);
  2506. }
  2507. return ret;
  2508. }
  2509. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  2510. struct snd_ctl_elem_value *ucontrol)
  2511. {
  2512. struct tdm_port port;
  2513. int ret = tdm_get_port_idx(kcontrol, &port);
  2514. if (ret) {
  2515. pr_err("%s: unsupported control: %s\n",
  2516. __func__, kcontrol->id.name);
  2517. } else {
  2518. ucontrol->value.enumerated.item[0] =
  2519. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  2520. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  2521. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  2522. ucontrol->value.enumerated.item[0]);
  2523. }
  2524. return ret;
  2525. }
  2526. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  2527. struct snd_ctl_elem_value *ucontrol)
  2528. {
  2529. struct tdm_port port;
  2530. int ret = tdm_get_port_idx(kcontrol, &port);
  2531. if (ret) {
  2532. pr_err("%s: unsupported control: %s\n",
  2533. __func__, kcontrol->id.name);
  2534. } else {
  2535. tdm_rx_cfg[port.mode][port.channel].channels =
  2536. ucontrol->value.enumerated.item[0] + 1;
  2537. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  2538. tdm_rx_cfg[port.mode][port.channel].channels,
  2539. ucontrol->value.enumerated.item[0] + 1);
  2540. }
  2541. return ret;
  2542. }
  2543. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  2544. struct snd_ctl_elem_value *ucontrol)
  2545. {
  2546. struct tdm_port port;
  2547. int ret = tdm_get_port_idx(kcontrol, &port);
  2548. if (ret) {
  2549. pr_err("%s: unsupported control: %s\n",
  2550. __func__, kcontrol->id.name);
  2551. } else {
  2552. ucontrol->value.enumerated.item[0] =
  2553. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  2554. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  2555. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  2556. ucontrol->value.enumerated.item[0]);
  2557. }
  2558. return ret;
  2559. }
  2560. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  2561. struct snd_ctl_elem_value *ucontrol)
  2562. {
  2563. struct tdm_port port;
  2564. int ret = tdm_get_port_idx(kcontrol, &port);
  2565. if (ret) {
  2566. pr_err("%s: unsupported control: %s\n",
  2567. __func__, kcontrol->id.name);
  2568. } else {
  2569. tdm_tx_cfg[port.mode][port.channel].channels =
  2570. ucontrol->value.enumerated.item[0] + 1;
  2571. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  2572. tdm_tx_cfg[port.mode][port.channel].channels,
  2573. ucontrol->value.enumerated.item[0] + 1);
  2574. }
  2575. return ret;
  2576. }
  2577. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  2578. {
  2579. int idx;
  2580. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  2581. sizeof("PRIM_AUX_PCM"))) {
  2582. idx = PRIM_AUX_PCM;
  2583. } else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  2584. sizeof("SEC_AUX_PCM"))) {
  2585. idx = SEC_AUX_PCM;
  2586. } else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  2587. sizeof("TERT_AUX_PCM"))) {
  2588. idx = TERT_AUX_PCM;
  2589. } else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
  2590. sizeof("QUAT_AUX_PCM"))) {
  2591. idx = QUAT_AUX_PCM;
  2592. } else if (strnstr(kcontrol->id.name, "QUIN_AUX_PCM",
  2593. sizeof("QUIN_AUX_PCM"))) {
  2594. idx = QUIN_AUX_PCM;
  2595. } else {
  2596. pr_err("%s: unsupported port: %s\n",
  2597. __func__, kcontrol->id.name);
  2598. idx = -EINVAL;
  2599. }
  2600. return idx;
  2601. }
  2602. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2603. struct snd_ctl_elem_value *ucontrol)
  2604. {
  2605. int idx = aux_pcm_get_port_idx(kcontrol);
  2606. if (idx < 0)
  2607. return idx;
  2608. aux_pcm_rx_cfg[idx].sample_rate =
  2609. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2610. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2611. idx, aux_pcm_rx_cfg[idx].sample_rate,
  2612. ucontrol->value.enumerated.item[0]);
  2613. return 0;
  2614. }
  2615. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2616. struct snd_ctl_elem_value *ucontrol)
  2617. {
  2618. int idx = aux_pcm_get_port_idx(kcontrol);
  2619. if (idx < 0)
  2620. return idx;
  2621. ucontrol->value.enumerated.item[0] =
  2622. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  2623. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2624. idx, aux_pcm_rx_cfg[idx].sample_rate,
  2625. ucontrol->value.enumerated.item[0]);
  2626. return 0;
  2627. }
  2628. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2629. struct snd_ctl_elem_value *ucontrol)
  2630. {
  2631. int idx = aux_pcm_get_port_idx(kcontrol);
  2632. if (idx < 0)
  2633. return idx;
  2634. aux_pcm_tx_cfg[idx].sample_rate =
  2635. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2636. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2637. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2638. ucontrol->value.enumerated.item[0]);
  2639. return 0;
  2640. }
  2641. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2642. struct snd_ctl_elem_value *ucontrol)
  2643. {
  2644. int idx = aux_pcm_get_port_idx(kcontrol);
  2645. if (idx < 0)
  2646. return idx;
  2647. ucontrol->value.enumerated.item[0] =
  2648. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  2649. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2650. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2651. ucontrol->value.enumerated.item[0]);
  2652. return 0;
  2653. }
  2654. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  2655. {
  2656. int idx;
  2657. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  2658. sizeof("PRIM_MI2S_RX"))) {
  2659. idx = PRIM_MI2S;
  2660. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  2661. sizeof("SEC_MI2S_RX"))) {
  2662. idx = SEC_MI2S;
  2663. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  2664. sizeof("TERT_MI2S_RX"))) {
  2665. idx = TERT_MI2S;
  2666. } else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
  2667. sizeof("QUAT_MI2S_RX"))) {
  2668. idx = QUAT_MI2S;
  2669. } else if (strnstr(kcontrol->id.name, "QUIN_MI2S_RX",
  2670. sizeof("QUIN_MI2S_RX"))) {
  2671. idx = QUIN_MI2S;
  2672. } else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  2673. sizeof("PRIM_MI2S_TX"))) {
  2674. idx = PRIM_MI2S;
  2675. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  2676. sizeof("SEC_MI2S_TX"))) {
  2677. idx = SEC_MI2S;
  2678. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  2679. sizeof("TERT_MI2S_TX"))) {
  2680. idx = TERT_MI2S;
  2681. } else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
  2682. sizeof("QUAT_MI2S_TX"))) {
  2683. idx = QUAT_MI2S;
  2684. } else if (strnstr(kcontrol->id.name, "QUIN_MI2S_TX",
  2685. sizeof("QUIN_MI2S_TX"))) {
  2686. idx = QUIN_MI2S;
  2687. } else {
  2688. pr_err("%s: unsupported channel: %s\n",
  2689. __func__, kcontrol->id.name);
  2690. idx = -EINVAL;
  2691. }
  2692. return idx;
  2693. }
  2694. static int mi2s_get_sample_rate_val(int sample_rate)
  2695. {
  2696. int sample_rate_val;
  2697. switch (sample_rate) {
  2698. case SAMPLING_RATE_8KHZ:
  2699. sample_rate_val = 0;
  2700. break;
  2701. case SAMPLING_RATE_11P025KHZ:
  2702. sample_rate_val = 1;
  2703. break;
  2704. case SAMPLING_RATE_16KHZ:
  2705. sample_rate_val = 2;
  2706. break;
  2707. case SAMPLING_RATE_22P05KHZ:
  2708. sample_rate_val = 3;
  2709. break;
  2710. case SAMPLING_RATE_32KHZ:
  2711. sample_rate_val = 4;
  2712. break;
  2713. case SAMPLING_RATE_44P1KHZ:
  2714. sample_rate_val = 5;
  2715. break;
  2716. case SAMPLING_RATE_48KHZ:
  2717. sample_rate_val = 6;
  2718. break;
  2719. case SAMPLING_RATE_96KHZ:
  2720. sample_rate_val = 7;
  2721. break;
  2722. case SAMPLING_RATE_192KHZ:
  2723. sample_rate_val = 8;
  2724. break;
  2725. default:
  2726. sample_rate_val = 6;
  2727. break;
  2728. }
  2729. return sample_rate_val;
  2730. }
  2731. static int mi2s_get_sample_rate(int value)
  2732. {
  2733. int sample_rate;
  2734. switch (value) {
  2735. case 0:
  2736. sample_rate = SAMPLING_RATE_8KHZ;
  2737. break;
  2738. case 1:
  2739. sample_rate = SAMPLING_RATE_11P025KHZ;
  2740. break;
  2741. case 2:
  2742. sample_rate = SAMPLING_RATE_16KHZ;
  2743. break;
  2744. case 3:
  2745. sample_rate = SAMPLING_RATE_22P05KHZ;
  2746. break;
  2747. case 4:
  2748. sample_rate = SAMPLING_RATE_32KHZ;
  2749. break;
  2750. case 5:
  2751. sample_rate = SAMPLING_RATE_44P1KHZ;
  2752. break;
  2753. case 6:
  2754. sample_rate = SAMPLING_RATE_48KHZ;
  2755. break;
  2756. case 7:
  2757. sample_rate = SAMPLING_RATE_96KHZ;
  2758. break;
  2759. case 8:
  2760. sample_rate = SAMPLING_RATE_192KHZ;
  2761. break;
  2762. default:
  2763. sample_rate = SAMPLING_RATE_48KHZ;
  2764. break;
  2765. }
  2766. return sample_rate;
  2767. }
  2768. static int mi2s_auxpcm_get_format(int value)
  2769. {
  2770. int format;
  2771. switch (value) {
  2772. case 0:
  2773. format = SNDRV_PCM_FORMAT_S16_LE;
  2774. break;
  2775. case 1:
  2776. format = SNDRV_PCM_FORMAT_S24_LE;
  2777. break;
  2778. case 2:
  2779. format = SNDRV_PCM_FORMAT_S24_3LE;
  2780. break;
  2781. case 3:
  2782. format = SNDRV_PCM_FORMAT_S32_LE;
  2783. break;
  2784. default:
  2785. format = SNDRV_PCM_FORMAT_S16_LE;
  2786. break;
  2787. }
  2788. return format;
  2789. }
  2790. static int mi2s_auxpcm_get_format_value(int format)
  2791. {
  2792. int value;
  2793. switch (format) {
  2794. case SNDRV_PCM_FORMAT_S16_LE:
  2795. value = 0;
  2796. break;
  2797. case SNDRV_PCM_FORMAT_S24_LE:
  2798. value = 1;
  2799. break;
  2800. case SNDRV_PCM_FORMAT_S24_3LE:
  2801. value = 2;
  2802. break;
  2803. case SNDRV_PCM_FORMAT_S32_LE:
  2804. value = 3;
  2805. break;
  2806. default:
  2807. value = 0;
  2808. break;
  2809. }
  2810. return value;
  2811. }
  2812. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2813. struct snd_ctl_elem_value *ucontrol)
  2814. {
  2815. int idx = mi2s_get_port_idx(kcontrol);
  2816. if (idx < 0)
  2817. return idx;
  2818. mi2s_rx_cfg[idx].sample_rate =
  2819. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2820. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2821. idx, mi2s_rx_cfg[idx].sample_rate,
  2822. ucontrol->value.enumerated.item[0]);
  2823. return 0;
  2824. }
  2825. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2826. struct snd_ctl_elem_value *ucontrol)
  2827. {
  2828. int idx = mi2s_get_port_idx(kcontrol);
  2829. if (idx < 0)
  2830. return idx;
  2831. ucontrol->value.enumerated.item[0] =
  2832. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  2833. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2834. idx, mi2s_rx_cfg[idx].sample_rate,
  2835. ucontrol->value.enumerated.item[0]);
  2836. return 0;
  2837. }
  2838. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2839. struct snd_ctl_elem_value *ucontrol)
  2840. {
  2841. int idx = mi2s_get_port_idx(kcontrol);
  2842. if (idx < 0)
  2843. return idx;
  2844. mi2s_tx_cfg[idx].sample_rate =
  2845. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2846. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2847. idx, mi2s_tx_cfg[idx].sample_rate,
  2848. ucontrol->value.enumerated.item[0]);
  2849. return 0;
  2850. }
  2851. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2852. struct snd_ctl_elem_value *ucontrol)
  2853. {
  2854. int idx = mi2s_get_port_idx(kcontrol);
  2855. if (idx < 0)
  2856. return idx;
  2857. ucontrol->value.enumerated.item[0] =
  2858. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  2859. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2860. idx, mi2s_tx_cfg[idx].sample_rate,
  2861. ucontrol->value.enumerated.item[0]);
  2862. return 0;
  2863. }
  2864. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  2865. struct snd_ctl_elem_value *ucontrol)
  2866. {
  2867. int idx = mi2s_get_port_idx(kcontrol);
  2868. if (idx < 0)
  2869. return idx;
  2870. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2871. idx, mi2s_rx_cfg[idx].channels);
  2872. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  2873. return 0;
  2874. }
  2875. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  2876. struct snd_ctl_elem_value *ucontrol)
  2877. {
  2878. int idx = mi2s_get_port_idx(kcontrol);
  2879. if (idx < 0)
  2880. return idx;
  2881. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2882. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2883. idx, mi2s_rx_cfg[idx].channels);
  2884. return 1;
  2885. }
  2886. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  2887. struct snd_ctl_elem_value *ucontrol)
  2888. {
  2889. int idx = mi2s_get_port_idx(kcontrol);
  2890. if (idx < 0)
  2891. return idx;
  2892. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2893. idx, mi2s_tx_cfg[idx].channels);
  2894. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  2895. return 0;
  2896. }
  2897. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  2898. struct snd_ctl_elem_value *ucontrol)
  2899. {
  2900. int idx = mi2s_get_port_idx(kcontrol);
  2901. if (idx < 0)
  2902. return idx;
  2903. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2904. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2905. idx, mi2s_tx_cfg[idx].channels);
  2906. return 1;
  2907. }
  2908. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  2909. struct snd_ctl_elem_value *ucontrol)
  2910. {
  2911. int idx = mi2s_get_port_idx(kcontrol);
  2912. if (idx < 0)
  2913. return idx;
  2914. ucontrol->value.enumerated.item[0] =
  2915. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  2916. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2917. idx, mi2s_rx_cfg[idx].bit_format,
  2918. ucontrol->value.enumerated.item[0]);
  2919. return 0;
  2920. }
  2921. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  2922. struct snd_ctl_elem_value *ucontrol)
  2923. {
  2924. int idx = mi2s_get_port_idx(kcontrol);
  2925. if (idx < 0)
  2926. return idx;
  2927. mi2s_rx_cfg[idx].bit_format =
  2928. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2929. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2930. idx, mi2s_rx_cfg[idx].bit_format,
  2931. ucontrol->value.enumerated.item[0]);
  2932. return 0;
  2933. }
  2934. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  2935. struct snd_ctl_elem_value *ucontrol)
  2936. {
  2937. int idx = mi2s_get_port_idx(kcontrol);
  2938. if (idx < 0)
  2939. return idx;
  2940. ucontrol->value.enumerated.item[0] =
  2941. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  2942. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2943. idx, mi2s_tx_cfg[idx].bit_format,
  2944. ucontrol->value.enumerated.item[0]);
  2945. return 0;
  2946. }
  2947. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  2948. struct snd_ctl_elem_value *ucontrol)
  2949. {
  2950. int idx = mi2s_get_port_idx(kcontrol);
  2951. if (idx < 0)
  2952. return idx;
  2953. mi2s_tx_cfg[idx].bit_format =
  2954. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2955. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2956. idx, mi2s_tx_cfg[idx].bit_format,
  2957. ucontrol->value.enumerated.item[0]);
  2958. return 0;
  2959. }
  2960. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  2961. struct snd_ctl_elem_value *ucontrol)
  2962. {
  2963. int idx = aux_pcm_get_port_idx(kcontrol);
  2964. if (idx < 0)
  2965. return idx;
  2966. ucontrol->value.enumerated.item[0] =
  2967. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  2968. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2969. idx, aux_pcm_rx_cfg[idx].bit_format,
  2970. ucontrol->value.enumerated.item[0]);
  2971. return 0;
  2972. }
  2973. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  2974. struct snd_ctl_elem_value *ucontrol)
  2975. {
  2976. int idx = aux_pcm_get_port_idx(kcontrol);
  2977. if (idx < 0)
  2978. return idx;
  2979. aux_pcm_rx_cfg[idx].bit_format =
  2980. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2981. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2982. idx, aux_pcm_rx_cfg[idx].bit_format,
  2983. ucontrol->value.enumerated.item[0]);
  2984. return 0;
  2985. }
  2986. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  2987. struct snd_ctl_elem_value *ucontrol)
  2988. {
  2989. int idx = aux_pcm_get_port_idx(kcontrol);
  2990. if (idx < 0)
  2991. return idx;
  2992. ucontrol->value.enumerated.item[0] =
  2993. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  2994. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2995. idx, aux_pcm_tx_cfg[idx].bit_format,
  2996. ucontrol->value.enumerated.item[0]);
  2997. return 0;
  2998. }
  2999. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  3000. struct snd_ctl_elem_value *ucontrol)
  3001. {
  3002. int idx = aux_pcm_get_port_idx(kcontrol);
  3003. if (idx < 0)
  3004. return idx;
  3005. aux_pcm_tx_cfg[idx].bit_format =
  3006. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  3007. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  3008. idx, aux_pcm_tx_cfg[idx].bit_format,
  3009. ucontrol->value.enumerated.item[0]);
  3010. return 0;
  3011. }
  3012. static int msm_hifi_ctrl(struct snd_soc_component *component)
  3013. {
  3014. struct snd_soc_dapm_context *dapm =
  3015. snd_soc_component_get_dapm(component);
  3016. struct snd_soc_card *card = component->card;
  3017. struct msm_asoc_mach_data *pdata =
  3018. snd_soc_card_get_drvdata(card);
  3019. dev_dbg(component->dev, "%s: msm_hifi_control = %d\n", __func__,
  3020. msm_hifi_control);
  3021. if (!pdata || !pdata->hph_en1_gpio_p) {
  3022. dev_err(component->dev, "%s: hph_en1_gpio is invalid\n",
  3023. __func__);
  3024. return -EINVAL;
  3025. }
  3026. if (msm_hifi_control == MSM_HIFI_ON) {
  3027. msm_cdc_pinctrl_select_active_state(pdata->hph_en1_gpio_p);
  3028. /* 5msec delay needed as per HW requirement */
  3029. usleep_range(5000, 5010);
  3030. } else {
  3031. msm_cdc_pinctrl_select_sleep_state(pdata->hph_en1_gpio_p);
  3032. }
  3033. snd_soc_dapm_sync(dapm);
  3034. return 0;
  3035. }
  3036. static int msm_hifi_get(struct snd_kcontrol *kcontrol,
  3037. struct snd_ctl_elem_value *ucontrol)
  3038. {
  3039. pr_debug("%s: msm_hifi_control = %d\n",
  3040. __func__, msm_hifi_control);
  3041. ucontrol->value.integer.value[0] = msm_hifi_control;
  3042. return 0;
  3043. }
  3044. static int msm_hifi_put(struct snd_kcontrol *kcontrol,
  3045. struct snd_ctl_elem_value *ucontrol)
  3046. {
  3047. struct snd_soc_component *component =
  3048. snd_soc_kcontrol_component(kcontrol);
  3049. dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n",
  3050. __func__, ucontrol->value.integer.value[0]);
  3051. msm_hifi_control = ucontrol->value.integer.value[0];
  3052. msm_hifi_ctrl(component);
  3053. return 0;
  3054. }
  3055. static const struct snd_kcontrol_new msm_int_snd_controls[] = {
  3056. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  3057. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3058. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  3059. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3060. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
  3061. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3062. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
  3063. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3064. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
  3065. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3066. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
  3067. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3068. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
  3069. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3070. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  3071. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3072. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  3073. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3074. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  3075. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3076. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
  3077. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3078. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
  3079. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3080. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
  3081. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3082. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  3083. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3084. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  3085. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3086. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc_dma_rx_0_format,
  3087. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3088. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc_dma_rx_1_format,
  3089. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3090. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc_dma_rx_2_format,
  3091. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3092. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc_dma_rx_3_format,
  3093. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3094. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc_dma_rx_5_format,
  3095. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3096. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  3097. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3098. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  3099. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3100. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
  3101. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3102. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
  3103. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3104. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
  3105. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3106. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  3107. wsa_cdc_dma_rx_0_sample_rate,
  3108. cdc_dma_rx_sample_rate_get,
  3109. cdc_dma_rx_sample_rate_put),
  3110. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  3111. wsa_cdc_dma_rx_1_sample_rate,
  3112. cdc_dma_rx_sample_rate_get,
  3113. cdc_dma_rx_sample_rate_put),
  3114. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  3115. rx_cdc_dma_rx_0_sample_rate,
  3116. cdc_dma_rx_sample_rate_get,
  3117. cdc_dma_rx_sample_rate_put),
  3118. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  3119. rx_cdc_dma_rx_1_sample_rate,
  3120. cdc_dma_rx_sample_rate_get,
  3121. cdc_dma_rx_sample_rate_put),
  3122. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  3123. rx_cdc_dma_rx_2_sample_rate,
  3124. cdc_dma_rx_sample_rate_get,
  3125. cdc_dma_rx_sample_rate_put),
  3126. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  3127. rx_cdc_dma_rx_3_sample_rate,
  3128. cdc_dma_rx_sample_rate_get,
  3129. cdc_dma_rx_sample_rate_put),
  3130. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  3131. rx_cdc_dma_rx_5_sample_rate,
  3132. cdc_dma_rx_sample_rate_get,
  3133. cdc_dma_rx_sample_rate_put),
  3134. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  3135. wsa_cdc_dma_tx_0_sample_rate,
  3136. cdc_dma_tx_sample_rate_get,
  3137. cdc_dma_tx_sample_rate_put),
  3138. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  3139. wsa_cdc_dma_tx_1_sample_rate,
  3140. cdc_dma_tx_sample_rate_get,
  3141. cdc_dma_tx_sample_rate_put),
  3142. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  3143. wsa_cdc_dma_tx_2_sample_rate,
  3144. cdc_dma_tx_sample_rate_get,
  3145. cdc_dma_tx_sample_rate_put),
  3146. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
  3147. tx_cdc_dma_tx_0_sample_rate,
  3148. cdc_dma_tx_sample_rate_get,
  3149. cdc_dma_tx_sample_rate_put),
  3150. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
  3151. tx_cdc_dma_tx_3_sample_rate,
  3152. cdc_dma_tx_sample_rate_get,
  3153. cdc_dma_tx_sample_rate_put),
  3154. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
  3155. tx_cdc_dma_tx_4_sample_rate,
  3156. cdc_dma_tx_sample_rate_get,
  3157. cdc_dma_tx_sample_rate_put),
  3158. };
  3159. static const struct snd_kcontrol_new msm_ext_snd_controls[] = {
  3160. SOC_ENUM_EXT("SLIM_0_RX Channels", slim_0_rx_chs,
  3161. slim_rx_ch_get, slim_rx_ch_put),
  3162. SOC_ENUM_EXT("SLIM_2_RX Channels", slim_2_rx_chs,
  3163. slim_rx_ch_get, slim_rx_ch_put),
  3164. SOC_ENUM_EXT("SLIM_0_TX Channels", slim_0_tx_chs,
  3165. slim_tx_ch_get, slim_tx_ch_put),
  3166. SOC_ENUM_EXT("SLIM_1_TX Channels", slim_1_tx_chs,
  3167. slim_tx_ch_get, slim_tx_ch_put),
  3168. SOC_ENUM_EXT("SLIM_5_RX Channels", slim_5_rx_chs,
  3169. slim_rx_ch_get, slim_rx_ch_put),
  3170. SOC_ENUM_EXT("SLIM_6_RX Channels", slim_6_rx_chs,
  3171. slim_rx_ch_get, slim_rx_ch_put),
  3172. SOC_ENUM_EXT("SLIM_0_RX Format", slim_0_rx_format,
  3173. slim_rx_bit_format_get, slim_rx_bit_format_put),
  3174. SOC_ENUM_EXT("SLIM_5_RX Format", slim_5_rx_format,
  3175. slim_rx_bit_format_get, slim_rx_bit_format_put),
  3176. SOC_ENUM_EXT("SLIM_6_RX Format", slim_6_rx_format,
  3177. slim_rx_bit_format_get, slim_rx_bit_format_put),
  3178. SOC_ENUM_EXT("SLIM_0_TX Format", slim_0_tx_format,
  3179. slim_tx_bit_format_get, slim_tx_bit_format_put),
  3180. SOC_ENUM_EXT("SLIM_0_RX SampleRate", slim_0_rx_sample_rate,
  3181. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3182. SOC_ENUM_EXT("SLIM_2_RX SampleRate", slim_2_rx_sample_rate,
  3183. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3184. SOC_ENUM_EXT("SLIM_0_TX SampleRate", slim_0_tx_sample_rate,
  3185. slim_tx_sample_rate_get, slim_tx_sample_rate_put),
  3186. SOC_ENUM_EXT("SLIM_5_RX SampleRate", slim_5_rx_sample_rate,
  3187. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3188. SOC_ENUM_EXT("SLIM_6_RX SampleRate", slim_6_rx_sample_rate,
  3189. slim_rx_sample_rate_get, slim_rx_sample_rate_put),
  3190. };
  3191. static const struct snd_kcontrol_new msm_common_snd_controls[] = {
  3192. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  3193. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  3194. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  3195. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  3196. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  3197. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  3198. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  3199. proxy_rx_ch_get, proxy_rx_ch_put),
  3200. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  3201. usb_audio_rx_format_get, usb_audio_rx_format_put),
  3202. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  3203. usb_audio_tx_format_get, usb_audio_tx_format_put),
  3204. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  3205. ext_disp_rx_format_get, ext_disp_rx_format_put),
  3206. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  3207. usb_audio_rx_sample_rate_get,
  3208. usb_audio_rx_sample_rate_put),
  3209. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  3210. usb_audio_tx_sample_rate_get,
  3211. usb_audio_tx_sample_rate_put),
  3212. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  3213. ext_disp_rx_sample_rate_get,
  3214. ext_disp_rx_sample_rate_put),
  3215. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3216. tdm_rx_sample_rate_get,
  3217. tdm_rx_sample_rate_put),
  3218. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3219. tdm_tx_sample_rate_get,
  3220. tdm_tx_sample_rate_put),
  3221. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  3222. tdm_rx_format_get,
  3223. tdm_rx_format_put),
  3224. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  3225. tdm_tx_format_get,
  3226. tdm_tx_format_put),
  3227. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  3228. tdm_rx_ch_get,
  3229. tdm_rx_ch_put),
  3230. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  3231. tdm_tx_ch_get,
  3232. tdm_tx_ch_put),
  3233. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3234. tdm_rx_sample_rate_get,
  3235. tdm_rx_sample_rate_put),
  3236. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3237. tdm_tx_sample_rate_get,
  3238. tdm_tx_sample_rate_put),
  3239. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  3240. tdm_rx_format_get,
  3241. tdm_rx_format_put),
  3242. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  3243. tdm_tx_format_get,
  3244. tdm_tx_format_put),
  3245. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  3246. tdm_rx_ch_get,
  3247. tdm_rx_ch_put),
  3248. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  3249. tdm_tx_ch_get,
  3250. tdm_tx_ch_put),
  3251. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3252. tdm_rx_sample_rate_get,
  3253. tdm_rx_sample_rate_put),
  3254. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3255. tdm_tx_sample_rate_get,
  3256. tdm_tx_sample_rate_put),
  3257. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  3258. tdm_rx_format_get,
  3259. tdm_rx_format_put),
  3260. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  3261. tdm_tx_format_get,
  3262. tdm_tx_format_put),
  3263. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  3264. tdm_rx_ch_get,
  3265. tdm_rx_ch_put),
  3266. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  3267. tdm_tx_ch_get,
  3268. tdm_tx_ch_put),
  3269. SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3270. tdm_rx_sample_rate_get,
  3271. tdm_rx_sample_rate_put),
  3272. SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3273. tdm_tx_sample_rate_get,
  3274. tdm_tx_sample_rate_put),
  3275. SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
  3276. tdm_rx_format_get,
  3277. tdm_rx_format_put),
  3278. SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
  3279. tdm_tx_format_get,
  3280. tdm_tx_format_put),
  3281. SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
  3282. tdm_rx_ch_get,
  3283. tdm_rx_ch_put),
  3284. SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
  3285. tdm_tx_ch_get,
  3286. tdm_tx_ch_put),
  3287. SOC_ENUM_EXT("QUIN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3288. tdm_rx_sample_rate_get,
  3289. tdm_rx_sample_rate_put),
  3290. SOC_ENUM_EXT("QUIN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3291. tdm_tx_sample_rate_get,
  3292. tdm_tx_sample_rate_put),
  3293. SOC_ENUM_EXT("QUIN_TDM_RX_0 Format", tdm_rx_format,
  3294. tdm_rx_format_get,
  3295. tdm_rx_format_put),
  3296. SOC_ENUM_EXT("QUIN_TDM_TX_0 Format", tdm_tx_format,
  3297. tdm_tx_format_get,
  3298. tdm_tx_format_put),
  3299. SOC_ENUM_EXT("QUIN_TDM_RX_0 Channels", tdm_rx_chs,
  3300. tdm_rx_ch_get,
  3301. tdm_rx_ch_put),
  3302. SOC_ENUM_EXT("QUIN_TDM_TX_0 Channels", tdm_tx_chs,
  3303. tdm_tx_ch_get,
  3304. tdm_tx_ch_put),
  3305. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3306. aux_pcm_rx_sample_rate_get,
  3307. aux_pcm_rx_sample_rate_put),
  3308. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  3309. aux_pcm_rx_sample_rate_get,
  3310. aux_pcm_rx_sample_rate_put),
  3311. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  3312. aux_pcm_rx_sample_rate_get,
  3313. aux_pcm_rx_sample_rate_put),
  3314. SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
  3315. aux_pcm_rx_sample_rate_get,
  3316. aux_pcm_rx_sample_rate_put),
  3317. SOC_ENUM_EXT("QUIN_AUX_PCM_RX SampleRate", quin_aux_pcm_rx_sample_rate,
  3318. aux_pcm_rx_sample_rate_get,
  3319. aux_pcm_rx_sample_rate_put),
  3320. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3321. aux_pcm_tx_sample_rate_get,
  3322. aux_pcm_tx_sample_rate_put),
  3323. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  3324. aux_pcm_tx_sample_rate_get,
  3325. aux_pcm_tx_sample_rate_put),
  3326. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  3327. aux_pcm_tx_sample_rate_get,
  3328. aux_pcm_tx_sample_rate_put),
  3329. SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
  3330. aux_pcm_tx_sample_rate_get,
  3331. aux_pcm_tx_sample_rate_put),
  3332. SOC_ENUM_EXT("QUIN_AUX_PCM_TX SampleRate", quin_aux_pcm_tx_sample_rate,
  3333. aux_pcm_tx_sample_rate_get,
  3334. aux_pcm_tx_sample_rate_put),
  3335. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  3336. mi2s_rx_sample_rate_get,
  3337. mi2s_rx_sample_rate_put),
  3338. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  3339. mi2s_rx_sample_rate_get,
  3340. mi2s_rx_sample_rate_put),
  3341. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  3342. mi2s_rx_sample_rate_get,
  3343. mi2s_rx_sample_rate_put),
  3344. SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
  3345. mi2s_rx_sample_rate_get,
  3346. mi2s_rx_sample_rate_put),
  3347. SOC_ENUM_EXT("QUIN_MI2S_RX SampleRate", quin_mi2s_rx_sample_rate,
  3348. mi2s_rx_sample_rate_get,
  3349. mi2s_rx_sample_rate_put),
  3350. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  3351. mi2s_tx_sample_rate_get,
  3352. mi2s_tx_sample_rate_put),
  3353. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  3354. mi2s_tx_sample_rate_get,
  3355. mi2s_tx_sample_rate_put),
  3356. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  3357. mi2s_tx_sample_rate_get,
  3358. mi2s_tx_sample_rate_put),
  3359. SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
  3360. mi2s_tx_sample_rate_get,
  3361. mi2s_tx_sample_rate_put),
  3362. SOC_ENUM_EXT("QUIN_MI2S_TX SampleRate", quin_mi2s_tx_sample_rate,
  3363. mi2s_tx_sample_rate_get,
  3364. mi2s_tx_sample_rate_put),
  3365. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  3366. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3367. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  3368. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3369. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  3370. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3371. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  3372. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3373. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  3374. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3375. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  3376. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3377. SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
  3378. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3379. SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
  3380. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3381. SOC_ENUM_EXT("QUIN_MI2S_RX Channels", quin_mi2s_rx_chs,
  3382. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3383. SOC_ENUM_EXT("QUIN_MI2S_TX Channels", quin_mi2s_tx_chs,
  3384. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3385. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  3386. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3387. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  3388. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3389. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  3390. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3391. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  3392. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3393. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  3394. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3395. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  3396. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3397. SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
  3398. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3399. SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
  3400. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3401. SOC_ENUM_EXT("QUIN_MI2S_RX Format", mi2s_rx_format,
  3402. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3403. SOC_ENUM_EXT("QUIN_MI2S_TX Format", mi2s_tx_format,
  3404. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3405. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3406. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3407. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3408. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3409. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  3410. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3411. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  3412. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3413. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3414. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3415. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3416. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3417. SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3418. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3419. SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3420. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3421. SOC_ENUM_EXT("QUIN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3422. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3423. SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3424. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3425. SOC_ENUM_EXT("HiFi Function", hifi_function, msm_hifi_get,
  3426. msm_hifi_put),
  3427. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  3428. msm_bt_sample_rate_get,
  3429. msm_bt_sample_rate_put),
  3430. SOC_ENUM_EXT("BT SampleRate RX", bt_sample_rate_rx,
  3431. msm_bt_sample_rate_rx_get,
  3432. msm_bt_sample_rate_rx_put),
  3433. SOC_ENUM_EXT("BT SampleRate TX", bt_sample_rate_tx,
  3434. msm_bt_sample_rate_tx_get,
  3435. msm_bt_sample_rate_tx_put),
  3436. SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
  3437. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  3438. };
  3439. static int msm_snd_enable_codec_ext_clk(struct snd_soc_component *component,
  3440. int enable, bool dapm)
  3441. {
  3442. int ret = 0;
  3443. if (!strcmp(component->name, "tavil_codec")) {
  3444. ret = tavil_cdc_mclk_enable(component, enable);
  3445. } else if (!strcmp(dev_name(component->dev), "tasha_codec")) {
  3446. ret = tasha_cdc_mclk_enable(component, enable, dapm);
  3447. } else {
  3448. dev_err(component->dev, "%s: unknown codec to enable ext clk\n",
  3449. __func__);
  3450. ret = -EINVAL;
  3451. }
  3452. return ret;
  3453. }
  3454. static int msm_snd_enable_codec_ext_tx_clk(struct snd_soc_component *component,
  3455. int enable, bool dapm)
  3456. {
  3457. int ret = 0;
  3458. if (!strcmp(component->name, "tavil_codec")) {
  3459. ret = tavil_cdc_mclk_tx_enable(component, enable);
  3460. } else if (!strcmp(dev_name(component->dev), "tasha_codec")) {
  3461. ret = tasha_cdc_mclk_tx_enable(component, enable, dapm);
  3462. } else {
  3463. dev_err(component->dev, "%s: unknown codec to enable TX ext clk\n",
  3464. __func__);
  3465. ret = -EINVAL;
  3466. }
  3467. return ret;
  3468. }
  3469. static int msm_mclk_tx_event(struct snd_soc_dapm_widget *w,
  3470. struct snd_kcontrol *kcontrol, int event)
  3471. {
  3472. struct snd_soc_component *component =
  3473. snd_soc_dapm_to_component(w->dapm);
  3474. pr_debug("%s: event = %d\n", __func__, event);
  3475. switch (event) {
  3476. case SND_SOC_DAPM_PRE_PMU:
  3477. return msm_snd_enable_codec_ext_tx_clk(component, 1, true);
  3478. case SND_SOC_DAPM_POST_PMD:
  3479. return msm_snd_enable_codec_ext_tx_clk(component, 0, true);
  3480. }
  3481. return 0;
  3482. }
  3483. static int msm_mclk_event(struct snd_soc_dapm_widget *w,
  3484. struct snd_kcontrol *kcontrol, int event)
  3485. {
  3486. struct snd_soc_component *component =
  3487. snd_soc_dapm_to_component(w->dapm);
  3488. pr_debug("%s: event = %d\n", __func__, event);
  3489. switch (event) {
  3490. case SND_SOC_DAPM_PRE_PMU:
  3491. return msm_snd_enable_codec_ext_clk(component, 1, true);
  3492. case SND_SOC_DAPM_POST_PMD:
  3493. return msm_snd_enable_codec_ext_clk(component, 0, true);
  3494. }
  3495. return 0;
  3496. }
  3497. static int msm_hifi_ctrl_event(struct snd_soc_dapm_widget *w,
  3498. struct snd_kcontrol *k, int event)
  3499. {
  3500. struct snd_soc_component *component =
  3501. snd_soc_dapm_to_component(w->dapm);
  3502. struct snd_soc_card *card = component->card;
  3503. struct msm_asoc_mach_data *pdata =
  3504. snd_soc_card_get_drvdata(card);
  3505. dev_dbg(component->dev, "%s: msm_hifi_control = %d\n",
  3506. __func__, msm_hifi_control);
  3507. if (!pdata || !pdata->hph_en0_gpio_p) {
  3508. dev_err(component->dev, "%s: hph_en0_gpio is invalid\n",
  3509. __func__);
  3510. return -EINVAL;
  3511. }
  3512. if (msm_hifi_control != MSM_HIFI_ON) {
  3513. dev_dbg(component->dev, "%s: HiFi mixer control is not set\n",
  3514. __func__);
  3515. return 0;
  3516. }
  3517. switch (event) {
  3518. case SND_SOC_DAPM_POST_PMU:
  3519. msm_cdc_pinctrl_select_active_state(pdata->hph_en0_gpio_p);
  3520. break;
  3521. case SND_SOC_DAPM_PRE_PMD:
  3522. msm_cdc_pinctrl_select_sleep_state(pdata->hph_en0_gpio_p);
  3523. break;
  3524. }
  3525. return 0;
  3526. }
  3527. static const struct snd_soc_dapm_widget msm_ext_dapm_widgets[] = {
  3528. SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
  3529. msm_mclk_event,
  3530. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  3531. SND_SOC_DAPM_SUPPLY("MCLK TX", SND_SOC_NOPM, 0, 0,
  3532. msm_mclk_tx_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  3533. SND_SOC_DAPM_SPK("Lineout_1 amp", NULL),
  3534. SND_SOC_DAPM_SPK("Lineout_2 amp", NULL),
  3535. SND_SOC_DAPM_SPK("Lineout_3 amp", NULL),
  3536. SND_SOC_DAPM_SPK("Lineout_4 amp", NULL),
  3537. SND_SOC_DAPM_SPK("hifi amp", msm_hifi_ctrl_event),
  3538. SND_SOC_DAPM_MIC("Handset Mic", NULL),
  3539. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  3540. SND_SOC_DAPM_MIC("Secondary Mic", NULL),
  3541. SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
  3542. SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
  3543. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  3544. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  3545. SND_SOC_DAPM_MIC("Analog Mic6", NULL),
  3546. SND_SOC_DAPM_MIC("Analog Mic7", NULL),
  3547. SND_SOC_DAPM_MIC("Analog Mic8", NULL),
  3548. SND_SOC_DAPM_MIC("Digital Mic0", NULL),
  3549. SND_SOC_DAPM_MIC("Digital Mic1", NULL),
  3550. SND_SOC_DAPM_MIC("Digital Mic2", NULL),
  3551. SND_SOC_DAPM_MIC("Digital Mic3", NULL),
  3552. SND_SOC_DAPM_MIC("Digital Mic4", NULL),
  3553. SND_SOC_DAPM_MIC("Digital Mic5", NULL),
  3554. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  3555. };
  3556. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  3557. struct snd_kcontrol *kcontrol, int event)
  3558. {
  3559. struct msm_asoc_mach_data *pdata = NULL;
  3560. struct snd_soc_component *component =
  3561. snd_soc_dapm_to_component(w->dapm);
  3562. int ret = 0;
  3563. u32 dmic_idx;
  3564. int *dmic_gpio_cnt;
  3565. struct device_node *dmic_gpio;
  3566. char *wname;
  3567. wname = strpbrk(w->name, "0123");
  3568. if (!wname) {
  3569. dev_err(component->dev, "%s: widget not found\n", __func__);
  3570. return -EINVAL;
  3571. }
  3572. ret = kstrtouint(wname, 10, &dmic_idx);
  3573. if (ret < 0) {
  3574. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  3575. __func__);
  3576. return -EINVAL;
  3577. }
  3578. pdata = snd_soc_card_get_drvdata(component->card);
  3579. switch (dmic_idx) {
  3580. case 0:
  3581. case 1:
  3582. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  3583. dmic_gpio = pdata->dmic01_gpio_p;
  3584. break;
  3585. case 2:
  3586. case 3:
  3587. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  3588. dmic_gpio = pdata->dmic23_gpio_p;
  3589. break;
  3590. default:
  3591. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  3592. __func__);
  3593. return -EINVAL;
  3594. }
  3595. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  3596. __func__, event, dmic_idx, *dmic_gpio_cnt);
  3597. switch (event) {
  3598. case SND_SOC_DAPM_PRE_PMU:
  3599. (*dmic_gpio_cnt)++;
  3600. if (*dmic_gpio_cnt == 1) {
  3601. ret = msm_cdc_pinctrl_select_active_state(
  3602. dmic_gpio);
  3603. if (ret < 0) {
  3604. pr_err("%s: gpio set cannot be activated %sd",
  3605. __func__, "dmic_gpio");
  3606. return ret;
  3607. }
  3608. }
  3609. break;
  3610. case SND_SOC_DAPM_POST_PMD:
  3611. (*dmic_gpio_cnt)--;
  3612. if (*dmic_gpio_cnt == 0) {
  3613. ret = msm_cdc_pinctrl_select_sleep_state(
  3614. dmic_gpio);
  3615. if (ret < 0) {
  3616. pr_err("%s: gpio set cannot be de-activated %sd",
  3617. __func__, "dmic_gpio");
  3618. return ret;
  3619. }
  3620. }
  3621. break;
  3622. default:
  3623. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  3624. return -EINVAL;
  3625. }
  3626. return 0;
  3627. }
  3628. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  3629. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  3630. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  3631. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  3632. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  3633. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  3634. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  3635. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  3636. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  3637. };
  3638. static inline int param_is_mask(int p)
  3639. {
  3640. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  3641. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  3642. }
  3643. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  3644. int n)
  3645. {
  3646. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  3647. }
  3648. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  3649. unsigned int bit)
  3650. {
  3651. if (bit >= SNDRV_MASK_MAX)
  3652. return;
  3653. if (param_is_mask(n)) {
  3654. struct snd_mask *m = param_to_mask(p, n);
  3655. m->bits[0] = 0;
  3656. m->bits[1] = 0;
  3657. m->bits[bit >> 5] |= (1 << (bit & 31));
  3658. }
  3659. }
  3660. static int msm_slim_get_ch_from_beid(int32_t be_id)
  3661. {
  3662. int ch_id = 0;
  3663. switch (be_id) {
  3664. case MSM_BACKEND_DAI_SLIMBUS_0_RX:
  3665. ch_id = SLIM_RX_0;
  3666. break;
  3667. case MSM_BACKEND_DAI_SLIMBUS_1_RX:
  3668. ch_id = SLIM_RX_1;
  3669. break;
  3670. case MSM_BACKEND_DAI_SLIMBUS_2_RX:
  3671. ch_id = SLIM_RX_2;
  3672. break;
  3673. case MSM_BACKEND_DAI_SLIMBUS_3_RX:
  3674. ch_id = SLIM_RX_3;
  3675. break;
  3676. case MSM_BACKEND_DAI_SLIMBUS_4_RX:
  3677. ch_id = SLIM_RX_4;
  3678. break;
  3679. case MSM_BACKEND_DAI_SLIMBUS_6_RX:
  3680. ch_id = SLIM_RX_6;
  3681. break;
  3682. case MSM_BACKEND_DAI_SLIMBUS_0_TX:
  3683. ch_id = SLIM_TX_0;
  3684. break;
  3685. case MSM_BACKEND_DAI_SLIMBUS_3_TX:
  3686. ch_id = SLIM_TX_3;
  3687. break;
  3688. default:
  3689. ch_id = SLIM_RX_0;
  3690. break;
  3691. }
  3692. return ch_id;
  3693. }
  3694. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  3695. {
  3696. int idx = 0;
  3697. switch (be_id) {
  3698. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3699. idx = WSA_CDC_DMA_RX_0;
  3700. break;
  3701. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3702. idx = WSA_CDC_DMA_TX_0;
  3703. break;
  3704. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3705. idx = WSA_CDC_DMA_RX_1;
  3706. break;
  3707. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3708. idx = WSA_CDC_DMA_TX_1;
  3709. break;
  3710. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3711. idx = WSA_CDC_DMA_TX_2;
  3712. break;
  3713. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  3714. idx = RX_CDC_DMA_RX_0;
  3715. break;
  3716. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  3717. idx = RX_CDC_DMA_RX_1;
  3718. break;
  3719. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  3720. idx = RX_CDC_DMA_RX_2;
  3721. break;
  3722. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  3723. idx = RX_CDC_DMA_RX_3;
  3724. break;
  3725. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  3726. idx = RX_CDC_DMA_RX_5;
  3727. break;
  3728. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  3729. idx = TX_CDC_DMA_TX_0;
  3730. break;
  3731. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  3732. idx = TX_CDC_DMA_TX_3;
  3733. break;
  3734. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  3735. idx = TX_CDC_DMA_TX_4;
  3736. break;
  3737. default:
  3738. idx = RX_CDC_DMA_RX_0;
  3739. break;
  3740. }
  3741. return idx;
  3742. }
  3743. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  3744. {
  3745. int idx = -EINVAL;
  3746. switch (be_id) {
  3747. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3748. idx = DP_RX_IDX;
  3749. break;
  3750. default:
  3751. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  3752. idx = -EINVAL;
  3753. break;
  3754. }
  3755. return idx;
  3756. }
  3757. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  3758. struct snd_pcm_hw_params *params)
  3759. {
  3760. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3761. struct snd_interval *rate = hw_param_interval(params,
  3762. SNDRV_PCM_HW_PARAM_RATE);
  3763. struct snd_interval *channels = hw_param_interval(params,
  3764. SNDRV_PCM_HW_PARAM_CHANNELS);
  3765. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3766. int rc = 0;
  3767. int idx;
  3768. void *config = NULL;
  3769. struct snd_soc_component *component = NULL;
  3770. pr_debug("%s: format = %d, rate = %d\n",
  3771. __func__, params_format(params), params_rate(params));
  3772. switch (dai_link->id) {
  3773. case MSM_BACKEND_DAI_SLIMBUS_0_RX:
  3774. case MSM_BACKEND_DAI_SLIMBUS_1_RX:
  3775. case MSM_BACKEND_DAI_SLIMBUS_2_RX:
  3776. case MSM_BACKEND_DAI_SLIMBUS_3_RX:
  3777. case MSM_BACKEND_DAI_SLIMBUS_4_RX:
  3778. case MSM_BACKEND_DAI_SLIMBUS_6_RX:
  3779. idx = msm_slim_get_ch_from_beid(dai_link->id);
  3780. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3781. slim_rx_cfg[idx].bit_format);
  3782. rate->min = rate->max = slim_rx_cfg[idx].sample_rate;
  3783. channels->min = channels->max = slim_rx_cfg[idx].channels;
  3784. break;
  3785. case MSM_BACKEND_DAI_SLIMBUS_0_TX:
  3786. case MSM_BACKEND_DAI_SLIMBUS_3_TX:
  3787. idx = msm_slim_get_ch_from_beid(dai_link->id);
  3788. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3789. slim_tx_cfg[idx].bit_format);
  3790. rate->min = rate->max = slim_tx_cfg[idx].sample_rate;
  3791. channels->min = channels->max = slim_tx_cfg[idx].channels;
  3792. break;
  3793. case MSM_BACKEND_DAI_SLIMBUS_1_TX:
  3794. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3795. slim_tx_cfg[1].bit_format);
  3796. rate->min = rate->max = slim_tx_cfg[1].sample_rate;
  3797. channels->min = channels->max = slim_tx_cfg[1].channels;
  3798. break;
  3799. case MSM_BACKEND_DAI_SLIMBUS_4_TX:
  3800. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3801. SNDRV_PCM_FORMAT_S32_LE);
  3802. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  3803. channels->min = channels->max = msm_vi_feed_tx_ch;
  3804. break;
  3805. case MSM_BACKEND_DAI_SLIMBUS_5_RX:
  3806. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3807. slim_rx_cfg[5].bit_format);
  3808. rate->min = rate->max = slim_rx_cfg[5].sample_rate;
  3809. channels->min = channels->max = slim_rx_cfg[5].channels;
  3810. break;
  3811. case MSM_BACKEND_DAI_SLIMBUS_5_TX:
  3812. component = snd_soc_rtdcom_lookup(rtd, "tavil_codec");
  3813. if (!component) {
  3814. pr_err("%s: component is NULL\n", __func__);
  3815. rc = -EINVAL;
  3816. goto done;
  3817. }
  3818. rate->min = rate->max = SAMPLING_RATE_16KHZ;
  3819. channels->min = channels->max = 1;
  3820. config = msm_codec_fn.get_afe_config_fn(component,
  3821. AFE_SLIMBUS_SLAVE_PORT_CONFIG);
  3822. if (config) {
  3823. rc = afe_set_config(AFE_SLIMBUS_SLAVE_PORT_CONFIG,
  3824. config, SLIMBUS_5_TX);
  3825. if (rc)
  3826. pr_err("%s: Failed to set slimbus slave port config %d\n",
  3827. __func__, rc);
  3828. }
  3829. break;
  3830. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  3831. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3832. slim_rx_cfg[SLIM_RX_7].bit_format);
  3833. rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
  3834. channels->min = channels->max =
  3835. slim_rx_cfg[SLIM_RX_7].channels;
  3836. break;
  3837. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  3838. rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
  3839. channels->min = channels->max =
  3840. slim_tx_cfg[SLIM_TX_7].channels;
  3841. break;
  3842. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  3843. rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
  3844. channels->min = channels->max =
  3845. slim_tx_cfg[SLIM_TX_8].channels;
  3846. break;
  3847. case MSM_BACKEND_DAI_USB_RX:
  3848. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3849. usb_rx_cfg.bit_format);
  3850. rate->min = rate->max = usb_rx_cfg.sample_rate;
  3851. channels->min = channels->max = usb_rx_cfg.channels;
  3852. break;
  3853. case MSM_BACKEND_DAI_USB_TX:
  3854. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3855. usb_tx_cfg.bit_format);
  3856. rate->min = rate->max = usb_tx_cfg.sample_rate;
  3857. channels->min = channels->max = usb_tx_cfg.channels;
  3858. break;
  3859. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3860. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  3861. if (idx < 0) {
  3862. pr_err("%s: Incorrect ext disp idx %d\n",
  3863. __func__, idx);
  3864. rc = idx;
  3865. goto done;
  3866. }
  3867. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3868. ext_disp_rx_cfg[idx].bit_format);
  3869. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  3870. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  3871. break;
  3872. case MSM_BACKEND_DAI_AFE_PCM_RX:
  3873. channels->min = channels->max = proxy_rx_cfg.channels;
  3874. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3875. break;
  3876. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  3877. channels->min = channels->max =
  3878. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  3879. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3880. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  3881. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  3882. break;
  3883. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  3884. channels->min = channels->max =
  3885. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3886. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3887. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  3888. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  3889. break;
  3890. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  3891. channels->min = channels->max =
  3892. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  3893. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3894. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  3895. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  3896. break;
  3897. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  3898. channels->min = channels->max =
  3899. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3900. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3901. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  3902. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  3903. break;
  3904. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  3905. channels->min = channels->max =
  3906. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  3907. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3908. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  3909. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  3910. break;
  3911. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  3912. channels->min = channels->max =
  3913. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3914. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3915. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  3916. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  3917. break;
  3918. case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
  3919. channels->min = channels->max =
  3920. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  3921. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3922. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  3923. rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3924. break;
  3925. case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
  3926. channels->min = channels->max =
  3927. tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  3928. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3929. tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
  3930. rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3931. break;
  3932. case MSM_BACKEND_DAI_QUIN_TDM_RX_0:
  3933. channels->min = channels->max =
  3934. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  3935. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3936. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  3937. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3938. break;
  3939. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  3940. channels->min = channels->max =
  3941. tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  3942. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3943. tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
  3944. rate->min = rate->max = tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3945. break;
  3946. case MSM_BACKEND_DAI_AUXPCM_RX:
  3947. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3948. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  3949. rate->min = rate->max =
  3950. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  3951. channels->min = channels->max =
  3952. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  3953. break;
  3954. case MSM_BACKEND_DAI_AUXPCM_TX:
  3955. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3956. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  3957. rate->min = rate->max =
  3958. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  3959. channels->min = channels->max =
  3960. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  3961. break;
  3962. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  3963. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3964. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  3965. rate->min = rate->max =
  3966. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  3967. channels->min = channels->max =
  3968. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  3969. break;
  3970. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  3971. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3972. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  3973. rate->min = rate->max =
  3974. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  3975. channels->min = channels->max =
  3976. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  3977. break;
  3978. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  3979. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3980. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  3981. rate->min = rate->max =
  3982. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  3983. channels->min = channels->max =
  3984. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  3985. break;
  3986. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  3987. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3988. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  3989. rate->min = rate->max =
  3990. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  3991. channels->min = channels->max =
  3992. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  3993. break;
  3994. case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
  3995. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3996. aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
  3997. rate->min = rate->max =
  3998. aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
  3999. channels->min = channels->max =
  4000. aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
  4001. break;
  4002. case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
  4003. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4004. aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
  4005. rate->min = rate->max =
  4006. aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
  4007. channels->min = channels->max =
  4008. aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
  4009. break;
  4010. case MSM_BACKEND_DAI_QUIN_AUXPCM_RX:
  4011. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4012. aux_pcm_rx_cfg[QUIN_AUX_PCM].bit_format);
  4013. rate->min = rate->max =
  4014. aux_pcm_rx_cfg[QUIN_AUX_PCM].sample_rate;
  4015. channels->min = channels->max =
  4016. aux_pcm_rx_cfg[QUIN_AUX_PCM].channels;
  4017. break;
  4018. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  4019. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4020. aux_pcm_tx_cfg[QUIN_AUX_PCM].bit_format);
  4021. rate->min = rate->max =
  4022. aux_pcm_tx_cfg[QUIN_AUX_PCM].sample_rate;
  4023. channels->min = channels->max =
  4024. aux_pcm_tx_cfg[QUIN_AUX_PCM].channels;
  4025. break;
  4026. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  4027. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4028. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  4029. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  4030. channels->min = channels->max =
  4031. mi2s_rx_cfg[PRIM_MI2S].channels;
  4032. break;
  4033. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  4034. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4035. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  4036. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  4037. channels->min = channels->max =
  4038. mi2s_tx_cfg[PRIM_MI2S].channels;
  4039. break;
  4040. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  4041. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4042. mi2s_rx_cfg[SEC_MI2S].bit_format);
  4043. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  4044. channels->min = channels->max =
  4045. mi2s_rx_cfg[SEC_MI2S].channels;
  4046. break;
  4047. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  4048. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4049. mi2s_tx_cfg[SEC_MI2S].bit_format);
  4050. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  4051. channels->min = channels->max =
  4052. mi2s_tx_cfg[SEC_MI2S].channels;
  4053. break;
  4054. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  4055. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4056. mi2s_rx_cfg[TERT_MI2S].bit_format);
  4057. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  4058. channels->min = channels->max =
  4059. mi2s_rx_cfg[TERT_MI2S].channels;
  4060. break;
  4061. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  4062. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4063. mi2s_tx_cfg[TERT_MI2S].bit_format);
  4064. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  4065. channels->min = channels->max =
  4066. mi2s_tx_cfg[TERT_MI2S].channels;
  4067. break;
  4068. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  4069. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4070. mi2s_rx_cfg[QUAT_MI2S].bit_format);
  4071. rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
  4072. channels->min = channels->max =
  4073. mi2s_rx_cfg[QUAT_MI2S].channels;
  4074. break;
  4075. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  4076. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4077. mi2s_tx_cfg[QUAT_MI2S].bit_format);
  4078. rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
  4079. channels->min = channels->max =
  4080. mi2s_tx_cfg[QUAT_MI2S].channels;
  4081. break;
  4082. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  4083. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4084. mi2s_rx_cfg[QUIN_MI2S].bit_format);
  4085. rate->min = rate->max = mi2s_rx_cfg[QUIN_MI2S].sample_rate;
  4086. channels->min = channels->max =
  4087. mi2s_rx_cfg[QUIN_MI2S].channels;
  4088. break;
  4089. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  4090. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4091. mi2s_tx_cfg[QUIN_MI2S].bit_format);
  4092. rate->min = rate->max = mi2s_tx_cfg[QUIN_MI2S].sample_rate;
  4093. channels->min = channels->max =
  4094. mi2s_tx_cfg[QUIN_MI2S].channels;
  4095. break;
  4096. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4097. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4098. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4099. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4100. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4101. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4102. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4103. cdc_dma_rx_cfg[idx].bit_format);
  4104. rate->min = rate->max = cdc_dma_rx_cfg[idx].sample_rate;
  4105. channels->min = channels->max = cdc_dma_rx_cfg[idx].channels;
  4106. break;
  4107. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4108. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4109. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4110. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4111. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4112. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4113. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4114. cdc_dma_tx_cfg[idx].bit_format);
  4115. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  4116. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  4117. break;
  4118. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4119. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4120. SNDRV_PCM_FORMAT_S32_LE);
  4121. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  4122. channels->min = channels->max = msm_vi_feed_tx_ch;
  4123. break;
  4124. default:
  4125. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  4126. break;
  4127. }
  4128. done:
  4129. return rc;
  4130. }
  4131. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component,
  4132. bool active)
  4133. {
  4134. struct snd_soc_card *card = component->card;
  4135. struct msm_asoc_mach_data *pdata =
  4136. snd_soc_card_get_drvdata(card);
  4137. if (!pdata->fsa_handle)
  4138. return false;
  4139. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  4140. }
  4141. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  4142. {
  4143. int value = 0;
  4144. bool ret = false;
  4145. struct snd_soc_card *card;
  4146. struct msm_asoc_mach_data *pdata;
  4147. if (!component) {
  4148. pr_err("%s component is NULL\n", __func__);
  4149. return false;
  4150. }
  4151. card = component->card;
  4152. pdata = snd_soc_card_get_drvdata(card);
  4153. if (!pdata)
  4154. return false;
  4155. if (wcd_mbhc_cfg.enable_usbc_analog)
  4156. return msm_usbc_swap_gnd_mic(component, active);
  4157. /* if usbc is not defined, swap using us_euro_gpio_p */
  4158. if (pdata->us_euro_gpio_p) {
  4159. value = msm_cdc_pinctrl_get_state(
  4160. pdata->us_euro_gpio_p);
  4161. if (value)
  4162. msm_cdc_pinctrl_select_sleep_state(
  4163. pdata->us_euro_gpio_p);
  4164. else
  4165. msm_cdc_pinctrl_select_active_state(
  4166. pdata->us_euro_gpio_p);
  4167. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  4168. __func__, value, !value);
  4169. ret = true;
  4170. }
  4171. return ret;
  4172. }
  4173. static int msm_afe_set_config(struct snd_soc_component *component)
  4174. {
  4175. int ret = 0;
  4176. void *config_data = NULL;
  4177. if (!msm_codec_fn.get_afe_config_fn) {
  4178. dev_err(component->dev, "%s: codec get afe config not init'ed\n",
  4179. __func__);
  4180. return -EINVAL;
  4181. }
  4182. config_data = msm_codec_fn.get_afe_config_fn(component,
  4183. AFE_CDC_REGISTERS_CONFIG);
  4184. if (config_data) {
  4185. ret = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
  4186. if (ret) {
  4187. dev_err(component->dev,
  4188. "%s: Failed to set codec registers config %d\n",
  4189. __func__, ret);
  4190. return ret;
  4191. }
  4192. }
  4193. config_data = msm_codec_fn.get_afe_config_fn(component,
  4194. AFE_CDC_REGISTER_PAGE_CONFIG);
  4195. if (config_data) {
  4196. ret = afe_set_config(AFE_CDC_REGISTER_PAGE_CONFIG, config_data,
  4197. 0);
  4198. if (ret)
  4199. dev_err(component->dev,
  4200. "%s: Failed to set cdc register page config\n",
  4201. __func__);
  4202. }
  4203. config_data = msm_codec_fn.get_afe_config_fn(component,
  4204. AFE_SLIMBUS_SLAVE_CONFIG);
  4205. if (config_data) {
  4206. ret = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
  4207. if (ret) {
  4208. dev_err(component->dev,
  4209. "%s: Failed to set slimbus slave config %d\n",
  4210. __func__, ret);
  4211. return ret;
  4212. }
  4213. }
  4214. return 0;
  4215. }
  4216. static void msm_afe_clear_config(void)
  4217. {
  4218. afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
  4219. afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
  4220. }
  4221. static int msm_audrx_tavil_init(struct snd_soc_pcm_runtime *rtd)
  4222. {
  4223. int ret = 0;
  4224. void *config_data;
  4225. struct snd_soc_component *component = NULL;
  4226. struct snd_soc_dapm_context *dapm;
  4227. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4228. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4229. struct snd_soc_component *aux_comp;
  4230. struct snd_card *card = rtd->card->snd_card;
  4231. struct snd_info_entry *entry;
  4232. struct msm_asoc_mach_data *pdata =
  4233. snd_soc_card_get_drvdata(rtd->card);
  4234. /*
  4235. * Codec SLIMBUS configuration
  4236. * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8
  4237. * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
  4238. * TX14, TX15, TX16
  4239. */
  4240. unsigned int rx_ch[WCD934X_RX_MAX] = {144, 145, 146, 147, 148, 149,
  4241. 150, 151};
  4242. unsigned int tx_ch[WCD934X_TX_MAX] = {128, 129, 130, 131, 132, 133,
  4243. 134, 135, 136, 137, 138, 139,
  4244. 140, 141, 142, 143};
  4245. pr_info("%s: dev_name:%s\n", __func__, dev_name(cpu_dai->dev));
  4246. rtd->pmdown_time = 0;
  4247. component = snd_soc_rtdcom_lookup(rtd, "tavil_codec");
  4248. if (!component) {
  4249. pr_err("%s: component is NULL\n", __func__);
  4250. return -EINVAL;
  4251. }
  4252. dapm = snd_soc_component_get_dapm(component);
  4253. ret = snd_soc_add_component_controls(component, msm_ext_snd_controls,
  4254. ARRAY_SIZE(msm_ext_snd_controls));
  4255. if (ret < 0) {
  4256. pr_err("%s: add_codec_controls failed, err %d\n",
  4257. __func__, ret);
  4258. return ret;
  4259. }
  4260. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  4261. ARRAY_SIZE(msm_common_snd_controls));
  4262. if (ret < 0) {
  4263. pr_err("%s: add_codec_controls failed, err %d\n",
  4264. __func__, ret);
  4265. return ret;
  4266. }
  4267. snd_soc_dapm_new_controls(dapm, msm_ext_dapm_widgets,
  4268. ARRAY_SIZE(msm_ext_dapm_widgets));
  4269. snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
  4270. ARRAY_SIZE(wcd_audio_paths));
  4271. snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
  4272. snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
  4273. snd_soc_dapm_ignore_suspend(dapm, "ANCRight Headset Mic");
  4274. snd_soc_dapm_ignore_suspend(dapm, "ANCLeft Headset Mic");
  4275. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  4276. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  4277. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  4278. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  4279. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  4280. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  4281. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  4282. snd_soc_dapm_ignore_suspend(dapm, "MADINPUT");
  4283. snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_INPUT");
  4284. snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT1");
  4285. snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_OUT2");
  4286. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  4287. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT1");
  4288. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT2");
  4289. snd_soc_dapm_ignore_suspend(dapm, "ANC EAR");
  4290. snd_soc_dapm_ignore_suspend(dapm, "SPK1 OUT");
  4291. snd_soc_dapm_ignore_suspend(dapm, "SPK2 OUT");
  4292. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  4293. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  4294. snd_soc_dapm_ignore_suspend(dapm, "AIF4 VI");
  4295. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT");
  4296. snd_soc_dapm_ignore_suspend(dapm, "ANC HPHL");
  4297. snd_soc_dapm_ignore_suspend(dapm, "ANC HPHR");
  4298. snd_soc_dapm_sync(dapm);
  4299. snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4300. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4301. msm_codec_fn.get_afe_config_fn = tavil_get_afe_config;
  4302. ret = msm_afe_set_config(component);
  4303. if (ret) {
  4304. pr_err("%s: Failed to set AFE config %d\n", __func__, ret);
  4305. goto err;
  4306. }
  4307. pdata->is_afe_config_done = true;
  4308. config_data = msm_codec_fn.get_afe_config_fn(component,
  4309. AFE_AANC_VERSION);
  4310. if (config_data) {
  4311. ret = afe_set_config(AFE_AANC_VERSION, config_data, 0);
  4312. if (ret) {
  4313. pr_err("%s: Failed to set aanc version %d\n",
  4314. __func__, ret);
  4315. goto err;
  4316. }
  4317. }
  4318. /*
  4319. * Send speaker configuration only for WSA8810.
  4320. * Default configuration is for WSA8815.
  4321. */
  4322. pr_debug("%s: Number of aux devices: %d\n",
  4323. __func__, rtd->card->num_aux_devs);
  4324. if (rtd->card->num_aux_devs &&
  4325. !list_empty(&rtd->card->aux_comp_list)) {
  4326. aux_comp = list_first_entry(&rtd->card->aux_comp_list,
  4327. struct snd_soc_component, card_aux_list);
  4328. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  4329. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  4330. tavil_set_spkr_mode(component, WCD934X_SPKR_MODE_1);
  4331. tavil_set_spkr_gain_offset(component,
  4332. WCD934X_RX_GAIN_OFFSET_M1P5_DB);
  4333. }
  4334. }
  4335. card = rtd->card->snd_card;
  4336. if (!pdata->codec_root) {
  4337. entry = snd_info_create_subdir(card->module, "codecs",
  4338. card->proc_root);
  4339. if (!entry) {
  4340. pr_debug("%s: Cannot create codecs module entry\n",
  4341. __func__);
  4342. ret = 0;
  4343. goto err;
  4344. }
  4345. pdata->codec_root = entry;
  4346. }
  4347. tavil_codec_info_create_codec_entry(pdata->codec_root, component);
  4348. codec_reg_done = true;
  4349. return 0;
  4350. err:
  4351. return ret;
  4352. }
  4353. static int msm_audrx_tasha_init(struct snd_soc_pcm_runtime *rtd)
  4354. {
  4355. int ret = 0;
  4356. void *config_data;
  4357. struct snd_soc_component *component = NULL;
  4358. struct snd_soc_dapm_context *dapm;
  4359. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4360. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4361. struct snd_soc_component *aux_comp;
  4362. struct snd_card *card;
  4363. struct snd_info_entry *entry;
  4364. struct msm_asoc_mach_data *pdata =
  4365. snd_soc_card_get_drvdata(rtd->card);
  4366. /* Codec SLIMBUS configuration
  4367. * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13
  4368. * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
  4369. * TX14, TX15, TX16
  4370. */
  4371. unsigned int rx_ch[TASHA_RX_MAX] = {144, 145, 146, 147, 148, 149, 150,
  4372. 151, 152, 153, 154, 155, 156};
  4373. unsigned int tx_ch[TASHA_TX_MAX] = {128, 129, 130, 131, 132, 133,
  4374. 134, 135, 136, 137, 138, 139,
  4375. 140, 141, 142, 143};
  4376. pr_info("%s: dev_name:%s\n", __func__, dev_name(cpu_dai->dev));
  4377. rtd->pmdown_time = 0;
  4378. component = snd_soc_rtdcom_lookup(rtd, "tasha_codec");
  4379. if (!component) {
  4380. pr_err("%s: component is NULL\n", __func__);
  4381. return -EINVAL;
  4382. }
  4383. dapm = snd_soc_component_get_dapm(component);
  4384. ret = snd_soc_add_component_controls(component, msm_ext_snd_controls,
  4385. ARRAY_SIZE(msm_ext_snd_controls));
  4386. if (ret < 0) {
  4387. pr_err("%s: add_component_controls failed, err %d\n",
  4388. __func__, ret);
  4389. return ret;
  4390. }
  4391. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  4392. ARRAY_SIZE(msm_common_snd_controls));
  4393. if (ret < 0) {
  4394. pr_err("%s: add_component_controls failed, err %d\n",
  4395. __func__, ret);
  4396. return ret;
  4397. }
  4398. snd_soc_dapm_new_controls(dapm, msm_ext_dapm_widgets,
  4399. ARRAY_SIZE(msm_ext_dapm_widgets));
  4400. snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
  4401. ARRAY_SIZE(wcd_audio_paths));
  4402. snd_soc_dapm_enable_pin(dapm, "Lineout_1 amp");
  4403. snd_soc_dapm_enable_pin(dapm, "Lineout_2 amp");
  4404. snd_soc_dapm_enable_pin(dapm, "Lineout_3 amp");
  4405. snd_soc_dapm_enable_pin(dapm, "Lineout_4 amp");
  4406. snd_soc_dapm_ignore_suspend(dapm, "MADINPUT");
  4407. snd_soc_dapm_ignore_suspend(dapm, "MAD_CPE_INPUT");
  4408. snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
  4409. snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
  4410. snd_soc_dapm_ignore_suspend(dapm, "Secondary Mic");
  4411. snd_soc_dapm_ignore_suspend(dapm, "Lineout_1 amp");
  4412. snd_soc_dapm_ignore_suspend(dapm, "Lineout_2 amp");
  4413. snd_soc_dapm_ignore_suspend(dapm, "Lineout_3 amp");
  4414. snd_soc_dapm_ignore_suspend(dapm, "Lineout_4 amp");
  4415. snd_soc_dapm_ignore_suspend(dapm, "ANCRight Headset Mic");
  4416. snd_soc_dapm_ignore_suspend(dapm, "ANCLeft Headset Mic");
  4417. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  4418. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  4419. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  4420. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  4421. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  4422. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  4423. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  4424. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic6");
  4425. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic7");
  4426. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic8");
  4427. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  4428. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT1");
  4429. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT2");
  4430. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  4431. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  4432. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  4433. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  4434. snd_soc_dapm_ignore_suspend(dapm, "AMIC5");
  4435. snd_soc_dapm_ignore_suspend(dapm, "DMIC0");
  4436. snd_soc_dapm_ignore_suspend(dapm, "DMIC1");
  4437. snd_soc_dapm_ignore_suspend(dapm, "DMIC2");
  4438. snd_soc_dapm_ignore_suspend(dapm, "DMIC3");
  4439. snd_soc_dapm_ignore_suspend(dapm, "DMIC4");
  4440. snd_soc_dapm_ignore_suspend(dapm, "DMIC5");
  4441. snd_soc_dapm_ignore_suspend(dapm, "ANC EAR");
  4442. snd_soc_dapm_ignore_suspend(dapm, "SPK1 OUT");
  4443. snd_soc_dapm_ignore_suspend(dapm, "SPK2 OUT");
  4444. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  4445. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  4446. snd_soc_dapm_ignore_suspend(dapm, "AIF4 VI");
  4447. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT");
  4448. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT3");
  4449. snd_soc_dapm_ignore_suspend(dapm, "LINEOUT4");
  4450. snd_soc_dapm_ignore_suspend(dapm, "ANC HPHL");
  4451. snd_soc_dapm_ignore_suspend(dapm, "ANC HPHR");
  4452. snd_soc_dapm_ignore_suspend(dapm, "ANC LINEOUT1");
  4453. snd_soc_dapm_ignore_suspend(dapm, "ANC LINEOUT2");
  4454. snd_soc_dapm_sync(dapm);
  4455. snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4456. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4457. msm_codec_fn.get_afe_config_fn = tasha_get_afe_config;
  4458. ret = msm_afe_set_config(component);
  4459. if (ret) {
  4460. pr_err("%s: Failed to set AFE config %d\n", __func__, ret);
  4461. goto err;
  4462. }
  4463. pdata->is_afe_config_done = true;
  4464. config_data = msm_codec_fn.get_afe_config_fn(component,
  4465. AFE_AANC_VERSION);
  4466. if (config_data) {
  4467. ret = afe_set_config(AFE_AANC_VERSION, config_data, 0);
  4468. if (ret) {
  4469. pr_err("%s: Failed to set aanc version %d\n",
  4470. __func__, ret);
  4471. goto err;
  4472. }
  4473. }
  4474. /*
  4475. * Send speaker configuration only for WSA8810.
  4476. * Default configuration is for WSA8815.
  4477. */
  4478. pr_debug("%s: Number of aux devices: %d\n",
  4479. __func__, rtd->card->num_aux_devs);
  4480. if (rtd->card->num_aux_devs &&
  4481. !list_empty(&rtd->card->aux_comp_list)) {
  4482. aux_comp = list_first_entry(&rtd->card->aux_comp_list,
  4483. struct snd_soc_component, card_aux_list);
  4484. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  4485. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  4486. tasha_set_spkr_mode(component, SPKR_MODE_1);
  4487. tasha_set_spkr_gain_offset(component,
  4488. RX_GAIN_OFFSET_M1P5_DB);
  4489. }
  4490. }
  4491. card = rtd->card->snd_card;
  4492. if (!pdata->codec_root) {
  4493. entry = snd_info_create_subdir(card->module, "codecs",
  4494. card->proc_root);
  4495. if (!entry) {
  4496. pr_debug("%s: Cannot create codecs module entry\n",
  4497. __func__);
  4498. ret = 0;
  4499. goto err;
  4500. }
  4501. pdata->codec_root = entry;
  4502. }
  4503. tasha_codec_info_create_codec_entry(pdata->codec_root, component);
  4504. codec_reg_done = true;
  4505. return 0;
  4506. err:
  4507. return ret;
  4508. }
  4509. static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
  4510. {
  4511. int ret = 0;
  4512. struct snd_soc_component *component;
  4513. struct snd_soc_dapm_context *dapm;
  4514. struct snd_card *card;
  4515. struct snd_info_entry *entry;
  4516. struct snd_soc_component *aux_comp;
  4517. struct msm_asoc_mach_data *pdata =
  4518. snd_soc_card_get_drvdata(rtd->card);
  4519. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4520. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  4521. if (!component) {
  4522. pr_err("%s: component is NULL\n", __func__);
  4523. return -EINVAL;
  4524. }
  4525. dapm = snd_soc_component_get_dapm(component);
  4526. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  4527. ARRAY_SIZE(msm_int_snd_controls));
  4528. if (ret < 0) {
  4529. pr_err("%s: add_component_controls failed: %d\n",
  4530. __func__, ret);
  4531. return ret;
  4532. }
  4533. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  4534. ARRAY_SIZE(msm_common_snd_controls));
  4535. if (ret < 0) {
  4536. pr_err("%s: add common snd controls failed: %d\n",
  4537. __func__, ret);
  4538. return ret;
  4539. }
  4540. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  4541. ARRAY_SIZE(msm_int_dapm_widgets));
  4542. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  4543. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  4544. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  4545. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  4546. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  4547. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  4548. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  4549. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  4550. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  4551. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  4552. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  4553. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  4554. snd_soc_dapm_sync(dapm);
  4555. /*
  4556. * Send speaker configuration only for WSA8810.
  4557. * Default configuration is for WSA8815.
  4558. */
  4559. dev_dbg(component->dev, "%s: Number of aux devices: %d\n",
  4560. __func__, rtd->card->num_aux_devs);
  4561. if (rtd->card->num_aux_devs &&
  4562. !list_empty(&rtd->card->aux_comp_list)) {
  4563. list_for_each_entry(aux_comp, &rtd->card->aux_comp_list,
  4564. card_aux_list) {
  4565. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  4566. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  4567. wsa_macro_set_spkr_mode(component,
  4568. WSA_MACRO_SPKR_MODE_1);
  4569. wsa_macro_set_spkr_gain_offset(component,
  4570. WSA_MACRO_GAIN_OFFSET_M1P5_DB);
  4571. break;
  4572. }
  4573. }
  4574. }
  4575. card = rtd->card->snd_card;
  4576. if (!pdata->codec_root) {
  4577. entry = snd_info_create_subdir(card->module, "codecs",
  4578. card->proc_root);
  4579. if (!entry) {
  4580. pr_debug("%s: Cannot create codecs module entry\n",
  4581. __func__);
  4582. ret = 0;
  4583. goto err;
  4584. }
  4585. pdata->codec_root = entry;
  4586. }
  4587. bolero_info_create_codec_entry(pdata->codec_root, codec);
  4588. /*
  4589. * SM6150 MSM 1.0 doesn't have hardware wake up interrupt line
  4590. * from AOSS to APSS. So, it uses SW workaround and listens to
  4591. * interrupt from AFE over IPC.
  4592. * Check for MSM version and MSM ID and register wake irq
  4593. * accordingly to provide compatibility to all chipsets.
  4594. */
  4595. if (socinfo_get_id() == SM6150_SOC_MSM_ID &&
  4596. socinfo_get_version() == SM6150_SOC_VERSION_1_0)
  4597. bolero_register_wake_irq(component, true);
  4598. else
  4599. bolero_register_wake_irq(component, false);
  4600. codec_reg_done = true;
  4601. return 0;
  4602. err:
  4603. return ret;
  4604. }
  4605. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  4606. {
  4607. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  4608. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160, 161};
  4609. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4610. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  4611. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  4612. }
  4613. static void *def_wcd_mbhc_cal(void)
  4614. {
  4615. void *wcd_mbhc_cal;
  4616. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  4617. u16 *btn_high;
  4618. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  4619. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  4620. if (!wcd_mbhc_cal)
  4621. return NULL;
  4622. #define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->X) = (Y))
  4623. S(v_hs_max, 1600);
  4624. #undef S
  4625. #define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->X) = (Y))
  4626. S(num_btn, WCD_MBHC_DEF_BUTTONS);
  4627. #undef S
  4628. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  4629. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  4630. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  4631. btn_high[0] = 75;
  4632. btn_high[1] = 150;
  4633. btn_high[2] = 237;
  4634. btn_high[3] = 500;
  4635. btn_high[4] = 500;
  4636. btn_high[5] = 500;
  4637. btn_high[6] = 500;
  4638. btn_high[7] = 500;
  4639. return wcd_mbhc_cal;
  4640. }
  4641. static int msm_snd_hw_params(struct snd_pcm_substream *substream,
  4642. struct snd_pcm_hw_params *params)
  4643. {
  4644. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4645. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4646. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4647. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4648. int ret = 0;
  4649. u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  4650. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4651. u32 user_set_tx_ch = 0;
  4652. u32 rx_ch_count;
  4653. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4654. ret = snd_soc_dai_get_channel_map(codec_dai,
  4655. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4656. if (ret < 0) {
  4657. pr_err("%s: failed to get codec chan map, err:%d\n",
  4658. __func__, ret);
  4659. goto err;
  4660. }
  4661. if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_5_RX) {
  4662. pr_debug("%s: rx_5_ch=%d\n", __func__,
  4663. slim_rx_cfg[5].channels);
  4664. rx_ch_count = slim_rx_cfg[5].channels;
  4665. } else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_2_RX) {
  4666. pr_debug("%s: rx_2_ch=%d\n", __func__,
  4667. slim_rx_cfg[2].channels);
  4668. rx_ch_count = slim_rx_cfg[2].channels;
  4669. } else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_6_RX) {
  4670. pr_debug("%s: rx_6_ch=%d\n", __func__,
  4671. slim_rx_cfg[6].channels);
  4672. rx_ch_count = slim_rx_cfg[6].channels;
  4673. } else {
  4674. pr_debug("%s: rx_0_ch=%d\n", __func__,
  4675. slim_rx_cfg[0].channels);
  4676. rx_ch_count = slim_rx_cfg[0].channels;
  4677. }
  4678. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4679. rx_ch_count, rx_ch);
  4680. if (ret < 0) {
  4681. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4682. __func__, ret);
  4683. goto err;
  4684. }
  4685. } else {
  4686. pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
  4687. codec_dai->name, codec_dai->id, user_set_tx_ch);
  4688. ret = snd_soc_dai_get_channel_map(codec_dai,
  4689. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4690. if (ret < 0) {
  4691. pr_err("%s: failed to get tx codec chan map, err:%d\n",
  4692. __func__, ret);
  4693. goto err;
  4694. }
  4695. /* For <codec>_tx1 case */
  4696. if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_0_TX)
  4697. user_set_tx_ch = slim_tx_cfg[0].channels;
  4698. /* For <codec>_tx3 case */
  4699. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_1_TX)
  4700. user_set_tx_ch = slim_tx_cfg[1].channels;
  4701. else if (dai_link->id == MSM_BACKEND_DAI_SLIMBUS_4_TX)
  4702. user_set_tx_ch = msm_vi_feed_tx_ch;
  4703. else
  4704. user_set_tx_ch = tx_ch_cnt;
  4705. pr_debug("%s: msm_slim_0_tx_ch(%d) user_set_tx_ch(%d) tx_ch_cnt(%d), BE id (%d)\n",
  4706. __func__, slim_tx_cfg[0].channels, user_set_tx_ch,
  4707. tx_ch_cnt, dai_link->id);
  4708. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4709. user_set_tx_ch, tx_ch, 0, 0);
  4710. if (ret < 0)
  4711. pr_err("%s: failed to set tx cpu chan map, err:%d\n",
  4712. __func__, ret);
  4713. }
  4714. err:
  4715. return ret;
  4716. }
  4717. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  4718. struct snd_pcm_hw_params *params)
  4719. {
  4720. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4721. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4722. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4723. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4724. int ret = 0;
  4725. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  4726. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4727. u32 user_set_tx_ch = 0;
  4728. u32 user_set_rx_ch = 0;
  4729. u32 ch_id;
  4730. ret = snd_soc_dai_get_channel_map(codec_dai,
  4731. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  4732. &rx_ch_cdc_dma);
  4733. if (ret < 0) {
  4734. pr_err("%s: failed to get codec chan map, err:%d\n",
  4735. __func__, ret);
  4736. goto err;
  4737. }
  4738. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4739. switch (dai_link->id) {
  4740. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4741. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4742. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4743. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4744. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4745. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  4746. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  4747. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  4748. {
  4749. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4750. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  4751. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  4752. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  4753. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4754. user_set_rx_ch, &rx_ch_cdc_dma);
  4755. if (ret < 0) {
  4756. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4757. __func__, ret);
  4758. goto err;
  4759. }
  4760. }
  4761. break;
  4762. }
  4763. } else {
  4764. switch (dai_link->id) {
  4765. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4766. {
  4767. user_set_tx_ch = msm_vi_feed_tx_ch;
  4768. }
  4769. break;
  4770. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4771. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4772. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4773. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4774. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4775. {
  4776. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4777. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  4778. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  4779. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  4780. }
  4781. break;
  4782. }
  4783. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  4784. &tx_ch_cdc_dma, 0, 0);
  4785. if (ret < 0) {
  4786. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4787. __func__, ret);
  4788. goto err;
  4789. }
  4790. }
  4791. err:
  4792. return ret;
  4793. }
  4794. static int msm_slimbus_2_hw_params(struct snd_pcm_substream *substream,
  4795. struct snd_pcm_hw_params *params)
  4796. {
  4797. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4798. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4799. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4800. unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
  4801. unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
  4802. unsigned int num_tx_ch = 0;
  4803. unsigned int num_rx_ch = 0;
  4804. int ret = 0;
  4805. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4806. num_rx_ch = params_channels(params);
  4807. pr_debug("%s: %s rx_dai_id = %d num_ch = %d\n", __func__,
  4808. codec_dai->name, codec_dai->id, num_rx_ch);
  4809. ret = snd_soc_dai_get_channel_map(codec_dai,
  4810. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4811. if (ret < 0) {
  4812. pr_err("%s: failed to get codec chan map, err:%d\n",
  4813. __func__, ret);
  4814. goto err;
  4815. }
  4816. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4817. num_rx_ch, rx_ch);
  4818. if (ret < 0) {
  4819. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4820. __func__, ret);
  4821. goto err;
  4822. }
  4823. } else {
  4824. num_tx_ch = params_channels(params);
  4825. pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__,
  4826. codec_dai->name, codec_dai->id, num_tx_ch);
  4827. ret = snd_soc_dai_get_channel_map(codec_dai,
  4828. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4829. if (ret < 0) {
  4830. pr_err("%s: failed to get tx codec chan map, err:%d\n",
  4831. __func__, ret);
  4832. goto err;
  4833. }
  4834. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4835. num_tx_ch, tx_ch, 0, 0);
  4836. if (ret < 0) {
  4837. pr_err("%s: failed to set tx cpu chan map, err:%d\n",
  4838. __func__, ret);
  4839. goto err;
  4840. }
  4841. }
  4842. err:
  4843. return ret;
  4844. }
  4845. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  4846. struct snd_pcm_hw_params *params)
  4847. {
  4848. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4849. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4850. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4851. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4852. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  4853. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4854. int ret;
  4855. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4856. codec_dai->name, codec_dai->id);
  4857. ret = snd_soc_dai_get_channel_map(codec_dai,
  4858. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4859. if (ret) {
  4860. dev_err(rtd->dev,
  4861. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4862. __func__, ret);
  4863. goto err;
  4864. }
  4865. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4866. __func__, tx_ch_cnt, dai_link->id);
  4867. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4868. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4869. if (ret)
  4870. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4871. __func__, ret);
  4872. err:
  4873. return ret;
  4874. }
  4875. int msm_snd_cpe_hw_params(struct snd_pcm_substream *substream,
  4876. struct snd_pcm_hw_params *params)
  4877. {
  4878. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4879. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4880. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4881. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4882. int ret = 0;
  4883. u32 tx_ch[SLIM_MAX_TX_PORTS];
  4884. u32 tx_ch_cnt = 0;
  4885. if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) {
  4886. pr_err("%s: Invalid stream type %d\n",
  4887. __func__, substream->stream);
  4888. ret = -EINVAL;
  4889. goto end;
  4890. }
  4891. pr_debug("%s: %s_tx_dai_id_%d\n", __func__,
  4892. codec_dai->name, codec_dai->id);
  4893. ret = snd_soc_dai_get_channel_map(codec_dai,
  4894. &tx_ch_cnt, tx_ch, NULL, NULL);
  4895. if (ret < 0) {
  4896. pr_err("%s: failed to get codec chan map\n, err:%d\n",
  4897. __func__, ret);
  4898. goto end;
  4899. }
  4900. pr_debug("%s: tx_ch_cnt(%d) id %d\n",
  4901. __func__, tx_ch_cnt, dai_link->id);
  4902. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4903. tx_ch_cnt, tx_ch, 0, 0);
  4904. if (ret < 0) {
  4905. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4906. __func__, ret);
  4907. goto end;
  4908. }
  4909. end:
  4910. return ret;
  4911. }
  4912. static int msm_get_port_id(int be_id)
  4913. {
  4914. int afe_port_id;
  4915. switch (be_id) {
  4916. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  4917. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  4918. break;
  4919. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  4920. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  4921. break;
  4922. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  4923. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  4924. break;
  4925. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  4926. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  4927. break;
  4928. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  4929. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  4930. break;
  4931. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  4932. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  4933. break;
  4934. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  4935. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  4936. break;
  4937. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  4938. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  4939. break;
  4940. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  4941. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  4942. break;
  4943. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  4944. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  4945. break;
  4946. default:
  4947. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  4948. afe_port_id = -EINVAL;
  4949. }
  4950. return afe_port_id;
  4951. }
  4952. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  4953. {
  4954. u32 bit_per_sample;
  4955. switch (bit_format) {
  4956. case SNDRV_PCM_FORMAT_S32_LE:
  4957. case SNDRV_PCM_FORMAT_S24_3LE:
  4958. case SNDRV_PCM_FORMAT_S24_LE:
  4959. bit_per_sample = 32;
  4960. break;
  4961. case SNDRV_PCM_FORMAT_S16_LE:
  4962. default:
  4963. bit_per_sample = 16;
  4964. break;
  4965. }
  4966. return bit_per_sample;
  4967. }
  4968. static void update_mi2s_clk_val(int dai_id, int stream)
  4969. {
  4970. u32 bit_per_sample;
  4971. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4972. bit_per_sample =
  4973. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  4974. mi2s_clk[dai_id].clk_freq_in_hz =
  4975. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  4976. } else {
  4977. bit_per_sample =
  4978. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  4979. mi2s_clk[dai_id].clk_freq_in_hz =
  4980. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  4981. }
  4982. }
  4983. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  4984. {
  4985. int ret = 0;
  4986. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4987. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4988. int port_id = 0;
  4989. int index = cpu_dai->id;
  4990. port_id = msm_get_port_id(rtd->dai_link->id);
  4991. if (port_id < 0) {
  4992. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  4993. ret = port_id;
  4994. goto err;
  4995. }
  4996. if (enable) {
  4997. update_mi2s_clk_val(index, substream->stream);
  4998. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  4999. mi2s_clk[index].clk_freq_in_hz);
  5000. }
  5001. mi2s_clk[index].enable = enable;
  5002. ret = afe_set_lpass_clock_v2(port_id,
  5003. &mi2s_clk[index]);
  5004. if (ret < 0) {
  5005. dev_err(rtd->card->dev,
  5006. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  5007. __func__, port_id, ret);
  5008. goto err;
  5009. }
  5010. err:
  5011. return ret;
  5012. }
  5013. static int sm6150_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  5014. struct snd_pcm_hw_params *params)
  5015. {
  5016. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5017. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5018. int ret = 0;
  5019. int slot_width = 32;
  5020. int channels, slots;
  5021. unsigned int slot_mask, rate, clk_freq;
  5022. unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
  5023. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  5024. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  5025. switch (cpu_dai->id) {
  5026. case AFE_PORT_ID_PRIMARY_TDM_RX:
  5027. slots = tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  5028. break;
  5029. case AFE_PORT_ID_SECONDARY_TDM_RX:
  5030. slots = tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  5031. break;
  5032. case AFE_PORT_ID_TERTIARY_TDM_RX:
  5033. slots = tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  5034. break;
  5035. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  5036. slots = tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  5037. break;
  5038. case AFE_PORT_ID_QUINARY_TDM_RX:
  5039. slots = tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  5040. break;
  5041. case AFE_PORT_ID_PRIMARY_TDM_TX:
  5042. slots = tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  5043. break;
  5044. case AFE_PORT_ID_SECONDARY_TDM_TX:
  5045. slots = tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  5046. break;
  5047. case AFE_PORT_ID_TERTIARY_TDM_TX:
  5048. slots = tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  5049. break;
  5050. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  5051. slots = tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  5052. break;
  5053. case AFE_PORT_ID_QUINARY_TDM_TX:
  5054. slots = tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  5055. break;
  5056. default:
  5057. pr_err("%s: dai id 0x%x not supported\n",
  5058. __func__, cpu_dai->id);
  5059. return -EINVAL;
  5060. }
  5061. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  5062. /*2 slot config - bits 0 and 1 set for the first two slots */
  5063. slot_mask = 0x0000FFFF >> (16-slots);
  5064. channels = slots;
  5065. pr_debug("%s: tdm rx slot_width %d slots %d\n",
  5066. __func__, slot_width, slots);
  5067. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  5068. slots, slot_width);
  5069. if (ret < 0) {
  5070. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  5071. __func__, ret);
  5072. goto end;
  5073. }
  5074. ret = snd_soc_dai_set_channel_map(cpu_dai,
  5075. 0, NULL, channels, slot_offset);
  5076. if (ret < 0) {
  5077. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  5078. __func__, ret);
  5079. goto end;
  5080. }
  5081. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  5082. /*2 slot config - bits 0 and 1 set for the first two slots */
  5083. slot_mask = 0x0000FFFF >> (16-slots);
  5084. channels = slots;
  5085. pr_debug("%s: tdm tx slot_width %d slots %d\n",
  5086. __func__, slot_width, slots);
  5087. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  5088. slots, slot_width);
  5089. if (ret < 0) {
  5090. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  5091. __func__, ret);
  5092. goto end;
  5093. }
  5094. ret = snd_soc_dai_set_channel_map(cpu_dai,
  5095. channels, slot_offset, 0, NULL);
  5096. if (ret < 0) {
  5097. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  5098. __func__, ret);
  5099. goto end;
  5100. }
  5101. } else {
  5102. ret = -EINVAL;
  5103. pr_err("%s: invalid use case, err:%d\n",
  5104. __func__, ret);
  5105. goto end;
  5106. }
  5107. rate = params_rate(params);
  5108. clk_freq = rate * slot_width * slots;
  5109. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  5110. if (ret < 0)
  5111. pr_err("%s: failed to set tdm clk, err:%d\n",
  5112. __func__, ret);
  5113. end:
  5114. return ret;
  5115. }
  5116. static int msm_get_tdm_mode(u32 port_id)
  5117. {
  5118. int tdm_mode;
  5119. switch (port_id) {
  5120. case AFE_PORT_ID_PRIMARY_TDM_RX:
  5121. case AFE_PORT_ID_PRIMARY_TDM_TX:
  5122. tdm_mode = TDM_PRI;
  5123. break;
  5124. case AFE_PORT_ID_SECONDARY_TDM_RX:
  5125. case AFE_PORT_ID_SECONDARY_TDM_TX:
  5126. tdm_mode = TDM_SEC;
  5127. break;
  5128. case AFE_PORT_ID_TERTIARY_TDM_RX:
  5129. case AFE_PORT_ID_TERTIARY_TDM_TX:
  5130. tdm_mode = TDM_TERT;
  5131. break;
  5132. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  5133. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  5134. tdm_mode = TDM_QUAT;
  5135. break;
  5136. case AFE_PORT_ID_QUINARY_TDM_RX:
  5137. case AFE_PORT_ID_QUINARY_TDM_TX:
  5138. tdm_mode = TDM_QUIN;
  5139. break;
  5140. default:
  5141. pr_err("%s: Invalid port id: %d\n", __func__, port_id);
  5142. tdm_mode = -EINVAL;
  5143. }
  5144. return tdm_mode;
  5145. }
  5146. static int sm6150_tdm_snd_startup(struct snd_pcm_substream *substream)
  5147. {
  5148. int ret = 0;
  5149. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5150. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5151. struct snd_soc_card *card = rtd->card;
  5152. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5153. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  5154. if (tdm_mode < 0) {
  5155. dev_err(rtd->card->dev, "%s: Invalid tdm_mode\n", __func__);
  5156. return tdm_mode;
  5157. }
  5158. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  5159. if (pdata->mi2s_gpio_p[tdm_mode])
  5160. ret = msm_cdc_pinctrl_select_active_state(
  5161. pdata->mi2s_gpio_p[tdm_mode]);
  5162. return ret;
  5163. }
  5164. static void sm6150_tdm_snd_shutdown(struct snd_pcm_substream *substream)
  5165. {
  5166. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5167. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5168. struct snd_soc_card *card = rtd->card;
  5169. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5170. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  5171. if (tdm_mode < 0) {
  5172. dev_err(rtd->card->dev, "%s: Invalid tdm_mode\n", __func__);
  5173. return;
  5174. }
  5175. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  5176. if (pdata->mi2s_gpio_p[tdm_mode])
  5177. msm_cdc_pinctrl_select_sleep_state(
  5178. pdata->mi2s_gpio_p[tdm_mode]);
  5179. }
  5180. static struct snd_soc_ops sm6150_tdm_be_ops = {
  5181. .hw_params = sm6150_tdm_snd_hw_params,
  5182. .startup = sm6150_tdm_snd_startup,
  5183. .shutdown = sm6150_tdm_snd_shutdown
  5184. };
  5185. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  5186. {
  5187. cpumask_t mask;
  5188. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  5189. pm_qos_remove_request(&substream->latency_pm_qos_req);
  5190. cpumask_clear(&mask);
  5191. cpumask_set_cpu(1, &mask); /* affine to core 1 */
  5192. cpumask_set_cpu(2, &mask); /* affine to core 2 */
  5193. cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
  5194. substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
  5195. pm_qos_add_request(&substream->latency_pm_qos_req,
  5196. PM_QOS_CPU_DMA_LATENCY,
  5197. MSM_LL_QOS_VALUE);
  5198. return 0;
  5199. }
  5200. static struct snd_soc_ops msm_fe_qos_ops = {
  5201. .prepare = msm_fe_qos_prepare,
  5202. };
  5203. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  5204. {
  5205. int ret = 0;
  5206. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5207. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  5208. int index = cpu_dai->id;
  5209. int port_id = msm_get_port_id(rtd->dai_link->id);
  5210. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  5211. struct snd_soc_card *card = rtd->card;
  5212. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5213. dev_dbg(rtd->card->dev,
  5214. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  5215. __func__, substream->name, substream->stream,
  5216. cpu_dai->name, cpu_dai->id);
  5217. if (port_id < 0) {
  5218. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  5219. ret = port_id;
  5220. goto err;
  5221. }
  5222. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  5223. ret = -EINVAL;
  5224. dev_err(rtd->card->dev,
  5225. "%s: CPU DAI id (%d) out of range\n",
  5226. __func__, cpu_dai->id);
  5227. goto err;
  5228. }
  5229. /*
  5230. * Mutex protection in case the same MI2S
  5231. * interface using for both TX and RX so
  5232. * that the same clock won't be enable twice.
  5233. */
  5234. mutex_lock(&mi2s_intf_conf[index].lock);
  5235. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  5236. /* Check if msm needs to provide the clock to the interface */
  5237. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  5238. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  5239. fmt = SND_SOC_DAIFMT_CBM_CFM;
  5240. }
  5241. ret = msm_mi2s_set_sclk(substream, true);
  5242. if (ret < 0) {
  5243. dev_err(rtd->card->dev,
  5244. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  5245. __func__, ret);
  5246. goto clean_up;
  5247. }
  5248. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  5249. if (ret < 0) {
  5250. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  5251. __func__, index, ret);
  5252. goto clk_off;
  5253. }
  5254. if (mi2s_intf_conf[index].msm_is_ext_mclk) {
  5255. pr_debug("%s: Enabling mclk, clk_freq_in_hz = %u\n",
  5256. __func__, mi2s_mclk[index].clk_freq_in_hz);
  5257. ret = afe_set_lpass_clock_v2(port_id,
  5258. &mi2s_mclk[index]);
  5259. if (ret < 0) {
  5260. pr_err("%s: afe lpass mclk failed, err:%d\n",
  5261. __func__, ret);
  5262. goto clk_off;
  5263. }
  5264. mi2s_mclk[index].enable = 1;
  5265. }
  5266. if (pdata->mi2s_gpio_p[index])
  5267. msm_cdc_pinctrl_select_active_state(
  5268. pdata->mi2s_gpio_p[index]);
  5269. }
  5270. clk_off:
  5271. if (ret < 0)
  5272. msm_mi2s_set_sclk(substream, false);
  5273. clean_up:
  5274. if (ret < 0)
  5275. mi2s_intf_conf[index].ref_cnt--;
  5276. mutex_unlock(&mi2s_intf_conf[index].lock);
  5277. err:
  5278. return ret;
  5279. }
  5280. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  5281. {
  5282. int ret;
  5283. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  5284. int index = rtd->cpu_dai->id;
  5285. int port_id = msm_get_port_id(rtd->dai_link->id);
  5286. struct snd_soc_card *card = rtd->card;
  5287. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  5288. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  5289. substream->name, substream->stream);
  5290. if (port_id < 0) {
  5291. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  5292. return;
  5293. }
  5294. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  5295. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  5296. return;
  5297. }
  5298. mutex_lock(&mi2s_intf_conf[index].lock);
  5299. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  5300. if (pdata->mi2s_gpio_p[index])
  5301. msm_cdc_pinctrl_select_sleep_state(
  5302. pdata->mi2s_gpio_p[index]);
  5303. ret = msm_mi2s_set_sclk(substream, false);
  5304. if (ret < 0)
  5305. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  5306. __func__, index, ret);
  5307. if (mi2s_intf_conf[index].msm_is_ext_mclk) {
  5308. pr_debug("%s: Disabling mclk, clk_freq_in_hz = %u\n",
  5309. __func__, mi2s_mclk[index].clk_freq_in_hz);
  5310. ret = afe_set_lpass_clock_v2(port_id,
  5311. &mi2s_mclk[index]);
  5312. if (ret < 0)
  5313. pr_err("%s: mclk disable failed for MCLK (%d); ret=%d\n",
  5314. __func__, index, ret);
  5315. mi2s_mclk[index].enable = 0;
  5316. }
  5317. }
  5318. mutex_unlock(&mi2s_intf_conf[index].lock);
  5319. }
  5320. static struct snd_soc_ops msm_mi2s_be_ops = {
  5321. .startup = msm_mi2s_snd_startup,
  5322. .shutdown = msm_mi2s_snd_shutdown,
  5323. };
  5324. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  5325. .hw_params = msm_snd_cdc_dma_hw_params,
  5326. };
  5327. static struct snd_soc_ops msm_be_ops = {
  5328. .hw_params = msm_snd_hw_params,
  5329. };
  5330. static struct snd_soc_ops msm_slimbus_2_be_ops = {
  5331. .hw_params = msm_slimbus_2_hw_params,
  5332. };
  5333. static struct snd_soc_ops msm_wcn_ops = {
  5334. .hw_params = msm_wcn_hw_params,
  5335. };
  5336. static struct snd_soc_ops msm_ext_cpe_ops = {
  5337. .hw_params = msm_snd_cpe_hw_params,
  5338. };
  5339. /* Digital audio interface glue - connects codec <---> CPU */
  5340. static struct snd_soc_dai_link msm_common_dai_links[] = {
  5341. /* FrontEnd DAI Links */
  5342. {/* hw:x,0 */
  5343. .name = MSM_DAILINK_NAME(Media1),
  5344. .stream_name = "MultiMedia1",
  5345. .cpu_dai_name = "MultiMedia1",
  5346. .platform_name = "msm-pcm-dsp.0",
  5347. .dynamic = 1,
  5348. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5349. .dpcm_playback = 1,
  5350. .dpcm_capture = 1,
  5351. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5352. SND_SOC_DPCM_TRIGGER_POST},
  5353. .codec_dai_name = "snd-soc-dummy-dai",
  5354. .codec_name = "snd-soc-dummy",
  5355. .ignore_suspend = 1,
  5356. /* this dainlink has playback support */
  5357. .ignore_pmdown_time = 1,
  5358. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  5359. },
  5360. {/* hw:x,1 */
  5361. .name = MSM_DAILINK_NAME(Media2),
  5362. .stream_name = "MultiMedia2",
  5363. .cpu_dai_name = "MultiMedia2",
  5364. .platform_name = "msm-pcm-dsp.0",
  5365. .dynamic = 1,
  5366. .dpcm_playback = 1,
  5367. .dpcm_capture = 1,
  5368. .codec_dai_name = "snd-soc-dummy-dai",
  5369. .codec_name = "snd-soc-dummy",
  5370. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5371. SND_SOC_DPCM_TRIGGER_POST},
  5372. .ignore_suspend = 1,
  5373. /* this dainlink has playback support */
  5374. .ignore_pmdown_time = 1,
  5375. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  5376. },
  5377. {/* hw:x,2 */
  5378. .name = "VoiceMMode1",
  5379. .stream_name = "VoiceMMode1",
  5380. .cpu_dai_name = "VoiceMMode1",
  5381. .platform_name = "msm-pcm-voice",
  5382. .dynamic = 1,
  5383. .dpcm_playback = 1,
  5384. .dpcm_capture = 1,
  5385. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5386. SND_SOC_DPCM_TRIGGER_POST},
  5387. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5388. .ignore_suspend = 1,
  5389. .ignore_pmdown_time = 1,
  5390. .codec_dai_name = "snd-soc-dummy-dai",
  5391. .codec_name = "snd-soc-dummy",
  5392. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  5393. },
  5394. {/* hw:x,3 */
  5395. .name = "MSM VoIP",
  5396. .stream_name = "VoIP",
  5397. .cpu_dai_name = "VoIP",
  5398. .platform_name = "msm-voip-dsp",
  5399. .dynamic = 1,
  5400. .dpcm_playback = 1,
  5401. .dpcm_capture = 1,
  5402. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5403. SND_SOC_DPCM_TRIGGER_POST},
  5404. .codec_dai_name = "snd-soc-dummy-dai",
  5405. .codec_name = "snd-soc-dummy",
  5406. .ignore_suspend = 1,
  5407. /* this dainlink has playback support */
  5408. .ignore_pmdown_time = 1,
  5409. .id = MSM_FRONTEND_DAI_VOIP,
  5410. },
  5411. {/* hw:x,4 */
  5412. .name = MSM_DAILINK_NAME(ULL),
  5413. .stream_name = "MultiMedia3",
  5414. .cpu_dai_name = "MultiMedia3",
  5415. .platform_name = "msm-pcm-dsp.2",
  5416. .dynamic = 1,
  5417. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5418. .dpcm_playback = 1,
  5419. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5420. SND_SOC_DPCM_TRIGGER_POST},
  5421. .codec_dai_name = "snd-soc-dummy-dai",
  5422. .codec_name = "snd-soc-dummy",
  5423. .ignore_suspend = 1,
  5424. /* this dainlink has playback support */
  5425. .ignore_pmdown_time = 1,
  5426. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  5427. },
  5428. /* Hostless PCM purpose */
  5429. {/* hw:x,5 */
  5430. .name = "SLIMBUS_0 Hostless",
  5431. .stream_name = "SLIMBUS_0 Hostless",
  5432. .cpu_dai_name = "SLIMBUS0_HOSTLESS",
  5433. .platform_name = "msm-pcm-hostless",
  5434. .dynamic = 1,
  5435. .dpcm_playback = 1,
  5436. .dpcm_capture = 1,
  5437. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5438. SND_SOC_DPCM_TRIGGER_POST},
  5439. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5440. .ignore_suspend = 1,
  5441. /* this dailink has playback support */
  5442. .ignore_pmdown_time = 1,
  5443. .codec_dai_name = "snd-soc-dummy-dai",
  5444. .codec_name = "snd-soc-dummy",
  5445. },
  5446. {/* hw:x,6 */
  5447. .name = "MSM AFE-PCM RX",
  5448. .stream_name = "AFE-PROXY RX",
  5449. .cpu_dai_name = "msm-dai-q6-dev.241",
  5450. .codec_name = "msm-stub-codec.1",
  5451. .codec_dai_name = "msm-stub-rx",
  5452. .platform_name = "msm-pcm-afe",
  5453. .dpcm_playback = 1,
  5454. .ignore_suspend = 1,
  5455. /* this dainlink has playback support */
  5456. .ignore_pmdown_time = 1,
  5457. },
  5458. {/* hw:x,7 */
  5459. .name = "MSM AFE-PCM TX",
  5460. .stream_name = "AFE-PROXY TX",
  5461. .cpu_dai_name = "msm-dai-q6-dev.240",
  5462. .codec_name = "msm-stub-codec.1",
  5463. .codec_dai_name = "msm-stub-tx",
  5464. .platform_name = "msm-pcm-afe",
  5465. .dpcm_capture = 1,
  5466. .ignore_suspend = 1,
  5467. },
  5468. {/* hw:x,8 */
  5469. .name = MSM_DAILINK_NAME(Compress1),
  5470. .stream_name = "Compress1",
  5471. .cpu_dai_name = "MultiMedia4",
  5472. .platform_name = "msm-compress-dsp",
  5473. .dynamic = 1,
  5474. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  5475. .dpcm_playback = 1,
  5476. .dpcm_capture = 1,
  5477. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5478. SND_SOC_DPCM_TRIGGER_POST},
  5479. .codec_dai_name = "snd-soc-dummy-dai",
  5480. .codec_name = "snd-soc-dummy",
  5481. .ignore_suspend = 1,
  5482. .ignore_pmdown_time = 1,
  5483. /* this dainlink has playback support */
  5484. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  5485. },
  5486. {/* hw:x,9 */
  5487. .name = "AUXPCM Hostless",
  5488. .stream_name = "AUXPCM Hostless",
  5489. .cpu_dai_name = "AUXPCM_HOSTLESS",
  5490. .platform_name = "msm-pcm-hostless",
  5491. .dynamic = 1,
  5492. .dpcm_playback = 1,
  5493. .dpcm_capture = 1,
  5494. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5495. SND_SOC_DPCM_TRIGGER_POST},
  5496. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5497. .ignore_suspend = 1,
  5498. /* this dainlink has playback support */
  5499. .ignore_pmdown_time = 1,
  5500. .codec_dai_name = "snd-soc-dummy-dai",
  5501. .codec_name = "snd-soc-dummy",
  5502. },
  5503. {/* hw:x,10 */
  5504. .name = "SLIMBUS_1 Hostless",
  5505. .stream_name = "SLIMBUS_1 Hostless",
  5506. .cpu_dai_name = "SLIMBUS1_HOSTLESS",
  5507. .platform_name = "msm-pcm-hostless",
  5508. .dynamic = 1,
  5509. .dpcm_playback = 1,
  5510. .dpcm_capture = 1,
  5511. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5512. SND_SOC_DPCM_TRIGGER_POST},
  5513. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5514. .ignore_suspend = 1,
  5515. /* this dailink has playback support */
  5516. .ignore_pmdown_time = 1,
  5517. .codec_dai_name = "snd-soc-dummy-dai",
  5518. .codec_name = "snd-soc-dummy",
  5519. },
  5520. {/* hw:x,11 */
  5521. .name = "SLIMBUS_3 Hostless",
  5522. .stream_name = "SLIMBUS_3 Hostless",
  5523. .cpu_dai_name = "SLIMBUS3_HOSTLESS",
  5524. .platform_name = "msm-pcm-hostless",
  5525. .dynamic = 1,
  5526. .dpcm_playback = 1,
  5527. .dpcm_capture = 1,
  5528. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5529. SND_SOC_DPCM_TRIGGER_POST},
  5530. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5531. .ignore_suspend = 1,
  5532. /* this dailink has playback support */
  5533. .ignore_pmdown_time = 1,
  5534. .codec_dai_name = "snd-soc-dummy-dai",
  5535. .codec_name = "snd-soc-dummy",
  5536. },
  5537. {/* hw:x,12 */
  5538. .name = "SLIMBUS_7 Hostless",
  5539. .stream_name = "SLIMBUS_7 Hostless",
  5540. .cpu_dai_name = "SLIMBUS7_HOSTLESS",
  5541. .platform_name = "msm-pcm-hostless",
  5542. .dynamic = 1,
  5543. .dpcm_playback = 1,
  5544. .dpcm_capture = 1,
  5545. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5546. SND_SOC_DPCM_TRIGGER_POST},
  5547. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5548. .ignore_suspend = 1,
  5549. /* this dailink has playback support */
  5550. .ignore_pmdown_time = 1,
  5551. .codec_dai_name = "snd-soc-dummy-dai",
  5552. .codec_name = "snd-soc-dummy",
  5553. },
  5554. {/* hw:x,13 */
  5555. .name = MSM_DAILINK_NAME(LowLatency),
  5556. .stream_name = "MultiMedia5",
  5557. .cpu_dai_name = "MultiMedia5",
  5558. .platform_name = "msm-pcm-dsp.1",
  5559. .dynamic = 1,
  5560. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5561. .dpcm_playback = 1,
  5562. .dpcm_capture = 1,
  5563. .codec_dai_name = "snd-soc-dummy-dai",
  5564. .codec_name = "snd-soc-dummy",
  5565. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5566. SND_SOC_DPCM_TRIGGER_POST},
  5567. .ignore_suspend = 1,
  5568. /* this dainlink has playback support */
  5569. .ignore_pmdown_time = 1,
  5570. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  5571. .ops = &msm_fe_qos_ops,
  5572. },
  5573. {/* hw:x,14 */
  5574. .name = "Listen 1 Audio Service",
  5575. .stream_name = "Listen 1 Audio Service",
  5576. .cpu_dai_name = "LSM1",
  5577. .platform_name = "msm-lsm-client",
  5578. .dynamic = 1,
  5579. .dpcm_capture = 1,
  5580. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5581. SND_SOC_DPCM_TRIGGER_POST },
  5582. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5583. .ignore_suspend = 1,
  5584. .codec_dai_name = "snd-soc-dummy-dai",
  5585. .codec_name = "snd-soc-dummy",
  5586. .id = MSM_FRONTEND_DAI_LSM1,
  5587. },
  5588. /* Multiple Tunnel instances */
  5589. {/* hw:x,15 */
  5590. .name = MSM_DAILINK_NAME(Compress2),
  5591. .stream_name = "Compress2",
  5592. .cpu_dai_name = "MultiMedia7",
  5593. .platform_name = "msm-compress-dsp",
  5594. .dynamic = 1,
  5595. .dpcm_playback = 1,
  5596. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5597. SND_SOC_DPCM_TRIGGER_POST},
  5598. .codec_dai_name = "snd-soc-dummy-dai",
  5599. .codec_name = "snd-soc-dummy",
  5600. .ignore_suspend = 1,
  5601. .ignore_pmdown_time = 1,
  5602. /* this dainlink has playback support */
  5603. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  5604. },
  5605. {/* hw:x,16 */
  5606. .name = MSM_DAILINK_NAME(MultiMedia10),
  5607. .stream_name = "MultiMedia10",
  5608. .cpu_dai_name = "MultiMedia10",
  5609. .platform_name = "msm-pcm-dsp.1",
  5610. .dynamic = 1,
  5611. .dpcm_playback = 1,
  5612. .dpcm_capture = 1,
  5613. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5614. SND_SOC_DPCM_TRIGGER_POST},
  5615. .codec_dai_name = "snd-soc-dummy-dai",
  5616. .codec_name = "snd-soc-dummy",
  5617. .ignore_suspend = 1,
  5618. .ignore_pmdown_time = 1,
  5619. /* this dainlink has playback support */
  5620. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  5621. },
  5622. {/* hw:x,17 */
  5623. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  5624. .stream_name = "MM_NOIRQ",
  5625. .cpu_dai_name = "MultiMedia8",
  5626. .platform_name = "msm-pcm-dsp-noirq",
  5627. .dynamic = 1,
  5628. .dpcm_playback = 1,
  5629. .dpcm_capture = 1,
  5630. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5631. SND_SOC_DPCM_TRIGGER_POST},
  5632. .codec_dai_name = "snd-soc-dummy-dai",
  5633. .codec_name = "snd-soc-dummy",
  5634. .ignore_suspend = 1,
  5635. .ignore_pmdown_time = 1,
  5636. /* this dainlink has playback support */
  5637. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  5638. .ops = &msm_fe_qos_ops,
  5639. },
  5640. /* HDMI Hostless */
  5641. {/* hw:x,18 */
  5642. .name = "HDMI_RX_HOSTLESS",
  5643. .stream_name = "HDMI_RX_HOSTLESS",
  5644. .cpu_dai_name = "HDMI_HOSTLESS",
  5645. .platform_name = "msm-pcm-hostless",
  5646. .dynamic = 1,
  5647. .dpcm_playback = 1,
  5648. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5649. SND_SOC_DPCM_TRIGGER_POST},
  5650. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5651. .ignore_suspend = 1,
  5652. .ignore_pmdown_time = 1,
  5653. .codec_dai_name = "snd-soc-dummy-dai",
  5654. .codec_name = "snd-soc-dummy",
  5655. },
  5656. {/* hw:x,19 */
  5657. .name = "VoiceMMode2",
  5658. .stream_name = "VoiceMMode2",
  5659. .cpu_dai_name = "VoiceMMode2",
  5660. .platform_name = "msm-pcm-voice",
  5661. .dynamic = 1,
  5662. .dpcm_playback = 1,
  5663. .dpcm_capture = 1,
  5664. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5665. SND_SOC_DPCM_TRIGGER_POST},
  5666. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5667. .ignore_suspend = 1,
  5668. .ignore_pmdown_time = 1,
  5669. .codec_dai_name = "snd-soc-dummy-dai",
  5670. .codec_name = "snd-soc-dummy",
  5671. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  5672. },
  5673. /* LSM FE */
  5674. {/* hw:x,20 */
  5675. .name = "Listen 2 Audio Service",
  5676. .stream_name = "Listen 2 Audio Service",
  5677. .cpu_dai_name = "LSM2",
  5678. .platform_name = "msm-lsm-client",
  5679. .dynamic = 1,
  5680. .dpcm_capture = 1,
  5681. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5682. SND_SOC_DPCM_TRIGGER_POST },
  5683. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5684. .ignore_suspend = 1,
  5685. .codec_dai_name = "snd-soc-dummy-dai",
  5686. .codec_name = "snd-soc-dummy",
  5687. .id = MSM_FRONTEND_DAI_LSM2,
  5688. },
  5689. {/* hw:x,21 */
  5690. .name = "Listen 3 Audio Service",
  5691. .stream_name = "Listen 3 Audio Service",
  5692. .cpu_dai_name = "LSM3",
  5693. .platform_name = "msm-lsm-client",
  5694. .dynamic = 1,
  5695. .dpcm_capture = 1,
  5696. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5697. SND_SOC_DPCM_TRIGGER_POST },
  5698. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5699. .ignore_suspend = 1,
  5700. .codec_dai_name = "snd-soc-dummy-dai",
  5701. .codec_name = "snd-soc-dummy",
  5702. .id = MSM_FRONTEND_DAI_LSM3,
  5703. },
  5704. {/* hw:x,22 */
  5705. .name = "Listen 4 Audio Service",
  5706. .stream_name = "Listen 4 Audio Service",
  5707. .cpu_dai_name = "LSM4",
  5708. .platform_name = "msm-lsm-client",
  5709. .dynamic = 1,
  5710. .dpcm_capture = 1,
  5711. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5712. SND_SOC_DPCM_TRIGGER_POST },
  5713. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5714. .ignore_suspend = 1,
  5715. .codec_dai_name = "snd-soc-dummy-dai",
  5716. .codec_name = "snd-soc-dummy",
  5717. .id = MSM_FRONTEND_DAI_LSM4,
  5718. },
  5719. {/* hw:x,23 */
  5720. .name = "Listen 5 Audio Service",
  5721. .stream_name = "Listen 5 Audio Service",
  5722. .cpu_dai_name = "LSM5",
  5723. .platform_name = "msm-lsm-client",
  5724. .dynamic = 1,
  5725. .dpcm_capture = 1,
  5726. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5727. SND_SOC_DPCM_TRIGGER_POST },
  5728. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5729. .ignore_suspend = 1,
  5730. .codec_dai_name = "snd-soc-dummy-dai",
  5731. .codec_name = "snd-soc-dummy",
  5732. .id = MSM_FRONTEND_DAI_LSM5,
  5733. },
  5734. {/* hw:x,24 */
  5735. .name = "Listen 6 Audio Service",
  5736. .stream_name = "Listen 6 Audio Service",
  5737. .cpu_dai_name = "LSM6",
  5738. .platform_name = "msm-lsm-client",
  5739. .dynamic = 1,
  5740. .dpcm_capture = 1,
  5741. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5742. SND_SOC_DPCM_TRIGGER_POST },
  5743. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5744. .ignore_suspend = 1,
  5745. .codec_dai_name = "snd-soc-dummy-dai",
  5746. .codec_name = "snd-soc-dummy",
  5747. .id = MSM_FRONTEND_DAI_LSM6,
  5748. },
  5749. {/* hw:x,25 */
  5750. .name = "Listen 7 Audio Service",
  5751. .stream_name = "Listen 7 Audio Service",
  5752. .cpu_dai_name = "LSM7",
  5753. .platform_name = "msm-lsm-client",
  5754. .dynamic = 1,
  5755. .dpcm_capture = 1,
  5756. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5757. SND_SOC_DPCM_TRIGGER_POST },
  5758. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5759. .ignore_suspend = 1,
  5760. .codec_dai_name = "snd-soc-dummy-dai",
  5761. .codec_name = "snd-soc-dummy",
  5762. .id = MSM_FRONTEND_DAI_LSM7,
  5763. },
  5764. {/* hw:x,26 */
  5765. .name = "Listen 8 Audio Service",
  5766. .stream_name = "Listen 8 Audio Service",
  5767. .cpu_dai_name = "LSM8",
  5768. .platform_name = "msm-lsm-client",
  5769. .dynamic = 1,
  5770. .dpcm_capture = 1,
  5771. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5772. SND_SOC_DPCM_TRIGGER_POST },
  5773. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5774. .ignore_suspend = 1,
  5775. .codec_dai_name = "snd-soc-dummy-dai",
  5776. .codec_name = "snd-soc-dummy",
  5777. .id = MSM_FRONTEND_DAI_LSM8,
  5778. },
  5779. {/* hw:x,27 */
  5780. .name = MSM_DAILINK_NAME(Media9),
  5781. .stream_name = "MultiMedia9",
  5782. .cpu_dai_name = "MultiMedia9",
  5783. .platform_name = "msm-pcm-dsp.0",
  5784. .dynamic = 1,
  5785. .dpcm_playback = 1,
  5786. .dpcm_capture = 1,
  5787. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5788. SND_SOC_DPCM_TRIGGER_POST},
  5789. .codec_dai_name = "snd-soc-dummy-dai",
  5790. .codec_name = "snd-soc-dummy",
  5791. .ignore_suspend = 1,
  5792. /* this dainlink has playback support */
  5793. .ignore_pmdown_time = 1,
  5794. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  5795. },
  5796. {/* hw:x,28 */
  5797. .name = MSM_DAILINK_NAME(Compress4),
  5798. .stream_name = "Compress4",
  5799. .cpu_dai_name = "MultiMedia11",
  5800. .platform_name = "msm-compress-dsp",
  5801. .dynamic = 1,
  5802. .dpcm_playback = 1,
  5803. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5804. SND_SOC_DPCM_TRIGGER_POST},
  5805. .codec_dai_name = "snd-soc-dummy-dai",
  5806. .codec_name = "snd-soc-dummy",
  5807. .ignore_suspend = 1,
  5808. .ignore_pmdown_time = 1,
  5809. /* this dainlink has playback support */
  5810. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  5811. },
  5812. {/* hw:x,29 */
  5813. .name = MSM_DAILINK_NAME(Compress5),
  5814. .stream_name = "Compress5",
  5815. .cpu_dai_name = "MultiMedia12",
  5816. .platform_name = "msm-compress-dsp",
  5817. .dynamic = 1,
  5818. .dpcm_playback = 1,
  5819. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5820. SND_SOC_DPCM_TRIGGER_POST},
  5821. .codec_dai_name = "snd-soc-dummy-dai",
  5822. .codec_name = "snd-soc-dummy",
  5823. .ignore_suspend = 1,
  5824. .ignore_pmdown_time = 1,
  5825. /* this dainlink has playback support */
  5826. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  5827. },
  5828. {/* hw:x,30 */
  5829. .name = MSM_DAILINK_NAME(Compress6),
  5830. .stream_name = "Compress6",
  5831. .cpu_dai_name = "MultiMedia13",
  5832. .platform_name = "msm-compress-dsp",
  5833. .dynamic = 1,
  5834. .dpcm_playback = 1,
  5835. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5836. SND_SOC_DPCM_TRIGGER_POST},
  5837. .codec_dai_name = "snd-soc-dummy-dai",
  5838. .codec_name = "snd-soc-dummy",
  5839. .ignore_suspend = 1,
  5840. .ignore_pmdown_time = 1,
  5841. /* this dainlink has playback support */
  5842. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  5843. },
  5844. {/* hw:x,31 */
  5845. .name = MSM_DAILINK_NAME(Compress7),
  5846. .stream_name = "Compress7",
  5847. .cpu_dai_name = "MultiMedia14",
  5848. .platform_name = "msm-compress-dsp",
  5849. .dynamic = 1,
  5850. .dpcm_playback = 1,
  5851. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5852. SND_SOC_DPCM_TRIGGER_POST},
  5853. .codec_dai_name = "snd-soc-dummy-dai",
  5854. .codec_name = "snd-soc-dummy",
  5855. .ignore_suspend = 1,
  5856. .ignore_pmdown_time = 1,
  5857. /* this dainlink has playback support */
  5858. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  5859. },
  5860. {/* hw:x,32 */
  5861. .name = MSM_DAILINK_NAME(Compress8),
  5862. .stream_name = "Compress8",
  5863. .cpu_dai_name = "MultiMedia15",
  5864. .platform_name = "msm-compress-dsp",
  5865. .dynamic = 1,
  5866. .dpcm_playback = 1,
  5867. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5868. SND_SOC_DPCM_TRIGGER_POST},
  5869. .codec_dai_name = "snd-soc-dummy-dai",
  5870. .codec_name = "snd-soc-dummy",
  5871. .ignore_suspend = 1,
  5872. .ignore_pmdown_time = 1,
  5873. /* this dainlink has playback support */
  5874. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  5875. },
  5876. {/* hw:x,33 */
  5877. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  5878. .stream_name = "MM_NOIRQ_2",
  5879. .cpu_dai_name = "MultiMedia16",
  5880. .platform_name = "msm-pcm-dsp-noirq",
  5881. .dynamic = 1,
  5882. .dpcm_playback = 1,
  5883. .dpcm_capture = 1,
  5884. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5885. SND_SOC_DPCM_TRIGGER_POST},
  5886. .codec_dai_name = "snd-soc-dummy-dai",
  5887. .codec_name = "snd-soc-dummy",
  5888. .ignore_suspend = 1,
  5889. .ignore_pmdown_time = 1,
  5890. /* this dainlink has playback support */
  5891. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  5892. },
  5893. {/* hw:x,34 */
  5894. .name = "SLIMBUS_8 Hostless",
  5895. .stream_name = "SLIMBUS8_HOSTLESS Capture",
  5896. .cpu_dai_name = "SLIMBUS8_HOSTLESS",
  5897. .platform_name = "msm-pcm-hostless",
  5898. .dynamic = 1,
  5899. .dpcm_capture = 1,
  5900. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5901. SND_SOC_DPCM_TRIGGER_POST},
  5902. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5903. .ignore_suspend = 1,
  5904. .codec_dai_name = "snd-soc-dummy-dai",
  5905. .codec_name = "snd-soc-dummy",
  5906. },
  5907. {/* hw:x,35 */
  5908. .name = "CDC_DMA Hostless",
  5909. .stream_name = "CDC_DMA Hostless",
  5910. .cpu_dai_name = "CDC_DMA_HOSTLESS",
  5911. .platform_name = "msm-pcm-hostless",
  5912. .dynamic = 1,
  5913. .dpcm_playback = 1,
  5914. .dpcm_capture = 1,
  5915. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5916. SND_SOC_DPCM_TRIGGER_POST},
  5917. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5918. .ignore_suspend = 1,
  5919. /* this dailink has playback support */
  5920. .ignore_pmdown_time = 1,
  5921. .codec_dai_name = "snd-soc-dummy-dai",
  5922. .codec_name = "snd-soc-dummy",
  5923. },
  5924. {/* hw:x,36 */
  5925. .name = "TX3_CDC_DMA Hostless",
  5926. .stream_name = "TX3_CDC_DMA Hostless",
  5927. .cpu_dai_name = "TX3_CDC_DMA_HOSTLESS",
  5928. .platform_name = "msm-pcm-hostless",
  5929. .dynamic = 1,
  5930. .dpcm_capture = 1,
  5931. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5932. SND_SOC_DPCM_TRIGGER_POST},
  5933. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5934. .ignore_suspend = 1,
  5935. .codec_dai_name = "snd-soc-dummy-dai",
  5936. .codec_name = "snd-soc-dummy",
  5937. },
  5938. };
  5939. static struct snd_soc_dai_link msm_tavil_fe_dai_links[] = {
  5940. {/* hw:x,37 */
  5941. .name = LPASS_BE_SLIMBUS_4_TX,
  5942. .stream_name = "Slimbus4 Capture",
  5943. .cpu_dai_name = "msm-dai-q6-dev.16393",
  5944. .platform_name = "msm-pcm-hostless",
  5945. .codec_name = "tavil_codec",
  5946. .codec_dai_name = "tavil_vifeedback",
  5947. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  5948. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5949. .ops = &msm_be_ops,
  5950. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5951. .ignore_suspend = 1,
  5952. },
  5953. /* Ultrasound RX DAI Link */
  5954. {/* hw:x,38 */
  5955. .name = "SLIMBUS_2 Hostless Playback",
  5956. .stream_name = "SLIMBUS_2 Hostless Playback",
  5957. .cpu_dai_name = "msm-dai-q6-dev.16388",
  5958. .platform_name = "msm-pcm-hostless",
  5959. .codec_name = "tavil_codec",
  5960. .codec_dai_name = "tavil_rx2",
  5961. .ignore_suspend = 1,
  5962. .ignore_pmdown_time = 1,
  5963. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5964. .ops = &msm_slimbus_2_be_ops,
  5965. },
  5966. /* Ultrasound TX DAI Link */
  5967. {/* hw:x,39 */
  5968. .name = "SLIMBUS_2 Hostless Capture",
  5969. .stream_name = "SLIMBUS_2 Hostless Capture",
  5970. .cpu_dai_name = "msm-dai-q6-dev.16389",
  5971. .platform_name = "msm-pcm-hostless",
  5972. .codec_name = "tavil_codec",
  5973. .codec_dai_name = "tavil_tx2",
  5974. .ignore_suspend = 1,
  5975. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5976. .ops = &msm_slimbus_2_be_ops,
  5977. },
  5978. };
  5979. static struct snd_soc_dai_link msm_int_compress_capture_dai[] = {
  5980. {
  5981. .name = "Compress9",
  5982. .stream_name = "Compress9",
  5983. .cpu_dai_name = "MultiMedia17",
  5984. .platform_name = "msm-compress-dsp",
  5985. .dynamic = 1,
  5986. .dpcm_capture = 1,
  5987. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5988. SND_SOC_DPCM_TRIGGER_POST},
  5989. .codec_dai_name = "snd-soc-dummy-dai",
  5990. .codec_name = "snd-soc-dummy",
  5991. .ignore_suspend = 1,
  5992. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  5993. },
  5994. {
  5995. .name = "Compress10",
  5996. .stream_name = "Compress10",
  5997. .cpu_dai_name = "MultiMedia18",
  5998. .platform_name = "msm-compress-dsp",
  5999. .dynamic = 1,
  6000. .dpcm_capture = 1,
  6001. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6002. SND_SOC_DPCM_TRIGGER_POST},
  6003. .codec_dai_name = "snd-soc-dummy-dai",
  6004. .codec_name = "snd-soc-dummy",
  6005. .ignore_suspend = 1,
  6006. .id = MSM_FRONTEND_DAI_MULTIMEDIA18,
  6007. },
  6008. {
  6009. .name = "Compress11",
  6010. .stream_name = "Compress11",
  6011. .cpu_dai_name = "MultiMedia19",
  6012. .platform_name = "msm-compress-dsp",
  6013. .dynamic = 1,
  6014. .dpcm_capture = 1,
  6015. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6016. SND_SOC_DPCM_TRIGGER_POST},
  6017. .codec_dai_name = "snd-soc-dummy-dai",
  6018. .codec_name = "snd-soc-dummy",
  6019. .ignore_suspend = 1,
  6020. .id = MSM_FRONTEND_DAI_MULTIMEDIA19,
  6021. },
  6022. {
  6023. .name = "Compress12",
  6024. .stream_name = "Compress12",
  6025. .cpu_dai_name = "MultiMedia28",
  6026. .platform_name = "msm-compress-dsp",
  6027. .dynamic = 1,
  6028. .dpcm_capture = 1,
  6029. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6030. SND_SOC_DPCM_TRIGGER_POST},
  6031. .codec_dai_name = "snd-soc-dummy-dai",
  6032. .codec_name = "snd-soc-dummy",
  6033. .ignore_suspend = 1,
  6034. .id = MSM_FRONTEND_DAI_MULTIMEDIA28,
  6035. },
  6036. {
  6037. .name = "Compress13",
  6038. .stream_name = "Compress13",
  6039. .cpu_dai_name = "MultiMedia29",
  6040. .platform_name = "msm-compress-dsp",
  6041. .dynamic = 1,
  6042. .dpcm_capture = 1,
  6043. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6044. SND_SOC_DPCM_TRIGGER_POST},
  6045. .codec_dai_name = "snd-soc-dummy-dai",
  6046. .codec_name = "snd-soc-dummy",
  6047. .ignore_suspend = 1,
  6048. .id = MSM_FRONTEND_DAI_MULTIMEDIA29,
  6049. },
  6050. };
  6051. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  6052. {/* hw:x,37 */
  6053. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  6054. .stream_name = "WSA CDC DMA0 Capture",
  6055. .cpu_dai_name = "msm-dai-cdc-dma-dev.45057",
  6056. .platform_name = "msm-pcm-hostless",
  6057. .codec_name = "bolero_codec",
  6058. .codec_dai_name = "wsa_macro_vifeedback",
  6059. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  6060. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6061. .ignore_suspend = 1,
  6062. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6063. .ops = &msm_cdc_dma_be_ops,
  6064. },
  6065. };
  6066. static struct snd_soc_dai_link msm_tasha_fe_dai_links[] = {
  6067. /* tasha_vifeedback for speaker protection */
  6068. {
  6069. .name = LPASS_BE_SLIMBUS_4_TX,
  6070. .stream_name = "Slimbus4 Capture",
  6071. .cpu_dai_name = "msm-dai-q6-dev.16393",
  6072. .platform_name = "msm-pcm-hostless",
  6073. .codec_name = "tasha_codec",
  6074. .codec_dai_name = "tasha_vifeedback",
  6075. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  6076. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6077. .ops = &msm_be_ops,
  6078. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6079. .ignore_suspend = 1,
  6080. },
  6081. /* Ultrasound RX DAI Link */
  6082. {
  6083. .name = "SLIMBUS_2 Hostless Playback",
  6084. .stream_name = "SLIMBUS_2 Hostless Playback",
  6085. .cpu_dai_name = "msm-dai-q6-dev.16388",
  6086. .platform_name = "msm-pcm-hostless",
  6087. .codec_name = "tasha_codec",
  6088. .codec_dai_name = "tasha_rx2",
  6089. .ignore_suspend = 1,
  6090. .dpcm_playback = 1,
  6091. .dpcm_capture = 1,
  6092. .ignore_pmdown_time = 1,
  6093. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6094. .ops = &msm_slimbus_2_be_ops,
  6095. },
  6096. /* Ultrasound TX DAI Link */
  6097. {
  6098. .name = "SLIMBUS_2 Hostless Capture",
  6099. .stream_name = "SLIMBUS_2 Hostless Capture",
  6100. .cpu_dai_name = "msm-dai-q6-dev.16389",
  6101. .platform_name = "msm-pcm-hostless",
  6102. .codec_name = "tasha_codec",
  6103. .codec_dai_name = "tasha_tx2",
  6104. .ignore_suspend = 1,
  6105. .dpcm_capture = 1,
  6106. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6107. .ops = &msm_slimbus_2_be_ops,
  6108. },
  6109. /* CPE LSM direct dai-link */
  6110. {
  6111. .name = "CPE Listen service",
  6112. .stream_name = "CPE Listen Audio Service",
  6113. .cpu_dai_name = "msm-dai-slim",
  6114. .platform_name = "msm-cpe-lsm",
  6115. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6116. SND_SOC_DPCM_TRIGGER_POST},
  6117. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6118. .ignore_suspend = 1,
  6119. .dpcm_capture = 1,
  6120. .codec_dai_name = "tasha_mad1",
  6121. .codec_name = "tasha_codec",
  6122. .ops = &msm_ext_cpe_ops,
  6123. },
  6124. {
  6125. .name = "SLIMBUS_6 Hostless Playback",
  6126. .stream_name = "SLIMBUS_6 Hostless",
  6127. .cpu_dai_name = "SLIMBUS6_HOSTLESS",
  6128. .platform_name = "msm-pcm-hostless",
  6129. .dynamic = 1,
  6130. .dpcm_playback = 1,
  6131. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6132. SND_SOC_DPCM_TRIGGER_POST},
  6133. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6134. .ignore_suspend = 1,
  6135. /* this dailink has playback support */
  6136. .ignore_pmdown_time = 1,
  6137. .codec_dai_name = "snd-soc-dummy-dai",
  6138. .codec_name = "snd-soc-dummy",
  6139. },
  6140. /* CPE LSM EC PP direct dai-link */
  6141. {
  6142. .name = "CPE Listen service ECPP",
  6143. .stream_name = "CPE Listen Audio Service ECPP",
  6144. .cpu_dai_name = "CPE_LSM_NOHOST",
  6145. .platform_name = "msm-cpe-lsm.3",
  6146. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6147. SND_SOC_DPCM_TRIGGER_POST},
  6148. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6149. .ignore_suspend = 1,
  6150. .ignore_pmdown_time = 1,
  6151. .codec_dai_name = "tasha_cpe",
  6152. .codec_name = "tasha_codec",
  6153. },
  6154. };
  6155. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  6156. {
  6157. .name = MSM_DAILINK_NAME(ASM Loopback),
  6158. .stream_name = "MultiMedia6",
  6159. .cpu_dai_name = "MultiMedia6",
  6160. .platform_name = "msm-pcm-loopback",
  6161. .dynamic = 1,
  6162. .dpcm_playback = 1,
  6163. .dpcm_capture = 1,
  6164. .codec_dai_name = "snd-soc-dummy-dai",
  6165. .codec_name = "snd-soc-dummy",
  6166. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6167. SND_SOC_DPCM_TRIGGER_POST},
  6168. .ignore_suspend = 1,
  6169. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6170. .ignore_pmdown_time = 1,
  6171. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  6172. },
  6173. {
  6174. .name = "USB Audio Hostless",
  6175. .stream_name = "USB Audio Hostless",
  6176. .cpu_dai_name = "USBAUDIO_HOSTLESS",
  6177. .platform_name = "msm-pcm-hostless",
  6178. .dynamic = 1,
  6179. .dpcm_playback = 1,
  6180. .dpcm_capture = 1,
  6181. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6182. SND_SOC_DPCM_TRIGGER_POST},
  6183. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  6184. .ignore_suspend = 1,
  6185. .ignore_pmdown_time = 1,
  6186. .codec_dai_name = "snd-soc-dummy-dai",
  6187. .codec_name = "snd-soc-dummy",
  6188. },
  6189. };
  6190. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  6191. /* Backend AFE DAI Links */
  6192. {
  6193. .name = LPASS_BE_AFE_PCM_RX,
  6194. .stream_name = "AFE Playback",
  6195. .cpu_dai_name = "msm-dai-q6-dev.224",
  6196. .platform_name = "msm-pcm-routing",
  6197. .codec_name = "msm-stub-codec.1",
  6198. .codec_dai_name = "msm-stub-rx",
  6199. .no_pcm = 1,
  6200. .dpcm_playback = 1,
  6201. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  6202. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6203. /* this dainlink has playback support */
  6204. .ignore_pmdown_time = 1,
  6205. .ignore_suspend = 1,
  6206. },
  6207. {
  6208. .name = LPASS_BE_AFE_PCM_TX,
  6209. .stream_name = "AFE Capture",
  6210. .cpu_dai_name = "msm-dai-q6-dev.225",
  6211. .platform_name = "msm-pcm-routing",
  6212. .codec_name = "msm-stub-codec.1",
  6213. .codec_dai_name = "msm-stub-tx",
  6214. .no_pcm = 1,
  6215. .dpcm_capture = 1,
  6216. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  6217. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6218. .ignore_suspend = 1,
  6219. },
  6220. /* Incall Record Uplink BACK END DAI Link */
  6221. {
  6222. .name = LPASS_BE_INCALL_RECORD_TX,
  6223. .stream_name = "Voice Uplink Capture",
  6224. .cpu_dai_name = "msm-dai-q6-dev.32772",
  6225. .platform_name = "msm-pcm-routing",
  6226. .codec_name = "msm-stub-codec.1",
  6227. .codec_dai_name = "msm-stub-tx",
  6228. .no_pcm = 1,
  6229. .dpcm_capture = 1,
  6230. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  6231. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6232. .ignore_suspend = 1,
  6233. },
  6234. /* Incall Record Downlink BACK END DAI Link */
  6235. {
  6236. .name = LPASS_BE_INCALL_RECORD_RX,
  6237. .stream_name = "Voice Downlink Capture",
  6238. .cpu_dai_name = "msm-dai-q6-dev.32771",
  6239. .platform_name = "msm-pcm-routing",
  6240. .codec_name = "msm-stub-codec.1",
  6241. .codec_dai_name = "msm-stub-tx",
  6242. .no_pcm = 1,
  6243. .dpcm_capture = 1,
  6244. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  6245. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6246. .ignore_suspend = 1,
  6247. },
  6248. /* Incall Music BACK END DAI Link */
  6249. {
  6250. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  6251. .stream_name = "Voice Farend Playback",
  6252. .cpu_dai_name = "msm-dai-q6-dev.32773",
  6253. .platform_name = "msm-pcm-routing",
  6254. .codec_name = "msm-stub-codec.1",
  6255. .codec_dai_name = "msm-stub-rx",
  6256. .no_pcm = 1,
  6257. .dpcm_playback = 1,
  6258. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  6259. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6260. .ignore_suspend = 1,
  6261. .ignore_pmdown_time = 1,
  6262. },
  6263. /* Incall Music 2 BACK END DAI Link */
  6264. {
  6265. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  6266. .stream_name = "Voice2 Farend Playback",
  6267. .cpu_dai_name = "msm-dai-q6-dev.32770",
  6268. .platform_name = "msm-pcm-routing",
  6269. .codec_name = "msm-stub-codec.1",
  6270. .codec_dai_name = "msm-stub-rx",
  6271. .no_pcm = 1,
  6272. .dpcm_playback = 1,
  6273. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  6274. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6275. .ignore_suspend = 1,
  6276. .ignore_pmdown_time = 1,
  6277. },
  6278. {
  6279. .name = LPASS_BE_USB_AUDIO_RX,
  6280. .stream_name = "USB Audio Playback",
  6281. .cpu_dai_name = "msm-dai-q6-dev.28672",
  6282. .platform_name = "msm-pcm-routing",
  6283. .codec_name = "msm-stub-codec.1",
  6284. .codec_dai_name = "msm-stub-rx",
  6285. .no_pcm = 1,
  6286. .dpcm_playback = 1,
  6287. .id = MSM_BACKEND_DAI_USB_RX,
  6288. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6289. .ignore_pmdown_time = 1,
  6290. .ignore_suspend = 1,
  6291. },
  6292. {
  6293. .name = LPASS_BE_USB_AUDIO_TX,
  6294. .stream_name = "USB Audio Capture",
  6295. .cpu_dai_name = "msm-dai-q6-dev.28673",
  6296. .platform_name = "msm-pcm-routing",
  6297. .codec_name = "msm-stub-codec.1",
  6298. .codec_dai_name = "msm-stub-tx",
  6299. .no_pcm = 1,
  6300. .dpcm_capture = 1,
  6301. .id = MSM_BACKEND_DAI_USB_TX,
  6302. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6303. .ignore_suspend = 1,
  6304. },
  6305. {
  6306. .name = LPASS_BE_PRI_TDM_RX_0,
  6307. .stream_name = "Primary TDM0 Playback",
  6308. .cpu_dai_name = "msm-dai-q6-tdm.36864",
  6309. .platform_name = "msm-pcm-routing",
  6310. .codec_name = "msm-stub-codec.1",
  6311. .codec_dai_name = "msm-stub-rx",
  6312. .no_pcm = 1,
  6313. .dpcm_playback = 1,
  6314. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  6315. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6316. .ops = &sm6150_tdm_be_ops,
  6317. .ignore_suspend = 1,
  6318. .ignore_pmdown_time = 1,
  6319. },
  6320. {
  6321. .name = LPASS_BE_PRI_TDM_TX_0,
  6322. .stream_name = "Primary TDM0 Capture",
  6323. .cpu_dai_name = "msm-dai-q6-tdm.36865",
  6324. .platform_name = "msm-pcm-routing",
  6325. .codec_name = "msm-stub-codec.1",
  6326. .codec_dai_name = "msm-stub-tx",
  6327. .no_pcm = 1,
  6328. .dpcm_capture = 1,
  6329. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  6330. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6331. .ops = &sm6150_tdm_be_ops,
  6332. .ignore_suspend = 1,
  6333. },
  6334. {
  6335. .name = LPASS_BE_SEC_TDM_RX_0,
  6336. .stream_name = "Secondary TDM0 Playback",
  6337. .cpu_dai_name = "msm-dai-q6-tdm.36880",
  6338. .platform_name = "msm-pcm-routing",
  6339. .codec_name = "msm-stub-codec.1",
  6340. .codec_dai_name = "msm-stub-rx",
  6341. .no_pcm = 1,
  6342. .dpcm_playback = 1,
  6343. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  6344. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6345. .ops = &sm6150_tdm_be_ops,
  6346. .ignore_suspend = 1,
  6347. .ignore_pmdown_time = 1,
  6348. },
  6349. {
  6350. .name = LPASS_BE_SEC_TDM_TX_0,
  6351. .stream_name = "Secondary TDM0 Capture",
  6352. .cpu_dai_name = "msm-dai-q6-tdm.36881",
  6353. .platform_name = "msm-pcm-routing",
  6354. .codec_name = "msm-stub-codec.1",
  6355. .codec_dai_name = "msm-stub-tx",
  6356. .no_pcm = 1,
  6357. .dpcm_capture = 1,
  6358. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  6359. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6360. .ops = &sm6150_tdm_be_ops,
  6361. .ignore_suspend = 1,
  6362. },
  6363. {
  6364. .name = LPASS_BE_TERT_TDM_RX_0,
  6365. .stream_name = "Tertiary TDM0 Playback",
  6366. .cpu_dai_name = "msm-dai-q6-tdm.36896",
  6367. .platform_name = "msm-pcm-routing",
  6368. .codec_name = "msm-stub-codec.1",
  6369. .codec_dai_name = "msm-stub-rx",
  6370. .no_pcm = 1,
  6371. .dpcm_playback = 1,
  6372. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  6373. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6374. .ops = &sm6150_tdm_be_ops,
  6375. .ignore_suspend = 1,
  6376. .ignore_pmdown_time = 1,
  6377. },
  6378. {
  6379. .name = LPASS_BE_TERT_TDM_TX_0,
  6380. .stream_name = "Tertiary TDM0 Capture",
  6381. .cpu_dai_name = "msm-dai-q6-tdm.36897",
  6382. .platform_name = "msm-pcm-routing",
  6383. .codec_name = "msm-stub-codec.1",
  6384. .codec_dai_name = "msm-stub-tx",
  6385. .no_pcm = 1,
  6386. .dpcm_capture = 1,
  6387. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  6388. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6389. .ops = &sm6150_tdm_be_ops,
  6390. .ignore_suspend = 1,
  6391. },
  6392. {
  6393. .name = LPASS_BE_QUAT_TDM_RX_0,
  6394. .stream_name = "Quaternary TDM0 Playback",
  6395. .cpu_dai_name = "msm-dai-q6-tdm.36912",
  6396. .platform_name = "msm-pcm-routing",
  6397. .codec_name = "msm-stub-codec.1",
  6398. .codec_dai_name = "msm-stub-rx",
  6399. .no_pcm = 1,
  6400. .dpcm_playback = 1,
  6401. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  6402. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6403. .ops = &sm6150_tdm_be_ops,
  6404. .ignore_suspend = 1,
  6405. .ignore_pmdown_time = 1,
  6406. },
  6407. {
  6408. .name = LPASS_BE_QUAT_TDM_TX_0,
  6409. .stream_name = "Quaternary TDM0 Capture",
  6410. .cpu_dai_name = "msm-dai-q6-tdm.36913",
  6411. .platform_name = "msm-pcm-routing",
  6412. .codec_name = "msm-stub-codec.1",
  6413. .codec_dai_name = "msm-stub-tx",
  6414. .no_pcm = 1,
  6415. .dpcm_capture = 1,
  6416. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  6417. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6418. .ops = &sm6150_tdm_be_ops,
  6419. .ignore_suspend = 1,
  6420. },
  6421. {
  6422. .name = LPASS_BE_QUIN_TDM_RX_0,
  6423. .stream_name = "Quinary TDM0 Playback",
  6424. .cpu_dai_name = "msm-dai-q6-tdm.36928",
  6425. .platform_name = "msm-pcm-routing",
  6426. .codec_name = "msm-stub-codec.1",
  6427. .codec_dai_name = "msm-stub-rx",
  6428. .no_pcm = 1,
  6429. .dpcm_playback = 1,
  6430. .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0,
  6431. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6432. .ops = &sm6150_tdm_be_ops,
  6433. .ignore_suspend = 1,
  6434. .ignore_pmdown_time = 1,
  6435. },
  6436. {
  6437. .name = LPASS_BE_QUIN_TDM_TX_0,
  6438. .stream_name = "Quinary TDM0 Capture",
  6439. .cpu_dai_name = "msm-dai-q6-tdm.36929",
  6440. .platform_name = "msm-pcm-routing",
  6441. .codec_name = "msm-stub-codec.1",
  6442. .codec_dai_name = "msm-stub-tx",
  6443. .no_pcm = 1,
  6444. .dpcm_capture = 1,
  6445. .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0,
  6446. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6447. .ops = &sm6150_tdm_be_ops,
  6448. .ignore_suspend = 1,
  6449. },
  6450. };
  6451. static struct snd_soc_dai_link msm_tavil_be_dai_links[] = {
  6452. {
  6453. .name = LPASS_BE_SLIMBUS_0_RX,
  6454. .stream_name = "Slimbus Playback",
  6455. .cpu_dai_name = "msm-dai-q6-dev.16384",
  6456. .platform_name = "msm-pcm-routing",
  6457. .codec_name = "tavil_codec",
  6458. .codec_dai_name = "tavil_rx1",
  6459. .no_pcm = 1,
  6460. .dpcm_playback = 1,
  6461. .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  6462. .init = &msm_audrx_tavil_init,
  6463. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6464. /* this dainlink has playback support */
  6465. .ignore_pmdown_time = 1,
  6466. .ignore_suspend = 1,
  6467. .ops = &msm_be_ops,
  6468. },
  6469. {
  6470. .name = LPASS_BE_SLIMBUS_0_TX,
  6471. .stream_name = "Slimbus Capture",
  6472. .cpu_dai_name = "msm-dai-q6-dev.16385",
  6473. .platform_name = "msm-pcm-routing",
  6474. .codec_name = "tavil_codec",
  6475. .codec_dai_name = "tavil_tx1",
  6476. .no_pcm = 1,
  6477. .dpcm_capture = 1,
  6478. .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  6479. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6480. .ignore_suspend = 1,
  6481. .ops = &msm_be_ops,
  6482. },
  6483. {
  6484. .name = LPASS_BE_SLIMBUS_1_RX,
  6485. .stream_name = "Slimbus1 Playback",
  6486. .cpu_dai_name = "msm-dai-q6-dev.16386",
  6487. .platform_name = "msm-pcm-routing",
  6488. .codec_name = "tavil_codec",
  6489. .codec_dai_name = "tavil_rx1",
  6490. .no_pcm = 1,
  6491. .dpcm_playback = 1,
  6492. .id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  6493. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6494. .ops = &msm_be_ops,
  6495. /* dai link has playback support */
  6496. .ignore_pmdown_time = 1,
  6497. .ignore_suspend = 1,
  6498. },
  6499. {
  6500. .name = LPASS_BE_SLIMBUS_1_TX,
  6501. .stream_name = "Slimbus1 Capture",
  6502. .cpu_dai_name = "msm-dai-q6-dev.16387",
  6503. .platform_name = "msm-pcm-routing",
  6504. .codec_name = "tavil_codec",
  6505. .codec_dai_name = "tavil_tx3",
  6506. .no_pcm = 1,
  6507. .dpcm_capture = 1,
  6508. .id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  6509. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6510. .ops = &msm_be_ops,
  6511. .ignore_suspend = 1,
  6512. },
  6513. {
  6514. .name = LPASS_BE_SLIMBUS_2_RX,
  6515. .stream_name = "Slimbus2 Playback",
  6516. .cpu_dai_name = "msm-dai-q6-dev.16388",
  6517. .platform_name = "msm-pcm-routing",
  6518. .codec_name = "tavil_codec",
  6519. .codec_dai_name = "tavil_rx2",
  6520. .no_pcm = 1,
  6521. .dpcm_playback = 1,
  6522. .id = MSM_BACKEND_DAI_SLIMBUS_2_RX,
  6523. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6524. .ops = &msm_be_ops,
  6525. .ignore_pmdown_time = 1,
  6526. .ignore_suspend = 1,
  6527. },
  6528. {
  6529. .name = LPASS_BE_SLIMBUS_3_RX,
  6530. .stream_name = "Slimbus3 Playback",
  6531. .cpu_dai_name = "msm-dai-q6-dev.16390",
  6532. .platform_name = "msm-pcm-routing",
  6533. .codec_name = "tavil_codec",
  6534. .codec_dai_name = "tavil_rx1",
  6535. .no_pcm = 1,
  6536. .dpcm_playback = 1,
  6537. .id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  6538. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6539. .ops = &msm_be_ops,
  6540. /* dai link has playback support */
  6541. .ignore_pmdown_time = 1,
  6542. .ignore_suspend = 1,
  6543. },
  6544. {
  6545. .name = LPASS_BE_SLIMBUS_3_TX,
  6546. .stream_name = "Slimbus3 Capture",
  6547. .cpu_dai_name = "msm-dai-q6-dev.16391",
  6548. .platform_name = "msm-pcm-routing",
  6549. .codec_name = "tavil_codec",
  6550. .codec_dai_name = "tavil_tx1",
  6551. .no_pcm = 1,
  6552. .dpcm_capture = 1,
  6553. .id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  6554. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6555. .ops = &msm_be_ops,
  6556. .ignore_suspend = 1,
  6557. },
  6558. {
  6559. .name = LPASS_BE_SLIMBUS_4_RX,
  6560. .stream_name = "Slimbus4 Playback",
  6561. .cpu_dai_name = "msm-dai-q6-dev.16392",
  6562. .platform_name = "msm-pcm-routing",
  6563. .codec_name = "tavil_codec",
  6564. .codec_dai_name = "tavil_rx1",
  6565. .no_pcm = 1,
  6566. .dpcm_playback = 1,
  6567. .id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  6568. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6569. .ops = &msm_be_ops,
  6570. /* dai link has playback support */
  6571. .ignore_pmdown_time = 1,
  6572. .ignore_suspend = 1,
  6573. },
  6574. {
  6575. .name = LPASS_BE_SLIMBUS_5_RX,
  6576. .stream_name = "Slimbus5 Playback",
  6577. .cpu_dai_name = "msm-dai-q6-dev.16394",
  6578. .platform_name = "msm-pcm-routing",
  6579. .codec_name = "tavil_codec",
  6580. .codec_dai_name = "tavil_rx3",
  6581. .no_pcm = 1,
  6582. .dpcm_playback = 1,
  6583. .id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
  6584. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6585. .ops = &msm_be_ops,
  6586. /* dai link has playback support */
  6587. .ignore_pmdown_time = 1,
  6588. .ignore_suspend = 1,
  6589. },
  6590. /* MAD BE */
  6591. {
  6592. .name = LPASS_BE_SLIMBUS_5_TX,
  6593. .stream_name = "Slimbus5 Capture",
  6594. .cpu_dai_name = "msm-dai-q6-dev.16395",
  6595. .platform_name = "msm-pcm-routing",
  6596. .codec_name = "tavil_codec",
  6597. .codec_dai_name = "tavil_mad1",
  6598. .no_pcm = 1,
  6599. .dpcm_capture = 1,
  6600. .id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
  6601. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6602. .ops = &msm_be_ops,
  6603. .ignore_suspend = 1,
  6604. },
  6605. {
  6606. .name = LPASS_BE_SLIMBUS_6_RX,
  6607. .stream_name = "Slimbus6 Playback",
  6608. .cpu_dai_name = "msm-dai-q6-dev.16396",
  6609. .platform_name = "msm-pcm-routing",
  6610. .codec_name = "tavil_codec",
  6611. .codec_dai_name = "tavil_rx4",
  6612. .no_pcm = 1,
  6613. .dpcm_playback = 1,
  6614. .id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
  6615. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6616. .ops = &msm_be_ops,
  6617. /* dai link has playback support */
  6618. .ignore_pmdown_time = 1,
  6619. .ignore_suspend = 1,
  6620. },
  6621. /* Slimbus VI Recording */
  6622. {
  6623. .name = LPASS_BE_SLIMBUS_TX_VI,
  6624. .stream_name = "Slimbus4 Capture",
  6625. .cpu_dai_name = "msm-dai-q6-dev.16393",
  6626. .platform_name = "msm-pcm-routing",
  6627. .codec_name = "tavil_codec",
  6628. .codec_dai_name = "tavil_vifeedback",
  6629. .id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
  6630. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6631. .ops = &msm_be_ops,
  6632. .ignore_suspend = 1,
  6633. .no_pcm = 1,
  6634. .dpcm_capture = 1,
  6635. },
  6636. };
  6637. static struct snd_soc_dai_link msm_tasha_be_dai_links[] = {
  6638. /* Backend DAI Links */
  6639. {
  6640. .name = LPASS_BE_SLIMBUS_0_RX,
  6641. .stream_name = "Slimbus Playback",
  6642. .cpu_dai_name = "msm-dai-q6-dev.16384",
  6643. .platform_name = "msm-pcm-routing",
  6644. .codec_name = "tasha_codec",
  6645. .codec_dai_name = "tasha_mix_rx1",
  6646. .no_pcm = 1,
  6647. .dpcm_playback = 1,
  6648. .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  6649. .init = &msm_audrx_tasha_init,
  6650. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6651. /* this dainlink has playback support */
  6652. .ignore_pmdown_time = 1,
  6653. .ignore_suspend = 1,
  6654. .ops = &msm_be_ops,
  6655. },
  6656. {
  6657. .name = LPASS_BE_SLIMBUS_0_TX,
  6658. .stream_name = "Slimbus Capture",
  6659. .cpu_dai_name = "msm-dai-q6-dev.16385",
  6660. .platform_name = "msm-pcm-routing",
  6661. .codec_name = "tasha_codec",
  6662. .codec_dai_name = "tasha_tx1",
  6663. .no_pcm = 1,
  6664. .dpcm_capture = 1,
  6665. .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  6666. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6667. .ignore_suspend = 1,
  6668. .ops = &msm_be_ops,
  6669. },
  6670. {
  6671. .name = LPASS_BE_SLIMBUS_1_RX,
  6672. .stream_name = "Slimbus1 Playback",
  6673. .cpu_dai_name = "msm-dai-q6-dev.16386",
  6674. .platform_name = "msm-pcm-routing",
  6675. .codec_name = "tasha_codec",
  6676. .codec_dai_name = "tasha_mix_rx1",
  6677. .no_pcm = 1,
  6678. .dpcm_playback = 1,
  6679. .id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
  6680. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6681. .ops = &msm_be_ops,
  6682. /* dai link has playback support */
  6683. .ignore_pmdown_time = 1,
  6684. .ignore_suspend = 1,
  6685. },
  6686. {
  6687. .name = LPASS_BE_SLIMBUS_1_TX,
  6688. .stream_name = "Slimbus1 Capture",
  6689. .cpu_dai_name = "msm-dai-q6-dev.16387",
  6690. .platform_name = "msm-pcm-routing",
  6691. .codec_name = "tasha_codec",
  6692. .codec_dai_name = "tasha_tx3",
  6693. .no_pcm = 1,
  6694. .dpcm_capture = 1,
  6695. .id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
  6696. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6697. .ops = &msm_be_ops,
  6698. .ignore_suspend = 1,
  6699. },
  6700. {
  6701. .name = LPASS_BE_SLIMBUS_3_RX,
  6702. .stream_name = "Slimbus3 Playback",
  6703. .cpu_dai_name = "msm-dai-q6-dev.16390",
  6704. .platform_name = "msm-pcm-routing",
  6705. .codec_name = "tasha_codec",
  6706. .codec_dai_name = "tasha_mix_rx1",
  6707. .no_pcm = 1,
  6708. .dpcm_playback = 1,
  6709. .id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
  6710. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6711. .ops = &msm_be_ops,
  6712. /* dai link has playback support */
  6713. .ignore_pmdown_time = 1,
  6714. .ignore_suspend = 1,
  6715. },
  6716. {
  6717. .name = LPASS_BE_SLIMBUS_3_TX,
  6718. .stream_name = "Slimbus3 Capture",
  6719. .cpu_dai_name = "msm-dai-q6-dev.16391",
  6720. .platform_name = "msm-pcm-routing",
  6721. .codec_name = "tasha_codec",
  6722. .codec_dai_name = "tasha_tx1",
  6723. .no_pcm = 1,
  6724. .dpcm_capture = 1,
  6725. .dpcm_playback = 1,
  6726. .id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
  6727. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6728. .ops = &msm_be_ops,
  6729. .ignore_suspend = 1,
  6730. },
  6731. {
  6732. .name = LPASS_BE_SLIMBUS_4_RX,
  6733. .stream_name = "Slimbus4 Playback",
  6734. .cpu_dai_name = "msm-dai-q6-dev.16392",
  6735. .platform_name = "msm-pcm-routing",
  6736. .codec_name = "tasha_codec",
  6737. .codec_dai_name = "tasha_mix_rx1",
  6738. .no_pcm = 1,
  6739. .dpcm_playback = 1,
  6740. .id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
  6741. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6742. .ops = &msm_be_ops,
  6743. /* dai link has playback support */
  6744. .ignore_pmdown_time = 1,
  6745. .ignore_suspend = 1,
  6746. },
  6747. {
  6748. .name = LPASS_BE_SLIMBUS_5_RX,
  6749. .stream_name = "Slimbus5 Playback",
  6750. .cpu_dai_name = "msm-dai-q6-dev.16394",
  6751. .platform_name = "msm-pcm-routing",
  6752. .codec_name = "tasha_codec",
  6753. .codec_dai_name = "tasha_rx3",
  6754. .no_pcm = 1,
  6755. .dpcm_playback = 1,
  6756. .id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
  6757. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6758. .ops = &msm_be_ops,
  6759. /* dai link has playback support */
  6760. .ignore_pmdown_time = 1,
  6761. .ignore_suspend = 1,
  6762. },
  6763. /* MAD BE */
  6764. {
  6765. .name = LPASS_BE_SLIMBUS_5_TX,
  6766. .stream_name = "Slimbus5 Capture",
  6767. .cpu_dai_name = "msm-dai-q6-dev.16395",
  6768. .platform_name = "msm-pcm-routing",
  6769. .codec_name = "tasha_codec",
  6770. .codec_dai_name = "tasha_mad1",
  6771. .no_pcm = 1,
  6772. .dpcm_capture = 1,
  6773. .id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
  6774. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6775. .ops = &msm_be_ops,
  6776. .ignore_suspend = 1,
  6777. },
  6778. {
  6779. .name = LPASS_BE_SLIMBUS_6_RX,
  6780. .stream_name = "Slimbus6 Playback",
  6781. .cpu_dai_name = "msm-dai-q6-dev.16396",
  6782. .platform_name = "msm-pcm-routing",
  6783. .codec_name = "tasha_codec",
  6784. .codec_dai_name = "tasha_rx4",
  6785. .no_pcm = 1,
  6786. .dpcm_playback = 1,
  6787. .id = MSM_BACKEND_DAI_SLIMBUS_6_RX,
  6788. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6789. .ops = &msm_be_ops,
  6790. /* dai link has playback support */
  6791. .ignore_pmdown_time = 1,
  6792. .ignore_suspend = 1,
  6793. },
  6794. };
  6795. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  6796. {
  6797. .name = LPASS_BE_SLIMBUS_7_RX,
  6798. .stream_name = "Slimbus7 Playback",
  6799. .cpu_dai_name = "msm-dai-q6-dev.16398",
  6800. .platform_name = "msm-pcm-routing",
  6801. .codec_name = "btfmslim_slave",
  6802. /* BT codec driver determines capabilities based on
  6803. * dai name, bt codecdai name should always contains
  6804. * supported usecase information
  6805. */
  6806. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  6807. .no_pcm = 1,
  6808. .dpcm_playback = 1,
  6809. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  6810. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6811. .ops = &msm_wcn_ops,
  6812. /* dai link has playback support */
  6813. .ignore_pmdown_time = 1,
  6814. .ignore_suspend = 1,
  6815. },
  6816. {
  6817. .name = LPASS_BE_SLIMBUS_7_TX,
  6818. .stream_name = "Slimbus7 Capture",
  6819. .cpu_dai_name = "msm-dai-q6-dev.16399",
  6820. .platform_name = "msm-pcm-routing",
  6821. .codec_name = "btfmslim_slave",
  6822. .codec_dai_name = "btfm_bt_sco_slim_tx",
  6823. .no_pcm = 1,
  6824. .dpcm_capture = 1,
  6825. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  6826. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6827. .ops = &msm_wcn_ops,
  6828. .ignore_suspend = 1,
  6829. },
  6830. {
  6831. .name = LPASS_BE_SLIMBUS_8_TX,
  6832. .stream_name = "Slimbus8 Capture",
  6833. .cpu_dai_name = "msm-dai-q6-dev.16401",
  6834. .platform_name = "msm-pcm-routing",
  6835. .codec_name = "btfmslim_slave",
  6836. .codec_dai_name = "btfm_fm_slim_tx",
  6837. .no_pcm = 1,
  6838. .dpcm_capture = 1,
  6839. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  6840. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6841. .init = &msm_wcn_init,
  6842. .ops = &msm_wcn_ops,
  6843. .ignore_suspend = 1,
  6844. },
  6845. };
  6846. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  6847. /* DISP PORT BACK END DAI Link */
  6848. {
  6849. .name = LPASS_BE_DISPLAY_PORT,
  6850. .stream_name = "Display Port Playback",
  6851. .cpu_dai_name = "msm-dai-q6-dp.24608",
  6852. .platform_name = "msm-pcm-routing",
  6853. .codec_name = "msm-ext-disp-audio-codec-rx",
  6854. .codec_dai_name = "msm_dp_audio_codec_rx_dai",
  6855. .no_pcm = 1,
  6856. .dpcm_playback = 1,
  6857. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  6858. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6859. .ignore_pmdown_time = 1,
  6860. .ignore_suspend = 1,
  6861. },
  6862. };
  6863. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  6864. {
  6865. .name = LPASS_BE_PRI_MI2S_RX,
  6866. .stream_name = "Primary MI2S Playback",
  6867. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  6868. .platform_name = "msm-pcm-routing",
  6869. .codec_name = "msm-stub-codec.1",
  6870. .codec_dai_name = "msm-stub-rx",
  6871. .no_pcm = 1,
  6872. .dpcm_playback = 1,
  6873. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  6874. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6875. .ops = &msm_mi2s_be_ops,
  6876. .ignore_suspend = 1,
  6877. .ignore_pmdown_time = 1,
  6878. },
  6879. {
  6880. .name = LPASS_BE_PRI_MI2S_TX,
  6881. .stream_name = "Primary MI2S Capture",
  6882. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  6883. .platform_name = "msm-pcm-routing",
  6884. .codec_name = "msm-stub-codec.1",
  6885. .codec_dai_name = "msm-stub-tx",
  6886. .no_pcm = 1,
  6887. .dpcm_capture = 1,
  6888. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  6889. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6890. .ops = &msm_mi2s_be_ops,
  6891. .ignore_suspend = 1,
  6892. },
  6893. {
  6894. .name = LPASS_BE_SEC_MI2S_RX,
  6895. .stream_name = "Secondary MI2S Playback",
  6896. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  6897. .platform_name = "msm-pcm-routing",
  6898. .codec_name = "msm-stub-codec.1",
  6899. .codec_dai_name = "msm-stub-rx",
  6900. .no_pcm = 1,
  6901. .dpcm_playback = 1,
  6902. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  6903. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6904. .ops = &msm_mi2s_be_ops,
  6905. .ignore_suspend = 1,
  6906. .ignore_pmdown_time = 1,
  6907. },
  6908. {
  6909. .name = LPASS_BE_SEC_MI2S_TX,
  6910. .stream_name = "Secondary MI2S Capture",
  6911. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  6912. .platform_name = "msm-pcm-routing",
  6913. .codec_name = "msm-stub-codec.1",
  6914. .codec_dai_name = "msm-stub-tx",
  6915. .no_pcm = 1,
  6916. .dpcm_capture = 1,
  6917. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  6918. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6919. .ops = &msm_mi2s_be_ops,
  6920. .ignore_suspend = 1,
  6921. },
  6922. {
  6923. .name = LPASS_BE_TERT_MI2S_RX,
  6924. .stream_name = "Tertiary MI2S Playback",
  6925. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  6926. .platform_name = "msm-pcm-routing",
  6927. .codec_name = "msm-stub-codec.1",
  6928. .codec_dai_name = "msm-stub-rx",
  6929. .no_pcm = 1,
  6930. .dpcm_playback = 1,
  6931. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  6932. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6933. .ops = &msm_mi2s_be_ops,
  6934. .ignore_suspend = 1,
  6935. .ignore_pmdown_time = 1,
  6936. },
  6937. {
  6938. .name = LPASS_BE_TERT_MI2S_TX,
  6939. .stream_name = "Tertiary MI2S Capture",
  6940. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  6941. .platform_name = "msm-pcm-routing",
  6942. .codec_name = "msm-stub-codec.1",
  6943. .codec_dai_name = "msm-stub-tx",
  6944. .no_pcm = 1,
  6945. .dpcm_capture = 1,
  6946. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  6947. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6948. .ops = &msm_mi2s_be_ops,
  6949. .ignore_suspend = 1,
  6950. },
  6951. {
  6952. .name = LPASS_BE_QUAT_MI2S_RX,
  6953. .stream_name = "Quaternary MI2S Playback",
  6954. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  6955. .platform_name = "msm-pcm-routing",
  6956. .codec_name = "msm-stub-codec.1",
  6957. .codec_dai_name = "msm-stub-rx",
  6958. .no_pcm = 1,
  6959. .dpcm_playback = 1,
  6960. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  6961. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6962. .ops = &msm_mi2s_be_ops,
  6963. .ignore_suspend = 1,
  6964. .ignore_pmdown_time = 1,
  6965. },
  6966. {
  6967. .name = LPASS_BE_QUAT_MI2S_TX,
  6968. .stream_name = "Quaternary MI2S Capture",
  6969. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  6970. .platform_name = "msm-pcm-routing",
  6971. .codec_name = "msm-stub-codec.1",
  6972. .codec_dai_name = "msm-stub-tx",
  6973. .no_pcm = 1,
  6974. .dpcm_capture = 1,
  6975. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  6976. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6977. .ops = &msm_mi2s_be_ops,
  6978. .ignore_suspend = 1,
  6979. },
  6980. {
  6981. .name = LPASS_BE_QUIN_MI2S_RX,
  6982. .stream_name = "Quinary MI2S Playback",
  6983. .cpu_dai_name = "msm-dai-q6-mi2s.4",
  6984. .platform_name = "msm-pcm-routing",
  6985. .codec_name = "msm-stub-codec.1",
  6986. .codec_dai_name = "msm-stub-rx",
  6987. .no_pcm = 1,
  6988. .dpcm_playback = 1,
  6989. .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
  6990. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6991. .ops = &msm_mi2s_be_ops,
  6992. .ignore_suspend = 1,
  6993. .ignore_pmdown_time = 1,
  6994. },
  6995. {
  6996. .name = LPASS_BE_QUIN_MI2S_TX,
  6997. .stream_name = "Quinary MI2S Capture",
  6998. .cpu_dai_name = "msm-dai-q6-mi2s.4",
  6999. .platform_name = "msm-pcm-routing",
  7000. .codec_name = "msm-stub-codec.1",
  7001. .codec_dai_name = "msm-stub-tx",
  7002. .no_pcm = 1,
  7003. .dpcm_capture = 1,
  7004. .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
  7005. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7006. .ops = &msm_mi2s_be_ops,
  7007. .ignore_suspend = 1,
  7008. },
  7009. };
  7010. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  7011. /* Primary AUX PCM Backend DAI Links */
  7012. {
  7013. .name = LPASS_BE_AUXPCM_RX,
  7014. .stream_name = "AUX PCM Playback",
  7015. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  7016. .platform_name = "msm-pcm-routing",
  7017. .codec_name = "msm-stub-codec.1",
  7018. .codec_dai_name = "msm-stub-rx",
  7019. .no_pcm = 1,
  7020. .dpcm_playback = 1,
  7021. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  7022. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7023. .ignore_pmdown_time = 1,
  7024. .ignore_suspend = 1,
  7025. },
  7026. {
  7027. .name = LPASS_BE_AUXPCM_TX,
  7028. .stream_name = "AUX PCM Capture",
  7029. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  7030. .platform_name = "msm-pcm-routing",
  7031. .codec_name = "msm-stub-codec.1",
  7032. .codec_dai_name = "msm-stub-tx",
  7033. .no_pcm = 1,
  7034. .dpcm_capture = 1,
  7035. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  7036. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7037. .ignore_suspend = 1,
  7038. },
  7039. /* Secondary AUX PCM Backend DAI Links */
  7040. {
  7041. .name = LPASS_BE_SEC_AUXPCM_RX,
  7042. .stream_name = "Sec AUX PCM Playback",
  7043. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  7044. .platform_name = "msm-pcm-routing",
  7045. .codec_name = "msm-stub-codec.1",
  7046. .codec_dai_name = "msm-stub-rx",
  7047. .no_pcm = 1,
  7048. .dpcm_playback = 1,
  7049. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  7050. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7051. .ignore_pmdown_time = 1,
  7052. .ignore_suspend = 1,
  7053. },
  7054. {
  7055. .name = LPASS_BE_SEC_AUXPCM_TX,
  7056. .stream_name = "Sec AUX PCM Capture",
  7057. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  7058. .platform_name = "msm-pcm-routing",
  7059. .codec_name = "msm-stub-codec.1",
  7060. .codec_dai_name = "msm-stub-tx",
  7061. .no_pcm = 1,
  7062. .dpcm_capture = 1,
  7063. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  7064. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7065. .ignore_suspend = 1,
  7066. },
  7067. /* Tertiary AUX PCM Backend DAI Links */
  7068. {
  7069. .name = LPASS_BE_TERT_AUXPCM_RX,
  7070. .stream_name = "Tert AUX PCM Playback",
  7071. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  7072. .platform_name = "msm-pcm-routing",
  7073. .codec_name = "msm-stub-codec.1",
  7074. .codec_dai_name = "msm-stub-rx",
  7075. .no_pcm = 1,
  7076. .dpcm_playback = 1,
  7077. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  7078. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7079. .ignore_suspend = 1,
  7080. },
  7081. {
  7082. .name = LPASS_BE_TERT_AUXPCM_TX,
  7083. .stream_name = "Tert AUX PCM Capture",
  7084. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  7085. .platform_name = "msm-pcm-routing",
  7086. .codec_name = "msm-stub-codec.1",
  7087. .codec_dai_name = "msm-stub-tx",
  7088. .no_pcm = 1,
  7089. .dpcm_capture = 1,
  7090. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  7091. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7092. .ignore_suspend = 1,
  7093. },
  7094. /* Quaternary AUX PCM Backend DAI Links */
  7095. {
  7096. .name = LPASS_BE_QUAT_AUXPCM_RX,
  7097. .stream_name = "Quat AUX PCM Playback",
  7098. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  7099. .platform_name = "msm-pcm-routing",
  7100. .codec_name = "msm-stub-codec.1",
  7101. .codec_dai_name = "msm-stub-rx",
  7102. .no_pcm = 1,
  7103. .dpcm_playback = 1,
  7104. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  7105. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7106. .ignore_pmdown_time = 1,
  7107. .ignore_suspend = 1,
  7108. },
  7109. {
  7110. .name = LPASS_BE_QUAT_AUXPCM_TX,
  7111. .stream_name = "Quat AUX PCM Capture",
  7112. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  7113. .platform_name = "msm-pcm-routing",
  7114. .codec_name = "msm-stub-codec.1",
  7115. .codec_dai_name = "msm-stub-tx",
  7116. .no_pcm = 1,
  7117. .dpcm_capture = 1,
  7118. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  7119. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7120. .ignore_suspend = 1,
  7121. },
  7122. /* Quinary AUX PCM Backend DAI Links */
  7123. {
  7124. .name = LPASS_BE_QUIN_AUXPCM_RX,
  7125. .stream_name = "Quin AUX PCM Playback",
  7126. .cpu_dai_name = "msm-dai-q6-auxpcm.5",
  7127. .platform_name = "msm-pcm-routing",
  7128. .codec_name = "msm-stub-codec.1",
  7129. .codec_dai_name = "msm-stub-rx",
  7130. .no_pcm = 1,
  7131. .dpcm_playback = 1,
  7132. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
  7133. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7134. .ignore_pmdown_time = 1,
  7135. .ignore_suspend = 1,
  7136. },
  7137. {
  7138. .name = LPASS_BE_QUIN_AUXPCM_TX,
  7139. .stream_name = "Quin AUX PCM Capture",
  7140. .cpu_dai_name = "msm-dai-q6-auxpcm.5",
  7141. .platform_name = "msm-pcm-routing",
  7142. .codec_name = "msm-stub-codec.1",
  7143. .codec_dai_name = "msm-stub-tx",
  7144. .no_pcm = 1,
  7145. .dpcm_capture = 1,
  7146. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
  7147. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7148. .ignore_suspend = 1,
  7149. },
  7150. };
  7151. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  7152. /* WSA CDC DMA Backend DAI Links */
  7153. {
  7154. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  7155. .stream_name = "WSA CDC DMA0 Playback",
  7156. .cpu_dai_name = "msm-dai-cdc-dma-dev.45056",
  7157. .platform_name = "msm-pcm-routing",
  7158. .codec_name = "bolero_codec",
  7159. .codec_dai_name = "wsa_macro_rx1",
  7160. .no_pcm = 1,
  7161. .dpcm_playback = 1,
  7162. .init = &msm_int_audrx_init,
  7163. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  7164. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7165. .ignore_pmdown_time = 1,
  7166. .ignore_suspend = 1,
  7167. .ops = &msm_cdc_dma_be_ops,
  7168. },
  7169. {
  7170. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  7171. .stream_name = "WSA CDC DMA1 Playback",
  7172. .cpu_dai_name = "msm-dai-cdc-dma-dev.45058",
  7173. .platform_name = "msm-pcm-routing",
  7174. .codec_name = "bolero_codec",
  7175. .codec_dai_name = "wsa_macro_rx_mix",
  7176. .no_pcm = 1,
  7177. .dpcm_playback = 1,
  7178. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  7179. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7180. .ignore_pmdown_time = 1,
  7181. .ignore_suspend = 1,
  7182. .ops = &msm_cdc_dma_be_ops,
  7183. },
  7184. {
  7185. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  7186. .stream_name = "WSA CDC DMA1 Capture",
  7187. .cpu_dai_name = "msm-dai-cdc-dma-dev.45059",
  7188. .platform_name = "msm-pcm-routing",
  7189. .codec_name = "bolero_codec",
  7190. .codec_dai_name = "wsa_macro_echo",
  7191. .no_pcm = 1,
  7192. .dpcm_capture = 1,
  7193. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  7194. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7195. .ignore_suspend = 1,
  7196. .ops = &msm_cdc_dma_be_ops,
  7197. },
  7198. };
  7199. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  7200. /* RX CDC DMA Backend DAI Links */
  7201. {
  7202. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  7203. .stream_name = "RX CDC DMA0 Playback",
  7204. .cpu_dai_name = "msm-dai-cdc-dma-dev.45104",
  7205. .platform_name = "msm-pcm-routing",
  7206. .codec_name = "bolero_codec",
  7207. .codec_dai_name = "rx_macro_rx1",
  7208. .no_pcm = 1,
  7209. .dpcm_playback = 1,
  7210. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  7211. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7212. .ignore_pmdown_time = 1,
  7213. .ignore_suspend = 1,
  7214. .ops = &msm_cdc_dma_be_ops,
  7215. },
  7216. {
  7217. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  7218. .stream_name = "RX CDC DMA1 Playback",
  7219. .cpu_dai_name = "msm-dai-cdc-dma-dev.45106",
  7220. .platform_name = "msm-pcm-routing",
  7221. .codec_name = "bolero_codec",
  7222. .codec_dai_name = "rx_macro_rx2",
  7223. .no_pcm = 1,
  7224. .dpcm_playback = 1,
  7225. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  7226. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7227. .ignore_pmdown_time = 1,
  7228. .ignore_suspend = 1,
  7229. .ops = &msm_cdc_dma_be_ops,
  7230. },
  7231. {
  7232. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  7233. .stream_name = "RX CDC DMA2 Playback",
  7234. .cpu_dai_name = "msm-dai-cdc-dma-dev.45108",
  7235. .platform_name = "msm-pcm-routing",
  7236. .codec_name = "bolero_codec",
  7237. .codec_dai_name = "rx_macro_rx3",
  7238. .no_pcm = 1,
  7239. .dpcm_playback = 1,
  7240. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  7241. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7242. .ignore_pmdown_time = 1,
  7243. .ignore_suspend = 1,
  7244. .ops = &msm_cdc_dma_be_ops,
  7245. },
  7246. {
  7247. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  7248. .stream_name = "RX CDC DMA3 Playback",
  7249. .cpu_dai_name = "msm-dai-cdc-dma-dev.45110",
  7250. .platform_name = "msm-pcm-routing",
  7251. .codec_name = "bolero_codec",
  7252. .codec_dai_name = "rx_macro_rx4",
  7253. .no_pcm = 1,
  7254. .dpcm_playback = 1,
  7255. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  7256. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7257. .ignore_pmdown_time = 1,
  7258. .ignore_suspend = 1,
  7259. .ops = &msm_cdc_dma_be_ops,
  7260. },
  7261. /* TX CDC DMA Backend DAI Links */
  7262. {
  7263. .name = LPASS_BE_TX_CDC_DMA_TX_0,
  7264. .stream_name = "TX CDC DMA0 Capture",
  7265. .cpu_dai_name = "msm-dai-cdc-dma-dev.45105",
  7266. .platform_name = "msm-pcm-routing",
  7267. .codec_name = "bolero_codec",
  7268. .codec_dai_name = "rx_macro_echo",
  7269. .no_pcm = 1,
  7270. .dpcm_capture = 1,
  7271. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_0,
  7272. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7273. .ignore_suspend = 1,
  7274. .ops = &msm_cdc_dma_be_ops,
  7275. },
  7276. {
  7277. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  7278. .stream_name = "TX CDC DMA3 Capture",
  7279. .cpu_dai_name = "msm-dai-cdc-dma-dev.45111",
  7280. .platform_name = "msm-pcm-routing",
  7281. .codec_name = "bolero_codec",
  7282. .codec_dai_name = "tx_macro_tx1",
  7283. .no_pcm = 1,
  7284. .dpcm_capture = 1,
  7285. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  7286. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7287. .ignore_suspend = 1,
  7288. .ops = &msm_cdc_dma_be_ops,
  7289. },
  7290. {
  7291. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  7292. .stream_name = "TX CDC DMA4 Capture",
  7293. .cpu_dai_name = "msm-dai-cdc-dma-dev.45113",
  7294. .platform_name = "msm-pcm-routing",
  7295. .codec_name = "bolero_codec",
  7296. .codec_dai_name = "tx_macro_tx2",
  7297. .no_pcm = 1,
  7298. .dpcm_capture = 1,
  7299. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  7300. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7301. .ignore_suspend = 1,
  7302. .ops = &msm_cdc_dma_be_ops,
  7303. },
  7304. };
  7305. static struct snd_soc_dai_link msm_sm6150_dai_links[
  7306. ARRAY_SIZE(msm_common_dai_links) +
  7307. ARRAY_SIZE(msm_tavil_fe_dai_links) +
  7308. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  7309. ARRAY_SIZE(msm_tasha_fe_dai_links) +
  7310. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  7311. ARRAY_SIZE(msm_int_compress_capture_dai) +
  7312. ARRAY_SIZE(msm_common_be_dai_links) +
  7313. ARRAY_SIZE(msm_tavil_be_dai_links) +
  7314. ARRAY_SIZE(msm_tasha_be_dai_links) +
  7315. ARRAY_SIZE(msm_wcn_be_dai_links) +
  7316. ARRAY_SIZE(ext_disp_be_dai_link) +
  7317. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  7318. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  7319. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  7320. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)];
  7321. static int msm_snd_card_tavil_late_probe(struct snd_soc_card *card)
  7322. {
  7323. const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
  7324. struct snd_soc_pcm_runtime *rtd;
  7325. struct snd_soc_component *component;
  7326. int ret = 0;
  7327. void *mbhc_calibration;
  7328. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  7329. if (!rtd) {
  7330. dev_err(card->dev,
  7331. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  7332. __func__, be_dl_name);
  7333. ret = -EINVAL;
  7334. goto err_pcm_runtime;
  7335. }
  7336. component = snd_soc_rtdcom_lookup(rtd, "tavil_codec");
  7337. if (!component) {
  7338. pr_err("%s: component is NULL\n", __func__);
  7339. ret = -EINVAL;
  7340. goto err_pcm_runtime;
  7341. }
  7342. mbhc_calibration = def_wcd_mbhc_cal();
  7343. if (!mbhc_calibration) {
  7344. ret = -ENOMEM;
  7345. goto err_mbhc_cal;
  7346. }
  7347. wcd_mbhc_cfg.calibration = mbhc_calibration;
  7348. ret = tavil_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  7349. if (ret) {
  7350. dev_err(card->dev, "%s: mbhc hs detect failed, err:%d\n",
  7351. __func__, ret);
  7352. goto err_hs_detect;
  7353. }
  7354. return 0;
  7355. err_hs_detect:
  7356. kfree(mbhc_calibration);
  7357. err_mbhc_cal:
  7358. err_pcm_runtime:
  7359. return ret;
  7360. }
  7361. static int msm_snd_card_tasha_late_probe(struct snd_soc_card *card)
  7362. {
  7363. const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
  7364. struct snd_soc_pcm_runtime *rtd;
  7365. struct snd_soc_component *component;
  7366. int ret = 0;
  7367. void *mbhc_calibration;
  7368. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  7369. if (!rtd) {
  7370. dev_err(card->dev,
  7371. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  7372. __func__, be_dl_name);
  7373. ret = -EINVAL;
  7374. goto err_pcm_runtime;
  7375. }
  7376. component = snd_soc_rtdcom_lookup(rtd, "tasha_codec");
  7377. if (!component) {
  7378. pr_err("%s: component is NULL\n", __func__);
  7379. ret = -EINVAL;
  7380. goto err_pcm_runtime;
  7381. }
  7382. mbhc_calibration = def_wcd_mbhc_cal();
  7383. if (!mbhc_calibration) {
  7384. ret = -ENOMEM;
  7385. goto err_mbhc_cal;
  7386. }
  7387. wcd_mbhc_cfg.calibration = mbhc_calibration;
  7388. ret = tasha_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  7389. if (ret) {
  7390. dev_err(card->dev, "%s: mbhc hs detect failed, err:%d\n",
  7391. __func__, ret);
  7392. goto err_hs_detect;
  7393. }
  7394. return 0;
  7395. err_hs_detect:
  7396. kfree(mbhc_calibration);
  7397. err_mbhc_cal:
  7398. err_pcm_runtime:
  7399. return ret;
  7400. }
  7401. static int msm_populate_dai_link_component_of_node(
  7402. struct snd_soc_card *card)
  7403. {
  7404. int i, index, ret = 0;
  7405. struct device *cdev = card->dev;
  7406. struct snd_soc_dai_link *dai_link = card->dai_link;
  7407. struct device_node *np;
  7408. if (!cdev) {
  7409. pr_err("%s: Sound card device memory NULL\n", __func__);
  7410. return -ENODEV;
  7411. }
  7412. for (i = 0; i < card->num_links; i++) {
  7413. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  7414. continue;
  7415. /* populate platform_of_node for snd card dai links */
  7416. if (dai_link[i].platform_name &&
  7417. !dai_link[i].platform_of_node) {
  7418. index = of_property_match_string(cdev->of_node,
  7419. "asoc-platform-names",
  7420. dai_link[i].platform_name);
  7421. if (index < 0) {
  7422. pr_err("%s: No match found for platform name: %s\n",
  7423. __func__, dai_link[i].platform_name);
  7424. ret = index;
  7425. goto err;
  7426. }
  7427. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  7428. index);
  7429. if (!np) {
  7430. pr_err("%s: retrieving phandle for platform %s, index %d failed\n",
  7431. __func__, dai_link[i].platform_name,
  7432. index);
  7433. ret = -ENODEV;
  7434. goto err;
  7435. }
  7436. dai_link[i].platform_of_node = np;
  7437. dai_link[i].platform_name = NULL;
  7438. }
  7439. /* populate cpu_of_node for snd card dai links */
  7440. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  7441. index = of_property_match_string(cdev->of_node,
  7442. "asoc-cpu-names",
  7443. dai_link[i].cpu_dai_name);
  7444. if (index >= 0) {
  7445. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  7446. index);
  7447. if (!np) {
  7448. pr_err("%s: retrieving phandle for cpu dai %s failed\n",
  7449. __func__,
  7450. dai_link[i].cpu_dai_name);
  7451. ret = -ENODEV;
  7452. goto err;
  7453. }
  7454. dai_link[i].cpu_of_node = np;
  7455. dai_link[i].cpu_dai_name = NULL;
  7456. }
  7457. }
  7458. /* populate codec_of_node for snd card dai links */
  7459. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  7460. index = of_property_match_string(cdev->of_node,
  7461. "asoc-codec-names",
  7462. dai_link[i].codec_name);
  7463. if (index < 0)
  7464. continue;
  7465. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  7466. index);
  7467. if (!np) {
  7468. pr_err("%s: retrieving phandle for codec %s failed\n",
  7469. __func__, dai_link[i].codec_name);
  7470. ret = -ENODEV;
  7471. goto err;
  7472. }
  7473. dai_link[i].codec_of_node = np;
  7474. dai_link[i].codec_name = NULL;
  7475. }
  7476. }
  7477. err:
  7478. return ret;
  7479. }
  7480. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  7481. {
  7482. int ret = 0;
  7483. struct snd_soc_component *component =
  7484. snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  7485. ret = snd_soc_add_component_controls(component, msm_ext_snd_controls,
  7486. ARRAY_SIZE(msm_ext_snd_controls));
  7487. if (ret < 0) {
  7488. dev_err(component->dev,
  7489. "%s: add_codec_controls failed, err = %d\n",
  7490. __func__, ret);
  7491. return ret;
  7492. }
  7493. return 0;
  7494. }
  7495. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  7496. struct snd_pcm_hw_params *params)
  7497. {
  7498. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  7499. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  7500. int ret = 0;
  7501. unsigned int rx_ch[] = {144, 145, 146, 147, 148, 149, 150,
  7502. 151};
  7503. unsigned int tx_ch[] = {128, 129, 130, 131, 132, 133,
  7504. 134, 135, 136, 137, 138, 139,
  7505. 140, 141, 142, 143};
  7506. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  7507. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  7508. slim_rx_cfg[SLIM_RX_0].channels,
  7509. rx_ch);
  7510. if (ret < 0)
  7511. pr_err("%s: RX failed to set cpu chan map error %d\n",
  7512. __func__, ret);
  7513. } else {
  7514. ret = snd_soc_dai_set_channel_map(cpu_dai,
  7515. slim_tx_cfg[SLIM_TX_0].channels,
  7516. tx_ch, 0, 0);
  7517. if (ret < 0)
  7518. pr_err("%s: TX failed to set cpu chan map error %d\n",
  7519. __func__, ret);
  7520. }
  7521. return ret;
  7522. }
  7523. static struct snd_soc_ops msm_stub_be_ops = {
  7524. .hw_params = msm_snd_stub_hw_params,
  7525. };
  7526. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  7527. /* FrontEnd DAI Links */
  7528. {
  7529. .name = "MSMSTUB Media1",
  7530. .stream_name = "MultiMedia1",
  7531. .cpu_dai_name = "MultiMedia1",
  7532. .platform_name = "msm-pcm-dsp.0",
  7533. .dynamic = 1,
  7534. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  7535. .dpcm_playback = 1,
  7536. .dpcm_capture = 1,
  7537. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  7538. SND_SOC_DPCM_TRIGGER_POST},
  7539. .codec_dai_name = "snd-soc-dummy-dai",
  7540. .codec_name = "snd-soc-dummy",
  7541. .ignore_suspend = 1,
  7542. /* this dainlink has playback support */
  7543. .ignore_pmdown_time = 1,
  7544. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  7545. },
  7546. };
  7547. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  7548. /* Backend DAI Links */
  7549. {
  7550. .name = LPASS_BE_SLIMBUS_0_RX,
  7551. .stream_name = "Slimbus Playback",
  7552. .cpu_dai_name = "msm-dai-q6-dev.16384",
  7553. .platform_name = "msm-pcm-routing",
  7554. .codec_name = "msm-stub-codec.1",
  7555. .codec_dai_name = "msm-stub-rx",
  7556. .no_pcm = 1,
  7557. .dpcm_playback = 1,
  7558. .id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
  7559. .init = &msm_audrx_stub_init,
  7560. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7561. .ignore_pmdown_time = 1, /* dai link has playback support */
  7562. .ignore_suspend = 1,
  7563. .ops = &msm_stub_be_ops,
  7564. },
  7565. {
  7566. .name = LPASS_BE_SLIMBUS_0_TX,
  7567. .stream_name = "Slimbus Capture",
  7568. .cpu_dai_name = "msm-dai-q6-dev.16385",
  7569. .platform_name = "msm-pcm-routing",
  7570. .codec_name = "msm-stub-codec.1",
  7571. .codec_dai_name = "msm-stub-tx",
  7572. .no_pcm = 1,
  7573. .dpcm_capture = 1,
  7574. .id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
  7575. .be_hw_params_fixup = msm_be_hw_params_fixup,
  7576. .ignore_suspend = 1,
  7577. .ops = &msm_stub_be_ops,
  7578. },
  7579. };
  7580. static struct snd_soc_dai_link msm_stub_dai_links[
  7581. ARRAY_SIZE(msm_stub_fe_dai_links) +
  7582. ARRAY_SIZE(msm_stub_be_dai_links)];
  7583. struct snd_soc_card snd_soc_card_stub_msm = {
  7584. .name = "sm6150-stub-snd-card",
  7585. };
  7586. static const struct of_device_id sm6150_asoc_machine_of_match[] = {
  7587. { .compatible = "qcom,sm6150-asoc-snd",
  7588. .data = "codec"},
  7589. { .compatible = "qcom,sm6150-asoc-snd-stub",
  7590. .data = "stub_codec"},
  7591. {},
  7592. };
  7593. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  7594. {
  7595. struct snd_soc_card *card = NULL;
  7596. struct snd_soc_dai_link *dailink;
  7597. int total_links = 0, rc = 0;
  7598. u32 tavil_codec = 0, auxpcm_audio_intf = 0;
  7599. u32 mi2s_audio_intf = 0, ext_disp_audio_intf = 0;
  7600. u32 wcn_btfm_intf = 0;
  7601. const struct of_device_id *match;
  7602. u32 tasha_codec = 0;
  7603. match = of_match_node(sm6150_asoc_machine_of_match, dev->of_node);
  7604. if (!match) {
  7605. dev_err(dev, "%s: No DT match found for sound card\n",
  7606. __func__);
  7607. return NULL;
  7608. }
  7609. if (!strcmp(match->data, "codec")) {
  7610. card = &snd_soc_card_sm6150_msm;
  7611. memcpy(msm_sm6150_dai_links + total_links,
  7612. msm_common_dai_links,
  7613. sizeof(msm_common_dai_links));
  7614. total_links += ARRAY_SIZE(msm_common_dai_links);
  7615. memcpy(msm_sm6150_dai_links + total_links,
  7616. msm_common_misc_fe_dai_links,
  7617. sizeof(msm_common_misc_fe_dai_links));
  7618. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  7619. rc = of_property_read_u32(dev->of_node, "qcom,tavil_codec",
  7620. &tavil_codec);
  7621. if (rc)
  7622. dev_dbg(dev, "%s: No DT match for tavil codec\n",
  7623. __func__);
  7624. rc = of_property_read_u32(dev->of_node, "qcom,tasha_codec",
  7625. &tasha_codec);
  7626. if (rc)
  7627. dev_dbg(dev, "%s: No DT match for tasha codec\n",
  7628. __func__);
  7629. if (tavil_codec) {
  7630. card->late_probe =
  7631. msm_snd_card_tavil_late_probe;
  7632. memcpy(msm_sm6150_dai_links + total_links,
  7633. msm_tavil_fe_dai_links,
  7634. sizeof(msm_tavil_fe_dai_links));
  7635. total_links +=
  7636. ARRAY_SIZE(msm_tavil_fe_dai_links);
  7637. } else if (tasha_codec) {
  7638. card->late_probe =
  7639. msm_snd_card_tasha_late_probe;
  7640. memcpy(msm_sm6150_dai_links + total_links,
  7641. msm_tasha_fe_dai_links,
  7642. sizeof(msm_tasha_fe_dai_links));
  7643. total_links +=
  7644. ARRAY_SIZE(msm_tasha_fe_dai_links);
  7645. } else {
  7646. memcpy(msm_sm6150_dai_links + total_links,
  7647. msm_bolero_fe_dai_links,
  7648. sizeof(msm_bolero_fe_dai_links));
  7649. total_links +=
  7650. ARRAY_SIZE(msm_bolero_fe_dai_links);
  7651. }
  7652. memcpy(msm_sm6150_dai_links + total_links,
  7653. msm_int_compress_capture_dai,
  7654. sizeof(msm_int_compress_capture_dai));
  7655. total_links += ARRAY_SIZE(msm_int_compress_capture_dai);
  7656. memcpy(msm_sm6150_dai_links + total_links,
  7657. msm_common_be_dai_links,
  7658. sizeof(msm_common_be_dai_links));
  7659. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  7660. if (tavil_codec) {
  7661. memcpy(msm_sm6150_dai_links + total_links,
  7662. msm_tavil_be_dai_links,
  7663. sizeof(msm_tavil_be_dai_links));
  7664. total_links += ARRAY_SIZE(msm_tavil_be_dai_links);
  7665. } else if (tasha_codec) {
  7666. memcpy(msm_sm6150_dai_links + total_links,
  7667. msm_tasha_be_dai_links,
  7668. sizeof(msm_tasha_be_dai_links));
  7669. total_links += ARRAY_SIZE(msm_tasha_be_dai_links);
  7670. } else {
  7671. memcpy(msm_sm6150_dai_links + total_links,
  7672. msm_wsa_cdc_dma_be_dai_links,
  7673. sizeof(msm_wsa_cdc_dma_be_dai_links));
  7674. total_links +=
  7675. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  7676. memcpy(msm_sm6150_dai_links + total_links,
  7677. msm_rx_tx_cdc_dma_be_dai_links,
  7678. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  7679. total_links +=
  7680. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  7681. }
  7682. rc = of_property_read_u32(dev->of_node,
  7683. "qcom,ext-disp-audio-rx",
  7684. &ext_disp_audio_intf);
  7685. if (rc) {
  7686. dev_dbg(dev, "%s: No DT match Ext Disp interface\n",
  7687. __func__);
  7688. } else {
  7689. if (ext_disp_audio_intf) {
  7690. memcpy(msm_sm6150_dai_links + total_links,
  7691. ext_disp_be_dai_link,
  7692. sizeof(ext_disp_be_dai_link));
  7693. total_links +=
  7694. ARRAY_SIZE(ext_disp_be_dai_link);
  7695. }
  7696. }
  7697. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  7698. &mi2s_audio_intf);
  7699. if (rc) {
  7700. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  7701. __func__);
  7702. } else {
  7703. if (mi2s_audio_intf) {
  7704. memcpy(msm_sm6150_dai_links + total_links,
  7705. msm_mi2s_be_dai_links,
  7706. sizeof(msm_mi2s_be_dai_links));
  7707. total_links +=
  7708. ARRAY_SIZE(msm_mi2s_be_dai_links);
  7709. }
  7710. }
  7711. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  7712. &wcn_btfm_intf);
  7713. if (rc) {
  7714. dev_dbg(dev, "%s: No DT match wcn btfm interface\n",
  7715. __func__);
  7716. } else {
  7717. if (wcn_btfm_intf) {
  7718. memcpy(msm_sm6150_dai_links + total_links,
  7719. msm_wcn_be_dai_links,
  7720. sizeof(msm_wcn_be_dai_links));
  7721. total_links +=
  7722. ARRAY_SIZE(msm_wcn_be_dai_links);
  7723. }
  7724. }
  7725. rc = of_property_read_u32(dev->of_node,
  7726. "qcom,auxpcm-audio-intf",
  7727. &auxpcm_audio_intf);
  7728. if (rc) {
  7729. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  7730. __func__);
  7731. } else {
  7732. if (auxpcm_audio_intf) {
  7733. memcpy(msm_sm6150_dai_links + total_links,
  7734. msm_auxpcm_be_dai_links,
  7735. sizeof(msm_auxpcm_be_dai_links));
  7736. total_links +=
  7737. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  7738. }
  7739. }
  7740. dailink = msm_sm6150_dai_links;
  7741. } else if (!strcmp(match->data, "stub_codec")) {
  7742. card = &snd_soc_card_stub_msm;
  7743. memcpy(msm_stub_dai_links + total_links,
  7744. msm_stub_fe_dai_links,
  7745. sizeof(msm_stub_fe_dai_links));
  7746. total_links += ARRAY_SIZE(msm_stub_fe_dai_links);
  7747. memcpy(msm_stub_dai_links + total_links,
  7748. msm_stub_be_dai_links,
  7749. sizeof(msm_stub_be_dai_links));
  7750. total_links += ARRAY_SIZE(msm_stub_be_dai_links);
  7751. dailink = msm_stub_dai_links;
  7752. }
  7753. if (card) {
  7754. card->dai_link = dailink;
  7755. card->num_links = total_links;
  7756. }
  7757. return card;
  7758. }
  7759. static int msm_wsa881x_init(struct snd_soc_component *component)
  7760. {
  7761. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  7762. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  7763. u8 spkleft_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  7764. SPKR_L_BOOST, SPKR_L_VI};
  7765. u8 spkright_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  7766. SPKR_R_BOOST, SPKR_R_VI};
  7767. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  7768. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  7769. struct msm_asoc_mach_data *pdata;
  7770. struct snd_soc_dapm_context *dapm;
  7771. struct snd_card *card = component->card->snd_card;
  7772. struct snd_info_entry *entry;
  7773. int ret = 0;
  7774. if (!component) {
  7775. pr_err("%s codec is NULL\n", __func__);
  7776. return -EINVAL;
  7777. }
  7778. dapm = snd_soc_component_get_dapm(component);
  7779. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  7780. dev_dbg(component->dev, "%s: setting left ch map to codec %s\n",
  7781. __func__, component->name);
  7782. wsa881x_set_channel_map(component, &spkleft_ports[0],
  7783. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  7784. &ch_rate[0], &spkleft_port_types[0]);
  7785. if (dapm->component) {
  7786. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  7787. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  7788. }
  7789. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  7790. dev_dbg(component->dev, "%s: setting right ch map to codec %s\n",
  7791. __func__, component->name);
  7792. wsa881x_set_channel_map(component, &spkright_ports[0],
  7793. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  7794. &ch_rate[0], &spkright_port_types[0]);
  7795. if (dapm->component) {
  7796. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  7797. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  7798. }
  7799. } else {
  7800. dev_err(component->dev, "%s: wrong codec name %s\n", __func__,
  7801. component->name);
  7802. ret = -EINVAL;
  7803. goto err;
  7804. }
  7805. pdata = snd_soc_card_get_drvdata(component->card);
  7806. if (!pdata->codec_root) {
  7807. entry = snd_info_create_subdir(card->module, "codecs",
  7808. card->proc_root);
  7809. if (!entry) {
  7810. pr_err("%s: Cannot create codecs module entry\n",
  7811. __func__);
  7812. ret = 0;
  7813. goto err;
  7814. }
  7815. pdata->codec_root = entry;
  7816. }
  7817. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  7818. component);
  7819. err:
  7820. return ret;
  7821. }
  7822. static int msm_aux_codec_init(struct snd_soc_component *component)
  7823. {
  7824. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  7825. int ret = 0;
  7826. void *mbhc_calibration;
  7827. struct snd_info_entry *entry;
  7828. struct snd_card *card = component->card->snd_card;
  7829. struct msm_asoc_mach_data *pdata;
  7830. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  7831. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  7832. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  7833. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  7834. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  7835. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  7836. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  7837. snd_soc_dapm_sync(dapm);
  7838. pdata = snd_soc_card_get_drvdata(component->card);
  7839. if (!pdata->codec_root) {
  7840. entry = snd_info_create_subdir(card->module, "codecs",
  7841. card->proc_root);
  7842. if (!entry) {
  7843. pr_err("%s: Cannot create codecs module entry\n",
  7844. __func__);
  7845. ret = 0;
  7846. goto codec_root_err;
  7847. }
  7848. pdata->codec_root = entry;
  7849. }
  7850. wcd937x_info_create_codec_entry(pdata->codec_root, component);
  7851. codec_root_err:
  7852. mbhc_calibration = def_wcd_mbhc_cal();
  7853. if (!mbhc_calibration) {
  7854. return -ENOMEM;
  7855. }
  7856. wcd_mbhc_cfg.calibration = mbhc_calibration;
  7857. ret = wcd937x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  7858. return ret;
  7859. }
  7860. static int msm_init_aux_dev(struct platform_device *pdev,
  7861. struct snd_soc_card *card)
  7862. {
  7863. struct device_node *wsa_of_node;
  7864. struct device_node *aux_codec_of_node;
  7865. u32 wsa_max_devs;
  7866. u32 wsa_dev_cnt;
  7867. u32 codec_max_aux_devs = 0;
  7868. u32 codec_aux_dev_cnt = 0;
  7869. int i;
  7870. struct msm_wsa881x_dev_info *wsa881x_dev_info = NULL;
  7871. struct aux_codec_dev_info *aux_cdc_dev_info = NULL;
  7872. const char *auxdev_name_prefix[1];
  7873. char *dev_name_str = NULL;
  7874. int found = 0;
  7875. int codecs_found = 0;
  7876. int ret = 0;
  7877. /* Get maximum WSA device count for this platform */
  7878. ret = of_property_read_u32(pdev->dev.of_node,
  7879. "qcom,wsa-max-devs", &wsa_max_devs);
  7880. if (ret) {
  7881. dev_err(&pdev->dev,
  7882. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  7883. __func__, pdev->dev.of_node->full_name, ret);
  7884. wsa_max_devs = 0;
  7885. goto codec_aux_dev;
  7886. }
  7887. if (wsa_max_devs == 0) {
  7888. dev_dbg(&pdev->dev,
  7889. "%s: Max WSA devices is 0 for this target?\n",
  7890. __func__);
  7891. goto codec_aux_dev;
  7892. }
  7893. /* Get count of WSA device phandles for this platform */
  7894. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  7895. "qcom,wsa-devs", NULL);
  7896. if (wsa_dev_cnt == -ENOENT) {
  7897. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  7898. __func__);
  7899. goto err;
  7900. } else if (wsa_dev_cnt <= 0) {
  7901. dev_err(&pdev->dev,
  7902. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  7903. __func__, wsa_dev_cnt);
  7904. ret = -EINVAL;
  7905. goto err;
  7906. }
  7907. /*
  7908. * Expect total phandles count to be NOT less than maximum possible
  7909. * WSA count. However, if it is less, then assign same value to
  7910. * max count as well.
  7911. */
  7912. if (wsa_dev_cnt < wsa_max_devs) {
  7913. dev_dbg(&pdev->dev,
  7914. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  7915. __func__, wsa_max_devs, wsa_dev_cnt);
  7916. wsa_max_devs = wsa_dev_cnt;
  7917. }
  7918. /* Make sure prefix string passed for each WSA device */
  7919. ret = of_property_count_strings(pdev->dev.of_node,
  7920. "qcom,wsa-aux-dev-prefix");
  7921. if (ret != wsa_dev_cnt) {
  7922. dev_err(&pdev->dev,
  7923. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  7924. __func__, wsa_dev_cnt, ret);
  7925. ret = -EINVAL;
  7926. goto err;
  7927. }
  7928. /*
  7929. * Alloc mem to store phandle and index info of WSA device, if already
  7930. * registered with ALSA core
  7931. */
  7932. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  7933. sizeof(struct msm_wsa881x_dev_info),
  7934. GFP_KERNEL);
  7935. if (!wsa881x_dev_info) {
  7936. ret = -ENOMEM;
  7937. goto err;
  7938. }
  7939. /*
  7940. * search and check whether all WSA devices are already
  7941. * registered with ALSA core or not. If found a node, store
  7942. * the node and the index in a local array of struct for later
  7943. * use.
  7944. */
  7945. for (i = 0; i < wsa_dev_cnt; i++) {
  7946. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  7947. "qcom,wsa-devs", i);
  7948. if (unlikely(!wsa_of_node)) {
  7949. /* we should not be here */
  7950. dev_err(&pdev->dev,
  7951. "%s: wsa dev node is not present\n",
  7952. __func__);
  7953. ret = -EINVAL;
  7954. goto err;
  7955. }
  7956. if (soc_find_component_locked(wsa_of_node, NULL)) {
  7957. /* WSA device registered with ALSA core */
  7958. wsa881x_dev_info[found].of_node = wsa_of_node;
  7959. wsa881x_dev_info[found].index = i;
  7960. found++;
  7961. if (found == wsa_max_devs)
  7962. break;
  7963. }
  7964. }
  7965. if (found < wsa_max_devs) {
  7966. dev_dbg(&pdev->dev,
  7967. "%s: failed to find %d components. Found only %d\n",
  7968. __func__, wsa_max_devs, found);
  7969. return -EPROBE_DEFER;
  7970. }
  7971. dev_info(&pdev->dev,
  7972. "%s: found %d wsa881x devices registered with ALSA core\n",
  7973. __func__, found);
  7974. codec_aux_dev:
  7975. if (!strnstr(card->name, "tavil", strlen(card->name)) &&
  7976. !strnstr(card->name, "tasha", strlen(card->name))) {
  7977. /* Get maximum aux codec device count for this platform */
  7978. ret = of_property_read_u32(pdev->dev.of_node,
  7979. "qcom,codec-max-aux-devs",
  7980. &codec_max_aux_devs);
  7981. if (ret) {
  7982. dev_err(&pdev->dev,
  7983. "%s: codec-max-aux-devs property missing in DT %s, ret = %d\n",
  7984. __func__, pdev->dev.of_node->full_name, ret);
  7985. codec_max_aux_devs = 0;
  7986. goto aux_dev_register;
  7987. }
  7988. if (codec_max_aux_devs == 0) {
  7989. dev_dbg(&pdev->dev,
  7990. "%s: Max aux codec devices is 0 for this target?\n",
  7991. __func__);
  7992. goto aux_dev_register;
  7993. }
  7994. /* Get count of aux codec device phandles for this platform */
  7995. codec_aux_dev_cnt = of_count_phandle_with_args(
  7996. pdev->dev.of_node,
  7997. "qcom,codec-aux-devs", NULL);
  7998. if (codec_aux_dev_cnt == -ENOENT) {
  7999. dev_warn(&pdev->dev, "%s: No aux codec defined in DT.\n",
  8000. __func__);
  8001. goto err;
  8002. } else if (codec_aux_dev_cnt <= 0) {
  8003. dev_err(&pdev->dev,
  8004. "%s: Error reading aux codec device from DT, dev_cnt=%d\n",
  8005. __func__, codec_aux_dev_cnt);
  8006. ret = -EINVAL;
  8007. goto err;
  8008. }
  8009. /*
  8010. * Expect total phandles count to be NOT less than maximum possible
  8011. * AUX device count. However, if it is less, then assign same value to
  8012. * max count as well.
  8013. */
  8014. if (codec_aux_dev_cnt < codec_max_aux_devs) {
  8015. dev_dbg(&pdev->dev,
  8016. "%s: codec_max_aux_devs = %d cannot exceed codec_aux_dev_cnt = %d\n",
  8017. __func__, codec_max_aux_devs,
  8018. codec_aux_dev_cnt);
  8019. codec_max_aux_devs = codec_aux_dev_cnt;
  8020. }
  8021. /*
  8022. * Alloc mem to store phandle and index info of aux codec
  8023. * if already registered with ALSA core
  8024. */
  8025. aux_cdc_dev_info = devm_kcalloc(&pdev->dev, codec_max_aux_devs,
  8026. sizeof(struct aux_codec_dev_info),
  8027. GFP_KERNEL);
  8028. if (!aux_cdc_dev_info) {
  8029. ret = -ENOMEM;
  8030. goto err;
  8031. }
  8032. /*
  8033. * search and check whether all aux codecs are already
  8034. * registered with ALSA core or not. If found a node, store
  8035. * the node and the index in a local array of struct for later
  8036. * use.
  8037. */
  8038. for (i = 0; i < codec_aux_dev_cnt; i++) {
  8039. aux_codec_of_node = of_parse_phandle(pdev->dev.of_node,
  8040. "qcom,codec-aux-devs", i);
  8041. if (unlikely(!aux_codec_of_node)) {
  8042. /* we should not be here */
  8043. dev_err(&pdev->dev,
  8044. "%s: aux codec dev node is not present\n",
  8045. __func__);
  8046. ret = -EINVAL;
  8047. goto err;
  8048. }
  8049. if (soc_find_component_locked(aux_codec_of_node, NULL)) {
  8050. /* AUX codec registered with ALSA core */
  8051. aux_cdc_dev_info[codecs_found].of_node =
  8052. aux_codec_of_node;
  8053. aux_cdc_dev_info[codecs_found].index = i;
  8054. codecs_found++;
  8055. }
  8056. }
  8057. if (codecs_found < codec_max_aux_devs) {
  8058. dev_dbg(&pdev->dev,
  8059. "%s: failed to find %d components. Found only %d\n",
  8060. __func__, codec_max_aux_devs, codecs_found);
  8061. return -EPROBE_DEFER;
  8062. }
  8063. dev_info(&pdev->dev,
  8064. "%s: found %d AUX codecs registered with ALSA core\n",
  8065. __func__, codecs_found);
  8066. }
  8067. aux_dev_register:
  8068. card->num_aux_devs = wsa_max_devs + codec_max_aux_devs;
  8069. card->num_configs = wsa_max_devs + codec_max_aux_devs;
  8070. /* Alloc array of AUX devs struct */
  8071. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  8072. sizeof(struct snd_soc_aux_dev),
  8073. GFP_KERNEL);
  8074. if (!msm_aux_dev) {
  8075. ret = -ENOMEM;
  8076. goto err;
  8077. }
  8078. /* Alloc array of codec conf struct */
  8079. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_configs,
  8080. sizeof(struct snd_soc_codec_conf),
  8081. GFP_KERNEL);
  8082. if (!msm_codec_conf) {
  8083. ret = -ENOMEM;
  8084. goto err;
  8085. }
  8086. for (i = 0; i < wsa_max_devs; i++) {
  8087. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  8088. GFP_KERNEL);
  8089. if (!dev_name_str) {
  8090. ret = -ENOMEM;
  8091. goto err;
  8092. }
  8093. ret = of_property_read_string_index(pdev->dev.of_node,
  8094. "qcom,wsa-aux-dev-prefix",
  8095. wsa881x_dev_info[i].index,
  8096. auxdev_name_prefix);
  8097. if (ret) {
  8098. dev_err(&pdev->dev,
  8099. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  8100. __func__, ret);
  8101. ret = -EINVAL;
  8102. goto err;
  8103. }
  8104. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  8105. msm_aux_dev[i].name = dev_name_str;
  8106. msm_aux_dev[i].codec_name = NULL;
  8107. msm_aux_dev[i].codec_of_node =
  8108. wsa881x_dev_info[i].of_node;
  8109. msm_aux_dev[i].init = msm_wsa881x_init;
  8110. msm_codec_conf[i].dev_name = NULL;
  8111. msm_codec_conf[i].name_prefix = auxdev_name_prefix[0];
  8112. msm_codec_conf[i].of_node =
  8113. wsa881x_dev_info[i].of_node;
  8114. }
  8115. for (i = 0; i < codec_aux_dev_cnt; i++) {
  8116. msm_aux_dev[wsa_max_devs + i].name = "aux_codec";
  8117. msm_aux_dev[wsa_max_devs + i].codec_name = NULL;
  8118. msm_aux_dev[wsa_max_devs + i].codec_of_node =
  8119. aux_cdc_dev_info[i].of_node;
  8120. msm_aux_dev[wsa_max_devs + i].init = msm_aux_codec_init;
  8121. msm_codec_conf[wsa_max_devs + i].dev_name = NULL;
  8122. msm_codec_conf[wsa_max_devs + i].name_prefix =
  8123. NULL;
  8124. msm_codec_conf[wsa_max_devs + i].of_node =
  8125. aux_cdc_dev_info[i].of_node;
  8126. }
  8127. card->codec_conf = msm_codec_conf;
  8128. card->aux_dev = msm_aux_dev;
  8129. err:
  8130. return ret;
  8131. }
  8132. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  8133. {
  8134. int count;
  8135. u32 mi2s_master_slave[MI2S_MAX];
  8136. u32 mi2s_ext_mclk[MI2S_MAX];
  8137. int ret;
  8138. for (count = 0; count < MI2S_MAX; count++) {
  8139. mutex_init(&mi2s_intf_conf[count].lock);
  8140. mi2s_intf_conf[count].ref_cnt = 0;
  8141. }
  8142. ret = of_property_read_u32_array(pdev->dev.of_node,
  8143. "qcom,msm-mi2s-master",
  8144. mi2s_master_slave, MI2S_MAX);
  8145. if (ret) {
  8146. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  8147. __func__);
  8148. } else {
  8149. for (count = 0; count < MI2S_MAX; count++) {
  8150. mi2s_intf_conf[count].msm_is_mi2s_master =
  8151. mi2s_master_slave[count];
  8152. }
  8153. }
  8154. ret = of_property_read_u32_array(pdev->dev.of_node,
  8155. "qcom,msm-mi2s-ext-mclk",
  8156. mi2s_ext_mclk, MI2S_MAX);
  8157. if (ret) {
  8158. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-ext-mclk in DT node\n",
  8159. __func__);
  8160. } else {
  8161. for (count = 0; count < MI2S_MAX; count++)
  8162. mi2s_intf_conf[count].msm_is_ext_mclk =
  8163. mi2s_ext_mclk[count];
  8164. }
  8165. }
  8166. static void msm_i2s_auxpcm_deinit(void)
  8167. {
  8168. int count;
  8169. for (count = 0; count < MI2S_MAX; count++) {
  8170. mutex_destroy(&mi2s_intf_conf[count].lock);
  8171. mi2s_intf_conf[count].ref_cnt = 0;
  8172. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  8173. mi2s_intf_conf[count].msm_is_ext_mclk = 0;
  8174. }
  8175. }
  8176. static int sm6150_ssr_enable(struct device *dev, void *data)
  8177. {
  8178. struct platform_device *pdev = to_platform_device(dev);
  8179. struct snd_soc_card *card = platform_get_drvdata(pdev);
  8180. struct msm_asoc_mach_data *pdata = NULL;
  8181. struct snd_soc_component *component = NULL;
  8182. int ret = 0;
  8183. if (!card) {
  8184. dev_err(dev, "%s: card is NULL\n", __func__);
  8185. ret = -EINVAL;
  8186. goto err;
  8187. }
  8188. if (strnstr(card->name, "tavil", strlen(card->name)) ||
  8189. strnstr(card->name, "tasha", strlen(card->name))) {
  8190. pdata = snd_soc_card_get_drvdata(card);
  8191. if (!pdata->is_afe_config_done) {
  8192. const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
  8193. struct snd_soc_pcm_runtime *rtd;
  8194. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  8195. if (!rtd) {
  8196. dev_err(dev,
  8197. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  8198. __func__, be_dl_name);
  8199. ret = -EINVAL;
  8200. goto err;
  8201. }
  8202. component = snd_soc_rtdcom_lookup(rtd, "tavil_codec");
  8203. if (!component) {
  8204. dev_err(dev, "%s: component is NULL\n",
  8205. __func__);
  8206. ret = -EINVAL;
  8207. goto err;
  8208. }
  8209. ret = msm_afe_set_config(component);
  8210. if (ret)
  8211. dev_err(dev, "%s: Failed to set AFE config. err %d\n",
  8212. __func__, ret);
  8213. else
  8214. pdata->is_afe_config_done = true;
  8215. }
  8216. }
  8217. snd_soc_card_change_online_state(card, 1);
  8218. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  8219. err:
  8220. return ret;
  8221. }
  8222. static void sm6150_ssr_disable(struct device *dev, void *data)
  8223. {
  8224. struct platform_device *pdev = to_platform_device(dev);
  8225. struct snd_soc_card *card = platform_get_drvdata(pdev);
  8226. struct msm_asoc_mach_data *pdata;
  8227. if (!card) {
  8228. dev_err(dev, "%s: card is NULL\n", __func__);
  8229. return;
  8230. }
  8231. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  8232. snd_soc_card_change_online_state(card, 0);
  8233. if (strnstr(card->name, "tavil", strlen(card->name)) ||
  8234. strnstr(card->name, "tasha", strlen(card->name))) {
  8235. pdata = snd_soc_card_get_drvdata(card);
  8236. msm_afe_clear_config();
  8237. pdata->is_afe_config_done = false;
  8238. }
  8239. }
  8240. static int msm_ext_prepare_hifi(struct msm_asoc_mach_data *pdata)
  8241. {
  8242. int ret = 0;
  8243. if (gpio_is_valid(pdata->hph_en1_gpio)) {
  8244. pr_debug("%s: hph_en1_gpio request %d\n", __func__,
  8245. pdata->hph_en1_gpio);
  8246. ret = gpio_request(pdata->hph_en1_gpio, "hph_en1_gpio");
  8247. if (ret) {
  8248. pr_err("%s: hph_en1_gpio request failed, ret:%d\n",
  8249. __func__, ret);
  8250. goto err;
  8251. }
  8252. }
  8253. if (gpio_is_valid(pdata->hph_en0_gpio)) {
  8254. pr_debug("%s: hph_en0_gpio request %d\n", __func__,
  8255. pdata->hph_en0_gpio);
  8256. ret = gpio_request(pdata->hph_en0_gpio, "hph_en0_gpio");
  8257. if (ret)
  8258. pr_err("%s: hph_en0_gpio request failed, ret:%d\n",
  8259. __func__, ret);
  8260. }
  8261. err:
  8262. return ret;
  8263. }
  8264. static const struct snd_event_ops sm6150_ssr_ops = {
  8265. .enable = sm6150_ssr_enable,
  8266. .disable = sm6150_ssr_disable,
  8267. };
  8268. static int msm_audio_ssr_compare(struct device *dev, void *data)
  8269. {
  8270. struct device_node *node = data;
  8271. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  8272. __func__, dev->of_node, node);
  8273. return (dev->of_node && dev->of_node == node);
  8274. }
  8275. static int msm_audio_ssr_register(struct device *dev)
  8276. {
  8277. struct device_node *np = dev->of_node;
  8278. struct snd_event_clients *ssr_clients = NULL;
  8279. struct device_node *node;
  8280. int ret;
  8281. int i;
  8282. for (i = 0; ; i++) {
  8283. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  8284. if (!node)
  8285. break;
  8286. snd_event_mstr_add_client(&ssr_clients,
  8287. msm_audio_ssr_compare, node);
  8288. }
  8289. ret = snd_event_master_register(dev, &sm6150_ssr_ops,
  8290. ssr_clients, NULL);
  8291. if (!ret)
  8292. snd_event_notify(dev, SND_EVENT_UP);
  8293. return ret;
  8294. }
  8295. static int msm_asoc_machine_probe(struct platform_device *pdev)
  8296. {
  8297. struct snd_soc_card *card;
  8298. struct msm_asoc_mach_data *pdata;
  8299. const char *mbhc_audio_jack_type = NULL;
  8300. int ret;
  8301. if (!pdev->dev.of_node) {
  8302. dev_err(&pdev->dev, "No platform supplied from device tree\n");
  8303. return -EINVAL;
  8304. }
  8305. pdata = devm_kzalloc(&pdev->dev,
  8306. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  8307. if (!pdata)
  8308. return -ENOMEM;
  8309. card = populate_snd_card_dailinks(&pdev->dev);
  8310. if (!card) {
  8311. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  8312. ret = -EINVAL;
  8313. goto err;
  8314. }
  8315. card->dev = &pdev->dev;
  8316. platform_set_drvdata(pdev, card);
  8317. snd_soc_card_set_drvdata(card, pdata);
  8318. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  8319. if (ret) {
  8320. dev_err(&pdev->dev, "parse card name failed, err:%d\n",
  8321. ret);
  8322. goto err;
  8323. }
  8324. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  8325. if (ret) {
  8326. dev_err(&pdev->dev, "parse audio routing failed, err:%d\n",
  8327. ret);
  8328. goto err;
  8329. }
  8330. ret = msm_populate_dai_link_component_of_node(card);
  8331. if (ret) {
  8332. ret = -EPROBE_DEFER;
  8333. goto err;
  8334. }
  8335. ret = msm_init_aux_dev(pdev, card);
  8336. if (ret)
  8337. goto err;
  8338. ret = devm_snd_soc_register_card(&pdev->dev, card);
  8339. if (ret == -EPROBE_DEFER) {
  8340. if (codec_reg_done)
  8341. ret = -EINVAL;
  8342. goto err;
  8343. } else if (ret) {
  8344. dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
  8345. ret);
  8346. goto err;
  8347. }
  8348. dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
  8349. pdata->hph_en1_gpio = of_get_named_gpio(pdev->dev.of_node,
  8350. "qcom,hph-en1-gpio", 0);
  8351. if (!gpio_is_valid(pdata->hph_en1_gpio))
  8352. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8353. "qcom,hph-en1-gpio", 0);
  8354. if (!gpio_is_valid(pdata->hph_en1_gpio) && (!pdata->hph_en1_gpio_p)) {
  8355. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  8356. "qcom,hph-en1-gpio", pdev->dev.of_node->full_name);
  8357. }
  8358. pdata->hph_en0_gpio = of_get_named_gpio(pdev->dev.of_node,
  8359. "qcom,hph-en0-gpio", 0);
  8360. if (!gpio_is_valid(pdata->hph_en0_gpio))
  8361. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8362. "qcom,hph-en0-gpio", 0);
  8363. if (!gpio_is_valid(pdata->hph_en0_gpio) && (!pdata->hph_en0_gpio_p)) {
  8364. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  8365. "qcom,hph-en0-gpio", pdev->dev.of_node->full_name);
  8366. }
  8367. ret = msm_ext_prepare_hifi(pdata);
  8368. if (ret) {
  8369. dev_dbg(&pdev->dev, "msm_ext_prepare_hifi failed (%d)\n",
  8370. ret);
  8371. ret = 0;
  8372. }
  8373. ret = of_property_read_string(pdev->dev.of_node,
  8374. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  8375. if (ret) {
  8376. dev_dbg(&pdev->dev, "Looking up %s property in node %s failed\n",
  8377. "qcom,mbhc-audio-jack-type",
  8378. pdev->dev.of_node->full_name);
  8379. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  8380. ret = 0;
  8381. } else {
  8382. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  8383. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  8384. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  8385. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  8386. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  8387. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  8388. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  8389. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  8390. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  8391. } else {
  8392. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  8393. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  8394. }
  8395. }
  8396. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8397. "qcom,pri-mi2s-gpios", 0);
  8398. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8399. "qcom,sec-mi2s-gpios", 0);
  8400. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8401. "qcom,tert-mi2s-gpios", 0);
  8402. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8403. "qcom,quat-mi2s-gpios", 0);
  8404. pdata->mi2s_gpio_p[QUIN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  8405. "qcom,quin-mi2s-gpios", 0);
  8406. /*
  8407. * Parse US-Euro gpio info from DT. Report no error if us-euro
  8408. * entry is not found in DT file as some targets do not support
  8409. * US-Euro detection
  8410. */
  8411. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8412. "qcom,us-euro-gpios", 0);
  8413. if (!pdata->us_euro_gpio_p) {
  8414. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  8415. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  8416. } else {
  8417. dev_dbg(&pdev->dev, "%s detected\n",
  8418. "qcom,us-euro-gpios");
  8419. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  8420. }
  8421. if (wcd_mbhc_cfg.enable_usbc_analog) {
  8422. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  8423. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  8424. "fsa4480-i2c-handle", 0);
  8425. if (!pdata->fsa_handle)
  8426. dev_err(&pdev->dev,
  8427. "property %s not detected in node %s\n",
  8428. "fsa4480-i2c-handle",
  8429. pdev->dev.of_node->full_name);
  8430. }
  8431. msm_i2s_auxpcm_init(pdev);
  8432. if (!strnstr(card->name, "tavil", strlen(card->name)) &&
  8433. !strnstr(card->name, "tasha", strlen(card->name))) {
  8434. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8435. "qcom,cdc-dmic01-gpios",
  8436. 0);
  8437. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  8438. "qcom,cdc-dmic23-gpios",
  8439. 0);
  8440. }
  8441. ret = msm_audio_ssr_register(&pdev->dev);
  8442. if (ret)
  8443. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  8444. __func__, ret);
  8445. err:
  8446. return ret;
  8447. }
  8448. static int msm_asoc_machine_remove(struct platform_device *pdev)
  8449. {
  8450. snd_event_master_deregister(&pdev->dev);
  8451. msm_i2s_auxpcm_deinit();
  8452. return 0;
  8453. }
  8454. static struct platform_driver sm6150_asoc_machine_driver = {
  8455. .driver = {
  8456. .name = DRV_NAME,
  8457. .owner = THIS_MODULE,
  8458. .pm = &snd_soc_pm_ops,
  8459. .of_match_table = sm6150_asoc_machine_of_match,
  8460. .suppress_bind_attrs = true,
  8461. },
  8462. .probe = msm_asoc_machine_probe,
  8463. .remove = msm_asoc_machine_remove,
  8464. };
  8465. module_platform_driver(sm6150_asoc_machine_driver);
  8466. MODULE_DESCRIPTION("ALSA SoC SM6150 Machine driver");
  8467. MODULE_LICENSE("GPL v2");
  8468. MODULE_ALIAS("platform:" DRV_NAME);
  8469. MODULE_DEVICE_TABLE(of, sm6150_asoc_machine_of_match);