1b3ed4c86SKuninori Morimoto // SPDX-License-Identifier: GPL-2.0+
2b3ed4c86SKuninori Morimoto //
3b3ed4c86SKuninori Morimoto // soc-compress.c -- ALSA SoC Compress
4b3ed4c86SKuninori Morimoto //
5b3ed4c86SKuninori Morimoto // Copyright (C) 2012 Intel Corp.
6b3ed4c86SKuninori Morimoto //
7b3ed4c86SKuninori Morimoto // Authors: Namarta Kohli <namartax.kohli@intel.com>
8b3ed4c86SKuninori Morimoto // Ramesh Babu K V <ramesh.babu@linux.intel.com>
9b3ed4c86SKuninori Morimoto // Vinod Koul <vinod.koul@linux.intel.com>
101245b700SNamarta Kohli
111245b700SNamarta Kohli #include <linux/kernel.h>
121245b700SNamarta Kohli #include <linux/init.h>
131245b700SNamarta Kohli #include <linux/delay.h>
141245b700SNamarta Kohli #include <linux/slab.h>
151245b700SNamarta Kohli #include <linux/workqueue.h>
161245b700SNamarta Kohli #include <sound/core.h>
171245b700SNamarta Kohli #include <sound/compress_params.h>
181245b700SNamarta Kohli #include <sound/compress_driver.h>
191245b700SNamarta Kohli #include <sound/soc.h>
201245b700SNamarta Kohli #include <sound/initval.h>
212a99ef0fSLiam Girdwood #include <sound/soc-dpcm.h>
229ab711cbSKuninori Morimoto #include <sound/soc-link.h>
234137f4b6SCezary Rojewski
snd_soc_compr_components_open(struct snd_compr_stream * cstream)241245b700SNamarta Kohli static int snd_soc_compr_components_open(struct snd_compr_stream *cstream)
25cd46f382SPeter Ujfalusi {
26cd46f382SPeter Ujfalusi struct snd_soc_pcm_runtime *rtd = cstream->private_data;
27cd46f382SPeter Ujfalusi struct snd_soc_component *component;
28cd46f382SPeter Ujfalusi int ret = 0;
29cd46f382SPeter Ujfalusi int i;
30cd46f382SPeter Ujfalusi
31cd46f382SPeter Ujfalusi for_each_rtd_components(rtd, i, component) {
32cd46f382SPeter Ujfalusi ret = snd_soc_component_module_get_when_open(component, cstream);
33cd46f382SPeter Ujfalusi if (ret < 0)
34cd46f382SPeter Ujfalusi break;
35cd46f382SPeter Ujfalusi
36cd46f382SPeter Ujfalusi ret = snd_soc_component_compr_open(component, cstream);
37cd46f382SPeter Ujfalusi if (ret < 0)
38cd46f382SPeter Ujfalusi break;
39cd46f382SPeter Ujfalusi }
40cd46f382SPeter Ujfalusi
41cd46f382SPeter Ujfalusi return ret;
42cd46f382SPeter Ujfalusi }
43cd46f382SPeter Ujfalusi
snd_soc_compr_components_free(struct snd_compr_stream * cstream,int rollback)44cd46f382SPeter Ujfalusi static void snd_soc_compr_components_free(struct snd_compr_stream *cstream,
45cd46f382SPeter Ujfalusi int rollback)
46cd46f382SPeter Ujfalusi {
47cd46f382SPeter Ujfalusi struct snd_soc_pcm_runtime *rtd = cstream->private_data;
48cd46f382SPeter Ujfalusi struct snd_soc_component *component;
49cd46f382SPeter Ujfalusi int i;
50cd46f382SPeter Ujfalusi
51cd46f382SPeter Ujfalusi for_each_rtd_components(rtd, i, component) {
52cd46f382SPeter Ujfalusi snd_soc_component_compr_free(component, cstream, rollback);
53cd46f382SPeter Ujfalusi snd_soc_component_module_put_when_close(component, cstream, rollback);
54cd46f382SPeter Ujfalusi }
55cd46f382SPeter Ujfalusi }
56cd46f382SPeter Ujfalusi
soc_compr_clean(struct snd_compr_stream * cstream,int rollback)57cd46f382SPeter Ujfalusi static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback)
58453d32c2SKuninori Morimoto {
5915a7b8c1SKuninori Morimoto struct snd_soc_pcm_runtime *rtd = cstream->private_data;
6015a7b8c1SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
6115a7b8c1SKuninori Morimoto struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
6215a7b8c1SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
6315a7b8c1SKuninori Morimoto
6415a7b8c1SKuninori Morimoto snd_soc_dpcm_mutex_lock(rtd);
6538e42f6dSKuninori Morimoto
6615a7b8c1SKuninori Morimoto if (!rollback)
67453d32c2SKuninori Morimoto snd_soc_runtime_deactivate(rtd, stream);
6815a7b8c1SKuninori Morimoto
6915a7b8c1SKuninori Morimoto snd_soc_dai_digital_mute(codec_dai, 1, stream);
7015a7b8c1SKuninori Morimoto
7115a7b8c1SKuninori Morimoto if (!snd_soc_dai_active(cpu_dai))
7215a7b8c1SKuninori Morimoto cpu_dai->rate = 0;
7315a7b8c1SKuninori Morimoto
7415a7b8c1SKuninori Morimoto if (!snd_soc_dai_active(codec_dai))
7515a7b8c1SKuninori Morimoto codec_dai->rate = 0;
7615a7b8c1SKuninori Morimoto
7715a7b8c1SKuninori Morimoto snd_soc_link_compr_shutdown(cstream, rollback);
78453d32c2SKuninori Morimoto
7915a7b8c1SKuninori Morimoto snd_soc_compr_components_free(cstream, rollback);
80cd46f382SPeter Ujfalusi
8115a7b8c1SKuninori Morimoto snd_soc_dai_compr_shutdown(cpu_dai, cstream, rollback);
82453d32c2SKuninori Morimoto
8315a7b8c1SKuninori Morimoto if (!rollback)
84453d32c2SKuninori Morimoto snd_soc_dapm_stream_stop(rtd, stream);
8515a7b8c1SKuninori Morimoto
8615a7b8c1SKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
8738e42f6dSKuninori Morimoto
8815a7b8c1SKuninori Morimoto snd_soc_pcm_component_pm_runtime_put(rtd, cstream, rollback);
89453d32c2SKuninori Morimoto
9015a7b8c1SKuninori Morimoto return 0;
9115a7b8c1SKuninori Morimoto }
9215a7b8c1SKuninori Morimoto
soc_compr_free(struct snd_compr_stream * cstream)9315a7b8c1SKuninori Morimoto static int soc_compr_free(struct snd_compr_stream *cstream)
94453d32c2SKuninori Morimoto {
95453d32c2SKuninori Morimoto return soc_compr_clean(cstream, 0);
96453d32c2SKuninori Morimoto }
97453d32c2SKuninori Morimoto
soc_compr_open(struct snd_compr_stream * cstream)98453d32c2SKuninori Morimoto static int soc_compr_open(struct snd_compr_stream *cstream)
991e57b828SCharles Keepax {
1001e57b828SCharles Keepax struct snd_soc_pcm_runtime *rtd = cstream->private_data;
1011e57b828SCharles Keepax struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
102c2233a26SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
1037428d8c8SKuninori Morimoto int ret;
104939a5cfbSKuninori Morimoto
1051245b700SNamarta Kohli ret = snd_soc_pcm_component_pm_runtime_get(rtd, cstream);
106939a5cfbSKuninori Morimoto if (ret < 0)
107939a5cfbSKuninori Morimoto goto err_no_lock;
108453d32c2SKuninori Morimoto
1094137f4b6SCezary Rojewski snd_soc_dpcm_mutex_lock(rtd);
11038e42f6dSKuninori Morimoto
11115e2e619SCharles Keepax ret = snd_soc_dai_compr_startup(cpu_dai, cstream);
112b5ae4cceSKuninori Morimoto if (ret < 0)
113b5ae4cceSKuninori Morimoto goto err;
114453d32c2SKuninori Morimoto
1152e622ae4SVinod Koul ret = snd_soc_compr_components_open(cstream);
116cd46f382SPeter Ujfalusi if (ret < 0)
1171e57b828SCharles Keepax goto err;
118453d32c2SKuninori Morimoto
1199e7e3738SKuninori Morimoto ret = snd_soc_link_compr_startup(cstream);
1209ab711cbSKuninori Morimoto if (ret < 0)
1219ab711cbSKuninori Morimoto goto err;
122453d32c2SKuninori Morimoto
1231245b700SNamarta Kohli snd_soc_runtime_activate(rtd, stream);
124eb84959aSKuninori Morimoto err:
125453d32c2SKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
12638e42f6dSKuninori Morimoto err_no_lock:
127453d32c2SKuninori Morimoto if (ret < 0)
128453d32c2SKuninori Morimoto soc_compr_clean(cstream, 1);
129453d32c2SKuninori Morimoto
1304137f4b6SCezary Rojewski return ret;
1311245b700SNamarta Kohli }
1321245b700SNamarta Kohli
soc_compr_open_fe(struct snd_compr_stream * cstream)1331245b700SNamarta Kohli static int soc_compr_open_fe(struct snd_compr_stream *cstream)
1342a99ef0fSLiam Girdwood {
1352a99ef0fSLiam Girdwood struct snd_soc_pcm_runtime *fe = cstream->private_data;
1362a99ef0fSLiam Girdwood struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
137c2233a26SKuninori Morimoto struct snd_soc_dpcm *dpcm;
1382a99ef0fSLiam Girdwood struct snd_soc_dapm_widget_list *list;
1392a99ef0fSLiam Girdwood int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
1407428d8c8SKuninori Morimoto int ret;
141572e6c8dSCharles Keepax
1422a99ef0fSLiam Girdwood snd_soc_card_mutex_lock(fe->card);
1430f3b8184SKuninori Morimoto
1440b0722e1SSrinivas Kandagatla ret = dpcm_path_get(fe, stream, &list);
1450b0722e1SSrinivas Kandagatla if (ret < 0)
1460b0722e1SSrinivas Kandagatla goto be_err;
1470b0722e1SSrinivas Kandagatla
148d479f00bSKuninori Morimoto snd_soc_dpcm_mutex_lock(fe);
14938e42f6dSKuninori Morimoto
150aa9ff6a4S강신형 /* calculate valid and active FE <-> BE dpcms */
1510b0722e1SSrinivas Kandagatla dpcm_process_paths(fe, stream, &list, 1);
1520b0722e1SSrinivas Kandagatla
1530b0722e1SSrinivas Kandagatla fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
1540b0722e1SSrinivas Kandagatla
1550b0722e1SSrinivas Kandagatla ret = dpcm_be_dai_startup(fe, stream);
1560b0722e1SSrinivas Kandagatla if (ret < 0) {
1570b0722e1SSrinivas Kandagatla /* clean up all links */
1580b0722e1SSrinivas Kandagatla for_each_dpcm_be(fe, stream, dpcm)
1598d6258a4SKuninori Morimoto dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
1600b0722e1SSrinivas Kandagatla
1610b0722e1SSrinivas Kandagatla dpcm_be_disconnect(fe, stream);
1620b0722e1SSrinivas Kandagatla goto out;
1630b0722e1SSrinivas Kandagatla }
1640b0722e1SSrinivas Kandagatla
1652a99ef0fSLiam Girdwood ret = snd_soc_dai_compr_startup(cpu_dai, cstream);
166b5ae4cceSKuninori Morimoto if (ret < 0)
167b5ae4cceSKuninori Morimoto goto out;
1682e622ae4SVinod Koul
1692e622ae4SVinod Koul ret = snd_soc_compr_components_open(cstream);
170cd46f382SPeter Ujfalusi if (ret < 0)
1711e57b828SCharles Keepax goto open_err;
1720b0722e1SSrinivas Kandagatla
1739e7e3738SKuninori Morimoto ret = snd_soc_link_compr_startup(cstream);
1749ab711cbSKuninori Morimoto if (ret < 0)
1759ab711cbSKuninori Morimoto goto machine_err;
1762a99ef0fSLiam Girdwood
1772a99ef0fSLiam Girdwood dpcm_clear_pending_state(fe, stream);
1782a99ef0fSLiam Girdwood dpcm_path_put(&list);
1792a99ef0fSLiam Girdwood
1802a99ef0fSLiam Girdwood fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN;
1812a99ef0fSLiam Girdwood fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
1822a99ef0fSLiam Girdwood
1832a99ef0fSLiam Girdwood snd_soc_runtime_activate(fe, stream);
18424894b76SLars-Peter Clausen snd_soc_dpcm_mutex_unlock(fe);
18538e42f6dSKuninori Morimoto
1862a99ef0fSLiam Girdwood snd_soc_card_mutex_unlock(fe->card);
1870f3b8184SKuninori Morimoto
1882a99ef0fSLiam Girdwood return 0;
1892a99ef0fSLiam Girdwood
1902a99ef0fSLiam Girdwood machine_err:
1912a99ef0fSLiam Girdwood snd_soc_compr_components_free(cstream, 1);
192cd46f382SPeter Ujfalusi open_err:
1930b0722e1SSrinivas Kandagatla snd_soc_dai_compr_shutdown(cpu_dai, cstream, 1);
1941e6a93cfSKuninori Morimoto out:
1952a99ef0fSLiam Girdwood dpcm_path_put(&list);
1960b0722e1SSrinivas Kandagatla snd_soc_dpcm_mutex_unlock(fe);
197*22222147Syixuanjiang be_err:
1980b0722e1SSrinivas Kandagatla fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
1992a99ef0fSLiam Girdwood snd_soc_card_mutex_unlock(fe->card);
2000f3b8184SKuninori Morimoto return ret;
2012a99ef0fSLiam Girdwood }
2022a99ef0fSLiam Girdwood
soc_compr_free_fe(struct snd_compr_stream * cstream)2032a99ef0fSLiam Girdwood static int soc_compr_free_fe(struct snd_compr_stream *cstream)
2042a99ef0fSLiam Girdwood {
2052a99ef0fSLiam Girdwood struct snd_soc_pcm_runtime *fe = cstream->private_data;
2062a99ef0fSLiam Girdwood struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
207c2233a26SKuninori Morimoto struct snd_soc_dpcm *dpcm;
2082a99ef0fSLiam Girdwood int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
2097428d8c8SKuninori Morimoto
2102a99ef0fSLiam Girdwood snd_soc_card_mutex_lock(fe->card);
2110f3b8184SKuninori Morimoto
2122a99ef0fSLiam Girdwood snd_soc_dpcm_mutex_lock(fe);
21338e42f6dSKuninori Morimoto snd_soc_runtime_deactivate(fe, stream);
21424894b76SLars-Peter Clausen
2152a99ef0fSLiam Girdwood fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
2162a99ef0fSLiam Girdwood
2172a99ef0fSLiam Girdwood dpcm_be_dai_hw_free(fe, stream);
218f52366e6SKuninori Morimoto
2192a99ef0fSLiam Girdwood dpcm_be_dai_shutdown(fe, stream);
220531590bbSKuninori Morimoto
2212a99ef0fSLiam Girdwood /* mark FE's links ready to prune */
2222a99ef0fSLiam Girdwood for_each_dpcm_be(fe, stream, dpcm)
2238d6258a4SKuninori Morimoto dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
2242a99ef0fSLiam Girdwood
2252a99ef0fSLiam Girdwood dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP);
2261c531230SKuninori Morimoto
2272a99ef0fSLiam Girdwood fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE;
2282a99ef0fSLiam Girdwood fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
2292a99ef0fSLiam Girdwood
2302a99ef0fSLiam Girdwood dpcm_be_disconnect(fe, stream);
2312a99ef0fSLiam Girdwood
2322a99ef0fSLiam Girdwood snd_soc_dpcm_mutex_unlock(fe);
23338e42f6dSKuninori Morimoto
234aa9ff6a4S강신형 snd_soc_link_compr_shutdown(cstream, 0);
235cd7c7d10SKuninori Morimoto
2362a99ef0fSLiam Girdwood snd_soc_compr_components_free(cstream, 0);
237cd46f382SPeter Ujfalusi
2389e7e3738SKuninori Morimoto snd_soc_dai_compr_shutdown(cpu_dai, cstream, 0);
2391e6a93cfSKuninori Morimoto
2402e622ae4SVinod Koul snd_soc_card_mutex_unlock(fe->card);
2410f3b8184SKuninori Morimoto return 0;
2422a99ef0fSLiam Girdwood }
2432a99ef0fSLiam Girdwood
soc_compr_trigger(struct snd_compr_stream * cstream,int cmd)2442a99ef0fSLiam Girdwood static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
2454ef0ecb8SCharles Keepax {
2464ef0ecb8SCharles Keepax struct snd_soc_pcm_runtime *rtd = cstream->private_data;
2474ef0ecb8SCharles Keepax struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
248c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
249c2233a26SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
2507428d8c8SKuninori Morimoto int ret;
2514ef0ecb8SCharles Keepax
2524ef0ecb8SCharles Keepax snd_soc_dpcm_mutex_lock(rtd);
25338e42f6dSKuninori Morimoto
2544ef0ecb8SCharles Keepax ret = snd_soc_component_compr_trigger(cstream, cmd);
25508aee251SKuninori Morimoto if (ret < 0)
2564ef0ecb8SCharles Keepax goto out;
2574ef0ecb8SCharles Keepax
2584ef0ecb8SCharles Keepax ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
259eb08411bSKuninori Morimoto if (ret < 0)
260eb08411bSKuninori Morimoto goto out;
261eb08411bSKuninori Morimoto
2622e622ae4SVinod Koul switch (cmd) {
263e38b9b74SMark Brown case SNDRV_PCM_TRIGGER_START:
264e38b9b74SMark Brown snd_soc_dai_digital_mute(codec_dai, 0, stream);
265eb84959aSKuninori Morimoto break;
266e38b9b74SMark Brown case SNDRV_PCM_TRIGGER_STOP:
267e38b9b74SMark Brown snd_soc_dai_digital_mute(codec_dai, 1, stream);
268eb84959aSKuninori Morimoto break;
269e38b9b74SMark Brown }
270e38b9b74SMark Brown
2711245b700SNamarta Kohli out:
27215e2e619SCharles Keepax snd_soc_dpcm_mutex_unlock(rtd);
27338e42f6dSKuninori Morimoto return ret;
2741245b700SNamarta Kohli }
2751245b700SNamarta Kohli
soc_compr_trigger_fe(struct snd_compr_stream * cstream,int cmd)2761245b700SNamarta Kohli static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
2772a99ef0fSLiam Girdwood {
2782a99ef0fSLiam Girdwood struct snd_soc_pcm_runtime *fe = cstream->private_data;
2792a99ef0fSLiam Girdwood struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
280c2233a26SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
2817428d8c8SKuninori Morimoto int ret;
2827428d8c8SKuninori Morimoto
2832a99ef0fSLiam Girdwood if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN ||
2842a99ef0fSLiam Girdwood cmd == SND_COMPR_TRIGGER_DRAIN)
2854ef0ecb8SCharles Keepax return snd_soc_component_compr_trigger(cstream, cmd);
28608aee251SKuninori Morimoto
2872a99ef0fSLiam Girdwood snd_soc_card_mutex_lock(fe->card);
2880f3b8184SKuninori Morimoto
2892a99ef0fSLiam Girdwood ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
290eb08411bSKuninori Morimoto if (ret < 0)
2912e622ae4SVinod Koul goto out;
2922e622ae4SVinod Koul
2932e622ae4SVinod Koul ret = snd_soc_component_compr_trigger(cstream, cmd);
29408aee251SKuninori Morimoto if (ret < 0)
2959e7e3738SKuninori Morimoto goto out;
2969e7e3738SKuninori Morimoto
2979e7e3738SKuninori Morimoto fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
2982a99ef0fSLiam Girdwood
2992a99ef0fSLiam Girdwood ret = dpcm_be_dai_trigger(fe, stream, cmd);
3002a99ef0fSLiam Girdwood
3012a99ef0fSLiam Girdwood switch (cmd) {
3022a99ef0fSLiam Girdwood case SNDRV_PCM_TRIGGER_START:
3032a99ef0fSLiam Girdwood case SNDRV_PCM_TRIGGER_RESUME:
3042a99ef0fSLiam Girdwood case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
3052a99ef0fSLiam Girdwood fe->dpcm[stream].state = SND_SOC_DPCM_STATE_START;
3062a99ef0fSLiam Girdwood break;
3072a99ef0fSLiam Girdwood case SNDRV_PCM_TRIGGER_STOP:
3082a99ef0fSLiam Girdwood case SNDRV_PCM_TRIGGER_SUSPEND:
3092a99ef0fSLiam Girdwood fe->dpcm[stream].state = SND_SOC_DPCM_STATE_STOP;
3102a99ef0fSLiam Girdwood break;
3112a99ef0fSLiam Girdwood case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
3122a99ef0fSLiam Girdwood fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PAUSED;
3132a99ef0fSLiam Girdwood break;
3142a99ef0fSLiam Girdwood }
3152a99ef0fSLiam Girdwood
3162a99ef0fSLiam Girdwood out:
3172a99ef0fSLiam Girdwood fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
3182a99ef0fSLiam Girdwood snd_soc_card_mutex_unlock(fe->card);
3190f3b8184SKuninori Morimoto return ret;
3202a99ef0fSLiam Girdwood }
3212a99ef0fSLiam Girdwood
soc_compr_set_params(struct snd_compr_stream * cstream,struct snd_compr_params * params)3222a99ef0fSLiam Girdwood static int soc_compr_set_params(struct snd_compr_stream *cstream,
3234ef0ecb8SCharles Keepax struct snd_compr_params *params)
3244ef0ecb8SCharles Keepax {
3254ef0ecb8SCharles Keepax struct snd_soc_pcm_runtime *rtd = cstream->private_data;
3264ef0ecb8SCharles Keepax struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
327c2233a26SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
3287428d8c8SKuninori Morimoto int ret;
32952cadf1fSCharles Keepax
3301245b700SNamarta Kohli snd_soc_dpcm_mutex_lock(rtd);
33138e42f6dSKuninori Morimoto
33215e2e619SCharles Keepax /*
333ef050becSCharles Keepax * First we call set_params for the CPU DAI, then the component
334ef050becSCharles Keepax * driver this should configure the SoC side. If the machine has
335ef050becSCharles Keepax * compressed ops then we call that as well. The expectation is
336ef050becSCharles Keepax * that these callbacks will configure everything for this compress
337ef050becSCharles Keepax * path, like configuring a PCM port for a CODEC.
338ef050becSCharles Keepax */
3391245b700SNamarta Kohli ret = snd_soc_dai_compr_set_params(cpu_dai, cstream, params);
3408dfedafbSKuninori Morimoto if (ret < 0)
3412e622ae4SVinod Koul goto err;
3422e622ae4SVinod Koul
3432e622ae4SVinod Koul ret = snd_soc_component_compr_set_params(cstream, params);
344ff08cf80SKuninori Morimoto if (ret < 0)
3459e7e3738SKuninori Morimoto goto err;
3469e7e3738SKuninori Morimoto
3479e7e3738SKuninori Morimoto ret = snd_soc_link_compr_set_params(cstream);
348eab810f3SKuninori Morimoto if (ret < 0)
3491245b700SNamarta Kohli goto err;
350fa40ef20SCharles Keepax
3511245b700SNamarta Kohli snd_soc_dapm_stream_event(rtd, stream, SND_SOC_DAPM_STREAM_START);
3527428d8c8SKuninori Morimoto
3531245b700SNamarta Kohli /* cancel any delayed stream shutdown that is pending */
354fa40ef20SCharles Keepax rtd->pop_wait = 0;
355fa40ef20SCharles Keepax snd_soc_dpcm_mutex_unlock(rtd);
35638e42f6dSKuninori Morimoto
357fa40ef20SCharles Keepax cancel_delayed_work_sync(&rtd->delayed_work);
358fa40ef20SCharles Keepax
359fa40ef20SCharles Keepax return 0;
36052cadf1fSCharles Keepax
361fa40ef20SCharles Keepax err:
362fa40ef20SCharles Keepax snd_soc_dpcm_mutex_unlock(rtd);
36338e42f6dSKuninori Morimoto return ret;
3641245b700SNamarta Kohli }
3651245b700SNamarta Kohli
soc_compr_set_params_fe(struct snd_compr_stream * cstream,struct snd_compr_params * params)3661245b700SNamarta Kohli static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
3672a99ef0fSLiam Girdwood struct snd_compr_params *params)
3682a99ef0fSLiam Girdwood {
3692a99ef0fSLiam Girdwood struct snd_soc_pcm_runtime *fe = cstream->private_data;
3702a99ef0fSLiam Girdwood struct snd_pcm_substream *fe_substream =
37101b8cedfSSatish Babu Patakokila fe->pcm->streams[cstream->direction].substream;
37201b8cedfSSatish Babu Patakokila struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
373c2233a26SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
3747428d8c8SKuninori Morimoto int ret;
3757428d8c8SKuninori Morimoto
3762a99ef0fSLiam Girdwood snd_soc_card_mutex_lock(fe->card);
3770f3b8184SKuninori Morimoto
3782a99ef0fSLiam Girdwood /*
3790b0722e1SSrinivas Kandagatla * Create an empty hw_params for the BE as the machine driver must
3800b0722e1SSrinivas Kandagatla * fix this up to match DSP decoder and ASRC configuration.
3810b0722e1SSrinivas Kandagatla * I.e. machine driver fixup for compressed BE is mandatory.
3820b0722e1SSrinivas Kandagatla */
3830b0722e1SSrinivas Kandagatla memset(&fe->dpcm[fe_substream->stream].hw_params, 0,
3840b0722e1SSrinivas Kandagatla sizeof(struct snd_pcm_hw_params));
3850b0722e1SSrinivas Kandagatla
3860b0722e1SSrinivas Kandagatla fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
3870b0722e1SSrinivas Kandagatla
3880b0722e1SSrinivas Kandagatla ret = dpcm_be_dai_hw_params(fe, stream);
3890b0722e1SSrinivas Kandagatla if (ret < 0)
3900b0722e1SSrinivas Kandagatla goto out;
3910b0722e1SSrinivas Kandagatla
3920b0722e1SSrinivas Kandagatla ret = dpcm_be_dai_prepare(fe, stream);
3930b0722e1SSrinivas Kandagatla if (ret < 0)
3940b0722e1SSrinivas Kandagatla goto out;
3950b0722e1SSrinivas Kandagatla
3960b0722e1SSrinivas Kandagatla ret = snd_soc_dai_compr_set_params(cpu_dai, cstream, params);
3978dfedafbSKuninori Morimoto if (ret < 0)
3982e622ae4SVinod Koul goto out;
3992e622ae4SVinod Koul
4002e622ae4SVinod Koul ret = snd_soc_component_compr_set_params(cstream, params);
401ff08cf80SKuninori Morimoto if (ret < 0)
4029e7e3738SKuninori Morimoto goto out;
4039e7e3738SKuninori Morimoto
4049e7e3738SKuninori Morimoto ret = snd_soc_link_compr_set_params(cstream);
405eab810f3SKuninori Morimoto if (ret < 0)
4062a99ef0fSLiam Girdwood goto out;
4072a99ef0fSLiam Girdwood snd_soc_dpcm_mutex_lock(fe);
40838e42f6dSKuninori Morimoto dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START);
4092a99ef0fSLiam Girdwood snd_soc_dpcm_mutex_unlock(fe);
41038e42f6dSKuninori Morimoto fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE;
4112a99ef0fSLiam Girdwood
4122a99ef0fSLiam Girdwood out:
4132a99ef0fSLiam Girdwood fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
4142a99ef0fSLiam Girdwood snd_soc_card_mutex_unlock(fe->card);
4150f3b8184SKuninori Morimoto return ret;
4162a99ef0fSLiam Girdwood }
4172a99ef0fSLiam Girdwood
soc_compr_get_params(struct snd_compr_stream * cstream,struct snd_codec * params)4182a99ef0fSLiam Girdwood static int soc_compr_get_params(struct snd_compr_stream *cstream,
4191245b700SNamarta Kohli struct snd_codec *params)
4201245b700SNamarta Kohli {
4211245b700SNamarta Kohli struct snd_soc_pcm_runtime *rtd = cstream->private_data;
4221245b700SNamarta Kohli struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
423c2233a26SKuninori Morimoto int ret = 0;
42477c221ecSKuninori Morimoto
4251245b700SNamarta Kohli snd_soc_dpcm_mutex_lock(rtd);
42638e42f6dSKuninori Morimoto
42715e2e619SCharles Keepax ret = snd_soc_dai_compr_get_params(cpu_dai, cstream, params);
428adbef543SKuninori Morimoto if (ret < 0)
4292e622ae4SVinod Koul goto err;
4302e622ae4SVinod Koul
4312e622ae4SVinod Koul ret = snd_soc_component_compr_get_params(cstream, params);
43277c221ecSKuninori Morimoto err:
4332e622ae4SVinod Koul snd_soc_dpcm_mutex_unlock(rtd);
43438e42f6dSKuninori Morimoto return ret;
4351245b700SNamarta Kohli }
4361245b700SNamarta Kohli
soc_compr_ack(struct snd_compr_stream * cstream,size_t bytes)4371245b700SNamarta Kohli static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
4381245b700SNamarta Kohli {
4391245b700SNamarta Kohli struct snd_soc_pcm_runtime *rtd = cstream->private_data;
4401245b700SNamarta Kohli struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
441c2233a26SKuninori Morimoto int ret;
4420506b885SKuninori Morimoto
4431245b700SNamarta Kohli snd_soc_dpcm_mutex_lock(rtd);
44438e42f6dSKuninori Morimoto
44515e2e619SCharles Keepax ret = snd_soc_dai_compr_ack(cpu_dai, cstream, bytes);
44653294353SKuninori Morimoto if (ret < 0)
4472e622ae4SVinod Koul goto err;
4482e622ae4SVinod Koul
4492e622ae4SVinod Koul ret = snd_soc_component_compr_ack(cstream, bytes);
4500506b885SKuninori Morimoto err:
4512e622ae4SVinod Koul snd_soc_dpcm_mutex_unlock(rtd);
45238e42f6dSKuninori Morimoto return ret;
4531245b700SNamarta Kohli }
4541245b700SNamarta Kohli
soc_compr_pointer(struct snd_compr_stream * cstream,struct snd_compr_tstamp * tstamp)4551245b700SNamarta Kohli static int soc_compr_pointer(struct snd_compr_stream *cstream,
4561245b700SNamarta Kohli struct snd_compr_tstamp *tstamp)
4571245b700SNamarta Kohli {
4581245b700SNamarta Kohli struct snd_soc_pcm_runtime *rtd = cstream->private_data;
4591245b700SNamarta Kohli int ret;
46003ecea64SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
461c2233a26SKuninori Morimoto
4621245b700SNamarta Kohli snd_soc_dpcm_mutex_lock(rtd);
46338e42f6dSKuninori Morimoto
46415e2e619SCharles Keepax ret = snd_soc_dai_compr_pointer(cpu_dai, cstream, tstamp);
465ed38cc59SKuninori Morimoto if (ret < 0)
466ed38cc59SKuninori Morimoto goto out;
467ed38cc59SKuninori Morimoto
4682e622ae4SVinod Koul ret = snd_soc_component_compr_pointer(cstream, tstamp);
46903ecea64SKuninori Morimoto out:
470ed38cc59SKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
47138e42f6dSKuninori Morimoto return ret;
4727c9190f7SCharles Keepax }
4731245b700SNamarta Kohli
soc_compr_set_metadata(struct snd_compr_stream * cstream,struct snd_compr_metadata * metadata)4741245b700SNamarta Kohli static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
47502bd90e8SVinod Koul struct snd_compr_metadata *metadata)
47636953d98SJeeja KP {
47736953d98SJeeja KP struct snd_soc_pcm_runtime *rtd = cstream->private_data;
47836953d98SJeeja KP struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
479c2233a26SKuninori Morimoto int ret;
4801b308fb1SKuninori Morimoto
48136953d98SJeeja KP ret = snd_soc_dai_compr_set_metadata(cpu_dai, cstream, metadata);
48288b3a7dfSKuninori Morimoto if (ret < 0)
4832e622ae4SVinod Koul return ret;
4842e622ae4SVinod Koul
4852e622ae4SVinod Koul return snd_soc_component_compr_set_metadata(cstream, metadata);
4861b308fb1SKuninori Morimoto }
48736953d98SJeeja KP
soc_compr_get_metadata(struct snd_compr_stream * cstream,struct snd_compr_metadata * metadata)48836953d98SJeeja KP static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
48902bd90e8SVinod Koul struct snd_compr_metadata *metadata)
49036953d98SJeeja KP {
49136953d98SJeeja KP struct snd_soc_pcm_runtime *rtd = cstream->private_data;
49236953d98SJeeja KP struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
493c2233a26SKuninori Morimoto int ret;
494bab78c23SKuninori Morimoto
49536953d98SJeeja KP ret = snd_soc_dai_compr_get_metadata(cpu_dai, cstream, metadata);
49694d72819SKuninori Morimoto if (ret < 0)
4972e622ae4SVinod Koul return ret;
4982e622ae4SVinod Koul
4992e622ae4SVinod Koul return snd_soc_component_compr_get_metadata(cstream, metadata);
500bab78c23SKuninori Morimoto }
50136953d98SJeeja KP
5022a99ef0fSLiam Girdwood /* ASoC Compress operations */
5031245b700SNamarta Kohli static struct snd_compr_ops soc_compr_ops = {
5041245b700SNamarta Kohli .open = soc_compr_open,
5051245b700SNamarta Kohli .free = soc_compr_free,
5061245b700SNamarta Kohli .set_params = soc_compr_set_params,
5071245b700SNamarta Kohli .set_metadata = soc_compr_set_metadata,
50802bd90e8SVinod Koul .get_metadata = soc_compr_get_metadata,
50902bd90e8SVinod Koul .get_params = soc_compr_get_params,
5101245b700SNamarta Kohli .trigger = soc_compr_trigger,
5111245b700SNamarta Kohli .pointer = soc_compr_pointer,
5121245b700SNamarta Kohli .ack = soc_compr_ack,
5131245b700SNamarta Kohli .get_caps = snd_soc_component_compr_get_caps,
514d67fcb2dSKuninori Morimoto .get_codec_caps = snd_soc_component_compr_get_codec_caps,
5150f6fe097SKuninori Morimoto };
5161245b700SNamarta Kohli
5171245b700SNamarta Kohli /* ASoC Dynamic Compress operations */
5182a99ef0fSLiam Girdwood static struct snd_compr_ops soc_compr_dyn_ops = {
5192a99ef0fSLiam Girdwood .open = soc_compr_open_fe,
5202a99ef0fSLiam Girdwood .free = soc_compr_free_fe,
5212a99ef0fSLiam Girdwood .set_params = soc_compr_set_params_fe,
5222a99ef0fSLiam Girdwood .get_params = soc_compr_get_params,
5232a99ef0fSLiam Girdwood .set_metadata = soc_compr_set_metadata,
5242a99ef0fSLiam Girdwood .get_metadata = soc_compr_get_metadata,
5252a99ef0fSLiam Girdwood .trigger = soc_compr_trigger_fe,
5262a99ef0fSLiam Girdwood .pointer = soc_compr_pointer,
5272a99ef0fSLiam Girdwood .ack = soc_compr_ack,
5282a99ef0fSLiam Girdwood .get_caps = snd_soc_component_compr_get_caps,
529d67fcb2dSKuninori Morimoto .get_codec_caps = snd_soc_component_compr_get_codec_caps,
5300f6fe097SKuninori Morimoto };
5312a99ef0fSLiam Girdwood
5322a99ef0fSLiam Girdwood /**
5336f0c4226SJie Yang * snd_soc_new_compress - create a new compress.
5346f0c4226SJie Yang *
5356f0c4226SJie Yang * @rtd: The runtime for which we will create compress
5366f0c4226SJie Yang * @num: the device index number (zero based - shared with normal PCMs)
5376f0c4226SJie Yang *
5386f0c4226SJie Yang * Return: 0 for success, else error.
5396f0c4226SJie Yang */
snd_soc_new_compress(struct snd_soc_pcm_runtime * rtd,int num)5406f0c4226SJie Yang int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
5416f0c4226SJie Yang {
5421245b700SNamarta Kohli struct snd_soc_component *component;
5439e7e3738SKuninori Morimoto struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
544c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
545c2233a26SKuninori Morimoto struct snd_compr *compr;
5461245b700SNamarta Kohli struct snd_pcm *be_pcm;
5472a99ef0fSLiam Girdwood char new_name[64];
5481245b700SNamarta Kohli int ret = 0, direction = 0;
5491245b700SNamarta Kohli int playback = 0, capture = 0;
550a1068045SVinod Koul int i;
551613fb500SKuninori Morimoto
5521245b700SNamarta Kohli /*
5537428d8c8SKuninori Morimoto * make sure these are same value,
5547428d8c8SKuninori Morimoto * and then use these as equally
5557428d8c8SKuninori Morimoto */
5567428d8c8SKuninori Morimoto BUILD_BUG_ON((int)SNDRV_PCM_STREAM_PLAYBACK != (int)SND_COMPRESS_PLAYBACK);
5577428d8c8SKuninori Morimoto BUILD_BUG_ON((int)SNDRV_PCM_STREAM_CAPTURE != (int)SND_COMPRESS_CAPTURE);
5587428d8c8SKuninori Morimoto
5597428d8c8SKuninori Morimoto if (rtd->dai_link->num_cpus > 1 ||
5603989ade2SKuninori Morimoto rtd->dai_link->num_codecs > 1) {
5613989ade2SKuninori Morimoto dev_err(rtd->card->dev,
562141dfc9eSCharles Keepax "Compress ASoC: Multi CPU/Codec not supported\n");
5636e1276a5SBard Liao return -EINVAL;
5648151d5e6SBenoit Cousson }
5658151d5e6SBenoit Cousson
5668151d5e6SBenoit Cousson if (!codec_dai) {
567ccb4214fSJiasheng Jiang dev_err(rtd->card->dev, "Missing codec\n");
568ccb4214fSJiasheng Jiang return -EINVAL;
569ccb4214fSJiasheng Jiang }
570ccb4214fSJiasheng Jiang
571ccb4214fSJiasheng Jiang /* check client and interface hw capabilities */
5721245b700SNamarta Kohli if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
573467fece8SKuninori Morimoto snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK))
574467fece8SKuninori Morimoto playback = 1;
575a1068045SVinod Koul if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
576467fece8SKuninori Morimoto snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE))
577467fece8SKuninori Morimoto capture = 1;
578a1068045SVinod Koul
579a1068045SVinod Koul /*
580a1068045SVinod Koul * Compress devices are unidirectional so only one of the directions
581a1068045SVinod Koul * should be set, check for that (xor)
582a1068045SVinod Koul */
583a1068045SVinod Koul if (playback + capture != 1) {
584a1068045SVinod Koul dev_err(rtd->card->dev,
585141dfc9eSCharles Keepax "Compress ASoC: Invalid direction for P %d, C %d\n",
586141dfc9eSCharles Keepax playback, capture);
587a1068045SVinod Koul return -EINVAL;
588daa2db59SCharles Keepax }
589a1068045SVinod Koul
590a1068045SVinod Koul if (playback)
591a1068045SVinod Koul direction = SND_COMPRESS_PLAYBACK;
592a1068045SVinod Koul else
593a1068045SVinod Koul direction = SND_COMPRESS_CAPTURE;
594a1068045SVinod Koul
595daa2db59SCharles Keepax compr = devm_kzalloc(rtd->card->dev, sizeof(*compr), GFP_KERNEL);
59609f448a4SAmadeusz Sławiński if (!compr)
5977a0cf42eSMarkus Elfring return -ENOMEM;
5981245b700SNamarta Kohli
5991245b700SNamarta Kohli compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops),
6001f88eb0fSCharles Keepax GFP_KERNEL);
6011f88eb0fSCharles Keepax if (!compr->ops)
60209f448a4SAmadeusz Sławiński return -ENOMEM;
60309f448a4SAmadeusz Sławiński
6042a99ef0fSLiam Girdwood if (rtd->dai_link->dynamic) {
6052a99ef0fSLiam Girdwood snprintf(new_name, sizeof(new_name), "(%s)",
6062a99ef0fSLiam Girdwood rtd->dai_link->stream_name);
6072a99ef0fSLiam Girdwood
6082a99ef0fSLiam Girdwood ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
6092a99ef0fSLiam Girdwood rtd->dai_link->dpcm_playback,
610d3268a40SQais Yousef rtd->dai_link->dpcm_capture, &be_pcm);
611d3268a40SQais Yousef if (ret < 0) {
6122a99ef0fSLiam Girdwood dev_err(rtd->card->dev,
613141dfc9eSCharles Keepax "Compress ASoC: can't create compressed for %s: %d\n",
614141dfc9eSCharles Keepax rtd->dai_link->name, ret);
615141dfc9eSCharles Keepax return ret;
61609f448a4SAmadeusz Sławiński }
6172a99ef0fSLiam Girdwood
6182a99ef0fSLiam Girdwood /* inherit atomicity from DAI link */
61937b58becSDaniel Baluta be_pcm->nonatomic = rtd->dai_link->nonatomic;
62037b58becSDaniel Baluta
62137b58becSDaniel Baluta rtd->pcm = be_pcm;
6222a99ef0fSLiam Girdwood rtd->fe_compr = 1;
6232a99ef0fSLiam Girdwood if (rtd->dai_link->dpcm_playback)
624d3268a40SQais Yousef be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
6252a99ef0fSLiam Girdwood if (rtd->dai_link->dpcm_capture)
626ffe4c0f0SKuninori Morimoto be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd;
6272a99ef0fSLiam Girdwood memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops));
6282a99ef0fSLiam Girdwood } else {
629aeb6fa0fSPeng Donglin snprintf(new_name, sizeof(new_name), "%s %s-%d",
630aeb6fa0fSPeng Donglin rtd->dai_link->stream_name, codec_dai->name, num);
631aeb6fa0fSPeng Donglin
632aeb6fa0fSPeng Donglin memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
6331f88eb0fSCharles Keepax }
634aeb6fa0fSPeng Donglin
6351f88eb0fSCharles Keepax for_each_rtd_components(rtd, i, component) {
636613fb500SKuninori Morimoto if (!component->driver->compress_ops ||
637c6cb522cSKuninori Morimoto !component->driver->compress_ops->copy)
638c6cb522cSKuninori Morimoto continue;
639c6cb522cSKuninori Morimoto
640c6cb522cSKuninori Morimoto compr->ops->copy = snd_soc_component_compr_copy;
641b5852e66SKuninori Morimoto break;
642c6cb522cSKuninori Morimoto }
643c6cb522cSKuninori Morimoto
644c6cb522cSKuninori Morimoto ret = snd_compress_new(rtd->card->snd_card, num, direction,
645e5241a8cSRichard Fitzgerald new_name, compr);
646e5241a8cSRichard Fitzgerald if (ret < 0) {
6471245b700SNamarta Kohli component = asoc_rtd_to_codec(rtd, 0)->component;
648c2233a26SKuninori Morimoto dev_err(component->dev,
649141dfc9eSCharles Keepax "Compress ASoC: can't create compress for codec %s: %d\n",
650141dfc9eSCharles Keepax component->name, ret);
651141dfc9eSCharles Keepax return ret;
65209f448a4SAmadeusz Sławiński }
6531245b700SNamarta Kohli
6541245b700SNamarta Kohli /* DAPM dai link stream work */
655202c8f70SCharles Keepax rtd->close_delayed_work_func = snd_soc_close_delayed_work;
65683f94a2eSKuninori Morimoto
657202c8f70SCharles Keepax rtd->compr = compr;
6581245b700SNamarta Kohli compr->private_data = rtd;
6591245b700SNamarta Kohli
6601245b700SNamarta Kohli dev_dbg(rtd->card->dev, "Compress ASoC: %s <-> %s mapping ok\n",
6611d5cd525SPierre-Louis Bossart codec_dai->name, cpu_dai->name);
662141dfc9eSCharles Keepax
6631f88eb0fSCharles Keepax return 0;
66409f448a4SAmadeusz Sławiński }
6651245b700SNamarta Kohli EXPORT_SYMBOL_GPL(snd_soc_new_compress);
6666f0c4226SJie Yang