s3c24xx_simtec_tlv320aic23.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.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 "s3c-dma.h"
  18. #include "s3c24xx-i2s.h"
  19. #include "s3c24xx_simtec.h"
  20. #include "../codecs/tlv320aic23.h"
  21. /* supported machines:
  22. *
  23. * Machine Connections AMP
  24. * ------- ----------- ---
  25. * BAST MIC, HPOUT, LOUT, LIN TPA2001D1 (HPOUTL,R) (gain hardwired)
  26. * VR1000 HPOUT, LIN None
  27. * VR2000 LIN, LOUT, MIC, HP LM4871 (HPOUTL,R)
  28. * DePicture LIN, LOUT, MIC, HP LM4871 (HPOUTL,R)
  29. * Anubis LIN, LOUT, MIC, HP TPA2001D1 (HPOUTL,R)
  30. */
  31. static const struct snd_soc_dapm_widget dapm_widgets[] = {
  32. SND_SOC_DAPM_HP("Headphone Jack", NULL),
  33. SND_SOC_DAPM_LINE("Line In", NULL),
  34. SND_SOC_DAPM_LINE("Line Out", NULL),
  35. SND_SOC_DAPM_MIC("Mic Jack", NULL),
  36. };
  37. static const struct snd_soc_dapm_route base_map[] = {
  38. { "Headphone Jack", NULL, "LHPOUT"},
  39. { "Headphone Jack", NULL, "RHPOUT"},
  40. { "Line Out", NULL, "LOUT" },
  41. { "Line Out", NULL, "ROUT" },
  42. { "LLINEIN", NULL, "Line In"},
  43. { "RLINEIN", NULL, "Line In"},
  44. { "MICIN", NULL, "Mic Jack"},
  45. };
  46. /**
  47. * simtec_tlv320aic23_init - initialise and add controls
  48. * @codec; The codec instance to attach to.
  49. *
  50. * Attach our controls and configure the necessary codec
  51. * mappings for our sound card instance.
  52. */
  53. static int simtec_tlv320aic23_init(struct snd_soc_pcm_runtime *rtd)
  54. {
  55. struct snd_soc_codec *codec = rtd->codec;
  56. struct snd_soc_dapm_context *dapm = &codec->dapm;
  57. snd_soc_dapm_new_controls(dapm, dapm_widgets,
  58. ARRAY_SIZE(dapm_widgets));
  59. snd_soc_dapm_add_routes(dapm, base_map, ARRAY_SIZE(base_map));
  60. snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
  61. snd_soc_dapm_enable_pin(dapm, "Line In");
  62. snd_soc_dapm_enable_pin(dapm, "Line Out");
  63. snd_soc_dapm_enable_pin(dapm, "Mic Jack");
  64. simtec_audio_init(rtd);
  65. snd_soc_dapm_sync(dapm);
  66. return 0;
  67. }
  68. static struct snd_soc_dai_link simtec_dai_aic23 = {
  69. .name = "tlv320aic23",
  70. .stream_name = "TLV320AIC23",
  71. .codec_name = "tlv320aic3x-codec.0-0x1a",
  72. .cpu_dai_name = "s3c24xx-i2s",
  73. .codec_dai_name = "tlv320aic3x-hifi",
  74. .platform_name = "s3c24xx-pcm-audio",
  75. .init = simtec_tlv320aic23_init,
  76. };
  77. /* simtec audio machine driver */
  78. static struct snd_soc_card snd_soc_machine_simtec_aic23 = {
  79. .name = "Simtec",
  80. .dai_link = &simtec_dai_aic23,
  81. .num_links = 1,
  82. };
  83. static int __devinit simtec_audio_tlv320aic23_probe(struct platform_device *pd)
  84. {
  85. return simtec_audio_core_probe(pd, &snd_soc_machine_simtec_aic23);
  86. }
  87. static struct platform_driver simtec_audio_tlv320aic23_platdrv = {
  88. .driver = {
  89. .owner = THIS_MODULE,
  90. .name = "s3c24xx-simtec-tlv320aic23",
  91. .pm = simtec_audio_pm,
  92. },
  93. .probe = simtec_audio_tlv320aic23_probe,
  94. .remove = __devexit_p(simtec_audio_remove),
  95. };
  96. MODULE_ALIAS("platform:s3c24xx-simtec-tlv320aic23");
  97. static int __init simtec_tlv320aic23_modinit(void)
  98. {
  99. return platform_driver_register(&simtec_audio_tlv320aic23_platdrv);
  100. }
  101. static void __exit simtec_tlv320aic23_modexit(void)
  102. {
  103. platform_driver_unregister(&simtec_audio_tlv320aic23_platdrv);
  104. }
  105. module_init(simtec_tlv320aic23_modinit);
  106. module_exit(simtec_tlv320aic23_modexit);
  107. MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
  108. MODULE_DESCRIPTION("ALSA SoC Simtec Audio support");
  109. MODULE_LICENSE("GPL");