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

Commit e0bbf839 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge changes If54fa36c,I82574c88 into msm-next

* changes:
  ASoC: Compress: Check and set pcm_new driver op
  ASoC: pcm: Add support for hostless playback/capture
parents 2a302f2f cb1437d3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -774,6 +774,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 */
+8 −0
Original line number Diff line number Diff line
@@ -817,6 +817,14 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
	rtd->compr = compr;
	compr->private_data = rtd;

	if (platform->driver->pcm_new) {
		ret = platform->driver->pcm_new(rtd);
		if (ret < 0) {
			pr_err("asoc: compress pcm constructor failed\n");
			goto compr_err;
		}
	}

	printk(KERN_INFO "compress asoc: %s <-> %s mapping ok\n", codec_dai->name,
		cpu_dai->name);
	return ret;
+47 −9
Original line number Diff line number Diff line
@@ -25,6 +25,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>
@@ -50,7 +51,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,
};

/*
@@ -175,6 +181,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;
@@ -878,10 +886,31 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,

	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);
	}

	ret = soc_pcm_params_symmetry(substream, params);
	if (ret)
		goto out;

	/* 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 && rtd->dai_link->ops->hw_params) {
		ret = rtd->dai_link->ops->hw_params(substream, params);
		if (ret < 0) {
@@ -959,8 +988,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 platform_err;
@@ -2676,6 +2709,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
	struct snd_soc_dai *codec_dai;
	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
	struct snd_pcm *pcm;
	struct snd_pcm_str *stream;
	char new_name[64];
	int ret = 0, playback = 0, capture = 0;
	int i;
@@ -2750,15 +2784,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) {