aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/ak4535.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/ak4535.c')
-rw-r--r--sound/soc/codecs/ak4535.c46
1 files changed, 17 insertions, 29 deletions
diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c
index 81300d8d42ca..1f63d387a2f4 100644
--- a/sound/soc/codecs/ak4535.c
+++ b/sound/soc/codecs/ak4535.c
@@ -155,21 +155,6 @@ static const struct snd_kcontrol_new ak4535_snd_controls[] = {
155 SOC_SINGLE("Mic Sidetone Volume", AK4535_VOL, 4, 7, 0), 155 SOC_SINGLE("Mic Sidetone Volume", AK4535_VOL, 4, 7, 0),
156}; 156};
157 157
158/* add non dapm controls */
159static int ak4535_add_controls(struct snd_soc_codec *codec)
160{
161 int err, i;
162
163 for (i = 0; i < ARRAY_SIZE(ak4535_snd_controls); i++) {
164 err = snd_ctl_add(codec->card,
165 snd_soc_cnew(&ak4535_snd_controls[i], codec, NULL));
166 if (err < 0)
167 return err;
168 }
169
170 return 0;
171}
172
173/* Mono 1 Mixer */ 158/* Mono 1 Mixer */
174static const struct snd_kcontrol_new ak4535_mono1_mixer_controls[] = { 159static const struct snd_kcontrol_new ak4535_mono1_mixer_controls[] = {
175 SOC_DAPM_SINGLE("Mic Sidetone Switch", AK4535_SIG1, 4, 1, 0), 160 SOC_DAPM_SINGLE("Mic Sidetone Switch", AK4535_SIG1, 4, 1, 0),
@@ -344,7 +329,7 @@ static int ak4535_hw_params(struct snd_pcm_substream *substream,
344{ 329{
345 struct snd_soc_pcm_runtime *rtd = substream->private_data; 330 struct snd_soc_pcm_runtime *rtd = substream->private_data;
346 struct snd_soc_device *socdev = rtd->socdev; 331 struct snd_soc_device *socdev = rtd->socdev;
347 struct snd_soc_codec *codec = socdev->codec; 332 struct snd_soc_codec *codec = socdev->card->codec;
348 struct ak4535_priv *ak4535 = codec->private_data; 333 struct ak4535_priv *ak4535 = codec->private_data;
349 u8 mode2 = ak4535_read_reg_cache(codec, AK4535_MODE2) & ~(0x3 << 5); 334 u8 mode2 = ak4535_read_reg_cache(codec, AK4535_MODE2) & ~(0x3 << 5);
350 int rate = params_rate(params), fs = 256; 335 int rate = params_rate(params), fs = 256;
@@ -436,6 +421,13 @@ static int ak4535_set_bias_level(struct snd_soc_codec *codec,
436 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ 421 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
437 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) 422 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
438 423
424static struct snd_soc_dai_ops ak4535_dai_ops = {
425 .hw_params = ak4535_hw_params,
426 .set_fmt = ak4535_set_dai_fmt,
427 .digital_mute = ak4535_mute,
428 .set_sysclk = ak4535_set_dai_sysclk,
429};
430
439struct snd_soc_dai ak4535_dai = { 431struct snd_soc_dai ak4535_dai = {
440 .name = "AK4535", 432 .name = "AK4535",
441 .playback = { 433 .playback = {
@@ -450,19 +442,14 @@ struct snd_soc_dai ak4535_dai = {
450 .channels_max = 2, 442 .channels_max = 2,
451 .rates = AK4535_RATES, 443 .rates = AK4535_RATES,
452 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 444 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
453 .ops = { 445 .ops = &ak4535_dai_ops,
454 .hw_params = ak4535_hw_params,
455 .set_fmt = ak4535_set_dai_fmt,
456 .digital_mute = ak4535_mute,
457 .set_sysclk = ak4535_set_dai_sysclk,
458 },
459}; 446};
460EXPORT_SYMBOL_GPL(ak4535_dai); 447EXPORT_SYMBOL_GPL(ak4535_dai);
461 448
462static int ak4535_suspend(struct platform_device *pdev, pm_message_t state) 449static int ak4535_suspend(struct platform_device *pdev, pm_message_t state)
463{ 450{
464 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 451 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
465 struct snd_soc_codec *codec = socdev->codec; 452 struct snd_soc_codec *codec = socdev->card->codec;
466 453
467 ak4535_set_bias_level(codec, SND_SOC_BIAS_OFF); 454 ak4535_set_bias_level(codec, SND_SOC_BIAS_OFF);
468 return 0; 455 return 0;
@@ -471,7 +458,7 @@ static int ak4535_suspend(struct platform_device *pdev, pm_message_t state)
471static int ak4535_resume(struct platform_device *pdev) 458static int ak4535_resume(struct platform_device *pdev)
472{ 459{
473 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 460 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
474 struct snd_soc_codec *codec = socdev->codec; 461 struct snd_soc_codec *codec = socdev->card->codec;
475 ak4535_sync(codec); 462 ak4535_sync(codec);
476 ak4535_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 463 ak4535_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
477 ak4535_set_bias_level(codec, codec->suspend_bias_level); 464 ak4535_set_bias_level(codec, codec->suspend_bias_level);
@@ -484,7 +471,7 @@ static int ak4535_resume(struct platform_device *pdev)
484 */ 471 */
485static int ak4535_init(struct snd_soc_device *socdev) 472static int ak4535_init(struct snd_soc_device *socdev)
486{ 473{
487 struct snd_soc_codec *codec = socdev->codec; 474 struct snd_soc_codec *codec = socdev->card->codec;
488 int ret = 0; 475 int ret = 0;
489 476
490 codec->name = "AK4535"; 477 codec->name = "AK4535";
@@ -510,7 +497,8 @@ static int ak4535_init(struct snd_soc_device *socdev)
510 /* power on device */ 497 /* power on device */
511 ak4535_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 498 ak4535_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
512 499
513 ak4535_add_controls(codec); 500 snd_soc_add_controls(codec, ak4535_snd_controls,
501 ARRAY_SIZE(ak4535_snd_controls));
514 ak4535_add_widgets(codec); 502 ak4535_add_widgets(codec);
515 ret = snd_soc_init_card(socdev); 503 ret = snd_soc_init_card(socdev);
516 if (ret < 0) { 504 if (ret < 0) {
@@ -537,7 +525,7 @@ static int ak4535_i2c_probe(struct i2c_client *i2c,
537 const struct i2c_device_id *id) 525 const struct i2c_device_id *id)
538{ 526{
539 struct snd_soc_device *socdev = ak4535_socdev; 527 struct snd_soc_device *socdev = ak4535_socdev;
540 struct snd_soc_codec *codec = socdev->codec; 528 struct snd_soc_codec *codec = socdev->card->codec;
541 int ret; 529 int ret;
542 530
543 i2c_set_clientdata(i2c, codec); 531 i2c_set_clientdata(i2c, codec);
@@ -636,7 +624,7 @@ static int ak4535_probe(struct platform_device *pdev)
636 } 624 }
637 625
638 codec->private_data = ak4535; 626 codec->private_data = ak4535;
639 socdev->codec = codec; 627 socdev->card->codec = codec;
640 mutex_init(&codec->mutex); 628 mutex_init(&codec->mutex);
641 INIT_LIST_HEAD(&codec->dapm_widgets); 629 INIT_LIST_HEAD(&codec->dapm_widgets);
642 INIT_LIST_HEAD(&codec->dapm_paths); 630 INIT_LIST_HEAD(&codec->dapm_paths);
@@ -663,7 +651,7 @@ static int ak4535_probe(struct platform_device *pdev)
663static int ak4535_remove(struct platform_device *pdev) 651static int ak4535_remove(struct platform_device *pdev)
664{ 652{
665 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 653 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
666 struct snd_soc_codec *codec = socdev->codec; 654 struct snd_soc_codec *codec = socdev->card->codec;
667 655
668 if (codec->control_data) 656 if (codec->control_data)
669 ak4535_set_bias_level(codec, SND_SOC_BIAS_OFF); 657 ak4535_set_bias_level(codec, SND_SOC_BIAS_OFF);