aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/uda1380.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/uda1380.c')
-rw-r--r--sound/soc/codecs/uda1380.c241
1 files changed, 141 insertions, 100 deletions
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index e6bf0844fbf3..5b21594e0e58 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -25,6 +25,7 @@
25#include <linux/ioctl.h> 25#include <linux/ioctl.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/workqueue.h>
28#include <sound/core.h> 29#include <sound/core.h>
29#include <sound/control.h> 30#include <sound/control.h>
30#include <sound/initval.h> 31#include <sound/initval.h>
@@ -35,7 +36,8 @@
35 36
36#include "uda1380.h" 37#include "uda1380.h"
37 38
38#define UDA1380_VERSION "0.6" 39static struct work_struct uda1380_work;
40static struct snd_soc_codec *uda1380_codec;
39 41
40/* 42/*
41 * uda1380 register cache 43 * uda1380 register cache
@@ -52,6 +54,8 @@ static const u16 uda1380_reg[UDA1380_CACHEREGNUM] = {
52 0x0000, 0x8000, 0x0002, 0x0000, 54 0x0000, 0x8000, 0x0002, 0x0000,
53}; 55};
54 56
57static unsigned long uda1380_cache_dirty;
58
55/* 59/*
56 * read uda1380 register cache 60 * read uda1380 register cache
57 */ 61 */
@@ -73,8 +77,11 @@ static inline void uda1380_write_reg_cache(struct snd_soc_codec *codec,
73 u16 reg, unsigned int value) 77 u16 reg, unsigned int value)
74{ 78{
75 u16 *cache = codec->reg_cache; 79 u16 *cache = codec->reg_cache;
80
76 if (reg >= UDA1380_CACHEREGNUM) 81 if (reg >= UDA1380_CACHEREGNUM)
77 return; 82 return;
83 if ((reg >= 0x10) && (cache[reg] != value))
84 set_bit(reg - 0x10, &uda1380_cache_dirty);
78 cache[reg] = value; 85 cache[reg] = value;
79} 86}
80 87
@@ -113,6 +120,8 @@ static int uda1380_write(struct snd_soc_codec *codec, unsigned int reg,
113 (data[0]<<8) | data[1]); 120 (data[0]<<8) | data[1]);
114 return -EIO; 121 return -EIO;
115 } 122 }
123 if (reg >= 0x10)
124 clear_bit(reg - 0x10, &uda1380_cache_dirty);
116 return 0; 125 return 0;
117 } else 126 } else
118 return -EIO; 127 return -EIO;
@@ -120,6 +129,20 @@ static int uda1380_write(struct snd_soc_codec *codec, unsigned int reg,
120 129
121#define uda1380_reset(c) uda1380_write(c, UDA1380_RESET, 0) 130#define uda1380_reset(c) uda1380_write(c, UDA1380_RESET, 0)
122 131
132static void uda1380_flush_work(struct work_struct *work)
133{
134 int bit, reg;
135
136 for_each_bit(bit, &uda1380_cache_dirty, UDA1380_CACHEREGNUM - 0x10) {
137 reg = 0x10 + bit;
138 pr_debug("uda1380: flush reg %x val %x:\n", reg,
139 uda1380_read_reg_cache(uda1380_codec, reg));
140 uda1380_write(uda1380_codec, reg,
141 uda1380_read_reg_cache(uda1380_codec, reg));
142 clear_bit(bit, &uda1380_cache_dirty);
143 }
144}
145
123/* declarations of ALSA reg_elem_REAL controls */ 146/* declarations of ALSA reg_elem_REAL controls */
124static const char *uda1380_deemp[] = { 147static const char *uda1380_deemp[] = {
125 "None", 148 "None",
@@ -254,7 +277,6 @@ static const struct snd_kcontrol_new uda1380_snd_controls[] = {
254 SOC_SINGLE("DAC Polarity inverting Switch", UDA1380_MIXER, 15, 1, 0), /* DA_POL_INV */ 277 SOC_SINGLE("DAC Polarity inverting Switch", UDA1380_MIXER, 15, 1, 0), /* DA_POL_INV */
255 SOC_ENUM("Noise Shaper", uda1380_sel_ns_enum), /* SEL_NS */ 278 SOC_ENUM("Noise Shaper", uda1380_sel_ns_enum), /* SEL_NS */
256 SOC_ENUM("Digital Mixer Signal Control", uda1380_mix_enum), /* MIX_POS, MIX */ 279 SOC_ENUM("Digital Mixer Signal Control", uda1380_mix_enum), /* MIX_POS, MIX */
257 SOC_SINGLE("Silence Switch", UDA1380_MIXER, 7, 1, 0), /* SILENCE, force DAC output to silence */
258 SOC_SINGLE("Silence Detector Switch", UDA1380_MIXER, 6, 1, 0), /* SDET_ON */ 280 SOC_SINGLE("Silence Detector Switch", UDA1380_MIXER, 6, 1, 0), /* SDET_ON */
259 SOC_ENUM("Silence Detector Setting", uda1380_sdet_enum), /* SD_VALUE */ 281 SOC_ENUM("Silence Detector Setting", uda1380_sdet_enum), /* SD_VALUE */
260 SOC_ENUM("Oversampling Input", uda1380_os_enum), /* OS */ 282 SOC_ENUM("Oversampling Input", uda1380_os_enum), /* OS */
@@ -271,21 +293,6 @@ static const struct snd_kcontrol_new uda1380_snd_controls[] = {
271 SOC_SINGLE("AGC Switch", UDA1380_AGC, 0, 1, 0), 293 SOC_SINGLE("AGC Switch", UDA1380_AGC, 0, 1, 0),
272}; 294};
273 295
274/* add non dapm controls */
275static int uda1380_add_controls(struct snd_soc_codec *codec)
276{
277 int err, i;
278
279 for (i = 0; i < ARRAY_SIZE(uda1380_snd_controls); i++) {
280 err = snd_ctl_add(codec->card,
281 snd_soc_cnew(&uda1380_snd_controls[i], codec, NULL));
282 if (err < 0)
283 return err;
284 }
285
286 return 0;
287}
288
289/* Input mux */ 296/* Input mux */
290static const struct snd_kcontrol_new uda1380_input_mux_control = 297static const struct snd_kcontrol_new uda1380_input_mux_control =
291 SOC_DAPM_ENUM("Route", uda1380_input_sel_enum); 298 SOC_DAPM_ENUM("Route", uda1380_input_sel_enum);
@@ -371,7 +378,7 @@ static int uda1380_add_widgets(struct snd_soc_codec *codec)
371 return 0; 378 return 0;
372} 379}
373 380
374static int uda1380_set_dai_fmt(struct snd_soc_dai *codec_dai, 381static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai,
375 unsigned int fmt) 382 unsigned int fmt)
376{ 383{
377 struct snd_soc_codec *codec = codec_dai->codec; 384 struct snd_soc_codec *codec = codec_dai->codec;
@@ -381,61 +388,107 @@ static int uda1380_set_dai_fmt(struct snd_soc_dai *codec_dai,
381 iface = uda1380_read_reg_cache(codec, UDA1380_IFACE); 388 iface = uda1380_read_reg_cache(codec, UDA1380_IFACE);
382 iface &= ~(R01_SFORI_MASK | R01_SIM | R01_SFORO_MASK); 389 iface &= ~(R01_SFORI_MASK | R01_SIM | R01_SFORO_MASK);
383 390
384 /* FIXME: how to select I2S for DATAO and MSB for DATAI correctly? */
385 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 391 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
386 case SND_SOC_DAIFMT_I2S: 392 case SND_SOC_DAIFMT_I2S:
387 iface |= R01_SFORI_I2S | R01_SFORO_I2S; 393 iface |= R01_SFORI_I2S | R01_SFORO_I2S;
388 break; 394 break;
389 case SND_SOC_DAIFMT_LSB: 395 case SND_SOC_DAIFMT_LSB:
390 iface |= R01_SFORI_LSB16 | R01_SFORO_I2S; 396 iface |= R01_SFORI_LSB16 | R01_SFORO_LSB16;
391 break; 397 break;
392 case SND_SOC_DAIFMT_MSB: 398 case SND_SOC_DAIFMT_MSB:
393 iface |= R01_SFORI_MSB | R01_SFORO_I2S; 399 iface |= R01_SFORI_MSB | R01_SFORO_MSB;
394 } 400 }
395 401
396 if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM) 402 /* DATAI is slave only, so in single-link mode, this has to be slave */
397 iface |= R01_SIM; 403 if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS)
404 return -EINVAL;
398 405
399 uda1380_write(codec, UDA1380_IFACE, iface); 406 uda1380_write(codec, UDA1380_IFACE, iface);
400 407
401 return 0; 408 return 0;
402} 409}
403 410
404/* 411static int uda1380_set_dai_fmt_playback(struct snd_soc_dai *codec_dai,
405 * Flush reg cache 412 unsigned int fmt)
406 * We can only write the interpolator and decimator registers
407 * when the DAI is being clocked by the CPU DAI. It's up to the
408 * machine and cpu DAI driver to do this before we are called.
409 */
410static int uda1380_pcm_prepare(struct snd_pcm_substream *substream,
411 struct snd_soc_dai *dai)
412{ 413{
413 struct snd_soc_pcm_runtime *rtd = substream->private_data; 414 struct snd_soc_codec *codec = codec_dai->codec;
414 struct snd_soc_device *socdev = rtd->socdev; 415 int iface;
415 struct snd_soc_codec *codec = socdev->codec; 416
416 int reg, reg_start, reg_end, clk; 417 /* set up DAI based upon fmt */
417 418 iface = uda1380_read_reg_cache(codec, UDA1380_IFACE);
418 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 419 iface &= ~R01_SFORI_MASK;
419 reg_start = UDA1380_MVOL; 420
420 reg_end = UDA1380_MIXER; 421 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
421 } else { 422 case SND_SOC_DAIFMT_I2S:
422 reg_start = UDA1380_DEC; 423 iface |= R01_SFORI_I2S;
423 reg_end = UDA1380_AGC; 424 break;
425 case SND_SOC_DAIFMT_LSB:
426 iface |= R01_SFORI_LSB16;
427 break;
428 case SND_SOC_DAIFMT_MSB:
429 iface |= R01_SFORI_MSB;
424 } 430 }
425 431
426 /* FIXME disable DAC_CLK */ 432 /* DATAI is slave only, so this has to be slave */
427 clk = uda1380_read_reg_cache(codec, UDA1380_CLK); 433 if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS)
428 uda1380_write(codec, UDA1380_CLK, clk & ~R00_DAC_CLK); 434 return -EINVAL;
435
436 uda1380_write(codec, UDA1380_IFACE, iface);
437
438 return 0;
439}
440
441static int uda1380_set_dai_fmt_capture(struct snd_soc_dai *codec_dai,
442 unsigned int fmt)
443{
444 struct snd_soc_codec *codec = codec_dai->codec;
445 int iface;
446
447 /* set up DAI based upon fmt */
448 iface = uda1380_read_reg_cache(codec, UDA1380_IFACE);
449 iface &= ~(R01_SIM | R01_SFORO_MASK);
429 450
430 for (reg = reg_start; reg <= reg_end; reg++) { 451 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
431 pr_debug("uda1380: flush reg %x val %x:", reg, 452 case SND_SOC_DAIFMT_I2S:
432 uda1380_read_reg_cache(codec, reg)); 453 iface |= R01_SFORO_I2S;
433 uda1380_write(codec, reg, uda1380_read_reg_cache(codec, reg)); 454 break;
455 case SND_SOC_DAIFMT_LSB:
456 iface |= R01_SFORO_LSB16;
457 break;
458 case SND_SOC_DAIFMT_MSB:
459 iface |= R01_SFORO_MSB;
434 } 460 }
435 461
436 /* FIXME enable DAC_CLK */ 462 if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
437 uda1380_write(codec, UDA1380_CLK, clk | R00_DAC_CLK); 463 iface |= R01_SIM;
438 464
465 uda1380_write(codec, UDA1380_IFACE, iface);
466
467 return 0;
468}
469
470static int uda1380_trigger(struct snd_pcm_substream *substream, int cmd,
471 struct snd_soc_dai *dai)
472{
473 struct snd_soc_pcm_runtime *rtd = substream->private_data;
474 struct snd_soc_device *socdev = rtd->socdev;
475 struct snd_soc_codec *codec = socdev->card->codec;
476 int mixer = uda1380_read_reg_cache(codec, UDA1380_MIXER);
477
478 switch (cmd) {
479 case SNDRV_PCM_TRIGGER_START:
480 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
481 uda1380_write_reg_cache(codec, UDA1380_MIXER,
482 mixer & ~R14_SILENCE);
483 schedule_work(&uda1380_work);
484 break;
485 case SNDRV_PCM_TRIGGER_STOP:
486 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
487 uda1380_write_reg_cache(codec, UDA1380_MIXER,
488 mixer | R14_SILENCE);
489 schedule_work(&uda1380_work);
490 break;
491 }
439 return 0; 492 return 0;
440} 493}
441 494
@@ -445,7 +498,7 @@ static int uda1380_pcm_hw_params(struct snd_pcm_substream *substream,
445{ 498{
446 struct snd_soc_pcm_runtime *rtd = substream->private_data; 499 struct snd_soc_pcm_runtime *rtd = substream->private_data;
447 struct snd_soc_device *socdev = rtd->socdev; 500 struct snd_soc_device *socdev = rtd->socdev;
448 struct snd_soc_codec *codec = socdev->codec; 501 struct snd_soc_codec *codec = socdev->card->codec;
449 u16 clk = uda1380_read_reg_cache(codec, UDA1380_CLK); 502 u16 clk = uda1380_read_reg_cache(codec, UDA1380_CLK);
450 503
451 /* set WSPLL power and divider if running from this clock */ 504 /* set WSPLL power and divider if running from this clock */
@@ -484,7 +537,7 @@ static void uda1380_pcm_shutdown(struct snd_pcm_substream *substream,
484{ 537{
485 struct snd_soc_pcm_runtime *rtd = substream->private_data; 538 struct snd_soc_pcm_runtime *rtd = substream->private_data;
486 struct snd_soc_device *socdev = rtd->socdev; 539 struct snd_soc_device *socdev = rtd->socdev;
487 struct snd_soc_codec *codec = socdev->codec; 540 struct snd_soc_codec *codec = socdev->card->codec;
488 u16 clk = uda1380_read_reg_cache(codec, UDA1380_CLK); 541 u16 clk = uda1380_read_reg_cache(codec, UDA1380_CLK);
489 542
490 /* shut down WSPLL power if running from this clock */ 543 /* shut down WSPLL power if running from this clock */
@@ -501,24 +554,6 @@ static void uda1380_pcm_shutdown(struct snd_pcm_substream *substream,
501 uda1380_write(codec, UDA1380_CLK, clk); 554 uda1380_write(codec, UDA1380_CLK, clk);
502} 555}
503 556
504static int uda1380_mute(struct snd_soc_dai *codec_dai, int mute)
505{
506 struct snd_soc_codec *codec = codec_dai->codec;
507 u16 mute_reg = uda1380_read_reg_cache(codec, UDA1380_DEEMP) & ~R13_MTM;
508
509 /* FIXME: mute(codec,0) is called when the magician clock is already
510 * set to WSPLL, but for some unknown reason writing to interpolator
511 * registers works only when clocked by SYSCLK */
512 u16 clk = uda1380_read_reg_cache(codec, UDA1380_CLK);
513 uda1380_write(codec, UDA1380_CLK, ~R00_DAC_CLK & clk);
514 if (mute)
515 uda1380_write(codec, UDA1380_DEEMP, mute_reg | R13_MTM);
516 else
517 uda1380_write(codec, UDA1380_DEEMP, mute_reg);
518 uda1380_write(codec, UDA1380_CLK, clk);
519 return 0;
520}
521
522static int uda1380_set_bias_level(struct snd_soc_codec *codec, 557static int uda1380_set_bias_level(struct snd_soc_codec *codec,
523 enum snd_soc_bias_level level) 558 enum snd_soc_bias_level level)
524{ 559{
@@ -544,6 +579,27 @@ static int uda1380_set_bias_level(struct snd_soc_codec *codec,
544 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ 579 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
545 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) 580 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
546 581
582static struct snd_soc_dai_ops uda1380_dai_ops = {
583 .hw_params = uda1380_pcm_hw_params,
584 .shutdown = uda1380_pcm_shutdown,
585 .trigger = uda1380_trigger,
586 .set_fmt = uda1380_set_dai_fmt_both,
587};
588
589static struct snd_soc_dai_ops uda1380_dai_ops_playback = {
590 .hw_params = uda1380_pcm_hw_params,
591 .shutdown = uda1380_pcm_shutdown,
592 .trigger = uda1380_trigger,
593 .set_fmt = uda1380_set_dai_fmt_playback,
594};
595
596static struct snd_soc_dai_ops uda1380_dai_ops_capture = {
597 .hw_params = uda1380_pcm_hw_params,
598 .shutdown = uda1380_pcm_shutdown,
599 .trigger = uda1380_trigger,
600 .set_fmt = uda1380_set_dai_fmt_capture,
601};
602
547struct snd_soc_dai uda1380_dai[] = { 603struct snd_soc_dai uda1380_dai[] = {
548{ 604{
549 .name = "UDA1380", 605 .name = "UDA1380",
@@ -559,13 +615,7 @@ struct snd_soc_dai uda1380_dai[] = {
559 .channels_max = 2, 615 .channels_max = 2,
560 .rates = UDA1380_RATES, 616 .rates = UDA1380_RATES,
561 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 617 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
562 .ops = { 618 .ops = &uda1380_dai_ops,
563 .hw_params = uda1380_pcm_hw_params,
564 .shutdown = uda1380_pcm_shutdown,
565 .prepare = uda1380_pcm_prepare,
566 .digital_mute = uda1380_mute,
567 .set_fmt = uda1380_set_dai_fmt,
568 },
569}, 619},
570{ /* playback only - dual interface */ 620{ /* playback only - dual interface */
571 .name = "UDA1380", 621 .name = "UDA1380",
@@ -576,13 +626,7 @@ struct snd_soc_dai uda1380_dai[] = {
576 .rates = UDA1380_RATES, 626 .rates = UDA1380_RATES,
577 .formats = SNDRV_PCM_FMTBIT_S16_LE, 627 .formats = SNDRV_PCM_FMTBIT_S16_LE,
578 }, 628 },
579 .ops = { 629 .ops = &uda1380_dai_ops_playback,
580 .hw_params = uda1380_pcm_hw_params,
581 .shutdown = uda1380_pcm_shutdown,
582 .prepare = uda1380_pcm_prepare,
583 .digital_mute = uda1380_mute,
584 .set_fmt = uda1380_set_dai_fmt,
585 },
586}, 630},
587{ /* capture only - dual interface*/ 631{ /* capture only - dual interface*/
588 .name = "UDA1380", 632 .name = "UDA1380",
@@ -593,12 +637,7 @@ struct snd_soc_dai uda1380_dai[] = {
593 .rates = UDA1380_RATES, 637 .rates = UDA1380_RATES,
594 .formats = SNDRV_PCM_FMTBIT_S16_LE, 638 .formats = SNDRV_PCM_FMTBIT_S16_LE,
595 }, 639 },
596 .ops = { 640 .ops = &uda1380_dai_ops_capture,
597 .hw_params = uda1380_pcm_hw_params,
598 .shutdown = uda1380_pcm_shutdown,
599 .prepare = uda1380_pcm_prepare,
600 .set_fmt = uda1380_set_dai_fmt,
601 },
602}, 641},
603}; 642};
604EXPORT_SYMBOL_GPL(uda1380_dai); 643EXPORT_SYMBOL_GPL(uda1380_dai);
@@ -606,7 +645,7 @@ EXPORT_SYMBOL_GPL(uda1380_dai);
606static int uda1380_suspend(struct platform_device *pdev, pm_message_t state) 645static int uda1380_suspend(struct platform_device *pdev, pm_message_t state)
607{ 646{
608 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 647 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
609 struct snd_soc_codec *codec = socdev->codec; 648 struct snd_soc_codec *codec = socdev->card->codec;
610 649
611 uda1380_set_bias_level(codec, SND_SOC_BIAS_OFF); 650 uda1380_set_bias_level(codec, SND_SOC_BIAS_OFF);
612 return 0; 651 return 0;
@@ -615,7 +654,7 @@ static int uda1380_suspend(struct platform_device *pdev, pm_message_t state)
615static int uda1380_resume(struct platform_device *pdev) 654static int uda1380_resume(struct platform_device *pdev)
616{ 655{
617 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 656 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
618 struct snd_soc_codec *codec = socdev->codec; 657 struct snd_soc_codec *codec = socdev->card->codec;
619 int i; 658 int i;
620 u8 data[2]; 659 u8 data[2];
621 u16 *cache = codec->reg_cache; 660 u16 *cache = codec->reg_cache;
@@ -637,7 +676,7 @@ static int uda1380_resume(struct platform_device *pdev)
637 */ 676 */
638static int uda1380_init(struct snd_soc_device *socdev, int dac_clk) 677static int uda1380_init(struct snd_soc_device *socdev, int dac_clk)
639{ 678{
640 struct snd_soc_codec *codec = socdev->codec; 679 struct snd_soc_codec *codec = socdev->card->codec;
641 int ret = 0; 680 int ret = 0;
642 681
643 codec->name = "UDA1380"; 682 codec->name = "UDA1380";
@@ -655,6 +694,9 @@ static int uda1380_init(struct snd_soc_device *socdev, int dac_clk)
655 codec->reg_cache_step = 1; 694 codec->reg_cache_step = 1;
656 uda1380_reset(codec); 695 uda1380_reset(codec);
657 696
697 uda1380_codec = codec;
698 INIT_WORK(&uda1380_work, uda1380_flush_work);
699
658 /* register pcms */ 700 /* register pcms */
659 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); 701 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
660 if (ret < 0) { 702 if (ret < 0) {
@@ -675,7 +717,8 @@ static int uda1380_init(struct snd_soc_device *socdev, int dac_clk)
675 } 717 }
676 718
677 /* uda1380 init */ 719 /* uda1380 init */
678 uda1380_add_controls(codec); 720 snd_soc_add_controls(codec, uda1380_snd_controls,
721 ARRAY_SIZE(uda1380_snd_controls));
679 uda1380_add_widgets(codec); 722 uda1380_add_widgets(codec);
680 ret = snd_soc_init_card(socdev); 723 ret = snd_soc_init_card(socdev);
681 if (ret < 0) { 724 if (ret < 0) {
@@ -702,7 +745,7 @@ static int uda1380_i2c_probe(struct i2c_client *i2c,
702{ 745{
703 struct snd_soc_device *socdev = uda1380_socdev; 746 struct snd_soc_device *socdev = uda1380_socdev;
704 struct uda1380_setup_data *setup = socdev->codec_data; 747 struct uda1380_setup_data *setup = socdev->codec_data;
705 struct snd_soc_codec *codec = socdev->codec; 748 struct snd_soc_codec *codec = socdev->card->codec;
706 int ret; 749 int ret;
707 750
708 i2c_set_clientdata(i2c, codec); 751 i2c_set_clientdata(i2c, codec);
@@ -786,14 +829,12 @@ static int uda1380_probe(struct platform_device *pdev)
786 struct snd_soc_codec *codec; 829 struct snd_soc_codec *codec;
787 int ret; 830 int ret;
788 831
789 pr_info("UDA1380 Audio Codec %s", UDA1380_VERSION);
790
791 setup = socdev->codec_data; 832 setup = socdev->codec_data;
792 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); 833 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
793 if (codec == NULL) 834 if (codec == NULL)
794 return -ENOMEM; 835 return -ENOMEM;
795 836
796 socdev->codec = codec; 837 socdev->card->codec = codec;
797 mutex_init(&codec->mutex); 838 mutex_init(&codec->mutex);
798 INIT_LIST_HEAD(&codec->dapm_widgets); 839 INIT_LIST_HEAD(&codec->dapm_widgets);
799 INIT_LIST_HEAD(&codec->dapm_paths); 840 INIT_LIST_HEAD(&codec->dapm_paths);
@@ -817,7 +858,7 @@ static int uda1380_probe(struct platform_device *pdev)
817static int uda1380_remove(struct platform_device *pdev) 858static int uda1380_remove(struct platform_device *pdev)
818{ 859{
819 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 860 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
820 struct snd_soc_codec *codec = socdev->codec; 861 struct snd_soc_codec *codec = socdev->card->codec;
821 862
822 if (codec->control_data) 863 if (codec->control_data)
823 uda1380_set_bias_level(codec, SND_SOC_BIAS_OFF); 864 uda1380_set_bias_level(codec, SND_SOC_BIAS_OFF);