wm8727.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * wm8727.c
  3. *
  4. * Created on: 15-Oct-2009
  5. * Author: neil.jones@imgtec.com
  6. *
  7. * Copyright (C) 2009 Imagination Technologies Ltd.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/slab.h>
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/device.h>
  19. #include <sound/core.h>
  20. #include <sound/pcm.h>
  21. #include <sound/ac97_codec.h>
  22. #include <sound/initval.h>
  23. #include <sound/soc.h>
  24. static const struct snd_soc_dapm_widget wm8727_dapm_widgets[] = {
  25. SND_SOC_DAPM_OUTPUT("VOUTL"),
  26. SND_SOC_DAPM_OUTPUT("VOUTR"),
  27. };
  28. static const struct snd_soc_dapm_route wm8727_dapm_routes[] = {
  29. { "VOUTL", NULL, "Playback" },
  30. { "VOUTR", NULL, "Playback" },
  31. };
  32. /*
  33. * Note this is a simple chip with no configuration interface, sample rate is
  34. * determined automatically by examining the Master clock and Bit clock ratios
  35. */
  36. #define WM8727_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
  37. SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |\
  38. SNDRV_PCM_RATE_192000)
  39. static struct snd_soc_dai_driver wm8727_dai = {
  40. .name = "wm8727-hifi",
  41. .playback = {
  42. .stream_name = "Playback",
  43. .channels_min = 2,
  44. .channels_max = 2,
  45. .rates = WM8727_RATES,
  46. .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
  47. },
  48. };
  49. static const struct snd_soc_codec_driver soc_codec_dev_wm8727 = {
  50. .component_driver = {
  51. .dapm_widgets = wm8727_dapm_widgets,
  52. .num_dapm_widgets = ARRAY_SIZE(wm8727_dapm_widgets),
  53. .dapm_routes = wm8727_dapm_routes,
  54. .num_dapm_routes = ARRAY_SIZE(wm8727_dapm_routes),
  55. },
  56. };
  57. static int wm8727_probe(struct platform_device *pdev)
  58. {
  59. return snd_soc_register_codec(&pdev->dev,
  60. &soc_codec_dev_wm8727, &wm8727_dai, 1);
  61. }
  62. static int wm8727_remove(struct platform_device *pdev)
  63. {
  64. snd_soc_unregister_codec(&pdev->dev);
  65. return 0;
  66. }
  67. static struct platform_driver wm8727_codec_driver = {
  68. .driver = {
  69. .name = "wm8727",
  70. },
  71. .probe = wm8727_probe,
  72. .remove = wm8727_remove,
  73. };
  74. module_platform_driver(wm8727_codec_driver);
  75. MODULE_DESCRIPTION("ASoC wm8727 driver");
  76. MODULE_AUTHOR("Neil Jones");
  77. MODULE_LICENSE("GPL");