ads117x.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * ads117x.c -- Driver for ads1174/8 ADC chips
  3. *
  4. * Copyright 2009 ShotSpotter Inc.
  5. * Author: Graeme Gregory <gg@slimlogic.co.uk>
  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. #include <linux/kernel.h>
  13. #include <linux/slab.h>
  14. #include <linux/init.h>
  15. #include <linux/device.h>
  16. #include <linux/module.h>
  17. #include <sound/core.h>
  18. #include <sound/pcm.h>
  19. #include <sound/initval.h>
  20. #include <sound/soc.h>
  21. #define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000)
  22. #define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
  23. static const struct snd_soc_dapm_widget ads117x_dapm_widgets[] = {
  24. SND_SOC_DAPM_INPUT("Input1"),
  25. SND_SOC_DAPM_INPUT("Input2"),
  26. SND_SOC_DAPM_INPUT("Input3"),
  27. SND_SOC_DAPM_INPUT("Input4"),
  28. SND_SOC_DAPM_INPUT("Input5"),
  29. SND_SOC_DAPM_INPUT("Input6"),
  30. SND_SOC_DAPM_INPUT("Input7"),
  31. SND_SOC_DAPM_INPUT("Input8"),
  32. };
  33. static const struct snd_soc_dapm_route ads117x_dapm_routes[] = {
  34. { "Capture", NULL, "Input1" },
  35. { "Capture", NULL, "Input2" },
  36. { "Capture", NULL, "Input3" },
  37. { "Capture", NULL, "Input4" },
  38. { "Capture", NULL, "Input5" },
  39. { "Capture", NULL, "Input6" },
  40. { "Capture", NULL, "Input7" },
  41. { "Capture", NULL, "Input8" },
  42. };
  43. static struct snd_soc_dai_driver ads117x_dai = {
  44. /* ADC */
  45. .name = "ads117x-hifi",
  46. .capture = {
  47. .stream_name = "Capture",
  48. .channels_min = 1,
  49. .channels_max = 32,
  50. .rates = ADS117X_RATES,
  51. .formats = ADS117X_FORMATS,},
  52. };
  53. static struct snd_soc_codec_driver soc_codec_dev_ads117x = {
  54. .dapm_widgets = ads117x_dapm_widgets,
  55. .num_dapm_widgets = ARRAY_SIZE(ads117x_dapm_widgets),
  56. .dapm_routes = ads117x_dapm_routes,
  57. .num_dapm_routes = ARRAY_SIZE(ads117x_dapm_routes),
  58. };
  59. static int ads117x_probe(struct platform_device *pdev)
  60. {
  61. return snd_soc_register_codec(&pdev->dev,
  62. &soc_codec_dev_ads117x, &ads117x_dai, 1);
  63. }
  64. static int ads117x_remove(struct platform_device *pdev)
  65. {
  66. snd_soc_unregister_codec(&pdev->dev);
  67. return 0;
  68. }
  69. static struct platform_driver ads117x_codec_driver = {
  70. .driver = {
  71. .name = "ads117x-codec",
  72. .owner = THIS_MODULE,
  73. },
  74. .probe = ads117x_probe,
  75. .remove = ads117x_remove,
  76. };
  77. module_platform_driver(ads117x_codec_driver);
  78. MODULE_DESCRIPTION("ASoC ads117x driver");
  79. MODULE_AUTHOR("Graeme Gregory");
  80. MODULE_LICENSE("GPL");