msm-dai-q6-v2.c 330 KB

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