soc-dpcm.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * linux/sound/soc-dpcm.h -- ALSA SoC Dynamic PCM Support
  3. *
  4. * Author: Liam Girdwood <lrg@ti.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __LINUX_SND_SOC_DPCM_H
  11. #define __LINUX_SND_SOC_DPCM_H
  12. #include <linux/slab.h>
  13. #include <sound/pcm.h>
  14. /*
  15. * Types of runtime_update to perform (e.g. originated from FE PCM ops
  16. * or audio route changes triggered by muxes/mixers.
  17. */
  18. #define SND_SOC_DPCM_UPDATE_NO 0
  19. #define SND_SOC_DPCM_UPDATE_BE 1
  20. #define SND_SOC_DPCM_UPDATE_FE 2
  21. /*
  22. * Dynamic PCM Frontend -> Backend link state.
  23. */
  24. enum snd_soc_dpcm_link_state {
  25. SND_SOC_DPCM_LINK_STATE_NEW = 0, /* newly created path */
  26. SND_SOC_DPCM_LINK_STATE_FREE, /* path to be dismantled */
  27. };
  28. /*
  29. * Dynamic PCM params link
  30. * This links together a FE and BE DAI at runtime and stores the link
  31. * state information and the hw_params configuration.
  32. */
  33. struct snd_soc_dpcm_params {
  34. /* FE and BE DAIs*/
  35. struct snd_soc_pcm_runtime *be;
  36. struct snd_soc_pcm_runtime *fe;
  37. /* link state */
  38. enum snd_soc_dpcm_link_state state;
  39. struct list_head list_be;
  40. struct list_head list_fe;
  41. /* hw params for this link - may be different for each link */
  42. struct snd_pcm_hw_params hw_params;
  43. #ifdef CONFIG_DEBUG_FS
  44. struct dentry *debugfs_state;
  45. #endif
  46. };
  47. /*
  48. * Bespoke Trigger() Helper API
  49. */
  50. /* is the PCM operation for this FE ? */
  51. static inline int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe,
  52. int stream)
  53. {
  54. return (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE);
  55. }
  56. /* is the PCM operation for this BE ? */
  57. static inline int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe,
  58. struct snd_soc_pcm_runtime *be, int stream)
  59. {
  60. if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) ||
  61. ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) &&
  62. be->dpcm[stream].runtime_update))
  63. return 1;
  64. else
  65. return 0;
  66. }
  67. /* trigger platform driver only */
  68. static inline int
  69. snd_soc_dpcm_platform_trigger(struct snd_pcm_substream *substream,
  70. int cmd, struct snd_soc_platform *platform)
  71. {
  72. if (platform->driver->ops->trigger)
  73. return platform->driver->ops->trigger(substream, cmd);
  74. return 0;
  75. }
  76. int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
  77. struct snd_soc_pcm_runtime *be, int stream);
  78. static inline struct snd_pcm_substream *
  79. snd_soc_dpcm_get_substream(struct snd_soc_pcm_runtime *be, int stream)
  80. {
  81. return be->pcm->streams[stream].substream;
  82. }
  83. static inline enum snd_soc_dpcm_state
  84. snd_soc_dpcm_be_get_state(struct snd_soc_pcm_runtime *be, int stream)
  85. {
  86. return be->dpcm[stream].state;
  87. }
  88. static inline void snd_soc_dpcm_be_set_state(struct snd_soc_pcm_runtime *be,
  89. int stream, enum snd_soc_dpcm_state state)
  90. {
  91. be->dpcm[stream].state = state;
  92. }
  93. int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
  94. int stream, struct snd_soc_dapm_widget_list **list_);
  95. int dpcm_process_paths(struct snd_soc_pcm_runtime *fe,
  96. int stream, struct snd_soc_dapm_widget_list **list, int new);
  97. int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream);
  98. int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream);
  99. void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream);
  100. void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream);
  101. int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream);
  102. int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int tream);
  103. int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, int cmd);
  104. int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream);
  105. int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe,
  106. int dir, const char *stream, int event);
  107. static inline void dpcm_path_put(struct snd_soc_dapm_widget_list **list)
  108. {
  109. kfree(*list);
  110. }
  111. #endif