diff options
-rw-r--r-- | sound/soc/codecs/tas5086.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index 199272d5cb6a..5efc4b7145d4 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c | |||
@@ -261,9 +261,9 @@ struct tas5086_private { | |||
261 | 261 | ||
262 | static int tas5086_deemph[] = { 0, 32000, 44100, 48000 }; | 262 | static int tas5086_deemph[] = { 0, 32000, 44100, 48000 }; |
263 | 263 | ||
264 | static int tas5086_set_deemph(struct snd_soc_codec *codec) | 264 | static int tas5086_set_deemph(struct snd_soc_component *component) |
265 | { | 265 | { |
266 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 266 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
267 | int i, val = 0; | 267 | int i, val = 0; |
268 | 268 | ||
269 | if (priv->deemph) { | 269 | if (priv->deemph) { |
@@ -282,8 +282,8 @@ static int tas5086_set_deemph(struct snd_soc_codec *codec) | |||
282 | static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, | 282 | static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, |
283 | struct snd_ctl_elem_value *ucontrol) | 283 | struct snd_ctl_elem_value *ucontrol) |
284 | { | 284 | { |
285 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 285 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
286 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 286 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
287 | 287 | ||
288 | ucontrol->value.integer.value[0] = priv->deemph; | 288 | ucontrol->value.integer.value[0] = priv->deemph; |
289 | 289 | ||
@@ -293,20 +293,20 @@ static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, | |||
293 | static int tas5086_put_deemph(struct snd_kcontrol *kcontrol, | 293 | static int tas5086_put_deemph(struct snd_kcontrol *kcontrol, |
294 | struct snd_ctl_elem_value *ucontrol) | 294 | struct snd_ctl_elem_value *ucontrol) |
295 | { | 295 | { |
296 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 296 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
297 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 297 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
298 | 298 | ||
299 | priv->deemph = ucontrol->value.integer.value[0]; | 299 | priv->deemph = ucontrol->value.integer.value[0]; |
300 | 300 | ||
301 | return tas5086_set_deemph(codec); | 301 | return tas5086_set_deemph(component); |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | static int tas5086_set_dai_sysclk(struct snd_soc_dai *codec_dai, | 305 | static int tas5086_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
306 | int clk_id, unsigned int freq, int dir) | 306 | int clk_id, unsigned int freq, int dir) |
307 | { | 307 | { |
308 | struct snd_soc_codec *codec = codec_dai->codec; | 308 | struct snd_soc_component *component = codec_dai->component; |
309 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 309 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
310 | 310 | ||
311 | switch (clk_id) { | 311 | switch (clk_id) { |
312 | case TAS5086_CLK_IDX_MCLK: | 312 | case TAS5086_CLK_IDX_MCLK: |
@@ -323,12 +323,12 @@ static int tas5086_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
323 | static int tas5086_set_dai_fmt(struct snd_soc_dai *codec_dai, | 323 | static int tas5086_set_dai_fmt(struct snd_soc_dai *codec_dai, |
324 | unsigned int format) | 324 | unsigned int format) |
325 | { | 325 | { |
326 | struct snd_soc_codec *codec = codec_dai->codec; | 326 | struct snd_soc_component *component = codec_dai->component; |
327 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 327 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
328 | 328 | ||
329 | /* The TAS5086 can only be slave to all clocks */ | 329 | /* The TAS5086 can only be slave to all clocks */ |
330 | if ((format & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) { | 330 | if ((format & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) { |
331 | dev_err(codec->dev, "Invalid clocking mode\n"); | 331 | dev_err(component->dev, "Invalid clocking mode\n"); |
332 | return -EINVAL; | 332 | return -EINVAL; |
333 | } | 333 | } |
334 | 334 | ||
@@ -361,8 +361,8 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, | |||
361 | struct snd_pcm_hw_params *params, | 361 | struct snd_pcm_hw_params *params, |
362 | struct snd_soc_dai *dai) | 362 | struct snd_soc_dai *dai) |
363 | { | 363 | { |
364 | struct snd_soc_codec *codec = dai->codec; | 364 | struct snd_soc_component *component = dai->component; |
365 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 365 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
366 | int val; | 366 | int val; |
367 | int ret; | 367 | int ret; |
368 | 368 | ||
@@ -373,7 +373,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, | |||
373 | ARRAY_SIZE(tas5086_sample_rates), priv->rate); | 373 | ARRAY_SIZE(tas5086_sample_rates), priv->rate); |
374 | 374 | ||
375 | if (val < 0) { | 375 | if (val < 0) { |
376 | dev_err(codec->dev, "Invalid sample rate\n"); | 376 | dev_err(component->dev, "Invalid sample rate\n"); |
377 | return -EINVAL; | 377 | return -EINVAL; |
378 | } | 378 | } |
379 | 379 | ||
@@ -387,7 +387,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, | |||
387 | val = index_in_array(tas5086_ratios, ARRAY_SIZE(tas5086_ratios), | 387 | val = index_in_array(tas5086_ratios, ARRAY_SIZE(tas5086_ratios), |
388 | priv->mclk / priv->rate); | 388 | priv->mclk / priv->rate); |
389 | if (val < 0) { | 389 | if (val < 0) { |
390 | dev_err(codec->dev, "Invalid MCLK / Fs ratio\n"); | 390 | dev_err(component->dev, "Invalid MCLK / Fs ratio\n"); |
391 | return -EINVAL; | 391 | return -EINVAL; |
392 | } | 392 | } |
393 | 393 | ||
@@ -424,7 +424,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, | |||
424 | val = 0x06; | 424 | val = 0x06; |
425 | break; | 425 | break; |
426 | default: | 426 | default: |
427 | dev_err(codec->dev, "Invalid DAI format\n"); | 427 | dev_err(component->dev, "Invalid DAI format\n"); |
428 | return -EINVAL; | 428 | return -EINVAL; |
429 | } | 429 | } |
430 | 430 | ||
@@ -440,7 +440,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, | |||
440 | val += 2; | 440 | val += 2; |
441 | break; | 441 | break; |
442 | default: | 442 | default: |
443 | dev_err(codec->dev, "Invalid bit width\n"); | 443 | dev_err(component->dev, "Invalid bit width\n"); |
444 | return -EINVAL; | 444 | return -EINVAL; |
445 | } | 445 | } |
446 | 446 | ||
@@ -454,13 +454,13 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, | |||
454 | if (ret < 0) | 454 | if (ret < 0) |
455 | return ret; | 455 | return ret; |
456 | 456 | ||
457 | return tas5086_set_deemph(codec); | 457 | return tas5086_set_deemph(component); |
458 | } | 458 | } |
459 | 459 | ||
460 | static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream) | 460 | static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream) |
461 | { | 461 | { |
462 | struct snd_soc_codec *codec = dai->codec; | 462 | struct snd_soc_component *component = dai->component; |
463 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 463 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
464 | unsigned int val = 0; | 464 | unsigned int val = 0; |
465 | 465 | ||
466 | if (mute) | 466 | if (mute) |
@@ -773,9 +773,9 @@ static struct snd_soc_dai_driver tas5086_dai = { | |||
773 | }; | 773 | }; |
774 | 774 | ||
775 | #ifdef CONFIG_PM | 775 | #ifdef CONFIG_PM |
776 | static int tas5086_soc_suspend(struct snd_soc_codec *codec) | 776 | static int tas5086_soc_suspend(struct snd_soc_component *component) |
777 | { | 777 | { |
778 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 778 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
779 | int ret; | 779 | int ret; |
780 | 780 | ||
781 | /* Shut down all channels */ | 781 | /* Shut down all channels */ |
@@ -788,9 +788,9 @@ static int tas5086_soc_suspend(struct snd_soc_codec *codec) | |||
788 | return 0; | 788 | return 0; |
789 | } | 789 | } |
790 | 790 | ||
791 | static int tas5086_soc_resume(struct snd_soc_codec *codec) | 791 | static int tas5086_soc_resume(struct snd_soc_component *component) |
792 | { | 792 | { |
793 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 793 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
794 | int ret; | 794 | int ret; |
795 | 795 | ||
796 | ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); | 796 | ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); |
@@ -800,7 +800,7 @@ static int tas5086_soc_resume(struct snd_soc_codec *codec) | |||
800 | tas5086_reset(priv); | 800 | tas5086_reset(priv); |
801 | regcache_mark_dirty(priv->regmap); | 801 | regcache_mark_dirty(priv->regmap); |
802 | 802 | ||
803 | ret = tas5086_init(codec->dev, priv); | 803 | ret = tas5086_init(component->dev, priv); |
804 | if (ret < 0) | 804 | if (ret < 0) |
805 | return ret; | 805 | return ret; |
806 | 806 | ||
@@ -823,22 +823,22 @@ static const struct of_device_id tas5086_dt_ids[] = { | |||
823 | MODULE_DEVICE_TABLE(of, tas5086_dt_ids); | 823 | MODULE_DEVICE_TABLE(of, tas5086_dt_ids); |
824 | #endif | 824 | #endif |
825 | 825 | ||
826 | static int tas5086_probe(struct snd_soc_codec *codec) | 826 | static int tas5086_probe(struct snd_soc_component *component) |
827 | { | 827 | { |
828 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 828 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
829 | int i, ret; | 829 | int i, ret; |
830 | 830 | ||
831 | ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); | 831 | ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); |
832 | if (ret < 0) { | 832 | if (ret < 0) { |
833 | dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); | 833 | dev_err(component->dev, "Failed to enable regulators: %d\n", ret); |
834 | return ret; | 834 | return ret; |
835 | } | 835 | } |
836 | 836 | ||
837 | priv->pwm_start_mid_z = 0; | 837 | priv->pwm_start_mid_z = 0; |
838 | priv->charge_period = 1300000; /* hardware default is 1300 ms */ | 838 | priv->charge_period = 1300000; /* hardware default is 1300 ms */ |
839 | 839 | ||
840 | if (of_match_device(of_match_ptr(tas5086_dt_ids), codec->dev)) { | 840 | if (of_match_device(of_match_ptr(tas5086_dt_ids), component->dev)) { |
841 | struct device_node *of_node = codec->dev->of_node; | 841 | struct device_node *of_node = component->dev->of_node; |
842 | 842 | ||
843 | of_property_read_u32(of_node, "ti,charge-period", | 843 | of_property_read_u32(of_node, "ti,charge-period", |
844 | &priv->charge_period); | 844 | &priv->charge_period); |
@@ -855,7 +855,7 @@ static int tas5086_probe(struct snd_soc_codec *codec) | |||
855 | } | 855 | } |
856 | 856 | ||
857 | tas5086_reset(priv); | 857 | tas5086_reset(priv); |
858 | ret = tas5086_init(codec->dev, priv); | 858 | ret = tas5086_init(component->dev, priv); |
859 | if (ret < 0) | 859 | if (ret < 0) |
860 | goto exit_disable_regulators; | 860 | goto exit_disable_regulators; |
861 | 861 | ||
@@ -872,32 +872,32 @@ exit_disable_regulators: | |||
872 | return ret; | 872 | return ret; |
873 | } | 873 | } |
874 | 874 | ||
875 | static int tas5086_remove(struct snd_soc_codec *codec) | 875 | static void tas5086_remove(struct snd_soc_component *component) |
876 | { | 876 | { |
877 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 877 | struct tas5086_private *priv = snd_soc_component_get_drvdata(component); |
878 | 878 | ||
879 | if (gpio_is_valid(priv->gpio_nreset)) | 879 | if (gpio_is_valid(priv->gpio_nreset)) |
880 | /* Set codec to the reset state */ | 880 | /* Set codec to the reset state */ |
881 | gpio_set_value(priv->gpio_nreset, 0); | 881 | gpio_set_value(priv->gpio_nreset, 0); |
882 | 882 | ||
883 | regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); | 883 | regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); |
884 | |||
885 | return 0; | ||
886 | }; | 884 | }; |
887 | 885 | ||
888 | static const struct snd_soc_codec_driver soc_codec_dev_tas5086 = { | 886 | static const struct snd_soc_component_driver soc_component_dev_tas5086 = { |
889 | .probe = tas5086_probe, | 887 | .probe = tas5086_probe, |
890 | .remove = tas5086_remove, | 888 | .remove = tas5086_remove, |
891 | .suspend = tas5086_soc_suspend, | 889 | .suspend = tas5086_soc_suspend, |
892 | .resume = tas5086_soc_resume, | 890 | .resume = tas5086_soc_resume, |
893 | .component_driver = { | 891 | .controls = tas5086_controls, |
894 | .controls = tas5086_controls, | 892 | .num_controls = ARRAY_SIZE(tas5086_controls), |
895 | .num_controls = ARRAY_SIZE(tas5086_controls), | 893 | .dapm_widgets = tas5086_dapm_widgets, |
896 | .dapm_widgets = tas5086_dapm_widgets, | 894 | .num_dapm_widgets = ARRAY_SIZE(tas5086_dapm_widgets), |
897 | .num_dapm_widgets = ARRAY_SIZE(tas5086_dapm_widgets), | 895 | .dapm_routes = tas5086_dapm_routes, |
898 | .dapm_routes = tas5086_dapm_routes, | 896 | .num_dapm_routes = ARRAY_SIZE(tas5086_dapm_routes), |
899 | .num_dapm_routes = ARRAY_SIZE(tas5086_dapm_routes), | 897 | .idle_bias_on = 1, |
900 | }, | 898 | .use_pmdown_time = 1, |
899 | .endianness = 1, | ||
900 | .non_legacy_dai_naming = 1, | ||
901 | }; | 901 | }; |
902 | 902 | ||
903 | static const struct i2c_device_id tas5086_i2c_id[] = { | 903 | static const struct i2c_device_id tas5086_i2c_id[] = { |
@@ -985,7 +985,8 @@ static int tas5086_i2c_probe(struct i2c_client *i2c, | |||
985 | regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); | 985 | regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); |
986 | 986 | ||
987 | if (ret == 0) | 987 | if (ret == 0) |
988 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_tas5086, | 988 | ret = devm_snd_soc_register_component(&i2c->dev, |
989 | &soc_component_dev_tas5086, | ||
989 | &tas5086_dai, 1); | 990 | &tas5086_dai, 1); |
990 | 991 | ||
991 | return ret; | 992 | return ret; |
@@ -993,7 +994,6 @@ static int tas5086_i2c_probe(struct i2c_client *i2c, | |||
993 | 994 | ||
994 | static int tas5086_i2c_remove(struct i2c_client *i2c) | 995 | static int tas5086_i2c_remove(struct i2c_client *i2c) |
995 | { | 996 | { |
996 | snd_soc_unregister_codec(&i2c->dev); | ||
997 | return 0; | 997 | return 0; |
998 | } | 998 | } |
999 | 999 | ||