diff options
Diffstat (limited to 'sound/soc/soc-generic-dmaengine-pcm.c')
-rw-r--r-- | sound/soc/soc-generic-dmaengine-pcm.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index c39e19e84c8a..99f9495c1c40 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c | |||
@@ -84,12 +84,19 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, | |||
84 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 84 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
85 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); | 85 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); |
86 | struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); | 86 | struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); |
87 | int (*prepare_slave_config)(struct snd_pcm_substream *substream, | ||
88 | struct snd_pcm_hw_params *params, | ||
89 | struct dma_slave_config *slave_config); | ||
87 | struct dma_slave_config slave_config; | 90 | struct dma_slave_config slave_config; |
88 | int ret; | 91 | int ret; |
89 | 92 | ||
90 | if (pcm->config->prepare_slave_config) { | 93 | if (!pcm->config) |
91 | ret = pcm->config->prepare_slave_config(substream, params, | 94 | prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config; |
92 | &slave_config); | 95 | else |
96 | prepare_slave_config = pcm->config->prepare_slave_config; | ||
97 | |||
98 | if (prepare_slave_config) { | ||
99 | ret = prepare_slave_config(substream, params, &slave_config); | ||
93 | if (ret) | 100 | if (ret) |
94 | return ret; | 101 | return ret; |
95 | 102 | ||
@@ -112,7 +119,7 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea | |||
112 | struct snd_pcm_hardware hw; | 119 | struct snd_pcm_hardware hw; |
113 | int ret; | 120 | int ret; |
114 | 121 | ||
115 | if (pcm->config->pcm_hardware) | 122 | if (pcm->config && pcm->config->pcm_hardware) |
116 | return snd_soc_set_runtime_hwparams(substream, | 123 | return snd_soc_set_runtime_hwparams(substream, |
117 | pcm->config->pcm_hardware); | 124 | pcm->config->pcm_hardware); |
118 | 125 | ||
@@ -177,9 +184,20 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) | |||
177 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); | 184 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); |
178 | const struct snd_dmaengine_pcm_config *config = pcm->config; | 185 | const struct snd_dmaengine_pcm_config *config = pcm->config; |
179 | struct snd_pcm_substream *substream; | 186 | struct snd_pcm_substream *substream; |
187 | size_t prealloc_buffer_size; | ||
188 | size_t max_buffer_size; | ||
180 | unsigned int i; | 189 | unsigned int i; |
181 | int ret; | 190 | int ret; |
182 | 191 | ||
192 | if (config && config->prealloc_buffer_size) { | ||
193 | prealloc_buffer_size = config->prealloc_buffer_size; | ||
194 | max_buffer_size = config->pcm_hardware->buffer_bytes_max; | ||
195 | } else { | ||
196 | prealloc_buffer_size = 512 * 1024; | ||
197 | max_buffer_size = SIZE_MAX; | ||
198 | } | ||
199 | |||
200 | |||
183 | for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { | 201 | for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { |
184 | substream = rtd->pcm->streams[i].substream; | 202 | substream = rtd->pcm->streams[i].substream; |
185 | if (!substream) | 203 | if (!substream) |
@@ -200,8 +218,8 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) | |||
200 | ret = snd_pcm_lib_preallocate_pages(substream, | 218 | ret = snd_pcm_lib_preallocate_pages(substream, |
201 | SNDRV_DMA_TYPE_DEV, | 219 | SNDRV_DMA_TYPE_DEV, |
202 | dmaengine_dma_dev(pcm, substream), | 220 | dmaengine_dma_dev(pcm, substream), |
203 | config->prealloc_buffer_size, | 221 | prealloc_buffer_size, |
204 | config->pcm_hardware->buffer_bytes_max); | 222 | max_buffer_size); |
205 | if (ret) | 223 | if (ret) |
206 | goto err_free; | 224 | goto err_free; |
207 | } | 225 | } |