1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105 |
- /* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- #include <linux/clk.h>
- #include <linux/delay.h>
- #include <linux/gpio.h>
- #include <linux/of_gpio.h>
- #include <linux/platform_device.h>
- #include <linux/slab.h>
- #include <linux/mfd/pm8xxx/pm8921.h>
- #include <linux/qpnp/clkdiv.h>
- #include <linux/regulator/consumer.h>
- #include <linux/io.h>
- #include <sound/core.h>
- #include <sound/soc.h>
- #include <sound/soc-dapm.h>
- #include <sound/pcm.h>
- #include <sound/jack.h>
- #include <sound/q6afe-v2.h>
- #include <sound/q6core.h>
- #include <sound/pcm_params.h>
- #include <asm/mach-types.h>
- #include <mach/subsystem_notif.h>
- #include "qdsp6v2/msm-pcm-routing-v2.h"
- #include "../codecs/wcd9xxx-common.h"
- #include "../codecs/wcd9320.h"
- #if defined(CONFIG_SND_SOC_ES705)
- #include "../codecs/audience/es705-export.h"
- #elif defined(CONFIG_SND_SOC_ES325)
- #include "../codecs/es325-export.h"
- #endif
- #define DRV_NAME "msm8974-asoc-taiko"
- #define MSM8974_SPK_ON 1
- #define MSM8974_SPK_OFF 0
- #define MSM_SLIM_0_RX_MAX_CHANNELS 2
- #define MSM_SLIM_0_TX_MAX_CHANNELS 4
- #define BTSCO_RATE_8KHZ 8000
- #define BTSCO_RATE_16KHZ 16000
- static int slim0_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
- static int slim0_tx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
- static int hdmi_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
- #define SAMPLING_RATE_48KHZ 48000
- #define SAMPLING_RATE_96KHZ 96000
- #define SAMPLING_RATE_192KHZ 192000
- static int msm8974_auxpcm_rate = 8000;
- #define LO_1_SPK_AMP 0x1
- #define LO_3_SPK_AMP 0x2
- #define LO_2_SPK_AMP 0x4
- #define LO_4_SPK_AMP 0x8
- #define I2S_PCM_SEL 1
- #define I2S_PCM_SEL_OFFSET 1
- #define WCD9XXX_MBHC_DEF_BUTTONS 3
- #define WCD9XXX_MBHC_DEF_RLOADS 5
- #define TAIKO_EXT_CLK_RATE 9600000
- /* It takes about 13ms for Class-D PAs to ramp-up */
- #define EXT_CLASS_D_EN_DELAY 13000
- #define EXT_CLASS_D_DIS_DELAY 3000
- #define EXT_CLASS_D_DELAY_DELTA 2000
- /* It takes about 13ms for Class-AB PAs to ramp-up */
- #define EXT_CLASS_AB_EN_DELAY 10000
- #define EXT_CLASS_AB_DIS_DELAY 1000
- #define EXT_CLASS_AB_DELAY_DELTA 1000
- #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98506)
- #if defined (CONFIG_TERT_MI2S_ENABLE)
- #define GPIO_TERT_MI2S_SCK 74
- #define GPIO_TERT_MI2S_WS 75
- #define GPIO_TERT_MI2S_DATA0 76
- #define GPIO_TERT_MI2S_DATA1 77
- #else
- #define GPIO_SECOND_MI2S_SCK 79
- #define GPIO_SECOND_MI2S_WS 80
- #define GPIO_SECOND_MI2S_DATA0 81
- #define GPIO_SECOND_MI2S_DATA1 82
- #endif
- #endif
- #define NUM_OF_AUXPCM_GPIOS 4
- static void *adsp_state_notifier;
- #define ADSP_STATE_READY_TIMEOUT_MS 50
- static inline int param_is_mask(int p)
- {
- return ((p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
- (p <= SNDRV_PCM_HW_PARAM_LAST_MASK));
- }
- static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p, int n)
- {
- return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
- }
- static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned bit)
- {
- if (bit >= SNDRV_MASK_MAX)
- return;
- if (param_is_mask(n)) {
- struct snd_mask *m = param_to_mask(p, n);
- m->bits[0] = 0;
- m->bits[1] = 0;
- m->bits[bit >> 5] |= (1 << (bit & 31));
- }
- }
- static const char *const auxpcm_rate_text[] = {"8000", "16000"};
- static const struct soc_enum msm8974_auxpcm_enum[] = {
- SOC_ENUM_SINGLE_EXT(2, auxpcm_rate_text),
- };
- void *def_taiko_mbhc_cal(void);
- static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
- bool dapm);
- static struct wcd9xxx_mbhc_config mbhc_cfg = {
- #if defined(CONFIG_MACH_KS01EUR) || defined(CONFIG_MACH_KS01SKT) || \
- defined(CONFIG_MACH_KS01KTT) || defined(CONFIG_MACH_KS01LGT)
- .read_fw_bin = false,
- #else
- .read_fw_bin = true,
- #endif
- .calibration = NULL,
- .micbias = MBHC_MICBIAS2,
- .anc_micbias = MBHC_MICBIAS2,
- .mclk_cb_fn = msm_snd_enable_codec_ext_clk,
- .mclk_rate = TAIKO_EXT_CLK_RATE,
- .gpio = 0,
- .gpio_irq = 0,
- .gpio_level_insert = 0,
- .detect_extn_cable = true,
- #if defined(CONFIG_SEC_FACTORY)
- /* Micbias for MBHC is always on in factory test */
- .micbias_enable_flags = (1 << MBHC_MICBIAS_ENABLE_THRESHOLD_HEADSET |
- 1 << MBHC_MICBIAS_ENABLE_REGULAR_HEADSET),
- #else
- .micbias_enable_flags = 1 << MBHC_MICBIAS_ENABLE_THRESHOLD_HEADSET,
- #endif
- .insert_detect = true,
- .swap_gnd_mic = NULL,
- #if (defined(CONFIG_MACH_KLTE_KOR) || defined(CONFIG_MACH_KLTE_JPN) || defined(CONFIG_MACH_KACTIVELTE_DCM) || defined(CONFIG_MACH_CHAGALL_KDI) || defined(CONFIG_MACH_KLIMT_LTE_DCM)) && !defined(CONFIG_SEC_FACTORY)
- .cs_enable_flags = (1 << MBHC_CS_ENABLE_POLLING),
- #else
- .cs_enable_flags = 0,
- #endif
- .do_recalibration = false,
- .use_vddio_meas = true,
- .enable_anc_mic_detect = false,
- .hw_jack_type = SIX_POLE_JACK,
- };
- struct msm_auxpcm_gpio {
- unsigned gpio_no;
- const char *gpio_name;
- };
- struct msm_auxpcm_ctrl {
- struct msm_auxpcm_gpio *pin_data;
- u32 cnt;
- void __iomem *mux;
- };
- struct msm8974_asoc_mach_data {
- int mclk_gpio;
- u32 mclk_freq;
- int us_euro_gpio;
- struct msm_auxpcm_ctrl *pri_auxpcm_ctrl;
- struct msm_auxpcm_ctrl *sec_auxpcm_ctrl;
- };
- #define GPIO_NAME_INDEX 0
- #define DT_PARSE_INDEX 1
- static char *msm_prim_auxpcm_gpio_name[][2] = {
- {"PRIM_AUXPCM_CLK", "qcom,prim-auxpcm-gpio-clk"},
- {"PRIM_AUXPCM_SYNC", "qcom,prim-auxpcm-gpio-sync"},
- {"PRIM_AUXPCM_DIN", "qcom,prim-auxpcm-gpio-din"},
- {"PRIM_AUXPCM_DOUT", "qcom,prim-auxpcm-gpio-dout"},
- };
- static char *msm_sec_auxpcm_gpio_name[][2] = {
- {"SEC_AUXPCM_CLK", "qcom,sec-auxpcm-gpio-clk"},
- {"SEC_AUXPCM_SYNC", "qcom,sec-auxpcm-gpio-sync"},
- {"SEC_AUXPCM_DIN", "qcom,sec-auxpcm-gpio-din"},
- {"SEC_AUXPCM_DOUT", "qcom,sec-auxpcm-gpio-dout"},
- };
- struct msm8974_liquid_dock_dev {
- int dock_plug_gpio;
- int dock_plug_irq;
- int dock_plug_det;
- struct snd_soc_dapm_context *dapm;
- struct work_struct irq_work;
- };
- static struct msm8974_liquid_dock_dev *msm8974_liquid_dock_dev;
- /* Shared channel numbers for Slimbus ports that connect APQ to MDM. */
- enum {
- SLIM_1_RX_1 = 145, /* BT-SCO and USB TX */
- SLIM_1_TX_1 = 146, /* BT-SCO and USB RX */
- SLIM_2_RX_1 = 147, /* HDMI RX */
- SLIM_3_RX_1 = 148, /* In-call recording RX */
- SLIM_3_RX_2 = 149, /* In-call recording RX */
- SLIM_4_TX_1 = 150, /* In-call musid delivery TX */
- };
- static struct platform_device *spdev;
- static struct regulator *ext_spk_amp_regulator;
- static int ext_spk_amp_gpio = -1;
- static int ext_ult_spk_amp_gpio = -1;
- static int ext_ult_lo_amp_gpio = -1;
- static int msm8974_spk_control = 1;
- static int msm8974_ext_spk_pamp;
- static int msm_slim_0_rx_ch = 1;
- static int msm_slim_0_tx_ch = 1;
- static int msm_btsco_rate = BTSCO_RATE_8KHZ;
- static int msm_btsco_ch = 1;
- static int msm_hdmi_rx_ch = 2;
- static int slim0_rx_sample_rate = SAMPLING_RATE_48KHZ;
- static int msm_proxy_rx_ch = 2;
- static int hdmi_rx_sample_rate = SAMPLING_RATE_48KHZ;
- static struct mutex cdc_mclk_mutex;
- static struct clk *codec_clk;
- static int clk_users;
- static atomic_t prim_auxpcm_rsc_ref;
- static atomic_t sec_auxpcm_rsc_ref;
- static int mainmic_bias_gpio = 0;
- static int micbias_en_msm_gpio = 0;
- #if defined(CONFIG_LDO_SUBMIC_BIAS)
- static int submic_bias_gpio = 0;
- #endif
- #if defined(CONFIG_LDO_EARMIC_BIAS)
- static int earmic_bias_gpio = 0;
- #endif
- static int spkamp_en_gpio = 0;
- static int main_mic_delay = 0;
- #ifdef CONFIG_SEC_JACTIVE_PROJECT
- static int ear_jack_fsa8038_en = 0;
- #endif
- #if defined(CONFIG_SEC_H_PROJECT)
- int speaker_status = 0;
- EXPORT_SYMBOL(speaker_status);
- #endif
- #if defined(CONFIG_MACH_KLTE_KOR) || defined(CONFIG_MACH_KLTE_JPN) || defined(CONFIG_MACH_KACTIVELTE_DCM) \
- || defined(CONFIG_MACH_CHAGALL_KDI) || defined(CONFIG_MACH_KLIMT_LTE_DCM) || defined(CONFIG_MACH_KACTIVELTE_KOR)
- static int fsa_en_gpio;
- #endif
- #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98506)
- struct request_gpio {
- unsigned gpio_no;
- char *gpio_name;
- };
- static struct request_gpio pri_mi2s_gpio[] = {
- #if defined (CONFIG_TERT_MI2S_ENABLE)
- {
- .gpio_no = GPIO_TERT_MI2S_SCK,
- .gpio_name = "TERT_MI2S_SCK",
- },
- {
- .gpio_no = GPIO_TERT_MI2S_WS,
- .gpio_name = "TERT_MI2S_WS",
- },
- {
- .gpio_no = GPIO_TERT_MI2S_DATA0,
- .gpio_name = "TERT_MI2S_DATA0",
- },
- {
- .gpio_no = GPIO_TERT_MI2S_DATA1,
- .gpio_name = "TERT_MI2S_DATA1",
- },
- #else
- {
- .gpio_no = GPIO_SECOND_MI2S_SCK,
- .gpio_name = "SECOND_MI2S_SCK",
- },
- {
- .gpio_no = GPIO_SECOND_MI2S_WS,
- .gpio_name = "SECOND_MI2S_WS",
- },
- {
- .gpio_no = GPIO_SECOND_MI2S_DATA0,
- .gpio_name = "SECOND_MI2S_DATA0",
- },
- {
- .gpio_no = GPIO_SECOND_MI2S_DATA1,
- .gpio_name = "SECOND_MI2S_DATA1",
- },
- #endif
- };
- /* MI2S clock */
- struct mi2s_clk {
- struct clk *core_clk;
- struct clk *osr_clk;
- struct clk *bit_clk;
- atomic_t mi2s_rsc_ref;
- };
- static struct mi2s_clk pri_mi2s_clk;
- #endif
- static int msm8974_liquid_ext_spk_power_amp_init(void)
- {
- int ret = 0;
- ext_spk_amp_gpio = of_get_named_gpio(spdev->dev.of_node,
- "qcom,ext-spk-amp-gpio", 0);
- if (ext_spk_amp_gpio >= 0) {
- ret = gpio_request(ext_spk_amp_gpio, "ext_spk_amp_gpio");
- if (ret) {
- pr_err("%s: gpio_request failed for ext_spk_amp_gpio.\n",
- __func__);
- return -EINVAL;
- }
- gpio_direction_output(ext_spk_amp_gpio, 0);
- if (ext_spk_amp_regulator == NULL) {
- ext_spk_amp_regulator = regulator_get(&spdev->dev,
- "qcom,ext-spk-amp");
- if (IS_ERR(ext_spk_amp_regulator)) {
- pr_err("%s: Cannot get regulator %s.\n",
- __func__, "qcom,ext-spk-amp");
- gpio_free(ext_spk_amp_gpio);
- return PTR_ERR(ext_spk_amp_regulator);
- }
- }
- }
- ext_ult_spk_amp_gpio = of_get_named_gpio(spdev->dev.of_node,
- "qcom,ext-ult-spk-amp-gpio", 0);
- if (ext_ult_spk_amp_gpio >= 0) {
- ret = gpio_request(ext_ult_spk_amp_gpio,
- "ext_ult_spk_amp_gpio");
- if (ret) {
- pr_err("%s: gpio_request failed for ext-ult_spk-amp-gpio.\n",
- __func__);
- return -EINVAL;
- }
- gpio_direction_output(ext_ult_spk_amp_gpio, 0);
- }
- return 0;
- }
- static void msm8974_liquid_ext_ult_spk_power_amp_enable(u32 on)
- {
- if (on) {
- if (regulator_enable(ext_spk_amp_regulator))
- pr_err("%s: enable failed ext_spk_amp_reg\n",
- __func__);
- gpio_direction_output(ext_ult_spk_amp_gpio, 1);
- /* time takes enable the external power class AB amplifier */
- usleep_range(EXT_CLASS_AB_EN_DELAY,
- EXT_CLASS_AB_EN_DELAY + EXT_CLASS_AB_DELAY_DELTA);
- } else {
- gpio_direction_output(ext_ult_spk_amp_gpio, 0);
- regulator_disable(ext_spk_amp_regulator);
- /* time takes disable the external power class AB amplifier */
- usleep_range(EXT_CLASS_AB_DIS_DELAY,
- EXT_CLASS_AB_DIS_DELAY + EXT_CLASS_AB_DELAY_DELTA);
- }
- pr_debug("%s: %s external ultrasound SPKR_DRV PAs.\n", __func__,
- on ? "Enable" : "Disable");
- }
- static void msm8974_liquid_ext_spk_power_amp_enable(u32 on)
- {
- if (on) {
- if (regulator_enable(ext_spk_amp_regulator))
- pr_err("%s: enable failed ext_spk_amp_reg\n",
- __func__);
- gpio_direction_output(ext_spk_amp_gpio, on);
- /*time takes enable the external power amplifier*/
- usleep_range(EXT_CLASS_D_EN_DELAY,
- EXT_CLASS_D_EN_DELAY + EXT_CLASS_D_DELAY_DELTA);
- } else {
- gpio_direction_output(ext_spk_amp_gpio, on);
- regulator_disable(ext_spk_amp_regulator);
- /*time takes disable the external power amplifier*/
- usleep_range(EXT_CLASS_D_DIS_DELAY,
- EXT_CLASS_D_DIS_DELAY + EXT_CLASS_D_DELAY_DELTA);
- }
- pr_debug("%s: %s external speaker PAs.\n", __func__,
- on ? "Enable" : "Disable");
- }
- static void msm8974_liquid_docking_irq_work(struct work_struct *work)
- {
- struct msm8974_liquid_dock_dev *dock_dev =
- container_of(work,
- struct msm8974_liquid_dock_dev,
- irq_work);
- struct snd_soc_dapm_context *dapm = dock_dev->dapm;
- mutex_lock(&dapm->codec->mutex);
- dock_dev->dock_plug_det =
- gpio_get_value(dock_dev->dock_plug_gpio);
- if (0 == dock_dev->dock_plug_det) {
- if ((msm8974_ext_spk_pamp & LO_1_SPK_AMP) &&
- (msm8974_ext_spk_pamp & LO_3_SPK_AMP) &&
- (msm8974_ext_spk_pamp & LO_2_SPK_AMP) &&
- (msm8974_ext_spk_pamp & LO_4_SPK_AMP))
- msm8974_liquid_ext_spk_power_amp_enable(1);
- } else {
- if ((msm8974_ext_spk_pamp & LO_1_SPK_AMP) &&
- (msm8974_ext_spk_pamp & LO_3_SPK_AMP) &&
- (msm8974_ext_spk_pamp & LO_2_SPK_AMP) &&
- (msm8974_ext_spk_pamp & LO_4_SPK_AMP))
- msm8974_liquid_ext_spk_power_amp_enable(0);
- }
- mutex_unlock(&dapm->codec->mutex);
- }
- static irqreturn_t msm8974_liquid_docking_irq_handler(int irq, void *dev)
- {
- struct msm8974_liquid_dock_dev *dock_dev = dev;
- /* switch speakers should not run in interrupt context */
- schedule_work(&dock_dev->irq_work);
- return IRQ_HANDLED;
- }
- static int msm8974_liquid_init_docking(struct snd_soc_dapm_context *dapm)
- {
- int ret = 0;
- int dock_plug_gpio = 0;
- /* plug in docking speaker+plug in device OR unplug one of them */
- u32 dock_plug_irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
- dock_plug_gpio = of_get_named_gpio(spdev->dev.of_node,
- "qcom,dock-plug-det-irq", 0);
- if (dock_plug_gpio >= 0) {
- msm8974_liquid_dock_dev =
- kzalloc(sizeof(*msm8974_liquid_dock_dev), GFP_KERNEL);
- if (!msm8974_liquid_dock_dev) {
- pr_err("msm8974_liquid_dock_dev alloc fail.\n");
- return -ENOMEM;
- }
- msm8974_liquid_dock_dev->dock_plug_gpio = dock_plug_gpio;
- ret = gpio_request(msm8974_liquid_dock_dev->dock_plug_gpio,
- "dock-plug-det-irq");
- if (ret) {
- pr_err("%s:failed request msm8974_liquid_dock_plug_gpio.\n",
- __func__);
- return -EINVAL;
- }
- msm8974_liquid_dock_dev->dock_plug_det =
- gpio_get_value(msm8974_liquid_dock_dev->dock_plug_gpio);
- msm8974_liquid_dock_dev->dock_plug_irq =
- gpio_to_irq(msm8974_liquid_dock_dev->dock_plug_gpio);
- msm8974_liquid_dock_dev->dapm = dapm;
- INIT_WORK(
- &msm8974_liquid_dock_dev->irq_work,
- msm8974_liquid_docking_irq_work);
- ret = request_irq(msm8974_liquid_dock_dev->dock_plug_irq,
- msm8974_liquid_docking_irq_handler,
- dock_plug_irq_flags,
- "liquid_dock_plug_irq",
- msm8974_liquid_dock_dev);
- }
- return 0;
- }
- #if !defined(CONFIG_MACH_VIENNA_LTE) && !defined(CONFIG_MACH_V2_LTE) && !defined(CONFIG_MACH_LT03_LTE) && !defined(CONFIG_MACH_PICASSO_LTE) && !defined(CONFIG_MACH_MONDRIAN) && !defined(CONFIG_MACH_CHAGALL) && !defined(CONFIG_MACH_KLIMT)
- static int msm8974_liquid_ext_spk_power_amp_on(u32 spk)
- {
- int rc;
- if (spk & (LO_1_SPK_AMP | LO_3_SPK_AMP | LO_2_SPK_AMP | LO_4_SPK_AMP)) {
- pr_debug("%s: External speakers are already on. spk = 0x%x\n",
- __func__, spk);
- msm8974_ext_spk_pamp |= spk;
- if ((msm8974_ext_spk_pamp & LO_1_SPK_AMP) &&
- (msm8974_ext_spk_pamp & LO_3_SPK_AMP) &&
- (msm8974_ext_spk_pamp & LO_2_SPK_AMP) &&
- (msm8974_ext_spk_pamp & LO_4_SPK_AMP))
- if (ext_spk_amp_gpio >= 0 &&
- msm8974_liquid_dock_dev &&
- msm8974_liquid_dock_dev->dock_plug_det == 0)
- msm8974_liquid_ext_spk_power_amp_enable(1);
- rc = 0;
- } else {
- pr_err("%s: Invalid external speaker ampl. spk = 0x%x\n",
- __func__, spk);
- rc = -EINVAL;
- }
- return rc;
- }
- static void msm8974_fluid_ext_us_amp_on(u32 spk)
- {
- if (!gpio_is_valid(ext_ult_lo_amp_gpio)) {
- pr_err("%s: ext_ult_lo_amp_gpio isn't configured\n", __func__);
- } else if (spk & (LO_1_SPK_AMP | LO_3_SPK_AMP)) {
- pr_debug("%s: External US amp is already on. spk = 0x%x\n",
- __func__, spk);
- msm8974_ext_spk_pamp |= spk;
- if ((msm8974_ext_spk_pamp & LO_1_SPK_AMP) &&
- (msm8974_ext_spk_pamp & LO_3_SPK_AMP))
- pr_debug("%s: Turn on US amp. spk = 0x%x\n",
- __func__, spk);
- gpio_direction_output(ext_ult_lo_amp_gpio, 1);
- } else {
- pr_err("%s: Invalid external speaker ampl. spk = 0x%x\n",
- __func__, spk);
- }
- }
- static void msm8974_fluid_ext_us_amp_off(u32 spk)
- {
- if (!gpio_is_valid(ext_ult_lo_amp_gpio)) {
- pr_err("%s: ext_ult_lo_amp_gpio isn't configured\n", __func__);
- } else if (spk & (LO_1_SPK_AMP | LO_3_SPK_AMP)) {
- pr_debug("%s LO1 and LO3. spk = 0x%x", __func__, spk);
- if (!msm8974_ext_spk_pamp) {
- pr_debug("%s: Turn off US amp. spk = 0x%x\n",
- __func__, spk);
- gpio_direction_output(ext_ult_lo_amp_gpio, 0);
- msm8974_ext_spk_pamp = 0;
- }
- } else {
- pr_err("%s: Invalid external speaker ampl. spk = 0x%x\n",
- __func__, spk);
- }
- }
- static void msm8974_ext_spk_power_amp_on(u32 spk)
- {
- if (gpio_is_valid(ext_spk_amp_gpio))
- msm8974_liquid_ext_spk_power_amp_on(spk);
- else if (gpio_is_valid(ext_ult_lo_amp_gpio))
- msm8974_fluid_ext_us_amp_on(spk);
- }
- static void msm8974_liquid_ext_spk_power_amp_off(u32 spk)
- {
- if (spk & (LO_1_SPK_AMP |
- LO_3_SPK_AMP |
- LO_2_SPK_AMP |
- LO_4_SPK_AMP)) {
- pr_debug("%s Left and right speakers case spk = 0x%08x",
- __func__, spk);
- msm8974_ext_spk_pamp &= ~spk;
- if (!msm8974_ext_spk_pamp) {
- if (ext_spk_amp_gpio >= 0 &&
- msm8974_liquid_dock_dev != NULL &&
- msm8974_liquid_dock_dev->dock_plug_det == 0)
- msm8974_liquid_ext_spk_power_amp_enable(0);
- }
- } else {
- pr_err("%s: ERROR : Invalid Ext Spk Ampl. spk = 0x%08x\n",
- __func__, spk);
- return;
- }
- }
- static void msm8974_ext_spk_power_amp_off(u32 spk)
- {
- if (gpio_is_valid(ext_spk_amp_gpio))
- msm8974_liquid_ext_spk_power_amp_off(spk);
- else if (gpio_is_valid(ext_ult_lo_amp_gpio))
- msm8974_fluid_ext_us_amp_off(spk);
- }
- #endif
- static void msm8974_ext_control(struct snd_soc_codec *codec)
- {
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- mutex_lock(&dapm->codec->mutex);
- pr_debug("%s: msm8974_spk_control = %d", __func__, msm8974_spk_control);
- if (msm8974_spk_control == MSM8974_SPK_ON) {
- snd_soc_dapm_enable_pin(dapm, "Lineout_1 amp");
- snd_soc_dapm_enable_pin(dapm, "Lineout_3 amp");
- snd_soc_dapm_enable_pin(dapm, "Lineout_2 amp");
- snd_soc_dapm_enable_pin(dapm, "Lineout_4 amp");
- } else {
- snd_soc_dapm_disable_pin(dapm, "Lineout_1 amp");
- snd_soc_dapm_disable_pin(dapm, "Lineout_3 amp");
- snd_soc_dapm_disable_pin(dapm, "Lineout_2 amp");
- snd_soc_dapm_disable_pin(dapm, "Lineout_4 amp");
- }
- snd_soc_dapm_sync(dapm);
- mutex_unlock(&dapm->codec->mutex);
- }
- static int msm8974_get_spk(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm8974_spk_control = %d", __func__, msm8974_spk_control);
- ucontrol->value.integer.value[0] = msm8974_spk_control;
- return 0;
- }
- static int msm8974_set_spk(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
- pr_debug("%s()\n", __func__);
- if (msm8974_spk_control == ucontrol->value.integer.value[0])
- return 0;
- msm8974_spk_control = ucontrol->value.integer.value[0];
- msm8974_ext_control(codec);
- return 1;
- }
- #if !defined(CONFIG_MACH_VIENNA_LTE) && !defined(CONFIG_MACH_V2_LTE) && !defined(CONFIG_MACH_LT03_LTE) && !defined(CONFIG_MACH_PICASSO_LTE) && !defined(CONFIG_MACH_MONDRIAN) && !defined(CONFIG_MACH_CHAGALL) && !defined(CONFIG_MACH_KLIMT)
- static int msm_ext_spkramp_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *k, int event)
- {
- pr_debug("%s()\n", __func__);
- if (SND_SOC_DAPM_EVENT_ON(event)) {
- if (!strncmp(w->name, "Lineout_1 amp", 14))
- msm8974_ext_spk_power_amp_on(LO_1_SPK_AMP);
- else if (!strncmp(w->name, "Lineout_3 amp", 14))
- msm8974_ext_spk_power_amp_on(LO_3_SPK_AMP);
- else if (!strncmp(w->name, "Lineout_2 amp", 14))
- msm8974_ext_spk_power_amp_on(LO_2_SPK_AMP);
- else if (!strncmp(w->name, "Lineout_4 amp", 14))
- msm8974_ext_spk_power_amp_on(LO_4_SPK_AMP);
- else {
- pr_err("%s() Invalid Speaker Widget = %s\n",
- __func__, w->name);
- return -EINVAL;
- }
- } else {
- if (!strncmp(w->name, "Lineout_1 amp", 14))
- msm8974_ext_spk_power_amp_off(LO_1_SPK_AMP);
- else if (!strncmp(w->name, "Lineout_3 amp", 14))
- msm8974_ext_spk_power_amp_off(LO_3_SPK_AMP);
- else if (!strncmp(w->name, "Lineout_2 amp", 14))
- msm8974_ext_spk_power_amp_off(LO_2_SPK_AMP);
- else if (!strncmp(w->name, "Lineout_4 amp", 14))
- msm8974_ext_spk_power_amp_off(LO_4_SPK_AMP);
- else {
- pr_err("%s() Invalid Speaker Widget = %s\n",
- __func__, w->name);
- return -EINVAL;
- }
- }
- return 0;
- }
- #else
- static int msm_ext_spkramp_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *k, int event)
- {
- pr_info("%s() : control =%d\n", __func__, event);
- gpio_direction_output(spkamp_en_gpio,
- SND_SOC_DAPM_EVENT_ON(event));
- return 0;
- }
- #endif
- static int msm_ext_spkramp_ultrasound_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *k, int event)
- {
- pr_debug("%s()\n", __func__);
- if (!strncmp(w->name, "SPK_ultrasound amp", 19)) {
- if (!gpio_is_valid(ext_ult_spk_amp_gpio)) {
- pr_err("%s: ext_ult_spk_amp_gpio isn't configured\n",
- __func__);
- return -EINVAL;
- }
- if (SND_SOC_DAPM_EVENT_ON(event))
- msm8974_liquid_ext_ult_spk_power_amp_enable(1);
- else
- msm8974_liquid_ext_ult_spk_power_amp_enable(0);
- } else {
- pr_err("%s() Invalid Speaker Widget = %s\n",
- __func__, w->name);
- return -EINVAL;
- }
- return 0;
- }
- static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec, int enable,
- bool dapm)
- {
- int ret = 0;
- pr_debug("%s: enable = %d clk_users = %d\n",
- __func__, enable, clk_users);
- mutex_lock(&cdc_mclk_mutex);
- if (enable) {
- if (!codec_clk) {
- dev_err(codec->dev, "%s: did not get Taiko MCLK\n",
- __func__);
- ret = -EINVAL;
- goto exit;
- }
- clk_users++;
- if (clk_users != 1)
- goto exit;
- if (codec_clk) {
- clk_prepare_enable(codec_clk);
- taiko_mclk_enable(codec, 1, dapm);
- } else {
- pr_err("%s: Error setting Taiko MCLK\n", __func__);
- clk_users--;
- goto exit;
- }
- } else {
- if (clk_users > 0) {
- clk_users--;
- if (clk_users == 0) {
- taiko_mclk_enable(codec, 0, dapm);
- clk_disable_unprepare(codec_clk);
- }
- } else {
- pr_err("%s: Error releasing Taiko MCLK\n", __func__);
- ret = -EINVAL;
- goto exit;
- }
- }
- exit:
- mutex_unlock(&cdc_mclk_mutex);
- return ret;
- }
- static int msm8974_mclk_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
- {
- pr_debug("%s: event = %d\n", __func__, event);
- switch (event) {
- case SND_SOC_DAPM_PRE_PMU:
- return msm_snd_enable_codec_ext_clk(w->codec, 1, true);
- case SND_SOC_DAPM_POST_PMD:
- return msm_snd_enable_codec_ext_clk(w->codec, 0, true);
- }
- return 0;
- }
- #if !defined(CONFIG_SEC_KS01_PROJECT)
- static int msm_mainmic_bias_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *k, int event)
- {
- pr_info("%s : Event %d, SND_SOC_DAPM:%d\n",
- __func__, (event), SND_SOC_DAPM_EVENT_ON(event));
- if (mainmic_bias_gpio < 0) {
- gpio_set_value_cansleep(micbias_en_msm_gpio,
- SND_SOC_DAPM_EVENT_ON(event));
- } else {
- gpio_direction_output(mainmic_bias_gpio,
- SND_SOC_DAPM_EVENT_ON(event));
- }
- if(main_mic_delay) {
- if(main_mic_delay != 100)
- main_mic_delay *= 50;
- msleep(main_mic_delay);
- pr_info("%s: main_mic_delay = %d\n", __func__, main_mic_delay);
- main_mic_delay = 0;
- }
- return 0;
- }
- #endif
- #if defined(CONFIG_LDO_SUBMIC_BIAS)
- static int msm_submic_bias_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *k, int event)
- {
- pr_info("%s : Event %d, SND_SOC_DAPM:%d\n",
- __func__, (event), SND_SOC_DAPM_EVENT_ON(event));
- gpio_direction_output(submic_bias_gpio,
- SND_SOC_DAPM_EVENT_ON(event));
- return 0;
- }
- #endif
- #if defined(CONFIG_LDO_EARMIC_BIAS)
- static int msm_earmic_bias_event(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *k, int event)
- {
- pr_info("%s : Event %d, SND_SOC_DAPM:%d\n",
- __func__, (event), SND_SOC_DAPM_EVENT_ON(event));
- gpio_direction_output(earmic_bias_gpio,
- SND_SOC_DAPM_EVENT_ON(event));
- return 0;
- }
- #endif
- #ifdef CONFIG_SEC_K_PROJECT
- static const struct snd_soc_dapm_widget msm8974_dapm_widgets[] = {
- SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
- msm8974_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SPK("Lineout_1 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_3 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_2 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_4 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("SPK_ultrasound amp",
- msm_ext_spkramp_ultrasound_event),
- SND_SOC_DAPM_MIC("Handset Mic", NULL),
- SND_SOC_DAPM_MIC("Headset Mic", NULL),
- SND_SOC_DAPM_MIC("ANCRight Headset Mic", NULL),
- SND_SOC_DAPM_MIC("ANCLeft Headset Mic", NULL),
- SND_SOC_DAPM_MIC("Analog Mic4", NULL),
- SND_SOC_DAPM_MIC("Analog Mic6", NULL),
- SND_SOC_DAPM_MIC("Analog Mic7", NULL),
- SND_SOC_DAPM_MIC("Digital Mic1", NULL),
- SND_SOC_DAPM_MIC("Main Mic", msm_mainmic_bias_event),
- SND_SOC_DAPM_MIC("Digital Mic3", NULL),
- SND_SOC_DAPM_MIC("Sub Mic", NULL),
- SND_SOC_DAPM_MIC("Digital Mic5", NULL),
- SND_SOC_DAPM_MIC("Third Mic", NULL),
- };
- #elif defined (CONFIG_SEC_JACTIVE_PROJECT)
- static const struct snd_soc_dapm_widget msm8974_dapm_widgets_01[] = {
- SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
- msm8974_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SPK("Lineout_1 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_3 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_2 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_4 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("SPK_ultrasound amp",
- msm_ext_spkramp_ultrasound_event),
- SND_SOC_DAPM_MIC("Main Mic", NULL),
- SND_SOC_DAPM_MIC("Headset Mic", NULL),
- SND_SOC_DAPM_MIC("Sub Mic", NULL),
- SND_SOC_DAPM_MIC("Third Mic", NULL),
- SND_SOC_DAPM_MIC("Digital Mic1", NULL),
- SND_SOC_DAPM_MIC("Digital Mic2", NULL),
- SND_SOC_DAPM_MIC("Digital Mic3", NULL),
- SND_SOC_DAPM_MIC("Digital Mic4", NULL),
- SND_SOC_DAPM_MIC("Digital Mic5", NULL),
- SND_SOC_DAPM_MIC("Digital Mic6", NULL),
- };
- static const struct snd_soc_dapm_widget msm8974_dapm_widgets[] = {
- SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
- msm8974_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SPK("Lineout_1 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_3 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_2 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_4 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("SPK_ultrasound amp",
- msm_ext_spkramp_ultrasound_event),
- SND_SOC_DAPM_MIC("Main Mic", msm_mainmic_bias_event),
- SND_SOC_DAPM_MIC("Headset Mic", NULL),
- SND_SOC_DAPM_MIC("Sub Mic", NULL),
- SND_SOC_DAPM_MIC("Third Mic", NULL),
- SND_SOC_DAPM_MIC("Digital Mic1", NULL),
- SND_SOC_DAPM_MIC("Digital Mic2", NULL),
- SND_SOC_DAPM_MIC("Digital Mic3", NULL),
- SND_SOC_DAPM_MIC("Digital Mic4", NULL),
- SND_SOC_DAPM_MIC("Digital Mic5", NULL),
- SND_SOC_DAPM_MIC("Digital Mic6", NULL),
- };
- #else
- static const struct snd_soc_dapm_widget msm8974_dapm_widgets[] = {
- SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0,
- msm8974_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SPK("Lineout_1 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_3 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_2 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("Lineout_4 amp", msm_ext_spkramp_event),
- SND_SOC_DAPM_SPK("SPK_ultrasound amp",
- msm_ext_spkramp_ultrasound_event),
- #if defined(CONFIG_SEC_KS01_PROJECT)
- SND_SOC_DAPM_MIC("Main Mic", NULL),
- #else
- SND_SOC_DAPM_MIC("Main Mic", msm_mainmic_bias_event),
- #endif
- #if defined(CONFIG_LDO_EARMIC_BIAS)
- SND_SOC_DAPM_MIC("Headset Mic", msm_earmic_bias_event),
- #else
- SND_SOC_DAPM_MIC("Headset Mic", NULL),
- #endif
- #if defined(CONFIG_LDO_SUBMIC_BIAS)
- SND_SOC_DAPM_MIC("Sub Mic", msm_submic_bias_event),
- #else
- SND_SOC_DAPM_MIC("Sub Mic", NULL),
- #endif
- SND_SOC_DAPM_MIC("Third Mic", NULL),
- SND_SOC_DAPM_MIC("Digital Mic1", NULL),
- SND_SOC_DAPM_MIC("Digital Mic2", NULL),
- SND_SOC_DAPM_MIC("Digital Mic3", NULL),
- SND_SOC_DAPM_MIC("Digital Mic4", NULL),
- SND_SOC_DAPM_MIC("Digital Mic5", NULL),
- SND_SOC_DAPM_MIC("Digital Mic6", NULL),
- };
- #endif
- static const char *const spk_function[] = {"Off", "On"};
- static const char *const slim0_rx_ch_text[] = {"One", "Two"};
- static const char *const slim0_tx_ch_text[] = {"One", "Two", "Three", "Four",
- "Five", "Six", "Seven",
- "Eight"};
- static char const *hdmi_rx_ch_text[] = {"Two", "Three", "Four", "Five",
- "Six", "Seven", "Eight"};
- static char const *rx_bit_format_text[] = {"S16_LE", "S24_LE"};
- static char const *slim0_rx_sample_rate_text[] = {"KHZ_48", "KHZ_96",
- "KHZ_192"};
- static const char *const proxy_rx_ch_text[] = {"One", "Two", "Three", "Four",
- "Five", "Six", "Seven", "Eight"};
- static char const *hdmi_rx_sample_rate_text[] = {"KHZ_48", "KHZ_96",
- "KHZ_192"};
- static const char *const btsco_rate_text[] = {"8000", "16000"};
- static const struct soc_enum msm_btsco_enum[] = {
- SOC_ENUM_SINGLE_EXT(2, btsco_rate_text),
- };
- static int slim0_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int sample_rate_val = 0;
- switch (slim0_rx_sample_rate) {
- case SAMPLING_RATE_192KHZ:
- sample_rate_val = 2;
- break;
- case SAMPLING_RATE_96KHZ:
- sample_rate_val = 1;
- break;
- case SAMPLING_RATE_48KHZ:
- default:
- sample_rate_val = 0;
- break;
- }
- ucontrol->value.integer.value[0] = sample_rate_val;
- pr_debug("%s: slim0_rx_sample_rate = %d\n", __func__,
- slim0_rx_sample_rate);
- return 0;
- }
- static int slim0_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: ucontrol value = %ld\n", __func__,
- ucontrol->value.integer.value[0]);
- switch (ucontrol->value.integer.value[0]) {
- case 2:
- slim0_rx_sample_rate = SAMPLING_RATE_192KHZ;
- break;
- case 1:
- slim0_rx_sample_rate = SAMPLING_RATE_96KHZ;
- break;
- case 0:
- default:
- slim0_rx_sample_rate = SAMPLING_RATE_48KHZ;
- }
- pr_info("%s: slim0_rx_sample_rate = %d\n", __func__,
- slim0_rx_sample_rate);
- return 0;
- }
- static int slim0_rx_bit_format_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (slim0_rx_bit_format) {
- case SNDRV_PCM_FORMAT_S24_LE:
- ucontrol->value.integer.value[0] = 1;
- break;
- case SNDRV_PCM_FORMAT_S16_LE:
- default:
- ucontrol->value.integer.value[0] = 0;
- break;
- }
- pr_debug("%s: slim0_rx_bit_format = %d, ucontrol value = %ld\n",
- __func__, slim0_rx_bit_format,
- ucontrol->value.integer.value[0]);
- return 0;
- }
- static int slim0_rx_bit_format_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (ucontrol->value.integer.value[0]) {
- case 1:
- slim0_rx_bit_format = SNDRV_PCM_FORMAT_S24_LE;
- break;
- case 0:
- default:
- slim0_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
- break;
- }
- return 0;
- }
- static int msm_slim_0_rx_ch_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
- msm_slim_0_rx_ch);
- ucontrol->value.integer.value[0] = msm_slim_0_rx_ch - 1;
- return 0;
- }
- static int msm_slim_0_rx_ch_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- msm_slim_0_rx_ch = ucontrol->value.integer.value[0] + 1;
- pr_debug("%s: msm_slim_0_rx_ch = %d\n", __func__,
- msm_slim_0_rx_ch);
- return 1;
- }
- static int msm_slim_0_tx_ch_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__,
- msm_slim_0_tx_ch);
- ucontrol->value.integer.value[0] = msm_slim_0_tx_ch - 1;
- return 0;
- }
- static int msm_slim_0_tx_ch_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- msm_slim_0_tx_ch = ucontrol->value.integer.value[0] + 1;
- pr_debug("%s: msm_slim_0_tx_ch = %d\n", __func__, msm_slim_0_tx_ch);
- return 1;
- }
- static int msm_btsco_rate_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm_btsco_rate = %d", __func__, msm_btsco_rate);
- ucontrol->value.integer.value[0] = msm_btsco_rate;
- return 0;
- }
- static int msm_btsco_rate_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (ucontrol->value.integer.value[0]) {
- case 0:
- msm_btsco_rate = BTSCO_RATE_8KHZ;
- break;
- case 1:
- msm_btsco_rate = BTSCO_RATE_16KHZ;
- break;
- default:
- msm_btsco_rate = BTSCO_RATE_8KHZ;
- break;
- }
- pr_debug("%s: msm_btsco_rate = %d\n", __func__, msm_btsco_rate);
- return 0;
- }
- static int hdmi_rx_bit_format_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (hdmi_rx_bit_format) {
- case SNDRV_PCM_FORMAT_S24_LE:
- ucontrol->value.integer.value[0] = 1;
- break;
- case SNDRV_PCM_FORMAT_S16_LE:
- default:
- ucontrol->value.integer.value[0] = 0;
- break;
- }
- pr_debug("%s: hdmi_rx_bit_format = %d, ucontrol value = %ld\n",
- __func__, hdmi_rx_bit_format,
- ucontrol->value.integer.value[0]);
- return 0;
- }
- static int hdmi_rx_bit_format_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (ucontrol->value.integer.value[0]) {
- case 1:
- hdmi_rx_bit_format = SNDRV_PCM_FORMAT_S24_LE;
- break;
- case 0:
- default:
- hdmi_rx_bit_format = SNDRV_PCM_FORMAT_S16_LE;
- break;
- }
- pr_debug("%s: hdmi_rx_bit_format = %d, ucontrol value = %ld\n",
- __func__, hdmi_rx_bit_format,
- ucontrol->value.integer.value[0]);
- return 0;
- }
- static int msm_hdmi_rx_ch_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm_hdmi_rx_ch = %d\n", __func__,
- msm_hdmi_rx_ch);
- ucontrol->value.integer.value[0] = msm_hdmi_rx_ch - 2;
- return 0;
- }
- static int msm_hdmi_rx_ch_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- msm_hdmi_rx_ch = ucontrol->value.integer.value[0] + 2;
- if (msm_hdmi_rx_ch > 8) {
- pr_err("%s: channels exceeded 8.Limiting to max channels-8\n",
- __func__);
- msm_hdmi_rx_ch = 8;
- }
- pr_debug("%s: msm_hdmi_rx_ch = %d\n", __func__, msm_hdmi_rx_ch);
- return 1;
- }
- static int hdmi_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- int sample_rate_val = 0;
- switch (hdmi_rx_sample_rate) {
- case SAMPLING_RATE_192KHZ:
- sample_rate_val = 2;
- break;
- case SAMPLING_RATE_96KHZ:
- sample_rate_val = 1;
- break;
- case SAMPLING_RATE_48KHZ:
- default:
- sample_rate_val = 0;
- break;
- }
- ucontrol->value.integer.value[0] = sample_rate_val;
- pr_debug("%s: hdmi_rx_sample_rate = %d\n", __func__,
- hdmi_rx_sample_rate);
- return 0;
- }
- static int hdmi_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: ucontrol value = %ld\n", __func__,
- ucontrol->value.integer.value[0]);
- switch (ucontrol->value.integer.value[0]) {
- case 2:
- hdmi_rx_sample_rate = SAMPLING_RATE_192KHZ;
- break;
- case 1:
- hdmi_rx_sample_rate = SAMPLING_RATE_96KHZ;
- break;
- case 0:
- default:
- hdmi_rx_sample_rate = SAMPLING_RATE_48KHZ;
- }
- pr_debug("%s: hdmi_rx_sample_rate = %d\n", __func__,
- hdmi_rx_sample_rate);
- return 0;
- }
- static const struct snd_kcontrol_new int_btsco_rate_mixer_controls[] = {
- SOC_ENUM_EXT("Internal BTSCO SampleRate", msm_btsco_enum[0],
- msm_btsco_rate_get, msm_btsco_rate_put),
- };
- static int msm_btsco_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_CHANNELS);
- rate->min = rate->max = msm_btsco_rate;
- channels->min = channels->max = msm_btsco_ch;
- return 0;
- }
- static int msm8974_auxpcm_rate_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- ucontrol->value.integer.value[0] = msm8974_auxpcm_rate;
- return 0;
- }
- static int msm8974_auxpcm_rate_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- switch (ucontrol->value.integer.value[0]) {
- case 0:
- msm8974_auxpcm_rate = 8000;
- msm_btsco_rate = BTSCO_RATE_8KHZ;
- break;
- case 1:
- msm8974_auxpcm_rate = 16000;
- msm_btsco_rate = BTSCO_RATE_16KHZ;
- break;
- default:
- msm8974_auxpcm_rate = 8000;
- msm_btsco_rate = BTSCO_RATE_8KHZ;
- break;
- }
- pr_info("%s: BT sample rate = %d ====\n",__func__, msm8974_auxpcm_rate);
- return 0;
- }
- static int main_mic_delay_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: main_mic_delay = %d\n", __func__,
- main_mic_delay);
- ucontrol->value.integer.value[0] = main_mic_delay;
- return 0;
- }
- static int main_mic_delay_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- main_mic_delay = ucontrol->value.integer.value[0];
- pr_debug("%s: main_mic_delay = %d\n", __func__,
- main_mic_delay);
- return 1;
- }
- #if defined(CONFIG_SEC_H_PROJECT)
- static int speaker_status_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_info("%s: speaker_status = %d\n", __func__, speaker_status);
- ucontrol->value.integer.value[0] = speaker_status;
- return 0;
- }
- static int speaker_status_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- speaker_status = ucontrol->value.integer.value[0];
- pr_info("%s: speaker_status = %d\n", __func__, speaker_status);
- return 1;
- }
- #endif
- static int msm_proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- pr_debug("%s: msm_proxy_rx_ch = %d\n", __func__,
- msm_proxy_rx_ch);
- ucontrol->value.integer.value[0] = msm_proxy_rx_ch - 1;
- return 0;
- }
- static int msm_proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
- {
- msm_proxy_rx_ch = ucontrol->value.integer.value[0] + 1;
- pr_debug("%s: msm_proxy_rx_ch = %d\n", __func__,
- msm_proxy_rx_ch);
- return 1;
- }
- static int msm_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- rate->min = rate->max = msm8974_auxpcm_rate;
- channels->min = channels->max = 1;
- return 0;
- }
- #if defined( CONFIG_PCM_ROUTE_VOICE_STUB ) || defined(CONFIG_BT_CALL_FORWARDING)
- static int msm_auxpcm2_be_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- rate->min = rate->max = 8000;
- channels->min = channels->max = 1;
- return 0;
- }
- #endif
- static int msm_proxy_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_CHANNELS);
- pr_debug("%s: msm_proxy_rx_ch =%d\n", __func__, msm_proxy_rx_ch);
- if (channels->max < 2)
- channels->min = channels->max = 2;
- channels->min = channels->max = msm_proxy_rx_ch;
- rate->min = rate->max = 48000;
- return 0;
- }
- static int msm_proxy_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- rate->min = rate->max = 48000;
- return 0;
- }
- static int msm8974_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_CHANNELS);
- pr_info("%s channels->min %u channels->max %u ()\n", __func__,
- channels->min, channels->max);
- param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
- hdmi_rx_bit_format);
- if (channels->max < 2)
- channels->min = channels->max = 2;
- rate->min = rate->max = hdmi_rx_sample_rate;
- if (channels->min != channels->max)
- channels->min = channels->max;
- return 0;
- }
- static int msm_aux_pcm_get_gpios(struct msm_auxpcm_ctrl *auxpcm_ctrl)
- {
- struct msm_auxpcm_gpio *pin_data = NULL;
- int ret = 0;
- int i;
- int j;
- pin_data = auxpcm_ctrl->pin_data;
- for (i = 0; i < auxpcm_ctrl->cnt; i++, pin_data++) {
- ret = gpio_request(pin_data->gpio_no,
- pin_data->gpio_name);
- pr_debug("%s: gpio = %d, gpio name = %s\n"
- "ret = %d\n", __func__,
- pin_data->gpio_no,
- pin_data->gpio_name,
- ret);
- if (ret) {
- pr_err("%s: Failed to request gpio %d\n",
- __func__, pin_data->gpio_no);
- /* Release all GPIOs on failure */
- for (j = i; j >= 0; j--)
- gpio_free(pin_data->gpio_no);
- return ret;
- }
- }
- return 0;
- }
- static int msm_aux_pcm_free_gpios(struct msm_auxpcm_ctrl *auxpcm_ctrl)
- {
- struct msm_auxpcm_gpio *pin_data = NULL;
- int i;
- int ret = 0;
- if (auxpcm_ctrl == NULL || auxpcm_ctrl->pin_data == NULL) {
- pr_err("%s: Ctrl pointers are NULL\n", __func__);
- ret = -EINVAL;
- goto err;
- }
- pin_data = auxpcm_ctrl->pin_data;
- for (i = 0; i < auxpcm_ctrl->cnt; i++, pin_data++) {
- gpio_free(pin_data->gpio_no);
- pr_debug("%s: gpio = %d, gpio_name = %s\n",
- __func__, pin_data->gpio_no,
- pin_data->gpio_name);
- }
- err:
- return ret;
- }
- static int msm_prim_auxpcm_startup(struct snd_pcm_substream *substream)
- {
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_card *card = rtd->card;
- struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
- struct msm_auxpcm_ctrl *auxpcm_ctrl = NULL;
- int ret = 0;
- pr_debug("%s(): substream = %s, prim_auxpcm_rsc_ref counter = %d\n",
- __func__, substream->name, atomic_read(&prim_auxpcm_rsc_ref));
- auxpcm_ctrl = pdata->pri_auxpcm_ctrl;
- if (auxpcm_ctrl == NULL || auxpcm_ctrl->pin_data == NULL) {
- pr_err("%s: Ctrl pointers are NULL\n", __func__);
- ret = -EINVAL;
- goto err;
- }
- if (atomic_inc_return(&prim_auxpcm_rsc_ref) == 1) {
- if (auxpcm_ctrl->mux != NULL) {
- iowrite32(I2S_PCM_SEL << I2S_PCM_SEL_OFFSET,
- auxpcm_ctrl->mux);
- } else {
- pr_err("%s: Pri AUXPCM MUX addr is NULL\n", __func__);
- ret = -EINVAL;
- goto err;
- }
- ret = msm_aux_pcm_get_gpios(auxpcm_ctrl);
- }
- if (ret < 0) {
- pr_err("%s: Aux PCM GPIO request failed\n", __func__);
- return -EINVAL;
- }
- err:
- return ret;
- }
- static void msm_prim_auxpcm_shutdown(struct snd_pcm_substream *substream)
- {
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_card *card = rtd->card;
- struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
- struct msm_auxpcm_ctrl *auxpcm_ctrl = NULL;
- pr_debug("%s(): substream = %s, prim_auxpcm_rsc_ref counter = %d\n",
- __func__, substream->name, atomic_read(&prim_auxpcm_rsc_ref));
- auxpcm_ctrl = pdata->pri_auxpcm_ctrl;
- if (atomic_dec_return(&prim_auxpcm_rsc_ref) == 0)
- msm_aux_pcm_free_gpios(auxpcm_ctrl);
- }
- static struct snd_soc_ops msm_pri_auxpcm_be_ops = {
- .startup = msm_prim_auxpcm_startup,
- .shutdown = msm_prim_auxpcm_shutdown,
- };
- static int msm_sec_auxpcm_startup(struct snd_pcm_substream *substream)
- {
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_card *card = rtd->card;
- struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
- struct msm_auxpcm_ctrl *auxpcm_ctrl = NULL;
- int ret = 0;
- pr_debug("%s(): substream = %s, sec_auxpcm_rsc_ref counter = %d\n",
- __func__, substream->name, atomic_read(&sec_auxpcm_rsc_ref));
- auxpcm_ctrl = pdata->sec_auxpcm_ctrl;
- if (auxpcm_ctrl == NULL || auxpcm_ctrl->pin_data == NULL) {
- pr_err("%s: Ctrl pointers are NULL\n", __func__);
- ret = -EINVAL;
- goto err;
- }
- if (atomic_inc_return(&sec_auxpcm_rsc_ref) == 1) {
- if (auxpcm_ctrl->mux != NULL) {
- iowrite32(I2S_PCM_SEL << I2S_PCM_SEL_OFFSET,
- auxpcm_ctrl->mux);
- } else {
- pr_err("%s Sec AUXPCM MUX addr is NULL\n", __func__);
- ret = -EINVAL;
- goto err;
- }
- ret = msm_aux_pcm_get_gpios(auxpcm_ctrl);
- }
- if (ret < 0) {
- pr_err("%s: Aux PCM GPIO request failed\n", __func__);
- return -EINVAL;
- }
- err:
- return ret;
- }
- static void msm_sec_auxpcm_shutdown(struct snd_pcm_substream *substream)
- {
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_card *card = rtd->card;
- struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
- struct msm_auxpcm_ctrl *auxpcm_ctrl = NULL;
- pr_debug("%s(): substream = %s, sec_auxpcm_rsc_ref counter = %d\n",
- __func__, substream->name, atomic_read(&sec_auxpcm_rsc_ref));
- auxpcm_ctrl = pdata->sec_auxpcm_ctrl;
- if (atomic_dec_return(&sec_auxpcm_rsc_ref) == 0)
- msm_aux_pcm_free_gpios(auxpcm_ctrl);
- }
- static struct snd_soc_ops msm_sec_auxpcm_be_ops = {
- .startup = msm_sec_auxpcm_startup,
- .shutdown = msm_sec_auxpcm_shutdown,
- };
- static int msm_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- pr_debug("%s()\n", __func__);
- param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
- slim0_rx_bit_format);
- rate->min = rate->max = slim0_rx_sample_rate;
- channels->min = channels->max = msm_slim_0_rx_ch;
- pr_info("%s: format = %d, rate = %d, channels = %d\n",
- __func__, params_format(params), params_rate(params),
- msm_slim_0_rx_ch);
- return 0;
- }
- static int msm_slim_0_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_CHANNELS);
- pr_debug("%s()\n", __func__);
- param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
- slim0_tx_bit_format);
- rate->min = rate->max = 48000;
- channels->min = channels->max = msm_slim_0_tx_ch;
- pr_info("%s: format = %d, rate = %d, channels = %d\n",
- __func__, params_format(params), params_rate(params),
- msm_slim_0_tx_ch);
- return 0;
- }
- static int msm_slim_4_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_CHANNELS);
- pr_debug("%s()\n", __func__);
- rate->min = rate->max = 48000;
- channels->min = channels->max = 2;
- return 0;
- }
- static int msm_slim_5_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- int rc;
- void *config;
- struct snd_soc_codec *codec = rtd->codec;
- struct snd_interval *rate =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- pr_debug("%s enter\n", __func__);
- rate->min = rate->max = 16000;
- channels->min = channels->max = 1;
- config = taiko_get_afe_config(codec, AFE_SLIMBUS_SLAVE_PORT_CONFIG);
- rc = afe_set_config(AFE_SLIMBUS_SLAVE_PORT_CONFIG, config,
- SLIMBUS_5_TX);
- if (rc) {
- pr_err("%s: Failed to set slimbus slave port config %d\n",
- __func__, rc);
- return rc;
- }
- return 0;
- }
- static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate = hw_param_interval(params,
- SNDRV_PCM_HW_PARAM_RATE);
- pr_debug("%s()\n", __func__);
- rate->min = rate->max = 48000;
- return 0;
- }
- #if defined (CONFIG_SND_SOC_MAX98504) || defined(CONFIG_SND_SOC_MAX98505) \
- || defined (CONFIG_SND_SOC_MAX98506)
- static int msm8974_mi2s_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- pr_debug("%s: enter\n", __func__);
- rate->min = rate->max = 48000;
- channels->min = channels->max = 2;
- param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
- SNDRV_PCM_FORMAT_S16_LE);
- return 0;
- }
- #endif
- static int msm_be_fm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
- struct snd_pcm_hw_params *params)
- {
- struct snd_interval *rate =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
- struct snd_interval *channels =
- hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
- pr_debug("%s()\n", __func__);
- rate->min = rate->max = 48000;
- channels->min = channels->max = 2;
- return 0;
- }
- static const struct soc_enum msm_snd_enum[] = {
- SOC_ENUM_SINGLE_EXT(2, spk_function),
- SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text),
- SOC_ENUM_SINGLE_EXT(8, slim0_tx_ch_text),
- SOC_ENUM_SINGLE_EXT(7, hdmi_rx_ch_text),
- SOC_ENUM_SINGLE_EXT(2, rx_bit_format_text),
- SOC_ENUM_SINGLE_EXT(3, slim0_rx_sample_rate_text),
- SOC_ENUM_SINGLE_EXT(8, proxy_rx_ch_text),
- SOC_ENUM_SINGLE_EXT(3, hdmi_rx_sample_rate_text),
- };
- static const struct snd_kcontrol_new msm_snd_controls[] = {
- SOC_ENUM_EXT("Speaker Function", msm_snd_enum[0], msm8974_get_spk,
- msm8974_set_spk),
- SOC_ENUM_EXT("SLIM_0_RX Channels", msm_snd_enum[1],
- msm_slim_0_rx_ch_get, msm_slim_0_rx_ch_put),
- SOC_ENUM_EXT("SLIM_0_TX Channels", msm_snd_enum[2],
- msm_slim_0_tx_ch_get, msm_slim_0_tx_ch_put),
- SOC_ENUM_EXT("AUX PCM SampleRate", msm8974_auxpcm_enum[0],
- msm8974_auxpcm_rate_get, msm8974_auxpcm_rate_put),
- SOC_ENUM_EXT("HDMI_RX Channels", msm_snd_enum[3],
- msm_hdmi_rx_ch_get, msm_hdmi_rx_ch_put),
- SOC_ENUM_EXT("SLIM_0_RX Format", msm_snd_enum[4],
- slim0_rx_bit_format_get, slim0_rx_bit_format_put),
- SOC_ENUM_EXT("SLIM_0_RX SampleRate", msm_snd_enum[5],
- slim0_rx_sample_rate_get, slim0_rx_sample_rate_put),
- SOC_ENUM_EXT("HDMI_RX Bit Format", msm_snd_enum[4],
- hdmi_rx_bit_format_get, hdmi_rx_bit_format_put),
- SOC_ENUM_EXT("PROXY_RX Channels", msm_snd_enum[6],
- msm_proxy_rx_ch_get, msm_proxy_rx_ch_put),
- SOC_ENUM_EXT("Internal BTSCO SampleRate", msm_btsco_enum[0],
- msm_btsco_rate_get, msm_btsco_rate_put),
- SOC_ENUM_EXT("HDMI_RX SampleRate", msm_snd_enum[7],
- hdmi_rx_sample_rate_get, hdmi_rx_sample_rate_put),
- SOC_SINGLE_EXT("Main Mic Delay",SND_SOC_NOPM, 0, 100, 0,
- main_mic_delay_get, main_mic_delay_put),
- #if defined(CONFIG_SEC_H_PROJECT)
- SOC_SINGLE_EXT("SPK Status",SND_SOC_NOPM, 0, 1, 0,
- speaker_status_get, speaker_status_put),
- #endif
- };
- static bool msm8974_swap_gnd_mic(struct snd_soc_codec *codec)
- {
- struct snd_soc_card *card = codec->card;
- struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
- int value = gpio_get_value_cansleep(pdata->us_euro_gpio);
- pr_debug("%s: swap select switch %d to %d\n", __func__, value, !value);
- gpio_set_value_cansleep(pdata->us_euro_gpio, !value);
- return true;
- }
- static int msm_afe_set_config(struct snd_soc_codec *codec)
- {
- int rc;
- void *config_data;
- pr_debug("%s: enter\n", __func__);
- config_data = taiko_get_afe_config(codec, AFE_CDC_REGISTERS_CONFIG);
- rc = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
- if (rc) {
- pr_err("%s: Failed to set codec registers config %d\n",
- __func__, rc);
- return rc;
- }
- config_data = taiko_get_afe_config(codec, AFE_SLIMBUS_SLAVE_CONFIG);
- rc = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
- if (rc) {
- pr_err("%s: Failed to set slimbus slave config %d\n", __func__,
- rc);
- return rc;
- }
- return 0;
- }
- static void msm_afe_clear_config(void)
- {
- afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
- afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
- }
- static int msm8974_adsp_state_callback(struct notifier_block *nb,
- unsigned long value, void *priv)
- {
- if (value == SUBSYS_BEFORE_SHUTDOWN) {
- pr_debug("%s: ADSP is about to shutdown. Clearing AFE config\n",
- __func__);
- msm_afe_clear_config();
- } else if (value == SUBSYS_AFTER_POWERUP) {
- pr_debug("%s: ADSP is up\n", __func__);
- }
- return NOTIFY_OK;
- }
- static struct notifier_block adsp_state_notifier_block = {
- .notifier_call = msm8974_adsp_state_callback,
- .priority = -INT_MAX,
- };
- static int msm8974_taiko_codec_up(struct snd_soc_codec *codec)
- {
- int err;
- unsigned long timeout;
- int adsp_ready = 0;
- timeout = jiffies +
- msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
- do {
- if (!q6core_is_adsp_ready()) {
- pr_err("%s: ADSP Audio isn't ready\n", __func__);
- } else {
- pr_debug("%s: ADSP Audio is ready\n", __func__);
- adsp_ready = 1;
- break;
- }
- } while (time_after(timeout, jiffies));
- if (!adsp_ready) {
- pr_err("%s: timed out waiting for ADSP Audio\n", __func__);
- return -ETIMEDOUT;
- }
- err = msm_afe_set_config(codec);
- if (err)
- pr_err("%s: Failed to set AFE config. err %d\n",
- __func__, err);
- return err;
- }
- static int msm8974_taiko_event_cb(struct snd_soc_codec *codec,
- enum wcd9xxx_codec_event codec_event)
- {
- switch (codec_event) {
- case WCD9XXX_CODEC_EVENT_CODEC_UP:
- return msm8974_taiko_codec_up(codec);
- break;
- default:
- pr_err("%s: UnSupported codec event %d\n",
- __func__, codec_event);
- return -EINVAL;
- }
- }
- #if defined(CONFIG_MACH_KLTE_KOR) || defined(CONFIG_MACH_KLTE_JPN) || defined(CONFIG_MACH_KACTIVELTE_DCM) || defined(CONFIG_MACH_CHAGALL_KDI) || defined(CONFIG_MACH_KLIMT_LTE_DCM)
- extern unsigned int system_rev;
- #endif
- static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
- {
- int err;
- void *config_data;
- struct snd_soc_codec *codec = rtd->codec;
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
- #if defined(CONFIG_SEC_JACTIVE_PROJECT)
- extern unsigned int system_rev;
- #endif
- /* Taiko SLIMBUS configuration
- * RX1, RX2, RX3, RX4, RX5, RX6, RX7, RX8, RX9, RX10, RX11, RX12, RX13
- * TX1, TX2, TX3, TX4, TX5, TX6, TX7, TX8, TX9, TX10, TX11, TX12, TX13
- * TX14, TX15, TX16
- */
- unsigned int rx_ch[TAIKO_RX_MAX] = {144, 145, 146, 147, 148, 149, 150,
- 151, 152, 153, 154, 155, 156};
- unsigned int tx_ch[TAIKO_TX_MAX] = {128, 129, 130, 131, 132, 133,
- 134, 135, 136, 137, 138, 139,
- 140, 141, 142, 143};
- pr_info("%s(), dev_name%s\n", __func__, dev_name(cpu_dai->dev));
- rtd->pmdown_time = 0;
- err = snd_soc_add_codec_controls(codec, msm_snd_controls,
- ARRAY_SIZE(msm_snd_controls));
- if (err < 0)
- return err;
- err = msm8974_liquid_ext_spk_power_amp_init();
- if (err) {
- pr_err("%s: LiQUID 8974 CLASS_D PAs init failed (%d)\n",
- __func__, err);
- return err;
- }
- err = msm8974_liquid_init_docking(dapm);
- if (err) {
- pr_err("%s: LiQUID 8974 init Docking stat IRQ failed (%d)\n",
- __func__, err);
- return err;
- }
- #if defined(CONFIG_SEC_JACTIVE_PROJECT)
- pr_info("1. msm_audrx_init system_rev %d",system_rev);
- if(system_rev < 3) {
- snd_soc_dapm_new_controls(dapm, msm8974_dapm_widgets_01,
- ARRAY_SIZE(msm8974_dapm_widgets_01));
- }
- else
- {
- snd_soc_dapm_new_controls(dapm, msm8974_dapm_widgets,
- ARRAY_SIZE(msm8974_dapm_widgets));
- }
- #else
- snd_soc_dapm_new_controls(dapm, msm8974_dapm_widgets,
- ARRAY_SIZE(msm8974_dapm_widgets));
- #endif
- snd_soc_dapm_enable_pin(dapm, "Lineout_1 amp");
- snd_soc_dapm_enable_pin(dapm, "Lineout_3 amp");
- snd_soc_dapm_enable_pin(dapm, "Lineout_2 amp");
- snd_soc_dapm_enable_pin(dapm, "Lineout_4 amp");
- snd_soc_dapm_sync(dapm);
- codec_clk = clk_get(cpu_dai->dev, "osr_clk");
- snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
- tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
- err = msm_afe_set_config(codec);
- if (err) {
- pr_err("%s: Failed to set AFE config %d\n", __func__, err);
- goto out;
- }
- config_data = taiko_get_afe_config(codec, AFE_AANC_VERSION);
- err = afe_set_config(AFE_AANC_VERSION, config_data, 0);
- if (err) {
- pr_err("%s: Failed to set aanc version %d\n",
- __func__, err);
- goto out;
- }
- config_data = taiko_get_afe_config(codec,
- AFE_CDC_CLIP_REGISTERS_CONFIG);
- if (config_data) {
- err = afe_set_config(AFE_CDC_CLIP_REGISTERS_CONFIG,
- config_data, 0);
- if (err) {
- pr_err("%s: Failed to set clip registers %d\n",
- __func__, err);
- return err;
- }
- }
- config_data = taiko_get_afe_config(codec, AFE_CLIP_BANK_SEL);
- if (config_data) {
- err = afe_set_config(AFE_CLIP_BANK_SEL, config_data, 0);
- if (err) {
- pr_err("%s: Failed to set AFE bank selection %d\n",
- __func__, err);
- return err;
- }
- }
- #if defined(CONFIG_MACH_KLTE_KOR)
- if (system_rev >= 13) {
- pr_info("%s: USE MBHC revision %d\n", __func__, system_rev);
- /* start mbhc */
- mbhc_cfg.calibration = def_taiko_mbhc_cal();
- if (mbhc_cfg.calibration) {
- err = taiko_hs_detect(codec, &mbhc_cfg);
- if (err)
- goto out;
- } else {
- err = -ENOMEM;
- goto out;
- }
- }
- #elif defined(CONFIG_MACH_KLTE_JPN)
- if (system_rev >= 11) {
- pr_info("%s: USE MBHC revision %d\n", __func__, system_rev);
- /* start mbhc */
- mbhc_cfg.calibration = def_taiko_mbhc_cal();
- if (mbhc_cfg.calibration) {
- err = taiko_hs_detect(codec, &mbhc_cfg);
- if (err)
- goto out;
- } else {
- err = -ENOMEM;
- goto out;
- }
- }
- #else
- #if !defined(CONFIG_SAMSUNG_JACK) && !defined(CONFIG_MUIC_DET_JACK)
- /* start mbhc */
- mbhc_cfg.calibration = def_taiko_mbhc_cal();
- if (mbhc_cfg.calibration) {
- err = taiko_hs_detect(codec, &mbhc_cfg);
- if (err)
- goto out;
- } else {
- err = -ENOMEM;
- goto out;
- }
- #elif defined(CONFIG_SEC_JACTIVE_PROJECT)
- pr_info("2. msm_audrx_init system_rev %d",system_rev);
- if(system_rev < 3) {
- mbhc_cfg.calibration = def_taiko_mbhc_cal();
- if (mbhc_cfg.calibration) {
- err = taiko_hs_detect(codec, &mbhc_cfg);
- if (err)
- goto out;
- else
- return err;
- } else {
- err = -ENOMEM;
- goto out;
- }
- }
- #endif
- #endif /* CONFIG_MACH_KLTE_KOR */
- adsp_state_notifier =
- subsys_notif_register_notifier("adsp",
- &adsp_state_notifier_block);
- if (!adsp_state_notifier) {
- pr_err("%s: Failed to register adsp state notifier\n",
- __func__);
- err = -EFAULT;
- #if defined(CONFIG_MACH_KLTE_KOR)
- if (system_rev >= 13) {
- taiko_hs_detect_exit(codec);
- }
- #elif defined(CONFIG_MACH_KLTE_JPN)
- if (system_rev >= 11) {
- taiko_hs_detect_exit(codec);
- }
- #else
- #if !defined(CONFIG_SAMSUNG_JACK) && !defined(CONFIG_MUIC_DET_JACK)
- taiko_hs_detect_exit(codec);
- #endif
- #endif /* CONFIG_MACH_KLTE_KOR */
- goto out;
- }
- taiko_event_register(msm8974_taiko_event_cb, rtd->codec);
- return 0;
- out:
- clk_put(codec_clk);
- return err;
- }
- static int msm8974_snd_startup(struct snd_pcm_substream *substream)
- {
- pr_debug("%s(): substream = %s stream = %d\n", __func__,
- substream->name, substream->stream);
- return 0;
- }
- void *def_taiko_mbhc_cal(void)
- {
- void *taiko_cal;
- struct wcd9xxx_mbhc_btn_detect_cfg *btn_cfg;
- u16 *btn_low, *btn_high;
- u8 *n_ready, *n_cic, *gain;
- taiko_cal = kzalloc(WCD9XXX_MBHC_CAL_SIZE(WCD9XXX_MBHC_DEF_BUTTONS,
- WCD9XXX_MBHC_DEF_RLOADS),
- GFP_KERNEL);
- if (!taiko_cal) {
- pr_err("%s: out of memory\n", __func__);
- return NULL;
- }
- #define S(X, Y) ((WCD9XXX_MBHC_CAL_GENERAL_PTR(taiko_cal)->X) = (Y))
- S(t_ldoh, 100);
- S(t_bg_fast_settle, 100);
- S(t_shutdown_plug_rem, 255);
- S(mbhc_nsa, 4);
- S(mbhc_navg, 4);
- #undef S
- #define S(X, Y) ((WCD9XXX_MBHC_CAL_PLUG_DET_PTR(taiko_cal)->X) = (Y))
- S(mic_current, TAIKO_PID_MIC_5_UA);
- S(hph_current, TAIKO_PID_MIC_5_UA);
- S(t_mic_pid, 100);
- S(t_ins_complete, 250);
- S(t_ins_retry, 200);
- #undef S
- #define S(X, Y) ((WCD9XXX_MBHC_CAL_PLUG_TYPE_PTR(taiko_cal)->X) = (Y))
- S(v_no_mic, 950);
- S(v_hs_max, 3000);
- #undef S
- #define S(X, Y) ((WCD9XXX_MBHC_CAL_BTN_DET_PTR(taiko_cal)->X) = (Y))
- S(c[0], 62);
- S(c[1], 124);
- S(nc, 1);
- S(n_meas, 3);
- S(mbhc_nsc, 11);
- S(n_btn_meas, 1);
- S(n_btn_con, 2);
- S(num_btn, WCD9XXX_MBHC_DEF_BUTTONS);
- S(v_btn_press_delta_sta, 100);
- S(v_btn_press_delta_cic, 50);
- #undef S
- btn_cfg = WCD9XXX_MBHC_CAL_BTN_DET_PTR(taiko_cal);
- btn_low = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_V_BTN_LOW);
- btn_high = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg,
- MBHC_BTN_DET_V_BTN_HIGH);
- btn_low[0] = -50;
- btn_high[0] = 160;
- btn_low[1] = 161;
- btn_high[1] = 330;
- btn_low[2] = 331;
- btn_high[2] = 730;
- n_ready = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_N_READY);
- n_ready[0] = 80;
- n_ready[1] = 68;
- n_cic = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_N_CIC);
- n_cic[0] = 60;
- n_cic[1] = 47;
- gain = wcd9xxx_mbhc_cal_btn_det_mp(btn_cfg, MBHC_BTN_DET_GAIN);
- gain[0] = 11;
- gain[1] = 9;
- return taiko_cal;
- }
- static int msm_snd_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
- {
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- int ret = 0;
- unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
- unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
- unsigned int user_set_tx_ch = 0;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- pr_debug("%s: rx_0_ch=%d\n", __func__, msm_slim_0_rx_ch);
- ret = snd_soc_dai_get_channel_map(codec_dai,
- &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to get codec chan map\n", __func__);
- goto end;
- }
- ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
- msm_slim_0_rx_ch, rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to set cpu chan map\n", __func__);
- goto end;
- }
- } else {
- pr_debug("%s: %s_tx_dai_id_%d_ch=%d\n", __func__,
- codec_dai->name, codec_dai->id, user_set_tx_ch);
- ret = snd_soc_dai_get_channel_map(codec_dai,
- &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to get codec chan map\n", __func__);
- goto end;
- }
- /* For tabla_tx1 case */
- #if defined(CONFIG_SND_SOC_ES705)
- if (codec_dai->id == 1)
- user_set_tx_ch = msm_slim_0_tx_ch;
- #elif defined(CONFIG_SND_SOC_ES325)
- if ((codec_dai->id == 1) ||(codec_dai->id == 11)) {
- user_set_tx_ch = msm_slim_0_tx_ch;
- }
- #else
- if (codec_dai->id == 1)
- user_set_tx_ch = msm_slim_0_tx_ch;
- #endif
- /* For tabla_tx2 case */
- else if (codec_dai->id == 3)
- user_set_tx_ch = params_channels(params);
- else
- user_set_tx_ch = tx_ch_cnt;
- pr_info("%s: msm_slim_0_tx_ch(%d)user_set_tx_ch(%d)tx_ch_cnt(%d)\n",
- __func__, msm_slim_0_tx_ch, user_set_tx_ch, tx_ch_cnt);
- ret = snd_soc_dai_set_channel_map(cpu_dai,
- user_set_tx_ch, tx_ch, 0 , 0);
- if (ret < 0) {
- pr_err("%s: failed to set cpu chan map\n", __func__);
- goto end;
- }
- }
- end:
- return ret;
- }
- static void msm8974_snd_shudown(struct snd_pcm_substream *substream)
- {
- pr_debug("%s(): substream = %s stream = %d\n", __func__,
- substream->name, substream->stream);
- }
- #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98506)
- static int msm8974_pri_mi2s_free_gpios(void)
- {
- int i;
- for (i = 0; i < ARRAY_SIZE(pri_mi2s_gpio); i++)
- gpio_free(pri_mi2s_gpio[i].gpio_no);
- return 0;
- }
- static struct afe_clk_cfg lpass_mi2s_enable = {
- AFE_API_VERSION_I2S_CONFIG,
- Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
- Q6AFE_LPASS_OSR_CLK_12_P288_MHZ,
- Q6AFE_LPASS_CLK_SRC_INTERNAL,
- Q6AFE_LPASS_CLK_ROOT_DEFAULT,
- Q6AFE_LPASS_MODE_BOTH_VALID,
- 0,
- };
- static struct afe_clk_cfg lpass_mi2s_disable = {
- AFE_API_VERSION_I2S_CONFIG,
- 0,
- 0,
- Q6AFE_LPASS_CLK_SRC_INTERNAL,
- Q6AFE_LPASS_CLK_ROOT_DEFAULT,
- Q6AFE_LPASS_MODE_BOTH_VALID,
- 0,
- };
- static void msm8974_mi2s_shutdown(struct snd_pcm_substream *substream)
- {
- if (atomic_dec_return(&pri_mi2s_clk.mi2s_rsc_ref) == 0) {
- int ret = 0;
- u16 port_id = 0;
- pr_debug("[MAX9850x_DEBUG] %s: free mi2s resources\n", __func__);
- #if defined (CONFIG_TERT_MI2S_ENABLE)
- port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
- #else
- port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
- #endif
- if(substream->stream == 0)
- ret = afe_set_lpass_clock(port_id, &lpass_mi2s_disable);
- else if(substream->stream == 1)
- ret = afe_set_lpass_clock(port_id, &lpass_mi2s_disable);
- if (ret < 0) {
- pr_err("%s: afe_set_lpass_clock failed\n", __func__);
- }
- msm8974_pri_mi2s_free_gpios();
- }
- }
- static int msm8974_configure_pri_mi2s_gpio(void)
- {
- int rtn;
- int i;
- for (i = 0; i < ARRAY_SIZE(pri_mi2s_gpio); i++) {
- rtn = gpio_request(pri_mi2s_gpio[i].gpio_no,
- pri_mi2s_gpio[i].gpio_name);
- pr_debug("%s: gpio = %d, gpio name = %s, rtn = %d\n", __func__,
- pri_mi2s_gpio[i].gpio_no, pri_mi2s_gpio[i].gpio_name, rtn);
- if (rtn) {
- pr_err("%s: Failed to request gpio %d\n",
- __func__,
- pri_mi2s_gpio[i].gpio_no);
- while( i >= 0) {
- gpio_free(pri_mi2s_gpio[i].gpio_no);
- i--;
- }
- break;
- }
- }
- return rtn;
- }
- static int msm8974_mi2s_startup(struct snd_pcm_substream *substream)
- {
- int ret = 0;
- u16 port_id = 0;
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
- pr_debug("%s: dai name %s %p\n", __func__, cpu_dai->name, cpu_dai->dev);
- if (atomic_inc_return(&pri_mi2s_clk.mi2s_rsc_ref) == 1) {
- pr_info("%s: acquire mi2s resources\n", __func__);
- msm8974_configure_pri_mi2s_gpio();
- #if defined (CONFIG_TERT_MI2S_ENABLE)
- port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
- #else
- port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
- #endif
- if(substream->stream == 0)
- ret = afe_set_lpass_clock(port_id, &lpass_mi2s_enable);
- else if(substream->stream == 1)
- ret = afe_set_lpass_clock(port_id, &lpass_mi2s_enable);
- if (ret < 0) {
- pr_err("%s: afe_set_lpass_clock failed\n", __func__);
- return ret;
- }
- ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
- if (ret < 0)
- dev_err(cpu_dai->dev, "set format for CPU dai"
- " failed\n");
- ret = snd_soc_dai_set_fmt(codec_dai,
- SND_SOC_DAIFMT_I2S |
- SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS);
- if (ret < 0)
- dev_err(codec_dai->dev, "set format for codec dai"
- " failed\n");
- ret = 0;
- }
- return ret;
- }
- static struct snd_soc_ops msm8974_mi2s_be_ops = {
- .startup = msm8974_mi2s_startup,
- .shutdown = msm8974_mi2s_shutdown
- };
- #endif
- static struct snd_soc_ops msm8974_be_ops = {
- .startup = msm8974_snd_startup,
- .hw_params = msm_snd_hw_params,
- .shutdown = msm8974_snd_shudown,
- };
- static int msm8974_slimbus_2_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
- {
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
- int ret = 0;
- unsigned int rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
- unsigned int rx_ch_cnt = 0, tx_ch_cnt = 0;
- unsigned int num_tx_ch = 0;
- unsigned int num_rx_ch = 0;
- if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- num_rx_ch = params_channels(params);
- pr_debug("%s: %s rx_dai_id = %d num_ch = %d\n", __func__,
- codec_dai->name, codec_dai->id, num_rx_ch);
- ret = snd_soc_dai_get_channel_map(codec_dai,
- &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to get codec chan map\n", __func__);
- goto end;
- }
- ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
- num_rx_ch, rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to set cpu chan map\n", __func__);
- goto end;
- }
- } else {
- num_tx_ch = params_channels(params);
- pr_debug("%s: %s tx_dai_id = %d num_ch = %d\n", __func__,
- codec_dai->name, codec_dai->id, num_tx_ch);
- ret = snd_soc_dai_get_channel_map(codec_dai,
- &tx_ch_cnt, tx_ch, &rx_ch_cnt , rx_ch);
- if (ret < 0) {
- pr_err("%s: failed to get codec chan map\n", __func__);
- goto end;
- }
- ret = snd_soc_dai_set_channel_map(cpu_dai,
- num_tx_ch, tx_ch, 0 , 0);
- if (ret < 0) {
- pr_err("%s: failed to set cpu chan map\n", __func__);
- goto end;
- }
- }
- end:
- return ret;
- }
- static struct snd_soc_ops msm8974_slimbus_2_be_ops = {
- .startup = msm8974_snd_startup,
- .hw_params = msm8974_slimbus_2_hw_params,
- .shutdown = msm8974_snd_shudown,
- };
- /* Digital audio interface glue - connects codec <---> CPU */
- static struct snd_soc_dai_link msm8974_common_dai_links[] = {
- /* FrontEnd DAI Links */
- {
- .name = "MSM8974 Media1",
- .stream_name = "MultiMedia1",
- .cpu_dai_name = "MultiMedia1",
- .platform_name = "msm-pcm-dsp.0",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1
- },
- {
- .name = "MSM8974 Media2",
- .stream_name = "MultiMedia2",
- .cpu_dai_name = "MultiMedia2",
- .platform_name = "msm-pcm-dsp.0",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2,
- },
- {
- .name = "Circuit-Switch Voice",
- .stream_name = "CS-Voice",
- .cpu_dai_name = "CS-VOICE",
- .platform_name = "msm-pcm-voice",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_CS_VOICE,
- },
- {
- .name = "MSM VoIP",
- .stream_name = "VoIP",
- .cpu_dai_name = "VoIP",
- .platform_name = "msm-voip-dsp",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_VOIP,
- },
- {
- .name = "MSM8974 LPA",
- .stream_name = "LPA",
- .cpu_dai_name = "MultiMedia3",
- .platform_name = "msm-pcm-lpa",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3,
- },
- /* Hostless PCM purpose */
- {
- .name = "SLIMBUS_0 Hostless",
- .stream_name = "SLIMBUS_0 Hostless",
- .cpu_dai_name = "SLIMBUS0_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* dai link has playback support */
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- {
- .name = "INT_FM Hostless",
- .stream_name = "INT_FM Hostless",
- .cpu_dai_name = "INT_FM_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- {
- .name = "MSM AFE-PCM RX",
- .stream_name = "AFE-PROXY RX",
- .cpu_dai_name = "msm-dai-q6-dev.241",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .platform_name = "msm-pcm-afe",
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- },
- {
- .name = "MSM AFE-PCM TX",
- .stream_name = "AFE-PROXY TX",
- .cpu_dai_name = "msm-dai-q6-dev.240",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .platform_name = "msm-pcm-afe",
- .ignore_suspend = 1,
- },
- {
- .name = "MSM8974 Compr",
- .stream_name = "COMPR",
- .cpu_dai_name = "MultiMedia4",
- .platform_name = "msm-compress-dsp",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- /* this dainlink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4,
- },
- {
- .name = "AUXPCM Hostless",
- .stream_name = "AUXPCM Hostless",
- .cpu_dai_name = "AUXPCM_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- {
- .name = "SLIMBUS_1 Hostless",
- .stream_name = "SLIMBUS_1 Hostless",
- .cpu_dai_name = "SLIMBUS1_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* dai link has playback support */
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- {
- .name = "SLIMBUS_3 Hostless",
- .stream_name = "SLIMBUS_3 Hostless",
- .cpu_dai_name = "SLIMBUS3_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* dai link has playback support */
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- {
- .name = "SLIMBUS_4 Hostless",
- .stream_name = "SLIMBUS_4 Hostless",
- .cpu_dai_name = "SLIMBUS4_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* dai link has playback support */
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- {
- .name = "VoLTE",
- .stream_name = "VoLTE",
- .cpu_dai_name = "VoLTE",
- .platform_name = "msm-pcm-voice",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_VOLTE,
- },
- {
- .name = "MSM8974 LowLatency",
- .stream_name = "MultiMedia5",
- .cpu_dai_name = "MultiMedia5",
- .platform_name = "msm-pcm-dsp.1",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA5,
- },
- /* LSM FE */
- {
- .name = "Listen 1 Audio Service",
- .stream_name = "Listen 1 Audio Service",
- .cpu_dai_name = "LSM1",
- .platform_name = "msm-lsm-client",
- .dynamic = 1,
- .trigger = { SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST },
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_LSM1,
- },
- /* Multiple Tunnel instances */
- {
- .name = "MSM8974 Compr2",
- .stream_name = "COMPR2",
- .cpu_dai_name = "MultiMedia6",
- .platform_name = "msm-compress-dsp",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- /* this dainlink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6,
- },
- {
- .name = "MSM8974 Compr3",
- .stream_name = "COMPR3",
- .cpu_dai_name = "MultiMedia7",
- .platform_name = "msm-compress-dsp",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- /* this dainlink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA7,
- },
- {
- .name = "MSM8974 Compr4",
- .stream_name = "COMPR4",
- .cpu_dai_name = "MultiMedia8",
- .platform_name = "msm-compress-dsp",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- /* this dainlink has playback support */
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA8,
- },
- {
- .name = "QCHAT",
- .stream_name = "QCHAT",
- .cpu_dai_name = "QCHAT",
- .platform_name = "msm-pcm-voice",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_QCHAT,
- },
- /* HDMI Hostless */
- {
- .name = "HDMI_RX_HOSTLESS",
- .stream_name = "HDMI_RX_HOSTLESS",
- .cpu_dai_name = "HDMI_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- {
- .name = "Voice2",
- .stream_name = "Voice2",
- .cpu_dai_name = "Voice2",
- .platform_name = "msm-pcm-voice",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_VOICE2,
- },
- {
- .name = "INT_HFP_BT Hostless",
- .stream_name = "INT_HFP_BT Hostless",
- .cpu_dai_name = "INT_HFP_BT_HOSTLESS",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- /* this dai link has playback support */
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- {
- .name = "MSM8974 HFP TX",
- .stream_name = "MultiMedia6",
- .cpu_dai_name = "MultiMedia6",
- .platform_name = "msm-pcm-loopback",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA6,
- },
- {
- .name = "Listen 2 Audio Service",
- .stream_name = "Listen 2 Audio Service",
- .cpu_dai_name = "LSM2",
- .platform_name = "msm-lsm-client",
- .dynamic = 1,
- .trigger = { SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST },
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_LSM2,
- },
- {
- .name = "Listen 3 Audio Service",
- .stream_name = "Listen 3 Audio Service",
- .cpu_dai_name = "LSM3",
- .platform_name = "msm-lsm-client",
- .dynamic = 1,
- .trigger = { SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST },
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_LSM3,
- },
- {
- .name = "Listen 4 Audio Service",
- .stream_name = "Listen 4 Audio Service",
- .cpu_dai_name = "LSM4",
- .platform_name = "msm-lsm-client",
- .dynamic = 1,
- .trigger = { SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST },
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_LSM4,
- },
- {
- .name = "Listen 5 Audio Service",
- .stream_name = "Listen 5 Audio Service",
- .cpu_dai_name = "LSM5",
- .platform_name = "msm-lsm-client",
- .dynamic = 1,
- .trigger = { SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST },
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_LSM5,
- },
- {
- .name = "Listen 6 Audio Service",
- .stream_name = "Listen 6 Audio Service",
- .cpu_dai_name = "LSM6",
- .platform_name = "msm-lsm-client",
- .dynamic = 1,
- .trigger = { SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST },
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_LSM6,
- },
- {
- .name = "Listen 7 Audio Service",
- .stream_name = "Listen 7 Audio Service",
- .cpu_dai_name = "LSM7",
- .platform_name = "msm-lsm-client",
- .dynamic = 1,
- .trigger = { SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST },
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_LSM7,
- },
- {
- .name = "Listen 8 Audio Service",
- .stream_name = "Listen 8 Audio Service",
- .cpu_dai_name = "LSM8",
- .platform_name = "msm-lsm-client",
- .dynamic = 1,
- .trigger = { SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST },
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_LSM8,
- },
- {
- .name = LPASS_BE_SLIMBUS_4_TX,
- .stream_name = "Slimbus4 Capture",
- .cpu_dai_name = "msm-dai-q6-dev.16393",
- .platform_name = "msm-pcm-hostless",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_vifeedback",
- .be_id = MSM_BACKEND_DAI_SLIMBUS_4_TX,
- .be_hw_params_fixup = msm_slim_4_tx_be_hw_params_fixup,
- .ops = &msm8974_be_ops,
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- },
- /* Ultrasound RX Back End DAI Link */
- {
- .name = "SLIMBUS_2 Hostless Playback",
- .stream_name = "SLIMBUS_2 Hostless Playback",
- .cpu_dai_name = "msm-dai-q6-dev.16388",
- .platform_name = "msm-pcm-hostless",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_rx2",
- .ignore_suspend = 1,
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ops = &msm8974_slimbus_2_be_ops,
- },
- /* Ultrasound TX Back End DAI Link */
- {
- .name = "SLIMBUS_2 Hostless Capture",
- .stream_name = "SLIMBUS_2 Hostless Capture",
- .cpu_dai_name = "msm-dai-q6-dev.16389",
- .platform_name = "msm-pcm-hostless",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_tx2",
- .ignore_suspend = 1,
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ops = &msm8974_slimbus_2_be_ops,
- },
- {
- .name = "MSM8974 Media9",
- .stream_name = "MultiMedia9",
- .cpu_dai_name = "MultiMedia9",
- .platform_name = "msm-pcm-dsp.0",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA9,
- },
- {
- .name = "VoWLAN",
- .stream_name = "VoWLAN",
- .cpu_dai_name = "VoWLAN",
- .platform_name = "msm-pcm-voice",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .be_id = MSM_FRONTEND_DAI_VOWLAN,
- },
- /* Backend BT/FM DAI Links */
- {
- .name = LPASS_BE_INT_BT_SCO_RX,
- .stream_name = "Internal BT-SCO Playback",
- .cpu_dai_name = "msm-dai-q6-dev.12288",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INT_BT_SCO_RX,
- .be_hw_params_fixup = msm_btsco_be_hw_params_fixup,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- },
- {
- .name = LPASS_BE_INT_BT_SCO_TX,
- .stream_name = "Internal BT-SCO Capture",
- .cpu_dai_name = "msm-dai-q6-dev.12289",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INT_BT_SCO_TX,
- .be_hw_params_fixup = msm_btsco_be_hw_params_fixup,
- .ignore_suspend = 1,
- },
- {
- .name = LPASS_BE_INT_FM_RX,
- .stream_name = "Internal FM Playback",
- .cpu_dai_name = "msm-dai-q6-dev.12292",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INT_FM_RX,
- .be_hw_params_fixup = msm_be_fm_hw_params_fixup,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- },
- {
- .name = LPASS_BE_INT_FM_TX,
- .stream_name = "Internal FM Capture",
- .cpu_dai_name = "msm-dai-q6-dev.12293",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INT_FM_TX,
- .be_hw_params_fixup = msm_be_hw_params_fixup,
- .ignore_suspend = 1,
- },
- /* Backend AFE DAI Links */
- {
- .name = LPASS_BE_AFE_PCM_RX,
- .stream_name = "AFE Playback",
- .cpu_dai_name = "msm-dai-q6-dev.224",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_AFE_PCM_RX,
- .be_hw_params_fixup = msm_proxy_rx_be_hw_params_fixup,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- },
- {
- .name = LPASS_BE_AFE_PCM_TX,
- .stream_name = "AFE Capture",
- .cpu_dai_name = "msm-dai-q6-dev.225",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_AFE_PCM_TX,
- .be_hw_params_fixup = msm_proxy_tx_be_hw_params_fixup,
- .ignore_suspend = 1,
- },
- #if defined( CONFIG_PCM_ROUTE_VOICE_STUB ) || defined(CONFIG_BT_CALL_FORWARDING)
- {
- .name = "Voice Stub",
- .stream_name = "Voice Stub",
- .cpu_dai_name = "VOICE_STUB",
- .platform_name = "msm-pcm-hostless",
- .dynamic = 1,
- .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
- .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
- .ignore_suspend = 1,
- .ignore_pmdown_time = 1, /* this dainlink has playback support */
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- },
- #endif /* CONFIG_PCM_ROUTE_VOICE_STUB || CONFIG_BT_CALL_FORWARDING */
- #ifdef CONFIG_JACK_AUDIO
- {
- .name = "MSM8974 JACK LowLatency",
- .stream_name = "MultiMedia10",
- .cpu_dai_name = "MultiMedia10",
- .platform_name = "msm-pcm-dsp.1",
- .dynamic = 1,
- .codec_dai_name = "snd-soc-dummy-dai",
- .codec_name = "snd-soc-dummy",
- .trigger = {SND_SOC_DPCM_TRIGGER_POST,
- SND_SOC_DPCM_TRIGGER_POST},
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- .ignore_pmdown_time = 1,
- .be_id = MSM_FRONTEND_DAI_MULTIMEDIA10,
- },
- #endif
- /* Primary AUX PCM Backend DAI Links */
- {
- .name = LPASS_BE_AUXPCM_RX,
- .stream_name = "AUX PCM Playback",
- .cpu_dai_name = "msm-dai-q6-auxpcm.1",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_AUXPCM_RX,
- .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
- .ops = &msm_pri_auxpcm_be_ops,
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- },
- {
- .name = LPASS_BE_AUXPCM_TX,
- .stream_name = "AUX PCM Capture",
- .cpu_dai_name = "msm-dai-q6-auxpcm.1",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_AUXPCM_TX,
- .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
- .ops = &msm_pri_auxpcm_be_ops,
- .ignore_suspend = 1,
- },
- #if defined( CONFIG_PCM_ROUTE_VOICE_STUB ) || defined(CONFIG_BT_CALL_FORWARDING)
- /* Secondary AUX PCM Backend DAI Links */
- {
- .name = LPASS_BE_SEC_AUXPCM_RX,
- .stream_name = "Sec AUX PCM Playback",
- .cpu_dai_name = "msm-dai-q6-auxpcm.2",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
- .be_hw_params_fixup = msm_auxpcm2_be_params_fixup,
- .ops = &msm_sec_auxpcm_be_ops,
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- },
- {
- .name = LPASS_BE_SEC_AUXPCM_TX,
- .stream_name = "Sec AUX PCM Capture",
- .cpu_dai_name = "msm-dai-q6-auxpcm.2",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
- .be_hw_params_fixup = msm_auxpcm2_be_params_fixup,
- .ops = &msm_sec_auxpcm_be_ops,
- .ignore_suspend = 1,
- },
- #else
- /* Secondary AUX PCM Backend DAI Links */
- {
- .name = LPASS_BE_SEC_AUXPCM_RX,
- .stream_name = "Sec AUX PCM Playback",
- .cpu_dai_name = "msm-dai-q6-auxpcm.2",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
- .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
- .ops = &msm_sec_auxpcm_be_ops,
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- /* this dainlink has playback support */
- },
- {
- .name = LPASS_BE_SEC_AUXPCM_TX,
- .stream_name = "Sec AUX PCM Capture",
- .cpu_dai_name = "msm-dai-q6-auxpcm.2",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
- .be_hw_params_fixup = msm_auxpcm_be_params_fixup,
- .ops = &msm_sec_auxpcm_be_ops,
- .ignore_suspend = 1,
- },
- #endif
- /* Backend DAI Links */
- {
- .name = LPASS_BE_SLIMBUS_0_RX,
- .stream_name = "Slimbus Playback",
- .cpu_dai_name = "msm-dai-q6-dev.16384",
- .platform_name = "msm-pcm-routing",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_rx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
- .init = &msm_audrx_init,
- .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
- .ops = &msm8974_be_ops,
- .ignore_pmdown_time = 1, /* dai link has playback support */
- .ignore_suspend = 1,
- },
- {
- .name = LPASS_BE_SLIMBUS_0_TX,
- .stream_name = "Slimbus Capture",
- .cpu_dai_name = "msm-dai-q6-dev.16385",
- .platform_name = "msm-pcm-routing",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_tx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
- .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
- .ops = &msm8974_be_ops,
- .ignore_suspend = 1,
- },
- {
- .name = LPASS_BE_SLIMBUS_1_RX,
- .stream_name = "Slimbus1 Playback",
- .cpu_dai_name = "msm-dai-q6-dev.16386",
- .platform_name = "msm-pcm-routing",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_rx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
- .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
- .ops = &msm8974_be_ops,
- /* dai link has playback support */
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- },
- {
- .name = LPASS_BE_SLIMBUS_1_TX,
- .stream_name = "Slimbus1 Capture",
- .cpu_dai_name = "msm-dai-q6-dev.16387",
- .platform_name = "msm-pcm-routing",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_tx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
- .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
- .ops = &msm8974_be_ops,
- .ignore_suspend = 1,
- },
- {
- .name = LPASS_BE_SLIMBUS_3_RX,
- .stream_name = "Slimbus3 Playback",
- .cpu_dai_name = "msm-dai-q6-dev.16390",
- .platform_name = "msm-pcm-routing",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_rx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
- .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
- .ops = &msm8974_be_ops,
- /* dai link has playback support */
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- },
- {
- .name = LPASS_BE_SLIMBUS_3_TX,
- .stream_name = "Slimbus3 Capture",
- .cpu_dai_name = "msm-dai-q6-dev.16391",
- .platform_name = "msm-pcm-routing",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_tx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
- .be_hw_params_fixup = msm_slim_0_tx_be_hw_params_fixup,
- .ops = &msm8974_be_ops,
- .ignore_suspend = 1,
- },
- {
- .name = LPASS_BE_SLIMBUS_4_RX,
- .stream_name = "Slimbus4 Playback",
- .cpu_dai_name = "msm-dai-q6-dev.16392",
- .platform_name = "msm-pcm-routing",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_rx1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
- .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
- .ops = &msm8974_be_ops,
- /* dai link has playback support */
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- },
- /* Incall Record Uplink BACK END DAI Link */
- {
- .name = LPASS_BE_INCALL_RECORD_TX,
- .stream_name = "Voice Uplink Capture",
- .cpu_dai_name = "msm-dai-q6-dev.32772",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
- .be_hw_params_fixup = msm_be_hw_params_fixup,
- .ignore_suspend = 1,
- },
- /* Incall Record Downlink BACK END DAI Link */
- {
- .name = LPASS_BE_INCALL_RECORD_RX,
- .stream_name = "Voice Downlink Capture",
- .cpu_dai_name = "msm-dai-q6-dev.32771",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-tx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
- .be_hw_params_fixup = msm_be_hw_params_fixup,
- .ignore_suspend = 1,
- },
- /* MAD BE */
- {
- .name = LPASS_BE_SLIMBUS_5_TX,
- .stream_name = "Slimbus5 Capture",
- .cpu_dai_name = "msm-dai-q6-dev.16395",
- .platform_name = "msm-pcm-routing",
- .codec_name = "taiko_codec",
- .codec_dai_name = "taiko_mad1",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SLIMBUS_5_TX,
- .be_hw_params_fixup = msm_slim_5_tx_be_hw_params_fixup,
- .ops = &msm8974_be_ops,
- },
- /* Incall Music BACK END DAI Link */
- {
- .name = LPASS_BE_VOICE_PLAYBACK_TX,
- .stream_name = "Voice Farend Playback",
- .cpu_dai_name = "msm-dai-q6-dev.32773",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
- .be_hw_params_fixup = msm_be_hw_params_fixup,
- .ignore_suspend = 1,
- },
- /* Incall Music 2 BACK END DAI Link */
- {
- .name = LPASS_BE_VOICE2_PLAYBACK_TX,
- .stream_name = "Voice2 Farend Playback",
- .cpu_dai_name = "msm-dai-q6-dev.32770",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-stub-codec.1",
- .codec_dai_name = "msm-stub-rx",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
- .be_hw_params_fixup = msm_be_hw_params_fixup,
- .ignore_suspend = 1,
- },
- #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98506)
- #if defined (CONFIG_TERT_MI2S_ENABLE)
- {
- .name = LPASS_BE_TERT_MI2S_TX,
- .stream_name = "Tertiary MI2S Capture",
- .cpu_dai_name = "msm-dai-q6-mi2s.2",
- .platform_name = "msm-pcm-routing",
- #if defined (CONFIG_SND_SOC_MAX98504)
- .codec_name = "max98504.18-0031",//"msm-stub-codec.1",
- .codec_dai_name = "max98504-aif1",//"msm-stub-tx",
- #elif defined (CONFIG_SND_SOC_MAX98506)
- .codec_name = "max98506.18-0031",
- .codec_dai_name = "max98506-aif1",
- #endif
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
- .be_hw_params_fixup = msm8974_mi2s_be_hw_params_fixup,
- .ops = &msm8974_mi2s_be_ops,
- .ignore_suspend = 1,
- },
- #else
- {
- .name = LPASS_BE_SEC_MI2S_TX,
- .stream_name = "Secondary MI2S Capture",
- .cpu_dai_name = "msm-dai-q6-mi2s.1",
- .platform_name = "msm-pcm-routing",
- #if defined (CONFIG_SND_SOC_MAX98504)
- .codec_name = "max98504.18-0031",//"msm-stub-codec.1",
- .codec_dai_name = "max98504-aif1",//"msm-stub-tx",
- #elif defined (CONFIG_SND_SOC_MAX98506)
- .codec_name = "max98506.18-0031",
- .codec_dai_name = "max98506-aif1",
- #endif
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
- .be_hw_params_fixup = msm8974_mi2s_be_hw_params_fixup,
- .ops = &msm8974_mi2s_be_ops,
- },
- #endif
- #endif
- };
- static struct snd_soc_dai_link msm8974_hdmi_dai_link[] = {
- /* HDMI BACK END DAI Link */
- {
- .name = LPASS_BE_HDMI,
- .stream_name = "HDMI Playback",
- .cpu_dai_name = "msm-dai-q6-hdmi.8",
- .platform_name = "msm-pcm-routing",
- .codec_name = "msm-hdmi-audio-codec-rx",
- .codec_dai_name = "msm_hdmi_audio_codec_rx_dai",
- .no_pcm = 1,
- .be_id = MSM_BACKEND_DAI_HDMI_RX,
- .be_hw_params_fixup = msm8974_hdmi_be_hw_params_fixup,
- .ignore_pmdown_time = 1,
- .ignore_suspend = 1,
- },
- };
- static struct snd_soc_dai_link msm8974_dai_links[
- ARRAY_SIZE(msm8974_common_dai_links) +
- ARRAY_SIZE(msm8974_hdmi_dai_link)];
- struct snd_soc_card snd_soc_card_msm8974 = {
- .name = "msm8974-taiko-snd-card",
- };
- static int msm8974_dtparse_auxpcm(struct platform_device *pdev,
- struct msm_auxpcm_ctrl **auxpcm_ctrl,
- char *msm_auxpcm_gpio_name[][2])
- {
- int ret = 0;
- int i = 0;
- struct msm_auxpcm_gpio *pin_data = NULL;
- struct msm_auxpcm_ctrl *ctrl;
- unsigned int gpio_no[NUM_OF_AUXPCM_GPIOS];
- enum of_gpio_flags flags = OF_GPIO_ACTIVE_LOW;
- int auxpcm_cnt = 0;
- pin_data = devm_kzalloc(&pdev->dev, (ARRAY_SIZE(gpio_no) *
- sizeof(struct msm_auxpcm_gpio)),
- GFP_KERNEL);
- if (!pin_data) {
- dev_err(&pdev->dev, "No memory for gpio\n");
- ret = -ENOMEM;
- goto err;
- }
- for (i = 0; i < ARRAY_SIZE(gpio_no); i++) {
- gpio_no[i] = of_get_named_gpio_flags(pdev->dev.of_node,
- msm_auxpcm_gpio_name[i][DT_PARSE_INDEX],
- 0, &flags);
- if (gpio_no[i] > 0) {
- pin_data[i].gpio_name =
- msm_auxpcm_gpio_name[auxpcm_cnt][GPIO_NAME_INDEX];
- pin_data[i].gpio_no = gpio_no[i];
- dev_dbg(&pdev->dev, "%s:GPIO gpio[%s] =\n"
- "0x%x\n", __func__,
- pin_data[i].gpio_name,
- pin_data[i].gpio_no);
- auxpcm_cnt++;
- } else {
- dev_err(&pdev->dev, "%s:Invalid AUXPCM GPIO[%s]= %x\n",
- __func__,
- msm_auxpcm_gpio_name[i][GPIO_NAME_INDEX],
- gpio_no[i]);
- ret = -ENODEV;
- goto err;
- }
- }
- ctrl = devm_kzalloc(&pdev->dev,
- sizeof(struct msm_auxpcm_ctrl), GFP_KERNEL);
- if (!ctrl) {
- dev_err(&pdev->dev, "No memory for gpio\n");
- ret = -ENOMEM;
- goto err;
- }
- ctrl->pin_data = pin_data;
- ctrl->cnt = auxpcm_cnt;
- *auxpcm_ctrl = ctrl;
- return ret;
- err:
- if (pin_data)
- devm_kfree(&pdev->dev, pin_data);
- return ret;
- }
- static int msm8974_prepare_codec_mclk(struct snd_soc_card *card)
- {
- struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
- int ret;
- if (pdata->mclk_gpio) {
- ret = gpio_request(pdata->mclk_gpio, "TAIKO_CODEC_PMIC_MCLK");
- if (ret) {
- dev_err(card->dev,
- "%s: Failed to request taiko mclk gpio %d\n",
- __func__, pdata->mclk_gpio);
- return ret;
- }
- }
- return 0;
- }
- static int msm8974_prepare_us_euro(struct snd_soc_card *card)
- {
- struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
- int ret;
- if (pdata->us_euro_gpio >= 0) {
- dev_dbg(card->dev, "%s : us_euro gpio request %d", __func__,
- pdata->us_euro_gpio);
- ret = gpio_request(pdata->us_euro_gpio, "TAIKO_CODEC_US_EURO");
- if (ret) {
- dev_err(card->dev,
- "%s: Failed to request taiko US/EURO gpio %d error %d\n",
- __func__, pdata->us_euro_gpio, ret);
- return ret;
- }
- }
- return 0;
- }
- static int msm8974_prepare_mainmic(void)
- {
- int ret;
- if (mainmic_bias_gpio) {
- pr_debug("%s : mainmic bias gpio request %d", __func__,
- mainmic_bias_gpio);
- ret = gpio_request(mainmic_bias_gpio, "TAIKO_MAINMIC_BIAS");
- if (ret) {
- pr_debug("%s: Failed to request taiko mainmic bias gpio %d error %d\n",
- __func__, mainmic_bias_gpio, ret);
- return ret;
- }
- gpio_direction_output(mainmic_bias_gpio, 0);
- }
- return 0;
- }
- #if defined(CONFIG_LDO_SUBMIC_BIAS)
- static int msm8974_prepare_submic(void)
- {
- int ret;
- if (submic_bias_gpio) {
- pr_debug("%s : submic bias gpio request %d", __func__,
- submic_bias_gpio);
- ret = gpio_request(submic_bias_gpio, "TAIKO_SUBMIC_BIAS");
- if (ret) {
- pr_debug("%s: Failed to request taiko submic bias gpio %d error %d\n",
- __func__, submic_bias_gpio, ret);
- return ret;
- }
- gpio_direction_output(submic_bias_gpio, 0);
- }
- return 0;
- }
- #endif
- #if defined(CONFIG_LDO_EARMIC_BIAS)
- static int msm8974_prepare_earmic(void)
- {
- int ret;
- if (earmic_bias_gpio) {
- pr_debug("%s : earmic bias gpio request %d", __func__,
- earmic_bias_gpio);
- ret = gpio_request(earmic_bias_gpio, "TAIKO_EARMIC_BIAS");
- if (ret) {
- pr_debug("%s: Failed to request taiko earmic bias gpio %d error %d\n",
- __func__, earmic_bias_gpio, ret);
- return ret;
- }
- gpio_direction_output(earmic_bias_gpio, 0);
- }
- return 0;
- }
- #endif
- static int msm8974_prepare_spkamp(void)
- {
- int ret;
- if (spkamp_en_gpio) {
- pr_debug("%s : spkamp en gpio request %d", __func__,
- spkamp_en_gpio);
- ret = gpio_request(spkamp_en_gpio, "SPKAMP_EN");
- if (ret) {
- pr_debug("%s: Failed to request spkamp en gpio %d error %d\n",
- __func__, spkamp_en_gpio, ret);
- return ret;
- }
- gpio_direction_output(spkamp_en_gpio, 0);
- }
- return 0;
- }
- static int msm8974_prepare_micbias_to_codec(void)
- {
- int ret;
- if (micbias_en_msm_gpio) {
- pr_debug("%s : micbias en msm gpio request %d", __func__,
- micbias_en_msm_gpio);
- ret = gpio_request(micbias_en_msm_gpio, "MICBIAS_TO_CODEC");
- if (ret) {
- pr_debug("%s: Failed to request taiko micbias en msm gpio %d error %d\n",
- __func__, micbias_en_msm_gpio, ret);
- return ret;
- }
- gpio_direction_output(micbias_en_msm_gpio, 0);
- }
- return 0;
- }
- static __devinit int msm8974_asoc_machine_probe(struct platform_device *pdev)
- {
- struct snd_soc_card *card = &snd_soc_card_msm8974;
- struct msm8974_asoc_mach_data *pdata;
- int ret;
- const char *auxpcm_pri_gpio_set = NULL;
- const char *prop_name_ult_lo_gpio = "qcom,ext-ult-lo-amp-gpio";
- const char *mbhc_audio_jack_type = NULL;
- size_t n = strlen("4-pole-jack");
- struct resource *pri_muxsel;
- struct resource *sec_muxsel;
- #if defined(CONFIG_SEC_JACTIVE_PROJECT)
- extern unsigned int system_rev;
- #endif
- if (!pdev->dev.of_node) {
- dev_err(&pdev->dev, "No platform supplied from device tree\n");
- return -EINVAL;
- }
- pdata = devm_kzalloc(&pdev->dev,
- sizeof(struct msm8974_asoc_mach_data), GFP_KERNEL);
- if (!pdata) {
- dev_err(&pdev->dev, "Can't allocate msm8974_asoc_mach_data\n");
- return -ENOMEM;
- }
- card->dev = &pdev->dev;
- platform_set_drvdata(pdev, card);
- snd_soc_card_set_drvdata(card, pdata);
- ret = snd_soc_of_parse_card_name(card, "qcom,model");
- if (ret)
- goto err;
- ret = snd_soc_of_parse_audio_routing(card,
- "qcom,audio-routing");
- if (ret)
- goto err;
- ret = of_property_read_u32(pdev->dev.of_node,
- "qcom,taiko-mclk-clk-freq", &pdata->mclk_freq);
- if (ret) {
- dev_err(&pdev->dev, "Looking up %s property in node %s failed",
- "qcom,taiko-mclk-clk-freq",
- pdev->dev.of_node->full_name);
- goto err;
- }
- if (pdata->mclk_freq != 9600000) {
- dev_err(&pdev->dev, "unsupported taiko mclk freq %u\n",
- pdata->mclk_freq);
- ret = -EINVAL;
- goto err;
- }
- pdata->mclk_gpio = of_get_named_gpio(pdev->dev.of_node,
- "qcom,cdc-mclk-gpios", 0);
- if (pdata->mclk_gpio < 0) {
- dev_err(&pdev->dev,
- "Looking up %s property in node %s failed %d\n",
- "qcom, cdc-mclk-gpios", pdev->dev.of_node->full_name,
- pdata->mclk_gpio);
- ret = -ENODEV;
- goto err;
- }
- ret = msm8974_prepare_codec_mclk(card);
- if (ret)
- goto err;
- ret = of_property_read_string(pdev->dev.of_node,
- "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
- if (ret) {
- dev_dbg(&pdev->dev, "Looking up %s property in node %s failed",
- "qcom,mbhc-audio-jack-type",
- pdev->dev.of_node->full_name);
- mbhc_cfg.hw_jack_type = FOUR_POLE_JACK;
- mbhc_cfg.enable_anc_mic_detect = false;
- dev_dbg(&pdev->dev, "Jack type properties set to default");
- } else {
- if (!strncmp(mbhc_audio_jack_type, "4-pole-jack", n)) {
- mbhc_cfg.hw_jack_type = FOUR_POLE_JACK;
- mbhc_cfg.enable_anc_mic_detect = false;
- dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
- } else if (!strncmp(mbhc_audio_jack_type, "5-pole-jack", n)) {
- mbhc_cfg.hw_jack_type = FIVE_POLE_JACK;
- mbhc_cfg.enable_anc_mic_detect = true;
- dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
- } else if (!strncmp(mbhc_audio_jack_type, "6-pole-jack", n)) {
- mbhc_cfg.hw_jack_type = SIX_POLE_JACK;
- mbhc_cfg.enable_anc_mic_detect = true;
- dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
- } else {
- mbhc_cfg.hw_jack_type = FOUR_POLE_JACK;
- mbhc_cfg.enable_anc_mic_detect = false;
- dev_dbg(&pdev->dev, "Unknown value, hence setting to default");
- }
- }
- if (of_property_read_bool(pdev->dev.of_node, "qcom,hdmi-audio-rx")) {
- dev_info(&pdev->dev, "%s(): hdmi audio support present\n",
- __func__);
- memcpy(msm8974_dai_links, msm8974_common_dai_links,
- sizeof(msm8974_common_dai_links));
- memcpy(msm8974_dai_links + ARRAY_SIZE(msm8974_common_dai_links),
- msm8974_hdmi_dai_link, sizeof(msm8974_hdmi_dai_link));
- card->dai_link = msm8974_dai_links;
- card->num_links = ARRAY_SIZE(msm8974_dai_links);
- } else {
- dev_info(&pdev->dev, "%s(): No hdmi audio support\n", __func__);
- card->dai_link = msm8974_common_dai_links;
- card->num_links = ARRAY_SIZE(msm8974_common_dai_links);
- }
- mutex_init(&cdc_mclk_mutex);
- atomic_set(&prim_auxpcm_rsc_ref, 0);
- atomic_set(&sec_auxpcm_rsc_ref, 0);
- spdev = pdev;
- ext_spk_amp_regulator = NULL;
- msm8974_liquid_dock_dev = NULL;
- ret = snd_soc_register_card(card);
- if (ret == -EPROBE_DEFER)
- goto err;
- else if (ret) {
- dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
- ret);
- goto err;
- }
- /* Parse Primary AUXPCM info from DT */
- ret = msm8974_dtparse_auxpcm(pdev, &pdata->pri_auxpcm_ctrl,
- msm_prim_auxpcm_gpio_name);
- if (ret) {
- dev_err(&pdev->dev,
- "%s: Primary Auxpcm pin data parse failed\n", __func__);
- goto err;
- }
- /* Parse Secondary AUXPCM info from DT */
- ret = msm8974_dtparse_auxpcm(pdev, &pdata->sec_auxpcm_ctrl,
- msm_sec_auxpcm_gpio_name);
- if (ret) {
- dev_err(&pdev->dev,
- "%s: Secondary Auxpcm pin data parse failed\n", __func__);
- goto err;
- }
- ext_ult_lo_amp_gpio = of_get_named_gpio(pdev->dev.of_node,
- prop_name_ult_lo_gpio, 0);
- if (!gpio_is_valid(ext_ult_lo_amp_gpio)) {
- dev_dbg(&pdev->dev,
- "Couldn't find %s property in node %s, %d\n",
- prop_name_ult_lo_gpio, pdev->dev.of_node->full_name,
- ext_ult_lo_amp_gpio);
- } else {
- ret = gpio_request(ext_ult_lo_amp_gpio, "US_AMP_GPIO");
- if (ret) {
- dev_err(card->dev,
- "%s: Failed to request US amp gpio %d\n",
- __func__, ext_ult_lo_amp_gpio);
- goto err;
- }
- }
- pdata->us_euro_gpio = of_get_named_gpio(pdev->dev.of_node,
- "qcom,us-euro-gpios", 0);
- if (pdata->us_euro_gpio < 0) {
- dev_info(&pdev->dev, "property %s not detected in node %s",
- "qcom,us-euro-gpios",
- pdev->dev.of_node->full_name);
- } else {
- dev_dbg(&pdev->dev, "%s detected %d",
- "qcom,us-euro-gpios", pdata->us_euro_gpio);
- mbhc_cfg.swap_gnd_mic = msm8974_swap_gnd_mic;
- }
- ret = msm8974_prepare_us_euro(card);
- if (ret)
- dev_err(&pdev->dev, "msm8974_prepare_us_euro failed (%d)\n",
- ret);
- #ifdef CONFIG_SEC_JACTIVE_PROJECT
- if(system_rev < 3) {
- ear_jack_fsa8038_en = of_get_named_gpio(pdev->dev.of_node, "qcom,fsa8038_enable", 0);
- if (ear_jack_fsa8038_en < 0) {
- dev_err(&pdev->dev, "Looking up %s property in node %s failed",
- "qcom,fsa8038_enable",
- pdev->dev.of_node->full_name);
- } else {
- ret = gpio_request(ear_jack_fsa8038_en, "fsa8038 enable");
- if (ret) {
- dev_err(&pdev->dev, "Looking up %s property in node %s failed",
- "qcom,fsa8038_enable",
- pdev->dev.of_node->full_name);
- gpio_free(ear_jack_fsa8038_en);
- } else {
- gpio_direction_output(ear_jack_fsa8038_en, 1);
- }
- }
- }
- #endif
- /* the ldo of main mic bias */
- mainmic_bias_gpio = of_get_named_gpio(pdev->dev.of_node,
- "qcom,mainmic-bias-gpio", 0);
- if (mainmic_bias_gpio < 0) {
- dev_err(&pdev->dev, "Looking up %s property in node %s failed",
- "qcom,mainmic-bias-gpio",
- pdev->dev.of_node->full_name);
- } else {
- pr_info("%s : mic bias = %d\n", __func__, mainmic_bias_gpio);
- ret = msm8974_prepare_mainmic();
- if (ret) {
- dev_err(&pdev->dev, "msm8974_prepare_mainmic failed (%d)\n",
- ret);
- gpio_free(mainmic_bias_gpio);
- mainmic_bias_gpio = 0;
- }
- }
- #if defined(CONFIG_LDO_SUBMIC_BIAS)
- /* the ldo of sub mic bias */
- submic_bias_gpio = of_get_named_gpio(pdev->dev.of_node,
- "qcom,submic-bias-gpio", 0);
- pr_info("%s :sub mic bias = %d\n", __func__, submic_bias_gpio);
- ret = msm8974_prepare_submic();
- if (ret) {
- dev_err(&pdev->dev, "msm8974_prepare_submic failed (%d)\n",
- ret);
- gpio_free(submic_bias_gpio);
- submic_bias_gpio = 0;
- }
- #endif
- #if defined(CONFIG_LDO_EARMIC_BIAS)
- /* the ldo of ear mic bias */
- earmic_bias_gpio = of_get_named_gpio(pdev->dev.of_node,
- "qcom,earmic-bias-gpio", 0);
- pr_info("%s :ear mic bias = %d\n", __func__, earmic_bias_gpio);
- ret = msm8974_prepare_earmic();
- if (ret) {
- dev_err(&pdev->dev, "msm8974_prepare_earmic failed (%d)\n",
- ret);
- gpio_free(earmic_bias_gpio);
- earmic_bias_gpio = 0;
- }
- #endif
- #if defined(CONFIG_MACH_KLTE_KOR) || defined(CONFIG_MACH_KLTE_JPN) || defined(CONFIG_MACH_KACTIVELTE_DCM) \
- || defined(CONFIG_MACH_CHAGALL_KDI) || defined(CONFIG_MACH_KLIMT_LTE_DCM) || defined(CONFIG_MACH_KACTIVELTE_KOR)
- /* enable FSA8039 for jack detection */
- pr_info("%s: Check to enable FSA8039\n", __func__);
- fsa_en_gpio = of_get_named_gpio(pdev->dev.of_node,
- "qcom,earjack-fsa_en-gpio", 0);
- if (fsa_en_gpio < 0)
- of_property_read_u32(pdev->dev.of_node,
- "qcom,earjack-fsa_en-expander-gpio", &fsa_en_gpio);
- if (fsa_en_gpio < 0)
- pr_info("%s: No support FSA8039 chip\n", __func__);
- else
- pr_info("%s: earjack-fsa_en-gpio =%d\n",
- __func__, fsa_en_gpio);
- if (fsa_en_gpio > 0) {
- ret = gpio_request(fsa_en_gpio, "fsa_en");
- if (ret) {
- pr_err("%s : gpio_request failed for %d, ret %d\n",
- __func__, fsa_en_gpio, ret);
- goto err;
- }
- gpio_direction_output(fsa_en_gpio, 1);
- }
- #endif
- /* the switch to connect the main mic to the codec or es705 */
- #if defined(CONFIG_MACH_KLTE_JPN) || defined(CONFIG_MACH_KACTIVELTE_DCM) || defined(CONFIG_MACH_CHAGALL_KDI) || defined(CONFIG_MACH_KLIMT_LTE_DCM)
- #if defined(CONFIG_MACH_KLTE_MAX77828_JPN)
- micbias_en_msm_gpio = of_get_named_gpio(pdev->dev.of_node,
- "qcom,micbias-en-msm-gpio", 0);
- #else
- micbias_en_msm_gpio = of_get_named_gpio(pdev->dev.of_node,
- "qcom,micbias-en-msm-jpn-gpio", 0);
- #endif
- #else
- micbias_en_msm_gpio = of_get_named_gpio(pdev->dev.of_node,
- "qcom,micbias-en-msm-gpio", 0);
- #endif
- if (micbias_en_msm_gpio < 0) {
- dev_err(&pdev->dev, "Looking up %s property in node %s failed",
- "qcom,micbias-en-msm-gpio",
- pdev->dev.of_node->full_name);
- } else {
- pr_info("%s : micbias en msm = %d\n", __func__, micbias_en_msm_gpio);
- ret = msm8974_prepare_micbias_to_codec();
- if (ret) {
- dev_err(&pdev->dev, "msm8974_prepare_micbias_to_codec failed (%d)\n",
- ret);
- gpio_free(micbias_en_msm_gpio);
- micbias_en_msm_gpio = 0;
- }
- }
- spkamp_en_gpio = of_get_named_gpio(pdev->dev.of_node,
- "qcom,spkamp-en-gpio", 0);
- if (spkamp_en_gpio < 0) {
- dev_err(&pdev->dev, "Looking up %s property in node %s failed",
- "qcom,spkamp-en-gpio",
- pdev->dev.of_node->full_name);
- } else {
- pr_info("%s : spkamp_en_ gpio = %d\n", __func__, spkamp_en_gpio);
- ret = msm8974_prepare_spkamp();
- if (ret) {
- dev_err(&pdev->dev, "msm8974_prepare_spkamp_en_ gpio failed (%d)\n",
- ret);
- gpio_free(spkamp_en_gpio);
- spkamp_en_gpio = 0;
- }
- }
- ret = of_property_read_string(pdev->dev.of_node,
- "qcom,prim-auxpcm-gpio-set", &auxpcm_pri_gpio_set);
- if (ret) {
- dev_err(&pdev->dev, "Looking up %s property in node %s failed",
- "qcom,prim-auxpcm-gpio-set",
- pdev->dev.of_node->full_name);
- goto err1;
- }
- if (!strcmp(auxpcm_pri_gpio_set, "prim-gpio-prim")) {
- pri_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
- "lpaif_pri_mode_muxsel");
- } else if (!strcmp(auxpcm_pri_gpio_set, "prim-gpio-tert")) {
- pri_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
- "lpaif_tert_mode_muxsel");
- } else {
- dev_err(&pdev->dev, "Invalid value %s for AUXPCM GPIO set\n",
- auxpcm_pri_gpio_set);
- ret = -EINVAL;
- goto err1;
- }
- if (!pri_muxsel) {
- dev_err(&pdev->dev, "MUX addr invalid for primary AUXPCM\n");
- ret = -ENODEV;
- goto err1;
- } else {
- pdata->pri_auxpcm_ctrl->mux = ioremap(pri_muxsel->start,
- resource_size(pri_muxsel));
- if (pdata->pri_auxpcm_ctrl->mux == NULL) {
- pr_err("%s Pri muxsel virt addr is null\n", __func__);
- ret = -EINVAL;
- goto err1;
- }
- }
- #if defined( CONFIG_PCM_ROUTE_VOICE_STUB ) || defined(CONFIG_BT_CALL_FORWARDING)
- sec_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
- "lpaif_quat_mode_muxsel");
- #else
- sec_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
- "lpaif_sec_mode_muxsel");
- #endif /* CONFIG_PCM_ROUTE_VOICE_STUB || CONFIG_BT_CALL_FORWARDING*/
- if (!sec_muxsel) {
- dev_err(&pdev->dev, "MUX addr invalid for secondary AUXPCM\n");
- ret = -ENODEV;
- goto err2;
- }
- pdata->sec_auxpcm_ctrl->mux = ioremap(sec_muxsel->start,
- resource_size(sec_muxsel));
- if (pdata->sec_auxpcm_ctrl->mux == NULL) {
- pr_err("%s Sec muxsel virt addr is null\n", __func__);
- ret = -EINVAL;
- goto err2;
- }
- #if defined (CONFIG_SND_SOC_MAX98504) || defined (CONFIG_SND_SOC_MAX98506)
- atomic_set(&pri_mi2s_clk.mi2s_rsc_ref, 0);
- #endif
- return 0;
- err2:
- iounmap(pdata->pri_auxpcm_ctrl->mux);
- err1:
- if (ext_ult_lo_amp_gpio >= 0)
- gpio_free(ext_ult_lo_amp_gpio);
- ext_ult_lo_amp_gpio = -1;
- err:
- if (pdata->mclk_gpio > 0) {
- dev_dbg(&pdev->dev, "%s free gpio %d\n",
- __func__, pdata->mclk_gpio);
- gpio_free(pdata->mclk_gpio);
- pdata->mclk_gpio = 0;
- }
- if (pdata->us_euro_gpio > 0) {
- dev_dbg(&pdev->dev, "%s free us_euro gpio %d\n",
- __func__, pdata->us_euro_gpio);
- gpio_free(pdata->us_euro_gpio);
- pdata->us_euro_gpio = 0;
- }
- mutex_destroy(&cdc_mclk_mutex);
- devm_kfree(&pdev->dev, pdata);
- return ret;
- }
- static int __devexit msm8974_asoc_machine_remove(struct platform_device *pdev)
- {
- struct snd_soc_card *card = platform_get_drvdata(pdev);
- struct msm8974_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
- if (ext_spk_amp_regulator)
- regulator_put(ext_spk_amp_regulator);
- if (gpio_is_valid(ext_ult_spk_amp_gpio))
- gpio_free(ext_ult_spk_amp_gpio);
- if (gpio_is_valid(ext_ult_lo_amp_gpio))
- gpio_free(ext_ult_lo_amp_gpio);
- gpio_free(pdata->mclk_gpio);
- gpio_free(pdata->us_euro_gpio);
- if (gpio_is_valid(ext_spk_amp_gpio))
- gpio_free(ext_spk_amp_gpio);
- if (msm8974_liquid_dock_dev != NULL) {
- if (msm8974_liquid_dock_dev->dock_plug_gpio)
- gpio_free(msm8974_liquid_dock_dev->dock_plug_gpio);
- if (msm8974_liquid_dock_dev->dock_plug_irq)
- free_irq(msm8974_liquid_dock_dev->dock_plug_irq,
- msm8974_liquid_dock_dev);
- kfree(msm8974_liquid_dock_dev);
- msm8974_liquid_dock_dev = NULL;
- }
- iounmap(pdata->pri_auxpcm_ctrl->mux);
- iounmap(pdata->sec_auxpcm_ctrl->mux);
- snd_soc_unregister_card(card);
- return 0;
- }
- static const struct of_device_id msm8974_asoc_machine_of_match[] = {
- { .compatible = "qcom,msm8974-audio-taiko", },
- {},
- };
- static struct platform_driver msm8974_asoc_machine_driver = {
- .driver = {
- .name = DRV_NAME,
- .owner = THIS_MODULE,
- .pm = &snd_soc_pm_ops,
- .of_match_table = msm8974_asoc_machine_of_match,
- },
- .probe = msm8974_asoc_machine_probe,
- .remove = __devexit_p(msm8974_asoc_machine_remove),
- };
- module_platform_driver(msm8974_asoc_machine_driver);
- MODULE_DESCRIPTION("ALSA SoC msm");
- MODULE_LICENSE("GPL v2");
- MODULE_ALIAS("platform:" DRV_NAME);
- MODULE_DEVICE_TABLE(of, msm8974_asoc_machine_of_match);
|