aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/sta32x.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/sta32x.c')
-rw-r--r--sound/soc/codecs/sta32x.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
index fbd7eb9e61ce..bb82408ab8e1 100644
--- a/sound/soc/codecs/sta32x.c
+++ b/sound/soc/codecs/sta32x.c
@@ -524,13 +524,17 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream,
524 rate = params_rate(params); 524 rate = params_rate(params);
525 pr_debug("rate: %u\n", rate); 525 pr_debug("rate: %u\n", rate);
526 for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) 526 for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++)
527 if (interpolation_ratios[i].fs == rate) 527 if (interpolation_ratios[i].fs == rate) {
528 ir = interpolation_ratios[i].ir; 528 ir = interpolation_ratios[i].ir;
529 break;
530 }
529 if (ir < 0) 531 if (ir < 0)
530 return -EINVAL; 532 return -EINVAL;
531 for (i = 0; mclk_ratios[ir][i].ratio; i++) 533 for (i = 0; mclk_ratios[ir][i].ratio; i++)
532 if (mclk_ratios[ir][i].ratio * rate == sta32x->mclk) 534 if (mclk_ratios[ir][i].ratio * rate == sta32x->mclk) {
533 mcs = mclk_ratios[ir][i].mcs; 535 mcs = mclk_ratios[ir][i].mcs;
536 break;
537 }
534 if (mcs < 0) 538 if (mcs < 0)
535 return -EINVAL; 539 return -EINVAL;
536 540
@@ -752,25 +756,19 @@ static int sta32x_probe(struct snd_soc_codec *codec)
752 return ret; 756 return ret;
753 } 757 }
754 758
755 /* read reg reset values into cache */ 759 /* Chip documentation explicitly requires that the reset values
756 for (i = 0; i < STA32X_REGISTER_COUNT; i++) 760 * of reserved register bits are left untouched.
757 snd_soc_cache_write(codec, i, sta32x_regs[i]); 761 * Write the register default value to cache for reserved registers,
758 762 * so the write to the these registers are suppressed by the cache
759 /* preserve reset values of reserved register bits */ 763 * restore code when it skips writes of default registers.
760 snd_soc_cache_write(codec, STA32X_CONFC, 764 */
761 codec->hw_read(codec, STA32X_CONFC)); 765 snd_soc_cache_write(codec, STA32X_CONFC, 0xc2);
762 snd_soc_cache_write(codec, STA32X_CONFE, 766 snd_soc_cache_write(codec, STA32X_CONFE, 0xc2);
763 codec->hw_read(codec, STA32X_CONFE)); 767 snd_soc_cache_write(codec, STA32X_CONFF, 0x5c);
764 snd_soc_cache_write(codec, STA32X_CONFF, 768 snd_soc_cache_write(codec, STA32X_MMUTE, 0x10);
765 codec->hw_read(codec, STA32X_CONFF)); 769 snd_soc_cache_write(codec, STA32X_AUTO1, 0x60);
766 snd_soc_cache_write(codec, STA32X_MMUTE, 770 snd_soc_cache_write(codec, STA32X_AUTO3, 0x00);
767 codec->hw_read(codec, STA32X_MMUTE)); 771 snd_soc_cache_write(codec, STA32X_C3CFG, 0x40);
768 snd_soc_cache_write(codec, STA32X_AUTO1,
769 codec->hw_read(codec, STA32X_AUTO1));
770 snd_soc_cache_write(codec, STA32X_AUTO3,
771 codec->hw_read(codec, STA32X_AUTO3));
772 snd_soc_cache_write(codec, STA32X_C3CFG,
773 codec->hw_read(codec, STA32X_C3CFG));
774 772
775 /* FIXME enable thermal warning adjustment and recovery */ 773 /* FIXME enable thermal warning adjustment and recovery */
776 snd_soc_update_bits(codec, STA32X_CONFA, 774 snd_soc_update_bits(codec, STA32X_CONFA,
@@ -808,6 +806,7 @@ static int sta32x_remove(struct snd_soc_codec *codec)
808{ 806{
809 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); 807 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);
810 808
809 sta32x_set_bias_level(codec, SND_SOC_BIAS_OFF);
811 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); 810 regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
812 regulator_bulk_free(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); 811 regulator_bulk_free(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
813 812
@@ -832,6 +831,7 @@ static const struct snd_soc_codec_driver sta32x_codec = {
832 .resume = sta32x_resume, 831 .resume = sta32x_resume,
833 .reg_cache_size = STA32X_REGISTER_COUNT, 832 .reg_cache_size = STA32X_REGISTER_COUNT,
834 .reg_word_size = sizeof(u8), 833 .reg_word_size = sizeof(u8),
834 .reg_cache_default = sta32x_regs,
835 .volatile_register = sta32x_reg_is_volatile, 835 .volatile_register = sta32x_reg_is_volatile,
836 .set_bias_level = sta32x_set_bias_level, 836 .set_bias_level = sta32x_set_bias_level,
837 .controls = sta32x_snd_controls, 837 .controls = sta32x_snd_controls,
@@ -867,18 +867,8 @@ static __devinit int sta32x_i2c_probe(struct i2c_client *i2c,
867static __devexit int sta32x_i2c_remove(struct i2c_client *client) 867static __devexit int sta32x_i2c_remove(struct i2c_client *client)
868{ 868{
869 struct sta32x_priv *sta32x = i2c_get_clientdata(client); 869 struct sta32x_priv *sta32x = i2c_get_clientdata(client);
870 struct snd_soc_codec *codec = sta32x->codec;
871
872 if (codec)
873 sta32x_set_bias_level(codec, SND_SOC_BIAS_OFF);
874
875 regulator_bulk_free(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
876
877 if (codec) {
878 snd_soc_unregister_codec(&client->dev);
879 snd_soc_codec_set_drvdata(codec, NULL);
880 }
881 870
871 snd_soc_unregister_codec(&client->dev);
882 kfree(sta32x); 872 kfree(sta32x);
883 return 0; 873 return 0;
884} 874}