aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/codecs/stac9766.c65
1 files changed, 29 insertions, 36 deletions
diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c
index 7740cd5a7604..8ad4b7b3e3ba 100644
--- a/sound/soc/codecs/stac9766.c
+++ b/sound/soc/codecs/stac9766.c
@@ -52,12 +52,14 @@ static const u16 stac9766_reg[] = {
52 0x0000, 0x0000, 0x0000, 0x0000, /* 7e */ 52 0x0000, 0x0000, 0x0000, 0x0000, /* 7e */
53}; 53};
54 54
55static const char *stac9766_record_mux[] = {"Mic", "CD", "Video", "AUX", "Line", "Stereo Mix", "Mono Mix", "Phone"}; 55static const char *stac9766_record_mux[] = {"Mic", "CD", "Video", "AUX",
56 "Line", "Stereo Mix", "Mono Mix", "Phone"};
56static const char *stac9766_mono_mux[] = {"Mix", "Mic"}; 57static const char *stac9766_mono_mux[] = {"Mix", "Mic"};
57static const char *stac9766_mic_mux[] = {"Mic1", "Mic2"}; 58static const char *stac9766_mic_mux[] = {"Mic1", "Mic2"};
58static const char *stac9766_SPDIF_mux[] = {"PCM", "ADC Record"}; 59static const char *stac9766_SPDIF_mux[] = {"PCM", "ADC Record"};
59static const char *stac9766_popbypass_mux[] = {"Normal", "Bypass Mixer"}; 60static const char *stac9766_popbypass_mux[] = {"Normal", "Bypass Mixer"};
60static const char *stac9766_record_all_mux[] = {"All analog", "Analog plus DAC"}; 61static const char *stac9766_record_all_mux[] = {"All analog",
62 "Analog plus DAC"};
61static const char *stac9766_boost1[] = {"0dB", "10dB"}; 63static const char *stac9766_boost1[] = {"0dB", "10dB"};
62static const char *stac9766_boost2[] = {"0dB", "20dB"}; 64static const char *stac9766_boost2[] = {"0dB", "20dB"};
63static const char *stac9766_stereo_mic[] = {"Off", "On"}; 65static const char *stac9766_stereo_mic[] = {"Off", "On"};
@@ -73,7 +75,8 @@ static const struct soc_enum stac9766_SPDIF_enum =
73static const struct soc_enum stac9766_popbypass_enum = 75static const struct soc_enum stac9766_popbypass_enum =
74 SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 15, 2, stac9766_popbypass_mux); 76 SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 15, 2, stac9766_popbypass_mux);
75static const struct soc_enum stac9766_record_all_enum = 77static const struct soc_enum stac9766_record_all_enum =
76 SOC_ENUM_SINGLE(AC97_STAC_ANALOG_SPECIAL, 12, 2, stac9766_record_all_mux); 78 SOC_ENUM_SINGLE(AC97_STAC_ANALOG_SPECIAL, 12, 2,
79 stac9766_record_all_mux);
77static const struct soc_enum stac9766_boost1_enum = 80static const struct soc_enum stac9766_boost1_enum =
78 SOC_ENUM_SINGLE(AC97_MIC, 6, 2, stac9766_boost1); /* 0/10dB */ 81 SOC_ENUM_SINGLE(AC97_MIC, 6, 2, stac9766_boost1); /* 0/10dB */
79static const struct soc_enum stac9766_boost2_enum = 82static const struct soc_enum stac9766_boost2_enum =
@@ -89,9 +92,11 @@ static const DECLARE_TLV_DB_LINEAR(mix_tlv, -3450, 1200);
89static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = { 92static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = {
90 SOC_DOUBLE_TLV("Speaker Volume", AC97_MASTER, 8, 0, 31, 1, master_tlv), 93 SOC_DOUBLE_TLV("Speaker Volume", AC97_MASTER, 8, 0, 31, 1, master_tlv),
91 SOC_SINGLE("Speaker Switch", AC97_MASTER, 15, 1, 1), 94 SOC_SINGLE("Speaker Switch", AC97_MASTER, 15, 1, 1),
92 SOC_DOUBLE_TLV("Headphone Volume", AC97_HEADPHONE, 8, 0, 31, 1, master_tlv), 95 SOC_DOUBLE_TLV("Headphone Volume", AC97_HEADPHONE, 8, 0, 31, 1,
96 master_tlv),
93 SOC_SINGLE("Headphone Switch", AC97_HEADPHONE, 15, 1, 1), 97 SOC_SINGLE("Headphone Switch", AC97_HEADPHONE, 15, 1, 1),
94 SOC_SINGLE_TLV("Mono Out Volume", AC97_MASTER_MONO, 0, 31, 1, master_tlv), 98 SOC_SINGLE_TLV("Mono Out Volume", AC97_MASTER_MONO, 0, 31, 1,
99 master_tlv),
95 SOC_SINGLE("Mono Out Switch", AC97_MASTER_MONO, 15, 1, 1), 100 SOC_SINGLE("Mono Out Switch", AC97_MASTER_MONO, 15, 1, 1),
96 101
97 SOC_DOUBLE_TLV("Record Volume", AC97_REC_GAIN, 8, 0, 15, 0, record_tlv), 102 SOC_DOUBLE_TLV("Record Volume", AC97_REC_GAIN, 8, 0, 15, 0, record_tlv),
@@ -133,8 +138,8 @@ static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = {
133 SOC_ENUM("Pop Bypass Mux", stac9766_popbypass_enum), 138 SOC_ENUM("Pop Bypass Mux", stac9766_popbypass_enum),
134}; 139};
135 140
136int stac9766_ac97_write(struct snd_soc_codec *codec, unsigned int reg, 141static int stac9766_ac97_write(struct snd_soc_codec *codec, unsigned int reg,
137 unsigned int val) 142 unsigned int val)
138{ 143{
139 u16 *cache = codec->reg_cache; 144 u16 *cache = codec->reg_cache;
140 145
@@ -152,7 +157,8 @@ int stac9766_ac97_write(struct snd_soc_codec *codec, unsigned int reg,
152 return 0; 157 return 0;
153} 158}
154 159
155unsigned int stac9766_ac97_read(struct snd_soc_codec *codec, unsigned int reg) 160static unsigned int stac9766_ac97_read(struct snd_soc_codec *codec,
161 unsigned int reg)
156{ 162{
157 u16 val = 0, *cache = codec->reg_cache; 163 u16 val = 0, *cache = codec->reg_cache;
158 164
@@ -176,7 +182,7 @@ unsigned int stac9766_ac97_read(struct snd_soc_codec *codec, unsigned int reg)
176} 182}
177 183
178static int ac97_analog_prepare(struct snd_pcm_substream *substream, 184static int ac97_analog_prepare(struct snd_pcm_substream *substream,
179 struct snd_soc_dai *dai) 185 struct snd_soc_dai *dai)
180{ 186{
181 struct snd_soc_codec *codec = dai->codec; 187 struct snd_soc_codec *codec = dai->codec;
182 struct snd_pcm_runtime *runtime = substream->runtime; 188 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -197,7 +203,7 @@ static int ac97_analog_prepare(struct snd_pcm_substream *substream,
197} 203}
198 204
199static int ac97_digital_prepare(struct snd_pcm_substream *substream, 205static int ac97_digital_prepare(struct snd_pcm_substream *substream,
200 struct snd_soc_dai *dai) 206 struct snd_soc_dai *dai)
201{ 207{
202 struct snd_soc_codec *codec = dai->codec; 208 struct snd_soc_codec *codec = dai->codec;
203 struct snd_pcm_runtime *runtime = substream->runtime; 209 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -216,7 +222,7 @@ static int ac97_digital_prepare(struct snd_pcm_substream *substream,
216} 222}
217 223
218static int ac97_digital_trigger(struct snd_pcm_substream *substream, 224static int ac97_digital_trigger(struct snd_pcm_substream *substream,
219 int cmd, struct snd_soc_dai *dai) 225 int cmd, struct snd_soc_dai *dai)
220{ 226{
221 struct snd_soc_codec *codec = dai->codec; 227 struct snd_soc_codec *codec = dai->codec;
222 unsigned short vra; 228 unsigned short vra;
@@ -232,7 +238,7 @@ static int ac97_digital_trigger(struct snd_pcm_substream *substream,
232} 238}
233 239
234static int stac9766_set_bias_level(struct snd_soc_codec *codec, 240static int stac9766_set_bias_level(struct snd_soc_codec *codec,
235 enum snd_soc_bias_level level) 241 enum snd_soc_bias_level level)
236{ 242{
237 switch (level) { 243 switch (level) {
238 case SND_SOC_BIAS_ON: /* full On */ 244 case SND_SOC_BIAS_ON: /* full On */
@@ -249,7 +255,7 @@ static int stac9766_set_bias_level(struct snd_soc_codec *codec,
249 return 0; 255 return 0;
250} 256}
251 257
252int stac9766_reset(struct snd_soc_codec *codec, int try_warm) 258static int stac9766_reset(struct snd_soc_codec *codec, int try_warm)
253{ 259{
254 if (try_warm && soc_ac97_ops.warm_reset) { 260 if (try_warm && soc_ac97_ops.warm_reset) {
255 soc_ac97_ops.warm_reset(codec->ac97); 261 soc_ac97_ops.warm_reset(codec->ac97);
@@ -266,7 +272,7 @@ int stac9766_reset(struct snd_soc_codec *codec, int try_warm)
266} 272}
267 273
268static int stac9766_codec_suspend(struct platform_device *pdev, 274static int stac9766_codec_suspend(struct platform_device *pdev,
269 pm_message_t state) 275 pm_message_t state)
270{ 276{
271 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 277 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
272 struct snd_soc_codec *codec = socdev->card->codec; 278 struct snd_soc_codec *codec = socdev->card->codec;
@@ -303,13 +309,11 @@ reset:
303 return 0; 309 return 0;
304} 310}
305 311
306static struct snd_soc_dai_ops stac9766_dai_ops_analog = 312static struct snd_soc_dai_ops stac9766_dai_ops_analog = {
307{
308 .prepare = ac97_analog_prepare, 313 .prepare = ac97_analog_prepare,
309}; 314};
310 315
311static struct snd_soc_dai_ops stac9766_dai_ops_digital = 316static struct snd_soc_dai_ops stac9766_dai_ops_digital = {
312{
313 .prepare = ac97_digital_prepare, 317 .prepare = ac97_digital_prepare,
314 .trigger = ac97_digital_trigger, 318 .trigger = ac97_digital_trigger,
315}; 319};
@@ -354,7 +358,8 @@ struct snd_soc_dai stac9766_dai[] = {
354 }, 358 },
355 /* alsa ops */ 359 /* alsa ops */
356 .ops = &stac9766_dai_ops_digital, 360 .ops = &stac9766_dai_ops_digital,
357}}; 361}
362};
358EXPORT_SYMBOL_GPL(stac9766_dai); 363EXPORT_SYMBOL_GPL(stac9766_dai);
359 364
360static int stac9766_codec_probe(struct platform_device *pdev) 365static int stac9766_codec_probe(struct platform_device *pdev)
@@ -371,7 +376,8 @@ static int stac9766_codec_probe(struct platform_device *pdev)
371 codec = socdev->card->codec; 376 codec = socdev->card->codec;
372 mutex_init(&codec->mutex); 377 mutex_init(&codec->mutex);
373 378
374 codec->reg_cache = kmemdup(stac9766_reg, sizeof(stac9766_reg), GFP_KERNEL); 379 codec->reg_cache = kmemdup(stac9766_reg, sizeof(stac9766_reg),
380 GFP_KERNEL);
375 if (codec->reg_cache == NULL) { 381 if (codec->reg_cache == NULL) {
376 ret = -ENOMEM; 382 ret = -ENOMEM;
377 goto cache_err; 383 goto cache_err;
@@ -409,8 +415,8 @@ static int stac9766_codec_probe(struct platform_device *pdev)
409 415
410 stac9766_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 416 stac9766_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
411 417
412 snd_soc_add_controls(codec, stac9766_snd_ac97_controls, ARRAY_SIZE( 418 snd_soc_add_controls(codec, stac9766_snd_ac97_controls,
413 stac9766_snd_ac97_controls)); 419 ARRAY_SIZE(stac9766_snd_ac97_controls));
414 420
415 ret = snd_soc_init_card(socdev); 421 ret = snd_soc_init_card(socdev);
416 if (ret < 0) 422 if (ret < 0)
@@ -444,8 +450,7 @@ static int stac9766_codec_remove(struct platform_device *pdev)
444 return 0; 450 return 0;
445} 451}
446 452
447struct snd_soc_codec_device soc_codec_dev_stac9766 = 453struct snd_soc_codec_device soc_codec_dev_stac9766 = {
448{
449 .probe = stac9766_codec_probe, 454 .probe = stac9766_codec_probe,
450 .remove = stac9766_codec_remove, 455 .remove = stac9766_codec_remove,
451 .suspend = stac9766_codec_suspend, 456 .suspend = stac9766_codec_suspend,
@@ -453,18 +458,6 @@ struct snd_soc_codec_device soc_codec_dev_stac9766 =
453}; 458};
454EXPORT_SYMBOL_GPL(soc_codec_dev_stac9766); 459EXPORT_SYMBOL_GPL(soc_codec_dev_stac9766);
455 460
456static int __init stac9766_modinit(void)
457{
458 return snd_soc_register_dais(stac9766_dai, ARRAY_SIZE(stac9766_dai));
459}
460module_init(stac9766_modinit);
461
462static void __exit stac9766_exit(void)
463{
464 snd_soc_unregister_dais(stac9766_dai, ARRAY_SIZE(stac9766_dai));
465}
466module_exit(stac9766_exit);
467
468MODULE_DESCRIPTION("ASoC stac9766 driver"); 461MODULE_DESCRIPTION("ASoC stac9766 driver");
469MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>"); 462MODULE_AUTHOR("Jon Smirl <jonsmirl@gmail.com>");
470MODULE_LICENSE("GPL"); 463MODULE_LICENSE("GPL");