snappercl15.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * snappercl15.c -- SoC audio for Bluewater Systems Snapper CL15 module
  3. *
  4. * Copyright (C) 2008 Bluewater Systems Ltd
  5. * Author: Ryan Mallon
  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. */
  13. #include <linux/platform_device.h>
  14. #include <linux/module.h>
  15. #include <sound/core.h>
  16. #include <sound/pcm.h>
  17. #include <sound/soc.h>
  18. #include <asm/mach-types.h>
  19. #include <mach/hardware.h>
  20. #include "../codecs/tlv320aic23.h"
  21. #define CODEC_CLOCK 5644800
  22. static int snappercl15_hw_params(struct snd_pcm_substream *substream,
  23. struct snd_pcm_hw_params *params)
  24. {
  25. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  26. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  27. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  28. int err;
  29. err = snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_CLOCK,
  30. SND_SOC_CLOCK_IN);
  31. if (err)
  32. return err;
  33. err = snd_soc_dai_set_sysclk(cpu_dai, 0, CODEC_CLOCK,
  34. SND_SOC_CLOCK_OUT);
  35. if (err)
  36. return err;
  37. return 0;
  38. }
  39. static struct snd_soc_ops snappercl15_ops = {
  40. .hw_params = snappercl15_hw_params,
  41. };
  42. static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = {
  43. SND_SOC_DAPM_HP("Headphone Jack", NULL),
  44. SND_SOC_DAPM_LINE("Line In", NULL),
  45. SND_SOC_DAPM_MIC("Mic Jack", NULL),
  46. };
  47. static const struct snd_soc_dapm_route audio_map[] = {
  48. {"Headphone Jack", NULL, "LHPOUT"},
  49. {"Headphone Jack", NULL, "RHPOUT"},
  50. {"LLINEIN", NULL, "Line In"},
  51. {"RLINEIN", NULL, "Line In"},
  52. {"MICIN", NULL, "Mic Jack"},
  53. };
  54. static struct snd_soc_dai_link snappercl15_dai = {
  55. .name = "tlv320aic23",
  56. .stream_name = "AIC23",
  57. .cpu_dai_name = "ep93xx-i2s",
  58. .codec_dai_name = "tlv320aic23-hifi",
  59. .codec_name = "tlv320aic23-codec.0-001a",
  60. .platform_name = "ep93xx-i2s",
  61. .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  62. SND_SOC_DAIFMT_CBS_CFS,
  63. .ops = &snappercl15_ops,
  64. };
  65. static struct snd_soc_card snd_soc_snappercl15 = {
  66. .name = "Snapper CL15",
  67. .owner = THIS_MODULE,
  68. .dai_link = &snappercl15_dai,
  69. .num_links = 1,
  70. .dapm_widgets = tlv320aic23_dapm_widgets,
  71. .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets),
  72. .dapm_routes = audio_map,
  73. .num_dapm_routes = ARRAY_SIZE(audio_map),
  74. };
  75. static int snappercl15_probe(struct platform_device *pdev)
  76. {
  77. struct snd_soc_card *card = &snd_soc_snappercl15;
  78. int ret;
  79. ret = ep93xx_i2s_acquire();
  80. if (ret)
  81. return ret;
  82. card->dev = &pdev->dev;
  83. ret = snd_soc_register_card(card);
  84. if (ret) {
  85. dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
  86. ret);
  87. ep93xx_i2s_release();
  88. }
  89. return ret;
  90. }
  91. static int snappercl15_remove(struct platform_device *pdev)
  92. {
  93. struct snd_soc_card *card = platform_get_drvdata(pdev);
  94. snd_soc_unregister_card(card);
  95. ep93xx_i2s_release();
  96. return 0;
  97. }
  98. static struct platform_driver snappercl15_driver = {
  99. .driver = {
  100. .name = "snappercl15-audio",
  101. },
  102. .probe = snappercl15_probe,
  103. .remove = snappercl15_remove,
  104. };
  105. module_platform_driver(snappercl15_driver);
  106. MODULE_AUTHOR("Ryan Mallon");
  107. MODULE_DESCRIPTION("ALSA SoC Snapper CL15");
  108. MODULE_LICENSE("GPL");
  109. MODULE_ALIAS("platform:snappercl15-audio");