ams-delta.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. /*
  2. * ams-delta.c -- SoC audio for Amstrad E3 (Delta) videophone
  3. *
  4. * Copyright (C) 2009 Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
  5. *
  6. * Initially based on sound/soc/omap/osk5912.x
  7. * Copyright (C) 2008 Mistral Solutions
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. #include <linux/gpio.h>
  25. #include <linux/spinlock.h>
  26. #include <linux/tty.h>
  27. #include <linux/module.h>
  28. #include <sound/soc.h>
  29. #include <sound/jack.h>
  30. #include <asm/mach-types.h>
  31. #include <plat/board-ams-delta.h>
  32. #include <plat/mcbsp.h>
  33. #include "omap-mcbsp.h"
  34. #include "omap-pcm.h"
  35. #include "../codecs/cx20442.h"
  36. /* Board specific DAPM widgets */
  37. static const struct snd_soc_dapm_widget ams_delta_dapm_widgets[] = {
  38. /* Handset */
  39. SND_SOC_DAPM_MIC("Mouthpiece", NULL),
  40. SND_SOC_DAPM_HP("Earpiece", NULL),
  41. /* Handsfree/Speakerphone */
  42. SND_SOC_DAPM_MIC("Microphone", NULL),
  43. SND_SOC_DAPM_SPK("Speaker", NULL),
  44. };
  45. /* How they are connected to codec pins */
  46. static const struct snd_soc_dapm_route ams_delta_audio_map[] = {
  47. {"TELIN", NULL, "Mouthpiece"},
  48. {"Earpiece", NULL, "TELOUT"},
  49. {"MIC", NULL, "Microphone"},
  50. {"Speaker", NULL, "SPKOUT"},
  51. };
  52. /*
  53. * Controls, functional after the modem line discipline is activated.
  54. */
  55. /* Virtual switch: audio input/output constellations */
  56. static const char *ams_delta_audio_mode[] =
  57. {"Mixed", "Handset", "Handsfree", "Speakerphone"};
  58. /* Selection <-> pin translation */
  59. #define AMS_DELTA_MOUTHPIECE 0
  60. #define AMS_DELTA_EARPIECE 1
  61. #define AMS_DELTA_MICROPHONE 2
  62. #define AMS_DELTA_SPEAKER 3
  63. #define AMS_DELTA_AGC 4
  64. #define AMS_DELTA_MIXED ((1 << AMS_DELTA_EARPIECE) | \
  65. (1 << AMS_DELTA_MICROPHONE))
  66. #define AMS_DELTA_HANDSET ((1 << AMS_DELTA_MOUTHPIECE) | \
  67. (1 << AMS_DELTA_EARPIECE))
  68. #define AMS_DELTA_HANDSFREE ((1 << AMS_DELTA_MICROPHONE) | \
  69. (1 << AMS_DELTA_SPEAKER))
  70. #define AMS_DELTA_SPEAKERPHONE (AMS_DELTA_HANDSFREE | (1 << AMS_DELTA_AGC))
  71. static const unsigned short ams_delta_audio_mode_pins[] = {
  72. AMS_DELTA_MIXED,
  73. AMS_DELTA_HANDSET,
  74. AMS_DELTA_HANDSFREE,
  75. AMS_DELTA_SPEAKERPHONE,
  76. };
  77. static unsigned short ams_delta_audio_agc;
  78. static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
  79. struct snd_ctl_elem_value *ucontrol)
  80. {
  81. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  82. struct snd_soc_dapm_context *dapm = &codec->dapm;
  83. struct soc_enum *control = (struct soc_enum *)kcontrol->private_value;
  84. unsigned short pins;
  85. int pin, changed = 0;
  86. /* Refuse any mode changes if we are not able to control the codec. */
  87. if (!codec->hw_write)
  88. return -EUNATCH;
  89. if (ucontrol->value.enumerated.item[0] >= control->max)
  90. return -EINVAL;
  91. mutex_lock(&codec->mutex);
  92. /* Translate selection to bitmap */
  93. pins = ams_delta_audio_mode_pins[ucontrol->value.enumerated.item[0]];
  94. /* Setup pins after corresponding bits if changed */
  95. pin = !!(pins & (1 << AMS_DELTA_MOUTHPIECE));
  96. if (pin != snd_soc_dapm_get_pin_status(dapm, "Mouthpiece")) {
  97. changed = 1;
  98. if (pin)
  99. snd_soc_dapm_enable_pin(dapm, "Mouthpiece");
  100. else
  101. snd_soc_dapm_disable_pin(dapm, "Mouthpiece");
  102. }
  103. pin = !!(pins & (1 << AMS_DELTA_EARPIECE));
  104. if (pin != snd_soc_dapm_get_pin_status(dapm, "Earpiece")) {
  105. changed = 1;
  106. if (pin)
  107. snd_soc_dapm_enable_pin(dapm, "Earpiece");
  108. else
  109. snd_soc_dapm_disable_pin(dapm, "Earpiece");
  110. }
  111. pin = !!(pins & (1 << AMS_DELTA_MICROPHONE));
  112. if (pin != snd_soc_dapm_get_pin_status(dapm, "Microphone")) {
  113. changed = 1;
  114. if (pin)
  115. snd_soc_dapm_enable_pin(dapm, "Microphone");
  116. else
  117. snd_soc_dapm_disable_pin(dapm, "Microphone");
  118. }
  119. pin = !!(pins & (1 << AMS_DELTA_SPEAKER));
  120. if (pin != snd_soc_dapm_get_pin_status(dapm, "Speaker")) {
  121. changed = 1;
  122. if (pin)
  123. snd_soc_dapm_enable_pin(dapm, "Speaker");
  124. else
  125. snd_soc_dapm_disable_pin(dapm, "Speaker");
  126. }
  127. pin = !!(pins & (1 << AMS_DELTA_AGC));
  128. if (pin != ams_delta_audio_agc) {
  129. ams_delta_audio_agc = pin;
  130. changed = 1;
  131. if (pin)
  132. snd_soc_dapm_enable_pin(dapm, "AGCIN");
  133. else
  134. snd_soc_dapm_disable_pin(dapm, "AGCIN");
  135. }
  136. if (changed)
  137. snd_soc_dapm_sync(dapm);
  138. mutex_unlock(&codec->mutex);
  139. return changed;
  140. }
  141. static int ams_delta_get_audio_mode(struct snd_kcontrol *kcontrol,
  142. struct snd_ctl_elem_value *ucontrol)
  143. {
  144. struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
  145. struct snd_soc_dapm_context *dapm = &codec->dapm;
  146. unsigned short pins, mode;
  147. pins = ((snd_soc_dapm_get_pin_status(dapm, "Mouthpiece") <<
  148. AMS_DELTA_MOUTHPIECE) |
  149. (snd_soc_dapm_get_pin_status(dapm, "Earpiece") <<
  150. AMS_DELTA_EARPIECE));
  151. if (pins)
  152. pins |= (snd_soc_dapm_get_pin_status(dapm, "Microphone") <<
  153. AMS_DELTA_MICROPHONE);
  154. else
  155. pins = ((snd_soc_dapm_get_pin_status(dapm, "Microphone") <<
  156. AMS_DELTA_MICROPHONE) |
  157. (snd_soc_dapm_get_pin_status(dapm, "Speaker") <<
  158. AMS_DELTA_SPEAKER) |
  159. (ams_delta_audio_agc << AMS_DELTA_AGC));
  160. for (mode = 0; mode < ARRAY_SIZE(ams_delta_audio_mode); mode++)
  161. if (pins == ams_delta_audio_mode_pins[mode])
  162. break;
  163. if (mode >= ARRAY_SIZE(ams_delta_audio_mode))
  164. return -EINVAL;
  165. ucontrol->value.enumerated.item[0] = mode;
  166. return 0;
  167. }
  168. static const struct soc_enum ams_delta_audio_enum[] = {
  169. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ams_delta_audio_mode),
  170. ams_delta_audio_mode),
  171. };
  172. static const struct snd_kcontrol_new ams_delta_audio_controls[] = {
  173. SOC_ENUM_EXT("Audio Mode", ams_delta_audio_enum[0],
  174. ams_delta_get_audio_mode, ams_delta_set_audio_mode),
  175. };
  176. /* Hook switch */
  177. static struct snd_soc_jack ams_delta_hook_switch;
  178. static struct snd_soc_jack_gpio ams_delta_hook_switch_gpios[] = {
  179. {
  180. .gpio = 4,
  181. .name = "hook_switch",
  182. .report = SND_JACK_HEADSET,
  183. .invert = 1,
  184. .debounce_time = 150,
  185. }
  186. };
  187. /* After we are able to control the codec over the modem,
  188. * the hook switch can be used for dynamic DAPM reconfiguration. */
  189. static struct snd_soc_jack_pin ams_delta_hook_switch_pins[] = {
  190. /* Handset */
  191. {
  192. .pin = "Mouthpiece",
  193. .mask = SND_JACK_MICROPHONE,
  194. },
  195. {
  196. .pin = "Earpiece",
  197. .mask = SND_JACK_HEADPHONE,
  198. },
  199. /* Handsfree */
  200. {
  201. .pin = "Microphone",
  202. .mask = SND_JACK_MICROPHONE,
  203. .invert = 1,
  204. },
  205. {
  206. .pin = "Speaker",
  207. .mask = SND_JACK_HEADPHONE,
  208. .invert = 1,
  209. },
  210. };
  211. /*
  212. * Modem line discipline, required for making above controls functional.
  213. * Activated from userspace with ldattach, possibly invoked from udev rule.
  214. */
  215. /* To actually apply any modem controlled configuration changes to the codec,
  216. * we must connect codec DAI pins to the modem for a moment. Be careful not
  217. * to interfere with our digital mute function that shares the same hardware. */
  218. static struct timer_list cx81801_timer;
  219. static bool cx81801_cmd_pending;
  220. static bool ams_delta_muted;
  221. static DEFINE_SPINLOCK(ams_delta_lock);
  222. static void cx81801_timeout(unsigned long data)
  223. {
  224. int muted;
  225. spin_lock(&ams_delta_lock);
  226. cx81801_cmd_pending = 0;
  227. muted = ams_delta_muted;
  228. spin_unlock(&ams_delta_lock);
  229. /* Reconnect the codec DAI back from the modem to the CPU DAI
  230. * only if digital mute still off */
  231. if (!muted)
  232. ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 0);
  233. }
  234. /*
  235. * Used for passing a codec structure pointer
  236. * from the board initialization code to the tty line discipline.
  237. */
  238. static struct snd_soc_codec *cx20442_codec;
  239. /* Line discipline .open() */
  240. static int cx81801_open(struct tty_struct *tty)
  241. {
  242. int ret;
  243. if (!cx20442_codec)
  244. return -ENODEV;
  245. /*
  246. * Pass the codec structure pointer for use by other ldisc callbacks,
  247. * both the card and the codec specific parts.
  248. */
  249. tty->disc_data = cx20442_codec;
  250. ret = v253_ops.open(tty);
  251. if (ret < 0)
  252. tty->disc_data = NULL;
  253. return ret;
  254. }
  255. /* Line discipline .close() */
  256. static void cx81801_close(struct tty_struct *tty)
  257. {
  258. struct snd_soc_codec *codec = tty->disc_data;
  259. struct snd_soc_dapm_context *dapm = &codec->dapm;
  260. del_timer_sync(&cx81801_timer);
  261. /* Prevent the hook switch from further changing the DAPM pins */
  262. INIT_LIST_HEAD(&ams_delta_hook_switch.pins);
  263. if (!codec)
  264. return;
  265. v253_ops.close(tty);
  266. /* Revert back to default audio input/output constellation */
  267. snd_soc_dapm_disable_pin(dapm, "Mouthpiece");
  268. snd_soc_dapm_enable_pin(dapm, "Earpiece");
  269. snd_soc_dapm_enable_pin(dapm, "Microphone");
  270. snd_soc_dapm_disable_pin(dapm, "Speaker");
  271. snd_soc_dapm_disable_pin(dapm, "AGCIN");
  272. snd_soc_dapm_sync(dapm);
  273. }
  274. /* Line discipline .hangup() */
  275. static int cx81801_hangup(struct tty_struct *tty)
  276. {
  277. cx81801_close(tty);
  278. return 0;
  279. }
  280. /* Line discipline .receive_buf() */
  281. static void cx81801_receive(struct tty_struct *tty,
  282. const unsigned char *cp, char *fp, int count)
  283. {
  284. struct snd_soc_codec *codec = tty->disc_data;
  285. const unsigned char *c;
  286. int apply, ret;
  287. if (!codec)
  288. return;
  289. if (!codec->hw_write) {
  290. /* First modem response, complete setup procedure */
  291. /* Initialize timer used for config pulse generation */
  292. setup_timer(&cx81801_timer, cx81801_timeout, 0);
  293. v253_ops.receive_buf(tty, cp, fp, count);
  294. /* Link hook switch to DAPM pins */
  295. ret = snd_soc_jack_add_pins(&ams_delta_hook_switch,
  296. ARRAY_SIZE(ams_delta_hook_switch_pins),
  297. ams_delta_hook_switch_pins);
  298. if (ret)
  299. dev_warn(codec->dev,
  300. "Failed to link hook switch to DAPM pins, "
  301. "will continue with hook switch unlinked.\n");
  302. return;
  303. }
  304. v253_ops.receive_buf(tty, cp, fp, count);
  305. for (c = &cp[count - 1]; c >= cp; c--) {
  306. if (*c != '\r')
  307. continue;
  308. /* Complete modem response received, apply config to codec */
  309. spin_lock_bh(&ams_delta_lock);
  310. mod_timer(&cx81801_timer, jiffies + msecs_to_jiffies(150));
  311. apply = !ams_delta_muted && !cx81801_cmd_pending;
  312. cx81801_cmd_pending = 1;
  313. spin_unlock_bh(&ams_delta_lock);
  314. /* Apply config pulse by connecting the codec to the modem
  315. * if not already done */
  316. if (apply)
  317. ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
  318. AMS_DELTA_LATCH2_MODEM_CODEC);
  319. break;
  320. }
  321. }
  322. /* Line discipline .write_wakeup() */
  323. static void cx81801_wakeup(struct tty_struct *tty)
  324. {
  325. v253_ops.write_wakeup(tty);
  326. }
  327. static struct tty_ldisc_ops cx81801_ops = {
  328. .magic = TTY_LDISC_MAGIC,
  329. .name = "cx81801",
  330. .owner = THIS_MODULE,
  331. .open = cx81801_open,
  332. .close = cx81801_close,
  333. .hangup = cx81801_hangup,
  334. .receive_buf = cx81801_receive,
  335. .write_wakeup = cx81801_wakeup,
  336. };
  337. /*
  338. * Even if not very useful, the sound card can still work without any of the
  339. * above functonality activated. You can still control its audio input/output
  340. * constellation and speakerphone gain from userspace by issuing AT commands
  341. * over the modem port.
  342. */
  343. static int ams_delta_hw_params(struct snd_pcm_substream *substream,
  344. struct snd_pcm_hw_params *params)
  345. {
  346. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  347. /* Set cpu DAI configuration */
  348. return snd_soc_dai_set_fmt(rtd->cpu_dai,
  349. SND_SOC_DAIFMT_DSP_A |
  350. SND_SOC_DAIFMT_NB_NF |
  351. SND_SOC_DAIFMT_CBM_CFM);
  352. }
  353. static struct snd_soc_ops ams_delta_ops = {
  354. .hw_params = ams_delta_hw_params,
  355. };
  356. /* Digital mute implemented using modem/CPU multiplexer.
  357. * Shares hardware with codec config pulse generation */
  358. static bool ams_delta_muted = 1;
  359. static int ams_delta_digital_mute(struct snd_soc_dai *dai, int mute)
  360. {
  361. int apply;
  362. if (ams_delta_muted == mute)
  363. return 0;
  364. spin_lock_bh(&ams_delta_lock);
  365. ams_delta_muted = mute;
  366. apply = !cx81801_cmd_pending;
  367. spin_unlock_bh(&ams_delta_lock);
  368. if (apply)
  369. ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
  370. mute ? AMS_DELTA_LATCH2_MODEM_CODEC : 0);
  371. return 0;
  372. }
  373. /* Our codec DAI probably doesn't have its own .ops structure */
  374. static const struct snd_soc_dai_ops ams_delta_dai_ops = {
  375. .digital_mute = ams_delta_digital_mute,
  376. };
  377. /* Will be used if the codec ever has its own digital_mute function */
  378. static int ams_delta_startup(struct snd_pcm_substream *substream)
  379. {
  380. return ams_delta_digital_mute(NULL, 0);
  381. }
  382. static void ams_delta_shutdown(struct snd_pcm_substream *substream)
  383. {
  384. ams_delta_digital_mute(NULL, 1);
  385. }
  386. /*
  387. * Card initialization
  388. */
  389. static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
  390. {
  391. struct snd_soc_codec *codec = rtd->codec;
  392. struct snd_soc_dapm_context *dapm = &codec->dapm;
  393. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  394. struct snd_soc_card *card = rtd->card;
  395. int ret;
  396. /* Codec is ready, now add/activate board specific controls */
  397. /* Store a pointer to the codec structure for tty ldisc use */
  398. cx20442_codec = codec;
  399. /* Set up digital mute if not provided by the codec */
  400. if (!codec_dai->driver->ops) {
  401. codec_dai->driver->ops = &ams_delta_dai_ops;
  402. } else {
  403. ams_delta_ops.startup = ams_delta_startup;
  404. ams_delta_ops.shutdown = ams_delta_shutdown;
  405. }
  406. /* Add hook switch - can be used to control the codec from userspace
  407. * even if line discipline fails */
  408. ret = snd_soc_jack_new(rtd->codec, "hook_switch",
  409. SND_JACK_HEADSET, &ams_delta_hook_switch);
  410. if (ret)
  411. dev_warn(card->dev,
  412. "Failed to allocate resources for hook switch, "
  413. "will continue without one.\n");
  414. else {
  415. ret = snd_soc_jack_add_gpios(&ams_delta_hook_switch,
  416. ARRAY_SIZE(ams_delta_hook_switch_gpios),
  417. ams_delta_hook_switch_gpios);
  418. if (ret)
  419. dev_warn(card->dev,
  420. "Failed to set up hook switch GPIO line, "
  421. "will continue with hook switch inactive.\n");
  422. }
  423. /* Register optional line discipline for over the modem control */
  424. ret = tty_register_ldisc(N_V253, &cx81801_ops);
  425. if (ret) {
  426. dev_warn(card->dev,
  427. "Failed to register line discipline, "
  428. "will continue without any controls.\n");
  429. return 0;
  430. }
  431. /* Add board specific DAPM widgets and routes */
  432. ret = snd_soc_dapm_new_controls(dapm, ams_delta_dapm_widgets,
  433. ARRAY_SIZE(ams_delta_dapm_widgets));
  434. if (ret) {
  435. dev_warn(card->dev,
  436. "Failed to register DAPM controls, "
  437. "will continue without any.\n");
  438. return 0;
  439. }
  440. ret = snd_soc_dapm_add_routes(dapm, ams_delta_audio_map,
  441. ARRAY_SIZE(ams_delta_audio_map));
  442. if (ret) {
  443. dev_warn(card->dev,
  444. "Failed to set up DAPM routes, "
  445. "will continue with codec default map.\n");
  446. return 0;
  447. }
  448. /* Set up initial pin constellation */
  449. snd_soc_dapm_disable_pin(dapm, "Mouthpiece");
  450. snd_soc_dapm_enable_pin(dapm, "Earpiece");
  451. snd_soc_dapm_enable_pin(dapm, "Microphone");
  452. snd_soc_dapm_disable_pin(dapm, "Speaker");
  453. snd_soc_dapm_disable_pin(dapm, "AGCIN");
  454. snd_soc_dapm_disable_pin(dapm, "AGCOUT");
  455. /* Add virtual switch */
  456. ret = snd_soc_add_codec_controls(codec, ams_delta_audio_controls,
  457. ARRAY_SIZE(ams_delta_audio_controls));
  458. if (ret)
  459. dev_warn(card->dev,
  460. "Failed to register audio mode control, "
  461. "will continue without it.\n");
  462. return 0;
  463. }
  464. /* DAI glue - connects codec <--> CPU */
  465. static struct snd_soc_dai_link ams_delta_dai_link = {
  466. .name = "CX20442",
  467. .stream_name = "CX20442",
  468. .cpu_dai_name = "omap-mcbsp.1",
  469. .codec_dai_name = "cx20442-voice",
  470. .init = ams_delta_cx20442_init,
  471. .platform_name = "omap-pcm-audio",
  472. .codec_name = "cx20442-codec",
  473. .ops = &ams_delta_ops,
  474. };
  475. /* Audio card driver */
  476. static struct snd_soc_card ams_delta_audio_card = {
  477. .name = "AMS_DELTA",
  478. .owner = THIS_MODULE,
  479. .dai_link = &ams_delta_dai_link,
  480. .num_links = 1,
  481. };
  482. /* Module init/exit */
  483. static struct platform_device *ams_delta_audio_platform_device;
  484. static struct platform_device *cx20442_platform_device;
  485. static int __init ams_delta_module_init(void)
  486. {
  487. int ret;
  488. if (!(machine_is_ams_delta()))
  489. return -ENODEV;
  490. ams_delta_audio_platform_device =
  491. platform_device_alloc("soc-audio", -1);
  492. if (!ams_delta_audio_platform_device)
  493. return -ENOMEM;
  494. platform_set_drvdata(ams_delta_audio_platform_device,
  495. &ams_delta_audio_card);
  496. ret = platform_device_add(ams_delta_audio_platform_device);
  497. if (ret)
  498. goto err;
  499. /*
  500. * Codec platform device could be registered from elsewhere (board?),
  501. * but I do it here as it makes sense only if used with the card.
  502. */
  503. cx20442_platform_device =
  504. platform_device_register_simple("cx20442-codec", -1, NULL, 0);
  505. return 0;
  506. err:
  507. platform_device_put(ams_delta_audio_platform_device);
  508. return ret;
  509. }
  510. late_initcall(ams_delta_module_init);
  511. static void __exit ams_delta_module_exit(void)
  512. {
  513. if (tty_unregister_ldisc(N_V253) != 0)
  514. dev_warn(&ams_delta_audio_platform_device->dev,
  515. "failed to unregister V253 line discipline\n");
  516. snd_soc_jack_free_gpios(&ams_delta_hook_switch,
  517. ARRAY_SIZE(ams_delta_hook_switch_gpios),
  518. ams_delta_hook_switch_gpios);
  519. platform_device_unregister(cx20442_platform_device);
  520. platform_device_unregister(ams_delta_audio_platform_device);
  521. }
  522. module_exit(ams_delta_module_exit);
  523. MODULE_AUTHOR("Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>");
  524. MODULE_DESCRIPTION("ALSA SoC driver for Amstrad E3 (Delta) videophone");
  525. MODULE_LICENSE("GPL");