soc-dapm.c 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886
  1. /*
  2. * soc-dapm.c -- ALSA SoC Dynamic Audio Power Management
  3. *
  4. * Copyright 2005 Wolfson Microelectronics PLC.
  5. * Author: Liam Girdwood <lrg@slimlogic.co.uk>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * Features:
  13. * o Changes power status of internal codec blocks depending on the
  14. * dynamic configuration of codec internal audio paths and active
  15. * DACs/ADCs.
  16. * o Platform power domain - can support external components i.e. amps and
  17. * mic/meadphone insertion events.
  18. * o Automatic Mic Bias support
  19. * o Jack insertion power event initiation - e.g. hp insertion will enable
  20. * sinks, dacs, etc
  21. * o Delayed powerdown of audio susbsystem to reduce pops between a quick
  22. * device reopen.
  23. *
  24. * Todo:
  25. * o DAPM power change sequencing - allow for configurable per
  26. * codec sequences.
  27. * o Support for analogue bias optimisation.
  28. * o Support for reduced codec oversampling rates.
  29. * o Support for reduced codec bias currents.
  30. */
  31. #include <linux/module.h>
  32. #include <linux/moduleparam.h>
  33. #include <linux/init.h>
  34. #include <linux/delay.h>
  35. #include <linux/pm.h>
  36. #include <linux/bitops.h>
  37. #include <linux/platform_device.h>
  38. #include <linux/jiffies.h>
  39. #include <sound/core.h>
  40. #include <sound/pcm.h>
  41. #include <sound/pcm_params.h>
  42. #include <sound/soc-dapm.h>
  43. #include <sound/initval.h>
  44. /* debug */
  45. #ifdef DEBUG
  46. #define dump_dapm(codec, action) dbg_dump_dapm(codec, action)
  47. #else
  48. #define dump_dapm(codec, action)
  49. #endif
  50. /* dapm power sequences - make this per codec in the future */
  51. static int dapm_up_seq[] = {
  52. snd_soc_dapm_pre, snd_soc_dapm_supply, snd_soc_dapm_micbias,
  53. snd_soc_dapm_mic, snd_soc_dapm_mux, snd_soc_dapm_value_mux,
  54. snd_soc_dapm_dac, snd_soc_dapm_mixer, snd_soc_dapm_mixer_named_ctl,
  55. snd_soc_dapm_pga, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk,
  56. snd_soc_dapm_post
  57. };
  58. static int dapm_down_seq[] = {
  59. snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk,
  60. snd_soc_dapm_pga, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_mixer,
  61. snd_soc_dapm_dac, snd_soc_dapm_mic, snd_soc_dapm_micbias,
  62. snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_supply,
  63. snd_soc_dapm_post
  64. };
  65. static void pop_wait(u32 pop_time)
  66. {
  67. if (pop_time)
  68. schedule_timeout_uninterruptible(msecs_to_jiffies(pop_time));
  69. }
  70. static void pop_dbg(u32 pop_time, const char *fmt, ...)
  71. {
  72. va_list args;
  73. va_start(args, fmt);
  74. if (pop_time) {
  75. vprintk(fmt, args);
  76. pop_wait(pop_time);
  77. }
  78. va_end(args);
  79. }
  80. /* create a new dapm widget */
  81. static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
  82. const struct snd_soc_dapm_widget *_widget)
  83. {
  84. return kmemdup(_widget, sizeof(*_widget), GFP_KERNEL);
  85. }
  86. /**
  87. * snd_soc_dapm_set_bias_level - set the bias level for the system
  88. * @socdev: audio device
  89. * @level: level to configure
  90. *
  91. * Configure the bias (power) levels for the SoC audio device.
  92. *
  93. * Returns 0 for success else error.
  94. */
  95. static int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev,
  96. enum snd_soc_bias_level level)
  97. {
  98. struct snd_soc_card *card = socdev->card;
  99. struct snd_soc_codec *codec = socdev->card->codec;
  100. int ret = 0;
  101. switch (level) {
  102. case SND_SOC_BIAS_ON:
  103. dev_dbg(socdev->dev, "Setting full bias\n");
  104. break;
  105. case SND_SOC_BIAS_PREPARE:
  106. dev_dbg(socdev->dev, "Setting bias prepare\n");
  107. break;
  108. case SND_SOC_BIAS_STANDBY:
  109. dev_dbg(socdev->dev, "Setting standby bias\n");
  110. break;
  111. case SND_SOC_BIAS_OFF:
  112. dev_dbg(socdev->dev, "Setting bias off\n");
  113. break;
  114. default:
  115. dev_err(socdev->dev, "Setting invalid bias %d\n", level);
  116. return -EINVAL;
  117. }
  118. if (card->set_bias_level)
  119. ret = card->set_bias_level(card, level);
  120. if (ret == 0 && codec->set_bias_level)
  121. ret = codec->set_bias_level(codec, level);
  122. return ret;
  123. }
  124. /* set up initial codec paths */
  125. static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
  126. struct snd_soc_dapm_path *p, int i)
  127. {
  128. switch (w->id) {
  129. case snd_soc_dapm_switch:
  130. case snd_soc_dapm_mixer:
  131. case snd_soc_dapm_mixer_named_ctl: {
  132. int val;
  133. struct soc_mixer_control *mc = (struct soc_mixer_control *)
  134. w->kcontrols[i].private_value;
  135. unsigned int reg = mc->reg;
  136. unsigned int shift = mc->shift;
  137. int max = mc->max;
  138. unsigned int mask = (1 << fls(max)) - 1;
  139. unsigned int invert = mc->invert;
  140. val = snd_soc_read(w->codec, reg);
  141. val = (val >> shift) & mask;
  142. if ((invert && !val) || (!invert && val))
  143. p->connect = 1;
  144. else
  145. p->connect = 0;
  146. }
  147. break;
  148. case snd_soc_dapm_mux: {
  149. struct soc_enum *e = (struct soc_enum *)w->kcontrols[i].private_value;
  150. int val, item, bitmask;
  151. for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
  152. ;
  153. val = snd_soc_read(w->codec, e->reg);
  154. item = (val >> e->shift_l) & (bitmask - 1);
  155. p->connect = 0;
  156. for (i = 0; i < e->max; i++) {
  157. if (!(strcmp(p->name, e->texts[i])) && item == i)
  158. p->connect = 1;
  159. }
  160. }
  161. break;
  162. case snd_soc_dapm_value_mux: {
  163. struct soc_enum *e = (struct soc_enum *)
  164. w->kcontrols[i].private_value;
  165. int val, item;
  166. val = snd_soc_read(w->codec, e->reg);
  167. val = (val >> e->shift_l) & e->mask;
  168. for (item = 0; item < e->max; item++) {
  169. if (val == e->values[item])
  170. break;
  171. }
  172. p->connect = 0;
  173. for (i = 0; i < e->max; i++) {
  174. if (!(strcmp(p->name, e->texts[i])) && item == i)
  175. p->connect = 1;
  176. }
  177. }
  178. break;
  179. /* does not effect routing - always connected */
  180. case snd_soc_dapm_pga:
  181. case snd_soc_dapm_output:
  182. case snd_soc_dapm_adc:
  183. case snd_soc_dapm_input:
  184. case snd_soc_dapm_dac:
  185. case snd_soc_dapm_micbias:
  186. case snd_soc_dapm_vmid:
  187. case snd_soc_dapm_supply:
  188. p->connect = 1;
  189. break;
  190. /* does effect routing - dynamically connected */
  191. case snd_soc_dapm_hp:
  192. case snd_soc_dapm_mic:
  193. case snd_soc_dapm_spk:
  194. case snd_soc_dapm_line:
  195. case snd_soc_dapm_pre:
  196. case snd_soc_dapm_post:
  197. p->connect = 0;
  198. break;
  199. }
  200. }
  201. /* connect mux widget to its interconnecting audio paths */
  202. static int dapm_connect_mux(struct snd_soc_codec *codec,
  203. struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
  204. struct snd_soc_dapm_path *path, const char *control_name,
  205. const struct snd_kcontrol_new *kcontrol)
  206. {
  207. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  208. int i;
  209. for (i = 0; i < e->max; i++) {
  210. if (!(strcmp(control_name, e->texts[i]))) {
  211. list_add(&path->list, &codec->dapm_paths);
  212. list_add(&path->list_sink, &dest->sources);
  213. list_add(&path->list_source, &src->sinks);
  214. path->name = (char*)e->texts[i];
  215. dapm_set_path_status(dest, path, 0);
  216. return 0;
  217. }
  218. }
  219. return -ENODEV;
  220. }
  221. /* connect mixer widget to its interconnecting audio paths */
  222. static int dapm_connect_mixer(struct snd_soc_codec *codec,
  223. struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
  224. struct snd_soc_dapm_path *path, const char *control_name)
  225. {
  226. int i;
  227. /* search for mixer kcontrol */
  228. for (i = 0; i < dest->num_kcontrols; i++) {
  229. if (!strcmp(control_name, dest->kcontrols[i].name)) {
  230. list_add(&path->list, &codec->dapm_paths);
  231. list_add(&path->list_sink, &dest->sources);
  232. list_add(&path->list_source, &src->sinks);
  233. path->name = dest->kcontrols[i].name;
  234. dapm_set_path_status(dest, path, i);
  235. return 0;
  236. }
  237. }
  238. return -ENODEV;
  239. }
  240. /* update dapm codec register bits */
  241. static int dapm_update_bits(struct snd_soc_dapm_widget *widget)
  242. {
  243. int change, power;
  244. unsigned short old, new;
  245. struct snd_soc_codec *codec = widget->codec;
  246. /* check for valid widgets */
  247. if (widget->reg < 0 || widget->id == snd_soc_dapm_input ||
  248. widget->id == snd_soc_dapm_output ||
  249. widget->id == snd_soc_dapm_hp ||
  250. widget->id == snd_soc_dapm_mic ||
  251. widget->id == snd_soc_dapm_line ||
  252. widget->id == snd_soc_dapm_spk)
  253. return 0;
  254. power = widget->power;
  255. if (widget->invert)
  256. power = (power ? 0:1);
  257. old = snd_soc_read(codec, widget->reg);
  258. new = (old & ~(0x1 << widget->shift)) | (power << widget->shift);
  259. change = old != new;
  260. if (change) {
  261. pop_dbg(codec->pop_time, "pop test %s : %s in %d ms\n",
  262. widget->name, widget->power ? "on" : "off",
  263. codec->pop_time);
  264. snd_soc_write(codec, widget->reg, new);
  265. pop_wait(codec->pop_time);
  266. }
  267. pr_debug("reg %x old %x new %x change %d\n", widget->reg,
  268. old, new, change);
  269. return change;
  270. }
  271. /* ramps the volume up or down to minimise pops before or after a
  272. * DAPM power event */
  273. static int dapm_set_pga(struct snd_soc_dapm_widget *widget, int power)
  274. {
  275. const struct snd_kcontrol_new *k = widget->kcontrols;
  276. if (widget->muted && !power)
  277. return 0;
  278. if (!widget->muted && power)
  279. return 0;
  280. if (widget->num_kcontrols && k) {
  281. struct soc_mixer_control *mc =
  282. (struct soc_mixer_control *)k->private_value;
  283. unsigned int reg = mc->reg;
  284. unsigned int shift = mc->shift;
  285. int max = mc->max;
  286. unsigned int mask = (1 << fls(max)) - 1;
  287. unsigned int invert = mc->invert;
  288. if (power) {
  289. int i;
  290. /* power up has happended, increase volume to last level */
  291. if (invert) {
  292. for (i = max; i > widget->saved_value; i--)
  293. snd_soc_update_bits(widget->codec, reg, mask, i);
  294. } else {
  295. for (i = 0; i < widget->saved_value; i++)
  296. snd_soc_update_bits(widget->codec, reg, mask, i);
  297. }
  298. widget->muted = 0;
  299. } else {
  300. /* power down is about to occur, decrease volume to mute */
  301. int val = snd_soc_read(widget->codec, reg);
  302. int i = widget->saved_value = (val >> shift) & mask;
  303. if (invert) {
  304. for (; i < mask; i++)
  305. snd_soc_update_bits(widget->codec, reg, mask, i);
  306. } else {
  307. for (; i > 0; i--)
  308. snd_soc_update_bits(widget->codec, reg, mask, i);
  309. }
  310. widget->muted = 1;
  311. }
  312. }
  313. return 0;
  314. }
  315. /* create new dapm mixer control */
  316. static int dapm_new_mixer(struct snd_soc_codec *codec,
  317. struct snd_soc_dapm_widget *w)
  318. {
  319. int i, ret = 0;
  320. size_t name_len;
  321. struct snd_soc_dapm_path *path;
  322. /* add kcontrol */
  323. for (i = 0; i < w->num_kcontrols; i++) {
  324. /* match name */
  325. list_for_each_entry(path, &w->sources, list_sink) {
  326. /* mixer/mux paths name must match control name */
  327. if (path->name != (char*)w->kcontrols[i].name)
  328. continue;
  329. /* add dapm control with long name.
  330. * for dapm_mixer this is the concatenation of the
  331. * mixer and kcontrol name.
  332. * for dapm_mixer_named_ctl this is simply the
  333. * kcontrol name.
  334. */
  335. name_len = strlen(w->kcontrols[i].name) + 1;
  336. if (w->id != snd_soc_dapm_mixer_named_ctl)
  337. name_len += 1 + strlen(w->name);
  338. path->long_name = kmalloc(name_len, GFP_KERNEL);
  339. if (path->long_name == NULL)
  340. return -ENOMEM;
  341. switch (w->id) {
  342. default:
  343. snprintf(path->long_name, name_len, "%s %s",
  344. w->name, w->kcontrols[i].name);
  345. break;
  346. case snd_soc_dapm_mixer_named_ctl:
  347. snprintf(path->long_name, name_len, "%s",
  348. w->kcontrols[i].name);
  349. break;
  350. }
  351. path->long_name[name_len - 1] = '\0';
  352. path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w,
  353. path->long_name);
  354. ret = snd_ctl_add(codec->card, path->kcontrol);
  355. if (ret < 0) {
  356. printk(KERN_ERR "asoc: failed to add dapm kcontrol %s: %d\n",
  357. path->long_name,
  358. ret);
  359. kfree(path->long_name);
  360. path->long_name = NULL;
  361. return ret;
  362. }
  363. }
  364. }
  365. return ret;
  366. }
  367. /* create new dapm mux control */
  368. static int dapm_new_mux(struct snd_soc_codec *codec,
  369. struct snd_soc_dapm_widget *w)
  370. {
  371. struct snd_soc_dapm_path *path = NULL;
  372. struct snd_kcontrol *kcontrol;
  373. int ret = 0;
  374. if (!w->num_kcontrols) {
  375. printk(KERN_ERR "asoc: mux %s has no controls\n", w->name);
  376. return -EINVAL;
  377. }
  378. kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name);
  379. ret = snd_ctl_add(codec->card, kcontrol);
  380. if (ret < 0)
  381. goto err;
  382. list_for_each_entry(path, &w->sources, list_sink)
  383. path->kcontrol = kcontrol;
  384. return ret;
  385. err:
  386. printk(KERN_ERR "asoc: failed to add kcontrol %s\n", w->name);
  387. return ret;
  388. }
  389. /* create new dapm volume control */
  390. static int dapm_new_pga(struct snd_soc_codec *codec,
  391. struct snd_soc_dapm_widget *w)
  392. {
  393. struct snd_kcontrol *kcontrol;
  394. int ret = 0;
  395. if (!w->num_kcontrols)
  396. return -EINVAL;
  397. kcontrol = snd_soc_cnew(&w->kcontrols[0], w, w->name);
  398. ret = snd_ctl_add(codec->card, kcontrol);
  399. if (ret < 0) {
  400. printk(KERN_ERR "asoc: failed to add kcontrol %s\n", w->name);
  401. return ret;
  402. }
  403. return ret;
  404. }
  405. /* reset 'walked' bit for each dapm path */
  406. static inline void dapm_clear_walk(struct snd_soc_codec *codec)
  407. {
  408. struct snd_soc_dapm_path *p;
  409. list_for_each_entry(p, &codec->dapm_paths, list)
  410. p->walked = 0;
  411. }
  412. /*
  413. * Recursively check for a completed path to an active or physically connected
  414. * output widget. Returns number of complete paths.
  415. */
  416. static int is_connected_output_ep(struct snd_soc_dapm_widget *widget)
  417. {
  418. struct snd_soc_dapm_path *path;
  419. int con = 0;
  420. if (widget->id == snd_soc_dapm_supply)
  421. return 0;
  422. if (widget->id == snd_soc_dapm_adc && widget->active)
  423. return 1;
  424. if (widget->connected) {
  425. /* connected pin ? */
  426. if (widget->id == snd_soc_dapm_output && !widget->ext)
  427. return 1;
  428. /* connected jack or spk ? */
  429. if (widget->id == snd_soc_dapm_hp || widget->id == snd_soc_dapm_spk ||
  430. widget->id == snd_soc_dapm_line)
  431. return 1;
  432. }
  433. list_for_each_entry(path, &widget->sinks, list_source) {
  434. if (path->walked)
  435. continue;
  436. if (path->sink && path->connect) {
  437. path->walked = 1;
  438. con += is_connected_output_ep(path->sink);
  439. }
  440. }
  441. return con;
  442. }
  443. /*
  444. * Recursively check for a completed path to an active or physically connected
  445. * input widget. Returns number of complete paths.
  446. */
  447. static int is_connected_input_ep(struct snd_soc_dapm_widget *widget)
  448. {
  449. struct snd_soc_dapm_path *path;
  450. int con = 0;
  451. if (widget->id == snd_soc_dapm_supply)
  452. return 0;
  453. /* active stream ? */
  454. if (widget->id == snd_soc_dapm_dac && widget->active)
  455. return 1;
  456. if (widget->connected) {
  457. /* connected pin ? */
  458. if (widget->id == snd_soc_dapm_input && !widget->ext)
  459. return 1;
  460. /* connected VMID/Bias for lower pops */
  461. if (widget->id == snd_soc_dapm_vmid)
  462. return 1;
  463. /* connected jack ? */
  464. if (widget->id == snd_soc_dapm_mic || widget->id == snd_soc_dapm_line)
  465. return 1;
  466. }
  467. list_for_each_entry(path, &widget->sources, list_sink) {
  468. if (path->walked)
  469. continue;
  470. if (path->source && path->connect) {
  471. path->walked = 1;
  472. con += is_connected_input_ep(path->source);
  473. }
  474. }
  475. return con;
  476. }
  477. /*
  478. * Handler for generic register modifier widget.
  479. */
  480. int dapm_reg_event(struct snd_soc_dapm_widget *w,
  481. struct snd_kcontrol *kcontrol, int event)
  482. {
  483. unsigned int val;
  484. if (SND_SOC_DAPM_EVENT_ON(event))
  485. val = w->on_val;
  486. else
  487. val = w->off_val;
  488. snd_soc_update_bits(w->codec, -(w->reg + 1),
  489. w->mask << w->shift, val << w->shift);
  490. return 0;
  491. }
  492. EXPORT_SYMBOL_GPL(dapm_reg_event);
  493. /* Standard power change method, used to apply power changes to most
  494. * widgets.
  495. */
  496. static int dapm_generic_apply_power(struct snd_soc_dapm_widget *w)
  497. {
  498. int ret;
  499. /* call any power change event handlers */
  500. if (w->event)
  501. pr_debug("power %s event for %s flags %x\n",
  502. w->power ? "on" : "off",
  503. w->name, w->event_flags);
  504. /* power up pre event */
  505. if (w->power && w->event &&
  506. (w->event_flags & SND_SOC_DAPM_PRE_PMU)) {
  507. ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU);
  508. if (ret < 0)
  509. return ret;
  510. }
  511. /* power down pre event */
  512. if (!w->power && w->event &&
  513. (w->event_flags & SND_SOC_DAPM_PRE_PMD)) {
  514. ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD);
  515. if (ret < 0)
  516. return ret;
  517. }
  518. /* Lower PGA volume to reduce pops */
  519. if (w->id == snd_soc_dapm_pga && !w->power)
  520. dapm_set_pga(w, w->power);
  521. dapm_update_bits(w);
  522. /* Raise PGA volume to reduce pops */
  523. if (w->id == snd_soc_dapm_pga && w->power)
  524. dapm_set_pga(w, w->power);
  525. /* power up post event */
  526. if (w->power && w->event &&
  527. (w->event_flags & SND_SOC_DAPM_POST_PMU)) {
  528. ret = w->event(w,
  529. NULL, SND_SOC_DAPM_POST_PMU);
  530. if (ret < 0)
  531. return ret;
  532. }
  533. /* power down post event */
  534. if (!w->power && w->event &&
  535. (w->event_flags & SND_SOC_DAPM_POST_PMD)) {
  536. ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD);
  537. if (ret < 0)
  538. return ret;
  539. }
  540. return 0;
  541. }
  542. /* Generic check to see if a widget should be powered.
  543. */
  544. static int dapm_generic_check_power(struct snd_soc_dapm_widget *w)
  545. {
  546. int in, out;
  547. in = is_connected_input_ep(w);
  548. dapm_clear_walk(w->codec);
  549. out = is_connected_output_ep(w);
  550. dapm_clear_walk(w->codec);
  551. return out != 0 && in != 0;
  552. }
  553. /* Check to see if an ADC has power */
  554. static int dapm_adc_check_power(struct snd_soc_dapm_widget *w)
  555. {
  556. int in;
  557. if (w->active) {
  558. in = is_connected_input_ep(w);
  559. dapm_clear_walk(w->codec);
  560. return in != 0;
  561. } else {
  562. return dapm_generic_check_power(w);
  563. }
  564. }
  565. /* Check to see if a DAC has power */
  566. static int dapm_dac_check_power(struct snd_soc_dapm_widget *w)
  567. {
  568. int out;
  569. if (w->active) {
  570. out = is_connected_output_ep(w);
  571. dapm_clear_walk(w->codec);
  572. return out != 0;
  573. } else {
  574. return dapm_generic_check_power(w);
  575. }
  576. }
  577. /* Check to see if a power supply is needed */
  578. static int dapm_supply_check_power(struct snd_soc_dapm_widget *w)
  579. {
  580. struct snd_soc_dapm_path *path;
  581. int power = 0;
  582. /* Check if one of our outputs is connected */
  583. list_for_each_entry(path, &w->sinks, list_source) {
  584. if (path->sink && path->sink->power_check &&
  585. path->sink->power_check(path->sink)) {
  586. power = 1;
  587. break;
  588. }
  589. }
  590. dapm_clear_walk(w->codec);
  591. return power;
  592. }
  593. /*
  594. * Scan a single DAPM widget for a complete audio path and update the
  595. * power status appropriately.
  596. */
  597. static int dapm_power_widget(struct snd_soc_codec *codec, int event,
  598. struct snd_soc_dapm_widget *w)
  599. {
  600. int ret;
  601. switch (w->id) {
  602. case snd_soc_dapm_pre:
  603. if (!w->event)
  604. return 0;
  605. if (event == SND_SOC_DAPM_STREAM_START) {
  606. ret = w->event(w,
  607. NULL, SND_SOC_DAPM_PRE_PMU);
  608. if (ret < 0)
  609. return ret;
  610. } else if (event == SND_SOC_DAPM_STREAM_STOP) {
  611. ret = w->event(w,
  612. NULL, SND_SOC_DAPM_PRE_PMD);
  613. if (ret < 0)
  614. return ret;
  615. }
  616. return 0;
  617. case snd_soc_dapm_post:
  618. if (!w->event)
  619. return 0;
  620. if (event == SND_SOC_DAPM_STREAM_START) {
  621. ret = w->event(w,
  622. NULL, SND_SOC_DAPM_POST_PMU);
  623. if (ret < 0)
  624. return ret;
  625. } else if (event == SND_SOC_DAPM_STREAM_STOP) {
  626. ret = w->event(w,
  627. NULL, SND_SOC_DAPM_POST_PMD);
  628. if (ret < 0)
  629. return ret;
  630. }
  631. return 0;
  632. default:
  633. return dapm_generic_apply_power(w);
  634. }
  635. }
  636. /*
  637. * Scan each dapm widget for complete audio path.
  638. * A complete path is a route that has valid endpoints i.e.:-
  639. *
  640. * o DAC to output pin.
  641. * o Input Pin to ADC.
  642. * o Input pin to Output pin (bypass, sidetone)
  643. * o DAC to ADC (loopback).
  644. */
  645. static int dapm_power_widgets(struct snd_soc_codec *codec, int event)
  646. {
  647. struct snd_soc_device *socdev = codec->socdev;
  648. struct snd_soc_dapm_widget *w;
  649. int ret = 0;
  650. int i, power;
  651. int sys_power = 0;
  652. INIT_LIST_HEAD(&codec->up_list);
  653. INIT_LIST_HEAD(&codec->down_list);
  654. /* Check which widgets we need to power and store them in
  655. * lists indicating if they should be powered up or down.
  656. */
  657. list_for_each_entry(w, &codec->dapm_widgets, list) {
  658. switch (w->id) {
  659. case snd_soc_dapm_pre:
  660. list_add_tail(&codec->down_list, &w->power_list);
  661. break;
  662. case snd_soc_dapm_post:
  663. list_add_tail(&codec->up_list, &w->power_list);
  664. break;
  665. default:
  666. if (!w->power_check)
  667. continue;
  668. power = w->power_check(w);
  669. if (power)
  670. sys_power = 1;
  671. if (w->power == power)
  672. continue;
  673. if (power)
  674. list_add_tail(&w->power_list, &codec->up_list);
  675. else
  676. list_add_tail(&w->power_list,
  677. &codec->down_list);
  678. w->power = power;
  679. break;
  680. }
  681. }
  682. /* If we're changing to all on or all off then prepare */
  683. if ((sys_power && codec->bias_level == SND_SOC_BIAS_STANDBY) ||
  684. (!sys_power && codec->bias_level == SND_SOC_BIAS_ON)) {
  685. ret = snd_soc_dapm_set_bias_level(socdev,
  686. SND_SOC_BIAS_PREPARE);
  687. if (ret != 0)
  688. pr_err("Failed to prepare bias: %d\n", ret);
  689. }
  690. /* Power down widgets first; try to avoid amplifying pops. */
  691. for (i = 0; i < ARRAY_SIZE(dapm_down_seq); i++) {
  692. list_for_each_entry(w, &codec->down_list, power_list) {
  693. /* is widget in stream order */
  694. if (w->id != dapm_down_seq[i])
  695. continue;
  696. ret = dapm_power_widget(codec, event, w);
  697. if (ret != 0)
  698. pr_err("Failed to power down %s: %d\n",
  699. w->name, ret);
  700. }
  701. }
  702. /* Now power up. */
  703. for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++) {
  704. list_for_each_entry(w, &codec->up_list, power_list) {
  705. /* is widget in stream order */
  706. if (w->id != dapm_up_seq[i])
  707. continue;
  708. ret = dapm_power_widget(codec, event, w);
  709. if (ret != 0)
  710. pr_err("Failed to power up %s: %d\n",
  711. w->name, ret);
  712. }
  713. }
  714. /* If we just powered the last thing off drop to standby bias */
  715. if (codec->bias_level == SND_SOC_BIAS_PREPARE && !sys_power) {
  716. ret = snd_soc_dapm_set_bias_level(socdev,
  717. SND_SOC_BIAS_STANDBY);
  718. if (ret != 0)
  719. pr_err("Failed to apply standby bias: %d\n", ret);
  720. }
  721. /* If we just powered up then move to active bias */
  722. if (codec->bias_level == SND_SOC_BIAS_PREPARE && sys_power) {
  723. ret = snd_soc_dapm_set_bias_level(socdev,
  724. SND_SOC_BIAS_ON);
  725. if (ret != 0)
  726. pr_err("Failed to apply active bias: %d\n", ret);
  727. }
  728. return 0;
  729. }
  730. #ifdef DEBUG
  731. static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action)
  732. {
  733. struct snd_soc_dapm_widget *w;
  734. struct snd_soc_dapm_path *p = NULL;
  735. int in, out;
  736. printk("DAPM %s %s\n", codec->name, action);
  737. list_for_each_entry(w, &codec->dapm_widgets, list) {
  738. /* only display widgets that effect routing */
  739. switch (w->id) {
  740. case snd_soc_dapm_pre:
  741. case snd_soc_dapm_post:
  742. case snd_soc_dapm_vmid:
  743. continue;
  744. case snd_soc_dapm_mux:
  745. case snd_soc_dapm_value_mux:
  746. case snd_soc_dapm_output:
  747. case snd_soc_dapm_input:
  748. case snd_soc_dapm_switch:
  749. case snd_soc_dapm_hp:
  750. case snd_soc_dapm_mic:
  751. case snd_soc_dapm_spk:
  752. case snd_soc_dapm_line:
  753. case snd_soc_dapm_micbias:
  754. case snd_soc_dapm_dac:
  755. case snd_soc_dapm_adc:
  756. case snd_soc_dapm_pga:
  757. case snd_soc_dapm_mixer:
  758. case snd_soc_dapm_mixer_named_ctl:
  759. case snd_soc_dapm_supply:
  760. if (w->name) {
  761. in = is_connected_input_ep(w);
  762. dapm_clear_walk(w->codec);
  763. out = is_connected_output_ep(w);
  764. dapm_clear_walk(w->codec);
  765. printk("%s: %s in %d out %d\n", w->name,
  766. w->power ? "On":"Off",in, out);
  767. list_for_each_entry(p, &w->sources, list_sink) {
  768. if (p->connect)
  769. printk(" in %s %s\n", p->name ? p->name : "static",
  770. p->source->name);
  771. }
  772. list_for_each_entry(p, &w->sinks, list_source) {
  773. if (p->connect)
  774. printk(" out %s %s\n", p->name ? p->name : "static",
  775. p->sink->name);
  776. }
  777. }
  778. break;
  779. }
  780. }
  781. }
  782. #endif
  783. /* test and update the power status of a mux widget */
  784. static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
  785. struct snd_kcontrol *kcontrol, int mask,
  786. int mux, int val, struct soc_enum *e)
  787. {
  788. struct snd_soc_dapm_path *path;
  789. int found = 0;
  790. if (widget->id != snd_soc_dapm_mux &&
  791. widget->id != snd_soc_dapm_value_mux)
  792. return -ENODEV;
  793. if (!snd_soc_test_bits(widget->codec, e->reg, mask, val))
  794. return 0;
  795. /* find dapm widget path assoc with kcontrol */
  796. list_for_each_entry(path, &widget->codec->dapm_paths, list) {
  797. if (path->kcontrol != kcontrol)
  798. continue;
  799. if (!path->name || !e->texts[mux])
  800. continue;
  801. found = 1;
  802. /* we now need to match the string in the enum to the path */
  803. if (!(strcmp(path->name, e->texts[mux])))
  804. path->connect = 1; /* new connection */
  805. else
  806. path->connect = 0; /* old connection must be powered down */
  807. }
  808. if (found) {
  809. dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP);
  810. dump_dapm(widget->codec, "mux power update");
  811. }
  812. return 0;
  813. }
  814. /* test and update the power status of a mixer or switch widget */
  815. static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
  816. struct snd_kcontrol *kcontrol, int reg,
  817. int val_mask, int val, int invert)
  818. {
  819. struct snd_soc_dapm_path *path;
  820. int found = 0;
  821. if (widget->id != snd_soc_dapm_mixer &&
  822. widget->id != snd_soc_dapm_mixer_named_ctl &&
  823. widget->id != snd_soc_dapm_switch)
  824. return -ENODEV;
  825. if (!snd_soc_test_bits(widget->codec, reg, val_mask, val))
  826. return 0;
  827. /* find dapm widget path assoc with kcontrol */
  828. list_for_each_entry(path, &widget->codec->dapm_paths, list) {
  829. if (path->kcontrol != kcontrol)
  830. continue;
  831. /* found, now check type */
  832. found = 1;
  833. if (val)
  834. /* new connection */
  835. path->connect = invert ? 0:1;
  836. else
  837. /* old connection must be powered down */
  838. path->connect = invert ? 1:0;
  839. break;
  840. }
  841. if (found) {
  842. dapm_power_widgets(widget->codec, SND_SOC_DAPM_STREAM_NOP);
  843. dump_dapm(widget->codec, "mixer power update");
  844. }
  845. return 0;
  846. }
  847. /* show dapm widget status in sys fs */
  848. static ssize_t dapm_widget_show(struct device *dev,
  849. struct device_attribute *attr, char *buf)
  850. {
  851. struct snd_soc_device *devdata = dev_get_drvdata(dev);
  852. struct snd_soc_codec *codec = devdata->card->codec;
  853. struct snd_soc_dapm_widget *w;
  854. int count = 0;
  855. char *state = "not set";
  856. list_for_each_entry(w, &codec->dapm_widgets, list) {
  857. /* only display widgets that burnm power */
  858. switch (w->id) {
  859. case snd_soc_dapm_hp:
  860. case snd_soc_dapm_mic:
  861. case snd_soc_dapm_spk:
  862. case snd_soc_dapm_line:
  863. case snd_soc_dapm_micbias:
  864. case snd_soc_dapm_dac:
  865. case snd_soc_dapm_adc:
  866. case snd_soc_dapm_pga:
  867. case snd_soc_dapm_mixer:
  868. case snd_soc_dapm_mixer_named_ctl:
  869. case snd_soc_dapm_supply:
  870. if (w->name)
  871. count += sprintf(buf + count, "%s: %s\n",
  872. w->name, w->power ? "On":"Off");
  873. break;
  874. default:
  875. break;
  876. }
  877. }
  878. switch (codec->bias_level) {
  879. case SND_SOC_BIAS_ON:
  880. state = "On";
  881. break;
  882. case SND_SOC_BIAS_PREPARE:
  883. state = "Prepare";
  884. break;
  885. case SND_SOC_BIAS_STANDBY:
  886. state = "Standby";
  887. break;
  888. case SND_SOC_BIAS_OFF:
  889. state = "Off";
  890. break;
  891. }
  892. count += sprintf(buf + count, "PM State: %s\n", state);
  893. return count;
  894. }
  895. static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
  896. int snd_soc_dapm_sys_add(struct device *dev)
  897. {
  898. return device_create_file(dev, &dev_attr_dapm_widget);
  899. }
  900. static void snd_soc_dapm_sys_remove(struct device *dev)
  901. {
  902. device_remove_file(dev, &dev_attr_dapm_widget);
  903. }
  904. /* free all dapm widgets and resources */
  905. static void dapm_free_widgets(struct snd_soc_codec *codec)
  906. {
  907. struct snd_soc_dapm_widget *w, *next_w;
  908. struct snd_soc_dapm_path *p, *next_p;
  909. list_for_each_entry_safe(w, next_w, &codec->dapm_widgets, list) {
  910. list_del(&w->list);
  911. kfree(w);
  912. }
  913. list_for_each_entry_safe(p, next_p, &codec->dapm_paths, list) {
  914. list_del(&p->list);
  915. kfree(p->long_name);
  916. kfree(p);
  917. }
  918. }
  919. static int snd_soc_dapm_set_pin(struct snd_soc_codec *codec,
  920. const char *pin, int status)
  921. {
  922. struct snd_soc_dapm_widget *w;
  923. list_for_each_entry(w, &codec->dapm_widgets, list) {
  924. if (!strcmp(w->name, pin)) {
  925. pr_debug("dapm: %s: pin %s\n", codec->name, pin);
  926. w->connected = status;
  927. return 0;
  928. }
  929. }
  930. pr_err("dapm: %s: configuring unknown pin %s\n", codec->name, pin);
  931. return -EINVAL;
  932. }
  933. /**
  934. * snd_soc_dapm_sync - scan and power dapm paths
  935. * @codec: audio codec
  936. *
  937. * Walks all dapm audio paths and powers widgets according to their
  938. * stream or path usage.
  939. *
  940. * Returns 0 for success.
  941. */
  942. int snd_soc_dapm_sync(struct snd_soc_codec *codec)
  943. {
  944. int ret = dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP);
  945. dump_dapm(codec, "sync");
  946. return ret;
  947. }
  948. EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);
  949. static int snd_soc_dapm_add_route(struct snd_soc_codec *codec,
  950. const char *sink, const char *control, const char *source)
  951. {
  952. struct snd_soc_dapm_path *path;
  953. struct snd_soc_dapm_widget *wsource = NULL, *wsink = NULL, *w;
  954. int ret = 0;
  955. /* find src and dest widgets */
  956. list_for_each_entry(w, &codec->dapm_widgets, list) {
  957. if (!wsink && !(strcmp(w->name, sink))) {
  958. wsink = w;
  959. continue;
  960. }
  961. if (!wsource && !(strcmp(w->name, source))) {
  962. wsource = w;
  963. }
  964. }
  965. if (wsource == NULL || wsink == NULL)
  966. return -ENODEV;
  967. path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL);
  968. if (!path)
  969. return -ENOMEM;
  970. path->source = wsource;
  971. path->sink = wsink;
  972. INIT_LIST_HEAD(&path->list);
  973. INIT_LIST_HEAD(&path->list_source);
  974. INIT_LIST_HEAD(&path->list_sink);
  975. /* check for external widgets */
  976. if (wsink->id == snd_soc_dapm_input) {
  977. if (wsource->id == snd_soc_dapm_micbias ||
  978. wsource->id == snd_soc_dapm_mic ||
  979. wsink->id == snd_soc_dapm_line ||
  980. wsink->id == snd_soc_dapm_output)
  981. wsink->ext = 1;
  982. }
  983. if (wsource->id == snd_soc_dapm_output) {
  984. if (wsink->id == snd_soc_dapm_spk ||
  985. wsink->id == snd_soc_dapm_hp ||
  986. wsink->id == snd_soc_dapm_line ||
  987. wsink->id == snd_soc_dapm_input)
  988. wsource->ext = 1;
  989. }
  990. /* connect static paths */
  991. if (control == NULL) {
  992. list_add(&path->list, &codec->dapm_paths);
  993. list_add(&path->list_sink, &wsink->sources);
  994. list_add(&path->list_source, &wsource->sinks);
  995. path->connect = 1;
  996. return 0;
  997. }
  998. /* connect dynamic paths */
  999. switch(wsink->id) {
  1000. case snd_soc_dapm_adc:
  1001. case snd_soc_dapm_dac:
  1002. case snd_soc_dapm_pga:
  1003. case snd_soc_dapm_input:
  1004. case snd_soc_dapm_output:
  1005. case snd_soc_dapm_micbias:
  1006. case snd_soc_dapm_vmid:
  1007. case snd_soc_dapm_pre:
  1008. case snd_soc_dapm_post:
  1009. case snd_soc_dapm_supply:
  1010. list_add(&path->list, &codec->dapm_paths);
  1011. list_add(&path->list_sink, &wsink->sources);
  1012. list_add(&path->list_source, &wsource->sinks);
  1013. path->connect = 1;
  1014. return 0;
  1015. case snd_soc_dapm_mux:
  1016. case snd_soc_dapm_value_mux:
  1017. ret = dapm_connect_mux(codec, wsource, wsink, path, control,
  1018. &wsink->kcontrols[0]);
  1019. if (ret != 0)
  1020. goto err;
  1021. break;
  1022. case snd_soc_dapm_switch:
  1023. case snd_soc_dapm_mixer:
  1024. case snd_soc_dapm_mixer_named_ctl:
  1025. ret = dapm_connect_mixer(codec, wsource, wsink, path, control);
  1026. if (ret != 0)
  1027. goto err;
  1028. break;
  1029. case snd_soc_dapm_hp:
  1030. case snd_soc_dapm_mic:
  1031. case snd_soc_dapm_line:
  1032. case snd_soc_dapm_spk:
  1033. list_add(&path->list, &codec->dapm_paths);
  1034. list_add(&path->list_sink, &wsink->sources);
  1035. list_add(&path->list_source, &wsource->sinks);
  1036. path->connect = 0;
  1037. return 0;
  1038. }
  1039. return 0;
  1040. err:
  1041. printk(KERN_WARNING "asoc: no dapm match for %s --> %s --> %s\n", source,
  1042. control, sink);
  1043. kfree(path);
  1044. return ret;
  1045. }
  1046. /**
  1047. * snd_soc_dapm_add_routes - Add routes between DAPM widgets
  1048. * @codec: codec
  1049. * @route: audio routes
  1050. * @num: number of routes
  1051. *
  1052. * Connects 2 dapm widgets together via a named audio path. The sink is
  1053. * the widget receiving the audio signal, whilst the source is the sender
  1054. * of the audio signal.
  1055. *
  1056. * Returns 0 for success else error. On error all resources can be freed
  1057. * with a call to snd_soc_card_free().
  1058. */
  1059. int snd_soc_dapm_add_routes(struct snd_soc_codec *codec,
  1060. const struct snd_soc_dapm_route *route, int num)
  1061. {
  1062. int i, ret;
  1063. for (i = 0; i < num; i++) {
  1064. ret = snd_soc_dapm_add_route(codec, route->sink,
  1065. route->control, route->source);
  1066. if (ret < 0) {
  1067. printk(KERN_ERR "Failed to add route %s->%s\n",
  1068. route->source,
  1069. route->sink);
  1070. return ret;
  1071. }
  1072. route++;
  1073. }
  1074. return 0;
  1075. }
  1076. EXPORT_SYMBOL_GPL(snd_soc_dapm_add_routes);
  1077. /**
  1078. * snd_soc_dapm_new_widgets - add new dapm widgets
  1079. * @codec: audio codec
  1080. *
  1081. * Checks the codec for any new dapm widgets and creates them if found.
  1082. *
  1083. * Returns 0 for success.
  1084. */
  1085. int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec)
  1086. {
  1087. struct snd_soc_dapm_widget *w;
  1088. list_for_each_entry(w, &codec->dapm_widgets, list)
  1089. {
  1090. if (w->new)
  1091. continue;
  1092. switch(w->id) {
  1093. case snd_soc_dapm_switch:
  1094. case snd_soc_dapm_mixer:
  1095. case snd_soc_dapm_mixer_named_ctl:
  1096. w->power_check = dapm_generic_check_power;
  1097. dapm_new_mixer(codec, w);
  1098. break;
  1099. case snd_soc_dapm_mux:
  1100. case snd_soc_dapm_value_mux:
  1101. w->power_check = dapm_generic_check_power;
  1102. dapm_new_mux(codec, w);
  1103. break;
  1104. case snd_soc_dapm_adc:
  1105. w->power_check = dapm_adc_check_power;
  1106. break;
  1107. case snd_soc_dapm_dac:
  1108. w->power_check = dapm_dac_check_power;
  1109. break;
  1110. case snd_soc_dapm_pga:
  1111. w->power_check = dapm_generic_check_power;
  1112. dapm_new_pga(codec, w);
  1113. break;
  1114. case snd_soc_dapm_input:
  1115. case snd_soc_dapm_output:
  1116. case snd_soc_dapm_micbias:
  1117. case snd_soc_dapm_spk:
  1118. case snd_soc_dapm_hp:
  1119. case snd_soc_dapm_mic:
  1120. case snd_soc_dapm_line:
  1121. w->power_check = dapm_generic_check_power;
  1122. break;
  1123. case snd_soc_dapm_supply:
  1124. w->power_check = dapm_supply_check_power;
  1125. case snd_soc_dapm_vmid:
  1126. case snd_soc_dapm_pre:
  1127. case snd_soc_dapm_post:
  1128. break;
  1129. }
  1130. w->new = 1;
  1131. }
  1132. dapm_power_widgets(codec, SND_SOC_DAPM_STREAM_NOP);
  1133. return 0;
  1134. }
  1135. EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
  1136. /**
  1137. * snd_soc_dapm_get_volsw - dapm mixer get callback
  1138. * @kcontrol: mixer control
  1139. * @ucontrol: control element information
  1140. *
  1141. * Callback to get the value of a dapm mixer control.
  1142. *
  1143. * Returns 0 for success.
  1144. */
  1145. int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
  1146. struct snd_ctl_elem_value *ucontrol)
  1147. {
  1148. struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
  1149. struct soc_mixer_control *mc =
  1150. (struct soc_mixer_control *)kcontrol->private_value;
  1151. unsigned int reg = mc->reg;
  1152. unsigned int shift = mc->shift;
  1153. unsigned int rshift = mc->rshift;
  1154. int max = mc->max;
  1155. unsigned int invert = mc->invert;
  1156. unsigned int mask = (1 << fls(max)) - 1;
  1157. /* return the saved value if we are powered down */
  1158. if (widget->id == snd_soc_dapm_pga && !widget->power) {
  1159. ucontrol->value.integer.value[0] = widget->saved_value;
  1160. return 0;
  1161. }
  1162. ucontrol->value.integer.value[0] =
  1163. (snd_soc_read(widget->codec, reg) >> shift) & mask;
  1164. if (shift != rshift)
  1165. ucontrol->value.integer.value[1] =
  1166. (snd_soc_read(widget->codec, reg) >> rshift) & mask;
  1167. if (invert) {
  1168. ucontrol->value.integer.value[0] =
  1169. max - ucontrol->value.integer.value[0];
  1170. if (shift != rshift)
  1171. ucontrol->value.integer.value[1] =
  1172. max - ucontrol->value.integer.value[1];
  1173. }
  1174. return 0;
  1175. }
  1176. EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw);
  1177. /**
  1178. * snd_soc_dapm_put_volsw - dapm mixer set callback
  1179. * @kcontrol: mixer control
  1180. * @ucontrol: control element information
  1181. *
  1182. * Callback to set the value of a dapm mixer control.
  1183. *
  1184. * Returns 0 for success.
  1185. */
  1186. int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
  1187. struct snd_ctl_elem_value *ucontrol)
  1188. {
  1189. struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
  1190. struct soc_mixer_control *mc =
  1191. (struct soc_mixer_control *)kcontrol->private_value;
  1192. unsigned int reg = mc->reg;
  1193. unsigned int shift = mc->shift;
  1194. unsigned int rshift = mc->rshift;
  1195. int max = mc->max;
  1196. unsigned int mask = (1 << fls(max)) - 1;
  1197. unsigned int invert = mc->invert;
  1198. unsigned short val, val2, val_mask;
  1199. int ret;
  1200. val = (ucontrol->value.integer.value[0] & mask);
  1201. if (invert)
  1202. val = max - val;
  1203. val_mask = mask << shift;
  1204. val = val << shift;
  1205. if (shift != rshift) {
  1206. val2 = (ucontrol->value.integer.value[1] & mask);
  1207. if (invert)
  1208. val2 = max - val2;
  1209. val_mask |= mask << rshift;
  1210. val |= val2 << rshift;
  1211. }
  1212. mutex_lock(&widget->codec->mutex);
  1213. widget->value = val;
  1214. /* save volume value if the widget is powered down */
  1215. if (widget->id == snd_soc_dapm_pga && !widget->power) {
  1216. widget->saved_value = val;
  1217. mutex_unlock(&widget->codec->mutex);
  1218. return 1;
  1219. }
  1220. dapm_mixer_update_power(widget, kcontrol, reg, val_mask, val, invert);
  1221. if (widget->event) {
  1222. if (widget->event_flags & SND_SOC_DAPM_PRE_REG) {
  1223. ret = widget->event(widget, kcontrol,
  1224. SND_SOC_DAPM_PRE_REG);
  1225. if (ret < 0) {
  1226. ret = 1;
  1227. goto out;
  1228. }
  1229. }
  1230. ret = snd_soc_update_bits(widget->codec, reg, val_mask, val);
  1231. if (widget->event_flags & SND_SOC_DAPM_POST_REG)
  1232. ret = widget->event(widget, kcontrol,
  1233. SND_SOC_DAPM_POST_REG);
  1234. } else
  1235. ret = snd_soc_update_bits(widget->codec, reg, val_mask, val);
  1236. out:
  1237. mutex_unlock(&widget->codec->mutex);
  1238. return ret;
  1239. }
  1240. EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
  1241. /**
  1242. * snd_soc_dapm_get_enum_double - dapm enumerated double mixer get callback
  1243. * @kcontrol: mixer control
  1244. * @ucontrol: control element information
  1245. *
  1246. * Callback to get the value of a dapm enumerated double mixer control.
  1247. *
  1248. * Returns 0 for success.
  1249. */
  1250. int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
  1251. struct snd_ctl_elem_value *ucontrol)
  1252. {
  1253. struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
  1254. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  1255. unsigned short val, bitmask;
  1256. for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
  1257. ;
  1258. val = snd_soc_read(widget->codec, e->reg);
  1259. ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1);
  1260. if (e->shift_l != e->shift_r)
  1261. ucontrol->value.enumerated.item[1] =
  1262. (val >> e->shift_r) & (bitmask - 1);
  1263. return 0;
  1264. }
  1265. EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
  1266. /**
  1267. * snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
  1268. * @kcontrol: mixer control
  1269. * @ucontrol: control element information
  1270. *
  1271. * Callback to set the value of a dapm enumerated double mixer control.
  1272. *
  1273. * Returns 0 for success.
  1274. */
  1275. int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
  1276. struct snd_ctl_elem_value *ucontrol)
  1277. {
  1278. struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
  1279. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  1280. unsigned short val, mux;
  1281. unsigned short mask, bitmask;
  1282. int ret = 0;
  1283. for (bitmask = 1; bitmask < e->max; bitmask <<= 1)
  1284. ;
  1285. if (ucontrol->value.enumerated.item[0] > e->max - 1)
  1286. return -EINVAL;
  1287. mux = ucontrol->value.enumerated.item[0];
  1288. val = mux << e->shift_l;
  1289. mask = (bitmask - 1) << e->shift_l;
  1290. if (e->shift_l != e->shift_r) {
  1291. if (ucontrol->value.enumerated.item[1] > e->max - 1)
  1292. return -EINVAL;
  1293. val |= ucontrol->value.enumerated.item[1] << e->shift_r;
  1294. mask |= (bitmask - 1) << e->shift_r;
  1295. }
  1296. mutex_lock(&widget->codec->mutex);
  1297. widget->value = val;
  1298. dapm_mux_update_power(widget, kcontrol, mask, mux, val, e);
  1299. if (widget->event) {
  1300. if (widget->event_flags & SND_SOC_DAPM_PRE_REG) {
  1301. ret = widget->event(widget,
  1302. kcontrol, SND_SOC_DAPM_PRE_REG);
  1303. if (ret < 0)
  1304. goto out;
  1305. }
  1306. ret = snd_soc_update_bits(widget->codec, e->reg, mask, val);
  1307. if (widget->event_flags & SND_SOC_DAPM_POST_REG)
  1308. ret = widget->event(widget,
  1309. kcontrol, SND_SOC_DAPM_POST_REG);
  1310. } else
  1311. ret = snd_soc_update_bits(widget->codec, e->reg, mask, val);
  1312. out:
  1313. mutex_unlock(&widget->codec->mutex);
  1314. return ret;
  1315. }
  1316. EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
  1317. /**
  1318. * snd_soc_dapm_get_value_enum_double - dapm semi enumerated double mixer get
  1319. * callback
  1320. * @kcontrol: mixer control
  1321. * @ucontrol: control element information
  1322. *
  1323. * Callback to get the value of a dapm semi enumerated double mixer control.
  1324. *
  1325. * Semi enumerated mixer: the enumerated items are referred as values. Can be
  1326. * used for handling bitfield coded enumeration for example.
  1327. *
  1328. * Returns 0 for success.
  1329. */
  1330. int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol,
  1331. struct snd_ctl_elem_value *ucontrol)
  1332. {
  1333. struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
  1334. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  1335. unsigned short reg_val, val, mux;
  1336. reg_val = snd_soc_read(widget->codec, e->reg);
  1337. val = (reg_val >> e->shift_l) & e->mask;
  1338. for (mux = 0; mux < e->max; mux++) {
  1339. if (val == e->values[mux])
  1340. break;
  1341. }
  1342. ucontrol->value.enumerated.item[0] = mux;
  1343. if (e->shift_l != e->shift_r) {
  1344. val = (reg_val >> e->shift_r) & e->mask;
  1345. for (mux = 0; mux < e->max; mux++) {
  1346. if (val == e->values[mux])
  1347. break;
  1348. }
  1349. ucontrol->value.enumerated.item[1] = mux;
  1350. }
  1351. return 0;
  1352. }
  1353. EXPORT_SYMBOL_GPL(snd_soc_dapm_get_value_enum_double);
  1354. /**
  1355. * snd_soc_dapm_put_value_enum_double - dapm semi enumerated double mixer set
  1356. * callback
  1357. * @kcontrol: mixer control
  1358. * @ucontrol: control element information
  1359. *
  1360. * Callback to set the value of a dapm semi enumerated double mixer control.
  1361. *
  1362. * Semi enumerated mixer: the enumerated items are referred as values. Can be
  1363. * used for handling bitfield coded enumeration for example.
  1364. *
  1365. * Returns 0 for success.
  1366. */
  1367. int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
  1368. struct snd_ctl_elem_value *ucontrol)
  1369. {
  1370. struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
  1371. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  1372. unsigned short val, mux;
  1373. unsigned short mask;
  1374. int ret = 0;
  1375. if (ucontrol->value.enumerated.item[0] > e->max - 1)
  1376. return -EINVAL;
  1377. mux = ucontrol->value.enumerated.item[0];
  1378. val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l;
  1379. mask = e->mask << e->shift_l;
  1380. if (e->shift_l != e->shift_r) {
  1381. if (ucontrol->value.enumerated.item[1] > e->max - 1)
  1382. return -EINVAL;
  1383. val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r;
  1384. mask |= e->mask << e->shift_r;
  1385. }
  1386. mutex_lock(&widget->codec->mutex);
  1387. widget->value = val;
  1388. dapm_mux_update_power(widget, kcontrol, mask, mux, val, e);
  1389. if (widget->event) {
  1390. if (widget->event_flags & SND_SOC_DAPM_PRE_REG) {
  1391. ret = widget->event(widget,
  1392. kcontrol, SND_SOC_DAPM_PRE_REG);
  1393. if (ret < 0)
  1394. goto out;
  1395. }
  1396. ret = snd_soc_update_bits(widget->codec, e->reg, mask, val);
  1397. if (widget->event_flags & SND_SOC_DAPM_POST_REG)
  1398. ret = widget->event(widget,
  1399. kcontrol, SND_SOC_DAPM_POST_REG);
  1400. } else
  1401. ret = snd_soc_update_bits(widget->codec, e->reg, mask, val);
  1402. out:
  1403. mutex_unlock(&widget->codec->mutex);
  1404. return ret;
  1405. }
  1406. EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double);
  1407. /**
  1408. * snd_soc_dapm_info_pin_switch - Info for a pin switch
  1409. *
  1410. * @kcontrol: mixer control
  1411. * @uinfo: control element information
  1412. *
  1413. * Callback to provide information about a pin switch control.
  1414. */
  1415. int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
  1416. struct snd_ctl_elem_info *uinfo)
  1417. {
  1418. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  1419. uinfo->count = 1;
  1420. uinfo->value.integer.min = 0;
  1421. uinfo->value.integer.max = 1;
  1422. return 0;
  1423. }
  1424. EXPORT_SYMBOL_GPL(snd_soc_dapm_info_pin_switch);
  1425. /**
  1426. * snd_soc_dapm_get_pin_switch - Get information for a pin switch
  1427. *
  1428. * @kcontrol: mixer control
  1429. * @ucontrol: Value
  1430. */
  1431. int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
  1432. struct snd_ctl_elem_value *ucontrol)
  1433. {
  1434. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  1435. const char *pin = (const char *)kcontrol->private_value;
  1436. mutex_lock(&codec->mutex);
  1437. ucontrol->value.integer.value[0] =
  1438. snd_soc_dapm_get_pin_status(codec, pin);
  1439. mutex_unlock(&codec->mutex);
  1440. return 0;
  1441. }
  1442. EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_switch);
  1443. /**
  1444. * snd_soc_dapm_put_pin_switch - Set information for a pin switch
  1445. *
  1446. * @kcontrol: mixer control
  1447. * @ucontrol: Value
  1448. */
  1449. int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
  1450. struct snd_ctl_elem_value *ucontrol)
  1451. {
  1452. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  1453. const char *pin = (const char *)kcontrol->private_value;
  1454. mutex_lock(&codec->mutex);
  1455. if (ucontrol->value.integer.value[0])
  1456. snd_soc_dapm_enable_pin(codec, pin);
  1457. else
  1458. snd_soc_dapm_disable_pin(codec, pin);
  1459. snd_soc_dapm_sync(codec);
  1460. mutex_unlock(&codec->mutex);
  1461. return 0;
  1462. }
  1463. EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch);
  1464. /**
  1465. * snd_soc_dapm_new_control - create new dapm control
  1466. * @codec: audio codec
  1467. * @widget: widget template
  1468. *
  1469. * Creates a new dapm control based upon the template.
  1470. *
  1471. * Returns 0 for success else error.
  1472. */
  1473. int snd_soc_dapm_new_control(struct snd_soc_codec *codec,
  1474. const struct snd_soc_dapm_widget *widget)
  1475. {
  1476. struct snd_soc_dapm_widget *w;
  1477. if ((w = dapm_cnew_widget(widget)) == NULL)
  1478. return -ENOMEM;
  1479. w->codec = codec;
  1480. INIT_LIST_HEAD(&w->sources);
  1481. INIT_LIST_HEAD(&w->sinks);
  1482. INIT_LIST_HEAD(&w->list);
  1483. list_add(&w->list, &codec->dapm_widgets);
  1484. /* machine layer set ups unconnected pins and insertions */
  1485. w->connected = 1;
  1486. return 0;
  1487. }
  1488. EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control);
  1489. /**
  1490. * snd_soc_dapm_new_controls - create new dapm controls
  1491. * @codec: audio codec
  1492. * @widget: widget array
  1493. * @num: number of widgets
  1494. *
  1495. * Creates new DAPM controls based upon the templates.
  1496. *
  1497. * Returns 0 for success else error.
  1498. */
  1499. int snd_soc_dapm_new_controls(struct snd_soc_codec *codec,
  1500. const struct snd_soc_dapm_widget *widget,
  1501. int num)
  1502. {
  1503. int i, ret;
  1504. for (i = 0; i < num; i++) {
  1505. ret = snd_soc_dapm_new_control(codec, widget);
  1506. if (ret < 0) {
  1507. printk(KERN_ERR
  1508. "ASoC: Failed to create DAPM control %s: %d\n",
  1509. widget->name, ret);
  1510. return ret;
  1511. }
  1512. widget++;
  1513. }
  1514. return 0;
  1515. }
  1516. EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls);
  1517. /**
  1518. * snd_soc_dapm_stream_event - send a stream event to the dapm core
  1519. * @codec: audio codec
  1520. * @stream: stream name
  1521. * @event: stream event
  1522. *
  1523. * Sends a stream event to the dapm core. The core then makes any
  1524. * necessary widget power changes.
  1525. *
  1526. * Returns 0 for success else error.
  1527. */
  1528. int snd_soc_dapm_stream_event(struct snd_soc_codec *codec,
  1529. char *stream, int event)
  1530. {
  1531. struct snd_soc_dapm_widget *w;
  1532. if (stream == NULL)
  1533. return 0;
  1534. mutex_lock(&codec->mutex);
  1535. list_for_each_entry(w, &codec->dapm_widgets, list)
  1536. {
  1537. if (!w->sname)
  1538. continue;
  1539. pr_debug("widget %s\n %s stream %s event %d\n",
  1540. w->name, w->sname, stream, event);
  1541. if (strstr(w->sname, stream)) {
  1542. switch(event) {
  1543. case SND_SOC_DAPM_STREAM_START:
  1544. w->active = 1;
  1545. break;
  1546. case SND_SOC_DAPM_STREAM_STOP:
  1547. w->active = 0;
  1548. break;
  1549. case SND_SOC_DAPM_STREAM_SUSPEND:
  1550. if (w->active)
  1551. w->suspend = 1;
  1552. w->active = 0;
  1553. break;
  1554. case SND_SOC_DAPM_STREAM_RESUME:
  1555. if (w->suspend) {
  1556. w->active = 1;
  1557. w->suspend = 0;
  1558. }
  1559. break;
  1560. case SND_SOC_DAPM_STREAM_PAUSE_PUSH:
  1561. break;
  1562. case SND_SOC_DAPM_STREAM_PAUSE_RELEASE:
  1563. break;
  1564. }
  1565. }
  1566. }
  1567. mutex_unlock(&codec->mutex);
  1568. dapm_power_widgets(codec, event);
  1569. dump_dapm(codec, __func__);
  1570. return 0;
  1571. }
  1572. EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event);
  1573. /**
  1574. * snd_soc_dapm_enable_pin - enable pin.
  1575. * @codec: SoC codec
  1576. * @pin: pin name
  1577. *
  1578. * Enables input/output pin and its parents or children widgets iff there is
  1579. * a valid audio route and active audio stream.
  1580. * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
  1581. * do any widget power switching.
  1582. */
  1583. int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, const char *pin)
  1584. {
  1585. return snd_soc_dapm_set_pin(codec, pin, 1);
  1586. }
  1587. EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
  1588. /**
  1589. * snd_soc_dapm_disable_pin - disable pin.
  1590. * @codec: SoC codec
  1591. * @pin: pin name
  1592. *
  1593. * Disables input/output pin and its parents or children widgets.
  1594. * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
  1595. * do any widget power switching.
  1596. */
  1597. int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, const char *pin)
  1598. {
  1599. return snd_soc_dapm_set_pin(codec, pin, 0);
  1600. }
  1601. EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
  1602. /**
  1603. * snd_soc_dapm_nc_pin - permanently disable pin.
  1604. * @codec: SoC codec
  1605. * @pin: pin name
  1606. *
  1607. * Marks the specified pin as being not connected, disabling it along
  1608. * any parent or child widgets. At present this is identical to
  1609. * snd_soc_dapm_disable_pin() but in future it will be extended to do
  1610. * additional things such as disabling controls which only affect
  1611. * paths through the pin.
  1612. *
  1613. * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
  1614. * do any widget power switching.
  1615. */
  1616. int snd_soc_dapm_nc_pin(struct snd_soc_codec *codec, const char *pin)
  1617. {
  1618. return snd_soc_dapm_set_pin(codec, pin, 0);
  1619. }
  1620. EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin);
  1621. /**
  1622. * snd_soc_dapm_get_pin_status - get audio pin status
  1623. * @codec: audio codec
  1624. * @pin: audio signal pin endpoint (or start point)
  1625. *
  1626. * Get audio pin status - connected or disconnected.
  1627. *
  1628. * Returns 1 for connected otherwise 0.
  1629. */
  1630. int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, const char *pin)
  1631. {
  1632. struct snd_soc_dapm_widget *w;
  1633. list_for_each_entry(w, &codec->dapm_widgets, list) {
  1634. if (!strcmp(w->name, pin))
  1635. return w->connected;
  1636. }
  1637. return 0;
  1638. }
  1639. EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status);
  1640. /**
  1641. * snd_soc_dapm_free - free dapm resources
  1642. * @socdev: SoC device
  1643. *
  1644. * Free all dapm widgets and resources.
  1645. */
  1646. void snd_soc_dapm_free(struct snd_soc_device *socdev)
  1647. {
  1648. struct snd_soc_codec *codec = socdev->card->codec;
  1649. snd_soc_dapm_sys_remove(socdev->dev);
  1650. dapm_free_widgets(codec);
  1651. }
  1652. EXPORT_SYMBOL_GPL(snd_soc_dapm_free);
  1653. /* Module information */
  1654. MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk");
  1655. MODULE_DESCRIPTION("Dynamic Audio Power Management core for ALSA SoC");
  1656. MODULE_LICENSE("GPL");