diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2009-12-31 03:30:19 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-12-31 06:54:26 -0500 |
commit | 7427b4b9a63fd7e051d642ff0f12ef8337c08bb3 (patch) | |
tree | 873988c18d0b19ad2b6cc1c983d2d31177994ff3 /sound/soc/codecs/tlv320dac33.c | |
parent | 8998c89907f84f7e25536c1c670a134c831e682f (diff) |
ASoC: tlv320dac33: Change nsample switch to FIFO mode enum
In order to have support for more FIFO modes supported by
tlv320dac33, the switch for enabling/disabling the FIFO
use has to be replaced with an enum.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/tlv320dac33.c')
-rw-r--r-- | sound/soc/codecs/tlv320dac33.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index 5037454974b6..b67961dd2a12 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c | |||
@@ -59,6 +59,12 @@ enum dac33_state { | |||
59 | DAC33_FLUSH, | 59 | DAC33_FLUSH, |
60 | }; | 60 | }; |
61 | 61 | ||
62 | enum dac33_fifo_modes { | ||
63 | DAC33_FIFO_BYPASS = 0, | ||
64 | DAC33_FIFO_MODE1, | ||
65 | DAC33_FIFO_LAST_MODE, | ||
66 | }; | ||
67 | |||
62 | #define DAC33_NUM_SUPPLIES 3 | 68 | #define DAC33_NUM_SUPPLIES 3 |
63 | static const char *dac33_supply_names[DAC33_NUM_SUPPLIES] = { | 69 | static const char *dac33_supply_names[DAC33_NUM_SUPPLIES] = { |
64 | "AVDD", | 70 | "AVDD", |
@@ -82,7 +88,7 @@ struct tlv320dac33_priv { | |||
82 | * this */ | 88 | * this */ |
83 | unsigned int nsample_max; /* nsample should not be higher than | 89 | unsigned int nsample_max; /* nsample should not be higher than |
84 | * this */ | 90 | * this */ |
85 | unsigned int nsample_switch; /* Use FIFO or bypass FIFO switch */ | 91 | enum dac33_fifo_modes fifo_mode;/* FIFO mode selection */ |
86 | unsigned int nsample; /* burst read amount from host */ | 92 | unsigned int nsample; /* burst read amount from host */ |
87 | 93 | ||
88 | enum dac33_state state; | 94 | enum dac33_state state; |
@@ -381,39 +387,48 @@ static int dac33_set_nsample(struct snd_kcontrol *kcontrol, | |||
381 | return ret; | 387 | return ret; |
382 | } | 388 | } |
383 | 389 | ||
384 | static int dac33_get_nsample_switch(struct snd_kcontrol *kcontrol, | 390 | static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol, |
385 | struct snd_ctl_elem_value *ucontrol) | 391 | struct snd_ctl_elem_value *ucontrol) |
386 | { | 392 | { |
387 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 393 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
388 | struct tlv320dac33_priv *dac33 = codec->private_data; | 394 | struct tlv320dac33_priv *dac33 = codec->private_data; |
389 | 395 | ||
390 | ucontrol->value.integer.value[0] = dac33->nsample_switch; | 396 | ucontrol->value.integer.value[0] = dac33->fifo_mode; |
391 | 397 | ||
392 | return 0; | 398 | return 0; |
393 | } | 399 | } |
394 | 400 | ||
395 | static int dac33_set_nsample_switch(struct snd_kcontrol *kcontrol, | 401 | static int dac33_set_fifo_mode(struct snd_kcontrol *kcontrol, |
396 | struct snd_ctl_elem_value *ucontrol) | 402 | struct snd_ctl_elem_value *ucontrol) |
397 | { | 403 | { |
398 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 404 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
399 | struct tlv320dac33_priv *dac33 = codec->private_data; | 405 | struct tlv320dac33_priv *dac33 = codec->private_data; |
400 | int ret = 0; | 406 | int ret = 0; |
401 | 407 | ||
402 | if (dac33->nsample_switch == ucontrol->value.integer.value[0]) | 408 | if (dac33->fifo_mode == ucontrol->value.integer.value[0]) |
403 | return 0; | 409 | return 0; |
404 | /* Do not allow changes while stream is running*/ | 410 | /* Do not allow changes while stream is running*/ |
405 | if (codec->active) | 411 | if (codec->active) |
406 | return -EPERM; | 412 | return -EPERM; |
407 | 413 | ||
408 | if (ucontrol->value.integer.value[0] < 0 || | 414 | if (ucontrol->value.integer.value[0] < 0 || |
409 | ucontrol->value.integer.value[0] > 1) | 415 | ucontrol->value.integer.value[0] >= DAC33_FIFO_LAST_MODE) |
410 | ret = -EINVAL; | 416 | ret = -EINVAL; |
411 | else | 417 | else |
412 | dac33->nsample_switch = ucontrol->value.integer.value[0]; | 418 | dac33->fifo_mode = ucontrol->value.integer.value[0]; |
413 | 419 | ||
414 | return ret; | 420 | return ret; |
415 | } | 421 | } |
416 | 422 | ||
423 | /* Codec operation modes */ | ||
424 | static const char *dac33_fifo_mode_texts[] = { | ||
425 | "Bypass", "Mode 1" | ||
426 | }; | ||
427 | |||
428 | static const struct soc_enum dac33_fifo_mode_enum = | ||
429 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(dac33_fifo_mode_texts), | ||
430 | dac33_fifo_mode_texts); | ||
431 | |||
417 | /* | 432 | /* |
418 | * DACL/R digital volume control: | 433 | * DACL/R digital volume control: |
419 | * from 0 dB to -63.5 in 0.5 dB steps | 434 | * from 0 dB to -63.5 in 0.5 dB steps |
@@ -436,8 +451,8 @@ static const struct snd_kcontrol_new dac33_snd_controls[] = { | |||
436 | static const struct snd_kcontrol_new dac33_nsample_snd_controls[] = { | 451 | static const struct snd_kcontrol_new dac33_nsample_snd_controls[] = { |
437 | SOC_SINGLE_EXT("nSample", 0, 0, 5900, 0, | 452 | SOC_SINGLE_EXT("nSample", 0, 0, 5900, 0, |
438 | dac33_get_nsample, dac33_set_nsample), | 453 | dac33_get_nsample, dac33_set_nsample), |
439 | SOC_SINGLE_EXT("nSample Switch", 0, 0, 1, 0, | 454 | SOC_ENUM_EXT("FIFO Mode", dac33_fifo_mode_enum, |
440 | dac33_get_nsample_switch, dac33_set_nsample_switch), | 455 | dac33_get_fifo_mode, dac33_set_fifo_mode), |
441 | }; | 456 | }; |
442 | 457 | ||
443 | /* Analog bypass */ | 458 | /* Analog bypass */ |
@@ -586,7 +601,7 @@ static void dac33_shutdown(struct snd_pcm_substream *substream, | |||
586 | unsigned int pwr_ctrl; | 601 | unsigned int pwr_ctrl; |
587 | 602 | ||
588 | /* Stop pending workqueue */ | 603 | /* Stop pending workqueue */ |
589 | if (dac33->nsample_switch) | 604 | if (dac33->fifo_mode) |
590 | cancel_work_sync(&dac33->work); | 605 | cancel_work_sync(&dac33->work); |
591 | 606 | ||
592 | mutex_lock(&dac33->mutex); | 607 | mutex_lock(&dac33->mutex); |
@@ -714,7 +729,7 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream) | |||
714 | 729 | ||
715 | dac33_oscwait(codec); | 730 | dac33_oscwait(codec); |
716 | 731 | ||
717 | if (dac33->nsample_switch) { | 732 | if (dac33->fifo_mode) { |
718 | /* 50-51 : ASRC Control registers */ | 733 | /* 50-51 : ASRC Control registers */ |
719 | dac33_write(codec, DAC33_ASRC_CTRL_A, (1 << 4)); /* div=2 */ | 734 | dac33_write(codec, DAC33_ASRC_CTRL_A, (1 << 4)); /* div=2 */ |
720 | dac33_write(codec, DAC33_ASRC_CTRL_B, 1); /* ??? */ | 735 | dac33_write(codec, DAC33_ASRC_CTRL_B, 1); /* ??? */ |
@@ -734,7 +749,7 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream) | |||
734 | dac33_write(codec, DAC33_ASRC_CTRL_B, 0); /* ??? */ | 749 | dac33_write(codec, DAC33_ASRC_CTRL_B, 0); /* ??? */ |
735 | } | 750 | } |
736 | 751 | ||
737 | if (dac33->nsample_switch) | 752 | if (dac33->fifo_mode) |
738 | fifoctrl_a &= ~DAC33_FBYPAS; | 753 | fifoctrl_a &= ~DAC33_FBYPAS; |
739 | else | 754 | else |
740 | fifoctrl_a |= DAC33_FBYPAS; | 755 | fifoctrl_a |= DAC33_FBYPAS; |
@@ -742,13 +757,13 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream) | |||
742 | 757 | ||
743 | dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_A, aictrl_a); | 758 | dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_A, aictrl_a); |
744 | reg_tmp = dac33_read_reg_cache(codec, DAC33_SER_AUDIOIF_CTRL_B); | 759 | reg_tmp = dac33_read_reg_cache(codec, DAC33_SER_AUDIOIF_CTRL_B); |
745 | if (dac33->nsample_switch) | 760 | if (dac33->fifo_mode) |
746 | reg_tmp &= ~DAC33_BCLKON; | 761 | reg_tmp &= ~DAC33_BCLKON; |
747 | else | 762 | else |
748 | reg_tmp |= DAC33_BCLKON; | 763 | reg_tmp |= DAC33_BCLKON; |
749 | dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_B, reg_tmp); | 764 | dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_B, reg_tmp); |
750 | 765 | ||
751 | if (dac33->nsample_switch) { | 766 | if (dac33->fifo_mode) { |
752 | /* 20: BCLK divide ratio */ | 767 | /* 20: BCLK divide ratio */ |
753 | dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C, 3); | 768 | dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C, 3); |
754 | 769 | ||
@@ -828,7 +843,7 @@ static int dac33_pcm_trigger(struct snd_pcm_substream *substream, int cmd, | |||
828 | case SNDRV_PCM_TRIGGER_START: | 843 | case SNDRV_PCM_TRIGGER_START: |
829 | case SNDRV_PCM_TRIGGER_RESUME: | 844 | case SNDRV_PCM_TRIGGER_RESUME: |
830 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 845 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
831 | if (dac33->nsample_switch) { | 846 | if (dac33->fifo_mode) { |
832 | dac33->state = DAC33_PREFILL; | 847 | dac33->state = DAC33_PREFILL; |
833 | queue_work(dac33->dac33_wq, &dac33->work); | 848 | queue_work(dac33->dac33_wq, &dac33->work); |
834 | } | 849 | } |
@@ -836,7 +851,7 @@ static int dac33_pcm_trigger(struct snd_pcm_substream *substream, int cmd, | |||
836 | case SNDRV_PCM_TRIGGER_STOP: | 851 | case SNDRV_PCM_TRIGGER_STOP: |
837 | case SNDRV_PCM_TRIGGER_SUSPEND: | 852 | case SNDRV_PCM_TRIGGER_SUSPEND: |
838 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 853 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
839 | if (dac33->nsample_switch) { | 854 | if (dac33->fifo_mode) { |
840 | dac33->state = DAC33_FLUSH; | 855 | dac33->state = DAC33_FLUSH; |
841 | queue_work(dac33->dac33_wq, &dac33->work); | 856 | queue_work(dac33->dac33_wq, &dac33->work); |
842 | } | 857 | } |
@@ -1125,7 +1140,7 @@ static int dac33_i2c_probe(struct i2c_client *client, | |||
1125 | dac33->irq = client->irq; | 1140 | dac33->irq = client->irq; |
1126 | dac33->nsample = NSAMPLE_MAX; | 1141 | dac33->nsample = NSAMPLE_MAX; |
1127 | /* Disable FIFO use by default */ | 1142 | /* Disable FIFO use by default */ |
1128 | dac33->nsample_switch = 0; | 1143 | dac33->fifo_mode = DAC33_FIFO_BYPASS; |
1129 | 1144 | ||
1130 | tlv320dac33_codec = codec; | 1145 | tlv320dac33_codec = codec; |
1131 | 1146 | ||