CRIS: UAPI: use generic sembuf.h
[linux-2.6/btrfs-unstable.git] / include / sound / soc-dpcm.h
blob806059052bfcca4aa9d46ff3b0f061442136e84f
1 /*
2 * linux/sound/soc-dpcm.h -- ALSA SoC Dynamic PCM Support
4 * Author: Liam Girdwood <lrg@ti.com>
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 */
11 #ifndef __LINUX_SND_SOC_DPCM_H
12 #define __LINUX_SND_SOC_DPCM_H
14 #include <linux/slab.h>
15 #include <linux/list.h>
16 #include <sound/pcm.h>
18 struct snd_soc_pcm_runtime;
21 * Types of runtime_update to perform. e.g. originated from FE PCM ops
22 * or audio route changes triggered by muxes/mixers.
24 enum snd_soc_dpcm_update {
25 SND_SOC_DPCM_UPDATE_NO = 0,
26 SND_SOC_DPCM_UPDATE_BE,
27 SND_SOC_DPCM_UPDATE_FE,
31 * Dynamic PCM Frontend -> Backend link management states.
33 enum snd_soc_dpcm_link_state {
34 SND_SOC_DPCM_LINK_STATE_NEW = 0, /* newly created link */
35 SND_SOC_DPCM_LINK_STATE_FREE, /* link to be dismantled */
39 * Dynamic PCM Frontend -> Backend link PCM states.
41 enum snd_soc_dpcm_state {
42 SND_SOC_DPCM_STATE_NEW = 0,
43 SND_SOC_DPCM_STATE_OPEN,
44 SND_SOC_DPCM_STATE_HW_PARAMS,
45 SND_SOC_DPCM_STATE_PREPARE,
46 SND_SOC_DPCM_STATE_START,
47 SND_SOC_DPCM_STATE_STOP,
48 SND_SOC_DPCM_STATE_PAUSED,
49 SND_SOC_DPCM_STATE_SUSPEND,
50 SND_SOC_DPCM_STATE_HW_FREE,
51 SND_SOC_DPCM_STATE_CLOSE,
55 * Dynamic PCM trigger ordering. Triggering flexibility is required as some
56 * DSPs require triggering before/after their CPU platform and DAIs.
58 * i.e. some clients may want to manually order this call in their PCM
59 * trigger() whilst others will just use the regular core ordering.
61 enum snd_soc_dpcm_trigger {
62 SND_SOC_DPCM_TRIGGER_PRE = 0,
63 SND_SOC_DPCM_TRIGGER_POST,
64 SND_SOC_DPCM_TRIGGER_BESPOKE,
68 * Dynamic PCM link
69 * This links together a FE and BE DAI at runtime and stores the link
70 * state information and the hw_params configuration.
72 struct snd_soc_dpcm {
73 /* FE and BE DAIs*/
74 struct snd_soc_pcm_runtime *be;
75 struct snd_soc_pcm_runtime *fe;
77 /* link state */
78 enum snd_soc_dpcm_link_state state;
80 /* list of BE and FE for this DPCM link */
81 struct list_head list_be;
82 struct list_head list_fe;
84 /* hw params for this link - may be different for each link */
85 struct snd_pcm_hw_params hw_params;
86 #ifdef CONFIG_DEBUG_FS
87 struct dentry *debugfs_state;
88 #endif
92 * Dynamic PCM runtime data.
94 struct snd_soc_dpcm_runtime {
95 struct list_head be_clients;
96 struct list_head fe_clients;
98 int users;
99 struct snd_pcm_runtime *runtime;
100 struct snd_pcm_hw_params hw_params;
102 /* state and update */
103 enum snd_soc_dpcm_update runtime_update;
104 enum snd_soc_dpcm_state state;
106 int trigger_pending; /* trigger cmd + 1 if pending, 0 if not */
109 /* can this BE stop and free */
110 int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe,
111 struct snd_soc_pcm_runtime *be, int stream);
113 /* can this BE perform a hw_params() */
114 int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
115 struct snd_soc_pcm_runtime *be, int stream);
117 /* is the current PCM operation for this FE ? */
118 int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream);
120 /* is the current PCM operation for this BE ? */
121 int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe,
122 struct snd_soc_pcm_runtime *be, int stream);
124 /* get the substream for this BE */
125 struct snd_pcm_substream *
126 snd_soc_dpcm_get_substream(struct snd_soc_pcm_runtime *be, int stream);
128 /* get the BE runtime state */
129 enum snd_soc_dpcm_state
130 snd_soc_dpcm_be_get_state(struct snd_soc_pcm_runtime *be, int stream);
132 /* set the BE runtime state */
133 void snd_soc_dpcm_be_set_state(struct snd_soc_pcm_runtime *be, int stream,
134 enum snd_soc_dpcm_state state);
136 /* internal use only */
137 int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute);
138 void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd);
139 int soc_dpcm_runtime_update(struct snd_soc_card *);
141 int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
142 int stream, struct snd_soc_dapm_widget_list **list_);
143 int dpcm_process_paths(struct snd_soc_pcm_runtime *fe,
144 int stream, struct snd_soc_dapm_widget_list **list, int new);
145 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream);
146 int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream);
147 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream);
148 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream);
149 int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream);
150 int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int tream);
151 int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, int cmd);
152 int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream);
153 int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir,
154 int event);
156 static inline void dpcm_path_put(struct snd_soc_dapm_widget_list **list)
158 kfree(*list);
162 #endif