ASoC: msm: Add multi-channel pcm support

Add support for multi-channel pcm playback.

Change-Id: I67b8d3cc511b9b33cf652dd24ede58c6f2f4fc65
Signed-off-by: Phani Kumar Uppalapati <phanik@codeaurora.org>
This commit is contained in:
Phani Kumar Uppalapati 2012-11-01 17:13:16 -07:00 committed by Stephen Boyd
parent 2282f95d86
commit 0e46355cbb
3 changed files with 22 additions and 10 deletions

View file

@ -56,7 +56,7 @@ static struct snd_soc_dai_driver msm_fe_dais[] = {
SNDRV_PCM_RATE_KNOT),
.formats = SNDRV_PCM_FMTBIT_S16_LE,
.channels_min = 1,
.channels_max = 6,
.channels_max = 8,
.rate_min = 8000,
.rate_max = 48000,
},

View file

@ -41,7 +41,8 @@ struct snd_msm {
};
#define PLAYBACK_NUM_PERIODS 8
#define PLAYBACK_PERIOD_SIZE 2048
#define PLAYBACK_MAX_PERIOD_SIZE 12288
#define PLAYBACK_MIN_PERIOD_SIZE 2048
#define CAPTURE_NUM_PERIODS 16
#define CAPTURE_PERIOD_SIZE 512
@ -76,10 +77,10 @@ static struct snd_pcm_hardware msm_pcm_hardware_playback = {
.rate_min = 8000,
.rate_max = 48000,
.channels_min = 1,
.channels_max = 2,
.buffer_bytes_max = PLAYBACK_NUM_PERIODS * PLAYBACK_PERIOD_SIZE,
.period_bytes_min = PLAYBACK_PERIOD_SIZE,
.period_bytes_max = PLAYBACK_PERIOD_SIZE,
.channels_max = 8,
.buffer_bytes_max = PLAYBACK_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE,
.period_bytes_min = PLAYBACK_MIN_PERIOD_SIZE,
.period_bytes_max = PLAYBACK_MAX_PERIOD_SIZE,
.periods_min = PLAYBACK_NUM_PERIODS,
.periods_max = PLAYBACK_NUM_PERIODS,
.fifo_size = 0,
@ -352,6 +353,17 @@ static int msm_pcm_open(struct snd_pcm_substream *substream)
if (ret < 0)
pr_info("snd_pcm_hw_constraint_integer failed\n");
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
ret = snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
PLAYBACK_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE,
PLAYBACK_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE);
if (ret < 0) {
pr_err("constraint for buffer bytes min max ret = %d\n",
ret);
}
}
prtd->dsp_cnt = 0;
runtime->private_data = prtd;
@ -642,8 +654,8 @@ static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
ret = q6asm_audio_client_buf_alloc_contiguous(dir,
prtd->audio_client,
runtime->hw.period_bytes_min,
runtime->hw.periods_max);
(params_buffer_bytes(params) / params_periods(params)),
params_periods(params));
if (ret < 0) {
pr_err("Audio Start: Buffer Allocation failed rc = %d\n",
ret);
@ -659,7 +671,7 @@ static int msm_pcm_hw_params(struct snd_pcm_substream *substream,
dma_buf->private_data = NULL;
dma_buf->area = buf[0].data;
dma_buf->addr = buf[0].phys;
dma_buf->bytes = runtime->hw.buffer_bytes_max;
dma_buf->bytes = params_buffer_bytes(params);
if (!dma_buf->area)
return -ENOMEM;

View file

@ -1855,7 +1855,7 @@ static int q6asm_map_channels(u8 *channel_mapping, uint32_t channels)
lchannel_mapping[3] = PCM_CHANNEL_FC;
lchannel_mapping[4] = PCM_CHANNEL_LB;
lchannel_mapping[5] = PCM_CHANNEL_RB;
} else if (channels == 6) {
} else if (channels == 8) {
lchannel_mapping[0] = PCM_CHANNEL_FL;
lchannel_mapping[1] = PCM_CHANNEL_FR;
lchannel_mapping[2] = PCM_CHANNEL_LFE;