diff options
Diffstat (limited to 'sound/soc/codecs/uda134x.c')
-rw-r--r-- | sound/soc/codecs/uda134x.c | 84 |
1 files changed, 34 insertions, 50 deletions
diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index a2c5064a774b..ddefb8f80145 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c | |||
@@ -173,7 +173,7 @@ static int uda134x_startup(struct snd_pcm_substream *substream, | |||
173 | { | 173 | { |
174 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 174 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
175 | struct snd_soc_device *socdev = rtd->socdev; | 175 | struct snd_soc_device *socdev = rtd->socdev; |
176 | struct snd_soc_codec *codec = socdev->codec; | 176 | struct snd_soc_codec *codec = socdev->card->codec; |
177 | struct uda134x_priv *uda134x = codec->private_data; | 177 | struct uda134x_priv *uda134x = codec->private_data; |
178 | struct snd_pcm_runtime *master_runtime; | 178 | struct snd_pcm_runtime *master_runtime; |
179 | 179 | ||
@@ -206,7 +206,7 @@ static void uda134x_shutdown(struct snd_pcm_substream *substream, | |||
206 | { | 206 | { |
207 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 207 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
208 | struct snd_soc_device *socdev = rtd->socdev; | 208 | struct snd_soc_device *socdev = rtd->socdev; |
209 | struct snd_soc_codec *codec = socdev->codec; | 209 | struct snd_soc_codec *codec = socdev->card->codec; |
210 | struct uda134x_priv *uda134x = codec->private_data; | 210 | struct uda134x_priv *uda134x = codec->private_data; |
211 | 211 | ||
212 | if (uda134x->master_substream == substream) | 212 | if (uda134x->master_substream == substream) |
@@ -221,7 +221,7 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream, | |||
221 | { | 221 | { |
222 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 222 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
223 | struct snd_soc_device *socdev = rtd->socdev; | 223 | struct snd_soc_device *socdev = rtd->socdev; |
224 | struct snd_soc_codec *codec = socdev->codec; | 224 | struct snd_soc_codec *codec = socdev->card->codec; |
225 | struct uda134x_priv *uda134x = codec->private_data; | 225 | struct uda134x_priv *uda134x = codec->private_data; |
226 | u8 hw_params; | 226 | u8 hw_params; |
227 | 227 | ||
@@ -431,38 +431,14 @@ SOC_ENUM("PCM Playback De-emphasis", uda134x_mixer_enum[1]), | |||
431 | SOC_SINGLE("DC Filter Enable Switch", UDA134X_STATUS0, 0, 1, 0), | 431 | SOC_SINGLE("DC Filter Enable Switch", UDA134X_STATUS0, 0, 1, 0), |
432 | }; | 432 | }; |
433 | 433 | ||
434 | static int uda134x_add_controls(struct snd_soc_codec *codec) | 434 | static struct snd_soc_dai_ops uda134x_dai_ops = { |
435 | { | 435 | .startup = uda134x_startup, |
436 | int err, i, n; | 436 | .shutdown = uda134x_shutdown, |
437 | const struct snd_kcontrol_new *ctrls; | 437 | .hw_params = uda134x_hw_params, |
438 | struct uda134x_platform_data *pd = codec->control_data; | 438 | .digital_mute = uda134x_mute, |
439 | 439 | .set_sysclk = uda134x_set_dai_sysclk, | |
440 | switch (pd->model) { | 440 | .set_fmt = uda134x_set_dai_fmt, |
441 | case UDA134X_UDA1340: | 441 | }; |
442 | case UDA134X_UDA1344: | ||
443 | n = ARRAY_SIZE(uda1340_snd_controls); | ||
444 | ctrls = uda1340_snd_controls; | ||
445 | break; | ||
446 | case UDA134X_UDA1341: | ||
447 | n = ARRAY_SIZE(uda1341_snd_controls); | ||
448 | ctrls = uda1341_snd_controls; | ||
449 | break; | ||
450 | default: | ||
451 | printk(KERN_ERR "%s unkown codec type: %d", | ||
452 | __func__, pd->model); | ||
453 | return -EINVAL; | ||
454 | } | ||
455 | |||
456 | for (i = 0; i < n; i++) { | ||
457 | err = snd_ctl_add(codec->card, | ||
458 | snd_soc_cnew(&ctrls[i], | ||
459 | codec, NULL)); | ||
460 | if (err < 0) | ||
461 | return err; | ||
462 | } | ||
463 | |||
464 | return 0; | ||
465 | } | ||
466 | 442 | ||
467 | struct snd_soc_dai uda134x_dai = { | 443 | struct snd_soc_dai uda134x_dai = { |
468 | .name = "UDA134X", | 444 | .name = "UDA134X", |
@@ -483,14 +459,7 @@ struct snd_soc_dai uda134x_dai = { | |||
483 | .formats = UDA134X_FORMATS, | 459 | .formats = UDA134X_FORMATS, |
484 | }, | 460 | }, |
485 | /* pcm operations */ | 461 | /* pcm operations */ |
486 | .ops = { | 462 | .ops = &uda134x_dai_ops, |
487 | .startup = uda134x_startup, | ||
488 | .shutdown = uda134x_shutdown, | ||
489 | .hw_params = uda134x_hw_params, | ||
490 | .digital_mute = uda134x_mute, | ||
491 | .set_sysclk = uda134x_set_dai_sysclk, | ||
492 | .set_fmt = uda134x_set_dai_fmt, | ||
493 | } | ||
494 | }; | 463 | }; |
495 | EXPORT_SYMBOL(uda134x_dai); | 464 | EXPORT_SYMBOL(uda134x_dai); |
496 | 465 | ||
@@ -525,11 +494,11 @@ static int uda134x_soc_probe(struct platform_device *pdev) | |||
525 | return -EINVAL; | 494 | return -EINVAL; |
526 | } | 495 | } |
527 | 496 | ||
528 | socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); | 497 | socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); |
529 | if (socdev->codec == NULL) | 498 | if (socdev->card->codec == NULL) |
530 | return ret; | 499 | return ret; |
531 | 500 | ||
532 | codec = socdev->codec; | 501 | codec = socdev->card->codec; |
533 | 502 | ||
534 | uda134x = kzalloc(sizeof(struct uda134x_priv), GFP_KERNEL); | 503 | uda134x = kzalloc(sizeof(struct uda134x_priv), GFP_KERNEL); |
535 | if (uda134x == NULL) | 504 | if (uda134x == NULL) |
@@ -572,7 +541,22 @@ static int uda134x_soc_probe(struct platform_device *pdev) | |||
572 | goto pcm_err; | 541 | goto pcm_err; |
573 | } | 542 | } |
574 | 543 | ||
575 | ret = uda134x_add_controls(codec); | 544 | switch (pd->model) { |
545 | case UDA134X_UDA1340: | ||
546 | case UDA134X_UDA1344: | ||
547 | ret = snd_soc_add_controls(codec, uda1340_snd_controls, | ||
548 | ARRAY_SIZE(uda1340_snd_controls)); | ||
549 | break; | ||
550 | case UDA134X_UDA1341: | ||
551 | ret = snd_soc_add_controls(codec, uda1341_snd_controls, | ||
552 | ARRAY_SIZE(uda1341_snd_controls)); | ||
553 | break; | ||
554 | default: | ||
555 | printk(KERN_ERR "%s unkown codec type: %d", | ||
556 | __func__, pd->model); | ||
557 | return -EINVAL; | ||
558 | } | ||
559 | |||
576 | if (ret < 0) { | 560 | if (ret < 0) { |
577 | printk(KERN_ERR "UDA134X: failed to register controls\n"); | 561 | printk(KERN_ERR "UDA134X: failed to register controls\n"); |
578 | goto pcm_err; | 562 | goto pcm_err; |
@@ -602,7 +586,7 @@ priv_err: | |||
602 | static int uda134x_soc_remove(struct platform_device *pdev) | 586 | static int uda134x_soc_remove(struct platform_device *pdev) |
603 | { | 587 | { |
604 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 588 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
605 | struct snd_soc_codec *codec = socdev->codec; | 589 | struct snd_soc_codec *codec = socdev->card->codec; |
606 | 590 | ||
607 | uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 591 | uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
608 | uda134x_set_bias_level(codec, SND_SOC_BIAS_OFF); | 592 | uda134x_set_bias_level(codec, SND_SOC_BIAS_OFF); |
@@ -622,7 +606,7 @@ static int uda134x_soc_suspend(struct platform_device *pdev, | |||
622 | pm_message_t state) | 606 | pm_message_t state) |
623 | { | 607 | { |
624 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 608 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
625 | struct snd_soc_codec *codec = socdev->codec; | 609 | struct snd_soc_codec *codec = socdev->card->codec; |
626 | 610 | ||
627 | uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 611 | uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
628 | uda134x_set_bias_level(codec, SND_SOC_BIAS_OFF); | 612 | uda134x_set_bias_level(codec, SND_SOC_BIAS_OFF); |
@@ -632,7 +616,7 @@ static int uda134x_soc_suspend(struct platform_device *pdev, | |||
632 | static int uda134x_soc_resume(struct platform_device *pdev) | 616 | static int uda134x_soc_resume(struct platform_device *pdev) |
633 | { | 617 | { |
634 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 618 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
635 | struct snd_soc_codec *codec = socdev->codec; | 619 | struct snd_soc_codec *codec = socdev->card->codec; |
636 | 620 | ||
637 | uda134x_set_bias_level(codec, SND_SOC_BIAS_PREPARE); | 621 | uda134x_set_bias_level(codec, SND_SOC_BIAS_PREPARE); |
638 | uda134x_set_bias_level(codec, SND_SOC_BIAS_ON); | 622 | uda134x_set_bias_level(codec, SND_SOC_BIAS_ON); |