diff options
Diffstat (limited to 'sound/soc/codecs/da7210.c')
-rw-r--r-- | sound/soc/codecs/da7210.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index 75af2d6e0e78..3c51d6a57523 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c | |||
@@ -15,23 +15,15 @@ | |||
15 | * option) any later version. | 15 | * option) any later version. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/moduleparam.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
23 | #include <linux/pm.h> | ||
24 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
25 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
26 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
27 | #include <sound/core.h> | ||
28 | #include <sound/pcm.h> | 22 | #include <sound/pcm.h> |
29 | #include <sound/pcm_params.h> | 23 | #include <sound/pcm_params.h> |
30 | #include <sound/soc.h> | ||
31 | #include <sound/soc-dapm.h> | 24 | #include <sound/soc-dapm.h> |
32 | #include <sound/tlv.h> | ||
33 | #include <sound/initval.h> | 25 | #include <sound/initval.h> |
34 | #include <asm/div64.h> | 26 | #include <sound/tlv.h> |
35 | 27 | ||
36 | #include "da7210.h" | 28 | #include "da7210.h" |
37 | 29 | ||
@@ -145,6 +137,29 @@ | |||
145 | 137 | ||
146 | #define DA7210_VERSION "0.0.1" | 138 | #define DA7210_VERSION "0.0.1" |
147 | 139 | ||
140 | /* | ||
141 | * Playback Volume | ||
142 | * | ||
143 | * max : 0x3F (+15.0 dB) | ||
144 | * (1.5 dB step) | ||
145 | * min : 0x11 (-54.0 dB) | ||
146 | * mute : 0x10 | ||
147 | * reserved : 0x00 - 0x0F | ||
148 | * | ||
149 | * ** FIXME ** | ||
150 | * | ||
151 | * Reserved area are considered as "mute". | ||
152 | * -> min = -79.5 dB | ||
153 | */ | ||
154 | static const DECLARE_TLV_DB_SCALE(hp_out_tlv, -7950, 150, 1); | ||
155 | |||
156 | static const struct snd_kcontrol_new da7210_snd_controls[] = { | ||
157 | |||
158 | SOC_DOUBLE_R_TLV("HeadPhone Playback Volume", | ||
159 | DA7210_HP_L_VOL, DA7210_HP_R_VOL, | ||
160 | 0, 0x3F, 0, hp_out_tlv), | ||
161 | }; | ||
162 | |||
148 | /* Codec private data */ | 163 | /* Codec private data */ |
149 | struct da7210_priv { | 164 | struct da7210_priv { |
150 | struct snd_soc_codec codec; | 165 | struct snd_soc_codec codec; |
@@ -227,10 +242,6 @@ static int da7210_startup(struct snd_pcm_substream *substream, | |||
227 | struct snd_soc_codec *codec = dai->codec; | 242 | struct snd_soc_codec *codec = dai->codec; |
228 | 243 | ||
229 | if (is_play) { | 244 | if (is_play) { |
230 | /* PlayBack Volume 40 */ | ||
231 | snd_soc_update_bits(codec, DA7210_HP_L_VOL, 0x3F, 40); | ||
232 | snd_soc_update_bits(codec, DA7210_HP_R_VOL, 0x3F, 40); | ||
233 | |||
234 | /* Enable Out */ | 245 | /* Enable Out */ |
235 | snd_soc_update_bits(codec, DA7210_OUTMIX_L, 0x1F, 0x10); | 246 | snd_soc_update_bits(codec, DA7210_OUTMIX_L, 0x1F, 0x10); |
236 | snd_soc_update_bits(codec, DA7210_OUTMIX_R, 0x1F, 0x10); | 247 | snd_soc_update_bits(codec, DA7210_OUTMIX_R, 0x1F, 0x10); |
@@ -488,7 +499,7 @@ static int da7210_init(struct da7210_priv *da7210) | |||
488 | ret = snd_soc_register_dai(&da7210_dai); | 499 | ret = snd_soc_register_dai(&da7210_dai); |
489 | if (ret) { | 500 | if (ret) { |
490 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); | 501 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); |
491 | goto init_err; | 502 | goto codec_err; |
492 | } | 503 | } |
493 | 504 | ||
494 | /* FIXME | 505 | /* FIXME |
@@ -574,6 +585,8 @@ static int da7210_init(struct da7210_priv *da7210) | |||
574 | 585 | ||
575 | return ret; | 586 | return ret; |
576 | 587 | ||
588 | codec_err: | ||
589 | snd_soc_unregister_codec(codec); | ||
577 | init_err: | 590 | init_err: |
578 | kfree(codec->reg_cache); | 591 | kfree(codec->reg_cache); |
579 | codec->reg_cache = NULL; | 592 | codec->reg_cache = NULL; |
@@ -601,8 +614,10 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c, | |||
601 | codec->control_data = i2c; | 614 | codec->control_data = i2c; |
602 | 615 | ||
603 | ret = da7210_init(da7210); | 616 | ret = da7210_init(da7210); |
604 | if (ret < 0) | 617 | if (ret < 0) { |
605 | pr_err("Failed to initialise da7210 audio codec\n"); | 618 | pr_err("Failed to initialise da7210 audio codec\n"); |
619 | kfree(da7210); | ||
620 | } | ||
606 | 621 | ||
607 | return ret; | 622 | return ret; |
608 | } | 623 | } |
@@ -656,6 +671,9 @@ static int da7210_probe(struct platform_device *pdev) | |||
656 | if (ret < 0) | 671 | if (ret < 0) |
657 | goto pcm_err; | 672 | goto pcm_err; |
658 | 673 | ||
674 | snd_soc_add_controls(da7210_codec, da7210_snd_controls, | ||
675 | ARRAY_SIZE(da7210_snd_controls)); | ||
676 | |||
659 | dev_info(&pdev->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); | 677 | dev_info(&pdev->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); |
660 | 678 | ||
661 | pcm_err: | 679 | pcm_err: |