s3c24xx_simtec_hermes.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* sound/soc/s3c24xx/s3c24xx_simtec_hermes.c
  2. *
  3. * Copyright 2009 Simtec Electronics
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/module.h>
  10. #include <linux/clk.h>
  11. #include <linux/platform_device.h>
  12. #include <sound/core.h>
  13. #include <sound/pcm.h>
  14. #include <sound/soc.h>
  15. #include <sound/soc-dapm.h>
  16. #include <plat/audio-simtec.h>
  17. #include "s3c24xx-pcm.h"
  18. #include "s3c24xx-i2s.h"
  19. #include "s3c24xx_simtec.h"
  20. #include "../codecs/tlv320aic3x.h"
  21. static const struct snd_soc_dapm_widget dapm_widgets[] = {
  22. SND_SOC_DAPM_LINE("GSM Out", NULL),
  23. SND_SOC_DAPM_LINE("GSM In", NULL),
  24. SND_SOC_DAPM_LINE("Line In", NULL),
  25. SND_SOC_DAPM_LINE("Line Out", NULL),
  26. SND_SOC_DAPM_LINE("ZV", NULL),
  27. SND_SOC_DAPM_MIC("Mic Jack", NULL),
  28. SND_SOC_DAPM_HP("Headphone Jack", NULL),
  29. };
  30. static const struct snd_soc_dapm_route base_map[] = {
  31. /* Headphone connected to HP{L,R}OUT and HP{L,R}COM */
  32. { "Headphone Jack", NULL, "HPLOUT" },
  33. { "Headphone Jack", NULL, "HPLCOM" },
  34. { "Headphone Jack", NULL, "HPROUT" },
  35. { "Headphone Jack", NULL, "HPRCOM" },
  36. /* ZV connected to Line1 */
  37. { "LINE1L", NULL, "ZV" },
  38. { "LINE1R", NULL, "ZV" },
  39. /* Line In connected to Line2 */
  40. { "LINE2L", NULL, "Line In" },
  41. { "LINE2R", NULL, "Line In" },
  42. /* Microphone connected to MIC3R and MIC_BIAS */
  43. { "MIC3L", NULL, "Mic Jack" },
  44. /* GSM connected to MONO_LOUT and MIC3L (in) */
  45. { "GSM Out", NULL, "MONO_LOUT" },
  46. { "MIC3L", NULL, "GSM In" },
  47. /* Speaker is connected to LINEOUT{LN,LP,RN,RP}, however we are
  48. * not using the DAPM to power it up and down as there it makes
  49. * a click when powering up. */
  50. };
  51. /**
  52. * simtec_hermes_init - initialise and add controls
  53. * @codec; The codec instance to attach to.
  54. *
  55. * Attach our controls and configure the necessary codec
  56. * mappings for our sound card instance.
  57. */
  58. static int simtec_hermes_init(struct snd_soc_codec *codec)
  59. {
  60. snd_soc_dapm_new_controls(codec, dapm_widgets,
  61. ARRAY_SIZE(dapm_widgets));
  62. snd_soc_dapm_add_routes(codec, base_map, ARRAY_SIZE(base_map));
  63. snd_soc_dapm_enable_pin(codec, "Headphone Jack");
  64. snd_soc_dapm_enable_pin(codec, "Line In");
  65. snd_soc_dapm_enable_pin(codec, "Line Out");
  66. snd_soc_dapm_enable_pin(codec, "Mic Jack");
  67. simtec_audio_init(codec);
  68. snd_soc_dapm_sync(codec);
  69. return 0;
  70. }
  71. static struct aic3x_setup_data codec_setup = {
  72. };
  73. static struct snd_soc_dai_link simtec_dai_aic33 = {
  74. .name = "tlv320aic33",
  75. .stream_name = "TLV320AIC33",
  76. .cpu_dai = &s3c24xx_i2s_dai,
  77. .codec_dai = &aic3x_dai,
  78. .init = simtec_hermes_init,
  79. };
  80. /* simtec audio machine driver */
  81. static struct snd_soc_card snd_soc_machine_simtec_aic33 = {
  82. .name = "Simtec-Hermes",
  83. .platform = &s3c24xx_soc_platform,
  84. .dai_link = &simtec_dai_aic33,
  85. .num_links = 1,
  86. };
  87. /* simtec audio subsystem */
  88. static struct snd_soc_device simtec_snd_devdata_aic33 = {
  89. .card = &snd_soc_machine_simtec_aic33,
  90. .codec_dev = &soc_codec_dev_aic3x,
  91. .codec_data = &codec_setup,
  92. };
  93. static int __devinit simtec_audio_hermes_probe(struct platform_device *pd)
  94. {
  95. dev_info(&pd->dev, "probing....\n");
  96. return simtec_audio_core_probe(pd, &simtec_snd_devdata_aic33);
  97. }
  98. static struct platform_driver simtec_audio_hermes_platdrv = {
  99. .driver = {
  100. .owner = THIS_MODULE,
  101. .name = "s3c24xx-simtec-hermes-snd",
  102. .pm = simtec_audio_pm,
  103. },
  104. .probe = simtec_audio_hermes_probe,
  105. .remove = __devexit_p(simtec_audio_remove),
  106. };
  107. MODULE_ALIAS("platform:s3c24xx-simtec-hermes-snd");
  108. static int __init simtec_hermes_modinit(void)
  109. {
  110. return platform_driver_register(&simtec_audio_hermes_platdrv);
  111. }
  112. static void __exit simtec_hermes_modexit(void)
  113. {
  114. platform_driver_unregister(&simtec_audio_hermes_platdrv);
  115. }
  116. module_init(simtec_hermes_modinit);
  117. module_exit(simtec_hermes_modexit);
  118. MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
  119. MODULE_DESCRIPTION("ALSA SoC Simtec Audio support");
  120. MODULE_LICENSE("GPL");