msm-dai-q6-v2.c 382 KB

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