Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d8ec305 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: pcm: Add support for hostless playback/capture"

parents 7e85fe5b f156bb58
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -743,6 +743,7 @@ struct snd_soc_pcm_stream {
	unsigned int channels_min;	/* min channels */
	unsigned int channels_max;	/* max channels */
	unsigned int sig_bits;		/* number of bits of content */
	const char *aif_name;		/* DAPM AIF widget name */
};

/* SoC audio ops */
+37 −9
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/workqueue.h>
#include <linux/export.h>
#include <linux/debugfs.h>
#include <linux/dma-mapping.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -44,7 +45,12 @@ static const struct snd_pcm_hardware no_host_hardware = {
	.period_bytes_max	= PAGE_SIZE >> 1,
	.periods_min		= 2,
	.periods_max		= 4,
	.buffer_bytes_max	= PAGE_SIZE,
	/*
	 * Increase the max buffer bytes as PAGE_SIZE bytes is
	 * not enough to encompass all the scenarios sent by
	 * userspapce.
	 */
	.buffer_bytes_max	= PAGE_SIZE * 4,
};

/*
@@ -173,6 +179,8 @@ int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
	const struct snd_pcm_hardware *hw)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	if (!runtime)
		return 0;
	runtime->hw.info = hw->info;
	runtime->hw.formats = hw->formats;
	runtime->hw.period_bytes_min = hw->period_bytes_min;
@@ -945,6 +953,17 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
	int i, ret = 0;

	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);

	/* perform any hw_params fixups */
	if ((rtd->dai_link->no_host_mode == SND_SOC_DAI_LINK_NO_HOST) &&
				rtd->dai_link->be_hw_params_fixup) {
		ret = rtd->dai_link->be_hw_params_fixup(rtd,
				params);
		if (ret < 0)
			dev_err(rtd->card->dev, "ASoC: fixup failed for %s\n",
				rtd->dai_link->name);
	}

	if (rtd->dai_link->ops->hw_params) {
		ret = rtd->dai_link->ops->hw_params(substream, params);
		if (ret < 0) {
@@ -1034,8 +1053,12 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
	if (rtd->dai_link->no_host_mode == SND_SOC_DAI_LINK_NO_HOST) {
		substream->dma_buffer.dev.type = SNDRV_DMA_TYPE_DEV;
		substream->dma_buffer.dev.dev = rtd->dev;
		substream->dma_buffer.dev.dev->coherent_dma_mask =
					DMA_BIT_MASK(sizeof(dma_addr_t) * 8);
		substream->dma_buffer.private_data = NULL;

		arch_setup_dma_ops(substream->dma_buffer.dev.dev,
				   0, 0, NULL, 0);
		ret = snd_pcm_lib_malloc_pages(substream, PAGE_SIZE);
		if (ret < 0)
			goto component_err;
@@ -3071,6 +3094,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
	struct snd_soc_component *component;
	struct snd_soc_rtdcom_list *rtdcom;
	struct snd_pcm *pcm;
	struct snd_pcm_str *stream;
	char new_name[64];
	int ret = 0, playback = 0, capture = 0;
	int i;
@@ -3145,15 +3169,19 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)

	/* setup any hostless PCMs - i.e. no host IO is performed */
	if (rtd->dai_link->no_host_mode) {
		pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->hw_no_buffer = 1;
		pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->hw_no_buffer = 1;
		snd_soc_set_runtime_hwparams(
			pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
		if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
			stream = &pcm->streams[SNDRV_PCM_STREAM_PLAYBACK];
			stream->substream->hw_no_buffer = 1;
			snd_soc_set_runtime_hwparams(stream->substream,
						     &no_host_hardware);
		snd_soc_set_runtime_hwparams(
			pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
		}
		if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
			stream = &pcm->streams[SNDRV_PCM_STREAM_CAPTURE];
			stream->substream->hw_no_buffer = 1;
			snd_soc_set_runtime_hwparams(stream->substream,
						     &no_host_hardware);
		}
	}

	/* ASoC PCM operations */
	if (rtd->dai_link->dynamic) {