diff options
Diffstat (limited to 'sound/soc/codecs/tlv320dac33.c')
-rw-r--r-- | sound/soc/codecs/tlv320dac33.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index 4587ddd0fbf8..0dd41077ab79 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c | |||
@@ -62,8 +62,10 @@ | |||
62 | #define UTHR_FROM_PERIOD_SIZE(samples, playrate, burstrate) \ | 62 | #define UTHR_FROM_PERIOD_SIZE(samples, playrate, burstrate) \ |
63 | (((samples)*5000) / (((burstrate)*5000) / ((burstrate) - (playrate)))) | 63 | (((samples)*5000) / (((burstrate)*5000) / ((burstrate) - (playrate)))) |
64 | 64 | ||
65 | static void dac33_calculate_times(struct snd_pcm_substream *substream); | 65 | static void dac33_calculate_times(struct snd_pcm_substream *substream, |
66 | static int dac33_prepare_chip(struct snd_pcm_substream *substream); | 66 | struct snd_soc_codec *codec); |
67 | static int dac33_prepare_chip(struct snd_pcm_substream *substream, | ||
68 | struct snd_soc_codec *codec); | ||
67 | 69 | ||
68 | enum dac33_state { | 70 | enum dac33_state { |
69 | DAC33_IDLE = 0, | 71 | DAC33_IDLE = 0, |
@@ -427,8 +429,8 @@ static int dac33_playback_event(struct snd_soc_dapm_widget *w, | |||
427 | switch (event) { | 429 | switch (event) { |
428 | case SND_SOC_DAPM_PRE_PMU: | 430 | case SND_SOC_DAPM_PRE_PMU: |
429 | if (likely(dac33->substream)) { | 431 | if (likely(dac33->substream)) { |
430 | dac33_calculate_times(dac33->substream); | 432 | dac33_calculate_times(dac33->substream, w->codec); |
431 | dac33_prepare_chip(dac33->substream); | 433 | dac33_prepare_chip(dac33->substream, w->codec); |
432 | } | 434 | } |
433 | break; | 435 | break; |
434 | case SND_SOC_DAPM_POST_PMD: | 436 | case SND_SOC_DAPM_POST_PMD: |
@@ -799,8 +801,7 @@ static void dac33_oscwait(struct snd_soc_codec *codec) | |||
799 | static int dac33_startup(struct snd_pcm_substream *substream, | 801 | static int dac33_startup(struct snd_pcm_substream *substream, |
800 | struct snd_soc_dai *dai) | 802 | struct snd_soc_dai *dai) |
801 | { | 803 | { |
802 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 804 | struct snd_soc_codec *codec = dai->codec; |
803 | struct snd_soc_codec *codec = rtd->codec; | ||
804 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | 805 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
805 | 806 | ||
806 | /* Stream started, save the substream pointer */ | 807 | /* Stream started, save the substream pointer */ |
@@ -812,8 +813,7 @@ static int dac33_startup(struct snd_pcm_substream *substream, | |||
812 | static void dac33_shutdown(struct snd_pcm_substream *substream, | 813 | static void dac33_shutdown(struct snd_pcm_substream *substream, |
813 | struct snd_soc_dai *dai) | 814 | struct snd_soc_dai *dai) |
814 | { | 815 | { |
815 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 816 | struct snd_soc_codec *codec = dai->codec; |
816 | struct snd_soc_codec *codec = rtd->codec; | ||
817 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | 817 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
818 | 818 | ||
819 | dac33->substream = NULL; | 819 | dac33->substream = NULL; |
@@ -825,8 +825,7 @@ static int dac33_hw_params(struct snd_pcm_substream *substream, | |||
825 | struct snd_pcm_hw_params *params, | 825 | struct snd_pcm_hw_params *params, |
826 | struct snd_soc_dai *dai) | 826 | struct snd_soc_dai *dai) |
827 | { | 827 | { |
828 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 828 | struct snd_soc_codec *codec = dai->codec; |
829 | struct snd_soc_codec *codec = rtd->codec; | ||
830 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | 829 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
831 | 830 | ||
832 | /* Check parameters for validity */ | 831 | /* Check parameters for validity */ |
@@ -868,10 +867,9 @@ static int dac33_hw_params(struct snd_pcm_substream *substream, | |||
868 | * writes happens in different order, than dac33 might end up in unknown state. | 867 | * writes happens in different order, than dac33 might end up in unknown state. |
869 | * Use the known, working sequence of register writes to initialize the dac33. | 868 | * Use the known, working sequence of register writes to initialize the dac33. |
870 | */ | 869 | */ |
871 | static int dac33_prepare_chip(struct snd_pcm_substream *substream) | 870 | static int dac33_prepare_chip(struct snd_pcm_substream *substream, |
871 | struct snd_soc_codec *codec) | ||
872 | { | 872 | { |
873 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
874 | struct snd_soc_codec *codec = rtd->codec; | ||
875 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | 873 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
876 | unsigned int oscset, ratioset, pwr_ctrl, reg_tmp; | 874 | unsigned int oscset, ratioset, pwr_ctrl, reg_tmp; |
877 | u8 aictrl_a, aictrl_b, fifoctrl_a; | 875 | u8 aictrl_a, aictrl_b, fifoctrl_a; |
@@ -1067,10 +1065,9 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream) | |||
1067 | return 0; | 1065 | return 0; |
1068 | } | 1066 | } |
1069 | 1067 | ||
1070 | static void dac33_calculate_times(struct snd_pcm_substream *substream) | 1068 | static void dac33_calculate_times(struct snd_pcm_substream *substream, |
1069 | struct snd_soc_codec *codec) | ||
1071 | { | 1070 | { |
1072 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
1073 | struct snd_soc_codec *codec = rtd->codec; | ||
1074 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | 1071 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
1075 | unsigned int period_size = substream->runtime->period_size; | 1072 | unsigned int period_size = substream->runtime->period_size; |
1076 | unsigned int rate = substream->runtime->rate; | 1073 | unsigned int rate = substream->runtime->rate; |
@@ -1128,8 +1125,7 @@ static void dac33_calculate_times(struct snd_pcm_substream *substream) | |||
1128 | static int dac33_pcm_trigger(struct snd_pcm_substream *substream, int cmd, | 1125 | static int dac33_pcm_trigger(struct snd_pcm_substream *substream, int cmd, |
1129 | struct snd_soc_dai *dai) | 1126 | struct snd_soc_dai *dai) |
1130 | { | 1127 | { |
1131 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1128 | struct snd_soc_codec *codec = dai->codec; |
1132 | struct snd_soc_codec *codec = rtd->codec; | ||
1133 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | 1129 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
1134 | int ret = 0; | 1130 | int ret = 0; |
1135 | 1131 | ||
@@ -1161,8 +1157,7 @@ static snd_pcm_sframes_t dac33_dai_delay( | |||
1161 | struct snd_pcm_substream *substream, | 1157 | struct snd_pcm_substream *substream, |
1162 | struct snd_soc_dai *dai) | 1158 | struct snd_soc_dai *dai) |
1163 | { | 1159 | { |
1164 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1160 | struct snd_soc_codec *codec = dai->codec; |
1165 | struct snd_soc_codec *codec = rtd->codec; | ||
1166 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | 1161 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
1167 | unsigned long long t0, t1, t_now; | 1162 | unsigned long long t0, t1, t_now; |
1168 | unsigned int time_delta, uthr; | 1163 | unsigned int time_delta, uthr; |