18 #include <linux/slab.h>
19 #include <linux/module.h>
20 #include <linux/device.h>
31 #define STAC9766_VERSION "0.10"
36 static const u16 stac9766_reg[] = {
37 0x6A90, 0x8000, 0x8000, 0x8000,
38 0x0000, 0x0000, 0x8008, 0x8008,
39 0x8808, 0x8808, 0x8808, 0x8808,
40 0x8808, 0x0000, 0x8000, 0x0000,
41 0x0000, 0x0000, 0x0000, 0x000f,
42 0x0a05, 0x0400, 0xbb80, 0x0000,
43 0x0000, 0xbb80, 0x0000, 0x0000,
44 0x0000, 0x2000, 0x0000, 0x0100,
45 0x0000, 0x0000, 0x0080, 0x0000,
46 0x0000, 0x0000, 0x0003, 0xffff,
47 0x0000, 0x0000, 0x0000, 0x0000,
48 0x4000, 0x0000, 0x0000, 0x0000,
49 0x1201, 0xFFFF, 0xFFFF, 0x0000,
50 0x0000, 0x0000, 0x0000, 0x0000,
51 0x0000, 0x0000, 0x0000, 0x0006,
52 0x0000, 0x0000, 0x0000, 0x0000,
55 static const char *stac9766_record_mux[] = {
"Mic",
"CD",
"Video",
"AUX",
56 "Line",
"Stereo Mix",
"Mono Mix",
"Phone"};
57 static const char *stac9766_mono_mux[] = {
"Mix",
"Mic"};
58 static const char *stac9766_mic_mux[] = {
"Mic1",
"Mic2"};
59 static const char *stac9766_SPDIF_mux[] = {
"PCM",
"ADC Record"};
60 static const char *stac9766_popbypass_mux[] = {
"Normal",
"Bypass Mixer"};
61 static const char *stac9766_record_all_mux[] = {
"All analog",
63 static const char *stac9766_boost1[] = {
"0dB",
"10dB"};
64 static const char *stac9766_boost2[] = {
"0dB",
"20dB"};
65 static const char *stac9766_stereo_mic[] = {
"Off",
"On"};
67 static const struct soc_enum stac9766_record_enum =
69 static const struct soc_enum stac9766_mono_enum =
71 static const struct soc_enum stac9766_mic_enum =
73 static const struct soc_enum stac9766_SPDIF_enum =
75 static const struct soc_enum stac9766_popbypass_enum =
77 static const struct soc_enum stac9766_record_all_enum =
79 stac9766_record_all_mux);
80 static const struct soc_enum stac9766_boost1_enum =
82 static const struct soc_enum stac9766_boost2_enum =
84 static const struct soc_enum stac9766_stereo_mic_enum =
112 SOC_ENUM(
"Mic Boost1", stac9766_boost1_enum),
113 SOC_ENUM(
"Mic Boost2", stac9766_boost2_enum),
116 SOC_ENUM(
"Stereo Mic", stac9766_stereo_mic_enum),
133 SOC_ENUM(
"SPDIF Mux", stac9766_SPDIF_enum),
134 SOC_ENUM(
"Mic1/2 Mux", stac9766_mic_enum),
135 SOC_ENUM(
"Record All Mux", stac9766_record_all_enum),
136 SOC_ENUM(
"Record Mux", stac9766_record_enum),
137 SOC_ENUM(
"Mono Mux", stac9766_mono_enum),
138 SOC_ENUM(
"Pop Bypass Mux", stac9766_popbypass_enum),
156 cache[reg / 2] =
val;
160 static unsigned int stac9766_ac97_read(
struct snd_soc_codec *codec,
181 return cache[reg / 2];
189 unsigned short reg, vra;
203 return stac9766_ac97_write(codec, reg, runtime->
rate);
211 unsigned short reg, vra;
213 stac9766_ac97_write(codec,
AC97_SPDIF, 0x2002);
222 return stac9766_ac97_write(codec, reg, runtime->
rate);
225 static int stac9766_set_bias_level(
struct snd_soc_codec *codec,
243 static int stac9766_reset(
struct snd_soc_codec *codec,
int try_warm)
247 if (stac9766_ac97_read(codec, 0) == stac9766_reg[0])
254 if (stac9766_ac97_read(codec, 0) != stac9766_reg[0])
259 static int stac9766_codec_suspend(
struct snd_soc_codec *codec)
265 static int stac9766_codec_resume(
struct snd_soc_codec *codec)
276 codec->
ac97->bus->ops->warm_reset(codec->
ac97);
279 stac9766_reset(codec, 0);
289 .prepare = ac97_analog_prepare,
293 .prepare = ac97_digital_prepare,
298 .name =
"stac9766-hifi-analog",
303 .stream_name =
"stac9766 analog",
310 .stream_name =
"stac9766 analog",
317 .ops = &stac9766_dai_ops_analog,
320 .name =
"stac9766-hifi-IEC958",
325 .stream_name =
"stac9766 IEC958",
333 .ops = &stac9766_dai_ops_digital,
349 stac9766_reset(codec, 0);
350 ret = stac9766_reset(codec, 1);
368 static int stac9766_codec_remove(
struct snd_soc_codec *codec)
375 .write = stac9766_ac97_write,
376 .read = stac9766_ac97_read,
377 .set_bias_level = stac9766_set_bias_level,
378 .probe = stac9766_codec_probe,
379 .remove = stac9766_codec_remove,
380 .suspend = stac9766_codec_suspend,
381 .resume = stac9766_codec_resume,
383 .reg_word_size =
sizeof(
u16),
391 &soc_codec_dev_stac9766, stac9766_dai,
ARRAY_SIZE(stac9766_dai));
402 .name =
"stac9766-codec",
406 .probe = stac9766_probe,