msm-dai-q6-v2.c 263 KB

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