msm-dai-q6-v2.c 266 KB

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