msm-dai-q6-v2.c 390 KB

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