aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2012-09-14 08:05:52 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-22 11:12:59 -0400
commit03945e99a8ac4f596dad9a679816e5b4bb77e5d2 (patch)
tree51f73408c4f3eefdfd6be05f776ee497beda92da /sound
parent061fb36db7c0187aa90b95f1ba56f6192f42b984 (diff)
ASoC: omap-pcm: Prepare to configure the DMA data_type based on stream properties
Based on the format of the stream the omap-pcm can decide alone what data type should be used with by the sDMA. Keep the possibility for OMAP dai drivers to tell omap-pcm if they want to use different data type. This is needed for the omap-hdmi for example which needs 32bit data type even if the stream format is S16_LE. The check if (dma_data->data_type) is safe at the moment since omap-pcm does not support 8bit samples (OMAP_DMA_DATA_TYPE_S8 == 0x00). The next step is to redefine the meaning of dma_data->data_type to unblock this limitation. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/omap/omap-pcm.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 02eeb2e7ceda..4c13a5f4eebb 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -149,6 +149,24 @@ static int omap_pcm_hw_free(struct snd_pcm_substream *substream)
149 return 0; 149 return 0;
150} 150}
151 151
152static int omap_pcm_get_dma_type(int num_bits)
153{
154 int data_type;
155
156 switch (num_bits) {
157 case 16:
158 data_type = OMAP_DMA_DATA_TYPE_S16;
159 break;
160 case 32:
161 data_type = OMAP_DMA_DATA_TYPE_S32;
162 break;
163 default:
164 data_type = -EINVAL;
165 break;
166 }
167 return data_type;
168}
169
152static int omap_pcm_prepare(struct snd_pcm_substream *substream) 170static int omap_pcm_prepare(struct snd_pcm_substream *substream)
153{ 171{
154 struct snd_pcm_runtime *runtime = substream->runtime; 172 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -163,7 +181,16 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
163 return 0; 181 return 0;
164 182
165 memset(&dma_params, 0, sizeof(dma_params)); 183 memset(&dma_params, 0, sizeof(dma_params));
166 dma_params.data_type = dma_data->data_type; 184
185 if (dma_data->data_type)
186 dma_params.data_type = dma_data->data_type;
187 else
188 dma_params.data_type = omap_pcm_get_dma_type(
189 snd_pcm_format_physical_width(runtime->format));
190
191 if (dma_params.data_type < 0)
192 return dma_params.data_type;
193
167 dma_params.trigger = dma_data->dma_req; 194 dma_params.trigger = dma_data->dma_req;
168 195
169 if (dma_data->packet_size) 196 if (dma_data->packet_size)
@@ -195,7 +222,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
195 * still can get an interrupt at each period bounary 222 * still can get an interrupt at each period bounary
196 */ 223 */
197 bytes = snd_pcm_lib_period_bytes(substream); 224 bytes = snd_pcm_lib_period_bytes(substream);
198 dma_params.elem_count = bytes >> dma_data->data_type; 225 dma_params.elem_count = bytes >> dma_params.data_type;
199 dma_params.frame_count = runtime->periods; 226 dma_params.frame_count = runtime->periods;
200 omap_set_dma_params(prtd->dma_ch, &dma_params); 227 omap_set_dma_params(prtd->dma_ch, &dma_params);
201 228