msm-pcm-hostless.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/of_device.h>
  16. #include <sound/core.h>
  17. #include <sound/soc.h>
  18. #include <sound/pcm.h>
  19. static int msm_pcm_hostless_prepare(struct snd_pcm_substream *substream)
  20. {
  21. if (!substream) {
  22. pr_err("%s: invalid params\n", __func__);
  23. return -EINVAL;
  24. }
  25. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  26. pm_qos_remove_request(&substream->latency_pm_qos_req);
  27. return 0;
  28. }
  29. static struct snd_pcm_ops msm_pcm_hostless_ops = {
  30. .prepare = msm_pcm_hostless_prepare
  31. };
  32. static struct snd_soc_platform_driver msm_soc_hostless_platform = {
  33. .ops = &msm_pcm_hostless_ops,
  34. };
  35. static __devinit int msm_pcm_hostless_probe(struct platform_device *pdev)
  36. {
  37. if (pdev->dev.of_node)
  38. dev_set_name(&pdev->dev, "%s", "msm-pcm-hostless");
  39. pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
  40. return snd_soc_register_platform(&pdev->dev,
  41. &msm_soc_hostless_platform);
  42. }
  43. static int msm_pcm_hostless_remove(struct platform_device *pdev)
  44. {
  45. snd_soc_unregister_platform(&pdev->dev);
  46. return 0;
  47. }
  48. static const struct of_device_id msm_pcm_hostless_dt_match[] = {
  49. {.compatible = "qcom,msm-pcm-hostless"},
  50. {}
  51. };
  52. static struct platform_driver msm_pcm_hostless_driver = {
  53. .driver = {
  54. .name = "msm-pcm-hostless",
  55. .owner = THIS_MODULE,
  56. .of_match_table = msm_pcm_hostless_dt_match,
  57. },
  58. .probe = msm_pcm_hostless_probe,
  59. .remove = __devexit_p(msm_pcm_hostless_remove),
  60. };
  61. static int __init msm_soc_platform_init(void)
  62. {
  63. return platform_driver_register(&msm_pcm_hostless_driver);
  64. }
  65. module_init(msm_soc_platform_init);
  66. static void __exit msm_soc_platform_exit(void)
  67. {
  68. platform_driver_unregister(&msm_pcm_hostless_driver);
  69. }
  70. module_exit(msm_soc_platform_exit);
  71. MODULE_DESCRIPTION("Hostless platform driver");
  72. MODULE_LICENSE("GPL v2");