sirf-audio-port.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * SiRF Audio port driver
  3. *
  4. * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
  5. *
  6. * Licensed under GPLv2 or later.
  7. */
  8. #include <linux/module.h>
  9. #include <sound/soc.h>
  10. #include <sound/dmaengine_pcm.h>
  11. struct sirf_audio_port {
  12. struct regmap *regmap;
  13. struct snd_dmaengine_dai_dma_data playback_dma_data;
  14. struct snd_dmaengine_dai_dma_data capture_dma_data;
  15. };
  16. static int sirf_audio_port_dai_probe(struct snd_soc_dai *dai)
  17. {
  18. struct sirf_audio_port *port = snd_soc_dai_get_drvdata(dai);
  19. snd_soc_dai_init_dma_data(dai, &port->playback_dma_data,
  20. &port->capture_dma_data);
  21. return 0;
  22. }
  23. static struct snd_soc_dai_driver sirf_audio_port_dai = {
  24. .probe = sirf_audio_port_dai_probe,
  25. .name = "sirf-audio-port",
  26. .id = 0,
  27. .playback = {
  28. .channels_min = 2,
  29. .channels_max = 2,
  30. .rates = SNDRV_PCM_RATE_48000,
  31. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  32. },
  33. .capture = {
  34. .channels_min = 1,
  35. .channels_max = 2,
  36. .rates = SNDRV_PCM_RATE_48000,
  37. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  38. },
  39. };
  40. static const struct snd_soc_component_driver sirf_audio_port_component = {
  41. .name = "sirf-audio-port",
  42. };
  43. static int sirf_audio_port_probe(struct platform_device *pdev)
  44. {
  45. int ret;
  46. struct sirf_audio_port *port;
  47. port = devm_kzalloc(&pdev->dev,
  48. sizeof(struct sirf_audio_port), GFP_KERNEL);
  49. if (!port)
  50. return -ENOMEM;
  51. ret = devm_snd_soc_register_component(&pdev->dev,
  52. &sirf_audio_port_component, &sirf_audio_port_dai, 1);
  53. if (ret)
  54. return ret;
  55. platform_set_drvdata(pdev, port);
  56. return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
  57. }
  58. static const struct of_device_id sirf_audio_port_of_match[] = {
  59. { .compatible = "sirf,audio-port", },
  60. {}
  61. };
  62. MODULE_DEVICE_TABLE(of, sirf_audio_port_of_match);
  63. static struct platform_driver sirf_audio_port_driver = {
  64. .driver = {
  65. .name = "sirf-audio-port",
  66. .of_match_table = sirf_audio_port_of_match,
  67. },
  68. .probe = sirf_audio_port_probe,
  69. };
  70. module_platform_driver(sirf_audio_port_driver);
  71. MODULE_DESCRIPTION("SiRF Audio Port driver");
  72. MODULE_AUTHOR("RongJun Ying <Rongjun.Ying@csr.com>");
  73. MODULE_LICENSE("GPL v2");