diff options
Diffstat (limited to 'sound')
118 files changed, 7669 insertions, 4528 deletions
diff --git a/sound/Kconfig b/sound/Kconfig index 1eceb85287c5..439e15c8faa3 100644 --- a/sound/Kconfig +++ b/sound/Kconfig | |||
@@ -32,6 +32,34 @@ config SOUND_OSS_CORE | |||
32 | bool | 32 | bool |
33 | default n | 33 | default n |
34 | 34 | ||
35 | config SOUND_OSS_CORE_PRECLAIM | ||
36 | bool "Preclaim OSS device numbers" | ||
37 | depends on SOUND_OSS_CORE | ||
38 | default y | ||
39 | help | ||
40 | With this option enabled, the kernel will claim all OSS device | ||
41 | numbers if any OSS support (native or emulation) is enabled | ||
42 | whether the respective module is loaded or not and try to load the | ||
43 | appropriate module using sound-slot/service-* and char-major-* | ||
44 | module aliases when one of the device numbers is opened. With | ||
45 | this option disabled, kernel will only claim actually in-use | ||
46 | device numbers and opening a missing device will generate only the | ||
47 | standard char-major-* aliases. | ||
48 | |||
49 | The only visible difference is use of additional module aliases | ||
50 | and whether OSS sound devices appear multiple times in | ||
51 | /proc/devices. sound-slot/service-* module aliases are scheduled | ||
52 | to be removed (ie. PRECLAIM won't be available) and this option is | ||
53 | to make the transition easier. This option can be overridden | ||
54 | during boot using the kernel parameter soundcore.preclaim_oss. | ||
55 | |||
56 | Disabling this allows alternative OSS implementations. | ||
57 | |||
58 | Please read Documentation/feature-removal-schedule.txt for | ||
59 | details. | ||
60 | |||
61 | If unusre, say Y. | ||
62 | |||
35 | source "sound/oss/dmasound/Kconfig" | 63 | source "sound/oss/dmasound/Kconfig" |
36 | 64 | ||
37 | if !M68K | 65 | if !M68K |
diff --git a/sound/aoa/core/gpio-pmf.c b/sound/aoa/core/gpio-pmf.c index 5ca2220eac7d..1dd0c28d1fb7 100644 --- a/sound/aoa/core/gpio-pmf.c +++ b/sound/aoa/core/gpio-pmf.c | |||
@@ -182,6 +182,10 @@ static int pmf_set_notify(struct gpio_runtime *rt, | |||
182 | if (!old && notify) { | 182 | if (!old && notify) { |
183 | irq_client = kzalloc(sizeof(struct pmf_irq_client), | 183 | irq_client = kzalloc(sizeof(struct pmf_irq_client), |
184 | GFP_KERNEL); | 184 | GFP_KERNEL); |
185 | if (!irq_client) { | ||
186 | err = -ENOMEM; | ||
187 | goto out_unlock; | ||
188 | } | ||
185 | irq_client->data = notif; | 189 | irq_client->data = notif; |
186 | irq_client->handler = pmf_handle_notify_irq; | 190 | irq_client->handler = pmf_handle_notify_irq; |
187 | irq_client->owner = THIS_MODULE; | 191 | irq_client->owner = THIS_MODULE; |
diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 6061fb5f4e1c..c15682a2f9db 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig | |||
@@ -206,4 +206,8 @@ config SND_PCM_XRUN_DEBUG | |||
206 | config SND_VMASTER | 206 | config SND_VMASTER |
207 | bool | 207 | bool |
208 | 208 | ||
209 | config SND_DMA_SGBUF | ||
210 | def_bool y | ||
211 | depends on X86 | ||
212 | |||
209 | source "sound/core/seq/Kconfig" | 213 | source "sound/core/seq/Kconfig" |
diff --git a/sound/core/Makefile b/sound/core/Makefile index 4229052e7b91..350a08d277f4 100644 --- a/sound/core/Makefile +++ b/sound/core/Makefile | |||
@@ -13,7 +13,7 @@ snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \ | |||
13 | pcm_memory.o | 13 | pcm_memory.o |
14 | 14 | ||
15 | snd-page-alloc-y := memalloc.o | 15 | snd-page-alloc-y := memalloc.o |
16 | snd-page-alloc-$(CONFIG_HAS_DMA) += sgbuf.o | 16 | snd-page-alloc-$(CONFIG_SND_DMA_SGBUF) += sgbuf.o |
17 | 17 | ||
18 | snd-rawmidi-objs := rawmidi.o | 18 | snd-rawmidi-objs := rawmidi.o |
19 | snd-timer-objs := timer.o | 19 | snd-timer-objs := timer.o |
diff --git a/sound/core/control.c b/sound/core/control.c index 17b8d47a5cd0..a8b7fabe645e 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -414,7 +414,7 @@ int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id) | |||
414 | EXPORT_SYMBOL(snd_ctl_remove_id); | 414 | EXPORT_SYMBOL(snd_ctl_remove_id); |
415 | 415 | ||
416 | /** | 416 | /** |
417 | * snd_ctl_remove_unlocked_id - remove the unlocked control of the given id and release it | 417 | * snd_ctl_remove_user_ctl - remove and release the unlocked user control |
418 | * @file: active control handle | 418 | * @file: active control handle |
419 | * @id: the control id to remove | 419 | * @id: the control id to remove |
420 | * | 420 | * |
@@ -423,8 +423,8 @@ EXPORT_SYMBOL(snd_ctl_remove_id); | |||
423 | * | 423 | * |
424 | * Returns 0 if successful, or a negative error code on failure. | 424 | * Returns 0 if successful, or a negative error code on failure. |
425 | */ | 425 | */ |
426 | static int snd_ctl_remove_unlocked_id(struct snd_ctl_file * file, | 426 | static int snd_ctl_remove_user_ctl(struct snd_ctl_file * file, |
427 | struct snd_ctl_elem_id *id) | 427 | struct snd_ctl_elem_id *id) |
428 | { | 428 | { |
429 | struct snd_card *card = file->card; | 429 | struct snd_card *card = file->card; |
430 | struct snd_kcontrol *kctl; | 430 | struct snd_kcontrol *kctl; |
@@ -433,15 +433,23 @@ static int snd_ctl_remove_unlocked_id(struct snd_ctl_file * file, | |||
433 | down_write(&card->controls_rwsem); | 433 | down_write(&card->controls_rwsem); |
434 | kctl = snd_ctl_find_id(card, id); | 434 | kctl = snd_ctl_find_id(card, id); |
435 | if (kctl == NULL) { | 435 | if (kctl == NULL) { |
436 | up_write(&card->controls_rwsem); | 436 | ret = -ENOENT; |
437 | return -ENOENT; | 437 | goto error; |
438 | } | ||
439 | if (!(kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_USER)) { | ||
440 | ret = -EINVAL; | ||
441 | goto error; | ||
438 | } | 442 | } |
439 | for (idx = 0; idx < kctl->count; idx++) | 443 | for (idx = 0; idx < kctl->count; idx++) |
440 | if (kctl->vd[idx].owner != NULL && kctl->vd[idx].owner != file) { | 444 | if (kctl->vd[idx].owner != NULL && kctl->vd[idx].owner != file) { |
441 | up_write(&card->controls_rwsem); | 445 | ret = -EBUSY; |
442 | return -EBUSY; | 446 | goto error; |
443 | } | 447 | } |
444 | ret = snd_ctl_remove(card, kctl); | 448 | ret = snd_ctl_remove(card, kctl); |
449 | if (ret < 0) | ||
450 | goto error; | ||
451 | card->user_ctl_count--; | ||
452 | error: | ||
445 | up_write(&card->controls_rwsem); | 453 | up_write(&card->controls_rwsem); |
446 | return ret; | 454 | return ret; |
447 | } | 455 | } |
@@ -951,7 +959,7 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, | |||
951 | 959 | ||
952 | if (card->user_ctl_count >= MAX_USER_CONTROLS) | 960 | if (card->user_ctl_count >= MAX_USER_CONTROLS) |
953 | return -ENOMEM; | 961 | return -ENOMEM; |
954 | if (info->count > 1024) | 962 | if (info->count < 1) |
955 | return -EINVAL; | 963 | return -EINVAL; |
956 | access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : | 964 | access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : |
957 | (info->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE| | 965 | (info->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE| |
@@ -1052,18 +1060,10 @@ static int snd_ctl_elem_remove(struct snd_ctl_file *file, | |||
1052 | struct snd_ctl_elem_id __user *_id) | 1060 | struct snd_ctl_elem_id __user *_id) |
1053 | { | 1061 | { |
1054 | struct snd_ctl_elem_id id; | 1062 | struct snd_ctl_elem_id id; |
1055 | int err; | ||
1056 | 1063 | ||
1057 | if (copy_from_user(&id, _id, sizeof(id))) | 1064 | if (copy_from_user(&id, _id, sizeof(id))) |
1058 | return -EFAULT; | 1065 | return -EFAULT; |
1059 | err = snd_ctl_remove_unlocked_id(file, &id); | 1066 | return snd_ctl_remove_user_ctl(file, &id); |
1060 | if (! err) { | ||
1061 | struct snd_card *card = file->card; | ||
1062 | down_write(&card->controls_rwsem); | ||
1063 | card->user_ctl_count--; | ||
1064 | up_write(&card->controls_rwsem); | ||
1065 | } | ||
1066 | return err; | ||
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | static int snd_ctl_subscribe_events(struct snd_ctl_file *file, int __user *ptr) | 1069 | static int snd_ctl_subscribe_events(struct snd_ctl_file *file, int __user *ptr) |
diff --git a/sound/core/info.c b/sound/core/info.c index 35df614f6c55..d749a0d394a7 100644 --- a/sound/core/info.c +++ b/sound/core/info.c | |||
@@ -88,12 +88,10 @@ static int resize_info_buffer(struct snd_info_buffer *buffer, | |||
88 | char *nbuf; | 88 | char *nbuf; |
89 | 89 | ||
90 | nsize = PAGE_ALIGN(nsize); | 90 | nsize = PAGE_ALIGN(nsize); |
91 | nbuf = kmalloc(nsize, GFP_KERNEL); | 91 | nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL); |
92 | if (! nbuf) | 92 | if (! nbuf) |
93 | return -ENOMEM; | 93 | return -ENOMEM; |
94 | 94 | ||
95 | memcpy(nbuf, buffer->buffer, buffer->len); | ||
96 | kfree(buffer->buffer); | ||
97 | buffer->buffer = nbuf; | 95 | buffer->buffer = nbuf; |
98 | buffer->len = nsize; | 96 | buffer->len = nsize; |
99 | return 0; | 97 | return 0; |
@@ -108,7 +106,7 @@ static int resize_info_buffer(struct snd_info_buffer *buffer, | |||
108 | * | 106 | * |
109 | * Returns the size of output string. | 107 | * Returns the size of output string. |
110 | */ | 108 | */ |
111 | int snd_iprintf(struct snd_info_buffer *buffer, char *fmt,...) | 109 | int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...) |
112 | { | 110 | { |
113 | va_list args; | 111 | va_list args; |
114 | int len, res; | 112 | int len, res; |
@@ -727,7 +725,7 @@ EXPORT_SYMBOL(snd_info_get_line); | |||
727 | * Returns the updated pointer of the original string so that | 725 | * Returns the updated pointer of the original string so that |
728 | * it can be used for the next call. | 726 | * it can be used for the next call. |
729 | */ | 727 | */ |
730 | char *snd_info_get_str(char *dest, char *src, int len) | 728 | const char *snd_info_get_str(char *dest, const char *src, int len) |
731 | { | 729 | { |
732 | int c; | 730 | int c; |
733 | 731 | ||
diff --git a/sound/core/init.c b/sound/core/init.c index d5d40d78c409..ec4a50ce5656 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -31,6 +31,14 @@ | |||
31 | #include <sound/control.h> | 31 | #include <sound/control.h> |
32 | #include <sound/info.h> | 32 | #include <sound/info.h> |
33 | 33 | ||
34 | /* monitor files for graceful shutdown (hotplug) */ | ||
35 | struct snd_monitor_file { | ||
36 | struct file *file; | ||
37 | const struct file_operations *disconnected_f_op; | ||
38 | struct list_head shutdown_list; /* still need to shutdown */ | ||
39 | struct list_head list; /* link of monitor files */ | ||
40 | }; | ||
41 | |||
34 | static DEFINE_SPINLOCK(shutdown_lock); | 42 | static DEFINE_SPINLOCK(shutdown_lock); |
35 | static LIST_HEAD(shutdown_files); | 43 | static LIST_HEAD(shutdown_files); |
36 | 44 | ||
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 1b3534d67686..9e92441f9b78 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c | |||
@@ -199,6 +199,8 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size, | |||
199 | case SNDRV_DMA_TYPE_DEV: | 199 | case SNDRV_DMA_TYPE_DEV: |
200 | dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr); | 200 | dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr); |
201 | break; | 201 | break; |
202 | #endif | ||
203 | #ifdef CONFIG_SND_DMA_SGBUF | ||
202 | case SNDRV_DMA_TYPE_DEV_SG: | 204 | case SNDRV_DMA_TYPE_DEV_SG: |
203 | snd_malloc_sgbuf_pages(device, size, dmab, NULL); | 205 | snd_malloc_sgbuf_pages(device, size, dmab, NULL); |
204 | break; | 206 | break; |
@@ -269,6 +271,8 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab) | |||
269 | case SNDRV_DMA_TYPE_DEV: | 271 | case SNDRV_DMA_TYPE_DEV: |
270 | snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr); | 272 | snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr); |
271 | break; | 273 | break; |
274 | #endif | ||
275 | #ifdef CONFIG_SND_DMA_SGBUF | ||
272 | case SNDRV_DMA_TYPE_DEV_SG: | 276 | case SNDRV_DMA_TYPE_DEV_SG: |
273 | snd_free_sgbuf_pages(dmab); | 277 | snd_free_sgbuf_pages(dmab); |
274 | break; | 278 | break; |
diff --git a/sound/core/misc.c b/sound/core/misc.c index a9710e0c97af..23a032c6d487 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c | |||
@@ -24,6 +24,20 @@ | |||
24 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
25 | #include <sound/core.h> | 25 | #include <sound/core.h> |
26 | 26 | ||
27 | #ifdef CONFIG_SND_DEBUG | ||
28 | |||
29 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
30 | #define DEFAULT_DEBUG_LEVEL 2 | ||
31 | #else | ||
32 | #define DEFAULT_DEBUG_LEVEL 1 | ||
33 | #endif | ||
34 | |||
35 | static int debug = DEFAULT_DEBUG_LEVEL; | ||
36 | module_param(debug, int, 0644); | ||
37 | MODULE_PARM_DESC(debug, "Debug level (0 = disable)"); | ||
38 | |||
39 | #endif /* CONFIG_SND_DEBUG */ | ||
40 | |||
27 | void release_and_free_resource(struct resource *res) | 41 | void release_and_free_resource(struct resource *res) |
28 | { | 42 | { |
29 | if (res) { | 43 | if (res) { |
@@ -35,46 +49,53 @@ void release_and_free_resource(struct resource *res) | |||
35 | EXPORT_SYMBOL(release_and_free_resource); | 49 | EXPORT_SYMBOL(release_and_free_resource); |
36 | 50 | ||
37 | #ifdef CONFIG_SND_VERBOSE_PRINTK | 51 | #ifdef CONFIG_SND_VERBOSE_PRINTK |
38 | void snd_verbose_printk(const char *file, int line, const char *format, ...) | 52 | /* strip the leading path if the given path is absolute */ |
53 | static const char *sanity_file_name(const char *path) | ||
39 | { | 54 | { |
40 | va_list args; | 55 | if (*path == '/') |
41 | 56 | return strrchr(path, '/') + 1; | |
42 | if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') { | 57 | else |
43 | char tmp[] = "<0>"; | 58 | return path; |
59 | } | ||
60 | |||
61 | /* print file and line with a certain printk prefix */ | ||
62 | static int print_snd_pfx(unsigned int level, const char *path, int line, | ||
63 | const char *format) | ||
64 | { | ||
65 | const char *file = sanity_file_name(path); | ||
66 | char tmp[] = "<0>"; | ||
67 | const char *pfx = level ? KERN_DEBUG : KERN_DEFAULT; | ||
68 | int ret = 0; | ||
69 | |||
70 | if (format[0] == '<' && format[2] == '>') { | ||
44 | tmp[1] = format[1]; | 71 | tmp[1] = format[1]; |
45 | printk("%sALSA %s:%d: ", tmp, file, line); | 72 | pfx = tmp; |
46 | format += 3; | 73 | ret = 1; |
47 | } else { | ||
48 | printk("ALSA %s:%d: ", file, line); | ||
49 | } | 74 | } |
50 | va_start(args, format); | 75 | printk("%sALSA %s:%d: ", pfx, file, line); |
51 | vprintk(format, args); | 76 | return ret; |
52 | va_end(args); | ||
53 | } | 77 | } |
54 | 78 | #else | |
55 | EXPORT_SYMBOL(snd_verbose_printk); | 79 | #define print_snd_pfx(level, path, line, format) 0 |
56 | #endif | 80 | #endif |
57 | 81 | ||
58 | #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK) | 82 | #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) |
59 | void snd_verbose_printd(const char *file, int line, const char *format, ...) | 83 | void __snd_printk(unsigned int level, const char *path, int line, |
84 | const char *format, ...) | ||
60 | { | 85 | { |
61 | va_list args; | 86 | va_list args; |
62 | 87 | ||
63 | if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') { | 88 | #ifdef CONFIG_SND_DEBUG |
64 | char tmp[] = "<0>"; | 89 | if (debug < level) |
65 | tmp[1] = format[1]; | 90 | return; |
66 | printk("%sALSA %s:%d: ", tmp, file, line); | 91 | #endif |
67 | format += 3; | ||
68 | } else { | ||
69 | printk(KERN_DEBUG "ALSA %s:%d: ", file, line); | ||
70 | } | ||
71 | va_start(args, format); | 92 | va_start(args, format); |
93 | if (print_snd_pfx(level, path, line, format)) | ||
94 | format += 3; /* skip the printk level-prefix */ | ||
72 | vprintk(format, args); | 95 | vprintk(format, args); |
73 | va_end(args); | 96 | va_end(args); |
74 | |||
75 | } | 97 | } |
76 | 98 | EXPORT_SYMBOL_GPL(__snd_printk); | |
77 | EXPORT_SYMBOL(snd_verbose_printd); | ||
78 | #endif | 99 | #endif |
79 | 100 | ||
80 | #ifdef CONFIG_PCI | 101 | #ifdef CONFIG_PCI |
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 5dcd8a526970..772423889eb3 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c | |||
@@ -1154,7 +1154,8 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry, | |||
1154 | struct snd_info_buffer *buffer) | 1154 | struct snd_info_buffer *buffer) |
1155 | { | 1155 | { |
1156 | struct snd_mixer_oss *mixer = entry->private_data; | 1156 | struct snd_mixer_oss *mixer = entry->private_data; |
1157 | char line[128], str[32], idxstr[16], *cptr; | 1157 | char line[128], str[32], idxstr[16]; |
1158 | const char *cptr; | ||
1158 | int ch, idx; | 1159 | int ch, idx; |
1159 | struct snd_mixer_oss_assign_table *tbl; | 1160 | struct snd_mixer_oss_assign_table *tbl; |
1160 | struct slot *slot; | 1161 | struct slot *slot; |
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index dbe406b82591..d9c96353121a 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c | |||
@@ -1043,10 +1043,15 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) | |||
1043 | runtime->oss.channels = params_channels(params); | 1043 | runtime->oss.channels = params_channels(params); |
1044 | runtime->oss.rate = params_rate(params); | 1044 | runtime->oss.rate = params_rate(params); |
1045 | 1045 | ||
1046 | runtime->oss.params = 0; | ||
1047 | runtime->oss.prepare = 1; | ||
1048 | vfree(runtime->oss.buffer); | 1046 | vfree(runtime->oss.buffer); |
1049 | runtime->oss.buffer = vmalloc(runtime->oss.period_bytes); | 1047 | runtime->oss.buffer = vmalloc(runtime->oss.period_bytes); |
1048 | if (!runtime->oss.buffer) { | ||
1049 | err = -ENOMEM; | ||
1050 | goto failure; | ||
1051 | } | ||
1052 | |||
1053 | runtime->oss.params = 0; | ||
1054 | runtime->oss.prepare = 1; | ||
1050 | runtime->oss.buffer_used = 0; | 1055 | runtime->oss.buffer_used = 0; |
1051 | if (runtime->dma_area) | 1056 | if (runtime->dma_area) |
1052 | snd_pcm_format_set_silence(runtime->format, runtime->dma_area, bytes_to_samples(runtime, runtime->dma_bytes)); | 1057 | snd_pcm_format_set_silence(runtime->format, runtime->dma_area, bytes_to_samples(runtime, runtime->dma_bytes)); |
@@ -2836,7 +2841,8 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry, | |||
2836 | struct snd_info_buffer *buffer) | 2841 | struct snd_info_buffer *buffer) |
2837 | { | 2842 | { |
2838 | struct snd_pcm_str *pstr = entry->private_data; | 2843 | struct snd_pcm_str *pstr = entry->private_data; |
2839 | char line[128], str[32], task_name[32], *ptr; | 2844 | char line[128], str[32], task_name[32]; |
2845 | const char *ptr; | ||
2840 | int idx1; | 2846 | int idx1; |
2841 | struct snd_pcm_oss_setup *setup, *setup1, template; | 2847 | struct snd_pcm_oss_setup *setup, *setup1, template; |
2842 | 2848 | ||
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 145931a9ff30..0c1440121c22 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -162,18 +162,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, | |||
162 | return -ENOIOCTLCMD; | 162 | return -ENOIOCTLCMD; |
163 | } | 163 | } |
164 | 164 | ||
165 | #ifdef CONFIG_SND_VERBOSE_PROCFS | ||
166 | |||
167 | #define STATE(v) [SNDRV_PCM_STATE_##v] = #v | ||
168 | #define STREAM(v) [SNDRV_PCM_STREAM_##v] = #v | ||
169 | #define READY(v) [SNDRV_PCM_READY_##v] = #v | ||
170 | #define XRUN(v) [SNDRV_PCM_XRUN_##v] = #v | ||
171 | #define SILENCE(v) [SNDRV_PCM_SILENCE_##v] = #v | ||
172 | #define TSTAMP(v) [SNDRV_PCM_TSTAMP_##v] = #v | ||
173 | #define ACCESS(v) [SNDRV_PCM_ACCESS_##v] = #v | ||
174 | #define START(v) [SNDRV_PCM_START_##v] = #v | ||
175 | #define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v | 165 | #define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v |
176 | #define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v | ||
177 | 166 | ||
178 | static char *snd_pcm_format_names[] = { | 167 | static char *snd_pcm_format_names[] = { |
179 | FORMAT(S8), | 168 | FORMAT(S8), |
@@ -216,10 +205,23 @@ static char *snd_pcm_format_names[] = { | |||
216 | FORMAT(U18_3BE), | 205 | FORMAT(U18_3BE), |
217 | }; | 206 | }; |
218 | 207 | ||
219 | static const char *snd_pcm_format_name(snd_pcm_format_t format) | 208 | const char *snd_pcm_format_name(snd_pcm_format_t format) |
220 | { | 209 | { |
221 | return snd_pcm_format_names[format]; | 210 | return snd_pcm_format_names[format]; |
222 | } | 211 | } |
212 | EXPORT_SYMBOL_GPL(snd_pcm_format_name); | ||
213 | |||
214 | #ifdef CONFIG_SND_VERBOSE_PROCFS | ||
215 | |||
216 | #define STATE(v) [SNDRV_PCM_STATE_##v] = #v | ||
217 | #define STREAM(v) [SNDRV_PCM_STREAM_##v] = #v | ||
218 | #define READY(v) [SNDRV_PCM_READY_##v] = #v | ||
219 | #define XRUN(v) [SNDRV_PCM_XRUN_##v] = #v | ||
220 | #define SILENCE(v) [SNDRV_PCM_SILENCE_##v] = #v | ||
221 | #define TSTAMP(v) [SNDRV_PCM_TSTAMP_##v] = #v | ||
222 | #define ACCESS(v) [SNDRV_PCM_ACCESS_##v] = #v | ||
223 | #define START(v) [SNDRV_PCM_START_##v] = #v | ||
224 | #define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v | ||
223 | 225 | ||
224 | static char *snd_pcm_stream_names[] = { | 226 | static char *snd_pcm_stream_names[] = { |
225 | STREAM(PLAYBACK), | 227 | STREAM(PLAYBACK), |
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 333e4dd29450..30f410832a25 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -197,12 +197,16 @@ static int snd_pcm_update_hw_ptr_post(struct snd_pcm_substream *substream, | |||
197 | avail = snd_pcm_capture_avail(runtime); | 197 | avail = snd_pcm_capture_avail(runtime); |
198 | if (avail > runtime->avail_max) | 198 | if (avail > runtime->avail_max) |
199 | runtime->avail_max = avail; | 199 | runtime->avail_max = avail; |
200 | if (avail >= runtime->stop_threshold) { | 200 | if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { |
201 | if (substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING) | 201 | if (avail >= runtime->buffer_size) { |
202 | snd_pcm_drain_done(substream); | 202 | snd_pcm_drain_done(substream); |
203 | else | 203 | return -EPIPE; |
204 | } | ||
205 | } else { | ||
206 | if (avail >= runtime->stop_threshold) { | ||
204 | xrun(substream); | 207 | xrun(substream); |
205 | return -EPIPE; | 208 | return -EPIPE; |
209 | } | ||
206 | } | 210 | } |
207 | if (avail >= runtime->control->avail_min) | 211 | if (avail >= runtime->control->avail_min) |
208 | wake_up(&runtime->sleep); | 212 | wake_up(&runtime->sleep); |
@@ -233,6 +237,18 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | |||
233 | xrun(substream); | 237 | xrun(substream); |
234 | return -EPIPE; | 238 | return -EPIPE; |
235 | } | 239 | } |
240 | if (xrun_debug(substream, 8)) { | ||
241 | char name[16]; | ||
242 | pcm_debug_name(substream, name, sizeof(name)); | ||
243 | snd_printd("period_update: %s: pos=0x%x/0x%x/0x%x, " | ||
244 | "hwptr=0x%lx, hw_base=0x%lx, hw_intr=0x%lx\n", | ||
245 | name, (unsigned int)pos, | ||
246 | (unsigned int)runtime->period_size, | ||
247 | (unsigned int)runtime->buffer_size, | ||
248 | (unsigned long)old_hw_ptr, | ||
249 | (unsigned long)runtime->hw_ptr_base, | ||
250 | (unsigned long)runtime->hw_ptr_interrupt); | ||
251 | } | ||
236 | hw_base = runtime->hw_ptr_base; | 252 | hw_base = runtime->hw_ptr_base; |
237 | new_hw_ptr = hw_base + pos; | 253 | new_hw_ptr = hw_base + pos; |
238 | hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size; | 254 | hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size; |
@@ -244,18 +260,27 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | |||
244 | delta = new_hw_ptr - hw_ptr_interrupt; | 260 | delta = new_hw_ptr - hw_ptr_interrupt; |
245 | } | 261 | } |
246 | if (delta < 0) { | 262 | if (delta < 0) { |
247 | delta += runtime->buffer_size; | 263 | if (runtime->periods == 1 || new_hw_ptr < old_hw_ptr) |
264 | delta += runtime->buffer_size; | ||
248 | if (delta < 0) { | 265 | if (delta < 0) { |
249 | hw_ptr_error(substream, | 266 | hw_ptr_error(substream, |
250 | "Unexpected hw_pointer value " | 267 | "Unexpected hw_pointer value " |
251 | "(stream=%i, pos=%ld, intr_ptr=%ld)\n", | 268 | "(stream=%i, pos=%ld, intr_ptr=%ld)\n", |
252 | substream->stream, (long)pos, | 269 | substream->stream, (long)pos, |
253 | (long)hw_ptr_interrupt); | 270 | (long)hw_ptr_interrupt); |
271 | #if 1 | ||
272 | /* simply skipping the hwptr update seems more | ||
273 | * robust in some cases, e.g. on VMware with | ||
274 | * inaccurate timer source | ||
275 | */ | ||
276 | return 0; /* skip this update */ | ||
277 | #else | ||
254 | /* rebase to interrupt position */ | 278 | /* rebase to interrupt position */ |
255 | hw_base = new_hw_ptr = hw_ptr_interrupt; | 279 | hw_base = new_hw_ptr = hw_ptr_interrupt; |
256 | /* align hw_base to buffer_size */ | 280 | /* align hw_base to buffer_size */ |
257 | hw_base -= hw_base % runtime->buffer_size; | 281 | hw_base -= hw_base % runtime->buffer_size; |
258 | delta = 0; | 282 | delta = 0; |
283 | #endif | ||
259 | } else { | 284 | } else { |
260 | hw_base += runtime->buffer_size; | 285 | hw_base += runtime->buffer_size; |
261 | if (hw_base >= runtime->boundary) | 286 | if (hw_base >= runtime->boundary) |
@@ -344,6 +369,19 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) | |||
344 | xrun(substream); | 369 | xrun(substream); |
345 | return -EPIPE; | 370 | return -EPIPE; |
346 | } | 371 | } |
372 | if (xrun_debug(substream, 16)) { | ||
373 | char name[16]; | ||
374 | pcm_debug_name(substream, name, sizeof(name)); | ||
375 | snd_printd("hw_update: %s: pos=0x%x/0x%x/0x%x, " | ||
376 | "hwptr=0x%lx, hw_base=0x%lx, hw_intr=0x%lx\n", | ||
377 | name, (unsigned int)pos, | ||
378 | (unsigned int)runtime->period_size, | ||
379 | (unsigned int)runtime->buffer_size, | ||
380 | (unsigned long)old_hw_ptr, | ||
381 | (unsigned long)runtime->hw_ptr_base, | ||
382 | (unsigned long)runtime->hw_ptr_interrupt); | ||
383 | } | ||
384 | |||
347 | hw_base = runtime->hw_ptr_base; | 385 | hw_base = runtime->hw_ptr_base; |
348 | new_hw_ptr = hw_base + pos; | 386 | new_hw_ptr = hw_base + pos; |
349 | 387 | ||
@@ -909,47 +947,24 @@ static int snd_interval_ratden(struct snd_interval *i, | |||
909 | int snd_interval_list(struct snd_interval *i, unsigned int count, unsigned int *list, unsigned int mask) | 947 | int snd_interval_list(struct snd_interval *i, unsigned int count, unsigned int *list, unsigned int mask) |
910 | { | 948 | { |
911 | unsigned int k; | 949 | unsigned int k; |
912 | int changed = 0; | 950 | struct snd_interval list_range; |
913 | 951 | ||
914 | if (!count) { | 952 | if (!count) { |
915 | i->empty = 1; | 953 | i->empty = 1; |
916 | return -EINVAL; | 954 | return -EINVAL; |
917 | } | 955 | } |
956 | snd_interval_any(&list_range); | ||
957 | list_range.min = UINT_MAX; | ||
958 | list_range.max = 0; | ||
918 | for (k = 0; k < count; k++) { | 959 | for (k = 0; k < count; k++) { |
919 | if (mask && !(mask & (1 << k))) | 960 | if (mask && !(mask & (1 << k))) |
920 | continue; | 961 | continue; |
921 | if (i->min == list[k] && !i->openmin) | 962 | if (!snd_interval_test(i, list[k])) |
922 | goto _l1; | ||
923 | if (i->min < list[k]) { | ||
924 | i->min = list[k]; | ||
925 | i->openmin = 0; | ||
926 | changed = 1; | ||
927 | goto _l1; | ||
928 | } | ||
929 | } | ||
930 | i->empty = 1; | ||
931 | return -EINVAL; | ||
932 | _l1: | ||
933 | for (k = count; k-- > 0;) { | ||
934 | if (mask && !(mask & (1 << k))) | ||
935 | continue; | 963 | continue; |
936 | if (i->max == list[k] && !i->openmax) | 964 | list_range.min = min(list_range.min, list[k]); |
937 | goto _l2; | 965 | list_range.max = max(list_range.max, list[k]); |
938 | if (i->max > list[k]) { | ||
939 | i->max = list[k]; | ||
940 | i->openmax = 0; | ||
941 | changed = 1; | ||
942 | goto _l2; | ||
943 | } | ||
944 | } | 966 | } |
945 | i->empty = 1; | 967 | return snd_interval_refine(i, &list_range); |
946 | return -EINVAL; | ||
947 | _l2: | ||
948 | if (snd_interval_checkempty(i)) { | ||
949 | i->empty = 1; | ||
950 | return -EINVAL; | ||
951 | } | ||
952 | return changed; | ||
953 | } | 968 | } |
954 | 969 | ||
955 | EXPORT_SYMBOL(snd_interval_list); | 970 | EXPORT_SYMBOL(snd_interval_list); |
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index a6d42808828c..caa7796bc2f5 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c | |||
@@ -304,6 +304,7 @@ int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm, | |||
304 | 304 | ||
305 | EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages_for_all); | 305 | EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages_for_all); |
306 | 306 | ||
307 | #ifdef CONFIG_SND_DMA_SGBUF | ||
307 | /** | 308 | /** |
308 | * snd_pcm_sgbuf_ops_page - get the page struct at the given offset | 309 | * snd_pcm_sgbuf_ops_page - get the page struct at the given offset |
309 | * @substream: the pcm substream instance | 310 | * @substream: the pcm substream instance |
@@ -349,6 +350,7 @@ unsigned int snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, | |||
349 | return size; | 350 | return size; |
350 | } | 351 | } |
351 | EXPORT_SYMBOL(snd_pcm_sgbuf_get_chunk_size); | 352 | EXPORT_SYMBOL(snd_pcm_sgbuf_get_chunk_size); |
353 | #endif /* CONFIG_SND_DMA_SGBUF */ | ||
352 | 354 | ||
353 | /** | 355 | /** |
354 | * snd_pcm_lib_malloc_pages - allocate the DMA buffer | 356 | * snd_pcm_lib_malloc_pages - allocate the DMA buffer |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index ac2150e0670d..59e5fbe6af51 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -1343,8 +1343,6 @@ static int snd_pcm_prepare(struct snd_pcm_substream *substream, | |||
1343 | 1343 | ||
1344 | static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, int state) | 1344 | static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, int state) |
1345 | { | 1345 | { |
1346 | if (substream->f_flags & O_NONBLOCK) | ||
1347 | return -EAGAIN; | ||
1348 | substream->runtime->trigger_master = substream; | 1346 | substream->runtime->trigger_master = substream; |
1349 | return 0; | 1347 | return 0; |
1350 | } | 1348 | } |
@@ -1392,7 +1390,6 @@ static struct action_ops snd_pcm_action_drain_init = { | |||
1392 | struct drain_rec { | 1390 | struct drain_rec { |
1393 | struct snd_pcm_substream *substream; | 1391 | struct snd_pcm_substream *substream; |
1394 | wait_queue_t wait; | 1392 | wait_queue_t wait; |
1395 | snd_pcm_uframes_t stop_threshold; | ||
1396 | }; | 1393 | }; |
1397 | 1394 | ||
1398 | static int snd_pcm_drop(struct snd_pcm_substream *substream); | 1395 | static int snd_pcm_drop(struct snd_pcm_substream *substream); |
@@ -1404,13 +1401,15 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream); | |||
1404 | * After this call, all streams are supposed to be either SETUP or DRAINING | 1401 | * After this call, all streams are supposed to be either SETUP or DRAINING |
1405 | * (capture only) state. | 1402 | * (capture only) state. |
1406 | */ | 1403 | */ |
1407 | static int snd_pcm_drain(struct snd_pcm_substream *substream) | 1404 | static int snd_pcm_drain(struct snd_pcm_substream *substream, |
1405 | struct file *file) | ||
1408 | { | 1406 | { |
1409 | struct snd_card *card; | 1407 | struct snd_card *card; |
1410 | struct snd_pcm_runtime *runtime; | 1408 | struct snd_pcm_runtime *runtime; |
1411 | struct snd_pcm_substream *s; | 1409 | struct snd_pcm_substream *s; |
1412 | int result = 0; | 1410 | int result = 0; |
1413 | int i, num_drecs; | 1411 | int i, num_drecs; |
1412 | int nonblock = 0; | ||
1414 | struct drain_rec *drec, drec_tmp, *d; | 1413 | struct drain_rec *drec, drec_tmp, *d; |
1415 | 1414 | ||
1416 | card = substream->pcm->card; | 1415 | card = substream->pcm->card; |
@@ -1428,6 +1427,15 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream) | |||
1428 | } | 1427 | } |
1429 | } | 1428 | } |
1430 | 1429 | ||
1430 | if (file) { | ||
1431 | if (file->f_flags & O_NONBLOCK) | ||
1432 | nonblock = 1; | ||
1433 | } else if (substream->f_flags & O_NONBLOCK) | ||
1434 | nonblock = 1; | ||
1435 | |||
1436 | if (nonblock) | ||
1437 | goto lock; /* no need to allocate waitqueues */ | ||
1438 | |||
1431 | /* allocate temporary record for drain sync */ | 1439 | /* allocate temporary record for drain sync */ |
1432 | down_read(&snd_pcm_link_rwsem); | 1440 | down_read(&snd_pcm_link_rwsem); |
1433 | if (snd_pcm_stream_linked(substream)) { | 1441 | if (snd_pcm_stream_linked(substream)) { |
@@ -1449,16 +1457,11 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream) | |||
1449 | d->substream = s; | 1457 | d->substream = s; |
1450 | init_waitqueue_entry(&d->wait, current); | 1458 | init_waitqueue_entry(&d->wait, current); |
1451 | add_wait_queue(&runtime->sleep, &d->wait); | 1459 | add_wait_queue(&runtime->sleep, &d->wait); |
1452 | /* stop_threshold fixup to avoid endless loop when | ||
1453 | * stop_threshold > buffer_size | ||
1454 | */ | ||
1455 | d->stop_threshold = runtime->stop_threshold; | ||
1456 | if (runtime->stop_threshold > runtime->buffer_size) | ||
1457 | runtime->stop_threshold = runtime->buffer_size; | ||
1458 | } | 1460 | } |
1459 | } | 1461 | } |
1460 | up_read(&snd_pcm_link_rwsem); | 1462 | up_read(&snd_pcm_link_rwsem); |
1461 | 1463 | ||
1464 | lock: | ||
1462 | snd_pcm_stream_lock_irq(substream); | 1465 | snd_pcm_stream_lock_irq(substream); |
1463 | /* resume pause */ | 1466 | /* resume pause */ |
1464 | if (substream->runtime->status->state == SNDRV_PCM_STATE_PAUSED) | 1467 | if (substream->runtime->status->state == SNDRV_PCM_STATE_PAUSED) |
@@ -1466,9 +1469,12 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream) | |||
1466 | 1469 | ||
1467 | /* pre-start/stop - all running streams are changed to DRAINING state */ | 1470 | /* pre-start/stop - all running streams are changed to DRAINING state */ |
1468 | result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0); | 1471 | result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0); |
1469 | if (result < 0) { | 1472 | if (result < 0) |
1470 | snd_pcm_stream_unlock_irq(substream); | 1473 | goto unlock; |
1471 | goto _error; | 1474 | /* in non-blocking, we don't wait in ioctl but let caller poll */ |
1475 | if (nonblock) { | ||
1476 | result = -EAGAIN; | ||
1477 | goto unlock; | ||
1472 | } | 1478 | } |
1473 | 1479 | ||
1474 | for (;;) { | 1480 | for (;;) { |
@@ -1504,18 +1510,18 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream) | |||
1504 | } | 1510 | } |
1505 | } | 1511 | } |
1506 | 1512 | ||
1513 | unlock: | ||
1507 | snd_pcm_stream_unlock_irq(substream); | 1514 | snd_pcm_stream_unlock_irq(substream); |
1508 | 1515 | ||
1509 | _error: | 1516 | if (!nonblock) { |
1510 | for (i = 0; i < num_drecs; i++) { | 1517 | for (i = 0; i < num_drecs; i++) { |
1511 | d = &drec[i]; | 1518 | d = &drec[i]; |
1512 | runtime = d->substream->runtime; | 1519 | runtime = d->substream->runtime; |
1513 | remove_wait_queue(&runtime->sleep, &d->wait); | 1520 | remove_wait_queue(&runtime->sleep, &d->wait); |
1514 | runtime->stop_threshold = d->stop_threshold; | 1521 | } |
1522 | if (drec != &drec_tmp) | ||
1523 | kfree(drec); | ||
1515 | } | 1524 | } |
1516 | |||
1517 | if (drec != &drec_tmp) | ||
1518 | kfree(drec); | ||
1519 | snd_power_unlock(card); | 1525 | snd_power_unlock(card); |
1520 | 1526 | ||
1521 | return result; | 1527 | return result; |
@@ -2208,6 +2214,9 @@ static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *subst | |||
2208 | case SNDRV_PCM_STATE_XRUN: | 2214 | case SNDRV_PCM_STATE_XRUN: |
2209 | ret = -EPIPE; | 2215 | ret = -EPIPE; |
2210 | goto __end; | 2216 | goto __end; |
2217 | case SNDRV_PCM_STATE_SUSPENDED: | ||
2218 | ret = -ESTRPIPE; | ||
2219 | goto __end; | ||
2211 | default: | 2220 | default: |
2212 | ret = -EBADFD; | 2221 | ret = -EBADFD; |
2213 | goto __end; | 2222 | goto __end; |
@@ -2253,6 +2262,9 @@ static snd_pcm_sframes_t snd_pcm_capture_rewind(struct snd_pcm_substream *substr | |||
2253 | case SNDRV_PCM_STATE_XRUN: | 2262 | case SNDRV_PCM_STATE_XRUN: |
2254 | ret = -EPIPE; | 2263 | ret = -EPIPE; |
2255 | goto __end; | 2264 | goto __end; |
2265 | case SNDRV_PCM_STATE_SUSPENDED: | ||
2266 | ret = -ESTRPIPE; | ||
2267 | goto __end; | ||
2256 | default: | 2268 | default: |
2257 | ret = -EBADFD; | 2269 | ret = -EBADFD; |
2258 | goto __end; | 2270 | goto __end; |
@@ -2299,6 +2311,9 @@ static snd_pcm_sframes_t snd_pcm_playback_forward(struct snd_pcm_substream *subs | |||
2299 | case SNDRV_PCM_STATE_XRUN: | 2311 | case SNDRV_PCM_STATE_XRUN: |
2300 | ret = -EPIPE; | 2312 | ret = -EPIPE; |
2301 | goto __end; | 2313 | goto __end; |
2314 | case SNDRV_PCM_STATE_SUSPENDED: | ||
2315 | ret = -ESTRPIPE; | ||
2316 | goto __end; | ||
2302 | default: | 2317 | default: |
2303 | ret = -EBADFD; | 2318 | ret = -EBADFD; |
2304 | goto __end; | 2319 | goto __end; |
@@ -2345,6 +2360,9 @@ static snd_pcm_sframes_t snd_pcm_capture_forward(struct snd_pcm_substream *subst | |||
2345 | case SNDRV_PCM_STATE_XRUN: | 2360 | case SNDRV_PCM_STATE_XRUN: |
2346 | ret = -EPIPE; | 2361 | ret = -EPIPE; |
2347 | goto __end; | 2362 | goto __end; |
2363 | case SNDRV_PCM_STATE_SUSPENDED: | ||
2364 | ret = -ESTRPIPE; | ||
2365 | goto __end; | ||
2348 | default: | 2366 | default: |
2349 | ret = -EBADFD; | 2367 | ret = -EBADFD; |
2350 | goto __end; | 2368 | goto __end; |
@@ -2544,7 +2562,7 @@ static int snd_pcm_common_ioctl1(struct file *file, | |||
2544 | return snd_pcm_hw_params_old_user(substream, arg); | 2562 | return snd_pcm_hw_params_old_user(substream, arg); |
2545 | #endif | 2563 | #endif |
2546 | case SNDRV_PCM_IOCTL_DRAIN: | 2564 | case SNDRV_PCM_IOCTL_DRAIN: |
2547 | return snd_pcm_drain(substream); | 2565 | return snd_pcm_drain(substream, file); |
2548 | case SNDRV_PCM_IOCTL_DROP: | 2566 | case SNDRV_PCM_IOCTL_DROP: |
2549 | return snd_pcm_drop(substream); | 2567 | return snd_pcm_drop(substream); |
2550 | case SNDRV_PCM_IOCTL_PAUSE: | 2568 | case SNDRV_PCM_IOCTL_PAUSE: |
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 473247c8e6d3..c0adc14c91f0 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
@@ -274,7 +274,7 @@ static int open_substream(struct snd_rawmidi *rmidi, | |||
274 | return err; | 274 | return err; |
275 | substream->opened = 1; | 275 | substream->opened = 1; |
276 | if (substream->use_count++ == 0) | 276 | if (substream->use_count++ == 0) |
277 | substream->active_sensing = 1; | 277 | substream->active_sensing = 0; |
278 | if (mode & SNDRV_RAWMIDI_LFLG_APPEND) | 278 | if (mode & SNDRV_RAWMIDI_LFLG_APPEND) |
279 | substream->append = 1; | 279 | substream->append = 1; |
280 | rmidi->streams[substream->stream].substream_opened++; | 280 | rmidi->streams[substream->stream].substream_opened++; |
diff --git a/sound/core/seq/Makefile b/sound/core/seq/Makefile index 1bcb360330e5..941f64a853eb 100644 --- a/sound/core/seq/Makefile +++ b/sound/core/seq/Makefile | |||
@@ -3,10 +3,6 @@ | |||
3 | # Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz> | 3 | # Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz> |
4 | # | 4 | # |
5 | 5 | ||
6 | ifeq ($(CONFIG_SND_SEQUENCER_OSS),y) | ||
7 | obj-$(CONFIG_SND_SEQUENCER) += oss/ | ||
8 | endif | ||
9 | |||
10 | snd-seq-device-objs := seq_device.o | 6 | snd-seq-device-objs := seq_device.o |
11 | snd-seq-objs := seq.o seq_lock.o seq_clientmgr.o seq_memory.o seq_queue.o \ | 7 | snd-seq-objs := seq.o seq_lock.o seq_clientmgr.o seq_memory.o seq_queue.o \ |
12 | seq_fifo.o seq_prioq.o seq_timer.o \ | 8 | seq_fifo.o seq_prioq.o seq_timer.o \ |
@@ -19,7 +15,8 @@ snd-seq-virmidi-objs := seq_virmidi.o | |||
19 | 15 | ||
20 | obj-$(CONFIG_SND_SEQUENCER) += snd-seq.o snd-seq-device.o | 16 | obj-$(CONFIG_SND_SEQUENCER) += snd-seq.o snd-seq-device.o |
21 | ifeq ($(CONFIG_SND_SEQUENCER_OSS),y) | 17 | ifeq ($(CONFIG_SND_SEQUENCER_OSS),y) |
22 | obj-$(CONFIG_SND_SEQUENCER) += snd-seq-midi-event.o | 18 | obj-$(CONFIG_SND_SEQUENCER) += snd-seq-midi-event.o |
19 | obj-$(CONFIG_SND_SEQUENCER) += oss/ | ||
23 | endif | 20 | endif |
24 | obj-$(CONFIG_SND_SEQ_DUMMY) += snd-seq-dummy.o | 21 | obj-$(CONFIG_SND_SEQ_DUMMY) += snd-seq-dummy.o |
25 | 22 | ||
diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c index 0a711d2d04f0..9dfb2f77be60 100644 --- a/sound/core/seq/oss/seq_oss_midi.c +++ b/sound/core/seq/oss/seq_oss_midi.c | |||
@@ -20,6 +20,7 @@ | |||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <sound/asoundef.h> | ||
23 | #include "seq_oss_midi.h" | 24 | #include "seq_oss_midi.h" |
24 | #include "seq_oss_readq.h" | 25 | #include "seq_oss_readq.h" |
25 | #include "seq_oss_timer.h" | 26 | #include "seq_oss_timer.h" |
@@ -476,19 +477,20 @@ snd_seq_oss_midi_reset(struct seq_oss_devinfo *dp, int dev) | |||
476 | ev.source.port = dp->port; | 477 | ev.source.port = dp->port; |
477 | if (dp->seq_mode == SNDRV_SEQ_OSS_MODE_SYNTH) { | 478 | if (dp->seq_mode == SNDRV_SEQ_OSS_MODE_SYNTH) { |
478 | ev.type = SNDRV_SEQ_EVENT_SENSING; | 479 | ev.type = SNDRV_SEQ_EVENT_SENSING; |
479 | snd_seq_oss_dispatch(dp, &ev, 0, 0); /* active sensing */ | 480 | snd_seq_oss_dispatch(dp, &ev, 0, 0); |
480 | } | 481 | } |
481 | for (c = 0; c < 16; c++) { | 482 | for (c = 0; c < 16; c++) { |
482 | ev.type = SNDRV_SEQ_EVENT_CONTROLLER; | 483 | ev.type = SNDRV_SEQ_EVENT_CONTROLLER; |
483 | ev.data.control.channel = c; | 484 | ev.data.control.channel = c; |
484 | ev.data.control.param = 123; | 485 | ev.data.control.param = MIDI_CTL_ALL_NOTES_OFF; |
485 | snd_seq_oss_dispatch(dp, &ev, 0, 0); /* all notes off */ | 486 | snd_seq_oss_dispatch(dp, &ev, 0, 0); |
486 | if (dp->seq_mode == SNDRV_SEQ_OSS_MODE_MUSIC) { | 487 | if (dp->seq_mode == SNDRV_SEQ_OSS_MODE_MUSIC) { |
487 | ev.data.control.param = 121; | 488 | ev.data.control.param = |
488 | snd_seq_oss_dispatch(dp, &ev, 0, 0); /* reset all controllers */ | 489 | MIDI_CTL_RESET_CONTROLLERS; |
490 | snd_seq_oss_dispatch(dp, &ev, 0, 0); | ||
489 | ev.type = SNDRV_SEQ_EVENT_PITCHBEND; | 491 | ev.type = SNDRV_SEQ_EVENT_PITCHBEND; |
490 | ev.data.control.value = 0; | 492 | ev.data.control.value = 0; |
491 | snd_seq_oss_dispatch(dp, &ev, 0, 0); /* bender off */ | 493 | snd_seq_oss_dispatch(dp, &ev, 0, 0); |
492 | } | 494 | } |
493 | } | 495 | } |
494 | } | 496 | } |
diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index 4d26146a62cc..ebaf1b541dcd 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c | |||
@@ -120,7 +120,8 @@ static int dump_midi(struct snd_rawmidi_substream *substream, const char *buf, i | |||
120 | return -EINVAL; | 120 | return -EINVAL; |
121 | runtime = substream->runtime; | 121 | runtime = substream->runtime; |
122 | if ((tmp = runtime->avail) < count) { | 122 | if ((tmp = runtime->avail) < count) { |
123 | snd_printd("warning, output event was lost (count = %i, available = %i)\n", count, tmp); | 123 | if (printk_ratelimit()) |
124 | snd_printk(KERN_ERR "MIDI output buffer overrun\n"); | ||
124 | return -ENOMEM; | 125 | return -ENOMEM; |
125 | } | 126 | } |
126 | if (snd_rawmidi_kernel_write(substream, buf, count) < count) | 127 | if (snd_rawmidi_kernel_write(substream, buf, count) < count) |
@@ -236,6 +237,7 @@ static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *info | |||
236 | memset(¶ms, 0, sizeof(params)); | 237 | memset(¶ms, 0, sizeof(params)); |
237 | params.avail_min = 1; | 238 | params.avail_min = 1; |
238 | params.buffer_size = output_buffer_size; | 239 | params.buffer_size = output_buffer_size; |
240 | params.no_active_sensing = 1; | ||
239 | if ((err = snd_rawmidi_output_params(msynth->output_rfile.output, ¶ms)) < 0) { | 241 | if ((err = snd_rawmidi_output_params(msynth->output_rfile.output, ¶ms)) < 0) { |
240 | snd_rawmidi_kernel_release(&msynth->output_rfile); | 242 | snd_rawmidi_kernel_release(&msynth->output_rfile); |
241 | return err; | 243 | return err; |
@@ -248,12 +250,9 @@ static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *info | |||
248 | static int midisynth_unuse(void *private_data, struct snd_seq_port_subscribe *info) | 250 | static int midisynth_unuse(void *private_data, struct snd_seq_port_subscribe *info) |
249 | { | 251 | { |
250 | struct seq_midisynth *msynth = private_data; | 252 | struct seq_midisynth *msynth = private_data; |
251 | unsigned char buf = 0xff; /* MIDI reset */ | ||
252 | 253 | ||
253 | if (snd_BUG_ON(!msynth->output_rfile.output)) | 254 | if (snd_BUG_ON(!msynth->output_rfile.output)) |
254 | return -EINVAL; | 255 | return -EINVAL; |
255 | /* sending single MIDI reset message to shut the device up */ | ||
256 | snd_rawmidi_kernel_write(msynth->output_rfile.output, &buf, 1); | ||
257 | snd_rawmidi_drain_output(msynth->output_rfile.output); | 256 | snd_rawmidi_drain_output(msynth->output_rfile.output); |
258 | return snd_rawmidi_kernel_release(&msynth->output_rfile); | 257 | return snd_rawmidi_kernel_release(&msynth->output_rfile); |
259 | } | 258 | } |
diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c index 257624bd1997..3b9b550109cb 100644 --- a/sound/core/vmaster.c +++ b/sound/core/vmaster.c | |||
@@ -353,7 +353,8 @@ static void master_free(struct snd_kcontrol *kcontrol) | |||
353 | * | 353 | * |
354 | * The optional argument @tlv can be used to specify the TLV information | 354 | * The optional argument @tlv can be used to specify the TLV information |
355 | * for dB scale of the master control. It should be a single element | 355 | * for dB scale of the master control. It should be a single element |
356 | * with #SNDRV_CTL_TLVT_DB_SCALE type, and should be the max 0dB. | 356 | * with #SNDRV_CTL_TLVT_DB_SCALE, #SNDRV_CTL_TLV_DB_MINMAX or |
357 | * #SNDRV_CTL_TLVT_DB_MINMAX_MUTE type, and should be the max 0dB. | ||
357 | */ | 358 | */ |
358 | struct snd_kcontrol *snd_ctl_make_virtual_master(char *name, | 359 | struct snd_kcontrol *snd_ctl_make_virtual_master(char *name, |
359 | const unsigned int *tlv) | 360 | const unsigned int *tlv) |
@@ -384,7 +385,10 @@ struct snd_kcontrol *snd_ctl_make_virtual_master(char *name, | |||
384 | kctl->private_free = master_free; | 385 | kctl->private_free = master_free; |
385 | 386 | ||
386 | /* additional (constant) TLV read */ | 387 | /* additional (constant) TLV read */ |
387 | if (tlv && tlv[0] == SNDRV_CTL_TLVT_DB_SCALE) { | 388 | if (tlv && |
389 | (tlv[0] == SNDRV_CTL_TLVT_DB_SCALE || | ||
390 | tlv[0] == SNDRV_CTL_TLVT_DB_MINMAX || | ||
391 | tlv[0] == SNDRV_CTL_TLVT_DB_MINMAX_MUTE)) { | ||
388 | kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; | 392 | kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; |
389 | memcpy(master->tlv, tlv, sizeof(master->tlv)); | 393 | memcpy(master->tlv, tlv, sizeof(master->tlv)); |
390 | kctl->tlv.p = master->tlv; | 394 | kctl->tlv.p = master->tlv; |
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 54239d2e0997..6ba066c41d2e 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c | |||
@@ -25,12 +25,15 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/time.h> | 26 | #include <linux/time.h> |
27 | #include <linux/wait.h> | 27 | #include <linux/wait.h> |
28 | #include <linux/hrtimer.h> | ||
29 | #include <linux/math64.h> | ||
28 | #include <linux/moduleparam.h> | 30 | #include <linux/moduleparam.h> |
29 | #include <sound/core.h> | 31 | #include <sound/core.h> |
30 | #include <sound/control.h> | 32 | #include <sound/control.h> |
31 | #include <sound/tlv.h> | 33 | #include <sound/tlv.h> |
32 | #include <sound/pcm.h> | 34 | #include <sound/pcm.h> |
33 | #include <sound/rawmidi.h> | 35 | #include <sound/rawmidi.h> |
36 | #include <sound/info.h> | ||
34 | #include <sound/initval.h> | 37 | #include <sound/initval.h> |
35 | 38 | ||
36 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); | 39 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); |
@@ -39,7 +42,7 @@ MODULE_LICENSE("GPL"); | |||
39 | MODULE_SUPPORTED_DEVICE("{{ALSA,Dummy soundcard}}"); | 42 | MODULE_SUPPORTED_DEVICE("{{ALSA,Dummy soundcard}}"); |
40 | 43 | ||
41 | #define MAX_PCM_DEVICES 4 | 44 | #define MAX_PCM_DEVICES 4 |
42 | #define MAX_PCM_SUBSTREAMS 16 | 45 | #define MAX_PCM_SUBSTREAMS 128 |
43 | #define MAX_MIDI_DEVICES 2 | 46 | #define MAX_MIDI_DEVICES 2 |
44 | 47 | ||
45 | #if 0 /* emu10k1 emulation */ | 48 | #if 0 /* emu10k1 emulation */ |
@@ -148,6 +151,10 @@ static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; | |||
148 | static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; | 151 | static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; |
149 | static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8}; | 152 | static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8}; |
150 | //static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; | 153 | //static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; |
154 | #ifdef CONFIG_HIGH_RES_TIMERS | ||
155 | static int hrtimer = 1; | ||
156 | #endif | ||
157 | static int fake_buffer = 1; | ||
151 | 158 | ||
152 | module_param_array(index, int, NULL, 0444); | 159 | module_param_array(index, int, NULL, 0444); |
153 | MODULE_PARM_DESC(index, "Index value for dummy soundcard."); | 160 | MODULE_PARM_DESC(index, "Index value for dummy soundcard."); |
@@ -161,6 +168,12 @@ module_param_array(pcm_substreams, int, NULL, 0444); | |||
161 | MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver."); | 168 | MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver."); |
162 | //module_param_array(midi_devs, int, NULL, 0444); | 169 | //module_param_array(midi_devs, int, NULL, 0444); |
163 | //MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver."); | 170 | //MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver."); |
171 | module_param(fake_buffer, bool, 0444); | ||
172 | MODULE_PARM_DESC(fake_buffer, "Fake buffer allocations."); | ||
173 | #ifdef CONFIG_HIGH_RES_TIMERS | ||
174 | module_param(hrtimer, bool, 0644); | ||
175 | MODULE_PARM_DESC(hrtimer, "Use hrtimer as the timer source."); | ||
176 | #endif | ||
164 | 177 | ||
165 | static struct platform_device *devices[SNDRV_CARDS]; | 178 | static struct platform_device *devices[SNDRV_CARDS]; |
166 | 179 | ||
@@ -171,137 +184,324 @@ static struct platform_device *devices[SNDRV_CARDS]; | |||
171 | #define MIXER_ADDR_CD 4 | 184 | #define MIXER_ADDR_CD 4 |
172 | #define MIXER_ADDR_LAST 4 | 185 | #define MIXER_ADDR_LAST 4 |
173 | 186 | ||
187 | struct dummy_timer_ops { | ||
188 | int (*create)(struct snd_pcm_substream *); | ||
189 | void (*free)(struct snd_pcm_substream *); | ||
190 | int (*prepare)(struct snd_pcm_substream *); | ||
191 | int (*start)(struct snd_pcm_substream *); | ||
192 | int (*stop)(struct snd_pcm_substream *); | ||
193 | snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *); | ||
194 | }; | ||
195 | |||
174 | struct snd_dummy { | 196 | struct snd_dummy { |
175 | struct snd_card *card; | 197 | struct snd_card *card; |
176 | struct snd_pcm *pcm; | 198 | struct snd_pcm *pcm; |
177 | spinlock_t mixer_lock; | 199 | spinlock_t mixer_lock; |
178 | int mixer_volume[MIXER_ADDR_LAST+1][2]; | 200 | int mixer_volume[MIXER_ADDR_LAST+1][2]; |
179 | int capture_source[MIXER_ADDR_LAST+1][2]; | 201 | int capture_source[MIXER_ADDR_LAST+1][2]; |
202 | const struct dummy_timer_ops *timer_ops; | ||
180 | }; | 203 | }; |
181 | 204 | ||
182 | struct snd_dummy_pcm { | 205 | /* |
183 | struct snd_dummy *dummy; | 206 | * system timer interface |
207 | */ | ||
208 | |||
209 | struct dummy_systimer_pcm { | ||
184 | spinlock_t lock; | 210 | spinlock_t lock; |
185 | struct timer_list timer; | 211 | struct timer_list timer; |
186 | unsigned int pcm_buffer_size; | 212 | unsigned long base_time; |
187 | unsigned int pcm_period_size; | 213 | unsigned int frac_pos; /* fractional sample position (based HZ) */ |
188 | unsigned int pcm_bps; /* bytes per second */ | 214 | unsigned int frac_period_rest; |
189 | unsigned int pcm_hz; /* HZ */ | 215 | unsigned int frac_buffer_size; /* buffer_size * HZ */ |
190 | unsigned int pcm_irq_pos; /* IRQ position */ | 216 | unsigned int frac_period_size; /* period_size * HZ */ |
191 | unsigned int pcm_buf_pos; /* position in buffer */ | 217 | unsigned int rate; |
218 | int elapsed; | ||
192 | struct snd_pcm_substream *substream; | 219 | struct snd_pcm_substream *substream; |
193 | }; | 220 | }; |
194 | 221 | ||
195 | 222 | static void dummy_systimer_rearm(struct dummy_systimer_pcm *dpcm) | |
196 | static inline void snd_card_dummy_pcm_timer_start(struct snd_dummy_pcm *dpcm) | ||
197 | { | 223 | { |
198 | dpcm->timer.expires = 1 + jiffies; | 224 | dpcm->timer.expires = jiffies + |
225 | (dpcm->frac_period_rest + dpcm->rate - 1) / dpcm->rate; | ||
199 | add_timer(&dpcm->timer); | 226 | add_timer(&dpcm->timer); |
200 | } | 227 | } |
201 | 228 | ||
202 | static inline void snd_card_dummy_pcm_timer_stop(struct snd_dummy_pcm *dpcm) | 229 | static void dummy_systimer_update(struct dummy_systimer_pcm *dpcm) |
203 | { | 230 | { |
204 | del_timer(&dpcm->timer); | 231 | unsigned long delta; |
232 | |||
233 | delta = jiffies - dpcm->base_time; | ||
234 | if (!delta) | ||
235 | return; | ||
236 | dpcm->base_time += delta; | ||
237 | delta *= dpcm->rate; | ||
238 | dpcm->frac_pos += delta; | ||
239 | while (dpcm->frac_pos >= dpcm->frac_buffer_size) | ||
240 | dpcm->frac_pos -= dpcm->frac_buffer_size; | ||
241 | while (dpcm->frac_period_rest <= delta) { | ||
242 | dpcm->elapsed++; | ||
243 | dpcm->frac_period_rest += dpcm->frac_period_size; | ||
244 | } | ||
245 | dpcm->frac_period_rest -= delta; | ||
205 | } | 246 | } |
206 | 247 | ||
207 | static int snd_card_dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | 248 | static int dummy_systimer_start(struct snd_pcm_substream *substream) |
208 | { | 249 | { |
209 | struct snd_pcm_runtime *runtime = substream->runtime; | 250 | struct dummy_systimer_pcm *dpcm = substream->runtime->private_data; |
210 | struct snd_dummy_pcm *dpcm = runtime->private_data; | 251 | spin_lock(&dpcm->lock); |
211 | int err = 0; | 252 | dpcm->base_time = jiffies; |
253 | dummy_systimer_rearm(dpcm); | ||
254 | spin_unlock(&dpcm->lock); | ||
255 | return 0; | ||
256 | } | ||
212 | 257 | ||
258 | static int dummy_systimer_stop(struct snd_pcm_substream *substream) | ||
259 | { | ||
260 | struct dummy_systimer_pcm *dpcm = substream->runtime->private_data; | ||
213 | spin_lock(&dpcm->lock); | 261 | spin_lock(&dpcm->lock); |
214 | switch (cmd) { | 262 | del_timer(&dpcm->timer); |
215 | case SNDRV_PCM_TRIGGER_START: | ||
216 | case SNDRV_PCM_TRIGGER_RESUME: | ||
217 | snd_card_dummy_pcm_timer_start(dpcm); | ||
218 | break; | ||
219 | case SNDRV_PCM_TRIGGER_STOP: | ||
220 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
221 | snd_card_dummy_pcm_timer_stop(dpcm); | ||
222 | break; | ||
223 | default: | ||
224 | err = -EINVAL; | ||
225 | break; | ||
226 | } | ||
227 | spin_unlock(&dpcm->lock); | 263 | spin_unlock(&dpcm->lock); |
228 | return 0; | 264 | return 0; |
229 | } | 265 | } |
230 | 266 | ||
231 | static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream) | 267 | static int dummy_systimer_prepare(struct snd_pcm_substream *substream) |
232 | { | 268 | { |
233 | struct snd_pcm_runtime *runtime = substream->runtime; | 269 | struct snd_pcm_runtime *runtime = substream->runtime; |
234 | struct snd_dummy_pcm *dpcm = runtime->private_data; | 270 | struct dummy_systimer_pcm *dpcm = runtime->private_data; |
235 | int bps; | ||
236 | |||
237 | bps = snd_pcm_format_width(runtime->format) * runtime->rate * | ||
238 | runtime->channels / 8; | ||
239 | |||
240 | if (bps <= 0) | ||
241 | return -EINVAL; | ||
242 | |||
243 | dpcm->pcm_bps = bps; | ||
244 | dpcm->pcm_hz = HZ; | ||
245 | dpcm->pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream); | ||
246 | dpcm->pcm_period_size = snd_pcm_lib_period_bytes(substream); | ||
247 | dpcm->pcm_irq_pos = 0; | ||
248 | dpcm->pcm_buf_pos = 0; | ||
249 | 271 | ||
250 | snd_pcm_format_set_silence(runtime->format, runtime->dma_area, | 272 | dpcm->frac_pos = 0; |
251 | bytes_to_samples(runtime, runtime->dma_bytes)); | 273 | dpcm->rate = runtime->rate; |
274 | dpcm->frac_buffer_size = runtime->buffer_size * HZ; | ||
275 | dpcm->frac_period_size = runtime->period_size * HZ; | ||
276 | dpcm->frac_period_rest = dpcm->frac_period_size; | ||
277 | dpcm->elapsed = 0; | ||
252 | 278 | ||
253 | return 0; | 279 | return 0; |
254 | } | 280 | } |
255 | 281 | ||
256 | static void snd_card_dummy_pcm_timer_function(unsigned long data) | 282 | static void dummy_systimer_callback(unsigned long data) |
257 | { | 283 | { |
258 | struct snd_dummy_pcm *dpcm = (struct snd_dummy_pcm *)data; | 284 | struct dummy_systimer_pcm *dpcm = (struct dummy_systimer_pcm *)data; |
259 | unsigned long flags; | 285 | unsigned long flags; |
286 | int elapsed = 0; | ||
260 | 287 | ||
261 | spin_lock_irqsave(&dpcm->lock, flags); | 288 | spin_lock_irqsave(&dpcm->lock, flags); |
262 | dpcm->timer.expires = 1 + jiffies; | 289 | dummy_systimer_update(dpcm); |
263 | add_timer(&dpcm->timer); | 290 | dummy_systimer_rearm(dpcm); |
264 | dpcm->pcm_irq_pos += dpcm->pcm_bps; | 291 | elapsed = dpcm->elapsed; |
265 | dpcm->pcm_buf_pos += dpcm->pcm_bps; | 292 | dpcm->elapsed = 0; |
266 | dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size * dpcm->pcm_hz; | 293 | spin_unlock_irqrestore(&dpcm->lock, flags); |
267 | if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) { | 294 | if (elapsed) |
268 | dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz; | 295 | snd_pcm_period_elapsed(dpcm->substream); |
269 | spin_unlock_irqrestore(&dpcm->lock, flags); | 296 | } |
297 | |||
298 | static snd_pcm_uframes_t | ||
299 | dummy_systimer_pointer(struct snd_pcm_substream *substream) | ||
300 | { | ||
301 | struct dummy_systimer_pcm *dpcm = substream->runtime->private_data; | ||
302 | snd_pcm_uframes_t pos; | ||
303 | |||
304 | spin_lock(&dpcm->lock); | ||
305 | dummy_systimer_update(dpcm); | ||
306 | pos = dpcm->frac_pos / HZ; | ||
307 | spin_unlock(&dpcm->lock); | ||
308 | return pos; | ||
309 | } | ||
310 | |||
311 | static int dummy_systimer_create(struct snd_pcm_substream *substream) | ||
312 | { | ||
313 | struct dummy_systimer_pcm *dpcm; | ||
314 | |||
315 | dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); | ||
316 | if (!dpcm) | ||
317 | return -ENOMEM; | ||
318 | substream->runtime->private_data = dpcm; | ||
319 | init_timer(&dpcm->timer); | ||
320 | dpcm->timer.data = (unsigned long) dpcm; | ||
321 | dpcm->timer.function = dummy_systimer_callback; | ||
322 | spin_lock_init(&dpcm->lock); | ||
323 | dpcm->substream = substream; | ||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | static void dummy_systimer_free(struct snd_pcm_substream *substream) | ||
328 | { | ||
329 | kfree(substream->runtime->private_data); | ||
330 | } | ||
331 | |||
332 | static struct dummy_timer_ops dummy_systimer_ops = { | ||
333 | .create = dummy_systimer_create, | ||
334 | .free = dummy_systimer_free, | ||
335 | .prepare = dummy_systimer_prepare, | ||
336 | .start = dummy_systimer_start, | ||
337 | .stop = dummy_systimer_stop, | ||
338 | .pointer = dummy_systimer_pointer, | ||
339 | }; | ||
340 | |||
341 | #ifdef CONFIG_HIGH_RES_TIMERS | ||
342 | /* | ||
343 | * hrtimer interface | ||
344 | */ | ||
345 | |||
346 | struct dummy_hrtimer_pcm { | ||
347 | ktime_t base_time; | ||
348 | ktime_t period_time; | ||
349 | atomic_t running; | ||
350 | struct hrtimer timer; | ||
351 | struct tasklet_struct tasklet; | ||
352 | struct snd_pcm_substream *substream; | ||
353 | }; | ||
354 | |||
355 | static void dummy_hrtimer_pcm_elapsed(unsigned long priv) | ||
356 | { | ||
357 | struct dummy_hrtimer_pcm *dpcm = (struct dummy_hrtimer_pcm *)priv; | ||
358 | if (atomic_read(&dpcm->running)) | ||
270 | snd_pcm_period_elapsed(dpcm->substream); | 359 | snd_pcm_period_elapsed(dpcm->substream); |
271 | } else | ||
272 | spin_unlock_irqrestore(&dpcm->lock, flags); | ||
273 | } | 360 | } |
274 | 361 | ||
275 | static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream) | 362 | static enum hrtimer_restart dummy_hrtimer_callback(struct hrtimer *timer) |
363 | { | ||
364 | struct dummy_hrtimer_pcm *dpcm; | ||
365 | |||
366 | dpcm = container_of(timer, struct dummy_hrtimer_pcm, timer); | ||
367 | if (!atomic_read(&dpcm->running)) | ||
368 | return HRTIMER_NORESTART; | ||
369 | tasklet_schedule(&dpcm->tasklet); | ||
370 | hrtimer_forward_now(timer, dpcm->period_time); | ||
371 | return HRTIMER_RESTART; | ||
372 | } | ||
373 | |||
374 | static int dummy_hrtimer_start(struct snd_pcm_substream *substream) | ||
375 | { | ||
376 | struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; | ||
377 | |||
378 | dpcm->base_time = hrtimer_cb_get_time(&dpcm->timer); | ||
379 | hrtimer_start(&dpcm->timer, dpcm->period_time, HRTIMER_MODE_REL); | ||
380 | atomic_set(&dpcm->running, 1); | ||
381 | return 0; | ||
382 | } | ||
383 | |||
384 | static int dummy_hrtimer_stop(struct snd_pcm_substream *substream) | ||
385 | { | ||
386 | struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; | ||
387 | |||
388 | atomic_set(&dpcm->running, 0); | ||
389 | hrtimer_cancel(&dpcm->timer); | ||
390 | return 0; | ||
391 | } | ||
392 | |||
393 | static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm) | ||
394 | { | ||
395 | tasklet_kill(&dpcm->tasklet); | ||
396 | } | ||
397 | |||
398 | static snd_pcm_uframes_t | ||
399 | dummy_hrtimer_pointer(struct snd_pcm_substream *substream) | ||
276 | { | 400 | { |
277 | struct snd_pcm_runtime *runtime = substream->runtime; | 401 | struct snd_pcm_runtime *runtime = substream->runtime; |
278 | struct snd_dummy_pcm *dpcm = runtime->private_data; | 402 | struct dummy_hrtimer_pcm *dpcm = runtime->private_data; |
403 | u64 delta; | ||
404 | u32 pos; | ||
405 | |||
406 | delta = ktime_us_delta(hrtimer_cb_get_time(&dpcm->timer), | ||
407 | dpcm->base_time); | ||
408 | delta = div_u64(delta * runtime->rate + 999999, 1000000); | ||
409 | div_u64_rem(delta, runtime->buffer_size, &pos); | ||
410 | return pos; | ||
411 | } | ||
279 | 412 | ||
280 | return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz); | 413 | static int dummy_hrtimer_prepare(struct snd_pcm_substream *substream) |
414 | { | ||
415 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
416 | struct dummy_hrtimer_pcm *dpcm = runtime->private_data; | ||
417 | unsigned int period, rate; | ||
418 | long sec; | ||
419 | unsigned long nsecs; | ||
420 | |||
421 | dummy_hrtimer_sync(dpcm); | ||
422 | period = runtime->period_size; | ||
423 | rate = runtime->rate; | ||
424 | sec = period / rate; | ||
425 | period %= rate; | ||
426 | nsecs = div_u64((u64)period * 1000000000UL + rate - 1, rate); | ||
427 | dpcm->period_time = ktime_set(sec, nsecs); | ||
428 | |||
429 | return 0; | ||
281 | } | 430 | } |
282 | 431 | ||
283 | static struct snd_pcm_hardware snd_card_dummy_playback = | 432 | static int dummy_hrtimer_create(struct snd_pcm_substream *substream) |
284 | { | 433 | { |
285 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 434 | struct dummy_hrtimer_pcm *dpcm; |
286 | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), | 435 | |
287 | .formats = USE_FORMATS, | 436 | dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); |
288 | .rates = USE_RATE, | 437 | if (!dpcm) |
289 | .rate_min = USE_RATE_MIN, | 438 | return -ENOMEM; |
290 | .rate_max = USE_RATE_MAX, | 439 | substream->runtime->private_data = dpcm; |
291 | .channels_min = USE_CHANNELS_MIN, | 440 | hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
292 | .channels_max = USE_CHANNELS_MAX, | 441 | dpcm->timer.function = dummy_hrtimer_callback; |
293 | .buffer_bytes_max = MAX_BUFFER_SIZE, | 442 | dpcm->substream = substream; |
294 | .period_bytes_min = 64, | 443 | atomic_set(&dpcm->running, 0); |
295 | .period_bytes_max = MAX_PERIOD_SIZE, | 444 | tasklet_init(&dpcm->tasklet, dummy_hrtimer_pcm_elapsed, |
296 | .periods_min = USE_PERIODS_MIN, | 445 | (unsigned long)dpcm); |
297 | .periods_max = USE_PERIODS_MAX, | 446 | return 0; |
298 | .fifo_size = 0, | 447 | } |
448 | |||
449 | static void dummy_hrtimer_free(struct snd_pcm_substream *substream) | ||
450 | { | ||
451 | struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; | ||
452 | dummy_hrtimer_sync(dpcm); | ||
453 | kfree(dpcm); | ||
454 | } | ||
455 | |||
456 | static struct dummy_timer_ops dummy_hrtimer_ops = { | ||
457 | .create = dummy_hrtimer_create, | ||
458 | .free = dummy_hrtimer_free, | ||
459 | .prepare = dummy_hrtimer_prepare, | ||
460 | .start = dummy_hrtimer_start, | ||
461 | .stop = dummy_hrtimer_stop, | ||
462 | .pointer = dummy_hrtimer_pointer, | ||
299 | }; | 463 | }; |
300 | 464 | ||
301 | static struct snd_pcm_hardware snd_card_dummy_capture = | 465 | #endif /* CONFIG_HIGH_RES_TIMERS */ |
466 | |||
467 | /* | ||
468 | * PCM interface | ||
469 | */ | ||
470 | |||
471 | static int dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
302 | { | 472 | { |
303 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 473 | struct snd_dummy *dummy = snd_pcm_substream_chip(substream); |
304 | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), | 474 | |
475 | switch (cmd) { | ||
476 | case SNDRV_PCM_TRIGGER_START: | ||
477 | case SNDRV_PCM_TRIGGER_RESUME: | ||
478 | return dummy->timer_ops->start(substream); | ||
479 | case SNDRV_PCM_TRIGGER_STOP: | ||
480 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
481 | return dummy->timer_ops->stop(substream); | ||
482 | } | ||
483 | return -EINVAL; | ||
484 | } | ||
485 | |||
486 | static int dummy_pcm_prepare(struct snd_pcm_substream *substream) | ||
487 | { | ||
488 | struct snd_dummy *dummy = snd_pcm_substream_chip(substream); | ||
489 | |||
490 | return dummy->timer_ops->prepare(substream); | ||
491 | } | ||
492 | |||
493 | static snd_pcm_uframes_t dummy_pcm_pointer(struct snd_pcm_substream *substream) | ||
494 | { | ||
495 | struct snd_dummy *dummy = snd_pcm_substream_chip(substream); | ||
496 | |||
497 | return dummy->timer_ops->pointer(substream); | ||
498 | } | ||
499 | |||
500 | static struct snd_pcm_hardware dummy_pcm_hardware = { | ||
501 | .info = (SNDRV_PCM_INFO_MMAP | | ||
502 | SNDRV_PCM_INFO_INTERLEAVED | | ||
503 | SNDRV_PCM_INFO_RESUME | | ||
504 | SNDRV_PCM_INFO_MMAP_VALID), | ||
305 | .formats = USE_FORMATS, | 505 | .formats = USE_FORMATS, |
306 | .rates = USE_RATE, | 506 | .rates = USE_RATE, |
307 | .rate_min = USE_RATE_MIN, | 507 | .rate_min = USE_RATE_MIN, |
@@ -316,123 +516,152 @@ static struct snd_pcm_hardware snd_card_dummy_capture = | |||
316 | .fifo_size = 0, | 516 | .fifo_size = 0, |
317 | }; | 517 | }; |
318 | 518 | ||
319 | static void snd_card_dummy_runtime_free(struct snd_pcm_runtime *runtime) | 519 | static int dummy_pcm_hw_params(struct snd_pcm_substream *substream, |
320 | { | 520 | struct snd_pcm_hw_params *hw_params) |
321 | kfree(runtime->private_data); | ||
322 | } | ||
323 | |||
324 | static int snd_card_dummy_hw_params(struct snd_pcm_substream *substream, | ||
325 | struct snd_pcm_hw_params *hw_params) | ||
326 | { | 521 | { |
327 | return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); | 522 | if (fake_buffer) { |
523 | /* runtime->dma_bytes has to be set manually to allow mmap */ | ||
524 | substream->runtime->dma_bytes = params_buffer_bytes(hw_params); | ||
525 | return 0; | ||
526 | } | ||
527 | return snd_pcm_lib_malloc_pages(substream, | ||
528 | params_buffer_bytes(hw_params)); | ||
328 | } | 529 | } |
329 | 530 | ||
330 | static int snd_card_dummy_hw_free(struct snd_pcm_substream *substream) | 531 | static int dummy_pcm_hw_free(struct snd_pcm_substream *substream) |
331 | { | 532 | { |
533 | if (fake_buffer) | ||
534 | return 0; | ||
332 | return snd_pcm_lib_free_pages(substream); | 535 | return snd_pcm_lib_free_pages(substream); |
333 | } | 536 | } |
334 | 537 | ||
335 | static struct snd_dummy_pcm *new_pcm_stream(struct snd_pcm_substream *substream) | 538 | static int dummy_pcm_open(struct snd_pcm_substream *substream) |
336 | { | ||
337 | struct snd_dummy_pcm *dpcm; | ||
338 | |||
339 | dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); | ||
340 | if (! dpcm) | ||
341 | return dpcm; | ||
342 | init_timer(&dpcm->timer); | ||
343 | dpcm->timer.data = (unsigned long) dpcm; | ||
344 | dpcm->timer.function = snd_card_dummy_pcm_timer_function; | ||
345 | spin_lock_init(&dpcm->lock); | ||
346 | dpcm->substream = substream; | ||
347 | return dpcm; | ||
348 | } | ||
349 | |||
350 | static int snd_card_dummy_playback_open(struct snd_pcm_substream *substream) | ||
351 | { | 539 | { |
540 | struct snd_dummy *dummy = snd_pcm_substream_chip(substream); | ||
352 | struct snd_pcm_runtime *runtime = substream->runtime; | 541 | struct snd_pcm_runtime *runtime = substream->runtime; |
353 | struct snd_dummy_pcm *dpcm; | ||
354 | int err; | 542 | int err; |
355 | 543 | ||
356 | if ((dpcm = new_pcm_stream(substream)) == NULL) | 544 | dummy->timer_ops = &dummy_systimer_ops; |
357 | return -ENOMEM; | 545 | #ifdef CONFIG_HIGH_RES_TIMERS |
358 | runtime->private_data = dpcm; | 546 | if (hrtimer) |
359 | /* makes the infrastructure responsible for freeing dpcm */ | 547 | dummy->timer_ops = &dummy_hrtimer_ops; |
360 | runtime->private_free = snd_card_dummy_runtime_free; | 548 | #endif |
361 | runtime->hw = snd_card_dummy_playback; | 549 | |
550 | err = dummy->timer_ops->create(substream); | ||
551 | if (err < 0) | ||
552 | return err; | ||
553 | |||
554 | runtime->hw = dummy_pcm_hardware; | ||
362 | if (substream->pcm->device & 1) { | 555 | if (substream->pcm->device & 1) { |
363 | runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; | 556 | runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; |
364 | runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; | 557 | runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; |
365 | } | 558 | } |
366 | if (substream->pcm->device & 2) | 559 | if (substream->pcm->device & 2) |
367 | runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID); | 560 | runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP | |
368 | err = add_playback_constraints(runtime); | 561 | SNDRV_PCM_INFO_MMAP_VALID); |
369 | if (err < 0) | 562 | |
563 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
564 | err = add_playback_constraints(substream->runtime); | ||
565 | else | ||
566 | err = add_capture_constraints(substream->runtime); | ||
567 | if (err < 0) { | ||
568 | dummy->timer_ops->free(substream); | ||
370 | return err; | 569 | return err; |
371 | 570 | } | |
372 | return 0; | 571 | return 0; |
373 | } | 572 | } |
374 | 573 | ||
375 | static int snd_card_dummy_capture_open(struct snd_pcm_substream *substream) | 574 | static int dummy_pcm_close(struct snd_pcm_substream *substream) |
376 | { | 575 | { |
377 | struct snd_pcm_runtime *runtime = substream->runtime; | 576 | struct snd_dummy *dummy = snd_pcm_substream_chip(substream); |
378 | struct snd_dummy_pcm *dpcm; | 577 | dummy->timer_ops->free(substream); |
379 | int err; | 578 | return 0; |
579 | } | ||
380 | 580 | ||
381 | if ((dpcm = new_pcm_stream(substream)) == NULL) | 581 | /* |
382 | return -ENOMEM; | 582 | * dummy buffer handling |
383 | runtime->private_data = dpcm; | 583 | */ |
384 | /* makes the infrastructure responsible for freeing dpcm */ | 584 | |
385 | runtime->private_free = snd_card_dummy_runtime_free; | 585 | static void *dummy_page[2]; |
386 | runtime->hw = snd_card_dummy_capture; | 586 | |
387 | if (substream->pcm->device == 1) { | 587 | static void free_fake_buffer(void) |
388 | runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; | 588 | { |
389 | runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; | 589 | if (fake_buffer) { |
590 | int i; | ||
591 | for (i = 0; i < 2; i++) | ||
592 | if (dummy_page[i]) { | ||
593 | free_page((unsigned long)dummy_page[i]); | ||
594 | dummy_page[i] = NULL; | ||
595 | } | ||
390 | } | 596 | } |
391 | if (substream->pcm->device & 2) | 597 | } |
392 | runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID); | ||
393 | err = add_capture_constraints(runtime); | ||
394 | if (err < 0) | ||
395 | return err; | ||
396 | 598 | ||
599 | static int alloc_fake_buffer(void) | ||
600 | { | ||
601 | int i; | ||
602 | |||
603 | if (!fake_buffer) | ||
604 | return 0; | ||
605 | for (i = 0; i < 2; i++) { | ||
606 | dummy_page[i] = (void *)get_zeroed_page(GFP_KERNEL); | ||
607 | if (!dummy_page[i]) { | ||
608 | free_fake_buffer(); | ||
609 | return -ENOMEM; | ||
610 | } | ||
611 | } | ||
397 | return 0; | 612 | return 0; |
398 | } | 613 | } |
399 | 614 | ||
400 | static int snd_card_dummy_playback_close(struct snd_pcm_substream *substream) | 615 | static int dummy_pcm_copy(struct snd_pcm_substream *substream, |
616 | int channel, snd_pcm_uframes_t pos, | ||
617 | void __user *dst, snd_pcm_uframes_t count) | ||
401 | { | 618 | { |
402 | return 0; | 619 | return 0; /* do nothing */ |
403 | } | 620 | } |
404 | 621 | ||
405 | static int snd_card_dummy_capture_close(struct snd_pcm_substream *substream) | 622 | static int dummy_pcm_silence(struct snd_pcm_substream *substream, |
623 | int channel, snd_pcm_uframes_t pos, | ||
624 | snd_pcm_uframes_t count) | ||
406 | { | 625 | { |
407 | return 0; | 626 | return 0; /* do nothing */ |
627 | } | ||
628 | |||
629 | static struct page *dummy_pcm_page(struct snd_pcm_substream *substream, | ||
630 | unsigned long offset) | ||
631 | { | ||
632 | return virt_to_page(dummy_page[substream->stream]); /* the same page */ | ||
408 | } | 633 | } |
409 | 634 | ||
410 | static struct snd_pcm_ops snd_card_dummy_playback_ops = { | 635 | static struct snd_pcm_ops dummy_pcm_ops = { |
411 | .open = snd_card_dummy_playback_open, | 636 | .open = dummy_pcm_open, |
412 | .close = snd_card_dummy_playback_close, | 637 | .close = dummy_pcm_close, |
413 | .ioctl = snd_pcm_lib_ioctl, | 638 | .ioctl = snd_pcm_lib_ioctl, |
414 | .hw_params = snd_card_dummy_hw_params, | 639 | .hw_params = dummy_pcm_hw_params, |
415 | .hw_free = snd_card_dummy_hw_free, | 640 | .hw_free = dummy_pcm_hw_free, |
416 | .prepare = snd_card_dummy_pcm_prepare, | 641 | .prepare = dummy_pcm_prepare, |
417 | .trigger = snd_card_dummy_pcm_trigger, | 642 | .trigger = dummy_pcm_trigger, |
418 | .pointer = snd_card_dummy_pcm_pointer, | 643 | .pointer = dummy_pcm_pointer, |
419 | }; | 644 | }; |
420 | 645 | ||
421 | static struct snd_pcm_ops snd_card_dummy_capture_ops = { | 646 | static struct snd_pcm_ops dummy_pcm_ops_no_buf = { |
422 | .open = snd_card_dummy_capture_open, | 647 | .open = dummy_pcm_open, |
423 | .close = snd_card_dummy_capture_close, | 648 | .close = dummy_pcm_close, |
424 | .ioctl = snd_pcm_lib_ioctl, | 649 | .ioctl = snd_pcm_lib_ioctl, |
425 | .hw_params = snd_card_dummy_hw_params, | 650 | .hw_params = dummy_pcm_hw_params, |
426 | .hw_free = snd_card_dummy_hw_free, | 651 | .hw_free = dummy_pcm_hw_free, |
427 | .prepare = snd_card_dummy_pcm_prepare, | 652 | .prepare = dummy_pcm_prepare, |
428 | .trigger = snd_card_dummy_pcm_trigger, | 653 | .trigger = dummy_pcm_trigger, |
429 | .pointer = snd_card_dummy_pcm_pointer, | 654 | .pointer = dummy_pcm_pointer, |
655 | .copy = dummy_pcm_copy, | ||
656 | .silence = dummy_pcm_silence, | ||
657 | .page = dummy_pcm_page, | ||
430 | }; | 658 | }; |
431 | 659 | ||
432 | static int __devinit snd_card_dummy_pcm(struct snd_dummy *dummy, int device, | 660 | static int __devinit snd_card_dummy_pcm(struct snd_dummy *dummy, int device, |
433 | int substreams) | 661 | int substreams) |
434 | { | 662 | { |
435 | struct snd_pcm *pcm; | 663 | struct snd_pcm *pcm; |
664 | struct snd_pcm_ops *ops; | ||
436 | int err; | 665 | int err; |
437 | 666 | ||
438 | err = snd_pcm_new(dummy->card, "Dummy PCM", device, | 667 | err = snd_pcm_new(dummy->card, "Dummy PCM", device, |
@@ -440,17 +669,28 @@ static int __devinit snd_card_dummy_pcm(struct snd_dummy *dummy, int device, | |||
440 | if (err < 0) | 669 | if (err < 0) |
441 | return err; | 670 | return err; |
442 | dummy->pcm = pcm; | 671 | dummy->pcm = pcm; |
443 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_dummy_playback_ops); | 672 | if (fake_buffer) |
444 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_dummy_capture_ops); | 673 | ops = &dummy_pcm_ops_no_buf; |
674 | else | ||
675 | ops = &dummy_pcm_ops; | ||
676 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, ops); | ||
677 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, ops); | ||
445 | pcm->private_data = dummy; | 678 | pcm->private_data = dummy; |
446 | pcm->info_flags = 0; | 679 | pcm->info_flags = 0; |
447 | strcpy(pcm->name, "Dummy PCM"); | 680 | strcpy(pcm->name, "Dummy PCM"); |
448 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, | 681 | if (!fake_buffer) { |
449 | snd_dma_continuous_data(GFP_KERNEL), | 682 | snd_pcm_lib_preallocate_pages_for_all(pcm, |
450 | 0, 64*1024); | 683 | SNDRV_DMA_TYPE_CONTINUOUS, |
684 | snd_dma_continuous_data(GFP_KERNEL), | ||
685 | 0, 64*1024); | ||
686 | } | ||
451 | return 0; | 687 | return 0; |
452 | } | 688 | } |
453 | 689 | ||
690 | /* | ||
691 | * mixer interface | ||
692 | */ | ||
693 | |||
454 | #define DUMMY_VOLUME(xname, xindex, addr) \ | 694 | #define DUMMY_VOLUME(xname, xindex, addr) \ |
455 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 695 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
456 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | 696 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ |
@@ -581,6 +821,131 @@ static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy) | |||
581 | return 0; | 821 | return 0; |
582 | } | 822 | } |
583 | 823 | ||
824 | #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_PROC_FS) | ||
825 | /* | ||
826 | * proc interface | ||
827 | */ | ||
828 | static void print_formats(struct snd_info_buffer *buffer) | ||
829 | { | ||
830 | int i; | ||
831 | |||
832 | for (i = 0; i < SNDRV_PCM_FORMAT_LAST; i++) { | ||
833 | if (dummy_pcm_hardware.formats & (1ULL << i)) | ||
834 | snd_iprintf(buffer, " %s", snd_pcm_format_name(i)); | ||
835 | } | ||
836 | } | ||
837 | |||
838 | static void print_rates(struct snd_info_buffer *buffer) | ||
839 | { | ||
840 | static int rates[] = { | ||
841 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, | ||
842 | 64000, 88200, 96000, 176400, 192000, | ||
843 | }; | ||
844 | int i; | ||
845 | |||
846 | if (dummy_pcm_hardware.rates & SNDRV_PCM_RATE_CONTINUOUS) | ||
847 | snd_iprintf(buffer, " continuous"); | ||
848 | if (dummy_pcm_hardware.rates & SNDRV_PCM_RATE_KNOT) | ||
849 | snd_iprintf(buffer, " knot"); | ||
850 | for (i = 0; i < ARRAY_SIZE(rates); i++) | ||
851 | if (dummy_pcm_hardware.rates & (1 << i)) | ||
852 | snd_iprintf(buffer, " %d", rates[i]); | ||
853 | } | ||
854 | |||
855 | #define get_dummy_int_ptr(ofs) \ | ||
856 | (unsigned int *)((char *)&dummy_pcm_hardware + (ofs)) | ||
857 | #define get_dummy_ll_ptr(ofs) \ | ||
858 | (unsigned long long *)((char *)&dummy_pcm_hardware + (ofs)) | ||
859 | |||
860 | struct dummy_hw_field { | ||
861 | const char *name; | ||
862 | const char *format; | ||
863 | unsigned int offset; | ||
864 | unsigned int size; | ||
865 | }; | ||
866 | #define FIELD_ENTRY(item, fmt) { \ | ||
867 | .name = #item, \ | ||
868 | .format = fmt, \ | ||
869 | .offset = offsetof(struct snd_pcm_hardware, item), \ | ||
870 | .size = sizeof(dummy_pcm_hardware.item) } | ||
871 | |||
872 | static struct dummy_hw_field fields[] = { | ||
873 | FIELD_ENTRY(formats, "%#llx"), | ||
874 | FIELD_ENTRY(rates, "%#x"), | ||
875 | FIELD_ENTRY(rate_min, "%d"), | ||
876 | FIELD_ENTRY(rate_max, "%d"), | ||
877 | FIELD_ENTRY(channels_min, "%d"), | ||
878 | FIELD_ENTRY(channels_max, "%d"), | ||
879 | FIELD_ENTRY(buffer_bytes_max, "%ld"), | ||
880 | FIELD_ENTRY(period_bytes_min, "%ld"), | ||
881 | FIELD_ENTRY(period_bytes_max, "%ld"), | ||
882 | FIELD_ENTRY(periods_min, "%d"), | ||
883 | FIELD_ENTRY(periods_max, "%d"), | ||
884 | }; | ||
885 | |||
886 | static void dummy_proc_read(struct snd_info_entry *entry, | ||
887 | struct snd_info_buffer *buffer) | ||
888 | { | ||
889 | int i; | ||
890 | |||
891 | for (i = 0; i < ARRAY_SIZE(fields); i++) { | ||
892 | snd_iprintf(buffer, "%s ", fields[i].name); | ||
893 | if (fields[i].size == sizeof(int)) | ||
894 | snd_iprintf(buffer, fields[i].format, | ||
895 | *get_dummy_int_ptr(fields[i].offset)); | ||
896 | else | ||
897 | snd_iprintf(buffer, fields[i].format, | ||
898 | *get_dummy_ll_ptr(fields[i].offset)); | ||
899 | if (!strcmp(fields[i].name, "formats")) | ||
900 | print_formats(buffer); | ||
901 | else if (!strcmp(fields[i].name, "rates")) | ||
902 | print_rates(buffer); | ||
903 | snd_iprintf(buffer, "\n"); | ||
904 | } | ||
905 | } | ||
906 | |||
907 | static void dummy_proc_write(struct snd_info_entry *entry, | ||
908 | struct snd_info_buffer *buffer) | ||
909 | { | ||
910 | char line[64]; | ||
911 | |||
912 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | ||
913 | char item[20]; | ||
914 | const char *ptr; | ||
915 | unsigned long long val; | ||
916 | int i; | ||
917 | |||
918 | ptr = snd_info_get_str(item, line, sizeof(item)); | ||
919 | for (i = 0; i < ARRAY_SIZE(fields); i++) { | ||
920 | if (!strcmp(item, fields[i].name)) | ||
921 | break; | ||
922 | } | ||
923 | if (i >= ARRAY_SIZE(fields)) | ||
924 | continue; | ||
925 | snd_info_get_str(item, ptr, sizeof(item)); | ||
926 | if (strict_strtoull(item, 0, &val)) | ||
927 | continue; | ||
928 | if (fields[i].size == sizeof(int)) | ||
929 | *get_dummy_int_ptr(fields[i].offset) = val; | ||
930 | else | ||
931 | *get_dummy_ll_ptr(fields[i].offset) = val; | ||
932 | } | ||
933 | } | ||
934 | |||
935 | static void __devinit dummy_proc_init(struct snd_dummy *chip) | ||
936 | { | ||
937 | struct snd_info_entry *entry; | ||
938 | |||
939 | if (!snd_card_proc_new(chip->card, "dummy_pcm", &entry)) { | ||
940 | snd_info_set_text_ops(entry, chip, dummy_proc_read); | ||
941 | entry->c.text.write = dummy_proc_write; | ||
942 | entry->mode |= S_IWUSR; | ||
943 | } | ||
944 | } | ||
945 | #else | ||
946 | #define dummy_proc_init(x) | ||
947 | #endif /* CONFIG_SND_DEBUG && CONFIG_PROC_FS */ | ||
948 | |||
584 | static int __devinit snd_dummy_probe(struct platform_device *devptr) | 949 | static int __devinit snd_dummy_probe(struct platform_device *devptr) |
585 | { | 950 | { |
586 | struct snd_card *card; | 951 | struct snd_card *card; |
@@ -610,6 +975,8 @@ static int __devinit snd_dummy_probe(struct platform_device *devptr) | |||
610 | strcpy(card->shortname, "Dummy"); | 975 | strcpy(card->shortname, "Dummy"); |
611 | sprintf(card->longname, "Dummy %i", dev + 1); | 976 | sprintf(card->longname, "Dummy %i", dev + 1); |
612 | 977 | ||
978 | dummy_proc_init(dummy); | ||
979 | |||
613 | snd_card_set_dev(card, &devptr->dev); | 980 | snd_card_set_dev(card, &devptr->dev); |
614 | 981 | ||
615 | err = snd_card_register(card); | 982 | err = snd_card_register(card); |
@@ -670,6 +1037,7 @@ static void snd_dummy_unregister_all(void) | |||
670 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | 1037 | for (i = 0; i < ARRAY_SIZE(devices); ++i) |
671 | platform_device_unregister(devices[i]); | 1038 | platform_device_unregister(devices[i]); |
672 | platform_driver_unregister(&snd_dummy_driver); | 1039 | platform_driver_unregister(&snd_dummy_driver); |
1040 | free_fake_buffer(); | ||
673 | } | 1041 | } |
674 | 1042 | ||
675 | static int __init alsa_card_dummy_init(void) | 1043 | static int __init alsa_card_dummy_init(void) |
@@ -680,6 +1048,12 @@ static int __init alsa_card_dummy_init(void) | |||
680 | if (err < 0) | 1048 | if (err < 0) |
681 | return err; | 1049 | return err; |
682 | 1050 | ||
1051 | err = alloc_fake_buffer(); | ||
1052 | if (err < 0) { | ||
1053 | platform_driver_unregister(&snd_dummy_driver); | ||
1054 | return err; | ||
1055 | } | ||
1056 | |||
683 | cards = 0; | 1057 | cards = 0; |
684 | for (i = 0; i < SNDRV_CARDS; i++) { | 1058 | for (i = 0; i < SNDRV_CARDS; i++) { |
685 | struct platform_device *device; | 1059 | struct platform_device *device; |
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index de83608719ea..02f79d252718 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for C-Media's CMI8330 soundcards. | 2 | * Driver for C-Media's CMI8330 and CMI8329 soundcards. |
3 | * Copyright (c) by George Talusan <gstalusan@uwaterloo.ca> | 3 | * Copyright (c) by George Talusan <gstalusan@uwaterloo.ca> |
4 | * http://www.undergrad.math.uwaterloo.ca/~gstalusa | 4 | * http://www.undergrad.math.uwaterloo.ca/~gstalusa |
5 | * | 5 | * |
@@ -35,7 +35,7 @@ | |||
35 | * | 35 | * |
36 | * This card has two mixers and two PCM devices. I've cheesed it such | 36 | * This card has two mixers and two PCM devices. I've cheesed it such |
37 | * that recording and playback can be done through the same device. | 37 | * that recording and playback can be done through the same device. |
38 | * The driver "magically" routes the capturing to the CMI8330 codec, | 38 | * The driver "magically" routes the capturing to the AD1848 codec, |
39 | * and playback to the SB16 codec. This allows for full-duplex mode | 39 | * and playback to the SB16 codec. This allows for full-duplex mode |
40 | * to some extent. | 40 | * to some extent. |
41 | * The utilities in alsa-utils are aware of both devices, so passing | 41 | * The utilities in alsa-utils are aware of both devices, so passing |
@@ -64,7 +64,7 @@ | |||
64 | /* | 64 | /* |
65 | */ | 65 | */ |
66 | MODULE_AUTHOR("George Talusan <gstalusan@uwaterloo.ca>"); | 66 | MODULE_AUTHOR("George Talusan <gstalusan@uwaterloo.ca>"); |
67 | MODULE_DESCRIPTION("C-Media CMI8330"); | 67 | MODULE_DESCRIPTION("C-Media CMI8330/CMI8329"); |
68 | MODULE_LICENSE("GPL"); | 68 | MODULE_LICENSE("GPL"); |
69 | MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8330,isapnp:{CMI0001,@@@0001,@X@0001}}}"); | 69 | MODULE_SUPPORTED_DEVICE("{{C-Media,CMI8330,isapnp:{CMI0001,@@@0001,@X@0001}}}"); |
70 | 70 | ||
@@ -86,38 +86,38 @@ static long mpuport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | |||
86 | static int mpuirq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | 86 | static int mpuirq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; |
87 | 87 | ||
88 | module_param_array(index, int, NULL, 0444); | 88 | module_param_array(index, int, NULL, 0444); |
89 | MODULE_PARM_DESC(index, "Index value for CMI8330 soundcard."); | 89 | MODULE_PARM_DESC(index, "Index value for CMI8330/CMI8329 soundcard."); |
90 | module_param_array(id, charp, NULL, 0444); | 90 | module_param_array(id, charp, NULL, 0444); |
91 | MODULE_PARM_DESC(id, "ID string for CMI8330 soundcard."); | 91 | MODULE_PARM_DESC(id, "ID string for CMI8330/CMI8329 soundcard."); |
92 | module_param_array(enable, bool, NULL, 0444); | 92 | module_param_array(enable, bool, NULL, 0444); |
93 | MODULE_PARM_DESC(enable, "Enable CMI8330 soundcard."); | 93 | MODULE_PARM_DESC(enable, "Enable CMI8330/CMI8329 soundcard."); |
94 | #ifdef CONFIG_PNP | 94 | #ifdef CONFIG_PNP |
95 | module_param_array(isapnp, bool, NULL, 0444); | 95 | module_param_array(isapnp, bool, NULL, 0444); |
96 | MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard."); | 96 | MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard."); |
97 | #endif | 97 | #endif |
98 | 98 | ||
99 | module_param_array(sbport, long, NULL, 0444); | 99 | module_param_array(sbport, long, NULL, 0444); |
100 | MODULE_PARM_DESC(sbport, "Port # for CMI8330 SB driver."); | 100 | MODULE_PARM_DESC(sbport, "Port # for CMI8330/CMI8329 SB driver."); |
101 | module_param_array(sbirq, int, NULL, 0444); | 101 | module_param_array(sbirq, int, NULL, 0444); |
102 | MODULE_PARM_DESC(sbirq, "IRQ # for CMI8330 SB driver."); | 102 | MODULE_PARM_DESC(sbirq, "IRQ # for CMI8330/CMI8329 SB driver."); |
103 | module_param_array(sbdma8, int, NULL, 0444); | 103 | module_param_array(sbdma8, int, NULL, 0444); |
104 | MODULE_PARM_DESC(sbdma8, "DMA8 for CMI8330 SB driver."); | 104 | MODULE_PARM_DESC(sbdma8, "DMA8 for CMI8330/CMI8329 SB driver."); |
105 | module_param_array(sbdma16, int, NULL, 0444); | 105 | module_param_array(sbdma16, int, NULL, 0444); |
106 | MODULE_PARM_DESC(sbdma16, "DMA16 for CMI8330 SB driver."); | 106 | MODULE_PARM_DESC(sbdma16, "DMA16 for CMI8330/CMI8329 SB driver."); |
107 | 107 | ||
108 | module_param_array(wssport, long, NULL, 0444); | 108 | module_param_array(wssport, long, NULL, 0444); |
109 | MODULE_PARM_DESC(wssport, "Port # for CMI8330 WSS driver."); | 109 | MODULE_PARM_DESC(wssport, "Port # for CMI8330/CMI8329 WSS driver."); |
110 | module_param_array(wssirq, int, NULL, 0444); | 110 | module_param_array(wssirq, int, NULL, 0444); |
111 | MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver."); | 111 | MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330/CMI8329 WSS driver."); |
112 | module_param_array(wssdma, int, NULL, 0444); | 112 | module_param_array(wssdma, int, NULL, 0444); |
113 | MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); | 113 | MODULE_PARM_DESC(wssdma, "DMA for CMI8330/CMI8329 WSS driver."); |
114 | 114 | ||
115 | module_param_array(fmport, long, NULL, 0444); | 115 | module_param_array(fmport, long, NULL, 0444); |
116 | MODULE_PARM_DESC(fmport, "FM port # for CMI8330 driver."); | 116 | MODULE_PARM_DESC(fmport, "FM port # for CMI8330/CMI8329 driver."); |
117 | module_param_array(mpuport, long, NULL, 0444); | 117 | module_param_array(mpuport, long, NULL, 0444); |
118 | MODULE_PARM_DESC(mpuport, "MPU-401 port # for CMI8330 driver."); | 118 | MODULE_PARM_DESC(mpuport, "MPU-401 port # for CMI8330/CMI8329 driver."); |
119 | module_param_array(mpuirq, int, NULL, 0444); | 119 | module_param_array(mpuirq, int, NULL, 0444); |
120 | MODULE_PARM_DESC(mpuirq, "IRQ # for CMI8330 MPU-401 port."); | 120 | MODULE_PARM_DESC(mpuirq, "IRQ # for CMI8330/CMI8329 MPU-401 port."); |
121 | #ifdef CONFIG_PNP | 121 | #ifdef CONFIG_PNP |
122 | static int isa_registered; | 122 | static int isa_registered; |
123 | static int pnp_registered; | 123 | static int pnp_registered; |
@@ -156,6 +156,11 @@ static unsigned char snd_cmi8330_image[((CMI8330_CDINGAIN)-16) + 1] = | |||
156 | 156 | ||
157 | typedef int (*snd_pcm_open_callback_t)(struct snd_pcm_substream *); | 157 | typedef int (*snd_pcm_open_callback_t)(struct snd_pcm_substream *); |
158 | 158 | ||
159 | enum card_type { | ||
160 | CMI8330, | ||
161 | CMI8329 | ||
162 | }; | ||
163 | |||
159 | struct snd_cmi8330 { | 164 | struct snd_cmi8330 { |
160 | #ifdef CONFIG_PNP | 165 | #ifdef CONFIG_PNP |
161 | struct pnp_dev *cap; | 166 | struct pnp_dev *cap; |
@@ -172,11 +177,14 @@ struct snd_cmi8330 { | |||
172 | snd_pcm_open_callback_t open; | 177 | snd_pcm_open_callback_t open; |
173 | void *private_data; /* sb or wss */ | 178 | void *private_data; /* sb or wss */ |
174 | } streams[2]; | 179 | } streams[2]; |
180 | |||
181 | enum card_type type; | ||
175 | }; | 182 | }; |
176 | 183 | ||
177 | #ifdef CONFIG_PNP | 184 | #ifdef CONFIG_PNP |
178 | 185 | ||
179 | static struct pnp_card_device_id snd_cmi8330_pnpids[] = { | 186 | static struct pnp_card_device_id snd_cmi8330_pnpids[] = { |
187 | { .id = "CMI0001", .devs = { { "@X@0001" }, { "@@@0001" }, { "@H@0001" }, { "A@@0001" } } }, | ||
180 | { .id = "CMI0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } } }, | 188 | { .id = "CMI0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } } }, |
181 | { .id = "" } | 189 | { .id = "" } |
182 | }; | 190 | }; |
@@ -304,7 +312,7 @@ static int __devinit snd_cmi8330_mixer(struct snd_card *card, struct snd_cmi8330 | |||
304 | unsigned int idx; | 312 | unsigned int idx; |
305 | int err; | 313 | int err; |
306 | 314 | ||
307 | strcpy(card->mixername, "CMI8330/C3D"); | 315 | strcpy(card->mixername, (acard->type == CMI8329) ? "CMI8329" : "CMI8330/C3D"); |
308 | 316 | ||
309 | for (idx = 0; idx < ARRAY_SIZE(snd_cmi8330_controls); idx++) { | 317 | for (idx = 0; idx < ARRAY_SIZE(snd_cmi8330_controls); idx++) { |
310 | err = snd_ctl_add(card, | 318 | err = snd_ctl_add(card, |
@@ -329,6 +337,9 @@ static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard, | |||
329 | struct pnp_dev *pdev; | 337 | struct pnp_dev *pdev; |
330 | int err; | 338 | int err; |
331 | 339 | ||
340 | /* CMI8329 has a device with ID A@@0001, CMI8330 does not */ | ||
341 | acard->type = (id->devs[3].id[0]) ? CMI8329 : CMI8330; | ||
342 | |||
332 | acard->cap = pnp_request_card_device(card, id->devs[0].id, NULL); | 343 | acard->cap = pnp_request_card_device(card, id->devs[0].id, NULL); |
333 | if (acard->cap == NULL) | 344 | if (acard->cap == NULL) |
334 | return -EBUSY; | 345 | return -EBUSY; |
@@ -338,45 +349,52 @@ static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard, | |||
338 | return -EBUSY; | 349 | return -EBUSY; |
339 | 350 | ||
340 | acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL); | 351 | acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL); |
341 | if (acard->play == NULL) | 352 | if (acard->mpu == NULL) |
342 | return -EBUSY; | 353 | return -EBUSY; |
343 | 354 | ||
344 | pdev = acard->cap; | 355 | pdev = acard->cap; |
345 | 356 | ||
346 | err = pnp_activate_dev(pdev); | 357 | err = pnp_activate_dev(pdev); |
347 | if (err < 0) { | 358 | if (err < 0) { |
348 | snd_printk(KERN_ERR "CMI8330/C3D PnP configure failure\n"); | 359 | snd_printk(KERN_ERR "AD1848 PnP configure failure\n"); |
349 | return -EBUSY; | 360 | return -EBUSY; |
350 | } | 361 | } |
351 | wssport[dev] = pnp_port_start(pdev, 0); | 362 | wssport[dev] = pnp_port_start(pdev, 0); |
352 | wssdma[dev] = pnp_dma(pdev, 0); | 363 | wssdma[dev] = pnp_dma(pdev, 0); |
353 | wssirq[dev] = pnp_irq(pdev, 0); | 364 | wssirq[dev] = pnp_irq(pdev, 0); |
354 | fmport[dev] = pnp_port_start(pdev, 1); | 365 | if (pnp_port_start(pdev, 1)) |
366 | fmport[dev] = pnp_port_start(pdev, 1); | ||
355 | 367 | ||
356 | /* allocate SB16 resources */ | 368 | /* allocate SB16 resources */ |
357 | pdev = acard->play; | 369 | pdev = acard->play; |
358 | 370 | ||
359 | err = pnp_activate_dev(pdev); | 371 | err = pnp_activate_dev(pdev); |
360 | if (err < 0) { | 372 | if (err < 0) { |
361 | snd_printk(KERN_ERR "CMI8330/C3D (SB16) PnP configure failure\n"); | 373 | snd_printk(KERN_ERR "SB16 PnP configure failure\n"); |
362 | return -EBUSY; | 374 | return -EBUSY; |
363 | } | 375 | } |
364 | sbport[dev] = pnp_port_start(pdev, 0); | 376 | sbport[dev] = pnp_port_start(pdev, 0); |
365 | sbdma8[dev] = pnp_dma(pdev, 0); | 377 | sbdma8[dev] = pnp_dma(pdev, 0); |
366 | sbdma16[dev] = pnp_dma(pdev, 1); | 378 | sbdma16[dev] = pnp_dma(pdev, 1); |
367 | sbirq[dev] = pnp_irq(pdev, 0); | 379 | sbirq[dev] = pnp_irq(pdev, 0); |
380 | /* On CMI8239, the OPL3 port might be present in SB16 PnP resources */ | ||
381 | if (fmport[dev] == SNDRV_AUTO_PORT) { | ||
382 | if (pnp_port_start(pdev, 1)) | ||
383 | fmport[dev] = pnp_port_start(pdev, 1); | ||
384 | else | ||
385 | fmport[dev] = 0x388; /* Or hardwired */ | ||
386 | } | ||
368 | 387 | ||
369 | /* allocate MPU-401 resources */ | 388 | /* allocate MPU-401 resources */ |
370 | pdev = acard->mpu; | 389 | pdev = acard->mpu; |
371 | 390 | ||
372 | err = pnp_activate_dev(pdev); | 391 | err = pnp_activate_dev(pdev); |
373 | if (err < 0) { | 392 | if (err < 0) |
374 | snd_printk(KERN_ERR | 393 | snd_printk(KERN_ERR "MPU-401 PnP configure failure: will be disabled\n"); |
375 | "CMI8330/C3D (MPU-401) PnP configure failure\n"); | 394 | else { |
376 | return -EBUSY; | 395 | mpuport[dev] = pnp_port_start(pdev, 0); |
396 | mpuirq[dev] = pnp_irq(pdev, 0); | ||
377 | } | 397 | } |
378 | mpuport[dev] = pnp_port_start(pdev, 0); | ||
379 | mpuirq[dev] = pnp_irq(pdev, 0); | ||
380 | return 0; | 398 | return 0; |
381 | } | 399 | } |
382 | #endif | 400 | #endif |
@@ -430,9 +448,9 @@ static int __devinit snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 * | |||
430 | snd_cmi8330_capture_open | 448 | snd_cmi8330_capture_open |
431 | }; | 449 | }; |
432 | 450 | ||
433 | if ((err = snd_pcm_new(card, "CMI8330", 0, 1, 1, &pcm)) < 0) | 451 | if ((err = snd_pcm_new(card, (chip->type == CMI8329) ? "CMI8329" : "CMI8330", 0, 1, 1, &pcm)) < 0) |
434 | return err; | 452 | return err; |
435 | strcpy(pcm->name, "CMI8330"); | 453 | strcpy(pcm->name, (chip->type == CMI8329) ? "CMI8329" : "CMI8330"); |
436 | pcm->private_data = chip; | 454 | pcm->private_data = chip; |
437 | 455 | ||
438 | /* SB16 */ | 456 | /* SB16 */ |
@@ -527,11 +545,11 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev) | |||
527 | wssdma[dev], -1, | 545 | wssdma[dev], -1, |
528 | WSS_HW_DETECT, 0, &acard->wss); | 546 | WSS_HW_DETECT, 0, &acard->wss); |
529 | if (err < 0) { | 547 | if (err < 0) { |
530 | snd_printk(KERN_ERR PFX "(CMI8330) device busy??\n"); | 548 | snd_printk(KERN_ERR PFX "AD1848 device busy??\n"); |
531 | return err; | 549 | return err; |
532 | } | 550 | } |
533 | if (acard->wss->hardware != WSS_HW_CMI8330) { | 551 | if (acard->wss->hardware != WSS_HW_CMI8330) { |
534 | snd_printk(KERN_ERR PFX "(CMI8330) not found during probe\n"); | 552 | snd_printk(KERN_ERR PFX "AD1848 not found during probe\n"); |
535 | return -ENODEV; | 553 | return -ENODEV; |
536 | } | 554 | } |
537 | 555 | ||
@@ -541,11 +559,11 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev) | |||
541 | sbdma8[dev], | 559 | sbdma8[dev], |
542 | sbdma16[dev], | 560 | sbdma16[dev], |
543 | SB_HW_AUTO, &acard->sb)) < 0) { | 561 | SB_HW_AUTO, &acard->sb)) < 0) { |
544 | snd_printk(KERN_ERR PFX "(SB16) device busy??\n"); | 562 | snd_printk(KERN_ERR PFX "SB16 device busy??\n"); |
545 | return err; | 563 | return err; |
546 | } | 564 | } |
547 | if (acard->sb->hardware != SB_HW_16) { | 565 | if (acard->sb->hardware != SB_HW_16) { |
548 | snd_printk(KERN_ERR PFX "(SB16) not found during probe\n"); | 566 | snd_printk(KERN_ERR PFX "SB16 not found during probe\n"); |
549 | return err; | 567 | return err; |
550 | } | 568 | } |
551 | 569 | ||
@@ -585,8 +603,8 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev) | |||
585 | mpuport[dev]); | 603 | mpuport[dev]); |
586 | } | 604 | } |
587 | 605 | ||
588 | strcpy(card->driver, "CMI8330/C3D"); | 606 | strcpy(card->driver, (acard->type == CMI8329) ? "CMI8329" : "CMI8330/C3D"); |
589 | strcpy(card->shortname, "C-Media CMI8330/C3D"); | 607 | strcpy(card->shortname, (acard->type == CMI8329) ? "C-Media CMI8329" : "C-Media CMI8330/C3D"); |
590 | sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", | 608 | sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", |
591 | card->shortname, | 609 | card->shortname, |
592 | acard->wss->port, | 610 | acard->wss->port, |
diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index edb11eefdfe3..2dcf45bf7293 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c | |||
@@ -795,13 +795,13 @@ static int snd_gf1_pcm_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
795 | if (!(pcmp->flags & SNDRV_GF1_PCM_PFLG_ACTIVE)) | 795 | if (!(pcmp->flags & SNDRV_GF1_PCM_PFLG_ACTIVE)) |
796 | continue; | 796 | continue; |
797 | /* load real volume - better precision */ | 797 | /* load real volume - better precision */ |
798 | spin_lock_irqsave(&gus->reg_lock, flags); | 798 | spin_lock(&gus->reg_lock); |
799 | snd_gf1_select_voice(gus, pvoice->number); | 799 | snd_gf1_select_voice(gus, pvoice->number); |
800 | snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL); | 800 | snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL); |
801 | vol = pvoice == pcmp->pvoices[0] ? gus->gf1.pcm_volume_level_left : gus->gf1.pcm_volume_level_right; | 801 | vol = pvoice == pcmp->pvoices[0] ? gus->gf1.pcm_volume_level_left : gus->gf1.pcm_volume_level_right; |
802 | snd_gf1_write16(gus, SNDRV_GF1_VW_VOLUME, vol); | 802 | snd_gf1_write16(gus, SNDRV_GF1_VW_VOLUME, vol); |
803 | pcmp->final_volume = 1; | 803 | pcmp->final_volume = 1; |
804 | spin_unlock_irqrestore(&gus->reg_lock, flags); | 804 | spin_unlock(&gus->reg_lock); |
805 | } | 805 | } |
806 | spin_unlock_irqrestore(&gus->voice_alloc, flags); | 806 | spin_unlock_irqrestore(&gus->voice_alloc, flags); |
807 | return change; | 807 | return change; |
diff --git a/sound/oss/aedsp16.c b/sound/oss/aedsp16.c index 3ee9900ffd7b..35b5912cf3f8 100644 --- a/sound/oss/aedsp16.c +++ b/sound/oss/aedsp16.c | |||
@@ -325,8 +325,9 @@ | |||
325 | /* | 325 | /* |
326 | * Size of character arrays that store name and version of sound card | 326 | * Size of character arrays that store name and version of sound card |
327 | */ | 327 | */ |
328 | #define CARDNAMELEN 15 /* Size of the card's name in chars */ | 328 | #define CARDNAMELEN 15 /* Size of the card's name in chars */ |
329 | #define CARDVERLEN 2 /* Size of the card's version in chars */ | 329 | #define CARDVERLEN 10 /* Size of the card's version in chars */ |
330 | #define CARDVERDIGITS 2 /* Number of digits in the version */ | ||
330 | 331 | ||
331 | #if defined(CONFIG_SC6600) | 332 | #if defined(CONFIG_SC6600) |
332 | /* | 333 | /* |
@@ -410,7 +411,7 @@ | |||
410 | 411 | ||
411 | static int soft_cfg __initdata = 0; /* bitmapped config */ | 412 | static int soft_cfg __initdata = 0; /* bitmapped config */ |
412 | static int soft_cfg_mss __initdata = 0; /* bitmapped mss config */ | 413 | static int soft_cfg_mss __initdata = 0; /* bitmapped mss config */ |
413 | static int ver[CARDVERLEN] __initdata = {0, 0}; /* DSP Ver: | 414 | static int ver[CARDVERDIGITS] __initdata = {0, 0}; /* DSP Ver: |
414 | hi->ver[0] lo->ver[1] */ | 415 | hi->ver[0] lo->ver[1] */ |
415 | 416 | ||
416 | #if defined(CONFIG_SC6600) | 417 | #if defined(CONFIG_SC6600) |
@@ -957,7 +958,7 @@ static int __init aedsp16_dsp_version(int port) | |||
957 | * string is finished. | 958 | * string is finished. |
958 | */ | 959 | */ |
959 | ver[len++] = ret; | 960 | ver[len++] = ret; |
960 | } while (len < CARDVERLEN); | 961 | } while (len < CARDVERDIGITS); |
961 | sprintf(DSPVersion, "%d.%d", ver[0], ver[1]); | 962 | sprintf(DSPVersion, "%d.%d", ver[0], ver[1]); |
962 | 963 | ||
963 | DBG(("success.\n")); | 964 | DBG(("success.\n")); |
diff --git a/sound/oss/kahlua.c b/sound/oss/kahlua.c index c180598f1710..89466b056be7 100644 --- a/sound/oss/kahlua.c +++ b/sound/oss/kahlua.c | |||
@@ -199,7 +199,7 @@ MODULE_LICENSE("GPL"); | |||
199 | */ | 199 | */ |
200 | 200 | ||
201 | static struct pci_device_id id_tbl[] = { | 201 | static struct pci_device_id id_tbl[] = { |
202 | { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | 202 | { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO), 0 }, |
203 | { } | 203 | { } |
204 | }; | 204 | }; |
205 | 205 | ||
diff --git a/sound/oss/midibuf.c b/sound/oss/midibuf.c index a40be0cf1d97..782b3b84dac6 100644 --- a/sound/oss/midibuf.c +++ b/sound/oss/midibuf.c | |||
@@ -127,15 +127,16 @@ static void midi_poll(unsigned long dummy) | |||
127 | for (dev = 0; dev < num_midis; dev++) | 127 | for (dev = 0; dev < num_midis; dev++) |
128 | if (midi_devs[dev] != NULL && midi_out_buf[dev] != NULL) | 128 | if (midi_devs[dev] != NULL && midi_out_buf[dev] != NULL) |
129 | { | 129 | { |
130 | int ok = 1; | 130 | while (DATA_AVAIL(midi_out_buf[dev])) |
131 | |||
132 | while (DATA_AVAIL(midi_out_buf[dev]) && ok) | ||
133 | { | 131 | { |
132 | int ok; | ||
134 | int c = midi_out_buf[dev]->queue[midi_out_buf[dev]->head]; | 133 | int c = midi_out_buf[dev]->queue[midi_out_buf[dev]->head]; |
135 | 134 | ||
136 | spin_unlock_irqrestore(&lock,flags);/* Give some time to others */ | 135 | spin_unlock_irqrestore(&lock,flags);/* Give some time to others */ |
137 | ok = midi_devs[dev]->outputc(dev, c); | 136 | ok = midi_devs[dev]->outputc(dev, c); |
138 | spin_lock_irqsave(&lock, flags); | 137 | spin_lock_irqsave(&lock, flags); |
138 | if (!ok) | ||
139 | break; | ||
139 | midi_out_buf[dev]->head = (midi_out_buf[dev]->head + 1) % MAX_QUEUE_SIZE; | 140 | midi_out_buf[dev]->head = (midi_out_buf[dev]->head + 1) % MAX_QUEUE_SIZE; |
140 | midi_out_buf[dev]->len--; | 141 | midi_out_buf[dev]->len--; |
141 | } | 142 | } |
diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c index 6c0a770ed054..734b8f9e2f78 100644 --- a/sound/oss/mpu401.c +++ b/sound/oss/mpu401.c | |||
@@ -926,31 +926,21 @@ static struct midi_operations mpu401_midi_operations[MAX_MIDI_DEV]; | |||
926 | static void mpu401_chk_version(int n, struct mpu_config *devc) | 926 | static void mpu401_chk_version(int n, struct mpu_config *devc) |
927 | { | 927 | { |
928 | int tmp; | 928 | int tmp; |
929 | unsigned long flags; | ||
930 | 929 | ||
931 | devc->version = devc->revision = 0; | 930 | devc->version = devc->revision = 0; |
932 | 931 | ||
933 | spin_lock_irqsave(&devc->lock,flags); | 932 | tmp = mpu_cmd(n, 0xAC, 0); |
934 | if ((tmp = mpu_cmd(n, 0xAC, 0)) < 0) | 933 | if (tmp < 0) |
935 | { | ||
936 | spin_unlock_irqrestore(&devc->lock,flags); | ||
937 | return; | 934 | return; |
938 | } | ||
939 | if ((tmp & 0xf0) > 0x20) /* Why it's larger than 2.x ??? */ | 935 | if ((tmp & 0xf0) > 0x20) /* Why it's larger than 2.x ??? */ |
940 | { | ||
941 | spin_unlock_irqrestore(&devc->lock,flags); | ||
942 | return; | 936 | return; |
943 | } | ||
944 | devc->version = tmp; | 937 | devc->version = tmp; |
945 | 938 | ||
946 | if ((tmp = mpu_cmd(n, 0xAD, 0)) < 0) | 939 | if ((tmp = mpu_cmd(n, 0xAD, 0)) < 0) { |
947 | { | ||
948 | devc->version = 0; | 940 | devc->version = 0; |
949 | spin_unlock_irqrestore(&devc->lock,flags); | ||
950 | return; | 941 | return; |
951 | } | 942 | } |
952 | devc->revision = tmp; | 943 | devc->revision = tmp; |
953 | spin_unlock_irqrestore(&devc->lock,flags); | ||
954 | } | 944 | } |
955 | 945 | ||
956 | int attach_mpu401(struct address_info *hw_config, struct module *owner) | 946 | int attach_mpu401(struct address_info *hw_config, struct module *owner) |
@@ -1084,7 +1074,7 @@ int attach_mpu401(struct address_info *hw_config, struct module *owner) | |||
1084 | sprintf(mpu_synth_info[m].name, "%s (MPU401)", hw_config->name); | 1074 | sprintf(mpu_synth_info[m].name, "%s (MPU401)", hw_config->name); |
1085 | else | 1075 | else |
1086 | sprintf(mpu_synth_info[m].name, | 1076 | sprintf(mpu_synth_info[m].name, |
1087 | "MPU-401 %d.%d%c Midi interface #%d", | 1077 | "MPU-401 %d.%d%c MIDI #%d", |
1088 | (int) (devc->version & 0xf0) >> 4, | 1078 | (int) (devc->version & 0xf0) >> 4, |
1089 | devc->version & 0x0f, | 1079 | devc->version & 0x0f, |
1090 | revision_char, | 1080 | revision_char, |
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c index 187f72750e8f..6713110bdc75 100644 --- a/sound/oss/vwsnd.c +++ b/sound/oss/vwsnd.c | |||
@@ -628,7 +628,7 @@ static void li_setup_dma(dma_chan_t *chan, | |||
628 | ASSERT(!(buffer_paddr & 0xFF)); | 628 | ASSERT(!(buffer_paddr & 0xFF)); |
629 | chan->baseval = (buffer_paddr >> 8) | 1 << (37 - 8); | 629 | chan->baseval = (buffer_paddr >> 8) | 1 << (37 - 8); |
630 | 630 | ||
631 | chan->cfgval = (!LI_CCFG_LOCK | | 631 | chan->cfgval = ((chan->cfgval & ~LI_CCFG_LOCK) | |
632 | SHIFT_FIELD(desc->ad1843_slot, LI_CCFG_SLOT) | | 632 | SHIFT_FIELD(desc->ad1843_slot, LI_CCFG_SLOT) | |
633 | desc->direction | | 633 | desc->direction | |
634 | mode | | 634 | mode | |
@@ -638,9 +638,9 @@ static void li_setup_dma(dma_chan_t *chan, | |||
638 | tmask = 13 - fragshift; /* See Lithium DMA Notes above. */ | 638 | tmask = 13 - fragshift; /* See Lithium DMA Notes above. */ |
639 | ASSERT(size >= 2 && size <= 7); | 639 | ASSERT(size >= 2 && size <= 7); |
640 | ASSERT(tmask >= 1 && tmask <= 7); | 640 | ASSERT(tmask >= 1 && tmask <= 7); |
641 | chan->ctlval = (!LI_CCTL_RESET | | 641 | chan->ctlval = ((chan->ctlval & ~LI_CCTL_RESET) | |
642 | SHIFT_FIELD(size, LI_CCTL_SIZE) | | 642 | SHIFT_FIELD(size, LI_CCTL_SIZE) | |
643 | !LI_CCTL_DMA_ENABLE | | 643 | (chan->ctlval & ~LI_CCTL_DMA_ENABLE) | |
644 | SHIFT_FIELD(tmask, LI_CCTL_TMASK) | | 644 | SHIFT_FIELD(tmask, LI_CCTL_TMASK) | |
645 | SHIFT_FIELD(0, LI_CCTL_TPTR)); | 645 | SHIFT_FIELD(0, LI_CCTL_TPTR)); |
646 | 646 | ||
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 748f6b7d90b7..fb5ee3cc3968 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig | |||
@@ -135,11 +135,11 @@ config SND_AW2 | |||
135 | 135 | ||
136 | 136 | ||
137 | config SND_AZT3328 | 137 | config SND_AZT3328 |
138 | tristate "Aztech AZF3328 / PCI168 (EXPERIMENTAL)" | 138 | tristate "Aztech AZF3328 / PCI168" |
139 | depends on EXPERIMENTAL | ||
140 | select SND_OPL3_LIB | 139 | select SND_OPL3_LIB |
141 | select SND_MPU401_UART | 140 | select SND_MPU401_UART |
142 | select SND_PCM | 141 | select SND_PCM |
142 | select SND_RAWMIDI | ||
143 | help | 143 | help |
144 | Say Y here to include support for Aztech AZF3328 (PCI168) | 144 | Say Y here to include support for Aztech AZF3328 (PCI168) |
145 | soundcards. | 145 | soundcards. |
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index c551006e2920..b458d208720b 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c | |||
@@ -310,12 +310,16 @@ static int snd_ali_codec_ready(struct snd_ali *codec, | |||
310 | unsigned int res; | 310 | unsigned int res; |
311 | 311 | ||
312 | end_time = jiffies + msecs_to_jiffies(250); | 312 | end_time = jiffies + msecs_to_jiffies(250); |
313 | do { | 313 | |
314 | for (;;) { | ||
314 | res = snd_ali_5451_peek(codec,port); | 315 | res = snd_ali_5451_peek(codec,port); |
315 | if (!(res & 0x8000)) | 316 | if (!(res & 0x8000)) |
316 | return 0; | 317 | return 0; |
318 | if (!time_after_eq(end_time, jiffies)) | ||
319 | break; | ||
317 | schedule_timeout_uninterruptible(1); | 320 | schedule_timeout_uninterruptible(1); |
318 | } while (time_after_eq(end_time, jiffies)); | 321 | } |
322 | |||
319 | snd_ali_5451_poke(codec, port, res & ~0x8000); | 323 | snd_ali_5451_poke(codec, port, res & ~0x8000); |
320 | snd_printdd("ali_codec_ready: codec is not ready.\n "); | 324 | snd_printdd("ali_codec_ready: codec is not ready.\n "); |
321 | return -EIO; | 325 | return -EIO; |
@@ -327,15 +331,17 @@ static int snd_ali_stimer_ready(struct snd_ali *codec) | |||
327 | unsigned long dwChk1,dwChk2; | 331 | unsigned long dwChk1,dwChk2; |
328 | 332 | ||
329 | dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER); | 333 | dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER); |
330 | dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); | ||
331 | |||
332 | end_time = jiffies + msecs_to_jiffies(250); | 334 | end_time = jiffies + msecs_to_jiffies(250); |
333 | do { | 335 | |
336 | for (;;) { | ||
334 | dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); | 337 | dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); |
335 | if (dwChk2 != dwChk1) | 338 | if (dwChk2 != dwChk1) |
336 | return 0; | 339 | return 0; |
340 | if (!time_after_eq(end_time, jiffies)) | ||
341 | break; | ||
337 | schedule_timeout_uninterruptible(1); | 342 | schedule_timeout_uninterruptible(1); |
338 | } while (time_after_eq(end_time, jiffies)); | 343 | } |
344 | |||
339 | snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n"); | 345 | snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n"); |
340 | return -EIO; | 346 | return -EIO; |
341 | } | 347 | } |
@@ -472,45 +478,6 @@ static int snd_ali_reset_5451(struct snd_ali *codec) | |||
472 | return 0; | 478 | return 0; |
473 | } | 479 | } |
474 | 480 | ||
475 | #ifdef CODEC_RESET | ||
476 | |||
477 | static int snd_ali_reset_codec(struct snd_ali *codec) | ||
478 | { | ||
479 | struct pci_dev *pci_dev; | ||
480 | unsigned char bVal; | ||
481 | unsigned int dwVal; | ||
482 | unsigned short wCount, wReg; | ||
483 | |||
484 | pci_dev = codec->pci_m1533; | ||
485 | |||
486 | pci_read_config_dword(pci_dev, 0x7c, &dwVal); | ||
487 | pci_write_config_dword(pci_dev, 0x7c, dwVal | 0x08000000); | ||
488 | udelay(5000); | ||
489 | pci_read_config_dword(pci_dev, 0x7c, &dwVal); | ||
490 | pci_write_config_dword(pci_dev, 0x7c, dwVal & 0xf7ffffff); | ||
491 | udelay(5000); | ||
492 | |||
493 | bVal = inb(ALI_REG(codec,ALI_SCTRL)); | ||
494 | bVal |= 0x02; | ||
495 | outb(ALI_REG(codec,ALI_SCTRL),bVal); | ||
496 | udelay(5000); | ||
497 | bVal = inb(ALI_REG(codec,ALI_SCTRL)); | ||
498 | bVal &= 0xfd; | ||
499 | outb(ALI_REG(codec,ALI_SCTRL),bVal); | ||
500 | udelay(15000); | ||
501 | |||
502 | wCount = 200; | ||
503 | while (wCount--) { | ||
504 | wReg = snd_ali_codec_read(codec->ac97, AC97_POWERDOWN); | ||
505 | if ((wReg & 0x000f) == 0x000f) | ||
506 | return 0; | ||
507 | udelay(5000); | ||
508 | } | ||
509 | return -1; | ||
510 | } | ||
511 | |||
512 | #endif | ||
513 | |||
514 | /* | 481 | /* |
515 | * ALI 5451 Controller | 482 | * ALI 5451 Controller |
516 | */ | 483 | */ |
@@ -555,22 +522,6 @@ static void snd_ali_disable_address_interrupt(struct snd_ali *codec) | |||
555 | outl(gc, ALI_REG(codec, ALI_GC_CIR)); | 522 | outl(gc, ALI_REG(codec, ALI_GC_CIR)); |
556 | } | 523 | } |
557 | 524 | ||
558 | #if 0 /* not used */ | ||
559 | static void snd_ali_enable_voice_irq(struct snd_ali *codec, | ||
560 | unsigned int channel) | ||
561 | { | ||
562 | unsigned int mask; | ||
563 | struct snd_ali_channel_control *pchregs = &(codec->chregs); | ||
564 | |||
565 | snd_ali_printk("enable_voice_irq channel=%d\n",channel); | ||
566 | |||
567 | mask = 1 << (channel & 0x1f); | ||
568 | pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten)); | ||
569 | pchregs->data.ainten |= mask; | ||
570 | outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten)); | ||
571 | } | ||
572 | #endif | ||
573 | |||
574 | static void snd_ali_disable_voice_irq(struct snd_ali *codec, | 525 | static void snd_ali_disable_voice_irq(struct snd_ali *codec, |
575 | unsigned int channel) | 526 | unsigned int channel) |
576 | { | 527 | { |
@@ -671,16 +622,6 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel) | |||
671 | } | 622 | } |
672 | } | 623 | } |
673 | 624 | ||
674 | #if 0 /* not used */ | ||
675 | static void snd_ali_start_voice(struct snd_ali *codec, unsigned int channel) | ||
676 | { | ||
677 | unsigned int mask = 1 << (channel & 0x1f); | ||
678 | |||
679 | snd_ali_printk("start_voice: channel=%d\n",channel); | ||
680 | outl(mask, ALI_REG(codec,codec->chregs.regs.start)); | ||
681 | } | ||
682 | #endif | ||
683 | |||
684 | static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel) | 625 | static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel) |
685 | { | 626 | { |
686 | unsigned int mask = 1 << (channel & 0x1f); | 627 | unsigned int mask = 1 << (channel & 0x1f); |
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 71515ddb4593..d6752dff2a44 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c | |||
@@ -287,10 +287,10 @@ struct atiixp { | |||
287 | /* | 287 | /* |
288 | */ | 288 | */ |
289 | static struct pci_device_id snd_atiixp_ids[] = { | 289 | static struct pci_device_id snd_atiixp_ids[] = { |
290 | { 0x1002, 0x4341, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB200 */ | 290 | { PCI_VDEVICE(ATI, 0x4341), 0 }, /* SB200 */ |
291 | { 0x1002, 0x4361, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB300 */ | 291 | { PCI_VDEVICE(ATI, 0x4361), 0 }, /* SB300 */ |
292 | { 0x1002, 0x4370, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB400 */ | 292 | { PCI_VDEVICE(ATI, 0x4370), 0 }, /* SB400 */ |
293 | { 0x1002, 0x4382, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB600 */ | 293 | { PCI_VDEVICE(ATI, 0x4382), 0 }, /* SB600 */ |
294 | { 0, } | 294 | { 0, } |
295 | }; | 295 | }; |
296 | 296 | ||
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index c3136cccc559..e7e147bf8eb2 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c | |||
@@ -262,8 +262,8 @@ struct atiixp_modem { | |||
262 | /* | 262 | /* |
263 | */ | 263 | */ |
264 | static struct pci_device_id snd_atiixp_ids[] = { | 264 | static struct pci_device_id snd_atiixp_ids[] = { |
265 | { 0x1002, 0x434d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB200 */ | 265 | { PCI_VDEVICE(ATI, 0x434d), 0 }, /* SB200 */ |
266 | { 0x1002, 0x4378, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* SB400 */ | 266 | { PCI_VDEVICE(ATI, 0x4378), 0 }, /* SB400 */ |
267 | { 0, } | 267 | { 0, } |
268 | }; | 268 | }; |
269 | 269 | ||
diff --git a/sound/pci/au88x0/au8810.c b/sound/pci/au88x0/au8810.c index fce22c7af0ea..c0e8c6b295cb 100644 --- a/sound/pci/au88x0/au8810.c +++ b/sound/pci/au88x0/au8810.c | |||
@@ -1,8 +1,7 @@ | |||
1 | #include "au8810.h" | 1 | #include "au8810.h" |
2 | #include "au88x0.h" | 2 | #include "au88x0.h" |
3 | static struct pci_device_id snd_vortex_ids[] = { | 3 | static struct pci_device_id snd_vortex_ids[] = { |
4 | {PCI_VENDOR_ID_AUREAL, PCI_DEVICE_ID_AUREAL_ADVANTAGE, | 4 | {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_ADVANTAGE), 1,}, |
5 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1,}, | ||
6 | {0,} | 5 | {0,} |
7 | }; | 6 | }; |
8 | 7 | ||
diff --git a/sound/pci/au88x0/au8820.c b/sound/pci/au88x0/au8820.c index d1fbcce07257..a6527330df58 100644 --- a/sound/pci/au88x0/au8820.c +++ b/sound/pci/au88x0/au8820.c | |||
@@ -1,8 +1,7 @@ | |||
1 | #include "au8820.h" | 1 | #include "au8820.h" |
2 | #include "au88x0.h" | 2 | #include "au88x0.h" |
3 | static struct pci_device_id snd_vortex_ids[] = { | 3 | static struct pci_device_id snd_vortex_ids[] = { |
4 | {PCI_VENDOR_ID_AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_1, | 4 | {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_1), 0,}, |
5 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,}, | ||
6 | {0,} | 5 | {0,} |
7 | }; | 6 | }; |
8 | 7 | ||
diff --git a/sound/pci/au88x0/au8830.c b/sound/pci/au88x0/au8830.c index d4f2717c14fb..6c702ad4352a 100644 --- a/sound/pci/au88x0/au8830.c +++ b/sound/pci/au88x0/au8830.c | |||
@@ -1,8 +1,7 @@ | |||
1 | #include "au8830.h" | 1 | #include "au8830.h" |
2 | #include "au88x0.h" | 2 | #include "au88x0.h" |
3 | static struct pci_device_id snd_vortex_ids[] = { | 3 | static struct pci_device_id snd_vortex_ids[] = { |
4 | {PCI_VENDOR_ID_AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_2, | 4 | {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_2), 0,}, |
5 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,}, | ||
6 | {0,} | 5 | {0,} |
7 | }; | 6 | }; |
8 | 7 | ||
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index f290bc56178f..8451a0169f32 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168). | 2 | * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168). |
3 | * Copyright (C) 2002, 2005 - 2008 by Andreas Mohr <andi AT lisas.de> | 3 | * Copyright (C) 2002, 2005 - 2009 by Andreas Mohr <andi AT lisas.de> |
4 | * | 4 | * |
5 | * Framework borrowed from Bart Hartgers's als4000.c. | 5 | * Framework borrowed from Bart Hartgers's als4000.c. |
6 | * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801), | 6 | * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801), |
@@ -10,6 +10,13 @@ | |||
10 | * PCI168 A/AP, sub ID 8000 | 10 | * PCI168 A/AP, sub ID 8000 |
11 | * Please give me feedback in case you try my driver with one of these!! | 11 | * Please give me feedback in case you try my driver with one of these!! |
12 | * | 12 | * |
13 | * Keywords: Windows XP Vista 168nt4-125.zip 168win95-125.zip PCI 168 download | ||
14 | * (XP/Vista do not support this card at all but every Linux distribution | ||
15 | * has very good support out of the box; | ||
16 | * just to make sure that the right people hit this and get to know that, | ||
17 | * despite the high level of Internet ignorance - as usual :-P - | ||
18 | * about very good support for this card - on Linux!) | ||
19 | * | ||
13 | * GPL LICENSE | 20 | * GPL LICENSE |
14 | * This program is free software; you can redistribute it and/or modify | 21 | * This program is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU General Public License as published by | 22 | * it under the terms of the GNU General Public License as published by |
@@ -71,10 +78,11 @@ | |||
71 | * - built-in General DirectX timer having a 20 bits counter | 78 | * - built-in General DirectX timer having a 20 bits counter |
72 | * with 1us resolution (see below!) | 79 | * with 1us resolution (see below!) |
73 | * - I2S serial output port for external DAC | 80 | * - I2S serial output port for external DAC |
81 | * [FIXME: 3.3V or 5V level? maximum rate is 66.2kHz right?] | ||
74 | * - supports 33MHz PCI spec 2.1, PCI power management 1.0, compliant with ACPI | 82 | * - supports 33MHz PCI spec 2.1, PCI power management 1.0, compliant with ACPI |
75 | * - supports hardware volume control | 83 | * - supports hardware volume control |
76 | * - single chip low cost solution (128 pin QFP) | 84 | * - single chip low cost solution (128 pin QFP) |
77 | * - supports programmable Sub-vendor and Sub-system ID | 85 | * - supports programmable Sub-vendor and Sub-system ID [24C02 SEEPROM chip] |
78 | * required for Microsoft's logo compliance (FIXME: where?) | 86 | * required for Microsoft's logo compliance (FIXME: where?) |
79 | * At least the Trident 4D Wave DX has one bit somewhere | 87 | * At least the Trident 4D Wave DX has one bit somewhere |
80 | * to enable writes to PCI subsystem VID registers, that should be it. | 88 | * to enable writes to PCI subsystem VID registers, that should be it. |
@@ -82,6 +90,7 @@ | |||
82 | * some custom data starting at 0x80. What kind of config settings | 90 | * some custom data starting at 0x80. What kind of config settings |
83 | * are located in our extended PCI space anyway?? | 91 | * are located in our extended PCI space anyway?? |
84 | * - PCI168 AP(W) card: power amplifier with 4 Watts/channel at 4 Ohms | 92 | * - PCI168 AP(W) card: power amplifier with 4 Watts/channel at 4 Ohms |
93 | * [TDA1517P chip] | ||
85 | * | 94 | * |
86 | * Note that this driver now is actually *better* than the Windows driver, | 95 | * Note that this driver now is actually *better* than the Windows driver, |
87 | * since it additionally supports the card's 1MHz DirectX timer - just try | 96 | * since it additionally supports the card's 1MHz DirectX timer - just try |
@@ -146,10 +155,15 @@ | |||
146 | * to read the Digital Enhanced Game Port. Not sure whether it is fixable. | 155 | * to read the Digital Enhanced Game Port. Not sure whether it is fixable. |
147 | * | 156 | * |
148 | * TODO | 157 | * TODO |
158 | * - use PCI_VDEVICE | ||
159 | * - verify driver status on x86_64 | ||
160 | * - test multi-card driver operation | ||
161 | * - (ab)use 1MHz DirectX timer as kernel clocksource | ||
149 | * - test MPU401 MIDI playback etc. | 162 | * - test MPU401 MIDI playback etc. |
150 | * - add more power micro-management (disable various units of the card | 163 | * - add more power micro-management (disable various units of the card |
151 | * as long as they're unused). However this requires more I/O ports which I | 164 | * as long as they're unused, to improve audio quality and save power). |
152 | * haven't figured out yet and which thus might not even exist... | 165 | * However this requires more I/O ports which I haven't figured out yet |
166 | * and which thus might not even exist... | ||
153 | * The standard suspend/resume functionality could probably make use of | 167 | * The standard suspend/resume functionality could probably make use of |
154 | * some improvement, too... | 168 | * some improvement, too... |
155 | * - figure out what all unknown port bits are responsible for | 169 | * - figure out what all unknown port bits are responsible for |
@@ -185,25 +199,46 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}"); | |||
185 | #define SUPPORT_GAMEPORT 1 | 199 | #define SUPPORT_GAMEPORT 1 |
186 | #endif | 200 | #endif |
187 | 201 | ||
202 | /* === Debug settings === | ||
203 | Further diagnostic functionality than the settings below | ||
204 | does not need to be provided, since one can easily write a bash script | ||
205 | to dump the card's I/O ports (those listed in lspci -v -v): | ||
206 | function dump() | ||
207 | { | ||
208 | local descr=$1; local addr=$2; local count=$3 | ||
209 | |||
210 | echo "${descr}: ${count} @ ${addr}:" | ||
211 | dd if=/dev/port skip=$[${addr}] count=${count} bs=1 2>/dev/null| hexdump -C | ||
212 | } | ||
213 | and then use something like | ||
214 | "dump joy200 0x200 8", "dump mpu388 0x388 4", "dump joy 0xb400 8", | ||
215 | "dump codec00 0xa800 32", "dump mixer 0xb800 64", "dump synth 0xbc00 8", | ||
216 | possibly within a "while true; do ... sleep 1; done" loop. | ||
217 | Tweaking ports could be done using | ||
218 | VALSTRING="`printf "%02x" $value`" | ||
219 | printf "\x""$VALSTRING"|dd of=/dev/port seek=$[${addr}] bs=1 2>/dev/null | ||
220 | */ | ||
221 | |||
188 | #define DEBUG_MISC 0 | 222 | #define DEBUG_MISC 0 |
189 | #define DEBUG_CALLS 0 | 223 | #define DEBUG_CALLS 0 |
190 | #define DEBUG_MIXER 0 | 224 | #define DEBUG_MIXER 0 |
191 | #define DEBUG_PLAY_REC 0 | 225 | #define DEBUG_CODEC 0 |
192 | #define DEBUG_IO 0 | 226 | #define DEBUG_IO 0 |
193 | #define DEBUG_TIMER 0 | 227 | #define DEBUG_TIMER 0 |
194 | #define DEBUG_GAME 0 | 228 | #define DEBUG_GAME 0 |
229 | #define DEBUG_PM 0 | ||
195 | #define MIXER_TESTING 0 | 230 | #define MIXER_TESTING 0 |
196 | 231 | ||
197 | #if DEBUG_MISC | 232 | #if DEBUG_MISC |
198 | #define snd_azf3328_dbgmisc(format, args...) printk(KERN_ERR format, ##args) | 233 | #define snd_azf3328_dbgmisc(format, args...) printk(KERN_DEBUG format, ##args) |
199 | #else | 234 | #else |
200 | #define snd_azf3328_dbgmisc(format, args...) | 235 | #define snd_azf3328_dbgmisc(format, args...) |
201 | #endif | 236 | #endif |
202 | 237 | ||
203 | #if DEBUG_CALLS | 238 | #if DEBUG_CALLS |
204 | #define snd_azf3328_dbgcalls(format, args...) printk(format, ##args) | 239 | #define snd_azf3328_dbgcalls(format, args...) printk(format, ##args) |
205 | #define snd_azf3328_dbgcallenter() printk(KERN_ERR "--> %s\n", __func__) | 240 | #define snd_azf3328_dbgcallenter() printk(KERN_DEBUG "--> %s\n", __func__) |
206 | #define snd_azf3328_dbgcallleave() printk(KERN_ERR "<-- %s\n", __func__) | 241 | #define snd_azf3328_dbgcallleave() printk(KERN_DEBUG "<-- %s\n", __func__) |
207 | #else | 242 | #else |
208 | #define snd_azf3328_dbgcalls(format, args...) | 243 | #define snd_azf3328_dbgcalls(format, args...) |
209 | #define snd_azf3328_dbgcallenter() | 244 | #define snd_azf3328_dbgcallenter() |
@@ -216,10 +251,10 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}"); | |||
216 | #define snd_azf3328_dbgmixer(format, args...) | 251 | #define snd_azf3328_dbgmixer(format, args...) |
217 | #endif | 252 | #endif |
218 | 253 | ||
219 | #if DEBUG_PLAY_REC | 254 | #if DEBUG_CODEC |
220 | #define snd_azf3328_dbgplay(format, args...) printk(KERN_DEBUG format, ##args) | 255 | #define snd_azf3328_dbgcodec(format, args...) printk(KERN_DEBUG format, ##args) |
221 | #else | 256 | #else |
222 | #define snd_azf3328_dbgplay(format, args...) | 257 | #define snd_azf3328_dbgcodec(format, args...) |
223 | #endif | 258 | #endif |
224 | 259 | ||
225 | #if DEBUG_MISC | 260 | #if DEBUG_MISC |
@@ -234,6 +269,12 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}"); | |||
234 | #define snd_azf3328_dbggame(format, args...) | 269 | #define snd_azf3328_dbggame(format, args...) |
235 | #endif | 270 | #endif |
236 | 271 | ||
272 | #if DEBUG_PM | ||
273 | #define snd_azf3328_dbgpm(format, args...) printk(KERN_DEBUG format, ##args) | ||
274 | #else | ||
275 | #define snd_azf3328_dbgpm(format, args...) | ||
276 | #endif | ||
277 | |||
237 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | 278 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
238 | module_param_array(index, int, NULL, 0444); | 279 | module_param_array(index, int, NULL, 0444); |
239 | MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard."); | 280 | MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard."); |
@@ -250,22 +291,23 @@ static int seqtimer_scaling = 128; | |||
250 | module_param(seqtimer_scaling, int, 0444); | 291 | module_param(seqtimer_scaling, int, 0444); |
251 | MODULE_PARM_DESC(seqtimer_scaling, "Set 1024000Hz sequencer timer scale factor (lockup danger!). Default 128."); | 292 | MODULE_PARM_DESC(seqtimer_scaling, "Set 1024000Hz sequencer timer scale factor (lockup danger!). Default 128."); |
252 | 293 | ||
253 | struct snd_azf3328_audio_stream { | 294 | struct snd_azf3328_codec_data { |
295 | unsigned long io_base; | ||
254 | struct snd_pcm_substream *substream; | 296 | struct snd_pcm_substream *substream; |
255 | int enabled; | 297 | bool running; |
256 | int running; | 298 | const char *name; |
257 | unsigned long portbase; | ||
258 | }; | 299 | }; |
259 | 300 | ||
260 | enum snd_azf3328_stream_index { | 301 | enum snd_azf3328_codec_type { |
261 | AZF_PLAYBACK = 0, | 302 | AZF_CODEC_PLAYBACK = 0, |
262 | AZF_CAPTURE = 1, | 303 | AZF_CODEC_CAPTURE = 1, |
304 | AZF_CODEC_I2S_OUT = 2, | ||
263 | }; | 305 | }; |
264 | 306 | ||
265 | struct snd_azf3328 { | 307 | struct snd_azf3328 { |
266 | /* often-used fields towards beginning, then grouped */ | 308 | /* often-used fields towards beginning, then grouped */ |
267 | 309 | ||
268 | unsigned long codec_io; /* usually 0xb000, size 128 */ | 310 | unsigned long ctrl_io; /* usually 0xb000, size 128 */ |
269 | unsigned long game_io; /* usually 0xb400, size 8 */ | 311 | unsigned long game_io; /* usually 0xb400, size 8 */ |
270 | unsigned long mpu_io; /* usually 0xb800, size 4 */ | 312 | unsigned long mpu_io; /* usually 0xb800, size 4 */ |
271 | unsigned long opl3_io; /* usually 0xbc00, size 8 */ | 313 | unsigned long opl3_io; /* usually 0xbc00, size 8 */ |
@@ -275,15 +317,17 @@ struct snd_azf3328 { | |||
275 | 317 | ||
276 | struct snd_timer *timer; | 318 | struct snd_timer *timer; |
277 | 319 | ||
278 | struct snd_pcm *pcm; | 320 | struct snd_pcm *pcm[3]; |
279 | struct snd_azf3328_audio_stream audio_stream[2]; | 321 | |
322 | /* playback, recording and I2S out codecs */ | ||
323 | struct snd_azf3328_codec_data codecs[3]; | ||
280 | 324 | ||
281 | struct snd_card *card; | 325 | struct snd_card *card; |
282 | struct snd_rawmidi *rmidi; | 326 | struct snd_rawmidi *rmidi; |
283 | 327 | ||
284 | #ifdef SUPPORT_GAMEPORT | 328 | #ifdef SUPPORT_GAMEPORT |
285 | struct gameport *gameport; | 329 | struct gameport *gameport; |
286 | int axes[4]; | 330 | u16 axes[4]; |
287 | #endif | 331 | #endif |
288 | 332 | ||
289 | struct pci_dev *pci; | 333 | struct pci_dev *pci; |
@@ -293,16 +337,16 @@ struct snd_azf3328 { | |||
293 | * If we need to add more registers here, then we might try to fold this | 337 | * If we need to add more registers here, then we might try to fold this |
294 | * into some transparent combined shadow register handling with | 338 | * into some transparent combined shadow register handling with |
295 | * CONFIG_PM register storage below, but that's slightly difficult. */ | 339 | * CONFIG_PM register storage below, but that's slightly difficult. */ |
296 | u16 shadow_reg_codec_6AH; | 340 | u16 shadow_reg_ctrl_6AH; |
297 | 341 | ||
298 | #ifdef CONFIG_PM | 342 | #ifdef CONFIG_PM |
299 | /* register value containers for power management | 343 | /* register value containers for power management |
300 | * Note: not always full I/O range preserved (just like Win driver!) */ | 344 | * Note: not always full I/O range preserved (similar to Win driver!) */ |
301 | u16 saved_regs_codec[AZF_IO_SIZE_CODEC_PM / 2]; | 345 | u32 saved_regs_ctrl[AZF_ALIGN(AZF_IO_SIZE_CTRL_PM) / 4]; |
302 | u16 saved_regs_game [AZF_IO_SIZE_GAME_PM / 2]; | 346 | u32 saved_regs_game[AZF_ALIGN(AZF_IO_SIZE_GAME_PM) / 4]; |
303 | u16 saved_regs_mpu [AZF_IO_SIZE_MPU_PM / 2]; | 347 | u32 saved_regs_mpu[AZF_ALIGN(AZF_IO_SIZE_MPU_PM) / 4]; |
304 | u16 saved_regs_opl3 [AZF_IO_SIZE_OPL3_PM / 2]; | 348 | u32 saved_regs_opl3[AZF_ALIGN(AZF_IO_SIZE_OPL3_PM) / 4]; |
305 | u16 saved_regs_mixer[AZF_IO_SIZE_MIXER_PM / 2]; | 349 | u32 saved_regs_mixer[AZF_ALIGN(AZF_IO_SIZE_MIXER_PM) / 4]; |
306 | #endif | 350 | #endif |
307 | }; | 351 | }; |
308 | 352 | ||
@@ -316,7 +360,7 @@ MODULE_DEVICE_TABLE(pci, snd_azf3328_ids); | |||
316 | 360 | ||
317 | 361 | ||
318 | static int | 362 | static int |
319 | snd_azf3328_io_reg_setb(unsigned reg, u8 mask, int do_set) | 363 | snd_azf3328_io_reg_setb(unsigned reg, u8 mask, bool do_set) |
320 | { | 364 | { |
321 | u8 prev = inb(reg), new; | 365 | u8 prev = inb(reg), new; |
322 | 366 | ||
@@ -331,39 +375,72 @@ snd_azf3328_io_reg_setb(unsigned reg, u8 mask, int do_set) | |||
331 | } | 375 | } |
332 | 376 | ||
333 | static inline void | 377 | static inline void |
334 | snd_azf3328_codec_outb(const struct snd_azf3328 *chip, unsigned reg, u8 value) | 378 | snd_azf3328_codec_outb(const struct snd_azf3328_codec_data *codec, |
379 | unsigned reg, | ||
380 | u8 value | ||
381 | ) | ||
335 | { | 382 | { |
336 | outb(value, chip->codec_io + reg); | 383 | outb(value, codec->io_base + reg); |
337 | } | 384 | } |
338 | 385 | ||
339 | static inline u8 | 386 | static inline u8 |
340 | snd_azf3328_codec_inb(const struct snd_azf3328 *chip, unsigned reg) | 387 | snd_azf3328_codec_inb(const struct snd_azf3328_codec_data *codec, unsigned reg) |
341 | { | 388 | { |
342 | return inb(chip->codec_io + reg); | 389 | return inb(codec->io_base + reg); |
343 | } | 390 | } |
344 | 391 | ||
345 | static inline void | 392 | static inline void |
346 | snd_azf3328_codec_outw(const struct snd_azf3328 *chip, unsigned reg, u16 value) | 393 | snd_azf3328_codec_outw(const struct snd_azf3328_codec_data *codec, |
394 | unsigned reg, | ||
395 | u16 value | ||
396 | ) | ||
347 | { | 397 | { |
348 | outw(value, chip->codec_io + reg); | 398 | outw(value, codec->io_base + reg); |
349 | } | 399 | } |
350 | 400 | ||
351 | static inline u16 | 401 | static inline u16 |
352 | snd_azf3328_codec_inw(const struct snd_azf3328 *chip, unsigned reg) | 402 | snd_azf3328_codec_inw(const struct snd_azf3328_codec_data *codec, unsigned reg) |
353 | { | 403 | { |
354 | return inw(chip->codec_io + reg); | 404 | return inw(codec->io_base + reg); |
355 | } | 405 | } |
356 | 406 | ||
357 | static inline void | 407 | static inline void |
358 | snd_azf3328_codec_outl(const struct snd_azf3328 *chip, unsigned reg, u32 value) | 408 | snd_azf3328_codec_outl(const struct snd_azf3328_codec_data *codec, |
409 | unsigned reg, | ||
410 | u32 value | ||
411 | ) | ||
359 | { | 412 | { |
360 | outl(value, chip->codec_io + reg); | 413 | outl(value, codec->io_base + reg); |
361 | } | 414 | } |
362 | 415 | ||
363 | static inline u32 | 416 | static inline u32 |
364 | snd_azf3328_codec_inl(const struct snd_azf3328 *chip, unsigned reg) | 417 | snd_azf3328_codec_inl(const struct snd_azf3328_codec_data *codec, unsigned reg) |
418 | { | ||
419 | return inl(codec->io_base + reg); | ||
420 | } | ||
421 | |||
422 | static inline void | ||
423 | snd_azf3328_ctrl_outb(const struct snd_azf3328 *chip, unsigned reg, u8 value) | ||
424 | { | ||
425 | outb(value, chip->ctrl_io + reg); | ||
426 | } | ||
427 | |||
428 | static inline u8 | ||
429 | snd_azf3328_ctrl_inb(const struct snd_azf3328 *chip, unsigned reg) | ||
430 | { | ||
431 | return inb(chip->ctrl_io + reg); | ||
432 | } | ||
433 | |||
434 | static inline void | ||
435 | snd_azf3328_ctrl_outw(const struct snd_azf3328 *chip, unsigned reg, u16 value) | ||
436 | { | ||
437 | outw(value, chip->ctrl_io + reg); | ||
438 | } | ||
439 | |||
440 | static inline void | ||
441 | snd_azf3328_ctrl_outl(const struct snd_azf3328 *chip, unsigned reg, u32 value) | ||
365 | { | 442 | { |
366 | return inl(chip->codec_io + reg); | 443 | outl(value, chip->ctrl_io + reg); |
367 | } | 444 | } |
368 | 445 | ||
369 | static inline void | 446 | static inline void |
@@ -404,13 +481,13 @@ snd_azf3328_mixer_inw(const struct snd_azf3328 *chip, unsigned reg) | |||
404 | 481 | ||
405 | #define AZF_MUTE_BIT 0x80 | 482 | #define AZF_MUTE_BIT 0x80 |
406 | 483 | ||
407 | static int | 484 | static bool |
408 | snd_azf3328_mixer_set_mute(const struct snd_azf3328 *chip, | 485 | snd_azf3328_mixer_set_mute(const struct snd_azf3328 *chip, |
409 | unsigned reg, int do_mute | 486 | unsigned reg, bool do_mute |
410 | ) | 487 | ) |
411 | { | 488 | { |
412 | unsigned long portbase = chip->mixer_io + reg + 1; | 489 | unsigned long portbase = chip->mixer_io + reg + 1; |
413 | int updated; | 490 | bool updated; |
414 | 491 | ||
415 | /* the mute bit is on the *second* (i.e. right) register of a | 492 | /* the mute bit is on the *second* (i.e. right) register of a |
416 | * left/right channel setting */ | 493 | * left/right channel setting */ |
@@ -569,7 +646,7 @@ snd_azf3328_get_mixer(struct snd_kcontrol *kcontrol, | |||
569 | { | 646 | { |
570 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); | 647 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); |
571 | struct azf3328_mixer_reg reg; | 648 | struct azf3328_mixer_reg reg; |
572 | unsigned int oreg, val; | 649 | u16 oreg, val; |
573 | 650 | ||
574 | snd_azf3328_dbgcallenter(); | 651 | snd_azf3328_dbgcallenter(); |
575 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); | 652 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); |
@@ -600,7 +677,7 @@ snd_azf3328_put_mixer(struct snd_kcontrol *kcontrol, | |||
600 | { | 677 | { |
601 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); | 678 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); |
602 | struct azf3328_mixer_reg reg; | 679 | struct azf3328_mixer_reg reg; |
603 | unsigned int oreg, nreg, val; | 680 | u16 oreg, nreg, val; |
604 | 681 | ||
605 | snd_azf3328_dbgcallenter(); | 682 | snd_azf3328_dbgcallenter(); |
606 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); | 683 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); |
@@ -709,7 +786,7 @@ snd_azf3328_put_mixer_enum(struct snd_kcontrol *kcontrol, | |||
709 | { | 786 | { |
710 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); | 787 | struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); |
711 | struct azf3328_mixer_reg reg; | 788 | struct azf3328_mixer_reg reg; |
712 | unsigned int oreg, nreg, val; | 789 | u16 oreg, nreg, val; |
713 | 790 | ||
714 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); | 791 | snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); |
715 | oreg = snd_azf3328_mixer_inw(chip, reg.reg); | 792 | oreg = snd_azf3328_mixer_inw(chip, reg.reg); |
@@ -867,14 +944,15 @@ snd_azf3328_hw_free(struct snd_pcm_substream *substream) | |||
867 | 944 | ||
868 | static void | 945 | static void |
869 | snd_azf3328_codec_setfmt(struct snd_azf3328 *chip, | 946 | snd_azf3328_codec_setfmt(struct snd_azf3328 *chip, |
870 | unsigned reg, | 947 | enum snd_azf3328_codec_type codec_type, |
871 | enum azf_freq_t bitrate, | 948 | enum azf_freq_t bitrate, |
872 | unsigned int format_width, | 949 | unsigned int format_width, |
873 | unsigned int channels | 950 | unsigned int channels |
874 | ) | 951 | ) |
875 | { | 952 | { |
876 | u16 val = 0xff00; | ||
877 | unsigned long flags; | 953 | unsigned long flags; |
954 | const struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; | ||
955 | u16 val = 0xff00; | ||
878 | 956 | ||
879 | snd_azf3328_dbgcallenter(); | 957 | snd_azf3328_dbgcallenter(); |
880 | switch (bitrate) { | 958 | switch (bitrate) { |
@@ -917,7 +995,7 @@ snd_azf3328_codec_setfmt(struct snd_azf3328 *chip, | |||
917 | spin_lock_irqsave(&chip->reg_lock, flags); | 995 | spin_lock_irqsave(&chip->reg_lock, flags); |
918 | 996 | ||
919 | /* set bitrate/format */ | 997 | /* set bitrate/format */ |
920 | snd_azf3328_codec_outw(chip, reg, val); | 998 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_SOUNDFORMAT, val); |
921 | 999 | ||
922 | /* changing the bitrate/format settings switches off the | 1000 | /* changing the bitrate/format settings switches off the |
923 | * audio output with an annoying click in case of 8/16bit format change | 1001 | * audio output with an annoying click in case of 8/16bit format change |
@@ -926,11 +1004,11 @@ snd_azf3328_codec_setfmt(struct snd_azf3328 *chip, | |||
926 | * (FIXME: yes, it works, but what exactly am I doing here?? :) | 1004 | * (FIXME: yes, it works, but what exactly am I doing here?? :) |
927 | * FIXME: does this have some side effects for full-duplex | 1005 | * FIXME: does this have some side effects for full-duplex |
928 | * or other dramatic side effects? */ | 1006 | * or other dramatic side effects? */ |
929 | if (reg == IDX_IO_PLAY_SOUNDFORMAT) /* only do it for playback */ | 1007 | if (codec_type == AZF_CODEC_PLAYBACK) /* only do it for playback */ |
930 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1008 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
931 | snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS) | | 1009 | snd_azf3328_codec_inw(codec, IDX_IO_CODEC_DMA_FLAGS) | |
932 | DMA_PLAY_SOMETHING1 | | 1010 | DMA_RUN_SOMETHING1 | |
933 | DMA_PLAY_SOMETHING2 | | 1011 | DMA_RUN_SOMETHING2 | |
934 | SOMETHING_ALMOST_ALWAYS_SET | | 1012 | SOMETHING_ALMOST_ALWAYS_SET | |
935 | DMA_EPILOGUE_SOMETHING | | 1013 | DMA_EPILOGUE_SOMETHING | |
936 | DMA_SOMETHING_ELSE | 1014 | DMA_SOMETHING_ELSE |
@@ -942,112 +1020,134 @@ snd_azf3328_codec_setfmt(struct snd_azf3328 *chip, | |||
942 | 1020 | ||
943 | static inline void | 1021 | static inline void |
944 | snd_azf3328_codec_setfmt_lowpower(struct snd_azf3328 *chip, | 1022 | snd_azf3328_codec_setfmt_lowpower(struct snd_azf3328 *chip, |
945 | unsigned reg | 1023 | enum snd_azf3328_codec_type codec_type |
946 | ) | 1024 | ) |
947 | { | 1025 | { |
948 | /* choose lowest frequency for low power consumption. | 1026 | /* choose lowest frequency for low power consumption. |
949 | * While this will cause louder noise due to rather coarse frequency, | 1027 | * While this will cause louder noise due to rather coarse frequency, |
950 | * it should never matter since output should always | 1028 | * it should never matter since output should always |
951 | * get disabled properly when idle anyway. */ | 1029 | * get disabled properly when idle anyway. */ |
952 | snd_azf3328_codec_setfmt(chip, reg, AZF_FREQ_4000, 8, 1); | 1030 | snd_azf3328_codec_setfmt(chip, codec_type, AZF_FREQ_4000, 8, 1); |
953 | } | 1031 | } |
954 | 1032 | ||
955 | static void | 1033 | static void |
956 | snd_azf3328_codec_reg_6AH_update(struct snd_azf3328 *chip, | 1034 | snd_azf3328_ctrl_reg_6AH_update(struct snd_azf3328 *chip, |
957 | unsigned bitmask, | 1035 | unsigned bitmask, |
958 | int enable | 1036 | bool enable |
959 | ) | 1037 | ) |
960 | { | 1038 | { |
961 | if (enable) | 1039 | bool do_mask = !enable; |
962 | chip->shadow_reg_codec_6AH &= ~bitmask; | 1040 | if (do_mask) |
1041 | chip->shadow_reg_ctrl_6AH |= bitmask; | ||
963 | else | 1042 | else |
964 | chip->shadow_reg_codec_6AH |= bitmask; | 1043 | chip->shadow_reg_ctrl_6AH &= ~bitmask; |
965 | snd_azf3328_dbgplay("6AH_update mask 0x%04x enable %d: val 0x%04x\n", | 1044 | snd_azf3328_dbgcodec("6AH_update mask 0x%04x do_mask %d: val 0x%04x\n", |
966 | bitmask, enable, chip->shadow_reg_codec_6AH); | 1045 | bitmask, do_mask, chip->shadow_reg_ctrl_6AH); |
967 | snd_azf3328_codec_outw(chip, IDX_IO_6AH, chip->shadow_reg_codec_6AH); | 1046 | snd_azf3328_ctrl_outw(chip, IDX_IO_6AH, chip->shadow_reg_ctrl_6AH); |
968 | } | 1047 | } |
969 | 1048 | ||
970 | static inline void | 1049 | static inline void |
971 | snd_azf3328_codec_enable(struct snd_azf3328 *chip, int enable) | 1050 | snd_azf3328_ctrl_enable_codecs(struct snd_azf3328 *chip, bool enable) |
972 | { | 1051 | { |
973 | snd_azf3328_dbgplay("codec_enable %d\n", enable); | 1052 | snd_azf3328_dbgcodec("codec_enable %d\n", enable); |
974 | /* no idea what exactly is being done here, but I strongly assume it's | 1053 | /* no idea what exactly is being done here, but I strongly assume it's |
975 | * PM related */ | 1054 | * PM related */ |
976 | snd_azf3328_codec_reg_6AH_update( | 1055 | snd_azf3328_ctrl_reg_6AH_update( |
977 | chip, IO_6A_PAUSE_PLAYBACK_BIT8, enable | 1056 | chip, IO_6A_PAUSE_PLAYBACK_BIT8, enable |
978 | ); | 1057 | ); |
979 | } | 1058 | } |
980 | 1059 | ||
981 | static void | 1060 | static void |
982 | snd_azf3328_codec_activity(struct snd_azf3328 *chip, | 1061 | snd_azf3328_ctrl_codec_activity(struct snd_azf3328 *chip, |
983 | enum snd_azf3328_stream_index stream_type, | 1062 | enum snd_azf3328_codec_type codec_type, |
984 | int enable | 1063 | bool enable |
985 | ) | 1064 | ) |
986 | { | 1065 | { |
987 | int need_change = (chip->audio_stream[stream_type].running != enable); | 1066 | struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; |
1067 | bool need_change = (codec->running != enable); | ||
988 | 1068 | ||
989 | snd_azf3328_dbgplay( | 1069 | snd_azf3328_dbgcodec( |
990 | "codec_activity: type %d, enable %d, need_change %d\n", | 1070 | "codec_activity: %s codec, enable %d, need_change %d\n", |
991 | stream_type, enable, need_change | 1071 | codec->name, enable, need_change |
992 | ); | 1072 | ); |
993 | if (need_change) { | 1073 | if (need_change) { |
994 | enum snd_azf3328_stream_index other = | 1074 | static const struct { |
995 | (stream_type == AZF_PLAYBACK) ? | 1075 | enum snd_azf3328_codec_type other1; |
996 | AZF_CAPTURE : AZF_PLAYBACK; | 1076 | enum snd_azf3328_codec_type other2; |
997 | /* small check to prevent shutting down the other party | 1077 | } peer_codecs[3] = |
998 | * in case it's active */ | 1078 | { { AZF_CODEC_CAPTURE, AZF_CODEC_I2S_OUT }, |
999 | if ((enable) || !(chip->audio_stream[other].running)) | 1079 | { AZF_CODEC_PLAYBACK, AZF_CODEC_I2S_OUT }, |
1000 | snd_azf3328_codec_enable(chip, enable); | 1080 | { AZF_CODEC_PLAYBACK, AZF_CODEC_CAPTURE } }; |
1081 | bool call_function; | ||
1082 | |||
1083 | if (enable) | ||
1084 | /* if enable codec, call enable_codecs func | ||
1085 | to enable codec supply... */ | ||
1086 | call_function = 1; | ||
1087 | else { | ||
1088 | /* ...otherwise call enable_codecs func | ||
1089 | (which globally shuts down operation of codecs) | ||
1090 | only in case the other codecs are currently | ||
1091 | not active either! */ | ||
1092 | call_function = | ||
1093 | ((!chip->codecs[peer_codecs[codec_type].other1] | ||
1094 | .running) | ||
1095 | && (!chip->codecs[peer_codecs[codec_type].other2] | ||
1096 | .running)); | ||
1097 | } | ||
1098 | if (call_function) | ||
1099 | snd_azf3328_ctrl_enable_codecs(chip, enable); | ||
1001 | 1100 | ||
1002 | /* ...and adjust clock, too | 1101 | /* ...and adjust clock, too |
1003 | * (reduce noise and power consumption) */ | 1102 | * (reduce noise and power consumption) */ |
1004 | if (!enable) | 1103 | if (!enable) |
1005 | snd_azf3328_codec_setfmt_lowpower( | 1104 | snd_azf3328_codec_setfmt_lowpower( |
1006 | chip, | 1105 | chip, |
1007 | chip->audio_stream[stream_type].portbase | 1106 | codec_type |
1008 | + IDX_IO_PLAY_SOUNDFORMAT | ||
1009 | ); | 1107 | ); |
1108 | codec->running = enable; | ||
1010 | } | 1109 | } |
1011 | chip->audio_stream[stream_type].running = enable; | ||
1012 | } | 1110 | } |
1013 | 1111 | ||
1014 | static void | 1112 | static void |
1015 | snd_azf3328_setdmaa(struct snd_azf3328 *chip, | 1113 | snd_azf3328_codec_setdmaa(struct snd_azf3328 *chip, |
1016 | long unsigned int addr, | 1114 | enum snd_azf3328_codec_type codec_type, |
1017 | unsigned int count, | 1115 | unsigned long addr, |
1018 | unsigned int size, | 1116 | unsigned int count, |
1019 | enum snd_azf3328_stream_index stream_type | 1117 | unsigned int size |
1020 | ) | 1118 | ) |
1021 | { | 1119 | { |
1120 | const struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; | ||
1022 | snd_azf3328_dbgcallenter(); | 1121 | snd_azf3328_dbgcallenter(); |
1023 | if (!chip->audio_stream[stream_type].running) { | 1122 | if (!codec->running) { |
1024 | /* AZF3328 uses a two buffer pointer DMA playback approach */ | 1123 | /* AZF3328 uses a two buffer pointer DMA transfer approach */ |
1025 | 1124 | ||
1026 | unsigned long flags, portbase, addr_area2; | 1125 | unsigned long flags, addr_area2; |
1027 | 1126 | ||
1028 | /* width 32bit (prevent overflow): */ | 1127 | /* width 32bit (prevent overflow): */ |
1029 | unsigned long count_areas, count_tmp; | 1128 | u32 count_areas, lengths; |
1030 | 1129 | ||
1031 | portbase = chip->audio_stream[stream_type].portbase; | ||
1032 | count_areas = size/2; | 1130 | count_areas = size/2; |
1033 | addr_area2 = addr+count_areas; | 1131 | addr_area2 = addr+count_areas; |
1034 | count_areas--; /* max. index */ | 1132 | count_areas--; /* max. index */ |
1035 | snd_azf3328_dbgplay("set DMA: buf1 %08lx[%lu], buf2 %08lx[%lu]\n", addr, count_areas, addr_area2, count_areas); | 1133 | snd_azf3328_dbgcodec("setdma: buffers %08lx[%u] / %08lx[%u]\n", |
1134 | addr, count_areas, addr_area2, count_areas); | ||
1036 | 1135 | ||
1037 | /* build combined I/O buffer length word */ | 1136 | /* build combined I/O buffer length word */ |
1038 | count_tmp = count_areas; | 1137 | lengths = (count_areas << 16) | (count_areas); |
1039 | count_areas |= (count_tmp << 16); | ||
1040 | spin_lock_irqsave(&chip->reg_lock, flags); | 1138 | spin_lock_irqsave(&chip->reg_lock, flags); |
1041 | outl(addr, portbase + IDX_IO_PLAY_DMA_START_1); | 1139 | snd_azf3328_codec_outl(codec, IDX_IO_CODEC_DMA_START_1, addr); |
1042 | outl(addr_area2, portbase + IDX_IO_PLAY_DMA_START_2); | 1140 | snd_azf3328_codec_outl(codec, IDX_IO_CODEC_DMA_START_2, |
1043 | outl(count_areas, portbase + IDX_IO_PLAY_DMA_LEN_1); | 1141 | addr_area2); |
1142 | snd_azf3328_codec_outl(codec, IDX_IO_CODEC_DMA_LENGTHS, | ||
1143 | lengths); | ||
1044 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1144 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1045 | } | 1145 | } |
1046 | snd_azf3328_dbgcallleave(); | 1146 | snd_azf3328_dbgcallleave(); |
1047 | } | 1147 | } |
1048 | 1148 | ||
1049 | static int | 1149 | static int |
1050 | snd_azf3328_playback_prepare(struct snd_pcm_substream *substream) | 1150 | snd_azf3328_codec_prepare(struct snd_pcm_substream *substream) |
1051 | { | 1151 | { |
1052 | #if 0 | 1152 | #if 0 |
1053 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1153 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); |
@@ -1058,157 +1158,161 @@ snd_azf3328_playback_prepare(struct snd_pcm_substream *substream) | |||
1058 | 1158 | ||
1059 | snd_azf3328_dbgcallenter(); | 1159 | snd_azf3328_dbgcallenter(); |
1060 | #if 0 | 1160 | #if 0 |
1061 | snd_azf3328_codec_setfmt(chip, IDX_IO_PLAY_SOUNDFORMAT, | 1161 | snd_azf3328_codec_setfmt(chip, AZF_CODEC_..., |
1062 | runtime->rate, | 1162 | runtime->rate, |
1063 | snd_pcm_format_width(runtime->format), | 1163 | snd_pcm_format_width(runtime->format), |
1064 | runtime->channels); | 1164 | runtime->channels); |
1065 | snd_azf3328_setdmaa(chip, runtime->dma_addr, count, size, AZF_PLAYBACK); | 1165 | snd_azf3328_codec_setdmaa(chip, AZF_CODEC_..., |
1166 | runtime->dma_addr, count, size); | ||
1066 | #endif | 1167 | #endif |
1067 | snd_azf3328_dbgcallleave(); | 1168 | snd_azf3328_dbgcallleave(); |
1068 | return 0; | 1169 | return 0; |
1069 | } | 1170 | } |
1070 | 1171 | ||
1071 | static int | 1172 | static int |
1072 | snd_azf3328_capture_prepare(struct snd_pcm_substream *substream) | 1173 | snd_azf3328_codec_trigger(enum snd_azf3328_codec_type codec_type, |
1073 | { | 1174 | struct snd_pcm_substream *substream, int cmd) |
1074 | #if 0 | ||
1075 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | ||
1076 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
1077 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | ||
1078 | unsigned int count = snd_pcm_lib_period_bytes(substream); | ||
1079 | #endif | ||
1080 | |||
1081 | snd_azf3328_dbgcallenter(); | ||
1082 | #if 0 | ||
1083 | snd_azf3328_codec_setfmt(chip, IDX_IO_REC_SOUNDFORMAT, | ||
1084 | runtime->rate, | ||
1085 | snd_pcm_format_width(runtime->format), | ||
1086 | runtime->channels); | ||
1087 | snd_azf3328_setdmaa(chip, runtime->dma_addr, count, size, AZF_CAPTURE); | ||
1088 | #endif | ||
1089 | snd_azf3328_dbgcallleave(); | ||
1090 | return 0; | ||
1091 | } | ||
1092 | |||
1093 | static int | ||
1094 | snd_azf3328_playback_trigger(struct snd_pcm_substream *substream, int cmd) | ||
1095 | { | 1175 | { |
1096 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1176 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); |
1177 | const struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; | ||
1097 | struct snd_pcm_runtime *runtime = substream->runtime; | 1178 | struct snd_pcm_runtime *runtime = substream->runtime; |
1098 | int result = 0; | 1179 | int result = 0; |
1099 | unsigned int status1; | 1180 | u16 flags1; |
1100 | int previously_muted; | 1181 | bool previously_muted = 0; |
1182 | bool is_playback_codec = (AZF_CODEC_PLAYBACK == codec_type); | ||
1101 | 1183 | ||
1102 | snd_azf3328_dbgcalls("snd_azf3328_playback_trigger cmd %d\n", cmd); | 1184 | snd_azf3328_dbgcalls("snd_azf3328_codec_trigger cmd %d\n", cmd); |
1103 | 1185 | ||
1104 | switch (cmd) { | 1186 | switch (cmd) { |
1105 | case SNDRV_PCM_TRIGGER_START: | 1187 | case SNDRV_PCM_TRIGGER_START: |
1106 | snd_azf3328_dbgplay("START PLAYBACK\n"); | 1188 | snd_azf3328_dbgcodec("START %s\n", codec->name); |
1107 | 1189 | ||
1108 | /* mute WaveOut (avoid clicking during setup) */ | 1190 | if (is_playback_codec) { |
1109 | previously_muted = | 1191 | /* mute WaveOut (avoid clicking during setup) */ |
1110 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 1); | 1192 | previously_muted = |
1193 | snd_azf3328_mixer_set_mute( | ||
1194 | chip, IDX_MIXER_WAVEOUT, 1 | ||
1195 | ); | ||
1196 | } | ||
1111 | 1197 | ||
1112 | snd_azf3328_codec_setfmt(chip, IDX_IO_PLAY_SOUNDFORMAT, | 1198 | snd_azf3328_codec_setfmt(chip, codec_type, |
1113 | runtime->rate, | 1199 | runtime->rate, |
1114 | snd_pcm_format_width(runtime->format), | 1200 | snd_pcm_format_width(runtime->format), |
1115 | runtime->channels); | 1201 | runtime->channels); |
1116 | 1202 | ||
1117 | spin_lock(&chip->reg_lock); | 1203 | spin_lock(&chip->reg_lock); |
1118 | /* first, remember current value: */ | 1204 | /* first, remember current value: */ |
1119 | status1 = snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS); | 1205 | flags1 = snd_azf3328_codec_inw(codec, IDX_IO_CODEC_DMA_FLAGS); |
1120 | 1206 | ||
1121 | /* stop playback */ | 1207 | /* stop transfer */ |
1122 | status1 &= ~DMA_RESUME; | 1208 | flags1 &= ~DMA_RESUME; |
1123 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1209 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1124 | 1210 | ||
1125 | /* FIXME: clear interrupts or what??? */ | 1211 | /* FIXME: clear interrupts or what??? */ |
1126 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_IRQTYPE, 0xffff); | 1212 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_IRQTYPE, 0xffff); |
1127 | spin_unlock(&chip->reg_lock); | 1213 | spin_unlock(&chip->reg_lock); |
1128 | 1214 | ||
1129 | snd_azf3328_setdmaa(chip, runtime->dma_addr, | 1215 | snd_azf3328_codec_setdmaa(chip, codec_type, runtime->dma_addr, |
1130 | snd_pcm_lib_period_bytes(substream), | 1216 | snd_pcm_lib_period_bytes(substream), |
1131 | snd_pcm_lib_buffer_bytes(substream), | 1217 | snd_pcm_lib_buffer_bytes(substream) |
1132 | AZF_PLAYBACK); | 1218 | ); |
1133 | 1219 | ||
1134 | spin_lock(&chip->reg_lock); | 1220 | spin_lock(&chip->reg_lock); |
1135 | #ifdef WIN9X | 1221 | #ifdef WIN9X |
1136 | /* FIXME: enable playback/recording??? */ | 1222 | /* FIXME: enable playback/recording??? */ |
1137 | status1 |= DMA_PLAY_SOMETHING1 | DMA_PLAY_SOMETHING2; | 1223 | flags1 |= DMA_RUN_SOMETHING1 | DMA_RUN_SOMETHING2; |
1138 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1224 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1139 | 1225 | ||
1140 | /* start playback again */ | 1226 | /* start transfer again */ |
1141 | /* FIXME: what is this value (0x0010)??? */ | 1227 | /* FIXME: what is this value (0x0010)??? */ |
1142 | status1 |= DMA_RESUME | DMA_EPILOGUE_SOMETHING; | 1228 | flags1 |= DMA_RESUME | DMA_EPILOGUE_SOMETHING; |
1143 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1229 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1144 | #else /* NT4 */ | 1230 | #else /* NT4 */ |
1145 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1231 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1146 | 0x0000); | 1232 | 0x0000); |
1147 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1233 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1148 | DMA_PLAY_SOMETHING1); | 1234 | DMA_RUN_SOMETHING1); |
1149 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1235 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1150 | DMA_PLAY_SOMETHING1 | | 1236 | DMA_RUN_SOMETHING1 | |
1151 | DMA_PLAY_SOMETHING2); | 1237 | DMA_RUN_SOMETHING2); |
1152 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1238 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1153 | DMA_RESUME | | 1239 | DMA_RESUME | |
1154 | SOMETHING_ALMOST_ALWAYS_SET | | 1240 | SOMETHING_ALMOST_ALWAYS_SET | |
1155 | DMA_EPILOGUE_SOMETHING | | 1241 | DMA_EPILOGUE_SOMETHING | |
1156 | DMA_SOMETHING_ELSE); | 1242 | DMA_SOMETHING_ELSE); |
1157 | #endif | 1243 | #endif |
1158 | spin_unlock(&chip->reg_lock); | 1244 | spin_unlock(&chip->reg_lock); |
1159 | snd_azf3328_codec_activity(chip, AZF_PLAYBACK, 1); | 1245 | snd_azf3328_ctrl_codec_activity(chip, codec_type, 1); |
1160 | 1246 | ||
1161 | /* now unmute WaveOut */ | 1247 | if (is_playback_codec) { |
1162 | if (!previously_muted) | 1248 | /* now unmute WaveOut */ |
1163 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 0); | 1249 | if (!previously_muted) |
1250 | snd_azf3328_mixer_set_mute( | ||
1251 | chip, IDX_MIXER_WAVEOUT, 0 | ||
1252 | ); | ||
1253 | } | ||
1164 | 1254 | ||
1165 | snd_azf3328_dbgplay("STARTED PLAYBACK\n"); | 1255 | snd_azf3328_dbgcodec("STARTED %s\n", codec->name); |
1166 | break; | 1256 | break; |
1167 | case SNDRV_PCM_TRIGGER_RESUME: | 1257 | case SNDRV_PCM_TRIGGER_RESUME: |
1168 | snd_azf3328_dbgplay("RESUME PLAYBACK\n"); | 1258 | snd_azf3328_dbgcodec("RESUME %s\n", codec->name); |
1169 | /* resume playback if we were active */ | 1259 | /* resume codec if we were active */ |
1170 | spin_lock(&chip->reg_lock); | 1260 | spin_lock(&chip->reg_lock); |
1171 | if (chip->audio_stream[AZF_PLAYBACK].running) | 1261 | if (codec->running) |
1172 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1262 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1173 | snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS) | DMA_RESUME); | 1263 | snd_azf3328_codec_inw( |
1264 | codec, IDX_IO_CODEC_DMA_FLAGS | ||
1265 | ) | DMA_RESUME | ||
1266 | ); | ||
1174 | spin_unlock(&chip->reg_lock); | 1267 | spin_unlock(&chip->reg_lock); |
1175 | break; | 1268 | break; |
1176 | case SNDRV_PCM_TRIGGER_STOP: | 1269 | case SNDRV_PCM_TRIGGER_STOP: |
1177 | snd_azf3328_dbgplay("STOP PLAYBACK\n"); | 1270 | snd_azf3328_dbgcodec("STOP %s\n", codec->name); |
1178 | 1271 | ||
1179 | /* mute WaveOut (avoid clicking during setup) */ | 1272 | if (is_playback_codec) { |
1180 | previously_muted = | 1273 | /* mute WaveOut (avoid clicking during setup) */ |
1181 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 1); | 1274 | previously_muted = |
1275 | snd_azf3328_mixer_set_mute( | ||
1276 | chip, IDX_MIXER_WAVEOUT, 1 | ||
1277 | ); | ||
1278 | } | ||
1182 | 1279 | ||
1183 | spin_lock(&chip->reg_lock); | 1280 | spin_lock(&chip->reg_lock); |
1184 | /* first, remember current value: */ | 1281 | /* first, remember current value: */ |
1185 | status1 = snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS); | 1282 | flags1 = snd_azf3328_codec_inw(codec, IDX_IO_CODEC_DMA_FLAGS); |
1186 | 1283 | ||
1187 | /* stop playback */ | 1284 | /* stop transfer */ |
1188 | status1 &= ~DMA_RESUME; | 1285 | flags1 &= ~DMA_RESUME; |
1189 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1286 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1190 | 1287 | ||
1191 | /* hmm, is this really required? we're resetting the same bit | 1288 | /* hmm, is this really required? we're resetting the same bit |
1192 | * immediately thereafter... */ | 1289 | * immediately thereafter... */ |
1193 | status1 |= DMA_PLAY_SOMETHING1; | 1290 | flags1 |= DMA_RUN_SOMETHING1; |
1194 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1291 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1195 | 1292 | ||
1196 | status1 &= ~DMA_PLAY_SOMETHING1; | 1293 | flags1 &= ~DMA_RUN_SOMETHING1; |
1197 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, status1); | 1294 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, flags1); |
1198 | spin_unlock(&chip->reg_lock); | 1295 | spin_unlock(&chip->reg_lock); |
1199 | snd_azf3328_codec_activity(chip, AZF_PLAYBACK, 0); | 1296 | snd_azf3328_ctrl_codec_activity(chip, codec_type, 0); |
1200 | 1297 | ||
1201 | /* now unmute WaveOut */ | 1298 | if (is_playback_codec) { |
1202 | if (!previously_muted) | 1299 | /* now unmute WaveOut */ |
1203 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 0); | 1300 | if (!previously_muted) |
1301 | snd_azf3328_mixer_set_mute( | ||
1302 | chip, IDX_MIXER_WAVEOUT, 0 | ||
1303 | ); | ||
1304 | } | ||
1204 | 1305 | ||
1205 | snd_azf3328_dbgplay("STOPPED PLAYBACK\n"); | 1306 | snd_azf3328_dbgcodec("STOPPED %s\n", codec->name); |
1206 | break; | 1307 | break; |
1207 | case SNDRV_PCM_TRIGGER_SUSPEND: | 1308 | case SNDRV_PCM_TRIGGER_SUSPEND: |
1208 | snd_azf3328_dbgplay("SUSPEND PLAYBACK\n"); | 1309 | snd_azf3328_dbgcodec("SUSPEND %s\n", codec->name); |
1209 | /* make sure playback is stopped */ | 1310 | /* make sure codec is stopped */ |
1210 | snd_azf3328_codec_outw(chip, IDX_IO_PLAY_FLAGS, | 1311 | snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, |
1211 | snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS) & ~DMA_RESUME); | 1312 | snd_azf3328_codec_inw( |
1313 | codec, IDX_IO_CODEC_DMA_FLAGS | ||
1314 | ) & ~DMA_RESUME | ||
1315 | ); | ||
1212 | break; | 1316 | break; |
1213 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 1317 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
1214 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n"); | 1318 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n"); |
@@ -1217,7 +1321,7 @@ snd_azf3328_playback_trigger(struct snd_pcm_substream *substream, int cmd) | |||
1217 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n"); | 1321 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n"); |
1218 | break; | 1322 | break; |
1219 | default: | 1323 | default: |
1220 | printk(KERN_ERR "FIXME: unknown trigger mode!\n"); | 1324 | snd_printk(KERN_ERR "FIXME: unknown trigger mode!\n"); |
1221 | return -EINVAL; | 1325 | return -EINVAL; |
1222 | } | 1326 | } |
1223 | 1327 | ||
@@ -1225,172 +1329,74 @@ snd_azf3328_playback_trigger(struct snd_pcm_substream *substream, int cmd) | |||
1225 | return result; | 1329 | return result; |
1226 | } | 1330 | } |
1227 | 1331 | ||
1228 | /* this is just analogous to playback; I'm not quite sure whether recording | ||
1229 | * should actually be triggered like that */ | ||
1230 | static int | 1332 | static int |
1231 | snd_azf3328_capture_trigger(struct snd_pcm_substream *substream, int cmd) | 1333 | snd_azf3328_codec_playback_trigger(struct snd_pcm_substream *substream, int cmd) |
1232 | { | 1334 | { |
1233 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1335 | return snd_azf3328_codec_trigger(AZF_CODEC_PLAYBACK, substream, cmd); |
1234 | struct snd_pcm_runtime *runtime = substream->runtime; | 1336 | } |
1235 | int result = 0; | ||
1236 | unsigned int status1; | ||
1237 | |||
1238 | snd_azf3328_dbgcalls("snd_azf3328_capture_trigger cmd %d\n", cmd); | ||
1239 | |||
1240 | switch (cmd) { | ||
1241 | case SNDRV_PCM_TRIGGER_START: | ||
1242 | |||
1243 | snd_azf3328_dbgplay("START CAPTURE\n"); | ||
1244 | |||
1245 | snd_azf3328_codec_setfmt(chip, IDX_IO_REC_SOUNDFORMAT, | ||
1246 | runtime->rate, | ||
1247 | snd_pcm_format_width(runtime->format), | ||
1248 | runtime->channels); | ||
1249 | |||
1250 | spin_lock(&chip->reg_lock); | ||
1251 | /* first, remember current value: */ | ||
1252 | status1 = snd_azf3328_codec_inw(chip, IDX_IO_REC_FLAGS); | ||
1253 | |||
1254 | /* stop recording */ | ||
1255 | status1 &= ~DMA_RESUME; | ||
1256 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1257 | |||
1258 | /* FIXME: clear interrupts or what??? */ | ||
1259 | snd_azf3328_codec_outw(chip, IDX_IO_REC_IRQTYPE, 0xffff); | ||
1260 | spin_unlock(&chip->reg_lock); | ||
1261 | |||
1262 | snd_azf3328_setdmaa(chip, runtime->dma_addr, | ||
1263 | snd_pcm_lib_period_bytes(substream), | ||
1264 | snd_pcm_lib_buffer_bytes(substream), | ||
1265 | AZF_CAPTURE); | ||
1266 | |||
1267 | spin_lock(&chip->reg_lock); | ||
1268 | #ifdef WIN9X | ||
1269 | /* FIXME: enable playback/recording??? */ | ||
1270 | status1 |= DMA_PLAY_SOMETHING1 | DMA_PLAY_SOMETHING2; | ||
1271 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1272 | |||
1273 | /* start capture again */ | ||
1274 | /* FIXME: what is this value (0x0010)??? */ | ||
1275 | status1 |= DMA_RESUME | DMA_EPILOGUE_SOMETHING; | ||
1276 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1277 | #else | ||
1278 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1279 | 0x0000); | ||
1280 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1281 | DMA_PLAY_SOMETHING1); | ||
1282 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1283 | DMA_PLAY_SOMETHING1 | | ||
1284 | DMA_PLAY_SOMETHING2); | ||
1285 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1286 | DMA_RESUME | | ||
1287 | SOMETHING_ALMOST_ALWAYS_SET | | ||
1288 | DMA_EPILOGUE_SOMETHING | | ||
1289 | DMA_SOMETHING_ELSE); | ||
1290 | #endif | ||
1291 | spin_unlock(&chip->reg_lock); | ||
1292 | snd_azf3328_codec_activity(chip, AZF_CAPTURE, 1); | ||
1293 | |||
1294 | snd_azf3328_dbgplay("STARTED CAPTURE\n"); | ||
1295 | break; | ||
1296 | case SNDRV_PCM_TRIGGER_RESUME: | ||
1297 | snd_azf3328_dbgplay("RESUME CAPTURE\n"); | ||
1298 | /* resume recording if we were active */ | ||
1299 | spin_lock(&chip->reg_lock); | ||
1300 | if (chip->audio_stream[AZF_CAPTURE].running) | ||
1301 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1302 | snd_azf3328_codec_inw(chip, IDX_IO_REC_FLAGS) | DMA_RESUME); | ||
1303 | spin_unlock(&chip->reg_lock); | ||
1304 | break; | ||
1305 | case SNDRV_PCM_TRIGGER_STOP: | ||
1306 | snd_azf3328_dbgplay("STOP CAPTURE\n"); | ||
1307 | |||
1308 | spin_lock(&chip->reg_lock); | ||
1309 | /* first, remember current value: */ | ||
1310 | status1 = snd_azf3328_codec_inw(chip, IDX_IO_REC_FLAGS); | ||
1311 | |||
1312 | /* stop recording */ | ||
1313 | status1 &= ~DMA_RESUME; | ||
1314 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1315 | |||
1316 | status1 |= DMA_PLAY_SOMETHING1; | ||
1317 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1318 | |||
1319 | status1 &= ~DMA_PLAY_SOMETHING1; | ||
1320 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, status1); | ||
1321 | spin_unlock(&chip->reg_lock); | ||
1322 | snd_azf3328_codec_activity(chip, AZF_CAPTURE, 0); | ||
1323 | 1337 | ||
1324 | snd_azf3328_dbgplay("STOPPED CAPTURE\n"); | 1338 | static int |
1325 | break; | 1339 | snd_azf3328_codec_capture_trigger(struct snd_pcm_substream *substream, int cmd) |
1326 | case SNDRV_PCM_TRIGGER_SUSPEND: | 1340 | { |
1327 | snd_azf3328_dbgplay("SUSPEND CAPTURE\n"); | 1341 | return snd_azf3328_codec_trigger(AZF_CODEC_CAPTURE, substream, cmd); |
1328 | /* make sure recording is stopped */ | 1342 | } |
1329 | snd_azf3328_codec_outw(chip, IDX_IO_REC_FLAGS, | ||
1330 | snd_azf3328_codec_inw(chip, IDX_IO_REC_FLAGS) & ~DMA_RESUME); | ||
1331 | break; | ||
1332 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
1333 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n"); | ||
1334 | break; | ||
1335 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
1336 | snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n"); | ||
1337 | break; | ||
1338 | default: | ||
1339 | printk(KERN_ERR "FIXME: unknown trigger mode!\n"); | ||
1340 | return -EINVAL; | ||
1341 | } | ||
1342 | 1343 | ||
1343 | snd_azf3328_dbgcallleave(); | 1344 | static int |
1344 | return result; | 1345 | snd_azf3328_codec_i2s_out_trigger(struct snd_pcm_substream *substream, int cmd) |
1346 | { | ||
1347 | return snd_azf3328_codec_trigger(AZF_CODEC_I2S_OUT, substream, cmd); | ||
1345 | } | 1348 | } |
1346 | 1349 | ||
1347 | static snd_pcm_uframes_t | 1350 | static snd_pcm_uframes_t |
1348 | snd_azf3328_playback_pointer(struct snd_pcm_substream *substream) | 1351 | snd_azf3328_codec_pointer(struct snd_pcm_substream *substream, |
1352 | enum snd_azf3328_codec_type codec_type | ||
1353 | ) | ||
1349 | { | 1354 | { |
1350 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1355 | const struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); |
1356 | const struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; | ||
1351 | unsigned long bufptr, result; | 1357 | unsigned long bufptr, result; |
1352 | snd_pcm_uframes_t frmres; | 1358 | snd_pcm_uframes_t frmres; |
1353 | 1359 | ||
1354 | #ifdef QUERY_HARDWARE | 1360 | #ifdef QUERY_HARDWARE |
1355 | bufptr = snd_azf3328_codec_inl(chip, IDX_IO_PLAY_DMA_START_1); | 1361 | bufptr = snd_azf3328_codec_inl(codec, IDX_IO_CODEC_DMA_START_1); |
1356 | #else | 1362 | #else |
1357 | bufptr = substream->runtime->dma_addr; | 1363 | bufptr = substream->runtime->dma_addr; |
1358 | #endif | 1364 | #endif |
1359 | result = snd_azf3328_codec_inl(chip, IDX_IO_PLAY_DMA_CURRPOS); | 1365 | result = snd_azf3328_codec_inl(codec, IDX_IO_CODEC_DMA_CURRPOS); |
1360 | 1366 | ||
1361 | /* calculate offset */ | 1367 | /* calculate offset */ |
1362 | result -= bufptr; | 1368 | result -= bufptr; |
1363 | frmres = bytes_to_frames( substream->runtime, result); | 1369 | frmres = bytes_to_frames( substream->runtime, result); |
1364 | snd_azf3328_dbgplay("PLAY @ 0x%8lx, frames %8ld\n", result, frmres); | 1370 | snd_azf3328_dbgcodec("%s @ 0x%8lx, frames %8ld\n", |
1371 | codec->name, result, frmres); | ||
1365 | return frmres; | 1372 | return frmres; |
1366 | } | 1373 | } |
1367 | 1374 | ||
1368 | static snd_pcm_uframes_t | 1375 | static snd_pcm_uframes_t |
1369 | snd_azf3328_capture_pointer(struct snd_pcm_substream *substream) | 1376 | snd_azf3328_codec_playback_pointer(struct snd_pcm_substream *substream) |
1370 | { | 1377 | { |
1371 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1378 | return snd_azf3328_codec_pointer(substream, AZF_CODEC_PLAYBACK); |
1372 | unsigned long bufptr, result; | 1379 | } |
1373 | snd_pcm_uframes_t frmres; | ||
1374 | 1380 | ||
1375 | #ifdef QUERY_HARDWARE | 1381 | static snd_pcm_uframes_t |
1376 | bufptr = snd_azf3328_codec_inl(chip, IDX_IO_REC_DMA_START_1); | 1382 | snd_azf3328_codec_capture_pointer(struct snd_pcm_substream *substream) |
1377 | #else | 1383 | { |
1378 | bufptr = substream->runtime->dma_addr; | 1384 | return snd_azf3328_codec_pointer(substream, AZF_CODEC_CAPTURE); |
1379 | #endif | 1385 | } |
1380 | result = snd_azf3328_codec_inl(chip, IDX_IO_REC_DMA_CURRPOS); | ||
1381 | 1386 | ||
1382 | /* calculate offset */ | 1387 | static snd_pcm_uframes_t |
1383 | result -= bufptr; | 1388 | snd_azf3328_codec_i2s_out_pointer(struct snd_pcm_substream *substream) |
1384 | frmres = bytes_to_frames( substream->runtime, result); | 1389 | { |
1385 | snd_azf3328_dbgplay("REC @ 0x%8lx, frames %8ld\n", result, frmres); | 1390 | return snd_azf3328_codec_pointer(substream, AZF_CODEC_I2S_OUT); |
1386 | return frmres; | ||
1387 | } | 1391 | } |
1388 | 1392 | ||
1389 | /******************************************************************/ | 1393 | /******************************************************************/ |
1390 | 1394 | ||
1391 | #ifdef SUPPORT_GAMEPORT | 1395 | #ifdef SUPPORT_GAMEPORT |
1392 | static inline void | 1396 | static inline void |
1393 | snd_azf3328_gameport_irq_enable(struct snd_azf3328 *chip, int enable) | 1397 | snd_azf3328_gameport_irq_enable(struct snd_azf3328 *chip, |
1398 | bool enable | ||
1399 | ) | ||
1394 | { | 1400 | { |
1395 | snd_azf3328_io_reg_setb( | 1401 | snd_azf3328_io_reg_setb( |
1396 | chip->game_io+IDX_GAME_HWCONFIG, | 1402 | chip->game_io+IDX_GAME_HWCONFIG, |
@@ -1400,7 +1406,9 @@ snd_azf3328_gameport_irq_enable(struct snd_azf3328 *chip, int enable) | |||
1400 | } | 1406 | } |
1401 | 1407 | ||
1402 | static inline void | 1408 | static inline void |
1403 | snd_azf3328_gameport_legacy_address_enable(struct snd_azf3328 *chip, int enable) | 1409 | snd_azf3328_gameport_legacy_address_enable(struct snd_azf3328 *chip, |
1410 | bool enable | ||
1411 | ) | ||
1404 | { | 1412 | { |
1405 | snd_azf3328_io_reg_setb( | 1413 | snd_azf3328_io_reg_setb( |
1406 | chip->game_io+IDX_GAME_HWCONFIG, | 1414 | chip->game_io+IDX_GAME_HWCONFIG, |
@@ -1409,10 +1417,27 @@ snd_azf3328_gameport_legacy_address_enable(struct snd_azf3328 *chip, int enable) | |||
1409 | ); | 1417 | ); |
1410 | } | 1418 | } |
1411 | 1419 | ||
1420 | static void | ||
1421 | snd_azf3328_gameport_set_counter_frequency(struct snd_azf3328 *chip, | ||
1422 | unsigned int freq_cfg | ||
1423 | ) | ||
1424 | { | ||
1425 | snd_azf3328_io_reg_setb( | ||
1426 | chip->game_io+IDX_GAME_HWCONFIG, | ||
1427 | 0x02, | ||
1428 | (freq_cfg & 1) != 0 | ||
1429 | ); | ||
1430 | snd_azf3328_io_reg_setb( | ||
1431 | chip->game_io+IDX_GAME_HWCONFIG, | ||
1432 | 0x04, | ||
1433 | (freq_cfg & 2) != 0 | ||
1434 | ); | ||
1435 | } | ||
1436 | |||
1412 | static inline void | 1437 | static inline void |
1413 | snd_azf3328_gameport_axis_circuit_enable(struct snd_azf3328 *chip, int enable) | 1438 | snd_azf3328_gameport_axis_circuit_enable(struct snd_azf3328 *chip, bool enable) |
1414 | { | 1439 | { |
1415 | snd_azf3328_codec_reg_6AH_update( | 1440 | snd_azf3328_ctrl_reg_6AH_update( |
1416 | chip, IO_6A_SOMETHING2_GAMEPORT, enable | 1441 | chip, IO_6A_SOMETHING2_GAMEPORT, enable |
1417 | ); | 1442 | ); |
1418 | } | 1443 | } |
@@ -1447,6 +1472,8 @@ snd_azf3328_gameport_open(struct gameport *gameport, int mode) | |||
1447 | break; | 1472 | break; |
1448 | } | 1473 | } |
1449 | 1474 | ||
1475 | snd_azf3328_gameport_set_counter_frequency(chip, | ||
1476 | GAME_HWCFG_ADC_COUNTER_FREQ_STD); | ||
1450 | snd_azf3328_gameport_axis_circuit_enable(chip, (res == 0)); | 1477 | snd_azf3328_gameport_axis_circuit_enable(chip, (res == 0)); |
1451 | 1478 | ||
1452 | return res; | 1479 | return res; |
@@ -1458,6 +1485,8 @@ snd_azf3328_gameport_close(struct gameport *gameport) | |||
1458 | struct snd_azf3328 *chip = gameport_get_port_data(gameport); | 1485 | struct snd_azf3328 *chip = gameport_get_port_data(gameport); |
1459 | 1486 | ||
1460 | snd_azf3328_dbggame("gameport_close\n"); | 1487 | snd_azf3328_dbggame("gameport_close\n"); |
1488 | snd_azf3328_gameport_set_counter_frequency(chip, | ||
1489 | GAME_HWCFG_ADC_COUNTER_FREQ_1_200); | ||
1461 | snd_azf3328_gameport_axis_circuit_enable(chip, 0); | 1490 | snd_azf3328_gameport_axis_circuit_enable(chip, 0); |
1462 | } | 1491 | } |
1463 | 1492 | ||
@@ -1491,7 +1520,7 @@ snd_azf3328_gameport_cooked_read(struct gameport *gameport, | |||
1491 | 1520 | ||
1492 | val = snd_azf3328_game_inb(chip, IDX_GAME_AXES_CONFIG); | 1521 | val = snd_azf3328_game_inb(chip, IDX_GAME_AXES_CONFIG); |
1493 | if (val & GAME_AXES_SAMPLING_READY) { | 1522 | if (val & GAME_AXES_SAMPLING_READY) { |
1494 | for (i = 0; i < 4; ++i) { | 1523 | for (i = 0; i < ARRAY_SIZE(chip->axes); ++i) { |
1495 | /* configure the axis to read */ | 1524 | /* configure the axis to read */ |
1496 | val = (i << 4) | 0x0f; | 1525 | val = (i << 4) | 0x0f; |
1497 | snd_azf3328_game_outb(chip, IDX_GAME_AXES_CONFIG, val); | 1526 | snd_azf3328_game_outb(chip, IDX_GAME_AXES_CONFIG, val); |
@@ -1514,7 +1543,7 @@ snd_azf3328_gameport_cooked_read(struct gameport *gameport, | |||
1514 | snd_azf3328_game_outw(chip, IDX_GAME_AXIS_VALUE, 0xffff); | 1543 | snd_azf3328_game_outw(chip, IDX_GAME_AXIS_VALUE, 0xffff); |
1515 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1544 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1516 | 1545 | ||
1517 | for (i = 0; i < 4; i++) { | 1546 | for (i = 0; i < ARRAY_SIZE(chip->axes); i++) { |
1518 | axes[i] = chip->axes[i]; | 1547 | axes[i] = chip->axes[i]; |
1519 | if (axes[i] == 0xffff) | 1548 | if (axes[i] == 0xffff) |
1520 | axes[i] = -1; | 1549 | axes[i] = -1; |
@@ -1552,6 +1581,8 @@ snd_azf3328_gameport(struct snd_azf3328 *chip, int dev) | |||
1552 | /* DISABLE legacy address: we don't need it! */ | 1581 | /* DISABLE legacy address: we don't need it! */ |
1553 | snd_azf3328_gameport_legacy_address_enable(chip, 0); | 1582 | snd_azf3328_gameport_legacy_address_enable(chip, 0); |
1554 | 1583 | ||
1584 | snd_azf3328_gameport_set_counter_frequency(chip, | ||
1585 | GAME_HWCFG_ADC_COUNTER_FREQ_1_200); | ||
1555 | snd_azf3328_gameport_axis_circuit_enable(chip, 0); | 1586 | snd_azf3328_gameport_axis_circuit_enable(chip, 0); |
1556 | 1587 | ||
1557 | gameport_register_port(chip->gameport); | 1588 | gameport_register_port(chip->gameport); |
@@ -1585,40 +1616,77 @@ snd_azf3328_gameport_interrupt(struct snd_azf3328 *chip) | |||
1585 | static inline void | 1616 | static inline void |
1586 | snd_azf3328_irq_log_unknown_type(u8 which) | 1617 | snd_azf3328_irq_log_unknown_type(u8 which) |
1587 | { | 1618 | { |
1588 | snd_azf3328_dbgplay( | 1619 | snd_azf3328_dbgcodec( |
1589 | "azt3328: unknown IRQ type (%x) occurred, please report!\n", | 1620 | "azt3328: unknown IRQ type (%x) occurred, please report!\n", |
1590 | which | 1621 | which |
1591 | ); | 1622 | ); |
1592 | } | 1623 | } |
1593 | 1624 | ||
1625 | static inline void | ||
1626 | snd_azf3328_codec_interrupt(struct snd_azf3328 *chip, u8 status) | ||
1627 | { | ||
1628 | u8 which; | ||
1629 | enum snd_azf3328_codec_type codec_type; | ||
1630 | const struct snd_azf3328_codec_data *codec; | ||
1631 | |||
1632 | for (codec_type = AZF_CODEC_PLAYBACK; | ||
1633 | codec_type <= AZF_CODEC_I2S_OUT; | ||
1634 | ++codec_type) { | ||
1635 | |||
1636 | /* skip codec if there's no interrupt for it */ | ||
1637 | if (!(status & (1 << codec_type))) | ||
1638 | continue; | ||
1639 | |||
1640 | codec = &chip->codecs[codec_type]; | ||
1641 | |||
1642 | spin_lock(&chip->reg_lock); | ||
1643 | which = snd_azf3328_codec_inb(codec, IDX_IO_CODEC_IRQTYPE); | ||
1644 | /* ack all IRQ types immediately */ | ||
1645 | snd_azf3328_codec_outb(codec, IDX_IO_CODEC_IRQTYPE, which); | ||
1646 | spin_unlock(&chip->reg_lock); | ||
1647 | |||
1648 | if ((chip->pcm[codec_type]) && (codec->substream)) { | ||
1649 | snd_pcm_period_elapsed(codec->substream); | ||
1650 | snd_azf3328_dbgcodec("%s period done (#%x), @ %x\n", | ||
1651 | codec->name, | ||
1652 | which, | ||
1653 | snd_azf3328_codec_inl( | ||
1654 | codec, IDX_IO_CODEC_DMA_CURRPOS | ||
1655 | ) | ||
1656 | ); | ||
1657 | } else | ||
1658 | printk(KERN_WARNING "azt3328: irq handler problem!\n"); | ||
1659 | if (which & IRQ_SOMETHING) | ||
1660 | snd_azf3328_irq_log_unknown_type(which); | ||
1661 | } | ||
1662 | } | ||
1663 | |||
1594 | static irqreturn_t | 1664 | static irqreturn_t |
1595 | snd_azf3328_interrupt(int irq, void *dev_id) | 1665 | snd_azf3328_interrupt(int irq, void *dev_id) |
1596 | { | 1666 | { |
1597 | struct snd_azf3328 *chip = dev_id; | 1667 | struct snd_azf3328 *chip = dev_id; |
1598 | u8 status, which; | 1668 | u8 status; |
1599 | #if DEBUG_PLAY_REC | 1669 | #if DEBUG_CODEC |
1600 | static unsigned long irq_count; | 1670 | static unsigned long irq_count; |
1601 | #endif | 1671 | #endif |
1602 | 1672 | ||
1603 | status = snd_azf3328_codec_inb(chip, IDX_IO_IRQSTATUS); | 1673 | status = snd_azf3328_ctrl_inb(chip, IDX_IO_IRQSTATUS); |
1604 | 1674 | ||
1605 | /* fast path out, to ease interrupt sharing */ | 1675 | /* fast path out, to ease interrupt sharing */ |
1606 | if (!(status & | 1676 | if (!(status & |
1607 | (IRQ_PLAYBACK|IRQ_RECORDING|IRQ_GAMEPORT|IRQ_MPU401|IRQ_TIMER) | 1677 | (IRQ_PLAYBACK|IRQ_RECORDING|IRQ_I2S_OUT |
1678 | |IRQ_GAMEPORT|IRQ_MPU401|IRQ_TIMER) | ||
1608 | )) | 1679 | )) |
1609 | return IRQ_NONE; /* must be interrupt for another device */ | 1680 | return IRQ_NONE; /* must be interrupt for another device */ |
1610 | 1681 | ||
1611 | snd_azf3328_dbgplay( | 1682 | snd_azf3328_dbgcodec( |
1612 | "irq_count %ld! IDX_IO_PLAY_FLAGS %04x, " | 1683 | "irq_count %ld! IDX_IO_IRQSTATUS %04x\n", |
1613 | "IDX_IO_PLAY_IRQTYPE %04x, IDX_IO_IRQSTATUS %04x\n", | ||
1614 | irq_count++ /* debug-only */, | 1684 | irq_count++ /* debug-only */, |
1615 | snd_azf3328_codec_inw(chip, IDX_IO_PLAY_FLAGS), | ||
1616 | snd_azf3328_codec_inw(chip, IDX_IO_PLAY_IRQTYPE), | ||
1617 | status | 1685 | status |
1618 | ); | 1686 | ); |
1619 | 1687 | ||
1620 | if (status & IRQ_TIMER) { | 1688 | if (status & IRQ_TIMER) { |
1621 | /* snd_azf3328_dbgplay("timer %ld\n", | 1689 | /* snd_azf3328_dbgcodec("timer %ld\n", |
1622 | snd_azf3328_codec_inl(chip, IDX_IO_TIMER_VALUE) | 1690 | snd_azf3328_codec_inl(chip, IDX_IO_TIMER_VALUE) |
1623 | & TIMER_VALUE_MASK | 1691 | & TIMER_VALUE_MASK |
1624 | ); */ | 1692 | ); */ |
@@ -1626,71 +1694,36 @@ snd_azf3328_interrupt(int irq, void *dev_id) | |||
1626 | snd_timer_interrupt(chip->timer, chip->timer->sticks); | 1694 | snd_timer_interrupt(chip->timer, chip->timer->sticks); |
1627 | /* ACK timer */ | 1695 | /* ACK timer */ |
1628 | spin_lock(&chip->reg_lock); | 1696 | spin_lock(&chip->reg_lock); |
1629 | snd_azf3328_codec_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x07); | 1697 | snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x07); |
1630 | spin_unlock(&chip->reg_lock); | 1698 | spin_unlock(&chip->reg_lock); |
1631 | snd_azf3328_dbgplay("azt3328: timer IRQ\n"); | 1699 | snd_azf3328_dbgcodec("azt3328: timer IRQ\n"); |
1632 | } | 1700 | } |
1633 | if (status & IRQ_PLAYBACK) { | ||
1634 | spin_lock(&chip->reg_lock); | ||
1635 | which = snd_azf3328_codec_inb(chip, IDX_IO_PLAY_IRQTYPE); | ||
1636 | /* ack all IRQ types immediately */ | ||
1637 | snd_azf3328_codec_outb(chip, IDX_IO_PLAY_IRQTYPE, which); | ||
1638 | spin_unlock(&chip->reg_lock); | ||
1639 | 1701 | ||
1640 | if (chip->pcm && chip->audio_stream[AZF_PLAYBACK].substream) { | 1702 | if (status & (IRQ_PLAYBACK|IRQ_RECORDING|IRQ_I2S_OUT)) |
1641 | snd_pcm_period_elapsed( | 1703 | snd_azf3328_codec_interrupt(chip, status); |
1642 | chip->audio_stream[AZF_PLAYBACK].substream | ||
1643 | ); | ||
1644 | snd_azf3328_dbgplay("PLAY period done (#%x), @ %x\n", | ||
1645 | which, | ||
1646 | snd_azf3328_codec_inl( | ||
1647 | chip, IDX_IO_PLAY_DMA_CURRPOS | ||
1648 | ) | ||
1649 | ); | ||
1650 | } else | ||
1651 | printk(KERN_WARNING "azt3328: irq handler problem!\n"); | ||
1652 | if (which & IRQ_PLAY_SOMETHING) | ||
1653 | snd_azf3328_irq_log_unknown_type(which); | ||
1654 | } | ||
1655 | if (status & IRQ_RECORDING) { | ||
1656 | spin_lock(&chip->reg_lock); | ||
1657 | which = snd_azf3328_codec_inb(chip, IDX_IO_REC_IRQTYPE); | ||
1658 | /* ack all IRQ types immediately */ | ||
1659 | snd_azf3328_codec_outb(chip, IDX_IO_REC_IRQTYPE, which); | ||
1660 | spin_unlock(&chip->reg_lock); | ||
1661 | 1704 | ||
1662 | if (chip->pcm && chip->audio_stream[AZF_CAPTURE].substream) { | ||
1663 | snd_pcm_period_elapsed( | ||
1664 | chip->audio_stream[AZF_CAPTURE].substream | ||
1665 | ); | ||
1666 | snd_azf3328_dbgplay("REC period done (#%x), @ %x\n", | ||
1667 | which, | ||
1668 | snd_azf3328_codec_inl( | ||
1669 | chip, IDX_IO_REC_DMA_CURRPOS | ||
1670 | ) | ||
1671 | ); | ||
1672 | } else | ||
1673 | printk(KERN_WARNING "azt3328: irq handler problem!\n"); | ||
1674 | if (which & IRQ_REC_SOMETHING) | ||
1675 | snd_azf3328_irq_log_unknown_type(which); | ||
1676 | } | ||
1677 | if (status & IRQ_GAMEPORT) | 1705 | if (status & IRQ_GAMEPORT) |
1678 | snd_azf3328_gameport_interrupt(chip); | 1706 | snd_azf3328_gameport_interrupt(chip); |
1707 | |||
1679 | /* MPU401 has less critical IRQ requirements | 1708 | /* MPU401 has less critical IRQ requirements |
1680 | * than timer and playback/recording, right? */ | 1709 | * than timer and playback/recording, right? */ |
1681 | if (status & IRQ_MPU401) { | 1710 | if (status & IRQ_MPU401) { |
1682 | snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); | 1711 | snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); |
1683 | 1712 | ||
1684 | /* hmm, do we have to ack the IRQ here somehow? | 1713 | /* hmm, do we have to ack the IRQ here somehow? |
1685 | * If so, then I don't know how... */ | 1714 | * If so, then I don't know how yet... */ |
1686 | snd_azf3328_dbgplay("azt3328: MPU401 IRQ\n"); | 1715 | snd_azf3328_dbgcodec("azt3328: MPU401 IRQ\n"); |
1687 | } | 1716 | } |
1688 | return IRQ_HANDLED; | 1717 | return IRQ_HANDLED; |
1689 | } | 1718 | } |
1690 | 1719 | ||
1691 | /*****************************************************************/ | 1720 | /*****************************************************************/ |
1692 | 1721 | ||
1693 | static const struct snd_pcm_hardware snd_azf3328_playback = | 1722 | /* as long as we think we have identical snd_pcm_hardware parameters |
1723 | for playback, capture and i2s out, we can use the same physical struct | ||
1724 | since the struct is simply being copied into a member. | ||
1725 | */ | ||
1726 | static const struct snd_pcm_hardware snd_azf3328_hardware = | ||
1694 | { | 1727 | { |
1695 | /* FIXME!! Correct? */ | 1728 | /* FIXME!! Correct? */ |
1696 | .info = SNDRV_PCM_INFO_MMAP | | 1729 | .info = SNDRV_PCM_INFO_MMAP | |
@@ -1718,31 +1751,6 @@ static const struct snd_pcm_hardware snd_azf3328_playback = | |||
1718 | .fifo_size = 0, | 1751 | .fifo_size = 0, |
1719 | }; | 1752 | }; |
1720 | 1753 | ||
1721 | static const struct snd_pcm_hardware snd_azf3328_capture = | ||
1722 | { | ||
1723 | /* FIXME */ | ||
1724 | .info = SNDRV_PCM_INFO_MMAP | | ||
1725 | SNDRV_PCM_INFO_INTERLEAVED | | ||
1726 | SNDRV_PCM_INFO_MMAP_VALID, | ||
1727 | .formats = SNDRV_PCM_FMTBIT_S8 | | ||
1728 | SNDRV_PCM_FMTBIT_U8 | | ||
1729 | SNDRV_PCM_FMTBIT_S16_LE | | ||
1730 | SNDRV_PCM_FMTBIT_U16_LE, | ||
1731 | .rates = SNDRV_PCM_RATE_5512 | | ||
1732 | SNDRV_PCM_RATE_8000_48000 | | ||
1733 | SNDRV_PCM_RATE_KNOT, | ||
1734 | .rate_min = AZF_FREQ_4000, | ||
1735 | .rate_max = AZF_FREQ_66200, | ||
1736 | .channels_min = 1, | ||
1737 | .channels_max = 2, | ||
1738 | .buffer_bytes_max = 65536, | ||
1739 | .period_bytes_min = 64, | ||
1740 | .period_bytes_max = 65536, | ||
1741 | .periods_min = 1, | ||
1742 | .periods_max = 1024, | ||
1743 | .fifo_size = 0, | ||
1744 | }; | ||
1745 | |||
1746 | 1754 | ||
1747 | static unsigned int snd_azf3328_fixed_rates[] = { | 1755 | static unsigned int snd_azf3328_fixed_rates[] = { |
1748 | AZF_FREQ_4000, | 1756 | AZF_FREQ_4000, |
@@ -1770,14 +1778,19 @@ static struct snd_pcm_hw_constraint_list snd_azf3328_hw_constraints_rates = { | |||
1770 | /*****************************************************************/ | 1778 | /*****************************************************************/ |
1771 | 1779 | ||
1772 | static int | 1780 | static int |
1773 | snd_azf3328_playback_open(struct snd_pcm_substream *substream) | 1781 | snd_azf3328_pcm_open(struct snd_pcm_substream *substream, |
1782 | enum snd_azf3328_codec_type codec_type | ||
1783 | ) | ||
1774 | { | 1784 | { |
1775 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1785 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); |
1776 | struct snd_pcm_runtime *runtime = substream->runtime; | 1786 | struct snd_pcm_runtime *runtime = substream->runtime; |
1777 | 1787 | ||
1778 | snd_azf3328_dbgcallenter(); | 1788 | snd_azf3328_dbgcallenter(); |
1779 | chip->audio_stream[AZF_PLAYBACK].substream = substream; | 1789 | chip->codecs[codec_type].substream = substream; |
1780 | runtime->hw = snd_azf3328_playback; | 1790 | |
1791 | /* same parameters for all our codecs - at least we think so... */ | ||
1792 | runtime->hw = snd_azf3328_hardware; | ||
1793 | |||
1781 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 1794 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
1782 | &snd_azf3328_hw_constraints_rates); | 1795 | &snd_azf3328_hw_constraints_rates); |
1783 | snd_azf3328_dbgcallleave(); | 1796 | snd_azf3328_dbgcallleave(); |
@@ -1785,40 +1798,52 @@ snd_azf3328_playback_open(struct snd_pcm_substream *substream) | |||
1785 | } | 1798 | } |
1786 | 1799 | ||
1787 | static int | 1800 | static int |
1801 | snd_azf3328_playback_open(struct snd_pcm_substream *substream) | ||
1802 | { | ||
1803 | return snd_azf3328_pcm_open(substream, AZF_CODEC_PLAYBACK); | ||
1804 | } | ||
1805 | |||
1806 | static int | ||
1788 | snd_azf3328_capture_open(struct snd_pcm_substream *substream) | 1807 | snd_azf3328_capture_open(struct snd_pcm_substream *substream) |
1789 | { | 1808 | { |
1790 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1809 | return snd_azf3328_pcm_open(substream, AZF_CODEC_CAPTURE); |
1791 | struct snd_pcm_runtime *runtime = substream->runtime; | 1810 | } |
1792 | 1811 | ||
1793 | snd_azf3328_dbgcallenter(); | 1812 | static int |
1794 | chip->audio_stream[AZF_CAPTURE].substream = substream; | 1813 | snd_azf3328_i2s_out_open(struct snd_pcm_substream *substream) |
1795 | runtime->hw = snd_azf3328_capture; | 1814 | { |
1796 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 1815 | return snd_azf3328_pcm_open(substream, AZF_CODEC_I2S_OUT); |
1797 | &snd_azf3328_hw_constraints_rates); | ||
1798 | snd_azf3328_dbgcallleave(); | ||
1799 | return 0; | ||
1800 | } | 1816 | } |
1801 | 1817 | ||
1802 | static int | 1818 | static int |
1803 | snd_azf3328_playback_close(struct snd_pcm_substream *substream) | 1819 | snd_azf3328_pcm_close(struct snd_pcm_substream *substream, |
1820 | enum snd_azf3328_codec_type codec_type | ||
1821 | ) | ||
1804 | { | 1822 | { |
1805 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1823 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); |
1806 | 1824 | ||
1807 | snd_azf3328_dbgcallenter(); | 1825 | snd_azf3328_dbgcallenter(); |
1808 | chip->audio_stream[AZF_PLAYBACK].substream = NULL; | 1826 | chip->codecs[codec_type].substream = NULL; |
1809 | snd_azf3328_dbgcallleave(); | 1827 | snd_azf3328_dbgcallleave(); |
1810 | return 0; | 1828 | return 0; |
1811 | } | 1829 | } |
1812 | 1830 | ||
1813 | static int | 1831 | static int |
1832 | snd_azf3328_playback_close(struct snd_pcm_substream *substream) | ||
1833 | { | ||
1834 | return snd_azf3328_pcm_close(substream, AZF_CODEC_PLAYBACK); | ||
1835 | } | ||
1836 | |||
1837 | static int | ||
1814 | snd_azf3328_capture_close(struct snd_pcm_substream *substream) | 1838 | snd_azf3328_capture_close(struct snd_pcm_substream *substream) |
1815 | { | 1839 | { |
1816 | struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); | 1840 | return snd_azf3328_pcm_close(substream, AZF_CODEC_CAPTURE); |
1841 | } | ||
1817 | 1842 | ||
1818 | snd_azf3328_dbgcallenter(); | 1843 | static int |
1819 | chip->audio_stream[AZF_CAPTURE].substream = NULL; | 1844 | snd_azf3328_i2s_out_close(struct snd_pcm_substream *substream) |
1820 | snd_azf3328_dbgcallleave(); | 1845 | { |
1821 | return 0; | 1846 | return snd_azf3328_pcm_close(substream, AZF_CODEC_I2S_OUT); |
1822 | } | 1847 | } |
1823 | 1848 | ||
1824 | /******************************************************************/ | 1849 | /******************************************************************/ |
@@ -1829,9 +1854,9 @@ static struct snd_pcm_ops snd_azf3328_playback_ops = { | |||
1829 | .ioctl = snd_pcm_lib_ioctl, | 1854 | .ioctl = snd_pcm_lib_ioctl, |
1830 | .hw_params = snd_azf3328_hw_params, | 1855 | .hw_params = snd_azf3328_hw_params, |
1831 | .hw_free = snd_azf3328_hw_free, | 1856 | .hw_free = snd_azf3328_hw_free, |
1832 | .prepare = snd_azf3328_playback_prepare, | 1857 | .prepare = snd_azf3328_codec_prepare, |
1833 | .trigger = snd_azf3328_playback_trigger, | 1858 | .trigger = snd_azf3328_codec_playback_trigger, |
1834 | .pointer = snd_azf3328_playback_pointer | 1859 | .pointer = snd_azf3328_codec_playback_pointer |
1835 | }; | 1860 | }; |
1836 | 1861 | ||
1837 | static struct snd_pcm_ops snd_azf3328_capture_ops = { | 1862 | static struct snd_pcm_ops snd_azf3328_capture_ops = { |
@@ -1840,30 +1865,67 @@ static struct snd_pcm_ops snd_azf3328_capture_ops = { | |||
1840 | .ioctl = snd_pcm_lib_ioctl, | 1865 | .ioctl = snd_pcm_lib_ioctl, |
1841 | .hw_params = snd_azf3328_hw_params, | 1866 | .hw_params = snd_azf3328_hw_params, |
1842 | .hw_free = snd_azf3328_hw_free, | 1867 | .hw_free = snd_azf3328_hw_free, |
1843 | .prepare = snd_azf3328_capture_prepare, | 1868 | .prepare = snd_azf3328_codec_prepare, |
1844 | .trigger = snd_azf3328_capture_trigger, | 1869 | .trigger = snd_azf3328_codec_capture_trigger, |
1845 | .pointer = snd_azf3328_capture_pointer | 1870 | .pointer = snd_azf3328_codec_capture_pointer |
1871 | }; | ||
1872 | |||
1873 | static struct snd_pcm_ops snd_azf3328_i2s_out_ops = { | ||
1874 | .open = snd_azf3328_i2s_out_open, | ||
1875 | .close = snd_azf3328_i2s_out_close, | ||
1876 | .ioctl = snd_pcm_lib_ioctl, | ||
1877 | .hw_params = snd_azf3328_hw_params, | ||
1878 | .hw_free = snd_azf3328_hw_free, | ||
1879 | .prepare = snd_azf3328_codec_prepare, | ||
1880 | .trigger = snd_azf3328_codec_i2s_out_trigger, | ||
1881 | .pointer = snd_azf3328_codec_i2s_out_pointer | ||
1846 | }; | 1882 | }; |
1847 | 1883 | ||
1848 | static int __devinit | 1884 | static int __devinit |
1849 | snd_azf3328_pcm(struct snd_azf3328 *chip, int device) | 1885 | snd_azf3328_pcm(struct snd_azf3328 *chip) |
1850 | { | 1886 | { |
1887 | enum { AZF_PCMDEV_STD, AZF_PCMDEV_I2S_OUT, NUM_AZF_PCMDEVS }; /* pcm devices */ | ||
1888 | |||
1851 | struct snd_pcm *pcm; | 1889 | struct snd_pcm *pcm; |
1852 | int err; | 1890 | int err; |
1853 | 1891 | ||
1854 | snd_azf3328_dbgcallenter(); | 1892 | snd_azf3328_dbgcallenter(); |
1855 | if ((err = snd_pcm_new(chip->card, "AZF3328 DSP", device, 1, 1, &pcm)) < 0) | 1893 | |
1894 | err = snd_pcm_new(chip->card, "AZF3328 DSP", AZF_PCMDEV_STD, | ||
1895 | 1, 1, &pcm); | ||
1896 | if (err < 0) | ||
1856 | return err; | 1897 | return err; |
1857 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_azf3328_playback_ops); | 1898 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
1858 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_azf3328_capture_ops); | 1899 | &snd_azf3328_playback_ops); |
1900 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | ||
1901 | &snd_azf3328_capture_ops); | ||
1859 | 1902 | ||
1860 | pcm->private_data = chip; | 1903 | pcm->private_data = chip; |
1861 | pcm->info_flags = 0; | 1904 | pcm->info_flags = 0; |
1862 | strcpy(pcm->name, chip->card->shortname); | 1905 | strcpy(pcm->name, chip->card->shortname); |
1863 | chip->pcm = pcm; | 1906 | /* same pcm object for playback/capture (see snd_pcm_new() above) */ |
1907 | chip->pcm[AZF_CODEC_PLAYBACK] = pcm; | ||
1908 | chip->pcm[AZF_CODEC_CAPTURE] = pcm; | ||
1864 | 1909 | ||
1865 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 1910 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
1866 | snd_dma_pci_data(chip->pci), 64*1024, 64*1024); | 1911 | snd_dma_pci_data(chip->pci), |
1912 | 64*1024, 64*1024); | ||
1913 | |||
1914 | err = snd_pcm_new(chip->card, "AZF3328 I2S OUT", AZF_PCMDEV_I2S_OUT, | ||
1915 | 1, 0, &pcm); | ||
1916 | if (err < 0) | ||
1917 | return err; | ||
1918 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, | ||
1919 | &snd_azf3328_i2s_out_ops); | ||
1920 | |||
1921 | pcm->private_data = chip; | ||
1922 | pcm->info_flags = 0; | ||
1923 | strcpy(pcm->name, chip->card->shortname); | ||
1924 | chip->pcm[AZF_CODEC_I2S_OUT] = pcm; | ||
1925 | |||
1926 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | ||
1927 | snd_dma_pci_data(chip->pci), | ||
1928 | 64*1024, 64*1024); | ||
1867 | 1929 | ||
1868 | snd_azf3328_dbgcallleave(); | 1930 | snd_azf3328_dbgcallleave(); |
1869 | return 0; | 1931 | return 0; |
@@ -1902,7 +1964,7 @@ snd_azf3328_timer_start(struct snd_timer *timer) | |||
1902 | snd_azf3328_dbgtimer("setting timer countdown value %d, add COUNTDOWN|IRQ\n", delay); | 1964 | snd_azf3328_dbgtimer("setting timer countdown value %d, add COUNTDOWN|IRQ\n", delay); |
1903 | delay |= TIMER_COUNTDOWN_ENABLE | TIMER_IRQ_ENABLE; | 1965 | delay |= TIMER_COUNTDOWN_ENABLE | TIMER_IRQ_ENABLE; |
1904 | spin_lock_irqsave(&chip->reg_lock, flags); | 1966 | spin_lock_irqsave(&chip->reg_lock, flags); |
1905 | snd_azf3328_codec_outl(chip, IDX_IO_TIMER_VALUE, delay); | 1967 | snd_azf3328_ctrl_outl(chip, IDX_IO_TIMER_VALUE, delay); |
1906 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1968 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1907 | snd_azf3328_dbgcallleave(); | 1969 | snd_azf3328_dbgcallleave(); |
1908 | return 0; | 1970 | return 0; |
@@ -1919,7 +1981,7 @@ snd_azf3328_timer_stop(struct snd_timer *timer) | |||
1919 | spin_lock_irqsave(&chip->reg_lock, flags); | 1981 | spin_lock_irqsave(&chip->reg_lock, flags); |
1920 | /* disable timer countdown and interrupt */ | 1982 | /* disable timer countdown and interrupt */ |
1921 | /* FIXME: should we write TIMER_IRQ_ACK here? */ | 1983 | /* FIXME: should we write TIMER_IRQ_ACK here? */ |
1922 | snd_azf3328_codec_outb(chip, IDX_IO_TIMER_VALUE + 3, 0); | 1984 | snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0); |
1923 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1985 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1924 | snd_azf3328_dbgcallleave(); | 1986 | snd_azf3328_dbgcallleave(); |
1925 | return 0; | 1987 | return 0; |
@@ -2035,7 +2097,7 @@ snd_azf3328_test_bit(unsigned unsigned reg, int bit) | |||
2035 | 2097 | ||
2036 | outb(val, reg); | 2098 | outb(val, reg); |
2037 | 2099 | ||
2038 | printk(KERN_ERR "reg %04x bit %d: %02x %02x %02x\n", | 2100 | printk(KERN_DEBUG "reg %04x bit %d: %02x %02x %02x\n", |
2039 | reg, bit, val, valoff, valon | 2101 | reg, bit, val, valoff, valon |
2040 | ); | 2102 | ); |
2041 | } | 2103 | } |
@@ -2048,9 +2110,9 @@ snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) | |||
2048 | u16 tmp; | 2110 | u16 tmp; |
2049 | 2111 | ||
2050 | snd_azf3328_dbgmisc( | 2112 | snd_azf3328_dbgmisc( |
2051 | "codec_io 0x%lx, game_io 0x%lx, mpu_io 0x%lx, " | 2113 | "ctrl_io 0x%lx, game_io 0x%lx, mpu_io 0x%lx, " |
2052 | "opl3_io 0x%lx, mixer_io 0x%lx, irq %d\n", | 2114 | "opl3_io 0x%lx, mixer_io 0x%lx, irq %d\n", |
2053 | chip->codec_io, chip->game_io, chip->mpu_io, | 2115 | chip->ctrl_io, chip->game_io, chip->mpu_io, |
2054 | chip->opl3_io, chip->mixer_io, chip->irq | 2116 | chip->opl3_io, chip->mixer_io, chip->irq |
2055 | ); | 2117 | ); |
2056 | 2118 | ||
@@ -2083,9 +2145,9 @@ snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) | |||
2083 | inb(0x38c + tmp) | 2145 | inb(0x38c + tmp) |
2084 | ); | 2146 | ); |
2085 | 2147 | ||
2086 | for (tmp = 0; tmp < AZF_IO_SIZE_CODEC; tmp += 2) | 2148 | for (tmp = 0; tmp < AZF_IO_SIZE_CTRL; tmp += 2) |
2087 | snd_azf3328_dbgmisc("codec 0x%02x: 0x%04x\n", | 2149 | snd_azf3328_dbgmisc("ctrl 0x%02x: 0x%04x\n", |
2088 | tmp, snd_azf3328_codec_inw(chip, tmp) | 2150 | tmp, snd_azf3328_ctrl_inw(chip, tmp) |
2089 | ); | 2151 | ); |
2090 | 2152 | ||
2091 | for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2) | 2153 | for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2) |
@@ -2106,7 +2168,8 @@ snd_azf3328_create(struct snd_card *card, | |||
2106 | static struct snd_device_ops ops = { | 2168 | static struct snd_device_ops ops = { |
2107 | .dev_free = snd_azf3328_dev_free, | 2169 | .dev_free = snd_azf3328_dev_free, |
2108 | }; | 2170 | }; |
2109 | u16 tmp; | 2171 | u8 dma_init; |
2172 | enum snd_azf3328_codec_type codec_type; | ||
2110 | 2173 | ||
2111 | *rchip = NULL; | 2174 | *rchip = NULL; |
2112 | 2175 | ||
@@ -2138,14 +2201,21 @@ snd_azf3328_create(struct snd_card *card, | |||
2138 | if (err < 0) | 2201 | if (err < 0) |
2139 | goto out_err; | 2202 | goto out_err; |
2140 | 2203 | ||
2141 | chip->codec_io = pci_resource_start(pci, 0); | 2204 | chip->ctrl_io = pci_resource_start(pci, 0); |
2142 | chip->game_io = pci_resource_start(pci, 1); | 2205 | chip->game_io = pci_resource_start(pci, 1); |
2143 | chip->mpu_io = pci_resource_start(pci, 2); | 2206 | chip->mpu_io = pci_resource_start(pci, 2); |
2144 | chip->opl3_io = pci_resource_start(pci, 3); | 2207 | chip->opl3_io = pci_resource_start(pci, 3); |
2145 | chip->mixer_io = pci_resource_start(pci, 4); | 2208 | chip->mixer_io = pci_resource_start(pci, 4); |
2146 | 2209 | ||
2147 | chip->audio_stream[AZF_PLAYBACK].portbase = chip->codec_io + 0x00; | 2210 | chip->codecs[AZF_CODEC_PLAYBACK].io_base = |
2148 | chip->audio_stream[AZF_CAPTURE].portbase = chip->codec_io + 0x20; | 2211 | chip->ctrl_io + AZF_IO_OFFS_CODEC_PLAYBACK; |
2212 | chip->codecs[AZF_CODEC_PLAYBACK].name = "PLAYBACK"; | ||
2213 | chip->codecs[AZF_CODEC_CAPTURE].io_base = | ||
2214 | chip->ctrl_io + AZF_IO_OFFS_CODEC_CAPTURE; | ||
2215 | chip->codecs[AZF_CODEC_CAPTURE].name = "CAPTURE"; | ||
2216 | chip->codecs[AZF_CODEC_I2S_OUT].io_base = | ||
2217 | chip->ctrl_io + AZF_IO_OFFS_CODEC_I2S_OUT; | ||
2218 | chip->codecs[AZF_CODEC_I2S_OUT].name = "I2S_OUT"; | ||
2149 | 2219 | ||
2150 | if (request_irq(pci->irq, snd_azf3328_interrupt, | 2220 | if (request_irq(pci->irq, snd_azf3328_interrupt, |
2151 | IRQF_SHARED, card->shortname, chip)) { | 2221 | IRQF_SHARED, card->shortname, chip)) { |
@@ -2168,20 +2238,25 @@ snd_azf3328_create(struct snd_card *card, | |||
2168 | if (err < 0) | 2238 | if (err < 0) |
2169 | goto out_err; | 2239 | goto out_err; |
2170 | 2240 | ||
2171 | /* shutdown codecs to save power */ | 2241 | /* standard codec init stuff */ |
2172 | /* have snd_azf3328_codec_activity() act properly */ | 2242 | /* default DMA init value */ |
2173 | chip->audio_stream[AZF_PLAYBACK].running = 1; | 2243 | dma_init = DMA_RUN_SOMETHING2|DMA_EPILOGUE_SOMETHING|DMA_SOMETHING_ELSE; |
2174 | snd_azf3328_codec_activity(chip, AZF_PLAYBACK, 0); | ||
2175 | 2244 | ||
2176 | /* standard chip init stuff */ | 2245 | for (codec_type = AZF_CODEC_PLAYBACK; |
2177 | /* default IRQ init value */ | 2246 | codec_type <= AZF_CODEC_I2S_OUT; ++codec_type) { |
2178 | tmp = DMA_PLAY_SOMETHING2|DMA_EPILOGUE_SOMETHING|DMA_SOMETHING_ELSE; | 2247 | struct snd_azf3328_codec_data *codec = |
2248 | &chip->codecs[codec_type]; | ||
2179 | 2249 | ||
2180 | spin_lock_irq(&chip->reg_lock); | 2250 | /* shutdown codecs to save power */ |
2181 | snd_azf3328_codec_outb(chip, IDX_IO_PLAY_FLAGS, tmp); | 2251 | /* have ...ctrl_codec_activity() act properly */ |
2182 | snd_azf3328_codec_outb(chip, IDX_IO_REC_FLAGS, tmp); | 2252 | codec->running = 1; |
2183 | snd_azf3328_codec_outb(chip, IDX_IO_SOMETHING_FLAGS, tmp); | 2253 | snd_azf3328_ctrl_codec_activity(chip, codec_type, 0); |
2184 | spin_unlock_irq(&chip->reg_lock); | 2254 | |
2255 | spin_lock_irq(&chip->reg_lock); | ||
2256 | snd_azf3328_codec_outb(codec, IDX_IO_CODEC_DMA_FLAGS, | ||
2257 | dma_init); | ||
2258 | spin_unlock_irq(&chip->reg_lock); | ||
2259 | } | ||
2185 | 2260 | ||
2186 | snd_card_set_dev(card, &pci->dev); | 2261 | snd_card_set_dev(card, &pci->dev); |
2187 | 2262 | ||
@@ -2229,8 +2304,11 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
2229 | 2304 | ||
2230 | card->private_data = chip; | 2305 | card->private_data = chip; |
2231 | 2306 | ||
2307 | /* chose to use MPU401_HW_AZT2320 ID instead of MPU401_HW_MPU401, | ||
2308 | since our hardware ought to be similar, thus use same ID. */ | ||
2232 | err = snd_mpu401_uart_new( | 2309 | err = snd_mpu401_uart_new( |
2233 | card, 0, MPU401_HW_MPU401, chip->mpu_io, MPU401_INFO_INTEGRATED, | 2310 | card, 0, |
2311 | MPU401_HW_AZT2320, chip->mpu_io, MPU401_INFO_INTEGRATED, | ||
2234 | pci->irq, 0, &chip->rmidi | 2312 | pci->irq, 0, &chip->rmidi |
2235 | ); | 2313 | ); |
2236 | if (err < 0) { | 2314 | if (err < 0) { |
@@ -2244,7 +2322,7 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
2244 | if (err < 0) | 2322 | if (err < 0) |
2245 | goto out_err; | 2323 | goto out_err; |
2246 | 2324 | ||
2247 | err = snd_azf3328_pcm(chip, 0); | 2325 | err = snd_azf3328_pcm(chip); |
2248 | if (err < 0) | 2326 | if (err < 0) |
2249 | goto out_err; | 2327 | goto out_err; |
2250 | 2328 | ||
@@ -2266,14 +2344,14 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
2266 | opl3->private_data = chip; | 2344 | opl3->private_data = chip; |
2267 | 2345 | ||
2268 | sprintf(card->longname, "%s at 0x%lx, irq %i", | 2346 | sprintf(card->longname, "%s at 0x%lx, irq %i", |
2269 | card->shortname, chip->codec_io, chip->irq); | 2347 | card->shortname, chip->ctrl_io, chip->irq); |
2270 | 2348 | ||
2271 | err = snd_card_register(card); | 2349 | err = snd_card_register(card); |
2272 | if (err < 0) | 2350 | if (err < 0) |
2273 | goto out_err; | 2351 | goto out_err; |
2274 | 2352 | ||
2275 | #ifdef MODULE | 2353 | #ifdef MODULE |
2276 | printk( | 2354 | printk(KERN_INFO |
2277 | "azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n" | 2355 | "azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n" |
2278 | "azt3328: Hardware was completely undocumented, unfortunately.\n" | 2356 | "azt3328: Hardware was completely undocumented, unfortunately.\n" |
2279 | "azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n" | 2357 | "azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n" |
@@ -2308,36 +2386,52 @@ snd_azf3328_remove(struct pci_dev *pci) | |||
2308 | } | 2386 | } |
2309 | 2387 | ||
2310 | #ifdef CONFIG_PM | 2388 | #ifdef CONFIG_PM |
2389 | static inline void | ||
2390 | snd_azf3328_suspend_regs(unsigned long io_addr, unsigned count, u32 *saved_regs) | ||
2391 | { | ||
2392 | unsigned reg; | ||
2393 | |||
2394 | for (reg = 0; reg < count; ++reg) { | ||
2395 | *saved_regs = inl(io_addr); | ||
2396 | snd_azf3328_dbgpm("suspend: io 0x%04lx: 0x%08x\n", | ||
2397 | io_addr, *saved_regs); | ||
2398 | ++saved_regs; | ||
2399 | io_addr += sizeof(*saved_regs); | ||
2400 | } | ||
2401 | } | ||
2402 | |||
2311 | static int | 2403 | static int |
2312 | snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state) | 2404 | snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state) |
2313 | { | 2405 | { |
2314 | struct snd_card *card = pci_get_drvdata(pci); | 2406 | struct snd_card *card = pci_get_drvdata(pci); |
2315 | struct snd_azf3328 *chip = card->private_data; | 2407 | struct snd_azf3328 *chip = card->private_data; |
2316 | unsigned reg; | 2408 | u16 *saved_regs_ctrl_u16; |
2317 | 2409 | ||
2318 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | 2410 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
2319 | 2411 | ||
2320 | snd_pcm_suspend_all(chip->pcm); | 2412 | snd_pcm_suspend_all(chip->pcm[AZF_CODEC_PLAYBACK]); |
2413 | snd_pcm_suspend_all(chip->pcm[AZF_CODEC_I2S_OUT]); | ||
2321 | 2414 | ||
2322 | for (reg = 0; reg < AZF_IO_SIZE_MIXER_PM / 2; ++reg) | 2415 | snd_azf3328_suspend_regs(chip->mixer_io, |
2323 | chip->saved_regs_mixer[reg] = inw(chip->mixer_io + reg * 2); | 2416 | ARRAY_SIZE(chip->saved_regs_mixer), chip->saved_regs_mixer); |
2324 | 2417 | ||
2325 | /* make sure to disable master volume etc. to prevent looping sound */ | 2418 | /* make sure to disable master volume etc. to prevent looping sound */ |
2326 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_PLAY_MASTER, 1); | 2419 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_PLAY_MASTER, 1); |
2327 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 1); | 2420 | snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 1); |
2328 | 2421 | ||
2329 | for (reg = 0; reg < AZF_IO_SIZE_CODEC_PM / 2; ++reg) | 2422 | snd_azf3328_suspend_regs(chip->ctrl_io, |
2330 | chip->saved_regs_codec[reg] = inw(chip->codec_io + reg * 2); | 2423 | ARRAY_SIZE(chip->saved_regs_ctrl), chip->saved_regs_ctrl); |
2331 | 2424 | ||
2332 | /* manually store the one currently relevant write-only reg, too */ | 2425 | /* manually store the one currently relevant write-only reg, too */ |
2333 | chip->saved_regs_codec[IDX_IO_6AH / 2] = chip->shadow_reg_codec_6AH; | 2426 | saved_regs_ctrl_u16 = (u16 *)chip->saved_regs_ctrl; |
2427 | saved_regs_ctrl_u16[IDX_IO_6AH / 2] = chip->shadow_reg_ctrl_6AH; | ||
2334 | 2428 | ||
2335 | for (reg = 0; reg < AZF_IO_SIZE_GAME_PM / 2; ++reg) | 2429 | snd_azf3328_suspend_regs(chip->game_io, |
2336 | chip->saved_regs_game[reg] = inw(chip->game_io + reg * 2); | 2430 | ARRAY_SIZE(chip->saved_regs_game), chip->saved_regs_game); |
2337 | for (reg = 0; reg < AZF_IO_SIZE_MPU_PM / 2; ++reg) | 2431 | snd_azf3328_suspend_regs(chip->mpu_io, |
2338 | chip->saved_regs_mpu[reg] = inw(chip->mpu_io + reg * 2); | 2432 | ARRAY_SIZE(chip->saved_regs_mpu), chip->saved_regs_mpu); |
2339 | for (reg = 0; reg < AZF_IO_SIZE_OPL3_PM / 2; ++reg) | 2433 | snd_azf3328_suspend_regs(chip->opl3_io, |
2340 | chip->saved_regs_opl3[reg] = inw(chip->opl3_io + reg * 2); | 2434 | ARRAY_SIZE(chip->saved_regs_opl3), chip->saved_regs_opl3); |
2341 | 2435 | ||
2342 | pci_disable_device(pci); | 2436 | pci_disable_device(pci); |
2343 | pci_save_state(pci); | 2437 | pci_save_state(pci); |
@@ -2345,12 +2439,28 @@ snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state) | |||
2345 | return 0; | 2439 | return 0; |
2346 | } | 2440 | } |
2347 | 2441 | ||
2442 | static inline void | ||
2443 | snd_azf3328_resume_regs(const u32 *saved_regs, | ||
2444 | unsigned long io_addr, | ||
2445 | unsigned count | ||
2446 | ) | ||
2447 | { | ||
2448 | unsigned reg; | ||
2449 | |||
2450 | for (reg = 0; reg < count; ++reg) { | ||
2451 | outl(*saved_regs, io_addr); | ||
2452 | snd_azf3328_dbgpm("resume: io 0x%04lx: 0x%08x --> 0x%08x\n", | ||
2453 | io_addr, *saved_regs, inl(io_addr)); | ||
2454 | ++saved_regs; | ||
2455 | io_addr += sizeof(*saved_regs); | ||
2456 | } | ||
2457 | } | ||
2458 | |||
2348 | static int | 2459 | static int |
2349 | snd_azf3328_resume(struct pci_dev *pci) | 2460 | snd_azf3328_resume(struct pci_dev *pci) |
2350 | { | 2461 | { |
2351 | struct snd_card *card = pci_get_drvdata(pci); | 2462 | struct snd_card *card = pci_get_drvdata(pci); |
2352 | struct snd_azf3328 *chip = card->private_data; | 2463 | const struct snd_azf3328 *chip = card->private_data; |
2353 | unsigned reg; | ||
2354 | 2464 | ||
2355 | pci_set_power_state(pci, PCI_D0); | 2465 | pci_set_power_state(pci, PCI_D0); |
2356 | pci_restore_state(pci); | 2466 | pci_restore_state(pci); |
@@ -2362,16 +2472,24 @@ snd_azf3328_resume(struct pci_dev *pci) | |||
2362 | } | 2472 | } |
2363 | pci_set_master(pci); | 2473 | pci_set_master(pci); |
2364 | 2474 | ||
2365 | for (reg = 0; reg < AZF_IO_SIZE_GAME_PM / 2; ++reg) | 2475 | snd_azf3328_resume_regs(chip->saved_regs_game, chip->game_io, |
2366 | outw(chip->saved_regs_game[reg], chip->game_io + reg * 2); | 2476 | ARRAY_SIZE(chip->saved_regs_game)); |
2367 | for (reg = 0; reg < AZF_IO_SIZE_MPU_PM / 2; ++reg) | 2477 | snd_azf3328_resume_regs(chip->saved_regs_mpu, chip->mpu_io, |
2368 | outw(chip->saved_regs_mpu[reg], chip->mpu_io + reg * 2); | 2478 | ARRAY_SIZE(chip->saved_regs_mpu)); |
2369 | for (reg = 0; reg < AZF_IO_SIZE_OPL3_PM / 2; ++reg) | 2479 | snd_azf3328_resume_regs(chip->saved_regs_opl3, chip->opl3_io, |
2370 | outw(chip->saved_regs_opl3[reg], chip->opl3_io + reg * 2); | 2480 | ARRAY_SIZE(chip->saved_regs_opl3)); |
2371 | for (reg = 0; reg < AZF_IO_SIZE_MIXER_PM / 2; ++reg) | 2481 | |
2372 | outw(chip->saved_regs_mixer[reg], chip->mixer_io + reg * 2); | 2482 | snd_azf3328_resume_regs(chip->saved_regs_mixer, chip->mixer_io, |
2373 | for (reg = 0; reg < AZF_IO_SIZE_CODEC_PM / 2; ++reg) | 2483 | ARRAY_SIZE(chip->saved_regs_mixer)); |
2374 | outw(chip->saved_regs_codec[reg], chip->codec_io + reg * 2); | 2484 | |
2485 | /* unfortunately with 32bit transfers, IDX_MIXER_PLAY_MASTER (0x02) | ||
2486 | and IDX_MIXER_RESET (offset 0x00) get touched at the same time, | ||
2487 | resulting in a mixer reset condition persisting until _after_ | ||
2488 | master vol was restored. Thus master vol needs an extra restore. */ | ||
2489 | outw(((u16 *)chip->saved_regs_mixer)[1], chip->mixer_io + 2); | ||
2490 | |||
2491 | snd_azf3328_resume_regs(chip->saved_regs_ctrl, chip->ctrl_io, | ||
2492 | ARRAY_SIZE(chip->saved_regs_ctrl)); | ||
2375 | 2493 | ||
2376 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | 2494 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
2377 | return 0; | 2495 | return 0; |
diff --git a/sound/pci/azt3328.h b/sound/pci/azt3328.h index 974e05122f00..6f46b97650cc 100644 --- a/sound/pci/azt3328.h +++ b/sound/pci/azt3328.h | |||
@@ -6,50 +6,59 @@ | |||
6 | 6 | ||
7 | /*** main I/O area port indices ***/ | 7 | /*** main I/O area port indices ***/ |
8 | /* (only 0x70 of 0x80 bytes saved/restored by Windows driver) */ | 8 | /* (only 0x70 of 0x80 bytes saved/restored by Windows driver) */ |
9 | #define AZF_IO_SIZE_CODEC 0x80 | 9 | #define AZF_IO_SIZE_CTRL 0x80 |
10 | #define AZF_IO_SIZE_CODEC_PM 0x70 | 10 | #define AZF_IO_SIZE_CTRL_PM 0x70 |
11 | 11 | ||
12 | /* the driver initialisation suggests a layout of 4 main areas: | 12 | /* the driver initialisation suggests a layout of 4 areas |
13 | * from 0x00 (playback), from 0x20 (recording) and from 0x40 (maybe MPU401??). | 13 | * within the main card control I/O: |
14 | * from 0x00 (playback codec), from 0x20 (recording codec) | ||
15 | * and from 0x40 (most certainly I2S out codec). | ||
14 | * And another area from 0x60 to 0x6f (DirectX timer, IRQ management, | 16 | * And another area from 0x60 to 0x6f (DirectX timer, IRQ management, |
15 | * power management etc.???). */ | 17 | * power management etc.???). */ |
16 | 18 | ||
17 | /** playback area **/ | 19 | #define AZF_IO_OFFS_CODEC_PLAYBACK 0x00 |
18 | #define IDX_IO_PLAY_FLAGS 0x00 /* PU:0x0000 */ | 20 | #define AZF_IO_OFFS_CODEC_CAPTURE 0x20 |
21 | #define AZF_IO_OFFS_CODEC_I2S_OUT 0x40 | ||
22 | |||
23 | #define IDX_IO_CODEC_DMA_FLAGS 0x00 /* PU:0x0000 */ | ||
19 | /* able to reactivate output after output muting due to 8/16bit | 24 | /* able to reactivate output after output muting due to 8/16bit |
20 | * output change, just like 0x0002. | 25 | * output change, just like 0x0002. |
21 | * 0x0001 is the only bit that's able to start the DMA counter */ | 26 | * 0x0001 is the only bit that's able to start the DMA counter */ |
22 | #define DMA_RESUME 0x0001 /* paused if cleared ? */ | 27 | #define DMA_RESUME 0x0001 /* paused if cleared? */ |
23 | /* 0x0002 *temporarily* set during DMA stopping. hmm | 28 | /* 0x0002 *temporarily* set during DMA stopping. hmm |
24 | * both 0x0002 and 0x0004 set in playback setup. */ | 29 | * both 0x0002 and 0x0004 set in playback setup. */ |
25 | /* able to reactivate output after output muting due to 8/16bit | 30 | /* able to reactivate output after output muting due to 8/16bit |
26 | * output change, just like 0x0001. */ | 31 | * output change, just like 0x0001. */ |
27 | #define DMA_PLAY_SOMETHING1 0x0002 /* \ alternated (toggled) */ | 32 | #define DMA_RUN_SOMETHING1 0x0002 /* \ alternated (toggled) */ |
28 | /* 0x0004: NOT able to reactivate output */ | 33 | /* 0x0004: NOT able to reactivate output */ |
29 | #define DMA_PLAY_SOMETHING2 0x0004 /* / bits */ | 34 | #define DMA_RUN_SOMETHING2 0x0004 /* / bits */ |
30 | #define SOMETHING_ALMOST_ALWAYS_SET 0x0008 /* ???; can be modified */ | 35 | #define SOMETHING_ALMOST_ALWAYS_SET 0x0008 /* ???; can be modified */ |
31 | #define DMA_EPILOGUE_SOMETHING 0x0010 | 36 | #define DMA_EPILOGUE_SOMETHING 0x0010 |
32 | #define DMA_SOMETHING_ELSE 0x0020 /* ??? */ | 37 | #define DMA_SOMETHING_ELSE 0x0020 /* ??? */ |
33 | #define SOMETHING_UNMODIFIABLE 0xffc0 /* unused ? not modifiable */ | 38 | #define SOMETHING_UNMODIFIABLE 0xffc0 /* unused? not modifiable */ |
34 | #define IDX_IO_PLAY_IRQTYPE 0x02 /* PU:0x0001 */ | 39 | #define IDX_IO_CODEC_IRQTYPE 0x02 /* PU:0x0001 */ |
35 | /* write back to flags in case flags are set, in order to ACK IRQ in handler | 40 | /* write back to flags in case flags are set, in order to ACK IRQ in handler |
36 | * (bit 1 of port 0x64 indicates interrupt for one of these three types) | 41 | * (bit 1 of port 0x64 indicates interrupt for one of these three types) |
37 | * sometimes in this case it just writes 0xffff to globally ACK all IRQs | 42 | * sometimes in this case it just writes 0xffff to globally ACK all IRQs |
38 | * settings written are not reflected when reading back, though. | 43 | * settings written are not reflected when reading back, though. |
39 | * seems to be IRQ, too (frequently used: port |= 0x07 !), but who knows ? */ | 44 | * seems to be IRQ, too (frequently used: port |= 0x07 !), but who knows? */ |
40 | #define IRQ_PLAY_SOMETHING 0x0001 /* something & ACK */ | 45 | #define IRQ_SOMETHING 0x0001 /* something & ACK */ |
41 | #define IRQ_FINISHED_PLAYBUF_1 0x0002 /* 1st dmabuf finished & ACK */ | 46 | #define IRQ_FINISHED_DMABUF_1 0x0002 /* 1st dmabuf finished & ACK */ |
42 | #define IRQ_FINISHED_PLAYBUF_2 0x0004 /* 2nd dmabuf finished & ACK */ | 47 | #define IRQ_FINISHED_DMABUF_2 0x0004 /* 2nd dmabuf finished & ACK */ |
43 | #define IRQMASK_SOME_STATUS_1 0x0008 /* \ related bits */ | 48 | #define IRQMASK_SOME_STATUS_1 0x0008 /* \ related bits */ |
44 | #define IRQMASK_SOME_STATUS_2 0x0010 /* / (checked together in loop) */ | 49 | #define IRQMASK_SOME_STATUS_2 0x0010 /* / (checked together in loop) */ |
45 | #define IRQMASK_UNMODIFIABLE 0xffe0 /* unused ? not modifiable */ | 50 | #define IRQMASK_UNMODIFIABLE 0xffe0 /* unused? not modifiable */ |
46 | #define IDX_IO_PLAY_DMA_START_1 0x04 /* start address of 1st DMA play area, PU:0x00000000 */ | 51 | /* start address of 1st DMA transfer area, PU:0x00000000 */ |
47 | #define IDX_IO_PLAY_DMA_START_2 0x08 /* start address of 2nd DMA play area, PU:0x00000000 */ | 52 | #define IDX_IO_CODEC_DMA_START_1 0x04 |
48 | #define IDX_IO_PLAY_DMA_LEN_1 0x0c /* length of 1st DMA play area, PU:0x0000 */ | 53 | /* start address of 2nd DMA transfer area, PU:0x00000000 */ |
49 | #define IDX_IO_PLAY_DMA_LEN_2 0x0e /* length of 2nd DMA play area, PU:0x0000 */ | 54 | #define IDX_IO_CODEC_DMA_START_2 0x08 |
50 | #define IDX_IO_PLAY_DMA_CURRPOS 0x10 /* current DMA position, PU:0x00000000 */ | 55 | /* both lengths of DMA transfer areas, PU:0x00000000 |
51 | #define IDX_IO_PLAY_DMA_CURROFS 0x14 /* offset within current DMA play area, PU:0x0000 */ | 56 | length1: offset 0x0c, length2: offset 0x0e */ |
52 | #define IDX_IO_PLAY_SOUNDFORMAT 0x16 /* PU:0x0010 */ | 57 | #define IDX_IO_CODEC_DMA_LENGTHS 0x0c |
58 | #define IDX_IO_CODEC_DMA_CURRPOS 0x10 /* current DMA position, PU:0x00000000 */ | ||
59 | /* offset within current DMA transfer area, PU:0x0000 */ | ||
60 | #define IDX_IO_CODEC_DMA_CURROFS 0x14 | ||
61 | #define IDX_IO_CODEC_SOUNDFORMAT 0x16 /* PU:0x0010 */ | ||
53 | /* all unspecified bits can't be modified */ | 62 | /* all unspecified bits can't be modified */ |
54 | #define SOUNDFORMAT_FREQUENCY_MASK 0x000f | 63 | #define SOUNDFORMAT_FREQUENCY_MASK 0x000f |
55 | #define SOUNDFORMAT_XTAL1 0x00 | 64 | #define SOUNDFORMAT_XTAL1 0x00 |
@@ -76,6 +85,7 @@ | |||
76 | #define SOUNDFORMAT_FLAG_16BIT 0x0010 | 85 | #define SOUNDFORMAT_FLAG_16BIT 0x0010 |
77 | #define SOUNDFORMAT_FLAG_2CHANNELS 0x0020 | 86 | #define SOUNDFORMAT_FLAG_2CHANNELS 0x0020 |
78 | 87 | ||
88 | |||
79 | /* define frequency helpers, for maximum value safety */ | 89 | /* define frequency helpers, for maximum value safety */ |
80 | enum azf_freq_t { | 90 | enum azf_freq_t { |
81 | #define AZF_FREQ(rate) AZF_FREQ_##rate = rate | 91 | #define AZF_FREQ(rate) AZF_FREQ_##rate = rate |
@@ -96,29 +106,6 @@ enum azf_freq_t { | |||
96 | #undef AZF_FREQ | 106 | #undef AZF_FREQ |
97 | }; | 107 | }; |
98 | 108 | ||
99 | /** recording area (see also: playback bit flag definitions) **/ | ||
100 | #define IDX_IO_REC_FLAGS 0x20 /* ??, PU:0x0000 */ | ||
101 | #define IDX_IO_REC_IRQTYPE 0x22 /* ??, PU:0x0000 */ | ||
102 | #define IRQ_REC_SOMETHING 0x0001 /* something & ACK */ | ||
103 | #define IRQ_FINISHED_RECBUF_1 0x0002 /* 1st dmabuf finished & ACK */ | ||
104 | #define IRQ_FINISHED_RECBUF_2 0x0004 /* 2nd dmabuf finished & ACK */ | ||
105 | /* hmm, maybe these are just the corresponding *recording* flags ? | ||
106 | * but OTOH they are most likely at port 0x22 instead */ | ||
107 | #define IRQMASK_SOME_STATUS_1 0x0008 /* \ related bits */ | ||
108 | #define IRQMASK_SOME_STATUS_2 0x0010 /* / (checked together in loop) */ | ||
109 | #define IDX_IO_REC_DMA_START_1 0x24 /* PU:0x00000000 */ | ||
110 | #define IDX_IO_REC_DMA_START_2 0x28 /* PU:0x00000000 */ | ||
111 | #define IDX_IO_REC_DMA_LEN_1 0x2c /* PU:0x0000 */ | ||
112 | #define IDX_IO_REC_DMA_LEN_2 0x2e /* PU:0x0000 */ | ||
113 | #define IDX_IO_REC_DMA_CURRPOS 0x30 /* PU:0x00000000 */ | ||
114 | #define IDX_IO_REC_DMA_CURROFS 0x34 /* PU:0x00000000 */ | ||
115 | #define IDX_IO_REC_SOUNDFORMAT 0x36 /* PU:0x0000 */ | ||
116 | |||
117 | /** hmm, what is this I/O area for? MPU401?? or external DAC via I2S?? (after playback, recording, ???, timer) **/ | ||
118 | #define IDX_IO_SOMETHING_FLAGS 0x40 /* gets set to 0x34 just like port 0x0 and 0x20 on card init, PU:0x0000 */ | ||
119 | /* general */ | ||
120 | #define IDX_IO_42H 0x42 /* PU:0x0001 */ | ||
121 | |||
122 | /** DirectX timer, main interrupt area (FIXME: and something else?) **/ | 109 | /** DirectX timer, main interrupt area (FIXME: and something else?) **/ |
123 | #define IDX_IO_TIMER_VALUE 0x60 /* found this timer area by pure luck :-) */ | 110 | #define IDX_IO_TIMER_VALUE 0x60 /* found this timer area by pure luck :-) */ |
124 | /* timer countdown value; triggers IRQ when timer is finished */ | 111 | /* timer countdown value; triggers IRQ when timer is finished */ |
@@ -133,17 +120,19 @@ enum azf_freq_t { | |||
133 | #define IDX_IO_IRQSTATUS 0x64 | 120 | #define IDX_IO_IRQSTATUS 0x64 |
134 | /* some IRQ bit in here might also be used to signal a power-management timer | 121 | /* some IRQ bit in here might also be used to signal a power-management timer |
135 | * timeout, to request shutdown of the chip (e.g. AD1815JS has such a thing). | 122 | * timeout, to request shutdown of the chip (e.g. AD1815JS has such a thing). |
136 | * Some OPL3 hardware (e.g. in LM4560) has some special timer hardware which | 123 | * OPL3 hardware contains several timers which confusingly in most cases |
137 | * can trigger an OPL3 timer IRQ, so maybe there's such a thing as well... */ | 124 | * are NOT routed to an IRQ, but some designs (e.g. LM4560) DO support that, |
125 | * so I wouldn't be surprised at all to discover that AZF3328 | ||
126 | * supports that thing as well... */ | ||
138 | 127 | ||
139 | #define IRQ_PLAYBACK 0x0001 | 128 | #define IRQ_PLAYBACK 0x0001 |
140 | #define IRQ_RECORDING 0x0002 | 129 | #define IRQ_RECORDING 0x0002 |
141 | #define IRQ_UNKNOWN1 0x0004 /* most probably I2S port */ | 130 | #define IRQ_I2S_OUT 0x0004 /* this IS I2S, right!? (untested) */ |
142 | #define IRQ_GAMEPORT 0x0008 /* Interrupt of Digital(ly) Enhanced Game Port */ | 131 | #define IRQ_GAMEPORT 0x0008 /* Interrupt of Digital(ly) Enhanced Game Port */ |
143 | #define IRQ_MPU401 0x0010 | 132 | #define IRQ_MPU401 0x0010 |
144 | #define IRQ_TIMER 0x0020 /* DirectX timer */ | 133 | #define IRQ_TIMER 0x0020 /* DirectX timer */ |
145 | #define IRQ_UNKNOWN2 0x0040 /* probably unused, or possibly I2S port? */ | 134 | #define IRQ_UNKNOWN2 0x0040 /* probably unused, or possibly OPL3 timer? */ |
146 | #define IRQ_UNKNOWN3 0x0080 /* probably unused, or possibly I2S port? */ | 135 | #define IRQ_UNKNOWN3 0x0080 /* probably unused, or possibly OPL3 timer? */ |
147 | #define IDX_IO_66H 0x66 /* writing 0xffff returns 0x0000 */ | 136 | #define IDX_IO_66H 0x66 /* writing 0xffff returns 0x0000 */ |
148 | /* this is set to e.g. 0x3ff or 0x300, and writable; | 137 | /* this is set to e.g. 0x3ff or 0x300, and writable; |
149 | * maybe some buffer limit, but I couldn't find out more, PU:0x00ff: */ | 138 | * maybe some buffer limit, but I couldn't find out more, PU:0x00ff: */ |
@@ -206,7 +195,7 @@ enum azf_freq_t { | |||
206 | /*** Gameport area port indices ***/ | 195 | /*** Gameport area port indices ***/ |
207 | /* (only 0x06 of 0x08 bytes saved/restored by Windows driver) */ | 196 | /* (only 0x06 of 0x08 bytes saved/restored by Windows driver) */ |
208 | #define AZF_IO_SIZE_GAME 0x08 | 197 | #define AZF_IO_SIZE_GAME 0x08 |
209 | #define AZF_IO_SIZE_GAME_PM 0x06 | 198 | #define AZF_IO_SIZE_GAME_PM 0x06 |
210 | 199 | ||
211 | enum { | 200 | enum { |
212 | AZF_GAME_LEGACY_IO_PORT = 0x200 | 201 | AZF_GAME_LEGACY_IO_PORT = 0x200 |
@@ -272,6 +261,12 @@ enum { | |||
272 | * 11 --> 1/200: */ | 261 | * 11 --> 1/200: */ |
273 | #define GAME_HWCFG_ADC_COUNTER_FREQ_MASK 0x06 | 262 | #define GAME_HWCFG_ADC_COUNTER_FREQ_MASK 0x06 |
274 | 263 | ||
264 | /* FIXME: these values might be reversed... */ | ||
265 | #define GAME_HWCFG_ADC_COUNTER_FREQ_STD 0 | ||
266 | #define GAME_HWCFG_ADC_COUNTER_FREQ_1_2 1 | ||
267 | #define GAME_HWCFG_ADC_COUNTER_FREQ_1_20 2 | ||
268 | #define GAME_HWCFG_ADC_COUNTER_FREQ_1_200 3 | ||
269 | |||
275 | /* enable gameport legacy I/O address (0x200) | 270 | /* enable gameport legacy I/O address (0x200) |
276 | * I was unable to locate any configurability for a different address: */ | 271 | * I was unable to locate any configurability for a different address: */ |
277 | #define GAME_HWCFG_LEGACY_ADDRESS_ENABLE 0x08 | 272 | #define GAME_HWCFG_LEGACY_ADDRESS_ENABLE 0x08 |
@@ -281,6 +276,7 @@ enum { | |||
281 | #define AZF_IO_SIZE_MPU_PM 0x04 | 276 | #define AZF_IO_SIZE_MPU_PM 0x04 |
282 | 277 | ||
283 | /*** OPL3 synth ***/ | 278 | /*** OPL3 synth ***/ |
279 | /* (only 0x06 of 0x08 bytes saved/restored by Windows driver) */ | ||
284 | #define AZF_IO_SIZE_OPL3 0x08 | 280 | #define AZF_IO_SIZE_OPL3 0x08 |
285 | #define AZF_IO_SIZE_OPL3_PM 0x06 | 281 | #define AZF_IO_SIZE_OPL3_PM 0x06 |
286 | /* hmm, given that a standard OPL3 has 4 registers only, | 282 | /* hmm, given that a standard OPL3 has 4 registers only, |
@@ -340,4 +336,7 @@ enum { | |||
340 | #define SET_CHAN_LEFT 1 | 336 | #define SET_CHAN_LEFT 1 |
341 | #define SET_CHAN_RIGHT 2 | 337 | #define SET_CHAN_RIGHT 2 |
342 | 338 | ||
339 | /* helper macro to align I/O port ranges to 32bit I/O width */ | ||
340 | #define AZF_ALIGN(x) (((x) + 3) & (~3)) | ||
341 | |||
343 | #endif /* __SOUND_AZT3328_H */ | 342 | #endif /* __SOUND_AZT3328_H */ |
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 57b992a5c057..15e4138bce17 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c | |||
@@ -325,9 +325,9 @@ static struct snd_pcm_hardware snd_ca0106_capture_hw = { | |||
325 | .rate_max = 192000, | 325 | .rate_max = 192000, |
326 | .channels_min = 2, | 326 | .channels_min = 2, |
327 | .channels_max = 2, | 327 | .channels_max = 2, |
328 | .buffer_bytes_max = ((65536 - 64) * 8), | 328 | .buffer_bytes_max = 65536 - 128, |
329 | .period_bytes_min = 64, | 329 | .period_bytes_min = 64, |
330 | .period_bytes_max = (65536 - 64), | 330 | .period_bytes_max = 32768 - 64, |
331 | .periods_min = 2, | 331 | .periods_min = 2, |
332 | .periods_max = 2, | 332 | .periods_max = 2, |
333 | .fifo_size = 0, | 333 | .fifo_size = 0, |
@@ -1876,7 +1876,7 @@ static int snd_ca0106_resume(struct pci_dev *pci) | |||
1876 | 1876 | ||
1877 | // PCI IDs | 1877 | // PCI IDs |
1878 | static struct pci_device_id snd_ca0106_ids[] = { | 1878 | static struct pci_device_id snd_ca0106_ids[] = { |
1879 | { 0x1102, 0x0007, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Audigy LS or Live 24bit */ | 1879 | { PCI_VDEVICE(CREATIVE, 0x0007), 0 }, /* Audigy LS or Live 24bit */ |
1880 | { 0, } | 1880 | { 0, } |
1881 | }; | 1881 | }; |
1882 | MODULE_DEVICE_TABLE(pci, snd_ca0106_ids); | 1882 | MODULE_DEVICE_TABLE(pci, snd_ca0106_ids); |
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 449fe02f666e..ddcd4a9fd7e6 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c | |||
@@ -2797,11 +2797,11 @@ static inline void snd_cmipci_proc_init(struct cmipci *cm) {} | |||
2797 | 2797 | ||
2798 | 2798 | ||
2799 | static struct pci_device_id snd_cmipci_ids[] = { | 2799 | static struct pci_device_id snd_cmipci_ids[] = { |
2800 | {PCI_VENDOR_ID_CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 2800 | {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338A), 0}, |
2801 | {PCI_VENDOR_ID_CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 2801 | {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338B), 0}, |
2802 | {PCI_VENDOR_ID_CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 2802 | {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738), 0}, |
2803 | {PCI_VENDOR_ID_CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 2803 | {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738B), 0}, |
2804 | {PCI_VENDOR_ID_AL, PCI_DEVICE_ID_CMEDIA_CM8738, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 2804 | {PCI_VDEVICE(AL, PCI_DEVICE_ID_CMEDIA_CM8738), 0}, |
2805 | {0,}, | 2805 | {0,}, |
2806 | }; | 2806 | }; |
2807 | 2807 | ||
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index f6286f84a221..e2e0359bb056 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c | |||
@@ -495,7 +495,7 @@ struct cs4281 { | |||
495 | static irqreturn_t snd_cs4281_interrupt(int irq, void *dev_id); | 495 | static irqreturn_t snd_cs4281_interrupt(int irq, void *dev_id); |
496 | 496 | ||
497 | static struct pci_device_id snd_cs4281_ids[] = { | 497 | static struct pci_device_id snd_cs4281_ids[] = { |
498 | { 0x1013, 0x6005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4281 */ | 498 | { PCI_VDEVICE(CIRRUS, 0x6005), 0, }, /* CS4281 */ |
499 | { 0, } | 499 | { 0, } |
500 | }; | 500 | }; |
501 | 501 | ||
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index c9b3e3d48cbc..033aec430117 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c | |||
@@ -65,9 +65,9 @@ module_param_array(mmap_valid, bool, NULL, 0444); | |||
65 | MODULE_PARM_DESC(mmap_valid, "Support OSS mmap."); | 65 | MODULE_PARM_DESC(mmap_valid, "Support OSS mmap."); |
66 | 66 | ||
67 | static struct pci_device_id snd_cs46xx_ids[] = { | 67 | static struct pci_device_id snd_cs46xx_ids[] = { |
68 | { 0x1013, 0x6001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4280 */ | 68 | { PCI_VDEVICE(CIRRUS, 0x6001), 0, }, /* CS4280 */ |
69 | { 0x1013, 0x6003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4612 */ | 69 | { PCI_VDEVICE(CIRRUS, 0x6003), 0, }, /* CS4612 */ |
70 | { 0x1013, 0x6004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CS4615 */ | 70 | { PCI_VDEVICE(CIRRUS, 0x6004), 0, }, /* CS4615 */ |
71 | { 0, } | 71 | { 0, } |
72 | }; | 72 | }; |
73 | 73 | ||
diff --git a/sound/pci/cs46xx/cs46xx_lib.h b/sound/pci/cs46xx/cs46xx_lib.h index 4eb55aa33612..b5189495d58a 100644 --- a/sound/pci/cs46xx/cs46xx_lib.h +++ b/sound/pci/cs46xx/cs46xx_lib.h | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | 36 | ||
37 | #ifdef CONFIG_SND_CS46XX_NEW_DSP | 37 | #ifdef CONFIG_SND_CS46XX_NEW_DSP |
38 | #define CS46XX_MIN_PERIOD_SIZE 1 | 38 | #define CS46XX_MIN_PERIOD_SIZE 64 |
39 | #define CS46XX_MAX_PERIOD_SIZE 1024*1024 | 39 | #define CS46XX_MAX_PERIOD_SIZE 1024*1024 |
40 | #else | 40 | #else |
41 | #define CS46XX_MIN_PERIOD_SIZE 2048 | 41 | #define CS46XX_MIN_PERIOD_SIZE 2048 |
diff --git a/sound/pci/ctxfi/ct20k2reg.h b/sound/pci/ctxfi/ct20k2reg.h index 2d07986f57cc..e0394e3996e8 100644 --- a/sound/pci/ctxfi/ct20k2reg.h +++ b/sound/pci/ctxfi/ct20k2reg.h | |||
@@ -11,9 +11,12 @@ | |||
11 | 11 | ||
12 | 12 | ||
13 | /* Timer Registers */ | 13 | /* Timer Registers */ |
14 | #define TIMER_TIMR 0x1B7004 | 14 | #define WC 0x1b7000 |
15 | #define INTERRUPT_GIP 0x1B7010 | 15 | #define TIMR 0x1b7004 |
16 | #define INTERRUPT_GIE 0x1B7014 | 16 | # define TIMR_IE (1<<15) |
17 | # define TIMR_IP (1<<14) | ||
18 | #define GIP 0x1b7010 | ||
19 | #define GIE 0x1b7014 | ||
17 | 20 | ||
18 | /* I2C Registers */ | 21 | /* I2C Registers */ |
19 | #define I2C_IF_ADDRESS 0x1B9000 | 22 | #define I2C_IF_ADDRESS 0x1B9000 |
diff --git a/sound/pci/ctxfi/ctamixer.c b/sound/pci/ctxfi/ctamixer.c index a1db51b3ead8..fee35cfc0c7f 100644 --- a/sound/pci/ctxfi/ctamixer.c +++ b/sound/pci/ctxfi/ctamixer.c | |||
@@ -63,7 +63,7 @@ static int amixer_set_input(struct amixer *amixer, struct rsc *rsc) | |||
63 | hw = amixer->rsc.hw; | 63 | hw = amixer->rsc.hw; |
64 | hw->amixer_set_mode(amixer->rsc.ctrl_blk, AMIXER_Y_IMMEDIATE); | 64 | hw->amixer_set_mode(amixer->rsc.ctrl_blk, AMIXER_Y_IMMEDIATE); |
65 | amixer->input = rsc; | 65 | amixer->input = rsc; |
66 | if (NULL == rsc) | 66 | if (!rsc) |
67 | hw->amixer_set_x(amixer->rsc.ctrl_blk, BLANK_SLOT); | 67 | hw->amixer_set_x(amixer->rsc.ctrl_blk, BLANK_SLOT); |
68 | else | 68 | else |
69 | hw->amixer_set_x(amixer->rsc.ctrl_blk, | 69 | hw->amixer_set_x(amixer->rsc.ctrl_blk, |
@@ -99,7 +99,7 @@ static int amixer_set_sum(struct amixer *amixer, struct sum *sum) | |||
99 | 99 | ||
100 | hw = amixer->rsc.hw; | 100 | hw = amixer->rsc.hw; |
101 | amixer->sum = sum; | 101 | amixer->sum = sum; |
102 | if (NULL == sum) { | 102 | if (!sum) { |
103 | hw->amixer_set_se(amixer->rsc.ctrl_blk, 0); | 103 | hw->amixer_set_se(amixer->rsc.ctrl_blk, 0); |
104 | } else { | 104 | } else { |
105 | hw->amixer_set_se(amixer->rsc.ctrl_blk, 1); | 105 | hw->amixer_set_se(amixer->rsc.ctrl_blk, 1); |
@@ -124,20 +124,20 @@ static int amixer_commit_write(struct amixer *amixer) | |||
124 | 124 | ||
125 | /* Program master and conjugate resources */ | 125 | /* Program master and conjugate resources */ |
126 | amixer->rsc.ops->master(&amixer->rsc); | 126 | amixer->rsc.ops->master(&amixer->rsc); |
127 | if (NULL != input) | 127 | if (input) |
128 | input->ops->master(input); | 128 | input->ops->master(input); |
129 | 129 | ||
130 | if (NULL != sum) | 130 | if (sum) |
131 | sum->rsc.ops->master(&sum->rsc); | 131 | sum->rsc.ops->master(&sum->rsc); |
132 | 132 | ||
133 | for (i = 0; i < amixer->rsc.msr; i++) { | 133 | for (i = 0; i < amixer->rsc.msr; i++) { |
134 | hw->amixer_set_dirty_all(amixer->rsc.ctrl_blk); | 134 | hw->amixer_set_dirty_all(amixer->rsc.ctrl_blk); |
135 | if (NULL != input) { | 135 | if (input) { |
136 | hw->amixer_set_x(amixer->rsc.ctrl_blk, | 136 | hw->amixer_set_x(amixer->rsc.ctrl_blk, |
137 | input->ops->output_slot(input)); | 137 | input->ops->output_slot(input)); |
138 | input->ops->next_conj(input); | 138 | input->ops->next_conj(input); |
139 | } | 139 | } |
140 | if (NULL != sum) { | 140 | if (sum) { |
141 | hw->amixer_set_sadr(amixer->rsc.ctrl_blk, | 141 | hw->amixer_set_sadr(amixer->rsc.ctrl_blk, |
142 | sum->rsc.ops->index(&sum->rsc)); | 142 | sum->rsc.ops->index(&sum->rsc)); |
143 | sum->rsc.ops->next_conj(&sum->rsc); | 143 | sum->rsc.ops->next_conj(&sum->rsc); |
@@ -147,10 +147,10 @@ static int amixer_commit_write(struct amixer *amixer) | |||
147 | amixer->rsc.ops->next_conj(&amixer->rsc); | 147 | amixer->rsc.ops->next_conj(&amixer->rsc); |
148 | } | 148 | } |
149 | amixer->rsc.ops->master(&amixer->rsc); | 149 | amixer->rsc.ops->master(&amixer->rsc); |
150 | if (NULL != input) | 150 | if (input) |
151 | input->ops->master(input); | 151 | input->ops->master(input); |
152 | 152 | ||
153 | if (NULL != sum) | 153 | if (sum) |
154 | sum->rsc.ops->master(&sum->rsc); | 154 | sum->rsc.ops->master(&sum->rsc); |
155 | 155 | ||
156 | return 0; | 156 | return 0; |
@@ -242,13 +242,12 @@ static int get_amixer_rsc(struct amixer_mgr *mgr, | |||
242 | 242 | ||
243 | /* Allocate mem for amixer resource */ | 243 | /* Allocate mem for amixer resource */ |
244 | amixer = kzalloc(sizeof(*amixer), GFP_KERNEL); | 244 | amixer = kzalloc(sizeof(*amixer), GFP_KERNEL); |
245 | if (NULL == amixer) { | 245 | if (!amixer) |
246 | err = -ENOMEM; | 246 | return -ENOMEM; |
247 | return err; | ||
248 | } | ||
249 | 247 | ||
250 | /* Check whether there are sufficient | 248 | /* Check whether there are sufficient |
251 | * amixer resources to meet request. */ | 249 | * amixer resources to meet request. */ |
250 | err = 0; | ||
252 | spin_lock_irqsave(&mgr->mgr_lock, flags); | 251 | spin_lock_irqsave(&mgr->mgr_lock, flags); |
253 | for (i = 0; i < desc->msr; i++) { | 252 | for (i = 0; i < desc->msr; i++) { |
254 | err = mgr_get_resource(&mgr->mgr, 1, &idx); | 253 | err = mgr_get_resource(&mgr->mgr, 1, &idx); |
@@ -304,7 +303,7 @@ int amixer_mgr_create(void *hw, struct amixer_mgr **ramixer_mgr) | |||
304 | 303 | ||
305 | *ramixer_mgr = NULL; | 304 | *ramixer_mgr = NULL; |
306 | amixer_mgr = kzalloc(sizeof(*amixer_mgr), GFP_KERNEL); | 305 | amixer_mgr = kzalloc(sizeof(*amixer_mgr), GFP_KERNEL); |
307 | if (NULL == amixer_mgr) | 306 | if (!amixer_mgr) |
308 | return -ENOMEM; | 307 | return -ENOMEM; |
309 | 308 | ||
310 | err = rsc_mgr_init(&amixer_mgr->mgr, AMIXER, AMIXER_RESOURCE_NUM, hw); | 309 | err = rsc_mgr_init(&amixer_mgr->mgr, AMIXER, AMIXER_RESOURCE_NUM, hw); |
@@ -397,12 +396,11 @@ static int get_sum_rsc(struct sum_mgr *mgr, | |||
397 | 396 | ||
398 | /* Allocate mem for sum resource */ | 397 | /* Allocate mem for sum resource */ |
399 | sum = kzalloc(sizeof(*sum), GFP_KERNEL); | 398 | sum = kzalloc(sizeof(*sum), GFP_KERNEL); |
400 | if (NULL == sum) { | 399 | if (!sum) |
401 | err = -ENOMEM; | 400 | return -ENOMEM; |
402 | return err; | ||
403 | } | ||
404 | 401 | ||
405 | /* Check whether there are sufficient sum resources to meet request. */ | 402 | /* Check whether there are sufficient sum resources to meet request. */ |
403 | err = 0; | ||
406 | spin_lock_irqsave(&mgr->mgr_lock, flags); | 404 | spin_lock_irqsave(&mgr->mgr_lock, flags); |
407 | for (i = 0; i < desc->msr; i++) { | 405 | for (i = 0; i < desc->msr; i++) { |
408 | err = mgr_get_resource(&mgr->mgr, 1, &idx); | 406 | err = mgr_get_resource(&mgr->mgr, 1, &idx); |
@@ -458,7 +456,7 @@ int sum_mgr_create(void *hw, struct sum_mgr **rsum_mgr) | |||
458 | 456 | ||
459 | *rsum_mgr = NULL; | 457 | *rsum_mgr = NULL; |
460 | sum_mgr = kzalloc(sizeof(*sum_mgr), GFP_KERNEL); | 458 | sum_mgr = kzalloc(sizeof(*sum_mgr), GFP_KERNEL); |
461 | if (NULL == sum_mgr) | 459 | if (!sum_mgr) |
462 | return -ENOMEM; | 460 | return -ENOMEM; |
463 | 461 | ||
464 | err = rsc_mgr_init(&sum_mgr->mgr, SUM, SUM_RESOURCE_NUM, hw); | 462 | err = rsc_mgr_init(&sum_mgr->mgr, SUM, SUM_RESOURCE_NUM, hw); |
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index a49c76647307..b1b3a644f738 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c | |||
@@ -136,7 +136,7 @@ static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
136 | struct snd_pcm_runtime *runtime; | 136 | struct snd_pcm_runtime *runtime; |
137 | struct ct_vm *vm; | 137 | struct ct_vm *vm; |
138 | 138 | ||
139 | if (NULL == apcm->substream) | 139 | if (!apcm->substream) |
140 | return 0; | 140 | return 0; |
141 | 141 | ||
142 | runtime = apcm->substream->runtime; | 142 | runtime = apcm->substream->runtime; |
@@ -144,7 +144,7 @@ static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
144 | 144 | ||
145 | apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes); | 145 | apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes); |
146 | 146 | ||
147 | if (NULL == apcm->vm_block) | 147 | if (!apcm->vm_block) |
148 | return -ENOENT; | 148 | return -ENOENT; |
149 | 149 | ||
150 | return 0; | 150 | return 0; |
@@ -154,7 +154,7 @@ static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
154 | { | 154 | { |
155 | struct ct_vm *vm; | 155 | struct ct_vm *vm; |
156 | 156 | ||
157 | if (NULL == apcm->vm_block) | 157 | if (!apcm->vm_block) |
158 | return; | 158 | return; |
159 | 159 | ||
160 | vm = atc->vm; | 160 | vm = atc->vm; |
@@ -231,16 +231,16 @@ atc_get_pitch(unsigned int input_rate, unsigned int output_rate) | |||
231 | 231 | ||
232 | static int select_rom(unsigned int pitch) | 232 | static int select_rom(unsigned int pitch) |
233 | { | 233 | { |
234 | if ((pitch > 0x00428f5c) && (pitch < 0x01b851ec)) { | 234 | if (pitch > 0x00428f5c && pitch < 0x01b851ec) { |
235 | /* 0.26 <= pitch <= 1.72 */ | 235 | /* 0.26 <= pitch <= 1.72 */ |
236 | return 1; | 236 | return 1; |
237 | } else if ((0x01d66666 == pitch) || (0x01d66667 == pitch)) { | 237 | } else if (pitch == 0x01d66666 || pitch == 0x01d66667) { |
238 | /* pitch == 1.8375 */ | 238 | /* pitch == 1.8375 */ |
239 | return 2; | 239 | return 2; |
240 | } else if (0x02000000 == pitch) { | 240 | } else if (pitch == 0x02000000) { |
241 | /* pitch == 2 */ | 241 | /* pitch == 2 */ |
242 | return 3; | 242 | return 3; |
243 | } else if ((pitch >= 0x0) && (pitch <= 0x08000000)) { | 243 | } else if (pitch >= 0x0 && pitch <= 0x08000000) { |
244 | /* 0 <= pitch <= 8 */ | 244 | /* 0 <= pitch <= 8 */ |
245 | return 0; | 245 | return 0; |
246 | } else { | 246 | } else { |
@@ -283,7 +283,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
283 | /* Get AMIXER resource */ | 283 | /* Get AMIXER resource */ |
284 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; | 284 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; |
285 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); | 285 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); |
286 | if (NULL == apcm->amixers) { | 286 | if (!apcm->amixers) { |
287 | err = -ENOMEM; | 287 | err = -ENOMEM; |
288 | goto error1; | 288 | goto error1; |
289 | } | 289 | } |
@@ -311,7 +311,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
311 | INIT_VOL, atc->pcm[i+device*2]); | 311 | INIT_VOL, atc->pcm[i+device*2]); |
312 | mutex_unlock(&atc->atc_mutex); | 312 | mutex_unlock(&atc->atc_mutex); |
313 | src = src->ops->next_interleave(src); | 313 | src = src->ops->next_interleave(src); |
314 | if (NULL == src) | 314 | if (!src) |
315 | src = apcm->src; | 315 | src = apcm->src; |
316 | } | 316 | } |
317 | 317 | ||
@@ -334,7 +334,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
334 | struct srcimp *srcimp; | 334 | struct srcimp *srcimp; |
335 | int i; | 335 | int i; |
336 | 336 | ||
337 | if (NULL != apcm->srcimps) { | 337 | if (apcm->srcimps) { |
338 | for (i = 0; i < apcm->n_srcimp; i++) { | 338 | for (i = 0; i < apcm->n_srcimp; i++) { |
339 | srcimp = apcm->srcimps[i]; | 339 | srcimp = apcm->srcimps[i]; |
340 | srcimp->ops->unmap(srcimp); | 340 | srcimp->ops->unmap(srcimp); |
@@ -345,7 +345,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
345 | apcm->srcimps = NULL; | 345 | apcm->srcimps = NULL; |
346 | } | 346 | } |
347 | 347 | ||
348 | if (NULL != apcm->srccs) { | 348 | if (apcm->srccs) { |
349 | for (i = 0; i < apcm->n_srcc; i++) { | 349 | for (i = 0; i < apcm->n_srcc; i++) { |
350 | src_mgr->put_src(src_mgr, apcm->srccs[i]); | 350 | src_mgr->put_src(src_mgr, apcm->srccs[i]); |
351 | apcm->srccs[i] = NULL; | 351 | apcm->srccs[i] = NULL; |
@@ -354,7 +354,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
354 | apcm->srccs = NULL; | 354 | apcm->srccs = NULL; |
355 | } | 355 | } |
356 | 356 | ||
357 | if (NULL != apcm->amixers) { | 357 | if (apcm->amixers) { |
358 | for (i = 0; i < apcm->n_amixer; i++) { | 358 | for (i = 0; i < apcm->n_amixer; i++) { |
359 | amixer_mgr->put_amixer(amixer_mgr, apcm->amixers[i]); | 359 | amixer_mgr->put_amixer(amixer_mgr, apcm->amixers[i]); |
360 | apcm->amixers[i] = NULL; | 360 | apcm->amixers[i] = NULL; |
@@ -363,17 +363,17 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
363 | apcm->amixers = NULL; | 363 | apcm->amixers = NULL; |
364 | } | 364 | } |
365 | 365 | ||
366 | if (NULL != apcm->mono) { | 366 | if (apcm->mono) { |
367 | sum_mgr->put_sum(sum_mgr, apcm->mono); | 367 | sum_mgr->put_sum(sum_mgr, apcm->mono); |
368 | apcm->mono = NULL; | 368 | apcm->mono = NULL; |
369 | } | 369 | } |
370 | 370 | ||
371 | if (NULL != apcm->src) { | 371 | if (apcm->src) { |
372 | src_mgr->put_src(src_mgr, apcm->src); | 372 | src_mgr->put_src(src_mgr, apcm->src); |
373 | apcm->src = NULL; | 373 | apcm->src = NULL; |
374 | } | 374 | } |
375 | 375 | ||
376 | if (NULL != apcm->vm_block) { | 376 | if (apcm->vm_block) { |
377 | /* Undo device virtual mem map */ | 377 | /* Undo device virtual mem map */ |
378 | ct_unmap_audio_buffer(atc, apcm); | 378 | ct_unmap_audio_buffer(atc, apcm); |
379 | apcm->vm_block = NULL; | 379 | apcm->vm_block = NULL; |
@@ -419,7 +419,7 @@ static int atc_pcm_stop(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
419 | src->ops->set_state(src, SRC_STATE_OFF); | 419 | src->ops->set_state(src, SRC_STATE_OFF); |
420 | src->ops->commit_write(src); | 420 | src->ops->commit_write(src); |
421 | 421 | ||
422 | if (NULL != apcm->srccs) { | 422 | if (apcm->srccs) { |
423 | for (i = 0; i < apcm->n_srcc; i++) { | 423 | for (i = 0; i < apcm->n_srcc; i++) { |
424 | src = apcm->srccs[i]; | 424 | src = apcm->srccs[i]; |
425 | src->ops->set_bm(src, 0); | 425 | src->ops->set_bm(src, 0); |
@@ -544,18 +544,18 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
544 | 544 | ||
545 | if (n_srcc) { | 545 | if (n_srcc) { |
546 | apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL); | 546 | apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL); |
547 | if (NULL == apcm->srccs) | 547 | if (!apcm->srccs) |
548 | return -ENOMEM; | 548 | return -ENOMEM; |
549 | } | 549 | } |
550 | if (n_amixer) { | 550 | if (n_amixer) { |
551 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); | 551 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); |
552 | if (NULL == apcm->amixers) { | 552 | if (!apcm->amixers) { |
553 | err = -ENOMEM; | 553 | err = -ENOMEM; |
554 | goto error1; | 554 | goto error1; |
555 | } | 555 | } |
556 | } | 556 | } |
557 | apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL); | 557 | apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL); |
558 | if (NULL == apcm->srcimps) { | 558 | if (!apcm->srcimps) { |
559 | err = -ENOMEM; | 559 | err = -ENOMEM; |
560 | goto error1; | 560 | goto error1; |
561 | } | 561 | } |
@@ -818,7 +818,7 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc, | |||
818 | /* Get AMIXER resource */ | 818 | /* Get AMIXER resource */ |
819 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; | 819 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; |
820 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); | 820 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); |
821 | if (NULL == apcm->amixers) { | 821 | if (!apcm->amixers) { |
822 | err = -ENOMEM; | 822 | err = -ENOMEM; |
823 | goto error1; | 823 | goto error1; |
824 | } | 824 | } |
@@ -919,7 +919,7 @@ spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
919 | amixer = apcm->amixers[i]; | 919 | amixer = apcm->amixers[i]; |
920 | amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); | 920 | amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); |
921 | src = src->ops->next_interleave(src); | 921 | src = src->ops->next_interleave(src); |
922 | if (NULL == src) | 922 | if (!src) |
923 | src = apcm->src; | 923 | src = apcm->src; |
924 | } | 924 | } |
925 | /* Connect to SPDIFOO */ | 925 | /* Connect to SPDIFOO */ |
@@ -1121,7 +1121,7 @@ static int atc_release_resources(struct ct_atc *atc) | |||
1121 | struct ct_mixer *mixer = NULL; | 1121 | struct ct_mixer *mixer = NULL; |
1122 | 1122 | ||
1123 | /* disconnect internal mixer objects */ | 1123 | /* disconnect internal mixer objects */ |
1124 | if (NULL != atc->mixer) { | 1124 | if (atc->mixer) { |
1125 | mixer = atc->mixer; | 1125 | mixer = atc->mixer; |
1126 | mixer->set_input_left(mixer, MIX_LINE_IN, NULL); | 1126 | mixer->set_input_left(mixer, MIX_LINE_IN, NULL); |
1127 | mixer->set_input_right(mixer, MIX_LINE_IN, NULL); | 1127 | mixer->set_input_right(mixer, MIX_LINE_IN, NULL); |
@@ -1131,7 +1131,7 @@ static int atc_release_resources(struct ct_atc *atc) | |||
1131 | mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL); | 1131 | mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL); |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | if (NULL != atc->daios) { | 1134 | if (atc->daios) { |
1135 | daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; | 1135 | daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; |
1136 | for (i = 0; i < atc->n_daio; i++) { | 1136 | for (i = 0; i < atc->n_daio; i++) { |
1137 | daio = atc->daios[i]; | 1137 | daio = atc->daios[i]; |
@@ -1149,7 +1149,7 @@ static int atc_release_resources(struct ct_atc *atc) | |||
1149 | atc->daios = NULL; | 1149 | atc->daios = NULL; |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | if (NULL != atc->pcm) { | 1152 | if (atc->pcm) { |
1153 | sum_mgr = atc->rsc_mgrs[SUM]; | 1153 | sum_mgr = atc->rsc_mgrs[SUM]; |
1154 | for (i = 0; i < atc->n_pcm; i++) | 1154 | for (i = 0; i < atc->n_pcm; i++) |
1155 | sum_mgr->put_sum(sum_mgr, atc->pcm[i]); | 1155 | sum_mgr->put_sum(sum_mgr, atc->pcm[i]); |
@@ -1158,7 +1158,7 @@ static int atc_release_resources(struct ct_atc *atc) | |||
1158 | atc->pcm = NULL; | 1158 | atc->pcm = NULL; |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | if (NULL != atc->srcs) { | 1161 | if (atc->srcs) { |
1162 | src_mgr = atc->rsc_mgrs[SRC]; | 1162 | src_mgr = atc->rsc_mgrs[SRC]; |
1163 | for (i = 0; i < atc->n_src; i++) | 1163 | for (i = 0; i < atc->n_src; i++) |
1164 | src_mgr->put_src(src_mgr, atc->srcs[i]); | 1164 | src_mgr->put_src(src_mgr, atc->srcs[i]); |
@@ -1167,7 +1167,7 @@ static int atc_release_resources(struct ct_atc *atc) | |||
1167 | atc->srcs = NULL; | 1167 | atc->srcs = NULL; |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | if (NULL != atc->srcimps) { | 1170 | if (atc->srcimps) { |
1171 | srcimp_mgr = atc->rsc_mgrs[SRCIMP]; | 1171 | srcimp_mgr = atc->rsc_mgrs[SRCIMP]; |
1172 | for (i = 0; i < atc->n_srcimp; i++) { | 1172 | for (i = 0; i < atc->n_srcimp; i++) { |
1173 | srcimp = atc->srcimps[i]; | 1173 | srcimp = atc->srcimps[i]; |
@@ -1185,7 +1185,7 @@ static int ct_atc_destroy(struct ct_atc *atc) | |||
1185 | { | 1185 | { |
1186 | int i = 0; | 1186 | int i = 0; |
1187 | 1187 | ||
1188 | if (NULL == atc) | 1188 | if (!atc) |
1189 | return 0; | 1189 | return 0; |
1190 | 1190 | ||
1191 | if (atc->timer) { | 1191 | if (atc->timer) { |
@@ -1196,21 +1196,20 @@ static int ct_atc_destroy(struct ct_atc *atc) | |||
1196 | atc_release_resources(atc); | 1196 | atc_release_resources(atc); |
1197 | 1197 | ||
1198 | /* Destroy internal mixer objects */ | 1198 | /* Destroy internal mixer objects */ |
1199 | if (NULL != atc->mixer) | 1199 | if (atc->mixer) |
1200 | ct_mixer_destroy(atc->mixer); | 1200 | ct_mixer_destroy(atc->mixer); |
1201 | 1201 | ||
1202 | for (i = 0; i < NUM_RSCTYP; i++) { | 1202 | for (i = 0; i < NUM_RSCTYP; i++) { |
1203 | if ((NULL != rsc_mgr_funcs[i].destroy) && | 1203 | if (rsc_mgr_funcs[i].destroy && atc->rsc_mgrs[i]) |
1204 | (NULL != atc->rsc_mgrs[i])) | ||
1205 | rsc_mgr_funcs[i].destroy(atc->rsc_mgrs[i]); | 1204 | rsc_mgr_funcs[i].destroy(atc->rsc_mgrs[i]); |
1206 | 1205 | ||
1207 | } | 1206 | } |
1208 | 1207 | ||
1209 | if (NULL != atc->hw) | 1208 | if (atc->hw) |
1210 | destroy_hw_obj((struct hw *)atc->hw); | 1209 | destroy_hw_obj((struct hw *)atc->hw); |
1211 | 1210 | ||
1212 | /* Destroy device virtual memory manager object */ | 1211 | /* Destroy device virtual memory manager object */ |
1213 | if (NULL != atc->vm) { | 1212 | if (atc->vm) { |
1214 | ct_vm_destroy(atc->vm); | 1213 | ct_vm_destroy(atc->vm); |
1215 | atc->vm = NULL; | 1214 | atc->vm = NULL; |
1216 | } | 1215 | } |
@@ -1275,7 +1274,7 @@ int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc) | |||
1275 | alsa_dev_funcs[MIXER].public_name = atc->chip_name; | 1274 | alsa_dev_funcs[MIXER].public_name = atc->chip_name; |
1276 | 1275 | ||
1277 | for (i = 0; i < NUM_CTALSADEVS; i++) { | 1276 | for (i = 0; i < NUM_CTALSADEVS; i++) { |
1278 | if (NULL == alsa_dev_funcs[i].create) | 1277 | if (!alsa_dev_funcs[i].create) |
1279 | continue; | 1278 | continue; |
1280 | 1279 | ||
1281 | err = alsa_dev_funcs[i].create(atc, i, | 1280 | err = alsa_dev_funcs[i].create(atc, i, |
@@ -1312,7 +1311,7 @@ static int __devinit atc_create_hw_devs(struct ct_atc *atc) | |||
1312 | return err; | 1311 | return err; |
1313 | 1312 | ||
1314 | for (i = 0; i < NUM_RSCTYP; i++) { | 1313 | for (i = 0; i < NUM_RSCTYP; i++) { |
1315 | if (NULL == rsc_mgr_funcs[i].create) | 1314 | if (!rsc_mgr_funcs[i].create) |
1316 | continue; | 1315 | continue; |
1317 | 1316 | ||
1318 | err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]); | 1317 | err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]); |
@@ -1339,19 +1338,19 @@ static int atc_get_resources(struct ct_atc *atc) | |||
1339 | int err, i; | 1338 | int err, i; |
1340 | 1339 | ||
1341 | atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL); | 1340 | atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL); |
1342 | if (NULL == atc->daios) | 1341 | if (!atc->daios) |
1343 | return -ENOMEM; | 1342 | return -ENOMEM; |
1344 | 1343 | ||
1345 | atc->srcs = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL); | 1344 | atc->srcs = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL); |
1346 | if (NULL == atc->srcs) | 1345 | if (!atc->srcs) |
1347 | return -ENOMEM; | 1346 | return -ENOMEM; |
1348 | 1347 | ||
1349 | atc->srcimps = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL); | 1348 | atc->srcimps = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL); |
1350 | if (NULL == atc->srcimps) | 1349 | if (!atc->srcimps) |
1351 | return -ENOMEM; | 1350 | return -ENOMEM; |
1352 | 1351 | ||
1353 | atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL); | 1352 | atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL); |
1354 | if (NULL == atc->pcm) | 1353 | if (!atc->pcm) |
1355 | return -ENOMEM; | 1354 | return -ENOMEM; |
1356 | 1355 | ||
1357 | daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; | 1356 | daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; |
@@ -1648,7 +1647,7 @@ int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | |||
1648 | *ratc = NULL; | 1647 | *ratc = NULL; |
1649 | 1648 | ||
1650 | atc = kzalloc(sizeof(*atc), GFP_KERNEL); | 1649 | atc = kzalloc(sizeof(*atc), GFP_KERNEL); |
1651 | if (NULL == atc) | 1650 | if (!atc) |
1652 | return -ENOMEM; | 1651 | return -ENOMEM; |
1653 | 1652 | ||
1654 | /* Set operations */ | 1653 | /* Set operations */ |
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index 082e35c08c02..af56eb949bde 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c | |||
@@ -57,9 +57,9 @@ struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { | |||
57 | 57 | ||
58 | struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { | 58 | struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { |
59 | [LINEO1] = {.left = 0x40, .right = 0x41}, | 59 | [LINEO1] = {.left = 0x40, .right = 0x41}, |
60 | [LINEO2] = {.left = 0x70, .right = 0x71}, | 60 | [LINEO2] = {.left = 0x60, .right = 0x61}, |
61 | [LINEO3] = {.left = 0x50, .right = 0x51}, | 61 | [LINEO3] = {.left = 0x50, .right = 0x51}, |
62 | [LINEO4] = {.left = 0x60, .right = 0x61}, | 62 | [LINEO4] = {.left = 0x70, .right = 0x71}, |
63 | [LINEIM] = {.left = 0x45, .right = 0xc5}, | 63 | [LINEIM] = {.left = 0x45, .right = 0xc5}, |
64 | [SPDIFOO] = {.left = 0x00, .right = 0x01}, | 64 | [SPDIFOO] = {.left = 0x00, .right = 0x01}, |
65 | [SPDIFIO] = {.left = 0x05, .right = 0x85}, | 65 | [SPDIFIO] = {.left = 0x05, .right = 0x85}, |
@@ -173,7 +173,7 @@ static int dao_set_left_input(struct dao *dao, struct rsc *input) | |||
173 | int i; | 173 | int i; |
174 | 174 | ||
175 | entry = kzalloc((sizeof(*entry) * daio->rscl.msr), GFP_KERNEL); | 175 | entry = kzalloc((sizeof(*entry) * daio->rscl.msr), GFP_KERNEL); |
176 | if (NULL == entry) | 176 | if (!entry) |
177 | return -ENOMEM; | 177 | return -ENOMEM; |
178 | 178 | ||
179 | /* Program master and conjugate resources */ | 179 | /* Program master and conjugate resources */ |
@@ -201,7 +201,7 @@ static int dao_set_right_input(struct dao *dao, struct rsc *input) | |||
201 | int i; | 201 | int i; |
202 | 202 | ||
203 | entry = kzalloc((sizeof(*entry) * daio->rscr.msr), GFP_KERNEL); | 203 | entry = kzalloc((sizeof(*entry) * daio->rscr.msr), GFP_KERNEL); |
204 | if (NULL == entry) | 204 | if (!entry) |
205 | return -ENOMEM; | 205 | return -ENOMEM; |
206 | 206 | ||
207 | /* Program master and conjugate resources */ | 207 | /* Program master and conjugate resources */ |
@@ -228,7 +228,7 @@ static int dao_clear_left_input(struct dao *dao) | |||
228 | struct daio *daio = &dao->daio; | 228 | struct daio *daio = &dao->daio; |
229 | int i; | 229 | int i; |
230 | 230 | ||
231 | if (NULL == dao->imappers[0]) | 231 | if (!dao->imappers[0]) |
232 | return 0; | 232 | return 0; |
233 | 233 | ||
234 | entry = dao->imappers[0]; | 234 | entry = dao->imappers[0]; |
@@ -252,7 +252,7 @@ static int dao_clear_right_input(struct dao *dao) | |||
252 | struct daio *daio = &dao->daio; | 252 | struct daio *daio = &dao->daio; |
253 | int i; | 253 | int i; |
254 | 254 | ||
255 | if (NULL == dao->imappers[daio->rscl.msr]) | 255 | if (!dao->imappers[daio->rscl.msr]) |
256 | return 0; | 256 | return 0; |
257 | 257 | ||
258 | entry = dao->imappers[daio->rscl.msr]; | 258 | entry = dao->imappers[daio->rscl.msr]; |
@@ -408,7 +408,7 @@ static int dao_rsc_init(struct dao *dao, | |||
408 | return err; | 408 | return err; |
409 | 409 | ||
410 | dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL); | 410 | dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL); |
411 | if (NULL == dao->imappers) { | 411 | if (!dao->imappers) { |
412 | err = -ENOMEM; | 412 | err = -ENOMEM; |
413 | goto error1; | 413 | goto error1; |
414 | } | 414 | } |
@@ -442,11 +442,11 @@ error1: | |||
442 | 442 | ||
443 | static int dao_rsc_uninit(struct dao *dao) | 443 | static int dao_rsc_uninit(struct dao *dao) |
444 | { | 444 | { |
445 | if (NULL != dao->imappers) { | 445 | if (dao->imappers) { |
446 | if (NULL != dao->imappers[0]) | 446 | if (dao->imappers[0]) |
447 | dao_clear_left_input(dao); | 447 | dao_clear_left_input(dao); |
448 | 448 | ||
449 | if (NULL != dao->imappers[dao->daio.rscl.msr]) | 449 | if (dao->imappers[dao->daio.rscl.msr]) |
450 | dao_clear_right_input(dao); | 450 | dao_clear_right_input(dao); |
451 | 451 | ||
452 | kfree(dao->imappers); | 452 | kfree(dao->imappers); |
@@ -555,7 +555,7 @@ static int get_daio_rsc(struct daio_mgr *mgr, | |||
555 | /* Allocate mem for daio resource */ | 555 | /* Allocate mem for daio resource */ |
556 | if (desc->type <= DAIO_OUT_MAX) { | 556 | if (desc->type <= DAIO_OUT_MAX) { |
557 | dao = kzalloc(sizeof(*dao), GFP_KERNEL); | 557 | dao = kzalloc(sizeof(*dao), GFP_KERNEL); |
558 | if (NULL == dao) { | 558 | if (!dao) { |
559 | err = -ENOMEM; | 559 | err = -ENOMEM; |
560 | goto error; | 560 | goto error; |
561 | } | 561 | } |
@@ -566,7 +566,7 @@ static int get_daio_rsc(struct daio_mgr *mgr, | |||
566 | *rdaio = &dao->daio; | 566 | *rdaio = &dao->daio; |
567 | } else { | 567 | } else { |
568 | dai = kzalloc(sizeof(*dai), GFP_KERNEL); | 568 | dai = kzalloc(sizeof(*dai), GFP_KERNEL); |
569 | if (NULL == dai) { | 569 | if (!dai) { |
570 | err = -ENOMEM; | 570 | err = -ENOMEM; |
571 | goto error; | 571 | goto error; |
572 | } | 572 | } |
@@ -583,9 +583,9 @@ static int get_daio_rsc(struct daio_mgr *mgr, | |||
583 | return 0; | 583 | return 0; |
584 | 584 | ||
585 | error: | 585 | error: |
586 | if (NULL != dao) | 586 | if (dao) |
587 | kfree(dao); | 587 | kfree(dao); |
588 | else if (NULL != dai) | 588 | else if (dai) |
589 | kfree(dai); | 589 | kfree(dai); |
590 | 590 | ||
591 | spin_lock_irqsave(&mgr->mgr_lock, flags); | 591 | spin_lock_irqsave(&mgr->mgr_lock, flags); |
@@ -663,7 +663,7 @@ static int daio_imap_add(struct daio_mgr *mgr, struct imapper *entry) | |||
663 | int err; | 663 | int err; |
664 | 664 | ||
665 | spin_lock_irqsave(&mgr->imap_lock, flags); | 665 | spin_lock_irqsave(&mgr->imap_lock, flags); |
666 | if ((0 == entry->addr) && (mgr->init_imap_added)) { | 666 | if (!entry->addr && mgr->init_imap_added) { |
667 | input_mapper_delete(&mgr->imappers, mgr->init_imap, | 667 | input_mapper_delete(&mgr->imappers, mgr->init_imap, |
668 | daio_map_op, mgr); | 668 | daio_map_op, mgr); |
669 | mgr->init_imap_added = 0; | 669 | mgr->init_imap_added = 0; |
@@ -707,7 +707,7 @@ int daio_mgr_create(void *hw, struct daio_mgr **rdaio_mgr) | |||
707 | 707 | ||
708 | *rdaio_mgr = NULL; | 708 | *rdaio_mgr = NULL; |
709 | daio_mgr = kzalloc(sizeof(*daio_mgr), GFP_KERNEL); | 709 | daio_mgr = kzalloc(sizeof(*daio_mgr), GFP_KERNEL); |
710 | if (NULL == daio_mgr) | 710 | if (!daio_mgr) |
711 | return -ENOMEM; | 711 | return -ENOMEM; |
712 | 712 | ||
713 | err = rsc_mgr_init(&daio_mgr->mgr, DAIO, DAIO_RESOURCE_NUM, hw); | 713 | err = rsc_mgr_init(&daio_mgr->mgr, DAIO, DAIO_RESOURCE_NUM, hw); |
@@ -718,7 +718,7 @@ int daio_mgr_create(void *hw, struct daio_mgr **rdaio_mgr) | |||
718 | spin_lock_init(&daio_mgr->imap_lock); | 718 | spin_lock_init(&daio_mgr->imap_lock); |
719 | INIT_LIST_HEAD(&daio_mgr->imappers); | 719 | INIT_LIST_HEAD(&daio_mgr->imappers); |
720 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); | 720 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); |
721 | if (NULL == entry) { | 721 | if (!entry) { |
722 | err = -ENOMEM; | 722 | err = -ENOMEM; |
723 | goto error2; | 723 | goto error2; |
724 | } | 724 | } |
diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index ad3e1d144464..0cf400f879f9 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c | |||
@@ -168,7 +168,7 @@ static int src_get_rsc_ctrl_blk(void **rblk) | |||
168 | 168 | ||
169 | *rblk = NULL; | 169 | *rblk = NULL; |
170 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 170 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
171 | if (NULL == blk) | 171 | if (!blk) |
172 | return -ENOMEM; | 172 | return -ENOMEM; |
173 | 173 | ||
174 | *rblk = blk; | 174 | *rblk = blk; |
@@ -494,7 +494,7 @@ static int src_mgr_get_ctrl_blk(void **rblk) | |||
494 | 494 | ||
495 | *rblk = NULL; | 495 | *rblk = NULL; |
496 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 496 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
497 | if (NULL == blk) | 497 | if (!blk) |
498 | return -ENOMEM; | 498 | return -ENOMEM; |
499 | 499 | ||
500 | *rblk = blk; | 500 | *rblk = blk; |
@@ -515,7 +515,7 @@ static int srcimp_mgr_get_ctrl_blk(void **rblk) | |||
515 | 515 | ||
516 | *rblk = NULL; | 516 | *rblk = NULL; |
517 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 517 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
518 | if (NULL == blk) | 518 | if (!blk) |
519 | return -ENOMEM; | 519 | return -ENOMEM; |
520 | 520 | ||
521 | *rblk = blk; | 521 | *rblk = blk; |
@@ -702,7 +702,7 @@ static int amixer_rsc_get_ctrl_blk(void **rblk) | |||
702 | 702 | ||
703 | *rblk = NULL; | 703 | *rblk = NULL; |
704 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 704 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
705 | if (NULL == blk) | 705 | if (!blk) |
706 | return -ENOMEM; | 706 | return -ENOMEM; |
707 | 707 | ||
708 | *rblk = blk; | 708 | *rblk = blk; |
@@ -723,7 +723,7 @@ static int amixer_mgr_get_ctrl_blk(void **rblk) | |||
723 | 723 | ||
724 | *rblk = NULL; | 724 | *rblk = NULL; |
725 | /*blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 725 | /*blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
726 | if (NULL == blk) | 726 | if (!blk) |
727 | return -ENOMEM; | 727 | return -ENOMEM; |
728 | 728 | ||
729 | *rblk = blk;*/ | 729 | *rblk = blk;*/ |
@@ -909,7 +909,7 @@ static int dai_get_ctrl_blk(void **rblk) | |||
909 | 909 | ||
910 | *rblk = NULL; | 910 | *rblk = NULL; |
911 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 911 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
912 | if (NULL == blk) | 912 | if (!blk) |
913 | return -ENOMEM; | 913 | return -ENOMEM; |
914 | 914 | ||
915 | *rblk = blk; | 915 | *rblk = blk; |
@@ -958,7 +958,7 @@ static int dao_get_ctrl_blk(void **rblk) | |||
958 | 958 | ||
959 | *rblk = NULL; | 959 | *rblk = NULL; |
960 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 960 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
961 | if (NULL == blk) | 961 | if (!blk) |
962 | return -ENOMEM; | 962 | return -ENOMEM; |
963 | 963 | ||
964 | *rblk = blk; | 964 | *rblk = blk; |
@@ -1152,7 +1152,7 @@ static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk) | |||
1152 | 1152 | ||
1153 | *rblk = NULL; | 1153 | *rblk = NULL; |
1154 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 1154 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
1155 | if (NULL == blk) | 1155 | if (!blk) |
1156 | return -ENOMEM; | 1156 | return -ENOMEM; |
1157 | 1157 | ||
1158 | blk->i2sctl = hw_read_20kx(hw, I2SCTL); | 1158 | blk->i2sctl = hw_read_20kx(hw, I2SCTL); |
@@ -1808,7 +1808,7 @@ static int uaa_to_xfi(struct pci_dev *pci) | |||
1808 | /* By default, Hendrix card UAA Bar0 should be using memory... */ | 1808 | /* By default, Hendrix card UAA Bar0 should be using memory... */ |
1809 | io_base = pci_resource_start(pci, 0); | 1809 | io_base = pci_resource_start(pci, 0); |
1810 | mem_base = ioremap(io_base, pci_resource_len(pci, 0)); | 1810 | mem_base = ioremap(io_base, pci_resource_len(pci, 0)); |
1811 | if (NULL == mem_base) | 1811 | if (!mem_base) |
1812 | return -ENOENT; | 1812 | return -ENOENT; |
1813 | 1813 | ||
1814 | /* Read current mode from Mode Change Register */ | 1814 | /* Read current mode from Mode Change Register */ |
@@ -1977,7 +1977,7 @@ static int hw_card_shutdown(struct hw *hw) | |||
1977 | 1977 | ||
1978 | hw->irq = -1; | 1978 | hw->irq = -1; |
1979 | 1979 | ||
1980 | if (NULL != ((void *)hw->mem_base)) | 1980 | if (hw->mem_base) |
1981 | iounmap((void *)hw->mem_base); | 1981 | iounmap((void *)hw->mem_base); |
1982 | 1982 | ||
1983 | hw->mem_base = (unsigned long)NULL; | 1983 | hw->mem_base = (unsigned long)NULL; |
@@ -2274,7 +2274,7 @@ int __devinit create_20k1_hw_obj(struct hw **rhw) | |||
2274 | 2274 | ||
2275 | *rhw = NULL; | 2275 | *rhw = NULL; |
2276 | hw20k1 = kzalloc(sizeof(*hw20k1), GFP_KERNEL); | 2276 | hw20k1 = kzalloc(sizeof(*hw20k1), GFP_KERNEL); |
2277 | if (NULL == hw20k1) | 2277 | if (!hw20k1) |
2278 | return -ENOMEM; | 2278 | return -ENOMEM; |
2279 | 2279 | ||
2280 | spin_lock_init(&hw20k1->reg_20k1_lock); | 2280 | spin_lock_init(&hw20k1->reg_20k1_lock); |
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index dec46d04b041..b6b11bfe7574 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c | |||
@@ -166,7 +166,7 @@ static int src_get_rsc_ctrl_blk(void **rblk) | |||
166 | 166 | ||
167 | *rblk = NULL; | 167 | *rblk = NULL; |
168 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 168 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
169 | if (NULL == blk) | 169 | if (!blk) |
170 | return -ENOMEM; | 170 | return -ENOMEM; |
171 | 171 | ||
172 | *rblk = blk; | 172 | *rblk = blk; |
@@ -492,7 +492,7 @@ static int src_mgr_get_ctrl_blk(void **rblk) | |||
492 | 492 | ||
493 | *rblk = NULL; | 493 | *rblk = NULL; |
494 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 494 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
495 | if (NULL == blk) | 495 | if (!blk) |
496 | return -ENOMEM; | 496 | return -ENOMEM; |
497 | 497 | ||
498 | *rblk = blk; | 498 | *rblk = blk; |
@@ -513,7 +513,7 @@ static int srcimp_mgr_get_ctrl_blk(void **rblk) | |||
513 | 513 | ||
514 | *rblk = NULL; | 514 | *rblk = NULL; |
515 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 515 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
516 | if (NULL == blk) | 516 | if (!blk) |
517 | return -ENOMEM; | 517 | return -ENOMEM; |
518 | 518 | ||
519 | *rblk = blk; | 519 | *rblk = blk; |
@@ -702,7 +702,7 @@ static int amixer_rsc_get_ctrl_blk(void **rblk) | |||
702 | 702 | ||
703 | *rblk = NULL; | 703 | *rblk = NULL; |
704 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 704 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
705 | if (NULL == blk) | 705 | if (!blk) |
706 | return -ENOMEM; | 706 | return -ENOMEM; |
707 | 707 | ||
708 | *rblk = blk; | 708 | *rblk = blk; |
@@ -891,7 +891,7 @@ static int dai_get_ctrl_blk(void **rblk) | |||
891 | 891 | ||
892 | *rblk = NULL; | 892 | *rblk = NULL; |
893 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 893 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
894 | if (NULL == blk) | 894 | if (!blk) |
895 | return -ENOMEM; | 895 | return -ENOMEM; |
896 | 896 | ||
897 | *rblk = blk; | 897 | *rblk = blk; |
@@ -941,7 +941,7 @@ static int dao_get_ctrl_blk(void **rblk) | |||
941 | 941 | ||
942 | *rblk = NULL; | 942 | *rblk = NULL; |
943 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 943 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
944 | if (NULL == blk) | 944 | if (!blk) |
945 | return -ENOMEM; | 945 | return -ENOMEM; |
946 | 946 | ||
947 | *rblk = blk; | 947 | *rblk = blk; |
@@ -1092,7 +1092,7 @@ static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk) | |||
1092 | 1092 | ||
1093 | *rblk = NULL; | 1093 | *rblk = NULL; |
1094 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); | 1094 | blk = kzalloc(sizeof(*blk), GFP_KERNEL); |
1095 | if (NULL == blk) | 1095 | if (!blk) |
1096 | return -ENOMEM; | 1096 | return -ENOMEM; |
1097 | 1097 | ||
1098 | for (i = 0; i < 8; i++) { | 1098 | for (i = 0; i < 8; i++) { |
@@ -1112,6 +1112,26 @@ static int daio_mgr_put_ctrl_blk(void *blk) | |||
1112 | return 0; | 1112 | return 0; |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | /* Timer interrupt */ | ||
1116 | static int set_timer_irq(struct hw *hw, int enable) | ||
1117 | { | ||
1118 | hw_write_20kx(hw, GIE, enable ? IT_INT : 0); | ||
1119 | return 0; | ||
1120 | } | ||
1121 | |||
1122 | static int set_timer_tick(struct hw *hw, unsigned int ticks) | ||
1123 | { | ||
1124 | if (ticks) | ||
1125 | ticks |= TIMR_IE | TIMR_IP; | ||
1126 | hw_write_20kx(hw, TIMR, ticks); | ||
1127 | return 0; | ||
1128 | } | ||
1129 | |||
1130 | static unsigned int get_wc(struct hw *hw) | ||
1131 | { | ||
1132 | return hw_read_20kx(hw, WC); | ||
1133 | } | ||
1134 | |||
1115 | /* Card hardware initialization block */ | 1135 | /* Card hardware initialization block */ |
1116 | struct dac_conf { | 1136 | struct dac_conf { |
1117 | unsigned int msr; /* master sample rate in rsrs */ | 1137 | unsigned int msr; /* master sample rate in rsrs */ |
@@ -1841,6 +1861,22 @@ static int hw_have_digit_io_switch(struct hw *hw) | |||
1841 | return 0; | 1861 | return 0; |
1842 | } | 1862 | } |
1843 | 1863 | ||
1864 | static irqreturn_t ct_20k2_interrupt(int irq, void *dev_id) | ||
1865 | { | ||
1866 | struct hw *hw = dev_id; | ||
1867 | unsigned int status; | ||
1868 | |||
1869 | status = hw_read_20kx(hw, GIP); | ||
1870 | if (!status) | ||
1871 | return IRQ_NONE; | ||
1872 | |||
1873 | if (hw->irq_callback) | ||
1874 | hw->irq_callback(hw->irq_callback_data, status); | ||
1875 | |||
1876 | hw_write_20kx(hw, GIP, status); | ||
1877 | return IRQ_HANDLED; | ||
1878 | } | ||
1879 | |||
1844 | static int hw_card_start(struct hw *hw) | 1880 | static int hw_card_start(struct hw *hw) |
1845 | { | 1881 | { |
1846 | int err = 0; | 1882 | int err = 0; |
@@ -1868,7 +1904,7 @@ static int hw_card_start(struct hw *hw) | |||
1868 | hw->io_base = pci_resource_start(hw->pci, 2); | 1904 | hw->io_base = pci_resource_start(hw->pci, 2); |
1869 | hw->mem_base = (unsigned long)ioremap(hw->io_base, | 1905 | hw->mem_base = (unsigned long)ioremap(hw->io_base, |
1870 | pci_resource_len(hw->pci, 2)); | 1906 | pci_resource_len(hw->pci, 2)); |
1871 | if (NULL == (void *)hw->mem_base) { | 1907 | if (!hw->mem_base) { |
1872 | err = -ENOENT; | 1908 | err = -ENOENT; |
1873 | goto error2; | 1909 | goto error2; |
1874 | } | 1910 | } |
@@ -1879,12 +1915,15 @@ static int hw_card_start(struct hw *hw) | |||
1879 | set_field(&gctl, GCTL_UAA, 0); | 1915 | set_field(&gctl, GCTL_UAA, 0); |
1880 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); | 1916 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); |
1881 | 1917 | ||
1882 | /*if ((err = request_irq(pci->irq, ct_atc_interrupt, IRQF_SHARED, | 1918 | if (hw->irq < 0) { |
1883 | atc->chip_details->nm_card, hw))) { | 1919 | err = request_irq(pci->irq, ct_20k2_interrupt, IRQF_SHARED, |
1884 | goto error3; | 1920 | "ctxfi", hw); |
1921 | if (err < 0) { | ||
1922 | printk(KERN_ERR "XFi: Cannot get irq %d\n", pci->irq); | ||
1923 | goto error2; | ||
1924 | } | ||
1925 | hw->irq = pci->irq; | ||
1885 | } | 1926 | } |
1886 | hw->irq = pci->irq; | ||
1887 | */ | ||
1888 | 1927 | ||
1889 | pci_set_master(pci); | 1928 | pci_set_master(pci); |
1890 | 1929 | ||
@@ -1923,7 +1962,7 @@ static int hw_card_shutdown(struct hw *hw) | |||
1923 | 1962 | ||
1924 | hw->irq = -1; | 1963 | hw->irq = -1; |
1925 | 1964 | ||
1926 | if (NULL != ((void *)hw->mem_base)) | 1965 | if (hw->mem_base) |
1927 | iounmap((void *)hw->mem_base); | 1966 | iounmap((void *)hw->mem_base); |
1928 | 1967 | ||
1929 | hw->mem_base = (unsigned long)NULL; | 1968 | hw->mem_base = (unsigned long)NULL; |
@@ -1972,7 +2011,7 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) | |||
1972 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); | 2011 | hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); |
1973 | 2012 | ||
1974 | /* Reset all global pending interrupts */ | 2013 | /* Reset all global pending interrupts */ |
1975 | hw_write_20kx(hw, INTERRUPT_GIE, 0); | 2014 | hw_write_20kx(hw, GIE, 0); |
1976 | /* Reset all SRC pending interrupts */ | 2015 | /* Reset all SRC pending interrupts */ |
1977 | hw_write_20kx(hw, SRC_IP, 0); | 2016 | hw_write_20kx(hw, SRC_IP, 0); |
1978 | 2017 | ||
@@ -2149,6 +2188,10 @@ static struct hw ct20k2_preset __devinitdata = { | |||
2149 | .daio_mgr_set_imapnxt = daio_mgr_set_imapnxt, | 2188 | .daio_mgr_set_imapnxt = daio_mgr_set_imapnxt, |
2150 | .daio_mgr_set_imapaddr = daio_mgr_set_imapaddr, | 2189 | .daio_mgr_set_imapaddr = daio_mgr_set_imapaddr, |
2151 | .daio_mgr_commit_write = daio_mgr_commit_write, | 2190 | .daio_mgr_commit_write = daio_mgr_commit_write, |
2191 | |||
2192 | .set_timer_irq = set_timer_irq, | ||
2193 | .set_timer_tick = set_timer_tick, | ||
2194 | .get_wc = get_wc, | ||
2152 | }; | 2195 | }; |
2153 | 2196 | ||
2154 | int __devinit create_20k2_hw_obj(struct hw **rhw) | 2197 | int __devinit create_20k2_hw_obj(struct hw **rhw) |
diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c index f26d7cd9db9f..15c1e7271ea8 100644 --- a/sound/pci/ctxfi/ctmixer.c +++ b/sound/pci/ctxfi/ctmixer.c | |||
@@ -654,7 +654,7 @@ ct_mixer_kcontrol_new(struct ct_mixer *mixer, struct snd_kcontrol_new *new) | |||
654 | int err; | 654 | int err; |
655 | 655 | ||
656 | kctl = snd_ctl_new1(new, mixer->atc); | 656 | kctl = snd_ctl_new1(new, mixer->atc); |
657 | if (NULL == kctl) | 657 | if (!kctl) |
658 | return -ENOMEM; | 658 | return -ENOMEM; |
659 | 659 | ||
660 | if (SNDRV_CTL_ELEM_IFACE_PCM == kctl->id.iface) | 660 | if (SNDRV_CTL_ELEM_IFACE_PCM == kctl->id.iface) |
@@ -837,17 +837,17 @@ static int ct_mixer_get_mem(struct ct_mixer **rmixer) | |||
837 | *rmixer = NULL; | 837 | *rmixer = NULL; |
838 | /* Allocate mem for mixer obj */ | 838 | /* Allocate mem for mixer obj */ |
839 | mixer = kzalloc(sizeof(*mixer), GFP_KERNEL); | 839 | mixer = kzalloc(sizeof(*mixer), GFP_KERNEL); |
840 | if (NULL == mixer) | 840 | if (!mixer) |
841 | return -ENOMEM; | 841 | return -ENOMEM; |
842 | 842 | ||
843 | mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM), | 843 | mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM), |
844 | GFP_KERNEL); | 844 | GFP_KERNEL); |
845 | if (NULL == mixer->amixers) { | 845 | if (!mixer->amixers) { |
846 | err = -ENOMEM; | 846 | err = -ENOMEM; |
847 | goto error1; | 847 | goto error1; |
848 | } | 848 | } |
849 | mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL); | 849 | mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL); |
850 | if (NULL == mixer->sums) { | 850 | if (!mixer->sums) { |
851 | err = -ENOMEM; | 851 | err = -ENOMEM; |
852 | goto error2; | 852 | goto error2; |
853 | } | 853 | } |
diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index 60ea23180acb..d0dc227fbdd3 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c | |||
@@ -97,7 +97,7 @@ static void ct_atc_pcm_interrupt(struct ct_atc_pcm *atc_pcm) | |||
97 | { | 97 | { |
98 | struct ct_atc_pcm *apcm = atc_pcm; | 98 | struct ct_atc_pcm *apcm = atc_pcm; |
99 | 99 | ||
100 | if (NULL == apcm->substream) | 100 | if (!apcm->substream) |
101 | return; | 101 | return; |
102 | 102 | ||
103 | snd_pcm_period_elapsed(apcm->substream); | 103 | snd_pcm_period_elapsed(apcm->substream); |
@@ -123,7 +123,7 @@ static int ct_pcm_playback_open(struct snd_pcm_substream *substream) | |||
123 | int err; | 123 | int err; |
124 | 124 | ||
125 | apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); | 125 | apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); |
126 | if (NULL == apcm) | 126 | if (!apcm) |
127 | return -ENOMEM; | 127 | return -ENOMEM; |
128 | 128 | ||
129 | apcm->substream = substream; | 129 | apcm->substream = substream; |
@@ -271,7 +271,7 @@ static int ct_pcm_capture_open(struct snd_pcm_substream *substream) | |||
271 | int err; | 271 | int err; |
272 | 272 | ||
273 | apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); | 273 | apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); |
274 | if (NULL == apcm) | 274 | if (!apcm) |
275 | return -ENOMEM; | 275 | return -ENOMEM; |
276 | 276 | ||
277 | apcm->started = 0; | 277 | apcm->started = 0; |
diff --git a/sound/pci/ctxfi/ctresource.c b/sound/pci/ctxfi/ctresource.c index 889c495bb7d1..7dfaf67344d4 100644 --- a/sound/pci/ctxfi/ctresource.c +++ b/sound/pci/ctxfi/ctresource.c | |||
@@ -144,7 +144,7 @@ int rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, void *hw) | |||
144 | rsc->msr = msr; | 144 | rsc->msr = msr; |
145 | rsc->hw = hw; | 145 | rsc->hw = hw; |
146 | rsc->ops = &rsc_generic_ops; | 146 | rsc->ops = &rsc_generic_ops; |
147 | if (NULL == hw) { | 147 | if (!hw) { |
148 | rsc->ctrl_blk = NULL; | 148 | rsc->ctrl_blk = NULL; |
149 | return 0; | 149 | return 0; |
150 | } | 150 | } |
@@ -216,7 +216,7 @@ int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type, | |||
216 | mgr->type = NUM_RSCTYP; | 216 | mgr->type = NUM_RSCTYP; |
217 | 217 | ||
218 | mgr->rscs = kzalloc(((amount + 8 - 1) / 8), GFP_KERNEL); | 218 | mgr->rscs = kzalloc(((amount + 8 - 1) / 8), GFP_KERNEL); |
219 | if (NULL == mgr->rscs) | 219 | if (!mgr->rscs) |
220 | return -ENOMEM; | 220 | return -ENOMEM; |
221 | 221 | ||
222 | switch (type) { | 222 | switch (type) { |
diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c index e1c145d8b702..c749fa720889 100644 --- a/sound/pci/ctxfi/ctsrc.c +++ b/sound/pci/ctxfi/ctsrc.c | |||
@@ -441,7 +441,7 @@ get_src_rsc(struct src_mgr *mgr, const struct src_desc *desc, struct src **rsrc) | |||
441 | else | 441 | else |
442 | src = kzalloc(sizeof(*src), GFP_KERNEL); | 442 | src = kzalloc(sizeof(*src), GFP_KERNEL); |
443 | 443 | ||
444 | if (NULL == src) { | 444 | if (!src) { |
445 | err = -ENOMEM; | 445 | err = -ENOMEM; |
446 | goto error1; | 446 | goto error1; |
447 | } | 447 | } |
@@ -550,7 +550,7 @@ int src_mgr_create(void *hw, struct src_mgr **rsrc_mgr) | |||
550 | 550 | ||
551 | *rsrc_mgr = NULL; | 551 | *rsrc_mgr = NULL; |
552 | src_mgr = kzalloc(sizeof(*src_mgr), GFP_KERNEL); | 552 | src_mgr = kzalloc(sizeof(*src_mgr), GFP_KERNEL); |
553 | if (NULL == src_mgr) | 553 | if (!src_mgr) |
554 | return -ENOMEM; | 554 | return -ENOMEM; |
555 | 555 | ||
556 | err = rsc_mgr_init(&src_mgr->mgr, SRC, SRC_RESOURCE_NUM, hw); | 556 | err = rsc_mgr_init(&src_mgr->mgr, SRC, SRC_RESOURCE_NUM, hw); |
@@ -679,7 +679,7 @@ static int srcimp_rsc_init(struct srcimp *srcimp, | |||
679 | /* Reserve memory for imapper nodes */ | 679 | /* Reserve memory for imapper nodes */ |
680 | srcimp->imappers = kzalloc(sizeof(struct imapper)*desc->msr, | 680 | srcimp->imappers = kzalloc(sizeof(struct imapper)*desc->msr, |
681 | GFP_KERNEL); | 681 | GFP_KERNEL); |
682 | if (NULL == srcimp->imappers) { | 682 | if (!srcimp->imappers) { |
683 | err = -ENOMEM; | 683 | err = -ENOMEM; |
684 | goto error1; | 684 | goto error1; |
685 | } | 685 | } |
@@ -724,12 +724,11 @@ static int get_srcimp_rsc(struct srcimp_mgr *mgr, | |||
724 | 724 | ||
725 | /* Allocate mem for SRCIMP resource */ | 725 | /* Allocate mem for SRCIMP resource */ |
726 | srcimp = kzalloc(sizeof(*srcimp), GFP_KERNEL); | 726 | srcimp = kzalloc(sizeof(*srcimp), GFP_KERNEL); |
727 | if (NULL == srcimp) { | 727 | if (!srcimp) |
728 | err = -ENOMEM; | 728 | return -ENOMEM; |
729 | return err; | ||
730 | } | ||
731 | 729 | ||
732 | /* Check whether there are sufficient SRCIMP resources. */ | 730 | /* Check whether there are sufficient SRCIMP resources. */ |
731 | err = 0; | ||
733 | spin_lock_irqsave(&mgr->mgr_lock, flags); | 732 | spin_lock_irqsave(&mgr->mgr_lock, flags); |
734 | for (i = 0; i < desc->msr; i++) { | 733 | for (i = 0; i < desc->msr; i++) { |
735 | err = mgr_get_resource(&mgr->mgr, 1, &idx); | 734 | err = mgr_get_resource(&mgr->mgr, 1, &idx); |
@@ -834,7 +833,7 @@ int srcimp_mgr_create(void *hw, struct srcimp_mgr **rsrcimp_mgr) | |||
834 | 833 | ||
835 | *rsrcimp_mgr = NULL; | 834 | *rsrcimp_mgr = NULL; |
836 | srcimp_mgr = kzalloc(sizeof(*srcimp_mgr), GFP_KERNEL); | 835 | srcimp_mgr = kzalloc(sizeof(*srcimp_mgr), GFP_KERNEL); |
837 | if (NULL == srcimp_mgr) | 836 | if (!srcimp_mgr) |
838 | return -ENOMEM; | 837 | return -ENOMEM; |
839 | 838 | ||
840 | err = rsc_mgr_init(&srcimp_mgr->mgr, SRCIMP, SRCIMP_RESOURCE_NUM, hw); | 839 | err = rsc_mgr_init(&srcimp_mgr->mgr, SRCIMP, SRCIMP_RESOURCE_NUM, hw); |
@@ -845,7 +844,7 @@ int srcimp_mgr_create(void *hw, struct srcimp_mgr **rsrcimp_mgr) | |||
845 | spin_lock_init(&srcimp_mgr->imap_lock); | 844 | spin_lock_init(&srcimp_mgr->imap_lock); |
846 | INIT_LIST_HEAD(&srcimp_mgr->imappers); | 845 | INIT_LIST_HEAD(&srcimp_mgr->imappers); |
847 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); | 846 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); |
848 | if (NULL == entry) { | 847 | if (!entry) { |
849 | err = -ENOMEM; | 848 | err = -ENOMEM; |
850 | goto error2; | 849 | goto error2; |
851 | } | 850 | } |
diff --git a/sound/pci/ctxfi/ctvmem.c b/sound/pci/ctxfi/ctvmem.c index 67665a7e43c6..6b78752e9503 100644 --- a/sound/pci/ctxfi/ctvmem.c +++ b/sound/pci/ctxfi/ctvmem.c | |||
@@ -60,7 +60,7 @@ get_vm_block(struct ct_vm *vm, unsigned int size) | |||
60 | } | 60 | } |
61 | 61 | ||
62 | block = kzalloc(sizeof(*block), GFP_KERNEL); | 62 | block = kzalloc(sizeof(*block), GFP_KERNEL); |
63 | if (NULL == block) | 63 | if (!block) |
64 | goto out; | 64 | goto out; |
65 | 65 | ||
66 | block->addr = entry->addr; | 66 | block->addr = entry->addr; |
@@ -181,7 +181,7 @@ int ct_vm_create(struct ct_vm **rvm) | |||
181 | *rvm = NULL; | 181 | *rvm = NULL; |
182 | 182 | ||
183 | vm = kzalloc(sizeof(*vm), GFP_KERNEL); | 183 | vm = kzalloc(sizeof(*vm), GFP_KERNEL); |
184 | if (NULL == vm) | 184 | if (!vm) |
185 | return -ENOMEM; | 185 | return -ENOMEM; |
186 | 186 | ||
187 | mutex_init(&vm->lock); | 187 | mutex_init(&vm->lock); |
@@ -189,7 +189,7 @@ int ct_vm_create(struct ct_vm **rvm) | |||
189 | /* Allocate page table pages */ | 189 | /* Allocate page table pages */ |
190 | for (i = 0; i < CT_PTP_NUM; i++) { | 190 | for (i = 0; i < CT_PTP_NUM; i++) { |
191 | vm->ptp[i] = kmalloc(PAGE_SIZE, GFP_KERNEL); | 191 | vm->ptp[i] = kmalloc(PAGE_SIZE, GFP_KERNEL); |
192 | if (NULL == vm->ptp[i]) | 192 | if (!vm->ptp[i]) |
193 | break; | 193 | break; |
194 | } | 194 | } |
195 | if (!i) { | 195 | if (!i) { |
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index c7f3b994101c..168af67d938e 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c | |||
@@ -77,9 +77,9 @@ MODULE_PARM_DESC(subsystem, "Force card subsystem model."); | |||
77 | * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value Model:SB0400 | 77 | * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value Model:SB0400 |
78 | */ | 78 | */ |
79 | static struct pci_device_id snd_emu10k1_ids[] = { | 79 | static struct pci_device_id snd_emu10k1_ids[] = { |
80 | { 0x1102, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* EMU10K1 */ | 80 | { PCI_VDEVICE(CREATIVE, 0x0002), 0 }, /* EMU10K1 */ |
81 | { 0x1102, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, /* Audigy */ | 81 | { PCI_VDEVICE(CREATIVE, 0x0004), 1 }, /* Audigy */ |
82 | { 0x1102, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, /* Audigy 2 Value SB0400 */ | 82 | { PCI_VDEVICE(CREATIVE, 0x0008), 1 }, /* Audigy 2 Value SB0400 */ |
83 | { 0, } | 83 | { 0, } |
84 | }; | 84 | }; |
85 | 85 | ||
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 4d3ad793e98f..36e08bd2b3cc 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c | |||
@@ -1607,7 +1607,7 @@ static void __devexit snd_emu10k1x_remove(struct pci_dev *pci) | |||
1607 | 1607 | ||
1608 | // PCI IDs | 1608 | // PCI IDs |
1609 | static struct pci_device_id snd_emu10k1x_ids[] = { | 1609 | static struct pci_device_id snd_emu10k1x_ids[] = { |
1610 | { 0x1102, 0x0006, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Dell OEM version (EMU10K1) */ | 1610 | { PCI_VDEVICE(CREATIVE, 0x0006), 0 }, /* Dell OEM version (EMU10K1) */ |
1611 | { 0, } | 1611 | { 0, } |
1612 | }; | 1612 | }; |
1613 | MODULE_DEVICE_TABLE(pci, snd_emu10k1x_ids); | 1613 | MODULE_DEVICE_TABLE(pci, snd_emu10k1x_ids); |
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index e617acaf10e3..61b8ab39800f 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c | |||
@@ -644,7 +644,7 @@ int __devinit snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm * | |||
644 | int err; | 644 | int err; |
645 | int capture=1; | 645 | int capture=1; |
646 | 646 | ||
647 | /* snd_printk("KERN_DEBUG snd_p16v_pcm called. device=%d\n", device); */ | 647 | /* snd_printk(KERN_DEBUG "snd_p16v_pcm called. device=%d\n", device); */ |
648 | emu->p16v_device_offset = device; | 648 | emu->p16v_device_offset = device; |
649 | if (rpcm) | 649 | if (rpcm) |
650 | *rpcm = NULL; | 650 | *rpcm = NULL; |
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 18f4d1e98c46..2b82c5c723e1 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c | |||
@@ -445,12 +445,12 @@ static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id); | |||
445 | 445 | ||
446 | static struct pci_device_id snd_audiopci_ids[] = { | 446 | static struct pci_device_id snd_audiopci_ids[] = { |
447 | #ifdef CHIP1370 | 447 | #ifdef CHIP1370 |
448 | { 0x1274, 0x5000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ES1370 */ | 448 | { PCI_VDEVICE(ENSONIQ, 0x5000), 0, }, /* ES1370 */ |
449 | #endif | 449 | #endif |
450 | #ifdef CHIP1371 | 450 | #ifdef CHIP1371 |
451 | { 0x1274, 0x1371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ES1371 */ | 451 | { PCI_VDEVICE(ENSONIQ, 0x1371), 0, }, /* ES1371 */ |
452 | { 0x1274, 0x5880, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ES1373 - CT5880 */ | 452 | { PCI_VDEVICE(ENSONIQ, 0x5880), 0, }, /* ES1373 - CT5880 */ |
453 | { 0x1102, 0x8938, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Ectiva EV1938 */ | 453 | { PCI_VDEVICE(ECTIVA, 0x8938), 0, }, /* Ectiva EV1938 */ |
454 | #endif | 454 | #endif |
455 | { 0, } | 455 | { 0, } |
456 | }; | 456 | }; |
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index fbd2ac09aa34..820318ee62c1 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c | |||
@@ -244,7 +244,7 @@ struct es1938 { | |||
244 | static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id); | 244 | static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id); |
245 | 245 | ||
246 | static struct pci_device_id snd_es1938_ids[] = { | 246 | static struct pci_device_id snd_es1938_ids[] = { |
247 | { 0x125d, 0x1969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Solo-1 */ | 247 | { PCI_VDEVICE(ESS, 0x1969), 0, }, /* Solo-1 */ |
248 | { 0, } | 248 | { 0, } |
249 | }; | 249 | }; |
250 | 250 | ||
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 04438f1d682d..55545e0818b5 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig | |||
@@ -46,6 +46,20 @@ config SND_HDA_INPUT_JACK | |||
46 | Say Y here to enable the jack plugging notification via | 46 | Say Y here to enable the jack plugging notification via |
47 | input layer. | 47 | input layer. |
48 | 48 | ||
49 | config SND_HDA_PATCH_LOADER | ||
50 | bool "Support initialization patch loading for HD-audio" | ||
51 | depends on EXPERIMENTAL | ||
52 | select FW_LOADER | ||
53 | select SND_HDA_HWDEP | ||
54 | select SND_HDA_RECONFIG | ||
55 | help | ||
56 | Say Y here to allow the HD-audio driver to load a pseudo | ||
57 | firmware file ("patch") for overriding the BIOS setup at | ||
58 | start up. The "patch" file can be specified via patch module | ||
59 | option, such as patch=hda-init. | ||
60 | |||
61 | This option turns on hwdep and reconfig features automatically. | ||
62 | |||
49 | config SND_HDA_CODEC_REALTEK | 63 | config SND_HDA_CODEC_REALTEK |
50 | bool "Build Realtek HD-audio codec support" | 64 | bool "Build Realtek HD-audio codec support" |
51 | default y | 65 | default y |
@@ -134,6 +148,19 @@ config SND_HDA_ELD | |||
134 | def_bool y | 148 | def_bool y |
135 | depends on SND_HDA_CODEC_INTELHDMI | 149 | depends on SND_HDA_CODEC_INTELHDMI |
136 | 150 | ||
151 | config SND_HDA_CODEC_CIRRUS | ||
152 | bool "Build Cirrus Logic codec support" | ||
153 | depends on SND_HDA_INTEL | ||
154 | default y | ||
155 | help | ||
156 | Say Y here to include Cirrus Logic codec support in | ||
157 | snd-hda-intel driver, such as CS4206. | ||
158 | |||
159 | When the HD-audio driver is built as a module, the codec | ||
160 | support code is also built as another module, | ||
161 | snd-hda-codec-cirrus. | ||
162 | This module is automatically loaded at probing. | ||
163 | |||
137 | config SND_HDA_CODEC_CONEXANT | 164 | config SND_HDA_CODEC_CONEXANT |
138 | bool "Build Conexant HD-audio codec support" | 165 | bool "Build Conexant HD-audio codec support" |
139 | default y | 166 | default y |
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile index e3081d4586cc..315a1c4f8998 100644 --- a/sound/pci/hda/Makefile +++ b/sound/pci/hda/Makefile | |||
@@ -13,6 +13,7 @@ snd-hda-codec-analog-objs := patch_analog.o | |||
13 | snd-hda-codec-idt-objs := patch_sigmatel.o | 13 | snd-hda-codec-idt-objs := patch_sigmatel.o |
14 | snd-hda-codec-si3054-objs := patch_si3054.o | 14 | snd-hda-codec-si3054-objs := patch_si3054.o |
15 | snd-hda-codec-atihdmi-objs := patch_atihdmi.o | 15 | snd-hda-codec-atihdmi-objs := patch_atihdmi.o |
16 | snd-hda-codec-cirrus-objs := patch_cirrus.o | ||
16 | snd-hda-codec-ca0110-objs := patch_ca0110.o | 17 | snd-hda-codec-ca0110-objs := patch_ca0110.o |
17 | snd-hda-codec-conexant-objs := patch_conexant.o | 18 | snd-hda-codec-conexant-objs := patch_conexant.o |
18 | snd-hda-codec-via-objs := patch_via.o | 19 | snd-hda-codec-via-objs := patch_via.o |
@@ -41,6 +42,9 @@ endif | |||
41 | ifdef CONFIG_SND_HDA_CODEC_ATIHDMI | 42 | ifdef CONFIG_SND_HDA_CODEC_ATIHDMI |
42 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-atihdmi.o | 43 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-atihdmi.o |
43 | endif | 44 | endif |
45 | ifdef CONFIG_SND_HDA_CODEC_CIRRUS | ||
46 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-cirrus.o | ||
47 | endif | ||
44 | ifdef CONFIG_SND_HDA_CODEC_CA0110 | 48 | ifdef CONFIG_SND_HDA_CODEC_CA0110 |
45 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-ca0110.o | 49 | obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-ca0110.o |
46 | endif | 50 | endif |
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index 29272f2e95a0..3f51a981e604 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
25 | #include <sound/core.h> | 25 | #include <sound/core.h> |
26 | #include "hda_beep.h" | 26 | #include "hda_beep.h" |
27 | #include "hda_local.h" | ||
27 | 28 | ||
28 | enum { | 29 | enum { |
29 | DIGBEEP_HZ_STEP = 46875, /* 46.875 Hz */ | 30 | DIGBEEP_HZ_STEP = 46875, /* 46.875 Hz */ |
@@ -50,19 +51,22 @@ static void snd_hda_generate_beep(struct work_struct *work) | |||
50 | * The tone frequency of beep generator on IDT/STAC codecs is | 51 | * The tone frequency of beep generator on IDT/STAC codecs is |
51 | * defined from the 8bit tone parameter, in Hz, | 52 | * defined from the 8bit tone parameter, in Hz, |
52 | * freq = 48000 * (257 - tone) / 1024 | 53 | * freq = 48000 * (257 - tone) / 1024 |
53 | * that is from 12kHz to 93.75kHz in step of 46.875 hz | 54 | * that is from 12kHz to 93.75Hz in steps of 46.875 Hz |
54 | */ | 55 | */ |
55 | static int beep_linear_tone(struct hda_beep *beep, int hz) | 56 | static int beep_linear_tone(struct hda_beep *beep, int hz) |
56 | { | 57 | { |
58 | if (hz <= 0) | ||
59 | return 0; | ||
57 | hz *= 1000; /* fixed point */ | 60 | hz *= 1000; /* fixed point */ |
58 | hz = hz - DIGBEEP_HZ_MIN; | 61 | hz = hz - DIGBEEP_HZ_MIN |
62 | + DIGBEEP_HZ_STEP / 2; /* round to nearest step */ | ||
59 | if (hz < 0) | 63 | if (hz < 0) |
60 | hz = 0; /* turn off PC beep*/ | 64 | hz = 0; /* turn off PC beep*/ |
61 | else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN)) | 65 | else if (hz >= (DIGBEEP_HZ_MAX - DIGBEEP_HZ_MIN)) |
62 | hz = 0xff; | 66 | hz = 1; /* max frequency */ |
63 | else { | 67 | else { |
64 | hz /= DIGBEEP_HZ_STEP; | 68 | hz /= DIGBEEP_HZ_STEP; |
65 | hz++; | 69 | hz = 255 - hz; |
66 | } | 70 | } |
67 | return hz; | 71 | return hz; |
68 | } | 72 | } |
@@ -115,6 +119,9 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) | |||
115 | struct hda_beep *beep; | 119 | struct hda_beep *beep; |
116 | int err; | 120 | int err; |
117 | 121 | ||
122 | if (!snd_hda_get_bool_hint(codec, "beep")) | ||
123 | return 0; /* disabled explicitly */ | ||
124 | |||
118 | beep = kzalloc(sizeof(*beep), GFP_KERNEL); | 125 | beep = kzalloc(sizeof(*beep), GFP_KERNEL); |
119 | if (beep == NULL) | 126 | if (beep == NULL) |
120 | return -ENOMEM; | 127 | return -ENOMEM; |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 462e2cedaa6a..af989f660cca 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -44,6 +44,7 @@ struct hda_vendor_id { | |||
44 | /* codec vendor labels */ | 44 | /* codec vendor labels */ |
45 | static struct hda_vendor_id hda_vendor_ids[] = { | 45 | static struct hda_vendor_id hda_vendor_ids[] = { |
46 | { 0x1002, "ATI" }, | 46 | { 0x1002, "ATI" }, |
47 | { 0x1013, "Cirrus Logic" }, | ||
47 | { 0x1057, "Motorola" }, | 48 | { 0x1057, "Motorola" }, |
48 | { 0x1095, "Silicon Image" }, | 49 | { 0x1095, "Silicon Image" }, |
49 | { 0x10de, "Nvidia" }, | 50 | { 0x10de, "Nvidia" }, |
@@ -150,7 +151,14 @@ make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, | |||
150 | { | 151 | { |
151 | u32 val; | 152 | u32 val; |
152 | 153 | ||
153 | val = (u32)(codec->addr & 0x0f) << 28; | 154 | if ((codec->addr & ~0xf) || (direct & ~1) || (nid & ~0x7f) || |
155 | (verb & ~0xfff) || (parm & ~0xffff)) { | ||
156 | printk(KERN_ERR "hda-codec: out of range cmd %x:%x:%x:%x:%x\n", | ||
157 | codec->addr, direct, nid, verb, parm); | ||
158 | return ~0; | ||
159 | } | ||
160 | |||
161 | val = (u32)codec->addr << 28; | ||
154 | val |= (u32)direct << 27; | 162 | val |= (u32)direct << 27; |
155 | val |= (u32)nid << 20; | 163 | val |= (u32)nid << 20; |
156 | val |= verb << 8; | 164 | val |= verb << 8; |
@@ -167,6 +175,9 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd, | |||
167 | struct hda_bus *bus = codec->bus; | 175 | struct hda_bus *bus = codec->bus; |
168 | int err; | 176 | int err; |
169 | 177 | ||
178 | if (cmd == ~0) | ||
179 | return -1; | ||
180 | |||
170 | if (res) | 181 | if (res) |
171 | *res = -1; | 182 | *res = -1; |
172 | again: | 183 | again: |
@@ -174,7 +185,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd, | |||
174 | mutex_lock(&bus->cmd_mutex); | 185 | mutex_lock(&bus->cmd_mutex); |
175 | err = bus->ops.command(bus, cmd); | 186 | err = bus->ops.command(bus, cmd); |
176 | if (!err && res) | 187 | if (!err && res) |
177 | *res = bus->ops.get_response(bus); | 188 | *res = bus->ops.get_response(bus, codec->addr); |
178 | mutex_unlock(&bus->cmd_mutex); | 189 | mutex_unlock(&bus->cmd_mutex); |
179 | snd_hda_power_down(codec); | 190 | snd_hda_power_down(codec); |
180 | if (res && *res == -1 && bus->rirb_error) { | 191 | if (res && *res == -1 && bus->rirb_error) { |
@@ -291,11 +302,20 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, | |||
291 | unsigned int parm; | 302 | unsigned int parm; |
292 | int i, conn_len, conns; | 303 | int i, conn_len, conns; |
293 | unsigned int shift, num_elems, mask; | 304 | unsigned int shift, num_elems, mask; |
305 | unsigned int wcaps; | ||
294 | hda_nid_t prev_nid; | 306 | hda_nid_t prev_nid; |
295 | 307 | ||
296 | if (snd_BUG_ON(!conn_list || max_conns <= 0)) | 308 | if (snd_BUG_ON(!conn_list || max_conns <= 0)) |
297 | return -EINVAL; | 309 | return -EINVAL; |
298 | 310 | ||
311 | wcaps = get_wcaps(codec, nid); | ||
312 | if (!(wcaps & AC_WCAP_CONN_LIST) && | ||
313 | get_wcaps_type(wcaps) != AC_WID_VOL_KNB) { | ||
314 | snd_printk(KERN_WARNING "hda_codec: " | ||
315 | "connection list not available for 0x%x\n", nid); | ||
316 | return -EINVAL; | ||
317 | } | ||
318 | |||
299 | parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN); | 319 | parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN); |
300 | if (parm & AC_CLIST_LONG) { | 320 | if (parm & AC_CLIST_LONG) { |
301 | /* long form */ | 321 | /* long form */ |
@@ -316,6 +336,8 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, | |||
316 | /* single connection */ | 336 | /* single connection */ |
317 | parm = snd_hda_codec_read(codec, nid, 0, | 337 | parm = snd_hda_codec_read(codec, nid, 0, |
318 | AC_VERB_GET_CONNECT_LIST, 0); | 338 | AC_VERB_GET_CONNECT_LIST, 0); |
339 | if (parm == -1 && codec->bus->rirb_error) | ||
340 | return -EIO; | ||
319 | conn_list[0] = parm & mask; | 341 | conn_list[0] = parm & mask; |
320 | return 1; | 342 | return 1; |
321 | } | 343 | } |
@@ -327,11 +349,20 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, | |||
327 | int range_val; | 349 | int range_val; |
328 | hda_nid_t val, n; | 350 | hda_nid_t val, n; |
329 | 351 | ||
330 | if (i % num_elems == 0) | 352 | if (i % num_elems == 0) { |
331 | parm = snd_hda_codec_read(codec, nid, 0, | 353 | parm = snd_hda_codec_read(codec, nid, 0, |
332 | AC_VERB_GET_CONNECT_LIST, i); | 354 | AC_VERB_GET_CONNECT_LIST, i); |
355 | if (parm == -1 && codec->bus->rirb_error) | ||
356 | return -EIO; | ||
357 | } | ||
333 | range_val = !!(parm & (1 << (shift-1))); /* ranges */ | 358 | range_val = !!(parm & (1 << (shift-1))); /* ranges */ |
334 | val = parm & mask; | 359 | val = parm & mask; |
360 | if (val == 0) { | ||
361 | snd_printk(KERN_WARNING "hda_codec: " | ||
362 | "invalid CONNECT_LIST verb %x[%i]:%x\n", | ||
363 | nid, i, parm); | ||
364 | return 0; | ||
365 | } | ||
335 | parm >>= shift; | 366 | parm >>= shift; |
336 | if (range_val) { | 367 | if (range_val) { |
337 | /* ranges between the previous and this one */ | 368 | /* ranges between the previous and this one */ |
@@ -721,8 +752,7 @@ static int read_pin_defaults(struct hda_codec *codec) | |||
721 | for (i = 0; i < codec->num_nodes; i++, nid++) { | 752 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
722 | struct hda_pincfg *pin; | 753 | struct hda_pincfg *pin; |
723 | unsigned int wcaps = get_wcaps(codec, nid); | 754 | unsigned int wcaps = get_wcaps(codec, nid); |
724 | unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> | 755 | unsigned int wid_type = get_wcaps_type(wcaps); |
725 | AC_WCAP_TYPE_SHIFT; | ||
726 | if (wid_type != AC_WID_PIN) | 756 | if (wid_type != AC_WID_PIN) |
727 | continue; | 757 | continue; |
728 | pin = snd_array_new(&codec->init_pins); | 758 | pin = snd_array_new(&codec->init_pins); |
@@ -885,7 +915,7 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
885 | * Returns 0 if successful, or a negative error code. | 915 | * Returns 0 if successful, or a negative error code. |
886 | */ | 916 | */ |
887 | int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, | 917 | int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, |
888 | int do_init, struct hda_codec **codecp) | 918 | struct hda_codec **codecp) |
889 | { | 919 | { |
890 | struct hda_codec *codec; | 920 | struct hda_codec *codec; |
891 | char component[31]; | 921 | char component[31]; |
@@ -978,11 +1008,6 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
978 | codec->afg ? codec->afg : codec->mfg, | 1008 | codec->afg ? codec->afg : codec->mfg, |
979 | AC_PWRST_D0); | 1009 | AC_PWRST_D0); |
980 | 1010 | ||
981 | if (do_init) { | ||
982 | err = snd_hda_codec_configure(codec); | ||
983 | if (err < 0) | ||
984 | goto error; | ||
985 | } | ||
986 | snd_hda_codec_proc_new(codec); | 1011 | snd_hda_codec_proc_new(codec); |
987 | 1012 | ||
988 | snd_hda_create_hwdep(codec); | 1013 | snd_hda_create_hwdep(codec); |
@@ -1036,6 +1061,7 @@ int snd_hda_codec_configure(struct hda_codec *codec) | |||
1036 | err = init_unsol_queue(codec->bus); | 1061 | err = init_unsol_queue(codec->bus); |
1037 | return err; | 1062 | return err; |
1038 | } | 1063 | } |
1064 | EXPORT_SYMBOL_HDA(snd_hda_codec_configure); | ||
1039 | 1065 | ||
1040 | /** | 1066 | /** |
1041 | * snd_hda_codec_setup_stream - set up the codec for streaming | 1067 | * snd_hda_codec_setup_stream - set up the codec for streaming |
@@ -2350,16 +2376,20 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
2350 | hda_nid_t nid; | 2376 | hda_nid_t nid; |
2351 | int i; | 2377 | int i; |
2352 | 2378 | ||
2353 | snd_hda_codec_write(codec, fg, 0, AC_VERB_SET_POWER_STATE, | 2379 | /* this delay seems necessary to avoid click noise at power-down */ |
2380 | if (power_state == AC_PWRST_D3) | ||
2381 | msleep(100); | ||
2382 | snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, | ||
2354 | power_state); | 2383 | power_state); |
2355 | msleep(10); /* partial workaround for "azx_get_response timeout" */ | 2384 | /* partial workaround for "azx_get_response timeout" */ |
2385 | if (power_state == AC_PWRST_D0) | ||
2386 | msleep(10); | ||
2356 | 2387 | ||
2357 | nid = codec->start_nid; | 2388 | nid = codec->start_nid; |
2358 | for (i = 0; i < codec->num_nodes; i++, nid++) { | 2389 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
2359 | unsigned int wcaps = get_wcaps(codec, nid); | 2390 | unsigned int wcaps = get_wcaps(codec, nid); |
2360 | if (wcaps & AC_WCAP_POWER) { | 2391 | if (wcaps & AC_WCAP_POWER) { |
2361 | unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> | 2392 | unsigned int wid_type = get_wcaps_type(wcaps); |
2362 | AC_WCAP_TYPE_SHIFT; | ||
2363 | if (power_state == AC_PWRST_D3 && | 2393 | if (power_state == AC_PWRST_D3 && |
2364 | wid_type == AC_WID_PIN) { | 2394 | wid_type == AC_WID_PIN) { |
2365 | unsigned int pincap; | 2395 | unsigned int pincap; |
@@ -2567,7 +2597,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate, | |||
2567 | case 20: | 2597 | case 20: |
2568 | case 24: | 2598 | case 24: |
2569 | case 32: | 2599 | case 32: |
2570 | if (maxbps >= 32) | 2600 | if (maxbps >= 32 || format == SNDRV_PCM_FORMAT_FLOAT_LE) |
2571 | val |= 0x40; | 2601 | val |= 0x40; |
2572 | else if (maxbps >= 24) | 2602 | else if (maxbps >= 24) |
2573 | val |= 0x30; | 2603 | val |= 0x30; |
@@ -2694,11 +2724,12 @@ static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, | |||
2694 | bps = 20; | 2724 | bps = 20; |
2695 | } | 2725 | } |
2696 | } | 2726 | } |
2697 | else if (streams == AC_SUPFMT_FLOAT32) { | 2727 | if (streams & AC_SUPFMT_FLOAT32) { |
2698 | /* should be exclusive */ | ||
2699 | formats |= SNDRV_PCM_FMTBIT_FLOAT_LE; | 2728 | formats |= SNDRV_PCM_FMTBIT_FLOAT_LE; |
2700 | bps = 32; | 2729 | if (!bps) |
2701 | } else if (streams == AC_SUPFMT_AC3) { | 2730 | bps = 32; |
2731 | } | ||
2732 | if (streams == AC_SUPFMT_AC3) { | ||
2702 | /* should be exclusive */ | 2733 | /* should be exclusive */ |
2703 | /* temporary hack: we have still no proper support | 2734 | /* temporary hack: we have still no proper support |
2704 | * for the direct AC3 stream... | 2735 | * for the direct AC3 stream... |
@@ -3096,7 +3127,7 @@ int snd_hda_check_board_codec_sid_config(struct hda_codec *codec, | |||
3096 | tbl = q; | 3127 | tbl = q; |
3097 | 3128 | ||
3098 | if (tbl->value >= 0 && tbl->value < num_configs) { | 3129 | if (tbl->value >= 0 && tbl->value < num_configs) { |
3099 | #ifdef CONFIG_SND_DEBUG_DETECT | 3130 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
3100 | char tmp[10]; | 3131 | char tmp[10]; |
3101 | const char *model = NULL; | 3132 | const char *model = NULL; |
3102 | if (models) | 3133 | if (models) |
@@ -3470,10 +3501,16 @@ int snd_hda_multi_out_analog_open(struct hda_codec *codec, | |||
3470 | } | 3501 | } |
3471 | mutex_lock(&codec->spdif_mutex); | 3502 | mutex_lock(&codec->spdif_mutex); |
3472 | if (mout->share_spdif) { | 3503 | if (mout->share_spdif) { |
3473 | runtime->hw.rates &= mout->spdif_rates; | 3504 | if ((runtime->hw.rates & mout->spdif_rates) && |
3474 | runtime->hw.formats &= mout->spdif_formats; | 3505 | (runtime->hw.formats & mout->spdif_formats)) { |
3475 | if (mout->spdif_maxbps < hinfo->maxbps) | 3506 | runtime->hw.rates &= mout->spdif_rates; |
3476 | hinfo->maxbps = mout->spdif_maxbps; | 3507 | runtime->hw.formats &= mout->spdif_formats; |
3508 | if (mout->spdif_maxbps < hinfo->maxbps) | ||
3509 | hinfo->maxbps = mout->spdif_maxbps; | ||
3510 | } else { | ||
3511 | mout->share_spdif = 0; | ||
3512 | /* FIXME: need notify? */ | ||
3513 | } | ||
3477 | } | 3514 | } |
3478 | mutex_unlock(&codec->spdif_mutex); | 3515 | mutex_unlock(&codec->spdif_mutex); |
3479 | } | 3516 | } |
@@ -3643,8 +3680,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, | |||
3643 | end_nid = codec->start_nid + codec->num_nodes; | 3680 | end_nid = codec->start_nid + codec->num_nodes; |
3644 | for (nid = codec->start_nid; nid < end_nid; nid++) { | 3681 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
3645 | unsigned int wid_caps = get_wcaps(codec, nid); | 3682 | unsigned int wid_caps = get_wcaps(codec, nid); |
3646 | unsigned int wid_type = | 3683 | unsigned int wid_type = get_wcaps_type(wid_caps); |
3647 | (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
3648 | unsigned int def_conf; | 3684 | unsigned int def_conf; |
3649 | short assoc, loc; | 3685 | short assoc, loc; |
3650 | 3686 | ||
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index cad79efaabc9..99552fb5f756 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -568,7 +568,7 @@ struct hda_bus_ops { | |||
568 | /* send a single command */ | 568 | /* send a single command */ |
569 | int (*command)(struct hda_bus *bus, unsigned int cmd); | 569 | int (*command)(struct hda_bus *bus, unsigned int cmd); |
570 | /* get a response from the last command */ | 570 | /* get a response from the last command */ |
571 | unsigned int (*get_response)(struct hda_bus *bus); | 571 | unsigned int (*get_response)(struct hda_bus *bus, unsigned int addr); |
572 | /* free the private data */ | 572 | /* free the private data */ |
573 | void (*private_free)(struct hda_bus *); | 573 | void (*private_free)(struct hda_bus *); |
574 | /* attach a PCM stream */ | 574 | /* attach a PCM stream */ |
@@ -830,7 +830,8 @@ enum { | |||
830 | int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, | 830 | int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, |
831 | struct hda_bus **busp); | 831 | struct hda_bus **busp); |
832 | int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, | 832 | int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, |
833 | int do_init, struct hda_codec **codecp); | 833 | struct hda_codec **codecp); |
834 | int snd_hda_codec_configure(struct hda_codec *codec); | ||
834 | 835 | ||
835 | /* | 836 | /* |
836 | * low level functions | 837 | * low level functions |
@@ -938,6 +939,13 @@ static inline void snd_hda_power_down(struct hda_codec *codec) {} | |||
938 | #define snd_hda_codec_needs_resume(codec) 1 | 939 | #define snd_hda_codec_needs_resume(codec) 1 |
939 | #endif | 940 | #endif |
940 | 941 | ||
942 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | ||
943 | /* | ||
944 | * patch firmware | ||
945 | */ | ||
946 | int snd_hda_load_patch(struct hda_bus *bus, const char *patch); | ||
947 | #endif | ||
948 | |||
941 | /* | 949 | /* |
942 | * Codec modularization | 950 | * Codec modularization |
943 | */ | 951 | */ |
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index fcad5ec31773..9446a5abea13 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c | |||
@@ -508,7 +508,7 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry, | |||
508 | char name[64]; | 508 | char name[64]; |
509 | char *sname; | 509 | char *sname; |
510 | long long val; | 510 | long long val; |
511 | int n; | 511 | unsigned int n; |
512 | 512 | ||
513 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | 513 | while (!snd_info_get_line(buffer, line, sizeof(line))) { |
514 | if (sscanf(line, "%s %llx", name, &val) != 2) | 514 | if (sscanf(line, "%s %llx", name, &val) != 2) |
@@ -539,7 +539,7 @@ static void hdmi_write_eld_info(struct snd_info_entry *entry, | |||
539 | sname++; | 539 | sname++; |
540 | n = 10 * n + name[4] - '0'; | 540 | n = 10 * n + name[4] - '0'; |
541 | } | 541 | } |
542 | if (n < 0 || n > 31) /* double the CEA limit */ | 542 | if (n >= ELD_MAX_SAD) |
543 | continue; | 543 | continue; |
544 | if (!strcmp(sname, "_coding_type")) | 544 | if (!strcmp(sname, "_coding_type")) |
545 | e->sad[n].format = val; | 545 | e->sad[n].format = val; |
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 1d5797a96682..b36f6c5a92df 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -121,11 +121,17 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid | |||
121 | if (node == NULL) | 121 | if (node == NULL) |
122 | return -ENOMEM; | 122 | return -ENOMEM; |
123 | node->nid = nid; | 123 | node->nid = nid; |
124 | nconns = snd_hda_get_connections(codec, nid, conn_list, | 124 | node->wid_caps = get_wcaps(codec, nid); |
125 | HDA_MAX_CONNECTIONS); | 125 | node->type = get_wcaps_type(node->wid_caps); |
126 | if (nconns < 0) { | 126 | if (node->wid_caps & AC_WCAP_CONN_LIST) { |
127 | kfree(node); | 127 | nconns = snd_hda_get_connections(codec, nid, conn_list, |
128 | return nconns; | 128 | HDA_MAX_CONNECTIONS); |
129 | if (nconns < 0) { | ||
130 | kfree(node); | ||
131 | return nconns; | ||
132 | } | ||
133 | } else { | ||
134 | nconns = 0; | ||
129 | } | 135 | } |
130 | if (nconns <= ARRAY_SIZE(node->slist)) | 136 | if (nconns <= ARRAY_SIZE(node->slist)) |
131 | node->conn_list = node->slist; | 137 | node->conn_list = node->slist; |
@@ -140,8 +146,6 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid | |||
140 | } | 146 | } |
141 | memcpy(node->conn_list, conn_list, nconns * sizeof(hda_nid_t)); | 147 | memcpy(node->conn_list, conn_list, nconns * sizeof(hda_nid_t)); |
142 | node->nconns = nconns; | 148 | node->nconns = nconns; |
143 | node->wid_caps = get_wcaps(codec, nid); | ||
144 | node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
145 | 149 | ||
146 | if (node->type == AC_WID_PIN) { | 150 | if (node->type == AC_WID_PIN) { |
147 | node->pin_caps = snd_hda_query_pin_caps(codec, node->nid); | 151 | node->pin_caps = snd_hda_query_pin_caps(codec, node->nid); |
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index 6812fbe80fa4..cc24e6721d74 100644 --- a/sound/pci/hda/hda_hwdep.c +++ b/sound/pci/hda/hda_hwdep.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/compat.h> | 24 | #include <linux/compat.h> |
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/ctype.h> | 26 | #include <linux/ctype.h> |
27 | #include <linux/firmware.h> | ||
27 | #include <sound/core.h> | 28 | #include <sound/core.h> |
28 | #include "hda_codec.h" | 29 | #include "hda_codec.h" |
29 | #include "hda_local.h" | 30 | #include "hda_local.h" |
@@ -312,12 +313,8 @@ static ssize_t init_verbs_show(struct device *dev, | |||
312 | return len; | 313 | return len; |
313 | } | 314 | } |
314 | 315 | ||
315 | static ssize_t init_verbs_store(struct device *dev, | 316 | static int parse_init_verbs(struct hda_codec *codec, const char *buf) |
316 | struct device_attribute *attr, | ||
317 | const char *buf, size_t count) | ||
318 | { | 317 | { |
319 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
320 | struct hda_codec *codec = hwdep->private_data; | ||
321 | struct hda_verb *v; | 318 | struct hda_verb *v; |
322 | int nid, verb, param; | 319 | int nid, verb, param; |
323 | 320 | ||
@@ -331,6 +328,18 @@ static ssize_t init_verbs_store(struct device *dev, | |||
331 | v->nid = nid; | 328 | v->nid = nid; |
332 | v->verb = verb; | 329 | v->verb = verb; |
333 | v->param = param; | 330 | v->param = param; |
331 | return 0; | ||
332 | } | ||
333 | |||
334 | static ssize_t init_verbs_store(struct device *dev, | ||
335 | struct device_attribute *attr, | ||
336 | const char *buf, size_t count) | ||
337 | { | ||
338 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
339 | struct hda_codec *codec = hwdep->private_data; | ||
340 | int err = parse_init_verbs(codec, buf); | ||
341 | if (err < 0) | ||
342 | return err; | ||
334 | return count; | 343 | return count; |
335 | } | 344 | } |
336 | 345 | ||
@@ -376,19 +385,15 @@ static void remove_trail_spaces(char *str) | |||
376 | 385 | ||
377 | #define MAX_HINTS 1024 | 386 | #define MAX_HINTS 1024 |
378 | 387 | ||
379 | static ssize_t hints_store(struct device *dev, | 388 | static int parse_hints(struct hda_codec *codec, const char *buf) |
380 | struct device_attribute *attr, | ||
381 | const char *buf, size_t count) | ||
382 | { | 389 | { |
383 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
384 | struct hda_codec *codec = hwdep->private_data; | ||
385 | char *key, *val; | 390 | char *key, *val; |
386 | struct hda_hint *hint; | 391 | struct hda_hint *hint; |
387 | 392 | ||
388 | while (isspace(*buf)) | 393 | while (isspace(*buf)) |
389 | buf++; | 394 | buf++; |
390 | if (!*buf || *buf == '#' || *buf == '\n') | 395 | if (!*buf || *buf == '#' || *buf == '\n') |
391 | return count; | 396 | return 0; |
392 | if (*buf == '=') | 397 | if (*buf == '=') |
393 | return -EINVAL; | 398 | return -EINVAL; |
394 | key = kstrndup_noeol(buf, 1024); | 399 | key = kstrndup_noeol(buf, 1024); |
@@ -411,7 +416,7 @@ static ssize_t hints_store(struct device *dev, | |||
411 | kfree(hint->key); | 416 | kfree(hint->key); |
412 | hint->key = key; | 417 | hint->key = key; |
413 | hint->val = val; | 418 | hint->val = val; |
414 | return count; | 419 | return 0; |
415 | } | 420 | } |
416 | /* allocate a new hint entry */ | 421 | /* allocate a new hint entry */ |
417 | if (codec->hints.used >= MAX_HINTS) | 422 | if (codec->hints.used >= MAX_HINTS) |
@@ -424,6 +429,18 @@ static ssize_t hints_store(struct device *dev, | |||
424 | } | 429 | } |
425 | hint->key = key; | 430 | hint->key = key; |
426 | hint->val = val; | 431 | hint->val = val; |
432 | return 0; | ||
433 | } | ||
434 | |||
435 | static ssize_t hints_store(struct device *dev, | ||
436 | struct device_attribute *attr, | ||
437 | const char *buf, size_t count) | ||
438 | { | ||
439 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
440 | struct hda_codec *codec = hwdep->private_data; | ||
441 | int err = parse_hints(codec, buf); | ||
442 | if (err < 0) | ||
443 | return err; | ||
427 | return count; | 444 | return count; |
428 | } | 445 | } |
429 | 446 | ||
@@ -469,20 +486,24 @@ static ssize_t driver_pin_configs_show(struct device *dev, | |||
469 | 486 | ||
470 | #define MAX_PIN_CONFIGS 32 | 487 | #define MAX_PIN_CONFIGS 32 |
471 | 488 | ||
472 | static ssize_t user_pin_configs_store(struct device *dev, | 489 | static int parse_user_pin_configs(struct hda_codec *codec, const char *buf) |
473 | struct device_attribute *attr, | ||
474 | const char *buf, size_t count) | ||
475 | { | 490 | { |
476 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
477 | struct hda_codec *codec = hwdep->private_data; | ||
478 | int nid, cfg; | 491 | int nid, cfg; |
479 | int err; | ||
480 | 492 | ||
481 | if (sscanf(buf, "%i %i", &nid, &cfg) != 2) | 493 | if (sscanf(buf, "%i %i", &nid, &cfg) != 2) |
482 | return -EINVAL; | 494 | return -EINVAL; |
483 | if (!nid) | 495 | if (!nid) |
484 | return -EINVAL; | 496 | return -EINVAL; |
485 | err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg); | 497 | return snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg); |
498 | } | ||
499 | |||
500 | static ssize_t user_pin_configs_store(struct device *dev, | ||
501 | struct device_attribute *attr, | ||
502 | const char *buf, size_t count) | ||
503 | { | ||
504 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
505 | struct hda_codec *codec = hwdep->private_data; | ||
506 | int err = parse_user_pin_configs(codec, buf); | ||
486 | if (err < 0) | 507 | if (err < 0) |
487 | return err; | 508 | return err; |
488 | return count; | 509 | return count; |
@@ -553,3 +574,180 @@ int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key) | |||
553 | EXPORT_SYMBOL_HDA(snd_hda_get_bool_hint); | 574 | EXPORT_SYMBOL_HDA(snd_hda_get_bool_hint); |
554 | 575 | ||
555 | #endif /* CONFIG_SND_HDA_RECONFIG */ | 576 | #endif /* CONFIG_SND_HDA_RECONFIG */ |
577 | |||
578 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | ||
579 | |||
580 | /* parser mode */ | ||
581 | enum { | ||
582 | LINE_MODE_NONE, | ||
583 | LINE_MODE_CODEC, | ||
584 | LINE_MODE_MODEL, | ||
585 | LINE_MODE_PINCFG, | ||
586 | LINE_MODE_VERB, | ||
587 | LINE_MODE_HINT, | ||
588 | NUM_LINE_MODES, | ||
589 | }; | ||
590 | |||
591 | static inline int strmatch(const char *a, const char *b) | ||
592 | { | ||
593 | return strnicmp(a, b, strlen(b)) == 0; | ||
594 | } | ||
595 | |||
596 | /* parse the contents after the line "[codec]" | ||
597 | * accept only the line with three numbers, and assign the current codec | ||
598 | */ | ||
599 | static void parse_codec_mode(char *buf, struct hda_bus *bus, | ||
600 | struct hda_codec **codecp) | ||
601 | { | ||
602 | unsigned int vendorid, subid, caddr; | ||
603 | struct hda_codec *codec; | ||
604 | |||
605 | *codecp = NULL; | ||
606 | if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) { | ||
607 | list_for_each_entry(codec, &bus->codec_list, list) { | ||
608 | if (codec->addr == caddr) { | ||
609 | *codecp = codec; | ||
610 | break; | ||
611 | } | ||
612 | } | ||
613 | } | ||
614 | } | ||
615 | |||
616 | /* parse the contents after the other command tags, [pincfg], [verb], | ||
617 | * [hint] and [model] | ||
618 | * just pass to the sysfs helper (only when any codec was specified) | ||
619 | */ | ||
620 | static void parse_pincfg_mode(char *buf, struct hda_bus *bus, | ||
621 | struct hda_codec **codecp) | ||
622 | { | ||
623 | if (!*codecp) | ||
624 | return; | ||
625 | parse_user_pin_configs(*codecp, buf); | ||
626 | } | ||
627 | |||
628 | static void parse_verb_mode(char *buf, struct hda_bus *bus, | ||
629 | struct hda_codec **codecp) | ||
630 | { | ||
631 | if (!*codecp) | ||
632 | return; | ||
633 | parse_init_verbs(*codecp, buf); | ||
634 | } | ||
635 | |||
636 | static void parse_hint_mode(char *buf, struct hda_bus *bus, | ||
637 | struct hda_codec **codecp) | ||
638 | { | ||
639 | if (!*codecp) | ||
640 | return; | ||
641 | parse_hints(*codecp, buf); | ||
642 | } | ||
643 | |||
644 | static void parse_model_mode(char *buf, struct hda_bus *bus, | ||
645 | struct hda_codec **codecp) | ||
646 | { | ||
647 | if (!*codecp) | ||
648 | return; | ||
649 | kfree((*codecp)->modelname); | ||
650 | (*codecp)->modelname = kstrdup(buf, GFP_KERNEL); | ||
651 | } | ||
652 | |||
653 | struct hda_patch_item { | ||
654 | const char *tag; | ||
655 | void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc); | ||
656 | }; | ||
657 | |||
658 | static struct hda_patch_item patch_items[NUM_LINE_MODES] = { | ||
659 | [LINE_MODE_CODEC] = { "[codec]", parse_codec_mode }, | ||
660 | [LINE_MODE_MODEL] = { "[model]", parse_model_mode }, | ||
661 | [LINE_MODE_VERB] = { "[verb]", parse_verb_mode }, | ||
662 | [LINE_MODE_PINCFG] = { "[pincfg]", parse_pincfg_mode }, | ||
663 | [LINE_MODE_HINT] = { "[hint]", parse_hint_mode }, | ||
664 | }; | ||
665 | |||
666 | /* check the line starting with '[' -- change the parser mode accodingly */ | ||
667 | static int parse_line_mode(char *buf, struct hda_bus *bus) | ||
668 | { | ||
669 | int i; | ||
670 | for (i = 0; i < ARRAY_SIZE(patch_items); i++) { | ||
671 | if (!patch_items[i].tag) | ||
672 | continue; | ||
673 | if (strmatch(buf, patch_items[i].tag)) | ||
674 | return i; | ||
675 | } | ||
676 | return LINE_MODE_NONE; | ||
677 | } | ||
678 | |||
679 | /* copy one line from the buffer in fw, and update the fields in fw | ||
680 | * return zero if it reaches to the end of the buffer, or non-zero | ||
681 | * if successfully copied a line | ||
682 | * | ||
683 | * the spaces at the beginning and the end of the line are stripped | ||
684 | */ | ||
685 | static int get_line_from_fw(char *buf, int size, struct firmware *fw) | ||
686 | { | ||
687 | int len; | ||
688 | const char *p = fw->data; | ||
689 | while (isspace(*p) && fw->size) { | ||
690 | p++; | ||
691 | fw->size--; | ||
692 | } | ||
693 | if (!fw->size) | ||
694 | return 0; | ||
695 | if (size < fw->size) | ||
696 | size = fw->size; | ||
697 | |||
698 | for (len = 0; len < fw->size; len++) { | ||
699 | if (!*p) | ||
700 | break; | ||
701 | if (*p == '\n') { | ||
702 | p++; | ||
703 | len++; | ||
704 | break; | ||
705 | } | ||
706 | if (len < size) | ||
707 | *buf++ = *p++; | ||
708 | } | ||
709 | *buf = 0; | ||
710 | fw->size -= len; | ||
711 | fw->data = p; | ||
712 | remove_trail_spaces(buf); | ||
713 | return 1; | ||
714 | } | ||
715 | |||
716 | /* | ||
717 | * load a "patch" firmware file and parse it | ||
718 | */ | ||
719 | int snd_hda_load_patch(struct hda_bus *bus, const char *patch) | ||
720 | { | ||
721 | int err; | ||
722 | const struct firmware *fw; | ||
723 | struct firmware tmp; | ||
724 | char buf[128]; | ||
725 | struct hda_codec *codec; | ||
726 | int line_mode; | ||
727 | struct device *dev = bus->card->dev; | ||
728 | |||
729 | if (snd_BUG_ON(!dev)) | ||
730 | return -ENODEV; | ||
731 | err = request_firmware(&fw, patch, dev); | ||
732 | if (err < 0) { | ||
733 | printk(KERN_ERR "hda-codec: Cannot load the patch '%s'\n", | ||
734 | patch); | ||
735 | return err; | ||
736 | } | ||
737 | |||
738 | tmp = *fw; | ||
739 | line_mode = LINE_MODE_NONE; | ||
740 | codec = NULL; | ||
741 | while (get_line_from_fw(buf, sizeof(buf) - 1, &tmp)) { | ||
742 | if (!*buf || *buf == '#' || *buf == '\n') | ||
743 | continue; | ||
744 | if (*buf == '[') | ||
745 | line_mode = parse_line_mode(buf, bus); | ||
746 | else if (patch_items[line_mode].parser) | ||
747 | patch_items[line_mode].parser(buf, bus, &codec); | ||
748 | } | ||
749 | release_firmware(fw); | ||
750 | return 0; | ||
751 | } | ||
752 | EXPORT_SYMBOL_HDA(snd_hda_load_patch); | ||
753 | #endif /* CONFIG_SND_HDA_PATCH_LOADER */ | ||
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 4e9ea7080270..20a66f85f0a4 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -61,6 +61,9 @@ static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; | |||
61 | static int probe_only[SNDRV_CARDS]; | 61 | static int probe_only[SNDRV_CARDS]; |
62 | static int single_cmd; | 62 | static int single_cmd; |
63 | static int enable_msi; | 63 | static int enable_msi; |
64 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | ||
65 | static char *patch[SNDRV_CARDS]; | ||
66 | #endif | ||
64 | 67 | ||
65 | module_param_array(index, int, NULL, 0444); | 68 | module_param_array(index, int, NULL, 0444); |
66 | MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); | 69 | MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); |
@@ -84,6 +87,10 @@ MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs " | |||
84 | "(for debugging only)."); | 87 | "(for debugging only)."); |
85 | module_param(enable_msi, int, 0444); | 88 | module_param(enable_msi, int, 0444); |
86 | MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)"); | 89 | MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)"); |
90 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | ||
91 | module_param_array(patch, charp, NULL, 0444); | ||
92 | MODULE_PARM_DESC(patch, "Patch file for Intel HD audio interface."); | ||
93 | #endif | ||
87 | 94 | ||
88 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 95 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
89 | static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; | 96 | static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; |
@@ -253,7 +260,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; | |||
253 | 260 | ||
254 | /* STATESTS int mask: S3,SD2,SD1,SD0 */ | 261 | /* STATESTS int mask: S3,SD2,SD1,SD0 */ |
255 | #define AZX_MAX_CODECS 4 | 262 | #define AZX_MAX_CODECS 4 |
256 | #define STATESTS_INT_MASK 0x0f | 263 | #define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1) |
257 | 264 | ||
258 | /* SD_CTL bits */ | 265 | /* SD_CTL bits */ |
259 | #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ | 266 | #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ |
@@ -361,8 +368,8 @@ struct azx_rb { | |||
361 | dma_addr_t addr; /* physical address of CORB/RIRB buffer */ | 368 | dma_addr_t addr; /* physical address of CORB/RIRB buffer */ |
362 | /* for RIRB */ | 369 | /* for RIRB */ |
363 | unsigned short rp, wp; /* read/write pointers */ | 370 | unsigned short rp, wp; /* read/write pointers */ |
364 | int cmds; /* number of pending requests */ | 371 | int cmds[AZX_MAX_CODECS]; /* number of pending requests */ |
365 | u32 res; /* last read value */ | 372 | u32 res[AZX_MAX_CODECS]; /* last read value */ |
366 | }; | 373 | }; |
367 | 374 | ||
368 | struct azx { | 375 | struct azx { |
@@ -418,7 +425,7 @@ struct azx { | |||
418 | unsigned int probing :1; /* codec probing phase */ | 425 | unsigned int probing :1; /* codec probing phase */ |
419 | 426 | ||
420 | /* for debugging */ | 427 | /* for debugging */ |
421 | unsigned int last_cmd; /* last issued command (to sync) */ | 428 | unsigned int last_cmd[AZX_MAX_CODECS]; |
422 | 429 | ||
423 | /* for pending irqs */ | 430 | /* for pending irqs */ |
424 | struct work_struct irq_pending_work; | 431 | struct work_struct irq_pending_work; |
@@ -513,6 +520,7 @@ static int azx_alloc_cmd_io(struct azx *chip) | |||
513 | 520 | ||
514 | static void azx_init_cmd_io(struct azx *chip) | 521 | static void azx_init_cmd_io(struct azx *chip) |
515 | { | 522 | { |
523 | spin_lock_irq(&chip->reg_lock); | ||
516 | /* CORB set up */ | 524 | /* CORB set up */ |
517 | chip->corb.addr = chip->rb.addr; | 525 | chip->corb.addr = chip->rb.addr; |
518 | chip->corb.buf = (u32 *)chip->rb.area; | 526 | chip->corb.buf = (u32 *)chip->rb.area; |
@@ -531,7 +539,8 @@ static void azx_init_cmd_io(struct azx *chip) | |||
531 | /* RIRB set up */ | 539 | /* RIRB set up */ |
532 | chip->rirb.addr = chip->rb.addr + 2048; | 540 | chip->rirb.addr = chip->rb.addr + 2048; |
533 | chip->rirb.buf = (u32 *)(chip->rb.area + 2048); | 541 | chip->rirb.buf = (u32 *)(chip->rb.area + 2048); |
534 | chip->rirb.wp = chip->rirb.rp = chip->rirb.cmds = 0; | 542 | chip->rirb.wp = chip->rirb.rp = 0; |
543 | memset(chip->rirb.cmds, 0, sizeof(chip->rirb.cmds)); | ||
535 | azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr); | 544 | azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr); |
536 | azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr)); | 545 | azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr)); |
537 | 546 | ||
@@ -543,30 +552,60 @@ static void azx_init_cmd_io(struct azx *chip) | |||
543 | azx_writew(chip, RINTCNT, 1); | 552 | azx_writew(chip, RINTCNT, 1); |
544 | /* enable rirb dma and response irq */ | 553 | /* enable rirb dma and response irq */ |
545 | azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); | 554 | azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); |
555 | spin_unlock_irq(&chip->reg_lock); | ||
546 | } | 556 | } |
547 | 557 | ||
548 | static void azx_free_cmd_io(struct azx *chip) | 558 | static void azx_free_cmd_io(struct azx *chip) |
549 | { | 559 | { |
560 | spin_lock_irq(&chip->reg_lock); | ||
550 | /* disable ringbuffer DMAs */ | 561 | /* disable ringbuffer DMAs */ |
551 | azx_writeb(chip, RIRBCTL, 0); | 562 | azx_writeb(chip, RIRBCTL, 0); |
552 | azx_writeb(chip, CORBCTL, 0); | 563 | azx_writeb(chip, CORBCTL, 0); |
564 | spin_unlock_irq(&chip->reg_lock); | ||
565 | } | ||
566 | |||
567 | static unsigned int azx_command_addr(u32 cmd) | ||
568 | { | ||
569 | unsigned int addr = cmd >> 28; | ||
570 | |||
571 | if (addr >= AZX_MAX_CODECS) { | ||
572 | snd_BUG(); | ||
573 | addr = 0; | ||
574 | } | ||
575 | |||
576 | return addr; | ||
577 | } | ||
578 | |||
579 | static unsigned int azx_response_addr(u32 res) | ||
580 | { | ||
581 | unsigned int addr = res & 0xf; | ||
582 | |||
583 | if (addr >= AZX_MAX_CODECS) { | ||
584 | snd_BUG(); | ||
585 | addr = 0; | ||
586 | } | ||
587 | |||
588 | return addr; | ||
553 | } | 589 | } |
554 | 590 | ||
555 | /* send a command */ | 591 | /* send a command */ |
556 | static int azx_corb_send_cmd(struct hda_bus *bus, u32 val) | 592 | static int azx_corb_send_cmd(struct hda_bus *bus, u32 val) |
557 | { | 593 | { |
558 | struct azx *chip = bus->private_data; | 594 | struct azx *chip = bus->private_data; |
595 | unsigned int addr = azx_command_addr(val); | ||
559 | unsigned int wp; | 596 | unsigned int wp; |
560 | 597 | ||
598 | spin_lock_irq(&chip->reg_lock); | ||
599 | |||
561 | /* add command to corb */ | 600 | /* add command to corb */ |
562 | wp = azx_readb(chip, CORBWP); | 601 | wp = azx_readb(chip, CORBWP); |
563 | wp++; | 602 | wp++; |
564 | wp %= ICH6_MAX_CORB_ENTRIES; | 603 | wp %= ICH6_MAX_CORB_ENTRIES; |
565 | 604 | ||
566 | spin_lock_irq(&chip->reg_lock); | 605 | chip->rirb.cmds[addr]++; |
567 | chip->rirb.cmds++; | ||
568 | chip->corb.buf[wp] = cpu_to_le32(val); | 606 | chip->corb.buf[wp] = cpu_to_le32(val); |
569 | azx_writel(chip, CORBWP, wp); | 607 | azx_writel(chip, CORBWP, wp); |
608 | |||
570 | spin_unlock_irq(&chip->reg_lock); | 609 | spin_unlock_irq(&chip->reg_lock); |
571 | 610 | ||
572 | return 0; | 611 | return 0; |
@@ -578,13 +617,14 @@ static int azx_corb_send_cmd(struct hda_bus *bus, u32 val) | |||
578 | static void azx_update_rirb(struct azx *chip) | 617 | static void azx_update_rirb(struct azx *chip) |
579 | { | 618 | { |
580 | unsigned int rp, wp; | 619 | unsigned int rp, wp; |
620 | unsigned int addr; | ||
581 | u32 res, res_ex; | 621 | u32 res, res_ex; |
582 | 622 | ||
583 | wp = azx_readb(chip, RIRBWP); | 623 | wp = azx_readb(chip, RIRBWP); |
584 | if (wp == chip->rirb.wp) | 624 | if (wp == chip->rirb.wp) |
585 | return; | 625 | return; |
586 | chip->rirb.wp = wp; | 626 | chip->rirb.wp = wp; |
587 | 627 | ||
588 | while (chip->rirb.rp != wp) { | 628 | while (chip->rirb.rp != wp) { |
589 | chip->rirb.rp++; | 629 | chip->rirb.rp++; |
590 | chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES; | 630 | chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES; |
@@ -592,18 +632,24 @@ static void azx_update_rirb(struct azx *chip) | |||
592 | rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */ | 632 | rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */ |
593 | res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]); | 633 | res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]); |
594 | res = le32_to_cpu(chip->rirb.buf[rp]); | 634 | res = le32_to_cpu(chip->rirb.buf[rp]); |
635 | addr = azx_response_addr(res_ex); | ||
595 | if (res_ex & ICH6_RIRB_EX_UNSOL_EV) | 636 | if (res_ex & ICH6_RIRB_EX_UNSOL_EV) |
596 | snd_hda_queue_unsol_event(chip->bus, res, res_ex); | 637 | snd_hda_queue_unsol_event(chip->bus, res, res_ex); |
597 | else if (chip->rirb.cmds) { | 638 | else if (chip->rirb.cmds[addr]) { |
598 | chip->rirb.res = res; | 639 | chip->rirb.res[addr] = res; |
599 | smp_wmb(); | 640 | smp_wmb(); |
600 | chip->rirb.cmds--; | 641 | chip->rirb.cmds[addr]--; |
601 | } | 642 | } else |
643 | snd_printk(KERN_ERR SFX "spurious response %#x:%#x, " | ||
644 | "last cmd=%#08x\n", | ||
645 | res, res_ex, | ||
646 | chip->last_cmd[addr]); | ||
602 | } | 647 | } |
603 | } | 648 | } |
604 | 649 | ||
605 | /* receive a response */ | 650 | /* receive a response */ |
606 | static unsigned int azx_rirb_get_response(struct hda_bus *bus) | 651 | static unsigned int azx_rirb_get_response(struct hda_bus *bus, |
652 | unsigned int addr) | ||
607 | { | 653 | { |
608 | struct azx *chip = bus->private_data; | 654 | struct azx *chip = bus->private_data; |
609 | unsigned long timeout; | 655 | unsigned long timeout; |
@@ -616,10 +662,10 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) | |||
616 | azx_update_rirb(chip); | 662 | azx_update_rirb(chip); |
617 | spin_unlock_irq(&chip->reg_lock); | 663 | spin_unlock_irq(&chip->reg_lock); |
618 | } | 664 | } |
619 | if (!chip->rirb.cmds) { | 665 | if (!chip->rirb.cmds[addr]) { |
620 | smp_rmb(); | 666 | smp_rmb(); |
621 | bus->rirb_error = 0; | 667 | bus->rirb_error = 0; |
622 | return chip->rirb.res; /* the last value */ | 668 | return chip->rirb.res[addr]; /* the last value */ |
623 | } | 669 | } |
624 | if (time_after(jiffies, timeout)) | 670 | if (time_after(jiffies, timeout)) |
625 | break; | 671 | break; |
@@ -633,7 +679,8 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) | |||
633 | 679 | ||
634 | if (chip->msi) { | 680 | if (chip->msi) { |
635 | snd_printk(KERN_WARNING SFX "No response from codec, " | 681 | snd_printk(KERN_WARNING SFX "No response from codec, " |
636 | "disabling MSI: last cmd=0x%08x\n", chip->last_cmd); | 682 | "disabling MSI: last cmd=0x%08x\n", |
683 | chip->last_cmd[addr]); | ||
637 | free_irq(chip->irq, chip); | 684 | free_irq(chip->irq, chip); |
638 | chip->irq = -1; | 685 | chip->irq = -1; |
639 | pci_disable_msi(chip->pci); | 686 | pci_disable_msi(chip->pci); |
@@ -648,7 +695,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) | |||
648 | if (!chip->polling_mode) { | 695 | if (!chip->polling_mode) { |
649 | snd_printk(KERN_WARNING SFX "azx_get_response timeout, " | 696 | snd_printk(KERN_WARNING SFX "azx_get_response timeout, " |
650 | "switching to polling mode: last cmd=0x%08x\n", | 697 | "switching to polling mode: last cmd=0x%08x\n", |
651 | chip->last_cmd); | 698 | chip->last_cmd[addr]); |
652 | chip->polling_mode = 1; | 699 | chip->polling_mode = 1; |
653 | goto again; | 700 | goto again; |
654 | } | 701 | } |
@@ -672,7 +719,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) | |||
672 | 719 | ||
673 | snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " | 720 | snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " |
674 | "switching to single_cmd mode: last cmd=0x%08x\n", | 721 | "switching to single_cmd mode: last cmd=0x%08x\n", |
675 | chip->last_cmd); | 722 | chip->last_cmd[addr]); |
676 | chip->single_cmd = 1; | 723 | chip->single_cmd = 1; |
677 | bus->response_reset = 0; | 724 | bus->response_reset = 0; |
678 | /* re-initialize CORB/RIRB */ | 725 | /* re-initialize CORB/RIRB */ |
@@ -692,7 +739,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) | |||
692 | */ | 739 | */ |
693 | 740 | ||
694 | /* receive a response */ | 741 | /* receive a response */ |
695 | static int azx_single_wait_for_response(struct azx *chip) | 742 | static int azx_single_wait_for_response(struct azx *chip, unsigned int addr) |
696 | { | 743 | { |
697 | int timeout = 50; | 744 | int timeout = 50; |
698 | 745 | ||
@@ -700,7 +747,7 @@ static int azx_single_wait_for_response(struct azx *chip) | |||
700 | /* check IRV busy bit */ | 747 | /* check IRV busy bit */ |
701 | if (azx_readw(chip, IRS) & ICH6_IRS_VALID) { | 748 | if (azx_readw(chip, IRS) & ICH6_IRS_VALID) { |
702 | /* reuse rirb.res as the response return value */ | 749 | /* reuse rirb.res as the response return value */ |
703 | chip->rirb.res = azx_readl(chip, IR); | 750 | chip->rirb.res[addr] = azx_readl(chip, IR); |
704 | return 0; | 751 | return 0; |
705 | } | 752 | } |
706 | udelay(1); | 753 | udelay(1); |
@@ -708,7 +755,7 @@ static int azx_single_wait_for_response(struct azx *chip) | |||
708 | if (printk_ratelimit()) | 755 | if (printk_ratelimit()) |
709 | snd_printd(SFX "get_response timeout: IRS=0x%x\n", | 756 | snd_printd(SFX "get_response timeout: IRS=0x%x\n", |
710 | azx_readw(chip, IRS)); | 757 | azx_readw(chip, IRS)); |
711 | chip->rirb.res = -1; | 758 | chip->rirb.res[addr] = -1; |
712 | return -EIO; | 759 | return -EIO; |
713 | } | 760 | } |
714 | 761 | ||
@@ -716,6 +763,7 @@ static int azx_single_wait_for_response(struct azx *chip) | |||
716 | static int azx_single_send_cmd(struct hda_bus *bus, u32 val) | 763 | static int azx_single_send_cmd(struct hda_bus *bus, u32 val) |
717 | { | 764 | { |
718 | struct azx *chip = bus->private_data; | 765 | struct azx *chip = bus->private_data; |
766 | unsigned int addr = azx_command_addr(val); | ||
719 | int timeout = 50; | 767 | int timeout = 50; |
720 | 768 | ||
721 | bus->rirb_error = 0; | 769 | bus->rirb_error = 0; |
@@ -728,7 +776,7 @@ static int azx_single_send_cmd(struct hda_bus *bus, u32 val) | |||
728 | azx_writel(chip, IC, val); | 776 | azx_writel(chip, IC, val); |
729 | azx_writew(chip, IRS, azx_readw(chip, IRS) | | 777 | azx_writew(chip, IRS, azx_readw(chip, IRS) | |
730 | ICH6_IRS_BUSY); | 778 | ICH6_IRS_BUSY); |
731 | return azx_single_wait_for_response(chip); | 779 | return azx_single_wait_for_response(chip, addr); |
732 | } | 780 | } |
733 | udelay(1); | 781 | udelay(1); |
734 | } | 782 | } |
@@ -739,10 +787,11 @@ static int azx_single_send_cmd(struct hda_bus *bus, u32 val) | |||
739 | } | 787 | } |
740 | 788 | ||
741 | /* receive a response */ | 789 | /* receive a response */ |
742 | static unsigned int azx_single_get_response(struct hda_bus *bus) | 790 | static unsigned int azx_single_get_response(struct hda_bus *bus, |
791 | unsigned int addr) | ||
743 | { | 792 | { |
744 | struct azx *chip = bus->private_data; | 793 | struct azx *chip = bus->private_data; |
745 | return chip->rirb.res; | 794 | return chip->rirb.res[addr]; |
746 | } | 795 | } |
747 | 796 | ||
748 | /* | 797 | /* |
@@ -757,7 +806,7 @@ static int azx_send_cmd(struct hda_bus *bus, unsigned int val) | |||
757 | { | 806 | { |
758 | struct azx *chip = bus->private_data; | 807 | struct azx *chip = bus->private_data; |
759 | 808 | ||
760 | chip->last_cmd = val; | 809 | chip->last_cmd[azx_command_addr(val)] = val; |
761 | if (chip->single_cmd) | 810 | if (chip->single_cmd) |
762 | return azx_single_send_cmd(bus, val); | 811 | return azx_single_send_cmd(bus, val); |
763 | else | 812 | else |
@@ -765,13 +814,14 @@ static int azx_send_cmd(struct hda_bus *bus, unsigned int val) | |||
765 | } | 814 | } |
766 | 815 | ||
767 | /* get a response */ | 816 | /* get a response */ |
768 | static unsigned int azx_get_response(struct hda_bus *bus) | 817 | static unsigned int azx_get_response(struct hda_bus *bus, |
818 | unsigned int addr) | ||
769 | { | 819 | { |
770 | struct azx *chip = bus->private_data; | 820 | struct azx *chip = bus->private_data; |
771 | if (chip->single_cmd) | 821 | if (chip->single_cmd) |
772 | return azx_single_get_response(bus); | 822 | return azx_single_get_response(bus, addr); |
773 | else | 823 | else |
774 | return azx_rirb_get_response(bus); | 824 | return azx_rirb_get_response(bus, addr); |
775 | } | 825 | } |
776 | 826 | ||
777 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 827 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -1243,10 +1293,12 @@ static int probe_codec(struct azx *chip, int addr) | |||
1243 | (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID; | 1293 | (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID; |
1244 | unsigned int res; | 1294 | unsigned int res; |
1245 | 1295 | ||
1296 | mutex_lock(&chip->bus->cmd_mutex); | ||
1246 | chip->probing = 1; | 1297 | chip->probing = 1; |
1247 | azx_send_cmd(chip->bus, cmd); | 1298 | azx_send_cmd(chip->bus, cmd); |
1248 | res = azx_get_response(chip->bus); | 1299 | res = azx_get_response(chip->bus, addr); |
1249 | chip->probing = 0; | 1300 | chip->probing = 0; |
1301 | mutex_unlock(&chip->bus->cmd_mutex); | ||
1250 | if (res == -1) | 1302 | if (res == -1) |
1251 | return -EIO; | 1303 | return -EIO; |
1252 | snd_printdd(SFX "codec #%d probed OK\n", addr); | 1304 | snd_printdd(SFX "codec #%d probed OK\n", addr); |
@@ -1286,8 +1338,7 @@ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = { | |||
1286 | [AZX_DRIVER_TERA] = 1, | 1338 | [AZX_DRIVER_TERA] = 1, |
1287 | }; | 1339 | }; |
1288 | 1340 | ||
1289 | static int __devinit azx_codec_create(struct azx *chip, const char *model, | 1341 | static int __devinit azx_codec_create(struct azx *chip, const char *model) |
1290 | int no_init) | ||
1291 | { | 1342 | { |
1292 | struct hda_bus_template bus_temp; | 1343 | struct hda_bus_template bus_temp; |
1293 | int c, codecs, err; | 1344 | int c, codecs, err; |
@@ -1346,7 +1397,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model, | |||
1346 | for (c = 0; c < max_slots; c++) { | 1397 | for (c = 0; c < max_slots; c++) { |
1347 | if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) { | 1398 | if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) { |
1348 | struct hda_codec *codec; | 1399 | struct hda_codec *codec; |
1349 | err = snd_hda_codec_new(chip->bus, c, !no_init, &codec); | 1400 | err = snd_hda_codec_new(chip->bus, c, &codec); |
1350 | if (err < 0) | 1401 | if (err < 0) |
1351 | continue; | 1402 | continue; |
1352 | codecs++; | 1403 | codecs++; |
@@ -1356,7 +1407,16 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model, | |||
1356 | snd_printk(KERN_ERR SFX "no codecs initialized\n"); | 1407 | snd_printk(KERN_ERR SFX "no codecs initialized\n"); |
1357 | return -ENXIO; | 1408 | return -ENXIO; |
1358 | } | 1409 | } |
1410 | return 0; | ||
1411 | } | ||
1359 | 1412 | ||
1413 | /* configure each codec instance */ | ||
1414 | static int __devinit azx_codec_configure(struct azx *chip) | ||
1415 | { | ||
1416 | struct hda_codec *codec; | ||
1417 | list_for_each_entry(codec, &chip->bus->codec_list, list) { | ||
1418 | snd_hda_codec_configure(codec); | ||
1419 | } | ||
1360 | return 0; | 1420 | return 0; |
1361 | } | 1421 | } |
1362 | 1422 | ||
@@ -1454,6 +1514,18 @@ static int azx_pcm_open(struct snd_pcm_substream *substream) | |||
1454 | mutex_unlock(&chip->open_mutex); | 1514 | mutex_unlock(&chip->open_mutex); |
1455 | return err; | 1515 | return err; |
1456 | } | 1516 | } |
1517 | snd_pcm_limit_hw_rates(runtime); | ||
1518 | /* sanity check */ | ||
1519 | if (snd_BUG_ON(!runtime->hw.channels_min) || | ||
1520 | snd_BUG_ON(!runtime->hw.channels_max) || | ||
1521 | snd_BUG_ON(!runtime->hw.formats) || | ||
1522 | snd_BUG_ON(!runtime->hw.rates)) { | ||
1523 | azx_release_device(azx_dev); | ||
1524 | hinfo->ops.close(hinfo, apcm->codec, substream); | ||
1525 | snd_hda_power_down(apcm->codec); | ||
1526 | mutex_unlock(&chip->open_mutex); | ||
1527 | return -EINVAL; | ||
1528 | } | ||
1457 | spin_lock_irqsave(&chip->reg_lock, flags); | 1529 | spin_lock_irqsave(&chip->reg_lock, flags); |
1458 | azx_dev->substream = substream; | 1530 | azx_dev->substream = substream; |
1459 | azx_dev->running = 0; | 1531 | azx_dev->running = 0; |
@@ -1462,7 +1534,6 @@ static int azx_pcm_open(struct snd_pcm_substream *substream) | |||
1462 | runtime->private_data = azx_dev; | 1534 | runtime->private_data = azx_dev; |
1463 | snd_pcm_set_sync(substream); | 1535 | snd_pcm_set_sync(substream); |
1464 | mutex_unlock(&chip->open_mutex); | 1536 | mutex_unlock(&chip->open_mutex); |
1465 | |||
1466 | return 0; | 1537 | return 0; |
1467 | } | 1538 | } |
1468 | 1539 | ||
@@ -2228,6 +2299,30 @@ static void __devinit check_probe_mask(struct azx *chip, int dev) | |||
2228 | } | 2299 | } |
2229 | } | 2300 | } |
2230 | 2301 | ||
2302 | /* | ||
2303 | * white-list for enable_msi | ||
2304 | */ | ||
2305 | static struct snd_pci_quirk msi_white_list[] __devinitdata = { | ||
2306 | SND_PCI_QUIRK(0x103c, 0x3607, "HP Compa CQ40", 1), | ||
2307 | {} | ||
2308 | }; | ||
2309 | |||
2310 | static void __devinit check_msi(struct azx *chip) | ||
2311 | { | ||
2312 | const struct snd_pci_quirk *q; | ||
2313 | |||
2314 | chip->msi = enable_msi; | ||
2315 | if (chip->msi) | ||
2316 | return; | ||
2317 | q = snd_pci_quirk_lookup(chip->pci, msi_white_list); | ||
2318 | if (q) { | ||
2319 | printk(KERN_INFO | ||
2320 | "hda_intel: msi for device %04x:%04x set to %d\n", | ||
2321 | q->subvendor, q->subdevice, q->value); | ||
2322 | chip->msi = q->value; | ||
2323 | } | ||
2324 | } | ||
2325 | |||
2231 | 2326 | ||
2232 | /* | 2327 | /* |
2233 | * constructor | 2328 | * constructor |
@@ -2262,7 +2357,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
2262 | chip->pci = pci; | 2357 | chip->pci = pci; |
2263 | chip->irq = -1; | 2358 | chip->irq = -1; |
2264 | chip->driver_type = driver_type; | 2359 | chip->driver_type = driver_type; |
2265 | chip->msi = enable_msi; | 2360 | check_msi(chip); |
2266 | chip->dev_index = dev; | 2361 | chip->dev_index = dev; |
2267 | INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); | 2362 | INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); |
2268 | 2363 | ||
@@ -2322,9 +2417,19 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
2322 | gcap = azx_readw(chip, GCAP); | 2417 | gcap = azx_readw(chip, GCAP); |
2323 | snd_printdd(SFX "chipset global capabilities = 0x%x\n", gcap); | 2418 | snd_printdd(SFX "chipset global capabilities = 0x%x\n", gcap); |
2324 | 2419 | ||
2325 | /* ATI chips seems buggy about 64bit DMA addresses */ | 2420 | /* disable SB600 64bit support for safety */ |
2326 | if (chip->driver_type == AZX_DRIVER_ATI) | 2421 | if ((chip->driver_type == AZX_DRIVER_ATI) || |
2327 | gcap &= ~ICH6_GCAP_64OK; | 2422 | (chip->driver_type == AZX_DRIVER_ATIHDMI)) { |
2423 | struct pci_dev *p_smbus; | ||
2424 | p_smbus = pci_get_device(PCI_VENDOR_ID_ATI, | ||
2425 | PCI_DEVICE_ID_ATI_SBX00_SMBUS, | ||
2426 | NULL); | ||
2427 | if (p_smbus) { | ||
2428 | if (p_smbus->revision < 0x30) | ||
2429 | gcap &= ~ICH6_GCAP_64OK; | ||
2430 | pci_dev_put(p_smbus); | ||
2431 | } | ||
2432 | } | ||
2328 | 2433 | ||
2329 | /* allow 64bit DMA address if supported by H/W */ | 2434 | /* allow 64bit DMA address if supported by H/W */ |
2330 | if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) | 2435 | if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) |
@@ -2460,15 +2565,32 @@ static int __devinit azx_probe(struct pci_dev *pci, | |||
2460 | return err; | 2565 | return err; |
2461 | } | 2566 | } |
2462 | 2567 | ||
2568 | /* set this here since it's referred in snd_hda_load_patch() */ | ||
2569 | snd_card_set_dev(card, &pci->dev); | ||
2570 | |||
2463 | err = azx_create(card, pci, dev, pci_id->driver_data, &chip); | 2571 | err = azx_create(card, pci, dev, pci_id->driver_data, &chip); |
2464 | if (err < 0) | 2572 | if (err < 0) |
2465 | goto out_free; | 2573 | goto out_free; |
2466 | card->private_data = chip; | 2574 | card->private_data = chip; |
2467 | 2575 | ||
2468 | /* create codec instances */ | 2576 | /* create codec instances */ |
2469 | err = azx_codec_create(chip, model[dev], probe_only[dev]); | 2577 | err = azx_codec_create(chip, model[dev]); |
2470 | if (err < 0) | 2578 | if (err < 0) |
2471 | goto out_free; | 2579 | goto out_free; |
2580 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | ||
2581 | if (patch[dev]) { | ||
2582 | snd_printk(KERN_ERR SFX "Applying patch firmware '%s'\n", | ||
2583 | patch[dev]); | ||
2584 | err = snd_hda_load_patch(chip->bus, patch[dev]); | ||
2585 | if (err < 0) | ||
2586 | goto out_free; | ||
2587 | } | ||
2588 | #endif | ||
2589 | if (!probe_only[dev]) { | ||
2590 | err = azx_codec_configure(chip); | ||
2591 | if (err < 0) | ||
2592 | goto out_free; | ||
2593 | } | ||
2472 | 2594 | ||
2473 | /* create PCM streams */ | 2595 | /* create PCM streams */ |
2474 | err = snd_hda_build_pcms(chip->bus); | 2596 | err = snd_hda_build_pcms(chip->bus); |
@@ -2480,8 +2602,6 @@ static int __devinit azx_probe(struct pci_dev *pci, | |||
2480 | if (err < 0) | 2602 | if (err < 0) |
2481 | goto out_free; | 2603 | goto out_free; |
2482 | 2604 | ||
2483 | snd_card_set_dev(card, &pci->dev); | ||
2484 | |||
2485 | err = snd_card_register(card); | 2605 | err = snd_card_register(card); |
2486 | if (err < 0) | 2606 | if (err < 0) |
2487 | goto out_free; | 2607 | goto out_free; |
@@ -2583,11 +2703,15 @@ static struct pci_device_id azx_ids[] = { | |||
2583 | /* this entry seems still valid -- i.e. without emu20kx chip */ | 2703 | /* this entry seems still valid -- i.e. without emu20kx chip */ |
2584 | { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_GENERIC }, | 2704 | { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_GENERIC }, |
2585 | #endif | 2705 | #endif |
2586 | /* AMD Generic, PCI class code and Vendor ID for HD Audio */ | 2706 | /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */ |
2587 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID), | 2707 | { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID), |
2588 | .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, | 2708 | .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, |
2589 | .class_mask = 0xffffff, | 2709 | .class_mask = 0xffffff, |
2590 | .driver_data = AZX_DRIVER_GENERIC }, | 2710 | .driver_data = AZX_DRIVER_GENERIC }, |
2711 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_ANY_ID), | ||
2712 | .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, | ||
2713 | .class_mask = 0xffffff, | ||
2714 | .driver_data = AZX_DRIVER_GENERIC }, | ||
2591 | { 0, } | 2715 | { 0, } |
2592 | }; | 2716 | }; |
2593 | MODULE_DEVICE_TABLE(pci, azx_ids); | 2717 | MODULE_DEVICE_TABLE(pci, azx_ids); |
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 83349013b4df..5f1dcc59002b 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -99,7 +99,6 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, | |||
99 | int snd_hda_add_vmaster(struct hda_codec *codec, char *name, | 99 | int snd_hda_add_vmaster(struct hda_codec *codec, char *name, |
100 | unsigned int *tlv, const char **slaves); | 100 | unsigned int *tlv, const char **slaves); |
101 | int snd_hda_codec_reset(struct hda_codec *codec); | 101 | int snd_hda_codec_reset(struct hda_codec *codec); |
102 | int snd_hda_codec_configure(struct hda_codec *codec); | ||
103 | 102 | ||
104 | /* amp value bits */ | 103 | /* amp value bits */ |
105 | #define HDA_AMP_MUTE 0x80 | 104 | #define HDA_AMP_MUTE 0x80 |
@@ -408,6 +407,19 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid) | |||
408 | return codec->wcaps[nid - codec->start_nid]; | 407 | return codec->wcaps[nid - codec->start_nid]; |
409 | } | 408 | } |
410 | 409 | ||
410 | /* get the widget type from widget capability bits */ | ||
411 | #define get_wcaps_type(wcaps) (((wcaps) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT) | ||
412 | |||
413 | static inline unsigned int get_wcaps_channels(u32 wcaps) | ||
414 | { | ||
415 | unsigned int chans; | ||
416 | |||
417 | chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13; | ||
418 | chans = ((chans << 1) | 1) + 1; | ||
419 | |||
420 | return chans; | ||
421 | } | ||
422 | |||
411 | u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); | 423 | u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); |
412 | int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, | 424 | int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, |
413 | unsigned int caps); | 425 | unsigned int caps); |
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 418c5d1badaa..95f24e4729f8 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c | |||
@@ -508,17 +508,14 @@ static void print_codec_info(struct snd_info_entry *entry, | |||
508 | unsigned int wid_caps = | 508 | unsigned int wid_caps = |
509 | snd_hda_param_read(codec, nid, | 509 | snd_hda_param_read(codec, nid, |
510 | AC_PAR_AUDIO_WIDGET_CAP); | 510 | AC_PAR_AUDIO_WIDGET_CAP); |
511 | unsigned int wid_type = | 511 | unsigned int wid_type = get_wcaps_type(wid_caps); |
512 | (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
513 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; | 512 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
514 | int conn_len = 0; | 513 | int conn_len = 0; |
515 | 514 | ||
516 | snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, | 515 | snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, |
517 | get_wid_type_name(wid_type), wid_caps); | 516 | get_wid_type_name(wid_type), wid_caps); |
518 | if (wid_caps & AC_WCAP_STEREO) { | 517 | if (wid_caps & AC_WCAP_STEREO) { |
519 | unsigned int chans; | 518 | unsigned int chans = get_wcaps_channels(wid_caps); |
520 | chans = (wid_caps & AC_WCAP_CHAN_CNT_EXT) >> 13; | ||
521 | chans = ((chans << 1) | 1) + 1; | ||
522 | if (chans == 2) | 519 | if (chans == 2) |
523 | snd_iprintf(buffer, " Stereo"); | 520 | snd_iprintf(buffer, " Stereo"); |
524 | else | 521 | else |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 84cc49ca9148..215e72a87113 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -72,6 +72,7 @@ struct ad198x_spec { | |||
72 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; | 72 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
73 | 73 | ||
74 | unsigned int jack_present :1; | 74 | unsigned int jack_present :1; |
75 | unsigned int inv_jack_detect:1; | ||
75 | 76 | ||
76 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 77 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
77 | struct hda_loopback_check loopback; | 78 | struct hda_loopback_check loopback; |
@@ -669,39 +670,13 @@ static struct hda_input_mux ad1986a_automic_capture_source = { | |||
669 | }, | 670 | }, |
670 | }; | 671 | }; |
671 | 672 | ||
672 | static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { | 673 | static struct snd_kcontrol_new ad1986a_laptop_master_mixers[] = { |
673 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), | 674 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), |
674 | HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), | 675 | HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), |
675 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), | ||
676 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), | ||
677 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT), | ||
678 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT), | ||
679 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), | ||
680 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), | ||
681 | HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), | ||
682 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), | ||
683 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), | ||
684 | { | ||
685 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
686 | .name = "Capture Source", | ||
687 | .info = ad198x_mux_enum_info, | ||
688 | .get = ad198x_mux_enum_get, | ||
689 | .put = ad198x_mux_enum_put, | ||
690 | }, | ||
691 | { | ||
692 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
693 | .name = "External Amplifier", | ||
694 | .info = ad198x_eapd_info, | ||
695 | .get = ad198x_eapd_get, | ||
696 | .put = ad198x_eapd_put, | ||
697 | .private_value = 0x1b | (1 << 8), /* port-D, inversed */ | ||
698 | }, | ||
699 | { } /* end */ | 676 | { } /* end */ |
700 | }; | 677 | }; |
701 | 678 | ||
702 | static struct snd_kcontrol_new ad1986a_samsung_mixers[] = { | 679 | static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { |
703 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), | ||
704 | HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw), | ||
705 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), | 680 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), |
706 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), | 681 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), |
707 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), | 682 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), |
@@ -727,6 +702,12 @@ static struct snd_kcontrol_new ad1986a_samsung_mixers[] = { | |||
727 | { } /* end */ | 702 | { } /* end */ |
728 | }; | 703 | }; |
729 | 704 | ||
705 | static struct snd_kcontrol_new ad1986a_laptop_intmic_mixers[] = { | ||
706 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT), | ||
707 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT), | ||
708 | { } /* end */ | ||
709 | }; | ||
710 | |||
730 | /* re-connect the mic boost input according to the jack sensing */ | 711 | /* re-connect the mic boost input according to the jack sensing */ |
731 | static void ad1986a_automic(struct hda_codec *codec) | 712 | static void ad1986a_automic(struct hda_codec *codec) |
732 | { | 713 | { |
@@ -776,8 +757,9 @@ static void ad1986a_hp_automute(struct hda_codec *codec) | |||
776 | unsigned int present; | 757 | unsigned int present; |
777 | 758 | ||
778 | present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0); | 759 | present = snd_hda_codec_read(codec, 0x1a, 0, AC_VERB_GET_PIN_SENSE, 0); |
779 | /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */ | 760 | spec->jack_present = !!(present & 0x80000000); |
780 | spec->jack_present = !(present & 0x80000000); | 761 | if (spec->inv_jack_detect) |
762 | spec->jack_present = !spec->jack_present; | ||
781 | ad1986a_update_hp(codec); | 763 | ad1986a_update_hp(codec); |
782 | } | 764 | } |
783 | 765 | ||
@@ -816,7 +798,7 @@ static int ad1986a_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |||
816 | return change; | 798 | return change; |
817 | } | 799 | } |
818 | 800 | ||
819 | static struct snd_kcontrol_new ad1986a_laptop_automute_mixers[] = { | 801 | static struct snd_kcontrol_new ad1986a_automute_master_mixers[] = { |
820 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), | 802 | HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol), |
821 | { | 803 | { |
822 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 804 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
@@ -826,33 +808,10 @@ static struct snd_kcontrol_new ad1986a_laptop_automute_mixers[] = { | |||
826 | .put = ad1986a_hp_master_sw_put, | 808 | .put = ad1986a_hp_master_sw_put, |
827 | .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), | 809 | .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT), |
828 | }, | 810 | }, |
829 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT), | ||
830 | HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), | ||
831 | HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x0, HDA_OUTPUT), | ||
832 | HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x0, HDA_OUTPUT), | ||
833 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), | ||
834 | HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), | ||
835 | HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), | ||
836 | HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), | ||
837 | HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), | ||
838 | { | ||
839 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
840 | .name = "Capture Source", | ||
841 | .info = ad198x_mux_enum_info, | ||
842 | .get = ad198x_mux_enum_get, | ||
843 | .put = ad198x_mux_enum_put, | ||
844 | }, | ||
845 | { | ||
846 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
847 | .name = "External Amplifier", | ||
848 | .info = ad198x_eapd_info, | ||
849 | .get = ad198x_eapd_get, | ||
850 | .put = ad198x_eapd_put, | ||
851 | .private_value = 0x1b | (1 << 8), /* port-D, inversed */ | ||
852 | }, | ||
853 | { } /* end */ | 811 | { } /* end */ |
854 | }; | 812 | }; |
855 | 813 | ||
814 | |||
856 | /* | 815 | /* |
857 | * initialization verbs | 816 | * initialization verbs |
858 | */ | 817 | */ |
@@ -981,6 +940,27 @@ static struct hda_verb ad1986a_hp_init_verbs[] = { | |||
981 | {} | 940 | {} |
982 | }; | 941 | }; |
983 | 942 | ||
943 | static void ad1986a_samsung_p50_unsol_event(struct hda_codec *codec, | ||
944 | unsigned int res) | ||
945 | { | ||
946 | switch (res >> 26) { | ||
947 | case AD1986A_HP_EVENT: | ||
948 | ad1986a_hp_automute(codec); | ||
949 | break; | ||
950 | case AD1986A_MIC_EVENT: | ||
951 | ad1986a_automic(codec); | ||
952 | break; | ||
953 | } | ||
954 | } | ||
955 | |||
956 | static int ad1986a_samsung_p50_init(struct hda_codec *codec) | ||
957 | { | ||
958 | ad198x_init(codec); | ||
959 | ad1986a_hp_automute(codec); | ||
960 | ad1986a_automic(codec); | ||
961 | return 0; | ||
962 | } | ||
963 | |||
984 | 964 | ||
985 | /* models */ | 965 | /* models */ |
986 | enum { | 966 | enum { |
@@ -991,6 +971,7 @@ enum { | |||
991 | AD1986A_LAPTOP_AUTOMUTE, | 971 | AD1986A_LAPTOP_AUTOMUTE, |
992 | AD1986A_ULTRA, | 972 | AD1986A_ULTRA, |
993 | AD1986A_SAMSUNG, | 973 | AD1986A_SAMSUNG, |
974 | AD1986A_SAMSUNG_P50, | ||
994 | AD1986A_MODELS | 975 | AD1986A_MODELS |
995 | }; | 976 | }; |
996 | 977 | ||
@@ -1002,6 +983,7 @@ static const char *ad1986a_models[AD1986A_MODELS] = { | |||
1002 | [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute", | 983 | [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute", |
1003 | [AD1986A_ULTRA] = "ultra", | 984 | [AD1986A_ULTRA] = "ultra", |
1004 | [AD1986A_SAMSUNG] = "samsung", | 985 | [AD1986A_SAMSUNG] = "samsung", |
986 | [AD1986A_SAMSUNG_P50] = "samsung-p50", | ||
1005 | }; | 987 | }; |
1006 | 988 | ||
1007 | static struct snd_pci_quirk ad1986a_cfg_tbl[] = { | 989 | static struct snd_pci_quirk ad1986a_cfg_tbl[] = { |
@@ -1024,6 +1006,7 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = { | |||
1024 | SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD), | 1006 | SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD), |
1025 | SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), | 1007 | SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), |
1026 | SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), | 1008 | SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), |
1009 | SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50), | ||
1027 | SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA), | 1010 | SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA), |
1028 | SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG), | 1011 | SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG), |
1029 | SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK), | 1012 | SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK), |
@@ -1111,7 +1094,10 @@ static int patch_ad1986a(struct hda_codec *codec) | |||
1111 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; | 1094 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; |
1112 | break; | 1095 | break; |
1113 | case AD1986A_LAPTOP_EAPD: | 1096 | case AD1986A_LAPTOP_EAPD: |
1114 | spec->mixers[0] = ad1986a_laptop_eapd_mixers; | 1097 | spec->num_mixers = 3; |
1098 | spec->mixers[0] = ad1986a_laptop_master_mixers; | ||
1099 | spec->mixers[1] = ad1986a_laptop_eapd_mixers; | ||
1100 | spec->mixers[2] = ad1986a_laptop_intmic_mixers; | ||
1115 | spec->num_init_verbs = 2; | 1101 | spec->num_init_verbs = 2; |
1116 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; | 1102 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
1117 | spec->multiout.max_channels = 2; | 1103 | spec->multiout.max_channels = 2; |
@@ -1122,7 +1108,9 @@ static int patch_ad1986a(struct hda_codec *codec) | |||
1122 | spec->input_mux = &ad1986a_laptop_eapd_capture_source; | 1108 | spec->input_mux = &ad1986a_laptop_eapd_capture_source; |
1123 | break; | 1109 | break; |
1124 | case AD1986A_SAMSUNG: | 1110 | case AD1986A_SAMSUNG: |
1125 | spec->mixers[0] = ad1986a_samsung_mixers; | 1111 | spec->num_mixers = 2; |
1112 | spec->mixers[0] = ad1986a_laptop_master_mixers; | ||
1113 | spec->mixers[1] = ad1986a_laptop_eapd_mixers; | ||
1126 | spec->num_init_verbs = 3; | 1114 | spec->num_init_verbs = 3; |
1127 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; | 1115 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
1128 | spec->init_verbs[2] = ad1986a_automic_verbs; | 1116 | spec->init_verbs[2] = ad1986a_automic_verbs; |
@@ -1135,8 +1123,28 @@ static int patch_ad1986a(struct hda_codec *codec) | |||
1135 | codec->patch_ops.unsol_event = ad1986a_automic_unsol_event; | 1123 | codec->patch_ops.unsol_event = ad1986a_automic_unsol_event; |
1136 | codec->patch_ops.init = ad1986a_automic_init; | 1124 | codec->patch_ops.init = ad1986a_automic_init; |
1137 | break; | 1125 | break; |
1126 | case AD1986A_SAMSUNG_P50: | ||
1127 | spec->num_mixers = 2; | ||
1128 | spec->mixers[0] = ad1986a_automute_master_mixers; | ||
1129 | spec->mixers[1] = ad1986a_laptop_eapd_mixers; | ||
1130 | spec->num_init_verbs = 4; | ||
1131 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; | ||
1132 | spec->init_verbs[2] = ad1986a_automic_verbs; | ||
1133 | spec->init_verbs[3] = ad1986a_hp_init_verbs; | ||
1134 | spec->multiout.max_channels = 2; | ||
1135 | spec->multiout.num_dacs = 1; | ||
1136 | spec->multiout.dac_nids = ad1986a_laptop_dac_nids; | ||
1137 | if (!is_jack_available(codec, 0x25)) | ||
1138 | spec->multiout.dig_out_nid = 0; | ||
1139 | spec->input_mux = &ad1986a_automic_capture_source; | ||
1140 | codec->patch_ops.unsol_event = ad1986a_samsung_p50_unsol_event; | ||
1141 | codec->patch_ops.init = ad1986a_samsung_p50_init; | ||
1142 | break; | ||
1138 | case AD1986A_LAPTOP_AUTOMUTE: | 1143 | case AD1986A_LAPTOP_AUTOMUTE: |
1139 | spec->mixers[0] = ad1986a_laptop_automute_mixers; | 1144 | spec->num_mixers = 3; |
1145 | spec->mixers[0] = ad1986a_automute_master_mixers; | ||
1146 | spec->mixers[1] = ad1986a_laptop_eapd_mixers; | ||
1147 | spec->mixers[2] = ad1986a_laptop_intmic_mixers; | ||
1140 | spec->num_init_verbs = 3; | 1148 | spec->num_init_verbs = 3; |
1141 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; | 1149 | spec->init_verbs[1] = ad1986a_eapd_init_verbs; |
1142 | spec->init_verbs[2] = ad1986a_hp_init_verbs; | 1150 | spec->init_verbs[2] = ad1986a_hp_init_verbs; |
@@ -1148,6 +1156,10 @@ static int patch_ad1986a(struct hda_codec *codec) | |||
1148 | spec->input_mux = &ad1986a_laptop_eapd_capture_source; | 1156 | spec->input_mux = &ad1986a_laptop_eapd_capture_source; |
1149 | codec->patch_ops.unsol_event = ad1986a_hp_unsol_event; | 1157 | codec->patch_ops.unsol_event = ad1986a_hp_unsol_event; |
1150 | codec->patch_ops.init = ad1986a_hp_init; | 1158 | codec->patch_ops.init = ad1986a_hp_init; |
1159 | /* Lenovo N100 seems to report the reversed bit | ||
1160 | * for HP jack-sensing | ||
1161 | */ | ||
1162 | spec->inv_jack_detect = 1; | ||
1151 | break; | 1163 | break; |
1152 | case AD1986A_ULTRA: | 1164 | case AD1986A_ULTRA: |
1153 | spec->mixers[0] = ad1986a_laptop_eapd_mixers; | 1165 | spec->mixers[0] = ad1986a_laptop_eapd_mixers; |
@@ -2970,7 +2982,8 @@ static int patch_ad1988(struct hda_codec *codec) | |||
2970 | board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST, | 2982 | board_config = snd_hda_check_board_config(codec, AD1988_MODEL_LAST, |
2971 | ad1988_models, ad1988_cfg_tbl); | 2983 | ad1988_models, ad1988_cfg_tbl); |
2972 | if (board_config < 0) { | 2984 | if (board_config < 0) { |
2973 | printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n"); | 2985 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
2986 | codec->chip_name); | ||
2974 | board_config = AD1988_AUTO; | 2987 | board_config = AD1988_AUTO; |
2975 | } | 2988 | } |
2976 | 2989 | ||
@@ -3690,19 +3703,29 @@ static struct hda_amp_list ad1884a_loopbacks[] = { | |||
3690 | * Port F: Internal speakers | 3703 | * Port F: Internal speakers |
3691 | */ | 3704 | */ |
3692 | 3705 | ||
3693 | static struct hda_input_mux ad1884a_laptop_capture_source = { | 3706 | static int ad1884a_mobile_master_sw_put(struct snd_kcontrol *kcontrol, |
3694 | .num_items = 4, | 3707 | struct snd_ctl_elem_value *ucontrol) |
3695 | .items = { | 3708 | { |
3696 | { "Mic", 0x0 }, /* port-B */ | 3709 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
3697 | { "Internal Mic", 0x1 }, /* port-C */ | 3710 | int ret = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); |
3698 | { "Dock Mic", 0x4 }, /* port-E */ | 3711 | int mute = (!ucontrol->value.integer.value[0] && |
3699 | { "Mix", 0x3 }, | 3712 | !ucontrol->value.integer.value[1]); |
3700 | }, | 3713 | /* toggle GPIO1 according to the mute state */ |
3701 | }; | 3714 | snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
3715 | mute ? 0x02 : 0x0); | ||
3716 | return ret; | ||
3717 | } | ||
3702 | 3718 | ||
3703 | static struct snd_kcontrol_new ad1884a_laptop_mixers[] = { | 3719 | static struct snd_kcontrol_new ad1884a_laptop_mixers[] = { |
3704 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), | 3720 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
3705 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), | 3721 | { |
3722 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
3723 | .name = "Master Playback Switch", | ||
3724 | .info = snd_hda_mixer_amp_switch_info, | ||
3725 | .get = snd_hda_mixer_amp_switch_get, | ||
3726 | .put = ad1884a_mobile_master_sw_put, | ||
3727 | .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | ||
3728 | }, | ||
3706 | HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT), | 3729 | HDA_CODEC_MUTE("Dock Playback Switch", 0x12, 0x0, HDA_OUTPUT), |
3707 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), | 3730 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
3708 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), | 3731 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
@@ -3717,26 +3740,20 @@ static struct snd_kcontrol_new ad1884a_laptop_mixers[] = { | |||
3717 | HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT), | 3740 | HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT), |
3718 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), | 3741 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), |
3719 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), | 3742 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), |
3720 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), | ||
3721 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), | ||
3722 | { | ||
3723 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
3724 | /* The multiple "Capture Source" controls confuse alsamixer | ||
3725 | * So call somewhat different.. | ||
3726 | */ | ||
3727 | /* .name = "Capture Source", */ | ||
3728 | .name = "Input Source", | ||
3729 | .count = 2, | ||
3730 | .info = ad198x_mux_enum_info, | ||
3731 | .get = ad198x_mux_enum_get, | ||
3732 | .put = ad198x_mux_enum_put, | ||
3733 | }, | ||
3734 | { } /* end */ | 3743 | { } /* end */ |
3735 | }; | 3744 | }; |
3736 | 3745 | ||
3737 | static struct snd_kcontrol_new ad1884a_mobile_mixers[] = { | 3746 | static struct snd_kcontrol_new ad1884a_mobile_mixers[] = { |
3738 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), | 3747 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), |
3739 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), | 3748 | /*HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/ |
3749 | { | ||
3750 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
3751 | .name = "Master Playback Switch", | ||
3752 | .info = snd_hda_mixer_amp_switch_info, | ||
3753 | .get = snd_hda_mixer_amp_switch_get, | ||
3754 | .put = ad1884a_mobile_master_sw_put, | ||
3755 | .private_value = HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | ||
3756 | }, | ||
3740 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), | 3757 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), |
3741 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), | 3758 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), |
3742 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT), | 3759 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT), |
@@ -3795,6 +3812,63 @@ static int ad1884a_hp_init(struct hda_codec *codec) | |||
3795 | return 0; | 3812 | return 0; |
3796 | } | 3813 | } |
3797 | 3814 | ||
3815 | /* mute internal speaker if HP or docking HP is plugged */ | ||
3816 | static void ad1884a_laptop_automute(struct hda_codec *codec) | ||
3817 | { | ||
3818 | unsigned int present; | ||
3819 | |||
3820 | present = snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0); | ||
3821 | present &= AC_PINSENSE_PRESENCE; | ||
3822 | if (!present) { | ||
3823 | present = snd_hda_codec_read(codec, 0x12, 0, | ||
3824 | AC_VERB_GET_PIN_SENSE, 0); | ||
3825 | present &= AC_PINSENSE_PRESENCE; | ||
3826 | } | ||
3827 | snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0, | ||
3828 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
3829 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_EAPD_BTLENABLE, | ||
3830 | present ? 0x00 : 0x02); | ||
3831 | } | ||
3832 | |||
3833 | /* switch to external mic if plugged */ | ||
3834 | static void ad1884a_laptop_automic(struct hda_codec *codec) | ||
3835 | { | ||
3836 | unsigned int idx; | ||
3837 | |||
3838 | if (snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0) & | ||
3839 | AC_PINSENSE_PRESENCE) | ||
3840 | idx = 0; | ||
3841 | else if (snd_hda_codec_read(codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) & | ||
3842 | AC_PINSENSE_PRESENCE) | ||
3843 | idx = 4; | ||
3844 | else | ||
3845 | idx = 1; | ||
3846 | snd_hda_codec_write(codec, 0x0c, 0, AC_VERB_SET_CONNECT_SEL, idx); | ||
3847 | } | ||
3848 | |||
3849 | /* unsolicited event for HP jack sensing */ | ||
3850 | static void ad1884a_laptop_unsol_event(struct hda_codec *codec, | ||
3851 | unsigned int res) | ||
3852 | { | ||
3853 | switch (res >> 26) { | ||
3854 | case AD1884A_HP_EVENT: | ||
3855 | ad1884a_laptop_automute(codec); | ||
3856 | break; | ||
3857 | case AD1884A_MIC_EVENT: | ||
3858 | ad1884a_laptop_automic(codec); | ||
3859 | break; | ||
3860 | } | ||
3861 | } | ||
3862 | |||
3863 | /* initialize jack-sensing, too */ | ||
3864 | static int ad1884a_laptop_init(struct hda_codec *codec) | ||
3865 | { | ||
3866 | ad198x_init(codec); | ||
3867 | ad1884a_laptop_automute(codec); | ||
3868 | ad1884a_laptop_automic(codec); | ||
3869 | return 0; | ||
3870 | } | ||
3871 | |||
3798 | /* additional verbs for laptop model */ | 3872 | /* additional verbs for laptop model */ |
3799 | static struct hda_verb ad1884a_laptop_verbs[] = { | 3873 | static struct hda_verb ad1884a_laptop_verbs[] = { |
3800 | /* Port-A (HP) pin - always unmuted */ | 3874 | /* Port-A (HP) pin - always unmuted */ |
@@ -3802,18 +3876,28 @@ static struct hda_verb ad1884a_laptop_verbs[] = { | |||
3802 | /* Port-F (int speaker) mixer - route only from analog mixer */ | 3876 | /* Port-F (int speaker) mixer - route only from analog mixer */ |
3803 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 3877 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
3804 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 3878 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
3805 | /* Port-F pin */ | 3879 | /* Port-F (int speaker) pin */ |
3806 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | 3880 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
3807 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | 3881 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, |
3882 | /* required for compaq 6530s/6531s speaker output */ | ||
3883 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
3808 | /* Port-C pin - internal mic-in */ | 3884 | /* Port-C pin - internal mic-in */ |
3809 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 3885 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
3810 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ | 3886 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
3811 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ | 3887 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ |
3888 | /* Port-D (docking line-out) pin - default unmuted */ | ||
3889 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
3812 | /* analog mix */ | 3890 | /* analog mix */ |
3813 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | 3891 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
3814 | /* unsolicited event for pin-sense */ | 3892 | /* unsolicited event for pin-sense */ |
3815 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, | 3893 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
3894 | {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, | ||
3816 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, | 3895 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, |
3896 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, | ||
3897 | /* allow to touch GPIO1 (for mute control) */ | ||
3898 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | ||
3899 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | ||
3900 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */ | ||
3817 | { } /* end */ | 3901 | { } /* end */ |
3818 | }; | 3902 | }; |
3819 | 3903 | ||
@@ -3857,6 +3941,10 @@ static struct hda_verb ad1884a_mobile_verbs[] = { | |||
3857 | /* unsolicited event for pin-sense */ | 3941 | /* unsolicited event for pin-sense */ |
3858 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, | 3942 | {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, |
3859 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, | 3943 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_MIC_EVENT}, |
3944 | /* allow to touch GPIO1 (for mute control) */ | ||
3945 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, | ||
3946 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, | ||
3947 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, /* first muted */ | ||
3860 | { } /* end */ | 3948 | { } /* end */ |
3861 | }; | 3949 | }; |
3862 | 3950 | ||
@@ -3966,8 +4054,10 @@ static struct snd_pci_quirk ad1884a_cfg_tbl[] = { | |||
3966 | SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP), | 4054 | SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP), |
3967 | SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), | 4055 | SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), |
3968 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE), | 4056 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE), |
4057 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30d0, "HP laptop", AD1884A_LAPTOP), | ||
3969 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP), | 4058 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP), |
3970 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP), | 4059 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP), |
4060 | SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x7010, "HP laptop", AD1884A_MOBILE), | ||
3971 | SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), | 4061 | SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), |
3972 | {} | 4062 | {} |
3973 | }; | 4063 | }; |
@@ -4017,9 +4107,8 @@ static int patch_ad1884a(struct hda_codec *codec) | |||
4017 | spec->mixers[0] = ad1884a_laptop_mixers; | 4107 | spec->mixers[0] = ad1884a_laptop_mixers; |
4018 | spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs; | 4108 | spec->init_verbs[spec->num_init_verbs++] = ad1884a_laptop_verbs; |
4019 | spec->multiout.dig_out_nid = 0; | 4109 | spec->multiout.dig_out_nid = 0; |
4020 | spec->input_mux = &ad1884a_laptop_capture_source; | 4110 | codec->patch_ops.unsol_event = ad1884a_laptop_unsol_event; |
4021 | codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; | 4111 | codec->patch_ops.init = ad1884a_laptop_init; |
4022 | codec->patch_ops.init = ad1884a_hp_init; | ||
4023 | /* set the upper-limit for mixer amp to 0dB for avoiding the | 4112 | /* set the upper-limit for mixer amp to 0dB for avoiding the |
4024 | * possible damage by overloading | 4113 | * possible damage by overloading |
4025 | */ | 4114 | */ |
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c index 233e4778bba9..fb684f00156b 100644 --- a/sound/pci/hda/patch_atihdmi.c +++ b/sound/pci/hda/patch_atihdmi.c | |||
@@ -141,8 +141,7 @@ static int atihdmi_build_pcms(struct hda_codec *codec) | |||
141 | /* FIXME: we must check ELD and change the PCM parameters dynamically | 141 | /* FIXME: we must check ELD and change the PCM parameters dynamically |
142 | */ | 142 | */ |
143 | chans = get_wcaps(codec, CVT_NID); | 143 | chans = get_wcaps(codec, CVT_NID); |
144 | chans = (chans & AC_WCAP_CHAN_CNT_EXT) >> 13; | 144 | chans = get_wcaps_channels(chans); |
145 | chans = ((chans << 1) | 1) + 1; | ||
146 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; | 145 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; |
147 | 146 | ||
148 | return 0; | 147 | return 0; |
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c index 392d108c3558..d08353d3bb7f 100644 --- a/sound/pci/hda/patch_ca0110.c +++ b/sound/pci/hda/patch_ca0110.c | |||
@@ -459,8 +459,7 @@ static void parse_input(struct hda_codec *codec) | |||
459 | nid = codec->start_nid; | 459 | nid = codec->start_nid; |
460 | for (i = 0; i < codec->num_nodes; i++, nid++) { | 460 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
461 | unsigned int wcaps = get_wcaps(codec, nid); | 461 | unsigned int wcaps = get_wcaps(codec, nid); |
462 | unsigned int type = (wcaps & AC_WCAP_TYPE) >> | 462 | unsigned int type = get_wcaps_type(wcaps); |
463 | AC_WCAP_TYPE_SHIFT; | ||
464 | if (type != AC_WID_AUD_IN) | 463 | if (type != AC_WID_AUD_IN) |
465 | continue; | 464 | continue; |
466 | if (snd_hda_get_connections(codec, nid, &pin, 1) != 1) | 465 | if (snd_hda_get_connections(codec, nid, &pin, 1) != 1) |
@@ -510,7 +509,7 @@ static int ca0110_parse_auto_config(struct hda_codec *codec) | |||
510 | } | 509 | } |
511 | 510 | ||
512 | 511 | ||
513 | int patch_ca0110(struct hda_codec *codec) | 512 | static int patch_ca0110(struct hda_codec *codec) |
514 | { | 513 | { |
515 | struct ca0110_spec *spec; | 514 | struct ca0110_spec *spec; |
516 | int err; | 515 | int err; |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c new file mode 100644 index 000000000000..8ba306856d38 --- /dev/null +++ b/sound/pci/hda/patch_cirrus.c | |||
@@ -0,0 +1,1194 @@ | |||
1 | /* | ||
2 | * HD audio interface patch for Cirrus Logic CS420x chip | ||
3 | * | ||
4 | * Copyright (c) 2009 Takashi Iwai <tiwai@suse.de> | ||
5 | * | ||
6 | * This driver is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This driver is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <linux/init.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/slab.h> | ||
24 | #include <linux/pci.h> | ||
25 | #include <sound/core.h> | ||
26 | #include "hda_codec.h" | ||
27 | #include "hda_local.h" | ||
28 | |||
29 | /* | ||
30 | */ | ||
31 | |||
32 | struct cs_spec { | ||
33 | int board_config; | ||
34 | struct auto_pin_cfg autocfg; | ||
35 | struct hda_multi_out multiout; | ||
36 | struct snd_kcontrol *vmaster_sw; | ||
37 | struct snd_kcontrol *vmaster_vol; | ||
38 | |||
39 | hda_nid_t dac_nid[AUTO_CFG_MAX_OUTS]; | ||
40 | hda_nid_t slave_dig_outs[2]; | ||
41 | |||
42 | unsigned int input_idx[AUTO_PIN_LAST]; | ||
43 | unsigned int capsrc_idx[AUTO_PIN_LAST]; | ||
44 | hda_nid_t adc_nid[AUTO_PIN_LAST]; | ||
45 | unsigned int adc_idx[AUTO_PIN_LAST]; | ||
46 | unsigned int num_inputs; | ||
47 | unsigned int cur_input; | ||
48 | unsigned int automic_idx; | ||
49 | hda_nid_t cur_adc; | ||
50 | unsigned int cur_adc_stream_tag; | ||
51 | unsigned int cur_adc_format; | ||
52 | hda_nid_t dig_in; | ||
53 | |||
54 | struct hda_bind_ctls *capture_bind[2]; | ||
55 | |||
56 | unsigned int gpio_mask; | ||
57 | unsigned int gpio_dir; | ||
58 | unsigned int gpio_data; | ||
59 | |||
60 | struct hda_pcm pcm_rec[2]; /* PCM information */ | ||
61 | |||
62 | unsigned int hp_detect:1; | ||
63 | unsigned int mic_detect:1; | ||
64 | }; | ||
65 | |||
66 | /* available models */ | ||
67 | enum { | ||
68 | CS420X_MBP55, | ||
69 | CS420X_AUTO, | ||
70 | CS420X_MODELS | ||
71 | }; | ||
72 | |||
73 | /* Vendor-specific processing widget */ | ||
74 | #define CS420X_VENDOR_NID 0x11 | ||
75 | #define CS_DIG_OUT1_PIN_NID 0x10 | ||
76 | #define CS_DIG_OUT2_PIN_NID 0x15 | ||
77 | #define CS_DMIC1_PIN_NID 0x12 | ||
78 | #define CS_DMIC2_PIN_NID 0x0e | ||
79 | |||
80 | /* coef indices */ | ||
81 | #define IDX_SPDIF_STAT 0x0000 | ||
82 | #define IDX_SPDIF_CTL 0x0001 | ||
83 | #define IDX_ADC_CFG 0x0002 | ||
84 | /* SZC bitmask, 4 modes below: | ||
85 | * 0 = immediate, | ||
86 | * 1 = digital immediate, analog zero-cross | ||
87 | * 2 = digtail & analog soft-ramp | ||
88 | * 3 = digital soft-ramp, analog zero-cross | ||
89 | */ | ||
90 | #define CS_COEF_ADC_SZC_MASK (3 << 0) | ||
91 | #define CS_COEF_ADC_MIC_SZC_MODE (3 << 0) /* SZC setup for mic */ | ||
92 | #define CS_COEF_ADC_LI_SZC_MODE (3 << 0) /* SZC setup for line-in */ | ||
93 | /* PGA mode: 0 = differential, 1 = signle-ended */ | ||
94 | #define CS_COEF_ADC_MIC_PGA_MODE (1 << 5) /* PGA setup for mic */ | ||
95 | #define CS_COEF_ADC_LI_PGA_MODE (1 << 6) /* PGA setup for line-in */ | ||
96 | #define IDX_DAC_CFG 0x0003 | ||
97 | /* SZC bitmask, 4 modes below: | ||
98 | * 0 = Immediate | ||
99 | * 1 = zero-cross | ||
100 | * 2 = soft-ramp | ||
101 | * 3 = soft-ramp on zero-cross | ||
102 | */ | ||
103 | #define CS_COEF_DAC_HP_SZC_MODE (3 << 0) /* nid 0x02 */ | ||
104 | #define CS_COEF_DAC_LO_SZC_MODE (3 << 2) /* nid 0x03 */ | ||
105 | #define CS_COEF_DAC_SPK_SZC_MODE (3 << 4) /* nid 0x04 */ | ||
106 | |||
107 | #define IDX_BEEP_CFG 0x0004 | ||
108 | /* 0x0008 - test reg key */ | ||
109 | /* 0x0009 - 0x0014 -> 12 test regs */ | ||
110 | /* 0x0015 - visibility reg */ | ||
111 | |||
112 | |||
113 | static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx) | ||
114 | { | ||
115 | snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0, | ||
116 | AC_VERB_SET_COEF_INDEX, idx); | ||
117 | return snd_hda_codec_read(codec, CS420X_VENDOR_NID, 0, | ||
118 | AC_VERB_GET_PROC_COEF, 0); | ||
119 | } | ||
120 | |||
121 | static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx, | ||
122 | unsigned int coef) | ||
123 | { | ||
124 | snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0, | ||
125 | AC_VERB_SET_COEF_INDEX, idx); | ||
126 | snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0, | ||
127 | AC_VERB_SET_PROC_COEF, coef); | ||
128 | } | ||
129 | |||
130 | |||
131 | #define HP_EVENT 1 | ||
132 | #define MIC_EVENT 2 | ||
133 | |||
134 | /* | ||
135 | * PCM callbacks | ||
136 | */ | ||
137 | static int cs_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
138 | struct hda_codec *codec, | ||
139 | struct snd_pcm_substream *substream) | ||
140 | { | ||
141 | struct cs_spec *spec = codec->spec; | ||
142 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, | ||
143 | hinfo); | ||
144 | } | ||
145 | |||
146 | static int cs_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
147 | struct hda_codec *codec, | ||
148 | unsigned int stream_tag, | ||
149 | unsigned int format, | ||
150 | struct snd_pcm_substream *substream) | ||
151 | { | ||
152 | struct cs_spec *spec = codec->spec; | ||
153 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, | ||
154 | stream_tag, format, substream); | ||
155 | } | ||
156 | |||
157 | static int cs_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
158 | struct hda_codec *codec, | ||
159 | struct snd_pcm_substream *substream) | ||
160 | { | ||
161 | struct cs_spec *spec = codec->spec; | ||
162 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * Digital out | ||
167 | */ | ||
168 | static int cs_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | ||
169 | struct hda_codec *codec, | ||
170 | struct snd_pcm_substream *substream) | ||
171 | { | ||
172 | struct cs_spec *spec = codec->spec; | ||
173 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | ||
174 | } | ||
175 | |||
176 | static int cs_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | ||
177 | struct hda_codec *codec, | ||
178 | struct snd_pcm_substream *substream) | ||
179 | { | ||
180 | struct cs_spec *spec = codec->spec; | ||
181 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | ||
182 | } | ||
183 | |||
184 | static int cs_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
185 | struct hda_codec *codec, | ||
186 | unsigned int stream_tag, | ||
187 | unsigned int format, | ||
188 | struct snd_pcm_substream *substream) | ||
189 | { | ||
190 | struct cs_spec *spec = codec->spec; | ||
191 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, | ||
192 | format, substream); | ||
193 | } | ||
194 | |||
195 | static int cs_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
196 | struct hda_codec *codec, | ||
197 | struct snd_pcm_substream *substream) | ||
198 | { | ||
199 | struct cs_spec *spec = codec->spec; | ||
200 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); | ||
201 | } | ||
202 | |||
203 | /* | ||
204 | * Analog capture | ||
205 | */ | ||
206 | static int cs_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | ||
207 | struct hda_codec *codec, | ||
208 | unsigned int stream_tag, | ||
209 | unsigned int format, | ||
210 | struct snd_pcm_substream *substream) | ||
211 | { | ||
212 | struct cs_spec *spec = codec->spec; | ||
213 | spec->cur_adc = spec->adc_nid[spec->cur_input]; | ||
214 | spec->cur_adc_stream_tag = stream_tag; | ||
215 | spec->cur_adc_format = format; | ||
216 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); | ||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static int cs_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
221 | struct hda_codec *codec, | ||
222 | struct snd_pcm_substream *substream) | ||
223 | { | ||
224 | struct cs_spec *spec = codec->spec; | ||
225 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); | ||
226 | spec->cur_adc = 0; | ||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | /* | ||
231 | */ | ||
232 | static struct hda_pcm_stream cs_pcm_analog_playback = { | ||
233 | .substreams = 1, | ||
234 | .channels_min = 2, | ||
235 | .channels_max = 2, | ||
236 | .ops = { | ||
237 | .open = cs_playback_pcm_open, | ||
238 | .prepare = cs_playback_pcm_prepare, | ||
239 | .cleanup = cs_playback_pcm_cleanup | ||
240 | }, | ||
241 | }; | ||
242 | |||
243 | static struct hda_pcm_stream cs_pcm_analog_capture = { | ||
244 | .substreams = 1, | ||
245 | .channels_min = 2, | ||
246 | .channels_max = 2, | ||
247 | .ops = { | ||
248 | .prepare = cs_capture_pcm_prepare, | ||
249 | .cleanup = cs_capture_pcm_cleanup | ||
250 | }, | ||
251 | }; | ||
252 | |||
253 | static struct hda_pcm_stream cs_pcm_digital_playback = { | ||
254 | .substreams = 1, | ||
255 | .channels_min = 2, | ||
256 | .channels_max = 2, | ||
257 | .ops = { | ||
258 | .open = cs_dig_playback_pcm_open, | ||
259 | .close = cs_dig_playback_pcm_close, | ||
260 | .prepare = cs_dig_playback_pcm_prepare, | ||
261 | .cleanup = cs_dig_playback_pcm_cleanup | ||
262 | }, | ||
263 | }; | ||
264 | |||
265 | static struct hda_pcm_stream cs_pcm_digital_capture = { | ||
266 | .substreams = 1, | ||
267 | .channels_min = 2, | ||
268 | .channels_max = 2, | ||
269 | }; | ||
270 | |||
271 | static int cs_build_pcms(struct hda_codec *codec) | ||
272 | { | ||
273 | struct cs_spec *spec = codec->spec; | ||
274 | struct hda_pcm *info = spec->pcm_rec; | ||
275 | |||
276 | codec->pcm_info = info; | ||
277 | codec->num_pcms = 0; | ||
278 | |||
279 | info->name = "Cirrus Analog"; | ||
280 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cs_pcm_analog_playback; | ||
281 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->dac_nid[0]; | ||
282 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = | ||
283 | spec->multiout.max_channels; | ||
284 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = cs_pcm_analog_capture; | ||
285 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = | ||
286 | spec->adc_nid[spec->cur_input]; | ||
287 | codec->num_pcms++; | ||
288 | |||
289 | if (!spec->multiout.dig_out_nid && !spec->dig_in) | ||
290 | return 0; | ||
291 | |||
292 | info++; | ||
293 | info->name = "Cirrus Digital"; | ||
294 | info->pcm_type = spec->autocfg.dig_out_type[0]; | ||
295 | if (!info->pcm_type) | ||
296 | info->pcm_type = HDA_PCM_TYPE_SPDIF; | ||
297 | if (spec->multiout.dig_out_nid) { | ||
298 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = | ||
299 | cs_pcm_digital_playback; | ||
300 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | ||
301 | spec->multiout.dig_out_nid; | ||
302 | } | ||
303 | if (spec->dig_in) { | ||
304 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = | ||
305 | cs_pcm_digital_capture; | ||
306 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in; | ||
307 | } | ||
308 | codec->num_pcms++; | ||
309 | |||
310 | return 0; | ||
311 | } | ||
312 | |||
313 | /* | ||
314 | * parse codec topology | ||
315 | */ | ||
316 | |||
317 | static hda_nid_t get_dac(struct hda_codec *codec, hda_nid_t pin) | ||
318 | { | ||
319 | hda_nid_t dac; | ||
320 | if (!pin) | ||
321 | return 0; | ||
322 | if (snd_hda_get_connections(codec, pin, &dac, 1) != 1) | ||
323 | return 0; | ||
324 | return dac; | ||
325 | } | ||
326 | |||
327 | static int is_ext_mic(struct hda_codec *codec, unsigned int idx) | ||
328 | { | ||
329 | struct cs_spec *spec = codec->spec; | ||
330 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
331 | hda_nid_t pin = cfg->input_pins[idx]; | ||
332 | unsigned int val = snd_hda_query_pin_caps(codec, pin); | ||
333 | if (!(val & AC_PINCAP_PRES_DETECT)) | ||
334 | return 0; | ||
335 | val = snd_hda_codec_get_pincfg(codec, pin); | ||
336 | return (get_defcfg_connect(val) == AC_JACK_PORT_COMPLEX); | ||
337 | } | ||
338 | |||
339 | static hda_nid_t get_adc(struct hda_codec *codec, hda_nid_t pin, | ||
340 | unsigned int *idxp) | ||
341 | { | ||
342 | int i; | ||
343 | hda_nid_t nid; | ||
344 | |||
345 | nid = codec->start_nid; | ||
346 | for (i = 0; i < codec->num_nodes; i++, nid++) { | ||
347 | hda_nid_t pins[2]; | ||
348 | unsigned int type; | ||
349 | int j, nums; | ||
350 | type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) | ||
351 | >> AC_WCAP_TYPE_SHIFT; | ||
352 | if (type != AC_WID_AUD_IN) | ||
353 | continue; | ||
354 | nums = snd_hda_get_connections(codec, nid, pins, | ||
355 | ARRAY_SIZE(pins)); | ||
356 | if (nums <= 0) | ||
357 | continue; | ||
358 | for (j = 0; j < nums; j++) { | ||
359 | if (pins[j] == pin) { | ||
360 | *idxp = j; | ||
361 | return nid; | ||
362 | } | ||
363 | } | ||
364 | } | ||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | static int is_active_pin(struct hda_codec *codec, hda_nid_t nid) | ||
369 | { | ||
370 | unsigned int val; | ||
371 | val = snd_hda_codec_get_pincfg(codec, nid); | ||
372 | return (get_defcfg_connect(val) != AC_JACK_PORT_NONE); | ||
373 | } | ||
374 | |||
375 | static int parse_output(struct hda_codec *codec) | ||
376 | { | ||
377 | struct cs_spec *spec = codec->spec; | ||
378 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
379 | int i, extra_nids; | ||
380 | hda_nid_t dac; | ||
381 | |||
382 | for (i = 0; i < cfg->line_outs; i++) { | ||
383 | dac = get_dac(codec, cfg->line_out_pins[i]); | ||
384 | if (!dac) | ||
385 | break; | ||
386 | spec->dac_nid[i] = dac; | ||
387 | } | ||
388 | spec->multiout.num_dacs = i; | ||
389 | spec->multiout.dac_nids = spec->dac_nid; | ||
390 | spec->multiout.max_channels = i * 2; | ||
391 | |||
392 | /* add HP and speakers */ | ||
393 | extra_nids = 0; | ||
394 | for (i = 0; i < cfg->hp_outs; i++) { | ||
395 | dac = get_dac(codec, cfg->hp_pins[i]); | ||
396 | if (!dac) | ||
397 | break; | ||
398 | if (!i) | ||
399 | spec->multiout.hp_nid = dac; | ||
400 | else | ||
401 | spec->multiout.extra_out_nid[extra_nids++] = dac; | ||
402 | } | ||
403 | for (i = 0; i < cfg->speaker_outs; i++) { | ||
404 | dac = get_dac(codec, cfg->speaker_pins[i]); | ||
405 | if (!dac) | ||
406 | break; | ||
407 | spec->multiout.extra_out_nid[extra_nids++] = dac; | ||
408 | } | ||
409 | |||
410 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { | ||
411 | cfg->speaker_outs = cfg->line_outs; | ||
412 | memcpy(cfg->speaker_pins, cfg->line_out_pins, | ||
413 | sizeof(cfg->speaker_pins)); | ||
414 | cfg->line_outs = 0; | ||
415 | } | ||
416 | |||
417 | return 0; | ||
418 | } | ||
419 | |||
420 | static int parse_input(struct hda_codec *codec) | ||
421 | { | ||
422 | struct cs_spec *spec = codec->spec; | ||
423 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
424 | int i; | ||
425 | |||
426 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
427 | hda_nid_t pin = cfg->input_pins[i]; | ||
428 | if (!pin) | ||
429 | continue; | ||
430 | spec->input_idx[spec->num_inputs] = i; | ||
431 | spec->capsrc_idx[i] = spec->num_inputs++; | ||
432 | spec->cur_input = i; | ||
433 | spec->adc_nid[i] = get_adc(codec, pin, &spec->adc_idx[i]); | ||
434 | } | ||
435 | if (!spec->num_inputs) | ||
436 | return 0; | ||
437 | |||
438 | /* check whether the automatic mic switch is available */ | ||
439 | if (spec->num_inputs == 2 && | ||
440 | spec->adc_nid[AUTO_PIN_MIC] && spec->adc_nid[AUTO_PIN_FRONT_MIC]) { | ||
441 | if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_FRONT_MIC])) { | ||
442 | if (!is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) { | ||
443 | spec->mic_detect = 1; | ||
444 | spec->automic_idx = AUTO_PIN_FRONT_MIC; | ||
445 | } | ||
446 | } else { | ||
447 | if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) { | ||
448 | spec->mic_detect = 1; | ||
449 | spec->automic_idx = AUTO_PIN_MIC; | ||
450 | } | ||
451 | } | ||
452 | } | ||
453 | return 0; | ||
454 | } | ||
455 | |||
456 | |||
457 | static int parse_digital_output(struct hda_codec *codec) | ||
458 | { | ||
459 | struct cs_spec *spec = codec->spec; | ||
460 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
461 | hda_nid_t nid; | ||
462 | |||
463 | if (!cfg->dig_outs) | ||
464 | return 0; | ||
465 | if (snd_hda_get_connections(codec, cfg->dig_out_pins[0], &nid, 1) < 1) | ||
466 | return 0; | ||
467 | spec->multiout.dig_out_nid = nid; | ||
468 | spec->multiout.share_spdif = 1; | ||
469 | if (cfg->dig_outs > 1 && | ||
470 | snd_hda_get_connections(codec, cfg->dig_out_pins[1], &nid, 1) > 0) { | ||
471 | spec->slave_dig_outs[0] = nid; | ||
472 | codec->slave_dig_outs = spec->slave_dig_outs; | ||
473 | } | ||
474 | return 0; | ||
475 | } | ||
476 | |||
477 | static int parse_digital_input(struct hda_codec *codec) | ||
478 | { | ||
479 | struct cs_spec *spec = codec->spec; | ||
480 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
481 | int idx; | ||
482 | |||
483 | if (cfg->dig_in_pin) | ||
484 | spec->dig_in = get_adc(codec, cfg->dig_in_pin, &idx); | ||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | /* | ||
489 | * create mixer controls | ||
490 | */ | ||
491 | |||
492 | static const char *dir_sfx[2] = { "Playback", "Capture" }; | ||
493 | |||
494 | static int add_mute(struct hda_codec *codec, const char *name, int index, | ||
495 | unsigned int pval, int dir, struct snd_kcontrol **kctlp) | ||
496 | { | ||
497 | char tmp[44]; | ||
498 | struct snd_kcontrol_new knew = | ||
499 | HDA_CODEC_MUTE_IDX(tmp, index, 0, 0, HDA_OUTPUT); | ||
500 | knew.private_value = pval; | ||
501 | snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]); | ||
502 | *kctlp = snd_ctl_new1(&knew, codec); | ||
503 | return snd_hda_ctl_add(codec, *kctlp); | ||
504 | } | ||
505 | |||
506 | static int add_volume(struct hda_codec *codec, const char *name, | ||
507 | int index, unsigned int pval, int dir, | ||
508 | struct snd_kcontrol **kctlp) | ||
509 | { | ||
510 | char tmp[32]; | ||
511 | struct snd_kcontrol_new knew = | ||
512 | HDA_CODEC_VOLUME_IDX(tmp, index, 0, 0, HDA_OUTPUT); | ||
513 | knew.private_value = pval; | ||
514 | snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]); | ||
515 | *kctlp = snd_ctl_new1(&knew, codec); | ||
516 | return snd_hda_ctl_add(codec, *kctlp); | ||
517 | } | ||
518 | |||
519 | static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) | ||
520 | { | ||
521 | unsigned int caps; | ||
522 | |||
523 | /* set the upper-limit for mixer amp to 0dB */ | ||
524 | caps = query_amp_caps(codec, dac, HDA_OUTPUT); | ||
525 | caps &= ~(0x7f << AC_AMPCAP_NUM_STEPS_SHIFT); | ||
526 | caps |= ((caps >> AC_AMPCAP_OFFSET_SHIFT) & 0x7f) | ||
527 | << AC_AMPCAP_NUM_STEPS_SHIFT; | ||
528 | snd_hda_override_amp_caps(codec, dac, HDA_OUTPUT, caps); | ||
529 | } | ||
530 | |||
531 | static int add_vmaster(struct hda_codec *codec, hda_nid_t dac) | ||
532 | { | ||
533 | struct cs_spec *spec = codec->spec; | ||
534 | unsigned int tlv[4]; | ||
535 | int err; | ||
536 | |||
537 | spec->vmaster_sw = | ||
538 | snd_ctl_make_virtual_master("Master Playback Switch", NULL); | ||
539 | err = snd_hda_ctl_add(codec, spec->vmaster_sw); | ||
540 | if (err < 0) | ||
541 | return err; | ||
542 | |||
543 | snd_hda_set_vmaster_tlv(codec, dac, HDA_OUTPUT, tlv); | ||
544 | spec->vmaster_vol = | ||
545 | snd_ctl_make_virtual_master("Master Playback Volume", tlv); | ||
546 | err = snd_hda_ctl_add(codec, spec->vmaster_vol); | ||
547 | if (err < 0) | ||
548 | return err; | ||
549 | return 0; | ||
550 | } | ||
551 | |||
552 | static int add_output(struct hda_codec *codec, hda_nid_t dac, int idx, | ||
553 | int num_ctls, int type) | ||
554 | { | ||
555 | struct cs_spec *spec = codec->spec; | ||
556 | const char *name; | ||
557 | int err, index; | ||
558 | struct snd_kcontrol *kctl; | ||
559 | static char *speakers[] = { | ||
560 | "Front Speaker", "Surround Speaker", "Bass Speaker" | ||
561 | }; | ||
562 | static char *line_outs[] = { | ||
563 | "Front Line-Out", "Surround Line-Out", "Bass Line-Out" | ||
564 | }; | ||
565 | |||
566 | fix_volume_caps(codec, dac); | ||
567 | if (!spec->vmaster_sw) { | ||
568 | err = add_vmaster(codec, dac); | ||
569 | if (err < 0) | ||
570 | return err; | ||
571 | } | ||
572 | |||
573 | index = 0; | ||
574 | switch (type) { | ||
575 | case AUTO_PIN_HP_OUT: | ||
576 | name = "Headphone"; | ||
577 | index = idx; | ||
578 | break; | ||
579 | case AUTO_PIN_SPEAKER_OUT: | ||
580 | if (num_ctls > 1) | ||
581 | name = speakers[idx]; | ||
582 | else | ||
583 | name = "Speaker"; | ||
584 | break; | ||
585 | default: | ||
586 | if (num_ctls > 1) | ||
587 | name = line_outs[idx]; | ||
588 | else | ||
589 | name = "Line-Out"; | ||
590 | break; | ||
591 | } | ||
592 | |||
593 | err = add_mute(codec, name, index, | ||
594 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl); | ||
595 | if (err < 0) | ||
596 | return err; | ||
597 | err = snd_ctl_add_slave(spec->vmaster_sw, kctl); | ||
598 | if (err < 0) | ||
599 | return err; | ||
600 | |||
601 | err = add_volume(codec, name, index, | ||
602 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl); | ||
603 | if (err < 0) | ||
604 | return err; | ||
605 | err = snd_ctl_add_slave(spec->vmaster_vol, kctl); | ||
606 | if (err < 0) | ||
607 | return err; | ||
608 | |||
609 | return 0; | ||
610 | } | ||
611 | |||
612 | static int build_output(struct hda_codec *codec) | ||
613 | { | ||
614 | struct cs_spec *spec = codec->spec; | ||
615 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
616 | int i, err; | ||
617 | |||
618 | for (i = 0; i < cfg->line_outs; i++) { | ||
619 | err = add_output(codec, get_dac(codec, cfg->line_out_pins[i]), | ||
620 | i, cfg->line_outs, cfg->line_out_type); | ||
621 | if (err < 0) | ||
622 | return err; | ||
623 | } | ||
624 | for (i = 0; i < cfg->hp_outs; i++) { | ||
625 | err = add_output(codec, get_dac(codec, cfg->hp_pins[i]), | ||
626 | i, cfg->hp_outs, AUTO_PIN_HP_OUT); | ||
627 | if (err < 0) | ||
628 | return err; | ||
629 | } | ||
630 | for (i = 0; i < cfg->speaker_outs; i++) { | ||
631 | err = add_output(codec, get_dac(codec, cfg->speaker_pins[i]), | ||
632 | i, cfg->speaker_outs, AUTO_PIN_SPEAKER_OUT); | ||
633 | if (err < 0) | ||
634 | return err; | ||
635 | } | ||
636 | return 0; | ||
637 | } | ||
638 | |||
639 | /* | ||
640 | */ | ||
641 | |||
642 | static struct snd_kcontrol_new cs_capture_ctls[] = { | ||
643 | HDA_BIND_SW("Capture Switch", 0), | ||
644 | HDA_BIND_VOL("Capture Volume", 0), | ||
645 | }; | ||
646 | |||
647 | static int change_cur_input(struct hda_codec *codec, unsigned int idx, | ||
648 | int force) | ||
649 | { | ||
650 | struct cs_spec *spec = codec->spec; | ||
651 | |||
652 | if (spec->cur_input == idx && !force) | ||
653 | return 0; | ||
654 | if (spec->cur_adc && spec->cur_adc != spec->adc_nid[idx]) { | ||
655 | /* stream is running, let's swap the current ADC */ | ||
656 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); | ||
657 | spec->cur_adc = spec->adc_nid[idx]; | ||
658 | snd_hda_codec_setup_stream(codec, spec->cur_adc, | ||
659 | spec->cur_adc_stream_tag, 0, | ||
660 | spec->cur_adc_format); | ||
661 | } | ||
662 | snd_hda_codec_write(codec, spec->cur_adc, 0, | ||
663 | AC_VERB_SET_CONNECT_SEL, | ||
664 | spec->adc_idx[idx]); | ||
665 | spec->cur_input = idx; | ||
666 | return 1; | ||
667 | } | ||
668 | |||
669 | static int cs_capture_source_info(struct snd_kcontrol *kcontrol, | ||
670 | struct snd_ctl_elem_info *uinfo) | ||
671 | { | ||
672 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
673 | struct cs_spec *spec = codec->spec; | ||
674 | unsigned int idx; | ||
675 | |||
676 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
677 | uinfo->count = 1; | ||
678 | uinfo->value.enumerated.items = spec->num_inputs; | ||
679 | if (uinfo->value.enumerated.item >= spec->num_inputs) | ||
680 | uinfo->value.enumerated.item = spec->num_inputs - 1; | ||
681 | idx = spec->input_idx[uinfo->value.enumerated.item]; | ||
682 | strcpy(uinfo->value.enumerated.name, auto_pin_cfg_labels[idx]); | ||
683 | return 0; | ||
684 | } | ||
685 | |||
686 | static int cs_capture_source_get(struct snd_kcontrol *kcontrol, | ||
687 | struct snd_ctl_elem_value *ucontrol) | ||
688 | { | ||
689 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
690 | struct cs_spec *spec = codec->spec; | ||
691 | ucontrol->value.enumerated.item[0] = spec->capsrc_idx[spec->cur_input]; | ||
692 | return 0; | ||
693 | } | ||
694 | |||
695 | static int cs_capture_source_put(struct snd_kcontrol *kcontrol, | ||
696 | struct snd_ctl_elem_value *ucontrol) | ||
697 | { | ||
698 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
699 | struct cs_spec *spec = codec->spec; | ||
700 | unsigned int idx = ucontrol->value.enumerated.item[0]; | ||
701 | |||
702 | if (idx >= spec->num_inputs) | ||
703 | return -EINVAL; | ||
704 | idx = spec->input_idx[idx]; | ||
705 | return change_cur_input(codec, idx, 0); | ||
706 | } | ||
707 | |||
708 | static struct snd_kcontrol_new cs_capture_source = { | ||
709 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
710 | .name = "Capture Source", | ||
711 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, | ||
712 | .info = cs_capture_source_info, | ||
713 | .get = cs_capture_source_get, | ||
714 | .put = cs_capture_source_put, | ||
715 | }; | ||
716 | |||
717 | static struct hda_bind_ctls *make_bind_capture(struct hda_codec *codec, | ||
718 | struct hda_ctl_ops *ops) | ||
719 | { | ||
720 | struct cs_spec *spec = codec->spec; | ||
721 | struct hda_bind_ctls *bind; | ||
722 | int i, n; | ||
723 | |||
724 | bind = kzalloc(sizeof(*bind) + sizeof(long) * (spec->num_inputs + 1), | ||
725 | GFP_KERNEL); | ||
726 | if (!bind) | ||
727 | return NULL; | ||
728 | bind->ops = ops; | ||
729 | n = 0; | ||
730 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
731 | if (!spec->adc_nid[i]) | ||
732 | continue; | ||
733 | bind->values[n++] = | ||
734 | HDA_COMPOSE_AMP_VAL(spec->adc_nid[i], 3, | ||
735 | spec->adc_idx[i], HDA_INPUT); | ||
736 | } | ||
737 | return bind; | ||
738 | } | ||
739 | |||
740 | static int build_input(struct hda_codec *codec) | ||
741 | { | ||
742 | struct cs_spec *spec = codec->spec; | ||
743 | int i, err; | ||
744 | |||
745 | if (!spec->num_inputs) | ||
746 | return 0; | ||
747 | |||
748 | /* make bind-capture */ | ||
749 | spec->capture_bind[0] = make_bind_capture(codec, &snd_hda_bind_sw); | ||
750 | spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol); | ||
751 | for (i = 0; i < 2; i++) { | ||
752 | struct snd_kcontrol *kctl; | ||
753 | if (!spec->capture_bind[i]) | ||
754 | return -ENOMEM; | ||
755 | kctl = snd_ctl_new1(&cs_capture_ctls[i], codec); | ||
756 | if (!kctl) | ||
757 | return -ENOMEM; | ||
758 | kctl->private_value = (long)spec->capture_bind[i]; | ||
759 | err = snd_hda_ctl_add(codec, kctl); | ||
760 | if (err < 0) | ||
761 | return err; | ||
762 | } | ||
763 | |||
764 | if (spec->num_inputs > 1 && !spec->mic_detect) { | ||
765 | err = snd_hda_ctl_add(codec, | ||
766 | snd_ctl_new1(&cs_capture_source, codec)); | ||
767 | if (err < 0) | ||
768 | return err; | ||
769 | } | ||
770 | |||
771 | return 0; | ||
772 | } | ||
773 | |||
774 | /* | ||
775 | */ | ||
776 | |||
777 | static int build_digital_output(struct hda_codec *codec) | ||
778 | { | ||
779 | struct cs_spec *spec = codec->spec; | ||
780 | int err; | ||
781 | |||
782 | if (!spec->multiout.dig_out_nid) | ||
783 | return 0; | ||
784 | |||
785 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); | ||
786 | if (err < 0) | ||
787 | return err; | ||
788 | err = snd_hda_create_spdif_share_sw(codec, &spec->multiout); | ||
789 | if (err < 0) | ||
790 | return err; | ||
791 | return 0; | ||
792 | } | ||
793 | |||
794 | static int build_digital_input(struct hda_codec *codec) | ||
795 | { | ||
796 | struct cs_spec *spec = codec->spec; | ||
797 | if (spec->dig_in) | ||
798 | return snd_hda_create_spdif_in_ctls(codec, spec->dig_in); | ||
799 | return 0; | ||
800 | } | ||
801 | |||
802 | /* | ||
803 | * auto-mute and auto-mic switching | ||
804 | */ | ||
805 | |||
806 | static void cs_automute(struct hda_codec *codec) | ||
807 | { | ||
808 | struct cs_spec *spec = codec->spec; | ||
809 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
810 | unsigned int caps, present, hp_present; | ||
811 | hda_nid_t nid; | ||
812 | int i; | ||
813 | |||
814 | hp_present = 0; | ||
815 | for (i = 0; i < cfg->hp_outs; i++) { | ||
816 | nid = cfg->hp_pins[i]; | ||
817 | caps = snd_hda_query_pin_caps(codec, nid); | ||
818 | if (!(caps & AC_PINCAP_PRES_DETECT)) | ||
819 | continue; | ||
820 | if (caps & AC_PINCAP_TRIG_REQ) | ||
821 | snd_hda_codec_read(codec, nid, 0, | ||
822 | AC_VERB_SET_PIN_SENSE, 0); | ||
823 | present = snd_hda_codec_read(codec, nid, 0, | ||
824 | AC_VERB_GET_PIN_SENSE, 0); | ||
825 | hp_present |= (present & AC_PINSENSE_PRESENCE) != 0; | ||
826 | if (hp_present) | ||
827 | break; | ||
828 | } | ||
829 | for (i = 0; i < cfg->speaker_outs; i++) { | ||
830 | nid = cfg->speaker_pins[i]; | ||
831 | snd_hda_codec_write(codec, nid, 0, | ||
832 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
833 | hp_present ? 0 : PIN_OUT); | ||
834 | } | ||
835 | if (spec->board_config == CS420X_MBP55) { | ||
836 | unsigned int gpio = hp_present ? 0x02 : 0x08; | ||
837 | snd_hda_codec_write(codec, 0x01, 0, | ||
838 | AC_VERB_SET_GPIO_DATA, gpio); | ||
839 | } | ||
840 | } | ||
841 | |||
842 | static void cs_automic(struct hda_codec *codec) | ||
843 | { | ||
844 | struct cs_spec *spec = codec->spec; | ||
845 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
846 | hda_nid_t nid; | ||
847 | unsigned int caps, present; | ||
848 | |||
849 | nid = cfg->input_pins[spec->automic_idx]; | ||
850 | caps = snd_hda_query_pin_caps(codec, nid); | ||
851 | if (caps & AC_PINCAP_TRIG_REQ) | ||
852 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
853 | present = snd_hda_codec_read(codec, nid, 0, | ||
854 | AC_VERB_GET_PIN_SENSE, 0); | ||
855 | if (present & AC_PINSENSE_PRESENCE) | ||
856 | change_cur_input(codec, spec->automic_idx, 0); | ||
857 | else { | ||
858 | unsigned int imic = (spec->automic_idx == AUTO_PIN_MIC) ? | ||
859 | AUTO_PIN_FRONT_MIC : AUTO_PIN_MIC; | ||
860 | change_cur_input(codec, imic, 0); | ||
861 | } | ||
862 | } | ||
863 | |||
864 | /* | ||
865 | */ | ||
866 | |||
867 | static void init_output(struct hda_codec *codec) | ||
868 | { | ||
869 | struct cs_spec *spec = codec->spec; | ||
870 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
871 | int i; | ||
872 | |||
873 | /* mute first */ | ||
874 | for (i = 0; i < spec->multiout.num_dacs; i++) | ||
875 | snd_hda_codec_write(codec, spec->multiout.dac_nids[i], 0, | ||
876 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); | ||
877 | if (spec->multiout.hp_nid) | ||
878 | snd_hda_codec_write(codec, spec->multiout.hp_nid, 0, | ||
879 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); | ||
880 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { | ||
881 | if (!spec->multiout.extra_out_nid[i]) | ||
882 | break; | ||
883 | snd_hda_codec_write(codec, spec->multiout.extra_out_nid[i], 0, | ||
884 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); | ||
885 | } | ||
886 | |||
887 | /* set appropriate pin controls */ | ||
888 | for (i = 0; i < cfg->line_outs; i++) | ||
889 | snd_hda_codec_write(codec, cfg->line_out_pins[i], 0, | ||
890 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
891 | for (i = 0; i < cfg->hp_outs; i++) { | ||
892 | hda_nid_t nid = cfg->hp_pins[i]; | ||
893 | snd_hda_codec_write(codec, nid, 0, | ||
894 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); | ||
895 | if (!cfg->speaker_outs) | ||
896 | continue; | ||
897 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { | ||
898 | snd_hda_codec_write(codec, nid, 0, | ||
899 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
900 | AC_USRSP_EN | HP_EVENT); | ||
901 | spec->hp_detect = 1; | ||
902 | } | ||
903 | } | ||
904 | for (i = 0; i < cfg->speaker_outs; i++) | ||
905 | snd_hda_codec_write(codec, cfg->speaker_pins[i], 0, | ||
906 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
907 | if (spec->hp_detect) | ||
908 | cs_automute(codec); | ||
909 | } | ||
910 | |||
911 | static void init_input(struct hda_codec *codec) | ||
912 | { | ||
913 | struct cs_spec *spec = codec->spec; | ||
914 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
915 | unsigned int coef; | ||
916 | int i; | ||
917 | |||
918 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
919 | unsigned int ctl; | ||
920 | hda_nid_t pin = cfg->input_pins[i]; | ||
921 | if (!pin || !spec->adc_nid[i]) | ||
922 | continue; | ||
923 | /* set appropriate pin control and mute first */ | ||
924 | ctl = PIN_IN; | ||
925 | if (i <= AUTO_PIN_FRONT_MIC) { | ||
926 | unsigned int caps = snd_hda_query_pin_caps(codec, pin); | ||
927 | caps >>= AC_PINCAP_VREF_SHIFT; | ||
928 | if (caps & AC_PINCAP_VREF_80) | ||
929 | ctl = PIN_VREF80; | ||
930 | } | ||
931 | snd_hda_codec_write(codec, pin, 0, | ||
932 | AC_VERB_SET_PIN_WIDGET_CONTROL, ctl); | ||
933 | snd_hda_codec_write(codec, spec->adc_nid[i], 0, | ||
934 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
935 | AMP_IN_MUTE(spec->adc_idx[i])); | ||
936 | if (spec->mic_detect && spec->automic_idx == i) | ||
937 | snd_hda_codec_write(codec, pin, 0, | ||
938 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
939 | AC_USRSP_EN | MIC_EVENT); | ||
940 | } | ||
941 | change_cur_input(codec, spec->cur_input, 1); | ||
942 | if (spec->mic_detect) | ||
943 | cs_automic(codec); | ||
944 | |||
945 | coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */ | ||
946 | if (is_active_pin(codec, CS_DMIC2_PIN_NID)) | ||
947 | coef |= 0x0500; /* DMIC2 enable 2 channels, disable GPIO1 */ | ||
948 | if (is_active_pin(codec, CS_DMIC1_PIN_NID)) | ||
949 | coef |= 0x1800; /* DMIC1 enable 2 channels, disable GPIO0 | ||
950 | * No effect if SPDIF_OUT2 is slected in | ||
951 | * IDX_SPDIF_CTL. | ||
952 | */ | ||
953 | cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); | ||
954 | } | ||
955 | |||
956 | static struct hda_verb cs_coef_init_verbs[] = { | ||
957 | {0x11, AC_VERB_SET_PROC_STATE, 1}, | ||
958 | {0x11, AC_VERB_SET_COEF_INDEX, IDX_DAC_CFG}, | ||
959 | {0x11, AC_VERB_SET_PROC_COEF, | ||
960 | (0x002a /* DAC1/2/3 SZCMode Soft Ramp */ | ||
961 | | 0x0040 /* Mute DACs on FIFO error */ | ||
962 | | 0x1000 /* Enable DACs High Pass Filter */ | ||
963 | | 0x0400 /* Disable Coefficient Auto increment */ | ||
964 | )}, | ||
965 | /* Beep */ | ||
966 | {0x11, AC_VERB_SET_COEF_INDEX, IDX_DAC_CFG}, | ||
967 | {0x11, AC_VERB_SET_PROC_COEF, 0x0007}, /* Enable Beep thru DAC1/2/3 */ | ||
968 | |||
969 | {} /* terminator */ | ||
970 | }; | ||
971 | |||
972 | /* SPDIF setup */ | ||
973 | static void init_digital(struct hda_codec *codec) | ||
974 | { | ||
975 | unsigned int coef; | ||
976 | |||
977 | coef = 0x0002; /* SRC_MUTE soft-mute on SPDIF (if no lock) */ | ||
978 | coef |= 0x0008; /* Replace with mute on error */ | ||
979 | if (is_active_pin(codec, CS_DIG_OUT2_PIN_NID)) | ||
980 | coef |= 0x4000; /* RX to TX1 or TX2 Loopthru / SPDIF2 | ||
981 | * SPDIF_OUT2 is shared with GPIO1 and | ||
982 | * DMIC_SDA2. | ||
983 | */ | ||
984 | cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef); | ||
985 | } | ||
986 | |||
987 | static int cs_init(struct hda_codec *codec) | ||
988 | { | ||
989 | struct cs_spec *spec = codec->spec; | ||
990 | |||
991 | snd_hda_sequence_write(codec, cs_coef_init_verbs); | ||
992 | |||
993 | if (spec->gpio_mask) { | ||
994 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, | ||
995 | spec->gpio_mask); | ||
996 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, | ||
997 | spec->gpio_dir); | ||
998 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, | ||
999 | spec->gpio_data); | ||
1000 | } | ||
1001 | |||
1002 | init_output(codec); | ||
1003 | init_input(codec); | ||
1004 | init_digital(codec); | ||
1005 | return 0; | ||
1006 | } | ||
1007 | |||
1008 | static int cs_build_controls(struct hda_codec *codec) | ||
1009 | { | ||
1010 | int err; | ||
1011 | |||
1012 | err = build_output(codec); | ||
1013 | if (err < 0) | ||
1014 | return err; | ||
1015 | err = build_input(codec); | ||
1016 | if (err < 0) | ||
1017 | return err; | ||
1018 | err = build_digital_output(codec); | ||
1019 | if (err < 0) | ||
1020 | return err; | ||
1021 | err = build_digital_input(codec); | ||
1022 | if (err < 0) | ||
1023 | return err; | ||
1024 | return cs_init(codec); | ||
1025 | } | ||
1026 | |||
1027 | static void cs_free(struct hda_codec *codec) | ||
1028 | { | ||
1029 | struct cs_spec *spec = codec->spec; | ||
1030 | kfree(spec->capture_bind[0]); | ||
1031 | kfree(spec->capture_bind[1]); | ||
1032 | kfree(codec->spec); | ||
1033 | } | ||
1034 | |||
1035 | static void cs_unsol_event(struct hda_codec *codec, unsigned int res) | ||
1036 | { | ||
1037 | switch ((res >> 26) & 0x7f) { | ||
1038 | case HP_EVENT: | ||
1039 | cs_automute(codec); | ||
1040 | break; | ||
1041 | case MIC_EVENT: | ||
1042 | cs_automic(codec); | ||
1043 | break; | ||
1044 | } | ||
1045 | } | ||
1046 | |||
1047 | static struct hda_codec_ops cs_patch_ops = { | ||
1048 | .build_controls = cs_build_controls, | ||
1049 | .build_pcms = cs_build_pcms, | ||
1050 | .init = cs_init, | ||
1051 | .free = cs_free, | ||
1052 | .unsol_event = cs_unsol_event, | ||
1053 | }; | ||
1054 | |||
1055 | static int cs_parse_auto_config(struct hda_codec *codec) | ||
1056 | { | ||
1057 | struct cs_spec *spec = codec->spec; | ||
1058 | int err; | ||
1059 | |||
1060 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); | ||
1061 | if (err < 0) | ||
1062 | return err; | ||
1063 | |||
1064 | err = parse_output(codec); | ||
1065 | if (err < 0) | ||
1066 | return err; | ||
1067 | err = parse_input(codec); | ||
1068 | if (err < 0) | ||
1069 | return err; | ||
1070 | err = parse_digital_output(codec); | ||
1071 | if (err < 0) | ||
1072 | return err; | ||
1073 | err = parse_digital_input(codec); | ||
1074 | if (err < 0) | ||
1075 | return err; | ||
1076 | return 0; | ||
1077 | } | ||
1078 | |||
1079 | static const char *cs420x_models[CS420X_MODELS] = { | ||
1080 | [CS420X_MBP55] = "mbp55", | ||
1081 | [CS420X_AUTO] = "auto", | ||
1082 | }; | ||
1083 | |||
1084 | |||
1085 | static struct snd_pci_quirk cs420x_cfg_tbl[] = { | ||
1086 | SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), | ||
1087 | {} /* terminator */ | ||
1088 | }; | ||
1089 | |||
1090 | struct cs_pincfg { | ||
1091 | hda_nid_t nid; | ||
1092 | u32 val; | ||
1093 | }; | ||
1094 | |||
1095 | static struct cs_pincfg mbp55_pincfgs[] = { | ||
1096 | { 0x09, 0x012b4030 }, | ||
1097 | { 0x0a, 0x90100121 }, | ||
1098 | { 0x0b, 0x90100120 }, | ||
1099 | { 0x0c, 0x400000f0 }, | ||
1100 | { 0x0d, 0x90a00110 }, | ||
1101 | { 0x0e, 0x400000f0 }, | ||
1102 | { 0x0f, 0x400000f0 }, | ||
1103 | { 0x10, 0x014be040 }, | ||
1104 | { 0x12, 0x400000f0 }, | ||
1105 | { 0x15, 0x400000f0 }, | ||
1106 | {} /* terminator */ | ||
1107 | }; | ||
1108 | |||
1109 | static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { | ||
1110 | [CS420X_MBP55] = mbp55_pincfgs, | ||
1111 | }; | ||
1112 | |||
1113 | static void fix_pincfg(struct hda_codec *codec, int model) | ||
1114 | { | ||
1115 | const struct cs_pincfg *cfg = cs_pincfgs[model]; | ||
1116 | if (!cfg) | ||
1117 | return; | ||
1118 | for (; cfg->nid; cfg++) | ||
1119 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); | ||
1120 | } | ||
1121 | |||
1122 | |||
1123 | static int patch_cs420x(struct hda_codec *codec) | ||
1124 | { | ||
1125 | struct cs_spec *spec; | ||
1126 | int err; | ||
1127 | |||
1128 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
1129 | if (!spec) | ||
1130 | return -ENOMEM; | ||
1131 | codec->spec = spec; | ||
1132 | |||
1133 | spec->board_config = | ||
1134 | snd_hda_check_board_config(codec, CS420X_MODELS, | ||
1135 | cs420x_models, cs420x_cfg_tbl); | ||
1136 | if (spec->board_config >= 0) | ||
1137 | fix_pincfg(codec, spec->board_config); | ||
1138 | |||
1139 | switch (spec->board_config) { | ||
1140 | case CS420X_MBP55: | ||
1141 | /* GPIO1 = headphones */ | ||
1142 | /* GPIO3 = speakers */ | ||
1143 | spec->gpio_mask = 0x0a; | ||
1144 | spec->gpio_dir = 0x0a; | ||
1145 | break; | ||
1146 | } | ||
1147 | |||
1148 | err = cs_parse_auto_config(codec); | ||
1149 | if (err < 0) | ||
1150 | goto error; | ||
1151 | |||
1152 | codec->patch_ops = cs_patch_ops; | ||
1153 | |||
1154 | return 0; | ||
1155 | |||
1156 | error: | ||
1157 | kfree(codec->spec); | ||
1158 | codec->spec = NULL; | ||
1159 | return err; | ||
1160 | } | ||
1161 | |||
1162 | |||
1163 | /* | ||
1164 | * patch entries | ||
1165 | */ | ||
1166 | static struct hda_codec_preset snd_hda_preset_cirrus[] = { | ||
1167 | { .id = 0x10134206, .name = "CS4206", .patch = patch_cs420x }, | ||
1168 | { .id = 0x10134207, .name = "CS4207", .patch = patch_cs420x }, | ||
1169 | {} /* terminator */ | ||
1170 | }; | ||
1171 | |||
1172 | MODULE_ALIAS("snd-hda-codec-id:10134206"); | ||
1173 | MODULE_ALIAS("snd-hda-codec-id:10134207"); | ||
1174 | |||
1175 | MODULE_LICENSE("GPL"); | ||
1176 | MODULE_DESCRIPTION("Cirrus Logic HD-audio codec"); | ||
1177 | |||
1178 | static struct hda_codec_preset_list cirrus_list = { | ||
1179 | .preset = snd_hda_preset_cirrus, | ||
1180 | .owner = THIS_MODULE, | ||
1181 | }; | ||
1182 | |||
1183 | static int __init patch_cirrus_init(void) | ||
1184 | { | ||
1185 | return snd_hda_add_codec_preset(&cirrus_list); | ||
1186 | } | ||
1187 | |||
1188 | static void __exit patch_cirrus_exit(void) | ||
1189 | { | ||
1190 | snd_hda_delete_codec_preset(&cirrus_list); | ||
1191 | } | ||
1192 | |||
1193 | module_init(patch_cirrus_init) | ||
1194 | module_exit(patch_cirrus_exit) | ||
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index c921264bbd71..780e1a72114a 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c | |||
@@ -635,7 +635,8 @@ static int patch_cmi9880(struct hda_codec *codec) | |||
635 | cmi9880_models, | 635 | cmi9880_models, |
636 | cmi9880_cfg_tbl); | 636 | cmi9880_cfg_tbl); |
637 | if (spec->board_config < 0) { | 637 | if (spec->board_config < 0) { |
638 | snd_printdd(KERN_INFO "hda_codec: Unknown model for CMI9880\n"); | 638 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
639 | codec->chip_name); | ||
639 | spec->board_config = CMI_AUTO; /* try everything */ | 640 | spec->board_config = CMI_AUTO; /* try everything */ |
640 | } | 641 | } |
641 | 642 | ||
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index ac868c59f9e3..9d899eda44d7 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -108,6 +108,8 @@ struct conexant_spec { | |||
108 | struct hda_input_mux private_imux; | 108 | struct hda_input_mux private_imux; |
109 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; | 109 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
110 | 110 | ||
111 | unsigned int dell_automute; | ||
112 | unsigned int port_d_mode; | ||
111 | }; | 113 | }; |
112 | 114 | ||
113 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, | 115 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, |
@@ -1908,6 +1910,480 @@ static int patch_cxt5051(struct hda_codec *codec) | |||
1908 | return 0; | 1910 | return 0; |
1909 | } | 1911 | } |
1910 | 1912 | ||
1913 | /* Conexant 5066 specific */ | ||
1914 | |||
1915 | static hda_nid_t cxt5066_dac_nids[1] = { 0x10 }; | ||
1916 | static hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 }; | ||
1917 | static hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; | ||
1918 | #define CXT5066_SPDIF_OUT 0x21 | ||
1919 | |||
1920 | static struct hda_channel_mode cxt5066_modes[1] = { | ||
1921 | { 2, NULL }, | ||
1922 | }; | ||
1923 | |||
1924 | static void cxt5066_update_speaker(struct hda_codec *codec) | ||
1925 | { | ||
1926 | struct conexant_spec *spec = codec->spec; | ||
1927 | unsigned int pinctl; | ||
1928 | |||
1929 | snd_printdd("CXT5066: update speaker, hp_present=%d\n", | ||
1930 | spec->hp_present); | ||
1931 | |||
1932 | /* Port A (HP) */ | ||
1933 | pinctl = ((spec->hp_present & 1) && spec->cur_eapd) ? PIN_HP : 0; | ||
1934 | snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1935 | pinctl); | ||
1936 | |||
1937 | /* Port D (HP/LO) */ | ||
1938 | pinctl = ((spec->hp_present & 2) && spec->cur_eapd) | ||
1939 | ? spec->port_d_mode : 0; | ||
1940 | snd_hda_codec_write(codec, 0x1c, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1941 | pinctl); | ||
1942 | |||
1943 | /* CLASS_D AMP */ | ||
1944 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; | ||
1945 | snd_hda_codec_write(codec, 0x1f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1946 | pinctl); | ||
1947 | |||
1948 | if (spec->dell_automute) { | ||
1949 | /* DELL AIO Port Rule: PortA > PortD > IntSpk */ | ||
1950 | pinctl = (!(spec->hp_present & 1) && spec->cur_eapd) | ||
1951 | ? PIN_OUT : 0; | ||
1952 | snd_hda_codec_write(codec, 0x1c, 0, | ||
1953 | AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl); | ||
1954 | } | ||
1955 | } | ||
1956 | |||
1957 | /* turn on/off EAPD (+ mute HP) as a master switch */ | ||
1958 | static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, | ||
1959 | struct snd_ctl_elem_value *ucontrol) | ||
1960 | { | ||
1961 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
1962 | |||
1963 | if (!cxt_eapd_put(kcontrol, ucontrol)) | ||
1964 | return 0; | ||
1965 | |||
1966 | cxt5066_update_speaker(codec); | ||
1967 | return 1; | ||
1968 | } | ||
1969 | |||
1970 | /* toggle input of built-in and mic jack appropriately */ | ||
1971 | static void cxt5066_automic(struct hda_codec *codec) | ||
1972 | { | ||
1973 | static struct hda_verb ext_mic_present[] = { | ||
1974 | /* enable external mic, port B */ | ||
1975 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
1976 | |||
1977 | /* switch to external mic input */ | ||
1978 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | ||
1979 | |||
1980 | /* disable internal mic, port C */ | ||
1981 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
1982 | {} | ||
1983 | }; | ||
1984 | static struct hda_verb ext_mic_absent[] = { | ||
1985 | /* enable internal mic, port C */ | ||
1986 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
1987 | |||
1988 | /* switch to internal mic input */ | ||
1989 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, | ||
1990 | |||
1991 | /* disable external mic, port B */ | ||
1992 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
1993 | {} | ||
1994 | }; | ||
1995 | unsigned int present; | ||
1996 | |||
1997 | present = snd_hda_codec_read(codec, 0x1a, 0, | ||
1998 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
1999 | if (present) { | ||
2000 | snd_printdd("CXT5066: external microphone detected\n"); | ||
2001 | snd_hda_sequence_write(codec, ext_mic_present); | ||
2002 | } else { | ||
2003 | snd_printdd("CXT5066: external microphone absent\n"); | ||
2004 | snd_hda_sequence_write(codec, ext_mic_absent); | ||
2005 | } | ||
2006 | } | ||
2007 | |||
2008 | /* mute internal speaker if HP is plugged */ | ||
2009 | static void cxt5066_hp_automute(struct hda_codec *codec) | ||
2010 | { | ||
2011 | struct conexant_spec *spec = codec->spec; | ||
2012 | unsigned int portA, portD; | ||
2013 | |||
2014 | /* Port A */ | ||
2015 | portA = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
2016 | & AC_PINSENSE_PRESENCE; | ||
2017 | |||
2018 | /* Port D */ | ||
2019 | portD = (snd_hda_codec_read(codec, 0x1c, 0, AC_VERB_GET_PIN_SENSE, 0) | ||
2020 | & AC_PINSENSE_PRESENCE) << 1; | ||
2021 | |||
2022 | spec->hp_present = !!(portA | portD); | ||
2023 | snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", | ||
2024 | portA, portD, spec->hp_present); | ||
2025 | cxt5066_update_speaker(codec); | ||
2026 | } | ||
2027 | |||
2028 | /* unsolicited event for jack sensing */ | ||
2029 | static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) | ||
2030 | { | ||
2031 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); | ||
2032 | switch (res >> 26) { | ||
2033 | case CONEXANT_HP_EVENT: | ||
2034 | cxt5066_hp_automute(codec); | ||
2035 | break; | ||
2036 | case CONEXANT_MIC_EVENT: | ||
2037 | cxt5066_automic(codec); | ||
2038 | break; | ||
2039 | } | ||
2040 | } | ||
2041 | |||
2042 | static const struct hda_input_mux cxt5066_analog_mic_boost = { | ||
2043 | .num_items = 5, | ||
2044 | .items = { | ||
2045 | { "0dB", 0 }, | ||
2046 | { "10dB", 1 }, | ||
2047 | { "20dB", 2 }, | ||
2048 | { "30dB", 3 }, | ||
2049 | { "40dB", 4 }, | ||
2050 | }, | ||
2051 | }; | ||
2052 | |||
2053 | static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, | ||
2054 | struct snd_ctl_elem_info *uinfo) | ||
2055 | { | ||
2056 | return snd_hda_input_mux_info(&cxt5066_analog_mic_boost, uinfo); | ||
2057 | } | ||
2058 | |||
2059 | static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, | ||
2060 | struct snd_ctl_elem_value *ucontrol) | ||
2061 | { | ||
2062 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2063 | int val; | ||
2064 | |||
2065 | val = snd_hda_codec_read(codec, 0x17, 0, | ||
2066 | AC_VERB_GET_AMP_GAIN_MUTE, AC_AMP_GET_OUTPUT); | ||
2067 | |||
2068 | ucontrol->value.enumerated.item[0] = val & AC_AMP_GAIN; | ||
2069 | return 0; | ||
2070 | } | ||
2071 | |||
2072 | static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, | ||
2073 | struct snd_ctl_elem_value *ucontrol) | ||
2074 | { | ||
2075 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2076 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; | ||
2077 | unsigned int idx; | ||
2078 | |||
2079 | if (!imux->num_items) | ||
2080 | return 0; | ||
2081 | idx = ucontrol->value.enumerated.item[0]; | ||
2082 | if (idx >= imux->num_items) | ||
2083 | idx = imux->num_items - 1; | ||
2084 | |||
2085 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
2086 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
2087 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | | ||
2088 | imux->items[idx].index); | ||
2089 | |||
2090 | return 1; | ||
2091 | } | ||
2092 | |||
2093 | static struct hda_input_mux cxt5066_capture_source = { | ||
2094 | .num_items = 4, | ||
2095 | .items = { | ||
2096 | { "Mic B", 0 }, | ||
2097 | { "Mic C", 1 }, | ||
2098 | { "Mic E", 2 }, | ||
2099 | { "Mic F", 3 }, | ||
2100 | }, | ||
2101 | }; | ||
2102 | |||
2103 | static struct hda_bind_ctls cxt5066_bind_capture_vol_others = { | ||
2104 | .ops = &snd_hda_bind_vol, | ||
2105 | .values = { | ||
2106 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), | ||
2107 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), | ||
2108 | 0 | ||
2109 | }, | ||
2110 | }; | ||
2111 | |||
2112 | static struct hda_bind_ctls cxt5066_bind_capture_sw_others = { | ||
2113 | .ops = &snd_hda_bind_sw, | ||
2114 | .values = { | ||
2115 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_INPUT), | ||
2116 | HDA_COMPOSE_AMP_VAL(0x14, 3, 2, HDA_INPUT), | ||
2117 | 0 | ||
2118 | }, | ||
2119 | }; | ||
2120 | |||
2121 | static struct snd_kcontrol_new cxt5066_mixer_master[] = { | ||
2122 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), | ||
2123 | {} | ||
2124 | }; | ||
2125 | |||
2126 | static struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { | ||
2127 | { | ||
2128 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2129 | .name = "Master Playback Volume", | ||
2130 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | ||
2131 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | | ||
2132 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, | ||
2133 | .info = snd_hda_mixer_amp_volume_info, | ||
2134 | .get = snd_hda_mixer_amp_volume_get, | ||
2135 | .put = snd_hda_mixer_amp_volume_put, | ||
2136 | .tlv = { .c = snd_hda_mixer_amp_tlv }, | ||
2137 | /* offset by 28 volume steps to limit minimum gain to -46dB */ | ||
2138 | .private_value = | ||
2139 | HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), | ||
2140 | }, | ||
2141 | {} | ||
2142 | }; | ||
2143 | |||
2144 | static struct snd_kcontrol_new cxt5066_mixers[] = { | ||
2145 | { | ||
2146 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2147 | .name = "Master Playback Switch", | ||
2148 | .info = cxt_eapd_info, | ||
2149 | .get = cxt_eapd_get, | ||
2150 | .put = cxt5066_hp_master_sw_put, | ||
2151 | .private_value = 0x1d, | ||
2152 | }, | ||
2153 | |||
2154 | { | ||
2155 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2156 | .name = "Analog Mic Boost Capture Enum", | ||
2157 | .info = cxt5066_mic_boost_mux_enum_info, | ||
2158 | .get = cxt5066_mic_boost_mux_enum_get, | ||
2159 | .put = cxt5066_mic_boost_mux_enum_put, | ||
2160 | }, | ||
2161 | |||
2162 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), | ||
2163 | HDA_BIND_SW("Capture Switch", &cxt5066_bind_capture_sw_others), | ||
2164 | {} | ||
2165 | }; | ||
2166 | |||
2167 | static struct hda_verb cxt5066_init_verbs[] = { | ||
2168 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ | ||
2169 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ | ||
2170 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ | ||
2171 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ | ||
2172 | |||
2173 | /* Speakers */ | ||
2174 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2175 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2176 | |||
2177 | /* HP, Amp */ | ||
2178 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
2179 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2180 | |||
2181 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
2182 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2183 | |||
2184 | /* DAC1 */ | ||
2185 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
2186 | |||
2187 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ | ||
2188 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | ||
2189 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2190 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, | ||
2191 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2192 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
2193 | |||
2194 | /* no digital microphone support yet */ | ||
2195 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2196 | |||
2197 | /* Audio input selector */ | ||
2198 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | ||
2199 | |||
2200 | /* SPDIF route: PCM */ | ||
2201 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
2202 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
2203 | |||
2204 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2205 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2206 | |||
2207 | /* EAPD */ | ||
2208 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | ||
2209 | |||
2210 | /* not handling these yet */ | ||
2211 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2212 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2213 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2214 | {0x1c, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2215 | {0x1d, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2216 | {0x1e, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2217 | {0x20, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2218 | {0x22, AC_VERB_SET_UNSOLICITED_ENABLE, 0}, | ||
2219 | { } /* end */ | ||
2220 | }; | ||
2221 | |||
2222 | static struct hda_verb cxt5066_init_verbs_olpc[] = { | ||
2223 | /* Port A: headphones */ | ||
2224 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
2225 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2226 | |||
2227 | /* Port B: external microphone */ | ||
2228 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
2229 | |||
2230 | /* Port C: internal microphone */ | ||
2231 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
2232 | |||
2233 | /* Port D: unused */ | ||
2234 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2235 | |||
2236 | /* Port E: unused, but has primary EAPD */ | ||
2237 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2238 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | ||
2239 | |||
2240 | /* Port F: unused */ | ||
2241 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2242 | |||
2243 | /* Port G: internal speakers */ | ||
2244 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2245 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2246 | |||
2247 | /* DAC1 */ | ||
2248 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
2249 | |||
2250 | /* DAC2: unused */ | ||
2251 | {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
2252 | |||
2253 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | ||
2254 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2255 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
2256 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2257 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
2258 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2259 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
2260 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2261 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
2262 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2263 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
2264 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2265 | |||
2266 | /* Disable digital microphone port */ | ||
2267 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2268 | |||
2269 | /* Audio input selectors */ | ||
2270 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3}, | ||
2271 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
2272 | |||
2273 | /* Disable SPDIF */ | ||
2274 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2275 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2276 | |||
2277 | /* enable unsolicited events for Port A and B */ | ||
2278 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | ||
2279 | {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | ||
2280 | { } /* end */ | ||
2281 | }; | ||
2282 | |||
2283 | static struct hda_verb cxt5066_init_verbs_portd_lo[] = { | ||
2284 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2285 | { } /* end */ | ||
2286 | }; | ||
2287 | |||
2288 | /* initialize jack-sensing, too */ | ||
2289 | static int cxt5066_init(struct hda_codec *codec) | ||
2290 | { | ||
2291 | snd_printdd("CXT5066: init\n"); | ||
2292 | conexant_init(codec); | ||
2293 | if (codec->patch_ops.unsol_event) { | ||
2294 | cxt5066_hp_automute(codec); | ||
2295 | cxt5066_automic(codec); | ||
2296 | } | ||
2297 | return 0; | ||
2298 | } | ||
2299 | |||
2300 | enum { | ||
2301 | CXT5066_LAPTOP, /* Laptops w/ EAPD support */ | ||
2302 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ | ||
2303 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ | ||
2304 | CXT5066_MODELS | ||
2305 | }; | ||
2306 | |||
2307 | static const char *cxt5066_models[CXT5066_MODELS] = { | ||
2308 | [CXT5066_LAPTOP] = "laptop", | ||
2309 | [CXT5066_DELL_LAPTOP] = "dell-laptop", | ||
2310 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", | ||
2311 | }; | ||
2312 | |||
2313 | static struct snd_pci_quirk cxt5066_cfg_tbl[] = { | ||
2314 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", | ||
2315 | CXT5066_LAPTOP), | ||
2316 | SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", | ||
2317 | CXT5066_DELL_LAPTOP), | ||
2318 | {} | ||
2319 | }; | ||
2320 | |||
2321 | static int patch_cxt5066(struct hda_codec *codec) | ||
2322 | { | ||
2323 | struct conexant_spec *spec; | ||
2324 | int board_config; | ||
2325 | |||
2326 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
2327 | if (!spec) | ||
2328 | return -ENOMEM; | ||
2329 | codec->spec = spec; | ||
2330 | |||
2331 | codec->patch_ops = conexant_patch_ops; | ||
2332 | codec->patch_ops.init = cxt5066_init; | ||
2333 | |||
2334 | spec->dell_automute = 0; | ||
2335 | spec->multiout.max_channels = 2; | ||
2336 | spec->multiout.num_dacs = ARRAY_SIZE(cxt5066_dac_nids); | ||
2337 | spec->multiout.dac_nids = cxt5066_dac_nids; | ||
2338 | spec->multiout.dig_out_nid = CXT5066_SPDIF_OUT; | ||
2339 | spec->num_adc_nids = 1; | ||
2340 | spec->adc_nids = cxt5066_adc_nids; | ||
2341 | spec->capsrc_nids = cxt5066_capsrc_nids; | ||
2342 | spec->input_mux = &cxt5066_capture_source; | ||
2343 | |||
2344 | spec->port_d_mode = PIN_HP; | ||
2345 | |||
2346 | spec->num_init_verbs = 1; | ||
2347 | spec->init_verbs[0] = cxt5066_init_verbs; | ||
2348 | spec->num_channel_mode = ARRAY_SIZE(cxt5066_modes); | ||
2349 | spec->channel_mode = cxt5066_modes; | ||
2350 | spec->cur_adc = 0; | ||
2351 | spec->cur_adc_idx = 0; | ||
2352 | |||
2353 | board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, | ||
2354 | cxt5066_models, cxt5066_cfg_tbl); | ||
2355 | switch (board_config) { | ||
2356 | default: | ||
2357 | case CXT5066_LAPTOP: | ||
2358 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | ||
2359 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | ||
2360 | break; | ||
2361 | case CXT5066_DELL_LAPTOP: | ||
2362 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | ||
2363 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | ||
2364 | |||
2365 | spec->port_d_mode = PIN_OUT; | ||
2366 | spec->init_verbs[spec->num_init_verbs] = cxt5066_init_verbs_portd_lo; | ||
2367 | spec->num_init_verbs++; | ||
2368 | spec->dell_automute = 1; | ||
2369 | break; | ||
2370 | case CXT5066_OLPC_XO_1_5: | ||
2371 | codec->patch_ops.unsol_event = cxt5066_unsol_event; | ||
2372 | spec->init_verbs[0] = cxt5066_init_verbs_olpc; | ||
2373 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | ||
2374 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | ||
2375 | spec->port_d_mode = 0; | ||
2376 | |||
2377 | /* no S/PDIF out */ | ||
2378 | spec->multiout.dig_out_nid = 0; | ||
2379 | |||
2380 | /* input source automatically selected */ | ||
2381 | spec->input_mux = NULL; | ||
2382 | break; | ||
2383 | } | ||
2384 | |||
2385 | return 0; | ||
2386 | } | ||
1911 | 2387 | ||
1912 | /* | 2388 | /* |
1913 | */ | 2389 | */ |
@@ -1919,12 +2395,15 @@ static struct hda_codec_preset snd_hda_preset_conexant[] = { | |||
1919 | .patch = patch_cxt5047 }, | 2395 | .patch = patch_cxt5047 }, |
1920 | { .id = 0x14f15051, .name = "CX20561 (Hermosa)", | 2396 | { .id = 0x14f15051, .name = "CX20561 (Hermosa)", |
1921 | .patch = patch_cxt5051 }, | 2397 | .patch = patch_cxt5051 }, |
2398 | { .id = 0x14f15066, .name = "CX20582 (Pebble)", | ||
2399 | .patch = patch_cxt5066 }, | ||
1922 | {} /* terminator */ | 2400 | {} /* terminator */ |
1923 | }; | 2401 | }; |
1924 | 2402 | ||
1925 | MODULE_ALIAS("snd-hda-codec-id:14f15045"); | 2403 | MODULE_ALIAS("snd-hda-codec-id:14f15045"); |
1926 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); | 2404 | MODULE_ALIAS("snd-hda-codec-id:14f15047"); |
1927 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); | 2405 | MODULE_ALIAS("snd-hda-codec-id:14f15051"); |
2406 | MODULE_ALIAS("snd-hda-codec-id:14f15066"); | ||
1928 | 2407 | ||
1929 | MODULE_LICENSE("GPL"); | 2408 | MODULE_LICENSE("GPL"); |
1930 | MODULE_DESCRIPTION("Conexant HD-audio codec"); | 2409 | MODULE_DESCRIPTION("Conexant HD-audio codec"); |
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c index fcc77fec4487..01a18ed475ac 100644 --- a/sound/pci/hda/patch_intelhdmi.c +++ b/sound/pci/hda/patch_intelhdmi.c | |||
@@ -33,8 +33,8 @@ | |||
33 | #include "hda_codec.h" | 33 | #include "hda_codec.h" |
34 | #include "hda_local.h" | 34 | #include "hda_local.h" |
35 | 35 | ||
36 | #define CVT_NID 0x02 /* audio converter */ | 36 | static hda_nid_t cvt_nid; /* audio converter */ |
37 | #define PIN_NID 0x03 /* HDMI output pin */ | 37 | static hda_nid_t pin_nid; /* HDMI output pin */ |
38 | 38 | ||
39 | #define INTEL_HDMI_EVENT_TAG 0x08 | 39 | #define INTEL_HDMI_EVENT_TAG 0x08 |
40 | 40 | ||
@@ -44,30 +44,6 @@ struct intel_hdmi_spec { | |||
44 | struct hdmi_eld sink_eld; | 44 | struct hdmi_eld sink_eld; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | static struct hda_verb pinout_enable_verb[] = { | ||
48 | {PIN_NID, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
49 | {} /* terminator */ | ||
50 | }; | ||
51 | |||
52 | static struct hda_verb unsolicited_response_verb[] = { | ||
53 | {PIN_NID, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | | ||
54 | INTEL_HDMI_EVENT_TAG}, | ||
55 | {} | ||
56 | }; | ||
57 | |||
58 | static struct hda_verb def_chan_map[] = { | ||
59 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x00}, | ||
60 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x11}, | ||
61 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x22}, | ||
62 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x33}, | ||
63 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x44}, | ||
64 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x55}, | ||
65 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x66}, | ||
66 | {CVT_NID, AC_VERB_SET_HDMI_CHAN_SLOT, 0x77}, | ||
67 | {} | ||
68 | }; | ||
69 | |||
70 | |||
71 | struct hdmi_audio_infoframe { | 47 | struct hdmi_audio_infoframe { |
72 | u8 type; /* 0x84 */ | 48 | u8 type; /* 0x84 */ |
73 | u8 ver; /* 0x01 */ | 49 | u8 ver; /* 0x01 */ |
@@ -244,11 +220,12 @@ static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t nid, | |||
244 | static void hdmi_enable_output(struct hda_codec *codec) | 220 | static void hdmi_enable_output(struct hda_codec *codec) |
245 | { | 221 | { |
246 | /* Unmute */ | 222 | /* Unmute */ |
247 | if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP) | 223 | if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) |
248 | snd_hda_codec_write(codec, PIN_NID, 0, | 224 | snd_hda_codec_write(codec, pin_nid, 0, |
249 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | 225 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); |
250 | /* Enable pin out */ | 226 | /* Enable pin out */ |
251 | snd_hda_sequence_write(codec, pinout_enable_verb); | 227 | snd_hda_codec_write(codec, pin_nid, 0, |
228 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
252 | } | 229 | } |
253 | 230 | ||
254 | /* | 231 | /* |
@@ -256,8 +233,8 @@ static void hdmi_enable_output(struct hda_codec *codec) | |||
256 | */ | 233 | */ |
257 | static void hdmi_start_infoframe_trans(struct hda_codec *codec) | 234 | static void hdmi_start_infoframe_trans(struct hda_codec *codec) |
258 | { | 235 | { |
259 | hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0); | 236 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
260 | snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT, | 237 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, |
261 | AC_DIPXMIT_BEST); | 238 | AC_DIPXMIT_BEST); |
262 | } | 239 | } |
263 | 240 | ||
@@ -266,20 +243,20 @@ static void hdmi_start_infoframe_trans(struct hda_codec *codec) | |||
266 | */ | 243 | */ |
267 | static void hdmi_stop_infoframe_trans(struct hda_codec *codec) | 244 | static void hdmi_stop_infoframe_trans(struct hda_codec *codec) |
268 | { | 245 | { |
269 | hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0); | 246 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
270 | snd_hda_codec_write(codec, PIN_NID, 0, AC_VERB_SET_HDMI_DIP_XMIT, | 247 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, |
271 | AC_DIPXMIT_DISABLE); | 248 | AC_DIPXMIT_DISABLE); |
272 | } | 249 | } |
273 | 250 | ||
274 | static int hdmi_get_channel_count(struct hda_codec *codec) | 251 | static int hdmi_get_channel_count(struct hda_codec *codec) |
275 | { | 252 | { |
276 | return 1 + snd_hda_codec_read(codec, CVT_NID, 0, | 253 | return 1 + snd_hda_codec_read(codec, cvt_nid, 0, |
277 | AC_VERB_GET_CVT_CHAN_COUNT, 0); | 254 | AC_VERB_GET_CVT_CHAN_COUNT, 0); |
278 | } | 255 | } |
279 | 256 | ||
280 | static void hdmi_set_channel_count(struct hda_codec *codec, int chs) | 257 | static void hdmi_set_channel_count(struct hda_codec *codec, int chs) |
281 | { | 258 | { |
282 | snd_hda_codec_write(codec, CVT_NID, 0, | 259 | snd_hda_codec_write(codec, cvt_nid, 0, |
283 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); | 260 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); |
284 | 261 | ||
285 | if (chs != hdmi_get_channel_count(codec)) | 262 | if (chs != hdmi_get_channel_count(codec)) |
@@ -294,7 +271,7 @@ static void hdmi_debug_channel_mapping(struct hda_codec *codec) | |||
294 | int slot; | 271 | int slot; |
295 | 272 | ||
296 | for (i = 0; i < 8; i++) { | 273 | for (i = 0; i < 8; i++) { |
297 | slot = snd_hda_codec_read(codec, CVT_NID, 0, | 274 | slot = snd_hda_codec_read(codec, cvt_nid, 0, |
298 | AC_VERB_GET_HDMI_CHAN_SLOT, i); | 275 | AC_VERB_GET_HDMI_CHAN_SLOT, i); |
299 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", | 276 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", |
300 | slot >> 4, slot & 0x7); | 277 | slot >> 4, slot & 0x7); |
@@ -307,7 +284,7 @@ static void hdmi_parse_eld(struct hda_codec *codec) | |||
307 | struct intel_hdmi_spec *spec = codec->spec; | 284 | struct intel_hdmi_spec *spec = codec->spec; |
308 | struct hdmi_eld *eld = &spec->sink_eld; | 285 | struct hdmi_eld *eld = &spec->sink_eld; |
309 | 286 | ||
310 | if (!snd_hdmi_get_eld(eld, codec, PIN_NID)) | 287 | if (!snd_hdmi_get_eld(eld, codec, pin_nid)) |
311 | snd_hdmi_show_eld(eld); | 288 | snd_hdmi_show_eld(eld); |
312 | } | 289 | } |
313 | 290 | ||
@@ -322,11 +299,11 @@ static void hdmi_debug_dip_size(struct hda_codec *codec) | |||
322 | int i; | 299 | int i; |
323 | int size; | 300 | int size; |
324 | 301 | ||
325 | size = snd_hdmi_get_eld_size(codec, PIN_NID); | 302 | size = snd_hdmi_get_eld_size(codec, pin_nid); |
326 | printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size); | 303 | printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size); |
327 | 304 | ||
328 | for (i = 0; i < 8; i++) { | 305 | for (i = 0; i < 8; i++) { |
329 | size = snd_hda_codec_read(codec, PIN_NID, 0, | 306 | size = snd_hda_codec_read(codec, pin_nid, 0, |
330 | AC_VERB_GET_HDMI_DIP_SIZE, i); | 307 | AC_VERB_GET_HDMI_DIP_SIZE, i); |
331 | printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size); | 308 | printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size); |
332 | } | 309 | } |
@@ -340,15 +317,15 @@ static void hdmi_clear_dip_buffers(struct hda_codec *codec) | |||
340 | int size; | 317 | int size; |
341 | int pi, bi; | 318 | int pi, bi; |
342 | for (i = 0; i < 8; i++) { | 319 | for (i = 0; i < 8; i++) { |
343 | size = snd_hda_codec_read(codec, PIN_NID, 0, | 320 | size = snd_hda_codec_read(codec, pin_nid, 0, |
344 | AC_VERB_GET_HDMI_DIP_SIZE, i); | 321 | AC_VERB_GET_HDMI_DIP_SIZE, i); |
345 | if (size == 0) | 322 | if (size == 0) |
346 | continue; | 323 | continue; |
347 | 324 | ||
348 | hdmi_set_dip_index(codec, PIN_NID, i, 0x0); | 325 | hdmi_set_dip_index(codec, pin_nid, i, 0x0); |
349 | for (j = 1; j < 1000; j++) { | 326 | for (j = 1; j < 1000; j++) { |
350 | hdmi_write_dip_byte(codec, PIN_NID, 0x0); | 327 | hdmi_write_dip_byte(codec, pin_nid, 0x0); |
351 | hdmi_get_dip_index(codec, PIN_NID, &pi, &bi); | 328 | hdmi_get_dip_index(codec, pin_nid, &pi, &bi); |
352 | if (pi != i) | 329 | if (pi != i) |
353 | snd_printd(KERN_INFO "dip index %d: %d != %d\n", | 330 | snd_printd(KERN_INFO "dip index %d: %d != %d\n", |
354 | bi, pi, i); | 331 | bi, pi, i); |
@@ -376,9 +353,9 @@ static void hdmi_fill_audio_infoframe(struct hda_codec *codec, | |||
376 | sum += params[i]; | 353 | sum += params[i]; |
377 | ai->checksum = - sum; | 354 | ai->checksum = - sum; |
378 | 355 | ||
379 | hdmi_set_dip_index(codec, PIN_NID, 0x0, 0x0); | 356 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); |
380 | for (i = 0; i < sizeof(ai); i++) | 357 | for (i = 0; i < sizeof(ai); i++) |
381 | hdmi_write_dip_byte(codec, PIN_NID, params[i]); | 358 | hdmi_write_dip_byte(codec, pin_nid, params[i]); |
382 | } | 359 | } |
383 | 360 | ||
384 | /* | 361 | /* |
@@ -465,6 +442,8 @@ static int hdmi_setup_channel_allocation(struct hda_codec *codec, | |||
465 | static void hdmi_setup_channel_mapping(struct hda_codec *codec, | 442 | static void hdmi_setup_channel_mapping(struct hda_codec *codec, |
466 | struct hdmi_audio_infoframe *ai) | 443 | struct hdmi_audio_infoframe *ai) |
467 | { | 444 | { |
445 | int i; | ||
446 | |||
468 | if (!ai->CA) | 447 | if (!ai->CA) |
469 | return; | 448 | return; |
470 | 449 | ||
@@ -473,7 +452,11 @@ static void hdmi_setup_channel_mapping(struct hda_codec *codec, | |||
473 | * ALSA sequence is front/surr/clfe/side? | 452 | * ALSA sequence is front/surr/clfe/side? |
474 | */ | 453 | */ |
475 | 454 | ||
476 | snd_hda_sequence_write(codec, def_chan_map); | 455 | for (i = 0; i < 8; i++) |
456 | snd_hda_codec_write(codec, cvt_nid, 0, | ||
457 | AC_VERB_SET_HDMI_CHAN_SLOT, | ||
458 | (i << 4) | i); | ||
459 | |||
477 | hdmi_debug_channel_mapping(codec); | 460 | hdmi_debug_channel_mapping(codec); |
478 | } | 461 | } |
479 | 462 | ||
@@ -597,7 +580,6 @@ static struct hda_pcm_stream intel_hdmi_pcm_playback = { | |||
597 | .substreams = 1, | 580 | .substreams = 1, |
598 | .channels_min = 2, | 581 | .channels_min = 2, |
599 | .channels_max = 8, | 582 | .channels_max = 8, |
600 | .nid = CVT_NID, /* NID to query formats and rates and setup streams */ | ||
601 | .ops = { | 583 | .ops = { |
602 | .open = intel_hdmi_playback_pcm_open, | 584 | .open = intel_hdmi_playback_pcm_open, |
603 | .close = intel_hdmi_playback_pcm_close, | 585 | .close = intel_hdmi_playback_pcm_close, |
@@ -613,6 +595,9 @@ static int intel_hdmi_build_pcms(struct hda_codec *codec) | |||
613 | codec->num_pcms = 1; | 595 | codec->num_pcms = 1; |
614 | codec->pcm_info = info; | 596 | codec->pcm_info = info; |
615 | 597 | ||
598 | /* NID to query formats and rates and setup streams */ | ||
599 | intel_hdmi_pcm_playback.nid = cvt_nid; | ||
600 | |||
616 | info->name = "INTEL HDMI"; | 601 | info->name = "INTEL HDMI"; |
617 | info->pcm_type = HDA_PCM_TYPE_HDMI; | 602 | info->pcm_type = HDA_PCM_TYPE_HDMI; |
618 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = intel_hdmi_pcm_playback; | 603 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = intel_hdmi_pcm_playback; |
@@ -636,8 +621,9 @@ static int intel_hdmi_init(struct hda_codec *codec) | |||
636 | { | 621 | { |
637 | hdmi_enable_output(codec); | 622 | hdmi_enable_output(codec); |
638 | 623 | ||
639 | snd_hda_sequence_write(codec, unsolicited_response_verb); | 624 | snd_hda_codec_write(codec, pin_nid, 0, |
640 | 625 | AC_VERB_SET_UNSOLICITED_ENABLE, | |
626 | AC_USRSP_EN | INTEL_HDMI_EVENT_TAG); | ||
641 | return 0; | 627 | return 0; |
642 | } | 628 | } |
643 | 629 | ||
@@ -657,7 +643,7 @@ static struct hda_codec_ops intel_hdmi_patch_ops = { | |||
657 | .unsol_event = intel_hdmi_unsol_event, | 643 | .unsol_event = intel_hdmi_unsol_event, |
658 | }; | 644 | }; |
659 | 645 | ||
660 | static int patch_intel_hdmi(struct hda_codec *codec) | 646 | static int do_patch_intel_hdmi(struct hda_codec *codec) |
661 | { | 647 | { |
662 | struct intel_hdmi_spec *spec; | 648 | struct intel_hdmi_spec *spec; |
663 | 649 | ||
@@ -667,7 +653,7 @@ static int patch_intel_hdmi(struct hda_codec *codec) | |||
667 | 653 | ||
668 | spec->multiout.num_dacs = 0; /* no analog */ | 654 | spec->multiout.num_dacs = 0; /* no analog */ |
669 | spec->multiout.max_channels = 8; | 655 | spec->multiout.max_channels = 8; |
670 | spec->multiout.dig_out_nid = CVT_NID; | 656 | spec->multiout.dig_out_nid = cvt_nid; |
671 | 657 | ||
672 | codec->spec = spec; | 658 | codec->spec = spec; |
673 | codec->patch_ops = intel_hdmi_patch_ops; | 659 | codec->patch_ops = intel_hdmi_patch_ops; |
@@ -679,12 +665,27 @@ static int patch_intel_hdmi(struct hda_codec *codec) | |||
679 | return 0; | 665 | return 0; |
680 | } | 666 | } |
681 | 667 | ||
668 | static int patch_intel_hdmi(struct hda_codec *codec) | ||
669 | { | ||
670 | cvt_nid = 0x02; | ||
671 | pin_nid = 0x03; | ||
672 | return do_patch_intel_hdmi(codec); | ||
673 | } | ||
674 | |||
675 | static int patch_intel_hdmi_ibexpeak(struct hda_codec *codec) | ||
676 | { | ||
677 | cvt_nid = 0x02; | ||
678 | pin_nid = 0x04; | ||
679 | return do_patch_intel_hdmi(codec); | ||
680 | } | ||
681 | |||
682 | static struct hda_codec_preset snd_hda_preset_intelhdmi[] = { | 682 | static struct hda_codec_preset snd_hda_preset_intelhdmi[] = { |
683 | { .id = 0x808629fb, .name = "G45 DEVCL", .patch = patch_intel_hdmi }, | 683 | { .id = 0x808629fb, .name = "G45 DEVCL", .patch = patch_intel_hdmi }, |
684 | { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi }, | 684 | { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi }, |
685 | { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi }, | 685 | { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi }, |
686 | { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi }, | 686 | { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi }, |
687 | { .id = 0x80862804, .name = "G45 DEVIBX", .patch = patch_intel_hdmi }, | 687 | { .id = 0x80862804, .name = "G45 DEVIBX", .patch = patch_intel_hdmi }, |
688 | { .id = 0x80860054, .name = "Q57 DEVIBX", .patch = patch_intel_hdmi_ibexpeak }, | ||
688 | { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, | 689 | { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, |
689 | {} /* terminator */ | 690 | {} /* terminator */ |
690 | }; | 691 | }; |
@@ -694,6 +695,7 @@ MODULE_ALIAS("snd-hda-codec-id:80862801"); | |||
694 | MODULE_ALIAS("snd-hda-codec-id:80862802"); | 695 | MODULE_ALIAS("snd-hda-codec-id:80862802"); |
695 | MODULE_ALIAS("snd-hda-codec-id:80862803"); | 696 | MODULE_ALIAS("snd-hda-codec-id:80862803"); |
696 | MODULE_ALIAS("snd-hda-codec-id:80862804"); | 697 | MODULE_ALIAS("snd-hda-codec-id:80862804"); |
698 | MODULE_ALIAS("snd-hda-codec-id:80860054"); | ||
697 | MODULE_ALIAS("snd-hda-codec-id:10951392"); | 699 | MODULE_ALIAS("snd-hda-codec-id:10951392"); |
698 | 700 | ||
699 | MODULE_LICENSE("GPL"); | 701 | MODULE_LICENSE("GPL"); |
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index f5792e2eea82..c8435c9a97f9 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c | |||
@@ -377,6 +377,7 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec) | |||
377 | */ | 377 | */ |
378 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { | 378 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { |
379 | { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | 379 | { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, |
380 | { .id = 0x10de0003, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | ||
380 | { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | 381 | { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, |
381 | { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch }, | 382 | { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch }, |
382 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, | 383 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, |
@@ -385,6 +386,7 @@ static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { | |||
385 | }; | 386 | }; |
386 | 387 | ||
387 | MODULE_ALIAS("snd-hda-codec-id:10de0002"); | 388 | MODULE_ALIAS("snd-hda-codec-id:10de0002"); |
389 | MODULE_ALIAS("snd-hda-codec-id:10de0003"); | ||
388 | MODULE_ALIAS("snd-hda-codec-id:10de0006"); | 390 | MODULE_ALIAS("snd-hda-codec-id:10de0006"); |
389 | MODULE_ALIAS("snd-hda-codec-id:10de0007"); | 391 | MODULE_ALIAS("snd-hda-codec-id:10de0007"); |
390 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); | 392 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 334533197425..7ed47f66ddd1 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -208,12 +208,6 @@ enum { | |||
208 | ALC885_MBP3, | 208 | ALC885_MBP3, |
209 | ALC885_MB5, | 209 | ALC885_MB5, |
210 | ALC885_IMAC24, | 210 | ALC885_IMAC24, |
211 | ALC882_AUTO, | ||
212 | ALC882_MODEL_LAST, | ||
213 | }; | ||
214 | |||
215 | /* ALC883 models */ | ||
216 | enum { | ||
217 | ALC883_3ST_2ch_DIG, | 211 | ALC883_3ST_2ch_DIG, |
218 | ALC883_3ST_6ch_DIG, | 212 | ALC883_3ST_6ch_DIG, |
219 | ALC883_3ST_6ch, | 213 | ALC883_3ST_6ch, |
@@ -226,6 +220,7 @@ enum { | |||
226 | ALC888_ACER_ASPIRE_4930G, | 220 | ALC888_ACER_ASPIRE_4930G, |
227 | ALC888_ACER_ASPIRE_6530G, | 221 | ALC888_ACER_ASPIRE_6530G, |
228 | ALC888_ACER_ASPIRE_8930G, | 222 | ALC888_ACER_ASPIRE_8930G, |
223 | ALC888_ACER_ASPIRE_7730G, | ||
229 | ALC883_MEDION, | 224 | ALC883_MEDION, |
230 | ALC883_MEDION_MD2, | 225 | ALC883_MEDION_MD2, |
231 | ALC883_LAPTOP_EAPD, | 226 | ALC883_LAPTOP_EAPD, |
@@ -237,17 +232,20 @@ enum { | |||
237 | ALC888_3ST_HP, | 232 | ALC888_3ST_HP, |
238 | ALC888_6ST_DELL, | 233 | ALC888_6ST_DELL, |
239 | ALC883_MITAC, | 234 | ALC883_MITAC, |
235 | ALC883_CLEVO_M540R, | ||
240 | ALC883_CLEVO_M720, | 236 | ALC883_CLEVO_M720, |
241 | ALC883_FUJITSU_PI2515, | 237 | ALC883_FUJITSU_PI2515, |
242 | ALC888_FUJITSU_XA3530, | 238 | ALC888_FUJITSU_XA3530, |
243 | ALC883_3ST_6ch_INTEL, | 239 | ALC883_3ST_6ch_INTEL, |
240 | ALC889A_INTEL, | ||
241 | ALC889_INTEL, | ||
244 | ALC888_ASUS_M90V, | 242 | ALC888_ASUS_M90V, |
245 | ALC888_ASUS_EEE1601, | 243 | ALC888_ASUS_EEE1601, |
246 | ALC889A_MB31, | 244 | ALC889A_MB31, |
247 | ALC1200_ASUS_P5Q, | 245 | ALC1200_ASUS_P5Q, |
248 | ALC883_SONY_VAIO_TT, | 246 | ALC883_SONY_VAIO_TT, |
249 | ALC883_AUTO, | 247 | ALC882_AUTO, |
250 | ALC883_MODEL_LAST, | 248 | ALC882_MODEL_LAST, |
251 | }; | 249 | }; |
252 | 250 | ||
253 | /* for GPIO Poll */ | 251 | /* for GPIO Poll */ |
@@ -262,6 +260,14 @@ enum { | |||
262 | ALC_INIT_GPIO3, | 260 | ALC_INIT_GPIO3, |
263 | }; | 261 | }; |
264 | 262 | ||
263 | struct alc_mic_route { | ||
264 | hda_nid_t pin; | ||
265 | unsigned char mux_idx; | ||
266 | unsigned char amix_idx; | ||
267 | }; | ||
268 | |||
269 | #define MUX_IDX_UNDEF ((unsigned char)-1) | ||
270 | |||
265 | struct alc_spec { | 271 | struct alc_spec { |
266 | /* codec parameterization */ | 272 | /* codec parameterization */ |
267 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ | 273 | struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
@@ -275,13 +281,13 @@ struct alc_spec { | |||
275 | */ | 281 | */ |
276 | unsigned int num_init_verbs; | 282 | unsigned int num_init_verbs; |
277 | 283 | ||
278 | char stream_name_analog[16]; /* analog PCM stream */ | 284 | char stream_name_analog[32]; /* analog PCM stream */ |
279 | struct hda_pcm_stream *stream_analog_playback; | 285 | struct hda_pcm_stream *stream_analog_playback; |
280 | struct hda_pcm_stream *stream_analog_capture; | 286 | struct hda_pcm_stream *stream_analog_capture; |
281 | struct hda_pcm_stream *stream_analog_alt_playback; | 287 | struct hda_pcm_stream *stream_analog_alt_playback; |
282 | struct hda_pcm_stream *stream_analog_alt_capture; | 288 | struct hda_pcm_stream *stream_analog_alt_capture; |
283 | 289 | ||
284 | char stream_name_digital[16]; /* digital PCM stream */ | 290 | char stream_name_digital[32]; /* digital PCM stream */ |
285 | struct hda_pcm_stream *stream_digital_playback; | 291 | struct hda_pcm_stream *stream_digital_playback; |
286 | struct hda_pcm_stream *stream_digital_capture; | 292 | struct hda_pcm_stream *stream_digital_capture; |
287 | 293 | ||
@@ -304,6 +310,8 @@ struct alc_spec { | |||
304 | unsigned int num_mux_defs; | 310 | unsigned int num_mux_defs; |
305 | const struct hda_input_mux *input_mux; | 311 | const struct hda_input_mux *input_mux; |
306 | unsigned int cur_mux[3]; | 312 | unsigned int cur_mux[3]; |
313 | struct alc_mic_route ext_mic; | ||
314 | struct alc_mic_route int_mic; | ||
307 | 315 | ||
308 | /* channel model */ | 316 | /* channel model */ |
309 | const struct hda_channel_mode *channel_mode; | 317 | const struct hda_channel_mode *channel_mode; |
@@ -320,6 +328,8 @@ struct alc_spec { | |||
320 | struct snd_array kctls; | 328 | struct snd_array kctls; |
321 | struct hda_input_mux private_imux[3]; | 329 | struct hda_input_mux private_imux[3]; |
322 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; | 330 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
331 | hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; | ||
332 | hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; | ||
323 | 333 | ||
324 | /* hooks */ | 334 | /* hooks */ |
325 | void (*init_hook)(struct hda_codec *codec); | 335 | void (*init_hook)(struct hda_codec *codec); |
@@ -329,6 +339,7 @@ struct alc_spec { | |||
329 | unsigned int sense_updated: 1; | 339 | unsigned int sense_updated: 1; |
330 | unsigned int jack_present: 1; | 340 | unsigned int jack_present: 1; |
331 | unsigned int master_sw: 1; | 341 | unsigned int master_sw: 1; |
342 | unsigned int auto_mic:1; | ||
332 | 343 | ||
333 | /* other flags */ | 344 | /* other flags */ |
334 | unsigned int no_analog :1; /* digital I/O only */ | 345 | unsigned int no_analog :1; /* digital I/O only */ |
@@ -370,6 +381,7 @@ struct alc_config_preset { | |||
370 | unsigned int num_mux_defs; | 381 | unsigned int num_mux_defs; |
371 | const struct hda_input_mux *input_mux; | 382 | const struct hda_input_mux *input_mux; |
372 | void (*unsol_event)(struct hda_codec *, unsigned int); | 383 | void (*unsol_event)(struct hda_codec *, unsigned int); |
384 | void (*setup)(struct hda_codec *); | ||
373 | void (*init_hook)(struct hda_codec *); | 385 | void (*init_hook)(struct hda_codec *); |
374 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 386 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
375 | struct hda_amp_list *loopbacks; | 387 | struct hda_amp_list *loopbacks; |
@@ -417,7 +429,7 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
417 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; | 429 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
418 | imux = &spec->input_mux[mux_idx]; | 430 | imux = &spec->input_mux[mux_idx]; |
419 | 431 | ||
420 | type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 432 | type = get_wcaps_type(get_wcaps(codec, nid)); |
421 | if (type == AC_WID_AUD_MIX) { | 433 | if (type == AC_WID_AUD_MIX) { |
422 | /* Matrix-mixer style (e.g. ALC882) */ | 434 | /* Matrix-mixer style (e.g. ALC882) */ |
423 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | 435 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; |
@@ -559,7 +571,7 @@ static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, | |||
559 | 571 | ||
560 | /* Find enumerated value for current pinctl setting */ | 572 | /* Find enumerated value for current pinctl setting */ |
561 | i = alc_pin_mode_min(dir); | 573 | i = alc_pin_mode_min(dir); |
562 | while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) | 574 | while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl) |
563 | i++; | 575 | i++; |
564 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); | 576 | *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); |
565 | return 0; | 577 | return 0; |
@@ -842,9 +854,10 @@ static void print_realtek_coef(struct snd_info_buffer *buffer, | |||
842 | /* | 854 | /* |
843 | * set up from the preset table | 855 | * set up from the preset table |
844 | */ | 856 | */ |
845 | static void setup_preset(struct alc_spec *spec, | 857 | static void setup_preset(struct hda_codec *codec, |
846 | const struct alc_config_preset *preset) | 858 | const struct alc_config_preset *preset) |
847 | { | 859 | { |
860 | struct alc_spec *spec = codec->spec; | ||
848 | int i; | 861 | int i; |
849 | 862 | ||
850 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) | 863 | for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) |
@@ -886,6 +899,9 @@ static void setup_preset(struct alc_spec *spec, | |||
886 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 899 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
887 | spec->loopback.amplist = preset->loopbacks; | 900 | spec->loopback.amplist = preset->loopbacks; |
888 | #endif | 901 | #endif |
902 | |||
903 | if (preset->setup) | ||
904 | preset->setup(codec); | ||
889 | } | 905 | } |
890 | 906 | ||
891 | /* Enable GPIO mask and set output */ | 907 | /* Enable GPIO mask and set output */ |
@@ -945,12 +961,13 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, | |||
945 | static void alc_automute_pin(struct hda_codec *codec) | 961 | static void alc_automute_pin(struct hda_codec *codec) |
946 | { | 962 | { |
947 | struct alc_spec *spec = codec->spec; | 963 | struct alc_spec *spec = codec->spec; |
948 | unsigned int present; | 964 | unsigned int present, pincap; |
949 | unsigned int nid = spec->autocfg.hp_pins[0]; | 965 | unsigned int nid = spec->autocfg.hp_pins[0]; |
950 | int i; | 966 | int i; |
951 | 967 | ||
952 | /* need to execute and sync at first */ | 968 | pincap = snd_hda_query_pin_caps(codec, nid); |
953 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); | 969 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ |
970 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); | ||
954 | present = snd_hda_codec_read(codec, nid, 0, | 971 | present = snd_hda_codec_read(codec, nid, 0, |
955 | AC_VERB_GET_PIN_SENSE, 0); | 972 | AC_VERB_GET_PIN_SENSE, 0); |
956 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; | 973 | spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0; |
@@ -964,30 +981,64 @@ static void alc_automute_pin(struct hda_codec *codec) | |||
964 | } | 981 | } |
965 | } | 982 | } |
966 | 983 | ||
967 | #if 0 /* it's broken in some cases -- temporarily disabled */ | 984 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, |
985 | hda_nid_t nid) | ||
986 | { | ||
987 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; | ||
988 | int i, nums; | ||
989 | |||
990 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); | ||
991 | for (i = 0; i < nums; i++) | ||
992 | if (conn[i] == nid) | ||
993 | return i; | ||
994 | return -1; | ||
995 | } | ||
996 | |||
968 | static void alc_mic_automute(struct hda_codec *codec) | 997 | static void alc_mic_automute(struct hda_codec *codec) |
969 | { | 998 | { |
970 | struct alc_spec *spec = codec->spec; | 999 | struct alc_spec *spec = codec->spec; |
971 | unsigned int present; | 1000 | struct alc_mic_route *dead, *alive; |
972 | unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | 1001 | unsigned int present, type; |
973 | unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | 1002 | hda_nid_t cap_nid; |
974 | unsigned int mix_nid = spec->capsrc_nids[0]; | 1003 | |
975 | unsigned int capsrc_idx_mic, capsrc_idx_fmic; | 1004 | if (!spec->auto_mic) |
976 | 1005 | return; | |
977 | capsrc_idx_mic = mic_nid - 0x18; | 1006 | if (!spec->int_mic.pin || !spec->ext_mic.pin) |
978 | capsrc_idx_fmic = fmic_nid - 0x18; | 1007 | return; |
979 | present = snd_hda_codec_read(codec, mic_nid, 0, | 1008 | if (snd_BUG_ON(!spec->adc_nids)) |
980 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 1009 | return; |
981 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 1010 | |
982 | 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80)); | 1011 | cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0]; |
983 | snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 1012 | |
984 | 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0)); | 1013 | present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0, |
985 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic, | 1014 | AC_VERB_GET_PIN_SENSE, 0); |
986 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 1015 | present &= AC_PINSENSE_PRESENCE; |
1016 | if (present) { | ||
1017 | alive = &spec->ext_mic; | ||
1018 | dead = &spec->int_mic; | ||
1019 | } else { | ||
1020 | alive = &spec->int_mic; | ||
1021 | dead = &spec->ext_mic; | ||
1022 | } | ||
1023 | |||
1024 | type = get_wcaps_type(get_wcaps(codec, cap_nid)); | ||
1025 | if (type == AC_WID_AUD_MIX) { | ||
1026 | /* Matrix-mixer style (e.g. ALC882) */ | ||
1027 | snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT, | ||
1028 | alive->mux_idx, | ||
1029 | HDA_AMP_MUTE, 0); | ||
1030 | snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT, | ||
1031 | dead->mux_idx, | ||
1032 | HDA_AMP_MUTE, HDA_AMP_MUTE); | ||
1033 | } else { | ||
1034 | /* MUX style (e.g. ALC880) */ | ||
1035 | snd_hda_codec_write_cache(codec, cap_nid, 0, | ||
1036 | AC_VERB_SET_CONNECT_SEL, | ||
1037 | alive->mux_idx); | ||
1038 | } | ||
1039 | |||
1040 | /* FIXME: analog mixer */ | ||
987 | } | 1041 | } |
988 | #else | ||
989 | #define alc_mic_automute(codec) do {} while(0) /* NOP */ | ||
990 | #endif /* disabled */ | ||
991 | 1042 | ||
992 | /* unsolicited event for HP jack sensing */ | 1043 | /* unsolicited event for HP jack sensing */ |
993 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) | 1044 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) |
@@ -1030,6 +1081,16 @@ static void alc888_coef_init(struct hda_codec *codec) | |||
1030 | AC_VERB_SET_PROC_COEF, 0x3030); | 1081 | AC_VERB_SET_PROC_COEF, 0x3030); |
1031 | } | 1082 | } |
1032 | 1083 | ||
1084 | static void alc889_coef_init(struct hda_codec *codec) | ||
1085 | { | ||
1086 | unsigned int tmp; | ||
1087 | |||
1088 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | ||
1089 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); | ||
1090 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); | ||
1091 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); | ||
1092 | } | ||
1093 | |||
1033 | static void alc_auto_init_amp(struct hda_codec *codec, int type) | 1094 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
1034 | { | 1095 | { |
1035 | unsigned int tmp; | 1096 | unsigned int tmp; |
@@ -1087,15 +1148,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type) | |||
1087 | case 0x10ec0885: | 1148 | case 0x10ec0885: |
1088 | case 0x10ec0887: | 1149 | case 0x10ec0887: |
1089 | case 0x10ec0889: | 1150 | case 0x10ec0889: |
1090 | snd_hda_codec_write(codec, 0x20, 0, | 1151 | alc889_coef_init(codec); |
1091 | AC_VERB_SET_COEF_INDEX, 7); | ||
1092 | tmp = snd_hda_codec_read(codec, 0x20, 0, | ||
1093 | AC_VERB_GET_PROC_COEF, 0); | ||
1094 | snd_hda_codec_write(codec, 0x20, 0, | ||
1095 | AC_VERB_SET_COEF_INDEX, 7); | ||
1096 | snd_hda_codec_write(codec, 0x20, 0, | ||
1097 | AC_VERB_SET_PROC_COEF, | ||
1098 | tmp | 0x2010); | ||
1099 | break; | 1152 | break; |
1100 | case 0x10ec0888: | 1153 | case 0x10ec0888: |
1101 | alc888_coef_init(codec); | 1154 | alc888_coef_init(codec); |
@@ -1141,6 +1194,55 @@ static void alc_init_auto_hp(struct hda_codec *codec) | |||
1141 | spec->unsol_event = alc_sku_unsol_event; | 1194 | spec->unsol_event = alc_sku_unsol_event; |
1142 | } | 1195 | } |
1143 | 1196 | ||
1197 | static void alc_init_auto_mic(struct hda_codec *codec) | ||
1198 | { | ||
1199 | struct alc_spec *spec = codec->spec; | ||
1200 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
1201 | hda_nid_t fixed, ext; | ||
1202 | int i; | ||
1203 | |||
1204 | /* there must be only two mic inputs exclusively */ | ||
1205 | for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) | ||
1206 | if (cfg->input_pins[i]) | ||
1207 | return; | ||
1208 | |||
1209 | fixed = ext = 0; | ||
1210 | for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) { | ||
1211 | hda_nid_t nid = cfg->input_pins[i]; | ||
1212 | unsigned int defcfg; | ||
1213 | if (!nid) | ||
1214 | return; | ||
1215 | defcfg = snd_hda_codec_get_pincfg(codec, nid); | ||
1216 | switch (get_defcfg_connect(defcfg)) { | ||
1217 | case AC_JACK_PORT_FIXED: | ||
1218 | if (fixed) | ||
1219 | return; /* already occupied */ | ||
1220 | fixed = nid; | ||
1221 | break; | ||
1222 | case AC_JACK_PORT_COMPLEX: | ||
1223 | if (ext) | ||
1224 | return; /* already occupied */ | ||
1225 | ext = nid; | ||
1226 | break; | ||
1227 | default: | ||
1228 | return; /* invalid entry */ | ||
1229 | } | ||
1230 | } | ||
1231 | if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) | ||
1232 | return; /* no unsol support */ | ||
1233 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n", | ||
1234 | ext, fixed); | ||
1235 | spec->ext_mic.pin = ext; | ||
1236 | spec->int_mic.pin = fixed; | ||
1237 | spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */ | ||
1238 | spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */ | ||
1239 | spec->auto_mic = 1; | ||
1240 | snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0, | ||
1241 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
1242 | AC_USRSP_EN | ALC880_MIC_EVENT); | ||
1243 | spec->unsol_event = alc_sku_unsol_event; | ||
1244 | } | ||
1245 | |||
1144 | /* check subsystem ID and set up device-specific initialization; | 1246 | /* check subsystem ID and set up device-specific initialization; |
1145 | * return 1 if initialized, 0 if invalid SSID | 1247 | * return 1 if initialized, 0 if invalid SSID |
1146 | */ | 1248 | */ |
@@ -1242,6 +1344,7 @@ do_sku: | |||
1242 | } | 1344 | } |
1243 | 1345 | ||
1244 | alc_init_auto_hp(codec); | 1346 | alc_init_auto_hp(codec); |
1347 | alc_init_auto_mic(codec); | ||
1245 | return 1; | 1348 | return 1; |
1246 | } | 1349 | } |
1247 | 1350 | ||
@@ -1254,6 +1357,7 @@ static void alc_ssid_check(struct hda_codec *codec, | |||
1254 | "Enable default setup for auto mode as fallback\n"); | 1357 | "Enable default setup for auto mode as fallback\n"); |
1255 | spec->init_amp = ALC_INIT_DEFAULT; | 1358 | spec->init_amp = ALC_INIT_DEFAULT; |
1256 | alc_init_auto_hp(codec); | 1359 | alc_init_auto_hp(codec); |
1360 | alc_init_auto_mic(codec); | ||
1257 | } | 1361 | } |
1258 | } | 1362 | } |
1259 | 1363 | ||
@@ -1392,7 +1496,7 @@ static struct hda_verb alc888_fujitsu_xa3530_verbs[] = { | |||
1392 | static void alc_automute_amp(struct hda_codec *codec) | 1496 | static void alc_automute_amp(struct hda_codec *codec) |
1393 | { | 1497 | { |
1394 | struct alc_spec *spec = codec->spec; | 1498 | struct alc_spec *spec = codec->spec; |
1395 | unsigned int val, mute; | 1499 | unsigned int val, mute, pincap; |
1396 | hda_nid_t nid; | 1500 | hda_nid_t nid; |
1397 | int i; | 1501 | int i; |
1398 | 1502 | ||
@@ -1401,6 +1505,10 @@ static void alc_automute_amp(struct hda_codec *codec) | |||
1401 | nid = spec->autocfg.hp_pins[i]; | 1505 | nid = spec->autocfg.hp_pins[i]; |
1402 | if (!nid) | 1506 | if (!nid) |
1403 | break; | 1507 | break; |
1508 | pincap = snd_hda_query_pin_caps(codec, nid); | ||
1509 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ | ||
1510 | snd_hda_codec_read(codec, nid, 0, | ||
1511 | AC_VERB_SET_PIN_SENSE, 0); | ||
1404 | val = snd_hda_codec_read(codec, nid, 0, | 1512 | val = snd_hda_codec_read(codec, nid, 0, |
1405 | AC_VERB_GET_PIN_SENSE, 0); | 1513 | AC_VERB_GET_PIN_SENSE, 0); |
1406 | if (val & AC_PINSENSE_PRESENCE) { | 1514 | if (val & AC_PINSENSE_PRESENCE) { |
@@ -1431,7 +1539,25 @@ static void alc_automute_amp_unsol_event(struct hda_codec *codec, | |||
1431 | alc_automute_amp(codec); | 1539 | alc_automute_amp(codec); |
1432 | } | 1540 | } |
1433 | 1541 | ||
1434 | static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec) | 1542 | static void alc889_automute_setup(struct hda_codec *codec) |
1543 | { | ||
1544 | struct alc_spec *spec = codec->spec; | ||
1545 | |||
1546 | spec->autocfg.hp_pins[0] = 0x15; | ||
1547 | spec->autocfg.speaker_pins[0] = 0x14; | ||
1548 | spec->autocfg.speaker_pins[1] = 0x16; | ||
1549 | spec->autocfg.speaker_pins[2] = 0x17; | ||
1550 | spec->autocfg.speaker_pins[3] = 0x19; | ||
1551 | spec->autocfg.speaker_pins[4] = 0x1a; | ||
1552 | } | ||
1553 | |||
1554 | static void alc889_intel_init_hook(struct hda_codec *codec) | ||
1555 | { | ||
1556 | alc889_coef_init(codec); | ||
1557 | alc_automute_amp(codec); | ||
1558 | } | ||
1559 | |||
1560 | static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec) | ||
1435 | { | 1561 | { |
1436 | struct alc_spec *spec = codec->spec; | 1562 | struct alc_spec *spec = codec->spec; |
1437 | 1563 | ||
@@ -1439,7 +1565,6 @@ static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec) | |||
1439 | spec->autocfg.hp_pins[1] = 0x1b; /* hp */ | 1565 | spec->autocfg.hp_pins[1] = 0x1b; /* hp */ |
1440 | spec->autocfg.speaker_pins[0] = 0x14; /* speaker */ | 1566 | spec->autocfg.speaker_pins[0] = 0x14; /* speaker */ |
1441 | spec->autocfg.speaker_pins[1] = 0x15; /* bass */ | 1567 | spec->autocfg.speaker_pins[1] = 0x15; /* bass */ |
1442 | alc_automute_amp(codec); | ||
1443 | } | 1568 | } |
1444 | 1569 | ||
1445 | /* | 1570 | /* |
@@ -1471,6 +1596,10 @@ static struct hda_verb alc888_acer_aspire_4930g_verbs[] = { | |||
1471 | static struct hda_verb alc888_acer_aspire_6530g_verbs[] = { | 1596 | static struct hda_verb alc888_acer_aspire_6530g_verbs[] = { |
1472 | /* Bias voltage on for external mic port */ | 1597 | /* Bias voltage on for external mic port */ |
1473 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80}, | 1598 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80}, |
1599 | /* Front Mic: set to PIN_IN (empty by default) */ | ||
1600 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
1601 | /* Unselect Front Mic by default in input mixer 3 */ | ||
1602 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)}, | ||
1474 | /* Enable unsolicited event for HP jack */ | 1603 | /* Enable unsolicited event for HP jack */ |
1475 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | 1604 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
1476 | /* Enable speaker output */ | 1605 | /* Enable speaker output */ |
@@ -1560,18 +1689,22 @@ static struct hda_input_mux alc888_2_capture_sources[2] = { | |||
1560 | static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = { | 1689 | static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = { |
1561 | /* Interal mic only available on one ADC */ | 1690 | /* Interal mic only available on one ADC */ |
1562 | { | 1691 | { |
1563 | .num_items = 3, | 1692 | .num_items = 5, |
1564 | .items = { | 1693 | .items = { |
1565 | { "Ext Mic", 0x0 }, | 1694 | { "Ext Mic", 0x0 }, |
1695 | { "Line In", 0x2 }, | ||
1566 | { "CD", 0x4 }, | 1696 | { "CD", 0x4 }, |
1697 | { "Input Mix", 0xa }, | ||
1567 | { "Int Mic", 0xb }, | 1698 | { "Int Mic", 0xb }, |
1568 | }, | 1699 | }, |
1569 | }, | 1700 | }, |
1570 | { | 1701 | { |
1571 | .num_items = 2, | 1702 | .num_items = 4, |
1572 | .items = { | 1703 | .items = { |
1573 | { "Ext Mic", 0x0 }, | 1704 | { "Ext Mic", 0x0 }, |
1705 | { "Line In", 0x2 }, | ||
1574 | { "CD", 0x4 }, | 1706 | { "CD", 0x4 }, |
1707 | { "Input Mix", 0xa }, | ||
1575 | }, | 1708 | }, |
1576 | } | 1709 | } |
1577 | }; | 1710 | }; |
@@ -1630,16 +1763,25 @@ static struct snd_kcontrol_new alc888_base_mixer[] = { | |||
1630 | { } /* end */ | 1763 | { } /* end */ |
1631 | }; | 1764 | }; |
1632 | 1765 | ||
1633 | static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec) | 1766 | static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec) |
1634 | { | 1767 | { |
1635 | struct alc_spec *spec = codec->spec; | 1768 | struct alc_spec *spec = codec->spec; |
1636 | 1769 | ||
1637 | spec->autocfg.hp_pins[0] = 0x15; | 1770 | spec->autocfg.hp_pins[0] = 0x15; |
1638 | spec->autocfg.speaker_pins[0] = 0x14; | 1771 | spec->autocfg.speaker_pins[0] = 0x14; |
1639 | alc_automute_amp(codec); | ||
1640 | } | 1772 | } |
1641 | 1773 | ||
1642 | static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec) | 1774 | static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec) |
1775 | { | ||
1776 | struct alc_spec *spec = codec->spec; | ||
1777 | |||
1778 | spec->autocfg.hp_pins[0] = 0x15; | ||
1779 | spec->autocfg.speaker_pins[0] = 0x14; | ||
1780 | spec->autocfg.speaker_pins[1] = 0x16; | ||
1781 | spec->autocfg.speaker_pins[2] = 0x17; | ||
1782 | } | ||
1783 | |||
1784 | static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec) | ||
1643 | { | 1785 | { |
1644 | struct alc_spec *spec = codec->spec; | 1786 | struct alc_spec *spec = codec->spec; |
1645 | 1787 | ||
@@ -1647,7 +1789,6 @@ static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec) | |||
1647 | spec->autocfg.speaker_pins[0] = 0x14; | 1789 | spec->autocfg.speaker_pins[0] = 0x14; |
1648 | spec->autocfg.speaker_pins[1] = 0x16; | 1790 | spec->autocfg.speaker_pins[1] = 0x16; |
1649 | spec->autocfg.speaker_pins[2] = 0x1b; | 1791 | spec->autocfg.speaker_pins[2] = 0x1b; |
1650 | alc_automute_amp(codec); | ||
1651 | } | 1792 | } |
1652 | 1793 | ||
1653 | /* | 1794 | /* |
@@ -2627,13 +2768,17 @@ static void alc880_uniwill_mic_automute(struct hda_codec *codec) | |||
2627 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); | 2768 | snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits); |
2628 | } | 2769 | } |
2629 | 2770 | ||
2630 | static void alc880_uniwill_init_hook(struct hda_codec *codec) | 2771 | static void alc880_uniwill_setup(struct hda_codec *codec) |
2631 | { | 2772 | { |
2632 | struct alc_spec *spec = codec->spec; | 2773 | struct alc_spec *spec = codec->spec; |
2633 | 2774 | ||
2634 | spec->autocfg.hp_pins[0] = 0x14; | 2775 | spec->autocfg.hp_pins[0] = 0x14; |
2635 | spec->autocfg.speaker_pins[0] = 0x15; | 2776 | spec->autocfg.speaker_pins[0] = 0x15; |
2636 | spec->autocfg.speaker_pins[0] = 0x16; | 2777 | spec->autocfg.speaker_pins[0] = 0x16; |
2778 | } | ||
2779 | |||
2780 | static void alc880_uniwill_init_hook(struct hda_codec *codec) | ||
2781 | { | ||
2637 | alc_automute_amp(codec); | 2782 | alc_automute_amp(codec); |
2638 | alc880_uniwill_mic_automute(codec); | 2783 | alc880_uniwill_mic_automute(codec); |
2639 | } | 2784 | } |
@@ -2654,13 +2799,12 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec, | |||
2654 | } | 2799 | } |
2655 | } | 2800 | } |
2656 | 2801 | ||
2657 | static void alc880_uniwill_p53_init_hook(struct hda_codec *codec) | 2802 | static void alc880_uniwill_p53_setup(struct hda_codec *codec) |
2658 | { | 2803 | { |
2659 | struct alc_spec *spec = codec->spec; | 2804 | struct alc_spec *spec = codec->spec; |
2660 | 2805 | ||
2661 | spec->autocfg.hp_pins[0] = 0x14; | 2806 | spec->autocfg.hp_pins[0] = 0x14; |
2662 | spec->autocfg.speaker_pins[0] = 0x15; | 2807 | spec->autocfg.speaker_pins[0] = 0x15; |
2663 | alc_automute_amp(codec); | ||
2664 | } | 2808 | } |
2665 | 2809 | ||
2666 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) | 2810 | static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) |
@@ -2923,13 +3067,12 @@ static struct hda_verb alc880_lg_init_verbs[] = { | |||
2923 | }; | 3067 | }; |
2924 | 3068 | ||
2925 | /* toggle speaker-output according to the hp-jack state */ | 3069 | /* toggle speaker-output according to the hp-jack state */ |
2926 | static void alc880_lg_init_hook(struct hda_codec *codec) | 3070 | static void alc880_lg_setup(struct hda_codec *codec) |
2927 | { | 3071 | { |
2928 | struct alc_spec *spec = codec->spec; | 3072 | struct alc_spec *spec = codec->spec; |
2929 | 3073 | ||
2930 | spec->autocfg.hp_pins[0] = 0x1b; | 3074 | spec->autocfg.hp_pins[0] = 0x1b; |
2931 | spec->autocfg.speaker_pins[0] = 0x17; | 3075 | spec->autocfg.speaker_pins[0] = 0x17; |
2932 | alc_automute_amp(codec); | ||
2933 | } | 3076 | } |
2934 | 3077 | ||
2935 | /* | 3078 | /* |
@@ -3008,13 +3151,12 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = { | |||
3008 | }; | 3151 | }; |
3009 | 3152 | ||
3010 | /* toggle speaker-output according to the hp-jack state */ | 3153 | /* toggle speaker-output according to the hp-jack state */ |
3011 | static void alc880_lg_lw_init_hook(struct hda_codec *codec) | 3154 | static void alc880_lg_lw_setup(struct hda_codec *codec) |
3012 | { | 3155 | { |
3013 | struct alc_spec *spec = codec->spec; | 3156 | struct alc_spec *spec = codec->spec; |
3014 | 3157 | ||
3015 | spec->autocfg.hp_pins[0] = 0x1b; | 3158 | spec->autocfg.hp_pins[0] = 0x1b; |
3016 | spec->autocfg.speaker_pins[0] = 0x14; | 3159 | spec->autocfg.speaker_pins[0] = 0x14; |
3017 | alc_automute_amp(codec); | ||
3018 | } | 3160 | } |
3019 | 3161 | ||
3020 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { | 3162 | static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { |
@@ -3080,13 +3222,12 @@ static void alc880_medion_rim_unsol_event(struct hda_codec *codec, | |||
3080 | alc880_medion_rim_automute(codec); | 3222 | alc880_medion_rim_automute(codec); |
3081 | } | 3223 | } |
3082 | 3224 | ||
3083 | static void alc880_medion_rim_init_hook(struct hda_codec *codec) | 3225 | static void alc880_medion_rim_setup(struct hda_codec *codec) |
3084 | { | 3226 | { |
3085 | struct alc_spec *spec = codec->spec; | 3227 | struct alc_spec *spec = codec->spec; |
3086 | 3228 | ||
3087 | spec->autocfg.hp_pins[0] = 0x14; | 3229 | spec->autocfg.hp_pins[0] = 0x14; |
3088 | spec->autocfg.speaker_pins[0] = 0x1b; | 3230 | spec->autocfg.speaker_pins[0] = 0x1b; |
3089 | alc880_medion_rim_automute(codec); | ||
3090 | } | 3231 | } |
3091 | 3232 | ||
3092 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 3233 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -3953,7 +4094,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
3953 | .channel_mode = alc880_2_jack_modes, | 4094 | .channel_mode = alc880_2_jack_modes, |
3954 | .input_mux = &alc880_f1734_capture_source, | 4095 | .input_mux = &alc880_f1734_capture_source, |
3955 | .unsol_event = alc880_uniwill_p53_unsol_event, | 4096 | .unsol_event = alc880_uniwill_p53_unsol_event, |
3956 | .init_hook = alc880_uniwill_p53_init_hook, | 4097 | .setup = alc880_uniwill_p53_setup, |
4098 | .init_hook = alc_automute_amp, | ||
3957 | }, | 4099 | }, |
3958 | [ALC880_ASUS] = { | 4100 | [ALC880_ASUS] = { |
3959 | .mixers = { alc880_asus_mixer }, | 4101 | .mixers = { alc880_asus_mixer }, |
@@ -4030,6 +4172,7 @@ static struct alc_config_preset alc880_presets[] = { | |||
4030 | .need_dac_fix = 1, | 4172 | .need_dac_fix = 1, |
4031 | .input_mux = &alc880_capture_source, | 4173 | .input_mux = &alc880_capture_source, |
4032 | .unsol_event = alc880_uniwill_unsol_event, | 4174 | .unsol_event = alc880_uniwill_unsol_event, |
4175 | .setup = alc880_uniwill_setup, | ||
4033 | .init_hook = alc880_uniwill_init_hook, | 4176 | .init_hook = alc880_uniwill_init_hook, |
4034 | }, | 4177 | }, |
4035 | [ALC880_UNIWILL_P53] = { | 4178 | [ALC880_UNIWILL_P53] = { |
@@ -4042,7 +4185,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
4042 | .channel_mode = alc880_threestack_modes, | 4185 | .channel_mode = alc880_threestack_modes, |
4043 | .input_mux = &alc880_capture_source, | 4186 | .input_mux = &alc880_capture_source, |
4044 | .unsol_event = alc880_uniwill_p53_unsol_event, | 4187 | .unsol_event = alc880_uniwill_p53_unsol_event, |
4045 | .init_hook = alc880_uniwill_p53_init_hook, | 4188 | .setup = alc880_uniwill_p53_setup, |
4189 | .init_hook = alc_automute_amp, | ||
4046 | }, | 4190 | }, |
4047 | [ALC880_FUJITSU] = { | 4191 | [ALC880_FUJITSU] = { |
4048 | .mixers = { alc880_fujitsu_mixer }, | 4192 | .mixers = { alc880_fujitsu_mixer }, |
@@ -4056,7 +4200,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
4056 | .channel_mode = alc880_2_jack_modes, | 4200 | .channel_mode = alc880_2_jack_modes, |
4057 | .input_mux = &alc880_capture_source, | 4201 | .input_mux = &alc880_capture_source, |
4058 | .unsol_event = alc880_uniwill_p53_unsol_event, | 4202 | .unsol_event = alc880_uniwill_p53_unsol_event, |
4059 | .init_hook = alc880_uniwill_p53_init_hook, | 4203 | .setup = alc880_uniwill_p53_setup, |
4204 | .init_hook = alc_automute_amp, | ||
4060 | }, | 4205 | }, |
4061 | [ALC880_CLEVO] = { | 4206 | [ALC880_CLEVO] = { |
4062 | .mixers = { alc880_three_stack_mixer }, | 4207 | .mixers = { alc880_three_stack_mixer }, |
@@ -4082,7 +4227,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
4082 | .need_dac_fix = 1, | 4227 | .need_dac_fix = 1, |
4083 | .input_mux = &alc880_lg_capture_source, | 4228 | .input_mux = &alc880_lg_capture_source, |
4084 | .unsol_event = alc_automute_amp_unsol_event, | 4229 | .unsol_event = alc_automute_amp_unsol_event, |
4085 | .init_hook = alc880_lg_init_hook, | 4230 | .setup = alc880_lg_setup, |
4231 | .init_hook = alc_automute_amp, | ||
4086 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 4232 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
4087 | .loopbacks = alc880_lg_loopbacks, | 4233 | .loopbacks = alc880_lg_loopbacks, |
4088 | #endif | 4234 | #endif |
@@ -4098,7 +4244,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
4098 | .channel_mode = alc880_lg_lw_modes, | 4244 | .channel_mode = alc880_lg_lw_modes, |
4099 | .input_mux = &alc880_lg_lw_capture_source, | 4245 | .input_mux = &alc880_lg_lw_capture_source, |
4100 | .unsol_event = alc_automute_amp_unsol_event, | 4246 | .unsol_event = alc_automute_amp_unsol_event, |
4101 | .init_hook = alc880_lg_lw_init_hook, | 4247 | .setup = alc880_lg_lw_setup, |
4248 | .init_hook = alc_automute_amp, | ||
4102 | }, | 4249 | }, |
4103 | [ALC880_MEDION_RIM] = { | 4250 | [ALC880_MEDION_RIM] = { |
4104 | .mixers = { alc880_medion_rim_mixer }, | 4251 | .mixers = { alc880_medion_rim_mixer }, |
@@ -4112,7 +4259,8 @@ static struct alc_config_preset alc880_presets[] = { | |||
4112 | .channel_mode = alc880_2_jack_modes, | 4259 | .channel_mode = alc880_2_jack_modes, |
4113 | .input_mux = &alc880_medion_rim_capture_source, | 4260 | .input_mux = &alc880_medion_rim_capture_source, |
4114 | .unsol_event = alc880_medion_rim_unsol_event, | 4261 | .unsol_event = alc880_medion_rim_unsol_event, |
4115 | .init_hook = alc880_medion_rim_init_hook, | 4262 | .setup = alc880_medion_rim_setup, |
4263 | .init_hook = alc880_medion_rim_automute, | ||
4116 | }, | 4264 | }, |
4117 | #ifdef CONFIG_SND_DEBUG | 4265 | #ifdef CONFIG_SND_DEBUG |
4118 | [ALC880_TEST] = { | 4266 | [ALC880_TEST] = { |
@@ -4165,8 +4313,6 @@ static int add_control(struct alc_spec *spec, int type, const char *name, | |||
4165 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) | 4313 | #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) |
4166 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) | 4314 | #define alc880_is_multi_pin(nid) ((nid) >= 0x18) |
4167 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) | 4315 | #define alc880_multi_pin_idx(nid) ((nid) - 0x18) |
4168 | #define alc880_is_input_pin(nid) ((nid) >= 0x18) | ||
4169 | #define alc880_input_pin_idx(nid) ((nid) - 0x18) | ||
4170 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) | 4316 | #define alc880_idx_to_dac(nid) ((nid) + 0x02) |
4171 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) | 4317 | #define alc880_dac_to_idx(nid) ((nid) - 0x02) |
4172 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) | 4318 | #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) |
@@ -4254,13 +4400,19 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
4254 | if (err < 0) | 4400 | if (err < 0) |
4255 | return err; | 4401 | return err; |
4256 | } else { | 4402 | } else { |
4257 | sprintf(name, "%s Playback Volume", chname[i]); | 4403 | const char *pfx; |
4404 | if (cfg->line_outs == 1 && | ||
4405 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
4406 | pfx = "Speaker"; | ||
4407 | else | ||
4408 | pfx = chname[i]; | ||
4409 | sprintf(name, "%s Playback Volume", pfx); | ||
4258 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 4410 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
4259 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | 4411 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
4260 | HDA_OUTPUT)); | 4412 | HDA_OUTPUT)); |
4261 | if (err < 0) | 4413 | if (err < 0) |
4262 | return err; | 4414 | return err; |
4263 | sprintf(name, "%s Playback Switch", chname[i]); | 4415 | sprintf(name, "%s Playback Switch", pfx); |
4264 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | 4416 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
4265 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, | 4417 | HDA_COMPOSE_AMP_VAL(nid, 3, 2, |
4266 | HDA_INPUT)); | 4418 | HDA_INPUT)); |
@@ -4334,31 +4486,61 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, | |||
4334 | return 0; | 4486 | return 0; |
4335 | } | 4487 | } |
4336 | 4488 | ||
4489 | static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid) | ||
4490 | { | ||
4491 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); | ||
4492 | return (pincap & AC_PINCAP_IN) != 0; | ||
4493 | } | ||
4494 | |||
4337 | /* create playback/capture controls for input pins */ | 4495 | /* create playback/capture controls for input pins */ |
4338 | static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, | 4496 | static int alc_auto_create_input_ctls(struct hda_codec *codec, |
4339 | const struct auto_pin_cfg *cfg) | 4497 | const struct auto_pin_cfg *cfg, |
4498 | hda_nid_t mixer, | ||
4499 | hda_nid_t cap1, hda_nid_t cap2) | ||
4340 | { | 4500 | { |
4501 | struct alc_spec *spec = codec->spec; | ||
4341 | struct hda_input_mux *imux = &spec->private_imux[0]; | 4502 | struct hda_input_mux *imux = &spec->private_imux[0]; |
4342 | int i, err, idx; | 4503 | int i, err, idx; |
4343 | 4504 | ||
4344 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 4505 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
4345 | if (alc880_is_input_pin(cfg->input_pins[i])) { | 4506 | hda_nid_t pin; |
4346 | idx = alc880_input_pin_idx(cfg->input_pins[i]); | 4507 | |
4347 | err = new_analog_input(spec, cfg->input_pins[i], | 4508 | pin = cfg->input_pins[i]; |
4348 | auto_pin_cfg_labels[i], | 4509 | if (!alc_is_input_pin(codec, pin)) |
4349 | idx, 0x0b); | 4510 | continue; |
4350 | if (err < 0) | 4511 | |
4351 | return err; | 4512 | if (mixer) { |
4513 | idx = get_connection_index(codec, mixer, pin); | ||
4514 | if (idx >= 0) { | ||
4515 | err = new_analog_input(spec, pin, | ||
4516 | auto_pin_cfg_labels[i], | ||
4517 | idx, mixer); | ||
4518 | if (err < 0) | ||
4519 | return err; | ||
4520 | } | ||
4521 | } | ||
4522 | |||
4523 | if (!cap1) | ||
4524 | continue; | ||
4525 | idx = get_connection_index(codec, cap1, pin); | ||
4526 | if (idx < 0 && cap2) | ||
4527 | idx = get_connection_index(codec, cap2, pin); | ||
4528 | if (idx >= 0) { | ||
4352 | imux->items[imux->num_items].label = | 4529 | imux->items[imux->num_items].label = |
4353 | auto_pin_cfg_labels[i]; | 4530 | auto_pin_cfg_labels[i]; |
4354 | imux->items[imux->num_items].index = | 4531 | imux->items[imux->num_items].index = idx; |
4355 | alc880_input_pin_idx(cfg->input_pins[i]); | ||
4356 | imux->num_items++; | 4532 | imux->num_items++; |
4357 | } | 4533 | } |
4358 | } | 4534 | } |
4359 | return 0; | 4535 | return 0; |
4360 | } | 4536 | } |
4361 | 4537 | ||
4538 | static int alc880_auto_create_input_ctls(struct hda_codec *codec, | ||
4539 | const struct auto_pin_cfg *cfg) | ||
4540 | { | ||
4541 | return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09); | ||
4542 | } | ||
4543 | |||
4362 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, | 4544 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
4363 | unsigned int pin_type) | 4545 | unsigned int pin_type) |
4364 | { | 4546 | { |
@@ -4424,7 +4606,7 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec) | |||
4424 | 4606 | ||
4425 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 4607 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
4426 | hda_nid_t nid = spec->autocfg.input_pins[i]; | 4608 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
4427 | if (alc880_is_input_pin(nid)) { | 4609 | if (alc_is_input_pin(codec, nid)) { |
4428 | alc_set_input_pin(codec, nid, i); | 4610 | alc_set_input_pin(codec, nid, i); |
4429 | if (nid != ALC880_PIN_CD_NID && | 4611 | if (nid != ALC880_PIN_CD_NID && |
4430 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) | 4612 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) |
@@ -4467,7 +4649,7 @@ static int alc880_parse_auto_config(struct hda_codec *codec) | |||
4467 | "Headphone"); | 4649 | "Headphone"); |
4468 | if (err < 0) | 4650 | if (err < 0) |
4469 | return err; | 4651 | return err; |
4470 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | 4652 | err = alc880_auto_create_input_ctls(codec, &spec->autocfg); |
4471 | if (err < 0) | 4653 | if (err < 0) |
4472 | return err; | 4654 | return err; |
4473 | 4655 | ||
@@ -4517,8 +4699,42 @@ static void alc880_auto_init(struct hda_codec *codec) | |||
4517 | alc_inithook(codec); | 4699 | alc_inithook(codec); |
4518 | } | 4700 | } |
4519 | 4701 | ||
4520 | static void set_capture_mixer(struct alc_spec *spec) | 4702 | /* check the ADC/MUX contains all input pins; some ADC/MUX contains only |
4703 | * one of two digital mic pins, e.g. on ALC272 | ||
4704 | */ | ||
4705 | static void fixup_automic_adc(struct hda_codec *codec) | ||
4706 | { | ||
4707 | struct alc_spec *spec = codec->spec; | ||
4708 | int i; | ||
4709 | |||
4710 | for (i = 0; i < spec->num_adc_nids; i++) { | ||
4711 | hda_nid_t cap = spec->capsrc_nids ? | ||
4712 | spec->capsrc_nids[i] : spec->adc_nids[i]; | ||
4713 | int iidx, eidx; | ||
4714 | |||
4715 | iidx = get_connection_index(codec, cap, spec->int_mic.pin); | ||
4716 | if (iidx < 0) | ||
4717 | continue; | ||
4718 | eidx = get_connection_index(codec, cap, spec->ext_mic.pin); | ||
4719 | if (eidx < 0) | ||
4720 | continue; | ||
4721 | spec->int_mic.mux_idx = iidx; | ||
4722 | spec->ext_mic.mux_idx = eidx; | ||
4723 | if (spec->capsrc_nids) | ||
4724 | spec->capsrc_nids += i; | ||
4725 | spec->adc_nids += i; | ||
4726 | spec->num_adc_nids = 1; | ||
4727 | return; | ||
4728 | } | ||
4729 | snd_printd(KERN_INFO "hda_codec: %s: " | ||
4730 | "No ADC/MUX containing both 0x%x and 0x%x pins\n", | ||
4731 | codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin); | ||
4732 | spec->auto_mic = 0; /* disable auto-mic to be sure */ | ||
4733 | } | ||
4734 | |||
4735 | static void set_capture_mixer(struct hda_codec *codec) | ||
4521 | { | 4736 | { |
4737 | struct alc_spec *spec = codec->spec; | ||
4522 | static struct snd_kcontrol_new *caps[2][3] = { | 4738 | static struct snd_kcontrol_new *caps[2][3] = { |
4523 | { alc_capture_mixer_nosrc1, | 4739 | { alc_capture_mixer_nosrc1, |
4524 | alc_capture_mixer_nosrc2, | 4740 | alc_capture_mixer_nosrc2, |
@@ -4529,7 +4745,10 @@ static void set_capture_mixer(struct alc_spec *spec) | |||
4529 | }; | 4745 | }; |
4530 | if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) { | 4746 | if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) { |
4531 | int mux; | 4747 | int mux; |
4532 | if (spec->input_mux && spec->input_mux->num_items > 1) | 4748 | if (spec->auto_mic) { |
4749 | mux = 0; | ||
4750 | fixup_automic_adc(codec); | ||
4751 | } else if (spec->input_mux && spec->input_mux->num_items > 1) | ||
4533 | mux = 1; | 4752 | mux = 1; |
4534 | else | 4753 | else |
4535 | mux = 0; | 4754 | mux = 0; |
@@ -4560,8 +4779,8 @@ static int patch_alc880(struct hda_codec *codec) | |||
4560 | alc880_models, | 4779 | alc880_models, |
4561 | alc880_cfg_tbl); | 4780 | alc880_cfg_tbl); |
4562 | if (board_config < 0) { | 4781 | if (board_config < 0) { |
4563 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 4782 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
4564 | "trying auto-probe from BIOS...\n", codec->chip_name); | 4783 | codec->chip_name); |
4565 | board_config = ALC880_AUTO; | 4784 | board_config = ALC880_AUTO; |
4566 | } | 4785 | } |
4567 | 4786 | ||
@@ -4586,7 +4805,7 @@ static int patch_alc880(struct hda_codec *codec) | |||
4586 | } | 4805 | } |
4587 | 4806 | ||
4588 | if (board_config != ALC880_AUTO) | 4807 | if (board_config != ALC880_AUTO) |
4589 | setup_preset(spec, &alc880_presets[board_config]); | 4808 | setup_preset(codec, &alc880_presets[board_config]); |
4590 | 4809 | ||
4591 | spec->stream_analog_playback = &alc880_pcm_analog_playback; | 4810 | spec->stream_analog_playback = &alc880_pcm_analog_playback; |
4592 | spec->stream_analog_capture = &alc880_pcm_analog_capture; | 4811 | spec->stream_analog_capture = &alc880_pcm_analog_capture; |
@@ -4599,7 +4818,7 @@ static int patch_alc880(struct hda_codec *codec) | |||
4599 | /* check whether NID 0x07 is valid */ | 4818 | /* check whether NID 0x07 is valid */ |
4600 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); | 4819 | unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); |
4601 | /* get type */ | 4820 | /* get type */ |
4602 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 4821 | wcap = get_wcaps_type(wcap); |
4603 | if (wcap != AC_WID_AUD_IN) { | 4822 | if (wcap != AC_WID_AUD_IN) { |
4604 | spec->adc_nids = alc880_adc_nids_alt; | 4823 | spec->adc_nids = alc880_adc_nids_alt; |
4605 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); | 4824 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); |
@@ -4608,7 +4827,7 @@ static int patch_alc880(struct hda_codec *codec) | |||
4608 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); | 4827 | spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); |
4609 | } | 4828 | } |
4610 | } | 4829 | } |
4611 | set_capture_mixer(spec); | 4830 | set_capture_mixer(codec); |
4612 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 4831 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
4613 | 4832 | ||
4614 | spec->vmaster_nid = 0x0c; | 4833 | spec->vmaster_nid = 0x0c; |
@@ -5800,7 +6019,14 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
5800 | 6019 | ||
5801 | nid = cfg->line_out_pins[0]; | 6020 | nid = cfg->line_out_pins[0]; |
5802 | if (nid) { | 6021 | if (nid) { |
5803 | err = alc260_add_playback_controls(spec, nid, "Front", &vols); | 6022 | const char *pfx; |
6023 | if (!cfg->speaker_pins[0] && !cfg->hp_pins[0]) | ||
6024 | pfx = "Master"; | ||
6025 | else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
6026 | pfx = "Speaker"; | ||
6027 | else | ||
6028 | pfx = "Front"; | ||
6029 | err = alc260_add_playback_controls(spec, nid, pfx, &vols); | ||
5804 | if (err < 0) | 6030 | if (err < 0) |
5805 | return err; | 6031 | return err; |
5806 | } | 6032 | } |
@@ -5823,39 +6049,10 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
5823 | } | 6049 | } |
5824 | 6050 | ||
5825 | /* create playback/capture controls for input pins */ | 6051 | /* create playback/capture controls for input pins */ |
5826 | static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, | 6052 | static int alc260_auto_create_input_ctls(struct hda_codec *codec, |
5827 | const struct auto_pin_cfg *cfg) | 6053 | const struct auto_pin_cfg *cfg) |
5828 | { | 6054 | { |
5829 | struct hda_input_mux *imux = &spec->private_imux[0]; | 6055 | return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05); |
5830 | int i, err, idx; | ||
5831 | |||
5832 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
5833 | if (cfg->input_pins[i] >= 0x12) { | ||
5834 | idx = cfg->input_pins[i] - 0x12; | ||
5835 | err = new_analog_input(spec, cfg->input_pins[i], | ||
5836 | auto_pin_cfg_labels[i], idx, | ||
5837 | 0x07); | ||
5838 | if (err < 0) | ||
5839 | return err; | ||
5840 | imux->items[imux->num_items].label = | ||
5841 | auto_pin_cfg_labels[i]; | ||
5842 | imux->items[imux->num_items].index = idx; | ||
5843 | imux->num_items++; | ||
5844 | } | ||
5845 | if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){ | ||
5846 | idx = cfg->input_pins[i] - 0x09; | ||
5847 | err = new_analog_input(spec, cfg->input_pins[i], | ||
5848 | auto_pin_cfg_labels[i], idx, | ||
5849 | 0x07); | ||
5850 | if (err < 0) | ||
5851 | return err; | ||
5852 | imux->items[imux->num_items].label = | ||
5853 | auto_pin_cfg_labels[i]; | ||
5854 | imux->items[imux->num_items].index = idx; | ||
5855 | imux->num_items++; | ||
5856 | } | ||
5857 | } | ||
5858 | return 0; | ||
5859 | } | 6056 | } |
5860 | 6057 | ||
5861 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, | 6058 | static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, |
@@ -5969,7 +6166,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec) | |||
5969 | return err; | 6166 | return err; |
5970 | if (!spec->kctls.list) | 6167 | if (!spec->kctls.list) |
5971 | return 0; /* can't find valid BIOS pin config */ | 6168 | return 0; /* can't find valid BIOS pin config */ |
5972 | err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg); | 6169 | err = alc260_auto_create_input_ctls(codec, &spec->autocfg); |
5973 | if (err < 0) | 6170 | if (err < 0) |
5974 | return err; | 6171 | return err; |
5975 | 6172 | ||
@@ -6204,8 +6401,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
6204 | alc260_models, | 6401 | alc260_models, |
6205 | alc260_cfg_tbl); | 6402 | alc260_cfg_tbl); |
6206 | if (board_config < 0) { | 6403 | if (board_config < 0) { |
6207 | snd_printd(KERN_INFO "hda_codec: Unknown model for %s, " | 6404 | snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
6208 | "trying auto-probe from BIOS...\n", | ||
6209 | codec->chip_name); | 6405 | codec->chip_name); |
6210 | board_config = ALC260_AUTO; | 6406 | board_config = ALC260_AUTO; |
6211 | } | 6407 | } |
@@ -6231,7 +6427,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
6231 | } | 6427 | } |
6232 | 6428 | ||
6233 | if (board_config != ALC260_AUTO) | 6429 | if (board_config != ALC260_AUTO) |
6234 | setup_preset(spec, &alc260_presets[board_config]); | 6430 | setup_preset(codec, &alc260_presets[board_config]); |
6235 | 6431 | ||
6236 | spec->stream_analog_playback = &alc260_pcm_analog_playback; | 6432 | spec->stream_analog_playback = &alc260_pcm_analog_playback; |
6237 | spec->stream_analog_capture = &alc260_pcm_analog_capture; | 6433 | spec->stream_analog_capture = &alc260_pcm_analog_capture; |
@@ -6242,7 +6438,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
6242 | if (!spec->adc_nids && spec->input_mux) { | 6438 | if (!spec->adc_nids && spec->input_mux) { |
6243 | /* check whether NID 0x04 is valid */ | 6439 | /* check whether NID 0x04 is valid */ |
6244 | unsigned int wcap = get_wcaps(codec, 0x04); | 6440 | unsigned int wcap = get_wcaps(codec, 0x04); |
6245 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 6441 | wcap = get_wcaps_type(wcap); |
6246 | /* get type */ | 6442 | /* get type */ |
6247 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { | 6443 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { |
6248 | spec->adc_nids = alc260_adc_nids_alt; | 6444 | spec->adc_nids = alc260_adc_nids_alt; |
@@ -6252,7 +6448,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
6252 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); | 6448 | spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); |
6253 | } | 6449 | } |
6254 | } | 6450 | } |
6255 | set_capture_mixer(spec); | 6451 | set_capture_mixer(codec); |
6256 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); | 6452 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
6257 | 6453 | ||
6258 | spec->vmaster_nid = 0x08; | 6454 | spec->vmaster_nid = 0x08; |
@@ -6271,7 +6467,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
6271 | 6467 | ||
6272 | 6468 | ||
6273 | /* | 6469 | /* |
6274 | * ALC882 support | 6470 | * ALC882/883/885/888/889 support |
6275 | * | 6471 | * |
6276 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible | 6472 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
6277 | * configuration. Each pin widget can choose any input DACs and a mixer. | 6473 | * configuration. Each pin widget can choose any input DACs and a mixer. |
@@ -6283,22 +6479,35 @@ static int patch_alc260(struct hda_codec *codec) | |||
6283 | */ | 6479 | */ |
6284 | #define ALC882_DIGOUT_NID 0x06 | 6480 | #define ALC882_DIGOUT_NID 0x06 |
6285 | #define ALC882_DIGIN_NID 0x0a | 6481 | #define ALC882_DIGIN_NID 0x0a |
6482 | #define ALC883_DIGOUT_NID ALC882_DIGOUT_NID | ||
6483 | #define ALC883_DIGIN_NID ALC882_DIGIN_NID | ||
6484 | #define ALC1200_DIGOUT_NID 0x10 | ||
6485 | |||
6286 | 6486 | ||
6287 | static struct hda_channel_mode alc882_ch_modes[1] = { | 6487 | static struct hda_channel_mode alc882_ch_modes[1] = { |
6288 | { 8, NULL } | 6488 | { 8, NULL } |
6289 | }; | 6489 | }; |
6290 | 6490 | ||
6491 | /* DACs */ | ||
6291 | static hda_nid_t alc882_dac_nids[4] = { | 6492 | static hda_nid_t alc882_dac_nids[4] = { |
6292 | /* front, rear, clfe, rear_surr */ | 6493 | /* front, rear, clfe, rear_surr */ |
6293 | 0x02, 0x03, 0x04, 0x05 | 6494 | 0x02, 0x03, 0x04, 0x05 |
6294 | }; | 6495 | }; |
6496 | #define alc883_dac_nids alc882_dac_nids | ||
6295 | 6497 | ||
6296 | /* identical with ALC880 */ | 6498 | /* ADCs */ |
6297 | #define alc882_adc_nids alc880_adc_nids | 6499 | #define alc882_adc_nids alc880_adc_nids |
6298 | #define alc882_adc_nids_alt alc880_adc_nids_alt | 6500 | #define alc882_adc_nids_alt alc880_adc_nids_alt |
6501 | #define alc883_adc_nids alc882_adc_nids_alt | ||
6502 | static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 }; | ||
6503 | static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 }; | ||
6504 | #define alc889_adc_nids alc880_adc_nids | ||
6299 | 6505 | ||
6300 | static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; | 6506 | static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 }; |
6301 | static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; | 6507 | static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 }; |
6508 | #define alc883_capsrc_nids alc882_capsrc_nids_alt | ||
6509 | static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 }; | ||
6510 | #define alc889_capsrc_nids alc882_capsrc_nids | ||
6302 | 6511 | ||
6303 | /* input MUX */ | 6512 | /* input MUX */ |
6304 | /* FIXME: should be a matrix-type input source selection */ | 6513 | /* FIXME: should be a matrix-type input source selection */ |
@@ -6313,6 +6522,17 @@ static struct hda_input_mux alc882_capture_source = { | |||
6313 | }, | 6522 | }, |
6314 | }; | 6523 | }; |
6315 | 6524 | ||
6525 | #define alc883_capture_source alc882_capture_source | ||
6526 | |||
6527 | static struct hda_input_mux alc889_capture_source = { | ||
6528 | .num_items = 3, | ||
6529 | .items = { | ||
6530 | { "Front Mic", 0x0 }, | ||
6531 | { "Mic", 0x3 }, | ||
6532 | { "Line", 0x2 }, | ||
6533 | }, | ||
6534 | }; | ||
6535 | |||
6316 | static struct hda_input_mux mb5_capture_source = { | 6536 | static struct hda_input_mux mb5_capture_source = { |
6317 | .num_items = 3, | 6537 | .num_items = 3, |
6318 | .items = { | 6538 | .items = { |
@@ -6322,6 +6542,77 @@ static struct hda_input_mux mb5_capture_source = { | |||
6322 | }, | 6542 | }, |
6323 | }; | 6543 | }; |
6324 | 6544 | ||
6545 | static struct hda_input_mux alc883_3stack_6ch_intel = { | ||
6546 | .num_items = 4, | ||
6547 | .items = { | ||
6548 | { "Mic", 0x1 }, | ||
6549 | { "Front Mic", 0x0 }, | ||
6550 | { "Line", 0x2 }, | ||
6551 | { "CD", 0x4 }, | ||
6552 | }, | ||
6553 | }; | ||
6554 | |||
6555 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { | ||
6556 | .num_items = 2, | ||
6557 | .items = { | ||
6558 | { "Mic", 0x1 }, | ||
6559 | { "Line", 0x2 }, | ||
6560 | }, | ||
6561 | }; | ||
6562 | |||
6563 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { | ||
6564 | .num_items = 4, | ||
6565 | .items = { | ||
6566 | { "Mic", 0x0 }, | ||
6567 | { "iMic", 0x1 }, | ||
6568 | { "Line", 0x2 }, | ||
6569 | { "CD", 0x4 }, | ||
6570 | }, | ||
6571 | }; | ||
6572 | |||
6573 | static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { | ||
6574 | .num_items = 2, | ||
6575 | .items = { | ||
6576 | { "Mic", 0x0 }, | ||
6577 | { "Int Mic", 0x1 }, | ||
6578 | }, | ||
6579 | }; | ||
6580 | |||
6581 | static struct hda_input_mux alc883_lenovo_sky_capture_source = { | ||
6582 | .num_items = 3, | ||
6583 | .items = { | ||
6584 | { "Mic", 0x0 }, | ||
6585 | { "Front Mic", 0x1 }, | ||
6586 | { "Line", 0x4 }, | ||
6587 | }, | ||
6588 | }; | ||
6589 | |||
6590 | static struct hda_input_mux alc883_asus_eee1601_capture_source = { | ||
6591 | .num_items = 2, | ||
6592 | .items = { | ||
6593 | { "Mic", 0x0 }, | ||
6594 | { "Line", 0x2 }, | ||
6595 | }, | ||
6596 | }; | ||
6597 | |||
6598 | static struct hda_input_mux alc889A_mb31_capture_source = { | ||
6599 | .num_items = 2, | ||
6600 | .items = { | ||
6601 | { "Mic", 0x0 }, | ||
6602 | /* Front Mic (0x01) unused */ | ||
6603 | { "Line", 0x2 }, | ||
6604 | /* Line 2 (0x03) unused */ | ||
6605 | /* CD (0x04) unsused? */ | ||
6606 | }, | ||
6607 | }; | ||
6608 | |||
6609 | /* | ||
6610 | * 2ch mode | ||
6611 | */ | ||
6612 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | ||
6613 | { 2, NULL } | ||
6614 | }; | ||
6615 | |||
6325 | /* | 6616 | /* |
6326 | * 2ch mode | 6617 | * 2ch mode |
6327 | */ | 6618 | */ |
@@ -6334,6 +6625,18 @@ static struct hda_verb alc882_3ST_ch2_init[] = { | |||
6334 | }; | 6625 | }; |
6335 | 6626 | ||
6336 | /* | 6627 | /* |
6628 | * 4ch mode | ||
6629 | */ | ||
6630 | static struct hda_verb alc882_3ST_ch4_init[] = { | ||
6631 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6632 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6633 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6634 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6635 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6636 | { } /* end */ | ||
6637 | }; | ||
6638 | |||
6639 | /* | ||
6337 | * 6ch mode | 6640 | * 6ch mode |
6338 | */ | 6641 | */ |
6339 | static struct hda_verb alc882_3ST_ch6_init[] = { | 6642 | static struct hda_verb alc882_3ST_ch6_init[] = { |
@@ -6346,11 +6649,60 @@ static struct hda_verb alc882_3ST_ch6_init[] = { | |||
6346 | { } /* end */ | 6649 | { } /* end */ |
6347 | }; | 6650 | }; |
6348 | 6651 | ||
6349 | static struct hda_channel_mode alc882_3ST_6ch_modes[2] = { | 6652 | static struct hda_channel_mode alc882_3ST_6ch_modes[3] = { |
6350 | { 2, alc882_3ST_ch2_init }, | 6653 | { 2, alc882_3ST_ch2_init }, |
6654 | { 4, alc882_3ST_ch4_init }, | ||
6351 | { 6, alc882_3ST_ch6_init }, | 6655 | { 6, alc882_3ST_ch6_init }, |
6352 | }; | 6656 | }; |
6353 | 6657 | ||
6658 | #define alc883_3ST_6ch_modes alc882_3ST_6ch_modes | ||
6659 | |||
6660 | /* | ||
6661 | * 2ch mode | ||
6662 | */ | ||
6663 | static struct hda_verb alc883_3ST_ch2_clevo_init[] = { | ||
6664 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, | ||
6665 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6666 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6667 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
6668 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6669 | { } /* end */ | ||
6670 | }; | ||
6671 | |||
6672 | /* | ||
6673 | * 4ch mode | ||
6674 | */ | ||
6675 | static struct hda_verb alc883_3ST_ch4_clevo_init[] = { | ||
6676 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6677 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6678 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6679 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6680 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6681 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6682 | { } /* end */ | ||
6683 | }; | ||
6684 | |||
6685 | /* | ||
6686 | * 6ch mode | ||
6687 | */ | ||
6688 | static struct hda_verb alc883_3ST_ch6_clevo_init[] = { | ||
6689 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6690 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6691 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6692 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6693 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6694 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6695 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6696 | { } /* end */ | ||
6697 | }; | ||
6698 | |||
6699 | static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = { | ||
6700 | { 2, alc883_3ST_ch2_clevo_init }, | ||
6701 | { 4, alc883_3ST_ch4_clevo_init }, | ||
6702 | { 6, alc883_3ST_ch6_clevo_init }, | ||
6703 | }; | ||
6704 | |||
6705 | |||
6354 | /* | 6706 | /* |
6355 | * 6ch mode | 6707 | * 6ch mode |
6356 | */ | 6708 | */ |
@@ -6393,9 +6745,9 @@ static struct hda_verb alc885_mbp_ch2_init[] = { | |||
6393 | }; | 6745 | }; |
6394 | 6746 | ||
6395 | /* | 6747 | /* |
6396 | * 6ch mode | 6748 | * 4ch mode |
6397 | */ | 6749 | */ |
6398 | static struct hda_verb alc885_mbp_ch6_init[] = { | 6750 | static struct hda_verb alc885_mbp_ch4_init[] = { |
6399 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | 6751 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, |
6400 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 6752 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
6401 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | 6753 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
@@ -6404,9 +6756,9 @@ static struct hda_verb alc885_mbp_ch6_init[] = { | |||
6404 | { } /* end */ | 6756 | { } /* end */ |
6405 | }; | 6757 | }; |
6406 | 6758 | ||
6407 | static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { | 6759 | static struct hda_channel_mode alc885_mbp_4ch_modes[2] = { |
6408 | { 2, alc885_mbp_ch2_init }, | 6760 | { 2, alc885_mbp_ch2_init }, |
6409 | { 6, alc885_mbp_ch6_init }, | 6761 | { 4, alc885_mbp_ch4_init }, |
6410 | }; | 6762 | }; |
6411 | 6763 | ||
6412 | /* | 6764 | /* |
@@ -6438,6 +6790,189 @@ static struct hda_channel_mode alc885_mb5_6ch_modes[2] = { | |||
6438 | { 6, alc885_mb5_ch6_init }, | 6790 | { 6, alc885_mb5_ch6_init }, |
6439 | }; | 6791 | }; |
6440 | 6792 | ||
6793 | |||
6794 | /* | ||
6795 | * 2ch mode | ||
6796 | */ | ||
6797 | static struct hda_verb alc883_4ST_ch2_init[] = { | ||
6798 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6799 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6800 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6801 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6802 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
6803 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6804 | { } /* end */ | ||
6805 | }; | ||
6806 | |||
6807 | /* | ||
6808 | * 4ch mode | ||
6809 | */ | ||
6810 | static struct hda_verb alc883_4ST_ch4_init[] = { | ||
6811 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6812 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6813 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6814 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6815 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6816 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6817 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6818 | { } /* end */ | ||
6819 | }; | ||
6820 | |||
6821 | /* | ||
6822 | * 6ch mode | ||
6823 | */ | ||
6824 | static struct hda_verb alc883_4ST_ch6_init[] = { | ||
6825 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6826 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6827 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6828 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6829 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6830 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6831 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6832 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6833 | { } /* end */ | ||
6834 | }; | ||
6835 | |||
6836 | /* | ||
6837 | * 8ch mode | ||
6838 | */ | ||
6839 | static struct hda_verb alc883_4ST_ch8_init[] = { | ||
6840 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6841 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6842 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
6843 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6844 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6845 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6846 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6847 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6848 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6849 | { } /* end */ | ||
6850 | }; | ||
6851 | |||
6852 | static struct hda_channel_mode alc883_4ST_8ch_modes[4] = { | ||
6853 | { 2, alc883_4ST_ch2_init }, | ||
6854 | { 4, alc883_4ST_ch4_init }, | ||
6855 | { 6, alc883_4ST_ch6_init }, | ||
6856 | { 8, alc883_4ST_ch8_init }, | ||
6857 | }; | ||
6858 | |||
6859 | |||
6860 | /* | ||
6861 | * 2ch mode | ||
6862 | */ | ||
6863 | static struct hda_verb alc883_3ST_ch2_intel_init[] = { | ||
6864 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6865 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6866 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
6867 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6868 | { } /* end */ | ||
6869 | }; | ||
6870 | |||
6871 | /* | ||
6872 | * 4ch mode | ||
6873 | */ | ||
6874 | static struct hda_verb alc883_3ST_ch4_intel_init[] = { | ||
6875 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
6876 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6877 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6878 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6879 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6880 | { } /* end */ | ||
6881 | }; | ||
6882 | |||
6883 | /* | ||
6884 | * 6ch mode | ||
6885 | */ | ||
6886 | static struct hda_verb alc883_3ST_ch6_intel_init[] = { | ||
6887 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6888 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6889 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6890 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6891 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6892 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6893 | { } /* end */ | ||
6894 | }; | ||
6895 | |||
6896 | static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { | ||
6897 | { 2, alc883_3ST_ch2_intel_init }, | ||
6898 | { 4, alc883_3ST_ch4_intel_init }, | ||
6899 | { 6, alc883_3ST_ch6_intel_init }, | ||
6900 | }; | ||
6901 | |||
6902 | /* | ||
6903 | * 2ch mode | ||
6904 | */ | ||
6905 | static struct hda_verb alc889_ch2_intel_init[] = { | ||
6906 | { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6907 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6908 | { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6909 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6910 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
6911 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6912 | { } /* end */ | ||
6913 | }; | ||
6914 | |||
6915 | /* | ||
6916 | * 6ch mode | ||
6917 | */ | ||
6918 | static struct hda_verb alc889_ch6_intel_init[] = { | ||
6919 | { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6920 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6921 | { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6922 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
6923 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
6924 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
6925 | { } /* end */ | ||
6926 | }; | ||
6927 | |||
6928 | /* | ||
6929 | * 8ch mode | ||
6930 | */ | ||
6931 | static struct hda_verb alc889_ch8_intel_init[] = { | ||
6932 | { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
6933 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
6934 | { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
6935 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
6936 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
6937 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6938 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
6939 | { } /* end */ | ||
6940 | }; | ||
6941 | |||
6942 | static struct hda_channel_mode alc889_8ch_intel_modes[3] = { | ||
6943 | { 2, alc889_ch2_intel_init }, | ||
6944 | { 6, alc889_ch6_intel_init }, | ||
6945 | { 8, alc889_ch8_intel_init }, | ||
6946 | }; | ||
6947 | |||
6948 | /* | ||
6949 | * 6ch mode | ||
6950 | */ | ||
6951 | static struct hda_verb alc883_sixstack_ch6_init[] = { | ||
6952 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | ||
6953 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6954 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6955 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6956 | { } /* end */ | ||
6957 | }; | ||
6958 | |||
6959 | /* | ||
6960 | * 8ch mode | ||
6961 | */ | ||
6962 | static struct hda_verb alc883_sixstack_ch8_init[] = { | ||
6963 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6964 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6965 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6966 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
6967 | { } /* end */ | ||
6968 | }; | ||
6969 | |||
6970 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | ||
6971 | { 6, alc883_sixstack_ch6_init }, | ||
6972 | { 8, alc883_sixstack_ch8_init }, | ||
6973 | }; | ||
6974 | |||
6975 | |||
6441 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | 6976 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 |
6442 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | 6977 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b |
6443 | */ | 6978 | */ |
@@ -6467,10 +7002,11 @@ static struct snd_kcontrol_new alc882_base_mixer[] = { | |||
6467 | }; | 7002 | }; |
6468 | 7003 | ||
6469 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { | 7004 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
6470 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | 7005 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
6471 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | 7006 | HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT), |
6472 | HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), | 7007 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT), |
6473 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | 7008 | HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT), |
7009 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | ||
6474 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | 7010 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), |
6475 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | 7011 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), |
6476 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), | 7012 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), |
@@ -6573,7 +7109,7 @@ static struct snd_kcontrol_new alc882_chmode_mixer[] = { | |||
6573 | { } /* end */ | 7109 | { } /* end */ |
6574 | }; | 7110 | }; |
6575 | 7111 | ||
6576 | static struct hda_verb alc882_init_verbs[] = { | 7112 | static struct hda_verb alc882_base_init_verbs[] = { |
6577 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | 7113 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
6578 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 7114 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6579 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7115 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
@@ -6591,6 +7127,13 @@ static struct hda_verb alc882_init_verbs[] = { | |||
6591 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7127 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6592 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 7128 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
6593 | 7129 | ||
7130 | /* mute analog input loopbacks */ | ||
7131 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7132 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7133 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7134 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7135 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7136 | |||
6594 | /* Front Pin: output 0 (0x0c) */ | 7137 | /* Front Pin: output 0 (0x0c) */ |
6595 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | 7138 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
6596 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 7139 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
@@ -6625,11 +7168,6 @@ static struct hda_verb alc882_init_verbs[] = { | |||
6625 | 7168 | ||
6626 | /* FIXME: use matrix-type input source selection */ | 7169 | /* FIXME: use matrix-type input source selection */ |
6627 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | 7170 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
6628 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | ||
6629 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
6630 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
6631 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
6632 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
6633 | /* Input mixer2 */ | 7171 | /* Input mixer2 */ |
6634 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 7172 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
6635 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | 7173 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
@@ -6640,9 +7178,6 @@ static struct hda_verb alc882_init_verbs[] = { | |||
6640 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | 7178 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
6641 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | 7179 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
6642 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | 7180 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, |
6643 | /* ADC1: mute amp left and right */ | ||
6644 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
6645 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
6646 | /* ADC2: mute amp left and right */ | 7181 | /* ADC2: mute amp left and right */ |
6647 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7182 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6648 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7183 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -6653,6 +7188,18 @@ static struct hda_verb alc882_init_verbs[] = { | |||
6653 | { } | 7188 | { } |
6654 | }; | 7189 | }; |
6655 | 7190 | ||
7191 | static struct hda_verb alc882_adc1_init_verbs[] = { | ||
7192 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | ||
7193 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7194 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7195 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7196 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7197 | /* ADC1: mute amp left and right */ | ||
7198 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7199 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7200 | { } | ||
7201 | }; | ||
7202 | |||
6656 | static struct hda_verb alc882_eapd_verbs[] = { | 7203 | static struct hda_verb alc882_eapd_verbs[] = { |
6657 | /* change to EAPD mode */ | 7204 | /* change to EAPD mode */ |
6658 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, | 7205 | {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, |
@@ -6660,6 +7207,110 @@ static struct hda_verb alc882_eapd_verbs[] = { | |||
6660 | { } | 7207 | { } |
6661 | }; | 7208 | }; |
6662 | 7209 | ||
7210 | static struct hda_verb alc889_eapd_verbs[] = { | ||
7211 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | ||
7212 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | ||
7213 | { } | ||
7214 | }; | ||
7215 | |||
7216 | static struct hda_verb alc_hp15_unsol_verbs[] = { | ||
7217 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
7218 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
7219 | {} | ||
7220 | }; | ||
7221 | |||
7222 | static struct hda_verb alc885_init_verbs[] = { | ||
7223 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | ||
7224 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7225 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7226 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7227 | /* Rear mixer */ | ||
7228 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7229 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7230 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7231 | /* CLFE mixer */ | ||
7232 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7233 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7234 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7235 | /* Side mixer */ | ||
7236 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7237 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7238 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7239 | |||
7240 | /* mute analog input loopbacks */ | ||
7241 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7242 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7243 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7244 | |||
7245 | /* Front HP Pin: output 0 (0x0c) */ | ||
7246 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
7247 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7248 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7249 | /* Front Pin: output 0 (0x0c) */ | ||
7250 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
7251 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7252 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7253 | /* Rear Pin: output 1 (0x0d) */ | ||
7254 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
7255 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7256 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
7257 | /* CLFE Pin: output 2 (0x0e) */ | ||
7258 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
7259 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7260 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
7261 | /* Side Pin: output 3 (0x0f) */ | ||
7262 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
7263 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7264 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
7265 | /* Mic (rear) pin: input vref at 80% */ | ||
7266 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
7267 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7268 | /* Front Mic pin: input vref at 80% */ | ||
7269 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
7270 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7271 | /* Line In pin: input */ | ||
7272 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
7273 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7274 | |||
7275 | /* Mixer elements: 0x18, , 0x1a, 0x1b */ | ||
7276 | /* Input mixer1 */ | ||
7277 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | ||
7278 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7279 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7280 | /* Input mixer2 */ | ||
7281 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7282 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7283 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7284 | /* Input mixer3 */ | ||
7285 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | ||
7286 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7287 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7288 | /* ADC2: mute amp left and right */ | ||
7289 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7290 | /* ADC3: mute amp left and right */ | ||
7291 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7292 | |||
7293 | { } | ||
7294 | }; | ||
7295 | |||
7296 | static struct hda_verb alc885_init_input_verbs[] = { | ||
7297 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7298 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | ||
7299 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | ||
7300 | { } | ||
7301 | }; | ||
7302 | |||
7303 | |||
7304 | /* Unmute Selector 24h and set the default input to front mic */ | ||
7305 | static struct hda_verb alc889_init_input_verbs[] = { | ||
7306 | {0x24, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7307 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7308 | { } | ||
7309 | }; | ||
7310 | |||
7311 | |||
7312 | #define alc883_init_verbs alc882_base_init_verbs | ||
7313 | |||
6663 | /* Mac Pro test */ | 7314 | /* Mac Pro test */ |
6664 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { | 7315 | static struct snd_kcontrol_new alc882_macpro_mixer[] = { |
6665 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 7316 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
@@ -6784,14 +7435,18 @@ static struct hda_verb alc885_mbp3_init_verbs[] = { | |||
6784 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 7435 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
6785 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7436 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
6786 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 7437 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7438 | /* HP mixer */ | ||
7439 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7440 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7441 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
6787 | /* Front Pin: output 0 (0x0c) */ | 7442 | /* Front Pin: output 0 (0x0c) */ |
6788 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | 7443 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
6789 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 7444 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
6790 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7445 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, |
6791 | /* HP Pin: output 0 (0x0d) */ | 7446 | /* HP Pin: output 0 (0x0e) */ |
6792 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | 7447 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, |
6793 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | 7448 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
6794 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7449 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, |
6795 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | 7450 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
6796 | /* Mic (rear) pin: input vref at 80% */ | 7451 | /* Mic (rear) pin: input vref at 80% */ |
6797 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 7452 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
@@ -6863,23 +7518,21 @@ static struct hda_verb alc885_imac24_init_verbs[] = { | |||
6863 | }; | 7518 | }; |
6864 | 7519 | ||
6865 | /* Toggle speaker-output according to the hp-jack state */ | 7520 | /* Toggle speaker-output according to the hp-jack state */ |
6866 | static void alc885_imac24_automute_init_hook(struct hda_codec *codec) | 7521 | static void alc885_imac24_setup(struct hda_codec *codec) |
6867 | { | 7522 | { |
6868 | struct alc_spec *spec = codec->spec; | 7523 | struct alc_spec *spec = codec->spec; |
6869 | 7524 | ||
6870 | spec->autocfg.hp_pins[0] = 0x14; | 7525 | spec->autocfg.hp_pins[0] = 0x14; |
6871 | spec->autocfg.speaker_pins[0] = 0x18; | 7526 | spec->autocfg.speaker_pins[0] = 0x18; |
6872 | spec->autocfg.speaker_pins[1] = 0x1a; | 7527 | spec->autocfg.speaker_pins[1] = 0x1a; |
6873 | alc_automute_amp(codec); | ||
6874 | } | 7528 | } |
6875 | 7529 | ||
6876 | static void alc885_mbp3_init_hook(struct hda_codec *codec) | 7530 | static void alc885_mbp3_setup(struct hda_codec *codec) |
6877 | { | 7531 | { |
6878 | struct alc_spec *spec = codec->spec; | 7532 | struct alc_spec *spec = codec->spec; |
6879 | 7533 | ||
6880 | spec->autocfg.hp_pins[0] = 0x15; | 7534 | spec->autocfg.hp_pins[0] = 0x15; |
6881 | spec->autocfg.speaker_pins[0] = 0x14; | 7535 | spec->autocfg.speaker_pins[0] = 0x14; |
6882 | alc_automute_amp(codec); | ||
6883 | } | 7536 | } |
6884 | 7537 | ||
6885 | 7538 | ||
@@ -6895,9 +7548,6 @@ static struct hda_verb alc882_targa_verbs[] = { | |||
6895 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ | 7548 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ |
6896 | 7549 | ||
6897 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | 7550 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
6898 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, | ||
6899 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, | ||
6900 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, | ||
6901 | { } /* end */ | 7551 | { } /* end */ |
6902 | }; | 7552 | }; |
6903 | 7553 | ||
@@ -6910,13 +7560,12 @@ static void alc882_targa_automute(struct hda_codec *codec) | |||
6910 | spec->jack_present ? 1 : 3); | 7560 | spec->jack_present ? 1 : 3); |
6911 | } | 7561 | } |
6912 | 7562 | ||
6913 | static void alc882_targa_init_hook(struct hda_codec *codec) | 7563 | static void alc882_targa_setup(struct hda_codec *codec) |
6914 | { | 7564 | { |
6915 | struct alc_spec *spec = codec->spec; | 7565 | struct alc_spec *spec = codec->spec; |
6916 | 7566 | ||
6917 | spec->autocfg.hp_pins[0] = 0x14; | 7567 | spec->autocfg.hp_pins[0] = 0x14; |
6918 | spec->autocfg.speaker_pins[0] = 0x1b; | 7568 | spec->autocfg.speaker_pins[0] = 0x1b; |
6919 | alc882_targa_automute(codec); | ||
6920 | } | 7569 | } |
6921 | 7570 | ||
6922 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) | 7571 | static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res) |
@@ -7004,18 +7653,16 @@ static void alc885_macpro_init_hook(struct hda_codec *codec) | |||
7004 | static void alc885_imac24_init_hook(struct hda_codec *codec) | 7653 | static void alc885_imac24_init_hook(struct hda_codec *codec) |
7005 | { | 7654 | { |
7006 | alc885_macpro_init_hook(codec); | 7655 | alc885_macpro_init_hook(codec); |
7007 | alc885_imac24_automute_init_hook(codec); | 7656 | alc_automute_amp(codec); |
7008 | } | 7657 | } |
7009 | 7658 | ||
7010 | /* | 7659 | /* |
7011 | * generic initialization of ADC, input mixers and output mixers | 7660 | * generic initialization of ADC, input mixers and output mixers |
7012 | */ | 7661 | */ |
7013 | static struct hda_verb alc882_auto_init_verbs[] = { | 7662 | static struct hda_verb alc883_auto_init_verbs[] = { |
7014 | /* | 7663 | /* |
7015 | * Unmute ADC0-2 and set the default input to mic-in | 7664 | * Unmute ADC0-2 and set the default input to mic-in |
7016 | */ | 7665 | */ |
7017 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7018 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7019 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7666 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
7020 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 7667 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7021 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7668 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -7056,11 +7703,6 @@ static struct hda_verb alc882_auto_init_verbs[] = { | |||
7056 | 7703 | ||
7057 | /* FIXME: use matrix-type input source selection */ | 7704 | /* FIXME: use matrix-type input source selection */ |
7058 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | 7705 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
7059 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | ||
7060 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | ||
7061 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | ||
7062 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | ||
7063 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | ||
7064 | /* Input mixer2 */ | 7706 | /* Input mixer2 */ |
7065 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 7707 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, |
7066 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | 7708 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, |
@@ -7075,819 +7717,6 @@ static struct hda_verb alc882_auto_init_verbs[] = { | |||
7075 | { } | 7717 | { } |
7076 | }; | 7718 | }; |
7077 | 7719 | ||
7078 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
7079 | #define alc882_loopbacks alc880_loopbacks | ||
7080 | #endif | ||
7081 | |||
7082 | /* pcm configuration: identical with ALC880 */ | ||
7083 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback | ||
7084 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture | ||
7085 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback | ||
7086 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture | ||
7087 | |||
7088 | /* | ||
7089 | * configuration and preset | ||
7090 | */ | ||
7091 | static const char *alc882_models[ALC882_MODEL_LAST] = { | ||
7092 | [ALC882_3ST_DIG] = "3stack-dig", | ||
7093 | [ALC882_6ST_DIG] = "6stack-dig", | ||
7094 | [ALC882_ARIMA] = "arima", | ||
7095 | [ALC882_W2JC] = "w2jc", | ||
7096 | [ALC882_TARGA] = "targa", | ||
7097 | [ALC882_ASUS_A7J] = "asus-a7j", | ||
7098 | [ALC882_ASUS_A7M] = "asus-a7m", | ||
7099 | [ALC885_MACPRO] = "macpro", | ||
7100 | [ALC885_MB5] = "mb5", | ||
7101 | [ALC885_MBP3] = "mbp3", | ||
7102 | [ALC885_IMAC24] = "imac24", | ||
7103 | [ALC882_AUTO] = "auto", | ||
7104 | }; | ||
7105 | |||
7106 | static struct snd_pci_quirk alc882_cfg_tbl[] = { | ||
7107 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), | ||
7108 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), | ||
7109 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), | ||
7110 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), | ||
7111 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), | ||
7112 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), | ||
7113 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), | ||
7114 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), | ||
7115 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), | ||
7116 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ | ||
7117 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | ||
7118 | SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), | ||
7119 | {} | ||
7120 | }; | ||
7121 | |||
7122 | static struct alc_config_preset alc882_presets[] = { | ||
7123 | [ALC882_3ST_DIG] = { | ||
7124 | .mixers = { alc882_base_mixer }, | ||
7125 | .init_verbs = { alc882_init_verbs }, | ||
7126 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7127 | .dac_nids = alc882_dac_nids, | ||
7128 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7129 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7130 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
7131 | .channel_mode = alc882_ch_modes, | ||
7132 | .need_dac_fix = 1, | ||
7133 | .input_mux = &alc882_capture_source, | ||
7134 | }, | ||
7135 | [ALC882_6ST_DIG] = { | ||
7136 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | ||
7137 | .init_verbs = { alc882_init_verbs }, | ||
7138 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7139 | .dac_nids = alc882_dac_nids, | ||
7140 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7141 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7142 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | ||
7143 | .channel_mode = alc882_sixstack_modes, | ||
7144 | .input_mux = &alc882_capture_source, | ||
7145 | }, | ||
7146 | [ALC882_ARIMA] = { | ||
7147 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | ||
7148 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs }, | ||
7149 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7150 | .dac_nids = alc882_dac_nids, | ||
7151 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | ||
7152 | .channel_mode = alc882_sixstack_modes, | ||
7153 | .input_mux = &alc882_capture_source, | ||
7154 | }, | ||
7155 | [ALC882_W2JC] = { | ||
7156 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | ||
7157 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | ||
7158 | alc880_gpio1_init_verbs }, | ||
7159 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7160 | .dac_nids = alc882_dac_nids, | ||
7161 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | ||
7162 | .channel_mode = alc880_threestack_modes, | ||
7163 | .need_dac_fix = 1, | ||
7164 | .input_mux = &alc882_capture_source, | ||
7165 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7166 | }, | ||
7167 | [ALC885_MBP3] = { | ||
7168 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | ||
7169 | .init_verbs = { alc885_mbp3_init_verbs, | ||
7170 | alc880_gpio1_init_verbs }, | ||
7171 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7172 | .dac_nids = alc882_dac_nids, | ||
7173 | .channel_mode = alc885_mbp_6ch_modes, | ||
7174 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), | ||
7175 | .input_mux = &alc882_capture_source, | ||
7176 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7177 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7178 | .unsol_event = alc_automute_amp_unsol_event, | ||
7179 | .init_hook = alc885_mbp3_init_hook, | ||
7180 | }, | ||
7181 | [ALC885_MB5] = { | ||
7182 | .mixers = { alc885_mb5_mixer, alc882_chmode_mixer }, | ||
7183 | .init_verbs = { alc885_mb5_init_verbs, | ||
7184 | alc880_gpio1_init_verbs }, | ||
7185 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7186 | .dac_nids = alc882_dac_nids, | ||
7187 | .channel_mode = alc885_mb5_6ch_modes, | ||
7188 | .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes), | ||
7189 | .input_mux = &mb5_capture_source, | ||
7190 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7191 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7192 | }, | ||
7193 | [ALC885_MACPRO] = { | ||
7194 | .mixers = { alc882_macpro_mixer }, | ||
7195 | .init_verbs = { alc882_macpro_init_verbs }, | ||
7196 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7197 | .dac_nids = alc882_dac_nids, | ||
7198 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7199 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7200 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
7201 | .channel_mode = alc882_ch_modes, | ||
7202 | .input_mux = &alc882_capture_source, | ||
7203 | .init_hook = alc885_macpro_init_hook, | ||
7204 | }, | ||
7205 | [ALC885_IMAC24] = { | ||
7206 | .mixers = { alc885_imac24_mixer }, | ||
7207 | .init_verbs = { alc885_imac24_init_verbs }, | ||
7208 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7209 | .dac_nids = alc882_dac_nids, | ||
7210 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7211 | .dig_in_nid = ALC882_DIGIN_NID, | ||
7212 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
7213 | .channel_mode = alc882_ch_modes, | ||
7214 | .input_mux = &alc882_capture_source, | ||
7215 | .unsol_event = alc_automute_amp_unsol_event, | ||
7216 | .init_hook = alc885_imac24_init_hook, | ||
7217 | }, | ||
7218 | [ALC882_TARGA] = { | ||
7219 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, | ||
7220 | .init_verbs = { alc882_init_verbs, alc882_targa_verbs}, | ||
7221 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7222 | .dac_nids = alc882_dac_nids, | ||
7223 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7224 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | ||
7225 | .adc_nids = alc882_adc_nids, | ||
7226 | .capsrc_nids = alc882_capsrc_nids, | ||
7227 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | ||
7228 | .channel_mode = alc882_3ST_6ch_modes, | ||
7229 | .need_dac_fix = 1, | ||
7230 | .input_mux = &alc882_capture_source, | ||
7231 | .unsol_event = alc882_targa_unsol_event, | ||
7232 | .init_hook = alc882_targa_init_hook, | ||
7233 | }, | ||
7234 | [ALC882_ASUS_A7J] = { | ||
7235 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, | ||
7236 | .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs}, | ||
7237 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7238 | .dac_nids = alc882_dac_nids, | ||
7239 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7240 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | ||
7241 | .adc_nids = alc882_adc_nids, | ||
7242 | .capsrc_nids = alc882_capsrc_nids, | ||
7243 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | ||
7244 | .channel_mode = alc882_3ST_6ch_modes, | ||
7245 | .need_dac_fix = 1, | ||
7246 | .input_mux = &alc882_capture_source, | ||
7247 | }, | ||
7248 | [ALC882_ASUS_A7M] = { | ||
7249 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | ||
7250 | .init_verbs = { alc882_init_verbs, alc882_eapd_verbs, | ||
7251 | alc880_gpio1_init_verbs, | ||
7252 | alc882_asus_a7m_verbs }, | ||
7253 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
7254 | .dac_nids = alc882_dac_nids, | ||
7255 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
7256 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | ||
7257 | .channel_mode = alc880_threestack_modes, | ||
7258 | .need_dac_fix = 1, | ||
7259 | .input_mux = &alc882_capture_source, | ||
7260 | }, | ||
7261 | }; | ||
7262 | |||
7263 | |||
7264 | /* | ||
7265 | * Pin config fixes | ||
7266 | */ | ||
7267 | enum { | ||
7268 | PINFIX_ABIT_AW9D_MAX | ||
7269 | }; | ||
7270 | |||
7271 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | ||
7272 | { 0x15, 0x01080104 }, /* side */ | ||
7273 | { 0x16, 0x01011012 }, /* rear */ | ||
7274 | { 0x17, 0x01016011 }, /* clfe */ | ||
7275 | { } | ||
7276 | }; | ||
7277 | |||
7278 | static const struct alc_pincfg *alc882_pin_fixes[] = { | ||
7279 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | ||
7280 | }; | ||
7281 | |||
7282 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | ||
7283 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | ||
7284 | {} | ||
7285 | }; | ||
7286 | |||
7287 | /* | ||
7288 | * BIOS auto configuration | ||
7289 | */ | ||
7290 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | ||
7291 | hda_nid_t nid, int pin_type, | ||
7292 | int dac_idx) | ||
7293 | { | ||
7294 | /* set as output */ | ||
7295 | struct alc_spec *spec = codec->spec; | ||
7296 | int idx; | ||
7297 | |||
7298 | alc_set_pin_output(codec, nid, pin_type); | ||
7299 | if (spec->multiout.dac_nids[dac_idx] == 0x25) | ||
7300 | idx = 4; | ||
7301 | else | ||
7302 | idx = spec->multiout.dac_nids[dac_idx] - 2; | ||
7303 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); | ||
7304 | |||
7305 | } | ||
7306 | |||
7307 | static void alc882_auto_init_multi_out(struct hda_codec *codec) | ||
7308 | { | ||
7309 | struct alc_spec *spec = codec->spec; | ||
7310 | int i; | ||
7311 | |||
7312 | for (i = 0; i <= HDA_SIDE; i++) { | ||
7313 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | ||
7314 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | ||
7315 | if (nid) | ||
7316 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, | ||
7317 | i); | ||
7318 | } | ||
7319 | } | ||
7320 | |||
7321 | static void alc882_auto_init_hp_out(struct hda_codec *codec) | ||
7322 | { | ||
7323 | struct alc_spec *spec = codec->spec; | ||
7324 | hda_nid_t pin; | ||
7325 | |||
7326 | pin = spec->autocfg.hp_pins[0]; | ||
7327 | if (pin) /* connect to front */ | ||
7328 | /* use dac 0 */ | ||
7329 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | ||
7330 | pin = spec->autocfg.speaker_pins[0]; | ||
7331 | if (pin) | ||
7332 | alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | ||
7333 | } | ||
7334 | |||
7335 | #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) | ||
7336 | #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID | ||
7337 | |||
7338 | static void alc882_auto_init_analog_input(struct hda_codec *codec) | ||
7339 | { | ||
7340 | struct alc_spec *spec = codec->spec; | ||
7341 | int i; | ||
7342 | |||
7343 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
7344 | hda_nid_t nid = spec->autocfg.input_pins[i]; | ||
7345 | if (!nid) | ||
7346 | continue; | ||
7347 | alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/); | ||
7348 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) | ||
7349 | snd_hda_codec_write(codec, nid, 0, | ||
7350 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
7351 | AMP_OUT_MUTE); | ||
7352 | } | ||
7353 | } | ||
7354 | |||
7355 | static void alc882_auto_init_input_src(struct hda_codec *codec) | ||
7356 | { | ||
7357 | struct alc_spec *spec = codec->spec; | ||
7358 | int c; | ||
7359 | |||
7360 | for (c = 0; c < spec->num_adc_nids; c++) { | ||
7361 | hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; | ||
7362 | hda_nid_t nid = spec->capsrc_nids[c]; | ||
7363 | unsigned int mux_idx; | ||
7364 | const struct hda_input_mux *imux; | ||
7365 | int conns, mute, idx, item; | ||
7366 | |||
7367 | conns = snd_hda_get_connections(codec, nid, conn_list, | ||
7368 | ARRAY_SIZE(conn_list)); | ||
7369 | if (conns < 0) | ||
7370 | continue; | ||
7371 | mux_idx = c >= spec->num_mux_defs ? 0 : c; | ||
7372 | imux = &spec->input_mux[mux_idx]; | ||
7373 | for (idx = 0; idx < conns; idx++) { | ||
7374 | /* if the current connection is the selected one, | ||
7375 | * unmute it as default - otherwise mute it | ||
7376 | */ | ||
7377 | mute = AMP_IN_MUTE(idx); | ||
7378 | for (item = 0; item < imux->num_items; item++) { | ||
7379 | if (imux->items[item].index == idx) { | ||
7380 | if (spec->cur_mux[c] == item) | ||
7381 | mute = AMP_IN_UNMUTE(idx); | ||
7382 | break; | ||
7383 | } | ||
7384 | } | ||
7385 | /* check if we have a selector or mixer | ||
7386 | * we could check for the widget type instead, but | ||
7387 | * just check for Amp-In presence (in case of mixer | ||
7388 | * without amp-in there is something wrong, this | ||
7389 | * function shouldn't be used or capsrc nid is wrong) | ||
7390 | */ | ||
7391 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) | ||
7392 | snd_hda_codec_write(codec, nid, 0, | ||
7393 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
7394 | mute); | ||
7395 | else if (mute != AMP_IN_MUTE(idx)) | ||
7396 | snd_hda_codec_write(codec, nid, 0, | ||
7397 | AC_VERB_SET_CONNECT_SEL, | ||
7398 | idx); | ||
7399 | } | ||
7400 | } | ||
7401 | } | ||
7402 | |||
7403 | /* add mic boosts if needed */ | ||
7404 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | ||
7405 | { | ||
7406 | struct alc_spec *spec = codec->spec; | ||
7407 | int err; | ||
7408 | hda_nid_t nid; | ||
7409 | |||
7410 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | ||
7411 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { | ||
7412 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
7413 | "Mic Boost", | ||
7414 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | ||
7415 | if (err < 0) | ||
7416 | return err; | ||
7417 | } | ||
7418 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | ||
7419 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { | ||
7420 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
7421 | "Front Mic Boost", | ||
7422 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | ||
7423 | if (err < 0) | ||
7424 | return err; | ||
7425 | } | ||
7426 | return 0; | ||
7427 | } | ||
7428 | |||
7429 | /* almost identical with ALC880 parser... */ | ||
7430 | static int alc882_parse_auto_config(struct hda_codec *codec) | ||
7431 | { | ||
7432 | struct alc_spec *spec = codec->spec; | ||
7433 | int err = alc880_parse_auto_config(codec); | ||
7434 | |||
7435 | if (err < 0) | ||
7436 | return err; | ||
7437 | else if (!err) | ||
7438 | return 0; /* no config found */ | ||
7439 | |||
7440 | err = alc_auto_add_mic_boost(codec); | ||
7441 | if (err < 0) | ||
7442 | return err; | ||
7443 | |||
7444 | /* hack - override the init verbs */ | ||
7445 | spec->init_verbs[0] = alc882_auto_init_verbs; | ||
7446 | |||
7447 | return 1; /* config found */ | ||
7448 | } | ||
7449 | |||
7450 | /* additional initialization for auto-configuration model */ | ||
7451 | static void alc882_auto_init(struct hda_codec *codec) | ||
7452 | { | ||
7453 | struct alc_spec *spec = codec->spec; | ||
7454 | alc882_auto_init_multi_out(codec); | ||
7455 | alc882_auto_init_hp_out(codec); | ||
7456 | alc882_auto_init_analog_input(codec); | ||
7457 | alc882_auto_init_input_src(codec); | ||
7458 | if (spec->unsol_event) | ||
7459 | alc_inithook(codec); | ||
7460 | } | ||
7461 | |||
7462 | static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */ | ||
7463 | |||
7464 | static int patch_alc882(struct hda_codec *codec) | ||
7465 | { | ||
7466 | struct alc_spec *spec; | ||
7467 | int err, board_config; | ||
7468 | |||
7469 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
7470 | if (spec == NULL) | ||
7471 | return -ENOMEM; | ||
7472 | |||
7473 | codec->spec = spec; | ||
7474 | |||
7475 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, | ||
7476 | alc882_models, | ||
7477 | alc882_cfg_tbl); | ||
7478 | |||
7479 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { | ||
7480 | /* Pick up systems that don't supply PCI SSID */ | ||
7481 | switch (codec->subsystem_id) { | ||
7482 | case 0x106b0c00: /* Mac Pro */ | ||
7483 | board_config = ALC885_MACPRO; | ||
7484 | break; | ||
7485 | case 0x106b1000: /* iMac 24 */ | ||
7486 | case 0x106b2800: /* AppleTV */ | ||
7487 | case 0x106b3e00: /* iMac 24 Aluminium */ | ||
7488 | board_config = ALC885_IMAC24; | ||
7489 | break; | ||
7490 | case 0x106b00a0: /* MacBookPro3,1 - Another revision */ | ||
7491 | case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */ | ||
7492 | case 0x106b00a4: /* MacbookPro4,1 */ | ||
7493 | case 0x106b2c00: /* Macbook Pro rev3 */ | ||
7494 | /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */ | ||
7495 | case 0x106b3800: /* MacbookPro4,1 - latter revision */ | ||
7496 | board_config = ALC885_MBP3; | ||
7497 | break; | ||
7498 | case 0x106b3f00: /* Macbook 5,1 */ | ||
7499 | case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense | ||
7500 | * seems not working, so apparently | ||
7501 | * no perfect solution yet | ||
7502 | */ | ||
7503 | board_config = ALC885_MB5; | ||
7504 | break; | ||
7505 | default: | ||
7506 | /* ALC889A is handled better as ALC888-compatible */ | ||
7507 | if (codec->revision_id == 0x100101 || | ||
7508 | codec->revision_id == 0x100103) { | ||
7509 | alc_free(codec); | ||
7510 | return patch_alc883(codec); | ||
7511 | } | ||
7512 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | ||
7513 | "trying auto-probe from BIOS...\n", | ||
7514 | codec->chip_name); | ||
7515 | board_config = ALC882_AUTO; | ||
7516 | } | ||
7517 | } | ||
7518 | |||
7519 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); | ||
7520 | |||
7521 | if (board_config == ALC882_AUTO) { | ||
7522 | /* automatic parse from the BIOS config */ | ||
7523 | err = alc882_parse_auto_config(codec); | ||
7524 | if (err < 0) { | ||
7525 | alc_free(codec); | ||
7526 | return err; | ||
7527 | } else if (!err) { | ||
7528 | printk(KERN_INFO | ||
7529 | "hda_codec: Cannot set up configuration " | ||
7530 | "from BIOS. Using base mode...\n"); | ||
7531 | board_config = ALC882_3ST_DIG; | ||
7532 | } | ||
7533 | } | ||
7534 | |||
7535 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
7536 | if (err < 0) { | ||
7537 | alc_free(codec); | ||
7538 | return err; | ||
7539 | } | ||
7540 | |||
7541 | if (board_config != ALC882_AUTO) | ||
7542 | setup_preset(spec, &alc882_presets[board_config]); | ||
7543 | |||
7544 | spec->stream_analog_playback = &alc882_pcm_analog_playback; | ||
7545 | spec->stream_analog_capture = &alc882_pcm_analog_capture; | ||
7546 | /* FIXME: setup DAC5 */ | ||
7547 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ | ||
7548 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; | ||
7549 | |||
7550 | spec->stream_digital_playback = &alc882_pcm_digital_playback; | ||
7551 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | ||
7552 | |||
7553 | if (!spec->adc_nids && spec->input_mux) { | ||
7554 | /* check whether NID 0x07 is valid */ | ||
7555 | unsigned int wcap = get_wcaps(codec, 0x07); | ||
7556 | /* get type */ | ||
7557 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
7558 | if (wcap != AC_WID_AUD_IN) { | ||
7559 | spec->adc_nids = alc882_adc_nids_alt; | ||
7560 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); | ||
7561 | spec->capsrc_nids = alc882_capsrc_nids_alt; | ||
7562 | } else { | ||
7563 | spec->adc_nids = alc882_adc_nids; | ||
7564 | spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); | ||
7565 | spec->capsrc_nids = alc882_capsrc_nids; | ||
7566 | } | ||
7567 | } | ||
7568 | set_capture_mixer(spec); | ||
7569 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | ||
7570 | |||
7571 | spec->vmaster_nid = 0x0c; | ||
7572 | |||
7573 | codec->patch_ops = alc_patch_ops; | ||
7574 | if (board_config == ALC882_AUTO) | ||
7575 | spec->init_hook = alc882_auto_init; | ||
7576 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
7577 | if (!spec->loopback.amplist) | ||
7578 | spec->loopback.amplist = alc882_loopbacks; | ||
7579 | #endif | ||
7580 | codec->proc_widget_hook = print_realtek_coef; | ||
7581 | |||
7582 | return 0; | ||
7583 | } | ||
7584 | |||
7585 | /* | ||
7586 | * ALC883 support | ||
7587 | * | ||
7588 | * ALC883 is almost identical with ALC880 but has cleaner and more flexible | ||
7589 | * configuration. Each pin widget can choose any input DACs and a mixer. | ||
7590 | * Each ADC is connected from a mixer of all inputs. This makes possible | ||
7591 | * 6-channel independent captures. | ||
7592 | * | ||
7593 | * In addition, an independent DAC for the multi-playback (not used in this | ||
7594 | * driver yet). | ||
7595 | */ | ||
7596 | #define ALC883_DIGOUT_NID 0x06 | ||
7597 | #define ALC883_DIGIN_NID 0x0a | ||
7598 | |||
7599 | #define ALC1200_DIGOUT_NID 0x10 | ||
7600 | |||
7601 | static hda_nid_t alc883_dac_nids[4] = { | ||
7602 | /* front, rear, clfe, rear_surr */ | ||
7603 | 0x02, 0x03, 0x04, 0x05 | ||
7604 | }; | ||
7605 | |||
7606 | static hda_nid_t alc883_adc_nids[2] = { | ||
7607 | /* ADC1-2 */ | ||
7608 | 0x08, 0x09, | ||
7609 | }; | ||
7610 | |||
7611 | static hda_nid_t alc883_adc_nids_alt[1] = { | ||
7612 | /* ADC1 */ | ||
7613 | 0x08, | ||
7614 | }; | ||
7615 | |||
7616 | static hda_nid_t alc883_adc_nids_rev[2] = { | ||
7617 | /* ADC2-1 */ | ||
7618 | 0x09, 0x08 | ||
7619 | }; | ||
7620 | |||
7621 | #define alc889_adc_nids alc880_adc_nids | ||
7622 | |||
7623 | static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; | ||
7624 | |||
7625 | static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 }; | ||
7626 | |||
7627 | #define alc889_capsrc_nids alc882_capsrc_nids | ||
7628 | |||
7629 | /* input MUX */ | ||
7630 | /* FIXME: should be a matrix-type input source selection */ | ||
7631 | |||
7632 | static struct hda_input_mux alc883_capture_source = { | ||
7633 | .num_items = 4, | ||
7634 | .items = { | ||
7635 | { "Mic", 0x0 }, | ||
7636 | { "Front Mic", 0x1 }, | ||
7637 | { "Line", 0x2 }, | ||
7638 | { "CD", 0x4 }, | ||
7639 | }, | ||
7640 | }; | ||
7641 | |||
7642 | static struct hda_input_mux alc883_3stack_6ch_intel = { | ||
7643 | .num_items = 4, | ||
7644 | .items = { | ||
7645 | { "Mic", 0x1 }, | ||
7646 | { "Front Mic", 0x0 }, | ||
7647 | { "Line", 0x2 }, | ||
7648 | { "CD", 0x4 }, | ||
7649 | }, | ||
7650 | }; | ||
7651 | |||
7652 | static struct hda_input_mux alc883_lenovo_101e_capture_source = { | ||
7653 | .num_items = 2, | ||
7654 | .items = { | ||
7655 | { "Mic", 0x1 }, | ||
7656 | { "Line", 0x2 }, | ||
7657 | }, | ||
7658 | }; | ||
7659 | |||
7660 | static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { | ||
7661 | .num_items = 4, | ||
7662 | .items = { | ||
7663 | { "Mic", 0x0 }, | ||
7664 | { "iMic", 0x1 }, | ||
7665 | { "Line", 0x2 }, | ||
7666 | { "CD", 0x4 }, | ||
7667 | }, | ||
7668 | }; | ||
7669 | |||
7670 | static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = { | ||
7671 | .num_items = 2, | ||
7672 | .items = { | ||
7673 | { "Mic", 0x0 }, | ||
7674 | { "Int Mic", 0x1 }, | ||
7675 | }, | ||
7676 | }; | ||
7677 | |||
7678 | static struct hda_input_mux alc883_lenovo_sky_capture_source = { | ||
7679 | .num_items = 3, | ||
7680 | .items = { | ||
7681 | { "Mic", 0x0 }, | ||
7682 | { "Front Mic", 0x1 }, | ||
7683 | { "Line", 0x4 }, | ||
7684 | }, | ||
7685 | }; | ||
7686 | |||
7687 | static struct hda_input_mux alc883_asus_eee1601_capture_source = { | ||
7688 | .num_items = 2, | ||
7689 | .items = { | ||
7690 | { "Mic", 0x0 }, | ||
7691 | { "Line", 0x2 }, | ||
7692 | }, | ||
7693 | }; | ||
7694 | |||
7695 | static struct hda_input_mux alc889A_mb31_capture_source = { | ||
7696 | .num_items = 2, | ||
7697 | .items = { | ||
7698 | { "Mic", 0x0 }, | ||
7699 | /* Front Mic (0x01) unused */ | ||
7700 | { "Line", 0x2 }, | ||
7701 | /* Line 2 (0x03) unused */ | ||
7702 | /* CD (0x04) unsused? */ | ||
7703 | }, | ||
7704 | }; | ||
7705 | |||
7706 | /* | ||
7707 | * 2ch mode | ||
7708 | */ | ||
7709 | static struct hda_channel_mode alc883_3ST_2ch_modes[1] = { | ||
7710 | { 2, NULL } | ||
7711 | }; | ||
7712 | |||
7713 | /* | ||
7714 | * 2ch mode | ||
7715 | */ | ||
7716 | static struct hda_verb alc883_3ST_ch2_init[] = { | ||
7717 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7718 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7719 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
7720 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7721 | { } /* end */ | ||
7722 | }; | ||
7723 | |||
7724 | /* | ||
7725 | * 4ch mode | ||
7726 | */ | ||
7727 | static struct hda_verb alc883_3ST_ch4_init[] = { | ||
7728 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7729 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7730 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7731 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7732 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7733 | { } /* end */ | ||
7734 | }; | ||
7735 | |||
7736 | /* | ||
7737 | * 6ch mode | ||
7738 | */ | ||
7739 | static struct hda_verb alc883_3ST_ch6_init[] = { | ||
7740 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7741 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7742 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
7743 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7744 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7745 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7746 | { } /* end */ | ||
7747 | }; | ||
7748 | |||
7749 | static struct hda_channel_mode alc883_3ST_6ch_modes[3] = { | ||
7750 | { 2, alc883_3ST_ch2_init }, | ||
7751 | { 4, alc883_3ST_ch4_init }, | ||
7752 | { 6, alc883_3ST_ch6_init }, | ||
7753 | }; | ||
7754 | |||
7755 | |||
7756 | /* | ||
7757 | * 2ch mode | ||
7758 | */ | ||
7759 | static struct hda_verb alc883_4ST_ch2_init[] = { | ||
7760 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7761 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7762 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7763 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7764 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
7765 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7766 | { } /* end */ | ||
7767 | }; | ||
7768 | |||
7769 | /* | ||
7770 | * 4ch mode | ||
7771 | */ | ||
7772 | static struct hda_verb alc883_4ST_ch4_init[] = { | ||
7773 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7774 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7775 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7776 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7777 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7778 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7779 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7780 | { } /* end */ | ||
7781 | }; | ||
7782 | |||
7783 | /* | ||
7784 | * 6ch mode | ||
7785 | */ | ||
7786 | static struct hda_verb alc883_4ST_ch6_init[] = { | ||
7787 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7788 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7789 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7790 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7791 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
7792 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7793 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7794 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7795 | { } /* end */ | ||
7796 | }; | ||
7797 | |||
7798 | /* | ||
7799 | * 8ch mode | ||
7800 | */ | ||
7801 | static struct hda_verb alc883_4ST_ch8_init[] = { | ||
7802 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7803 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7804 | { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 }, | ||
7805 | { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7806 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7807 | { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
7808 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7809 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7810 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7811 | { } /* end */ | ||
7812 | }; | ||
7813 | |||
7814 | static struct hda_channel_mode alc883_4ST_8ch_modes[4] = { | ||
7815 | { 2, alc883_4ST_ch2_init }, | ||
7816 | { 4, alc883_4ST_ch4_init }, | ||
7817 | { 6, alc883_4ST_ch6_init }, | ||
7818 | { 8, alc883_4ST_ch8_init }, | ||
7819 | }; | ||
7820 | |||
7821 | |||
7822 | /* | ||
7823 | * 2ch mode | ||
7824 | */ | ||
7825 | static struct hda_verb alc883_3ST_ch2_intel_init[] = { | ||
7826 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7827 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7828 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, | ||
7829 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7830 | { } /* end */ | ||
7831 | }; | ||
7832 | |||
7833 | /* | ||
7834 | * 4ch mode | ||
7835 | */ | ||
7836 | static struct hda_verb alc883_3ST_ch4_intel_init[] = { | ||
7837 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, | ||
7838 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | ||
7839 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7840 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7841 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7842 | { } /* end */ | ||
7843 | }; | ||
7844 | |||
7845 | /* | ||
7846 | * 6ch mode | ||
7847 | */ | ||
7848 | static struct hda_verb alc883_3ST_ch6_intel_init[] = { | ||
7849 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7850 | { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7851 | { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
7852 | { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7853 | { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, | ||
7854 | { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
7855 | { } /* end */ | ||
7856 | }; | ||
7857 | |||
7858 | static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = { | ||
7859 | { 2, alc883_3ST_ch2_intel_init }, | ||
7860 | { 4, alc883_3ST_ch4_intel_init }, | ||
7861 | { 6, alc883_3ST_ch6_intel_init }, | ||
7862 | }; | ||
7863 | |||
7864 | /* | ||
7865 | * 6ch mode | ||
7866 | */ | ||
7867 | static struct hda_verb alc883_sixstack_ch6_init[] = { | ||
7868 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, | ||
7869 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7870 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7871 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7872 | { } /* end */ | ||
7873 | }; | ||
7874 | |||
7875 | /* | ||
7876 | * 8ch mode | ||
7877 | */ | ||
7878 | static struct hda_verb alc883_sixstack_ch8_init[] = { | ||
7879 | { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7880 | { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7881 | { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7882 | { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, | ||
7883 | { } /* end */ | ||
7884 | }; | ||
7885 | |||
7886 | static struct hda_channel_mode alc883_sixstack_modes[2] = { | ||
7887 | { 6, alc883_sixstack_ch6_init }, | ||
7888 | { 8, alc883_sixstack_ch8_init }, | ||
7889 | }; | ||
7890 | |||
7891 | /* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */ | 7720 | /* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */ |
7892 | static struct hda_verb alc889A_mb31_ch2_init[] = { | 7721 | static struct hda_verb alc889A_mb31_ch2_init[] = { |
7893 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */ | 7722 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */ |
@@ -7938,34 +7767,7 @@ static struct hda_verb alc883_medion_eapd_verbs[] = { | |||
7938 | { } | 7767 | { } |
7939 | }; | 7768 | }; |
7940 | 7769 | ||
7941 | /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 | 7770 | #define alc883_base_mixer alc882_base_mixer |
7942 | * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b | ||
7943 | */ | ||
7944 | |||
7945 | static struct snd_kcontrol_new alc883_base_mixer[] = { | ||
7946 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
7947 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | ||
7948 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
7949 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | ||
7950 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), | ||
7951 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | ||
7952 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | ||
7953 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | ||
7954 | HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | ||
7955 | HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), | ||
7956 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), | ||
7957 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | ||
7958 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | ||
7959 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
7960 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
7961 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
7962 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
7963 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
7964 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), | ||
7965 | HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), | ||
7966 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), | ||
7967 | { } /* end */ | ||
7968 | }; | ||
7969 | 7771 | ||
7970 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { | 7772 | static struct snd_kcontrol_new alc883_mitac_mixer[] = { |
7971 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 7773 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
@@ -8076,6 +7878,30 @@ static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = { | |||
8076 | { } /* end */ | 7878 | { } /* end */ |
8077 | }; | 7879 | }; |
8078 | 7880 | ||
7881 | static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = { | ||
7882 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
7883 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | ||
7884 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), | ||
7885 | HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), | ||
7886 | HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, | ||
7887 | HDA_OUTPUT), | ||
7888 | HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), | ||
7889 | HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), | ||
7890 | HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), | ||
7891 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | ||
7892 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT), | ||
7893 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | ||
7894 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
7895 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
7896 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), | ||
7897 | HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT), | ||
7898 | HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), | ||
7899 | HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | ||
7900 | HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), | ||
7901 | HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), | ||
7902 | { } /* end */ | ||
7903 | }; | ||
7904 | |||
8079 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { | 7905 | static struct snd_kcontrol_new alc883_fivestack_mixer[] = { |
8080 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 7906 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
8081 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | 7907 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
@@ -8189,6 +8015,8 @@ static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = { | |||
8189 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), | 8015 | HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), |
8190 | HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT), | 8016 | HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT), |
8191 | HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT), | 8017 | HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT), |
8018 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), | ||
8019 | HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), | ||
8192 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | 8020 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
8193 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | 8021 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
8194 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), | 8022 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), |
@@ -8314,93 +8142,14 @@ static struct snd_kcontrol_new alc883_chmode_mixer[] = { | |||
8314 | { } /* end */ | 8142 | { } /* end */ |
8315 | }; | 8143 | }; |
8316 | 8144 | ||
8317 | static struct hda_verb alc883_init_verbs[] = { | ||
8318 | /* ADC1: mute amp left and right */ | ||
8319 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8320 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8321 | /* ADC2: mute amp left and right */ | ||
8322 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8323 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8324 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | ||
8325 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8326 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8327 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8328 | /* Rear mixer */ | ||
8329 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8330 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8331 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8332 | /* CLFE mixer */ | ||
8333 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8334 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8335 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8336 | /* Side mixer */ | ||
8337 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8338 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8339 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8340 | |||
8341 | /* mute analog input loopbacks */ | ||
8342 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8343 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8344 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
8345 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
8346 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
8347 | |||
8348 | /* Front Pin: output 0 (0x0c) */ | ||
8349 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8350 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8351 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8352 | /* Rear Pin: output 1 (0x0d) */ | ||
8353 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8354 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8355 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
8356 | /* CLFE Pin: output 2 (0x0e) */ | ||
8357 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8358 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8359 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
8360 | /* Side Pin: output 3 (0x0f) */ | ||
8361 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
8362 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8363 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
8364 | /* Mic (rear) pin: input vref at 80% */ | ||
8365 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
8366 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
8367 | /* Front Mic pin: input vref at 80% */ | ||
8368 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
8369 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
8370 | /* Line In pin: input */ | ||
8371 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
8372 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
8373 | /* Line-2 In: Headphone output (output 0 - 0x0c) */ | ||
8374 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
8375 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
8376 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8377 | /* CD pin widget for input */ | ||
8378 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
8379 | |||
8380 | /* FIXME: use matrix-type input source selection */ | ||
8381 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | ||
8382 | /* Input mixer2 */ | ||
8383 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8384 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8385 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
8386 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
8387 | /* Input mixer3 */ | ||
8388 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8389 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8390 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
8391 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
8392 | { } | ||
8393 | }; | ||
8394 | |||
8395 | /* toggle speaker-output according to the hp-jack state */ | 8145 | /* toggle speaker-output according to the hp-jack state */ |
8396 | static void alc883_mitac_init_hook(struct hda_codec *codec) | 8146 | static void alc883_mitac_setup(struct hda_codec *codec) |
8397 | { | 8147 | { |
8398 | struct alc_spec *spec = codec->spec; | 8148 | struct alc_spec *spec = codec->spec; |
8399 | 8149 | ||
8400 | spec->autocfg.hp_pins[0] = 0x15; | 8150 | spec->autocfg.hp_pins[0] = 0x15; |
8401 | spec->autocfg.speaker_pins[0] = 0x14; | 8151 | spec->autocfg.speaker_pins[0] = 0x14; |
8402 | spec->autocfg.speaker_pins[1] = 0x17; | 8152 | spec->autocfg.speaker_pins[1] = 0x17; |
8403 | alc_automute_amp(codec); | ||
8404 | } | 8153 | } |
8405 | 8154 | ||
8406 | /* auto-toggle front mic */ | 8155 | /* auto-toggle front mic */ |
@@ -8432,6 +8181,22 @@ static struct hda_verb alc883_mitac_verbs[] = { | |||
8432 | { } /* end */ | 8181 | { } /* end */ |
8433 | }; | 8182 | }; |
8434 | 8183 | ||
8184 | static struct hda_verb alc883_clevo_m540r_verbs[] = { | ||
8185 | /* HP */ | ||
8186 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8187 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
8188 | /* Int speaker */ | ||
8189 | /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/ | ||
8190 | |||
8191 | /* enable unsolicited event */ | ||
8192 | /* | ||
8193 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | ||
8194 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | ||
8195 | */ | ||
8196 | |||
8197 | { } /* end */ | ||
8198 | }; | ||
8199 | |||
8435 | static struct hda_verb alc883_clevo_m720_verbs[] = { | 8200 | static struct hda_verb alc883_clevo_m720_verbs[] = { |
8436 | /* HP */ | 8201 | /* HP */ |
8437 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | 8202 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -8555,7 +8320,7 @@ static struct hda_verb alc883_vaiott_verbs[] = { | |||
8555 | { } /* end */ | 8320 | { } /* end */ |
8556 | }; | 8321 | }; |
8557 | 8322 | ||
8558 | static void alc888_3st_hp_init_hook(struct hda_codec *codec) | 8323 | static void alc888_3st_hp_setup(struct hda_codec *codec) |
8559 | { | 8324 | { |
8560 | struct alc_spec *spec = codec->spec; | 8325 | struct alc_spec *spec = codec->spec; |
8561 | 8326 | ||
@@ -8563,7 +8328,6 @@ static void alc888_3st_hp_init_hook(struct hda_codec *codec) | |||
8563 | spec->autocfg.speaker_pins[0] = 0x14; | 8328 | spec->autocfg.speaker_pins[0] = 0x14; |
8564 | spec->autocfg.speaker_pins[1] = 0x16; | 8329 | spec->autocfg.speaker_pins[1] = 0x16; |
8565 | spec->autocfg.speaker_pins[2] = 0x18; | 8330 | spec->autocfg.speaker_pins[2] = 0x18; |
8566 | alc_automute_amp(codec); | ||
8567 | } | 8331 | } |
8568 | 8332 | ||
8569 | static struct hda_verb alc888_3st_hp_verbs[] = { | 8333 | static struct hda_verb alc888_3st_hp_verbs[] = { |
@@ -8660,13 +8424,12 @@ static struct hda_verb alc883_medion_md2_verbs[] = { | |||
8660 | }; | 8424 | }; |
8661 | 8425 | ||
8662 | /* toggle speaker-output according to the hp-jack state */ | 8426 | /* toggle speaker-output according to the hp-jack state */ |
8663 | static void alc883_medion_md2_init_hook(struct hda_codec *codec) | 8427 | static void alc883_medion_md2_setup(struct hda_codec *codec) |
8664 | { | 8428 | { |
8665 | struct alc_spec *spec = codec->spec; | 8429 | struct alc_spec *spec = codec->spec; |
8666 | 8430 | ||
8667 | spec->autocfg.hp_pins[0] = 0x14; | 8431 | spec->autocfg.hp_pins[0] = 0x14; |
8668 | spec->autocfg.speaker_pins[0] = 0x15; | 8432 | spec->autocfg.speaker_pins[0] = 0x15; |
8669 | alc_automute_amp(codec); | ||
8670 | } | 8433 | } |
8671 | 8434 | ||
8672 | /* toggle speaker-output according to the hp-jack state */ | 8435 | /* toggle speaker-output according to the hp-jack state */ |
@@ -8683,12 +8446,16 @@ static void alc883_clevo_m720_mic_automute(struct hda_codec *codec) | |||
8683 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | 8446 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); |
8684 | } | 8447 | } |
8685 | 8448 | ||
8686 | static void alc883_clevo_m720_init_hook(struct hda_codec *codec) | 8449 | static void alc883_clevo_m720_setup(struct hda_codec *codec) |
8687 | { | 8450 | { |
8688 | struct alc_spec *spec = codec->spec; | 8451 | struct alc_spec *spec = codec->spec; |
8689 | 8452 | ||
8690 | spec->autocfg.hp_pins[0] = 0x15; | 8453 | spec->autocfg.hp_pins[0] = 0x15; |
8691 | spec->autocfg.speaker_pins[0] = 0x14; | 8454 | spec->autocfg.speaker_pins[0] = 0x14; |
8455 | } | ||
8456 | |||
8457 | static void alc883_clevo_m720_init_hook(struct hda_codec *codec) | ||
8458 | { | ||
8692 | alc_automute_amp(codec); | 8459 | alc_automute_amp(codec); |
8693 | alc883_clevo_m720_mic_automute(codec); | 8460 | alc883_clevo_m720_mic_automute(codec); |
8694 | } | 8461 | } |
@@ -8707,22 +8474,20 @@ static void alc883_clevo_m720_unsol_event(struct hda_codec *codec, | |||
8707 | } | 8474 | } |
8708 | 8475 | ||
8709 | /* toggle speaker-output according to the hp-jack state */ | 8476 | /* toggle speaker-output according to the hp-jack state */ |
8710 | static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec) | 8477 | static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec) |
8711 | { | 8478 | { |
8712 | struct alc_spec *spec = codec->spec; | 8479 | struct alc_spec *spec = codec->spec; |
8713 | 8480 | ||
8714 | spec->autocfg.hp_pins[0] = 0x14; | 8481 | spec->autocfg.hp_pins[0] = 0x14; |
8715 | spec->autocfg.speaker_pins[0] = 0x15; | 8482 | spec->autocfg.speaker_pins[0] = 0x15; |
8716 | alc_automute_amp(codec); | ||
8717 | } | 8483 | } |
8718 | 8484 | ||
8719 | static void alc883_haier_w66_init_hook(struct hda_codec *codec) | 8485 | static void alc883_haier_w66_setup(struct hda_codec *codec) |
8720 | { | 8486 | { |
8721 | struct alc_spec *spec = codec->spec; | 8487 | struct alc_spec *spec = codec->spec; |
8722 | 8488 | ||
8723 | spec->autocfg.hp_pins[0] = 0x1b; | 8489 | spec->autocfg.hp_pins[0] = 0x1b; |
8724 | spec->autocfg.speaker_pins[0] = 0x14; | 8490 | spec->autocfg.speaker_pins[0] = 0x14; |
8725 | alc_automute_amp(codec); | ||
8726 | } | 8491 | } |
8727 | 8492 | ||
8728 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) | 8493 | static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec) |
@@ -8761,14 +8526,13 @@ static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec, | |||
8761 | } | 8526 | } |
8762 | 8527 | ||
8763 | /* toggle speaker-output according to the hp-jack state */ | 8528 | /* toggle speaker-output according to the hp-jack state */ |
8764 | static void alc883_acer_aspire_init_hook(struct hda_codec *codec) | 8529 | static void alc883_acer_aspire_setup(struct hda_codec *codec) |
8765 | { | 8530 | { |
8766 | struct alc_spec *spec = codec->spec; | 8531 | struct alc_spec *spec = codec->spec; |
8767 | 8532 | ||
8768 | spec->autocfg.hp_pins[0] = 0x14; | 8533 | spec->autocfg.hp_pins[0] = 0x14; |
8769 | spec->autocfg.speaker_pins[0] = 0x15; | 8534 | spec->autocfg.speaker_pins[0] = 0x15; |
8770 | spec->autocfg.speaker_pins[1] = 0x16; | 8535 | spec->autocfg.speaker_pins[1] = 0x16; |
8771 | alc_automute_amp(codec); | ||
8772 | } | 8536 | } |
8773 | 8537 | ||
8774 | static struct hda_verb alc883_acer_eapd_verbs[] = { | 8538 | static struct hda_verb alc883_acer_eapd_verbs[] = { |
@@ -8789,7 +8553,14 @@ static struct hda_verb alc883_acer_eapd_verbs[] = { | |||
8789 | { } | 8553 | { } |
8790 | }; | 8554 | }; |
8791 | 8555 | ||
8792 | static void alc888_6st_dell_init_hook(struct hda_codec *codec) | 8556 | static struct hda_verb alc888_acer_aspire_7730G_verbs[] = { |
8557 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8558 | {0x17, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
8559 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | ||
8560 | { } /* end */ | ||
8561 | }; | ||
8562 | |||
8563 | static void alc888_6st_dell_setup(struct hda_codec *codec) | ||
8793 | { | 8564 | { |
8794 | struct alc_spec *spec = codec->spec; | 8565 | struct alc_spec *spec = codec->spec; |
8795 | 8566 | ||
@@ -8798,10 +8569,9 @@ static void alc888_6st_dell_init_hook(struct hda_codec *codec) | |||
8798 | spec->autocfg.speaker_pins[1] = 0x15; | 8569 | spec->autocfg.speaker_pins[1] = 0x15; |
8799 | spec->autocfg.speaker_pins[2] = 0x16; | 8570 | spec->autocfg.speaker_pins[2] = 0x16; |
8800 | spec->autocfg.speaker_pins[3] = 0x17; | 8571 | spec->autocfg.speaker_pins[3] = 0x17; |
8801 | alc_automute_amp(codec); | ||
8802 | } | 8572 | } |
8803 | 8573 | ||
8804 | static void alc888_lenovo_sky_init_hook(struct hda_codec *codec) | 8574 | static void alc888_lenovo_sky_setup(struct hda_codec *codec) |
8805 | { | 8575 | { |
8806 | struct alc_spec *spec = codec->spec; | 8576 | struct alc_spec *spec = codec->spec; |
8807 | 8577 | ||
@@ -8811,82 +8581,17 @@ static void alc888_lenovo_sky_init_hook(struct hda_codec *codec) | |||
8811 | spec->autocfg.speaker_pins[2] = 0x16; | 8581 | spec->autocfg.speaker_pins[2] = 0x16; |
8812 | spec->autocfg.speaker_pins[3] = 0x17; | 8582 | spec->autocfg.speaker_pins[3] = 0x17; |
8813 | spec->autocfg.speaker_pins[4] = 0x1a; | 8583 | spec->autocfg.speaker_pins[4] = 0x1a; |
8814 | alc_automute_amp(codec); | ||
8815 | } | 8584 | } |
8816 | 8585 | ||
8817 | static void alc883_vaiott_init_hook(struct hda_codec *codec) | 8586 | static void alc883_vaiott_setup(struct hda_codec *codec) |
8818 | { | 8587 | { |
8819 | struct alc_spec *spec = codec->spec; | 8588 | struct alc_spec *spec = codec->spec; |
8820 | 8589 | ||
8821 | spec->autocfg.hp_pins[0] = 0x15; | 8590 | spec->autocfg.hp_pins[0] = 0x15; |
8822 | spec->autocfg.speaker_pins[0] = 0x14; | 8591 | spec->autocfg.speaker_pins[0] = 0x14; |
8823 | spec->autocfg.speaker_pins[1] = 0x17; | 8592 | spec->autocfg.speaker_pins[1] = 0x17; |
8824 | alc_automute_amp(codec); | ||
8825 | } | 8593 | } |
8826 | 8594 | ||
8827 | /* | ||
8828 | * generic initialization of ADC, input mixers and output mixers | ||
8829 | */ | ||
8830 | static struct hda_verb alc883_auto_init_verbs[] = { | ||
8831 | /* | ||
8832 | * Unmute ADC0-2 and set the default input to mic-in | ||
8833 | */ | ||
8834 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8835 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8836 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
8837 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8838 | |||
8839 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | ||
8840 | * mixer widget | ||
8841 | * Note: PASD motherboards uses the Line In 2 as the input for | ||
8842 | * front panel mic (mic 2) | ||
8843 | */ | ||
8844 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | ||
8845 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
8846 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
8847 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
8848 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
8849 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
8850 | |||
8851 | /* | ||
8852 | * Set up output mixers (0x0c - 0x0f) | ||
8853 | */ | ||
8854 | /* set vol=0 to output mixers */ | ||
8855 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8856 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8857 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8858 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
8859 | /* set up input amps for analog loopback */ | ||
8860 | /* Amp Indices: DAC = 0, mixer = 1 */ | ||
8861 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8862 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8863 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8864 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8865 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8866 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8867 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8868 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8869 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8870 | {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8871 | |||
8872 | /* FIXME: use matrix-type input source selection */ | ||
8873 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | ||
8874 | /* Input mixer1 */ | ||
8875 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8876 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8877 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | ||
8878 | /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ | ||
8879 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | ||
8880 | /* Input mixer2 */ | ||
8881 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
8882 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
8883 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | ||
8884 | /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */ | ||
8885 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, | ||
8886 | |||
8887 | { } | ||
8888 | }; | ||
8889 | |||
8890 | static struct hda_verb alc888_asus_m90v_verbs[] = { | 8595 | static struct hda_verb alc888_asus_m90v_verbs[] = { |
8891 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 8596 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
8892 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 8597 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
@@ -8897,19 +8602,7 @@ static struct hda_verb alc888_asus_m90v_verbs[] = { | |||
8897 | { } /* end */ | 8602 | { } /* end */ |
8898 | }; | 8603 | }; |
8899 | 8604 | ||
8900 | static void alc883_nb_mic_automute(struct hda_codec *codec) | 8605 | static void alc883_mode2_setup(struct hda_codec *codec) |
8901 | { | ||
8902 | unsigned int present; | ||
8903 | |||
8904 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
8905 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
8906 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
8907 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
8908 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
8909 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | ||
8910 | } | ||
8911 | |||
8912 | static void alc883_M90V_init_hook(struct hda_codec *codec) | ||
8913 | { | 8606 | { |
8914 | struct alc_spec *spec = codec->spec; | 8607 | struct alc_spec *spec = codec->spec; |
8915 | 8608 | ||
@@ -8917,26 +8610,11 @@ static void alc883_M90V_init_hook(struct hda_codec *codec) | |||
8917 | spec->autocfg.speaker_pins[0] = 0x14; | 8610 | spec->autocfg.speaker_pins[0] = 0x14; |
8918 | spec->autocfg.speaker_pins[1] = 0x15; | 8611 | spec->autocfg.speaker_pins[1] = 0x15; |
8919 | spec->autocfg.speaker_pins[2] = 0x16; | 8612 | spec->autocfg.speaker_pins[2] = 0x16; |
8920 | alc_automute_pin(codec); | 8613 | spec->ext_mic.pin = 0x18; |
8921 | } | 8614 | spec->int_mic.pin = 0x19; |
8922 | 8615 | spec->ext_mic.mux_idx = 0; | |
8923 | static void alc883_mode2_unsol_event(struct hda_codec *codec, | 8616 | spec->int_mic.mux_idx = 1; |
8924 | unsigned int res) | 8617 | spec->auto_mic = 1; |
8925 | { | ||
8926 | switch (res >> 26) { | ||
8927 | case ALC880_MIC_EVENT: | ||
8928 | alc883_nb_mic_automute(codec); | ||
8929 | break; | ||
8930 | default: | ||
8931 | alc_sku_unsol_event(codec, res); | ||
8932 | break; | ||
8933 | } | ||
8934 | } | ||
8935 | |||
8936 | static void alc883_mode2_inithook(struct hda_codec *codec) | ||
8937 | { | ||
8938 | alc883_M90V_init_hook(codec); | ||
8939 | alc883_nb_mic_automute(codec); | ||
8940 | } | 8618 | } |
8941 | 8619 | ||
8942 | static struct hda_verb alc888_asus_eee1601_verbs[] = { | 8620 | static struct hda_verb alc888_asus_eee1601_verbs[] = { |
@@ -8997,25 +8675,44 @@ static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res) | |||
8997 | alc889A_mb31_automute(codec); | 8675 | alc889A_mb31_automute(codec); |
8998 | } | 8676 | } |
8999 | 8677 | ||
8678 | |||
9000 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 8679 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9001 | #define alc883_loopbacks alc880_loopbacks | 8680 | #define alc882_loopbacks alc880_loopbacks |
9002 | #endif | 8681 | #endif |
9003 | 8682 | ||
9004 | /* pcm configuration: identical with ALC880 */ | 8683 | /* pcm configuration: identical with ALC880 */ |
9005 | #define alc883_pcm_analog_playback alc880_pcm_analog_playback | 8684 | #define alc882_pcm_analog_playback alc880_pcm_analog_playback |
9006 | #define alc883_pcm_analog_capture alc880_pcm_analog_capture | 8685 | #define alc882_pcm_analog_capture alc880_pcm_analog_capture |
9007 | #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture | 8686 | #define alc882_pcm_digital_playback alc880_pcm_digital_playback |
9008 | #define alc883_pcm_digital_playback alc880_pcm_digital_playback | 8687 | #define alc882_pcm_digital_capture alc880_pcm_digital_capture |
9009 | #define alc883_pcm_digital_capture alc880_pcm_digital_capture | 8688 | |
8689 | static hda_nid_t alc883_slave_dig_outs[] = { | ||
8690 | ALC1200_DIGOUT_NID, 0, | ||
8691 | }; | ||
8692 | |||
8693 | static hda_nid_t alc1200_slave_dig_outs[] = { | ||
8694 | ALC883_DIGOUT_NID, 0, | ||
8695 | }; | ||
9010 | 8696 | ||
9011 | /* | 8697 | /* |
9012 | * configuration and preset | 8698 | * configuration and preset |
9013 | */ | 8699 | */ |
9014 | static const char *alc883_models[ALC883_MODEL_LAST] = { | 8700 | static const char *alc882_models[ALC882_MODEL_LAST] = { |
9015 | [ALC883_3ST_2ch_DIG] = "3stack-dig", | 8701 | [ALC882_3ST_DIG] = "3stack-dig", |
8702 | [ALC882_6ST_DIG] = "6stack-dig", | ||
8703 | [ALC882_ARIMA] = "arima", | ||
8704 | [ALC882_W2JC] = "w2jc", | ||
8705 | [ALC882_TARGA] = "targa", | ||
8706 | [ALC882_ASUS_A7J] = "asus-a7j", | ||
8707 | [ALC882_ASUS_A7M] = "asus-a7m", | ||
8708 | [ALC885_MACPRO] = "macpro", | ||
8709 | [ALC885_MB5] = "mb5", | ||
8710 | [ALC885_MBP3] = "mbp3", | ||
8711 | [ALC885_IMAC24] = "imac24", | ||
8712 | [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig", | ||
9016 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", | 8713 | [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig", |
9017 | [ALC883_3ST_6ch] = "3stack-6ch", | 8714 | [ALC883_3ST_6ch] = "3stack-6ch", |
9018 | [ALC883_6ST_DIG] = "6stack-dig", | 8715 | [ALC883_6ST_DIG] = "alc883-6stack-dig", |
9019 | [ALC883_TARGA_DIG] = "targa-dig", | 8716 | [ALC883_TARGA_DIG] = "targa-dig", |
9020 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", | 8717 | [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig", |
9021 | [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig", | 8718 | [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig", |
@@ -9024,6 +8721,7 @@ static const char *alc883_models[ALC883_MODEL_LAST] = { | |||
9024 | [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", | 8721 | [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g", |
9025 | [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g", | 8722 | [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g", |
9026 | [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g", | 8723 | [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g", |
8724 | [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g", | ||
9027 | [ALC883_MEDION] = "medion", | 8725 | [ALC883_MEDION] = "medion", |
9028 | [ALC883_MEDION_MD2] = "medion-md2", | 8726 | [ALC883_MEDION_MD2] = "medion-md2", |
9029 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", | 8727 | [ALC883_LAPTOP_EAPD] = "laptop-eapd", |
@@ -9035,18 +8733,22 @@ static const char *alc883_models[ALC883_MODEL_LAST] = { | |||
9035 | [ALC888_3ST_HP] = "3stack-hp", | 8733 | [ALC888_3ST_HP] = "3stack-hp", |
9036 | [ALC888_6ST_DELL] = "6stack-dell", | 8734 | [ALC888_6ST_DELL] = "6stack-dell", |
9037 | [ALC883_MITAC] = "mitac", | 8735 | [ALC883_MITAC] = "mitac", |
8736 | [ALC883_CLEVO_M540R] = "clevo-m540r", | ||
9038 | [ALC883_CLEVO_M720] = "clevo-m720", | 8737 | [ALC883_CLEVO_M720] = "clevo-m720", |
9039 | [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", | 8738 | [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515", |
9040 | [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", | 8739 | [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530", |
9041 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", | 8740 | [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel", |
8741 | [ALC889A_INTEL] = "intel-alc889a", | ||
8742 | [ALC889_INTEL] = "intel-x58", | ||
9042 | [ALC1200_ASUS_P5Q] = "asus-p5q", | 8743 | [ALC1200_ASUS_P5Q] = "asus-p5q", |
9043 | [ALC889A_MB31] = "mb31", | 8744 | [ALC889A_MB31] = "mb31", |
9044 | [ALC883_SONY_VAIO_TT] = "sony-vaio-tt", | 8745 | [ALC883_SONY_VAIO_TT] = "sony-vaio-tt", |
9045 | [ALC883_AUTO] = "auto", | 8746 | [ALC882_AUTO] = "auto", |
9046 | }; | 8747 | }; |
9047 | 8748 | ||
9048 | static struct snd_pci_quirk alc883_cfg_tbl[] = { | 8749 | static struct snd_pci_quirk alc882_cfg_tbl[] = { |
9049 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG), | 8750 | SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG), |
8751 | |||
9050 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), | 8752 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE), |
9051 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), | 8753 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE), |
9052 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE), | 8754 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE), |
@@ -9061,40 +8763,56 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
9061 | ALC888_ACER_ASPIRE_8930G), | 8763 | ALC888_ACER_ASPIRE_8930G), |
9062 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", | 8764 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
9063 | ALC888_ACER_ASPIRE_8930G), | 8765 | ALC888_ACER_ASPIRE_8930G), |
9064 | SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO), | 8766 | SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO), |
9065 | SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO), | 8767 | SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO), |
9066 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", | 8768 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
9067 | ALC888_ACER_ASPIRE_4930G), | 8769 | ALC888_ACER_ASPIRE_6530G), |
9068 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", | 8770 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
9069 | ALC888_ACER_ASPIRE_6530G), | 8771 | ALC888_ACER_ASPIRE_6530G), |
8772 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", | ||
8773 | ALC888_ACER_ASPIRE_7730G), | ||
9070 | /* default Acer -- disabled as it causes more problems. | 8774 | /* default Acer -- disabled as it causes more problems. |
9071 | * model=auto should work fine now | 8775 | * model=auto should work fine now |
9072 | */ | 8776 | */ |
9073 | /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */ | 8777 | /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */ |
8778 | |||
9074 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), | 8779 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
8780 | |||
9075 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), | 8781 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
9076 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), | 8782 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
9077 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | 8783 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), |
9078 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), | 8784 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), |
9079 | SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), | 8785 | SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), |
9080 | SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP), | 8786 | SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP), |
8787 | |||
8788 | SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J), | ||
8789 | SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J), | ||
8790 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M), | ||
9081 | SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), | 8791 | SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), |
8792 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC), | ||
8793 | SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG), | ||
8794 | SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), | ||
9082 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), | 8795 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), |
9083 | SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG), | 8796 | SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG), |
9084 | SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), | 8797 | SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), |
9085 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), | 8798 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601), |
8799 | |||
8800 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT), | ||
9086 | SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), | 8801 | SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG), |
9087 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), | 8802 | SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG), |
9088 | SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC), | 8803 | SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC), |
9089 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), | 8804 | SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC), |
9090 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), | 8805 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), |
9091 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), | 8806 | SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL), |
9092 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), | 8807 | SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), |
9093 | SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG), | 8808 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG), |
8809 | |||
9094 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), | 8810 | SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG), |
9095 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), | 8811 | SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG), |
9096 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), | 8812 | SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG), |
8813 | SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */ | ||
9097 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), | 8814 | SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG), |
8815 | SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), | ||
9098 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), | 8816 | SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG), |
9099 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), | 8817 | SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG), |
9100 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), | 8818 | SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG), |
@@ -9103,6 +8821,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
9103 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), | 8821 | SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG), |
9104 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), | 8822 | SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG), |
9105 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), | 8823 | SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG), |
8824 | SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG), | ||
9106 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), | 8825 | SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG), |
9107 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), | 8826 | SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG), |
9108 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), | 8827 | SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG), |
@@ -9116,11 +8835,15 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
9116 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), | 8835 | SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG), |
9117 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG), | 8836 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG), |
9118 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), | 8837 | SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG), |
8838 | SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG), | ||
8839 | |||
9119 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), | 8840 | SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), |
9120 | SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), | 8841 | SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), |
9121 | SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), | 8842 | SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), |
8843 | SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R), | ||
9122 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), | 8844 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), |
9123 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), | 8845 | SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), |
8846 | /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */ | ||
9124 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), | 8847 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), |
9125 | SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx", | 8848 | SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx", |
9126 | ALC883_FUJITSU_PI2515), | 8849 | ALC883_FUJITSU_PI2515), |
@@ -9135,24 +8858,186 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
9135 | SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), | 8858 | SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG), |
9136 | SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), | 8859 | SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG), |
9137 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), | 8860 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
8861 | |||
9138 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), | 8862 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), |
9139 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), | 8863 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), |
9140 | SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), | 8864 | SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC), |
9141 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), | 8865 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL), |
8866 | SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL), | ||
8867 | SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL), | ||
9142 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), | 8868 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
9143 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT), | ||
9144 | {} | ||
9145 | }; | ||
9146 | 8869 | ||
9147 | static hda_nid_t alc883_slave_dig_outs[] = { | 8870 | {} |
9148 | ALC1200_DIGOUT_NID, 0, | ||
9149 | }; | 8871 | }; |
9150 | 8872 | ||
9151 | static hda_nid_t alc1200_slave_dig_outs[] = { | 8873 | /* codec SSID table for Intel Mac */ |
9152 | ALC883_DIGOUT_NID, 0, | 8874 | static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = { |
8875 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3), | ||
8876 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3), | ||
8877 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3), | ||
8878 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO), | ||
8879 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24), | ||
8880 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24), | ||
8881 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3), | ||
8882 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), | ||
8883 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3), | ||
8884 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24), | ||
8885 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5), | ||
8886 | /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently | ||
8887 | * no perfect solution yet | ||
8888 | */ | ||
8889 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5), | ||
8890 | {} /* terminator */ | ||
9153 | }; | 8891 | }; |
9154 | 8892 | ||
9155 | static struct alc_config_preset alc883_presets[] = { | 8893 | static struct alc_config_preset alc882_presets[] = { |
8894 | [ALC882_3ST_DIG] = { | ||
8895 | .mixers = { alc882_base_mixer }, | ||
8896 | .init_verbs = { alc882_base_init_verbs, | ||
8897 | alc882_adc1_init_verbs }, | ||
8898 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8899 | .dac_nids = alc882_dac_nids, | ||
8900 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8901 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8902 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
8903 | .channel_mode = alc882_ch_modes, | ||
8904 | .need_dac_fix = 1, | ||
8905 | .input_mux = &alc882_capture_source, | ||
8906 | }, | ||
8907 | [ALC882_6ST_DIG] = { | ||
8908 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | ||
8909 | .init_verbs = { alc882_base_init_verbs, | ||
8910 | alc882_adc1_init_verbs }, | ||
8911 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8912 | .dac_nids = alc882_dac_nids, | ||
8913 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8914 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8915 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | ||
8916 | .channel_mode = alc882_sixstack_modes, | ||
8917 | .input_mux = &alc882_capture_source, | ||
8918 | }, | ||
8919 | [ALC882_ARIMA] = { | ||
8920 | .mixers = { alc882_base_mixer, alc882_chmode_mixer }, | ||
8921 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | ||
8922 | alc882_eapd_verbs }, | ||
8923 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8924 | .dac_nids = alc882_dac_nids, | ||
8925 | .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), | ||
8926 | .channel_mode = alc882_sixstack_modes, | ||
8927 | .input_mux = &alc882_capture_source, | ||
8928 | }, | ||
8929 | [ALC882_W2JC] = { | ||
8930 | .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer }, | ||
8931 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | ||
8932 | alc882_eapd_verbs, alc880_gpio1_init_verbs }, | ||
8933 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8934 | .dac_nids = alc882_dac_nids, | ||
8935 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | ||
8936 | .channel_mode = alc880_threestack_modes, | ||
8937 | .need_dac_fix = 1, | ||
8938 | .input_mux = &alc882_capture_source, | ||
8939 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8940 | }, | ||
8941 | [ALC885_MBP3] = { | ||
8942 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | ||
8943 | .init_verbs = { alc885_mbp3_init_verbs, | ||
8944 | alc880_gpio1_init_verbs }, | ||
8945 | .num_dacs = 2, | ||
8946 | .dac_nids = alc882_dac_nids, | ||
8947 | .hp_nid = 0x04, | ||
8948 | .channel_mode = alc885_mbp_4ch_modes, | ||
8949 | .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes), | ||
8950 | .input_mux = &alc882_capture_source, | ||
8951 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8952 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8953 | .unsol_event = alc_automute_amp_unsol_event, | ||
8954 | .setup = alc885_mbp3_setup, | ||
8955 | .init_hook = alc_automute_amp, | ||
8956 | }, | ||
8957 | [ALC885_MB5] = { | ||
8958 | .mixers = { alc885_mb5_mixer, alc882_chmode_mixer }, | ||
8959 | .init_verbs = { alc885_mb5_init_verbs, | ||
8960 | alc880_gpio1_init_verbs }, | ||
8961 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8962 | .dac_nids = alc882_dac_nids, | ||
8963 | .channel_mode = alc885_mb5_6ch_modes, | ||
8964 | .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes), | ||
8965 | .input_mux = &mb5_capture_source, | ||
8966 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8967 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8968 | }, | ||
8969 | [ALC885_MACPRO] = { | ||
8970 | .mixers = { alc882_macpro_mixer }, | ||
8971 | .init_verbs = { alc882_macpro_init_verbs }, | ||
8972 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8973 | .dac_nids = alc882_dac_nids, | ||
8974 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8975 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8976 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
8977 | .channel_mode = alc882_ch_modes, | ||
8978 | .input_mux = &alc882_capture_source, | ||
8979 | .init_hook = alc885_macpro_init_hook, | ||
8980 | }, | ||
8981 | [ALC885_IMAC24] = { | ||
8982 | .mixers = { alc885_imac24_mixer }, | ||
8983 | .init_verbs = { alc885_imac24_init_verbs }, | ||
8984 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
8985 | .dac_nids = alc882_dac_nids, | ||
8986 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
8987 | .dig_in_nid = ALC882_DIGIN_NID, | ||
8988 | .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), | ||
8989 | .channel_mode = alc882_ch_modes, | ||
8990 | .input_mux = &alc882_capture_source, | ||
8991 | .unsol_event = alc_automute_amp_unsol_event, | ||
8992 | .setup = alc885_imac24_setup, | ||
8993 | .init_hook = alc885_imac24_init_hook, | ||
8994 | }, | ||
8995 | [ALC882_TARGA] = { | ||
8996 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, | ||
8997 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | ||
8998 | alc880_gpio3_init_verbs, alc882_targa_verbs}, | ||
8999 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
9000 | .dac_nids = alc882_dac_nids, | ||
9001 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
9002 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | ||
9003 | .adc_nids = alc882_adc_nids, | ||
9004 | .capsrc_nids = alc882_capsrc_nids, | ||
9005 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | ||
9006 | .channel_mode = alc882_3ST_6ch_modes, | ||
9007 | .need_dac_fix = 1, | ||
9008 | .input_mux = &alc882_capture_source, | ||
9009 | .unsol_event = alc882_targa_unsol_event, | ||
9010 | .setup = alc882_targa_setup, | ||
9011 | .init_hook = alc882_targa_automute, | ||
9012 | }, | ||
9013 | [ALC882_ASUS_A7J] = { | ||
9014 | .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer }, | ||
9015 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | ||
9016 | alc882_asus_a7j_verbs}, | ||
9017 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
9018 | .dac_nids = alc882_dac_nids, | ||
9019 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
9020 | .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), | ||
9021 | .adc_nids = alc882_adc_nids, | ||
9022 | .capsrc_nids = alc882_capsrc_nids, | ||
9023 | .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes), | ||
9024 | .channel_mode = alc882_3ST_6ch_modes, | ||
9025 | .need_dac_fix = 1, | ||
9026 | .input_mux = &alc882_capture_source, | ||
9027 | }, | ||
9028 | [ALC882_ASUS_A7M] = { | ||
9029 | .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer }, | ||
9030 | .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs, | ||
9031 | alc882_eapd_verbs, alc880_gpio1_init_verbs, | ||
9032 | alc882_asus_a7m_verbs }, | ||
9033 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
9034 | .dac_nids = alc882_dac_nids, | ||
9035 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
9036 | .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), | ||
9037 | .channel_mode = alc880_threestack_modes, | ||
9038 | .need_dac_fix = 1, | ||
9039 | .input_mux = &alc882_capture_source, | ||
9040 | }, | ||
9156 | [ALC883_3ST_2ch_DIG] = { | 9041 | [ALC883_3ST_2ch_DIG] = { |
9157 | .mixers = { alc883_3ST_2ch_mixer }, | 9042 | .mixers = { alc883_3ST_2ch_mixer }, |
9158 | .init_verbs = { alc883_init_verbs }, | 9043 | .init_verbs = { alc883_init_verbs }, |
@@ -9199,6 +9084,46 @@ static struct alc_config_preset alc883_presets[] = { | |||
9199 | .need_dac_fix = 1, | 9084 | .need_dac_fix = 1, |
9200 | .input_mux = &alc883_3stack_6ch_intel, | 9085 | .input_mux = &alc883_3stack_6ch_intel, |
9201 | }, | 9086 | }, |
9087 | [ALC889A_INTEL] = { | ||
9088 | .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer }, | ||
9089 | .init_verbs = { alc885_init_verbs, alc885_init_input_verbs, | ||
9090 | alc_hp15_unsol_verbs }, | ||
9091 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9092 | .dac_nids = alc883_dac_nids, | ||
9093 | .num_adc_nids = ARRAY_SIZE(alc889_adc_nids), | ||
9094 | .adc_nids = alc889_adc_nids, | ||
9095 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9096 | .dig_in_nid = ALC883_DIGIN_NID, | ||
9097 | .slave_dig_outs = alc883_slave_dig_outs, | ||
9098 | .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes), | ||
9099 | .channel_mode = alc889_8ch_intel_modes, | ||
9100 | .capsrc_nids = alc889_capsrc_nids, | ||
9101 | .input_mux = &alc889_capture_source, | ||
9102 | .setup = alc889_automute_setup, | ||
9103 | .init_hook = alc_automute_amp, | ||
9104 | .unsol_event = alc_automute_amp_unsol_event, | ||
9105 | .need_dac_fix = 1, | ||
9106 | }, | ||
9107 | [ALC889_INTEL] = { | ||
9108 | .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer }, | ||
9109 | .init_verbs = { alc885_init_verbs, alc889_init_input_verbs, | ||
9110 | alc889_eapd_verbs, alc_hp15_unsol_verbs}, | ||
9111 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9112 | .dac_nids = alc883_dac_nids, | ||
9113 | .num_adc_nids = ARRAY_SIZE(alc889_adc_nids), | ||
9114 | .adc_nids = alc889_adc_nids, | ||
9115 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9116 | .dig_in_nid = ALC883_DIGIN_NID, | ||
9117 | .slave_dig_outs = alc883_slave_dig_outs, | ||
9118 | .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes), | ||
9119 | .channel_mode = alc889_8ch_intel_modes, | ||
9120 | .capsrc_nids = alc889_capsrc_nids, | ||
9121 | .input_mux = &alc889_capture_source, | ||
9122 | .setup = alc889_automute_setup, | ||
9123 | .init_hook = alc889_intel_init_hook, | ||
9124 | .unsol_event = alc_automute_amp_unsol_event, | ||
9125 | .need_dac_fix = 1, | ||
9126 | }, | ||
9202 | [ALC883_6ST_DIG] = { | 9127 | [ALC883_6ST_DIG] = { |
9203 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | 9128 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
9204 | .init_verbs = { alc883_init_verbs }, | 9129 | .init_verbs = { alc883_init_verbs }, |
@@ -9212,7 +9137,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9212 | }, | 9137 | }, |
9213 | [ALC883_TARGA_DIG] = { | 9138 | [ALC883_TARGA_DIG] = { |
9214 | .mixers = { alc883_targa_mixer, alc883_chmode_mixer }, | 9139 | .mixers = { alc883_targa_mixer, alc883_chmode_mixer }, |
9215 | .init_verbs = { alc883_init_verbs, alc883_targa_verbs}, | 9140 | .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs, |
9141 | alc883_targa_verbs}, | ||
9216 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | 9142 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
9217 | .dac_nids = alc883_dac_nids, | 9143 | .dac_nids = alc883_dac_nids, |
9218 | .dig_out_nid = ALC883_DIGOUT_NID, | 9144 | .dig_out_nid = ALC883_DIGOUT_NID, |
@@ -9221,11 +9147,13 @@ static struct alc_config_preset alc883_presets[] = { | |||
9221 | .need_dac_fix = 1, | 9147 | .need_dac_fix = 1, |
9222 | .input_mux = &alc883_capture_source, | 9148 | .input_mux = &alc883_capture_source, |
9223 | .unsol_event = alc883_targa_unsol_event, | 9149 | .unsol_event = alc883_targa_unsol_event, |
9224 | .init_hook = alc883_targa_init_hook, | 9150 | .setup = alc882_targa_setup, |
9151 | .init_hook = alc882_targa_automute, | ||
9225 | }, | 9152 | }, |
9226 | [ALC883_TARGA_2ch_DIG] = { | 9153 | [ALC883_TARGA_2ch_DIG] = { |
9227 | .mixers = { alc883_targa_2ch_mixer}, | 9154 | .mixers = { alc883_targa_2ch_mixer}, |
9228 | .init_verbs = { alc883_init_verbs, alc883_targa_verbs}, | 9155 | .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs, |
9156 | alc883_targa_verbs}, | ||
9229 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | 9157 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), |
9230 | .dac_nids = alc883_dac_nids, | 9158 | .dac_nids = alc883_dac_nids, |
9231 | .adc_nids = alc883_adc_nids_alt, | 9159 | .adc_nids = alc883_adc_nids_alt, |
@@ -9235,7 +9163,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9235 | .channel_mode = alc883_3ST_2ch_modes, | 9163 | .channel_mode = alc883_3ST_2ch_modes, |
9236 | .input_mux = &alc883_capture_source, | 9164 | .input_mux = &alc883_capture_source, |
9237 | .unsol_event = alc883_targa_unsol_event, | 9165 | .unsol_event = alc883_targa_unsol_event, |
9238 | .init_hook = alc883_targa_init_hook, | 9166 | .setup = alc882_targa_setup, |
9167 | .init_hook = alc882_targa_automute, | ||
9239 | }, | 9168 | }, |
9240 | [ALC883_TARGA_8ch_DIG] = { | 9169 | [ALC883_TARGA_8ch_DIG] = { |
9241 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | 9170 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
@@ -9253,7 +9182,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9253 | .need_dac_fix = 1, | 9182 | .need_dac_fix = 1, |
9254 | .input_mux = &alc883_capture_source, | 9183 | .input_mux = &alc883_capture_source, |
9255 | .unsol_event = alc883_targa_unsol_event, | 9184 | .unsol_event = alc883_targa_unsol_event, |
9256 | .init_hook = alc883_targa_init_hook, | 9185 | .setup = alc882_targa_setup, |
9186 | .init_hook = alc882_targa_automute, | ||
9257 | }, | 9187 | }, |
9258 | [ALC883_ACER] = { | 9188 | [ALC883_ACER] = { |
9259 | .mixers = { alc883_base_mixer }, | 9189 | .mixers = { alc883_base_mixer }, |
@@ -9279,7 +9209,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9279 | .channel_mode = alc883_3ST_2ch_modes, | 9209 | .channel_mode = alc883_3ST_2ch_modes, |
9280 | .input_mux = &alc883_capture_source, | 9210 | .input_mux = &alc883_capture_source, |
9281 | .unsol_event = alc_automute_amp_unsol_event, | 9211 | .unsol_event = alc_automute_amp_unsol_event, |
9282 | .init_hook = alc883_acer_aspire_init_hook, | 9212 | .setup = alc883_acer_aspire_setup, |
9213 | .init_hook = alc_automute_amp, | ||
9283 | }, | 9214 | }, |
9284 | [ALC888_ACER_ASPIRE_4930G] = { | 9215 | [ALC888_ACER_ASPIRE_4930G] = { |
9285 | .mixers = { alc888_base_mixer, | 9216 | .mixers = { alc888_base_mixer, |
@@ -9299,7 +9230,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9299 | ARRAY_SIZE(alc888_2_capture_sources), | 9230 | ARRAY_SIZE(alc888_2_capture_sources), |
9300 | .input_mux = alc888_2_capture_sources, | 9231 | .input_mux = alc888_2_capture_sources, |
9301 | .unsol_event = alc_automute_amp_unsol_event, | 9232 | .unsol_event = alc_automute_amp_unsol_event, |
9302 | .init_hook = alc888_acer_aspire_4930g_init_hook, | 9233 | .setup = alc888_acer_aspire_4930g_setup, |
9234 | .init_hook = alc_automute_amp, | ||
9303 | }, | 9235 | }, |
9304 | [ALC888_ACER_ASPIRE_6530G] = { | 9236 | [ALC888_ACER_ASPIRE_6530G] = { |
9305 | .mixers = { alc888_acer_aspire_6530_mixer }, | 9237 | .mixers = { alc888_acer_aspire_6530_mixer }, |
@@ -9317,7 +9249,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9317 | ARRAY_SIZE(alc888_2_capture_sources), | 9249 | ARRAY_SIZE(alc888_2_capture_sources), |
9318 | .input_mux = alc888_acer_aspire_6530_sources, | 9250 | .input_mux = alc888_acer_aspire_6530_sources, |
9319 | .unsol_event = alc_automute_amp_unsol_event, | 9251 | .unsol_event = alc_automute_amp_unsol_event, |
9320 | .init_hook = alc888_acer_aspire_4930g_init_hook, | 9252 | .setup = alc888_acer_aspire_6530g_setup, |
9253 | .init_hook = alc_automute_amp, | ||
9321 | }, | 9254 | }, |
9322 | [ALC888_ACER_ASPIRE_8930G] = { | 9255 | [ALC888_ACER_ASPIRE_8930G] = { |
9323 | .mixers = { alc888_base_mixer, | 9256 | .mixers = { alc888_base_mixer, |
@@ -9338,7 +9271,28 @@ static struct alc_config_preset alc883_presets[] = { | |||
9338 | ARRAY_SIZE(alc889_capture_sources), | 9271 | ARRAY_SIZE(alc889_capture_sources), |
9339 | .input_mux = alc889_capture_sources, | 9272 | .input_mux = alc889_capture_sources, |
9340 | .unsol_event = alc_automute_amp_unsol_event, | 9273 | .unsol_event = alc_automute_amp_unsol_event, |
9341 | .init_hook = alc889_acer_aspire_8930g_init_hook, | 9274 | .setup = alc889_acer_aspire_8930g_setup, |
9275 | .init_hook = alc_automute_amp, | ||
9276 | }, | ||
9277 | [ALC888_ACER_ASPIRE_7730G] = { | ||
9278 | .mixers = { alc883_3ST_6ch_mixer, | ||
9279 | alc883_chmode_mixer }, | ||
9280 | .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs, | ||
9281 | alc888_acer_aspire_7730G_verbs }, | ||
9282 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9283 | .dac_nids = alc883_dac_nids, | ||
9284 | .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev), | ||
9285 | .adc_nids = alc883_adc_nids_rev, | ||
9286 | .capsrc_nids = alc883_capsrc_nids_rev, | ||
9287 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9288 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | ||
9289 | .channel_mode = alc883_3ST_6ch_modes, | ||
9290 | .need_dac_fix = 1, | ||
9291 | .const_channel_count = 6, | ||
9292 | .input_mux = &alc883_capture_source, | ||
9293 | .unsol_event = alc_automute_amp_unsol_event, | ||
9294 | .setup = alc888_acer_aspire_6530g_setup, | ||
9295 | .init_hook = alc_automute_amp, | ||
9342 | }, | 9296 | }, |
9343 | [ALC883_MEDION] = { | 9297 | [ALC883_MEDION] = { |
9344 | .mixers = { alc883_fivestack_mixer, | 9298 | .mixers = { alc883_fivestack_mixer, |
@@ -9363,7 +9317,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9363 | .channel_mode = alc883_3ST_2ch_modes, | 9317 | .channel_mode = alc883_3ST_2ch_modes, |
9364 | .input_mux = &alc883_capture_source, | 9318 | .input_mux = &alc883_capture_source, |
9365 | .unsol_event = alc_automute_amp_unsol_event, | 9319 | .unsol_event = alc_automute_amp_unsol_event, |
9366 | .init_hook = alc883_medion_md2_init_hook, | 9320 | .setup = alc883_medion_md2_setup, |
9321 | .init_hook = alc_automute_amp, | ||
9367 | }, | 9322 | }, |
9368 | [ALC883_LAPTOP_EAPD] = { | 9323 | [ALC883_LAPTOP_EAPD] = { |
9369 | .mixers = { alc883_base_mixer }, | 9324 | .mixers = { alc883_base_mixer }, |
@@ -9374,6 +9329,21 @@ static struct alc_config_preset alc883_presets[] = { | |||
9374 | .channel_mode = alc883_3ST_2ch_modes, | 9329 | .channel_mode = alc883_3ST_2ch_modes, |
9375 | .input_mux = &alc883_capture_source, | 9330 | .input_mux = &alc883_capture_source, |
9376 | }, | 9331 | }, |
9332 | [ALC883_CLEVO_M540R] = { | ||
9333 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | ||
9334 | .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs }, | ||
9335 | .num_dacs = ARRAY_SIZE(alc883_dac_nids), | ||
9336 | .dac_nids = alc883_dac_nids, | ||
9337 | .dig_out_nid = ALC883_DIGOUT_NID, | ||
9338 | .dig_in_nid = ALC883_DIGIN_NID, | ||
9339 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes), | ||
9340 | .channel_mode = alc883_3ST_6ch_clevo_modes, | ||
9341 | .need_dac_fix = 1, | ||
9342 | .input_mux = &alc883_capture_source, | ||
9343 | /* This machine has the hardware HP auto-muting, thus | ||
9344 | * we need no software mute via unsol event | ||
9345 | */ | ||
9346 | }, | ||
9377 | [ALC883_CLEVO_M720] = { | 9347 | [ALC883_CLEVO_M720] = { |
9378 | .mixers = { alc883_clevo_m720_mixer }, | 9348 | .mixers = { alc883_clevo_m720_mixer }, |
9379 | .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, | 9349 | .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs }, |
@@ -9384,6 +9354,7 @@ static struct alc_config_preset alc883_presets[] = { | |||
9384 | .channel_mode = alc883_3ST_2ch_modes, | 9354 | .channel_mode = alc883_3ST_2ch_modes, |
9385 | .input_mux = &alc883_capture_source, | 9355 | .input_mux = &alc883_capture_source, |
9386 | .unsol_event = alc883_clevo_m720_unsol_event, | 9356 | .unsol_event = alc883_clevo_m720_unsol_event, |
9357 | .setup = alc883_clevo_m720_setup, | ||
9387 | .init_hook = alc883_clevo_m720_init_hook, | 9358 | .init_hook = alc883_clevo_m720_init_hook, |
9388 | }, | 9359 | }, |
9389 | [ALC883_LENOVO_101E_2ch] = { | 9360 | [ALC883_LENOVO_101E_2ch] = { |
@@ -9409,7 +9380,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9409 | .need_dac_fix = 1, | 9380 | .need_dac_fix = 1, |
9410 | .input_mux = &alc883_lenovo_nb0763_capture_source, | 9381 | .input_mux = &alc883_lenovo_nb0763_capture_source, |
9411 | .unsol_event = alc_automute_amp_unsol_event, | 9382 | .unsol_event = alc_automute_amp_unsol_event, |
9412 | .init_hook = alc883_medion_md2_init_hook, | 9383 | .setup = alc883_medion_md2_setup, |
9384 | .init_hook = alc_automute_amp, | ||
9413 | }, | 9385 | }, |
9414 | [ALC888_LENOVO_MS7195_DIG] = { | 9386 | [ALC888_LENOVO_MS7195_DIG] = { |
9415 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 9387 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9434,7 +9406,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9434 | .channel_mode = alc883_3ST_2ch_modes, | 9406 | .channel_mode = alc883_3ST_2ch_modes, |
9435 | .input_mux = &alc883_capture_source, | 9407 | .input_mux = &alc883_capture_source, |
9436 | .unsol_event = alc_automute_amp_unsol_event, | 9408 | .unsol_event = alc_automute_amp_unsol_event, |
9437 | .init_hook = alc883_haier_w66_init_hook, | 9409 | .setup = alc883_haier_w66_setup, |
9410 | .init_hook = alc_automute_amp, | ||
9438 | }, | 9411 | }, |
9439 | [ALC888_3ST_HP] = { | 9412 | [ALC888_3ST_HP] = { |
9440 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 9413 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9446,7 +9419,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9446 | .need_dac_fix = 1, | 9419 | .need_dac_fix = 1, |
9447 | .input_mux = &alc883_capture_source, | 9420 | .input_mux = &alc883_capture_source, |
9448 | .unsol_event = alc_automute_amp_unsol_event, | 9421 | .unsol_event = alc_automute_amp_unsol_event, |
9449 | .init_hook = alc888_3st_hp_init_hook, | 9422 | .setup = alc888_3st_hp_setup, |
9423 | .init_hook = alc_automute_amp, | ||
9450 | }, | 9424 | }, |
9451 | [ALC888_6ST_DELL] = { | 9425 | [ALC888_6ST_DELL] = { |
9452 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, | 9426 | .mixers = { alc883_base_mixer, alc883_chmode_mixer }, |
@@ -9459,7 +9433,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9459 | .channel_mode = alc883_sixstack_modes, | 9433 | .channel_mode = alc883_sixstack_modes, |
9460 | .input_mux = &alc883_capture_source, | 9434 | .input_mux = &alc883_capture_source, |
9461 | .unsol_event = alc_automute_amp_unsol_event, | 9435 | .unsol_event = alc_automute_amp_unsol_event, |
9462 | .init_hook = alc888_6st_dell_init_hook, | 9436 | .setup = alc888_6st_dell_setup, |
9437 | .init_hook = alc_automute_amp, | ||
9463 | }, | 9438 | }, |
9464 | [ALC883_MITAC] = { | 9439 | [ALC883_MITAC] = { |
9465 | .mixers = { alc883_mitac_mixer }, | 9440 | .mixers = { alc883_mitac_mixer }, |
@@ -9470,7 +9445,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9470 | .channel_mode = alc883_3ST_2ch_modes, | 9445 | .channel_mode = alc883_3ST_2ch_modes, |
9471 | .input_mux = &alc883_capture_source, | 9446 | .input_mux = &alc883_capture_source, |
9472 | .unsol_event = alc_automute_amp_unsol_event, | 9447 | .unsol_event = alc_automute_amp_unsol_event, |
9473 | .init_hook = alc883_mitac_init_hook, | 9448 | .setup = alc883_mitac_setup, |
9449 | .init_hook = alc_automute_amp, | ||
9474 | }, | 9450 | }, |
9475 | [ALC883_FUJITSU_PI2515] = { | 9451 | [ALC883_FUJITSU_PI2515] = { |
9476 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, | 9452 | .mixers = { alc883_2ch_fujitsu_pi2515_mixer }, |
@@ -9483,7 +9459,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9483 | .channel_mode = alc883_3ST_2ch_modes, | 9459 | .channel_mode = alc883_3ST_2ch_modes, |
9484 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | 9460 | .input_mux = &alc883_fujitsu_pi2515_capture_source, |
9485 | .unsol_event = alc_automute_amp_unsol_event, | 9461 | .unsol_event = alc_automute_amp_unsol_event, |
9486 | .init_hook = alc883_2ch_fujitsu_pi2515_init_hook, | 9462 | .setup = alc883_2ch_fujitsu_pi2515_setup, |
9463 | .init_hook = alc_automute_amp, | ||
9487 | }, | 9464 | }, |
9488 | [ALC888_FUJITSU_XA3530] = { | 9465 | [ALC888_FUJITSU_XA3530] = { |
9489 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, | 9466 | .mixers = { alc888_base_mixer, alc883_chmode_mixer }, |
@@ -9501,7 +9478,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9501 | ARRAY_SIZE(alc888_2_capture_sources), | 9478 | ARRAY_SIZE(alc888_2_capture_sources), |
9502 | .input_mux = alc888_2_capture_sources, | 9479 | .input_mux = alc888_2_capture_sources, |
9503 | .unsol_event = alc_automute_amp_unsol_event, | 9480 | .unsol_event = alc_automute_amp_unsol_event, |
9504 | .init_hook = alc888_fujitsu_xa3530_init_hook, | 9481 | .setup = alc888_fujitsu_xa3530_setup, |
9482 | .init_hook = alc_automute_amp, | ||
9505 | }, | 9483 | }, |
9506 | [ALC888_LENOVO_SKY] = { | 9484 | [ALC888_LENOVO_SKY] = { |
9507 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, | 9485 | .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer }, |
@@ -9514,7 +9492,8 @@ static struct alc_config_preset alc883_presets[] = { | |||
9514 | .need_dac_fix = 1, | 9492 | .need_dac_fix = 1, |
9515 | .input_mux = &alc883_lenovo_sky_capture_source, | 9493 | .input_mux = &alc883_lenovo_sky_capture_source, |
9516 | .unsol_event = alc_automute_amp_unsol_event, | 9494 | .unsol_event = alc_automute_amp_unsol_event, |
9517 | .init_hook = alc888_lenovo_sky_init_hook, | 9495 | .setup = alc888_lenovo_sky_setup, |
9496 | .init_hook = alc_automute_amp, | ||
9518 | }, | 9497 | }, |
9519 | [ALC888_ASUS_M90V] = { | 9498 | [ALC888_ASUS_M90V] = { |
9520 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, | 9499 | .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, |
@@ -9527,8 +9506,9 @@ static struct alc_config_preset alc883_presets[] = { | |||
9527 | .channel_mode = alc883_3ST_6ch_modes, | 9506 | .channel_mode = alc883_3ST_6ch_modes, |
9528 | .need_dac_fix = 1, | 9507 | .need_dac_fix = 1, |
9529 | .input_mux = &alc883_fujitsu_pi2515_capture_source, | 9508 | .input_mux = &alc883_fujitsu_pi2515_capture_source, |
9530 | .unsol_event = alc883_mode2_unsol_event, | 9509 | .unsol_event = alc_sku_unsol_event, |
9531 | .init_hook = alc883_mode2_inithook, | 9510 | .setup = alc883_mode2_setup, |
9511 | .init_hook = alc_inithook, | ||
9532 | }, | 9512 | }, |
9533 | [ALC888_ASUS_EEE1601] = { | 9513 | [ALC888_ASUS_EEE1601] = { |
9534 | .mixers = { alc883_asus_eee1601_mixer }, | 9514 | .mixers = { alc883_asus_eee1601_mixer }, |
@@ -9581,15 +9561,45 @@ static struct alc_config_preset alc883_presets[] = { | |||
9581 | .channel_mode = alc883_3ST_2ch_modes, | 9561 | .channel_mode = alc883_3ST_2ch_modes, |
9582 | .input_mux = &alc883_capture_source, | 9562 | .input_mux = &alc883_capture_source, |
9583 | .unsol_event = alc_automute_amp_unsol_event, | 9563 | .unsol_event = alc_automute_amp_unsol_event, |
9584 | .init_hook = alc883_vaiott_init_hook, | 9564 | .setup = alc883_vaiott_setup, |
9565 | .init_hook = alc_automute_amp, | ||
9585 | }, | 9566 | }, |
9586 | }; | 9567 | }; |
9587 | 9568 | ||
9588 | 9569 | ||
9589 | /* | 9570 | /* |
9571 | * Pin config fixes | ||
9572 | */ | ||
9573 | enum { | ||
9574 | PINFIX_ABIT_AW9D_MAX | ||
9575 | }; | ||
9576 | |||
9577 | static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { | ||
9578 | { 0x15, 0x01080104 }, /* side */ | ||
9579 | { 0x16, 0x01011012 }, /* rear */ | ||
9580 | { 0x17, 0x01016011 }, /* clfe */ | ||
9581 | { } | ||
9582 | }; | ||
9583 | |||
9584 | static const struct alc_pincfg *alc882_pin_fixes[] = { | ||
9585 | [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix, | ||
9586 | }; | ||
9587 | |||
9588 | static struct snd_pci_quirk alc882_pinfix_tbl[] = { | ||
9589 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), | ||
9590 | {} | ||
9591 | }; | ||
9592 | |||
9593 | /* | ||
9590 | * BIOS auto configuration | 9594 | * BIOS auto configuration |
9591 | */ | 9595 | */ |
9592 | static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | 9596 | static int alc882_auto_create_input_ctls(struct hda_codec *codec, |
9597 | const struct auto_pin_cfg *cfg) | ||
9598 | { | ||
9599 | return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22); | ||
9600 | } | ||
9601 | |||
9602 | static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, | ||
9593 | hda_nid_t nid, int pin_type, | 9603 | hda_nid_t nid, int pin_type, |
9594 | int dac_idx) | 9604 | int dac_idx) |
9595 | { | 9605 | { |
@@ -9606,7 +9616,7 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec, | |||
9606 | 9616 | ||
9607 | } | 9617 | } |
9608 | 9618 | ||
9609 | static void alc883_auto_init_multi_out(struct hda_codec *codec) | 9619 | static void alc882_auto_init_multi_out(struct hda_codec *codec) |
9610 | { | 9620 | { |
9611 | struct alc_spec *spec = codec->spec; | 9621 | struct alc_spec *spec = codec->spec; |
9612 | int i; | 9622 | int i; |
@@ -9615,12 +9625,12 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec) | |||
9615 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; | 9625 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
9616 | int pin_type = get_pin_type(spec->autocfg.line_out_type); | 9626 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
9617 | if (nid) | 9627 | if (nid) |
9618 | alc883_auto_set_output_and_unmute(codec, nid, pin_type, | 9628 | alc882_auto_set_output_and_unmute(codec, nid, pin_type, |
9619 | i); | 9629 | i); |
9620 | } | 9630 | } |
9621 | } | 9631 | } |
9622 | 9632 | ||
9623 | static void alc883_auto_init_hp_out(struct hda_codec *codec) | 9633 | static void alc882_auto_init_hp_out(struct hda_codec *codec) |
9624 | { | 9634 | { |
9625 | struct alc_spec *spec = codec->spec; | 9635 | struct alc_spec *spec = codec->spec; |
9626 | hda_nid_t pin; | 9636 | hda_nid_t pin; |
@@ -9628,91 +9638,191 @@ static void alc883_auto_init_hp_out(struct hda_codec *codec) | |||
9628 | pin = spec->autocfg.hp_pins[0]; | 9638 | pin = spec->autocfg.hp_pins[0]; |
9629 | if (pin) /* connect to front */ | 9639 | if (pin) /* connect to front */ |
9630 | /* use dac 0 */ | 9640 | /* use dac 0 */ |
9631 | alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); | 9641 | alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); |
9632 | pin = spec->autocfg.speaker_pins[0]; | 9642 | pin = spec->autocfg.speaker_pins[0]; |
9633 | if (pin) | 9643 | if (pin) |
9634 | alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | 9644 | alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
9635 | } | 9645 | } |
9636 | 9646 | ||
9637 | #define alc883_is_input_pin(nid) alc880_is_input_pin(nid) | 9647 | static void alc882_auto_init_analog_input(struct hda_codec *codec) |
9638 | #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID | ||
9639 | |||
9640 | static void alc883_auto_init_analog_input(struct hda_codec *codec) | ||
9641 | { | 9648 | { |
9642 | struct alc_spec *spec = codec->spec; | 9649 | struct alc_spec *spec = codec->spec; |
9643 | int i; | 9650 | int i; |
9644 | 9651 | ||
9645 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 9652 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
9646 | hda_nid_t nid = spec->autocfg.input_pins[i]; | 9653 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
9647 | if (alc883_is_input_pin(nid)) { | 9654 | if (!nid) |
9648 | alc_set_input_pin(codec, nid, i); | 9655 | continue; |
9649 | if (nid != ALC883_PIN_CD_NID && | 9656 | alc_set_input_pin(codec, nid, i); |
9650 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) | 9657 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
9658 | snd_hda_codec_write(codec, nid, 0, | ||
9659 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
9660 | AMP_OUT_MUTE); | ||
9661 | } | ||
9662 | } | ||
9663 | |||
9664 | static void alc882_auto_init_input_src(struct hda_codec *codec) | ||
9665 | { | ||
9666 | struct alc_spec *spec = codec->spec; | ||
9667 | int c; | ||
9668 | |||
9669 | for (c = 0; c < spec->num_adc_nids; c++) { | ||
9670 | hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; | ||
9671 | hda_nid_t nid = spec->capsrc_nids[c]; | ||
9672 | unsigned int mux_idx; | ||
9673 | const struct hda_input_mux *imux; | ||
9674 | int conns, mute, idx, item; | ||
9675 | |||
9676 | conns = snd_hda_get_connections(codec, nid, conn_list, | ||
9677 | ARRAY_SIZE(conn_list)); | ||
9678 | if (conns < 0) | ||
9679 | continue; | ||
9680 | mux_idx = c >= spec->num_mux_defs ? 0 : c; | ||
9681 | imux = &spec->input_mux[mux_idx]; | ||
9682 | for (idx = 0; idx < conns; idx++) { | ||
9683 | /* if the current connection is the selected one, | ||
9684 | * unmute it as default - otherwise mute it | ||
9685 | */ | ||
9686 | mute = AMP_IN_MUTE(idx); | ||
9687 | for (item = 0; item < imux->num_items; item++) { | ||
9688 | if (imux->items[item].index == idx) { | ||
9689 | if (spec->cur_mux[c] == item) | ||
9690 | mute = AMP_IN_UNMUTE(idx); | ||
9691 | break; | ||
9692 | } | ||
9693 | } | ||
9694 | /* check if we have a selector or mixer | ||
9695 | * we could check for the widget type instead, but | ||
9696 | * just check for Amp-In presence (in case of mixer | ||
9697 | * without amp-in there is something wrong, this | ||
9698 | * function shouldn't be used or capsrc nid is wrong) | ||
9699 | */ | ||
9700 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) | ||
9651 | snd_hda_codec_write(codec, nid, 0, | 9701 | snd_hda_codec_write(codec, nid, 0, |
9652 | AC_VERB_SET_AMP_GAIN_MUTE, | 9702 | AC_VERB_SET_AMP_GAIN_MUTE, |
9653 | AMP_OUT_MUTE); | 9703 | mute); |
9704 | else if (mute != AMP_IN_MUTE(idx)) | ||
9705 | snd_hda_codec_write(codec, nid, 0, | ||
9706 | AC_VERB_SET_CONNECT_SEL, | ||
9707 | idx); | ||
9654 | } | 9708 | } |
9655 | } | 9709 | } |
9656 | } | 9710 | } |
9657 | 9711 | ||
9658 | #define alc883_auto_init_input_src alc882_auto_init_input_src | 9712 | /* add mic boosts if needed */ |
9713 | static int alc_auto_add_mic_boost(struct hda_codec *codec) | ||
9714 | { | ||
9715 | struct alc_spec *spec = codec->spec; | ||
9716 | int err; | ||
9717 | hda_nid_t nid; | ||
9718 | |||
9719 | nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; | ||
9720 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { | ||
9721 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
9722 | "Mic Boost", | ||
9723 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | ||
9724 | if (err < 0) | ||
9725 | return err; | ||
9726 | } | ||
9727 | nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; | ||
9728 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { | ||
9729 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
9730 | "Front Mic Boost", | ||
9731 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | ||
9732 | if (err < 0) | ||
9733 | return err; | ||
9734 | } | ||
9735 | return 0; | ||
9736 | } | ||
9659 | 9737 | ||
9660 | /* almost identical with ALC880 parser... */ | 9738 | /* almost identical with ALC880 parser... */ |
9661 | static int alc883_parse_auto_config(struct hda_codec *codec) | 9739 | static int alc882_parse_auto_config(struct hda_codec *codec) |
9662 | { | 9740 | { |
9663 | struct alc_spec *spec = codec->spec; | 9741 | struct alc_spec *spec = codec->spec; |
9664 | int err = alc880_parse_auto_config(codec); | 9742 | static hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
9665 | struct auto_pin_cfg *cfg = &spec->autocfg; | 9743 | int i, err; |
9666 | int i; | ||
9667 | 9744 | ||
9745 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | ||
9746 | alc882_ignore); | ||
9668 | if (err < 0) | 9747 | if (err < 0) |
9669 | return err; | 9748 | return err; |
9670 | else if (!err) | 9749 | if (!spec->autocfg.line_outs) |
9671 | return 0; /* no config found */ | 9750 | return 0; /* can't find valid BIOS pin config */ |
9672 | 9751 | ||
9673 | err = alc_auto_add_mic_boost(codec); | 9752 | err = alc880_auto_fill_dac_nids(spec, &spec->autocfg); |
9753 | if (err < 0) | ||
9754 | return err; | ||
9755 | err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); | ||
9756 | if (err < 0) | ||
9757 | return err; | ||
9758 | err = alc880_auto_create_extra_out(spec, | ||
9759 | spec->autocfg.speaker_pins[0], | ||
9760 | "Speaker"); | ||
9761 | if (err < 0) | ||
9762 | return err; | ||
9763 | err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], | ||
9764 | "Headphone"); | ||
9765 | if (err < 0) | ||
9766 | return err; | ||
9767 | err = alc882_auto_create_input_ctls(codec, &spec->autocfg); | ||
9674 | if (err < 0) | 9768 | if (err < 0) |
9675 | return err; | 9769 | return err; |
9676 | 9770 | ||
9677 | /* hack - override the init verbs */ | 9771 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
9678 | spec->init_verbs[0] = alc883_auto_init_verbs; | ||
9679 | 9772 | ||
9680 | /* setup input_mux for ALC889 */ | 9773 | /* check multiple SPDIF-out (for recent codecs) */ |
9681 | if (codec->vendor_id == 0x10ec0889) { | 9774 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
9682 | /* digital-mic input pin is excluded in alc880_auto_create..() | 9775 | hda_nid_t dig_nid; |
9683 | * because it's under 0x18 | 9776 | err = snd_hda_get_connections(codec, |
9684 | */ | 9777 | spec->autocfg.dig_out_pins[i], |
9685 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | 9778 | &dig_nid, 1); |
9686 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | 9779 | if (err < 0) |
9687 | struct hda_input_mux *imux = &spec->private_imux[0]; | 9780 | continue; |
9688 | for (i = 1; i < 3; i++) | 9781 | if (!i) |
9689 | memcpy(&spec->private_imux[i], | 9782 | spec->multiout.dig_out_nid = dig_nid; |
9690 | &spec->private_imux[0], | 9783 | else { |
9691 | sizeof(spec->private_imux[0])); | 9784 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
9692 | imux->items[imux->num_items].label = "Int DMic"; | 9785 | spec->slave_dig_outs[i - 1] = dig_nid; |
9693 | imux->items[imux->num_items].index = 0x0b; | 9786 | if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1) |
9694 | imux->num_items++; | 9787 | break; |
9695 | spec->num_mux_defs = 3; | ||
9696 | spec->input_mux = spec->private_imux; | ||
9697 | } | 9788 | } |
9698 | } | 9789 | } |
9790 | if (spec->autocfg.dig_in_pin) | ||
9791 | spec->dig_in_nid = ALC880_DIGIN_NID; | ||
9792 | |||
9793 | if (spec->kctls.list) | ||
9794 | add_mixer(spec, spec->kctls.list); | ||
9795 | |||
9796 | add_verb(spec, alc883_auto_init_verbs); | ||
9797 | /* if ADC 0x07 is available, initialize it, too */ | ||
9798 | if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN) | ||
9799 | add_verb(spec, alc882_adc1_init_verbs); | ||
9800 | |||
9801 | spec->num_mux_defs = 1; | ||
9802 | spec->input_mux = &spec->private_imux[0]; | ||
9803 | |||
9804 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | ||
9805 | |||
9806 | err = alc_auto_add_mic_boost(codec); | ||
9807 | if (err < 0) | ||
9808 | return err; | ||
9699 | 9809 | ||
9700 | return 1; /* config found */ | 9810 | return 1; /* config found */ |
9701 | } | 9811 | } |
9702 | 9812 | ||
9703 | /* additional initialization for auto-configuration model */ | 9813 | /* additional initialization for auto-configuration model */ |
9704 | static void alc883_auto_init(struct hda_codec *codec) | 9814 | static void alc882_auto_init(struct hda_codec *codec) |
9705 | { | 9815 | { |
9706 | struct alc_spec *spec = codec->spec; | 9816 | struct alc_spec *spec = codec->spec; |
9707 | alc883_auto_init_multi_out(codec); | 9817 | alc882_auto_init_multi_out(codec); |
9708 | alc883_auto_init_hp_out(codec); | 9818 | alc882_auto_init_hp_out(codec); |
9709 | alc883_auto_init_analog_input(codec); | 9819 | alc882_auto_init_analog_input(codec); |
9710 | alc883_auto_init_input_src(codec); | 9820 | alc882_auto_init_input_src(codec); |
9711 | if (spec->unsol_event) | 9821 | if (spec->unsol_event) |
9712 | alc_inithook(codec); | 9822 | alc_inithook(codec); |
9713 | } | 9823 | } |
9714 | 9824 | ||
9715 | static int patch_alc883(struct hda_codec *codec) | 9825 | static int patch_alc882(struct hda_codec *codec) |
9716 | { | 9826 | { |
9717 | struct alc_spec *spec; | 9827 | struct alc_spec *spec; |
9718 | int err, board_config; | 9828 | int err, board_config; |
@@ -9723,28 +9833,35 @@ static int patch_alc883(struct hda_codec *codec) | |||
9723 | 9833 | ||
9724 | codec->spec = spec; | 9834 | codec->spec = spec; |
9725 | 9835 | ||
9726 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); | 9836 | switch (codec->vendor_id) { |
9837 | case 0x10ec0882: | ||
9838 | case 0x10ec0885: | ||
9839 | break; | ||
9840 | default: | ||
9841 | /* ALC883 and variants */ | ||
9842 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); | ||
9843 | break; | ||
9844 | } | ||
9727 | 9845 | ||
9728 | board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST, | 9846 | board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST, |
9729 | alc883_models, | 9847 | alc882_models, |
9730 | alc883_cfg_tbl); | 9848 | alc882_cfg_tbl); |
9731 | if (board_config < 0 || board_config >= ALC883_MODEL_LAST) { | 9849 | |
9732 | /* Pick up systems that don't supply PCI SSID */ | 9850 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) |
9733 | switch (codec->subsystem_id) { | 9851 | board_config = snd_hda_check_board_codec_sid_config(codec, |
9734 | case 0x106b3600: /* Macbook 3.1 */ | 9852 | ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl); |
9735 | board_config = ALC889A_MB31; | 9853 | |
9736 | break; | 9854 | if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { |
9737 | default: | 9855 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
9738 | printk(KERN_INFO | 9856 | codec->chip_name); |
9739 | "hda_codec: Unknown model for %s, trying " | 9857 | board_config = ALC882_AUTO; |
9740 | "auto-probe from BIOS...\n", codec->chip_name); | ||
9741 | board_config = ALC883_AUTO; | ||
9742 | } | ||
9743 | } | 9858 | } |
9744 | 9859 | ||
9745 | if (board_config == ALC883_AUTO) { | 9860 | alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes); |
9861 | |||
9862 | if (board_config == ALC882_AUTO) { | ||
9746 | /* automatic parse from the BIOS config */ | 9863 | /* automatic parse from the BIOS config */ |
9747 | err = alc883_parse_auto_config(codec); | 9864 | err = alc882_parse_auto_config(codec); |
9748 | if (err < 0) { | 9865 | if (err < 0) { |
9749 | alc_free(codec); | 9866 | alc_free(codec); |
9750 | return err; | 9867 | return err; |
@@ -9752,7 +9869,7 @@ static int patch_alc883(struct hda_codec *codec) | |||
9752 | printk(KERN_INFO | 9869 | printk(KERN_INFO |
9753 | "hda_codec: Cannot set up configuration " | 9870 | "hda_codec: Cannot set up configuration " |
9754 | "from BIOS. Using base mode...\n"); | 9871 | "from BIOS. Using base mode...\n"); |
9755 | board_config = ALC883_3ST_2ch_DIG; | 9872 | board_config = ALC882_3ST_DIG; |
9756 | } | 9873 | } |
9757 | } | 9874 | } |
9758 | 9875 | ||
@@ -9762,63 +9879,61 @@ static int patch_alc883(struct hda_codec *codec) | |||
9762 | return err; | 9879 | return err; |
9763 | } | 9880 | } |
9764 | 9881 | ||
9765 | if (board_config != ALC883_AUTO) | 9882 | if (board_config != ALC882_AUTO) |
9766 | setup_preset(spec, &alc883_presets[board_config]); | 9883 | setup_preset(codec, &alc882_presets[board_config]); |
9767 | 9884 | ||
9768 | switch (codec->vendor_id) { | 9885 | spec->stream_analog_playback = &alc882_pcm_analog_playback; |
9769 | case 0x10ec0888: | 9886 | spec->stream_analog_capture = &alc882_pcm_analog_capture; |
9770 | if (!spec->num_adc_nids) { | 9887 | /* FIXME: setup DAC5 */ |
9771 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | 9888 | /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/ |
9772 | spec->adc_nids = alc883_adc_nids; | 9889 | spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture; |
9773 | } | 9890 | |
9774 | if (!spec->capsrc_nids) | 9891 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
9775 | spec->capsrc_nids = alc883_capsrc_nids; | 9892 | spec->stream_digital_capture = &alc882_pcm_digital_capture; |
9893 | |||
9894 | if (codec->vendor_id == 0x10ec0888) | ||
9776 | spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ | 9895 | spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ |
9777 | break; | 9896 | |
9778 | case 0x10ec0889: | 9897 | if (!spec->adc_nids && spec->input_mux) { |
9779 | if (!spec->num_adc_nids) { | 9898 | int i; |
9780 | spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids); | 9899 | spec->num_adc_nids = 0; |
9781 | spec->adc_nids = alc889_adc_nids; | 9900 | for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) { |
9782 | } | 9901 | hda_nid_t cap; |
9783 | if (!spec->capsrc_nids) | 9902 | hda_nid_t nid = alc882_adc_nids[i]; |
9784 | spec->capsrc_nids = alc889_capsrc_nids; | 9903 | unsigned int wcap = get_wcaps(codec, nid); |
9785 | break; | 9904 | /* get type */ |
9786 | default: | 9905 | wcap = get_wcaps_type(wcap); |
9787 | if (!spec->num_adc_nids) { | 9906 | if (wcap != AC_WID_AUD_IN) |
9788 | spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); | 9907 | continue; |
9789 | spec->adc_nids = alc883_adc_nids; | 9908 | spec->private_adc_nids[spec->num_adc_nids] = nid; |
9909 | err = snd_hda_get_connections(codec, nid, &cap, 1); | ||
9910 | if (err < 0) | ||
9911 | continue; | ||
9912 | spec->private_capsrc_nids[spec->num_adc_nids] = cap; | ||
9913 | spec->num_adc_nids++; | ||
9790 | } | 9914 | } |
9791 | if (!spec->capsrc_nids) | 9915 | spec->adc_nids = spec->private_adc_nids; |
9792 | spec->capsrc_nids = alc883_capsrc_nids; | 9916 | spec->capsrc_nids = spec->private_capsrc_nids; |
9793 | break; | ||
9794 | } | 9917 | } |
9795 | 9918 | ||
9796 | spec->stream_analog_playback = &alc883_pcm_analog_playback; | 9919 | set_capture_mixer(codec); |
9797 | spec->stream_analog_capture = &alc883_pcm_analog_capture; | ||
9798 | spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture; | ||
9799 | |||
9800 | spec->stream_digital_playback = &alc883_pcm_digital_playback; | ||
9801 | spec->stream_digital_capture = &alc883_pcm_digital_capture; | ||
9802 | |||
9803 | if (!spec->cap_mixer) | ||
9804 | set_capture_mixer(spec); | ||
9805 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 9920 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
9806 | 9921 | ||
9807 | spec->vmaster_nid = 0x0c; | 9922 | spec->vmaster_nid = 0x0c; |
9808 | 9923 | ||
9809 | codec->patch_ops = alc_patch_ops; | 9924 | codec->patch_ops = alc_patch_ops; |
9810 | if (board_config == ALC883_AUTO) | 9925 | if (board_config == ALC882_AUTO) |
9811 | spec->init_hook = alc883_auto_init; | 9926 | spec->init_hook = alc882_auto_init; |
9812 | |||
9813 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 9927 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9814 | if (!spec->loopback.amplist) | 9928 | if (!spec->loopback.amplist) |
9815 | spec->loopback.amplist = alc883_loopbacks; | 9929 | spec->loopback.amplist = alc882_loopbacks; |
9816 | #endif | 9930 | #endif |
9817 | codec->proc_widget_hook = print_realtek_coef; | 9931 | codec->proc_widget_hook = print_realtek_coef; |
9818 | 9932 | ||
9819 | return 0; | 9933 | return 0; |
9820 | } | 9934 | } |
9821 | 9935 | ||
9936 | |||
9822 | /* | 9937 | /* |
9823 | * ALC262 support | 9938 | * ALC262 support |
9824 | */ | 9939 | */ |
@@ -9994,13 +10109,12 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = { | |||
9994 | }; | 10109 | }; |
9995 | 10110 | ||
9996 | /* mute/unmute internal speaker according to the hp jack and mute state */ | 10111 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
9997 | static void alc262_hp_t5735_init_hook(struct hda_codec *codec) | 10112 | static void alc262_hp_t5735_setup(struct hda_codec *codec) |
9998 | { | 10113 | { |
9999 | struct alc_spec *spec = codec->spec; | 10114 | struct alc_spec *spec = codec->spec; |
10000 | 10115 | ||
10001 | spec->autocfg.hp_pins[0] = 0x15; | 10116 | spec->autocfg.hp_pins[0] = 0x15; |
10002 | spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ | 10117 | spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ |
10003 | alc_automute_amp(codec); | ||
10004 | } | 10118 | } |
10005 | 10119 | ||
10006 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | 10120 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { |
@@ -10157,22 +10271,20 @@ static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res) | |||
10157 | alc262_hippo_automute(codec); | 10271 | alc262_hippo_automute(codec); |
10158 | } | 10272 | } |
10159 | 10273 | ||
10160 | static void alc262_hippo_init_hook(struct hda_codec *codec) | 10274 | static void alc262_hippo_setup(struct hda_codec *codec) |
10161 | { | 10275 | { |
10162 | struct alc_spec *spec = codec->spec; | 10276 | struct alc_spec *spec = codec->spec; |
10163 | 10277 | ||
10164 | spec->autocfg.hp_pins[0] = 0x15; | 10278 | spec->autocfg.hp_pins[0] = 0x15; |
10165 | spec->autocfg.speaker_pins[0] = 0x14; | 10279 | spec->autocfg.speaker_pins[0] = 0x14; |
10166 | alc262_hippo_automute(codec); | ||
10167 | } | 10280 | } |
10168 | 10281 | ||
10169 | static void alc262_hippo1_init_hook(struct hda_codec *codec) | 10282 | static void alc262_hippo1_setup(struct hda_codec *codec) |
10170 | { | 10283 | { |
10171 | struct alc_spec *spec = codec->spec; | 10284 | struct alc_spec *spec = codec->spec; |
10172 | 10285 | ||
10173 | spec->autocfg.hp_pins[0] = 0x1b; | 10286 | spec->autocfg.hp_pins[0] = 0x1b; |
10174 | spec->autocfg.speaker_pins[0] = 0x14; | 10287 | spec->autocfg.speaker_pins[0] = 0x14; |
10175 | alc262_hippo_automute(codec); | ||
10176 | } | 10288 | } |
10177 | 10289 | ||
10178 | 10290 | ||
@@ -10229,13 +10341,12 @@ static struct hda_verb alc262_tyan_verbs[] = { | |||
10229 | }; | 10341 | }; |
10230 | 10342 | ||
10231 | /* unsolicited event for HP jack sensing */ | 10343 | /* unsolicited event for HP jack sensing */ |
10232 | static void alc262_tyan_init_hook(struct hda_codec *codec) | 10344 | static void alc262_tyan_setup(struct hda_codec *codec) |
10233 | { | 10345 | { |
10234 | struct alc_spec *spec = codec->spec; | 10346 | struct alc_spec *spec = codec->spec; |
10235 | 10347 | ||
10236 | spec->autocfg.hp_pins[0] = 0x1b; | 10348 | spec->autocfg.hp_pins[0] = 0x1b; |
10237 | spec->autocfg.speaker_pins[0] = 0x15; | 10349 | spec->autocfg.speaker_pins[0] = 0x15; |
10238 | alc_automute_amp(codec); | ||
10239 | } | 10350 | } |
10240 | 10351 | ||
10241 | 10352 | ||
@@ -10327,12 +10438,6 @@ static struct hda_verb alc262_eapd_verbs[] = { | |||
10327 | { } | 10438 | { } |
10328 | }; | 10439 | }; |
10329 | 10440 | ||
10330 | static struct hda_verb alc262_hippo_unsol_verbs[] = { | ||
10331 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
10332 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
10333 | {} | ||
10334 | }; | ||
10335 | |||
10336 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { | 10441 | static struct hda_verb alc262_hippo1_unsol_verbs[] = { |
10337 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, | 10442 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, |
10338 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, | 10443 | {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -10353,14 +10458,6 @@ static struct hda_verb alc262_sony_unsol_verbs[] = { | |||
10353 | {} | 10458 | {} |
10354 | }; | 10459 | }; |
10355 | 10460 | ||
10356 | static struct hda_input_mux alc262_dmic_capture_source = { | ||
10357 | .num_items = 2, | ||
10358 | .items = { | ||
10359 | { "Int DMic", 0x9 }, | ||
10360 | { "Mic", 0x0 }, | ||
10361 | }, | ||
10362 | }; | ||
10363 | |||
10364 | static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { | 10461 | static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = { |
10365 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 10462 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
10366 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 10463 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
@@ -10382,35 +10479,17 @@ static struct hda_verb alc262_toshiba_s06_verbs[] = { | |||
10382 | {} | 10479 | {} |
10383 | }; | 10480 | }; |
10384 | 10481 | ||
10385 | static void alc262_dmic_automute(struct hda_codec *codec) | 10482 | static void alc262_toshiba_s06_setup(struct hda_codec *codec) |
10386 | { | ||
10387 | unsigned int present; | ||
10388 | |||
10389 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
10390 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
10391 | snd_hda_codec_write(codec, 0x22, 0, | ||
10392 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09); | ||
10393 | } | ||
10394 | |||
10395 | |||
10396 | /* unsolicited event for HP jack sensing */ | ||
10397 | static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec, | ||
10398 | unsigned int res) | ||
10399 | { | ||
10400 | if ((res >> 26) == ALC880_MIC_EVENT) | ||
10401 | alc262_dmic_automute(codec); | ||
10402 | else | ||
10403 | alc_sku_unsol_event(codec, res); | ||
10404 | } | ||
10405 | |||
10406 | static void alc262_toshiba_s06_init_hook(struct hda_codec *codec) | ||
10407 | { | 10483 | { |
10408 | struct alc_spec *spec = codec->spec; | 10484 | struct alc_spec *spec = codec->spec; |
10409 | 10485 | ||
10410 | spec->autocfg.hp_pins[0] = 0x15; | 10486 | spec->autocfg.hp_pins[0] = 0x15; |
10411 | spec->autocfg.speaker_pins[0] = 0x14; | 10487 | spec->autocfg.speaker_pins[0] = 0x14; |
10412 | alc_automute_pin(codec); | 10488 | spec->ext_mic.pin = 0x18; |
10413 | alc262_dmic_automute(codec); | 10489 | spec->ext_mic.mux_idx = 0; |
10490 | spec->int_mic.pin = 0x12; | ||
10491 | spec->int_mic.mux_idx = 9; | ||
10492 | spec->auto_mic = 1; | ||
10414 | } | 10493 | } |
10415 | 10494 | ||
10416 | /* | 10495 | /* |
@@ -10599,6 +10678,18 @@ static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec, | |||
10599 | alc262_lenovo_3000_automute(codec, 1); | 10678 | alc262_lenovo_3000_automute(codec, 1); |
10600 | } | 10679 | } |
10601 | 10680 | ||
10681 | static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid, | ||
10682 | int dir, int idx, long *valp) | ||
10683 | { | ||
10684 | int i, change = 0; | ||
10685 | |||
10686 | for (i = 0; i < 2; i++, valp++) | ||
10687 | change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx, | ||
10688 | HDA_AMP_MUTE, | ||
10689 | *valp ? 0 : HDA_AMP_MUTE); | ||
10690 | return change; | ||
10691 | } | ||
10692 | |||
10602 | /* bind hp and internal speaker mute (with plug check) */ | 10693 | /* bind hp and internal speaker mute (with plug check) */ |
10603 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | 10694 | static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, |
10604 | struct snd_ctl_elem_value *ucontrol) | 10695 | struct snd_ctl_elem_value *ucontrol) |
@@ -10607,13 +10698,8 @@ static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, | |||
10607 | long *valp = ucontrol->value.integer.value; | 10698 | long *valp = ucontrol->value.integer.value; |
10608 | int change; | 10699 | int change; |
10609 | 10700 | ||
10610 | change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, | 10701 | change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp); |
10611 | HDA_AMP_MUTE, | 10702 | change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp); |
10612 | valp ? 0 : HDA_AMP_MUTE); | ||
10613 | change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | ||
10614 | HDA_AMP_MUTE, | ||
10615 | valp ? 0 : HDA_AMP_MUTE); | ||
10616 | |||
10617 | if (change) | 10703 | if (change) |
10618 | alc262_fujitsu_automute(codec, 0); | 10704 | alc262_fujitsu_automute(codec, 0); |
10619 | return change; | 10705 | return change; |
@@ -10648,10 +10734,7 @@ static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol, | |||
10648 | long *valp = ucontrol->value.integer.value; | 10734 | long *valp = ucontrol->value.integer.value; |
10649 | int change; | 10735 | int change; |
10650 | 10736 | ||
10651 | change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, | 10737 | change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp); |
10652 | HDA_AMP_MUTE, | ||
10653 | valp ? 0 : HDA_AMP_MUTE); | ||
10654 | |||
10655 | if (change) | 10738 | if (change) |
10656 | alc262_lenovo_3000_automute(codec, 0); | 10739 | alc262_lenovo_3000_automute(codec, 0); |
10657 | return change; | 10740 | return change; |
@@ -10824,104 +10907,111 @@ static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { | |||
10824 | { } /* end */ | 10907 | { } /* end */ |
10825 | }; | 10908 | }; |
10826 | 10909 | ||
10910 | /* We use two mixers depending on the output pin; 0x16 is a mono output | ||
10911 | * and thus it's bound with a different mixer. | ||
10912 | * This function returns which mixer amp should be used. | ||
10913 | */ | ||
10914 | static int alc262_check_volbit(hda_nid_t nid) | ||
10915 | { | ||
10916 | if (!nid) | ||
10917 | return 0; | ||
10918 | else if (nid == 0x16) | ||
10919 | return 2; | ||
10920 | else | ||
10921 | return 1; | ||
10922 | } | ||
10923 | |||
10924 | static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, | ||
10925 | const char *pfx, int *vbits) | ||
10926 | { | ||
10927 | char name[32]; | ||
10928 | unsigned long val; | ||
10929 | int vbit; | ||
10930 | |||
10931 | vbit = alc262_check_volbit(nid); | ||
10932 | if (!vbit) | ||
10933 | return 0; | ||
10934 | if (*vbits & vbit) /* a volume control for this mixer already there */ | ||
10935 | return 0; | ||
10936 | *vbits |= vbit; | ||
10937 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); | ||
10938 | if (vbit == 2) | ||
10939 | val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); | ||
10940 | else | ||
10941 | val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); | ||
10942 | return add_control(spec, ALC_CTL_WIDGET_VOL, name, val); | ||
10943 | } | ||
10944 | |||
10945 | static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, | ||
10946 | const char *pfx) | ||
10947 | { | ||
10948 | char name[32]; | ||
10949 | unsigned long val; | ||
10950 | |||
10951 | if (!nid) | ||
10952 | return 0; | ||
10953 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
10954 | if (nid == 0x16) | ||
10955 | val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); | ||
10956 | else | ||
10957 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | ||
10958 | return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val); | ||
10959 | } | ||
10960 | |||
10827 | /* add playback controls from the parsed DAC table */ | 10961 | /* add playback controls from the parsed DAC table */ |
10828 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, | 10962 | static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, |
10829 | const struct auto_pin_cfg *cfg) | 10963 | const struct auto_pin_cfg *cfg) |
10830 | { | 10964 | { |
10831 | hda_nid_t nid; | 10965 | const char *pfx; |
10966 | int vbits; | ||
10832 | int err; | 10967 | int err; |
10833 | 10968 | ||
10834 | spec->multiout.num_dacs = 1; /* only use one dac */ | 10969 | spec->multiout.num_dacs = 1; /* only use one dac */ |
10835 | spec->multiout.dac_nids = spec->private_dac_nids; | 10970 | spec->multiout.dac_nids = spec->private_dac_nids; |
10836 | spec->multiout.dac_nids[0] = 2; | 10971 | spec->multiout.dac_nids[0] = 2; |
10837 | 10972 | ||
10838 | nid = cfg->line_out_pins[0]; | 10973 | if (!cfg->speaker_pins[0] && !cfg->hp_pins[0]) |
10839 | if (nid) { | 10974 | pfx = "Master"; |
10840 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | 10975 | else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
10841 | "Front Playback Volume", | 10976 | pfx = "Speaker"; |
10842 | HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT)); | 10977 | else |
10843 | if (err < 0) | 10978 | pfx = "Front"; |
10844 | return err; | 10979 | err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx); |
10845 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 10980 | if (err < 0) |
10846 | "Front Playback Switch", | 10981 | return err; |
10847 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | 10982 | err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker"); |
10848 | if (err < 0) | 10983 | if (err < 0) |
10849 | return err; | 10984 | return err; |
10850 | } | 10985 | err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone"); |
10851 | 10986 | if (err < 0) | |
10852 | nid = cfg->speaker_pins[0]; | 10987 | return err; |
10853 | if (nid) { | ||
10854 | if (nid == 0x16) { | ||
10855 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
10856 | "Speaker Playback Volume", | ||
10857 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | ||
10858 | HDA_OUTPUT)); | ||
10859 | if (err < 0) | ||
10860 | return err; | ||
10861 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
10862 | "Speaker Playback Switch", | ||
10863 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
10864 | HDA_OUTPUT)); | ||
10865 | if (err < 0) | ||
10866 | return err; | ||
10867 | } else { | ||
10868 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
10869 | "Speaker Playback Switch", | ||
10870 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
10871 | HDA_OUTPUT)); | ||
10872 | if (err < 0) | ||
10873 | return err; | ||
10874 | } | ||
10875 | } | ||
10876 | nid = cfg->hp_pins[0]; | ||
10877 | if (nid) { | ||
10878 | /* spec->multiout.hp_nid = 2; */ | ||
10879 | if (nid == 0x16) { | ||
10880 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
10881 | "Headphone Playback Volume", | ||
10882 | HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, | ||
10883 | HDA_OUTPUT)); | ||
10884 | if (err < 0) | ||
10885 | return err; | ||
10886 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
10887 | "Headphone Playback Switch", | ||
10888 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
10889 | HDA_OUTPUT)); | ||
10890 | if (err < 0) | ||
10891 | return err; | ||
10892 | } else { | ||
10893 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
10894 | "Headphone Playback Switch", | ||
10895 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
10896 | HDA_OUTPUT)); | ||
10897 | if (err < 0) | ||
10898 | return err; | ||
10899 | } | ||
10900 | } | ||
10901 | return 0; | ||
10902 | } | ||
10903 | |||
10904 | static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec, | ||
10905 | const struct auto_pin_cfg *cfg) | ||
10906 | { | ||
10907 | int err; | ||
10908 | 10988 | ||
10909 | err = alc880_auto_create_analog_input_ctls(spec, cfg); | 10989 | vbits = alc262_check_volbit(cfg->line_out_pins[0]) | |
10990 | alc262_check_volbit(cfg->speaker_pins[0]) | | ||
10991 | alc262_check_volbit(cfg->hp_pins[0]); | ||
10992 | if (vbits == 1 || vbits == 2) | ||
10993 | pfx = "Master"; /* only one mixer is used */ | ||
10994 | else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
10995 | pfx = "Speaker"; | ||
10996 | else | ||
10997 | pfx = "Front"; | ||
10998 | vbits = 0; | ||
10999 | err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits); | ||
11000 | if (err < 0) | ||
11001 | return err; | ||
11002 | err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker", | ||
11003 | &vbits); | ||
11004 | if (err < 0) | ||
11005 | return err; | ||
11006 | err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone", | ||
11007 | &vbits); | ||
10910 | if (err < 0) | 11008 | if (err < 0) |
10911 | return err; | 11009 | return err; |
10912 | /* digital-mic input pin is excluded in alc880_auto_create..() | ||
10913 | * because it's under 0x18 | ||
10914 | */ | ||
10915 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | ||
10916 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | ||
10917 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
10918 | imux->items[imux->num_items].label = "Int Mic"; | ||
10919 | imux->items[imux->num_items].index = 0x09; | ||
10920 | imux->num_items++; | ||
10921 | } | ||
10922 | return 0; | 11010 | return 0; |
10923 | } | 11011 | } |
10924 | 11012 | ||
11013 | #define alc262_auto_create_input_ctls \ | ||
11014 | alc880_auto_create_input_ctls | ||
10925 | 11015 | ||
10926 | /* | 11016 | /* |
10927 | * generic initialization of ADC, input mixers and output mixers | 11017 | * generic initialization of ADC, input mixers and output mixers |
@@ -11239,7 +11329,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec) | |||
11239 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); | 11329 | err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); |
11240 | if (err < 0) | 11330 | if (err < 0) |
11241 | return err; | 11331 | return err; |
11242 | err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg); | 11332 | err = alc262_auto_create_input_ctls(codec, &spec->autocfg); |
11243 | if (err < 0) | 11333 | if (err < 0) |
11244 | return err; | 11334 | return err; |
11245 | 11335 | ||
@@ -11370,7 +11460,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
11370 | }, | 11460 | }, |
11371 | [ALC262_HIPPO] = { | 11461 | [ALC262_HIPPO] = { |
11372 | .mixers = { alc262_hippo_mixer }, | 11462 | .mixers = { alc262_hippo_mixer }, |
11373 | .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs}, | 11463 | .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs}, |
11374 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | 11464 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
11375 | .dac_nids = alc262_dac_nids, | 11465 | .dac_nids = alc262_dac_nids, |
11376 | .hp_nid = 0x03, | 11466 | .hp_nid = 0x03, |
@@ -11379,7 +11469,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11379 | .channel_mode = alc262_modes, | 11469 | .channel_mode = alc262_modes, |
11380 | .input_mux = &alc262_capture_source, | 11470 | .input_mux = &alc262_capture_source, |
11381 | .unsol_event = alc262_hippo_unsol_event, | 11471 | .unsol_event = alc262_hippo_unsol_event, |
11382 | .init_hook = alc262_hippo_init_hook, | 11472 | .setup = alc262_hippo_setup, |
11473 | .init_hook = alc262_hippo_automute, | ||
11383 | }, | 11474 | }, |
11384 | [ALC262_HIPPO_1] = { | 11475 | [ALC262_HIPPO_1] = { |
11385 | .mixers = { alc262_hippo1_mixer }, | 11476 | .mixers = { alc262_hippo1_mixer }, |
@@ -11392,7 +11483,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11392 | .channel_mode = alc262_modes, | 11483 | .channel_mode = alc262_modes, |
11393 | .input_mux = &alc262_capture_source, | 11484 | .input_mux = &alc262_capture_source, |
11394 | .unsol_event = alc262_hippo_unsol_event, | 11485 | .unsol_event = alc262_hippo_unsol_event, |
11395 | .init_hook = alc262_hippo1_init_hook, | 11486 | .setup = alc262_hippo1_setup, |
11487 | .init_hook = alc262_hippo_automute, | ||
11396 | }, | 11488 | }, |
11397 | [ALC262_FUJITSU] = { | 11489 | [ALC262_FUJITSU] = { |
11398 | .mixers = { alc262_fujitsu_mixer }, | 11490 | .mixers = { alc262_fujitsu_mixer }, |
@@ -11455,7 +11547,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11455 | .channel_mode = alc262_modes, | 11547 | .channel_mode = alc262_modes, |
11456 | .input_mux = &alc262_capture_source, | 11548 | .input_mux = &alc262_capture_source, |
11457 | .unsol_event = alc_automute_amp_unsol_event, | 11549 | .unsol_event = alc_automute_amp_unsol_event, |
11458 | .init_hook = alc262_hp_t5735_init_hook, | 11550 | .setup = alc262_hp_t5735_setup, |
11551 | .init_hook = alc_automute_amp, | ||
11459 | }, | 11552 | }, |
11460 | [ALC262_HP_RP5700] = { | 11553 | [ALC262_HP_RP5700] = { |
11461 | .mixers = { alc262_hp_rp5700_mixer }, | 11554 | .mixers = { alc262_hp_rp5700_mixer }, |
@@ -11486,11 +11579,13 @@ static struct alc_config_preset alc262_presets[] = { | |||
11486 | .channel_mode = alc262_modes, | 11579 | .channel_mode = alc262_modes, |
11487 | .input_mux = &alc262_capture_source, | 11580 | .input_mux = &alc262_capture_source, |
11488 | .unsol_event = alc262_hippo_unsol_event, | 11581 | .unsol_event = alc262_hippo_unsol_event, |
11489 | .init_hook = alc262_hippo_init_hook, | 11582 | .setup = alc262_hippo_setup, |
11583 | .init_hook = alc262_hippo_automute, | ||
11490 | }, | 11584 | }, |
11491 | [ALC262_BENQ_T31] = { | 11585 | [ALC262_BENQ_T31] = { |
11492 | .mixers = { alc262_benq_t31_mixer }, | 11586 | .mixers = { alc262_benq_t31_mixer }, |
11493 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs }, | 11587 | .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, |
11588 | alc_hp15_unsol_verbs }, | ||
11494 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), | 11589 | .num_dacs = ARRAY_SIZE(alc262_dac_nids), |
11495 | .dac_nids = alc262_dac_nids, | 11590 | .dac_nids = alc262_dac_nids, |
11496 | .hp_nid = 0x03, | 11591 | .hp_nid = 0x03, |
@@ -11498,7 +11593,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11498 | .channel_mode = alc262_modes, | 11593 | .channel_mode = alc262_modes, |
11499 | .input_mux = &alc262_capture_source, | 11594 | .input_mux = &alc262_capture_source, |
11500 | .unsol_event = alc262_hippo_unsol_event, | 11595 | .unsol_event = alc262_hippo_unsol_event, |
11501 | .init_hook = alc262_hippo_init_hook, | 11596 | .setup = alc262_hippo_setup, |
11597 | .init_hook = alc262_hippo_automute, | ||
11502 | }, | 11598 | }, |
11503 | [ALC262_ULTRA] = { | 11599 | [ALC262_ULTRA] = { |
11504 | .mixers = { alc262_ultra_mixer }, | 11600 | .mixers = { alc262_ultra_mixer }, |
@@ -11550,9 +11646,9 @@ static struct alc_config_preset alc262_presets[] = { | |||
11550 | .dig_out_nid = ALC262_DIGOUT_NID, | 11646 | .dig_out_nid = ALC262_DIGOUT_NID, |
11551 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | 11647 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
11552 | .channel_mode = alc262_modes, | 11648 | .channel_mode = alc262_modes, |
11553 | .input_mux = &alc262_dmic_capture_source, | 11649 | .unsol_event = alc_sku_unsol_event, |
11554 | .unsol_event = alc262_toshiba_s06_unsol_event, | 11650 | .setup = alc262_toshiba_s06_setup, |
11555 | .init_hook = alc262_toshiba_s06_init_hook, | 11651 | .init_hook = alc_inithook, |
11556 | }, | 11652 | }, |
11557 | [ALC262_TOSHIBA_RX1] = { | 11653 | [ALC262_TOSHIBA_RX1] = { |
11558 | .mixers = { alc262_toshiba_rx1_mixer }, | 11654 | .mixers = { alc262_toshiba_rx1_mixer }, |
@@ -11564,7 +11660,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11564 | .channel_mode = alc262_modes, | 11660 | .channel_mode = alc262_modes, |
11565 | .input_mux = &alc262_capture_source, | 11661 | .input_mux = &alc262_capture_source, |
11566 | .unsol_event = alc262_hippo_unsol_event, | 11662 | .unsol_event = alc262_hippo_unsol_event, |
11567 | .init_hook = alc262_hippo_init_hook, | 11663 | .setup = alc262_hippo_setup, |
11664 | .init_hook = alc262_hippo_automute, | ||
11568 | }, | 11665 | }, |
11569 | [ALC262_TYAN] = { | 11666 | [ALC262_TYAN] = { |
11570 | .mixers = { alc262_tyan_mixer }, | 11667 | .mixers = { alc262_tyan_mixer }, |
@@ -11577,7 +11674,8 @@ static struct alc_config_preset alc262_presets[] = { | |||
11577 | .channel_mode = alc262_modes, | 11674 | .channel_mode = alc262_modes, |
11578 | .input_mux = &alc262_capture_source, | 11675 | .input_mux = &alc262_capture_source, |
11579 | .unsol_event = alc_automute_amp_unsol_event, | 11676 | .unsol_event = alc_automute_amp_unsol_event, |
11580 | .init_hook = alc262_tyan_init_hook, | 11677 | .setup = alc262_tyan_setup, |
11678 | .init_hook = alc_automute_amp, | ||
11581 | }, | 11679 | }, |
11582 | }; | 11680 | }; |
11583 | 11681 | ||
@@ -11612,8 +11710,8 @@ static int patch_alc262(struct hda_codec *codec) | |||
11612 | alc262_cfg_tbl); | 11710 | alc262_cfg_tbl); |
11613 | 11711 | ||
11614 | if (board_config < 0) { | 11712 | if (board_config < 0) { |
11615 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 11713 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
11616 | "trying auto-probe from BIOS...\n", codec->chip_name); | 11714 | codec->chip_name); |
11617 | board_config = ALC262_AUTO; | 11715 | board_config = ALC262_AUTO; |
11618 | } | 11716 | } |
11619 | 11717 | ||
@@ -11640,7 +11738,7 @@ static int patch_alc262(struct hda_codec *codec) | |||
11640 | } | 11738 | } |
11641 | 11739 | ||
11642 | if (board_config != ALC262_AUTO) | 11740 | if (board_config != ALC262_AUTO) |
11643 | setup_preset(spec, &alc262_presets[board_config]); | 11741 | setup_preset(codec, &alc262_presets[board_config]); |
11644 | 11742 | ||
11645 | spec->stream_analog_playback = &alc262_pcm_analog_playback; | 11743 | spec->stream_analog_playback = &alc262_pcm_analog_playback; |
11646 | spec->stream_analog_capture = &alc262_pcm_analog_capture; | 11744 | spec->stream_analog_capture = &alc262_pcm_analog_capture; |
@@ -11666,7 +11764,7 @@ static int patch_alc262(struct hda_codec *codec) | |||
11666 | unsigned int wcap = get_wcaps(codec, 0x07); | 11764 | unsigned int wcap = get_wcaps(codec, 0x07); |
11667 | 11765 | ||
11668 | /* get type */ | 11766 | /* get type */ |
11669 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 11767 | wcap = get_wcaps_type(wcap); |
11670 | if (wcap != AC_WID_AUD_IN) { | 11768 | if (wcap != AC_WID_AUD_IN) { |
11671 | spec->adc_nids = alc262_adc_nids_alt; | 11769 | spec->adc_nids = alc262_adc_nids_alt; |
11672 | spec->num_adc_nids = | 11770 | spec->num_adc_nids = |
@@ -11681,7 +11779,7 @@ static int patch_alc262(struct hda_codec *codec) | |||
11681 | } | 11779 | } |
11682 | } | 11780 | } |
11683 | if (!spec->cap_mixer && !spec->no_analog) | 11781 | if (!spec->cap_mixer && !spec->no_analog) |
11684 | set_capture_mixer(spec); | 11782 | set_capture_mixer(codec); |
11685 | if (!spec->no_analog) | 11783 | if (!spec->no_analog) |
11686 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 11784 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
11687 | 11785 | ||
@@ -11773,14 +11871,6 @@ static struct hda_verb alc268_toshiba_verbs[] = { | |||
11773 | { } /* end */ | 11871 | { } /* end */ |
11774 | }; | 11872 | }; |
11775 | 11873 | ||
11776 | static struct hda_input_mux alc268_acer_lc_capture_source = { | ||
11777 | .num_items = 2, | ||
11778 | .items = { | ||
11779 | { "i-Mic", 0x6 }, | ||
11780 | { "E-Mic", 0x0 }, | ||
11781 | }, | ||
11782 | }; | ||
11783 | |||
11784 | /* Acer specific */ | 11874 | /* Acer specific */ |
11785 | /* bind volumes of both NID 0x02 and 0x03 */ | 11875 | /* bind volumes of both NID 0x02 and 0x03 */ |
11786 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { | 11876 | static struct hda_bind_ctls alc268_acer_bind_master_vol = { |
@@ -11822,12 +11912,7 @@ static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol, | |||
11822 | long *valp = ucontrol->value.integer.value; | 11912 | long *valp = ucontrol->value.integer.value; |
11823 | int change; | 11913 | int change; |
11824 | 11914 | ||
11825 | change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, | 11915 | change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp); |
11826 | HDA_AMP_MUTE, | ||
11827 | valp[0] ? 0 : HDA_AMP_MUTE); | ||
11828 | change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, | ||
11829 | HDA_AMP_MUTE, | ||
11830 | valp[1] ? 0 : HDA_AMP_MUTE); | ||
11831 | if (change) | 11916 | if (change) |
11832 | alc268_acer_automute(codec, 0); | 11917 | alc268_acer_automute(codec, 0); |
11833 | return change; | 11918 | return change; |
@@ -11904,7 +11989,8 @@ static struct hda_verb alc268_acer_verbs[] = { | |||
11904 | 11989 | ||
11905 | /* unsolicited event for HP jack sensing */ | 11990 | /* unsolicited event for HP jack sensing */ |
11906 | #define alc268_toshiba_unsol_event alc262_hippo_unsol_event | 11991 | #define alc268_toshiba_unsol_event alc262_hippo_unsol_event |
11907 | #define alc268_toshiba_init_hook alc262_hippo_init_hook | 11992 | #define alc268_toshiba_setup alc262_hippo_setup |
11993 | #define alc268_toshiba_automute alc262_hippo_automute | ||
11908 | 11994 | ||
11909 | static void alc268_acer_unsol_event(struct hda_codec *codec, | 11995 | static void alc268_acer_unsol_event(struct hda_codec *codec, |
11910 | unsigned int res) | 11996 | unsigned int res) |
@@ -11934,30 +12020,33 @@ static void alc268_aspire_one_speaker_automute(struct hda_codec *codec) | |||
11934 | AMP_IN_MUTE(0), bits); | 12020 | AMP_IN_MUTE(0), bits); |
11935 | } | 12021 | } |
11936 | 12022 | ||
11937 | |||
11938 | static void alc268_acer_mic_automute(struct hda_codec *codec) | ||
11939 | { | ||
11940 | unsigned int present; | ||
11941 | |||
11942 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
11943 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
11944 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL, | ||
11945 | present ? 0x0 : 0x6); | ||
11946 | } | ||
11947 | |||
11948 | static void alc268_acer_lc_unsol_event(struct hda_codec *codec, | 12023 | static void alc268_acer_lc_unsol_event(struct hda_codec *codec, |
11949 | unsigned int res) | 12024 | unsigned int res) |
11950 | { | 12025 | { |
11951 | if ((res >> 26) == ALC880_HP_EVENT) | 12026 | switch (res >> 26) { |
12027 | case ALC880_HP_EVENT: | ||
11952 | alc268_aspire_one_speaker_automute(codec); | 12028 | alc268_aspire_one_speaker_automute(codec); |
11953 | if ((res >> 26) == ALC880_MIC_EVENT) | 12029 | break; |
11954 | alc268_acer_mic_automute(codec); | 12030 | case ALC880_MIC_EVENT: |
12031 | alc_mic_automute(codec); | ||
12032 | break; | ||
12033 | } | ||
12034 | } | ||
12035 | |||
12036 | static void alc268_acer_lc_setup(struct hda_codec *codec) | ||
12037 | { | ||
12038 | struct alc_spec *spec = codec->spec; | ||
12039 | spec->ext_mic.pin = 0x18; | ||
12040 | spec->ext_mic.mux_idx = 0; | ||
12041 | spec->int_mic.pin = 0x12; | ||
12042 | spec->int_mic.mux_idx = 6; | ||
12043 | spec->auto_mic = 1; | ||
11955 | } | 12044 | } |
11956 | 12045 | ||
11957 | static void alc268_acer_lc_init_hook(struct hda_codec *codec) | 12046 | static void alc268_acer_lc_init_hook(struct hda_codec *codec) |
11958 | { | 12047 | { |
11959 | alc268_aspire_one_speaker_automute(codec); | 12048 | alc268_aspire_one_speaker_automute(codec); |
11960 | alc268_acer_mic_automute(codec); | 12049 | alc_mic_automute(codec); |
11961 | } | 12050 | } |
11962 | 12051 | ||
11963 | static struct snd_kcontrol_new alc268_dell_mixer[] = { | 12052 | static struct snd_kcontrol_new alc268_dell_mixer[] = { |
@@ -11975,17 +12064,22 @@ static struct hda_verb alc268_dell_verbs[] = { | |||
11975 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | 12064 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
11976 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | 12065 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
11977 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | 12066 | {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, |
12067 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, | ||
11978 | { } | 12068 | { } |
11979 | }; | 12069 | }; |
11980 | 12070 | ||
11981 | /* mute/unmute internal speaker according to the hp jack and mute state */ | 12071 | /* mute/unmute internal speaker according to the hp jack and mute state */ |
11982 | static void alc268_dell_init_hook(struct hda_codec *codec) | 12072 | static void alc268_dell_setup(struct hda_codec *codec) |
11983 | { | 12073 | { |
11984 | struct alc_spec *spec = codec->spec; | 12074 | struct alc_spec *spec = codec->spec; |
11985 | 12075 | ||
11986 | spec->autocfg.hp_pins[0] = 0x15; | 12076 | spec->autocfg.hp_pins[0] = 0x15; |
11987 | spec->autocfg.speaker_pins[0] = 0x14; | 12077 | spec->autocfg.speaker_pins[0] = 0x14; |
11988 | alc_automute_pin(codec); | 12078 | spec->ext_mic.pin = 0x18; |
12079 | spec->ext_mic.mux_idx = 0; | ||
12080 | spec->int_mic.pin = 0x19; | ||
12081 | spec->int_mic.mux_idx = 1; | ||
12082 | spec->auto_mic = 1; | ||
11989 | } | 12083 | } |
11990 | 12084 | ||
11991 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { | 12085 | static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = { |
@@ -12006,38 +12100,16 @@ static struct hda_verb alc267_quanta_il1_verbs[] = { | |||
12006 | { } | 12100 | { } |
12007 | }; | 12101 | }; |
12008 | 12102 | ||
12009 | static void alc267_quanta_il1_mic_automute(struct hda_codec *codec) | 12103 | static void alc267_quanta_il1_setup(struct hda_codec *codec) |
12010 | { | ||
12011 | unsigned int present; | ||
12012 | |||
12013 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
12014 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
12015 | snd_hda_codec_write(codec, 0x23, 0, | ||
12016 | AC_VERB_SET_CONNECT_SEL, | ||
12017 | present ? 0x00 : 0x01); | ||
12018 | } | ||
12019 | |||
12020 | static void alc267_quanta_il1_init_hook(struct hda_codec *codec) | ||
12021 | { | 12104 | { |
12022 | struct alc_spec *spec = codec->spec; | 12105 | struct alc_spec *spec = codec->spec; |
12023 | |||
12024 | spec->autocfg.hp_pins[0] = 0x15; | 12106 | spec->autocfg.hp_pins[0] = 0x15; |
12025 | spec->autocfg.speaker_pins[0] = 0x14; | 12107 | spec->autocfg.speaker_pins[0] = 0x14; |
12026 | alc_automute_pin(codec); | 12108 | spec->ext_mic.pin = 0x18; |
12027 | alc267_quanta_il1_mic_automute(codec); | 12109 | spec->ext_mic.mux_idx = 0; |
12028 | } | 12110 | spec->int_mic.pin = 0x19; |
12029 | 12111 | spec->int_mic.mux_idx = 1; | |
12030 | static void alc267_quanta_il1_unsol_event(struct hda_codec *codec, | 12112 | spec->auto_mic = 1; |
12031 | unsigned int res) | ||
12032 | { | ||
12033 | switch (res >> 26) { | ||
12034 | case ALC880_MIC_EVENT: | ||
12035 | alc267_quanta_il1_mic_automute(codec); | ||
12036 | break; | ||
12037 | default: | ||
12038 | alc_sku_unsol_event(codec, res); | ||
12039 | break; | ||
12040 | } | ||
12041 | } | 12113 | } |
12042 | 12114 | ||
12043 | /* | 12115 | /* |
@@ -12117,21 +12189,16 @@ static struct hda_verb alc268_volume_init_verbs[] = { | |||
12117 | { } | 12189 | { } |
12118 | }; | 12190 | }; |
12119 | 12191 | ||
12192 | static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = { | ||
12193 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | ||
12194 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | ||
12195 | { } /* end */ | ||
12196 | }; | ||
12197 | |||
12120 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { | 12198 | static struct snd_kcontrol_new alc268_capture_alt_mixer[] = { |
12121 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), | 12199 | HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT), |
12122 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | 12200 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), |
12123 | { | 12201 | _DEFINE_CAPSRC(1), |
12124 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
12125 | /* The multiple "Capture Source" controls confuse alsamixer | ||
12126 | * So call somewhat different.. | ||
12127 | */ | ||
12128 | /* .name = "Capture Source", */ | ||
12129 | .name = "Input Source", | ||
12130 | .count = 1, | ||
12131 | .info = alc_mux_enum_info, | ||
12132 | .get = alc_mux_enum_get, | ||
12133 | .put = alc_mux_enum_put, | ||
12134 | }, | ||
12135 | { } /* end */ | 12202 | { } /* end */ |
12136 | }; | 12203 | }; |
12137 | 12204 | ||
@@ -12140,18 +12207,7 @@ static struct snd_kcontrol_new alc268_capture_mixer[] = { | |||
12140 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), | 12207 | HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT), |
12141 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), | 12208 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT), |
12142 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), | 12209 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT), |
12143 | { | 12210 | _DEFINE_CAPSRC(2), |
12144 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
12145 | /* The multiple "Capture Source" controls confuse alsamixer | ||
12146 | * So call somewhat different.. | ||
12147 | */ | ||
12148 | /* .name = "Capture Source", */ | ||
12149 | .name = "Input Source", | ||
12150 | .count = 2, | ||
12151 | .info = alc_mux_enum_info, | ||
12152 | .get = alc_mux_enum_get, | ||
12153 | .put = alc_mux_enum_put, | ||
12154 | }, | ||
12155 | { } /* end */ | 12211 | { } /* end */ |
12156 | }; | 12212 | }; |
12157 | 12213 | ||
@@ -12238,26 +12294,38 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, | |||
12238 | const char *ctlname, int idx) | 12294 | const char *ctlname, int idx) |
12239 | { | 12295 | { |
12240 | char name[32]; | 12296 | char name[32]; |
12297 | hda_nid_t dac; | ||
12241 | int err; | 12298 | int err; |
12242 | 12299 | ||
12243 | sprintf(name, "%s Playback Volume", ctlname); | 12300 | sprintf(name, "%s Playback Volume", ctlname); |
12244 | if (nid == 0x14) { | 12301 | switch (nid) { |
12245 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 12302 | case 0x14: |
12246 | HDA_COMPOSE_AMP_VAL(0x02, 3, idx, | 12303 | case 0x16: |
12247 | HDA_OUTPUT)); | 12304 | dac = 0x02; |
12248 | if (err < 0) | 12305 | break; |
12249 | return err; | 12306 | case 0x15: |
12250 | } else if (nid == 0x15) { | 12307 | dac = 0x03; |
12308 | break; | ||
12309 | default: | ||
12310 | return 0; | ||
12311 | } | ||
12312 | if (spec->multiout.dac_nids[0] != dac && | ||
12313 | spec->multiout.dac_nids[1] != dac) { | ||
12251 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 12314 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
12252 | HDA_COMPOSE_AMP_VAL(0x03, 3, idx, | 12315 | HDA_COMPOSE_AMP_VAL(dac, 3, idx, |
12253 | HDA_OUTPUT)); | 12316 | HDA_OUTPUT)); |
12254 | if (err < 0) | 12317 | if (err < 0) |
12255 | return err; | 12318 | return err; |
12256 | } else | 12319 | spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; |
12257 | return -1; | 12320 | } |
12321 | |||
12258 | sprintf(name, "%s Playback Switch", ctlname); | 12322 | sprintf(name, "%s Playback Switch", ctlname); |
12259 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | 12323 | if (nid != 0x16) |
12324 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
12260 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); | 12325 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); |
12326 | else /* mono */ | ||
12327 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | ||
12328 | HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT)); | ||
12261 | if (err < 0) | 12329 | if (err < 0) |
12262 | return err; | 12330 | return err; |
12263 | return 0; | 12331 | return 0; |
@@ -12270,14 +12338,19 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12270 | hda_nid_t nid; | 12338 | hda_nid_t nid; |
12271 | int err; | 12339 | int err; |
12272 | 12340 | ||
12273 | spec->multiout.num_dacs = 2; /* only use one dac */ | ||
12274 | spec->multiout.dac_nids = spec->private_dac_nids; | 12341 | spec->multiout.dac_nids = spec->private_dac_nids; |
12275 | spec->multiout.dac_nids[0] = 2; | ||
12276 | spec->multiout.dac_nids[1] = 3; | ||
12277 | 12342 | ||
12278 | nid = cfg->line_out_pins[0]; | 12343 | nid = cfg->line_out_pins[0]; |
12279 | if (nid) | 12344 | if (nid) { |
12280 | alc268_new_analog_output(spec, nid, "Front", 0); | 12345 | const char *name; |
12346 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
12347 | name = "Speaker"; | ||
12348 | else | ||
12349 | name = "Front"; | ||
12350 | err = alc268_new_analog_output(spec, nid, name, 0); | ||
12351 | if (err < 0) | ||
12352 | return err; | ||
12353 | } | ||
12281 | 12354 | ||
12282 | nid = cfg->speaker_pins[0]; | 12355 | nid = cfg->speaker_pins[0]; |
12283 | if (nid == 0x1d) { | 12356 | if (nid == 0x1d) { |
@@ -12286,16 +12359,23 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12286 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); | 12359 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
12287 | if (err < 0) | 12360 | if (err < 0) |
12288 | return err; | 12361 | return err; |
12362 | } else { | ||
12363 | err = alc268_new_analog_output(spec, nid, "Speaker", 0); | ||
12364 | if (err < 0) | ||
12365 | return err; | ||
12289 | } | 12366 | } |
12290 | nid = cfg->hp_pins[0]; | 12367 | nid = cfg->hp_pins[0]; |
12291 | if (nid) | 12368 | if (nid) { |
12292 | alc268_new_analog_output(spec, nid, "Headphone", 0); | 12369 | err = alc268_new_analog_output(spec, nid, "Headphone", 0); |
12370 | if (err < 0) | ||
12371 | return err; | ||
12372 | } | ||
12293 | 12373 | ||
12294 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; | 12374 | nid = cfg->line_out_pins[1] | cfg->line_out_pins[2]; |
12295 | if (nid == 0x16) { | 12375 | if (nid == 0x16) { |
12296 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 12376 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, |
12297 | "Mono Playback Switch", | 12377 | "Mono Playback Switch", |
12298 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT)); | 12378 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT)); |
12299 | if (err < 0) | 12379 | if (err < 0) |
12300 | return err; | 12380 | return err; |
12301 | } | 12381 | } |
@@ -12303,38 +12383,46 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
12303 | } | 12383 | } |
12304 | 12384 | ||
12305 | /* create playback/capture controls for input pins */ | 12385 | /* create playback/capture controls for input pins */ |
12306 | static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, | 12386 | static int alc268_auto_create_input_ctls(struct hda_codec *codec, |
12307 | const struct auto_pin_cfg *cfg) | 12387 | const struct auto_pin_cfg *cfg) |
12308 | { | 12388 | { |
12309 | struct hda_input_mux *imux = &spec->private_imux[0]; | 12389 | return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24); |
12310 | int i, idx1; | 12390 | } |
12311 | 12391 | ||
12312 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 12392 | static void alc268_auto_set_output_and_unmute(struct hda_codec *codec, |
12313 | switch(cfg->input_pins[i]) { | 12393 | hda_nid_t nid, int pin_type) |
12314 | case 0x18: | 12394 | { |
12315 | idx1 = 0; /* Mic 1 */ | 12395 | int idx; |
12316 | break; | 12396 | |
12317 | case 0x19: | 12397 | alc_set_pin_output(codec, nid, pin_type); |
12318 | idx1 = 1; /* Mic 2 */ | 12398 | if (nid == 0x14 || nid == 0x16) |
12319 | break; | 12399 | idx = 0; |
12320 | case 0x1a: | 12400 | else |
12321 | idx1 = 2; /* Line In */ | 12401 | idx = 1; |
12322 | break; | 12402 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); |
12323 | case 0x1c: | 12403 | } |
12324 | idx1 = 3; /* CD */ | 12404 | |
12325 | break; | 12405 | static void alc268_auto_init_multi_out(struct hda_codec *codec) |
12326 | case 0x12: | 12406 | { |
12327 | case 0x13: | 12407 | struct alc_spec *spec = codec->spec; |
12328 | idx1 = 6; /* digital mics */ | 12408 | hda_nid_t nid = spec->autocfg.line_out_pins[0]; |
12329 | break; | 12409 | if (nid) { |
12330 | default: | 12410 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
12331 | continue; | 12411 | alc268_auto_set_output_and_unmute(codec, nid, pin_type); |
12332 | } | ||
12333 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | ||
12334 | imux->items[imux->num_items].index = idx1; | ||
12335 | imux->num_items++; | ||
12336 | } | 12412 | } |
12337 | return 0; | 12413 | } |
12414 | |||
12415 | static void alc268_auto_init_hp_out(struct hda_codec *codec) | ||
12416 | { | ||
12417 | struct alc_spec *spec = codec->spec; | ||
12418 | hda_nid_t pin; | ||
12419 | |||
12420 | pin = spec->autocfg.hp_pins[0]; | ||
12421 | if (pin) | ||
12422 | alc268_auto_set_output_and_unmute(codec, pin, PIN_HP); | ||
12423 | pin = spec->autocfg.speaker_pins[0]; | ||
12424 | if (pin) | ||
12425 | alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT); | ||
12338 | } | 12426 | } |
12339 | 12427 | ||
12340 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | 12428 | static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) |
@@ -12345,9 +12433,10 @@ static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |||
12345 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; | 12433 | hda_nid_t line_nid = spec->autocfg.line_out_pins[0]; |
12346 | unsigned int dac_vol1, dac_vol2; | 12434 | unsigned int dac_vol1, dac_vol2; |
12347 | 12435 | ||
12348 | if (speaker_nid) { | 12436 | if (line_nid == 0x1d || speaker_nid == 0x1d) { |
12349 | snd_hda_codec_write(codec, speaker_nid, 0, | 12437 | snd_hda_codec_write(codec, speaker_nid, 0, |
12350 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | 12438 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); |
12439 | /* mute mixer inputs from 0x1d */ | ||
12351 | snd_hda_codec_write(codec, 0x0f, 0, | 12440 | snd_hda_codec_write(codec, 0x0f, 0, |
12352 | AC_VERB_SET_AMP_GAIN_MUTE, | 12441 | AC_VERB_SET_AMP_GAIN_MUTE, |
12353 | AMP_IN_UNMUTE(1)); | 12442 | AMP_IN_UNMUTE(1)); |
@@ -12355,6 +12444,7 @@ static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) | |||
12355 | AC_VERB_SET_AMP_GAIN_MUTE, | 12444 | AC_VERB_SET_AMP_GAIN_MUTE, |
12356 | AMP_IN_UNMUTE(1)); | 12445 | AMP_IN_UNMUTE(1)); |
12357 | } else { | 12446 | } else { |
12447 | /* unmute mixer inputs from 0x1d */ | ||
12358 | snd_hda_codec_write(codec, 0x0f, 0, | 12448 | snd_hda_codec_write(codec, 0x0f, 0, |
12359 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); | 12449 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)); |
12360 | snd_hda_codec_write(codec, 0x10, 0, | 12450 | snd_hda_codec_write(codec, 0x10, 0, |
@@ -12411,7 +12501,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec) | |||
12411 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); | 12501 | err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); |
12412 | if (err < 0) | 12502 | if (err < 0) |
12413 | return err; | 12503 | return err; |
12414 | err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg); | 12504 | err = alc268_auto_create_input_ctls(codec, &spec->autocfg); |
12415 | if (err < 0) | 12505 | if (err < 0) |
12416 | return err; | 12506 | return err; |
12417 | 12507 | ||
@@ -12430,18 +12520,18 @@ static int alc268_parse_auto_config(struct hda_codec *codec) | |||
12430 | add_mixer(spec, alc268_beep_mixer); | 12520 | add_mixer(spec, alc268_beep_mixer); |
12431 | 12521 | ||
12432 | add_verb(spec, alc268_volume_init_verbs); | 12522 | add_verb(spec, alc268_volume_init_verbs); |
12433 | spec->num_mux_defs = 1; | 12523 | spec->num_mux_defs = 2; |
12434 | spec->input_mux = &spec->private_imux[0]; | 12524 | spec->input_mux = &spec->private_imux[0]; |
12435 | 12525 | ||
12436 | err = alc_auto_add_mic_boost(codec); | 12526 | err = alc_auto_add_mic_boost(codec); |
12437 | if (err < 0) | 12527 | if (err < 0) |
12438 | return err; | 12528 | return err; |
12439 | 12529 | ||
12530 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | ||
12531 | |||
12440 | return 1; | 12532 | return 1; |
12441 | } | 12533 | } |
12442 | 12534 | ||
12443 | #define alc268_auto_init_multi_out alc882_auto_init_multi_out | ||
12444 | #define alc268_auto_init_hp_out alc882_auto_init_hp_out | ||
12445 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input | 12535 | #define alc268_auto_init_analog_input alc882_auto_init_analog_input |
12446 | 12536 | ||
12447 | /* init callback for auto-configuration model -- overriding the default init */ | 12537 | /* init callback for auto-configuration model -- overriding the default init */ |
@@ -12484,12 +12574,13 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = { | |||
12484 | ALC268_ACER_ASPIRE_ONE), | 12574 | ALC268_ACER_ASPIRE_ONE), |
12485 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), | 12575 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
12486 | SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), | 12576 | SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), |
12577 | /* almost compatible with toshiba but with optional digital outs; | ||
12578 | * auto-probing seems working fine | ||
12579 | */ | ||
12487 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series", | 12580 | SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series", |
12488 | ALC268_TOSHIBA), | 12581 | ALC268_AUTO), |
12489 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), | 12582 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
12490 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), | 12583 | SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), |
12491 | SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05", | ||
12492 | ALC268_TOSHIBA), | ||
12493 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), | 12584 | SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), |
12494 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), | 12585 | SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), |
12495 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), | 12586 | SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), |
@@ -12497,9 +12588,19 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = { | |||
12497 | {} | 12588 | {} |
12498 | }; | 12589 | }; |
12499 | 12590 | ||
12591 | /* Toshiba laptops have no unique PCI SSID but only codec SSID */ | ||
12592 | static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = { | ||
12593 | SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO), | ||
12594 | SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO), | ||
12595 | SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05", | ||
12596 | ALC268_TOSHIBA), | ||
12597 | {} | ||
12598 | }; | ||
12599 | |||
12500 | static struct alc_config_preset alc268_presets[] = { | 12600 | static struct alc_config_preset alc268_presets[] = { |
12501 | [ALC267_QUANTA_IL1] = { | 12601 | [ALC267_QUANTA_IL1] = { |
12502 | .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer }, | 12602 | .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer, |
12603 | alc268_capture_nosrc_mixer }, | ||
12503 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | 12604 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12504 | alc267_quanta_il1_verbs }, | 12605 | alc267_quanta_il1_verbs }, |
12505 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | 12606 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
@@ -12509,9 +12610,9 @@ static struct alc_config_preset alc268_presets[] = { | |||
12509 | .hp_nid = 0x03, | 12610 | .hp_nid = 0x03, |
12510 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | 12611 | .num_channel_mode = ARRAY_SIZE(alc268_modes), |
12511 | .channel_mode = alc268_modes, | 12612 | .channel_mode = alc268_modes, |
12512 | .input_mux = &alc268_capture_source, | 12613 | .unsol_event = alc_sku_unsol_event, |
12513 | .unsol_event = alc267_quanta_il1_unsol_event, | 12614 | .setup = alc267_quanta_il1_setup, |
12514 | .init_hook = alc267_quanta_il1_init_hook, | 12615 | .init_hook = alc_inithook, |
12515 | }, | 12616 | }, |
12516 | [ALC268_3ST] = { | 12617 | [ALC268_3ST] = { |
12517 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, | 12618 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
@@ -12543,10 +12644,11 @@ static struct alc_config_preset alc268_presets[] = { | |||
12543 | .channel_mode = alc268_modes, | 12644 | .channel_mode = alc268_modes, |
12544 | .input_mux = &alc268_capture_source, | 12645 | .input_mux = &alc268_capture_source, |
12545 | .unsol_event = alc268_toshiba_unsol_event, | 12646 | .unsol_event = alc268_toshiba_unsol_event, |
12546 | .init_hook = alc268_toshiba_init_hook, | 12647 | .setup = alc268_toshiba_setup, |
12648 | .init_hook = alc268_toshiba_automute, | ||
12547 | }, | 12649 | }, |
12548 | [ALC268_ACER] = { | 12650 | [ALC268_ACER] = { |
12549 | .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer, | 12651 | .mixers = { alc268_acer_mixer, alc268_capture_nosrc_mixer, |
12550 | alc268_beep_mixer }, | 12652 | alc268_beep_mixer }, |
12551 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | 12653 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12552 | alc268_acer_verbs }, | 12654 | alc268_acer_verbs }, |
@@ -12582,7 +12684,7 @@ static struct alc_config_preset alc268_presets[] = { | |||
12582 | [ALC268_ACER_ASPIRE_ONE] = { | 12684 | [ALC268_ACER_ASPIRE_ONE] = { |
12583 | .mixers = { alc268_acer_aspire_one_mixer, | 12685 | .mixers = { alc268_acer_aspire_one_mixer, |
12584 | alc268_beep_mixer, | 12686 | alc268_beep_mixer, |
12585 | alc268_capture_alt_mixer }, | 12687 | alc268_capture_nosrc_mixer }, |
12586 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | 12688 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12587 | alc268_acer_aspire_one_verbs }, | 12689 | alc268_acer_aspire_one_verbs }, |
12588 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | 12690 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
@@ -12593,22 +12695,26 @@ static struct alc_config_preset alc268_presets[] = { | |||
12593 | .hp_nid = 0x03, | 12695 | .hp_nid = 0x03, |
12594 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | 12696 | .num_channel_mode = ARRAY_SIZE(alc268_modes), |
12595 | .channel_mode = alc268_modes, | 12697 | .channel_mode = alc268_modes, |
12596 | .input_mux = &alc268_acer_lc_capture_source, | ||
12597 | .unsol_event = alc268_acer_lc_unsol_event, | 12698 | .unsol_event = alc268_acer_lc_unsol_event, |
12699 | .setup = alc268_acer_lc_setup, | ||
12598 | .init_hook = alc268_acer_lc_init_hook, | 12700 | .init_hook = alc268_acer_lc_init_hook, |
12599 | }, | 12701 | }, |
12600 | [ALC268_DELL] = { | 12702 | [ALC268_DELL] = { |
12601 | .mixers = { alc268_dell_mixer, alc268_beep_mixer }, | 12703 | .mixers = { alc268_dell_mixer, alc268_beep_mixer, |
12704 | alc268_capture_nosrc_mixer }, | ||
12602 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, | 12705 | .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, |
12603 | alc268_dell_verbs }, | 12706 | alc268_dell_verbs }, |
12604 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), | 12707 | .num_dacs = ARRAY_SIZE(alc268_dac_nids), |
12605 | .dac_nids = alc268_dac_nids, | 12708 | .dac_nids = alc268_dac_nids, |
12709 | .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt), | ||
12710 | .adc_nids = alc268_adc_nids_alt, | ||
12711 | .capsrc_nids = alc268_capsrc_nids, | ||
12606 | .hp_nid = 0x02, | 12712 | .hp_nid = 0x02, |
12607 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | 12713 | .num_channel_mode = ARRAY_SIZE(alc268_modes), |
12608 | .channel_mode = alc268_modes, | 12714 | .channel_mode = alc268_modes, |
12609 | .unsol_event = alc_sku_unsol_event, | 12715 | .unsol_event = alc_sku_unsol_event, |
12610 | .init_hook = alc268_dell_init_hook, | 12716 | .setup = alc268_dell_setup, |
12611 | .input_mux = &alc268_capture_source, | 12717 | .init_hook = alc_inithook, |
12612 | }, | 12718 | }, |
12613 | [ALC268_ZEPTO] = { | 12719 | [ALC268_ZEPTO] = { |
12614 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, | 12720 | .mixers = { alc268_base_mixer, alc268_capture_alt_mixer, |
@@ -12625,8 +12731,8 @@ static struct alc_config_preset alc268_presets[] = { | |||
12625 | .num_channel_mode = ARRAY_SIZE(alc268_modes), | 12731 | .num_channel_mode = ARRAY_SIZE(alc268_modes), |
12626 | .channel_mode = alc268_modes, | 12732 | .channel_mode = alc268_modes, |
12627 | .input_mux = &alc268_capture_source, | 12733 | .input_mux = &alc268_capture_source, |
12628 | .unsol_event = alc268_toshiba_unsol_event, | 12734 | .setup = alc268_toshiba_setup, |
12629 | .init_hook = alc268_toshiba_init_hook | 12735 | .init_hook = alc268_toshiba_automute, |
12630 | }, | 12736 | }, |
12631 | #ifdef CONFIG_SND_DEBUG | 12737 | #ifdef CONFIG_SND_DEBUG |
12632 | [ALC268_TEST] = { | 12738 | [ALC268_TEST] = { |
@@ -12663,9 +12769,13 @@ static int patch_alc268(struct hda_codec *codec) | |||
12663 | alc268_models, | 12769 | alc268_models, |
12664 | alc268_cfg_tbl); | 12770 | alc268_cfg_tbl); |
12665 | 12771 | ||
12772 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) | ||
12773 | board_config = snd_hda_check_board_codec_sid_config(codec, | ||
12774 | ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl); | ||
12775 | |||
12666 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { | 12776 | if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { |
12667 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 12777 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
12668 | "trying auto-probe from BIOS...\n", codec->chip_name); | 12778 | codec->chip_name); |
12669 | board_config = ALC268_AUTO; | 12779 | board_config = ALC268_AUTO; |
12670 | } | 12780 | } |
12671 | 12781 | ||
@@ -12684,7 +12794,7 @@ static int patch_alc268(struct hda_codec *codec) | |||
12684 | } | 12794 | } |
12685 | 12795 | ||
12686 | if (board_config != ALC268_AUTO) | 12796 | if (board_config != ALC268_AUTO) |
12687 | setup_preset(spec, &alc268_presets[board_config]); | 12797 | setup_preset(codec, &alc268_presets[board_config]); |
12688 | 12798 | ||
12689 | spec->stream_analog_playback = &alc268_pcm_analog_playback; | 12799 | spec->stream_analog_playback = &alc268_pcm_analog_playback; |
12690 | spec->stream_analog_capture = &alc268_pcm_analog_capture; | 12800 | spec->stream_analog_capture = &alc268_pcm_analog_capture; |
@@ -12721,11 +12831,15 @@ static int patch_alc268(struct hda_codec *codec) | |||
12721 | int i; | 12831 | int i; |
12722 | 12832 | ||
12723 | /* get type */ | 12833 | /* get type */ |
12724 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 12834 | wcap = get_wcaps_type(wcap); |
12725 | if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { | 12835 | if (spec->auto_mic || |
12836 | wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) { | ||
12726 | spec->adc_nids = alc268_adc_nids_alt; | 12837 | spec->adc_nids = alc268_adc_nids_alt; |
12727 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); | 12838 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt); |
12728 | add_mixer(spec, alc268_capture_alt_mixer); | 12839 | if (spec->auto_mic || spec->input_mux->num_items == 1) |
12840 | add_mixer(spec, alc268_capture_nosrc_mixer); | ||
12841 | else | ||
12842 | add_mixer(spec, alc268_capture_alt_mixer); | ||
12729 | } else { | 12843 | } else { |
12730 | spec->adc_nids = alc268_adc_nids; | 12844 | spec->adc_nids = alc268_adc_nids; |
12731 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); | 12845 | spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids); |
@@ -12736,6 +12850,8 @@ static int patch_alc268(struct hda_codec *codec) | |||
12736 | for (i = 0; i < spec->num_adc_nids; i++) | 12850 | for (i = 0; i < spec->num_adc_nids; i++) |
12737 | snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], | 12851 | snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i], |
12738 | 0, AC_VERB_SET_CONNECT_SEL, | 12852 | 0, AC_VERB_SET_CONNECT_SEL, |
12853 | i < spec->num_mux_defs ? | ||
12854 | spec->input_mux[i].items[0].index : | ||
12739 | spec->input_mux->items[0].index); | 12855 | spec->input_mux->items[0].index); |
12740 | } | 12856 | } |
12741 | 12857 | ||
@@ -12770,22 +12886,6 @@ static hda_nid_t alc269_capsrc_nids[1] = { | |||
12770 | * not a mux! | 12886 | * not a mux! |
12771 | */ | 12887 | */ |
12772 | 12888 | ||
12773 | static struct hda_input_mux alc269_eeepc_dmic_capture_source = { | ||
12774 | .num_items = 2, | ||
12775 | .items = { | ||
12776 | { "i-Mic", 0x5 }, | ||
12777 | { "e-Mic", 0x0 }, | ||
12778 | }, | ||
12779 | }; | ||
12780 | |||
12781 | static struct hda_input_mux alc269_eeepc_amic_capture_source = { | ||
12782 | .num_items = 2, | ||
12783 | .items = { | ||
12784 | { "i-Mic", 0x1 }, | ||
12785 | { "e-Mic", 0x0 }, | ||
12786 | }, | ||
12787 | }; | ||
12788 | |||
12789 | #define alc269_modes alc260_modes | 12889 | #define alc269_modes alc260_modes |
12790 | #define alc269_capture_source alc880_lg_lw_capture_source | 12890 | #define alc269_capture_source alc880_lg_lw_capture_source |
12791 | 12891 | ||
@@ -12848,20 +12948,11 @@ static struct snd_kcontrol_new alc269_lifebook_mixer[] = { | |||
12848 | { } | 12948 | { } |
12849 | }; | 12949 | }; |
12850 | 12950 | ||
12851 | /* bind volumes of both NID 0x0c and 0x0d */ | ||
12852 | static struct hda_bind_ctls alc269_epc_bind_vol = { | ||
12853 | .ops = &snd_hda_bind_vol, | ||
12854 | .values = { | ||
12855 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), | ||
12856 | HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT), | ||
12857 | 0 | ||
12858 | }, | ||
12859 | }; | ||
12860 | |||
12861 | static struct snd_kcontrol_new alc269_eeepc_mixer[] = { | 12951 | static struct snd_kcontrol_new alc269_eeepc_mixer[] = { |
12862 | HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 12952 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
12863 | HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol), | 12953 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
12864 | HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT), | 12954 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
12955 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | ||
12865 | { } /* end */ | 12956 | { } /* end */ |
12866 | }; | 12957 | }; |
12867 | 12958 | ||
@@ -12874,12 +12965,7 @@ static struct snd_kcontrol_new alc269_epc_capture_mixer[] = { | |||
12874 | }; | 12965 | }; |
12875 | 12966 | ||
12876 | /* FSC amilo */ | 12967 | /* FSC amilo */ |
12877 | static struct snd_kcontrol_new alc269_fujitsu_mixer[] = { | 12968 | #define alc269_fujitsu_mixer alc269_eeepc_mixer |
12878 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | ||
12879 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | ||
12880 | HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol), | ||
12881 | { } /* end */ | ||
12882 | }; | ||
12883 | 12969 | ||
12884 | static struct hda_verb alc269_quanta_fl1_verbs[] = { | 12970 | static struct hda_verb alc269_quanta_fl1_verbs[] = { |
12885 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | 12971 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
@@ -12961,16 +13047,6 @@ static void alc269_lifebook_speaker_automute(struct hda_codec *codec) | |||
12961 | AC_VERB_SET_PROC_COEF, 0x480); | 13047 | AC_VERB_SET_PROC_COEF, 0x480); |
12962 | } | 13048 | } |
12963 | 13049 | ||
12964 | static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec) | ||
12965 | { | ||
12966 | unsigned int present; | ||
12967 | |||
12968 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
12969 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
12970 | snd_hda_codec_write(codec, 0x23, 0, | ||
12971 | AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1); | ||
12972 | } | ||
12973 | |||
12974 | static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) | 13050 | static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) |
12975 | { | 13051 | { |
12976 | unsigned int present_laptop; | 13052 | unsigned int present_laptop; |
@@ -12997,10 +13073,14 @@ static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec) | |||
12997 | static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, | 13073 | static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec, |
12998 | unsigned int res) | 13074 | unsigned int res) |
12999 | { | 13075 | { |
13000 | if ((res >> 26) == ALC880_HP_EVENT) | 13076 | switch (res >> 26) { |
13077 | case ALC880_HP_EVENT: | ||
13001 | alc269_quanta_fl1_speaker_automute(codec); | 13078 | alc269_quanta_fl1_speaker_automute(codec); |
13002 | if ((res >> 26) == ALC880_MIC_EVENT) | 13079 | break; |
13003 | alc269_quanta_fl1_mic_automute(codec); | 13080 | case ALC880_MIC_EVENT: |
13081 | alc_mic_automute(codec); | ||
13082 | break; | ||
13083 | } | ||
13004 | } | 13084 | } |
13005 | 13085 | ||
13006 | static void alc269_lifebook_unsol_event(struct hda_codec *codec, | 13086 | static void alc269_lifebook_unsol_event(struct hda_codec *codec, |
@@ -13012,10 +13092,20 @@ static void alc269_lifebook_unsol_event(struct hda_codec *codec, | |||
13012 | alc269_lifebook_mic_autoswitch(codec); | 13092 | alc269_lifebook_mic_autoswitch(codec); |
13013 | } | 13093 | } |
13014 | 13094 | ||
13095 | static void alc269_quanta_fl1_setup(struct hda_codec *codec) | ||
13096 | { | ||
13097 | struct alc_spec *spec = codec->spec; | ||
13098 | spec->ext_mic.pin = 0x18; | ||
13099 | spec->ext_mic.mux_idx = 0; | ||
13100 | spec->int_mic.pin = 0x19; | ||
13101 | spec->int_mic.mux_idx = 1; | ||
13102 | spec->auto_mic = 1; | ||
13103 | } | ||
13104 | |||
13015 | static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) | 13105 | static void alc269_quanta_fl1_init_hook(struct hda_codec *codec) |
13016 | { | 13106 | { |
13017 | alc269_quanta_fl1_speaker_automute(codec); | 13107 | alc269_quanta_fl1_speaker_automute(codec); |
13018 | alc269_quanta_fl1_mic_automute(codec); | 13108 | alc_mic_automute(codec); |
13019 | } | 13109 | } |
13020 | 13110 | ||
13021 | static void alc269_lifebook_init_hook(struct hda_codec *codec) | 13111 | static void alc269_lifebook_init_hook(struct hda_codec *codec) |
@@ -13060,60 +13150,44 @@ static void alc269_speaker_automute(struct hda_codec *codec) | |||
13060 | AMP_IN_MUTE(0), bits); | 13150 | AMP_IN_MUTE(0), bits); |
13061 | } | 13151 | } |
13062 | 13152 | ||
13063 | static void alc269_eeepc_dmic_automute(struct hda_codec *codec) | ||
13064 | { | ||
13065 | unsigned int present; | ||
13066 | |||
13067 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
13068 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13069 | snd_hda_codec_write(codec, 0x23, 0, | ||
13070 | AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5)); | ||
13071 | } | ||
13072 | |||
13073 | static void alc269_eeepc_amic_automute(struct hda_codec *codec) | ||
13074 | { | ||
13075 | unsigned int present; | ||
13076 | |||
13077 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
13078 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
13079 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
13080 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
13081 | snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
13082 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | ||
13083 | } | ||
13084 | |||
13085 | /* unsolicited event for HP jack sensing */ | 13153 | /* unsolicited event for HP jack sensing */ |
13086 | static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec, | 13154 | static void alc269_eeepc_unsol_event(struct hda_codec *codec, |
13087 | unsigned int res) | 13155 | unsigned int res) |
13088 | { | 13156 | { |
13089 | if ((res >> 26) == ALC880_HP_EVENT) | 13157 | switch (res >> 26) { |
13158 | case ALC880_HP_EVENT: | ||
13090 | alc269_speaker_automute(codec); | 13159 | alc269_speaker_automute(codec); |
13091 | 13160 | break; | |
13092 | if ((res >> 26) == ALC880_MIC_EVENT) | 13161 | case ALC880_MIC_EVENT: |
13093 | alc269_eeepc_dmic_automute(codec); | 13162 | alc_mic_automute(codec); |
13163 | break; | ||
13164 | } | ||
13094 | } | 13165 | } |
13095 | 13166 | ||
13096 | static void alc269_eeepc_dmic_inithook(struct hda_codec *codec) | 13167 | static void alc269_eeepc_dmic_setup(struct hda_codec *codec) |
13097 | { | 13168 | { |
13098 | alc269_speaker_automute(codec); | 13169 | struct alc_spec *spec = codec->spec; |
13099 | alc269_eeepc_dmic_automute(codec); | 13170 | spec->ext_mic.pin = 0x18; |
13171 | spec->ext_mic.mux_idx = 0; | ||
13172 | spec->int_mic.pin = 0x12; | ||
13173 | spec->int_mic.mux_idx = 5; | ||
13174 | spec->auto_mic = 1; | ||
13100 | } | 13175 | } |
13101 | 13176 | ||
13102 | /* unsolicited event for HP jack sensing */ | 13177 | static void alc269_eeepc_amic_setup(struct hda_codec *codec) |
13103 | static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec, | ||
13104 | unsigned int res) | ||
13105 | { | 13178 | { |
13106 | if ((res >> 26) == ALC880_HP_EVENT) | 13179 | struct alc_spec *spec = codec->spec; |
13107 | alc269_speaker_automute(codec); | 13180 | spec->ext_mic.pin = 0x18; |
13108 | 13181 | spec->ext_mic.mux_idx = 0; | |
13109 | if ((res >> 26) == ALC880_MIC_EVENT) | 13182 | spec->int_mic.pin = 0x19; |
13110 | alc269_eeepc_amic_automute(codec); | 13183 | spec->int_mic.mux_idx = 1; |
13184 | spec->auto_mic = 1; | ||
13111 | } | 13185 | } |
13112 | 13186 | ||
13113 | static void alc269_eeepc_amic_inithook(struct hda_codec *codec) | 13187 | static void alc269_eeepc_inithook(struct hda_codec *codec) |
13114 | { | 13188 | { |
13115 | alc269_speaker_automute(codec); | 13189 | alc269_speaker_automute(codec); |
13116 | alc269_eeepc_amic_automute(codec); | 13190 | alc_mic_automute(codec); |
13117 | } | 13191 | } |
13118 | 13192 | ||
13119 | /* | 13193 | /* |
@@ -13186,89 +13260,10 @@ static struct hda_verb alc269_init_verbs[] = { | |||
13186 | { } | 13260 | { } |
13187 | }; | 13261 | }; |
13188 | 13262 | ||
13189 | /* add playback controls from the parsed DAC table */ | 13263 | #define alc269_auto_create_multi_out_ctls \ |
13190 | static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, | 13264 | alc268_auto_create_multi_out_ctls |
13191 | const struct auto_pin_cfg *cfg) | 13265 | #define alc269_auto_create_input_ctls \ |
13192 | { | 13266 | alc268_auto_create_input_ctls |
13193 | hda_nid_t nid; | ||
13194 | int err; | ||
13195 | |||
13196 | spec->multiout.num_dacs = 1; /* only use one dac */ | ||
13197 | spec->multiout.dac_nids = spec->private_dac_nids; | ||
13198 | spec->multiout.dac_nids[0] = 2; | ||
13199 | |||
13200 | nid = cfg->line_out_pins[0]; | ||
13201 | if (nid) { | ||
13202 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
13203 | "Front Playback Volume", | ||
13204 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT)); | ||
13205 | if (err < 0) | ||
13206 | return err; | ||
13207 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
13208 | "Front Playback Switch", | ||
13209 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | ||
13210 | if (err < 0) | ||
13211 | return err; | ||
13212 | } | ||
13213 | |||
13214 | nid = cfg->speaker_pins[0]; | ||
13215 | if (nid) { | ||
13216 | if (!cfg->line_out_pins[0]) { | ||
13217 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
13218 | "Speaker Playback Volume", | ||
13219 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | ||
13220 | HDA_OUTPUT)); | ||
13221 | if (err < 0) | ||
13222 | return err; | ||
13223 | } | ||
13224 | if (nid == 0x16) { | ||
13225 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
13226 | "Speaker Playback Switch", | ||
13227 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
13228 | HDA_OUTPUT)); | ||
13229 | if (err < 0) | ||
13230 | return err; | ||
13231 | } else { | ||
13232 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
13233 | "Speaker Playback Switch", | ||
13234 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
13235 | HDA_OUTPUT)); | ||
13236 | if (err < 0) | ||
13237 | return err; | ||
13238 | } | ||
13239 | } | ||
13240 | nid = cfg->hp_pins[0]; | ||
13241 | if (nid) { | ||
13242 | /* spec->multiout.hp_nid = 2; */ | ||
13243 | if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) { | ||
13244 | err = add_control(spec, ALC_CTL_WIDGET_VOL, | ||
13245 | "Headphone Playback Volume", | ||
13246 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, | ||
13247 | HDA_OUTPUT)); | ||
13248 | if (err < 0) | ||
13249 | return err; | ||
13250 | } | ||
13251 | if (nid == 0x16) { | ||
13252 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
13253 | "Headphone Playback Switch", | ||
13254 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
13255 | HDA_OUTPUT)); | ||
13256 | if (err < 0) | ||
13257 | return err; | ||
13258 | } else { | ||
13259 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | ||
13260 | "Headphone Playback Switch", | ||
13261 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
13262 | HDA_OUTPUT)); | ||
13263 | if (err < 0) | ||
13264 | return err; | ||
13265 | } | ||
13266 | } | ||
13267 | return 0; | ||
13268 | } | ||
13269 | |||
13270 | #define alc269_auto_create_analog_input_ctls \ | ||
13271 | alc262_auto_create_analog_input_ctls | ||
13272 | 13267 | ||
13273 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 13268 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
13274 | #define alc269_loopbacks alc880_loopbacks | 13269 | #define alc269_loopbacks alc880_loopbacks |
@@ -13318,7 +13313,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
13318 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); | 13313 | err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); |
13319 | if (err < 0) | 13314 | if (err < 0) |
13320 | return err; | 13315 | return err; |
13321 | err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg); | 13316 | err = alc269_auto_create_input_ctls(codec, &spec->autocfg); |
13322 | if (err < 0) | 13317 | if (err < 0) |
13323 | return err; | 13318 | return err; |
13324 | 13319 | ||
@@ -13343,13 +13338,15 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
13343 | return err; | 13338 | return err; |
13344 | 13339 | ||
13345 | if (!spec->cap_mixer && !spec->no_analog) | 13340 | if (!spec->cap_mixer && !spec->no_analog) |
13346 | set_capture_mixer(spec); | 13341 | set_capture_mixer(codec); |
13342 | |||
13343 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | ||
13347 | 13344 | ||
13348 | return 1; | 13345 | return 1; |
13349 | } | 13346 | } |
13350 | 13347 | ||
13351 | #define alc269_auto_init_multi_out alc882_auto_init_multi_out | 13348 | #define alc269_auto_init_multi_out alc268_auto_init_multi_out |
13352 | #define alc269_auto_init_hp_out alc882_auto_init_hp_out | 13349 | #define alc269_auto_init_hp_out alc268_auto_init_hp_out |
13353 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input | 13350 | #define alc269_auto_init_analog_input alc882_auto_init_analog_input |
13354 | 13351 | ||
13355 | 13352 | ||
@@ -13417,6 +13414,7 @@ static struct alc_config_preset alc269_presets[] = { | |||
13417 | .channel_mode = alc269_modes, | 13414 | .channel_mode = alc269_modes, |
13418 | .input_mux = &alc269_capture_source, | 13415 | .input_mux = &alc269_capture_source, |
13419 | .unsol_event = alc269_quanta_fl1_unsol_event, | 13416 | .unsol_event = alc269_quanta_fl1_unsol_event, |
13417 | .setup = alc269_quanta_fl1_setup, | ||
13420 | .init_hook = alc269_quanta_fl1_init_hook, | 13418 | .init_hook = alc269_quanta_fl1_init_hook, |
13421 | }, | 13419 | }, |
13422 | [ALC269_ASUS_EEEPC_P703] = { | 13420 | [ALC269_ASUS_EEEPC_P703] = { |
@@ -13429,9 +13427,9 @@ static struct alc_config_preset alc269_presets[] = { | |||
13429 | .hp_nid = 0x03, | 13427 | .hp_nid = 0x03, |
13430 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | 13428 | .num_channel_mode = ARRAY_SIZE(alc269_modes), |
13431 | .channel_mode = alc269_modes, | 13429 | .channel_mode = alc269_modes, |
13432 | .input_mux = &alc269_eeepc_amic_capture_source, | 13430 | .unsol_event = alc269_eeepc_unsol_event, |
13433 | .unsol_event = alc269_eeepc_amic_unsol_event, | 13431 | .setup = alc269_eeepc_amic_setup, |
13434 | .init_hook = alc269_eeepc_amic_inithook, | 13432 | .init_hook = alc269_eeepc_inithook, |
13435 | }, | 13433 | }, |
13436 | [ALC269_ASUS_EEEPC_P901] = { | 13434 | [ALC269_ASUS_EEEPC_P901] = { |
13437 | .mixers = { alc269_eeepc_mixer }, | 13435 | .mixers = { alc269_eeepc_mixer }, |
@@ -13443,9 +13441,9 @@ static struct alc_config_preset alc269_presets[] = { | |||
13443 | .hp_nid = 0x03, | 13441 | .hp_nid = 0x03, |
13444 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | 13442 | .num_channel_mode = ARRAY_SIZE(alc269_modes), |
13445 | .channel_mode = alc269_modes, | 13443 | .channel_mode = alc269_modes, |
13446 | .input_mux = &alc269_eeepc_dmic_capture_source, | 13444 | .unsol_event = alc269_eeepc_unsol_event, |
13447 | .unsol_event = alc269_eeepc_dmic_unsol_event, | 13445 | .setup = alc269_eeepc_dmic_setup, |
13448 | .init_hook = alc269_eeepc_dmic_inithook, | 13446 | .init_hook = alc269_eeepc_inithook, |
13449 | }, | 13447 | }, |
13450 | [ALC269_FUJITSU] = { | 13448 | [ALC269_FUJITSU] = { |
13451 | .mixers = { alc269_fujitsu_mixer }, | 13449 | .mixers = { alc269_fujitsu_mixer }, |
@@ -13457,9 +13455,9 @@ static struct alc_config_preset alc269_presets[] = { | |||
13457 | .hp_nid = 0x03, | 13455 | .hp_nid = 0x03, |
13458 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | 13456 | .num_channel_mode = ARRAY_SIZE(alc269_modes), |
13459 | .channel_mode = alc269_modes, | 13457 | .channel_mode = alc269_modes, |
13460 | .input_mux = &alc269_eeepc_dmic_capture_source, | 13458 | .unsol_event = alc269_eeepc_unsol_event, |
13461 | .unsol_event = alc269_eeepc_dmic_unsol_event, | 13459 | .setup = alc269_eeepc_dmic_setup, |
13462 | .init_hook = alc269_eeepc_dmic_inithook, | 13460 | .init_hook = alc269_eeepc_inithook, |
13463 | }, | 13461 | }, |
13464 | [ALC269_LIFEBOOK] = { | 13462 | [ALC269_LIFEBOOK] = { |
13465 | .mixers = { alc269_lifebook_mixer }, | 13463 | .mixers = { alc269_lifebook_mixer }, |
@@ -13494,8 +13492,8 @@ static int patch_alc269(struct hda_codec *codec) | |||
13494 | alc269_cfg_tbl); | 13492 | alc269_cfg_tbl); |
13495 | 13493 | ||
13496 | if (board_config < 0) { | 13494 | if (board_config < 0) { |
13497 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 13495 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
13498 | "trying auto-probe from BIOS...\n", codec->chip_name); | 13496 | codec->chip_name); |
13499 | board_config = ALC269_AUTO; | 13497 | board_config = ALC269_AUTO; |
13500 | } | 13498 | } |
13501 | 13499 | ||
@@ -13520,7 +13518,7 @@ static int patch_alc269(struct hda_codec *codec) | |||
13520 | } | 13518 | } |
13521 | 13519 | ||
13522 | if (board_config != ALC269_AUTO) | 13520 | if (board_config != ALC269_AUTO) |
13523 | setup_preset(spec, &alc269_presets[board_config]); | 13521 | setup_preset(codec, &alc269_presets[board_config]); |
13524 | 13522 | ||
13525 | if (codec->subsystem_id == 0x17aa3bf8) { | 13523 | if (codec->subsystem_id == 0x17aa3bf8) { |
13526 | /* Due to a hardware problem on Lenovo Ideadpad, we need to | 13524 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
@@ -13539,9 +13537,11 @@ static int patch_alc269(struct hda_codec *codec) | |||
13539 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); | 13537 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); |
13540 | spec->capsrc_nids = alc269_capsrc_nids; | 13538 | spec->capsrc_nids = alc269_capsrc_nids; |
13541 | if (!spec->cap_mixer) | 13539 | if (!spec->cap_mixer) |
13542 | set_capture_mixer(spec); | 13540 | set_capture_mixer(codec); |
13543 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); | 13541 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
13544 | 13542 | ||
13543 | spec->vmaster_nid = 0x02; | ||
13544 | |||
13545 | codec->patch_ops = alc_patch_ops; | 13545 | codec->patch_ops = alc_patch_ops; |
13546 | if (board_config == ALC269_AUTO) | 13546 | if (board_config == ALC269_AUTO) |
13547 | spec->init_hook = alc269_auto_init; | 13547 | spec->init_hook = alc269_auto_init; |
@@ -14087,23 +14087,23 @@ static struct hda_verb alc861_auto_init_verbs[] = { | |||
14087 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | 14087 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, |
14088 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, | 14088 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, |
14089 | 14089 | ||
14090 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 14090 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14091 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 14091 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14092 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 14092 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14093 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 14093 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14094 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 14094 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14095 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 14095 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14096 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 14096 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14097 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 14097 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14098 | 14098 | ||
14099 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 14099 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14100 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 14100 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14101 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | 14101 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
14102 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | 14102 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
14103 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 14103 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
14104 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 14104 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
14105 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | 14105 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, |
14106 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | 14106 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, |
14107 | 14107 | ||
14108 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ | 14108 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */ |
14109 | 14109 | ||
@@ -14175,64 +14175,96 @@ static struct hda_input_mux alc861_capture_source = { | |||
14175 | }, | 14175 | }, |
14176 | }; | 14176 | }; |
14177 | 14177 | ||
14178 | static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin) | ||
14179 | { | ||
14180 | struct alc_spec *spec = codec->spec; | ||
14181 | hda_nid_t mix, srcs[5]; | ||
14182 | int i, j, num; | ||
14183 | |||
14184 | if (snd_hda_get_connections(codec, pin, &mix, 1) != 1) | ||
14185 | return 0; | ||
14186 | num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs)); | ||
14187 | if (num < 0) | ||
14188 | return 0; | ||
14189 | for (i = 0; i < num; i++) { | ||
14190 | unsigned int type; | ||
14191 | type = get_wcaps_type(get_wcaps(codec, srcs[i])); | ||
14192 | if (type != AC_WID_AUD_OUT) | ||
14193 | continue; | ||
14194 | for (j = 0; j < spec->multiout.num_dacs; j++) | ||
14195 | if (spec->multiout.dac_nids[j] == srcs[i]) | ||
14196 | break; | ||
14197 | if (j >= spec->multiout.num_dacs) | ||
14198 | return srcs[i]; | ||
14199 | } | ||
14200 | return 0; | ||
14201 | } | ||
14202 | |||
14178 | /* fill in the dac_nids table from the parsed pin configuration */ | 14203 | /* fill in the dac_nids table from the parsed pin configuration */ |
14179 | static int alc861_auto_fill_dac_nids(struct alc_spec *spec, | 14204 | static int alc861_auto_fill_dac_nids(struct hda_codec *codec, |
14180 | const struct auto_pin_cfg *cfg) | 14205 | const struct auto_pin_cfg *cfg) |
14181 | { | 14206 | { |
14207 | struct alc_spec *spec = codec->spec; | ||
14182 | int i; | 14208 | int i; |
14183 | hda_nid_t nid; | 14209 | hda_nid_t nid, dac; |
14184 | 14210 | ||
14185 | spec->multiout.dac_nids = spec->private_dac_nids; | 14211 | spec->multiout.dac_nids = spec->private_dac_nids; |
14186 | for (i = 0; i < cfg->line_outs; i++) { | 14212 | for (i = 0; i < cfg->line_outs; i++) { |
14187 | nid = cfg->line_out_pins[i]; | 14213 | nid = cfg->line_out_pins[i]; |
14188 | if (nid) { | 14214 | dac = alc861_look_for_dac(codec, nid); |
14189 | if (i >= ARRAY_SIZE(alc861_dac_nids)) | 14215 | if (!dac) |
14190 | continue; | 14216 | continue; |
14191 | spec->multiout.dac_nids[i] = alc861_dac_nids[i]; | 14217 | spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; |
14192 | } | ||
14193 | } | 14218 | } |
14194 | spec->multiout.num_dacs = cfg->line_outs; | ||
14195 | return 0; | 14219 | return 0; |
14196 | } | 14220 | } |
14197 | 14221 | ||
14222 | static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx, | ||
14223 | hda_nid_t nid, unsigned int chs) | ||
14224 | { | ||
14225 | char name[32]; | ||
14226 | snprintf(name, sizeof(name), "%s Playback Switch", pfx); | ||
14227 | return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name, | ||
14228 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | ||
14229 | } | ||
14230 | |||
14198 | /* add playback controls from the parsed DAC table */ | 14231 | /* add playback controls from the parsed DAC table */ |
14199 | static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | 14232 | static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec, |
14200 | const struct auto_pin_cfg *cfg) | 14233 | const struct auto_pin_cfg *cfg) |
14201 | { | 14234 | { |
14202 | char name[32]; | 14235 | struct alc_spec *spec = codec->spec; |
14203 | static const char *chname[4] = { | 14236 | static const char *chname[4] = { |
14204 | "Front", "Surround", NULL /*CLFE*/, "Side" | 14237 | "Front", "Surround", NULL /*CLFE*/, "Side" |
14205 | }; | 14238 | }; |
14206 | hda_nid_t nid; | 14239 | hda_nid_t nid; |
14207 | int i, idx, err; | 14240 | int i, err; |
14241 | |||
14242 | if (cfg->line_outs == 1) { | ||
14243 | const char *pfx = NULL; | ||
14244 | if (!cfg->hp_outs) | ||
14245 | pfx = "Master"; | ||
14246 | else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
14247 | pfx = "Speaker"; | ||
14248 | if (pfx) { | ||
14249 | nid = spec->multiout.dac_nids[0]; | ||
14250 | return alc861_create_out_sw(codec, pfx, nid, 3); | ||
14251 | } | ||
14252 | } | ||
14208 | 14253 | ||
14209 | for (i = 0; i < cfg->line_outs; i++) { | 14254 | for (i = 0; i < cfg->line_outs; i++) { |
14210 | nid = spec->multiout.dac_nids[i]; | 14255 | nid = spec->multiout.dac_nids[i]; |
14211 | if (!nid) | 14256 | if (!nid) |
14212 | continue; | 14257 | continue; |
14213 | if (nid == 0x05) { | 14258 | if (i == 2) { |
14214 | /* Center/LFE */ | 14259 | /* Center/LFE */ |
14215 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 14260 | err = alc861_create_out_sw(codec, "Center", nid, 1); |
14216 | "Center Playback Switch", | ||
14217 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, | ||
14218 | HDA_OUTPUT)); | ||
14219 | if (err < 0) | 14261 | if (err < 0) |
14220 | return err; | 14262 | return err; |
14221 | err = add_control(spec, ALC_CTL_BIND_MUTE, | 14263 | err = alc861_create_out_sw(codec, "LFE", nid, 2); |
14222 | "LFE Playback Switch", | ||
14223 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, | ||
14224 | HDA_OUTPUT)); | ||
14225 | if (err < 0) | 14264 | if (err < 0) |
14226 | return err; | 14265 | return err; |
14227 | } else { | 14266 | } else { |
14228 | for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; | 14267 | err = alc861_create_out_sw(codec, chname[i], nid, 3); |
14229 | idx++) | ||
14230 | if (nid == alc861_dac_nids[idx]) | ||
14231 | break; | ||
14232 | sprintf(name, "%s Playback Switch", chname[idx]); | ||
14233 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | ||
14234 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | ||
14235 | HDA_OUTPUT)); | ||
14236 | if (err < 0) | 14268 | if (err < 0) |
14237 | return err; | 14269 | return err; |
14238 | } | 14270 | } |
@@ -14240,8 +14272,9 @@ static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
14240 | return 0; | 14272 | return 0; |
14241 | } | 14273 | } |
14242 | 14274 | ||
14243 | static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | 14275 | static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin) |
14244 | { | 14276 | { |
14277 | struct alc_spec *spec = codec->spec; | ||
14245 | int err; | 14278 | int err; |
14246 | hda_nid_t nid; | 14279 | hda_nid_t nid; |
14247 | 14280 | ||
@@ -14249,70 +14282,49 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) | |||
14249 | return 0; | 14282 | return 0; |
14250 | 14283 | ||
14251 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { | 14284 | if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { |
14252 | nid = 0x03; | 14285 | nid = alc861_look_for_dac(codec, pin); |
14253 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, | 14286 | if (nid) { |
14254 | "Headphone Playback Switch", | 14287 | err = alc861_create_out_sw(codec, "Headphone", nid, 3); |
14255 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | 14288 | if (err < 0) |
14256 | if (err < 0) | 14289 | return err; |
14257 | return err; | 14290 | spec->multiout.hp_nid = nid; |
14258 | spec->multiout.hp_nid = nid; | 14291 | } |
14259 | } | 14292 | } |
14260 | return 0; | 14293 | return 0; |
14261 | } | 14294 | } |
14262 | 14295 | ||
14263 | /* create playback/capture controls for input pins */ | 14296 | /* create playback/capture controls for input pins */ |
14264 | static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, | 14297 | static int alc861_auto_create_input_ctls(struct hda_codec *codec, |
14265 | const struct auto_pin_cfg *cfg) | 14298 | const struct auto_pin_cfg *cfg) |
14266 | { | 14299 | { |
14267 | struct hda_input_mux *imux = &spec->private_imux[0]; | 14300 | return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0); |
14268 | int i, err, idx, idx1; | ||
14269 | |||
14270 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
14271 | switch (cfg->input_pins[i]) { | ||
14272 | case 0x0c: | ||
14273 | idx1 = 1; | ||
14274 | idx = 2; /* Line In */ | ||
14275 | break; | ||
14276 | case 0x0f: | ||
14277 | idx1 = 2; | ||
14278 | idx = 2; /* Line In */ | ||
14279 | break; | ||
14280 | case 0x0d: | ||
14281 | idx1 = 0; | ||
14282 | idx = 1; /* Mic In */ | ||
14283 | break; | ||
14284 | case 0x10: | ||
14285 | idx1 = 3; | ||
14286 | idx = 1; /* Mic In */ | ||
14287 | break; | ||
14288 | case 0x11: | ||
14289 | idx1 = 4; | ||
14290 | idx = 0; /* CD */ | ||
14291 | break; | ||
14292 | default: | ||
14293 | continue; | ||
14294 | } | ||
14295 | |||
14296 | err = new_analog_input(spec, cfg->input_pins[i], | ||
14297 | auto_pin_cfg_labels[i], idx, 0x15); | ||
14298 | if (err < 0) | ||
14299 | return err; | ||
14300 | |||
14301 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | ||
14302 | imux->items[imux->num_items].index = idx1; | ||
14303 | imux->num_items++; | ||
14304 | } | ||
14305 | return 0; | ||
14306 | } | 14301 | } |
14307 | 14302 | ||
14308 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, | 14303 | static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, |
14309 | hda_nid_t nid, | 14304 | hda_nid_t nid, |
14310 | int pin_type, int dac_idx) | 14305 | int pin_type, hda_nid_t dac) |
14311 | { | 14306 | { |
14307 | hda_nid_t mix, srcs[5]; | ||
14308 | int i, num; | ||
14309 | |||
14312 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 14310 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
14313 | pin_type); | 14311 | pin_type); |
14314 | snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 14312 | snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
14315 | AMP_OUT_UNMUTE); | 14313 | AMP_OUT_UNMUTE); |
14314 | if (snd_hda_get_connections(codec, nid, &mix, 1) != 1) | ||
14315 | return; | ||
14316 | num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs)); | ||
14317 | if (num < 0) | ||
14318 | return; | ||
14319 | for (i = 0; i < num; i++) { | ||
14320 | unsigned int mute; | ||
14321 | if (srcs[i] == dac || srcs[i] == 0x15) | ||
14322 | mute = AMP_IN_UNMUTE(i); | ||
14323 | else | ||
14324 | mute = AMP_IN_MUTE(i); | ||
14325 | snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
14326 | mute); | ||
14327 | } | ||
14316 | } | 14328 | } |
14317 | 14329 | ||
14318 | static void alc861_auto_init_multi_out(struct hda_codec *codec) | 14330 | static void alc861_auto_init_multi_out(struct hda_codec *codec) |
@@ -14335,12 +14347,13 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec) | |||
14335 | hda_nid_t pin; | 14347 | hda_nid_t pin; |
14336 | 14348 | ||
14337 | pin = spec->autocfg.hp_pins[0]; | 14349 | pin = spec->autocfg.hp_pins[0]; |
14338 | if (pin) /* connect to front */ | 14350 | if (pin) |
14339 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, | 14351 | alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, |
14340 | spec->multiout.dac_nids[0]); | 14352 | spec->multiout.hp_nid); |
14341 | pin = spec->autocfg.speaker_pins[0]; | 14353 | pin = spec->autocfg.speaker_pins[0]; |
14342 | if (pin) | 14354 | if (pin) |
14343 | alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | 14355 | alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, |
14356 | spec->multiout.dac_nids[0]); | ||
14344 | } | 14357 | } |
14345 | 14358 | ||
14346 | static void alc861_auto_init_analog_input(struct hda_codec *codec) | 14359 | static void alc861_auto_init_analog_input(struct hda_codec *codec) |
@@ -14372,16 +14385,16 @@ static int alc861_parse_auto_config(struct hda_codec *codec) | |||
14372 | if (!spec->autocfg.line_outs) | 14385 | if (!spec->autocfg.line_outs) |
14373 | return 0; /* can't find valid BIOS pin config */ | 14386 | return 0; /* can't find valid BIOS pin config */ |
14374 | 14387 | ||
14375 | err = alc861_auto_fill_dac_nids(spec, &spec->autocfg); | 14388 | err = alc861_auto_fill_dac_nids(codec, &spec->autocfg); |
14376 | if (err < 0) | 14389 | if (err < 0) |
14377 | return err; | 14390 | return err; |
14378 | err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg); | 14391 | err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg); |
14379 | if (err < 0) | 14392 | if (err < 0) |
14380 | return err; | 14393 | return err; |
14381 | err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); | 14394 | err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]); |
14382 | if (err < 0) | 14395 | if (err < 0) |
14383 | return err; | 14396 | return err; |
14384 | err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg); | 14397 | err = alc861_auto_create_input_ctls(codec, &spec->autocfg); |
14385 | if (err < 0) | 14398 | if (err < 0) |
14386 | return err; | 14399 | return err; |
14387 | 14400 | ||
@@ -14400,7 +14413,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec) | |||
14400 | 14413 | ||
14401 | spec->adc_nids = alc861_adc_nids; | 14414 | spec->adc_nids = alc861_adc_nids; |
14402 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | 14415 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); |
14403 | set_capture_mixer(spec); | 14416 | set_capture_mixer(codec); |
14404 | 14417 | ||
14405 | alc_ssid_check(codec, 0x0e, 0x0f, 0x0b); | 14418 | alc_ssid_check(codec, 0x0e, 0x0f, 0x0b); |
14406 | 14419 | ||
@@ -14593,8 +14606,8 @@ static int patch_alc861(struct hda_codec *codec) | |||
14593 | alc861_cfg_tbl); | 14606 | alc861_cfg_tbl); |
14594 | 14607 | ||
14595 | if (board_config < 0) { | 14608 | if (board_config < 0) { |
14596 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 14609 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
14597 | "trying auto-probe from BIOS...\n", codec->chip_name); | 14610 | codec->chip_name); |
14598 | board_config = ALC861_AUTO; | 14611 | board_config = ALC861_AUTO; |
14599 | } | 14612 | } |
14600 | 14613 | ||
@@ -14619,7 +14632,7 @@ static int patch_alc861(struct hda_codec *codec) | |||
14619 | } | 14632 | } |
14620 | 14633 | ||
14621 | if (board_config != ALC861_AUTO) | 14634 | if (board_config != ALC861_AUTO) |
14622 | setup_preset(spec, &alc861_presets[board_config]); | 14635 | setup_preset(codec, &alc861_presets[board_config]); |
14623 | 14636 | ||
14624 | spec->stream_analog_playback = &alc861_pcm_analog_playback; | 14637 | spec->stream_analog_playback = &alc861_pcm_analog_playback; |
14625 | spec->stream_analog_capture = &alc861_pcm_analog_capture; | 14638 | spec->stream_analog_capture = &alc861_pcm_analog_capture; |
@@ -15022,12 +15035,15 @@ static void alc861vd_lenovo_mic_automute(struct hda_codec *codec) | |||
15022 | HDA_AMP_MUTE, bits); | 15035 | HDA_AMP_MUTE, bits); |
15023 | } | 15036 | } |
15024 | 15037 | ||
15025 | static void alc861vd_lenovo_init_hook(struct hda_codec *codec) | 15038 | static void alc861vd_lenovo_setup(struct hda_codec *codec) |
15026 | { | 15039 | { |
15027 | struct alc_spec *spec = codec->spec; | 15040 | struct alc_spec *spec = codec->spec; |
15028 | |||
15029 | spec->autocfg.hp_pins[0] = 0x1b; | 15041 | spec->autocfg.hp_pins[0] = 0x1b; |
15030 | spec->autocfg.speaker_pins[0] = 0x14; | 15042 | spec->autocfg.speaker_pins[0] = 0x14; |
15043 | } | ||
15044 | |||
15045 | static void alc861vd_lenovo_init_hook(struct hda_codec *codec) | ||
15046 | { | ||
15031 | alc_automute_amp(codec); | 15047 | alc_automute_amp(codec); |
15032 | alc861vd_lenovo_mic_automute(codec); | 15048 | alc861vd_lenovo_mic_automute(codec); |
15033 | } | 15049 | } |
@@ -15091,13 +15107,12 @@ static struct hda_verb alc861vd_dallas_verbs[] = { | |||
15091 | }; | 15107 | }; |
15092 | 15108 | ||
15093 | /* toggle speaker-output according to the hp-jack state */ | 15109 | /* toggle speaker-output according to the hp-jack state */ |
15094 | static void alc861vd_dallas_init_hook(struct hda_codec *codec) | 15110 | static void alc861vd_dallas_setup(struct hda_codec *codec) |
15095 | { | 15111 | { |
15096 | struct alc_spec *spec = codec->spec; | 15112 | struct alc_spec *spec = codec->spec; |
15097 | 15113 | ||
15098 | spec->autocfg.hp_pins[0] = 0x15; | 15114 | spec->autocfg.hp_pins[0] = 0x15; |
15099 | spec->autocfg.speaker_pins[0] = 0x14; | 15115 | spec->autocfg.speaker_pins[0] = 0x14; |
15100 | alc_automute_amp(codec); | ||
15101 | } | 15116 | } |
15102 | 15117 | ||
15103 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 15118 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -15136,7 +15151,7 @@ static struct snd_pci_quirk alc861vd_cfg_tbl[] = { | |||
15136 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), | 15151 | SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), |
15137 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), | 15152 | SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), |
15138 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ | 15153 | /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ |
15139 | SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), | 15154 | SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO), |
15140 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), | 15155 | SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), |
15141 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), | 15156 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), |
15142 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), | 15157 | SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), |
@@ -15211,6 +15226,7 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15211 | .channel_mode = alc861vd_3stack_2ch_modes, | 15226 | .channel_mode = alc861vd_3stack_2ch_modes, |
15212 | .input_mux = &alc861vd_capture_source, | 15227 | .input_mux = &alc861vd_capture_source, |
15213 | .unsol_event = alc861vd_lenovo_unsol_event, | 15228 | .unsol_event = alc861vd_lenovo_unsol_event, |
15229 | .setup = alc861vd_lenovo_setup, | ||
15214 | .init_hook = alc861vd_lenovo_init_hook, | 15230 | .init_hook = alc861vd_lenovo_init_hook, |
15215 | }, | 15231 | }, |
15216 | [ALC861VD_DALLAS] = { | 15232 | [ALC861VD_DALLAS] = { |
@@ -15222,7 +15238,8 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15222 | .channel_mode = alc861vd_3stack_2ch_modes, | 15238 | .channel_mode = alc861vd_3stack_2ch_modes, |
15223 | .input_mux = &alc861vd_dallas_capture_source, | 15239 | .input_mux = &alc861vd_dallas_capture_source, |
15224 | .unsol_event = alc_automute_amp_unsol_event, | 15240 | .unsol_event = alc_automute_amp_unsol_event, |
15225 | .init_hook = alc861vd_dallas_init_hook, | 15241 | .setup = alc861vd_dallas_setup, |
15242 | .init_hook = alc_automute_amp, | ||
15226 | }, | 15243 | }, |
15227 | [ALC861VD_HP] = { | 15244 | [ALC861VD_HP] = { |
15228 | .mixers = { alc861vd_hp_mixer }, | 15245 | .mixers = { alc861vd_hp_mixer }, |
@@ -15234,7 +15251,8 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15234 | .channel_mode = alc861vd_3stack_2ch_modes, | 15251 | .channel_mode = alc861vd_3stack_2ch_modes, |
15235 | .input_mux = &alc861vd_hp_capture_source, | 15252 | .input_mux = &alc861vd_hp_capture_source, |
15236 | .unsol_event = alc_automute_amp_unsol_event, | 15253 | .unsol_event = alc_automute_amp_unsol_event, |
15237 | .init_hook = alc861vd_dallas_init_hook, | 15254 | .setup = alc861vd_dallas_setup, |
15255 | .init_hook = alc_automute_amp, | ||
15238 | }, | 15256 | }, |
15239 | [ALC660VD_ASUS_V1S] = { | 15257 | [ALC660VD_ASUS_V1S] = { |
15240 | .mixers = { alc861vd_lenovo_mixer }, | 15258 | .mixers = { alc861vd_lenovo_mixer }, |
@@ -15249,6 +15267,7 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15249 | .channel_mode = alc861vd_3stack_2ch_modes, | 15267 | .channel_mode = alc861vd_3stack_2ch_modes, |
15250 | .input_mux = &alc861vd_capture_source, | 15268 | .input_mux = &alc861vd_capture_source, |
15251 | .unsol_event = alc861vd_lenovo_unsol_event, | 15269 | .unsol_event = alc861vd_lenovo_unsol_event, |
15270 | .setup = alc861vd_lenovo_setup, | ||
15252 | .init_hook = alc861vd_lenovo_init_hook, | 15271 | .init_hook = alc861vd_lenovo_init_hook, |
15253 | }, | 15272 | }, |
15254 | }; | 15273 | }; |
@@ -15256,6 +15275,13 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15256 | /* | 15275 | /* |
15257 | * BIOS auto configuration | 15276 | * BIOS auto configuration |
15258 | */ | 15277 | */ |
15278 | static int alc861vd_auto_create_input_ctls(struct hda_codec *codec, | ||
15279 | const struct auto_pin_cfg *cfg) | ||
15280 | { | ||
15281 | return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0); | ||
15282 | } | ||
15283 | |||
15284 | |||
15259 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, | 15285 | static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec, |
15260 | hda_nid_t nid, int pin_type, int dac_idx) | 15286 | hda_nid_t nid, int pin_type, int dac_idx) |
15261 | { | 15287 | { |
@@ -15290,7 +15316,6 @@ static void alc861vd_auto_init_hp_out(struct hda_codec *codec) | |||
15290 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); | 15316 | alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
15291 | } | 15317 | } |
15292 | 15318 | ||
15293 | #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid) | ||
15294 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID | 15319 | #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID |
15295 | 15320 | ||
15296 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | 15321 | static void alc861vd_auto_init_analog_input(struct hda_codec *codec) |
@@ -15300,7 +15325,7 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec) | |||
15300 | 15325 | ||
15301 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 15326 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
15302 | hda_nid_t nid = spec->autocfg.input_pins[i]; | 15327 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
15303 | if (alc861vd_is_input_pin(nid)) { | 15328 | if (alc_is_input_pin(codec, nid)) { |
15304 | alc_set_input_pin(codec, nid, i); | 15329 | alc_set_input_pin(codec, nid, i); |
15305 | if (nid != ALC861VD_PIN_CD_NID && | 15330 | if (nid != ALC861VD_PIN_CD_NID && |
15306 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) | 15331 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) |
@@ -15364,13 +15389,25 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
15364 | if (err < 0) | 15389 | if (err < 0) |
15365 | return err; | 15390 | return err; |
15366 | } else { | 15391 | } else { |
15367 | sprintf(name, "%s Playback Volume", chname[i]); | 15392 | const char *pfx; |
15393 | if (cfg->line_outs == 1 && | ||
15394 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { | ||
15395 | if (!cfg->hp_pins) | ||
15396 | pfx = "Speaker"; | ||
15397 | else | ||
15398 | pfx = "PCM"; | ||
15399 | } else | ||
15400 | pfx = chname[i]; | ||
15401 | sprintf(name, "%s Playback Volume", pfx); | ||
15368 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 15402 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
15369 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, | 15403 | HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, |
15370 | HDA_OUTPUT)); | 15404 | HDA_OUTPUT)); |
15371 | if (err < 0) | 15405 | if (err < 0) |
15372 | return err; | 15406 | return err; |
15373 | sprintf(name, "%s Playback Switch", chname[i]); | 15407 | if (cfg->line_outs == 1 && |
15408 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
15409 | pfx = "Speaker"; | ||
15410 | sprintf(name, "%s Playback Switch", pfx); | ||
15374 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, | 15411 | err = add_control(spec, ALC_CTL_BIND_MUTE, name, |
15375 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, | 15412 | HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, |
15376 | HDA_INPUT)); | 15413 | HDA_INPUT)); |
@@ -15463,7 +15500,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec) | |||
15463 | "Headphone"); | 15500 | "Headphone"); |
15464 | if (err < 0) | 15501 | if (err < 0) |
15465 | return err; | 15502 | return err; |
15466 | err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg); | 15503 | err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg); |
15467 | if (err < 0) | 15504 | if (err < 0) |
15468 | return err; | 15505 | return err; |
15469 | 15506 | ||
@@ -15517,8 +15554,8 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
15517 | alc861vd_cfg_tbl); | 15554 | alc861vd_cfg_tbl); |
15518 | 15555 | ||
15519 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { | 15556 | if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) { |
15520 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 15557 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
15521 | "trying auto-probe from BIOS...\n", codec->chip_name); | 15558 | codec->chip_name); |
15522 | board_config = ALC861VD_AUTO; | 15559 | board_config = ALC861VD_AUTO; |
15523 | } | 15560 | } |
15524 | 15561 | ||
@@ -15543,7 +15580,7 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
15543 | } | 15580 | } |
15544 | 15581 | ||
15545 | if (board_config != ALC861VD_AUTO) | 15582 | if (board_config != ALC861VD_AUTO) |
15546 | setup_preset(spec, &alc861vd_presets[board_config]); | 15583 | setup_preset(codec, &alc861vd_presets[board_config]); |
15547 | 15584 | ||
15548 | if (codec->vendor_id == 0x10ec0660) { | 15585 | if (codec->vendor_id == 0x10ec0660) { |
15549 | /* always turn on EAPD */ | 15586 | /* always turn on EAPD */ |
@@ -15556,11 +15593,14 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
15556 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; | 15593 | spec->stream_digital_playback = &alc861vd_pcm_digital_playback; |
15557 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; | 15594 | spec->stream_digital_capture = &alc861vd_pcm_digital_capture; |
15558 | 15595 | ||
15559 | spec->adc_nids = alc861vd_adc_nids; | 15596 | if (!spec->adc_nids) { |
15560 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | 15597 | spec->adc_nids = alc861vd_adc_nids; |
15561 | spec->capsrc_nids = alc861vd_capsrc_nids; | 15598 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); |
15599 | } | ||
15600 | if (!spec->capsrc_nids) | ||
15601 | spec->capsrc_nids = alc861vd_capsrc_nids; | ||
15562 | 15602 | ||
15563 | set_capture_mixer(spec); | 15603 | set_capture_mixer(codec); |
15564 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 15604 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
15565 | 15605 | ||
15566 | spec->vmaster_nid = 0x02; | 15606 | spec->vmaster_nid = 0x02; |
@@ -15601,9 +15641,9 @@ static hda_nid_t alc272_dac_nids[2] = { | |||
15601 | 0x02, 0x03 | 15641 | 0x02, 0x03 |
15602 | }; | 15642 | }; |
15603 | 15643 | ||
15604 | static hda_nid_t alc662_adc_nids[1] = { | 15644 | static hda_nid_t alc662_adc_nids[2] = { |
15605 | /* ADC1-2 */ | 15645 | /* ADC1-2 */ |
15606 | 0x09, | 15646 | 0x09, 0x08 |
15607 | }; | 15647 | }; |
15608 | 15648 | ||
15609 | static hda_nid_t alc272_adc_nids[1] = { | 15649 | static hda_nid_t alc272_adc_nids[1] = { |
@@ -15611,7 +15651,7 @@ static hda_nid_t alc272_adc_nids[1] = { | |||
15611 | 0x08, | 15651 | 0x08, |
15612 | }; | 15652 | }; |
15613 | 15653 | ||
15614 | static hda_nid_t alc662_capsrc_nids[1] = { 0x22 }; | 15654 | static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 }; |
15615 | static hda_nid_t alc272_capsrc_nids[1] = { 0x23 }; | 15655 | static hda_nid_t alc272_capsrc_nids[1] = { 0x23 }; |
15616 | 15656 | ||
15617 | 15657 | ||
@@ -15635,14 +15675,6 @@ static struct hda_input_mux alc662_lenovo_101e_capture_source = { | |||
15635 | }, | 15675 | }, |
15636 | }; | 15676 | }; |
15637 | 15677 | ||
15638 | static struct hda_input_mux alc662_eeepc_capture_source = { | ||
15639 | .num_items = 2, | ||
15640 | .items = { | ||
15641 | { "i-Mic", 0x1 }, | ||
15642 | { "e-Mic", 0x0 }, | ||
15643 | }, | ||
15644 | }; | ||
15645 | |||
15646 | static struct hda_input_mux alc663_capture_source = { | 15678 | static struct hda_input_mux alc663_capture_source = { |
15647 | .num_items = 3, | 15679 | .num_items = 3, |
15648 | .items = { | 15680 | .items = { |
@@ -15652,23 +15684,7 @@ static struct hda_input_mux alc663_capture_source = { | |||
15652 | }, | 15684 | }, |
15653 | }; | 15685 | }; |
15654 | 15686 | ||
15655 | static struct hda_input_mux alc663_m51va_capture_source = { | 15687 | #if 0 /* set to 1 for testing other input sources below */ |
15656 | .num_items = 2, | ||
15657 | .items = { | ||
15658 | { "Ext-Mic", 0x0 }, | ||
15659 | { "D-Mic", 0x9 }, | ||
15660 | }, | ||
15661 | }; | ||
15662 | |||
15663 | #if 1 /* set to 0 for testing other input sources below */ | ||
15664 | static struct hda_input_mux alc272_nc10_capture_source = { | ||
15665 | .num_items = 2, | ||
15666 | .items = { | ||
15667 | { "Autoselect Mic", 0x0 }, | ||
15668 | { "Internal Mic", 0x1 }, | ||
15669 | }, | ||
15670 | }; | ||
15671 | #else | ||
15672 | static struct hda_input_mux alc272_nc10_capture_source = { | 15688 | static struct hda_input_mux alc272_nc10_capture_source = { |
15673 | .num_items = 16, | 15689 | .num_items = 16, |
15674 | .items = { | 15690 | .items = { |
@@ -16337,47 +16353,44 @@ static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec, | |||
16337 | alc662_lenovo_101e_ispeaker_automute(codec); | 16353 | alc662_lenovo_101e_ispeaker_automute(codec); |
16338 | } | 16354 | } |
16339 | 16355 | ||
16340 | static void alc662_eeepc_mic_automute(struct hda_codec *codec) | ||
16341 | { | ||
16342 | unsigned int present; | ||
16343 | |||
16344 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
16345 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
16346 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16347 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
16348 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16349 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
16350 | snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16351 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | ||
16352 | snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16353 | 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); | ||
16354 | } | ||
16355 | |||
16356 | /* unsolicited event for HP jack sensing */ | 16356 | /* unsolicited event for HP jack sensing */ |
16357 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, | 16357 | static void alc662_eeepc_unsol_event(struct hda_codec *codec, |
16358 | unsigned int res) | 16358 | unsigned int res) |
16359 | { | 16359 | { |
16360 | if ((res >> 26) == ALC880_MIC_EVENT) | 16360 | if ((res >> 26) == ALC880_MIC_EVENT) |
16361 | alc662_eeepc_mic_automute(codec); | 16361 | alc_mic_automute(codec); |
16362 | else | 16362 | else |
16363 | alc262_hippo_unsol_event(codec, res); | 16363 | alc262_hippo_unsol_event(codec, res); |
16364 | } | 16364 | } |
16365 | 16365 | ||
16366 | static void alc662_eeepc_setup(struct hda_codec *codec) | ||
16367 | { | ||
16368 | struct alc_spec *spec = codec->spec; | ||
16369 | |||
16370 | alc262_hippo1_setup(codec); | ||
16371 | spec->ext_mic.pin = 0x18; | ||
16372 | spec->ext_mic.mux_idx = 0; | ||
16373 | spec->int_mic.pin = 0x19; | ||
16374 | spec->int_mic.mux_idx = 1; | ||
16375 | spec->auto_mic = 1; | ||
16376 | } | ||
16377 | |||
16366 | static void alc662_eeepc_inithook(struct hda_codec *codec) | 16378 | static void alc662_eeepc_inithook(struct hda_codec *codec) |
16367 | { | 16379 | { |
16368 | alc262_hippo1_init_hook(codec); | 16380 | alc262_hippo_automute(codec); |
16369 | alc662_eeepc_mic_automute(codec); | 16381 | alc_mic_automute(codec); |
16370 | } | 16382 | } |
16371 | 16383 | ||
16372 | static void alc662_eeepc_ep20_inithook(struct hda_codec *codec) | 16384 | static void alc662_eeepc_ep20_setup(struct hda_codec *codec) |
16373 | { | 16385 | { |
16374 | struct alc_spec *spec = codec->spec; | 16386 | struct alc_spec *spec = codec->spec; |
16375 | 16387 | ||
16376 | spec->autocfg.hp_pins[0] = 0x14; | 16388 | spec->autocfg.hp_pins[0] = 0x14; |
16377 | spec->autocfg.speaker_pins[0] = 0x1b; | 16389 | spec->autocfg.speaker_pins[0] = 0x1b; |
16378 | alc262_hippo_master_update(codec); | ||
16379 | } | 16390 | } |
16380 | 16391 | ||
16392 | #define alc662_eeepc_ep20_inithook alc262_hippo_master_update | ||
16393 | |||
16381 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) | 16394 | static void alc663_m51va_speaker_automute(struct hda_codec *codec) |
16382 | { | 16395 | { |
16383 | unsigned int present; | 16396 | unsigned int present; |
@@ -16488,23 +16501,6 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec) | |||
16488 | } | 16501 | } |
16489 | } | 16502 | } |
16490 | 16503 | ||
16491 | static void alc663_m51va_mic_automute(struct hda_codec *codec) | ||
16492 | { | ||
16493 | unsigned int present; | ||
16494 | |||
16495 | present = snd_hda_codec_read(codec, 0x18, 0, | ||
16496 | AC_VERB_GET_PIN_SENSE, 0) | ||
16497 | & AC_PINSENSE_PRESENCE; | ||
16498 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16499 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
16500 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16501 | 0x7000 | (0x00 << 8) | (present ? 0 : 0x80)); | ||
16502 | snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16503 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); | ||
16504 | snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
16505 | 0x7000 | (0x09 << 8) | (present ? 0x80 : 0)); | ||
16506 | } | ||
16507 | |||
16508 | static void alc663_m51va_unsol_event(struct hda_codec *codec, | 16504 | static void alc663_m51va_unsol_event(struct hda_codec *codec, |
16509 | unsigned int res) | 16505 | unsigned int res) |
16510 | { | 16506 | { |
@@ -16513,36 +16509,32 @@ static void alc663_m51va_unsol_event(struct hda_codec *codec, | |||
16513 | alc663_m51va_speaker_automute(codec); | 16509 | alc663_m51va_speaker_automute(codec); |
16514 | break; | 16510 | break; |
16515 | case ALC880_MIC_EVENT: | 16511 | case ALC880_MIC_EVENT: |
16516 | alc663_m51va_mic_automute(codec); | 16512 | alc_mic_automute(codec); |
16517 | break; | 16513 | break; |
16518 | } | 16514 | } |
16519 | } | 16515 | } |
16520 | 16516 | ||
16517 | static void alc663_m51va_setup(struct hda_codec *codec) | ||
16518 | { | ||
16519 | struct alc_spec *spec = codec->spec; | ||
16520 | spec->ext_mic.pin = 0x18; | ||
16521 | spec->ext_mic.mux_idx = 0; | ||
16522 | spec->int_mic.pin = 0x12; | ||
16523 | spec->int_mic.mux_idx = 1; | ||
16524 | spec->auto_mic = 1; | ||
16525 | } | ||
16526 | |||
16521 | static void alc663_m51va_inithook(struct hda_codec *codec) | 16527 | static void alc663_m51va_inithook(struct hda_codec *codec) |
16522 | { | 16528 | { |
16523 | alc663_m51va_speaker_automute(codec); | 16529 | alc663_m51va_speaker_automute(codec); |
16524 | alc663_m51va_mic_automute(codec); | 16530 | alc_mic_automute(codec); |
16525 | } | 16531 | } |
16526 | 16532 | ||
16527 | /* ***************** Mode1 ******************************/ | 16533 | /* ***************** Mode1 ******************************/ |
16528 | static void alc663_mode1_unsol_event(struct hda_codec *codec, | 16534 | #define alc663_mode1_unsol_event alc663_m51va_unsol_event |
16529 | unsigned int res) | 16535 | #define alc663_mode1_setup alc663_m51va_setup |
16530 | { | 16536 | #define alc663_mode1_inithook alc663_m51va_inithook |
16531 | switch (res >> 26) { | ||
16532 | case ALC880_HP_EVENT: | ||
16533 | alc663_m51va_speaker_automute(codec); | ||
16534 | break; | ||
16535 | case ALC880_MIC_EVENT: | ||
16536 | alc662_eeepc_mic_automute(codec); | ||
16537 | break; | ||
16538 | } | ||
16539 | } | ||
16540 | 16537 | ||
16541 | static void alc663_mode1_inithook(struct hda_codec *codec) | ||
16542 | { | ||
16543 | alc663_m51va_speaker_automute(codec); | ||
16544 | alc662_eeepc_mic_automute(codec); | ||
16545 | } | ||
16546 | /* ***************** Mode2 ******************************/ | 16538 | /* ***************** Mode2 ******************************/ |
16547 | static void alc662_mode2_unsol_event(struct hda_codec *codec, | 16539 | static void alc662_mode2_unsol_event(struct hda_codec *codec, |
16548 | unsigned int res) | 16540 | unsigned int res) |
@@ -16552,15 +16544,17 @@ static void alc662_mode2_unsol_event(struct hda_codec *codec, | |||
16552 | alc662_f5z_speaker_automute(codec); | 16544 | alc662_f5z_speaker_automute(codec); |
16553 | break; | 16545 | break; |
16554 | case ALC880_MIC_EVENT: | 16546 | case ALC880_MIC_EVENT: |
16555 | alc662_eeepc_mic_automute(codec); | 16547 | alc_mic_automute(codec); |
16556 | break; | 16548 | break; |
16557 | } | 16549 | } |
16558 | } | 16550 | } |
16559 | 16551 | ||
16552 | #define alc662_mode2_setup alc663_m51va_setup | ||
16553 | |||
16560 | static void alc662_mode2_inithook(struct hda_codec *codec) | 16554 | static void alc662_mode2_inithook(struct hda_codec *codec) |
16561 | { | 16555 | { |
16562 | alc662_f5z_speaker_automute(codec); | 16556 | alc662_f5z_speaker_automute(codec); |
16563 | alc662_eeepc_mic_automute(codec); | 16557 | alc_mic_automute(codec); |
16564 | } | 16558 | } |
16565 | /* ***************** Mode3 ******************************/ | 16559 | /* ***************** Mode3 ******************************/ |
16566 | static void alc663_mode3_unsol_event(struct hda_codec *codec, | 16560 | static void alc663_mode3_unsol_event(struct hda_codec *codec, |
@@ -16571,15 +16565,17 @@ static void alc663_mode3_unsol_event(struct hda_codec *codec, | |||
16571 | alc663_two_hp_m1_speaker_automute(codec); | 16565 | alc663_two_hp_m1_speaker_automute(codec); |
16572 | break; | 16566 | break; |
16573 | case ALC880_MIC_EVENT: | 16567 | case ALC880_MIC_EVENT: |
16574 | alc662_eeepc_mic_automute(codec); | 16568 | alc_mic_automute(codec); |
16575 | break; | 16569 | break; |
16576 | } | 16570 | } |
16577 | } | 16571 | } |
16578 | 16572 | ||
16573 | #define alc663_mode3_setup alc663_m51va_setup | ||
16574 | |||
16579 | static void alc663_mode3_inithook(struct hda_codec *codec) | 16575 | static void alc663_mode3_inithook(struct hda_codec *codec) |
16580 | { | 16576 | { |
16581 | alc663_two_hp_m1_speaker_automute(codec); | 16577 | alc663_two_hp_m1_speaker_automute(codec); |
16582 | alc662_eeepc_mic_automute(codec); | 16578 | alc_mic_automute(codec); |
16583 | } | 16579 | } |
16584 | /* ***************** Mode4 ******************************/ | 16580 | /* ***************** Mode4 ******************************/ |
16585 | static void alc663_mode4_unsol_event(struct hda_codec *codec, | 16581 | static void alc663_mode4_unsol_event(struct hda_codec *codec, |
@@ -16590,15 +16586,17 @@ static void alc663_mode4_unsol_event(struct hda_codec *codec, | |||
16590 | alc663_21jd_two_speaker_automute(codec); | 16586 | alc663_21jd_two_speaker_automute(codec); |
16591 | break; | 16587 | break; |
16592 | case ALC880_MIC_EVENT: | 16588 | case ALC880_MIC_EVENT: |
16593 | alc662_eeepc_mic_automute(codec); | 16589 | alc_mic_automute(codec); |
16594 | break; | 16590 | break; |
16595 | } | 16591 | } |
16596 | } | 16592 | } |
16597 | 16593 | ||
16594 | #define alc663_mode4_setup alc663_m51va_setup | ||
16595 | |||
16598 | static void alc663_mode4_inithook(struct hda_codec *codec) | 16596 | static void alc663_mode4_inithook(struct hda_codec *codec) |
16599 | { | 16597 | { |
16600 | alc663_21jd_two_speaker_automute(codec); | 16598 | alc663_21jd_two_speaker_automute(codec); |
16601 | alc662_eeepc_mic_automute(codec); | 16599 | alc_mic_automute(codec); |
16602 | } | 16600 | } |
16603 | /* ***************** Mode5 ******************************/ | 16601 | /* ***************** Mode5 ******************************/ |
16604 | static void alc663_mode5_unsol_event(struct hda_codec *codec, | 16602 | static void alc663_mode5_unsol_event(struct hda_codec *codec, |
@@ -16609,15 +16607,17 @@ static void alc663_mode5_unsol_event(struct hda_codec *codec, | |||
16609 | alc663_15jd_two_speaker_automute(codec); | 16607 | alc663_15jd_two_speaker_automute(codec); |
16610 | break; | 16608 | break; |
16611 | case ALC880_MIC_EVENT: | 16609 | case ALC880_MIC_EVENT: |
16612 | alc662_eeepc_mic_automute(codec); | 16610 | alc_mic_automute(codec); |
16613 | break; | 16611 | break; |
16614 | } | 16612 | } |
16615 | } | 16613 | } |
16616 | 16614 | ||
16615 | #define alc663_mode5_setup alc663_m51va_setup | ||
16616 | |||
16617 | static void alc663_mode5_inithook(struct hda_codec *codec) | 16617 | static void alc663_mode5_inithook(struct hda_codec *codec) |
16618 | { | 16618 | { |
16619 | alc663_15jd_two_speaker_automute(codec); | 16619 | alc663_15jd_two_speaker_automute(codec); |
16620 | alc662_eeepc_mic_automute(codec); | 16620 | alc_mic_automute(codec); |
16621 | } | 16621 | } |
16622 | /* ***************** Mode6 ******************************/ | 16622 | /* ***************** Mode6 ******************************/ |
16623 | static void alc663_mode6_unsol_event(struct hda_codec *codec, | 16623 | static void alc663_mode6_unsol_event(struct hda_codec *codec, |
@@ -16628,15 +16628,17 @@ static void alc663_mode6_unsol_event(struct hda_codec *codec, | |||
16628 | alc663_two_hp_m2_speaker_automute(codec); | 16628 | alc663_two_hp_m2_speaker_automute(codec); |
16629 | break; | 16629 | break; |
16630 | case ALC880_MIC_EVENT: | 16630 | case ALC880_MIC_EVENT: |
16631 | alc662_eeepc_mic_automute(codec); | 16631 | alc_mic_automute(codec); |
16632 | break; | 16632 | break; |
16633 | } | 16633 | } |
16634 | } | 16634 | } |
16635 | 16635 | ||
16636 | #define alc663_mode6_setup alc663_m51va_setup | ||
16637 | |||
16636 | static void alc663_mode6_inithook(struct hda_codec *codec) | 16638 | static void alc663_mode6_inithook(struct hda_codec *codec) |
16637 | { | 16639 | { |
16638 | alc663_two_hp_m2_speaker_automute(codec); | 16640 | alc663_two_hp_m2_speaker_automute(codec); |
16639 | alc662_eeepc_mic_automute(codec); | 16641 | alc_mic_automute(codec); |
16640 | } | 16642 | } |
16641 | 16643 | ||
16642 | static void alc663_g71v_hp_automute(struct hda_codec *codec) | 16644 | static void alc663_g71v_hp_automute(struct hda_codec *codec) |
@@ -16678,16 +16680,18 @@ static void alc663_g71v_unsol_event(struct hda_codec *codec, | |||
16678 | alc663_g71v_front_automute(codec); | 16680 | alc663_g71v_front_automute(codec); |
16679 | break; | 16681 | break; |
16680 | case ALC880_MIC_EVENT: | 16682 | case ALC880_MIC_EVENT: |
16681 | alc662_eeepc_mic_automute(codec); | 16683 | alc_mic_automute(codec); |
16682 | break; | 16684 | break; |
16683 | } | 16685 | } |
16684 | } | 16686 | } |
16685 | 16687 | ||
16688 | #define alc663_g71v_setup alc663_m51va_setup | ||
16689 | |||
16686 | static void alc663_g71v_inithook(struct hda_codec *codec) | 16690 | static void alc663_g71v_inithook(struct hda_codec *codec) |
16687 | { | 16691 | { |
16688 | alc663_g71v_front_automute(codec); | 16692 | alc663_g71v_front_automute(codec); |
16689 | alc663_g71v_hp_automute(codec); | 16693 | alc663_g71v_hp_automute(codec); |
16690 | alc662_eeepc_mic_automute(codec); | 16694 | alc_mic_automute(codec); |
16691 | } | 16695 | } |
16692 | 16696 | ||
16693 | static void alc663_g50v_unsol_event(struct hda_codec *codec, | 16697 | static void alc663_g50v_unsol_event(struct hda_codec *codec, |
@@ -16698,15 +16702,17 @@ static void alc663_g50v_unsol_event(struct hda_codec *codec, | |||
16698 | alc663_m51va_speaker_automute(codec); | 16702 | alc663_m51va_speaker_automute(codec); |
16699 | break; | 16703 | break; |
16700 | case ALC880_MIC_EVENT: | 16704 | case ALC880_MIC_EVENT: |
16701 | alc662_eeepc_mic_automute(codec); | 16705 | alc_mic_automute(codec); |
16702 | break; | 16706 | break; |
16703 | } | 16707 | } |
16704 | } | 16708 | } |
16705 | 16709 | ||
16710 | #define alc663_g50v_setup alc663_m51va_setup | ||
16711 | |||
16706 | static void alc663_g50v_inithook(struct hda_codec *codec) | 16712 | static void alc663_g50v_inithook(struct hda_codec *codec) |
16707 | { | 16713 | { |
16708 | alc663_m51va_speaker_automute(codec); | 16714 | alc663_m51va_speaker_automute(codec); |
16709 | alc662_eeepc_mic_automute(codec); | 16715 | alc_mic_automute(codec); |
16710 | } | 16716 | } |
16711 | 16717 | ||
16712 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { | 16718 | static struct snd_kcontrol_new alc662_ecs_mixer[] = { |
@@ -16910,8 +16916,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
16910 | .dac_nids = alc662_dac_nids, | 16916 | .dac_nids = alc662_dac_nids, |
16911 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 16917 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16912 | .channel_mode = alc662_3ST_2ch_modes, | 16918 | .channel_mode = alc662_3ST_2ch_modes, |
16913 | .input_mux = &alc662_eeepc_capture_source, | ||
16914 | .unsol_event = alc662_eeepc_unsol_event, | 16919 | .unsol_event = alc662_eeepc_unsol_event, |
16920 | .setup = alc662_eeepc_setup, | ||
16915 | .init_hook = alc662_eeepc_inithook, | 16921 | .init_hook = alc662_eeepc_inithook, |
16916 | }, | 16922 | }, |
16917 | [ALC662_ASUS_EEEPC_EP20] = { | 16923 | [ALC662_ASUS_EEEPC_EP20] = { |
@@ -16925,6 +16931,7 @@ static struct alc_config_preset alc662_presets[] = { | |||
16925 | .channel_mode = alc662_3ST_6ch_modes, | 16931 | .channel_mode = alc662_3ST_6ch_modes, |
16926 | .input_mux = &alc662_lenovo_101e_capture_source, | 16932 | .input_mux = &alc662_lenovo_101e_capture_source, |
16927 | .unsol_event = alc662_eeepc_unsol_event, | 16933 | .unsol_event = alc662_eeepc_unsol_event, |
16934 | .setup = alc662_eeepc_ep20_setup, | ||
16928 | .init_hook = alc662_eeepc_ep20_inithook, | 16935 | .init_hook = alc662_eeepc_ep20_inithook, |
16929 | }, | 16936 | }, |
16930 | [ALC662_ECS] = { | 16937 | [ALC662_ECS] = { |
@@ -16935,8 +16942,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
16935 | .dac_nids = alc662_dac_nids, | 16942 | .dac_nids = alc662_dac_nids, |
16936 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 16943 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16937 | .channel_mode = alc662_3ST_2ch_modes, | 16944 | .channel_mode = alc662_3ST_2ch_modes, |
16938 | .input_mux = &alc662_eeepc_capture_source, | ||
16939 | .unsol_event = alc662_eeepc_unsol_event, | 16945 | .unsol_event = alc662_eeepc_unsol_event, |
16946 | .setup = alc662_eeepc_setup, | ||
16940 | .init_hook = alc662_eeepc_inithook, | 16947 | .init_hook = alc662_eeepc_inithook, |
16941 | }, | 16948 | }, |
16942 | [ALC663_ASUS_M51VA] = { | 16949 | [ALC663_ASUS_M51VA] = { |
@@ -16947,8 +16954,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
16947 | .dig_out_nid = ALC662_DIGOUT_NID, | 16954 | .dig_out_nid = ALC662_DIGOUT_NID, |
16948 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 16955 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16949 | .channel_mode = alc662_3ST_2ch_modes, | 16956 | .channel_mode = alc662_3ST_2ch_modes, |
16950 | .input_mux = &alc663_m51va_capture_source, | ||
16951 | .unsol_event = alc663_m51va_unsol_event, | 16957 | .unsol_event = alc663_m51va_unsol_event, |
16958 | .setup = alc663_m51va_setup, | ||
16952 | .init_hook = alc663_m51va_inithook, | 16959 | .init_hook = alc663_m51va_inithook, |
16953 | }, | 16960 | }, |
16954 | [ALC663_ASUS_G71V] = { | 16961 | [ALC663_ASUS_G71V] = { |
@@ -16959,8 +16966,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
16959 | .dig_out_nid = ALC662_DIGOUT_NID, | 16966 | .dig_out_nid = ALC662_DIGOUT_NID, |
16960 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 16967 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16961 | .channel_mode = alc662_3ST_2ch_modes, | 16968 | .channel_mode = alc662_3ST_2ch_modes, |
16962 | .input_mux = &alc662_eeepc_capture_source, | ||
16963 | .unsol_event = alc663_g71v_unsol_event, | 16969 | .unsol_event = alc663_g71v_unsol_event, |
16970 | .setup = alc663_g71v_setup, | ||
16964 | .init_hook = alc663_g71v_inithook, | 16971 | .init_hook = alc663_g71v_inithook, |
16965 | }, | 16972 | }, |
16966 | [ALC663_ASUS_H13] = { | 16973 | [ALC663_ASUS_H13] = { |
@@ -16970,7 +16977,6 @@ static struct alc_config_preset alc662_presets[] = { | |||
16970 | .dac_nids = alc662_dac_nids, | 16977 | .dac_nids = alc662_dac_nids, |
16971 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 16978 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16972 | .channel_mode = alc662_3ST_2ch_modes, | 16979 | .channel_mode = alc662_3ST_2ch_modes, |
16973 | .input_mux = &alc663_m51va_capture_source, | ||
16974 | .unsol_event = alc663_m51va_unsol_event, | 16980 | .unsol_event = alc663_m51va_unsol_event, |
16975 | .init_hook = alc663_m51va_inithook, | 16981 | .init_hook = alc663_m51va_inithook, |
16976 | }, | 16982 | }, |
@@ -16984,6 +16990,7 @@ static struct alc_config_preset alc662_presets[] = { | |||
16984 | .channel_mode = alc662_3ST_6ch_modes, | 16990 | .channel_mode = alc662_3ST_6ch_modes, |
16985 | .input_mux = &alc663_capture_source, | 16991 | .input_mux = &alc663_capture_source, |
16986 | .unsol_event = alc663_g50v_unsol_event, | 16992 | .unsol_event = alc663_g50v_unsol_event, |
16993 | .setup = alc663_g50v_setup, | ||
16987 | .init_hook = alc663_g50v_inithook, | 16994 | .init_hook = alc663_g50v_inithook, |
16988 | }, | 16995 | }, |
16989 | [ALC663_ASUS_MODE1] = { | 16996 | [ALC663_ASUS_MODE1] = { |
@@ -16997,8 +17004,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
16997 | .dig_out_nid = ALC662_DIGOUT_NID, | 17004 | .dig_out_nid = ALC662_DIGOUT_NID, |
16998 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17005 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
16999 | .channel_mode = alc662_3ST_2ch_modes, | 17006 | .channel_mode = alc662_3ST_2ch_modes, |
17000 | .input_mux = &alc662_eeepc_capture_source, | ||
17001 | .unsol_event = alc663_mode1_unsol_event, | 17007 | .unsol_event = alc663_mode1_unsol_event, |
17008 | .setup = alc663_mode1_setup, | ||
17002 | .init_hook = alc663_mode1_inithook, | 17009 | .init_hook = alc663_mode1_inithook, |
17003 | }, | 17010 | }, |
17004 | [ALC662_ASUS_MODE2] = { | 17011 | [ALC662_ASUS_MODE2] = { |
@@ -17011,8 +17018,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17011 | .dig_out_nid = ALC662_DIGOUT_NID, | 17018 | .dig_out_nid = ALC662_DIGOUT_NID, |
17012 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17019 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17013 | .channel_mode = alc662_3ST_2ch_modes, | 17020 | .channel_mode = alc662_3ST_2ch_modes, |
17014 | .input_mux = &alc662_eeepc_capture_source, | ||
17015 | .unsol_event = alc662_mode2_unsol_event, | 17021 | .unsol_event = alc662_mode2_unsol_event, |
17022 | .setup = alc662_mode2_setup, | ||
17016 | .init_hook = alc662_mode2_inithook, | 17023 | .init_hook = alc662_mode2_inithook, |
17017 | }, | 17024 | }, |
17018 | [ALC663_ASUS_MODE3] = { | 17025 | [ALC663_ASUS_MODE3] = { |
@@ -17026,8 +17033,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17026 | .dig_out_nid = ALC662_DIGOUT_NID, | 17033 | .dig_out_nid = ALC662_DIGOUT_NID, |
17027 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17034 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17028 | .channel_mode = alc662_3ST_2ch_modes, | 17035 | .channel_mode = alc662_3ST_2ch_modes, |
17029 | .input_mux = &alc662_eeepc_capture_source, | ||
17030 | .unsol_event = alc663_mode3_unsol_event, | 17036 | .unsol_event = alc663_mode3_unsol_event, |
17037 | .setup = alc663_mode3_setup, | ||
17031 | .init_hook = alc663_mode3_inithook, | 17038 | .init_hook = alc663_mode3_inithook, |
17032 | }, | 17039 | }, |
17033 | [ALC663_ASUS_MODE4] = { | 17040 | [ALC663_ASUS_MODE4] = { |
@@ -17041,8 +17048,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17041 | .dig_out_nid = ALC662_DIGOUT_NID, | 17048 | .dig_out_nid = ALC662_DIGOUT_NID, |
17042 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17049 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17043 | .channel_mode = alc662_3ST_2ch_modes, | 17050 | .channel_mode = alc662_3ST_2ch_modes, |
17044 | .input_mux = &alc662_eeepc_capture_source, | ||
17045 | .unsol_event = alc663_mode4_unsol_event, | 17051 | .unsol_event = alc663_mode4_unsol_event, |
17052 | .setup = alc663_mode4_setup, | ||
17046 | .init_hook = alc663_mode4_inithook, | 17053 | .init_hook = alc663_mode4_inithook, |
17047 | }, | 17054 | }, |
17048 | [ALC663_ASUS_MODE5] = { | 17055 | [ALC663_ASUS_MODE5] = { |
@@ -17056,8 +17063,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17056 | .dig_out_nid = ALC662_DIGOUT_NID, | 17063 | .dig_out_nid = ALC662_DIGOUT_NID, |
17057 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17064 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17058 | .channel_mode = alc662_3ST_2ch_modes, | 17065 | .channel_mode = alc662_3ST_2ch_modes, |
17059 | .input_mux = &alc662_eeepc_capture_source, | ||
17060 | .unsol_event = alc663_mode5_unsol_event, | 17066 | .unsol_event = alc663_mode5_unsol_event, |
17067 | .setup = alc663_mode5_setup, | ||
17061 | .init_hook = alc663_mode5_inithook, | 17068 | .init_hook = alc663_mode5_inithook, |
17062 | }, | 17069 | }, |
17063 | [ALC663_ASUS_MODE6] = { | 17070 | [ALC663_ASUS_MODE6] = { |
@@ -17071,8 +17078,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17071 | .dig_out_nid = ALC662_DIGOUT_NID, | 17078 | .dig_out_nid = ALC662_DIGOUT_NID, |
17072 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17079 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17073 | .channel_mode = alc662_3ST_2ch_modes, | 17080 | .channel_mode = alc662_3ST_2ch_modes, |
17074 | .input_mux = &alc662_eeepc_capture_source, | ||
17075 | .unsol_event = alc663_mode6_unsol_event, | 17081 | .unsol_event = alc663_mode6_unsol_event, |
17082 | .setup = alc663_mode6_setup, | ||
17076 | .init_hook = alc663_mode6_inithook, | 17083 | .init_hook = alc663_mode6_inithook, |
17077 | }, | 17084 | }, |
17078 | [ALC272_DELL] = { | 17085 | [ALC272_DELL] = { |
@@ -17086,8 +17093,8 @@ static struct alc_config_preset alc662_presets[] = { | |||
17086 | .num_adc_nids = ARRAY_SIZE(alc272_adc_nids), | 17093 | .num_adc_nids = ARRAY_SIZE(alc272_adc_nids), |
17087 | .capsrc_nids = alc272_capsrc_nids, | 17094 | .capsrc_nids = alc272_capsrc_nids, |
17088 | .channel_mode = alc662_3ST_2ch_modes, | 17095 | .channel_mode = alc662_3ST_2ch_modes, |
17089 | .input_mux = &alc663_m51va_capture_source, | ||
17090 | .unsol_event = alc663_m51va_unsol_event, | 17096 | .unsol_event = alc663_m51va_unsol_event, |
17097 | .setup = alc663_m51va_setup, | ||
17091 | .init_hook = alc663_m51va_inithook, | 17098 | .init_hook = alc663_m51va_inithook, |
17092 | }, | 17099 | }, |
17093 | [ALC272_DELL_ZM1] = { | 17100 | [ALC272_DELL_ZM1] = { |
@@ -17098,11 +17105,11 @@ static struct alc_config_preset alc662_presets[] = { | |||
17098 | .dac_nids = alc662_dac_nids, | 17105 | .dac_nids = alc662_dac_nids, |
17099 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17106 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17100 | .adc_nids = alc662_adc_nids, | 17107 | .adc_nids = alc662_adc_nids, |
17101 | .num_adc_nids = ARRAY_SIZE(alc662_adc_nids), | 17108 | .num_adc_nids = 1, |
17102 | .capsrc_nids = alc662_capsrc_nids, | 17109 | .capsrc_nids = alc662_capsrc_nids, |
17103 | .channel_mode = alc662_3ST_2ch_modes, | 17110 | .channel_mode = alc662_3ST_2ch_modes, |
17104 | .input_mux = &alc663_m51va_capture_source, | ||
17105 | .unsol_event = alc663_m51va_unsol_event, | 17111 | .unsol_event = alc663_m51va_unsol_event, |
17112 | .setup = alc663_m51va_setup, | ||
17106 | .init_hook = alc663_m51va_inithook, | 17113 | .init_hook = alc663_m51va_inithook, |
17107 | }, | 17114 | }, |
17108 | [ALC272_SAMSUNG_NC10] = { | 17115 | [ALC272_SAMSUNG_NC10] = { |
@@ -17113,8 +17120,9 @@ static struct alc_config_preset alc662_presets[] = { | |||
17113 | .dac_nids = alc272_dac_nids, | 17120 | .dac_nids = alc272_dac_nids, |
17114 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), | 17121 | .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes), |
17115 | .channel_mode = alc662_3ST_2ch_modes, | 17122 | .channel_mode = alc662_3ST_2ch_modes, |
17116 | .input_mux = &alc272_nc10_capture_source, | 17123 | /*.input_mux = &alc272_nc10_capture_source,*/ |
17117 | .unsol_event = alc663_mode4_unsol_event, | 17124 | .unsol_event = alc663_mode4_unsol_event, |
17125 | .setup = alc663_mode4_setup, | ||
17118 | .init_hook = alc663_mode4_inithook, | 17126 | .init_hook = alc663_mode4_inithook, |
17119 | }, | 17127 | }, |
17120 | }; | 17128 | }; |
@@ -17166,13 +17174,25 @@ static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
17166 | if (err < 0) | 17174 | if (err < 0) |
17167 | return err; | 17175 | return err; |
17168 | } else { | 17176 | } else { |
17169 | sprintf(name, "%s Playback Volume", chname[i]); | 17177 | const char *pfx; |
17178 | if (cfg->line_outs == 1 && | ||
17179 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { | ||
17180 | if (!cfg->hp_pins) | ||
17181 | pfx = "Speaker"; | ||
17182 | else | ||
17183 | pfx = "PCM"; | ||
17184 | } else | ||
17185 | pfx = chname[i]; | ||
17186 | sprintf(name, "%s Playback Volume", pfx); | ||
17170 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, | 17187 | err = add_control(spec, ALC_CTL_WIDGET_VOL, name, |
17171 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | 17188 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
17172 | HDA_OUTPUT)); | 17189 | HDA_OUTPUT)); |
17173 | if (err < 0) | 17190 | if (err < 0) |
17174 | return err; | 17191 | return err; |
17175 | sprintf(name, "%s Playback Switch", chname[i]); | 17192 | if (cfg->line_outs == 1 && |
17193 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | ||
17194 | pfx = "Speaker"; | ||
17195 | sprintf(name, "%s Playback Switch", pfx); | ||
17176 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, | 17196 | err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, |
17177 | HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), | 17197 | HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i), |
17178 | 3, 0, HDA_INPUT)); | 17198 | 3, 0, HDA_INPUT)); |
@@ -17234,62 +17254,9 @@ static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, | |||
17234 | return 0; | 17254 | return 0; |
17235 | } | 17255 | } |
17236 | 17256 | ||
17237 | /* return the index of the src widget from the connection list of the nid. | ||
17238 | * return -1 if not found | ||
17239 | */ | ||
17240 | static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid, | ||
17241 | hda_nid_t src) | ||
17242 | { | ||
17243 | hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; | ||
17244 | int i, conns; | ||
17245 | |||
17246 | conns = snd_hda_get_connections(codec, nid, conn_list, | ||
17247 | ARRAY_SIZE(conn_list)); | ||
17248 | if (conns < 0) | ||
17249 | return -1; | ||
17250 | for (i = 0; i < conns; i++) | ||
17251 | if (conn_list[i] == src) | ||
17252 | return i; | ||
17253 | return -1; | ||
17254 | } | ||
17255 | |||
17256 | static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid) | ||
17257 | { | ||
17258 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); | ||
17259 | return (pincap & AC_PINCAP_IN) != 0; | ||
17260 | } | ||
17261 | |||
17262 | /* create playback/capture controls for input pins */ | 17257 | /* create playback/capture controls for input pins */ |
17263 | static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec, | 17258 | #define alc662_auto_create_input_ctls \ |
17264 | const struct auto_pin_cfg *cfg) | 17259 | alc880_auto_create_input_ctls |
17265 | { | ||
17266 | struct alc_spec *spec = codec->spec; | ||
17267 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
17268 | int i, err, idx; | ||
17269 | |||
17270 | for (i = 0; i < AUTO_PIN_LAST; i++) { | ||
17271 | if (alc662_is_input_pin(codec, cfg->input_pins[i])) { | ||
17272 | idx = alc662_input_pin_idx(codec, 0x0b, | ||
17273 | cfg->input_pins[i]); | ||
17274 | if (idx >= 0) { | ||
17275 | err = new_analog_input(spec, cfg->input_pins[i], | ||
17276 | auto_pin_cfg_labels[i], | ||
17277 | idx, 0x0b); | ||
17278 | if (err < 0) | ||
17279 | return err; | ||
17280 | } | ||
17281 | idx = alc662_input_pin_idx(codec, 0x22, | ||
17282 | cfg->input_pins[i]); | ||
17283 | if (idx >= 0) { | ||
17284 | imux->items[imux->num_items].label = | ||
17285 | auto_pin_cfg_labels[i]; | ||
17286 | imux->items[imux->num_items].index = idx; | ||
17287 | imux->num_items++; | ||
17288 | } | ||
17289 | } | ||
17290 | } | ||
17291 | return 0; | ||
17292 | } | ||
17293 | 17260 | ||
17294 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, | 17261 | static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, |
17295 | hda_nid_t nid, int pin_type, | 17262 | hda_nid_t nid, int pin_type, |
@@ -17343,7 +17310,7 @@ static void alc662_auto_init_analog_input(struct hda_codec *codec) | |||
17343 | 17310 | ||
17344 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 17311 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
17345 | hda_nid_t nid = spec->autocfg.input_pins[i]; | 17312 | hda_nid_t nid = spec->autocfg.input_pins[i]; |
17346 | if (alc662_is_input_pin(codec, nid)) { | 17313 | if (alc_is_input_pin(codec, nid)) { |
17347 | alc_set_input_pin(codec, nid, i); | 17314 | alc_set_input_pin(codec, nid, i); |
17348 | if (nid != ALC662_PIN_CD_NID && | 17315 | if (nid != ALC662_PIN_CD_NID && |
17349 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) | 17316 | (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) |
@@ -17384,7 +17351,7 @@ static int alc662_parse_auto_config(struct hda_codec *codec) | |||
17384 | "Headphone"); | 17351 | "Headphone"); |
17385 | if (err < 0) | 17352 | if (err < 0) |
17386 | return err; | 17353 | return err; |
17387 | err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg); | 17354 | err = alc662_auto_create_input_ctls(codec, &spec->autocfg); |
17388 | if (err < 0) | 17355 | if (err < 0) |
17389 | return err; | 17356 | return err; |
17390 | 17357 | ||
@@ -17441,8 +17408,8 @@ static int patch_alc662(struct hda_codec *codec) | |||
17441 | alc662_models, | 17408 | alc662_models, |
17442 | alc662_cfg_tbl); | 17409 | alc662_cfg_tbl); |
17443 | if (board_config < 0) { | 17410 | if (board_config < 0) { |
17444 | printk(KERN_INFO "hda_codec: Unknown model for %s, " | 17411 | printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
17445 | "trying auto-probe from BIOS...\n", codec->chip_name); | 17412 | codec->chip_name); |
17446 | board_config = ALC662_AUTO; | 17413 | board_config = ALC662_AUTO; |
17447 | } | 17414 | } |
17448 | 17415 | ||
@@ -17467,7 +17434,7 @@ static int patch_alc662(struct hda_codec *codec) | |||
17467 | } | 17434 | } |
17468 | 17435 | ||
17469 | if (board_config != ALC662_AUTO) | 17436 | if (board_config != ALC662_AUTO) |
17470 | setup_preset(spec, &alc662_presets[board_config]); | 17437 | setup_preset(codec, &alc662_presets[board_config]); |
17471 | 17438 | ||
17472 | spec->stream_analog_playback = &alc662_pcm_analog_playback; | 17439 | spec->stream_analog_playback = &alc662_pcm_analog_playback; |
17473 | spec->stream_analog_capture = &alc662_pcm_analog_capture; | 17440 | spec->stream_analog_capture = &alc662_pcm_analog_capture; |
@@ -17475,12 +17442,15 @@ static int patch_alc662(struct hda_codec *codec) | |||
17475 | spec->stream_digital_playback = &alc662_pcm_digital_playback; | 17442 | spec->stream_digital_playback = &alc662_pcm_digital_playback; |
17476 | spec->stream_digital_capture = &alc662_pcm_digital_capture; | 17443 | spec->stream_digital_capture = &alc662_pcm_digital_capture; |
17477 | 17444 | ||
17478 | spec->adc_nids = alc662_adc_nids; | 17445 | if (!spec->adc_nids) { |
17479 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | 17446 | spec->adc_nids = alc662_adc_nids; |
17480 | spec->capsrc_nids = alc662_capsrc_nids; | 17447 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); |
17448 | } | ||
17449 | if (!spec->capsrc_nids) | ||
17450 | spec->capsrc_nids = alc662_capsrc_nids; | ||
17481 | 17451 | ||
17482 | if (!spec->cap_mixer) | 17452 | if (!spec->cap_mixer) |
17483 | set_capture_mixer(spec); | 17453 | set_capture_mixer(codec); |
17484 | if (codec->vendor_id == 0x10ec0662) | 17454 | if (codec->vendor_id == 0x10ec0662) |
17485 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 17455 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
17486 | else | 17456 | else |
@@ -17516,23 +17486,23 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
17516 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, | 17486 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
17517 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, | 17487 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
17518 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", | 17488 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
17519 | .patch = patch_alc883 }, | 17489 | .patch = patch_alc882 }, |
17520 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | 17490 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
17521 | .patch = patch_alc662 }, | 17491 | .patch = patch_alc662 }, |
17522 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, | 17492 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
17523 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, | 17493 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
17524 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, | 17494 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
17525 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, | 17495 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
17526 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", | 17496 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
17527 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ | 17497 | .patch = patch_alc882 }, |
17528 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", | 17498 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
17529 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ | 17499 | .patch = patch_alc882 }, |
17530 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, | 17500 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
17531 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, | 17501 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
17532 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", | 17502 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
17533 | .patch = patch_alc883 }, | 17503 | .patch = patch_alc882 }, |
17534 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, | 17504 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
17535 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, | 17505 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
17536 | {} /* terminator */ | 17506 | {} /* terminator */ |
17537 | }; | 17507 | }; |
17538 | 17508 | ||
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 14f3c3e0f62d..e31e53dc6962 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -40,6 +40,8 @@ enum { | |||
40 | STAC_INSERT_EVENT, | 40 | STAC_INSERT_EVENT, |
41 | STAC_PWR_EVENT, | 41 | STAC_PWR_EVENT, |
42 | STAC_HP_EVENT, | 42 | STAC_HP_EVENT, |
43 | STAC_LO_EVENT, | ||
44 | STAC_MIC_EVENT, | ||
43 | }; | 45 | }; |
44 | 46 | ||
45 | enum { | 47 | enum { |
@@ -76,10 +78,12 @@ enum { | |||
76 | STAC_92HD73XX_AUTO, | 78 | STAC_92HD73XX_AUTO, |
77 | STAC_92HD73XX_NO_JD, /* no jack-detection */ | 79 | STAC_92HD73XX_NO_JD, /* no jack-detection */ |
78 | STAC_92HD73XX_REF, | 80 | STAC_92HD73XX_REF, |
81 | STAC_92HD73XX_INTEL, | ||
79 | STAC_DELL_M6_AMIC, | 82 | STAC_DELL_M6_AMIC, |
80 | STAC_DELL_M6_DMIC, | 83 | STAC_DELL_M6_DMIC, |
81 | STAC_DELL_M6_BOTH, | 84 | STAC_DELL_M6_BOTH, |
82 | STAC_DELL_EQ, | 85 | STAC_DELL_EQ, |
86 | STAC_ALIENWARE_M17X, | ||
83 | STAC_92HD73XX_MODELS | 87 | STAC_92HD73XX_MODELS |
84 | }; | 88 | }; |
85 | 89 | ||
@@ -176,6 +180,12 @@ struct sigmatel_jack { | |||
176 | struct snd_jack *jack; | 180 | struct snd_jack *jack; |
177 | }; | 181 | }; |
178 | 182 | ||
183 | struct sigmatel_mic_route { | ||
184 | hda_nid_t pin; | ||
185 | unsigned char mux_idx; | ||
186 | unsigned char dmux_idx; | ||
187 | }; | ||
188 | |||
179 | struct sigmatel_spec { | 189 | struct sigmatel_spec { |
180 | struct snd_kcontrol_new *mixers[4]; | 190 | struct snd_kcontrol_new *mixers[4]; |
181 | unsigned int num_mixers; | 191 | unsigned int num_mixers; |
@@ -187,6 +197,7 @@ struct sigmatel_spec { | |||
187 | unsigned int hp_detect: 1; | 197 | unsigned int hp_detect: 1; |
188 | unsigned int spdif_mute: 1; | 198 | unsigned int spdif_mute: 1; |
189 | unsigned int check_volume_offset:1; | 199 | unsigned int check_volume_offset:1; |
200 | unsigned int auto_mic:1; | ||
190 | 201 | ||
191 | /* gpio lines */ | 202 | /* gpio lines */ |
192 | unsigned int eapd_mask; | 203 | unsigned int eapd_mask; |
@@ -218,7 +229,6 @@ struct sigmatel_spec { | |||
218 | 229 | ||
219 | /* playback */ | 230 | /* playback */ |
220 | struct hda_input_mux *mono_mux; | 231 | struct hda_input_mux *mono_mux; |
221 | struct hda_input_mux *amp_mux; | ||
222 | unsigned int cur_mmux; | 232 | unsigned int cur_mmux; |
223 | struct hda_multi_out multiout; | 233 | struct hda_multi_out multiout; |
224 | hda_nid_t dac_nids[5]; | 234 | hda_nid_t dac_nids[5]; |
@@ -238,6 +248,15 @@ struct sigmatel_spec { | |||
238 | unsigned int num_dmuxes; | 248 | unsigned int num_dmuxes; |
239 | hda_nid_t *smux_nids; | 249 | hda_nid_t *smux_nids; |
240 | unsigned int num_smuxes; | 250 | unsigned int num_smuxes; |
251 | unsigned int num_analog_muxes; | ||
252 | |||
253 | unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */ | ||
254 | unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */ | ||
255 | unsigned int num_caps; /* number of capture volume/switch elements */ | ||
256 | |||
257 | struct sigmatel_mic_route ext_mic; | ||
258 | struct sigmatel_mic_route int_mic; | ||
259 | |||
241 | const char **spdif_labels; | 260 | const char **spdif_labels; |
242 | 261 | ||
243 | hda_nid_t dig_in_nid; | 262 | hda_nid_t dig_in_nid; |
@@ -262,7 +281,6 @@ struct sigmatel_spec { | |||
262 | unsigned int cur_smux[2]; | 281 | unsigned int cur_smux[2]; |
263 | unsigned int cur_amux; | 282 | unsigned int cur_amux; |
264 | hda_nid_t *amp_nids; | 283 | hda_nid_t *amp_nids; |
265 | unsigned int num_amps; | ||
266 | unsigned int powerdown_adcs; | 284 | unsigned int powerdown_adcs; |
267 | 285 | ||
268 | /* i/o switches */ | 286 | /* i/o switches */ |
@@ -281,7 +299,6 @@ struct sigmatel_spec { | |||
281 | struct hda_input_mux private_dimux; | 299 | struct hda_input_mux private_dimux; |
282 | struct hda_input_mux private_imux; | 300 | struct hda_input_mux private_imux; |
283 | struct hda_input_mux private_smux; | 301 | struct hda_input_mux private_smux; |
284 | struct hda_input_mux private_amp_mux; | ||
285 | struct hda_input_mux private_mono_mux; | 302 | struct hda_input_mux private_mono_mux; |
286 | }; | 303 | }; |
287 | 304 | ||
@@ -310,11 +327,6 @@ static hda_nid_t stac92hd73xx_adc_nids[2] = { | |||
310 | 0x1a, 0x1b | 327 | 0x1a, 0x1b |
311 | }; | 328 | }; |
312 | 329 | ||
313 | #define DELL_M6_AMP 2 | ||
314 | static hda_nid_t stac92hd73xx_amp_nids[3] = { | ||
315 | 0x0b, 0x0c, 0x0e | ||
316 | }; | ||
317 | |||
318 | #define STAC92HD73XX_NUM_DMICS 2 | 330 | #define STAC92HD73XX_NUM_DMICS 2 |
319 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { | 331 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
320 | 0x13, 0x14, 0 | 332 | 0x13, 0x14, 0 |
@@ -322,8 +334,8 @@ static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { | |||
322 | 334 | ||
323 | #define STAC92HD73_DAC_COUNT 5 | 335 | #define STAC92HD73_DAC_COUNT 5 |
324 | 336 | ||
325 | static hda_nid_t stac92hd73xx_mux_nids[4] = { | 337 | static hda_nid_t stac92hd73xx_mux_nids[2] = { |
326 | 0x28, 0x29, 0x2a, 0x2b, | 338 | 0x20, 0x21, |
327 | }; | 339 | }; |
328 | 340 | ||
329 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { | 341 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
@@ -334,14 +346,16 @@ static hda_nid_t stac92hd73xx_smux_nids[2] = { | |||
334 | 0x22, 0x23, | 346 | 0x22, 0x23, |
335 | }; | 347 | }; |
336 | 348 | ||
337 | #define STAC92HD83XXX_NUM_DMICS 2 | 349 | #define STAC92HD73XX_NUM_CAPS 2 |
338 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { | 350 | static unsigned long stac92hd73xx_capvols[] = { |
339 | 0x11, 0x12, 0 | 351 | HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT), |
352 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | ||
340 | }; | 353 | }; |
354 | #define stac92hd73xx_capsws stac92hd73xx_capvols | ||
341 | 355 | ||
342 | #define STAC92HD83_DAC_COUNT 3 | 356 | #define STAC92HD83_DAC_COUNT 3 |
343 | 357 | ||
344 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { | 358 | static hda_nid_t stac92hd83xxx_mux_nids[2] = { |
345 | 0x17, 0x18, | 359 | 0x17, 0x18, |
346 | }; | 360 | }; |
347 | 361 | ||
@@ -361,9 +375,12 @@ static unsigned int stac92hd83xxx_pwr_mapping[4] = { | |||
361 | 0x03, 0x0c, 0x20, 0x40, | 375 | 0x03, 0x0c, 0x20, 0x40, |
362 | }; | 376 | }; |
363 | 377 | ||
364 | static hda_nid_t stac92hd83xxx_amp_nids[1] = { | 378 | #define STAC92HD83XXX_NUM_CAPS 2 |
365 | 0xc, | 379 | static unsigned long stac92hd83xxx_capvols[] = { |
380 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), | ||
381 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT), | ||
366 | }; | 382 | }; |
383 | #define stac92hd83xxx_capsws stac92hd83xxx_capvols | ||
367 | 384 | ||
368 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { | 385 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
369 | 0x0a, 0x0d, 0x0f | 386 | 0x0a, 0x0d, 0x0f |
@@ -394,6 +411,13 @@ static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { | |||
394 | 0x22, 0 | 411 | 0x22, 0 |
395 | }; | 412 | }; |
396 | 413 | ||
414 | #define STAC92HD71BXX_NUM_CAPS 2 | ||
415 | static unsigned long stac92hd71bxx_capvols[] = { | ||
416 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), | ||
417 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), | ||
418 | }; | ||
419 | #define stac92hd71bxx_capsws stac92hd71bxx_capvols | ||
420 | |||
397 | static hda_nid_t stac925x_adc_nids[1] = { | 421 | static hda_nid_t stac925x_adc_nids[1] = { |
398 | 0x03, | 422 | 0x03, |
399 | }; | 423 | }; |
@@ -415,6 +439,13 @@ static hda_nid_t stac925x_dmux_nids[1] = { | |||
415 | 0x14, | 439 | 0x14, |
416 | }; | 440 | }; |
417 | 441 | ||
442 | static unsigned long stac925x_capvols[] = { | ||
443 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), | ||
444 | }; | ||
445 | static unsigned long stac925x_capsws[] = { | ||
446 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | ||
447 | }; | ||
448 | |||
418 | static hda_nid_t stac922x_adc_nids[2] = { | 449 | static hda_nid_t stac922x_adc_nids[2] = { |
419 | 0x06, 0x07, | 450 | 0x06, 0x07, |
420 | }; | 451 | }; |
@@ -423,6 +454,13 @@ static hda_nid_t stac922x_mux_nids[2] = { | |||
423 | 0x12, 0x13, | 454 | 0x12, 0x13, |
424 | }; | 455 | }; |
425 | 456 | ||
457 | #define STAC922X_NUM_CAPS 2 | ||
458 | static unsigned long stac922x_capvols[] = { | ||
459 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT), | ||
460 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), | ||
461 | }; | ||
462 | #define stac922x_capsws stac922x_capvols | ||
463 | |||
426 | static hda_nid_t stac927x_slave_dig_outs[2] = { | 464 | static hda_nid_t stac927x_slave_dig_outs[2] = { |
427 | 0x1f, 0, | 465 | 0x1f, 0, |
428 | }; | 466 | }; |
@@ -452,6 +490,18 @@ static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { | |||
452 | 0x13, 0x14, 0 | 490 | 0x13, 0x14, 0 |
453 | }; | 491 | }; |
454 | 492 | ||
493 | #define STAC927X_NUM_CAPS 3 | ||
494 | static unsigned long stac927x_capvols[] = { | ||
495 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), | ||
496 | HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT), | ||
497 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT), | ||
498 | }; | ||
499 | static unsigned long stac927x_capsws[] = { | ||
500 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | ||
501 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), | ||
502 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), | ||
503 | }; | ||
504 | |||
455 | static const char *stac927x_spdif_labels[5] = { | 505 | static const char *stac927x_spdif_labels[5] = { |
456 | "Digital Playback", "ADAT", "Analog Mux 1", | 506 | "Digital Playback", "ADAT", "Analog Mux 1", |
457 | "Analog Mux 2", "Analog Mux 3" | 507 | "Analog Mux 2", "Analog Mux 3" |
@@ -478,6 +528,16 @@ static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { | |||
478 | 0x17, 0x18, 0 | 528 | 0x17, 0x18, 0 |
479 | }; | 529 | }; |
480 | 530 | ||
531 | #define STAC9205_NUM_CAPS 2 | ||
532 | static unsigned long stac9205_capvols[] = { | ||
533 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT), | ||
534 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT), | ||
535 | }; | ||
536 | static unsigned long stac9205_capsws[] = { | ||
537 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), | ||
538 | HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT), | ||
539 | }; | ||
540 | |||
481 | static hda_nid_t stac9200_pin_nids[8] = { | 541 | static hda_nid_t stac9200_pin_nids[8] = { |
482 | 0x08, 0x09, 0x0d, 0x0e, | 542 | 0x08, 0x09, 0x0d, 0x0e, |
483 | 0x0f, 0x10, 0x11, 0x12, | 543 | 0x0f, 0x10, 0x11, 0x12, |
@@ -528,34 +588,6 @@ static hda_nid_t stac9205_pin_nids[12] = { | |||
528 | 0x21, 0x22, | 588 | 0x21, 0x22, |
529 | }; | 589 | }; |
530 | 590 | ||
531 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info | ||
532 | |||
533 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, | ||
534 | struct snd_ctl_elem_value *ucontrol) | ||
535 | { | ||
536 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
537 | struct sigmatel_spec *spec = codec->spec; | ||
538 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; | ||
539 | |||
540 | kcontrol->private_value ^= get_amp_nid(kcontrol); | ||
541 | kcontrol->private_value |= nid; | ||
542 | |||
543 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); | ||
544 | } | ||
545 | |||
546 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, | ||
547 | struct snd_ctl_elem_value *ucontrol) | ||
548 | { | ||
549 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
550 | struct sigmatel_spec *spec = codec->spec; | ||
551 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; | ||
552 | |||
553 | kcontrol->private_value ^= get_amp_nid(kcontrol); | ||
554 | kcontrol->private_value |= nid; | ||
555 | |||
556 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); | ||
557 | } | ||
558 | |||
559 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, | 591 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
560 | struct snd_ctl_elem_info *uinfo) | 592 | struct snd_ctl_elem_info *uinfo) |
561 | { | 593 | { |
@@ -692,9 +724,35 @@ static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
692 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 724 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
693 | struct sigmatel_spec *spec = codec->spec; | 725 | struct sigmatel_spec *spec = codec->spec; |
694 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 726 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
695 | 727 | const struct hda_input_mux *imux = spec->input_mux; | |
696 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | 728 | unsigned int idx, prev_idx; |
697 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); | 729 | |
730 | idx = ucontrol->value.enumerated.item[0]; | ||
731 | if (idx >= imux->num_items) | ||
732 | idx = imux->num_items - 1; | ||
733 | prev_idx = spec->cur_mux[adc_idx]; | ||
734 | if (prev_idx == idx) | ||
735 | return 0; | ||
736 | if (idx < spec->num_analog_muxes) { | ||
737 | snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0, | ||
738 | AC_VERB_SET_CONNECT_SEL, | ||
739 | imux->items[idx].index); | ||
740 | if (prev_idx >= spec->num_analog_muxes) { | ||
741 | imux = spec->dinput_mux; | ||
742 | /* 0 = analog */ | ||
743 | snd_hda_codec_write_cache(codec, | ||
744 | spec->dmux_nids[adc_idx], 0, | ||
745 | AC_VERB_SET_CONNECT_SEL, | ||
746 | imux->items[0].index); | ||
747 | } | ||
748 | } else { | ||
749 | imux = spec->dinput_mux; | ||
750 | snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0, | ||
751 | AC_VERB_SET_CONNECT_SEL, | ||
752 | imux->items[idx - 1].index); | ||
753 | } | ||
754 | spec->cur_mux[adc_idx] = idx; | ||
755 | return 1; | ||
698 | } | 756 | } |
699 | 757 | ||
700 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, | 758 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
@@ -725,41 +783,6 @@ static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
725 | spec->mono_nid, &spec->cur_mmux); | 783 | spec->mono_nid, &spec->cur_mmux); |
726 | } | 784 | } |
727 | 785 | ||
728 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, | ||
729 | struct snd_ctl_elem_info *uinfo) | ||
730 | { | ||
731 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
732 | struct sigmatel_spec *spec = codec->spec; | ||
733 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); | ||
734 | } | ||
735 | |||
736 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, | ||
737 | struct snd_ctl_elem_value *ucontrol) | ||
738 | { | ||
739 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
740 | struct sigmatel_spec *spec = codec->spec; | ||
741 | |||
742 | ucontrol->value.enumerated.item[0] = spec->cur_amux; | ||
743 | return 0; | ||
744 | } | ||
745 | |||
746 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, | ||
747 | struct snd_ctl_elem_value *ucontrol) | ||
748 | { | ||
749 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
750 | struct sigmatel_spec *spec = codec->spec; | ||
751 | struct snd_kcontrol *ctl = | ||
752 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); | ||
753 | if (!ctl) | ||
754 | return -EINVAL; | ||
755 | |||
756 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | | ||
757 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); | ||
758 | |||
759 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, | ||
760 | 0, &spec->cur_amux); | ||
761 | } | ||
762 | |||
763 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info | 786 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
764 | 787 | ||
765 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, | 788 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
@@ -827,84 +850,16 @@ static struct hda_verb stac9200_eapd_init[] = { | |||
827 | {} | 850 | {} |
828 | }; | 851 | }; |
829 | 852 | ||
830 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { | ||
831 | /* set master volume and direct control */ | ||
832 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | ||
833 | /* setup adcs to point to mixer */ | ||
834 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
835 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
836 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
837 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
838 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
839 | /* setup import muxs */ | ||
840 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
841 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
842 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
843 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
844 | {} | ||
845 | }; | ||
846 | |||
847 | static struct hda_verb dell_eq_core_init[] = { | 853 | static struct hda_verb dell_eq_core_init[] = { |
848 | /* set master volume to max value without distortion | 854 | /* set master volume to max value without distortion |
849 | * and direct control */ | 855 | * and direct control */ |
850 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, | 856 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
851 | /* setup adcs to point to mixer */ | ||
852 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
853 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
854 | /* setup import muxs */ | ||
855 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
856 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
857 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
858 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
859 | {} | ||
860 | }; | ||
861 | |||
862 | static struct hda_verb dell_m6_core_init[] = { | ||
863 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | ||
864 | /* setup adcs to point to mixer */ | ||
865 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
866 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
867 | /* setup import muxs */ | ||
868 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
869 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
870 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
871 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
872 | {} | 857 | {} |
873 | }; | 858 | }; |
874 | 859 | ||
875 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { | 860 | static struct hda_verb stac92hd73xx_core_init[] = { |
876 | /* set master volume and direct control */ | 861 | /* set master volume and direct control */ |
877 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 862 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
878 | /* setup adcs to point to mixer */ | ||
879 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
880 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
881 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
882 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
883 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
884 | /* setup import muxs */ | ||
885 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
886 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
887 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
888 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
889 | {} | ||
890 | }; | ||
891 | |||
892 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { | ||
893 | /* set master volume and direct control */ | ||
894 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | ||
895 | /* dac3 is connected to import3 mux */ | ||
896 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, | ||
897 | /* setup adcs to point to mixer */ | ||
898 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
899 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | ||
900 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
901 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
902 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
903 | /* setup import muxs */ | ||
904 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
905 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
906 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
907 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
908 | {} | 863 | {} |
909 | }; | 864 | }; |
910 | 865 | ||
@@ -924,19 +879,6 @@ static struct hda_verb stac92hd71bxx_core_init[] = { | |||
924 | {} | 879 | {} |
925 | }; | 880 | }; |
926 | 881 | ||
927 | #define HD_DISABLE_PORTF 1 | ||
928 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { | ||
929 | /* start of config #1 */ | ||
930 | |||
931 | /* connect port 0f to audio mixer */ | ||
932 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, | ||
933 | /* start of config #2 */ | ||
934 | |||
935 | /* set master volume and direct control */ | ||
936 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | ||
937 | {} | ||
938 | }; | ||
939 | |||
940 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { | 882 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
941 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ | 883 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
942 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 884 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
@@ -995,31 +937,6 @@ static struct hda_verb stac9205_core_init[] = { | |||
995 | .put = stac92xx_mono_mux_enum_put, \ | 937 | .put = stac92xx_mono_mux_enum_put, \ |
996 | } | 938 | } |
997 | 939 | ||
998 | #define STAC_AMP_MUX \ | ||
999 | { \ | ||
1000 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
1001 | .name = "Amp Selector Capture Switch", \ | ||
1002 | .count = 1, \ | ||
1003 | .info = stac92xx_amp_mux_enum_info, \ | ||
1004 | .get = stac92xx_amp_mux_enum_get, \ | ||
1005 | .put = stac92xx_amp_mux_enum_put, \ | ||
1006 | } | ||
1007 | |||
1008 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ | ||
1009 | { \ | ||
1010 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
1011 | .name = xname, \ | ||
1012 | .index = 0, \ | ||
1013 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | ||
1014 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | ||
1015 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ | ||
1016 | .info = stac92xx_amp_volume_info, \ | ||
1017 | .get = stac92xx_amp_volume_get, \ | ||
1018 | .put = stac92xx_amp_volume_put, \ | ||
1019 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ | ||
1020 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ | ||
1021 | } | ||
1022 | |||
1023 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ | 940 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
1024 | { \ | 941 | { \ |
1025 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 942 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
@@ -1050,34 +967,6 @@ static struct snd_kcontrol_new stac9200_mixer[] = { | |||
1050 | { } /* end */ | 967 | { } /* end */ |
1051 | }; | 968 | }; |
1052 | 969 | ||
1053 | #define DELL_M6_MIXER 6 | ||
1054 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { | ||
1055 | /* start of config #1 */ | ||
1056 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), | ||
1057 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), | ||
1058 | |||
1059 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), | ||
1060 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), | ||
1061 | |||
1062 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), | ||
1063 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), | ||
1064 | |||
1065 | /* start of config #2 */ | ||
1066 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), | ||
1067 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), | ||
1068 | |||
1069 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), | ||
1070 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), | ||
1071 | |||
1072 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1073 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1074 | |||
1075 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1076 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1077 | |||
1078 | { } /* end */ | ||
1079 | }; | ||
1080 | |||
1081 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { | 970 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
1082 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), | 971 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
1083 | {} | 972 | {} |
@@ -1093,134 +982,14 @@ static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { | |||
1093 | {} | 982 | {} |
1094 | }; | 983 | }; |
1095 | 984 | ||
1096 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { | ||
1097 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1098 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1099 | |||
1100 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1101 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1102 | |||
1103 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), | ||
1104 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), | ||
1105 | |||
1106 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), | ||
1107 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), | ||
1108 | |||
1109 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), | ||
1110 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), | ||
1111 | |||
1112 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), | ||
1113 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), | ||
1114 | |||
1115 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), | ||
1116 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), | ||
1117 | { } /* end */ | ||
1118 | }; | ||
1119 | |||
1120 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { | ||
1121 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1122 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), | ||
1123 | |||
1124 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1125 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), | ||
1126 | |||
1127 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), | ||
1128 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), | ||
1129 | |||
1130 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), | ||
1131 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), | ||
1132 | |||
1133 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), | ||
1134 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), | ||
1135 | |||
1136 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), | ||
1137 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), | ||
1138 | |||
1139 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), | ||
1140 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), | ||
1141 | { } /* end */ | ||
1142 | }; | ||
1143 | |||
1144 | |||
1145 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { | ||
1146 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT), | ||
1147 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT), | ||
1148 | |||
1149 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), | ||
1150 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), | ||
1151 | |||
1152 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), | ||
1153 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), | ||
1154 | |||
1155 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), | ||
1156 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), | ||
1157 | |||
1158 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), | ||
1159 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), | ||
1160 | |||
1161 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), | ||
1162 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), | ||
1163 | |||
1164 | /* | ||
1165 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), | ||
1166 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), | ||
1167 | */ | ||
1168 | { } /* end */ | ||
1169 | }; | ||
1170 | |||
1171 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { | ||
1172 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), | ||
1173 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), | ||
1174 | |||
1175 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), | ||
1176 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), | ||
1177 | /* analog pc-beep replaced with digital beep support */ | ||
1178 | /* | ||
1179 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), | ||
1180 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), | ||
1181 | */ | ||
1182 | |||
1183 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), | ||
1184 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), | ||
1185 | |||
1186 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), | ||
1187 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), | ||
1188 | |||
1189 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), | ||
1190 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), | ||
1191 | |||
1192 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), | ||
1193 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), | ||
1194 | { } /* end */ | ||
1195 | }; | ||
1196 | 985 | ||
1197 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { | 986 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
1198 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) | 987 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
1199 | }; | 988 | }; |
1200 | 989 | ||
1201 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { | ||
1202 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), | ||
1203 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), | ||
1204 | |||
1205 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), | ||
1206 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), | ||
1207 | { } /* end */ | ||
1208 | }; | ||
1209 | |||
1210 | static struct snd_kcontrol_new stac925x_mixer[] = { | 990 | static struct snd_kcontrol_new stac925x_mixer[] = { |
1211 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), | 991 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
1212 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), | 992 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), |
1213 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), | ||
1214 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), | ||
1215 | { } /* end */ | ||
1216 | }; | ||
1217 | |||
1218 | static struct snd_kcontrol_new stac9205_mixer[] = { | ||
1219 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), | ||
1220 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), | ||
1221 | |||
1222 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), | ||
1223 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), | ||
1224 | { } /* end */ | 993 | { } /* end */ |
1225 | }; | 994 | }; |
1226 | 995 | ||
@@ -1229,29 +998,6 @@ static struct snd_kcontrol_new stac9205_loopback[] = { | |||
1229 | {} | 998 | {} |
1230 | }; | 999 | }; |
1231 | 1000 | ||
1232 | /* This needs to be generated dynamically based on sequence */ | ||
1233 | static struct snd_kcontrol_new stac922x_mixer[] = { | ||
1234 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), | ||
1235 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), | ||
1236 | |||
1237 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), | ||
1238 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), | ||
1239 | { } /* end */ | ||
1240 | }; | ||
1241 | |||
1242 | |||
1243 | static struct snd_kcontrol_new stac927x_mixer[] = { | ||
1244 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), | ||
1245 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), | ||
1246 | |||
1247 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), | ||
1248 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), | ||
1249 | |||
1250 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), | ||
1251 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), | ||
1252 | { } /* end */ | ||
1253 | }; | ||
1254 | |||
1255 | static struct snd_kcontrol_new stac927x_loopback[] = { | 1001 | static struct snd_kcontrol_new stac927x_loopback[] = { |
1256 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), | 1002 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
1257 | {} | 1003 | {} |
@@ -1309,16 +1055,19 @@ static int stac92xx_build_controls(struct hda_codec *codec) | |||
1309 | int err; | 1055 | int err; |
1310 | int i; | 1056 | int i; |
1311 | 1057 | ||
1312 | err = snd_hda_add_new_ctls(codec, spec->mixer); | 1058 | if (spec->mixer) { |
1313 | if (err < 0) | 1059 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
1314 | return err; | 1060 | if (err < 0) |
1061 | return err; | ||
1062 | } | ||
1315 | 1063 | ||
1316 | for (i = 0; i < spec->num_mixers; i++) { | 1064 | for (i = 0; i < spec->num_mixers; i++) { |
1317 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | 1065 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
1318 | if (err < 0) | 1066 | if (err < 0) |
1319 | return err; | 1067 | return err; |
1320 | } | 1068 | } |
1321 | if (spec->num_dmuxes > 0) { | 1069 | if (!spec->auto_mic && spec->num_dmuxes > 0 && |
1070 | snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { | ||
1322 | stac_dmux_mixer.count = spec->num_dmuxes; | 1071 | stac_dmux_mixer.count = spec->num_dmuxes; |
1323 | err = snd_hda_ctl_add(codec, | 1072 | err = snd_hda_ctl_add(codec, |
1324 | snd_ctl_new1(&stac_dmux_mixer, codec)); | 1073 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
@@ -1590,8 +1339,6 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = { | |||
1590 | /* SigmaTel reference board */ | 1339 | /* SigmaTel reference board */ |
1591 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 1340 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
1592 | "DFI LanParty", STAC_REF), | 1341 | "DFI LanParty", STAC_REF), |
1593 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, | ||
1594 | "SigmaTel",STAC_9205_REF), | ||
1595 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 1342 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
1596 | "DFI LanParty", STAC_REF), | 1343 | "DFI LanParty", STAC_REF), |
1597 | /* Dell laptops have BIOS problem */ | 1344 | /* Dell laptops have BIOS problem */ |
@@ -1767,22 +1514,32 @@ static unsigned int dell_m6_pin_configs[13] = { | |||
1767 | 0x4f0000f0, | 1514 | 0x4f0000f0, |
1768 | }; | 1515 | }; |
1769 | 1516 | ||
1517 | static unsigned int alienware_m17x_pin_configs[13] = { | ||
1518 | 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020, | ||
1519 | 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0, | ||
1520 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, | ||
1521 | 0x904601b0, | ||
1522 | }; | ||
1523 | |||
1770 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { | 1524 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
1771 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, | 1525 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
1772 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, | 1526 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
1773 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, | 1527 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
1774 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, | 1528 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
1775 | [STAC_DELL_EQ] = dell_m6_pin_configs, | 1529 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
1530 | [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs, | ||
1776 | }; | 1531 | }; |
1777 | 1532 | ||
1778 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { | 1533 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
1779 | [STAC_92HD73XX_AUTO] = "auto", | 1534 | [STAC_92HD73XX_AUTO] = "auto", |
1780 | [STAC_92HD73XX_NO_JD] = "no-jd", | 1535 | [STAC_92HD73XX_NO_JD] = "no-jd", |
1781 | [STAC_92HD73XX_REF] = "ref", | 1536 | [STAC_92HD73XX_REF] = "ref", |
1537 | [STAC_92HD73XX_INTEL] = "intel", | ||
1782 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", | 1538 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
1783 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", | 1539 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
1784 | [STAC_DELL_M6_BOTH] = "dell-m6", | 1540 | [STAC_DELL_M6_BOTH] = "dell-m6", |
1785 | [STAC_DELL_EQ] = "dell-eq", | 1541 | [STAC_DELL_EQ] = "dell-eq", |
1542 | [STAC_ALIENWARE_M17X] = "alienware", | ||
1786 | }; | 1543 | }; |
1787 | 1544 | ||
1788 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { | 1545 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
@@ -1791,6 +1548,10 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { | |||
1791 | "DFI LanParty", STAC_92HD73XX_REF), | 1548 | "DFI LanParty", STAC_92HD73XX_REF), |
1792 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 1549 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
1793 | "DFI LanParty", STAC_92HD73XX_REF), | 1550 | "DFI LanParty", STAC_92HD73XX_REF), |
1551 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002, | ||
1552 | "Intel DG45ID", STAC_92HD73XX_INTEL), | ||
1553 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003, | ||
1554 | "Intel DG45FC", STAC_92HD73XX_INTEL), | ||
1794 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, | 1555 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
1795 | "Dell Studio 1535", STAC_DELL_M6_DMIC), | 1556 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
1796 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, | 1557 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
@@ -1811,6 +1572,14 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { | |||
1811 | "Dell Studio 1537", STAC_DELL_M6_DMIC), | 1572 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
1812 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, | 1573 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
1813 | "Dell Studio 17", STAC_DELL_M6_DMIC), | 1574 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
1575 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be, | ||
1576 | "Dell Studio 1555", STAC_DELL_M6_DMIC), | ||
1577 | {} /* terminator */ | ||
1578 | }; | ||
1579 | |||
1580 | static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = { | ||
1581 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1, | ||
1582 | "Alienware M17x", STAC_ALIENWARE_M17X), | ||
1814 | {} /* terminator */ | 1583 | {} /* terminator */ |
1815 | }; | 1584 | }; |
1816 | 1585 | ||
@@ -1921,6 +1690,8 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { | |||
1921 | "HP mini 1000", STAC_HP_M4), | 1690 | "HP mini 1000", STAC_HP_M4), |
1922 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, | 1691 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, |
1923 | "HP HDX", STAC_HP_HDX), /* HDX16 */ | 1692 | "HP HDX", STAC_HP_HDX), /* HDX16 */ |
1693 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010, | ||
1694 | "HP", STAC_HP_DV5), | ||
1924 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, | 1695 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
1925 | "unknown Dell", STAC_DELL_M4_1), | 1696 | "unknown Dell", STAC_DELL_M4_1), |
1926 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, | 1697 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
@@ -2266,7 +2037,7 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = { | |||
2266 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), | 2037 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
2267 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS), | 2038 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS), |
2268 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), | 2039 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
2269 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST), | 2040 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS), |
2270 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), | 2041 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
2271 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), | 2042 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
2272 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), | 2043 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
@@ -2344,6 +2115,8 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = { | |||
2344 | /* SigmaTel reference board */ | 2115 | /* SigmaTel reference board */ |
2345 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 2116 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
2346 | "DFI LanParty", STAC_9205_REF), | 2117 | "DFI LanParty", STAC_9205_REF), |
2118 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, | ||
2119 | "SigmaTel", STAC_9205_REF), | ||
2347 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 2120 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
2348 | "DFI LanParty", STAC_9205_REF), | 2121 | "DFI LanParty", STAC_9205_REF), |
2349 | /* Dell */ | 2122 | /* Dell */ |
@@ -2378,6 +2151,7 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = { | |||
2378 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, | 2151 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
2379 | "Dell Vostro 1500", STAC_9205_DELL_M42), | 2152 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
2380 | /* Gateway */ | 2153 | /* Gateway */ |
2154 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), | ||
2381 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), | 2155 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
2382 | {} /* terminator */ | 2156 | {} /* terminator */ |
2383 | }; | 2157 | }; |
@@ -2633,8 +2407,7 @@ static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, | |||
2633 | return 0; | 2407 | return 0; |
2634 | } | 2408 | } |
2635 | 2409 | ||
2636 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, | 2410 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid); |
2637 | unsigned char type); | ||
2638 | 2411 | ||
2639 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, | 2412 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
2640 | struct snd_ctl_elem_value *ucontrol) | 2413 | struct snd_ctl_elem_value *ucontrol) |
@@ -2648,7 +2421,7 @@ static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, | |||
2648 | /* check to be sure that the ports are upto date with | 2421 | /* check to be sure that the ports are upto date with |
2649 | * switch changes | 2422 | * switch changes |
2650 | */ | 2423 | */ |
2651 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); | 2424 | stac_issue_unsol_event(codec, nid); |
2652 | 2425 | ||
2653 | return 1; | 2426 | return 1; |
2654 | } | 2427 | } |
@@ -2781,7 +2554,7 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
2781 | * appropriately according to the pin direction | 2554 | * appropriately according to the pin direction |
2782 | */ | 2555 | */ |
2783 | if (spec->hp_detect) | 2556 | if (spec->hp_detect) |
2784 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); | 2557 | stac_issue_unsol_event(codec, nid); |
2785 | 2558 | ||
2786 | return 1; | 2559 | return 1; |
2787 | } | 2560 | } |
@@ -2850,8 +2623,6 @@ enum { | |||
2850 | STAC_CTL_WIDGET_VOL, | 2623 | STAC_CTL_WIDGET_VOL, |
2851 | STAC_CTL_WIDGET_MUTE, | 2624 | STAC_CTL_WIDGET_MUTE, |
2852 | STAC_CTL_WIDGET_MONO_MUX, | 2625 | STAC_CTL_WIDGET_MONO_MUX, |
2853 | STAC_CTL_WIDGET_AMP_MUX, | ||
2854 | STAC_CTL_WIDGET_AMP_VOL, | ||
2855 | STAC_CTL_WIDGET_HP_SWITCH, | 2626 | STAC_CTL_WIDGET_HP_SWITCH, |
2856 | STAC_CTL_WIDGET_IO_SWITCH, | 2627 | STAC_CTL_WIDGET_IO_SWITCH, |
2857 | STAC_CTL_WIDGET_CLFE_SWITCH, | 2628 | STAC_CTL_WIDGET_CLFE_SWITCH, |
@@ -2862,8 +2633,6 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = { | |||
2862 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), | 2633 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
2863 | HDA_CODEC_MUTE(NULL, 0, 0, 0), | 2634 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
2864 | STAC_MONO_MUX, | 2635 | STAC_MONO_MUX, |
2865 | STAC_AMP_MUX, | ||
2866 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), | ||
2867 | STAC_CODEC_HP_SWITCH(NULL), | 2636 | STAC_CODEC_HP_SWITCH(NULL), |
2868 | STAC_CODEC_IO_SWITCH(NULL, 0), | 2637 | STAC_CODEC_IO_SWITCH(NULL, 0), |
2869 | STAC_CODEC_CLFE_SWITCH(NULL, 0), | 2638 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
@@ -2964,6 +2733,8 @@ static int stac92xx_add_input_source(struct sigmatel_spec *spec) | |||
2964 | struct snd_kcontrol_new *knew; | 2733 | struct snd_kcontrol_new *knew; |
2965 | struct hda_input_mux *imux = &spec->private_imux; | 2734 | struct hda_input_mux *imux = &spec->private_imux; |
2966 | 2735 | ||
2736 | if (spec->auto_mic) | ||
2737 | return 0; /* no need for input source */ | ||
2967 | if (!spec->num_adcs || imux->num_items <= 1) | 2738 | if (!spec->num_adcs || imux->num_items <= 1) |
2968 | return 0; /* no need for input source control */ | 2739 | return 0; /* no need for input source control */ |
2969 | knew = stac_control_new(spec, &stac_input_src_temp, | 2740 | knew = stac_control_new(spec, &stac_input_src_temp, |
@@ -3057,7 +2828,7 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) | |||
3057 | HDA_MAX_CONNECTIONS); | 2828 | HDA_MAX_CONNECTIONS); |
3058 | for (j = 0; j < conn_len; j++) { | 2829 | for (j = 0; j < conn_len; j++) { |
3059 | wcaps = get_wcaps(codec, conn[j]); | 2830 | wcaps = get_wcaps(codec, conn[j]); |
3060 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 2831 | wtype = get_wcaps_type(wcaps); |
3061 | /* we check only analog outputs */ | 2832 | /* we check only analog outputs */ |
3062 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) | 2833 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
3063 | continue; | 2834 | continue; |
@@ -3316,6 +3087,21 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, | |||
3316 | return 0; | 3087 | return 0; |
3317 | } | 3088 | } |
3318 | 3089 | ||
3090 | static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol, | ||
3091 | unsigned long sw, int idx) | ||
3092 | { | ||
3093 | int err; | ||
3094 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, | ||
3095 | "Capture Volume", vol); | ||
3096 | if (err < 0) | ||
3097 | return err; | ||
3098 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx, | ||
3099 | "Capture Switch", sw); | ||
3100 | if (err < 0) | ||
3101 | return err; | ||
3102 | return 0; | ||
3103 | } | ||
3104 | |||
3319 | /* add playback controls from the parsed DAC table */ | 3105 | /* add playback controls from the parsed DAC table */ |
3320 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | 3106 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
3321 | const struct auto_pin_cfg *cfg) | 3107 | const struct auto_pin_cfg *cfg) |
@@ -3389,7 +3175,7 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) | |||
3389 | spec->mono_nid, | 3175 | spec->mono_nid, |
3390 | con_lst, | 3176 | con_lst, |
3391 | HDA_MAX_NUM_INPUTS); | 3177 | HDA_MAX_NUM_INPUTS); |
3392 | if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) | 3178 | if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
3393 | return -EINVAL; | 3179 | return -EINVAL; |
3394 | 3180 | ||
3395 | for (i = 0; i < num_cons; i++) { | 3181 | for (i = 0; i < num_cons; i++) { |
@@ -3403,37 +3189,6 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) | |||
3403 | "Mono Mux", spec->mono_nid); | 3189 | "Mono Mux", spec->mono_nid); |
3404 | } | 3190 | } |
3405 | 3191 | ||
3406 | /* labels for amp mux outputs */ | ||
3407 | static const char *stac92xx_amp_labels[3] = { | ||
3408 | "Front Microphone", "Microphone", "Line In", | ||
3409 | }; | ||
3410 | |||
3411 | /* create amp out controls mux on capable codecs */ | ||
3412 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) | ||
3413 | { | ||
3414 | struct sigmatel_spec *spec = codec->spec; | ||
3415 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; | ||
3416 | int i, err; | ||
3417 | |||
3418 | for (i = 0; i < spec->num_amps; i++) { | ||
3419 | amp_mux->items[amp_mux->num_items].label = | ||
3420 | stac92xx_amp_labels[i]; | ||
3421 | amp_mux->items[amp_mux->num_items].index = i; | ||
3422 | amp_mux->num_items++; | ||
3423 | } | ||
3424 | |||
3425 | if (spec->num_amps > 1) { | ||
3426 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, | ||
3427 | "Amp Selector Capture Switch", 0); | ||
3428 | if (err < 0) | ||
3429 | return err; | ||
3430 | } | ||
3431 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, | ||
3432 | "Amp Capture Volume", | ||
3433 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); | ||
3434 | } | ||
3435 | |||
3436 | |||
3437 | /* create PC beep volume controls */ | 3192 | /* create PC beep volume controls */ |
3438 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, | 3193 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
3439 | hda_nid_t nid) | 3194 | hda_nid_t nid) |
@@ -3502,19 +3257,33 @@ static int stac92xx_beep_switch_ctl(struct hda_codec *codec) | |||
3502 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) | 3257 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
3503 | { | 3258 | { |
3504 | struct sigmatel_spec *spec = codec->spec; | 3259 | struct sigmatel_spec *spec = codec->spec; |
3505 | int wcaps, nid, i, err = 0; | 3260 | int i, j, err = 0; |
3506 | 3261 | ||
3507 | for (i = 0; i < spec->num_muxes; i++) { | 3262 | for (i = 0; i < spec->num_muxes; i++) { |
3263 | hda_nid_t nid; | ||
3264 | unsigned int wcaps; | ||
3265 | unsigned long val; | ||
3266 | |||
3508 | nid = spec->mux_nids[i]; | 3267 | nid = spec->mux_nids[i]; |
3509 | wcaps = get_wcaps(codec, nid); | 3268 | wcaps = get_wcaps(codec, nid); |
3269 | if (!(wcaps & AC_WCAP_OUT_AMP)) | ||
3270 | continue; | ||
3510 | 3271 | ||
3511 | if (wcaps & AC_WCAP_OUT_AMP) { | 3272 | /* check whether already the same control was created as |
3512 | err = stac92xx_add_control_idx(spec, | 3273 | * normal Capture Volume. |
3513 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", | 3274 | */ |
3514 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); | 3275 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
3515 | if (err < 0) | 3276 | for (j = 0; j < spec->num_caps; j++) { |
3516 | return err; | 3277 | if (spec->capvols[j] == val) |
3278 | break; | ||
3517 | } | 3279 | } |
3280 | if (j < spec->num_caps) | ||
3281 | continue; | ||
3282 | |||
3283 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i, | ||
3284 | "Mux Capture Volume", val); | ||
3285 | if (err < 0) | ||
3286 | return err; | ||
3518 | } | 3287 | } |
3519 | return 0; | 3288 | return 0; |
3520 | }; | 3289 | }; |
@@ -3535,7 +3304,7 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) | |||
3535 | spec->smux_nids[0], | 3304 | spec->smux_nids[0], |
3536 | con_lst, | 3305 | con_lst, |
3537 | HDA_MAX_NUM_INPUTS); | 3306 | HDA_MAX_NUM_INPUTS); |
3538 | if (!num_cons) | 3307 | if (num_cons <= 0) |
3539 | return -EINVAL; | 3308 | return -EINVAL; |
3540 | 3309 | ||
3541 | if (!labels) | 3310 | if (!labels) |
@@ -3556,101 +3325,231 @@ static const char *stac92xx_dmic_labels[5] = { | |||
3556 | "Digital Mic 3", "Digital Mic 4" | 3325 | "Digital Mic 3", "Digital Mic 4" |
3557 | }; | 3326 | }; |
3558 | 3327 | ||
3328 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, | ||
3329 | hda_nid_t nid) | ||
3330 | { | ||
3331 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; | ||
3332 | int i, nums; | ||
3333 | |||
3334 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); | ||
3335 | for (i = 0; i < nums; i++) | ||
3336 | if (conn[i] == nid) | ||
3337 | return i; | ||
3338 | return -1; | ||
3339 | } | ||
3340 | |||
3341 | /* create a volume assigned to the given pin (only if supported) */ | ||
3342 | /* return 1 if the volume control is created */ | ||
3343 | static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, | ||
3344 | const char *label, int direction) | ||
3345 | { | ||
3346 | unsigned int caps, nums; | ||
3347 | char name[32]; | ||
3348 | int err; | ||
3349 | |||
3350 | if (direction == HDA_OUTPUT) | ||
3351 | caps = AC_WCAP_OUT_AMP; | ||
3352 | else | ||
3353 | caps = AC_WCAP_IN_AMP; | ||
3354 | if (!(get_wcaps(codec, nid) & caps)) | ||
3355 | return 0; | ||
3356 | caps = query_amp_caps(codec, nid, direction); | ||
3357 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; | ||
3358 | if (!nums) | ||
3359 | return 0; | ||
3360 | snprintf(name, sizeof(name), "%s Capture Volume", label); | ||
3361 | err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name, | ||
3362 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction)); | ||
3363 | if (err < 0) | ||
3364 | return err; | ||
3365 | return 1; | ||
3366 | } | ||
3367 | |||
3559 | /* create playback/capture controls for input pins on dmic capable codecs */ | 3368 | /* create playback/capture controls for input pins on dmic capable codecs */ |
3560 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, | 3369 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
3561 | const struct auto_pin_cfg *cfg) | 3370 | const struct auto_pin_cfg *cfg) |
3562 | { | 3371 | { |
3563 | struct sigmatel_spec *spec = codec->spec; | 3372 | struct sigmatel_spec *spec = codec->spec; |
3373 | struct hda_input_mux *imux = &spec->private_imux; | ||
3564 | struct hda_input_mux *dimux = &spec->private_dimux; | 3374 | struct hda_input_mux *dimux = &spec->private_dimux; |
3565 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; | 3375 | int err, i, active_mics; |
3566 | int err, i, j; | 3376 | unsigned int def_conf; |
3567 | char name[32]; | ||
3568 | 3377 | ||
3569 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; | 3378 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
3570 | dimux->items[dimux->num_items].index = 0; | 3379 | dimux->items[dimux->num_items].index = 0; |
3571 | dimux->num_items++; | 3380 | dimux->num_items++; |
3572 | 3381 | ||
3382 | active_mics = 0; | ||
3383 | for (i = 0; i < spec->num_dmics; i++) { | ||
3384 | /* check the validity: sometimes it's a dead vendor-spec node */ | ||
3385 | if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i])) | ||
3386 | != AC_WID_PIN) | ||
3387 | continue; | ||
3388 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); | ||
3389 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) | ||
3390 | active_mics++; | ||
3391 | } | ||
3392 | |||
3573 | for (i = 0; i < spec->num_dmics; i++) { | 3393 | for (i = 0; i < spec->num_dmics; i++) { |
3574 | hda_nid_t nid; | 3394 | hda_nid_t nid; |
3575 | int index; | 3395 | int index; |
3576 | int num_cons; | 3396 | const char *label; |
3577 | unsigned int wcaps; | ||
3578 | unsigned int def_conf; | ||
3579 | 3397 | ||
3580 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); | 3398 | nid = spec->dmic_nids[i]; |
3399 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) | ||
3400 | continue; | ||
3401 | def_conf = snd_hda_codec_get_pincfg(codec, nid); | ||
3581 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) | 3402 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
3582 | continue; | 3403 | continue; |
3583 | 3404 | ||
3584 | nid = spec->dmic_nids[i]; | 3405 | index = get_connection_index(codec, spec->dmux_nids[0], nid); |
3585 | num_cons = snd_hda_get_connections(codec, | 3406 | if (index < 0) |
3586 | spec->dmux_nids[0], | 3407 | continue; |
3587 | con_lst, | ||
3588 | HDA_MAX_NUM_INPUTS); | ||
3589 | for (j = 0; j < num_cons; j++) | ||
3590 | if (con_lst[j] == nid) { | ||
3591 | index = j; | ||
3592 | goto found; | ||
3593 | } | ||
3594 | continue; | ||
3595 | found: | ||
3596 | wcaps = get_wcaps(codec, nid) & | ||
3597 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); | ||
3598 | 3408 | ||
3599 | if (wcaps) { | 3409 | if (active_mics == 1) |
3600 | sprintf(name, "%s Capture Volume", | 3410 | label = "Digital Mic"; |
3601 | stac92xx_dmic_labels[dimux->num_items]); | 3411 | else |
3412 | label = stac92xx_dmic_labels[dimux->num_items]; | ||
3602 | 3413 | ||
3603 | err = stac92xx_add_control(spec, | 3414 | err = create_elem_capture_vol(codec, nid, label, HDA_INPUT); |
3604 | STAC_CTL_WIDGET_VOL, | 3415 | if (err < 0) |
3605 | name, | 3416 | return err; |
3606 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, | 3417 | if (!err) { |
3607 | (wcaps & AC_WCAP_OUT_AMP) ? | 3418 | err = create_elem_capture_vol(codec, nid, label, |
3608 | HDA_OUTPUT : HDA_INPUT)); | 3419 | HDA_OUTPUT); |
3609 | if (err < 0) | 3420 | if (err < 0) |
3610 | return err; | 3421 | return err; |
3611 | } | 3422 | } |
3612 | 3423 | ||
3613 | dimux->items[dimux->num_items].label = | 3424 | dimux->items[dimux->num_items].label = label; |
3614 | stac92xx_dmic_labels[dimux->num_items]; | ||
3615 | dimux->items[dimux->num_items].index = index; | 3425 | dimux->items[dimux->num_items].index = index; |
3616 | dimux->num_items++; | 3426 | dimux->num_items++; |
3427 | if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) { | ||
3428 | imux->items[imux->num_items].label = label; | ||
3429 | imux->items[imux->num_items].index = index; | ||
3430 | imux->num_items++; | ||
3431 | } | ||
3617 | } | 3432 | } |
3618 | 3433 | ||
3619 | return 0; | 3434 | return 0; |
3620 | } | 3435 | } |
3621 | 3436 | ||
3437 | static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, | ||
3438 | hda_nid_t *fixed, hda_nid_t *ext) | ||
3439 | { | ||
3440 | unsigned int cfg; | ||
3441 | |||
3442 | if (!nid) | ||
3443 | return 0; | ||
3444 | cfg = snd_hda_codec_get_pincfg(codec, nid); | ||
3445 | switch (get_defcfg_connect(cfg)) { | ||
3446 | case AC_JACK_PORT_FIXED: | ||
3447 | if (*fixed) | ||
3448 | return 1; /* already occupied */ | ||
3449 | *fixed = nid; | ||
3450 | break; | ||
3451 | case AC_JACK_PORT_COMPLEX: | ||
3452 | if (*ext) | ||
3453 | return 1; /* already occupied */ | ||
3454 | *ext = nid; | ||
3455 | break; | ||
3456 | } | ||
3457 | return 0; | ||
3458 | } | ||
3459 | |||
3460 | static int set_mic_route(struct hda_codec *codec, | ||
3461 | struct sigmatel_mic_route *mic, | ||
3462 | hda_nid_t pin) | ||
3463 | { | ||
3464 | struct sigmatel_spec *spec = codec->spec; | ||
3465 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
3466 | int i; | ||
3467 | |||
3468 | mic->pin = pin; | ||
3469 | for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) | ||
3470 | if (pin == cfg->input_pins[i]) | ||
3471 | break; | ||
3472 | if (i <= AUTO_PIN_FRONT_MIC) { | ||
3473 | /* analog pin */ | ||
3474 | mic->dmux_idx = 0; | ||
3475 | i = get_connection_index(codec, spec->mux_nids[0], pin); | ||
3476 | if (i < 0) | ||
3477 | return -1; | ||
3478 | mic->mux_idx = i; | ||
3479 | } else if (spec->dmux_nids) { | ||
3480 | /* digital pin */ | ||
3481 | mic->mux_idx = 0; | ||
3482 | i = get_connection_index(codec, spec->dmux_nids[0], pin); | ||
3483 | if (i < 0) | ||
3484 | return -1; | ||
3485 | mic->dmux_idx = i; | ||
3486 | } | ||
3487 | return 0; | ||
3488 | } | ||
3489 | |||
3490 | /* return non-zero if the device is for automatic mic switch */ | ||
3491 | static int stac_check_auto_mic(struct hda_codec *codec) | ||
3492 | { | ||
3493 | struct sigmatel_spec *spec = codec->spec; | ||
3494 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
3495 | hda_nid_t fixed, ext; | ||
3496 | int i; | ||
3497 | |||
3498 | for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) { | ||
3499 | if (cfg->input_pins[i]) | ||
3500 | return 0; /* must be exclusively mics */ | ||
3501 | } | ||
3502 | fixed = ext = 0; | ||
3503 | for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) | ||
3504 | if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext)) | ||
3505 | return 0; | ||
3506 | for (i = 0; i < spec->num_dmics; i++) | ||
3507 | if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext)) | ||
3508 | return 0; | ||
3509 | if (!fixed || !ext) | ||
3510 | return 0; | ||
3511 | if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) | ||
3512 | return 0; /* no unsol support */ | ||
3513 | if (set_mic_route(codec, &spec->ext_mic, ext) || | ||
3514 | set_mic_route(codec, &spec->int_mic, fixed)) | ||
3515 | return 0; /* something is wrong */ | ||
3516 | return 1; | ||
3517 | } | ||
3518 | |||
3622 | /* create playback/capture controls for input pins */ | 3519 | /* create playback/capture controls for input pins */ |
3623 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) | 3520 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
3624 | { | 3521 | { |
3625 | struct sigmatel_spec *spec = codec->spec; | 3522 | struct sigmatel_spec *spec = codec->spec; |
3626 | struct hda_input_mux *imux = &spec->private_imux; | 3523 | struct hda_input_mux *imux = &spec->private_imux; |
3627 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; | 3524 | int i, j; |
3628 | int i, j, k; | ||
3629 | 3525 | ||
3630 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 3526 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
3631 | int index; | 3527 | hda_nid_t nid = cfg->input_pins[i]; |
3528 | int index, err; | ||
3632 | 3529 | ||
3633 | if (!cfg->input_pins[i]) | 3530 | if (!nid) |
3634 | continue; | 3531 | continue; |
3635 | index = -1; | 3532 | index = -1; |
3636 | for (j = 0; j < spec->num_muxes; j++) { | 3533 | for (j = 0; j < spec->num_muxes; j++) { |
3637 | int num_cons; | 3534 | index = get_connection_index(codec, spec->mux_nids[j], |
3638 | num_cons = snd_hda_get_connections(codec, | 3535 | nid); |
3639 | spec->mux_nids[j], | 3536 | if (index >= 0) |
3640 | con_lst, | 3537 | break; |
3641 | HDA_MAX_NUM_INPUTS); | ||
3642 | for (k = 0; k < num_cons; k++) | ||
3643 | if (con_lst[k] == cfg->input_pins[i]) { | ||
3644 | index = k; | ||
3645 | goto found; | ||
3646 | } | ||
3647 | } | 3538 | } |
3648 | continue; | 3539 | if (index < 0) |
3649 | found: | 3540 | continue; |
3541 | |||
3542 | err = create_elem_capture_vol(codec, nid, | ||
3543 | auto_pin_cfg_labels[i], | ||
3544 | HDA_INPUT); | ||
3545 | if (err < 0) | ||
3546 | return err; | ||
3547 | |||
3650 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | 3548 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
3651 | imux->items[imux->num_items].index = index; | 3549 | imux->items[imux->num_items].index = index; |
3652 | imux->num_items++; | 3550 | imux->num_items++; |
3653 | } | 3551 | } |
3552 | spec->num_analog_muxes = imux->num_items; | ||
3654 | 3553 | ||
3655 | if (imux->num_items) { | 3554 | if (imux->num_items) { |
3656 | /* | 3555 | /* |
@@ -3702,7 +3601,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3702 | { | 3601 | { |
3703 | struct sigmatel_spec *spec = codec->spec; | 3602 | struct sigmatel_spec *spec = codec->spec; |
3704 | int hp_swap = 0; | 3603 | int hp_swap = 0; |
3705 | int err; | 3604 | int i, err; |
3706 | 3605 | ||
3707 | if ((err = snd_hda_parse_pin_def_config(codec, | 3606 | if ((err = snd_hda_parse_pin_def_config(codec, |
3708 | &spec->autocfg, | 3607 | &spec->autocfg, |
@@ -3742,11 +3641,10 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3742 | if (snd_hda_get_connections(codec, | 3641 | if (snd_hda_get_connections(codec, |
3743 | spec->autocfg.mono_out_pin, conn_list, 1) && | 3642 | spec->autocfg.mono_out_pin, conn_list, 1) && |
3744 | snd_hda_get_connections(codec, conn_list[0], | 3643 | snd_hda_get_connections(codec, conn_list[0], |
3745 | conn_list, 1)) { | 3644 | conn_list, 1) > 0) { |
3746 | 3645 | ||
3747 | int wcaps = get_wcaps(codec, conn_list[0]); | 3646 | int wcaps = get_wcaps(codec, conn_list[0]); |
3748 | int wid_type = (wcaps & AC_WCAP_TYPE) | 3647 | int wid_type = get_wcaps_type(wcaps); |
3749 | >> AC_WCAP_TYPE_SHIFT; | ||
3750 | /* LR swap check, some stac925x have a mux that | 3648 | /* LR swap check, some stac925x have a mux that |
3751 | * changes the DACs output path instead of the | 3649 | * changes the DACs output path instead of the |
3752 | * mono-mux path. | 3650 | * mono-mux path. |
@@ -3837,6 +3735,21 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3837 | spec->autocfg.line_outs = 0; | 3735 | spec->autocfg.line_outs = 0; |
3838 | } | 3736 | } |
3839 | 3737 | ||
3738 | if (stac_check_auto_mic(codec)) { | ||
3739 | spec->auto_mic = 1; | ||
3740 | /* only one capture for auto-mic */ | ||
3741 | spec->num_adcs = 1; | ||
3742 | spec->num_caps = 1; | ||
3743 | spec->num_muxes = 1; | ||
3744 | } | ||
3745 | |||
3746 | for (i = 0; i < spec->num_caps; i++) { | ||
3747 | err = stac92xx_add_capvol_ctls(codec, spec->capvols[i], | ||
3748 | spec->capsws[i], i); | ||
3749 | if (err < 0) | ||
3750 | return err; | ||
3751 | } | ||
3752 | |||
3840 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); | 3753 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
3841 | if (err < 0) | 3754 | if (err < 0) |
3842 | return err; | 3755 | return err; |
@@ -3846,11 +3759,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3846 | if (err < 0) | 3759 | if (err < 0) |
3847 | return err; | 3760 | return err; |
3848 | } | 3761 | } |
3849 | if (spec->num_amps > 0) { | ||
3850 | err = stac92xx_auto_create_amp_output_ctls(codec); | ||
3851 | if (err < 0) | ||
3852 | return err; | ||
3853 | } | ||
3854 | if (spec->num_dmics > 0 && !spec->dinput_mux) | 3762 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
3855 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, | 3763 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
3856 | &spec->autocfg)) < 0) | 3764 | &spec->autocfg)) < 0) |
@@ -3887,7 +3795,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3887 | spec->dinput_mux = &spec->private_dimux; | 3795 | spec->dinput_mux = &spec->private_dimux; |
3888 | spec->sinput_mux = &spec->private_smux; | 3796 | spec->sinput_mux = &spec->private_smux; |
3889 | spec->mono_mux = &spec->private_mono_mux; | 3797 | spec->mono_mux = &spec->private_mono_mux; |
3890 | spec->amp_mux = &spec->private_amp_mux; | ||
3891 | return 1; | 3798 | return 1; |
3892 | } | 3799 | } |
3893 | 3800 | ||
@@ -4065,7 +3972,7 @@ static int stac92xx_add_jack(struct hda_codec *codec, | |||
4065 | jack->nid = nid; | 3972 | jack->nid = nid; |
4066 | jack->type = type; | 3973 | jack->type = type; |
4067 | 3974 | ||
4068 | sprintf(name, "%s at %s %s Jack", | 3975 | snprintf(name, sizeof(name), "%s at %s %s Jack", |
4069 | snd_hda_get_jack_type(def_conf), | 3976 | snd_hda_get_jack_type(def_conf), |
4070 | snd_hda_get_jack_connectivity(def_conf), | 3977 | snd_hda_get_jack_connectivity(def_conf), |
4071 | snd_hda_get_jack_location(def_conf)); | 3978 | snd_hda_get_jack_location(def_conf)); |
@@ -4099,14 +4006,14 @@ static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, | |||
4099 | } | 4006 | } |
4100 | 4007 | ||
4101 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, | 4008 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
4102 | hda_nid_t nid, unsigned char type) | 4009 | hda_nid_t nid) |
4103 | { | 4010 | { |
4104 | struct sigmatel_spec *spec = codec->spec; | 4011 | struct sigmatel_spec *spec = codec->spec; |
4105 | struct sigmatel_event *event = spec->events.list; | 4012 | struct sigmatel_event *event = spec->events.list; |
4106 | int i; | 4013 | int i; |
4107 | 4014 | ||
4108 | for (i = 0; i < spec->events.used; i++, event++) { | 4015 | for (i = 0; i < spec->events.used; i++, event++) { |
4109 | if (event->nid == nid && event->type == type) | 4016 | if (event->nid == nid) |
4110 | return event; | 4017 | return event; |
4111 | } | 4018 | } |
4112 | return NULL; | 4019 | return NULL; |
@@ -4126,24 +4033,32 @@ static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, | |||
4126 | return NULL; | 4033 | return NULL; |
4127 | } | 4034 | } |
4128 | 4035 | ||
4129 | static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, | 4036 | /* check if given nid is a valid pin and no other events are assigned |
4130 | unsigned int type) | 4037 | * to it. If OK, assign the event, set the unsol flag, and returns 1. |
4038 | * Otherwise, returns zero. | ||
4039 | */ | ||
4040 | static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, | ||
4041 | unsigned int type) | ||
4131 | { | 4042 | { |
4132 | struct sigmatel_event *event; | 4043 | struct sigmatel_event *event; |
4133 | int tag; | 4044 | int tag; |
4134 | 4045 | ||
4135 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) | 4046 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
4136 | return; | 4047 | return 0; |
4137 | event = stac_get_event(codec, nid, type); | 4048 | event = stac_get_event(codec, nid); |
4138 | if (event) | 4049 | if (event) { |
4050 | if (event->type != type) | ||
4051 | return 0; | ||
4139 | tag = event->tag; | 4052 | tag = event->tag; |
4140 | else | 4053 | } else { |
4141 | tag = stac_add_event(codec->spec, nid, type, 0); | 4054 | tag = stac_add_event(codec->spec, nid, type, 0); |
4142 | if (tag < 0) | 4055 | if (tag < 0) |
4143 | return; | 4056 | return 0; |
4057 | } | ||
4144 | snd_hda_codec_write_cache(codec, nid, 0, | 4058 | snd_hda_codec_write_cache(codec, nid, 0, |
4145 | AC_VERB_SET_UNSOLICITED_ENABLE, | 4059 | AC_VERB_SET_UNSOLICITED_ENABLE, |
4146 | AC_USRSP_EN | tag); | 4060 | AC_USRSP_EN | tag); |
4061 | return 1; | ||
4147 | } | 4062 | } |
4148 | 4063 | ||
4149 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) | 4064 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
@@ -4236,20 +4151,36 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4236 | hda_nid_t nid = cfg->hp_pins[i]; | 4151 | hda_nid_t nid = cfg->hp_pins[i]; |
4237 | enable_pin_detect(codec, nid, STAC_HP_EVENT); | 4152 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
4238 | } | 4153 | } |
4154 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && | ||
4155 | cfg->speaker_outs > 0) { | ||
4156 | /* enable pin-detect for line-outs as well */ | ||
4157 | for (i = 0; i < cfg->line_outs; i++) { | ||
4158 | hda_nid_t nid = cfg->line_out_pins[i]; | ||
4159 | enable_pin_detect(codec, nid, STAC_LO_EVENT); | ||
4160 | } | ||
4161 | } | ||
4162 | |||
4239 | /* force to enable the first line-out; the others are set up | 4163 | /* force to enable the first line-out; the others are set up |
4240 | * in unsol_event | 4164 | * in unsol_event |
4241 | */ | 4165 | */ |
4242 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], | 4166 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
4243 | AC_PINCTL_OUT_EN); | 4167 | AC_PINCTL_OUT_EN); |
4244 | /* fake event to set up pins */ | 4168 | /* fake event to set up pins */ |
4245 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], | 4169 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); |
4246 | STAC_HP_EVENT); | ||
4247 | } else { | 4170 | } else { |
4248 | stac92xx_auto_init_multi_out(codec); | 4171 | stac92xx_auto_init_multi_out(codec); |
4249 | stac92xx_auto_init_hp_out(codec); | 4172 | stac92xx_auto_init_hp_out(codec); |
4250 | for (i = 0; i < cfg->hp_outs; i++) | 4173 | for (i = 0; i < cfg->hp_outs; i++) |
4251 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); | 4174 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
4252 | } | 4175 | } |
4176 | if (spec->auto_mic) { | ||
4177 | /* initialize connection to analog input */ | ||
4178 | if (spec->dmux_nids) | ||
4179 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, | ||
4180 | AC_VERB_SET_CONNECT_SEL, 0); | ||
4181 | if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT)) | ||
4182 | stac_issue_unsol_event(codec, spec->ext_mic.pin); | ||
4183 | } | ||
4253 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 4184 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
4254 | hda_nid_t nid = cfg->input_pins[i]; | 4185 | hda_nid_t nid = cfg->input_pins[i]; |
4255 | if (nid) { | 4186 | if (nid) { |
@@ -4276,10 +4207,9 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4276 | } | 4207 | } |
4277 | conf = snd_hda_codec_get_pincfg(codec, nid); | 4208 | conf = snd_hda_codec_get_pincfg(codec, nid); |
4278 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { | 4209 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
4279 | enable_pin_detect(codec, nid, | 4210 | if (enable_pin_detect(codec, nid, |
4280 | STAC_INSERT_EVENT); | 4211 | STAC_INSERT_EVENT)) |
4281 | stac_issue_unsol_event(codec, nid, | 4212 | stac_issue_unsol_event(codec, nid); |
4282 | STAC_INSERT_EVENT); | ||
4283 | } | 4213 | } |
4284 | } | 4214 | } |
4285 | } | 4215 | } |
@@ -4324,10 +4254,8 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4324 | stac_toggle_power_map(codec, nid, 1); | 4254 | stac_toggle_power_map(codec, nid, 1); |
4325 | continue; | 4255 | continue; |
4326 | } | 4256 | } |
4327 | if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { | 4257 | if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) |
4328 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); | 4258 | stac_issue_unsol_event(codec, nid); |
4329 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); | ||
4330 | } | ||
4331 | } | 4259 | } |
4332 | if (spec->dac_list) | 4260 | if (spec->dac_list) |
4333 | stac92xx_power_down(codec); | 4261 | stac92xx_power_down(codec); |
@@ -4431,6 +4359,48 @@ static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) | |||
4431 | return 0; | 4359 | return 0; |
4432 | } | 4360 | } |
4433 | 4361 | ||
4362 | static void stac92xx_line_out_detect(struct hda_codec *codec, | ||
4363 | int presence) | ||
4364 | { | ||
4365 | struct sigmatel_spec *spec = codec->spec; | ||
4366 | struct auto_pin_cfg *cfg = &spec->autocfg; | ||
4367 | int i; | ||
4368 | |||
4369 | for (i = 0; i < cfg->line_outs; i++) { | ||
4370 | if (presence) | ||
4371 | break; | ||
4372 | presence = get_pin_presence(codec, cfg->line_out_pins[i]); | ||
4373 | if (presence) { | ||
4374 | unsigned int pinctl; | ||
4375 | pinctl = snd_hda_codec_read(codec, | ||
4376 | cfg->line_out_pins[i], 0, | ||
4377 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
4378 | if (pinctl & AC_PINCTL_IN_EN) | ||
4379 | presence = 0; /* mic- or line-input */ | ||
4380 | } | ||
4381 | } | ||
4382 | |||
4383 | if (presence) { | ||
4384 | /* disable speakers */ | ||
4385 | for (i = 0; i < cfg->speaker_outs; i++) | ||
4386 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], | ||
4387 | AC_PINCTL_OUT_EN); | ||
4388 | if (spec->eapd_mask && spec->eapd_switch) | ||
4389 | stac_gpio_set(codec, spec->gpio_mask, | ||
4390 | spec->gpio_dir, spec->gpio_data & | ||
4391 | ~spec->eapd_mask); | ||
4392 | } else { | ||
4393 | /* enable speakers */ | ||
4394 | for (i = 0; i < cfg->speaker_outs; i++) | ||
4395 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], | ||
4396 | AC_PINCTL_OUT_EN); | ||
4397 | if (spec->eapd_mask && spec->eapd_switch) | ||
4398 | stac_gpio_set(codec, spec->gpio_mask, | ||
4399 | spec->gpio_dir, spec->gpio_data | | ||
4400 | spec->eapd_mask); | ||
4401 | } | ||
4402 | } | ||
4403 | |||
4434 | /* return non-zero if the hp-pin of the given array index isn't | 4404 | /* return non-zero if the hp-pin of the given array index isn't |
4435 | * a jack-detection target | 4405 | * a jack-detection target |
4436 | */ | 4406 | */ |
@@ -4483,13 +4453,6 @@ static void stac92xx_hp_detect(struct hda_codec *codec) | |||
4483 | for (i = 0; i < cfg->line_outs; i++) | 4453 | for (i = 0; i < cfg->line_outs; i++) |
4484 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], | 4454 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
4485 | AC_PINCTL_OUT_EN); | 4455 | AC_PINCTL_OUT_EN); |
4486 | for (i = 0; i < cfg->speaker_outs; i++) | ||
4487 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], | ||
4488 | AC_PINCTL_OUT_EN); | ||
4489 | if (spec->eapd_mask && spec->eapd_switch) | ||
4490 | stac_gpio_set(codec, spec->gpio_mask, | ||
4491 | spec->gpio_dir, spec->gpio_data & | ||
4492 | ~spec->eapd_mask); | ||
4493 | } else { | 4456 | } else { |
4494 | /* enable lineouts */ | 4457 | /* enable lineouts */ |
4495 | if (spec->hp_switch) | 4458 | if (spec->hp_switch) |
@@ -4498,14 +4461,8 @@ static void stac92xx_hp_detect(struct hda_codec *codec) | |||
4498 | for (i = 0; i < cfg->line_outs; i++) | 4461 | for (i = 0; i < cfg->line_outs; i++) |
4499 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], | 4462 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
4500 | AC_PINCTL_OUT_EN); | 4463 | AC_PINCTL_OUT_EN); |
4501 | for (i = 0; i < cfg->speaker_outs; i++) | ||
4502 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], | ||
4503 | AC_PINCTL_OUT_EN); | ||
4504 | if (spec->eapd_mask && spec->eapd_switch) | ||
4505 | stac_gpio_set(codec, spec->gpio_mask, | ||
4506 | spec->gpio_dir, spec->gpio_data | | ||
4507 | spec->eapd_mask); | ||
4508 | } | 4464 | } |
4465 | stac92xx_line_out_detect(codec, presence); | ||
4509 | /* toggle hp outs */ | 4466 | /* toggle hp outs */ |
4510 | for (i = 0; i < cfg->hp_outs; i++) { | 4467 | for (i = 0; i < cfg->hp_outs; i++) { |
4511 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; | 4468 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
@@ -4590,10 +4547,28 @@ static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) | |||
4590 | } | 4547 | } |
4591 | } | 4548 | } |
4592 | 4549 | ||
4593 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, | 4550 | static void stac92xx_mic_detect(struct hda_codec *codec) |
4594 | unsigned char type) | ||
4595 | { | 4551 | { |
4596 | struct sigmatel_event *event = stac_get_event(codec, nid, type); | 4552 | struct sigmatel_spec *spec = codec->spec; |
4553 | struct sigmatel_mic_route *mic; | ||
4554 | |||
4555 | if (get_pin_presence(codec, spec->ext_mic.pin)) | ||
4556 | mic = &spec->ext_mic; | ||
4557 | else | ||
4558 | mic = &spec->int_mic; | ||
4559 | if (mic->dmux_idx) | ||
4560 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, | ||
4561 | AC_VERB_SET_CONNECT_SEL, | ||
4562 | mic->dmux_idx); | ||
4563 | else | ||
4564 | snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0, | ||
4565 | AC_VERB_SET_CONNECT_SEL, | ||
4566 | mic->mux_idx); | ||
4567 | } | ||
4568 | |||
4569 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) | ||
4570 | { | ||
4571 | struct sigmatel_event *event = stac_get_event(codec, nid); | ||
4597 | if (!event) | 4572 | if (!event) |
4598 | return; | 4573 | return; |
4599 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); | 4574 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
@@ -4612,8 +4587,18 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) | |||
4612 | 4587 | ||
4613 | switch (event->type) { | 4588 | switch (event->type) { |
4614 | case STAC_HP_EVENT: | 4589 | case STAC_HP_EVENT: |
4590 | case STAC_LO_EVENT: | ||
4615 | stac92xx_hp_detect(codec); | 4591 | stac92xx_hp_detect(codec); |
4616 | /* fallthru */ | 4592 | break; |
4593 | case STAC_MIC_EVENT: | ||
4594 | stac92xx_mic_detect(codec); | ||
4595 | break; | ||
4596 | } | ||
4597 | |||
4598 | switch (event->type) { | ||
4599 | case STAC_HP_EVENT: | ||
4600 | case STAC_LO_EVENT: | ||
4601 | case STAC_MIC_EVENT: | ||
4617 | case STAC_INSERT_EVENT: | 4602 | case STAC_INSERT_EVENT: |
4618 | case STAC_PWR_EVENT: | 4603 | case STAC_PWR_EVENT: |
4619 | if (spec->num_pwrs > 0) | 4604 | if (spec->num_pwrs > 0) |
@@ -4704,8 +4689,7 @@ static int stac92xx_resume(struct hda_codec *codec) | |||
4704 | snd_hda_codec_resume_cache(codec); | 4689 | snd_hda_codec_resume_cache(codec); |
4705 | /* fake event to set up pins again to override cached values */ | 4690 | /* fake event to set up pins again to override cached values */ |
4706 | if (spec->hp_detect) | 4691 | if (spec->hp_detect) |
4707 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], | 4692 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); |
4708 | STAC_HP_EVENT); | ||
4709 | return 0; | 4693 | return 0; |
4710 | } | 4694 | } |
4711 | 4695 | ||
@@ -4745,6 +4729,19 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec, | |||
4745 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) | 4729 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
4746 | { | 4730 | { |
4747 | struct sigmatel_spec *spec = codec->spec; | 4731 | struct sigmatel_spec *spec = codec->spec; |
4732 | int i; | ||
4733 | hda_nid_t nid; | ||
4734 | |||
4735 | /* reset each pin before powering down DAC/ADC to avoid click noise */ | ||
4736 | nid = codec->start_nid; | ||
4737 | for (i = 0; i < codec->num_nodes; i++, nid++) { | ||
4738 | unsigned int wcaps = get_wcaps(codec, nid); | ||
4739 | unsigned int wid_type = get_wcaps_type(wcaps); | ||
4740 | if (wid_type == AC_WID_PIN) | ||
4741 | snd_hda_codec_read(codec, nid, 0, | ||
4742 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
4743 | } | ||
4744 | |||
4748 | if (spec->eapd_mask) | 4745 | if (spec->eapd_mask) |
4749 | stac_gpio_set(codec, spec->gpio_mask, | 4746 | stac_gpio_set(codec, spec->gpio_mask, |
4750 | spec->gpio_dir, spec->gpio_data & | 4747 | spec->gpio_dir, spec->gpio_data & |
@@ -4781,7 +4778,8 @@ static int patch_stac9200(struct hda_codec *codec) | |||
4781 | stac9200_models, | 4778 | stac9200_models, |
4782 | stac9200_cfg_tbl); | 4779 | stac9200_cfg_tbl); |
4783 | if (spec->board_config < 0) | 4780 | if (spec->board_config < 0) |
4784 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); | 4781 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
4782 | codec->chip_name); | ||
4785 | else | 4783 | else |
4786 | stac92xx_set_config_regs(codec, | 4784 | stac92xx_set_config_regs(codec, |
4787 | stac9200_brd_tbl[spec->board_config]); | 4785 | stac9200_brd_tbl[spec->board_config]); |
@@ -4853,8 +4851,8 @@ static int patch_stac925x(struct hda_codec *codec) | |||
4853 | stac925x_cfg_tbl); | 4851 | stac925x_cfg_tbl); |
4854 | again: | 4852 | again: |
4855 | if (spec->board_config < 0) | 4853 | if (spec->board_config < 0) |
4856 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," | 4854 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
4857 | "using BIOS defaults\n"); | 4855 | codec->chip_name); |
4858 | else | 4856 | else |
4859 | stac92xx_set_config_regs(codec, | 4857 | stac92xx_set_config_regs(codec, |
4860 | stac925x_brd_tbl[spec->board_config]); | 4858 | stac925x_brd_tbl[spec->board_config]); |
@@ -4884,6 +4882,9 @@ static int patch_stac925x(struct hda_codec *codec) | |||
4884 | 4882 | ||
4885 | spec->init = stac925x_core_init; | 4883 | spec->init = stac925x_core_init; |
4886 | spec->mixer = stac925x_mixer; | 4884 | spec->mixer = stac925x_mixer; |
4885 | spec->num_caps = 1; | ||
4886 | spec->capvols = stac925x_capvols; | ||
4887 | spec->capsws = stac925x_capsws; | ||
4887 | 4888 | ||
4888 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); | 4889 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
4889 | if (!err) { | 4890 | if (!err) { |
@@ -4905,16 +4906,6 @@ static int patch_stac925x(struct hda_codec *codec) | |||
4905 | return 0; | 4906 | return 0; |
4906 | } | 4907 | } |
4907 | 4908 | ||
4908 | static struct hda_input_mux stac92hd73xx_dmux = { | ||
4909 | .num_items = 4, | ||
4910 | .items = { | ||
4911 | { "Analog Inputs", 0x0b }, | ||
4912 | { "Digital Mic 1", 0x09 }, | ||
4913 | { "Digital Mic 2", 0x0a }, | ||
4914 | { "CD", 0x08 }, | ||
4915 | } | ||
4916 | }; | ||
4917 | |||
4918 | static int patch_stac92hd73xx(struct hda_codec *codec) | 4909 | static int patch_stac92hd73xx(struct hda_codec *codec) |
4919 | { | 4910 | { |
4920 | struct sigmatel_spec *spec; | 4911 | struct sigmatel_spec *spec; |
@@ -4934,10 +4925,16 @@ static int patch_stac92hd73xx(struct hda_codec *codec) | |||
4934 | STAC_92HD73XX_MODELS, | 4925 | STAC_92HD73XX_MODELS, |
4935 | stac92hd73xx_models, | 4926 | stac92hd73xx_models, |
4936 | stac92hd73xx_cfg_tbl); | 4927 | stac92hd73xx_cfg_tbl); |
4928 | /* check codec subsystem id if not found */ | ||
4929 | if (spec->board_config < 0) | ||
4930 | spec->board_config = | ||
4931 | snd_hda_check_board_codec_sid_config(codec, | ||
4932 | STAC_92HD73XX_MODELS, stac92hd73xx_models, | ||
4933 | stac92hd73xx_codec_id_cfg_tbl); | ||
4937 | again: | 4934 | again: |
4938 | if (spec->board_config < 0) | 4935 | if (spec->board_config < 0) |
4939 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 4936 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
4940 | " STAC92HD73XX, using BIOS defaults\n"); | 4937 | codec->chip_name); |
4941 | else | 4938 | else |
4942 | stac92xx_set_config_regs(codec, | 4939 | stac92xx_set_config_regs(codec, |
4943 | stac92hd73xx_brd_tbl[spec->board_config]); | 4940 | stac92hd73xx_brd_tbl[spec->board_config]); |
@@ -4950,20 +4947,15 @@ again: | |||
4950 | "number of channels defaulting to DAC count\n"); | 4947 | "number of channels defaulting to DAC count\n"); |
4951 | num_dacs = STAC92HD73_DAC_COUNT; | 4948 | num_dacs = STAC92HD73_DAC_COUNT; |
4952 | } | 4949 | } |
4950 | spec->init = stac92hd73xx_core_init; | ||
4953 | switch (num_dacs) { | 4951 | switch (num_dacs) { |
4954 | case 0x3: /* 6 Channel */ | 4952 | case 0x3: /* 6 Channel */ |
4955 | spec->mixer = stac92hd73xx_6ch_mixer; | ||
4956 | spec->init = stac92hd73xx_6ch_core_init; | ||
4957 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; | 4953 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
4958 | break; | 4954 | break; |
4959 | case 0x4: /* 8 Channel */ | 4955 | case 0x4: /* 8 Channel */ |
4960 | spec->mixer = stac92hd73xx_8ch_mixer; | ||
4961 | spec->init = stac92hd73xx_8ch_core_init; | ||
4962 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; | 4956 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
4963 | break; | 4957 | break; |
4964 | case 0x5: /* 10 Channel */ | 4958 | case 0x5: /* 10 Channel */ |
4965 | spec->mixer = stac92hd73xx_10ch_mixer; | ||
4966 | spec->init = stac92hd73xx_10ch_core_init; | ||
4967 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; | 4959 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
4968 | break; | 4960 | break; |
4969 | } | 4961 | } |
@@ -4978,14 +4970,14 @@ again: | |||
4978 | spec->dmic_nids = stac92hd73xx_dmic_nids; | 4970 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
4979 | spec->dmux_nids = stac92hd73xx_dmux_nids; | 4971 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
4980 | spec->smux_nids = stac92hd73xx_smux_nids; | 4972 | spec->smux_nids = stac92hd73xx_smux_nids; |
4981 | spec->amp_nids = stac92hd73xx_amp_nids; | ||
4982 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); | ||
4983 | 4973 | ||
4984 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); | 4974 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
4985 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); | 4975 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
4986 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); | 4976 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
4987 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, | 4977 | |
4988 | sizeof(stac92hd73xx_dmux)); | 4978 | spec->num_caps = STAC92HD73XX_NUM_CAPS; |
4979 | spec->capvols = stac92hd73xx_capvols; | ||
4980 | spec->capsws = stac92hd73xx_capsws; | ||
4989 | 4981 | ||
4990 | switch (spec->board_config) { | 4982 | switch (spec->board_config) { |
4991 | case STAC_DELL_EQ: | 4983 | case STAC_DELL_EQ: |
@@ -4995,43 +4987,40 @@ again: | |||
4995 | case STAC_DELL_M6_DMIC: | 4987 | case STAC_DELL_M6_DMIC: |
4996 | case STAC_DELL_M6_BOTH: | 4988 | case STAC_DELL_M6_BOTH: |
4997 | spec->num_smuxes = 0; | 4989 | spec->num_smuxes = 0; |
4998 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; | ||
4999 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; | ||
5000 | spec->eapd_switch = 0; | 4990 | spec->eapd_switch = 0; |
5001 | spec->num_amps = 1; | ||
5002 | 4991 | ||
5003 | if (spec->board_config != STAC_DELL_EQ) | ||
5004 | spec->init = dell_m6_core_init; | ||
5005 | switch (spec->board_config) { | 4992 | switch (spec->board_config) { |
5006 | case STAC_DELL_M6_AMIC: /* Analog Mics */ | 4993 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
5007 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); | 4994 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
5008 | spec->num_dmics = 0; | 4995 | spec->num_dmics = 0; |
5009 | spec->private_dimux.num_items = 1; | ||
5010 | break; | 4996 | break; |
5011 | case STAC_DELL_M6_DMIC: /* Digital Mics */ | 4997 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
5012 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); | 4998 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
5013 | spec->num_dmics = 1; | 4999 | spec->num_dmics = 1; |
5014 | spec->private_dimux.num_items = 2; | ||
5015 | break; | 5000 | break; |
5016 | case STAC_DELL_M6_BOTH: /* Both */ | 5001 | case STAC_DELL_M6_BOTH: /* Both */ |
5017 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); | 5002 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
5018 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); | 5003 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
5019 | spec->num_dmics = 1; | 5004 | spec->num_dmics = 1; |
5020 | spec->private_dimux.num_items = 2; | ||
5021 | break; | 5005 | break; |
5022 | } | 5006 | } |
5023 | break; | 5007 | break; |
5008 | case STAC_ALIENWARE_M17X: | ||
5009 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; | ||
5010 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); | ||
5011 | spec->eapd_switch = 0; | ||
5012 | break; | ||
5024 | default: | 5013 | default: |
5025 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; | 5014 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
5026 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); | 5015 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
5027 | spec->eapd_switch = 1; | 5016 | spec->eapd_switch = 1; |
5017 | break; | ||
5028 | } | 5018 | } |
5029 | if (spec->board_config > STAC_92HD73XX_REF) { | 5019 | if (spec->board_config > STAC_92HD73XX_REF) { |
5030 | /* GPIO0 High = Enable EAPD */ | 5020 | /* GPIO0 High = Enable EAPD */ |
5031 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; | 5021 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
5032 | spec->gpio_data = 0x01; | 5022 | spec->gpio_data = 0x01; |
5033 | } | 5023 | } |
5034 | spec->dinput_mux = &spec->private_dimux; | ||
5035 | 5024 | ||
5036 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); | 5025 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
5037 | spec->pwr_nids = stac92hd73xx_pwr_nids; | 5026 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
@@ -5063,15 +5052,6 @@ again: | |||
5063 | return 0; | 5052 | return 0; |
5064 | } | 5053 | } |
5065 | 5054 | ||
5066 | static struct hda_input_mux stac92hd83xxx_dmux = { | ||
5067 | .num_items = 3, | ||
5068 | .items = { | ||
5069 | { "Analog Inputs", 0x03 }, | ||
5070 | { "Digital Mic 1", 0x04 }, | ||
5071 | { "Digital Mic 2", 0x05 }, | ||
5072 | } | ||
5073 | }; | ||
5074 | |||
5075 | static int patch_stac92hd83xxx(struct hda_codec *codec) | 5055 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
5076 | { | 5056 | { |
5077 | struct sigmatel_spec *spec; | 5057 | struct sigmatel_spec *spec; |
@@ -5088,32 +5068,30 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
5088 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; | 5068 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
5089 | spec->mono_nid = 0x19; | 5069 | spec->mono_nid = 0x19; |
5090 | spec->digbeep_nid = 0x21; | 5070 | spec->digbeep_nid = 0x21; |
5091 | spec->dmic_nids = stac92hd83xxx_dmic_nids; | 5071 | spec->mux_nids = stac92hd83xxx_mux_nids; |
5092 | spec->dmux_nids = stac92hd83xxx_dmux_nids; | 5072 | spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids); |
5093 | spec->adc_nids = stac92hd83xxx_adc_nids; | 5073 | spec->adc_nids = stac92hd83xxx_adc_nids; |
5074 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); | ||
5094 | spec->pwr_nids = stac92hd83xxx_pwr_nids; | 5075 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
5095 | spec->amp_nids = stac92hd83xxx_amp_nids; | ||
5096 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; | 5076 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
5097 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); | 5077 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
5098 | spec->multiout.dac_nids = spec->dac_nids; | 5078 | spec->multiout.dac_nids = spec->dac_nids; |
5099 | 5079 | ||
5100 | spec->init = stac92hd83xxx_core_init; | 5080 | spec->init = stac92hd83xxx_core_init; |
5101 | spec->mixer = stac92hd83xxx_mixer; | ||
5102 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); | 5081 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
5103 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); | ||
5104 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); | ||
5105 | spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids); | ||
5106 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; | ||
5107 | spec->dinput_mux = &stac92hd83xxx_dmux; | ||
5108 | spec->pin_nids = stac92hd83xxx_pin_nids; | 5082 | spec->pin_nids = stac92hd83xxx_pin_nids; |
5083 | spec->num_caps = STAC92HD83XXX_NUM_CAPS; | ||
5084 | spec->capvols = stac92hd83xxx_capvols; | ||
5085 | spec->capsws = stac92hd83xxx_capsws; | ||
5086 | |||
5109 | spec->board_config = snd_hda_check_board_config(codec, | 5087 | spec->board_config = snd_hda_check_board_config(codec, |
5110 | STAC_92HD83XXX_MODELS, | 5088 | STAC_92HD83XXX_MODELS, |
5111 | stac92hd83xxx_models, | 5089 | stac92hd83xxx_models, |
5112 | stac92hd83xxx_cfg_tbl); | 5090 | stac92hd83xxx_cfg_tbl); |
5113 | again: | 5091 | again: |
5114 | if (spec->board_config < 0) | 5092 | if (spec->board_config < 0) |
5115 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 5093 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5116 | " STAC92HD83XXX, using BIOS defaults\n"); | 5094 | codec->chip_name); |
5117 | else | 5095 | else |
5118 | stac92xx_set_config_regs(codec, | 5096 | stac92xx_set_config_regs(codec, |
5119 | stac92hd83xxx_brd_tbl[spec->board_config]); | 5097 | stac92hd83xxx_brd_tbl[spec->board_config]); |
@@ -5155,6 +5133,8 @@ again: | |||
5155 | 5133 | ||
5156 | num_dacs = snd_hda_get_connections(codec, nid, | 5134 | num_dacs = snd_hda_get_connections(codec, nid, |
5157 | conn, STAC92HD83_DAC_COUNT + 1) - 1; | 5135 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
5136 | if (num_dacs < 0) | ||
5137 | num_dacs = STAC92HD83_DAC_COUNT; | ||
5158 | 5138 | ||
5159 | /* set port X to select the last DAC | 5139 | /* set port X to select the last DAC |
5160 | */ | 5140 | */ |
@@ -5168,25 +5148,6 @@ again: | |||
5168 | return 0; | 5148 | return 0; |
5169 | } | 5149 | } |
5170 | 5150 | ||
5171 | static struct hda_input_mux stac92hd71bxx_dmux_nomixer = { | ||
5172 | .num_items = 3, | ||
5173 | .items = { | ||
5174 | { "Analog Inputs", 0x00 }, | ||
5175 | { "Digital Mic 1", 0x02 }, | ||
5176 | { "Digital Mic 2", 0x03 }, | ||
5177 | } | ||
5178 | }; | ||
5179 | |||
5180 | static struct hda_input_mux stac92hd71bxx_dmux_amixer = { | ||
5181 | .num_items = 4, | ||
5182 | .items = { | ||
5183 | { "Analog Inputs", 0x00 }, | ||
5184 | { "Mixer", 0x01 }, | ||
5185 | { "Digital Mic 1", 0x02 }, | ||
5186 | { "Digital Mic 2", 0x03 }, | ||
5187 | } | ||
5188 | }; | ||
5189 | |||
5190 | /* get the pin connection (fixed, none, etc) */ | 5151 | /* get the pin connection (fixed, none, etc) */ |
5191 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) | 5152 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
5192 | { | 5153 | { |
@@ -5247,7 +5208,6 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) | |||
5247 | struct sigmatel_spec *spec; | 5208 | struct sigmatel_spec *spec; |
5248 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; | 5209 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
5249 | int err = 0; | 5210 | int err = 0; |
5250 | unsigned int ndmic_nids = 0; | ||
5251 | 5211 | ||
5252 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5212 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
5253 | if (spec == NULL) | 5213 | if (spec == NULL) |
@@ -5276,8 +5236,8 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) | |||
5276 | stac92hd71bxx_cfg_tbl); | 5236 | stac92hd71bxx_cfg_tbl); |
5277 | again: | 5237 | again: |
5278 | if (spec->board_config < 0) | 5238 | if (spec->board_config < 0) |
5279 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 5239 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5280 | " STAC92HD71BXX, using BIOS defaults\n"); | 5240 | codec->chip_name); |
5281 | else | 5241 | else |
5282 | stac92xx_set_config_regs(codec, | 5242 | stac92xx_set_config_regs(codec, |
5283 | stac92hd71bxx_brd_tbl[spec->board_config]); | 5243 | stac92hd71bxx_brd_tbl[spec->board_config]); |
@@ -5292,6 +5252,10 @@ again: | |||
5292 | spec->dmic_nids = stac92hd71bxx_dmic_nids; | 5252 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
5293 | spec->dmux_nids = stac92hd71bxx_dmux_nids; | 5253 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
5294 | 5254 | ||
5255 | spec->num_caps = STAC92HD71BXX_NUM_CAPS; | ||
5256 | spec->capvols = stac92hd71bxx_capvols; | ||
5257 | spec->capsws = stac92hd71bxx_capsws; | ||
5258 | |||
5295 | switch (codec->vendor_id) { | 5259 | switch (codec->vendor_id) { |
5296 | case 0x111d76b6: /* 4 Port without Analog Mixer */ | 5260 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
5297 | case 0x111d76b7: | 5261 | case 0x111d76b7: |
@@ -5299,24 +5263,13 @@ again: | |||
5299 | /* fallthru */ | 5263 | /* fallthru */ |
5300 | case 0x111d76b4: /* 6 Port without Analog Mixer */ | 5264 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
5301 | case 0x111d76b5: | 5265 | case 0x111d76b5: |
5302 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer, | ||
5303 | sizeof(stac92hd71bxx_dmux_nomixer)); | ||
5304 | spec->mixer = stac92hd71bxx_mixer; | ||
5305 | spec->init = stac92hd71bxx_core_init; | 5266 | spec->init = stac92hd71bxx_core_init; |
5306 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; | 5267 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
5307 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, | 5268 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
5308 | stac92hd71bxx_dmic_nids, | 5269 | stac92hd71bxx_dmic_nids, |
5309 | STAC92HD71BXX_NUM_DMICS); | 5270 | STAC92HD71BXX_NUM_DMICS); |
5310 | if (spec->num_dmics) { | ||
5311 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | ||
5312 | spec->dinput_mux = &spec->private_dimux; | ||
5313 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; | ||
5314 | } | ||
5315 | break; | 5271 | break; |
5316 | case 0x111d7608: /* 5 Port with Analog Mixer */ | 5272 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
5317 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, | ||
5318 | sizeof(stac92hd71bxx_dmux_amixer)); | ||
5319 | spec->private_dimux.num_items--; | ||
5320 | switch (spec->board_config) { | 5273 | switch (spec->board_config) { |
5321 | case STAC_HP_M4: | 5274 | case STAC_HP_M4: |
5322 | /* Enable VREF power saving on GPIO1 detect */ | 5275 | /* Enable VREF power saving on GPIO1 detect */ |
@@ -5338,11 +5291,8 @@ again: | |||
5338 | 5291 | ||
5339 | /* no output amps */ | 5292 | /* no output amps */ |
5340 | spec->num_pwrs = 0; | 5293 | spec->num_pwrs = 0; |
5341 | spec->mixer = stac92hd71bxx_analog_mixer; | ||
5342 | spec->dinput_mux = &spec->private_dimux; | ||
5343 | |||
5344 | /* disable VSW */ | 5294 | /* disable VSW */ |
5345 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; | 5295 | spec->init = stac92hd71bxx_core_init; |
5346 | unmute_init++; | 5296 | unmute_init++; |
5347 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); | 5297 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
5348 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); | 5298 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
@@ -5350,8 +5300,6 @@ again: | |||
5350 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, | 5300 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
5351 | stac92hd71bxx_dmic_nids, | 5301 | stac92hd71bxx_dmic_nids, |
5352 | STAC92HD71BXX_NUM_DMICS - 1); | 5302 | STAC92HD71BXX_NUM_DMICS - 1); |
5353 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | ||
5354 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2; | ||
5355 | break; | 5303 | break; |
5356 | case 0x111d7603: /* 6 Port with Analog Mixer */ | 5304 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
5357 | if ((codec->revision_id & 0xf) == 1) | 5305 | if ((codec->revision_id & 0xf) == 1) |
@@ -5361,17 +5309,12 @@ again: | |||
5361 | spec->num_pwrs = 0; | 5309 | spec->num_pwrs = 0; |
5362 | /* fallthru */ | 5310 | /* fallthru */ |
5363 | default: | 5311 | default: |
5364 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, | 5312 | spec->init = stac92hd71bxx_core_init; |
5365 | sizeof(stac92hd71bxx_dmux_amixer)); | ||
5366 | spec->dinput_mux = &spec->private_dimux; | ||
5367 | spec->mixer = stac92hd71bxx_analog_mixer; | ||
5368 | spec->init = stac92hd71bxx_analog_core_init; | ||
5369 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; | 5313 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
5370 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, | 5314 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
5371 | stac92hd71bxx_dmic_nids, | 5315 | stac92hd71bxx_dmic_nids, |
5372 | STAC92HD71BXX_NUM_DMICS); | 5316 | STAC92HD71BXX_NUM_DMICS); |
5373 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | 5317 | break; |
5374 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; | ||
5375 | } | 5318 | } |
5376 | 5319 | ||
5377 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) | 5320 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
@@ -5399,6 +5342,7 @@ again: | |||
5399 | 5342 | ||
5400 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); | 5343 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
5401 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); | 5344 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
5345 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | ||
5402 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); | 5346 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
5403 | 5347 | ||
5404 | switch (spec->board_config) { | 5348 | switch (spec->board_config) { |
@@ -5453,8 +5397,6 @@ again: | |||
5453 | #endif | 5397 | #endif |
5454 | 5398 | ||
5455 | spec->multiout.dac_nids = spec->dac_nids; | 5399 | spec->multiout.dac_nids = spec->dac_nids; |
5456 | if (spec->dinput_mux) | ||
5457 | spec->private_dimux.num_items += spec->num_dmics - ndmic_nids; | ||
5458 | 5400 | ||
5459 | err = stac92xx_parse_auto_config(codec, 0x21, 0); | 5401 | err = stac92xx_parse_auto_config(codec, 0x21, 0); |
5460 | if (!err) { | 5402 | if (!err) { |
@@ -5532,8 +5474,8 @@ static int patch_stac922x(struct hda_codec *codec) | |||
5532 | 5474 | ||
5533 | again: | 5475 | again: |
5534 | if (spec->board_config < 0) | 5476 | if (spec->board_config < 0) |
5535 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " | 5477 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5536 | "using BIOS defaults\n"); | 5478 | codec->chip_name); |
5537 | else | 5479 | else |
5538 | stac92xx_set_config_regs(codec, | 5480 | stac92xx_set_config_regs(codec, |
5539 | stac922x_brd_tbl[spec->board_config]); | 5481 | stac922x_brd_tbl[spec->board_config]); |
@@ -5546,7 +5488,10 @@ static int patch_stac922x(struct hda_codec *codec) | |||
5546 | spec->num_pwrs = 0; | 5488 | spec->num_pwrs = 0; |
5547 | 5489 | ||
5548 | spec->init = stac922x_core_init; | 5490 | spec->init = stac922x_core_init; |
5549 | spec->mixer = stac922x_mixer; | 5491 | |
5492 | spec->num_caps = STAC922X_NUM_CAPS; | ||
5493 | spec->capvols = stac922x_capvols; | ||
5494 | spec->capsws = stac922x_capsws; | ||
5550 | 5495 | ||
5551 | spec->multiout.dac_nids = spec->dac_nids; | 5496 | spec->multiout.dac_nids = spec->dac_nids; |
5552 | 5497 | ||
@@ -5595,8 +5540,8 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5595 | stac927x_cfg_tbl); | 5540 | stac927x_cfg_tbl); |
5596 | again: | 5541 | again: |
5597 | if (spec->board_config < 0) | 5542 | if (spec->board_config < 0) |
5598 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 5543 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5599 | "STAC927x, using BIOS defaults\n"); | 5544 | codec->chip_name); |
5600 | else | 5545 | else |
5601 | stac92xx_set_config_regs(codec, | 5546 | stac92xx_set_config_regs(codec, |
5602 | stac927x_brd_tbl[spec->board_config]); | 5547 | stac927x_brd_tbl[spec->board_config]); |
@@ -5621,7 +5566,6 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5621 | spec->num_dmics = 0; | 5566 | spec->num_dmics = 0; |
5622 | 5567 | ||
5623 | spec->init = d965_core_init; | 5568 | spec->init = d965_core_init; |
5624 | spec->mixer = stac927x_mixer; | ||
5625 | break; | 5569 | break; |
5626 | case STAC_DELL_BIOS: | 5570 | case STAC_DELL_BIOS: |
5627 | switch (codec->subsystem_id) { | 5571 | switch (codec->subsystem_id) { |
@@ -5642,11 +5586,17 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5642 | /* GPIO2 High = Enable EAPD */ | 5586 | /* GPIO2 High = Enable EAPD */ |
5643 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; | 5587 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
5644 | spec->gpio_data = 0x04; | 5588 | spec->gpio_data = 0x04; |
5589 | switch (codec->subsystem_id) { | ||
5590 | case 0x1028022f: | ||
5591 | /* correct EAPD to be GPIO0 */ | ||
5592 | spec->eapd_mask = spec->gpio_mask = 0x01; | ||
5593 | spec->gpio_dir = spec->gpio_data = 0x01; | ||
5594 | break; | ||
5595 | }; | ||
5645 | spec->dmic_nids = stac927x_dmic_nids; | 5596 | spec->dmic_nids = stac927x_dmic_nids; |
5646 | spec->num_dmics = STAC927X_NUM_DMICS; | 5597 | spec->num_dmics = STAC927X_NUM_DMICS; |
5647 | 5598 | ||
5648 | spec->init = d965_core_init; | 5599 | spec->init = d965_core_init; |
5649 | spec->mixer = stac927x_mixer; | ||
5650 | spec->dmux_nids = stac927x_dmux_nids; | 5600 | spec->dmux_nids = stac927x_dmux_nids; |
5651 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); | 5601 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
5652 | break; | 5602 | break; |
@@ -5659,9 +5609,12 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5659 | spec->num_dmics = 0; | 5609 | spec->num_dmics = 0; |
5660 | 5610 | ||
5661 | spec->init = stac927x_core_init; | 5611 | spec->init = stac927x_core_init; |
5662 | spec->mixer = stac927x_mixer; | ||
5663 | } | 5612 | } |
5664 | 5613 | ||
5614 | spec->num_caps = STAC927X_NUM_CAPS; | ||
5615 | spec->capvols = stac927x_capvols; | ||
5616 | spec->capsws = stac927x_capsws; | ||
5617 | |||
5665 | spec->num_pwrs = 0; | 5618 | spec->num_pwrs = 0; |
5666 | spec->aloopback_ctl = stac927x_loopback; | 5619 | spec->aloopback_ctl = stac927x_loopback; |
5667 | spec->aloopback_mask = 0x40; | 5620 | spec->aloopback_mask = 0x40; |
@@ -5723,7 +5676,8 @@ static int patch_stac9205(struct hda_codec *codec) | |||
5723 | stac9205_cfg_tbl); | 5676 | stac9205_cfg_tbl); |
5724 | again: | 5677 | again: |
5725 | if (spec->board_config < 0) | 5678 | if (spec->board_config < 0) |
5726 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); | 5679 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5680 | codec->chip_name); | ||
5727 | else | 5681 | else |
5728 | stac92xx_set_config_regs(codec, | 5682 | stac92xx_set_config_regs(codec, |
5729 | stac9205_brd_tbl[spec->board_config]); | 5683 | stac9205_brd_tbl[spec->board_config]); |
@@ -5742,9 +5696,12 @@ static int patch_stac9205(struct hda_codec *codec) | |||
5742 | spec->num_pwrs = 0; | 5696 | spec->num_pwrs = 0; |
5743 | 5697 | ||
5744 | spec->init = stac9205_core_init; | 5698 | spec->init = stac9205_core_init; |
5745 | spec->mixer = stac9205_mixer; | ||
5746 | spec->aloopback_ctl = stac9205_loopback; | 5699 | spec->aloopback_ctl = stac9205_loopback; |
5747 | 5700 | ||
5701 | spec->num_caps = STAC9205_NUM_CAPS; | ||
5702 | spec->capvols = stac9205_capvols; | ||
5703 | spec->capsws = stac9205_capsws; | ||
5704 | |||
5748 | spec->aloopback_mask = 0x40; | 5705 | spec->aloopback_mask = 0x40; |
5749 | spec->aloopback_shift = 0; | 5706 | spec->aloopback_shift = 0; |
5750 | /* Turn on/off EAPD per HP plugging */ | 5707 | /* Turn on/off EAPD per HP plugging */ |
@@ -5819,12 +5776,6 @@ static struct hda_verb stac9872_core_init[] = { | |||
5819 | {} | 5776 | {} |
5820 | }; | 5777 | }; |
5821 | 5778 | ||
5822 | static struct snd_kcontrol_new stac9872_mixer[] = { | ||
5823 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), | ||
5824 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), | ||
5825 | { } /* end */ | ||
5826 | }; | ||
5827 | |||
5828 | static hda_nid_t stac9872_pin_nids[] = { | 5779 | static hda_nid_t stac9872_pin_nids[] = { |
5829 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | 5780 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
5830 | 0x11, 0x13, 0x14, | 5781 | 0x11, 0x13, 0x14, |
@@ -5838,6 +5789,11 @@ static hda_nid_t stac9872_mux_nids[] = { | |||
5838 | 0x15 | 5789 | 0x15 |
5839 | }; | 5790 | }; |
5840 | 5791 | ||
5792 | static unsigned long stac9872_capvols[] = { | ||
5793 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | ||
5794 | }; | ||
5795 | #define stac9872_capsws stac9872_capvols | ||
5796 | |||
5841 | static unsigned int stac9872_vaio_pin_configs[9] = { | 5797 | static unsigned int stac9872_vaio_pin_configs[9] = { |
5842 | 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, | 5798 | 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, |
5843 | 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, | 5799 | 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, |
@@ -5854,6 +5810,8 @@ static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = { | |||
5854 | }; | 5810 | }; |
5855 | 5811 | ||
5856 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { | 5812 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
5813 | SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0, | ||
5814 | "Sony VAIO F/S", STAC_9872_VAIO), | ||
5857 | {} /* terminator */ | 5815 | {} /* terminator */ |
5858 | }; | 5816 | }; |
5859 | 5817 | ||
@@ -5866,26 +5824,28 @@ static int patch_stac9872(struct hda_codec *codec) | |||
5866 | if (spec == NULL) | 5824 | if (spec == NULL) |
5867 | return -ENOMEM; | 5825 | return -ENOMEM; |
5868 | codec->spec = spec; | 5826 | codec->spec = spec; |
5827 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); | ||
5828 | spec->pin_nids = stac9872_pin_nids; | ||
5869 | 5829 | ||
5870 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, | 5830 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
5871 | stac9872_models, | 5831 | stac9872_models, |
5872 | stac9872_cfg_tbl); | 5832 | stac9872_cfg_tbl); |
5873 | if (spec->board_config < 0) | 5833 | if (spec->board_config < 0) |
5874 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, " | 5834 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
5875 | "using BIOS defaults\n"); | 5835 | codec->chip_name); |
5876 | else | 5836 | else |
5877 | stac92xx_set_config_regs(codec, | 5837 | stac92xx_set_config_regs(codec, |
5878 | stac9872_brd_tbl[spec->board_config]); | 5838 | stac9872_brd_tbl[spec->board_config]); |
5879 | 5839 | ||
5880 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); | ||
5881 | spec->pin_nids = stac9872_pin_nids; | ||
5882 | spec->multiout.dac_nids = spec->dac_nids; | 5840 | spec->multiout.dac_nids = spec->dac_nids; |
5883 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); | 5841 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
5884 | spec->adc_nids = stac9872_adc_nids; | 5842 | spec->adc_nids = stac9872_adc_nids; |
5885 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); | 5843 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
5886 | spec->mux_nids = stac9872_mux_nids; | 5844 | spec->mux_nids = stac9872_mux_nids; |
5887 | spec->mixer = stac9872_mixer; | ||
5888 | spec->init = stac9872_core_init; | 5845 | spec->init = stac9872_core_init; |
5846 | spec->num_caps = 1; | ||
5847 | spec->capvols = stac9872_capvols; | ||
5848 | spec->capsws = stac9872_capsws; | ||
5889 | 5849 | ||
5890 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); | 5850 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); |
5891 | if (err < 0) { | 5851 | if (err < 0) { |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 8e004fb6961a..ee89db90c9b6 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -210,7 +210,9 @@ struct via_spec { | |||
210 | /* capture */ | 210 | /* capture */ |
211 | unsigned int num_adc_nids; | 211 | unsigned int num_adc_nids; |
212 | hda_nid_t *adc_nids; | 212 | hda_nid_t *adc_nids; |
213 | hda_nid_t mux_nids[3]; | ||
213 | hda_nid_t dig_in_nid; | 214 | hda_nid_t dig_in_nid; |
215 | hda_nid_t dig_in_pin; | ||
214 | 216 | ||
215 | /* capture source */ | 217 | /* capture source */ |
216 | const struct hda_input_mux *input_mux; | 218 | const struct hda_input_mux *input_mux; |
@@ -319,6 +321,9 @@ static void via_auto_set_output_and_unmute(struct hda_codec *codec, | |||
319 | pin_type); | 321 | pin_type); |
320 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 322 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
321 | AMP_OUT_UNMUTE); | 323 | AMP_OUT_UNMUTE); |
324 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) | ||
325 | snd_hda_codec_write(codec, nid, 0, | ||
326 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); | ||
322 | } | 327 | } |
323 | 328 | ||
324 | 329 | ||
@@ -387,27 +392,12 @@ static int via_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
387 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 392 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
388 | struct via_spec *spec = codec->spec; | 393 | struct via_spec *spec = codec->spec; |
389 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 394 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
390 | unsigned int vendor_id = codec->vendor_id; | 395 | |
391 | 396 | if (!spec->mux_nids[adc_idx]) | |
392 | /* AIW0 lydia 060801 add for correct sw0 input select */ | 397 | return -EINVAL; |
393 | if (IS_VT1708_VENDORID(vendor_id) && (adc_idx == 0)) | 398 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
394 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | 399 | spec->mux_nids[adc_idx], |
395 | 0x18, &spec->cur_mux[adc_idx]); | 400 | &spec->cur_mux[adc_idx]); |
396 | else if ((IS_VT1709_10CH_VENDORID(vendor_id) || | ||
397 | IS_VT1709_6CH_VENDORID(vendor_id)) && (adc_idx == 0)) | ||
398 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | ||
399 | 0x19, &spec->cur_mux[adc_idx]); | ||
400 | else if ((IS_VT1708B_8CH_VENDORID(vendor_id) || | ||
401 | IS_VT1708B_4CH_VENDORID(vendor_id)) && (adc_idx == 0)) | ||
402 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | ||
403 | 0x17, &spec->cur_mux[adc_idx]); | ||
404 | else if (IS_VT1702_VENDORID(vendor_id) && (adc_idx == 0)) | ||
405 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | ||
406 | 0x13, &spec->cur_mux[adc_idx]); | ||
407 | else | ||
408 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, | ||
409 | spec->adc_nids[adc_idx], | ||
410 | &spec->cur_mux[adc_idx]); | ||
411 | } | 401 | } |
412 | 402 | ||
413 | static int via_independent_hp_info(struct snd_kcontrol *kcontrol, | 403 | static int via_independent_hp_info(struct snd_kcontrol *kcontrol, |
@@ -998,25 +988,11 @@ static int via_init(struct hda_codec *codec) | |||
998 | 988 | ||
999 | /* Lydia Add for EAPD enable */ | 989 | /* Lydia Add for EAPD enable */ |
1000 | if (!spec->dig_in_nid) { /* No Digital In connection */ | 990 | if (!spec->dig_in_nid) { /* No Digital In connection */ |
1001 | if (IS_VT1708_VENDORID(codec->vendor_id)) { | 991 | if (spec->dig_in_pin) { |
1002 | snd_hda_codec_write(codec, VT1708_DIGIN_PIN, 0, | 992 | snd_hda_codec_write(codec, spec->dig_in_pin, 0, |
1003 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1004 | PIN_OUT); | ||
1005 | snd_hda_codec_write(codec, VT1708_DIGIN_PIN, 0, | ||
1006 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); | ||
1007 | } else if (IS_VT1709_10CH_VENDORID(codec->vendor_id) || | ||
1008 | IS_VT1709_6CH_VENDORID(codec->vendor_id)) { | ||
1009 | snd_hda_codec_write(codec, VT1709_DIGIN_PIN, 0, | ||
1010 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 993 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
1011 | PIN_OUT); | 994 | PIN_OUT); |
1012 | snd_hda_codec_write(codec, VT1709_DIGIN_PIN, 0, | 995 | snd_hda_codec_write(codec, spec->dig_in_pin, 0, |
1013 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); | ||
1014 | } else if (IS_VT1708B_8CH_VENDORID(codec->vendor_id) || | ||
1015 | IS_VT1708B_4CH_VENDORID(codec->vendor_id)) { | ||
1016 | snd_hda_codec_write(codec, VT1708B_DIGIN_PIN, 0, | ||
1017 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1018 | PIN_OUT); | ||
1019 | snd_hda_codec_write(codec, VT1708B_DIGIN_PIN, 0, | ||
1020 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); | 996 | AC_VERB_SET_EAPD_BTLENABLE, 0x02); |
1021 | } | 997 | } |
1022 | } else /* enable SPDIF-input pin */ | 998 | } else /* enable SPDIF-input pin */ |
@@ -1326,6 +1302,7 @@ static int vt1708_parse_auto_config(struct hda_codec *codec) | |||
1326 | 1302 | ||
1327 | if (spec->autocfg.dig_outs) | 1303 | if (spec->autocfg.dig_outs) |
1328 | spec->multiout.dig_out_nid = VT1708_DIGOUT_NID; | 1304 | spec->multiout.dig_out_nid = VT1708_DIGOUT_NID; |
1305 | spec->dig_in_pin = VT1708_DIGIN_PIN; | ||
1329 | if (spec->autocfg.dig_in_pin) | 1306 | if (spec->autocfg.dig_in_pin) |
1330 | spec->dig_in_nid = VT1708_DIGIN_NID; | 1307 | spec->dig_in_nid = VT1708_DIGIN_NID; |
1331 | 1308 | ||
@@ -1352,6 +1329,33 @@ static int via_auto_init(struct hda_codec *codec) | |||
1352 | return 0; | 1329 | return 0; |
1353 | } | 1330 | } |
1354 | 1331 | ||
1332 | static int get_mux_nids(struct hda_codec *codec) | ||
1333 | { | ||
1334 | struct via_spec *spec = codec->spec; | ||
1335 | hda_nid_t nid, conn[8]; | ||
1336 | unsigned int type; | ||
1337 | int i, n; | ||
1338 | |||
1339 | for (i = 0; i < spec->num_adc_nids; i++) { | ||
1340 | nid = spec->adc_nids[i]; | ||
1341 | while (nid) { | ||
1342 | type = get_wcaps_type(get_wcaps(codec, nid)); | ||
1343 | if (type == AC_WID_PIN) | ||
1344 | break; | ||
1345 | n = snd_hda_get_connections(codec, nid, conn, | ||
1346 | ARRAY_SIZE(conn)); | ||
1347 | if (n <= 0) | ||
1348 | break; | ||
1349 | if (n > 1) { | ||
1350 | spec->mux_nids[i] = nid; | ||
1351 | break; | ||
1352 | } | ||
1353 | nid = conn[0]; | ||
1354 | } | ||
1355 | } | ||
1356 | return 0; | ||
1357 | } | ||
1358 | |||
1355 | static int patch_vt1708(struct hda_codec *codec) | 1359 | static int patch_vt1708(struct hda_codec *codec) |
1356 | { | 1360 | { |
1357 | struct via_spec *spec; | 1361 | struct via_spec *spec; |
@@ -1390,6 +1394,7 @@ static int patch_vt1708(struct hda_codec *codec) | |||
1390 | if (!spec->adc_nids && spec->input_mux) { | 1394 | if (!spec->adc_nids && spec->input_mux) { |
1391 | spec->adc_nids = vt1708_adc_nids; | 1395 | spec->adc_nids = vt1708_adc_nids; |
1392 | spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids); | 1396 | spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids); |
1397 | get_mux_nids(codec); | ||
1393 | spec->mixers[spec->num_mixers] = vt1708_capture_mixer; | 1398 | spec->mixers[spec->num_mixers] = vt1708_capture_mixer; |
1394 | spec->num_mixers++; | 1399 | spec->num_mixers++; |
1395 | } | 1400 | } |
@@ -1799,6 +1804,7 @@ static int vt1709_parse_auto_config(struct hda_codec *codec) | |||
1799 | 1804 | ||
1800 | if (spec->autocfg.dig_outs) | 1805 | if (spec->autocfg.dig_outs) |
1801 | spec->multiout.dig_out_nid = VT1709_DIGOUT_NID; | 1806 | spec->multiout.dig_out_nid = VT1709_DIGOUT_NID; |
1807 | spec->dig_in_pin = VT1709_DIGIN_PIN; | ||
1802 | if (spec->autocfg.dig_in_pin) | 1808 | if (spec->autocfg.dig_in_pin) |
1803 | spec->dig_in_nid = VT1709_DIGIN_NID; | 1809 | spec->dig_in_nid = VT1709_DIGIN_NID; |
1804 | 1810 | ||
@@ -1859,6 +1865,7 @@ static int patch_vt1709_10ch(struct hda_codec *codec) | |||
1859 | if (!spec->adc_nids && spec->input_mux) { | 1865 | if (!spec->adc_nids && spec->input_mux) { |
1860 | spec->adc_nids = vt1709_adc_nids; | 1866 | spec->adc_nids = vt1709_adc_nids; |
1861 | spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); | 1867 | spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); |
1868 | get_mux_nids(codec); | ||
1862 | spec->mixers[spec->num_mixers] = vt1709_capture_mixer; | 1869 | spec->mixers[spec->num_mixers] = vt1709_capture_mixer; |
1863 | spec->num_mixers++; | 1870 | spec->num_mixers++; |
1864 | } | 1871 | } |
@@ -1952,6 +1959,7 @@ static int patch_vt1709_6ch(struct hda_codec *codec) | |||
1952 | if (!spec->adc_nids && spec->input_mux) { | 1959 | if (!spec->adc_nids && spec->input_mux) { |
1953 | spec->adc_nids = vt1709_adc_nids; | 1960 | spec->adc_nids = vt1709_adc_nids; |
1954 | spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); | 1961 | spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); |
1962 | get_mux_nids(codec); | ||
1955 | spec->mixers[spec->num_mixers] = vt1709_capture_mixer; | 1963 | spec->mixers[spec->num_mixers] = vt1709_capture_mixer; |
1956 | spec->num_mixers++; | 1964 | spec->num_mixers++; |
1957 | } | 1965 | } |
@@ -2344,6 +2352,7 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec) | |||
2344 | 2352 | ||
2345 | if (spec->autocfg.dig_outs) | 2353 | if (spec->autocfg.dig_outs) |
2346 | spec->multiout.dig_out_nid = VT1708B_DIGOUT_NID; | 2354 | spec->multiout.dig_out_nid = VT1708B_DIGOUT_NID; |
2355 | spec->dig_in_pin = VT1708B_DIGIN_PIN; | ||
2347 | if (spec->autocfg.dig_in_pin) | 2356 | if (spec->autocfg.dig_in_pin) |
2348 | spec->dig_in_nid = VT1708B_DIGIN_NID; | 2357 | spec->dig_in_nid = VT1708B_DIGIN_NID; |
2349 | 2358 | ||
@@ -2404,6 +2413,7 @@ static int patch_vt1708B_8ch(struct hda_codec *codec) | |||
2404 | if (!spec->adc_nids && spec->input_mux) { | 2413 | if (!spec->adc_nids && spec->input_mux) { |
2405 | spec->adc_nids = vt1708B_adc_nids; | 2414 | spec->adc_nids = vt1708B_adc_nids; |
2406 | spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids); | 2415 | spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids); |
2416 | get_mux_nids(codec); | ||
2407 | spec->mixers[spec->num_mixers] = vt1708B_capture_mixer; | 2417 | spec->mixers[spec->num_mixers] = vt1708B_capture_mixer; |
2408 | spec->num_mixers++; | 2418 | spec->num_mixers++; |
2409 | } | 2419 | } |
@@ -2455,6 +2465,7 @@ static int patch_vt1708B_4ch(struct hda_codec *codec) | |||
2455 | if (!spec->adc_nids && spec->input_mux) { | 2465 | if (!spec->adc_nids && spec->input_mux) { |
2456 | spec->adc_nids = vt1708B_adc_nids; | 2466 | spec->adc_nids = vt1708B_adc_nids; |
2457 | spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids); | 2467 | spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids); |
2468 | get_mux_nids(codec); | ||
2458 | spec->mixers[spec->num_mixers] = vt1708B_capture_mixer; | 2469 | spec->mixers[spec->num_mixers] = vt1708B_capture_mixer; |
2459 | spec->num_mixers++; | 2470 | spec->num_mixers++; |
2460 | } | 2471 | } |
@@ -2889,6 +2900,7 @@ static int patch_vt1708S(struct hda_codec *codec) | |||
2889 | if (!spec->adc_nids && spec->input_mux) { | 2900 | if (!spec->adc_nids && spec->input_mux) { |
2890 | spec->adc_nids = vt1708S_adc_nids; | 2901 | spec->adc_nids = vt1708S_adc_nids; |
2891 | spec->num_adc_nids = ARRAY_SIZE(vt1708S_adc_nids); | 2902 | spec->num_adc_nids = ARRAY_SIZE(vt1708S_adc_nids); |
2903 | get_mux_nids(codec); | ||
2892 | spec->mixers[spec->num_mixers] = vt1708S_capture_mixer; | 2904 | spec->mixers[spec->num_mixers] = vt1708S_capture_mixer; |
2893 | spec->num_mixers++; | 2905 | spec->num_mixers++; |
2894 | } | 2906 | } |
@@ -3206,6 +3218,7 @@ static int patch_vt1702(struct hda_codec *codec) | |||
3206 | if (!spec->adc_nids && spec->input_mux) { | 3218 | if (!spec->adc_nids && spec->input_mux) { |
3207 | spec->adc_nids = vt1702_adc_nids; | 3219 | spec->adc_nids = vt1702_adc_nids; |
3208 | spec->num_adc_nids = ARRAY_SIZE(vt1702_adc_nids); | 3220 | spec->num_adc_nids = ARRAY_SIZE(vt1702_adc_nids); |
3221 | get_mux_nids(codec); | ||
3209 | spec->mixers[spec->num_mixers] = vt1702_capture_mixer; | 3222 | spec->mixers[spec->num_mixers] = vt1702_capture_mixer; |
3210 | spec->num_mixers++; | 3223 | spec->num_mixers++; |
3211 | } | 3224 | } |
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 0d0cdbdb4486..cecf1ffeeaaa 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c | |||
@@ -107,7 +107,7 @@ MODULE_PARM_DESC(dxr_enable, "Enable DXR support for Terratec DMX6FIRE."); | |||
107 | 107 | ||
108 | 108 | ||
109 | static const struct pci_device_id snd_ice1712_ids[] = { | 109 | static const struct pci_device_id snd_ice1712_ids[] = { |
110 | { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_ICE_1712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICE1712 */ | 110 | { PCI_VDEVICE(ICE, PCI_DEVICE_ID_ICE_1712), 0 }, /* ICE1712 */ |
111 | { 0, } | 111 | { 0, } |
112 | }; | 112 | }; |
113 | 113 | ||
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h index adc909ec125c..9da2dae64c5b 100644 --- a/sound/pci/ice1712/ice1712.h +++ b/sound/pci/ice1712/ice1712.h | |||
@@ -379,6 +379,15 @@ struct snd_ice1712 { | |||
379 | unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate); | 379 | unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate); |
380 | void (*set_spdif_clock)(struct snd_ice1712 *ice); | 380 | void (*set_spdif_clock)(struct snd_ice1712 *ice); |
381 | 381 | ||
382 | #ifdef CONFIG_PM | ||
383 | int (*pm_suspend)(struct snd_ice1712 *); | ||
384 | int (*pm_resume)(struct snd_ice1712 *); | ||
385 | int pm_suspend_enabled:1; | ||
386 | int pm_saved_is_spdif_master:1; | ||
387 | unsigned int pm_saved_spdif_ctrl; | ||
388 | unsigned char pm_saved_spdif_cfg; | ||
389 | unsigned int pm_saved_route; | ||
390 | #endif | ||
382 | }; | 391 | }; |
383 | 392 | ||
384 | 393 | ||
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 36ade77cf371..af6e00148621 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c | |||
@@ -93,7 +93,7 @@ MODULE_PARM_DESC(model, "Use the given board model."); | |||
93 | 93 | ||
94 | /* Both VT1720 and VT1724 have the same PCI IDs */ | 94 | /* Both VT1720 and VT1724 have the same PCI IDs */ |
95 | static const struct pci_device_id snd_vt1724_ids[] = { | 95 | static const struct pci_device_id snd_vt1724_ids[] = { |
96 | { PCI_VENDOR_ID_ICE, PCI_DEVICE_ID_VT1724, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | 96 | { PCI_VDEVICE(ICE, PCI_DEVICE_ID_VT1724), 0 }, |
97 | { 0, } | 97 | { 0, } |
98 | }; | 98 | }; |
99 | 99 | ||
@@ -560,6 +560,7 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
560 | 560 | ||
561 | case SNDRV_PCM_TRIGGER_START: | 561 | case SNDRV_PCM_TRIGGER_START: |
562 | case SNDRV_PCM_TRIGGER_STOP: | 562 | case SNDRV_PCM_TRIGGER_STOP: |
563 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
563 | spin_lock(&ice->reg_lock); | 564 | spin_lock(&ice->reg_lock); |
564 | old = inb(ICEMT1724(ice, DMA_CONTROL)); | 565 | old = inb(ICEMT1724(ice, DMA_CONTROL)); |
565 | if (cmd == SNDRV_PCM_TRIGGER_START) | 566 | if (cmd == SNDRV_PCM_TRIGGER_START) |
@@ -570,6 +571,10 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
570 | spin_unlock(&ice->reg_lock); | 571 | spin_unlock(&ice->reg_lock); |
571 | break; | 572 | break; |
572 | 573 | ||
574 | case SNDRV_PCM_TRIGGER_RESUME: | ||
575 | /* apps will have to restart stream */ | ||
576 | break; | ||
577 | |||
573 | default: | 578 | default: |
574 | return -EINVAL; | 579 | return -EINVAL; |
575 | } | 580 | } |
@@ -2262,7 +2267,7 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice, | |||
2262 | 2267 | ||
2263 | 2268 | ||
2264 | 2269 | ||
2265 | static void __devinit snd_vt1724_chip_reset(struct snd_ice1712 *ice) | 2270 | static void snd_vt1724_chip_reset(struct snd_ice1712 *ice) |
2266 | { | 2271 | { |
2267 | outb(VT1724_RESET , ICEREG1724(ice, CONTROL)); | 2272 | outb(VT1724_RESET , ICEREG1724(ice, CONTROL)); |
2268 | inb(ICEREG1724(ice, CONTROL)); /* pci posting flush */ | 2273 | inb(ICEREG1724(ice, CONTROL)); /* pci posting flush */ |
@@ -2272,7 +2277,7 @@ static void __devinit snd_vt1724_chip_reset(struct snd_ice1712 *ice) | |||
2272 | msleep(10); | 2277 | msleep(10); |
2273 | } | 2278 | } |
2274 | 2279 | ||
2275 | static int __devinit snd_vt1724_chip_init(struct snd_ice1712 *ice) | 2280 | static int snd_vt1724_chip_init(struct snd_ice1712 *ice) |
2276 | { | 2281 | { |
2277 | outb(ice->eeprom.data[ICE_EEP2_SYSCONF], ICEREG1724(ice, SYS_CFG)); | 2282 | outb(ice->eeprom.data[ICE_EEP2_SYSCONF], ICEREG1724(ice, SYS_CFG)); |
2278 | outb(ice->eeprom.data[ICE_EEP2_ACLINK], ICEREG1724(ice, AC97_CFG)); | 2283 | outb(ice->eeprom.data[ICE_EEP2_ACLINK], ICEREG1724(ice, AC97_CFG)); |
@@ -2287,6 +2292,14 @@ static int __devinit snd_vt1724_chip_init(struct snd_ice1712 *ice) | |||
2287 | 2292 | ||
2288 | outb(0, ICEREG1724(ice, POWERDOWN)); | 2293 | outb(0, ICEREG1724(ice, POWERDOWN)); |
2289 | 2294 | ||
2295 | /* MPU_RX and TX irq masks are cleared later dynamically */ | ||
2296 | outb(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX , ICEREG1724(ice, IRQMASK)); | ||
2297 | |||
2298 | /* don't handle FIFO overrun/underruns (just yet), | ||
2299 | * since they cause machine lockups | ||
2300 | */ | ||
2301 | outb(VT1724_MULTI_FIFO_ERR, ICEMT1724(ice, DMA_INT_MASK)); | ||
2302 | |||
2290 | return 0; | 2303 | return 0; |
2291 | } | 2304 | } |
2292 | 2305 | ||
@@ -2431,6 +2444,8 @@ static int __devinit snd_vt1724_create(struct snd_card *card, | |||
2431 | snd_vt1724_proc_init(ice); | 2444 | snd_vt1724_proc_init(ice); |
2432 | synchronize_irq(pci->irq); | 2445 | synchronize_irq(pci->irq); |
2433 | 2446 | ||
2447 | card->private_data = ice; | ||
2448 | |||
2434 | err = pci_request_regions(pci, "ICE1724"); | 2449 | err = pci_request_regions(pci, "ICE1724"); |
2435 | if (err < 0) { | 2450 | if (err < 0) { |
2436 | kfree(ice); | 2451 | kfree(ice); |
@@ -2459,14 +2474,6 @@ static int __devinit snd_vt1724_create(struct snd_card *card, | |||
2459 | return -EIO; | 2474 | return -EIO; |
2460 | } | 2475 | } |
2461 | 2476 | ||
2462 | /* MPU_RX and TX irq masks are cleared later dynamically */ | ||
2463 | outb(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX , ICEREG1724(ice, IRQMASK)); | ||
2464 | |||
2465 | /* don't handle FIFO overrun/underruns (just yet), | ||
2466 | * since they cause machine lockups | ||
2467 | */ | ||
2468 | outb(VT1724_MULTI_FIFO_ERR, ICEMT1724(ice, DMA_INT_MASK)); | ||
2469 | |||
2470 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops); | 2477 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops); |
2471 | if (err < 0) { | 2478 | if (err < 0) { |
2472 | snd_vt1724_free(ice); | 2479 | snd_vt1724_free(ice); |
@@ -2650,11 +2657,96 @@ static void __devexit snd_vt1724_remove(struct pci_dev *pci) | |||
2650 | pci_set_drvdata(pci, NULL); | 2657 | pci_set_drvdata(pci, NULL); |
2651 | } | 2658 | } |
2652 | 2659 | ||
2660 | #ifdef CONFIG_PM | ||
2661 | static int snd_vt1724_suspend(struct pci_dev *pci, pm_message_t state) | ||
2662 | { | ||
2663 | struct snd_card *card = pci_get_drvdata(pci); | ||
2664 | struct snd_ice1712 *ice = card->private_data; | ||
2665 | |||
2666 | if (!ice->pm_suspend_enabled) | ||
2667 | return 0; | ||
2668 | |||
2669 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
2670 | |||
2671 | snd_pcm_suspend_all(ice->pcm); | ||
2672 | snd_pcm_suspend_all(ice->pcm_pro); | ||
2673 | snd_pcm_suspend_all(ice->pcm_ds); | ||
2674 | snd_ac97_suspend(ice->ac97); | ||
2675 | |||
2676 | spin_lock_irq(&ice->reg_lock); | ||
2677 | ice->pm_saved_is_spdif_master = ice->is_spdif_master(ice); | ||
2678 | ice->pm_saved_spdif_ctrl = inw(ICEMT1724(ice, SPDIF_CTRL)); | ||
2679 | ice->pm_saved_spdif_cfg = inb(ICEREG1724(ice, SPDIF_CFG)); | ||
2680 | ice->pm_saved_route = inl(ICEMT1724(ice, ROUTE_PLAYBACK)); | ||
2681 | spin_unlock_irq(&ice->reg_lock); | ||
2682 | |||
2683 | if (ice->pm_suspend) | ||
2684 | ice->pm_suspend(ice); | ||
2685 | |||
2686 | pci_disable_device(pci); | ||
2687 | pci_save_state(pci); | ||
2688 | pci_set_power_state(pci, pci_choose_state(pci, state)); | ||
2689 | return 0; | ||
2690 | } | ||
2691 | |||
2692 | static int snd_vt1724_resume(struct pci_dev *pci) | ||
2693 | { | ||
2694 | struct snd_card *card = pci_get_drvdata(pci); | ||
2695 | struct snd_ice1712 *ice = card->private_data; | ||
2696 | |||
2697 | if (!ice->pm_suspend_enabled) | ||
2698 | return 0; | ||
2699 | |||
2700 | pci_set_power_state(pci, PCI_D0); | ||
2701 | pci_restore_state(pci); | ||
2702 | |||
2703 | if (pci_enable_device(pci) < 0) { | ||
2704 | snd_card_disconnect(card); | ||
2705 | return -EIO; | ||
2706 | } | ||
2707 | |||
2708 | pci_set_master(pci); | ||
2709 | |||
2710 | snd_vt1724_chip_reset(ice); | ||
2711 | |||
2712 | if (snd_vt1724_chip_init(ice) < 0) { | ||
2713 | snd_card_disconnect(card); | ||
2714 | return -EIO; | ||
2715 | } | ||
2716 | |||
2717 | if (ice->pm_resume) | ||
2718 | ice->pm_resume(ice); | ||
2719 | |||
2720 | if (ice->pm_saved_is_spdif_master) { | ||
2721 | /* switching to external clock via SPDIF */ | ||
2722 | ice->set_spdif_clock(ice); | ||
2723 | } else { | ||
2724 | /* internal on-card clock */ | ||
2725 | snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1); | ||
2726 | } | ||
2727 | |||
2728 | update_spdif_bits(ice, ice->pm_saved_spdif_ctrl); | ||
2729 | |||
2730 | outb(ice->pm_saved_spdif_cfg, ICEREG1724(ice, SPDIF_CFG)); | ||
2731 | outl(ice->pm_saved_route, ICEMT1724(ice, ROUTE_PLAYBACK)); | ||
2732 | |||
2733 | if (ice->ac97) | ||
2734 | snd_ac97_resume(ice->ac97); | ||
2735 | |||
2736 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
2737 | return 0; | ||
2738 | } | ||
2739 | #endif | ||
2740 | |||
2653 | static struct pci_driver driver = { | 2741 | static struct pci_driver driver = { |
2654 | .name = "ICE1724", | 2742 | .name = "ICE1724", |
2655 | .id_table = snd_vt1724_ids, | 2743 | .id_table = snd_vt1724_ids, |
2656 | .probe = snd_vt1724_probe, | 2744 | .probe = snd_vt1724_probe, |
2657 | .remove = __devexit_p(snd_vt1724_remove), | 2745 | .remove = __devexit_p(snd_vt1724_remove), |
2746 | #ifdef CONFIG_PM | ||
2747 | .suspend = snd_vt1724_suspend, | ||
2748 | .resume = snd_vt1724_resume, | ||
2749 | #endif | ||
2658 | }; | 2750 | }; |
2659 | 2751 | ||
2660 | static int __init alsa_card_ice1724_init(void) | 2752 | static int __init alsa_card_ice1724_init(void) |
diff --git a/sound/pci/ice1712/prodigy_hifi.c b/sound/pci/ice1712/prodigy_hifi.c index 043a93879bd5..c75515f5be6f 100644 --- a/sound/pci/ice1712/prodigy_hifi.c +++ b/sound/pci/ice1712/prodigy_hifi.c | |||
@@ -1077,7 +1077,7 @@ static int __devinit prodigy_hifi_init(struct snd_ice1712 *ice) | |||
1077 | /* | 1077 | /* |
1078 | * initialize the chip | 1078 | * initialize the chip |
1079 | */ | 1079 | */ |
1080 | static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice) | 1080 | static void ak4396_init(struct snd_ice1712 *ice) |
1081 | { | 1081 | { |
1082 | static unsigned short ak4396_inits[] = { | 1082 | static unsigned short ak4396_inits[] = { |
1083 | AK4396_CTRL1, 0x87, /* I2S Normal Mode, 24 bit */ | 1083 | AK4396_CTRL1, 0x87, /* I2S Normal Mode, 24 bit */ |
@@ -1087,9 +1087,37 @@ static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice) | |||
1087 | AK4396_RCH_ATT, 0x00, | 1087 | AK4396_RCH_ATT, 0x00, |
1088 | }; | 1088 | }; |
1089 | 1089 | ||
1090 | struct prodigy_hifi_spec *spec; | ||
1091 | unsigned int i; | 1090 | unsigned int i; |
1092 | 1091 | ||
1092 | /* initialize ak4396 codec */ | ||
1093 | /* reset codec */ | ||
1094 | ak4396_write(ice, AK4396_CTRL1, 0x86); | ||
1095 | msleep(100); | ||
1096 | ak4396_write(ice, AK4396_CTRL1, 0x87); | ||
1097 | |||
1098 | for (i = 0; i < ARRAY_SIZE(ak4396_inits); i += 2) | ||
1099 | ak4396_write(ice, ak4396_inits[i], ak4396_inits[i+1]); | ||
1100 | } | ||
1101 | |||
1102 | #ifdef CONFIG_PM | ||
1103 | static int __devinit prodigy_hd2_resume(struct snd_ice1712 *ice) | ||
1104 | { | ||
1105 | /* initialize ak4396 codec and restore previous mixer volumes */ | ||
1106 | struct prodigy_hifi_spec *spec = ice->spec; | ||
1107 | int i; | ||
1108 | mutex_lock(&ice->gpio_mutex); | ||
1109 | ak4396_init(ice); | ||
1110 | for (i = 0; i < 2; i++) | ||
1111 | ak4396_write(ice, AK4396_LCH_ATT + i, spec->vol[i] & 0xff); | ||
1112 | mutex_unlock(&ice->gpio_mutex); | ||
1113 | return 0; | ||
1114 | } | ||
1115 | #endif | ||
1116 | |||
1117 | static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice) | ||
1118 | { | ||
1119 | struct prodigy_hifi_spec *spec; | ||
1120 | |||
1093 | ice->vt1720 = 0; | 1121 | ice->vt1720 = 0; |
1094 | ice->vt1724 = 1; | 1122 | ice->vt1724 = 1; |
1095 | 1123 | ||
@@ -1112,14 +1140,12 @@ static int __devinit prodigy_hd2_init(struct snd_ice1712 *ice) | |||
1112 | return -ENOMEM; | 1140 | return -ENOMEM; |
1113 | ice->spec = spec; | 1141 | ice->spec = spec; |
1114 | 1142 | ||
1115 | /* initialize ak4396 codec */ | 1143 | #ifdef CONFIG_PM |
1116 | /* reset codec */ | 1144 | ice->pm_resume = &prodigy_hd2_resume; |
1117 | ak4396_write(ice, AK4396_CTRL1, 0x86); | 1145 | ice->pm_suspend_enabled = 1; |
1118 | msleep(100); | 1146 | #endif |
1119 | ak4396_write(ice, AK4396_CTRL1, 0x87); | 1147 | |
1120 | 1148 | ak4396_init(ice); | |
1121 | for (i = 0; i < ARRAY_SIZE(ak4396_inits); i += 2) | ||
1122 | ak4396_write(ice, ak4396_inits[i], ak4396_inits[i+1]); | ||
1123 | 1149 | ||
1124 | return 0; | 1150 | return 0; |
1125 | } | 1151 | } |
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 8aa5687f392a..171ada535209 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c | |||
@@ -421,29 +421,29 @@ struct intel8x0 { | |||
421 | }; | 421 | }; |
422 | 422 | ||
423 | static struct pci_device_id snd_intel8x0_ids[] = { | 423 | static struct pci_device_id snd_intel8x0_ids[] = { |
424 | { 0x8086, 0x2415, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82801AA */ | 424 | { PCI_VDEVICE(INTEL, 0x2415), DEVICE_INTEL }, /* 82801AA */ |
425 | { 0x8086, 0x2425, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82901AB */ | 425 | { PCI_VDEVICE(INTEL, 0x2425), DEVICE_INTEL }, /* 82901AB */ |
426 | { 0x8086, 0x2445, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82801BA */ | 426 | { PCI_VDEVICE(INTEL, 0x2445), DEVICE_INTEL }, /* 82801BA */ |
427 | { 0x8086, 0x2485, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH3 */ | 427 | { PCI_VDEVICE(INTEL, 0x2485), DEVICE_INTEL }, /* ICH3 */ |
428 | { 0x8086, 0x24c5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ICH4 */ | 428 | { PCI_VDEVICE(INTEL, 0x24c5), DEVICE_INTEL_ICH4 }, /* ICH4 */ |
429 | { 0x8086, 0x24d5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ICH5 */ | 429 | { PCI_VDEVICE(INTEL, 0x24d5), DEVICE_INTEL_ICH4 }, /* ICH5 */ |
430 | { 0x8086, 0x25a6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ESB */ | 430 | { PCI_VDEVICE(INTEL, 0x25a6), DEVICE_INTEL_ICH4 }, /* ESB */ |
431 | { 0x8086, 0x266e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ICH6 */ | 431 | { PCI_VDEVICE(INTEL, 0x266e), DEVICE_INTEL_ICH4 }, /* ICH6 */ |
432 | { 0x8086, 0x27de, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ICH7 */ | 432 | { PCI_VDEVICE(INTEL, 0x27de), DEVICE_INTEL_ICH4 }, /* ICH7 */ |
433 | { 0x8086, 0x2698, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL_ICH4 }, /* ESB2 */ | 433 | { PCI_VDEVICE(INTEL, 0x2698), DEVICE_INTEL_ICH4 }, /* ESB2 */ |
434 | { 0x8086, 0x7195, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 440MX */ | 434 | { PCI_VDEVICE(INTEL, 0x7195), DEVICE_INTEL }, /* 440MX */ |
435 | { 0x1039, 0x7012, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_SIS }, /* SI7012 */ | 435 | { PCI_VDEVICE(SI, 0x7012), DEVICE_SIS }, /* SI7012 */ |
436 | { 0x10de, 0x01b1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE */ | 436 | { PCI_VDEVICE(NVIDIA, 0x01b1), DEVICE_NFORCE }, /* NFORCE */ |
437 | { 0x10de, 0x003a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* MCP04 */ | 437 | { PCI_VDEVICE(NVIDIA, 0x003a), DEVICE_NFORCE }, /* MCP04 */ |
438 | { 0x10de, 0x006a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE2 */ | 438 | { PCI_VDEVICE(NVIDIA, 0x006a), DEVICE_NFORCE }, /* NFORCE2 */ |
439 | { 0x10de, 0x0059, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK804 */ | 439 | { PCI_VDEVICE(NVIDIA, 0x0059), DEVICE_NFORCE }, /* CK804 */ |
440 | { 0x10de, 0x008a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK8 */ | 440 | { PCI_VDEVICE(NVIDIA, 0x008a), DEVICE_NFORCE }, /* CK8 */ |
441 | { 0x10de, 0x00da, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE3 */ | 441 | { PCI_VDEVICE(NVIDIA, 0x00da), DEVICE_NFORCE }, /* NFORCE3 */ |
442 | { 0x10de, 0x00ea, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* CK8S */ | 442 | { PCI_VDEVICE(NVIDIA, 0x00ea), DEVICE_NFORCE }, /* CK8S */ |
443 | { 0x10de, 0x026b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* MCP51 */ | 443 | { PCI_VDEVICE(NVIDIA, 0x026b), DEVICE_NFORCE }, /* MCP51 */ |
444 | { 0x1022, 0x746d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD8111 */ | 444 | { PCI_VDEVICE(AMD, 0x746d), DEVICE_INTEL }, /* AMD8111 */ |
445 | { 0x1022, 0x7445, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD768 */ | 445 | { PCI_VDEVICE(AMD, 0x7445), DEVICE_INTEL }, /* AMD768 */ |
446 | { 0x10b9, 0x5455, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALI }, /* Ali5455 */ | 446 | { PCI_VDEVICE(AL, 0x5455), DEVICE_ALI }, /* Ali5455 */ |
447 | { 0, } | 447 | { 0, } |
448 | }; | 448 | }; |
449 | 449 | ||
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 6ec0fc50d6be..9e7d12e7673f 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c | |||
@@ -220,24 +220,24 @@ struct intel8x0m { | |||
220 | }; | 220 | }; |
221 | 221 | ||
222 | static struct pci_device_id snd_intel8x0m_ids[] = { | 222 | static struct pci_device_id snd_intel8x0m_ids[] = { |
223 | { 0x8086, 0x2416, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82801AA */ | 223 | { PCI_VDEVICE(INTEL, 0x2416), DEVICE_INTEL }, /* 82801AA */ |
224 | { 0x8086, 0x2426, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82901AB */ | 224 | { PCI_VDEVICE(INTEL, 0x2426), DEVICE_INTEL }, /* 82901AB */ |
225 | { 0x8086, 0x2446, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 82801BA */ | 225 | { PCI_VDEVICE(INTEL, 0x2446), DEVICE_INTEL }, /* 82801BA */ |
226 | { 0x8086, 0x2486, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH3 */ | 226 | { PCI_VDEVICE(INTEL, 0x2486), DEVICE_INTEL }, /* ICH3 */ |
227 | { 0x8086, 0x24c6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH4 */ | 227 | { PCI_VDEVICE(INTEL, 0x24c6), DEVICE_INTEL }, /* ICH4 */ |
228 | { 0x8086, 0x24d6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH5 */ | 228 | { PCI_VDEVICE(INTEL, 0x24d6), DEVICE_INTEL }, /* ICH5 */ |
229 | { 0x8086, 0x266d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH6 */ | 229 | { PCI_VDEVICE(INTEL, 0x266d), DEVICE_INTEL }, /* ICH6 */ |
230 | { 0x8086, 0x27dd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* ICH7 */ | 230 | { PCI_VDEVICE(INTEL, 0x27dd), DEVICE_INTEL }, /* ICH7 */ |
231 | { 0x8086, 0x7196, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* 440MX */ | 231 | { PCI_VDEVICE(INTEL, 0x7196), DEVICE_INTEL }, /* 440MX */ |
232 | { 0x1022, 0x7446, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD768 */ | 232 | { PCI_VDEVICE(AMD, 0x7446), DEVICE_INTEL }, /* AMD768 */ |
233 | { 0x1039, 0x7013, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_SIS }, /* SI7013 */ | 233 | { PCI_VDEVICE(SI, 0x7013), DEVICE_SIS }, /* SI7013 */ |
234 | { 0x10de, 0x01c1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE */ | 234 | { PCI_VDEVICE(NVIDIA, 0x01c1), DEVICE_NFORCE }, /* NFORCE */ |
235 | { 0x10de, 0x0069, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE2 */ | 235 | { PCI_VDEVICE(NVIDIA, 0x0069), DEVICE_NFORCE }, /* NFORCE2 */ |
236 | { 0x10de, 0x0089, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE2s */ | 236 | { PCI_VDEVICE(NVIDIA, 0x0089), DEVICE_NFORCE }, /* NFORCE2s */ |
237 | { 0x10de, 0x00d9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_NFORCE }, /* NFORCE3 */ | 237 | { PCI_VDEVICE(NVIDIA, 0x00d9), DEVICE_NFORCE }, /* NFORCE3 */ |
238 | #if 0 | 238 | #if 0 |
239 | { 0x1022, 0x746d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_INTEL }, /* AMD8111 */ | 239 | { PCI_VDEVICE(AMD, 0x746d), DEVICE_INTEL }, /* AMD8111 */ |
240 | { 0x10b9, 0x5455, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALI }, /* Ali5455 */ | 240 | { PCI_VDEVICE(AL, 0x5455), DEVICE_ALI }, /* Ali5455 */ |
241 | #endif | 241 | #endif |
242 | { 0, } | 242 | { 0, } |
243 | }; | 243 | }; |
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index 18da2ef04d09..11b8c6514b3d 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c | |||
@@ -654,13 +654,12 @@ static int __devinit lx_init_ethersound_config(struct lx6464es *chip) | |||
654 | int i; | 654 | int i; |
655 | u32 orig_conf_es = lx_dsp_reg_read(chip, eReg_CONFES); | 655 | u32 orig_conf_es = lx_dsp_reg_read(chip, eReg_CONFES); |
656 | 656 | ||
657 | u32 default_conf_es = (64 << IOCR_OUTPUTS_OFFSET) | | 657 | /* configure 64 io channels */ |
658 | u32 conf_es = (orig_conf_es & CONFES_READ_PART_MASK) | | ||
658 | (64 << IOCR_INPUTS_OFFSET) | | 659 | (64 << IOCR_INPUTS_OFFSET) | |
660 | (64 << IOCR_OUTPUTS_OFFSET) | | ||
659 | (FREQ_RATIO_SINGLE_MODE << FREQ_RATIO_OFFSET); | 661 | (FREQ_RATIO_SINGLE_MODE << FREQ_RATIO_OFFSET); |
660 | 662 | ||
661 | u32 conf_es = (orig_conf_es & CONFES_READ_PART_MASK) | ||
662 | | (default_conf_es & CONFES_WRITE_PART_MASK); | ||
663 | |||
664 | snd_printdd("->lx_init_ethersound\n"); | 663 | snd_printdd("->lx_init_ethersound\n"); |
665 | 664 | ||
666 | chip->freq_ratio = FREQ_RATIO_SINGLE_MODE; | 665 | chip->freq_ratio = FREQ_RATIO_SINGLE_MODE; |
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 82bc5b9e7629..a83d1968a845 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c | |||
@@ -61,7 +61,7 @@ MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard."); | |||
61 | */ | 61 | */ |
62 | 62 | ||
63 | static struct pci_device_id snd_mixart_ids[] = { | 63 | static struct pci_device_id snd_mixart_ids[] = { |
64 | { 0x1057, 0x0003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* MC8240 */ | 64 | { PCI_VDEVICE(MOTOROLA, 0x0003), 0, }, /* MC8240 */ |
65 | { 0, } | 65 | { 0, } |
66 | }; | 66 | }; |
67 | 67 | ||
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 522a040855d4..97a0731331a1 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c | |||
@@ -263,9 +263,9 @@ struct nm256 { | |||
263 | * PCI ids | 263 | * PCI ids |
264 | */ | 264 | */ |
265 | static struct pci_device_id snd_nm256_ids[] = { | 265 | static struct pci_device_id snd_nm256_ids[] = { |
266 | {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 266 | {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO), 0}, |
267 | {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 267 | {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO), 0}, |
268 | {PCI_VENDOR_ID_NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 268 | {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO), 0}, |
269 | {0,}, | 269 | {0,}, |
270 | }; | 270 | }; |
271 | 271 | ||
diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c index c1eb923f2ac9..09b2b2a36df5 100644 --- a/sound/pci/oxygen/oxygen_io.c +++ b/sound/pci/oxygen/oxygen_io.c | |||
@@ -215,17 +215,8 @@ EXPORT_SYMBOL(oxygen_write_spi); | |||
215 | 215 | ||
216 | void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data) | 216 | void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data) |
217 | { | 217 | { |
218 | unsigned long timeout; | ||
219 | |||
220 | /* should not need more than about 300 us */ | 218 | /* should not need more than about 300 us */ |
221 | timeout = jiffies + msecs_to_jiffies(1); | 219 | msleep(1); |
222 | do { | ||
223 | if (!(oxygen_read16(chip, OXYGEN_2WIRE_BUS_STATUS) | ||
224 | & OXYGEN_2WIRE_BUSY)) | ||
225 | break; | ||
226 | udelay(1); | ||
227 | cond_resched(); | ||
228 | } while (time_after_eq(timeout, jiffies)); | ||
229 | 220 | ||
230 | oxygen_write8(chip, OXYGEN_2WIRE_MAP, map); | 221 | oxygen_write8(chip, OXYGEN_2WIRE_MAP, map); |
231 | oxygen_write8(chip, OXYGEN_2WIRE_DATA, data); | 222 | oxygen_write8(chip, OXYGEN_2WIRE_DATA, data); |
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index 312251d39696..9a8936e20744 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c | |||
@@ -260,6 +260,9 @@ oxygen_search_pci_id(struct oxygen *chip, const struct pci_device_id ids[]) | |||
260 | * chip didn't if the first EEPROM word was overwritten. | 260 | * chip didn't if the first EEPROM word was overwritten. |
261 | */ | 261 | */ |
262 | subdevice = oxygen_read_eeprom(chip, 2); | 262 | subdevice = oxygen_read_eeprom(chip, 2); |
263 | /* use default ID if EEPROM is missing */ | ||
264 | if (subdevice == 0xffff) | ||
265 | subdevice = 0x8788; | ||
263 | /* | 266 | /* |
264 | * We use only the subsystem device ID for searching because it is | 267 | * We use only the subsystem device ID for searching because it is |
265 | * unique even without the subsystem vendor ID, which may have been | 268 | * unique even without the subsystem vendor ID, which may have been |
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c index 304da169bfdc..5401c547c4e3 100644 --- a/sound/pci/oxygen/oxygen_mixer.c +++ b/sound/pci/oxygen/oxygen_mixer.c | |||
@@ -575,8 +575,10 @@ static int ac97_switch_put(struct snd_kcontrol *ctl, | |||
575 | static int ac97_volume_info(struct snd_kcontrol *ctl, | 575 | static int ac97_volume_info(struct snd_kcontrol *ctl, |
576 | struct snd_ctl_elem_info *info) | 576 | struct snd_ctl_elem_info *info) |
577 | { | 577 | { |
578 | int stereo = (ctl->private_value >> 16) & 1; | ||
579 | |||
578 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 580 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
579 | info->count = 2; | 581 | info->count = stereo ? 2 : 1; |
580 | info->value.integer.min = 0; | 582 | info->value.integer.min = 0; |
581 | info->value.integer.max = 0x1f; | 583 | info->value.integer.max = 0x1f; |
582 | return 0; | 584 | return 0; |
@@ -587,6 +589,7 @@ static int ac97_volume_get(struct snd_kcontrol *ctl, | |||
587 | { | 589 | { |
588 | struct oxygen *chip = ctl->private_data; | 590 | struct oxygen *chip = ctl->private_data; |
589 | unsigned int codec = (ctl->private_value >> 24) & 1; | 591 | unsigned int codec = (ctl->private_value >> 24) & 1; |
592 | int stereo = (ctl->private_value >> 16) & 1; | ||
590 | unsigned int index = ctl->private_value & 0xff; | 593 | unsigned int index = ctl->private_value & 0xff; |
591 | u16 reg; | 594 | u16 reg; |
592 | 595 | ||
@@ -594,7 +597,8 @@ static int ac97_volume_get(struct snd_kcontrol *ctl, | |||
594 | reg = oxygen_read_ac97(chip, codec, index); | 597 | reg = oxygen_read_ac97(chip, codec, index); |
595 | mutex_unlock(&chip->mutex); | 598 | mutex_unlock(&chip->mutex); |
596 | value->value.integer.value[0] = 31 - (reg & 0x1f); | 599 | value->value.integer.value[0] = 31 - (reg & 0x1f); |
597 | value->value.integer.value[1] = 31 - ((reg >> 8) & 0x1f); | 600 | if (stereo) |
601 | value->value.integer.value[1] = 31 - ((reg >> 8) & 0x1f); | ||
598 | return 0; | 602 | return 0; |
599 | } | 603 | } |
600 | 604 | ||
@@ -603,6 +607,7 @@ static int ac97_volume_put(struct snd_kcontrol *ctl, | |||
603 | { | 607 | { |
604 | struct oxygen *chip = ctl->private_data; | 608 | struct oxygen *chip = ctl->private_data; |
605 | unsigned int codec = (ctl->private_value >> 24) & 1; | 609 | unsigned int codec = (ctl->private_value >> 24) & 1; |
610 | int stereo = (ctl->private_value >> 16) & 1; | ||
606 | unsigned int index = ctl->private_value & 0xff; | 611 | unsigned int index = ctl->private_value & 0xff; |
607 | u16 oldreg, newreg; | 612 | u16 oldreg, newreg; |
608 | int change; | 613 | int change; |
@@ -612,8 +617,11 @@ static int ac97_volume_put(struct snd_kcontrol *ctl, | |||
612 | newreg = oldreg; | 617 | newreg = oldreg; |
613 | newreg = (newreg & ~0x1f) | | 618 | newreg = (newreg & ~0x1f) | |
614 | (31 - (value->value.integer.value[0] & 0x1f)); | 619 | (31 - (value->value.integer.value[0] & 0x1f)); |
615 | newreg = (newreg & ~0x1f00) | | 620 | if (stereo) |
616 | ((31 - (value->value.integer.value[0] & 0x1f)) << 8); | 621 | newreg = (newreg & ~0x1f00) | |
622 | ((31 - (value->value.integer.value[1] & 0x1f)) << 8); | ||
623 | else | ||
624 | newreg = (newreg & ~0x1f00) | ((newreg & 0x1f) << 8); | ||
617 | change = newreg != oldreg; | 625 | change = newreg != oldreg; |
618 | if (change) | 626 | if (change) |
619 | oxygen_write_ac97(chip, codec, index, newreg); | 627 | oxygen_write_ac97(chip, codec, index, newreg); |
@@ -673,7 +681,7 @@ static int ac97_fp_rec_volume_put(struct snd_kcontrol *ctl, | |||
673 | .private_value = ((codec) << 24) | ((invert) << 16) | \ | 681 | .private_value = ((codec) << 24) | ((invert) << 16) | \ |
674 | ((bitnr) << 8) | (index), \ | 682 | ((bitnr) << 8) | (index), \ |
675 | } | 683 | } |
676 | #define AC97_VOLUME(xname, codec, index) { \ | 684 | #define AC97_VOLUME(xname, codec, index, stereo) { \ |
677 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 685 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
678 | .name = xname, \ | 686 | .name = xname, \ |
679 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | 687 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
@@ -682,7 +690,7 @@ static int ac97_fp_rec_volume_put(struct snd_kcontrol *ctl, | |||
682 | .get = ac97_volume_get, \ | 690 | .get = ac97_volume_get, \ |
683 | .put = ac97_volume_put, \ | 691 | .put = ac97_volume_put, \ |
684 | .tlv = { .p = ac97_db_scale, }, \ | 692 | .tlv = { .p = ac97_db_scale, }, \ |
685 | .private_value = ((codec) << 24) | (index), \ | 693 | .private_value = ((codec) << 24) | ((stereo) << 16) | (index), \ |
686 | } | 694 | } |
687 | 695 | ||
688 | static DECLARE_TLV_DB_SCALE(monitor_db_scale, -1000, 1000, 0); | 696 | static DECLARE_TLV_DB_SCALE(monitor_db_scale, -1000, 1000, 0); |
@@ -882,18 +890,18 @@ static const struct { | |||
882 | }; | 890 | }; |
883 | 891 | ||
884 | static const struct snd_kcontrol_new ac97_controls[] = { | 892 | static const struct snd_kcontrol_new ac97_controls[] = { |
885 | AC97_VOLUME("Mic Capture Volume", 0, AC97_MIC), | 893 | AC97_VOLUME("Mic Capture Volume", 0, AC97_MIC, 0), |
886 | AC97_SWITCH("Mic Capture Switch", 0, AC97_MIC, 15, 1), | 894 | AC97_SWITCH("Mic Capture Switch", 0, AC97_MIC, 15, 1), |
887 | AC97_SWITCH("Mic Boost (+20dB)", 0, AC97_MIC, 6, 0), | 895 | AC97_SWITCH("Mic Boost (+20dB)", 0, AC97_MIC, 6, 0), |
888 | AC97_SWITCH("Line Capture Switch", 0, AC97_LINE, 15, 1), | 896 | AC97_SWITCH("Line Capture Switch", 0, AC97_LINE, 15, 1), |
889 | AC97_VOLUME("CD Capture Volume", 0, AC97_CD), | 897 | AC97_VOLUME("CD Capture Volume", 0, AC97_CD, 1), |
890 | AC97_SWITCH("CD Capture Switch", 0, AC97_CD, 15, 1), | 898 | AC97_SWITCH("CD Capture Switch", 0, AC97_CD, 15, 1), |
891 | AC97_VOLUME("Aux Capture Volume", 0, AC97_AUX), | 899 | AC97_VOLUME("Aux Capture Volume", 0, AC97_AUX, 1), |
892 | AC97_SWITCH("Aux Capture Switch", 0, AC97_AUX, 15, 1), | 900 | AC97_SWITCH("Aux Capture Switch", 0, AC97_AUX, 15, 1), |
893 | }; | 901 | }; |
894 | 902 | ||
895 | static const struct snd_kcontrol_new ac97_fp_controls[] = { | 903 | static const struct snd_kcontrol_new ac97_fp_controls[] = { |
896 | AC97_VOLUME("Front Panel Playback Volume", 1, AC97_HEADPHONE), | 904 | AC97_VOLUME("Front Panel Playback Volume", 1, AC97_HEADPHONE, 1), |
897 | AC97_SWITCH("Front Panel Playback Switch", 1, AC97_HEADPHONE, 15, 1), | 905 | AC97_SWITCH("Front Panel Playback Switch", 1, AC97_HEADPHONE, 15, 1), |
898 | { | 906 | { |
899 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 907 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index 3b5ca70c9d4d..ef2345d82b86 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c | |||
@@ -469,9 +469,11 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream, | |||
469 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, | 469 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, |
470 | oxygen_rate(hw_params) | | 470 | oxygen_rate(hw_params) | |
471 | chip->model.dac_i2s_format | | 471 | chip->model.dac_i2s_format | |
472 | oxygen_i2s_mclk(hw_params) | | ||
472 | oxygen_i2s_bits(hw_params), | 473 | oxygen_i2s_bits(hw_params), |
473 | OXYGEN_I2S_RATE_MASK | | 474 | OXYGEN_I2S_RATE_MASK | |
474 | OXYGEN_I2S_FORMAT_MASK | | 475 | OXYGEN_I2S_FORMAT_MASK | |
476 | OXYGEN_I2S_MCLK_MASK | | ||
475 | OXYGEN_I2S_BITS_MASK); | 477 | OXYGEN_I2S_BITS_MASK); |
476 | oxygen_update_dac_routing(chip); | 478 | oxygen_update_dac_routing(chip); |
477 | oxygen_update_spdif_source(chip); | 479 | oxygen_update_spdif_source(chip); |
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index bf971f7cfdc6..6ebcb6bdd712 100644 --- a/sound/pci/oxygen/virtuoso.c +++ b/sound/pci/oxygen/virtuoso.c | |||
@@ -635,6 +635,8 @@ static void xonar_d2_resume(struct oxygen *chip) | |||
635 | 635 | ||
636 | static void xonar_d1_resume(struct oxygen *chip) | 636 | static void xonar_d1_resume(struct oxygen *chip) |
637 | { | 637 | { |
638 | oxygen_set_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC); | ||
639 | msleep(1); | ||
638 | cs43xx_init(chip); | 640 | cs43xx_init(chip); |
639 | xonar_enable_output(chip); | 641 | xonar_enable_output(chip); |
640 | } | 642 | } |
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 235a71e5ac8d..b5ca02e2038c 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c | |||
@@ -2197,9 +2197,12 @@ static int __init alsa_card_riptide_init(void) | |||
2197 | if (err < 0) | 2197 | if (err < 0) |
2198 | return err; | 2198 | return err; |
2199 | #if defined(SUPPORT_JOYSTICK) | 2199 | #if defined(SUPPORT_JOYSTICK) |
2200 | pci_register_driver(&joystick_driver); | 2200 | err = pci_register_driver(&joystick_driver); |
2201 | /* On failure unregister formerly registered audio driver */ | ||
2202 | if (err < 0) | ||
2203 | pci_unregister_driver(&driver); | ||
2201 | #endif | 2204 | #endif |
2202 | return 0; | 2205 | return err; |
2203 | } | 2206 | } |
2204 | 2207 | ||
2205 | static void __exit alsa_card_riptide_exit(void) | 2208 | static void __exit alsa_card_riptide_exit(void) |
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index d7b966e7c4cf..f977dba7cbd0 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c | |||
@@ -227,12 +227,9 @@ struct rme32 { | |||
227 | }; | 227 | }; |
228 | 228 | ||
229 | static struct pci_device_id snd_rme32_ids[] = { | 229 | static struct pci_device_id snd_rme32_ids[] = { |
230 | {PCI_VENDOR_ID_XILINX_RME, PCI_DEVICE_ID_RME_DIGI32, | 230 | {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32), 0,}, |
231 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,}, | 231 | {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_8), 0,}, |
232 | {PCI_VENDOR_ID_XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_8, | 232 | {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_PRO), 0,}, |
233 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,}, | ||
234 | {PCI_VENDOR_ID_XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_PRO, | ||
235 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,}, | ||
236 | {0,} | 233 | {0,} |
237 | }; | 234 | }; |
238 | 235 | ||
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 55fb1c131f58..2ba5c0fd55db 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c | |||
@@ -232,14 +232,10 @@ struct rme96 { | |||
232 | }; | 232 | }; |
233 | 233 | ||
234 | static struct pci_device_id snd_rme96_ids[] = { | 234 | static struct pci_device_id snd_rme96_ids[] = { |
235 | { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96, | 235 | { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96), 0, }, |
236 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, | 236 | { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8), 0, }, |
237 | { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96_8, | 237 | { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PRO), 0, }, |
238 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, | 238 | { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST), 0, }, |
239 | { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PRO, | ||
240 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, | ||
241 | { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST, | ||
242 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, | ||
243 | { 0, } | 239 | { 0, } |
244 | }; | 240 | }; |
245 | 241 | ||
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 3da5c029f93b..7bb827c7d806 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c | |||
@@ -3294,15 +3294,33 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) | |||
3294 | char *clock_source; | 3294 | char *clock_source; |
3295 | int x; | 3295 | int x; |
3296 | 3296 | ||
3297 | if (hdsp_check_for_iobox (hdsp)) { | 3297 | status = hdsp_read(hdsp, HDSP_statusRegister); |
3298 | snd_iprintf(buffer, "No I/O box connected.\nPlease connect one and upload firmware.\n"); | 3298 | status2 = hdsp_read(hdsp, HDSP_status2Register); |
3299 | |||
3300 | snd_iprintf(buffer, "%s (Card #%d)\n", hdsp->card_name, | ||
3301 | hdsp->card->number + 1); | ||
3302 | snd_iprintf(buffer, "Buffers: capture %p playback %p\n", | ||
3303 | hdsp->capture_buffer, hdsp->playback_buffer); | ||
3304 | snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n", | ||
3305 | hdsp->irq, hdsp->port, (unsigned long)hdsp->iobase); | ||
3306 | snd_iprintf(buffer, "Control register: 0x%x\n", hdsp->control_register); | ||
3307 | snd_iprintf(buffer, "Control2 register: 0x%x\n", | ||
3308 | hdsp->control2_register); | ||
3309 | snd_iprintf(buffer, "Status register: 0x%x\n", status); | ||
3310 | snd_iprintf(buffer, "Status2 register: 0x%x\n", status2); | ||
3311 | |||
3312 | if (hdsp_check_for_iobox(hdsp)) { | ||
3313 | snd_iprintf(buffer, "No I/O box connected.\n" | ||
3314 | "Please connect one and upload firmware.\n"); | ||
3299 | return; | 3315 | return; |
3300 | } | 3316 | } |
3301 | 3317 | ||
3302 | if (hdsp_check_for_firmware(hdsp, 0)) { | 3318 | if (hdsp_check_for_firmware(hdsp, 0)) { |
3303 | if (hdsp->state & HDSP_FirmwareCached) { | 3319 | if (hdsp->state & HDSP_FirmwareCached) { |
3304 | if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { | 3320 | if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { |
3305 | snd_iprintf(buffer, "Firmware loading from cache failed, please upload manually.\n"); | 3321 | snd_iprintf(buffer, "Firmware loading from " |
3322 | "cache failed, " | ||
3323 | "please upload manually.\n"); | ||
3306 | return; | 3324 | return; |
3307 | } | 3325 | } |
3308 | } else { | 3326 | } else { |
@@ -3319,18 +3337,6 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) | |||
3319 | } | 3337 | } |
3320 | } | 3338 | } |
3321 | 3339 | ||
3322 | status = hdsp_read(hdsp, HDSP_statusRegister); | ||
3323 | status2 = hdsp_read(hdsp, HDSP_status2Register); | ||
3324 | |||
3325 | snd_iprintf(buffer, "%s (Card #%d)\n", hdsp->card_name, hdsp->card->number + 1); | ||
3326 | snd_iprintf(buffer, "Buffers: capture %p playback %p\n", | ||
3327 | hdsp->capture_buffer, hdsp->playback_buffer); | ||
3328 | snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n", | ||
3329 | hdsp->irq, hdsp->port, (unsigned long)hdsp->iobase); | ||
3330 | snd_iprintf(buffer, "Control register: 0x%x\n", hdsp->control_register); | ||
3331 | snd_iprintf(buffer, "Control2 register: 0x%x\n", hdsp->control2_register); | ||
3332 | snd_iprintf(buffer, "Status register: 0x%x\n", status); | ||
3333 | snd_iprintf(buffer, "Status2 register: 0x%x\n", status2); | ||
3334 | snd_iprintf(buffer, "FIFO status: %d\n", hdsp_read(hdsp, HDSP_fifoStatus) & 0xff); | 3340 | snd_iprintf(buffer, "FIFO status: %d\n", hdsp_read(hdsp, HDSP_fifoStatus) & 0xff); |
3335 | snd_iprintf(buffer, "MIDI1 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut0)); | 3341 | snd_iprintf(buffer, "MIDI1 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut0)); |
3336 | snd_iprintf(buffer, "MIDI1 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn0)); | 3342 | snd_iprintf(buffer, "MIDI1 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn0)); |
@@ -3351,7 +3357,6 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) | |||
3351 | 3357 | ||
3352 | snd_iprintf(buffer, "\n"); | 3358 | snd_iprintf(buffer, "\n"); |
3353 | 3359 | ||
3354 | |||
3355 | switch (hdsp_clock_source(hdsp)) { | 3360 | switch (hdsp_clock_source(hdsp)) { |
3356 | case HDSP_CLOCK_SOURCE_AUTOSYNC: | 3361 | case HDSP_CLOCK_SOURCE_AUTOSYNC: |
3357 | clock_source = "AutoSync"; | 3362 | clock_source = "AutoSync"; |
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 7dc60ad4772e..1f6406c4534d 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c | |||
@@ -243,7 +243,7 @@ struct sonicvibes { | |||
243 | }; | 243 | }; |
244 | 244 | ||
245 | static struct pci_device_id snd_sonic_ids[] = { | 245 | static struct pci_device_id snd_sonic_ids[] = { |
246 | { 0x5333, 0xca00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, | 246 | { PCI_VDEVICE(S3, 0xca00), 0, }, |
247 | { 0, } | 247 | { 0, } |
248 | }; | 248 | }; |
249 | 249 | ||
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 949fcaf6b70e..acfa4760da49 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c | |||
@@ -402,9 +402,9 @@ struct via82xx { | |||
402 | 402 | ||
403 | static struct pci_device_id snd_via82xx_ids[] = { | 403 | static struct pci_device_id snd_via82xx_ids[] = { |
404 | /* 0x1106, 0x3058 */ | 404 | /* 0x1106, 0x3058 */ |
405 | { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA686, }, /* 686A */ | 405 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C686_5), TYPE_CARD_VIA686, }, /* 686A */ |
406 | /* 0x1106, 0x3059 */ | 406 | /* 0x1106, 0x3059 */ |
407 | { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233_5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA8233, }, /* VT8233 */ | 407 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8233_5), TYPE_CARD_VIA8233, }, /* VT8233 */ |
408 | { 0, } | 408 | { 0, } |
409 | }; | 409 | }; |
410 | 410 | ||
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 0d54e3503c1e..47eb61561dfc 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c | |||
@@ -261,7 +261,7 @@ struct via82xx_modem { | |||
261 | }; | 261 | }; |
262 | 262 | ||
263 | static struct pci_device_id snd_via82xx_modem_ids[] = { | 263 | static struct pci_device_id snd_via82xx_modem_ids[] = { |
264 | { 0x1106, 0x3068, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TYPE_CARD_VIA82XX_MODEM, }, | 264 | { PCI_VDEVICE(VIA, 0x3068), TYPE_CARD_VIA82XX_MODEM, }, |
265 | { 0, } | 265 | { 0, } |
266 | }; | 266 | }; |
267 | 267 | ||
diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c index 6416d3f0c7be..a69e774d0b13 100644 --- a/sound/pci/vx222/vx222_ops.c +++ b/sound/pci/vx222/vx222_ops.c | |||
@@ -885,10 +885,10 @@ static int vx_input_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem | |||
885 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); | 885 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); |
886 | struct snd_vx222 *chip = (struct snd_vx222 *)_chip; | 886 | struct snd_vx222 *chip = (struct snd_vx222 *)_chip; |
887 | if (ucontrol->value.integer.value[0] < 0 || | 887 | if (ucontrol->value.integer.value[0] < 0 || |
888 | ucontrol->value.integer.value[0] < MIC_LEVEL_MAX) | 888 | ucontrol->value.integer.value[0] > MIC_LEVEL_MAX) |
889 | return -EINVAL; | 889 | return -EINVAL; |
890 | if (ucontrol->value.integer.value[1] < 0 || | 890 | if (ucontrol->value.integer.value[1] < 0 || |
891 | ucontrol->value.integer.value[1] < MIC_LEVEL_MAX) | 891 | ucontrol->value.integer.value[1] > MIC_LEVEL_MAX) |
892 | return -EINVAL; | 892 | return -EINVAL; |
893 | mutex_lock(&_chip->mixer_mutex); | 893 | mutex_lock(&_chip->mixer_mutex); |
894 | if (chip->input_level[0] != ucontrol->value.integer.value[0] || | 894 | if (chip->input_level[0] != ucontrol->value.integer.value[0] || |
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 4af66661f9b0..e6b18b90d451 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c | |||
@@ -67,12 +67,12 @@ module_param_array(rear_switch, bool, NULL, 0444); | |||
67 | MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch"); | 67 | MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch"); |
68 | 68 | ||
69 | static struct pci_device_id snd_ymfpci_ids[] = { | 69 | static struct pci_device_id snd_ymfpci_ids[] = { |
70 | { 0x1073, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF724 */ | 70 | { PCI_VDEVICE(YAMAHA, 0x0004), 0, }, /* YMF724 */ |
71 | { 0x1073, 0x000d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF724F */ | 71 | { PCI_VDEVICE(YAMAHA, 0x000d), 0, }, /* YMF724F */ |
72 | { 0x1073, 0x000a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF740 */ | 72 | { PCI_VDEVICE(YAMAHA, 0x000a), 0, }, /* YMF740 */ |
73 | { 0x1073, 0x000c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF740C */ | 73 | { PCI_VDEVICE(YAMAHA, 0x000c), 0, }, /* YMF740C */ |
74 | { 0x1073, 0x0010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF744 */ | 74 | { PCI_VDEVICE(YAMAHA, 0x0010), 0, }, /* YMF744 */ |
75 | { 0x1073, 0x0012, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* YMF754 */ | 75 | { PCI_VDEVICE(YAMAHA, 0x0012), 0, }, /* YMF754 */ |
76 | { 0, } | 76 | { 0, } |
77 | }; | 77 | }; |
78 | 78 | ||
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 2f0925236a1b..5518371db13f 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c | |||
@@ -834,7 +834,7 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id) | |||
834 | status = snd_ymfpci_readw(chip, YDSXGR_INTFLAG); | 834 | status = snd_ymfpci_readw(chip, YDSXGR_INTFLAG); |
835 | if (status & 1) { | 835 | if (status & 1) { |
836 | if (chip->timer) | 836 | if (chip->timer) |
837 | snd_timer_interrupt(chip->timer, chip->timer->sticks); | 837 | snd_timer_interrupt(chip->timer, chip->timer_ticks); |
838 | } | 838 | } |
839 | snd_ymfpci_writew(chip, YDSXGR_INTFLAG, status); | 839 | snd_ymfpci_writew(chip, YDSXGR_INTFLAG, status); |
840 | 840 | ||
@@ -1885,8 +1885,18 @@ static int snd_ymfpci_timer_start(struct snd_timer *timer) | |||
1885 | unsigned int count; | 1885 | unsigned int count; |
1886 | 1886 | ||
1887 | chip = snd_timer_chip(timer); | 1887 | chip = snd_timer_chip(timer); |
1888 | count = (timer->sticks << 1) - 1; | ||
1889 | spin_lock_irqsave(&chip->reg_lock, flags); | 1888 | spin_lock_irqsave(&chip->reg_lock, flags); |
1889 | if (timer->sticks > 1) { | ||
1890 | chip->timer_ticks = timer->sticks; | ||
1891 | count = timer->sticks - 1; | ||
1892 | } else { | ||
1893 | /* | ||
1894 | * Divisor 1 is not allowed; fake it by using divisor 2 and | ||
1895 | * counting two ticks for each interrupt. | ||
1896 | */ | ||
1897 | chip->timer_ticks = 2; | ||
1898 | count = 2 - 1; | ||
1899 | } | ||
1890 | snd_ymfpci_writew(chip, YDSXGR_TIMERCOUNT, count); | 1900 | snd_ymfpci_writew(chip, YDSXGR_TIMERCOUNT, count); |
1891 | snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x03); | 1901 | snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x03); |
1892 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1902 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
@@ -1909,14 +1919,14 @@ static int snd_ymfpci_timer_precise_resolution(struct snd_timer *timer, | |||
1909 | unsigned long *num, unsigned long *den) | 1919 | unsigned long *num, unsigned long *den) |
1910 | { | 1920 | { |
1911 | *num = 1; | 1921 | *num = 1; |
1912 | *den = 48000; | 1922 | *den = 96000; |
1913 | return 0; | 1923 | return 0; |
1914 | } | 1924 | } |
1915 | 1925 | ||
1916 | static struct snd_timer_hardware snd_ymfpci_timer_hw = { | 1926 | static struct snd_timer_hardware snd_ymfpci_timer_hw = { |
1917 | .flags = SNDRV_TIMER_HW_AUTO, | 1927 | .flags = SNDRV_TIMER_HW_AUTO, |
1918 | .resolution = 20833, /* 1/fs = 20.8333...us */ | 1928 | .resolution = 10417, /* 1 / 96 kHz = 10.41666...us */ |
1919 | .ticks = 0x8000, | 1929 | .ticks = 0x10000, |
1920 | .start = snd_ymfpci_timer_start, | 1930 | .start = snd_ymfpci_timer_start, |
1921 | .stop = snd_ymfpci_timer_stop, | 1931 | .stop = snd_ymfpci_timer_stop, |
1922 | .precise_resolution = snd_ymfpci_timer_precise_resolution, | 1932 | .precise_resolution = snd_ymfpci_timer_precise_resolution, |
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c index 1c8653523c8c..3f530f8a972a 100644 --- a/sound/soc/codecs/wm8988.c +++ b/sound/soc/codecs/wm8988.c | |||
@@ -992,14 +992,14 @@ static int __devinit wm8988_spi_probe(struct spi_device *spi) | |||
992 | codec->control_data = spi; | 992 | codec->control_data = spi; |
993 | codec->dev = &spi->dev; | 993 | codec->dev = &spi->dev; |
994 | 994 | ||
995 | spi->dev.driver_data = wm8988; | 995 | dev_set_drvdata(&spi->dev, wm8988); |
996 | 996 | ||
997 | return wm8988_register(wm8988, SND_SOC_SPI); | 997 | return wm8988_register(wm8988, SND_SOC_SPI); |
998 | } | 998 | } |
999 | 999 | ||
1000 | static int __devexit wm8988_spi_remove(struct spi_device *spi) | 1000 | static int __devexit wm8988_spi_remove(struct spi_device *spi) |
1001 | { | 1001 | { |
1002 | struct wm8988_priv *wm8988 = spi->dev.driver_data; | 1002 | struct wm8988_priv *wm8988 = dev_get_drvdata(&spi->dev); |
1003 | 1003 | ||
1004 | wm8988_unregister(wm8988); | 1004 | wm8988_unregister(wm8988); |
1005 | 1005 | ||
diff --git a/sound/soc/fsl/efika-audio-fabric.c b/sound/soc/fsl/efika-audio-fabric.c index 85b0e7569504..3326e2a1e863 100644 --- a/sound/soc/fsl/efika-audio-fabric.c +++ b/sound/soc/fsl/efika-audio-fabric.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include "mpc5200_psc_ac97.h" | 30 | #include "mpc5200_psc_ac97.h" |
31 | #include "../codecs/stac9766.h" | 31 | #include "../codecs/stac9766.h" |
32 | 32 | ||
33 | #define DRV_NAME "efika-audio-fabric" | ||
34 | |||
33 | static struct snd_soc_device device; | 35 | static struct snd_soc_device device; |
34 | static struct snd_soc_card card; | 36 | static struct snd_soc_card card; |
35 | 37 | ||
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c index 8766f7a3893d..b928ef7d28eb 100644 --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include "mpc5200_psc_ac97.h" | 30 | #include "mpc5200_psc_ac97.h" |
31 | #include "../codecs/wm9712.h" | 31 | #include "../codecs/wm9712.h" |
32 | 32 | ||
33 | #define DRV_NAME "pcm030-audio-fabric" | ||
34 | |||
33 | static struct snd_soc_device device; | 35 | static struct snd_soc_device device; |
34 | static struct snd_soc_card card; | 36 | static struct snd_soc_card card; |
35 | 37 | ||
diff --git a/sound/sound_core.c b/sound/sound_core.c index 12522e6913d9..bb4b88e606bb 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c | |||
@@ -10,6 +10,8 @@ | |||
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/device.h> | 11 | #include <linux/device.h> |
12 | #include <linux/err.h> | 12 | #include <linux/err.h> |
13 | #include <linux/kdev_t.h> | ||
14 | #include <linux/major.h> | ||
13 | #include <sound/core.h> | 15 | #include <sound/core.h> |
14 | 16 | ||
15 | #ifdef CONFIG_SOUND_OSS_CORE | 17 | #ifdef CONFIG_SOUND_OSS_CORE |
@@ -29,6 +31,8 @@ MODULE_LICENSE("GPL"); | |||
29 | 31 | ||
30 | static char *sound_nodename(struct device *dev) | 32 | static char *sound_nodename(struct device *dev) |
31 | { | 33 | { |
34 | if (MAJOR(dev->devt) == SOUND_MAJOR) | ||
35 | return NULL; | ||
32 | return kasprintf(GFP_KERNEL, "snd/%s", dev_name(dev)); | 36 | return kasprintf(GFP_KERNEL, "snd/%s", dev_name(dev)); |
33 | } | 37 | } |
34 | 38 | ||
@@ -104,7 +108,6 @@ module_exit(cleanup_soundcore); | |||
104 | #include <linux/types.h> | 108 | #include <linux/types.h> |
105 | #include <linux/kernel.h> | 109 | #include <linux/kernel.h> |
106 | #include <linux/sound.h> | 110 | #include <linux/sound.h> |
107 | #include <linux/major.h> | ||
108 | #include <linux/kmod.h> | 111 | #include <linux/kmod.h> |
109 | 112 | ||
110 | #define SOUND_STEP 16 | 113 | #define SOUND_STEP 16 |
@@ -125,6 +128,46 @@ extern int msnd_pinnacle_init(void); | |||
125 | #endif | 128 | #endif |
126 | 129 | ||
127 | /* | 130 | /* |
131 | * By default, OSS sound_core claims full legacy minor range (0-255) | ||
132 | * of SOUND_MAJOR to trap open attempts to any sound minor and | ||
133 | * requests modules using custom sound-slot/service-* module aliases. | ||
134 | * The only benefit of doing this is allowing use of custom module | ||
135 | * aliases instead of the standard char-major-* ones. This behavior | ||
136 | * prevents alternative OSS implementation and is scheduled to be | ||
137 | * removed. | ||
138 | * | ||
139 | * CONFIG_SOUND_OSS_CORE_PRECLAIM and soundcore.preclaim_oss kernel | ||
140 | * parameter are added to allow distros and developers to try and | ||
141 | * switch to alternative implementations without needing to rebuild | ||
142 | * the kernel in the meantime. If preclaim_oss is non-zero, the | ||
143 | * kernel will behave the same as before. All SOUND_MAJOR minors are | ||
144 | * preclaimed and the custom module aliases along with standard chrdev | ||
145 | * ones are emitted if a missing device is opened. If preclaim_oss is | ||
146 | * zero, sound_core only grabs what's actually in use and for missing | ||
147 | * devices only the standard chrdev aliases are requested. | ||
148 | * | ||
149 | * All these clutters are scheduled to be removed along with | ||
150 | * sound-slot/service-* module aliases. Please take a look at | ||
151 | * feature-removal-schedule.txt for details. | ||
152 | */ | ||
153 | #ifdef CONFIG_SOUND_OSS_CORE_PRECLAIM | ||
154 | static int preclaim_oss = 1; | ||
155 | #else | ||
156 | static int preclaim_oss = 0; | ||
157 | #endif | ||
158 | |||
159 | module_param(preclaim_oss, int, 0444); | ||
160 | |||
161 | static int soundcore_open(struct inode *, struct file *); | ||
162 | |||
163 | static const struct file_operations soundcore_fops = | ||
164 | { | ||
165 | /* We must have an owner or the module locking fails */ | ||
166 | .owner = THIS_MODULE, | ||
167 | .open = soundcore_open, | ||
168 | }; | ||
169 | |||
170 | /* | ||
128 | * Low level list operator. Scan the ordered list, find a hole and | 171 | * Low level list operator. Scan the ordered list, find a hole and |
129 | * join into it. Called with the lock asserted | 172 | * join into it. Called with the lock asserted |
130 | */ | 173 | */ |
@@ -216,8 +259,9 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati | |||
216 | 259 | ||
217 | if (!s) | 260 | if (!s) |
218 | return -ENOMEM; | 261 | return -ENOMEM; |
219 | 262 | ||
220 | spin_lock(&sound_loader_lock); | 263 | spin_lock(&sound_loader_lock); |
264 | retry: | ||
221 | r = __sound_insert_unit(s, list, fops, index, low, top); | 265 | r = __sound_insert_unit(s, list, fops, index, low, top); |
222 | spin_unlock(&sound_loader_lock); | 266 | spin_unlock(&sound_loader_lock); |
223 | 267 | ||
@@ -228,11 +272,31 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati | |||
228 | else | 272 | else |
229 | sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP); | 273 | sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP); |
230 | 274 | ||
275 | if (!preclaim_oss) { | ||
276 | /* | ||
277 | * Something else might have grabbed the minor. If | ||
278 | * first free slot is requested, rescan with @low set | ||
279 | * to the next unit; otherwise, -EBUSY. | ||
280 | */ | ||
281 | r = __register_chrdev(SOUND_MAJOR, s->unit_minor, 1, s->name, | ||
282 | &soundcore_fops); | ||
283 | if (r < 0) { | ||
284 | spin_lock(&sound_loader_lock); | ||
285 | __sound_remove_unit(list, s->unit_minor); | ||
286 | if (index < 0) { | ||
287 | low = s->unit_minor + SOUND_STEP; | ||
288 | goto retry; | ||
289 | } | ||
290 | spin_unlock(&sound_loader_lock); | ||
291 | return -EBUSY; | ||
292 | } | ||
293 | } | ||
294 | |||
231 | device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor), | 295 | device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor), |
232 | NULL, s->name+6); | 296 | NULL, s->name+6); |
233 | return r; | 297 | return s->unit_minor; |
234 | 298 | ||
235 | fail: | 299 | fail: |
236 | kfree(s); | 300 | kfree(s); |
237 | return r; | 301 | return r; |
238 | } | 302 | } |
@@ -251,6 +315,9 @@ static void sound_remove_unit(struct sound_unit **list, int unit) | |||
251 | p = __sound_remove_unit(list, unit); | 315 | p = __sound_remove_unit(list, unit); |
252 | spin_unlock(&sound_loader_lock); | 316 | spin_unlock(&sound_loader_lock); |
253 | if (p) { | 317 | if (p) { |
318 | if (!preclaim_oss) | ||
319 | __unregister_chrdev(SOUND_MAJOR, p->unit_minor, 1, | ||
320 | p->name); | ||
254 | device_destroy(sound_class, MKDEV(SOUND_MAJOR, p->unit_minor)); | 321 | device_destroy(sound_class, MKDEV(SOUND_MAJOR, p->unit_minor)); |
255 | kfree(p); | 322 | kfree(p); |
256 | } | 323 | } |
@@ -488,19 +555,6 @@ void unregister_sound_dsp(int unit) | |||
488 | 555 | ||
489 | EXPORT_SYMBOL(unregister_sound_dsp); | 556 | EXPORT_SYMBOL(unregister_sound_dsp); |
490 | 557 | ||
491 | /* | ||
492 | * Now our file operations | ||
493 | */ | ||
494 | |||
495 | static int soundcore_open(struct inode *, struct file *); | ||
496 | |||
497 | static const struct file_operations soundcore_fops= | ||
498 | { | ||
499 | /* We must have an owner or the module locking fails */ | ||
500 | .owner = THIS_MODULE, | ||
501 | .open = soundcore_open, | ||
502 | }; | ||
503 | |||
504 | static struct sound_unit *__look_for_unit(int chain, int unit) | 558 | static struct sound_unit *__look_for_unit(int chain, int unit) |
505 | { | 559 | { |
506 | struct sound_unit *s; | 560 | struct sound_unit *s; |
@@ -536,8 +590,9 @@ static int soundcore_open(struct inode *inode, struct file *file) | |||
536 | s = __look_for_unit(chain, unit); | 590 | s = __look_for_unit(chain, unit); |
537 | if (s) | 591 | if (s) |
538 | new_fops = fops_get(s->unit_fops); | 592 | new_fops = fops_get(s->unit_fops); |
539 | if (!new_fops) { | 593 | if (preclaim_oss && !new_fops) { |
540 | spin_unlock(&sound_loader_lock); | 594 | spin_unlock(&sound_loader_lock); |
595 | |||
541 | /* | 596 | /* |
542 | * Please, don't change this order or code. | 597 | * Please, don't change this order or code. |
543 | * For ALSA slot means soundcard and OSS emulation code | 598 | * For ALSA slot means soundcard and OSS emulation code |
@@ -547,6 +602,17 @@ static int soundcore_open(struct inode *inode, struct file *file) | |||
547 | */ | 602 | */ |
548 | request_module("sound-slot-%i", unit>>4); | 603 | request_module("sound-slot-%i", unit>>4); |
549 | request_module("sound-service-%i-%i", unit>>4, chain); | 604 | request_module("sound-service-%i-%i", unit>>4, chain); |
605 | |||
606 | /* | ||
607 | * sound-slot/service-* module aliases are scheduled | ||
608 | * for removal in favor of the standard char-major-* | ||
609 | * module aliases. For the time being, generate both | ||
610 | * the legacy and standard module aliases to ease | ||
611 | * transition. | ||
612 | */ | ||
613 | if (request_module("char-major-%d-%d", SOUND_MAJOR, unit) > 0) | ||
614 | request_module("char-major-%d", SOUND_MAJOR); | ||
615 | |||
550 | spin_lock(&sound_loader_lock); | 616 | spin_lock(&sound_loader_lock); |
551 | s = __look_for_unit(chain, unit); | 617 | s = __look_for_unit(chain, unit); |
552 | if (s) | 618 | if (s) |
@@ -590,7 +656,8 @@ static void cleanup_oss_soundcore(void) | |||
590 | 656 | ||
591 | static int __init init_oss_soundcore(void) | 657 | static int __init init_oss_soundcore(void) |
592 | { | 658 | { |
593 | if (register_chrdev(SOUND_MAJOR, "sound", &soundcore_fops)==-1) { | 659 | if (preclaim_oss && |
660 | register_chrdev(SOUND_MAJOR, "sound", &soundcore_fops) == -1) { | ||
594 | printk(KERN_ERR "soundcore: sound device already in use.\n"); | 661 | printk(KERN_ERR "soundcore: sound device already in use.\n"); |
595 | return -EBUSY; | 662 | return -EBUSY; |
596 | } | 663 | } |
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig index 523aec188ccf..73525c048e7f 100644 --- a/sound/usb/Kconfig +++ b/sound/usb/Kconfig | |||
@@ -48,6 +48,7 @@ config SND_USB_CAIAQ | |||
48 | * Native Instruments Kore Controller | 48 | * Native Instruments Kore Controller |
49 | * Native Instruments Kore Controller 2 | 49 | * Native Instruments Kore Controller 2 |
50 | * Native Instruments Audio Kontrol 1 | 50 | * Native Instruments Audio Kontrol 1 |
51 | * Native Instruments Audio 2 DJ | ||
51 | * Native Instruments Audio 4 DJ | 52 | * Native Instruments Audio 4 DJ |
52 | * Native Instruments Audio 8 DJ | 53 | * Native Instruments Audio 8 DJ |
53 | * Native Instruments Guitar Rig Session I/O | 54 | * Native Instruments Guitar Rig Session I/O |
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 8f9b60c5d74c..121af0644fd9 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c | |||
@@ -646,6 +646,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | |||
646 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): | 646 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): |
647 | dev->samplerates |= SNDRV_PCM_RATE_192000; | 647 | dev->samplerates |= SNDRV_PCM_RATE_192000; |
648 | /* fall thru */ | 648 | /* fall thru */ |
649 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO2DJ): | ||
649 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): | 650 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): |
650 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 651 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
651 | dev->samplerates |= SNDRV_PCM_RATE_88200; | 652 | dev->samplerates |= SNDRV_PCM_RATE_88200; |
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index 0e5db719de24..83e6c1312d47 100644 --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c | |||
@@ -35,13 +35,14 @@ | |||
35 | #include "input.h" | 35 | #include "input.h" |
36 | 36 | ||
37 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); | 37 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); |
38 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.17"); | 38 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.19"); |
39 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
40 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," | 40 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," |
41 | "{Native Instruments, RigKontrol3}," | 41 | "{Native Instruments, RigKontrol3}," |
42 | "{Native Instruments, Kore Controller}," | 42 | "{Native Instruments, Kore Controller}," |
43 | "{Native Instruments, Kore Controller 2}," | 43 | "{Native Instruments, Kore Controller 2}," |
44 | "{Native Instruments, Audio Kontrol 1}," | 44 | "{Native Instruments, Audio Kontrol 1}," |
45 | "{Native Instruments, Audio 2 DJ}," | ||
45 | "{Native Instruments, Audio 4 DJ}," | 46 | "{Native Instruments, Audio 4 DJ}," |
46 | "{Native Instruments, Audio 8 DJ}," | 47 | "{Native Instruments, Audio 8 DJ}," |
47 | "{Native Instruments, Session I/O}," | 48 | "{Native Instruments, Session I/O}," |
@@ -121,6 +122,11 @@ static struct usb_device_id snd_usb_id_table[] = { | |||
121 | .idVendor = USB_VID_NATIVEINSTRUMENTS, | 122 | .idVendor = USB_VID_NATIVEINSTRUMENTS, |
122 | .idProduct = USB_PID_AUDIO4DJ | 123 | .idProduct = USB_PID_AUDIO4DJ |
123 | }, | 124 | }, |
125 | { | ||
126 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, | ||
127 | .idVendor = USB_VID_NATIVEINSTRUMENTS, | ||
128 | .idProduct = USB_PID_AUDIO2DJ | ||
129 | }, | ||
124 | { /* terminator */ } | 130 | { /* terminator */ } |
125 | }; | 131 | }; |
126 | 132 | ||
@@ -349,7 +355,9 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev) | |||
349 | log("Unable to set up control system (ret=%d)\n", ret); | 355 | log("Unable to set up control system (ret=%d)\n", ret); |
350 | } | 356 | } |
351 | 357 | ||
352 | static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) | 358 | static int create_card(struct usb_device *usb_dev, |
359 | struct usb_interface *intf, | ||
360 | struct snd_card **cardp) | ||
353 | { | 361 | { |
354 | int devnum; | 362 | int devnum; |
355 | int err; | 363 | int err; |
@@ -374,7 +382,7 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) | |||
374 | dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), | 382 | dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), |
375 | le16_to_cpu(usb_dev->descriptor.idProduct)); | 383 | le16_to_cpu(usb_dev->descriptor.idProduct)); |
376 | spin_lock_init(&dev->spinlock); | 384 | spin_lock_init(&dev->spinlock); |
377 | snd_card_set_dev(card, &usb_dev->dev); | 385 | snd_card_set_dev(card, &intf->dev); |
378 | 386 | ||
379 | *cardp = card; | 387 | *cardp = card; |
380 | return 0; | 388 | return 0; |
@@ -461,7 +469,7 @@ static int __devinit snd_probe(struct usb_interface *intf, | |||
461 | struct snd_card *card; | 469 | struct snd_card *card; |
462 | struct usb_device *device = interface_to_usbdev(intf); | 470 | struct usb_device *device = interface_to_usbdev(intf); |
463 | 471 | ||
464 | ret = create_card(device, &card); | 472 | ret = create_card(device, intf, &card); |
465 | 473 | ||
466 | if (ret < 0) | 474 | if (ret < 0) |
467 | return ret; | 475 | return ret; |
diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h index ece73514854e..44e3edf88bef 100644 --- a/sound/usb/caiaq/device.h +++ b/sound/usb/caiaq/device.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #define USB_PID_KORECONTROLLER 0x4711 | 10 | #define USB_PID_KORECONTROLLER 0x4711 |
11 | #define USB_PID_KORECONTROLLER2 0x4712 | 11 | #define USB_PID_KORECONTROLLER2 0x4712 |
12 | #define USB_PID_AK1 0x0815 | 12 | #define USB_PID_AK1 0x0815 |
13 | #define USB_PID_AUDIO2DJ 0x041c | ||
13 | #define USB_PID_AUDIO4DJ 0x0839 | 14 | #define USB_PID_AUDIO4DJ 0x0839 |
14 | #define USB_PID_AUDIO8DJ 0x1978 | 15 | #define USB_PID_AUDIO8DJ 0x1978 |
15 | #define USB_PID_SESSIONIO 0x1915 | 16 | #define USB_PID_SESSIONIO 0x1915 |
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index c7b902358b7b..8db0374e10d5 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -1083,6 +1083,8 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri | |||
1083 | } else | 1083 | } else |
1084 | urb_packs = 1; | 1084 | urb_packs = 1; |
1085 | urb_packs *= packs_per_ms; | 1085 | urb_packs *= packs_per_ms; |
1086 | if (subs->syncpipe) | ||
1087 | urb_packs = min(urb_packs, 1U << subs->syncinterval); | ||
1086 | 1088 | ||
1087 | /* decide how many packets to be used */ | 1089 | /* decide how many packets to be used */ |
1088 | if (is_playback) { | 1090 | if (is_playback) { |
@@ -2124,8 +2126,8 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s | |||
2124 | fp = list_entry(p, struct audioformat, list); | 2126 | fp = list_entry(p, struct audioformat, list); |
2125 | snd_iprintf(buffer, " Interface %d\n", fp->iface); | 2127 | snd_iprintf(buffer, " Interface %d\n", fp->iface); |
2126 | snd_iprintf(buffer, " Altset %d\n", fp->altsetting); | 2128 | snd_iprintf(buffer, " Altset %d\n", fp->altsetting); |
2127 | snd_iprintf(buffer, " Format: %#x (%d bits)\n", | 2129 | snd_iprintf(buffer, " Format: %s\n", |
2128 | fp->format, snd_pcm_format_width(fp->format)); | 2130 | snd_pcm_format_name(fp->format)); |
2129 | snd_iprintf(buffer, " Channels: %d\n", fp->channels); | 2131 | snd_iprintf(buffer, " Channels: %d\n", fp->channels); |
2130 | snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", | 2132 | snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", |
2131 | fp->endpoint & USB_ENDPOINT_NUMBER_MASK, | 2133 | fp->endpoint & USB_ENDPOINT_NUMBER_MASK, |
@@ -2661,7 +2663,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2661 | struct usb_interface_descriptor *altsd; | 2663 | struct usb_interface_descriptor *altsd; |
2662 | int i, altno, err, stream; | 2664 | int i, altno, err, stream; |
2663 | int format; | 2665 | int format; |
2664 | struct audioformat *fp; | 2666 | struct audioformat *fp = NULL; |
2665 | unsigned char *fmt, *csep; | 2667 | unsigned char *fmt, *csep; |
2666 | int num; | 2668 | int num; |
2667 | 2669 | ||
@@ -2734,6 +2736,18 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2734 | continue; | 2736 | continue; |
2735 | } | 2737 | } |
2736 | 2738 | ||
2739 | /* | ||
2740 | * Blue Microphones workaround: The last altsetting is identical | ||
2741 | * with the previous one, except for a larger packet size, but | ||
2742 | * is actually a mislabeled two-channel setting; ignore it. | ||
2743 | */ | ||
2744 | if (fmt[4] == 1 && fmt[5] == 2 && altno == 2 && num == 3 && | ||
2745 | fp && fp->altsetting == 1 && fp->channels == 1 && | ||
2746 | fp->format == SNDRV_PCM_FORMAT_S16_LE && | ||
2747 | le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == | ||
2748 | fp->maxpacksize * 2) | ||
2749 | continue; | ||
2750 | |||
2737 | csep = snd_usb_find_desc(alts->endpoint[0].extra, alts->endpoint[0].extralen, NULL, USB_DT_CS_ENDPOINT); | 2751 | csep = snd_usb_find_desc(alts->endpoint[0].extra, alts->endpoint[0].extralen, NULL, USB_DT_CS_ENDPOINT); |
2738 | /* Creamware Noah has this descriptor after the 2nd endpoint */ | 2752 | /* Creamware Noah has this descriptor after the 2nd endpoint */ |
2739 | if (!csep && altsd->bNumEndpoints >= 2) | 2753 | if (!csep && altsd->bNumEndpoints >= 2) |
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index 2fb35cc22a30..0eff19ceb7e1 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/slab.h> | 45 | #include <linux/slab.h> |
46 | #include <linux/timer.h> | 46 | #include <linux/timer.h> |
47 | #include <linux/usb.h> | 47 | #include <linux/usb.h> |
48 | #include <linux/wait.h> | ||
48 | #include <sound/core.h> | 49 | #include <sound/core.h> |
49 | #include <sound/rawmidi.h> | 50 | #include <sound/rawmidi.h> |
50 | #include <sound/asequencer.h> | 51 | #include <sound/asequencer.h> |
@@ -62,6 +63,9 @@ | |||
62 | */ | 63 | */ |
63 | #define ERROR_DELAY_JIFFIES (HZ / 10) | 64 | #define ERROR_DELAY_JIFFIES (HZ / 10) |
64 | 65 | ||
66 | #define OUTPUT_URBS 7 | ||
67 | #define INPUT_URBS 7 | ||
68 | |||
65 | 69 | ||
66 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); | 70 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); |
67 | MODULE_DESCRIPTION("USB Audio/MIDI helper module"); | 71 | MODULE_DESCRIPTION("USB Audio/MIDI helper module"); |
@@ -90,7 +94,7 @@ struct snd_usb_midi_endpoint; | |||
90 | 94 | ||
91 | struct usb_protocol_ops { | 95 | struct usb_protocol_ops { |
92 | void (*input)(struct snd_usb_midi_in_endpoint*, uint8_t*, int); | 96 | void (*input)(struct snd_usb_midi_in_endpoint*, uint8_t*, int); |
93 | void (*output)(struct snd_usb_midi_out_endpoint*); | 97 | void (*output)(struct snd_usb_midi_out_endpoint *ep, struct urb *urb); |
94 | void (*output_packet)(struct urb*, uint8_t, uint8_t, uint8_t, uint8_t); | 98 | void (*output_packet)(struct urb*, uint8_t, uint8_t, uint8_t, uint8_t); |
95 | void (*init_out_endpoint)(struct snd_usb_midi_out_endpoint*); | 99 | void (*init_out_endpoint)(struct snd_usb_midi_out_endpoint*); |
96 | void (*finish_out_endpoint)(struct snd_usb_midi_out_endpoint*); | 100 | void (*finish_out_endpoint)(struct snd_usb_midi_out_endpoint*); |
@@ -116,11 +120,15 @@ struct snd_usb_midi { | |||
116 | 120 | ||
117 | struct snd_usb_midi_out_endpoint { | 121 | struct snd_usb_midi_out_endpoint { |
118 | struct snd_usb_midi* umidi; | 122 | struct snd_usb_midi* umidi; |
119 | struct urb* urb; | 123 | struct out_urb_context { |
120 | int urb_active; | 124 | struct urb *urb; |
125 | struct snd_usb_midi_out_endpoint *ep; | ||
126 | } urbs[OUTPUT_URBS]; | ||
127 | unsigned int active_urbs; | ||
128 | unsigned int drain_urbs; | ||
121 | int max_transfer; /* size of urb buffer */ | 129 | int max_transfer; /* size of urb buffer */ |
122 | struct tasklet_struct tasklet; | 130 | struct tasklet_struct tasklet; |
123 | 131 | unsigned int next_urb; | |
124 | spinlock_t buffer_lock; | 132 | spinlock_t buffer_lock; |
125 | 133 | ||
126 | struct usbmidi_out_port { | 134 | struct usbmidi_out_port { |
@@ -139,11 +147,13 @@ struct snd_usb_midi_out_endpoint { | |||
139 | uint8_t data[2]; | 147 | uint8_t data[2]; |
140 | } ports[0x10]; | 148 | } ports[0x10]; |
141 | int current_port; | 149 | int current_port; |
150 | |||
151 | wait_queue_head_t drain_wait; | ||
142 | }; | 152 | }; |
143 | 153 | ||
144 | struct snd_usb_midi_in_endpoint { | 154 | struct snd_usb_midi_in_endpoint { |
145 | struct snd_usb_midi* umidi; | 155 | struct snd_usb_midi* umidi; |
146 | struct urb* urb; | 156 | struct urb* urbs[INPUT_URBS]; |
147 | struct usbmidi_in_port { | 157 | struct usbmidi_in_port { |
148 | struct snd_rawmidi_substream *substream; | 158 | struct snd_rawmidi_substream *substream; |
149 | u8 running_status_length; | 159 | u8 running_status_length; |
@@ -251,10 +261,17 @@ static void snd_usbmidi_in_urb_complete(struct urb* urb) | |||
251 | 261 | ||
252 | static void snd_usbmidi_out_urb_complete(struct urb* urb) | 262 | static void snd_usbmidi_out_urb_complete(struct urb* urb) |
253 | { | 263 | { |
254 | struct snd_usb_midi_out_endpoint* ep = urb->context; | 264 | struct out_urb_context *context = urb->context; |
265 | struct snd_usb_midi_out_endpoint* ep = context->ep; | ||
266 | unsigned int urb_index; | ||
255 | 267 | ||
256 | spin_lock(&ep->buffer_lock); | 268 | spin_lock(&ep->buffer_lock); |
257 | ep->urb_active = 0; | 269 | urb_index = context - ep->urbs; |
270 | ep->active_urbs &= ~(1 << urb_index); | ||
271 | if (unlikely(ep->drain_urbs)) { | ||
272 | ep->drain_urbs &= ~(1 << urb_index); | ||
273 | wake_up(&ep->drain_wait); | ||
274 | } | ||
258 | spin_unlock(&ep->buffer_lock); | 275 | spin_unlock(&ep->buffer_lock); |
259 | if (urb->status < 0) { | 276 | if (urb->status < 0) { |
260 | int err = snd_usbmidi_urb_error(urb->status); | 277 | int err = snd_usbmidi_urb_error(urb->status); |
@@ -274,24 +291,38 @@ static void snd_usbmidi_out_urb_complete(struct urb* urb) | |||
274 | */ | 291 | */ |
275 | static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep) | 292 | static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep) |
276 | { | 293 | { |
277 | struct urb* urb = ep->urb; | 294 | unsigned int urb_index; |
295 | struct urb* urb; | ||
278 | unsigned long flags; | 296 | unsigned long flags; |
279 | 297 | ||
280 | spin_lock_irqsave(&ep->buffer_lock, flags); | 298 | spin_lock_irqsave(&ep->buffer_lock, flags); |
281 | if (ep->urb_active || ep->umidi->chip->shutdown) { | 299 | if (ep->umidi->chip->shutdown) { |
282 | spin_unlock_irqrestore(&ep->buffer_lock, flags); | 300 | spin_unlock_irqrestore(&ep->buffer_lock, flags); |
283 | return; | 301 | return; |
284 | } | 302 | } |
285 | 303 | ||
286 | urb->transfer_buffer_length = 0; | 304 | urb_index = ep->next_urb; |
287 | ep->umidi->usb_protocol_ops->output(ep); | 305 | for (;;) { |
306 | if (!(ep->active_urbs & (1 << urb_index))) { | ||
307 | urb = ep->urbs[urb_index].urb; | ||
308 | urb->transfer_buffer_length = 0; | ||
309 | ep->umidi->usb_protocol_ops->output(ep, urb); | ||
310 | if (urb->transfer_buffer_length == 0) | ||
311 | break; | ||
288 | 312 | ||
289 | if (urb->transfer_buffer_length > 0) { | 313 | dump_urb("sending", urb->transfer_buffer, |
290 | dump_urb("sending", urb->transfer_buffer, | 314 | urb->transfer_buffer_length); |
291 | urb->transfer_buffer_length); | 315 | urb->dev = ep->umidi->chip->dev; |
292 | urb->dev = ep->umidi->chip->dev; | 316 | if (snd_usbmidi_submit_urb(urb, GFP_ATOMIC) < 0) |
293 | ep->urb_active = snd_usbmidi_submit_urb(urb, GFP_ATOMIC) >= 0; | 317 | break; |
318 | ep->active_urbs |= 1 << urb_index; | ||
319 | } | ||
320 | if (++urb_index >= OUTPUT_URBS) | ||
321 | urb_index = 0; | ||
322 | if (urb_index == ep->next_urb) | ||
323 | break; | ||
294 | } | 324 | } |
325 | ep->next_urb = urb_index; | ||
295 | spin_unlock_irqrestore(&ep->buffer_lock, flags); | 326 | spin_unlock_irqrestore(&ep->buffer_lock, flags); |
296 | } | 327 | } |
297 | 328 | ||
@@ -306,7 +337,7 @@ static void snd_usbmidi_out_tasklet(unsigned long data) | |||
306 | static void snd_usbmidi_error_timer(unsigned long data) | 337 | static void snd_usbmidi_error_timer(unsigned long data) |
307 | { | 338 | { |
308 | struct snd_usb_midi *umidi = (struct snd_usb_midi *)data; | 339 | struct snd_usb_midi *umidi = (struct snd_usb_midi *)data; |
309 | int i; | 340 | unsigned int i, j; |
310 | 341 | ||
311 | spin_lock(&umidi->disc_lock); | 342 | spin_lock(&umidi->disc_lock); |
312 | if (umidi->disconnected) { | 343 | if (umidi->disconnected) { |
@@ -317,8 +348,10 @@ static void snd_usbmidi_error_timer(unsigned long data) | |||
317 | struct snd_usb_midi_in_endpoint *in = umidi->endpoints[i].in; | 348 | struct snd_usb_midi_in_endpoint *in = umidi->endpoints[i].in; |
318 | if (in && in->error_resubmit) { | 349 | if (in && in->error_resubmit) { |
319 | in->error_resubmit = 0; | 350 | in->error_resubmit = 0; |
320 | in->urb->dev = umidi->chip->dev; | 351 | for (j = 0; j < INPUT_URBS; ++j) { |
321 | snd_usbmidi_submit_urb(in->urb, GFP_ATOMIC); | 352 | in->urbs[j]->dev = umidi->chip->dev; |
353 | snd_usbmidi_submit_urb(in->urbs[j], GFP_ATOMIC); | ||
354 | } | ||
322 | } | 355 | } |
323 | if (umidi->endpoints[i].out) | 356 | if (umidi->endpoints[i].out) |
324 | snd_usbmidi_do_output(umidi->endpoints[i].out); | 357 | snd_usbmidi_do_output(umidi->endpoints[i].out); |
@@ -330,13 +363,14 @@ static void snd_usbmidi_error_timer(unsigned long data) | |||
330 | static int send_bulk_static_data(struct snd_usb_midi_out_endpoint* ep, | 363 | static int send_bulk_static_data(struct snd_usb_midi_out_endpoint* ep, |
331 | const void *data, int len) | 364 | const void *data, int len) |
332 | { | 365 | { |
333 | int err; | 366 | int err = 0; |
334 | void *buf = kmemdup(data, len, GFP_KERNEL); | 367 | void *buf = kmemdup(data, len, GFP_KERNEL); |
335 | if (!buf) | 368 | if (!buf) |
336 | return -ENOMEM; | 369 | return -ENOMEM; |
337 | dump_urb("sending", buf, len); | 370 | dump_urb("sending", buf, len); |
338 | err = usb_bulk_msg(ep->umidi->chip->dev, ep->urb->pipe, buf, len, | 371 | if (ep->urbs[0].urb) |
339 | NULL, 250); | 372 | err = usb_bulk_msg(ep->umidi->chip->dev, ep->urbs[0].urb->pipe, |
373 | buf, len, NULL, 250); | ||
340 | kfree(buf); | 374 | kfree(buf); |
341 | return err; | 375 | return err; |
342 | } | 376 | } |
@@ -554,9 +588,9 @@ static void snd_usbmidi_transmit_byte(struct usbmidi_out_port* port, | |||
554 | } | 588 | } |
555 | } | 589 | } |
556 | 590 | ||
557 | static void snd_usbmidi_standard_output(struct snd_usb_midi_out_endpoint* ep) | 591 | static void snd_usbmidi_standard_output(struct snd_usb_midi_out_endpoint* ep, |
592 | struct urb *urb) | ||
558 | { | 593 | { |
559 | struct urb* urb = ep->urb; | ||
560 | int p; | 594 | int p; |
561 | 595 | ||
562 | /* FIXME: lower-numbered ports can starve higher-numbered ports */ | 596 | /* FIXME: lower-numbered ports can starve higher-numbered ports */ |
@@ -613,14 +647,15 @@ static void snd_usbmidi_novation_input(struct snd_usb_midi_in_endpoint* ep, | |||
613 | snd_usbmidi_input_data(ep, 0, &buffer[2], buffer[0] - 1); | 647 | snd_usbmidi_input_data(ep, 0, &buffer[2], buffer[0] - 1); |
614 | } | 648 | } |
615 | 649 | ||
616 | static void snd_usbmidi_novation_output(struct snd_usb_midi_out_endpoint* ep) | 650 | static void snd_usbmidi_novation_output(struct snd_usb_midi_out_endpoint* ep, |
651 | struct urb *urb) | ||
617 | { | 652 | { |
618 | uint8_t* transfer_buffer; | 653 | uint8_t* transfer_buffer; |
619 | int count; | 654 | int count; |
620 | 655 | ||
621 | if (!ep->ports[0].active) | 656 | if (!ep->ports[0].active) |
622 | return; | 657 | return; |
623 | transfer_buffer = ep->urb->transfer_buffer; | 658 | transfer_buffer = urb->transfer_buffer; |
624 | count = snd_rawmidi_transmit(ep->ports[0].substream, | 659 | count = snd_rawmidi_transmit(ep->ports[0].substream, |
625 | &transfer_buffer[2], | 660 | &transfer_buffer[2], |
626 | ep->max_transfer - 2); | 661 | ep->max_transfer - 2); |
@@ -630,7 +665,7 @@ static void snd_usbmidi_novation_output(struct snd_usb_midi_out_endpoint* ep) | |||
630 | } | 665 | } |
631 | transfer_buffer[0] = 0; | 666 | transfer_buffer[0] = 0; |
632 | transfer_buffer[1] = count; | 667 | transfer_buffer[1] = count; |
633 | ep->urb->transfer_buffer_length = 2 + count; | 668 | urb->transfer_buffer_length = 2 + count; |
634 | } | 669 | } |
635 | 670 | ||
636 | static struct usb_protocol_ops snd_usbmidi_novation_ops = { | 671 | static struct usb_protocol_ops snd_usbmidi_novation_ops = { |
@@ -648,20 +683,21 @@ static void snd_usbmidi_raw_input(struct snd_usb_midi_in_endpoint* ep, | |||
648 | snd_usbmidi_input_data(ep, 0, buffer, buffer_length); | 683 | snd_usbmidi_input_data(ep, 0, buffer, buffer_length); |
649 | } | 684 | } |
650 | 685 | ||
651 | static void snd_usbmidi_raw_output(struct snd_usb_midi_out_endpoint* ep) | 686 | static void snd_usbmidi_raw_output(struct snd_usb_midi_out_endpoint* ep, |
687 | struct urb *urb) | ||
652 | { | 688 | { |
653 | int count; | 689 | int count; |
654 | 690 | ||
655 | if (!ep->ports[0].active) | 691 | if (!ep->ports[0].active) |
656 | return; | 692 | return; |
657 | count = snd_rawmidi_transmit(ep->ports[0].substream, | 693 | count = snd_rawmidi_transmit(ep->ports[0].substream, |
658 | ep->urb->transfer_buffer, | 694 | urb->transfer_buffer, |
659 | ep->max_transfer); | 695 | ep->max_transfer); |
660 | if (count < 1) { | 696 | if (count < 1) { |
661 | ep->ports[0].active = 0; | 697 | ep->ports[0].active = 0; |
662 | return; | 698 | return; |
663 | } | 699 | } |
664 | ep->urb->transfer_buffer_length = count; | 700 | urb->transfer_buffer_length = count; |
665 | } | 701 | } |
666 | 702 | ||
667 | static struct usb_protocol_ops snd_usbmidi_raw_ops = { | 703 | static struct usb_protocol_ops snd_usbmidi_raw_ops = { |
@@ -681,23 +717,25 @@ static void snd_usbmidi_us122l_input(struct snd_usb_midi_in_endpoint *ep, | |||
681 | snd_usbmidi_input_data(ep, 0, buffer, buffer_length); | 717 | snd_usbmidi_input_data(ep, 0, buffer, buffer_length); |
682 | } | 718 | } |
683 | 719 | ||
684 | static void snd_usbmidi_us122l_output(struct snd_usb_midi_out_endpoint *ep) | 720 | static void snd_usbmidi_us122l_output(struct snd_usb_midi_out_endpoint *ep, |
721 | struct urb *urb) | ||
685 | { | 722 | { |
686 | int count; | 723 | int count; |
687 | 724 | ||
688 | if (!ep->ports[0].active) | 725 | if (!ep->ports[0].active) |
689 | return; | 726 | return; |
690 | count = ep->urb->dev->speed == USB_SPEED_HIGH ? 1 : 2; | 727 | count = snd_usb_get_speed(ep->umidi->chip->dev) == USB_SPEED_HIGH |
728 | ? 1 : 2; | ||
691 | count = snd_rawmidi_transmit(ep->ports[0].substream, | 729 | count = snd_rawmidi_transmit(ep->ports[0].substream, |
692 | ep->urb->transfer_buffer, | 730 | urb->transfer_buffer, |
693 | count); | 731 | count); |
694 | if (count < 1) { | 732 | if (count < 1) { |
695 | ep->ports[0].active = 0; | 733 | ep->ports[0].active = 0; |
696 | return; | 734 | return; |
697 | } | 735 | } |
698 | 736 | ||
699 | memset(ep->urb->transfer_buffer + count, 0xFD, 9 - count); | 737 | memset(urb->transfer_buffer + count, 0xFD, 9 - count); |
700 | ep->urb->transfer_buffer_length = count; | 738 | urb->transfer_buffer_length = count; |
701 | } | 739 | } |
702 | 740 | ||
703 | static struct usb_protocol_ops snd_usbmidi_122l_ops = { | 741 | static struct usb_protocol_ops snd_usbmidi_122l_ops = { |
@@ -786,10 +824,11 @@ static void snd_usbmidi_emagic_input(struct snd_usb_midi_in_endpoint* ep, | |||
786 | } | 824 | } |
787 | } | 825 | } |
788 | 826 | ||
789 | static void snd_usbmidi_emagic_output(struct snd_usb_midi_out_endpoint* ep) | 827 | static void snd_usbmidi_emagic_output(struct snd_usb_midi_out_endpoint* ep, |
828 | struct urb *urb) | ||
790 | { | 829 | { |
791 | int port0 = ep->current_port; | 830 | int port0 = ep->current_port; |
792 | uint8_t* buf = ep->urb->transfer_buffer; | 831 | uint8_t* buf = urb->transfer_buffer; |
793 | int buf_free = ep->max_transfer; | 832 | int buf_free = ep->max_transfer; |
794 | int length, i; | 833 | int length, i; |
795 | 834 | ||
@@ -829,7 +868,7 @@ static void snd_usbmidi_emagic_output(struct snd_usb_midi_out_endpoint* ep) | |||
829 | *buf = 0xff; | 868 | *buf = 0xff; |
830 | --buf_free; | 869 | --buf_free; |
831 | } | 870 | } |
832 | ep->urb->transfer_buffer_length = ep->max_transfer - buf_free; | 871 | urb->transfer_buffer_length = ep->max_transfer - buf_free; |
833 | } | 872 | } |
834 | 873 | ||
835 | static struct usb_protocol_ops snd_usbmidi_emagic_ops = { | 874 | static struct usb_protocol_ops snd_usbmidi_emagic_ops = { |
@@ -884,6 +923,35 @@ static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream, | |||
884 | } | 923 | } |
885 | } | 924 | } |
886 | 925 | ||
926 | static void snd_usbmidi_output_drain(struct snd_rawmidi_substream *substream) | ||
927 | { | ||
928 | struct usbmidi_out_port* port = substream->runtime->private_data; | ||
929 | struct snd_usb_midi_out_endpoint *ep = port->ep; | ||
930 | unsigned int drain_urbs; | ||
931 | DEFINE_WAIT(wait); | ||
932 | long timeout = msecs_to_jiffies(50); | ||
933 | |||
934 | /* | ||
935 | * The substream buffer is empty, but some data might still be in the | ||
936 | * currently active URBs, so we have to wait for those to complete. | ||
937 | */ | ||
938 | spin_lock_irq(&ep->buffer_lock); | ||
939 | drain_urbs = ep->active_urbs; | ||
940 | if (drain_urbs) { | ||
941 | ep->drain_urbs |= drain_urbs; | ||
942 | do { | ||
943 | prepare_to_wait(&ep->drain_wait, &wait, | ||
944 | TASK_UNINTERRUPTIBLE); | ||
945 | spin_unlock_irq(&ep->buffer_lock); | ||
946 | timeout = schedule_timeout(timeout); | ||
947 | spin_lock_irq(&ep->buffer_lock); | ||
948 | drain_urbs &= ep->drain_urbs; | ||
949 | } while (drain_urbs && timeout); | ||
950 | finish_wait(&ep->drain_wait, &wait); | ||
951 | } | ||
952 | spin_unlock_irq(&ep->buffer_lock); | ||
953 | } | ||
954 | |||
887 | static int snd_usbmidi_input_open(struct snd_rawmidi_substream *substream) | 955 | static int snd_usbmidi_input_open(struct snd_rawmidi_substream *substream) |
888 | { | 956 | { |
889 | return 0; | 957 | return 0; |
@@ -908,6 +976,7 @@ static struct snd_rawmidi_ops snd_usbmidi_output_ops = { | |||
908 | .open = snd_usbmidi_output_open, | 976 | .open = snd_usbmidi_output_open, |
909 | .close = snd_usbmidi_output_close, | 977 | .close = snd_usbmidi_output_close, |
910 | .trigger = snd_usbmidi_output_trigger, | 978 | .trigger = snd_usbmidi_output_trigger, |
979 | .drain = snd_usbmidi_output_drain, | ||
911 | }; | 980 | }; |
912 | 981 | ||
913 | static struct snd_rawmidi_ops snd_usbmidi_input_ops = { | 982 | static struct snd_rawmidi_ops snd_usbmidi_input_ops = { |
@@ -916,19 +985,26 @@ static struct snd_rawmidi_ops snd_usbmidi_input_ops = { | |||
916 | .trigger = snd_usbmidi_input_trigger | 985 | .trigger = snd_usbmidi_input_trigger |
917 | }; | 986 | }; |
918 | 987 | ||
988 | static void free_urb_and_buffer(struct snd_usb_midi *umidi, struct urb *urb, | ||
989 | unsigned int buffer_length) | ||
990 | { | ||
991 | usb_buffer_free(umidi->chip->dev, buffer_length, | ||
992 | urb->transfer_buffer, urb->transfer_dma); | ||
993 | usb_free_urb(urb); | ||
994 | } | ||
995 | |||
919 | /* | 996 | /* |
920 | * Frees an input endpoint. | 997 | * Frees an input endpoint. |
921 | * May be called when ep hasn't been initialized completely. | 998 | * May be called when ep hasn't been initialized completely. |
922 | */ | 999 | */ |
923 | static void snd_usbmidi_in_endpoint_delete(struct snd_usb_midi_in_endpoint* ep) | 1000 | static void snd_usbmidi_in_endpoint_delete(struct snd_usb_midi_in_endpoint* ep) |
924 | { | 1001 | { |
925 | if (ep->urb) { | 1002 | unsigned int i; |
926 | usb_buffer_free(ep->umidi->chip->dev, | 1003 | |
927 | ep->urb->transfer_buffer_length, | 1004 | for (i = 0; i < INPUT_URBS; ++i) |
928 | ep->urb->transfer_buffer, | 1005 | if (ep->urbs[i]) |
929 | ep->urb->transfer_dma); | 1006 | free_urb_and_buffer(ep->umidi, ep->urbs[i], |
930 | usb_free_urb(ep->urb); | 1007 | ep->urbs[i]->transfer_buffer_length); |
931 | } | ||
932 | kfree(ep); | 1008 | kfree(ep); |
933 | } | 1009 | } |
934 | 1010 | ||
@@ -943,6 +1019,7 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi, | |||
943 | void* buffer; | 1019 | void* buffer; |
944 | unsigned int pipe; | 1020 | unsigned int pipe; |
945 | int length; | 1021 | int length; |
1022 | unsigned int i; | ||
946 | 1023 | ||
947 | rep->in = NULL; | 1024 | rep->in = NULL; |
948 | ep = kzalloc(sizeof(*ep), GFP_KERNEL); | 1025 | ep = kzalloc(sizeof(*ep), GFP_KERNEL); |
@@ -950,30 +1027,36 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi, | |||
950 | return -ENOMEM; | 1027 | return -ENOMEM; |
951 | ep->umidi = umidi; | 1028 | ep->umidi = umidi; |
952 | 1029 | ||
953 | ep->urb = usb_alloc_urb(0, GFP_KERNEL); | 1030 | for (i = 0; i < INPUT_URBS; ++i) { |
954 | if (!ep->urb) { | 1031 | ep->urbs[i] = usb_alloc_urb(0, GFP_KERNEL); |
955 | snd_usbmidi_in_endpoint_delete(ep); | 1032 | if (!ep->urbs[i]) { |
956 | return -ENOMEM; | 1033 | snd_usbmidi_in_endpoint_delete(ep); |
1034 | return -ENOMEM; | ||
1035 | } | ||
957 | } | 1036 | } |
958 | if (ep_info->in_interval) | 1037 | if (ep_info->in_interval) |
959 | pipe = usb_rcvintpipe(umidi->chip->dev, ep_info->in_ep); | 1038 | pipe = usb_rcvintpipe(umidi->chip->dev, ep_info->in_ep); |
960 | else | 1039 | else |
961 | pipe = usb_rcvbulkpipe(umidi->chip->dev, ep_info->in_ep); | 1040 | pipe = usb_rcvbulkpipe(umidi->chip->dev, ep_info->in_ep); |
962 | length = usb_maxpacket(umidi->chip->dev, pipe, 0); | 1041 | length = usb_maxpacket(umidi->chip->dev, pipe, 0); |
963 | buffer = usb_buffer_alloc(umidi->chip->dev, length, GFP_KERNEL, | 1042 | for (i = 0; i < INPUT_URBS; ++i) { |
964 | &ep->urb->transfer_dma); | 1043 | buffer = usb_buffer_alloc(umidi->chip->dev, length, GFP_KERNEL, |
965 | if (!buffer) { | 1044 | &ep->urbs[i]->transfer_dma); |
966 | snd_usbmidi_in_endpoint_delete(ep); | 1045 | if (!buffer) { |
967 | return -ENOMEM; | 1046 | snd_usbmidi_in_endpoint_delete(ep); |
1047 | return -ENOMEM; | ||
1048 | } | ||
1049 | if (ep_info->in_interval) | ||
1050 | usb_fill_int_urb(ep->urbs[i], umidi->chip->dev, | ||
1051 | pipe, buffer, length, | ||
1052 | snd_usbmidi_in_urb_complete, | ||
1053 | ep, ep_info->in_interval); | ||
1054 | else | ||
1055 | usb_fill_bulk_urb(ep->urbs[i], umidi->chip->dev, | ||
1056 | pipe, buffer, length, | ||
1057 | snd_usbmidi_in_urb_complete, ep); | ||
1058 | ep->urbs[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | ||
968 | } | 1059 | } |
969 | if (ep_info->in_interval) | ||
970 | usb_fill_int_urb(ep->urb, umidi->chip->dev, pipe, buffer, | ||
971 | length, snd_usbmidi_in_urb_complete, ep, | ||
972 | ep_info->in_interval); | ||
973 | else | ||
974 | usb_fill_bulk_urb(ep->urb, umidi->chip->dev, pipe, buffer, | ||
975 | length, snd_usbmidi_in_urb_complete, ep); | ||
976 | ep->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | ||
977 | 1060 | ||
978 | rep->in = ep; | 1061 | rep->in = ep; |
979 | return 0; | 1062 | return 0; |
@@ -994,12 +1077,12 @@ static unsigned int snd_usbmidi_count_bits(unsigned int x) | |||
994 | */ | 1077 | */ |
995 | static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint* ep) | 1078 | static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint* ep) |
996 | { | 1079 | { |
997 | if (ep->urb) { | 1080 | unsigned int i; |
998 | usb_buffer_free(ep->umidi->chip->dev, ep->max_transfer, | 1081 | |
999 | ep->urb->transfer_buffer, | 1082 | for (i = 0; i < OUTPUT_URBS; ++i) |
1000 | ep->urb->transfer_dma); | 1083 | if (ep->urbs[i].urb) |
1001 | usb_free_urb(ep->urb); | 1084 | free_urb_and_buffer(ep->umidi, ep->urbs[i].urb, |
1002 | } | 1085 | ep->max_transfer); |
1003 | kfree(ep); | 1086 | kfree(ep); |
1004 | } | 1087 | } |
1005 | 1088 | ||
@@ -1011,7 +1094,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi, | |||
1011 | struct snd_usb_midi_endpoint* rep) | 1094 | struct snd_usb_midi_endpoint* rep) |
1012 | { | 1095 | { |
1013 | struct snd_usb_midi_out_endpoint* ep; | 1096 | struct snd_usb_midi_out_endpoint* ep; |
1014 | int i; | 1097 | unsigned int i; |
1015 | unsigned int pipe; | 1098 | unsigned int pipe; |
1016 | void* buffer; | 1099 | void* buffer; |
1017 | 1100 | ||
@@ -1021,38 +1104,46 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi, | |||
1021 | return -ENOMEM; | 1104 | return -ENOMEM; |
1022 | ep->umidi = umidi; | 1105 | ep->umidi = umidi; |
1023 | 1106 | ||
1024 | ep->urb = usb_alloc_urb(0, GFP_KERNEL); | 1107 | for (i = 0; i < OUTPUT_URBS; ++i) { |
1025 | if (!ep->urb) { | 1108 | ep->urbs[i].urb = usb_alloc_urb(0, GFP_KERNEL); |
1026 | snd_usbmidi_out_endpoint_delete(ep); | 1109 | if (!ep->urbs[i].urb) { |
1027 | return -ENOMEM; | 1110 | snd_usbmidi_out_endpoint_delete(ep); |
1111 | return -ENOMEM; | ||
1112 | } | ||
1113 | ep->urbs[i].ep = ep; | ||
1028 | } | 1114 | } |
1029 | if (ep_info->out_interval) | 1115 | if (ep_info->out_interval) |
1030 | pipe = usb_sndintpipe(umidi->chip->dev, ep_info->out_ep); | 1116 | pipe = usb_sndintpipe(umidi->chip->dev, ep_info->out_ep); |
1031 | else | 1117 | else |
1032 | pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep); | 1118 | pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep); |
1033 | if (umidi->chip->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */ | 1119 | if (umidi->chip->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */ |
1034 | /* FIXME: we need more URBs to get reasonable bandwidth here: */ | ||
1035 | ep->max_transfer = 4; | 1120 | ep->max_transfer = 4; |
1036 | else | 1121 | else |
1037 | ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1); | 1122 | ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1); |
1038 | buffer = usb_buffer_alloc(umidi->chip->dev, ep->max_transfer, | 1123 | for (i = 0; i < OUTPUT_URBS; ++i) { |
1039 | GFP_KERNEL, &ep->urb->transfer_dma); | 1124 | buffer = usb_buffer_alloc(umidi->chip->dev, |
1040 | if (!buffer) { | 1125 | ep->max_transfer, GFP_KERNEL, |
1041 | snd_usbmidi_out_endpoint_delete(ep); | 1126 | &ep->urbs[i].urb->transfer_dma); |
1042 | return -ENOMEM; | 1127 | if (!buffer) { |
1128 | snd_usbmidi_out_endpoint_delete(ep); | ||
1129 | return -ENOMEM; | ||
1130 | } | ||
1131 | if (ep_info->out_interval) | ||
1132 | usb_fill_int_urb(ep->urbs[i].urb, umidi->chip->dev, | ||
1133 | pipe, buffer, ep->max_transfer, | ||
1134 | snd_usbmidi_out_urb_complete, | ||
1135 | &ep->urbs[i], ep_info->out_interval); | ||
1136 | else | ||
1137 | usb_fill_bulk_urb(ep->urbs[i].urb, umidi->chip->dev, | ||
1138 | pipe, buffer, ep->max_transfer, | ||
1139 | snd_usbmidi_out_urb_complete, | ||
1140 | &ep->urbs[i]); | ||
1141 | ep->urbs[i].urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | ||
1043 | } | 1142 | } |
1044 | if (ep_info->out_interval) | ||
1045 | usb_fill_int_urb(ep->urb, umidi->chip->dev, pipe, buffer, | ||
1046 | ep->max_transfer, snd_usbmidi_out_urb_complete, | ||
1047 | ep, ep_info->out_interval); | ||
1048 | else | ||
1049 | usb_fill_bulk_urb(ep->urb, umidi->chip->dev, | ||
1050 | pipe, buffer, ep->max_transfer, | ||
1051 | snd_usbmidi_out_urb_complete, ep); | ||
1052 | ep->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | ||
1053 | 1143 | ||
1054 | spin_lock_init(&ep->buffer_lock); | 1144 | spin_lock_init(&ep->buffer_lock); |
1055 | tasklet_init(&ep->tasklet, snd_usbmidi_out_tasklet, (unsigned long)ep); | 1145 | tasklet_init(&ep->tasklet, snd_usbmidi_out_tasklet, (unsigned long)ep); |
1146 | init_waitqueue_head(&ep->drain_wait); | ||
1056 | 1147 | ||
1057 | for (i = 0; i < 0x10; ++i) | 1148 | for (i = 0; i < 0x10; ++i) |
1058 | if (ep_info->out_cables & (1 << i)) { | 1149 | if (ep_info->out_cables & (1 << i)) { |
@@ -1090,7 +1181,7 @@ static void snd_usbmidi_free(struct snd_usb_midi* umidi) | |||
1090 | void snd_usbmidi_disconnect(struct list_head* p) | 1181 | void snd_usbmidi_disconnect(struct list_head* p) |
1091 | { | 1182 | { |
1092 | struct snd_usb_midi* umidi; | 1183 | struct snd_usb_midi* umidi; |
1093 | int i; | 1184 | unsigned int i, j; |
1094 | 1185 | ||
1095 | umidi = list_entry(p, struct snd_usb_midi, list); | 1186 | umidi = list_entry(p, struct snd_usb_midi, list); |
1096 | /* | 1187 | /* |
@@ -1105,13 +1196,15 @@ void snd_usbmidi_disconnect(struct list_head* p) | |||
1105 | struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i]; | 1196 | struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i]; |
1106 | if (ep->out) | 1197 | if (ep->out) |
1107 | tasklet_kill(&ep->out->tasklet); | 1198 | tasklet_kill(&ep->out->tasklet); |
1108 | if (ep->out && ep->out->urb) { | 1199 | if (ep->out) { |
1109 | usb_kill_urb(ep->out->urb); | 1200 | for (j = 0; j < OUTPUT_URBS; ++j) |
1201 | usb_kill_urb(ep->out->urbs[j].urb); | ||
1110 | if (umidi->usb_protocol_ops->finish_out_endpoint) | 1202 | if (umidi->usb_protocol_ops->finish_out_endpoint) |
1111 | umidi->usb_protocol_ops->finish_out_endpoint(ep->out); | 1203 | umidi->usb_protocol_ops->finish_out_endpoint(ep->out); |
1112 | } | 1204 | } |
1113 | if (ep->in) | 1205 | if (ep->in) |
1114 | usb_kill_urb(ep->in->urb); | 1206 | for (j = 0; j < INPUT_URBS; ++j) |
1207 | usb_kill_urb(ep->in->urbs[j]); | ||
1115 | /* free endpoints here; later call can result in Oops */ | 1208 | /* free endpoints here; later call can result in Oops */ |
1116 | if (ep->out) { | 1209 | if (ep->out) { |
1117 | snd_usbmidi_out_endpoint_delete(ep->out); | 1210 | snd_usbmidi_out_endpoint_delete(ep->out); |
@@ -1692,20 +1785,25 @@ static int snd_usbmidi_create_rawmidi(struct snd_usb_midi* umidi, | |||
1692 | void snd_usbmidi_input_stop(struct list_head* p) | 1785 | void snd_usbmidi_input_stop(struct list_head* p) |
1693 | { | 1786 | { |
1694 | struct snd_usb_midi* umidi; | 1787 | struct snd_usb_midi* umidi; |
1695 | int i; | 1788 | unsigned int i, j; |
1696 | 1789 | ||
1697 | umidi = list_entry(p, struct snd_usb_midi, list); | 1790 | umidi = list_entry(p, struct snd_usb_midi, list); |
1698 | for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { | 1791 | for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { |
1699 | struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i]; | 1792 | struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i]; |
1700 | if (ep->in) | 1793 | if (ep->in) |
1701 | usb_kill_urb(ep->in->urb); | 1794 | for (j = 0; j < INPUT_URBS; ++j) |
1795 | usb_kill_urb(ep->in->urbs[j]); | ||
1702 | } | 1796 | } |
1703 | } | 1797 | } |
1704 | 1798 | ||
1705 | static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep) | 1799 | static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep) |
1706 | { | 1800 | { |
1707 | if (ep) { | 1801 | unsigned int i; |
1708 | struct urb* urb = ep->urb; | 1802 | |
1803 | if (!ep) | ||
1804 | return; | ||
1805 | for (i = 0; i < INPUT_URBS; ++i) { | ||
1806 | struct urb* urb = ep->urbs[i]; | ||
1709 | urb->dev = ep->umidi->chip->dev; | 1807 | urb->dev = ep->umidi->chip->dev; |
1710 | snd_usbmidi_submit_urb(urb, GFP_KERNEL); | 1808 | snd_usbmidi_submit_urb(urb, GFP_KERNEL); |
1711 | } | 1809 | } |
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index 4bd3a7a0edc1..ab5a3ac2ac47 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c | |||
@@ -86,6 +86,7 @@ struct usb_mixer_interface { | |||
86 | u8 rc_buffer[6]; | 86 | u8 rc_buffer[6]; |
87 | 87 | ||
88 | u8 audigy2nx_leds[3]; | 88 | u8 audigy2nx_leds[3]; |
89 | u8 xonar_u1_status; | ||
89 | }; | 90 | }; |
90 | 91 | ||
91 | 92 | ||
@@ -461,7 +462,7 @@ static int mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |||
461 | unsigned int size, unsigned int __user *_tlv) | 462 | unsigned int size, unsigned int __user *_tlv) |
462 | { | 463 | { |
463 | struct usb_mixer_elem_info *cval = kcontrol->private_data; | 464 | struct usb_mixer_elem_info *cval = kcontrol->private_data; |
464 | DECLARE_TLV_DB_SCALE(scale, 0, 0, 0); | 465 | DECLARE_TLV_DB_MINMAX(scale, 0, 0); |
465 | 466 | ||
466 | if (size < sizeof(scale)) | 467 | if (size < sizeof(scale)) |
467 | return -ENOMEM; | 468 | return -ENOMEM; |
@@ -469,7 +470,16 @@ static int mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |||
469 | * while ALSA TLV contains in 1/100 dB unit | 470 | * while ALSA TLV contains in 1/100 dB unit |
470 | */ | 471 | */ |
471 | scale[2] = (convert_signed_value(cval, cval->min) * 100) / 256; | 472 | scale[2] = (convert_signed_value(cval, cval->min) * 100) / 256; |
472 | scale[3] = (convert_signed_value(cval, cval->res) * 100) / 256; | 473 | scale[3] = (convert_signed_value(cval, cval->max) * 100) / 256; |
474 | if (scale[3] <= scale[2]) { | ||
475 | /* something is wrong; assume it's either from/to 0dB */ | ||
476 | if (scale[2] < 0) | ||
477 | scale[3] = 0; | ||
478 | else if (scale[2] > 0) | ||
479 | scale[2] = 0; | ||
480 | else /* totally crap, return an error */ | ||
481 | return -EINVAL; | ||
482 | } | ||
473 | if (copy_to_user(_tlv, scale, sizeof(scale))) | 483 | if (copy_to_user(_tlv, scale, sizeof(scale))) |
474 | return -EFAULT; | 484 | return -EFAULT; |
475 | return 0; | 485 | return 0; |
@@ -990,20 +1000,35 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc, | |||
990 | break; | 1000 | break; |
991 | } | 1001 | } |
992 | 1002 | ||
993 | /* quirk for UDA1321/N101 */ | 1003 | /* volume control quirks */ |
994 | /* note that detection between firmware 2.1.1.7 (N101) and later 2.1.1.21 */ | ||
995 | /* is not very clear from datasheets */ | ||
996 | /* I hope that the min value is -15360 for newer firmware --jk */ | ||
997 | switch (state->chip->usb_id) { | 1004 | switch (state->chip->usb_id) { |
998 | case USB_ID(0x0471, 0x0101): | 1005 | case USB_ID(0x0471, 0x0101): |
999 | case USB_ID(0x0471, 0x0104): | 1006 | case USB_ID(0x0471, 0x0104): |
1000 | case USB_ID(0x0471, 0x0105): | 1007 | case USB_ID(0x0471, 0x0105): |
1001 | case USB_ID(0x0672, 0x1041): | 1008 | case USB_ID(0x0672, 0x1041): |
1009 | /* quirk for UDA1321/N101. | ||
1010 | * note that detection between firmware 2.1.1.7 (N101) | ||
1011 | * and later 2.1.1.21 is not very clear from datasheets. | ||
1012 | * I hope that the min value is -15360 for newer firmware --jk | ||
1013 | */ | ||
1002 | if (!strcmp(kctl->id.name, "PCM Playback Volume") && | 1014 | if (!strcmp(kctl->id.name, "PCM Playback Volume") && |
1003 | cval->min == -15616) { | 1015 | cval->min == -15616) { |
1004 | snd_printk(KERN_INFO "using volume control quirk for the UDA1321/N101 chip\n"); | 1016 | snd_printk(KERN_INFO |
1017 | "set volume quirk for UDA1321/N101 chip\n"); | ||
1005 | cval->max = -256; | 1018 | cval->max = -256; |
1006 | } | 1019 | } |
1020 | break; | ||
1021 | |||
1022 | case USB_ID(0x046d, 0x09a4): | ||
1023 | if (!strcmp(kctl->id.name, "Mic Capture Volume")) { | ||
1024 | snd_printk(KERN_INFO | ||
1025 | "set volume quirk for QuickCam E3500\n"); | ||
1026 | cval->min = 6080; | ||
1027 | cval->max = 8768; | ||
1028 | cval->res = 192; | ||
1029 | } | ||
1030 | break; | ||
1031 | |||
1007 | } | 1032 | } |
1008 | 1033 | ||
1009 | snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", | 1034 | snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", |
@@ -2018,6 +2043,58 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry, | |||
2018 | } | 2043 | } |
2019 | } | 2044 | } |
2020 | 2045 | ||
2046 | static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol, | ||
2047 | struct snd_ctl_elem_value *ucontrol) | ||
2048 | { | ||
2049 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); | ||
2050 | |||
2051 | ucontrol->value.integer.value[0] = !!(mixer->xonar_u1_status & 0x02); | ||
2052 | return 0; | ||
2053 | } | ||
2054 | |||
2055 | static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol, | ||
2056 | struct snd_ctl_elem_value *ucontrol) | ||
2057 | { | ||
2058 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); | ||
2059 | u8 old_status, new_status; | ||
2060 | int err, changed; | ||
2061 | |||
2062 | old_status = mixer->xonar_u1_status; | ||
2063 | if (ucontrol->value.integer.value[0]) | ||
2064 | new_status = old_status | 0x02; | ||
2065 | else | ||
2066 | new_status = old_status & ~0x02; | ||
2067 | changed = new_status != old_status; | ||
2068 | err = snd_usb_ctl_msg(mixer->chip->dev, | ||
2069 | usb_sndctrlpipe(mixer->chip->dev, 0), 0x08, | ||
2070 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, | ||
2071 | 50, 0, &new_status, 1, 100); | ||
2072 | if (err < 0) | ||
2073 | return err; | ||
2074 | mixer->xonar_u1_status = new_status; | ||
2075 | return changed; | ||
2076 | } | ||
2077 | |||
2078 | static struct snd_kcontrol_new snd_xonar_u1_output_switch = { | ||
2079 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2080 | .name = "Digital Playback Switch", | ||
2081 | .info = snd_ctl_boolean_mono_info, | ||
2082 | .get = snd_xonar_u1_switch_get, | ||
2083 | .put = snd_xonar_u1_switch_put, | ||
2084 | }; | ||
2085 | |||
2086 | static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer) | ||
2087 | { | ||
2088 | int err; | ||
2089 | |||
2090 | err = snd_ctl_add(mixer->chip->card, | ||
2091 | snd_ctl_new1(&snd_xonar_u1_output_switch, mixer)); | ||
2092 | if (err < 0) | ||
2093 | return err; | ||
2094 | mixer->xonar_u1_status = 0x05; | ||
2095 | return 0; | ||
2096 | } | ||
2097 | |||
2021 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | 2098 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, |
2022 | int ignore_error) | 2099 | int ignore_error) |
2023 | { | 2100 | { |
@@ -2060,6 +2137,13 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | |||
2060 | snd_audigy2nx_proc_read); | 2137 | snd_audigy2nx_proc_read); |
2061 | } | 2138 | } |
2062 | 2139 | ||
2140 | if (mixer->chip->usb_id == USB_ID(0x0b05, 0x1739) || | ||
2141 | mixer->chip->usb_id == USB_ID(0x0b05, 0x1743)) { | ||
2142 | err = snd_xonar_u1_controls_create(mixer); | ||
2143 | if (err < 0) | ||
2144 | goto _error; | ||
2145 | } | ||
2146 | |||
2063 | err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops); | 2147 | err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops); |
2064 | if (err < 0) | 2148 | if (err < 0) |
2065 | goto _error; | 2149 | goto _error; |
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index a5aae9d67f31..fd44946ce4b3 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c | |||
@@ -514,7 +514,6 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) | |||
514 | US122L(card)->chip.dev->bus->busnum, | 514 | US122L(card)->chip.dev->bus->busnum, |
515 | US122L(card)->chip.dev->devnum | 515 | US122L(card)->chip.dev->devnum |
516 | ); | 516 | ); |
517 | snd_card_set_dev(card, &device->dev); | ||
518 | *cardp = card; | 517 | *cardp = card; |
519 | return 0; | 518 | return 0; |
520 | } | 519 | } |
@@ -531,6 +530,7 @@ static int us122l_usb_probe(struct usb_interface *intf, | |||
531 | if (err < 0) | 530 | if (err < 0) |
532 | return err; | 531 | return err; |
533 | 532 | ||
533 | snd_card_set_dev(card, &intf->dev); | ||
534 | if (!us122l_create_card(card)) { | 534 | if (!us122l_create_card(card)) { |
535 | snd_card_free(card); | 535 | snd_card_free(card); |
536 | return -EINVAL; | 536 | return -EINVAL; |
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index 5ce0da23ee96..cb4bb8373ca2 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c | |||
@@ -364,7 +364,6 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp) | |||
364 | 0,//us428(card)->usbmidi.ifnum, | 364 | 0,//us428(card)->usbmidi.ifnum, |
365 | usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum | 365 | usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum |
366 | ); | 366 | ); |
367 | snd_card_set_dev(card, &device->dev); | ||
368 | *cardp = card; | 367 | *cardp = card; |
369 | return 0; | 368 | return 0; |
370 | } | 369 | } |
@@ -388,6 +387,7 @@ static int usX2Y_usb_probe(struct usb_device *device, | |||
388 | err = usX2Y_create_card(device, &card); | 387 | err = usX2Y_create_card(device, &card); |
389 | if (err < 0) | 388 | if (err < 0) |
390 | return err; | 389 | return err; |
390 | snd_card_set_dev(card, &intf->dev); | ||
391 | if ((err = usX2Y_hwdep_new(card, device)) < 0 || | 391 | if ((err = usX2Y_hwdep_new(card, device)) < 0 || |
392 | (err = snd_card_register(card)) < 0) { | 392 | (err = snd_card_register(card)) < 0) { |
393 | snd_card_free(card); | 393 | snd_card_free(card); |
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index dd1ab6177840..9efd27f6b52f 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c | |||
@@ -296,9 +296,10 @@ static void usX2Y_error_urb_status(struct usX2Ydev *usX2Y, | |||
296 | static void usX2Y_error_sequence(struct usX2Ydev *usX2Y, | 296 | static void usX2Y_error_sequence(struct usX2Ydev *usX2Y, |
297 | struct snd_usX2Y_substream *subs, struct urb *urb) | 297 | struct snd_usX2Y_substream *subs, struct urb *urb) |
298 | { | 298 | { |
299 | snd_printk(KERN_ERR "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" | 299 | snd_printk(KERN_ERR |
300 | KERN_ERR "Most propably some urb of usb-frame %i is still missing.\n" | 300 | "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" |
301 | KERN_ERR "Cause could be too long delays in usb-hcd interrupt handling.\n", | 301 | "Most propably some urb of usb-frame %i is still missing.\n" |
302 | "Cause could be too long delays in usb-hcd interrupt handling.\n", | ||
302 | usb_get_current_frame_number(usX2Y->chip.dev), | 303 | usb_get_current_frame_number(usX2Y->chip.dev), |
303 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", | 304 | subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", |
304 | usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); | 305 | usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); |