msm-dai-q6-v2.c 379 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
  3. */
  4. #include <linux/init.h>
  5. #include <linux/module.h>
  6. #include <linux/device.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/bitops.h>
  9. #include <linux/slab.h>
  10. #include <linux/clk.h>
  11. #include <linux/of_device.h>
  12. #include <sound/core.h>
  13. #include <sound/pcm.h>
  14. #include <sound/soc.h>
  15. #include <sound/pcm_params.h>
  16. #include <dsp/apr_audio-v2.h>
  17. #include <dsp/q6afe-v2.h>
  18. #include <dsp/sp_params.h>
  19. #include <dsp/q6core.h>
  20. #include "msm-dai-q6-v2.h"
  21. #include <asoc/core.h>
  22. #define MSM_DAI_PRI_AUXPCM_DT_DEV_ID 1
  23. #define MSM_DAI_SEC_AUXPCM_DT_DEV_ID 2
  24. #define MSM_DAI_TERT_AUXPCM_DT_DEV_ID 3
  25. #define MSM_DAI_QUAT_AUXPCM_DT_DEV_ID 4
  26. #define MSM_DAI_QUIN_AUXPCM_DT_DEV_ID 5
  27. #define MSM_DAI_SEN_AUXPCM_DT_DEV_ID 6
  28. #define MSM_DAI_TWS_CHANNEL_MODE_ONE 1
  29. #define MSM_DAI_TWS_CHANNEL_MODE_TWO 2
  30. #define spdif_clock_value(rate) (2*rate*32*2)
  31. #define CHANNEL_STATUS_SIZE 24
  32. #define CHANNEL_STATUS_MASK_INIT 0x0
  33. #define CHANNEL_STATUS_MASK 0x4
  34. #define PREEMPH_MASK 0x38
  35. #define PREEMPH_SHIFT 3
  36. #define GET_PREEMPH(b) ((b & PREEMPH_MASK) >> PREEMPH_SHIFT)
  37. #define AFE_API_VERSION_CLOCK_SET 1
  38. #define MSM_DAI_SYSFS_ENTRY_MAX_LEN 64
  39. #define DAI_FORMATS_S16_S24_S32_LE (SNDRV_PCM_FMTBIT_S16_LE | \
  40. SNDRV_PCM_FMTBIT_S24_LE | \
  41. SNDRV_PCM_FMTBIT_S32_LE)
  42. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id);
  43. enum {
  44. ENC_FMT_NONE,
  45. DEC_FMT_NONE = ENC_FMT_NONE,
  46. ENC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  47. DEC_FMT_SBC = ASM_MEDIA_FMT_SBC,
  48. ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  49. DEC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  50. ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
  51. ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
  52. ENC_FMT_CELT = ASM_MEDIA_FMT_CELT,
  53. ENC_FMT_LDAC = ASM_MEDIA_FMT_LDAC,
  54. ENC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  55. DEC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  56. DEC_FMT_MP3 = ASM_MEDIA_FMT_MP3,
  57. ENC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
  58. DEC_FMT_APTX_AD_SPEECH = ASM_MEDIA_FMT_APTX_AD_SPEECH,
  59. };
  60. enum {
  61. SPKR_1,
  62. SPKR_2,
  63. };
  64. static const struct afe_clk_set lpass_clk_set_default = {
  65. AFE_API_VERSION_CLOCK_SET,
  66. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
  67. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  68. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  69. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  70. 0,
  71. };
  72. static const struct afe_clk_cfg lpass_clk_cfg_default = {
  73. AFE_API_VERSION_I2S_CONFIG,
  74. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  75. 0,
  76. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  77. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  78. Q6AFE_LPASS_MODE_CLK1_VALID,
  79. 0,
  80. };
  81. enum {
  82. STATUS_PORT_STARTED, /* track if AFE port has started */
  83. /* track AFE Tx port status for bi-directional transfers */
  84. STATUS_TX_PORT,
  85. /* track AFE Rx port status for bi-directional transfers */
  86. STATUS_RX_PORT,
  87. STATUS_MAX
  88. };
  89. enum {
  90. RATE_8KHZ,
  91. RATE_16KHZ,
  92. RATE_MAX_NUM_OF_AUX_PCM_RATES,
  93. };
  94. enum {
  95. IDX_PRIMARY_TDM_RX_0,
  96. IDX_PRIMARY_TDM_RX_1,
  97. IDX_PRIMARY_TDM_RX_2,
  98. IDX_PRIMARY_TDM_RX_3,
  99. IDX_PRIMARY_TDM_RX_4,
  100. IDX_PRIMARY_TDM_RX_5,
  101. IDX_PRIMARY_TDM_RX_6,
  102. IDX_PRIMARY_TDM_RX_7,
  103. IDX_PRIMARY_TDM_TX_0,
  104. IDX_PRIMARY_TDM_TX_1,
  105. IDX_PRIMARY_TDM_TX_2,
  106. IDX_PRIMARY_TDM_TX_3,
  107. IDX_PRIMARY_TDM_TX_4,
  108. IDX_PRIMARY_TDM_TX_5,
  109. IDX_PRIMARY_TDM_TX_6,
  110. IDX_PRIMARY_TDM_TX_7,
  111. IDX_SECONDARY_TDM_RX_0,
  112. IDX_SECONDARY_TDM_RX_1,
  113. IDX_SECONDARY_TDM_RX_2,
  114. IDX_SECONDARY_TDM_RX_3,
  115. IDX_SECONDARY_TDM_RX_4,
  116. IDX_SECONDARY_TDM_RX_5,
  117. IDX_SECONDARY_TDM_RX_6,
  118. IDX_SECONDARY_TDM_RX_7,
  119. IDX_SECONDARY_TDM_TX_0,
  120. IDX_SECONDARY_TDM_TX_1,
  121. IDX_SECONDARY_TDM_TX_2,
  122. IDX_SECONDARY_TDM_TX_3,
  123. IDX_SECONDARY_TDM_TX_4,
  124. IDX_SECONDARY_TDM_TX_5,
  125. IDX_SECONDARY_TDM_TX_6,
  126. IDX_SECONDARY_TDM_TX_7,
  127. IDX_TERTIARY_TDM_RX_0,
  128. IDX_TERTIARY_TDM_RX_1,
  129. IDX_TERTIARY_TDM_RX_2,
  130. IDX_TERTIARY_TDM_RX_3,
  131. IDX_TERTIARY_TDM_RX_4,
  132. IDX_TERTIARY_TDM_RX_5,
  133. IDX_TERTIARY_TDM_RX_6,
  134. IDX_TERTIARY_TDM_RX_7,
  135. IDX_TERTIARY_TDM_TX_0,
  136. IDX_TERTIARY_TDM_TX_1,
  137. IDX_TERTIARY_TDM_TX_2,
  138. IDX_TERTIARY_TDM_TX_3,
  139. IDX_TERTIARY_TDM_TX_4,
  140. IDX_TERTIARY_TDM_TX_5,
  141. IDX_TERTIARY_TDM_TX_6,
  142. IDX_TERTIARY_TDM_TX_7,
  143. IDX_QUATERNARY_TDM_RX_0,
  144. IDX_QUATERNARY_TDM_RX_1,
  145. IDX_QUATERNARY_TDM_RX_2,
  146. IDX_QUATERNARY_TDM_RX_3,
  147. IDX_QUATERNARY_TDM_RX_4,
  148. IDX_QUATERNARY_TDM_RX_5,
  149. IDX_QUATERNARY_TDM_RX_6,
  150. IDX_QUATERNARY_TDM_RX_7,
  151. IDX_QUATERNARY_TDM_TX_0,
  152. IDX_QUATERNARY_TDM_TX_1,
  153. IDX_QUATERNARY_TDM_TX_2,
  154. IDX_QUATERNARY_TDM_TX_3,
  155. IDX_QUATERNARY_TDM_TX_4,
  156. IDX_QUATERNARY_TDM_TX_5,
  157. IDX_QUATERNARY_TDM_TX_6,
  158. IDX_QUATERNARY_TDM_TX_7,
  159. IDX_QUINARY_TDM_RX_0,
  160. IDX_QUINARY_TDM_RX_1,
  161. IDX_QUINARY_TDM_RX_2,
  162. IDX_QUINARY_TDM_RX_3,
  163. IDX_QUINARY_TDM_RX_4,
  164. IDX_QUINARY_TDM_RX_5,
  165. IDX_QUINARY_TDM_RX_6,
  166. IDX_QUINARY_TDM_RX_7,
  167. IDX_QUINARY_TDM_TX_0,
  168. IDX_QUINARY_TDM_TX_1,
  169. IDX_QUINARY_TDM_TX_2,
  170. IDX_QUINARY_TDM_TX_3,
  171. IDX_QUINARY_TDM_TX_4,
  172. IDX_QUINARY_TDM_TX_5,
  173. IDX_QUINARY_TDM_TX_6,
  174. IDX_QUINARY_TDM_TX_7,
  175. IDX_SENARY_TDM_RX_0,
  176. IDX_SENARY_TDM_RX_1,
  177. IDX_SENARY_TDM_RX_2,
  178. IDX_SENARY_TDM_RX_3,
  179. IDX_SENARY_TDM_RX_4,
  180. IDX_SENARY_TDM_RX_5,
  181. IDX_SENARY_TDM_RX_6,
  182. IDX_SENARY_TDM_RX_7,
  183. IDX_SENARY_TDM_TX_0,
  184. IDX_SENARY_TDM_TX_1,
  185. IDX_SENARY_TDM_TX_2,
  186. IDX_SENARY_TDM_TX_3,
  187. IDX_SENARY_TDM_TX_4,
  188. IDX_SENARY_TDM_TX_5,
  189. IDX_SENARY_TDM_TX_6,
  190. IDX_SENARY_TDM_TX_7,
  191. IDX_TDM_MAX,
  192. };
  193. enum {
  194. IDX_GROUP_PRIMARY_TDM_RX,
  195. IDX_GROUP_PRIMARY_TDM_TX,
  196. IDX_GROUP_SECONDARY_TDM_RX,
  197. IDX_GROUP_SECONDARY_TDM_TX,
  198. IDX_GROUP_TERTIARY_TDM_RX,
  199. IDX_GROUP_TERTIARY_TDM_TX,
  200. IDX_GROUP_QUATERNARY_TDM_RX,
  201. IDX_GROUP_QUATERNARY_TDM_TX,
  202. IDX_GROUP_QUINARY_TDM_RX,
  203. IDX_GROUP_QUINARY_TDM_TX,
  204. IDX_GROUP_SENARY_TDM_RX,
  205. IDX_GROUP_SENARY_TDM_TX,
  206. IDX_GROUP_TDM_MAX,
  207. };
  208. struct msm_dai_q6_dai_data {
  209. DECLARE_BITMAP(status_mask, STATUS_MAX);
  210. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  211. u32 rate;
  212. u32 channels;
  213. u32 bitwidth;
  214. u32 cal_mode;
  215. u32 afe_rx_in_channels;
  216. u16 afe_rx_in_bitformat;
  217. u32 afe_tx_out_channels;
  218. u16 afe_tx_out_bitformat;
  219. struct afe_enc_config enc_config;
  220. struct afe_dec_config dec_config;
  221. union afe_port_config port_config;
  222. u16 vi_feed_mono;
  223. u32 xt_logging_disable;
  224. };
  225. struct msm_dai_q6_spdif_dai_data {
  226. DECLARE_BITMAP(status_mask, STATUS_MAX);
  227. u32 rate;
  228. u32 channels;
  229. u32 bitwidth;
  230. u16 port_id;
  231. struct afe_spdif_port_config spdif_port;
  232. struct afe_event_fmt_update fmt_event;
  233. struct kobject *kobj;
  234. };
  235. struct msm_dai_q6_spdif_event_msg {
  236. struct afe_port_mod_evt_rsp_hdr evt_hdr;
  237. struct afe_event_fmt_update fmt_event;
  238. };
  239. struct msm_dai_q6_mi2s_dai_config {
  240. u16 pdata_mi2s_lines;
  241. struct msm_dai_q6_dai_data mi2s_dai_data;
  242. };
  243. struct msm_dai_q6_mi2s_dai_data {
  244. u32 is_island_dai;
  245. struct msm_dai_q6_mi2s_dai_config tx_dai;
  246. struct msm_dai_q6_mi2s_dai_config rx_dai;
  247. };
  248. struct msm_dai_q6_meta_mi2s_dai_data {
  249. DECLARE_BITMAP(status_mask, STATUS_MAX);
  250. u16 num_member_ports;
  251. u16 member_port_id[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  252. u16 channel_mode[MAX_NUM_I2S_META_PORT_MEMBER_PORTS];
  253. u32 rate;
  254. u32 channels;
  255. u32 bitwidth;
  256. union afe_port_config port_config;
  257. };
  258. struct msm_dai_q6_cdc_dma_dai_data {
  259. DECLARE_BITMAP(status_mask, STATUS_MAX);
  260. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  261. u32 rate;
  262. u32 channels;
  263. u32 bitwidth;
  264. u32 is_island_dai;
  265. union afe_port_config port_config;
  266. };
  267. struct msm_dai_q6_auxpcm_dai_data {
  268. /* BITMAP to track Rx and Tx port usage count */
  269. DECLARE_BITMAP(auxpcm_port_status, STATUS_MAX);
  270. struct mutex rlock; /* auxpcm dev resource lock */
  271. u16 rx_pid; /* AUXPCM RX AFE port ID */
  272. u16 tx_pid; /* AUXPCM TX AFE port ID */
  273. u16 afe_clk_ver;
  274. u32 is_island_dai;
  275. struct afe_clk_cfg clk_cfg; /* hold LPASS clock configuration */
  276. struct afe_clk_set clk_set; /* hold LPASS clock configuration */
  277. struct msm_dai_q6_dai_data bdai_data; /* incoporate base DAI data */
  278. };
  279. struct msm_dai_q6_tdm_dai_data {
  280. DECLARE_BITMAP(status_mask, STATUS_MAX);
  281. u32 rate;
  282. u32 channels;
  283. u32 bitwidth;
  284. u32 num_group_ports;
  285. u32 is_island_dai;
  286. struct afe_clk_set clk_set; /* hold LPASS clock config. */
  287. union afe_port_group_config group_cfg; /* hold tdm group config */
  288. struct afe_tdm_port_config port_cfg; /* hold tdm config */
  289. struct afe_param_id_tdm_lane_cfg lane_cfg; /* hold tdm lane config */
  290. };
  291. /* MI2S format field for AFE_PORT_CMD_I2S_CONFIG command
  292. * 0: linear PCM
  293. * 1: non-linear PCM
  294. * 2: PCM data in IEC 60968 container
  295. * 3: compressed data in IEC 60958 container
  296. * 9: DSD over PCM (DoP) with marker byte
  297. */
  298. static const char *const mi2s_format[] = {
  299. "LPCM",
  300. "Compr",
  301. "LPCM-60958",
  302. "Compr-60958",
  303. "NA4",
  304. "NA5",
  305. "NA6",
  306. "NA7",
  307. "NA8",
  308. "DSD_DOP_W_MARKER"
  309. };
  310. static const char *const mi2s_vi_feed_mono[] = {
  311. "Left",
  312. "Right",
  313. };
  314. static const struct soc_enum mi2s_config_enum[] = {
  315. SOC_ENUM_SINGLE_EXT(10, mi2s_format),
  316. SOC_ENUM_SINGLE_EXT(2, mi2s_vi_feed_mono),
  317. };
  318. static const char *const cdc_dma_format[] = {
  319. "UNPACKED",
  320. "PACKED_16B",
  321. };
  322. static const struct soc_enum cdc_dma_config_enum[] = {
  323. SOC_ENUM_SINGLE_EXT(2, cdc_dma_format),
  324. };
  325. static const char *const sb_format[] = {
  326. "UNPACKED",
  327. "PACKED_16B",
  328. "DSD_DOP",
  329. };
  330. static const struct soc_enum sb_config_enum[] = {
  331. SOC_ENUM_SINGLE_EXT(3, sb_format),
  332. };
  333. static const char * const xt_logging_disable_text[] = {
  334. "FALSE",
  335. "TRUE",
  336. };
  337. static const struct soc_enum xt_logging_disable_enum[] = {
  338. SOC_ENUM_SINGLE_EXT(2, xt_logging_disable_text),
  339. };
  340. static const char *const tdm_data_format[] = {
  341. "LPCM",
  342. "Compr",
  343. "Gen Compr"
  344. };
  345. static const char *const tdm_header_type[] = {
  346. "Invalid",
  347. "Default",
  348. "Entertainment",
  349. };
  350. static const struct soc_enum tdm_config_enum[] = {
  351. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_data_format), tdm_data_format),
  352. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type),
  353. };
  354. static DEFINE_MUTEX(tdm_mutex);
  355. static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
  356. static struct afe_param_id_tdm_lane_cfg tdm_lane_cfg = {
  357. AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX,
  358. 0x0,
  359. };
  360. /* cache of group cfg per parent node */
  361. static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = {
  362. AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG,
  363. AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX,
  364. 0,
  365. {AFE_PORT_ID_QUATERNARY_TDM_RX,
  366. AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  367. AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  368. AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  369. AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  370. AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  371. AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  372. AFE_PORT_ID_QUATERNARY_TDM_RX_7},
  373. 8,
  374. 48000,
  375. 32,
  376. 8,
  377. 32,
  378. 0xFF,
  379. };
  380. static u32 num_tdm_group_ports;
  381. static struct afe_clk_set tdm_clk_set = {
  382. AFE_API_VERSION_CLOCK_SET,
  383. Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT,
  384. Q6AFE_LPASS_IBIT_CLK_DISABLE,
  385. Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
  386. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  387. 0,
  388. };
  389. static int msm_dai_q6_get_tdm_clk_ref(u16 id)
  390. {
  391. switch (id) {
  392. case IDX_GROUP_PRIMARY_TDM_RX:
  393. case IDX_GROUP_PRIMARY_TDM_TX:
  394. return atomic_read(&tdm_group_ref[IDX_GROUP_PRIMARY_TDM_RX]) +
  395. atomic_read(&tdm_group_ref[IDX_GROUP_PRIMARY_TDM_TX]);
  396. case IDX_GROUP_SECONDARY_TDM_RX:
  397. case IDX_GROUP_SECONDARY_TDM_TX:
  398. return atomic_read(&tdm_group_ref[IDX_GROUP_SECONDARY_TDM_RX]) +
  399. atomic_read(&tdm_group_ref[IDX_GROUP_SECONDARY_TDM_TX]);
  400. case IDX_GROUP_TERTIARY_TDM_RX:
  401. case IDX_GROUP_TERTIARY_TDM_TX:
  402. return atomic_read(&tdm_group_ref[IDX_GROUP_TERTIARY_TDM_RX]) +
  403. atomic_read(&tdm_group_ref[IDX_GROUP_TERTIARY_TDM_TX]);
  404. case IDX_GROUP_QUATERNARY_TDM_RX:
  405. case IDX_GROUP_QUATERNARY_TDM_TX:
  406. return atomic_read(&tdm_group_ref[IDX_GROUP_QUATERNARY_TDM_RX]) +
  407. atomic_read(&tdm_group_ref[IDX_GROUP_QUATERNARY_TDM_TX]);
  408. case IDX_GROUP_QUINARY_TDM_RX:
  409. case IDX_GROUP_QUINARY_TDM_TX:
  410. return atomic_read(&tdm_group_ref[IDX_GROUP_QUINARY_TDM_RX]) +
  411. atomic_read(&tdm_group_ref[IDX_GROUP_QUINARY_TDM_TX]);
  412. case IDX_GROUP_SENARY_TDM_RX:
  413. case IDX_GROUP_SENARY_TDM_TX:
  414. return atomic_read(&tdm_group_ref[IDX_GROUP_SENARY_TDM_RX]) +
  415. atomic_read(&tdm_group_ref[IDX_GROUP_SENARY_TDM_TX]);
  416. default: return -EINVAL;
  417. }
  418. }
  419. int msm_dai_q6_get_group_idx(u16 id)
  420. {
  421. switch (id) {
  422. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  423. case AFE_PORT_ID_PRIMARY_TDM_RX:
  424. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  425. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  426. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  427. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  428. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  429. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  430. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  431. return IDX_GROUP_PRIMARY_TDM_RX;
  432. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  433. case AFE_PORT_ID_PRIMARY_TDM_TX:
  434. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  435. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  436. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  437. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  438. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  439. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  440. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  441. return IDX_GROUP_PRIMARY_TDM_TX;
  442. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  443. case AFE_PORT_ID_SECONDARY_TDM_RX:
  444. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  445. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  446. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  447. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  448. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  449. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  450. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  451. return IDX_GROUP_SECONDARY_TDM_RX;
  452. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  453. case AFE_PORT_ID_SECONDARY_TDM_TX:
  454. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  455. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  456. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  457. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  458. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  459. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  460. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  461. return IDX_GROUP_SECONDARY_TDM_TX;
  462. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  463. case AFE_PORT_ID_TERTIARY_TDM_RX:
  464. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  465. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  466. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  467. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  468. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  469. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  470. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  471. return IDX_GROUP_TERTIARY_TDM_RX;
  472. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  473. case AFE_PORT_ID_TERTIARY_TDM_TX:
  474. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  475. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  476. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  477. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  478. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  479. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  480. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  481. return IDX_GROUP_TERTIARY_TDM_TX;
  482. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  483. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  484. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  485. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  486. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  487. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  488. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  489. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  490. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  491. return IDX_GROUP_QUATERNARY_TDM_RX;
  492. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  493. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  494. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  495. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  496. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  497. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  498. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  499. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  500. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  501. return IDX_GROUP_QUATERNARY_TDM_TX;
  502. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  503. case AFE_PORT_ID_QUINARY_TDM_RX:
  504. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  505. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  506. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  507. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  508. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  509. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  510. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  511. return IDX_GROUP_QUINARY_TDM_RX;
  512. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  513. case AFE_PORT_ID_QUINARY_TDM_TX:
  514. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  515. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  516. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  517. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  518. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  519. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  520. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  521. return IDX_GROUP_QUINARY_TDM_TX;
  522. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  523. case AFE_PORT_ID_SENARY_TDM_RX:
  524. case AFE_PORT_ID_SENARY_TDM_RX_1:
  525. case AFE_PORT_ID_SENARY_TDM_RX_2:
  526. case AFE_PORT_ID_SENARY_TDM_RX_3:
  527. case AFE_PORT_ID_SENARY_TDM_RX_4:
  528. case AFE_PORT_ID_SENARY_TDM_RX_5:
  529. case AFE_PORT_ID_SENARY_TDM_RX_6:
  530. case AFE_PORT_ID_SENARY_TDM_RX_7:
  531. return IDX_GROUP_SENARY_TDM_RX;
  532. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  533. case AFE_PORT_ID_SENARY_TDM_TX:
  534. case AFE_PORT_ID_SENARY_TDM_TX_1:
  535. case AFE_PORT_ID_SENARY_TDM_TX_2:
  536. case AFE_PORT_ID_SENARY_TDM_TX_3:
  537. case AFE_PORT_ID_SENARY_TDM_TX_4:
  538. case AFE_PORT_ID_SENARY_TDM_TX_5:
  539. case AFE_PORT_ID_SENARY_TDM_TX_6:
  540. case AFE_PORT_ID_SENARY_TDM_TX_7:
  541. return IDX_GROUP_SENARY_TDM_TX;
  542. default: return -EINVAL;
  543. }
  544. }
  545. int msm_dai_q6_get_port_idx(u16 id)
  546. {
  547. switch (id) {
  548. case AFE_PORT_ID_PRIMARY_TDM_RX:
  549. return IDX_PRIMARY_TDM_RX_0;
  550. case AFE_PORT_ID_PRIMARY_TDM_TX:
  551. return IDX_PRIMARY_TDM_TX_0;
  552. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  553. return IDX_PRIMARY_TDM_RX_1;
  554. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  555. return IDX_PRIMARY_TDM_TX_1;
  556. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  557. return IDX_PRIMARY_TDM_RX_2;
  558. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  559. return IDX_PRIMARY_TDM_TX_2;
  560. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  561. return IDX_PRIMARY_TDM_RX_3;
  562. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  563. return IDX_PRIMARY_TDM_TX_3;
  564. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  565. return IDX_PRIMARY_TDM_RX_4;
  566. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  567. return IDX_PRIMARY_TDM_TX_4;
  568. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  569. return IDX_PRIMARY_TDM_RX_5;
  570. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  571. return IDX_PRIMARY_TDM_TX_5;
  572. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  573. return IDX_PRIMARY_TDM_RX_6;
  574. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  575. return IDX_PRIMARY_TDM_TX_6;
  576. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  577. return IDX_PRIMARY_TDM_RX_7;
  578. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  579. return IDX_PRIMARY_TDM_TX_7;
  580. case AFE_PORT_ID_SECONDARY_TDM_RX:
  581. return IDX_SECONDARY_TDM_RX_0;
  582. case AFE_PORT_ID_SECONDARY_TDM_TX:
  583. return IDX_SECONDARY_TDM_TX_0;
  584. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  585. return IDX_SECONDARY_TDM_RX_1;
  586. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  587. return IDX_SECONDARY_TDM_TX_1;
  588. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  589. return IDX_SECONDARY_TDM_RX_2;
  590. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  591. return IDX_SECONDARY_TDM_TX_2;
  592. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  593. return IDX_SECONDARY_TDM_RX_3;
  594. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  595. return IDX_SECONDARY_TDM_TX_3;
  596. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  597. return IDX_SECONDARY_TDM_RX_4;
  598. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  599. return IDX_SECONDARY_TDM_TX_4;
  600. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  601. return IDX_SECONDARY_TDM_RX_5;
  602. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  603. return IDX_SECONDARY_TDM_TX_5;
  604. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  605. return IDX_SECONDARY_TDM_RX_6;
  606. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  607. return IDX_SECONDARY_TDM_TX_6;
  608. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  609. return IDX_SECONDARY_TDM_RX_7;
  610. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  611. return IDX_SECONDARY_TDM_TX_7;
  612. case AFE_PORT_ID_TERTIARY_TDM_RX:
  613. return IDX_TERTIARY_TDM_RX_0;
  614. case AFE_PORT_ID_TERTIARY_TDM_TX:
  615. return IDX_TERTIARY_TDM_TX_0;
  616. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  617. return IDX_TERTIARY_TDM_RX_1;
  618. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  619. return IDX_TERTIARY_TDM_TX_1;
  620. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  621. return IDX_TERTIARY_TDM_RX_2;
  622. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  623. return IDX_TERTIARY_TDM_TX_2;
  624. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  625. return IDX_TERTIARY_TDM_RX_3;
  626. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  627. return IDX_TERTIARY_TDM_TX_3;
  628. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  629. return IDX_TERTIARY_TDM_RX_4;
  630. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  631. return IDX_TERTIARY_TDM_TX_4;
  632. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  633. return IDX_TERTIARY_TDM_RX_5;
  634. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  635. return IDX_TERTIARY_TDM_TX_5;
  636. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  637. return IDX_TERTIARY_TDM_RX_6;
  638. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  639. return IDX_TERTIARY_TDM_TX_6;
  640. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  641. return IDX_TERTIARY_TDM_RX_7;
  642. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  643. return IDX_TERTIARY_TDM_TX_7;
  644. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  645. return IDX_QUATERNARY_TDM_RX_0;
  646. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  647. return IDX_QUATERNARY_TDM_TX_0;
  648. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  649. return IDX_QUATERNARY_TDM_RX_1;
  650. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  651. return IDX_QUATERNARY_TDM_TX_1;
  652. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  653. return IDX_QUATERNARY_TDM_RX_2;
  654. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  655. return IDX_QUATERNARY_TDM_TX_2;
  656. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  657. return IDX_QUATERNARY_TDM_RX_3;
  658. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  659. return IDX_QUATERNARY_TDM_TX_3;
  660. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  661. return IDX_QUATERNARY_TDM_RX_4;
  662. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  663. return IDX_QUATERNARY_TDM_TX_4;
  664. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  665. return IDX_QUATERNARY_TDM_RX_5;
  666. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  667. return IDX_QUATERNARY_TDM_TX_5;
  668. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  669. return IDX_QUATERNARY_TDM_RX_6;
  670. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  671. return IDX_QUATERNARY_TDM_TX_6;
  672. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  673. return IDX_QUATERNARY_TDM_RX_7;
  674. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  675. return IDX_QUATERNARY_TDM_TX_7;
  676. case AFE_PORT_ID_QUINARY_TDM_RX:
  677. return IDX_QUINARY_TDM_RX_0;
  678. case AFE_PORT_ID_QUINARY_TDM_TX:
  679. return IDX_QUINARY_TDM_TX_0;
  680. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  681. return IDX_QUINARY_TDM_RX_1;
  682. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  683. return IDX_QUINARY_TDM_TX_1;
  684. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  685. return IDX_QUINARY_TDM_RX_2;
  686. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  687. return IDX_QUINARY_TDM_TX_2;
  688. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  689. return IDX_QUINARY_TDM_RX_3;
  690. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  691. return IDX_QUINARY_TDM_TX_3;
  692. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  693. return IDX_QUINARY_TDM_RX_4;
  694. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  695. return IDX_QUINARY_TDM_TX_4;
  696. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  697. return IDX_QUINARY_TDM_RX_5;
  698. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  699. return IDX_QUINARY_TDM_TX_5;
  700. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  701. return IDX_QUINARY_TDM_RX_6;
  702. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  703. return IDX_QUINARY_TDM_TX_6;
  704. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  705. return IDX_QUINARY_TDM_RX_7;
  706. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  707. return IDX_QUINARY_TDM_TX_7;
  708. case AFE_PORT_ID_SENARY_TDM_RX:
  709. return IDX_SENARY_TDM_RX_0;
  710. case AFE_PORT_ID_SENARY_TDM_TX:
  711. return IDX_SENARY_TDM_TX_0;
  712. case AFE_PORT_ID_SENARY_TDM_RX_1:
  713. return IDX_SENARY_TDM_RX_1;
  714. case AFE_PORT_ID_SENARY_TDM_TX_1:
  715. return IDX_SENARY_TDM_TX_1;
  716. case AFE_PORT_ID_SENARY_TDM_RX_2:
  717. return IDX_SENARY_TDM_RX_2;
  718. case AFE_PORT_ID_SENARY_TDM_TX_2:
  719. return IDX_SENARY_TDM_TX_2;
  720. case AFE_PORT_ID_SENARY_TDM_RX_3:
  721. return IDX_SENARY_TDM_RX_3;
  722. case AFE_PORT_ID_SENARY_TDM_TX_3:
  723. return IDX_SENARY_TDM_TX_3;
  724. case AFE_PORT_ID_SENARY_TDM_RX_4:
  725. return IDX_SENARY_TDM_RX_4;
  726. case AFE_PORT_ID_SENARY_TDM_TX_4:
  727. return IDX_SENARY_TDM_TX_4;
  728. case AFE_PORT_ID_SENARY_TDM_RX_5:
  729. return IDX_SENARY_TDM_RX_5;
  730. case AFE_PORT_ID_SENARY_TDM_TX_5:
  731. return IDX_SENARY_TDM_TX_5;
  732. case AFE_PORT_ID_SENARY_TDM_RX_6:
  733. return IDX_SENARY_TDM_RX_6;
  734. case AFE_PORT_ID_SENARY_TDM_TX_6:
  735. return IDX_SENARY_TDM_TX_6;
  736. case AFE_PORT_ID_SENARY_TDM_RX_7:
  737. return IDX_SENARY_TDM_RX_7;
  738. case AFE_PORT_ID_SENARY_TDM_TX_7:
  739. return IDX_SENARY_TDM_TX_7;
  740. default: return -EINVAL;
  741. }
  742. }
  743. static u16 msm_dai_q6_max_num_slot(int frame_rate)
  744. {
  745. /* Max num of slots is bits per frame divided
  746. * by bits per sample which is 16
  747. */
  748. switch (frame_rate) {
  749. case AFE_PORT_PCM_BITS_PER_FRAME_8:
  750. return 0;
  751. case AFE_PORT_PCM_BITS_PER_FRAME_16:
  752. return 1;
  753. case AFE_PORT_PCM_BITS_PER_FRAME_32:
  754. return 2;
  755. case AFE_PORT_PCM_BITS_PER_FRAME_64:
  756. return 4;
  757. case AFE_PORT_PCM_BITS_PER_FRAME_128:
  758. return 8;
  759. case AFE_PORT_PCM_BITS_PER_FRAME_256:
  760. return 16;
  761. default:
  762. pr_err("%s Invalid bits per frame %d\n",
  763. __func__, frame_rate);
  764. return 0;
  765. }
  766. }
  767. static int msm_dai_q6_dai_add_route(struct snd_soc_dai *dai)
  768. {
  769. struct snd_soc_dapm_route intercon;
  770. struct snd_soc_dapm_context *dapm;
  771. if (!dai) {
  772. pr_err("%s: Invalid params dai\n", __func__);
  773. return -EINVAL;
  774. }
  775. if (!dai->driver) {
  776. pr_err("%s: Invalid params dai driver\n", __func__);
  777. return -EINVAL;
  778. }
  779. dapm = snd_soc_component_get_dapm(dai->component);
  780. memset(&intercon, 0, sizeof(intercon));
  781. if (dai->driver->playback.stream_name &&
  782. dai->driver->playback.aif_name) {
  783. dev_dbg(dai->dev, "%s: add route for widget %s",
  784. __func__, dai->driver->playback.stream_name);
  785. intercon.source = dai->driver->playback.aif_name;
  786. intercon.sink = dai->driver->playback.stream_name;
  787. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  788. __func__, intercon.source, intercon.sink);
  789. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  790. snd_soc_dapm_ignore_suspend(dapm, intercon.sink);
  791. }
  792. if (dai->driver->capture.stream_name &&
  793. dai->driver->capture.aif_name) {
  794. dev_dbg(dai->dev, "%s: add route for widget %s",
  795. __func__, dai->driver->capture.stream_name);
  796. intercon.sink = dai->driver->capture.aif_name;
  797. intercon.source = dai->driver->capture.stream_name;
  798. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  799. __func__, intercon.source, intercon.sink);
  800. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  801. snd_soc_dapm_ignore_suspend(dapm, intercon.source);
  802. }
  803. return 0;
  804. }
  805. static int msm_dai_q6_auxpcm_hw_params(
  806. struct snd_pcm_substream *substream,
  807. struct snd_pcm_hw_params *params,
  808. struct snd_soc_dai *dai)
  809. {
  810. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  811. dev_get_drvdata(dai->dev);
  812. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  813. struct msm_dai_auxpcm_pdata *auxpcm_pdata =
  814. (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data;
  815. int rc = 0, slot_mapping_copy_len = 0;
  816. if (params_channels(params) != 1 || (params_rate(params) != 8000 &&
  817. params_rate(params) != 16000)) {
  818. dev_err(dai->dev, "%s: invalid param chan %d rate %d\n",
  819. __func__, params_channels(params), params_rate(params));
  820. return -EINVAL;
  821. }
  822. mutex_lock(&aux_dai_data->rlock);
  823. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  824. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  825. /* AUXPCM DAI in use */
  826. if (dai_data->rate != params_rate(params)) {
  827. dev_err(dai->dev, "%s: rate mismatch of running DAI\n",
  828. __func__);
  829. rc = -EINVAL;
  830. }
  831. mutex_unlock(&aux_dai_data->rlock);
  832. return rc;
  833. }
  834. dai_data->channels = params_channels(params);
  835. dai_data->rate = params_rate(params);
  836. if (dai_data->rate == 8000) {
  837. dai_data->port_config.pcm.pcm_cfg_minor_version =
  838. AFE_API_VERSION_PCM_CONFIG;
  839. dai_data->port_config.pcm.aux_mode = auxpcm_pdata->mode_8k.mode;
  840. dai_data->port_config.pcm.sync_src = auxpcm_pdata->mode_8k.sync;
  841. dai_data->port_config.pcm.frame_setting =
  842. auxpcm_pdata->mode_8k.frame;
  843. dai_data->port_config.pcm.quantype =
  844. auxpcm_pdata->mode_8k.quant;
  845. dai_data->port_config.pcm.ctrl_data_out_enable =
  846. auxpcm_pdata->mode_8k.data;
  847. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  848. dai_data->port_config.pcm.num_channels = dai_data->channels;
  849. dai_data->port_config.pcm.bit_width = 16;
  850. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  851. auxpcm_pdata->mode_8k.num_slots)
  852. slot_mapping_copy_len =
  853. ARRAY_SIZE(
  854. dai_data->port_config.pcm.slot_number_mapping)
  855. * sizeof(uint16_t);
  856. else
  857. slot_mapping_copy_len = auxpcm_pdata->mode_8k.num_slots
  858. * sizeof(uint16_t);
  859. if (auxpcm_pdata->mode_8k.slot_mapping) {
  860. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  861. auxpcm_pdata->mode_8k.slot_mapping,
  862. slot_mapping_copy_len);
  863. } else {
  864. dev_err(dai->dev, "%s 8khz slot mapping is NULL\n",
  865. __func__);
  866. mutex_unlock(&aux_dai_data->rlock);
  867. return -EINVAL;
  868. }
  869. } else {
  870. dai_data->port_config.pcm.pcm_cfg_minor_version =
  871. AFE_API_VERSION_PCM_CONFIG;
  872. dai_data->port_config.pcm.aux_mode =
  873. auxpcm_pdata->mode_16k.mode;
  874. dai_data->port_config.pcm.sync_src =
  875. auxpcm_pdata->mode_16k.sync;
  876. dai_data->port_config.pcm.frame_setting =
  877. auxpcm_pdata->mode_16k.frame;
  878. dai_data->port_config.pcm.quantype =
  879. auxpcm_pdata->mode_16k.quant;
  880. dai_data->port_config.pcm.ctrl_data_out_enable =
  881. auxpcm_pdata->mode_16k.data;
  882. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  883. dai_data->port_config.pcm.num_channels = dai_data->channels;
  884. dai_data->port_config.pcm.bit_width = 16;
  885. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  886. auxpcm_pdata->mode_16k.num_slots)
  887. slot_mapping_copy_len =
  888. ARRAY_SIZE(
  889. dai_data->port_config.pcm.slot_number_mapping)
  890. * sizeof(uint16_t);
  891. else
  892. slot_mapping_copy_len = auxpcm_pdata->mode_16k.num_slots
  893. * sizeof(uint16_t);
  894. if (auxpcm_pdata->mode_16k.slot_mapping) {
  895. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  896. auxpcm_pdata->mode_16k.slot_mapping,
  897. slot_mapping_copy_len);
  898. } else {
  899. dev_err(dai->dev, "%s 16khz slot mapping is NULL\n",
  900. __func__);
  901. mutex_unlock(&aux_dai_data->rlock);
  902. return -EINVAL;
  903. }
  904. }
  905. dev_dbg(dai->dev, "%s: aux_mode 0x%x sync_src 0x%x frame_setting 0x%x\n",
  906. __func__, dai_data->port_config.pcm.aux_mode,
  907. dai_data->port_config.pcm.sync_src,
  908. dai_data->port_config.pcm.frame_setting);
  909. dev_dbg(dai->dev, "%s: qtype 0x%x dout 0x%x num_map[0] 0x%x\n"
  910. "num_map[1] 0x%x num_map[2] 0x%x num_map[3] 0x%x\n",
  911. __func__, dai_data->port_config.pcm.quantype,
  912. dai_data->port_config.pcm.ctrl_data_out_enable,
  913. dai_data->port_config.pcm.slot_number_mapping[0],
  914. dai_data->port_config.pcm.slot_number_mapping[1],
  915. dai_data->port_config.pcm.slot_number_mapping[2],
  916. dai_data->port_config.pcm.slot_number_mapping[3]);
  917. mutex_unlock(&aux_dai_data->rlock);
  918. return rc;
  919. }
  920. static int msm_dai_q6_auxpcm_set_clk(
  921. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data,
  922. u16 port_id, bool enable)
  923. {
  924. int rc;
  925. pr_debug("%s: afe_clk_ver: %d, port_id: %d, enable: %d\n", __func__,
  926. aux_dai_data->afe_clk_ver, port_id, enable);
  927. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  928. aux_dai_data->clk_set.enable = enable;
  929. rc = afe_set_lpass_clock_v2(port_id,
  930. &aux_dai_data->clk_set);
  931. } else {
  932. if (!enable)
  933. aux_dai_data->clk_cfg.clk_val1 = 0;
  934. rc = afe_set_lpass_clock(port_id,
  935. &aux_dai_data->clk_cfg);
  936. }
  937. return rc;
  938. }
  939. static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
  940. struct snd_soc_dai *dai)
  941. {
  942. int rc = 0;
  943. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  944. dev_get_drvdata(dai->dev);
  945. mutex_lock(&aux_dai_data->rlock);
  946. if (!(test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  947. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))) {
  948. dev_dbg(dai->dev, "%s(): dai->id %d PCM ports already closed\n",
  949. __func__, dai->id);
  950. goto exit;
  951. }
  952. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  953. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status))
  954. clear_bit(STATUS_TX_PORT,
  955. aux_dai_data->auxpcm_port_status);
  956. else {
  957. dev_dbg(dai->dev, "%s: PCM_TX port already closed\n",
  958. __func__);
  959. goto exit;
  960. }
  961. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  962. if (test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))
  963. clear_bit(STATUS_RX_PORT,
  964. aux_dai_data->auxpcm_port_status);
  965. else {
  966. dev_dbg(dai->dev, "%s: PCM_RX port already closed\n",
  967. __func__);
  968. goto exit;
  969. }
  970. }
  971. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  972. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  973. dev_dbg(dai->dev, "%s: cannot shutdown PCM ports\n",
  974. __func__);
  975. goto exit;
  976. }
  977. dev_dbg(dai->dev, "%s: dai->id = %d closing PCM AFE ports\n",
  978. __func__, dai->id);
  979. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  980. if (rc < 0)
  981. dev_err(dai->dev, "fail to close PCM_RX AFE port\n");
  982. rc = afe_close(aux_dai_data->tx_pid);
  983. if (rc < 0)
  984. dev_err(dai->dev, "fail to close AUX PCM TX port\n");
  985. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  986. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  987. exit:
  988. mutex_unlock(&aux_dai_data->rlock);
  989. }
  990. static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
  991. struct snd_soc_dai *dai)
  992. {
  993. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  994. dev_get_drvdata(dai->dev);
  995. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  996. struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
  997. int rc = 0;
  998. u32 pcm_clk_rate;
  999. auxpcm_pdata = dai->dev->platform_data;
  1000. mutex_lock(&aux_dai_data->rlock);
  1001. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  1002. if (test_bit(STATUS_TX_PORT,
  1003. aux_dai_data->auxpcm_port_status)) {
  1004. dev_dbg(dai->dev, "%s: PCM_TX port already ON\n",
  1005. __func__);
  1006. goto exit;
  1007. } else
  1008. set_bit(STATUS_TX_PORT,
  1009. aux_dai_data->auxpcm_port_status);
  1010. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1011. if (test_bit(STATUS_RX_PORT,
  1012. aux_dai_data->auxpcm_port_status)) {
  1013. dev_dbg(dai->dev, "%s: PCM_RX port already ON\n",
  1014. __func__);
  1015. goto exit;
  1016. } else
  1017. set_bit(STATUS_RX_PORT,
  1018. aux_dai_data->auxpcm_port_status);
  1019. }
  1020. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) &&
  1021. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  1022. dev_dbg(dai->dev, "%s: PCM ports already set\n", __func__);
  1023. goto exit;
  1024. }
  1025. dev_dbg(dai->dev, "%s: dai->id:%d opening afe ports\n",
  1026. __func__, dai->id);
  1027. rc = afe_q6_interface_prepare();
  1028. if (rc < 0) {
  1029. dev_err(dai->dev, "fail to open AFE APR\n");
  1030. goto fail;
  1031. }
  1032. /*
  1033. * For AUX PCM Interface the below sequence of clk
  1034. * settings and afe_open is a strict requirement.
  1035. *
  1036. * Also using afe_open instead of afe_port_start_nowait
  1037. * to make sure the port is open before deasserting the
  1038. * clock line. This is required because pcm register is
  1039. * not written before clock deassert. Hence the hw does
  1040. * not get updated with new setting if the below clock
  1041. * assert/deasset and afe_open sequence is not followed.
  1042. */
  1043. if (dai_data->rate == 8000) {
  1044. pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate;
  1045. } else if (dai_data->rate == 16000) {
  1046. pcm_clk_rate = (auxpcm_pdata->mode_16k.pcm_clk_rate);
  1047. } else {
  1048. dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__,
  1049. dai_data->rate);
  1050. rc = -EINVAL;
  1051. goto fail;
  1052. }
  1053. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  1054. memcpy(&aux_dai_data->clk_set, &lpass_clk_set_default,
  1055. sizeof(struct afe_clk_set));
  1056. aux_dai_data->clk_set.clk_freq_in_hz = pcm_clk_rate;
  1057. switch (dai->id) {
  1058. case MSM_DAI_PRI_AUXPCM_DT_DEV_ID:
  1059. if (pcm_clk_rate)
  1060. aux_dai_data->clk_set.clk_id =
  1061. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT;
  1062. else
  1063. aux_dai_data->clk_set.clk_id =
  1064. Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT;
  1065. break;
  1066. case MSM_DAI_SEC_AUXPCM_DT_DEV_ID:
  1067. if (pcm_clk_rate)
  1068. aux_dai_data->clk_set.clk_id =
  1069. Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT;
  1070. else
  1071. aux_dai_data->clk_set.clk_id =
  1072. Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT;
  1073. break;
  1074. case MSM_DAI_TERT_AUXPCM_DT_DEV_ID:
  1075. if (pcm_clk_rate)
  1076. aux_dai_data->clk_set.clk_id =
  1077. Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT;
  1078. else
  1079. aux_dai_data->clk_set.clk_id =
  1080. Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT;
  1081. break;
  1082. case MSM_DAI_QUAT_AUXPCM_DT_DEV_ID:
  1083. if (pcm_clk_rate)
  1084. aux_dai_data->clk_set.clk_id =
  1085. Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT;
  1086. else
  1087. aux_dai_data->clk_set.clk_id =
  1088. Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT;
  1089. break;
  1090. case MSM_DAI_QUIN_AUXPCM_DT_DEV_ID:
  1091. if (pcm_clk_rate)
  1092. aux_dai_data->clk_set.clk_id =
  1093. Q6AFE_LPASS_CLK_ID_QUIN_PCM_IBIT;
  1094. else
  1095. aux_dai_data->clk_set.clk_id =
  1096. Q6AFE_LPASS_CLK_ID_QUIN_PCM_EBIT;
  1097. break;
  1098. case MSM_DAI_SEN_AUXPCM_DT_DEV_ID:
  1099. if (pcm_clk_rate)
  1100. aux_dai_data->clk_set.clk_id =
  1101. Q6AFE_LPASS_CLK_ID_SEN_PCM_IBIT;
  1102. else
  1103. aux_dai_data->clk_set.clk_id =
  1104. Q6AFE_LPASS_CLK_ID_SEN_PCM_EBIT;
  1105. break;
  1106. default:
  1107. dev_err(dai->dev, "%s: AUXPCM id: %d not supported\n",
  1108. __func__, dai->id);
  1109. break;
  1110. }
  1111. } else {
  1112. memcpy(&aux_dai_data->clk_cfg, &lpass_clk_cfg_default,
  1113. sizeof(struct afe_clk_cfg));
  1114. aux_dai_data->clk_cfg.clk_val1 = pcm_clk_rate;
  1115. }
  1116. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  1117. aux_dai_data->rx_pid, true);
  1118. if (rc < 0) {
  1119. dev_err(dai->dev,
  1120. "%s:afe_set_lpass_clock on RX pcm_src_clk failed\n",
  1121. __func__);
  1122. goto fail;
  1123. }
  1124. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  1125. aux_dai_data->tx_pid, true);
  1126. if (rc < 0) {
  1127. dev_err(dai->dev,
  1128. "%s:afe_set_lpass_clock on TX pcm_src_clk failed\n",
  1129. __func__);
  1130. goto fail;
  1131. }
  1132. afe_open(aux_dai_data->rx_pid, &dai_data->port_config, dai_data->rate);
  1133. afe_open(aux_dai_data->tx_pid, &dai_data->port_config, dai_data->rate);
  1134. goto exit;
  1135. fail:
  1136. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  1137. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1138. else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  1139. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1140. exit:
  1141. mutex_unlock(&aux_dai_data->rlock);
  1142. return rc;
  1143. }
  1144. static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream,
  1145. int cmd, struct snd_soc_dai *dai)
  1146. {
  1147. int rc = 0;
  1148. pr_debug("%s:port:%d cmd:%d\n",
  1149. __func__, dai->id, cmd);
  1150. switch (cmd) {
  1151. case SNDRV_PCM_TRIGGER_START:
  1152. case SNDRV_PCM_TRIGGER_RESUME:
  1153. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  1154. /* afe_open will be called from prepare */
  1155. return 0;
  1156. case SNDRV_PCM_TRIGGER_STOP:
  1157. case SNDRV_PCM_TRIGGER_SUSPEND:
  1158. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  1159. return 0;
  1160. default:
  1161. pr_err("%s: cmd %d\n", __func__, cmd);
  1162. rc = -EINVAL;
  1163. }
  1164. return rc;
  1165. }
  1166. static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai)
  1167. {
  1168. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data;
  1169. int rc;
  1170. aux_dai_data = dev_get_drvdata(dai->dev);
  1171. dev_dbg(dai->dev, "%s: dai->id %d closing afe\n",
  1172. __func__, dai->id);
  1173. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  1174. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  1175. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  1176. if (rc < 0)
  1177. dev_err(dai->dev, "fail to close AUXPCM RX AFE port\n");
  1178. rc = afe_close(aux_dai_data->tx_pid);
  1179. if (rc < 0)
  1180. dev_err(dai->dev, "fail to close AUXPCM TX AFE port\n");
  1181. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1182. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1183. }
  1184. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  1185. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  1186. return 0;
  1187. }
  1188. static int msm_dai_q6_island_mode_put(struct snd_kcontrol *kcontrol,
  1189. struct snd_ctl_elem_value *ucontrol)
  1190. {
  1191. int value = ucontrol->value.integer.value[0];
  1192. u16 port_id = (u16)kcontrol->private_value;
  1193. pr_debug("%s: island mode = %d\n", __func__, value);
  1194. afe_set_island_mode_cfg(port_id, value);
  1195. return 0;
  1196. }
  1197. static int msm_dai_q6_island_mode_get(struct snd_kcontrol *kcontrol,
  1198. struct snd_ctl_elem_value *ucontrol)
  1199. {
  1200. int value;
  1201. u16 port_id = (u16)kcontrol->private_value;
  1202. afe_get_island_mode_cfg(port_id, &value);
  1203. ucontrol->value.integer.value[0] = value;
  1204. return 0;
  1205. }
  1206. static void island_mx_ctl_private_free(struct snd_kcontrol *kcontrol)
  1207. {
  1208. struct snd_kcontrol_new *knew = snd_kcontrol_chip(kcontrol);
  1209. kfree(knew);
  1210. }
  1211. static int msm_dai_q6_add_island_mx_ctls(struct snd_card *card,
  1212. const char *dai_name,
  1213. int dai_id, void *dai_data)
  1214. {
  1215. const char *mx_ctl_name = "TX island";
  1216. char *mixer_str = NULL;
  1217. int dai_str_len = 0, ctl_len = 0;
  1218. int rc = 0;
  1219. struct snd_kcontrol_new *knew = NULL;
  1220. struct snd_kcontrol *kctl = NULL;
  1221. dai_str_len = strlen(dai_name) + 1;
  1222. /* Add island related mixer controls */
  1223. ctl_len = dai_str_len + strlen(mx_ctl_name) + 1;
  1224. mixer_str = kzalloc(ctl_len, GFP_KERNEL);
  1225. if (!mixer_str)
  1226. return -ENOMEM;
  1227. snprintf(mixer_str, ctl_len, "%s %s", dai_name, mx_ctl_name);
  1228. knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL);
  1229. if (!knew) {
  1230. kfree(mixer_str);
  1231. return -ENOMEM;
  1232. }
  1233. knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  1234. knew->info = snd_ctl_boolean_mono_info;
  1235. knew->get = msm_dai_q6_island_mode_get;
  1236. knew->put = msm_dai_q6_island_mode_put;
  1237. knew->name = mixer_str;
  1238. knew->private_value = dai_id;
  1239. kctl = snd_ctl_new1(knew, knew);
  1240. if (!kctl) {
  1241. kfree(knew);
  1242. kfree(mixer_str);
  1243. return -ENOMEM;
  1244. }
  1245. kctl->private_free = island_mx_ctl_private_free;
  1246. rc = snd_ctl_add(card, kctl);
  1247. if (rc < 0)
  1248. pr_err("%s: err add config ctl, DAI = %s\n",
  1249. __func__, dai_name);
  1250. kfree(mixer_str);
  1251. return rc;
  1252. }
  1253. /*
  1254. * For single CPU DAI registration, the dai id needs to be
  1255. * set explicitly in the dai probe as ASoC does not read
  1256. * the cpu->driver->id field rather it assigns the dai id
  1257. * from the device name that is in the form %s.%d. This dai
  1258. * id should be assigned to back-end AFE port id and used
  1259. * during dai prepare. For multiple dai registration, it
  1260. * is not required to call this function, however the dai->
  1261. * driver->id field must be defined and set to corresponding
  1262. * AFE Port id.
  1263. */
  1264. static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
  1265. {
  1266. if (!dai->driver) {
  1267. dev_err(dai->dev, "DAI driver is not set\n");
  1268. return;
  1269. }
  1270. if (!dai->driver->id) {
  1271. dev_dbg(dai->dev, "DAI driver id is not set\n");
  1272. return;
  1273. }
  1274. dai->id = dai->driver->id;
  1275. }
  1276. static int msm_dai_q6_aux_pcm_probe(struct snd_soc_dai *dai)
  1277. {
  1278. int rc = 0;
  1279. struct msm_dai_q6_auxpcm_dai_data *dai_data = NULL;
  1280. if (!dai) {
  1281. pr_err("%s: Invalid params dai\n", __func__);
  1282. return -EINVAL;
  1283. }
  1284. if (!dai->dev) {
  1285. pr_err("%s: Invalid params dai dev\n", __func__);
  1286. return -EINVAL;
  1287. }
  1288. msm_dai_q6_set_dai_id(dai);
  1289. dai_data = dev_get_drvdata(dai->dev);
  1290. if (dai_data->is_island_dai)
  1291. rc = msm_dai_q6_add_island_mx_ctls(
  1292. dai->component->card->snd_card,
  1293. dai->name, dai_data->tx_pid,
  1294. (void *)dai_data);
  1295. rc = msm_dai_q6_dai_add_route(dai);
  1296. return rc;
  1297. }
  1298. static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
  1299. .prepare = msm_dai_q6_auxpcm_prepare,
  1300. .trigger = msm_dai_q6_auxpcm_trigger,
  1301. .hw_params = msm_dai_q6_auxpcm_hw_params,
  1302. .shutdown = msm_dai_q6_auxpcm_shutdown,
  1303. };
  1304. static const struct snd_soc_component_driver
  1305. msm_dai_q6_aux_pcm_dai_component = {
  1306. .name = "msm-auxpcm-dev",
  1307. };
  1308. static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_dai[] = {
  1309. {
  1310. .playback = {
  1311. .stream_name = "AUX PCM Playback",
  1312. .aif_name = "AUX_PCM_RX",
  1313. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1314. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1315. .channels_min = 1,
  1316. .channels_max = 1,
  1317. .rate_max = 16000,
  1318. .rate_min = 8000,
  1319. },
  1320. .capture = {
  1321. .stream_name = "AUX PCM Capture",
  1322. .aif_name = "AUX_PCM_TX",
  1323. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1324. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1325. .channels_min = 1,
  1326. .channels_max = 1,
  1327. .rate_max = 16000,
  1328. .rate_min = 8000,
  1329. },
  1330. .id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID,
  1331. .name = "Pri AUX PCM",
  1332. .ops = &msm_dai_q6_auxpcm_ops,
  1333. .probe = msm_dai_q6_aux_pcm_probe,
  1334. .remove = msm_dai_q6_dai_auxpcm_remove,
  1335. },
  1336. {
  1337. .playback = {
  1338. .stream_name = "Sec AUX PCM Playback",
  1339. .aif_name = "SEC_AUX_PCM_RX",
  1340. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1341. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1342. .channels_min = 1,
  1343. .channels_max = 1,
  1344. .rate_max = 16000,
  1345. .rate_min = 8000,
  1346. },
  1347. .capture = {
  1348. .stream_name = "Sec AUX PCM Capture",
  1349. .aif_name = "SEC_AUX_PCM_TX",
  1350. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1351. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1352. .channels_min = 1,
  1353. .channels_max = 1,
  1354. .rate_max = 16000,
  1355. .rate_min = 8000,
  1356. },
  1357. .id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID,
  1358. .name = "Sec AUX PCM",
  1359. .ops = &msm_dai_q6_auxpcm_ops,
  1360. .probe = msm_dai_q6_aux_pcm_probe,
  1361. .remove = msm_dai_q6_dai_auxpcm_remove,
  1362. },
  1363. {
  1364. .playback = {
  1365. .stream_name = "Tert AUX PCM Playback",
  1366. .aif_name = "TERT_AUX_PCM_RX",
  1367. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1368. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1369. .channels_min = 1,
  1370. .channels_max = 1,
  1371. .rate_max = 16000,
  1372. .rate_min = 8000,
  1373. },
  1374. .capture = {
  1375. .stream_name = "Tert AUX PCM Capture",
  1376. .aif_name = "TERT_AUX_PCM_TX",
  1377. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1378. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1379. .channels_min = 1,
  1380. .channels_max = 1,
  1381. .rate_max = 16000,
  1382. .rate_min = 8000,
  1383. },
  1384. .id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID,
  1385. .name = "Tert AUX PCM",
  1386. .ops = &msm_dai_q6_auxpcm_ops,
  1387. .probe = msm_dai_q6_aux_pcm_probe,
  1388. .remove = msm_dai_q6_dai_auxpcm_remove,
  1389. },
  1390. {
  1391. .playback = {
  1392. .stream_name = "Quat AUX PCM Playback",
  1393. .aif_name = "QUAT_AUX_PCM_RX",
  1394. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1395. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1396. .channels_min = 1,
  1397. .channels_max = 1,
  1398. .rate_max = 16000,
  1399. .rate_min = 8000,
  1400. },
  1401. .capture = {
  1402. .stream_name = "Quat AUX PCM Capture",
  1403. .aif_name = "QUAT_AUX_PCM_TX",
  1404. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1405. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1406. .channels_min = 1,
  1407. .channels_max = 1,
  1408. .rate_max = 16000,
  1409. .rate_min = 8000,
  1410. },
  1411. .id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID,
  1412. .name = "Quat AUX PCM",
  1413. .ops = &msm_dai_q6_auxpcm_ops,
  1414. .probe = msm_dai_q6_aux_pcm_probe,
  1415. .remove = msm_dai_q6_dai_auxpcm_remove,
  1416. },
  1417. {
  1418. .playback = {
  1419. .stream_name = "Quin AUX PCM Playback",
  1420. .aif_name = "QUIN_AUX_PCM_RX",
  1421. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1422. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1423. .channels_min = 1,
  1424. .channels_max = 1,
  1425. .rate_max = 16000,
  1426. .rate_min = 8000,
  1427. },
  1428. .capture = {
  1429. .stream_name = "Quin AUX PCM Capture",
  1430. .aif_name = "QUIN_AUX_PCM_TX",
  1431. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1432. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1433. .channels_min = 1,
  1434. .channels_max = 1,
  1435. .rate_max = 16000,
  1436. .rate_min = 8000,
  1437. },
  1438. .id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID,
  1439. .name = "Quin AUX PCM",
  1440. .ops = &msm_dai_q6_auxpcm_ops,
  1441. .probe = msm_dai_q6_aux_pcm_probe,
  1442. .remove = msm_dai_q6_dai_auxpcm_remove,
  1443. },
  1444. {
  1445. .playback = {
  1446. .stream_name = "Sen AUX PCM Playback",
  1447. .aif_name = "SEN_AUX_PCM_RX",
  1448. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1449. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1450. .channels_min = 1,
  1451. .channels_max = 1,
  1452. .rate_max = 16000,
  1453. .rate_min = 8000,
  1454. },
  1455. .capture = {
  1456. .stream_name = "Sen AUX PCM Capture",
  1457. .aif_name = "SEN_AUX_PCM_TX",
  1458. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1459. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1460. .channels_min = 1,
  1461. .channels_max = 1,
  1462. .rate_max = 16000,
  1463. .rate_min = 8000,
  1464. },
  1465. .id = MSM_DAI_SEN_AUXPCM_DT_DEV_ID,
  1466. .name = "Sen AUX PCM",
  1467. .ops = &msm_dai_q6_auxpcm_ops,
  1468. .probe = msm_dai_q6_aux_pcm_probe,
  1469. .remove = msm_dai_q6_dai_auxpcm_remove,
  1470. },
  1471. };
  1472. static int msm_dai_q6_spdif_format_put(struct snd_kcontrol *kcontrol,
  1473. struct snd_ctl_elem_value *ucontrol)
  1474. {
  1475. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1476. int value = ucontrol->value.integer.value[0];
  1477. dai_data->spdif_port.cfg.data_format = value;
  1478. pr_debug("%s: value = %d\n", __func__, value);
  1479. return 0;
  1480. }
  1481. static int msm_dai_q6_spdif_format_get(struct snd_kcontrol *kcontrol,
  1482. struct snd_ctl_elem_value *ucontrol)
  1483. {
  1484. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1485. ucontrol->value.integer.value[0] =
  1486. dai_data->spdif_port.cfg.data_format;
  1487. return 0;
  1488. }
  1489. static int msm_dai_q6_spdif_source_put(struct snd_kcontrol *kcontrol,
  1490. struct snd_ctl_elem_value *ucontrol)
  1491. {
  1492. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1493. int value = ucontrol->value.integer.value[0];
  1494. dai_data->spdif_port.cfg.src_sel = value;
  1495. pr_debug("%s: value = %d\n", __func__, value);
  1496. return 0;
  1497. }
  1498. static int msm_dai_q6_spdif_source_get(struct snd_kcontrol *kcontrol,
  1499. struct snd_ctl_elem_value *ucontrol)
  1500. {
  1501. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1502. ucontrol->value.integer.value[0] =
  1503. dai_data->spdif_port.cfg.src_sel;
  1504. return 0;
  1505. }
  1506. static const char * const spdif_format[] = {
  1507. "LPCM",
  1508. "Compr"
  1509. };
  1510. static const char * const spdif_source[] = {
  1511. "Optical", "EXT-ARC", "Coaxial", "VT-ARC"
  1512. };
  1513. static const struct soc_enum spdif_rx_config_enum[] = {
  1514. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1515. };
  1516. static const struct soc_enum spdif_tx_config_enum[] = {
  1517. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_source), spdif_source),
  1518. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spdif_format), spdif_format),
  1519. };
  1520. static int msm_dai_q6_spdif_chstatus_put(struct snd_kcontrol *kcontrol,
  1521. struct snd_ctl_elem_value *ucontrol)
  1522. {
  1523. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1524. int ret = 0;
  1525. dai_data->spdif_port.ch_status.status_type =
  1526. AFE_API_VERSION_SPDIF_CH_STATUS_CONFIG;
  1527. memset(dai_data->spdif_port.ch_status.status_mask,
  1528. CHANNEL_STATUS_MASK_INIT, CHANNEL_STATUS_SIZE);
  1529. dai_data->spdif_port.ch_status.status_mask[0] =
  1530. CHANNEL_STATUS_MASK;
  1531. memcpy(dai_data->spdif_port.ch_status.status_bits,
  1532. ucontrol->value.iec958.status, CHANNEL_STATUS_SIZE);
  1533. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1534. pr_debug("%s: Port already started. Dynamic update\n",
  1535. __func__);
  1536. ret = afe_send_spdif_ch_status_cfg(
  1537. &dai_data->spdif_port.ch_status,
  1538. dai_data->port_id);
  1539. }
  1540. return ret;
  1541. }
  1542. static int msm_dai_q6_spdif_chstatus_get(struct snd_kcontrol *kcontrol,
  1543. struct snd_ctl_elem_value *ucontrol)
  1544. {
  1545. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1546. memcpy(ucontrol->value.iec958.status,
  1547. dai_data->spdif_port.ch_status.status_bits,
  1548. CHANNEL_STATUS_SIZE);
  1549. return 0;
  1550. }
  1551. static int msm_dai_q6_spdif_chstatus_info(struct snd_kcontrol *kcontrol,
  1552. struct snd_ctl_elem_info *uinfo)
  1553. {
  1554. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1555. uinfo->count = 1;
  1556. return 0;
  1557. }
  1558. static const struct snd_kcontrol_new spdif_rx_config_controls[] = {
  1559. /* Primary SPDIF output */
  1560. {
  1561. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1562. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1563. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1564. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
  1565. .info = msm_dai_q6_spdif_chstatus_info,
  1566. .get = msm_dai_q6_spdif_chstatus_get,
  1567. .put = msm_dai_q6_spdif_chstatus_put,
  1568. },
  1569. SOC_ENUM_EXT("PRI SPDIF RX Format", spdif_rx_config_enum[0],
  1570. msm_dai_q6_spdif_format_get,
  1571. msm_dai_q6_spdif_format_put),
  1572. /* Secondary SPDIF output */
  1573. {
  1574. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1575. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1576. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1577. .name = SNDRV_CTL_NAME_IEC958("SEC", PLAYBACK, PCM_STREAM),
  1578. .info = msm_dai_q6_spdif_chstatus_info,
  1579. .get = msm_dai_q6_spdif_chstatus_get,
  1580. .put = msm_dai_q6_spdif_chstatus_put,
  1581. },
  1582. SOC_ENUM_EXT("SEC SPDIF RX Format", spdif_rx_config_enum[0],
  1583. msm_dai_q6_spdif_format_get,
  1584. msm_dai_q6_spdif_format_put)
  1585. };
  1586. static const struct snd_kcontrol_new spdif_tx_config_controls[] = {
  1587. SOC_ENUM_EXT("PRI SPDIF TX Source", spdif_tx_config_enum[0],
  1588. msm_dai_q6_spdif_source_get,
  1589. msm_dai_q6_spdif_source_put),
  1590. SOC_ENUM_EXT("PRI SPDIF TX Format", spdif_tx_config_enum[1],
  1591. msm_dai_q6_spdif_format_get,
  1592. msm_dai_q6_spdif_format_put),
  1593. SOC_ENUM_EXT("SEC SPDIF TX Source", spdif_tx_config_enum[0],
  1594. msm_dai_q6_spdif_source_get,
  1595. msm_dai_q6_spdif_source_put),
  1596. SOC_ENUM_EXT("SEC SPDIF TX Format", spdif_tx_config_enum[1],
  1597. msm_dai_q6_spdif_format_get,
  1598. msm_dai_q6_spdif_format_put)
  1599. };
  1600. static void msm_dai_q6_spdif_process_event(uint32_t opcode, uint32_t token,
  1601. uint32_t *payload, void *private_data)
  1602. {
  1603. struct msm_dai_q6_spdif_event_msg *evt;
  1604. struct msm_dai_q6_spdif_dai_data *dai_data;
  1605. int preemph_old = 0;
  1606. int preemph_new = 0;
  1607. evt = (struct msm_dai_q6_spdif_event_msg *)payload;
  1608. dai_data = (struct msm_dai_q6_spdif_dai_data *)private_data;
  1609. preemph_old = GET_PREEMPH(dai_data->fmt_event.channel_status[0]);
  1610. preemph_new = GET_PREEMPH(evt->fmt_event.channel_status[0]);
  1611. pr_debug("%s: old state %d, fmt %d, rate %d, preemph %d\n",
  1612. __func__, dai_data->fmt_event.status,
  1613. dai_data->fmt_event.data_format,
  1614. dai_data->fmt_event.sample_rate,
  1615. preemph_old);
  1616. pr_debug("%s: new state %d, fmt %d, rate %d, preemph %d\n",
  1617. __func__, evt->fmt_event.status,
  1618. evt->fmt_event.data_format,
  1619. evt->fmt_event.sample_rate,
  1620. preemph_new);
  1621. dai_data->fmt_event.status = evt->fmt_event.status;
  1622. dai_data->fmt_event.data_format = evt->fmt_event.data_format;
  1623. dai_data->fmt_event.sample_rate = evt->fmt_event.sample_rate;
  1624. dai_data->fmt_event.channel_status[0] =
  1625. evt->fmt_event.channel_status[0];
  1626. dai_data->fmt_event.channel_status[1] =
  1627. evt->fmt_event.channel_status[1];
  1628. dai_data->fmt_event.channel_status[2] =
  1629. evt->fmt_event.channel_status[2];
  1630. dai_data->fmt_event.channel_status[3] =
  1631. evt->fmt_event.channel_status[3];
  1632. dai_data->fmt_event.channel_status[4] =
  1633. evt->fmt_event.channel_status[4];
  1634. dai_data->fmt_event.channel_status[5] =
  1635. evt->fmt_event.channel_status[5];
  1636. }
  1637. static int msm_dai_q6_spdif_hw_params(struct snd_pcm_substream *substream,
  1638. struct snd_pcm_hw_params *params,
  1639. struct snd_soc_dai *dai)
  1640. {
  1641. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1642. dai_data->channels = params_channels(params);
  1643. dai_data->spdif_port.cfg.num_channels = dai_data->channels;
  1644. switch (params_format(params)) {
  1645. case SNDRV_PCM_FORMAT_S16_LE:
  1646. dai_data->spdif_port.cfg.bit_width = 16;
  1647. break;
  1648. case SNDRV_PCM_FORMAT_S24_LE:
  1649. case SNDRV_PCM_FORMAT_S24_3LE:
  1650. dai_data->spdif_port.cfg.bit_width = 24;
  1651. break;
  1652. default:
  1653. pr_err("%s: format %d\n",
  1654. __func__, params_format(params));
  1655. return -EINVAL;
  1656. }
  1657. dai_data->rate = params_rate(params);
  1658. dai_data->bitwidth = dai_data->spdif_port.cfg.bit_width;
  1659. dai_data->spdif_port.cfg.sample_rate = dai_data->rate;
  1660. dai_data->spdif_port.cfg.spdif_cfg_minor_version =
  1661. AFE_API_VERSION_SPDIF_CONFIG_V2;
  1662. dev_dbg(dai->dev, " channel %d sample rate %d bit width %d\n",
  1663. dai_data->channels, dai_data->rate,
  1664. dai_data->spdif_port.cfg.bit_width);
  1665. dai_data->spdif_port.cfg.reserved = 0;
  1666. return 0;
  1667. }
  1668. static void msm_dai_q6_spdif_shutdown(struct snd_pcm_substream *substream,
  1669. struct snd_soc_dai *dai)
  1670. {
  1671. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1672. int rc = 0;
  1673. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1674. pr_info("%s: afe port not started. dai_data->status_mask = %ld\n",
  1675. __func__, *dai_data->status_mask);
  1676. return;
  1677. }
  1678. rc = afe_close(dai->id);
  1679. if (rc < 0)
  1680. dev_err(dai->dev, "fail to close AFE port\n");
  1681. dai_data->fmt_event.status = 0; /* report invalid line state */
  1682. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1683. *dai_data->status_mask);
  1684. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1685. }
  1686. static int msm_dai_q6_spdif_prepare(struct snd_pcm_substream *substream,
  1687. struct snd_soc_dai *dai)
  1688. {
  1689. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1690. int rc = 0;
  1691. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1692. rc = afe_spdif_reg_event_cfg(dai->id,
  1693. AFE_MODULE_REGISTER_EVENT_FLAG,
  1694. msm_dai_q6_spdif_process_event,
  1695. dai_data);
  1696. if (rc < 0)
  1697. dev_err(dai->dev,
  1698. "fail to register event for port 0x%x\n",
  1699. dai->id);
  1700. rc = afe_spdif_port_start(dai->id, &dai_data->spdif_port,
  1701. dai_data->rate);
  1702. if (rc < 0)
  1703. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1704. dai->id);
  1705. else
  1706. set_bit(STATUS_PORT_STARTED,
  1707. dai_data->status_mask);
  1708. }
  1709. return rc;
  1710. }
  1711. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_state(struct device *dev,
  1712. struct device_attribute *attr, char *buf)
  1713. {
  1714. ssize_t ret;
  1715. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1716. if (!dai_data) {
  1717. pr_err("%s: invalid input\n", __func__);
  1718. return -EINVAL;
  1719. }
  1720. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1721. dai_data->fmt_event.status);
  1722. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.status);
  1723. return ret;
  1724. }
  1725. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_format(struct device *dev,
  1726. struct device_attribute *attr, char *buf)
  1727. {
  1728. ssize_t ret;
  1729. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1730. if (!dai_data) {
  1731. pr_err("%s: invalid input\n", __func__);
  1732. return -EINVAL;
  1733. }
  1734. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1735. dai_data->fmt_event.data_format);
  1736. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.data_format);
  1737. return ret;
  1738. }
  1739. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_rate(struct device *dev,
  1740. struct device_attribute *attr, char *buf)
  1741. {
  1742. ssize_t ret;
  1743. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1744. if (!dai_data) {
  1745. pr_err("%s: invalid input\n", __func__);
  1746. return -EINVAL;
  1747. }
  1748. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n",
  1749. dai_data->fmt_event.sample_rate);
  1750. pr_debug("%s: '%d'\n", __func__, dai_data->fmt_event.sample_rate);
  1751. return ret;
  1752. }
  1753. static ssize_t msm_dai_q6_spdif_sysfs_rda_audio_preemph(struct device *dev,
  1754. struct device_attribute *attr, char *buf)
  1755. {
  1756. ssize_t ret;
  1757. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dev);
  1758. int preemph = 0;
  1759. if (!dai_data) {
  1760. pr_err("%s: invalid input\n", __func__);
  1761. return -EINVAL;
  1762. }
  1763. preemph = GET_PREEMPH(dai_data->fmt_event.channel_status[0]);
  1764. ret = snprintf(buf, MSM_DAI_SYSFS_ENTRY_MAX_LEN, "%d\n", preemph);
  1765. pr_debug("%s: '%d'\n", __func__, preemph);
  1766. return ret;
  1767. }
  1768. static DEVICE_ATTR(audio_state, 0444, msm_dai_q6_spdif_sysfs_rda_audio_state,
  1769. NULL);
  1770. static DEVICE_ATTR(audio_format, 0444, msm_dai_q6_spdif_sysfs_rda_audio_format,
  1771. NULL);
  1772. static DEVICE_ATTR(audio_rate, 0444, msm_dai_q6_spdif_sysfs_rda_audio_rate,
  1773. NULL);
  1774. static DEVICE_ATTR(audio_preemph, 0444,
  1775. msm_dai_q6_spdif_sysfs_rda_audio_preemph, NULL);
  1776. static struct attribute *msm_dai_q6_spdif_fs_attrs[] = {
  1777. &dev_attr_audio_state.attr,
  1778. &dev_attr_audio_format.attr,
  1779. &dev_attr_audio_rate.attr,
  1780. &dev_attr_audio_preemph.attr,
  1781. NULL,
  1782. };
  1783. static struct attribute_group msm_dai_q6_spdif_fs_attrs_group = {
  1784. .attrs = msm_dai_q6_spdif_fs_attrs,
  1785. };
  1786. static int msm_dai_q6_spdif_sysfs_create(struct snd_soc_dai *dai,
  1787. struct msm_dai_q6_spdif_dai_data *dai_data)
  1788. {
  1789. int rc;
  1790. rc = sysfs_create_group(&dai->dev->kobj,
  1791. &msm_dai_q6_spdif_fs_attrs_group);
  1792. if (rc) {
  1793. pr_err("%s: failed, rc=%d\n", __func__, rc);
  1794. return rc;
  1795. }
  1796. dai_data->kobj = &dai->dev->kobj;
  1797. return 0;
  1798. }
  1799. static void msm_dai_q6_spdif_sysfs_remove(struct snd_soc_dai *dai,
  1800. struct msm_dai_q6_spdif_dai_data *dai_data)
  1801. {
  1802. if (dai_data->kobj)
  1803. sysfs_remove_group(dai_data->kobj,
  1804. &msm_dai_q6_spdif_fs_attrs_group);
  1805. dai_data->kobj = NULL;
  1806. }
  1807. static int msm_dai_q6_spdif_dai_probe(struct snd_soc_dai *dai)
  1808. {
  1809. struct msm_dai_q6_spdif_dai_data *dai_data;
  1810. int rc = 0;
  1811. struct snd_soc_dapm_route intercon;
  1812. struct snd_soc_dapm_context *dapm;
  1813. if (!dai) {
  1814. pr_err("%s: dai not found!!\n", __func__);
  1815. return -EINVAL;
  1816. }
  1817. if (!dai->dev) {
  1818. pr_err("%s: Invalid params dai dev\n", __func__);
  1819. return -EINVAL;
  1820. }
  1821. dai_data = kzalloc(sizeof(struct msm_dai_q6_spdif_dai_data),
  1822. GFP_KERNEL);
  1823. if (!dai_data)
  1824. return -ENOMEM;
  1825. else
  1826. dev_set_drvdata(dai->dev, dai_data);
  1827. msm_dai_q6_set_dai_id(dai);
  1828. dai_data->port_id = dai->id;
  1829. switch (dai->id) {
  1830. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  1831. rc = snd_ctl_add(dai->component->card->snd_card,
  1832. snd_ctl_new1(&spdif_rx_config_controls[1],
  1833. dai_data));
  1834. break;
  1835. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  1836. rc = snd_ctl_add(dai->component->card->snd_card,
  1837. snd_ctl_new1(&spdif_rx_config_controls[3],
  1838. dai_data));
  1839. break;
  1840. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  1841. rc = msm_dai_q6_spdif_sysfs_create(dai, dai_data);
  1842. rc = snd_ctl_add(dai->component->card->snd_card,
  1843. snd_ctl_new1(&spdif_tx_config_controls[0],
  1844. dai_data));
  1845. rc = snd_ctl_add(dai->component->card->snd_card,
  1846. snd_ctl_new1(&spdif_tx_config_controls[1],
  1847. dai_data));
  1848. break;
  1849. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  1850. rc = msm_dai_q6_spdif_sysfs_create(dai, dai_data);
  1851. rc = snd_ctl_add(dai->component->card->snd_card,
  1852. snd_ctl_new1(&spdif_tx_config_controls[2],
  1853. dai_data));
  1854. rc = snd_ctl_add(dai->component->card->snd_card,
  1855. snd_ctl_new1(&spdif_tx_config_controls[3],
  1856. dai_data));
  1857. break;
  1858. }
  1859. if (rc < 0)
  1860. dev_err(dai->dev,
  1861. "%s: err add config ctl, DAI = %s\n",
  1862. __func__, dai->name);
  1863. dapm = snd_soc_component_get_dapm(dai->component);
  1864. memset(&intercon, 0, sizeof(intercon));
  1865. if (!rc && dai && dai->driver) {
  1866. if (dai->driver->playback.stream_name &&
  1867. dai->driver->playback.aif_name) {
  1868. dev_dbg(dai->dev, "%s: add route for widget %s",
  1869. __func__, dai->driver->playback.stream_name);
  1870. intercon.source = dai->driver->playback.aif_name;
  1871. intercon.sink = dai->driver->playback.stream_name;
  1872. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1873. __func__, intercon.source, intercon.sink);
  1874. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1875. }
  1876. if (dai->driver->capture.stream_name &&
  1877. dai->driver->capture.aif_name) {
  1878. dev_dbg(dai->dev, "%s: add route for widget %s",
  1879. __func__, dai->driver->capture.stream_name);
  1880. intercon.sink = dai->driver->capture.aif_name;
  1881. intercon.source = dai->driver->capture.stream_name;
  1882. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1883. __func__, intercon.source, intercon.sink);
  1884. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1885. }
  1886. }
  1887. return rc;
  1888. }
  1889. static int msm_dai_q6_spdif_dai_remove(struct snd_soc_dai *dai)
  1890. {
  1891. struct msm_dai_q6_spdif_dai_data *dai_data;
  1892. int rc;
  1893. dai_data = dev_get_drvdata(dai->dev);
  1894. /* If AFE port is still up, close it */
  1895. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1896. rc = afe_spdif_reg_event_cfg(dai->id,
  1897. AFE_MODULE_DEREGISTER_EVENT_FLAG,
  1898. NULL,
  1899. dai_data);
  1900. if (rc < 0)
  1901. dev_err(dai->dev,
  1902. "fail to deregister event for port 0x%x\n",
  1903. dai->id);
  1904. rc = afe_close(dai->id); /* can block */
  1905. if (rc < 0)
  1906. dev_err(dai->dev, "fail to close AFE port\n");
  1907. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1908. }
  1909. msm_dai_q6_spdif_sysfs_remove(dai, dai_data);
  1910. kfree(dai_data);
  1911. return 0;
  1912. }
  1913. static struct snd_soc_dai_ops msm_dai_q6_spdif_ops = {
  1914. .prepare = msm_dai_q6_spdif_prepare,
  1915. .hw_params = msm_dai_q6_spdif_hw_params,
  1916. .shutdown = msm_dai_q6_spdif_shutdown,
  1917. };
  1918. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_rx_dai[] = {
  1919. {
  1920. .playback = {
  1921. .stream_name = "Primary SPDIF Playback",
  1922. .aif_name = "PRI_SPDIF_RX",
  1923. .rates = SNDRV_PCM_RATE_32000 |
  1924. SNDRV_PCM_RATE_44100 |
  1925. SNDRV_PCM_RATE_48000 |
  1926. SNDRV_PCM_RATE_88200 |
  1927. SNDRV_PCM_RATE_96000 |
  1928. SNDRV_PCM_RATE_176400 |
  1929. SNDRV_PCM_RATE_192000,
  1930. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1931. SNDRV_PCM_FMTBIT_S24_LE,
  1932. .channels_min = 1,
  1933. .channels_max = 2,
  1934. .rate_min = 32000,
  1935. .rate_max = 192000,
  1936. },
  1937. .name = "PRI_SPDIF_RX",
  1938. .ops = &msm_dai_q6_spdif_ops,
  1939. .id = AFE_PORT_ID_PRIMARY_SPDIF_RX,
  1940. .probe = msm_dai_q6_spdif_dai_probe,
  1941. .remove = msm_dai_q6_spdif_dai_remove,
  1942. },
  1943. {
  1944. .playback = {
  1945. .stream_name = "Secondary SPDIF Playback",
  1946. .aif_name = "SEC_SPDIF_RX",
  1947. .rates = SNDRV_PCM_RATE_32000 |
  1948. SNDRV_PCM_RATE_44100 |
  1949. SNDRV_PCM_RATE_48000 |
  1950. SNDRV_PCM_RATE_88200 |
  1951. SNDRV_PCM_RATE_96000 |
  1952. SNDRV_PCM_RATE_176400 |
  1953. SNDRV_PCM_RATE_192000,
  1954. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1955. SNDRV_PCM_FMTBIT_S24_LE,
  1956. .channels_min = 1,
  1957. .channels_max = 2,
  1958. .rate_min = 32000,
  1959. .rate_max = 192000,
  1960. },
  1961. .name = "SEC_SPDIF_RX",
  1962. .ops = &msm_dai_q6_spdif_ops,
  1963. .id = AFE_PORT_ID_SECONDARY_SPDIF_RX,
  1964. .probe = msm_dai_q6_spdif_dai_probe,
  1965. .remove = msm_dai_q6_spdif_dai_remove,
  1966. },
  1967. };
  1968. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_tx_dai[] = {
  1969. {
  1970. .capture = {
  1971. .stream_name = "Primary SPDIF Capture",
  1972. .aif_name = "PRI_SPDIF_TX",
  1973. .rates = SNDRV_PCM_RATE_32000 |
  1974. SNDRV_PCM_RATE_44100 |
  1975. SNDRV_PCM_RATE_48000 |
  1976. SNDRV_PCM_RATE_88200 |
  1977. SNDRV_PCM_RATE_96000 |
  1978. SNDRV_PCM_RATE_176400 |
  1979. SNDRV_PCM_RATE_192000,
  1980. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  1981. SNDRV_PCM_FMTBIT_S24_LE,
  1982. .channels_min = 1,
  1983. .channels_max = 2,
  1984. .rate_min = 32000,
  1985. .rate_max = 192000,
  1986. },
  1987. .name = "PRI_SPDIF_TX",
  1988. .ops = &msm_dai_q6_spdif_ops,
  1989. .id = AFE_PORT_ID_PRIMARY_SPDIF_TX,
  1990. .probe = msm_dai_q6_spdif_dai_probe,
  1991. .remove = msm_dai_q6_spdif_dai_remove,
  1992. },
  1993. {
  1994. .capture = {
  1995. .stream_name = "Secondary SPDIF Capture",
  1996. .aif_name = "SEC_SPDIF_TX",
  1997. .rates = SNDRV_PCM_RATE_32000 |
  1998. SNDRV_PCM_RATE_44100 |
  1999. SNDRV_PCM_RATE_48000 |
  2000. SNDRV_PCM_RATE_88200 |
  2001. SNDRV_PCM_RATE_96000 |
  2002. SNDRV_PCM_RATE_176400 |
  2003. SNDRV_PCM_RATE_192000,
  2004. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2005. SNDRV_PCM_FMTBIT_S24_LE,
  2006. .channels_min = 1,
  2007. .channels_max = 2,
  2008. .rate_min = 32000,
  2009. .rate_max = 192000,
  2010. },
  2011. .name = "SEC_SPDIF_TX",
  2012. .ops = &msm_dai_q6_spdif_ops,
  2013. .id = AFE_PORT_ID_SECONDARY_SPDIF_TX,
  2014. .probe = msm_dai_q6_spdif_dai_probe,
  2015. .remove = msm_dai_q6_spdif_dai_remove,
  2016. },
  2017. };
  2018. static const struct snd_soc_component_driver msm_dai_spdif_q6_component = {
  2019. .name = "msm-dai-q6-spdif",
  2020. };
  2021. static int msm_dai_q6_prepare(struct snd_pcm_substream *substream,
  2022. struct snd_soc_dai *dai)
  2023. {
  2024. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2025. int rc = 0;
  2026. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2027. if (dai_data->enc_config.format != ENC_FMT_NONE) {
  2028. int bitwidth = 0;
  2029. switch (dai_data->afe_rx_in_bitformat) {
  2030. case SNDRV_PCM_FORMAT_S32_LE:
  2031. bitwidth = 32;
  2032. break;
  2033. case SNDRV_PCM_FORMAT_S24_LE:
  2034. bitwidth = 24;
  2035. break;
  2036. case SNDRV_PCM_FORMAT_S16_LE:
  2037. default:
  2038. bitwidth = 16;
  2039. break;
  2040. }
  2041. pr_debug("%s: calling AFE_PORT_START_V2 with enc_format: %d\n",
  2042. __func__, dai_data->enc_config.format);
  2043. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  2044. dai_data->rate,
  2045. dai_data->afe_rx_in_channels,
  2046. bitwidth,
  2047. &dai_data->enc_config, NULL);
  2048. if (rc < 0)
  2049. pr_err("%s: afe_port_start_v2 failed error: %d\n",
  2050. __func__, rc);
  2051. } else if (dai_data->dec_config.format != DEC_FMT_NONE) {
  2052. int bitwidth = 0;
  2053. /*
  2054. * If bitwidth is not configured set default value to
  2055. * zero, so that decoder port config uses slim device
  2056. * bit width value in afe decoder config.
  2057. */
  2058. switch (dai_data->afe_tx_out_bitformat) {
  2059. case SNDRV_PCM_FORMAT_S32_LE:
  2060. bitwidth = 32;
  2061. break;
  2062. case SNDRV_PCM_FORMAT_S24_LE:
  2063. bitwidth = 24;
  2064. break;
  2065. case SNDRV_PCM_FORMAT_S16_LE:
  2066. bitwidth = 16;
  2067. break;
  2068. default:
  2069. bitwidth = 0;
  2070. break;
  2071. }
  2072. pr_debug("%s: calling AFE_PORT_START_V2 with dec format: %d\n",
  2073. __func__, dai_data->dec_config.format);
  2074. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  2075. dai_data->rate,
  2076. dai_data->afe_tx_out_channels,
  2077. bitwidth,
  2078. NULL, &dai_data->dec_config);
  2079. if (rc < 0) {
  2080. pr_err("%s: fail to open AFE port 0x%x\n",
  2081. __func__, dai->id);
  2082. }
  2083. } else {
  2084. rc = afe_port_start(dai->id, &dai_data->port_config,
  2085. dai_data->rate);
  2086. }
  2087. if (rc < 0)
  2088. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  2089. dai->id);
  2090. else
  2091. set_bit(STATUS_PORT_STARTED,
  2092. dai_data->status_mask);
  2093. }
  2094. return rc;
  2095. }
  2096. static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params,
  2097. struct snd_soc_dai *dai, int stream)
  2098. {
  2099. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2100. dai_data->channels = params_channels(params);
  2101. switch (dai_data->channels) {
  2102. case 2:
  2103. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  2104. break;
  2105. case 1:
  2106. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  2107. break;
  2108. default:
  2109. return -EINVAL;
  2110. pr_err("%s: err channels %d\n",
  2111. __func__, dai_data->channels);
  2112. break;
  2113. }
  2114. switch (params_format(params)) {
  2115. case SNDRV_PCM_FORMAT_S16_LE:
  2116. case SNDRV_PCM_FORMAT_SPECIAL:
  2117. dai_data->port_config.i2s.bit_width = 16;
  2118. break;
  2119. case SNDRV_PCM_FORMAT_S24_LE:
  2120. case SNDRV_PCM_FORMAT_S24_3LE:
  2121. dai_data->port_config.i2s.bit_width = 24;
  2122. break;
  2123. default:
  2124. pr_err("%s: format %d\n",
  2125. __func__, params_format(params));
  2126. return -EINVAL;
  2127. }
  2128. dai_data->rate = params_rate(params);
  2129. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  2130. dai_data->port_config.i2s.i2s_cfg_minor_version =
  2131. AFE_API_VERSION_I2S_CONFIG;
  2132. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  2133. dev_dbg(dai->dev, " channel %d sample rate %d entered\n",
  2134. dai_data->channels, dai_data->rate);
  2135. dai_data->port_config.i2s.channel_mode = 1;
  2136. return 0;
  2137. }
  2138. static u16 num_of_bits_set(u16 sd_line_mask)
  2139. {
  2140. u8 num_bits_set = 0;
  2141. while (sd_line_mask) {
  2142. num_bits_set++;
  2143. sd_line_mask = sd_line_mask & (sd_line_mask - 1);
  2144. }
  2145. return num_bits_set;
  2146. }
  2147. static int msm_dai_q6_i2s_hw_params(struct snd_pcm_hw_params *params,
  2148. struct snd_soc_dai *dai, int stream)
  2149. {
  2150. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2151. struct msm_i2s_data *i2s_pdata =
  2152. (struct msm_i2s_data *) dai->dev->platform_data;
  2153. dai_data->channels = params_channels(params);
  2154. if (num_of_bits_set(i2s_pdata->sd_lines) == 1) {
  2155. switch (dai_data->channels) {
  2156. case 2:
  2157. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  2158. break;
  2159. case 1:
  2160. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  2161. break;
  2162. default:
  2163. pr_warn("%s: greater than stereo has not been validated %d",
  2164. __func__, dai_data->channels);
  2165. break;
  2166. }
  2167. }
  2168. dai_data->rate = params_rate(params);
  2169. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  2170. dai_data->port_config.i2s.i2s_cfg_minor_version =
  2171. AFE_API_VERSION_I2S_CONFIG;
  2172. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  2173. /* Q6 only supports 16 as now */
  2174. dai_data->port_config.i2s.bit_width = 16;
  2175. dai_data->port_config.i2s.channel_mode = 1;
  2176. return 0;
  2177. }
  2178. static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params,
  2179. struct snd_soc_dai *dai, int stream)
  2180. {
  2181. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2182. dai_data->channels = params_channels(params);
  2183. dai_data->rate = params_rate(params);
  2184. switch (params_format(params)) {
  2185. case SNDRV_PCM_FORMAT_S16_LE:
  2186. case SNDRV_PCM_FORMAT_SPECIAL:
  2187. dai_data->port_config.slim_sch.bit_width = 16;
  2188. break;
  2189. case SNDRV_PCM_FORMAT_S24_LE:
  2190. case SNDRV_PCM_FORMAT_S24_3LE:
  2191. dai_data->port_config.slim_sch.bit_width = 24;
  2192. break;
  2193. case SNDRV_PCM_FORMAT_S32_LE:
  2194. dai_data->port_config.slim_sch.bit_width = 32;
  2195. break;
  2196. default:
  2197. pr_err("%s: format %d\n",
  2198. __func__, params_format(params));
  2199. return -EINVAL;
  2200. }
  2201. dai_data->port_config.slim_sch.sb_cfg_minor_version =
  2202. AFE_API_VERSION_SLIMBUS_CONFIG;
  2203. dai_data->port_config.slim_sch.sample_rate = dai_data->rate;
  2204. dai_data->port_config.slim_sch.num_channels = dai_data->channels;
  2205. dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n"
  2206. "num_channel %hu shared_ch_mapping[0] %hu\n"
  2207. "slave_port_mapping[1] %hu slave_port_mapping[2] %hu\n"
  2208. "sample_rate %d\n", __func__,
  2209. dai_data->port_config.slim_sch.slimbus_dev_id,
  2210. dai_data->port_config.slim_sch.bit_width,
  2211. dai_data->port_config.slim_sch.data_format,
  2212. dai_data->port_config.slim_sch.num_channels,
  2213. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2214. dai_data->port_config.slim_sch.shared_ch_mapping[1],
  2215. dai_data->port_config.slim_sch.shared_ch_mapping[2],
  2216. dai_data->rate);
  2217. return 0;
  2218. }
  2219. static int msm_dai_q6_usb_audio_hw_params(struct snd_pcm_hw_params *params,
  2220. struct snd_soc_dai *dai, int stream)
  2221. {
  2222. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2223. dai_data->channels = params_channels(params);
  2224. dai_data->rate = params_rate(params);
  2225. switch (params_format(params)) {
  2226. case SNDRV_PCM_FORMAT_S16_LE:
  2227. case SNDRV_PCM_FORMAT_SPECIAL:
  2228. dai_data->port_config.usb_audio.bit_width = 16;
  2229. break;
  2230. case SNDRV_PCM_FORMAT_S24_LE:
  2231. case SNDRV_PCM_FORMAT_S24_3LE:
  2232. dai_data->port_config.usb_audio.bit_width = 24;
  2233. break;
  2234. case SNDRV_PCM_FORMAT_S32_LE:
  2235. dai_data->port_config.usb_audio.bit_width = 32;
  2236. break;
  2237. default:
  2238. dev_err(dai->dev, "%s: invalid format %d\n",
  2239. __func__, params_format(params));
  2240. return -EINVAL;
  2241. }
  2242. dai_data->port_config.usb_audio.cfg_minor_version =
  2243. AFE_API_MINOR_VERSION_USB_AUDIO_CONFIG;
  2244. dai_data->port_config.usb_audio.num_channels = dai_data->channels;
  2245. dai_data->port_config.usb_audio.sample_rate = dai_data->rate;
  2246. dev_dbg(dai->dev, "%s: dev_id[0x%x] bit_wd[%hu] format[%hu]\n"
  2247. "num_channel %hu sample_rate %d\n", __func__,
  2248. dai_data->port_config.usb_audio.dev_token,
  2249. dai_data->port_config.usb_audio.bit_width,
  2250. dai_data->port_config.usb_audio.data_format,
  2251. dai_data->port_config.usb_audio.num_channels,
  2252. dai_data->port_config.usb_audio.sample_rate);
  2253. return 0;
  2254. }
  2255. static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params,
  2256. struct snd_soc_dai *dai, int stream)
  2257. {
  2258. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2259. dai_data->channels = params_channels(params);
  2260. dai_data->rate = params_rate(params);
  2261. dev_dbg(dai->dev, "channels %d sample rate %d entered\n",
  2262. dai_data->channels, dai_data->rate);
  2263. memset(&dai_data->port_config, 0, sizeof(dai_data->port_config));
  2264. pr_debug("%s: setting bt_fm parameters\n", __func__);
  2265. dai_data->port_config.int_bt_fm.bt_fm_cfg_minor_version =
  2266. AFE_API_VERSION_INTERNAL_BT_FM_CONFIG;
  2267. dai_data->port_config.int_bt_fm.num_channels = dai_data->channels;
  2268. dai_data->port_config.int_bt_fm.sample_rate = dai_data->rate;
  2269. dai_data->port_config.int_bt_fm.bit_width = 16;
  2270. return 0;
  2271. }
  2272. static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
  2273. struct snd_soc_dai *dai)
  2274. {
  2275. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2276. dai_data->rate = params_rate(params);
  2277. dai_data->port_config.rtproxy.num_channels = params_channels(params);
  2278. dai_data->port_config.rtproxy.sample_rate = params_rate(params);
  2279. pr_debug("channel %d entered,dai_id: %d,rate: %d\n",
  2280. dai_data->port_config.rtproxy.num_channels, dai->id, dai_data->rate);
  2281. dai_data->port_config.rtproxy.rt_proxy_cfg_minor_version =
  2282. AFE_API_VERSION_RT_PROXY_CONFIG;
  2283. dai_data->port_config.rtproxy.bit_width = 16; /* Q6 only supports 16 */
  2284. dai_data->port_config.rtproxy.interleaved = 1;
  2285. dai_data->port_config.rtproxy.frame_size = params_period_bytes(params);
  2286. dai_data->port_config.rtproxy.jitter_allowance =
  2287. dai_data->port_config.rtproxy.frame_size/2;
  2288. dai_data->port_config.rtproxy.low_water_mark = 0;
  2289. dai_data->port_config.rtproxy.high_water_mark = 0;
  2290. return 0;
  2291. }
  2292. static int msm_dai_q6_pseudo_port_hw_params(struct snd_pcm_hw_params *params,
  2293. struct snd_soc_dai *dai, int stream)
  2294. {
  2295. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2296. dai_data->channels = params_channels(params);
  2297. dai_data->rate = params_rate(params);
  2298. /* Q6 only supports 16 as now */
  2299. dai_data->port_config.pseudo_port.pseud_port_cfg_minor_version =
  2300. AFE_API_VERSION_PSEUDO_PORT_CONFIG;
  2301. dai_data->port_config.pseudo_port.num_channels =
  2302. params_channels(params);
  2303. dai_data->port_config.pseudo_port.bit_width = 16;
  2304. dai_data->port_config.pseudo_port.data_format = 0;
  2305. dai_data->port_config.pseudo_port.timing_mode =
  2306. AFE_PSEUDOPORT_TIMING_MODE_TIMER;
  2307. dai_data->port_config.pseudo_port.sample_rate = params_rate(params);
  2308. dev_dbg(dai->dev, "%s: bit_wd[%hu] num_channels [%hu] format[%hu]\n"
  2309. "timing Mode %hu sample_rate %d\n", __func__,
  2310. dai_data->port_config.pseudo_port.bit_width,
  2311. dai_data->port_config.pseudo_port.num_channels,
  2312. dai_data->port_config.pseudo_port.data_format,
  2313. dai_data->port_config.pseudo_port.timing_mode,
  2314. dai_data->port_config.pseudo_port.sample_rate);
  2315. return 0;
  2316. }
  2317. /* Current implementation assumes hw_param is called once
  2318. * This may not be the case but what to do when ADM and AFE
  2319. * port are already opened and parameter changes
  2320. */
  2321. static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream,
  2322. struct snd_pcm_hw_params *params,
  2323. struct snd_soc_dai *dai)
  2324. {
  2325. int rc = 0;
  2326. switch (dai->id) {
  2327. case PRIMARY_I2S_TX:
  2328. case PRIMARY_I2S_RX:
  2329. case SECONDARY_I2S_RX:
  2330. rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream);
  2331. break;
  2332. case MI2S_RX:
  2333. rc = msm_dai_q6_i2s_hw_params(params, dai, substream->stream);
  2334. break;
  2335. case SLIMBUS_0_RX:
  2336. case SLIMBUS_1_RX:
  2337. case SLIMBUS_2_RX:
  2338. case SLIMBUS_3_RX:
  2339. case SLIMBUS_4_RX:
  2340. case SLIMBUS_5_RX:
  2341. case SLIMBUS_6_RX:
  2342. case SLIMBUS_7_RX:
  2343. case SLIMBUS_8_RX:
  2344. case SLIMBUS_9_RX:
  2345. case SLIMBUS_0_TX:
  2346. case SLIMBUS_1_TX:
  2347. case SLIMBUS_2_TX:
  2348. case SLIMBUS_3_TX:
  2349. case SLIMBUS_4_TX:
  2350. case SLIMBUS_5_TX:
  2351. case SLIMBUS_6_TX:
  2352. case SLIMBUS_7_TX:
  2353. case SLIMBUS_8_TX:
  2354. case SLIMBUS_9_TX:
  2355. rc = msm_dai_q6_slim_bus_hw_params(params, dai,
  2356. substream->stream);
  2357. break;
  2358. case INT_BT_SCO_RX:
  2359. case INT_BT_SCO_TX:
  2360. case INT_BT_A2DP_RX:
  2361. case INT_FM_RX:
  2362. case INT_FM_TX:
  2363. rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream);
  2364. break;
  2365. case AFE_PORT_ID_USB_RX:
  2366. case AFE_PORT_ID_USB_TX:
  2367. rc = msm_dai_q6_usb_audio_hw_params(params, dai,
  2368. substream->stream);
  2369. break;
  2370. case RT_PROXY_DAI_001_TX:
  2371. case RT_PROXY_DAI_001_RX:
  2372. case RT_PROXY_DAI_002_TX:
  2373. case RT_PROXY_DAI_002_RX:
  2374. rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai);
  2375. break;
  2376. case VOICE_PLAYBACK_TX:
  2377. case VOICE2_PLAYBACK_TX:
  2378. case VOICE_RECORD_RX:
  2379. case VOICE_RECORD_TX:
  2380. rc = msm_dai_q6_pseudo_port_hw_params(params,
  2381. dai, substream->stream);
  2382. break;
  2383. default:
  2384. dev_err(dai->dev, "invalid AFE port ID 0x%x\n", dai->id);
  2385. rc = -EINVAL;
  2386. break;
  2387. }
  2388. return rc;
  2389. }
  2390. static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream,
  2391. struct snd_soc_dai *dai)
  2392. {
  2393. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2394. int rc = 0;
  2395. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2396. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  2397. rc = afe_close(dai->id); /* can block */
  2398. if (rc < 0)
  2399. dev_err(dai->dev, "fail to close AFE port\n");
  2400. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  2401. *dai_data->status_mask);
  2402. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2403. }
  2404. }
  2405. static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2406. {
  2407. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2408. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  2409. case SND_SOC_DAIFMT_CBS_CFS:
  2410. dai_data->port_config.i2s.ws_src = 1; /* CPU is master */
  2411. break;
  2412. case SND_SOC_DAIFMT_CBM_CFM:
  2413. dai_data->port_config.i2s.ws_src = 0; /* CPU is slave */
  2414. break;
  2415. default:
  2416. pr_err("%s: fmt 0x%x\n",
  2417. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  2418. return -EINVAL;
  2419. }
  2420. return 0;
  2421. }
  2422. static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  2423. {
  2424. int rc = 0;
  2425. dev_dbg(dai->dev, "%s: id = %d fmt[%d]\n", __func__,
  2426. dai->id, fmt);
  2427. switch (dai->id) {
  2428. case PRIMARY_I2S_TX:
  2429. case PRIMARY_I2S_RX:
  2430. case MI2S_RX:
  2431. case SECONDARY_I2S_RX:
  2432. rc = msm_dai_q6_cdc_set_fmt(dai, fmt);
  2433. break;
  2434. default:
  2435. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2436. rc = -EINVAL;
  2437. break;
  2438. }
  2439. return rc;
  2440. }
  2441. static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai,
  2442. unsigned int tx_num, unsigned int *tx_slot,
  2443. unsigned int rx_num, unsigned int *rx_slot)
  2444. {
  2445. int rc = 0;
  2446. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2447. unsigned int i = 0;
  2448. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  2449. switch (dai->id) {
  2450. case SLIMBUS_0_RX:
  2451. case SLIMBUS_1_RX:
  2452. case SLIMBUS_2_RX:
  2453. case SLIMBUS_3_RX:
  2454. case SLIMBUS_4_RX:
  2455. case SLIMBUS_5_RX:
  2456. case SLIMBUS_6_RX:
  2457. case SLIMBUS_7_RX:
  2458. case SLIMBUS_8_RX:
  2459. case SLIMBUS_9_RX:
  2460. /*
  2461. * channel number to be between 128 and 255.
  2462. * For RX port use channel numbers
  2463. * from 138 to 144 for pre-Taiko
  2464. * from 144 to 159 for Taiko
  2465. */
  2466. if (!rx_slot) {
  2467. pr_err("%s: rx slot not found\n", __func__);
  2468. return -EINVAL;
  2469. }
  2470. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  2471. pr_err("%s: invalid rx num %d\n", __func__, rx_num);
  2472. return -EINVAL;
  2473. }
  2474. for (i = 0; i < rx_num; i++) {
  2475. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  2476. rx_slot[i];
  2477. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  2478. __func__, i, rx_slot[i]);
  2479. }
  2480. dai_data->port_config.slim_sch.num_channels = rx_num;
  2481. pr_debug("%s: SLIMBUS_%d_RX cnt[%d] ch[%d %d]\n", __func__,
  2482. (dai->id - SLIMBUS_0_RX) / 2, rx_num,
  2483. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2484. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2485. break;
  2486. case SLIMBUS_0_TX:
  2487. case SLIMBUS_1_TX:
  2488. case SLIMBUS_2_TX:
  2489. case SLIMBUS_3_TX:
  2490. case SLIMBUS_4_TX:
  2491. case SLIMBUS_5_TX:
  2492. case SLIMBUS_6_TX:
  2493. case SLIMBUS_7_TX:
  2494. case SLIMBUS_8_TX:
  2495. case SLIMBUS_9_TX:
  2496. /*
  2497. * channel number to be between 128 and 255.
  2498. * For TX port use channel numbers
  2499. * from 128 to 137 for pre-Taiko
  2500. * from 128 to 143 for Taiko
  2501. */
  2502. if (!tx_slot) {
  2503. pr_err("%s: tx slot not found\n", __func__);
  2504. return -EINVAL;
  2505. }
  2506. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  2507. pr_err("%s: invalid tx num %d\n", __func__, tx_num);
  2508. return -EINVAL;
  2509. }
  2510. for (i = 0; i < tx_num; i++) {
  2511. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  2512. tx_slot[i];
  2513. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  2514. __func__, i, tx_slot[i]);
  2515. }
  2516. dai_data->port_config.slim_sch.num_channels = tx_num;
  2517. pr_debug("%s:SLIMBUS_%d_TX cnt[%d] ch[%d %d]\n", __func__,
  2518. (dai->id - SLIMBUS_0_TX) / 2, tx_num,
  2519. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2520. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2521. break;
  2522. default:
  2523. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2524. rc = -EINVAL;
  2525. break;
  2526. }
  2527. return rc;
  2528. }
  2529. /* all ports with excursion logging requirement can use this digital_mute api */
  2530. static int msm_dai_q6_spk_digital_mute(struct snd_soc_dai *dai,
  2531. int mute)
  2532. {
  2533. int port_id = dai->id;
  2534. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2535. if (mute && !dai_data->xt_logging_disable)
  2536. afe_get_sp_xt_logging_data(port_id);
  2537. return 0;
  2538. }
  2539. static struct snd_soc_dai_ops msm_dai_q6_ops = {
  2540. .prepare = msm_dai_q6_prepare,
  2541. .hw_params = msm_dai_q6_hw_params,
  2542. .shutdown = msm_dai_q6_shutdown,
  2543. .set_fmt = msm_dai_q6_set_fmt,
  2544. .set_channel_map = msm_dai_q6_set_channel_map,
  2545. };
  2546. static struct snd_soc_dai_ops msm_dai_slimbus_0_rx_ops = {
  2547. .prepare = msm_dai_q6_prepare,
  2548. .hw_params = msm_dai_q6_hw_params,
  2549. .shutdown = msm_dai_q6_shutdown,
  2550. .set_fmt = msm_dai_q6_set_fmt,
  2551. .set_channel_map = msm_dai_q6_set_channel_map,
  2552. .digital_mute = msm_dai_q6_spk_digital_mute,
  2553. };
  2554. static int msm_dai_q6_cal_info_put(struct snd_kcontrol *kcontrol,
  2555. struct snd_ctl_elem_value *ucontrol)
  2556. {
  2557. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2558. u16 port_id = ((struct soc_enum *)
  2559. kcontrol->private_value)->reg;
  2560. dai_data->cal_mode = ucontrol->value.integer.value[0];
  2561. pr_debug("%s: setting cal_mode to %d\n",
  2562. __func__, dai_data->cal_mode);
  2563. afe_set_cal_mode(port_id, dai_data->cal_mode);
  2564. return 0;
  2565. }
  2566. static int msm_dai_q6_cal_info_get(struct snd_kcontrol *kcontrol,
  2567. struct snd_ctl_elem_value *ucontrol)
  2568. {
  2569. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2570. ucontrol->value.integer.value[0] = dai_data->cal_mode;
  2571. return 0;
  2572. }
  2573. static int msm_dai_q6_xt_logging_disable_put(struct snd_kcontrol *kcontrol,
  2574. struct snd_ctl_elem_value *ucontrol)
  2575. {
  2576. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2577. dai_data->xt_logging_disable = ucontrol->value.integer.value[0];
  2578. pr_debug("%s: setting xt logging disable to %d\n",
  2579. __func__, dai_data->xt_logging_disable);
  2580. return 0;
  2581. }
  2582. static int msm_dai_q6_xt_logging_disable_get(struct snd_kcontrol *kcontrol,
  2583. struct snd_ctl_elem_value *ucontrol)
  2584. {
  2585. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2586. ucontrol->value.integer.value[0] = dai_data->xt_logging_disable;
  2587. return 0;
  2588. }
  2589. static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
  2590. struct snd_ctl_elem_value *ucontrol)
  2591. {
  2592. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2593. int value = ucontrol->value.integer.value[0];
  2594. if (dai_data) {
  2595. dai_data->port_config.slim_sch.data_format = value;
  2596. pr_debug("%s: format = %d\n", __func__, value);
  2597. }
  2598. return 0;
  2599. }
  2600. static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
  2601. struct snd_ctl_elem_value *ucontrol)
  2602. {
  2603. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2604. if (dai_data)
  2605. ucontrol->value.integer.value[0] =
  2606. dai_data->port_config.slim_sch.data_format;
  2607. return 0;
  2608. }
  2609. static int msm_dai_q6_usb_audio_cfg_put(struct snd_kcontrol *kcontrol,
  2610. struct snd_ctl_elem_value *ucontrol)
  2611. {
  2612. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2613. u32 val = ucontrol->value.integer.value[0];
  2614. if (dai_data) {
  2615. dai_data->port_config.usb_audio.dev_token = val;
  2616. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2617. dai_data->port_config.usb_audio.dev_token);
  2618. } else {
  2619. pr_err("%s: dai_data is NULL\n", __func__);
  2620. }
  2621. return 0;
  2622. }
  2623. static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol,
  2624. struct snd_ctl_elem_value *ucontrol)
  2625. {
  2626. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2627. if (dai_data) {
  2628. ucontrol->value.integer.value[0] =
  2629. dai_data->port_config.usb_audio.dev_token;
  2630. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2631. dai_data->port_config.usb_audio.dev_token);
  2632. } else {
  2633. pr_err("%s: dai_data is NULL\n", __func__);
  2634. }
  2635. return 0;
  2636. }
  2637. static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol,
  2638. struct snd_ctl_elem_value *ucontrol)
  2639. {
  2640. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2641. u32 val = ucontrol->value.integer.value[0];
  2642. if (dai_data) {
  2643. dai_data->port_config.usb_audio.endian = val;
  2644. pr_debug("%s: endian = 0x%x\n", __func__,
  2645. dai_data->port_config.usb_audio.endian);
  2646. } else {
  2647. pr_err("%s: dai_data is NULL\n", __func__);
  2648. return -EINVAL;
  2649. }
  2650. return 0;
  2651. }
  2652. static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol,
  2653. struct snd_ctl_elem_value *ucontrol)
  2654. {
  2655. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2656. if (dai_data) {
  2657. ucontrol->value.integer.value[0] =
  2658. dai_data->port_config.usb_audio.endian;
  2659. pr_debug("%s: endian = 0x%x\n", __func__,
  2660. dai_data->port_config.usb_audio.endian);
  2661. } else {
  2662. pr_err("%s: dai_data is NULL\n", __func__);
  2663. return -EINVAL;
  2664. }
  2665. return 0;
  2666. }
  2667. static int msm_dai_q6_usb_audio_svc_interval_put(struct snd_kcontrol *kcontrol,
  2668. struct snd_ctl_elem_value *ucontrol)
  2669. {
  2670. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2671. u32 val = ucontrol->value.integer.value[0];
  2672. if (!dai_data) {
  2673. pr_err("%s: dai_data is NULL\n", __func__);
  2674. return -EINVAL;
  2675. }
  2676. dai_data->port_config.usb_audio.service_interval = val;
  2677. pr_debug("%s: new service interval = %u\n", __func__,
  2678. dai_data->port_config.usb_audio.service_interval);
  2679. return 0;
  2680. }
  2681. static int msm_dai_q6_usb_audio_svc_interval_get(struct snd_kcontrol *kcontrol,
  2682. struct snd_ctl_elem_value *ucontrol)
  2683. {
  2684. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2685. if (!dai_data) {
  2686. pr_err("%s: dai_data is NULL\n", __func__);
  2687. return -EINVAL;
  2688. }
  2689. ucontrol->value.integer.value[0] =
  2690. dai_data->port_config.usb_audio.service_interval;
  2691. pr_debug("%s: service interval = %d\n", __func__,
  2692. dai_data->port_config.usb_audio.service_interval);
  2693. return 0;
  2694. }
  2695. static int msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol,
  2696. struct snd_ctl_elem_info *uinfo)
  2697. {
  2698. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2699. uinfo->count = sizeof(struct afe_enc_config);
  2700. return 0;
  2701. }
  2702. static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
  2703. struct snd_ctl_elem_value *ucontrol)
  2704. {
  2705. int ret = 0;
  2706. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2707. if (dai_data) {
  2708. int format_size = sizeof(dai_data->enc_config.format);
  2709. pr_debug("%s: encoder config for %d format\n",
  2710. __func__, dai_data->enc_config.format);
  2711. memcpy(ucontrol->value.bytes.data,
  2712. &dai_data->enc_config.format,
  2713. format_size);
  2714. switch (dai_data->enc_config.format) {
  2715. case ENC_FMT_SBC:
  2716. memcpy(ucontrol->value.bytes.data + format_size,
  2717. &dai_data->enc_config.data,
  2718. sizeof(struct asm_sbc_enc_cfg_t));
  2719. break;
  2720. case ENC_FMT_AAC_V2:
  2721. memcpy(ucontrol->value.bytes.data + format_size,
  2722. &dai_data->enc_config.data,
  2723. sizeof(struct asm_aac_enc_cfg_t));
  2724. break;
  2725. case ENC_FMT_APTX:
  2726. memcpy(ucontrol->value.bytes.data + format_size,
  2727. &dai_data->enc_config.data,
  2728. sizeof(struct asm_aptx_enc_cfg_t));
  2729. break;
  2730. case ENC_FMT_APTX_HD:
  2731. memcpy(ucontrol->value.bytes.data + format_size,
  2732. &dai_data->enc_config.data,
  2733. sizeof(struct asm_custom_enc_cfg_t));
  2734. break;
  2735. case ENC_FMT_CELT:
  2736. memcpy(ucontrol->value.bytes.data + format_size,
  2737. &dai_data->enc_config.data,
  2738. sizeof(struct asm_celt_enc_cfg_t));
  2739. break;
  2740. case ENC_FMT_LDAC:
  2741. memcpy(ucontrol->value.bytes.data + format_size,
  2742. &dai_data->enc_config.data,
  2743. sizeof(struct asm_ldac_enc_cfg_t));
  2744. break;
  2745. case ENC_FMT_APTX_ADAPTIVE:
  2746. memcpy(ucontrol->value.bytes.data + format_size,
  2747. &dai_data->enc_config.data,
  2748. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2749. break;
  2750. case ENC_FMT_APTX_AD_SPEECH:
  2751. memcpy(ucontrol->value.bytes.data + format_size,
  2752. &dai_data->enc_config.data,
  2753. sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
  2754. break;
  2755. default:
  2756. pr_debug("%s: unknown format = %d\n",
  2757. __func__, dai_data->enc_config.format);
  2758. ret = -EINVAL;
  2759. break;
  2760. }
  2761. }
  2762. return ret;
  2763. }
  2764. static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
  2765. struct snd_ctl_elem_value *ucontrol)
  2766. {
  2767. int ret = 0;
  2768. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2769. if (dai_data) {
  2770. int format_size = sizeof(dai_data->enc_config.format);
  2771. memset(&dai_data->enc_config, 0x0,
  2772. sizeof(struct afe_enc_config));
  2773. memcpy(&dai_data->enc_config.format,
  2774. ucontrol->value.bytes.data,
  2775. format_size);
  2776. pr_debug("%s: Received encoder config for %d format\n",
  2777. __func__, dai_data->enc_config.format);
  2778. switch (dai_data->enc_config.format) {
  2779. case ENC_FMT_SBC:
  2780. memcpy(&dai_data->enc_config.data,
  2781. ucontrol->value.bytes.data + format_size,
  2782. sizeof(struct asm_sbc_enc_cfg_t));
  2783. break;
  2784. case ENC_FMT_AAC_V2:
  2785. memcpy(&dai_data->enc_config.data,
  2786. ucontrol->value.bytes.data + format_size,
  2787. sizeof(struct asm_aac_enc_cfg_t));
  2788. break;
  2789. case ENC_FMT_APTX:
  2790. memcpy(&dai_data->enc_config.data,
  2791. ucontrol->value.bytes.data + format_size,
  2792. sizeof(struct asm_aptx_enc_cfg_t));
  2793. break;
  2794. case ENC_FMT_APTX_HD:
  2795. memcpy(&dai_data->enc_config.data,
  2796. ucontrol->value.bytes.data + format_size,
  2797. sizeof(struct asm_custom_enc_cfg_t));
  2798. break;
  2799. case ENC_FMT_CELT:
  2800. memcpy(&dai_data->enc_config.data,
  2801. ucontrol->value.bytes.data + format_size,
  2802. sizeof(struct asm_celt_enc_cfg_t));
  2803. break;
  2804. case ENC_FMT_LDAC:
  2805. memcpy(&dai_data->enc_config.data,
  2806. ucontrol->value.bytes.data + format_size,
  2807. sizeof(struct asm_ldac_enc_cfg_t));
  2808. break;
  2809. case ENC_FMT_APTX_ADAPTIVE:
  2810. memcpy(&dai_data->enc_config.data,
  2811. ucontrol->value.bytes.data + format_size,
  2812. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2813. break;
  2814. case ENC_FMT_APTX_AD_SPEECH:
  2815. memcpy(&dai_data->enc_config.data,
  2816. ucontrol->value.bytes.data + format_size,
  2817. sizeof(struct asm_aptx_ad_speech_enc_cfg_t));
  2818. break;
  2819. default:
  2820. pr_debug("%s: Ignore enc config for unknown format = %d\n",
  2821. __func__, dai_data->enc_config.format);
  2822. ret = -EINVAL;
  2823. break;
  2824. }
  2825. } else
  2826. ret = -EINVAL;
  2827. return ret;
  2828. }
  2829. static const char *const afe_chs_text[] = {"Zero", "One", "Two"};
  2830. static const struct soc_enum afe_chs_enum[] = {
  2831. SOC_ENUM_SINGLE_EXT(3, afe_chs_text),
  2832. };
  2833. static const char *const afe_bit_format_text[] = {"S16_LE", "S24_LE",
  2834. "S32_LE"};
  2835. static const struct soc_enum afe_bit_format_enum[] = {
  2836. SOC_ENUM_SINGLE_EXT(3, afe_bit_format_text),
  2837. };
  2838. static const char *const tws_chs_mode_text[] = {"Zero", "One", "Two"};
  2839. static const struct soc_enum tws_chs_mode_enum[] = {
  2840. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tws_chs_mode_text), tws_chs_mode_text),
  2841. };
  2842. static int msm_dai_q6_afe_input_channel_get(struct snd_kcontrol *kcontrol,
  2843. struct snd_ctl_elem_value *ucontrol)
  2844. {
  2845. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2846. if (dai_data) {
  2847. ucontrol->value.integer.value[0] = dai_data->afe_rx_in_channels;
  2848. pr_debug("%s:afe input channel = %d\n",
  2849. __func__, dai_data->afe_rx_in_channels);
  2850. }
  2851. return 0;
  2852. }
  2853. static int msm_dai_q6_afe_input_channel_put(struct snd_kcontrol *kcontrol,
  2854. struct snd_ctl_elem_value *ucontrol)
  2855. {
  2856. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2857. if (dai_data) {
  2858. dai_data->afe_rx_in_channels = ucontrol->value.integer.value[0];
  2859. pr_debug("%s: updating afe input channel : %d\n",
  2860. __func__, dai_data->afe_rx_in_channels);
  2861. }
  2862. return 0;
  2863. }
  2864. static int msm_dai_q6_tws_channel_mode_get(struct snd_kcontrol *kcontrol,
  2865. struct snd_ctl_elem_value *ucontrol)
  2866. {
  2867. struct snd_soc_dai *dai = kcontrol->private_data;
  2868. struct msm_dai_q6_dai_data *dai_data = NULL;
  2869. if (dai)
  2870. dai_data = dev_get_drvdata(dai->dev);
  2871. if (dai_data) {
  2872. ucontrol->value.integer.value[0] =
  2873. dai_data->enc_config.mono_mode;
  2874. pr_debug("%s:tws channel mode = %d\n",
  2875. __func__, dai_data->enc_config.mono_mode);
  2876. }
  2877. return 0;
  2878. }
  2879. static int msm_dai_q6_tws_channel_mode_put(struct snd_kcontrol *kcontrol,
  2880. struct snd_ctl_elem_value *ucontrol)
  2881. {
  2882. struct snd_soc_dai *dai = kcontrol->private_data;
  2883. struct msm_dai_q6_dai_data *dai_data = NULL;
  2884. int ret = 0;
  2885. u32 format = 0;
  2886. if (dai)
  2887. dai_data = dev_get_drvdata(dai->dev);
  2888. if (dai_data)
  2889. format = dai_data->enc_config.format;
  2890. else
  2891. goto exit;
  2892. if (format == ENC_FMT_APTX || format == ENC_FMT_APTX_ADAPTIVE) {
  2893. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2894. ret = afe_set_tws_channel_mode(format,
  2895. dai->id, ucontrol->value.integer.value[0]);
  2896. if (ret < 0) {
  2897. pr_err("%s: channel mode setting failed for TWS\n",
  2898. __func__);
  2899. goto exit;
  2900. } else {
  2901. pr_debug("%s: updating tws channel mode : %d\n",
  2902. __func__, dai_data->enc_config.mono_mode);
  2903. }
  2904. }
  2905. if (ucontrol->value.integer.value[0] ==
  2906. MSM_DAI_TWS_CHANNEL_MODE_ONE ||
  2907. ucontrol->value.integer.value[0] ==
  2908. MSM_DAI_TWS_CHANNEL_MODE_TWO)
  2909. dai_data->enc_config.mono_mode =
  2910. ucontrol->value.integer.value[0];
  2911. else
  2912. return -EINVAL;
  2913. }
  2914. exit:
  2915. return ret;
  2916. }
  2917. static int msm_dai_q6_afe_input_bit_format_get(
  2918. struct snd_kcontrol *kcontrol,
  2919. struct snd_ctl_elem_value *ucontrol)
  2920. {
  2921. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2922. if (!dai_data) {
  2923. pr_err("%s: Invalid dai data\n", __func__);
  2924. return -EINVAL;
  2925. }
  2926. switch (dai_data->afe_rx_in_bitformat) {
  2927. case SNDRV_PCM_FORMAT_S32_LE:
  2928. ucontrol->value.integer.value[0] = 2;
  2929. break;
  2930. case SNDRV_PCM_FORMAT_S24_LE:
  2931. ucontrol->value.integer.value[0] = 1;
  2932. break;
  2933. case SNDRV_PCM_FORMAT_S16_LE:
  2934. default:
  2935. ucontrol->value.integer.value[0] = 0;
  2936. break;
  2937. }
  2938. pr_debug("%s: afe input bit format : %ld\n",
  2939. __func__, ucontrol->value.integer.value[0]);
  2940. return 0;
  2941. }
  2942. static int msm_dai_q6_afe_input_bit_format_put(
  2943. struct snd_kcontrol *kcontrol,
  2944. struct snd_ctl_elem_value *ucontrol)
  2945. {
  2946. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2947. if (!dai_data) {
  2948. pr_err("%s: Invalid dai data\n", __func__);
  2949. return -EINVAL;
  2950. }
  2951. switch (ucontrol->value.integer.value[0]) {
  2952. case 2:
  2953. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  2954. break;
  2955. case 1:
  2956. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  2957. break;
  2958. case 0:
  2959. default:
  2960. dai_data->afe_rx_in_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  2961. break;
  2962. }
  2963. pr_debug("%s: updating afe input bit format : %d\n",
  2964. __func__, dai_data->afe_rx_in_bitformat);
  2965. return 0;
  2966. }
  2967. static int msm_dai_q6_afe_output_bit_format_get(
  2968. struct snd_kcontrol *kcontrol,
  2969. struct snd_ctl_elem_value *ucontrol)
  2970. {
  2971. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2972. if (!dai_data) {
  2973. pr_err("%s: Invalid dai data\n", __func__);
  2974. return -EINVAL;
  2975. }
  2976. switch (dai_data->afe_tx_out_bitformat) {
  2977. case SNDRV_PCM_FORMAT_S32_LE:
  2978. ucontrol->value.integer.value[0] = 2;
  2979. break;
  2980. case SNDRV_PCM_FORMAT_S24_LE:
  2981. ucontrol->value.integer.value[0] = 1;
  2982. break;
  2983. case SNDRV_PCM_FORMAT_S16_LE:
  2984. default:
  2985. ucontrol->value.integer.value[0] = 0;
  2986. break;
  2987. }
  2988. pr_debug("%s: afe output bit format : %ld\n",
  2989. __func__, ucontrol->value.integer.value[0]);
  2990. return 0;
  2991. }
  2992. static int msm_dai_q6_afe_output_bit_format_put(
  2993. struct snd_kcontrol *kcontrol,
  2994. struct snd_ctl_elem_value *ucontrol)
  2995. {
  2996. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2997. if (!dai_data) {
  2998. pr_err("%s: Invalid dai data\n", __func__);
  2999. return -EINVAL;
  3000. }
  3001. switch (ucontrol->value.integer.value[0]) {
  3002. case 2:
  3003. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  3004. break;
  3005. case 1:
  3006. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  3007. break;
  3008. case 0:
  3009. default:
  3010. dai_data->afe_tx_out_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  3011. break;
  3012. }
  3013. pr_debug("%s: updating afe output bit format : %d\n",
  3014. __func__, dai_data->afe_tx_out_bitformat);
  3015. return 0;
  3016. }
  3017. static int msm_dai_q6_afe_output_channel_get(struct snd_kcontrol *kcontrol,
  3018. struct snd_ctl_elem_value *ucontrol)
  3019. {
  3020. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3021. if (dai_data) {
  3022. ucontrol->value.integer.value[0] =
  3023. dai_data->afe_tx_out_channels;
  3024. pr_debug("%s:afe output channel = %d\n",
  3025. __func__, dai_data->afe_tx_out_channels);
  3026. }
  3027. return 0;
  3028. }
  3029. static int msm_dai_q6_afe_output_channel_put(struct snd_kcontrol *kcontrol,
  3030. struct snd_ctl_elem_value *ucontrol)
  3031. {
  3032. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3033. if (dai_data) {
  3034. dai_data->afe_tx_out_channels =
  3035. ucontrol->value.integer.value[0];
  3036. pr_debug("%s: updating afe output channel : %d\n",
  3037. __func__, dai_data->afe_tx_out_channels);
  3038. }
  3039. return 0;
  3040. }
  3041. static int msm_dai_q6_afe_scrambler_mode_get(
  3042. struct snd_kcontrol *kcontrol,
  3043. struct snd_ctl_elem_value *ucontrol)
  3044. {
  3045. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3046. if (!dai_data) {
  3047. pr_err("%s: Invalid dai data\n", __func__);
  3048. return -EINVAL;
  3049. }
  3050. ucontrol->value.integer.value[0] = dai_data->enc_config.scrambler_mode;
  3051. return 0;
  3052. }
  3053. static int msm_dai_q6_afe_scrambler_mode_put(
  3054. struct snd_kcontrol *kcontrol,
  3055. struct snd_ctl_elem_value *ucontrol)
  3056. {
  3057. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3058. if (!dai_data) {
  3059. pr_err("%s: Invalid dai data\n", __func__);
  3060. return -EINVAL;
  3061. }
  3062. dai_data->enc_config.scrambler_mode = ucontrol->value.integer.value[0];
  3063. pr_debug("%s: afe scrambler mode : %d\n",
  3064. __func__, dai_data->enc_config.scrambler_mode);
  3065. return 0;
  3066. }
  3067. static const struct snd_kcontrol_new afe_enc_config_controls[] = {
  3068. {
  3069. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3070. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3071. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3072. .name = "SLIM_7_RX Encoder Config",
  3073. .info = msm_dai_q6_afe_enc_cfg_info,
  3074. .get = msm_dai_q6_afe_enc_cfg_get,
  3075. .put = msm_dai_q6_afe_enc_cfg_put,
  3076. },
  3077. {
  3078. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3079. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3080. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3081. .name = "SLIM_7_RX APTX_AD Enc Cfg",
  3082. .info = msm_dai_q6_afe_enc_cfg_info,
  3083. .get = msm_dai_q6_afe_enc_cfg_get,
  3084. .put = msm_dai_q6_afe_enc_cfg_put,
  3085. },
  3086. SOC_ENUM_EXT("AFE Input Channels", afe_chs_enum[0],
  3087. msm_dai_q6_afe_input_channel_get,
  3088. msm_dai_q6_afe_input_channel_put),
  3089. SOC_ENUM_EXT("AFE Input Bit Format", afe_bit_format_enum[0],
  3090. msm_dai_q6_afe_input_bit_format_get,
  3091. msm_dai_q6_afe_input_bit_format_put),
  3092. SOC_SINGLE_EXT("AFE Scrambler Mode",
  3093. 0, 0, 1, 0,
  3094. msm_dai_q6_afe_scrambler_mode_get,
  3095. msm_dai_q6_afe_scrambler_mode_put),
  3096. SOC_ENUM_EXT("TWS Channel Mode", tws_chs_mode_enum[0],
  3097. msm_dai_q6_tws_channel_mode_get,
  3098. msm_dai_q6_tws_channel_mode_put)
  3099. };
  3100. static int msm_dai_q6_afe_dec_cfg_info(struct snd_kcontrol *kcontrol,
  3101. struct snd_ctl_elem_info *uinfo)
  3102. {
  3103. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3104. uinfo->count = sizeof(struct afe_dec_config);
  3105. return 0;
  3106. }
  3107. static int msm_dai_q6_afe_feedback_dec_cfg_get(struct snd_kcontrol *kcontrol,
  3108. struct snd_ctl_elem_value *ucontrol)
  3109. {
  3110. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3111. u32 format_size = 0;
  3112. u32 abr_size = 0;
  3113. if (!dai_data) {
  3114. pr_err("%s: Invalid dai data\n", __func__);
  3115. return -EINVAL;
  3116. }
  3117. format_size = sizeof(dai_data->dec_config.format);
  3118. memcpy(ucontrol->value.bytes.data,
  3119. &dai_data->dec_config.format,
  3120. format_size);
  3121. pr_debug("%s: abr_dec_cfg for %d format\n",
  3122. __func__, dai_data->dec_config.format);
  3123. abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
  3124. memcpy(ucontrol->value.bytes.data + format_size,
  3125. &dai_data->dec_config.abr_dec_cfg,
  3126. sizeof(struct afe_imc_dec_enc_info));
  3127. switch (dai_data->dec_config.format) {
  3128. case DEC_FMT_APTX_AD_SPEECH:
  3129. pr_debug("%s: afe_dec_cfg for %d format\n",
  3130. __func__, dai_data->dec_config.format);
  3131. memcpy(ucontrol->value.bytes.data + format_size + abr_size,
  3132. &dai_data->dec_config.data,
  3133. sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
  3134. break;
  3135. default:
  3136. pr_debug("%s: no afe_dec_cfg for format %d\n",
  3137. __func__, dai_data->dec_config.format);
  3138. break;
  3139. }
  3140. return 0;
  3141. }
  3142. static int msm_dai_q6_afe_feedback_dec_cfg_put(struct snd_kcontrol *kcontrol,
  3143. struct snd_ctl_elem_value *ucontrol)
  3144. {
  3145. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3146. u32 format_size = 0;
  3147. u32 abr_size = 0;
  3148. if (!dai_data) {
  3149. pr_err("%s: Invalid dai data\n", __func__);
  3150. return -EINVAL;
  3151. }
  3152. memset(&dai_data->dec_config, 0x0,
  3153. sizeof(struct afe_dec_config));
  3154. format_size = sizeof(dai_data->dec_config.format);
  3155. memcpy(&dai_data->dec_config.format,
  3156. ucontrol->value.bytes.data,
  3157. format_size);
  3158. pr_debug("%s: abr_dec_cfg for %d format\n",
  3159. __func__, dai_data->dec_config.format);
  3160. abr_size = sizeof(dai_data->dec_config.abr_dec_cfg.imc_info);
  3161. memcpy(&dai_data->dec_config.abr_dec_cfg,
  3162. ucontrol->value.bytes.data + format_size,
  3163. sizeof(struct afe_imc_dec_enc_info));
  3164. dai_data->dec_config.abr_dec_cfg.is_abr_enabled = true;
  3165. switch (dai_data->dec_config.format) {
  3166. case DEC_FMT_APTX_AD_SPEECH:
  3167. pr_debug("%s: afe_dec_cfg for %d format\n",
  3168. __func__, dai_data->dec_config.format);
  3169. memcpy(&dai_data->dec_config.data,
  3170. ucontrol->value.bytes.data + format_size + abr_size,
  3171. sizeof(struct asm_aptx_ad_speech_dec_cfg_t));
  3172. break;
  3173. default:
  3174. pr_debug("%s: no afe_dec_cfg for format %d\n",
  3175. __func__, dai_data->dec_config.format);
  3176. break;
  3177. }
  3178. return 0;
  3179. }
  3180. static int msm_dai_q6_afe_dec_cfg_get(struct snd_kcontrol *kcontrol,
  3181. struct snd_ctl_elem_value *ucontrol)
  3182. {
  3183. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3184. u32 format_size = 0;
  3185. int ret = 0;
  3186. if (!dai_data) {
  3187. pr_err("%s: Invalid dai data\n", __func__);
  3188. return -EINVAL;
  3189. }
  3190. format_size = sizeof(dai_data->dec_config.format);
  3191. memcpy(ucontrol->value.bytes.data,
  3192. &dai_data->dec_config.format,
  3193. format_size);
  3194. switch (dai_data->dec_config.format) {
  3195. case DEC_FMT_AAC_V2:
  3196. memcpy(ucontrol->value.bytes.data + format_size,
  3197. &dai_data->dec_config.data,
  3198. sizeof(struct asm_aac_dec_cfg_v2_t));
  3199. break;
  3200. case DEC_FMT_APTX_ADAPTIVE:
  3201. memcpy(ucontrol->value.bytes.data + format_size,
  3202. &dai_data->dec_config.data,
  3203. sizeof(struct asm_aptx_ad_dec_cfg_t));
  3204. break;
  3205. case DEC_FMT_SBC:
  3206. case DEC_FMT_MP3:
  3207. /* No decoder specific data available */
  3208. break;
  3209. default:
  3210. pr_err("%s: Invalid format %d\n",
  3211. __func__, dai_data->dec_config.format);
  3212. ret = -EINVAL;
  3213. break;
  3214. }
  3215. return ret;
  3216. }
  3217. static int msm_dai_q6_afe_dec_cfg_put(struct snd_kcontrol *kcontrol,
  3218. struct snd_ctl_elem_value *ucontrol)
  3219. {
  3220. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3221. u32 format_size = 0;
  3222. int ret = 0;
  3223. if (!dai_data) {
  3224. pr_err("%s: Invalid dai data\n", __func__);
  3225. return -EINVAL;
  3226. }
  3227. memset(&dai_data->dec_config, 0x0,
  3228. sizeof(struct afe_dec_config));
  3229. format_size = sizeof(dai_data->dec_config.format);
  3230. memcpy(&dai_data->dec_config.format,
  3231. ucontrol->value.bytes.data,
  3232. format_size);
  3233. pr_debug("%s: Received decoder config for %d format\n",
  3234. __func__, dai_data->dec_config.format);
  3235. switch (dai_data->dec_config.format) {
  3236. case DEC_FMT_AAC_V2:
  3237. memcpy(&dai_data->dec_config.data,
  3238. ucontrol->value.bytes.data + format_size,
  3239. sizeof(struct asm_aac_dec_cfg_v2_t));
  3240. break;
  3241. case DEC_FMT_SBC:
  3242. memcpy(&dai_data->dec_config.data,
  3243. ucontrol->value.bytes.data + format_size,
  3244. sizeof(struct asm_sbc_dec_cfg_t));
  3245. break;
  3246. case DEC_FMT_APTX_ADAPTIVE:
  3247. memcpy(&dai_data->dec_config.data,
  3248. ucontrol->value.bytes.data + format_size,
  3249. sizeof(struct asm_aptx_ad_dec_cfg_t));
  3250. break;
  3251. default:
  3252. pr_err("%s: Invalid format %d\n",
  3253. __func__, dai_data->dec_config.format);
  3254. ret = -EINVAL;
  3255. break;
  3256. }
  3257. return ret;
  3258. }
  3259. static const struct snd_kcontrol_new afe_dec_config_controls[] = {
  3260. {
  3261. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3262. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3263. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3264. .name = "SLIM_7_TX Decoder Config",
  3265. .info = msm_dai_q6_afe_dec_cfg_info,
  3266. .get = msm_dai_q6_afe_feedback_dec_cfg_get,
  3267. .put = msm_dai_q6_afe_feedback_dec_cfg_put,
  3268. },
  3269. {
  3270. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  3271. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  3272. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3273. .name = "SLIM_9_TX Decoder Config",
  3274. .info = msm_dai_q6_afe_dec_cfg_info,
  3275. .get = msm_dai_q6_afe_dec_cfg_get,
  3276. .put = msm_dai_q6_afe_dec_cfg_put,
  3277. },
  3278. SOC_ENUM_EXT("AFE Output Channels", afe_chs_enum[0],
  3279. msm_dai_q6_afe_output_channel_get,
  3280. msm_dai_q6_afe_output_channel_put),
  3281. SOC_ENUM_EXT("AFE Output Bit Format", afe_bit_format_enum[0],
  3282. msm_dai_q6_afe_output_bit_format_get,
  3283. msm_dai_q6_afe_output_bit_format_put),
  3284. };
  3285. static int msm_dai_q6_slim_rx_drift_info(struct snd_kcontrol *kcontrol,
  3286. struct snd_ctl_elem_info *uinfo)
  3287. {
  3288. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  3289. uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
  3290. return 0;
  3291. }
  3292. static int msm_dai_q6_slim_rx_drift_get(struct snd_kcontrol *kcontrol,
  3293. struct snd_ctl_elem_value *ucontrol)
  3294. {
  3295. int ret = -EINVAL;
  3296. struct afe_param_id_dev_timing_stats timing_stats;
  3297. struct snd_soc_dai *dai = kcontrol->private_data;
  3298. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  3299. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3300. pr_debug("%s: afe port not started. dai_data->status_mask = %ld\n",
  3301. __func__, *dai_data->status_mask);
  3302. goto done;
  3303. }
  3304. memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
  3305. ret = afe_get_av_dev_drift(&timing_stats, dai->id);
  3306. if (ret) {
  3307. pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
  3308. __func__, dai->id, ret);
  3309. goto done;
  3310. }
  3311. memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
  3312. sizeof(struct afe_param_id_dev_timing_stats));
  3313. done:
  3314. return ret;
  3315. }
  3316. static const char * const afe_cal_mode_text[] = {
  3317. "CAL_MODE_DEFAULT", "CAL_MODE_NONE"
  3318. };
  3319. static const struct soc_enum slim_2_rx_enum =
  3320. SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3321. afe_cal_mode_text);
  3322. static const struct soc_enum rt_proxy_1_rx_enum =
  3323. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3324. afe_cal_mode_text);
  3325. static const struct soc_enum rt_proxy_1_tx_enum =
  3326. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_TX, 0, ARRAY_SIZE(afe_cal_mode_text),
  3327. afe_cal_mode_text);
  3328. static const struct snd_kcontrol_new sb_config_controls[] = {
  3329. SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
  3330. msm_dai_q6_sb_format_get,
  3331. msm_dai_q6_sb_format_put),
  3332. SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
  3333. msm_dai_q6_cal_info_get,
  3334. msm_dai_q6_cal_info_put),
  3335. SOC_ENUM_EXT("SLIM_2_RX Format", sb_config_enum[0],
  3336. msm_dai_q6_sb_format_get,
  3337. msm_dai_q6_sb_format_put),
  3338. SOC_ENUM_EXT("SLIM_0_RX XTLoggingDisable", xt_logging_disable_enum[0],
  3339. msm_dai_q6_xt_logging_disable_get,
  3340. msm_dai_q6_xt_logging_disable_put),
  3341. };
  3342. static const struct snd_kcontrol_new rt_proxy_config_controls[] = {
  3343. SOC_ENUM_EXT("RT_PROXY_1_RX SetCalMode", rt_proxy_1_rx_enum,
  3344. msm_dai_q6_cal_info_get,
  3345. msm_dai_q6_cal_info_put),
  3346. SOC_ENUM_EXT("RT_PROXY_1_TX SetCalMode", rt_proxy_1_tx_enum,
  3347. msm_dai_q6_cal_info_get,
  3348. msm_dai_q6_cal_info_put),
  3349. };
  3350. static const struct snd_kcontrol_new usb_audio_cfg_controls[] = {
  3351. SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0,
  3352. msm_dai_q6_usb_audio_cfg_get,
  3353. msm_dai_q6_usb_audio_cfg_put),
  3354. SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0,
  3355. msm_dai_q6_usb_audio_endian_cfg_get,
  3356. msm_dai_q6_usb_audio_endian_cfg_put),
  3357. SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0,
  3358. msm_dai_q6_usb_audio_cfg_get,
  3359. msm_dai_q6_usb_audio_cfg_put),
  3360. SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0,
  3361. msm_dai_q6_usb_audio_endian_cfg_get,
  3362. msm_dai_q6_usb_audio_endian_cfg_put),
  3363. SOC_SINGLE_EXT("USB_AUDIO_RX service_interval", SND_SOC_NOPM, 0,
  3364. UINT_MAX, 0,
  3365. msm_dai_q6_usb_audio_svc_interval_get,
  3366. msm_dai_q6_usb_audio_svc_interval_put),
  3367. };
  3368. static const struct snd_kcontrol_new avd_drift_config_controls[] = {
  3369. {
  3370. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3371. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3372. .name = "SLIMBUS_0_RX DRIFT",
  3373. .info = msm_dai_q6_slim_rx_drift_info,
  3374. .get = msm_dai_q6_slim_rx_drift_get,
  3375. },
  3376. {
  3377. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3378. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3379. .name = "SLIMBUS_6_RX DRIFT",
  3380. .info = msm_dai_q6_slim_rx_drift_info,
  3381. .get = msm_dai_q6_slim_rx_drift_get,
  3382. },
  3383. {
  3384. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  3385. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  3386. .name = "SLIMBUS_7_RX DRIFT",
  3387. .info = msm_dai_q6_slim_rx_drift_info,
  3388. .get = msm_dai_q6_slim_rx_drift_get,
  3389. },
  3390. };
  3391. static inline void msm_dai_q6_set_slim_dev_id(struct snd_soc_dai *dai)
  3392. {
  3393. int rc = 0;
  3394. int slim_dev_id = 0;
  3395. const char *q6_slim_dev_id = "qcom,msm-dai-q6-slim-dev-id";
  3396. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  3397. dai_data->port_config.slim_sch.slimbus_dev_id = AFE_SLIMBUS_DEVICE_1;
  3398. rc = of_property_read_u32(dai->dev->of_node, q6_slim_dev_id,
  3399. &slim_dev_id);
  3400. if (rc) {
  3401. dev_dbg(dai->dev,
  3402. "%s: missing %s in dt node\n", __func__, q6_slim_dev_id);
  3403. return;
  3404. }
  3405. dev_dbg(dai->dev, "%s: slim_dev_id = %d\n", __func__, slim_dev_id);
  3406. if (slim_dev_id >= AFE_SLIMBUS_DEVICE_1 &&
  3407. slim_dev_id <= AFE_SLIMBUS_DEVICE_2)
  3408. dai_data->port_config.slim_sch.slimbus_dev_id = slim_dev_id;
  3409. }
  3410. static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
  3411. {
  3412. struct msm_dai_q6_dai_data *dai_data;
  3413. int rc = 0;
  3414. if (!dai) {
  3415. pr_err("%s: Invalid params dai\n", __func__);
  3416. return -EINVAL;
  3417. }
  3418. if (!dai->dev) {
  3419. pr_err("%s: Invalid params dai dev\n", __func__);
  3420. return -EINVAL;
  3421. }
  3422. dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL);
  3423. if (!dai_data)
  3424. return -ENOMEM;
  3425. else
  3426. dev_set_drvdata(dai->dev, dai_data);
  3427. msm_dai_q6_set_dai_id(dai);
  3428. if ((dai->id >= SLIMBUS_0_RX) && (dai->id <= SLIMBUS_9_TX))
  3429. msm_dai_q6_set_slim_dev_id(dai);
  3430. switch (dai->id) {
  3431. case SLIMBUS_4_TX:
  3432. rc = snd_ctl_add(dai->component->card->snd_card,
  3433. snd_ctl_new1(&sb_config_controls[0],
  3434. dai_data));
  3435. break;
  3436. case SLIMBUS_2_RX:
  3437. rc = snd_ctl_add(dai->component->card->snd_card,
  3438. snd_ctl_new1(&sb_config_controls[1],
  3439. dai_data));
  3440. rc = snd_ctl_add(dai->component->card->snd_card,
  3441. snd_ctl_new1(&sb_config_controls[2],
  3442. dai_data));
  3443. break;
  3444. case SLIMBUS_7_RX:
  3445. rc = snd_ctl_add(dai->component->card->snd_card,
  3446. snd_ctl_new1(&afe_enc_config_controls[0],
  3447. dai_data));
  3448. rc = snd_ctl_add(dai->component->card->snd_card,
  3449. snd_ctl_new1(&afe_enc_config_controls[1],
  3450. dai_data));
  3451. rc = snd_ctl_add(dai->component->card->snd_card,
  3452. snd_ctl_new1(&afe_enc_config_controls[2],
  3453. dai_data));
  3454. rc = snd_ctl_add(dai->component->card->snd_card,
  3455. snd_ctl_new1(&afe_enc_config_controls[3],
  3456. dai_data));
  3457. rc = snd_ctl_add(dai->component->card->snd_card,
  3458. snd_ctl_new1(&afe_enc_config_controls[4],
  3459. dai));
  3460. rc = snd_ctl_add(dai->component->card->snd_card,
  3461. snd_ctl_new1(&afe_enc_config_controls[5],
  3462. dai));
  3463. rc = snd_ctl_add(dai->component->card->snd_card,
  3464. snd_ctl_new1(&avd_drift_config_controls[2],
  3465. dai));
  3466. break;
  3467. case SLIMBUS_7_TX:
  3468. rc = snd_ctl_add(dai->component->card->snd_card,
  3469. snd_ctl_new1(&afe_dec_config_controls[0],
  3470. dai_data));
  3471. break;
  3472. case SLIMBUS_9_TX:
  3473. rc = snd_ctl_add(dai->component->card->snd_card,
  3474. snd_ctl_new1(&afe_dec_config_controls[1],
  3475. dai_data));
  3476. rc = snd_ctl_add(dai->component->card->snd_card,
  3477. snd_ctl_new1(&afe_dec_config_controls[2],
  3478. dai_data));
  3479. rc = snd_ctl_add(dai->component->card->snd_card,
  3480. snd_ctl_new1(&afe_dec_config_controls[3],
  3481. dai_data));
  3482. break;
  3483. case RT_PROXY_DAI_001_RX:
  3484. rc = snd_ctl_add(dai->component->card->snd_card,
  3485. snd_ctl_new1(&rt_proxy_config_controls[0],
  3486. dai_data));
  3487. break;
  3488. case RT_PROXY_DAI_001_TX:
  3489. rc = snd_ctl_add(dai->component->card->snd_card,
  3490. snd_ctl_new1(&rt_proxy_config_controls[1],
  3491. dai_data));
  3492. break;
  3493. case AFE_PORT_ID_USB_RX:
  3494. rc = snd_ctl_add(dai->component->card->snd_card,
  3495. snd_ctl_new1(&usb_audio_cfg_controls[0],
  3496. dai_data));
  3497. rc = snd_ctl_add(dai->component->card->snd_card,
  3498. snd_ctl_new1(&usb_audio_cfg_controls[1],
  3499. dai_data));
  3500. rc = snd_ctl_add(dai->component->card->snd_card,
  3501. snd_ctl_new1(&usb_audio_cfg_controls[4],
  3502. dai_data));
  3503. break;
  3504. case AFE_PORT_ID_USB_TX:
  3505. rc = snd_ctl_add(dai->component->card->snd_card,
  3506. snd_ctl_new1(&usb_audio_cfg_controls[2],
  3507. dai_data));
  3508. rc = snd_ctl_add(dai->component->card->snd_card,
  3509. snd_ctl_new1(&usb_audio_cfg_controls[3],
  3510. dai_data));
  3511. break;
  3512. case SLIMBUS_0_RX:
  3513. rc = snd_ctl_add(dai->component->card->snd_card,
  3514. snd_ctl_new1(&avd_drift_config_controls[0],
  3515. dai));
  3516. rc = snd_ctl_add(dai->component->card->snd_card,
  3517. snd_ctl_new1(&sb_config_controls[3],
  3518. dai_data));
  3519. break;
  3520. case SLIMBUS_6_RX:
  3521. rc = snd_ctl_add(dai->component->card->snd_card,
  3522. snd_ctl_new1(&avd_drift_config_controls[1],
  3523. dai));
  3524. break;
  3525. }
  3526. if (rc < 0)
  3527. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  3528. __func__, dai->name);
  3529. rc = msm_dai_q6_dai_add_route(dai);
  3530. return rc;
  3531. }
  3532. static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
  3533. {
  3534. struct msm_dai_q6_dai_data *dai_data;
  3535. int rc;
  3536. dai_data = dev_get_drvdata(dai->dev);
  3537. /* If AFE port is still up, close it */
  3538. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3539. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  3540. rc = afe_close(dai->id); /* can block */
  3541. if (rc < 0)
  3542. dev_err(dai->dev, "fail to close AFE port\n");
  3543. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  3544. }
  3545. kfree(dai_data);
  3546. return 0;
  3547. }
  3548. static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai[] = {
  3549. {
  3550. .playback = {
  3551. .stream_name = "AFE Playback",
  3552. .aif_name = "PCM_RX",
  3553. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3554. SNDRV_PCM_RATE_16000,
  3555. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3556. SNDRV_PCM_FMTBIT_S24_LE,
  3557. .channels_min = 1,
  3558. .channels_max = 2,
  3559. .rate_min = 8000,
  3560. .rate_max = 48000,
  3561. },
  3562. .ops = &msm_dai_q6_ops,
  3563. .id = RT_PROXY_DAI_001_RX,
  3564. .probe = msm_dai_q6_dai_probe,
  3565. .remove = msm_dai_q6_dai_remove,
  3566. },
  3567. {
  3568. .playback = {
  3569. .stream_name = "AFE-PROXY RX",
  3570. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3571. SNDRV_PCM_RATE_16000,
  3572. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3573. SNDRV_PCM_FMTBIT_S24_LE,
  3574. .channels_min = 1,
  3575. .channels_max = 2,
  3576. .rate_min = 8000,
  3577. .rate_max = 48000,
  3578. },
  3579. .ops = &msm_dai_q6_ops,
  3580. .id = RT_PROXY_DAI_002_RX,
  3581. .probe = msm_dai_q6_dai_probe,
  3582. .remove = msm_dai_q6_dai_remove,
  3583. },
  3584. };
  3585. static struct snd_soc_dai_driver msm_dai_q6_afe_lb_tx_dai[] = {
  3586. {
  3587. .capture = {
  3588. .stream_name = "AFE Loopback Capture",
  3589. .aif_name = "AFE_LOOPBACK_TX",
  3590. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3591. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3592. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3593. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3594. SNDRV_PCM_RATE_192000,
  3595. .formats = (SNDRV_PCM_FMTBIT_S16_LE |
  3596. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_3LE |
  3597. SNDRV_PCM_FMTBIT_S32_LE ),
  3598. .channels_min = 1,
  3599. .channels_max = 8,
  3600. .rate_min = 8000,
  3601. .rate_max = 192000,
  3602. },
  3603. .id = AFE_LOOPBACK_TX,
  3604. .probe = msm_dai_q6_dai_probe,
  3605. .remove = msm_dai_q6_dai_remove,
  3606. },
  3607. };
  3608. static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai[] = {
  3609. {
  3610. .capture = {
  3611. .stream_name = "AFE Capture",
  3612. .aif_name = "PCM_TX",
  3613. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3614. SNDRV_PCM_RATE_16000,
  3615. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3616. .channels_min = 1,
  3617. .channels_max = 8,
  3618. .rate_min = 8000,
  3619. .rate_max = 48000,
  3620. },
  3621. .ops = &msm_dai_q6_ops,
  3622. .id = RT_PROXY_DAI_002_TX,
  3623. .probe = msm_dai_q6_dai_probe,
  3624. .remove = msm_dai_q6_dai_remove,
  3625. },
  3626. {
  3627. .capture = {
  3628. .stream_name = "AFE-PROXY TX",
  3629. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3630. SNDRV_PCM_RATE_16000,
  3631. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3632. .channels_min = 1,
  3633. .channels_max = 8,
  3634. .rate_min = 8000,
  3635. .rate_max = 48000,
  3636. },
  3637. .ops = &msm_dai_q6_ops,
  3638. .id = RT_PROXY_DAI_001_TX,
  3639. .probe = msm_dai_q6_dai_probe,
  3640. .remove = msm_dai_q6_dai_remove,
  3641. },
  3642. };
  3643. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
  3644. .playback = {
  3645. .stream_name = "Internal BT-SCO Playback",
  3646. .aif_name = "INT_BT_SCO_RX",
  3647. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  3648. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3649. .channels_min = 1,
  3650. .channels_max = 1,
  3651. .rate_max = 16000,
  3652. .rate_min = 8000,
  3653. },
  3654. .ops = &msm_dai_q6_ops,
  3655. .id = INT_BT_SCO_RX,
  3656. .probe = msm_dai_q6_dai_probe,
  3657. .remove = msm_dai_q6_dai_remove,
  3658. };
  3659. static struct snd_soc_dai_driver msm_dai_q6_bt_a2dp_rx_dai = {
  3660. .playback = {
  3661. .stream_name = "Internal BT-A2DP Playback",
  3662. .aif_name = "INT_BT_A2DP_RX",
  3663. .rates = SNDRV_PCM_RATE_48000,
  3664. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3665. .channels_min = 1,
  3666. .channels_max = 2,
  3667. .rate_max = 48000,
  3668. .rate_min = 48000,
  3669. },
  3670. .ops = &msm_dai_q6_ops,
  3671. .id = INT_BT_A2DP_RX,
  3672. .probe = msm_dai_q6_dai_probe,
  3673. .remove = msm_dai_q6_dai_remove,
  3674. };
  3675. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
  3676. .capture = {
  3677. .stream_name = "Internal BT-SCO Capture",
  3678. .aif_name = "INT_BT_SCO_TX",
  3679. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  3680. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3681. .channels_min = 1,
  3682. .channels_max = 1,
  3683. .rate_max = 16000,
  3684. .rate_min = 8000,
  3685. },
  3686. .ops = &msm_dai_q6_ops,
  3687. .id = INT_BT_SCO_TX,
  3688. .probe = msm_dai_q6_dai_probe,
  3689. .remove = msm_dai_q6_dai_remove,
  3690. };
  3691. static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
  3692. .playback = {
  3693. .stream_name = "Internal FM Playback",
  3694. .aif_name = "INT_FM_RX",
  3695. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3696. SNDRV_PCM_RATE_16000,
  3697. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3698. .channels_min = 2,
  3699. .channels_max = 2,
  3700. .rate_max = 48000,
  3701. .rate_min = 8000,
  3702. },
  3703. .ops = &msm_dai_q6_ops,
  3704. .id = INT_FM_RX,
  3705. .probe = msm_dai_q6_dai_probe,
  3706. .remove = msm_dai_q6_dai_remove,
  3707. };
  3708. static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
  3709. .capture = {
  3710. .stream_name = "Internal FM Capture",
  3711. .aif_name = "INT_FM_TX",
  3712. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3713. SNDRV_PCM_RATE_16000,
  3714. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3715. .channels_min = 2,
  3716. .channels_max = 2,
  3717. .rate_max = 48000,
  3718. .rate_min = 8000,
  3719. },
  3720. .ops = &msm_dai_q6_ops,
  3721. .id = INT_FM_TX,
  3722. .probe = msm_dai_q6_dai_probe,
  3723. .remove = msm_dai_q6_dai_remove,
  3724. };
  3725. static struct snd_soc_dai_driver msm_dai_q6_voc_playback_dai[] = {
  3726. {
  3727. .playback = {
  3728. .stream_name = "Voice Farend Playback",
  3729. .aif_name = "VOICE_PLAYBACK_TX",
  3730. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3731. SNDRV_PCM_RATE_16000,
  3732. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3733. .channels_min = 1,
  3734. .channels_max = 2,
  3735. .rate_min = 8000,
  3736. .rate_max = 48000,
  3737. },
  3738. .ops = &msm_dai_q6_ops,
  3739. .id = VOICE_PLAYBACK_TX,
  3740. .probe = msm_dai_q6_dai_probe,
  3741. .remove = msm_dai_q6_dai_remove,
  3742. },
  3743. {
  3744. .playback = {
  3745. .stream_name = "Voice2 Farend Playback",
  3746. .aif_name = "VOICE2_PLAYBACK_TX",
  3747. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3748. SNDRV_PCM_RATE_16000,
  3749. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3750. .channels_min = 1,
  3751. .channels_max = 2,
  3752. .rate_min = 8000,
  3753. .rate_max = 48000,
  3754. },
  3755. .ops = &msm_dai_q6_ops,
  3756. .id = VOICE2_PLAYBACK_TX,
  3757. .probe = msm_dai_q6_dai_probe,
  3758. .remove = msm_dai_q6_dai_remove,
  3759. },
  3760. };
  3761. static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = {
  3762. {
  3763. .capture = {
  3764. .stream_name = "Voice Uplink Capture",
  3765. .aif_name = "INCALL_RECORD_TX",
  3766. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3767. SNDRV_PCM_RATE_16000,
  3768. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3769. .channels_min = 1,
  3770. .channels_max = 2,
  3771. .rate_min = 8000,
  3772. .rate_max = 48000,
  3773. },
  3774. .ops = &msm_dai_q6_ops,
  3775. .id = VOICE_RECORD_TX,
  3776. .probe = msm_dai_q6_dai_probe,
  3777. .remove = msm_dai_q6_dai_remove,
  3778. },
  3779. {
  3780. .capture = {
  3781. .stream_name = "Voice Downlink Capture",
  3782. .aif_name = "INCALL_RECORD_RX",
  3783. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3784. SNDRV_PCM_RATE_16000,
  3785. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  3786. .channels_min = 1,
  3787. .channels_max = 2,
  3788. .rate_min = 8000,
  3789. .rate_max = 48000,
  3790. },
  3791. .ops = &msm_dai_q6_ops,
  3792. .id = VOICE_RECORD_RX,
  3793. .probe = msm_dai_q6_dai_probe,
  3794. .remove = msm_dai_q6_dai_remove,
  3795. },
  3796. };
  3797. static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = {
  3798. .playback = {
  3799. .stream_name = "USB Audio Playback",
  3800. .aif_name = "USB_AUDIO_RX",
  3801. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3802. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3803. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3804. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  3805. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  3806. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  3807. SNDRV_PCM_RATE_384000,
  3808. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  3809. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  3810. .channels_min = 1,
  3811. .channels_max = 8,
  3812. .rate_max = 384000,
  3813. .rate_min = 8000,
  3814. },
  3815. .ops = &msm_dai_q6_ops,
  3816. .id = AFE_PORT_ID_USB_RX,
  3817. .probe = msm_dai_q6_dai_probe,
  3818. .remove = msm_dai_q6_dai_remove,
  3819. };
  3820. static struct snd_soc_dai_driver msm_dai_q6_usb_tx_dai = {
  3821. .capture = {
  3822. .stream_name = "USB Audio Capture",
  3823. .aif_name = "USB_AUDIO_TX",
  3824. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  3825. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  3826. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  3827. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  3828. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  3829. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  3830. SNDRV_PCM_RATE_384000,
  3831. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  3832. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  3833. .channels_min = 1,
  3834. .channels_max = 8,
  3835. .rate_max = 384000,
  3836. .rate_min = 8000,
  3837. },
  3838. .ops = &msm_dai_q6_ops,
  3839. .id = AFE_PORT_ID_USB_TX,
  3840. .probe = msm_dai_q6_dai_probe,
  3841. .remove = msm_dai_q6_dai_remove,
  3842. };
  3843. static int msm_auxpcm_dev_probe(struct platform_device *pdev)
  3844. {
  3845. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  3846. struct msm_dai_auxpcm_pdata *auxpcm_pdata;
  3847. uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
  3848. uint32_t val = 0;
  3849. const char *intf_name;
  3850. int rc = 0, i = 0, len = 0;
  3851. const uint32_t *slot_mapping_array = NULL;
  3852. u32 array_length = 0;
  3853. dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
  3854. GFP_KERNEL);
  3855. if (!dai_data)
  3856. return -ENOMEM;
  3857. rc = of_property_read_u32(pdev->dev.of_node,
  3858. "qcom,msm-dai-is-island-supported",
  3859. &dai_data->is_island_dai);
  3860. if (rc)
  3861. dev_dbg(&pdev->dev, "island supported entry not found\n");
  3862. auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
  3863. GFP_KERNEL);
  3864. if (!auxpcm_pdata) {
  3865. dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
  3866. goto fail_pdata_nomem;
  3867. }
  3868. dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
  3869. __func__, &pdev->dev, dai_data, auxpcm_pdata);
  3870. rc = of_property_read_u32_array(pdev->dev.of_node,
  3871. "qcom,msm-cpudai-auxpcm-mode",
  3872. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3873. if (rc) {
  3874. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
  3875. __func__);
  3876. goto fail_invalid_dt;
  3877. }
  3878. auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
  3879. auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
  3880. rc = of_property_read_u32_array(pdev->dev.of_node,
  3881. "qcom,msm-cpudai-auxpcm-sync",
  3882. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3883. if (rc) {
  3884. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
  3885. __func__);
  3886. goto fail_invalid_dt;
  3887. }
  3888. auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
  3889. auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
  3890. rc = of_property_read_u32_array(pdev->dev.of_node,
  3891. "qcom,msm-cpudai-auxpcm-frame",
  3892. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3893. if (rc) {
  3894. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
  3895. __func__);
  3896. goto fail_invalid_dt;
  3897. }
  3898. auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
  3899. auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
  3900. rc = of_property_read_u32_array(pdev->dev.of_node,
  3901. "qcom,msm-cpudai-auxpcm-quant",
  3902. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3903. if (rc) {
  3904. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
  3905. __func__);
  3906. goto fail_invalid_dt;
  3907. }
  3908. auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
  3909. auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
  3910. rc = of_property_read_u32_array(pdev->dev.of_node,
  3911. "qcom,msm-cpudai-auxpcm-num-slots",
  3912. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3913. if (rc) {
  3914. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
  3915. __func__);
  3916. goto fail_invalid_dt;
  3917. }
  3918. auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
  3919. if (auxpcm_pdata->mode_8k.num_slots >
  3920. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
  3921. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  3922. __func__,
  3923. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
  3924. auxpcm_pdata->mode_8k.num_slots);
  3925. rc = -EINVAL;
  3926. goto fail_invalid_dt;
  3927. }
  3928. auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
  3929. if (auxpcm_pdata->mode_16k.num_slots >
  3930. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
  3931. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  3932. __func__,
  3933. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
  3934. auxpcm_pdata->mode_16k.num_slots);
  3935. rc = -EINVAL;
  3936. goto fail_invalid_dt;
  3937. }
  3938. slot_mapping_array = of_get_property(pdev->dev.of_node,
  3939. "qcom,msm-cpudai-auxpcm-slot-mapping", &len);
  3940. if (slot_mapping_array == NULL) {
  3941. dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
  3942. __func__);
  3943. rc = -EINVAL;
  3944. goto fail_invalid_dt;
  3945. }
  3946. array_length = auxpcm_pdata->mode_8k.num_slots +
  3947. auxpcm_pdata->mode_16k.num_slots;
  3948. if (len != sizeof(uint32_t) * array_length) {
  3949. dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
  3950. __func__, len, sizeof(uint32_t) * array_length);
  3951. rc = -EINVAL;
  3952. goto fail_invalid_dt;
  3953. }
  3954. auxpcm_pdata->mode_8k.slot_mapping =
  3955. kzalloc(sizeof(uint16_t) *
  3956. auxpcm_pdata->mode_8k.num_slots,
  3957. GFP_KERNEL);
  3958. if (!auxpcm_pdata->mode_8k.slot_mapping) {
  3959. dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
  3960. __func__);
  3961. rc = -ENOMEM;
  3962. goto fail_invalid_dt;
  3963. }
  3964. for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
  3965. auxpcm_pdata->mode_8k.slot_mapping[i] =
  3966. (u16)be32_to_cpu(slot_mapping_array[i]);
  3967. auxpcm_pdata->mode_16k.slot_mapping =
  3968. kzalloc(sizeof(uint16_t) *
  3969. auxpcm_pdata->mode_16k.num_slots,
  3970. GFP_KERNEL);
  3971. if (!auxpcm_pdata->mode_16k.slot_mapping) {
  3972. dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
  3973. __func__);
  3974. rc = -ENOMEM;
  3975. goto fail_invalid_16k_slot_mapping;
  3976. }
  3977. for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
  3978. auxpcm_pdata->mode_16k.slot_mapping[i] =
  3979. (u16)be32_to_cpu(slot_mapping_array[i +
  3980. auxpcm_pdata->mode_8k.num_slots]);
  3981. rc = of_property_read_u32_array(pdev->dev.of_node,
  3982. "qcom,msm-cpudai-auxpcm-data",
  3983. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3984. if (rc) {
  3985. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
  3986. __func__);
  3987. goto fail_invalid_dt1;
  3988. }
  3989. auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
  3990. auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
  3991. rc = of_property_read_u32_array(pdev->dev.of_node,
  3992. "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
  3993. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3994. if (rc) {
  3995. dev_err(&pdev->dev,
  3996. "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
  3997. __func__);
  3998. goto fail_invalid_dt1;
  3999. }
  4000. auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
  4001. auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
  4002. rc = of_property_read_string(pdev->dev.of_node,
  4003. "qcom,msm-auxpcm-interface", &intf_name);
  4004. if (rc) {
  4005. dev_err(&pdev->dev,
  4006. "%s: qcom,msm-auxpcm-interface missing in DT node\n",
  4007. __func__);
  4008. goto fail_nodev_intf;
  4009. }
  4010. if (!strcmp(intf_name, "primary")) {
  4011. dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
  4012. dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
  4013. pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
  4014. i = 0;
  4015. } else if (!strcmp(intf_name, "secondary")) {
  4016. dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
  4017. dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
  4018. pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
  4019. i = 1;
  4020. } else if (!strcmp(intf_name, "tertiary")) {
  4021. dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
  4022. dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
  4023. pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
  4024. i = 2;
  4025. } else if (!strcmp(intf_name, "quaternary")) {
  4026. dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
  4027. dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
  4028. pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
  4029. i = 3;
  4030. } else if (!strcmp(intf_name, "quinary")) {
  4031. dai_data->rx_pid = AFE_PORT_ID_QUINARY_PCM_RX;
  4032. dai_data->tx_pid = AFE_PORT_ID_QUINARY_PCM_TX;
  4033. pdev->id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID;
  4034. i = 4;
  4035. } else if (!strcmp(intf_name, "senary")) {
  4036. dai_data->rx_pid = AFE_PORT_ID_SENARY_PCM_RX;
  4037. dai_data->tx_pid = AFE_PORT_ID_SENARY_PCM_TX;
  4038. pdev->id = MSM_DAI_SEN_AUXPCM_DT_DEV_ID;
  4039. i = 5;
  4040. } else {
  4041. dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
  4042. __func__, intf_name);
  4043. goto fail_invalid_intf;
  4044. }
  4045. rc = of_property_read_u32(pdev->dev.of_node,
  4046. "qcom,msm-cpudai-afe-clk-ver", &val);
  4047. if (rc)
  4048. dai_data->afe_clk_ver = AFE_CLK_VERSION_V1;
  4049. else
  4050. dai_data->afe_clk_ver = val;
  4051. mutex_init(&dai_data->rlock);
  4052. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  4053. dev_set_drvdata(&pdev->dev, dai_data);
  4054. pdev->dev.platform_data = (void *) auxpcm_pdata;
  4055. rc = snd_soc_register_component(&pdev->dev,
  4056. &msm_dai_q6_aux_pcm_dai_component,
  4057. &msm_dai_q6_aux_pcm_dai[i], 1);
  4058. if (rc) {
  4059. dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
  4060. __func__, rc);
  4061. goto fail_reg_dai;
  4062. }
  4063. return rc;
  4064. fail_reg_dai:
  4065. fail_invalid_intf:
  4066. fail_nodev_intf:
  4067. fail_invalid_dt1:
  4068. kfree(auxpcm_pdata->mode_16k.slot_mapping);
  4069. fail_invalid_16k_slot_mapping:
  4070. kfree(auxpcm_pdata->mode_8k.slot_mapping);
  4071. fail_invalid_dt:
  4072. kfree(auxpcm_pdata);
  4073. fail_pdata_nomem:
  4074. kfree(dai_data);
  4075. return rc;
  4076. }
  4077. static int msm_auxpcm_dev_remove(struct platform_device *pdev)
  4078. {
  4079. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  4080. dai_data = dev_get_drvdata(&pdev->dev);
  4081. snd_soc_unregister_component(&pdev->dev);
  4082. mutex_destroy(&dai_data->rlock);
  4083. kfree(dai_data);
  4084. kfree(pdev->dev.platform_data);
  4085. return 0;
  4086. }
  4087. static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
  4088. { .compatible = "qcom,msm-auxpcm-dev", },
  4089. {}
  4090. };
  4091. static struct platform_driver msm_auxpcm_dev_driver = {
  4092. .probe = msm_auxpcm_dev_probe,
  4093. .remove = msm_auxpcm_dev_remove,
  4094. .driver = {
  4095. .name = "msm-auxpcm-dev",
  4096. .owner = THIS_MODULE,
  4097. .of_match_table = msm_auxpcm_dev_dt_match,
  4098. .suppress_bind_attrs = true,
  4099. },
  4100. };
  4101. static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
  4102. {
  4103. .playback = {
  4104. .stream_name = "Slimbus Playback",
  4105. .aif_name = "SLIMBUS_0_RX",
  4106. .rates = SNDRV_PCM_RATE_8000_384000,
  4107. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4108. .channels_min = 1,
  4109. .channels_max = 8,
  4110. .rate_min = 8000,
  4111. .rate_max = 384000,
  4112. },
  4113. .ops = &msm_dai_slimbus_0_rx_ops,
  4114. .id = SLIMBUS_0_RX,
  4115. .probe = msm_dai_q6_dai_probe,
  4116. .remove = msm_dai_q6_dai_remove,
  4117. },
  4118. {
  4119. .playback = {
  4120. .stream_name = "Slimbus1 Playback",
  4121. .aif_name = "SLIMBUS_1_RX",
  4122. .rates = SNDRV_PCM_RATE_8000_384000,
  4123. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4124. .channels_min = 1,
  4125. .channels_max = 2,
  4126. .rate_min = 8000,
  4127. .rate_max = 384000,
  4128. },
  4129. .ops = &msm_dai_q6_ops,
  4130. .id = SLIMBUS_1_RX,
  4131. .probe = msm_dai_q6_dai_probe,
  4132. .remove = msm_dai_q6_dai_remove,
  4133. },
  4134. {
  4135. .playback = {
  4136. .stream_name = "Slimbus2 Playback",
  4137. .aif_name = "SLIMBUS_2_RX",
  4138. .rates = SNDRV_PCM_RATE_8000_384000,
  4139. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4140. .channels_min = 1,
  4141. .channels_max = 8,
  4142. .rate_min = 8000,
  4143. .rate_max = 384000,
  4144. },
  4145. .ops = &msm_dai_q6_ops,
  4146. .id = SLIMBUS_2_RX,
  4147. .probe = msm_dai_q6_dai_probe,
  4148. .remove = msm_dai_q6_dai_remove,
  4149. },
  4150. {
  4151. .playback = {
  4152. .stream_name = "Slimbus3 Playback",
  4153. .aif_name = "SLIMBUS_3_RX",
  4154. .rates = SNDRV_PCM_RATE_8000_384000,
  4155. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4156. .channels_min = 1,
  4157. .channels_max = 2,
  4158. .rate_min = 8000,
  4159. .rate_max = 384000,
  4160. },
  4161. .ops = &msm_dai_q6_ops,
  4162. .id = SLIMBUS_3_RX,
  4163. .probe = msm_dai_q6_dai_probe,
  4164. .remove = msm_dai_q6_dai_remove,
  4165. },
  4166. {
  4167. .playback = {
  4168. .stream_name = "Slimbus4 Playback",
  4169. .aif_name = "SLIMBUS_4_RX",
  4170. .rates = SNDRV_PCM_RATE_8000_384000,
  4171. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4172. .channels_min = 1,
  4173. .channels_max = 2,
  4174. .rate_min = 8000,
  4175. .rate_max = 384000,
  4176. },
  4177. .ops = &msm_dai_q6_ops,
  4178. .id = SLIMBUS_4_RX,
  4179. .probe = msm_dai_q6_dai_probe,
  4180. .remove = msm_dai_q6_dai_remove,
  4181. },
  4182. {
  4183. .playback = {
  4184. .stream_name = "Slimbus6 Playback",
  4185. .aif_name = "SLIMBUS_6_RX",
  4186. .rates = SNDRV_PCM_RATE_8000_384000,
  4187. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4188. .channels_min = 1,
  4189. .channels_max = 2,
  4190. .rate_min = 8000,
  4191. .rate_max = 384000,
  4192. },
  4193. .ops = &msm_dai_q6_ops,
  4194. .id = SLIMBUS_6_RX,
  4195. .probe = msm_dai_q6_dai_probe,
  4196. .remove = msm_dai_q6_dai_remove,
  4197. },
  4198. {
  4199. .playback = {
  4200. .stream_name = "Slimbus5 Playback",
  4201. .aif_name = "SLIMBUS_5_RX",
  4202. .rates = SNDRV_PCM_RATE_8000_384000,
  4203. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4204. .channels_min = 1,
  4205. .channels_max = 2,
  4206. .rate_min = 8000,
  4207. .rate_max = 384000,
  4208. },
  4209. .ops = &msm_dai_q6_ops,
  4210. .id = SLIMBUS_5_RX,
  4211. .probe = msm_dai_q6_dai_probe,
  4212. .remove = msm_dai_q6_dai_remove,
  4213. },
  4214. {
  4215. .playback = {
  4216. .stream_name = "Slimbus7 Playback",
  4217. .aif_name = "SLIMBUS_7_RX",
  4218. .rates = SNDRV_PCM_RATE_8000_384000,
  4219. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4220. .channels_min = 1,
  4221. .channels_max = 8,
  4222. .rate_min = 8000,
  4223. .rate_max = 384000,
  4224. },
  4225. .ops = &msm_dai_q6_ops,
  4226. .id = SLIMBUS_7_RX,
  4227. .probe = msm_dai_q6_dai_probe,
  4228. .remove = msm_dai_q6_dai_remove,
  4229. },
  4230. {
  4231. .playback = {
  4232. .stream_name = "Slimbus8 Playback",
  4233. .aif_name = "SLIMBUS_8_RX",
  4234. .rates = SNDRV_PCM_RATE_8000_384000,
  4235. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4236. .channels_min = 1,
  4237. .channels_max = 8,
  4238. .rate_min = 8000,
  4239. .rate_max = 384000,
  4240. },
  4241. .ops = &msm_dai_q6_ops,
  4242. .id = SLIMBUS_8_RX,
  4243. .probe = msm_dai_q6_dai_probe,
  4244. .remove = msm_dai_q6_dai_remove,
  4245. },
  4246. {
  4247. .playback = {
  4248. .stream_name = "Slimbus9 Playback",
  4249. .aif_name = "SLIMBUS_9_RX",
  4250. .rates = SNDRV_PCM_RATE_8000_384000,
  4251. .formats = DAI_FORMATS_S16_S24_S32_LE,
  4252. .channels_min = 1,
  4253. .channels_max = 8,
  4254. .rate_min = 8000,
  4255. .rate_max = 384000,
  4256. },
  4257. .ops = &msm_dai_q6_ops,
  4258. .id = SLIMBUS_9_RX,
  4259. .probe = msm_dai_q6_dai_probe,
  4260. .remove = msm_dai_q6_dai_remove,
  4261. },
  4262. };
  4263. static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
  4264. {
  4265. .capture = {
  4266. .stream_name = "Slimbus Capture",
  4267. .aif_name = "SLIMBUS_0_TX",
  4268. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4269. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4270. SNDRV_PCM_RATE_192000,
  4271. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4272. SNDRV_PCM_FMTBIT_S24_LE |
  4273. SNDRV_PCM_FMTBIT_S24_3LE,
  4274. .channels_min = 1,
  4275. .channels_max = 8,
  4276. .rate_min = 8000,
  4277. .rate_max = 192000,
  4278. },
  4279. .ops = &msm_dai_q6_ops,
  4280. .id = SLIMBUS_0_TX,
  4281. .probe = msm_dai_q6_dai_probe,
  4282. .remove = msm_dai_q6_dai_remove,
  4283. },
  4284. {
  4285. .capture = {
  4286. .stream_name = "Slimbus1 Capture",
  4287. .aif_name = "SLIMBUS_1_TX",
  4288. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4289. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4290. SNDRV_PCM_RATE_192000,
  4291. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4292. SNDRV_PCM_FMTBIT_S24_LE |
  4293. SNDRV_PCM_FMTBIT_S24_3LE,
  4294. .channels_min = 1,
  4295. .channels_max = 2,
  4296. .rate_min = 8000,
  4297. .rate_max = 192000,
  4298. },
  4299. .ops = &msm_dai_q6_ops,
  4300. .id = SLIMBUS_1_TX,
  4301. .probe = msm_dai_q6_dai_probe,
  4302. .remove = msm_dai_q6_dai_remove,
  4303. },
  4304. {
  4305. .capture = {
  4306. .stream_name = "Slimbus2 Capture",
  4307. .aif_name = "SLIMBUS_2_TX",
  4308. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4309. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4310. SNDRV_PCM_RATE_192000,
  4311. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4312. SNDRV_PCM_FMTBIT_S24_LE,
  4313. .channels_min = 1,
  4314. .channels_max = 8,
  4315. .rate_min = 8000,
  4316. .rate_max = 192000,
  4317. },
  4318. .ops = &msm_dai_q6_ops,
  4319. .id = SLIMBUS_2_TX,
  4320. .probe = msm_dai_q6_dai_probe,
  4321. .remove = msm_dai_q6_dai_remove,
  4322. },
  4323. {
  4324. .capture = {
  4325. .stream_name = "Slimbus3 Capture",
  4326. .aif_name = "SLIMBUS_3_TX",
  4327. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4328. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4329. SNDRV_PCM_RATE_192000,
  4330. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4331. SNDRV_PCM_FMTBIT_S24_LE,
  4332. .channels_min = 2,
  4333. .channels_max = 4,
  4334. .rate_min = 8000,
  4335. .rate_max = 192000,
  4336. },
  4337. .ops = &msm_dai_q6_ops,
  4338. .id = SLIMBUS_3_TX,
  4339. .probe = msm_dai_q6_dai_probe,
  4340. .remove = msm_dai_q6_dai_remove,
  4341. },
  4342. {
  4343. .capture = {
  4344. .stream_name = "Slimbus4 Capture",
  4345. .aif_name = "SLIMBUS_4_TX",
  4346. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4347. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4348. SNDRV_PCM_RATE_192000,
  4349. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4350. SNDRV_PCM_FMTBIT_S24_LE |
  4351. SNDRV_PCM_FMTBIT_S32_LE,
  4352. .channels_min = 2,
  4353. .channels_max = 4,
  4354. .rate_min = 8000,
  4355. .rate_max = 192000,
  4356. },
  4357. .ops = &msm_dai_q6_ops,
  4358. .id = SLIMBUS_4_TX,
  4359. .probe = msm_dai_q6_dai_probe,
  4360. .remove = msm_dai_q6_dai_remove,
  4361. },
  4362. {
  4363. .capture = {
  4364. .stream_name = "Slimbus5 Capture",
  4365. .aif_name = "SLIMBUS_5_TX",
  4366. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4367. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4368. SNDRV_PCM_RATE_192000,
  4369. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4370. SNDRV_PCM_FMTBIT_S24_LE,
  4371. .channels_min = 1,
  4372. .channels_max = 8,
  4373. .rate_min = 8000,
  4374. .rate_max = 192000,
  4375. },
  4376. .ops = &msm_dai_q6_ops,
  4377. .id = SLIMBUS_5_TX,
  4378. .probe = msm_dai_q6_dai_probe,
  4379. .remove = msm_dai_q6_dai_remove,
  4380. },
  4381. {
  4382. .capture = {
  4383. .stream_name = "Slimbus6 Capture",
  4384. .aif_name = "SLIMBUS_6_TX",
  4385. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4386. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4387. SNDRV_PCM_RATE_192000,
  4388. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4389. SNDRV_PCM_FMTBIT_S24_LE,
  4390. .channels_min = 1,
  4391. .channels_max = 2,
  4392. .rate_min = 8000,
  4393. .rate_max = 192000,
  4394. },
  4395. .ops = &msm_dai_q6_ops,
  4396. .id = SLIMBUS_6_TX,
  4397. .probe = msm_dai_q6_dai_probe,
  4398. .remove = msm_dai_q6_dai_remove,
  4399. },
  4400. {
  4401. .capture = {
  4402. .stream_name = "Slimbus7 Capture",
  4403. .aif_name = "SLIMBUS_7_TX",
  4404. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4405. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4406. SNDRV_PCM_RATE_192000,
  4407. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4408. SNDRV_PCM_FMTBIT_S24_LE |
  4409. SNDRV_PCM_FMTBIT_S32_LE,
  4410. .channels_min = 1,
  4411. .channels_max = 8,
  4412. .rate_min = 8000,
  4413. .rate_max = 192000,
  4414. },
  4415. .ops = &msm_dai_q6_ops,
  4416. .id = SLIMBUS_7_TX,
  4417. .probe = msm_dai_q6_dai_probe,
  4418. .remove = msm_dai_q6_dai_remove,
  4419. },
  4420. {
  4421. .capture = {
  4422. .stream_name = "Slimbus8 Capture",
  4423. .aif_name = "SLIMBUS_8_TX",
  4424. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4425. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4426. SNDRV_PCM_RATE_192000,
  4427. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4428. SNDRV_PCM_FMTBIT_S24_LE |
  4429. SNDRV_PCM_FMTBIT_S32_LE,
  4430. .channels_min = 1,
  4431. .channels_max = 8,
  4432. .rate_min = 8000,
  4433. .rate_max = 192000,
  4434. },
  4435. .ops = &msm_dai_q6_ops,
  4436. .id = SLIMBUS_8_TX,
  4437. .probe = msm_dai_q6_dai_probe,
  4438. .remove = msm_dai_q6_dai_remove,
  4439. },
  4440. {
  4441. .capture = {
  4442. .stream_name = "Slimbus9 Capture",
  4443. .aif_name = "SLIMBUS_9_TX",
  4444. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  4445. SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
  4446. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
  4447. SNDRV_PCM_RATE_192000,
  4448. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4449. SNDRV_PCM_FMTBIT_S24_LE |
  4450. SNDRV_PCM_FMTBIT_S32_LE,
  4451. .channels_min = 1,
  4452. .channels_max = 8,
  4453. .rate_min = 8000,
  4454. .rate_max = 192000,
  4455. },
  4456. .ops = &msm_dai_q6_ops,
  4457. .id = SLIMBUS_9_TX,
  4458. .probe = msm_dai_q6_dai_probe,
  4459. .remove = msm_dai_q6_dai_remove,
  4460. },
  4461. };
  4462. static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol,
  4463. struct snd_ctl_elem_value *ucontrol)
  4464. {
  4465. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4466. int value = ucontrol->value.integer.value[0];
  4467. dai_data->port_config.i2s.data_format = value;
  4468. pr_debug("%s: value = %d, channel = %d, line = %d\n",
  4469. __func__, value, dai_data->port_config.i2s.mono_stereo,
  4470. dai_data->port_config.i2s.channel_mode);
  4471. return 0;
  4472. }
  4473. static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
  4474. struct snd_ctl_elem_value *ucontrol)
  4475. {
  4476. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4477. ucontrol->value.integer.value[0] =
  4478. dai_data->port_config.i2s.data_format;
  4479. return 0;
  4480. }
  4481. static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
  4482. struct snd_ctl_elem_value *ucontrol)
  4483. {
  4484. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4485. int value = ucontrol->value.integer.value[0];
  4486. dai_data->vi_feed_mono = value;
  4487. pr_debug("%s: value = %d\n", __func__, value);
  4488. return 0;
  4489. }
  4490. static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
  4491. struct snd_ctl_elem_value *ucontrol)
  4492. {
  4493. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  4494. ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
  4495. return 0;
  4496. }
  4497. static const struct snd_kcontrol_new mi2s_config_controls[] = {
  4498. SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
  4499. msm_dai_q6_mi2s_format_get,
  4500. msm_dai_q6_mi2s_format_put),
  4501. SOC_ENUM_EXT("SEC MI2S RX Format", mi2s_config_enum[0],
  4502. msm_dai_q6_mi2s_format_get,
  4503. msm_dai_q6_mi2s_format_put),
  4504. SOC_ENUM_EXT("TERT MI2S RX Format", mi2s_config_enum[0],
  4505. msm_dai_q6_mi2s_format_get,
  4506. msm_dai_q6_mi2s_format_put),
  4507. SOC_ENUM_EXT("QUAT MI2S RX Format", mi2s_config_enum[0],
  4508. msm_dai_q6_mi2s_format_get,
  4509. msm_dai_q6_mi2s_format_put),
  4510. SOC_ENUM_EXT("QUIN MI2S RX Format", mi2s_config_enum[0],
  4511. msm_dai_q6_mi2s_format_get,
  4512. msm_dai_q6_mi2s_format_put),
  4513. SOC_ENUM_EXT("PRI MI2S TX Format", mi2s_config_enum[0],
  4514. msm_dai_q6_mi2s_format_get,
  4515. msm_dai_q6_mi2s_format_put),
  4516. SOC_ENUM_EXT("SEC MI2S TX Format", mi2s_config_enum[0],
  4517. msm_dai_q6_mi2s_format_get,
  4518. msm_dai_q6_mi2s_format_put),
  4519. SOC_ENUM_EXT("TERT MI2S TX Format", mi2s_config_enum[0],
  4520. msm_dai_q6_mi2s_format_get,
  4521. msm_dai_q6_mi2s_format_put),
  4522. SOC_ENUM_EXT("QUAT MI2S TX Format", mi2s_config_enum[0],
  4523. msm_dai_q6_mi2s_format_get,
  4524. msm_dai_q6_mi2s_format_put),
  4525. SOC_ENUM_EXT("QUIN MI2S TX Format", mi2s_config_enum[0],
  4526. msm_dai_q6_mi2s_format_get,
  4527. msm_dai_q6_mi2s_format_put),
  4528. SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
  4529. msm_dai_q6_mi2s_format_get,
  4530. msm_dai_q6_mi2s_format_put),
  4531. SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
  4532. msm_dai_q6_mi2s_format_get,
  4533. msm_dai_q6_mi2s_format_put),
  4534. };
  4535. static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
  4536. SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
  4537. msm_dai_q6_mi2s_vi_feed_mono_get,
  4538. msm_dai_q6_mi2s_vi_feed_mono_put),
  4539. };
  4540. static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
  4541. {
  4542. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4543. dev_get_drvdata(dai->dev);
  4544. struct msm_mi2s_pdata *mi2s_pdata =
  4545. (struct msm_mi2s_pdata *) dai->dev->platform_data;
  4546. struct snd_kcontrol *kcontrol = NULL;
  4547. int rc = 0;
  4548. const struct snd_kcontrol_new *ctrl = NULL;
  4549. const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
  4550. u16 dai_id = 0;
  4551. dai->id = mi2s_pdata->intf_id;
  4552. if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4553. if (dai->id == MSM_PRIM_MI2S)
  4554. ctrl = &mi2s_config_controls[0];
  4555. if (dai->id == MSM_SEC_MI2S)
  4556. ctrl = &mi2s_config_controls[1];
  4557. if (dai->id == MSM_TERT_MI2S)
  4558. ctrl = &mi2s_config_controls[2];
  4559. if (dai->id == MSM_QUAT_MI2S)
  4560. ctrl = &mi2s_config_controls[3];
  4561. if (dai->id == MSM_QUIN_MI2S)
  4562. ctrl = &mi2s_config_controls[4];
  4563. }
  4564. if (ctrl) {
  4565. kcontrol = snd_ctl_new1(ctrl,
  4566. &mi2s_dai_data->rx_dai.mi2s_dai_data);
  4567. rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
  4568. if (rc < 0) {
  4569. dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
  4570. __func__, dai->name);
  4571. goto rtn;
  4572. }
  4573. }
  4574. ctrl = NULL;
  4575. if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  4576. if (dai->id == MSM_PRIM_MI2S)
  4577. ctrl = &mi2s_config_controls[5];
  4578. if (dai->id == MSM_SEC_MI2S)
  4579. ctrl = &mi2s_config_controls[6];
  4580. if (dai->id == MSM_TERT_MI2S)
  4581. ctrl = &mi2s_config_controls[7];
  4582. if (dai->id == MSM_QUAT_MI2S)
  4583. ctrl = &mi2s_config_controls[8];
  4584. if (dai->id == MSM_QUIN_MI2S)
  4585. ctrl = &mi2s_config_controls[9];
  4586. if (dai->id == MSM_SENARY_MI2S)
  4587. ctrl = &mi2s_config_controls[10];
  4588. if (dai->id == MSM_INT5_MI2S)
  4589. ctrl = &mi2s_config_controls[11];
  4590. }
  4591. if (ctrl) {
  4592. rc = snd_ctl_add(dai->component->card->snd_card,
  4593. snd_ctl_new1(ctrl,
  4594. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4595. if (rc < 0) {
  4596. if (kcontrol)
  4597. snd_ctl_remove(dai->component->card->snd_card,
  4598. kcontrol);
  4599. dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
  4600. __func__, dai->name);
  4601. }
  4602. }
  4603. if (dai->id == MSM_INT5_MI2S)
  4604. vi_feed_ctrl = &mi2s_vi_feed_controls[0];
  4605. if (vi_feed_ctrl) {
  4606. rc = snd_ctl_add(dai->component->card->snd_card,
  4607. snd_ctl_new1(vi_feed_ctrl,
  4608. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  4609. if (rc < 0) {
  4610. dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
  4611. __func__, dai->name);
  4612. }
  4613. }
  4614. if (mi2s_dai_data->is_island_dai) {
  4615. msm_mi2s_get_port_id(dai->id, SNDRV_PCM_STREAM_CAPTURE,
  4616. &dai_id);
  4617. rc = msm_dai_q6_add_island_mx_ctls(
  4618. dai->component->card->snd_card,
  4619. dai->name, dai_id,
  4620. (void *)mi2s_dai_data);
  4621. }
  4622. rc = msm_dai_q6_dai_add_route(dai);
  4623. rtn:
  4624. return rc;
  4625. }
  4626. static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
  4627. {
  4628. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4629. dev_get_drvdata(dai->dev);
  4630. int rc;
  4631. /* If AFE port is still up, close it */
  4632. if (test_bit(STATUS_PORT_STARTED,
  4633. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
  4634. rc = afe_close(MI2S_RX); /* can block */
  4635. if (rc < 0)
  4636. dev_err(dai->dev, "fail to close MI2S_RX port\n");
  4637. clear_bit(STATUS_PORT_STARTED,
  4638. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
  4639. }
  4640. if (test_bit(STATUS_PORT_STARTED,
  4641. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  4642. rc = afe_close(MI2S_TX); /* can block */
  4643. if (rc < 0)
  4644. dev_err(dai->dev, "fail to close MI2S_TX port\n");
  4645. clear_bit(STATUS_PORT_STARTED,
  4646. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
  4647. }
  4648. return 0;
  4649. }
  4650. static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
  4651. struct snd_soc_dai *dai)
  4652. {
  4653. return 0;
  4654. }
  4655. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  4656. {
  4657. int ret = 0;
  4658. switch (stream) {
  4659. case SNDRV_PCM_STREAM_PLAYBACK:
  4660. switch (mi2s_id) {
  4661. case MSM_PRIM_MI2S:
  4662. *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  4663. break;
  4664. case MSM_SEC_MI2S:
  4665. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  4666. break;
  4667. case MSM_TERT_MI2S:
  4668. *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  4669. break;
  4670. case MSM_QUAT_MI2S:
  4671. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  4672. break;
  4673. case MSM_SEC_MI2S_SD1:
  4674. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  4675. break;
  4676. case MSM_QUIN_MI2S:
  4677. *port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  4678. break;
  4679. case MSM_SENARY_MI2S:
  4680. *port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  4681. break;
  4682. case MSM_INT0_MI2S:
  4683. *port_id = AFE_PORT_ID_INT0_MI2S_RX;
  4684. break;
  4685. case MSM_INT1_MI2S:
  4686. *port_id = AFE_PORT_ID_INT1_MI2S_RX;
  4687. break;
  4688. case MSM_INT2_MI2S:
  4689. *port_id = AFE_PORT_ID_INT2_MI2S_RX;
  4690. break;
  4691. case MSM_INT3_MI2S:
  4692. *port_id = AFE_PORT_ID_INT3_MI2S_RX;
  4693. break;
  4694. case MSM_INT4_MI2S:
  4695. *port_id = AFE_PORT_ID_INT4_MI2S_RX;
  4696. break;
  4697. case MSM_INT5_MI2S:
  4698. *port_id = AFE_PORT_ID_INT5_MI2S_RX;
  4699. break;
  4700. case MSM_INT6_MI2S:
  4701. *port_id = AFE_PORT_ID_INT6_MI2S_RX;
  4702. break;
  4703. default:
  4704. pr_err("%s: playback err id 0x%x\n",
  4705. __func__, mi2s_id);
  4706. ret = -1;
  4707. break;
  4708. }
  4709. break;
  4710. case SNDRV_PCM_STREAM_CAPTURE:
  4711. switch (mi2s_id) {
  4712. case MSM_PRIM_MI2S:
  4713. *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  4714. break;
  4715. case MSM_SEC_MI2S:
  4716. *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  4717. break;
  4718. case MSM_TERT_MI2S:
  4719. *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  4720. break;
  4721. case MSM_QUAT_MI2S:
  4722. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  4723. break;
  4724. case MSM_QUIN_MI2S:
  4725. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  4726. break;
  4727. case MSM_SENARY_MI2S:
  4728. *port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  4729. break;
  4730. case MSM_INT0_MI2S:
  4731. *port_id = AFE_PORT_ID_INT0_MI2S_TX;
  4732. break;
  4733. case MSM_INT1_MI2S:
  4734. *port_id = AFE_PORT_ID_INT1_MI2S_TX;
  4735. break;
  4736. case MSM_INT2_MI2S:
  4737. *port_id = AFE_PORT_ID_INT2_MI2S_TX;
  4738. break;
  4739. case MSM_INT3_MI2S:
  4740. *port_id = AFE_PORT_ID_INT3_MI2S_TX;
  4741. break;
  4742. case MSM_INT4_MI2S:
  4743. *port_id = AFE_PORT_ID_INT4_MI2S_TX;
  4744. break;
  4745. case MSM_INT5_MI2S:
  4746. *port_id = AFE_PORT_ID_INT5_MI2S_TX;
  4747. break;
  4748. case MSM_INT6_MI2S:
  4749. *port_id = AFE_PORT_ID_INT6_MI2S_TX;
  4750. break;
  4751. default:
  4752. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  4753. ret = -1;
  4754. break;
  4755. }
  4756. break;
  4757. default:
  4758. pr_err("%s: default err %d\n", __func__, stream);
  4759. ret = -1;
  4760. break;
  4761. }
  4762. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  4763. return ret;
  4764. }
  4765. static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
  4766. struct snd_soc_dai *dai)
  4767. {
  4768. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4769. dev_get_drvdata(dai->dev);
  4770. struct msm_dai_q6_dai_data *dai_data =
  4771. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4772. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4773. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4774. u16 port_id = 0;
  4775. int rc = 0;
  4776. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  4777. &port_id) != 0) {
  4778. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  4779. __func__, port_id);
  4780. return -EINVAL;
  4781. }
  4782. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  4783. "dai_data->channels = %u sample_rate = %u\n", __func__,
  4784. dai->id, port_id, dai_data->channels, dai_data->rate);
  4785. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  4786. /* PORT START should be set if prepare called
  4787. * in active state.
  4788. */
  4789. rc = afe_port_start(port_id, &dai_data->port_config,
  4790. dai_data->rate);
  4791. if (rc < 0)
  4792. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  4793. dai->id);
  4794. else
  4795. set_bit(STATUS_PORT_STARTED,
  4796. dai_data->status_mask);
  4797. }
  4798. if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  4799. set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4800. dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
  4801. __func__);
  4802. }
  4803. return rc;
  4804. }
  4805. static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
  4806. struct snd_pcm_hw_params *params,
  4807. struct snd_soc_dai *dai)
  4808. {
  4809. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4810. dev_get_drvdata(dai->dev);
  4811. struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
  4812. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4813. &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
  4814. struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
  4815. struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
  4816. dai_data->channels = params_channels(params);
  4817. switch (dai_data->channels) {
  4818. case 15:
  4819. case 16:
  4820. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4821. case AFE_PORT_I2S_16CHS:
  4822. dai_data->port_config.i2s.channel_mode
  4823. = AFE_PORT_I2S_16CHS;
  4824. break;
  4825. default:
  4826. goto error_invalid_data;
  4827. };
  4828. break;
  4829. case 13:
  4830. case 14:
  4831. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4832. case AFE_PORT_I2S_14CHS:
  4833. case AFE_PORT_I2S_16CHS:
  4834. dai_data->port_config.i2s.channel_mode
  4835. = AFE_PORT_I2S_14CHS;
  4836. break;
  4837. default:
  4838. goto error_invalid_data;
  4839. };
  4840. break;
  4841. case 11:
  4842. case 12:
  4843. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4844. case AFE_PORT_I2S_12CHS:
  4845. case AFE_PORT_I2S_14CHS:
  4846. case AFE_PORT_I2S_16CHS:
  4847. dai_data->port_config.i2s.channel_mode
  4848. = AFE_PORT_I2S_12CHS;
  4849. break;
  4850. default:
  4851. goto error_invalid_data;
  4852. };
  4853. break;
  4854. case 9:
  4855. case 10:
  4856. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4857. case AFE_PORT_I2S_10CHS:
  4858. case AFE_PORT_I2S_12CHS:
  4859. case AFE_PORT_I2S_14CHS:
  4860. case AFE_PORT_I2S_16CHS:
  4861. dai_data->port_config.i2s.channel_mode
  4862. = AFE_PORT_I2S_10CHS;
  4863. break;
  4864. default:
  4865. goto error_invalid_data;
  4866. };
  4867. break;
  4868. case 8:
  4869. case 7:
  4870. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
  4871. goto error_invalid_data;
  4872. else
  4873. if (mi2s_dai_config->pdata_mi2s_lines
  4874. == AFE_PORT_I2S_8CHS_2)
  4875. dai_data->port_config.i2s.channel_mode =
  4876. AFE_PORT_I2S_8CHS_2;
  4877. else
  4878. dai_data->port_config.i2s.channel_mode =
  4879. AFE_PORT_I2S_8CHS;
  4880. break;
  4881. case 6:
  4882. case 5:
  4883. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
  4884. goto error_invalid_data;
  4885. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
  4886. break;
  4887. case 4:
  4888. case 3:
  4889. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4890. case AFE_PORT_I2S_SD0:
  4891. case AFE_PORT_I2S_SD1:
  4892. case AFE_PORT_I2S_SD2:
  4893. case AFE_PORT_I2S_SD3:
  4894. case AFE_PORT_I2S_SD4:
  4895. case AFE_PORT_I2S_SD5:
  4896. case AFE_PORT_I2S_SD6:
  4897. case AFE_PORT_I2S_SD7:
  4898. goto error_invalid_data;
  4899. break;
  4900. case AFE_PORT_I2S_QUAD01:
  4901. case AFE_PORT_I2S_QUAD23:
  4902. case AFE_PORT_I2S_QUAD45:
  4903. case AFE_PORT_I2S_QUAD67:
  4904. dai_data->port_config.i2s.channel_mode =
  4905. mi2s_dai_config->pdata_mi2s_lines;
  4906. break;
  4907. case AFE_PORT_I2S_8CHS_2:
  4908. dai_data->port_config.i2s.channel_mode =
  4909. AFE_PORT_I2S_QUAD45;
  4910. break;
  4911. default:
  4912. dai_data->port_config.i2s.channel_mode =
  4913. AFE_PORT_I2S_QUAD01;
  4914. break;
  4915. };
  4916. break;
  4917. case 2:
  4918. case 1:
  4919. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
  4920. goto error_invalid_data;
  4921. switch (mi2s_dai_config->pdata_mi2s_lines) {
  4922. case AFE_PORT_I2S_SD0:
  4923. case AFE_PORT_I2S_SD1:
  4924. case AFE_PORT_I2S_SD2:
  4925. case AFE_PORT_I2S_SD3:
  4926. case AFE_PORT_I2S_SD4:
  4927. case AFE_PORT_I2S_SD5:
  4928. case AFE_PORT_I2S_SD6:
  4929. case AFE_PORT_I2S_SD7:
  4930. dai_data->port_config.i2s.channel_mode =
  4931. mi2s_dai_config->pdata_mi2s_lines;
  4932. break;
  4933. case AFE_PORT_I2S_QUAD01:
  4934. case AFE_PORT_I2S_6CHS:
  4935. case AFE_PORT_I2S_8CHS:
  4936. case AFE_PORT_I2S_10CHS:
  4937. case AFE_PORT_I2S_12CHS:
  4938. case AFE_PORT_I2S_14CHS:
  4939. case AFE_PORT_I2S_16CHS:
  4940. if (dai_data->vi_feed_mono == SPKR_1)
  4941. dai_data->port_config.i2s.channel_mode =
  4942. AFE_PORT_I2S_SD0;
  4943. else
  4944. dai_data->port_config.i2s.channel_mode =
  4945. AFE_PORT_I2S_SD1;
  4946. break;
  4947. case AFE_PORT_I2S_QUAD23:
  4948. dai_data->port_config.i2s.channel_mode =
  4949. AFE_PORT_I2S_SD2;
  4950. break;
  4951. case AFE_PORT_I2S_QUAD45:
  4952. dai_data->port_config.i2s.channel_mode =
  4953. AFE_PORT_I2S_SD4;
  4954. break;
  4955. case AFE_PORT_I2S_QUAD67:
  4956. dai_data->port_config.i2s.channel_mode =
  4957. AFE_PORT_I2S_SD6;
  4958. break;
  4959. }
  4960. if (dai_data->channels == 2)
  4961. dai_data->port_config.i2s.mono_stereo =
  4962. MSM_AFE_CH_STEREO;
  4963. else
  4964. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  4965. break;
  4966. default:
  4967. pr_err("%s: default err channels %d\n",
  4968. __func__, dai_data->channels);
  4969. goto error_invalid_data;
  4970. }
  4971. dai_data->rate = params_rate(params);
  4972. switch (params_format(params)) {
  4973. case SNDRV_PCM_FORMAT_S16_LE:
  4974. case SNDRV_PCM_FORMAT_SPECIAL:
  4975. dai_data->port_config.i2s.bit_width = 16;
  4976. dai_data->bitwidth = 16;
  4977. break;
  4978. case SNDRV_PCM_FORMAT_S24_LE:
  4979. case SNDRV_PCM_FORMAT_S24_3LE:
  4980. dai_data->port_config.i2s.bit_width = 24;
  4981. dai_data->bitwidth = 24;
  4982. break;
  4983. default:
  4984. pr_err("%s: format %d\n",
  4985. __func__, params_format(params));
  4986. return -EINVAL;
  4987. }
  4988. dai_data->port_config.i2s.i2s_cfg_minor_version =
  4989. AFE_API_VERSION_I2S_CONFIG;
  4990. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  4991. if ((test_bit(STATUS_PORT_STARTED,
  4992. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
  4993. test_bit(STATUS_PORT_STARTED,
  4994. mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
  4995. (test_bit(STATUS_PORT_STARTED,
  4996. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
  4997. test_bit(STATUS_PORT_STARTED,
  4998. mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
  4999. if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
  5000. mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
  5001. (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
  5002. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
  5003. dev_err(dai->dev, "%s: Error mismatch in HW params\n"
  5004. "Tx sample_rate = %u bit_width = %hu\n"
  5005. "Rx sample_rate = %u bit_width = %hu\n"
  5006. , __func__,
  5007. mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
  5008. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
  5009. mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
  5010. mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
  5011. return -EINVAL;
  5012. }
  5013. }
  5014. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  5015. "sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
  5016. "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n"
  5017. "ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
  5018. "reserved = %u\n", __func__, dai->id, dai_data->channels,
  5019. dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
  5020. i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
  5021. i2s->sample_rate, i2s->data_format, i2s->reserved);
  5022. return 0;
  5023. error_invalid_data:
  5024. pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
  5025. dai_data->channels, dai_data->port_config.i2s.channel_mode);
  5026. return -EINVAL;
  5027. }
  5028. static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  5029. {
  5030. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5031. dev_get_drvdata(dai->dev);
  5032. if (test_bit(STATUS_PORT_STARTED,
  5033. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
  5034. test_bit(STATUS_PORT_STARTED,
  5035. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  5036. dev_err(dai->dev, "%s: err chg i2s mode while dai running",
  5037. __func__);
  5038. return -EPERM;
  5039. }
  5040. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  5041. case SND_SOC_DAIFMT_CBS_CFS:
  5042. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  5043. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  5044. break;
  5045. case SND_SOC_DAIFMT_CBM_CFM:
  5046. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  5047. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  5048. break;
  5049. default:
  5050. pr_err("%s: fmt %d\n",
  5051. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  5052. return -EINVAL;
  5053. }
  5054. return 0;
  5055. }
  5056. static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
  5057. struct snd_soc_dai *dai)
  5058. {
  5059. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5060. dev_get_drvdata(dai->dev);
  5061. struct msm_dai_q6_dai_data *dai_data =
  5062. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5063. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  5064. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  5065. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  5066. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  5067. dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
  5068. }
  5069. return 0;
  5070. }
  5071. static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
  5072. struct snd_soc_dai *dai)
  5073. {
  5074. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  5075. dev_get_drvdata(dai->dev);
  5076. struct msm_dai_q6_dai_data *dai_data =
  5077. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  5078. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  5079. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  5080. u16 port_id = 0;
  5081. int rc = 0;
  5082. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  5083. &port_id) != 0) {
  5084. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  5085. __func__, port_id);
  5086. }
  5087. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  5088. __func__, port_id);
  5089. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  5090. rc = afe_close(port_id);
  5091. if (rc < 0)
  5092. dev_err(dai->dev, "fail to close AFE port\n");
  5093. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  5094. }
  5095. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  5096. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  5097. }
  5098. static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
  5099. .startup = msm_dai_q6_mi2s_startup,
  5100. .prepare = msm_dai_q6_mi2s_prepare,
  5101. .hw_params = msm_dai_q6_mi2s_hw_params,
  5102. .hw_free = msm_dai_q6_mi2s_hw_free,
  5103. .set_fmt = msm_dai_q6_mi2s_set_fmt,
  5104. .shutdown = msm_dai_q6_mi2s_shutdown,
  5105. };
  5106. /* Channel min and max are initialized base on platform data */
  5107. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  5108. {
  5109. .playback = {
  5110. .stream_name = "Primary MI2S Playback",
  5111. .aif_name = "PRI_MI2S_RX",
  5112. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5113. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5114. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5115. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  5116. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  5117. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  5118. SNDRV_PCM_RATE_384000,
  5119. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5120. SNDRV_PCM_FMTBIT_S24_LE |
  5121. SNDRV_PCM_FMTBIT_S24_3LE,
  5122. .rate_min = 8000,
  5123. .rate_max = 384000,
  5124. },
  5125. .capture = {
  5126. .stream_name = "Primary MI2S Capture",
  5127. .aif_name = "PRI_MI2S_TX",
  5128. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5129. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5130. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5131. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5132. SNDRV_PCM_RATE_192000,
  5133. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5134. .rate_min = 8000,
  5135. .rate_max = 192000,
  5136. },
  5137. .ops = &msm_dai_q6_mi2s_ops,
  5138. .name = "Primary MI2S",
  5139. .id = MSM_PRIM_MI2S,
  5140. .probe = msm_dai_q6_dai_mi2s_probe,
  5141. .remove = msm_dai_q6_dai_mi2s_remove,
  5142. },
  5143. {
  5144. .playback = {
  5145. .stream_name = "Secondary MI2S Playback",
  5146. .aif_name = "SEC_MI2S_RX",
  5147. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5148. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5149. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5150. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5151. SNDRV_PCM_RATE_192000,
  5152. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5153. .rate_min = 8000,
  5154. .rate_max = 192000,
  5155. },
  5156. .capture = {
  5157. .stream_name = "Secondary MI2S Capture",
  5158. .aif_name = "SEC_MI2S_TX",
  5159. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5160. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5161. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5162. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5163. SNDRV_PCM_RATE_192000,
  5164. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5165. .rate_min = 8000,
  5166. .rate_max = 192000,
  5167. },
  5168. .ops = &msm_dai_q6_mi2s_ops,
  5169. .name = "Secondary MI2S",
  5170. .id = MSM_SEC_MI2S,
  5171. .probe = msm_dai_q6_dai_mi2s_probe,
  5172. .remove = msm_dai_q6_dai_mi2s_remove,
  5173. },
  5174. {
  5175. .playback = {
  5176. .stream_name = "Tertiary MI2S Playback",
  5177. .aif_name = "TERT_MI2S_RX",
  5178. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5179. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5180. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5181. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5182. SNDRV_PCM_RATE_192000,
  5183. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5184. .rate_min = 8000,
  5185. .rate_max = 192000,
  5186. },
  5187. .capture = {
  5188. .stream_name = "Tertiary MI2S Capture",
  5189. .aif_name = "TERT_MI2S_TX",
  5190. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5191. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5192. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5193. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5194. SNDRV_PCM_RATE_192000,
  5195. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5196. .rate_min = 8000,
  5197. .rate_max = 192000,
  5198. },
  5199. .ops = &msm_dai_q6_mi2s_ops,
  5200. .name = "Tertiary MI2S",
  5201. .id = MSM_TERT_MI2S,
  5202. .probe = msm_dai_q6_dai_mi2s_probe,
  5203. .remove = msm_dai_q6_dai_mi2s_remove,
  5204. },
  5205. {
  5206. .playback = {
  5207. .stream_name = "Quaternary MI2S Playback",
  5208. .aif_name = "QUAT_MI2S_RX",
  5209. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5210. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5211. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5212. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5213. SNDRV_PCM_RATE_192000,
  5214. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5215. .rate_min = 8000,
  5216. .rate_max = 192000,
  5217. },
  5218. .capture = {
  5219. .stream_name = "Quaternary MI2S Capture",
  5220. .aif_name = "QUAT_MI2S_TX",
  5221. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  5222. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  5223. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  5224. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  5225. SNDRV_PCM_RATE_192000,
  5226. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5227. .rate_min = 8000,
  5228. .rate_max = 192000,
  5229. },
  5230. .ops = &msm_dai_q6_mi2s_ops,
  5231. .name = "Quaternary MI2S",
  5232. .id = MSM_QUAT_MI2S,
  5233. .probe = msm_dai_q6_dai_mi2s_probe,
  5234. .remove = msm_dai_q6_dai_mi2s_remove,
  5235. },
  5236. {
  5237. .playback = {
  5238. .stream_name = "Quinary MI2S Playback",
  5239. .aif_name = "QUIN_MI2S_RX",
  5240. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5241. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5242. SNDRV_PCM_RATE_192000,
  5243. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5244. .rate_min = 8000,
  5245. .rate_max = 192000,
  5246. },
  5247. .capture = {
  5248. .stream_name = "Quinary MI2S Capture",
  5249. .aif_name = "QUIN_MI2S_TX",
  5250. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5251. SNDRV_PCM_RATE_16000,
  5252. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5253. .rate_min = 8000,
  5254. .rate_max = 48000,
  5255. },
  5256. .ops = &msm_dai_q6_mi2s_ops,
  5257. .name = "Quinary MI2S",
  5258. .id = MSM_QUIN_MI2S,
  5259. .probe = msm_dai_q6_dai_mi2s_probe,
  5260. .remove = msm_dai_q6_dai_mi2s_remove,
  5261. },
  5262. {
  5263. .playback = {
  5264. .stream_name = "Senary MI2S Playback",
  5265. .aif_name = "SEN_MI2S_RX",
  5266. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5267. SNDRV_PCM_RATE_16000,
  5268. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5269. .rate_min = 8000,
  5270. .rate_max = 48000,
  5271. },
  5272. .capture = {
  5273. .stream_name = "Senary MI2S Capture",
  5274. .aif_name = "SENARY_MI2S_TX",
  5275. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5276. SNDRV_PCM_RATE_16000,
  5277. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5278. .rate_min = 8000,
  5279. .rate_max = 48000,
  5280. },
  5281. .ops = &msm_dai_q6_mi2s_ops,
  5282. .name = "Senary MI2S",
  5283. .id = MSM_SENARY_MI2S,
  5284. .probe = msm_dai_q6_dai_mi2s_probe,
  5285. .remove = msm_dai_q6_dai_mi2s_remove,
  5286. },
  5287. {
  5288. .playback = {
  5289. .stream_name = "Secondary MI2S Playback SD1",
  5290. .aif_name = "SEC_MI2S_RX_SD1",
  5291. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5292. SNDRV_PCM_RATE_16000,
  5293. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5294. .rate_min = 8000,
  5295. .rate_max = 48000,
  5296. },
  5297. .id = MSM_SEC_MI2S_SD1,
  5298. },
  5299. {
  5300. .playback = {
  5301. .stream_name = "INT0 MI2S Playback",
  5302. .aif_name = "INT0_MI2S_RX",
  5303. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5304. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  5305. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  5306. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5307. SNDRV_PCM_FMTBIT_S24_LE |
  5308. SNDRV_PCM_FMTBIT_S24_3LE,
  5309. .rate_min = 8000,
  5310. .rate_max = 192000,
  5311. },
  5312. .capture = {
  5313. .stream_name = "INT0 MI2S Capture",
  5314. .aif_name = "INT0_MI2S_TX",
  5315. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5316. SNDRV_PCM_RATE_16000,
  5317. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5318. .rate_min = 8000,
  5319. .rate_max = 48000,
  5320. },
  5321. .ops = &msm_dai_q6_mi2s_ops,
  5322. .name = "INT0 MI2S",
  5323. .id = MSM_INT0_MI2S,
  5324. .probe = msm_dai_q6_dai_mi2s_probe,
  5325. .remove = msm_dai_q6_dai_mi2s_remove,
  5326. },
  5327. {
  5328. .playback = {
  5329. .stream_name = "INT1 MI2S Playback",
  5330. .aif_name = "INT1_MI2S_RX",
  5331. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5332. SNDRV_PCM_RATE_16000,
  5333. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5334. SNDRV_PCM_FMTBIT_S24_LE |
  5335. SNDRV_PCM_FMTBIT_S24_3LE,
  5336. .rate_min = 8000,
  5337. .rate_max = 48000,
  5338. },
  5339. .capture = {
  5340. .stream_name = "INT1 MI2S Capture",
  5341. .aif_name = "INT1_MI2S_TX",
  5342. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5343. SNDRV_PCM_RATE_16000,
  5344. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5345. .rate_min = 8000,
  5346. .rate_max = 48000,
  5347. },
  5348. .ops = &msm_dai_q6_mi2s_ops,
  5349. .name = "INT1 MI2S",
  5350. .id = MSM_INT1_MI2S,
  5351. .probe = msm_dai_q6_dai_mi2s_probe,
  5352. .remove = msm_dai_q6_dai_mi2s_remove,
  5353. },
  5354. {
  5355. .playback = {
  5356. .stream_name = "INT2 MI2S Playback",
  5357. .aif_name = "INT2_MI2S_RX",
  5358. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5359. SNDRV_PCM_RATE_16000,
  5360. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5361. SNDRV_PCM_FMTBIT_S24_LE |
  5362. SNDRV_PCM_FMTBIT_S24_3LE,
  5363. .rate_min = 8000,
  5364. .rate_max = 48000,
  5365. },
  5366. .capture = {
  5367. .stream_name = "INT2 MI2S Capture",
  5368. .aif_name = "INT2_MI2S_TX",
  5369. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5370. SNDRV_PCM_RATE_16000,
  5371. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5372. .rate_min = 8000,
  5373. .rate_max = 48000,
  5374. },
  5375. .ops = &msm_dai_q6_mi2s_ops,
  5376. .name = "INT2 MI2S",
  5377. .id = MSM_INT2_MI2S,
  5378. .probe = msm_dai_q6_dai_mi2s_probe,
  5379. .remove = msm_dai_q6_dai_mi2s_remove,
  5380. },
  5381. {
  5382. .playback = {
  5383. .stream_name = "INT3 MI2S Playback",
  5384. .aif_name = "INT3_MI2S_RX",
  5385. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5386. SNDRV_PCM_RATE_16000,
  5387. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5388. SNDRV_PCM_FMTBIT_S24_LE |
  5389. SNDRV_PCM_FMTBIT_S24_3LE,
  5390. .rate_min = 8000,
  5391. .rate_max = 48000,
  5392. },
  5393. .capture = {
  5394. .stream_name = "INT3 MI2S Capture",
  5395. .aif_name = "INT3_MI2S_TX",
  5396. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5397. SNDRV_PCM_RATE_16000,
  5398. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5399. .rate_min = 8000,
  5400. .rate_max = 48000,
  5401. },
  5402. .ops = &msm_dai_q6_mi2s_ops,
  5403. .name = "INT3 MI2S",
  5404. .id = MSM_INT3_MI2S,
  5405. .probe = msm_dai_q6_dai_mi2s_probe,
  5406. .remove = msm_dai_q6_dai_mi2s_remove,
  5407. },
  5408. {
  5409. .playback = {
  5410. .stream_name = "INT4 MI2S Playback",
  5411. .aif_name = "INT4_MI2S_RX",
  5412. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5413. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  5414. SNDRV_PCM_RATE_192000,
  5415. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5416. SNDRV_PCM_FMTBIT_S24_LE |
  5417. SNDRV_PCM_FMTBIT_S24_3LE,
  5418. .rate_min = 8000,
  5419. .rate_max = 192000,
  5420. },
  5421. .capture = {
  5422. .stream_name = "INT4 MI2S Capture",
  5423. .aif_name = "INT4_MI2S_TX",
  5424. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5425. SNDRV_PCM_RATE_16000,
  5426. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5427. .rate_min = 8000,
  5428. .rate_max = 48000,
  5429. },
  5430. .ops = &msm_dai_q6_mi2s_ops,
  5431. .name = "INT4 MI2S",
  5432. .id = MSM_INT4_MI2S,
  5433. .probe = msm_dai_q6_dai_mi2s_probe,
  5434. .remove = msm_dai_q6_dai_mi2s_remove,
  5435. },
  5436. {
  5437. .playback = {
  5438. .stream_name = "INT5 MI2S Playback",
  5439. .aif_name = "INT5_MI2S_RX",
  5440. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5441. SNDRV_PCM_RATE_16000,
  5442. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5443. SNDRV_PCM_FMTBIT_S24_LE |
  5444. SNDRV_PCM_FMTBIT_S24_3LE,
  5445. .rate_min = 8000,
  5446. .rate_max = 48000,
  5447. },
  5448. .capture = {
  5449. .stream_name = "INT5 MI2S Capture",
  5450. .aif_name = "INT5_MI2S_TX",
  5451. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5452. SNDRV_PCM_RATE_16000,
  5453. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5454. .rate_min = 8000,
  5455. .rate_max = 48000,
  5456. },
  5457. .ops = &msm_dai_q6_mi2s_ops,
  5458. .name = "INT5 MI2S",
  5459. .id = MSM_INT5_MI2S,
  5460. .probe = msm_dai_q6_dai_mi2s_probe,
  5461. .remove = msm_dai_q6_dai_mi2s_remove,
  5462. },
  5463. {
  5464. .playback = {
  5465. .stream_name = "INT6 MI2S Playback",
  5466. .aif_name = "INT6_MI2S_RX",
  5467. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5468. SNDRV_PCM_RATE_16000,
  5469. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  5470. SNDRV_PCM_FMTBIT_S24_LE |
  5471. SNDRV_PCM_FMTBIT_S24_3LE,
  5472. .rate_min = 8000,
  5473. .rate_max = 48000,
  5474. },
  5475. .capture = {
  5476. .stream_name = "INT6 MI2S Capture",
  5477. .aif_name = "INT6_MI2S_TX",
  5478. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  5479. SNDRV_PCM_RATE_16000,
  5480. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  5481. .rate_min = 8000,
  5482. .rate_max = 48000,
  5483. },
  5484. .ops = &msm_dai_q6_mi2s_ops,
  5485. .name = "INT6 MI2S",
  5486. .id = MSM_INT6_MI2S,
  5487. .probe = msm_dai_q6_dai_mi2s_probe,
  5488. .remove = msm_dai_q6_dai_mi2s_remove,
  5489. },
  5490. };
  5491. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  5492. unsigned int *ch_cnt)
  5493. {
  5494. u8 num_of_sd_lines;
  5495. num_of_sd_lines = num_of_bits_set(sd_lines);
  5496. switch (num_of_sd_lines) {
  5497. case 0:
  5498. pr_debug("%s: no line is assigned\n", __func__);
  5499. break;
  5500. case 1:
  5501. switch (sd_lines) {
  5502. case MSM_MI2S_SD0:
  5503. *config_ptr = AFE_PORT_I2S_SD0;
  5504. break;
  5505. case MSM_MI2S_SD1:
  5506. *config_ptr = AFE_PORT_I2S_SD1;
  5507. break;
  5508. case MSM_MI2S_SD2:
  5509. *config_ptr = AFE_PORT_I2S_SD2;
  5510. break;
  5511. case MSM_MI2S_SD3:
  5512. *config_ptr = AFE_PORT_I2S_SD3;
  5513. break;
  5514. case MSM_MI2S_SD4:
  5515. *config_ptr = AFE_PORT_I2S_SD4;
  5516. break;
  5517. case MSM_MI2S_SD5:
  5518. *config_ptr = AFE_PORT_I2S_SD5;
  5519. break;
  5520. case MSM_MI2S_SD6:
  5521. *config_ptr = AFE_PORT_I2S_SD6;
  5522. break;
  5523. case MSM_MI2S_SD7:
  5524. *config_ptr = AFE_PORT_I2S_SD7;
  5525. break;
  5526. default:
  5527. pr_err("%s: invalid SD lines %d\n",
  5528. __func__, sd_lines);
  5529. goto error_invalid_data;
  5530. }
  5531. break;
  5532. case 2:
  5533. switch (sd_lines) {
  5534. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  5535. *config_ptr = AFE_PORT_I2S_QUAD01;
  5536. break;
  5537. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5538. *config_ptr = AFE_PORT_I2S_QUAD23;
  5539. break;
  5540. case MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5541. *config_ptr = AFE_PORT_I2S_QUAD45;
  5542. break;
  5543. case MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5544. *config_ptr = AFE_PORT_I2S_QUAD67;
  5545. break;
  5546. default:
  5547. pr_err("%s: invalid SD lines %d\n",
  5548. __func__, sd_lines);
  5549. goto error_invalid_data;
  5550. }
  5551. break;
  5552. case 3:
  5553. switch (sd_lines) {
  5554. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  5555. *config_ptr = AFE_PORT_I2S_6CHS;
  5556. break;
  5557. default:
  5558. pr_err("%s: invalid SD lines %d\n",
  5559. __func__, sd_lines);
  5560. goto error_invalid_data;
  5561. }
  5562. break;
  5563. case 4:
  5564. switch (sd_lines) {
  5565. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  5566. *config_ptr = AFE_PORT_I2S_8CHS;
  5567. break;
  5568. case MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5569. *config_ptr = AFE_PORT_I2S_8CHS_2;
  5570. break;
  5571. default:
  5572. pr_err("%s: invalid SD lines %d\n",
  5573. __func__, sd_lines);
  5574. goto error_invalid_data;
  5575. }
  5576. break;
  5577. case 5:
  5578. switch (sd_lines) {
  5579. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5580. | MSM_MI2S_SD3 | MSM_MI2S_SD4:
  5581. *config_ptr = AFE_PORT_I2S_10CHS;
  5582. break;
  5583. default:
  5584. pr_err("%s: invalid SD lines %d\n",
  5585. __func__, sd_lines);
  5586. goto error_invalid_data;
  5587. }
  5588. break;
  5589. case 6:
  5590. switch (sd_lines) {
  5591. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2
  5592. | MSM_MI2S_SD3 | MSM_MI2S_SD4 | MSM_MI2S_SD5:
  5593. *config_ptr = AFE_PORT_I2S_12CHS;
  5594. break;
  5595. default:
  5596. pr_err("%s: invalid SD lines %d\n",
  5597. __func__, sd_lines);
  5598. goto error_invalid_data;
  5599. }
  5600. break;
  5601. case 7:
  5602. switch (sd_lines) {
  5603. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  5604. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6:
  5605. *config_ptr = AFE_PORT_I2S_14CHS;
  5606. break;
  5607. default:
  5608. pr_err("%s: invalid SD lines %d\n",
  5609. __func__, sd_lines);
  5610. goto error_invalid_data;
  5611. }
  5612. break;
  5613. case 8:
  5614. switch (sd_lines) {
  5615. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3
  5616. | MSM_MI2S_SD4 | MSM_MI2S_SD5 | MSM_MI2S_SD6 | MSM_MI2S_SD7:
  5617. *config_ptr = AFE_PORT_I2S_16CHS;
  5618. break;
  5619. default:
  5620. pr_err("%s: invalid SD lines %d\n",
  5621. __func__, sd_lines);
  5622. goto error_invalid_data;
  5623. }
  5624. break;
  5625. default:
  5626. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  5627. goto error_invalid_data;
  5628. }
  5629. *ch_cnt = num_of_sd_lines;
  5630. return 0;
  5631. error_invalid_data:
  5632. pr_err("%s: invalid data\n", __func__);
  5633. return -EINVAL;
  5634. }
  5635. static u16 msm_dai_q6_mi2s_get_num_channels(u16 config)
  5636. {
  5637. switch (config) {
  5638. case AFE_PORT_I2S_SD0:
  5639. case AFE_PORT_I2S_SD1:
  5640. case AFE_PORT_I2S_SD2:
  5641. case AFE_PORT_I2S_SD3:
  5642. case AFE_PORT_I2S_SD4:
  5643. case AFE_PORT_I2S_SD5:
  5644. case AFE_PORT_I2S_SD6:
  5645. case AFE_PORT_I2S_SD7:
  5646. return 2;
  5647. case AFE_PORT_I2S_QUAD01:
  5648. case AFE_PORT_I2S_QUAD23:
  5649. case AFE_PORT_I2S_QUAD45:
  5650. case AFE_PORT_I2S_QUAD67:
  5651. return 4;
  5652. case AFE_PORT_I2S_6CHS:
  5653. return 6;
  5654. case AFE_PORT_I2S_8CHS:
  5655. case AFE_PORT_I2S_8CHS_2:
  5656. return 8;
  5657. case AFE_PORT_I2S_10CHS:
  5658. return 10;
  5659. case AFE_PORT_I2S_12CHS:
  5660. return 12;
  5661. case AFE_PORT_I2S_14CHS:
  5662. return 14;
  5663. case AFE_PORT_I2S_16CHS:
  5664. return 16;
  5665. default:
  5666. pr_err("%s: invalid config\n", __func__);
  5667. return 0;
  5668. }
  5669. }
  5670. static int msm_dai_q6_mi2s_platform_data_validation(
  5671. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  5672. {
  5673. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  5674. struct msm_mi2s_pdata *mi2s_pdata =
  5675. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  5676. unsigned int ch_cnt;
  5677. int rc = 0;
  5678. u16 sd_line;
  5679. if (mi2s_pdata == NULL) {
  5680. pr_err("%s: mi2s_pdata NULL", __func__);
  5681. return -EINVAL;
  5682. }
  5683. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  5684. &sd_line, &ch_cnt);
  5685. if (rc < 0) {
  5686. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  5687. goto rtn;
  5688. }
  5689. if (ch_cnt) {
  5690. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  5691. sd_line;
  5692. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  5693. dai_driver->playback.channels_min = 1;
  5694. dai_driver->playback.channels_max = ch_cnt << 1;
  5695. } else {
  5696. dai_driver->playback.channels_min = 0;
  5697. dai_driver->playback.channels_max = 0;
  5698. }
  5699. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  5700. &sd_line, &ch_cnt);
  5701. if (rc < 0) {
  5702. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  5703. goto rtn;
  5704. }
  5705. if (ch_cnt) {
  5706. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  5707. sd_line;
  5708. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  5709. dai_driver->capture.channels_min = 1;
  5710. dai_driver->capture.channels_max = ch_cnt << 1;
  5711. } else {
  5712. dai_driver->capture.channels_min = 0;
  5713. dai_driver->capture.channels_max = 0;
  5714. }
  5715. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  5716. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  5717. dai_data->tx_dai.pdata_mi2s_lines);
  5718. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  5719. __func__, dai_driver->playback.channels_max,
  5720. dai_driver->capture.channels_max);
  5721. rtn:
  5722. return rc;
  5723. }
  5724. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  5725. .name = "msm-dai-q6-mi2s",
  5726. };
  5727. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  5728. {
  5729. struct msm_dai_q6_mi2s_dai_data *dai_data;
  5730. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  5731. u32 tx_line = 0;
  5732. u32 rx_line = 0;
  5733. u32 mi2s_intf = 0;
  5734. struct msm_mi2s_pdata *mi2s_pdata;
  5735. int rc;
  5736. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  5737. &mi2s_intf);
  5738. if (rc) {
  5739. dev_err(&pdev->dev,
  5740. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  5741. goto rtn;
  5742. }
  5743. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  5744. mi2s_intf);
  5745. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  5746. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  5747. dev_err(&pdev->dev,
  5748. "%s: Invalid MI2S ID %u from Device Tree\n",
  5749. __func__, mi2s_intf);
  5750. rc = -ENXIO;
  5751. goto rtn;
  5752. }
  5753. pdev->id = mi2s_intf;
  5754. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  5755. if (!mi2s_pdata) {
  5756. rc = -ENOMEM;
  5757. goto rtn;
  5758. }
  5759. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  5760. &rx_line);
  5761. if (rc) {
  5762. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  5763. "qcom,msm-mi2s-rx-lines");
  5764. goto free_pdata;
  5765. }
  5766. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  5767. &tx_line);
  5768. if (rc) {
  5769. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  5770. "qcom,msm-mi2s-tx-lines");
  5771. goto free_pdata;
  5772. }
  5773. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  5774. dev_name(&pdev->dev), rx_line, tx_line);
  5775. mi2s_pdata->rx_sd_lines = rx_line;
  5776. mi2s_pdata->tx_sd_lines = tx_line;
  5777. mi2s_pdata->intf_id = mi2s_intf;
  5778. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  5779. GFP_KERNEL);
  5780. if (!dai_data) {
  5781. rc = -ENOMEM;
  5782. goto free_pdata;
  5783. } else
  5784. dev_set_drvdata(&pdev->dev, dai_data);
  5785. rc = of_property_read_u32(pdev->dev.of_node,
  5786. "qcom,msm-dai-is-island-supported",
  5787. &dai_data->is_island_dai);
  5788. if (rc)
  5789. dev_dbg(&pdev->dev, "island supported entry not found\n");
  5790. pdev->dev.platform_data = mi2s_pdata;
  5791. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  5792. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  5793. if (rc < 0)
  5794. goto free_dai_data;
  5795. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  5796. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  5797. if (rc < 0)
  5798. goto err_register;
  5799. return 0;
  5800. err_register:
  5801. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  5802. free_dai_data:
  5803. kfree(dai_data);
  5804. free_pdata:
  5805. kfree(mi2s_pdata);
  5806. rtn:
  5807. return rc;
  5808. }
  5809. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  5810. {
  5811. snd_soc_unregister_component(&pdev->dev);
  5812. return 0;
  5813. }
  5814. static int msm_dai_q6_dai_meta_mi2s_probe(struct snd_soc_dai *dai)
  5815. {
  5816. struct msm_meta_mi2s_pdata *meta_mi2s_pdata =
  5817. (struct msm_meta_mi2s_pdata *) dai->dev->platform_data;
  5818. int rc = 0;
  5819. dai->id = meta_mi2s_pdata->intf_id;
  5820. rc = msm_dai_q6_dai_add_route(dai);
  5821. return rc;
  5822. }
  5823. static int msm_dai_q6_dai_meta_mi2s_remove(struct snd_soc_dai *dai)
  5824. {
  5825. return 0;
  5826. }
  5827. static int msm_dai_q6_meta_mi2s_startup(struct snd_pcm_substream *substream,
  5828. struct snd_soc_dai *dai)
  5829. {
  5830. return 0;
  5831. }
  5832. static int msm_meta_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  5833. {
  5834. int ret = 0;
  5835. switch (stream) {
  5836. case SNDRV_PCM_STREAM_PLAYBACK:
  5837. switch (mi2s_id) {
  5838. case MSM_PRIM_META_MI2S:
  5839. *port_id = AFE_PORT_ID_PRIMARY_META_MI2S_RX;
  5840. break;
  5841. case MSM_SEC_META_MI2S:
  5842. *port_id = AFE_PORT_ID_SECONDARY_META_MI2S_RX;
  5843. break;
  5844. default:
  5845. pr_err("%s: playback err id 0x%x\n",
  5846. __func__, mi2s_id);
  5847. ret = -1;
  5848. break;
  5849. }
  5850. break;
  5851. case SNDRV_PCM_STREAM_CAPTURE:
  5852. switch (mi2s_id) {
  5853. default:
  5854. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  5855. ret = -1;
  5856. break;
  5857. }
  5858. break;
  5859. default:
  5860. pr_err("%s: default err %d\n", __func__, stream);
  5861. ret = -1;
  5862. break;
  5863. }
  5864. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  5865. return ret;
  5866. }
  5867. static int msm_dai_q6_meta_mi2s_prepare(struct snd_pcm_substream *substream,
  5868. struct snd_soc_dai *dai)
  5869. {
  5870. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  5871. dev_get_drvdata(dai->dev);
  5872. u16 port_id = 0;
  5873. int rc = 0;
  5874. if (msm_meta_mi2s_get_port_id(dai->id, substream->stream,
  5875. &port_id) != 0) {
  5876. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  5877. __func__, port_id);
  5878. return -EINVAL;
  5879. }
  5880. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  5881. "dai_data->channels = %u sample_rate = %u\n", __func__,
  5882. dai->id, port_id, dai_data->channels, dai_data->rate);
  5883. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  5884. /* PORT START should be set if prepare called
  5885. * in active state.
  5886. */
  5887. rc = afe_port_start(port_id, &dai_data->port_config,
  5888. dai_data->rate);
  5889. if (rc < 0)
  5890. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  5891. dai->id);
  5892. else
  5893. set_bit(STATUS_PORT_STARTED,
  5894. dai_data->status_mask);
  5895. }
  5896. return rc;
  5897. }
  5898. static int msm_dai_q6_meta_mi2s_hw_params(struct snd_pcm_substream *substream,
  5899. struct snd_pcm_hw_params *params,
  5900. struct snd_soc_dai *dai)
  5901. {
  5902. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  5903. dev_get_drvdata(dai->dev);
  5904. struct afe_param_id_meta_i2s_cfg *port_cfg =
  5905. &dai_data->port_config.meta_i2s;
  5906. int idx = 0;
  5907. u16 port_channels = 0;
  5908. u16 channels_left = 0;
  5909. dai_data->channels = params_channels(params);
  5910. channels_left = dai_data->channels;
  5911. /* map requested channels to channels that member ports provide */
  5912. for (idx = 0; idx < dai_data->num_member_ports; idx++) {
  5913. port_channels = msm_dai_q6_mi2s_get_num_channels(
  5914. dai_data->channel_mode[idx]);
  5915. if (channels_left >= port_channels) {
  5916. port_cfg->member_port_id[idx] =
  5917. dai_data->member_port_id[idx];
  5918. port_cfg->member_port_channel_mode[idx] =
  5919. dai_data->channel_mode[idx];
  5920. channels_left -= port_channels;
  5921. } else {
  5922. switch (channels_left) {
  5923. case 15:
  5924. case 16:
  5925. switch (dai_data->channel_mode[idx]) {
  5926. case AFE_PORT_I2S_16CHS:
  5927. port_cfg->member_port_channel_mode[idx]
  5928. = AFE_PORT_I2S_16CHS;
  5929. break;
  5930. default:
  5931. goto error_invalid_data;
  5932. };
  5933. break;
  5934. case 13:
  5935. case 14:
  5936. switch (dai_data->channel_mode[idx]) {
  5937. case AFE_PORT_I2S_14CHS:
  5938. case AFE_PORT_I2S_16CHS:
  5939. port_cfg->member_port_channel_mode[idx]
  5940. = AFE_PORT_I2S_14CHS;
  5941. break;
  5942. default:
  5943. goto error_invalid_data;
  5944. };
  5945. break;
  5946. case 11:
  5947. case 12:
  5948. switch (dai_data->channel_mode[idx]) {
  5949. case AFE_PORT_I2S_12CHS:
  5950. case AFE_PORT_I2S_14CHS:
  5951. case AFE_PORT_I2S_16CHS:
  5952. port_cfg->member_port_channel_mode[idx]
  5953. = AFE_PORT_I2S_12CHS;
  5954. break;
  5955. default:
  5956. goto error_invalid_data;
  5957. };
  5958. break;
  5959. case 9:
  5960. case 10:
  5961. switch (dai_data->channel_mode[idx]) {
  5962. case AFE_PORT_I2S_10CHS:
  5963. case AFE_PORT_I2S_12CHS:
  5964. case AFE_PORT_I2S_14CHS:
  5965. case AFE_PORT_I2S_16CHS:
  5966. port_cfg->member_port_channel_mode[idx]
  5967. = AFE_PORT_I2S_10CHS;
  5968. break;
  5969. default:
  5970. goto error_invalid_data;
  5971. };
  5972. break;
  5973. case 8:
  5974. case 7:
  5975. switch (dai_data->channel_mode[idx]) {
  5976. case AFE_PORT_I2S_8CHS:
  5977. case AFE_PORT_I2S_10CHS:
  5978. case AFE_PORT_I2S_12CHS:
  5979. case AFE_PORT_I2S_14CHS:
  5980. case AFE_PORT_I2S_16CHS:
  5981. port_cfg->member_port_channel_mode[idx]
  5982. = AFE_PORT_I2S_8CHS;
  5983. break;
  5984. case AFE_PORT_I2S_8CHS_2:
  5985. port_cfg->member_port_channel_mode[idx]
  5986. = AFE_PORT_I2S_8CHS_2;
  5987. break;
  5988. default:
  5989. goto error_invalid_data;
  5990. };
  5991. break;
  5992. case 6:
  5993. case 5:
  5994. switch (dai_data->channel_mode[idx]) {
  5995. case AFE_PORT_I2S_6CHS:
  5996. case AFE_PORT_I2S_8CHS:
  5997. case AFE_PORT_I2S_10CHS:
  5998. case AFE_PORT_I2S_12CHS:
  5999. case AFE_PORT_I2S_14CHS:
  6000. case AFE_PORT_I2S_16CHS:
  6001. port_cfg->member_port_channel_mode[idx]
  6002. = AFE_PORT_I2S_6CHS;
  6003. break;
  6004. default:
  6005. goto error_invalid_data;
  6006. };
  6007. break;
  6008. case 4:
  6009. case 3:
  6010. switch (dai_data->channel_mode[idx]) {
  6011. case AFE_PORT_I2S_SD0:
  6012. case AFE_PORT_I2S_SD1:
  6013. case AFE_PORT_I2S_SD2:
  6014. case AFE_PORT_I2S_SD3:
  6015. case AFE_PORT_I2S_SD4:
  6016. case AFE_PORT_I2S_SD5:
  6017. case AFE_PORT_I2S_SD6:
  6018. case AFE_PORT_I2S_SD7:
  6019. goto error_invalid_data;
  6020. case AFE_PORT_I2S_QUAD01:
  6021. case AFE_PORT_I2S_QUAD23:
  6022. case AFE_PORT_I2S_QUAD45:
  6023. case AFE_PORT_I2S_QUAD67:
  6024. port_cfg->member_port_channel_mode[idx]
  6025. = dai_data->channel_mode[idx];
  6026. break;
  6027. case AFE_PORT_I2S_8CHS_2:
  6028. port_cfg->member_port_channel_mode[idx]
  6029. = AFE_PORT_I2S_QUAD45;
  6030. break;
  6031. default:
  6032. port_cfg->member_port_channel_mode[idx]
  6033. = AFE_PORT_I2S_QUAD01;
  6034. };
  6035. break;
  6036. case 2:
  6037. case 1:
  6038. if (dai_data->channel_mode[idx] <
  6039. AFE_PORT_I2S_SD0)
  6040. goto error_invalid_data;
  6041. switch (dai_data->channel_mode[idx]) {
  6042. case AFE_PORT_I2S_SD0:
  6043. case AFE_PORT_I2S_SD1:
  6044. case AFE_PORT_I2S_SD2:
  6045. case AFE_PORT_I2S_SD3:
  6046. case AFE_PORT_I2S_SD4:
  6047. case AFE_PORT_I2S_SD5:
  6048. case AFE_PORT_I2S_SD6:
  6049. case AFE_PORT_I2S_SD7:
  6050. port_cfg->member_port_channel_mode[idx]
  6051. = dai_data->channel_mode[idx];
  6052. break;
  6053. case AFE_PORT_I2S_QUAD01:
  6054. case AFE_PORT_I2S_6CHS:
  6055. case AFE_PORT_I2S_8CHS:
  6056. case AFE_PORT_I2S_10CHS:
  6057. case AFE_PORT_I2S_12CHS:
  6058. case AFE_PORT_I2S_14CHS:
  6059. case AFE_PORT_I2S_16CHS:
  6060. port_cfg->member_port_channel_mode[idx]
  6061. = AFE_PORT_I2S_SD0;
  6062. break;
  6063. case AFE_PORT_I2S_QUAD23:
  6064. port_cfg->member_port_channel_mode[idx]
  6065. = AFE_PORT_I2S_SD2;
  6066. break;
  6067. case AFE_PORT_I2S_QUAD45:
  6068. case AFE_PORT_I2S_8CHS_2:
  6069. port_cfg->member_port_channel_mode[idx]
  6070. = AFE_PORT_I2S_SD4;
  6071. break;
  6072. case AFE_PORT_I2S_QUAD67:
  6073. port_cfg->member_port_channel_mode[idx]
  6074. = AFE_PORT_I2S_SD6;
  6075. break;
  6076. }
  6077. break;
  6078. case 0:
  6079. port_cfg->member_port_channel_mode[idx] = 0;
  6080. }
  6081. if (port_cfg->member_port_channel_mode[idx] == 0) {
  6082. port_cfg->member_port_id[idx] =
  6083. AFE_PORT_ID_INVALID;
  6084. } else {
  6085. port_cfg->member_port_id[idx] =
  6086. dai_data->member_port_id[idx];
  6087. channels_left -=
  6088. msm_dai_q6_mi2s_get_num_channels(
  6089. port_cfg->member_port_channel_mode[idx]);
  6090. }
  6091. }
  6092. }
  6093. if (channels_left > 0) {
  6094. pr_err("%s: too many channels %d\n",
  6095. __func__, dai_data->channels);
  6096. return -EINVAL;
  6097. }
  6098. dai_data->rate = params_rate(params);
  6099. port_cfg->sample_rate = dai_data->rate;
  6100. switch (params_format(params)) {
  6101. case SNDRV_PCM_FORMAT_S16_LE:
  6102. case SNDRV_PCM_FORMAT_SPECIAL:
  6103. port_cfg->bit_width = 16;
  6104. dai_data->bitwidth = 16;
  6105. break;
  6106. case SNDRV_PCM_FORMAT_S24_LE:
  6107. case SNDRV_PCM_FORMAT_S24_3LE:
  6108. port_cfg->bit_width = 24;
  6109. dai_data->bitwidth = 24;
  6110. break;
  6111. default:
  6112. pr_err("%s: format %d\n",
  6113. __func__, params_format(params));
  6114. return -EINVAL;
  6115. }
  6116. port_cfg->minor_version = AFE_API_VERSION_META_I2S_CONFIG;
  6117. port_cfg->data_format = AFE_LINEAR_PCM_DATA;
  6118. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  6119. "bit_width = %hu ws_src = 0x%x sample_rate = %u\n"
  6120. "member_ports 0x%x 0x%x 0x%x 0x%x\n"
  6121. "sd_lines 0x%x 0x%x 0x%x 0x%x\n",
  6122. __func__, dai->id, dai_data->channels,
  6123. port_cfg->bit_width, port_cfg->ws_src, port_cfg->sample_rate,
  6124. port_cfg->member_port_id[0],
  6125. port_cfg->member_port_id[1],
  6126. port_cfg->member_port_id[2],
  6127. port_cfg->member_port_id[3],
  6128. port_cfg->member_port_channel_mode[0],
  6129. port_cfg->member_port_channel_mode[1],
  6130. port_cfg->member_port_channel_mode[2],
  6131. port_cfg->member_port_channel_mode[3]);
  6132. return 0;
  6133. error_invalid_data:
  6134. pr_err("%s: error when assigning member port %d channels (channels_left %d)\n",
  6135. __func__, idx, channels_left);
  6136. return -EINVAL;
  6137. }
  6138. static int msm_dai_q6_meta_mi2s_set_fmt(struct snd_soc_dai *dai,
  6139. unsigned int fmt)
  6140. {
  6141. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6142. dev_get_drvdata(dai->dev);
  6143. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6144. dev_err(dai->dev, "%s: err chg meta i2s mode while dai running",
  6145. __func__);
  6146. return -EPERM;
  6147. }
  6148. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  6149. case SND_SOC_DAIFMT_CBS_CFS:
  6150. dai_data->port_config.meta_i2s.ws_src = 1;
  6151. break;
  6152. case SND_SOC_DAIFMT_CBM_CFM:
  6153. dai_data->port_config.meta_i2s.ws_src = 0;
  6154. break;
  6155. default:
  6156. pr_err("%s: fmt %d\n",
  6157. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  6158. return -EINVAL;
  6159. }
  6160. return 0;
  6161. }
  6162. static void msm_dai_q6_meta_mi2s_shutdown(struct snd_pcm_substream *substream,
  6163. struct snd_soc_dai *dai)
  6164. {
  6165. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6166. dev_get_drvdata(dai->dev);
  6167. u16 port_id = 0;
  6168. int rc = 0;
  6169. if (msm_meta_mi2s_get_port_id(dai->id, substream->stream,
  6170. &port_id) != 0) {
  6171. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  6172. __func__, port_id);
  6173. }
  6174. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  6175. __func__, port_id);
  6176. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6177. rc = afe_close(port_id);
  6178. if (rc < 0)
  6179. dev_err(dai->dev, "fail to close AFE port\n");
  6180. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  6181. }
  6182. }
  6183. static struct snd_soc_dai_ops msm_dai_q6_meta_mi2s_ops = {
  6184. .startup = msm_dai_q6_meta_mi2s_startup,
  6185. .prepare = msm_dai_q6_meta_mi2s_prepare,
  6186. .hw_params = msm_dai_q6_meta_mi2s_hw_params,
  6187. .set_fmt = msm_dai_q6_meta_mi2s_set_fmt,
  6188. .shutdown = msm_dai_q6_meta_mi2s_shutdown,
  6189. };
  6190. /* Channel min and max are initialized base on platform data */
  6191. static struct snd_soc_dai_driver msm_dai_q6_meta_mi2s_dai[] = {
  6192. {
  6193. .playback = {
  6194. .stream_name = "Primary META MI2S Playback",
  6195. .aif_name = "PRI_META_MI2S_RX",
  6196. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  6197. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  6198. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  6199. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  6200. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  6201. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  6202. SNDRV_PCM_RATE_384000,
  6203. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6204. SNDRV_PCM_FMTBIT_S24_LE |
  6205. SNDRV_PCM_FMTBIT_S24_3LE,
  6206. .rate_min = 8000,
  6207. .rate_max = 384000,
  6208. },
  6209. .ops = &msm_dai_q6_meta_mi2s_ops,
  6210. .name = "Primary META MI2S",
  6211. .id = AFE_PORT_ID_PRIMARY_META_MI2S_RX,
  6212. .probe = msm_dai_q6_dai_meta_mi2s_probe,
  6213. .remove = msm_dai_q6_dai_meta_mi2s_remove,
  6214. },
  6215. {
  6216. .playback = {
  6217. .stream_name = "Secondary META MI2S Playback",
  6218. .aif_name = "SEC_META_MI2S_RX",
  6219. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  6220. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  6221. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  6222. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  6223. SNDRV_PCM_RATE_192000,
  6224. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  6225. .rate_min = 8000,
  6226. .rate_max = 192000,
  6227. },
  6228. .ops = &msm_dai_q6_meta_mi2s_ops,
  6229. .name = "Secondary META MI2S",
  6230. .id = AFE_PORT_ID_SECONDARY_META_MI2S_RX,
  6231. .probe = msm_dai_q6_dai_meta_mi2s_probe,
  6232. .remove = msm_dai_q6_dai_meta_mi2s_remove,
  6233. },
  6234. };
  6235. static int msm_dai_q6_meta_mi2s_platform_data_validation(
  6236. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  6237. {
  6238. struct msm_dai_q6_meta_mi2s_dai_data *dai_data =
  6239. dev_get_drvdata(&pdev->dev);
  6240. struct msm_meta_mi2s_pdata *meta_mi2s_pdata =
  6241. (struct msm_meta_mi2s_pdata *) pdev->dev.platform_data;
  6242. int rc = 0;
  6243. int idx = 0;
  6244. u16 channel_mode = 0;
  6245. unsigned int ch_cnt = 0;
  6246. unsigned int ch_cnt_sum = 0;
  6247. struct afe_param_id_meta_i2s_cfg *port_cfg =
  6248. &dai_data->port_config.meta_i2s;
  6249. if (meta_mi2s_pdata == NULL) {
  6250. pr_err("%s: meta_mi2s_pdata NULL", __func__);
  6251. return -EINVAL;
  6252. }
  6253. dai_data->num_member_ports = meta_mi2s_pdata->num_member_ports;
  6254. for (idx = 0; idx < meta_mi2s_pdata->num_member_ports; idx++) {
  6255. rc = msm_dai_q6_mi2s_get_lineconfig(
  6256. meta_mi2s_pdata->sd_lines[idx],
  6257. &channel_mode,
  6258. &ch_cnt);
  6259. if (rc < 0) {
  6260. dev_err(&pdev->dev, "invalid META MI2S RX sd line config\n");
  6261. goto rtn;
  6262. }
  6263. if (ch_cnt) {
  6264. msm_mi2s_get_port_id(meta_mi2s_pdata->member_port[idx],
  6265. SNDRV_PCM_STREAM_PLAYBACK,
  6266. &dai_data->member_port_id[idx]);
  6267. dai_data->channel_mode[idx] = channel_mode;
  6268. port_cfg->member_port_id[idx] =
  6269. dai_data->member_port_id[idx];
  6270. port_cfg->member_port_channel_mode[idx] = channel_mode;
  6271. }
  6272. ch_cnt_sum += ch_cnt;
  6273. }
  6274. if (ch_cnt_sum) {
  6275. dai_driver->playback.channels_min = 1;
  6276. dai_driver->playback.channels_max = ch_cnt_sum << 1;
  6277. } else {
  6278. dai_driver->playback.channels_min = 0;
  6279. dai_driver->playback.channels_max = 0;
  6280. }
  6281. dev_dbg(&pdev->dev, "%s: sdline 0x%x 0x%x 0x%x 0x%x\n", __func__,
  6282. dai_data->channel_mode[0], dai_data->channel_mode[1],
  6283. dai_data->channel_mode[2], dai_data->channel_mode[3]);
  6284. dev_dbg(&pdev->dev, "%s: playback ch_max %d\n",
  6285. __func__, dai_driver->playback.channels_max);
  6286. rtn:
  6287. return rc;
  6288. }
  6289. static const struct snd_soc_component_driver msm_q6_meta_mi2s_dai_component = {
  6290. .name = "msm-dai-q6-meta-mi2s",
  6291. };
  6292. static int msm_dai_q6_meta_mi2s_dev_probe(struct platform_device *pdev)
  6293. {
  6294. struct msm_dai_q6_meta_mi2s_dai_data *dai_data;
  6295. const char *q6_meta_mi2s_dev_id = "qcom,msm-dai-q6-meta-mi2s-dev-id";
  6296. u32 dev_id = 0;
  6297. u32 meta_mi2s_intf = 0;
  6298. struct msm_meta_mi2s_pdata *meta_mi2s_pdata;
  6299. int rc;
  6300. rc = of_property_read_u32(pdev->dev.of_node, q6_meta_mi2s_dev_id,
  6301. &dev_id);
  6302. if (rc) {
  6303. dev_err(&pdev->dev,
  6304. "%s: missing %s in dt node\n", __func__,
  6305. q6_meta_mi2s_dev_id);
  6306. goto rtn;
  6307. }
  6308. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  6309. dev_id);
  6310. switch (dev_id) {
  6311. case AFE_PORT_ID_PRIMARY_META_MI2S_RX:
  6312. meta_mi2s_intf = 0;
  6313. break;
  6314. case AFE_PORT_ID_SECONDARY_META_MI2S_RX:
  6315. meta_mi2s_intf = 1;
  6316. break;
  6317. default:
  6318. dev_err(&pdev->dev,
  6319. "%s: Invalid META MI2S ID 0x%x from Device Tree\n",
  6320. __func__, dev_id);
  6321. rc = -ENXIO;
  6322. goto rtn;
  6323. }
  6324. pdev->id = dev_id;
  6325. meta_mi2s_pdata = kzalloc(sizeof(struct msm_meta_mi2s_pdata),
  6326. GFP_KERNEL);
  6327. if (!meta_mi2s_pdata) {
  6328. rc = -ENOMEM;
  6329. goto rtn;
  6330. }
  6331. rc = of_property_read_u32(pdev->dev.of_node,
  6332. "qcom,msm-mi2s-num-members",
  6333. &meta_mi2s_pdata->num_member_ports);
  6334. if (rc) {
  6335. dev_err(&pdev->dev, "%s: invalid num from DT file %s\n",
  6336. __func__, "qcom,msm-mi2s-num-members");
  6337. goto free_pdata;
  6338. }
  6339. if (meta_mi2s_pdata->num_member_ports >
  6340. MAX_NUM_I2S_META_PORT_MEMBER_PORTS) {
  6341. dev_err(&pdev->dev, "%s: num-members %d too large from DT file\n",
  6342. __func__, meta_mi2s_pdata->num_member_ports);
  6343. goto free_pdata;
  6344. }
  6345. rc = of_property_read_u32_array(pdev->dev.of_node,
  6346. "qcom,msm-mi2s-member-id",
  6347. meta_mi2s_pdata->member_port,
  6348. meta_mi2s_pdata->num_member_ports);
  6349. if (rc) {
  6350. dev_err(&pdev->dev, "%s: member-id from DT file %s\n",
  6351. __func__, "qcom,msm-mi2s-member-id");
  6352. goto free_pdata;
  6353. }
  6354. rc = of_property_read_u32_array(pdev->dev.of_node,
  6355. "qcom,msm-mi2s-rx-lines",
  6356. meta_mi2s_pdata->sd_lines,
  6357. meta_mi2s_pdata->num_member_ports);
  6358. if (rc) {
  6359. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n",
  6360. __func__, "qcom,msm-mi2s-rx-lines");
  6361. goto free_pdata;
  6362. }
  6363. dev_dbg(&pdev->dev, "dev name %s num-members=%d\n",
  6364. dev_name(&pdev->dev), meta_mi2s_pdata->num_member_ports);
  6365. dev_dbg(&pdev->dev, "member array (%d, %d, %d, %d)\n",
  6366. meta_mi2s_pdata->member_port[0],
  6367. meta_mi2s_pdata->member_port[1],
  6368. meta_mi2s_pdata->member_port[2],
  6369. meta_mi2s_pdata->member_port[3]);
  6370. dev_dbg(&pdev->dev, "sd-lines array (0x%x, 0x%x, 0x%x, 0x%x)\n",
  6371. meta_mi2s_pdata->sd_lines[0],
  6372. meta_mi2s_pdata->sd_lines[1],
  6373. meta_mi2s_pdata->sd_lines[2],
  6374. meta_mi2s_pdata->sd_lines[3]);
  6375. meta_mi2s_pdata->intf_id = meta_mi2s_intf;
  6376. dai_data = kzalloc(sizeof(struct msm_dai_q6_meta_mi2s_dai_data),
  6377. GFP_KERNEL);
  6378. if (!dai_data) {
  6379. rc = -ENOMEM;
  6380. goto free_pdata;
  6381. } else
  6382. dev_set_drvdata(&pdev->dev, dai_data);
  6383. pdev->dev.platform_data = meta_mi2s_pdata;
  6384. rc = msm_dai_q6_meta_mi2s_platform_data_validation(pdev,
  6385. &msm_dai_q6_meta_mi2s_dai[meta_mi2s_intf]);
  6386. if (rc < 0)
  6387. goto free_dai_data;
  6388. rc = snd_soc_register_component(&pdev->dev,
  6389. &msm_q6_meta_mi2s_dai_component,
  6390. &msm_dai_q6_meta_mi2s_dai[meta_mi2s_intf], 1);
  6391. if (rc < 0)
  6392. goto err_register;
  6393. return 0;
  6394. err_register:
  6395. dev_err(&pdev->dev, "fail to %s\n", __func__);
  6396. free_dai_data:
  6397. kfree(dai_data);
  6398. free_pdata:
  6399. kfree(meta_mi2s_pdata);
  6400. rtn:
  6401. return rc;
  6402. }
  6403. static int msm_dai_q6_meta_mi2s_dev_remove(struct platform_device *pdev)
  6404. {
  6405. snd_soc_unregister_component(&pdev->dev);
  6406. return 0;
  6407. }
  6408. static const struct snd_soc_component_driver msm_dai_q6_component = {
  6409. .name = "msm-dai-q6-dev",
  6410. };
  6411. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  6412. {
  6413. int rc, id, i, len;
  6414. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  6415. char stream_name[80];
  6416. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  6417. if (rc) {
  6418. dev_err(&pdev->dev,
  6419. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  6420. return rc;
  6421. }
  6422. pdev->id = id;
  6423. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6424. dev_name(&pdev->dev), pdev->id);
  6425. switch (id) {
  6426. case SLIMBUS_0_RX:
  6427. strlcpy(stream_name, "Slimbus Playback", 80);
  6428. goto register_slim_playback;
  6429. case SLIMBUS_2_RX:
  6430. strlcpy(stream_name, "Slimbus2 Playback", 80);
  6431. goto register_slim_playback;
  6432. case SLIMBUS_1_RX:
  6433. strlcpy(stream_name, "Slimbus1 Playback", 80);
  6434. goto register_slim_playback;
  6435. case SLIMBUS_3_RX:
  6436. strlcpy(stream_name, "Slimbus3 Playback", 80);
  6437. goto register_slim_playback;
  6438. case SLIMBUS_4_RX:
  6439. strlcpy(stream_name, "Slimbus4 Playback", 80);
  6440. goto register_slim_playback;
  6441. case SLIMBUS_5_RX:
  6442. strlcpy(stream_name, "Slimbus5 Playback", 80);
  6443. goto register_slim_playback;
  6444. case SLIMBUS_6_RX:
  6445. strlcpy(stream_name, "Slimbus6 Playback", 80);
  6446. goto register_slim_playback;
  6447. case SLIMBUS_7_RX:
  6448. strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
  6449. goto register_slim_playback;
  6450. case SLIMBUS_8_RX:
  6451. strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
  6452. goto register_slim_playback;
  6453. case SLIMBUS_9_RX:
  6454. strlcpy(stream_name, "Slimbus9 Playback", sizeof(stream_name));
  6455. goto register_slim_playback;
  6456. register_slim_playback:
  6457. rc = -ENODEV;
  6458. len = strnlen(stream_name, 80);
  6459. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  6460. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  6461. !strcmp(stream_name,
  6462. msm_dai_q6_slimbus_rx_dai[i]
  6463. .playback.stream_name)) {
  6464. rc = snd_soc_register_component(&pdev->dev,
  6465. &msm_dai_q6_component,
  6466. &msm_dai_q6_slimbus_rx_dai[i], 1);
  6467. break;
  6468. }
  6469. }
  6470. if (rc)
  6471. pr_err("%s: Device not found stream name %s\n",
  6472. __func__, stream_name);
  6473. break;
  6474. case SLIMBUS_0_TX:
  6475. strlcpy(stream_name, "Slimbus Capture", 80);
  6476. goto register_slim_capture;
  6477. case SLIMBUS_1_TX:
  6478. strlcpy(stream_name, "Slimbus1 Capture", 80);
  6479. goto register_slim_capture;
  6480. case SLIMBUS_2_TX:
  6481. strlcpy(stream_name, "Slimbus2 Capture", 80);
  6482. goto register_slim_capture;
  6483. case SLIMBUS_3_TX:
  6484. strlcpy(stream_name, "Slimbus3 Capture", 80);
  6485. goto register_slim_capture;
  6486. case SLIMBUS_4_TX:
  6487. strlcpy(stream_name, "Slimbus4 Capture", 80);
  6488. goto register_slim_capture;
  6489. case SLIMBUS_5_TX:
  6490. strlcpy(stream_name, "Slimbus5 Capture", 80);
  6491. goto register_slim_capture;
  6492. case SLIMBUS_6_TX:
  6493. strlcpy(stream_name, "Slimbus6 Capture", 80);
  6494. goto register_slim_capture;
  6495. case SLIMBUS_7_TX:
  6496. strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
  6497. goto register_slim_capture;
  6498. case SLIMBUS_8_TX:
  6499. strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
  6500. goto register_slim_capture;
  6501. case SLIMBUS_9_TX:
  6502. strlcpy(stream_name, "Slimbus9 Capture", sizeof(stream_name));
  6503. goto register_slim_capture;
  6504. register_slim_capture:
  6505. rc = -ENODEV;
  6506. len = strnlen(stream_name, 80);
  6507. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  6508. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  6509. !strcmp(stream_name,
  6510. msm_dai_q6_slimbus_tx_dai[i]
  6511. .capture.stream_name)) {
  6512. rc = snd_soc_register_component(&pdev->dev,
  6513. &msm_dai_q6_component,
  6514. &msm_dai_q6_slimbus_tx_dai[i], 1);
  6515. break;
  6516. }
  6517. }
  6518. if (rc)
  6519. pr_err("%s: Device not found stream name %s\n",
  6520. __func__, stream_name);
  6521. break;
  6522. case AFE_LOOPBACK_TX:
  6523. rc = snd_soc_register_component(&pdev->dev,
  6524. &msm_dai_q6_component,
  6525. &msm_dai_q6_afe_lb_tx_dai[0],
  6526. 1);
  6527. break;
  6528. case INT_BT_SCO_RX:
  6529. rc = snd_soc_register_component(&pdev->dev,
  6530. &msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
  6531. break;
  6532. case INT_BT_SCO_TX:
  6533. rc = snd_soc_register_component(&pdev->dev,
  6534. &msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
  6535. break;
  6536. case INT_BT_A2DP_RX:
  6537. rc = snd_soc_register_component(&pdev->dev,
  6538. &msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
  6539. break;
  6540. case INT_FM_RX:
  6541. rc = snd_soc_register_component(&pdev->dev,
  6542. &msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
  6543. break;
  6544. case INT_FM_TX:
  6545. rc = snd_soc_register_component(&pdev->dev,
  6546. &msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
  6547. break;
  6548. case AFE_PORT_ID_USB_RX:
  6549. rc = snd_soc_register_component(&pdev->dev,
  6550. &msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
  6551. break;
  6552. case AFE_PORT_ID_USB_TX:
  6553. rc = snd_soc_register_component(&pdev->dev,
  6554. &msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
  6555. break;
  6556. case RT_PROXY_DAI_001_RX:
  6557. strlcpy(stream_name, "AFE Playback", 80);
  6558. goto register_afe_playback;
  6559. case RT_PROXY_DAI_002_RX:
  6560. strlcpy(stream_name, "AFE-PROXY RX", 80);
  6561. register_afe_playback:
  6562. rc = -ENODEV;
  6563. len = strnlen(stream_name, 80);
  6564. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
  6565. if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
  6566. !strcmp(stream_name,
  6567. msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
  6568. rc = snd_soc_register_component(&pdev->dev,
  6569. &msm_dai_q6_component,
  6570. &msm_dai_q6_afe_rx_dai[i], 1);
  6571. break;
  6572. }
  6573. }
  6574. if (rc)
  6575. pr_err("%s: Device not found stream name %s\n",
  6576. __func__, stream_name);
  6577. break;
  6578. case RT_PROXY_DAI_001_TX:
  6579. strlcpy(stream_name, "AFE-PROXY TX", 80);
  6580. goto register_afe_capture;
  6581. case RT_PROXY_DAI_002_TX:
  6582. strlcpy(stream_name, "AFE Capture", 80);
  6583. register_afe_capture:
  6584. rc = -ENODEV;
  6585. len = strnlen(stream_name, 80);
  6586. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
  6587. if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
  6588. !strcmp(stream_name,
  6589. msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
  6590. rc = snd_soc_register_component(&pdev->dev,
  6591. &msm_dai_q6_component,
  6592. &msm_dai_q6_afe_tx_dai[i], 1);
  6593. break;
  6594. }
  6595. }
  6596. if (rc)
  6597. pr_err("%s: Device not found stream name %s\n",
  6598. __func__, stream_name);
  6599. break;
  6600. case VOICE_PLAYBACK_TX:
  6601. strlcpy(stream_name, "Voice Farend Playback", 80);
  6602. goto register_voice_playback;
  6603. case VOICE2_PLAYBACK_TX:
  6604. strlcpy(stream_name, "Voice2 Farend Playback", 80);
  6605. register_voice_playback:
  6606. rc = -ENODEV;
  6607. len = strnlen(stream_name, 80);
  6608. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
  6609. if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
  6610. && !strcmp(stream_name,
  6611. msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
  6612. rc = snd_soc_register_component(&pdev->dev,
  6613. &msm_dai_q6_component,
  6614. &msm_dai_q6_voc_playback_dai[i], 1);
  6615. break;
  6616. }
  6617. }
  6618. if (rc)
  6619. pr_err("%s Device not found stream name %s\n",
  6620. __func__, stream_name);
  6621. break;
  6622. case VOICE_RECORD_RX:
  6623. strlcpy(stream_name, "Voice Downlink Capture", 80);
  6624. goto register_uplink_capture;
  6625. case VOICE_RECORD_TX:
  6626. strlcpy(stream_name, "Voice Uplink Capture", 80);
  6627. register_uplink_capture:
  6628. rc = -ENODEV;
  6629. len = strnlen(stream_name, 80);
  6630. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
  6631. if (msm_dai_q6_incall_record_dai[i].capture.stream_name
  6632. && !strcmp(stream_name,
  6633. msm_dai_q6_incall_record_dai[i].
  6634. capture.stream_name)) {
  6635. rc = snd_soc_register_component(&pdev->dev,
  6636. &msm_dai_q6_component,
  6637. &msm_dai_q6_incall_record_dai[i], 1);
  6638. break;
  6639. }
  6640. }
  6641. if (rc)
  6642. pr_err("%s: Device not found stream name %s\n",
  6643. __func__, stream_name);
  6644. break;
  6645. default:
  6646. rc = -ENODEV;
  6647. break;
  6648. }
  6649. return rc;
  6650. }
  6651. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  6652. {
  6653. snd_soc_unregister_component(&pdev->dev);
  6654. return 0;
  6655. }
  6656. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  6657. { .compatible = "qcom,msm-dai-q6-dev", },
  6658. { }
  6659. };
  6660. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  6661. static struct platform_driver msm_dai_q6_dev = {
  6662. .probe = msm_dai_q6_dev_probe,
  6663. .remove = msm_dai_q6_dev_remove,
  6664. .driver = {
  6665. .name = "msm-dai-q6-dev",
  6666. .owner = THIS_MODULE,
  6667. .of_match_table = msm_dai_q6_dev_dt_match,
  6668. .suppress_bind_attrs = true,
  6669. },
  6670. };
  6671. static int msm_dai_q6_probe(struct platform_device *pdev)
  6672. {
  6673. int rc;
  6674. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6675. dev_name(&pdev->dev), pdev->id);
  6676. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  6677. if (rc) {
  6678. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  6679. __func__, rc);
  6680. } else
  6681. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  6682. return rc;
  6683. }
  6684. static int msm_dai_q6_remove(struct platform_device *pdev)
  6685. {
  6686. of_platform_depopulate(&pdev->dev);
  6687. return 0;
  6688. }
  6689. static const struct of_device_id msm_dai_q6_dt_match[] = {
  6690. { .compatible = "qcom,msm-dai-q6", },
  6691. { }
  6692. };
  6693. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  6694. static struct platform_driver msm_dai_q6 = {
  6695. .probe = msm_dai_q6_probe,
  6696. .remove = msm_dai_q6_remove,
  6697. .driver = {
  6698. .name = "msm-dai-q6",
  6699. .owner = THIS_MODULE,
  6700. .of_match_table = msm_dai_q6_dt_match,
  6701. .suppress_bind_attrs = true,
  6702. },
  6703. };
  6704. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  6705. {
  6706. int rc;
  6707. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  6708. if (rc) {
  6709. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  6710. __func__, rc);
  6711. } else
  6712. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  6713. return rc;
  6714. }
  6715. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  6716. {
  6717. return 0;
  6718. }
  6719. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  6720. { .compatible = "qcom,msm-dai-mi2s", },
  6721. { }
  6722. };
  6723. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  6724. static struct platform_driver msm_dai_mi2s_q6 = {
  6725. .probe = msm_dai_mi2s_q6_probe,
  6726. .remove = msm_dai_mi2s_q6_remove,
  6727. .driver = {
  6728. .name = "msm-dai-mi2s",
  6729. .owner = THIS_MODULE,
  6730. .of_match_table = msm_dai_mi2s_dt_match,
  6731. .suppress_bind_attrs = true,
  6732. },
  6733. };
  6734. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  6735. { .compatible = "qcom,msm-dai-q6-mi2s", },
  6736. { }
  6737. };
  6738. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  6739. static struct platform_driver msm_dai_q6_mi2s_driver = {
  6740. .probe = msm_dai_q6_mi2s_dev_probe,
  6741. .remove = msm_dai_q6_mi2s_dev_remove,
  6742. .driver = {
  6743. .name = "msm-dai-q6-mi2s",
  6744. .owner = THIS_MODULE,
  6745. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  6746. .suppress_bind_attrs = true,
  6747. },
  6748. };
  6749. static const struct of_device_id msm_dai_q6_meta_mi2s_dev_dt_match[] = {
  6750. { .compatible = "qcom,msm-dai-q6-meta-mi2s", },
  6751. { }
  6752. };
  6753. MODULE_DEVICE_TABLE(of, msm_dai_q6_meta_mi2s_dev_dt_match);
  6754. static struct platform_driver msm_dai_q6_meta_mi2s_driver = {
  6755. .probe = msm_dai_q6_meta_mi2s_dev_probe,
  6756. .remove = msm_dai_q6_meta_mi2s_dev_remove,
  6757. .driver = {
  6758. .name = "msm-dai-q6-meta-mi2s",
  6759. .owner = THIS_MODULE,
  6760. .of_match_table = msm_dai_q6_meta_mi2s_dev_dt_match,
  6761. .suppress_bind_attrs = true,
  6762. },
  6763. };
  6764. static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
  6765. {
  6766. int rc, id;
  6767. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  6768. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  6769. if (rc) {
  6770. dev_err(&pdev->dev,
  6771. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  6772. return rc;
  6773. }
  6774. pdev->id = id;
  6775. pr_debug("%s: dev name %s, id:%d\n", __func__,
  6776. dev_name(&pdev->dev), pdev->id);
  6777. switch (pdev->id) {
  6778. case AFE_PORT_ID_PRIMARY_SPDIF_RX:
  6779. rc = snd_soc_register_component(&pdev->dev,
  6780. &msm_dai_spdif_q6_component,
  6781. &msm_dai_q6_spdif_spdif_rx_dai[0], 1);
  6782. break;
  6783. case AFE_PORT_ID_SECONDARY_SPDIF_RX:
  6784. rc = snd_soc_register_component(&pdev->dev,
  6785. &msm_dai_spdif_q6_component,
  6786. &msm_dai_q6_spdif_spdif_rx_dai[1], 1);
  6787. break;
  6788. case AFE_PORT_ID_PRIMARY_SPDIF_TX:
  6789. rc = snd_soc_register_component(&pdev->dev,
  6790. &msm_dai_spdif_q6_component,
  6791. &msm_dai_q6_spdif_spdif_tx_dai[0], 1);
  6792. break;
  6793. case AFE_PORT_ID_SECONDARY_SPDIF_TX:
  6794. rc = snd_soc_register_component(&pdev->dev,
  6795. &msm_dai_spdif_q6_component,
  6796. &msm_dai_q6_spdif_spdif_tx_dai[1], 1);
  6797. break;
  6798. default:
  6799. dev_err(&pdev->dev, "invalid device ID %d\n", pdev->id);
  6800. rc = -ENODEV;
  6801. break;
  6802. }
  6803. return rc;
  6804. }
  6805. static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
  6806. {
  6807. snd_soc_unregister_component(&pdev->dev);
  6808. return 0;
  6809. }
  6810. static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
  6811. {.compatible = "qcom,msm-dai-q6-spdif"},
  6812. {}
  6813. };
  6814. MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
  6815. static struct platform_driver msm_dai_q6_spdif_driver = {
  6816. .probe = msm_dai_q6_spdif_dev_probe,
  6817. .remove = msm_dai_q6_spdif_dev_remove,
  6818. .driver = {
  6819. .name = "msm-dai-q6-spdif",
  6820. .owner = THIS_MODULE,
  6821. .of_match_table = msm_dai_q6_spdif_dt_match,
  6822. .suppress_bind_attrs = true,
  6823. },
  6824. };
  6825. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  6826. struct afe_clk_set *clk_set, u32 mode)
  6827. {
  6828. switch (group_id) {
  6829. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  6830. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  6831. if (mode)
  6832. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
  6833. else
  6834. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
  6835. break;
  6836. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  6837. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  6838. if (mode)
  6839. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
  6840. else
  6841. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
  6842. break;
  6843. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  6844. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  6845. if (mode)
  6846. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
  6847. else
  6848. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
  6849. break;
  6850. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  6851. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  6852. if (mode)
  6853. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
  6854. else
  6855. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
  6856. break;
  6857. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  6858. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  6859. if (mode)
  6860. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT;
  6861. else
  6862. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT;
  6863. break;
  6864. case AFE_GROUP_DEVICE_ID_SENARY_TDM_RX:
  6865. case AFE_GROUP_DEVICE_ID_SENARY_TDM_TX:
  6866. if (mode)
  6867. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_IBIT;
  6868. else
  6869. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEN_TDM_EBIT;
  6870. break;
  6871. default:
  6872. return -EINVAL;
  6873. }
  6874. return 0;
  6875. }
  6876. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  6877. {
  6878. int rc = 0;
  6879. const uint32_t *port_id_array = NULL;
  6880. uint32_t array_length = 0;
  6881. int i = 0;
  6882. int group_idx = 0;
  6883. u32 clk_mode = 0;
  6884. /* extract tdm group info into static */
  6885. rc = of_property_read_u32(pdev->dev.of_node,
  6886. "qcom,msm-cpudai-tdm-group-id",
  6887. (u32 *)&tdm_group_cfg.group_id);
  6888. if (rc) {
  6889. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  6890. __func__, "qcom,msm-cpudai-tdm-group-id");
  6891. goto rtn;
  6892. }
  6893. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  6894. __func__, tdm_group_cfg.group_id);
  6895. rc = of_property_read_u32(pdev->dev.of_node,
  6896. "qcom,msm-cpudai-tdm-group-num-ports",
  6897. &num_tdm_group_ports);
  6898. if (rc) {
  6899. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  6900. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  6901. goto rtn;
  6902. }
  6903. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  6904. __func__, num_tdm_group_ports);
  6905. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  6906. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  6907. __func__, num_tdm_group_ports,
  6908. AFE_GROUP_DEVICE_NUM_PORTS);
  6909. rc = -EINVAL;
  6910. goto rtn;
  6911. }
  6912. port_id_array = of_get_property(pdev->dev.of_node,
  6913. "qcom,msm-cpudai-tdm-group-port-id",
  6914. &array_length);
  6915. if (port_id_array == NULL) {
  6916. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  6917. __func__);
  6918. rc = -EINVAL;
  6919. goto rtn;
  6920. }
  6921. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  6922. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  6923. __func__, array_length,
  6924. sizeof(uint32_t) * num_tdm_group_ports);
  6925. rc = -EINVAL;
  6926. goto rtn;
  6927. }
  6928. for (i = 0; i < num_tdm_group_ports; i++)
  6929. tdm_group_cfg.port_id[i] =
  6930. (u16)be32_to_cpu(port_id_array[i]);
  6931. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  6932. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  6933. tdm_group_cfg.port_id[i] =
  6934. AFE_PORT_INVALID;
  6935. /* extract tdm clk info into static */
  6936. rc = of_property_read_u32(pdev->dev.of_node,
  6937. "qcom,msm-cpudai-tdm-clk-rate",
  6938. &tdm_clk_set.clk_freq_in_hz);
  6939. if (rc) {
  6940. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  6941. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  6942. goto rtn;
  6943. }
  6944. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  6945. __func__, tdm_clk_set.clk_freq_in_hz);
  6946. /* initialize static tdm clk attribute to default value */
  6947. tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;
  6948. /* extract tdm clk attribute into static */
  6949. if (of_find_property(pdev->dev.of_node,
  6950. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  6951. rc = of_property_read_u16(pdev->dev.of_node,
  6952. "qcom,msm-cpudai-tdm-clk-attribute",
  6953. &tdm_clk_set.clk_attri);
  6954. if (rc) {
  6955. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  6956. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  6957. goto rtn;
  6958. }
  6959. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  6960. __func__, tdm_clk_set.clk_attri);
  6961. } else
  6962. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  6963. /* extract tdm lane cfg to static */
  6964. tdm_lane_cfg.port_id = tdm_group_cfg.group_id;
  6965. tdm_lane_cfg.lane_mask = AFE_LANE_MASK_INVALID;
  6966. if (of_find_property(pdev->dev.of_node,
  6967. "qcom,msm-cpudai-tdm-lane-mask", NULL)) {
  6968. rc = of_property_read_u16(pdev->dev.of_node,
  6969. "qcom,msm-cpudai-tdm-lane-mask",
  6970. &tdm_lane_cfg.lane_mask);
  6971. if (rc) {
  6972. dev_err(&pdev->dev, "%s: value for tdm lane mask not found %s\n",
  6973. __func__, "qcom,msm-cpudai-tdm-lane-mask");
  6974. goto rtn;
  6975. }
  6976. dev_dbg(&pdev->dev, "%s: tdm lane mask from DT file %d\n",
  6977. __func__, tdm_lane_cfg.lane_mask);
  6978. } else
  6979. dev_dbg(&pdev->dev, "%s: tdm lane mask not found\n", __func__);
  6980. /* extract tdm clk src master/slave info into static */
  6981. rc = of_property_read_u32(pdev->dev.of_node,
  6982. "qcom,msm-cpudai-tdm-clk-internal",
  6983. &clk_mode);
  6984. if (rc) {
  6985. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  6986. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  6987. goto rtn;
  6988. }
  6989. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  6990. __func__, clk_mode);
  6991. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  6992. &tdm_clk_set, clk_mode);
  6993. if (rc) {
  6994. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  6995. __func__, tdm_group_cfg.group_id);
  6996. goto rtn;
  6997. }
  6998. /* other initializations within device group */
  6999. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  7000. if (group_idx < 0) {
  7001. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  7002. __func__, tdm_group_cfg.group_id);
  7003. rc = -EINVAL;
  7004. goto rtn;
  7005. }
  7006. atomic_set(&tdm_group_ref[group_idx], 0);
  7007. /* probe child node info */
  7008. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  7009. if (rc) {
  7010. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  7011. __func__, rc);
  7012. goto rtn;
  7013. } else
  7014. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  7015. rtn:
  7016. return rc;
  7017. }
  7018. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  7019. {
  7020. return 0;
  7021. }
  7022. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  7023. { .compatible = "qcom,msm-dai-tdm", },
  7024. {}
  7025. };
  7026. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  7027. static struct platform_driver msm_dai_tdm_q6 = {
  7028. .probe = msm_dai_tdm_q6_probe,
  7029. .remove = msm_dai_tdm_q6_remove,
  7030. .driver = {
  7031. .name = "msm-dai-tdm",
  7032. .owner = THIS_MODULE,
  7033. .of_match_table = msm_dai_tdm_dt_match,
  7034. .suppress_bind_attrs = true,
  7035. },
  7036. };
  7037. static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
  7038. struct snd_ctl_elem_value *ucontrol)
  7039. {
  7040. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7041. int value = ucontrol->value.integer.value[0];
  7042. switch (value) {
  7043. case 0:
  7044. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  7045. break;
  7046. case 1:
  7047. dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
  7048. break;
  7049. case 2:
  7050. dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
  7051. break;
  7052. default:
  7053. pr_err("%s: data_format invalid\n", __func__);
  7054. break;
  7055. }
  7056. pr_debug("%s: data_format = %d\n",
  7057. __func__, dai_data->port_cfg.tdm.data_format);
  7058. return 0;
  7059. }
  7060. static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
  7061. struct snd_ctl_elem_value *ucontrol)
  7062. {
  7063. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7064. ucontrol->value.integer.value[0] =
  7065. dai_data->port_cfg.tdm.data_format;
  7066. pr_debug("%s: data_format = %d\n",
  7067. __func__, dai_data->port_cfg.tdm.data_format);
  7068. return 0;
  7069. }
  7070. static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
  7071. struct snd_ctl_elem_value *ucontrol)
  7072. {
  7073. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7074. int value = ucontrol->value.integer.value[0];
  7075. dai_data->port_cfg.custom_tdm_header.header_type = value;
  7076. pr_debug("%s: header_type = %d\n",
  7077. __func__,
  7078. dai_data->port_cfg.custom_tdm_header.header_type);
  7079. return 0;
  7080. }
  7081. static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
  7082. struct snd_ctl_elem_value *ucontrol)
  7083. {
  7084. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7085. ucontrol->value.integer.value[0] =
  7086. dai_data->port_cfg.custom_tdm_header.header_type;
  7087. pr_debug("%s: header_type = %d\n",
  7088. __func__,
  7089. dai_data->port_cfg.custom_tdm_header.header_type);
  7090. return 0;
  7091. }
  7092. static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
  7093. struct snd_ctl_elem_value *ucontrol)
  7094. {
  7095. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7096. int i = 0;
  7097. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  7098. dai_data->port_cfg.custom_tdm_header.header[i] =
  7099. (u16)ucontrol->value.integer.value[i];
  7100. pr_debug("%s: header #%d = 0x%x\n",
  7101. __func__, i,
  7102. dai_data->port_cfg.custom_tdm_header.header[i]);
  7103. }
  7104. return 0;
  7105. }
  7106. static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
  7107. struct snd_ctl_elem_value *ucontrol)
  7108. {
  7109. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  7110. int i = 0;
  7111. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  7112. ucontrol->value.integer.value[i] =
  7113. dai_data->port_cfg.custom_tdm_header.header[i];
  7114. pr_debug("%s: header #%d = 0x%x\n",
  7115. __func__, i,
  7116. dai_data->port_cfg.custom_tdm_header.header[i]);
  7117. }
  7118. return 0;
  7119. }
  7120. static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
  7121. SOC_ENUM_EXT("PRI_TDM_RX_0 Data Format", tdm_config_enum[0],
  7122. msm_dai_q6_tdm_data_format_get,
  7123. msm_dai_q6_tdm_data_format_put),
  7124. SOC_ENUM_EXT("PRI_TDM_RX_1 Data Format", tdm_config_enum[0],
  7125. msm_dai_q6_tdm_data_format_get,
  7126. msm_dai_q6_tdm_data_format_put),
  7127. SOC_ENUM_EXT("PRI_TDM_RX_2 Data Format", tdm_config_enum[0],
  7128. msm_dai_q6_tdm_data_format_get,
  7129. msm_dai_q6_tdm_data_format_put),
  7130. SOC_ENUM_EXT("PRI_TDM_RX_3 Data Format", tdm_config_enum[0],
  7131. msm_dai_q6_tdm_data_format_get,
  7132. msm_dai_q6_tdm_data_format_put),
  7133. SOC_ENUM_EXT("PRI_TDM_RX_4 Data Format", tdm_config_enum[0],
  7134. msm_dai_q6_tdm_data_format_get,
  7135. msm_dai_q6_tdm_data_format_put),
  7136. SOC_ENUM_EXT("PRI_TDM_RX_5 Data Format", tdm_config_enum[0],
  7137. msm_dai_q6_tdm_data_format_get,
  7138. msm_dai_q6_tdm_data_format_put),
  7139. SOC_ENUM_EXT("PRI_TDM_RX_6 Data Format", tdm_config_enum[0],
  7140. msm_dai_q6_tdm_data_format_get,
  7141. msm_dai_q6_tdm_data_format_put),
  7142. SOC_ENUM_EXT("PRI_TDM_RX_7 Data Format", tdm_config_enum[0],
  7143. msm_dai_q6_tdm_data_format_get,
  7144. msm_dai_q6_tdm_data_format_put),
  7145. SOC_ENUM_EXT("PRI_TDM_TX_0 Data Format", tdm_config_enum[0],
  7146. msm_dai_q6_tdm_data_format_get,
  7147. msm_dai_q6_tdm_data_format_put),
  7148. SOC_ENUM_EXT("PRI_TDM_TX_1 Data Format", tdm_config_enum[0],
  7149. msm_dai_q6_tdm_data_format_get,
  7150. msm_dai_q6_tdm_data_format_put),
  7151. SOC_ENUM_EXT("PRI_TDM_TX_2 Data Format", tdm_config_enum[0],
  7152. msm_dai_q6_tdm_data_format_get,
  7153. msm_dai_q6_tdm_data_format_put),
  7154. SOC_ENUM_EXT("PRI_TDM_TX_3 Data Format", tdm_config_enum[0],
  7155. msm_dai_q6_tdm_data_format_get,
  7156. msm_dai_q6_tdm_data_format_put),
  7157. SOC_ENUM_EXT("PRI_TDM_TX_4 Data Format", tdm_config_enum[0],
  7158. msm_dai_q6_tdm_data_format_get,
  7159. msm_dai_q6_tdm_data_format_put),
  7160. SOC_ENUM_EXT("PRI_TDM_TX_5 Data Format", tdm_config_enum[0],
  7161. msm_dai_q6_tdm_data_format_get,
  7162. msm_dai_q6_tdm_data_format_put),
  7163. SOC_ENUM_EXT("PRI_TDM_TX_6 Data Format", tdm_config_enum[0],
  7164. msm_dai_q6_tdm_data_format_get,
  7165. msm_dai_q6_tdm_data_format_put),
  7166. SOC_ENUM_EXT("PRI_TDM_TX_7 Data Format", tdm_config_enum[0],
  7167. msm_dai_q6_tdm_data_format_get,
  7168. msm_dai_q6_tdm_data_format_put),
  7169. SOC_ENUM_EXT("SEC_TDM_RX_0 Data Format", tdm_config_enum[0],
  7170. msm_dai_q6_tdm_data_format_get,
  7171. msm_dai_q6_tdm_data_format_put),
  7172. SOC_ENUM_EXT("SEC_TDM_RX_1 Data Format", tdm_config_enum[0],
  7173. msm_dai_q6_tdm_data_format_get,
  7174. msm_dai_q6_tdm_data_format_put),
  7175. SOC_ENUM_EXT("SEC_TDM_RX_2 Data Format", tdm_config_enum[0],
  7176. msm_dai_q6_tdm_data_format_get,
  7177. msm_dai_q6_tdm_data_format_put),
  7178. SOC_ENUM_EXT("SEC_TDM_RX_3 Data Format", tdm_config_enum[0],
  7179. msm_dai_q6_tdm_data_format_get,
  7180. msm_dai_q6_tdm_data_format_put),
  7181. SOC_ENUM_EXT("SEC_TDM_RX_4 Data Format", tdm_config_enum[0],
  7182. msm_dai_q6_tdm_data_format_get,
  7183. msm_dai_q6_tdm_data_format_put),
  7184. SOC_ENUM_EXT("SEC_TDM_RX_5 Data Format", tdm_config_enum[0],
  7185. msm_dai_q6_tdm_data_format_get,
  7186. msm_dai_q6_tdm_data_format_put),
  7187. SOC_ENUM_EXT("SEC_TDM_RX_6 Data Format", tdm_config_enum[0],
  7188. msm_dai_q6_tdm_data_format_get,
  7189. msm_dai_q6_tdm_data_format_put),
  7190. SOC_ENUM_EXT("SEC_TDM_RX_7 Data Format", tdm_config_enum[0],
  7191. msm_dai_q6_tdm_data_format_get,
  7192. msm_dai_q6_tdm_data_format_put),
  7193. SOC_ENUM_EXT("SEC_TDM_TX_0 Data Format", tdm_config_enum[0],
  7194. msm_dai_q6_tdm_data_format_get,
  7195. msm_dai_q6_tdm_data_format_put),
  7196. SOC_ENUM_EXT("SEC_TDM_TX_1 Data Format", tdm_config_enum[0],
  7197. msm_dai_q6_tdm_data_format_get,
  7198. msm_dai_q6_tdm_data_format_put),
  7199. SOC_ENUM_EXT("SEC_TDM_TX_2 Data Format", tdm_config_enum[0],
  7200. msm_dai_q6_tdm_data_format_get,
  7201. msm_dai_q6_tdm_data_format_put),
  7202. SOC_ENUM_EXT("SEC_TDM_TX_3 Data Format", tdm_config_enum[0],
  7203. msm_dai_q6_tdm_data_format_get,
  7204. msm_dai_q6_tdm_data_format_put),
  7205. SOC_ENUM_EXT("SEC_TDM_TX_4 Data Format", tdm_config_enum[0],
  7206. msm_dai_q6_tdm_data_format_get,
  7207. msm_dai_q6_tdm_data_format_put),
  7208. SOC_ENUM_EXT("SEC_TDM_TX_5 Data Format", tdm_config_enum[0],
  7209. msm_dai_q6_tdm_data_format_get,
  7210. msm_dai_q6_tdm_data_format_put),
  7211. SOC_ENUM_EXT("SEC_TDM_TX_6 Data Format", tdm_config_enum[0],
  7212. msm_dai_q6_tdm_data_format_get,
  7213. msm_dai_q6_tdm_data_format_put),
  7214. SOC_ENUM_EXT("SEC_TDM_TX_7 Data Format", tdm_config_enum[0],
  7215. msm_dai_q6_tdm_data_format_get,
  7216. msm_dai_q6_tdm_data_format_put),
  7217. SOC_ENUM_EXT("TERT_TDM_RX_0 Data Format", tdm_config_enum[0],
  7218. msm_dai_q6_tdm_data_format_get,
  7219. msm_dai_q6_tdm_data_format_put),
  7220. SOC_ENUM_EXT("TERT_TDM_RX_1 Data Format", tdm_config_enum[0],
  7221. msm_dai_q6_tdm_data_format_get,
  7222. msm_dai_q6_tdm_data_format_put),
  7223. SOC_ENUM_EXT("TERT_TDM_RX_2 Data Format", tdm_config_enum[0],
  7224. msm_dai_q6_tdm_data_format_get,
  7225. msm_dai_q6_tdm_data_format_put),
  7226. SOC_ENUM_EXT("TERT_TDM_RX_3 Data Format", tdm_config_enum[0],
  7227. msm_dai_q6_tdm_data_format_get,
  7228. msm_dai_q6_tdm_data_format_put),
  7229. SOC_ENUM_EXT("TERT_TDM_RX_4 Data Format", tdm_config_enum[0],
  7230. msm_dai_q6_tdm_data_format_get,
  7231. msm_dai_q6_tdm_data_format_put),
  7232. SOC_ENUM_EXT("TERT_TDM_RX_5 Data Format", tdm_config_enum[0],
  7233. msm_dai_q6_tdm_data_format_get,
  7234. msm_dai_q6_tdm_data_format_put),
  7235. SOC_ENUM_EXT("TERT_TDM_RX_6 Data Format", tdm_config_enum[0],
  7236. msm_dai_q6_tdm_data_format_get,
  7237. msm_dai_q6_tdm_data_format_put),
  7238. SOC_ENUM_EXT("TERT_TDM_RX_7 Data Format", tdm_config_enum[0],
  7239. msm_dai_q6_tdm_data_format_get,
  7240. msm_dai_q6_tdm_data_format_put),
  7241. SOC_ENUM_EXT("TERT_TDM_TX_0 Data Format", tdm_config_enum[0],
  7242. msm_dai_q6_tdm_data_format_get,
  7243. msm_dai_q6_tdm_data_format_put),
  7244. SOC_ENUM_EXT("TERT_TDM_TX_1 Data Format", tdm_config_enum[0],
  7245. msm_dai_q6_tdm_data_format_get,
  7246. msm_dai_q6_tdm_data_format_put),
  7247. SOC_ENUM_EXT("TERT_TDM_TX_2 Data Format", tdm_config_enum[0],
  7248. msm_dai_q6_tdm_data_format_get,
  7249. msm_dai_q6_tdm_data_format_put),
  7250. SOC_ENUM_EXT("TERT_TDM_TX_3 Data Format", tdm_config_enum[0],
  7251. msm_dai_q6_tdm_data_format_get,
  7252. msm_dai_q6_tdm_data_format_put),
  7253. SOC_ENUM_EXT("TERT_TDM_TX_4 Data Format", tdm_config_enum[0],
  7254. msm_dai_q6_tdm_data_format_get,
  7255. msm_dai_q6_tdm_data_format_put),
  7256. SOC_ENUM_EXT("TERT_TDM_TX_5 Data Format", tdm_config_enum[0],
  7257. msm_dai_q6_tdm_data_format_get,
  7258. msm_dai_q6_tdm_data_format_put),
  7259. SOC_ENUM_EXT("TERT_TDM_TX_6 Data Format", tdm_config_enum[0],
  7260. msm_dai_q6_tdm_data_format_get,
  7261. msm_dai_q6_tdm_data_format_put),
  7262. SOC_ENUM_EXT("TERT_TDM_TX_7 Data Format", tdm_config_enum[0],
  7263. msm_dai_q6_tdm_data_format_get,
  7264. msm_dai_q6_tdm_data_format_put),
  7265. SOC_ENUM_EXT("QUAT_TDM_RX_0 Data Format", tdm_config_enum[0],
  7266. msm_dai_q6_tdm_data_format_get,
  7267. msm_dai_q6_tdm_data_format_put),
  7268. SOC_ENUM_EXT("QUAT_TDM_RX_1 Data Format", tdm_config_enum[0],
  7269. msm_dai_q6_tdm_data_format_get,
  7270. msm_dai_q6_tdm_data_format_put),
  7271. SOC_ENUM_EXT("QUAT_TDM_RX_2 Data Format", tdm_config_enum[0],
  7272. msm_dai_q6_tdm_data_format_get,
  7273. msm_dai_q6_tdm_data_format_put),
  7274. SOC_ENUM_EXT("QUAT_TDM_RX_3 Data Format", tdm_config_enum[0],
  7275. msm_dai_q6_tdm_data_format_get,
  7276. msm_dai_q6_tdm_data_format_put),
  7277. SOC_ENUM_EXT("QUAT_TDM_RX_4 Data Format", tdm_config_enum[0],
  7278. msm_dai_q6_tdm_data_format_get,
  7279. msm_dai_q6_tdm_data_format_put),
  7280. SOC_ENUM_EXT("QUAT_TDM_RX_5 Data Format", tdm_config_enum[0],
  7281. msm_dai_q6_tdm_data_format_get,
  7282. msm_dai_q6_tdm_data_format_put),
  7283. SOC_ENUM_EXT("QUAT_TDM_RX_6 Data Format", tdm_config_enum[0],
  7284. msm_dai_q6_tdm_data_format_get,
  7285. msm_dai_q6_tdm_data_format_put),
  7286. SOC_ENUM_EXT("QUAT_TDM_RX_7 Data Format", tdm_config_enum[0],
  7287. msm_dai_q6_tdm_data_format_get,
  7288. msm_dai_q6_tdm_data_format_put),
  7289. SOC_ENUM_EXT("QUAT_TDM_TX_0 Data Format", tdm_config_enum[0],
  7290. msm_dai_q6_tdm_data_format_get,
  7291. msm_dai_q6_tdm_data_format_put),
  7292. SOC_ENUM_EXT("QUAT_TDM_TX_1 Data Format", tdm_config_enum[0],
  7293. msm_dai_q6_tdm_data_format_get,
  7294. msm_dai_q6_tdm_data_format_put),
  7295. SOC_ENUM_EXT("QUAT_TDM_TX_2 Data Format", tdm_config_enum[0],
  7296. msm_dai_q6_tdm_data_format_get,
  7297. msm_dai_q6_tdm_data_format_put),
  7298. SOC_ENUM_EXT("QUAT_TDM_TX_3 Data Format", tdm_config_enum[0],
  7299. msm_dai_q6_tdm_data_format_get,
  7300. msm_dai_q6_tdm_data_format_put),
  7301. SOC_ENUM_EXT("QUAT_TDM_TX_4 Data Format", tdm_config_enum[0],
  7302. msm_dai_q6_tdm_data_format_get,
  7303. msm_dai_q6_tdm_data_format_put),
  7304. SOC_ENUM_EXT("QUAT_TDM_TX_5 Data Format", tdm_config_enum[0],
  7305. msm_dai_q6_tdm_data_format_get,
  7306. msm_dai_q6_tdm_data_format_put),
  7307. SOC_ENUM_EXT("QUAT_TDM_TX_6 Data Format", tdm_config_enum[0],
  7308. msm_dai_q6_tdm_data_format_get,
  7309. msm_dai_q6_tdm_data_format_put),
  7310. SOC_ENUM_EXT("QUAT_TDM_TX_7 Data Format", tdm_config_enum[0],
  7311. msm_dai_q6_tdm_data_format_get,
  7312. msm_dai_q6_tdm_data_format_put),
  7313. SOC_ENUM_EXT("QUIN_TDM_RX_0 Data Format", tdm_config_enum[0],
  7314. msm_dai_q6_tdm_data_format_get,
  7315. msm_dai_q6_tdm_data_format_put),
  7316. SOC_ENUM_EXT("QUIN_TDM_RX_1 Data Format", tdm_config_enum[0],
  7317. msm_dai_q6_tdm_data_format_get,
  7318. msm_dai_q6_tdm_data_format_put),
  7319. SOC_ENUM_EXT("QUIN_TDM_RX_2 Data Format", tdm_config_enum[0],
  7320. msm_dai_q6_tdm_data_format_get,
  7321. msm_dai_q6_tdm_data_format_put),
  7322. SOC_ENUM_EXT("QUIN_TDM_RX_3 Data Format", tdm_config_enum[0],
  7323. msm_dai_q6_tdm_data_format_get,
  7324. msm_dai_q6_tdm_data_format_put),
  7325. SOC_ENUM_EXT("QUIN_TDM_RX_4 Data Format", tdm_config_enum[0],
  7326. msm_dai_q6_tdm_data_format_get,
  7327. msm_dai_q6_tdm_data_format_put),
  7328. SOC_ENUM_EXT("QUIN_TDM_RX_5 Data Format", tdm_config_enum[0],
  7329. msm_dai_q6_tdm_data_format_get,
  7330. msm_dai_q6_tdm_data_format_put),
  7331. SOC_ENUM_EXT("QUIN_TDM_RX_6 Data Format", tdm_config_enum[0],
  7332. msm_dai_q6_tdm_data_format_get,
  7333. msm_dai_q6_tdm_data_format_put),
  7334. SOC_ENUM_EXT("QUIN_TDM_RX_7 Data Format", tdm_config_enum[0],
  7335. msm_dai_q6_tdm_data_format_get,
  7336. msm_dai_q6_tdm_data_format_put),
  7337. SOC_ENUM_EXT("QUIN_TDM_TX_0 Data Format", tdm_config_enum[0],
  7338. msm_dai_q6_tdm_data_format_get,
  7339. msm_dai_q6_tdm_data_format_put),
  7340. SOC_ENUM_EXT("QUIN_TDM_TX_1 Data Format", tdm_config_enum[0],
  7341. msm_dai_q6_tdm_data_format_get,
  7342. msm_dai_q6_tdm_data_format_put),
  7343. SOC_ENUM_EXT("QUIN_TDM_TX_2 Data Format", tdm_config_enum[0],
  7344. msm_dai_q6_tdm_data_format_get,
  7345. msm_dai_q6_tdm_data_format_put),
  7346. SOC_ENUM_EXT("QUIN_TDM_TX_3 Data Format", tdm_config_enum[0],
  7347. msm_dai_q6_tdm_data_format_get,
  7348. msm_dai_q6_tdm_data_format_put),
  7349. SOC_ENUM_EXT("QUIN_TDM_TX_4 Data Format", tdm_config_enum[0],
  7350. msm_dai_q6_tdm_data_format_get,
  7351. msm_dai_q6_tdm_data_format_put),
  7352. SOC_ENUM_EXT("QUIN_TDM_TX_5 Data Format", tdm_config_enum[0],
  7353. msm_dai_q6_tdm_data_format_get,
  7354. msm_dai_q6_tdm_data_format_put),
  7355. SOC_ENUM_EXT("QUIN_TDM_TX_6 Data Format", tdm_config_enum[0],
  7356. msm_dai_q6_tdm_data_format_get,
  7357. msm_dai_q6_tdm_data_format_put),
  7358. SOC_ENUM_EXT("QUIN_TDM_TX_7 Data Format", tdm_config_enum[0],
  7359. msm_dai_q6_tdm_data_format_get,
  7360. msm_dai_q6_tdm_data_format_put),
  7361. SOC_ENUM_EXT("SEN_TDM_RX_0 Data Format", tdm_config_enum[0],
  7362. msm_dai_q6_tdm_data_format_get,
  7363. msm_dai_q6_tdm_data_format_put),
  7364. SOC_ENUM_EXT("SEN_TDM_RX_1 Data Format", tdm_config_enum[0],
  7365. msm_dai_q6_tdm_data_format_get,
  7366. msm_dai_q6_tdm_data_format_put),
  7367. SOC_ENUM_EXT("SEN_TDM_RX_2 Data Format", tdm_config_enum[0],
  7368. msm_dai_q6_tdm_data_format_get,
  7369. msm_dai_q6_tdm_data_format_put),
  7370. SOC_ENUM_EXT("SEN_TDM_RX_3 Data Format", tdm_config_enum[0],
  7371. msm_dai_q6_tdm_data_format_get,
  7372. msm_dai_q6_tdm_data_format_put),
  7373. SOC_ENUM_EXT("SEN_TDM_RX_4 Data Format", tdm_config_enum[0],
  7374. msm_dai_q6_tdm_data_format_get,
  7375. msm_dai_q6_tdm_data_format_put),
  7376. SOC_ENUM_EXT("SEN_TDM_RX_5 Data Format", tdm_config_enum[0],
  7377. msm_dai_q6_tdm_data_format_get,
  7378. msm_dai_q6_tdm_data_format_put),
  7379. SOC_ENUM_EXT("SEN_TDM_RX_6 Data Format", tdm_config_enum[0],
  7380. msm_dai_q6_tdm_data_format_get,
  7381. msm_dai_q6_tdm_data_format_put),
  7382. SOC_ENUM_EXT("SEN_TDM_RX_7 Data Format", tdm_config_enum[0],
  7383. msm_dai_q6_tdm_data_format_get,
  7384. msm_dai_q6_tdm_data_format_put),
  7385. SOC_ENUM_EXT("SEN_TDM_TX_0 Data Format", tdm_config_enum[0],
  7386. msm_dai_q6_tdm_data_format_get,
  7387. msm_dai_q6_tdm_data_format_put),
  7388. SOC_ENUM_EXT("SEN_TDM_TX_1 Data Format", tdm_config_enum[0],
  7389. msm_dai_q6_tdm_data_format_get,
  7390. msm_dai_q6_tdm_data_format_put),
  7391. SOC_ENUM_EXT("SEN_TDM_TX_2 Data Format", tdm_config_enum[0],
  7392. msm_dai_q6_tdm_data_format_get,
  7393. msm_dai_q6_tdm_data_format_put),
  7394. SOC_ENUM_EXT("SEN_TDM_TX_3 Data Format", tdm_config_enum[0],
  7395. msm_dai_q6_tdm_data_format_get,
  7396. msm_dai_q6_tdm_data_format_put),
  7397. SOC_ENUM_EXT("SEN_TDM_TX_4 Data Format", tdm_config_enum[0],
  7398. msm_dai_q6_tdm_data_format_get,
  7399. msm_dai_q6_tdm_data_format_put),
  7400. SOC_ENUM_EXT("SEN_TDM_TX_5 Data Format", tdm_config_enum[0],
  7401. msm_dai_q6_tdm_data_format_get,
  7402. msm_dai_q6_tdm_data_format_put),
  7403. SOC_ENUM_EXT("SEN_TDM_TX_6 Data Format", tdm_config_enum[0],
  7404. msm_dai_q6_tdm_data_format_get,
  7405. msm_dai_q6_tdm_data_format_put),
  7406. SOC_ENUM_EXT("SEN_TDM_TX_7 Data Format", tdm_config_enum[0],
  7407. msm_dai_q6_tdm_data_format_get,
  7408. msm_dai_q6_tdm_data_format_put),
  7409. };
  7410. static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
  7411. SOC_ENUM_EXT("PRI_TDM_RX_0 Header Type", tdm_config_enum[1],
  7412. msm_dai_q6_tdm_header_type_get,
  7413. msm_dai_q6_tdm_header_type_put),
  7414. SOC_ENUM_EXT("PRI_TDM_RX_1 Header Type", tdm_config_enum[1],
  7415. msm_dai_q6_tdm_header_type_get,
  7416. msm_dai_q6_tdm_header_type_put),
  7417. SOC_ENUM_EXT("PRI_TDM_RX_2 Header Type", tdm_config_enum[1],
  7418. msm_dai_q6_tdm_header_type_get,
  7419. msm_dai_q6_tdm_header_type_put),
  7420. SOC_ENUM_EXT("PRI_TDM_RX_3 Header Type", tdm_config_enum[1],
  7421. msm_dai_q6_tdm_header_type_get,
  7422. msm_dai_q6_tdm_header_type_put),
  7423. SOC_ENUM_EXT("PRI_TDM_RX_4 Header Type", tdm_config_enum[1],
  7424. msm_dai_q6_tdm_header_type_get,
  7425. msm_dai_q6_tdm_header_type_put),
  7426. SOC_ENUM_EXT("PRI_TDM_RX_5 Header Type", tdm_config_enum[1],
  7427. msm_dai_q6_tdm_header_type_get,
  7428. msm_dai_q6_tdm_header_type_put),
  7429. SOC_ENUM_EXT("PRI_TDM_RX_6 Header Type", tdm_config_enum[1],
  7430. msm_dai_q6_tdm_header_type_get,
  7431. msm_dai_q6_tdm_header_type_put),
  7432. SOC_ENUM_EXT("PRI_TDM_RX_7 Header Type", tdm_config_enum[1],
  7433. msm_dai_q6_tdm_header_type_get,
  7434. msm_dai_q6_tdm_header_type_put),
  7435. SOC_ENUM_EXT("PRI_TDM_TX_0 Header Type", tdm_config_enum[1],
  7436. msm_dai_q6_tdm_header_type_get,
  7437. msm_dai_q6_tdm_header_type_put),
  7438. SOC_ENUM_EXT("PRI_TDM_TX_1 Header Type", tdm_config_enum[1],
  7439. msm_dai_q6_tdm_header_type_get,
  7440. msm_dai_q6_tdm_header_type_put),
  7441. SOC_ENUM_EXT("PRI_TDM_TX_2 Header Type", tdm_config_enum[1],
  7442. msm_dai_q6_tdm_header_type_get,
  7443. msm_dai_q6_tdm_header_type_put),
  7444. SOC_ENUM_EXT("PRI_TDM_TX_3 Header Type", tdm_config_enum[1],
  7445. msm_dai_q6_tdm_header_type_get,
  7446. msm_dai_q6_tdm_header_type_put),
  7447. SOC_ENUM_EXT("PRI_TDM_TX_4 Header Type", tdm_config_enum[1],
  7448. msm_dai_q6_tdm_header_type_get,
  7449. msm_dai_q6_tdm_header_type_put),
  7450. SOC_ENUM_EXT("PRI_TDM_TX_5 Header Type", tdm_config_enum[1],
  7451. msm_dai_q6_tdm_header_type_get,
  7452. msm_dai_q6_tdm_header_type_put),
  7453. SOC_ENUM_EXT("PRI_TDM_TX_6 Header Type", tdm_config_enum[1],
  7454. msm_dai_q6_tdm_header_type_get,
  7455. msm_dai_q6_tdm_header_type_put),
  7456. SOC_ENUM_EXT("PRI_TDM_TX_7 Header Type", tdm_config_enum[1],
  7457. msm_dai_q6_tdm_header_type_get,
  7458. msm_dai_q6_tdm_header_type_put),
  7459. SOC_ENUM_EXT("SEC_TDM_RX_0 Header Type", tdm_config_enum[1],
  7460. msm_dai_q6_tdm_header_type_get,
  7461. msm_dai_q6_tdm_header_type_put),
  7462. SOC_ENUM_EXT("SEC_TDM_RX_1 Header Type", tdm_config_enum[1],
  7463. msm_dai_q6_tdm_header_type_get,
  7464. msm_dai_q6_tdm_header_type_put),
  7465. SOC_ENUM_EXT("SEC_TDM_RX_2 Header Type", tdm_config_enum[1],
  7466. msm_dai_q6_tdm_header_type_get,
  7467. msm_dai_q6_tdm_header_type_put),
  7468. SOC_ENUM_EXT("SEC_TDM_RX_3 Header Type", tdm_config_enum[1],
  7469. msm_dai_q6_tdm_header_type_get,
  7470. msm_dai_q6_tdm_header_type_put),
  7471. SOC_ENUM_EXT("SEC_TDM_RX_4 Header Type", tdm_config_enum[1],
  7472. msm_dai_q6_tdm_header_type_get,
  7473. msm_dai_q6_tdm_header_type_put),
  7474. SOC_ENUM_EXT("SEC_TDM_RX_5 Header Type", tdm_config_enum[1],
  7475. msm_dai_q6_tdm_header_type_get,
  7476. msm_dai_q6_tdm_header_type_put),
  7477. SOC_ENUM_EXT("SEC_TDM_RX_6 Header Type", tdm_config_enum[1],
  7478. msm_dai_q6_tdm_header_type_get,
  7479. msm_dai_q6_tdm_header_type_put),
  7480. SOC_ENUM_EXT("SEC_TDM_RX_7 Header Type", tdm_config_enum[1],
  7481. msm_dai_q6_tdm_header_type_get,
  7482. msm_dai_q6_tdm_header_type_put),
  7483. SOC_ENUM_EXT("SEC_TDM_TX_0 Header Type", tdm_config_enum[1],
  7484. msm_dai_q6_tdm_header_type_get,
  7485. msm_dai_q6_tdm_header_type_put),
  7486. SOC_ENUM_EXT("SEC_TDM_TX_1 Header Type", tdm_config_enum[1],
  7487. msm_dai_q6_tdm_header_type_get,
  7488. msm_dai_q6_tdm_header_type_put),
  7489. SOC_ENUM_EXT("SEC_TDM_TX_2 Header Type", tdm_config_enum[1],
  7490. msm_dai_q6_tdm_header_type_get,
  7491. msm_dai_q6_tdm_header_type_put),
  7492. SOC_ENUM_EXT("SEC_TDM_TX_3 Header Type", tdm_config_enum[1],
  7493. msm_dai_q6_tdm_header_type_get,
  7494. msm_dai_q6_tdm_header_type_put),
  7495. SOC_ENUM_EXT("SEC_TDM_TX_4 Header Type", tdm_config_enum[1],
  7496. msm_dai_q6_tdm_header_type_get,
  7497. msm_dai_q6_tdm_header_type_put),
  7498. SOC_ENUM_EXT("SEC_TDM_TX_5 Header Type", tdm_config_enum[1],
  7499. msm_dai_q6_tdm_header_type_get,
  7500. msm_dai_q6_tdm_header_type_put),
  7501. SOC_ENUM_EXT("SEC_TDM_TX_6 Header Type", tdm_config_enum[1],
  7502. msm_dai_q6_tdm_header_type_get,
  7503. msm_dai_q6_tdm_header_type_put),
  7504. SOC_ENUM_EXT("SEC_TDM_TX_7 Header Type", tdm_config_enum[1],
  7505. msm_dai_q6_tdm_header_type_get,
  7506. msm_dai_q6_tdm_header_type_put),
  7507. SOC_ENUM_EXT("TERT_TDM_RX_0 Header Type", tdm_config_enum[1],
  7508. msm_dai_q6_tdm_header_type_get,
  7509. msm_dai_q6_tdm_header_type_put),
  7510. SOC_ENUM_EXT("TERT_TDM_RX_1 Header Type", tdm_config_enum[1],
  7511. msm_dai_q6_tdm_header_type_get,
  7512. msm_dai_q6_tdm_header_type_put),
  7513. SOC_ENUM_EXT("TERT_TDM_RX_2 Header Type", tdm_config_enum[1],
  7514. msm_dai_q6_tdm_header_type_get,
  7515. msm_dai_q6_tdm_header_type_put),
  7516. SOC_ENUM_EXT("TERT_TDM_RX_3 Header Type", tdm_config_enum[1],
  7517. msm_dai_q6_tdm_header_type_get,
  7518. msm_dai_q6_tdm_header_type_put),
  7519. SOC_ENUM_EXT("TERT_TDM_RX_4 Header Type", tdm_config_enum[1],
  7520. msm_dai_q6_tdm_header_type_get,
  7521. msm_dai_q6_tdm_header_type_put),
  7522. SOC_ENUM_EXT("TERT_TDM_RX_5 Header Type", tdm_config_enum[1],
  7523. msm_dai_q6_tdm_header_type_get,
  7524. msm_dai_q6_tdm_header_type_put),
  7525. SOC_ENUM_EXT("TERT_TDM_RX_6 Header Type", tdm_config_enum[1],
  7526. msm_dai_q6_tdm_header_type_get,
  7527. msm_dai_q6_tdm_header_type_put),
  7528. SOC_ENUM_EXT("TERT_TDM_RX_7 Header Type", tdm_config_enum[1],
  7529. msm_dai_q6_tdm_header_type_get,
  7530. msm_dai_q6_tdm_header_type_put),
  7531. SOC_ENUM_EXT("TERT_TDM_TX_0 Header Type", tdm_config_enum[1],
  7532. msm_dai_q6_tdm_header_type_get,
  7533. msm_dai_q6_tdm_header_type_put),
  7534. SOC_ENUM_EXT("TERT_TDM_TX_1 Header Type", tdm_config_enum[1],
  7535. msm_dai_q6_tdm_header_type_get,
  7536. msm_dai_q6_tdm_header_type_put),
  7537. SOC_ENUM_EXT("TERT_TDM_TX_2 Header Type", tdm_config_enum[1],
  7538. msm_dai_q6_tdm_header_type_get,
  7539. msm_dai_q6_tdm_header_type_put),
  7540. SOC_ENUM_EXT("TERT_TDM_TX_3 Header Type", tdm_config_enum[1],
  7541. msm_dai_q6_tdm_header_type_get,
  7542. msm_dai_q6_tdm_header_type_put),
  7543. SOC_ENUM_EXT("TERT_TDM_TX_4 Header Type", tdm_config_enum[1],
  7544. msm_dai_q6_tdm_header_type_get,
  7545. msm_dai_q6_tdm_header_type_put),
  7546. SOC_ENUM_EXT("TERT_TDM_TX_5 Header Type", tdm_config_enum[1],
  7547. msm_dai_q6_tdm_header_type_get,
  7548. msm_dai_q6_tdm_header_type_put),
  7549. SOC_ENUM_EXT("TERT_TDM_TX_6 Header Type", tdm_config_enum[1],
  7550. msm_dai_q6_tdm_header_type_get,
  7551. msm_dai_q6_tdm_header_type_put),
  7552. SOC_ENUM_EXT("TERT_TDM_TX_7 Header Type", tdm_config_enum[1],
  7553. msm_dai_q6_tdm_header_type_get,
  7554. msm_dai_q6_tdm_header_type_put),
  7555. SOC_ENUM_EXT("QUAT_TDM_RX_0 Header Type", tdm_config_enum[1],
  7556. msm_dai_q6_tdm_header_type_get,
  7557. msm_dai_q6_tdm_header_type_put),
  7558. SOC_ENUM_EXT("QUAT_TDM_RX_1 Header Type", tdm_config_enum[1],
  7559. msm_dai_q6_tdm_header_type_get,
  7560. msm_dai_q6_tdm_header_type_put),
  7561. SOC_ENUM_EXT("QUAT_TDM_RX_2 Header Type", tdm_config_enum[1],
  7562. msm_dai_q6_tdm_header_type_get,
  7563. msm_dai_q6_tdm_header_type_put),
  7564. SOC_ENUM_EXT("QUAT_TDM_RX_3 Header Type", tdm_config_enum[1],
  7565. msm_dai_q6_tdm_header_type_get,
  7566. msm_dai_q6_tdm_header_type_put),
  7567. SOC_ENUM_EXT("QUAT_TDM_RX_4 Header Type", tdm_config_enum[1],
  7568. msm_dai_q6_tdm_header_type_get,
  7569. msm_dai_q6_tdm_header_type_put),
  7570. SOC_ENUM_EXT("QUAT_TDM_RX_5 Header Type", tdm_config_enum[1],
  7571. msm_dai_q6_tdm_header_type_get,
  7572. msm_dai_q6_tdm_header_type_put),
  7573. SOC_ENUM_EXT("QUAT_TDM_RX_6 Header Type", tdm_config_enum[1],
  7574. msm_dai_q6_tdm_header_type_get,
  7575. msm_dai_q6_tdm_header_type_put),
  7576. SOC_ENUM_EXT("QUAT_TDM_RX_7 Header Type", tdm_config_enum[1],
  7577. msm_dai_q6_tdm_header_type_get,
  7578. msm_dai_q6_tdm_header_type_put),
  7579. SOC_ENUM_EXT("QUAT_TDM_TX_0 Header Type", tdm_config_enum[1],
  7580. msm_dai_q6_tdm_header_type_get,
  7581. msm_dai_q6_tdm_header_type_put),
  7582. SOC_ENUM_EXT("QUAT_TDM_TX_1 Header Type", tdm_config_enum[1],
  7583. msm_dai_q6_tdm_header_type_get,
  7584. msm_dai_q6_tdm_header_type_put),
  7585. SOC_ENUM_EXT("QUAT_TDM_TX_2 Header Type", tdm_config_enum[1],
  7586. msm_dai_q6_tdm_header_type_get,
  7587. msm_dai_q6_tdm_header_type_put),
  7588. SOC_ENUM_EXT("QUAT_TDM_TX_3 Header Type", tdm_config_enum[1],
  7589. msm_dai_q6_tdm_header_type_get,
  7590. msm_dai_q6_tdm_header_type_put),
  7591. SOC_ENUM_EXT("QUAT_TDM_TX_4 Header Type", tdm_config_enum[1],
  7592. msm_dai_q6_tdm_header_type_get,
  7593. msm_dai_q6_tdm_header_type_put),
  7594. SOC_ENUM_EXT("QUAT_TDM_TX_5 Header Type", tdm_config_enum[1],
  7595. msm_dai_q6_tdm_header_type_get,
  7596. msm_dai_q6_tdm_header_type_put),
  7597. SOC_ENUM_EXT("QUAT_TDM_TX_6 Header Type", tdm_config_enum[1],
  7598. msm_dai_q6_tdm_header_type_get,
  7599. msm_dai_q6_tdm_header_type_put),
  7600. SOC_ENUM_EXT("QUAT_TDM_TX_7 Header Type", tdm_config_enum[1],
  7601. msm_dai_q6_tdm_header_type_get,
  7602. msm_dai_q6_tdm_header_type_put),
  7603. SOC_ENUM_EXT("QUIN_TDM_RX_0 Header Type", tdm_config_enum[1],
  7604. msm_dai_q6_tdm_header_type_get,
  7605. msm_dai_q6_tdm_header_type_put),
  7606. SOC_ENUM_EXT("QUIN_TDM_RX_1 Header Type", tdm_config_enum[1],
  7607. msm_dai_q6_tdm_header_type_get,
  7608. msm_dai_q6_tdm_header_type_put),
  7609. SOC_ENUM_EXT("QUIN_TDM_RX_2 Header Type", tdm_config_enum[1],
  7610. msm_dai_q6_tdm_header_type_get,
  7611. msm_dai_q6_tdm_header_type_put),
  7612. SOC_ENUM_EXT("QUIN_TDM_RX_3 Header Type", tdm_config_enum[1],
  7613. msm_dai_q6_tdm_header_type_get,
  7614. msm_dai_q6_tdm_header_type_put),
  7615. SOC_ENUM_EXT("QUIN_TDM_RX_4 Header Type", tdm_config_enum[1],
  7616. msm_dai_q6_tdm_header_type_get,
  7617. msm_dai_q6_tdm_header_type_put),
  7618. SOC_ENUM_EXT("QUIN_TDM_RX_5 Header Type", tdm_config_enum[1],
  7619. msm_dai_q6_tdm_header_type_get,
  7620. msm_dai_q6_tdm_header_type_put),
  7621. SOC_ENUM_EXT("QUIN_TDM_RX_6 Header Type", tdm_config_enum[1],
  7622. msm_dai_q6_tdm_header_type_get,
  7623. msm_dai_q6_tdm_header_type_put),
  7624. SOC_ENUM_EXT("QUIN_TDM_RX_7 Header Type", tdm_config_enum[1],
  7625. msm_dai_q6_tdm_header_type_get,
  7626. msm_dai_q6_tdm_header_type_put),
  7627. SOC_ENUM_EXT("QUIN_TDM_TX_0 Header Type", tdm_config_enum[1],
  7628. msm_dai_q6_tdm_header_type_get,
  7629. msm_dai_q6_tdm_header_type_put),
  7630. SOC_ENUM_EXT("QUIN_TDM_TX_1 Header Type", tdm_config_enum[1],
  7631. msm_dai_q6_tdm_header_type_get,
  7632. msm_dai_q6_tdm_header_type_put),
  7633. SOC_ENUM_EXT("QUIN_TDM_TX_2 Header Type", tdm_config_enum[1],
  7634. msm_dai_q6_tdm_header_type_get,
  7635. msm_dai_q6_tdm_header_type_put),
  7636. SOC_ENUM_EXT("QUIN_TDM_TX_3 Header Type", tdm_config_enum[1],
  7637. msm_dai_q6_tdm_header_type_get,
  7638. msm_dai_q6_tdm_header_type_put),
  7639. SOC_ENUM_EXT("QUIN_TDM_TX_4 Header Type", tdm_config_enum[1],
  7640. msm_dai_q6_tdm_header_type_get,
  7641. msm_dai_q6_tdm_header_type_put),
  7642. SOC_ENUM_EXT("QUIN_TDM_TX_5 Header Type", tdm_config_enum[1],
  7643. msm_dai_q6_tdm_header_type_get,
  7644. msm_dai_q6_tdm_header_type_put),
  7645. SOC_ENUM_EXT("QUIN_TDM_TX_6 Header Type", tdm_config_enum[1],
  7646. msm_dai_q6_tdm_header_type_get,
  7647. msm_dai_q6_tdm_header_type_put),
  7648. SOC_ENUM_EXT("QUIN_TDM_TX_7 Header Type", tdm_config_enum[1],
  7649. msm_dai_q6_tdm_header_type_get,
  7650. msm_dai_q6_tdm_header_type_put),
  7651. SOC_ENUM_EXT("SEN_TDM_RX_0 Header Type", tdm_config_enum[1],
  7652. msm_dai_q6_tdm_header_type_get,
  7653. msm_dai_q6_tdm_header_type_put),
  7654. SOC_ENUM_EXT("SEN_TDM_RX_1 Header Type", tdm_config_enum[1],
  7655. msm_dai_q6_tdm_header_type_get,
  7656. msm_dai_q6_tdm_header_type_put),
  7657. SOC_ENUM_EXT("SEN_TDM_RX_2 Header Type", tdm_config_enum[1],
  7658. msm_dai_q6_tdm_header_type_get,
  7659. msm_dai_q6_tdm_header_type_put),
  7660. SOC_ENUM_EXT("SEN_TDM_RX_3 Header Type", tdm_config_enum[1],
  7661. msm_dai_q6_tdm_header_type_get,
  7662. msm_dai_q6_tdm_header_type_put),
  7663. SOC_ENUM_EXT("SEN_TDM_RX_4 Header Type", tdm_config_enum[1],
  7664. msm_dai_q6_tdm_header_type_get,
  7665. msm_dai_q6_tdm_header_type_put),
  7666. SOC_ENUM_EXT("SEN_TDM_RX_5 Header Type", tdm_config_enum[1],
  7667. msm_dai_q6_tdm_header_type_get,
  7668. msm_dai_q6_tdm_header_type_put),
  7669. SOC_ENUM_EXT("SEN_TDM_RX_6 Header Type", tdm_config_enum[1],
  7670. msm_dai_q6_tdm_header_type_get,
  7671. msm_dai_q6_tdm_header_type_put),
  7672. SOC_ENUM_EXT("SEN_TDM_RX_7 Header Type", tdm_config_enum[1],
  7673. msm_dai_q6_tdm_header_type_get,
  7674. msm_dai_q6_tdm_header_type_put),
  7675. SOC_ENUM_EXT("SEN_TDM_TX_0 Header Type", tdm_config_enum[1],
  7676. msm_dai_q6_tdm_header_type_get,
  7677. msm_dai_q6_tdm_header_type_put),
  7678. SOC_ENUM_EXT("SEN_TDM_TX_1 Header Type", tdm_config_enum[1],
  7679. msm_dai_q6_tdm_header_type_get,
  7680. msm_dai_q6_tdm_header_type_put),
  7681. SOC_ENUM_EXT("SEN_TDM_TX_2 Header Type", tdm_config_enum[1],
  7682. msm_dai_q6_tdm_header_type_get,
  7683. msm_dai_q6_tdm_header_type_put),
  7684. SOC_ENUM_EXT("SEN_TDM_TX_3 Header Type", tdm_config_enum[1],
  7685. msm_dai_q6_tdm_header_type_get,
  7686. msm_dai_q6_tdm_header_type_put),
  7687. SOC_ENUM_EXT("SEN_TDM_TX_4 Header Type", tdm_config_enum[1],
  7688. msm_dai_q6_tdm_header_type_get,
  7689. msm_dai_q6_tdm_header_type_put),
  7690. SOC_ENUM_EXT("SEN_TDM_TX_5 Header Type", tdm_config_enum[1],
  7691. msm_dai_q6_tdm_header_type_get,
  7692. msm_dai_q6_tdm_header_type_put),
  7693. SOC_ENUM_EXT("SEN_TDM_TX_6 Header Type", tdm_config_enum[1],
  7694. msm_dai_q6_tdm_header_type_get,
  7695. msm_dai_q6_tdm_header_type_put),
  7696. SOC_ENUM_EXT("SEN_TDM_TX_7 Header Type", tdm_config_enum[1],
  7697. msm_dai_q6_tdm_header_type_get,
  7698. msm_dai_q6_tdm_header_type_put),
  7699. };
  7700. static const struct snd_kcontrol_new tdm_config_controls_header[] = {
  7701. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
  7702. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7703. msm_dai_q6_tdm_header_get,
  7704. msm_dai_q6_tdm_header_put),
  7705. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
  7706. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7707. msm_dai_q6_tdm_header_get,
  7708. msm_dai_q6_tdm_header_put),
  7709. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
  7710. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7711. msm_dai_q6_tdm_header_get,
  7712. msm_dai_q6_tdm_header_put),
  7713. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
  7714. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7715. msm_dai_q6_tdm_header_get,
  7716. msm_dai_q6_tdm_header_put),
  7717. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
  7718. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7719. msm_dai_q6_tdm_header_get,
  7720. msm_dai_q6_tdm_header_put),
  7721. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 Header",
  7722. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7723. msm_dai_q6_tdm_header_get,
  7724. msm_dai_q6_tdm_header_put),
  7725. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_6 Header",
  7726. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7727. msm_dai_q6_tdm_header_get,
  7728. msm_dai_q6_tdm_header_put),
  7729. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_7 Header",
  7730. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7731. msm_dai_q6_tdm_header_get,
  7732. msm_dai_q6_tdm_header_put),
  7733. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 Header",
  7734. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7735. msm_dai_q6_tdm_header_get,
  7736. msm_dai_q6_tdm_header_put),
  7737. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 Header",
  7738. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7739. msm_dai_q6_tdm_header_get,
  7740. msm_dai_q6_tdm_header_put),
  7741. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 Header",
  7742. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7743. msm_dai_q6_tdm_header_get,
  7744. msm_dai_q6_tdm_header_put),
  7745. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 Header",
  7746. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7747. msm_dai_q6_tdm_header_get,
  7748. msm_dai_q6_tdm_header_put),
  7749. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_4 Header",
  7750. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7751. msm_dai_q6_tdm_header_get,
  7752. msm_dai_q6_tdm_header_put),
  7753. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_5 Header",
  7754. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7755. msm_dai_q6_tdm_header_get,
  7756. msm_dai_q6_tdm_header_put),
  7757. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_6 Header",
  7758. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7759. msm_dai_q6_tdm_header_get,
  7760. msm_dai_q6_tdm_header_put),
  7761. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_7 Header",
  7762. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7763. msm_dai_q6_tdm_header_get,
  7764. msm_dai_q6_tdm_header_put),
  7765. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 Header",
  7766. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7767. msm_dai_q6_tdm_header_get,
  7768. msm_dai_q6_tdm_header_put),
  7769. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 Header",
  7770. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7771. msm_dai_q6_tdm_header_get,
  7772. msm_dai_q6_tdm_header_put),
  7773. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 Header",
  7774. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7775. msm_dai_q6_tdm_header_get,
  7776. msm_dai_q6_tdm_header_put),
  7777. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 Header",
  7778. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7779. msm_dai_q6_tdm_header_get,
  7780. msm_dai_q6_tdm_header_put),
  7781. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_4 Header",
  7782. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7783. msm_dai_q6_tdm_header_get,
  7784. msm_dai_q6_tdm_header_put),
  7785. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_5 Header",
  7786. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7787. msm_dai_q6_tdm_header_get,
  7788. msm_dai_q6_tdm_header_put),
  7789. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_6 Header",
  7790. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7791. msm_dai_q6_tdm_header_get,
  7792. msm_dai_q6_tdm_header_put),
  7793. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_7 Header",
  7794. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7795. msm_dai_q6_tdm_header_get,
  7796. msm_dai_q6_tdm_header_put),
  7797. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 Header",
  7798. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7799. msm_dai_q6_tdm_header_get,
  7800. msm_dai_q6_tdm_header_put),
  7801. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 Header",
  7802. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7803. msm_dai_q6_tdm_header_get,
  7804. msm_dai_q6_tdm_header_put),
  7805. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 Header",
  7806. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7807. msm_dai_q6_tdm_header_get,
  7808. msm_dai_q6_tdm_header_put),
  7809. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 Header",
  7810. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7811. msm_dai_q6_tdm_header_get,
  7812. msm_dai_q6_tdm_header_put),
  7813. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_4 Header",
  7814. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7815. msm_dai_q6_tdm_header_get,
  7816. msm_dai_q6_tdm_header_put),
  7817. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_5 Header",
  7818. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7819. msm_dai_q6_tdm_header_get,
  7820. msm_dai_q6_tdm_header_put),
  7821. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_6 Header",
  7822. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7823. msm_dai_q6_tdm_header_get,
  7824. msm_dai_q6_tdm_header_put),
  7825. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_7 Header",
  7826. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7827. msm_dai_q6_tdm_header_get,
  7828. msm_dai_q6_tdm_header_put),
  7829. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 Header",
  7830. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7831. msm_dai_q6_tdm_header_get,
  7832. msm_dai_q6_tdm_header_put),
  7833. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 Header",
  7834. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7835. msm_dai_q6_tdm_header_get,
  7836. msm_dai_q6_tdm_header_put),
  7837. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 Header",
  7838. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7839. msm_dai_q6_tdm_header_get,
  7840. msm_dai_q6_tdm_header_put),
  7841. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 Header",
  7842. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7843. msm_dai_q6_tdm_header_get,
  7844. msm_dai_q6_tdm_header_put),
  7845. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 Header",
  7846. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7847. msm_dai_q6_tdm_header_get,
  7848. msm_dai_q6_tdm_header_put),
  7849. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_5 Header",
  7850. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7851. msm_dai_q6_tdm_header_get,
  7852. msm_dai_q6_tdm_header_put),
  7853. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_6 Header",
  7854. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7855. msm_dai_q6_tdm_header_get,
  7856. msm_dai_q6_tdm_header_put),
  7857. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_7 Header",
  7858. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7859. msm_dai_q6_tdm_header_get,
  7860. msm_dai_q6_tdm_header_put),
  7861. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 Header",
  7862. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7863. msm_dai_q6_tdm_header_get,
  7864. msm_dai_q6_tdm_header_put),
  7865. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 Header",
  7866. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7867. msm_dai_q6_tdm_header_get,
  7868. msm_dai_q6_tdm_header_put),
  7869. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 Header",
  7870. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7871. msm_dai_q6_tdm_header_get,
  7872. msm_dai_q6_tdm_header_put),
  7873. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 Header",
  7874. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7875. msm_dai_q6_tdm_header_get,
  7876. msm_dai_q6_tdm_header_put),
  7877. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_4 Header",
  7878. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7879. msm_dai_q6_tdm_header_get,
  7880. msm_dai_q6_tdm_header_put),
  7881. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_5 Header",
  7882. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7883. msm_dai_q6_tdm_header_get,
  7884. msm_dai_q6_tdm_header_put),
  7885. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_6 Header",
  7886. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7887. msm_dai_q6_tdm_header_get,
  7888. msm_dai_q6_tdm_header_put),
  7889. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_7 Header",
  7890. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7891. msm_dai_q6_tdm_header_get,
  7892. msm_dai_q6_tdm_header_put),
  7893. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 Header",
  7894. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7895. msm_dai_q6_tdm_header_get,
  7896. msm_dai_q6_tdm_header_put),
  7897. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 Header",
  7898. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7899. msm_dai_q6_tdm_header_get,
  7900. msm_dai_q6_tdm_header_put),
  7901. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 Header",
  7902. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7903. msm_dai_q6_tdm_header_get,
  7904. msm_dai_q6_tdm_header_put),
  7905. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 Header",
  7906. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7907. msm_dai_q6_tdm_header_get,
  7908. msm_dai_q6_tdm_header_put),
  7909. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_4 Header",
  7910. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7911. msm_dai_q6_tdm_header_get,
  7912. msm_dai_q6_tdm_header_put),
  7913. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_5 Header",
  7914. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7915. msm_dai_q6_tdm_header_get,
  7916. msm_dai_q6_tdm_header_put),
  7917. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_6 Header",
  7918. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7919. msm_dai_q6_tdm_header_get,
  7920. msm_dai_q6_tdm_header_put),
  7921. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_7 Header",
  7922. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7923. msm_dai_q6_tdm_header_get,
  7924. msm_dai_q6_tdm_header_put),
  7925. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 Header",
  7926. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7927. msm_dai_q6_tdm_header_get,
  7928. msm_dai_q6_tdm_header_put),
  7929. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 Header",
  7930. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7931. msm_dai_q6_tdm_header_get,
  7932. msm_dai_q6_tdm_header_put),
  7933. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 Header",
  7934. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7935. msm_dai_q6_tdm_header_get,
  7936. msm_dai_q6_tdm_header_put),
  7937. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 Header",
  7938. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7939. msm_dai_q6_tdm_header_get,
  7940. msm_dai_q6_tdm_header_put),
  7941. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_4 Header",
  7942. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7943. msm_dai_q6_tdm_header_get,
  7944. msm_dai_q6_tdm_header_put),
  7945. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_5 Header",
  7946. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7947. msm_dai_q6_tdm_header_get,
  7948. msm_dai_q6_tdm_header_put),
  7949. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_6 Header",
  7950. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7951. msm_dai_q6_tdm_header_get,
  7952. msm_dai_q6_tdm_header_put),
  7953. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_7 Header",
  7954. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7955. msm_dai_q6_tdm_header_get,
  7956. msm_dai_q6_tdm_header_put),
  7957. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_0 Header",
  7958. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7959. msm_dai_q6_tdm_header_get,
  7960. msm_dai_q6_tdm_header_put),
  7961. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_1 Header",
  7962. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7963. msm_dai_q6_tdm_header_get,
  7964. msm_dai_q6_tdm_header_put),
  7965. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_2 Header",
  7966. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7967. msm_dai_q6_tdm_header_get,
  7968. msm_dai_q6_tdm_header_put),
  7969. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_3 Header",
  7970. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7971. msm_dai_q6_tdm_header_get,
  7972. msm_dai_q6_tdm_header_put),
  7973. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_4 Header",
  7974. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7975. msm_dai_q6_tdm_header_get,
  7976. msm_dai_q6_tdm_header_put),
  7977. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_5 Header",
  7978. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7979. msm_dai_q6_tdm_header_get,
  7980. msm_dai_q6_tdm_header_put),
  7981. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_6 Header",
  7982. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7983. msm_dai_q6_tdm_header_get,
  7984. msm_dai_q6_tdm_header_put),
  7985. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_7 Header",
  7986. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7987. msm_dai_q6_tdm_header_get,
  7988. msm_dai_q6_tdm_header_put),
  7989. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_0 Header",
  7990. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7991. msm_dai_q6_tdm_header_get,
  7992. msm_dai_q6_tdm_header_put),
  7993. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_1 Header",
  7994. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7995. msm_dai_q6_tdm_header_get,
  7996. msm_dai_q6_tdm_header_put),
  7997. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_2 Header",
  7998. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  7999. msm_dai_q6_tdm_header_get,
  8000. msm_dai_q6_tdm_header_put),
  8001. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_3 Header",
  8002. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8003. msm_dai_q6_tdm_header_get,
  8004. msm_dai_q6_tdm_header_put),
  8005. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_4 Header",
  8006. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8007. msm_dai_q6_tdm_header_get,
  8008. msm_dai_q6_tdm_header_put),
  8009. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_5 Header",
  8010. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8011. msm_dai_q6_tdm_header_get,
  8012. msm_dai_q6_tdm_header_put),
  8013. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_6 Header",
  8014. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8015. msm_dai_q6_tdm_header_get,
  8016. msm_dai_q6_tdm_header_put),
  8017. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_7 Header",
  8018. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8019. msm_dai_q6_tdm_header_get,
  8020. msm_dai_q6_tdm_header_put),
  8021. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_0 Header",
  8022. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8023. msm_dai_q6_tdm_header_get,
  8024. msm_dai_q6_tdm_header_put),
  8025. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_1 Header",
  8026. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8027. msm_dai_q6_tdm_header_get,
  8028. msm_dai_q6_tdm_header_put),
  8029. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_2 Header",
  8030. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8031. msm_dai_q6_tdm_header_get,
  8032. msm_dai_q6_tdm_header_put),
  8033. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_3 Header",
  8034. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8035. msm_dai_q6_tdm_header_get,
  8036. msm_dai_q6_tdm_header_put),
  8037. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_4 Header",
  8038. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8039. msm_dai_q6_tdm_header_get,
  8040. msm_dai_q6_tdm_header_put),
  8041. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_5 Header",
  8042. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8043. msm_dai_q6_tdm_header_get,
  8044. msm_dai_q6_tdm_header_put),
  8045. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_6 Header",
  8046. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8047. msm_dai_q6_tdm_header_get,
  8048. msm_dai_q6_tdm_header_put),
  8049. SOC_SINGLE_MULTI_EXT("SEN_TDM_RX_7 Header",
  8050. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8051. msm_dai_q6_tdm_header_get,
  8052. msm_dai_q6_tdm_header_put),
  8053. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_0 Header",
  8054. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8055. msm_dai_q6_tdm_header_get,
  8056. msm_dai_q6_tdm_header_put),
  8057. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_1 Header",
  8058. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8059. msm_dai_q6_tdm_header_get,
  8060. msm_dai_q6_tdm_header_put),
  8061. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_2 Header",
  8062. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8063. msm_dai_q6_tdm_header_get,
  8064. msm_dai_q6_tdm_header_put),
  8065. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_3 Header",
  8066. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8067. msm_dai_q6_tdm_header_get,
  8068. msm_dai_q6_tdm_header_put),
  8069. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_4 Header",
  8070. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8071. msm_dai_q6_tdm_header_get,
  8072. msm_dai_q6_tdm_header_put),
  8073. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_5 Header",
  8074. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8075. msm_dai_q6_tdm_header_get,
  8076. msm_dai_q6_tdm_header_put),
  8077. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_6 Header",
  8078. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8079. msm_dai_q6_tdm_header_get,
  8080. msm_dai_q6_tdm_header_put),
  8081. SOC_SINGLE_MULTI_EXT("SEN_TDM_TX_7 Header",
  8082. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  8083. msm_dai_q6_tdm_header_get,
  8084. msm_dai_q6_tdm_header_put),
  8085. };
  8086. static int msm_dai_q6_tdm_set_clk(
  8087. struct msm_dai_q6_tdm_dai_data *dai_data,
  8088. u16 port_id, bool enable)
  8089. {
  8090. int rc = 0;
  8091. dai_data->clk_set.enable = enable;
  8092. rc = afe_set_lpass_clock_v2(port_id,
  8093. &dai_data->clk_set);
  8094. if (rc < 0)
  8095. pr_err("%s: afe lpass clock failed, err:%d\n",
  8096. __func__, rc);
  8097. return rc;
  8098. }
  8099. static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
  8100. {
  8101. int rc = 0;
  8102. struct msm_dai_q6_tdm_dai_data *tdm_dai_data = NULL;
  8103. struct snd_kcontrol *data_format_kcontrol = NULL;
  8104. struct snd_kcontrol *header_type_kcontrol = NULL;
  8105. struct snd_kcontrol *header_kcontrol = NULL;
  8106. int port_idx = 0;
  8107. const struct snd_kcontrol_new *data_format_ctrl = NULL;
  8108. const struct snd_kcontrol_new *header_type_ctrl = NULL;
  8109. const struct snd_kcontrol_new *header_ctrl = NULL;
  8110. tdm_dai_data = dev_get_drvdata(dai->dev);
  8111. msm_dai_q6_set_dai_id(dai);
  8112. port_idx = msm_dai_q6_get_port_idx(dai->id);
  8113. if (port_idx < 0) {
  8114. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8115. __func__, dai->id);
  8116. rc = -EINVAL;
  8117. goto rtn;
  8118. }
  8119. data_format_ctrl =
  8120. &tdm_config_controls_data_format[port_idx];
  8121. header_type_ctrl =
  8122. &tdm_config_controls_header_type[port_idx];
  8123. header_ctrl =
  8124. &tdm_config_controls_header[port_idx];
  8125. if (data_format_ctrl) {
  8126. data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
  8127. tdm_dai_data);
  8128. rc = snd_ctl_add(dai->component->card->snd_card,
  8129. data_format_kcontrol);
  8130. if (rc < 0) {
  8131. dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
  8132. __func__, dai->name);
  8133. goto rtn;
  8134. }
  8135. }
  8136. if (header_type_ctrl) {
  8137. header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
  8138. tdm_dai_data);
  8139. rc = snd_ctl_add(dai->component->card->snd_card,
  8140. header_type_kcontrol);
  8141. if (rc < 0) {
  8142. if (data_format_kcontrol)
  8143. snd_ctl_remove(dai->component->card->snd_card,
  8144. data_format_kcontrol);
  8145. dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
  8146. __func__, dai->name);
  8147. goto rtn;
  8148. }
  8149. }
  8150. if (header_ctrl) {
  8151. header_kcontrol = snd_ctl_new1(header_ctrl,
  8152. tdm_dai_data);
  8153. rc = snd_ctl_add(dai->component->card->snd_card,
  8154. header_kcontrol);
  8155. if (rc < 0) {
  8156. if (header_type_kcontrol)
  8157. snd_ctl_remove(dai->component->card->snd_card,
  8158. header_type_kcontrol);
  8159. if (data_format_kcontrol)
  8160. snd_ctl_remove(dai->component->card->snd_card,
  8161. data_format_kcontrol);
  8162. dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
  8163. __func__, dai->name);
  8164. goto rtn;
  8165. }
  8166. }
  8167. if (tdm_dai_data->is_island_dai)
  8168. rc = msm_dai_q6_add_island_mx_ctls(
  8169. dai->component->card->snd_card,
  8170. dai->name,
  8171. dai->id, (void *)tdm_dai_data);
  8172. rc = msm_dai_q6_dai_add_route(dai);
  8173. rtn:
  8174. return rc;
  8175. }
  8176. static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
  8177. {
  8178. int rc = 0;
  8179. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  8180. dev_get_drvdata(dai->dev);
  8181. u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
  8182. int group_idx = 0;
  8183. atomic_t *group_ref = NULL;
  8184. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8185. if (group_idx < 0) {
  8186. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8187. __func__, dai->id);
  8188. return -EINVAL;
  8189. }
  8190. group_ref = &tdm_group_ref[group_idx];
  8191. /* If AFE port is still up, close it */
  8192. if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
  8193. rc = afe_close(dai->id); /* can block */
  8194. if (rc < 0) {
  8195. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  8196. __func__, dai->id);
  8197. }
  8198. atomic_dec(group_ref);
  8199. clear_bit(STATUS_PORT_STARTED,
  8200. tdm_dai_data->status_mask);
  8201. if (atomic_read(group_ref) == 0) {
  8202. rc = afe_port_group_enable(group_id,
  8203. NULL, false, NULL);
  8204. if (rc < 0) {
  8205. dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
  8206. group_id);
  8207. }
  8208. }
  8209. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8210. rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
  8211. dai->id, false);
  8212. if (rc < 0) {
  8213. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  8214. __func__, dai->id);
  8215. }
  8216. }
  8217. }
  8218. return 0;
  8219. }
  8220. static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
  8221. unsigned int tx_mask,
  8222. unsigned int rx_mask,
  8223. int slots, int slot_width)
  8224. {
  8225. int rc = 0;
  8226. struct msm_dai_q6_tdm_dai_data *dai_data =
  8227. dev_get_drvdata(dai->dev);
  8228. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  8229. &dai_data->group_cfg.tdm_cfg;
  8230. unsigned int cap_mask;
  8231. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  8232. /* HW only supports 16 and 32 bit slot width configuration */
  8233. if ((slot_width != 16) && (slot_width != 32)) {
  8234. dev_err(dai->dev, "%s: invalid slot_width %d\n",
  8235. __func__, slot_width);
  8236. return -EINVAL;
  8237. }
  8238. /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
  8239. switch (slots) {
  8240. case 1:
  8241. cap_mask = 0x01;
  8242. break;
  8243. case 2:
  8244. cap_mask = 0x03;
  8245. break;
  8246. case 4:
  8247. cap_mask = 0x0F;
  8248. break;
  8249. case 8:
  8250. cap_mask = 0xFF;
  8251. break;
  8252. case 16:
  8253. cap_mask = 0xFFFF;
  8254. break;
  8255. case 32:
  8256. cap_mask = 0xFFFFFFFF;
  8257. break;
  8258. default:
  8259. dev_err(dai->dev, "%s: invalid slots %d\n",
  8260. __func__, slots);
  8261. return -EINVAL;
  8262. }
  8263. switch (dai->id) {
  8264. case AFE_PORT_ID_PRIMARY_TDM_RX:
  8265. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  8266. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  8267. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  8268. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  8269. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  8270. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  8271. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  8272. case AFE_PORT_ID_SECONDARY_TDM_RX:
  8273. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  8274. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  8275. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  8276. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  8277. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  8278. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  8279. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  8280. case AFE_PORT_ID_TERTIARY_TDM_RX:
  8281. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  8282. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  8283. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  8284. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  8285. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  8286. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  8287. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  8288. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  8289. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  8290. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  8291. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  8292. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  8293. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  8294. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  8295. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  8296. case AFE_PORT_ID_QUINARY_TDM_RX:
  8297. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  8298. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  8299. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  8300. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  8301. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  8302. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  8303. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  8304. case AFE_PORT_ID_SENARY_TDM_RX:
  8305. case AFE_PORT_ID_SENARY_TDM_RX_1:
  8306. case AFE_PORT_ID_SENARY_TDM_RX_2:
  8307. case AFE_PORT_ID_SENARY_TDM_RX_3:
  8308. case AFE_PORT_ID_SENARY_TDM_RX_4:
  8309. case AFE_PORT_ID_SENARY_TDM_RX_5:
  8310. case AFE_PORT_ID_SENARY_TDM_RX_6:
  8311. case AFE_PORT_ID_SENARY_TDM_RX_7:
  8312. tdm_group->nslots_per_frame = slots;
  8313. tdm_group->slot_width = slot_width;
  8314. tdm_group->slot_mask = rx_mask & cap_mask;
  8315. break;
  8316. case AFE_PORT_ID_PRIMARY_TDM_TX:
  8317. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  8318. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  8319. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  8320. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  8321. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  8322. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  8323. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  8324. case AFE_PORT_ID_SECONDARY_TDM_TX:
  8325. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  8326. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  8327. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  8328. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  8329. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  8330. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  8331. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  8332. case AFE_PORT_ID_TERTIARY_TDM_TX:
  8333. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  8334. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  8335. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  8336. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  8337. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  8338. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  8339. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  8340. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  8341. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  8342. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  8343. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  8344. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  8345. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  8346. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  8347. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  8348. case AFE_PORT_ID_QUINARY_TDM_TX:
  8349. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  8350. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  8351. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  8352. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  8353. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  8354. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  8355. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  8356. case AFE_PORT_ID_SENARY_TDM_TX:
  8357. case AFE_PORT_ID_SENARY_TDM_TX_1:
  8358. case AFE_PORT_ID_SENARY_TDM_TX_2:
  8359. case AFE_PORT_ID_SENARY_TDM_TX_3:
  8360. case AFE_PORT_ID_SENARY_TDM_TX_4:
  8361. case AFE_PORT_ID_SENARY_TDM_TX_5:
  8362. case AFE_PORT_ID_SENARY_TDM_TX_6:
  8363. case AFE_PORT_ID_SENARY_TDM_TX_7:
  8364. tdm_group->nslots_per_frame = slots;
  8365. tdm_group->slot_width = slot_width;
  8366. tdm_group->slot_mask = tx_mask & cap_mask;
  8367. break;
  8368. default:
  8369. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8370. __func__, dai->id);
  8371. return -EINVAL;
  8372. }
  8373. return rc;
  8374. }
  8375. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  8376. int clk_id, unsigned int freq, int dir)
  8377. {
  8378. struct msm_dai_q6_tdm_dai_data *dai_data =
  8379. dev_get_drvdata(dai->dev);
  8380. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  8381. (dai->id <= AFE_PORT_ID_SENARY_TDM_TX_7)) {
  8382. dai_data->clk_set.clk_freq_in_hz = freq;
  8383. } else {
  8384. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8385. __func__, dai->id);
  8386. return -EINVAL;
  8387. }
  8388. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  8389. __func__, dai->id, freq);
  8390. return 0;
  8391. }
  8392. static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
  8393. unsigned int tx_num, unsigned int *tx_slot,
  8394. unsigned int rx_num, unsigned int *rx_slot)
  8395. {
  8396. int rc = 0;
  8397. struct msm_dai_q6_tdm_dai_data *dai_data =
  8398. dev_get_drvdata(dai->dev);
  8399. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  8400. &dai_data->port_cfg.slot_mapping;
  8401. struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  8402. &dai_data->port_cfg.slot_mapping_v2;
  8403. int i = 0;
  8404. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  8405. switch (dai->id) {
  8406. case AFE_PORT_ID_PRIMARY_TDM_RX:
  8407. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  8408. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  8409. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  8410. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  8411. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  8412. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  8413. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  8414. case AFE_PORT_ID_SECONDARY_TDM_RX:
  8415. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  8416. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  8417. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  8418. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  8419. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  8420. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  8421. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  8422. case AFE_PORT_ID_TERTIARY_TDM_RX:
  8423. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  8424. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  8425. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  8426. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  8427. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  8428. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  8429. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  8430. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  8431. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  8432. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  8433. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  8434. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  8435. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  8436. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  8437. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  8438. case AFE_PORT_ID_QUINARY_TDM_RX:
  8439. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  8440. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  8441. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  8442. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  8443. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  8444. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  8445. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  8446. case AFE_PORT_ID_SENARY_TDM_RX:
  8447. case AFE_PORT_ID_SENARY_TDM_RX_1:
  8448. case AFE_PORT_ID_SENARY_TDM_RX_2:
  8449. case AFE_PORT_ID_SENARY_TDM_RX_3:
  8450. case AFE_PORT_ID_SENARY_TDM_RX_4:
  8451. case AFE_PORT_ID_SENARY_TDM_RX_5:
  8452. case AFE_PORT_ID_SENARY_TDM_RX_6:
  8453. case AFE_PORT_ID_SENARY_TDM_RX_7:
  8454. if (q6core_get_avcs_api_version_per_service(
  8455. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8456. if (!rx_slot) {
  8457. dev_err(dai->dev, "%s: rx slot not found\n",
  8458. __func__);
  8459. return -EINVAL;
  8460. }
  8461. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT_V2) {
  8462. dev_err(dai->dev, "%s: invalid rx num %d\n",
  8463. __func__,
  8464. rx_num);
  8465. return -EINVAL;
  8466. }
  8467. for (i = 0; i < rx_num; i++)
  8468. slot_mapping_v2->offset[i] = rx_slot[i];
  8469. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  8470. i++)
  8471. slot_mapping_v2->offset[i] =
  8472. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8473. slot_mapping_v2->num_channel = rx_num;
  8474. } else {
  8475. if (!rx_slot) {
  8476. dev_err(dai->dev, "%s: rx slot not found\n",
  8477. __func__);
  8478. return -EINVAL;
  8479. }
  8480. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  8481. dev_err(dai->dev, "%s: invalid rx num %d\n",
  8482. __func__,
  8483. rx_num);
  8484. return -EINVAL;
  8485. }
  8486. for (i = 0; i < rx_num; i++)
  8487. slot_mapping->offset[i] = rx_slot[i];
  8488. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  8489. slot_mapping->offset[i] =
  8490. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8491. slot_mapping->num_channel = rx_num;
  8492. }
  8493. break;
  8494. case AFE_PORT_ID_PRIMARY_TDM_TX:
  8495. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  8496. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  8497. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  8498. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  8499. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  8500. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  8501. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  8502. case AFE_PORT_ID_SECONDARY_TDM_TX:
  8503. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  8504. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  8505. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  8506. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  8507. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  8508. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  8509. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  8510. case AFE_PORT_ID_TERTIARY_TDM_TX:
  8511. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  8512. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  8513. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  8514. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  8515. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  8516. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  8517. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  8518. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  8519. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  8520. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  8521. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  8522. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  8523. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  8524. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  8525. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  8526. case AFE_PORT_ID_QUINARY_TDM_TX:
  8527. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  8528. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  8529. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  8530. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  8531. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  8532. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  8533. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  8534. case AFE_PORT_ID_SENARY_TDM_TX:
  8535. case AFE_PORT_ID_SENARY_TDM_TX_1:
  8536. case AFE_PORT_ID_SENARY_TDM_TX_2:
  8537. case AFE_PORT_ID_SENARY_TDM_TX_3:
  8538. case AFE_PORT_ID_SENARY_TDM_TX_4:
  8539. case AFE_PORT_ID_SENARY_TDM_TX_5:
  8540. case AFE_PORT_ID_SENARY_TDM_TX_6:
  8541. case AFE_PORT_ID_SENARY_TDM_TX_7:
  8542. if (q6core_get_avcs_api_version_per_service(
  8543. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8544. if (!tx_slot) {
  8545. dev_err(dai->dev, "%s: tx slot not found\n",
  8546. __func__);
  8547. return -EINVAL;
  8548. }
  8549. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT_V2) {
  8550. dev_err(dai->dev, "%s: invalid tx num %d\n",
  8551. __func__,
  8552. tx_num);
  8553. return -EINVAL;
  8554. }
  8555. for (i = 0; i < tx_num; i++)
  8556. slot_mapping_v2->offset[i] = tx_slot[i];
  8557. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT_V2;
  8558. i++)
  8559. slot_mapping_v2->offset[i] =
  8560. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8561. slot_mapping_v2->num_channel = tx_num;
  8562. } else {
  8563. if (!tx_slot) {
  8564. dev_err(dai->dev, "%s: tx slot not found\n",
  8565. __func__);
  8566. return -EINVAL;
  8567. }
  8568. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  8569. dev_err(dai->dev, "%s: invalid tx num %d\n",
  8570. __func__,
  8571. tx_num);
  8572. return -EINVAL;
  8573. }
  8574. for (i = 0; i < tx_num; i++)
  8575. slot_mapping->offset[i] = tx_slot[i];
  8576. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  8577. slot_mapping->offset[i] =
  8578. AFE_SLOT_MAPPING_OFFSET_INVALID;
  8579. slot_mapping->num_channel = tx_num;
  8580. }
  8581. break;
  8582. default:
  8583. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  8584. __func__, dai->id);
  8585. return -EINVAL;
  8586. }
  8587. return rc;
  8588. }
  8589. static unsigned int tdm_param_set_slot_mask(u16 *slot_offset, int slot_width,
  8590. int slots_per_frame)
  8591. {
  8592. unsigned int i = 0;
  8593. unsigned int slot_index = 0;
  8594. unsigned long slot_mask = 0;
  8595. unsigned int slot_width_bytes = slot_width / 8;
  8596. if (slot_width_bytes == 0) {
  8597. pr_err("%s: slot width is zero\n", __func__);
  8598. return slot_mask;
  8599. }
  8600. for (i = 0; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++) {
  8601. if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID) {
  8602. slot_index = slot_offset[i] / slot_width_bytes;
  8603. if (slot_index < slots_per_frame)
  8604. set_bit(slot_index, &slot_mask);
  8605. else {
  8606. pr_err("%s: invalid slot map setting\n",
  8607. __func__);
  8608. return 0;
  8609. }
  8610. } else {
  8611. break;
  8612. }
  8613. }
  8614. return slot_mask;
  8615. }
  8616. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  8617. struct snd_pcm_hw_params *params,
  8618. struct snd_soc_dai *dai)
  8619. {
  8620. struct msm_dai_q6_tdm_dai_data *dai_data =
  8621. dev_get_drvdata(dai->dev);
  8622. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  8623. &dai_data->group_cfg.tdm_cfg;
  8624. struct afe_param_id_tdm_cfg *tdm =
  8625. &dai_data->port_cfg.tdm;
  8626. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  8627. &dai_data->port_cfg.slot_mapping;
  8628. struct afe_param_id_slot_mapping_cfg_v2 *slot_mapping_v2 =
  8629. &dai_data->port_cfg.slot_mapping_v2;
  8630. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  8631. &dai_data->port_cfg.custom_tdm_header;
  8632. pr_debug("%s: dev_name: %s\n",
  8633. __func__, dev_name(dai->dev));
  8634. if ((params_channels(params) == 0) ||
  8635. (params_channels(params) > 32)) {
  8636. dev_err(dai->dev, "%s: invalid param channels %d\n",
  8637. __func__, params_channels(params));
  8638. return -EINVAL;
  8639. }
  8640. switch (params_format(params)) {
  8641. case SNDRV_PCM_FORMAT_S16_LE:
  8642. dai_data->bitwidth = 16;
  8643. break;
  8644. case SNDRV_PCM_FORMAT_S24_LE:
  8645. case SNDRV_PCM_FORMAT_S24_3LE:
  8646. dai_data->bitwidth = 24;
  8647. break;
  8648. case SNDRV_PCM_FORMAT_S32_LE:
  8649. dai_data->bitwidth = 32;
  8650. break;
  8651. default:
  8652. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  8653. __func__, params_format(params));
  8654. return -EINVAL;
  8655. }
  8656. dai_data->channels = params_channels(params);
  8657. dai_data->rate = params_rate(params);
  8658. /*
  8659. * update tdm group config param
  8660. * NOTE: group config is set to the same as slot config.
  8661. */
  8662. tdm_group->bit_width = tdm_group->slot_width;
  8663. /*
  8664. * for multi lane scenario
  8665. * Total number of active channels = number of active lanes * number of active slots.
  8666. */
  8667. if (dai_data->lane_cfg.lane_mask != AFE_LANE_MASK_INVALID)
  8668. tdm_group->num_channels = tdm_group->nslots_per_frame
  8669. * num_of_bits_set(dai_data->lane_cfg.lane_mask);
  8670. else
  8671. tdm_group->num_channels = tdm_group->nslots_per_frame;
  8672. tdm_group->sample_rate = dai_data->rate;
  8673. pr_debug("%s: TDM GROUP:\n"
  8674. "num_channels=%d sample_rate=%d bit_width=%d\n"
  8675. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  8676. __func__,
  8677. tdm_group->num_channels,
  8678. tdm_group->sample_rate,
  8679. tdm_group->bit_width,
  8680. tdm_group->nslots_per_frame,
  8681. tdm_group->slot_width,
  8682. tdm_group->slot_mask);
  8683. pr_debug("%s: TDM GROUP:\n"
  8684. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  8685. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  8686. __func__,
  8687. tdm_group->port_id[0],
  8688. tdm_group->port_id[1],
  8689. tdm_group->port_id[2],
  8690. tdm_group->port_id[3],
  8691. tdm_group->port_id[4],
  8692. tdm_group->port_id[5],
  8693. tdm_group->port_id[6],
  8694. tdm_group->port_id[7]);
  8695. pr_debug("%s: TDM GROUP ID 0x%x lane mask 0x%x:\n",
  8696. __func__,
  8697. tdm_group->group_id,
  8698. dai_data->lane_cfg.lane_mask);
  8699. /*
  8700. * update tdm config param
  8701. * NOTE: channels/rate/bitwidth are per stream property
  8702. */
  8703. tdm->num_channels = dai_data->channels;
  8704. tdm->sample_rate = dai_data->rate;
  8705. tdm->bit_width = dai_data->bitwidth;
  8706. /*
  8707. * port slot config is the same as group slot config
  8708. * port slot mask should be set according to offset
  8709. */
  8710. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  8711. tdm->slot_width = tdm_group->slot_width;
  8712. tdm->slot_mask = tdm_param_set_slot_mask(slot_mapping->offset,
  8713. tdm_group->slot_width,
  8714. tdm_group->nslots_per_frame);
  8715. pr_debug("%s: TDM:\n"
  8716. "num_channels=%d sample_rate=%d bit_width=%d\n"
  8717. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  8718. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  8719. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  8720. __func__,
  8721. tdm->num_channels,
  8722. tdm->sample_rate,
  8723. tdm->bit_width,
  8724. tdm->nslots_per_frame,
  8725. tdm->slot_width,
  8726. tdm->slot_mask,
  8727. tdm->data_format,
  8728. tdm->sync_mode,
  8729. tdm->sync_src,
  8730. tdm->ctrl_data_out_enable,
  8731. tdm->ctrl_invert_sync_pulse,
  8732. tdm->ctrl_sync_data_delay);
  8733. if (q6core_get_avcs_api_version_per_service(
  8734. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V3) {
  8735. /*
  8736. * update slot mapping v2 config param
  8737. * NOTE: channels/rate/bitwidth are per stream property
  8738. */
  8739. slot_mapping_v2->bitwidth = dai_data->bitwidth;
  8740. pr_debug("%s: SLOT MAPPING_V2:\n"
  8741. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  8742. __func__,
  8743. slot_mapping_v2->num_channel,
  8744. slot_mapping_v2->bitwidth,
  8745. slot_mapping_v2->data_align_type);
  8746. pr_debug("%s: SLOT MAPPING V2:\n"
  8747. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  8748. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n"
  8749. "offset[8]=0x%x offset[9]=0x%x offset[10]=0x%x offset[11]=0x%x\n"
  8750. "offset[12]=0x%x offset[13]=0x%x offset[14]=0x%x offset[15]=0x%x\n"
  8751. "offset[16]=0x%x offset[17]=0x%x offset[18]=0x%x offset[19]=0x%x\n"
  8752. "offset[20]=0x%x offset[21]=0x%x offset[22]=0x%x offset[23]=0x%x\n"
  8753. "offset[24]=0x%x offset[25]=0x%x offset[26]=0x%x offset[27]=0x%x\n"
  8754. "offset[28]=0x%x offset[29]=0x%x offset[30]=0x%x offset[31]=0x%x\n",
  8755. __func__,
  8756. slot_mapping_v2->offset[0],
  8757. slot_mapping_v2->offset[1],
  8758. slot_mapping_v2->offset[2],
  8759. slot_mapping_v2->offset[3],
  8760. slot_mapping_v2->offset[4],
  8761. slot_mapping_v2->offset[5],
  8762. slot_mapping_v2->offset[6],
  8763. slot_mapping_v2->offset[7],
  8764. slot_mapping_v2->offset[8],
  8765. slot_mapping_v2->offset[9],
  8766. slot_mapping_v2->offset[10],
  8767. slot_mapping_v2->offset[11],
  8768. slot_mapping_v2->offset[12],
  8769. slot_mapping_v2->offset[13],
  8770. slot_mapping_v2->offset[14],
  8771. slot_mapping_v2->offset[15],
  8772. slot_mapping_v2->offset[16],
  8773. slot_mapping_v2->offset[17],
  8774. slot_mapping_v2->offset[18],
  8775. slot_mapping_v2->offset[19],
  8776. slot_mapping_v2->offset[20],
  8777. slot_mapping_v2->offset[21],
  8778. slot_mapping_v2->offset[22],
  8779. slot_mapping_v2->offset[23],
  8780. slot_mapping_v2->offset[24],
  8781. slot_mapping_v2->offset[25],
  8782. slot_mapping_v2->offset[26],
  8783. slot_mapping_v2->offset[27],
  8784. slot_mapping_v2->offset[28],
  8785. slot_mapping_v2->offset[29],
  8786. slot_mapping_v2->offset[30],
  8787. slot_mapping_v2->offset[31]);
  8788. } else {
  8789. /*
  8790. * update slot mapping config param
  8791. * NOTE: channels/rate/bitwidth are per stream property
  8792. */
  8793. slot_mapping->bitwidth = dai_data->bitwidth;
  8794. pr_debug("%s: SLOT MAPPING:\n"
  8795. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  8796. __func__,
  8797. slot_mapping->num_channel,
  8798. slot_mapping->bitwidth,
  8799. slot_mapping->data_align_type);
  8800. pr_debug("%s: SLOT MAPPING:\n"
  8801. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  8802. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  8803. __func__,
  8804. slot_mapping->offset[0],
  8805. slot_mapping->offset[1],
  8806. slot_mapping->offset[2],
  8807. slot_mapping->offset[3],
  8808. slot_mapping->offset[4],
  8809. slot_mapping->offset[5],
  8810. slot_mapping->offset[6],
  8811. slot_mapping->offset[7]);
  8812. }
  8813. /*
  8814. * update custom header config param
  8815. * NOTE: channels/rate/bitwidth are per playback stream property.
  8816. * custom tdm header only applicable to playback stream.
  8817. */
  8818. if (custom_tdm_header->header_type !=
  8819. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  8820. pr_debug("%s: CUSTOM TDM HEADER:\n"
  8821. "start_offset=0x%x header_width=%d\n"
  8822. "num_frame_repeat=%d header_type=0x%x\n",
  8823. __func__,
  8824. custom_tdm_header->start_offset,
  8825. custom_tdm_header->header_width,
  8826. custom_tdm_header->num_frame_repeat,
  8827. custom_tdm_header->header_type);
  8828. pr_debug("%s: CUSTOM TDM HEADER:\n"
  8829. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  8830. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  8831. __func__,
  8832. custom_tdm_header->header[0],
  8833. custom_tdm_header->header[1],
  8834. custom_tdm_header->header[2],
  8835. custom_tdm_header->header[3],
  8836. custom_tdm_header->header[4],
  8837. custom_tdm_header->header[5],
  8838. custom_tdm_header->header[6],
  8839. custom_tdm_header->header[7]);
  8840. }
  8841. return 0;
  8842. }
  8843. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  8844. struct snd_soc_dai *dai)
  8845. {
  8846. int rc = 0;
  8847. struct msm_dai_q6_tdm_dai_data *dai_data =
  8848. dev_get_drvdata(dai->dev);
  8849. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  8850. int group_idx = 0;
  8851. atomic_t *group_ref = NULL;
  8852. dev_dbg(dai->dev, "%s: dev_name: %s dev_id: 0x%x group_id: 0x%x\n",
  8853. __func__, dev_name(dai->dev), dai->dev->id, group_id);
  8854. if (dai_data->port_cfg.custom_tdm_header.minor_version == 0)
  8855. dev_dbg(dai->dev,
  8856. "%s: Custom tdm header not supported\n", __func__);
  8857. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8858. if (group_idx < 0) {
  8859. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8860. __func__, dai->id);
  8861. return -EINVAL;
  8862. }
  8863. mutex_lock(&tdm_mutex);
  8864. group_ref = &tdm_group_ref[group_idx];
  8865. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  8866. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8867. /* TX and RX share the same clk. So enable the clk
  8868. * per TDM interface. */
  8869. rc = msm_dai_q6_tdm_set_clk(dai_data,
  8870. dai->id, true);
  8871. if (rc < 0) {
  8872. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  8873. __func__, dai->id);
  8874. goto rtn;
  8875. }
  8876. }
  8877. /* PORT START should be set if prepare called
  8878. * in active state.
  8879. */
  8880. if (atomic_read(group_ref) == 0) {
  8881. /*
  8882. * if only one port, don't do group enable as there
  8883. * is no group need for only one port
  8884. */
  8885. if (dai_data->num_group_ports > 1) {
  8886. rc = afe_port_group_enable(group_id,
  8887. &dai_data->group_cfg, true,
  8888. &dai_data->lane_cfg);
  8889. if (rc < 0) {
  8890. dev_err(dai->dev,
  8891. "%s: fail to enable AFE group 0x%x\n",
  8892. __func__, group_id);
  8893. goto rtn;
  8894. }
  8895. }
  8896. }
  8897. rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
  8898. dai_data->rate, dai_data->num_group_ports);
  8899. if (rc < 0) {
  8900. if (atomic_read(group_ref) == 0) {
  8901. afe_port_group_enable(group_id,
  8902. NULL, false, NULL);
  8903. }
  8904. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8905. msm_dai_q6_tdm_set_clk(dai_data,
  8906. dai->id, false);
  8907. }
  8908. dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
  8909. __func__, dai->id);
  8910. } else {
  8911. set_bit(STATUS_PORT_STARTED,
  8912. dai_data->status_mask);
  8913. atomic_inc(group_ref);
  8914. }
  8915. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  8916. /* NOTE: AFE should error out if HW resource contention */
  8917. }
  8918. rtn:
  8919. mutex_unlock(&tdm_mutex);
  8920. return rc;
  8921. }
  8922. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  8923. struct snd_soc_dai *dai)
  8924. {
  8925. int rc = 0;
  8926. struct msm_dai_q6_tdm_dai_data *dai_data =
  8927. dev_get_drvdata(dai->dev);
  8928. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  8929. int group_idx = 0;
  8930. atomic_t *group_ref = NULL;
  8931. group_idx = msm_dai_q6_get_group_idx(dai->id);
  8932. if (group_idx < 0) {
  8933. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  8934. __func__, dai->id);
  8935. return;
  8936. }
  8937. mutex_lock(&tdm_mutex);
  8938. group_ref = &tdm_group_ref[group_idx];
  8939. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  8940. rc = afe_close(dai->id);
  8941. if (rc < 0) {
  8942. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  8943. __func__, dai->id);
  8944. }
  8945. atomic_dec(group_ref);
  8946. clear_bit(STATUS_PORT_STARTED,
  8947. dai_data->status_mask);
  8948. if (atomic_read(group_ref) == 0) {
  8949. rc = afe_port_group_enable(group_id,
  8950. NULL, false, NULL);
  8951. if (rc < 0) {
  8952. dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
  8953. __func__, group_id);
  8954. }
  8955. }
  8956. if (msm_dai_q6_get_tdm_clk_ref(group_idx) == 0) {
  8957. rc = msm_dai_q6_tdm_set_clk(dai_data,
  8958. dai->id, false);
  8959. if (rc < 0) {
  8960. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  8961. __func__, dai->id);
  8962. }
  8963. }
  8964. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  8965. /* NOTE: AFE should error out if HW resource contention */
  8966. }
  8967. mutex_unlock(&tdm_mutex);
  8968. }
  8969. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  8970. .prepare = msm_dai_q6_tdm_prepare,
  8971. .hw_params = msm_dai_q6_tdm_hw_params,
  8972. .set_tdm_slot = msm_dai_q6_tdm_set_tdm_slot,
  8973. .set_channel_map = msm_dai_q6_tdm_set_channel_map,
  8974. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  8975. .shutdown = msm_dai_q6_tdm_shutdown,
  8976. };
  8977. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  8978. {
  8979. .playback = {
  8980. .stream_name = "Primary TDM0 Playback",
  8981. .aif_name = "PRI_TDM_RX_0",
  8982. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8983. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8984. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8985. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8986. SNDRV_PCM_FMTBIT_S24_LE |
  8987. SNDRV_PCM_FMTBIT_S32_LE,
  8988. .channels_min = 1,
  8989. .channels_max = 16,
  8990. .rate_min = 8000,
  8991. .rate_max = 352800,
  8992. },
  8993. .name = "PRI_TDM_RX_0",
  8994. .ops = &msm_dai_q6_tdm_ops,
  8995. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  8996. .probe = msm_dai_q6_dai_tdm_probe,
  8997. .remove = msm_dai_q6_dai_tdm_remove,
  8998. },
  8999. {
  9000. .playback = {
  9001. .stream_name = "Primary TDM1 Playback",
  9002. .aif_name = "PRI_TDM_RX_1",
  9003. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9004. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9005. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9006. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9007. SNDRV_PCM_FMTBIT_S24_LE |
  9008. SNDRV_PCM_FMTBIT_S32_LE,
  9009. .channels_min = 1,
  9010. .channels_max = 16,
  9011. .rate_min = 8000,
  9012. .rate_max = 352800,
  9013. },
  9014. .name = "PRI_TDM_RX_1",
  9015. .ops = &msm_dai_q6_tdm_ops,
  9016. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  9017. .probe = msm_dai_q6_dai_tdm_probe,
  9018. .remove = msm_dai_q6_dai_tdm_remove,
  9019. },
  9020. {
  9021. .playback = {
  9022. .stream_name = "Primary TDM2 Playback",
  9023. .aif_name = "PRI_TDM_RX_2",
  9024. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9025. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9026. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9027. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9028. SNDRV_PCM_FMTBIT_S24_LE |
  9029. SNDRV_PCM_FMTBIT_S32_LE,
  9030. .channels_min = 1,
  9031. .channels_max = 16,
  9032. .rate_min = 8000,
  9033. .rate_max = 352800,
  9034. },
  9035. .name = "PRI_TDM_RX_2",
  9036. .ops = &msm_dai_q6_tdm_ops,
  9037. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  9038. .probe = msm_dai_q6_dai_tdm_probe,
  9039. .remove = msm_dai_q6_dai_tdm_remove,
  9040. },
  9041. {
  9042. .playback = {
  9043. .stream_name = "Primary TDM3 Playback",
  9044. .aif_name = "PRI_TDM_RX_3",
  9045. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9046. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9047. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9048. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9049. SNDRV_PCM_FMTBIT_S24_LE |
  9050. SNDRV_PCM_FMTBIT_S32_LE,
  9051. .channels_min = 1,
  9052. .channels_max = 16,
  9053. .rate_min = 8000,
  9054. .rate_max = 352800,
  9055. },
  9056. .name = "PRI_TDM_RX_3",
  9057. .ops = &msm_dai_q6_tdm_ops,
  9058. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  9059. .probe = msm_dai_q6_dai_tdm_probe,
  9060. .remove = msm_dai_q6_dai_tdm_remove,
  9061. },
  9062. {
  9063. .playback = {
  9064. .stream_name = "Primary TDM4 Playback",
  9065. .aif_name = "PRI_TDM_RX_4",
  9066. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9067. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9068. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9069. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9070. SNDRV_PCM_FMTBIT_S24_LE |
  9071. SNDRV_PCM_FMTBIT_S32_LE,
  9072. .channels_min = 1,
  9073. .channels_max = 16,
  9074. .rate_min = 8000,
  9075. .rate_max = 352800,
  9076. },
  9077. .name = "PRI_TDM_RX_4",
  9078. .ops = &msm_dai_q6_tdm_ops,
  9079. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  9080. .probe = msm_dai_q6_dai_tdm_probe,
  9081. .remove = msm_dai_q6_dai_tdm_remove,
  9082. },
  9083. {
  9084. .playback = {
  9085. .stream_name = "Primary TDM5 Playback",
  9086. .aif_name = "PRI_TDM_RX_5",
  9087. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9088. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9089. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9090. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9091. SNDRV_PCM_FMTBIT_S24_LE |
  9092. SNDRV_PCM_FMTBIT_S32_LE,
  9093. .channels_min = 1,
  9094. .channels_max = 16,
  9095. .rate_min = 8000,
  9096. .rate_max = 352800,
  9097. },
  9098. .name = "PRI_TDM_RX_5",
  9099. .ops = &msm_dai_q6_tdm_ops,
  9100. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  9101. .probe = msm_dai_q6_dai_tdm_probe,
  9102. .remove = msm_dai_q6_dai_tdm_remove,
  9103. },
  9104. {
  9105. .playback = {
  9106. .stream_name = "Primary TDM6 Playback",
  9107. .aif_name = "PRI_TDM_RX_6",
  9108. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9109. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9110. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9111. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9112. SNDRV_PCM_FMTBIT_S24_LE |
  9113. SNDRV_PCM_FMTBIT_S32_LE,
  9114. .channels_min = 1,
  9115. .channels_max = 16,
  9116. .rate_min = 8000,
  9117. .rate_max = 352800,
  9118. },
  9119. .name = "PRI_TDM_RX_6",
  9120. .ops = &msm_dai_q6_tdm_ops,
  9121. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  9122. .probe = msm_dai_q6_dai_tdm_probe,
  9123. .remove = msm_dai_q6_dai_tdm_remove,
  9124. },
  9125. {
  9126. .playback = {
  9127. .stream_name = "Primary TDM7 Playback",
  9128. .aif_name = "PRI_TDM_RX_7",
  9129. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9130. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9131. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9132. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9133. SNDRV_PCM_FMTBIT_S24_LE |
  9134. SNDRV_PCM_FMTBIT_S32_LE,
  9135. .channels_min = 1,
  9136. .channels_max = 16,
  9137. .rate_min = 8000,
  9138. .rate_max = 352800,
  9139. },
  9140. .name = "PRI_TDM_RX_7",
  9141. .ops = &msm_dai_q6_tdm_ops,
  9142. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  9143. .probe = msm_dai_q6_dai_tdm_probe,
  9144. .remove = msm_dai_q6_dai_tdm_remove,
  9145. },
  9146. {
  9147. .capture = {
  9148. .stream_name = "Primary TDM0 Capture",
  9149. .aif_name = "PRI_TDM_TX_0",
  9150. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9151. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9152. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9153. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9154. SNDRV_PCM_FMTBIT_S24_LE |
  9155. SNDRV_PCM_FMTBIT_S32_LE,
  9156. .channels_min = 1,
  9157. .channels_max = 16,
  9158. .rate_min = 8000,
  9159. .rate_max = 352800,
  9160. },
  9161. .name = "PRI_TDM_TX_0",
  9162. .ops = &msm_dai_q6_tdm_ops,
  9163. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  9164. .probe = msm_dai_q6_dai_tdm_probe,
  9165. .remove = msm_dai_q6_dai_tdm_remove,
  9166. },
  9167. {
  9168. .capture = {
  9169. .stream_name = "Primary TDM1 Capture",
  9170. .aif_name = "PRI_TDM_TX_1",
  9171. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9172. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9173. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9174. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9175. SNDRV_PCM_FMTBIT_S24_LE |
  9176. SNDRV_PCM_FMTBIT_S32_LE,
  9177. .channels_min = 1,
  9178. .channels_max = 16,
  9179. .rate_min = 8000,
  9180. .rate_max = 352800,
  9181. },
  9182. .name = "PRI_TDM_TX_1",
  9183. .ops = &msm_dai_q6_tdm_ops,
  9184. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  9185. .probe = msm_dai_q6_dai_tdm_probe,
  9186. .remove = msm_dai_q6_dai_tdm_remove,
  9187. },
  9188. {
  9189. .capture = {
  9190. .stream_name = "Primary TDM2 Capture",
  9191. .aif_name = "PRI_TDM_TX_2",
  9192. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9193. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9194. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9195. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9196. SNDRV_PCM_FMTBIT_S24_LE |
  9197. SNDRV_PCM_FMTBIT_S32_LE,
  9198. .channels_min = 1,
  9199. .channels_max = 16,
  9200. .rate_min = 8000,
  9201. .rate_max = 352800,
  9202. },
  9203. .name = "PRI_TDM_TX_2",
  9204. .ops = &msm_dai_q6_tdm_ops,
  9205. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  9206. .probe = msm_dai_q6_dai_tdm_probe,
  9207. .remove = msm_dai_q6_dai_tdm_remove,
  9208. },
  9209. {
  9210. .capture = {
  9211. .stream_name = "Primary TDM3 Capture",
  9212. .aif_name = "PRI_TDM_TX_3",
  9213. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9214. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9215. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9216. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9217. SNDRV_PCM_FMTBIT_S24_LE |
  9218. SNDRV_PCM_FMTBIT_S32_LE,
  9219. .channels_min = 1,
  9220. .channels_max = 16,
  9221. .rate_min = 8000,
  9222. .rate_max = 352800,
  9223. },
  9224. .name = "PRI_TDM_TX_3",
  9225. .ops = &msm_dai_q6_tdm_ops,
  9226. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  9227. .probe = msm_dai_q6_dai_tdm_probe,
  9228. .remove = msm_dai_q6_dai_tdm_remove,
  9229. },
  9230. {
  9231. .capture = {
  9232. .stream_name = "Primary TDM4 Capture",
  9233. .aif_name = "PRI_TDM_TX_4",
  9234. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9235. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9236. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9237. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9238. SNDRV_PCM_FMTBIT_S24_LE |
  9239. SNDRV_PCM_FMTBIT_S32_LE,
  9240. .channels_min = 1,
  9241. .channels_max = 16,
  9242. .rate_min = 8000,
  9243. .rate_max = 352800,
  9244. },
  9245. .name = "PRI_TDM_TX_4",
  9246. .ops = &msm_dai_q6_tdm_ops,
  9247. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  9248. .probe = msm_dai_q6_dai_tdm_probe,
  9249. .remove = msm_dai_q6_dai_tdm_remove,
  9250. },
  9251. {
  9252. .capture = {
  9253. .stream_name = "Primary TDM5 Capture",
  9254. .aif_name = "PRI_TDM_TX_5",
  9255. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9256. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9257. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9258. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9259. SNDRV_PCM_FMTBIT_S24_LE |
  9260. SNDRV_PCM_FMTBIT_S32_LE,
  9261. .channels_min = 1,
  9262. .channels_max = 16,
  9263. .rate_min = 8000,
  9264. .rate_max = 352800,
  9265. },
  9266. .name = "PRI_TDM_TX_5",
  9267. .ops = &msm_dai_q6_tdm_ops,
  9268. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  9269. .probe = msm_dai_q6_dai_tdm_probe,
  9270. .remove = msm_dai_q6_dai_tdm_remove,
  9271. },
  9272. {
  9273. .capture = {
  9274. .stream_name = "Primary TDM6 Capture",
  9275. .aif_name = "PRI_TDM_TX_6",
  9276. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9277. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9278. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9279. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9280. SNDRV_PCM_FMTBIT_S24_LE |
  9281. SNDRV_PCM_FMTBIT_S32_LE,
  9282. .channels_min = 1,
  9283. .channels_max = 16,
  9284. .rate_min = 8000,
  9285. .rate_max = 352800,
  9286. },
  9287. .name = "PRI_TDM_TX_6",
  9288. .ops = &msm_dai_q6_tdm_ops,
  9289. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  9290. .probe = msm_dai_q6_dai_tdm_probe,
  9291. .remove = msm_dai_q6_dai_tdm_remove,
  9292. },
  9293. {
  9294. .capture = {
  9295. .stream_name = "Primary TDM7 Capture",
  9296. .aif_name = "PRI_TDM_TX_7",
  9297. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9298. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9299. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9300. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9301. SNDRV_PCM_FMTBIT_S24_LE |
  9302. SNDRV_PCM_FMTBIT_S32_LE,
  9303. .channels_min = 1,
  9304. .channels_max = 16,
  9305. .rate_min = 8000,
  9306. .rate_max = 352800,
  9307. },
  9308. .name = "PRI_TDM_TX_7",
  9309. .ops = &msm_dai_q6_tdm_ops,
  9310. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  9311. .probe = msm_dai_q6_dai_tdm_probe,
  9312. .remove = msm_dai_q6_dai_tdm_remove,
  9313. },
  9314. {
  9315. .playback = {
  9316. .stream_name = "Secondary TDM0 Playback",
  9317. .aif_name = "SEC_TDM_RX_0",
  9318. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9319. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9320. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9321. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9322. SNDRV_PCM_FMTBIT_S24_LE |
  9323. SNDRV_PCM_FMTBIT_S32_LE,
  9324. .channels_min = 1,
  9325. .channels_max = 16,
  9326. .rate_min = 8000,
  9327. .rate_max = 352800,
  9328. },
  9329. .name = "SEC_TDM_RX_0",
  9330. .ops = &msm_dai_q6_tdm_ops,
  9331. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  9332. .probe = msm_dai_q6_dai_tdm_probe,
  9333. .remove = msm_dai_q6_dai_tdm_remove,
  9334. },
  9335. {
  9336. .playback = {
  9337. .stream_name = "Secondary TDM1 Playback",
  9338. .aif_name = "SEC_TDM_RX_1",
  9339. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9340. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9341. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9342. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9343. SNDRV_PCM_FMTBIT_S24_LE |
  9344. SNDRV_PCM_FMTBIT_S32_LE,
  9345. .channels_min = 1,
  9346. .channels_max = 16,
  9347. .rate_min = 8000,
  9348. .rate_max = 352800,
  9349. },
  9350. .name = "SEC_TDM_RX_1",
  9351. .ops = &msm_dai_q6_tdm_ops,
  9352. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  9353. .probe = msm_dai_q6_dai_tdm_probe,
  9354. .remove = msm_dai_q6_dai_tdm_remove,
  9355. },
  9356. {
  9357. .playback = {
  9358. .stream_name = "Secondary TDM2 Playback",
  9359. .aif_name = "SEC_TDM_RX_2",
  9360. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9361. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9362. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9363. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9364. SNDRV_PCM_FMTBIT_S24_LE |
  9365. SNDRV_PCM_FMTBIT_S32_LE,
  9366. .channels_min = 1,
  9367. .channels_max = 16,
  9368. .rate_min = 8000,
  9369. .rate_max = 352800,
  9370. },
  9371. .name = "SEC_TDM_RX_2",
  9372. .ops = &msm_dai_q6_tdm_ops,
  9373. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  9374. .probe = msm_dai_q6_dai_tdm_probe,
  9375. .remove = msm_dai_q6_dai_tdm_remove,
  9376. },
  9377. {
  9378. .playback = {
  9379. .stream_name = "Secondary TDM3 Playback",
  9380. .aif_name = "SEC_TDM_RX_3",
  9381. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9382. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9383. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9384. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9385. SNDRV_PCM_FMTBIT_S24_LE |
  9386. SNDRV_PCM_FMTBIT_S32_LE,
  9387. .channels_min = 1,
  9388. .channels_max = 16,
  9389. .rate_min = 8000,
  9390. .rate_max = 352800,
  9391. },
  9392. .name = "SEC_TDM_RX_3",
  9393. .ops = &msm_dai_q6_tdm_ops,
  9394. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  9395. .probe = msm_dai_q6_dai_tdm_probe,
  9396. .remove = msm_dai_q6_dai_tdm_remove,
  9397. },
  9398. {
  9399. .playback = {
  9400. .stream_name = "Secondary TDM4 Playback",
  9401. .aif_name = "SEC_TDM_RX_4",
  9402. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9403. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9404. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9405. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9406. SNDRV_PCM_FMTBIT_S24_LE |
  9407. SNDRV_PCM_FMTBIT_S32_LE,
  9408. .channels_min = 1,
  9409. .channels_max = 16,
  9410. .rate_min = 8000,
  9411. .rate_max = 352800,
  9412. },
  9413. .name = "SEC_TDM_RX_4",
  9414. .ops = &msm_dai_q6_tdm_ops,
  9415. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  9416. .probe = msm_dai_q6_dai_tdm_probe,
  9417. .remove = msm_dai_q6_dai_tdm_remove,
  9418. },
  9419. {
  9420. .playback = {
  9421. .stream_name = "Secondary TDM5 Playback",
  9422. .aif_name = "SEC_TDM_RX_5",
  9423. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9424. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9425. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9426. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9427. SNDRV_PCM_FMTBIT_S24_LE |
  9428. SNDRV_PCM_FMTBIT_S32_LE,
  9429. .channels_min = 1,
  9430. .channels_max = 16,
  9431. .rate_min = 8000,
  9432. .rate_max = 352800,
  9433. },
  9434. .name = "SEC_TDM_RX_5",
  9435. .ops = &msm_dai_q6_tdm_ops,
  9436. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  9437. .probe = msm_dai_q6_dai_tdm_probe,
  9438. .remove = msm_dai_q6_dai_tdm_remove,
  9439. },
  9440. {
  9441. .playback = {
  9442. .stream_name = "Secondary TDM6 Playback",
  9443. .aif_name = "SEC_TDM_RX_6",
  9444. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9445. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9446. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9447. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9448. SNDRV_PCM_FMTBIT_S24_LE |
  9449. SNDRV_PCM_FMTBIT_S32_LE,
  9450. .channels_min = 1,
  9451. .channels_max = 16,
  9452. .rate_min = 8000,
  9453. .rate_max = 352800,
  9454. },
  9455. .name = "SEC_TDM_RX_6",
  9456. .ops = &msm_dai_q6_tdm_ops,
  9457. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  9458. .probe = msm_dai_q6_dai_tdm_probe,
  9459. .remove = msm_dai_q6_dai_tdm_remove,
  9460. },
  9461. {
  9462. .playback = {
  9463. .stream_name = "Secondary TDM7 Playback",
  9464. .aif_name = "SEC_TDM_RX_7",
  9465. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9466. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9467. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9468. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9469. SNDRV_PCM_FMTBIT_S24_LE |
  9470. SNDRV_PCM_FMTBIT_S32_LE,
  9471. .channels_min = 1,
  9472. .channels_max = 16,
  9473. .rate_min = 8000,
  9474. .rate_max = 352800,
  9475. },
  9476. .name = "SEC_TDM_RX_7",
  9477. .ops = &msm_dai_q6_tdm_ops,
  9478. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  9479. .probe = msm_dai_q6_dai_tdm_probe,
  9480. .remove = msm_dai_q6_dai_tdm_remove,
  9481. },
  9482. {
  9483. .capture = {
  9484. .stream_name = "Secondary TDM0 Capture",
  9485. .aif_name = "SEC_TDM_TX_0",
  9486. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9487. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9488. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9489. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9490. SNDRV_PCM_FMTBIT_S24_LE |
  9491. SNDRV_PCM_FMTBIT_S32_LE,
  9492. .channels_min = 1,
  9493. .channels_max = 16,
  9494. .rate_min = 8000,
  9495. .rate_max = 352800,
  9496. },
  9497. .name = "SEC_TDM_TX_0",
  9498. .ops = &msm_dai_q6_tdm_ops,
  9499. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  9500. .probe = msm_dai_q6_dai_tdm_probe,
  9501. .remove = msm_dai_q6_dai_tdm_remove,
  9502. },
  9503. {
  9504. .capture = {
  9505. .stream_name = "Secondary TDM1 Capture",
  9506. .aif_name = "SEC_TDM_TX_1",
  9507. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9508. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9509. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9510. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9511. SNDRV_PCM_FMTBIT_S24_LE |
  9512. SNDRV_PCM_FMTBIT_S32_LE,
  9513. .channels_min = 1,
  9514. .channels_max = 16,
  9515. .rate_min = 8000,
  9516. .rate_max = 352800,
  9517. },
  9518. .name = "SEC_TDM_TX_1",
  9519. .ops = &msm_dai_q6_tdm_ops,
  9520. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  9521. .probe = msm_dai_q6_dai_tdm_probe,
  9522. .remove = msm_dai_q6_dai_tdm_remove,
  9523. },
  9524. {
  9525. .capture = {
  9526. .stream_name = "Secondary TDM2 Capture",
  9527. .aif_name = "SEC_TDM_TX_2",
  9528. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9529. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9530. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9531. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9532. SNDRV_PCM_FMTBIT_S24_LE |
  9533. SNDRV_PCM_FMTBIT_S32_LE,
  9534. .channels_min = 1,
  9535. .channels_max = 16,
  9536. .rate_min = 8000,
  9537. .rate_max = 352800,
  9538. },
  9539. .name = "SEC_TDM_TX_2",
  9540. .ops = &msm_dai_q6_tdm_ops,
  9541. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  9542. .probe = msm_dai_q6_dai_tdm_probe,
  9543. .remove = msm_dai_q6_dai_tdm_remove,
  9544. },
  9545. {
  9546. .capture = {
  9547. .stream_name = "Secondary TDM3 Capture",
  9548. .aif_name = "SEC_TDM_TX_3",
  9549. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9550. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9551. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9552. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9553. SNDRV_PCM_FMTBIT_S24_LE |
  9554. SNDRV_PCM_FMTBIT_S32_LE,
  9555. .channels_min = 1,
  9556. .channels_max = 16,
  9557. .rate_min = 8000,
  9558. .rate_max = 352800,
  9559. },
  9560. .name = "SEC_TDM_TX_3",
  9561. .ops = &msm_dai_q6_tdm_ops,
  9562. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  9563. .probe = msm_dai_q6_dai_tdm_probe,
  9564. .remove = msm_dai_q6_dai_tdm_remove,
  9565. },
  9566. {
  9567. .capture = {
  9568. .stream_name = "Secondary TDM4 Capture",
  9569. .aif_name = "SEC_TDM_TX_4",
  9570. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9571. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9572. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9573. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9574. SNDRV_PCM_FMTBIT_S24_LE |
  9575. SNDRV_PCM_FMTBIT_S32_LE,
  9576. .channels_min = 1,
  9577. .channels_max = 16,
  9578. .rate_min = 8000,
  9579. .rate_max = 352800,
  9580. },
  9581. .name = "SEC_TDM_TX_4",
  9582. .ops = &msm_dai_q6_tdm_ops,
  9583. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  9584. .probe = msm_dai_q6_dai_tdm_probe,
  9585. .remove = msm_dai_q6_dai_tdm_remove,
  9586. },
  9587. {
  9588. .capture = {
  9589. .stream_name = "Secondary TDM5 Capture",
  9590. .aif_name = "SEC_TDM_TX_5",
  9591. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9592. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9593. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9594. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9595. SNDRV_PCM_FMTBIT_S24_LE |
  9596. SNDRV_PCM_FMTBIT_S32_LE,
  9597. .channels_min = 1,
  9598. .channels_max = 16,
  9599. .rate_min = 8000,
  9600. .rate_max = 352800,
  9601. },
  9602. .name = "SEC_TDM_TX_5",
  9603. .ops = &msm_dai_q6_tdm_ops,
  9604. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  9605. .probe = msm_dai_q6_dai_tdm_probe,
  9606. .remove = msm_dai_q6_dai_tdm_remove,
  9607. },
  9608. {
  9609. .capture = {
  9610. .stream_name = "Secondary TDM6 Capture",
  9611. .aif_name = "SEC_TDM_TX_6",
  9612. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9613. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9614. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9615. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9616. SNDRV_PCM_FMTBIT_S24_LE |
  9617. SNDRV_PCM_FMTBIT_S32_LE,
  9618. .channels_min = 1,
  9619. .channels_max = 16,
  9620. .rate_min = 8000,
  9621. .rate_max = 352800,
  9622. },
  9623. .name = "SEC_TDM_TX_6",
  9624. .ops = &msm_dai_q6_tdm_ops,
  9625. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  9626. .probe = msm_dai_q6_dai_tdm_probe,
  9627. .remove = msm_dai_q6_dai_tdm_remove,
  9628. },
  9629. {
  9630. .capture = {
  9631. .stream_name = "Secondary TDM7 Capture",
  9632. .aif_name = "SEC_TDM_TX_7",
  9633. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9634. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9635. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9636. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9637. SNDRV_PCM_FMTBIT_S24_LE |
  9638. SNDRV_PCM_FMTBIT_S32_LE,
  9639. .channels_min = 1,
  9640. .channels_max = 16,
  9641. .rate_min = 8000,
  9642. .rate_max = 352800,
  9643. },
  9644. .name = "SEC_TDM_TX_7",
  9645. .ops = &msm_dai_q6_tdm_ops,
  9646. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  9647. .probe = msm_dai_q6_dai_tdm_probe,
  9648. .remove = msm_dai_q6_dai_tdm_remove,
  9649. },
  9650. {
  9651. .playback = {
  9652. .stream_name = "Tertiary TDM0 Playback",
  9653. .aif_name = "TERT_TDM_RX_0",
  9654. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9655. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9656. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9657. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9658. SNDRV_PCM_FMTBIT_S24_LE |
  9659. SNDRV_PCM_FMTBIT_S32_LE,
  9660. .channels_min = 1,
  9661. .channels_max = 16,
  9662. .rate_min = 8000,
  9663. .rate_max = 352800,
  9664. },
  9665. .name = "TERT_TDM_RX_0",
  9666. .ops = &msm_dai_q6_tdm_ops,
  9667. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  9668. .probe = msm_dai_q6_dai_tdm_probe,
  9669. .remove = msm_dai_q6_dai_tdm_remove,
  9670. },
  9671. {
  9672. .playback = {
  9673. .stream_name = "Tertiary TDM1 Playback",
  9674. .aif_name = "TERT_TDM_RX_1",
  9675. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9676. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9677. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9678. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9679. SNDRV_PCM_FMTBIT_S24_LE |
  9680. SNDRV_PCM_FMTBIT_S32_LE,
  9681. .channels_min = 1,
  9682. .channels_max = 16,
  9683. .rate_min = 8000,
  9684. .rate_max = 352800,
  9685. },
  9686. .name = "TERT_TDM_RX_1",
  9687. .ops = &msm_dai_q6_tdm_ops,
  9688. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  9689. .probe = msm_dai_q6_dai_tdm_probe,
  9690. .remove = msm_dai_q6_dai_tdm_remove,
  9691. },
  9692. {
  9693. .playback = {
  9694. .stream_name = "Tertiary TDM2 Playback",
  9695. .aif_name = "TERT_TDM_RX_2",
  9696. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9697. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9698. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9699. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9700. SNDRV_PCM_FMTBIT_S24_LE |
  9701. SNDRV_PCM_FMTBIT_S32_LE,
  9702. .channels_min = 1,
  9703. .channels_max = 16,
  9704. .rate_min = 8000,
  9705. .rate_max = 352800,
  9706. },
  9707. .name = "TERT_TDM_RX_2",
  9708. .ops = &msm_dai_q6_tdm_ops,
  9709. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  9710. .probe = msm_dai_q6_dai_tdm_probe,
  9711. .remove = msm_dai_q6_dai_tdm_remove,
  9712. },
  9713. {
  9714. .playback = {
  9715. .stream_name = "Tertiary TDM3 Playback",
  9716. .aif_name = "TERT_TDM_RX_3",
  9717. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9718. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9719. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9720. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9721. SNDRV_PCM_FMTBIT_S24_LE |
  9722. SNDRV_PCM_FMTBIT_S32_LE,
  9723. .channels_min = 1,
  9724. .channels_max = 16,
  9725. .rate_min = 8000,
  9726. .rate_max = 352800,
  9727. },
  9728. .name = "TERT_TDM_RX_3",
  9729. .ops = &msm_dai_q6_tdm_ops,
  9730. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  9731. .probe = msm_dai_q6_dai_tdm_probe,
  9732. .remove = msm_dai_q6_dai_tdm_remove,
  9733. },
  9734. {
  9735. .playback = {
  9736. .stream_name = "Tertiary TDM4 Playback",
  9737. .aif_name = "TERT_TDM_RX_4",
  9738. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9739. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9740. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9741. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9742. SNDRV_PCM_FMTBIT_S24_LE |
  9743. SNDRV_PCM_FMTBIT_S32_LE,
  9744. .channels_min = 1,
  9745. .channels_max = 16,
  9746. .rate_min = 8000,
  9747. .rate_max = 352800,
  9748. },
  9749. .name = "TERT_TDM_RX_4",
  9750. .ops = &msm_dai_q6_tdm_ops,
  9751. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  9752. .probe = msm_dai_q6_dai_tdm_probe,
  9753. .remove = msm_dai_q6_dai_tdm_remove,
  9754. },
  9755. {
  9756. .playback = {
  9757. .stream_name = "Tertiary TDM5 Playback",
  9758. .aif_name = "TERT_TDM_RX_5",
  9759. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9760. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9761. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9762. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9763. SNDRV_PCM_FMTBIT_S24_LE |
  9764. SNDRV_PCM_FMTBIT_S32_LE,
  9765. .channels_min = 1,
  9766. .channels_max = 16,
  9767. .rate_min = 8000,
  9768. .rate_max = 352800,
  9769. },
  9770. .name = "TERT_TDM_RX_5",
  9771. .ops = &msm_dai_q6_tdm_ops,
  9772. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  9773. .probe = msm_dai_q6_dai_tdm_probe,
  9774. .remove = msm_dai_q6_dai_tdm_remove,
  9775. },
  9776. {
  9777. .playback = {
  9778. .stream_name = "Tertiary TDM6 Playback",
  9779. .aif_name = "TERT_TDM_RX_6",
  9780. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9781. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9782. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9783. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9784. SNDRV_PCM_FMTBIT_S24_LE |
  9785. SNDRV_PCM_FMTBIT_S32_LE,
  9786. .channels_min = 1,
  9787. .channels_max = 16,
  9788. .rate_min = 8000,
  9789. .rate_max = 352800,
  9790. },
  9791. .name = "TERT_TDM_RX_6",
  9792. .ops = &msm_dai_q6_tdm_ops,
  9793. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  9794. .probe = msm_dai_q6_dai_tdm_probe,
  9795. .remove = msm_dai_q6_dai_tdm_remove,
  9796. },
  9797. {
  9798. .playback = {
  9799. .stream_name = "Tertiary TDM7 Playback",
  9800. .aif_name = "TERT_TDM_RX_7",
  9801. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9802. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9803. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9804. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9805. SNDRV_PCM_FMTBIT_S24_LE |
  9806. SNDRV_PCM_FMTBIT_S32_LE,
  9807. .channels_min = 1,
  9808. .channels_max = 16,
  9809. .rate_min = 8000,
  9810. .rate_max = 352800,
  9811. },
  9812. .name = "TERT_TDM_RX_7",
  9813. .ops = &msm_dai_q6_tdm_ops,
  9814. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  9815. .probe = msm_dai_q6_dai_tdm_probe,
  9816. .remove = msm_dai_q6_dai_tdm_remove,
  9817. },
  9818. {
  9819. .capture = {
  9820. .stream_name = "Tertiary TDM0 Capture",
  9821. .aif_name = "TERT_TDM_TX_0",
  9822. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9823. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9824. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9825. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9826. SNDRV_PCM_FMTBIT_S24_LE |
  9827. SNDRV_PCM_FMTBIT_S32_LE,
  9828. .channels_min = 1,
  9829. .channels_max = 16,
  9830. .rate_min = 8000,
  9831. .rate_max = 352800,
  9832. },
  9833. .name = "TERT_TDM_TX_0",
  9834. .ops = &msm_dai_q6_tdm_ops,
  9835. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  9836. .probe = msm_dai_q6_dai_tdm_probe,
  9837. .remove = msm_dai_q6_dai_tdm_remove,
  9838. },
  9839. {
  9840. .capture = {
  9841. .stream_name = "Tertiary TDM1 Capture",
  9842. .aif_name = "TERT_TDM_TX_1",
  9843. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9844. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9845. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9846. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9847. SNDRV_PCM_FMTBIT_S24_LE |
  9848. SNDRV_PCM_FMTBIT_S32_LE,
  9849. .channels_min = 1,
  9850. .channels_max = 16,
  9851. .rate_min = 8000,
  9852. .rate_max = 352800,
  9853. },
  9854. .name = "TERT_TDM_TX_1",
  9855. .ops = &msm_dai_q6_tdm_ops,
  9856. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  9857. .probe = msm_dai_q6_dai_tdm_probe,
  9858. .remove = msm_dai_q6_dai_tdm_remove,
  9859. },
  9860. {
  9861. .capture = {
  9862. .stream_name = "Tertiary TDM2 Capture",
  9863. .aif_name = "TERT_TDM_TX_2",
  9864. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9865. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9866. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9867. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9868. SNDRV_PCM_FMTBIT_S24_LE |
  9869. SNDRV_PCM_FMTBIT_S32_LE,
  9870. .channels_min = 1,
  9871. .channels_max = 16,
  9872. .rate_min = 8000,
  9873. .rate_max = 352800,
  9874. },
  9875. .name = "TERT_TDM_TX_2",
  9876. .ops = &msm_dai_q6_tdm_ops,
  9877. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  9878. .probe = msm_dai_q6_dai_tdm_probe,
  9879. .remove = msm_dai_q6_dai_tdm_remove,
  9880. },
  9881. {
  9882. .capture = {
  9883. .stream_name = "Tertiary TDM3 Capture",
  9884. .aif_name = "TERT_TDM_TX_3",
  9885. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9886. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9887. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9888. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9889. SNDRV_PCM_FMTBIT_S24_LE |
  9890. SNDRV_PCM_FMTBIT_S32_LE,
  9891. .channels_min = 1,
  9892. .channels_max = 16,
  9893. .rate_min = 8000,
  9894. .rate_max = 352800,
  9895. },
  9896. .name = "TERT_TDM_TX_3",
  9897. .ops = &msm_dai_q6_tdm_ops,
  9898. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  9899. .probe = msm_dai_q6_dai_tdm_probe,
  9900. .remove = msm_dai_q6_dai_tdm_remove,
  9901. },
  9902. {
  9903. .capture = {
  9904. .stream_name = "Tertiary TDM4 Capture",
  9905. .aif_name = "TERT_TDM_TX_4",
  9906. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9907. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9908. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9909. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9910. SNDRV_PCM_FMTBIT_S24_LE |
  9911. SNDRV_PCM_FMTBIT_S32_LE,
  9912. .channels_min = 1,
  9913. .channels_max = 16,
  9914. .rate_min = 8000,
  9915. .rate_max = 352800,
  9916. },
  9917. .name = "TERT_TDM_TX_4",
  9918. .ops = &msm_dai_q6_tdm_ops,
  9919. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  9920. .probe = msm_dai_q6_dai_tdm_probe,
  9921. .remove = msm_dai_q6_dai_tdm_remove,
  9922. },
  9923. {
  9924. .capture = {
  9925. .stream_name = "Tertiary TDM5 Capture",
  9926. .aif_name = "TERT_TDM_TX_5",
  9927. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9928. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9929. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9930. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9931. SNDRV_PCM_FMTBIT_S24_LE |
  9932. SNDRV_PCM_FMTBIT_S32_LE,
  9933. .channels_min = 1,
  9934. .channels_max = 16,
  9935. .rate_min = 8000,
  9936. .rate_max = 352800,
  9937. },
  9938. .name = "TERT_TDM_TX_5",
  9939. .ops = &msm_dai_q6_tdm_ops,
  9940. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  9941. .probe = msm_dai_q6_dai_tdm_probe,
  9942. .remove = msm_dai_q6_dai_tdm_remove,
  9943. },
  9944. {
  9945. .capture = {
  9946. .stream_name = "Tertiary TDM6 Capture",
  9947. .aif_name = "TERT_TDM_TX_6",
  9948. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9949. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9950. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9951. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9952. SNDRV_PCM_FMTBIT_S24_LE |
  9953. SNDRV_PCM_FMTBIT_S32_LE,
  9954. .channels_min = 1,
  9955. .channels_max = 16,
  9956. .rate_min = 8000,
  9957. .rate_max = 352800,
  9958. },
  9959. .name = "TERT_TDM_TX_6",
  9960. .ops = &msm_dai_q6_tdm_ops,
  9961. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  9962. .probe = msm_dai_q6_dai_tdm_probe,
  9963. .remove = msm_dai_q6_dai_tdm_remove,
  9964. },
  9965. {
  9966. .capture = {
  9967. .stream_name = "Tertiary TDM7 Capture",
  9968. .aif_name = "TERT_TDM_TX_7",
  9969. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  9970. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  9971. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9972. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9973. SNDRV_PCM_FMTBIT_S24_LE |
  9974. SNDRV_PCM_FMTBIT_S32_LE,
  9975. .channels_min = 1,
  9976. .channels_max = 16,
  9977. .rate_min = 8000,
  9978. .rate_max = 352800,
  9979. },
  9980. .name = "TERT_TDM_TX_7",
  9981. .ops = &msm_dai_q6_tdm_ops,
  9982. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  9983. .probe = msm_dai_q6_dai_tdm_probe,
  9984. .remove = msm_dai_q6_dai_tdm_remove,
  9985. },
  9986. {
  9987. .playback = {
  9988. .stream_name = "Quaternary TDM0 Playback",
  9989. .aif_name = "QUAT_TDM_RX_0",
  9990. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  9991. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  9992. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  9993. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9994. SNDRV_PCM_FMTBIT_S24_LE |
  9995. SNDRV_PCM_FMTBIT_S32_LE,
  9996. .channels_min = 1,
  9997. .channels_max = 16,
  9998. .rate_min = 8000,
  9999. .rate_max = 352800,
  10000. },
  10001. .name = "QUAT_TDM_RX_0",
  10002. .ops = &msm_dai_q6_tdm_ops,
  10003. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  10004. .probe = msm_dai_q6_dai_tdm_probe,
  10005. .remove = msm_dai_q6_dai_tdm_remove,
  10006. },
  10007. {
  10008. .playback = {
  10009. .stream_name = "Quaternary TDM1 Playback",
  10010. .aif_name = "QUAT_TDM_RX_1",
  10011. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10012. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10013. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10014. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10015. SNDRV_PCM_FMTBIT_S24_LE |
  10016. SNDRV_PCM_FMTBIT_S32_LE,
  10017. .channels_min = 1,
  10018. .channels_max = 16,
  10019. .rate_min = 8000,
  10020. .rate_max = 352800,
  10021. },
  10022. .name = "QUAT_TDM_RX_1",
  10023. .ops = &msm_dai_q6_tdm_ops,
  10024. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  10025. .probe = msm_dai_q6_dai_tdm_probe,
  10026. .remove = msm_dai_q6_dai_tdm_remove,
  10027. },
  10028. {
  10029. .playback = {
  10030. .stream_name = "Quaternary TDM2 Playback",
  10031. .aif_name = "QUAT_TDM_RX_2",
  10032. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10033. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10034. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10035. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10036. SNDRV_PCM_FMTBIT_S24_LE |
  10037. SNDRV_PCM_FMTBIT_S32_LE,
  10038. .channels_min = 1,
  10039. .channels_max = 16,
  10040. .rate_min = 8000,
  10041. .rate_max = 352800,
  10042. },
  10043. .name = "QUAT_TDM_RX_2",
  10044. .ops = &msm_dai_q6_tdm_ops,
  10045. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  10046. .probe = msm_dai_q6_dai_tdm_probe,
  10047. .remove = msm_dai_q6_dai_tdm_remove,
  10048. },
  10049. {
  10050. .playback = {
  10051. .stream_name = "Quaternary TDM3 Playback",
  10052. .aif_name = "QUAT_TDM_RX_3",
  10053. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10054. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10055. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10056. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10057. SNDRV_PCM_FMTBIT_S24_LE |
  10058. SNDRV_PCM_FMTBIT_S32_LE,
  10059. .channels_min = 1,
  10060. .channels_max = 16,
  10061. .rate_min = 8000,
  10062. .rate_max = 352800,
  10063. },
  10064. .name = "QUAT_TDM_RX_3",
  10065. .ops = &msm_dai_q6_tdm_ops,
  10066. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  10067. .probe = msm_dai_q6_dai_tdm_probe,
  10068. .remove = msm_dai_q6_dai_tdm_remove,
  10069. },
  10070. {
  10071. .playback = {
  10072. .stream_name = "Quaternary TDM4 Playback",
  10073. .aif_name = "QUAT_TDM_RX_4",
  10074. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10075. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10076. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10077. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10078. SNDRV_PCM_FMTBIT_S24_LE |
  10079. SNDRV_PCM_FMTBIT_S32_LE,
  10080. .channels_min = 1,
  10081. .channels_max = 16,
  10082. .rate_min = 8000,
  10083. .rate_max = 352800,
  10084. },
  10085. .name = "QUAT_TDM_RX_4",
  10086. .ops = &msm_dai_q6_tdm_ops,
  10087. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  10088. .probe = msm_dai_q6_dai_tdm_probe,
  10089. .remove = msm_dai_q6_dai_tdm_remove,
  10090. },
  10091. {
  10092. .playback = {
  10093. .stream_name = "Quaternary TDM5 Playback",
  10094. .aif_name = "QUAT_TDM_RX_5",
  10095. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10096. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10097. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10098. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10099. SNDRV_PCM_FMTBIT_S24_LE |
  10100. SNDRV_PCM_FMTBIT_S32_LE,
  10101. .channels_min = 1,
  10102. .channels_max = 16,
  10103. .rate_min = 8000,
  10104. .rate_max = 352800,
  10105. },
  10106. .name = "QUAT_TDM_RX_5",
  10107. .ops = &msm_dai_q6_tdm_ops,
  10108. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  10109. .probe = msm_dai_q6_dai_tdm_probe,
  10110. .remove = msm_dai_q6_dai_tdm_remove,
  10111. },
  10112. {
  10113. .playback = {
  10114. .stream_name = "Quaternary TDM6 Playback",
  10115. .aif_name = "QUAT_TDM_RX_6",
  10116. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10117. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10118. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10119. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10120. SNDRV_PCM_FMTBIT_S24_LE |
  10121. SNDRV_PCM_FMTBIT_S32_LE,
  10122. .channels_min = 1,
  10123. .channels_max = 16,
  10124. .rate_min = 8000,
  10125. .rate_max = 352800,
  10126. },
  10127. .name = "QUAT_TDM_RX_6",
  10128. .ops = &msm_dai_q6_tdm_ops,
  10129. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  10130. .probe = msm_dai_q6_dai_tdm_probe,
  10131. .remove = msm_dai_q6_dai_tdm_remove,
  10132. },
  10133. {
  10134. .playback = {
  10135. .stream_name = "Quaternary TDM7 Playback",
  10136. .aif_name = "QUAT_TDM_RX_7",
  10137. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10138. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10139. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10140. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10141. SNDRV_PCM_FMTBIT_S24_LE |
  10142. SNDRV_PCM_FMTBIT_S32_LE,
  10143. .channels_min = 1,
  10144. .channels_max = 16,
  10145. .rate_min = 8000,
  10146. .rate_max = 352800,
  10147. },
  10148. .name = "QUAT_TDM_RX_7",
  10149. .ops = &msm_dai_q6_tdm_ops,
  10150. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  10151. .probe = msm_dai_q6_dai_tdm_probe,
  10152. .remove = msm_dai_q6_dai_tdm_remove,
  10153. },
  10154. {
  10155. .capture = {
  10156. .stream_name = "Quaternary TDM0 Capture",
  10157. .aif_name = "QUAT_TDM_TX_0",
  10158. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10159. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10160. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10161. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10162. SNDRV_PCM_FMTBIT_S24_LE |
  10163. SNDRV_PCM_FMTBIT_S32_LE,
  10164. .channels_min = 1,
  10165. .channels_max = 16,
  10166. .rate_min = 8000,
  10167. .rate_max = 352800,
  10168. },
  10169. .name = "QUAT_TDM_TX_0",
  10170. .ops = &msm_dai_q6_tdm_ops,
  10171. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  10172. .probe = msm_dai_q6_dai_tdm_probe,
  10173. .remove = msm_dai_q6_dai_tdm_remove,
  10174. },
  10175. {
  10176. .capture = {
  10177. .stream_name = "Quaternary TDM1 Capture",
  10178. .aif_name = "QUAT_TDM_TX_1",
  10179. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10180. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10181. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10182. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10183. SNDRV_PCM_FMTBIT_S24_LE |
  10184. SNDRV_PCM_FMTBIT_S32_LE,
  10185. .channels_min = 1,
  10186. .channels_max = 16,
  10187. .rate_min = 8000,
  10188. .rate_max = 352800,
  10189. },
  10190. .name = "QUAT_TDM_TX_1",
  10191. .ops = &msm_dai_q6_tdm_ops,
  10192. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  10193. .probe = msm_dai_q6_dai_tdm_probe,
  10194. .remove = msm_dai_q6_dai_tdm_remove,
  10195. },
  10196. {
  10197. .capture = {
  10198. .stream_name = "Quaternary TDM2 Capture",
  10199. .aif_name = "QUAT_TDM_TX_2",
  10200. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10201. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10202. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10203. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10204. SNDRV_PCM_FMTBIT_S24_LE |
  10205. SNDRV_PCM_FMTBIT_S32_LE,
  10206. .channels_min = 1,
  10207. .channels_max = 16,
  10208. .rate_min = 8000,
  10209. .rate_max = 352800,
  10210. },
  10211. .name = "QUAT_TDM_TX_2",
  10212. .ops = &msm_dai_q6_tdm_ops,
  10213. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  10214. .probe = msm_dai_q6_dai_tdm_probe,
  10215. .remove = msm_dai_q6_dai_tdm_remove,
  10216. },
  10217. {
  10218. .capture = {
  10219. .stream_name = "Quaternary TDM3 Capture",
  10220. .aif_name = "QUAT_TDM_TX_3",
  10221. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10222. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10223. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10224. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10225. SNDRV_PCM_FMTBIT_S24_LE |
  10226. SNDRV_PCM_FMTBIT_S32_LE,
  10227. .channels_min = 1,
  10228. .channels_max = 16,
  10229. .rate_min = 8000,
  10230. .rate_max = 352800,
  10231. },
  10232. .name = "QUAT_TDM_TX_3",
  10233. .ops = &msm_dai_q6_tdm_ops,
  10234. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  10235. .probe = msm_dai_q6_dai_tdm_probe,
  10236. .remove = msm_dai_q6_dai_tdm_remove,
  10237. },
  10238. {
  10239. .capture = {
  10240. .stream_name = "Quaternary TDM4 Capture",
  10241. .aif_name = "QUAT_TDM_TX_4",
  10242. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10243. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10244. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10245. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10246. SNDRV_PCM_FMTBIT_S24_LE |
  10247. SNDRV_PCM_FMTBIT_S32_LE,
  10248. .channels_min = 1,
  10249. .channels_max = 16,
  10250. .rate_min = 8000,
  10251. .rate_max = 352800,
  10252. },
  10253. .name = "QUAT_TDM_TX_4",
  10254. .ops = &msm_dai_q6_tdm_ops,
  10255. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  10256. .probe = msm_dai_q6_dai_tdm_probe,
  10257. .remove = msm_dai_q6_dai_tdm_remove,
  10258. },
  10259. {
  10260. .capture = {
  10261. .stream_name = "Quaternary TDM5 Capture",
  10262. .aif_name = "QUAT_TDM_TX_5",
  10263. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10264. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10265. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10266. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10267. SNDRV_PCM_FMTBIT_S24_LE |
  10268. SNDRV_PCM_FMTBIT_S32_LE,
  10269. .channels_min = 1,
  10270. .channels_max = 16,
  10271. .rate_min = 8000,
  10272. .rate_max = 352800,
  10273. },
  10274. .name = "QUAT_TDM_TX_5",
  10275. .ops = &msm_dai_q6_tdm_ops,
  10276. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  10277. .probe = msm_dai_q6_dai_tdm_probe,
  10278. .remove = msm_dai_q6_dai_tdm_remove,
  10279. },
  10280. {
  10281. .capture = {
  10282. .stream_name = "Quaternary TDM6 Capture",
  10283. .aif_name = "QUAT_TDM_TX_6",
  10284. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10285. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10286. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10287. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10288. SNDRV_PCM_FMTBIT_S24_LE |
  10289. SNDRV_PCM_FMTBIT_S32_LE,
  10290. .channels_min = 1,
  10291. .channels_max = 16,
  10292. .rate_min = 8000,
  10293. .rate_max = 352800,
  10294. },
  10295. .name = "QUAT_TDM_TX_6",
  10296. .ops = &msm_dai_q6_tdm_ops,
  10297. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  10298. .probe = msm_dai_q6_dai_tdm_probe,
  10299. .remove = msm_dai_q6_dai_tdm_remove,
  10300. },
  10301. {
  10302. .capture = {
  10303. .stream_name = "Quaternary TDM7 Capture",
  10304. .aif_name = "QUAT_TDM_TX_7",
  10305. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10306. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10307. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10308. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10309. SNDRV_PCM_FMTBIT_S24_LE |
  10310. SNDRV_PCM_FMTBIT_S32_LE,
  10311. .channels_min = 1,
  10312. .channels_max = 16,
  10313. .rate_min = 8000,
  10314. .rate_max = 352800,
  10315. },
  10316. .name = "QUAT_TDM_TX_7",
  10317. .ops = &msm_dai_q6_tdm_ops,
  10318. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  10319. .probe = msm_dai_q6_dai_tdm_probe,
  10320. .remove = msm_dai_q6_dai_tdm_remove,
  10321. },
  10322. {
  10323. .playback = {
  10324. .stream_name = "Quinary TDM0 Playback",
  10325. .aif_name = "QUIN_TDM_RX_0",
  10326. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10327. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10328. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10329. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10330. SNDRV_PCM_FMTBIT_S24_LE |
  10331. SNDRV_PCM_FMTBIT_S32_LE,
  10332. .channels_min = 1,
  10333. .channels_max = 16,
  10334. .rate_min = 8000,
  10335. .rate_max = 352800,
  10336. },
  10337. .name = "QUIN_TDM_RX_0",
  10338. .ops = &msm_dai_q6_tdm_ops,
  10339. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  10340. .probe = msm_dai_q6_dai_tdm_probe,
  10341. .remove = msm_dai_q6_dai_tdm_remove,
  10342. },
  10343. {
  10344. .playback = {
  10345. .stream_name = "Quinary TDM1 Playback",
  10346. .aif_name = "QUIN_TDM_RX_1",
  10347. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10348. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10349. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10350. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10351. SNDRV_PCM_FMTBIT_S24_LE |
  10352. SNDRV_PCM_FMTBIT_S32_LE,
  10353. .channels_min = 1,
  10354. .channels_max = 16,
  10355. .rate_min = 8000,
  10356. .rate_max = 352800,
  10357. },
  10358. .name = "QUIN_TDM_RX_1",
  10359. .ops = &msm_dai_q6_tdm_ops,
  10360. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  10361. .probe = msm_dai_q6_dai_tdm_probe,
  10362. .remove = msm_dai_q6_dai_tdm_remove,
  10363. },
  10364. {
  10365. .playback = {
  10366. .stream_name = "Quinary TDM2 Playback",
  10367. .aif_name = "QUIN_TDM_RX_2",
  10368. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10369. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10370. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10371. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10372. SNDRV_PCM_FMTBIT_S24_LE |
  10373. SNDRV_PCM_FMTBIT_S32_LE,
  10374. .channels_min = 1,
  10375. .channels_max = 16,
  10376. .rate_min = 8000,
  10377. .rate_max = 352800,
  10378. },
  10379. .name = "QUIN_TDM_RX_2",
  10380. .ops = &msm_dai_q6_tdm_ops,
  10381. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  10382. .probe = msm_dai_q6_dai_tdm_probe,
  10383. .remove = msm_dai_q6_dai_tdm_remove,
  10384. },
  10385. {
  10386. .playback = {
  10387. .stream_name = "Quinary TDM3 Playback",
  10388. .aif_name = "QUIN_TDM_RX_3",
  10389. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10390. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10391. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10392. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10393. SNDRV_PCM_FMTBIT_S24_LE |
  10394. SNDRV_PCM_FMTBIT_S32_LE,
  10395. .channels_min = 1,
  10396. .channels_max = 16,
  10397. .rate_min = 8000,
  10398. .rate_max = 352800,
  10399. },
  10400. .name = "QUIN_TDM_RX_3",
  10401. .ops = &msm_dai_q6_tdm_ops,
  10402. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  10403. .probe = msm_dai_q6_dai_tdm_probe,
  10404. .remove = msm_dai_q6_dai_tdm_remove,
  10405. },
  10406. {
  10407. .playback = {
  10408. .stream_name = "Quinary TDM4 Playback",
  10409. .aif_name = "QUIN_TDM_RX_4",
  10410. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10411. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10412. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10413. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10414. SNDRV_PCM_FMTBIT_S24_LE |
  10415. SNDRV_PCM_FMTBIT_S32_LE,
  10416. .channels_min = 1,
  10417. .channels_max = 16,
  10418. .rate_min = 8000,
  10419. .rate_max = 352800,
  10420. },
  10421. .name = "QUIN_TDM_RX_4",
  10422. .ops = &msm_dai_q6_tdm_ops,
  10423. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  10424. .probe = msm_dai_q6_dai_tdm_probe,
  10425. .remove = msm_dai_q6_dai_tdm_remove,
  10426. },
  10427. {
  10428. .playback = {
  10429. .stream_name = "Quinary TDM5 Playback",
  10430. .aif_name = "QUIN_TDM_RX_5",
  10431. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10432. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10433. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10434. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10435. SNDRV_PCM_FMTBIT_S24_LE |
  10436. SNDRV_PCM_FMTBIT_S32_LE,
  10437. .channels_min = 1,
  10438. .channels_max = 16,
  10439. .rate_min = 8000,
  10440. .rate_max = 352800,
  10441. },
  10442. .name = "QUIN_TDM_RX_5",
  10443. .ops = &msm_dai_q6_tdm_ops,
  10444. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  10445. .probe = msm_dai_q6_dai_tdm_probe,
  10446. .remove = msm_dai_q6_dai_tdm_remove,
  10447. },
  10448. {
  10449. .playback = {
  10450. .stream_name = "Quinary TDM6 Playback",
  10451. .aif_name = "QUIN_TDM_RX_6",
  10452. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10453. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10454. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10455. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10456. SNDRV_PCM_FMTBIT_S24_LE |
  10457. SNDRV_PCM_FMTBIT_S32_LE,
  10458. .channels_min = 1,
  10459. .channels_max = 16,
  10460. .rate_min = 8000,
  10461. .rate_max = 352800,
  10462. },
  10463. .name = "QUIN_TDM_RX_6",
  10464. .ops = &msm_dai_q6_tdm_ops,
  10465. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  10466. .probe = msm_dai_q6_dai_tdm_probe,
  10467. .remove = msm_dai_q6_dai_tdm_remove,
  10468. },
  10469. {
  10470. .playback = {
  10471. .stream_name = "Quinary TDM7 Playback",
  10472. .aif_name = "QUIN_TDM_RX_7",
  10473. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10474. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10475. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10476. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10477. SNDRV_PCM_FMTBIT_S24_LE |
  10478. SNDRV_PCM_FMTBIT_S32_LE,
  10479. .channels_min = 1,
  10480. .channels_max = 16,
  10481. .rate_min = 8000,
  10482. .rate_max = 352800,
  10483. },
  10484. .name = "QUIN_TDM_RX_7",
  10485. .ops = &msm_dai_q6_tdm_ops,
  10486. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  10487. .probe = msm_dai_q6_dai_tdm_probe,
  10488. .remove = msm_dai_q6_dai_tdm_remove,
  10489. },
  10490. {
  10491. .capture = {
  10492. .stream_name = "Quinary TDM0 Capture",
  10493. .aif_name = "QUIN_TDM_TX_0",
  10494. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10495. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10496. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10497. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10498. SNDRV_PCM_FMTBIT_S24_LE |
  10499. SNDRV_PCM_FMTBIT_S32_LE,
  10500. .channels_min = 1,
  10501. .channels_max = 16,
  10502. .rate_min = 8000,
  10503. .rate_max = 352800,
  10504. },
  10505. .name = "QUIN_TDM_TX_0",
  10506. .ops = &msm_dai_q6_tdm_ops,
  10507. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  10508. .probe = msm_dai_q6_dai_tdm_probe,
  10509. .remove = msm_dai_q6_dai_tdm_remove,
  10510. },
  10511. {
  10512. .capture = {
  10513. .stream_name = "Quinary TDM1 Capture",
  10514. .aif_name = "QUIN_TDM_TX_1",
  10515. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10516. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10517. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10518. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10519. SNDRV_PCM_FMTBIT_S24_LE |
  10520. SNDRV_PCM_FMTBIT_S32_LE,
  10521. .channels_min = 1,
  10522. .channels_max = 16,
  10523. .rate_min = 8000,
  10524. .rate_max = 352800,
  10525. },
  10526. .name = "QUIN_TDM_TX_1",
  10527. .ops = &msm_dai_q6_tdm_ops,
  10528. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  10529. .probe = msm_dai_q6_dai_tdm_probe,
  10530. .remove = msm_dai_q6_dai_tdm_remove,
  10531. },
  10532. {
  10533. .capture = {
  10534. .stream_name = "Quinary TDM2 Capture",
  10535. .aif_name = "QUIN_TDM_TX_2",
  10536. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10537. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10538. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10539. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10540. SNDRV_PCM_FMTBIT_S24_LE |
  10541. SNDRV_PCM_FMTBIT_S32_LE,
  10542. .channels_min = 1,
  10543. .channels_max = 16,
  10544. .rate_min = 8000,
  10545. .rate_max = 352800,
  10546. },
  10547. .name = "QUIN_TDM_TX_2",
  10548. .ops = &msm_dai_q6_tdm_ops,
  10549. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  10550. .probe = msm_dai_q6_dai_tdm_probe,
  10551. .remove = msm_dai_q6_dai_tdm_remove,
  10552. },
  10553. {
  10554. .capture = {
  10555. .stream_name = "Quinary TDM3 Capture",
  10556. .aif_name = "QUIN_TDM_TX_3",
  10557. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10558. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10559. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10560. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10561. SNDRV_PCM_FMTBIT_S24_LE |
  10562. SNDRV_PCM_FMTBIT_S32_LE,
  10563. .channels_min = 1,
  10564. .channels_max = 16,
  10565. .rate_min = 8000,
  10566. .rate_max = 352800,
  10567. },
  10568. .name = "QUIN_TDM_TX_3",
  10569. .ops = &msm_dai_q6_tdm_ops,
  10570. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  10571. .probe = msm_dai_q6_dai_tdm_probe,
  10572. .remove = msm_dai_q6_dai_tdm_remove,
  10573. },
  10574. {
  10575. .capture = {
  10576. .stream_name = "Quinary TDM4 Capture",
  10577. .aif_name = "QUIN_TDM_TX_4",
  10578. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10579. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10580. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10581. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10582. SNDRV_PCM_FMTBIT_S24_LE |
  10583. SNDRV_PCM_FMTBIT_S32_LE,
  10584. .channels_min = 1,
  10585. .channels_max = 16,
  10586. .rate_min = 8000,
  10587. .rate_max = 352800,
  10588. },
  10589. .name = "QUIN_TDM_TX_4",
  10590. .ops = &msm_dai_q6_tdm_ops,
  10591. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  10592. .probe = msm_dai_q6_dai_tdm_probe,
  10593. .remove = msm_dai_q6_dai_tdm_remove,
  10594. },
  10595. {
  10596. .capture = {
  10597. .stream_name = "Quinary TDM5 Capture",
  10598. .aif_name = "QUIN_TDM_TX_5",
  10599. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10600. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10601. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10602. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10603. SNDRV_PCM_FMTBIT_S24_LE |
  10604. SNDRV_PCM_FMTBIT_S32_LE,
  10605. .channels_min = 1,
  10606. .channels_max = 16,
  10607. .rate_min = 8000,
  10608. .rate_max = 352800,
  10609. },
  10610. .name = "QUIN_TDM_TX_5",
  10611. .ops = &msm_dai_q6_tdm_ops,
  10612. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  10613. .probe = msm_dai_q6_dai_tdm_probe,
  10614. .remove = msm_dai_q6_dai_tdm_remove,
  10615. },
  10616. {
  10617. .capture = {
  10618. .stream_name = "Quinary TDM6 Capture",
  10619. .aif_name = "QUIN_TDM_TX_6",
  10620. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10621. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10622. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10623. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10624. SNDRV_PCM_FMTBIT_S24_LE |
  10625. SNDRV_PCM_FMTBIT_S32_LE,
  10626. .channels_min = 1,
  10627. .channels_max = 16,
  10628. .rate_min = 8000,
  10629. .rate_max = 352800,
  10630. },
  10631. .name = "QUIN_TDM_TX_6",
  10632. .ops = &msm_dai_q6_tdm_ops,
  10633. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  10634. .probe = msm_dai_q6_dai_tdm_probe,
  10635. .remove = msm_dai_q6_dai_tdm_remove,
  10636. },
  10637. {
  10638. .capture = {
  10639. .stream_name = "Quinary TDM7 Capture",
  10640. .aif_name = "QUIN_TDM_TX_7",
  10641. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10642. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10643. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10644. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10645. SNDRV_PCM_FMTBIT_S24_LE |
  10646. SNDRV_PCM_FMTBIT_S32_LE,
  10647. .channels_min = 1,
  10648. .channels_max = 16,
  10649. .rate_min = 8000,
  10650. .rate_max = 352800,
  10651. },
  10652. .name = "QUIN_TDM_TX_7",
  10653. .ops = &msm_dai_q6_tdm_ops,
  10654. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  10655. .probe = msm_dai_q6_dai_tdm_probe,
  10656. .remove = msm_dai_q6_dai_tdm_remove,
  10657. },
  10658. {
  10659. .playback = {
  10660. .stream_name = "Senary TDM0 Playback",
  10661. .aif_name = "SEN_TDM_RX_0",
  10662. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10663. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10664. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10665. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10666. SNDRV_PCM_FMTBIT_S24_LE |
  10667. SNDRV_PCM_FMTBIT_S32_LE,
  10668. .channels_min = 1,
  10669. .channels_max = 8,
  10670. .rate_min = 8000,
  10671. .rate_max = 352800,
  10672. },
  10673. .name = "SEN_TDM_RX_0",
  10674. .ops = &msm_dai_q6_tdm_ops,
  10675. .id = AFE_PORT_ID_SENARY_TDM_RX,
  10676. .probe = msm_dai_q6_dai_tdm_probe,
  10677. .remove = msm_dai_q6_dai_tdm_remove,
  10678. },
  10679. {
  10680. .playback = {
  10681. .stream_name = "Senary TDM1 Playback",
  10682. .aif_name = "SEN_TDM_RX_1",
  10683. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10684. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10685. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10686. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10687. SNDRV_PCM_FMTBIT_S24_LE |
  10688. SNDRV_PCM_FMTBIT_S32_LE,
  10689. .channels_min = 1,
  10690. .channels_max = 8,
  10691. .rate_min = 8000,
  10692. .rate_max = 352800,
  10693. },
  10694. .name = "SEN_TDM_RX_1",
  10695. .ops = &msm_dai_q6_tdm_ops,
  10696. .id = AFE_PORT_ID_SENARY_TDM_RX_1,
  10697. .probe = msm_dai_q6_dai_tdm_probe,
  10698. .remove = msm_dai_q6_dai_tdm_remove,
  10699. },
  10700. {
  10701. .playback = {
  10702. .stream_name = "Senary TDM2 Playback",
  10703. .aif_name = "SEN_TDM_RX_2",
  10704. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10705. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10706. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10707. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10708. SNDRV_PCM_FMTBIT_S24_LE |
  10709. SNDRV_PCM_FMTBIT_S32_LE,
  10710. .channels_min = 1,
  10711. .channels_max = 8,
  10712. .rate_min = 8000,
  10713. .rate_max = 352800,
  10714. },
  10715. .name = "SEN_TDM_RX_2",
  10716. .ops = &msm_dai_q6_tdm_ops,
  10717. .id = AFE_PORT_ID_SENARY_TDM_RX_2,
  10718. .probe = msm_dai_q6_dai_tdm_probe,
  10719. .remove = msm_dai_q6_dai_tdm_remove,
  10720. },
  10721. {
  10722. .playback = {
  10723. .stream_name = "Senary TDM3 Playback",
  10724. .aif_name = "SEN_TDM_RX_3",
  10725. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10726. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10727. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10728. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10729. SNDRV_PCM_FMTBIT_S24_LE |
  10730. SNDRV_PCM_FMTBIT_S32_LE,
  10731. .channels_min = 1,
  10732. .channels_max = 8,
  10733. .rate_min = 8000,
  10734. .rate_max = 352800,
  10735. },
  10736. .name = "SEN_TDM_RX_3",
  10737. .ops = &msm_dai_q6_tdm_ops,
  10738. .id = AFE_PORT_ID_SENARY_TDM_RX_3,
  10739. .probe = msm_dai_q6_dai_tdm_probe,
  10740. .remove = msm_dai_q6_dai_tdm_remove,
  10741. },
  10742. {
  10743. .playback = {
  10744. .stream_name = "Senary TDM4 Playback",
  10745. .aif_name = "SEN_TDM_RX_4",
  10746. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10747. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10748. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10749. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10750. SNDRV_PCM_FMTBIT_S24_LE |
  10751. SNDRV_PCM_FMTBIT_S32_LE,
  10752. .channels_min = 1,
  10753. .channels_max = 8,
  10754. .rate_min = 8000,
  10755. .rate_max = 352800,
  10756. },
  10757. .name = "SEN_TDM_RX_4",
  10758. .ops = &msm_dai_q6_tdm_ops,
  10759. .id = AFE_PORT_ID_SENARY_TDM_RX_4,
  10760. .probe = msm_dai_q6_dai_tdm_probe,
  10761. .remove = msm_dai_q6_dai_tdm_remove,
  10762. },
  10763. {
  10764. .playback = {
  10765. .stream_name = "Senary TDM5 Playback",
  10766. .aif_name = "SEN_TDM_RX_5",
  10767. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10768. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10769. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10770. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10771. SNDRV_PCM_FMTBIT_S24_LE |
  10772. SNDRV_PCM_FMTBIT_S32_LE,
  10773. .channels_min = 1,
  10774. .channels_max = 8,
  10775. .rate_min = 8000,
  10776. .rate_max = 352800,
  10777. },
  10778. .name = "SEN_TDM_RX_5",
  10779. .ops = &msm_dai_q6_tdm_ops,
  10780. .id = AFE_PORT_ID_SENARY_TDM_RX_5,
  10781. .probe = msm_dai_q6_dai_tdm_probe,
  10782. .remove = msm_dai_q6_dai_tdm_remove,
  10783. },
  10784. {
  10785. .playback = {
  10786. .stream_name = "Senary TDM6 Playback",
  10787. .aif_name = "SEN_TDM_RX_6",
  10788. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10789. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10790. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10791. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10792. SNDRV_PCM_FMTBIT_S24_LE |
  10793. SNDRV_PCM_FMTBIT_S32_LE,
  10794. .channels_min = 1,
  10795. .channels_max = 8,
  10796. .rate_min = 8000,
  10797. .rate_max = 352800,
  10798. },
  10799. .name = "SEN_TDM_RX_6",
  10800. .ops = &msm_dai_q6_tdm_ops,
  10801. .id = AFE_PORT_ID_SENARY_TDM_RX_6,
  10802. .probe = msm_dai_q6_dai_tdm_probe,
  10803. .remove = msm_dai_q6_dai_tdm_remove,
  10804. },
  10805. {
  10806. .playback = {
  10807. .stream_name = "Senary TDM7 Playback",
  10808. .aif_name = "SEN_TDM_RX_7",
  10809. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  10810. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  10811. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10812. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10813. SNDRV_PCM_FMTBIT_S24_LE |
  10814. SNDRV_PCM_FMTBIT_S32_LE,
  10815. .channels_min = 1,
  10816. .channels_max = 8,
  10817. .rate_min = 8000,
  10818. .rate_max = 352800,
  10819. },
  10820. .name = "SEN_TDM_RX_7",
  10821. .ops = &msm_dai_q6_tdm_ops,
  10822. .id = AFE_PORT_ID_SENARY_TDM_RX_7,
  10823. .probe = msm_dai_q6_dai_tdm_probe,
  10824. .remove = msm_dai_q6_dai_tdm_remove,
  10825. },
  10826. {
  10827. .capture = {
  10828. .stream_name = "Senary TDM0 Capture",
  10829. .aif_name = "SEN_TDM_TX_0",
  10830. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10831. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10832. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10833. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10834. SNDRV_PCM_FMTBIT_S24_LE |
  10835. SNDRV_PCM_FMTBIT_S32_LE,
  10836. .channels_min = 1,
  10837. .channels_max = 8,
  10838. .rate_min = 8000,
  10839. .rate_max = 352800,
  10840. },
  10841. .name = "SEN_TDM_TX_0",
  10842. .ops = &msm_dai_q6_tdm_ops,
  10843. .id = AFE_PORT_ID_SENARY_TDM_TX,
  10844. .probe = msm_dai_q6_dai_tdm_probe,
  10845. .remove = msm_dai_q6_dai_tdm_remove,
  10846. },
  10847. {
  10848. .capture = {
  10849. .stream_name = "Senary TDM1 Capture",
  10850. .aif_name = "SEN_TDM_TX_1",
  10851. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10852. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10853. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10854. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10855. SNDRV_PCM_FMTBIT_S24_LE |
  10856. SNDRV_PCM_FMTBIT_S32_LE,
  10857. .channels_min = 1,
  10858. .channels_max = 8,
  10859. .rate_min = 8000,
  10860. .rate_max = 352800,
  10861. },
  10862. .name = "SEN_TDM_TX_1",
  10863. .ops = &msm_dai_q6_tdm_ops,
  10864. .id = AFE_PORT_ID_SENARY_TDM_TX_1,
  10865. .probe = msm_dai_q6_dai_tdm_probe,
  10866. .remove = msm_dai_q6_dai_tdm_remove,
  10867. },
  10868. {
  10869. .capture = {
  10870. .stream_name = "Senary TDM2 Capture",
  10871. .aif_name = "SEN_TDM_TX_2",
  10872. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10873. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10874. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10875. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10876. SNDRV_PCM_FMTBIT_S24_LE |
  10877. SNDRV_PCM_FMTBIT_S32_LE,
  10878. .channels_min = 1,
  10879. .channels_max = 8,
  10880. .rate_min = 8000,
  10881. .rate_max = 352800,
  10882. },
  10883. .name = "SEN_TDM_TX_2",
  10884. .ops = &msm_dai_q6_tdm_ops,
  10885. .id = AFE_PORT_ID_SENARY_TDM_TX_2,
  10886. .probe = msm_dai_q6_dai_tdm_probe,
  10887. .remove = msm_dai_q6_dai_tdm_remove,
  10888. },
  10889. {
  10890. .capture = {
  10891. .stream_name = "Senary TDM3 Capture",
  10892. .aif_name = "SEN_TDM_TX_3",
  10893. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10894. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10895. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10896. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10897. SNDRV_PCM_FMTBIT_S24_LE |
  10898. SNDRV_PCM_FMTBIT_S32_LE,
  10899. .channels_min = 1,
  10900. .channels_max = 8,
  10901. .rate_min = 8000,
  10902. .rate_max = 352800,
  10903. },
  10904. .name = "SEN_TDM_TX_3",
  10905. .ops = &msm_dai_q6_tdm_ops,
  10906. .id = AFE_PORT_ID_SENARY_TDM_TX_3,
  10907. .probe = msm_dai_q6_dai_tdm_probe,
  10908. .remove = msm_dai_q6_dai_tdm_remove,
  10909. },
  10910. {
  10911. .capture = {
  10912. .stream_name = "Senary TDM4 Capture",
  10913. .aif_name = "SEN_TDM_TX_4",
  10914. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10915. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10916. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10917. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10918. SNDRV_PCM_FMTBIT_S24_LE |
  10919. SNDRV_PCM_FMTBIT_S32_LE,
  10920. .channels_min = 1,
  10921. .channels_max = 8,
  10922. .rate_min = 8000,
  10923. .rate_max = 352800,
  10924. },
  10925. .name = "SEN_TDM_TX_4",
  10926. .ops = &msm_dai_q6_tdm_ops,
  10927. .id = AFE_PORT_ID_SENARY_TDM_TX_4,
  10928. .probe = msm_dai_q6_dai_tdm_probe,
  10929. .remove = msm_dai_q6_dai_tdm_remove,
  10930. },
  10931. {
  10932. .capture = {
  10933. .stream_name = "Senary TDM5 Capture",
  10934. .aif_name = "SEN_TDM_TX_5",
  10935. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10936. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10937. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10938. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10939. SNDRV_PCM_FMTBIT_S24_LE |
  10940. SNDRV_PCM_FMTBIT_S32_LE,
  10941. .channels_min = 1,
  10942. .channels_max = 8,
  10943. .rate_min = 8000,
  10944. .rate_max = 352800,
  10945. },
  10946. .name = "SEN_TDM_TX_5",
  10947. .ops = &msm_dai_q6_tdm_ops,
  10948. .id = AFE_PORT_ID_SENARY_TDM_TX_5,
  10949. .probe = msm_dai_q6_dai_tdm_probe,
  10950. .remove = msm_dai_q6_dai_tdm_remove,
  10951. },
  10952. {
  10953. .capture = {
  10954. .stream_name = "Senary TDM6 Capture",
  10955. .aif_name = "SEN_TDM_TX_6",
  10956. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10957. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10958. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10959. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10960. SNDRV_PCM_FMTBIT_S24_LE |
  10961. SNDRV_PCM_FMTBIT_S32_LE,
  10962. .channels_min = 1,
  10963. .channels_max = 8,
  10964. .rate_min = 8000,
  10965. .rate_max = 352800,
  10966. },
  10967. .name = "SEN_TDM_TX_6",
  10968. .ops = &msm_dai_q6_tdm_ops,
  10969. .id = AFE_PORT_ID_SENARY_TDM_TX_6,
  10970. .probe = msm_dai_q6_dai_tdm_probe,
  10971. .remove = msm_dai_q6_dai_tdm_remove,
  10972. },
  10973. {
  10974. .capture = {
  10975. .stream_name = "Senary TDM7 Capture",
  10976. .aif_name = "SEN_TDM_TX_7",
  10977. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  10978. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  10979. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  10980. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  10981. SNDRV_PCM_FMTBIT_S24_LE |
  10982. SNDRV_PCM_FMTBIT_S32_LE,
  10983. .channels_min = 1,
  10984. .channels_max = 8,
  10985. .rate_min = 8000,
  10986. .rate_max = 352800,
  10987. },
  10988. .name = "SEN_TDM_TX_7",
  10989. .ops = &msm_dai_q6_tdm_ops,
  10990. .id = AFE_PORT_ID_SENARY_TDM_TX_7,
  10991. .probe = msm_dai_q6_dai_tdm_probe,
  10992. .remove = msm_dai_q6_dai_tdm_remove,
  10993. },
  10994. };
  10995. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  10996. .name = "msm-dai-q6-tdm",
  10997. };
  10998. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  10999. {
  11000. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  11001. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  11002. int rc = 0;
  11003. u32 tdm_dev_id = 0;
  11004. int port_idx = 0;
  11005. struct device_node *tdm_parent_node = NULL;
  11006. /* retrieve device/afe id */
  11007. rc = of_property_read_u32(pdev->dev.of_node,
  11008. "qcom,msm-cpudai-tdm-dev-id",
  11009. &tdm_dev_id);
  11010. if (rc) {
  11011. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  11012. __func__);
  11013. goto rtn;
  11014. }
  11015. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  11016. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  11017. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  11018. __func__, tdm_dev_id);
  11019. rc = -ENXIO;
  11020. goto rtn;
  11021. }
  11022. pdev->id = tdm_dev_id;
  11023. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  11024. GFP_KERNEL);
  11025. if (!dai_data) {
  11026. rc = -ENOMEM;
  11027. dev_err(&pdev->dev,
  11028. "%s Failed to allocate memory for tdm dai_data\n",
  11029. __func__);
  11030. goto rtn;
  11031. }
  11032. memset(dai_data, 0, sizeof(*dai_data));
  11033. rc = of_property_read_u32(pdev->dev.of_node,
  11034. "qcom,msm-dai-is-island-supported",
  11035. &dai_data->is_island_dai);
  11036. if (rc)
  11037. dev_dbg(&pdev->dev, "island supported entry not found\n");
  11038. /* TDM CFG */
  11039. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  11040. rc = of_property_read_u32(tdm_parent_node,
  11041. "qcom,msm-cpudai-tdm-sync-mode",
  11042. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  11043. if (rc) {
  11044. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  11045. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  11046. goto free_dai_data;
  11047. }
  11048. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  11049. __func__, dai_data->port_cfg.tdm.sync_mode);
  11050. rc = of_property_read_u32(tdm_parent_node,
  11051. "qcom,msm-cpudai-tdm-sync-src",
  11052. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  11053. if (rc) {
  11054. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  11055. __func__, "qcom,msm-cpudai-tdm-sync-src");
  11056. goto free_dai_data;
  11057. }
  11058. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  11059. __func__, dai_data->port_cfg.tdm.sync_src);
  11060. rc = of_property_read_u32(tdm_parent_node,
  11061. "qcom,msm-cpudai-tdm-data-out",
  11062. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  11063. if (rc) {
  11064. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  11065. __func__, "qcom,msm-cpudai-tdm-data-out");
  11066. goto free_dai_data;
  11067. }
  11068. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  11069. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  11070. rc = of_property_read_u32(tdm_parent_node,
  11071. "qcom,msm-cpudai-tdm-invert-sync",
  11072. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  11073. if (rc) {
  11074. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  11075. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  11076. goto free_dai_data;
  11077. }
  11078. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  11079. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  11080. rc = of_property_read_u32(tdm_parent_node,
  11081. "qcom,msm-cpudai-tdm-data-delay",
  11082. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  11083. if (rc) {
  11084. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  11085. __func__, "qcom,msm-cpudai-tdm-data-delay");
  11086. goto free_dai_data;
  11087. }
  11088. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  11089. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  11090. /* TDM CFG -- set default */
  11091. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  11092. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  11093. AFE_API_VERSION_TDM_CONFIG;
  11094. /* TDM SLOT MAPPING CFG */
  11095. rc = of_property_read_u32(pdev->dev.of_node,
  11096. "qcom,msm-cpudai-tdm-data-align",
  11097. &dai_data->port_cfg.slot_mapping.data_align_type);
  11098. if (rc) {
  11099. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  11100. __func__,
  11101. "qcom,msm-cpudai-tdm-data-align");
  11102. goto free_dai_data;
  11103. }
  11104. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  11105. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  11106. /* TDM SLOT MAPPING CFG -- set default */
  11107. dai_data->port_cfg.slot_mapping.minor_version =
  11108. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  11109. dai_data->port_cfg.slot_mapping_v2.minor_version =
  11110. AFE_API_VERSION_SLOT_MAPPING_CONFIG_V2;
  11111. /* CUSTOM TDM HEADER CFG */
  11112. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  11113. if (of_find_property(pdev->dev.of_node,
  11114. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  11115. of_find_property(pdev->dev.of_node,
  11116. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  11117. of_find_property(pdev->dev.of_node,
  11118. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  11119. /* if the property exist */
  11120. rc = of_property_read_u32(pdev->dev.of_node,
  11121. "qcom,msm-cpudai-tdm-header-start-offset",
  11122. (u32 *)&custom_tdm_header->start_offset);
  11123. if (rc) {
  11124. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  11125. __func__,
  11126. "qcom,msm-cpudai-tdm-header-start-offset");
  11127. goto free_dai_data;
  11128. }
  11129. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  11130. __func__, custom_tdm_header->start_offset);
  11131. rc = of_property_read_u32(pdev->dev.of_node,
  11132. "qcom,msm-cpudai-tdm-header-width",
  11133. (u32 *)&custom_tdm_header->header_width);
  11134. if (rc) {
  11135. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  11136. __func__, "qcom,msm-cpudai-tdm-header-width");
  11137. goto free_dai_data;
  11138. }
  11139. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  11140. __func__, custom_tdm_header->header_width);
  11141. rc = of_property_read_u32(pdev->dev.of_node,
  11142. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  11143. (u32 *)&custom_tdm_header->num_frame_repeat);
  11144. if (rc) {
  11145. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  11146. __func__,
  11147. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  11148. goto free_dai_data;
  11149. }
  11150. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  11151. __func__, custom_tdm_header->num_frame_repeat);
  11152. /* CUSTOM TDM HEADER CFG -- set default */
  11153. custom_tdm_header->minor_version =
  11154. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  11155. custom_tdm_header->header_type =
  11156. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  11157. } else {
  11158. /* CUSTOM TDM HEADER CFG -- set default */
  11159. custom_tdm_header->header_type =
  11160. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  11161. /* proceed with probe */
  11162. }
  11163. /* copy static clk per parent node */
  11164. dai_data->clk_set = tdm_clk_set;
  11165. /* copy static group cfg per parent node */
  11166. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  11167. /* copy static num group ports per parent node */
  11168. dai_data->num_group_ports = num_tdm_group_ports;
  11169. dai_data->lane_cfg = tdm_lane_cfg;
  11170. dev_set_drvdata(&pdev->dev, dai_data);
  11171. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  11172. if (port_idx < 0) {
  11173. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  11174. __func__, tdm_dev_id);
  11175. rc = -EINVAL;
  11176. goto free_dai_data;
  11177. }
  11178. rc = snd_soc_register_component(&pdev->dev,
  11179. &msm_q6_tdm_dai_component,
  11180. &msm_dai_q6_tdm_dai[port_idx], 1);
  11181. if (rc) {
  11182. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  11183. __func__, tdm_dev_id, rc);
  11184. goto err_register;
  11185. }
  11186. return 0;
  11187. err_register:
  11188. free_dai_data:
  11189. kfree(dai_data);
  11190. rtn:
  11191. return rc;
  11192. }
  11193. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  11194. {
  11195. struct msm_dai_q6_tdm_dai_data *dai_data =
  11196. dev_get_drvdata(&pdev->dev);
  11197. snd_soc_unregister_component(&pdev->dev);
  11198. kfree(dai_data);
  11199. return 0;
  11200. }
  11201. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  11202. { .compatible = "qcom,msm-dai-q6-tdm", },
  11203. {}
  11204. };
  11205. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  11206. static struct platform_driver msm_dai_q6_tdm_driver = {
  11207. .probe = msm_dai_q6_tdm_dev_probe,
  11208. .remove = msm_dai_q6_tdm_dev_remove,
  11209. .driver = {
  11210. .name = "msm-dai-q6-tdm",
  11211. .owner = THIS_MODULE,
  11212. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  11213. .suppress_bind_attrs = true,
  11214. },
  11215. };
  11216. static int msm_dai_q6_cdc_dma_format_put(struct snd_kcontrol *kcontrol,
  11217. struct snd_ctl_elem_value *ucontrol)
  11218. {
  11219. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  11220. int value = ucontrol->value.integer.value[0];
  11221. dai_data->port_config.cdc_dma.data_format = value;
  11222. pr_debug("%s: format = %d\n", __func__, value);
  11223. return 0;
  11224. }
  11225. static int msm_dai_q6_cdc_dma_format_get(struct snd_kcontrol *kcontrol,
  11226. struct snd_ctl_elem_value *ucontrol)
  11227. {
  11228. struct msm_dai_q6_cdc_dma_dai_data *dai_data = kcontrol->private_data;
  11229. ucontrol->value.integer.value[0] =
  11230. dai_data->port_config.cdc_dma.data_format;
  11231. return 0;
  11232. }
  11233. static const struct snd_kcontrol_new cdc_dma_config_controls[] = {
  11234. SOC_ENUM_EXT("WSA_CDC_DMA_0 TX Format", cdc_dma_config_enum[0],
  11235. msm_dai_q6_cdc_dma_format_get,
  11236. msm_dai_q6_cdc_dma_format_put),
  11237. SOC_ENUM_EXT("WSA_CDC_DMA_0 RX XTLoggingDisable",
  11238. xt_logging_disable_enum[0],
  11239. msm_dai_q6_xt_logging_disable_get,
  11240. msm_dai_q6_xt_logging_disable_put),
  11241. };
  11242. /* SOC probe for codec DMA interface */
  11243. static int msm_dai_q6_dai_cdc_dma_probe(struct snd_soc_dai *dai)
  11244. {
  11245. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  11246. int rc = 0;
  11247. if (!dai) {
  11248. pr_err("%s: Invalid params dai\n", __func__);
  11249. return -EINVAL;
  11250. }
  11251. if (!dai->dev) {
  11252. pr_err("%s: Invalid params dai dev\n", __func__);
  11253. return -EINVAL;
  11254. }
  11255. msm_dai_q6_set_dai_id(dai);
  11256. dai_data = dev_get_drvdata(dai->dev);
  11257. switch (dai->id) {
  11258. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  11259. rc = snd_ctl_add(dai->component->card->snd_card,
  11260. snd_ctl_new1(&cdc_dma_config_controls[0],
  11261. dai_data));
  11262. break;
  11263. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  11264. rc = snd_ctl_add(dai->component->card->snd_card,
  11265. snd_ctl_new1(&cdc_dma_config_controls[1],
  11266. dai_data));
  11267. break;
  11268. default:
  11269. break;
  11270. }
  11271. if (rc < 0)
  11272. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  11273. __func__, dai->name);
  11274. if (dai_data->is_island_dai)
  11275. rc = msm_dai_q6_add_island_mx_ctls(
  11276. dai->component->card->snd_card,
  11277. dai->name, dai->id,
  11278. (void *)dai_data);
  11279. rc = msm_dai_q6_dai_add_route(dai);
  11280. return rc;
  11281. }
  11282. static int msm_dai_q6_dai_cdc_dma_remove(struct snd_soc_dai *dai)
  11283. {
  11284. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11285. dev_get_drvdata(dai->dev);
  11286. int rc = 0;
  11287. /* If AFE port is still up, close it */
  11288. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11289. dev_dbg(dai->dev, "%s: stop codec dma port:%d\n", __func__,
  11290. dai->id);
  11291. rc = afe_close(dai->id); /* can block */
  11292. if (rc < 0)
  11293. dev_err(dai->dev, "fail to close AFE port\n");
  11294. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  11295. }
  11296. return rc;
  11297. }
  11298. static int msm_dai_q6_cdc_dma_set_channel_map(struct snd_soc_dai *dai,
  11299. unsigned int tx_num_ch, unsigned int *tx_ch_mask,
  11300. unsigned int rx_num_ch, unsigned int *rx_ch_mask)
  11301. {
  11302. int rc = 0;
  11303. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11304. dev_get_drvdata(dai->dev);
  11305. unsigned int ch_mask = 0, ch_num = 0;
  11306. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  11307. switch (dai->id) {
  11308. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  11309. case AFE_PORT_ID_WSA_CODEC_DMA_RX_1:
  11310. case AFE_PORT_ID_RX_CODEC_DMA_RX_0:
  11311. case AFE_PORT_ID_RX_CODEC_DMA_RX_1:
  11312. case AFE_PORT_ID_RX_CODEC_DMA_RX_2:
  11313. case AFE_PORT_ID_RX_CODEC_DMA_RX_3:
  11314. case AFE_PORT_ID_RX_CODEC_DMA_RX_4:
  11315. case AFE_PORT_ID_RX_CODEC_DMA_RX_5:
  11316. case AFE_PORT_ID_RX_CODEC_DMA_RX_6:
  11317. case AFE_PORT_ID_RX_CODEC_DMA_RX_7:
  11318. if (!rx_ch_mask) {
  11319. dev_err(dai->dev, "%s: invalid rx ch mask\n", __func__);
  11320. return -EINVAL;
  11321. }
  11322. if (rx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  11323. dev_err(dai->dev, "%s: invalid rx_num_ch %d\n",
  11324. __func__, rx_num_ch);
  11325. return -EINVAL;
  11326. }
  11327. ch_mask = *rx_ch_mask;
  11328. ch_num = rx_num_ch;
  11329. break;
  11330. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  11331. case AFE_PORT_ID_WSA_CODEC_DMA_TX_1:
  11332. case AFE_PORT_ID_WSA_CODEC_DMA_TX_2:
  11333. case AFE_PORT_ID_VA_CODEC_DMA_TX_0:
  11334. case AFE_PORT_ID_VA_CODEC_DMA_TX_1:
  11335. case AFE_PORT_ID_TX_CODEC_DMA_TX_0:
  11336. case AFE_PORT_ID_TX_CODEC_DMA_TX_1:
  11337. case AFE_PORT_ID_TX_CODEC_DMA_TX_2:
  11338. case AFE_PORT_ID_TX_CODEC_DMA_TX_3:
  11339. case AFE_PORT_ID_TX_CODEC_DMA_TX_4:
  11340. case AFE_PORT_ID_TX_CODEC_DMA_TX_5:
  11341. if (!tx_ch_mask) {
  11342. dev_err(dai->dev, "%s: invalid tx ch mask\n", __func__);
  11343. return -EINVAL;
  11344. }
  11345. if (tx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  11346. dev_err(dai->dev, "%s: invalid tx_num_ch %d\n",
  11347. __func__, tx_num_ch);
  11348. return -EINVAL;
  11349. }
  11350. ch_mask = *tx_ch_mask;
  11351. ch_num = tx_num_ch;
  11352. break;
  11353. default:
  11354. dev_err(dai->dev, "%s: invalid dai id %d\n", __func__, dai->id);
  11355. return -EINVAL;
  11356. }
  11357. dai_data->port_config.cdc_dma.active_channels_mask = ch_mask;
  11358. dev_dbg(dai->dev, "%s: CDC_DMA_%d_ch cnt[%d] ch mask[0x%x]\n", __func__,
  11359. dai->id, ch_num, ch_mask);
  11360. return rc;
  11361. }
  11362. static int msm_dai_q6_cdc_dma_hw_params(
  11363. struct snd_pcm_substream *substream,
  11364. struct snd_pcm_hw_params *params,
  11365. struct snd_soc_dai *dai)
  11366. {
  11367. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11368. dev_get_drvdata(dai->dev);
  11369. switch (params_format(params)) {
  11370. case SNDRV_PCM_FORMAT_S16_LE:
  11371. case SNDRV_PCM_FORMAT_SPECIAL:
  11372. dai_data->port_config.cdc_dma.bit_width = 16;
  11373. break;
  11374. case SNDRV_PCM_FORMAT_S24_LE:
  11375. case SNDRV_PCM_FORMAT_S24_3LE:
  11376. dai_data->port_config.cdc_dma.bit_width = 24;
  11377. break;
  11378. case SNDRV_PCM_FORMAT_S32_LE:
  11379. dai_data->port_config.cdc_dma.bit_width = 32;
  11380. break;
  11381. default:
  11382. dev_err(dai->dev, "%s: format %d\n",
  11383. __func__, params_format(params));
  11384. return -EINVAL;
  11385. }
  11386. dai_data->rate = params_rate(params);
  11387. dai_data->channels = params_channels(params);
  11388. dai_data->port_config.cdc_dma.cdc_dma_cfg_minor_version =
  11389. AFE_API_VERSION_CODEC_DMA_CONFIG;
  11390. dai_data->port_config.cdc_dma.sample_rate = dai_data->rate;
  11391. dai_data->port_config.cdc_dma.num_channels = dai_data->channels;
  11392. dev_dbg(dai->dev, "%s: bit_wd[%hu] format[%hu]\n"
  11393. "num_channel %hu sample_rate %d\n", __func__,
  11394. dai_data->port_config.cdc_dma.bit_width,
  11395. dai_data->port_config.cdc_dma.data_format,
  11396. dai_data->port_config.cdc_dma.num_channels,
  11397. dai_data->rate);
  11398. return 0;
  11399. }
  11400. static int msm_dai_q6_cdc_dma_prepare(struct snd_pcm_substream *substream,
  11401. struct snd_soc_dai *dai)
  11402. {
  11403. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  11404. dev_get_drvdata(dai->dev);
  11405. int rc = 0;
  11406. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11407. if ((dai->id == AFE_PORT_ID_WSA_CODEC_DMA_TX_0) &&
  11408. (dai_data->port_config.cdc_dma.data_format == 1))
  11409. dai_data->port_config.cdc_dma.data_format =
  11410. AFE_LINEAR_PCM_DATA_PACKED_16BIT;
  11411. rc = afe_port_start(dai->id, &dai_data->port_config,
  11412. dai_data->rate);
  11413. if (rc < 0)
  11414. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  11415. dai->id);
  11416. else
  11417. set_bit(STATUS_PORT_STARTED,
  11418. dai_data->status_mask);
  11419. }
  11420. return rc;
  11421. }
  11422. static void msm_dai_q6_cdc_dma_shutdown(struct snd_pcm_substream *substream,
  11423. struct snd_soc_dai *dai)
  11424. {
  11425. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  11426. int rc = 0;
  11427. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  11428. dev_dbg(dai->dev, "%s: stop AFE port:%d\n", __func__,
  11429. dai->id);
  11430. rc = afe_close(dai->id); /* can block */
  11431. if (rc < 0)
  11432. dev_err(dai->dev, "fail to close AFE port\n");
  11433. dev_dbg(dai->dev, "%s: dai_data->status_mask = %ld\n", __func__,
  11434. *dai_data->status_mask);
  11435. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  11436. }
  11437. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  11438. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  11439. }
  11440. static struct snd_soc_dai_ops msm_dai_q6_cdc_dma_ops = {
  11441. .prepare = msm_dai_q6_cdc_dma_prepare,
  11442. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  11443. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  11444. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  11445. };
  11446. static struct snd_soc_dai_ops msm_dai_q6_cdc_wsa_dma_ops = {
  11447. .prepare = msm_dai_q6_cdc_dma_prepare,
  11448. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  11449. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  11450. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  11451. .digital_mute = msm_dai_q6_spk_digital_mute,
  11452. };
  11453. static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = {
  11454. {
  11455. .playback = {
  11456. .stream_name = "WSA CDC DMA0 Playback",
  11457. .aif_name = "WSA_CDC_DMA_RX_0",
  11458. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11459. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11460. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11461. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11462. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11463. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11464. SNDRV_PCM_RATE_384000,
  11465. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11466. SNDRV_PCM_FMTBIT_S24_LE |
  11467. SNDRV_PCM_FMTBIT_S24_3LE |
  11468. SNDRV_PCM_FMTBIT_S32_LE,
  11469. .channels_min = 1,
  11470. .channels_max = 4,
  11471. .rate_min = 8000,
  11472. .rate_max = 384000,
  11473. },
  11474. .name = "WSA_CDC_DMA_RX_0",
  11475. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  11476. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0,
  11477. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11478. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11479. },
  11480. {
  11481. .capture = {
  11482. .stream_name = "WSA CDC DMA0 Capture",
  11483. .aif_name = "WSA_CDC_DMA_TX_0",
  11484. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11485. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11486. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11487. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11488. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11489. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11490. SNDRV_PCM_RATE_384000,
  11491. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11492. SNDRV_PCM_FMTBIT_S24_LE |
  11493. SNDRV_PCM_FMTBIT_S24_3LE |
  11494. SNDRV_PCM_FMTBIT_S32_LE,
  11495. .channels_min = 1,
  11496. .channels_max = 4,
  11497. .rate_min = 8000,
  11498. .rate_max = 384000,
  11499. },
  11500. .name = "WSA_CDC_DMA_TX_0",
  11501. .ops = &msm_dai_q6_cdc_dma_ops,
  11502. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0,
  11503. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11504. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11505. },
  11506. {
  11507. .playback = {
  11508. .stream_name = "WSA CDC DMA1 Playback",
  11509. .aif_name = "WSA_CDC_DMA_RX_1",
  11510. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11511. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11512. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11513. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11514. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11515. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11516. SNDRV_PCM_RATE_384000,
  11517. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11518. SNDRV_PCM_FMTBIT_S24_LE |
  11519. SNDRV_PCM_FMTBIT_S24_3LE |
  11520. SNDRV_PCM_FMTBIT_S32_LE,
  11521. .channels_min = 1,
  11522. .channels_max = 2,
  11523. .rate_min = 8000,
  11524. .rate_max = 384000,
  11525. },
  11526. .name = "WSA_CDC_DMA_RX_1",
  11527. .ops = &msm_dai_q6_cdc_wsa_dma_ops,
  11528. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1,
  11529. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11530. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11531. },
  11532. {
  11533. .capture = {
  11534. .stream_name = "WSA CDC DMA1 Capture",
  11535. .aif_name = "WSA_CDC_DMA_TX_1",
  11536. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11537. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11538. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11539. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11540. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11541. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11542. SNDRV_PCM_RATE_384000,
  11543. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11544. SNDRV_PCM_FMTBIT_S24_LE |
  11545. SNDRV_PCM_FMTBIT_S24_3LE |
  11546. SNDRV_PCM_FMTBIT_S32_LE,
  11547. .channels_min = 1,
  11548. .channels_max = 2,
  11549. .rate_min = 8000,
  11550. .rate_max = 384000,
  11551. },
  11552. .name = "WSA_CDC_DMA_TX_1",
  11553. .ops = &msm_dai_q6_cdc_dma_ops,
  11554. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1,
  11555. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11556. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11557. },
  11558. {
  11559. .capture = {
  11560. .stream_name = "WSA CDC DMA2 Capture",
  11561. .aif_name = "WSA_CDC_DMA_TX_2",
  11562. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11563. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11564. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11565. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11566. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11567. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11568. SNDRV_PCM_RATE_384000,
  11569. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11570. SNDRV_PCM_FMTBIT_S24_LE |
  11571. SNDRV_PCM_FMTBIT_S24_3LE |
  11572. SNDRV_PCM_FMTBIT_S32_LE,
  11573. .channels_min = 1,
  11574. .channels_max = 1,
  11575. .rate_min = 8000,
  11576. .rate_max = 384000,
  11577. },
  11578. .name = "WSA_CDC_DMA_TX_2",
  11579. .ops = &msm_dai_q6_cdc_dma_ops,
  11580. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2,
  11581. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11582. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11583. },
  11584. {
  11585. .capture = {
  11586. .stream_name = "VA CDC DMA0 Capture",
  11587. .aif_name = "VA_CDC_DMA_TX_0",
  11588. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11589. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11590. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11591. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11592. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11593. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11594. SNDRV_PCM_RATE_384000,
  11595. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11596. SNDRV_PCM_FMTBIT_S24_LE |
  11597. SNDRV_PCM_FMTBIT_S24_3LE,
  11598. .channels_min = 1,
  11599. .channels_max = 8,
  11600. .rate_min = 8000,
  11601. .rate_max = 384000,
  11602. },
  11603. .name = "VA_CDC_DMA_TX_0",
  11604. .ops = &msm_dai_q6_cdc_dma_ops,
  11605. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_0,
  11606. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11607. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11608. },
  11609. {
  11610. .capture = {
  11611. .stream_name = "VA CDC DMA1 Capture",
  11612. .aif_name = "VA_CDC_DMA_TX_1",
  11613. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11614. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11615. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11616. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11617. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11618. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11619. SNDRV_PCM_RATE_384000,
  11620. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11621. SNDRV_PCM_FMTBIT_S24_LE |
  11622. SNDRV_PCM_FMTBIT_S24_3LE,
  11623. .channels_min = 1,
  11624. .channels_max = 8,
  11625. .rate_min = 8000,
  11626. .rate_max = 384000,
  11627. },
  11628. .name = "VA_CDC_DMA_TX_1",
  11629. .ops = &msm_dai_q6_cdc_dma_ops,
  11630. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_1,
  11631. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11632. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11633. },
  11634. {
  11635. .capture = {
  11636. .stream_name = "VA CDC DMA2 Capture",
  11637. .aif_name = "VA_CDC_DMA_TX_2",
  11638. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11639. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11640. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11641. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11642. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11643. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11644. SNDRV_PCM_RATE_384000,
  11645. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11646. SNDRV_PCM_FMTBIT_S24_LE |
  11647. SNDRV_PCM_FMTBIT_S24_3LE,
  11648. .channels_min = 1,
  11649. .channels_max = 8,
  11650. .rate_min = 8000,
  11651. .rate_max = 384000,
  11652. },
  11653. .name = "VA_CDC_DMA_TX_2",
  11654. .ops = &msm_dai_q6_cdc_dma_ops,
  11655. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_2,
  11656. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11657. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11658. },
  11659. {
  11660. .playback = {
  11661. .stream_name = "RX CDC DMA0 Playback",
  11662. .aif_name = "RX_CDC_DMA_RX_0",
  11663. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11664. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11665. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11666. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11667. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11668. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11669. SNDRV_PCM_RATE_384000,
  11670. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11671. SNDRV_PCM_FMTBIT_S24_LE |
  11672. SNDRV_PCM_FMTBIT_S24_3LE |
  11673. SNDRV_PCM_FMTBIT_S32_LE,
  11674. .channels_min = 1,
  11675. .channels_max = 2,
  11676. .rate_min = 8000,
  11677. .rate_max = 384000,
  11678. },
  11679. .ops = &msm_dai_q6_cdc_dma_ops,
  11680. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_0,
  11681. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11682. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11683. },
  11684. {
  11685. .capture = {
  11686. .stream_name = "TX CDC DMA0 Capture",
  11687. .aif_name = "TX_CDC_DMA_TX_0",
  11688. .rates = SNDRV_PCM_RATE_8000 |
  11689. SNDRV_PCM_RATE_16000 |
  11690. SNDRV_PCM_RATE_32000 |
  11691. SNDRV_PCM_RATE_48000 |
  11692. SNDRV_PCM_RATE_96000 |
  11693. SNDRV_PCM_RATE_192000 |
  11694. SNDRV_PCM_RATE_384000,
  11695. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11696. SNDRV_PCM_FMTBIT_S24_LE |
  11697. SNDRV_PCM_FMTBIT_S24_3LE |
  11698. SNDRV_PCM_FMTBIT_S32_LE,
  11699. .channels_min = 1,
  11700. .channels_max = 3,
  11701. .rate_min = 8000,
  11702. .rate_max = 384000,
  11703. },
  11704. .ops = &msm_dai_q6_cdc_dma_ops,
  11705. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_0,
  11706. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11707. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11708. },
  11709. {
  11710. .playback = {
  11711. .stream_name = "RX CDC DMA1 Playback",
  11712. .aif_name = "RX_CDC_DMA_RX_1",
  11713. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11714. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11715. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11716. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11717. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11718. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11719. SNDRV_PCM_RATE_384000,
  11720. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11721. SNDRV_PCM_FMTBIT_S24_LE |
  11722. SNDRV_PCM_FMTBIT_S24_3LE |
  11723. SNDRV_PCM_FMTBIT_S32_LE,
  11724. .channels_min = 1,
  11725. .channels_max = 2,
  11726. .rate_min = 8000,
  11727. .rate_max = 384000,
  11728. },
  11729. .ops = &msm_dai_q6_cdc_dma_ops,
  11730. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_1,
  11731. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11732. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11733. },
  11734. {
  11735. .capture = {
  11736. .stream_name = "TX CDC DMA1 Capture",
  11737. .aif_name = "TX_CDC_DMA_TX_1",
  11738. .rates = SNDRV_PCM_RATE_8000 |
  11739. SNDRV_PCM_RATE_16000 |
  11740. SNDRV_PCM_RATE_32000 |
  11741. SNDRV_PCM_RATE_48000 |
  11742. SNDRV_PCM_RATE_96000 |
  11743. SNDRV_PCM_RATE_192000 |
  11744. SNDRV_PCM_RATE_384000,
  11745. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11746. SNDRV_PCM_FMTBIT_S24_LE |
  11747. SNDRV_PCM_FMTBIT_S24_3LE |
  11748. SNDRV_PCM_FMTBIT_S32_LE,
  11749. .channels_min = 1,
  11750. .channels_max = 3,
  11751. .rate_min = 8000,
  11752. .rate_max = 384000,
  11753. },
  11754. .ops = &msm_dai_q6_cdc_dma_ops,
  11755. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_1,
  11756. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11757. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11758. },
  11759. {
  11760. .playback = {
  11761. .stream_name = "RX CDC DMA2 Playback",
  11762. .aif_name = "RX_CDC_DMA_RX_2",
  11763. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11764. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11765. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11766. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11767. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11768. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11769. SNDRV_PCM_RATE_384000,
  11770. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11771. SNDRV_PCM_FMTBIT_S24_LE |
  11772. SNDRV_PCM_FMTBIT_S24_3LE |
  11773. SNDRV_PCM_FMTBIT_S32_LE,
  11774. .channels_min = 1,
  11775. .channels_max = 1,
  11776. .rate_min = 8000,
  11777. .rate_max = 384000,
  11778. },
  11779. .ops = &msm_dai_q6_cdc_dma_ops,
  11780. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_2,
  11781. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11782. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11783. },
  11784. {
  11785. .capture = {
  11786. .stream_name = "TX CDC DMA2 Capture",
  11787. .aif_name = "TX_CDC_DMA_TX_2",
  11788. .rates = SNDRV_PCM_RATE_8000 |
  11789. SNDRV_PCM_RATE_16000 |
  11790. SNDRV_PCM_RATE_32000 |
  11791. SNDRV_PCM_RATE_48000 |
  11792. SNDRV_PCM_RATE_96000 |
  11793. SNDRV_PCM_RATE_192000 |
  11794. SNDRV_PCM_RATE_384000,
  11795. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11796. SNDRV_PCM_FMTBIT_S24_LE |
  11797. SNDRV_PCM_FMTBIT_S24_3LE |
  11798. SNDRV_PCM_FMTBIT_S32_LE,
  11799. .channels_min = 1,
  11800. .channels_max = 4,
  11801. .rate_min = 8000,
  11802. .rate_max = 384000,
  11803. },
  11804. .ops = &msm_dai_q6_cdc_dma_ops,
  11805. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_2,
  11806. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11807. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11808. }, {
  11809. .playback = {
  11810. .stream_name = "RX CDC DMA3 Playback",
  11811. .aif_name = "RX_CDC_DMA_RX_3",
  11812. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11813. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11814. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11815. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11816. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11817. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11818. SNDRV_PCM_RATE_384000,
  11819. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11820. SNDRV_PCM_FMTBIT_S24_LE |
  11821. SNDRV_PCM_FMTBIT_S24_3LE |
  11822. SNDRV_PCM_FMTBIT_S32_LE,
  11823. .channels_min = 1,
  11824. .channels_max = 1,
  11825. .rate_min = 8000,
  11826. .rate_max = 384000,
  11827. },
  11828. .ops = &msm_dai_q6_cdc_dma_ops,
  11829. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_3,
  11830. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11831. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11832. },
  11833. {
  11834. .capture = {
  11835. .stream_name = "TX CDC DMA3 Capture",
  11836. .aif_name = "TX_CDC_DMA_TX_3",
  11837. .rates = SNDRV_PCM_RATE_8000 |
  11838. SNDRV_PCM_RATE_16000 |
  11839. SNDRV_PCM_RATE_32000 |
  11840. SNDRV_PCM_RATE_48000 |
  11841. SNDRV_PCM_RATE_96000 |
  11842. SNDRV_PCM_RATE_192000 |
  11843. SNDRV_PCM_RATE_384000,
  11844. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11845. SNDRV_PCM_FMTBIT_S24_LE |
  11846. SNDRV_PCM_FMTBIT_S24_3LE |
  11847. SNDRV_PCM_FMTBIT_S32_LE,
  11848. .channels_min = 1,
  11849. .channels_max = 8,
  11850. .rate_min = 8000,
  11851. .rate_max = 384000,
  11852. },
  11853. .ops = &msm_dai_q6_cdc_dma_ops,
  11854. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_3,
  11855. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11856. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11857. },
  11858. {
  11859. .playback = {
  11860. .stream_name = "RX CDC DMA4 Playback",
  11861. .aif_name = "RX_CDC_DMA_RX_4",
  11862. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11863. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11864. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11865. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11866. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11867. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11868. SNDRV_PCM_RATE_384000,
  11869. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11870. SNDRV_PCM_FMTBIT_S24_LE |
  11871. SNDRV_PCM_FMTBIT_S24_3LE |
  11872. SNDRV_PCM_FMTBIT_S32_LE,
  11873. .channels_min = 1,
  11874. .channels_max = 6,
  11875. .rate_min = 8000,
  11876. .rate_max = 384000,
  11877. },
  11878. .ops = &msm_dai_q6_cdc_dma_ops,
  11879. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_4,
  11880. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11881. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11882. },
  11883. {
  11884. .capture = {
  11885. .stream_name = "TX CDC DMA4 Capture",
  11886. .aif_name = "TX_CDC_DMA_TX_4",
  11887. .rates = SNDRV_PCM_RATE_8000 |
  11888. SNDRV_PCM_RATE_16000 |
  11889. SNDRV_PCM_RATE_32000 |
  11890. SNDRV_PCM_RATE_48000 |
  11891. SNDRV_PCM_RATE_96000 |
  11892. SNDRV_PCM_RATE_192000 |
  11893. SNDRV_PCM_RATE_384000,
  11894. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11895. SNDRV_PCM_FMTBIT_S24_LE |
  11896. SNDRV_PCM_FMTBIT_S24_3LE |
  11897. SNDRV_PCM_FMTBIT_S32_LE,
  11898. .channels_min = 1,
  11899. .channels_max = 8,
  11900. .rate_min = 8000,
  11901. .rate_max = 384000,
  11902. },
  11903. .ops = &msm_dai_q6_cdc_dma_ops,
  11904. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_4,
  11905. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11906. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11907. },
  11908. {
  11909. .playback = {
  11910. .stream_name = "RX CDC DMA5 Playback",
  11911. .aif_name = "RX_CDC_DMA_RX_5",
  11912. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11913. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11914. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11915. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11916. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11917. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11918. SNDRV_PCM_RATE_384000,
  11919. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11920. SNDRV_PCM_FMTBIT_S24_LE |
  11921. SNDRV_PCM_FMTBIT_S24_3LE |
  11922. SNDRV_PCM_FMTBIT_S32_LE,
  11923. .channels_min = 1,
  11924. .channels_max = 1,
  11925. .rate_min = 8000,
  11926. .rate_max = 384000,
  11927. },
  11928. .ops = &msm_dai_q6_cdc_dma_ops,
  11929. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_5,
  11930. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11931. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11932. },
  11933. {
  11934. .capture = {
  11935. .stream_name = "TX CDC DMA5 Capture",
  11936. .aif_name = "TX_CDC_DMA_TX_5",
  11937. .rates = SNDRV_PCM_RATE_8000 |
  11938. SNDRV_PCM_RATE_16000 |
  11939. SNDRV_PCM_RATE_32000 |
  11940. SNDRV_PCM_RATE_48000 |
  11941. SNDRV_PCM_RATE_96000 |
  11942. SNDRV_PCM_RATE_192000 |
  11943. SNDRV_PCM_RATE_384000,
  11944. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11945. SNDRV_PCM_FMTBIT_S24_LE |
  11946. SNDRV_PCM_FMTBIT_S24_3LE |
  11947. SNDRV_PCM_FMTBIT_S32_LE,
  11948. .channels_min = 1,
  11949. .channels_max = 4,
  11950. .rate_min = 8000,
  11951. .rate_max = 384000,
  11952. },
  11953. .ops = &msm_dai_q6_cdc_dma_ops,
  11954. .id = AFE_PORT_ID_TX_CODEC_DMA_TX_5,
  11955. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11956. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11957. },
  11958. {
  11959. .playback = {
  11960. .stream_name = "RX CDC DMA6 Playback",
  11961. .aif_name = "RX_CDC_DMA_RX_6",
  11962. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11963. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11964. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11965. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11966. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11967. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11968. SNDRV_PCM_RATE_384000,
  11969. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11970. SNDRV_PCM_FMTBIT_S24_LE |
  11971. SNDRV_PCM_FMTBIT_S24_3LE |
  11972. SNDRV_PCM_FMTBIT_S32_LE,
  11973. .channels_min = 1,
  11974. .channels_max = 4,
  11975. .rate_min = 8000,
  11976. .rate_max = 384000,
  11977. },
  11978. .ops = &msm_dai_q6_cdc_dma_ops,
  11979. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_6,
  11980. .probe = msm_dai_q6_dai_cdc_dma_probe,
  11981. .remove = msm_dai_q6_dai_cdc_dma_remove,
  11982. },
  11983. {
  11984. .playback = {
  11985. .stream_name = "RX CDC DMA7 Playback",
  11986. .aif_name = "RX_CDC_DMA_RX_7",
  11987. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  11988. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  11989. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  11990. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  11991. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  11992. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  11993. SNDRV_PCM_RATE_384000,
  11994. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  11995. SNDRV_PCM_FMTBIT_S24_LE |
  11996. SNDRV_PCM_FMTBIT_S24_3LE |
  11997. SNDRV_PCM_FMTBIT_S32_LE,
  11998. .channels_min = 1,
  11999. .channels_max = 2,
  12000. .rate_min = 8000,
  12001. .rate_max = 384000,
  12002. },
  12003. .ops = &msm_dai_q6_cdc_dma_ops,
  12004. .id = AFE_PORT_ID_RX_CODEC_DMA_RX_7,
  12005. .probe = msm_dai_q6_dai_cdc_dma_probe,
  12006. .remove = msm_dai_q6_dai_cdc_dma_remove,
  12007. },
  12008. };
  12009. static const struct snd_soc_component_driver msm_q6_cdc_dma_dai_component = {
  12010. .name = "msm-dai-cdc-dma-dev",
  12011. };
  12012. /* DT related probe for each codec DMA interface device */
  12013. static int msm_dai_q6_cdc_dma_dev_probe(struct platform_device *pdev)
  12014. {
  12015. const char *q6_cdc_dma_dev_id = "qcom,msm-dai-cdc-dma-dev-id";
  12016. u32 cdc_dma_id = 0;
  12017. int i;
  12018. int rc = 0;
  12019. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  12020. rc = of_property_read_u32(pdev->dev.of_node, q6_cdc_dma_dev_id,
  12021. &cdc_dma_id);
  12022. if (rc) {
  12023. dev_err(&pdev->dev,
  12024. "%s: missing 0x%x in dt node\n", __func__, cdc_dma_id);
  12025. return rc;
  12026. }
  12027. dev_dbg(&pdev->dev, "%s: dev name %s dev id 0x%x\n", __func__,
  12028. dev_name(&pdev->dev), cdc_dma_id);
  12029. pdev->id = cdc_dma_id;
  12030. dai_data = devm_kzalloc(&pdev->dev,
  12031. sizeof(struct msm_dai_q6_cdc_dma_dai_data),
  12032. GFP_KERNEL);
  12033. if (!dai_data)
  12034. return -ENOMEM;
  12035. rc = of_property_read_u32(pdev->dev.of_node,
  12036. "qcom,msm-dai-is-island-supported",
  12037. &dai_data->is_island_dai);
  12038. if (rc)
  12039. dev_dbg(&pdev->dev, "island supported entry not found\n");
  12040. dev_set_drvdata(&pdev->dev, dai_data);
  12041. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_cdc_dma_dai); i++) {
  12042. if (msm_dai_q6_cdc_dma_dai[i].id == cdc_dma_id) {
  12043. return snd_soc_register_component(&pdev->dev,
  12044. &msm_q6_cdc_dma_dai_component,
  12045. &msm_dai_q6_cdc_dma_dai[i], 1);
  12046. }
  12047. }
  12048. return -ENODEV;
  12049. }
  12050. static int msm_dai_q6_cdc_dma_dev_remove(struct platform_device *pdev)
  12051. {
  12052. snd_soc_unregister_component(&pdev->dev);
  12053. return 0;
  12054. }
  12055. static const struct of_device_id msm_dai_q6_cdc_dma_dev_dt_match[] = {
  12056. { .compatible = "qcom,msm-dai-cdc-dma-dev", },
  12057. { }
  12058. };
  12059. MODULE_DEVICE_TABLE(of, msm_dai_q6_cdc_dma_dev_dt_match);
  12060. static struct platform_driver msm_dai_q6_cdc_dma_driver = {
  12061. .probe = msm_dai_q6_cdc_dma_dev_probe,
  12062. .remove = msm_dai_q6_cdc_dma_dev_remove,
  12063. .driver = {
  12064. .name = "msm-dai-cdc-dma-dev",
  12065. .owner = THIS_MODULE,
  12066. .of_match_table = msm_dai_q6_cdc_dma_dev_dt_match,
  12067. .suppress_bind_attrs = true,
  12068. },
  12069. };
  12070. /* DT related probe for codec DMA interface device group */
  12071. static int msm_dai_cdc_dma_q6_probe(struct platform_device *pdev)
  12072. {
  12073. int rc;
  12074. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  12075. if (rc) {
  12076. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  12077. __func__, rc);
  12078. } else
  12079. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  12080. return rc;
  12081. }
  12082. static int msm_dai_cdc_dma_q6_remove(struct platform_device *pdev)
  12083. {
  12084. of_platform_depopulate(&pdev->dev);
  12085. return 0;
  12086. }
  12087. static const struct of_device_id msm_dai_cdc_dma_dt_match[] = {
  12088. { .compatible = "qcom,msm-dai-cdc-dma", },
  12089. { }
  12090. };
  12091. MODULE_DEVICE_TABLE(of, msm_dai_cdc_dma_dt_match);
  12092. static struct platform_driver msm_dai_cdc_dma_q6 = {
  12093. .probe = msm_dai_cdc_dma_q6_probe,
  12094. .remove = msm_dai_cdc_dma_q6_remove,
  12095. .driver = {
  12096. .name = "msm-dai-cdc-dma",
  12097. .owner = THIS_MODULE,
  12098. .of_match_table = msm_dai_cdc_dma_dt_match,
  12099. .suppress_bind_attrs = true,
  12100. },
  12101. };
  12102. int __init msm_dai_q6_init(void)
  12103. {
  12104. int rc;
  12105. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  12106. if (rc) {
  12107. pr_err("%s: fail to register auxpcm dev driver", __func__);
  12108. goto fail;
  12109. }
  12110. rc = platform_driver_register(&msm_dai_q6);
  12111. if (rc) {
  12112. pr_err("%s: fail to register dai q6 driver", __func__);
  12113. goto dai_q6_fail;
  12114. }
  12115. rc = platform_driver_register(&msm_dai_q6_dev);
  12116. if (rc) {
  12117. pr_err("%s: fail to register dai q6 dev driver", __func__);
  12118. goto dai_q6_dev_fail;
  12119. }
  12120. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  12121. if (rc) {
  12122. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  12123. goto dai_q6_mi2s_drv_fail;
  12124. }
  12125. rc = platform_driver_register(&msm_dai_q6_meta_mi2s_driver);
  12126. if (rc) {
  12127. pr_err("%s: fail to register dai META MI2S dev drv\n",
  12128. __func__);
  12129. goto dai_q6_meta_mi2s_drv_fail;
  12130. }
  12131. rc = platform_driver_register(&msm_dai_mi2s_q6);
  12132. if (rc) {
  12133. pr_err("%s: fail to register dai MI2S\n", __func__);
  12134. goto dai_mi2s_q6_fail;
  12135. }
  12136. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  12137. if (rc) {
  12138. pr_err("%s: fail to register dai SPDIF\n", __func__);
  12139. goto dai_spdif_q6_fail;
  12140. }
  12141. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  12142. if (rc) {
  12143. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  12144. goto dai_q6_tdm_drv_fail;
  12145. }
  12146. rc = platform_driver_register(&msm_dai_tdm_q6);
  12147. if (rc) {
  12148. pr_err("%s: fail to register dai TDM\n", __func__);
  12149. goto dai_tdm_q6_fail;
  12150. }
  12151. rc = platform_driver_register(&msm_dai_q6_cdc_dma_driver);
  12152. if (rc) {
  12153. pr_err("%s: fail to register dai CDC DMA dev\n", __func__);
  12154. goto dai_cdc_dma_q6_dev_fail;
  12155. }
  12156. rc = platform_driver_register(&msm_dai_cdc_dma_q6);
  12157. if (rc) {
  12158. pr_err("%s: fail to register dai CDC DMA\n", __func__);
  12159. goto dai_cdc_dma_q6_fail;
  12160. }
  12161. return rc;
  12162. dai_cdc_dma_q6_fail:
  12163. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  12164. dai_cdc_dma_q6_dev_fail:
  12165. platform_driver_unregister(&msm_dai_tdm_q6);
  12166. dai_tdm_q6_fail:
  12167. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  12168. dai_q6_tdm_drv_fail:
  12169. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  12170. dai_spdif_q6_fail:
  12171. platform_driver_unregister(&msm_dai_mi2s_q6);
  12172. dai_mi2s_q6_fail:
  12173. platform_driver_unregister(&msm_dai_q6_meta_mi2s_driver);
  12174. dai_q6_meta_mi2s_drv_fail:
  12175. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  12176. dai_q6_mi2s_drv_fail:
  12177. platform_driver_unregister(&msm_dai_q6_dev);
  12178. dai_q6_dev_fail:
  12179. platform_driver_unregister(&msm_dai_q6);
  12180. dai_q6_fail:
  12181. platform_driver_unregister(&msm_auxpcm_dev_driver);
  12182. fail:
  12183. return rc;
  12184. }
  12185. void msm_dai_q6_exit(void)
  12186. {
  12187. platform_driver_unregister(&msm_dai_cdc_dma_q6);
  12188. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  12189. platform_driver_unregister(&msm_dai_tdm_q6);
  12190. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  12191. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  12192. platform_driver_unregister(&msm_dai_mi2s_q6);
  12193. platform_driver_unregister(&msm_dai_q6_meta_mi2s_driver);
  12194. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  12195. platform_driver_unregister(&msm_dai_q6_dev);
  12196. platform_driver_unregister(&msm_dai_q6);
  12197. platform_driver_unregister(&msm_auxpcm_dev_driver);
  12198. }
  12199. /* Module information */
  12200. MODULE_DESCRIPTION("MSM DSP DAI driver");
  12201. MODULE_LICENSE("GPL v2");