aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/uda1380.c
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2009-02-03 11:19:40 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-02-04 08:15:15 -0500
commit5b2474425ed2a625b75dcd8d648701e473b7d764 (patch)
treedd78facc779ef568bbc77d840ca573f6f1f01519 /sound/soc/codecs/uda1380.c
parent111f6fbeb73fc350fe3a08c4ecd0ccdf3e13bef0 (diff)
ASoC: uda1380: split set_dai_fmt into _both, _playback and _capture variants
This patch splits set_dai_fmt into three variants (single interface, dual interface playback only, dual interface capture only) so that data input and output formats can be configured separately for dual interface setups. Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> Tested-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/uda1380.c')
-rw-r--r--sound/soc/codecs/uda1380.c68
1 files changed, 61 insertions, 7 deletions
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index 6e4a1770ce8d..5242b8156b38 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -356,7 +356,7 @@ static int uda1380_add_widgets(struct snd_soc_codec *codec)
356 return 0; 356 return 0;
357} 357}
358 358
359static int uda1380_set_dai_fmt(struct snd_soc_dai *codec_dai, 359static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai,
360 unsigned int fmt) 360 unsigned int fmt)
361{ 361{
362 struct snd_soc_codec *codec = codec_dai->codec; 362 struct snd_soc_codec *codec = codec_dai->codec;
@@ -366,16 +366,70 @@ static int uda1380_set_dai_fmt(struct snd_soc_dai *codec_dai,
366 iface = uda1380_read_reg_cache(codec, UDA1380_IFACE); 366 iface = uda1380_read_reg_cache(codec, UDA1380_IFACE);
367 iface &= ~(R01_SFORI_MASK | R01_SIM | R01_SFORO_MASK); 367 iface &= ~(R01_SFORI_MASK | R01_SIM | R01_SFORO_MASK);
368 368
369 /* FIXME: how to select I2S for DATAO and MSB for DATAI correctly? */
370 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 369 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
371 case SND_SOC_DAIFMT_I2S: 370 case SND_SOC_DAIFMT_I2S:
372 iface |= R01_SFORI_I2S | R01_SFORO_I2S; 371 iface |= R01_SFORI_I2S | R01_SFORO_I2S;
373 break; 372 break;
374 case SND_SOC_DAIFMT_LSB: 373 case SND_SOC_DAIFMT_LSB:
375 iface |= R01_SFORI_LSB16 | R01_SFORO_I2S; 374 iface |= R01_SFORI_LSB16 | R01_SFORO_LSB16;
376 break; 375 break;
377 case SND_SOC_DAIFMT_MSB: 376 case SND_SOC_DAIFMT_MSB:
378 iface |= R01_SFORI_MSB | R01_SFORO_I2S; 377 iface |= R01_SFORI_MSB | R01_SFORO_MSB;
378 }
379
380 if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
381 iface |= R01_SIM;
382
383 uda1380_write(codec, UDA1380_IFACE, iface);
384
385 return 0;
386}
387
388static int uda1380_set_dai_fmt_playback(struct snd_soc_dai *codec_dai,
389 unsigned int fmt)
390{
391 struct snd_soc_codec *codec = codec_dai->codec;
392 int iface;
393
394 /* set up DAI based upon fmt */
395 iface = uda1380_read_reg_cache(codec, UDA1380_IFACE);
396 iface &= ~R01_SFORI_MASK;
397
398 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
399 case SND_SOC_DAIFMT_I2S:
400 iface |= R01_SFORI_I2S;
401 break;
402 case SND_SOC_DAIFMT_LSB:
403 iface |= R01_SFORI_LSB16;
404 break;
405 case SND_SOC_DAIFMT_MSB:
406 iface |= R01_SFORI_MSB;
407 }
408
409 uda1380_write(codec, UDA1380_IFACE, iface);
410
411 return 0;
412}
413
414static int uda1380_set_dai_fmt_capture(struct snd_soc_dai *codec_dai,
415 unsigned int fmt)
416{
417 struct snd_soc_codec *codec = codec_dai->codec;
418 int iface;
419
420 /* set up DAI based upon fmt */
421 iface = uda1380_read_reg_cache(codec, UDA1380_IFACE);
422 iface &= ~(R01_SIM | R01_SFORO_MASK);
423
424 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
425 case SND_SOC_DAIFMT_I2S:
426 iface |= R01_SFORO_I2S;
427 break;
428 case SND_SOC_DAIFMT_LSB:
429 iface |= R01_SFORO_LSB16;
430 break;
431 case SND_SOC_DAIFMT_MSB:
432 iface |= R01_SFORO_MSB;
379 } 433 }
380 434
381 if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM) 435 if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
@@ -549,7 +603,7 @@ struct snd_soc_dai uda1380_dai[] = {
549 .shutdown = uda1380_pcm_shutdown, 603 .shutdown = uda1380_pcm_shutdown,
550 .prepare = uda1380_pcm_prepare, 604 .prepare = uda1380_pcm_prepare,
551 .digital_mute = uda1380_mute, 605 .digital_mute = uda1380_mute,
552 .set_fmt = uda1380_set_dai_fmt, 606 .set_fmt = uda1380_set_dai_fmt_both,
553 }, 607 },
554}, 608},
555{ /* playback only - dual interface */ 609{ /* playback only - dual interface */
@@ -566,7 +620,7 @@ struct snd_soc_dai uda1380_dai[] = {
566 .shutdown = uda1380_pcm_shutdown, 620 .shutdown = uda1380_pcm_shutdown,
567 .prepare = uda1380_pcm_prepare, 621 .prepare = uda1380_pcm_prepare,
568 .digital_mute = uda1380_mute, 622 .digital_mute = uda1380_mute,
569 .set_fmt = uda1380_set_dai_fmt, 623 .set_fmt = uda1380_set_dai_fmt_playback,
570 }, 624 },
571}, 625},
572{ /* capture only - dual interface*/ 626{ /* capture only - dual interface*/
@@ -582,7 +636,7 @@ struct snd_soc_dai uda1380_dai[] = {
582 .hw_params = uda1380_pcm_hw_params, 636 .hw_params = uda1380_pcm_hw_params,
583 .shutdown = uda1380_pcm_shutdown, 637 .shutdown = uda1380_pcm_shutdown,
584 .prepare = uda1380_pcm_prepare, 638 .prepare = uda1380_pcm_prepare,
585 .set_fmt = uda1380_set_dai_fmt, 639 .set_fmt = uda1380_set_dai_fmt_capture,
586 }, 640 },
587}, 641},
588}; 642};