diff options
Diffstat (limited to 'sound/soc/s3c24xx/neo1973_wm8753.c')
-rw-r--r-- | sound/soc/s3c24xx/neo1973_wm8753.c | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 962cc20b1af5..0e9d1c5f2484 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <asm/arch/regs-gpio.h> | 33 | #include <asm/arch/regs-gpio.h> |
34 | #include <asm/hardware.h> | 34 | #include <asm/hardware.h> |
35 | #include <asm/arch/audio.h> | 35 | #include <asm/arch/audio.h> |
36 | #include <asm/io.h> | 36 | #include <linux/io.h> |
37 | #include <asm/arch/spi-gpio.h> | 37 | #include <asm/arch/spi-gpio.h> |
38 | 38 | ||
39 | #include <asm/plat-s3c24xx/regs-iis.h> | 39 | #include <asm/plat-s3c24xx/regs-iis.h> |
@@ -122,7 +122,7 @@ static int neo1973_hifi_hw_params(struct snd_pcm_substream *substream, | |||
122 | 122 | ||
123 | /* set MCLK division for sample rate */ | 123 | /* set MCLK division for sample rate */ |
124 | ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK, | 124 | ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK, |
125 | S3C2410_IISMOD_32FS ); | 125 | S3C2410_IISMOD_32FS); |
126 | if (ret < 0) | 126 | if (ret < 0) |
127 | return ret; | 127 | return ret; |
128 | 128 | ||
@@ -133,7 +133,7 @@ static int neo1973_hifi_hw_params(struct snd_pcm_substream *substream, | |||
133 | 133 | ||
134 | /* set prescaler division for sample rate */ | 134 | /* set prescaler division for sample rate */ |
135 | ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER, | 135 | ret = cpu_dai->dai_ops.set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER, |
136 | S3C24XX_PRESCALE(4,4)); | 136 | S3C24XX_PRESCALE(4, 4)); |
137 | if (ret < 0) | 137 | if (ret < 0) |
138 | return ret; | 138 | return ret; |
139 | 139 | ||
@@ -222,7 +222,7 @@ static struct snd_soc_ops neo1973_voice_ops = { | |||
222 | .hw_free = neo1973_voice_hw_free, | 222 | .hw_free = neo1973_voice_hw_free, |
223 | }; | 223 | }; |
224 | 224 | ||
225 | static int neo1973_scenario = 0; | 225 | static int neo1973_scenario; |
226 | 226 | ||
227 | static int neo1973_get_scenario(struct snd_kcontrol *kcontrol, | 227 | static int neo1973_get_scenario(struct snd_kcontrol *kcontrol, |
228 | struct snd_ctl_elem_value *ucontrol) | 228 | struct snd_ctl_elem_value *ucontrol) |
@@ -233,7 +233,7 @@ static int neo1973_get_scenario(struct snd_kcontrol *kcontrol, | |||
233 | 233 | ||
234 | static int set_scenario_endpoints(struct snd_soc_codec *codec, int scenario) | 234 | static int set_scenario_endpoints(struct snd_soc_codec *codec, int scenario) |
235 | { | 235 | { |
236 | switch(neo1973_scenario) { | 236 | switch (neo1973_scenario) { |
237 | case NEO_AUDIO_OFF: | 237 | case NEO_AUDIO_OFF: |
238 | snd_soc_dapm_set_endpoint(codec, "Audio Out", 0); | 238 | snd_soc_dapm_set_endpoint(codec, "Audio Out", 0); |
239 | snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0); | 239 | snd_soc_dapm_set_endpoint(codec, "GSM Line Out", 0); |
@@ -334,7 +334,7 @@ static void lm4857_write_regs(void) | |||
334 | static int lm4857_get_reg(struct snd_kcontrol *kcontrol, | 334 | static int lm4857_get_reg(struct snd_kcontrol *kcontrol, |
335 | struct snd_ctl_elem_value *ucontrol) | 335 | struct snd_ctl_elem_value *ucontrol) |
336 | { | 336 | { |
337 | int reg=kcontrol->private_value & 0xFF; | 337 | int reg = kcontrol->private_value & 0xFF; |
338 | int shift = (kcontrol->private_value >> 8) & 0x0F; | 338 | int shift = (kcontrol->private_value >> 8) & 0x0F; |
339 | int mask = (kcontrol->private_value >> 16) & 0xFF; | 339 | int mask = (kcontrol->private_value >> 16) & 0xFF; |
340 | 340 | ||
@@ -349,11 +349,11 @@ static int lm4857_set_reg(struct snd_kcontrol *kcontrol, | |||
349 | int shift = (kcontrol->private_value >> 8) & 0x0F; | 349 | int shift = (kcontrol->private_value >> 8) & 0x0F; |
350 | int mask = (kcontrol->private_value >> 16) & 0xFF; | 350 | int mask = (kcontrol->private_value >> 16) & 0xFF; |
351 | 351 | ||
352 | if (((lm4857_regs[reg] >> shift ) & mask) == | 352 | if (((lm4857_regs[reg] >> shift) & mask) == |
353 | ucontrol->value.integer.value[0]) | 353 | ucontrol->value.integer.value[0]) |
354 | return 0; | 354 | return 0; |
355 | 355 | ||
356 | lm4857_regs[reg] &= ~ (mask << shift); | 356 | lm4857_regs[reg] &= ~(mask << shift); |
357 | lm4857_regs[reg] |= ucontrol->value.integer.value[0] << shift; | 357 | lm4857_regs[reg] |= ucontrol->value.integer.value[0] << shift; |
358 | lm4857_write_regs(); | 358 | lm4857_write_regs(); |
359 | return 1; | 359 | return 1; |
@@ -398,7 +398,7 @@ static const struct snd_soc_dapm_widget wm8753_dapm_widgets[] = { | |||
398 | 398 | ||
399 | 399 | ||
400 | /* example machine audio_mapnections */ | 400 | /* example machine audio_mapnections */ |
401 | static const char* audio_map[][3] = { | 401 | static const char *audio_map[][3] = { |
402 | 402 | ||
403 | /* Connections to the lm4857 amp */ | 403 | /* Connections to the lm4857 amp */ |
404 | {"Audio Out", NULL, "LOUT1"}, | 404 | {"Audio Out", NULL, "LOUT1"}, |
@@ -450,7 +450,7 @@ static const char *neo_scenarios[] = { | |||
450 | }; | 450 | }; |
451 | 451 | ||
452 | static const struct soc_enum neo_scenario_enum[] = { | 452 | static const struct soc_enum neo_scenario_enum[] = { |
453 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(neo_scenarios),neo_scenarios), | 453 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(neo_scenarios), neo_scenarios), |
454 | }; | 454 | }; |
455 | 455 | ||
456 | static const struct snd_kcontrol_new wm8753_neo1973_controls[] = { | 456 | static const struct snd_kcontrol_new wm8753_neo1973_controls[] = { |
@@ -521,8 +521,8 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec) | |||
521 | /* | 521 | /* |
522 | * BT Codec DAI | 522 | * BT Codec DAI |
523 | */ | 523 | */ |
524 | static struct snd_soc_cpu_dai bt_dai = | 524 | static struct snd_soc_cpu_dai bt_dai = { |
525 | { .name = "Bluetooth", | 525 | .name = "Bluetooth", |
526 | .id = 0, | 526 | .id = 0, |
527 | .type = SND_SOC_DAI_PCM, | 527 | .type = SND_SOC_DAI_PCM, |
528 | .playback = { | 528 | .playback = { |
@@ -616,6 +616,35 @@ static int lm4857_i2c_attach(struct i2c_adapter *adap) | |||
616 | return i2c_probe(adap, &addr_data, lm4857_amp_probe); | 616 | return i2c_probe(adap, &addr_data, lm4857_amp_probe); |
617 | } | 617 | } |
618 | 618 | ||
619 | static u8 lm4857_state; | ||
620 | |||
621 | static int lm4857_suspend(struct i2c_client *dev, pm_message_t state) | ||
622 | { | ||
623 | dev_dbg(&dev->dev, "lm4857_suspend\n"); | ||
624 | lm4857_state = lm4857_regs[LM4857_CTRL] & 0xf; | ||
625 | if (lm4857_state) { | ||
626 | lm4857_regs[LM4857_CTRL] &= 0xf0; | ||
627 | lm4857_write_regs(); | ||
628 | } | ||
629 | return 0; | ||
630 | } | ||
631 | |||
632 | static int lm4857_resume(struct i2c_client *dev) | ||
633 | { | ||
634 | if (lm4857_state) { | ||
635 | lm4857_regs[LM4857_CTRL] |= (lm4857_state & 0x0f); | ||
636 | lm4857_write_regs(); | ||
637 | } | ||
638 | return 0; | ||
639 | } | ||
640 | |||
641 | static void lm4857_shutdown(struct i2c_client *dev) | ||
642 | { | ||
643 | dev_dbg(&dev->dev, "lm4857_shutdown\n"); | ||
644 | lm4857_regs[LM4857_CTRL] &= 0xf0; | ||
645 | lm4857_write_regs(); | ||
646 | } | ||
647 | |||
619 | /* corgi i2c codec control layer */ | 648 | /* corgi i2c codec control layer */ |
620 | static struct i2c_driver lm4857_i2c_driver = { | 649 | static struct i2c_driver lm4857_i2c_driver = { |
621 | .driver = { | 650 | .driver = { |
@@ -623,6 +652,9 @@ static struct i2c_driver lm4857_i2c_driver = { | |||
623 | .owner = THIS_MODULE, | 652 | .owner = THIS_MODULE, |
624 | }, | 653 | }, |
625 | .id = I2C_DRIVERID_LM4857, | 654 | .id = I2C_DRIVERID_LM4857, |
655 | .suspend = lm4857_suspend, | ||
656 | .resume = lm4857_resume, | ||
657 | .shutdown = lm4857_shutdown, | ||
626 | .attach_adapter = lm4857_i2c_attach, | 658 | .attach_adapter = lm4857_i2c_attach, |
627 | .detach_client = lm4857_i2c_detach, | 659 | .detach_client = lm4857_i2c_detach, |
628 | .command = NULL, | 660 | .command = NULL, |
@@ -667,6 +699,6 @@ module_init(neo1973_init); | |||
667 | module_exit(neo1973_exit); | 699 | module_exit(neo1973_exit); |
668 | 700 | ||
669 | /* Module information */ | 701 | /* Module information */ |
670 | MODULE_AUTHOR("Graeme Gregory, graeme.gregory@wolfsonmicro.com, www.wolfsonmicro.com"); | 702 | MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org, www.openmoko.org"); |
671 | MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973"); | 703 | MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973"); |
672 | MODULE_LICENSE("GPL"); | 704 | MODULE_LICENSE("GPL"); |