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>
231245b700SNamarta Kohli
snd_soc_compr_components_open(struct snd_compr_stream * cstream)24cd46f382SPeter Ujfalusi 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)57453d32c2SKuninori Morimoto static int soc_compr_clean(struct snd_compr_stream *cstream, int rollback)
5815a7b8c1SKuninori 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
6438e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_lock(rtd);
6515a7b8c1SKuninori Morimoto
66453d32c2SKuninori Morimoto if (!rollback)
6715a7b8c1SKuninori 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
77453d32c2SKuninori Morimoto snd_soc_link_compr_shutdown(cstream, rollback);
7815a7b8c1SKuninori Morimoto
79cd46f382SPeter Ujfalusi snd_soc_compr_components_free(cstream, rollback);
8015a7b8c1SKuninori Morimoto
81453d32c2SKuninori Morimoto snd_soc_dai_compr_shutdown(cpu_dai, cstream, rollback);
8215a7b8c1SKuninori Morimoto
83453d32c2SKuninori Morimoto if (!rollback)
8415a7b8c1SKuninori Morimoto snd_soc_dapm_stream_stop(rtd, stream);
8515a7b8c1SKuninori Morimoto
8638e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
8715a7b8c1SKuninori Morimoto
88453d32c2SKuninori Morimoto snd_soc_pcm_component_pm_runtime_put(rtd, cstream, rollback);
8915a7b8c1SKuninori Morimoto
9015a7b8c1SKuninori Morimoto return 0;
9115a7b8c1SKuninori Morimoto }
9215a7b8c1SKuninori Morimoto
soc_compr_free(struct snd_compr_stream * cstream)93453d32c2SKuninori 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)981e57b828SCharles Keepax static int soc_compr_open(struct snd_compr_stream *cstream)
991e57b828SCharles Keepax {
1001e57b828SCharles Keepax struct snd_soc_pcm_runtime *rtd = cstream->private_data;
101c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
1027428d8c8SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
103939a5cfbSKuninori Morimoto int ret;
1041245b700SNamarta Kohli
105939a5cfbSKuninori Morimoto ret = snd_soc_pcm_component_pm_runtime_get(rtd, cstream);
106939a5cfbSKuninori Morimoto if (ret < 0)
107453d32c2SKuninori Morimoto goto err_no_lock;
1084137f4b6SCezary Rojewski
10938e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_lock(rtd);
11015e2e619SCharles Keepax
111b5ae4cceSKuninori Morimoto ret = snd_soc_dai_compr_startup(cpu_dai, cstream);
112b5ae4cceSKuninori Morimoto if (ret < 0)
113453d32c2SKuninori Morimoto goto err;
1142e622ae4SVinod Koul
115cd46f382SPeter Ujfalusi ret = snd_soc_compr_components_open(cstream);
1161e57b828SCharles Keepax if (ret < 0)
117453d32c2SKuninori Morimoto goto err;
1189e7e3738SKuninori Morimoto
1199ab711cbSKuninori Morimoto ret = snd_soc_link_compr_startup(cstream);
1209ab711cbSKuninori Morimoto if (ret < 0)
121453d32c2SKuninori Morimoto goto err;
1221245b700SNamarta Kohli
123eb84959aSKuninori Morimoto snd_soc_runtime_activate(rtd, stream);
124453d32c2SKuninori Morimoto err:
12538e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
126453d32c2SKuninori Morimoto err_no_lock:
127453d32c2SKuninori Morimoto if (ret < 0)
128453d32c2SKuninori Morimoto soc_compr_clean(cstream, 1);
1294137f4b6SCezary Rojewski
1301245b700SNamarta Kohli return ret;
1311245b700SNamarta Kohli }
1321245b700SNamarta Kohli
soc_compr_open_fe(struct snd_compr_stream * cstream)1332a99ef0fSLiam Girdwood static int soc_compr_open_fe(struct snd_compr_stream *cstream)
1342a99ef0fSLiam Girdwood {
1352a99ef0fSLiam Girdwood struct snd_soc_pcm_runtime *fe = cstream->private_data;
136c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
1372a99ef0fSLiam Girdwood struct snd_soc_dpcm *dpcm;
1382a99ef0fSLiam Girdwood struct snd_soc_dapm_widget_list *list;
1397428d8c8SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
140572e6c8dSCharles Keepax int ret;
1412a99ef0fSLiam Girdwood
1420f3b8184SKuninori Morimoto snd_soc_card_mutex_lock(fe->card);
1430b0722e1SSrinivas Kandagatla
1440b0722e1SSrinivas Kandagatla ret = dpcm_path_get(fe, stream, &list);
1450b0722e1SSrinivas Kandagatla if (ret < 0)
1460b0722e1SSrinivas Kandagatla goto be_err;
147d479f00bSKuninori Morimoto
14838e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_lock(fe);
149aa9ff6a4S강신형
1500b0722e1SSrinivas Kandagatla /* 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 */
1588d6258a4SKuninori Morimoto for_each_dpcm_be(fe, stream, dpcm)
1590b0722e1SSrinivas Kandagatla dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
1600b0722e1SSrinivas Kandagatla
1610b0722e1SSrinivas Kandagatla dpcm_be_disconnect(fe, stream);
1620b0722e1SSrinivas Kandagatla goto out;
1630b0722e1SSrinivas Kandagatla }
1642a99ef0fSLiam Girdwood
165b5ae4cceSKuninori Morimoto ret = snd_soc_dai_compr_startup(cpu_dai, cstream);
166b5ae4cceSKuninori Morimoto if (ret < 0)
1672e622ae4SVinod Koul goto out;
1682e622ae4SVinod Koul
169cd46f382SPeter Ujfalusi ret = snd_soc_compr_components_open(cstream);
1701e57b828SCharles Keepax if (ret < 0)
1710b0722e1SSrinivas Kandagatla goto open_err;
1729e7e3738SKuninori Morimoto
1739ab711cbSKuninori Morimoto ret = snd_soc_link_compr_startup(cstream);
1749ab711cbSKuninori Morimoto if (ret < 0)
1752a99ef0fSLiam Girdwood 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
18324894b76SLars-Peter Clausen snd_soc_runtime_activate(fe, stream);
18438e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(fe);
1852a99ef0fSLiam Girdwood
1860f3b8184SKuninori Morimoto snd_soc_card_mutex_unlock(fe->card);
1872a99ef0fSLiam Girdwood
1882a99ef0fSLiam Girdwood return 0;
1892a99ef0fSLiam Girdwood
1902a99ef0fSLiam Girdwood machine_err:
191cd46f382SPeter Ujfalusi snd_soc_compr_components_free(cstream, 1);
1920b0722e1SSrinivas Kandagatla open_err:
1931e6a93cfSKuninori Morimoto snd_soc_dai_compr_shutdown(cpu_dai, cstream, 1);
1942a99ef0fSLiam Girdwood out:
1950b0722e1SSrinivas Kandagatla dpcm_path_put(&list);
196*22222147Syixuanjiang snd_soc_dpcm_mutex_unlock(fe);
1970b0722e1SSrinivas Kandagatla be_err:
1982a99ef0fSLiam Girdwood fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
1990f3b8184SKuninori Morimoto snd_soc_card_mutex_unlock(fe->card);
2002a99ef0fSLiam Girdwood 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;
206c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
2072a99ef0fSLiam Girdwood struct snd_soc_dpcm *dpcm;
2087428d8c8SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
2092a99ef0fSLiam Girdwood
2100f3b8184SKuninori Morimoto snd_soc_card_mutex_lock(fe->card);
2112a99ef0fSLiam Girdwood
21238e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_lock(fe);
21324894b76SLars-Peter Clausen snd_soc_runtime_deactivate(fe, stream);
2142a99ef0fSLiam Girdwood
2152a99ef0fSLiam Girdwood fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
2162a99ef0fSLiam Girdwood
217f52366e6SKuninori Morimoto dpcm_be_dai_hw_free(fe, stream);
2182a99ef0fSLiam Girdwood
219531590bbSKuninori Morimoto dpcm_be_dai_shutdown(fe, stream);
2202a99ef0fSLiam Girdwood
2212a99ef0fSLiam Girdwood /* mark FE's links ready to prune */
2228d6258a4SKuninori Morimoto for_each_dpcm_be(fe, stream, dpcm)
2232a99ef0fSLiam Girdwood dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
2242a99ef0fSLiam Girdwood
2251c531230SKuninori Morimoto dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP);
2262a99ef0fSLiam Girdwood
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
23238e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(fe);
233aa9ff6a4S강신형
234cd7c7d10SKuninori Morimoto snd_soc_link_compr_shutdown(cstream, 0);
2352a99ef0fSLiam Girdwood
236cd46f382SPeter Ujfalusi snd_soc_compr_components_free(cstream, 0);
2379e7e3738SKuninori Morimoto
2381e6a93cfSKuninori Morimoto snd_soc_dai_compr_shutdown(cpu_dai, cstream, 0);
2392e622ae4SVinod Koul
2400f3b8184SKuninori Morimoto snd_soc_card_mutex_unlock(fe->card);
2412a99ef0fSLiam Girdwood return 0;
2422a99ef0fSLiam Girdwood }
2432a99ef0fSLiam Girdwood
soc_compr_trigger(struct snd_compr_stream * cstream,int cmd)2444ef0ecb8SCharles Keepax 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;
247c2233a26SKuninori Morimoto 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);
2497428d8c8SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
2504ef0ecb8SCharles Keepax int ret;
2514ef0ecb8SCharles Keepax
25238e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_lock(rtd);
2534ef0ecb8SCharles Keepax
25408aee251SKuninori Morimoto ret = snd_soc_component_compr_trigger(cstream, cmd);
2554ef0ecb8SCharles Keepax if (ret < 0)
2564ef0ecb8SCharles Keepax goto out;
2574ef0ecb8SCharles Keepax
258eb08411bSKuninori Morimoto ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
259eb08411bSKuninori Morimoto if (ret < 0)
260eb08411bSKuninori Morimoto goto out;
2612e622ae4SVinod Koul
262e38b9b74SMark Brown switch (cmd) {
263e38b9b74SMark Brown case SNDRV_PCM_TRIGGER_START:
264eb84959aSKuninori Morimoto snd_soc_dai_digital_mute(codec_dai, 0, stream);
265e38b9b74SMark Brown break;
266e38b9b74SMark Brown case SNDRV_PCM_TRIGGER_STOP:
267eb84959aSKuninori Morimoto snd_soc_dai_digital_mute(codec_dai, 1, stream);
268e38b9b74SMark Brown break;
269e38b9b74SMark Brown }
2701245b700SNamarta Kohli
27115e2e619SCharles Keepax out:
27238e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
2731245b700SNamarta Kohli return ret;
2741245b700SNamarta Kohli }
2751245b700SNamarta Kohli
soc_compr_trigger_fe(struct snd_compr_stream * cstream,int cmd)2762a99ef0fSLiam Girdwood 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;
279c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
2807428d8c8SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
2817428d8c8SKuninori Morimoto int ret;
2822a99ef0fSLiam Girdwood
2832a99ef0fSLiam Girdwood if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN ||
2844ef0ecb8SCharles Keepax cmd == SND_COMPR_TRIGGER_DRAIN)
28508aee251SKuninori Morimoto return snd_soc_component_compr_trigger(cstream, cmd);
2862a99ef0fSLiam Girdwood
2870f3b8184SKuninori Morimoto snd_soc_card_mutex_lock(fe->card);
2882a99ef0fSLiam Girdwood
289eb08411bSKuninori Morimoto ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
2902e622ae4SVinod Koul if (ret < 0)
2912e622ae4SVinod Koul goto out;
2922e622ae4SVinod Koul
29308aee251SKuninori Morimoto ret = snd_soc_component_compr_trigger(cstream, cmd);
2949e7e3738SKuninori Morimoto if (ret < 0)
2959e7e3738SKuninori Morimoto goto out;
2969e7e3738SKuninori Morimoto
2972a99ef0fSLiam Girdwood 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;
3180f3b8184SKuninori Morimoto snd_soc_card_mutex_unlock(fe->card);
3192a99ef0fSLiam Girdwood return ret;
3202a99ef0fSLiam Girdwood }
3212a99ef0fSLiam Girdwood
soc_compr_set_params(struct snd_compr_stream * cstream,struct snd_compr_params * params)3224ef0ecb8SCharles Keepax 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;
326c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
3277428d8c8SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
32852cadf1fSCharles Keepax int ret;
3291245b700SNamarta Kohli
33038e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_lock(rtd);
33115e2e619SCharles Keepax
332ef050becSCharles 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.
3381245b700SNamarta Kohli */
3398dfedafbSKuninori Morimoto ret = snd_soc_dai_compr_set_params(cpu_dai, cstream, params);
3402e622ae4SVinod Koul if (ret < 0)
3412e622ae4SVinod Koul goto err;
3422e622ae4SVinod Koul
343ff08cf80SKuninori Morimoto ret = snd_soc_component_compr_set_params(cstream, params);
3449e7e3738SKuninori Morimoto if (ret < 0)
3459e7e3738SKuninori Morimoto goto err;
3469e7e3738SKuninori Morimoto
347eab810f3SKuninori Morimoto ret = snd_soc_link_compr_set_params(cstream);
3481245b700SNamarta Kohli if (ret < 0)
349fa40ef20SCharles Keepax goto err;
3501245b700SNamarta Kohli
3517428d8c8SKuninori Morimoto snd_soc_dapm_stream_event(rtd, stream, SND_SOC_DAPM_STREAM_START);
3521245b700SNamarta Kohli
353fa40ef20SCharles Keepax /* cancel any delayed stream shutdown that is pending */
354fa40ef20SCharles Keepax rtd->pop_wait = 0;
35538e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
356fa40ef20SCharles Keepax
357fa40ef20SCharles Keepax cancel_delayed_work_sync(&rtd->delayed_work);
358fa40ef20SCharles Keepax
35952cadf1fSCharles Keepax return 0;
360fa40ef20SCharles Keepax
361fa40ef20SCharles Keepax err:
36238e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
3631245b700SNamarta Kohli return ret;
3641245b700SNamarta Kohli }
3651245b700SNamarta Kohli
soc_compr_set_params_fe(struct snd_compr_stream * cstream,struct snd_compr_params * params)3662a99ef0fSLiam Girdwood 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;
37001b8cedfSSatish Babu Patakokila struct snd_pcm_substream *fe_substream =
37101b8cedfSSatish Babu Patakokila fe->pcm->streams[cstream->direction].substream;
372c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0);
3737428d8c8SKuninori Morimoto int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
3747428d8c8SKuninori Morimoto int ret;
3752a99ef0fSLiam Girdwood
3760f3b8184SKuninori Morimoto snd_soc_card_mutex_lock(fe->card);
3772a99ef0fSLiam Girdwood
3780b0722e1SSrinivas Kandagatla /*
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
3968dfedafbSKuninori Morimoto ret = snd_soc_dai_compr_set_params(cpu_dai, cstream, params);
3972e622ae4SVinod Koul if (ret < 0)
3982e622ae4SVinod Koul goto out;
3992e622ae4SVinod Koul
400ff08cf80SKuninori Morimoto ret = snd_soc_component_compr_set_params(cstream, params);
4019e7e3738SKuninori Morimoto if (ret < 0)
4029e7e3738SKuninori Morimoto goto out;
4039e7e3738SKuninori Morimoto
404eab810f3SKuninori Morimoto ret = snd_soc_link_compr_set_params(cstream);
4052a99ef0fSLiam Girdwood if (ret < 0)
4062a99ef0fSLiam Girdwood goto out;
40738e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_lock(fe);
4082a99ef0fSLiam Girdwood dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_START);
40938e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(fe);
4102a99ef0fSLiam Girdwood 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;
4140f3b8184SKuninori Morimoto snd_soc_card_mutex_unlock(fe->card);
4152a99ef0fSLiam Girdwood return ret;
4162a99ef0fSLiam Girdwood }
4172a99ef0fSLiam Girdwood
soc_compr_get_params(struct snd_compr_stream * cstream,struct snd_codec * params)4181245b700SNamarta Kohli 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;
422c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
42377c221ecSKuninori Morimoto int ret = 0;
4241245b700SNamarta Kohli
42538e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_lock(rtd);
42615e2e619SCharles Keepax
427adbef543SKuninori Morimoto ret = snd_soc_dai_compr_get_params(cpu_dai, cstream, params);
4282e622ae4SVinod Koul if (ret < 0)
4292e622ae4SVinod Koul goto err;
4302e622ae4SVinod Koul
43177c221ecSKuninori Morimoto ret = snd_soc_component_compr_get_params(cstream, params);
4322e622ae4SVinod Koul err:
43338e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
4341245b700SNamarta Kohli 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;
440c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
4410506b885SKuninori Morimoto int ret;
4421245b700SNamarta Kohli
44338e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_lock(rtd);
44415e2e619SCharles Keepax
44553294353SKuninori Morimoto ret = snd_soc_dai_compr_ack(cpu_dai, cstream, bytes);
4462e622ae4SVinod Koul if (ret < 0)
4472e622ae4SVinod Koul goto err;
4482e622ae4SVinod Koul
4490506b885SKuninori Morimoto ret = snd_soc_component_compr_ack(cstream, bytes);
4502e622ae4SVinod Koul err:
45138e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
4521245b700SNamarta Kohli 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;
45903ecea64SKuninori Morimoto int ret;
460c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
4611245b700SNamarta Kohli
46238e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_lock(rtd);
46315e2e619SCharles Keepax
464ed38cc59SKuninori Morimoto ret = snd_soc_dai_compr_pointer(cpu_dai, cstream, tstamp);
465ed38cc59SKuninori Morimoto if (ret < 0)
466ed38cc59SKuninori Morimoto goto out;
4672e622ae4SVinod Koul
46803ecea64SKuninori Morimoto ret = snd_soc_component_compr_pointer(cstream, tstamp);
469ed38cc59SKuninori Morimoto out:
47038e42f6dSKuninori Morimoto snd_soc_dpcm_mutex_unlock(rtd);
4717c9190f7SCharles Keepax return ret;
4721245b700SNamarta Kohli }
4731245b700SNamarta Kohli
soc_compr_set_metadata(struct snd_compr_stream * cstream,struct snd_compr_metadata * metadata)47402bd90e8SVinod Koul static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
47536953d98SJeeja KP struct snd_compr_metadata *metadata)
47636953d98SJeeja KP {
47736953d98SJeeja KP struct snd_soc_pcm_runtime *rtd = cstream->private_data;
478c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
4791b308fb1SKuninori Morimoto int ret;
48036953d98SJeeja KP
48188b3a7dfSKuninori Morimoto ret = snd_soc_dai_compr_set_metadata(cpu_dai, cstream, metadata);
4822e622ae4SVinod Koul if (ret < 0)
4832e622ae4SVinod Koul return ret;
4842e622ae4SVinod Koul
4851b308fb1SKuninori Morimoto return snd_soc_component_compr_set_metadata(cstream, metadata);
48636953d98SJeeja KP }
48736953d98SJeeja KP
soc_compr_get_metadata(struct snd_compr_stream * cstream,struct snd_compr_metadata * metadata)48802bd90e8SVinod Koul static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
48936953d98SJeeja KP struct snd_compr_metadata *metadata)
49036953d98SJeeja KP {
49136953d98SJeeja KP struct snd_soc_pcm_runtime *rtd = cstream->private_data;
492c2233a26SKuninori Morimoto struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
493bab78c23SKuninori Morimoto int ret;
49436953d98SJeeja KP
49594d72819SKuninori Morimoto ret = snd_soc_dai_compr_get_metadata(cpu_dai, cstream, metadata);
4962e622ae4SVinod Koul if (ret < 0)
4972e622ae4SVinod Koul return ret;
4982e622ae4SVinod Koul
499bab78c23SKuninori Morimoto return snd_soc_component_compr_get_metadata(cstream, metadata);
50036953d98SJeeja KP }
5012a99ef0fSLiam Girdwood
5021245b700SNamarta Kohli /* 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,
50702bd90e8SVinod Koul .set_metadata = soc_compr_set_metadata,
50802bd90e8SVinod Koul .get_metadata = soc_compr_get_metadata,
5091245b700SNamarta Kohli .get_params = soc_compr_get_params,
5101245b700SNamarta Kohli .trigger = soc_compr_trigger,
5111245b700SNamarta Kohli .pointer = soc_compr_pointer,
5121245b700SNamarta Kohli .ack = soc_compr_ack,
513d67fcb2dSKuninori Morimoto .get_caps = snd_soc_component_compr_get_caps,
5140f6fe097SKuninori Morimoto .get_codec_caps = snd_soc_component_compr_get_codec_caps,
5151245b700SNamarta Kohli };
5161245b700SNamarta Kohli
5172a99ef0fSLiam Girdwood /* 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,
528d67fcb2dSKuninori Morimoto .get_caps = snd_soc_component_compr_get_caps,
5290f6fe097SKuninori Morimoto .get_codec_caps = snd_soc_component_compr_get_codec_caps,
5302a99ef0fSLiam Girdwood };
5312a99ef0fSLiam Girdwood
5326f0c4226SJie Yang /**
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)
5411245b700SNamarta Kohli {
5429e7e3738SKuninori Morimoto struct snd_soc_component *component;
543c2233a26SKuninori 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);
5451245b700SNamarta Kohli struct snd_compr *compr;
5462a99ef0fSLiam Girdwood struct snd_pcm *be_pcm;
5471245b700SNamarta Kohli char new_name[64];
5481245b700SNamarta Kohli int ret = 0, direction = 0;
549a1068045SVinod Koul int playback = 0, capture = 0;
550613fb500SKuninori Morimoto int i;
5511245b700SNamarta Kohli
5527428d8c8SKuninori Morimoto /*
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
5593989ade2SKuninori Morimoto if (rtd->dai_link->num_cpus > 1 ||
5603989ade2SKuninori Morimoto rtd->dai_link->num_codecs > 1) {
561141dfc9eSCharles Keepax dev_err(rtd->card->dev,
5626e1276a5SBard Liao "Compress ASoC: Multi CPU/Codec not supported\n");
5638151d5e6SBenoit Cousson return -EINVAL;
5648151d5e6SBenoit Cousson }
5658151d5e6SBenoit Cousson
566ccb4214fSJiasheng Jiang if (!codec_dai) {
567ccb4214fSJiasheng Jiang dev_err(rtd->card->dev, "Missing codec\n");
568ccb4214fSJiasheng Jiang return -EINVAL;
569ccb4214fSJiasheng Jiang }
570ccb4214fSJiasheng Jiang
5711245b700SNamarta Kohli /* check client and interface hw capabilities */
572467fece8SKuninori Morimoto 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))
574a1068045SVinod Koul playback = 1;
575467fece8SKuninori Morimoto 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))
577a1068045SVinod Koul 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) {
584141dfc9eSCharles Keepax dev_err(rtd->card->dev,
585141dfc9eSCharles Keepax "Compress ASoC: Invalid direction for P %d, C %d\n",
586a1068045SVinod Koul playback, capture);
587daa2db59SCharles Keepax return -EINVAL;
588a1068045SVinod Koul }
589a1068045SVinod Koul
590a1068045SVinod Koul if (playback)
591a1068045SVinod Koul direction = SND_COMPRESS_PLAYBACK;
592a1068045SVinod Koul else
593a1068045SVinod Koul direction = SND_COMPRESS_CAPTURE;
594daa2db59SCharles Keepax
59509f448a4SAmadeusz Sławiński compr = devm_kzalloc(rtd->card->dev, sizeof(*compr), GFP_KERNEL);
5967a0cf42eSMarkus Elfring if (!compr)
5971245b700SNamarta Kohli return -ENOMEM;
5981245b700SNamarta Kohli
5991f88eb0fSCharles Keepax compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops),
6001f88eb0fSCharles Keepax GFP_KERNEL);
60109f448a4SAmadeusz Sławiński if (!compr->ops)
60209f448a4SAmadeusz Sławiński return -ENOMEM;
6032a99ef0fSLiam Girdwood
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,
609d3268a40SQais Yousef rtd->dai_link->dpcm_playback,
610d3268a40SQais Yousef rtd->dai_link->dpcm_capture, &be_pcm);
6112a99ef0fSLiam Girdwood if (ret < 0) {
612141dfc9eSCharles Keepax dev_err(rtd->card->dev,
613141dfc9eSCharles Keepax "Compress ASoC: can't create compressed for %s: %d\n",
614141dfc9eSCharles Keepax rtd->dai_link->name, ret);
61509f448a4SAmadeusz Sławiński return ret;
6162a99ef0fSLiam Girdwood }
6172a99ef0fSLiam Girdwood
61837b58becSDaniel Baluta /* inherit atomicity from DAI link */
61937b58becSDaniel Baluta be_pcm->nonatomic = rtd->dai_link->nonatomic;
62037b58becSDaniel Baluta
6212a99ef0fSLiam Girdwood rtd->pcm = be_pcm;
6222a99ef0fSLiam Girdwood rtd->fe_compr = 1;
623d3268a40SQais Yousef if (rtd->dai_link->dpcm_playback)
6242a99ef0fSLiam Girdwood be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
625ffe4c0f0SKuninori Morimoto if (rtd->dai_link->dpcm_capture)
6262a99ef0fSLiam Girdwood 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));
628aeb6fa0fSPeng Donglin } 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
6321f88eb0fSCharles Keepax memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
633aeb6fa0fSPeng Donglin }
6341f88eb0fSCharles Keepax
635613fb500SKuninori Morimoto for_each_rtd_components(rtd, i, component) {
636c6cb522cSKuninori Morimoto if (!component->driver->compress_ops ||
637c6cb522cSKuninori Morimoto !component->driver->compress_ops->copy)
638c6cb522cSKuninori Morimoto continue;
639c6cb522cSKuninori Morimoto
640b5852e66SKuninori Morimoto compr->ops->copy = snd_soc_component_compr_copy;
641c6cb522cSKuninori Morimoto break;
642c6cb522cSKuninori Morimoto }
643c6cb522cSKuninori Morimoto
644e5241a8cSRichard Fitzgerald ret = snd_compress_new(rtd->card->snd_card, num, direction,
645e5241a8cSRichard Fitzgerald new_name, compr);
6461245b700SNamarta Kohli if (ret < 0) {
647c2233a26SKuninori Morimoto component = asoc_rtd_to_codec(rtd, 0)->component;
648141dfc9eSCharles Keepax dev_err(component->dev,
649141dfc9eSCharles Keepax "Compress ASoC: can't create compress for codec %s: %d\n",
650141dfc9eSCharles Keepax component->name, ret);
65109f448a4SAmadeusz Sławiński return ret;
6521245b700SNamarta Kohli }
6531245b700SNamarta Kohli
654202c8f70SCharles Keepax /* DAPM dai link stream work */
65583f94a2eSKuninori Morimoto rtd->close_delayed_work_func = snd_soc_close_delayed_work;
656202c8f70SCharles Keepax
6571245b700SNamarta Kohli rtd->compr = compr;
6581245b700SNamarta Kohli compr->private_data = rtd;
6591245b700SNamarta Kohli
6601d5cd525SPierre-Louis Bossart dev_dbg(rtd->card->dev, "Compress ASoC: %s <-> %s mapping ok\n",
661141dfc9eSCharles Keepax codec_dai->name, cpu_dai->name);
6621f88eb0fSCharles Keepax
66309f448a4SAmadeusz Sławiński return 0;
6641245b700SNamarta Kohli }
6656f0c4226SJie Yang EXPORT_SYMBOL_GPL(snd_soc_new_compress);
666