msm-dai-q6-v2.c 313 KB

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