soc-pcm.c (7e530d32a3655f15f1cf92e8aabed1bc3a21ee36) soc-pcm.c (092830cf550667d5fa6286605167d232f2c1f61e)
1// SPDX-License-Identifier: GPL-2.0+
2//
3// soc-pcm.c -- ALSA SoC PCM
4//
5// Copyright 2005 Wolfson Microelectronics PLC.
6// Copyright 2005 Openedhand Ltd.
7// Copyright (C) 2010 Slimlogic Ltd.
8// Copyright (C) 2010 Texas Instruments Inc.
9//
10// Authors: Liam Girdwood <lrg@ti.com>
11// Mark Brown <broonie@opensource.wolfsonmicro.com>
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/delay.h>
16#include <linux/pinctrl/consumer.h>
1// SPDX-License-Identifier: GPL-2.0+
2//
3// soc-pcm.c -- ALSA SoC PCM
4//
5// Copyright 2005 Wolfson Microelectronics PLC.
6// Copyright 2005 Openedhand Ltd.
7// Copyright (C) 2010 Slimlogic Ltd.
8// Copyright (C) 2010 Texas Instruments Inc.
9//
10// Authors: Liam Girdwood <lrg@ti.com>
11// Mark Brown <broonie@opensource.wolfsonmicro.com>
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/delay.h>
16#include <linux/pinctrl/consumer.h>
17#include <linux/pm_runtime.h>
18#include <linux/slab.h>
19#include <linux/workqueue.h>
20#include <linux/export.h>
21#include <linux/debugfs.h>
22#include <sound/core.h>
23#include <sound/pcm.h>
24#include <sound/pcm_params.h>
25#include <sound/soc.h>

--- 2374 unchanged lines hidden (view full) ---

2400 struct snd_soc_pcm_runtime *be = dpcm->be;
2401 struct snd_pcm_substream *be_substream =
2402 snd_soc_dpcm_get_substream(be, stream);
2403
2404 /* is this op for this BE ? */
2405 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
2406 continue;
2407
17#include <linux/slab.h>
18#include <linux/workqueue.h>
19#include <linux/export.h>
20#include <linux/debugfs.h>
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/pcm_params.h>
24#include <sound/soc.h>

--- 2374 unchanged lines hidden (view full) ---

2399 struct snd_soc_pcm_runtime *be = dpcm->be;
2400 struct snd_pcm_substream *be_substream =
2401 snd_soc_dpcm_get_substream(be, stream);
2402
2403 /* is this op for this BE ? */
2404 if (!snd_soc_dpcm_be_can_update(fe, be, stream))
2405 continue;
2406
2408 if (!snd_soc_dpcm_can_be_prepared(fe, be, stream))
2409 continue;
2410
2411 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) &&
2412 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) &&
2413 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND) &&
2414 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED))
2415 continue;
2416
2417 dev_dbg(be->dev, "ASoC: prepare BE %s\n",
2418 be->dai_link->name);

--- 394 unchanged lines hidden (view full) ---

2813 *capture = 0;
2814 }
2815
2816 if (rtd->dai_link->capture_only) {
2817 *playback = 0;
2818 *capture = 1;
2819 }
2820
2407 if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) &&
2408 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) &&
2409 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND) &&
2410 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED))
2411 continue;
2412
2413 dev_dbg(be->dev, "ASoC: prepare BE %s\n",
2414 be->dai_link->name);

--- 394 unchanged lines hidden (view full) ---

2809 *capture = 0;
2810 }
2811
2812 if (rtd->dai_link->capture_only) {
2813 *playback = 0;
2814 *capture = 1;
2815 }
2816
2817 if (!*playback && !*capture) {
2818 dev_err(rtd->dev, "substream %s has no playback, no capture\n",
2819 rtd->dai_link->stream_name);
2820
2821 return -EINVAL;
2822 }
2823
2821 return 0;
2822}
2823
2824static int soc_create_pcm(struct snd_pcm **pcm,
2825 struct snd_soc_pcm_runtime *rtd,
2826 int playback, int capture, int num)
2827{
2828 char new_name[64];

--- 211 unchanged lines hidden (view full) ---

3040 SND_SOC_DPCM_STATE_PAUSED,
3041 SND_SOC_DPCM_STATE_SUSPEND,
3042 SND_SOC_DPCM_STATE_PREPARE,
3043 };
3044
3045 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state));
3046}
3047EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_params);
2824 return 0;
2825}
2826
2827static int soc_create_pcm(struct snd_pcm **pcm,
2828 struct snd_soc_pcm_runtime *rtd,
2829 int playback, int capture, int num)
2830{
2831 char new_name[64];

--- 211 unchanged lines hidden (view full) ---

3043 SND_SOC_DPCM_STATE_PAUSED,
3044 SND_SOC_DPCM_STATE_SUSPEND,
3045 SND_SOC_DPCM_STATE_PREPARE,
3046 };
3047
3048 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state));
3049}
3050EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_params);
3048
3049/*
3050 * We can only prepare a BE DAI if any of it's FE are not prepared,
3051 * running or paused for the specified stream direction.
3052 */
3053int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe,
3054 struct snd_soc_pcm_runtime *be, int stream)
3055{
3056 const enum snd_soc_dpcm_state state[] = {
3057 SND_SOC_DPCM_STATE_START,
3058 SND_SOC_DPCM_STATE_PAUSED,
3059 SND_SOC_DPCM_STATE_PREPARE,
3060 };
3061
3062 return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state));
3063}
3064EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_prepared);