aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2012-02-14 08:23:15 -0500
committerLiam Girdwood <lrg@ti.com>2012-03-12 09:34:22 -0400
commit256d9c251fe6800a494206b96d2572e5a98762d5 (patch)
tree1bca28ebdb698c636734f1fee8ff14ca60cc874c /sound
parent2ee6595069f29b918b957a013debfae83e68724d (diff)
ASoC: omap-mcbsp: Merge the omap_mcbsp_data into omap_mcbsp structure
Since the drivers has been merged, merge the two structures together. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Grazvydas Ignotas <notasas@gmail.com> Tested-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com> Signed-off-by: Liam Girdwood <lrg@ti.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/omap/mcbsp.h33
-rw-r--r--sound/soc/omap/omap-mcbsp.c53
2 files changed, 38 insertions, 48 deletions
diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h
index ac90c1a4a489..d250bcc952d2 100644
--- a/sound/soc/omap/mcbsp.h
+++ b/sound/soc/omap/mcbsp.h
@@ -269,27 +269,20 @@ struct omap_mcbsp_st_data {
269 s16 ch1gain; 269 s16 ch1gain;
270}; 270};
271 271
272struct omap_mcbsp_data {
273 struct omap_mcbsp_reg_cfg regs;
274 struct omap_pcm_dma_data dma_data[2];
275 unsigned int fmt;
276 /*
277 * Flags indicating is the bus already activated and configured by
278 * another substream
279 */
280 int active;
281 int configured;
282 unsigned int in_freq;
283 int clk_div;
284 int wlen;
285};
286
287struct omap_mcbsp { 272struct omap_mcbsp {
288 struct device *dev; 273 struct device *dev;
274 struct clk *fclk;
275 spinlock_t lock;
289 unsigned long phys_base; 276 unsigned long phys_base;
290 unsigned long phys_dma_base; 277 unsigned long phys_dma_base;
291 void __iomem *io_base; 278 void __iomem *io_base;
292 u8 id; 279 u8 id;
280 /*
281 * Flags indicating is the bus already activated and configured by
282 * another substream
283 */
284 int active;
285 int configured;
293 u8 free; 286 u8 free;
294 287
295 int rx_irq; 288 int rx_irq;
@@ -300,16 +293,20 @@ struct omap_mcbsp {
300 u8 dma_tx_sync; 293 u8 dma_tx_sync;
301 294
302 /* Protect the field .free, while checking if the mcbsp is in use */ 295 /* Protect the field .free, while checking if the mcbsp is in use */
303 spinlock_t lock;
304 struct omap_mcbsp_platform_data *pdata; 296 struct omap_mcbsp_platform_data *pdata;
305 struct clk *fclk;
306 struct omap_mcbsp_st_data *st_data; 297 struct omap_mcbsp_st_data *st_data;
307 struct omap_mcbsp_data mcbsp_data; 298 struct omap_mcbsp_reg_cfg cfg_regs;
299 struct omap_pcm_dma_data dma_data[2];
308 int dma_op_mode; 300 int dma_op_mode;
309 u16 max_tx_thres; 301 u16 max_tx_thres;
310 u16 max_rx_thres; 302 u16 max_rx_thres;
311 void *reg_cache; 303 void *reg_cache;
312 int reg_cache_size; 304 int reg_cache_size;
305
306 unsigned int fmt;
307 unsigned int in_freq;
308 int clk_div;
309 int wlen;
313}; 310};
314 311
315void omap_mcbsp_config(struct omap_mcbsp *mcbsp, 312void omap_mcbsp_config(struct omap_mcbsp *mcbsp,
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 69a44aa4eeae..4cd7af883de9 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -66,7 +66,6 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
66 struct snd_soc_pcm_runtime *rtd = substream->private_data; 66 struct snd_soc_pcm_runtime *rtd = substream->private_data;
67 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 67 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
68 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); 68 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
69 struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data;
70 struct omap_pcm_dma_data *dma_data; 69 struct omap_pcm_dma_data *dma_data;
71 int words; 70 int words;
72 71
@@ -83,7 +82,7 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
83 words = dma_data->packet_size; 82 words = dma_data->packet_size;
84 else 83 else
85 words = snd_pcm_lib_period_bytes(substream) / 84 words = snd_pcm_lib_period_bytes(substream) /
86 (mcbsp_data->wlen / 8); 85 (mcbsp->wlen / 8);
87 else 86 else
88 words = 1; 87 words = 1;
89 88
@@ -160,11 +159,10 @@ static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream,
160 struct snd_soc_dai *cpu_dai) 159 struct snd_soc_dai *cpu_dai)
161{ 160{
162 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); 161 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
163 struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data;
164 162
165 if (!cpu_dai->active) { 163 if (!cpu_dai->active) {
166 omap_mcbsp_free(mcbsp); 164 omap_mcbsp_free(mcbsp);
167 mcbsp_data->configured = 0; 165 mcbsp->configured = 0;
168 } 166 }
169} 167}
170 168
@@ -172,14 +170,13 @@ static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd,
172 struct snd_soc_dai *cpu_dai) 170 struct snd_soc_dai *cpu_dai)
173{ 171{
174 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); 172 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
175 struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data;
176 int err = 0, play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); 173 int err = 0, play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
177 174
178 switch (cmd) { 175 switch (cmd) {
179 case SNDRV_PCM_TRIGGER_START: 176 case SNDRV_PCM_TRIGGER_START:
180 case SNDRV_PCM_TRIGGER_RESUME: 177 case SNDRV_PCM_TRIGGER_RESUME:
181 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 178 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
182 mcbsp_data->active++; 179 mcbsp->active++;
183 omap_mcbsp_start(mcbsp, play, !play); 180 omap_mcbsp_start(mcbsp, play, !play);
184 break; 181 break;
185 182
@@ -187,7 +184,7 @@ static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd,
187 case SNDRV_PCM_TRIGGER_SUSPEND: 184 case SNDRV_PCM_TRIGGER_SUSPEND:
188 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 185 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
189 omap_mcbsp_stop(mcbsp, play, !play); 186 omap_mcbsp_stop(mcbsp, play, !play);
190 mcbsp_data->active--; 187 mcbsp->active--;
191 break; 188 break;
192 default: 189 default:
193 err = -EINVAL; 190 err = -EINVAL;
@@ -226,8 +223,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
226 struct snd_soc_dai *cpu_dai) 223 struct snd_soc_dai *cpu_dai)
227{ 224{
228 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); 225 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
229 struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; 226 struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs;
230 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
231 struct omap_pcm_dma_data *dma_data; 227 struct omap_pcm_dma_data *dma_data;
232 int dma; 228 int dma;
233 int wlen, channels, wpf, sync_mode = OMAP_DMA_SYNC_ELEMENT; 229 int wlen, channels, wpf, sync_mode = OMAP_DMA_SYNC_ELEMENT;
@@ -235,7 +231,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
235 unsigned long port; 231 unsigned long port;
236 unsigned int format, div, framesize, master; 232 unsigned int format, div, framesize, master;
237 233
238 dma_data = &mcbsp_data->dma_data[substream->stream]; 234 dma_data = &mcbsp->dma_data[substream->stream];
239 235
240 dma = omap_mcbsp_dma_ch_params(mcbsp, substream->stream); 236 dma = omap_mcbsp_dma_ch_params(mcbsp, substream->stream);
241 port = omap_mcbsp_dma_reg_params(mcbsp, substream->stream); 237 port = omap_mcbsp_dma_reg_params(mcbsp, substream->stream);
@@ -303,7 +299,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
303 299
304 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data); 300 snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
305 301
306 if (mcbsp_data->configured) { 302 if (mcbsp->configured) {
307 /* McBSP already configured by another stream */ 303 /* McBSP already configured by another stream */
308 return 0; 304 return 0;
309 } 305 }
@@ -312,7 +308,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
312 regs->xcr2 &= ~(RPHASE | XFRLEN2(0x7f) | XWDLEN2(7)); 308 regs->xcr2 &= ~(RPHASE | XFRLEN2(0x7f) | XWDLEN2(7));
313 regs->rcr1 &= ~(RFRLEN1(0x7f) | RWDLEN1(7)); 309 regs->rcr1 &= ~(RFRLEN1(0x7f) | RWDLEN1(7));
314 regs->xcr1 &= ~(XFRLEN1(0x7f) | XWDLEN1(7)); 310 regs->xcr1 &= ~(XFRLEN1(0x7f) | XWDLEN1(7));
315 format = mcbsp_data->fmt & SND_SOC_DAIFMT_FORMAT_MASK; 311 format = mcbsp->fmt & SND_SOC_DAIFMT_FORMAT_MASK;
316 wpf = channels = params_channels(params); 312 wpf = channels = params_channels(params);
317 if (channels == 2 && (format == SND_SOC_DAIFMT_I2S || 313 if (channels == 2 && (format == SND_SOC_DAIFMT_I2S ||
318 format == SND_SOC_DAIFMT_LEFT_J)) { 314 format == SND_SOC_DAIFMT_LEFT_J)) {
@@ -350,10 +346,10 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
350 346
351 /* In McBSP master modes, FRAME (i.e. sample rate) is generated 347 /* In McBSP master modes, FRAME (i.e. sample rate) is generated
352 * by _counting_ BCLKs. Calculate frame size in BCLKs */ 348 * by _counting_ BCLKs. Calculate frame size in BCLKs */
353 master = mcbsp_data->fmt & SND_SOC_DAIFMT_MASTER_MASK; 349 master = mcbsp->fmt & SND_SOC_DAIFMT_MASTER_MASK;
354 if (master == SND_SOC_DAIFMT_CBS_CFS) { 350 if (master == SND_SOC_DAIFMT_CBS_CFS) {
355 div = mcbsp_data->clk_div ? mcbsp_data->clk_div : 1; 351 div = mcbsp->clk_div ? mcbsp->clk_div : 1;
356 framesize = (mcbsp_data->in_freq / div) / params_rate(params); 352 framesize = (mcbsp->in_freq / div) / params_rate(params);
357 353
358 if (framesize < wlen * channels) { 354 if (framesize < wlen * channels) {
359 printk(KERN_ERR "%s: not enough bandwidth for desired rate and " 355 printk(KERN_ERR "%s: not enough bandwidth for desired rate and "
@@ -379,9 +375,9 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
379 break; 375 break;
380 } 376 }
381 377
382 omap_mcbsp_config(mcbsp, &mcbsp_data->regs); 378 omap_mcbsp_config(mcbsp, &mcbsp->cfg_regs);
383 mcbsp_data->wlen = wlen; 379 mcbsp->wlen = wlen;
384 mcbsp_data->configured = 1; 380 mcbsp->configured = 1;
385 381
386 return 0; 382 return 0;
387} 383}
@@ -394,14 +390,13 @@ static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_dai *cpu_dai,
394 unsigned int fmt) 390 unsigned int fmt)
395{ 391{
396 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); 392 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
397 struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; 393 struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs;
398 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
399 bool inv_fs = false; 394 bool inv_fs = false;
400 395
401 if (mcbsp_data->configured) 396 if (mcbsp->configured)
402 return 0; 397 return 0;
403 398
404 mcbsp_data->fmt = fmt; 399 mcbsp->fmt = fmt;
405 memset(regs, 0, sizeof(*regs)); 400 memset(regs, 0, sizeof(*regs));
406 /* Generic McBSP register settings */ 401 /* Generic McBSP register settings */
407 regs->spcr2 |= XINTM(3) | FREE; 402 regs->spcr2 |= XINTM(3) | FREE;
@@ -497,13 +492,12 @@ static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_dai *cpu_dai,
497 int div_id, int div) 492 int div_id, int div)
498{ 493{
499 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); 494 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
500 struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; 495 struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs;
501 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
502 496
503 if (div_id != OMAP_MCBSP_CLKGDV) 497 if (div_id != OMAP_MCBSP_CLKGDV)
504 return -ENODEV; 498 return -ENODEV;
505 499
506 mcbsp_data->clk_div = div; 500 mcbsp->clk_div = div;
507 regs->srgr1 &= ~CLKGDV(0xff); 501 regs->srgr1 &= ~CLKGDV(0xff);
508 regs->srgr1 |= CLKGDV(div - 1); 502 regs->srgr1 |= CLKGDV(div - 1);
509 503
@@ -515,12 +509,11 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
515 int dir) 509 int dir)
516{ 510{
517 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); 511 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
518 struct omap_mcbsp_data *mcbsp_data = &mcbsp->mcbsp_data; 512 struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs;
519 struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
520 int err = 0; 513 int err = 0;
521 514
522 if (mcbsp_data->active) { 515 if (mcbsp->active) {
523 if (freq == mcbsp_data->in_freq) 516 if (freq == mcbsp->in_freq)
524 return 0; 517 return 0;
525 else 518 else
526 return -EBUSY; 519 return -EBUSY;
@@ -534,7 +527,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
534 if (cpu_class_is_omap1() || cpu_dai->id != 1) 527 if (cpu_class_is_omap1() || cpu_dai->id != 1)
535 return -EINVAL; 528 return -EINVAL;
536 529
537 mcbsp_data->in_freq = freq; 530 mcbsp->in_freq = freq;
538 regs->srgr2 &= ~CLKSM; 531 regs->srgr2 &= ~CLKSM;
539 regs->pcr0 &= ~SCLKME; 532 regs->pcr0 &= ~SCLKME;
540 533