0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __LINUX_SND_SOC_DPCM_H
0009 #define __LINUX_SND_SOC_DPCM_H
0010
0011 #include <linux/slab.h>
0012 #include <linux/list.h>
0013 #include <sound/pcm.h>
0014
0015 struct snd_soc_pcm_runtime;
0016
0017
0018
0019
0020
0021 enum snd_soc_dpcm_update {
0022 SND_SOC_DPCM_UPDATE_NO = 0,
0023 SND_SOC_DPCM_UPDATE_BE,
0024 SND_SOC_DPCM_UPDATE_FE,
0025 };
0026
0027
0028
0029
0030 enum snd_soc_dpcm_link_state {
0031 SND_SOC_DPCM_LINK_STATE_NEW = 0,
0032 SND_SOC_DPCM_LINK_STATE_FREE,
0033 };
0034
0035
0036
0037
0038 enum snd_soc_dpcm_state {
0039 SND_SOC_DPCM_STATE_NEW = 0,
0040 SND_SOC_DPCM_STATE_OPEN,
0041 SND_SOC_DPCM_STATE_HW_PARAMS,
0042 SND_SOC_DPCM_STATE_PREPARE,
0043 SND_SOC_DPCM_STATE_START,
0044 SND_SOC_DPCM_STATE_STOP,
0045 SND_SOC_DPCM_STATE_PAUSED,
0046 SND_SOC_DPCM_STATE_SUSPEND,
0047 SND_SOC_DPCM_STATE_HW_FREE,
0048 SND_SOC_DPCM_STATE_CLOSE,
0049 };
0050
0051
0052
0053
0054
0055
0056
0057
0058 enum snd_soc_dpcm_trigger {
0059 SND_SOC_DPCM_TRIGGER_PRE = 0,
0060 SND_SOC_DPCM_TRIGGER_POST,
0061 SND_SOC_DPCM_TRIGGER_BESPOKE,
0062 };
0063
0064
0065
0066
0067
0068
0069 struct snd_soc_dpcm {
0070
0071 struct snd_soc_pcm_runtime *be;
0072 struct snd_soc_pcm_runtime *fe;
0073
0074
0075 enum snd_soc_dpcm_link_state state;
0076
0077
0078 struct list_head list_be;
0079 struct list_head list_fe;
0080
0081
0082 struct snd_pcm_hw_params hw_params;
0083 #ifdef CONFIG_DEBUG_FS
0084 struct dentry *debugfs_state;
0085 #endif
0086 };
0087
0088
0089
0090
0091 struct snd_soc_dpcm_runtime {
0092 struct list_head be_clients;
0093 struct list_head fe_clients;
0094
0095 int users;
0096 struct snd_pcm_runtime *runtime;
0097 struct snd_pcm_hw_params hw_params;
0098
0099
0100 enum snd_soc_dpcm_update runtime_update;
0101 enum snd_soc_dpcm_state state;
0102
0103 int trigger_pending;
0104
0105 int be_start;
0106 int be_pause;
0107 bool fe_pause;
0108 };
0109
0110 #define for_each_dpcm_fe(be, stream, _dpcm) \
0111 list_for_each_entry(_dpcm, &(be)->dpcm[stream].fe_clients, list_fe)
0112
0113 #define for_each_dpcm_be(fe, stream, _dpcm) \
0114 list_for_each_entry(_dpcm, &(fe)->dpcm[stream].be_clients, list_be)
0115 #define for_each_dpcm_be_safe(fe, stream, _dpcm, __dpcm) \
0116 list_for_each_entry_safe(_dpcm, __dpcm, &(fe)->dpcm[stream].be_clients, list_be)
0117 #define for_each_dpcm_be_rollback(fe, stream, _dpcm) \
0118 list_for_each_entry_continue_reverse(_dpcm, &(fe)->dpcm[stream].be_clients, list_be)
0119
0120
0121 int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
0122 struct snd_soc_pcm_runtime *be, int stream);
0123
0124
0125 int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
0126 struct snd_soc_pcm_runtime *be, int stream);
0127
0128
0129 int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream);
0130
0131
0132 int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe,
0133 struct snd_soc_pcm_runtime *be, int stream);
0134
0135
0136 struct snd_pcm_substream *
0137 snd_soc_dpcm_get_substream(struct snd_soc_pcm_runtime *be, int stream);
0138
0139
0140 int snd_soc_dpcm_runtime_update(struct snd_soc_card *card);
0141
0142 #ifdef CONFIG_DEBUG_FS
0143 void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd);
0144 #else
0145 static inline void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd)
0146 {
0147 }
0148 #endif
0149
0150 int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
0151 int stream, struct snd_soc_dapm_widget_list **list_);
0152 void dpcm_path_put(struct snd_soc_dapm_widget_list **list);
0153 int dpcm_process_paths(struct snd_soc_pcm_runtime *fe,
0154 int stream, struct snd_soc_dapm_widget_list **list, int new);
0155 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream);
0156 void dpcm_be_dai_stop(struct snd_soc_pcm_runtime *fe, int stream,
0157 int do_hw_free, struct snd_soc_dpcm *last);
0158 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream);
0159 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream);
0160 void dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream);
0161 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int tream);
0162 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, int cmd);
0163 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream);
0164 int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir,
0165 int event);
0166 bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget, enum snd_soc_dapm_direction dir);
0167
0168 #define dpcm_be_dai_startup_rollback(fe, stream, last) \
0169 dpcm_be_dai_stop(fe, stream, 0, last)
0170 #define dpcm_be_dai_startup_unwind(fe, stream) dpcm_be_dai_stop(fe, stream, 0, NULL)
0171 #define dpcm_be_dai_shutdown(fe, stream) dpcm_be_dai_stop(fe, stream, 1, NULL)
0172
0173 #endif