blob: b10360e3c400f06fddc01de35edf712ff76ca08f [file] [log] [blame]
Liam Girdwooda00663b2011-01-31 21:23:17 +00001/*
2 * linux/sound/soc-dsp.h -- ALSA SoC DSP
3 *
4 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
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
11#ifndef __LINUX_SND_SOC_DSP_H
12#define __LINUX_SND_SOC_DSP_H
13
14#include <sound/pcm.h>
15
16struct snd_soc_dapm_widget;
17
18/*
19 * DSP trigger ordering. Triggering flexibility is required as some DSPs
20 * require triggering before/after their clients/hosts.
21 *
22 * i.e. some clients may want to manually order this call in their PCM
23 * trigger() whilst others will just use the regular core ordering.
24 */
25enum snd_soc_dsp_trigger {
26 SND_SOC_DSP_TRIGGER_PRE = 0,
27 SND_SOC_DSP_TRIGGER_POST,
28 SND_SOC_DSP_TRIGGER_BESPOKE,
29};
30
31/*
32 * The DSP Backend state.
33 */
34enum snd_soc_dsp_link_state {
35 SND_SOC_DSP_LINK_STATE_NEW = 0, /* newly created path */
36 SND_SOC_DSP_LINK_STATE_FREE, /* path to be dismantled */
37 SND_SOC_DSP_LINK_STATE_HW_PARAMS, /* path hw_params configured */
38 SND_SOC_DSP_LINK_STATE_PREPARE, /* path is prepared */
39 SND_SOC_DSP_LINK_STATE_START, /* path is started */
40 SND_SOC_DSP_LINK_STATE_PAUSED, /* path is paused */
41};
42
43struct snd_soc_dsp_params {
44 struct snd_soc_pcm_runtime *be;
45 struct snd_soc_pcm_runtime *fe;
46 enum snd_soc_dsp_link_state state;
47 struct list_head list_be;
48 struct list_head list_fe;
49 struct snd_pcm_hw_params params;
50#ifdef CONFIG_DEBUG_FS
51 struct dentry *debugfs_state;
52#endif
53};
54
55struct snd_soc_dsp_link {
56 /* supported BE */
57 const char **supported_be;
58 int num_be;
59 /* supported channels */
60 int fe_playback_channels;
61 int fe_capture_channels;
62
63 enum snd_soc_dsp_trigger trigger[2];
64};
65
66/* FE DSP PCM ops - called by soc-core */
67int soc_dsp_fe_dai_open(struct snd_pcm_substream *substream);
68int soc_dsp_fe_dai_close(struct snd_pcm_substream *substream);
69int soc_dsp_fe_dai_prepare(struct snd_pcm_substream *substream);
70int soc_dsp_fe_dai_hw_free(struct snd_pcm_substream *substream);
71int soc_dsp_fe_dai_trigger(struct snd_pcm_substream *substream, int cmd);
72int soc_dsp_fe_dai_hw_params(struct snd_pcm_substream *substream,
73 struct snd_pcm_hw_params *params);
74
75/* Backend DSP trigger.
76 * Can be called by core or components depending on trigger config.
77 */
78int soc_dsp_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, int cmd);
79
80/* Is this trigger() call required for this BE and stream */
81static inline int snd_soc_dsp_is_trigger_for_be(struct snd_soc_pcm_runtime *fe,
82 struct snd_soc_pcm_runtime *be, int stream)
83{
84 if (!fe->dsp[stream].runtime_update)
85 return 1;
86 else if (be->dsp[stream].runtime_update)
87 return 1;
88 else
89 return 0;
90}
91
92/* Is this trigger() call required for this FE and stream */
93static inline int snd_soc_dsp_is_trigger_for_fe(struct snd_soc_pcm_runtime *fe,
94 int stream)
95{
96 return !fe->dsp[stream].runtime_update;
97}
98
99static inline int snd_soc_dsp_platform_trigger(struct snd_pcm_substream *substream,
100 int cmd, struct snd_soc_platform *platform)
101{
102 if (platform->driver->ops->trigger)
103 return platform->driver->ops->trigger(substream, cmd);
104 return 0;
105}
106
107/* Runtime update - open/close Backend DSP paths depending on mixer updates */
108int soc_dsp_runtime_update(struct snd_soc_dapm_widget *widget);
109
110/* Backend DSP suspend and resume */
111int soc_dsp_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute);
112int soc_dsp_be_cpu_dai_suspend(struct snd_soc_pcm_runtime *fe);
113int soc_dsp_be_ac97_cpu_dai_suspend(struct snd_soc_pcm_runtime *fe);
114int soc_dsp_be_platform_suspend(struct snd_soc_pcm_runtime *fe);
115int soc_dsp_be_cpu_dai_resume(struct snd_soc_pcm_runtime *fe);
116int soc_dsp_be_ac97_cpu_dai_resume(struct snd_soc_pcm_runtime *fe);
117int soc_dsp_be_platform_resume(struct snd_soc_pcm_runtime *fe);
118
119/* DAPM stream events for Backend DSP paths */
120int soc_dsp_dapm_stream_event(struct snd_soc_pcm_runtime *fe,
121 int dir, const char *stream, int event);
122
123static inline struct snd_pcm_substream *snd_soc_dsp_get_substream(
124 struct snd_soc_pcm_runtime *be, int stream)
125{
126 return be->pcm->streams[stream].substream;
127}
128
129#endif