diff options
Diffstat (limited to 'sound/soc/omap/ams-delta.c')
-rw-r--r-- | sound/soc/omap/ams-delta.c | 68 |
1 files changed, 22 insertions, 46 deletions
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index 56a5219c0a00..bb243c663e6b 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include "omap-mcbsp.h" | 38 | #include "omap-mcbsp.h" |
39 | #include "../codecs/cx20442.h" | 39 | #include "../codecs/cx20442.h" |
40 | 40 | ||
41 | |||
42 | /* Board specific DAPM widgets */ | 41 | /* Board specific DAPM widgets */ |
43 | static const struct snd_soc_dapm_widget ams_delta_dapm_widgets[] = { | 42 | static const struct snd_soc_dapm_widget ams_delta_dapm_widgets[] = { |
44 | /* Handset */ | 43 | /* Handset */ |
@@ -90,17 +89,23 @@ static const unsigned short ams_delta_audio_mode_pins[] = { | |||
90 | 89 | ||
91 | static unsigned short ams_delta_audio_agc; | 90 | static unsigned short ams_delta_audio_agc; |
92 | 91 | ||
92 | /* | ||
93 | * Used for passing a codec structure pointer | ||
94 | * from the board initialization code to the tty line discipline. | ||
95 | */ | ||
96 | static struct snd_soc_codec *cx20442_codec; | ||
97 | |||
93 | static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, | 98 | static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, |
94 | struct snd_ctl_elem_value *ucontrol) | 99 | struct snd_ctl_elem_value *ucontrol) |
95 | { | 100 | { |
96 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 101 | struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); |
97 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 102 | struct snd_soc_dapm_context *dapm = &card->dapm; |
98 | struct soc_enum *control = (struct soc_enum *)kcontrol->private_value; | 103 | struct soc_enum *control = (struct soc_enum *)kcontrol->private_value; |
99 | unsigned short pins; | 104 | unsigned short pins; |
100 | int pin, changed = 0; | 105 | int pin, changed = 0; |
101 | 106 | ||
102 | /* Refuse any mode changes if we are not able to control the codec. */ | 107 | /* Refuse any mode changes if we are not able to control the codec. */ |
103 | if (!codec->hw_write) | 108 | if (!cx20442_codec->hw_write) |
104 | return -EUNATCH; | 109 | return -EUNATCH; |
105 | 110 | ||
106 | if (ucontrol->value.enumerated.item[0] >= control->items) | 111 | if (ucontrol->value.enumerated.item[0] >= control->items) |
@@ -166,8 +171,8 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, | |||
166 | static int ams_delta_get_audio_mode(struct snd_kcontrol *kcontrol, | 171 | static int ams_delta_get_audio_mode(struct snd_kcontrol *kcontrol, |
167 | struct snd_ctl_elem_value *ucontrol) | 172 | struct snd_ctl_elem_value *ucontrol) |
168 | { | 173 | { |
169 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 174 | struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); |
170 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 175 | struct snd_soc_dapm_context *dapm = &card->dapm; |
171 | unsigned short pins, mode; | 176 | unsigned short pins, mode; |
172 | 177 | ||
173 | pins = ((snd_soc_dapm_get_pin_status(dapm, "Mouthpiece") << | 178 | pins = ((snd_soc_dapm_get_pin_status(dapm, "Mouthpiece") << |
@@ -270,12 +275,6 @@ static void cx81801_timeout(unsigned long data) | |||
270 | ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 0); | 275 | ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 0); |
271 | } | 276 | } |
272 | 277 | ||
273 | /* | ||
274 | * Used for passing a codec structure pointer | ||
275 | * from the board initialization code to the tty line discipline. | ||
276 | */ | ||
277 | static struct snd_soc_codec *cx20442_codec; | ||
278 | |||
279 | /* Line discipline .open() */ | 278 | /* Line discipline .open() */ |
280 | static int cx81801_open(struct tty_struct *tty) | 279 | static int cx81801_open(struct tty_struct *tty) |
281 | { | 280 | { |
@@ -302,7 +301,7 @@ static int cx81801_open(struct tty_struct *tty) | |||
302 | static void cx81801_close(struct tty_struct *tty) | 301 | static void cx81801_close(struct tty_struct *tty) |
303 | { | 302 | { |
304 | struct snd_soc_codec *codec = tty->disc_data; | 303 | struct snd_soc_codec *codec = tty->disc_data; |
305 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 304 | struct snd_soc_dapm_context *dapm = &codec->card->dapm; |
306 | 305 | ||
307 | del_timer_sync(&cx81801_timer); | 306 | del_timer_sync(&cx81801_timer); |
308 | 307 | ||
@@ -475,15 +474,14 @@ static void ams_delta_shutdown(struct snd_pcm_substream *substream) | |||
475 | 474 | ||
476 | static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) | 475 | static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) |
477 | { | 476 | { |
478 | struct snd_soc_codec *codec = rtd->codec; | ||
479 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
480 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 477 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
481 | struct snd_soc_card *card = rtd->card; | 478 | struct snd_soc_card *card = rtd->card; |
479 | struct snd_soc_dapm_context *dapm = &card->dapm; | ||
482 | int ret; | 480 | int ret; |
483 | /* Codec is ready, now add/activate board specific controls */ | 481 | /* Codec is ready, now add/activate board specific controls */ |
484 | 482 | ||
485 | /* Store a pointer to the codec structure for tty ldisc use */ | 483 | /* Store a pointer to the codec structure for tty ldisc use */ |
486 | cx20442_codec = codec; | 484 | cx20442_codec = rtd->codec; |
487 | 485 | ||
488 | /* Set up digital mute if not provided by the codec */ | 486 | /* Set up digital mute if not provided by the codec */ |
489 | if (!codec_dai->driver->ops) { | 487 | if (!codec_dai->driver->ops) { |
@@ -520,41 +518,12 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) | |||
520 | return 0; | 518 | return 0; |
521 | } | 519 | } |
522 | 520 | ||
523 | /* Add board specific DAPM widgets and routes */ | ||
524 | ret = snd_soc_dapm_new_controls(dapm, ams_delta_dapm_widgets, | ||
525 | ARRAY_SIZE(ams_delta_dapm_widgets)); | ||
526 | if (ret) { | ||
527 | dev_warn(card->dev, | ||
528 | "Failed to register DAPM controls, " | ||
529 | "will continue without any.\n"); | ||
530 | return 0; | ||
531 | } | ||
532 | |||
533 | ret = snd_soc_dapm_add_routes(dapm, ams_delta_audio_map, | ||
534 | ARRAY_SIZE(ams_delta_audio_map)); | ||
535 | if (ret) { | ||
536 | dev_warn(card->dev, | ||
537 | "Failed to set up DAPM routes, " | ||
538 | "will continue with codec default map.\n"); | ||
539 | return 0; | ||
540 | } | ||
541 | |||
542 | /* Set up initial pin constellation */ | 521 | /* Set up initial pin constellation */ |
543 | snd_soc_dapm_disable_pin(dapm, "Mouthpiece"); | 522 | snd_soc_dapm_disable_pin(dapm, "Mouthpiece"); |
544 | snd_soc_dapm_enable_pin(dapm, "Earpiece"); | ||
545 | snd_soc_dapm_enable_pin(dapm, "Microphone"); | ||
546 | snd_soc_dapm_disable_pin(dapm, "Speaker"); | 523 | snd_soc_dapm_disable_pin(dapm, "Speaker"); |
547 | snd_soc_dapm_disable_pin(dapm, "AGCIN"); | 524 | snd_soc_dapm_disable_pin(dapm, "AGCIN"); |
548 | snd_soc_dapm_disable_pin(dapm, "AGCOUT"); | 525 | snd_soc_dapm_disable_pin(dapm, "AGCOUT"); |
549 | 526 | ||
550 | /* Add virtual switch */ | ||
551 | ret = snd_soc_add_codec_controls(codec, ams_delta_audio_controls, | ||
552 | ARRAY_SIZE(ams_delta_audio_controls)); | ||
553 | if (ret) | ||
554 | dev_warn(card->dev, | ||
555 | "Failed to register audio mode control, " | ||
556 | "will continue without it.\n"); | ||
557 | |||
558 | return 0; | 527 | return 0; |
559 | } | 528 | } |
560 | 529 | ||
@@ -565,7 +534,7 @@ static struct snd_soc_dai_link ams_delta_dai_link = { | |||
565 | .cpu_dai_name = "omap-mcbsp.1", | 534 | .cpu_dai_name = "omap-mcbsp.1", |
566 | .codec_dai_name = "cx20442-voice", | 535 | .codec_dai_name = "cx20442-voice", |
567 | .init = ams_delta_cx20442_init, | 536 | .init = ams_delta_cx20442_init, |
568 | .platform_name = "omap-pcm-audio", | 537 | .platform_name = "omap-mcbsp.1", |
569 | .codec_name = "cx20442-codec", | 538 | .codec_name = "cx20442-codec", |
570 | .ops = &ams_delta_ops, | 539 | .ops = &ams_delta_ops, |
571 | }; | 540 | }; |
@@ -576,6 +545,13 @@ static struct snd_soc_card ams_delta_audio_card = { | |||
576 | .owner = THIS_MODULE, | 545 | .owner = THIS_MODULE, |
577 | .dai_link = &ams_delta_dai_link, | 546 | .dai_link = &ams_delta_dai_link, |
578 | .num_links = 1, | 547 | .num_links = 1, |
548 | |||
549 | .controls = ams_delta_audio_controls, | ||
550 | .num_controls = ARRAY_SIZE(ams_delta_audio_controls), | ||
551 | .dapm_widgets = ams_delta_dapm_widgets, | ||
552 | .num_dapm_widgets = ARRAY_SIZE(ams_delta_dapm_widgets), | ||
553 | .dapm_routes = ams_delta_audio_map, | ||
554 | .num_dapm_routes = ARRAY_SIZE(ams_delta_audio_map), | ||
579 | }; | 555 | }; |
580 | 556 | ||
581 | /* Module init/exit */ | 557 | /* Module init/exit */ |