msm-dai-q6-v2.c 289 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907
  1. /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/device.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/bitops.h>
  17. #include <linux/slab.h>
  18. #include <linux/clk.h>
  19. #include <linux/of_device.h>
  20. #include <sound/core.h>
  21. #include <sound/pcm.h>
  22. #include <sound/soc.h>
  23. #include <sound/pcm_params.h>
  24. #include <dsp/apr_audio-v2.h>
  25. #include <dsp/q6afe-v2.h>
  26. #include <dsp/q6core.h>
  27. #include "msm-dai-q6-v2.h"
  28. #include "codecs/core.h"
  29. #define MSM_DAI_PRI_AUXPCM_DT_DEV_ID 1
  30. #define MSM_DAI_SEC_AUXPCM_DT_DEV_ID 2
  31. #define MSM_DAI_TERT_AUXPCM_DT_DEV_ID 3
  32. #define MSM_DAI_QUAT_AUXPCM_DT_DEV_ID 4
  33. #define MSM_DAI_QUIN_AUXPCM_DT_DEV_ID 5
  34. #define spdif_clock_value(rate) (2*rate*32*2)
  35. #define CHANNEL_STATUS_SIZE 24
  36. #define CHANNEL_STATUS_MASK_INIT 0x0
  37. #define CHANNEL_STATUS_MASK 0x4
  38. #define AFE_API_VERSION_CLOCK_SET 1
  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. ENC_FMT_AAC_V2 = ASM_MEDIA_FMT_AAC_V2,
  48. ENC_FMT_APTX = ASM_MEDIA_FMT_APTX,
  49. ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
  50. ENC_FMT_CELT = ASM_MEDIA_FMT_CELT,
  51. ENC_FMT_LDAC = ASM_MEDIA_FMT_LDAC,
  52. ENC_FMT_APTX_ADAPTIVE = ASM_MEDIA_FMT_APTX_ADAPTIVE,
  53. };
  54. enum {
  55. SPKR_1,
  56. SPKR_2,
  57. };
  58. static const struct afe_clk_set lpass_clk_set_default = {
  59. AFE_API_VERSION_CLOCK_SET,
  60. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
  61. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  62. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  63. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  64. 0,
  65. };
  66. static const struct afe_clk_cfg lpass_clk_cfg_default = {
  67. AFE_API_VERSION_I2S_CONFIG,
  68. Q6AFE_LPASS_OSR_CLK_2_P048_MHZ,
  69. 0,
  70. Q6AFE_LPASS_CLK_SRC_INTERNAL,
  71. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  72. Q6AFE_LPASS_MODE_CLK1_VALID,
  73. 0,
  74. };
  75. enum {
  76. STATUS_PORT_STARTED, /* track if AFE port has started */
  77. /* track AFE Tx port status for bi-directional transfers */
  78. STATUS_TX_PORT,
  79. /* track AFE Rx port status for bi-directional transfers */
  80. STATUS_RX_PORT,
  81. STATUS_MAX
  82. };
  83. enum {
  84. RATE_8KHZ,
  85. RATE_16KHZ,
  86. RATE_MAX_NUM_OF_AUX_PCM_RATES,
  87. };
  88. enum {
  89. IDX_PRIMARY_TDM_RX_0,
  90. IDX_PRIMARY_TDM_RX_1,
  91. IDX_PRIMARY_TDM_RX_2,
  92. IDX_PRIMARY_TDM_RX_3,
  93. IDX_PRIMARY_TDM_RX_4,
  94. IDX_PRIMARY_TDM_RX_5,
  95. IDX_PRIMARY_TDM_RX_6,
  96. IDX_PRIMARY_TDM_RX_7,
  97. IDX_PRIMARY_TDM_TX_0,
  98. IDX_PRIMARY_TDM_TX_1,
  99. IDX_PRIMARY_TDM_TX_2,
  100. IDX_PRIMARY_TDM_TX_3,
  101. IDX_PRIMARY_TDM_TX_4,
  102. IDX_PRIMARY_TDM_TX_5,
  103. IDX_PRIMARY_TDM_TX_6,
  104. IDX_PRIMARY_TDM_TX_7,
  105. IDX_SECONDARY_TDM_RX_0,
  106. IDX_SECONDARY_TDM_RX_1,
  107. IDX_SECONDARY_TDM_RX_2,
  108. IDX_SECONDARY_TDM_RX_3,
  109. IDX_SECONDARY_TDM_RX_4,
  110. IDX_SECONDARY_TDM_RX_5,
  111. IDX_SECONDARY_TDM_RX_6,
  112. IDX_SECONDARY_TDM_RX_7,
  113. IDX_SECONDARY_TDM_TX_0,
  114. IDX_SECONDARY_TDM_TX_1,
  115. IDX_SECONDARY_TDM_TX_2,
  116. IDX_SECONDARY_TDM_TX_3,
  117. IDX_SECONDARY_TDM_TX_4,
  118. IDX_SECONDARY_TDM_TX_5,
  119. IDX_SECONDARY_TDM_TX_6,
  120. IDX_SECONDARY_TDM_TX_7,
  121. IDX_TERTIARY_TDM_RX_0,
  122. IDX_TERTIARY_TDM_RX_1,
  123. IDX_TERTIARY_TDM_RX_2,
  124. IDX_TERTIARY_TDM_RX_3,
  125. IDX_TERTIARY_TDM_RX_4,
  126. IDX_TERTIARY_TDM_RX_5,
  127. IDX_TERTIARY_TDM_RX_6,
  128. IDX_TERTIARY_TDM_RX_7,
  129. IDX_TERTIARY_TDM_TX_0,
  130. IDX_TERTIARY_TDM_TX_1,
  131. IDX_TERTIARY_TDM_TX_2,
  132. IDX_TERTIARY_TDM_TX_3,
  133. IDX_TERTIARY_TDM_TX_4,
  134. IDX_TERTIARY_TDM_TX_5,
  135. IDX_TERTIARY_TDM_TX_6,
  136. IDX_TERTIARY_TDM_TX_7,
  137. IDX_QUATERNARY_TDM_RX_0,
  138. IDX_QUATERNARY_TDM_RX_1,
  139. IDX_QUATERNARY_TDM_RX_2,
  140. IDX_QUATERNARY_TDM_RX_3,
  141. IDX_QUATERNARY_TDM_RX_4,
  142. IDX_QUATERNARY_TDM_RX_5,
  143. IDX_QUATERNARY_TDM_RX_6,
  144. IDX_QUATERNARY_TDM_RX_7,
  145. IDX_QUATERNARY_TDM_TX_0,
  146. IDX_QUATERNARY_TDM_TX_1,
  147. IDX_QUATERNARY_TDM_TX_2,
  148. IDX_QUATERNARY_TDM_TX_3,
  149. IDX_QUATERNARY_TDM_TX_4,
  150. IDX_QUATERNARY_TDM_TX_5,
  151. IDX_QUATERNARY_TDM_TX_6,
  152. IDX_QUATERNARY_TDM_TX_7,
  153. IDX_QUINARY_TDM_RX_0,
  154. IDX_QUINARY_TDM_RX_1,
  155. IDX_QUINARY_TDM_RX_2,
  156. IDX_QUINARY_TDM_RX_3,
  157. IDX_QUINARY_TDM_RX_4,
  158. IDX_QUINARY_TDM_RX_5,
  159. IDX_QUINARY_TDM_RX_6,
  160. IDX_QUINARY_TDM_RX_7,
  161. IDX_QUINARY_TDM_TX_0,
  162. IDX_QUINARY_TDM_TX_1,
  163. IDX_QUINARY_TDM_TX_2,
  164. IDX_QUINARY_TDM_TX_3,
  165. IDX_QUINARY_TDM_TX_4,
  166. IDX_QUINARY_TDM_TX_5,
  167. IDX_QUINARY_TDM_TX_6,
  168. IDX_QUINARY_TDM_TX_7,
  169. IDX_TDM_MAX,
  170. };
  171. enum {
  172. IDX_GROUP_PRIMARY_TDM_RX,
  173. IDX_GROUP_PRIMARY_TDM_TX,
  174. IDX_GROUP_SECONDARY_TDM_RX,
  175. IDX_GROUP_SECONDARY_TDM_TX,
  176. IDX_GROUP_TERTIARY_TDM_RX,
  177. IDX_GROUP_TERTIARY_TDM_TX,
  178. IDX_GROUP_QUATERNARY_TDM_RX,
  179. IDX_GROUP_QUATERNARY_TDM_TX,
  180. IDX_GROUP_QUINARY_TDM_RX,
  181. IDX_GROUP_QUINARY_TDM_TX,
  182. IDX_GROUP_TDM_MAX,
  183. };
  184. struct msm_dai_q6_dai_data {
  185. DECLARE_BITMAP(status_mask, STATUS_MAX);
  186. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  187. u32 rate;
  188. u32 channels;
  189. u32 bitwidth;
  190. u32 cal_mode;
  191. u32 afe_in_channels;
  192. u16 afe_in_bitformat;
  193. struct afe_enc_config enc_config;
  194. struct afe_dec_config dec_config;
  195. union afe_port_config port_config;
  196. u16 vi_feed_mono;
  197. };
  198. struct msm_dai_q6_spdif_dai_data {
  199. DECLARE_BITMAP(status_mask, STATUS_MAX);
  200. u32 rate;
  201. u32 channels;
  202. u32 bitwidth;
  203. struct afe_spdif_port_config spdif_port;
  204. };
  205. struct msm_dai_q6_mi2s_dai_config {
  206. u16 pdata_mi2s_lines;
  207. struct msm_dai_q6_dai_data mi2s_dai_data;
  208. };
  209. struct msm_dai_q6_mi2s_dai_data {
  210. u32 is_island_dai;
  211. struct msm_dai_q6_mi2s_dai_config tx_dai;
  212. struct msm_dai_q6_mi2s_dai_config rx_dai;
  213. };
  214. struct msm_dai_q6_cdc_dma_dai_data {
  215. DECLARE_BITMAP(status_mask, STATUS_MAX);
  216. DECLARE_BITMAP(hwfree_status, STATUS_MAX);
  217. u32 rate;
  218. u32 channels;
  219. u32 bitwidth;
  220. u32 is_island_dai;
  221. union afe_port_config port_config;
  222. };
  223. struct msm_dai_q6_auxpcm_dai_data {
  224. /* BITMAP to track Rx and Tx port usage count */
  225. DECLARE_BITMAP(auxpcm_port_status, STATUS_MAX);
  226. struct mutex rlock; /* auxpcm dev resource lock */
  227. u16 rx_pid; /* AUXPCM RX AFE port ID */
  228. u16 tx_pid; /* AUXPCM TX AFE port ID */
  229. u16 afe_clk_ver;
  230. u32 is_island_dai;
  231. struct afe_clk_cfg clk_cfg; /* hold LPASS clock configuration */
  232. struct afe_clk_set clk_set; /* hold LPASS clock configuration */
  233. struct msm_dai_q6_dai_data bdai_data; /* incoporate base DAI data */
  234. };
  235. struct msm_dai_q6_tdm_dai_data {
  236. DECLARE_BITMAP(status_mask, STATUS_MAX);
  237. u32 rate;
  238. u32 channels;
  239. u32 bitwidth;
  240. u32 num_group_ports;
  241. u32 is_island_dai;
  242. struct afe_clk_set clk_set; /* hold LPASS clock config. */
  243. union afe_port_group_config group_cfg; /* hold tdm group config */
  244. struct afe_tdm_port_config port_cfg; /* hold tdm config */
  245. };
  246. /* MI2S format field for AFE_PORT_CMD_I2S_CONFIG command
  247. * 0: linear PCM
  248. * 1: non-linear PCM
  249. * 2: PCM data in IEC 60968 container
  250. * 3: compressed data in IEC 60958 container
  251. */
  252. static const char *const mi2s_format[] = {
  253. "LPCM",
  254. "Compr",
  255. "LPCM-60958",
  256. "Compr-60958"
  257. };
  258. static const char *const mi2s_vi_feed_mono[] = {
  259. "Left",
  260. "Right",
  261. };
  262. static const struct soc_enum mi2s_config_enum[] = {
  263. SOC_ENUM_SINGLE_EXT(4, mi2s_format),
  264. SOC_ENUM_SINGLE_EXT(2, mi2s_vi_feed_mono),
  265. };
  266. static const char *const cdc_dma_format[] = {
  267. "UNPACKED",
  268. "PACKED_16B",
  269. };
  270. static const struct soc_enum cdc_dma_config_enum[] = {
  271. SOC_ENUM_SINGLE_EXT(2, cdc_dma_format),
  272. };
  273. static const char *const sb_format[] = {
  274. "UNPACKED",
  275. "PACKED_16B",
  276. "DSD_DOP",
  277. };
  278. static const struct soc_enum sb_config_enum[] = {
  279. SOC_ENUM_SINGLE_EXT(3, sb_format),
  280. };
  281. static const char *const tdm_data_format[] = {
  282. "LPCM",
  283. "Compr",
  284. "Gen Compr"
  285. };
  286. static const char *const tdm_header_type[] = {
  287. "Invalid",
  288. "Default",
  289. "Entertainment",
  290. };
  291. static const struct soc_enum tdm_config_enum[] = {
  292. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_data_format), tdm_data_format),
  293. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type),
  294. };
  295. static DEFINE_MUTEX(tdm_mutex);
  296. static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
  297. /* cache of group cfg per parent node */
  298. static struct afe_param_id_group_device_tdm_cfg tdm_group_cfg = {
  299. AFE_API_VERSION_GROUP_DEVICE_TDM_CONFIG,
  300. AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX,
  301. 0,
  302. {AFE_PORT_ID_QUATERNARY_TDM_RX,
  303. AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  304. AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  305. AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  306. AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  307. AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  308. AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  309. AFE_PORT_ID_QUATERNARY_TDM_RX_7},
  310. 8,
  311. 48000,
  312. 32,
  313. 8,
  314. 32,
  315. 0xFF,
  316. };
  317. static u32 num_tdm_group_ports;
  318. static struct afe_clk_set tdm_clk_set = {
  319. AFE_API_VERSION_CLOCK_SET,
  320. Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT,
  321. Q6AFE_LPASS_IBIT_CLK_DISABLE,
  322. Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO,
  323. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  324. 0,
  325. };
  326. int msm_dai_q6_get_group_idx(u16 id)
  327. {
  328. switch (id) {
  329. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  330. case AFE_PORT_ID_PRIMARY_TDM_RX:
  331. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  332. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  333. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  334. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  335. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  336. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  337. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  338. return IDX_GROUP_PRIMARY_TDM_RX;
  339. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  340. case AFE_PORT_ID_PRIMARY_TDM_TX:
  341. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  342. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  343. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  344. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  345. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  346. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  347. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  348. return IDX_GROUP_PRIMARY_TDM_TX;
  349. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  350. case AFE_PORT_ID_SECONDARY_TDM_RX:
  351. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  352. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  353. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  354. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  355. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  356. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  357. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  358. return IDX_GROUP_SECONDARY_TDM_RX;
  359. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  360. case AFE_PORT_ID_SECONDARY_TDM_TX:
  361. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  362. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  363. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  364. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  365. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  366. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  367. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  368. return IDX_GROUP_SECONDARY_TDM_TX;
  369. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  370. case AFE_PORT_ID_TERTIARY_TDM_RX:
  371. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  372. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  373. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  374. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  375. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  376. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  377. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  378. return IDX_GROUP_TERTIARY_TDM_RX;
  379. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  380. case AFE_PORT_ID_TERTIARY_TDM_TX:
  381. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  382. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  383. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  384. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  385. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  386. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  387. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  388. return IDX_GROUP_TERTIARY_TDM_TX;
  389. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  390. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  391. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  392. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  393. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  394. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  395. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  396. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  397. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  398. return IDX_GROUP_QUATERNARY_TDM_RX;
  399. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  400. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  401. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  402. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  403. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  404. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  405. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  406. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  407. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  408. return IDX_GROUP_QUATERNARY_TDM_TX;
  409. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  410. case AFE_PORT_ID_QUINARY_TDM_RX:
  411. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  412. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  413. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  414. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  415. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  416. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  417. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  418. return IDX_GROUP_QUINARY_TDM_RX;
  419. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  420. case AFE_PORT_ID_QUINARY_TDM_TX:
  421. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  422. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  423. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  424. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  425. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  426. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  427. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  428. return IDX_GROUP_QUINARY_TDM_TX;
  429. default: return -EINVAL;
  430. }
  431. }
  432. int msm_dai_q6_get_port_idx(u16 id)
  433. {
  434. switch (id) {
  435. case AFE_PORT_ID_PRIMARY_TDM_RX:
  436. return IDX_PRIMARY_TDM_RX_0;
  437. case AFE_PORT_ID_PRIMARY_TDM_TX:
  438. return IDX_PRIMARY_TDM_TX_0;
  439. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  440. return IDX_PRIMARY_TDM_RX_1;
  441. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  442. return IDX_PRIMARY_TDM_TX_1;
  443. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  444. return IDX_PRIMARY_TDM_RX_2;
  445. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  446. return IDX_PRIMARY_TDM_TX_2;
  447. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  448. return IDX_PRIMARY_TDM_RX_3;
  449. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  450. return IDX_PRIMARY_TDM_TX_3;
  451. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  452. return IDX_PRIMARY_TDM_RX_4;
  453. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  454. return IDX_PRIMARY_TDM_TX_4;
  455. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  456. return IDX_PRIMARY_TDM_RX_5;
  457. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  458. return IDX_PRIMARY_TDM_TX_5;
  459. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  460. return IDX_PRIMARY_TDM_RX_6;
  461. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  462. return IDX_PRIMARY_TDM_TX_6;
  463. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  464. return IDX_PRIMARY_TDM_RX_7;
  465. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  466. return IDX_PRIMARY_TDM_TX_7;
  467. case AFE_PORT_ID_SECONDARY_TDM_RX:
  468. return IDX_SECONDARY_TDM_RX_0;
  469. case AFE_PORT_ID_SECONDARY_TDM_TX:
  470. return IDX_SECONDARY_TDM_TX_0;
  471. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  472. return IDX_SECONDARY_TDM_RX_1;
  473. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  474. return IDX_SECONDARY_TDM_TX_1;
  475. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  476. return IDX_SECONDARY_TDM_RX_2;
  477. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  478. return IDX_SECONDARY_TDM_TX_2;
  479. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  480. return IDX_SECONDARY_TDM_RX_3;
  481. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  482. return IDX_SECONDARY_TDM_TX_3;
  483. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  484. return IDX_SECONDARY_TDM_RX_4;
  485. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  486. return IDX_SECONDARY_TDM_TX_4;
  487. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  488. return IDX_SECONDARY_TDM_RX_5;
  489. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  490. return IDX_SECONDARY_TDM_TX_5;
  491. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  492. return IDX_SECONDARY_TDM_RX_6;
  493. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  494. return IDX_SECONDARY_TDM_TX_6;
  495. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  496. return IDX_SECONDARY_TDM_RX_7;
  497. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  498. return IDX_SECONDARY_TDM_TX_7;
  499. case AFE_PORT_ID_TERTIARY_TDM_RX:
  500. return IDX_TERTIARY_TDM_RX_0;
  501. case AFE_PORT_ID_TERTIARY_TDM_TX:
  502. return IDX_TERTIARY_TDM_TX_0;
  503. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  504. return IDX_TERTIARY_TDM_RX_1;
  505. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  506. return IDX_TERTIARY_TDM_TX_1;
  507. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  508. return IDX_TERTIARY_TDM_RX_2;
  509. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  510. return IDX_TERTIARY_TDM_TX_2;
  511. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  512. return IDX_TERTIARY_TDM_RX_3;
  513. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  514. return IDX_TERTIARY_TDM_TX_3;
  515. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  516. return IDX_TERTIARY_TDM_RX_4;
  517. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  518. return IDX_TERTIARY_TDM_TX_4;
  519. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  520. return IDX_TERTIARY_TDM_RX_5;
  521. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  522. return IDX_TERTIARY_TDM_TX_5;
  523. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  524. return IDX_TERTIARY_TDM_RX_6;
  525. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  526. return IDX_TERTIARY_TDM_TX_6;
  527. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  528. return IDX_TERTIARY_TDM_RX_7;
  529. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  530. return IDX_TERTIARY_TDM_TX_7;
  531. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  532. return IDX_QUATERNARY_TDM_RX_0;
  533. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  534. return IDX_QUATERNARY_TDM_TX_0;
  535. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  536. return IDX_QUATERNARY_TDM_RX_1;
  537. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  538. return IDX_QUATERNARY_TDM_TX_1;
  539. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  540. return IDX_QUATERNARY_TDM_RX_2;
  541. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  542. return IDX_QUATERNARY_TDM_TX_2;
  543. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  544. return IDX_QUATERNARY_TDM_RX_3;
  545. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  546. return IDX_QUATERNARY_TDM_TX_3;
  547. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  548. return IDX_QUATERNARY_TDM_RX_4;
  549. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  550. return IDX_QUATERNARY_TDM_TX_4;
  551. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  552. return IDX_QUATERNARY_TDM_RX_5;
  553. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  554. return IDX_QUATERNARY_TDM_TX_5;
  555. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  556. return IDX_QUATERNARY_TDM_RX_6;
  557. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  558. return IDX_QUATERNARY_TDM_TX_6;
  559. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  560. return IDX_QUATERNARY_TDM_RX_7;
  561. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  562. return IDX_QUATERNARY_TDM_TX_7;
  563. case AFE_PORT_ID_QUINARY_TDM_RX:
  564. return IDX_QUINARY_TDM_RX_0;
  565. case AFE_PORT_ID_QUINARY_TDM_TX:
  566. return IDX_QUINARY_TDM_TX_0;
  567. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  568. return IDX_QUINARY_TDM_RX_1;
  569. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  570. return IDX_QUINARY_TDM_TX_1;
  571. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  572. return IDX_QUINARY_TDM_RX_2;
  573. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  574. return IDX_QUINARY_TDM_TX_2;
  575. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  576. return IDX_QUINARY_TDM_RX_3;
  577. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  578. return IDX_QUINARY_TDM_TX_3;
  579. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  580. return IDX_QUINARY_TDM_RX_4;
  581. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  582. return IDX_QUINARY_TDM_TX_4;
  583. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  584. return IDX_QUINARY_TDM_RX_5;
  585. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  586. return IDX_QUINARY_TDM_TX_5;
  587. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  588. return IDX_QUINARY_TDM_RX_6;
  589. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  590. return IDX_QUINARY_TDM_TX_6;
  591. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  592. return IDX_QUINARY_TDM_RX_7;
  593. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  594. return IDX_QUINARY_TDM_TX_7;
  595. default: return -EINVAL;
  596. }
  597. }
  598. static u16 msm_dai_q6_max_num_slot(int frame_rate)
  599. {
  600. /* Max num of slots is bits per frame divided
  601. * by bits per sample which is 16
  602. */
  603. switch (frame_rate) {
  604. case AFE_PORT_PCM_BITS_PER_FRAME_8:
  605. return 0;
  606. case AFE_PORT_PCM_BITS_PER_FRAME_16:
  607. return 1;
  608. case AFE_PORT_PCM_BITS_PER_FRAME_32:
  609. return 2;
  610. case AFE_PORT_PCM_BITS_PER_FRAME_64:
  611. return 4;
  612. case AFE_PORT_PCM_BITS_PER_FRAME_128:
  613. return 8;
  614. case AFE_PORT_PCM_BITS_PER_FRAME_256:
  615. return 16;
  616. default:
  617. pr_err("%s Invalid bits per frame %d\n",
  618. __func__, frame_rate);
  619. return 0;
  620. }
  621. }
  622. static int msm_dai_q6_dai_add_route(struct snd_soc_dai *dai)
  623. {
  624. struct snd_soc_dapm_route intercon;
  625. struct snd_soc_dapm_context *dapm;
  626. if (!dai) {
  627. pr_err("%s: Invalid params dai\n", __func__);
  628. return -EINVAL;
  629. }
  630. if (!dai->driver) {
  631. pr_err("%s: Invalid params dai driver\n", __func__);
  632. return -EINVAL;
  633. }
  634. dapm = snd_soc_component_get_dapm(dai->component);
  635. memset(&intercon, 0, sizeof(intercon));
  636. if (dai->driver->playback.stream_name &&
  637. dai->driver->playback.aif_name) {
  638. dev_dbg(dai->dev, "%s: add route for widget %s",
  639. __func__, dai->driver->playback.stream_name);
  640. intercon.source = dai->driver->playback.aif_name;
  641. intercon.sink = dai->driver->playback.stream_name;
  642. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  643. __func__, intercon.source, intercon.sink);
  644. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  645. }
  646. if (dai->driver->capture.stream_name &&
  647. dai->driver->capture.aif_name) {
  648. dev_dbg(dai->dev, "%s: add route for widget %s",
  649. __func__, dai->driver->capture.stream_name);
  650. intercon.sink = dai->driver->capture.aif_name;
  651. intercon.source = dai->driver->capture.stream_name;
  652. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  653. __func__, intercon.source, intercon.sink);
  654. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  655. }
  656. return 0;
  657. }
  658. static int msm_dai_q6_auxpcm_hw_params(
  659. struct snd_pcm_substream *substream,
  660. struct snd_pcm_hw_params *params,
  661. struct snd_soc_dai *dai)
  662. {
  663. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  664. dev_get_drvdata(dai->dev);
  665. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  666. struct msm_dai_auxpcm_pdata *auxpcm_pdata =
  667. (struct msm_dai_auxpcm_pdata *) dai->dev->platform_data;
  668. int rc = 0, slot_mapping_copy_len = 0;
  669. if (params_channels(params) != 1 || (params_rate(params) != 8000 &&
  670. params_rate(params) != 16000)) {
  671. dev_err(dai->dev, "%s: invalid param chan %d rate %d\n",
  672. __func__, params_channels(params), params_rate(params));
  673. return -EINVAL;
  674. }
  675. mutex_lock(&aux_dai_data->rlock);
  676. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  677. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  678. /* AUXPCM DAI in use */
  679. if (dai_data->rate != params_rate(params)) {
  680. dev_err(dai->dev, "%s: rate mismatch of running DAI\n",
  681. __func__);
  682. rc = -EINVAL;
  683. }
  684. mutex_unlock(&aux_dai_data->rlock);
  685. return rc;
  686. }
  687. dai_data->channels = params_channels(params);
  688. dai_data->rate = params_rate(params);
  689. if (dai_data->rate == 8000) {
  690. dai_data->port_config.pcm.pcm_cfg_minor_version =
  691. AFE_API_VERSION_PCM_CONFIG;
  692. dai_data->port_config.pcm.aux_mode = auxpcm_pdata->mode_8k.mode;
  693. dai_data->port_config.pcm.sync_src = auxpcm_pdata->mode_8k.sync;
  694. dai_data->port_config.pcm.frame_setting =
  695. auxpcm_pdata->mode_8k.frame;
  696. dai_data->port_config.pcm.quantype =
  697. auxpcm_pdata->mode_8k.quant;
  698. dai_data->port_config.pcm.ctrl_data_out_enable =
  699. auxpcm_pdata->mode_8k.data;
  700. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  701. dai_data->port_config.pcm.num_channels = dai_data->channels;
  702. dai_data->port_config.pcm.bit_width = 16;
  703. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  704. auxpcm_pdata->mode_8k.num_slots)
  705. slot_mapping_copy_len =
  706. ARRAY_SIZE(
  707. dai_data->port_config.pcm.slot_number_mapping)
  708. * sizeof(uint16_t);
  709. else
  710. slot_mapping_copy_len = auxpcm_pdata->mode_8k.num_slots
  711. * sizeof(uint16_t);
  712. if (auxpcm_pdata->mode_8k.slot_mapping) {
  713. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  714. auxpcm_pdata->mode_8k.slot_mapping,
  715. slot_mapping_copy_len);
  716. } else {
  717. dev_err(dai->dev, "%s 8khz slot mapping is NULL\n",
  718. __func__);
  719. mutex_unlock(&aux_dai_data->rlock);
  720. return -EINVAL;
  721. }
  722. } else {
  723. dai_data->port_config.pcm.pcm_cfg_minor_version =
  724. AFE_API_VERSION_PCM_CONFIG;
  725. dai_data->port_config.pcm.aux_mode =
  726. auxpcm_pdata->mode_16k.mode;
  727. dai_data->port_config.pcm.sync_src =
  728. auxpcm_pdata->mode_16k.sync;
  729. dai_data->port_config.pcm.frame_setting =
  730. auxpcm_pdata->mode_16k.frame;
  731. dai_data->port_config.pcm.quantype =
  732. auxpcm_pdata->mode_16k.quant;
  733. dai_data->port_config.pcm.ctrl_data_out_enable =
  734. auxpcm_pdata->mode_16k.data;
  735. dai_data->port_config.pcm.sample_rate = dai_data->rate;
  736. dai_data->port_config.pcm.num_channels = dai_data->channels;
  737. dai_data->port_config.pcm.bit_width = 16;
  738. if (ARRAY_SIZE(dai_data->port_config.pcm.slot_number_mapping) <=
  739. auxpcm_pdata->mode_16k.num_slots)
  740. slot_mapping_copy_len =
  741. ARRAY_SIZE(
  742. dai_data->port_config.pcm.slot_number_mapping)
  743. * sizeof(uint16_t);
  744. else
  745. slot_mapping_copy_len = auxpcm_pdata->mode_16k.num_slots
  746. * sizeof(uint16_t);
  747. if (auxpcm_pdata->mode_16k.slot_mapping) {
  748. memcpy(dai_data->port_config.pcm.slot_number_mapping,
  749. auxpcm_pdata->mode_16k.slot_mapping,
  750. slot_mapping_copy_len);
  751. } else {
  752. dev_err(dai->dev, "%s 16khz slot mapping is NULL\n",
  753. __func__);
  754. mutex_unlock(&aux_dai_data->rlock);
  755. return -EINVAL;
  756. }
  757. }
  758. dev_dbg(dai->dev, "%s: aux_mode 0x%x sync_src 0x%x frame_setting 0x%x\n",
  759. __func__, dai_data->port_config.pcm.aux_mode,
  760. dai_data->port_config.pcm.sync_src,
  761. dai_data->port_config.pcm.frame_setting);
  762. dev_dbg(dai->dev, "%s: qtype 0x%x dout 0x%x num_map[0] 0x%x\n"
  763. "num_map[1] 0x%x num_map[2] 0x%x num_map[3] 0x%x\n",
  764. __func__, dai_data->port_config.pcm.quantype,
  765. dai_data->port_config.pcm.ctrl_data_out_enable,
  766. dai_data->port_config.pcm.slot_number_mapping[0],
  767. dai_data->port_config.pcm.slot_number_mapping[1],
  768. dai_data->port_config.pcm.slot_number_mapping[2],
  769. dai_data->port_config.pcm.slot_number_mapping[3]);
  770. mutex_unlock(&aux_dai_data->rlock);
  771. return rc;
  772. }
  773. static int msm_dai_q6_auxpcm_set_clk(
  774. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data,
  775. u16 port_id, bool enable)
  776. {
  777. int rc;
  778. pr_debug("%s: afe_clk_ver: %d, port_id: %d, enable: %d\n", __func__,
  779. aux_dai_data->afe_clk_ver, port_id, enable);
  780. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  781. aux_dai_data->clk_set.enable = enable;
  782. rc = afe_set_lpass_clock_v2(port_id,
  783. &aux_dai_data->clk_set);
  784. } else {
  785. if (!enable)
  786. aux_dai_data->clk_cfg.clk_val1 = 0;
  787. rc = afe_set_lpass_clock(port_id,
  788. &aux_dai_data->clk_cfg);
  789. }
  790. return rc;
  791. }
  792. static void msm_dai_q6_auxpcm_shutdown(struct snd_pcm_substream *substream,
  793. struct snd_soc_dai *dai)
  794. {
  795. int rc = 0;
  796. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  797. dev_get_drvdata(dai->dev);
  798. mutex_lock(&aux_dai_data->rlock);
  799. if (!(test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  800. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))) {
  801. dev_dbg(dai->dev, "%s(): dai->id %d PCM ports already closed\n",
  802. __func__, dai->id);
  803. goto exit;
  804. }
  805. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  806. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status))
  807. clear_bit(STATUS_TX_PORT,
  808. aux_dai_data->auxpcm_port_status);
  809. else {
  810. dev_dbg(dai->dev, "%s: PCM_TX port already closed\n",
  811. __func__);
  812. goto exit;
  813. }
  814. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  815. if (test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status))
  816. clear_bit(STATUS_RX_PORT,
  817. aux_dai_data->auxpcm_port_status);
  818. else {
  819. dev_dbg(dai->dev, "%s: PCM_RX port already closed\n",
  820. __func__);
  821. goto exit;
  822. }
  823. }
  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. dev_dbg(dai->dev, "%s: cannot shutdown PCM ports\n",
  827. __func__);
  828. goto exit;
  829. }
  830. dev_dbg(dai->dev, "%s: dai->id = %d closing PCM AFE ports\n",
  831. __func__, dai->id);
  832. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  833. if (rc < 0)
  834. dev_err(dai->dev, "fail to close PCM_RX AFE port\n");
  835. rc = afe_close(aux_dai_data->tx_pid);
  836. if (rc < 0)
  837. dev_err(dai->dev, "fail to close AUX PCM TX port\n");
  838. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  839. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  840. exit:
  841. mutex_unlock(&aux_dai_data->rlock);
  842. }
  843. static int msm_dai_q6_auxpcm_prepare(struct snd_pcm_substream *substream,
  844. struct snd_soc_dai *dai)
  845. {
  846. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data =
  847. dev_get_drvdata(dai->dev);
  848. struct msm_dai_q6_dai_data *dai_data = &aux_dai_data->bdai_data;
  849. struct msm_dai_auxpcm_pdata *auxpcm_pdata = NULL;
  850. int rc = 0;
  851. u32 pcm_clk_rate;
  852. auxpcm_pdata = dai->dev->platform_data;
  853. mutex_lock(&aux_dai_data->rlock);
  854. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  855. if (test_bit(STATUS_TX_PORT,
  856. aux_dai_data->auxpcm_port_status)) {
  857. dev_dbg(dai->dev, "%s: PCM_TX port already ON\n",
  858. __func__);
  859. goto exit;
  860. } else
  861. set_bit(STATUS_TX_PORT,
  862. aux_dai_data->auxpcm_port_status);
  863. } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  864. if (test_bit(STATUS_RX_PORT,
  865. aux_dai_data->auxpcm_port_status)) {
  866. dev_dbg(dai->dev, "%s: PCM_RX port already ON\n",
  867. __func__);
  868. goto exit;
  869. } else
  870. set_bit(STATUS_RX_PORT,
  871. aux_dai_data->auxpcm_port_status);
  872. }
  873. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) &&
  874. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  875. dev_dbg(dai->dev, "%s: PCM ports already set\n", __func__);
  876. goto exit;
  877. }
  878. dev_dbg(dai->dev, "%s: dai->id:%d opening afe ports\n",
  879. __func__, dai->id);
  880. rc = afe_q6_interface_prepare();
  881. if (rc < 0) {
  882. dev_err(dai->dev, "fail to open AFE APR\n");
  883. goto fail;
  884. }
  885. /*
  886. * For AUX PCM Interface the below sequence of clk
  887. * settings and afe_open is a strict requirement.
  888. *
  889. * Also using afe_open instead of afe_port_start_nowait
  890. * to make sure the port is open before deasserting the
  891. * clock line. This is required because pcm register is
  892. * not written before clock deassert. Hence the hw does
  893. * not get updated with new setting if the below clock
  894. * assert/deasset and afe_open sequence is not followed.
  895. */
  896. if (dai_data->rate == 8000) {
  897. pcm_clk_rate = auxpcm_pdata->mode_8k.pcm_clk_rate;
  898. } else if (dai_data->rate == 16000) {
  899. pcm_clk_rate = (auxpcm_pdata->mode_16k.pcm_clk_rate);
  900. } else {
  901. dev_err(dai->dev, "%s: Invalid AUX PCM rate %d\n", __func__,
  902. dai_data->rate);
  903. rc = -EINVAL;
  904. goto fail;
  905. }
  906. if (aux_dai_data->afe_clk_ver == AFE_CLK_VERSION_V2) {
  907. memcpy(&aux_dai_data->clk_set, &lpass_clk_set_default,
  908. sizeof(struct afe_clk_set));
  909. aux_dai_data->clk_set.clk_freq_in_hz = pcm_clk_rate;
  910. switch (dai->id) {
  911. case MSM_DAI_PRI_AUXPCM_DT_DEV_ID:
  912. if (pcm_clk_rate)
  913. aux_dai_data->clk_set.clk_id =
  914. Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT;
  915. else
  916. aux_dai_data->clk_set.clk_id =
  917. Q6AFE_LPASS_CLK_ID_PRI_PCM_EBIT;
  918. break;
  919. case MSM_DAI_SEC_AUXPCM_DT_DEV_ID:
  920. if (pcm_clk_rate)
  921. aux_dai_data->clk_set.clk_id =
  922. Q6AFE_LPASS_CLK_ID_SEC_PCM_IBIT;
  923. else
  924. aux_dai_data->clk_set.clk_id =
  925. Q6AFE_LPASS_CLK_ID_SEC_PCM_EBIT;
  926. break;
  927. case MSM_DAI_TERT_AUXPCM_DT_DEV_ID:
  928. if (pcm_clk_rate)
  929. aux_dai_data->clk_set.clk_id =
  930. Q6AFE_LPASS_CLK_ID_TER_PCM_IBIT;
  931. else
  932. aux_dai_data->clk_set.clk_id =
  933. Q6AFE_LPASS_CLK_ID_TER_PCM_EBIT;
  934. break;
  935. case MSM_DAI_QUAT_AUXPCM_DT_DEV_ID:
  936. if (pcm_clk_rate)
  937. aux_dai_data->clk_set.clk_id =
  938. Q6AFE_LPASS_CLK_ID_QUAD_PCM_IBIT;
  939. else
  940. aux_dai_data->clk_set.clk_id =
  941. Q6AFE_LPASS_CLK_ID_QUAD_PCM_EBIT;
  942. break;
  943. case MSM_DAI_QUIN_AUXPCM_DT_DEV_ID:
  944. if (pcm_clk_rate)
  945. aux_dai_data->clk_set.clk_id =
  946. Q6AFE_LPASS_CLK_ID_QUIN_PCM_IBIT;
  947. else
  948. aux_dai_data->clk_set.clk_id =
  949. Q6AFE_LPASS_CLK_ID_QUIN_PCM_EBIT;
  950. break;
  951. default:
  952. dev_err(dai->dev, "%s: AUXPCM id: %d not supported\n",
  953. __func__, dai->id);
  954. break;
  955. }
  956. } else {
  957. memcpy(&aux_dai_data->clk_cfg, &lpass_clk_cfg_default,
  958. sizeof(struct afe_clk_cfg));
  959. aux_dai_data->clk_cfg.clk_val1 = pcm_clk_rate;
  960. }
  961. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  962. aux_dai_data->rx_pid, true);
  963. if (rc < 0) {
  964. dev_err(dai->dev,
  965. "%s:afe_set_lpass_clock on RX pcm_src_clk failed\n",
  966. __func__);
  967. goto fail;
  968. }
  969. rc = msm_dai_q6_auxpcm_set_clk(aux_dai_data,
  970. aux_dai_data->tx_pid, true);
  971. if (rc < 0) {
  972. dev_err(dai->dev,
  973. "%s:afe_set_lpass_clock on TX pcm_src_clk failed\n",
  974. __func__);
  975. goto fail;
  976. }
  977. afe_open(aux_dai_data->rx_pid, &dai_data->port_config, dai_data->rate);
  978. if (q6core_get_avcs_api_version_per_service(
  979. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V4) {
  980. /*
  981. * send island mode config
  982. * This should be the first configuration
  983. */
  984. rc = afe_send_port_island_mode(aux_dai_data->tx_pid);
  985. if (rc)
  986. dev_err(dai->dev, "%s: afe send island mode failed %d\n",
  987. __func__, rc);
  988. }
  989. afe_open(aux_dai_data->tx_pid, &dai_data->port_config, dai_data->rate);
  990. goto exit;
  991. fail:
  992. if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
  993. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  994. else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  995. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  996. exit:
  997. mutex_unlock(&aux_dai_data->rlock);
  998. return rc;
  999. }
  1000. static int msm_dai_q6_auxpcm_trigger(struct snd_pcm_substream *substream,
  1001. int cmd, struct snd_soc_dai *dai)
  1002. {
  1003. int rc = 0;
  1004. pr_debug("%s:port:%d cmd:%d\n",
  1005. __func__, dai->id, cmd);
  1006. switch (cmd) {
  1007. case SNDRV_PCM_TRIGGER_START:
  1008. case SNDRV_PCM_TRIGGER_RESUME:
  1009. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  1010. /* afe_open will be called from prepare */
  1011. return 0;
  1012. case SNDRV_PCM_TRIGGER_STOP:
  1013. case SNDRV_PCM_TRIGGER_SUSPEND:
  1014. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  1015. return 0;
  1016. default:
  1017. pr_err("%s: cmd %d\n", __func__, cmd);
  1018. rc = -EINVAL;
  1019. }
  1020. return rc;
  1021. }
  1022. static int msm_dai_q6_dai_auxpcm_remove(struct snd_soc_dai *dai)
  1023. {
  1024. struct msm_dai_q6_auxpcm_dai_data *aux_dai_data;
  1025. int rc;
  1026. aux_dai_data = dev_get_drvdata(dai->dev);
  1027. dev_dbg(dai->dev, "%s: dai->id %d closing afe\n",
  1028. __func__, dai->id);
  1029. if (test_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status) ||
  1030. test_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status)) {
  1031. rc = afe_close(aux_dai_data->rx_pid); /* can block */
  1032. if (rc < 0)
  1033. dev_err(dai->dev, "fail to close AUXPCM RX AFE port\n");
  1034. rc = afe_close(aux_dai_data->tx_pid);
  1035. if (rc < 0)
  1036. dev_err(dai->dev, "fail to close AUXPCM TX AFE port\n");
  1037. clear_bit(STATUS_TX_PORT, aux_dai_data->auxpcm_port_status);
  1038. clear_bit(STATUS_RX_PORT, aux_dai_data->auxpcm_port_status);
  1039. }
  1040. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->rx_pid, false);
  1041. msm_dai_q6_auxpcm_set_clk(aux_dai_data, aux_dai_data->tx_pid, false);
  1042. return 0;
  1043. }
  1044. static int msm_dai_q6_island_mode_put(struct snd_kcontrol *kcontrol,
  1045. struct snd_ctl_elem_value *ucontrol)
  1046. {
  1047. int value = ucontrol->value.integer.value[0];
  1048. u16 port_id = (u16)kcontrol->private_value;
  1049. pr_debug("%s: island mode = %d\n", __func__, value);
  1050. afe_set_island_mode_cfg(port_id, value);
  1051. return 0;
  1052. }
  1053. static int msm_dai_q6_island_mode_get(struct snd_kcontrol *kcontrol,
  1054. struct snd_ctl_elem_value *ucontrol)
  1055. {
  1056. int value;
  1057. u16 port_id = (u16)kcontrol->private_value;
  1058. afe_get_island_mode_cfg(port_id, &value);
  1059. ucontrol->value.integer.value[0] = value;
  1060. return 0;
  1061. }
  1062. static void island_mx_ctl_private_free(struct snd_kcontrol *kcontrol)
  1063. {
  1064. struct snd_kcontrol_new *knew = snd_kcontrol_chip(kcontrol);
  1065. kfree(knew);
  1066. }
  1067. static int msm_dai_q6_add_island_mx_ctls(struct snd_card *card,
  1068. const char *dai_name,
  1069. int dai_id, void *dai_data)
  1070. {
  1071. const char *mx_ctl_name = "TX island";
  1072. char *mixer_str = NULL;
  1073. int dai_str_len = 0, ctl_len = 0;
  1074. int rc = 0;
  1075. struct snd_kcontrol_new *knew = NULL;
  1076. struct snd_kcontrol *kctl = NULL;
  1077. dai_str_len = strlen(dai_name) + 1;
  1078. /* Add island related mixer controls */
  1079. ctl_len = dai_str_len + strlen(mx_ctl_name) + 1;
  1080. mixer_str = kzalloc(ctl_len, GFP_KERNEL);
  1081. if (!mixer_str)
  1082. return -ENOMEM;
  1083. snprintf(mixer_str, ctl_len, "%s %s", dai_name, mx_ctl_name);
  1084. knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL);
  1085. if (!knew) {
  1086. kfree(mixer_str);
  1087. return -ENOMEM;
  1088. }
  1089. knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  1090. knew->info = snd_ctl_boolean_mono_info;
  1091. knew->get = msm_dai_q6_island_mode_get;
  1092. knew->put = msm_dai_q6_island_mode_put;
  1093. knew->name = mixer_str;
  1094. knew->private_value = dai_id;
  1095. kctl = snd_ctl_new1(knew, knew);
  1096. if (!kctl) {
  1097. kfree(knew);
  1098. kfree(mixer_str);
  1099. return -ENOMEM;
  1100. }
  1101. kctl->private_free = island_mx_ctl_private_free;
  1102. rc = snd_ctl_add(card, kctl);
  1103. if (rc < 0)
  1104. pr_err("%s: err add config ctl, DAI = %s\n",
  1105. __func__, dai_name);
  1106. kfree(mixer_str);
  1107. return rc;
  1108. }
  1109. static int msm_dai_q6_aux_pcm_probe(struct snd_soc_dai *dai)
  1110. {
  1111. int rc = 0;
  1112. struct msm_dai_q6_auxpcm_dai_data *dai_data = NULL;
  1113. if (!dai) {
  1114. pr_err("%s: Invalid params dai\n", __func__);
  1115. return -EINVAL;
  1116. }
  1117. if (!dai->dev) {
  1118. pr_err("%s: Invalid params dai dev\n", __func__);
  1119. return -EINVAL;
  1120. }
  1121. if (!dai->driver->id) {
  1122. dev_warn(dai->dev, "DAI driver id is not set\n");
  1123. return -EINVAL;
  1124. }
  1125. dai->id = dai->driver->id;
  1126. dai_data = dev_get_drvdata(dai->dev);
  1127. if (dai_data->is_island_dai)
  1128. rc = msm_dai_q6_add_island_mx_ctls(
  1129. dai->component->card->snd_card,
  1130. dai->name, dai_data->tx_pid,
  1131. (void *)dai_data);
  1132. rc = msm_dai_q6_dai_add_route(dai);
  1133. return rc;
  1134. }
  1135. static struct snd_soc_dai_ops msm_dai_q6_auxpcm_ops = {
  1136. .prepare = msm_dai_q6_auxpcm_prepare,
  1137. .trigger = msm_dai_q6_auxpcm_trigger,
  1138. .hw_params = msm_dai_q6_auxpcm_hw_params,
  1139. .shutdown = msm_dai_q6_auxpcm_shutdown,
  1140. };
  1141. static const struct snd_soc_component_driver
  1142. msm_dai_q6_aux_pcm_dai_component = {
  1143. .name = "msm-auxpcm-dev",
  1144. };
  1145. static struct snd_soc_dai_driver msm_dai_q6_aux_pcm_dai[] = {
  1146. {
  1147. .playback = {
  1148. .stream_name = "AUX PCM Playback",
  1149. .aif_name = "AUX_PCM_RX",
  1150. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1151. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1152. .channels_min = 1,
  1153. .channels_max = 1,
  1154. .rate_max = 16000,
  1155. .rate_min = 8000,
  1156. },
  1157. .capture = {
  1158. .stream_name = "AUX PCM Capture",
  1159. .aif_name = "AUX_PCM_TX",
  1160. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1161. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1162. .channels_min = 1,
  1163. .channels_max = 1,
  1164. .rate_max = 16000,
  1165. .rate_min = 8000,
  1166. },
  1167. .id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID,
  1168. .name = "Pri AUX PCM",
  1169. .ops = &msm_dai_q6_auxpcm_ops,
  1170. .probe = msm_dai_q6_aux_pcm_probe,
  1171. .remove = msm_dai_q6_dai_auxpcm_remove,
  1172. },
  1173. {
  1174. .playback = {
  1175. .stream_name = "Sec AUX PCM Playback",
  1176. .aif_name = "SEC_AUX_PCM_RX",
  1177. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1178. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1179. .channels_min = 1,
  1180. .channels_max = 1,
  1181. .rate_max = 16000,
  1182. .rate_min = 8000,
  1183. },
  1184. .capture = {
  1185. .stream_name = "Sec AUX PCM Capture",
  1186. .aif_name = "SEC_AUX_PCM_TX",
  1187. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1188. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1189. .channels_min = 1,
  1190. .channels_max = 1,
  1191. .rate_max = 16000,
  1192. .rate_min = 8000,
  1193. },
  1194. .id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID,
  1195. .name = "Sec AUX PCM",
  1196. .ops = &msm_dai_q6_auxpcm_ops,
  1197. .probe = msm_dai_q6_aux_pcm_probe,
  1198. .remove = msm_dai_q6_dai_auxpcm_remove,
  1199. },
  1200. {
  1201. .playback = {
  1202. .stream_name = "Tert AUX PCM Playback",
  1203. .aif_name = "TERT_AUX_PCM_RX",
  1204. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1205. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1206. .channels_min = 1,
  1207. .channels_max = 1,
  1208. .rate_max = 16000,
  1209. .rate_min = 8000,
  1210. },
  1211. .capture = {
  1212. .stream_name = "Tert AUX PCM Capture",
  1213. .aif_name = "TERT_AUX_PCM_TX",
  1214. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1215. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1216. .channels_min = 1,
  1217. .channels_max = 1,
  1218. .rate_max = 16000,
  1219. .rate_min = 8000,
  1220. },
  1221. .id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID,
  1222. .name = "Tert AUX PCM",
  1223. .ops = &msm_dai_q6_auxpcm_ops,
  1224. .probe = msm_dai_q6_aux_pcm_probe,
  1225. .remove = msm_dai_q6_dai_auxpcm_remove,
  1226. },
  1227. {
  1228. .playback = {
  1229. .stream_name = "Quat AUX PCM Playback",
  1230. .aif_name = "QUAT_AUX_PCM_RX",
  1231. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1232. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1233. .channels_min = 1,
  1234. .channels_max = 1,
  1235. .rate_max = 16000,
  1236. .rate_min = 8000,
  1237. },
  1238. .capture = {
  1239. .stream_name = "Quat AUX PCM Capture",
  1240. .aif_name = "QUAT_AUX_PCM_TX",
  1241. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1242. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1243. .channels_min = 1,
  1244. .channels_max = 1,
  1245. .rate_max = 16000,
  1246. .rate_min = 8000,
  1247. },
  1248. .id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID,
  1249. .name = "Quat AUX PCM",
  1250. .ops = &msm_dai_q6_auxpcm_ops,
  1251. .probe = msm_dai_q6_aux_pcm_probe,
  1252. .remove = msm_dai_q6_dai_auxpcm_remove,
  1253. },
  1254. {
  1255. .playback = {
  1256. .stream_name = "Quin AUX PCM Playback",
  1257. .aif_name = "QUIN_AUX_PCM_RX",
  1258. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1259. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1260. .channels_min = 1,
  1261. .channels_max = 1,
  1262. .rate_max = 16000,
  1263. .rate_min = 8000,
  1264. },
  1265. .capture = {
  1266. .stream_name = "Quin AUX PCM Capture",
  1267. .aif_name = "QUIN_AUX_PCM_TX",
  1268. .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000),
  1269. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  1270. .channels_min = 1,
  1271. .channels_max = 1,
  1272. .rate_max = 16000,
  1273. .rate_min = 8000,
  1274. },
  1275. .id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID,
  1276. .name = "Quin AUX PCM",
  1277. .ops = &msm_dai_q6_auxpcm_ops,
  1278. .probe = msm_dai_q6_aux_pcm_probe,
  1279. .remove = msm_dai_q6_dai_auxpcm_remove,
  1280. },
  1281. };
  1282. static int msm_dai_q6_spdif_format_put(struct snd_kcontrol *kcontrol,
  1283. struct snd_ctl_elem_value *ucontrol)
  1284. {
  1285. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1286. int value = ucontrol->value.integer.value[0];
  1287. dai_data->spdif_port.cfg.data_format = value;
  1288. pr_debug("%s: value = %d\n", __func__, value);
  1289. return 0;
  1290. }
  1291. static int msm_dai_q6_spdif_format_get(struct snd_kcontrol *kcontrol,
  1292. struct snd_ctl_elem_value *ucontrol)
  1293. {
  1294. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1295. ucontrol->value.integer.value[0] =
  1296. dai_data->spdif_port.cfg.data_format;
  1297. return 0;
  1298. }
  1299. static const char * const spdif_format[] = {
  1300. "LPCM",
  1301. "Compr"
  1302. };
  1303. static const struct soc_enum spdif_config_enum[] = {
  1304. SOC_ENUM_SINGLE_EXT(2, spdif_format),
  1305. };
  1306. static int msm_dai_q6_spdif_chstatus_put(struct snd_kcontrol *kcontrol,
  1307. struct snd_ctl_elem_value *ucontrol)
  1308. {
  1309. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1310. int ret = 0;
  1311. dai_data->spdif_port.ch_status.status_type =
  1312. AFE_API_VERSION_SPDIF_CH_STATUS_CONFIG;
  1313. memset(dai_data->spdif_port.ch_status.status_mask,
  1314. CHANNEL_STATUS_MASK_INIT, CHANNEL_STATUS_SIZE);
  1315. dai_data->spdif_port.ch_status.status_mask[0] =
  1316. CHANNEL_STATUS_MASK;
  1317. memcpy(dai_data->spdif_port.ch_status.status_bits,
  1318. ucontrol->value.iec958.status, CHANNEL_STATUS_SIZE);
  1319. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1320. pr_debug("%s: Port already started. Dynamic update\n",
  1321. __func__);
  1322. ret = afe_send_spdif_ch_status_cfg(
  1323. &dai_data->spdif_port.ch_status,
  1324. AFE_PORT_ID_SPDIF_RX);
  1325. }
  1326. return ret;
  1327. }
  1328. static int msm_dai_q6_spdif_chstatus_get(struct snd_kcontrol *kcontrol,
  1329. struct snd_ctl_elem_value *ucontrol)
  1330. {
  1331. struct msm_dai_q6_spdif_dai_data *dai_data = kcontrol->private_data;
  1332. memcpy(ucontrol->value.iec958.status,
  1333. dai_data->spdif_port.ch_status.status_bits,
  1334. CHANNEL_STATUS_SIZE);
  1335. return 0;
  1336. }
  1337. static int msm_dai_q6_spdif_chstatus_info(struct snd_kcontrol *kcontrol,
  1338. struct snd_ctl_elem_info *uinfo)
  1339. {
  1340. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1341. uinfo->count = 1;
  1342. return 0;
  1343. }
  1344. static const struct snd_kcontrol_new spdif_config_controls[] = {
  1345. {
  1346. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1347. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  1348. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1349. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
  1350. .info = msm_dai_q6_spdif_chstatus_info,
  1351. .get = msm_dai_q6_spdif_chstatus_get,
  1352. .put = msm_dai_q6_spdif_chstatus_put,
  1353. },
  1354. SOC_ENUM_EXT("SPDIF RX Format", spdif_config_enum[0],
  1355. msm_dai_q6_spdif_format_get,
  1356. msm_dai_q6_spdif_format_put)
  1357. };
  1358. static int msm_dai_q6_spdif_hw_params(struct snd_pcm_substream *substream,
  1359. struct snd_pcm_hw_params *params,
  1360. struct snd_soc_dai *dai)
  1361. {
  1362. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1363. dai->id = AFE_PORT_ID_SPDIF_RX;
  1364. dai_data->channels = params_channels(params);
  1365. dai_data->spdif_port.cfg.num_channels = dai_data->channels;
  1366. switch (params_format(params)) {
  1367. case SNDRV_PCM_FORMAT_S16_LE:
  1368. dai_data->spdif_port.cfg.bit_width = 16;
  1369. break;
  1370. case SNDRV_PCM_FORMAT_S24_LE:
  1371. case SNDRV_PCM_FORMAT_S24_3LE:
  1372. dai_data->spdif_port.cfg.bit_width = 24;
  1373. break;
  1374. default:
  1375. pr_err("%s: format %d\n",
  1376. __func__, params_format(params));
  1377. return -EINVAL;
  1378. }
  1379. dai_data->rate = params_rate(params);
  1380. dai_data->bitwidth = dai_data->spdif_port.cfg.bit_width;
  1381. dai_data->spdif_port.cfg.sample_rate = dai_data->rate;
  1382. dai_data->spdif_port.cfg.spdif_cfg_minor_version =
  1383. AFE_API_VERSION_SPDIF_CONFIG;
  1384. dev_dbg(dai->dev, " channel %d sample rate %d bit width %d\n",
  1385. dai_data->channels, dai_data->rate,
  1386. dai_data->spdif_port.cfg.bit_width);
  1387. dai_data->spdif_port.cfg.reserved = 0;
  1388. return 0;
  1389. }
  1390. static void msm_dai_q6_spdif_shutdown(struct snd_pcm_substream *substream,
  1391. struct snd_soc_dai *dai)
  1392. {
  1393. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1394. int rc = 0;
  1395. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1396. pr_info("%s: afe port not started. dai_data->status_mask = %ld\n",
  1397. __func__, *dai_data->status_mask);
  1398. return;
  1399. }
  1400. rc = afe_close(dai->id);
  1401. if (rc < 0)
  1402. dev_err(dai->dev, "fail to close AFE port\n");
  1403. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1404. *dai_data->status_mask);
  1405. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1406. }
  1407. static int msm_dai_q6_spdif_prepare(struct snd_pcm_substream *substream,
  1408. struct snd_soc_dai *dai)
  1409. {
  1410. struct msm_dai_q6_spdif_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1411. int rc = 0;
  1412. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1413. rc = afe_spdif_port_start(dai->id, &dai_data->spdif_port,
  1414. dai_data->rate);
  1415. if (rc < 0)
  1416. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1417. dai->id);
  1418. else
  1419. set_bit(STATUS_PORT_STARTED,
  1420. dai_data->status_mask);
  1421. }
  1422. return rc;
  1423. }
  1424. static int msm_dai_q6_spdif_dai_probe(struct snd_soc_dai *dai)
  1425. {
  1426. struct msm_dai_q6_spdif_dai_data *dai_data;
  1427. const struct snd_kcontrol_new *kcontrol;
  1428. int rc = 0;
  1429. struct snd_soc_dapm_route intercon;
  1430. struct snd_soc_dapm_context *dapm;
  1431. if (!dai) {
  1432. pr_err("%s: dai not found!!\n", __func__);
  1433. return -EINVAL;
  1434. }
  1435. dai_data = kzalloc(sizeof(struct msm_dai_q6_spdif_dai_data),
  1436. GFP_KERNEL);
  1437. if (!dai_data) {
  1438. dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n",
  1439. AFE_PORT_ID_SPDIF_RX);
  1440. rc = -ENOMEM;
  1441. } else
  1442. dev_set_drvdata(dai->dev, dai_data);
  1443. kcontrol = &spdif_config_controls[1];
  1444. dapm = snd_soc_component_get_dapm(dai->component);
  1445. rc = snd_ctl_add(dai->component->card->snd_card,
  1446. snd_ctl_new1(kcontrol, dai_data));
  1447. memset(&intercon, 0, sizeof(intercon));
  1448. if (!rc && dai && dai->driver) {
  1449. if (dai->driver->playback.stream_name &&
  1450. dai->driver->playback.aif_name) {
  1451. dev_dbg(dai->dev, "%s: add route for widget %s",
  1452. __func__, dai->driver->playback.stream_name);
  1453. intercon.source = dai->driver->playback.aif_name;
  1454. intercon.sink = dai->driver->playback.stream_name;
  1455. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1456. __func__, intercon.source, intercon.sink);
  1457. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1458. }
  1459. if (dai->driver->capture.stream_name &&
  1460. dai->driver->capture.aif_name) {
  1461. dev_dbg(dai->dev, "%s: add route for widget %s",
  1462. __func__, dai->driver->capture.stream_name);
  1463. intercon.sink = dai->driver->capture.aif_name;
  1464. intercon.source = dai->driver->capture.stream_name;
  1465. dev_dbg(dai->dev, "%s: src %s sink %s\n",
  1466. __func__, intercon.source, intercon.sink);
  1467. snd_soc_dapm_add_routes(dapm, &intercon, 1);
  1468. }
  1469. }
  1470. return rc;
  1471. }
  1472. static int msm_dai_q6_spdif_dai_remove(struct snd_soc_dai *dai)
  1473. {
  1474. struct msm_dai_q6_spdif_dai_data *dai_data;
  1475. int rc;
  1476. dai_data = dev_get_drvdata(dai->dev);
  1477. /* If AFE port is still up, close it */
  1478. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1479. rc = afe_close(dai->id); /* can block */
  1480. if (rc < 0)
  1481. dev_err(dai->dev, "fail to close AFE port\n");
  1482. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1483. }
  1484. kfree(dai_data);
  1485. return 0;
  1486. }
  1487. static struct snd_soc_dai_ops msm_dai_q6_spdif_ops = {
  1488. .prepare = msm_dai_q6_spdif_prepare,
  1489. .hw_params = msm_dai_q6_spdif_hw_params,
  1490. .shutdown = msm_dai_q6_spdif_shutdown,
  1491. };
  1492. static struct snd_soc_dai_driver msm_dai_q6_spdif_spdif_rx_dai = {
  1493. .playback = {
  1494. .stream_name = "SPDIF Playback",
  1495. .aif_name = "SPDIF_RX",
  1496. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  1497. SNDRV_PCM_RATE_16000,
  1498. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
  1499. .channels_min = 1,
  1500. .channels_max = 4,
  1501. .rate_min = 8000,
  1502. .rate_max = 48000,
  1503. },
  1504. .ops = &msm_dai_q6_spdif_ops,
  1505. .probe = msm_dai_q6_spdif_dai_probe,
  1506. .remove = msm_dai_q6_spdif_dai_remove,
  1507. };
  1508. static const struct snd_soc_component_driver msm_dai_spdif_q6_component = {
  1509. .name = "msm-dai-q6-spdif",
  1510. };
  1511. static int msm_dai_q6_prepare(struct snd_pcm_substream *substream,
  1512. struct snd_soc_dai *dai)
  1513. {
  1514. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1515. int rc = 0;
  1516. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1517. if (dai_data->enc_config.format != ENC_FMT_NONE) {
  1518. int bitwidth = 0;
  1519. switch (dai_data->afe_in_bitformat) {
  1520. case SNDRV_PCM_FORMAT_S32_LE:
  1521. bitwidth = 32;
  1522. break;
  1523. case SNDRV_PCM_FORMAT_S24_LE:
  1524. bitwidth = 24;
  1525. break;
  1526. case SNDRV_PCM_FORMAT_S16_LE:
  1527. default:
  1528. bitwidth = 16;
  1529. break;
  1530. }
  1531. pr_debug("%s: calling AFE_PORT_START_V2 with enc_format: %d\n",
  1532. __func__, dai_data->enc_config.format);
  1533. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  1534. dai_data->rate,
  1535. dai_data->afe_in_channels,
  1536. bitwidth,
  1537. &dai_data->enc_config, NULL);
  1538. if (rc < 0)
  1539. pr_err("%s: afe_port_start_v2 failed error: %d\n",
  1540. __func__, rc);
  1541. } else if (dai_data->dec_config.format != DEC_FMT_NONE) {
  1542. /*
  1543. * A dummy Tx session is established in LPASS to
  1544. * get the link statistics from BTSoC.
  1545. * Depacketizer extracts the bit rate levels and
  1546. * transmits them to the encoder on the Rx path.
  1547. * Since this is a dummy decoder - channels, bit
  1548. * width are sent as 0 and encoder config is NULL.
  1549. * This could be updated in the future if there is
  1550. * a complete Tx path set up that uses this decoder.
  1551. */
  1552. rc = afe_port_start_v2(dai->id, &dai_data->port_config,
  1553. dai_data->rate, 0, 0, NULL,
  1554. &dai_data->dec_config);
  1555. if (rc < 0) {
  1556. pr_err("%s: fail to open AFE port 0x%x\n",
  1557. __func__, dai->id);
  1558. }
  1559. } else {
  1560. rc = afe_port_start(dai->id, &dai_data->port_config,
  1561. dai_data->rate);
  1562. }
  1563. if (rc < 0)
  1564. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  1565. dai->id);
  1566. else
  1567. set_bit(STATUS_PORT_STARTED,
  1568. dai_data->status_mask);
  1569. }
  1570. return rc;
  1571. }
  1572. static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params,
  1573. struct snd_soc_dai *dai, int stream)
  1574. {
  1575. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1576. dai_data->channels = params_channels(params);
  1577. switch (dai_data->channels) {
  1578. case 2:
  1579. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  1580. break;
  1581. case 1:
  1582. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  1583. break;
  1584. default:
  1585. return -EINVAL;
  1586. pr_err("%s: err channels %d\n",
  1587. __func__, dai_data->channels);
  1588. break;
  1589. }
  1590. switch (params_format(params)) {
  1591. case SNDRV_PCM_FORMAT_S16_LE:
  1592. case SNDRV_PCM_FORMAT_SPECIAL:
  1593. dai_data->port_config.i2s.bit_width = 16;
  1594. break;
  1595. case SNDRV_PCM_FORMAT_S24_LE:
  1596. case SNDRV_PCM_FORMAT_S24_3LE:
  1597. dai_data->port_config.i2s.bit_width = 24;
  1598. break;
  1599. default:
  1600. pr_err("%s: format %d\n",
  1601. __func__, params_format(params));
  1602. return -EINVAL;
  1603. }
  1604. dai_data->rate = params_rate(params);
  1605. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  1606. dai_data->port_config.i2s.i2s_cfg_minor_version =
  1607. AFE_API_VERSION_I2S_CONFIG;
  1608. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  1609. dev_dbg(dai->dev, " channel %d sample rate %d entered\n",
  1610. dai_data->channels, dai_data->rate);
  1611. dai_data->port_config.i2s.channel_mode = 1;
  1612. return 0;
  1613. }
  1614. static u8 num_of_bits_set(u8 sd_line_mask)
  1615. {
  1616. u8 num_bits_set = 0;
  1617. while (sd_line_mask) {
  1618. num_bits_set++;
  1619. sd_line_mask = sd_line_mask & (sd_line_mask - 1);
  1620. }
  1621. return num_bits_set;
  1622. }
  1623. static int msm_dai_q6_i2s_hw_params(struct snd_pcm_hw_params *params,
  1624. struct snd_soc_dai *dai, int stream)
  1625. {
  1626. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1627. struct msm_i2s_data *i2s_pdata =
  1628. (struct msm_i2s_data *) dai->dev->platform_data;
  1629. dai_data->channels = params_channels(params);
  1630. if (num_of_bits_set(i2s_pdata->sd_lines) == 1) {
  1631. switch (dai_data->channels) {
  1632. case 2:
  1633. dai_data->port_config.i2s.mono_stereo = MSM_AFE_STEREO;
  1634. break;
  1635. case 1:
  1636. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  1637. break;
  1638. default:
  1639. pr_warn("%s: greater than stereo has not been validated %d",
  1640. __func__, dai_data->channels);
  1641. break;
  1642. }
  1643. }
  1644. dai_data->rate = params_rate(params);
  1645. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  1646. dai_data->port_config.i2s.i2s_cfg_minor_version =
  1647. AFE_API_VERSION_I2S_CONFIG;
  1648. dai_data->port_config.i2s.data_format = AFE_LINEAR_PCM_DATA;
  1649. /* Q6 only supports 16 as now */
  1650. dai_data->port_config.i2s.bit_width = 16;
  1651. dai_data->port_config.i2s.channel_mode = 1;
  1652. return 0;
  1653. }
  1654. static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params,
  1655. struct snd_soc_dai *dai, int stream)
  1656. {
  1657. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1658. dai_data->channels = params_channels(params);
  1659. dai_data->rate = params_rate(params);
  1660. switch (params_format(params)) {
  1661. case SNDRV_PCM_FORMAT_S16_LE:
  1662. case SNDRV_PCM_FORMAT_SPECIAL:
  1663. dai_data->port_config.slim_sch.bit_width = 16;
  1664. break;
  1665. case SNDRV_PCM_FORMAT_S24_LE:
  1666. case SNDRV_PCM_FORMAT_S24_3LE:
  1667. dai_data->port_config.slim_sch.bit_width = 24;
  1668. break;
  1669. case SNDRV_PCM_FORMAT_S32_LE:
  1670. dai_data->port_config.slim_sch.bit_width = 32;
  1671. break;
  1672. default:
  1673. pr_err("%s: format %d\n",
  1674. __func__, params_format(params));
  1675. return -EINVAL;
  1676. }
  1677. dai_data->port_config.slim_sch.sb_cfg_minor_version =
  1678. AFE_API_VERSION_SLIMBUS_CONFIG;
  1679. dai_data->port_config.slim_sch.sample_rate = dai_data->rate;
  1680. dai_data->port_config.slim_sch.num_channels = dai_data->channels;
  1681. switch (dai->id) {
  1682. case SLIMBUS_7_RX:
  1683. case SLIMBUS_7_TX:
  1684. case SLIMBUS_8_RX:
  1685. case SLIMBUS_8_TX:
  1686. dai_data->port_config.slim_sch.slimbus_dev_id =
  1687. AFE_SLIMBUS_DEVICE_2;
  1688. break;
  1689. default:
  1690. dai_data->port_config.slim_sch.slimbus_dev_id =
  1691. AFE_SLIMBUS_DEVICE_1;
  1692. break;
  1693. }
  1694. dev_dbg(dai->dev, "%s:slimbus_dev_id[%hu] bit_wd[%hu] format[%hu]\n"
  1695. "num_channel %hu shared_ch_mapping[0] %hu\n"
  1696. "slave_port_mapping[1] %hu slave_port_mapping[2] %hu\n"
  1697. "sample_rate %d\n", __func__,
  1698. dai_data->port_config.slim_sch.slimbus_dev_id,
  1699. dai_data->port_config.slim_sch.bit_width,
  1700. dai_data->port_config.slim_sch.data_format,
  1701. dai_data->port_config.slim_sch.num_channels,
  1702. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  1703. dai_data->port_config.slim_sch.shared_ch_mapping[1],
  1704. dai_data->port_config.slim_sch.shared_ch_mapping[2],
  1705. dai_data->rate);
  1706. return 0;
  1707. }
  1708. static int msm_dai_q6_usb_audio_hw_params(struct snd_pcm_hw_params *params,
  1709. struct snd_soc_dai *dai, int stream)
  1710. {
  1711. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1712. dai_data->channels = params_channels(params);
  1713. dai_data->rate = params_rate(params);
  1714. switch (params_format(params)) {
  1715. case SNDRV_PCM_FORMAT_S16_LE:
  1716. case SNDRV_PCM_FORMAT_SPECIAL:
  1717. dai_data->port_config.usb_audio.bit_width = 16;
  1718. break;
  1719. case SNDRV_PCM_FORMAT_S24_LE:
  1720. case SNDRV_PCM_FORMAT_S24_3LE:
  1721. dai_data->port_config.usb_audio.bit_width = 24;
  1722. break;
  1723. case SNDRV_PCM_FORMAT_S32_LE:
  1724. dai_data->port_config.usb_audio.bit_width = 32;
  1725. break;
  1726. default:
  1727. dev_err(dai->dev, "%s: invalid format %d\n",
  1728. __func__, params_format(params));
  1729. return -EINVAL;
  1730. }
  1731. dai_data->port_config.usb_audio.cfg_minor_version =
  1732. AFE_API_MINOR_VERSION_USB_AUDIO_CONFIG;
  1733. dai_data->port_config.usb_audio.num_channels = dai_data->channels;
  1734. dai_data->port_config.usb_audio.sample_rate = dai_data->rate;
  1735. dev_dbg(dai->dev, "%s: dev_id[0x%x] bit_wd[%hu] format[%hu]\n"
  1736. "num_channel %hu sample_rate %d\n", __func__,
  1737. dai_data->port_config.usb_audio.dev_token,
  1738. dai_data->port_config.usb_audio.bit_width,
  1739. dai_data->port_config.usb_audio.data_format,
  1740. dai_data->port_config.usb_audio.num_channels,
  1741. dai_data->port_config.usb_audio.sample_rate);
  1742. return 0;
  1743. }
  1744. static int msm_dai_q6_bt_fm_hw_params(struct snd_pcm_hw_params *params,
  1745. struct snd_soc_dai *dai, int stream)
  1746. {
  1747. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1748. dai_data->channels = params_channels(params);
  1749. dai_data->rate = params_rate(params);
  1750. dev_dbg(dai->dev, "channels %d sample rate %d entered\n",
  1751. dai_data->channels, dai_data->rate);
  1752. memset(&dai_data->port_config, 0, sizeof(dai_data->port_config));
  1753. pr_debug("%s: setting bt_fm parameters\n", __func__);
  1754. dai_data->port_config.int_bt_fm.bt_fm_cfg_minor_version =
  1755. AFE_API_VERSION_INTERNAL_BT_FM_CONFIG;
  1756. dai_data->port_config.int_bt_fm.num_channels = dai_data->channels;
  1757. dai_data->port_config.int_bt_fm.sample_rate = dai_data->rate;
  1758. dai_data->port_config.int_bt_fm.bit_width = 16;
  1759. return 0;
  1760. }
  1761. static int msm_dai_q6_afe_rtproxy_hw_params(struct snd_pcm_hw_params *params,
  1762. struct snd_soc_dai *dai)
  1763. {
  1764. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1765. dai_data->rate = params_rate(params);
  1766. dai_data->port_config.rtproxy.num_channels = params_channels(params);
  1767. dai_data->port_config.rtproxy.sample_rate = params_rate(params);
  1768. pr_debug("channel %d entered,dai_id: %d,rate: %d\n",
  1769. dai_data->port_config.rtproxy.num_channels, dai->id, dai_data->rate);
  1770. dai_data->port_config.rtproxy.rt_proxy_cfg_minor_version =
  1771. AFE_API_VERSION_RT_PROXY_CONFIG;
  1772. dai_data->port_config.rtproxy.bit_width = 16; /* Q6 only supports 16 */
  1773. dai_data->port_config.rtproxy.interleaved = 1;
  1774. dai_data->port_config.rtproxy.frame_size = params_period_bytes(params);
  1775. dai_data->port_config.rtproxy.jitter_allowance =
  1776. dai_data->port_config.rtproxy.frame_size/2;
  1777. dai_data->port_config.rtproxy.low_water_mark = 0;
  1778. dai_data->port_config.rtproxy.high_water_mark = 0;
  1779. return 0;
  1780. }
  1781. static int msm_dai_q6_pseudo_port_hw_params(struct snd_pcm_hw_params *params,
  1782. struct snd_soc_dai *dai, int stream)
  1783. {
  1784. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1785. dai_data->channels = params_channels(params);
  1786. dai_data->rate = params_rate(params);
  1787. /* Q6 only supports 16 as now */
  1788. dai_data->port_config.pseudo_port.pseud_port_cfg_minor_version =
  1789. AFE_API_VERSION_PSEUDO_PORT_CONFIG;
  1790. dai_data->port_config.pseudo_port.num_channels =
  1791. params_channels(params);
  1792. dai_data->port_config.pseudo_port.bit_width = 16;
  1793. dai_data->port_config.pseudo_port.data_format = 0;
  1794. dai_data->port_config.pseudo_port.timing_mode =
  1795. AFE_PSEUDOPORT_TIMING_MODE_TIMER;
  1796. dai_data->port_config.pseudo_port.sample_rate = params_rate(params);
  1797. dev_dbg(dai->dev, "%s: bit_wd[%hu] num_channels [%hu] format[%hu]\n"
  1798. "timing Mode %hu sample_rate %d\n", __func__,
  1799. dai_data->port_config.pseudo_port.bit_width,
  1800. dai_data->port_config.pseudo_port.num_channels,
  1801. dai_data->port_config.pseudo_port.data_format,
  1802. dai_data->port_config.pseudo_port.timing_mode,
  1803. dai_data->port_config.pseudo_port.sample_rate);
  1804. return 0;
  1805. }
  1806. /* Current implementation assumes hw_param is called once
  1807. * This may not be the case but what to do when ADM and AFE
  1808. * port are already opened and parameter changes
  1809. */
  1810. static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream,
  1811. struct snd_pcm_hw_params *params,
  1812. struct snd_soc_dai *dai)
  1813. {
  1814. int rc = 0;
  1815. switch (dai->id) {
  1816. case PRIMARY_I2S_TX:
  1817. case PRIMARY_I2S_RX:
  1818. case SECONDARY_I2S_RX:
  1819. rc = msm_dai_q6_cdc_hw_params(params, dai, substream->stream);
  1820. break;
  1821. case MI2S_RX:
  1822. rc = msm_dai_q6_i2s_hw_params(params, dai, substream->stream);
  1823. break;
  1824. case SLIMBUS_0_RX:
  1825. case SLIMBUS_1_RX:
  1826. case SLIMBUS_2_RX:
  1827. case SLIMBUS_3_RX:
  1828. case SLIMBUS_4_RX:
  1829. case SLIMBUS_5_RX:
  1830. case SLIMBUS_6_RX:
  1831. case SLIMBUS_7_RX:
  1832. case SLIMBUS_8_RX:
  1833. case SLIMBUS_0_TX:
  1834. case SLIMBUS_1_TX:
  1835. case SLIMBUS_2_TX:
  1836. case SLIMBUS_3_TX:
  1837. case SLIMBUS_4_TX:
  1838. case SLIMBUS_5_TX:
  1839. case SLIMBUS_6_TX:
  1840. case SLIMBUS_7_TX:
  1841. case SLIMBUS_8_TX:
  1842. rc = msm_dai_q6_slim_bus_hw_params(params, dai,
  1843. substream->stream);
  1844. break;
  1845. case INT_BT_SCO_RX:
  1846. case INT_BT_SCO_TX:
  1847. case INT_BT_A2DP_RX:
  1848. case INT_FM_RX:
  1849. case INT_FM_TX:
  1850. rc = msm_dai_q6_bt_fm_hw_params(params, dai, substream->stream);
  1851. break;
  1852. case AFE_PORT_ID_USB_RX:
  1853. case AFE_PORT_ID_USB_TX:
  1854. rc = msm_dai_q6_usb_audio_hw_params(params, dai,
  1855. substream->stream);
  1856. break;
  1857. case RT_PROXY_DAI_001_TX:
  1858. case RT_PROXY_DAI_001_RX:
  1859. case RT_PROXY_DAI_002_TX:
  1860. case RT_PROXY_DAI_002_RX:
  1861. rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai);
  1862. break;
  1863. case VOICE_PLAYBACK_TX:
  1864. case VOICE2_PLAYBACK_TX:
  1865. case VOICE_RECORD_RX:
  1866. case VOICE_RECORD_TX:
  1867. rc = msm_dai_q6_pseudo_port_hw_params(params,
  1868. dai, substream->stream);
  1869. break;
  1870. default:
  1871. dev_err(dai->dev, "invalid AFE port ID 0x%x\n", dai->id);
  1872. rc = -EINVAL;
  1873. break;
  1874. }
  1875. return rc;
  1876. }
  1877. static void msm_dai_q6_shutdown(struct snd_pcm_substream *substream,
  1878. struct snd_soc_dai *dai)
  1879. {
  1880. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1881. int rc = 0;
  1882. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  1883. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  1884. rc = afe_close(dai->id); /* can block */
  1885. if (rc < 0)
  1886. dev_err(dai->dev, "fail to close AFE port\n");
  1887. pr_debug("%s: dai_data->status_mask = %ld\n", __func__,
  1888. *dai_data->status_mask);
  1889. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  1890. }
  1891. }
  1892. static int msm_dai_q6_cdc_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  1893. {
  1894. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1895. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  1896. case SND_SOC_DAIFMT_CBS_CFS:
  1897. dai_data->port_config.i2s.ws_src = 1; /* CPU is master */
  1898. break;
  1899. case SND_SOC_DAIFMT_CBM_CFM:
  1900. dai_data->port_config.i2s.ws_src = 0; /* CPU is slave */
  1901. break;
  1902. default:
  1903. pr_err("%s: fmt 0x%x\n",
  1904. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  1905. return -EINVAL;
  1906. }
  1907. return 0;
  1908. }
  1909. static int msm_dai_q6_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  1910. {
  1911. int rc = 0;
  1912. dev_dbg(dai->dev, "%s: id = %d fmt[%d]\n", __func__,
  1913. dai->id, fmt);
  1914. switch (dai->id) {
  1915. case PRIMARY_I2S_TX:
  1916. case PRIMARY_I2S_RX:
  1917. case MI2S_RX:
  1918. case SECONDARY_I2S_RX:
  1919. rc = msm_dai_q6_cdc_set_fmt(dai, fmt);
  1920. break;
  1921. default:
  1922. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  1923. rc = -EINVAL;
  1924. break;
  1925. }
  1926. return rc;
  1927. }
  1928. static int msm_dai_q6_set_channel_map(struct snd_soc_dai *dai,
  1929. unsigned int tx_num, unsigned int *tx_slot,
  1930. unsigned int rx_num, unsigned int *rx_slot)
  1931. {
  1932. int rc = 0;
  1933. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  1934. unsigned int i = 0;
  1935. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  1936. switch (dai->id) {
  1937. case SLIMBUS_0_RX:
  1938. case SLIMBUS_1_RX:
  1939. case SLIMBUS_2_RX:
  1940. case SLIMBUS_3_RX:
  1941. case SLIMBUS_4_RX:
  1942. case SLIMBUS_5_RX:
  1943. case SLIMBUS_6_RX:
  1944. case SLIMBUS_7_RX:
  1945. case SLIMBUS_8_RX:
  1946. /*
  1947. * channel number to be between 128 and 255.
  1948. * For RX port use channel numbers
  1949. * from 138 to 144 for pre-Taiko
  1950. * from 144 to 159 for Taiko
  1951. */
  1952. if (!rx_slot) {
  1953. pr_err("%s: rx slot not found\n", __func__);
  1954. return -EINVAL;
  1955. }
  1956. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  1957. pr_err("%s: invalid rx num %d\n", __func__, rx_num);
  1958. return -EINVAL;
  1959. }
  1960. for (i = 0; i < rx_num; i++) {
  1961. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  1962. rx_slot[i];
  1963. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  1964. __func__, i, rx_slot[i]);
  1965. }
  1966. dai_data->port_config.slim_sch.num_channels = rx_num;
  1967. pr_debug("%s: SLIMBUS_%d_RX cnt[%d] ch[%d %d]\n", __func__,
  1968. (dai->id - SLIMBUS_0_RX) / 2, rx_num,
  1969. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  1970. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  1971. break;
  1972. case SLIMBUS_0_TX:
  1973. case SLIMBUS_1_TX:
  1974. case SLIMBUS_2_TX:
  1975. case SLIMBUS_3_TX:
  1976. case SLIMBUS_4_TX:
  1977. case SLIMBUS_5_TX:
  1978. case SLIMBUS_6_TX:
  1979. case SLIMBUS_7_TX:
  1980. case SLIMBUS_8_TX:
  1981. /*
  1982. * channel number to be between 128 and 255.
  1983. * For TX port use channel numbers
  1984. * from 128 to 137 for pre-Taiko
  1985. * from 128 to 143 for Taiko
  1986. */
  1987. if (!tx_slot) {
  1988. pr_err("%s: tx slot not found\n", __func__);
  1989. return -EINVAL;
  1990. }
  1991. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  1992. pr_err("%s: invalid tx num %d\n", __func__, tx_num);
  1993. return -EINVAL;
  1994. }
  1995. for (i = 0; i < tx_num; i++) {
  1996. dai_data->port_config.slim_sch.shared_ch_mapping[i] =
  1997. tx_slot[i];
  1998. pr_debug("%s: find number of channels[%d] ch[%d]\n",
  1999. __func__, i, tx_slot[i]);
  2000. }
  2001. dai_data->port_config.slim_sch.num_channels = tx_num;
  2002. pr_debug("%s:SLIMBUS_%d_TX cnt[%d] ch[%d %d]\n", __func__,
  2003. (dai->id - SLIMBUS_0_TX) / 2, tx_num,
  2004. dai_data->port_config.slim_sch.shared_ch_mapping[0],
  2005. dai_data->port_config.slim_sch.shared_ch_mapping[1]);
  2006. break;
  2007. default:
  2008. dev_err(dai->dev, "invalid cpu_dai id 0x%x\n", dai->id);
  2009. rc = -EINVAL;
  2010. break;
  2011. }
  2012. return rc;
  2013. }
  2014. static struct snd_soc_dai_ops msm_dai_q6_ops = {
  2015. .prepare = msm_dai_q6_prepare,
  2016. .hw_params = msm_dai_q6_hw_params,
  2017. .shutdown = msm_dai_q6_shutdown,
  2018. .set_fmt = msm_dai_q6_set_fmt,
  2019. .set_channel_map = msm_dai_q6_set_channel_map,
  2020. };
  2021. /*
  2022. * For single CPU DAI registration, the dai id needs to be
  2023. * set explicitly in the dai probe as ASoC does not read
  2024. * the cpu->driver->id field rather it assigns the dai id
  2025. * from the device name that is in the form %s.%d. This dai
  2026. * id should be assigned to back-end AFE port id and used
  2027. * during dai prepare. For multiple dai registration, it
  2028. * is not required to call this function, however the dai->
  2029. * driver->id field must be defined and set to corresponding
  2030. * AFE Port id.
  2031. */
  2032. static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
  2033. {
  2034. if (!dai->driver->id) {
  2035. dev_warn(dai->dev, "DAI driver id is not set\n");
  2036. return;
  2037. }
  2038. dai->id = dai->driver->id;
  2039. }
  2040. static int msm_dai_q6_cal_info_put(struct snd_kcontrol *kcontrol,
  2041. struct snd_ctl_elem_value *ucontrol)
  2042. {
  2043. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2044. u16 port_id = ((struct soc_enum *)
  2045. kcontrol->private_value)->reg;
  2046. dai_data->cal_mode = ucontrol->value.integer.value[0];
  2047. pr_debug("%s: setting cal_mode to %d\n",
  2048. __func__, dai_data->cal_mode);
  2049. afe_set_cal_mode(port_id, dai_data->cal_mode);
  2050. return 0;
  2051. }
  2052. static int msm_dai_q6_cal_info_get(struct snd_kcontrol *kcontrol,
  2053. struct snd_ctl_elem_value *ucontrol)
  2054. {
  2055. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2056. ucontrol->value.integer.value[0] = dai_data->cal_mode;
  2057. return 0;
  2058. }
  2059. static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
  2060. struct snd_ctl_elem_value *ucontrol)
  2061. {
  2062. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2063. int value = ucontrol->value.integer.value[0];
  2064. if (dai_data) {
  2065. dai_data->port_config.slim_sch.data_format = value;
  2066. pr_debug("%s: format = %d\n", __func__, value);
  2067. }
  2068. return 0;
  2069. }
  2070. static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
  2071. struct snd_ctl_elem_value *ucontrol)
  2072. {
  2073. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2074. if (dai_data)
  2075. ucontrol->value.integer.value[0] =
  2076. dai_data->port_config.slim_sch.data_format;
  2077. return 0;
  2078. }
  2079. static int msm_dai_q6_usb_audio_cfg_put(struct snd_kcontrol *kcontrol,
  2080. struct snd_ctl_elem_value *ucontrol)
  2081. {
  2082. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2083. u32 val = ucontrol->value.integer.value[0];
  2084. if (dai_data) {
  2085. dai_data->port_config.usb_audio.dev_token = val;
  2086. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2087. dai_data->port_config.usb_audio.dev_token);
  2088. } else {
  2089. pr_err("%s: dai_data is NULL\n", __func__);
  2090. }
  2091. return 0;
  2092. }
  2093. static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol,
  2094. struct snd_ctl_elem_value *ucontrol)
  2095. {
  2096. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2097. if (dai_data) {
  2098. ucontrol->value.integer.value[0] =
  2099. dai_data->port_config.usb_audio.dev_token;
  2100. pr_debug("%s: dev_token = 0x%x\n", __func__,
  2101. dai_data->port_config.usb_audio.dev_token);
  2102. } else {
  2103. pr_err("%s: dai_data is NULL\n", __func__);
  2104. }
  2105. return 0;
  2106. }
  2107. static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol,
  2108. struct snd_ctl_elem_value *ucontrol)
  2109. {
  2110. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2111. u32 val = ucontrol->value.integer.value[0];
  2112. if (dai_data) {
  2113. dai_data->port_config.usb_audio.endian = val;
  2114. pr_debug("%s: endian = 0x%x\n", __func__,
  2115. dai_data->port_config.usb_audio.endian);
  2116. } else {
  2117. pr_err("%s: dai_data is NULL\n", __func__);
  2118. return -EINVAL;
  2119. }
  2120. return 0;
  2121. }
  2122. static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol,
  2123. struct snd_ctl_elem_value *ucontrol)
  2124. {
  2125. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2126. if (dai_data) {
  2127. ucontrol->value.integer.value[0] =
  2128. dai_data->port_config.usb_audio.endian;
  2129. pr_debug("%s: endian = 0x%x\n", __func__,
  2130. dai_data->port_config.usb_audio.endian);
  2131. } else {
  2132. pr_err("%s: dai_data is NULL\n", __func__);
  2133. return -EINVAL;
  2134. }
  2135. return 0;
  2136. }
  2137. static int msm_dai_q6_usb_audio_svc_interval_put(struct snd_kcontrol *kcontrol,
  2138. struct snd_ctl_elem_value *ucontrol)
  2139. {
  2140. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2141. u32 val = ucontrol->value.integer.value[0];
  2142. if (!dai_data) {
  2143. pr_err("%s: dai_data is NULL\n", __func__);
  2144. return -EINVAL;
  2145. }
  2146. dai_data->port_config.usb_audio.service_interval = val;
  2147. pr_debug("%s: new service interval = %u\n", __func__,
  2148. dai_data->port_config.usb_audio.service_interval);
  2149. return 0;
  2150. }
  2151. static int msm_dai_q6_usb_audio_svc_interval_get(struct snd_kcontrol *kcontrol,
  2152. struct snd_ctl_elem_value *ucontrol)
  2153. {
  2154. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2155. if (!dai_data) {
  2156. pr_err("%s: dai_data is NULL\n", __func__);
  2157. return -EINVAL;
  2158. }
  2159. ucontrol->value.integer.value[0] =
  2160. dai_data->port_config.usb_audio.service_interval;
  2161. pr_debug("%s: service interval = %d\n", __func__,
  2162. dai_data->port_config.usb_audio.service_interval);
  2163. return 0;
  2164. }
  2165. static int msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol,
  2166. struct snd_ctl_elem_info *uinfo)
  2167. {
  2168. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2169. uinfo->count = sizeof(struct afe_enc_config);
  2170. return 0;
  2171. }
  2172. static int msm_dai_q6_afe_enc_cfg_get(struct snd_kcontrol *kcontrol,
  2173. struct snd_ctl_elem_value *ucontrol)
  2174. {
  2175. int ret = 0;
  2176. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2177. if (dai_data) {
  2178. int format_size = sizeof(dai_data->enc_config.format);
  2179. pr_debug("%s: encoder config for %d format\n",
  2180. __func__, dai_data->enc_config.format);
  2181. memcpy(ucontrol->value.bytes.data,
  2182. &dai_data->enc_config.format,
  2183. format_size);
  2184. switch (dai_data->enc_config.format) {
  2185. case ENC_FMT_SBC:
  2186. memcpy(ucontrol->value.bytes.data + format_size,
  2187. &dai_data->enc_config.data,
  2188. sizeof(struct asm_sbc_enc_cfg_t));
  2189. break;
  2190. case ENC_FMT_AAC_V2:
  2191. memcpy(ucontrol->value.bytes.data + format_size,
  2192. &dai_data->enc_config.data,
  2193. sizeof(struct asm_aac_enc_cfg_v2_t));
  2194. break;
  2195. case ENC_FMT_APTX:
  2196. memcpy(ucontrol->value.bytes.data + format_size,
  2197. &dai_data->enc_config.data,
  2198. sizeof(struct asm_aptx_enc_cfg_t));
  2199. break;
  2200. case ENC_FMT_APTX_HD:
  2201. memcpy(ucontrol->value.bytes.data + format_size,
  2202. &dai_data->enc_config.data,
  2203. sizeof(struct asm_custom_enc_cfg_t));
  2204. break;
  2205. case ENC_FMT_CELT:
  2206. memcpy(ucontrol->value.bytes.data + format_size,
  2207. &dai_data->enc_config.data,
  2208. sizeof(struct asm_celt_enc_cfg_t));
  2209. break;
  2210. case ENC_FMT_LDAC:
  2211. memcpy(ucontrol->value.bytes.data + format_size,
  2212. &dai_data->enc_config.data,
  2213. sizeof(struct asm_ldac_enc_cfg_t));
  2214. break;
  2215. case ENC_FMT_APTX_ADAPTIVE:
  2216. memcpy(ucontrol->value.bytes.data + format_size,
  2217. &dai_data->enc_config.data,
  2218. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2219. break;
  2220. default:
  2221. pr_debug("%s: unknown format = %d\n",
  2222. __func__, dai_data->enc_config.format);
  2223. ret = -EINVAL;
  2224. break;
  2225. }
  2226. }
  2227. return ret;
  2228. }
  2229. static int msm_dai_q6_afe_enc_cfg_put(struct snd_kcontrol *kcontrol,
  2230. struct snd_ctl_elem_value *ucontrol)
  2231. {
  2232. int ret = 0;
  2233. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2234. if (dai_data) {
  2235. int format_size = sizeof(dai_data->enc_config.format);
  2236. memset(&dai_data->enc_config, 0x0,
  2237. sizeof(struct afe_enc_config));
  2238. memcpy(&dai_data->enc_config.format,
  2239. ucontrol->value.bytes.data,
  2240. format_size);
  2241. pr_debug("%s: Received encoder config for %d format\n",
  2242. __func__, dai_data->enc_config.format);
  2243. switch (dai_data->enc_config.format) {
  2244. case ENC_FMT_SBC:
  2245. memcpy(&dai_data->enc_config.data,
  2246. ucontrol->value.bytes.data + format_size,
  2247. sizeof(struct asm_sbc_enc_cfg_t));
  2248. break;
  2249. case ENC_FMT_AAC_V2:
  2250. memcpy(&dai_data->enc_config.data,
  2251. ucontrol->value.bytes.data + format_size,
  2252. sizeof(struct asm_aac_enc_cfg_v2_t));
  2253. break;
  2254. case ENC_FMT_APTX:
  2255. memcpy(&dai_data->enc_config.data,
  2256. ucontrol->value.bytes.data + format_size,
  2257. sizeof(struct asm_aptx_enc_cfg_t));
  2258. break;
  2259. case ENC_FMT_APTX_HD:
  2260. memcpy(&dai_data->enc_config.data,
  2261. ucontrol->value.bytes.data + format_size,
  2262. sizeof(struct asm_custom_enc_cfg_t));
  2263. break;
  2264. case ENC_FMT_CELT:
  2265. memcpy(&dai_data->enc_config.data,
  2266. ucontrol->value.bytes.data + format_size,
  2267. sizeof(struct asm_celt_enc_cfg_t));
  2268. break;
  2269. case ENC_FMT_LDAC:
  2270. memcpy(&dai_data->enc_config.data,
  2271. ucontrol->value.bytes.data + format_size,
  2272. sizeof(struct asm_ldac_enc_cfg_t));
  2273. break;
  2274. case ENC_FMT_APTX_ADAPTIVE:
  2275. memcpy(&dai_data->enc_config.data,
  2276. ucontrol->value.bytes.data + format_size,
  2277. sizeof(struct asm_aptx_ad_enc_cfg_t));
  2278. break;
  2279. default:
  2280. pr_debug("%s: Ignore enc config for unknown format = %d\n",
  2281. __func__, dai_data->enc_config.format);
  2282. ret = -EINVAL;
  2283. break;
  2284. }
  2285. } else
  2286. ret = -EINVAL;
  2287. return ret;
  2288. }
  2289. static const char *const afe_input_chs_text[] = {"Zero", "One", "Two"};
  2290. static const struct soc_enum afe_input_chs_enum[] = {
  2291. SOC_ENUM_SINGLE_EXT(3, afe_input_chs_text),
  2292. };
  2293. static const char *const afe_input_bit_format_text[] = {"S16_LE", "S24_LE",
  2294. "S32_LE"};
  2295. static const struct soc_enum afe_input_bit_format_enum[] = {
  2296. SOC_ENUM_SINGLE_EXT(3, afe_input_bit_format_text),
  2297. };
  2298. static int msm_dai_q6_afe_input_channel_get(struct snd_kcontrol *kcontrol,
  2299. struct snd_ctl_elem_value *ucontrol)
  2300. {
  2301. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2302. if (dai_data) {
  2303. ucontrol->value.integer.value[0] = dai_data->afe_in_channels;
  2304. pr_debug("%s:afe input channel = %d\n",
  2305. __func__, dai_data->afe_in_channels);
  2306. }
  2307. return 0;
  2308. }
  2309. static int msm_dai_q6_afe_input_channel_put(struct snd_kcontrol *kcontrol,
  2310. struct snd_ctl_elem_value *ucontrol)
  2311. {
  2312. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2313. if (dai_data) {
  2314. dai_data->afe_in_channels = ucontrol->value.integer.value[0];
  2315. pr_debug("%s: updating afe input channel : %d\n",
  2316. __func__, dai_data->afe_in_channels);
  2317. }
  2318. return 0;
  2319. }
  2320. static int msm_dai_q6_afe_input_bit_format_get(
  2321. struct snd_kcontrol *kcontrol,
  2322. struct snd_ctl_elem_value *ucontrol)
  2323. {
  2324. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2325. if (!dai_data) {
  2326. pr_err("%s: Invalid dai data\n", __func__);
  2327. return -EINVAL;
  2328. }
  2329. switch (dai_data->afe_in_bitformat) {
  2330. case SNDRV_PCM_FORMAT_S32_LE:
  2331. ucontrol->value.integer.value[0] = 2;
  2332. break;
  2333. case SNDRV_PCM_FORMAT_S24_LE:
  2334. ucontrol->value.integer.value[0] = 1;
  2335. break;
  2336. case SNDRV_PCM_FORMAT_S16_LE:
  2337. default:
  2338. ucontrol->value.integer.value[0] = 0;
  2339. break;
  2340. }
  2341. pr_debug("%s: afe input bit format : %ld\n",
  2342. __func__, ucontrol->value.integer.value[0]);
  2343. return 0;
  2344. }
  2345. static int msm_dai_q6_afe_input_bit_format_put(
  2346. struct snd_kcontrol *kcontrol,
  2347. struct snd_ctl_elem_value *ucontrol)
  2348. {
  2349. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2350. if (!dai_data) {
  2351. pr_err("%s: Invalid dai data\n", __func__);
  2352. return -EINVAL;
  2353. }
  2354. switch (ucontrol->value.integer.value[0]) {
  2355. case 2:
  2356. dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S32_LE;
  2357. break;
  2358. case 1:
  2359. dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S24_LE;
  2360. break;
  2361. case 0:
  2362. default:
  2363. dai_data->afe_in_bitformat = SNDRV_PCM_FORMAT_S16_LE;
  2364. break;
  2365. }
  2366. pr_debug("%s: updating afe input bit format : %d\n",
  2367. __func__, dai_data->afe_in_bitformat);
  2368. return 0;
  2369. }
  2370. static int msm_dai_q6_afe_scrambler_mode_get(
  2371. struct snd_kcontrol *kcontrol,
  2372. struct snd_ctl_elem_value *ucontrol)
  2373. {
  2374. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2375. if (!dai_data) {
  2376. pr_err("%s: Invalid dai data\n", __func__);
  2377. return -EINVAL;
  2378. }
  2379. ucontrol->value.integer.value[0] = dai_data->enc_config.scrambler_mode;
  2380. return 0;
  2381. }
  2382. static int msm_dai_q6_afe_scrambler_mode_put(
  2383. struct snd_kcontrol *kcontrol,
  2384. struct snd_ctl_elem_value *ucontrol)
  2385. {
  2386. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2387. if (!dai_data) {
  2388. pr_err("%s: Invalid dai data\n", __func__);
  2389. return -EINVAL;
  2390. }
  2391. dai_data->enc_config.scrambler_mode = ucontrol->value.integer.value[0];
  2392. pr_debug("%s: afe scrambler mode : %d\n",
  2393. __func__, dai_data->enc_config.scrambler_mode);
  2394. return 0;
  2395. }
  2396. static const struct snd_kcontrol_new afe_enc_config_controls[] = {
  2397. {
  2398. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  2399. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  2400. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2401. .name = "SLIM_7_RX Encoder Config",
  2402. .info = msm_dai_q6_afe_enc_cfg_info,
  2403. .get = msm_dai_q6_afe_enc_cfg_get,
  2404. .put = msm_dai_q6_afe_enc_cfg_put,
  2405. },
  2406. SOC_ENUM_EXT("AFE Input Channels", afe_input_chs_enum[0],
  2407. msm_dai_q6_afe_input_channel_get,
  2408. msm_dai_q6_afe_input_channel_put),
  2409. SOC_ENUM_EXT("AFE Input Bit Format", afe_input_bit_format_enum[0],
  2410. msm_dai_q6_afe_input_bit_format_get,
  2411. msm_dai_q6_afe_input_bit_format_put),
  2412. SOC_SINGLE_EXT("AFE Scrambler Mode",
  2413. 0, 0, 1, 0,
  2414. msm_dai_q6_afe_scrambler_mode_get,
  2415. msm_dai_q6_afe_scrambler_mode_put),
  2416. };
  2417. static int msm_dai_q6_afe_dec_cfg_info(struct snd_kcontrol *kcontrol,
  2418. struct snd_ctl_elem_info *uinfo)
  2419. {
  2420. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2421. uinfo->count = sizeof(struct afe_dec_config);
  2422. return 0;
  2423. }
  2424. static int msm_dai_q6_afe_dec_cfg_get(struct snd_kcontrol *kcontrol,
  2425. struct snd_ctl_elem_value *ucontrol)
  2426. {
  2427. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2428. int format_size = 0;
  2429. if (!dai_data) {
  2430. pr_err("%s: Invalid dai data\n", __func__);
  2431. return -EINVAL;
  2432. }
  2433. format_size = sizeof(dai_data->dec_config.format);
  2434. memcpy(ucontrol->value.bytes.data,
  2435. &dai_data->dec_config.format,
  2436. format_size);
  2437. memcpy(ucontrol->value.bytes.data + format_size,
  2438. &dai_data->dec_config.abr_dec_cfg,
  2439. sizeof(struct afe_abr_dec_cfg_t));
  2440. return 0;
  2441. }
  2442. static int msm_dai_q6_afe_dec_cfg_put(struct snd_kcontrol *kcontrol,
  2443. struct snd_ctl_elem_value *ucontrol)
  2444. {
  2445. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  2446. int format_size = 0;
  2447. if (!dai_data) {
  2448. pr_err("%s: Invalid dai data\n", __func__);
  2449. return -EINVAL;
  2450. }
  2451. memset(&dai_data->dec_config, 0x0,
  2452. sizeof(struct afe_dec_config));
  2453. format_size = sizeof(dai_data->dec_config.format);
  2454. memcpy(&dai_data->dec_config.format,
  2455. ucontrol->value.bytes.data,
  2456. format_size);
  2457. memcpy(&dai_data->dec_config.abr_dec_cfg,
  2458. ucontrol->value.bytes.data + format_size,
  2459. sizeof(struct afe_abr_dec_cfg_t));
  2460. return 0;
  2461. }
  2462. static const struct snd_kcontrol_new afe_dec_config_controls[] = {
  2463. {
  2464. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  2465. SNDRV_CTL_ELEM_ACCESS_INACTIVE),
  2466. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2467. .name = "SLIM_7_TX Decoder Config",
  2468. .info = msm_dai_q6_afe_dec_cfg_info,
  2469. .get = msm_dai_q6_afe_dec_cfg_get,
  2470. .put = msm_dai_q6_afe_dec_cfg_put,
  2471. },
  2472. };
  2473. static int msm_dai_q6_slim_rx_drift_info(struct snd_kcontrol *kcontrol,
  2474. struct snd_ctl_elem_info *uinfo)
  2475. {
  2476. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  2477. uinfo->count = sizeof(struct afe_param_id_dev_timing_stats);
  2478. return 0;
  2479. }
  2480. static int msm_dai_q6_slim_rx_drift_get(struct snd_kcontrol *kcontrol,
  2481. struct snd_ctl_elem_value *ucontrol)
  2482. {
  2483. int ret = -EINVAL;
  2484. struct afe_param_id_dev_timing_stats timing_stats;
  2485. struct snd_soc_dai *dai = kcontrol->private_data;
  2486. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  2487. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2488. pr_err("%s: afe port not started. dai_data->status_mask = %ld\n",
  2489. __func__, *dai_data->status_mask);
  2490. goto done;
  2491. }
  2492. memset(&timing_stats, 0, sizeof(struct afe_param_id_dev_timing_stats));
  2493. ret = afe_get_av_dev_drift(&timing_stats, dai->id);
  2494. if (ret) {
  2495. pr_err("%s: Error getting AFE Drift for port %d, err=%d\n",
  2496. __func__, dai->id, ret);
  2497. goto done;
  2498. }
  2499. memcpy(ucontrol->value.bytes.data, (void *)&timing_stats,
  2500. sizeof(struct afe_param_id_dev_timing_stats));
  2501. done:
  2502. return ret;
  2503. }
  2504. static const char * const afe_cal_mode_text[] = {
  2505. "CAL_MODE_DEFAULT", "CAL_MODE_NONE"
  2506. };
  2507. static const struct soc_enum slim_2_rx_enum =
  2508. SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2509. afe_cal_mode_text);
  2510. static const struct soc_enum rt_proxy_1_rx_enum =
  2511. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_RX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2512. afe_cal_mode_text);
  2513. static const struct soc_enum rt_proxy_1_tx_enum =
  2514. SOC_ENUM_SINGLE(RT_PROXY_PORT_001_TX, 0, ARRAY_SIZE(afe_cal_mode_text),
  2515. afe_cal_mode_text);
  2516. static const struct snd_kcontrol_new sb_config_controls[] = {
  2517. SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
  2518. msm_dai_q6_sb_format_get,
  2519. msm_dai_q6_sb_format_put),
  2520. SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
  2521. msm_dai_q6_cal_info_get,
  2522. msm_dai_q6_cal_info_put),
  2523. SOC_ENUM_EXT("SLIM_2_RX Format", sb_config_enum[0],
  2524. msm_dai_q6_sb_format_get,
  2525. msm_dai_q6_sb_format_put)
  2526. };
  2527. static const struct snd_kcontrol_new rt_proxy_config_controls[] = {
  2528. SOC_ENUM_EXT("RT_PROXY_1_RX SetCalMode", rt_proxy_1_rx_enum,
  2529. msm_dai_q6_cal_info_get,
  2530. msm_dai_q6_cal_info_put),
  2531. SOC_ENUM_EXT("RT_PROXY_1_TX SetCalMode", rt_proxy_1_tx_enum,
  2532. msm_dai_q6_cal_info_get,
  2533. msm_dai_q6_cal_info_put),
  2534. };
  2535. static const struct snd_kcontrol_new usb_audio_cfg_controls[] = {
  2536. SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0,
  2537. msm_dai_q6_usb_audio_cfg_get,
  2538. msm_dai_q6_usb_audio_cfg_put),
  2539. SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0,
  2540. msm_dai_q6_usb_audio_endian_cfg_get,
  2541. msm_dai_q6_usb_audio_endian_cfg_put),
  2542. SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0,
  2543. msm_dai_q6_usb_audio_cfg_get,
  2544. msm_dai_q6_usb_audio_cfg_put),
  2545. SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0,
  2546. msm_dai_q6_usb_audio_endian_cfg_get,
  2547. msm_dai_q6_usb_audio_endian_cfg_put),
  2548. SOC_SINGLE_EXT("USB_AUDIO_RX service_interval", SND_SOC_NOPM, 0,
  2549. UINT_MAX, 0,
  2550. msm_dai_q6_usb_audio_svc_interval_get,
  2551. msm_dai_q6_usb_audio_svc_interval_put),
  2552. };
  2553. static const struct snd_kcontrol_new avd_drift_config_controls[] = {
  2554. {
  2555. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2556. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2557. .name = "SLIMBUS_0_RX DRIFT",
  2558. .info = msm_dai_q6_slim_rx_drift_info,
  2559. .get = msm_dai_q6_slim_rx_drift_get,
  2560. },
  2561. {
  2562. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2563. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2564. .name = "SLIMBUS_6_RX DRIFT",
  2565. .info = msm_dai_q6_slim_rx_drift_info,
  2566. .get = msm_dai_q6_slim_rx_drift_get,
  2567. },
  2568. {
  2569. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  2570. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  2571. .name = "SLIMBUS_7_RX DRIFT",
  2572. .info = msm_dai_q6_slim_rx_drift_info,
  2573. .get = msm_dai_q6_slim_rx_drift_get,
  2574. },
  2575. };
  2576. static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
  2577. {
  2578. struct msm_dai_q6_dai_data *dai_data;
  2579. int rc = 0;
  2580. if (!dai) {
  2581. pr_err("%s: Invalid params dai\n", __func__);
  2582. return -EINVAL;
  2583. }
  2584. if (!dai->dev) {
  2585. pr_err("%s: Invalid params dai dev\n", __func__);
  2586. return -EINVAL;
  2587. }
  2588. dai_data = kzalloc(sizeof(struct msm_dai_q6_dai_data), GFP_KERNEL);
  2589. if (!dai_data)
  2590. rc = -ENOMEM;
  2591. else
  2592. dev_set_drvdata(dai->dev, dai_data);
  2593. msm_dai_q6_set_dai_id(dai);
  2594. switch (dai->id) {
  2595. case SLIMBUS_4_TX:
  2596. rc = snd_ctl_add(dai->component->card->snd_card,
  2597. snd_ctl_new1(&sb_config_controls[0],
  2598. dai_data));
  2599. break;
  2600. case SLIMBUS_2_RX:
  2601. rc = snd_ctl_add(dai->component->card->snd_card,
  2602. snd_ctl_new1(&sb_config_controls[1],
  2603. dai_data));
  2604. rc = snd_ctl_add(dai->component->card->snd_card,
  2605. snd_ctl_new1(&sb_config_controls[2],
  2606. dai_data));
  2607. break;
  2608. case SLIMBUS_7_RX:
  2609. rc = snd_ctl_add(dai->component->card->snd_card,
  2610. snd_ctl_new1(&afe_enc_config_controls[0],
  2611. dai_data));
  2612. rc = snd_ctl_add(dai->component->card->snd_card,
  2613. snd_ctl_new1(&afe_enc_config_controls[1],
  2614. dai_data));
  2615. rc = snd_ctl_add(dai->component->card->snd_card,
  2616. snd_ctl_new1(&afe_enc_config_controls[2],
  2617. dai_data));
  2618. rc = snd_ctl_add(dai->component->card->snd_card,
  2619. snd_ctl_new1(&afe_enc_config_controls[3],
  2620. dai_data));
  2621. rc = snd_ctl_add(dai->component->card->snd_card,
  2622. snd_ctl_new1(&avd_drift_config_controls[2],
  2623. dai));
  2624. break;
  2625. case SLIMBUS_7_TX:
  2626. rc = snd_ctl_add(dai->component->card->snd_card,
  2627. snd_ctl_new1(&afe_dec_config_controls[0],
  2628. dai_data));
  2629. break;
  2630. case RT_PROXY_DAI_001_RX:
  2631. rc = snd_ctl_add(dai->component->card->snd_card,
  2632. snd_ctl_new1(&rt_proxy_config_controls[0],
  2633. dai_data));
  2634. break;
  2635. case RT_PROXY_DAI_001_TX:
  2636. rc = snd_ctl_add(dai->component->card->snd_card,
  2637. snd_ctl_new1(&rt_proxy_config_controls[1],
  2638. dai_data));
  2639. break;
  2640. case AFE_PORT_ID_USB_RX:
  2641. rc = snd_ctl_add(dai->component->card->snd_card,
  2642. snd_ctl_new1(&usb_audio_cfg_controls[0],
  2643. dai_data));
  2644. rc = snd_ctl_add(dai->component->card->snd_card,
  2645. snd_ctl_new1(&usb_audio_cfg_controls[1],
  2646. dai_data));
  2647. rc = snd_ctl_add(dai->component->card->snd_card,
  2648. snd_ctl_new1(&usb_audio_cfg_controls[4],
  2649. dai_data));
  2650. break;
  2651. case AFE_PORT_ID_USB_TX:
  2652. rc = snd_ctl_add(dai->component->card->snd_card,
  2653. snd_ctl_new1(&usb_audio_cfg_controls[2],
  2654. dai_data));
  2655. rc = snd_ctl_add(dai->component->card->snd_card,
  2656. snd_ctl_new1(&usb_audio_cfg_controls[3],
  2657. dai_data));
  2658. break;
  2659. case SLIMBUS_0_RX:
  2660. rc = snd_ctl_add(dai->component->card->snd_card,
  2661. snd_ctl_new1(&avd_drift_config_controls[0],
  2662. dai));
  2663. break;
  2664. case SLIMBUS_6_RX:
  2665. rc = snd_ctl_add(dai->component->card->snd_card,
  2666. snd_ctl_new1(&avd_drift_config_controls[1],
  2667. dai));
  2668. break;
  2669. }
  2670. if (rc < 0)
  2671. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  2672. __func__, dai->name);
  2673. rc = msm_dai_q6_dai_add_route(dai);
  2674. return rc;
  2675. }
  2676. static int msm_dai_q6_dai_remove(struct snd_soc_dai *dai)
  2677. {
  2678. struct msm_dai_q6_dai_data *dai_data;
  2679. int rc;
  2680. dai_data = dev_get_drvdata(dai->dev);
  2681. /* If AFE port is still up, close it */
  2682. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  2683. pr_debug("%s: stop pseudo port:%d\n", __func__, dai->id);
  2684. rc = afe_close(dai->id); /* can block */
  2685. if (rc < 0)
  2686. dev_err(dai->dev, "fail to close AFE port\n");
  2687. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  2688. }
  2689. kfree(dai_data);
  2690. return 0;
  2691. }
  2692. static struct snd_soc_dai_driver msm_dai_q6_afe_rx_dai[] = {
  2693. {
  2694. .playback = {
  2695. .stream_name = "AFE Playback",
  2696. .aif_name = "PCM_RX",
  2697. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2698. SNDRV_PCM_RATE_16000,
  2699. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2700. SNDRV_PCM_FMTBIT_S24_LE,
  2701. .channels_min = 1,
  2702. .channels_max = 2,
  2703. .rate_min = 8000,
  2704. .rate_max = 48000,
  2705. },
  2706. .ops = &msm_dai_q6_ops,
  2707. .id = RT_PROXY_DAI_001_RX,
  2708. .probe = msm_dai_q6_dai_probe,
  2709. .remove = msm_dai_q6_dai_remove,
  2710. },
  2711. {
  2712. .playback = {
  2713. .stream_name = "AFE-PROXY RX",
  2714. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2715. SNDRV_PCM_RATE_16000,
  2716. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  2717. SNDRV_PCM_FMTBIT_S24_LE,
  2718. .channels_min = 1,
  2719. .channels_max = 2,
  2720. .rate_min = 8000,
  2721. .rate_max = 48000,
  2722. },
  2723. .ops = &msm_dai_q6_ops,
  2724. .id = RT_PROXY_DAI_002_RX,
  2725. .probe = msm_dai_q6_dai_probe,
  2726. .remove = msm_dai_q6_dai_remove,
  2727. },
  2728. };
  2729. static struct snd_soc_dai_driver msm_dai_q6_afe_tx_dai[] = {
  2730. {
  2731. .capture = {
  2732. .stream_name = "AFE Capture",
  2733. .aif_name = "PCM_TX",
  2734. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2735. SNDRV_PCM_RATE_16000,
  2736. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2737. .channels_min = 1,
  2738. .channels_max = 8,
  2739. .rate_min = 8000,
  2740. .rate_max = 48000,
  2741. },
  2742. .ops = &msm_dai_q6_ops,
  2743. .id = RT_PROXY_DAI_002_TX,
  2744. .probe = msm_dai_q6_dai_probe,
  2745. .remove = msm_dai_q6_dai_remove,
  2746. },
  2747. {
  2748. .capture = {
  2749. .stream_name = "AFE-PROXY TX",
  2750. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2751. SNDRV_PCM_RATE_16000,
  2752. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2753. .channels_min = 1,
  2754. .channels_max = 8,
  2755. .rate_min = 8000,
  2756. .rate_max = 48000,
  2757. },
  2758. .ops = &msm_dai_q6_ops,
  2759. .id = RT_PROXY_DAI_001_TX,
  2760. .probe = msm_dai_q6_dai_probe,
  2761. .remove = msm_dai_q6_dai_remove,
  2762. },
  2763. };
  2764. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_rx_dai = {
  2765. .playback = {
  2766. .stream_name = "Internal BT-SCO Playback",
  2767. .aif_name = "INT_BT_SCO_RX",
  2768. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  2769. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2770. .channels_min = 1,
  2771. .channels_max = 1,
  2772. .rate_max = 16000,
  2773. .rate_min = 8000,
  2774. },
  2775. .ops = &msm_dai_q6_ops,
  2776. .id = INT_BT_SCO_RX,
  2777. .probe = msm_dai_q6_dai_probe,
  2778. .remove = msm_dai_q6_dai_remove,
  2779. };
  2780. static struct snd_soc_dai_driver msm_dai_q6_bt_a2dp_rx_dai = {
  2781. .playback = {
  2782. .stream_name = "Internal BT-A2DP Playback",
  2783. .aif_name = "INT_BT_A2DP_RX",
  2784. .rates = SNDRV_PCM_RATE_48000,
  2785. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2786. .channels_min = 1,
  2787. .channels_max = 2,
  2788. .rate_max = 48000,
  2789. .rate_min = 48000,
  2790. },
  2791. .ops = &msm_dai_q6_ops,
  2792. .id = INT_BT_A2DP_RX,
  2793. .probe = msm_dai_q6_dai_probe,
  2794. .remove = msm_dai_q6_dai_remove,
  2795. };
  2796. static struct snd_soc_dai_driver msm_dai_q6_bt_sco_tx_dai = {
  2797. .capture = {
  2798. .stream_name = "Internal BT-SCO Capture",
  2799. .aif_name = "INT_BT_SCO_TX",
  2800. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
  2801. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2802. .channels_min = 1,
  2803. .channels_max = 1,
  2804. .rate_max = 16000,
  2805. .rate_min = 8000,
  2806. },
  2807. .ops = &msm_dai_q6_ops,
  2808. .id = INT_BT_SCO_TX,
  2809. .probe = msm_dai_q6_dai_probe,
  2810. .remove = msm_dai_q6_dai_remove,
  2811. };
  2812. static struct snd_soc_dai_driver msm_dai_q6_fm_rx_dai = {
  2813. .playback = {
  2814. .stream_name = "Internal FM Playback",
  2815. .aif_name = "INT_FM_RX",
  2816. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2817. SNDRV_PCM_RATE_16000,
  2818. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2819. .channels_min = 2,
  2820. .channels_max = 2,
  2821. .rate_max = 48000,
  2822. .rate_min = 8000,
  2823. },
  2824. .ops = &msm_dai_q6_ops,
  2825. .id = INT_FM_RX,
  2826. .probe = msm_dai_q6_dai_probe,
  2827. .remove = msm_dai_q6_dai_remove,
  2828. };
  2829. static struct snd_soc_dai_driver msm_dai_q6_fm_tx_dai = {
  2830. .capture = {
  2831. .stream_name = "Internal FM Capture",
  2832. .aif_name = "INT_FM_TX",
  2833. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2834. SNDRV_PCM_RATE_16000,
  2835. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2836. .channels_min = 2,
  2837. .channels_max = 2,
  2838. .rate_max = 48000,
  2839. .rate_min = 8000,
  2840. },
  2841. .ops = &msm_dai_q6_ops,
  2842. .id = INT_FM_TX,
  2843. .probe = msm_dai_q6_dai_probe,
  2844. .remove = msm_dai_q6_dai_remove,
  2845. };
  2846. static struct snd_soc_dai_driver msm_dai_q6_voc_playback_dai[] = {
  2847. {
  2848. .playback = {
  2849. .stream_name = "Voice Farend Playback",
  2850. .aif_name = "VOICE_PLAYBACK_TX",
  2851. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2852. SNDRV_PCM_RATE_16000,
  2853. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2854. .channels_min = 1,
  2855. .channels_max = 2,
  2856. .rate_min = 8000,
  2857. .rate_max = 48000,
  2858. },
  2859. .ops = &msm_dai_q6_ops,
  2860. .id = VOICE_PLAYBACK_TX,
  2861. .probe = msm_dai_q6_dai_probe,
  2862. .remove = msm_dai_q6_dai_remove,
  2863. },
  2864. {
  2865. .playback = {
  2866. .stream_name = "Voice2 Farend Playback",
  2867. .aif_name = "VOICE2_PLAYBACK_TX",
  2868. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2869. SNDRV_PCM_RATE_16000,
  2870. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2871. .channels_min = 1,
  2872. .channels_max = 2,
  2873. .rate_min = 8000,
  2874. .rate_max = 48000,
  2875. },
  2876. .ops = &msm_dai_q6_ops,
  2877. .id = VOICE2_PLAYBACK_TX,
  2878. .probe = msm_dai_q6_dai_probe,
  2879. .remove = msm_dai_q6_dai_remove,
  2880. },
  2881. };
  2882. static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = {
  2883. {
  2884. .capture = {
  2885. .stream_name = "Voice Uplink Capture",
  2886. .aif_name = "INCALL_RECORD_TX",
  2887. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2888. SNDRV_PCM_RATE_16000,
  2889. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2890. .channels_min = 1,
  2891. .channels_max = 2,
  2892. .rate_min = 8000,
  2893. .rate_max = 48000,
  2894. },
  2895. .ops = &msm_dai_q6_ops,
  2896. .id = VOICE_RECORD_TX,
  2897. .probe = msm_dai_q6_dai_probe,
  2898. .remove = msm_dai_q6_dai_remove,
  2899. },
  2900. {
  2901. .capture = {
  2902. .stream_name = "Voice Downlink Capture",
  2903. .aif_name = "INCALL_RECORD_RX",
  2904. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  2905. SNDRV_PCM_RATE_16000,
  2906. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  2907. .channels_min = 1,
  2908. .channels_max = 2,
  2909. .rate_min = 8000,
  2910. .rate_max = 48000,
  2911. },
  2912. .ops = &msm_dai_q6_ops,
  2913. .id = VOICE_RECORD_RX,
  2914. .probe = msm_dai_q6_dai_probe,
  2915. .remove = msm_dai_q6_dai_remove,
  2916. },
  2917. };
  2918. static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = {
  2919. .playback = {
  2920. .stream_name = "USB Audio Playback",
  2921. .aif_name = "USB_AUDIO_RX",
  2922. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  2923. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  2924. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  2925. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  2926. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  2927. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  2928. SNDRV_PCM_RATE_384000,
  2929. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  2930. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  2931. .channels_min = 1,
  2932. .channels_max = 8,
  2933. .rate_max = 384000,
  2934. .rate_min = 8000,
  2935. },
  2936. .ops = &msm_dai_q6_ops,
  2937. .id = AFE_PORT_ID_USB_RX,
  2938. .probe = msm_dai_q6_dai_probe,
  2939. .remove = msm_dai_q6_dai_remove,
  2940. };
  2941. static struct snd_soc_dai_driver msm_dai_q6_usb_tx_dai = {
  2942. .capture = {
  2943. .stream_name = "USB Audio Capture",
  2944. .aif_name = "USB_AUDIO_TX",
  2945. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  2946. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  2947. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  2948. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  2949. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  2950. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  2951. SNDRV_PCM_RATE_384000,
  2952. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |
  2953. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE,
  2954. .channels_min = 1,
  2955. .channels_max = 8,
  2956. .rate_max = 384000,
  2957. .rate_min = 8000,
  2958. },
  2959. .ops = &msm_dai_q6_ops,
  2960. .id = AFE_PORT_ID_USB_TX,
  2961. .probe = msm_dai_q6_dai_probe,
  2962. .remove = msm_dai_q6_dai_remove,
  2963. };
  2964. static int msm_auxpcm_dev_probe(struct platform_device *pdev)
  2965. {
  2966. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  2967. struct msm_dai_auxpcm_pdata *auxpcm_pdata;
  2968. uint32_t val_array[RATE_MAX_NUM_OF_AUX_PCM_RATES];
  2969. uint32_t val = 0;
  2970. const char *intf_name;
  2971. int rc = 0, i = 0, len = 0;
  2972. const uint32_t *slot_mapping_array = NULL;
  2973. u32 array_length = 0;
  2974. dai_data = kzalloc(sizeof(struct msm_dai_q6_auxpcm_dai_data),
  2975. GFP_KERNEL);
  2976. if (!dai_data)
  2977. return -ENOMEM;
  2978. rc = of_property_read_u32(pdev->dev.of_node,
  2979. "qcom,msm-dai-is-island-supported",
  2980. &dai_data->is_island_dai);
  2981. if (rc)
  2982. dev_dbg(&pdev->dev, "island supported entry not found\n");
  2983. auxpcm_pdata = kzalloc(sizeof(struct msm_dai_auxpcm_pdata),
  2984. GFP_KERNEL);
  2985. if (!auxpcm_pdata) {
  2986. dev_err(&pdev->dev, "Failed to allocate memory for platform data\n");
  2987. goto fail_pdata_nomem;
  2988. }
  2989. dev_dbg(&pdev->dev, "%s: dev %pK, dai_data %pK, auxpcm_pdata %pK\n",
  2990. __func__, &pdev->dev, dai_data, auxpcm_pdata);
  2991. rc = of_property_read_u32_array(pdev->dev.of_node,
  2992. "qcom,msm-cpudai-auxpcm-mode",
  2993. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  2994. if (rc) {
  2995. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-mode missing in DT node\n",
  2996. __func__);
  2997. goto fail_invalid_dt;
  2998. }
  2999. auxpcm_pdata->mode_8k.mode = (u16)val_array[RATE_8KHZ];
  3000. auxpcm_pdata->mode_16k.mode = (u16)val_array[RATE_16KHZ];
  3001. rc = of_property_read_u32_array(pdev->dev.of_node,
  3002. "qcom,msm-cpudai-auxpcm-sync",
  3003. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3004. if (rc) {
  3005. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-sync missing in DT node\n",
  3006. __func__);
  3007. goto fail_invalid_dt;
  3008. }
  3009. auxpcm_pdata->mode_8k.sync = (u16)val_array[RATE_8KHZ];
  3010. auxpcm_pdata->mode_16k.sync = (u16)val_array[RATE_16KHZ];
  3011. rc = of_property_read_u32_array(pdev->dev.of_node,
  3012. "qcom,msm-cpudai-auxpcm-frame",
  3013. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3014. if (rc) {
  3015. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-frame missing in DT node\n",
  3016. __func__);
  3017. goto fail_invalid_dt;
  3018. }
  3019. auxpcm_pdata->mode_8k.frame = (u16)val_array[RATE_8KHZ];
  3020. auxpcm_pdata->mode_16k.frame = (u16)val_array[RATE_16KHZ];
  3021. rc = of_property_read_u32_array(pdev->dev.of_node,
  3022. "qcom,msm-cpudai-auxpcm-quant",
  3023. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3024. if (rc) {
  3025. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-quant missing in DT node\n",
  3026. __func__);
  3027. goto fail_invalid_dt;
  3028. }
  3029. auxpcm_pdata->mode_8k.quant = (u16)val_array[RATE_8KHZ];
  3030. auxpcm_pdata->mode_16k.quant = (u16)val_array[RATE_16KHZ];
  3031. rc = of_property_read_u32_array(pdev->dev.of_node,
  3032. "qcom,msm-cpudai-auxpcm-num-slots",
  3033. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3034. if (rc) {
  3035. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-num-slots missing in DT node\n",
  3036. __func__);
  3037. goto fail_invalid_dt;
  3038. }
  3039. auxpcm_pdata->mode_8k.num_slots = (u16)val_array[RATE_8KHZ];
  3040. if (auxpcm_pdata->mode_8k.num_slots >
  3041. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame)) {
  3042. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  3043. __func__,
  3044. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_8k.frame),
  3045. auxpcm_pdata->mode_8k.num_slots);
  3046. rc = -EINVAL;
  3047. goto fail_invalid_dt;
  3048. }
  3049. auxpcm_pdata->mode_16k.num_slots = (u16)val_array[RATE_16KHZ];
  3050. if (auxpcm_pdata->mode_16k.num_slots >
  3051. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame)) {
  3052. dev_err(&pdev->dev, "%s Max slots %d greater than DT node %d\n",
  3053. __func__,
  3054. msm_dai_q6_max_num_slot(auxpcm_pdata->mode_16k.frame),
  3055. auxpcm_pdata->mode_16k.num_slots);
  3056. rc = -EINVAL;
  3057. goto fail_invalid_dt;
  3058. }
  3059. slot_mapping_array = of_get_property(pdev->dev.of_node,
  3060. "qcom,msm-cpudai-auxpcm-slot-mapping", &len);
  3061. if (slot_mapping_array == NULL) {
  3062. dev_err(&pdev->dev, "%s slot_mapping_array is not valid\n",
  3063. __func__);
  3064. rc = -EINVAL;
  3065. goto fail_invalid_dt;
  3066. }
  3067. array_length = auxpcm_pdata->mode_8k.num_slots +
  3068. auxpcm_pdata->mode_16k.num_slots;
  3069. if (len != sizeof(uint32_t) * array_length) {
  3070. dev_err(&pdev->dev, "%s Length is %d and expected is %zd\n",
  3071. __func__, len, sizeof(uint32_t) * array_length);
  3072. rc = -EINVAL;
  3073. goto fail_invalid_dt;
  3074. }
  3075. auxpcm_pdata->mode_8k.slot_mapping =
  3076. kzalloc(sizeof(uint16_t) *
  3077. auxpcm_pdata->mode_8k.num_slots,
  3078. GFP_KERNEL);
  3079. if (!auxpcm_pdata->mode_8k.slot_mapping) {
  3080. dev_err(&pdev->dev, "%s No mem for mode_8k slot mapping\n",
  3081. __func__);
  3082. rc = -ENOMEM;
  3083. goto fail_invalid_dt;
  3084. }
  3085. for (i = 0; i < auxpcm_pdata->mode_8k.num_slots; i++)
  3086. auxpcm_pdata->mode_8k.slot_mapping[i] =
  3087. (u16)be32_to_cpu(slot_mapping_array[i]);
  3088. auxpcm_pdata->mode_16k.slot_mapping =
  3089. kzalloc(sizeof(uint16_t) *
  3090. auxpcm_pdata->mode_16k.num_slots,
  3091. GFP_KERNEL);
  3092. if (!auxpcm_pdata->mode_16k.slot_mapping) {
  3093. dev_err(&pdev->dev, "%s No mem for mode_16k slot mapping\n",
  3094. __func__);
  3095. rc = -ENOMEM;
  3096. goto fail_invalid_16k_slot_mapping;
  3097. }
  3098. for (i = 0; i < auxpcm_pdata->mode_16k.num_slots; i++)
  3099. auxpcm_pdata->mode_16k.slot_mapping[i] =
  3100. (u16)be32_to_cpu(slot_mapping_array[i +
  3101. auxpcm_pdata->mode_8k.num_slots]);
  3102. rc = of_property_read_u32_array(pdev->dev.of_node,
  3103. "qcom,msm-cpudai-auxpcm-data",
  3104. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3105. if (rc) {
  3106. dev_err(&pdev->dev, "%s: qcom,msm-cpudai-auxpcm-data missing in DT node\n",
  3107. __func__);
  3108. goto fail_invalid_dt1;
  3109. }
  3110. auxpcm_pdata->mode_8k.data = (u16)val_array[RATE_8KHZ];
  3111. auxpcm_pdata->mode_16k.data = (u16)val_array[RATE_16KHZ];
  3112. rc = of_property_read_u32_array(pdev->dev.of_node,
  3113. "qcom,msm-cpudai-auxpcm-pcm-clk-rate",
  3114. val_array, RATE_MAX_NUM_OF_AUX_PCM_RATES);
  3115. if (rc) {
  3116. dev_err(&pdev->dev,
  3117. "%s: qcom,msm-cpudai-auxpcm-pcm-clk-rate missing in DT\n",
  3118. __func__);
  3119. goto fail_invalid_dt1;
  3120. }
  3121. auxpcm_pdata->mode_8k.pcm_clk_rate = (int)val_array[RATE_8KHZ];
  3122. auxpcm_pdata->mode_16k.pcm_clk_rate = (int)val_array[RATE_16KHZ];
  3123. rc = of_property_read_string(pdev->dev.of_node,
  3124. "qcom,msm-auxpcm-interface", &intf_name);
  3125. if (rc) {
  3126. dev_err(&pdev->dev,
  3127. "%s: qcom,msm-auxpcm-interface missing in DT node\n",
  3128. __func__);
  3129. goto fail_nodev_intf;
  3130. }
  3131. if (!strcmp(intf_name, "primary")) {
  3132. dai_data->rx_pid = AFE_PORT_ID_PRIMARY_PCM_RX;
  3133. dai_data->tx_pid = AFE_PORT_ID_PRIMARY_PCM_TX;
  3134. pdev->id = MSM_DAI_PRI_AUXPCM_DT_DEV_ID;
  3135. i = 0;
  3136. } else if (!strcmp(intf_name, "secondary")) {
  3137. dai_data->rx_pid = AFE_PORT_ID_SECONDARY_PCM_RX;
  3138. dai_data->tx_pid = AFE_PORT_ID_SECONDARY_PCM_TX;
  3139. pdev->id = MSM_DAI_SEC_AUXPCM_DT_DEV_ID;
  3140. i = 1;
  3141. } else if (!strcmp(intf_name, "tertiary")) {
  3142. dai_data->rx_pid = AFE_PORT_ID_TERTIARY_PCM_RX;
  3143. dai_data->tx_pid = AFE_PORT_ID_TERTIARY_PCM_TX;
  3144. pdev->id = MSM_DAI_TERT_AUXPCM_DT_DEV_ID;
  3145. i = 2;
  3146. } else if (!strcmp(intf_name, "quaternary")) {
  3147. dai_data->rx_pid = AFE_PORT_ID_QUATERNARY_PCM_RX;
  3148. dai_data->tx_pid = AFE_PORT_ID_QUATERNARY_PCM_TX;
  3149. pdev->id = MSM_DAI_QUAT_AUXPCM_DT_DEV_ID;
  3150. i = 3;
  3151. } else if (!strcmp(intf_name, "quinary")) {
  3152. dai_data->rx_pid = AFE_PORT_ID_QUINARY_PCM_RX;
  3153. dai_data->tx_pid = AFE_PORT_ID_QUINARY_PCM_TX;
  3154. pdev->id = MSM_DAI_QUIN_AUXPCM_DT_DEV_ID;
  3155. i = 4;
  3156. } else {
  3157. dev_err(&pdev->dev, "%s: invalid DT intf name %s\n",
  3158. __func__, intf_name);
  3159. goto fail_invalid_intf;
  3160. }
  3161. rc = of_property_read_u32(pdev->dev.of_node,
  3162. "qcom,msm-cpudai-afe-clk-ver", &val);
  3163. if (rc)
  3164. dai_data->afe_clk_ver = AFE_CLK_VERSION_V1;
  3165. else
  3166. dai_data->afe_clk_ver = val;
  3167. mutex_init(&dai_data->rlock);
  3168. dev_dbg(&pdev->dev, "dev name %s\n", dev_name(&pdev->dev));
  3169. dev_set_drvdata(&pdev->dev, dai_data);
  3170. pdev->dev.platform_data = (void *) auxpcm_pdata;
  3171. rc = snd_soc_register_component(&pdev->dev,
  3172. &msm_dai_q6_aux_pcm_dai_component,
  3173. &msm_dai_q6_aux_pcm_dai[i], 1);
  3174. if (rc) {
  3175. dev_err(&pdev->dev, "%s: auxpcm dai reg failed, rc=%d\n",
  3176. __func__, rc);
  3177. goto fail_reg_dai;
  3178. }
  3179. return rc;
  3180. fail_reg_dai:
  3181. fail_invalid_intf:
  3182. fail_nodev_intf:
  3183. fail_invalid_dt1:
  3184. kfree(auxpcm_pdata->mode_16k.slot_mapping);
  3185. fail_invalid_16k_slot_mapping:
  3186. kfree(auxpcm_pdata->mode_8k.slot_mapping);
  3187. fail_invalid_dt:
  3188. kfree(auxpcm_pdata);
  3189. fail_pdata_nomem:
  3190. kfree(dai_data);
  3191. return rc;
  3192. }
  3193. static int msm_auxpcm_dev_remove(struct platform_device *pdev)
  3194. {
  3195. struct msm_dai_q6_auxpcm_dai_data *dai_data;
  3196. dai_data = dev_get_drvdata(&pdev->dev);
  3197. snd_soc_unregister_component(&pdev->dev);
  3198. mutex_destroy(&dai_data->rlock);
  3199. kfree(dai_data);
  3200. kfree(pdev->dev.platform_data);
  3201. return 0;
  3202. }
  3203. static const struct of_device_id msm_auxpcm_dev_dt_match[] = {
  3204. { .compatible = "qcom,msm-auxpcm-dev", },
  3205. {}
  3206. };
  3207. static struct platform_driver msm_auxpcm_dev_driver = {
  3208. .probe = msm_auxpcm_dev_probe,
  3209. .remove = msm_auxpcm_dev_remove,
  3210. .driver = {
  3211. .name = "msm-auxpcm-dev",
  3212. .owner = THIS_MODULE,
  3213. .of_match_table = msm_auxpcm_dev_dt_match,
  3214. },
  3215. };
  3216. static struct snd_soc_dai_driver msm_dai_q6_slimbus_rx_dai[] = {
  3217. {
  3218. .playback = {
  3219. .stream_name = "Slimbus Playback",
  3220. .aif_name = "SLIMBUS_0_RX",
  3221. .rates = SNDRV_PCM_RATE_8000_384000,
  3222. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3223. .channels_min = 1,
  3224. .channels_max = 8,
  3225. .rate_min = 8000,
  3226. .rate_max = 384000,
  3227. },
  3228. .ops = &msm_dai_q6_ops,
  3229. .id = SLIMBUS_0_RX,
  3230. .probe = msm_dai_q6_dai_probe,
  3231. .remove = msm_dai_q6_dai_remove,
  3232. },
  3233. {
  3234. .playback = {
  3235. .stream_name = "Slimbus1 Playback",
  3236. .aif_name = "SLIMBUS_1_RX",
  3237. .rates = SNDRV_PCM_RATE_8000_384000,
  3238. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3239. .channels_min = 1,
  3240. .channels_max = 2,
  3241. .rate_min = 8000,
  3242. .rate_max = 384000,
  3243. },
  3244. .ops = &msm_dai_q6_ops,
  3245. .id = SLIMBUS_1_RX,
  3246. .probe = msm_dai_q6_dai_probe,
  3247. .remove = msm_dai_q6_dai_remove,
  3248. },
  3249. {
  3250. .playback = {
  3251. .stream_name = "Slimbus2 Playback",
  3252. .aif_name = "SLIMBUS_2_RX",
  3253. .rates = SNDRV_PCM_RATE_8000_384000,
  3254. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3255. .channels_min = 1,
  3256. .channels_max = 8,
  3257. .rate_min = 8000,
  3258. .rate_max = 384000,
  3259. },
  3260. .ops = &msm_dai_q6_ops,
  3261. .id = SLIMBUS_2_RX,
  3262. .probe = msm_dai_q6_dai_probe,
  3263. .remove = msm_dai_q6_dai_remove,
  3264. },
  3265. {
  3266. .playback = {
  3267. .stream_name = "Slimbus3 Playback",
  3268. .aif_name = "SLIMBUS_3_RX",
  3269. .rates = SNDRV_PCM_RATE_8000_384000,
  3270. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3271. .channels_min = 1,
  3272. .channels_max = 2,
  3273. .rate_min = 8000,
  3274. .rate_max = 384000,
  3275. },
  3276. .ops = &msm_dai_q6_ops,
  3277. .id = SLIMBUS_3_RX,
  3278. .probe = msm_dai_q6_dai_probe,
  3279. .remove = msm_dai_q6_dai_remove,
  3280. },
  3281. {
  3282. .playback = {
  3283. .stream_name = "Slimbus4 Playback",
  3284. .aif_name = "SLIMBUS_4_RX",
  3285. .rates = SNDRV_PCM_RATE_8000_384000,
  3286. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3287. .channels_min = 1,
  3288. .channels_max = 2,
  3289. .rate_min = 8000,
  3290. .rate_max = 384000,
  3291. },
  3292. .ops = &msm_dai_q6_ops,
  3293. .id = SLIMBUS_4_RX,
  3294. .probe = msm_dai_q6_dai_probe,
  3295. .remove = msm_dai_q6_dai_remove,
  3296. },
  3297. {
  3298. .playback = {
  3299. .stream_name = "Slimbus6 Playback",
  3300. .aif_name = "SLIMBUS_6_RX",
  3301. .rates = SNDRV_PCM_RATE_8000_384000,
  3302. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3303. .channels_min = 1,
  3304. .channels_max = 2,
  3305. .rate_min = 8000,
  3306. .rate_max = 384000,
  3307. },
  3308. .ops = &msm_dai_q6_ops,
  3309. .id = SLIMBUS_6_RX,
  3310. .probe = msm_dai_q6_dai_probe,
  3311. .remove = msm_dai_q6_dai_remove,
  3312. },
  3313. {
  3314. .playback = {
  3315. .stream_name = "Slimbus5 Playback",
  3316. .aif_name = "SLIMBUS_5_RX",
  3317. .rates = SNDRV_PCM_RATE_8000_384000,
  3318. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3319. .channels_min = 1,
  3320. .channels_max = 2,
  3321. .rate_min = 8000,
  3322. .rate_max = 384000,
  3323. },
  3324. .ops = &msm_dai_q6_ops,
  3325. .id = SLIMBUS_5_RX,
  3326. .probe = msm_dai_q6_dai_probe,
  3327. .remove = msm_dai_q6_dai_remove,
  3328. },
  3329. {
  3330. .playback = {
  3331. .stream_name = "Slimbus7 Playback",
  3332. .aif_name = "SLIMBUS_7_RX",
  3333. .rates = SNDRV_PCM_RATE_8000_384000,
  3334. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3335. .channels_min = 1,
  3336. .channels_max = 8,
  3337. .rate_min = 8000,
  3338. .rate_max = 384000,
  3339. },
  3340. .ops = &msm_dai_q6_ops,
  3341. .id = SLIMBUS_7_RX,
  3342. .probe = msm_dai_q6_dai_probe,
  3343. .remove = msm_dai_q6_dai_remove,
  3344. },
  3345. {
  3346. .playback = {
  3347. .stream_name = "Slimbus8 Playback",
  3348. .aif_name = "SLIMBUS_8_RX",
  3349. .rates = SNDRV_PCM_RATE_8000_384000,
  3350. .formats = DAI_FORMATS_S16_S24_S32_LE,
  3351. .channels_min = 1,
  3352. .channels_max = 8,
  3353. .rate_min = 8000,
  3354. .rate_max = 384000,
  3355. },
  3356. .ops = &msm_dai_q6_ops,
  3357. .id = SLIMBUS_8_RX,
  3358. .probe = msm_dai_q6_dai_probe,
  3359. .remove = msm_dai_q6_dai_remove,
  3360. },
  3361. };
  3362. static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = {
  3363. {
  3364. .capture = {
  3365. .stream_name = "Slimbus Capture",
  3366. .aif_name = "SLIMBUS_0_TX",
  3367. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3368. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3369. SNDRV_PCM_RATE_192000,
  3370. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3371. SNDRV_PCM_FMTBIT_S24_LE |
  3372. SNDRV_PCM_FMTBIT_S24_3LE,
  3373. .channels_min = 1,
  3374. .channels_max = 8,
  3375. .rate_min = 8000,
  3376. .rate_max = 192000,
  3377. },
  3378. .ops = &msm_dai_q6_ops,
  3379. .id = SLIMBUS_0_TX,
  3380. .probe = msm_dai_q6_dai_probe,
  3381. .remove = msm_dai_q6_dai_remove,
  3382. },
  3383. {
  3384. .capture = {
  3385. .stream_name = "Slimbus1 Capture",
  3386. .aif_name = "SLIMBUS_1_TX",
  3387. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3388. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3389. SNDRV_PCM_RATE_192000,
  3390. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3391. SNDRV_PCM_FMTBIT_S24_LE |
  3392. SNDRV_PCM_FMTBIT_S24_3LE,
  3393. .channels_min = 1,
  3394. .channels_max = 2,
  3395. .rate_min = 8000,
  3396. .rate_max = 192000,
  3397. },
  3398. .ops = &msm_dai_q6_ops,
  3399. .id = SLIMBUS_1_TX,
  3400. .probe = msm_dai_q6_dai_probe,
  3401. .remove = msm_dai_q6_dai_remove,
  3402. },
  3403. {
  3404. .capture = {
  3405. .stream_name = "Slimbus2 Capture",
  3406. .aif_name = "SLIMBUS_2_TX",
  3407. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3408. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3409. SNDRV_PCM_RATE_192000,
  3410. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3411. SNDRV_PCM_FMTBIT_S24_LE,
  3412. .channels_min = 1,
  3413. .channels_max = 8,
  3414. .rate_min = 8000,
  3415. .rate_max = 192000,
  3416. },
  3417. .ops = &msm_dai_q6_ops,
  3418. .id = SLIMBUS_2_TX,
  3419. .probe = msm_dai_q6_dai_probe,
  3420. .remove = msm_dai_q6_dai_remove,
  3421. },
  3422. {
  3423. .capture = {
  3424. .stream_name = "Slimbus3 Capture",
  3425. .aif_name = "SLIMBUS_3_TX",
  3426. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3427. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3428. SNDRV_PCM_RATE_192000,
  3429. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3430. SNDRV_PCM_FMTBIT_S24_LE,
  3431. .channels_min = 2,
  3432. .channels_max = 4,
  3433. .rate_min = 8000,
  3434. .rate_max = 192000,
  3435. },
  3436. .ops = &msm_dai_q6_ops,
  3437. .id = SLIMBUS_3_TX,
  3438. .probe = msm_dai_q6_dai_probe,
  3439. .remove = msm_dai_q6_dai_remove,
  3440. },
  3441. {
  3442. .capture = {
  3443. .stream_name = "Slimbus4 Capture",
  3444. .aif_name = "SLIMBUS_4_TX",
  3445. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3446. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3447. SNDRV_PCM_RATE_192000,
  3448. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3449. SNDRV_PCM_FMTBIT_S24_LE |
  3450. SNDRV_PCM_FMTBIT_S32_LE,
  3451. .channels_min = 2,
  3452. .channels_max = 4,
  3453. .rate_min = 8000,
  3454. .rate_max = 192000,
  3455. },
  3456. .ops = &msm_dai_q6_ops,
  3457. .id = SLIMBUS_4_TX,
  3458. .probe = msm_dai_q6_dai_probe,
  3459. .remove = msm_dai_q6_dai_remove,
  3460. },
  3461. {
  3462. .capture = {
  3463. .stream_name = "Slimbus5 Capture",
  3464. .aif_name = "SLIMBUS_5_TX",
  3465. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  3466. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  3467. SNDRV_PCM_RATE_192000,
  3468. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3469. SNDRV_PCM_FMTBIT_S24_LE,
  3470. .channels_min = 1,
  3471. .channels_max = 8,
  3472. .rate_min = 8000,
  3473. .rate_max = 192000,
  3474. },
  3475. .ops = &msm_dai_q6_ops,
  3476. .id = SLIMBUS_5_TX,
  3477. .probe = msm_dai_q6_dai_probe,
  3478. .remove = msm_dai_q6_dai_remove,
  3479. },
  3480. {
  3481. .capture = {
  3482. .stream_name = "Slimbus6 Capture",
  3483. .aif_name = "SLIMBUS_6_TX",
  3484. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3485. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3486. SNDRV_PCM_RATE_192000,
  3487. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3488. SNDRV_PCM_FMTBIT_S24_LE,
  3489. .channels_min = 1,
  3490. .channels_max = 2,
  3491. .rate_min = 8000,
  3492. .rate_max = 192000,
  3493. },
  3494. .ops = &msm_dai_q6_ops,
  3495. .id = SLIMBUS_6_TX,
  3496. .probe = msm_dai_q6_dai_probe,
  3497. .remove = msm_dai_q6_dai_remove,
  3498. },
  3499. {
  3500. .capture = {
  3501. .stream_name = "Slimbus7 Capture",
  3502. .aif_name = "SLIMBUS_7_TX",
  3503. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3504. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3505. SNDRV_PCM_RATE_192000,
  3506. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3507. SNDRV_PCM_FMTBIT_S24_LE |
  3508. SNDRV_PCM_FMTBIT_S32_LE,
  3509. .channels_min = 1,
  3510. .channels_max = 8,
  3511. .rate_min = 8000,
  3512. .rate_max = 192000,
  3513. },
  3514. .ops = &msm_dai_q6_ops,
  3515. .id = SLIMBUS_7_TX,
  3516. .probe = msm_dai_q6_dai_probe,
  3517. .remove = msm_dai_q6_dai_remove,
  3518. },
  3519. {
  3520. .capture = {
  3521. .stream_name = "Slimbus8 Capture",
  3522. .aif_name = "SLIMBUS_8_TX",
  3523. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  3524. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  3525. SNDRV_PCM_RATE_192000,
  3526. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  3527. SNDRV_PCM_FMTBIT_S24_LE |
  3528. SNDRV_PCM_FMTBIT_S32_LE,
  3529. .channels_min = 1,
  3530. .channels_max = 8,
  3531. .rate_min = 8000,
  3532. .rate_max = 192000,
  3533. },
  3534. .ops = &msm_dai_q6_ops,
  3535. .id = SLIMBUS_8_TX,
  3536. .probe = msm_dai_q6_dai_probe,
  3537. .remove = msm_dai_q6_dai_remove,
  3538. },
  3539. };
  3540. static int msm_dai_q6_mi2s_format_put(struct snd_kcontrol *kcontrol,
  3541. struct snd_ctl_elem_value *ucontrol)
  3542. {
  3543. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3544. int value = ucontrol->value.integer.value[0];
  3545. dai_data->port_config.i2s.data_format = value;
  3546. pr_debug("%s: value = %d, channel = %d, line = %d\n",
  3547. __func__, value, dai_data->port_config.i2s.mono_stereo,
  3548. dai_data->port_config.i2s.channel_mode);
  3549. return 0;
  3550. }
  3551. static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
  3552. struct snd_ctl_elem_value *ucontrol)
  3553. {
  3554. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3555. ucontrol->value.integer.value[0] =
  3556. dai_data->port_config.i2s.data_format;
  3557. return 0;
  3558. }
  3559. static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
  3560. struct snd_ctl_elem_value *ucontrol)
  3561. {
  3562. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3563. int value = ucontrol->value.integer.value[0];
  3564. dai_data->vi_feed_mono = value;
  3565. pr_debug("%s: value = %d\n", __func__, value);
  3566. return 0;
  3567. }
  3568. static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
  3569. struct snd_ctl_elem_value *ucontrol)
  3570. {
  3571. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  3572. ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
  3573. return 0;
  3574. }
  3575. static const struct snd_kcontrol_new mi2s_config_controls[] = {
  3576. SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
  3577. msm_dai_q6_mi2s_format_get,
  3578. msm_dai_q6_mi2s_format_put),
  3579. SOC_ENUM_EXT("SEC MI2S RX Format", mi2s_config_enum[0],
  3580. msm_dai_q6_mi2s_format_get,
  3581. msm_dai_q6_mi2s_format_put),
  3582. SOC_ENUM_EXT("TERT MI2S RX Format", mi2s_config_enum[0],
  3583. msm_dai_q6_mi2s_format_get,
  3584. msm_dai_q6_mi2s_format_put),
  3585. SOC_ENUM_EXT("QUAT MI2S RX Format", mi2s_config_enum[0],
  3586. msm_dai_q6_mi2s_format_get,
  3587. msm_dai_q6_mi2s_format_put),
  3588. SOC_ENUM_EXT("QUIN MI2S RX Format", mi2s_config_enum[0],
  3589. msm_dai_q6_mi2s_format_get,
  3590. msm_dai_q6_mi2s_format_put),
  3591. SOC_ENUM_EXT("PRI MI2S TX Format", mi2s_config_enum[0],
  3592. msm_dai_q6_mi2s_format_get,
  3593. msm_dai_q6_mi2s_format_put),
  3594. SOC_ENUM_EXT("SEC MI2S TX Format", mi2s_config_enum[0],
  3595. msm_dai_q6_mi2s_format_get,
  3596. msm_dai_q6_mi2s_format_put),
  3597. SOC_ENUM_EXT("TERT MI2S TX Format", mi2s_config_enum[0],
  3598. msm_dai_q6_mi2s_format_get,
  3599. msm_dai_q6_mi2s_format_put),
  3600. SOC_ENUM_EXT("QUAT MI2S TX Format", mi2s_config_enum[0],
  3601. msm_dai_q6_mi2s_format_get,
  3602. msm_dai_q6_mi2s_format_put),
  3603. SOC_ENUM_EXT("QUIN MI2S TX Format", mi2s_config_enum[0],
  3604. msm_dai_q6_mi2s_format_get,
  3605. msm_dai_q6_mi2s_format_put),
  3606. SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
  3607. msm_dai_q6_mi2s_format_get,
  3608. msm_dai_q6_mi2s_format_put),
  3609. SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
  3610. msm_dai_q6_mi2s_format_get,
  3611. msm_dai_q6_mi2s_format_put),
  3612. };
  3613. static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
  3614. SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
  3615. msm_dai_q6_mi2s_vi_feed_mono_get,
  3616. msm_dai_q6_mi2s_vi_feed_mono_put),
  3617. };
  3618. static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
  3619. {
  3620. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3621. dev_get_drvdata(dai->dev);
  3622. struct msm_mi2s_pdata *mi2s_pdata =
  3623. (struct msm_mi2s_pdata *) dai->dev->platform_data;
  3624. struct snd_kcontrol *kcontrol = NULL;
  3625. int rc = 0;
  3626. const struct snd_kcontrol_new *ctrl = NULL;
  3627. const struct snd_kcontrol_new *vi_feed_ctrl = NULL;
  3628. u16 dai_id = 0;
  3629. dai->id = mi2s_pdata->intf_id;
  3630. if (mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  3631. if (dai->id == MSM_PRIM_MI2S)
  3632. ctrl = &mi2s_config_controls[0];
  3633. if (dai->id == MSM_SEC_MI2S)
  3634. ctrl = &mi2s_config_controls[1];
  3635. if (dai->id == MSM_TERT_MI2S)
  3636. ctrl = &mi2s_config_controls[2];
  3637. if (dai->id == MSM_QUAT_MI2S)
  3638. ctrl = &mi2s_config_controls[3];
  3639. if (dai->id == MSM_QUIN_MI2S)
  3640. ctrl = &mi2s_config_controls[4];
  3641. }
  3642. if (ctrl) {
  3643. kcontrol = snd_ctl_new1(ctrl,
  3644. &mi2s_dai_data->rx_dai.mi2s_dai_data);
  3645. rc = snd_ctl_add(dai->component->card->snd_card, kcontrol);
  3646. if (rc < 0) {
  3647. dev_err(dai->dev, "%s: err add RX fmt ctl DAI = %s\n",
  3648. __func__, dai->name);
  3649. goto rtn;
  3650. }
  3651. }
  3652. ctrl = NULL;
  3653. if (mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode) {
  3654. if (dai->id == MSM_PRIM_MI2S)
  3655. ctrl = &mi2s_config_controls[5];
  3656. if (dai->id == MSM_SEC_MI2S)
  3657. ctrl = &mi2s_config_controls[6];
  3658. if (dai->id == MSM_TERT_MI2S)
  3659. ctrl = &mi2s_config_controls[7];
  3660. if (dai->id == MSM_QUAT_MI2S)
  3661. ctrl = &mi2s_config_controls[8];
  3662. if (dai->id == MSM_QUIN_MI2S)
  3663. ctrl = &mi2s_config_controls[9];
  3664. if (dai->id == MSM_SENARY_MI2S)
  3665. ctrl = &mi2s_config_controls[10];
  3666. if (dai->id == MSM_INT5_MI2S)
  3667. ctrl = &mi2s_config_controls[11];
  3668. }
  3669. if (ctrl) {
  3670. rc = snd_ctl_add(dai->component->card->snd_card,
  3671. snd_ctl_new1(ctrl,
  3672. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  3673. if (rc < 0) {
  3674. if (kcontrol)
  3675. snd_ctl_remove(dai->component->card->snd_card,
  3676. kcontrol);
  3677. dev_err(dai->dev, "%s: err add TX fmt ctl DAI = %s\n",
  3678. __func__, dai->name);
  3679. }
  3680. }
  3681. if (dai->id == MSM_INT5_MI2S)
  3682. vi_feed_ctrl = &mi2s_vi_feed_controls[0];
  3683. if (vi_feed_ctrl) {
  3684. rc = snd_ctl_add(dai->component->card->snd_card,
  3685. snd_ctl_new1(vi_feed_ctrl,
  3686. &mi2s_dai_data->tx_dai.mi2s_dai_data));
  3687. if (rc < 0) {
  3688. dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
  3689. __func__, dai->name);
  3690. }
  3691. }
  3692. if (mi2s_dai_data->is_island_dai) {
  3693. msm_mi2s_get_port_id(dai->id, SNDRV_PCM_STREAM_CAPTURE,
  3694. &dai_id);
  3695. rc = msm_dai_q6_add_island_mx_ctls(
  3696. dai->component->card->snd_card,
  3697. dai->name, dai_id,
  3698. (void *)mi2s_dai_data);
  3699. }
  3700. rc = msm_dai_q6_dai_add_route(dai);
  3701. rtn:
  3702. return rc;
  3703. }
  3704. static int msm_dai_q6_dai_mi2s_remove(struct snd_soc_dai *dai)
  3705. {
  3706. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3707. dev_get_drvdata(dai->dev);
  3708. int rc;
  3709. /* If AFE port is still up, close it */
  3710. if (test_bit(STATUS_PORT_STARTED,
  3711. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask)) {
  3712. rc = afe_close(MI2S_RX); /* can block */
  3713. if (rc < 0)
  3714. dev_err(dai->dev, "fail to close MI2S_RX port\n");
  3715. clear_bit(STATUS_PORT_STARTED,
  3716. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask);
  3717. }
  3718. if (test_bit(STATUS_PORT_STARTED,
  3719. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  3720. rc = afe_close(MI2S_TX); /* can block */
  3721. if (rc < 0)
  3722. dev_err(dai->dev, "fail to close MI2S_TX port\n");
  3723. clear_bit(STATUS_PORT_STARTED,
  3724. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask);
  3725. }
  3726. return 0;
  3727. }
  3728. static int msm_dai_q6_mi2s_startup(struct snd_pcm_substream *substream,
  3729. struct snd_soc_dai *dai)
  3730. {
  3731. return 0;
  3732. }
  3733. static int msm_mi2s_get_port_id(u32 mi2s_id, int stream, u16 *port_id)
  3734. {
  3735. int ret = 0;
  3736. switch (stream) {
  3737. case SNDRV_PCM_STREAM_PLAYBACK:
  3738. switch (mi2s_id) {
  3739. case MSM_PRIM_MI2S:
  3740. *port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  3741. break;
  3742. case MSM_SEC_MI2S:
  3743. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  3744. break;
  3745. case MSM_TERT_MI2S:
  3746. *port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  3747. break;
  3748. case MSM_QUAT_MI2S:
  3749. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  3750. break;
  3751. case MSM_SEC_MI2S_SD1:
  3752. *port_id = AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
  3753. break;
  3754. case MSM_QUIN_MI2S:
  3755. *port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  3756. break;
  3757. case MSM_INT0_MI2S:
  3758. *port_id = AFE_PORT_ID_INT0_MI2S_RX;
  3759. break;
  3760. case MSM_INT1_MI2S:
  3761. *port_id = AFE_PORT_ID_INT1_MI2S_RX;
  3762. break;
  3763. case MSM_INT2_MI2S:
  3764. *port_id = AFE_PORT_ID_INT2_MI2S_RX;
  3765. break;
  3766. case MSM_INT3_MI2S:
  3767. *port_id = AFE_PORT_ID_INT3_MI2S_RX;
  3768. break;
  3769. case MSM_INT4_MI2S:
  3770. *port_id = AFE_PORT_ID_INT4_MI2S_RX;
  3771. break;
  3772. case MSM_INT5_MI2S:
  3773. *port_id = AFE_PORT_ID_INT5_MI2S_RX;
  3774. break;
  3775. case MSM_INT6_MI2S:
  3776. *port_id = AFE_PORT_ID_INT6_MI2S_RX;
  3777. break;
  3778. default:
  3779. pr_err("%s: playback err id 0x%x\n",
  3780. __func__, mi2s_id);
  3781. ret = -1;
  3782. break;
  3783. }
  3784. break;
  3785. case SNDRV_PCM_STREAM_CAPTURE:
  3786. switch (mi2s_id) {
  3787. case MSM_PRIM_MI2S:
  3788. *port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  3789. break;
  3790. case MSM_SEC_MI2S:
  3791. *port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  3792. break;
  3793. case MSM_TERT_MI2S:
  3794. *port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  3795. break;
  3796. case MSM_QUAT_MI2S:
  3797. *port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  3798. break;
  3799. case MSM_QUIN_MI2S:
  3800. *port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  3801. break;
  3802. case MSM_SENARY_MI2S:
  3803. *port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  3804. break;
  3805. case MSM_INT0_MI2S:
  3806. *port_id = AFE_PORT_ID_INT0_MI2S_TX;
  3807. break;
  3808. case MSM_INT1_MI2S:
  3809. *port_id = AFE_PORT_ID_INT1_MI2S_TX;
  3810. break;
  3811. case MSM_INT2_MI2S:
  3812. *port_id = AFE_PORT_ID_INT2_MI2S_TX;
  3813. break;
  3814. case MSM_INT3_MI2S:
  3815. *port_id = AFE_PORT_ID_INT3_MI2S_TX;
  3816. break;
  3817. case MSM_INT4_MI2S:
  3818. *port_id = AFE_PORT_ID_INT4_MI2S_TX;
  3819. break;
  3820. case MSM_INT5_MI2S:
  3821. *port_id = AFE_PORT_ID_INT5_MI2S_TX;
  3822. break;
  3823. case MSM_INT6_MI2S:
  3824. *port_id = AFE_PORT_ID_INT6_MI2S_TX;
  3825. break;
  3826. default:
  3827. pr_err("%s: capture err id 0x%x\n", __func__, mi2s_id);
  3828. ret = -1;
  3829. break;
  3830. }
  3831. break;
  3832. default:
  3833. pr_err("%s: default err %d\n", __func__, stream);
  3834. ret = -1;
  3835. break;
  3836. }
  3837. pr_debug("%s: port_id = 0x%x\n", __func__, *port_id);
  3838. return ret;
  3839. }
  3840. static int msm_dai_q6_mi2s_prepare(struct snd_pcm_substream *substream,
  3841. struct snd_soc_dai *dai)
  3842. {
  3843. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3844. dev_get_drvdata(dai->dev);
  3845. struct msm_dai_q6_dai_data *dai_data =
  3846. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  3847. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  3848. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  3849. u16 port_id = 0;
  3850. int rc = 0;
  3851. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  3852. &port_id) != 0) {
  3853. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  3854. __func__, port_id);
  3855. return -EINVAL;
  3856. }
  3857. dev_dbg(dai->dev, "%s: dai id %d, afe port id = 0x%x\n"
  3858. "dai_data->channels = %u sample_rate = %u\n", __func__,
  3859. dai->id, port_id, dai_data->channels, dai_data->rate);
  3860. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  3861. if (q6core_get_avcs_api_version_per_service(
  3862. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V4) {
  3863. /*
  3864. * send island mode config.
  3865. * This should be the first configuration
  3866. */
  3867. rc = afe_send_port_island_mode(port_id);
  3868. if (rc)
  3869. dev_err(dai->dev, "%s: afe send island mode failed %d\n",
  3870. __func__, rc);
  3871. }
  3872. /* PORT START should be set if prepare called
  3873. * in active state.
  3874. */
  3875. rc = afe_port_start(port_id, &dai_data->port_config,
  3876. dai_data->rate);
  3877. if (rc < 0)
  3878. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  3879. dai->id);
  3880. else
  3881. set_bit(STATUS_PORT_STARTED,
  3882. dai_data->status_mask);
  3883. }
  3884. if (!test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  3885. set_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  3886. dev_dbg(dai->dev, "%s: set hwfree_status to started\n",
  3887. __func__);
  3888. }
  3889. return rc;
  3890. }
  3891. static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
  3892. struct snd_pcm_hw_params *params,
  3893. struct snd_soc_dai *dai)
  3894. {
  3895. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  3896. dev_get_drvdata(dai->dev);
  3897. struct msm_dai_q6_mi2s_dai_config *mi2s_dai_config =
  3898. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  3899. &mi2s_dai_data->rx_dai : &mi2s_dai_data->tx_dai);
  3900. struct msm_dai_q6_dai_data *dai_data = &mi2s_dai_config->mi2s_dai_data;
  3901. struct afe_param_id_i2s_cfg *i2s = &dai_data->port_config.i2s;
  3902. dai_data->channels = params_channels(params);
  3903. switch (dai_data->channels) {
  3904. case 8:
  3905. case 7:
  3906. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_8CHS)
  3907. goto error_invalid_data;
  3908. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_8CHS;
  3909. break;
  3910. case 6:
  3911. case 5:
  3912. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_6CHS)
  3913. goto error_invalid_data;
  3914. dai_data->port_config.i2s.channel_mode = AFE_PORT_I2S_6CHS;
  3915. break;
  3916. case 4:
  3917. case 3:
  3918. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_QUAD01)
  3919. goto error_invalid_data;
  3920. if (mi2s_dai_config->pdata_mi2s_lines == AFE_PORT_I2S_QUAD23)
  3921. dai_data->port_config.i2s.channel_mode =
  3922. mi2s_dai_config->pdata_mi2s_lines;
  3923. else
  3924. dai_data->port_config.i2s.channel_mode =
  3925. AFE_PORT_I2S_QUAD01;
  3926. break;
  3927. case 2:
  3928. case 1:
  3929. if (mi2s_dai_config->pdata_mi2s_lines < AFE_PORT_I2S_SD0)
  3930. goto error_invalid_data;
  3931. switch (mi2s_dai_config->pdata_mi2s_lines) {
  3932. case AFE_PORT_I2S_SD0:
  3933. case AFE_PORT_I2S_SD1:
  3934. case AFE_PORT_I2S_SD2:
  3935. case AFE_PORT_I2S_SD3:
  3936. dai_data->port_config.i2s.channel_mode =
  3937. mi2s_dai_config->pdata_mi2s_lines;
  3938. break;
  3939. case AFE_PORT_I2S_QUAD01:
  3940. case AFE_PORT_I2S_6CHS:
  3941. case AFE_PORT_I2S_8CHS:
  3942. if (dai_data->vi_feed_mono == SPKR_1)
  3943. dai_data->port_config.i2s.channel_mode =
  3944. AFE_PORT_I2S_SD0;
  3945. else
  3946. dai_data->port_config.i2s.channel_mode =
  3947. AFE_PORT_I2S_SD1;
  3948. break;
  3949. case AFE_PORT_I2S_QUAD23:
  3950. dai_data->port_config.i2s.channel_mode =
  3951. AFE_PORT_I2S_SD2;
  3952. break;
  3953. }
  3954. if (dai_data->channels == 2)
  3955. dai_data->port_config.i2s.mono_stereo =
  3956. MSM_AFE_CH_STEREO;
  3957. else
  3958. dai_data->port_config.i2s.mono_stereo = MSM_AFE_MONO;
  3959. break;
  3960. default:
  3961. pr_err("%s: default err channels %d\n",
  3962. __func__, dai_data->channels);
  3963. goto error_invalid_data;
  3964. }
  3965. dai_data->rate = params_rate(params);
  3966. switch (params_format(params)) {
  3967. case SNDRV_PCM_FORMAT_S16_LE:
  3968. case SNDRV_PCM_FORMAT_SPECIAL:
  3969. dai_data->port_config.i2s.bit_width = 16;
  3970. dai_data->bitwidth = 16;
  3971. break;
  3972. case SNDRV_PCM_FORMAT_S24_LE:
  3973. case SNDRV_PCM_FORMAT_S24_3LE:
  3974. dai_data->port_config.i2s.bit_width = 24;
  3975. dai_data->bitwidth = 24;
  3976. break;
  3977. default:
  3978. pr_err("%s: format %d\n",
  3979. __func__, params_format(params));
  3980. return -EINVAL;
  3981. }
  3982. dai_data->port_config.i2s.i2s_cfg_minor_version =
  3983. AFE_API_VERSION_I2S_CONFIG;
  3984. dai_data->port_config.i2s.sample_rate = dai_data->rate;
  3985. if ((test_bit(STATUS_PORT_STARTED,
  3986. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) &&
  3987. test_bit(STATUS_PORT_STARTED,
  3988. mi2s_dai_data->rx_dai.mi2s_dai_data.hwfree_status)) ||
  3989. (test_bit(STATUS_PORT_STARTED,
  3990. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask) &&
  3991. test_bit(STATUS_PORT_STARTED,
  3992. mi2s_dai_data->tx_dai.mi2s_dai_data.hwfree_status))) {
  3993. if ((mi2s_dai_data->tx_dai.mi2s_dai_data.rate !=
  3994. mi2s_dai_data->rx_dai.mi2s_dai_data.rate) ||
  3995. (mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth !=
  3996. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth)) {
  3997. dev_err(dai->dev, "%s: Error mismatch in HW params\n"
  3998. "Tx sample_rate = %u bit_width = %hu\n"
  3999. "Rx sample_rate = %u bit_width = %hu\n"
  4000. , __func__,
  4001. mi2s_dai_data->tx_dai.mi2s_dai_data.rate,
  4002. mi2s_dai_data->tx_dai.mi2s_dai_data.bitwidth,
  4003. mi2s_dai_data->rx_dai.mi2s_dai_data.rate,
  4004. mi2s_dai_data->rx_dai.mi2s_dai_data.bitwidth);
  4005. return -EINVAL;
  4006. }
  4007. }
  4008. dev_dbg(dai->dev, "%s: dai id %d dai_data->channels = %d\n"
  4009. "sample_rate = %u i2s_cfg_minor_version = 0x%x\n"
  4010. "bit_width = %hu channel_mode = 0x%x mono_stereo = %#x\n"
  4011. "ws_src = 0x%x sample_rate = %u data_format = 0x%x\n"
  4012. "reserved = %u\n", __func__, dai->id, dai_data->channels,
  4013. dai_data->rate, i2s->i2s_cfg_minor_version, i2s->bit_width,
  4014. i2s->channel_mode, i2s->mono_stereo, i2s->ws_src,
  4015. i2s->sample_rate, i2s->data_format, i2s->reserved);
  4016. return 0;
  4017. error_invalid_data:
  4018. pr_err("%s: dai_data->channels = %d channel_mode = %d\n", __func__,
  4019. dai_data->channels, dai_data->port_config.i2s.channel_mode);
  4020. return -EINVAL;
  4021. }
  4022. static int msm_dai_q6_mi2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  4023. {
  4024. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4025. dev_get_drvdata(dai->dev);
  4026. if (test_bit(STATUS_PORT_STARTED,
  4027. mi2s_dai_data->rx_dai.mi2s_dai_data.status_mask) ||
  4028. test_bit(STATUS_PORT_STARTED,
  4029. mi2s_dai_data->tx_dai.mi2s_dai_data.status_mask)) {
  4030. dev_err(dai->dev, "%s: err chg i2s mode while dai running",
  4031. __func__);
  4032. return -EPERM;
  4033. }
  4034. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  4035. case SND_SOC_DAIFMT_CBS_CFS:
  4036. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  4037. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 1;
  4038. break;
  4039. case SND_SOC_DAIFMT_CBM_CFM:
  4040. mi2s_dai_data->rx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  4041. mi2s_dai_data->tx_dai.mi2s_dai_data.port_config.i2s.ws_src = 0;
  4042. break;
  4043. default:
  4044. pr_err("%s: fmt %d\n",
  4045. __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK);
  4046. return -EINVAL;
  4047. }
  4048. return 0;
  4049. }
  4050. static int msm_dai_q6_mi2s_hw_free(struct snd_pcm_substream *substream,
  4051. struct snd_soc_dai *dai)
  4052. {
  4053. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4054. dev_get_drvdata(dai->dev);
  4055. struct msm_dai_q6_dai_data *dai_data =
  4056. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4057. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4058. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4059. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status)) {
  4060. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4061. dev_dbg(dai->dev, "%s: clear hwfree_status\n", __func__);
  4062. }
  4063. return 0;
  4064. }
  4065. static void msm_dai_q6_mi2s_shutdown(struct snd_pcm_substream *substream,
  4066. struct snd_soc_dai *dai)
  4067. {
  4068. struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
  4069. dev_get_drvdata(dai->dev);
  4070. struct msm_dai_q6_dai_data *dai_data =
  4071. (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
  4072. &mi2s_dai_data->rx_dai.mi2s_dai_data :
  4073. &mi2s_dai_data->tx_dai.mi2s_dai_data);
  4074. u16 port_id = 0;
  4075. int rc = 0;
  4076. if (msm_mi2s_get_port_id(dai->id, substream->stream,
  4077. &port_id) != 0) {
  4078. dev_err(dai->dev, "%s: Invalid Port ID 0x%x\n",
  4079. __func__, port_id);
  4080. }
  4081. dev_dbg(dai->dev, "%s: closing afe port id = 0x%x\n",
  4082. __func__, port_id);
  4083. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  4084. rc = afe_close(port_id);
  4085. if (rc < 0)
  4086. dev_err(dai->dev, "fail to close AFE port\n");
  4087. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  4088. }
  4089. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  4090. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  4091. }
  4092. static struct snd_soc_dai_ops msm_dai_q6_mi2s_ops = {
  4093. .startup = msm_dai_q6_mi2s_startup,
  4094. .prepare = msm_dai_q6_mi2s_prepare,
  4095. .hw_params = msm_dai_q6_mi2s_hw_params,
  4096. .hw_free = msm_dai_q6_mi2s_hw_free,
  4097. .set_fmt = msm_dai_q6_mi2s_set_fmt,
  4098. .shutdown = msm_dai_q6_mi2s_shutdown,
  4099. };
  4100. /* Channel min and max are initialized base on platform data */
  4101. static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = {
  4102. {
  4103. .playback = {
  4104. .stream_name = "Primary MI2S Playback",
  4105. .aif_name = "PRI_MI2S_RX",
  4106. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4107. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4108. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4109. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4110. SNDRV_PCM_RATE_192000,
  4111. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4112. SNDRV_PCM_FMTBIT_S24_LE |
  4113. SNDRV_PCM_FMTBIT_S24_3LE,
  4114. .rate_min = 8000,
  4115. .rate_max = 192000,
  4116. },
  4117. .capture = {
  4118. .stream_name = "Primary MI2S Capture",
  4119. .aif_name = "PRI_MI2S_TX",
  4120. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4121. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4122. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4123. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4124. SNDRV_PCM_RATE_192000,
  4125. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4126. .rate_min = 8000,
  4127. .rate_max = 192000,
  4128. },
  4129. .ops = &msm_dai_q6_mi2s_ops,
  4130. .name = "Primary MI2S",
  4131. .id = MSM_PRIM_MI2S,
  4132. .probe = msm_dai_q6_dai_mi2s_probe,
  4133. .remove = msm_dai_q6_dai_mi2s_remove,
  4134. },
  4135. {
  4136. .playback = {
  4137. .stream_name = "Secondary MI2S Playback",
  4138. .aif_name = "SEC_MI2S_RX",
  4139. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4140. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4141. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4142. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4143. SNDRV_PCM_RATE_192000,
  4144. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4145. .rate_min = 8000,
  4146. .rate_max = 192000,
  4147. },
  4148. .capture = {
  4149. .stream_name = "Secondary MI2S Capture",
  4150. .aif_name = "SEC_MI2S_TX",
  4151. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4152. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4153. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4154. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4155. SNDRV_PCM_RATE_192000,
  4156. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4157. .rate_min = 8000,
  4158. .rate_max = 192000,
  4159. },
  4160. .ops = &msm_dai_q6_mi2s_ops,
  4161. .name = "Secondary MI2S",
  4162. .id = MSM_SEC_MI2S,
  4163. .probe = msm_dai_q6_dai_mi2s_probe,
  4164. .remove = msm_dai_q6_dai_mi2s_remove,
  4165. },
  4166. {
  4167. .playback = {
  4168. .stream_name = "Tertiary MI2S Playback",
  4169. .aif_name = "TERT_MI2S_RX",
  4170. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4171. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4172. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4173. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4174. SNDRV_PCM_RATE_192000,
  4175. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4176. .rate_min = 8000,
  4177. .rate_max = 192000,
  4178. },
  4179. .capture = {
  4180. .stream_name = "Tertiary MI2S Capture",
  4181. .aif_name = "TERT_MI2S_TX",
  4182. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4183. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4184. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4185. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4186. SNDRV_PCM_RATE_192000,
  4187. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4188. .rate_min = 8000,
  4189. .rate_max = 192000,
  4190. },
  4191. .ops = &msm_dai_q6_mi2s_ops,
  4192. .name = "Tertiary MI2S",
  4193. .id = MSM_TERT_MI2S,
  4194. .probe = msm_dai_q6_dai_mi2s_probe,
  4195. .remove = msm_dai_q6_dai_mi2s_remove,
  4196. },
  4197. {
  4198. .playback = {
  4199. .stream_name = "Quaternary MI2S Playback",
  4200. .aif_name = "QUAT_MI2S_RX",
  4201. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4202. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4203. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4204. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4205. SNDRV_PCM_RATE_192000,
  4206. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4207. .rate_min = 8000,
  4208. .rate_max = 192000,
  4209. },
  4210. .capture = {
  4211. .stream_name = "Quaternary MI2S Capture",
  4212. .aif_name = "QUAT_MI2S_TX",
  4213. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  4214. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  4215. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  4216. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
  4217. SNDRV_PCM_RATE_192000,
  4218. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4219. .rate_min = 8000,
  4220. .rate_max = 192000,
  4221. },
  4222. .ops = &msm_dai_q6_mi2s_ops,
  4223. .name = "Quaternary MI2S",
  4224. .id = MSM_QUAT_MI2S,
  4225. .probe = msm_dai_q6_dai_mi2s_probe,
  4226. .remove = msm_dai_q6_dai_mi2s_remove,
  4227. },
  4228. {
  4229. .playback = {
  4230. .stream_name = "Quinary MI2S Playback",
  4231. .aif_name = "QUIN_MI2S_RX",
  4232. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4233. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4234. SNDRV_PCM_RATE_192000,
  4235. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4236. .rate_min = 8000,
  4237. .rate_max = 192000,
  4238. },
  4239. .capture = {
  4240. .stream_name = "Quinary MI2S Capture",
  4241. .aif_name = "QUIN_MI2S_TX",
  4242. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4243. SNDRV_PCM_RATE_16000,
  4244. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4245. .rate_min = 8000,
  4246. .rate_max = 48000,
  4247. },
  4248. .ops = &msm_dai_q6_mi2s_ops,
  4249. .name = "Quinary MI2S",
  4250. .id = MSM_QUIN_MI2S,
  4251. .probe = msm_dai_q6_dai_mi2s_probe,
  4252. .remove = msm_dai_q6_dai_mi2s_remove,
  4253. },
  4254. {
  4255. .playback = {
  4256. .stream_name = "Secondary MI2S Playback SD1",
  4257. .aif_name = "SEC_MI2S_RX_SD1",
  4258. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4259. SNDRV_PCM_RATE_16000,
  4260. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4261. .rate_min = 8000,
  4262. .rate_max = 48000,
  4263. },
  4264. .id = MSM_SEC_MI2S_SD1,
  4265. },
  4266. {
  4267. .capture = {
  4268. .stream_name = "Senary_mi2s Capture",
  4269. .aif_name = "SENARY_TX",
  4270. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4271. SNDRV_PCM_RATE_16000,
  4272. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4273. .rate_min = 8000,
  4274. .rate_max = 48000,
  4275. },
  4276. .ops = &msm_dai_q6_mi2s_ops,
  4277. .name = "Senary MI2S",
  4278. .id = MSM_SENARY_MI2S,
  4279. .probe = msm_dai_q6_dai_mi2s_probe,
  4280. .remove = msm_dai_q6_dai_mi2s_remove,
  4281. },
  4282. {
  4283. .playback = {
  4284. .stream_name = "INT0 MI2S Playback",
  4285. .aif_name = "INT0_MI2S_RX",
  4286. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4287. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_44100 |
  4288. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
  4289. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4290. SNDRV_PCM_FMTBIT_S24_LE |
  4291. SNDRV_PCM_FMTBIT_S24_3LE,
  4292. .rate_min = 8000,
  4293. .rate_max = 192000,
  4294. },
  4295. .capture = {
  4296. .stream_name = "INT0 MI2S Capture",
  4297. .aif_name = "INT0_MI2S_TX",
  4298. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4299. SNDRV_PCM_RATE_16000,
  4300. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4301. .rate_min = 8000,
  4302. .rate_max = 48000,
  4303. },
  4304. .ops = &msm_dai_q6_mi2s_ops,
  4305. .name = "INT0 MI2S",
  4306. .id = MSM_INT0_MI2S,
  4307. .probe = msm_dai_q6_dai_mi2s_probe,
  4308. .remove = msm_dai_q6_dai_mi2s_remove,
  4309. },
  4310. {
  4311. .playback = {
  4312. .stream_name = "INT1 MI2S Playback",
  4313. .aif_name = "INT1_MI2S_RX",
  4314. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4315. SNDRV_PCM_RATE_16000,
  4316. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4317. SNDRV_PCM_FMTBIT_S24_LE |
  4318. SNDRV_PCM_FMTBIT_S24_3LE,
  4319. .rate_min = 8000,
  4320. .rate_max = 48000,
  4321. },
  4322. .capture = {
  4323. .stream_name = "INT1 MI2S Capture",
  4324. .aif_name = "INT1_MI2S_TX",
  4325. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4326. SNDRV_PCM_RATE_16000,
  4327. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4328. .rate_min = 8000,
  4329. .rate_max = 48000,
  4330. },
  4331. .ops = &msm_dai_q6_mi2s_ops,
  4332. .name = "INT1 MI2S",
  4333. .id = MSM_INT1_MI2S,
  4334. .probe = msm_dai_q6_dai_mi2s_probe,
  4335. .remove = msm_dai_q6_dai_mi2s_remove,
  4336. },
  4337. {
  4338. .playback = {
  4339. .stream_name = "INT2 MI2S Playback",
  4340. .aif_name = "INT2_MI2S_RX",
  4341. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4342. SNDRV_PCM_RATE_16000,
  4343. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4344. SNDRV_PCM_FMTBIT_S24_LE |
  4345. SNDRV_PCM_FMTBIT_S24_3LE,
  4346. .rate_min = 8000,
  4347. .rate_max = 48000,
  4348. },
  4349. .capture = {
  4350. .stream_name = "INT2 MI2S Capture",
  4351. .aif_name = "INT2_MI2S_TX",
  4352. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4353. SNDRV_PCM_RATE_16000,
  4354. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4355. .rate_min = 8000,
  4356. .rate_max = 48000,
  4357. },
  4358. .ops = &msm_dai_q6_mi2s_ops,
  4359. .name = "INT2 MI2S",
  4360. .id = MSM_INT2_MI2S,
  4361. .probe = msm_dai_q6_dai_mi2s_probe,
  4362. .remove = msm_dai_q6_dai_mi2s_remove,
  4363. },
  4364. {
  4365. .playback = {
  4366. .stream_name = "INT3 MI2S Playback",
  4367. .aif_name = "INT3_MI2S_RX",
  4368. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4369. SNDRV_PCM_RATE_16000,
  4370. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4371. SNDRV_PCM_FMTBIT_S24_LE |
  4372. SNDRV_PCM_FMTBIT_S24_3LE,
  4373. .rate_min = 8000,
  4374. .rate_max = 48000,
  4375. },
  4376. .capture = {
  4377. .stream_name = "INT3 MI2S Capture",
  4378. .aif_name = "INT3_MI2S_TX",
  4379. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4380. SNDRV_PCM_RATE_16000,
  4381. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4382. .rate_min = 8000,
  4383. .rate_max = 48000,
  4384. },
  4385. .ops = &msm_dai_q6_mi2s_ops,
  4386. .name = "INT3 MI2S",
  4387. .id = MSM_INT3_MI2S,
  4388. .probe = msm_dai_q6_dai_mi2s_probe,
  4389. .remove = msm_dai_q6_dai_mi2s_remove,
  4390. },
  4391. {
  4392. .playback = {
  4393. .stream_name = "INT4 MI2S Playback",
  4394. .aif_name = "INT4_MI2S_RX",
  4395. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4396. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 |
  4397. SNDRV_PCM_RATE_192000,
  4398. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4399. SNDRV_PCM_FMTBIT_S24_LE |
  4400. SNDRV_PCM_FMTBIT_S24_3LE,
  4401. .rate_min = 8000,
  4402. .rate_max = 192000,
  4403. },
  4404. .capture = {
  4405. .stream_name = "INT4 MI2S Capture",
  4406. .aif_name = "INT4_MI2S_TX",
  4407. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4408. SNDRV_PCM_RATE_16000,
  4409. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4410. .rate_min = 8000,
  4411. .rate_max = 48000,
  4412. },
  4413. .ops = &msm_dai_q6_mi2s_ops,
  4414. .name = "INT4 MI2S",
  4415. .id = MSM_INT4_MI2S,
  4416. .probe = msm_dai_q6_dai_mi2s_probe,
  4417. .remove = msm_dai_q6_dai_mi2s_remove,
  4418. },
  4419. {
  4420. .playback = {
  4421. .stream_name = "INT5 MI2S Playback",
  4422. .aif_name = "INT5_MI2S_RX",
  4423. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4424. SNDRV_PCM_RATE_16000,
  4425. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4426. SNDRV_PCM_FMTBIT_S24_LE |
  4427. SNDRV_PCM_FMTBIT_S24_3LE,
  4428. .rate_min = 8000,
  4429. .rate_max = 48000,
  4430. },
  4431. .capture = {
  4432. .stream_name = "INT5 MI2S Capture",
  4433. .aif_name = "INT5_MI2S_TX",
  4434. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4435. SNDRV_PCM_RATE_16000,
  4436. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4437. .rate_min = 8000,
  4438. .rate_max = 48000,
  4439. },
  4440. .ops = &msm_dai_q6_mi2s_ops,
  4441. .name = "INT5 MI2S",
  4442. .id = MSM_INT5_MI2S,
  4443. .probe = msm_dai_q6_dai_mi2s_probe,
  4444. .remove = msm_dai_q6_dai_mi2s_remove,
  4445. },
  4446. {
  4447. .playback = {
  4448. .stream_name = "INT6 MI2S Playback",
  4449. .aif_name = "INT6_MI2S_RX",
  4450. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4451. SNDRV_PCM_RATE_16000,
  4452. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  4453. SNDRV_PCM_FMTBIT_S24_LE |
  4454. SNDRV_PCM_FMTBIT_S24_3LE,
  4455. .rate_min = 8000,
  4456. .rate_max = 48000,
  4457. },
  4458. .capture = {
  4459. .stream_name = "INT6 MI2S Capture",
  4460. .aif_name = "INT6_MI2S_TX",
  4461. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  4462. SNDRV_PCM_RATE_16000,
  4463. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  4464. .rate_min = 8000,
  4465. .rate_max = 48000,
  4466. },
  4467. .ops = &msm_dai_q6_mi2s_ops,
  4468. .name = "INT6 MI2S",
  4469. .id = MSM_INT6_MI2S,
  4470. .probe = msm_dai_q6_dai_mi2s_probe,
  4471. .remove = msm_dai_q6_dai_mi2s_remove,
  4472. },
  4473. };
  4474. static int msm_dai_q6_mi2s_get_lineconfig(u16 sd_lines, u16 *config_ptr,
  4475. unsigned int *ch_cnt)
  4476. {
  4477. u8 num_of_sd_lines;
  4478. num_of_sd_lines = num_of_bits_set(sd_lines);
  4479. switch (num_of_sd_lines) {
  4480. case 0:
  4481. pr_debug("%s: no line is assigned\n", __func__);
  4482. break;
  4483. case 1:
  4484. switch (sd_lines) {
  4485. case MSM_MI2S_SD0:
  4486. *config_ptr = AFE_PORT_I2S_SD0;
  4487. break;
  4488. case MSM_MI2S_SD1:
  4489. *config_ptr = AFE_PORT_I2S_SD1;
  4490. break;
  4491. case MSM_MI2S_SD2:
  4492. *config_ptr = AFE_PORT_I2S_SD2;
  4493. break;
  4494. case MSM_MI2S_SD3:
  4495. *config_ptr = AFE_PORT_I2S_SD3;
  4496. break;
  4497. default:
  4498. pr_err("%s: invalid SD lines %d\n",
  4499. __func__, sd_lines);
  4500. goto error_invalid_data;
  4501. }
  4502. break;
  4503. case 2:
  4504. switch (sd_lines) {
  4505. case MSM_MI2S_SD0 | MSM_MI2S_SD1:
  4506. *config_ptr = AFE_PORT_I2S_QUAD01;
  4507. break;
  4508. case MSM_MI2S_SD2 | MSM_MI2S_SD3:
  4509. *config_ptr = AFE_PORT_I2S_QUAD23;
  4510. break;
  4511. default:
  4512. pr_err("%s: invalid SD lines %d\n",
  4513. __func__, sd_lines);
  4514. goto error_invalid_data;
  4515. }
  4516. break;
  4517. case 3:
  4518. switch (sd_lines) {
  4519. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2:
  4520. *config_ptr = AFE_PORT_I2S_6CHS;
  4521. break;
  4522. default:
  4523. pr_err("%s: invalid SD lines %d\n",
  4524. __func__, sd_lines);
  4525. goto error_invalid_data;
  4526. }
  4527. break;
  4528. case 4:
  4529. switch (sd_lines) {
  4530. case MSM_MI2S_SD0 | MSM_MI2S_SD1 | MSM_MI2S_SD2 | MSM_MI2S_SD3:
  4531. *config_ptr = AFE_PORT_I2S_8CHS;
  4532. break;
  4533. default:
  4534. pr_err("%s: invalid SD lines %d\n",
  4535. __func__, sd_lines);
  4536. goto error_invalid_data;
  4537. }
  4538. break;
  4539. default:
  4540. pr_err("%s: invalid SD lines %d\n", __func__, num_of_sd_lines);
  4541. goto error_invalid_data;
  4542. }
  4543. *ch_cnt = num_of_sd_lines;
  4544. return 0;
  4545. error_invalid_data:
  4546. pr_err("%s: invalid data\n", __func__);
  4547. return -EINVAL;
  4548. }
  4549. static int msm_dai_q6_mi2s_platform_data_validation(
  4550. struct platform_device *pdev, struct snd_soc_dai_driver *dai_driver)
  4551. {
  4552. struct msm_dai_q6_mi2s_dai_data *dai_data = dev_get_drvdata(&pdev->dev);
  4553. struct msm_mi2s_pdata *mi2s_pdata =
  4554. (struct msm_mi2s_pdata *) pdev->dev.platform_data;
  4555. unsigned int ch_cnt;
  4556. int rc = 0;
  4557. u16 sd_line;
  4558. if (mi2s_pdata == NULL) {
  4559. pr_err("%s: mi2s_pdata NULL", __func__);
  4560. return -EINVAL;
  4561. }
  4562. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->rx_sd_lines,
  4563. &sd_line, &ch_cnt);
  4564. if (rc < 0) {
  4565. dev_err(&pdev->dev, "invalid MI2S RX sd line config\n");
  4566. goto rtn;
  4567. }
  4568. if (ch_cnt) {
  4569. dai_data->rx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  4570. sd_line;
  4571. dai_data->rx_dai.pdata_mi2s_lines = sd_line;
  4572. dai_driver->playback.channels_min = 1;
  4573. dai_driver->playback.channels_max = ch_cnt << 1;
  4574. } else {
  4575. dai_driver->playback.channels_min = 0;
  4576. dai_driver->playback.channels_max = 0;
  4577. }
  4578. rc = msm_dai_q6_mi2s_get_lineconfig(mi2s_pdata->tx_sd_lines,
  4579. &sd_line, &ch_cnt);
  4580. if (rc < 0) {
  4581. dev_err(&pdev->dev, "invalid MI2S TX sd line config\n");
  4582. goto rtn;
  4583. }
  4584. if (ch_cnt) {
  4585. dai_data->tx_dai.mi2s_dai_data.port_config.i2s.channel_mode =
  4586. sd_line;
  4587. dai_data->tx_dai.pdata_mi2s_lines = sd_line;
  4588. dai_driver->capture.channels_min = 1;
  4589. dai_driver->capture.channels_max = ch_cnt << 1;
  4590. } else {
  4591. dai_driver->capture.channels_min = 0;
  4592. dai_driver->capture.channels_max = 0;
  4593. }
  4594. dev_dbg(&pdev->dev, "%s: playback sdline 0x%x capture sdline 0x%x\n",
  4595. __func__, dai_data->rx_dai.pdata_mi2s_lines,
  4596. dai_data->tx_dai.pdata_mi2s_lines);
  4597. dev_dbg(&pdev->dev, "%s: playback ch_max %d capture ch_mx %d\n",
  4598. __func__, dai_driver->playback.channels_max,
  4599. dai_driver->capture.channels_max);
  4600. rtn:
  4601. return rc;
  4602. }
  4603. static const struct snd_soc_component_driver msm_q6_mi2s_dai_component = {
  4604. .name = "msm-dai-q6-mi2s",
  4605. };
  4606. static int msm_dai_q6_mi2s_dev_probe(struct platform_device *pdev)
  4607. {
  4608. struct msm_dai_q6_mi2s_dai_data *dai_data;
  4609. const char *q6_mi2s_dev_id = "qcom,msm-dai-q6-mi2s-dev-id";
  4610. u32 tx_line = 0;
  4611. u32 rx_line = 0;
  4612. u32 mi2s_intf = 0;
  4613. struct msm_mi2s_pdata *mi2s_pdata;
  4614. int rc;
  4615. rc = of_property_read_u32(pdev->dev.of_node, q6_mi2s_dev_id,
  4616. &mi2s_intf);
  4617. if (rc) {
  4618. dev_err(&pdev->dev,
  4619. "%s: missing 0x%x in dt node\n", __func__, mi2s_intf);
  4620. goto rtn;
  4621. }
  4622. dev_dbg(&pdev->dev, "dev name %s dev id 0x%x\n", dev_name(&pdev->dev),
  4623. mi2s_intf);
  4624. if ((mi2s_intf < MSM_MI2S_MIN || mi2s_intf > MSM_MI2S_MAX)
  4625. || (mi2s_intf >= ARRAY_SIZE(msm_dai_q6_mi2s_dai))) {
  4626. dev_err(&pdev->dev,
  4627. "%s: Invalid MI2S ID %u from Device Tree\n",
  4628. __func__, mi2s_intf);
  4629. rc = -ENXIO;
  4630. goto rtn;
  4631. }
  4632. pdev->id = mi2s_intf;
  4633. mi2s_pdata = kzalloc(sizeof(struct msm_mi2s_pdata), GFP_KERNEL);
  4634. if (!mi2s_pdata) {
  4635. rc = -ENOMEM;
  4636. goto rtn;
  4637. }
  4638. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-rx-lines",
  4639. &rx_line);
  4640. if (rc) {
  4641. dev_err(&pdev->dev, "%s: Rx line from DT file %s\n", __func__,
  4642. "qcom,msm-mi2s-rx-lines");
  4643. goto free_pdata;
  4644. }
  4645. rc = of_property_read_u32(pdev->dev.of_node, "qcom,msm-mi2s-tx-lines",
  4646. &tx_line);
  4647. if (rc) {
  4648. dev_err(&pdev->dev, "%s: Tx line from DT file %s\n", __func__,
  4649. "qcom,msm-mi2s-tx-lines");
  4650. goto free_pdata;
  4651. }
  4652. dev_dbg(&pdev->dev, "dev name %s Rx line 0x%x , Tx ine 0x%x\n",
  4653. dev_name(&pdev->dev), rx_line, tx_line);
  4654. mi2s_pdata->rx_sd_lines = rx_line;
  4655. mi2s_pdata->tx_sd_lines = tx_line;
  4656. mi2s_pdata->intf_id = mi2s_intf;
  4657. dai_data = kzalloc(sizeof(struct msm_dai_q6_mi2s_dai_data),
  4658. GFP_KERNEL);
  4659. if (!dai_data) {
  4660. rc = -ENOMEM;
  4661. goto free_pdata;
  4662. } else
  4663. dev_set_drvdata(&pdev->dev, dai_data);
  4664. rc = of_property_read_u32(pdev->dev.of_node,
  4665. "qcom,msm-dai-is-island-supported",
  4666. &dai_data->is_island_dai);
  4667. if (rc)
  4668. dev_dbg(&pdev->dev, "island supported entry not found\n");
  4669. pdev->dev.platform_data = mi2s_pdata;
  4670. rc = msm_dai_q6_mi2s_platform_data_validation(pdev,
  4671. &msm_dai_q6_mi2s_dai[mi2s_intf]);
  4672. if (rc < 0)
  4673. goto free_dai_data;
  4674. rc = snd_soc_register_component(&pdev->dev, &msm_q6_mi2s_dai_component,
  4675. &msm_dai_q6_mi2s_dai[mi2s_intf], 1);
  4676. if (rc < 0)
  4677. goto err_register;
  4678. return 0;
  4679. err_register:
  4680. dev_err(&pdev->dev, "fail to msm_dai_q6_mi2s_dev_probe\n");
  4681. free_dai_data:
  4682. kfree(dai_data);
  4683. free_pdata:
  4684. kfree(mi2s_pdata);
  4685. rtn:
  4686. return rc;
  4687. }
  4688. static int msm_dai_q6_mi2s_dev_remove(struct platform_device *pdev)
  4689. {
  4690. snd_soc_unregister_component(&pdev->dev);
  4691. return 0;
  4692. }
  4693. static const struct snd_soc_component_driver msm_dai_q6_component = {
  4694. .name = "msm-dai-q6-dev",
  4695. };
  4696. static int msm_dai_q6_dev_probe(struct platform_device *pdev)
  4697. {
  4698. int rc, id, i, len;
  4699. const char *q6_dev_id = "qcom,msm-dai-q6-dev-id";
  4700. char stream_name[80];
  4701. rc = of_property_read_u32(pdev->dev.of_node, q6_dev_id, &id);
  4702. if (rc) {
  4703. dev_err(&pdev->dev,
  4704. "%s: missing %s in dt node\n", __func__, q6_dev_id);
  4705. return rc;
  4706. }
  4707. pdev->id = id;
  4708. pr_debug("%s: dev name %s, id:%d\n", __func__,
  4709. dev_name(&pdev->dev), pdev->id);
  4710. switch (id) {
  4711. case SLIMBUS_0_RX:
  4712. strlcpy(stream_name, "Slimbus Playback", 80);
  4713. goto register_slim_playback;
  4714. case SLIMBUS_2_RX:
  4715. strlcpy(stream_name, "Slimbus2 Playback", 80);
  4716. goto register_slim_playback;
  4717. case SLIMBUS_1_RX:
  4718. strlcpy(stream_name, "Slimbus1 Playback", 80);
  4719. goto register_slim_playback;
  4720. case SLIMBUS_3_RX:
  4721. strlcpy(stream_name, "Slimbus3 Playback", 80);
  4722. goto register_slim_playback;
  4723. case SLIMBUS_4_RX:
  4724. strlcpy(stream_name, "Slimbus4 Playback", 80);
  4725. goto register_slim_playback;
  4726. case SLIMBUS_5_RX:
  4727. strlcpy(stream_name, "Slimbus5 Playback", 80);
  4728. goto register_slim_playback;
  4729. case SLIMBUS_6_RX:
  4730. strlcpy(stream_name, "Slimbus6 Playback", 80);
  4731. goto register_slim_playback;
  4732. case SLIMBUS_7_RX:
  4733. strlcpy(stream_name, "Slimbus7 Playback", sizeof(stream_name));
  4734. goto register_slim_playback;
  4735. case SLIMBUS_8_RX:
  4736. strlcpy(stream_name, "Slimbus8 Playback", sizeof(stream_name));
  4737. goto register_slim_playback;
  4738. register_slim_playback:
  4739. rc = -ENODEV;
  4740. len = strnlen(stream_name, 80);
  4741. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_rx_dai); i++) {
  4742. if (msm_dai_q6_slimbus_rx_dai[i].playback.stream_name &&
  4743. !strcmp(stream_name,
  4744. msm_dai_q6_slimbus_rx_dai[i]
  4745. .playback.stream_name)) {
  4746. rc = snd_soc_register_component(&pdev->dev,
  4747. &msm_dai_q6_component,
  4748. &msm_dai_q6_slimbus_rx_dai[i], 1);
  4749. break;
  4750. }
  4751. }
  4752. if (rc)
  4753. pr_err("%s: Device not found stream name %s\n",
  4754. __func__, stream_name);
  4755. break;
  4756. case SLIMBUS_0_TX:
  4757. strlcpy(stream_name, "Slimbus Capture", 80);
  4758. goto register_slim_capture;
  4759. case SLIMBUS_1_TX:
  4760. strlcpy(stream_name, "Slimbus1 Capture", 80);
  4761. goto register_slim_capture;
  4762. case SLIMBUS_2_TX:
  4763. strlcpy(stream_name, "Slimbus2 Capture", 80);
  4764. goto register_slim_capture;
  4765. case SLIMBUS_3_TX:
  4766. strlcpy(stream_name, "Slimbus3 Capture", 80);
  4767. goto register_slim_capture;
  4768. case SLIMBUS_4_TX:
  4769. strlcpy(stream_name, "Slimbus4 Capture", 80);
  4770. goto register_slim_capture;
  4771. case SLIMBUS_5_TX:
  4772. strlcpy(stream_name, "Slimbus5 Capture", 80);
  4773. goto register_slim_capture;
  4774. case SLIMBUS_6_TX:
  4775. strlcpy(stream_name, "Slimbus6 Capture", 80);
  4776. goto register_slim_capture;
  4777. case SLIMBUS_7_TX:
  4778. strlcpy(stream_name, "Slimbus7 Capture", sizeof(stream_name));
  4779. goto register_slim_capture;
  4780. case SLIMBUS_8_TX:
  4781. strlcpy(stream_name, "Slimbus8 Capture", sizeof(stream_name));
  4782. goto register_slim_capture;
  4783. register_slim_capture:
  4784. rc = -ENODEV;
  4785. len = strnlen(stream_name, 80);
  4786. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_slimbus_tx_dai); i++) {
  4787. if (msm_dai_q6_slimbus_tx_dai[i].capture.stream_name &&
  4788. !strcmp(stream_name,
  4789. msm_dai_q6_slimbus_tx_dai[i]
  4790. .capture.stream_name)) {
  4791. rc = snd_soc_register_component(&pdev->dev,
  4792. &msm_dai_q6_component,
  4793. &msm_dai_q6_slimbus_tx_dai[i], 1);
  4794. break;
  4795. }
  4796. }
  4797. if (rc)
  4798. pr_err("%s: Device not found stream name %s\n",
  4799. __func__, stream_name);
  4800. break;
  4801. case INT_BT_SCO_RX:
  4802. rc = snd_soc_register_component(&pdev->dev,
  4803. &msm_dai_q6_component, &msm_dai_q6_bt_sco_rx_dai, 1);
  4804. break;
  4805. case INT_BT_SCO_TX:
  4806. rc = snd_soc_register_component(&pdev->dev,
  4807. &msm_dai_q6_component, &msm_dai_q6_bt_sco_tx_dai, 1);
  4808. break;
  4809. case INT_BT_A2DP_RX:
  4810. rc = snd_soc_register_component(&pdev->dev,
  4811. &msm_dai_q6_component, &msm_dai_q6_bt_a2dp_rx_dai, 1);
  4812. break;
  4813. case INT_FM_RX:
  4814. rc = snd_soc_register_component(&pdev->dev,
  4815. &msm_dai_q6_component, &msm_dai_q6_fm_rx_dai, 1);
  4816. break;
  4817. case INT_FM_TX:
  4818. rc = snd_soc_register_component(&pdev->dev,
  4819. &msm_dai_q6_component, &msm_dai_q6_fm_tx_dai, 1);
  4820. break;
  4821. case AFE_PORT_ID_USB_RX:
  4822. rc = snd_soc_register_component(&pdev->dev,
  4823. &msm_dai_q6_component, &msm_dai_q6_usb_rx_dai, 1);
  4824. break;
  4825. case AFE_PORT_ID_USB_TX:
  4826. rc = snd_soc_register_component(&pdev->dev,
  4827. &msm_dai_q6_component, &msm_dai_q6_usb_tx_dai, 1);
  4828. break;
  4829. case RT_PROXY_DAI_001_RX:
  4830. strlcpy(stream_name, "AFE Playback", 80);
  4831. goto register_afe_playback;
  4832. case RT_PROXY_DAI_002_RX:
  4833. strlcpy(stream_name, "AFE-PROXY RX", 80);
  4834. register_afe_playback:
  4835. rc = -ENODEV;
  4836. len = strnlen(stream_name, 80);
  4837. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_rx_dai); i++) {
  4838. if (msm_dai_q6_afe_rx_dai[i].playback.stream_name &&
  4839. !strcmp(stream_name,
  4840. msm_dai_q6_afe_rx_dai[i].playback.stream_name)) {
  4841. rc = snd_soc_register_component(&pdev->dev,
  4842. &msm_dai_q6_component,
  4843. &msm_dai_q6_afe_rx_dai[i], 1);
  4844. break;
  4845. }
  4846. }
  4847. if (rc)
  4848. pr_err("%s: Device not found stream name %s\n",
  4849. __func__, stream_name);
  4850. break;
  4851. case RT_PROXY_DAI_001_TX:
  4852. strlcpy(stream_name, "AFE-PROXY TX", 80);
  4853. goto register_afe_capture;
  4854. case RT_PROXY_DAI_002_TX:
  4855. strlcpy(stream_name, "AFE Capture", 80);
  4856. register_afe_capture:
  4857. rc = -ENODEV;
  4858. len = strnlen(stream_name, 80);
  4859. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_afe_tx_dai); i++) {
  4860. if (msm_dai_q6_afe_tx_dai[i].capture.stream_name &&
  4861. !strcmp(stream_name,
  4862. msm_dai_q6_afe_tx_dai[i].capture.stream_name)) {
  4863. rc = snd_soc_register_component(&pdev->dev,
  4864. &msm_dai_q6_component,
  4865. &msm_dai_q6_afe_tx_dai[i], 1);
  4866. break;
  4867. }
  4868. }
  4869. if (rc)
  4870. pr_err("%s: Device not found stream name %s\n",
  4871. __func__, stream_name);
  4872. break;
  4873. case VOICE_PLAYBACK_TX:
  4874. strlcpy(stream_name, "Voice Farend Playback", 80);
  4875. goto register_voice_playback;
  4876. case VOICE2_PLAYBACK_TX:
  4877. strlcpy(stream_name, "Voice2 Farend Playback", 80);
  4878. register_voice_playback:
  4879. rc = -ENODEV;
  4880. len = strnlen(stream_name, 80);
  4881. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_voc_playback_dai); i++) {
  4882. if (msm_dai_q6_voc_playback_dai[i].playback.stream_name
  4883. && !strcmp(stream_name,
  4884. msm_dai_q6_voc_playback_dai[i].playback.stream_name)) {
  4885. rc = snd_soc_register_component(&pdev->dev,
  4886. &msm_dai_q6_component,
  4887. &msm_dai_q6_voc_playback_dai[i], 1);
  4888. break;
  4889. }
  4890. }
  4891. if (rc)
  4892. pr_err("%s Device not found stream name %s\n",
  4893. __func__, stream_name);
  4894. break;
  4895. case VOICE_RECORD_RX:
  4896. strlcpy(stream_name, "Voice Downlink Capture", 80);
  4897. goto register_uplink_capture;
  4898. case VOICE_RECORD_TX:
  4899. strlcpy(stream_name, "Voice Uplink Capture", 80);
  4900. register_uplink_capture:
  4901. rc = -ENODEV;
  4902. len = strnlen(stream_name, 80);
  4903. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_incall_record_dai); i++) {
  4904. if (msm_dai_q6_incall_record_dai[i].capture.stream_name
  4905. && !strcmp(stream_name,
  4906. msm_dai_q6_incall_record_dai[i].
  4907. capture.stream_name)) {
  4908. rc = snd_soc_register_component(&pdev->dev,
  4909. &msm_dai_q6_component,
  4910. &msm_dai_q6_incall_record_dai[i], 1);
  4911. break;
  4912. }
  4913. }
  4914. if (rc)
  4915. pr_err("%s: Device not found stream name %s\n",
  4916. __func__, stream_name);
  4917. break;
  4918. default:
  4919. rc = -ENODEV;
  4920. break;
  4921. }
  4922. return rc;
  4923. }
  4924. static int msm_dai_q6_dev_remove(struct platform_device *pdev)
  4925. {
  4926. snd_soc_unregister_component(&pdev->dev);
  4927. return 0;
  4928. }
  4929. static const struct of_device_id msm_dai_q6_dev_dt_match[] = {
  4930. { .compatible = "qcom,msm-dai-q6-dev", },
  4931. { }
  4932. };
  4933. MODULE_DEVICE_TABLE(of, msm_dai_q6_dev_dt_match);
  4934. static struct platform_driver msm_dai_q6_dev = {
  4935. .probe = msm_dai_q6_dev_probe,
  4936. .remove = msm_dai_q6_dev_remove,
  4937. .driver = {
  4938. .name = "msm-dai-q6-dev",
  4939. .owner = THIS_MODULE,
  4940. .of_match_table = msm_dai_q6_dev_dt_match,
  4941. },
  4942. };
  4943. static int msm_dai_q6_probe(struct platform_device *pdev)
  4944. {
  4945. int rc;
  4946. pr_debug("%s: dev name %s, id:%d\n", __func__,
  4947. dev_name(&pdev->dev), pdev->id);
  4948. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  4949. if (rc) {
  4950. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  4951. __func__, rc);
  4952. } else
  4953. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  4954. return rc;
  4955. }
  4956. static int msm_dai_q6_remove(struct platform_device *pdev)
  4957. {
  4958. of_platform_depopulate(&pdev->dev);
  4959. return 0;
  4960. }
  4961. static const struct of_device_id msm_dai_q6_dt_match[] = {
  4962. { .compatible = "qcom,msm-dai-q6", },
  4963. { }
  4964. };
  4965. MODULE_DEVICE_TABLE(of, msm_dai_q6_dt_match);
  4966. static struct platform_driver msm_dai_q6 = {
  4967. .probe = msm_dai_q6_probe,
  4968. .remove = msm_dai_q6_remove,
  4969. .driver = {
  4970. .name = "msm-dai-q6",
  4971. .owner = THIS_MODULE,
  4972. .of_match_table = msm_dai_q6_dt_match,
  4973. },
  4974. };
  4975. static int msm_dai_mi2s_q6_probe(struct platform_device *pdev)
  4976. {
  4977. int rc;
  4978. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  4979. if (rc) {
  4980. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  4981. __func__, rc);
  4982. } else
  4983. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  4984. return rc;
  4985. }
  4986. static int msm_dai_mi2s_q6_remove(struct platform_device *pdev)
  4987. {
  4988. return 0;
  4989. }
  4990. static const struct of_device_id msm_dai_mi2s_dt_match[] = {
  4991. { .compatible = "qcom,msm-dai-mi2s", },
  4992. { }
  4993. };
  4994. MODULE_DEVICE_TABLE(of, msm_dai_mi2s_dt_match);
  4995. static struct platform_driver msm_dai_mi2s_q6 = {
  4996. .probe = msm_dai_mi2s_q6_probe,
  4997. .remove = msm_dai_mi2s_q6_remove,
  4998. .driver = {
  4999. .name = "msm-dai-mi2s",
  5000. .owner = THIS_MODULE,
  5001. .of_match_table = msm_dai_mi2s_dt_match,
  5002. },
  5003. };
  5004. static const struct of_device_id msm_dai_q6_mi2s_dev_dt_match[] = {
  5005. { .compatible = "qcom,msm-dai-q6-mi2s", },
  5006. { }
  5007. };
  5008. MODULE_DEVICE_TABLE(of, msm_dai_q6_mi2s_dev_dt_match);
  5009. static struct platform_driver msm_dai_q6_mi2s_driver = {
  5010. .probe = msm_dai_q6_mi2s_dev_probe,
  5011. .remove = msm_dai_q6_mi2s_dev_remove,
  5012. .driver = {
  5013. .name = "msm-dai-q6-mi2s",
  5014. .owner = THIS_MODULE,
  5015. .of_match_table = msm_dai_q6_mi2s_dev_dt_match,
  5016. },
  5017. };
  5018. static int msm_dai_q6_spdif_dev_probe(struct platform_device *pdev)
  5019. {
  5020. int rc;
  5021. pdev->id = AFE_PORT_ID_SPDIF_RX;
  5022. pr_debug("%s: dev name %s, id:%d\n", __func__,
  5023. dev_name(&pdev->dev), pdev->id);
  5024. rc = snd_soc_register_component(&pdev->dev,
  5025. &msm_dai_spdif_q6_component,
  5026. &msm_dai_q6_spdif_spdif_rx_dai, 1);
  5027. return rc;
  5028. }
  5029. static int msm_dai_q6_spdif_dev_remove(struct platform_device *pdev)
  5030. {
  5031. snd_soc_unregister_component(&pdev->dev);
  5032. return 0;
  5033. }
  5034. static const struct of_device_id msm_dai_q6_spdif_dt_match[] = {
  5035. {.compatible = "qcom,msm-dai-q6-spdif"},
  5036. {}
  5037. };
  5038. MODULE_DEVICE_TABLE(of, msm_dai_q6_spdif_dt_match);
  5039. static struct platform_driver msm_dai_q6_spdif_driver = {
  5040. .probe = msm_dai_q6_spdif_dev_probe,
  5041. .remove = msm_dai_q6_spdif_dev_remove,
  5042. .driver = {
  5043. .name = "msm-dai-q6-spdif",
  5044. .owner = THIS_MODULE,
  5045. .of_match_table = msm_dai_q6_spdif_dt_match,
  5046. },
  5047. };
  5048. static int msm_dai_q6_tdm_set_clk_param(u32 group_id,
  5049. struct afe_clk_set *clk_set, u32 mode)
  5050. {
  5051. switch (group_id) {
  5052. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_RX:
  5053. case AFE_GROUP_DEVICE_ID_PRIMARY_TDM_TX:
  5054. if (mode)
  5055. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_IBIT;
  5056. else
  5057. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_PRI_TDM_EBIT;
  5058. break;
  5059. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_RX:
  5060. case AFE_GROUP_DEVICE_ID_SECONDARY_TDM_TX:
  5061. if (mode)
  5062. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_IBIT;
  5063. else
  5064. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_SEC_TDM_EBIT;
  5065. break;
  5066. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_RX:
  5067. case AFE_GROUP_DEVICE_ID_TERTIARY_TDM_TX:
  5068. if (mode)
  5069. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_IBIT;
  5070. else
  5071. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_TER_TDM_EBIT;
  5072. break;
  5073. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_RX:
  5074. case AFE_GROUP_DEVICE_ID_QUATERNARY_TDM_TX:
  5075. if (mode)
  5076. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT;
  5077. else
  5078. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUAD_TDM_EBIT;
  5079. break;
  5080. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_RX:
  5081. case AFE_GROUP_DEVICE_ID_QUINARY_TDM_TX:
  5082. if (mode)
  5083. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_IBIT;
  5084. else
  5085. clk_set->clk_id = Q6AFE_LPASS_CLK_ID_QUIN_TDM_EBIT;
  5086. break;
  5087. default:
  5088. return -EINVAL;
  5089. }
  5090. return 0;
  5091. }
  5092. static int msm_dai_tdm_q6_probe(struct platform_device *pdev)
  5093. {
  5094. int rc = 0;
  5095. const uint32_t *port_id_array = NULL;
  5096. uint32_t array_length = 0;
  5097. int i = 0;
  5098. int group_idx = 0;
  5099. u32 clk_mode = 0;
  5100. /* extract tdm group info into static */
  5101. rc = of_property_read_u32(pdev->dev.of_node,
  5102. "qcom,msm-cpudai-tdm-group-id",
  5103. (u32 *)&tdm_group_cfg.group_id);
  5104. if (rc) {
  5105. dev_err(&pdev->dev, "%s: Group ID from DT file %s\n",
  5106. __func__, "qcom,msm-cpudai-tdm-group-id");
  5107. goto rtn;
  5108. }
  5109. dev_dbg(&pdev->dev, "%s: Group ID from DT file 0x%x\n",
  5110. __func__, tdm_group_cfg.group_id);
  5111. rc = of_property_read_u32(pdev->dev.of_node,
  5112. "qcom,msm-cpudai-tdm-group-num-ports",
  5113. &num_tdm_group_ports);
  5114. if (rc) {
  5115. dev_err(&pdev->dev, "%s: Group Num Ports from DT file %s\n",
  5116. __func__, "qcom,msm-cpudai-tdm-group-num-ports");
  5117. goto rtn;
  5118. }
  5119. dev_dbg(&pdev->dev, "%s: Group Num Ports from DT file 0x%x\n",
  5120. __func__, num_tdm_group_ports);
  5121. if (num_tdm_group_ports > AFE_GROUP_DEVICE_NUM_PORTS) {
  5122. dev_err(&pdev->dev, "%s Group Num Ports %d greater than Max %d\n",
  5123. __func__, num_tdm_group_ports,
  5124. AFE_GROUP_DEVICE_NUM_PORTS);
  5125. rc = -EINVAL;
  5126. goto rtn;
  5127. }
  5128. port_id_array = of_get_property(pdev->dev.of_node,
  5129. "qcom,msm-cpudai-tdm-group-port-id",
  5130. &array_length);
  5131. if (port_id_array == NULL) {
  5132. dev_err(&pdev->dev, "%s port_id_array is not valid\n",
  5133. __func__);
  5134. rc = -EINVAL;
  5135. goto rtn;
  5136. }
  5137. if (array_length != sizeof(uint32_t) * num_tdm_group_ports) {
  5138. dev_err(&pdev->dev, "%s array_length is %d, expected is %zd\n",
  5139. __func__, array_length,
  5140. sizeof(uint32_t) * num_tdm_group_ports);
  5141. rc = -EINVAL;
  5142. goto rtn;
  5143. }
  5144. for (i = 0; i < num_tdm_group_ports; i++)
  5145. tdm_group_cfg.port_id[i] =
  5146. (u16)be32_to_cpu(port_id_array[i]);
  5147. /* Unused index should be filled with 0 or AFE_PORT_INVALID */
  5148. for (i = num_tdm_group_ports; i < AFE_GROUP_DEVICE_NUM_PORTS; i++)
  5149. tdm_group_cfg.port_id[i] =
  5150. AFE_PORT_INVALID;
  5151. /* extract tdm clk info into static */
  5152. rc = of_property_read_u32(pdev->dev.of_node,
  5153. "qcom,msm-cpudai-tdm-clk-rate",
  5154. &tdm_clk_set.clk_freq_in_hz);
  5155. if (rc) {
  5156. dev_err(&pdev->dev, "%s: Clk Rate from DT file %s\n",
  5157. __func__, "qcom,msm-cpudai-tdm-clk-rate");
  5158. goto rtn;
  5159. }
  5160. dev_dbg(&pdev->dev, "%s: Clk Rate from DT file %d\n",
  5161. __func__, tdm_clk_set.clk_freq_in_hz);
  5162. /* initialize static tdm clk attribute to default value */
  5163. tdm_clk_set.clk_attri = Q6AFE_LPASS_CLK_ATTRIBUTE_INVERT_COUPLE_NO;
  5164. /* extract tdm clk attribute into static */
  5165. if (of_find_property(pdev->dev.of_node,
  5166. "qcom,msm-cpudai-tdm-clk-attribute", NULL)) {
  5167. rc = of_property_read_u16(pdev->dev.of_node,
  5168. "qcom,msm-cpudai-tdm-clk-attribute",
  5169. &tdm_clk_set.clk_attri);
  5170. if (rc) {
  5171. dev_err(&pdev->dev, "%s: value for clk attribute not found %s\n",
  5172. __func__, "qcom,msm-cpudai-tdm-clk-attribute");
  5173. goto rtn;
  5174. }
  5175. dev_dbg(&pdev->dev, "%s: clk attribute from DT file %d\n",
  5176. __func__, tdm_clk_set.clk_attri);
  5177. } else
  5178. dev_dbg(&pdev->dev, "%s: clk attribute not found\n", __func__);
  5179. /* extract tdm clk src master/slave info into static */
  5180. rc = of_property_read_u32(pdev->dev.of_node,
  5181. "qcom,msm-cpudai-tdm-clk-internal",
  5182. &clk_mode);
  5183. if (rc) {
  5184. dev_err(&pdev->dev, "%s: Clk id from DT file %s\n",
  5185. __func__, "qcom,msm-cpudai-tdm-clk-internal");
  5186. goto rtn;
  5187. }
  5188. dev_dbg(&pdev->dev, "%s: Clk id from DT file %d\n",
  5189. __func__, clk_mode);
  5190. rc = msm_dai_q6_tdm_set_clk_param(tdm_group_cfg.group_id,
  5191. &tdm_clk_set, clk_mode);
  5192. if (rc) {
  5193. dev_err(&pdev->dev, "%s: group id not supported 0x%x\n",
  5194. __func__, tdm_group_cfg.group_id);
  5195. goto rtn;
  5196. }
  5197. /* other initializations within device group */
  5198. group_idx = msm_dai_q6_get_group_idx(tdm_group_cfg.group_id);
  5199. if (group_idx < 0) {
  5200. dev_err(&pdev->dev, "%s: group id 0x%x not supported\n",
  5201. __func__, tdm_group_cfg.group_id);
  5202. rc = -EINVAL;
  5203. goto rtn;
  5204. }
  5205. atomic_set(&tdm_group_ref[group_idx], 0);
  5206. /* probe child node info */
  5207. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  5208. if (rc) {
  5209. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  5210. __func__, rc);
  5211. goto rtn;
  5212. } else
  5213. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  5214. rtn:
  5215. return rc;
  5216. }
  5217. static int msm_dai_tdm_q6_remove(struct platform_device *pdev)
  5218. {
  5219. return 0;
  5220. }
  5221. static const struct of_device_id msm_dai_tdm_dt_match[] = {
  5222. { .compatible = "qcom,msm-dai-tdm", },
  5223. {}
  5224. };
  5225. MODULE_DEVICE_TABLE(of, msm_dai_tdm_dt_match);
  5226. static struct platform_driver msm_dai_tdm_q6 = {
  5227. .probe = msm_dai_tdm_q6_probe,
  5228. .remove = msm_dai_tdm_q6_remove,
  5229. .driver = {
  5230. .name = "msm-dai-tdm",
  5231. .owner = THIS_MODULE,
  5232. .of_match_table = msm_dai_tdm_dt_match,
  5233. },
  5234. };
  5235. static int msm_dai_q6_tdm_data_format_put(struct snd_kcontrol *kcontrol,
  5236. struct snd_ctl_elem_value *ucontrol)
  5237. {
  5238. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5239. int value = ucontrol->value.integer.value[0];
  5240. switch (value) {
  5241. case 0:
  5242. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  5243. break;
  5244. case 1:
  5245. dai_data->port_cfg.tdm.data_format = AFE_NON_LINEAR_DATA;
  5246. break;
  5247. case 2:
  5248. dai_data->port_cfg.tdm.data_format = AFE_GENERIC_COMPRESSED;
  5249. break;
  5250. default:
  5251. pr_err("%s: data_format invalid\n", __func__);
  5252. break;
  5253. }
  5254. pr_debug("%s: data_format = %d\n",
  5255. __func__, dai_data->port_cfg.tdm.data_format);
  5256. return 0;
  5257. }
  5258. static int msm_dai_q6_tdm_data_format_get(struct snd_kcontrol *kcontrol,
  5259. struct snd_ctl_elem_value *ucontrol)
  5260. {
  5261. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5262. ucontrol->value.integer.value[0] =
  5263. dai_data->port_cfg.tdm.data_format;
  5264. pr_debug("%s: data_format = %d\n",
  5265. __func__, dai_data->port_cfg.tdm.data_format);
  5266. return 0;
  5267. }
  5268. static int msm_dai_q6_tdm_header_type_put(struct snd_kcontrol *kcontrol,
  5269. struct snd_ctl_elem_value *ucontrol)
  5270. {
  5271. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5272. int value = ucontrol->value.integer.value[0];
  5273. dai_data->port_cfg.custom_tdm_header.header_type = value;
  5274. pr_debug("%s: header_type = %d\n",
  5275. __func__,
  5276. dai_data->port_cfg.custom_tdm_header.header_type);
  5277. return 0;
  5278. }
  5279. static int msm_dai_q6_tdm_header_type_get(struct snd_kcontrol *kcontrol,
  5280. struct snd_ctl_elem_value *ucontrol)
  5281. {
  5282. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5283. ucontrol->value.integer.value[0] =
  5284. dai_data->port_cfg.custom_tdm_header.header_type;
  5285. pr_debug("%s: header_type = %d\n",
  5286. __func__,
  5287. dai_data->port_cfg.custom_tdm_header.header_type);
  5288. return 0;
  5289. }
  5290. static int msm_dai_q6_tdm_header_put(struct snd_kcontrol *kcontrol,
  5291. struct snd_ctl_elem_value *ucontrol)
  5292. {
  5293. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5294. int i = 0;
  5295. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  5296. dai_data->port_cfg.custom_tdm_header.header[i] =
  5297. (u16)ucontrol->value.integer.value[i];
  5298. pr_debug("%s: header #%d = 0x%x\n",
  5299. __func__, i,
  5300. dai_data->port_cfg.custom_tdm_header.header[i]);
  5301. }
  5302. return 0;
  5303. }
  5304. static int msm_dai_q6_tdm_header_get(struct snd_kcontrol *kcontrol,
  5305. struct snd_ctl_elem_value *ucontrol)
  5306. {
  5307. struct msm_dai_q6_tdm_dai_data *dai_data = kcontrol->private_data;
  5308. int i = 0;
  5309. for (i = 0; i < AFE_CUSTOM_TDM_HEADER_MAX_CNT; i++) {
  5310. ucontrol->value.integer.value[i] =
  5311. dai_data->port_cfg.custom_tdm_header.header[i];
  5312. pr_debug("%s: header #%d = 0x%x\n",
  5313. __func__, i,
  5314. dai_data->port_cfg.custom_tdm_header.header[i]);
  5315. }
  5316. return 0;
  5317. }
  5318. static const struct snd_kcontrol_new tdm_config_controls_data_format[] = {
  5319. SOC_ENUM_EXT("PRI_TDM_RX_0 Data Format", tdm_config_enum[0],
  5320. msm_dai_q6_tdm_data_format_get,
  5321. msm_dai_q6_tdm_data_format_put),
  5322. SOC_ENUM_EXT("PRI_TDM_RX_1 Data Format", tdm_config_enum[0],
  5323. msm_dai_q6_tdm_data_format_get,
  5324. msm_dai_q6_tdm_data_format_put),
  5325. SOC_ENUM_EXT("PRI_TDM_RX_2 Data Format", tdm_config_enum[0],
  5326. msm_dai_q6_tdm_data_format_get,
  5327. msm_dai_q6_tdm_data_format_put),
  5328. SOC_ENUM_EXT("PRI_TDM_RX_3 Data Format", tdm_config_enum[0],
  5329. msm_dai_q6_tdm_data_format_get,
  5330. msm_dai_q6_tdm_data_format_put),
  5331. SOC_ENUM_EXT("PRI_TDM_RX_4 Data Format", tdm_config_enum[0],
  5332. msm_dai_q6_tdm_data_format_get,
  5333. msm_dai_q6_tdm_data_format_put),
  5334. SOC_ENUM_EXT("PRI_TDM_RX_5 Data Format", tdm_config_enum[0],
  5335. msm_dai_q6_tdm_data_format_get,
  5336. msm_dai_q6_tdm_data_format_put),
  5337. SOC_ENUM_EXT("PRI_TDM_RX_6 Data Format", tdm_config_enum[0],
  5338. msm_dai_q6_tdm_data_format_get,
  5339. msm_dai_q6_tdm_data_format_put),
  5340. SOC_ENUM_EXT("PRI_TDM_RX_7 Data Format", tdm_config_enum[0],
  5341. msm_dai_q6_tdm_data_format_get,
  5342. msm_dai_q6_tdm_data_format_put),
  5343. SOC_ENUM_EXT("PRI_TDM_TX_0 Data Format", tdm_config_enum[0],
  5344. msm_dai_q6_tdm_data_format_get,
  5345. msm_dai_q6_tdm_data_format_put),
  5346. SOC_ENUM_EXT("PRI_TDM_TX_1 Data Format", tdm_config_enum[0],
  5347. msm_dai_q6_tdm_data_format_get,
  5348. msm_dai_q6_tdm_data_format_put),
  5349. SOC_ENUM_EXT("PRI_TDM_TX_2 Data Format", tdm_config_enum[0],
  5350. msm_dai_q6_tdm_data_format_get,
  5351. msm_dai_q6_tdm_data_format_put),
  5352. SOC_ENUM_EXT("PRI_TDM_TX_3 Data Format", tdm_config_enum[0],
  5353. msm_dai_q6_tdm_data_format_get,
  5354. msm_dai_q6_tdm_data_format_put),
  5355. SOC_ENUM_EXT("PRI_TDM_TX_4 Data Format", tdm_config_enum[0],
  5356. msm_dai_q6_tdm_data_format_get,
  5357. msm_dai_q6_tdm_data_format_put),
  5358. SOC_ENUM_EXT("PRI_TDM_TX_5 Data Format", tdm_config_enum[0],
  5359. msm_dai_q6_tdm_data_format_get,
  5360. msm_dai_q6_tdm_data_format_put),
  5361. SOC_ENUM_EXT("PRI_TDM_TX_6 Data Format", tdm_config_enum[0],
  5362. msm_dai_q6_tdm_data_format_get,
  5363. msm_dai_q6_tdm_data_format_put),
  5364. SOC_ENUM_EXT("PRI_TDM_TX_7 Data Format", tdm_config_enum[0],
  5365. msm_dai_q6_tdm_data_format_get,
  5366. msm_dai_q6_tdm_data_format_put),
  5367. SOC_ENUM_EXT("SEC_TDM_RX_0 Data Format", tdm_config_enum[0],
  5368. msm_dai_q6_tdm_data_format_get,
  5369. msm_dai_q6_tdm_data_format_put),
  5370. SOC_ENUM_EXT("SEC_TDM_RX_1 Data Format", tdm_config_enum[0],
  5371. msm_dai_q6_tdm_data_format_get,
  5372. msm_dai_q6_tdm_data_format_put),
  5373. SOC_ENUM_EXT("SEC_TDM_RX_2 Data Format", tdm_config_enum[0],
  5374. msm_dai_q6_tdm_data_format_get,
  5375. msm_dai_q6_tdm_data_format_put),
  5376. SOC_ENUM_EXT("SEC_TDM_RX_3 Data Format", tdm_config_enum[0],
  5377. msm_dai_q6_tdm_data_format_get,
  5378. msm_dai_q6_tdm_data_format_put),
  5379. SOC_ENUM_EXT("SEC_TDM_RX_4 Data Format", tdm_config_enum[0],
  5380. msm_dai_q6_tdm_data_format_get,
  5381. msm_dai_q6_tdm_data_format_put),
  5382. SOC_ENUM_EXT("SEC_TDM_RX_5 Data Format", tdm_config_enum[0],
  5383. msm_dai_q6_tdm_data_format_get,
  5384. msm_dai_q6_tdm_data_format_put),
  5385. SOC_ENUM_EXT("SEC_TDM_RX_6 Data Format", tdm_config_enum[0],
  5386. msm_dai_q6_tdm_data_format_get,
  5387. msm_dai_q6_tdm_data_format_put),
  5388. SOC_ENUM_EXT("SEC_TDM_RX_7 Data Format", tdm_config_enum[0],
  5389. msm_dai_q6_tdm_data_format_get,
  5390. msm_dai_q6_tdm_data_format_put),
  5391. SOC_ENUM_EXT("SEC_TDM_TX_0 Data Format", tdm_config_enum[0],
  5392. msm_dai_q6_tdm_data_format_get,
  5393. msm_dai_q6_tdm_data_format_put),
  5394. SOC_ENUM_EXT("SEC_TDM_TX_1 Data Format", tdm_config_enum[0],
  5395. msm_dai_q6_tdm_data_format_get,
  5396. msm_dai_q6_tdm_data_format_put),
  5397. SOC_ENUM_EXT("SEC_TDM_TX_2 Data Format", tdm_config_enum[0],
  5398. msm_dai_q6_tdm_data_format_get,
  5399. msm_dai_q6_tdm_data_format_put),
  5400. SOC_ENUM_EXT("SEC_TDM_TX_3 Data Format", tdm_config_enum[0],
  5401. msm_dai_q6_tdm_data_format_get,
  5402. msm_dai_q6_tdm_data_format_put),
  5403. SOC_ENUM_EXT("SEC_TDM_TX_4 Data Format", tdm_config_enum[0],
  5404. msm_dai_q6_tdm_data_format_get,
  5405. msm_dai_q6_tdm_data_format_put),
  5406. SOC_ENUM_EXT("SEC_TDM_TX_5 Data Format", tdm_config_enum[0],
  5407. msm_dai_q6_tdm_data_format_get,
  5408. msm_dai_q6_tdm_data_format_put),
  5409. SOC_ENUM_EXT("SEC_TDM_TX_6 Data Format", tdm_config_enum[0],
  5410. msm_dai_q6_tdm_data_format_get,
  5411. msm_dai_q6_tdm_data_format_put),
  5412. SOC_ENUM_EXT("SEC_TDM_TX_7 Data Format", tdm_config_enum[0],
  5413. msm_dai_q6_tdm_data_format_get,
  5414. msm_dai_q6_tdm_data_format_put),
  5415. SOC_ENUM_EXT("TERT_TDM_RX_0 Data Format", tdm_config_enum[0],
  5416. msm_dai_q6_tdm_data_format_get,
  5417. msm_dai_q6_tdm_data_format_put),
  5418. SOC_ENUM_EXT("TERT_TDM_RX_1 Data Format", tdm_config_enum[0],
  5419. msm_dai_q6_tdm_data_format_get,
  5420. msm_dai_q6_tdm_data_format_put),
  5421. SOC_ENUM_EXT("TERT_TDM_RX_2 Data Format", tdm_config_enum[0],
  5422. msm_dai_q6_tdm_data_format_get,
  5423. msm_dai_q6_tdm_data_format_put),
  5424. SOC_ENUM_EXT("TERT_TDM_RX_3 Data Format", tdm_config_enum[0],
  5425. msm_dai_q6_tdm_data_format_get,
  5426. msm_dai_q6_tdm_data_format_put),
  5427. SOC_ENUM_EXT("TERT_TDM_RX_4 Data Format", tdm_config_enum[0],
  5428. msm_dai_q6_tdm_data_format_get,
  5429. msm_dai_q6_tdm_data_format_put),
  5430. SOC_ENUM_EXT("TERT_TDM_RX_5 Data Format", tdm_config_enum[0],
  5431. msm_dai_q6_tdm_data_format_get,
  5432. msm_dai_q6_tdm_data_format_put),
  5433. SOC_ENUM_EXT("TERT_TDM_RX_6 Data Format", tdm_config_enum[0],
  5434. msm_dai_q6_tdm_data_format_get,
  5435. msm_dai_q6_tdm_data_format_put),
  5436. SOC_ENUM_EXT("TERT_TDM_RX_7 Data Format", tdm_config_enum[0],
  5437. msm_dai_q6_tdm_data_format_get,
  5438. msm_dai_q6_tdm_data_format_put),
  5439. SOC_ENUM_EXT("TERT_TDM_TX_0 Data Format", tdm_config_enum[0],
  5440. msm_dai_q6_tdm_data_format_get,
  5441. msm_dai_q6_tdm_data_format_put),
  5442. SOC_ENUM_EXT("TERT_TDM_TX_1 Data Format", tdm_config_enum[0],
  5443. msm_dai_q6_tdm_data_format_get,
  5444. msm_dai_q6_tdm_data_format_put),
  5445. SOC_ENUM_EXT("TERT_TDM_TX_2 Data Format", tdm_config_enum[0],
  5446. msm_dai_q6_tdm_data_format_get,
  5447. msm_dai_q6_tdm_data_format_put),
  5448. SOC_ENUM_EXT("TERT_TDM_TX_3 Data Format", tdm_config_enum[0],
  5449. msm_dai_q6_tdm_data_format_get,
  5450. msm_dai_q6_tdm_data_format_put),
  5451. SOC_ENUM_EXT("TERT_TDM_TX_4 Data Format", tdm_config_enum[0],
  5452. msm_dai_q6_tdm_data_format_get,
  5453. msm_dai_q6_tdm_data_format_put),
  5454. SOC_ENUM_EXT("TERT_TDM_TX_5 Data Format", tdm_config_enum[0],
  5455. msm_dai_q6_tdm_data_format_get,
  5456. msm_dai_q6_tdm_data_format_put),
  5457. SOC_ENUM_EXT("TERT_TDM_TX_6 Data Format", tdm_config_enum[0],
  5458. msm_dai_q6_tdm_data_format_get,
  5459. msm_dai_q6_tdm_data_format_put),
  5460. SOC_ENUM_EXT("TERT_TDM_TX_7 Data Format", tdm_config_enum[0],
  5461. msm_dai_q6_tdm_data_format_get,
  5462. msm_dai_q6_tdm_data_format_put),
  5463. SOC_ENUM_EXT("QUAT_TDM_RX_0 Data Format", tdm_config_enum[0],
  5464. msm_dai_q6_tdm_data_format_get,
  5465. msm_dai_q6_tdm_data_format_put),
  5466. SOC_ENUM_EXT("QUAT_TDM_RX_1 Data Format", tdm_config_enum[0],
  5467. msm_dai_q6_tdm_data_format_get,
  5468. msm_dai_q6_tdm_data_format_put),
  5469. SOC_ENUM_EXT("QUAT_TDM_RX_2 Data Format", tdm_config_enum[0],
  5470. msm_dai_q6_tdm_data_format_get,
  5471. msm_dai_q6_tdm_data_format_put),
  5472. SOC_ENUM_EXT("QUAT_TDM_RX_3 Data Format", tdm_config_enum[0],
  5473. msm_dai_q6_tdm_data_format_get,
  5474. msm_dai_q6_tdm_data_format_put),
  5475. SOC_ENUM_EXT("QUAT_TDM_RX_4 Data Format", tdm_config_enum[0],
  5476. msm_dai_q6_tdm_data_format_get,
  5477. msm_dai_q6_tdm_data_format_put),
  5478. SOC_ENUM_EXT("QUAT_TDM_RX_5 Data Format", tdm_config_enum[0],
  5479. msm_dai_q6_tdm_data_format_get,
  5480. msm_dai_q6_tdm_data_format_put),
  5481. SOC_ENUM_EXT("QUAT_TDM_RX_6 Data Format", tdm_config_enum[0],
  5482. msm_dai_q6_tdm_data_format_get,
  5483. msm_dai_q6_tdm_data_format_put),
  5484. SOC_ENUM_EXT("QUAT_TDM_RX_7 Data Format", tdm_config_enum[0],
  5485. msm_dai_q6_tdm_data_format_get,
  5486. msm_dai_q6_tdm_data_format_put),
  5487. SOC_ENUM_EXT("QUAT_TDM_TX_0 Data Format", tdm_config_enum[0],
  5488. msm_dai_q6_tdm_data_format_get,
  5489. msm_dai_q6_tdm_data_format_put),
  5490. SOC_ENUM_EXT("QUAT_TDM_TX_1 Data Format", tdm_config_enum[0],
  5491. msm_dai_q6_tdm_data_format_get,
  5492. msm_dai_q6_tdm_data_format_put),
  5493. SOC_ENUM_EXT("QUAT_TDM_TX_2 Data Format", tdm_config_enum[0],
  5494. msm_dai_q6_tdm_data_format_get,
  5495. msm_dai_q6_tdm_data_format_put),
  5496. SOC_ENUM_EXT("QUAT_TDM_TX_3 Data Format", tdm_config_enum[0],
  5497. msm_dai_q6_tdm_data_format_get,
  5498. msm_dai_q6_tdm_data_format_put),
  5499. SOC_ENUM_EXT("QUAT_TDM_TX_4 Data Format", tdm_config_enum[0],
  5500. msm_dai_q6_tdm_data_format_get,
  5501. msm_dai_q6_tdm_data_format_put),
  5502. SOC_ENUM_EXT("QUAT_TDM_TX_5 Data Format", tdm_config_enum[0],
  5503. msm_dai_q6_tdm_data_format_get,
  5504. msm_dai_q6_tdm_data_format_put),
  5505. SOC_ENUM_EXT("QUAT_TDM_TX_6 Data Format", tdm_config_enum[0],
  5506. msm_dai_q6_tdm_data_format_get,
  5507. msm_dai_q6_tdm_data_format_put),
  5508. SOC_ENUM_EXT("QUAT_TDM_TX_7 Data Format", tdm_config_enum[0],
  5509. msm_dai_q6_tdm_data_format_get,
  5510. msm_dai_q6_tdm_data_format_put),
  5511. SOC_ENUM_EXT("QUIN_TDM_RX_0 Data Format", tdm_config_enum[0],
  5512. msm_dai_q6_tdm_data_format_get,
  5513. msm_dai_q6_tdm_data_format_put),
  5514. SOC_ENUM_EXT("QUIN_TDM_RX_1 Data Format", tdm_config_enum[0],
  5515. msm_dai_q6_tdm_data_format_get,
  5516. msm_dai_q6_tdm_data_format_put),
  5517. SOC_ENUM_EXT("QUIN_TDM_RX_2 Data Format", tdm_config_enum[0],
  5518. msm_dai_q6_tdm_data_format_get,
  5519. msm_dai_q6_tdm_data_format_put),
  5520. SOC_ENUM_EXT("QUIN_TDM_RX_3 Data Format", tdm_config_enum[0],
  5521. msm_dai_q6_tdm_data_format_get,
  5522. msm_dai_q6_tdm_data_format_put),
  5523. SOC_ENUM_EXT("QUIN_TDM_RX_4 Data Format", tdm_config_enum[0],
  5524. msm_dai_q6_tdm_data_format_get,
  5525. msm_dai_q6_tdm_data_format_put),
  5526. SOC_ENUM_EXT("QUIN_TDM_RX_5 Data Format", tdm_config_enum[0],
  5527. msm_dai_q6_tdm_data_format_get,
  5528. msm_dai_q6_tdm_data_format_put),
  5529. SOC_ENUM_EXT("QUIN_TDM_RX_6 Data Format", tdm_config_enum[0],
  5530. msm_dai_q6_tdm_data_format_get,
  5531. msm_dai_q6_tdm_data_format_put),
  5532. SOC_ENUM_EXT("QUIN_TDM_RX_7 Data Format", tdm_config_enum[0],
  5533. msm_dai_q6_tdm_data_format_get,
  5534. msm_dai_q6_tdm_data_format_put),
  5535. SOC_ENUM_EXT("QUIN_TDM_TX_0 Data Format", tdm_config_enum[0],
  5536. msm_dai_q6_tdm_data_format_get,
  5537. msm_dai_q6_tdm_data_format_put),
  5538. SOC_ENUM_EXT("QUIN_TDM_TX_1 Data Format", tdm_config_enum[0],
  5539. msm_dai_q6_tdm_data_format_get,
  5540. msm_dai_q6_tdm_data_format_put),
  5541. SOC_ENUM_EXT("QUIN_TDM_TX_2 Data Format", tdm_config_enum[0],
  5542. msm_dai_q6_tdm_data_format_get,
  5543. msm_dai_q6_tdm_data_format_put),
  5544. SOC_ENUM_EXT("QUIN_TDM_TX_3 Data Format", tdm_config_enum[0],
  5545. msm_dai_q6_tdm_data_format_get,
  5546. msm_dai_q6_tdm_data_format_put),
  5547. SOC_ENUM_EXT("QUIN_TDM_TX_4 Data Format", tdm_config_enum[0],
  5548. msm_dai_q6_tdm_data_format_get,
  5549. msm_dai_q6_tdm_data_format_put),
  5550. SOC_ENUM_EXT("QUIN_TDM_TX_5 Data Format", tdm_config_enum[0],
  5551. msm_dai_q6_tdm_data_format_get,
  5552. msm_dai_q6_tdm_data_format_put),
  5553. SOC_ENUM_EXT("QUIN_TDM_TX_6 Data Format", tdm_config_enum[0],
  5554. msm_dai_q6_tdm_data_format_get,
  5555. msm_dai_q6_tdm_data_format_put),
  5556. SOC_ENUM_EXT("QUIN_TDM_TX_7 Data Format", tdm_config_enum[0],
  5557. msm_dai_q6_tdm_data_format_get,
  5558. msm_dai_q6_tdm_data_format_put),
  5559. };
  5560. static const struct snd_kcontrol_new tdm_config_controls_header_type[] = {
  5561. SOC_ENUM_EXT("PRI_TDM_RX_0 Header Type", tdm_config_enum[1],
  5562. msm_dai_q6_tdm_header_type_get,
  5563. msm_dai_q6_tdm_header_type_put),
  5564. SOC_ENUM_EXT("PRI_TDM_RX_1 Header Type", tdm_config_enum[1],
  5565. msm_dai_q6_tdm_header_type_get,
  5566. msm_dai_q6_tdm_header_type_put),
  5567. SOC_ENUM_EXT("PRI_TDM_RX_2 Header Type", tdm_config_enum[1],
  5568. msm_dai_q6_tdm_header_type_get,
  5569. msm_dai_q6_tdm_header_type_put),
  5570. SOC_ENUM_EXT("PRI_TDM_RX_3 Header Type", tdm_config_enum[1],
  5571. msm_dai_q6_tdm_header_type_get,
  5572. msm_dai_q6_tdm_header_type_put),
  5573. SOC_ENUM_EXT("PRI_TDM_RX_4 Header Type", tdm_config_enum[1],
  5574. msm_dai_q6_tdm_header_type_get,
  5575. msm_dai_q6_tdm_header_type_put),
  5576. SOC_ENUM_EXT("PRI_TDM_RX_5 Header Type", tdm_config_enum[1],
  5577. msm_dai_q6_tdm_header_type_get,
  5578. msm_dai_q6_tdm_header_type_put),
  5579. SOC_ENUM_EXT("PRI_TDM_RX_6 Header Type", tdm_config_enum[1],
  5580. msm_dai_q6_tdm_header_type_get,
  5581. msm_dai_q6_tdm_header_type_put),
  5582. SOC_ENUM_EXT("PRI_TDM_RX_7 Header Type", tdm_config_enum[1],
  5583. msm_dai_q6_tdm_header_type_get,
  5584. msm_dai_q6_tdm_header_type_put),
  5585. SOC_ENUM_EXT("PRI_TDM_TX_0 Header Type", tdm_config_enum[1],
  5586. msm_dai_q6_tdm_header_type_get,
  5587. msm_dai_q6_tdm_header_type_put),
  5588. SOC_ENUM_EXT("PRI_TDM_TX_1 Header Type", tdm_config_enum[1],
  5589. msm_dai_q6_tdm_header_type_get,
  5590. msm_dai_q6_tdm_header_type_put),
  5591. SOC_ENUM_EXT("PRI_TDM_TX_2 Header Type", tdm_config_enum[1],
  5592. msm_dai_q6_tdm_header_type_get,
  5593. msm_dai_q6_tdm_header_type_put),
  5594. SOC_ENUM_EXT("PRI_TDM_TX_3 Header Type", tdm_config_enum[1],
  5595. msm_dai_q6_tdm_header_type_get,
  5596. msm_dai_q6_tdm_header_type_put),
  5597. SOC_ENUM_EXT("PRI_TDM_TX_4 Header Type", tdm_config_enum[1],
  5598. msm_dai_q6_tdm_header_type_get,
  5599. msm_dai_q6_tdm_header_type_put),
  5600. SOC_ENUM_EXT("PRI_TDM_TX_5 Header Type", tdm_config_enum[1],
  5601. msm_dai_q6_tdm_header_type_get,
  5602. msm_dai_q6_tdm_header_type_put),
  5603. SOC_ENUM_EXT("PRI_TDM_TX_6 Header Type", tdm_config_enum[1],
  5604. msm_dai_q6_tdm_header_type_get,
  5605. msm_dai_q6_tdm_header_type_put),
  5606. SOC_ENUM_EXT("PRI_TDM_TX_7 Header Type", tdm_config_enum[1],
  5607. msm_dai_q6_tdm_header_type_get,
  5608. msm_dai_q6_tdm_header_type_put),
  5609. SOC_ENUM_EXT("SEC_TDM_RX_0 Header Type", tdm_config_enum[1],
  5610. msm_dai_q6_tdm_header_type_get,
  5611. msm_dai_q6_tdm_header_type_put),
  5612. SOC_ENUM_EXT("SEC_TDM_RX_1 Header Type", tdm_config_enum[1],
  5613. msm_dai_q6_tdm_header_type_get,
  5614. msm_dai_q6_tdm_header_type_put),
  5615. SOC_ENUM_EXT("SEC_TDM_RX_2 Header Type", tdm_config_enum[1],
  5616. msm_dai_q6_tdm_header_type_get,
  5617. msm_dai_q6_tdm_header_type_put),
  5618. SOC_ENUM_EXT("SEC_TDM_RX_3 Header Type", tdm_config_enum[1],
  5619. msm_dai_q6_tdm_header_type_get,
  5620. msm_dai_q6_tdm_header_type_put),
  5621. SOC_ENUM_EXT("SEC_TDM_RX_4 Header Type", tdm_config_enum[1],
  5622. msm_dai_q6_tdm_header_type_get,
  5623. msm_dai_q6_tdm_header_type_put),
  5624. SOC_ENUM_EXT("SEC_TDM_RX_5 Header Type", tdm_config_enum[1],
  5625. msm_dai_q6_tdm_header_type_get,
  5626. msm_dai_q6_tdm_header_type_put),
  5627. SOC_ENUM_EXT("SEC_TDM_RX_6 Header Type", tdm_config_enum[1],
  5628. msm_dai_q6_tdm_header_type_get,
  5629. msm_dai_q6_tdm_header_type_put),
  5630. SOC_ENUM_EXT("SEC_TDM_RX_7 Header Type", tdm_config_enum[1],
  5631. msm_dai_q6_tdm_header_type_get,
  5632. msm_dai_q6_tdm_header_type_put),
  5633. SOC_ENUM_EXT("SEC_TDM_TX_0 Header Type", tdm_config_enum[1],
  5634. msm_dai_q6_tdm_header_type_get,
  5635. msm_dai_q6_tdm_header_type_put),
  5636. SOC_ENUM_EXT("SEC_TDM_TX_1 Header Type", tdm_config_enum[1],
  5637. msm_dai_q6_tdm_header_type_get,
  5638. msm_dai_q6_tdm_header_type_put),
  5639. SOC_ENUM_EXT("SEC_TDM_TX_2 Header Type", tdm_config_enum[1],
  5640. msm_dai_q6_tdm_header_type_get,
  5641. msm_dai_q6_tdm_header_type_put),
  5642. SOC_ENUM_EXT("SEC_TDM_TX_3 Header Type", tdm_config_enum[1],
  5643. msm_dai_q6_tdm_header_type_get,
  5644. msm_dai_q6_tdm_header_type_put),
  5645. SOC_ENUM_EXT("SEC_TDM_TX_4 Header Type", tdm_config_enum[1],
  5646. msm_dai_q6_tdm_header_type_get,
  5647. msm_dai_q6_tdm_header_type_put),
  5648. SOC_ENUM_EXT("SEC_TDM_TX_5 Header Type", tdm_config_enum[1],
  5649. msm_dai_q6_tdm_header_type_get,
  5650. msm_dai_q6_tdm_header_type_put),
  5651. SOC_ENUM_EXT("SEC_TDM_TX_6 Header Type", tdm_config_enum[1],
  5652. msm_dai_q6_tdm_header_type_get,
  5653. msm_dai_q6_tdm_header_type_put),
  5654. SOC_ENUM_EXT("SEC_TDM_TX_7 Header Type", tdm_config_enum[1],
  5655. msm_dai_q6_tdm_header_type_get,
  5656. msm_dai_q6_tdm_header_type_put),
  5657. SOC_ENUM_EXT("TERT_TDM_RX_0 Header Type", tdm_config_enum[1],
  5658. msm_dai_q6_tdm_header_type_get,
  5659. msm_dai_q6_tdm_header_type_put),
  5660. SOC_ENUM_EXT("TERT_TDM_RX_1 Header Type", tdm_config_enum[1],
  5661. msm_dai_q6_tdm_header_type_get,
  5662. msm_dai_q6_tdm_header_type_put),
  5663. SOC_ENUM_EXT("TERT_TDM_RX_2 Header Type", tdm_config_enum[1],
  5664. msm_dai_q6_tdm_header_type_get,
  5665. msm_dai_q6_tdm_header_type_put),
  5666. SOC_ENUM_EXT("TERT_TDM_RX_3 Header Type", tdm_config_enum[1],
  5667. msm_dai_q6_tdm_header_type_get,
  5668. msm_dai_q6_tdm_header_type_put),
  5669. SOC_ENUM_EXT("TERT_TDM_RX_4 Header Type", tdm_config_enum[1],
  5670. msm_dai_q6_tdm_header_type_get,
  5671. msm_dai_q6_tdm_header_type_put),
  5672. SOC_ENUM_EXT("TERT_TDM_RX_5 Header Type", tdm_config_enum[1],
  5673. msm_dai_q6_tdm_header_type_get,
  5674. msm_dai_q6_tdm_header_type_put),
  5675. SOC_ENUM_EXT("TERT_TDM_RX_6 Header Type", tdm_config_enum[1],
  5676. msm_dai_q6_tdm_header_type_get,
  5677. msm_dai_q6_tdm_header_type_put),
  5678. SOC_ENUM_EXT("TERT_TDM_RX_7 Header Type", tdm_config_enum[1],
  5679. msm_dai_q6_tdm_header_type_get,
  5680. msm_dai_q6_tdm_header_type_put),
  5681. SOC_ENUM_EXT("TERT_TDM_TX_0 Header Type", tdm_config_enum[1],
  5682. msm_dai_q6_tdm_header_type_get,
  5683. msm_dai_q6_tdm_header_type_put),
  5684. SOC_ENUM_EXT("TERT_TDM_TX_1 Header Type", tdm_config_enum[1],
  5685. msm_dai_q6_tdm_header_type_get,
  5686. msm_dai_q6_tdm_header_type_put),
  5687. SOC_ENUM_EXT("TERT_TDM_TX_2 Header Type", tdm_config_enum[1],
  5688. msm_dai_q6_tdm_header_type_get,
  5689. msm_dai_q6_tdm_header_type_put),
  5690. SOC_ENUM_EXT("TERT_TDM_TX_3 Header Type", tdm_config_enum[1],
  5691. msm_dai_q6_tdm_header_type_get,
  5692. msm_dai_q6_tdm_header_type_put),
  5693. SOC_ENUM_EXT("TERT_TDM_TX_4 Header Type", tdm_config_enum[1],
  5694. msm_dai_q6_tdm_header_type_get,
  5695. msm_dai_q6_tdm_header_type_put),
  5696. SOC_ENUM_EXT("TERT_TDM_TX_5 Header Type", tdm_config_enum[1],
  5697. msm_dai_q6_tdm_header_type_get,
  5698. msm_dai_q6_tdm_header_type_put),
  5699. SOC_ENUM_EXT("TERT_TDM_TX_6 Header Type", tdm_config_enum[1],
  5700. msm_dai_q6_tdm_header_type_get,
  5701. msm_dai_q6_tdm_header_type_put),
  5702. SOC_ENUM_EXT("TERT_TDM_TX_7 Header Type", tdm_config_enum[1],
  5703. msm_dai_q6_tdm_header_type_get,
  5704. msm_dai_q6_tdm_header_type_put),
  5705. SOC_ENUM_EXT("QUAT_TDM_RX_0 Header Type", tdm_config_enum[1],
  5706. msm_dai_q6_tdm_header_type_get,
  5707. msm_dai_q6_tdm_header_type_put),
  5708. SOC_ENUM_EXT("QUAT_TDM_RX_1 Header Type", tdm_config_enum[1],
  5709. msm_dai_q6_tdm_header_type_get,
  5710. msm_dai_q6_tdm_header_type_put),
  5711. SOC_ENUM_EXT("QUAT_TDM_RX_2 Header Type", tdm_config_enum[1],
  5712. msm_dai_q6_tdm_header_type_get,
  5713. msm_dai_q6_tdm_header_type_put),
  5714. SOC_ENUM_EXT("QUAT_TDM_RX_3 Header Type", tdm_config_enum[1],
  5715. msm_dai_q6_tdm_header_type_get,
  5716. msm_dai_q6_tdm_header_type_put),
  5717. SOC_ENUM_EXT("QUAT_TDM_RX_4 Header Type", tdm_config_enum[1],
  5718. msm_dai_q6_tdm_header_type_get,
  5719. msm_dai_q6_tdm_header_type_put),
  5720. SOC_ENUM_EXT("QUAT_TDM_RX_5 Header Type", tdm_config_enum[1],
  5721. msm_dai_q6_tdm_header_type_get,
  5722. msm_dai_q6_tdm_header_type_put),
  5723. SOC_ENUM_EXT("QUAT_TDM_RX_6 Header Type", tdm_config_enum[1],
  5724. msm_dai_q6_tdm_header_type_get,
  5725. msm_dai_q6_tdm_header_type_put),
  5726. SOC_ENUM_EXT("QUAT_TDM_RX_7 Header Type", tdm_config_enum[1],
  5727. msm_dai_q6_tdm_header_type_get,
  5728. msm_dai_q6_tdm_header_type_put),
  5729. SOC_ENUM_EXT("QUAT_TDM_TX_0 Header Type", tdm_config_enum[1],
  5730. msm_dai_q6_tdm_header_type_get,
  5731. msm_dai_q6_tdm_header_type_put),
  5732. SOC_ENUM_EXT("QUAT_TDM_TX_1 Header Type", tdm_config_enum[1],
  5733. msm_dai_q6_tdm_header_type_get,
  5734. msm_dai_q6_tdm_header_type_put),
  5735. SOC_ENUM_EXT("QUAT_TDM_TX_2 Header Type", tdm_config_enum[1],
  5736. msm_dai_q6_tdm_header_type_get,
  5737. msm_dai_q6_tdm_header_type_put),
  5738. SOC_ENUM_EXT("QUAT_TDM_TX_3 Header Type", tdm_config_enum[1],
  5739. msm_dai_q6_tdm_header_type_get,
  5740. msm_dai_q6_tdm_header_type_put),
  5741. SOC_ENUM_EXT("QUAT_TDM_TX_4 Header Type", tdm_config_enum[1],
  5742. msm_dai_q6_tdm_header_type_get,
  5743. msm_dai_q6_tdm_header_type_put),
  5744. SOC_ENUM_EXT("QUAT_TDM_TX_5 Header Type", tdm_config_enum[1],
  5745. msm_dai_q6_tdm_header_type_get,
  5746. msm_dai_q6_tdm_header_type_put),
  5747. SOC_ENUM_EXT("QUAT_TDM_TX_6 Header Type", tdm_config_enum[1],
  5748. msm_dai_q6_tdm_header_type_get,
  5749. msm_dai_q6_tdm_header_type_put),
  5750. SOC_ENUM_EXT("QUAT_TDM_TX_7 Header Type", tdm_config_enum[1],
  5751. msm_dai_q6_tdm_header_type_get,
  5752. msm_dai_q6_tdm_header_type_put),
  5753. SOC_ENUM_EXT("QUIN_TDM_RX_0 Header Type", tdm_config_enum[1],
  5754. msm_dai_q6_tdm_header_type_get,
  5755. msm_dai_q6_tdm_header_type_put),
  5756. SOC_ENUM_EXT("QUIN_TDM_RX_1 Header Type", tdm_config_enum[1],
  5757. msm_dai_q6_tdm_header_type_get,
  5758. msm_dai_q6_tdm_header_type_put),
  5759. SOC_ENUM_EXT("QUIN_TDM_RX_2 Header Type", tdm_config_enum[1],
  5760. msm_dai_q6_tdm_header_type_get,
  5761. msm_dai_q6_tdm_header_type_put),
  5762. SOC_ENUM_EXT("QUIN_TDM_RX_3 Header Type", tdm_config_enum[1],
  5763. msm_dai_q6_tdm_header_type_get,
  5764. msm_dai_q6_tdm_header_type_put),
  5765. SOC_ENUM_EXT("QUIN_TDM_RX_4 Header Type", tdm_config_enum[1],
  5766. msm_dai_q6_tdm_header_type_get,
  5767. msm_dai_q6_tdm_header_type_put),
  5768. SOC_ENUM_EXT("QUIN_TDM_RX_5 Header Type", tdm_config_enum[1],
  5769. msm_dai_q6_tdm_header_type_get,
  5770. msm_dai_q6_tdm_header_type_put),
  5771. SOC_ENUM_EXT("QUIN_TDM_RX_6 Header Type", tdm_config_enum[1],
  5772. msm_dai_q6_tdm_header_type_get,
  5773. msm_dai_q6_tdm_header_type_put),
  5774. SOC_ENUM_EXT("QUIN_TDM_RX_7 Header Type", tdm_config_enum[1],
  5775. msm_dai_q6_tdm_header_type_get,
  5776. msm_dai_q6_tdm_header_type_put),
  5777. SOC_ENUM_EXT("QUIN_TDM_TX_0 Header Type", tdm_config_enum[1],
  5778. msm_dai_q6_tdm_header_type_get,
  5779. msm_dai_q6_tdm_header_type_put),
  5780. SOC_ENUM_EXT("QUIN_TDM_TX_1 Header Type", tdm_config_enum[1],
  5781. msm_dai_q6_tdm_header_type_get,
  5782. msm_dai_q6_tdm_header_type_put),
  5783. SOC_ENUM_EXT("QUIN_TDM_TX_2 Header Type", tdm_config_enum[1],
  5784. msm_dai_q6_tdm_header_type_get,
  5785. msm_dai_q6_tdm_header_type_put),
  5786. SOC_ENUM_EXT("QUIN_TDM_TX_3 Header Type", tdm_config_enum[1],
  5787. msm_dai_q6_tdm_header_type_get,
  5788. msm_dai_q6_tdm_header_type_put),
  5789. SOC_ENUM_EXT("QUIN_TDM_TX_4 Header Type", tdm_config_enum[1],
  5790. msm_dai_q6_tdm_header_type_get,
  5791. msm_dai_q6_tdm_header_type_put),
  5792. SOC_ENUM_EXT("QUIN_TDM_TX_5 Header Type", tdm_config_enum[1],
  5793. msm_dai_q6_tdm_header_type_get,
  5794. msm_dai_q6_tdm_header_type_put),
  5795. SOC_ENUM_EXT("QUIN_TDM_TX_6 Header Type", tdm_config_enum[1],
  5796. msm_dai_q6_tdm_header_type_get,
  5797. msm_dai_q6_tdm_header_type_put),
  5798. SOC_ENUM_EXT("QUIN_TDM_TX_7 Header Type", tdm_config_enum[1],
  5799. msm_dai_q6_tdm_header_type_get,
  5800. msm_dai_q6_tdm_header_type_put),
  5801. };
  5802. static const struct snd_kcontrol_new tdm_config_controls_header[] = {
  5803. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 Header",
  5804. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5805. msm_dai_q6_tdm_header_get,
  5806. msm_dai_q6_tdm_header_put),
  5807. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 Header",
  5808. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5809. msm_dai_q6_tdm_header_get,
  5810. msm_dai_q6_tdm_header_put),
  5811. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 Header",
  5812. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5813. msm_dai_q6_tdm_header_get,
  5814. msm_dai_q6_tdm_header_put),
  5815. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 Header",
  5816. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5817. msm_dai_q6_tdm_header_get,
  5818. msm_dai_q6_tdm_header_put),
  5819. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_4 Header",
  5820. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5821. msm_dai_q6_tdm_header_get,
  5822. msm_dai_q6_tdm_header_put),
  5823. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_5 Header",
  5824. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5825. msm_dai_q6_tdm_header_get,
  5826. msm_dai_q6_tdm_header_put),
  5827. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_6 Header",
  5828. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5829. msm_dai_q6_tdm_header_get,
  5830. msm_dai_q6_tdm_header_put),
  5831. SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_7 Header",
  5832. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5833. msm_dai_q6_tdm_header_get,
  5834. msm_dai_q6_tdm_header_put),
  5835. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 Header",
  5836. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5837. msm_dai_q6_tdm_header_get,
  5838. msm_dai_q6_tdm_header_put),
  5839. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 Header",
  5840. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5841. msm_dai_q6_tdm_header_get,
  5842. msm_dai_q6_tdm_header_put),
  5843. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 Header",
  5844. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5845. msm_dai_q6_tdm_header_get,
  5846. msm_dai_q6_tdm_header_put),
  5847. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 Header",
  5848. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5849. msm_dai_q6_tdm_header_get,
  5850. msm_dai_q6_tdm_header_put),
  5851. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_4 Header",
  5852. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5853. msm_dai_q6_tdm_header_get,
  5854. msm_dai_q6_tdm_header_put),
  5855. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_5 Header",
  5856. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5857. msm_dai_q6_tdm_header_get,
  5858. msm_dai_q6_tdm_header_put),
  5859. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_6 Header",
  5860. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5861. msm_dai_q6_tdm_header_get,
  5862. msm_dai_q6_tdm_header_put),
  5863. SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_7 Header",
  5864. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5865. msm_dai_q6_tdm_header_get,
  5866. msm_dai_q6_tdm_header_put),
  5867. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 Header",
  5868. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5869. msm_dai_q6_tdm_header_get,
  5870. msm_dai_q6_tdm_header_put),
  5871. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 Header",
  5872. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5873. msm_dai_q6_tdm_header_get,
  5874. msm_dai_q6_tdm_header_put),
  5875. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 Header",
  5876. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5877. msm_dai_q6_tdm_header_get,
  5878. msm_dai_q6_tdm_header_put),
  5879. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 Header",
  5880. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5881. msm_dai_q6_tdm_header_get,
  5882. msm_dai_q6_tdm_header_put),
  5883. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_4 Header",
  5884. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5885. msm_dai_q6_tdm_header_get,
  5886. msm_dai_q6_tdm_header_put),
  5887. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_5 Header",
  5888. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5889. msm_dai_q6_tdm_header_get,
  5890. msm_dai_q6_tdm_header_put),
  5891. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_6 Header",
  5892. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5893. msm_dai_q6_tdm_header_get,
  5894. msm_dai_q6_tdm_header_put),
  5895. SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_7 Header",
  5896. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5897. msm_dai_q6_tdm_header_get,
  5898. msm_dai_q6_tdm_header_put),
  5899. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 Header",
  5900. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5901. msm_dai_q6_tdm_header_get,
  5902. msm_dai_q6_tdm_header_put),
  5903. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 Header",
  5904. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5905. msm_dai_q6_tdm_header_get,
  5906. msm_dai_q6_tdm_header_put),
  5907. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 Header",
  5908. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5909. msm_dai_q6_tdm_header_get,
  5910. msm_dai_q6_tdm_header_put),
  5911. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 Header",
  5912. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5913. msm_dai_q6_tdm_header_get,
  5914. msm_dai_q6_tdm_header_put),
  5915. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_4 Header",
  5916. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5917. msm_dai_q6_tdm_header_get,
  5918. msm_dai_q6_tdm_header_put),
  5919. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_5 Header",
  5920. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5921. msm_dai_q6_tdm_header_get,
  5922. msm_dai_q6_tdm_header_put),
  5923. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_6 Header",
  5924. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5925. msm_dai_q6_tdm_header_get,
  5926. msm_dai_q6_tdm_header_put),
  5927. SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_7 Header",
  5928. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5929. msm_dai_q6_tdm_header_get,
  5930. msm_dai_q6_tdm_header_put),
  5931. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 Header",
  5932. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5933. msm_dai_q6_tdm_header_get,
  5934. msm_dai_q6_tdm_header_put),
  5935. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 Header",
  5936. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5937. msm_dai_q6_tdm_header_get,
  5938. msm_dai_q6_tdm_header_put),
  5939. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 Header",
  5940. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5941. msm_dai_q6_tdm_header_get,
  5942. msm_dai_q6_tdm_header_put),
  5943. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 Header",
  5944. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5945. msm_dai_q6_tdm_header_get,
  5946. msm_dai_q6_tdm_header_put),
  5947. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 Header",
  5948. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5949. msm_dai_q6_tdm_header_get,
  5950. msm_dai_q6_tdm_header_put),
  5951. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_5 Header",
  5952. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5953. msm_dai_q6_tdm_header_get,
  5954. msm_dai_q6_tdm_header_put),
  5955. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_6 Header",
  5956. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5957. msm_dai_q6_tdm_header_get,
  5958. msm_dai_q6_tdm_header_put),
  5959. SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_7 Header",
  5960. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5961. msm_dai_q6_tdm_header_get,
  5962. msm_dai_q6_tdm_header_put),
  5963. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 Header",
  5964. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5965. msm_dai_q6_tdm_header_get,
  5966. msm_dai_q6_tdm_header_put),
  5967. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 Header",
  5968. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5969. msm_dai_q6_tdm_header_get,
  5970. msm_dai_q6_tdm_header_put),
  5971. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 Header",
  5972. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5973. msm_dai_q6_tdm_header_get,
  5974. msm_dai_q6_tdm_header_put),
  5975. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 Header",
  5976. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5977. msm_dai_q6_tdm_header_get,
  5978. msm_dai_q6_tdm_header_put),
  5979. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_4 Header",
  5980. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5981. msm_dai_q6_tdm_header_get,
  5982. msm_dai_q6_tdm_header_put),
  5983. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_5 Header",
  5984. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5985. msm_dai_q6_tdm_header_get,
  5986. msm_dai_q6_tdm_header_put),
  5987. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_6 Header",
  5988. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5989. msm_dai_q6_tdm_header_get,
  5990. msm_dai_q6_tdm_header_put),
  5991. SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_7 Header",
  5992. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5993. msm_dai_q6_tdm_header_get,
  5994. msm_dai_q6_tdm_header_put),
  5995. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 Header",
  5996. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  5997. msm_dai_q6_tdm_header_get,
  5998. msm_dai_q6_tdm_header_put),
  5999. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 Header",
  6000. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6001. msm_dai_q6_tdm_header_get,
  6002. msm_dai_q6_tdm_header_put),
  6003. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 Header",
  6004. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6005. msm_dai_q6_tdm_header_get,
  6006. msm_dai_q6_tdm_header_put),
  6007. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 Header",
  6008. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6009. msm_dai_q6_tdm_header_get,
  6010. msm_dai_q6_tdm_header_put),
  6011. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_4 Header",
  6012. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6013. msm_dai_q6_tdm_header_get,
  6014. msm_dai_q6_tdm_header_put),
  6015. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_5 Header",
  6016. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6017. msm_dai_q6_tdm_header_get,
  6018. msm_dai_q6_tdm_header_put),
  6019. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_6 Header",
  6020. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6021. msm_dai_q6_tdm_header_get,
  6022. msm_dai_q6_tdm_header_put),
  6023. SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_7 Header",
  6024. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6025. msm_dai_q6_tdm_header_get,
  6026. msm_dai_q6_tdm_header_put),
  6027. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 Header",
  6028. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6029. msm_dai_q6_tdm_header_get,
  6030. msm_dai_q6_tdm_header_put),
  6031. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 Header",
  6032. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6033. msm_dai_q6_tdm_header_get,
  6034. msm_dai_q6_tdm_header_put),
  6035. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 Header",
  6036. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6037. msm_dai_q6_tdm_header_get,
  6038. msm_dai_q6_tdm_header_put),
  6039. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 Header",
  6040. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6041. msm_dai_q6_tdm_header_get,
  6042. msm_dai_q6_tdm_header_put),
  6043. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_4 Header",
  6044. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6045. msm_dai_q6_tdm_header_get,
  6046. msm_dai_q6_tdm_header_put),
  6047. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_5 Header",
  6048. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6049. msm_dai_q6_tdm_header_get,
  6050. msm_dai_q6_tdm_header_put),
  6051. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_6 Header",
  6052. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6053. msm_dai_q6_tdm_header_get,
  6054. msm_dai_q6_tdm_header_put),
  6055. SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_7 Header",
  6056. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6057. msm_dai_q6_tdm_header_get,
  6058. msm_dai_q6_tdm_header_put),
  6059. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_0 Header",
  6060. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6061. msm_dai_q6_tdm_header_get,
  6062. msm_dai_q6_tdm_header_put),
  6063. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_1 Header",
  6064. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6065. msm_dai_q6_tdm_header_get,
  6066. msm_dai_q6_tdm_header_put),
  6067. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_2 Header",
  6068. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6069. msm_dai_q6_tdm_header_get,
  6070. msm_dai_q6_tdm_header_put),
  6071. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_3 Header",
  6072. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6073. msm_dai_q6_tdm_header_get,
  6074. msm_dai_q6_tdm_header_put),
  6075. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_4 Header",
  6076. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6077. msm_dai_q6_tdm_header_get,
  6078. msm_dai_q6_tdm_header_put),
  6079. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_5 Header",
  6080. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6081. msm_dai_q6_tdm_header_get,
  6082. msm_dai_q6_tdm_header_put),
  6083. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_6 Header",
  6084. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6085. msm_dai_q6_tdm_header_get,
  6086. msm_dai_q6_tdm_header_put),
  6087. SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_7 Header",
  6088. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6089. msm_dai_q6_tdm_header_get,
  6090. msm_dai_q6_tdm_header_put),
  6091. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_0 Header",
  6092. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6093. msm_dai_q6_tdm_header_get,
  6094. msm_dai_q6_tdm_header_put),
  6095. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_1 Header",
  6096. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6097. msm_dai_q6_tdm_header_get,
  6098. msm_dai_q6_tdm_header_put),
  6099. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_2 Header",
  6100. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6101. msm_dai_q6_tdm_header_get,
  6102. msm_dai_q6_tdm_header_put),
  6103. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_3 Header",
  6104. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6105. msm_dai_q6_tdm_header_get,
  6106. msm_dai_q6_tdm_header_put),
  6107. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_4 Header",
  6108. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6109. msm_dai_q6_tdm_header_get,
  6110. msm_dai_q6_tdm_header_put),
  6111. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_5 Header",
  6112. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6113. msm_dai_q6_tdm_header_get,
  6114. msm_dai_q6_tdm_header_put),
  6115. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_6 Header",
  6116. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6117. msm_dai_q6_tdm_header_get,
  6118. msm_dai_q6_tdm_header_put),
  6119. SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_7 Header",
  6120. SND_SOC_NOPM, 0, 0xFFFFFFFF, 0, 8,
  6121. msm_dai_q6_tdm_header_get,
  6122. msm_dai_q6_tdm_header_put),
  6123. };
  6124. static int msm_dai_q6_tdm_set_clk(
  6125. struct msm_dai_q6_tdm_dai_data *dai_data,
  6126. u16 port_id, bool enable)
  6127. {
  6128. int rc = 0;
  6129. dai_data->clk_set.enable = enable;
  6130. rc = afe_set_lpass_clock_v2(port_id,
  6131. &dai_data->clk_set);
  6132. if (rc < 0)
  6133. pr_err("%s: afe lpass clock failed, err:%d\n",
  6134. __func__, rc);
  6135. return rc;
  6136. }
  6137. static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
  6138. {
  6139. int rc = 0;
  6140. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  6141. dev_get_drvdata(dai->dev);
  6142. struct snd_kcontrol *data_format_kcontrol = NULL;
  6143. struct snd_kcontrol *header_type_kcontrol = NULL;
  6144. struct snd_kcontrol *header_kcontrol = NULL;
  6145. int port_idx = 0;
  6146. const struct snd_kcontrol_new *data_format_ctrl = NULL;
  6147. const struct snd_kcontrol_new *header_type_ctrl = NULL;
  6148. const struct snd_kcontrol_new *header_ctrl = NULL;
  6149. msm_dai_q6_set_dai_id(dai);
  6150. port_idx = msm_dai_q6_get_port_idx(dai->id);
  6151. if (port_idx < 0) {
  6152. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  6153. __func__, dai->id);
  6154. rc = -EINVAL;
  6155. goto rtn;
  6156. }
  6157. data_format_ctrl =
  6158. &tdm_config_controls_data_format[port_idx];
  6159. header_type_ctrl =
  6160. &tdm_config_controls_header_type[port_idx];
  6161. header_ctrl =
  6162. &tdm_config_controls_header[port_idx];
  6163. if (data_format_ctrl) {
  6164. data_format_kcontrol = snd_ctl_new1(data_format_ctrl,
  6165. tdm_dai_data);
  6166. rc = snd_ctl_add(dai->component->card->snd_card,
  6167. data_format_kcontrol);
  6168. if (rc < 0) {
  6169. dev_err(dai->dev, "%s: err add data format ctrl DAI = %s\n",
  6170. __func__, dai->name);
  6171. goto rtn;
  6172. }
  6173. }
  6174. if (header_type_ctrl) {
  6175. header_type_kcontrol = snd_ctl_new1(header_type_ctrl,
  6176. tdm_dai_data);
  6177. rc = snd_ctl_add(dai->component->card->snd_card,
  6178. header_type_kcontrol);
  6179. if (rc < 0) {
  6180. if (data_format_kcontrol)
  6181. snd_ctl_remove(dai->component->card->snd_card,
  6182. data_format_kcontrol);
  6183. dev_err(dai->dev, "%s: err add header type ctrl DAI = %s\n",
  6184. __func__, dai->name);
  6185. goto rtn;
  6186. }
  6187. }
  6188. if (header_ctrl) {
  6189. header_kcontrol = snd_ctl_new1(header_ctrl,
  6190. tdm_dai_data);
  6191. rc = snd_ctl_add(dai->component->card->snd_card,
  6192. header_kcontrol);
  6193. if (rc < 0) {
  6194. if (header_type_kcontrol)
  6195. snd_ctl_remove(dai->component->card->snd_card,
  6196. header_type_kcontrol);
  6197. if (data_format_kcontrol)
  6198. snd_ctl_remove(dai->component->card->snd_card,
  6199. data_format_kcontrol);
  6200. dev_err(dai->dev, "%s: err add header ctrl DAI = %s\n",
  6201. __func__, dai->name);
  6202. goto rtn;
  6203. }
  6204. }
  6205. if (tdm_dai_data->is_island_dai)
  6206. rc = msm_dai_q6_add_island_mx_ctls(
  6207. dai->component->card->snd_card,
  6208. dai->name,
  6209. dai->id, (void *)tdm_dai_data);
  6210. rc = msm_dai_q6_dai_add_route(dai);
  6211. rtn:
  6212. return rc;
  6213. }
  6214. static int msm_dai_q6_dai_tdm_remove(struct snd_soc_dai *dai)
  6215. {
  6216. int rc = 0;
  6217. struct msm_dai_q6_tdm_dai_data *tdm_dai_data =
  6218. dev_get_drvdata(dai->dev);
  6219. u16 group_id = tdm_dai_data->group_cfg.tdm_cfg.group_id;
  6220. int group_idx = 0;
  6221. atomic_t *group_ref = NULL;
  6222. group_idx = msm_dai_q6_get_group_idx(dai->id);
  6223. if (group_idx < 0) {
  6224. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  6225. __func__, dai->id);
  6226. return -EINVAL;
  6227. }
  6228. group_ref = &tdm_group_ref[group_idx];
  6229. /* If AFE port is still up, close it */
  6230. if (test_bit(STATUS_PORT_STARTED, tdm_dai_data->status_mask)) {
  6231. rc = afe_close(dai->id); /* can block */
  6232. if (rc < 0) {
  6233. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  6234. __func__, dai->id);
  6235. }
  6236. atomic_dec(group_ref);
  6237. clear_bit(STATUS_PORT_STARTED,
  6238. tdm_dai_data->status_mask);
  6239. if (atomic_read(group_ref) == 0) {
  6240. rc = afe_port_group_enable(group_id,
  6241. NULL, false);
  6242. if (rc < 0) {
  6243. dev_err(dai->dev, "fail to disable AFE group 0x%x\n",
  6244. group_id);
  6245. }
  6246. rc = msm_dai_q6_tdm_set_clk(tdm_dai_data,
  6247. dai->id, false);
  6248. if (rc < 0) {
  6249. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  6250. __func__, dai->id);
  6251. }
  6252. }
  6253. }
  6254. return 0;
  6255. }
  6256. static int msm_dai_q6_tdm_set_tdm_slot(struct snd_soc_dai *dai,
  6257. unsigned int tx_mask,
  6258. unsigned int rx_mask,
  6259. int slots, int slot_width)
  6260. {
  6261. int rc = 0;
  6262. struct msm_dai_q6_tdm_dai_data *dai_data =
  6263. dev_get_drvdata(dai->dev);
  6264. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  6265. &dai_data->group_cfg.tdm_cfg;
  6266. unsigned int cap_mask;
  6267. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  6268. /* HW only supports 16 and 32 bit slot width configuration */
  6269. if ((slot_width != 16) && (slot_width != 32)) {
  6270. dev_err(dai->dev, "%s: invalid slot_width %d\n",
  6271. __func__, slot_width);
  6272. return -EINVAL;
  6273. }
  6274. /* HW supports 1-32 slots configuration. Typical: 1, 2, 4, 8, 16, 32 */
  6275. switch (slots) {
  6276. case 2:
  6277. cap_mask = 0x03;
  6278. break;
  6279. case 4:
  6280. cap_mask = 0x0F;
  6281. break;
  6282. case 8:
  6283. cap_mask = 0xFF;
  6284. break;
  6285. case 16:
  6286. cap_mask = 0xFFFF;
  6287. break;
  6288. default:
  6289. dev_err(dai->dev, "%s: invalid slots %d\n",
  6290. __func__, slots);
  6291. return -EINVAL;
  6292. }
  6293. switch (dai->id) {
  6294. case AFE_PORT_ID_PRIMARY_TDM_RX:
  6295. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  6296. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  6297. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  6298. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  6299. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  6300. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  6301. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  6302. case AFE_PORT_ID_SECONDARY_TDM_RX:
  6303. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  6304. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  6305. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  6306. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  6307. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  6308. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  6309. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  6310. case AFE_PORT_ID_TERTIARY_TDM_RX:
  6311. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  6312. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  6313. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  6314. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  6315. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  6316. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  6317. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  6318. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  6319. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  6320. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  6321. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  6322. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  6323. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  6324. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  6325. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  6326. case AFE_PORT_ID_QUINARY_TDM_RX:
  6327. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  6328. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  6329. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  6330. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  6331. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  6332. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  6333. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  6334. tdm_group->nslots_per_frame = slots;
  6335. tdm_group->slot_width = slot_width;
  6336. tdm_group->slot_mask = rx_mask & cap_mask;
  6337. break;
  6338. case AFE_PORT_ID_PRIMARY_TDM_TX:
  6339. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  6340. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  6341. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  6342. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  6343. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  6344. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  6345. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  6346. case AFE_PORT_ID_SECONDARY_TDM_TX:
  6347. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  6348. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  6349. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  6350. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  6351. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  6352. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  6353. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  6354. case AFE_PORT_ID_TERTIARY_TDM_TX:
  6355. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  6356. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  6357. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  6358. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  6359. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  6360. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  6361. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  6362. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  6363. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  6364. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  6365. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  6366. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  6367. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  6368. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  6369. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  6370. case AFE_PORT_ID_QUINARY_TDM_TX:
  6371. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  6372. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  6373. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  6374. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  6375. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  6376. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  6377. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  6378. tdm_group->nslots_per_frame = slots;
  6379. tdm_group->slot_width = slot_width;
  6380. tdm_group->slot_mask = tx_mask & cap_mask;
  6381. break;
  6382. default:
  6383. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6384. __func__, dai->id);
  6385. return -EINVAL;
  6386. }
  6387. return rc;
  6388. }
  6389. static int msm_dai_q6_tdm_set_sysclk(struct snd_soc_dai *dai,
  6390. int clk_id, unsigned int freq, int dir)
  6391. {
  6392. struct msm_dai_q6_tdm_dai_data *dai_data =
  6393. dev_get_drvdata(dai->dev);
  6394. if ((dai->id >= AFE_PORT_ID_PRIMARY_TDM_RX) &&
  6395. (dai->id <= AFE_PORT_ID_QUINARY_TDM_TX_7)) {
  6396. dai_data->clk_set.clk_freq_in_hz = freq;
  6397. } else {
  6398. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6399. __func__, dai->id);
  6400. return -EINVAL;
  6401. }
  6402. dev_dbg(dai->dev, "%s: dai id = 0x%x, group clk_freq = %d\n",
  6403. __func__, dai->id, freq);
  6404. return 0;
  6405. }
  6406. static int msm_dai_q6_tdm_set_channel_map(struct snd_soc_dai *dai,
  6407. unsigned int tx_num, unsigned int *tx_slot,
  6408. unsigned int rx_num, unsigned int *rx_slot)
  6409. {
  6410. int rc = 0;
  6411. struct msm_dai_q6_tdm_dai_data *dai_data =
  6412. dev_get_drvdata(dai->dev);
  6413. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  6414. &dai_data->port_cfg.slot_mapping;
  6415. int i = 0;
  6416. dev_dbg(dai->dev, "%s: dai id = 0x%x\n", __func__, dai->id);
  6417. switch (dai->id) {
  6418. case AFE_PORT_ID_PRIMARY_TDM_RX:
  6419. case AFE_PORT_ID_PRIMARY_TDM_RX_1:
  6420. case AFE_PORT_ID_PRIMARY_TDM_RX_2:
  6421. case AFE_PORT_ID_PRIMARY_TDM_RX_3:
  6422. case AFE_PORT_ID_PRIMARY_TDM_RX_4:
  6423. case AFE_PORT_ID_PRIMARY_TDM_RX_5:
  6424. case AFE_PORT_ID_PRIMARY_TDM_RX_6:
  6425. case AFE_PORT_ID_PRIMARY_TDM_RX_7:
  6426. case AFE_PORT_ID_SECONDARY_TDM_RX:
  6427. case AFE_PORT_ID_SECONDARY_TDM_RX_1:
  6428. case AFE_PORT_ID_SECONDARY_TDM_RX_2:
  6429. case AFE_PORT_ID_SECONDARY_TDM_RX_3:
  6430. case AFE_PORT_ID_SECONDARY_TDM_RX_4:
  6431. case AFE_PORT_ID_SECONDARY_TDM_RX_5:
  6432. case AFE_PORT_ID_SECONDARY_TDM_RX_6:
  6433. case AFE_PORT_ID_SECONDARY_TDM_RX_7:
  6434. case AFE_PORT_ID_TERTIARY_TDM_RX:
  6435. case AFE_PORT_ID_TERTIARY_TDM_RX_1:
  6436. case AFE_PORT_ID_TERTIARY_TDM_RX_2:
  6437. case AFE_PORT_ID_TERTIARY_TDM_RX_3:
  6438. case AFE_PORT_ID_TERTIARY_TDM_RX_4:
  6439. case AFE_PORT_ID_TERTIARY_TDM_RX_5:
  6440. case AFE_PORT_ID_TERTIARY_TDM_RX_6:
  6441. case AFE_PORT_ID_TERTIARY_TDM_RX_7:
  6442. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  6443. case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
  6444. case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
  6445. case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
  6446. case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
  6447. case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
  6448. case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
  6449. case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
  6450. case AFE_PORT_ID_QUINARY_TDM_RX:
  6451. case AFE_PORT_ID_QUINARY_TDM_RX_1:
  6452. case AFE_PORT_ID_QUINARY_TDM_RX_2:
  6453. case AFE_PORT_ID_QUINARY_TDM_RX_3:
  6454. case AFE_PORT_ID_QUINARY_TDM_RX_4:
  6455. case AFE_PORT_ID_QUINARY_TDM_RX_5:
  6456. case AFE_PORT_ID_QUINARY_TDM_RX_6:
  6457. case AFE_PORT_ID_QUINARY_TDM_RX_7:
  6458. if (!rx_slot) {
  6459. dev_err(dai->dev, "%s: rx slot not found\n", __func__);
  6460. return -EINVAL;
  6461. }
  6462. if (rx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  6463. dev_err(dai->dev, "%s: invalid rx num %d\n", __func__,
  6464. rx_num);
  6465. return -EINVAL;
  6466. }
  6467. for (i = 0; i < rx_num; i++)
  6468. slot_mapping->offset[i] = rx_slot[i];
  6469. for (i = rx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  6470. slot_mapping->offset[i] =
  6471. AFE_SLOT_MAPPING_OFFSET_INVALID;
  6472. slot_mapping->num_channel = rx_num;
  6473. break;
  6474. case AFE_PORT_ID_PRIMARY_TDM_TX:
  6475. case AFE_PORT_ID_PRIMARY_TDM_TX_1:
  6476. case AFE_PORT_ID_PRIMARY_TDM_TX_2:
  6477. case AFE_PORT_ID_PRIMARY_TDM_TX_3:
  6478. case AFE_PORT_ID_PRIMARY_TDM_TX_4:
  6479. case AFE_PORT_ID_PRIMARY_TDM_TX_5:
  6480. case AFE_PORT_ID_PRIMARY_TDM_TX_6:
  6481. case AFE_PORT_ID_PRIMARY_TDM_TX_7:
  6482. case AFE_PORT_ID_SECONDARY_TDM_TX:
  6483. case AFE_PORT_ID_SECONDARY_TDM_TX_1:
  6484. case AFE_PORT_ID_SECONDARY_TDM_TX_2:
  6485. case AFE_PORT_ID_SECONDARY_TDM_TX_3:
  6486. case AFE_PORT_ID_SECONDARY_TDM_TX_4:
  6487. case AFE_PORT_ID_SECONDARY_TDM_TX_5:
  6488. case AFE_PORT_ID_SECONDARY_TDM_TX_6:
  6489. case AFE_PORT_ID_SECONDARY_TDM_TX_7:
  6490. case AFE_PORT_ID_TERTIARY_TDM_TX:
  6491. case AFE_PORT_ID_TERTIARY_TDM_TX_1:
  6492. case AFE_PORT_ID_TERTIARY_TDM_TX_2:
  6493. case AFE_PORT_ID_TERTIARY_TDM_TX_3:
  6494. case AFE_PORT_ID_TERTIARY_TDM_TX_4:
  6495. case AFE_PORT_ID_TERTIARY_TDM_TX_5:
  6496. case AFE_PORT_ID_TERTIARY_TDM_TX_6:
  6497. case AFE_PORT_ID_TERTIARY_TDM_TX_7:
  6498. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  6499. case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
  6500. case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
  6501. case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
  6502. case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
  6503. case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
  6504. case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
  6505. case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
  6506. case AFE_PORT_ID_QUINARY_TDM_TX:
  6507. case AFE_PORT_ID_QUINARY_TDM_TX_1:
  6508. case AFE_PORT_ID_QUINARY_TDM_TX_2:
  6509. case AFE_PORT_ID_QUINARY_TDM_TX_3:
  6510. case AFE_PORT_ID_QUINARY_TDM_TX_4:
  6511. case AFE_PORT_ID_QUINARY_TDM_TX_5:
  6512. case AFE_PORT_ID_QUINARY_TDM_TX_6:
  6513. case AFE_PORT_ID_QUINARY_TDM_TX_7:
  6514. if (!tx_slot) {
  6515. dev_err(dai->dev, "%s: tx slot not found\n", __func__);
  6516. return -EINVAL;
  6517. }
  6518. if (tx_num > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  6519. dev_err(dai->dev, "%s: invalid tx num %d\n", __func__,
  6520. tx_num);
  6521. return -EINVAL;
  6522. }
  6523. for (i = 0; i < tx_num; i++)
  6524. slot_mapping->offset[i] = tx_slot[i];
  6525. for (i = tx_num; i < AFE_PORT_MAX_AUDIO_CHAN_CNT; i++)
  6526. slot_mapping->offset[i] =
  6527. AFE_SLOT_MAPPING_OFFSET_INVALID;
  6528. slot_mapping->num_channel = tx_num;
  6529. break;
  6530. default:
  6531. dev_err(dai->dev, "%s: invalid dai id 0x%x\n",
  6532. __func__, dai->id);
  6533. return -EINVAL;
  6534. }
  6535. return rc;
  6536. }
  6537. static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream,
  6538. struct snd_pcm_hw_params *params,
  6539. struct snd_soc_dai *dai)
  6540. {
  6541. struct msm_dai_q6_tdm_dai_data *dai_data =
  6542. dev_get_drvdata(dai->dev);
  6543. struct afe_param_id_group_device_tdm_cfg *tdm_group =
  6544. &dai_data->group_cfg.tdm_cfg;
  6545. struct afe_param_id_tdm_cfg *tdm =
  6546. &dai_data->port_cfg.tdm;
  6547. struct afe_param_id_slot_mapping_cfg *slot_mapping =
  6548. &dai_data->port_cfg.slot_mapping;
  6549. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header =
  6550. &dai_data->port_cfg.custom_tdm_header;
  6551. pr_debug("%s: dev_name: %s\n",
  6552. __func__, dev_name(dai->dev));
  6553. if ((params_channels(params) == 0) ||
  6554. (params_channels(params) > 8)) {
  6555. dev_err(dai->dev, "%s: invalid param channels %d\n",
  6556. __func__, params_channels(params));
  6557. return -EINVAL;
  6558. }
  6559. switch (params_format(params)) {
  6560. case SNDRV_PCM_FORMAT_S16_LE:
  6561. dai_data->bitwidth = 16;
  6562. break;
  6563. case SNDRV_PCM_FORMAT_S24_LE:
  6564. case SNDRV_PCM_FORMAT_S24_3LE:
  6565. dai_data->bitwidth = 24;
  6566. break;
  6567. case SNDRV_PCM_FORMAT_S32_LE:
  6568. dai_data->bitwidth = 32;
  6569. break;
  6570. default:
  6571. dev_err(dai->dev, "%s: invalid param format 0x%x\n",
  6572. __func__, params_format(params));
  6573. return -EINVAL;
  6574. }
  6575. dai_data->channels = params_channels(params);
  6576. dai_data->rate = params_rate(params);
  6577. /*
  6578. * update tdm group config param
  6579. * NOTE: group config is set to the same as slot config.
  6580. */
  6581. tdm_group->bit_width = tdm_group->slot_width;
  6582. tdm_group->num_channels = tdm_group->nslots_per_frame;
  6583. tdm_group->sample_rate = dai_data->rate;
  6584. pr_debug("%s: TDM GROUP:\n"
  6585. "num_channels=%d sample_rate=%d bit_width=%d\n"
  6586. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n",
  6587. __func__,
  6588. tdm_group->num_channels,
  6589. tdm_group->sample_rate,
  6590. tdm_group->bit_width,
  6591. tdm_group->nslots_per_frame,
  6592. tdm_group->slot_width,
  6593. tdm_group->slot_mask);
  6594. pr_debug("%s: TDM GROUP:\n"
  6595. "port_id[0]=0x%x port_id[1]=0x%x port_id[2]=0x%x port_id[3]=0x%x\n"
  6596. "port_id[4]=0x%x port_id[5]=0x%x port_id[6]=0x%x port_id[7]=0x%x\n",
  6597. __func__,
  6598. tdm_group->port_id[0],
  6599. tdm_group->port_id[1],
  6600. tdm_group->port_id[2],
  6601. tdm_group->port_id[3],
  6602. tdm_group->port_id[4],
  6603. tdm_group->port_id[5],
  6604. tdm_group->port_id[6],
  6605. tdm_group->port_id[7]);
  6606. /*
  6607. * update tdm config param
  6608. * NOTE: channels/rate/bitwidth are per stream property
  6609. */
  6610. tdm->num_channels = dai_data->channels;
  6611. tdm->sample_rate = dai_data->rate;
  6612. tdm->bit_width = dai_data->bitwidth;
  6613. /*
  6614. * port slot config is the same as group slot config
  6615. * port slot mask should be set according to offset
  6616. */
  6617. tdm->nslots_per_frame = tdm_group->nslots_per_frame;
  6618. tdm->slot_width = tdm_group->slot_width;
  6619. tdm->slot_mask = tdm_group->slot_mask;
  6620. pr_debug("%s: TDM:\n"
  6621. "num_channels=%d sample_rate=%d bit_width=%d\n"
  6622. "nslots_per_frame=%d slot_width=%d slot_mask=0x%x\n"
  6623. "data_format=0x%x sync_mode=0x%x sync_src=0x%x\n"
  6624. "data_out=0x%x invert_sync=0x%x data_delay=0x%x\n",
  6625. __func__,
  6626. tdm->num_channels,
  6627. tdm->sample_rate,
  6628. tdm->bit_width,
  6629. tdm->nslots_per_frame,
  6630. tdm->slot_width,
  6631. tdm->slot_mask,
  6632. tdm->data_format,
  6633. tdm->sync_mode,
  6634. tdm->sync_src,
  6635. tdm->ctrl_data_out_enable,
  6636. tdm->ctrl_invert_sync_pulse,
  6637. tdm->ctrl_sync_data_delay);
  6638. /*
  6639. * update slot mapping config param
  6640. * NOTE: channels/rate/bitwidth are per stream property
  6641. */
  6642. slot_mapping->bitwidth = dai_data->bitwidth;
  6643. pr_debug("%s: SLOT MAPPING:\n"
  6644. "num_channel=%d bitwidth=%d data_align=0x%x\n",
  6645. __func__,
  6646. slot_mapping->num_channel,
  6647. slot_mapping->bitwidth,
  6648. slot_mapping->data_align_type);
  6649. pr_debug("%s: SLOT MAPPING:\n"
  6650. "offset[0]=0x%x offset[1]=0x%x offset[2]=0x%x offset[3]=0x%x\n"
  6651. "offset[4]=0x%x offset[5]=0x%x offset[6]=0x%x offset[7]=0x%x\n",
  6652. __func__,
  6653. slot_mapping->offset[0],
  6654. slot_mapping->offset[1],
  6655. slot_mapping->offset[2],
  6656. slot_mapping->offset[3],
  6657. slot_mapping->offset[4],
  6658. slot_mapping->offset[5],
  6659. slot_mapping->offset[6],
  6660. slot_mapping->offset[7]);
  6661. /*
  6662. * update custom header config param
  6663. * NOTE: channels/rate/bitwidth are per playback stream property.
  6664. * custom tdm header only applicable to playback stream.
  6665. */
  6666. if (custom_tdm_header->header_type !=
  6667. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID) {
  6668. pr_debug("%s: CUSTOM TDM HEADER:\n"
  6669. "start_offset=0x%x header_width=%d\n"
  6670. "num_frame_repeat=%d header_type=0x%x\n",
  6671. __func__,
  6672. custom_tdm_header->start_offset,
  6673. custom_tdm_header->header_width,
  6674. custom_tdm_header->num_frame_repeat,
  6675. custom_tdm_header->header_type);
  6676. pr_debug("%s: CUSTOM TDM HEADER:\n"
  6677. "header[0]=0x%x header[1]=0x%x header[2]=0x%x header[3]=0x%x\n"
  6678. "header[4]=0x%x header[5]=0x%x header[6]=0x%x header[7]=0x%x\n",
  6679. __func__,
  6680. custom_tdm_header->header[0],
  6681. custom_tdm_header->header[1],
  6682. custom_tdm_header->header[2],
  6683. custom_tdm_header->header[3],
  6684. custom_tdm_header->header[4],
  6685. custom_tdm_header->header[5],
  6686. custom_tdm_header->header[6],
  6687. custom_tdm_header->header[7]);
  6688. }
  6689. return 0;
  6690. }
  6691. static int msm_dai_q6_tdm_prepare(struct snd_pcm_substream *substream,
  6692. struct snd_soc_dai *dai)
  6693. {
  6694. int rc = 0;
  6695. struct msm_dai_q6_tdm_dai_data *dai_data =
  6696. dev_get_drvdata(dai->dev);
  6697. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  6698. int group_idx = 0;
  6699. atomic_t *group_ref = NULL;
  6700. dev_dbg(dai->dev, "%s: dev_name: %s dev_id: 0x%x group_id: 0x%x\n",
  6701. __func__, dev_name(dai->dev), dai->dev->id, group_id);
  6702. if (dai_data->port_cfg.custom_tdm_header.minor_version == 0)
  6703. dev_dbg(dai->dev,
  6704. "%s: Custom tdm header not supported\n", __func__);
  6705. group_idx = msm_dai_q6_get_group_idx(dai->id);
  6706. if (group_idx < 0) {
  6707. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  6708. __func__, dai->id);
  6709. return -EINVAL;
  6710. }
  6711. mutex_lock(&tdm_mutex);
  6712. group_ref = &tdm_group_ref[group_idx];
  6713. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6714. if (q6core_get_avcs_api_version_per_service(
  6715. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V4) {
  6716. /*
  6717. * send island mode config.
  6718. * This should be the first configuration
  6719. */
  6720. rc = afe_send_port_island_mode(dai->id);
  6721. if (rc)
  6722. dev_err(dai->dev, "%s: afe send island mode failed %d\n",
  6723. __func__, rc);
  6724. }
  6725. /* PORT START should be set if prepare called
  6726. * in active state.
  6727. */
  6728. if (atomic_read(group_ref) == 0) {
  6729. /* TX and RX share the same clk.
  6730. * AFE clk is enabled per group to simplify the logic.
  6731. * DSP will monitor the clk count.
  6732. */
  6733. rc = msm_dai_q6_tdm_set_clk(dai_data,
  6734. dai->id, true);
  6735. if (rc < 0) {
  6736. dev_err(dai->dev, "%s: fail to enable AFE clk 0x%x\n",
  6737. __func__, dai->id);
  6738. goto rtn;
  6739. }
  6740. /*
  6741. * if only one port, don't do group enable as there
  6742. * is no group need for only one port
  6743. */
  6744. if (dai_data->num_group_ports > 1) {
  6745. rc = afe_port_group_enable(group_id,
  6746. &dai_data->group_cfg, true);
  6747. if (rc < 0) {
  6748. dev_err(dai->dev,
  6749. "%s: fail to enable AFE group 0x%x\n",
  6750. __func__, group_id);
  6751. goto rtn;
  6752. }
  6753. }
  6754. }
  6755. rc = afe_tdm_port_start(dai->id, &dai_data->port_cfg,
  6756. dai_data->rate, dai_data->num_group_ports);
  6757. if (rc < 0) {
  6758. if (atomic_read(group_ref) == 0) {
  6759. afe_port_group_enable(group_id,
  6760. NULL, false);
  6761. msm_dai_q6_tdm_set_clk(dai_data,
  6762. dai->id, false);
  6763. }
  6764. dev_err(dai->dev, "%s: fail to open AFE port 0x%x\n",
  6765. __func__, dai->id);
  6766. } else {
  6767. set_bit(STATUS_PORT_STARTED,
  6768. dai_data->status_mask);
  6769. atomic_inc(group_ref);
  6770. }
  6771. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  6772. /* NOTE: AFE should error out if HW resource contention */
  6773. }
  6774. rtn:
  6775. mutex_unlock(&tdm_mutex);
  6776. return rc;
  6777. }
  6778. static void msm_dai_q6_tdm_shutdown(struct snd_pcm_substream *substream,
  6779. struct snd_soc_dai *dai)
  6780. {
  6781. int rc = 0;
  6782. struct msm_dai_q6_tdm_dai_data *dai_data =
  6783. dev_get_drvdata(dai->dev);
  6784. u16 group_id = dai_data->group_cfg.tdm_cfg.group_id;
  6785. int group_idx = 0;
  6786. atomic_t *group_ref = NULL;
  6787. group_idx = msm_dai_q6_get_group_idx(dai->id);
  6788. if (group_idx < 0) {
  6789. dev_err(dai->dev, "%s port id 0x%x not supported\n",
  6790. __func__, dai->id);
  6791. return;
  6792. }
  6793. mutex_lock(&tdm_mutex);
  6794. group_ref = &tdm_group_ref[group_idx];
  6795. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  6796. rc = afe_close(dai->id);
  6797. if (rc < 0) {
  6798. dev_err(dai->dev, "%s: fail to close AFE port 0x%x\n",
  6799. __func__, dai->id);
  6800. }
  6801. atomic_dec(group_ref);
  6802. clear_bit(STATUS_PORT_STARTED,
  6803. dai_data->status_mask);
  6804. if (atomic_read(group_ref) == 0) {
  6805. rc = afe_port_group_enable(group_id,
  6806. NULL, false);
  6807. if (rc < 0) {
  6808. dev_err(dai->dev, "%s: fail to disable AFE group 0x%x\n",
  6809. __func__, group_id);
  6810. }
  6811. rc = msm_dai_q6_tdm_set_clk(dai_data,
  6812. dai->id, false);
  6813. if (rc < 0) {
  6814. dev_err(dai->dev, "%s: fail to disable AFE clk 0x%x\n",
  6815. __func__, dai->id);
  6816. }
  6817. }
  6818. /* TODO: need to monitor PCM/MI2S/TDM HW status */
  6819. /* NOTE: AFE should error out if HW resource contention */
  6820. }
  6821. mutex_unlock(&tdm_mutex);
  6822. }
  6823. static struct snd_soc_dai_ops msm_dai_q6_tdm_ops = {
  6824. .prepare = msm_dai_q6_tdm_prepare,
  6825. .hw_params = msm_dai_q6_tdm_hw_params,
  6826. .set_tdm_slot = msm_dai_q6_tdm_set_tdm_slot,
  6827. .set_channel_map = msm_dai_q6_tdm_set_channel_map,
  6828. .set_sysclk = msm_dai_q6_tdm_set_sysclk,
  6829. .shutdown = msm_dai_q6_tdm_shutdown,
  6830. };
  6831. static struct snd_soc_dai_driver msm_dai_q6_tdm_dai[] = {
  6832. {
  6833. .playback = {
  6834. .stream_name = "Primary TDM0 Playback",
  6835. .aif_name = "PRI_TDM_RX_0",
  6836. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6837. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6838. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6839. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6840. SNDRV_PCM_FMTBIT_S24_LE |
  6841. SNDRV_PCM_FMTBIT_S32_LE,
  6842. .channels_min = 1,
  6843. .channels_max = 8,
  6844. .rate_min = 8000,
  6845. .rate_max = 352800,
  6846. },
  6847. .ops = &msm_dai_q6_tdm_ops,
  6848. .id = AFE_PORT_ID_PRIMARY_TDM_RX,
  6849. .probe = msm_dai_q6_dai_tdm_probe,
  6850. .remove = msm_dai_q6_dai_tdm_remove,
  6851. },
  6852. {
  6853. .playback = {
  6854. .stream_name = "Primary TDM1 Playback",
  6855. .aif_name = "PRI_TDM_RX_1",
  6856. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6857. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6858. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6859. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6860. SNDRV_PCM_FMTBIT_S24_LE |
  6861. SNDRV_PCM_FMTBIT_S32_LE,
  6862. .channels_min = 1,
  6863. .channels_max = 8,
  6864. .rate_min = 8000,
  6865. .rate_max = 352800,
  6866. },
  6867. .ops = &msm_dai_q6_tdm_ops,
  6868. .id = AFE_PORT_ID_PRIMARY_TDM_RX_1,
  6869. .probe = msm_dai_q6_dai_tdm_probe,
  6870. .remove = msm_dai_q6_dai_tdm_remove,
  6871. },
  6872. {
  6873. .playback = {
  6874. .stream_name = "Primary TDM2 Playback",
  6875. .aif_name = "PRI_TDM_RX_2",
  6876. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6877. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6878. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6879. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6880. SNDRV_PCM_FMTBIT_S24_LE |
  6881. SNDRV_PCM_FMTBIT_S32_LE,
  6882. .channels_min = 1,
  6883. .channels_max = 8,
  6884. .rate_min = 8000,
  6885. .rate_max = 352800,
  6886. },
  6887. .ops = &msm_dai_q6_tdm_ops,
  6888. .id = AFE_PORT_ID_PRIMARY_TDM_RX_2,
  6889. .probe = msm_dai_q6_dai_tdm_probe,
  6890. .remove = msm_dai_q6_dai_tdm_remove,
  6891. },
  6892. {
  6893. .playback = {
  6894. .stream_name = "Primary TDM3 Playback",
  6895. .aif_name = "PRI_TDM_RX_3",
  6896. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6897. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6898. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6899. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6900. SNDRV_PCM_FMTBIT_S24_LE |
  6901. SNDRV_PCM_FMTBIT_S32_LE,
  6902. .channels_min = 1,
  6903. .channels_max = 8,
  6904. .rate_min = 8000,
  6905. .rate_max = 352800,
  6906. },
  6907. .ops = &msm_dai_q6_tdm_ops,
  6908. .id = AFE_PORT_ID_PRIMARY_TDM_RX_3,
  6909. .probe = msm_dai_q6_dai_tdm_probe,
  6910. .remove = msm_dai_q6_dai_tdm_remove,
  6911. },
  6912. {
  6913. .playback = {
  6914. .stream_name = "Primary TDM4 Playback",
  6915. .aif_name = "PRI_TDM_RX_4",
  6916. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6917. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6918. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6919. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6920. SNDRV_PCM_FMTBIT_S24_LE |
  6921. SNDRV_PCM_FMTBIT_S32_LE,
  6922. .channels_min = 1,
  6923. .channels_max = 8,
  6924. .rate_min = 8000,
  6925. .rate_max = 352800,
  6926. },
  6927. .ops = &msm_dai_q6_tdm_ops,
  6928. .id = AFE_PORT_ID_PRIMARY_TDM_RX_4,
  6929. .probe = msm_dai_q6_dai_tdm_probe,
  6930. .remove = msm_dai_q6_dai_tdm_remove,
  6931. },
  6932. {
  6933. .playback = {
  6934. .stream_name = "Primary TDM5 Playback",
  6935. .aif_name = "PRI_TDM_RX_5",
  6936. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6937. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6938. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6939. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6940. SNDRV_PCM_FMTBIT_S24_LE |
  6941. SNDRV_PCM_FMTBIT_S32_LE,
  6942. .channels_min = 1,
  6943. .channels_max = 8,
  6944. .rate_min = 8000,
  6945. .rate_max = 352800,
  6946. },
  6947. .ops = &msm_dai_q6_tdm_ops,
  6948. .id = AFE_PORT_ID_PRIMARY_TDM_RX_5,
  6949. .probe = msm_dai_q6_dai_tdm_probe,
  6950. .remove = msm_dai_q6_dai_tdm_remove,
  6951. },
  6952. {
  6953. .playback = {
  6954. .stream_name = "Primary TDM6 Playback",
  6955. .aif_name = "PRI_TDM_RX_6",
  6956. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6957. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6958. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6959. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6960. SNDRV_PCM_FMTBIT_S24_LE |
  6961. SNDRV_PCM_FMTBIT_S32_LE,
  6962. .channels_min = 1,
  6963. .channels_max = 8,
  6964. .rate_min = 8000,
  6965. .rate_max = 352800,
  6966. },
  6967. .ops = &msm_dai_q6_tdm_ops,
  6968. .id = AFE_PORT_ID_PRIMARY_TDM_RX_6,
  6969. .probe = msm_dai_q6_dai_tdm_probe,
  6970. .remove = msm_dai_q6_dai_tdm_remove,
  6971. },
  6972. {
  6973. .playback = {
  6974. .stream_name = "Primary TDM7 Playback",
  6975. .aif_name = "PRI_TDM_RX_7",
  6976. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6977. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6978. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6979. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  6980. SNDRV_PCM_FMTBIT_S24_LE |
  6981. SNDRV_PCM_FMTBIT_S32_LE,
  6982. .channels_min = 1,
  6983. .channels_max = 8,
  6984. .rate_min = 8000,
  6985. .rate_max = 352800,
  6986. },
  6987. .ops = &msm_dai_q6_tdm_ops,
  6988. .id = AFE_PORT_ID_PRIMARY_TDM_RX_7,
  6989. .probe = msm_dai_q6_dai_tdm_probe,
  6990. .remove = msm_dai_q6_dai_tdm_remove,
  6991. },
  6992. {
  6993. .capture = {
  6994. .stream_name = "Primary TDM0 Capture",
  6995. .aif_name = "PRI_TDM_TX_0",
  6996. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  6997. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  6998. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  6999. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7000. SNDRV_PCM_FMTBIT_S24_LE |
  7001. SNDRV_PCM_FMTBIT_S32_LE,
  7002. .channels_min = 1,
  7003. .channels_max = 8,
  7004. .rate_min = 8000,
  7005. .rate_max = 352800,
  7006. },
  7007. .ops = &msm_dai_q6_tdm_ops,
  7008. .id = AFE_PORT_ID_PRIMARY_TDM_TX,
  7009. .probe = msm_dai_q6_dai_tdm_probe,
  7010. .remove = msm_dai_q6_dai_tdm_remove,
  7011. },
  7012. {
  7013. .capture = {
  7014. .stream_name = "Primary TDM1 Capture",
  7015. .aif_name = "PRI_TDM_TX_1",
  7016. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7017. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7018. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7019. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7020. SNDRV_PCM_FMTBIT_S24_LE |
  7021. SNDRV_PCM_FMTBIT_S32_LE,
  7022. .channels_min = 1,
  7023. .channels_max = 8,
  7024. .rate_min = 8000,
  7025. .rate_max = 352800,
  7026. },
  7027. .ops = &msm_dai_q6_tdm_ops,
  7028. .id = AFE_PORT_ID_PRIMARY_TDM_TX_1,
  7029. .probe = msm_dai_q6_dai_tdm_probe,
  7030. .remove = msm_dai_q6_dai_tdm_remove,
  7031. },
  7032. {
  7033. .capture = {
  7034. .stream_name = "Primary TDM2 Capture",
  7035. .aif_name = "PRI_TDM_TX_2",
  7036. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7037. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7038. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7039. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7040. SNDRV_PCM_FMTBIT_S24_LE |
  7041. SNDRV_PCM_FMTBIT_S32_LE,
  7042. .channels_min = 1,
  7043. .channels_max = 8,
  7044. .rate_min = 8000,
  7045. .rate_max = 352800,
  7046. },
  7047. .ops = &msm_dai_q6_tdm_ops,
  7048. .id = AFE_PORT_ID_PRIMARY_TDM_TX_2,
  7049. .probe = msm_dai_q6_dai_tdm_probe,
  7050. .remove = msm_dai_q6_dai_tdm_remove,
  7051. },
  7052. {
  7053. .capture = {
  7054. .stream_name = "Primary TDM3 Capture",
  7055. .aif_name = "PRI_TDM_TX_3",
  7056. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7057. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7058. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7059. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7060. SNDRV_PCM_FMTBIT_S24_LE |
  7061. SNDRV_PCM_FMTBIT_S32_LE,
  7062. .channels_min = 1,
  7063. .channels_max = 8,
  7064. .rate_min = 8000,
  7065. .rate_max = 352800,
  7066. },
  7067. .ops = &msm_dai_q6_tdm_ops,
  7068. .id = AFE_PORT_ID_PRIMARY_TDM_TX_3,
  7069. .probe = msm_dai_q6_dai_tdm_probe,
  7070. .remove = msm_dai_q6_dai_tdm_remove,
  7071. },
  7072. {
  7073. .capture = {
  7074. .stream_name = "Primary TDM4 Capture",
  7075. .aif_name = "PRI_TDM_TX_4",
  7076. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7077. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7078. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7079. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7080. SNDRV_PCM_FMTBIT_S24_LE |
  7081. SNDRV_PCM_FMTBIT_S32_LE,
  7082. .channels_min = 1,
  7083. .channels_max = 8,
  7084. .rate_min = 8000,
  7085. .rate_max = 352800,
  7086. },
  7087. .ops = &msm_dai_q6_tdm_ops,
  7088. .id = AFE_PORT_ID_PRIMARY_TDM_TX_4,
  7089. .probe = msm_dai_q6_dai_tdm_probe,
  7090. .remove = msm_dai_q6_dai_tdm_remove,
  7091. },
  7092. {
  7093. .capture = {
  7094. .stream_name = "Primary TDM5 Capture",
  7095. .aif_name = "PRI_TDM_TX_5",
  7096. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7097. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7098. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7099. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7100. SNDRV_PCM_FMTBIT_S24_LE |
  7101. SNDRV_PCM_FMTBIT_S32_LE,
  7102. .channels_min = 1,
  7103. .channels_max = 8,
  7104. .rate_min = 8000,
  7105. .rate_max = 352800,
  7106. },
  7107. .ops = &msm_dai_q6_tdm_ops,
  7108. .id = AFE_PORT_ID_PRIMARY_TDM_TX_5,
  7109. .probe = msm_dai_q6_dai_tdm_probe,
  7110. .remove = msm_dai_q6_dai_tdm_remove,
  7111. },
  7112. {
  7113. .capture = {
  7114. .stream_name = "Primary TDM6 Capture",
  7115. .aif_name = "PRI_TDM_TX_6",
  7116. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7117. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7118. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7119. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7120. SNDRV_PCM_FMTBIT_S24_LE |
  7121. SNDRV_PCM_FMTBIT_S32_LE,
  7122. .channels_min = 1,
  7123. .channels_max = 8,
  7124. .rate_min = 8000,
  7125. .rate_max = 352800,
  7126. },
  7127. .ops = &msm_dai_q6_tdm_ops,
  7128. .id = AFE_PORT_ID_PRIMARY_TDM_TX_6,
  7129. .probe = msm_dai_q6_dai_tdm_probe,
  7130. .remove = msm_dai_q6_dai_tdm_remove,
  7131. },
  7132. {
  7133. .capture = {
  7134. .stream_name = "Primary TDM7 Capture",
  7135. .aif_name = "PRI_TDM_TX_7",
  7136. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7137. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7138. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7139. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7140. SNDRV_PCM_FMTBIT_S24_LE |
  7141. SNDRV_PCM_FMTBIT_S32_LE,
  7142. .channels_min = 1,
  7143. .channels_max = 8,
  7144. .rate_min = 8000,
  7145. .rate_max = 352800,
  7146. },
  7147. .ops = &msm_dai_q6_tdm_ops,
  7148. .id = AFE_PORT_ID_PRIMARY_TDM_TX_7,
  7149. .probe = msm_dai_q6_dai_tdm_probe,
  7150. .remove = msm_dai_q6_dai_tdm_remove,
  7151. },
  7152. {
  7153. .playback = {
  7154. .stream_name = "Secondary TDM0 Playback",
  7155. .aif_name = "SEC_TDM_RX_0",
  7156. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7157. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7158. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7159. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7160. SNDRV_PCM_FMTBIT_S24_LE |
  7161. SNDRV_PCM_FMTBIT_S32_LE,
  7162. .channels_min = 1,
  7163. .channels_max = 8,
  7164. .rate_min = 8000,
  7165. .rate_max = 352800,
  7166. },
  7167. .ops = &msm_dai_q6_tdm_ops,
  7168. .id = AFE_PORT_ID_SECONDARY_TDM_RX,
  7169. .probe = msm_dai_q6_dai_tdm_probe,
  7170. .remove = msm_dai_q6_dai_tdm_remove,
  7171. },
  7172. {
  7173. .playback = {
  7174. .stream_name = "Secondary TDM1 Playback",
  7175. .aif_name = "SEC_TDM_RX_1",
  7176. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7177. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7178. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7179. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7180. SNDRV_PCM_FMTBIT_S24_LE |
  7181. SNDRV_PCM_FMTBIT_S32_LE,
  7182. .channels_min = 1,
  7183. .channels_max = 8,
  7184. .rate_min = 8000,
  7185. .rate_max = 352800,
  7186. },
  7187. .ops = &msm_dai_q6_tdm_ops,
  7188. .id = AFE_PORT_ID_SECONDARY_TDM_RX_1,
  7189. .probe = msm_dai_q6_dai_tdm_probe,
  7190. .remove = msm_dai_q6_dai_tdm_remove,
  7191. },
  7192. {
  7193. .playback = {
  7194. .stream_name = "Secondary TDM2 Playback",
  7195. .aif_name = "SEC_TDM_RX_2",
  7196. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7197. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7198. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7199. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7200. SNDRV_PCM_FMTBIT_S24_LE |
  7201. SNDRV_PCM_FMTBIT_S32_LE,
  7202. .channels_min = 1,
  7203. .channels_max = 8,
  7204. .rate_min = 8000,
  7205. .rate_max = 352800,
  7206. },
  7207. .ops = &msm_dai_q6_tdm_ops,
  7208. .id = AFE_PORT_ID_SECONDARY_TDM_RX_2,
  7209. .probe = msm_dai_q6_dai_tdm_probe,
  7210. .remove = msm_dai_q6_dai_tdm_remove,
  7211. },
  7212. {
  7213. .playback = {
  7214. .stream_name = "Secondary TDM3 Playback",
  7215. .aif_name = "SEC_TDM_RX_3",
  7216. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7217. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7218. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7219. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7220. SNDRV_PCM_FMTBIT_S24_LE |
  7221. SNDRV_PCM_FMTBIT_S32_LE,
  7222. .channels_min = 1,
  7223. .channels_max = 8,
  7224. .rate_min = 8000,
  7225. .rate_max = 352800,
  7226. },
  7227. .ops = &msm_dai_q6_tdm_ops,
  7228. .id = AFE_PORT_ID_SECONDARY_TDM_RX_3,
  7229. .probe = msm_dai_q6_dai_tdm_probe,
  7230. .remove = msm_dai_q6_dai_tdm_remove,
  7231. },
  7232. {
  7233. .playback = {
  7234. .stream_name = "Secondary TDM4 Playback",
  7235. .aif_name = "SEC_TDM_RX_4",
  7236. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7237. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7238. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7239. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7240. SNDRV_PCM_FMTBIT_S24_LE |
  7241. SNDRV_PCM_FMTBIT_S32_LE,
  7242. .channels_min = 1,
  7243. .channels_max = 8,
  7244. .rate_min = 8000,
  7245. .rate_max = 352800,
  7246. },
  7247. .ops = &msm_dai_q6_tdm_ops,
  7248. .id = AFE_PORT_ID_SECONDARY_TDM_RX_4,
  7249. .probe = msm_dai_q6_dai_tdm_probe,
  7250. .remove = msm_dai_q6_dai_tdm_remove,
  7251. },
  7252. {
  7253. .playback = {
  7254. .stream_name = "Secondary TDM5 Playback",
  7255. .aif_name = "SEC_TDM_RX_5",
  7256. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7257. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7258. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7259. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7260. SNDRV_PCM_FMTBIT_S24_LE |
  7261. SNDRV_PCM_FMTBIT_S32_LE,
  7262. .channels_min = 1,
  7263. .channels_max = 8,
  7264. .rate_min = 8000,
  7265. .rate_max = 352800,
  7266. },
  7267. .ops = &msm_dai_q6_tdm_ops,
  7268. .id = AFE_PORT_ID_SECONDARY_TDM_RX_5,
  7269. .probe = msm_dai_q6_dai_tdm_probe,
  7270. .remove = msm_dai_q6_dai_tdm_remove,
  7271. },
  7272. {
  7273. .playback = {
  7274. .stream_name = "Secondary TDM6 Playback",
  7275. .aif_name = "SEC_TDM_RX_6",
  7276. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7277. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7278. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7279. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7280. SNDRV_PCM_FMTBIT_S24_LE |
  7281. SNDRV_PCM_FMTBIT_S32_LE,
  7282. .channels_min = 1,
  7283. .channels_max = 8,
  7284. .rate_min = 8000,
  7285. .rate_max = 352800,
  7286. },
  7287. .ops = &msm_dai_q6_tdm_ops,
  7288. .id = AFE_PORT_ID_SECONDARY_TDM_RX_6,
  7289. .probe = msm_dai_q6_dai_tdm_probe,
  7290. .remove = msm_dai_q6_dai_tdm_remove,
  7291. },
  7292. {
  7293. .playback = {
  7294. .stream_name = "Secondary TDM7 Playback",
  7295. .aif_name = "SEC_TDM_RX_7",
  7296. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7297. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7298. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7299. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7300. SNDRV_PCM_FMTBIT_S24_LE |
  7301. SNDRV_PCM_FMTBIT_S32_LE,
  7302. .channels_min = 1,
  7303. .channels_max = 8,
  7304. .rate_min = 8000,
  7305. .rate_max = 352800,
  7306. },
  7307. .ops = &msm_dai_q6_tdm_ops,
  7308. .id = AFE_PORT_ID_SECONDARY_TDM_RX_7,
  7309. .probe = msm_dai_q6_dai_tdm_probe,
  7310. .remove = msm_dai_q6_dai_tdm_remove,
  7311. },
  7312. {
  7313. .capture = {
  7314. .stream_name = "Secondary TDM0 Capture",
  7315. .aif_name = "SEC_TDM_TX_0",
  7316. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7317. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7318. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7319. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7320. SNDRV_PCM_FMTBIT_S24_LE |
  7321. SNDRV_PCM_FMTBIT_S32_LE,
  7322. .channels_min = 1,
  7323. .channels_max = 8,
  7324. .rate_min = 8000,
  7325. .rate_max = 352800,
  7326. },
  7327. .ops = &msm_dai_q6_tdm_ops,
  7328. .id = AFE_PORT_ID_SECONDARY_TDM_TX,
  7329. .probe = msm_dai_q6_dai_tdm_probe,
  7330. .remove = msm_dai_q6_dai_tdm_remove,
  7331. },
  7332. {
  7333. .capture = {
  7334. .stream_name = "Secondary TDM1 Capture",
  7335. .aif_name = "SEC_TDM_TX_1",
  7336. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7337. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7338. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7339. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7340. SNDRV_PCM_FMTBIT_S24_LE |
  7341. SNDRV_PCM_FMTBIT_S32_LE,
  7342. .channels_min = 1,
  7343. .channels_max = 8,
  7344. .rate_min = 8000,
  7345. .rate_max = 352800,
  7346. },
  7347. .ops = &msm_dai_q6_tdm_ops,
  7348. .id = AFE_PORT_ID_SECONDARY_TDM_TX_1,
  7349. .probe = msm_dai_q6_dai_tdm_probe,
  7350. .remove = msm_dai_q6_dai_tdm_remove,
  7351. },
  7352. {
  7353. .capture = {
  7354. .stream_name = "Secondary TDM2 Capture",
  7355. .aif_name = "SEC_TDM_TX_2",
  7356. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7357. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7358. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7359. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7360. SNDRV_PCM_FMTBIT_S24_LE |
  7361. SNDRV_PCM_FMTBIT_S32_LE,
  7362. .channels_min = 1,
  7363. .channels_max = 8,
  7364. .rate_min = 8000,
  7365. .rate_max = 352800,
  7366. },
  7367. .ops = &msm_dai_q6_tdm_ops,
  7368. .id = AFE_PORT_ID_SECONDARY_TDM_TX_2,
  7369. .probe = msm_dai_q6_dai_tdm_probe,
  7370. .remove = msm_dai_q6_dai_tdm_remove,
  7371. },
  7372. {
  7373. .capture = {
  7374. .stream_name = "Secondary TDM3 Capture",
  7375. .aif_name = "SEC_TDM_TX_3",
  7376. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7377. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7378. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7379. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7380. SNDRV_PCM_FMTBIT_S24_LE |
  7381. SNDRV_PCM_FMTBIT_S32_LE,
  7382. .channels_min = 1,
  7383. .channels_max = 8,
  7384. .rate_min = 8000,
  7385. .rate_max = 352800,
  7386. },
  7387. .ops = &msm_dai_q6_tdm_ops,
  7388. .id = AFE_PORT_ID_SECONDARY_TDM_TX_3,
  7389. .probe = msm_dai_q6_dai_tdm_probe,
  7390. .remove = msm_dai_q6_dai_tdm_remove,
  7391. },
  7392. {
  7393. .capture = {
  7394. .stream_name = "Secondary TDM4 Capture",
  7395. .aif_name = "SEC_TDM_TX_4",
  7396. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7397. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7398. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7399. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7400. SNDRV_PCM_FMTBIT_S24_LE |
  7401. SNDRV_PCM_FMTBIT_S32_LE,
  7402. .channels_min = 1,
  7403. .channels_max = 8,
  7404. .rate_min = 8000,
  7405. .rate_max = 352800,
  7406. },
  7407. .ops = &msm_dai_q6_tdm_ops,
  7408. .id = AFE_PORT_ID_SECONDARY_TDM_TX_4,
  7409. .probe = msm_dai_q6_dai_tdm_probe,
  7410. .remove = msm_dai_q6_dai_tdm_remove,
  7411. },
  7412. {
  7413. .capture = {
  7414. .stream_name = "Secondary TDM5 Capture",
  7415. .aif_name = "SEC_TDM_TX_5",
  7416. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7417. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7418. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7419. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7420. SNDRV_PCM_FMTBIT_S24_LE |
  7421. SNDRV_PCM_FMTBIT_S32_LE,
  7422. .channels_min = 1,
  7423. .channels_max = 8,
  7424. .rate_min = 8000,
  7425. .rate_max = 352800,
  7426. },
  7427. .ops = &msm_dai_q6_tdm_ops,
  7428. .id = AFE_PORT_ID_SECONDARY_TDM_TX_5,
  7429. .probe = msm_dai_q6_dai_tdm_probe,
  7430. .remove = msm_dai_q6_dai_tdm_remove,
  7431. },
  7432. {
  7433. .capture = {
  7434. .stream_name = "Secondary TDM6 Capture",
  7435. .aif_name = "SEC_TDM_TX_6",
  7436. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7437. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7438. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7439. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7440. SNDRV_PCM_FMTBIT_S24_LE |
  7441. SNDRV_PCM_FMTBIT_S32_LE,
  7442. .channels_min = 1,
  7443. .channels_max = 8,
  7444. .rate_min = 8000,
  7445. .rate_max = 352800,
  7446. },
  7447. .ops = &msm_dai_q6_tdm_ops,
  7448. .id = AFE_PORT_ID_SECONDARY_TDM_TX_6,
  7449. .probe = msm_dai_q6_dai_tdm_probe,
  7450. .remove = msm_dai_q6_dai_tdm_remove,
  7451. },
  7452. {
  7453. .capture = {
  7454. .stream_name = "Secondary TDM7 Capture",
  7455. .aif_name = "SEC_TDM_TX_7",
  7456. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7457. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7458. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7459. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7460. SNDRV_PCM_FMTBIT_S24_LE |
  7461. SNDRV_PCM_FMTBIT_S32_LE,
  7462. .channels_min = 1,
  7463. .channels_max = 8,
  7464. .rate_min = 8000,
  7465. .rate_max = 352800,
  7466. },
  7467. .ops = &msm_dai_q6_tdm_ops,
  7468. .id = AFE_PORT_ID_SECONDARY_TDM_TX_7,
  7469. .probe = msm_dai_q6_dai_tdm_probe,
  7470. .remove = msm_dai_q6_dai_tdm_remove,
  7471. },
  7472. {
  7473. .playback = {
  7474. .stream_name = "Tertiary TDM0 Playback",
  7475. .aif_name = "TERT_TDM_RX_0",
  7476. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7477. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7478. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7479. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7480. SNDRV_PCM_FMTBIT_S24_LE |
  7481. SNDRV_PCM_FMTBIT_S32_LE,
  7482. .channels_min = 1,
  7483. .channels_max = 8,
  7484. .rate_min = 8000,
  7485. .rate_max = 352800,
  7486. },
  7487. .ops = &msm_dai_q6_tdm_ops,
  7488. .id = AFE_PORT_ID_TERTIARY_TDM_RX,
  7489. .probe = msm_dai_q6_dai_tdm_probe,
  7490. .remove = msm_dai_q6_dai_tdm_remove,
  7491. },
  7492. {
  7493. .playback = {
  7494. .stream_name = "Tertiary TDM1 Playback",
  7495. .aif_name = "TERT_TDM_RX_1",
  7496. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7497. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7498. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7499. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7500. SNDRV_PCM_FMTBIT_S24_LE |
  7501. SNDRV_PCM_FMTBIT_S32_LE,
  7502. .channels_min = 1,
  7503. .channels_max = 8,
  7504. .rate_min = 8000,
  7505. .rate_max = 352800,
  7506. },
  7507. .ops = &msm_dai_q6_tdm_ops,
  7508. .id = AFE_PORT_ID_TERTIARY_TDM_RX_1,
  7509. .probe = msm_dai_q6_dai_tdm_probe,
  7510. .remove = msm_dai_q6_dai_tdm_remove,
  7511. },
  7512. {
  7513. .playback = {
  7514. .stream_name = "Tertiary TDM2 Playback",
  7515. .aif_name = "TERT_TDM_RX_2",
  7516. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7517. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7518. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7519. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7520. SNDRV_PCM_FMTBIT_S24_LE |
  7521. SNDRV_PCM_FMTBIT_S32_LE,
  7522. .channels_min = 1,
  7523. .channels_max = 8,
  7524. .rate_min = 8000,
  7525. .rate_max = 352800,
  7526. },
  7527. .ops = &msm_dai_q6_tdm_ops,
  7528. .id = AFE_PORT_ID_TERTIARY_TDM_RX_2,
  7529. .probe = msm_dai_q6_dai_tdm_probe,
  7530. .remove = msm_dai_q6_dai_tdm_remove,
  7531. },
  7532. {
  7533. .playback = {
  7534. .stream_name = "Tertiary TDM3 Playback",
  7535. .aif_name = "TERT_TDM_RX_3",
  7536. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7537. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7538. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7539. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7540. SNDRV_PCM_FMTBIT_S24_LE |
  7541. SNDRV_PCM_FMTBIT_S32_LE,
  7542. .channels_min = 1,
  7543. .channels_max = 8,
  7544. .rate_min = 8000,
  7545. .rate_max = 352800,
  7546. },
  7547. .ops = &msm_dai_q6_tdm_ops,
  7548. .id = AFE_PORT_ID_TERTIARY_TDM_RX_3,
  7549. .probe = msm_dai_q6_dai_tdm_probe,
  7550. .remove = msm_dai_q6_dai_tdm_remove,
  7551. },
  7552. {
  7553. .playback = {
  7554. .stream_name = "Tertiary TDM4 Playback",
  7555. .aif_name = "TERT_TDM_RX_4",
  7556. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7557. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7558. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7559. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7560. SNDRV_PCM_FMTBIT_S24_LE |
  7561. SNDRV_PCM_FMTBIT_S32_LE,
  7562. .channels_min = 1,
  7563. .channels_max = 8,
  7564. .rate_min = 8000,
  7565. .rate_max = 352800,
  7566. },
  7567. .ops = &msm_dai_q6_tdm_ops,
  7568. .id = AFE_PORT_ID_TERTIARY_TDM_RX_4,
  7569. .probe = msm_dai_q6_dai_tdm_probe,
  7570. .remove = msm_dai_q6_dai_tdm_remove,
  7571. },
  7572. {
  7573. .playback = {
  7574. .stream_name = "Tertiary TDM5 Playback",
  7575. .aif_name = "TERT_TDM_RX_5",
  7576. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7577. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7578. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7579. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7580. SNDRV_PCM_FMTBIT_S24_LE |
  7581. SNDRV_PCM_FMTBIT_S32_LE,
  7582. .channels_min = 1,
  7583. .channels_max = 8,
  7584. .rate_min = 8000,
  7585. .rate_max = 352800,
  7586. },
  7587. .ops = &msm_dai_q6_tdm_ops,
  7588. .id = AFE_PORT_ID_TERTIARY_TDM_RX_5,
  7589. .probe = msm_dai_q6_dai_tdm_probe,
  7590. .remove = msm_dai_q6_dai_tdm_remove,
  7591. },
  7592. {
  7593. .playback = {
  7594. .stream_name = "Tertiary TDM6 Playback",
  7595. .aif_name = "TERT_TDM_RX_6",
  7596. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7597. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7598. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7599. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7600. SNDRV_PCM_FMTBIT_S24_LE |
  7601. SNDRV_PCM_FMTBIT_S32_LE,
  7602. .channels_min = 1,
  7603. .channels_max = 8,
  7604. .rate_min = 8000,
  7605. .rate_max = 352800,
  7606. },
  7607. .ops = &msm_dai_q6_tdm_ops,
  7608. .id = AFE_PORT_ID_TERTIARY_TDM_RX_6,
  7609. .probe = msm_dai_q6_dai_tdm_probe,
  7610. .remove = msm_dai_q6_dai_tdm_remove,
  7611. },
  7612. {
  7613. .playback = {
  7614. .stream_name = "Tertiary TDM7 Playback",
  7615. .aif_name = "TERT_TDM_RX_7",
  7616. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7617. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7618. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7619. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7620. SNDRV_PCM_FMTBIT_S24_LE |
  7621. SNDRV_PCM_FMTBIT_S32_LE,
  7622. .channels_min = 1,
  7623. .channels_max = 8,
  7624. .rate_min = 8000,
  7625. .rate_max = 352800,
  7626. },
  7627. .ops = &msm_dai_q6_tdm_ops,
  7628. .id = AFE_PORT_ID_TERTIARY_TDM_RX_7,
  7629. .probe = msm_dai_q6_dai_tdm_probe,
  7630. .remove = msm_dai_q6_dai_tdm_remove,
  7631. },
  7632. {
  7633. .capture = {
  7634. .stream_name = "Tertiary TDM0 Capture",
  7635. .aif_name = "TERT_TDM_TX_0",
  7636. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7637. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7638. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7639. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7640. SNDRV_PCM_FMTBIT_S24_LE |
  7641. SNDRV_PCM_FMTBIT_S32_LE,
  7642. .channels_min = 1,
  7643. .channels_max = 8,
  7644. .rate_min = 8000,
  7645. .rate_max = 352800,
  7646. },
  7647. .ops = &msm_dai_q6_tdm_ops,
  7648. .id = AFE_PORT_ID_TERTIARY_TDM_TX,
  7649. .probe = msm_dai_q6_dai_tdm_probe,
  7650. .remove = msm_dai_q6_dai_tdm_remove,
  7651. },
  7652. {
  7653. .capture = {
  7654. .stream_name = "Tertiary TDM1 Capture",
  7655. .aif_name = "TERT_TDM_TX_1",
  7656. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7657. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7658. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7659. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7660. SNDRV_PCM_FMTBIT_S24_LE |
  7661. SNDRV_PCM_FMTBIT_S32_LE,
  7662. .channels_min = 1,
  7663. .channels_max = 8,
  7664. .rate_min = 8000,
  7665. .rate_max = 352800,
  7666. },
  7667. .ops = &msm_dai_q6_tdm_ops,
  7668. .id = AFE_PORT_ID_TERTIARY_TDM_TX_1,
  7669. .probe = msm_dai_q6_dai_tdm_probe,
  7670. .remove = msm_dai_q6_dai_tdm_remove,
  7671. },
  7672. {
  7673. .capture = {
  7674. .stream_name = "Tertiary TDM2 Capture",
  7675. .aif_name = "TERT_TDM_TX_2",
  7676. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7677. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7678. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7679. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7680. SNDRV_PCM_FMTBIT_S24_LE |
  7681. SNDRV_PCM_FMTBIT_S32_LE,
  7682. .channels_min = 1,
  7683. .channels_max = 8,
  7684. .rate_min = 8000,
  7685. .rate_max = 352800,
  7686. },
  7687. .ops = &msm_dai_q6_tdm_ops,
  7688. .id = AFE_PORT_ID_TERTIARY_TDM_TX_2,
  7689. .probe = msm_dai_q6_dai_tdm_probe,
  7690. .remove = msm_dai_q6_dai_tdm_remove,
  7691. },
  7692. {
  7693. .capture = {
  7694. .stream_name = "Tertiary TDM3 Capture",
  7695. .aif_name = "TERT_TDM_TX_3",
  7696. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7697. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7698. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7699. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7700. SNDRV_PCM_FMTBIT_S24_LE |
  7701. SNDRV_PCM_FMTBIT_S32_LE,
  7702. .channels_min = 1,
  7703. .channels_max = 8,
  7704. .rate_min = 8000,
  7705. .rate_max = 352800,
  7706. },
  7707. .ops = &msm_dai_q6_tdm_ops,
  7708. .id = AFE_PORT_ID_TERTIARY_TDM_TX_3,
  7709. .probe = msm_dai_q6_dai_tdm_probe,
  7710. .remove = msm_dai_q6_dai_tdm_remove,
  7711. },
  7712. {
  7713. .capture = {
  7714. .stream_name = "Tertiary TDM4 Capture",
  7715. .aif_name = "TERT_TDM_TX_4",
  7716. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7717. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7718. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7719. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7720. SNDRV_PCM_FMTBIT_S24_LE |
  7721. SNDRV_PCM_FMTBIT_S32_LE,
  7722. .channels_min = 1,
  7723. .channels_max = 8,
  7724. .rate_min = 8000,
  7725. .rate_max = 352800,
  7726. },
  7727. .ops = &msm_dai_q6_tdm_ops,
  7728. .id = AFE_PORT_ID_TERTIARY_TDM_TX_4,
  7729. .probe = msm_dai_q6_dai_tdm_probe,
  7730. .remove = msm_dai_q6_dai_tdm_remove,
  7731. },
  7732. {
  7733. .capture = {
  7734. .stream_name = "Tertiary TDM5 Capture",
  7735. .aif_name = "TERT_TDM_TX_5",
  7736. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7737. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7738. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7739. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7740. SNDRV_PCM_FMTBIT_S24_LE |
  7741. SNDRV_PCM_FMTBIT_S32_LE,
  7742. .channels_min = 1,
  7743. .channels_max = 8,
  7744. .rate_min = 8000,
  7745. .rate_max = 352800,
  7746. },
  7747. .ops = &msm_dai_q6_tdm_ops,
  7748. .id = AFE_PORT_ID_TERTIARY_TDM_TX_5,
  7749. .probe = msm_dai_q6_dai_tdm_probe,
  7750. .remove = msm_dai_q6_dai_tdm_remove,
  7751. },
  7752. {
  7753. .capture = {
  7754. .stream_name = "Tertiary TDM6 Capture",
  7755. .aif_name = "TERT_TDM_TX_6",
  7756. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7757. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7758. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7759. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7760. SNDRV_PCM_FMTBIT_S24_LE |
  7761. SNDRV_PCM_FMTBIT_S32_LE,
  7762. .channels_min = 1,
  7763. .channels_max = 8,
  7764. .rate_min = 8000,
  7765. .rate_max = 352800,
  7766. },
  7767. .ops = &msm_dai_q6_tdm_ops,
  7768. .id = AFE_PORT_ID_TERTIARY_TDM_TX_6,
  7769. .probe = msm_dai_q6_dai_tdm_probe,
  7770. .remove = msm_dai_q6_dai_tdm_remove,
  7771. },
  7772. {
  7773. .capture = {
  7774. .stream_name = "Tertiary TDM7 Capture",
  7775. .aif_name = "TERT_TDM_TX_7",
  7776. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7777. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7778. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7779. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7780. SNDRV_PCM_FMTBIT_S24_LE |
  7781. SNDRV_PCM_FMTBIT_S32_LE,
  7782. .channels_min = 1,
  7783. .channels_max = 8,
  7784. .rate_min = 8000,
  7785. .rate_max = 352800,
  7786. },
  7787. .ops = &msm_dai_q6_tdm_ops,
  7788. .id = AFE_PORT_ID_TERTIARY_TDM_TX_7,
  7789. .probe = msm_dai_q6_dai_tdm_probe,
  7790. .remove = msm_dai_q6_dai_tdm_remove,
  7791. },
  7792. {
  7793. .playback = {
  7794. .stream_name = "Quaternary TDM0 Playback",
  7795. .aif_name = "QUAT_TDM_RX_0",
  7796. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  7797. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  7798. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7799. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7800. SNDRV_PCM_FMTBIT_S24_LE |
  7801. SNDRV_PCM_FMTBIT_S32_LE,
  7802. .channels_min = 1,
  7803. .channels_max = 8,
  7804. .rate_min = 8000,
  7805. .rate_max = 352800,
  7806. },
  7807. .ops = &msm_dai_q6_tdm_ops,
  7808. .id = AFE_PORT_ID_QUATERNARY_TDM_RX,
  7809. .probe = msm_dai_q6_dai_tdm_probe,
  7810. .remove = msm_dai_q6_dai_tdm_remove,
  7811. },
  7812. {
  7813. .playback = {
  7814. .stream_name = "Quaternary TDM1 Playback",
  7815. .aif_name = "QUAT_TDM_RX_1",
  7816. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7817. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7818. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7819. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7820. SNDRV_PCM_FMTBIT_S24_LE |
  7821. SNDRV_PCM_FMTBIT_S32_LE,
  7822. .channels_min = 1,
  7823. .channels_max = 8,
  7824. .rate_min = 8000,
  7825. .rate_max = 352800,
  7826. },
  7827. .ops = &msm_dai_q6_tdm_ops,
  7828. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_1,
  7829. .probe = msm_dai_q6_dai_tdm_probe,
  7830. .remove = msm_dai_q6_dai_tdm_remove,
  7831. },
  7832. {
  7833. .playback = {
  7834. .stream_name = "Quaternary TDM2 Playback",
  7835. .aif_name = "QUAT_TDM_RX_2",
  7836. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7837. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7838. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7839. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7840. SNDRV_PCM_FMTBIT_S24_LE |
  7841. SNDRV_PCM_FMTBIT_S32_LE,
  7842. .channels_min = 1,
  7843. .channels_max = 8,
  7844. .rate_min = 8000,
  7845. .rate_max = 352800,
  7846. },
  7847. .ops = &msm_dai_q6_tdm_ops,
  7848. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_2,
  7849. .probe = msm_dai_q6_dai_tdm_probe,
  7850. .remove = msm_dai_q6_dai_tdm_remove,
  7851. },
  7852. {
  7853. .playback = {
  7854. .stream_name = "Quaternary TDM3 Playback",
  7855. .aif_name = "QUAT_TDM_RX_3",
  7856. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7857. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7858. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7859. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7860. SNDRV_PCM_FMTBIT_S24_LE |
  7861. SNDRV_PCM_FMTBIT_S32_LE,
  7862. .channels_min = 1,
  7863. .channels_max = 8,
  7864. .rate_min = 8000,
  7865. .rate_max = 352800,
  7866. },
  7867. .ops = &msm_dai_q6_tdm_ops,
  7868. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_3,
  7869. .probe = msm_dai_q6_dai_tdm_probe,
  7870. .remove = msm_dai_q6_dai_tdm_remove,
  7871. },
  7872. {
  7873. .playback = {
  7874. .stream_name = "Quaternary TDM4 Playback",
  7875. .aif_name = "QUAT_TDM_RX_4",
  7876. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7877. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7878. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7879. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7880. SNDRV_PCM_FMTBIT_S24_LE |
  7881. SNDRV_PCM_FMTBIT_S32_LE,
  7882. .channels_min = 1,
  7883. .channels_max = 8,
  7884. .rate_min = 8000,
  7885. .rate_max = 352800,
  7886. },
  7887. .ops = &msm_dai_q6_tdm_ops,
  7888. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_4,
  7889. .probe = msm_dai_q6_dai_tdm_probe,
  7890. .remove = msm_dai_q6_dai_tdm_remove,
  7891. },
  7892. {
  7893. .playback = {
  7894. .stream_name = "Quaternary TDM5 Playback",
  7895. .aif_name = "QUAT_TDM_RX_5",
  7896. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7897. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7898. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7899. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7900. SNDRV_PCM_FMTBIT_S24_LE |
  7901. SNDRV_PCM_FMTBIT_S32_LE,
  7902. .channels_min = 1,
  7903. .channels_max = 8,
  7904. .rate_min = 8000,
  7905. .rate_max = 352800,
  7906. },
  7907. .ops = &msm_dai_q6_tdm_ops,
  7908. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_5,
  7909. .probe = msm_dai_q6_dai_tdm_probe,
  7910. .remove = msm_dai_q6_dai_tdm_remove,
  7911. },
  7912. {
  7913. .playback = {
  7914. .stream_name = "Quaternary TDM6 Playback",
  7915. .aif_name = "QUAT_TDM_RX_6",
  7916. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7917. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7918. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7919. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7920. SNDRV_PCM_FMTBIT_S24_LE |
  7921. SNDRV_PCM_FMTBIT_S32_LE,
  7922. .channels_min = 1,
  7923. .channels_max = 8,
  7924. .rate_min = 8000,
  7925. .rate_max = 352800,
  7926. },
  7927. .ops = &msm_dai_q6_tdm_ops,
  7928. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_6,
  7929. .probe = msm_dai_q6_dai_tdm_probe,
  7930. .remove = msm_dai_q6_dai_tdm_remove,
  7931. },
  7932. {
  7933. .playback = {
  7934. .stream_name = "Quaternary TDM7 Playback",
  7935. .aif_name = "QUAT_TDM_RX_7",
  7936. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7937. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7938. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7939. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7940. SNDRV_PCM_FMTBIT_S24_LE |
  7941. SNDRV_PCM_FMTBIT_S32_LE,
  7942. .channels_min = 1,
  7943. .channels_max = 8,
  7944. .rate_min = 8000,
  7945. .rate_max = 352800,
  7946. },
  7947. .ops = &msm_dai_q6_tdm_ops,
  7948. .id = AFE_PORT_ID_QUATERNARY_TDM_RX_7,
  7949. .probe = msm_dai_q6_dai_tdm_probe,
  7950. .remove = msm_dai_q6_dai_tdm_remove,
  7951. },
  7952. {
  7953. .capture = {
  7954. .stream_name = "Quaternary TDM0 Capture",
  7955. .aif_name = "QUAT_TDM_TX_0",
  7956. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7957. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7958. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7959. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7960. SNDRV_PCM_FMTBIT_S24_LE |
  7961. SNDRV_PCM_FMTBIT_S32_LE,
  7962. .channels_min = 1,
  7963. .channels_max = 8,
  7964. .rate_min = 8000,
  7965. .rate_max = 352800,
  7966. },
  7967. .ops = &msm_dai_q6_tdm_ops,
  7968. .id = AFE_PORT_ID_QUATERNARY_TDM_TX,
  7969. .probe = msm_dai_q6_dai_tdm_probe,
  7970. .remove = msm_dai_q6_dai_tdm_remove,
  7971. },
  7972. {
  7973. .capture = {
  7974. .stream_name = "Quaternary TDM1 Capture",
  7975. .aif_name = "QUAT_TDM_TX_1",
  7976. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7977. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7978. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7979. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  7980. SNDRV_PCM_FMTBIT_S24_LE |
  7981. SNDRV_PCM_FMTBIT_S32_LE,
  7982. .channels_min = 1,
  7983. .channels_max = 8,
  7984. .rate_min = 8000,
  7985. .rate_max = 352800,
  7986. },
  7987. .ops = &msm_dai_q6_tdm_ops,
  7988. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_1,
  7989. .probe = msm_dai_q6_dai_tdm_probe,
  7990. .remove = msm_dai_q6_dai_tdm_remove,
  7991. },
  7992. {
  7993. .capture = {
  7994. .stream_name = "Quaternary TDM2 Capture",
  7995. .aif_name = "QUAT_TDM_TX_2",
  7996. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  7997. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  7998. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  7999. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8000. SNDRV_PCM_FMTBIT_S24_LE |
  8001. SNDRV_PCM_FMTBIT_S32_LE,
  8002. .channels_min = 1,
  8003. .channels_max = 8,
  8004. .rate_min = 8000,
  8005. .rate_max = 352800,
  8006. },
  8007. .ops = &msm_dai_q6_tdm_ops,
  8008. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_2,
  8009. .probe = msm_dai_q6_dai_tdm_probe,
  8010. .remove = msm_dai_q6_dai_tdm_remove,
  8011. },
  8012. {
  8013. .capture = {
  8014. .stream_name = "Quaternary TDM3 Capture",
  8015. .aif_name = "QUAT_TDM_TX_3",
  8016. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8017. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8018. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8019. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8020. SNDRV_PCM_FMTBIT_S24_LE |
  8021. SNDRV_PCM_FMTBIT_S32_LE,
  8022. .channels_min = 1,
  8023. .channels_max = 8,
  8024. .rate_min = 8000,
  8025. .rate_max = 352800,
  8026. },
  8027. .ops = &msm_dai_q6_tdm_ops,
  8028. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_3,
  8029. .probe = msm_dai_q6_dai_tdm_probe,
  8030. .remove = msm_dai_q6_dai_tdm_remove,
  8031. },
  8032. {
  8033. .capture = {
  8034. .stream_name = "Quaternary TDM4 Capture",
  8035. .aif_name = "QUAT_TDM_TX_4",
  8036. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8037. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8038. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8039. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8040. SNDRV_PCM_FMTBIT_S24_LE |
  8041. SNDRV_PCM_FMTBIT_S32_LE,
  8042. .channels_min = 1,
  8043. .channels_max = 8,
  8044. .rate_min = 8000,
  8045. .rate_max = 352800,
  8046. },
  8047. .ops = &msm_dai_q6_tdm_ops,
  8048. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_4,
  8049. .probe = msm_dai_q6_dai_tdm_probe,
  8050. .remove = msm_dai_q6_dai_tdm_remove,
  8051. },
  8052. {
  8053. .capture = {
  8054. .stream_name = "Quaternary TDM5 Capture",
  8055. .aif_name = "QUAT_TDM_TX_5",
  8056. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8057. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8058. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8059. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8060. SNDRV_PCM_FMTBIT_S24_LE |
  8061. SNDRV_PCM_FMTBIT_S32_LE,
  8062. .channels_min = 1,
  8063. .channels_max = 8,
  8064. .rate_min = 8000,
  8065. .rate_max = 352800,
  8066. },
  8067. .ops = &msm_dai_q6_tdm_ops,
  8068. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_5,
  8069. .probe = msm_dai_q6_dai_tdm_probe,
  8070. .remove = msm_dai_q6_dai_tdm_remove,
  8071. },
  8072. {
  8073. .capture = {
  8074. .stream_name = "Quaternary TDM6 Capture",
  8075. .aif_name = "QUAT_TDM_TX_6",
  8076. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8077. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8078. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8079. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8080. SNDRV_PCM_FMTBIT_S24_LE |
  8081. SNDRV_PCM_FMTBIT_S32_LE,
  8082. .channels_min = 1,
  8083. .channels_max = 8,
  8084. .rate_min = 8000,
  8085. .rate_max = 352800,
  8086. },
  8087. .ops = &msm_dai_q6_tdm_ops,
  8088. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_6,
  8089. .probe = msm_dai_q6_dai_tdm_probe,
  8090. .remove = msm_dai_q6_dai_tdm_remove,
  8091. },
  8092. {
  8093. .capture = {
  8094. .stream_name = "Quaternary TDM7 Capture",
  8095. .aif_name = "QUAT_TDM_TX_7",
  8096. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8097. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8098. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8099. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8100. SNDRV_PCM_FMTBIT_S24_LE |
  8101. SNDRV_PCM_FMTBIT_S32_LE,
  8102. .channels_min = 1,
  8103. .channels_max = 8,
  8104. .rate_min = 8000,
  8105. .rate_max = 352800,
  8106. },
  8107. .ops = &msm_dai_q6_tdm_ops,
  8108. .id = AFE_PORT_ID_QUATERNARY_TDM_TX_7,
  8109. .probe = msm_dai_q6_dai_tdm_probe,
  8110. .remove = msm_dai_q6_dai_tdm_remove,
  8111. },
  8112. {
  8113. .playback = {
  8114. .stream_name = "Quinary TDM0 Playback",
  8115. .aif_name = "QUIN_TDM_RX_0",
  8116. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8117. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8118. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8119. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8120. SNDRV_PCM_FMTBIT_S24_LE |
  8121. SNDRV_PCM_FMTBIT_S32_LE,
  8122. .channels_min = 1,
  8123. .channels_max = 8,
  8124. .rate_min = 8000,
  8125. .rate_max = 352800,
  8126. },
  8127. .ops = &msm_dai_q6_tdm_ops,
  8128. .id = AFE_PORT_ID_QUINARY_TDM_RX,
  8129. .probe = msm_dai_q6_dai_tdm_probe,
  8130. .remove = msm_dai_q6_dai_tdm_remove,
  8131. },
  8132. {
  8133. .playback = {
  8134. .stream_name = "Quinary TDM1 Playback",
  8135. .aif_name = "QUIN_TDM_RX_1",
  8136. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8137. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8138. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8139. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8140. SNDRV_PCM_FMTBIT_S24_LE |
  8141. SNDRV_PCM_FMTBIT_S32_LE,
  8142. .channels_min = 1,
  8143. .channels_max = 8,
  8144. .rate_min = 8000,
  8145. .rate_max = 352800,
  8146. },
  8147. .ops = &msm_dai_q6_tdm_ops,
  8148. .id = AFE_PORT_ID_QUINARY_TDM_RX_1,
  8149. .probe = msm_dai_q6_dai_tdm_probe,
  8150. .remove = msm_dai_q6_dai_tdm_remove,
  8151. },
  8152. {
  8153. .playback = {
  8154. .stream_name = "Quinary TDM2 Playback",
  8155. .aif_name = "QUIN_TDM_RX_2",
  8156. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8157. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8158. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8159. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8160. SNDRV_PCM_FMTBIT_S24_LE |
  8161. SNDRV_PCM_FMTBIT_S32_LE,
  8162. .channels_min = 1,
  8163. .channels_max = 8,
  8164. .rate_min = 8000,
  8165. .rate_max = 352800,
  8166. },
  8167. .ops = &msm_dai_q6_tdm_ops,
  8168. .id = AFE_PORT_ID_QUINARY_TDM_RX_2,
  8169. .probe = msm_dai_q6_dai_tdm_probe,
  8170. .remove = msm_dai_q6_dai_tdm_remove,
  8171. },
  8172. {
  8173. .playback = {
  8174. .stream_name = "Quinary TDM3 Playback",
  8175. .aif_name = "QUIN_TDM_RX_3",
  8176. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8177. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8178. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8179. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8180. SNDRV_PCM_FMTBIT_S24_LE |
  8181. SNDRV_PCM_FMTBIT_S32_LE,
  8182. .channels_min = 1,
  8183. .channels_max = 8,
  8184. .rate_min = 8000,
  8185. .rate_max = 352800,
  8186. },
  8187. .ops = &msm_dai_q6_tdm_ops,
  8188. .id = AFE_PORT_ID_QUINARY_TDM_RX_3,
  8189. .probe = msm_dai_q6_dai_tdm_probe,
  8190. .remove = msm_dai_q6_dai_tdm_remove,
  8191. },
  8192. {
  8193. .playback = {
  8194. .stream_name = "Quinary TDM4 Playback",
  8195. .aif_name = "QUIN_TDM_RX_4",
  8196. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8197. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8198. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8199. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8200. SNDRV_PCM_FMTBIT_S24_LE |
  8201. SNDRV_PCM_FMTBIT_S32_LE,
  8202. .channels_min = 1,
  8203. .channels_max = 8,
  8204. .rate_min = 8000,
  8205. .rate_max = 352800,
  8206. },
  8207. .ops = &msm_dai_q6_tdm_ops,
  8208. .id = AFE_PORT_ID_QUINARY_TDM_RX_4,
  8209. .probe = msm_dai_q6_dai_tdm_probe,
  8210. .remove = msm_dai_q6_dai_tdm_remove,
  8211. },
  8212. {
  8213. .playback = {
  8214. .stream_name = "Quinary TDM5 Playback",
  8215. .aif_name = "QUIN_TDM_RX_5",
  8216. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8217. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8218. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8219. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8220. SNDRV_PCM_FMTBIT_S24_LE |
  8221. SNDRV_PCM_FMTBIT_S32_LE,
  8222. .channels_min = 1,
  8223. .channels_max = 8,
  8224. .rate_min = 8000,
  8225. .rate_max = 352800,
  8226. },
  8227. .ops = &msm_dai_q6_tdm_ops,
  8228. .id = AFE_PORT_ID_QUINARY_TDM_RX_5,
  8229. .probe = msm_dai_q6_dai_tdm_probe,
  8230. .remove = msm_dai_q6_dai_tdm_remove,
  8231. },
  8232. {
  8233. .playback = {
  8234. .stream_name = "Quinary TDM6 Playback",
  8235. .aif_name = "QUIN_TDM_RX_6",
  8236. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8237. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8238. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8239. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8240. SNDRV_PCM_FMTBIT_S24_LE |
  8241. SNDRV_PCM_FMTBIT_S32_LE,
  8242. .channels_min = 1,
  8243. .channels_max = 8,
  8244. .rate_min = 8000,
  8245. .rate_max = 352800,
  8246. },
  8247. .ops = &msm_dai_q6_tdm_ops,
  8248. .id = AFE_PORT_ID_QUINARY_TDM_RX_6,
  8249. .probe = msm_dai_q6_dai_tdm_probe,
  8250. .remove = msm_dai_q6_dai_tdm_remove,
  8251. },
  8252. {
  8253. .playback = {
  8254. .stream_name = "Quinary TDM7 Playback",
  8255. .aif_name = "QUIN_TDM_RX_7",
  8256. .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 |
  8257. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_48000 |
  8258. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8259. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8260. SNDRV_PCM_FMTBIT_S24_LE |
  8261. SNDRV_PCM_FMTBIT_S32_LE,
  8262. .channels_min = 1,
  8263. .channels_max = 8,
  8264. .rate_min = 8000,
  8265. .rate_max = 352800,
  8266. },
  8267. .ops = &msm_dai_q6_tdm_ops,
  8268. .id = AFE_PORT_ID_QUINARY_TDM_RX_7,
  8269. .probe = msm_dai_q6_dai_tdm_probe,
  8270. .remove = msm_dai_q6_dai_tdm_remove,
  8271. },
  8272. {
  8273. .capture = {
  8274. .stream_name = "Quinary TDM0 Capture",
  8275. .aif_name = "QUIN_TDM_TX_0",
  8276. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8277. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8278. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8279. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8280. SNDRV_PCM_FMTBIT_S24_LE |
  8281. SNDRV_PCM_FMTBIT_S32_LE,
  8282. .channels_min = 1,
  8283. .channels_max = 8,
  8284. .rate_min = 8000,
  8285. .rate_max = 352800,
  8286. },
  8287. .ops = &msm_dai_q6_tdm_ops,
  8288. .id = AFE_PORT_ID_QUINARY_TDM_TX,
  8289. .probe = msm_dai_q6_dai_tdm_probe,
  8290. .remove = msm_dai_q6_dai_tdm_remove,
  8291. },
  8292. {
  8293. .capture = {
  8294. .stream_name = "Quinary TDM1 Capture",
  8295. .aif_name = "QUIN_TDM_TX_1",
  8296. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8297. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8298. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8299. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8300. SNDRV_PCM_FMTBIT_S24_LE |
  8301. SNDRV_PCM_FMTBIT_S32_LE,
  8302. .channels_min = 1,
  8303. .channels_max = 8,
  8304. .rate_min = 8000,
  8305. .rate_max = 352800,
  8306. },
  8307. .ops = &msm_dai_q6_tdm_ops,
  8308. .id = AFE_PORT_ID_QUINARY_TDM_TX_1,
  8309. .probe = msm_dai_q6_dai_tdm_probe,
  8310. .remove = msm_dai_q6_dai_tdm_remove,
  8311. },
  8312. {
  8313. .capture = {
  8314. .stream_name = "Quinary TDM2 Capture",
  8315. .aif_name = "QUIN_TDM_TX_2",
  8316. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8317. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8318. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8319. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8320. SNDRV_PCM_FMTBIT_S24_LE |
  8321. SNDRV_PCM_FMTBIT_S32_LE,
  8322. .channels_min = 1,
  8323. .channels_max = 8,
  8324. .rate_min = 8000,
  8325. .rate_max = 352800,
  8326. },
  8327. .ops = &msm_dai_q6_tdm_ops,
  8328. .id = AFE_PORT_ID_QUINARY_TDM_TX_2,
  8329. .probe = msm_dai_q6_dai_tdm_probe,
  8330. .remove = msm_dai_q6_dai_tdm_remove,
  8331. },
  8332. {
  8333. .capture = {
  8334. .stream_name = "Quinary TDM3 Capture",
  8335. .aif_name = "QUIN_TDM_TX_3",
  8336. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8337. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8338. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8339. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8340. SNDRV_PCM_FMTBIT_S24_LE |
  8341. SNDRV_PCM_FMTBIT_S32_LE,
  8342. .channels_min = 1,
  8343. .channels_max = 8,
  8344. .rate_min = 8000,
  8345. .rate_max = 352800,
  8346. },
  8347. .ops = &msm_dai_q6_tdm_ops,
  8348. .id = AFE_PORT_ID_QUINARY_TDM_TX_3,
  8349. .probe = msm_dai_q6_dai_tdm_probe,
  8350. .remove = msm_dai_q6_dai_tdm_remove,
  8351. },
  8352. {
  8353. .capture = {
  8354. .stream_name = "Quinary TDM4 Capture",
  8355. .aif_name = "QUIN_TDM_TX_4",
  8356. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8357. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8358. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8359. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8360. SNDRV_PCM_FMTBIT_S24_LE |
  8361. SNDRV_PCM_FMTBIT_S32_LE,
  8362. .channels_min = 1,
  8363. .channels_max = 8,
  8364. .rate_min = 8000,
  8365. .rate_max = 352800,
  8366. },
  8367. .ops = &msm_dai_q6_tdm_ops,
  8368. .id = AFE_PORT_ID_QUINARY_TDM_TX_4,
  8369. .probe = msm_dai_q6_dai_tdm_probe,
  8370. .remove = msm_dai_q6_dai_tdm_remove,
  8371. },
  8372. {
  8373. .capture = {
  8374. .stream_name = "Quinary TDM5 Capture",
  8375. .aif_name = "QUIN_TDM_TX_5",
  8376. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8377. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8378. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8379. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8380. SNDRV_PCM_FMTBIT_S24_LE |
  8381. SNDRV_PCM_FMTBIT_S32_LE,
  8382. .channels_min = 1,
  8383. .channels_max = 8,
  8384. .rate_min = 8000,
  8385. .rate_max = 352800,
  8386. },
  8387. .ops = &msm_dai_q6_tdm_ops,
  8388. .id = AFE_PORT_ID_QUINARY_TDM_TX_5,
  8389. .probe = msm_dai_q6_dai_tdm_probe,
  8390. .remove = msm_dai_q6_dai_tdm_remove,
  8391. },
  8392. {
  8393. .capture = {
  8394. .stream_name = "Quinary TDM6 Capture",
  8395. .aif_name = "QUIN_TDM_TX_6",
  8396. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8397. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8398. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8399. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8400. SNDRV_PCM_FMTBIT_S24_LE |
  8401. SNDRV_PCM_FMTBIT_S32_LE,
  8402. .channels_min = 1,
  8403. .channels_max = 8,
  8404. .rate_min = 8000,
  8405. .rate_max = 352800,
  8406. },
  8407. .ops = &msm_dai_q6_tdm_ops,
  8408. .id = AFE_PORT_ID_QUINARY_TDM_TX_6,
  8409. .probe = msm_dai_q6_dai_tdm_probe,
  8410. .remove = msm_dai_q6_dai_tdm_remove,
  8411. },
  8412. {
  8413. .capture = {
  8414. .stream_name = "Quinary TDM7 Capture",
  8415. .aif_name = "QUIN_TDM_TX_7",
  8416. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
  8417. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |
  8418. SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800,
  8419. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8420. SNDRV_PCM_FMTBIT_S24_LE |
  8421. SNDRV_PCM_FMTBIT_S32_LE,
  8422. .channels_min = 1,
  8423. .channels_max = 8,
  8424. .rate_min = 8000,
  8425. .rate_max = 352800,
  8426. },
  8427. .ops = &msm_dai_q6_tdm_ops,
  8428. .id = AFE_PORT_ID_QUINARY_TDM_TX_7,
  8429. .probe = msm_dai_q6_dai_tdm_probe,
  8430. .remove = msm_dai_q6_dai_tdm_remove,
  8431. },
  8432. };
  8433. static const struct snd_soc_component_driver msm_q6_tdm_dai_component = {
  8434. .name = "msm-dai-q6-tdm",
  8435. };
  8436. static int msm_dai_q6_tdm_dev_probe(struct platform_device *pdev)
  8437. {
  8438. struct msm_dai_q6_tdm_dai_data *dai_data = NULL;
  8439. struct afe_param_id_custom_tdm_header_cfg *custom_tdm_header = NULL;
  8440. int rc = 0;
  8441. u32 tdm_dev_id = 0;
  8442. int port_idx = 0;
  8443. struct device_node *tdm_parent_node = NULL;
  8444. /* retrieve device/afe id */
  8445. rc = of_property_read_u32(pdev->dev.of_node,
  8446. "qcom,msm-cpudai-tdm-dev-id",
  8447. &tdm_dev_id);
  8448. if (rc) {
  8449. dev_err(&pdev->dev, "%s: Device ID missing in DT file\n",
  8450. __func__);
  8451. goto rtn;
  8452. }
  8453. if ((tdm_dev_id < AFE_PORT_ID_TDM_PORT_RANGE_START) ||
  8454. (tdm_dev_id > AFE_PORT_ID_TDM_PORT_RANGE_END)) {
  8455. dev_err(&pdev->dev, "%s: Invalid TDM Device ID 0x%x in DT file\n",
  8456. __func__, tdm_dev_id);
  8457. rc = -ENXIO;
  8458. goto rtn;
  8459. }
  8460. pdev->id = tdm_dev_id;
  8461. dai_data = kzalloc(sizeof(struct msm_dai_q6_tdm_dai_data),
  8462. GFP_KERNEL);
  8463. if (!dai_data) {
  8464. rc = -ENOMEM;
  8465. dev_err(&pdev->dev,
  8466. "%s Failed to allocate memory for tdm dai_data\n",
  8467. __func__);
  8468. goto rtn;
  8469. }
  8470. memset(dai_data, 0, sizeof(*dai_data));
  8471. rc = of_property_read_u32(pdev->dev.of_node,
  8472. "qcom,msm-dai-is-island-supported",
  8473. &dai_data->is_island_dai);
  8474. if (rc)
  8475. dev_dbg(&pdev->dev, "island supported entry not found\n");
  8476. /* TDM CFG */
  8477. tdm_parent_node = of_get_parent(pdev->dev.of_node);
  8478. rc = of_property_read_u32(tdm_parent_node,
  8479. "qcom,msm-cpudai-tdm-sync-mode",
  8480. (u32 *)&dai_data->port_cfg.tdm.sync_mode);
  8481. if (rc) {
  8482. dev_err(&pdev->dev, "%s: Sync Mode from DT file %s\n",
  8483. __func__, "qcom,msm-cpudai-tdm-sync-mode");
  8484. goto free_dai_data;
  8485. }
  8486. dev_dbg(&pdev->dev, "%s: Sync Mode from DT file 0x%x\n",
  8487. __func__, dai_data->port_cfg.tdm.sync_mode);
  8488. rc = of_property_read_u32(tdm_parent_node,
  8489. "qcom,msm-cpudai-tdm-sync-src",
  8490. (u32 *)&dai_data->port_cfg.tdm.sync_src);
  8491. if (rc) {
  8492. dev_err(&pdev->dev, "%s: Sync Src from DT file %s\n",
  8493. __func__, "qcom,msm-cpudai-tdm-sync-src");
  8494. goto free_dai_data;
  8495. }
  8496. dev_dbg(&pdev->dev, "%s: Sync Src from DT file 0x%x\n",
  8497. __func__, dai_data->port_cfg.tdm.sync_src);
  8498. rc = of_property_read_u32(tdm_parent_node,
  8499. "qcom,msm-cpudai-tdm-data-out",
  8500. (u32 *)&dai_data->port_cfg.tdm.ctrl_data_out_enable);
  8501. if (rc) {
  8502. dev_err(&pdev->dev, "%s: Data Out from DT file %s\n",
  8503. __func__, "qcom,msm-cpudai-tdm-data-out");
  8504. goto free_dai_data;
  8505. }
  8506. dev_dbg(&pdev->dev, "%s: Data Out from DT file 0x%x\n",
  8507. __func__, dai_data->port_cfg.tdm.ctrl_data_out_enable);
  8508. rc = of_property_read_u32(tdm_parent_node,
  8509. "qcom,msm-cpudai-tdm-invert-sync",
  8510. (u32 *)&dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  8511. if (rc) {
  8512. dev_err(&pdev->dev, "%s: Invert Sync from DT file %s\n",
  8513. __func__, "qcom,msm-cpudai-tdm-invert-sync");
  8514. goto free_dai_data;
  8515. }
  8516. dev_dbg(&pdev->dev, "%s: Invert Sync from DT file 0x%x\n",
  8517. __func__, dai_data->port_cfg.tdm.ctrl_invert_sync_pulse);
  8518. rc = of_property_read_u32(tdm_parent_node,
  8519. "qcom,msm-cpudai-tdm-data-delay",
  8520. (u32 *)&dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  8521. if (rc) {
  8522. dev_err(&pdev->dev, "%s: Data Delay from DT file %s\n",
  8523. __func__, "qcom,msm-cpudai-tdm-data-delay");
  8524. goto free_dai_data;
  8525. }
  8526. dev_dbg(&pdev->dev, "%s: Data Delay from DT file 0x%x\n",
  8527. __func__, dai_data->port_cfg.tdm.ctrl_sync_data_delay);
  8528. /* TDM CFG -- set default */
  8529. dai_data->port_cfg.tdm.data_format = AFE_LINEAR_PCM_DATA;
  8530. dai_data->port_cfg.tdm.tdm_cfg_minor_version =
  8531. AFE_API_VERSION_TDM_CONFIG;
  8532. /* TDM SLOT MAPPING CFG */
  8533. rc = of_property_read_u32(pdev->dev.of_node,
  8534. "qcom,msm-cpudai-tdm-data-align",
  8535. &dai_data->port_cfg.slot_mapping.data_align_type);
  8536. if (rc) {
  8537. dev_err(&pdev->dev, "%s: Data Align from DT file %s\n",
  8538. __func__,
  8539. "qcom,msm-cpudai-tdm-data-align");
  8540. goto free_dai_data;
  8541. }
  8542. dev_dbg(&pdev->dev, "%s: Data Align from DT file 0x%x\n",
  8543. __func__, dai_data->port_cfg.slot_mapping.data_align_type);
  8544. /* TDM SLOT MAPPING CFG -- set default */
  8545. dai_data->port_cfg.slot_mapping.minor_version =
  8546. AFE_API_VERSION_SLOT_MAPPING_CONFIG;
  8547. /* CUSTOM TDM HEADER CFG */
  8548. custom_tdm_header = &dai_data->port_cfg.custom_tdm_header;
  8549. if (of_find_property(pdev->dev.of_node,
  8550. "qcom,msm-cpudai-tdm-header-start-offset", NULL) &&
  8551. of_find_property(pdev->dev.of_node,
  8552. "qcom,msm-cpudai-tdm-header-width", NULL) &&
  8553. of_find_property(pdev->dev.of_node,
  8554. "qcom,msm-cpudai-tdm-header-num-frame-repeat", NULL)) {
  8555. /* if the property exist */
  8556. rc = of_property_read_u32(pdev->dev.of_node,
  8557. "qcom,msm-cpudai-tdm-header-start-offset",
  8558. (u32 *)&custom_tdm_header->start_offset);
  8559. if (rc) {
  8560. dev_err(&pdev->dev, "%s: Header Start Offset from DT file %s\n",
  8561. __func__,
  8562. "qcom,msm-cpudai-tdm-header-start-offset");
  8563. goto free_dai_data;
  8564. }
  8565. dev_dbg(&pdev->dev, "%s: Header Start Offset from DT file 0x%x\n",
  8566. __func__, custom_tdm_header->start_offset);
  8567. rc = of_property_read_u32(pdev->dev.of_node,
  8568. "qcom,msm-cpudai-tdm-header-width",
  8569. (u32 *)&custom_tdm_header->header_width);
  8570. if (rc) {
  8571. dev_err(&pdev->dev, "%s: Header Width from DT file %s\n",
  8572. __func__, "qcom,msm-cpudai-tdm-header-width");
  8573. goto free_dai_data;
  8574. }
  8575. dev_dbg(&pdev->dev, "%s: Header Width from DT file 0x%x\n",
  8576. __func__, custom_tdm_header->header_width);
  8577. rc = of_property_read_u32(pdev->dev.of_node,
  8578. "qcom,msm-cpudai-tdm-header-num-frame-repeat",
  8579. (u32 *)&custom_tdm_header->num_frame_repeat);
  8580. if (rc) {
  8581. dev_err(&pdev->dev, "%s: Header Num Frame Repeat from DT file %s\n",
  8582. __func__,
  8583. "qcom,msm-cpudai-tdm-header-num-frame-repeat");
  8584. goto free_dai_data;
  8585. }
  8586. dev_dbg(&pdev->dev, "%s: Header Num Frame Repeat from DT file 0x%x\n",
  8587. __func__, custom_tdm_header->num_frame_repeat);
  8588. /* CUSTOM TDM HEADER CFG -- set default */
  8589. custom_tdm_header->minor_version =
  8590. AFE_API_VERSION_CUSTOM_TDM_HEADER_CONFIG;
  8591. custom_tdm_header->header_type =
  8592. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  8593. } else {
  8594. /* CUSTOM TDM HEADER CFG -- set default */
  8595. custom_tdm_header->header_type =
  8596. AFE_CUSTOM_TDM_HEADER_TYPE_INVALID;
  8597. /* proceed with probe */
  8598. }
  8599. /* copy static clk per parent node */
  8600. dai_data->clk_set = tdm_clk_set;
  8601. /* copy static group cfg per parent node */
  8602. dai_data->group_cfg.tdm_cfg = tdm_group_cfg;
  8603. /* copy static num group ports per parent node */
  8604. dai_data->num_group_ports = num_tdm_group_ports;
  8605. dev_set_drvdata(&pdev->dev, dai_data);
  8606. port_idx = msm_dai_q6_get_port_idx(tdm_dev_id);
  8607. if (port_idx < 0) {
  8608. dev_err(&pdev->dev, "%s Port id 0x%x not supported\n",
  8609. __func__, tdm_dev_id);
  8610. rc = -EINVAL;
  8611. goto free_dai_data;
  8612. }
  8613. rc = snd_soc_register_component(&pdev->dev,
  8614. &msm_q6_tdm_dai_component,
  8615. &msm_dai_q6_tdm_dai[port_idx], 1);
  8616. if (rc) {
  8617. dev_err(&pdev->dev, "%s: TDM dai 0x%x register failed, rc=%d\n",
  8618. __func__, tdm_dev_id, rc);
  8619. goto err_register;
  8620. }
  8621. return 0;
  8622. err_register:
  8623. free_dai_data:
  8624. kfree(dai_data);
  8625. rtn:
  8626. return rc;
  8627. }
  8628. static int msm_dai_q6_tdm_dev_remove(struct platform_device *pdev)
  8629. {
  8630. struct msm_dai_q6_tdm_dai_data *dai_data =
  8631. dev_get_drvdata(&pdev->dev);
  8632. snd_soc_unregister_component(&pdev->dev);
  8633. kfree(dai_data);
  8634. return 0;
  8635. }
  8636. static const struct of_device_id msm_dai_q6_tdm_dev_dt_match[] = {
  8637. { .compatible = "qcom,msm-dai-q6-tdm", },
  8638. {}
  8639. };
  8640. MODULE_DEVICE_TABLE(of, msm_dai_q6_tdm_dev_dt_match);
  8641. static struct platform_driver msm_dai_q6_tdm_driver = {
  8642. .probe = msm_dai_q6_tdm_dev_probe,
  8643. .remove = msm_dai_q6_tdm_dev_remove,
  8644. .driver = {
  8645. .name = "msm-dai-q6-tdm",
  8646. .owner = THIS_MODULE,
  8647. .of_match_table = msm_dai_q6_tdm_dev_dt_match,
  8648. },
  8649. };
  8650. static int msm_dai_q6_cdc_dma_format_put(struct snd_kcontrol *kcontrol,
  8651. struct snd_ctl_elem_value *ucontrol)
  8652. {
  8653. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  8654. int value = ucontrol->value.integer.value[0];
  8655. dai_data->port_config.cdc_dma.data_format = value;
  8656. pr_debug("%s: format = %d\n", __func__, value);
  8657. return 0;
  8658. }
  8659. static int msm_dai_q6_cdc_dma_format_get(struct snd_kcontrol *kcontrol,
  8660. struct snd_ctl_elem_value *ucontrol)
  8661. {
  8662. struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
  8663. ucontrol->value.integer.value[0] =
  8664. dai_data->port_config.cdc_dma.data_format;
  8665. return 0;
  8666. }
  8667. static const struct snd_kcontrol_new cdc_dma_config_controls[] = {
  8668. SOC_ENUM_EXT("WSA_CDC_DMA_0 TX Format", cdc_dma_config_enum[0],
  8669. msm_dai_q6_cdc_dma_format_get,
  8670. msm_dai_q6_cdc_dma_format_put),
  8671. };
  8672. /* SOC probe for codec DMA interface */
  8673. static int msm_dai_q6_dai_cdc_dma_probe(struct snd_soc_dai *dai)
  8674. {
  8675. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  8676. int rc = 0;
  8677. if (!dai) {
  8678. pr_err("%s: Invalid params dai\n", __func__);
  8679. return -EINVAL;
  8680. }
  8681. if (!dai->dev) {
  8682. pr_err("%s: Invalid params dai dev\n", __func__);
  8683. return -EINVAL;
  8684. }
  8685. msm_dai_q6_set_dai_id(dai);
  8686. dai_data = dev_get_drvdata(dai->dev);
  8687. switch (dai->id) {
  8688. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  8689. rc = snd_ctl_add(dai->component->card->snd_card,
  8690. snd_ctl_new1(&cdc_dma_config_controls[0],
  8691. dai_data));
  8692. break;
  8693. default:
  8694. break;
  8695. }
  8696. if (rc < 0)
  8697. dev_err(dai->dev, "%s: err add config ctl, DAI = %s\n",
  8698. __func__, dai->name);
  8699. if (dai_data->is_island_dai)
  8700. rc = msm_dai_q6_add_island_mx_ctls(
  8701. dai->component->card->snd_card,
  8702. dai->name, dai->id,
  8703. (void *)dai_data);
  8704. rc = msm_dai_q6_dai_add_route(dai);
  8705. return rc;
  8706. }
  8707. static int msm_dai_q6_dai_cdc_dma_remove(struct snd_soc_dai *dai)
  8708. {
  8709. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  8710. dev_get_drvdata(dai->dev);
  8711. int rc = 0;
  8712. /* If AFE port is still up, close it */
  8713. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  8714. dev_dbg(dai->dev, "%s: stop codec dma port:%d\n", __func__,
  8715. dai->id);
  8716. rc = afe_close(dai->id); /* can block */
  8717. if (rc < 0)
  8718. dev_err(dai->dev, "fail to close AFE port\n");
  8719. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  8720. }
  8721. return rc;
  8722. }
  8723. static int msm_dai_q6_cdc_dma_set_channel_map(struct snd_soc_dai *dai,
  8724. unsigned int tx_num_ch, unsigned int *tx_ch_mask,
  8725. unsigned int rx_num_ch, unsigned int *rx_ch_mask)
  8726. {
  8727. int rc = 0;
  8728. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  8729. dev_get_drvdata(dai->dev);
  8730. unsigned int ch_mask = 0, ch_num = 0;
  8731. dev_dbg(dai->dev, "%s: id = %d\n", __func__, dai->id);
  8732. switch (dai->id) {
  8733. case AFE_PORT_ID_WSA_CODEC_DMA_RX_0:
  8734. case AFE_PORT_ID_WSA_CODEC_DMA_RX_1:
  8735. if (!rx_ch_mask) {
  8736. dev_err(dai->dev, "%s: invalid rx ch mask\n", __func__);
  8737. return -EINVAL;
  8738. }
  8739. if (rx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  8740. dev_err(dai->dev, "%s: invalid rx_num_ch %d\n",
  8741. __func__, rx_num_ch);
  8742. return -EINVAL;
  8743. }
  8744. ch_mask = *rx_ch_mask;
  8745. ch_num = rx_num_ch;
  8746. break;
  8747. case AFE_PORT_ID_WSA_CODEC_DMA_TX_0:
  8748. case AFE_PORT_ID_WSA_CODEC_DMA_TX_1:
  8749. case AFE_PORT_ID_WSA_CODEC_DMA_TX_2:
  8750. case AFE_PORT_ID_VA_CODEC_DMA_TX_0:
  8751. case AFE_PORT_ID_VA_CODEC_DMA_TX_1:
  8752. if (!tx_ch_mask) {
  8753. dev_err(dai->dev, "%s: invalid tx ch mask\n", __func__);
  8754. return -EINVAL;
  8755. }
  8756. if (tx_num_ch > AFE_PORT_MAX_AUDIO_CHAN_CNT) {
  8757. dev_err(dai->dev, "%s: invalid tx_num_ch %d\n",
  8758. __func__, tx_num_ch);
  8759. return -EINVAL;
  8760. }
  8761. ch_mask = *tx_ch_mask;
  8762. ch_num = tx_num_ch;
  8763. break;
  8764. default:
  8765. dev_err(dai->dev, "%s: invalid dai id %d\n", __func__, dai->id);
  8766. return -EINVAL;
  8767. }
  8768. dai_data->port_config.cdc_dma.active_channels_mask = ch_mask;
  8769. dev_dbg(dai->dev, "%s: CDC_DMA_%d_ch cnt[%d] ch mask[0x%x]\n", __func__,
  8770. dai->id, ch_num, ch_mask);
  8771. return rc;
  8772. }
  8773. static int msm_dai_q6_cdc_dma_hw_params(
  8774. struct snd_pcm_substream *substream,
  8775. struct snd_pcm_hw_params *params,
  8776. struct snd_soc_dai *dai)
  8777. {
  8778. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  8779. dev_get_drvdata(dai->dev);
  8780. switch (params_format(params)) {
  8781. case SNDRV_PCM_FORMAT_S16_LE:
  8782. case SNDRV_PCM_FORMAT_SPECIAL:
  8783. dai_data->port_config.cdc_dma.bit_width = 16;
  8784. break;
  8785. case SNDRV_PCM_FORMAT_S24_LE:
  8786. case SNDRV_PCM_FORMAT_S24_3LE:
  8787. dai_data->port_config.cdc_dma.bit_width = 24;
  8788. break;
  8789. case SNDRV_PCM_FORMAT_S32_LE:
  8790. dai_data->port_config.cdc_dma.bit_width = 32;
  8791. break;
  8792. default:
  8793. dev_err(dai->dev, "%s: format %d\n",
  8794. __func__, params_format(params));
  8795. return -EINVAL;
  8796. }
  8797. dai_data->rate = params_rate(params);
  8798. dai_data->channels = params_channels(params);
  8799. dai_data->port_config.cdc_dma.cdc_dma_cfg_minor_version =
  8800. AFE_API_VERSION_CODEC_DMA_CONFIG;
  8801. dai_data->port_config.cdc_dma.sample_rate = dai_data->rate;
  8802. dai_data->port_config.cdc_dma.num_channels = dai_data->channels;
  8803. dev_dbg(dai->dev, "%s: bit_wd[%hu] format[%hu]\n"
  8804. "num_channel %hu sample_rate %d\n", __func__,
  8805. dai_data->port_config.cdc_dma.bit_width,
  8806. dai_data->port_config.cdc_dma.data_format,
  8807. dai_data->port_config.cdc_dma.num_channels,
  8808. dai_data->rate);
  8809. return 0;
  8810. }
  8811. static int msm_dai_q6_cdc_dma_prepare(struct snd_pcm_substream *substream,
  8812. struct snd_soc_dai *dai)
  8813. {
  8814. struct msm_dai_q6_cdc_dma_dai_data *dai_data =
  8815. dev_get_drvdata(dai->dev);
  8816. int rc = 0;
  8817. if (!test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  8818. if (q6core_get_avcs_api_version_per_service(
  8819. APRV2_IDS_SERVICE_ID_ADSP_AFE_V) >= AFE_API_VERSION_V4) {
  8820. /*
  8821. * send island mode config.
  8822. * This should be the first configuration
  8823. */
  8824. rc = afe_send_port_island_mode(dai->id);
  8825. if (rc)
  8826. pr_err("%s: afe send island mode failed %d\n",
  8827. __func__, rc);
  8828. }
  8829. rc = afe_port_start(dai->id, &dai_data->port_config,
  8830. dai_data->rate);
  8831. if (rc < 0)
  8832. dev_err(dai->dev, "fail to open AFE port 0x%x\n",
  8833. dai->id);
  8834. else
  8835. set_bit(STATUS_PORT_STARTED,
  8836. dai_data->status_mask);
  8837. }
  8838. return rc;
  8839. }
  8840. static void msm_dai_q6_cdc_dma_shutdown(struct snd_pcm_substream *substream,
  8841. struct snd_soc_dai *dai)
  8842. {
  8843. struct msm_dai_q6_dai_data *dai_data = dev_get_drvdata(dai->dev);
  8844. int rc = 0;
  8845. if (test_bit(STATUS_PORT_STARTED, dai_data->status_mask)) {
  8846. dev_dbg(dai->dev, "%s: stop AFE port:%d\n", __func__,
  8847. dai->id);
  8848. rc = afe_close(dai->id); /* can block */
  8849. if (rc < 0)
  8850. dev_err(dai->dev, "fail to close AFE port\n");
  8851. dev_dbg(dai->dev, "%s: dai_data->status_mask = %ld\n", __func__,
  8852. *dai_data->status_mask);
  8853. clear_bit(STATUS_PORT_STARTED, dai_data->status_mask);
  8854. }
  8855. if (test_bit(STATUS_PORT_STARTED, dai_data->hwfree_status))
  8856. clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status);
  8857. }
  8858. static struct snd_soc_dai_ops msm_dai_q6_cdc_dma_ops = {
  8859. .prepare = msm_dai_q6_cdc_dma_prepare,
  8860. .hw_params = msm_dai_q6_cdc_dma_hw_params,
  8861. .shutdown = msm_dai_q6_cdc_dma_shutdown,
  8862. .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map,
  8863. };
  8864. static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = {
  8865. {
  8866. .playback = {
  8867. .stream_name = "WSA CDC DMA0 Playback",
  8868. .aif_name = "WSA_CDC_DMA_RX_0",
  8869. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  8870. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  8871. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  8872. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  8873. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  8874. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  8875. SNDRV_PCM_RATE_384000,
  8876. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8877. SNDRV_PCM_FMTBIT_S24_LE |
  8878. SNDRV_PCM_FMTBIT_S24_3LE |
  8879. SNDRV_PCM_FMTBIT_S32_LE,
  8880. .channels_min = 1,
  8881. .channels_max = 2,
  8882. .rate_min = 8000,
  8883. .rate_max = 384000,
  8884. },
  8885. .name = "WSA_CDC_DMA_RX_0",
  8886. .ops = &msm_dai_q6_cdc_dma_ops,
  8887. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0,
  8888. .probe = msm_dai_q6_dai_cdc_dma_probe,
  8889. .remove = msm_dai_q6_dai_cdc_dma_remove,
  8890. },
  8891. {
  8892. .capture = {
  8893. .stream_name = "WSA CDC DMA0 Capture",
  8894. .aif_name = "WSA_CDC_DMA_TX_0",
  8895. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  8896. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  8897. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  8898. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  8899. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  8900. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  8901. SNDRV_PCM_RATE_384000,
  8902. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8903. SNDRV_PCM_FMTBIT_S24_LE |
  8904. SNDRV_PCM_FMTBIT_S24_3LE |
  8905. SNDRV_PCM_FMTBIT_S32_LE,
  8906. .channels_min = 1,
  8907. .channels_max = 2,
  8908. .rate_min = 8000,
  8909. .rate_max = 384000,
  8910. },
  8911. .name = "WSA_CDC_DMA_TX_0",
  8912. .ops = &msm_dai_q6_cdc_dma_ops,
  8913. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0,
  8914. .probe = msm_dai_q6_dai_cdc_dma_probe,
  8915. .remove = msm_dai_q6_dai_cdc_dma_remove,
  8916. },
  8917. {
  8918. .playback = {
  8919. .stream_name = "WSA CDC DMA1 Playback",
  8920. .aif_name = "WSA_CDC_DMA_RX_1",
  8921. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  8922. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  8923. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  8924. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  8925. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  8926. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  8927. SNDRV_PCM_RATE_384000,
  8928. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8929. SNDRV_PCM_FMTBIT_S24_LE |
  8930. SNDRV_PCM_FMTBIT_S24_3LE |
  8931. SNDRV_PCM_FMTBIT_S32_LE,
  8932. .channels_min = 1,
  8933. .channels_max = 2,
  8934. .rate_min = 8000,
  8935. .rate_max = 384000,
  8936. },
  8937. .name = "WSA_CDC_DMA_RX_1",
  8938. .ops = &msm_dai_q6_cdc_dma_ops,
  8939. .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1,
  8940. .probe = msm_dai_q6_dai_cdc_dma_probe,
  8941. .remove = msm_dai_q6_dai_cdc_dma_remove,
  8942. },
  8943. {
  8944. .capture = {
  8945. .stream_name = "WSA CDC DMA1 Capture",
  8946. .aif_name = "WSA_CDC_DMA_TX_1",
  8947. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  8948. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  8949. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  8950. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  8951. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  8952. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  8953. SNDRV_PCM_RATE_384000,
  8954. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8955. SNDRV_PCM_FMTBIT_S24_LE |
  8956. SNDRV_PCM_FMTBIT_S24_3LE |
  8957. SNDRV_PCM_FMTBIT_S32_LE,
  8958. .channels_min = 1,
  8959. .channels_max = 2,
  8960. .rate_min = 8000,
  8961. .rate_max = 384000,
  8962. },
  8963. .name = "WSA_CDC_DMA_TX_1",
  8964. .ops = &msm_dai_q6_cdc_dma_ops,
  8965. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1,
  8966. .probe = msm_dai_q6_dai_cdc_dma_probe,
  8967. .remove = msm_dai_q6_dai_cdc_dma_remove,
  8968. },
  8969. {
  8970. .capture = {
  8971. .stream_name = "WSA CDC DMA2 Capture",
  8972. .aif_name = "WSA_CDC_DMA_TX_2",
  8973. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  8974. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  8975. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  8976. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  8977. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  8978. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  8979. SNDRV_PCM_RATE_384000,
  8980. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  8981. SNDRV_PCM_FMTBIT_S24_LE |
  8982. SNDRV_PCM_FMTBIT_S24_3LE |
  8983. SNDRV_PCM_FMTBIT_S32_LE,
  8984. .channels_min = 1,
  8985. .channels_max = 1,
  8986. .rate_min = 8000,
  8987. .rate_max = 384000,
  8988. },
  8989. .name = "WSA_CDC_DMA_TX_2",
  8990. .ops = &msm_dai_q6_cdc_dma_ops,
  8991. .id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2,
  8992. .probe = msm_dai_q6_dai_cdc_dma_probe,
  8993. .remove = msm_dai_q6_dai_cdc_dma_remove,
  8994. },
  8995. {
  8996. .capture = {
  8997. .stream_name = "VA CDC DMA0 Capture",
  8998. .aif_name = "VA_CDC_DMA_TX_0",
  8999. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9000. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9001. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9002. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9003. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9004. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9005. SNDRV_PCM_RATE_384000,
  9006. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9007. SNDRV_PCM_FMTBIT_S24_LE |
  9008. SNDRV_PCM_FMTBIT_S24_3LE,
  9009. .channels_min = 1,
  9010. .channels_max = 8,
  9011. .rate_min = 8000,
  9012. .rate_max = 384000,
  9013. },
  9014. .name = "VA_CDC_DMA_TX_0",
  9015. .ops = &msm_dai_q6_cdc_dma_ops,
  9016. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_0,
  9017. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9018. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9019. },
  9020. {
  9021. .capture = {
  9022. .stream_name = "VA CDC DMA1 Capture",
  9023. .aif_name = "VA_CDC_DMA_TX_1",
  9024. .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
  9025. SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
  9026. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
  9027. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |
  9028. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |
  9029. SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_352800 |
  9030. SNDRV_PCM_RATE_384000,
  9031. .formats = SNDRV_PCM_FMTBIT_S16_LE |
  9032. SNDRV_PCM_FMTBIT_S24_LE |
  9033. SNDRV_PCM_FMTBIT_S24_3LE,
  9034. .channels_min = 1,
  9035. .channels_max = 8,
  9036. .rate_min = 8000,
  9037. .rate_max = 384000,
  9038. },
  9039. .name = "VA_CDC_DMA_TX_1",
  9040. .ops = &msm_dai_q6_cdc_dma_ops,
  9041. .id = AFE_PORT_ID_VA_CODEC_DMA_TX_1,
  9042. .probe = msm_dai_q6_dai_cdc_dma_probe,
  9043. .remove = msm_dai_q6_dai_cdc_dma_remove,
  9044. },
  9045. };
  9046. static const struct snd_soc_component_driver msm_q6_cdc_dma_dai_component = {
  9047. .name = "msm-dai-cdc-dma-dev",
  9048. };
  9049. /* DT related probe for each codec DMA interface device */
  9050. static int msm_dai_q6_cdc_dma_dev_probe(struct platform_device *pdev)
  9051. {
  9052. const char *q6_cdc_dma_dev_id = "qcom,msm-dai-cdc-dma-dev-id";
  9053. u32 cdc_dma_id = 0;
  9054. int i;
  9055. int rc = 0;
  9056. struct msm_dai_q6_cdc_dma_dai_data *dai_data = NULL;
  9057. rc = of_property_read_u32(pdev->dev.of_node, q6_cdc_dma_dev_id,
  9058. &cdc_dma_id);
  9059. if (rc) {
  9060. dev_err(&pdev->dev,
  9061. "%s: missing 0x%x in dt node\n", __func__, cdc_dma_id);
  9062. return rc;
  9063. }
  9064. dev_dbg(&pdev->dev, "%s: dev name %s dev id 0x%x\n", __func__,
  9065. dev_name(&pdev->dev), cdc_dma_id);
  9066. pdev->id = cdc_dma_id;
  9067. dai_data = devm_kzalloc(&pdev->dev,
  9068. sizeof(struct msm_dai_q6_cdc_dma_dai_data),
  9069. GFP_KERNEL);
  9070. if (!dai_data)
  9071. return -ENOMEM;
  9072. rc = of_property_read_u32(pdev->dev.of_node,
  9073. "qcom,msm-dai-is-island-supported",
  9074. &dai_data->is_island_dai);
  9075. if (rc)
  9076. dev_dbg(&pdev->dev, "island supported entry not found\n");
  9077. dev_set_drvdata(&pdev->dev, dai_data);
  9078. for (i = 0; i < ARRAY_SIZE(msm_dai_q6_cdc_dma_dai); i++) {
  9079. if (msm_dai_q6_cdc_dma_dai[i].id == cdc_dma_id) {
  9080. return snd_soc_register_component(&pdev->dev,
  9081. &msm_q6_cdc_dma_dai_component,
  9082. &msm_dai_q6_cdc_dma_dai[i], 1);
  9083. }
  9084. }
  9085. return -ENODEV;
  9086. }
  9087. static int msm_dai_q6_cdc_dma_dev_remove(struct platform_device *pdev)
  9088. {
  9089. snd_soc_unregister_component(&pdev->dev);
  9090. return 0;
  9091. }
  9092. static const struct of_device_id msm_dai_q6_cdc_dma_dev_dt_match[] = {
  9093. { .compatible = "qcom,msm-dai-cdc-dma-dev", },
  9094. { }
  9095. };
  9096. MODULE_DEVICE_TABLE(of, msm_dai_q6_cdc_dma_dev_dt_match);
  9097. static struct platform_driver msm_dai_q6_cdc_dma_driver = {
  9098. .probe = msm_dai_q6_cdc_dma_dev_probe,
  9099. .remove = msm_dai_q6_cdc_dma_dev_remove,
  9100. .driver = {
  9101. .name = "msm-dai-cdc-dma-dev",
  9102. .owner = THIS_MODULE,
  9103. .of_match_table = msm_dai_q6_cdc_dma_dev_dt_match,
  9104. },
  9105. };
  9106. /* DT related probe for codec DMA interface device group */
  9107. static int msm_dai_cdc_dma_q6_probe(struct platform_device *pdev)
  9108. {
  9109. int rc;
  9110. rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
  9111. if (rc) {
  9112. dev_err(&pdev->dev, "%s: failed to add child nodes, rc=%d\n",
  9113. __func__, rc);
  9114. } else
  9115. dev_dbg(&pdev->dev, "%s: added child node\n", __func__);
  9116. return rc;
  9117. }
  9118. static int msm_dai_cdc_dma_q6_remove(struct platform_device *pdev)
  9119. {
  9120. of_platform_depopulate(&pdev->dev);
  9121. return 0;
  9122. }
  9123. static const struct of_device_id msm_dai_cdc_dma_dt_match[] = {
  9124. { .compatible = "qcom,msm-dai-cdc-dma", },
  9125. { }
  9126. };
  9127. MODULE_DEVICE_TABLE(of, msm_dai_cdc_dma_dt_match);
  9128. static struct platform_driver msm_dai_cdc_dma_q6 = {
  9129. .probe = msm_dai_cdc_dma_q6_probe,
  9130. .remove = msm_dai_cdc_dma_q6_remove,
  9131. .driver = {
  9132. .name = "msm-dai-cdc-dma",
  9133. .owner = THIS_MODULE,
  9134. .of_match_table = msm_dai_cdc_dma_dt_match,
  9135. },
  9136. };
  9137. int __init msm_dai_q6_init(void)
  9138. {
  9139. int rc;
  9140. rc = platform_driver_register(&msm_auxpcm_dev_driver);
  9141. if (rc) {
  9142. pr_err("%s: fail to register auxpcm dev driver", __func__);
  9143. goto fail;
  9144. }
  9145. rc = platform_driver_register(&msm_dai_q6);
  9146. if (rc) {
  9147. pr_err("%s: fail to register dai q6 driver", __func__);
  9148. goto dai_q6_fail;
  9149. }
  9150. rc = platform_driver_register(&msm_dai_q6_dev);
  9151. if (rc) {
  9152. pr_err("%s: fail to register dai q6 dev driver", __func__);
  9153. goto dai_q6_dev_fail;
  9154. }
  9155. rc = platform_driver_register(&msm_dai_q6_mi2s_driver);
  9156. if (rc) {
  9157. pr_err("%s: fail to register dai MI2S dev drv\n", __func__);
  9158. goto dai_q6_mi2s_drv_fail;
  9159. }
  9160. rc = platform_driver_register(&msm_dai_mi2s_q6);
  9161. if (rc) {
  9162. pr_err("%s: fail to register dai MI2S\n", __func__);
  9163. goto dai_mi2s_q6_fail;
  9164. }
  9165. rc = platform_driver_register(&msm_dai_q6_spdif_driver);
  9166. if (rc) {
  9167. pr_err("%s: fail to register dai SPDIF\n", __func__);
  9168. goto dai_spdif_q6_fail;
  9169. }
  9170. rc = platform_driver_register(&msm_dai_q6_tdm_driver);
  9171. if (rc) {
  9172. pr_err("%s: fail to register dai TDM dev drv\n", __func__);
  9173. goto dai_q6_tdm_drv_fail;
  9174. }
  9175. rc = platform_driver_register(&msm_dai_tdm_q6);
  9176. if (rc) {
  9177. pr_err("%s: fail to register dai TDM\n", __func__);
  9178. goto dai_tdm_q6_fail;
  9179. }
  9180. rc = platform_driver_register(&msm_dai_q6_cdc_dma_driver);
  9181. if (rc) {
  9182. pr_err("%s: fail to register dai CDC DMA dev\n", __func__);
  9183. goto dai_cdc_dma_q6_dev_fail;
  9184. }
  9185. rc = platform_driver_register(&msm_dai_cdc_dma_q6);
  9186. if (rc) {
  9187. pr_err("%s: fail to register dai CDC DMA\n", __func__);
  9188. goto dai_cdc_dma_q6_fail;
  9189. }
  9190. return rc;
  9191. dai_cdc_dma_q6_fail:
  9192. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  9193. dai_cdc_dma_q6_dev_fail:
  9194. platform_driver_unregister(&msm_dai_tdm_q6);
  9195. dai_tdm_q6_fail:
  9196. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  9197. dai_q6_tdm_drv_fail:
  9198. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  9199. dai_spdif_q6_fail:
  9200. platform_driver_unregister(&msm_dai_mi2s_q6);
  9201. dai_mi2s_q6_fail:
  9202. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  9203. dai_q6_mi2s_drv_fail:
  9204. platform_driver_unregister(&msm_dai_q6_dev);
  9205. dai_q6_dev_fail:
  9206. platform_driver_unregister(&msm_dai_q6);
  9207. dai_q6_fail:
  9208. platform_driver_unregister(&msm_auxpcm_dev_driver);
  9209. fail:
  9210. return rc;
  9211. }
  9212. void msm_dai_q6_exit(void)
  9213. {
  9214. platform_driver_unregister(&msm_dai_cdc_dma_q6);
  9215. platform_driver_unregister(&msm_dai_q6_cdc_dma_driver);
  9216. platform_driver_unregister(&msm_dai_tdm_q6);
  9217. platform_driver_unregister(&msm_dai_q6_tdm_driver);
  9218. platform_driver_unregister(&msm_dai_q6_spdif_driver);
  9219. platform_driver_unregister(&msm_dai_mi2s_q6);
  9220. platform_driver_unregister(&msm_dai_q6_mi2s_driver);
  9221. platform_driver_unregister(&msm_dai_q6_dev);
  9222. platform_driver_unregister(&msm_dai_q6);
  9223. platform_driver_unregister(&msm_auxpcm_dev_driver);
  9224. }
  9225. /* Module information */
  9226. MODULE_DESCRIPTION("MSM DSP DAI driver");
  9227. MODULE_LICENSE("GPL v2");