diff options
author | Shengjiu Wang <shengjiu.wang@freescale.com> | 2017-02-24 11:53:46 +0800 |
---|---|---|
committer | Anson Huang <Anson.Huang@nxp.com> | 2017-06-09 22:19:07 +0800 |
commit | 62b4c8ba5f563e3eeeda1cd7858d201d2dfeccb3 (patch) | |
tree | c5599d0038059183548d68e634f72a3db3982161 /sound | |
parent | 1e56fb77c13a149a8e1ffa92d368ca95cc2b30c9 (diff) |
MLK-14258: ASoC: imx-pcm-rpmsg: sync sample rate with tx and rx
In suspend and resume, the M4 side will reset hw parameter for tx
and rx, when only tx is working, the parameter of rx is a old value,
which will cause the parameter is not sync with tx and rx.
currently the M4 audio can only work in sync mode, so set both
parameter in same time.
Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/fsl/fsl_rpmsg_i2s.h | 7 | ||||
-rw-r--r-- | sound/soc/fsl/imx-pcm-rpmsg.c | 45 |
2 files changed, 34 insertions, 18 deletions
diff --git a/sound/soc/fsl/fsl_rpmsg_i2s.h b/sound/soc/fsl/fsl_rpmsg_i2s.h index 0fcc80de953f..259cb632630f 100644 --- a/sound/soc/fsl/fsl_rpmsg_i2s.h +++ b/sound/soc/fsl/fsl_rpmsg_i2s.h @@ -243,6 +243,13 @@ #define I2S_RESP_SUCCESS 0x2 #define I2S_RESP_FAILED 0x3 +#define RPMSG_S16_LE 0x0 +#define RPMSG_S24_LE 0x1 + +#define RPMSG_CH_LEFT 0x0 +#define RPMSG_CH_RIGHT 0x1 +#define RPMSG_CH_STEREO 0x2 + struct i2s_param_s { unsigned char audioindex; unsigned char format; diff --git a/sound/soc/fsl/imx-pcm-rpmsg.c b/sound/soc/fsl/imx-pcm-rpmsg.c index 2ece2cfaa728..71ef7692c290 100644 --- a/sound/soc/fsl/imx-pcm-rpmsg.c +++ b/sound/soc/fsl/imx-pcm-rpmsg.c @@ -33,7 +33,7 @@ static const struct snd_pcm_hardware imx_rpmsg_pcm_hardware = { SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME, .buffer_bytes_max = IMX_SAI_DMABUF_SIZE, - .period_bytes_min = 128, + .period_bytes_min = 512, .period_bytes_max = 65535, /* Limited by SDMA engine */ .periods_min = 2, .periods_max = 255, @@ -49,28 +49,37 @@ static int imx_rpmsg_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct fsl_rpmsg_i2s *rpmsg_i2s = dev_get_drvdata(cpu_dai->dev); struct i2s_info *i2s_info = &rpmsg_i2s->i2s_info; - struct i2s_rpmsg_s *rpmsg = &i2s_info->send_msg[substream->stream]; - - rpmsg->param.rate = params_rate(params); - if (SNDRV_PCM_FORMAT_S16_LE == params_format(params)) - rpmsg->param.format = 0; - else - rpmsg->param.format = 1; + struct i2s_rpmsg_s *rpmsg_tx = &i2s_info->send_msg[SNDRV_PCM_STREAM_PLAYBACK]; + struct i2s_rpmsg_s *rpmsg_rx = &i2s_info->send_msg[SNDRV_PCM_STREAM_CAPTURE]; + + rpmsg_tx->param.rate = params_rate(params); + rpmsg_rx->param.rate = params_rate(params); + if (SNDRV_PCM_FORMAT_S16_LE == params_format(params)) { + rpmsg_tx->param.format = RPMSG_S16_LE; + rpmsg_rx->param.format = RPMSG_S16_LE; + } else { + rpmsg_tx->param.format = RPMSG_S24_LE; + rpmsg_rx->param.format = RPMSG_S24_LE; + } - if (params_channels(params) == 1) - rpmsg->param.channels = 0; - else - rpmsg->param.channels = 2; + if (params_channels(params) == 1) { + rpmsg_tx->param.channels = RPMSG_CH_LEFT; + rpmsg_rx->param.channels = RPMSG_CH_LEFT; + } else { + rpmsg_tx->param.channels = RPMSG_CH_STEREO; + rpmsg_rx->param.channels = RPMSG_CH_STEREO; + } snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); runtime->dma_bytes = params_buffer_bytes(params); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - rpmsg->header.cmd = I2S_TX_HW_PARAM; - else - rpmsg->header.cmd = I2S_RX_HW_PARAM; - - i2s_info->send_message(rpmsg, i2s_info); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + rpmsg_tx->header.cmd = I2S_TX_HW_PARAM; + i2s_info->send_message(rpmsg_tx, i2s_info); + } else { + rpmsg_rx->header.cmd = I2S_RX_HW_PARAM; + i2s_info->send_message(rpmsg_rx, i2s_info); + } return 0; } |