diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-03-10 10:02:37 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-03-10 10:02:37 -0500 |
commit | fad837c16cdd856c68ce2e1335ad0fe836ed8ecd (patch) | |
tree | 1a6babdc2ac7e5388c482e93505fdfaf5ff97f61 /sound | |
parent | 51c6ab130642ed975681df843c772dda48a1d2ed (diff) | |
parent | 57d54889cd00db2752994b389ba714138652e60c (diff) |
Merge commit 'v2.6.34-rc1' into for-2.6.35
Diffstat (limited to 'sound')
192 files changed, 10349 insertions, 4115 deletions
diff --git a/sound/aoa/fabrics/layout.c b/sound/aoa/fabrics/layout.c index 586965f9605f..7a437da05646 100644 --- a/sound/aoa/fabrics/layout.c +++ b/sound/aoa/fabrics/layout.c | |||
@@ -768,7 +768,7 @@ static int check_codec(struct aoa_codec *codec, | |||
768 | "required property %s not present\n", propname); | 768 | "required property %s not present\n", propname); |
769 | return -ENODEV; | 769 | return -ENODEV; |
770 | } | 770 | } |
771 | if (*ref != codec->node->linux_phandle) { | 771 | if (*ref != codec->node->phandle) { |
772 | printk(KERN_INFO "snd-aoa-fabric-layout: " | 772 | printk(KERN_INFO "snd-aoa-fabric-layout: " |
773 | "%s doesn't match!\n", propname); | 773 | "%s doesn't match!\n", propname); |
774 | return -ENODEV; | 774 | return -ENODEV; |
diff --git a/sound/core/control.c b/sound/core/control.c index 268ab7471224..439ce64f9d82 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -237,8 +237,9 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol, | |||
237 | access = ncontrol->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : | 237 | access = ncontrol->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : |
238 | (ncontrol->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE| | 238 | (ncontrol->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE| |
239 | SNDRV_CTL_ELEM_ACCESS_INACTIVE| | 239 | SNDRV_CTL_ELEM_ACCESS_INACTIVE| |
240 | SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE| | 240 | SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE| |
241 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)); | 241 | SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND| |
242 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)); | ||
242 | kctl.info = ncontrol->info; | 243 | kctl.info = ncontrol->info; |
243 | kctl.get = ncontrol->get; | 244 | kctl.get = ncontrol->get; |
244 | kctl.put = ncontrol->put; | 245 | kctl.put = ncontrol->put; |
@@ -1099,7 +1100,7 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file, | |||
1099 | 1100 | ||
1100 | if (copy_from_user(&tlv, _tlv, sizeof(tlv))) | 1101 | if (copy_from_user(&tlv, _tlv, sizeof(tlv))) |
1101 | return -EFAULT; | 1102 | return -EFAULT; |
1102 | if (tlv.length < sizeof(unsigned int) * 3) | 1103 | if (tlv.length < sizeof(unsigned int) * 2) |
1103 | return -EINVAL; | 1104 | return -EINVAL; |
1104 | down_read(&card->controls_rwsem); | 1105 | down_read(&card->controls_rwsem); |
1105 | kctl = snd_ctl_find_numid(card, tlv.numid); | 1106 | kctl = snd_ctl_find_numid(card, tlv.numid); |
diff --git a/sound/core/misc.c b/sound/core/misc.c index 23a032c6d487..3da4f92427d8 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c | |||
@@ -101,8 +101,9 @@ EXPORT_SYMBOL_GPL(__snd_printk); | |||
101 | #ifdef CONFIG_PCI | 101 | #ifdef CONFIG_PCI |
102 | #include <linux/pci.h> | 102 | #include <linux/pci.h> |
103 | /** | 103 | /** |
104 | * snd_pci_quirk_lookup - look up a PCI SSID quirk list | 104 | * snd_pci_quirk_lookup_id - look up a PCI SSID quirk list |
105 | * @pci: pci_dev handle | 105 | * @vendor: PCI SSV id |
106 | * @device: PCI SSD id | ||
106 | * @list: quirk list, terminated by a null entry | 107 | * @list: quirk list, terminated by a null entry |
107 | * | 108 | * |
108 | * Look through the given quirk list and finds a matching entry | 109 | * Look through the given quirk list and finds a matching entry |
@@ -112,18 +113,39 @@ EXPORT_SYMBOL_GPL(__snd_printk); | |||
112 | * Returns the matched entry pointer, or NULL if nothing matched. | 113 | * Returns the matched entry pointer, or NULL if nothing matched. |
113 | */ | 114 | */ |
114 | const struct snd_pci_quirk * | 115 | const struct snd_pci_quirk * |
115 | snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list) | 116 | snd_pci_quirk_lookup_id(u16 vendor, u16 device, |
117 | const struct snd_pci_quirk *list) | ||
116 | { | 118 | { |
117 | const struct snd_pci_quirk *q; | 119 | const struct snd_pci_quirk *q; |
118 | 120 | ||
119 | for (q = list; q->subvendor; q++) { | 121 | for (q = list; q->subvendor; q++) { |
120 | if (q->subvendor != pci->subsystem_vendor) | 122 | if (q->subvendor != vendor) |
121 | continue; | 123 | continue; |
122 | if (!q->subdevice || | 124 | if (!q->subdevice || |
123 | (pci->subsystem_device & q->subdevice_mask) == q->subdevice) | 125 | (device & q->subdevice_mask) == q->subdevice) |
124 | return q; | 126 | return q; |
125 | } | 127 | } |
126 | return NULL; | 128 | return NULL; |
127 | } | 129 | } |
130 | EXPORT_SYMBOL(snd_pci_quirk_lookup_id); | ||
131 | |||
132 | /** | ||
133 | * snd_pci_quirk_lookup - look up a PCI SSID quirk list | ||
134 | * @pci: pci_dev handle | ||
135 | * @list: quirk list, terminated by a null entry | ||
136 | * | ||
137 | * Look through the given quirk list and finds a matching entry | ||
138 | * with the same PCI SSID. When subdevice is 0, all subdevice | ||
139 | * values may match. | ||
140 | * | ||
141 | * Returns the matched entry pointer, or NULL if nothing matched. | ||
142 | */ | ||
143 | const struct snd_pci_quirk * | ||
144 | snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list) | ||
145 | { | ||
146 | return snd_pci_quirk_lookup_id(pci->subsystem_vendor, | ||
147 | pci->subsystem_device, | ||
148 | list); | ||
149 | } | ||
128 | EXPORT_SYMBOL(snd_pci_quirk_lookup); | 150 | EXPORT_SYMBOL(snd_pci_quirk_lookup); |
129 | #endif | 151 | #endif |
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index d9c96353121a..82d4e3329b3d 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c | |||
@@ -632,6 +632,12 @@ static long snd_pcm_alsa_frames(struct snd_pcm_substream *substream, long bytes) | |||
632 | return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes); | 632 | return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes); |
633 | } | 633 | } |
634 | 634 | ||
635 | static inline | ||
636 | snd_pcm_uframes_t get_hw_ptr_period(struct snd_pcm_runtime *runtime) | ||
637 | { | ||
638 | return runtime->hw_ptr_interrupt; | ||
639 | } | ||
640 | |||
635 | /* define extended formats in the recent OSS versions (if any) */ | 641 | /* define extended formats in the recent OSS versions (if any) */ |
636 | /* linear formats */ | 642 | /* linear formats */ |
637 | #define AFMT_S32_LE 0x00001000 | 643 | #define AFMT_S32_LE 0x00001000 |
@@ -1102,7 +1108,7 @@ static int snd_pcm_oss_prepare(struct snd_pcm_substream *substream) | |||
1102 | return err; | 1108 | return err; |
1103 | } | 1109 | } |
1104 | runtime->oss.prepare = 0; | 1110 | runtime->oss.prepare = 0; |
1105 | runtime->oss.prev_hw_ptr_interrupt = 0; | 1111 | runtime->oss.prev_hw_ptr_period = 0; |
1106 | runtime->oss.period_ptr = 0; | 1112 | runtime->oss.period_ptr = 0; |
1107 | runtime->oss.buffer_used = 0; | 1113 | runtime->oss.buffer_used = 0; |
1108 | 1114 | ||
@@ -1950,7 +1956,8 @@ static int snd_pcm_oss_get_caps(struct snd_pcm_oss_file *pcm_oss_file) | |||
1950 | return result; | 1956 | return result; |
1951 | } | 1957 | } |
1952 | 1958 | ||
1953 | static void snd_pcm_oss_simulate_fill(struct snd_pcm_substream *substream, snd_pcm_uframes_t hw_ptr) | 1959 | static void snd_pcm_oss_simulate_fill(struct snd_pcm_substream *substream, |
1960 | snd_pcm_uframes_t hw_ptr) | ||
1954 | { | 1961 | { |
1955 | struct snd_pcm_runtime *runtime = substream->runtime; | 1962 | struct snd_pcm_runtime *runtime = substream->runtime; |
1956 | snd_pcm_uframes_t appl_ptr; | 1963 | snd_pcm_uframes_t appl_ptr; |
@@ -1986,7 +1993,8 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr | |||
1986 | if (runtime->oss.trigger) | 1993 | if (runtime->oss.trigger) |
1987 | goto _skip1; | 1994 | goto _skip1; |
1988 | if (atomic_read(&psubstream->mmap_count)) | 1995 | if (atomic_read(&psubstream->mmap_count)) |
1989 | snd_pcm_oss_simulate_fill(psubstream, runtime->hw_ptr_interrupt); | 1996 | snd_pcm_oss_simulate_fill(psubstream, |
1997 | get_hw_ptr_period(runtime)); | ||
1990 | runtime->oss.trigger = 1; | 1998 | runtime->oss.trigger = 1; |
1991 | runtime->start_threshold = 1; | 1999 | runtime->start_threshold = 1; |
1992 | cmd = SNDRV_PCM_IOCTL_START; | 2000 | cmd = SNDRV_PCM_IOCTL_START; |
@@ -2105,11 +2113,12 @@ static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream | |||
2105 | info.ptr = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr % runtime->buffer_size); | 2113 | info.ptr = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr % runtime->buffer_size); |
2106 | if (atomic_read(&substream->mmap_count)) { | 2114 | if (atomic_read(&substream->mmap_count)) { |
2107 | snd_pcm_sframes_t n; | 2115 | snd_pcm_sframes_t n; |
2108 | n = (delay = runtime->hw_ptr_interrupt) - runtime->oss.prev_hw_ptr_interrupt; | 2116 | delay = get_hw_ptr_period(runtime); |
2117 | n = delay - runtime->oss.prev_hw_ptr_period; | ||
2109 | if (n < 0) | 2118 | if (n < 0) |
2110 | n += runtime->boundary; | 2119 | n += runtime->boundary; |
2111 | info.blocks = n / runtime->period_size; | 2120 | info.blocks = n / runtime->period_size; |
2112 | runtime->oss.prev_hw_ptr_interrupt = delay; | 2121 | runtime->oss.prev_hw_ptr_period = delay; |
2113 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 2122 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
2114 | snd_pcm_oss_simulate_fill(substream, delay); | 2123 | snd_pcm_oss_simulate_fill(substream, delay); |
2115 | info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX; | 2124 | info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX; |
@@ -2673,18 +2682,22 @@ static int snd_pcm_oss_playback_ready(struct snd_pcm_substream *substream) | |||
2673 | { | 2682 | { |
2674 | struct snd_pcm_runtime *runtime = substream->runtime; | 2683 | struct snd_pcm_runtime *runtime = substream->runtime; |
2675 | if (atomic_read(&substream->mmap_count)) | 2684 | if (atomic_read(&substream->mmap_count)) |
2676 | return runtime->oss.prev_hw_ptr_interrupt != runtime->hw_ptr_interrupt; | 2685 | return runtime->oss.prev_hw_ptr_period != |
2686 | get_hw_ptr_period(runtime); | ||
2677 | else | 2687 | else |
2678 | return snd_pcm_playback_avail(runtime) >= runtime->oss.period_frames; | 2688 | return snd_pcm_playback_avail(runtime) >= |
2689 | runtime->oss.period_frames; | ||
2679 | } | 2690 | } |
2680 | 2691 | ||
2681 | static int snd_pcm_oss_capture_ready(struct snd_pcm_substream *substream) | 2692 | static int snd_pcm_oss_capture_ready(struct snd_pcm_substream *substream) |
2682 | { | 2693 | { |
2683 | struct snd_pcm_runtime *runtime = substream->runtime; | 2694 | struct snd_pcm_runtime *runtime = substream->runtime; |
2684 | if (atomic_read(&substream->mmap_count)) | 2695 | if (atomic_read(&substream->mmap_count)) |
2685 | return runtime->oss.prev_hw_ptr_interrupt != runtime->hw_ptr_interrupt; | 2696 | return runtime->oss.prev_hw_ptr_period != |
2697 | get_hw_ptr_period(runtime); | ||
2686 | else | 2698 | else |
2687 | return snd_pcm_capture_avail(runtime) >= runtime->oss.period_frames; | 2699 | return snd_pcm_capture_avail(runtime) >= |
2700 | runtime->oss.period_frames; | ||
2688 | } | 2701 | } |
2689 | 2702 | ||
2690 | static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait) | 2703 | static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait) |
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 6884ae031f6f..0d428d0896db 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -894,6 +894,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, | |||
894 | memset((void*)runtime->control, 0, size); | 894 | memset((void*)runtime->control, 0, size); |
895 | 895 | ||
896 | init_waitqueue_head(&runtime->sleep); | 896 | init_waitqueue_head(&runtime->sleep); |
897 | init_waitqueue_head(&runtime->tsleep); | ||
897 | 898 | ||
898 | runtime->status->state = SNDRV_PCM_STATE_OPEN; | 899 | runtime->status->state = SNDRV_PCM_STATE_OPEN; |
899 | 900 | ||
@@ -921,6 +922,10 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream) | |||
921 | snd_free_pages((void*)runtime->control, | 922 | snd_free_pages((void*)runtime->control, |
922 | PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))); | 923 | PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))); |
923 | kfree(runtime->hw_constraints.rules); | 924 | kfree(runtime->hw_constraints.rules); |
925 | #ifdef CONFIG_SND_PCM_XRUN_DEBUG | ||
926 | if (runtime->hwptr_log) | ||
927 | kfree(runtime->hwptr_log); | ||
928 | #endif | ||
924 | kfree(runtime); | 929 | kfree(runtime); |
925 | substream->runtime = NULL; | 930 | substream->runtime = NULL; |
926 | put_pid(substream->pid); | 931 | put_pid(substream->pid); |
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index a27545b23ee9..b546ac2660f9 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -126,17 +126,6 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram | |||
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | #ifdef CONFIG_SND_PCM_XRUN_DEBUG | ||
130 | #define xrun_debug(substream, mask) ((substream)->pstr->xrun_debug & (mask)) | ||
131 | #else | ||
132 | #define xrun_debug(substream, mask) 0 | ||
133 | #endif | ||
134 | |||
135 | #define dump_stack_on_xrun(substream) do { \ | ||
136 | if (xrun_debug(substream, 2)) \ | ||
137 | dump_stack(); \ | ||
138 | } while (0) | ||
139 | |||
140 | static void pcm_debug_name(struct snd_pcm_substream *substream, | 129 | static void pcm_debug_name(struct snd_pcm_substream *substream, |
141 | char *name, size_t len) | 130 | char *name, size_t len) |
142 | { | 131 | { |
@@ -147,6 +136,24 @@ static void pcm_debug_name(struct snd_pcm_substream *substream, | |||
147 | substream->number); | 136 | substream->number); |
148 | } | 137 | } |
149 | 138 | ||
139 | #define XRUN_DEBUG_BASIC (1<<0) | ||
140 | #define XRUN_DEBUG_STACK (1<<1) /* dump also stack */ | ||
141 | #define XRUN_DEBUG_JIFFIESCHECK (1<<2) /* do jiffies check */ | ||
142 | #define XRUN_DEBUG_PERIODUPDATE (1<<3) /* full period update info */ | ||
143 | #define XRUN_DEBUG_HWPTRUPDATE (1<<4) /* full hwptr update info */ | ||
144 | #define XRUN_DEBUG_LOG (1<<5) /* show last 10 positions on err */ | ||
145 | #define XRUN_DEBUG_LOGONCE (1<<6) /* do above only once */ | ||
146 | |||
147 | #ifdef CONFIG_SND_PCM_XRUN_DEBUG | ||
148 | |||
149 | #define xrun_debug(substream, mask) \ | ||
150 | ((substream)->pstr->xrun_debug & (mask)) | ||
151 | |||
152 | #define dump_stack_on_xrun(substream) do { \ | ||
153 | if (xrun_debug(substream, XRUN_DEBUG_STACK)) \ | ||
154 | dump_stack(); \ | ||
155 | } while (0) | ||
156 | |||
150 | static void xrun(struct snd_pcm_substream *substream) | 157 | static void xrun(struct snd_pcm_substream *substream) |
151 | { | 158 | { |
152 | struct snd_pcm_runtime *runtime = substream->runtime; | 159 | struct snd_pcm_runtime *runtime = substream->runtime; |
@@ -154,7 +161,7 @@ static void xrun(struct snd_pcm_substream *substream) | |||
154 | if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) | 161 | if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) |
155 | snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); | 162 | snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); |
156 | snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); | 163 | snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); |
157 | if (xrun_debug(substream, 1)) { | 164 | if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { |
158 | char name[16]; | 165 | char name[16]; |
159 | pcm_debug_name(substream, name, sizeof(name)); | 166 | pcm_debug_name(substream, name, sizeof(name)); |
160 | snd_printd(KERN_DEBUG "XRUN: %s\n", name); | 167 | snd_printd(KERN_DEBUG "XRUN: %s\n", name); |
@@ -162,32 +169,102 @@ static void xrun(struct snd_pcm_substream *substream) | |||
162 | } | 169 | } |
163 | } | 170 | } |
164 | 171 | ||
165 | static snd_pcm_uframes_t | 172 | #define hw_ptr_error(substream, fmt, args...) \ |
166 | snd_pcm_update_hw_ptr_pos(struct snd_pcm_substream *substream, | 173 | do { \ |
167 | struct snd_pcm_runtime *runtime) | 174 | if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { \ |
168 | { | 175 | xrun_log_show(substream); \ |
176 | if (printk_ratelimit()) { \ | ||
177 | snd_printd("PCM: " fmt, ##args); \ | ||
178 | } \ | ||
179 | dump_stack_on_xrun(substream); \ | ||
180 | } \ | ||
181 | } while (0) | ||
182 | |||
183 | #define XRUN_LOG_CNT 10 | ||
184 | |||
185 | struct hwptr_log_entry { | ||
186 | unsigned long jiffies; | ||
169 | snd_pcm_uframes_t pos; | 187 | snd_pcm_uframes_t pos; |
188 | snd_pcm_uframes_t period_size; | ||
189 | snd_pcm_uframes_t buffer_size; | ||
190 | snd_pcm_uframes_t old_hw_ptr; | ||
191 | snd_pcm_uframes_t hw_ptr_base; | ||
192 | }; | ||
170 | 193 | ||
171 | pos = substream->ops->pointer(substream); | 194 | struct snd_pcm_hwptr_log { |
172 | if (pos == SNDRV_PCM_POS_XRUN) | 195 | unsigned int idx; |
173 | return pos; /* XRUN */ | 196 | unsigned int hit: 1; |
174 | if (pos >= runtime->buffer_size) { | 197 | struct hwptr_log_entry entries[XRUN_LOG_CNT]; |
175 | if (printk_ratelimit()) { | 198 | }; |
176 | char name[16]; | 199 | |
177 | pcm_debug_name(substream, name, sizeof(name)); | 200 | static void xrun_log(struct snd_pcm_substream *substream, |
178 | snd_printd(KERN_ERR "BUG: %s, pos = 0x%lx, " | 201 | snd_pcm_uframes_t pos) |
179 | "buffer size = 0x%lx, period size = 0x%lx\n", | 202 | { |
180 | name, pos, runtime->buffer_size, | 203 | struct snd_pcm_runtime *runtime = substream->runtime; |
181 | runtime->period_size); | 204 | struct snd_pcm_hwptr_log *log = runtime->hwptr_log; |
182 | } | 205 | struct hwptr_log_entry *entry; |
183 | pos = 0; | 206 | |
207 | if (log == NULL) { | ||
208 | log = kzalloc(sizeof(*log), GFP_ATOMIC); | ||
209 | if (log == NULL) | ||
210 | return; | ||
211 | runtime->hwptr_log = log; | ||
212 | } else { | ||
213 | if (xrun_debug(substream, XRUN_DEBUG_LOGONCE) && log->hit) | ||
214 | return; | ||
184 | } | 215 | } |
185 | pos -= pos % runtime->min_align; | 216 | entry = &log->entries[log->idx]; |
186 | return pos; | 217 | entry->jiffies = jiffies; |
218 | entry->pos = pos; | ||
219 | entry->period_size = runtime->period_size; | ||
220 | entry->buffer_size = runtime->buffer_size;; | ||
221 | entry->old_hw_ptr = runtime->status->hw_ptr; | ||
222 | entry->hw_ptr_base = runtime->hw_ptr_base; | ||
223 | log->idx = (log->idx + 1) % XRUN_LOG_CNT; | ||
224 | } | ||
225 | |||
226 | static void xrun_log_show(struct snd_pcm_substream *substream) | ||
227 | { | ||
228 | struct snd_pcm_hwptr_log *log = substream->runtime->hwptr_log; | ||
229 | struct hwptr_log_entry *entry; | ||
230 | char name[16]; | ||
231 | unsigned int idx; | ||
232 | int cnt; | ||
233 | |||
234 | if (log == NULL) | ||
235 | return; | ||
236 | if (xrun_debug(substream, XRUN_DEBUG_LOGONCE) && log->hit) | ||
237 | return; | ||
238 | pcm_debug_name(substream, name, sizeof(name)); | ||
239 | for (cnt = 0, idx = log->idx; cnt < XRUN_LOG_CNT; cnt++) { | ||
240 | entry = &log->entries[idx]; | ||
241 | if (entry->period_size == 0) | ||
242 | break; | ||
243 | snd_printd("hwptr log: %s: j=%lu, pos=%ld/%ld/%ld, " | ||
244 | "hwptr=%ld/%ld\n", | ||
245 | name, entry->jiffies, (unsigned long)entry->pos, | ||
246 | (unsigned long)entry->period_size, | ||
247 | (unsigned long)entry->buffer_size, | ||
248 | (unsigned long)entry->old_hw_ptr, | ||
249 | (unsigned long)entry->hw_ptr_base); | ||
250 | idx++; | ||
251 | idx %= XRUN_LOG_CNT; | ||
252 | } | ||
253 | log->hit = 1; | ||
187 | } | 254 | } |
188 | 255 | ||
189 | static int snd_pcm_update_hw_ptr_post(struct snd_pcm_substream *substream, | 256 | #else /* ! CONFIG_SND_PCM_XRUN_DEBUG */ |
190 | struct snd_pcm_runtime *runtime) | 257 | |
258 | #define xrun_debug(substream, mask) 0 | ||
259 | #define xrun(substream) do { } while (0) | ||
260 | #define hw_ptr_error(substream, fmt, args...) do { } while (0) | ||
261 | #define xrun_log(substream, pos) do { } while (0) | ||
262 | #define xrun_log_show(substream) do { } while (0) | ||
263 | |||
264 | #endif | ||
265 | |||
266 | int snd_pcm_update_state(struct snd_pcm_substream *substream, | ||
267 | struct snd_pcm_runtime *runtime) | ||
191 | { | 268 | { |
192 | snd_pcm_uframes_t avail; | 269 | snd_pcm_uframes_t avail; |
193 | 270 | ||
@@ -209,88 +286,94 @@ static int snd_pcm_update_hw_ptr_post(struct snd_pcm_substream *substream, | |||
209 | } | 286 | } |
210 | } | 287 | } |
211 | if (avail >= runtime->control->avail_min) | 288 | if (avail >= runtime->control->avail_min) |
212 | wake_up(&runtime->sleep); | 289 | wake_up(runtime->twake ? &runtime->tsleep : &runtime->sleep); |
213 | return 0; | 290 | return 0; |
214 | } | 291 | } |
215 | 292 | ||
216 | #define hw_ptr_error(substream, fmt, args...) \ | 293 | static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, |
217 | do { \ | 294 | unsigned int in_interrupt) |
218 | if (xrun_debug(substream, 1)) { \ | ||
219 | if (printk_ratelimit()) { \ | ||
220 | snd_printd("PCM: " fmt, ##args); \ | ||
221 | } \ | ||
222 | dump_stack_on_xrun(substream); \ | ||
223 | } \ | ||
224 | } while (0) | ||
225 | |||
226 | static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | ||
227 | { | 295 | { |
228 | struct snd_pcm_runtime *runtime = substream->runtime; | 296 | struct snd_pcm_runtime *runtime = substream->runtime; |
229 | snd_pcm_uframes_t pos; | 297 | snd_pcm_uframes_t pos; |
230 | snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_ptr_interrupt, hw_base; | 298 | snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base; |
231 | snd_pcm_sframes_t hdelta, delta; | 299 | snd_pcm_sframes_t hdelta, delta; |
232 | unsigned long jdelta; | 300 | unsigned long jdelta; |
233 | 301 | ||
234 | old_hw_ptr = runtime->status->hw_ptr; | 302 | old_hw_ptr = runtime->status->hw_ptr; |
235 | pos = snd_pcm_update_hw_ptr_pos(substream, runtime); | 303 | pos = substream->ops->pointer(substream); |
236 | if (pos == SNDRV_PCM_POS_XRUN) { | 304 | if (pos == SNDRV_PCM_POS_XRUN) { |
237 | xrun(substream); | 305 | xrun(substream); |
238 | return -EPIPE; | 306 | return -EPIPE; |
239 | } | 307 | } |
240 | if (xrun_debug(substream, 8)) { | 308 | if (pos >= runtime->buffer_size) { |
241 | char name[16]; | 309 | if (printk_ratelimit()) { |
242 | pcm_debug_name(substream, name, sizeof(name)); | 310 | char name[16]; |
243 | snd_printd("period_update: %s: pos=0x%x/0x%x/0x%x, " | 311 | pcm_debug_name(substream, name, sizeof(name)); |
244 | "hwptr=0x%lx, hw_base=0x%lx, hw_intr=0x%lx\n", | 312 | xrun_log_show(substream); |
245 | name, (unsigned int)pos, | 313 | snd_printd(KERN_ERR "BUG: %s, pos = %ld, " |
246 | (unsigned int)runtime->period_size, | 314 | "buffer size = %ld, period size = %ld\n", |
247 | (unsigned int)runtime->buffer_size, | 315 | name, pos, runtime->buffer_size, |
248 | (unsigned long)old_hw_ptr, | 316 | runtime->period_size); |
249 | (unsigned long)runtime->hw_ptr_base, | 317 | } |
250 | (unsigned long)runtime->hw_ptr_interrupt); | 318 | pos = 0; |
251 | } | 319 | } |
320 | pos -= pos % runtime->min_align; | ||
321 | if (xrun_debug(substream, XRUN_DEBUG_LOG)) | ||
322 | xrun_log(substream, pos); | ||
252 | hw_base = runtime->hw_ptr_base; | 323 | hw_base = runtime->hw_ptr_base; |
253 | new_hw_ptr = hw_base + pos; | 324 | new_hw_ptr = hw_base + pos; |
254 | hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size; | 325 | if (in_interrupt) { |
255 | delta = new_hw_ptr - hw_ptr_interrupt; | 326 | /* we know that one period was processed */ |
256 | if (hw_ptr_interrupt >= runtime->boundary) { | 327 | /* delta = "expected next hw_ptr" for in_interrupt != 0 */ |
257 | hw_ptr_interrupt -= runtime->boundary; | 328 | delta = runtime->hw_ptr_interrupt + runtime->period_size; |
258 | if (hw_base < runtime->boundary / 2) | 329 | if (delta > new_hw_ptr) { |
259 | /* hw_base was already lapped; recalc delta */ | ||
260 | delta = new_hw_ptr - hw_ptr_interrupt; | ||
261 | } | ||
262 | if (delta < 0) { | ||
263 | if (runtime->periods == 1 || new_hw_ptr < old_hw_ptr) | ||
264 | delta += runtime->buffer_size; | ||
265 | if (delta < 0) { | ||
266 | hw_ptr_error(substream, | ||
267 | "Unexpected hw_pointer value " | ||
268 | "(stream=%i, pos=%ld, intr_ptr=%ld)\n", | ||
269 | substream->stream, (long)pos, | ||
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 | ||
278 | /* rebase to interrupt position */ | ||
279 | hw_base = new_hw_ptr = hw_ptr_interrupt; | ||
280 | /* align hw_base to buffer_size */ | ||
281 | hw_base -= hw_base % runtime->buffer_size; | ||
282 | delta = 0; | ||
283 | #endif | ||
284 | } else { | ||
285 | hw_base += runtime->buffer_size; | 330 | hw_base += runtime->buffer_size; |
286 | if (hw_base >= runtime->boundary) | 331 | if (hw_base >= runtime->boundary) |
287 | hw_base = 0; | 332 | hw_base = 0; |
288 | new_hw_ptr = hw_base + pos; | 333 | new_hw_ptr = hw_base + pos; |
334 | goto __delta; | ||
289 | } | 335 | } |
290 | } | 336 | } |
337 | /* new_hw_ptr might be lower than old_hw_ptr in case when */ | ||
338 | /* pointer crosses the end of the ring buffer */ | ||
339 | if (new_hw_ptr < old_hw_ptr) { | ||
340 | hw_base += runtime->buffer_size; | ||
341 | if (hw_base >= runtime->boundary) | ||
342 | hw_base = 0; | ||
343 | new_hw_ptr = hw_base + pos; | ||
344 | } | ||
345 | __delta: | ||
346 | delta = (new_hw_ptr - old_hw_ptr) % runtime->boundary; | ||
347 | if (xrun_debug(substream, in_interrupt ? | ||
348 | XRUN_DEBUG_PERIODUPDATE : XRUN_DEBUG_HWPTRUPDATE)) { | ||
349 | char name[16]; | ||
350 | pcm_debug_name(substream, name, sizeof(name)); | ||
351 | snd_printd("%s_update: %s: pos=%u/%u/%u, " | ||
352 | "hwptr=%ld/%ld/%ld/%ld\n", | ||
353 | in_interrupt ? "period" : "hwptr", | ||
354 | name, | ||
355 | (unsigned int)pos, | ||
356 | (unsigned int)runtime->period_size, | ||
357 | (unsigned int)runtime->buffer_size, | ||
358 | (unsigned long)delta, | ||
359 | (unsigned long)old_hw_ptr, | ||
360 | (unsigned long)new_hw_ptr, | ||
361 | (unsigned long)runtime->hw_ptr_base); | ||
362 | } | ||
363 | /* something must be really wrong */ | ||
364 | if (delta >= runtime->buffer_size + runtime->period_size) { | ||
365 | hw_ptr_error(substream, | ||
366 | "Unexpected hw_pointer value %s" | ||
367 | "(stream=%i, pos=%ld, new_hw_ptr=%ld, " | ||
368 | "old_hw_ptr=%ld)\n", | ||
369 | in_interrupt ? "[Q] " : "[P]", | ||
370 | substream->stream, (long)pos, | ||
371 | (long)new_hw_ptr, (long)old_hw_ptr); | ||
372 | return 0; | ||
373 | } | ||
291 | 374 | ||
292 | /* Do jiffies check only in xrun_debug mode */ | 375 | /* Do jiffies check only in xrun_debug mode */ |
293 | if (!xrun_debug(substream, 4)) | 376 | if (!xrun_debug(substream, XRUN_DEBUG_JIFFIESCHECK)) |
294 | goto no_jiffies_check; | 377 | goto no_jiffies_check; |
295 | 378 | ||
296 | /* Skip the jiffies check for hardwares with BATCH flag. | 379 | /* Skip the jiffies check for hardwares with BATCH flag. |
@@ -299,7 +382,7 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | |||
299 | */ | 382 | */ |
300 | if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) | 383 | if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) |
301 | goto no_jiffies_check; | 384 | goto no_jiffies_check; |
302 | hdelta = new_hw_ptr - old_hw_ptr; | 385 | hdelta = delta; |
303 | if (hdelta < runtime->delay) | 386 | if (hdelta < runtime->delay) |
304 | goto no_jiffies_check; | 387 | goto no_jiffies_check; |
305 | hdelta -= runtime->delay; | 388 | hdelta -= runtime->delay; |
@@ -308,130 +391,68 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) | |||
308 | delta = jdelta / | 391 | delta = jdelta / |
309 | (((runtime->period_size * HZ) / runtime->rate) | 392 | (((runtime->period_size * HZ) / runtime->rate) |
310 | + HZ/100); | 393 | + HZ/100); |
394 | /* move new_hw_ptr according jiffies not pos variable */ | ||
395 | new_hw_ptr = old_hw_ptr; | ||
396 | hw_base = delta; | ||
397 | /* use loop to avoid checks for delta overflows */ | ||
398 | /* the delta value is small or zero in most cases */ | ||
399 | while (delta > 0) { | ||
400 | new_hw_ptr += runtime->period_size; | ||
401 | if (new_hw_ptr >= runtime->boundary) | ||
402 | new_hw_ptr -= runtime->boundary; | ||
403 | delta--; | ||
404 | } | ||
405 | /* align hw_base to buffer_size */ | ||
311 | hw_ptr_error(substream, | 406 | hw_ptr_error(substream, |
312 | "hw_ptr skipping! [Q] " | 407 | "hw_ptr skipping! %s" |
313 | "(pos=%ld, delta=%ld, period=%ld, " | 408 | "(pos=%ld, delta=%ld, period=%ld, " |
314 | "jdelta=%lu/%lu/%lu)\n", | 409 | "jdelta=%lu/%lu/%lu, hw_ptr=%ld/%ld)\n", |
410 | in_interrupt ? "[Q] " : "", | ||
315 | (long)pos, (long)hdelta, | 411 | (long)pos, (long)hdelta, |
316 | (long)runtime->period_size, jdelta, | 412 | (long)runtime->period_size, jdelta, |
317 | ((hdelta * HZ) / runtime->rate), delta); | 413 | ((hdelta * HZ) / runtime->rate), hw_base, |
318 | hw_ptr_interrupt = runtime->hw_ptr_interrupt + | 414 | (unsigned long)old_hw_ptr, |
319 | runtime->period_size * delta; | 415 | (unsigned long)new_hw_ptr); |
320 | if (hw_ptr_interrupt >= runtime->boundary) | 416 | /* reset values to proper state */ |
321 | hw_ptr_interrupt -= runtime->boundary; | ||
322 | /* rebase to interrupt position */ | ||
323 | hw_base = new_hw_ptr = hw_ptr_interrupt; | ||
324 | /* align hw_base to buffer_size */ | ||
325 | hw_base -= hw_base % runtime->buffer_size; | ||
326 | delta = 0; | 417 | delta = 0; |
418 | hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size); | ||
327 | } | 419 | } |
328 | no_jiffies_check: | 420 | no_jiffies_check: |
329 | if (delta > runtime->period_size + runtime->period_size / 2) { | 421 | if (delta > runtime->period_size + runtime->period_size / 2) { |
330 | hw_ptr_error(substream, | 422 | hw_ptr_error(substream, |
331 | "Lost interrupts? " | 423 | "Lost interrupts? %s" |
332 | "(stream=%i, delta=%ld, intr_ptr=%ld)\n", | 424 | "(stream=%i, delta=%ld, new_hw_ptr=%ld, " |
425 | "old_hw_ptr=%ld)\n", | ||
426 | in_interrupt ? "[Q] " : "", | ||
333 | substream->stream, (long)delta, | 427 | substream->stream, (long)delta, |
334 | (long)hw_ptr_interrupt); | 428 | (long)new_hw_ptr, |
335 | /* rebase hw_ptr_interrupt */ | 429 | (long)old_hw_ptr); |
336 | hw_ptr_interrupt = | ||
337 | new_hw_ptr - new_hw_ptr % runtime->period_size; | ||
338 | } | 430 | } |
339 | runtime->hw_ptr_interrupt = hw_ptr_interrupt; | 431 | |
432 | if (runtime->status->hw_ptr == new_hw_ptr) | ||
433 | return 0; | ||
340 | 434 | ||
341 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && | 435 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && |
342 | runtime->silence_size > 0) | 436 | runtime->silence_size > 0) |
343 | snd_pcm_playback_silence(substream, new_hw_ptr); | 437 | snd_pcm_playback_silence(substream, new_hw_ptr); |
344 | 438 | ||
345 | if (runtime->status->hw_ptr == new_hw_ptr) | 439 | if (in_interrupt) { |
346 | return 0; | 440 | runtime->hw_ptr_interrupt = new_hw_ptr - |
347 | 441 | (new_hw_ptr % runtime->period_size); | |
442 | } | ||
348 | runtime->hw_ptr_base = hw_base; | 443 | runtime->hw_ptr_base = hw_base; |
349 | runtime->status->hw_ptr = new_hw_ptr; | 444 | runtime->status->hw_ptr = new_hw_ptr; |
350 | runtime->hw_ptr_jiffies = jiffies; | 445 | runtime->hw_ptr_jiffies = jiffies; |
351 | if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) | 446 | if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) |
352 | snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); | 447 | snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); |
353 | 448 | ||
354 | return snd_pcm_update_hw_ptr_post(substream, runtime); | 449 | return snd_pcm_update_state(substream, runtime); |
355 | } | 450 | } |
356 | 451 | ||
357 | /* CAUTION: call it with irq disabled */ | 452 | /* CAUTION: call it with irq disabled */ |
358 | int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) | 453 | int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) |
359 | { | 454 | { |
360 | struct snd_pcm_runtime *runtime = substream->runtime; | 455 | return snd_pcm_update_hw_ptr0(substream, 0); |
361 | snd_pcm_uframes_t pos; | ||
362 | snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base; | ||
363 | snd_pcm_sframes_t delta; | ||
364 | unsigned long jdelta; | ||
365 | |||
366 | old_hw_ptr = runtime->status->hw_ptr; | ||
367 | pos = snd_pcm_update_hw_ptr_pos(substream, runtime); | ||
368 | if (pos == SNDRV_PCM_POS_XRUN) { | ||
369 | xrun(substream); | ||
370 | return -EPIPE; | ||
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 | |||
385 | hw_base = runtime->hw_ptr_base; | ||
386 | new_hw_ptr = hw_base + pos; | ||
387 | |||
388 | delta = new_hw_ptr - old_hw_ptr; | ||
389 | jdelta = jiffies - runtime->hw_ptr_jiffies; | ||
390 | if (delta < 0) { | ||
391 | delta += runtime->buffer_size; | ||
392 | if (delta < 0) { | ||
393 | hw_ptr_error(substream, | ||
394 | "Unexpected hw_pointer value [2] " | ||
395 | "(stream=%i, pos=%ld, old_ptr=%ld, jdelta=%li)\n", | ||
396 | substream->stream, (long)pos, | ||
397 | (long)old_hw_ptr, jdelta); | ||
398 | return 0; | ||
399 | } | ||
400 | hw_base += runtime->buffer_size; | ||
401 | if (hw_base >= runtime->boundary) | ||
402 | hw_base = 0; | ||
403 | new_hw_ptr = hw_base + pos; | ||
404 | } | ||
405 | /* Do jiffies check only in xrun_debug mode */ | ||
406 | if (!xrun_debug(substream, 4)) | ||
407 | goto no_jiffies_check; | ||
408 | if (delta < runtime->delay) | ||
409 | goto no_jiffies_check; | ||
410 | delta -= runtime->delay; | ||
411 | if (((delta * HZ) / runtime->rate) > jdelta + HZ/100) { | ||
412 | hw_ptr_error(substream, | ||
413 | "hw_ptr skipping! " | ||
414 | "(pos=%ld, delta=%ld, period=%ld, jdelta=%lu/%lu)\n", | ||
415 | (long)pos, (long)delta, | ||
416 | (long)runtime->period_size, jdelta, | ||
417 | ((delta * HZ) / runtime->rate)); | ||
418 | return 0; | ||
419 | } | ||
420 | no_jiffies_check: | ||
421 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && | ||
422 | runtime->silence_size > 0) | ||
423 | snd_pcm_playback_silence(substream, new_hw_ptr); | ||
424 | |||
425 | if (runtime->status->hw_ptr == new_hw_ptr) | ||
426 | return 0; | ||
427 | |||
428 | runtime->hw_ptr_base = hw_base; | ||
429 | runtime->status->hw_ptr = new_hw_ptr; | ||
430 | runtime->hw_ptr_jiffies = jiffies; | ||
431 | if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) | ||
432 | snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); | ||
433 | |||
434 | return snd_pcm_update_hw_ptr_post(substream, runtime); | ||
435 | } | 456 | } |
436 | 457 | ||
437 | /** | 458 | /** |
@@ -745,10 +766,13 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
745 | unsigned int rats_count, struct snd_ratnum *rats, | 766 | unsigned int rats_count, struct snd_ratnum *rats, |
746 | unsigned int *nump, unsigned int *denp) | 767 | unsigned int *nump, unsigned int *denp) |
747 | { | 768 | { |
748 | unsigned int best_num, best_diff, best_den; | 769 | unsigned int best_num, best_den; |
770 | int best_diff; | ||
749 | unsigned int k; | 771 | unsigned int k; |
750 | struct snd_interval t; | 772 | struct snd_interval t; |
751 | int err; | 773 | int err; |
774 | unsigned int result_num, result_den; | ||
775 | int result_diff; | ||
752 | 776 | ||
753 | best_num = best_den = best_diff = 0; | 777 | best_num = best_den = best_diff = 0; |
754 | for (k = 0; k < rats_count; ++k) { | 778 | for (k = 0; k < rats_count; ++k) { |
@@ -770,6 +794,8 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
770 | den -= r; | 794 | den -= r; |
771 | } | 795 | } |
772 | diff = num - q * den; | 796 | diff = num - q * den; |
797 | if (diff < 0) | ||
798 | diff = -diff; | ||
773 | if (best_num == 0 || | 799 | if (best_num == 0 || |
774 | diff * best_den < best_diff * den) { | 800 | diff * best_den < best_diff * den) { |
775 | best_diff = diff; | 801 | best_diff = diff; |
@@ -784,6 +810,9 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
784 | t.min = div_down(best_num, best_den); | 810 | t.min = div_down(best_num, best_den); |
785 | t.openmin = !!(best_num % best_den); | 811 | t.openmin = !!(best_num % best_den); |
786 | 812 | ||
813 | result_num = best_num; | ||
814 | result_diff = best_diff; | ||
815 | result_den = best_den; | ||
787 | best_num = best_den = best_diff = 0; | 816 | best_num = best_den = best_diff = 0; |
788 | for (k = 0; k < rats_count; ++k) { | 817 | for (k = 0; k < rats_count; ++k) { |
789 | unsigned int num = rats[k].num; | 818 | unsigned int num = rats[k].num; |
@@ -806,6 +835,8 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
806 | den += rats[k].den_step - r; | 835 | den += rats[k].den_step - r; |
807 | } | 836 | } |
808 | diff = q * den - num; | 837 | diff = q * den - num; |
838 | if (diff < 0) | ||
839 | diff = -diff; | ||
809 | if (best_num == 0 || | 840 | if (best_num == 0 || |
810 | diff * best_den < best_diff * den) { | 841 | diff * best_den < best_diff * den) { |
811 | best_diff = diff; | 842 | best_diff = diff; |
@@ -825,10 +856,14 @@ int snd_interval_ratnum(struct snd_interval *i, | |||
825 | return err; | 856 | return err; |
826 | 857 | ||
827 | if (snd_interval_single(i)) { | 858 | if (snd_interval_single(i)) { |
859 | if (best_diff * result_den < result_diff * best_den) { | ||
860 | result_num = best_num; | ||
861 | result_den = best_den; | ||
862 | } | ||
828 | if (nump) | 863 | if (nump) |
829 | *nump = best_num; | 864 | *nump = result_num; |
830 | if (denp) | 865 | if (denp) |
831 | *denp = best_den; | 866 | *denp = result_den; |
832 | } | 867 | } |
833 | return err; | 868 | return err; |
834 | } | 869 | } |
@@ -1643,7 +1678,7 @@ void snd_pcm_period_elapsed(struct snd_pcm_substream *substream) | |||
1643 | 1678 | ||
1644 | snd_pcm_stream_lock_irqsave(substream, flags); | 1679 | snd_pcm_stream_lock_irqsave(substream, flags); |
1645 | if (!snd_pcm_running(substream) || | 1680 | if (!snd_pcm_running(substream) || |
1646 | snd_pcm_update_hw_ptr_interrupt(substream) < 0) | 1681 | snd_pcm_update_hw_ptr0(substream, 1) < 0) |
1647 | goto _end; | 1682 | goto _end; |
1648 | 1683 | ||
1649 | if (substream->timer_running) | 1684 | if (substream->timer_running) |
@@ -1674,7 +1709,7 @@ static int wait_for_avail_min(struct snd_pcm_substream *substream, | |||
1674 | long tout; | 1709 | long tout; |
1675 | 1710 | ||
1676 | init_waitqueue_entry(&wait, current); | 1711 | init_waitqueue_entry(&wait, current); |
1677 | add_wait_queue(&runtime->sleep, &wait); | 1712 | add_wait_queue(&runtime->tsleep, &wait); |
1678 | for (;;) { | 1713 | for (;;) { |
1679 | if (signal_pending(current)) { | 1714 | if (signal_pending(current)) { |
1680 | err = -ERESTARTSYS; | 1715 | err = -ERESTARTSYS; |
@@ -1717,7 +1752,7 @@ static int wait_for_avail_min(struct snd_pcm_substream *substream, | |||
1717 | break; | 1752 | break; |
1718 | } | 1753 | } |
1719 | _endloop: | 1754 | _endloop: |
1720 | remove_wait_queue(&runtime->sleep, &wait); | 1755 | remove_wait_queue(&runtime->tsleep, &wait); |
1721 | *availp = avail; | 1756 | *availp = avail; |
1722 | return err; | 1757 | return err; |
1723 | } | 1758 | } |
@@ -1776,6 +1811,7 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, | |||
1776 | goto _end_unlock; | 1811 | goto _end_unlock; |
1777 | } | 1812 | } |
1778 | 1813 | ||
1814 | runtime->twake = 1; | ||
1779 | while (size > 0) { | 1815 | while (size > 0) { |
1780 | snd_pcm_uframes_t frames, appl_ptr, appl_ofs; | 1816 | snd_pcm_uframes_t frames, appl_ptr, appl_ofs; |
1781 | snd_pcm_uframes_t avail; | 1817 | snd_pcm_uframes_t avail; |
@@ -1797,15 +1833,17 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, | |||
1797 | if (frames > cont) | 1833 | if (frames > cont) |
1798 | frames = cont; | 1834 | frames = cont; |
1799 | if (snd_BUG_ON(!frames)) { | 1835 | if (snd_BUG_ON(!frames)) { |
1836 | runtime->twake = 0; | ||
1800 | snd_pcm_stream_unlock_irq(substream); | 1837 | snd_pcm_stream_unlock_irq(substream); |
1801 | return -EINVAL; | 1838 | return -EINVAL; |
1802 | } | 1839 | } |
1803 | appl_ptr = runtime->control->appl_ptr; | 1840 | appl_ptr = runtime->control->appl_ptr; |
1804 | appl_ofs = appl_ptr % runtime->buffer_size; | 1841 | appl_ofs = appl_ptr % runtime->buffer_size; |
1805 | snd_pcm_stream_unlock_irq(substream); | 1842 | snd_pcm_stream_unlock_irq(substream); |
1806 | if ((err = transfer(substream, appl_ofs, data, offset, frames)) < 0) | 1843 | err = transfer(substream, appl_ofs, data, offset, frames); |
1807 | goto _end; | ||
1808 | snd_pcm_stream_lock_irq(substream); | 1844 | snd_pcm_stream_lock_irq(substream); |
1845 | if (err < 0) | ||
1846 | goto _end_unlock; | ||
1809 | switch (runtime->status->state) { | 1847 | switch (runtime->status->state) { |
1810 | case SNDRV_PCM_STATE_XRUN: | 1848 | case SNDRV_PCM_STATE_XRUN: |
1811 | err = -EPIPE; | 1849 | err = -EPIPE; |
@@ -1834,8 +1872,10 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, | |||
1834 | } | 1872 | } |
1835 | } | 1873 | } |
1836 | _end_unlock: | 1874 | _end_unlock: |
1875 | runtime->twake = 0; | ||
1876 | if (xfer > 0 && err >= 0) | ||
1877 | snd_pcm_update_state(substream, runtime); | ||
1837 | snd_pcm_stream_unlock_irq(substream); | 1878 | snd_pcm_stream_unlock_irq(substream); |
1838 | _end: | ||
1839 | return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; | 1879 | return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; |
1840 | } | 1880 | } |
1841 | 1881 | ||
@@ -1993,6 +2033,7 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream, | |||
1993 | goto _end_unlock; | 2033 | goto _end_unlock; |
1994 | } | 2034 | } |
1995 | 2035 | ||
2036 | runtime->twake = 1; | ||
1996 | while (size > 0) { | 2037 | while (size > 0) { |
1997 | snd_pcm_uframes_t frames, appl_ptr, appl_ofs; | 2038 | snd_pcm_uframes_t frames, appl_ptr, appl_ofs; |
1998 | snd_pcm_uframes_t avail; | 2039 | snd_pcm_uframes_t avail; |
@@ -2021,15 +2062,17 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream, | |||
2021 | if (frames > cont) | 2062 | if (frames > cont) |
2022 | frames = cont; | 2063 | frames = cont; |
2023 | if (snd_BUG_ON(!frames)) { | 2064 | if (snd_BUG_ON(!frames)) { |
2065 | runtime->twake = 0; | ||
2024 | snd_pcm_stream_unlock_irq(substream); | 2066 | snd_pcm_stream_unlock_irq(substream); |
2025 | return -EINVAL; | 2067 | return -EINVAL; |
2026 | } | 2068 | } |
2027 | appl_ptr = runtime->control->appl_ptr; | 2069 | appl_ptr = runtime->control->appl_ptr; |
2028 | appl_ofs = appl_ptr % runtime->buffer_size; | 2070 | appl_ofs = appl_ptr % runtime->buffer_size; |
2029 | snd_pcm_stream_unlock_irq(substream); | 2071 | snd_pcm_stream_unlock_irq(substream); |
2030 | if ((err = transfer(substream, appl_ofs, data, offset, frames)) < 0) | 2072 | err = transfer(substream, appl_ofs, data, offset, frames); |
2031 | goto _end; | ||
2032 | snd_pcm_stream_lock_irq(substream); | 2073 | snd_pcm_stream_lock_irq(substream); |
2074 | if (err < 0) | ||
2075 | goto _end_unlock; | ||
2033 | switch (runtime->status->state) { | 2076 | switch (runtime->status->state) { |
2034 | case SNDRV_PCM_STATE_XRUN: | 2077 | case SNDRV_PCM_STATE_XRUN: |
2035 | err = -EPIPE; | 2078 | err = -EPIPE; |
@@ -2052,8 +2095,10 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream, | |||
2052 | xfer += frames; | 2095 | xfer += frames; |
2053 | } | 2096 | } |
2054 | _end_unlock: | 2097 | _end_unlock: |
2098 | runtime->twake = 0; | ||
2099 | if (xfer > 0 && err >= 0) | ||
2100 | snd_pcm_update_state(substream, runtime); | ||
2055 | snd_pcm_stream_unlock_irq(substream); | 2101 | snd_pcm_stream_unlock_irq(substream); |
2056 | _end: | ||
2057 | return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; | 2102 | return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; |
2058 | } | 2103 | } |
2059 | 2104 | ||
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index caa7796bc2f5..d6d49d6651f9 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/time.h> | 23 | #include <linux/time.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/moduleparam.h> | 25 | #include <linux/moduleparam.h> |
26 | #include <linux/vmalloc.h> | ||
26 | #include <sound/core.h> | 27 | #include <sound/core.h> |
27 | #include <sound/pcm.h> | 28 | #include <sound/pcm.h> |
28 | #include <sound/info.h> | 29 | #include <sound/info.h> |
@@ -434,3 +435,57 @@ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) | |||
434 | } | 435 | } |
435 | 436 | ||
436 | EXPORT_SYMBOL(snd_pcm_lib_free_pages); | 437 | EXPORT_SYMBOL(snd_pcm_lib_free_pages); |
438 | |||
439 | int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream, | ||
440 | size_t size, gfp_t gfp_flags) | ||
441 | { | ||
442 | struct snd_pcm_runtime *runtime; | ||
443 | |||
444 | if (PCM_RUNTIME_CHECK(substream)) | ||
445 | return -EINVAL; | ||
446 | runtime = substream->runtime; | ||
447 | if (runtime->dma_area) { | ||
448 | if (runtime->dma_bytes >= size) | ||
449 | return 0; /* already large enough */ | ||
450 | vfree(runtime->dma_area); | ||
451 | } | ||
452 | runtime->dma_area = __vmalloc(size, gfp_flags, PAGE_KERNEL); | ||
453 | if (!runtime->dma_area) | ||
454 | return -ENOMEM; | ||
455 | runtime->dma_bytes = size; | ||
456 | return 1; | ||
457 | } | ||
458 | EXPORT_SYMBOL(_snd_pcm_lib_alloc_vmalloc_buffer); | ||
459 | |||
460 | /** | ||
461 | * snd_pcm_lib_free_vmalloc_buffer - free vmalloc buffer | ||
462 | * @substream: the substream with a buffer allocated by | ||
463 | * snd_pcm_lib_alloc_vmalloc_buffer() | ||
464 | */ | ||
465 | int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream) | ||
466 | { | ||
467 | struct snd_pcm_runtime *runtime; | ||
468 | |||
469 | if (PCM_RUNTIME_CHECK(substream)) | ||
470 | return -EINVAL; | ||
471 | runtime = substream->runtime; | ||
472 | vfree(runtime->dma_area); | ||
473 | runtime->dma_area = NULL; | ||
474 | return 0; | ||
475 | } | ||
476 | EXPORT_SYMBOL(snd_pcm_lib_free_vmalloc_buffer); | ||
477 | |||
478 | /** | ||
479 | * snd_pcm_lib_get_vmalloc_page - map vmalloc buffer offset to page struct | ||
480 | * @substream: the substream with a buffer allocated by | ||
481 | * snd_pcm_lib_alloc_vmalloc_buffer() | ||
482 | * @offset: offset in the buffer | ||
483 | * | ||
484 | * This function is to be used as the page callback in the PCM ops. | ||
485 | */ | ||
486 | struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, | ||
487 | unsigned long offset) | ||
488 | { | ||
489 | return vmalloc_to_page(substream->runtime->dma_area + offset); | ||
490 | } | ||
491 | EXPORT_SYMBOL(snd_pcm_lib_get_vmalloc_page); | ||
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 25b0641e6b8c..872887624030 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/pm_qos_params.h> | 27 | #include <linux/pm_qos_params.h> |
28 | #include <linux/uio.h> | 28 | #include <linux/uio.h> |
29 | #include <linux/dma-mapping.h> | 29 | #include <linux/dma-mapping.h> |
30 | #include <linux/math64.h> | ||
30 | #include <sound/core.h> | 31 | #include <sound/core.h> |
31 | #include <sound/control.h> | 32 | #include <sound/control.h> |
32 | #include <sound/info.h> | 33 | #include <sound/info.h> |
@@ -315,10 +316,10 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream, | |||
315 | if (!params->info) | 316 | if (!params->info) |
316 | params->info = hw->info & ~SNDRV_PCM_INFO_FIFO_IN_FRAMES; | 317 | params->info = hw->info & ~SNDRV_PCM_INFO_FIFO_IN_FRAMES; |
317 | if (!params->fifo_size) { | 318 | if (!params->fifo_size) { |
318 | if (snd_mask_min(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT]) == | 319 | m = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); |
319 | snd_mask_max(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT]) && | 320 | i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); |
320 | snd_mask_min(¶ms->masks[SNDRV_PCM_HW_PARAM_CHANNELS]) == | 321 | if (snd_mask_min(m) == snd_mask_max(m) && |
321 | snd_mask_max(¶ms->masks[SNDRV_PCM_HW_PARAM_CHANNELS])) { | 322 | snd_interval_min(i) == snd_interval_max(i)) { |
322 | changed = substream->ops->ioctl(substream, | 323 | changed = substream->ops->ioctl(substream, |
323 | SNDRV_PCM_IOCTL1_FIFO_SIZE, params); | 324 | SNDRV_PCM_IOCTL1_FIFO_SIZE, params); |
324 | if (changed < 0) | 325 | if (changed < 0) |
@@ -366,6 +367,38 @@ static int period_to_usecs(struct snd_pcm_runtime *runtime) | |||
366 | return usecs; | 367 | return usecs; |
367 | } | 368 | } |
368 | 369 | ||
370 | static int calc_boundary(struct snd_pcm_runtime *runtime) | ||
371 | { | ||
372 | u_int64_t boundary; | ||
373 | |||
374 | boundary = (u_int64_t)runtime->buffer_size * | ||
375 | (u_int64_t)runtime->period_size; | ||
376 | #if BITS_PER_LONG < 64 | ||
377 | /* try to find lowest common multiple for buffer and period */ | ||
378 | if (boundary > LONG_MAX - runtime->buffer_size) { | ||
379 | u_int32_t remainder = -1; | ||
380 | u_int32_t divident = runtime->buffer_size; | ||
381 | u_int32_t divisor = runtime->period_size; | ||
382 | while (remainder) { | ||
383 | remainder = divident % divisor; | ||
384 | if (remainder) { | ||
385 | divident = divisor; | ||
386 | divisor = remainder; | ||
387 | } | ||
388 | } | ||
389 | boundary = div_u64(boundary, divisor); | ||
390 | if (boundary > LONG_MAX - runtime->buffer_size) | ||
391 | return -ERANGE; | ||
392 | } | ||
393 | #endif | ||
394 | if (boundary == 0) | ||
395 | return -ERANGE; | ||
396 | runtime->boundary = boundary; | ||
397 | while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) | ||
398 | runtime->boundary *= 2; | ||
399 | return 0; | ||
400 | } | ||
401 | |||
369 | static int snd_pcm_hw_params(struct snd_pcm_substream *substream, | 402 | static int snd_pcm_hw_params(struct snd_pcm_substream *substream, |
370 | struct snd_pcm_hw_params *params) | 403 | struct snd_pcm_hw_params *params) |
371 | { | 404 | { |
@@ -441,9 +474,9 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream, | |||
441 | runtime->stop_threshold = runtime->buffer_size; | 474 | runtime->stop_threshold = runtime->buffer_size; |
442 | runtime->silence_threshold = 0; | 475 | runtime->silence_threshold = 0; |
443 | runtime->silence_size = 0; | 476 | runtime->silence_size = 0; |
444 | runtime->boundary = runtime->buffer_size; | 477 | err = calc_boundary(runtime); |
445 | while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) | 478 | if (err < 0) |
446 | runtime->boundary *= 2; | 479 | goto _error; |
447 | 480 | ||
448 | snd_pcm_timer_resolution_change(substream); | 481 | snd_pcm_timer_resolution_change(substream); |
449 | runtime->status->state = SNDRV_PCM_STATE_SETUP; | 482 | runtime->status->state = SNDRV_PCM_STATE_SETUP; |
@@ -516,6 +549,7 @@ static int snd_pcm_sw_params(struct snd_pcm_substream *substream, | |||
516 | struct snd_pcm_sw_params *params) | 549 | struct snd_pcm_sw_params *params) |
517 | { | 550 | { |
518 | struct snd_pcm_runtime *runtime; | 551 | struct snd_pcm_runtime *runtime; |
552 | int err; | ||
519 | 553 | ||
520 | if (PCM_RUNTIME_CHECK(substream)) | 554 | if (PCM_RUNTIME_CHECK(substream)) |
521 | return -ENXIO; | 555 | return -ENXIO; |
@@ -540,6 +574,7 @@ static int snd_pcm_sw_params(struct snd_pcm_substream *substream, | |||
540 | if (params->silence_threshold > runtime->buffer_size) | 574 | if (params->silence_threshold > runtime->buffer_size) |
541 | return -EINVAL; | 575 | return -EINVAL; |
542 | } | 576 | } |
577 | err = 0; | ||
543 | snd_pcm_stream_lock_irq(substream); | 578 | snd_pcm_stream_lock_irq(substream); |
544 | runtime->tstamp_mode = params->tstamp_mode; | 579 | runtime->tstamp_mode = params->tstamp_mode; |
545 | runtime->period_step = params->period_step; | 580 | runtime->period_step = params->period_step; |
@@ -553,10 +588,10 @@ static int snd_pcm_sw_params(struct snd_pcm_substream *substream, | |||
553 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && | 588 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && |
554 | runtime->silence_size > 0) | 589 | runtime->silence_size > 0) |
555 | snd_pcm_playback_silence(substream, ULONG_MAX); | 590 | snd_pcm_playback_silence(substream, ULONG_MAX); |
556 | wake_up(&runtime->sleep); | 591 | err = snd_pcm_update_state(substream, runtime); |
557 | } | 592 | } |
558 | snd_pcm_stream_unlock_irq(substream); | 593 | snd_pcm_stream_unlock_irq(substream); |
559 | return 0; | 594 | return err; |
560 | } | 595 | } |
561 | 596 | ||
562 | static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, | 597 | static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, |
@@ -917,6 +952,7 @@ static void snd_pcm_post_stop(struct snd_pcm_substream *substream, int state) | |||
917 | runtime->status->state = state; | 952 | runtime->status->state = state; |
918 | } | 953 | } |
919 | wake_up(&runtime->sleep); | 954 | wake_up(&runtime->sleep); |
955 | wake_up(&runtime->tsleep); | ||
920 | } | 956 | } |
921 | 957 | ||
922 | static struct action_ops snd_pcm_action_stop = { | 958 | static struct action_ops snd_pcm_action_stop = { |
@@ -1002,6 +1038,7 @@ static void snd_pcm_post_pause(struct snd_pcm_substream *substream, int push) | |||
1002 | SNDRV_TIMER_EVENT_MPAUSE, | 1038 | SNDRV_TIMER_EVENT_MPAUSE, |
1003 | &runtime->trigger_tstamp); | 1039 | &runtime->trigger_tstamp); |
1004 | wake_up(&runtime->sleep); | 1040 | wake_up(&runtime->sleep); |
1041 | wake_up(&runtime->tsleep); | ||
1005 | } else { | 1042 | } else { |
1006 | runtime->status->state = SNDRV_PCM_STATE_RUNNING; | 1043 | runtime->status->state = SNDRV_PCM_STATE_RUNNING; |
1007 | if (substream->timer) | 1044 | if (substream->timer) |
@@ -1059,6 +1096,7 @@ static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, int state) | |||
1059 | runtime->status->suspended_state = runtime->status->state; | 1096 | runtime->status->suspended_state = runtime->status->state; |
1060 | runtime->status->state = SNDRV_PCM_STATE_SUSPENDED; | 1097 | runtime->status->state = SNDRV_PCM_STATE_SUSPENDED; |
1061 | wake_up(&runtime->sleep); | 1098 | wake_up(&runtime->sleep); |
1099 | wake_up(&runtime->tsleep); | ||
1062 | } | 1100 | } |
1063 | 1101 | ||
1064 | static struct action_ops snd_pcm_action_suspend = { | 1102 | static struct action_ops snd_pcm_action_suspend = { |
@@ -3162,9 +3200,7 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, | |||
3162 | long size; | 3200 | long size; |
3163 | unsigned long offset; | 3201 | unsigned long offset; |
3164 | 3202 | ||
3165 | #ifdef pgprot_noncached | ||
3166 | area->vm_page_prot = pgprot_noncached(area->vm_page_prot); | 3203 | area->vm_page_prot = pgprot_noncached(area->vm_page_prot); |
3167 | #endif | ||
3168 | area->vm_flags |= VM_IO; | 3204 | area->vm_flags |= VM_IO; |
3169 | size = area->vm_end - area->vm_start; | 3205 | size = area->vm_end - area->vm_start; |
3170 | offset = area->vm_pgoff << PAGE_SHIFT; | 3206 | offset = area->vm_pgoff << PAGE_SHIFT; |
@@ -3178,6 +3214,15 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, | |||
3178 | EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem); | 3214 | EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem); |
3179 | #endif /* SNDRV_PCM_INFO_MMAP */ | 3215 | #endif /* SNDRV_PCM_INFO_MMAP */ |
3180 | 3216 | ||
3217 | /* mmap callback with pgprot_noncached */ | ||
3218 | int snd_pcm_lib_mmap_noncached(struct snd_pcm_substream *substream, | ||
3219 | struct vm_area_struct *area) | ||
3220 | { | ||
3221 | area->vm_page_prot = pgprot_noncached(area->vm_page_prot); | ||
3222 | return snd_pcm_default_mmap(substream, area); | ||
3223 | } | ||
3224 | EXPORT_SYMBOL(snd_pcm_lib_mmap_noncached); | ||
3225 | |||
3181 | /* | 3226 | /* |
3182 | * mmap DMA buffer | 3227 | * mmap DMA buffer |
3183 | */ | 3228 | */ |
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 8ca2be339f3b..48eca9ff9ee7 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c | |||
@@ -2190,7 +2190,7 @@ static int snd_seq_do_ioctl(struct snd_seq_client *client, unsigned int cmd, | |||
2190 | if (p->cmd == cmd) | 2190 | if (p->cmd == cmd) |
2191 | return p->func(client, arg); | 2191 | return p->func(client, arg); |
2192 | } | 2192 | } |
2193 | snd_printd("seq unknown ioctl() 0x%x (type='%c', number=0x%2x)\n", | 2193 | snd_printd("seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n", |
2194 | cmd, _IOC_TYPE(cmd), _IOC_NR(cmd)); | 2194 | cmd, _IOC_TYPE(cmd), _IOC_NR(cmd)); |
2195 | return -ENOTTY; | 2195 | return -ENOTTY; |
2196 | } | 2196 | } |
diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c index f745c317d6af..160b1bd0cd62 100644 --- a/sound/core/seq/seq_timer.c +++ b/sound/core/seq/seq_timer.c | |||
@@ -33,22 +33,21 @@ | |||
33 | 33 | ||
34 | #define SKEW_BASE 0x10000 /* 16bit shift */ | 34 | #define SKEW_BASE 0x10000 /* 16bit shift */ |
35 | 35 | ||
36 | static void snd_seq_timer_set_tick_resolution(struct snd_seq_timer_tick *tick, | 36 | static void snd_seq_timer_set_tick_resolution(struct snd_seq_timer *tmr) |
37 | int tempo, int ppq) | ||
38 | { | 37 | { |
39 | if (tempo < 1000000) | 38 | if (tmr->tempo < 1000000) |
40 | tick->resolution = (tempo * 1000) / ppq; | 39 | tmr->tick.resolution = (tmr->tempo * 1000) / tmr->ppq; |
41 | else { | 40 | else { |
42 | /* might overflow.. */ | 41 | /* might overflow.. */ |
43 | unsigned int s; | 42 | unsigned int s; |
44 | s = tempo % ppq; | 43 | s = tmr->tempo % tmr->ppq; |
45 | s = (s * 1000) / ppq; | 44 | s = (s * 1000) / tmr->ppq; |
46 | tick->resolution = (tempo / ppq) * 1000; | 45 | tmr->tick.resolution = (tmr->tempo / tmr->ppq) * 1000; |
47 | tick->resolution += s; | 46 | tmr->tick.resolution += s; |
48 | } | 47 | } |
49 | if (tick->resolution <= 0) | 48 | if (tmr->tick.resolution <= 0) |
50 | tick->resolution = 1; | 49 | tmr->tick.resolution = 1; |
51 | snd_seq_timer_update_tick(tick, 0); | 50 | snd_seq_timer_update_tick(&tmr->tick, 0); |
52 | } | 51 | } |
53 | 52 | ||
54 | /* create new timer (constructor) */ | 53 | /* create new timer (constructor) */ |
@@ -96,7 +95,7 @@ void snd_seq_timer_defaults(struct snd_seq_timer * tmr) | |||
96 | /* setup defaults */ | 95 | /* setup defaults */ |
97 | tmr->ppq = 96; /* 96 PPQ */ | 96 | tmr->ppq = 96; /* 96 PPQ */ |
98 | tmr->tempo = 500000; /* 120 BPM */ | 97 | tmr->tempo = 500000; /* 120 BPM */ |
99 | snd_seq_timer_set_tick_resolution(&tmr->tick, tmr->tempo, tmr->ppq); | 98 | snd_seq_timer_set_tick_resolution(tmr); |
100 | tmr->running = 0; | 99 | tmr->running = 0; |
101 | 100 | ||
102 | tmr->type = SNDRV_SEQ_TIMER_ALSA; | 101 | tmr->type = SNDRV_SEQ_TIMER_ALSA; |
@@ -180,7 +179,7 @@ int snd_seq_timer_set_tempo(struct snd_seq_timer * tmr, int tempo) | |||
180 | spin_lock_irqsave(&tmr->lock, flags); | 179 | spin_lock_irqsave(&tmr->lock, flags); |
181 | if ((unsigned int)tempo != tmr->tempo) { | 180 | if ((unsigned int)tempo != tmr->tempo) { |
182 | tmr->tempo = tempo; | 181 | tmr->tempo = tempo; |
183 | snd_seq_timer_set_tick_resolution(&tmr->tick, tmr->tempo, tmr->ppq); | 182 | snd_seq_timer_set_tick_resolution(tmr); |
184 | } | 183 | } |
185 | spin_unlock_irqrestore(&tmr->lock, flags); | 184 | spin_unlock_irqrestore(&tmr->lock, flags); |
186 | return 0; | 185 | return 0; |
@@ -205,7 +204,7 @@ int snd_seq_timer_set_ppq(struct snd_seq_timer * tmr, int ppq) | |||
205 | } | 204 | } |
206 | 205 | ||
207 | tmr->ppq = ppq; | 206 | tmr->ppq = ppq; |
208 | snd_seq_timer_set_tick_resolution(&tmr->tick, tmr->tempo, tmr->ppq); | 207 | snd_seq_timer_set_tick_resolution(tmr); |
209 | spin_unlock_irqrestore(&tmr->lock, flags); | 208 | spin_unlock_irqrestore(&tmr->lock, flags); |
210 | return 0; | 209 | return 0; |
211 | } | 210 | } |
diff --git a/sound/core/timer.c b/sound/core/timer.c index 8f8b17ac074d..73943651caed 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c | |||
@@ -393,7 +393,7 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event) | |||
393 | event == SNDRV_TIMER_EVENT_CONTINUE) | 393 | event == SNDRV_TIMER_EVENT_CONTINUE) |
394 | resolution = snd_timer_resolution(ti); | 394 | resolution = snd_timer_resolution(ti); |
395 | if (ti->ccallback) | 395 | if (ti->ccallback) |
396 | ti->ccallback(ti, SNDRV_TIMER_EVENT_START, &tstamp, resolution); | 396 | ti->ccallback(ti, event, &tstamp, resolution); |
397 | if (ti->flags & SNDRV_TIMER_IFLG_SLAVE) | 397 | if (ti->flags & SNDRV_TIMER_IFLG_SLAVE) |
398 | return; | 398 | return; |
399 | timer = ti->timer; | 399 | timer = ti->timer; |
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 252e04ce602f..7f41990ed68b 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c | |||
@@ -45,109 +45,23 @@ MODULE_SUPPORTED_DEVICE("{{ALSA,Dummy soundcard}}"); | |||
45 | #define MAX_PCM_SUBSTREAMS 128 | 45 | #define MAX_PCM_SUBSTREAMS 128 |
46 | #define MAX_MIDI_DEVICES 2 | 46 | #define MAX_MIDI_DEVICES 2 |
47 | 47 | ||
48 | #if 0 /* emu10k1 emulation */ | ||
49 | #define MAX_BUFFER_SIZE (128 * 1024) | ||
50 | static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime) | ||
51 | { | ||
52 | int err; | ||
53 | err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); | ||
54 | if (err < 0) | ||
55 | return err; | ||
56 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX); | ||
57 | if (err < 0) | ||
58 | return err; | ||
59 | return 0; | ||
60 | } | ||
61 | #define add_playback_constraints emu10k1_playback_constraints | ||
62 | #endif | ||
63 | |||
64 | #if 0 /* RME9652 emulation */ | ||
65 | #define MAX_BUFFER_SIZE (26 * 64 * 1024) | ||
66 | #define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE | ||
67 | #define USE_CHANNELS_MIN 26 | ||
68 | #define USE_CHANNELS_MAX 26 | ||
69 | #define USE_PERIODS_MIN 2 | ||
70 | #define USE_PERIODS_MAX 2 | ||
71 | #endif | ||
72 | |||
73 | #if 0 /* ICE1712 emulation */ | ||
74 | #define MAX_BUFFER_SIZE (256 * 1024) | ||
75 | #define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE | ||
76 | #define USE_CHANNELS_MIN 10 | ||
77 | #define USE_CHANNELS_MAX 10 | ||
78 | #define USE_PERIODS_MIN 1 | ||
79 | #define USE_PERIODS_MAX 1024 | ||
80 | #endif | ||
81 | |||
82 | #if 0 /* UDA1341 emulation */ | ||
83 | #define MAX_BUFFER_SIZE (16380) | ||
84 | #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE | ||
85 | #define USE_CHANNELS_MIN 2 | ||
86 | #define USE_CHANNELS_MAX 2 | ||
87 | #define USE_PERIODS_MIN 2 | ||
88 | #define USE_PERIODS_MAX 255 | ||
89 | #endif | ||
90 | |||
91 | #if 0 /* simple AC97 bridge (intel8x0) with 48kHz AC97 only codec */ | ||
92 | #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE | ||
93 | #define USE_CHANNELS_MIN 2 | ||
94 | #define USE_CHANNELS_MAX 2 | ||
95 | #define USE_RATE SNDRV_PCM_RATE_48000 | ||
96 | #define USE_RATE_MIN 48000 | ||
97 | #define USE_RATE_MAX 48000 | ||
98 | #endif | ||
99 | |||
100 | #if 0 /* CA0106 */ | ||
101 | #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE | ||
102 | #define USE_CHANNELS_MIN 2 | ||
103 | #define USE_CHANNELS_MAX 2 | ||
104 | #define USE_RATE (SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_96000|SNDRV_PCM_RATE_192000) | ||
105 | #define USE_RATE_MIN 48000 | ||
106 | #define USE_RATE_MAX 192000 | ||
107 | #define MAX_BUFFER_SIZE ((65536-64)*8) | ||
108 | #define MAX_PERIOD_SIZE (65536-64) | ||
109 | #define USE_PERIODS_MIN 2 | ||
110 | #define USE_PERIODS_MAX 8 | ||
111 | #endif | ||
112 | |||
113 | |||
114 | /* defaults */ | 48 | /* defaults */ |
115 | #ifndef MAX_BUFFER_SIZE | ||
116 | #define MAX_BUFFER_SIZE (64*1024) | 49 | #define MAX_BUFFER_SIZE (64*1024) |
117 | #endif | 50 | #define MIN_PERIOD_SIZE 64 |
118 | #ifndef MAX_PERIOD_SIZE | ||
119 | #define MAX_PERIOD_SIZE MAX_BUFFER_SIZE | 51 | #define MAX_PERIOD_SIZE MAX_BUFFER_SIZE |
120 | #endif | ||
121 | #ifndef USE_FORMATS | ||
122 | #define USE_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE) | 52 | #define USE_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE) |
123 | #endif | ||
124 | #ifndef USE_RATE | ||
125 | #define USE_RATE SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000 | 53 | #define USE_RATE SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000 |
126 | #define USE_RATE_MIN 5500 | 54 | #define USE_RATE_MIN 5500 |
127 | #define USE_RATE_MAX 48000 | 55 | #define USE_RATE_MAX 48000 |
128 | #endif | ||
129 | #ifndef USE_CHANNELS_MIN | ||
130 | #define USE_CHANNELS_MIN 1 | 56 | #define USE_CHANNELS_MIN 1 |
131 | #endif | ||
132 | #ifndef USE_CHANNELS_MAX | ||
133 | #define USE_CHANNELS_MAX 2 | 57 | #define USE_CHANNELS_MAX 2 |
134 | #endif | ||
135 | #ifndef USE_PERIODS_MIN | ||
136 | #define USE_PERIODS_MIN 1 | 58 | #define USE_PERIODS_MIN 1 |
137 | #endif | ||
138 | #ifndef USE_PERIODS_MAX | ||
139 | #define USE_PERIODS_MAX 1024 | 59 | #define USE_PERIODS_MAX 1024 |
140 | #endif | ||
141 | #ifndef add_playback_constraints | ||
142 | #define add_playback_constraints(x) 0 | ||
143 | #endif | ||
144 | #ifndef add_capture_constraints | ||
145 | #define add_capture_constraints(x) 0 | ||
146 | #endif | ||
147 | 60 | ||
148 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | 61 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
149 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 62 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
150 | static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; | 63 | static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; |
64 | static char *model[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = NULL}; | ||
151 | static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; | 65 | static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; |
152 | static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8}; | 66 | static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8}; |
153 | //static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; | 67 | //static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; |
@@ -162,6 +76,8 @@ module_param_array(id, charp, NULL, 0444); | |||
162 | MODULE_PARM_DESC(id, "ID string for dummy soundcard."); | 76 | MODULE_PARM_DESC(id, "ID string for dummy soundcard."); |
163 | module_param_array(enable, bool, NULL, 0444); | 77 | module_param_array(enable, bool, NULL, 0444); |
164 | MODULE_PARM_DESC(enable, "Enable this dummy soundcard."); | 78 | MODULE_PARM_DESC(enable, "Enable this dummy soundcard."); |
79 | module_param_array(model, charp, NULL, 0444); | ||
80 | MODULE_PARM_DESC(model, "Soundcard model."); | ||
165 | module_param_array(pcm_devs, int, NULL, 0444); | 81 | module_param_array(pcm_devs, int, NULL, 0444); |
166 | MODULE_PARM_DESC(pcm_devs, "PCM devices # (0-4) for dummy driver."); | 82 | MODULE_PARM_DESC(pcm_devs, "PCM devices # (0-4) for dummy driver."); |
167 | module_param_array(pcm_substreams, int, NULL, 0444); | 83 | module_param_array(pcm_substreams, int, NULL, 0444); |
@@ -193,9 +109,28 @@ struct dummy_timer_ops { | |||
193 | snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *); | 109 | snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *); |
194 | }; | 110 | }; |
195 | 111 | ||
112 | struct dummy_model { | ||
113 | const char *name; | ||
114 | int (*playback_constraints)(struct snd_pcm_runtime *runtime); | ||
115 | int (*capture_constraints)(struct snd_pcm_runtime *runtime); | ||
116 | u64 formats; | ||
117 | size_t buffer_bytes_max; | ||
118 | size_t period_bytes_min; | ||
119 | size_t period_bytes_max; | ||
120 | unsigned int periods_min; | ||
121 | unsigned int periods_max; | ||
122 | unsigned int rates; | ||
123 | unsigned int rate_min; | ||
124 | unsigned int rate_max; | ||
125 | unsigned int channels_min; | ||
126 | unsigned int channels_max; | ||
127 | }; | ||
128 | |||
196 | struct snd_dummy { | 129 | struct snd_dummy { |
197 | struct snd_card *card; | 130 | struct snd_card *card; |
131 | struct dummy_model *model; | ||
198 | struct snd_pcm *pcm; | 132 | struct snd_pcm *pcm; |
133 | struct snd_pcm_hardware pcm_hw; | ||
199 | spinlock_t mixer_lock; | 134 | spinlock_t mixer_lock; |
200 | int mixer_volume[MIXER_ADDR_LAST+1][2]; | 135 | int mixer_volume[MIXER_ADDR_LAST+1][2]; |
201 | int capture_source[MIXER_ADDR_LAST+1][2]; | 136 | int capture_source[MIXER_ADDR_LAST+1][2]; |
@@ -203,6 +138,92 @@ struct snd_dummy { | |||
203 | }; | 138 | }; |
204 | 139 | ||
205 | /* | 140 | /* |
141 | * card models | ||
142 | */ | ||
143 | |||
144 | static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime) | ||
145 | { | ||
146 | int err; | ||
147 | err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); | ||
148 | if (err < 0) | ||
149 | return err; | ||
150 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX); | ||
151 | if (err < 0) | ||
152 | return err; | ||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | struct dummy_model model_emu10k1 = { | ||
157 | .name = "emu10k1", | ||
158 | .playback_constraints = emu10k1_playback_constraints, | ||
159 | .buffer_bytes_max = 128 * 1024, | ||
160 | }; | ||
161 | |||
162 | struct dummy_model model_rme9652 = { | ||
163 | .name = "rme9652", | ||
164 | .buffer_bytes_max = 26 * 64 * 1024, | ||
165 | .formats = SNDRV_PCM_FMTBIT_S32_LE, | ||
166 | .channels_min = 26, | ||
167 | .channels_max = 26, | ||
168 | .periods_min = 2, | ||
169 | .periods_max = 2, | ||
170 | }; | ||
171 | |||
172 | struct dummy_model model_ice1712 = { | ||
173 | .name = "ice1712", | ||
174 | .buffer_bytes_max = 256 * 1024, | ||
175 | .formats = SNDRV_PCM_FMTBIT_S32_LE, | ||
176 | .channels_min = 10, | ||
177 | .channels_max = 10, | ||
178 | .periods_min = 1, | ||
179 | .periods_max = 1024, | ||
180 | }; | ||
181 | |||
182 | struct dummy_model model_uda1341 = { | ||
183 | .name = "uda1341", | ||
184 | .buffer_bytes_max = 16380, | ||
185 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
186 | .channels_min = 2, | ||
187 | .channels_max = 2, | ||
188 | .periods_min = 2, | ||
189 | .periods_max = 255, | ||
190 | }; | ||
191 | |||
192 | struct dummy_model model_ac97 = { | ||
193 | .name = "ac97", | ||
194 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
195 | .channels_min = 2, | ||
196 | .channels_max = 2, | ||
197 | .rates = SNDRV_PCM_RATE_48000, | ||
198 | .rate_min = 48000, | ||
199 | .rate_max = 48000, | ||
200 | }; | ||
201 | |||
202 | struct dummy_model model_ca0106 = { | ||
203 | .name = "ca0106", | ||
204 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
205 | .buffer_bytes_max = ((65536-64)*8), | ||
206 | .period_bytes_max = (65536-64), | ||
207 | .periods_min = 2, | ||
208 | .periods_max = 8, | ||
209 | .channels_min = 2, | ||
210 | .channels_max = 2, | ||
211 | .rates = SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_96000|SNDRV_PCM_RATE_192000, | ||
212 | .rate_min = 48000, | ||
213 | .rate_max = 192000, | ||
214 | }; | ||
215 | |||
216 | struct dummy_model *dummy_models[] = { | ||
217 | &model_emu10k1, | ||
218 | &model_rme9652, | ||
219 | &model_ice1712, | ||
220 | &model_uda1341, | ||
221 | &model_ac97, | ||
222 | &model_ca0106, | ||
223 | NULL | ||
224 | }; | ||
225 | |||
226 | /* | ||
206 | * system timer interface | 227 | * system timer interface |
207 | */ | 228 | */ |
208 | 229 | ||
@@ -509,7 +530,7 @@ static struct snd_pcm_hardware dummy_pcm_hardware = { | |||
509 | .channels_min = USE_CHANNELS_MIN, | 530 | .channels_min = USE_CHANNELS_MIN, |
510 | .channels_max = USE_CHANNELS_MAX, | 531 | .channels_max = USE_CHANNELS_MAX, |
511 | .buffer_bytes_max = MAX_BUFFER_SIZE, | 532 | .buffer_bytes_max = MAX_BUFFER_SIZE, |
512 | .period_bytes_min = 64, | 533 | .period_bytes_min = MIN_PERIOD_SIZE, |
513 | .period_bytes_max = MAX_PERIOD_SIZE, | 534 | .period_bytes_max = MAX_PERIOD_SIZE, |
514 | .periods_min = USE_PERIODS_MIN, | 535 | .periods_min = USE_PERIODS_MIN, |
515 | .periods_max = USE_PERIODS_MAX, | 536 | .periods_max = USE_PERIODS_MAX, |
@@ -538,6 +559,7 @@ static int dummy_pcm_hw_free(struct snd_pcm_substream *substream) | |||
538 | static int dummy_pcm_open(struct snd_pcm_substream *substream) | 559 | static int dummy_pcm_open(struct snd_pcm_substream *substream) |
539 | { | 560 | { |
540 | struct snd_dummy *dummy = snd_pcm_substream_chip(substream); | 561 | struct snd_dummy *dummy = snd_pcm_substream_chip(substream); |
562 | struct dummy_model *model = dummy->model; | ||
541 | struct snd_pcm_runtime *runtime = substream->runtime; | 563 | struct snd_pcm_runtime *runtime = substream->runtime; |
542 | int err; | 564 | int err; |
543 | 565 | ||
@@ -551,7 +573,7 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream) | |||
551 | if (err < 0) | 573 | if (err < 0) |
552 | return err; | 574 | return err; |
553 | 575 | ||
554 | runtime->hw = dummy_pcm_hardware; | 576 | runtime->hw = dummy->pcm_hw; |
555 | if (substream->pcm->device & 1) { | 577 | if (substream->pcm->device & 1) { |
556 | runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; | 578 | runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; |
557 | runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; | 579 | runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; |
@@ -560,10 +582,16 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream) | |||
560 | runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP | | 582 | runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP | |
561 | SNDRV_PCM_INFO_MMAP_VALID); | 583 | SNDRV_PCM_INFO_MMAP_VALID); |
562 | 584 | ||
563 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 585 | if (model == NULL) |
564 | err = add_playback_constraints(substream->runtime); | 586 | return 0; |
565 | else | 587 | |
566 | err = add_capture_constraints(substream->runtime); | 588 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
589 | if (model->playback_constraints) | ||
590 | err = model->playback_constraints(substream->runtime); | ||
591 | } else { | ||
592 | if (model->capture_constraints) | ||
593 | err = model->capture_constraints(substream->runtime); | ||
594 | } | ||
567 | if (err < 0) { | 595 | if (err < 0) { |
568 | dummy->timer_ops->free(substream); | 596 | dummy->timer_ops->free(substream); |
569 | return err; | 597 | return err; |
@@ -823,17 +851,19 @@ static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy) | |||
823 | /* | 851 | /* |
824 | * proc interface | 852 | * proc interface |
825 | */ | 853 | */ |
826 | static void print_formats(struct snd_info_buffer *buffer) | 854 | static void print_formats(struct snd_dummy *dummy, |
855 | struct snd_info_buffer *buffer) | ||
827 | { | 856 | { |
828 | int i; | 857 | int i; |
829 | 858 | ||
830 | for (i = 0; i < SNDRV_PCM_FORMAT_LAST; i++) { | 859 | for (i = 0; i < SNDRV_PCM_FORMAT_LAST; i++) { |
831 | if (dummy_pcm_hardware.formats & (1ULL << i)) | 860 | if (dummy->pcm_hw.formats & (1ULL << i)) |
832 | snd_iprintf(buffer, " %s", snd_pcm_format_name(i)); | 861 | snd_iprintf(buffer, " %s", snd_pcm_format_name(i)); |
833 | } | 862 | } |
834 | } | 863 | } |
835 | 864 | ||
836 | static void print_rates(struct snd_info_buffer *buffer) | 865 | static void print_rates(struct snd_dummy *dummy, |
866 | struct snd_info_buffer *buffer) | ||
837 | { | 867 | { |
838 | static int rates[] = { | 868 | static int rates[] = { |
839 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, | 869 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, |
@@ -841,19 +871,19 @@ static void print_rates(struct snd_info_buffer *buffer) | |||
841 | }; | 871 | }; |
842 | int i; | 872 | int i; |
843 | 873 | ||
844 | if (dummy_pcm_hardware.rates & SNDRV_PCM_RATE_CONTINUOUS) | 874 | if (dummy->pcm_hw.rates & SNDRV_PCM_RATE_CONTINUOUS) |
845 | snd_iprintf(buffer, " continuous"); | 875 | snd_iprintf(buffer, " continuous"); |
846 | if (dummy_pcm_hardware.rates & SNDRV_PCM_RATE_KNOT) | 876 | if (dummy->pcm_hw.rates & SNDRV_PCM_RATE_KNOT) |
847 | snd_iprintf(buffer, " knot"); | 877 | snd_iprintf(buffer, " knot"); |
848 | for (i = 0; i < ARRAY_SIZE(rates); i++) | 878 | for (i = 0; i < ARRAY_SIZE(rates); i++) |
849 | if (dummy_pcm_hardware.rates & (1 << i)) | 879 | if (dummy->pcm_hw.rates & (1 << i)) |
850 | snd_iprintf(buffer, " %d", rates[i]); | 880 | snd_iprintf(buffer, " %d", rates[i]); |
851 | } | 881 | } |
852 | 882 | ||
853 | #define get_dummy_int_ptr(ofs) \ | 883 | #define get_dummy_int_ptr(dummy, ofs) \ |
854 | (unsigned int *)((char *)&dummy_pcm_hardware + (ofs)) | 884 | (unsigned int *)((char *)&((dummy)->pcm_hw) + (ofs)) |
855 | #define get_dummy_ll_ptr(ofs) \ | 885 | #define get_dummy_ll_ptr(dummy, ofs) \ |
856 | (unsigned long long *)((char *)&dummy_pcm_hardware + (ofs)) | 886 | (unsigned long long *)((char *)&((dummy)->pcm_hw) + (ofs)) |
857 | 887 | ||
858 | struct dummy_hw_field { | 888 | struct dummy_hw_field { |
859 | const char *name; | 889 | const char *name; |
@@ -884,20 +914,21 @@ static struct dummy_hw_field fields[] = { | |||
884 | static void dummy_proc_read(struct snd_info_entry *entry, | 914 | static void dummy_proc_read(struct snd_info_entry *entry, |
885 | struct snd_info_buffer *buffer) | 915 | struct snd_info_buffer *buffer) |
886 | { | 916 | { |
917 | struct snd_dummy *dummy = entry->private_data; | ||
887 | int i; | 918 | int i; |
888 | 919 | ||
889 | for (i = 0; i < ARRAY_SIZE(fields); i++) { | 920 | for (i = 0; i < ARRAY_SIZE(fields); i++) { |
890 | snd_iprintf(buffer, "%s ", fields[i].name); | 921 | snd_iprintf(buffer, "%s ", fields[i].name); |
891 | if (fields[i].size == sizeof(int)) | 922 | if (fields[i].size == sizeof(int)) |
892 | snd_iprintf(buffer, fields[i].format, | 923 | snd_iprintf(buffer, fields[i].format, |
893 | *get_dummy_int_ptr(fields[i].offset)); | 924 | *get_dummy_int_ptr(dummy, fields[i].offset)); |
894 | else | 925 | else |
895 | snd_iprintf(buffer, fields[i].format, | 926 | snd_iprintf(buffer, fields[i].format, |
896 | *get_dummy_ll_ptr(fields[i].offset)); | 927 | *get_dummy_ll_ptr(dummy, fields[i].offset)); |
897 | if (!strcmp(fields[i].name, "formats")) | 928 | if (!strcmp(fields[i].name, "formats")) |
898 | print_formats(buffer); | 929 | print_formats(dummy, buffer); |
899 | else if (!strcmp(fields[i].name, "rates")) | 930 | else if (!strcmp(fields[i].name, "rates")) |
900 | print_rates(buffer); | 931 | print_rates(dummy, buffer); |
901 | snd_iprintf(buffer, "\n"); | 932 | snd_iprintf(buffer, "\n"); |
902 | } | 933 | } |
903 | } | 934 | } |
@@ -905,6 +936,7 @@ static void dummy_proc_read(struct snd_info_entry *entry, | |||
905 | static void dummy_proc_write(struct snd_info_entry *entry, | 936 | static void dummy_proc_write(struct snd_info_entry *entry, |
906 | struct snd_info_buffer *buffer) | 937 | struct snd_info_buffer *buffer) |
907 | { | 938 | { |
939 | struct snd_dummy *dummy = entry->private_data; | ||
908 | char line[64]; | 940 | char line[64]; |
909 | 941 | ||
910 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | 942 | while (!snd_info_get_line(buffer, line, sizeof(line))) { |
@@ -924,9 +956,9 @@ static void dummy_proc_write(struct snd_info_entry *entry, | |||
924 | if (strict_strtoull(item, 0, &val)) | 956 | if (strict_strtoull(item, 0, &val)) |
925 | continue; | 957 | continue; |
926 | if (fields[i].size == sizeof(int)) | 958 | if (fields[i].size == sizeof(int)) |
927 | *get_dummy_int_ptr(fields[i].offset) = val; | 959 | *get_dummy_int_ptr(dummy, fields[i].offset) = val; |
928 | else | 960 | else |
929 | *get_dummy_ll_ptr(fields[i].offset) = val; | 961 | *get_dummy_ll_ptr(dummy, fields[i].offset) = val; |
930 | } | 962 | } |
931 | } | 963 | } |
932 | 964 | ||
@@ -938,6 +970,7 @@ static void __devinit dummy_proc_init(struct snd_dummy *chip) | |||
938 | snd_info_set_text_ops(entry, chip, dummy_proc_read); | 970 | snd_info_set_text_ops(entry, chip, dummy_proc_read); |
939 | entry->c.text.write = dummy_proc_write; | 971 | entry->c.text.write = dummy_proc_write; |
940 | entry->mode |= S_IWUSR; | 972 | entry->mode |= S_IWUSR; |
973 | entry->private_data = chip; | ||
941 | } | 974 | } |
942 | } | 975 | } |
943 | #else | 976 | #else |
@@ -948,6 +981,7 @@ static int __devinit snd_dummy_probe(struct platform_device *devptr) | |||
948 | { | 981 | { |
949 | struct snd_card *card; | 982 | struct snd_card *card; |
950 | struct snd_dummy *dummy; | 983 | struct snd_dummy *dummy; |
984 | struct dummy_model *m = NULL, **mdl; | ||
951 | int idx, err; | 985 | int idx, err; |
952 | int dev = devptr->id; | 986 | int dev = devptr->id; |
953 | 987 | ||
@@ -957,6 +991,15 @@ static int __devinit snd_dummy_probe(struct platform_device *devptr) | |||
957 | return err; | 991 | return err; |
958 | dummy = card->private_data; | 992 | dummy = card->private_data; |
959 | dummy->card = card; | 993 | dummy->card = card; |
994 | for (mdl = dummy_models; *mdl && model[dev]; mdl++) { | ||
995 | if (strcmp(model[dev], (*mdl)->name) == 0) { | ||
996 | printk(KERN_INFO | ||
997 | "snd-dummy: Using model '%s' for card %i\n", | ||
998 | (*mdl)->name, card->number); | ||
999 | m = dummy->model = *mdl; | ||
1000 | break; | ||
1001 | } | ||
1002 | } | ||
960 | for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) { | 1003 | for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) { |
961 | if (pcm_substreams[dev] < 1) | 1004 | if (pcm_substreams[dev] < 1) |
962 | pcm_substreams[dev] = 1; | 1005 | pcm_substreams[dev] = 1; |
@@ -966,6 +1009,33 @@ static int __devinit snd_dummy_probe(struct platform_device *devptr) | |||
966 | if (err < 0) | 1009 | if (err < 0) |
967 | goto __nodev; | 1010 | goto __nodev; |
968 | } | 1011 | } |
1012 | |||
1013 | dummy->pcm_hw = dummy_pcm_hardware; | ||
1014 | if (m) { | ||
1015 | if (m->formats) | ||
1016 | dummy->pcm_hw.formats = m->formats; | ||
1017 | if (m->buffer_bytes_max) | ||
1018 | dummy->pcm_hw.buffer_bytes_max = m->buffer_bytes_max; | ||
1019 | if (m->period_bytes_min) | ||
1020 | dummy->pcm_hw.period_bytes_min = m->period_bytes_min; | ||
1021 | if (m->period_bytes_max) | ||
1022 | dummy->pcm_hw.period_bytes_max = m->period_bytes_max; | ||
1023 | if (m->periods_min) | ||
1024 | dummy->pcm_hw.periods_min = m->periods_min; | ||
1025 | if (m->periods_max) | ||
1026 | dummy->pcm_hw.periods_max = m->periods_max; | ||
1027 | if (m->rates) | ||
1028 | dummy->pcm_hw.rates = m->rates; | ||
1029 | if (m->rate_min) | ||
1030 | dummy->pcm_hw.rate_min = m->rate_min; | ||
1031 | if (m->rate_max) | ||
1032 | dummy->pcm_hw.rate_max = m->rate_max; | ||
1033 | if (m->channels_min) | ||
1034 | dummy->pcm_hw.channels_min = m->channels_min; | ||
1035 | if (m->channels_max) | ||
1036 | dummy->pcm_hw.channels_max = m->channels_max; | ||
1037 | } | ||
1038 | |||
969 | err = snd_card_dummy_new_mixer(dummy); | 1039 | err = snd_card_dummy_new_mixer(dummy); |
970 | if (err < 0) | 1040 | if (err < 0) |
971 | goto __nodev; | 1041 | goto __nodev; |
diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index 6644d0034fba..35a2f71a6af5 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c | |||
@@ -46,7 +46,6 @@ | |||
46 | */ | 46 | */ |
47 | 47 | ||
48 | #include <linux/slab.h> | 48 | #include <linux/slab.h> |
49 | #include <linux/vmalloc.h> | ||
50 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
51 | #include <sound/core.h> | 50 | #include <sound/core.h> |
52 | #include <sound/asoundef.h> | 51 | #include <sound/asoundef.h> |
@@ -56,55 +55,6 @@ | |||
56 | 55 | ||
57 | 56 | ||
58 | /* | 57 | /* |
59 | * we use a vmalloc'ed (sg-)buffer | ||
60 | */ | ||
61 | |||
62 | /* get the physical page pointer on the given offset */ | ||
63 | static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, | ||
64 | unsigned long offset) | ||
65 | { | ||
66 | void *pageptr = subs->runtime->dma_area + offset; | ||
67 | return vmalloc_to_page(pageptr); | ||
68 | } | ||
69 | |||
70 | /* | ||
71 | * allocate a buffer via vmalloc_32(). | ||
72 | * called from hw_params | ||
73 | * NOTE: this may be called not only once per pcm open! | ||
74 | */ | ||
75 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) | ||
76 | { | ||
77 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
78 | if (runtime->dma_area) { | ||
79 | /* already allocated */ | ||
80 | if (runtime->dma_bytes >= size) | ||
81 | return 0; /* already enough large */ | ||
82 | vfree(runtime->dma_area); | ||
83 | } | ||
84 | runtime->dma_area = vmalloc_32(size); | ||
85 | if (! runtime->dma_area) | ||
86 | return -ENOMEM; | ||
87 | memset(runtime->dma_area, 0, size); | ||
88 | runtime->dma_bytes = size; | ||
89 | return 1; /* changed */ | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | * free the buffer. | ||
94 | * called from hw_free callback | ||
95 | * NOTE: this may be called not only once per pcm open! | ||
96 | */ | ||
97 | static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) | ||
98 | { | ||
99 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
100 | |||
101 | vfree(runtime->dma_area); | ||
102 | runtime->dma_area = NULL; | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | |||
107 | /* | ||
108 | * read three pending pcm bytes via inb() | 58 | * read three pending pcm bytes via inb() |
109 | */ | 59 | */ |
110 | static void vx_pcm_read_per_bytes(struct vx_core *chip, struct snd_pcm_runtime *runtime, | 60 | static void vx_pcm_read_per_bytes(struct vx_core *chip, struct snd_pcm_runtime *runtime, |
@@ -865,7 +815,8 @@ static snd_pcm_uframes_t vx_pcm_playback_pointer(struct snd_pcm_substream *subs) | |||
865 | static int vx_pcm_hw_params(struct snd_pcm_substream *subs, | 815 | static int vx_pcm_hw_params(struct snd_pcm_substream *subs, |
866 | struct snd_pcm_hw_params *hw_params) | 816 | struct snd_pcm_hw_params *hw_params) |
867 | { | 817 | { |
868 | return snd_pcm_alloc_vmalloc_buffer(subs, params_buffer_bytes(hw_params)); | 818 | return snd_pcm_lib_alloc_vmalloc_32_buffer |
819 | (subs, params_buffer_bytes(hw_params)); | ||
869 | } | 820 | } |
870 | 821 | ||
871 | /* | 822 | /* |
@@ -873,7 +824,7 @@ static int vx_pcm_hw_params(struct snd_pcm_substream *subs, | |||
873 | */ | 824 | */ |
874 | static int vx_pcm_hw_free(struct snd_pcm_substream *subs) | 825 | static int vx_pcm_hw_free(struct snd_pcm_substream *subs) |
875 | { | 826 | { |
876 | return snd_pcm_free_vmalloc_buffer(subs); | 827 | return snd_pcm_lib_free_vmalloc_buffer(subs); |
877 | } | 828 | } |
878 | 829 | ||
879 | /* | 830 | /* |
@@ -953,7 +904,8 @@ static struct snd_pcm_ops vx_pcm_playback_ops = { | |||
953 | .prepare = vx_pcm_prepare, | 904 | .prepare = vx_pcm_prepare, |
954 | .trigger = vx_pcm_trigger, | 905 | .trigger = vx_pcm_trigger, |
955 | .pointer = vx_pcm_playback_pointer, | 906 | .pointer = vx_pcm_playback_pointer, |
956 | .page = snd_pcm_get_vmalloc_page, | 907 | .page = snd_pcm_lib_get_vmalloc_page, |
908 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
957 | }; | 909 | }; |
958 | 910 | ||
959 | 911 | ||
@@ -1173,7 +1125,8 @@ static struct snd_pcm_ops vx_pcm_capture_ops = { | |||
1173 | .prepare = vx_pcm_prepare, | 1125 | .prepare = vx_pcm_prepare, |
1174 | .trigger = vx_pcm_trigger, | 1126 | .trigger = vx_pcm_trigger, |
1175 | .pointer = vx_pcm_capture_pointer, | 1127 | .pointer = vx_pcm_capture_pointer, |
1176 | .page = snd_pcm_get_vmalloc_page, | 1128 | .page = snd_pcm_lib_get_vmalloc_page, |
1129 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
1177 | }; | 1130 | }; |
1178 | 1131 | ||
1179 | 1132 | ||
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 02fe81ca88fd..755a0a5f0e3f 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig | |||
@@ -63,15 +63,16 @@ config SND_AD1848 | |||
63 | will be called snd-ad1848. | 63 | will be called snd-ad1848. |
64 | 64 | ||
65 | config SND_ALS100 | 65 | config SND_ALS100 |
66 | tristate "Avance Logic ALS100/ALS120" | 66 | tristate "Diamond Tech. DT-019x and Avance Logic ALSxxx" |
67 | depends on PNP | 67 | depends on PNP |
68 | select ISAPNP | 68 | select ISAPNP |
69 | select SND_OPL3_LIB | 69 | select SND_OPL3_LIB |
70 | select SND_MPU401_UART | 70 | select SND_MPU401_UART |
71 | select SND_SB16_DSP | 71 | select SND_SB16_DSP |
72 | help | 72 | help |
73 | Say Y here to include support for soundcards based on Avance | 73 | Say Y here to include support for soundcards based on the |
74 | Logic ALS100, ALS110, ALS120 and ALS200 chips. | 74 | Diamond Technologies DT-019X or Avance Logic chips: ALS007, |
75 | ALS100, ALS110, ALS120 and ALS200 chips. | ||
75 | 76 | ||
76 | To compile this driver as a module, choose M here: the module | 77 | To compile this driver as a module, choose M here: the module |
77 | will be called snd-als100. | 78 | will be called snd-als100. |
@@ -127,20 +128,6 @@ config SND_CS4236 | |||
127 | To compile this driver as a module, choose M here: the module | 128 | To compile this driver as a module, choose M here: the module |
128 | will be called snd-cs4236. | 129 | will be called snd-cs4236. |
129 | 130 | ||
130 | config SND_DT019X | ||
131 | tristate "Diamond Technologies DT-019X, Avance Logic ALS-007" | ||
132 | depends on PNP | ||
133 | select ISAPNP | ||
134 | select SND_OPL3_LIB | ||
135 | select SND_MPU401_UART | ||
136 | select SND_SB16_DSP | ||
137 | help | ||
138 | Say Y here to include support for soundcards based on the | ||
139 | Diamond Technologies DT-019X or Avance Logic ALS-007 chips. | ||
140 | |||
141 | To compile this driver as a module, choose M here: the module | ||
142 | will be called snd-dt019x. | ||
143 | |||
144 | config SND_ES968 | 131 | config SND_ES968 |
145 | tristate "Generic ESS ES968 driver" | 132 | tristate "Generic ESS ES968 driver" |
146 | depends on PNP | 133 | depends on PNP |
@@ -252,6 +239,22 @@ config SND_INTERWAVE_STB | |||
252 | To compile this driver as a module, choose M here: the module | 239 | To compile this driver as a module, choose M here: the module |
253 | will be called snd-interwave-stb. | 240 | will be called snd-interwave-stb. |
254 | 241 | ||
242 | config SND_JAZZ16 | ||
243 | tristate "Media Vision Jazz16 card and compatibles" | ||
244 | select SND_OPL3_LIB | ||
245 | select SND_MPU401_UART | ||
246 | select SND_SB8_DSP | ||
247 | help | ||
248 | Say Y here to include support for soundcards based on the | ||
249 | Media Vision Jazz16 chipset: digital chip MVD1216 (Jazz16), | ||
250 | codec MVA416 (CS4216) and mixer MVA514 (ICS2514). | ||
251 | Media Vision's Jazz16 cards were sold under names Pro Sonic 16, | ||
252 | Premium 3-D and Pro 3-D. There were also OEMs cards with the | ||
253 | Jazz16 chipset. | ||
254 | |||
255 | To compile this driver as a module, choose M here: the module | ||
256 | will be called snd-jazz16. | ||
257 | |||
255 | config SND_OPL3SA2 | 258 | config SND_OPL3SA2 |
256 | tristate "Yamaha OPL3-SA2/SA3" | 259 | tristate "Yamaha OPL3-SA2/SA3" |
257 | select SND_OPL3_LIB | 260 | select SND_OPL3_LIB |
diff --git a/sound/isa/Makefile b/sound/isa/Makefile index b906b9a1a81e..c73d30c4f462 100644 --- a/sound/isa/Makefile +++ b/sound/isa/Makefile | |||
@@ -7,7 +7,6 @@ snd-adlib-objs := adlib.o | |||
7 | snd-als100-objs := als100.o | 7 | snd-als100-objs := als100.o |
8 | snd-azt2320-objs := azt2320.o | 8 | snd-azt2320-objs := azt2320.o |
9 | snd-cmi8330-objs := cmi8330.o | 9 | snd-cmi8330-objs := cmi8330.o |
10 | snd-dt019x-objs := dt019x.o | ||
11 | snd-es18xx-objs := es18xx.o | 10 | snd-es18xx-objs := es18xx.o |
12 | snd-opl3sa2-objs := opl3sa2.o | 11 | snd-opl3sa2-objs := opl3sa2.o |
13 | snd-sc6000-objs := sc6000.o | 12 | snd-sc6000-objs := sc6000.o |
@@ -19,7 +18,6 @@ obj-$(CONFIG_SND_ADLIB) += snd-adlib.o | |||
19 | obj-$(CONFIG_SND_ALS100) += snd-als100.o | 18 | obj-$(CONFIG_SND_ALS100) += snd-als100.o |
20 | obj-$(CONFIG_SND_AZT2320) += snd-azt2320.o | 19 | obj-$(CONFIG_SND_AZT2320) += snd-azt2320.o |
21 | obj-$(CONFIG_SND_CMI8330) += snd-cmi8330.o | 20 | obj-$(CONFIG_SND_CMI8330) += snd-cmi8330.o |
22 | obj-$(CONFIG_SND_DT019X) += snd-dt019x.o | ||
23 | obj-$(CONFIG_SND_ES18XX) += snd-es18xx.o | 21 | obj-$(CONFIG_SND_ES18XX) += snd-es18xx.o |
24 | obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o | 22 | obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o |
25 | obj-$(CONFIG_SND_SC6000) += snd-sc6000.o | 23 | obj-$(CONFIG_SND_SC6000) += snd-sc6000.o |
diff --git a/sound/isa/als100.c b/sound/isa/als100.c index 5fd52e4d7079..20becc89f6f6 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c | |||
@@ -2,9 +2,13 @@ | |||
2 | /* | 2 | /* |
3 | card-als100.c - driver for Avance Logic ALS100 based soundcards. | 3 | card-als100.c - driver for Avance Logic ALS100 based soundcards. |
4 | Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it> | 4 | Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it> |
5 | Copyright (C) 1999-2002 by Massimo Piccioni <dafastidio@libero.it> | ||
5 | 6 | ||
6 | Thanks to Pierfrancesco 'qM2' Passerini. | 7 | Thanks to Pierfrancesco 'qM2' Passerini. |
7 | 8 | ||
9 | Generalised for soundcards based on DT-0196 and ALS-007 chips | ||
10 | by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>: June 2002. | ||
11 | |||
8 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 13 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 14 | the Free Software Foundation; either version 2 of the License, or |
@@ -33,10 +37,10 @@ | |||
33 | 37 | ||
34 | #define PFX "als100: " | 38 | #define PFX "als100: " |
35 | 39 | ||
36 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); | 40 | MODULE_DESCRIPTION("Avance Logic ALS007/ALS1X0"); |
37 | MODULE_DESCRIPTION("Avance Logic ALS1X0"); | 41 | MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X}," |
38 | MODULE_LICENSE("GPL"); | 42 | "{Avance Logic ALS-007}}" |
39 | MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS100 - PRO16PNP}," | 43 | "{{Avance Logic,ALS100 - PRO16PNP}," |
40 | "{Avance Logic,ALS110}," | 44 | "{Avance Logic,ALS110}," |
41 | "{Avance Logic,ALS120}," | 45 | "{Avance Logic,ALS120}," |
42 | "{Avance Logic,ALS200}," | 46 | "{Avance Logic,ALS200}," |
@@ -45,9 +49,12 @@ MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS100 - PRO16PNP}," | |||
45 | "{Avance Logic,ALS120}," | 49 | "{Avance Logic,ALS120}," |
46 | "{RTL,RTL3000}}"); | 50 | "{RTL,RTL3000}}"); |
47 | 51 | ||
52 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); | ||
53 | MODULE_LICENSE("GPL"); | ||
54 | |||
48 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | 55 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
49 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 56 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
50 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ | 57 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ |
51 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 58 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
52 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 59 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
53 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 60 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
@@ -57,14 +64,15 @@ static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ | |||
57 | static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ | 64 | static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ |
58 | 65 | ||
59 | module_param_array(index, int, NULL, 0444); | 66 | module_param_array(index, int, NULL, 0444); |
60 | MODULE_PARM_DESC(index, "Index value for als100 based soundcard."); | 67 | MODULE_PARM_DESC(index, "Index value for Avance Logic based soundcard."); |
61 | module_param_array(id, charp, NULL, 0444); | 68 | module_param_array(id, charp, NULL, 0444); |
62 | MODULE_PARM_DESC(id, "ID string for als100 based soundcard."); | 69 | MODULE_PARM_DESC(id, "ID string for Avance Logic based soundcard."); |
63 | module_param_array(enable, bool, NULL, 0444); | 70 | module_param_array(enable, bool, NULL, 0444); |
64 | MODULE_PARM_DESC(enable, "Enable als100 based soundcard."); | 71 | MODULE_PARM_DESC(enable, "Enable Avance Logic based soundcard."); |
72 | |||
73 | MODULE_ALIAS("snd-dt019x"); | ||
65 | 74 | ||
66 | struct snd_card_als100 { | 75 | struct snd_card_als100 { |
67 | int dev_no; | ||
68 | struct pnp_dev *dev; | 76 | struct pnp_dev *dev; |
69 | struct pnp_dev *devmpu; | 77 | struct pnp_dev *devmpu; |
70 | struct pnp_dev *devopl; | 78 | struct pnp_dev *devopl; |
@@ -72,25 +80,43 @@ struct snd_card_als100 { | |||
72 | }; | 80 | }; |
73 | 81 | ||
74 | static struct pnp_card_device_id snd_als100_pnpids[] = { | 82 | static struct pnp_card_device_id snd_als100_pnpids[] = { |
83 | /* DT197A30 */ | ||
84 | { .id = "RWB1688", | ||
85 | .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, | ||
86 | .driver_data = SB_HW_DT019X }, | ||
87 | /* DT0196 / ALS-007 */ | ||
88 | { .id = "ALS0007", | ||
89 | .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, | ||
90 | .driver_data = SB_HW_DT019X }, | ||
75 | /* ALS100 - PRO16PNP */ | 91 | /* ALS100 - PRO16PNP */ |
76 | { .id = "ALS0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } } }, | 92 | { .id = "ALS0001", |
93 | .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, | ||
94 | .driver_data = SB_HW_ALS100 }, | ||
77 | /* ALS110 - MF1000 - Digimate 3D Sound */ | 95 | /* ALS110 - MF1000 - Digimate 3D Sound */ |
78 | { .id = "ALS0110", .devs = { { "@@@1001" }, { "@X@1001" }, { "@H@1001" } } }, | 96 | { .id = "ALS0110", |
97 | .devs = { { "@@@1001" }, { "@X@1001" }, { "@H@1001" } }, | ||
98 | .driver_data = SB_HW_ALS100 }, | ||
79 | /* ALS120 */ | 99 | /* ALS120 */ |
80 | { .id = "ALS0120", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } }, | 100 | { .id = "ALS0120", |
101 | .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } }, | ||
102 | .driver_data = SB_HW_ALS100 }, | ||
81 | /* ALS200 */ | 103 | /* ALS200 */ |
82 | { .id = "ALS0200", .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0001" } } }, | 104 | { .id = "ALS0200", |
105 | .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0001" } }, | ||
106 | .driver_data = SB_HW_ALS100 }, | ||
83 | /* ALS200 OEM */ | 107 | /* ALS200 OEM */ |
84 | { .id = "ALS0200", .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0020" } } }, | 108 | { .id = "ALS0200", |
109 | .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0020" } }, | ||
110 | .driver_data = SB_HW_ALS100 }, | ||
85 | /* RTL3000 */ | 111 | /* RTL3000 */ |
86 | { .id = "RTL3000", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } }, | 112 | { .id = "RTL3000", |
87 | { .id = "", } /* end */ | 113 | .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } }, |
114 | .driver_data = SB_HW_ALS100 }, | ||
115 | { .id = "" } /* end */ | ||
88 | }; | 116 | }; |
89 | 117 | ||
90 | MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids); | 118 | MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids); |
91 | 119 | ||
92 | #define DRIVER_NAME "snd-card-als100" | ||
93 | |||
94 | static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, | 120 | static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, |
95 | struct pnp_card_link *card, | 121 | struct pnp_card_link *card, |
96 | const struct pnp_card_device_id *id) | 122 | const struct pnp_card_device_id *id) |
@@ -113,8 +139,12 @@ static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, | |||
113 | return err; | 139 | return err; |
114 | } | 140 | } |
115 | port[dev] = pnp_port_start(pdev, 0); | 141 | port[dev] = pnp_port_start(pdev, 0); |
116 | dma8[dev] = pnp_dma(pdev, 1); | 142 | if (id->driver_data == SB_HW_DT019X) |
117 | dma16[dev] = pnp_dma(pdev, 0); | 143 | dma8[dev] = pnp_dma(pdev, 0); |
144 | else { | ||
145 | dma8[dev] = pnp_dma(pdev, 1); | ||
146 | dma16[dev] = pnp_dma(pdev, 0); | ||
147 | } | ||
118 | irq[dev] = pnp_irq(pdev, 0); | 148 | irq[dev] = pnp_irq(pdev, 0); |
119 | 149 | ||
120 | pdev = acard->devmpu; | 150 | pdev = acard->devmpu; |
@@ -175,22 +205,33 @@ static int __devinit snd_card_als100_probe(int dev, | |||
175 | } | 205 | } |
176 | snd_card_set_dev(card, &pcard->card->dev); | 206 | snd_card_set_dev(card, &pcard->card->dev); |
177 | 207 | ||
178 | if ((error = snd_sbdsp_create(card, port[dev], | 208 | if (pid->driver_data == SB_HW_DT019X) |
179 | irq[dev], | 209 | dma16[dev] = -1; |
180 | snd_sb16dsp_interrupt, | 210 | |
181 | dma8[dev], | 211 | error = snd_sbdsp_create(card, port[dev], irq[dev], |
182 | dma16[dev], | 212 | snd_sb16dsp_interrupt, |
183 | SB_HW_ALS100, &chip)) < 0) { | 213 | dma8[dev], dma16[dev], |
214 | pid->driver_data, | ||
215 | &chip); | ||
216 | if (error < 0) { | ||
184 | snd_card_free(card); | 217 | snd_card_free(card); |
185 | return error; | 218 | return error; |
186 | } | 219 | } |
187 | acard->chip = chip; | 220 | acard->chip = chip; |
188 | 221 | ||
189 | strcpy(card->driver, "ALS100"); | 222 | if (pid->driver_data == SB_HW_DT019X) { |
190 | strcpy(card->shortname, "Avance Logic ALS100"); | 223 | strcpy(card->driver, "DT-019X"); |
191 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", | 224 | strcpy(card->shortname, "Diamond Tech. DT-019X"); |
192 | card->shortname, chip->name, chip->port, | 225 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", |
193 | irq[dev], dma8[dev], dma16[dev]); | 226 | card->shortname, chip->name, chip->port, |
227 | irq[dev], dma8[dev]); | ||
228 | } else { | ||
229 | strcpy(card->driver, "ALS100"); | ||
230 | strcpy(card->shortname, "Avance Logic ALS100"); | ||
231 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", | ||
232 | card->shortname, chip->name, chip->port, | ||
233 | irq[dev], dma8[dev], dma16[dev]); | ||
234 | } | ||
194 | 235 | ||
195 | if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { | 236 | if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { |
196 | snd_card_free(card); | 237 | snd_card_free(card); |
@@ -203,9 +244,19 @@ static int __devinit snd_card_als100_probe(int dev, | |||
203 | } | 244 | } |
204 | 245 | ||
205 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | 246 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { |
206 | if (snd_mpu401_uart_new(card, 0, MPU401_HW_ALS100, | 247 | int mpu_type = MPU401_HW_ALS100; |
248 | |||
249 | if (mpu_irq[dev] == SNDRV_AUTO_IRQ) | ||
250 | mpu_irq[dev] = -1; | ||
251 | |||
252 | if (pid->driver_data == SB_HW_DT019X) | ||
253 | mpu_type = MPU401_HW_MPU401; | ||
254 | |||
255 | if (snd_mpu401_uart_new(card, 0, | ||
256 | mpu_type, | ||
207 | mpu_port[dev], 0, | 257 | mpu_port[dev], 0, |
208 | mpu_irq[dev], IRQF_DISABLED, | 258 | mpu_irq[dev], |
259 | mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, | ||
209 | NULL) < 0) | 260 | NULL) < 0) |
210 | snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]); | 261 | snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]); |
211 | } | 262 | } |
@@ -291,7 +342,7 @@ static int snd_als100_pnp_resume(struct pnp_card_link *pcard) | |||
291 | 342 | ||
292 | static struct pnp_card_driver als100_pnpc_driver = { | 343 | static struct pnp_card_driver als100_pnpc_driver = { |
293 | .flags = PNP_DRIVER_RES_DISABLE, | 344 | .flags = PNP_DRIVER_RES_DISABLE, |
294 | .name = "als100", | 345 | .name = "als100", |
295 | .id_table = snd_als100_pnpids, | 346 | .id_table = snd_als100_pnpids, |
296 | .probe = snd_als100_pnp_detect, | 347 | .probe = snd_als100_pnp_detect, |
297 | .remove = __devexit_p(snd_als100_pnp_remove), | 348 | .remove = __devexit_p(snd_als100_pnp_remove), |
@@ -312,7 +363,7 @@ static int __init alsa_card_als100_init(void) | |||
312 | if (!als100_devices) { | 363 | if (!als100_devices) { |
313 | pnp_unregister_card_driver(&als100_pnpc_driver); | 364 | pnp_unregister_card_driver(&als100_pnpc_driver); |
314 | #ifdef MODULE | 365 | #ifdef MODULE |
315 | snd_printk(KERN_ERR "no ALS100 based soundcards found\n"); | 366 | snd_printk(KERN_ERR "no Avance Logic based soundcards found\n"); |
316 | #endif | 367 | #endif |
317 | return -ENODEV; | 368 | return -ENODEV; |
318 | } | 369 | } |
diff --git a/sound/isa/dt019x.c b/sound/isa/dt019x.c deleted file mode 100644 index 80f5b1af9be8..000000000000 --- a/sound/isa/dt019x.c +++ /dev/null | |||
@@ -1,321 +0,0 @@ | |||
1 | |||
2 | /* | ||
3 | dt019x.c - driver for Diamond Technologies DT-0197H based soundcards. | ||
4 | Copyright (C) 1999, 2002 by Massimo Piccioni <dafastidio@libero.it> | ||
5 | |||
6 | Generalised for soundcards based on DT-0196 and ALS-007 chips | ||
7 | by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>: June 2002. | ||
8 | |||
9 | This program is free software; you can redistribute it and/or modify | ||
10 | it under the terms of the GNU General Public License as published by | ||
11 | the Free Software Foundation; either version 2 of the License, or | ||
12 | (at your option) any later version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program; if not, write to the Free Software | ||
21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | */ | ||
23 | |||
24 | #include <linux/init.h> | ||
25 | #include <linux/wait.h> | ||
26 | #include <linux/pnp.h> | ||
27 | #include <linux/moduleparam.h> | ||
28 | #include <sound/core.h> | ||
29 | #include <sound/initval.h> | ||
30 | #include <sound/mpu401.h> | ||
31 | #include <sound/opl3.h> | ||
32 | #include <sound/sb.h> | ||
33 | |||
34 | #define PFX "dt019x: " | ||
35 | |||
36 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); | ||
37 | MODULE_DESCRIPTION("Diamond Technologies DT-019X / Avance Logic ALS-007"); | ||
38 | MODULE_LICENSE("GPL"); | ||
39 | MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X}," | ||
40 | "{Avance Logic ALS-007}}"); | ||
41 | |||
42 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | ||
43 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | ||
44 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ | ||
45 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | ||
46 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | ||
47 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | ||
48 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* PnP setup */ | ||
49 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* PnP setup */ | ||
50 | static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ | ||
51 | |||
52 | module_param_array(index, int, NULL, 0444); | ||
53 | MODULE_PARM_DESC(index, "Index value for DT-019X based soundcard."); | ||
54 | module_param_array(id, charp, NULL, 0444); | ||
55 | MODULE_PARM_DESC(id, "ID string for DT-019X based soundcard."); | ||
56 | module_param_array(enable, bool, NULL, 0444); | ||
57 | MODULE_PARM_DESC(enable, "Enable DT-019X based soundcard."); | ||
58 | |||
59 | struct snd_card_dt019x { | ||
60 | struct pnp_dev *dev; | ||
61 | struct pnp_dev *devmpu; | ||
62 | struct pnp_dev *devopl; | ||
63 | struct snd_sb *chip; | ||
64 | }; | ||
65 | |||
66 | static struct pnp_card_device_id snd_dt019x_pnpids[] = { | ||
67 | /* DT197A30 */ | ||
68 | { .id = "RWB1688", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, | ||
69 | /* DT0196 / ALS-007 */ | ||
70 | { .id = "ALS0007", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, | ||
71 | { .id = "", } | ||
72 | }; | ||
73 | |||
74 | MODULE_DEVICE_TABLE(pnp_card, snd_dt019x_pnpids); | ||
75 | |||
76 | |||
77 | #define DRIVER_NAME "snd-card-dt019x" | ||
78 | |||
79 | |||
80 | static int __devinit snd_card_dt019x_pnp(int dev, struct snd_card_dt019x *acard, | ||
81 | struct pnp_card_link *card, | ||
82 | const struct pnp_card_device_id *pid) | ||
83 | { | ||
84 | struct pnp_dev *pdev; | ||
85 | int err; | ||
86 | |||
87 | acard->dev = pnp_request_card_device(card, pid->devs[0].id, NULL); | ||
88 | if (acard->dev == NULL) | ||
89 | return -ENODEV; | ||
90 | |||
91 | acard->devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); | ||
92 | acard->devopl = pnp_request_card_device(card, pid->devs[2].id, NULL); | ||
93 | |||
94 | pdev = acard->dev; | ||
95 | |||
96 | err = pnp_activate_dev(pdev); | ||
97 | if (err < 0) { | ||
98 | snd_printk(KERN_ERR PFX "DT-019X AUDIO pnp configure failure\n"); | ||
99 | return err; | ||
100 | } | ||
101 | |||
102 | port[dev] = pnp_port_start(pdev, 0); | ||
103 | dma8[dev] = pnp_dma(pdev, 0); | ||
104 | irq[dev] = pnp_irq(pdev, 0); | ||
105 | snd_printdd("dt019x: found audio interface: port=0x%lx, irq=0x%x, dma=0x%x\n", | ||
106 | port[dev],irq[dev],dma8[dev]); | ||
107 | |||
108 | pdev = acard->devmpu; | ||
109 | if (pdev != NULL) { | ||
110 | err = pnp_activate_dev(pdev); | ||
111 | if (err < 0) { | ||
112 | pnp_release_card_device(pdev); | ||
113 | snd_printk(KERN_ERR PFX "DT-019X MPU401 pnp configure failure, skipping\n"); | ||
114 | goto __mpu_error; | ||
115 | } | ||
116 | mpu_port[dev] = pnp_port_start(pdev, 0); | ||
117 | mpu_irq[dev] = pnp_irq(pdev, 0); | ||
118 | snd_printdd("dt019x: found MPU-401: port=0x%lx, irq=0x%x\n", | ||
119 | mpu_port[dev],mpu_irq[dev]); | ||
120 | } else { | ||
121 | __mpu_error: | ||
122 | acard->devmpu = NULL; | ||
123 | mpu_port[dev] = -1; | ||
124 | } | ||
125 | |||
126 | pdev = acard->devopl; | ||
127 | if (pdev != NULL) { | ||
128 | err = pnp_activate_dev(pdev); | ||
129 | if (err < 0) { | ||
130 | pnp_release_card_device(pdev); | ||
131 | snd_printk(KERN_ERR PFX "DT-019X OPL3 pnp configure failure, skipping\n"); | ||
132 | goto __fm_error; | ||
133 | } | ||
134 | fm_port[dev] = pnp_port_start(pdev, 0); | ||
135 | snd_printdd("dt019x: found OPL3 synth: port=0x%lx\n",fm_port[dev]); | ||
136 | } else { | ||
137 | __fm_error: | ||
138 | acard->devopl = NULL; | ||
139 | fm_port[dev] = -1; | ||
140 | } | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) | ||
146 | { | ||
147 | int error; | ||
148 | struct snd_sb *chip; | ||
149 | struct snd_card *card; | ||
150 | struct snd_card_dt019x *acard; | ||
151 | struct snd_opl3 *opl3; | ||
152 | |||
153 | error = snd_card_create(index[dev], id[dev], THIS_MODULE, | ||
154 | sizeof(struct snd_card_dt019x), &card); | ||
155 | if (error < 0) | ||
156 | return error; | ||
157 | acard = card->private_data; | ||
158 | |||
159 | snd_card_set_dev(card, &pcard->card->dev); | ||
160 | if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) { | ||
161 | snd_card_free(card); | ||
162 | return error; | ||
163 | } | ||
164 | |||
165 | if ((error = snd_sbdsp_create(card, port[dev], | ||
166 | irq[dev], | ||
167 | snd_sb16dsp_interrupt, | ||
168 | dma8[dev], | ||
169 | -1, | ||
170 | SB_HW_DT019X, | ||
171 | &chip)) < 0) { | ||
172 | snd_card_free(card); | ||
173 | return error; | ||
174 | } | ||
175 | acard->chip = chip; | ||
176 | |||
177 | strcpy(card->driver, "DT-019X"); | ||
178 | strcpy(card->shortname, "Diamond Tech. DT-019X"); | ||
179 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", | ||
180 | card->shortname, chip->name, chip->port, | ||
181 | irq[dev], dma8[dev]); | ||
182 | |||
183 | if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { | ||
184 | snd_card_free(card); | ||
185 | return error; | ||
186 | } | ||
187 | if ((error = snd_sbmixer_new(chip)) < 0) { | ||
188 | snd_card_free(card); | ||
189 | return error; | ||
190 | } | ||
191 | |||
192 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | ||
193 | if (mpu_irq[dev] == SNDRV_AUTO_IRQ) | ||
194 | mpu_irq[dev] = -1; | ||
195 | if (snd_mpu401_uart_new(card, 0, | ||
196 | /* MPU401_HW_SB,*/ | ||
197 | MPU401_HW_MPU401, | ||
198 | mpu_port[dev], 0, | ||
199 | mpu_irq[dev], | ||
200 | mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, | ||
201 | NULL) < 0) | ||
202 | snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx ?\n", mpu_port[dev]); | ||
203 | } | ||
204 | |||
205 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { | ||
206 | if (snd_opl3_create(card, | ||
207 | fm_port[dev], | ||
208 | fm_port[dev] + 2, | ||
209 | OPL3_HW_AUTO, 0, &opl3) < 0) { | ||
210 | snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx ?\n", | ||
211 | fm_port[dev], fm_port[dev] + 2); | ||
212 | } else { | ||
213 | if ((error = snd_opl3_timer_new(opl3, 0, 1)) < 0) { | ||
214 | snd_card_free(card); | ||
215 | return error; | ||
216 | } | ||
217 | if ((error = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { | ||
218 | snd_card_free(card); | ||
219 | return error; | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | |||
224 | if ((error = snd_card_register(card)) < 0) { | ||
225 | snd_card_free(card); | ||
226 | return error; | ||
227 | } | ||
228 | pnp_set_card_drvdata(pcard, card); | ||
229 | return 0; | ||
230 | } | ||
231 | |||
232 | static unsigned int __devinitdata dt019x_devices; | ||
233 | |||
234 | static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card, | ||
235 | const struct pnp_card_device_id *pid) | ||
236 | { | ||
237 | static int dev; | ||
238 | int res; | ||
239 | |||
240 | for ( ; dev < SNDRV_CARDS; dev++) { | ||
241 | if (!enable[dev]) | ||
242 | continue; | ||
243 | res = snd_card_dt019x_probe(dev, card, pid); | ||
244 | if (res < 0) | ||
245 | return res; | ||
246 | dev++; | ||
247 | dt019x_devices++; | ||
248 | return 0; | ||
249 | } | ||
250 | return -ENODEV; | ||
251 | } | ||
252 | |||
253 | static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard) | ||
254 | { | ||
255 | snd_card_free(pnp_get_card_drvdata(pcard)); | ||
256 | pnp_set_card_drvdata(pcard, NULL); | ||
257 | } | ||
258 | |||
259 | #ifdef CONFIG_PM | ||
260 | static int snd_dt019x_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) | ||
261 | { | ||
262 | struct snd_card *card = pnp_get_card_drvdata(pcard); | ||
263 | struct snd_card_dt019x *acard = card->private_data; | ||
264 | struct snd_sb *chip = acard->chip; | ||
265 | |||
266 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
267 | snd_pcm_suspend_all(chip->pcm); | ||
268 | snd_sbmixer_suspend(chip); | ||
269 | return 0; | ||
270 | } | ||
271 | |||
272 | static int snd_dt019x_pnp_resume(struct pnp_card_link *pcard) | ||
273 | { | ||
274 | struct snd_card *card = pnp_get_card_drvdata(pcard); | ||
275 | struct snd_card_dt019x *acard = card->private_data; | ||
276 | struct snd_sb *chip = acard->chip; | ||
277 | |||
278 | snd_sbdsp_reset(chip); | ||
279 | snd_sbmixer_resume(chip); | ||
280 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
281 | return 0; | ||
282 | } | ||
283 | #endif | ||
284 | |||
285 | static struct pnp_card_driver dt019x_pnpc_driver = { | ||
286 | .flags = PNP_DRIVER_RES_DISABLE, | ||
287 | .name = "dt019x", | ||
288 | .id_table = snd_dt019x_pnpids, | ||
289 | .probe = snd_dt019x_pnp_probe, | ||
290 | .remove = __devexit_p(snd_dt019x_pnp_remove), | ||
291 | #ifdef CONFIG_PM | ||
292 | .suspend = snd_dt019x_pnp_suspend, | ||
293 | .resume = snd_dt019x_pnp_resume, | ||
294 | #endif | ||
295 | }; | ||
296 | |||
297 | static int __init alsa_card_dt019x_init(void) | ||
298 | { | ||
299 | int err; | ||
300 | |||
301 | err = pnp_register_card_driver(&dt019x_pnpc_driver); | ||
302 | if (err) | ||
303 | return err; | ||
304 | |||
305 | if (!dt019x_devices) { | ||
306 | pnp_unregister_card_driver(&dt019x_pnpc_driver); | ||
307 | #ifdef MODULE | ||
308 | snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n"); | ||
309 | #endif | ||
310 | return -ENODEV; | ||
311 | } | ||
312 | return 0; | ||
313 | } | ||
314 | |||
315 | static void __exit alsa_card_dt019x_exit(void) | ||
316 | { | ||
317 | pnp_unregister_card_driver(&dt019x_pnpc_driver); | ||
318 | } | ||
319 | |||
320 | module_init(alsa_card_dt019x_init) | ||
321 | module_exit(alsa_card_dt019x_exit) | ||
diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index b865e45a8f9b..5913717c1be6 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c | |||
@@ -1558,7 +1558,7 @@ static int __devinit snd_card_miro_pnp(struct snd_miro *chip, | |||
1558 | 1558 | ||
1559 | err = pnp_activate_dev(devmc); | 1559 | err = pnp_activate_dev(devmc); |
1560 | if (err < 0) { | 1560 | if (err < 0) { |
1561 | snd_printk(KERN_ERR "OPL syntg pnp configure failure: %d\n", | 1561 | snd_printk(KERN_ERR "MC pnp configure failure: %d\n", |
1562 | err); | 1562 | err); |
1563 | return err; | 1563 | return err; |
1564 | } | 1564 | } |
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index c8a8da0d4036..becd90d7536d 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <asm/io.h> | 33 | #include <asm/io.h> |
34 | #include <asm/dma.h> | 34 | #include <asm/dma.h> |
35 | #include <sound/core.h> | 35 | #include <sound/core.h> |
36 | #include <sound/tlv.h> | ||
36 | #include <sound/wss.h> | 37 | #include <sound/wss.h> |
37 | #include <sound/mpu401.h> | 38 | #include <sound/mpu401.h> |
38 | #include <sound/opl3.h> | 39 | #include <sound/opl3.h> |
@@ -143,12 +144,8 @@ struct snd_opti9xx { | |||
143 | 144 | ||
144 | spinlock_t lock; | 145 | spinlock_t lock; |
145 | 146 | ||
147 | long wss_base; | ||
146 | int irq; | 148 | int irq; |
147 | |||
148 | #ifdef CONFIG_PNP | ||
149 | struct pnp_dev *dev; | ||
150 | struct pnp_dev *devmpu; | ||
151 | #endif /* CONFIG_PNP */ | ||
152 | }; | 149 | }; |
153 | 150 | ||
154 | static int snd_opti9xx_pnp_is_probed; | 151 | static int snd_opti9xx_pnp_is_probed; |
@@ -158,12 +155,17 @@ static int snd_opti9xx_pnp_is_probed; | |||
158 | static struct pnp_card_device_id snd_opti9xx_pnpids[] = { | 155 | static struct pnp_card_device_id snd_opti9xx_pnpids[] = { |
159 | #ifndef OPTi93X | 156 | #ifndef OPTi93X |
160 | /* OPTi 82C924 */ | 157 | /* OPTi 82C924 */ |
161 | { .id = "OPT0924", .devs = { { "OPT0000" }, { "OPT0002" } }, .driver_data = 0x0924 }, | 158 | { .id = "OPT0924", |
159 | .devs = { { "OPT0000" }, { "OPT0002" }, { "OPT0005" } }, | ||
160 | .driver_data = 0x0924 }, | ||
162 | /* OPTi 82C925 */ | 161 | /* OPTi 82C925 */ |
163 | { .id = "OPT0925", .devs = { { "OPT9250" }, { "OPT0002" } }, .driver_data = 0x0925 }, | 162 | { .id = "OPT0925", |
163 | .devs = { { "OPT9250" }, { "OPT0002" }, { "OPT0005" } }, | ||
164 | .driver_data = 0x0925 }, | ||
164 | #else | 165 | #else |
165 | /* OPTi 82C931/3 */ | 166 | /* OPTi 82C931/3 */ |
166 | { .id = "OPT0931", .devs = { { "OPT9310" }, { "OPT0002" } }, .driver_data = 0x0931 }, | 167 | { .id = "OPT0931", .devs = { { "OPT9310" }, { "OPT0002" } }, |
168 | .driver_data = 0x0931 }, | ||
167 | #endif /* OPTi93X */ | 169 | #endif /* OPTi93X */ |
168 | { .id = "" } | 170 | { .id = "" } |
169 | }; | 171 | }; |
@@ -206,24 +208,34 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, | |||
206 | chip->hardware = hardware; | 208 | chip->hardware = hardware; |
207 | strcpy(chip->name, snd_opti9xx_names[hardware]); | 209 | strcpy(chip->name, snd_opti9xx_names[hardware]); |
208 | 210 | ||
209 | chip->mc_base_size = opti9xx_mc_size[hardware]; | ||
210 | |||
211 | spin_lock_init(&chip->lock); | 211 | spin_lock_init(&chip->lock); |
212 | 212 | ||
213 | chip->irq = -1; | 213 | chip->irq = -1; |
214 | 214 | ||
215 | #ifndef OPTi93X | ||
216 | #ifdef CONFIG_PNP | ||
217 | if (isapnp && chip->mc_base) | ||
218 | /* PnP resource gives the least 10 bits */ | ||
219 | chip->mc_base |= 0xc00; | ||
220 | #endif /* CONFIG_PNP */ | ||
221 | else { | ||
222 | chip->mc_base = 0xf8c; | ||
223 | chip->mc_base_size = opti9xx_mc_size[hardware]; | ||
224 | } | ||
225 | #else | ||
226 | chip->mc_base_size = opti9xx_mc_size[hardware]; | ||
227 | #endif | ||
228 | |||
215 | switch (hardware) { | 229 | switch (hardware) { |
216 | #ifndef OPTi93X | 230 | #ifndef OPTi93X |
217 | case OPTi9XX_HW_82C928: | 231 | case OPTi9XX_HW_82C928: |
218 | case OPTi9XX_HW_82C929: | 232 | case OPTi9XX_HW_82C929: |
219 | chip->mc_base = 0xf8c; | ||
220 | chip->password = (hardware == OPTi9XX_HW_82C928) ? 0xe2 : 0xe3; | 233 | chip->password = (hardware == OPTi9XX_HW_82C928) ? 0xe2 : 0xe3; |
221 | chip->pwd_reg = 3; | 234 | chip->pwd_reg = 3; |
222 | break; | 235 | break; |
223 | 236 | ||
224 | case OPTi9XX_HW_82C924: | 237 | case OPTi9XX_HW_82C924: |
225 | case OPTi9XX_HW_82C925: | 238 | case OPTi9XX_HW_82C925: |
226 | chip->mc_base = 0xf8c; | ||
227 | chip->password = 0xe5; | 239 | chip->password = 0xe5; |
228 | chip->pwd_reg = 3; | 240 | chip->pwd_reg = 3; |
229 | break; | 241 | break; |
@@ -291,7 +303,7 @@ static unsigned char snd_opti9xx_read(struct snd_opti9xx *chip, | |||
291 | spin_unlock_irqrestore(&chip->lock, flags); | 303 | spin_unlock_irqrestore(&chip->lock, flags); |
292 | return retval; | 304 | return retval; |
293 | } | 305 | } |
294 | 306 | ||
295 | static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, | 307 | static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, |
296 | unsigned char value) | 308 | unsigned char value) |
297 | { | 309 | { |
@@ -340,7 +352,7 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, | |||
340 | 352 | ||
341 | 353 | ||
342 | static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip, | 354 | static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip, |
343 | long wss_base, | 355 | long port, |
344 | int irq, int dma1, int dma2, | 356 | int irq, int dma1, int dma2, |
345 | long mpu_port, int mpu_irq) | 357 | long mpu_port, int mpu_irq) |
346 | { | 358 | { |
@@ -353,16 +365,23 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip, | |||
353 | switch (chip->hardware) { | 365 | switch (chip->hardware) { |
354 | #ifndef OPTi93X | 366 | #ifndef OPTi93X |
355 | case OPTi9XX_HW_82C924: | 367 | case OPTi9XX_HW_82C924: |
368 | /* opti 929 mode (?), OPL3 clock output, audio enable */ | ||
356 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0xf0, 0xfc); | 369 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0xf0, 0xfc); |
370 | /* enable wave audio */ | ||
357 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); | 371 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); |
358 | 372 | ||
359 | case OPTi9XX_HW_82C925: | 373 | case OPTi9XX_HW_82C925: |
374 | /* enable WSS mode */ | ||
360 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); | 375 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); |
376 | /* OPL3 FM synthesis */ | ||
361 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x00, 0x20); | 377 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x00, 0x20); |
378 | /* disable Sound Blaster IRQ and DMA */ | ||
362 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); | 379 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); |
363 | #ifdef CS4231 | 380 | #ifdef CS4231 |
381 | /* cs4231/4248 fix enabled */ | ||
364 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); | 382 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); |
365 | #else | 383 | #else |
384 | /* cs4231/4248 fix disabled */ | ||
366 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x00, 0x02); | 385 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x00, 0x02); |
367 | #endif /* CS4231 */ | 386 | #endif /* CS4231 */ |
368 | break; | 387 | break; |
@@ -410,21 +429,26 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip, | |||
410 | return -EINVAL; | 429 | return -EINVAL; |
411 | } | 430 | } |
412 | 431 | ||
413 | switch (wss_base) { | 432 | /* PnP resource says it decodes only 10 bits of address */ |
414 | case 0x530: | 433 | switch (port & 0x3ff) { |
434 | case 0x130: | ||
435 | chip->wss_base = 0x530; | ||
415 | wss_base_bits = 0x00; | 436 | wss_base_bits = 0x00; |
416 | break; | 437 | break; |
417 | case 0x604: | 438 | case 0x204: |
439 | chip->wss_base = 0x604; | ||
418 | wss_base_bits = 0x03; | 440 | wss_base_bits = 0x03; |
419 | break; | 441 | break; |
420 | case 0xe80: | 442 | case 0x280: |
443 | chip->wss_base = 0xe80; | ||
421 | wss_base_bits = 0x01; | 444 | wss_base_bits = 0x01; |
422 | break; | 445 | break; |
423 | case 0xf40: | 446 | case 0x340: |
447 | chip->wss_base = 0xf40; | ||
424 | wss_base_bits = 0x02; | 448 | wss_base_bits = 0x02; |
425 | break; | 449 | break; |
426 | default: | 450 | default: |
427 | snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", wss_base); | 451 | snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", port); |
428 | goto __skip_base; | 452 | goto __skip_base; |
429 | } | 453 | } |
430 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); | 454 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); |
@@ -486,7 +510,7 @@ __skip_base: | |||
486 | #endif /* CS4231 || OPTi93X */ | 510 | #endif /* CS4231 || OPTi93X */ |
487 | 511 | ||
488 | #ifndef OPTi93X | 512 | #ifndef OPTi93X |
489 | outb(irq_bits << 3 | dma_bits, wss_base); | 513 | outb(irq_bits << 3 | dma_bits, chip->wss_base); |
490 | #else /* OPTi93X */ | 514 | #else /* OPTi93X */ |
491 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits)); | 515 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits)); |
492 | #endif /* OPTi93X */ | 516 | #endif /* OPTi93X */ |
@@ -546,6 +570,93 @@ __skip_mpu: | |||
546 | 570 | ||
547 | #ifdef OPTi93X | 571 | #ifdef OPTi93X |
548 | 572 | ||
573 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_step, -9300, 300, 0); | ||
574 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0); | ||
575 | static const DECLARE_TLV_DB_SCALE(db_scale_4bit_12db_max, -3300, 300, 0); | ||
576 | |||
577 | static struct snd_kcontrol_new snd_opti93x_controls[] = { | ||
578 | WSS_DOUBLE("Master Playback Switch", 0, | ||
579 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), | ||
580 | WSS_DOUBLE_TLV("Master Playback Volume", 0, | ||
581 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1, | ||
582 | db_scale_5bit_3db_step), | ||
583 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, | ||
584 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1, | ||
585 | db_scale_5bit), | ||
586 | WSS_DOUBLE_TLV("FM Playback Volume", 0, | ||
587 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1, | ||
588 | db_scale_4bit_12db_max), | ||
589 | WSS_DOUBLE("Line Playback Switch", 0, | ||
590 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | ||
591 | WSS_DOUBLE_TLV("Line Playback Volume", 0, | ||
592 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1, | ||
593 | db_scale_4bit_12db_max), | ||
594 | WSS_DOUBLE("Mic Playback Switch", 0, | ||
595 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1), | ||
596 | WSS_DOUBLE_TLV("Mic Playback Volume", 0, | ||
597 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1, | ||
598 | db_scale_4bit_12db_max), | ||
599 | WSS_DOUBLE_TLV("CD Playback Volume", 0, | ||
600 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1, | ||
601 | db_scale_4bit_12db_max), | ||
602 | WSS_DOUBLE("Aux Playback Switch", 0, | ||
603 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1), | ||
604 | WSS_DOUBLE_TLV("Aux Playback Volume", 0, | ||
605 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1, | ||
606 | db_scale_4bit_12db_max), | ||
607 | }; | ||
608 | |||
609 | static int __devinit snd_opti93x_mixer(struct snd_wss *chip) | ||
610 | { | ||
611 | struct snd_card *card; | ||
612 | unsigned int idx; | ||
613 | struct snd_ctl_elem_id id1, id2; | ||
614 | int err; | ||
615 | |||
616 | if (snd_BUG_ON(!chip || !chip->pcm)) | ||
617 | return -EINVAL; | ||
618 | |||
619 | card = chip->card; | ||
620 | |||
621 | strcpy(card->mixername, chip->pcm->name); | ||
622 | |||
623 | memset(&id1, 0, sizeof(id1)); | ||
624 | memset(&id2, 0, sizeof(id2)); | ||
625 | id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
626 | /* reassign AUX0 switch to CD */ | ||
627 | strcpy(id1.name, "Aux Playback Switch"); | ||
628 | strcpy(id2.name, "CD Playback Switch"); | ||
629 | err = snd_ctl_rename_id(card, &id1, &id2); | ||
630 | if (err < 0) { | ||
631 | snd_printk(KERN_ERR "Cannot rename opti93x control\n"); | ||
632 | return err; | ||
633 | } | ||
634 | /* reassign AUX1 switch to FM */ | ||
635 | strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; | ||
636 | strcpy(id2.name, "FM Playback Switch"); | ||
637 | err = snd_ctl_rename_id(card, &id1, &id2); | ||
638 | if (err < 0) { | ||
639 | snd_printk(KERN_ERR "Cannot rename opti93x control\n"); | ||
640 | return err; | ||
641 | } | ||
642 | /* remove AUX1 volume */ | ||
643 | strcpy(id1.name, "Aux Playback Volume"); id1.index = 1; | ||
644 | snd_ctl_remove_id(card, &id1); | ||
645 | |||
646 | /* Replace WSS volume controls with OPTi93x volume controls */ | ||
647 | id1.index = 0; | ||
648 | for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) { | ||
649 | strcpy(id1.name, snd_opti93x_controls[idx].name); | ||
650 | snd_ctl_remove_id(card, &id1); | ||
651 | |||
652 | err = snd_ctl_add(card, | ||
653 | snd_ctl_new1(&snd_opti93x_controls[idx], chip)); | ||
654 | if (err < 0) | ||
655 | return err; | ||
656 | } | ||
657 | return 0; | ||
658 | } | ||
659 | |||
549 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) | 660 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) |
550 | { | 661 | { |
551 | struct snd_opti9xx *chip = dev_id; | 662 | struct snd_opti9xx *chip = dev_id; |
@@ -641,15 +752,15 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
641 | { | 752 | { |
642 | struct pnp_dev *pdev; | 753 | struct pnp_dev *pdev; |
643 | int err; | 754 | int err; |
755 | struct pnp_dev *devmpu; | ||
756 | #ifndef OPTi93X | ||
757 | struct pnp_dev *devmc; | ||
758 | #endif | ||
644 | 759 | ||
645 | chip->dev = pnp_request_card_device(card, pid->devs[0].id, NULL); | 760 | pdev = pnp_request_card_device(card, pid->devs[0].id, NULL); |
646 | if (chip->dev == NULL) | 761 | if (pdev == NULL) |
647 | return -EBUSY; | 762 | return -EBUSY; |
648 | 763 | ||
649 | chip->devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); | ||
650 | |||
651 | pdev = chip->dev; | ||
652 | |||
653 | err = pnp_activate_dev(pdev); | 764 | err = pnp_activate_dev(pdev); |
654 | if (err < 0) { | 765 | if (err < 0) { |
655 | snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err); | 766 | snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err); |
@@ -662,9 +773,24 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
662 | chip->mc_indir_index = pnp_port_start(pdev, 3) + 2; | 773 | chip->mc_indir_index = pnp_port_start(pdev, 3) + 2; |
663 | chip->mc_indir_size = pnp_port_len(pdev, 3) - 2; | 774 | chip->mc_indir_size = pnp_port_len(pdev, 3) - 2; |
664 | #else | 775 | #else |
665 | if (pid->driver_data != 0x0924) | 776 | devmc = pnp_request_card_device(card, pid->devs[2].id, NULL); |
666 | port = pnp_port_start(pdev, 1); | 777 | if (devmc == NULL) |
778 | return -EBUSY; | ||
779 | |||
780 | err = pnp_activate_dev(devmc); | ||
781 | if (err < 0) { | ||
782 | snd_printk(KERN_ERR "MC pnp configure failure: %d\n", err); | ||
783 | return err; | ||
784 | } | ||
785 | |||
786 | port = pnp_port_start(pdev, 1); | ||
667 | fm_port = pnp_port_start(pdev, 2) + 8; | 787 | fm_port = pnp_port_start(pdev, 2) + 8; |
788 | /* | ||
789 | * The MC(0) is never accessed and card does not | ||
790 | * include it in the PnP resource range. OPTI93x include it. | ||
791 | */ | ||
792 | chip->mc_base = pnp_port_start(devmc, 0) - 1; | ||
793 | chip->mc_base_size = pnp_port_len(devmc, 0) + 1; | ||
668 | #endif /* OPTi93X */ | 794 | #endif /* OPTi93X */ |
669 | irq = pnp_irq(pdev, 0); | 795 | irq = pnp_irq(pdev, 0); |
670 | dma1 = pnp_dma(pdev, 0); | 796 | dma1 = pnp_dma(pdev, 0); |
@@ -672,16 +798,16 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
672 | dma2 = pnp_dma(pdev, 1); | 798 | dma2 = pnp_dma(pdev, 1); |
673 | #endif /* CS4231 || OPTi93X */ | 799 | #endif /* CS4231 || OPTi93X */ |
674 | 800 | ||
675 | pdev = chip->devmpu; | 801 | devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); |
676 | if (pdev && mpu_port > 0) { | 802 | |
677 | err = pnp_activate_dev(pdev); | 803 | if (devmpu && mpu_port > 0) { |
804 | err = pnp_activate_dev(devmpu); | ||
678 | if (err < 0) { | 805 | if (err < 0) { |
679 | snd_printk(KERN_ERR "AUDIO pnp configure failure\n"); | 806 | snd_printk(KERN_ERR "MPU401 pnp configure failure\n"); |
680 | mpu_port = -1; | 807 | mpu_port = -1; |
681 | chip->devmpu = NULL; | ||
682 | } else { | 808 | } else { |
683 | mpu_port = pnp_port_start(pdev, 0); | 809 | mpu_port = pnp_port_start(devmpu, 0); |
684 | mpu_irq = pnp_irq(pdev, 0); | 810 | mpu_irq = pnp_irq(devmpu, 0); |
685 | } | 811 | } |
686 | } | 812 | } |
687 | return pid->driver_data; | 813 | return pid->driver_data; |
@@ -736,7 +862,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
736 | if (error) | 862 | if (error) |
737 | return error; | 863 | return error; |
738 | 864 | ||
739 | error = snd_wss_create(card, port + 4, -1, irq, dma1, xdma2, | 865 | error = snd_wss_create(card, chip->wss_base + 4, -1, irq, dma1, xdma2, |
740 | #ifdef OPTi93X | 866 | #ifdef OPTi93X |
741 | WSS_HW_OPTI93X, WSS_HWSHARE_IRQ, | 867 | WSS_HW_OPTI93X, WSS_HWSHARE_IRQ, |
742 | #else | 868 | #else |
@@ -754,6 +880,11 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
754 | error = snd_wss_mixer(codec); | 880 | error = snd_wss_mixer(codec); |
755 | if (error < 0) | 881 | if (error < 0) |
756 | return error; | 882 | return error; |
883 | #ifdef OPTi93X | ||
884 | error = snd_opti93x_mixer(codec); | ||
885 | if (error < 0) | ||
886 | return error; | ||
887 | #endif | ||
757 | #ifdef CS4231 | 888 | #ifdef CS4231 |
758 | error = snd_wss_timer(codec, 0, &timer); | 889 | error = snd_wss_timer(codec, 0, &timer); |
759 | if (error < 0) | 890 | if (error < 0) |
@@ -772,10 +903,11 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
772 | sprintf(card->shortname, "OPTi %s", card->driver); | 903 | sprintf(card->shortname, "OPTi %s", card->driver); |
773 | #if defined(CS4231) || defined(OPTi93X) | 904 | #if defined(CS4231) || defined(OPTi93X) |
774 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", | 905 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", |
775 | card->shortname, pcm->name, port + 4, irq, dma1, xdma2); | 906 | card->shortname, pcm->name, |
907 | chip->wss_base + 4, irq, dma1, xdma2); | ||
776 | #else | 908 | #else |
777 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", | 909 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", |
778 | card->shortname, pcm->name, port + 4, irq, dma1); | 910 | card->shortname, pcm->name, chip->wss_base + 4, irq, dma1); |
779 | #endif /* CS4231 || OPTi93X */ | 911 | #endif /* CS4231 || OPTi93X */ |
780 | 912 | ||
781 | if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) | 913 | if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) |
@@ -969,9 +1101,6 @@ static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, | |||
969 | snd_card_free(card); | 1101 | snd_card_free(card); |
970 | return error; | 1102 | return error; |
971 | } | 1103 | } |
972 | if (hw <= OPTi9XX_HW_82C930) | ||
973 | chip->mc_base -= 0x80; | ||
974 | |||
975 | error = snd_opti9xx_read_check(chip); | 1104 | error = snd_opti9xx_read_check(chip); |
976 | if (error) { | 1105 | if (error) { |
977 | snd_printk(KERN_ERR "OPTI chip not found\n"); | 1106 | snd_printk(KERN_ERR "OPTI chip not found\n"); |
diff --git a/sound/isa/sb/Makefile b/sound/isa/sb/Makefile index faeffceb01b7..af3669681788 100644 --- a/sound/isa/sb/Makefile +++ b/sound/isa/sb/Makefile | |||
@@ -12,6 +12,7 @@ snd-sb16-objs := sb16.o | |||
12 | snd-sbawe-objs := sbawe.o emu8000.o | 12 | snd-sbawe-objs := sbawe.o emu8000.o |
13 | snd-emu8000-synth-objs := emu8000_synth.o emu8000_callback.o emu8000_patch.o emu8000_pcm.o | 13 | snd-emu8000-synth-objs := emu8000_synth.o emu8000_callback.o emu8000_patch.o emu8000_pcm.o |
14 | snd-es968-objs := es968.o | 14 | snd-es968-objs := es968.o |
15 | snd-jazz16-objs := jazz16.o | ||
15 | 16 | ||
16 | # Toplevel Module Dependency | 17 | # Toplevel Module Dependency |
17 | obj-$(CONFIG_SND_SB_COMMON) += snd-sb-common.o | 18 | obj-$(CONFIG_SND_SB_COMMON) += snd-sb-common.o |
@@ -21,6 +22,7 @@ obj-$(CONFIG_SND_SB8) += snd-sb8.o | |||
21 | obj-$(CONFIG_SND_SB16) += snd-sb16.o | 22 | obj-$(CONFIG_SND_SB16) += snd-sb16.o |
22 | obj-$(CONFIG_SND_SBAWE) += snd-sbawe.o | 23 | obj-$(CONFIG_SND_SBAWE) += snd-sbawe.o |
23 | obj-$(CONFIG_SND_ES968) += snd-es968.o | 24 | obj-$(CONFIG_SND_ES968) += snd-es968.o |
25 | obj-$(CONFIG_SND_JAZZ16) += snd-jazz16.o | ||
24 | ifeq ($(CONFIG_SND_SB16_CSP),y) | 26 | ifeq ($(CONFIG_SND_SB16_CSP),y) |
25 | obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o | 27 | obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o |
26 | obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o | 28 | obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o |
diff --git a/sound/isa/sb/jazz16.c b/sound/isa/sb/jazz16.c new file mode 100644 index 000000000000..8ccbcddf08e1 --- /dev/null +++ b/sound/isa/sb/jazz16.c | |||
@@ -0,0 +1,405 @@ | |||
1 | |||
2 | /* | ||
3 | * jazz16.c - driver for Media Vision Jazz16 based soundcards. | ||
4 | * Copyright (C) 2009 Krzysztof Helt <krzysztof.h1@wp.pl> | ||
5 | * Based on patches posted by Rask Ingemann Lambertsen and Rene Herman. | ||
6 | * Based on OSS Sound Blaster driver. | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file COPYING in the main directory of this archive for | ||
10 | * more details. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/init.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <asm/dma.h> | ||
19 | #include <linux/isa.h> | ||
20 | #include <sound/core.h> | ||
21 | #include <sound/mpu401.h> | ||
22 | #include <sound/opl3.h> | ||
23 | #include <sound/sb.h> | ||
24 | #define SNDRV_LEGACY_FIND_FREE_IRQ | ||
25 | #define SNDRV_LEGACY_FIND_FREE_DMA | ||
26 | #include <sound/initval.h> | ||
27 | |||
28 | #define PFX "jazz16: " | ||
29 | |||
30 | MODULE_DESCRIPTION("Media Vision Jazz16"); | ||
31 | MODULE_SUPPORTED_DEVICE("{{Media Vision ??? }," | ||
32 | "{RTL,RTL3000}}"); | ||
33 | |||
34 | MODULE_AUTHOR("Krzysztof Helt <krzysztof.h1@wp.pl>"); | ||
35 | MODULE_LICENSE("GPL"); | ||
36 | |||
37 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | ||
38 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | ||
39 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ | ||
40 | static unsigned long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
41 | static unsigned long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
42 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
43 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
44 | static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
45 | static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
46 | |||
47 | module_param_array(index, int, NULL, 0444); | ||
48 | MODULE_PARM_DESC(index, "Index value for Media Vision Jazz16 based soundcard."); | ||
49 | module_param_array(id, charp, NULL, 0444); | ||
50 | MODULE_PARM_DESC(id, "ID string for Media Vision Jazz16 based soundcard."); | ||
51 | module_param_array(enable, bool, NULL, 0444); | ||
52 | MODULE_PARM_DESC(enable, "Enable Media Vision Jazz16 based soundcard."); | ||
53 | module_param_array(port, long, NULL, 0444); | ||
54 | MODULE_PARM_DESC(port, "Port # for jazz16 driver."); | ||
55 | module_param_array(mpu_port, long, NULL, 0444); | ||
56 | MODULE_PARM_DESC(mpu_port, "MPU-401 port # for jazz16 driver."); | ||
57 | module_param_array(irq, int, NULL, 0444); | ||
58 | MODULE_PARM_DESC(irq, "IRQ # for jazz16 driver."); | ||
59 | module_param_array(mpu_irq, int, NULL, 0444); | ||
60 | MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for jazz16 driver."); | ||
61 | module_param_array(dma8, int, NULL, 0444); | ||
62 | MODULE_PARM_DESC(dma8, "DMA8 # for jazz16 driver."); | ||
63 | module_param_array(dma16, int, NULL, 0444); | ||
64 | MODULE_PARM_DESC(dma16, "DMA16 # for jazz16 driver."); | ||
65 | |||
66 | #define SB_JAZZ16_WAKEUP 0xaf | ||
67 | #define SB_JAZZ16_SET_PORTS 0x50 | ||
68 | #define SB_DSP_GET_JAZZ_BRD_REV 0xfa | ||
69 | #define SB_JAZZ16_SET_DMAINTR 0xfb | ||
70 | #define SB_DSP_GET_JAZZ_MODEL 0xfe | ||
71 | |||
72 | struct snd_card_jazz16 { | ||
73 | struct snd_sb *chip; | ||
74 | }; | ||
75 | |||
76 | static irqreturn_t jazz16_interrupt(int irq, void *chip) | ||
77 | { | ||
78 | return snd_sb8dsp_interrupt(chip); | ||
79 | } | ||
80 | |||
81 | static int __devinit jazz16_configure_ports(unsigned long port, | ||
82 | unsigned long mpu_port, int idx) | ||
83 | { | ||
84 | unsigned char val; | ||
85 | |||
86 | if (!request_region(0x201, 1, "jazz16 config")) { | ||
87 | snd_printk(KERN_ERR "config port region is already in use.\n"); | ||
88 | return -EBUSY; | ||
89 | } | ||
90 | outb(SB_JAZZ16_WAKEUP - idx, 0x201); | ||
91 | udelay(100); | ||
92 | outb(SB_JAZZ16_SET_PORTS + idx, 0x201); | ||
93 | udelay(100); | ||
94 | val = port & 0x70; | ||
95 | val |= (mpu_port & 0x30) >> 4; | ||
96 | outb(val, 0x201); | ||
97 | |||
98 | release_region(0x201, 1); | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static int __devinit jazz16_detect_board(unsigned long port, | ||
103 | unsigned long mpu_port) | ||
104 | { | ||
105 | int err; | ||
106 | int val; | ||
107 | struct snd_sb chip; | ||
108 | |||
109 | if (!request_region(port, 0x10, "jazz16")) { | ||
110 | snd_printk(KERN_ERR "I/O port region is already in use.\n"); | ||
111 | return -EBUSY; | ||
112 | } | ||
113 | /* just to call snd_sbdsp_command/reset/get_byte() */ | ||
114 | chip.port = port; | ||
115 | |||
116 | err = snd_sbdsp_reset(&chip); | ||
117 | if (err < 0) | ||
118 | for (val = 0; val < 4; val++) { | ||
119 | err = jazz16_configure_ports(port, mpu_port, val); | ||
120 | if (err < 0) | ||
121 | break; | ||
122 | |||
123 | err = snd_sbdsp_reset(&chip); | ||
124 | if (!err) | ||
125 | break; | ||
126 | } | ||
127 | if (err < 0) { | ||
128 | err = -ENODEV; | ||
129 | goto err_unmap; | ||
130 | } | ||
131 | if (!snd_sbdsp_command(&chip, SB_DSP_GET_JAZZ_BRD_REV)) { | ||
132 | err = -EBUSY; | ||
133 | goto err_unmap; | ||
134 | } | ||
135 | val = snd_sbdsp_get_byte(&chip); | ||
136 | if (val >= 0x30) | ||
137 | snd_sbdsp_get_byte(&chip); | ||
138 | |||
139 | if ((val & 0xf0) != 0x10) { | ||
140 | err = -ENODEV; | ||
141 | goto err_unmap; | ||
142 | } | ||
143 | if (!snd_sbdsp_command(&chip, SB_DSP_GET_JAZZ_MODEL)) { | ||
144 | err = -EBUSY; | ||
145 | goto err_unmap; | ||
146 | } | ||
147 | snd_sbdsp_get_byte(&chip); | ||
148 | err = snd_sbdsp_get_byte(&chip); | ||
149 | snd_printd("Media Vision Jazz16 board detected: rev 0x%x, model 0x%x\n", | ||
150 | val, err); | ||
151 | |||
152 | err = 0; | ||
153 | |||
154 | err_unmap: | ||
155 | release_region(port, 0x10); | ||
156 | return err; | ||
157 | } | ||
158 | |||
159 | static int __devinit jazz16_configure_board(struct snd_sb *chip, int mpu_irq) | ||
160 | { | ||
161 | static unsigned char jazz_irq_bits[] = { 0, 0, 2, 3, 0, 1, 0, 4, | ||
162 | 0, 2, 5, 0, 0, 0, 0, 6 }; | ||
163 | static unsigned char jazz_dma_bits[] = { 0, 1, 0, 2, 0, 3, 0, 4 }; | ||
164 | |||
165 | if (jazz_dma_bits[chip->dma8] == 0 || | ||
166 | jazz_dma_bits[chip->dma16] == 0 || | ||
167 | jazz_irq_bits[chip->irq] == 0) | ||
168 | return -EINVAL; | ||
169 | |||
170 | if (!snd_sbdsp_command(chip, SB_JAZZ16_SET_DMAINTR)) | ||
171 | return -EBUSY; | ||
172 | |||
173 | if (!snd_sbdsp_command(chip, | ||
174 | jazz_dma_bits[chip->dma8] | | ||
175 | (jazz_dma_bits[chip->dma16] << 4))) | ||
176 | return -EBUSY; | ||
177 | |||
178 | if (!snd_sbdsp_command(chip, | ||
179 | jazz_irq_bits[chip->irq] | | ||
180 | (jazz_irq_bits[mpu_irq] << 4))) | ||
181 | return -EBUSY; | ||
182 | |||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | static int __devinit snd_jazz16_match(struct device *devptr, unsigned int dev) | ||
187 | { | ||
188 | if (!enable[dev]) | ||
189 | return 0; | ||
190 | if (port[dev] == SNDRV_AUTO_PORT) { | ||
191 | snd_printk(KERN_ERR "please specify port\n"); | ||
192 | return 0; | ||
193 | } else if (port[dev] == 0x200 || (port[dev] & ~0x270)) { | ||
194 | snd_printk(KERN_ERR "incorrect port specified\n"); | ||
195 | return 0; | ||
196 | } | ||
197 | if (dma8[dev] != SNDRV_AUTO_DMA && | ||
198 | dma8[dev] != 1 && dma8[dev] != 3) { | ||
199 | snd_printk(KERN_ERR "dma8 must be 1 or 3\n"); | ||
200 | return 0; | ||
201 | } | ||
202 | if (dma16[dev] != SNDRV_AUTO_DMA && | ||
203 | dma16[dev] != 5 && dma16[dev] != 7) { | ||
204 | snd_printk(KERN_ERR "dma16 must be 5 or 7\n"); | ||
205 | return 0; | ||
206 | } | ||
207 | if (mpu_port[dev] != SNDRV_AUTO_PORT && | ||
208 | (mpu_port[dev] & ~0x030) != 0x300) { | ||
209 | snd_printk(KERN_ERR "incorrect mpu_port specified\n"); | ||
210 | return 0; | ||
211 | } | ||
212 | if (mpu_irq[dev] != SNDRV_AUTO_DMA && | ||
213 | mpu_irq[dev] != 2 && mpu_irq[dev] != 3 && | ||
214 | mpu_irq[dev] != 5 && mpu_irq[dev] != 7) { | ||
215 | snd_printk(KERN_ERR "mpu_irq must be 2, 3, 5 or 7\n"); | ||
216 | return 0; | ||
217 | } | ||
218 | return 1; | ||
219 | } | ||
220 | |||
221 | static int __devinit snd_jazz16_probe(struct device *devptr, unsigned int dev) | ||
222 | { | ||
223 | struct snd_card *card; | ||
224 | struct snd_card_jazz16 *jazz16; | ||
225 | struct snd_sb *chip; | ||
226 | struct snd_opl3 *opl3; | ||
227 | static int possible_irqs[] = {2, 3, 5, 7, 9, 10, 15, -1}; | ||
228 | static int possible_dmas8[] = {1, 3, -1}; | ||
229 | static int possible_dmas16[] = {5, 7, -1}; | ||
230 | int err, xirq, xdma8, xdma16, xmpu_port, xmpu_irq; | ||
231 | |||
232 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, | ||
233 | sizeof(struct snd_card_jazz16), &card); | ||
234 | if (err < 0) | ||
235 | return err; | ||
236 | |||
237 | jazz16 = card->private_data; | ||
238 | |||
239 | xirq = irq[dev]; | ||
240 | if (xirq == SNDRV_AUTO_IRQ) { | ||
241 | xirq = snd_legacy_find_free_irq(possible_irqs); | ||
242 | if (xirq < 0) { | ||
243 | snd_printk(KERN_ERR "unable to find a free IRQ\n"); | ||
244 | err = -EBUSY; | ||
245 | goto err_free; | ||
246 | } | ||
247 | } | ||
248 | xdma8 = dma8[dev]; | ||
249 | if (xdma8 == SNDRV_AUTO_DMA) { | ||
250 | xdma8 = snd_legacy_find_free_dma(possible_dmas8); | ||
251 | if (xdma8 < 0) { | ||
252 | snd_printk(KERN_ERR "unable to find a free DMA8\n"); | ||
253 | err = -EBUSY; | ||
254 | goto err_free; | ||
255 | } | ||
256 | } | ||
257 | xdma16 = dma16[dev]; | ||
258 | if (xdma16 == SNDRV_AUTO_DMA) { | ||
259 | xdma16 = snd_legacy_find_free_dma(possible_dmas16); | ||
260 | if (xdma16 < 0) { | ||
261 | snd_printk(KERN_ERR "unable to find a free DMA16\n"); | ||
262 | err = -EBUSY; | ||
263 | goto err_free; | ||
264 | } | ||
265 | } | ||
266 | |||
267 | xmpu_port = mpu_port[dev]; | ||
268 | if (xmpu_port == SNDRV_AUTO_PORT) | ||
269 | xmpu_port = 0; | ||
270 | err = jazz16_detect_board(port[dev], xmpu_port); | ||
271 | if (err < 0) { | ||
272 | printk(KERN_ERR "Media Vision Jazz16 board not detected\n"); | ||
273 | goto err_free; | ||
274 | } | ||
275 | err = snd_sbdsp_create(card, port[dev], irq[dev], | ||
276 | jazz16_interrupt, | ||
277 | dma8[dev], dma16[dev], | ||
278 | SB_HW_JAZZ16, | ||
279 | &chip); | ||
280 | if (err < 0) | ||
281 | goto err_free; | ||
282 | |||
283 | xmpu_irq = mpu_irq[dev]; | ||
284 | if (xmpu_irq == SNDRV_AUTO_IRQ || mpu_port[dev] == SNDRV_AUTO_PORT) | ||
285 | xmpu_irq = 0; | ||
286 | err = jazz16_configure_board(chip, xmpu_irq); | ||
287 | if (err < 0) { | ||
288 | printk(KERN_ERR "Media Vision Jazz16 configuration failed\n"); | ||
289 | goto err_free; | ||
290 | } | ||
291 | |||
292 | jazz16->chip = chip; | ||
293 | |||
294 | strcpy(card->driver, "jazz16"); | ||
295 | strcpy(card->shortname, "Media Vision Jazz16"); | ||
296 | sprintf(card->longname, | ||
297 | "Media Vision Jazz16 at 0x%lx, irq %d, dma8 %d, dma16 %d", | ||
298 | port[dev], xirq, xdma8, xdma16); | ||
299 | |||
300 | err = snd_sb8dsp_pcm(chip, 0, NULL); | ||
301 | if (err < 0) | ||
302 | goto err_free; | ||
303 | err = snd_sbmixer_new(chip); | ||
304 | if (err < 0) | ||
305 | goto err_free; | ||
306 | |||
307 | err = snd_opl3_create(card, chip->port, chip->port + 2, | ||
308 | OPL3_HW_AUTO, 1, &opl3); | ||
309 | if (err < 0) | ||
310 | snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", | ||
311 | chip->port, chip->port + 2); | ||
312 | else { | ||
313 | err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); | ||
314 | if (err < 0) | ||
315 | goto err_free; | ||
316 | } | ||
317 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | ||
318 | if (mpu_irq[dev] == SNDRV_AUTO_IRQ) | ||
319 | mpu_irq[dev] = -1; | ||
320 | |||
321 | if (snd_mpu401_uart_new(card, 0, | ||
322 | MPU401_HW_MPU401, | ||
323 | mpu_port[dev], 0, | ||
324 | mpu_irq[dev], | ||
325 | mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, | ||
326 | NULL) < 0) | ||
327 | snd_printk(KERN_ERR "no MPU-401 device at 0x%lx\n", | ||
328 | mpu_port[dev]); | ||
329 | } | ||
330 | |||
331 | snd_card_set_dev(card, devptr); | ||
332 | |||
333 | err = snd_card_register(card); | ||
334 | if (err < 0) | ||
335 | goto err_free; | ||
336 | |||
337 | dev_set_drvdata(devptr, card); | ||
338 | return 0; | ||
339 | |||
340 | err_free: | ||
341 | snd_card_free(card); | ||
342 | return err; | ||
343 | } | ||
344 | |||
345 | static int __devexit snd_jazz16_remove(struct device *devptr, unsigned int dev) | ||
346 | { | ||
347 | struct snd_card *card = dev_get_drvdata(devptr); | ||
348 | |||
349 | dev_set_drvdata(devptr, NULL); | ||
350 | snd_card_free(card); | ||
351 | return 0; | ||
352 | } | ||
353 | |||
354 | #ifdef CONFIG_PM | ||
355 | static int snd_jazz16_suspend(struct device *pdev, unsigned int n, | ||
356 | pm_message_t state) | ||
357 | { | ||
358 | struct snd_card *card = dev_get_drvdata(pdev); | ||
359 | struct snd_card_jazz16 *acard = card->private_data; | ||
360 | struct snd_sb *chip = acard->chip; | ||
361 | |||
362 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
363 | snd_pcm_suspend_all(chip->pcm); | ||
364 | snd_sbmixer_suspend(chip); | ||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | static int snd_jazz16_resume(struct device *pdev, unsigned int n) | ||
369 | { | ||
370 | struct snd_card *card = dev_get_drvdata(pdev); | ||
371 | struct snd_card_jazz16 *acard = card->private_data; | ||
372 | struct snd_sb *chip = acard->chip; | ||
373 | |||
374 | snd_sbdsp_reset(chip); | ||
375 | snd_sbmixer_resume(chip); | ||
376 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
377 | return 0; | ||
378 | } | ||
379 | #endif | ||
380 | |||
381 | static struct isa_driver snd_jazz16_driver = { | ||
382 | .match = snd_jazz16_match, | ||
383 | .probe = snd_jazz16_probe, | ||
384 | .remove = __devexit_p(snd_jazz16_remove), | ||
385 | #ifdef CONFIG_PM | ||
386 | .suspend = snd_jazz16_suspend, | ||
387 | .resume = snd_jazz16_resume, | ||
388 | #endif | ||
389 | .driver = { | ||
390 | .name = "jazz16" | ||
391 | }, | ||
392 | }; | ||
393 | |||
394 | static int __init alsa_card_jazz16_init(void) | ||
395 | { | ||
396 | return isa_register_driver(&snd_jazz16_driver, SNDRV_CARDS); | ||
397 | } | ||
398 | |||
399 | static void __exit alsa_card_jazz16_exit(void) | ||
400 | { | ||
401 | isa_unregister_driver(&snd_jazz16_driver); | ||
402 | } | ||
403 | |||
404 | module_init(alsa_card_jazz16_init) | ||
405 | module_exit(alsa_card_jazz16_exit) | ||
diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 658d55769c9c..7d84c9f34dc9 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c | |||
@@ -106,9 +106,21 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
106 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 106 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
107 | struct snd_pcm_runtime *runtime = substream->runtime; | 107 | struct snd_pcm_runtime *runtime = substream->runtime; |
108 | unsigned int mixreg, rate, size, count; | 108 | unsigned int mixreg, rate, size, count; |
109 | unsigned char format; | ||
110 | unsigned char stereo = runtime->channels > 1; | ||
111 | int dma; | ||
109 | 112 | ||
110 | rate = runtime->rate; | 113 | rate = runtime->rate; |
111 | switch (chip->hardware) { | 114 | switch (chip->hardware) { |
115 | case SB_HW_JAZZ16: | ||
116 | if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) { | ||
117 | if (chip->mode & SB_MODE_CAPTURE_16) | ||
118 | return -EBUSY; | ||
119 | else | ||
120 | chip->mode |= SB_MODE_PLAYBACK_16; | ||
121 | } | ||
122 | chip->playback_format = SB_DSP_LO_OUTPUT_AUTO; | ||
123 | break; | ||
112 | case SB_HW_PRO: | 124 | case SB_HW_PRO: |
113 | if (runtime->channels > 1) { | 125 | if (runtime->channels > 1) { |
114 | if (snd_BUG_ON(rate != SB8_RATE(11025) && | 126 | if (snd_BUG_ON(rate != SB8_RATE(11025) && |
@@ -133,11 +145,21 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
133 | default: | 145 | default: |
134 | return -EINVAL; | 146 | return -EINVAL; |
135 | } | 147 | } |
148 | if (chip->mode & SB_MODE_PLAYBACK_16) { | ||
149 | format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT; | ||
150 | dma = chip->dma16; | ||
151 | } else { | ||
152 | format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT; | ||
153 | chip->mode |= SB_MODE_PLAYBACK_8; | ||
154 | dma = chip->dma8; | ||
155 | } | ||
136 | size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream); | 156 | size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream); |
137 | count = chip->p_period_size = snd_pcm_lib_period_bytes(substream); | 157 | count = chip->p_period_size = snd_pcm_lib_period_bytes(substream); |
138 | spin_lock_irqsave(&chip->reg_lock, flags); | 158 | spin_lock_irqsave(&chip->reg_lock, flags); |
139 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON); | 159 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON); |
140 | if (runtime->channels > 1) { | 160 | if (chip->hardware == SB_HW_JAZZ16) |
161 | snd_sbdsp_command(chip, format); | ||
162 | else if (stereo) { | ||
141 | /* set playback stereo mode */ | 163 | /* set playback stereo mode */ |
142 | spin_lock(&chip->mixer_lock); | 164 | spin_lock(&chip->mixer_lock); |
143 | mixreg = snd_sbmixer_read(chip, SB_DSP_STEREO_SW); | 165 | mixreg = snd_sbmixer_read(chip, SB_DSP_STEREO_SW); |
@@ -147,15 +169,14 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
147 | /* Soundblaster hardware programming reference guide, 3-23 */ | 169 | /* Soundblaster hardware programming reference guide, 3-23 */ |
148 | snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT); | 170 | snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT); |
149 | runtime->dma_area[0] = 0x80; | 171 | runtime->dma_area[0] = 0x80; |
150 | snd_dma_program(chip->dma8, runtime->dma_addr, 1, DMA_MODE_WRITE); | 172 | snd_dma_program(dma, runtime->dma_addr, 1, DMA_MODE_WRITE); |
151 | /* force interrupt */ | 173 | /* force interrupt */ |
152 | chip->mode = SB_MODE_HALT; | ||
153 | snd_sbdsp_command(chip, SB_DSP_OUTPUT); | 174 | snd_sbdsp_command(chip, SB_DSP_OUTPUT); |
154 | snd_sbdsp_command(chip, 0); | 175 | snd_sbdsp_command(chip, 0); |
155 | snd_sbdsp_command(chip, 0); | 176 | snd_sbdsp_command(chip, 0); |
156 | } | 177 | } |
157 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); | 178 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); |
158 | if (runtime->channels > 1) { | 179 | if (stereo) { |
159 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); | 180 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); |
160 | spin_lock(&chip->mixer_lock); | 181 | spin_lock(&chip->mixer_lock); |
161 | /* save output filter status and turn it off */ | 182 | /* save output filter status and turn it off */ |
@@ -168,13 +189,15 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
168 | snd_sbdsp_command(chip, 256 - runtime->rate_den); | 189 | snd_sbdsp_command(chip, 256 - runtime->rate_den); |
169 | } | 190 | } |
170 | if (chip->playback_format != SB_DSP_OUTPUT) { | 191 | if (chip->playback_format != SB_DSP_OUTPUT) { |
192 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
193 | count /= 2; | ||
171 | count--; | 194 | count--; |
172 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); | 195 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); |
173 | snd_sbdsp_command(chip, count & 0xff); | 196 | snd_sbdsp_command(chip, count & 0xff); |
174 | snd_sbdsp_command(chip, count >> 8); | 197 | snd_sbdsp_command(chip, count >> 8); |
175 | } | 198 | } |
176 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 199 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
177 | snd_dma_program(chip->dma8, runtime->dma_addr, | 200 | snd_dma_program(dma, runtime->dma_addr, |
178 | size, DMA_MODE_WRITE | DMA_AUTOINIT); | 201 | size, DMA_MODE_WRITE | DMA_AUTOINIT); |
179 | return 0; | 202 | return 0; |
180 | } | 203 | } |
@@ -212,7 +235,6 @@ static int snd_sb8_playback_trigger(struct snd_pcm_substream *substream, | |||
212 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 235 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
213 | } | 236 | } |
214 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 237 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
215 | chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_PLAYBACK_8 : SB_MODE_HALT; | ||
216 | return 0; | 238 | return 0; |
217 | } | 239 | } |
218 | 240 | ||
@@ -234,9 +256,21 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
234 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 256 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
235 | struct snd_pcm_runtime *runtime = substream->runtime; | 257 | struct snd_pcm_runtime *runtime = substream->runtime; |
236 | unsigned int mixreg, rate, size, count; | 258 | unsigned int mixreg, rate, size, count; |
259 | unsigned char format; | ||
260 | unsigned char stereo = runtime->channels > 1; | ||
261 | int dma; | ||
237 | 262 | ||
238 | rate = runtime->rate; | 263 | rate = runtime->rate; |
239 | switch (chip->hardware) { | 264 | switch (chip->hardware) { |
265 | case SB_HW_JAZZ16: | ||
266 | if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) { | ||
267 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
268 | return -EBUSY; | ||
269 | else | ||
270 | chip->mode |= SB_MODE_CAPTURE_16; | ||
271 | } | ||
272 | chip->capture_format = SB_DSP_LO_INPUT_AUTO; | ||
273 | break; | ||
240 | case SB_HW_PRO: | 274 | case SB_HW_PRO: |
241 | if (runtime->channels > 1) { | 275 | if (runtime->channels > 1) { |
242 | if (snd_BUG_ON(rate != SB8_RATE(11025) && | 276 | if (snd_BUG_ON(rate != SB8_RATE(11025) && |
@@ -262,14 +296,24 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
262 | default: | 296 | default: |
263 | return -EINVAL; | 297 | return -EINVAL; |
264 | } | 298 | } |
299 | if (chip->mode & SB_MODE_CAPTURE_16) { | ||
300 | format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT; | ||
301 | dma = chip->dma16; | ||
302 | } else { | ||
303 | format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT; | ||
304 | chip->mode |= SB_MODE_CAPTURE_8; | ||
305 | dma = chip->dma8; | ||
306 | } | ||
265 | size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream); | 307 | size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream); |
266 | count = chip->c_period_size = snd_pcm_lib_period_bytes(substream); | 308 | count = chip->c_period_size = snd_pcm_lib_period_bytes(substream); |
267 | spin_lock_irqsave(&chip->reg_lock, flags); | 309 | spin_lock_irqsave(&chip->reg_lock, flags); |
268 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 310 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
269 | if (runtime->channels > 1) | 311 | if (chip->hardware == SB_HW_JAZZ16) |
312 | snd_sbdsp_command(chip, format); | ||
313 | else if (stereo) | ||
270 | snd_sbdsp_command(chip, SB_DSP_STEREO_8BIT); | 314 | snd_sbdsp_command(chip, SB_DSP_STEREO_8BIT); |
271 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); | 315 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); |
272 | if (runtime->channels > 1) { | 316 | if (stereo) { |
273 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); | 317 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); |
274 | spin_lock(&chip->mixer_lock); | 318 | spin_lock(&chip->mixer_lock); |
275 | /* save input filter status and turn it off */ | 319 | /* save input filter status and turn it off */ |
@@ -282,13 +326,15 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
282 | snd_sbdsp_command(chip, 256 - runtime->rate_den); | 326 | snd_sbdsp_command(chip, 256 - runtime->rate_den); |
283 | } | 327 | } |
284 | if (chip->capture_format != SB_DSP_INPUT) { | 328 | if (chip->capture_format != SB_DSP_INPUT) { |
329 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
330 | count /= 2; | ||
285 | count--; | 331 | count--; |
286 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); | 332 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); |
287 | snd_sbdsp_command(chip, count & 0xff); | 333 | snd_sbdsp_command(chip, count & 0xff); |
288 | snd_sbdsp_command(chip, count >> 8); | 334 | snd_sbdsp_command(chip, count >> 8); |
289 | } | 335 | } |
290 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 336 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
291 | snd_dma_program(chip->dma8, runtime->dma_addr, | 337 | snd_dma_program(dma, runtime->dma_addr, |
292 | size, DMA_MODE_READ | DMA_AUTOINIT); | 338 | size, DMA_MODE_READ | DMA_AUTOINIT); |
293 | return 0; | 339 | return 0; |
294 | } | 340 | } |
@@ -328,7 +374,6 @@ static int snd_sb8_capture_trigger(struct snd_pcm_substream *substream, | |||
328 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 374 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
329 | } | 375 | } |
330 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 376 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
331 | chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_CAPTURE_8 : SB_MODE_HALT; | ||
332 | return 0; | 377 | return 0; |
333 | } | 378 | } |
334 | 379 | ||
@@ -339,13 +384,21 @@ irqreturn_t snd_sb8dsp_interrupt(struct snd_sb *chip) | |||
339 | 384 | ||
340 | snd_sb_ack_8bit(chip); | 385 | snd_sb_ack_8bit(chip); |
341 | switch (chip->mode) { | 386 | switch (chip->mode) { |
342 | case SB_MODE_PLAYBACK_8: /* ok.. playback is active */ | 387 | case SB_MODE_PLAYBACK_16: /* ok.. playback is active */ |
388 | if (chip->hardware != SB_HW_JAZZ16) | ||
389 | break; | ||
390 | /* fallthru */ | ||
391 | case SB_MODE_PLAYBACK_8: | ||
343 | substream = chip->playback_substream; | 392 | substream = chip->playback_substream; |
344 | runtime = substream->runtime; | 393 | runtime = substream->runtime; |
345 | if (chip->playback_format == SB_DSP_OUTPUT) | 394 | if (chip->playback_format == SB_DSP_OUTPUT) |
346 | snd_sb8_playback_trigger(substream, SNDRV_PCM_TRIGGER_START); | 395 | snd_sb8_playback_trigger(substream, SNDRV_PCM_TRIGGER_START); |
347 | snd_pcm_period_elapsed(substream); | 396 | snd_pcm_period_elapsed(substream); |
348 | break; | 397 | break; |
398 | case SB_MODE_CAPTURE_16: | ||
399 | if (chip->hardware != SB_HW_JAZZ16) | ||
400 | break; | ||
401 | /* fallthru */ | ||
349 | case SB_MODE_CAPTURE_8: | 402 | case SB_MODE_CAPTURE_8: |
350 | substream = chip->capture_substream; | 403 | substream = chip->capture_substream; |
351 | runtime = substream->runtime; | 404 | runtime = substream->runtime; |
@@ -361,10 +414,15 @@ static snd_pcm_uframes_t snd_sb8_playback_pointer(struct snd_pcm_substream *subs | |||
361 | { | 414 | { |
362 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 415 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
363 | size_t ptr; | 416 | size_t ptr; |
417 | int dma; | ||
364 | 418 | ||
365 | if (chip->mode != SB_MODE_PLAYBACK_8) | 419 | if (chip->mode & SB_MODE_PLAYBACK_8) |
420 | dma = chip->dma8; | ||
421 | else if (chip->mode & SB_MODE_PLAYBACK_16) | ||
422 | dma = chip->dma16; | ||
423 | else | ||
366 | return 0; | 424 | return 0; |
367 | ptr = snd_dma_pointer(chip->dma8, chip->p_dma_size); | 425 | ptr = snd_dma_pointer(dma, chip->p_dma_size); |
368 | return bytes_to_frames(substream->runtime, ptr); | 426 | return bytes_to_frames(substream->runtime, ptr); |
369 | } | 427 | } |
370 | 428 | ||
@@ -372,10 +430,15 @@ static snd_pcm_uframes_t snd_sb8_capture_pointer(struct snd_pcm_substream *subst | |||
372 | { | 430 | { |
373 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 431 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
374 | size_t ptr; | 432 | size_t ptr; |
433 | int dma; | ||
375 | 434 | ||
376 | if (chip->mode != SB_MODE_CAPTURE_8) | 435 | if (chip->mode & SB_MODE_CAPTURE_8) |
436 | dma = chip->dma8; | ||
437 | else if (chip->mode & SB_MODE_CAPTURE_16) | ||
438 | dma = chip->dma16; | ||
439 | else | ||
377 | return 0; | 440 | return 0; |
378 | ptr = snd_dma_pointer(chip->dma8, chip->c_dma_size); | 441 | ptr = snd_dma_pointer(dma, chip->c_dma_size); |
379 | return bytes_to_frames(substream->runtime, ptr); | 442 | return bytes_to_frames(substream->runtime, ptr); |
380 | } | 443 | } |
381 | 444 | ||
@@ -446,6 +509,14 @@ static int snd_sb8_open(struct snd_pcm_substream *substream) | |||
446 | runtime->hw = snd_sb8_capture; | 509 | runtime->hw = snd_sb8_capture; |
447 | } | 510 | } |
448 | switch (chip->hardware) { | 511 | switch (chip->hardware) { |
512 | case SB_HW_JAZZ16: | ||
513 | if (chip->dma16 == 5 || chip->dma16 == 7) | ||
514 | runtime->hw.formats |= SNDRV_PCM_FMTBIT_S16_LE; | ||
515 | runtime->hw.rates |= SNDRV_PCM_RATE_8000_48000; | ||
516 | runtime->hw.rate_min = 4000; | ||
517 | runtime->hw.rate_max = 50000; | ||
518 | runtime->hw.channels_max = 2; | ||
519 | break; | ||
449 | case SB_HW_PRO: | 520 | case SB_HW_PRO: |
450 | runtime->hw.rate_max = 44100; | 521 | runtime->hw.rate_max = 44100; |
451 | runtime->hw.channels_max = 2; | 522 | runtime->hw.channels_max = 2; |
@@ -468,6 +539,14 @@ static int snd_sb8_open(struct snd_pcm_substream *substream) | |||
468 | } | 539 | } |
469 | snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 540 | snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
470 | &hw_constraints_clock); | 541 | &hw_constraints_clock); |
542 | if (chip->dma8 > 3 || chip->dma16 >= 0) { | ||
543 | snd_pcm_hw_constraint_step(runtime, 0, | ||
544 | SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 2); | ||
545 | snd_pcm_hw_constraint_step(runtime, 0, | ||
546 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 2); | ||
547 | runtime->hw.buffer_bytes_max = 128 * 1024 * 1024; | ||
548 | runtime->hw.period_bytes_max = 128 * 1024 * 1024; | ||
549 | } | ||
471 | return 0; | 550 | return 0; |
472 | } | 551 | } |
473 | 552 | ||
@@ -480,6 +559,10 @@ static int snd_sb8_close(struct snd_pcm_substream *substream) | |||
480 | chip->capture_substream = NULL; | 559 | chip->capture_substream = NULL; |
481 | spin_lock_irqsave(&chip->open_lock, flags); | 560 | spin_lock_irqsave(&chip->open_lock, flags); |
482 | chip->open &= ~SB_OPEN_PCM; | 561 | chip->open &= ~SB_OPEN_PCM; |
562 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
563 | chip->mode &= ~SB_MODE_PLAYBACK; | ||
564 | else | ||
565 | chip->mode &= ~SB_MODE_CAPTURE; | ||
483 | spin_unlock_irqrestore(&chip->open_lock, flags); | 566 | spin_unlock_irqrestore(&chip->open_lock, flags); |
484 | return 0; | 567 | return 0; |
485 | } | 568 | } |
@@ -515,6 +598,7 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) | |||
515 | struct snd_card *card = chip->card; | 598 | struct snd_card *card = chip->card; |
516 | struct snd_pcm *pcm; | 599 | struct snd_pcm *pcm; |
517 | int err; | 600 | int err; |
601 | size_t max_prealloc = 64 * 1024; | ||
518 | 602 | ||
519 | if (rpcm) | 603 | if (rpcm) |
520 | *rpcm = NULL; | 604 | *rpcm = NULL; |
@@ -527,9 +611,11 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) | |||
527 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); | 611 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); |
528 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); | 612 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); |
529 | 613 | ||
614 | if (chip->dma8 > 3 || chip->dma16 >= 0) | ||
615 | max_prealloc = 128 * 1024; | ||
530 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 616 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
531 | snd_dma_isa_data(), | 617 | snd_dma_isa_data(), |
532 | 64*1024, 64*1024); | 618 | 64*1024, max_prealloc); |
533 | 619 | ||
534 | if (rpcm) | 620 | if (rpcm) |
535 | *rpcm = pcm; | 621 | *rpcm = pcm; |
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index 27a651502251..eae6c1c0eff9 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c | |||
@@ -170,6 +170,9 @@ static int snd_sbdsp_probe(struct snd_sb * chip) | |||
170 | case SB_HW_CS5530: | 170 | case SB_HW_CS5530: |
171 | str = "16 (CS5530)"; | 171 | str = "16 (CS5530)"; |
172 | break; | 172 | break; |
173 | case SB_HW_JAZZ16: | ||
174 | str = "Pro (Jazz16)"; | ||
175 | break; | ||
173 | default: | 176 | default: |
174 | return -ENODEV; | 177 | return -ENODEV; |
175 | } | 178 | } |
diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 318ff0c823e7..6496822c1808 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c | |||
@@ -528,20 +528,11 @@ int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int ty | |||
528 | * SB 2.0 specific mixer elements | 528 | * SB 2.0 specific mixer elements |
529 | */ | 529 | */ |
530 | 530 | ||
531 | static struct sbmix_elem snd_sb20_ctl_master_play_vol = | 531 | static struct sbmix_elem snd_sb20_controls[] = { |
532 | SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7); | 532 | SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7), |
533 | static struct sbmix_elem snd_sb20_ctl_pcm_play_vol = | 533 | SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3), |
534 | SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3); | 534 | SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7), |
535 | static struct sbmix_elem snd_sb20_ctl_synth_play_vol = | 535 | SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7) |
536 | SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7); | ||
537 | static struct sbmix_elem snd_sb20_ctl_cd_play_vol = | ||
538 | SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7); | ||
539 | |||
540 | static struct sbmix_elem *snd_sb20_controls[] = { | ||
541 | &snd_sb20_ctl_master_play_vol, | ||
542 | &snd_sb20_ctl_pcm_play_vol, | ||
543 | &snd_sb20_ctl_synth_play_vol, | ||
544 | &snd_sb20_ctl_cd_play_vol | ||
545 | }; | 536 | }; |
546 | 537 | ||
547 | static unsigned char snd_sb20_init_values[][2] = { | 538 | static unsigned char snd_sb20_init_values[][2] = { |
@@ -552,41 +543,24 @@ static unsigned char snd_sb20_init_values[][2] = { | |||
552 | /* | 543 | /* |
553 | * SB Pro specific mixer elements | 544 | * SB Pro specific mixer elements |
554 | */ | 545 | */ |
555 | static struct sbmix_elem snd_sbpro_ctl_master_play_vol = | 546 | static struct sbmix_elem snd_sbpro_controls[] = { |
556 | SB_DOUBLE("Master Playback Volume", SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7); | 547 | SB_DOUBLE("Master Playback Volume", |
557 | static struct sbmix_elem snd_sbpro_ctl_pcm_play_vol = | 548 | SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7), |
558 | SB_DOUBLE("PCM Playback Volume", SB_DSP_PCM_DEV, SB_DSP_PCM_DEV, 5, 1, 7); | 549 | SB_DOUBLE("PCM Playback Volume", |
559 | static struct sbmix_elem snd_sbpro_ctl_pcm_play_filter = | 550 | SB_DSP_PCM_DEV, SB_DSP_PCM_DEV, 5, 1, 7), |
560 | SB_SINGLE("PCM Playback Filter", SB_DSP_PLAYBACK_FILT, 5, 1); | 551 | SB_SINGLE("PCM Playback Filter", SB_DSP_PLAYBACK_FILT, 5, 1), |
561 | static struct sbmix_elem snd_sbpro_ctl_synth_play_vol = | 552 | SB_DOUBLE("Synth Playback Volume", |
562 | SB_DOUBLE("Synth Playback Volume", SB_DSP_FM_DEV, SB_DSP_FM_DEV, 5, 1, 7); | 553 | SB_DSP_FM_DEV, SB_DSP_FM_DEV, 5, 1, 7), |
563 | static struct sbmix_elem snd_sbpro_ctl_cd_play_vol = | 554 | SB_DOUBLE("CD Playback Volume", SB_DSP_CD_DEV, SB_DSP_CD_DEV, 5, 1, 7), |
564 | SB_DOUBLE("CD Playback Volume", SB_DSP_CD_DEV, SB_DSP_CD_DEV, 5, 1, 7); | 555 | SB_DOUBLE("Line Playback Volume", |
565 | static struct sbmix_elem snd_sbpro_ctl_line_play_vol = | 556 | SB_DSP_LINE_DEV, SB_DSP_LINE_DEV, 5, 1, 7), |
566 | SB_DOUBLE("Line Playback Volume", SB_DSP_LINE_DEV, SB_DSP_LINE_DEV, 5, 1, 7); | 557 | SB_SINGLE("Mic Playback Volume", SB_DSP_MIC_DEV, 1, 3), |
567 | static struct sbmix_elem snd_sbpro_ctl_mic_play_vol = | ||
568 | SB_SINGLE("Mic Playback Volume", SB_DSP_MIC_DEV, 1, 3); | ||
569 | static struct sbmix_elem snd_sbpro_ctl_capture_source = | ||
570 | { | 558 | { |
571 | .name = "Capture Source", | 559 | .name = "Capture Source", |
572 | .type = SB_MIX_CAPTURE_PRO | 560 | .type = SB_MIX_CAPTURE_PRO |
573 | }; | 561 | }, |
574 | static struct sbmix_elem snd_sbpro_ctl_capture_filter = | 562 | SB_SINGLE("Capture Filter", SB_DSP_CAPTURE_FILT, 5, 1), |
575 | SB_SINGLE("Capture Filter", SB_DSP_CAPTURE_FILT, 5, 1); | 563 | SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 1) |
576 | static struct sbmix_elem snd_sbpro_ctl_capture_low_filter = | ||
577 | SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 1); | ||
578 | |||
579 | static struct sbmix_elem *snd_sbpro_controls[] = { | ||
580 | &snd_sbpro_ctl_master_play_vol, | ||
581 | &snd_sbpro_ctl_pcm_play_vol, | ||
582 | &snd_sbpro_ctl_pcm_play_filter, | ||
583 | &snd_sbpro_ctl_synth_play_vol, | ||
584 | &snd_sbpro_ctl_cd_play_vol, | ||
585 | &snd_sbpro_ctl_line_play_vol, | ||
586 | &snd_sbpro_ctl_mic_play_vol, | ||
587 | &snd_sbpro_ctl_capture_source, | ||
588 | &snd_sbpro_ctl_capture_filter, | ||
589 | &snd_sbpro_ctl_capture_low_filter | ||
590 | }; | 564 | }; |
591 | 565 | ||
592 | static unsigned char snd_sbpro_init_values[][2] = { | 566 | static unsigned char snd_sbpro_init_values[][2] = { |
@@ -598,68 +572,42 @@ static unsigned char snd_sbpro_init_values[][2] = { | |||
598 | /* | 572 | /* |
599 | * SB16 specific mixer elements | 573 | * SB16 specific mixer elements |
600 | */ | 574 | */ |
601 | static struct sbmix_elem snd_sb16_ctl_master_play_vol = | 575 | static struct sbmix_elem snd_sb16_controls[] = { |
602 | SB_DOUBLE("Master Playback Volume", SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31); | 576 | SB_DOUBLE("Master Playback Volume", |
603 | static struct sbmix_elem snd_sb16_ctl_3d_enhance_switch = | 577 | SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31), |
604 | SB_SINGLE("3D Enhancement Switch", SB_DSP4_3DSE, 0, 1); | 578 | SB_DOUBLE("PCM Playback Volume", |
605 | static struct sbmix_elem snd_sb16_ctl_tone_bass = | 579 | SB_DSP4_PCM_DEV, (SB_DSP4_PCM_DEV + 1), 3, 3, 31), |
606 | SB_DOUBLE("Tone Control - Bass", SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15); | 580 | SB16_INPUT_SW("Synth Capture Route", |
607 | static struct sbmix_elem snd_sb16_ctl_tone_treble = | 581 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 6, 5), |
608 | SB_DOUBLE("Tone Control - Treble", SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15); | 582 | SB_DOUBLE("Synth Playback Volume", |
609 | static struct sbmix_elem snd_sb16_ctl_pcm_play_vol = | 583 | SB_DSP4_SYNTH_DEV, (SB_DSP4_SYNTH_DEV + 1), 3, 3, 31), |
610 | SB_DOUBLE("PCM Playback Volume", SB_DSP4_PCM_DEV, (SB_DSP4_PCM_DEV + 1), 3, 3, 31); | 584 | SB16_INPUT_SW("CD Capture Route", |
611 | static struct sbmix_elem snd_sb16_ctl_synth_capture_route = | 585 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 2, 1), |
612 | SB16_INPUT_SW("Synth Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 6, 5); | 586 | SB_DOUBLE("CD Playback Switch", |
613 | static struct sbmix_elem snd_sb16_ctl_synth_play_vol = | 587 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1), |
614 | SB_DOUBLE("Synth Playback Volume", SB_DSP4_SYNTH_DEV, (SB_DSP4_SYNTH_DEV + 1), 3, 3, 31); | 588 | SB_DOUBLE("CD Playback Volume", |
615 | static struct sbmix_elem snd_sb16_ctl_cd_capture_route = | 589 | SB_DSP4_CD_DEV, (SB_DSP4_CD_DEV + 1), 3, 3, 31), |
616 | SB16_INPUT_SW("CD Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 2, 1); | 590 | SB16_INPUT_SW("Mic Capture Route", |
617 | static struct sbmix_elem snd_sb16_ctl_cd_play_switch = | 591 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0), |
618 | SB_DOUBLE("CD Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1); | 592 | SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), |
619 | static struct sbmix_elem snd_sb16_ctl_cd_play_vol = | 593 | SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), |
620 | SB_DOUBLE("CD Playback Volume", SB_DSP4_CD_DEV, (SB_DSP4_CD_DEV + 1), 3, 3, 31); | 594 | SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3), |
621 | static struct sbmix_elem snd_sb16_ctl_line_capture_route = | 595 | SB_DOUBLE("Capture Volume", |
622 | SB16_INPUT_SW("Line Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 4, 3); | 596 | SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3), |
623 | static struct sbmix_elem snd_sb16_ctl_line_play_switch = | 597 | SB_DOUBLE("Playback Volume", |
624 | SB_DOUBLE("Line Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1); | 598 | SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3), |
625 | static struct sbmix_elem snd_sb16_ctl_line_play_vol = | 599 | SB16_INPUT_SW("Line Capture Route", |
626 | SB_DOUBLE("Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31); | 600 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 4, 3), |
627 | static struct sbmix_elem snd_sb16_ctl_mic_capture_route = | 601 | SB_DOUBLE("Line Playback Switch", |
628 | SB16_INPUT_SW("Mic Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0); | 602 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1), |
629 | static struct sbmix_elem snd_sb16_ctl_mic_play_switch = | 603 | SB_DOUBLE("Line Playback Volume", |
630 | SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1); | 604 | SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31), |
631 | static struct sbmix_elem snd_sb16_ctl_mic_play_vol = | 605 | SB_SINGLE("Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1), |
632 | SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31); | 606 | SB_SINGLE("3D Enhancement Switch", SB_DSP4_3DSE, 0, 1), |
633 | static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol = | 607 | SB_DOUBLE("Tone Control - Bass", |
634 | SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3); | 608 | SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15), |
635 | static struct sbmix_elem snd_sb16_ctl_capture_vol = | 609 | SB_DOUBLE("Tone Control - Treble", |
636 | SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3); | 610 | SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15) |
637 | static struct sbmix_elem snd_sb16_ctl_play_vol = | ||
638 | SB_DOUBLE("Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3); | ||
639 | static struct sbmix_elem snd_sb16_ctl_auto_mic_gain = | ||
640 | SB_SINGLE("Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1); | ||
641 | |||
642 | static struct sbmix_elem *snd_sb16_controls[] = { | ||
643 | &snd_sb16_ctl_master_play_vol, | ||
644 | &snd_sb16_ctl_3d_enhance_switch, | ||
645 | &snd_sb16_ctl_tone_bass, | ||
646 | &snd_sb16_ctl_tone_treble, | ||
647 | &snd_sb16_ctl_pcm_play_vol, | ||
648 | &snd_sb16_ctl_synth_capture_route, | ||
649 | &snd_sb16_ctl_synth_play_vol, | ||
650 | &snd_sb16_ctl_cd_capture_route, | ||
651 | &snd_sb16_ctl_cd_play_switch, | ||
652 | &snd_sb16_ctl_cd_play_vol, | ||
653 | &snd_sb16_ctl_line_capture_route, | ||
654 | &snd_sb16_ctl_line_play_switch, | ||
655 | &snd_sb16_ctl_line_play_vol, | ||
656 | &snd_sb16_ctl_mic_capture_route, | ||
657 | &snd_sb16_ctl_mic_play_switch, | ||
658 | &snd_sb16_ctl_mic_play_vol, | ||
659 | &snd_sb16_ctl_pc_speaker_vol, | ||
660 | &snd_sb16_ctl_capture_vol, | ||
661 | &snd_sb16_ctl_play_vol, | ||
662 | &snd_sb16_ctl_auto_mic_gain | ||
663 | }; | 611 | }; |
664 | 612 | ||
665 | static unsigned char snd_sb16_init_values[][2] = { | 613 | static unsigned char snd_sb16_init_values[][2] = { |
@@ -678,46 +626,34 @@ static unsigned char snd_sb16_init_values[][2] = { | |||
678 | /* | 626 | /* |
679 | * DT019x specific mixer elements | 627 | * DT019x specific mixer elements |
680 | */ | 628 | */ |
681 | static struct sbmix_elem snd_dt019x_ctl_master_play_vol = | 629 | static struct sbmix_elem snd_dt019x_controls[] = { |
682 | SB_DOUBLE("Master Playback Volume", SB_DT019X_MASTER_DEV, SB_DT019X_MASTER_DEV, 4,0, 15); | 630 | /* ALS4000 below has some parts which we might be lacking, |
683 | static struct sbmix_elem snd_dt019x_ctl_pcm_play_vol = | 631 | * e.g. snd_als4000_ctl_mono_playback_switch - check it! */ |
684 | SB_DOUBLE("PCM Playback Volume", SB_DT019X_PCM_DEV, SB_DT019X_PCM_DEV, 4,0, 15); | 632 | SB_DOUBLE("Master Playback Volume", |
685 | static struct sbmix_elem snd_dt019x_ctl_synth_play_vol = | 633 | SB_DT019X_MASTER_DEV, SB_DT019X_MASTER_DEV, 4, 0, 15), |
686 | SB_DOUBLE("Synth Playback Volume", SB_DT019X_SYNTH_DEV, SB_DT019X_SYNTH_DEV, 4,0, 15); | 634 | SB_DOUBLE("PCM Playback Switch", |
687 | static struct sbmix_elem snd_dt019x_ctl_cd_play_vol = | 635 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1), |
688 | SB_DOUBLE("CD Playback Volume", SB_DT019X_CD_DEV, SB_DT019X_CD_DEV, 4,0, 15); | 636 | SB_DOUBLE("PCM Playback Volume", |
689 | static struct sbmix_elem snd_dt019x_ctl_mic_play_vol = | 637 | SB_DT019X_PCM_DEV, SB_DT019X_PCM_DEV, 4, 0, 15), |
690 | SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7); | 638 | SB_DOUBLE("Synth Playback Switch", |
691 | static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol = | 639 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4, 3, 1), |
692 | SB_SINGLE("Beep Volume", SB_DT019X_SPKR_DEV, 0, 7); | 640 | SB_DOUBLE("Synth Playback Volume", |
693 | static struct sbmix_elem snd_dt019x_ctl_line_play_vol = | 641 | SB_DT019X_SYNTH_DEV, SB_DT019X_SYNTH_DEV, 4, 0, 15), |
694 | SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15); | 642 | SB_DOUBLE("CD Playback Switch", |
695 | static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch = | 643 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1), |
696 | SB_DOUBLE("PCM Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2,1, 1); | 644 | SB_DOUBLE("CD Playback Volume", |
697 | static struct sbmix_elem snd_dt019x_ctl_synth_play_switch = | 645 | SB_DT019X_CD_DEV, SB_DT019X_CD_DEV, 4, 0, 15), |
698 | SB_DOUBLE("Synth Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4,3, 1); | 646 | SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), |
699 | static struct sbmix_elem snd_dt019x_ctl_capture_source = | 647 | SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7), |
648 | SB_SINGLE("Beep Volume", SB_DT019X_SPKR_DEV, 0, 7), | ||
649 | SB_DOUBLE("Line Playback Switch", | ||
650 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1), | ||
651 | SB_DOUBLE("Line Playback Volume", | ||
652 | SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4, 0, 15), | ||
700 | { | 653 | { |
701 | .name = "Capture Source", | 654 | .name = "Capture Source", |
702 | .type = SB_MIX_CAPTURE_DT019X | 655 | .type = SB_MIX_CAPTURE_DT019X |
703 | }; | 656 | } |
704 | |||
705 | static struct sbmix_elem *snd_dt019x_controls[] = { | ||
706 | /* ALS4000 below has some parts which we might be lacking, | ||
707 | * e.g. snd_als4000_ctl_mono_playback_switch - check it! */ | ||
708 | &snd_dt019x_ctl_master_play_vol, | ||
709 | &snd_dt019x_ctl_pcm_play_vol, | ||
710 | &snd_dt019x_ctl_synth_play_vol, | ||
711 | &snd_dt019x_ctl_cd_play_vol, | ||
712 | &snd_dt019x_ctl_mic_play_vol, | ||
713 | &snd_dt019x_ctl_pc_speaker_vol, | ||
714 | &snd_dt019x_ctl_line_play_vol, | ||
715 | &snd_sb16_ctl_mic_play_switch, | ||
716 | &snd_sb16_ctl_cd_play_switch, | ||
717 | &snd_sb16_ctl_line_play_switch, | ||
718 | &snd_dt019x_ctl_pcm_play_switch, | ||
719 | &snd_dt019x_ctl_synth_play_switch, | ||
720 | &snd_dt019x_ctl_capture_source | ||
721 | }; | 657 | }; |
722 | 658 | ||
723 | static unsigned char snd_dt019x_init_values[][2] = { | 659 | static unsigned char snd_dt019x_init_values[][2] = { |
@@ -735,82 +671,37 @@ static unsigned char snd_dt019x_init_values[][2] = { | |||
735 | /* | 671 | /* |
736 | * ALS4000 specific mixer elements | 672 | * ALS4000 specific mixer elements |
737 | */ | 673 | */ |
738 | static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch = | 674 | static struct sbmix_elem snd_als4000_controls[] = { |
739 | SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1); | 675 | SB_DOUBLE("PCM Playback Switch", |
740 | static struct sbmix_elem snd_als4k_ctl_master_mono_capture_route = { | 676 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1), |
677 | SB_DOUBLE("Synth Playback Switch", | ||
678 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4, 3, 1), | ||
679 | SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03), | ||
680 | SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1), | ||
681 | { | ||
741 | .name = "Master Mono Capture Route", | 682 | .name = "Master Mono Capture Route", |
742 | .type = SB_MIX_MONO_CAPTURE_ALS4K | 683 | .type = SB_MIX_MONO_CAPTURE_ALS4K |
743 | }; | 684 | }, |
744 | static struct sbmix_elem snd_als4000_ctl_mono_playback_switch = | 685 | SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1), |
745 | SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1); | 686 | SB_SINGLE("Analog Loopback Switch", SB_ALS4000_MIC_IN_GAIN, 7, 0x01), |
746 | static struct sbmix_elem snd_als4000_ctl_mic_20db_boost = | 687 | SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01), |
747 | SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03); | ||
748 | static struct sbmix_elem snd_als4000_ctl_mixer_analog_loopback = | ||
749 | SB_SINGLE("Analog Loopback Switch", SB_ALS4000_MIC_IN_GAIN, 7, 0x01); | ||
750 | static struct sbmix_elem snd_als4000_ctl_mixer_digital_loopback = | ||
751 | SB_SINGLE("Digital Loopback Switch", | 688 | SB_SINGLE("Digital Loopback Switch", |
752 | SB_ALS4000_CR3_CONFIGURATION, 7, 0x01); | 689 | SB_ALS4000_CR3_CONFIGURATION, 7, 0x01), |
753 | /* FIXME: functionality of 3D controls might be swapped, I didn't find | 690 | /* FIXME: functionality of 3D controls might be swapped, I didn't find |
754 | * a description of how to identify what is supposed to be what */ | 691 | * a description of how to identify what is supposed to be what */ |
755 | static struct sbmix_elem snd_als4000_3d_control_switch = | 692 | SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07), |
756 | SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01); | ||
757 | static struct sbmix_elem snd_als4000_3d_control_ratio = | ||
758 | SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07); | ||
759 | static struct sbmix_elem snd_als4000_3d_control_freq = | ||
760 | /* FIXME: maybe there's actually some standard 3D ctrl name for it?? */ | 693 | /* FIXME: maybe there's actually some standard 3D ctrl name for it?? */ |
761 | SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03); | 694 | SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03), |
762 | static struct sbmix_elem snd_als4000_3d_control_delay = | ||
763 | /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay, | 695 | /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay, |
764 | * but what ALSA 3D attribute is that actually? "Center", "Depth", | 696 | * but what ALSA 3D attribute is that actually? "Center", "Depth", |
765 | * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */ | 697 | * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */ |
766 | SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f); | 698 | SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f), |
767 | static struct sbmix_elem snd_als4000_3d_control_poweroff_switch = | 699 | SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01), |
768 | SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01); | ||
769 | static struct sbmix_elem snd_als4000_ctl_3db_freq_control_switch = | ||
770 | SB_SINGLE("Master Playback 8kHz / 20kHz LPF Switch", | 700 | SB_SINGLE("Master Playback 8kHz / 20kHz LPF Switch", |
771 | SB_ALS4000_FMDAC, 5, 0x01); | 701 | SB_ALS4000_FMDAC, 5, 0x01), |
772 | #ifdef NOT_AVAILABLE | 702 | #ifdef NOT_AVAILABLE |
773 | static struct sbmix_elem snd_als4000_ctl_fmdac = | 703 | SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01), |
774 | SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01); | 704 | SB_SINGLE("QSound Mode", SB_ALS4000_QSOUND, 1, 0x1f), |
775 | static struct sbmix_elem snd_als4000_ctl_qsound = | ||
776 | SB_SINGLE("QSound Mode", SB_ALS4000_QSOUND, 1, 0x1f); | ||
777 | #endif | ||
778 | |||
779 | static struct sbmix_elem *snd_als4000_controls[] = { | ||
780 | /* ALS4000a.PDF regs page */ | ||
781 | &snd_sb16_ctl_master_play_vol, /* MX30/31 12 */ | ||
782 | &snd_dt019x_ctl_pcm_play_switch, /* MX4C 16 */ | ||
783 | &snd_sb16_ctl_pcm_play_vol, /* MX32/33 12 */ | ||
784 | &snd_sb16_ctl_synth_capture_route, /* MX3D/3E 14 */ | ||
785 | &snd_dt019x_ctl_synth_play_switch, /* MX4C 16 */ | ||
786 | &snd_sb16_ctl_synth_play_vol, /* MX34/35 12/13 */ | ||
787 | &snd_sb16_ctl_cd_capture_route, /* MX3D/3E 14 */ | ||
788 | &snd_sb16_ctl_cd_play_switch, /* MX3C 14 */ | ||
789 | &snd_sb16_ctl_cd_play_vol, /* MX36/37 13 */ | ||
790 | &snd_sb16_ctl_line_capture_route, /* MX3D/3E 14 */ | ||
791 | &snd_sb16_ctl_line_play_switch, /* MX3C 14 */ | ||
792 | &snd_sb16_ctl_line_play_vol, /* MX38/39 13 */ | ||
793 | &snd_sb16_ctl_mic_capture_route, /* MX3D/3E 14 */ | ||
794 | &snd_als4000_ctl_mic_20db_boost, /* MX4D 16 */ | ||
795 | &snd_sb16_ctl_mic_play_switch, /* MX3C 14 */ | ||
796 | &snd_sb16_ctl_mic_play_vol, /* MX3A 13 */ | ||
797 | &snd_sb16_ctl_pc_speaker_vol, /* MX3B 14 */ | ||
798 | &snd_sb16_ctl_capture_vol, /* MX3F/40 15 */ | ||
799 | &snd_sb16_ctl_play_vol, /* MX41/42 15 */ | ||
800 | &snd_als4000_ctl_master_mono_playback_switch, /* MX4C 16 */ | ||
801 | &snd_als4k_ctl_master_mono_capture_route, /* MX4B 16 */ | ||
802 | &snd_als4000_ctl_mono_playback_switch, /* MX4C 16 */ | ||
803 | &snd_als4000_ctl_mixer_analog_loopback, /* MX4D 16 */ | ||
804 | &snd_als4000_ctl_mixer_digital_loopback, /* CR3 21 */ | ||
805 | &snd_als4000_3d_control_switch, /* MX50 17 */ | ||
806 | &snd_als4000_3d_control_ratio, /* MX50 17 */ | ||
807 | &snd_als4000_3d_control_freq, /* MX50 17 */ | ||
808 | &snd_als4000_3d_control_delay, /* MX51 18 */ | ||
809 | &snd_als4000_3d_control_poweroff_switch, /* MX51 18 */ | ||
810 | &snd_als4000_ctl_3db_freq_control_switch, /* MX4F 17 */ | ||
811 | #ifdef NOT_AVAILABLE | ||
812 | &snd_als4000_ctl_fmdac, | ||
813 | &snd_als4000_ctl_qsound, | ||
814 | #endif | 705 | #endif |
815 | }; | 706 | }; |
816 | 707 | ||
@@ -829,11 +720,10 @@ static unsigned char snd_als4000_init_values[][2] = { | |||
829 | { SB_ALS4000_MIC_IN_GAIN, 0 }, | 720 | { SB_ALS4000_MIC_IN_GAIN, 0 }, |
830 | }; | 721 | }; |
831 | 722 | ||
832 | |||
833 | /* | 723 | /* |
834 | */ | 724 | */ |
835 | static int snd_sbmixer_init(struct snd_sb *chip, | 725 | static int snd_sbmixer_init(struct snd_sb *chip, |
836 | struct sbmix_elem **controls, | 726 | struct sbmix_elem *controls, |
837 | int controls_count, | 727 | int controls_count, |
838 | unsigned char map[][2], | 728 | unsigned char map[][2], |
839 | int map_count, | 729 | int map_count, |
@@ -856,7 +746,8 @@ static int snd_sbmixer_init(struct snd_sb *chip, | |||
856 | } | 746 | } |
857 | 747 | ||
858 | for (idx = 0; idx < controls_count; idx++) { | 748 | for (idx = 0; idx < controls_count; idx++) { |
859 | if ((err = snd_sbmixer_add_ctl_elem(chip, controls[idx])) < 0) | 749 | err = snd_sbmixer_add_ctl_elem(chip, &controls[idx]); |
750 | if (err < 0) | ||
860 | return err; | 751 | return err; |
861 | } | 752 | } |
862 | snd_component_add(card, name); | 753 | snd_component_add(card, name); |
@@ -888,6 +779,7 @@ int snd_sbmixer_new(struct snd_sb *chip) | |||
888 | return err; | 779 | return err; |
889 | break; | 780 | break; |
890 | case SB_HW_PRO: | 781 | case SB_HW_PRO: |
782 | case SB_HW_JAZZ16: | ||
891 | if ((err = snd_sbmixer_init(chip, | 783 | if ((err = snd_sbmixer_init(chip, |
892 | snd_sbpro_controls, | 784 | snd_sbpro_controls, |
893 | ARRAY_SIZE(snd_sbpro_controls), | 785 | ARRAY_SIZE(snd_sbpro_controls), |
@@ -908,6 +800,15 @@ int snd_sbmixer_new(struct snd_sb *chip) | |||
908 | return err; | 800 | return err; |
909 | break; | 801 | break; |
910 | case SB_HW_ALS4000: | 802 | case SB_HW_ALS4000: |
803 | /* use only the first 16 controls from SB16 */ | ||
804 | err = snd_sbmixer_init(chip, | ||
805 | snd_sb16_controls, | ||
806 | 16, | ||
807 | snd_sb16_init_values, | ||
808 | ARRAY_SIZE(snd_sb16_init_values), | ||
809 | "ALS4000"); | ||
810 | if (err < 0) | ||
811 | return err; | ||
911 | if ((err = snd_sbmixer_init(chip, | 812 | if ((err = snd_sbmixer_init(chip, |
912 | snd_als4000_controls, | 813 | snd_als4000_controls, |
913 | ARRAY_SIZE(snd_als4000_controls), | 814 | ARRAY_SIZE(snd_als4000_controls), |
@@ -1029,6 +930,7 @@ void snd_sbmixer_suspend(struct snd_sb *chip) | |||
1029 | save_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); | 930 | save_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); |
1030 | break; | 931 | break; |
1031 | case SB_HW_PRO: | 932 | case SB_HW_PRO: |
933 | case SB_HW_JAZZ16: | ||
1032 | save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); | 934 | save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); |
1033 | break; | 935 | break; |
1034 | case SB_HW_16: | 936 | case SB_HW_16: |
@@ -1055,6 +957,7 @@ void snd_sbmixer_resume(struct snd_sb *chip) | |||
1055 | restore_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); | 957 | restore_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); |
1056 | break; | 958 | break; |
1057 | case SB_HW_PRO: | 959 | case SB_HW_PRO: |
960 | case SB_HW_JAZZ16: | ||
1058 | restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); | 961 | restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); |
1059 | break; | 962 | break; |
1060 | case SB_HW_16: | 963 | case SB_HW_16: |
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 5b9d6c18bc45..9191b32d9130 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c | |||
@@ -2014,6 +2014,7 @@ static int snd_wss_info_mux(struct snd_kcontrol *kcontrol, | |||
2014 | case WSS_HW_INTERWAVE: | 2014 | case WSS_HW_INTERWAVE: |
2015 | ptexts = gusmax_texts; | 2015 | ptexts = gusmax_texts; |
2016 | break; | 2016 | break; |
2017 | case WSS_HW_OPTI93X: | ||
2017 | case WSS_HW_OPL3SA2: | 2018 | case WSS_HW_OPL3SA2: |
2018 | ptexts = opl3sa_texts; | 2019 | ptexts = opl3sa_texts; |
2019 | break; | 2020 | break; |
@@ -2246,54 +2247,12 @@ WSS_SINGLE("Beep Bypass Playback Switch", 0, | |||
2246 | CS4231_MONO_CTRL, 5, 1, 0), | 2247 | CS4231_MONO_CTRL, 5, 1, 0), |
2247 | }; | 2248 | }; |
2248 | 2249 | ||
2249 | static struct snd_kcontrol_new snd_opti93x_controls[] = { | ||
2250 | WSS_DOUBLE("Master Playback Switch", 0, | ||
2251 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), | ||
2252 | WSS_DOUBLE_TLV("Master Playback Volume", 0, | ||
2253 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1, | ||
2254 | db_scale_6bit), | ||
2255 | WSS_DOUBLE("PCM Playback Switch", 0, | ||
2256 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | ||
2257 | WSS_DOUBLE("PCM Playback Volume", 0, | ||
2258 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1), | ||
2259 | WSS_DOUBLE("FM Playback Switch", 0, | ||
2260 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | ||
2261 | WSS_DOUBLE("FM Playback Volume", 0, | ||
2262 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1), | ||
2263 | WSS_DOUBLE("Line Playback Switch", 0, | ||
2264 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | ||
2265 | WSS_DOUBLE("Line Playback Volume", 0, | ||
2266 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1), | ||
2267 | WSS_DOUBLE("Mic Playback Switch", 0, | ||
2268 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1), | ||
2269 | WSS_DOUBLE("Mic Playback Volume", 0, | ||
2270 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1), | ||
2271 | WSS_DOUBLE("Mic Boost", 0, | ||
2272 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), | ||
2273 | WSS_DOUBLE("CD Playback Switch", 0, | ||
2274 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | ||
2275 | WSS_DOUBLE("CD Playback Volume", 0, | ||
2276 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1), | ||
2277 | WSS_DOUBLE("Aux Playback Switch", 0, | ||
2278 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1), | ||
2279 | WSS_DOUBLE("Aux Playback Volume", 0, | ||
2280 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1), | ||
2281 | WSS_DOUBLE("Capture Volume", 0, | ||
2282 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), | ||
2283 | { | ||
2284 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2285 | .name = "Capture Source", | ||
2286 | .info = snd_wss_info_mux, | ||
2287 | .get = snd_wss_get_mux, | ||
2288 | .put = snd_wss_put_mux, | ||
2289 | } | ||
2290 | }; | ||
2291 | |||
2292 | int snd_wss_mixer(struct snd_wss *chip) | 2250 | int snd_wss_mixer(struct snd_wss *chip) |
2293 | { | 2251 | { |
2294 | struct snd_card *card; | 2252 | struct snd_card *card; |
2295 | unsigned int idx; | 2253 | unsigned int idx; |
2296 | int err; | 2254 | int err; |
2255 | int count = ARRAY_SIZE(snd_wss_controls); | ||
2297 | 2256 | ||
2298 | if (snd_BUG_ON(!chip || !chip->pcm)) | 2257 | if (snd_BUG_ON(!chip || !chip->pcm)) |
2299 | return -EINVAL; | 2258 | return -EINVAL; |
@@ -2302,28 +2261,19 @@ int snd_wss_mixer(struct snd_wss *chip) | |||
2302 | 2261 | ||
2303 | strcpy(card->mixername, chip->pcm->name); | 2262 | strcpy(card->mixername, chip->pcm->name); |
2304 | 2263 | ||
2305 | if (chip->hardware == WSS_HW_OPTI93X) | 2264 | /* Use only the first 11 entries on AD1848 */ |
2306 | for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) { | 2265 | if (chip->hardware & WSS_HW_AD1848_MASK) |
2307 | err = snd_ctl_add(card, | 2266 | count = 11; |
2308 | snd_ctl_new1(&snd_opti93x_controls[idx], | 2267 | /* There is no loopback on OPTI93X */ |
2309 | chip)); | 2268 | else if (chip->hardware == WSS_HW_OPTI93X) |
2310 | if (err < 0) | 2269 | count = 9; |
2311 | return err; | 2270 | |
2312 | } | 2271 | for (idx = 0; idx < count; idx++) { |
2313 | else { | 2272 | err = snd_ctl_add(card, |
2314 | int count = ARRAY_SIZE(snd_wss_controls); | 2273 | snd_ctl_new1(&snd_wss_controls[idx], |
2315 | 2274 | chip)); | |
2316 | /* Use only the first 11 entries on AD1848 */ | 2275 | if (err < 0) |
2317 | if (chip->hardware & WSS_HW_AD1848_MASK) | 2276 | return err; |
2318 | count = 11; | ||
2319 | |||
2320 | for (idx = 0; idx < count; idx++) { | ||
2321 | err = snd_ctl_add(card, | ||
2322 | snd_ctl_new1(&snd_wss_controls[idx], | ||
2323 | chip)); | ||
2324 | if (err < 0) | ||
2325 | return err; | ||
2326 | } | ||
2327 | } | 2277 | } |
2328 | return 0; | 2278 | return 0; |
2329 | } | 2279 | } |
diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index f1d9d16b5486..6aff217379d9 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/spinlock.h> | 27 | #include <linux/spinlock.h> |
28 | #include <linux/gfp.h> | 28 | #include <linux/gfp.h> |
29 | #include <linux/vmalloc.h> | ||
30 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
31 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
32 | #include <linux/platform_device.h> | 31 | #include <linux/platform_device.h> |
@@ -603,25 +602,14 @@ static int snd_sgio2audio_pcm_close(struct snd_pcm_substream *substream) | |||
603 | static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream, | 602 | static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream, |
604 | struct snd_pcm_hw_params *hw_params) | 603 | struct snd_pcm_hw_params *hw_params) |
605 | { | 604 | { |
606 | struct snd_pcm_runtime *runtime = substream->runtime; | 605 | return snd_pcm_lib_alloc_vmalloc_buffer(substream, |
607 | int size = params_buffer_bytes(hw_params); | 606 | params_buffer_bytes(hw_params)); |
608 | |||
609 | /* alloc virtual 'dma' area */ | ||
610 | if (runtime->dma_area) | ||
611 | vfree(runtime->dma_area); | ||
612 | runtime->dma_area = vmalloc_user(size); | ||
613 | if (runtime->dma_area == NULL) | ||
614 | return -ENOMEM; | ||
615 | runtime->dma_bytes = size; | ||
616 | return 0; | ||
617 | } | 607 | } |
618 | 608 | ||
619 | /* hw_free callback */ | 609 | /* hw_free callback */ |
620 | static int snd_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream) | 610 | static int snd_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream) |
621 | { | 611 | { |
622 | vfree(substream->runtime->dma_area); | 612 | return snd_pcm_lib_free_vmalloc_buffer(substream); |
623 | substream->runtime->dma_area = NULL; | ||
624 | return 0; | ||
625 | } | 613 | } |
626 | 614 | ||
627 | /* prepare callback */ | 615 | /* prepare callback */ |
@@ -692,13 +680,6 @@ snd_sgio2audio_pcm_pointer(struct snd_pcm_substream *substream) | |||
692 | chip->channel[chan->idx].pos); | 680 | chip->channel[chan->idx].pos); |
693 | } | 681 | } |
694 | 682 | ||
695 | /* get the physical page pointer on the given offset */ | ||
696 | static struct page *snd_sgio2audio_page(struct snd_pcm_substream *substream, | ||
697 | unsigned long offset) | ||
698 | { | ||
699 | return vmalloc_to_page(substream->runtime->dma_area + offset); | ||
700 | } | ||
701 | |||
702 | /* operators */ | 683 | /* operators */ |
703 | static struct snd_pcm_ops snd_sgio2audio_playback1_ops = { | 684 | static struct snd_pcm_ops snd_sgio2audio_playback1_ops = { |
704 | .open = snd_sgio2audio_playback1_open, | 685 | .open = snd_sgio2audio_playback1_open, |
@@ -709,7 +690,8 @@ static struct snd_pcm_ops snd_sgio2audio_playback1_ops = { | |||
709 | .prepare = snd_sgio2audio_pcm_prepare, | 690 | .prepare = snd_sgio2audio_pcm_prepare, |
710 | .trigger = snd_sgio2audio_pcm_trigger, | 691 | .trigger = snd_sgio2audio_pcm_trigger, |
711 | .pointer = snd_sgio2audio_pcm_pointer, | 692 | .pointer = snd_sgio2audio_pcm_pointer, |
712 | .page = snd_sgio2audio_page, | 693 | .page = snd_pcm_lib_get_vmalloc_page, |
694 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
713 | }; | 695 | }; |
714 | 696 | ||
715 | static struct snd_pcm_ops snd_sgio2audio_playback2_ops = { | 697 | static struct snd_pcm_ops snd_sgio2audio_playback2_ops = { |
@@ -721,7 +703,8 @@ static struct snd_pcm_ops snd_sgio2audio_playback2_ops = { | |||
721 | .prepare = snd_sgio2audio_pcm_prepare, | 703 | .prepare = snd_sgio2audio_pcm_prepare, |
722 | .trigger = snd_sgio2audio_pcm_trigger, | 704 | .trigger = snd_sgio2audio_pcm_trigger, |
723 | .pointer = snd_sgio2audio_pcm_pointer, | 705 | .pointer = snd_sgio2audio_pcm_pointer, |
724 | .page = snd_sgio2audio_page, | 706 | .page = snd_pcm_lib_get_vmalloc_page, |
707 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
725 | }; | 708 | }; |
726 | 709 | ||
727 | static struct snd_pcm_ops snd_sgio2audio_capture_ops = { | 710 | static struct snd_pcm_ops snd_sgio2audio_capture_ops = { |
@@ -733,7 +716,8 @@ static struct snd_pcm_ops snd_sgio2audio_capture_ops = { | |||
733 | .prepare = snd_sgio2audio_pcm_prepare, | 716 | .prepare = snd_sgio2audio_pcm_prepare, |
734 | .trigger = snd_sgio2audio_pcm_trigger, | 717 | .trigger = snd_sgio2audio_pcm_trigger, |
735 | .pointer = snd_sgio2audio_pcm_pointer, | 718 | .pointer = snd_sgio2audio_pcm_pointer, |
736 | .page = snd_sgio2audio_page, | 719 | .page = snd_pcm_lib_get_vmalloc_page, |
720 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
737 | }; | 721 | }; |
738 | 722 | ||
739 | /* | 723 | /* |
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c index 4191acccbcdb..c1070e33b32f 100644 --- a/sound/oss/au1550_ac97.c +++ b/sound/oss/au1550_ac97.c | |||
@@ -614,7 +614,8 @@ start_adc(struct au1550_state *s) | |||
614 | /* Put two buffers on the ring to get things started. | 614 | /* Put two buffers on the ring to get things started. |
615 | */ | 615 | */ |
616 | for (i=0; i<2; i++) { | 616 | for (i=0; i<2; i++) { |
617 | au1xxx_dbdma_put_dest(db->dmanr, db->nextIn, db->dma_fragsize); | 617 | au1xxx_dbdma_put_dest(db->dmanr, virt_to_phys(db->nextIn), |
618 | db->dma_fragsize, DDMA_FLAGS_IE); | ||
618 | 619 | ||
619 | db->nextIn += db->dma_fragsize; | 620 | db->nextIn += db->dma_fragsize; |
620 | if (db->nextIn >= db->rawbuf + db->dmasize) | 621 | if (db->nextIn >= db->rawbuf + db->dmasize) |
@@ -732,8 +733,9 @@ static void dac_dma_interrupt(int irq, void *dev_id) | |||
732 | db->dma_qcount--; | 733 | db->dma_qcount--; |
733 | 734 | ||
734 | if (db->count >= db->fragsize) { | 735 | if (db->count >= db->fragsize) { |
735 | if (au1xxx_dbdma_put_source(db->dmanr, db->nextOut, | 736 | if (au1xxx_dbdma_put_source(db->dmanr, |
736 | db->fragsize) == 0) { | 737 | virt_to_phys(db->nextOut), db->fragsize, |
738 | DDMA_FLAGS_IE) == 0) { | ||
737 | err("qcount < 2 and no ring room!"); | 739 | err("qcount < 2 and no ring room!"); |
738 | } | 740 | } |
739 | db->nextOut += db->fragsize; | 741 | db->nextOut += db->fragsize; |
@@ -777,7 +779,8 @@ static void adc_dma_interrupt(int irq, void *dev_id) | |||
777 | 779 | ||
778 | /* Put a new empty buffer on the destination DMA. | 780 | /* Put a new empty buffer on the destination DMA. |
779 | */ | 781 | */ |
780 | au1xxx_dbdma_put_dest(dp->dmanr, dp->nextIn, dp->dma_fragsize); | 782 | au1xxx_dbdma_put_dest(dp->dmanr, virt_to_phys(dp->nextIn), |
783 | dp->dma_fragsize, DDMA_FLAGS_IE); | ||
781 | 784 | ||
782 | dp->nextIn += dp->dma_fragsize; | 785 | dp->nextIn += dp->dma_fragsize; |
783 | if (dp->nextIn >= dp->rawbuf + dp->dmasize) | 786 | if (dp->nextIn >= dp->rawbuf + dp->dmasize) |
@@ -1177,8 +1180,9 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos) | |||
1177 | * we know the dma has stopped. | 1180 | * we know the dma has stopped. |
1178 | */ | 1181 | */ |
1179 | while ((db->dma_qcount < 2) && (db->count >= db->fragsize)) { | 1182 | while ((db->dma_qcount < 2) && (db->count >= db->fragsize)) { |
1180 | if (au1xxx_dbdma_put_source(db->dmanr, db->nextOut, | 1183 | if (au1xxx_dbdma_put_source(db->dmanr, |
1181 | db->fragsize) == 0) { | 1184 | virt_to_phys(db->nextOut), db->fragsize, |
1185 | DDMA_FLAGS_IE) == 0) { | ||
1182 | err("qcount < 2 and no ring room!"); | 1186 | err("qcount < 2 and no ring room!"); |
1183 | } | 1187 | } |
1184 | db->nextOut += db->fragsize; | 1188 | db->nextOut += db->fragsize; |
diff --git a/sound/oss/coproc.h b/sound/oss/coproc.h index 7306346e9ac4..7bec21bbdd88 100644 --- a/sound/oss/coproc.h +++ b/sound/oss/coproc.h | |||
@@ -4,7 +4,7 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* | 6 | /* |
7 | * Coprocessor access types | 7 | * Coprocessor access types |
8 | */ | 8 | */ |
9 | #define COPR_CUSTOM 0x0001 /* Custom applications */ | 9 | #define COPR_CUSTOM 0x0001 /* Custom applications */ |
10 | #define COPR_MIDI 0x0002 /* MIDI (MPU-401) emulation */ | 10 | #define COPR_MIDI 0x0002 /* MIDI (MPU-401) emulation */ |
diff --git a/sound/oss/kahlua.c b/sound/oss/kahlua.c index 89466b056be7..24d152ccf80d 100644 --- a/sound/oss/kahlua.c +++ b/sound/oss/kahlua.c | |||
@@ -198,7 +198,7 @@ MODULE_LICENSE("GPL"); | |||
198 | * 5530 only. The 5510/5520 decode is different. | 198 | * 5530 only. The 5510/5520 decode is different. |
199 | */ | 199 | */ |
200 | 200 | ||
201 | static struct pci_device_id id_tbl[] = { | 201 | static DEFINE_PCI_DEVICE_TABLE(id_tbl) = { |
202 | { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO), 0 }, | 202 | { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO), 0 }, |
203 | { } | 203 | { } |
204 | }; | 204 | }; |
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c index c62530943888..fde7c12fe5da 100644 --- a/sound/oss/soundcard.c +++ b/sound/oss/soundcard.c | |||
@@ -328,11 +328,11 @@ static int sound_mixer_ioctl(int mixdev, unsigned int cmd, void __user *arg) | |||
328 | return mixer_devs[mixdev]->ioctl(mixdev, cmd, arg); | 328 | return mixer_devs[mixdev]->ioctl(mixdev, cmd, arg); |
329 | } | 329 | } |
330 | 330 | ||
331 | static int sound_ioctl(struct inode *inode, struct file *file, | 331 | static long sound_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
332 | unsigned int cmd, unsigned long arg) | ||
333 | { | 332 | { |
334 | int len = 0, dtype; | 333 | int len = 0, dtype; |
335 | int dev = iminor(inode); | 334 | int dev = iminor(file->f_dentry->d_inode); |
335 | long ret = -EINVAL; | ||
336 | void __user *p = (void __user *)arg; | 336 | void __user *p = (void __user *)arg; |
337 | 337 | ||
338 | if (_SIOC_DIR(cmd) != _SIOC_NONE && _SIOC_DIR(cmd) != 0) { | 338 | if (_SIOC_DIR(cmd) != _SIOC_NONE && _SIOC_DIR(cmd) != 0) { |
@@ -353,6 +353,7 @@ static int sound_ioctl(struct inode *inode, struct file *file, | |||
353 | if (cmd == OSS_GETVERSION) | 353 | if (cmd == OSS_GETVERSION) |
354 | return __put_user(SOUND_VERSION, (int __user *)p); | 354 | return __put_user(SOUND_VERSION, (int __user *)p); |
355 | 355 | ||
356 | lock_kernel(); | ||
356 | if (_IOC_TYPE(cmd) == 'M' && num_mixers > 0 && /* Mixer ioctl */ | 357 | if (_IOC_TYPE(cmd) == 'M' && num_mixers > 0 && /* Mixer ioctl */ |
357 | (dev & 0x0f) != SND_DEV_CTL) { | 358 | (dev & 0x0f) != SND_DEV_CTL) { |
358 | dtype = dev & 0x0f; | 359 | dtype = dev & 0x0f; |
@@ -360,24 +361,31 @@ static int sound_ioctl(struct inode *inode, struct file *file, | |||
360 | case SND_DEV_DSP: | 361 | case SND_DEV_DSP: |
361 | case SND_DEV_DSP16: | 362 | case SND_DEV_DSP16: |
362 | case SND_DEV_AUDIO: | 363 | case SND_DEV_AUDIO: |
363 | return sound_mixer_ioctl(audio_devs[dev >> 4]->mixer_dev, | 364 | ret = sound_mixer_ioctl(audio_devs[dev >> 4]->mixer_dev, |
364 | cmd, p); | 365 | cmd, p); |
365 | 366 | break; | |
366 | default: | 367 | default: |
367 | return sound_mixer_ioctl(dev >> 4, cmd, p); | 368 | ret = sound_mixer_ioctl(dev >> 4, cmd, p); |
369 | break; | ||
368 | } | 370 | } |
371 | unlock_kernel(); | ||
372 | return ret; | ||
369 | } | 373 | } |
374 | |||
370 | switch (dev & 0x0f) { | 375 | switch (dev & 0x0f) { |
371 | case SND_DEV_CTL: | 376 | case SND_DEV_CTL: |
372 | if (cmd == SOUND_MIXER_GETLEVELS) | 377 | if (cmd == SOUND_MIXER_GETLEVELS) |
373 | return get_mixer_levels(p); | 378 | ret = get_mixer_levels(p); |
374 | if (cmd == SOUND_MIXER_SETLEVELS) | 379 | else if (cmd == SOUND_MIXER_SETLEVELS) |
375 | return set_mixer_levels(p); | 380 | ret = set_mixer_levels(p); |
376 | return sound_mixer_ioctl(dev >> 4, cmd, p); | 381 | else |
382 | ret = sound_mixer_ioctl(dev >> 4, cmd, p); | ||
383 | break; | ||
377 | 384 | ||
378 | case SND_DEV_SEQ: | 385 | case SND_DEV_SEQ: |
379 | case SND_DEV_SEQ2: | 386 | case SND_DEV_SEQ2: |
380 | return sequencer_ioctl(dev, file, cmd, p); | 387 | ret = sequencer_ioctl(dev, file, cmd, p); |
388 | break; | ||
381 | 389 | ||
382 | case SND_DEV_DSP: | 390 | case SND_DEV_DSP: |
383 | case SND_DEV_DSP16: | 391 | case SND_DEV_DSP16: |
@@ -390,7 +398,8 @@ static int sound_ioctl(struct inode *inode, struct file *file, | |||
390 | break; | 398 | break; |
391 | 399 | ||
392 | } | 400 | } |
393 | return -EINVAL; | 401 | unlock_kernel(); |
402 | return ret; | ||
394 | } | 403 | } |
395 | 404 | ||
396 | static unsigned int sound_poll(struct file *file, poll_table * wait) | 405 | static unsigned int sound_poll(struct file *file, poll_table * wait) |
@@ -490,7 +499,7 @@ const struct file_operations oss_sound_fops = { | |||
490 | .read = sound_read, | 499 | .read = sound_read, |
491 | .write = sound_write, | 500 | .write = sound_write, |
492 | .poll = sound_poll, | 501 | .poll = sound_poll, |
493 | .ioctl = sound_ioctl, | 502 | .unlocked_ioctl = sound_ioctl, |
494 | .mmap = sound_mmap, | 503 | .mmap = sound_mmap, |
495 | .open = sound_open, | 504 | .open = sound_open, |
496 | .release = sound_release, | 505 | .release = sound_release, |
diff --git a/sound/oss/v_midi.h b/sound/oss/v_midi.h index 1b86cb45c607..08e2185ee816 100644 --- a/sound/oss/v_midi.h +++ b/sound/oss/v_midi.h | |||
@@ -2,9 +2,9 @@ typedef struct vmidi_devc { | |||
2 | int dev; | 2 | int dev; |
3 | 3 | ||
4 | /* State variables */ | 4 | /* State variables */ |
5 | int opened; | 5 | int opened; |
6 | spinlock_t lock; | 6 | spinlock_t lock; |
7 | 7 | ||
8 | /* MIDI fields */ | 8 | /* MIDI fields */ |
9 | int my_mididev; | 9 | int my_mididev; |
10 | int pair_mididev; | 10 | int pair_mididev; |
@@ -12,4 +12,3 @@ typedef struct vmidi_devc { | |||
12 | int intr_active; | 12 | int intr_active; |
13 | void (*midi_input_intr) (int dev, unsigned char data); | 13 | void (*midi_input_intr) (int dev, unsigned char data); |
14 | } vmidi_devc; | 14 | } vmidi_devc; |
15 | |||
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 351654cf7b09..1298c68d6bf0 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig | |||
@@ -789,6 +789,7 @@ config SND_VIRTUOSO | |||
789 | Say Y here to include support for sound cards based on the | 789 | Say Y here to include support for sound cards based on the |
790 | Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, | 790 | Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, |
791 | Essence ST (Deluxe), and Essence STX. | 791 | Essence ST (Deluxe), and Essence STX. |
792 | Support for the DS is experimental. | ||
792 | Support for the HDAV1.3 (Deluxe) is very experimental. | 793 | Support for the HDAV1.3 (Deluxe) is very experimental. |
793 | 794 | ||
794 | To compile this driver as a module, choose M here: the module | 795 | To compile this driver as a module, choose M here: the module |
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index d9266bae2849..1caf5e3c1f6a 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c | |||
@@ -544,25 +544,10 @@ static int patch_wolfson04(struct snd_ac97 * ac97) | |||
544 | return 0; | 544 | return 0; |
545 | } | 545 | } |
546 | 546 | ||
547 | static int patch_wolfson_wm9705_specific(struct snd_ac97 * ac97) | ||
548 | { | ||
549 | int err, i; | ||
550 | for (i = 0; i < ARRAY_SIZE(wm97xx_snd_ac97_controls); i++) { | ||
551 | if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97))) < 0) | ||
552 | return err; | ||
553 | } | ||
554 | snd_ac97_write_cache(ac97, 0x72, 0x0808); | ||
555 | return 0; | ||
556 | } | ||
557 | |||
558 | static struct snd_ac97_build_ops patch_wolfson_wm9705_ops = { | ||
559 | .build_specific = patch_wolfson_wm9705_specific, | ||
560 | }; | ||
561 | |||
562 | static int patch_wolfson05(struct snd_ac97 * ac97) | 547 | static int patch_wolfson05(struct snd_ac97 * ac97) |
563 | { | 548 | { |
564 | /* WM9705, WM9710 */ | 549 | /* WM9705, WM9710 */ |
565 | ac97->build_ops = &patch_wolfson_wm9705_ops; | 550 | ac97->build_ops = &patch_wolfson_wm9703_ops; |
566 | #ifdef CONFIG_TOUCHSCREEN_WM9705 | 551 | #ifdef CONFIG_TOUCHSCREEN_WM9705 |
567 | /* WM9705 touchscreen uses AUX and VIDEO for touch */ | 552 | /* WM9705 touchscreen uses AUX and VIDEO for touch */ |
568 | ac97->flags |= AC97_HAS_NO_VIDEO | AC97_HAS_NO_AUX; | 553 | ac97->flags |= AC97_HAS_NO_VIDEO | AC97_HAS_NO_AUX; |
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 8f5098f92c37..4382d0fa6b9a 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c | |||
@@ -1048,7 +1048,7 @@ snd_ad1889_remove(struct pci_dev *pci) | |||
1048 | pci_set_drvdata(pci, NULL); | 1048 | pci_set_drvdata(pci, NULL); |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | static struct pci_device_id snd_ad1889_ids[] = { | 1051 | static DEFINE_PCI_DEVICE_TABLE(snd_ad1889_ids) = { |
1052 | { PCI_DEVICE(PCI_VENDOR_ID_ANALOG_DEVICES, PCI_DEVICE_ID_AD1889JS) }, | 1052 | { PCI_DEVICE(PCI_VENDOR_ID_ANALOG_DEVICES, PCI_DEVICE_ID_AD1889JS) }, |
1053 | { 0, }, | 1053 | { 0, }, |
1054 | }; | 1054 | }; |
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index aaf4da68969c..5c6e322a48f0 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c | |||
@@ -275,7 +275,7 @@ struct snd_ali { | |||
275 | #endif | 275 | #endif |
276 | }; | 276 | }; |
277 | 277 | ||
278 | static struct pci_device_id snd_ali_ids[] = { | 278 | static DEFINE_PCI_DEVICE_TABLE(snd_ali_ids) = { |
279 | {PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5451), 0, 0, 0}, | 279 | {PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5451), 0, 0, 0}, |
280 | {0, } | 280 | {0, } |
281 | }; | 281 | }; |
diff --git a/sound/pci/als300.c b/sound/pci/als300.c index 3aa35af7ca91..d7653cb7ac60 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c | |||
@@ -145,7 +145,7 @@ struct snd_als300_substream_data { | |||
145 | int block_counter_register; | 145 | int block_counter_register; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | static struct pci_device_id snd_als300_ids[] = { | 148 | static DEFINE_PCI_DEVICE_TABLE(snd_als300_ids) = { |
149 | { 0x4005, 0x0300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALS300 }, | 149 | { 0x4005, 0x0300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALS300 }, |
150 | { 0x4005, 0x0308, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALS300_PLUS }, | 150 | { 0x4005, 0x0308, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALS300_PLUS }, |
151 | { 0, } | 151 | { 0, } |
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 3dbacde1a5af..d75cf7b06426 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c | |||
@@ -117,7 +117,7 @@ struct snd_card_als4000 { | |||
117 | #endif | 117 | #endif |
118 | }; | 118 | }; |
119 | 119 | ||
120 | static struct pci_device_id snd_als4000_ids[] = { | 120 | static DEFINE_PCI_DEVICE_TABLE(snd_als4000_ids) = { |
121 | { 0x4005, 0x4000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ALS4000 */ | 121 | { 0x4005, 0x4000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ALS4000 */ |
122 | { 0, } | 122 | { 0, } |
123 | }; | 123 | }; |
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 42b4fbbd8e2b..49d572a7b235 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c | |||
@@ -286,7 +286,7 @@ struct atiixp { | |||
286 | 286 | ||
287 | /* | 287 | /* |
288 | */ | 288 | */ |
289 | static struct pci_device_id snd_atiixp_ids[] = { | 289 | static DEFINE_PCI_DEVICE_TABLE(snd_atiixp_ids) = { |
290 | { PCI_VDEVICE(ATI, 0x4341), 0 }, /* SB200 */ | 290 | { PCI_VDEVICE(ATI, 0x4341), 0 }, /* SB200 */ |
291 | { PCI_VDEVICE(ATI, 0x4361), 0 }, /* SB300 */ | 291 | { PCI_VDEVICE(ATI, 0x4361), 0 }, /* SB300 */ |
292 | { PCI_VDEVICE(ATI, 0x4370), 0 }, /* SB400 */ | 292 | { PCI_VDEVICE(ATI, 0x4370), 0 }, /* SB400 */ |
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index e7e147bf8eb2..91d7036b6411 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c | |||
@@ -261,7 +261,7 @@ struct atiixp_modem { | |||
261 | 261 | ||
262 | /* | 262 | /* |
263 | */ | 263 | */ |
264 | static struct pci_device_id snd_atiixp_ids[] = { | 264 | static DEFINE_PCI_DEVICE_TABLE(snd_atiixp_ids) = { |
265 | { PCI_VDEVICE(ATI, 0x434d), 0 }, /* SB200 */ | 265 | { PCI_VDEVICE(ATI, 0x434d), 0 }, /* SB200 */ |
266 | { PCI_VDEVICE(ATI, 0x4378), 0 }, /* SB400 */ | 266 | { PCI_VDEVICE(ATI, 0x4378), 0 }, /* SB400 */ |
267 | { 0, } | 267 | { 0, } |
diff --git a/sound/pci/au88x0/au8810.c b/sound/pci/au88x0/au8810.c index c0e8c6b295cb..aa51cc7771dd 100644 --- a/sound/pci/au88x0/au8810.c +++ b/sound/pci/au88x0/au8810.c | |||
@@ -1,6 +1,6 @@ | |||
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 DEFINE_PCI_DEVICE_TABLE(snd_vortex_ids) = { |
4 | {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_ADVANTAGE), 1,}, | 4 | {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_ADVANTAGE), 1,}, |
5 | {0,} | 5 | {0,} |
6 | }; | 6 | }; |
diff --git a/sound/pci/au88x0/au8820.c b/sound/pci/au88x0/au8820.c index a6527330df58..2f321e7306cd 100644 --- a/sound/pci/au88x0/au8820.c +++ b/sound/pci/au88x0/au8820.c | |||
@@ -1,6 +1,6 @@ | |||
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 DEFINE_PCI_DEVICE_TABLE(snd_vortex_ids) = { |
4 | {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_1), 0,}, | 4 | {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_1), 0,}, |
5 | {0,} | 5 | {0,} |
6 | }; | 6 | }; |
diff --git a/sound/pci/au88x0/au8830.c b/sound/pci/au88x0/au8830.c index 6c702ad4352a..279b78f06d22 100644 --- a/sound/pci/au88x0/au8830.c +++ b/sound/pci/au88x0/au8830.c | |||
@@ -1,6 +1,6 @@ | |||
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 DEFINE_PCI_DEVICE_TABLE(snd_vortex_ids) = { |
4 | {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_2), 0,}, | 4 | {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_2), 0,}, |
5 | {0,} | 5 | {0,} |
6 | }; | 6 | }; |
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c index 4d34bb0d99d3..67921f93a41e 100644 --- a/sound/pci/aw2/aw2-alsa.c +++ b/sound/pci/aw2/aw2-alsa.c | |||
@@ -164,7 +164,7 @@ MODULE_PARM_DESC(id, "ID string for the Audiowerk2 soundcard."); | |||
164 | module_param_array(enable, bool, NULL, 0444); | 164 | module_param_array(enable, bool, NULL, 0444); |
165 | MODULE_PARM_DESC(enable, "Enable Audiowerk2 soundcard."); | 165 | MODULE_PARM_DESC(enable, "Enable Audiowerk2 soundcard."); |
166 | 166 | ||
167 | static struct pci_device_id snd_aw2_ids[] = { | 167 | static DEFINE_PCI_DEVICE_TABLE(snd_aw2_ids) = { |
168 | {PCI_VENDOR_ID_SAA7146, PCI_DEVICE_ID_SAA7146, 0, 0, | 168 | {PCI_VENDOR_ID_SAA7146, PCI_DEVICE_ID_SAA7146, 0, 0, |
169 | 0, 0, 0}, | 169 | 0, 0, 0}, |
170 | {0} | 170 | {0} |
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 69867ace7860..4679ed83a43b 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c | |||
@@ -350,7 +350,7 @@ struct snd_azf3328 { | |||
350 | #endif | 350 | #endif |
351 | }; | 351 | }; |
352 | 352 | ||
353 | static const struct pci_device_id snd_azf3328_ids[] = { | 353 | static DEFINE_PCI_DEVICE_TABLE(snd_azf3328_ids) = { |
354 | { 0x122D, 0x50DC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* PCI168/3328 */ | 354 | { 0x122D, 0x50DC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* PCI168/3328 */ |
355 | { 0x122D, 0x80DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* 3328 */ | 355 | { 0x122D, 0x80DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* 3328 */ |
356 | { 0, } | 356 | { 0, } |
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 4e2b925a94cc..37e1b5df5ab8 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c | |||
@@ -795,7 +795,7 @@ fail: | |||
795 | .driver_data = SND_BT87X_BOARD_ ## id } | 795 | .driver_data = SND_BT87X_BOARD_ ## id } |
796 | /* driver_data is the card id for that device */ | 796 | /* driver_data is the card id for that device */ |
797 | 797 | ||
798 | static struct pci_device_id snd_bt87x_ids[] = { | 798 | static DEFINE_PCI_DEVICE_TABLE(snd_bt87x_ids) = { |
799 | /* Hauppauge WinTV series */ | 799 | /* Hauppauge WinTV series */ |
800 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0x13eb, GENERIC), | 800 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0x13eb, GENERIC), |
801 | /* Hauppauge WinTV series */ | 801 | /* Hauppauge WinTV series */ |
@@ -964,7 +964,7 @@ static void __devexit snd_bt87x_remove(struct pci_dev *pci) | |||
964 | 964 | ||
965 | /* default entries for all Bt87x cards - it's not exported */ | 965 | /* default entries for all Bt87x cards - it's not exported */ |
966 | /* driver_data is set to 0 to call detection */ | 966 | /* driver_data is set to 0 to call detection */ |
967 | static struct pci_device_id snd_bt87x_default_ids[] __devinitdata = { | 967 | static DEFINE_PCI_DEVICE_TABLE(snd_bt87x_default_ids) = { |
968 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, PCI_ANY_ID, PCI_ANY_ID, UNKNOWN), | 968 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, PCI_ANY_ID, PCI_ANY_ID, UNKNOWN), |
969 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, PCI_ANY_ID, PCI_ANY_ID, UNKNOWN), | 969 | BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, PCI_ANY_ID, PCI_ANY_ID, UNKNOWN), |
970 | { } | 970 | { } |
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 15e4138bce17..0a3d3d6e77b4 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c | |||
@@ -1875,7 +1875,7 @@ static int snd_ca0106_resume(struct pci_dev *pci) | |||
1875 | #endif | 1875 | #endif |
1876 | 1876 | ||
1877 | // PCI IDs | 1877 | // PCI IDs |
1878 | static struct pci_device_id snd_ca0106_ids[] = { | 1878 | static DEFINE_PCI_DEVICE_TABLE(snd_ca0106_ids) = { |
1879 | { PCI_VDEVICE(CREATIVE, 0x0007), 0 }, /* Audigy LS or Live 24bit */ | 1879 | { PCI_VDEVICE(CREATIVE, 0x0007), 0 }, /* Audigy LS or Live 24bit */ |
1880 | { 0, } | 1880 | { 0, } |
1881 | }; | 1881 | }; |
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index a312bae08f52..1ded64e05643 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c | |||
@@ -2796,7 +2796,7 @@ static inline void snd_cmipci_proc_init(struct cmipci *cm) {} | |||
2796 | #endif | 2796 | #endif |
2797 | 2797 | ||
2798 | 2798 | ||
2799 | static struct pci_device_id snd_cmipci_ids[] = { | 2799 | static DEFINE_PCI_DEVICE_TABLE(snd_cmipci_ids) = { |
2800 | {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338A), 0}, | 2800 | {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338A), 0}, |
2801 | {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338B), 0}, | 2801 | {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338B), 0}, |
2802 | {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738), 0}, | 2802 | {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738), 0}, |
@@ -3018,7 +3018,7 @@ static int __devinit snd_cmipci_create(struct snd_card *card, struct pci_dev *pc | |||
3018 | int integrated_midi = 0; | 3018 | int integrated_midi = 0; |
3019 | char modelstr[16]; | 3019 | char modelstr[16]; |
3020 | int pcm_index, pcm_spdif_index; | 3020 | int pcm_index, pcm_spdif_index; |
3021 | static struct pci_device_id intel_82437vx[] = { | 3021 | static DEFINE_PCI_DEVICE_TABLE(intel_82437vx) = { |
3022 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX) }, | 3022 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX) }, |
3023 | { }, | 3023 | { }, |
3024 | }; | 3024 | }; |
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index e2e0359bb056..9edc65059e3e 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c | |||
@@ -494,7 +494,7 @@ struct cs4281 { | |||
494 | 494 | ||
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 DEFINE_PCI_DEVICE_TABLE(snd_cs4281_ids) = { |
498 | { PCI_VDEVICE(CIRRUS, 0x6005), 0, }, /* CS4281 */ | 498 | { PCI_VDEVICE(CIRRUS, 0x6005), 0, }, /* CS4281 */ |
499 | { 0, } | 499 | { 0, } |
500 | }; | 500 | }; |
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index 033aec430117..767fa7f06cd0 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c | |||
@@ -64,7 +64,7 @@ MODULE_PARM_DESC(thinkpad, "Force to enable Thinkpad's CLKRUN control."); | |||
64 | module_param_array(mmap_valid, bool, NULL, 0444); | 64 | 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 DEFINE_PCI_DEVICE_TABLE(snd_cs46xx_ids) = { |
68 | { PCI_VDEVICE(CIRRUS, 0x6001), 0, }, /* CS4280 */ | 68 | { PCI_VDEVICE(CIRRUS, 0x6001), 0, }, /* CS4280 */ |
69 | { PCI_VDEVICE(CIRRUS, 0x6003), 0, }, /* CS4612 */ | 69 | { PCI_VDEVICE(CIRRUS, 0x6003), 0, }, /* CS4612 */ |
70 | { PCI_VDEVICE(CIRRUS, 0x6004), 0, }, /* CS4615 */ | 70 | { PCI_VDEVICE(CIRRUS, 0x6004), 0, }, /* CS4615 */ |
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 1be96ead4244..3f99a5e8528c 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c | |||
@@ -2238,11 +2238,11 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97) | |||
2238 | 2238 | ||
2239 | /* set the desired CODEC mode */ | 2239 | /* set the desired CODEC mode */ |
2240 | if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) { | 2240 | if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) { |
2241 | snd_printdd("cs46xx: CODOEC1 mode %04x\n",0x0); | 2241 | snd_printdd("cs46xx: CODEC1 mode %04x\n", 0x0); |
2242 | snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x0); | 2242 | snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x0); |
2243 | } else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) { | 2243 | } else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) { |
2244 | snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3); | 2244 | snd_printdd("cs46xx: CODEC2 mode %04x\n", 0x3); |
2245 | snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3); | 2245 | snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x3); |
2246 | } else { | 2246 | } else { |
2247 | snd_BUG(); /* should never happen ... */ | 2247 | snd_BUG(); /* should never happen ... */ |
2248 | } | 2248 | } |
@@ -2266,7 +2266,7 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97) | |||
2266 | return; | 2266 | return; |
2267 | 2267 | ||
2268 | /* test if we can write to the record gain volume register */ | 2268 | /* test if we can write to the record gain volume register */ |
2269 | snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a05); | 2269 | snd_ac97_write(ac97, AC97_REC_GAIN, 0x8a05); |
2270 | if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05) | 2270 | if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05) |
2271 | return; | 2271 | return; |
2272 | 2272 | ||
@@ -3597,7 +3597,7 @@ static struct cs_card_type __devinitdata cards[] = { | |||
3597 | #ifdef CONFIG_PM | 3597 | #ifdef CONFIG_PM |
3598 | static unsigned int saved_regs[] = { | 3598 | static unsigned int saved_regs[] = { |
3599 | BA0_ACOSV, | 3599 | BA0_ACOSV, |
3600 | BA0_ASER_FADDR, | 3600 | /*BA0_ASER_FADDR,*/ |
3601 | BA0_ASER_MASTER, | 3601 | BA0_ASER_MASTER, |
3602 | BA1_PVOL, | 3602 | BA1_PVOL, |
3603 | BA1_CVOL, | 3603 | BA1_CVOL, |
@@ -3644,6 +3644,7 @@ int snd_cs46xx_resume(struct pci_dev *pci) | |||
3644 | #ifdef CONFIG_SND_CS46XX_NEW_DSP | 3644 | #ifdef CONFIG_SND_CS46XX_NEW_DSP |
3645 | int i; | 3645 | int i; |
3646 | #endif | 3646 | #endif |
3647 | unsigned int tmp; | ||
3647 | 3648 | ||
3648 | pci_set_power_state(pci, PCI_D0); | 3649 | pci_set_power_state(pci, PCI_D0); |
3649 | pci_restore_state(pci); | 3650 | pci_restore_state(pci); |
@@ -3685,6 +3686,15 @@ int snd_cs46xx_resume(struct pci_dev *pci) | |||
3685 | snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); | 3686 | snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); |
3686 | snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); | 3687 | snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); |
3687 | 3688 | ||
3689 | /* | ||
3690 | * Stop capture DMA. | ||
3691 | */ | ||
3692 | tmp = snd_cs46xx_peek(chip, BA1_CCTL); | ||
3693 | chip->capt.ctl = tmp & 0x0000ffff; | ||
3694 | snd_cs46xx_poke(chip, BA1_CCTL, tmp & 0xffff0000); | ||
3695 | |||
3696 | mdelay(5); | ||
3697 | |||
3688 | /* reset playback/capture */ | 3698 | /* reset playback/capture */ |
3689 | snd_cs46xx_set_play_sample_rate(chip, 8000); | 3699 | snd_cs46xx_set_play_sample_rate(chip, 8000); |
3690 | snd_cs46xx_set_capture_sample_rate(chip, 8000); | 3700 | snd_cs46xx_set_capture_sample_rate(chip, 8000); |
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index f4f0c8f5dad7..3e5ca8fb519f 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c | |||
@@ -298,6 +298,9 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) | |||
298 | if (ins->scbs[i].deleted) continue; | 298 | if (ins->scbs[i].deleted) continue; |
299 | 299 | ||
300 | cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); | 300 | cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); |
301 | #ifdef CONFIG_PM | ||
302 | kfree(ins->scbs[i].data); | ||
303 | #endif | ||
301 | } | 304 | } |
302 | 305 | ||
303 | kfree(ins->code.data); | 306 | kfree(ins->code.data); |
@@ -974,13 +977,11 @@ static struct dsp_scb_descriptor * _map_scb (struct snd_cs46xx *chip, char * nam | |||
974 | 977 | ||
975 | index = find_free_scb_index (ins); | 978 | index = find_free_scb_index (ins); |
976 | 979 | ||
980 | memset(&ins->scbs[index], 0, sizeof(ins->scbs[index])); | ||
977 | strcpy(ins->scbs[index].scb_name, name); | 981 | strcpy(ins->scbs[index].scb_name, name); |
978 | ins->scbs[index].address = dest; | 982 | ins->scbs[index].address = dest; |
979 | ins->scbs[index].index = index; | 983 | ins->scbs[index].index = index; |
980 | ins->scbs[index].proc_info = NULL; | ||
981 | ins->scbs[index].ref_count = 1; | 984 | ins->scbs[index].ref_count = 1; |
982 | ins->scbs[index].deleted = 0; | ||
983 | spin_lock_init(&ins->scbs[index].lock); | ||
984 | 985 | ||
985 | desc = (ins->scbs + index); | 986 | desc = (ins->scbs + index); |
986 | ins->scbs[index].scb_symbol = add_symbol (chip, name, dest, SYMBOL_PARAMETER); | 987 | ins->scbs[index].scb_symbol = add_symbol (chip, name, dest, SYMBOL_PARAMETER); |
@@ -1022,17 +1023,29 @@ _map_task_tree (struct snd_cs46xx *chip, char * name, u32 dest, u32 size) | |||
1022 | return desc; | 1023 | return desc; |
1023 | } | 1024 | } |
1024 | 1025 | ||
1026 | #define SCB_BYTES (0x10 * 4) | ||
1027 | |||
1025 | struct dsp_scb_descriptor * | 1028 | struct dsp_scb_descriptor * |
1026 | cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 dest) | 1029 | cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 dest) |
1027 | { | 1030 | { |
1028 | struct dsp_scb_descriptor * desc; | 1031 | struct dsp_scb_descriptor * desc; |
1029 | 1032 | ||
1033 | #ifdef CONFIG_PM | ||
1034 | /* copy the data for resume */ | ||
1035 | scb_data = kmemdup(scb_data, SCB_BYTES, GFP_KERNEL); | ||
1036 | if (!scb_data) | ||
1037 | return NULL; | ||
1038 | #endif | ||
1039 | |||
1030 | desc = _map_scb (chip,name,dest); | 1040 | desc = _map_scb (chip,name,dest); |
1031 | if (desc) { | 1041 | if (desc) { |
1032 | desc->data = scb_data; | 1042 | desc->data = scb_data; |
1033 | _dsp_create_scb(chip,scb_data,dest); | 1043 | _dsp_create_scb(chip,scb_data,dest); |
1034 | } else { | 1044 | } else { |
1035 | snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n"); | 1045 | snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n"); |
1046 | #ifdef CONFIG_PM | ||
1047 | kfree(scb_data); | ||
1048 | #endif | ||
1036 | } | 1049 | } |
1037 | 1050 | ||
1038 | return desc; | 1051 | return desc; |
@@ -1988,7 +2001,28 @@ int cs46xx_dsp_resume(struct snd_cs46xx * chip) | |||
1988 | continue; | 2001 | continue; |
1989 | _dsp_create_scb(chip, s->data, s->address); | 2002 | _dsp_create_scb(chip, s->data, s->address); |
1990 | } | 2003 | } |
1991 | 2004 | for (i = 0; i < ins->nscb; i++) { | |
2005 | struct dsp_scb_descriptor *s = &ins->scbs[i]; | ||
2006 | if (s->deleted) | ||
2007 | continue; | ||
2008 | if (s->updated) | ||
2009 | cs46xx_dsp_spos_update_scb(chip, s); | ||
2010 | if (s->volume_set) | ||
2011 | cs46xx_dsp_scb_set_volume(chip, s, | ||
2012 | s->volume[0], s->volume[1]); | ||
2013 | } | ||
2014 | if (ins->spdif_status_out & DSP_SPDIF_STATUS_HW_ENABLED) { | ||
2015 | cs46xx_dsp_enable_spdif_hw(chip); | ||
2016 | snd_cs46xx_poke(chip, (ins->ref_snoop_scb->address + 2) << 2, | ||
2017 | (OUTPUT_SNOOP_BUFFER + 0x10) << 0x10); | ||
2018 | if (ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN) | ||
2019 | cs46xx_poke_via_dsp(chip, SP_SPDOUT_CSUV, | ||
2020 | ins->spdif_csuv_stream); | ||
2021 | } | ||
2022 | if (chip->dsp_spos_instance->spdif_status_in) { | ||
2023 | cs46xx_poke_via_dsp(chip, SP_ASER_COUNTDOWN, 0x80000005); | ||
2024 | cs46xx_poke_via_dsp(chip, SP_SPDIN_CONTROL, 0x800003ff); | ||
2025 | } | ||
1992 | return 0; | 2026 | return 0; |
1993 | } | 2027 | } |
1994 | #endif | 2028 | #endif |
diff --git a/sound/pci/cs46xx/dsp_spos.h b/sound/pci/cs46xx/dsp_spos.h index f9e169d33c03..ca47a8114c7f 100644 --- a/sound/pci/cs46xx/dsp_spos.h +++ b/sound/pci/cs46xx/dsp_spos.h | |||
@@ -212,6 +212,7 @@ static inline void cs46xx_dsp_spos_update_scb (struct snd_cs46xx * chip, | |||
212 | (scb->address + SCBsubListPtr) << 2, | 212 | (scb->address + SCBsubListPtr) << 2, |
213 | (scb->sub_list_ptr->address << 0x10) | | 213 | (scb->sub_list_ptr->address << 0x10) | |
214 | (scb->next_scb_ptr->address)); | 214 | (scb->next_scb_ptr->address)); |
215 | scb->updated = 1; | ||
215 | } | 216 | } |
216 | 217 | ||
217 | static inline void cs46xx_dsp_scb_set_volume (struct snd_cs46xx * chip, | 218 | static inline void cs46xx_dsp_scb_set_volume (struct snd_cs46xx * chip, |
@@ -222,6 +223,9 @@ static inline void cs46xx_dsp_scb_set_volume (struct snd_cs46xx * chip, | |||
222 | 223 | ||
223 | snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl) << 2, val); | 224 | snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl) << 2, val); |
224 | snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl + 1) << 2, val); | 225 | snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl + 1) << 2, val); |
226 | scb->volume_set = 1; | ||
227 | scb->volume[0] = left; | ||
228 | scb->volume[1] = right; | ||
225 | } | 229 | } |
226 | #endif /* __DSP_SPOS_H__ */ | 230 | #endif /* __DSP_SPOS_H__ */ |
227 | #endif /* CONFIG_SND_CS46XX_NEW_DSP */ | 231 | #endif /* CONFIG_SND_CS46XX_NEW_DSP */ |
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index dd7c41b037b4..00b148a10239 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c | |||
@@ -115,7 +115,6 @@ static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry, | |||
115 | static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb) | 115 | static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb) |
116 | { | 116 | { |
117 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; | 117 | struct dsp_spos_instance * ins = chip->dsp_spos_instance; |
118 | unsigned long flags; | ||
119 | 118 | ||
120 | if ( scb->parent_scb_ptr ) { | 119 | if ( scb->parent_scb_ptr ) { |
121 | /* unlink parent SCB */ | 120 | /* unlink parent SCB */ |
@@ -153,8 +152,6 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor | |||
153 | scb->next_scb_ptr = ins->the_null_scb; | 152 | scb->next_scb_ptr = ins->the_null_scb; |
154 | } | 153 | } |
155 | 154 | ||
156 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
157 | |||
158 | /* update parent first entry in DSP RAM */ | 155 | /* update parent first entry in DSP RAM */ |
159 | cs46xx_dsp_spos_update_scb(chip,scb->parent_scb_ptr); | 156 | cs46xx_dsp_spos_update_scb(chip,scb->parent_scb_ptr); |
160 | 157 | ||
@@ -162,7 +159,6 @@ static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor | |||
162 | cs46xx_dsp_spos_update_scb(chip,scb); | 159 | cs46xx_dsp_spos_update_scb(chip,scb); |
163 | 160 | ||
164 | scb->parent_scb_ptr = NULL; | 161 | scb->parent_scb_ptr = NULL; |
165 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
166 | } | 162 | } |
167 | } | 163 | } |
168 | 164 | ||
@@ -197,9 +193,9 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * | |||
197 | goto _end; | 193 | goto _end; |
198 | #endif | 194 | #endif |
199 | 195 | ||
200 | spin_lock_irqsave(&scb->lock, flags); | 196 | spin_lock_irqsave(&chip->reg_lock, flags); |
201 | _dsp_unlink_scb (chip,scb); | 197 | _dsp_unlink_scb (chip,scb); |
202 | spin_unlock_irqrestore(&scb->lock, flags); | 198 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
203 | 199 | ||
204 | cs46xx_dsp_proc_free_scb_desc(scb); | 200 | cs46xx_dsp_proc_free_scb_desc(scb); |
205 | if (snd_BUG_ON(!scb->scb_symbol)) | 201 | if (snd_BUG_ON(!scb->scb_symbol)) |
@@ -207,6 +203,10 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * | |||
207 | remove_symbol (chip,scb->scb_symbol); | 203 | remove_symbol (chip,scb->scb_symbol); |
208 | 204 | ||
209 | ins->scbs[scb->index].deleted = 1; | 205 | ins->scbs[scb->index].deleted = 1; |
206 | #ifdef CONFIG_PM | ||
207 | kfree(ins->scbs[scb->index].data); | ||
208 | ins->scbs[scb->index].data = NULL; | ||
209 | #endif | ||
210 | 210 | ||
211 | if (scb->index < ins->scb_highest_frag_index) | 211 | if (scb->index < ins->scb_highest_frag_index) |
212 | ins->scb_highest_frag_index = scb->index; | 212 | ins->scb_highest_frag_index = scb->index; |
@@ -1508,20 +1508,17 @@ int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip, | |||
1508 | chip->dsp_spos_instance->npcm_channels <= 0)) | 1508 | chip->dsp_spos_instance->npcm_channels <= 0)) |
1509 | return -EIO; | 1509 | return -EIO; |
1510 | 1510 | ||
1511 | spin_lock(&pcm_channel->src_scb->lock); | 1511 | spin_lock_irqsave(&chip->reg_lock, flags); |
1512 | |||
1513 | if (pcm_channel->unlinked) { | 1512 | if (pcm_channel->unlinked) { |
1514 | spin_unlock(&pcm_channel->src_scb->lock); | 1513 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1515 | return -EIO; | 1514 | return -EIO; |
1516 | } | 1515 | } |
1517 | 1516 | ||
1518 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
1519 | pcm_channel->unlinked = 1; | 1517 | pcm_channel->unlinked = 1; |
1520 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
1521 | 1518 | ||
1522 | _dsp_unlink_scb (chip,pcm_channel->pcm_reader_scb); | 1519 | _dsp_unlink_scb (chip,pcm_channel->pcm_reader_scb); |
1520 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
1523 | 1521 | ||
1524 | spin_unlock(&pcm_channel->src_scb->lock); | ||
1525 | return 0; | 1522 | return 0; |
1526 | } | 1523 | } |
1527 | 1524 | ||
@@ -1533,10 +1530,10 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, | |||
1533 | struct dsp_scb_descriptor * src_scb = pcm_channel->src_scb; | 1530 | struct dsp_scb_descriptor * src_scb = pcm_channel->src_scb; |
1534 | unsigned long flags; | 1531 | unsigned long flags; |
1535 | 1532 | ||
1536 | spin_lock(&pcm_channel->src_scb->lock); | 1533 | spin_lock_irqsave(&chip->reg_lock, flags); |
1537 | 1534 | ||
1538 | if (pcm_channel->unlinked == 0) { | 1535 | if (pcm_channel->unlinked == 0) { |
1539 | spin_unlock(&pcm_channel->src_scb->lock); | 1536 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1540 | return -EIO; | 1537 | return -EIO; |
1541 | } | 1538 | } |
1542 | 1539 | ||
@@ -1552,8 +1549,6 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, | |||
1552 | snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr); | 1549 | snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr); |
1553 | pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb; | 1550 | pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb; |
1554 | 1551 | ||
1555 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
1556 | |||
1557 | /* update SCB entry in DSP RAM */ | 1552 | /* update SCB entry in DSP RAM */ |
1558 | cs46xx_dsp_spos_update_scb(chip,pcm_channel->pcm_reader_scb); | 1553 | cs46xx_dsp_spos_update_scb(chip,pcm_channel->pcm_reader_scb); |
1559 | 1554 | ||
@@ -1562,8 +1557,6 @@ int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, | |||
1562 | 1557 | ||
1563 | pcm_channel->unlinked = 0; | 1558 | pcm_channel->unlinked = 0; |
1564 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 1559 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
1565 | |||
1566 | spin_unlock(&pcm_channel->src_scb->lock); | ||
1567 | return 0; | 1560 | return 0; |
1568 | } | 1561 | } |
1569 | 1562 | ||
@@ -1596,13 +1589,17 @@ cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * s | |||
1596 | 1589 | ||
1597 | int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) | 1590 | int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) |
1598 | { | 1591 | { |
1592 | unsigned long flags; | ||
1593 | |||
1599 | if (snd_BUG_ON(!src->parent_scb_ptr)) | 1594 | if (snd_BUG_ON(!src->parent_scb_ptr)) |
1600 | return -EINVAL; | 1595 | return -EINVAL; |
1601 | 1596 | ||
1602 | /* mute SCB */ | 1597 | /* mute SCB */ |
1603 | cs46xx_dsp_scb_set_volume (chip,src,0,0); | 1598 | cs46xx_dsp_scb_set_volume (chip,src,0,0); |
1604 | 1599 | ||
1600 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
1605 | _dsp_unlink_scb (chip,src); | 1601 | _dsp_unlink_scb (chip,src); |
1602 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
1606 | 1603 | ||
1607 | return 0; | 1604 | return 0; |
1608 | } | 1605 | } |
diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c index dc464321d0f3..207479a641cf 100644 --- a/sound/pci/cs5530.c +++ b/sound/pci/cs5530.c | |||
@@ -58,7 +58,7 @@ struct snd_cs5530 { | |||
58 | unsigned long pci_base; | 58 | unsigned long pci_base; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | static struct pci_device_id snd_cs5530_ids[] = { | 61 | static DEFINE_PCI_DEVICE_TABLE(snd_cs5530_ids) = { |
62 | {PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO, PCI_ANY_ID, | 62 | {PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO, PCI_ANY_ID, |
63 | PCI_ANY_ID, 0, 0}, | 63 | PCI_ANY_ID, 0, 0}, |
64 | {0,} | 64 | {0,} |
diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 91e7faf69bbb..afb803708416 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c | |||
@@ -66,7 +66,7 @@ MODULE_PARM_DESC(id, "ID string for " DRIVER_NAME); | |||
66 | module_param_array(enable, bool, NULL, 0444); | 66 | module_param_array(enable, bool, NULL, 0444); |
67 | MODULE_PARM_DESC(enable, "Enable " DRIVER_NAME); | 67 | MODULE_PARM_DESC(enable, "Enable " DRIVER_NAME); |
68 | 68 | ||
69 | static struct pci_device_id snd_cs5535audio_ids[] = { | 69 | static DEFINE_PCI_DEVICE_TABLE(snd_cs5535audio_ids) = { |
70 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO) }, | 70 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO) }, |
71 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO) }, | 71 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO) }, |
72 | {} | 72 | {} |
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index cb65bd0dd35b..480cb1e905b6 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c | |||
@@ -166,18 +166,7 @@ static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
166 | 166 | ||
167 | static unsigned long atc_get_ptp_phys(struct ct_atc *atc, int index) | 167 | static unsigned long atc_get_ptp_phys(struct ct_atc *atc, int index) |
168 | { | 168 | { |
169 | struct ct_vm *vm; | 169 | return atc->vm->get_ptp_phys(atc->vm, index); |
170 | void *kvirt_addr; | ||
171 | unsigned long phys_addr; | ||
172 | |||
173 | vm = atc->vm; | ||
174 | kvirt_addr = vm->get_ptp_virt(vm, index); | ||
175 | if (kvirt_addr == NULL) | ||
176 | phys_addr = (~0UL); | ||
177 | else | ||
178 | phys_addr = virt_to_phys(kvirt_addr); | ||
179 | |||
180 | return phys_addr; | ||
181 | } | 170 | } |
182 | 171 | ||
183 | static unsigned int convert_format(snd_pcm_format_t snd_format) | 172 | static unsigned int convert_format(snd_pcm_format_t snd_format) |
@@ -1225,10 +1214,11 @@ static int atc_dev_free(struct snd_device *dev) | |||
1225 | return ct_atc_destroy(atc); | 1214 | return ct_atc_destroy(atc); |
1226 | } | 1215 | } |
1227 | 1216 | ||
1228 | static int __devinit atc_identify_card(struct ct_atc *atc) | 1217 | static int __devinit atc_identify_card(struct ct_atc *atc, unsigned int ssid) |
1229 | { | 1218 | { |
1230 | const struct snd_pci_quirk *p; | 1219 | const struct snd_pci_quirk *p; |
1231 | const struct snd_pci_quirk *list; | 1220 | const struct snd_pci_quirk *list; |
1221 | u16 vendor_id, device_id; | ||
1232 | 1222 | ||
1233 | switch (atc->chip_type) { | 1223 | switch (atc->chip_type) { |
1234 | case ATC20K1: | 1224 | case ATC20K1: |
@@ -1242,13 +1232,19 @@ static int __devinit atc_identify_card(struct ct_atc *atc) | |||
1242 | default: | 1232 | default: |
1243 | return -ENOENT; | 1233 | return -ENOENT; |
1244 | } | 1234 | } |
1245 | p = snd_pci_quirk_lookup(atc->pci, list); | 1235 | if (ssid) { |
1236 | vendor_id = ssid >> 16; | ||
1237 | device_id = ssid & 0xffff; | ||
1238 | } else { | ||
1239 | vendor_id = atc->pci->subsystem_vendor; | ||
1240 | device_id = atc->pci->subsystem_device; | ||
1241 | } | ||
1242 | p = snd_pci_quirk_lookup_id(vendor_id, device_id, list); | ||
1246 | if (p) { | 1243 | if (p) { |
1247 | if (p->value < 0) { | 1244 | if (p->value < 0) { |
1248 | printk(KERN_ERR "ctxfi: " | 1245 | printk(KERN_ERR "ctxfi: " |
1249 | "Device %04x:%04x is black-listed\n", | 1246 | "Device %04x:%04x is black-listed\n", |
1250 | atc->pci->subsystem_vendor, | 1247 | vendor_id, device_id); |
1251 | atc->pci->subsystem_device); | ||
1252 | return -ENOENT; | 1248 | return -ENOENT; |
1253 | } | 1249 | } |
1254 | atc->model = p->value; | 1250 | atc->model = p->value; |
@@ -1261,8 +1257,7 @@ static int __devinit atc_identify_card(struct ct_atc *atc) | |||
1261 | atc->model_name = ct_subsys_name[atc->model]; | 1257 | atc->model_name = ct_subsys_name[atc->model]; |
1262 | snd_printd("ctxfi: chip %s model %s (%04x:%04x) is found\n", | 1258 | snd_printd("ctxfi: chip %s model %s (%04x:%04x) is found\n", |
1263 | atc->chip_name, atc->model_name, | 1259 | atc->chip_name, atc->model_name, |
1264 | atc->pci->subsystem_vendor, | 1260 | vendor_id, device_id); |
1265 | atc->pci->subsystem_device); | ||
1266 | return 0; | 1261 | return 0; |
1267 | } | 1262 | } |
1268 | 1263 | ||
@@ -1636,7 +1631,8 @@ static struct ct_atc atc_preset __devinitdata = { | |||
1636 | 1631 | ||
1637 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | 1632 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, |
1638 | unsigned int rsr, unsigned int msr, | 1633 | unsigned int rsr, unsigned int msr, |
1639 | int chip_type, struct ct_atc **ratc) | 1634 | int chip_type, unsigned int ssid, |
1635 | struct ct_atc **ratc) | ||
1640 | { | 1636 | { |
1641 | struct ct_atc *atc; | 1637 | struct ct_atc *atc; |
1642 | static struct snd_device_ops ops = { | 1638 | static struct snd_device_ops ops = { |
@@ -1662,14 +1658,14 @@ int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | |||
1662 | mutex_init(&atc->atc_mutex); | 1658 | mutex_init(&atc->atc_mutex); |
1663 | 1659 | ||
1664 | /* Find card model */ | 1660 | /* Find card model */ |
1665 | err = atc_identify_card(atc); | 1661 | err = atc_identify_card(atc, ssid); |
1666 | if (err < 0) { | 1662 | if (err < 0) { |
1667 | printk(KERN_ERR "ctatc: Card not recognised\n"); | 1663 | printk(KERN_ERR "ctatc: Card not recognised\n"); |
1668 | goto error1; | 1664 | goto error1; |
1669 | } | 1665 | } |
1670 | 1666 | ||
1671 | /* Set up device virtual memory management object */ | 1667 | /* Set up device virtual memory management object */ |
1672 | err = ct_vm_create(&atc->vm); | 1668 | err = ct_vm_create(&atc->vm, pci); |
1673 | if (err < 0) | 1669 | if (err < 0) |
1674 | goto error1; | 1670 | goto error1; |
1675 | 1671 | ||
diff --git a/sound/pci/ctxfi/ctatc.h b/sound/pci/ctxfi/ctatc.h index 9fd8a5708943..7167c0185d52 100644 --- a/sound/pci/ctxfi/ctatc.h +++ b/sound/pci/ctxfi/ctatc.h | |||
@@ -148,7 +148,7 @@ struct ct_atc { | |||
148 | 148 | ||
149 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | 149 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, |
150 | unsigned int rsr, unsigned int msr, int chip_type, | 150 | unsigned int rsr, unsigned int msr, int chip_type, |
151 | struct ct_atc **ratc); | 151 | unsigned int subsysid, struct ct_atc **ratc); |
152 | int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc); | 152 | int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc); |
153 | 153 | ||
154 | #endif /* CTATC_H */ | 154 | #endif /* CTATC_H */ |
diff --git a/sound/pci/ctxfi/ctvmem.c b/sound/pci/ctxfi/ctvmem.c index 6b78752e9503..65da6e466f80 100644 --- a/sound/pci/ctxfi/ctvmem.c +++ b/sound/pci/ctxfi/ctvmem.c | |||
@@ -138,7 +138,7 @@ ct_vm_map(struct ct_vm *vm, struct snd_pcm_substream *substream, int size) | |||
138 | return NULL; | 138 | return NULL; |
139 | } | 139 | } |
140 | 140 | ||
141 | ptp = vm->ptp[0]; | 141 | ptp = (unsigned long *)vm->ptp[0].area; |
142 | pte_start = (block->addr >> CT_PAGE_SHIFT); | 142 | pte_start = (block->addr >> CT_PAGE_SHIFT); |
143 | pages = block->size >> CT_PAGE_SHIFT; | 143 | pages = block->size >> CT_PAGE_SHIFT; |
144 | for (i = 0; i < pages; i++) { | 144 | for (i = 0; i < pages; i++) { |
@@ -158,25 +158,25 @@ static void ct_vm_unmap(struct ct_vm *vm, struct ct_vm_block *block) | |||
158 | } | 158 | } |
159 | 159 | ||
160 | /* * | 160 | /* * |
161 | * return the host (kmalloced) addr of the @index-th device | 161 | * return the host physical addr of the @index-th device |
162 | * page talbe page on success, or NULL on failure. | 162 | * page table page on success, or ~0UL on failure. |
163 | * The first returned NULL indicates the termination. | 163 | * The first returned ~0UL indicates the termination. |
164 | * */ | 164 | * */ |
165 | static void * | 165 | static dma_addr_t |
166 | ct_get_ptp_virt(struct ct_vm *vm, int index) | 166 | ct_get_ptp_phys(struct ct_vm *vm, int index) |
167 | { | 167 | { |
168 | void *addr; | 168 | dma_addr_t addr; |
169 | 169 | ||
170 | addr = (index >= CT_PTP_NUM) ? NULL : vm->ptp[index]; | 170 | addr = (index >= CT_PTP_NUM) ? ~0UL : vm->ptp[index].addr; |
171 | 171 | ||
172 | return addr; | 172 | return addr; |
173 | } | 173 | } |
174 | 174 | ||
175 | int ct_vm_create(struct ct_vm **rvm) | 175 | int ct_vm_create(struct ct_vm **rvm, struct pci_dev *pci) |
176 | { | 176 | { |
177 | struct ct_vm *vm; | 177 | struct ct_vm *vm; |
178 | struct ct_vm_block *block; | 178 | struct ct_vm_block *block; |
179 | int i; | 179 | int i, err = 0; |
180 | 180 | ||
181 | *rvm = NULL; | 181 | *rvm = NULL; |
182 | 182 | ||
@@ -188,23 +188,21 @@ int ct_vm_create(struct ct_vm **rvm) | |||
188 | 188 | ||
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 | err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, |
192 | if (!vm->ptp[i]) | 192 | snd_dma_pci_data(pci), |
193 | PAGE_SIZE, &vm->ptp[i]); | ||
194 | if (err < 0) | ||
193 | break; | 195 | break; |
194 | } | 196 | } |
195 | if (!i) { | 197 | if (err < 0) { |
196 | /* no page table pages are allocated */ | 198 | /* no page table pages are allocated */ |
197 | kfree(vm); | 199 | ct_vm_destroy(vm); |
198 | return -ENOMEM; | 200 | return -ENOMEM; |
199 | } | 201 | } |
200 | vm->size = CT_ADDRS_PER_PAGE * i; | 202 | vm->size = CT_ADDRS_PER_PAGE * i; |
201 | /* Initialise remaining ptps */ | ||
202 | for (; i < CT_PTP_NUM; i++) | ||
203 | vm->ptp[i] = NULL; | ||
204 | |||
205 | vm->map = ct_vm_map; | 203 | vm->map = ct_vm_map; |
206 | vm->unmap = ct_vm_unmap; | 204 | vm->unmap = ct_vm_unmap; |
207 | vm->get_ptp_virt = ct_get_ptp_virt; | 205 | vm->get_ptp_phys = ct_get_ptp_phys; |
208 | INIT_LIST_HEAD(&vm->unused); | 206 | INIT_LIST_HEAD(&vm->unused); |
209 | INIT_LIST_HEAD(&vm->used); | 207 | INIT_LIST_HEAD(&vm->used); |
210 | block = kzalloc(sizeof(*block), GFP_KERNEL); | 208 | block = kzalloc(sizeof(*block), GFP_KERNEL); |
@@ -242,7 +240,7 @@ void ct_vm_destroy(struct ct_vm *vm) | |||
242 | 240 | ||
243 | /* free allocated page table pages */ | 241 | /* free allocated page table pages */ |
244 | for (i = 0; i < CT_PTP_NUM; i++) | 242 | for (i = 0; i < CT_PTP_NUM; i++) |
245 | kfree(vm->ptp[i]); | 243 | snd_dma_free_pages(&vm->ptp[i]); |
246 | 244 | ||
247 | vm->size = 0; | 245 | vm->size = 0; |
248 | 246 | ||
diff --git a/sound/pci/ctxfi/ctvmem.h b/sound/pci/ctxfi/ctvmem.h index 01e4fd0386a3..b23adfca4de6 100644 --- a/sound/pci/ctxfi/ctvmem.h +++ b/sound/pci/ctxfi/ctvmem.h | |||
@@ -22,6 +22,8 @@ | |||
22 | 22 | ||
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <linux/pci.h> | ||
26 | #include <sound/memalloc.h> | ||
25 | 27 | ||
26 | /* The chip can handle the page table of 4k pages | 28 | /* The chip can handle the page table of 4k pages |
27 | * (emu20k1 can handle even 8k pages, but we don't use it right now) | 29 | * (emu20k1 can handle even 8k pages, but we don't use it right now) |
@@ -41,7 +43,7 @@ struct snd_pcm_substream; | |||
41 | 43 | ||
42 | /* Virtual memory management object for card device */ | 44 | /* Virtual memory management object for card device */ |
43 | struct ct_vm { | 45 | struct ct_vm { |
44 | void *ptp[CT_PTP_NUM]; /* Device page table pages */ | 46 | struct snd_dma_buffer ptp[CT_PTP_NUM]; /* Device page table pages */ |
45 | unsigned int size; /* Available addr space in bytes */ | 47 | unsigned int size; /* Available addr space in bytes */ |
46 | struct list_head unused; /* List of unused blocks */ | 48 | struct list_head unused; /* List of unused blocks */ |
47 | struct list_head used; /* List of used blocks */ | 49 | struct list_head used; /* List of used blocks */ |
@@ -52,10 +54,10 @@ struct ct_vm { | |||
52 | int size); | 54 | int size); |
53 | /* Unmap device logical addr area. */ | 55 | /* Unmap device logical addr area. */ |
54 | void (*unmap)(struct ct_vm *, struct ct_vm_block *block); | 56 | void (*unmap)(struct ct_vm *, struct ct_vm_block *block); |
55 | void *(*get_ptp_virt)(struct ct_vm *vm, int index); | 57 | dma_addr_t (*get_ptp_phys)(struct ct_vm *vm, int index); |
56 | }; | 58 | }; |
57 | 59 | ||
58 | int ct_vm_create(struct ct_vm **rvm); | 60 | int ct_vm_create(struct ct_vm **rvm, struct pci_dev *pci); |
59 | void ct_vm_destroy(struct ct_vm *vm); | 61 | void ct_vm_destroy(struct ct_vm *vm); |
60 | 62 | ||
61 | #endif /* CTVMEM_H */ | 63 | #endif /* CTVMEM_H */ |
diff --git a/sound/pci/ctxfi/xfi.c b/sound/pci/ctxfi/xfi.c index 76541748e7bc..f42e7e1a1074 100644 --- a/sound/pci/ctxfi/xfi.c +++ b/sound/pci/ctxfi/xfi.c | |||
@@ -32,6 +32,7 @@ module_param(multiple, uint, S_IRUGO); | |||
32 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | 32 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
33 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; | 33 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
34 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; | 34 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; |
35 | static unsigned int subsystem[SNDRV_CARDS]; | ||
35 | 36 | ||
36 | module_param_array(index, int, NULL, 0444); | 37 | module_param_array(index, int, NULL, 0444); |
37 | MODULE_PARM_DESC(index, "Index value for Creative X-Fi driver"); | 38 | MODULE_PARM_DESC(index, "Index value for Creative X-Fi driver"); |
@@ -39,8 +40,10 @@ module_param_array(id, charp, NULL, 0444); | |||
39 | MODULE_PARM_DESC(id, "ID string for Creative X-Fi driver"); | 40 | MODULE_PARM_DESC(id, "ID string for Creative X-Fi driver"); |
40 | module_param_array(enable, bool, NULL, 0444); | 41 | module_param_array(enable, bool, NULL, 0444); |
41 | MODULE_PARM_DESC(enable, "Enable Creative X-Fi driver"); | 42 | MODULE_PARM_DESC(enable, "Enable Creative X-Fi driver"); |
43 | module_param_array(subsystem, int, NULL, 0444); | ||
44 | MODULE_PARM_DESC(subsystem, "Override subsystem ID for Creative X-Fi driver"); | ||
42 | 45 | ||
43 | static struct pci_device_id ct_pci_dev_ids[] = { | 46 | static DEFINE_PCI_DEVICE_TABLE(ct_pci_dev_ids) = { |
44 | /* only X-Fi is supported, so... */ | 47 | /* only X-Fi is supported, so... */ |
45 | { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K1), | 48 | { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K1), |
46 | .driver_data = ATC20K1, | 49 | .driver_data = ATC20K1, |
@@ -85,7 +88,7 @@ ct_card_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
85 | multiple = 2; | 88 | multiple = 2; |
86 | } | 89 | } |
87 | err = ct_atc_create(card, pci, reference_rate, multiple, | 90 | err = ct_atc_create(card, pci, reference_rate, multiple, |
88 | pci_id->driver_data, &atc); | 91 | pci_id->driver_data, subsystem[dev], &atc); |
89 | if (err < 0) | 92 | if (err < 0) |
90 | goto error; | 93 | goto error; |
91 | 94 | ||
diff --git a/sound/pci/echoaudio/darla20.c b/sound/pci/echoaudio/darla20.c index 8c6db3aa3c1a..a65bafe0800f 100644 --- a/sound/pci/echoaudio/darla20.c +++ b/sound/pci/echoaudio/darla20.c | |||
@@ -63,7 +63,7 @@ static const struct firmware card_fw[] = { | |||
63 | {0, "darla20_dsp.fw"} | 63 | {0, "darla20_dsp.fw"} |
64 | }; | 64 | }; |
65 | 65 | ||
66 | static struct pci_device_id snd_echo_ids[] = { | 66 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
67 | {0x1057, 0x1801, 0xECC0, 0x0010, 0, 0, 0}, /* DSP 56301 Darla20 rev.0 */ | 67 | {0x1057, 0x1801, 0xECC0, 0x0010, 0, 0, 0}, /* DSP 56301 Darla20 rev.0 */ |
68 | {0,} | 68 | {0,} |
69 | }; | 69 | }; |
diff --git a/sound/pci/echoaudio/darla20_dsp.c b/sound/pci/echoaudio/darla20_dsp.c index 29043301ebb8..20c7cbc89bb3 100644 --- a/sound/pci/echoaudio/darla20_dsp.c +++ b/sound/pci/echoaudio/darla20_dsp.c | |||
@@ -45,7 +45,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
45 | chip->device_id = device_id; | 45 | chip->device_id = device_id; |
46 | chip->subdevice_id = subdevice_id; | 46 | chip->subdevice_id = subdevice_id; |
47 | chip->bad_board = TRUE; | 47 | chip->bad_board = TRUE; |
48 | chip->dsp_code_to_load = &card_fw[FW_DARLA20_DSP]; | 48 | chip->dsp_code_to_load = FW_DARLA20_DSP; |
49 | chip->spdif_status = GD_SPDIF_STATUS_UNDEF; | 49 | chip->spdif_status = GD_SPDIF_STATUS_UNDEF; |
50 | chip->clock_state = GD_CLOCK_UNDEF; | 50 | chip->clock_state = GD_CLOCK_UNDEF; |
51 | /* Since this card has no ASIC, mark it as loaded so everything | 51 | /* Since this card has no ASIC, mark it as loaded so everything |
@@ -57,15 +57,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
57 | return err; | 57 | return err; |
58 | chip->bad_board = FALSE; | 58 | chip->bad_board = FALSE; |
59 | 59 | ||
60 | if ((err = init_line_levels(chip)) < 0) | ||
61 | return err; | ||
62 | |||
63 | DE_INIT(("init_hw done\n")); | 60 | DE_INIT(("init_hw done\n")); |
64 | return err; | 61 | return err; |
65 | } | 62 | } |
66 | 63 | ||
67 | 64 | ||
68 | 65 | ||
66 | static int set_mixer_defaults(struct echoaudio *chip) | ||
67 | { | ||
68 | return init_line_levels(chip); | ||
69 | } | ||
70 | |||
71 | |||
72 | |||
69 | /* The Darla20 has no external clock sources */ | 73 | /* The Darla20 has no external clock sources */ |
70 | static u32 detect_input_clocks(const struct echoaudio *chip) | 74 | static u32 detect_input_clocks(const struct echoaudio *chip) |
71 | { | 75 | { |
diff --git a/sound/pci/echoaudio/darla24.c b/sound/pci/echoaudio/darla24.c index 04cbf3eaf05a..0a6c50bcd758 100644 --- a/sound/pci/echoaudio/darla24.c +++ b/sound/pci/echoaudio/darla24.c | |||
@@ -67,7 +67,7 @@ static const struct firmware card_fw[] = { | |||
67 | {0, "darla24_dsp.fw"} | 67 | {0, "darla24_dsp.fw"} |
68 | }; | 68 | }; |
69 | 69 | ||
70 | static struct pci_device_id snd_echo_ids[] = { | 70 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
71 | {0x1057, 0x1801, 0xECC0, 0x0040, 0, 0, 0}, /* DSP 56301 Darla24 rev.0 */ | 71 | {0x1057, 0x1801, 0xECC0, 0x0040, 0, 0, 0}, /* DSP 56301 Darla24 rev.0 */ |
72 | {0x1057, 0x1801, 0xECC0, 0x0041, 0, 0, 0}, /* DSP 56301 Darla24 rev.1 */ | 72 | {0x1057, 0x1801, 0xECC0, 0x0041, 0, 0, 0}, /* DSP 56301 Darla24 rev.1 */ |
73 | {0,} | 73 | {0,} |
diff --git a/sound/pci/echoaudio/darla24_dsp.c b/sound/pci/echoaudio/darla24_dsp.c index 60228731841f..6da6663e9176 100644 --- a/sound/pci/echoaudio/darla24_dsp.c +++ b/sound/pci/echoaudio/darla24_dsp.c | |||
@@ -45,7 +45,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
45 | chip->device_id = device_id; | 45 | chip->device_id = device_id; |
46 | chip->subdevice_id = subdevice_id; | 46 | chip->subdevice_id = subdevice_id; |
47 | chip->bad_board = TRUE; | 47 | chip->bad_board = TRUE; |
48 | chip->dsp_code_to_load = &card_fw[FW_DARLA24_DSP]; | 48 | chip->dsp_code_to_load = FW_DARLA24_DSP; |
49 | /* Since this card has no ASIC, mark it as loaded so everything | 49 | /* Since this card has no ASIC, mark it as loaded so everything |
50 | works OK */ | 50 | works OK */ |
51 | chip->asic_loaded = TRUE; | 51 | chip->asic_loaded = TRUE; |
@@ -56,15 +56,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
56 | return err; | 56 | return err; |
57 | chip->bad_board = FALSE; | 57 | chip->bad_board = FALSE; |
58 | 58 | ||
59 | if ((err = init_line_levels(chip)) < 0) | ||
60 | return err; | ||
61 | |||
62 | DE_INIT(("init_hw done\n")); | 59 | DE_INIT(("init_hw done\n")); |
63 | return err; | 60 | return err; |
64 | } | 61 | } |
65 | 62 | ||
66 | 63 | ||
67 | 64 | ||
65 | static int set_mixer_defaults(struct echoaudio *chip) | ||
66 | { | ||
67 | return init_line_levels(chip); | ||
68 | } | ||
69 | |||
70 | |||
71 | |||
68 | static u32 detect_input_clocks(const struct echoaudio *chip) | 72 | static u32 detect_input_clocks(const struct echoaudio *chip) |
69 | { | 73 | { |
70 | u32 clocks_from_dsp, clock_bits; | 74 | u32 clocks_from_dsp, clock_bits; |
diff --git a/sound/pci/echoaudio/echo3g.c b/sound/pci/echoaudio/echo3g.c index 4022e43a0053..f5142796989b 100644 --- a/sound/pci/echoaudio/echo3g.c +++ b/sound/pci/echoaudio/echo3g.c | |||
@@ -81,7 +81,7 @@ static const struct firmware card_fw[] = { | |||
81 | {0, "3g_asic.fw"} | 81 | {0, "3g_asic.fw"} |
82 | }; | 82 | }; |
83 | 83 | ||
84 | static struct pci_device_id snd_echo_ids[] = { | 84 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
85 | {0x1057, 0x3410, 0xECC0, 0x0100, 0, 0, 0}, /* Echo 3G */ | 85 | {0x1057, 0x3410, 0xECC0, 0x0100, 0, 0, 0}, /* Echo 3G */ |
86 | {0,} | 86 | {0,} |
87 | }; | 87 | }; |
diff --git a/sound/pci/echoaudio/echo3g_dsp.c b/sound/pci/echoaudio/echo3g_dsp.c index 57967e580571..3cdc2ee2d1dd 100644 --- a/sound/pci/echoaudio/echo3g_dsp.c +++ b/sound/pci/echoaudio/echo3g_dsp.c | |||
@@ -61,7 +61,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
61 | chip->subdevice_id = subdevice_id; | 61 | chip->subdevice_id = subdevice_id; |
62 | chip->bad_board = TRUE; | 62 | chip->bad_board = TRUE; |
63 | chip->has_midi = TRUE; | 63 | chip->has_midi = TRUE; |
64 | chip->dsp_code_to_load = &card_fw[FW_ECHO3G_DSP]; | 64 | chip->dsp_code_to_load = FW_ECHO3G_DSP; |
65 | 65 | ||
66 | /* Load the DSP code and the ASIC on the PCI card and get | 66 | /* Load the DSP code and the ASIC on the PCI card and get |
67 | what type of external box is attached */ | 67 | what type of external box is attached */ |
@@ -97,20 +97,6 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
97 | chip->digital_modes = ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | | 97 | chip->digital_modes = ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | |
98 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | | 98 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | |
99 | ECHOCAPS_HAS_DIGITAL_MODE_ADAT; | 99 | ECHOCAPS_HAS_DIGITAL_MODE_ADAT; |
100 | chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; | ||
101 | chip->professional_spdif = FALSE; | ||
102 | chip->non_audio_spdif = FALSE; | ||
103 | chip->bad_board = FALSE; | ||
104 | |||
105 | if ((err = init_line_levels(chip)) < 0) | ||
106 | return err; | ||
107 | err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); | ||
108 | if (err < 0) | ||
109 | return err; | ||
110 | err = set_phantom_power(chip, 0); | ||
111 | if (err < 0) | ||
112 | return err; | ||
113 | err = set_professional_spdif(chip, TRUE); | ||
114 | 100 | ||
115 | DE_INIT(("init_hw done\n")); | 101 | DE_INIT(("init_hw done\n")); |
116 | return err; | 102 | return err; |
@@ -118,6 +104,18 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
118 | 104 | ||
119 | 105 | ||
120 | 106 | ||
107 | static int set_mixer_defaults(struct echoaudio *chip) | ||
108 | { | ||
109 | chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; | ||
110 | chip->professional_spdif = FALSE; | ||
111 | chip->non_audio_spdif = FALSE; | ||
112 | chip->bad_board = FALSE; | ||
113 | chip->phantom_power = FALSE; | ||
114 | return init_line_levels(chip); | ||
115 | } | ||
116 | |||
117 | |||
118 | |||
121 | static int set_phantom_power(struct echoaudio *chip, char on) | 119 | static int set_phantom_power(struct echoaudio *chip, char on) |
122 | { | 120 | { |
123 | u32 control_reg = le32_to_cpu(chip->comm_page->control_register); | 121 | u32 control_reg = le32_to_cpu(chip->comm_page->control_register); |
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 1305f7ca02c3..8dab82d7d19d 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c | |||
@@ -36,22 +36,61 @@ MODULE_PARM_DESC(enable, "Enable " ECHOCARD_NAME " soundcard."); | |||
36 | static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999}; | 36 | static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999}; |
37 | static const DECLARE_TLV_DB_SCALE(db_scale_output_gain, -12800, 100, 1); | 37 | static const DECLARE_TLV_DB_SCALE(db_scale_output_gain, -12800, 100, 1); |
38 | 38 | ||
39 | |||
40 | |||
39 | static int get_firmware(const struct firmware **fw_entry, | 41 | static int get_firmware(const struct firmware **fw_entry, |
40 | const struct firmware *frm, struct echoaudio *chip) | 42 | struct echoaudio *chip, const short fw_index) |
41 | { | 43 | { |
42 | int err; | 44 | int err; |
43 | char name[30]; | 45 | char name[30]; |
44 | DE_ACT(("firmware requested: %s\n", frm->data)); | 46 | |
45 | snprintf(name, sizeof(name), "ea/%s", frm->data); | 47 | #ifdef CONFIG_PM |
46 | if ((err = request_firmware(fw_entry, name, pci_device(chip))) < 0) | 48 | if (chip->fw_cache[fw_index]) { |
49 | DE_ACT(("firmware requested: %s is cached\n", card_fw[fw_index].data)); | ||
50 | *fw_entry = chip->fw_cache[fw_index]; | ||
51 | return 0; | ||
52 | } | ||
53 | #endif | ||
54 | |||
55 | DE_ACT(("firmware requested: %s\n", card_fw[fw_index].data)); | ||
56 | snprintf(name, sizeof(name), "ea/%s", card_fw[fw_index].data); | ||
57 | err = request_firmware(fw_entry, name, pci_device(chip)); | ||
58 | if (err < 0) | ||
47 | snd_printk(KERN_ERR "get_firmware(): Firmware not available (%d)\n", err); | 59 | snd_printk(KERN_ERR "get_firmware(): Firmware not available (%d)\n", err); |
60 | #ifdef CONFIG_PM | ||
61 | else | ||
62 | chip->fw_cache[fw_index] = *fw_entry; | ||
63 | #endif | ||
48 | return err; | 64 | return err; |
49 | } | 65 | } |
50 | 66 | ||
67 | |||
68 | |||
51 | static void free_firmware(const struct firmware *fw_entry) | 69 | static void free_firmware(const struct firmware *fw_entry) |
52 | { | 70 | { |
71 | #ifdef CONFIG_PM | ||
72 | DE_ACT(("firmware not released (kept in cache)\n")); | ||
73 | #else | ||
53 | release_firmware(fw_entry); | 74 | release_firmware(fw_entry); |
54 | DE_ACT(("firmware released\n")); | 75 | DE_ACT(("firmware released\n")); |
76 | #endif | ||
77 | } | ||
78 | |||
79 | |||
80 | |||
81 | static void free_firmware_cache(struct echoaudio *chip) | ||
82 | { | ||
83 | #ifdef CONFIG_PM | ||
84 | int i; | ||
85 | |||
86 | for (i = 0; i < 8 ; i++) | ||
87 | if (chip->fw_cache[i]) { | ||
88 | release_firmware(chip->fw_cache[i]); | ||
89 | DE_ACT(("release_firmware(%d)\n", i)); | ||
90 | } | ||
91 | |||
92 | DE_ACT(("firmware_cache released\n")); | ||
93 | #endif | ||
55 | } | 94 | } |
56 | 95 | ||
57 | 96 | ||
@@ -714,6 +753,8 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
714 | 753 | ||
715 | spin_lock(&chip->lock); | 754 | spin_lock(&chip->lock); |
716 | switch (cmd) { | 755 | switch (cmd) { |
756 | case SNDRV_PCM_TRIGGER_RESUME: | ||
757 | DE_ACT(("pcm_trigger resume\n")); | ||
717 | case SNDRV_PCM_TRIGGER_START: | 758 | case SNDRV_PCM_TRIGGER_START: |
718 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 759 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
719 | DE_ACT(("pcm_trigger start\n")); | 760 | DE_ACT(("pcm_trigger start\n")); |
@@ -737,6 +778,8 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
737 | err = start_transport(chip, channelmask, | 778 | err = start_transport(chip, channelmask, |
738 | chip->pipe_cyclic_mask); | 779 | chip->pipe_cyclic_mask); |
739 | break; | 780 | break; |
781 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
782 | DE_ACT(("pcm_trigger suspend\n")); | ||
740 | case SNDRV_PCM_TRIGGER_STOP: | 783 | case SNDRV_PCM_TRIGGER_STOP: |
741 | DE_ACT(("pcm_trigger stop\n")); | 784 | DE_ACT(("pcm_trigger stop\n")); |
742 | for (i = 0; i < DSP_MAXPIPES; i++) { | 785 | for (i = 0; i < DSP_MAXPIPES; i++) { |
@@ -1821,7 +1864,9 @@ static irqreturn_t snd_echo_interrupt(int irq, void *dev_id) | |||
1821 | /* The hardware doesn't tell us which substream caused the irq, | 1864 | /* The hardware doesn't tell us which substream caused the irq, |
1822 | thus we have to check all running substreams. */ | 1865 | thus we have to check all running substreams. */ |
1823 | for (ss = 0; ss < DSP_MAXPIPES; ss++) { | 1866 | for (ss = 0; ss < DSP_MAXPIPES; ss++) { |
1824 | if ((substream = chip->substream[ss])) { | 1867 | substream = chip->substream[ss]; |
1868 | if (substream && ((struct audiopipe *)substream->runtime-> | ||
1869 | private_data)->state == PIPE_STATE_STARTED) { | ||
1825 | period = pcm_pointer(substream) / | 1870 | period = pcm_pointer(substream) / |
1826 | substream->runtime->period_size; | 1871 | substream->runtime->period_size; |
1827 | if (period != chip->last_period[ss]) { | 1872 | if (period != chip->last_period[ss]) { |
@@ -1874,6 +1919,7 @@ static int snd_echo_free(struct echoaudio *chip) | |||
1874 | pci_disable_device(chip->pci); | 1919 | pci_disable_device(chip->pci); |
1875 | 1920 | ||
1876 | /* release chip data */ | 1921 | /* release chip data */ |
1922 | free_firmware_cache(chip); | ||
1877 | kfree(chip); | 1923 | kfree(chip); |
1878 | DE_INIT(("Chip freed.\n")); | 1924 | DE_INIT(("Chip freed.\n")); |
1879 | return 0; | 1925 | return 0; |
@@ -1911,18 +1957,27 @@ static __devinit int snd_echo_create(struct snd_card *card, | |||
1911 | return err; | 1957 | return err; |
1912 | pci_set_master(pci); | 1958 | pci_set_master(pci); |
1913 | 1959 | ||
1914 | /* allocate a chip-specific data */ | 1960 | /* Allocate chip if needed */ |
1915 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 1961 | if (!*rchip) { |
1916 | if (!chip) { | 1962 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
1917 | pci_disable_device(pci); | 1963 | if (!chip) { |
1918 | return -ENOMEM; | 1964 | pci_disable_device(pci); |
1965 | return -ENOMEM; | ||
1966 | } | ||
1967 | DE_INIT(("chip=%p\n", chip)); | ||
1968 | spin_lock_init(&chip->lock); | ||
1969 | chip->card = card; | ||
1970 | chip->pci = pci; | ||
1971 | chip->irq = -1; | ||
1972 | atomic_set(&chip->opencount, 0); | ||
1973 | mutex_init(&chip->mode_mutex); | ||
1974 | chip->can_set_rate = 1; | ||
1975 | } else { | ||
1976 | /* If this was called from the resume function, chip is | ||
1977 | * already allocated and it contains current card settings. | ||
1978 | */ | ||
1979 | chip = *rchip; | ||
1919 | } | 1980 | } |
1920 | DE_INIT(("chip=%p\n", chip)); | ||
1921 | |||
1922 | spin_lock_init(&chip->lock); | ||
1923 | chip->card = card; | ||
1924 | chip->pci = pci; | ||
1925 | chip->irq = -1; | ||
1926 | 1981 | ||
1927 | /* PCI resource allocation */ | 1982 | /* PCI resource allocation */ |
1928 | chip->dsp_registers_phys = pci_resource_start(pci, 0); | 1983 | chip->dsp_registers_phys = pci_resource_start(pci, 0); |
@@ -1962,7 +2017,9 @@ static __devinit int snd_echo_create(struct snd_card *card, | |||
1962 | chip->comm_page = (struct comm_page *)chip->commpage_dma_buf.area; | 2017 | chip->comm_page = (struct comm_page *)chip->commpage_dma_buf.area; |
1963 | 2018 | ||
1964 | err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); | 2019 | err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); |
1965 | if (err) { | 2020 | if (err >= 0) |
2021 | err = set_mixer_defaults(chip); | ||
2022 | if (err < 0) { | ||
1966 | DE_INIT(("init_hw err=%d\n", err)); | 2023 | DE_INIT(("init_hw err=%d\n", err)); |
1967 | snd_echo_free(chip); | 2024 | snd_echo_free(chip); |
1968 | return err; | 2025 | return err; |
@@ -1973,9 +2030,6 @@ static __devinit int snd_echo_create(struct snd_card *card, | |||
1973 | snd_echo_free(chip); | 2030 | snd_echo_free(chip); |
1974 | return err; | 2031 | return err; |
1975 | } | 2032 | } |
1976 | atomic_set(&chip->opencount, 0); | ||
1977 | mutex_init(&chip->mode_mutex); | ||
1978 | chip->can_set_rate = 1; | ||
1979 | *rchip = chip; | 2033 | *rchip = chip; |
1980 | /* Init done ! */ | 2034 | /* Init done ! */ |
1981 | return 0; | 2035 | return 0; |
@@ -2008,6 +2062,7 @@ static int __devinit snd_echo_probe(struct pci_dev *pci, | |||
2008 | 2062 | ||
2009 | snd_card_set_dev(card, &pci->dev); | 2063 | snd_card_set_dev(card, &pci->dev); |
2010 | 2064 | ||
2065 | chip = NULL; /* Tells snd_echo_create to allocate chip */ | ||
2011 | if ((err = snd_echo_create(card, pci, &chip)) < 0) { | 2066 | if ((err = snd_echo_create(card, pci, &chip)) < 0) { |
2012 | snd_card_free(card); | 2067 | snd_card_free(card); |
2013 | return err; | 2068 | return err; |
@@ -2147,6 +2202,112 @@ ctl_error: | |||
2147 | 2202 | ||
2148 | 2203 | ||
2149 | 2204 | ||
2205 | #if defined(CONFIG_PM) | ||
2206 | |||
2207 | static int snd_echo_suspend(struct pci_dev *pci, pm_message_t state) | ||
2208 | { | ||
2209 | struct echoaudio *chip = pci_get_drvdata(pci); | ||
2210 | |||
2211 | DE_INIT(("suspend start\n")); | ||
2212 | snd_pcm_suspend_all(chip->analog_pcm); | ||
2213 | snd_pcm_suspend_all(chip->digital_pcm); | ||
2214 | |||
2215 | #ifdef ECHOCARD_HAS_MIDI | ||
2216 | /* This call can sleep */ | ||
2217 | if (chip->midi_out) | ||
2218 | snd_echo_midi_output_trigger(chip->midi_out, 0); | ||
2219 | #endif | ||
2220 | spin_lock_irq(&chip->lock); | ||
2221 | if (wait_handshake(chip)) { | ||
2222 | spin_unlock_irq(&chip->lock); | ||
2223 | return -EIO; | ||
2224 | } | ||
2225 | clear_handshake(chip); | ||
2226 | if (send_vector(chip, DSP_VC_GO_COMATOSE) < 0) { | ||
2227 | spin_unlock_irq(&chip->lock); | ||
2228 | return -EIO; | ||
2229 | } | ||
2230 | spin_unlock_irq(&chip->lock); | ||
2231 | |||
2232 | chip->dsp_code = NULL; | ||
2233 | free_irq(chip->irq, chip); | ||
2234 | chip->irq = -1; | ||
2235 | pci_save_state(pci); | ||
2236 | pci_disable_device(pci); | ||
2237 | |||
2238 | DE_INIT(("suspend done\n")); | ||
2239 | return 0; | ||
2240 | } | ||
2241 | |||
2242 | |||
2243 | |||
2244 | static int snd_echo_resume(struct pci_dev *pci) | ||
2245 | { | ||
2246 | struct echoaudio *chip = pci_get_drvdata(pci); | ||
2247 | struct comm_page *commpage, *commpage_bak; | ||
2248 | u32 pipe_alloc_mask; | ||
2249 | int err; | ||
2250 | |||
2251 | DE_INIT(("resume start\n")); | ||
2252 | pci_restore_state(pci); | ||
2253 | commpage_bak = kmalloc(sizeof(struct echoaudio), GFP_KERNEL); | ||
2254 | commpage = chip->comm_page; | ||
2255 | memcpy(commpage_bak, commpage, sizeof(struct comm_page)); | ||
2256 | |||
2257 | err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); | ||
2258 | if (err < 0) { | ||
2259 | kfree(commpage_bak); | ||
2260 | DE_INIT(("resume init_hw err=%d\n", err)); | ||
2261 | snd_echo_free(chip); | ||
2262 | return err; | ||
2263 | } | ||
2264 | DE_INIT(("resume init OK\n")); | ||
2265 | |||
2266 | /* Temporarily set chip->pipe_alloc_mask=0 otherwise | ||
2267 | * restore_dsp_settings() fails. | ||
2268 | */ | ||
2269 | pipe_alloc_mask = chip->pipe_alloc_mask; | ||
2270 | chip->pipe_alloc_mask = 0; | ||
2271 | err = restore_dsp_rettings(chip); | ||
2272 | chip->pipe_alloc_mask = pipe_alloc_mask; | ||
2273 | if (err < 0) { | ||
2274 | kfree(commpage_bak); | ||
2275 | return err; | ||
2276 | } | ||
2277 | DE_INIT(("resume restore OK\n")); | ||
2278 | |||
2279 | memcpy(&commpage->audio_format, &commpage_bak->audio_format, | ||
2280 | sizeof(commpage->audio_format)); | ||
2281 | memcpy(&commpage->sglist_addr, &commpage_bak->sglist_addr, | ||
2282 | sizeof(commpage->sglist_addr)); | ||
2283 | memcpy(&commpage->midi_output, &commpage_bak->midi_output, | ||
2284 | sizeof(commpage->midi_output)); | ||
2285 | kfree(commpage_bak); | ||
2286 | |||
2287 | if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED, | ||
2288 | ECHOCARD_NAME, chip)) { | ||
2289 | snd_echo_free(chip); | ||
2290 | snd_printk(KERN_ERR "cannot grab irq\n"); | ||
2291 | return -EBUSY; | ||
2292 | } | ||
2293 | chip->irq = pci->irq; | ||
2294 | DE_INIT(("resume irq=%d\n", chip->irq)); | ||
2295 | |||
2296 | #ifdef ECHOCARD_HAS_MIDI | ||
2297 | if (chip->midi_input_enabled) | ||
2298 | enable_midi_input(chip, TRUE); | ||
2299 | if (chip->midi_out) | ||
2300 | snd_echo_midi_output_trigger(chip->midi_out, 1); | ||
2301 | #endif | ||
2302 | |||
2303 | DE_INIT(("resume done\n")); | ||
2304 | return 0; | ||
2305 | } | ||
2306 | |||
2307 | #endif /* CONFIG_PM */ | ||
2308 | |||
2309 | |||
2310 | |||
2150 | static void __devexit snd_echo_remove(struct pci_dev *pci) | 2311 | static void __devexit snd_echo_remove(struct pci_dev *pci) |
2151 | { | 2312 | { |
2152 | struct echoaudio *chip; | 2313 | struct echoaudio *chip; |
@@ -2169,6 +2330,10 @@ static struct pci_driver driver = { | |||
2169 | .id_table = snd_echo_ids, | 2330 | .id_table = snd_echo_ids, |
2170 | .probe = snd_echo_probe, | 2331 | .probe = snd_echo_probe, |
2171 | .remove = __devexit_p(snd_echo_remove), | 2332 | .remove = __devexit_p(snd_echo_remove), |
2333 | #ifdef CONFIG_PM | ||
2334 | .suspend = snd_echo_suspend, | ||
2335 | .resume = snd_echo_resume, | ||
2336 | #endif /* CONFIG_PM */ | ||
2172 | }; | 2337 | }; |
2173 | 2338 | ||
2174 | 2339 | ||
diff --git a/sound/pci/echoaudio/echoaudio.h b/sound/pci/echoaudio/echoaudio.h index f9490ae36c2e..1df974dcb5f4 100644 --- a/sound/pci/echoaudio/echoaudio.h +++ b/sound/pci/echoaudio/echoaudio.h | |||
@@ -442,13 +442,16 @@ struct echoaudio { | |||
442 | u16 device_id, subdevice_id; | 442 | u16 device_id, subdevice_id; |
443 | u16 *dsp_code; /* Current DSP code loaded, | 443 | u16 *dsp_code; /* Current DSP code loaded, |
444 | * NULL if nothing loaded */ | 444 | * NULL if nothing loaded */ |
445 | const struct firmware *dsp_code_to_load;/* DSP code to load */ | 445 | short dsp_code_to_load; /* DSP code to load */ |
446 | const struct firmware *asic_code; /* Current ASIC code */ | 446 | short asic_code; /* Current ASIC code */ |
447 | u32 comm_page_phys; /* Physical address of the | 447 | u32 comm_page_phys; /* Physical address of the |
448 | * memory seen by DSP */ | 448 | * memory seen by DSP */ |
449 | volatile u32 __iomem *dsp_registers; /* DSP's register base */ | 449 | volatile u32 __iomem *dsp_registers; /* DSP's register base */ |
450 | u32 active_mask; /* Chs. active mask or | 450 | u32 active_mask; /* Chs. active mask or |
451 | * punks out */ | 451 | * punks out */ |
452 | #ifdef CONFIG_PM | ||
453 | const struct firmware *fw_cache[8]; /* Cached firmwares */ | ||
454 | #endif | ||
452 | 455 | ||
453 | #ifdef ECHOCARD_HAS_MIDI | 456 | #ifdef ECHOCARD_HAS_MIDI |
454 | u16 mtc_state; /* State for MIDI input parsing state machine */ | 457 | u16 mtc_state; /* State for MIDI input parsing state machine */ |
@@ -464,11 +467,13 @@ static int load_firmware(struct echoaudio *chip); | |||
464 | static int wait_handshake(struct echoaudio *chip); | 467 | static int wait_handshake(struct echoaudio *chip); |
465 | static int send_vector(struct echoaudio *chip, u32 command); | 468 | static int send_vector(struct echoaudio *chip, u32 command); |
466 | static int get_firmware(const struct firmware **fw_entry, | 469 | static int get_firmware(const struct firmware **fw_entry, |
467 | const struct firmware *frm, struct echoaudio *chip); | 470 | struct echoaudio *chip, const short fw_index); |
468 | static void free_firmware(const struct firmware *fw_entry); | 471 | static void free_firmware(const struct firmware *fw_entry); |
469 | 472 | ||
470 | #ifdef ECHOCARD_HAS_MIDI | 473 | #ifdef ECHOCARD_HAS_MIDI |
471 | static int enable_midi_input(struct echoaudio *chip, char enable); | 474 | static int enable_midi_input(struct echoaudio *chip, char enable); |
475 | static void snd_echo_midi_output_trigger( | ||
476 | struct snd_rawmidi_substream *substream, int up); | ||
472 | static int midi_service_irq(struct echoaudio *chip); | 477 | static int midi_service_irq(struct echoaudio *chip); |
473 | static int __devinit snd_echo_midi_create(struct snd_card *card, | 478 | static int __devinit snd_echo_midi_create(struct snd_card *card, |
474 | struct echoaudio *chip); | 479 | struct echoaudio *chip); |
diff --git a/sound/pci/echoaudio/echoaudio_3g.c b/sound/pci/echoaudio/echoaudio_3g.c index e32a74897921..658db44ef746 100644 --- a/sound/pci/echoaudio/echoaudio_3g.c +++ b/sound/pci/echoaudio/echoaudio_3g.c | |||
@@ -227,12 +227,11 @@ static int load_asic(struct echoaudio *chip) | |||
227 | /* Give the DSP a few milliseconds to settle down */ | 227 | /* Give the DSP a few milliseconds to settle down */ |
228 | mdelay(2); | 228 | mdelay(2); |
229 | 229 | ||
230 | err = load_asic_generic(chip, DSP_FNC_LOAD_3G_ASIC, | 230 | err = load_asic_generic(chip, DSP_FNC_LOAD_3G_ASIC, FW_3G_ASIC); |
231 | &card_fw[FW_3G_ASIC]); | ||
232 | if (err < 0) | 231 | if (err < 0) |
233 | return err; | 232 | return err; |
234 | 233 | ||
235 | chip->asic_code = &card_fw[FW_3G_ASIC]; | 234 | chip->asic_code = FW_3G_ASIC; |
236 | 235 | ||
237 | /* Now give the new ASIC some time to set up */ | 236 | /* Now give the new ASIC some time to set up */ |
238 | msleep(1000); | 237 | msleep(1000); |
diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c index 4df51ef5e095..64417a733220 100644 --- a/sound/pci/echoaudio/echoaudio_dsp.c +++ b/sound/pci/echoaudio/echoaudio_dsp.c | |||
@@ -175,15 +175,15 @@ static inline int check_asic_status(struct echoaudio *chip) | |||
175 | #ifdef ECHOCARD_HAS_ASIC | 175 | #ifdef ECHOCARD_HAS_ASIC |
176 | 176 | ||
177 | /* Load ASIC code - done after the DSP is loaded */ | 177 | /* Load ASIC code - done after the DSP is loaded */ |
178 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, | 178 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic) |
179 | const struct firmware *asic) | ||
180 | { | 179 | { |
181 | const struct firmware *fw; | 180 | const struct firmware *fw; |
182 | int err; | 181 | int err; |
183 | u32 i, size; | 182 | u32 i, size; |
184 | u8 *code; | 183 | u8 *code; |
185 | 184 | ||
186 | if ((err = get_firmware(&fw, asic, chip)) < 0) { | 185 | err = get_firmware(&fw, chip, asic); |
186 | if (err < 0) { | ||
187 | snd_printk(KERN_WARNING "Firmware not found !\n"); | 187 | snd_printk(KERN_WARNING "Firmware not found !\n"); |
188 | return err; | 188 | return err; |
189 | } | 189 | } |
@@ -245,7 +245,8 @@ static int install_resident_loader(struct echoaudio *chip) | |||
245 | return 0; | 245 | return 0; |
246 | } | 246 | } |
247 | 247 | ||
248 | if ((i = get_firmware(&fw, &card_fw[FW_361_LOADER], chip)) < 0) { | 248 | i = get_firmware(&fw, chip, FW_361_LOADER); |
249 | if (i < 0) { | ||
249 | snd_printk(KERN_WARNING "Firmware not found !\n"); | 250 | snd_printk(KERN_WARNING "Firmware not found !\n"); |
250 | return i; | 251 | return i; |
251 | } | 252 | } |
@@ -485,7 +486,8 @@ static int load_firmware(struct echoaudio *chip) | |||
485 | chip->dsp_code = NULL; | 486 | chip->dsp_code = NULL; |
486 | } | 487 | } |
487 | 488 | ||
488 | if ((err = get_firmware(&fw, chip->dsp_code_to_load, chip)) < 0) | 489 | err = get_firmware(&fw, chip, chip->dsp_code_to_load); |
490 | if (err < 0) | ||
489 | return err; | 491 | return err; |
490 | err = load_dsp(chip, (u16 *)fw->data); | 492 | err = load_dsp(chip, (u16 *)fw->data); |
491 | free_firmware(fw); | 493 | free_firmware(fw); |
@@ -495,9 +497,6 @@ static int load_firmware(struct echoaudio *chip) | |||
495 | if ((box_type = load_asic(chip)) < 0) | 497 | if ((box_type = load_asic(chip)) < 0) |
496 | return box_type; /* error */ | 498 | return box_type; /* error */ |
497 | 499 | ||
498 | if ((err = restore_dsp_rettings(chip)) < 0) | ||
499 | return err; | ||
500 | |||
501 | return box_type; | 500 | return box_type; |
502 | } | 501 | } |
503 | 502 | ||
@@ -657,51 +656,106 @@ static void get_audio_meters(struct echoaudio *chip, long *meters) | |||
657 | 656 | ||
658 | static int restore_dsp_rettings(struct echoaudio *chip) | 657 | static int restore_dsp_rettings(struct echoaudio *chip) |
659 | { | 658 | { |
660 | int err; | 659 | int i, o, err; |
661 | DE_INIT(("restore_dsp_settings\n")); | 660 | DE_INIT(("restore_dsp_settings\n")); |
662 | 661 | ||
663 | if ((err = check_asic_status(chip)) < 0) | 662 | if ((err = check_asic_status(chip)) < 0) |
664 | return err; | 663 | return err; |
665 | 664 | ||
666 | /* @ Gina20/Darla20 only. Should be harmless for other cards. */ | 665 | /* Gina20/Darla20 only. Should be harmless for other cards. */ |
667 | chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF; | 666 | chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF; |
668 | chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF; | 667 | chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF; |
669 | chip->comm_page->handshake = 0xffffffff; | 668 | chip->comm_page->handshake = 0xffffffff; |
670 | 669 | ||
671 | if ((err = set_sample_rate(chip, chip->sample_rate)) < 0) | 670 | /* Restore output busses */ |
671 | for (i = 0; i < num_busses_out(chip); i++) { | ||
672 | err = set_output_gain(chip, i, chip->output_gain[i]); | ||
673 | if (err < 0) | ||
674 | return err; | ||
675 | } | ||
676 | |||
677 | #ifdef ECHOCARD_HAS_VMIXER | ||
678 | for (i = 0; i < num_pipes_out(chip); i++) | ||
679 | for (o = 0; o < num_busses_out(chip); o++) { | ||
680 | err = set_vmixer_gain(chip, o, i, | ||
681 | chip->vmixer_gain[o][i]); | ||
682 | if (err < 0) | ||
683 | return err; | ||
684 | } | ||
685 | if (update_vmixer_level(chip) < 0) | ||
686 | return -EIO; | ||
687 | #endif /* ECHOCARD_HAS_VMIXER */ | ||
688 | |||
689 | #ifdef ECHOCARD_HAS_MONITOR | ||
690 | for (o = 0; o < num_busses_out(chip); o++) | ||
691 | for (i = 0; i < num_busses_in(chip); i++) { | ||
692 | err = set_monitor_gain(chip, o, i, | ||
693 | chip->monitor_gain[o][i]); | ||
694 | if (err < 0) | ||
695 | return err; | ||
696 | } | ||
697 | #endif /* ECHOCARD_HAS_MONITOR */ | ||
698 | |||
699 | #ifdef ECHOCARD_HAS_INPUT_GAIN | ||
700 | for (i = 0; i < num_busses_in(chip); i++) { | ||
701 | err = set_input_gain(chip, i, chip->input_gain[i]); | ||
702 | if (err < 0) | ||
703 | return err; | ||
704 | } | ||
705 | #endif /* ECHOCARD_HAS_INPUT_GAIN */ | ||
706 | |||
707 | err = update_output_line_level(chip); | ||
708 | if (err < 0) | ||
672 | return err; | 709 | return err; |
673 | 710 | ||
674 | if (chip->meters_enabled) | 711 | err = update_input_line_level(chip); |
675 | if (send_vector(chip, DSP_VC_METERS_ON) < 0) | 712 | if (err < 0) |
676 | return -EIO; | 713 | return err; |
677 | 714 | ||
678 | #ifdef ECHOCARD_HAS_EXTERNAL_CLOCK | 715 | err = set_sample_rate(chip, chip->sample_rate); |
679 | if (set_input_clock(chip, chip->input_clock) < 0) | 716 | if (err < 0) |
717 | return err; | ||
718 | |||
719 | if (chip->meters_enabled) { | ||
720 | err = send_vector(chip, DSP_VC_METERS_ON); | ||
721 | if (err < 0) | ||
722 | return err; | ||
723 | } | ||
724 | |||
725 | #ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH | ||
726 | if (set_digital_mode(chip, chip->digital_mode) < 0) | ||
680 | return -EIO; | 727 | return -EIO; |
681 | #endif | 728 | #endif |
682 | 729 | ||
683 | #ifdef ECHOCARD_HAS_OUTPUT_CLOCK_SWITCH | 730 | #ifdef ECHOCARD_HAS_DIGITAL_IO |
684 | if (set_output_clock(chip, chip->output_clock) < 0) | 731 | if (set_professional_spdif(chip, chip->professional_spdif) < 0) |
685 | return -EIO; | 732 | return -EIO; |
686 | #endif | 733 | #endif |
687 | 734 | ||
688 | if (update_output_line_level(chip) < 0) | 735 | #ifdef ECHOCARD_HAS_PHANTOM_POWER |
736 | if (set_phantom_power(chip, chip->phantom_power) < 0) | ||
689 | return -EIO; | 737 | return -EIO; |
738 | #endif | ||
690 | 739 | ||
691 | if (update_input_line_level(chip) < 0) | 740 | #ifdef ECHOCARD_HAS_EXTERNAL_CLOCK |
741 | /* set_input_clock() also restores automute setting */ | ||
742 | if (set_input_clock(chip, chip->input_clock) < 0) | ||
692 | return -EIO; | 743 | return -EIO; |
744 | #endif | ||
693 | 745 | ||
694 | #ifdef ECHOCARD_HAS_VMIXER | 746 | #ifdef ECHOCARD_HAS_OUTPUT_CLOCK_SWITCH |
695 | if (update_vmixer_level(chip) < 0) | 747 | if (set_output_clock(chip, chip->output_clock) < 0) |
696 | return -EIO; | 748 | return -EIO; |
697 | #endif | 749 | #endif |
698 | 750 | ||
699 | if (wait_handshake(chip) < 0) | 751 | if (wait_handshake(chip) < 0) |
700 | return -EIO; | 752 | return -EIO; |
701 | clear_handshake(chip); | 753 | clear_handshake(chip); |
754 | if (send_vector(chip, DSP_VC_UPDATE_FLAGS) < 0) | ||
755 | return -EIO; | ||
702 | 756 | ||
703 | DE_INIT(("restore_dsp_rettings done\n")); | 757 | DE_INIT(("restore_dsp_rettings done\n")); |
704 | return send_vector(chip, DSP_VC_UPDATE_FLAGS); | 758 | return 0; |
705 | } | 759 | } |
706 | 760 | ||
707 | 761 | ||
@@ -918,9 +972,6 @@ static int init_dsp_comm_page(struct echoaudio *chip) | |||
918 | chip->card_name = ECHOCARD_NAME; | 972 | chip->card_name = ECHOCARD_NAME; |
919 | chip->bad_board = TRUE; /* Set TRUE until DSP loaded */ | 973 | chip->bad_board = TRUE; /* Set TRUE until DSP loaded */ |
920 | chip->dsp_code = NULL; /* Current DSP code not loaded */ | 974 | chip->dsp_code = NULL; /* Current DSP code not loaded */ |
921 | chip->digital_mode = DIGITAL_MODE_NONE; | ||
922 | chip->input_clock = ECHO_CLOCK_INTERNAL; | ||
923 | chip->output_clock = ECHO_CLOCK_WORD; | ||
924 | chip->asic_loaded = FALSE; | 975 | chip->asic_loaded = FALSE; |
925 | memset(chip->comm_page, 0, sizeof(struct comm_page)); | 976 | memset(chip->comm_page, 0, sizeof(struct comm_page)); |
926 | 977 | ||
@@ -931,7 +982,6 @@ static int init_dsp_comm_page(struct echoaudio *chip) | |||
931 | chip->comm_page->midi_out_free_count = | 982 | chip->comm_page->midi_out_free_count = |
932 | cpu_to_le32(DSP_MIDI_OUT_FIFO_SIZE); | 983 | cpu_to_le32(DSP_MIDI_OUT_FIFO_SIZE); |
933 | chip->comm_page->sample_rate = cpu_to_le32(44100); | 984 | chip->comm_page->sample_rate = cpu_to_le32(44100); |
934 | chip->sample_rate = 44100; | ||
935 | 985 | ||
936 | /* Set line levels so we don't blast any inputs on startup */ | 986 | /* Set line levels so we don't blast any inputs on startup */ |
937 | memset(chip->comm_page->monitors, ECHOGAIN_MUTED, MONITOR_ARRAY_SIZE); | 987 | memset(chip->comm_page->monitors, ECHOGAIN_MUTED, MONITOR_ARRAY_SIZE); |
@@ -942,50 +992,21 @@ static int init_dsp_comm_page(struct echoaudio *chip) | |||
942 | 992 | ||
943 | 993 | ||
944 | 994 | ||
945 | /* This function initializes the several volume controls for busses and pipes. | 995 | /* This function initializes the chip structure with default values, ie. all |
946 | This MUST be called after the DSP is up and running ! */ | 996 | * muted and internal clock source. Then it copies the settings to the DSP. |
997 | * This MUST be called after the DSP is up and running ! | ||
998 | */ | ||
947 | static int init_line_levels(struct echoaudio *chip) | 999 | static int init_line_levels(struct echoaudio *chip) |
948 | { | 1000 | { |
949 | int st, i, o; | ||
950 | |||
951 | DE_INIT(("init_line_levels\n")); | 1001 | DE_INIT(("init_line_levels\n")); |
952 | 1002 | memset(chip->output_gain, ECHOGAIN_MUTED, sizeof(chip->output_gain)); | |
953 | /* Mute output busses */ | 1003 | memset(chip->input_gain, ECHOGAIN_MUTED, sizeof(chip->input_gain)); |
954 | for (i = 0; i < num_busses_out(chip); i++) | 1004 | memset(chip->monitor_gain, ECHOGAIN_MUTED, sizeof(chip->monitor_gain)); |
955 | if ((st = set_output_gain(chip, i, ECHOGAIN_MUTED))) | 1005 | memset(chip->vmixer_gain, ECHOGAIN_MUTED, sizeof(chip->vmixer_gain)); |
956 | return st; | 1006 | chip->input_clock = ECHO_CLOCK_INTERNAL; |
957 | if ((st = update_output_line_level(chip))) | 1007 | chip->output_clock = ECHO_CLOCK_WORD; |
958 | return st; | 1008 | chip->sample_rate = 44100; |
959 | 1009 | return restore_dsp_rettings(chip); | |
960 | #ifdef ECHOCARD_HAS_VMIXER | ||
961 | /* Mute the Vmixer */ | ||
962 | for (i = 0; i < num_pipes_out(chip); i++) | ||
963 | for (o = 0; o < num_busses_out(chip); o++) | ||
964 | if ((st = set_vmixer_gain(chip, o, i, ECHOGAIN_MUTED))) | ||
965 | return st; | ||
966 | if ((st = update_vmixer_level(chip))) | ||
967 | return st; | ||
968 | #endif /* ECHOCARD_HAS_VMIXER */ | ||
969 | |||
970 | #ifdef ECHOCARD_HAS_MONITOR | ||
971 | /* Mute the monitor mixer */ | ||
972 | for (o = 0; o < num_busses_out(chip); o++) | ||
973 | for (i = 0; i < num_busses_in(chip); i++) | ||
974 | if ((st = set_monitor_gain(chip, o, i, ECHOGAIN_MUTED))) | ||
975 | return st; | ||
976 | if ((st = update_output_line_level(chip))) | ||
977 | return st; | ||
978 | #endif /* ECHOCARD_HAS_MONITOR */ | ||
979 | |||
980 | #ifdef ECHOCARD_HAS_INPUT_GAIN | ||
981 | for (i = 0; i < num_busses_in(chip); i++) | ||
982 | if ((st = set_input_gain(chip, i, ECHOGAIN_MUTED))) | ||
983 | return st; | ||
984 | if ((st = update_input_line_level(chip))) | ||
985 | return st; | ||
986 | #endif /* ECHOCARD_HAS_INPUT_GAIN */ | ||
987 | |||
988 | return 0; | ||
989 | } | 1010 | } |
990 | 1011 | ||
991 | 1012 | ||
diff --git a/sound/pci/echoaudio/gina20.c b/sound/pci/echoaudio/gina20.c index c0e64b8f52a4..2364f8a1bc21 100644 --- a/sound/pci/echoaudio/gina20.c +++ b/sound/pci/echoaudio/gina20.c | |||
@@ -67,7 +67,7 @@ static const struct firmware card_fw[] = { | |||
67 | {0, "gina20_dsp.fw"} | 67 | {0, "gina20_dsp.fw"} |
68 | }; | 68 | }; |
69 | 69 | ||
70 | static struct pci_device_id snd_echo_ids[] = { | 70 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
71 | {0x1057, 0x1801, 0xECC0, 0x0020, 0, 0, 0}, /* DSP 56301 Gina20 rev.0 */ | 71 | {0x1057, 0x1801, 0xECC0, 0x0020, 0, 0, 0}, /* DSP 56301 Gina20 rev.0 */ |
72 | {0,} | 72 | {0,} |
73 | }; | 73 | }; |
diff --git a/sound/pci/echoaudio/gina20_dsp.c b/sound/pci/echoaudio/gina20_dsp.c index 3f1e7475faea..d1615a0579d1 100644 --- a/sound/pci/echoaudio/gina20_dsp.c +++ b/sound/pci/echoaudio/gina20_dsp.c | |||
@@ -49,7 +49,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
49 | chip->device_id = device_id; | 49 | chip->device_id = device_id; |
50 | chip->subdevice_id = subdevice_id; | 50 | chip->subdevice_id = subdevice_id; |
51 | chip->bad_board = TRUE; | 51 | chip->bad_board = TRUE; |
52 | chip->dsp_code_to_load = &card_fw[FW_GINA20_DSP]; | 52 | chip->dsp_code_to_load = FW_GINA20_DSP; |
53 | chip->spdif_status = GD_SPDIF_STATUS_UNDEF; | 53 | chip->spdif_status = GD_SPDIF_STATUS_UNDEF; |
54 | chip->clock_state = GD_CLOCK_UNDEF; | 54 | chip->clock_state = GD_CLOCK_UNDEF; |
55 | /* Since this card has no ASIC, mark it as loaded so everything | 55 | /* Since this card has no ASIC, mark it as loaded so everything |
@@ -62,17 +62,20 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
62 | return err; | 62 | return err; |
63 | chip->bad_board = FALSE; | 63 | chip->bad_board = FALSE; |
64 | 64 | ||
65 | if ((err = init_line_levels(chip)) < 0) | ||
66 | return err; | ||
67 | |||
68 | err = set_professional_spdif(chip, TRUE); | ||
69 | |||
70 | DE_INIT(("init_hw done\n")); | 65 | DE_INIT(("init_hw done\n")); |
71 | return err; | 66 | return err; |
72 | } | 67 | } |
73 | 68 | ||
74 | 69 | ||
75 | 70 | ||
71 | static int set_mixer_defaults(struct echoaudio *chip) | ||
72 | { | ||
73 | chip->professional_spdif = FALSE; | ||
74 | return init_line_levels(chip); | ||
75 | } | ||
76 | |||
77 | |||
78 | |||
76 | static u32 detect_input_clocks(const struct echoaudio *chip) | 79 | static u32 detect_input_clocks(const struct echoaudio *chip) |
77 | { | 80 | { |
78 | u32 clocks_from_dsp, clock_bits; | 81 | u32 clocks_from_dsp, clock_bits; |
diff --git a/sound/pci/echoaudio/gina24.c b/sound/pci/echoaudio/gina24.c index c36a78dd0b5e..616b55825a19 100644 --- a/sound/pci/echoaudio/gina24.c +++ b/sound/pci/echoaudio/gina24.c | |||
@@ -85,7 +85,7 @@ static const struct firmware card_fw[] = { | |||
85 | {0, "gina24_361_asic.fw"} | 85 | {0, "gina24_361_asic.fw"} |
86 | }; | 86 | }; |
87 | 87 | ||
88 | static struct pci_device_id snd_echo_ids[] = { | 88 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
89 | {0x1057, 0x1801, 0xECC0, 0x0050, 0, 0, 0}, /* DSP 56301 Gina24 rev.0 */ | 89 | {0x1057, 0x1801, 0xECC0, 0x0050, 0, 0, 0}, /* DSP 56301 Gina24 rev.0 */ |
90 | {0x1057, 0x1801, 0xECC0, 0x0051, 0, 0, 0}, /* DSP 56301 Gina24 rev.1 */ | 90 | {0x1057, 0x1801, 0xECC0, 0x0051, 0, 0, 0}, /* DSP 56301 Gina24 rev.1 */ |
91 | {0x1057, 0x3410, 0xECC0, 0x0050, 0, 0, 0}, /* DSP 56361 Gina24 rev.0 */ | 91 | {0x1057, 0x3410, 0xECC0, 0x0050, 0, 0, 0}, /* DSP 56361 Gina24 rev.0 */ |
diff --git a/sound/pci/echoaudio/gina24_dsp.c b/sound/pci/echoaudio/gina24_dsp.c index 2fef37a2a5b9..98f7cfa81b5f 100644 --- a/sound/pci/echoaudio/gina24_dsp.c +++ b/sound/pci/echoaudio/gina24_dsp.c | |||
@@ -33,8 +33,7 @@ static int write_control_reg(struct echoaudio *chip, u32 value, char force); | |||
33 | static int set_input_clock(struct echoaudio *chip, u16 clock); | 33 | static int set_input_clock(struct echoaudio *chip, u16 clock); |
34 | static int set_professional_spdif(struct echoaudio *chip, char prof); | 34 | static int set_professional_spdif(struct echoaudio *chip, char prof); |
35 | static int set_digital_mode(struct echoaudio *chip, u8 mode); | 35 | static int set_digital_mode(struct echoaudio *chip, u8 mode); |
36 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, | 36 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic); |
37 | const struct firmware *asic); | ||
38 | static int check_asic_status(struct echoaudio *chip); | 37 | static int check_asic_status(struct echoaudio *chip); |
39 | 38 | ||
40 | 39 | ||
@@ -58,19 +57,16 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
58 | ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF | | 57 | ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF | |
59 | ECHO_CLOCK_BIT_ESYNC | ECHO_CLOCK_BIT_ESYNC96 | | 58 | ECHO_CLOCK_BIT_ESYNC | ECHO_CLOCK_BIT_ESYNC96 | |
60 | ECHO_CLOCK_BIT_ADAT; | 59 | ECHO_CLOCK_BIT_ADAT; |
61 | chip->professional_spdif = FALSE; | ||
62 | chip->digital_in_automute = TRUE; | ||
63 | chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; | ||
64 | 60 | ||
65 | /* Gina24 comes in both '301 and '361 flavors */ | 61 | /* Gina24 comes in both '301 and '361 flavors */ |
66 | if (chip->device_id == DEVICE_ID_56361) { | 62 | if (chip->device_id == DEVICE_ID_56361) { |
67 | chip->dsp_code_to_load = &card_fw[FW_GINA24_361_DSP]; | 63 | chip->dsp_code_to_load = FW_GINA24_361_DSP; |
68 | chip->digital_modes = | 64 | chip->digital_modes = |
69 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | | 65 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | |
70 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | | 66 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | |
71 | ECHOCAPS_HAS_DIGITAL_MODE_ADAT; | 67 | ECHOCAPS_HAS_DIGITAL_MODE_ADAT; |
72 | } else { | 68 | } else { |
73 | chip->dsp_code_to_load = &card_fw[FW_GINA24_301_DSP]; | 69 | chip->dsp_code_to_load = FW_GINA24_301_DSP; |
74 | chip->digital_modes = | 70 | chip->digital_modes = |
75 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | | 71 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | |
76 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | | 72 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | |
@@ -82,19 +78,22 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
82 | return err; | 78 | return err; |
83 | chip->bad_board = FALSE; | 79 | chip->bad_board = FALSE; |
84 | 80 | ||
85 | if ((err = init_line_levels(chip)) < 0) | ||
86 | return err; | ||
87 | err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); | ||
88 | if (err < 0) | ||
89 | return err; | ||
90 | err = set_professional_spdif(chip, TRUE); | ||
91 | |||
92 | DE_INIT(("init_hw done\n")); | 81 | DE_INIT(("init_hw done\n")); |
93 | return err; | 82 | return err; |
94 | } | 83 | } |
95 | 84 | ||
96 | 85 | ||
97 | 86 | ||
87 | static int set_mixer_defaults(struct echoaudio *chip) | ||
88 | { | ||
89 | chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; | ||
90 | chip->professional_spdif = FALSE; | ||
91 | chip->digital_in_automute = TRUE; | ||
92 | return init_line_levels(chip); | ||
93 | } | ||
94 | |||
95 | |||
96 | |||
98 | static u32 detect_input_clocks(const struct echoaudio *chip) | 97 | static u32 detect_input_clocks(const struct echoaudio *chip) |
99 | { | 98 | { |
100 | u32 clocks_from_dsp, clock_bits; | 99 | u32 clocks_from_dsp, clock_bits; |
@@ -125,7 +124,7 @@ static int load_asic(struct echoaudio *chip) | |||
125 | { | 124 | { |
126 | u32 control_reg; | 125 | u32 control_reg; |
127 | int err; | 126 | int err; |
128 | const struct firmware *fw; | 127 | short asic; |
129 | 128 | ||
130 | if (chip->asic_loaded) | 129 | if (chip->asic_loaded) |
131 | return 1; | 130 | return 1; |
@@ -135,14 +134,15 @@ static int load_asic(struct echoaudio *chip) | |||
135 | 134 | ||
136 | /* Pick the correct ASIC for '301 or '361 Gina24 */ | 135 | /* Pick the correct ASIC for '301 or '361 Gina24 */ |
137 | if (chip->device_id == DEVICE_ID_56361) | 136 | if (chip->device_id == DEVICE_ID_56361) |
138 | fw = &card_fw[FW_GINA24_361_ASIC]; | 137 | asic = FW_GINA24_361_ASIC; |
139 | else | 138 | else |
140 | fw = &card_fw[FW_GINA24_301_ASIC]; | 139 | asic = FW_GINA24_301_ASIC; |
141 | 140 | ||
142 | if ((err = load_asic_generic(chip, DSP_FNC_LOAD_GINA24_ASIC, fw)) < 0) | 141 | err = load_asic_generic(chip, DSP_FNC_LOAD_GINA24_ASIC, asic); |
142 | if (err < 0) | ||
143 | return err; | 143 | return err; |
144 | 144 | ||
145 | chip->asic_code = fw; | 145 | chip->asic_code = asic; |
146 | 146 | ||
147 | /* Now give the new ASIC a little time to set up */ | 147 | /* Now give the new ASIC a little time to set up */ |
148 | mdelay(10); | 148 | mdelay(10); |
diff --git a/sound/pci/echoaudio/indigo.c b/sound/pci/echoaudio/indigo.c index 0a58a7c1fd7c..776175c0bdad 100644 --- a/sound/pci/echoaudio/indigo.c +++ b/sound/pci/echoaudio/indigo.c | |||
@@ -68,7 +68,7 @@ static const struct firmware card_fw[] = { | |||
68 | {0, "indigo_dsp.fw"} | 68 | {0, "indigo_dsp.fw"} |
69 | }; | 69 | }; |
70 | 70 | ||
71 | static struct pci_device_id snd_echo_ids[] = { | 71 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
72 | {0x1057, 0x3410, 0xECC0, 0x0090, 0, 0, 0}, /* Indigo */ | 72 | {0x1057, 0x3410, 0xECC0, 0x0090, 0, 0, 0}, /* Indigo */ |
73 | {0,} | 73 | {0,} |
74 | }; | 74 | }; |
diff --git a/sound/pci/echoaudio/indigo_dsp.c b/sound/pci/echoaudio/indigo_dsp.c index 0b2cd9c86277..5e85f14fe5a8 100644 --- a/sound/pci/echoaudio/indigo_dsp.c +++ b/sound/pci/echoaudio/indigo_dsp.c | |||
@@ -50,7 +50,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
50 | chip->device_id = device_id; | 50 | chip->device_id = device_id; |
51 | chip->subdevice_id = subdevice_id; | 51 | chip->subdevice_id = subdevice_id; |
52 | chip->bad_board = TRUE; | 52 | chip->bad_board = TRUE; |
53 | chip->dsp_code_to_load = &card_fw[FW_INDIGO_DSP]; | 53 | chip->dsp_code_to_load = FW_INDIGO_DSP; |
54 | /* Since this card has no ASIC, mark it as loaded so everything | 54 | /* Since this card has no ASIC, mark it as loaded so everything |
55 | works OK */ | 55 | works OK */ |
56 | chip->asic_loaded = TRUE; | 56 | chip->asic_loaded = TRUE; |
@@ -60,15 +60,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
60 | return err; | 60 | return err; |
61 | chip->bad_board = FALSE; | 61 | chip->bad_board = FALSE; |
62 | 62 | ||
63 | if ((err = init_line_levels(chip)) < 0) | ||
64 | return err; | ||
65 | |||
66 | DE_INIT(("init_hw done\n")); | 63 | DE_INIT(("init_hw done\n")); |
67 | return err; | 64 | return err; |
68 | } | 65 | } |
69 | 66 | ||
70 | 67 | ||
71 | 68 | ||
69 | static int set_mixer_defaults(struct echoaudio *chip) | ||
70 | { | ||
71 | return init_line_levels(chip); | ||
72 | } | ||
73 | |||
74 | |||
75 | |||
72 | static u32 detect_input_clocks(const struct echoaudio *chip) | 76 | static u32 detect_input_clocks(const struct echoaudio *chip) |
73 | { | 77 | { |
74 | return ECHO_CLOCK_BIT_INTERNAL; | 78 | return ECHO_CLOCK_BIT_INTERNAL; |
diff --git a/sound/pci/echoaudio/indigo_express_dsp.c b/sound/pci/echoaudio/indigo_express_dsp.c index 9ab625e15652..2e4ab3e34a74 100644 --- a/sound/pci/echoaudio/indigo_express_dsp.c +++ b/sound/pci/echoaudio/indigo_express_dsp.c | |||
@@ -61,6 +61,7 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate) | |||
61 | 61 | ||
62 | control_reg |= clock; | 62 | control_reg |= clock; |
63 | if (control_reg != old_control_reg) { | 63 | if (control_reg != old_control_reg) { |
64 | DE_ACT(("set_sample_rate: %d clock %d\n", rate, clock)); | ||
64 | chip->comm_page->control_register = cpu_to_le32(control_reg); | 65 | chip->comm_page->control_register = cpu_to_le32(control_reg); |
65 | chip->sample_rate = rate; | 66 | chip->sample_rate = rate; |
66 | clear_handshake(chip); | 67 | clear_handshake(chip); |
diff --git a/sound/pci/echoaudio/indigodj.c b/sound/pci/echoaudio/indigodj.c index 2db24d29332b..8816b0bd2ba6 100644 --- a/sound/pci/echoaudio/indigodj.c +++ b/sound/pci/echoaudio/indigodj.c | |||
@@ -68,7 +68,7 @@ static const struct firmware card_fw[] = { | |||
68 | {0, "indigo_dj_dsp.fw"} | 68 | {0, "indigo_dj_dsp.fw"} |
69 | }; | 69 | }; |
70 | 70 | ||
71 | static struct pci_device_id snd_echo_ids[] = { | 71 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
72 | {0x1057, 0x3410, 0xECC0, 0x00B0, 0, 0, 0}, /* Indigo DJ*/ | 72 | {0x1057, 0x3410, 0xECC0, 0x00B0, 0, 0, 0}, /* Indigo DJ*/ |
73 | {0,} | 73 | {0,} |
74 | }; | 74 | }; |
diff --git a/sound/pci/echoaudio/indigodj_dsp.c b/sound/pci/echoaudio/indigodj_dsp.c index 08392916691e..68f3c8ccc1bf 100644 --- a/sound/pci/echoaudio/indigodj_dsp.c +++ b/sound/pci/echoaudio/indigodj_dsp.c | |||
@@ -50,7 +50,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
50 | chip->device_id = device_id; | 50 | chip->device_id = device_id; |
51 | chip->subdevice_id = subdevice_id; | 51 | chip->subdevice_id = subdevice_id; |
52 | chip->bad_board = TRUE; | 52 | chip->bad_board = TRUE; |
53 | chip->dsp_code_to_load = &card_fw[FW_INDIGO_DJ_DSP]; | 53 | chip->dsp_code_to_load = FW_INDIGO_DJ_DSP; |
54 | /* Since this card has no ASIC, mark it as loaded so everything | 54 | /* Since this card has no ASIC, mark it as loaded so everything |
55 | works OK */ | 55 | works OK */ |
56 | chip->asic_loaded = TRUE; | 56 | chip->asic_loaded = TRUE; |
@@ -60,15 +60,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
60 | return err; | 60 | return err; |
61 | chip->bad_board = FALSE; | 61 | chip->bad_board = FALSE; |
62 | 62 | ||
63 | if ((err = init_line_levels(chip)) < 0) | ||
64 | return err; | ||
65 | |||
66 | DE_INIT(("init_hw done\n")); | 63 | DE_INIT(("init_hw done\n")); |
67 | return err; | 64 | return err; |
68 | } | 65 | } |
69 | 66 | ||
70 | 67 | ||
71 | 68 | ||
69 | static int set_mixer_defaults(struct echoaudio *chip) | ||
70 | { | ||
71 | return init_line_levels(chip); | ||
72 | } | ||
73 | |||
74 | |||
75 | |||
72 | static u32 detect_input_clocks(const struct echoaudio *chip) | 76 | static u32 detect_input_clocks(const struct echoaudio *chip) |
73 | { | 77 | { |
74 | return ECHO_CLOCK_BIT_INTERNAL; | 78 | return ECHO_CLOCK_BIT_INTERNAL; |
diff --git a/sound/pci/echoaudio/indigodjx.c b/sound/pci/echoaudio/indigodjx.c index 2e44316530a2..b1e3652f2f48 100644 --- a/sound/pci/echoaudio/indigodjx.c +++ b/sound/pci/echoaudio/indigodjx.c | |||
@@ -68,7 +68,7 @@ static const struct firmware card_fw[] = { | |||
68 | {0, "indigo_djx_dsp.fw"} | 68 | {0, "indigo_djx_dsp.fw"} |
69 | }; | 69 | }; |
70 | 70 | ||
71 | static struct pci_device_id snd_echo_ids[] = { | 71 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
72 | {0x1057, 0x3410, 0xECC0, 0x00E0, 0, 0, 0}, /* Indigo DJx*/ | 72 | {0x1057, 0x3410, 0xECC0, 0x00E0, 0, 0, 0}, /* Indigo DJx*/ |
73 | {0,} | 73 | {0,} |
74 | }; | 74 | }; |
diff --git a/sound/pci/echoaudio/indigodjx_dsp.c b/sound/pci/echoaudio/indigodjx_dsp.c index f591fc2ed960..bb9632c752a9 100644 --- a/sound/pci/echoaudio/indigodjx_dsp.c +++ b/sound/pci/echoaudio/indigodjx_dsp.c | |||
@@ -48,7 +48,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
48 | chip->device_id = device_id; | 48 | chip->device_id = device_id; |
49 | chip->subdevice_id = subdevice_id; | 49 | chip->subdevice_id = subdevice_id; |
50 | chip->bad_board = TRUE; | 50 | chip->bad_board = TRUE; |
51 | chip->dsp_code_to_load = &card_fw[FW_INDIGO_DJX_DSP]; | 51 | chip->dsp_code_to_load = FW_INDIGO_DJX_DSP; |
52 | /* Since this card has no ASIC, mark it as loaded so everything | 52 | /* Since this card has no ASIC, mark it as loaded so everything |
53 | works OK */ | 53 | works OK */ |
54 | chip->asic_loaded = TRUE; | 54 | chip->asic_loaded = TRUE; |
@@ -59,10 +59,13 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
59 | return err; | 59 | return err; |
60 | chip->bad_board = FALSE; | 60 | chip->bad_board = FALSE; |
61 | 61 | ||
62 | err = init_line_levels(chip); | ||
63 | if (err < 0) | ||
64 | return err; | ||
65 | |||
66 | DE_INIT(("init_hw done\n")); | 62 | DE_INIT(("init_hw done\n")); |
67 | return err; | 63 | return err; |
68 | } | 64 | } |
65 | |||
66 | |||
67 | |||
68 | static int set_mixer_defaults(struct echoaudio *chip) | ||
69 | { | ||
70 | return init_line_levels(chip); | ||
71 | } | ||
diff --git a/sound/pci/echoaudio/indigoio.c b/sound/pci/echoaudio/indigoio.c index a60c0a0a89b7..1035125336d6 100644 --- a/sound/pci/echoaudio/indigoio.c +++ b/sound/pci/echoaudio/indigoio.c | |||
@@ -69,7 +69,7 @@ static const struct firmware card_fw[] = { | |||
69 | {0, "indigo_io_dsp.fw"} | 69 | {0, "indigo_io_dsp.fw"} |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static struct pci_device_id snd_echo_ids[] = { | 72 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
73 | {0x1057, 0x3410, 0xECC0, 0x00A0, 0, 0, 0}, /* Indigo IO*/ | 73 | {0x1057, 0x3410, 0xECC0, 0x00A0, 0, 0, 0}, /* Indigo IO*/ |
74 | {0,} | 74 | {0,} |
75 | }; | 75 | }; |
diff --git a/sound/pci/echoaudio/indigoio_dsp.c b/sound/pci/echoaudio/indigoio_dsp.c index 0604c8a85223..beb9a5b69892 100644 --- a/sound/pci/echoaudio/indigoio_dsp.c +++ b/sound/pci/echoaudio/indigoio_dsp.c | |||
@@ -50,7 +50,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
50 | chip->device_id = device_id; | 50 | chip->device_id = device_id; |
51 | chip->subdevice_id = subdevice_id; | 51 | chip->subdevice_id = subdevice_id; |
52 | chip->bad_board = TRUE; | 52 | chip->bad_board = TRUE; |
53 | chip->dsp_code_to_load = &card_fw[FW_INDIGO_IO_DSP]; | 53 | chip->dsp_code_to_load = FW_INDIGO_IO_DSP; |
54 | /* Since this card has no ASIC, mark it as loaded so everything | 54 | /* Since this card has no ASIC, mark it as loaded so everything |
55 | works OK */ | 55 | works OK */ |
56 | chip->asic_loaded = TRUE; | 56 | chip->asic_loaded = TRUE; |
@@ -60,15 +60,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
60 | return err; | 60 | return err; |
61 | chip->bad_board = FALSE; | 61 | chip->bad_board = FALSE; |
62 | 62 | ||
63 | if ((err = init_line_levels(chip)) < 0) | ||
64 | return err; | ||
65 | |||
66 | DE_INIT(("init_hw done\n")); | 63 | DE_INIT(("init_hw done\n")); |
67 | return err; | 64 | return err; |
68 | } | 65 | } |
69 | 66 | ||
70 | 67 | ||
71 | 68 | ||
69 | static int set_mixer_defaults(struct echoaudio *chip) | ||
70 | { | ||
71 | return init_line_levels(chip); | ||
72 | } | ||
73 | |||
74 | |||
75 | |||
72 | static u32 detect_input_clocks(const struct echoaudio *chip) | 76 | static u32 detect_input_clocks(const struct echoaudio *chip) |
73 | { | 77 | { |
74 | return ECHO_CLOCK_BIT_INTERNAL; | 78 | return ECHO_CLOCK_BIT_INTERNAL; |
diff --git a/sound/pci/echoaudio/indigoiox.c b/sound/pci/echoaudio/indigoiox.c index eb3819f9654a..60b7cb2753cf 100644 --- a/sound/pci/echoaudio/indigoiox.c +++ b/sound/pci/echoaudio/indigoiox.c | |||
@@ -69,7 +69,7 @@ static const struct firmware card_fw[] = { | |||
69 | {0, "indigo_iox_dsp.fw"} | 69 | {0, "indigo_iox_dsp.fw"} |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static struct pci_device_id snd_echo_ids[] = { | 72 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
73 | {0x1057, 0x3410, 0xECC0, 0x00D0, 0, 0, 0}, /* Indigo IOx */ | 73 | {0x1057, 0x3410, 0xECC0, 0x00D0, 0, 0, 0}, /* Indigo IOx */ |
74 | {0,} | 74 | {0,} |
75 | }; | 75 | }; |
diff --git a/sound/pci/echoaudio/indigoiox_dsp.c b/sound/pci/echoaudio/indigoiox_dsp.c index f357521c79e6..394c6e76bcbc 100644 --- a/sound/pci/echoaudio/indigoiox_dsp.c +++ b/sound/pci/echoaudio/indigoiox_dsp.c | |||
@@ -48,7 +48,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
48 | chip->device_id = device_id; | 48 | chip->device_id = device_id; |
49 | chip->subdevice_id = subdevice_id; | 49 | chip->subdevice_id = subdevice_id; |
50 | chip->bad_board = TRUE; | 50 | chip->bad_board = TRUE; |
51 | chip->dsp_code_to_load = &card_fw[FW_INDIGO_IOX_DSP]; | 51 | chip->dsp_code_to_load = FW_INDIGO_IOX_DSP; |
52 | /* Since this card has no ASIC, mark it as loaded so everything | 52 | /* Since this card has no ASIC, mark it as loaded so everything |
53 | works OK */ | 53 | works OK */ |
54 | chip->asic_loaded = TRUE; | 54 | chip->asic_loaded = TRUE; |
@@ -59,10 +59,13 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
59 | return err; | 59 | return err; |
60 | chip->bad_board = FALSE; | 60 | chip->bad_board = FALSE; |
61 | 61 | ||
62 | err = init_line_levels(chip); | ||
63 | if (err < 0) | ||
64 | return err; | ||
65 | |||
66 | DE_INIT(("init_hw done\n")); | 62 | DE_INIT(("init_hw done\n")); |
67 | return err; | 63 | return err; |
68 | } | 64 | } |
65 | |||
66 | |||
67 | |||
68 | static int set_mixer_defaults(struct echoaudio *chip) | ||
69 | { | ||
70 | return init_line_levels(chip); | ||
71 | } | ||
diff --git a/sound/pci/echoaudio/layla20.c b/sound/pci/echoaudio/layla20.c index 506194688995..8c3f5c5b5301 100644 --- a/sound/pci/echoaudio/layla20.c +++ b/sound/pci/echoaudio/layla20.c | |||
@@ -76,7 +76,7 @@ static const struct firmware card_fw[] = { | |||
76 | {0, "layla20_asic.fw"} | 76 | {0, "layla20_asic.fw"} |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static struct pci_device_id snd_echo_ids[] = { | 79 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
80 | {0x1057, 0x1801, 0xECC0, 0x0030, 0, 0, 0}, /* DSP 56301 Layla20 rev.0 */ | 80 | {0x1057, 0x1801, 0xECC0, 0x0030, 0, 0, 0}, /* DSP 56301 Layla20 rev.0 */ |
81 | {0x1057, 0x1801, 0xECC0, 0x0031, 0, 0, 0}, /* DSP 56301 Layla20 rev.1 */ | 81 | {0x1057, 0x1801, 0xECC0, 0x0031, 0, 0, 0}, /* DSP 56301 Layla20 rev.1 */ |
82 | {0,} | 82 | {0,} |
diff --git a/sound/pci/echoaudio/layla20_dsp.c b/sound/pci/echoaudio/layla20_dsp.c index 83750e9fd7b4..53ce94605044 100644 --- a/sound/pci/echoaudio/layla20_dsp.c +++ b/sound/pci/echoaudio/layla20_dsp.c | |||
@@ -31,8 +31,7 @@ | |||
31 | 31 | ||
32 | static int read_dsp(struct echoaudio *chip, u32 *data); | 32 | static int read_dsp(struct echoaudio *chip, u32 *data); |
33 | static int set_professional_spdif(struct echoaudio *chip, char prof); | 33 | static int set_professional_spdif(struct echoaudio *chip, char prof); |
34 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, | 34 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic); |
35 | const struct firmware *asic); | ||
36 | static int check_asic_status(struct echoaudio *chip); | 35 | static int check_asic_status(struct echoaudio *chip); |
37 | static int update_flags(struct echoaudio *chip); | 36 | static int update_flags(struct echoaudio *chip); |
38 | 37 | ||
@@ -54,7 +53,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
54 | chip->subdevice_id = subdevice_id; | 53 | chip->subdevice_id = subdevice_id; |
55 | chip->bad_board = TRUE; | 54 | chip->bad_board = TRUE; |
56 | chip->has_midi = TRUE; | 55 | chip->has_midi = TRUE; |
57 | chip->dsp_code_to_load = &card_fw[FW_LAYLA20_DSP]; | 56 | chip->dsp_code_to_load = FW_LAYLA20_DSP; |
58 | chip->input_clock_types = | 57 | chip->input_clock_types = |
59 | ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF | | 58 | ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF | |
60 | ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_SUPER; | 59 | ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_SUPER; |
@@ -65,17 +64,20 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
65 | return err; | 64 | return err; |
66 | chip->bad_board = FALSE; | 65 | chip->bad_board = FALSE; |
67 | 66 | ||
68 | if ((err = init_line_levels(chip)) < 0) | ||
69 | return err; | ||
70 | |||
71 | err = set_professional_spdif(chip, TRUE); | ||
72 | |||
73 | DE_INIT(("init_hw done\n")); | 67 | DE_INIT(("init_hw done\n")); |
74 | return err; | 68 | return err; |
75 | } | 69 | } |
76 | 70 | ||
77 | 71 | ||
78 | 72 | ||
73 | static int set_mixer_defaults(struct echoaudio *chip) | ||
74 | { | ||
75 | chip->professional_spdif = FALSE; | ||
76 | return init_line_levels(chip); | ||
77 | } | ||
78 | |||
79 | |||
80 | |||
79 | static u32 detect_input_clocks(const struct echoaudio *chip) | 81 | static u32 detect_input_clocks(const struct echoaudio *chip) |
80 | { | 82 | { |
81 | u32 clocks_from_dsp, clock_bits; | 83 | u32 clocks_from_dsp, clock_bits; |
@@ -144,7 +146,7 @@ static int load_asic(struct echoaudio *chip) | |||
144 | return 0; | 146 | return 0; |
145 | 147 | ||
146 | err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA_ASIC, | 148 | err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA_ASIC, |
147 | &card_fw[FW_LAYLA20_ASIC]); | 149 | FW_LAYLA20_ASIC); |
148 | if (err < 0) | 150 | if (err < 0) |
149 | return err; | 151 | return err; |
150 | 152 | ||
diff --git a/sound/pci/echoaudio/layla24.c b/sound/pci/echoaudio/layla24.c index e09e3ea7781e..ed1cc0abc2b8 100644 --- a/sound/pci/echoaudio/layla24.c +++ b/sound/pci/echoaudio/layla24.c | |||
@@ -87,7 +87,7 @@ static const struct firmware card_fw[] = { | |||
87 | {0, "layla24_2S_asic.fw"} | 87 | {0, "layla24_2S_asic.fw"} |
88 | }; | 88 | }; |
89 | 89 | ||
90 | static struct pci_device_id snd_echo_ids[] = { | 90 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
91 | {0x1057, 0x3410, 0xECC0, 0x0060, 0, 0, 0}, /* DSP 56361 Layla24 rev.0 */ | 91 | {0x1057, 0x3410, 0xECC0, 0x0060, 0, 0, 0}, /* DSP 56361 Layla24 rev.0 */ |
92 | {0,} | 92 | {0,} |
93 | }; | 93 | }; |
diff --git a/sound/pci/echoaudio/layla24_dsp.c b/sound/pci/echoaudio/layla24_dsp.c index d61b5cbcccad..8c041647f285 100644 --- a/sound/pci/echoaudio/layla24_dsp.c +++ b/sound/pci/echoaudio/layla24_dsp.c | |||
@@ -32,8 +32,7 @@ static int write_control_reg(struct echoaudio *chip, u32 value, char force); | |||
32 | static int set_input_clock(struct echoaudio *chip, u16 clock); | 32 | static int set_input_clock(struct echoaudio *chip, u16 clock); |
33 | static int set_professional_spdif(struct echoaudio *chip, char prof); | 33 | static int set_professional_spdif(struct echoaudio *chip, char prof); |
34 | static int set_digital_mode(struct echoaudio *chip, u8 mode); | 34 | static int set_digital_mode(struct echoaudio *chip, u8 mode); |
35 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, | 35 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic); |
36 | const struct firmware *asic); | ||
37 | static int check_asic_status(struct echoaudio *chip); | 36 | static int check_asic_status(struct echoaudio *chip); |
38 | 37 | ||
39 | 38 | ||
@@ -54,7 +53,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
54 | chip->subdevice_id = subdevice_id; | 53 | chip->subdevice_id = subdevice_id; |
55 | chip->bad_board = TRUE; | 54 | chip->bad_board = TRUE; |
56 | chip->has_midi = TRUE; | 55 | chip->has_midi = TRUE; |
57 | chip->dsp_code_to_load = &card_fw[FW_LAYLA24_DSP]; | 56 | chip->dsp_code_to_load = FW_LAYLA24_DSP; |
58 | chip->input_clock_types = | 57 | chip->input_clock_types = |
59 | ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF | | 58 | ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF | |
60 | ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_ADAT; | 59 | ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_ADAT; |
@@ -62,9 +61,6 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
62 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | | 61 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | |
63 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | | 62 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | |
64 | ECHOCAPS_HAS_DIGITAL_MODE_ADAT; | 63 | ECHOCAPS_HAS_DIGITAL_MODE_ADAT; |
65 | chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; | ||
66 | chip->professional_spdif = FALSE; | ||
67 | chip->digital_in_automute = TRUE; | ||
68 | 64 | ||
69 | if ((err = load_firmware(chip)) < 0) | 65 | if ((err = load_firmware(chip)) < 0) |
70 | return err; | 66 | return err; |
@@ -73,17 +69,22 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
73 | if ((err = init_line_levels(chip)) < 0) | 69 | if ((err = init_line_levels(chip)) < 0) |
74 | return err; | 70 | return err; |
75 | 71 | ||
76 | err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); | ||
77 | if (err < 0) | ||
78 | return err; | ||
79 | err = set_professional_spdif(chip, TRUE); | ||
80 | |||
81 | DE_INIT(("init_hw done\n")); | 72 | DE_INIT(("init_hw done\n")); |
82 | return err; | 73 | return err; |
83 | } | 74 | } |
84 | 75 | ||
85 | 76 | ||
86 | 77 | ||
78 | static int set_mixer_defaults(struct echoaudio *chip) | ||
79 | { | ||
80 | chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; | ||
81 | chip->professional_spdif = FALSE; | ||
82 | chip->digital_in_automute = TRUE; | ||
83 | return init_line_levels(chip); | ||
84 | } | ||
85 | |||
86 | |||
87 | |||
87 | static u32 detect_input_clocks(const struct echoaudio *chip) | 88 | static u32 detect_input_clocks(const struct echoaudio *chip) |
88 | { | 89 | { |
89 | u32 clocks_from_dsp, clock_bits; | 90 | u32 clocks_from_dsp, clock_bits; |
@@ -123,18 +124,18 @@ static int load_asic(struct echoaudio *chip) | |||
123 | 124 | ||
124 | /* Load the ASIC for the PCI card */ | 125 | /* Load the ASIC for the PCI card */ |
125 | err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA24_PCI_CARD_ASIC, | 126 | err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA24_PCI_CARD_ASIC, |
126 | &card_fw[FW_LAYLA24_1_ASIC]); | 127 | FW_LAYLA24_1_ASIC); |
127 | if (err < 0) | 128 | if (err < 0) |
128 | return err; | 129 | return err; |
129 | 130 | ||
130 | chip->asic_code = &card_fw[FW_LAYLA24_2S_ASIC]; | 131 | chip->asic_code = FW_LAYLA24_2S_ASIC; |
131 | 132 | ||
132 | /* Now give the new ASIC a little time to set up */ | 133 | /* Now give the new ASIC a little time to set up */ |
133 | mdelay(10); | 134 | mdelay(10); |
134 | 135 | ||
135 | /* Do the external one */ | 136 | /* Do the external one */ |
136 | err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA24_EXTERNAL_ASIC, | 137 | err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA24_EXTERNAL_ASIC, |
137 | &card_fw[FW_LAYLA24_2S_ASIC]); | 138 | FW_LAYLA24_2S_ASIC); |
138 | if (err < 0) | 139 | if (err < 0) |
139 | return FALSE; | 140 | return FALSE; |
140 | 141 | ||
@@ -299,7 +300,7 @@ static int set_input_clock(struct echoaudio *chip, u16 clock) | |||
299 | /* Depending on what digital mode you want, Layla24 needs different ASICs | 300 | /* Depending on what digital mode you want, Layla24 needs different ASICs |
300 | loaded. This function checks the ASIC needed for the new mode and sees | 301 | loaded. This function checks the ASIC needed for the new mode and sees |
301 | if it matches the one already loaded. */ | 302 | if it matches the one already loaded. */ |
302 | static int switch_asic(struct echoaudio *chip, const struct firmware *asic) | 303 | static int switch_asic(struct echoaudio *chip, short asic) |
303 | { | 304 | { |
304 | s8 *monitors; | 305 | s8 *monitors; |
305 | 306 | ||
@@ -335,7 +336,7 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode) | |||
335 | { | 336 | { |
336 | u32 control_reg; | 337 | u32 control_reg; |
337 | int err, incompatible_clock; | 338 | int err, incompatible_clock; |
338 | const struct firmware *asic; | 339 | short asic; |
339 | 340 | ||
340 | /* Set clock to "internal" if it's not compatible with the new mode */ | 341 | /* Set clock to "internal" if it's not compatible with the new mode */ |
341 | incompatible_clock = FALSE; | 342 | incompatible_clock = FALSE; |
@@ -344,12 +345,12 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode) | |||
344 | case DIGITAL_MODE_SPDIF_RCA: | 345 | case DIGITAL_MODE_SPDIF_RCA: |
345 | if (chip->input_clock == ECHO_CLOCK_ADAT) | 346 | if (chip->input_clock == ECHO_CLOCK_ADAT) |
346 | incompatible_clock = TRUE; | 347 | incompatible_clock = TRUE; |
347 | asic = &card_fw[FW_LAYLA24_2S_ASIC]; | 348 | asic = FW_LAYLA24_2S_ASIC; |
348 | break; | 349 | break; |
349 | case DIGITAL_MODE_ADAT: | 350 | case DIGITAL_MODE_ADAT: |
350 | if (chip->input_clock == ECHO_CLOCK_SPDIF) | 351 | if (chip->input_clock == ECHO_CLOCK_SPDIF) |
351 | incompatible_clock = TRUE; | 352 | incompatible_clock = TRUE; |
352 | asic = &card_fw[FW_LAYLA24_2A_ASIC]; | 353 | asic = FW_LAYLA24_2A_ASIC; |
353 | break; | 354 | break; |
354 | default: | 355 | default: |
355 | DE_ACT(("Digital mode not supported: %d\n", mode)); | 356 | DE_ACT(("Digital mode not supported: %d\n", mode)); |
diff --git a/sound/pci/echoaudio/mia.c b/sound/pci/echoaudio/mia.c index f05c8c097aa8..cc2bbfc65327 100644 --- a/sound/pci/echoaudio/mia.c +++ b/sound/pci/echoaudio/mia.c | |||
@@ -77,7 +77,7 @@ static const struct firmware card_fw[] = { | |||
77 | {0, "mia_dsp.fw"} | 77 | {0, "mia_dsp.fw"} |
78 | }; | 78 | }; |
79 | 79 | ||
80 | static struct pci_device_id snd_echo_ids[] = { | 80 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
81 | {0x1057, 0x3410, 0xECC0, 0x0080, 0, 0, 0}, /* DSP 56361 Mia rev.0 */ | 81 | {0x1057, 0x3410, 0xECC0, 0x0080, 0, 0, 0}, /* DSP 56361 Mia rev.0 */ |
82 | {0x1057, 0x3410, 0xECC0, 0x0081, 0, 0, 0}, /* DSP 56361 Mia rev.1 */ | 82 | {0x1057, 0x3410, 0xECC0, 0x0081, 0, 0, 0}, /* DSP 56361 Mia rev.1 */ |
83 | {0,} | 83 | {0,} |
diff --git a/sound/pci/echoaudio/mia_dsp.c b/sound/pci/echoaudio/mia_dsp.c index 551405114cbc..6ebfa6e7ab9e 100644 --- a/sound/pci/echoaudio/mia_dsp.c +++ b/sound/pci/echoaudio/mia_dsp.c | |||
@@ -53,7 +53,7 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
53 | chip->device_id = device_id; | 53 | chip->device_id = device_id; |
54 | chip->subdevice_id = subdevice_id; | 54 | chip->subdevice_id = subdevice_id; |
55 | chip->bad_board = TRUE; | 55 | chip->bad_board = TRUE; |
56 | chip->dsp_code_to_load = &card_fw[FW_MIA_DSP]; | 56 | chip->dsp_code_to_load = FW_MIA_DSP; |
57 | /* Since this card has no ASIC, mark it as loaded so everything | 57 | /* Since this card has no ASIC, mark it as loaded so everything |
58 | works OK */ | 58 | works OK */ |
59 | chip->asic_loaded = TRUE; | 59 | chip->asic_loaded = TRUE; |
@@ -66,15 +66,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
66 | return err; | 66 | return err; |
67 | chip->bad_board = FALSE; | 67 | chip->bad_board = FALSE; |
68 | 68 | ||
69 | if ((err = init_line_levels(chip))) | ||
70 | return err; | ||
71 | |||
72 | DE_INIT(("init_hw done\n")); | 69 | DE_INIT(("init_hw done\n")); |
73 | return err; | 70 | return err; |
74 | } | 71 | } |
75 | 72 | ||
76 | 73 | ||
77 | 74 | ||
75 | static int set_mixer_defaults(struct echoaudio *chip) | ||
76 | { | ||
77 | return init_line_levels(chip); | ||
78 | } | ||
79 | |||
80 | |||
81 | |||
78 | static u32 detect_input_clocks(const struct echoaudio *chip) | 82 | static u32 detect_input_clocks(const struct echoaudio *chip) |
79 | { | 83 | { |
80 | u32 clocks_from_dsp, clock_bits; | 84 | u32 clocks_from_dsp, clock_bits; |
diff --git a/sound/pci/echoaudio/mona.c b/sound/pci/echoaudio/mona.c index b05bad944901..3e7e01824b40 100644 --- a/sound/pci/echoaudio/mona.c +++ b/sound/pci/echoaudio/mona.c | |||
@@ -92,7 +92,7 @@ static const struct firmware card_fw[] = { | |||
92 | {0, "mona_2_asic.fw"} | 92 | {0, "mona_2_asic.fw"} |
93 | }; | 93 | }; |
94 | 94 | ||
95 | static struct pci_device_id snd_echo_ids[] = { | 95 | static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { |
96 | {0x1057, 0x1801, 0xECC0, 0x0070, 0, 0, 0}, /* DSP 56301 Mona rev.0 */ | 96 | {0x1057, 0x1801, 0xECC0, 0x0070, 0, 0, 0}, /* DSP 56301 Mona rev.0 */ |
97 | {0x1057, 0x1801, 0xECC0, 0x0071, 0, 0, 0}, /* DSP 56301 Mona rev.1 */ | 97 | {0x1057, 0x1801, 0xECC0, 0x0071, 0, 0, 0}, /* DSP 56301 Mona rev.1 */ |
98 | {0x1057, 0x1801, 0xECC0, 0x0072, 0, 0, 0}, /* DSP 56301 Mona rev.2 */ | 98 | {0x1057, 0x1801, 0xECC0, 0x0072, 0, 0, 0}, /* DSP 56301 Mona rev.2 */ |
diff --git a/sound/pci/echoaudio/mona_dsp.c b/sound/pci/echoaudio/mona_dsp.c index eaa619bd2a03..6e6a7eb555b8 100644 --- a/sound/pci/echoaudio/mona_dsp.c +++ b/sound/pci/echoaudio/mona_dsp.c | |||
@@ -33,8 +33,7 @@ static int write_control_reg(struct echoaudio *chip, u32 value, char force); | |||
33 | static int set_input_clock(struct echoaudio *chip, u16 clock); | 33 | static int set_input_clock(struct echoaudio *chip, u16 clock); |
34 | static int set_professional_spdif(struct echoaudio *chip, char prof); | 34 | static int set_professional_spdif(struct echoaudio *chip, char prof); |
35 | static int set_digital_mode(struct echoaudio *chip, u8 mode); | 35 | static int set_digital_mode(struct echoaudio *chip, u8 mode); |
36 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, | 36 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic); |
37 | const struct firmware *asic); | ||
38 | static int check_asic_status(struct echoaudio *chip); | 37 | static int check_asic_status(struct echoaudio *chip); |
39 | 38 | ||
40 | 39 | ||
@@ -64,32 +63,30 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) | |||
64 | 63 | ||
65 | /* Mona comes in both '301 and '361 flavors */ | 64 | /* Mona comes in both '301 and '361 flavors */ |
66 | if (chip->device_id == DEVICE_ID_56361) | 65 | if (chip->device_id == DEVICE_ID_56361) |
67 | chip->dsp_code_to_load = &card_fw[FW_MONA_361_DSP]; | 66 | chip->dsp_code_to_load = FW_MONA_361_DSP; |
68 | else | 67 | else |
69 | chip->dsp_code_to_load = &card_fw[FW_MONA_301_DSP]; | 68 | chip->dsp_code_to_load = FW_MONA_301_DSP; |
70 | |||
71 | chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; | ||
72 | chip->professional_spdif = FALSE; | ||
73 | chip->digital_in_automute = TRUE; | ||
74 | 69 | ||
75 | if ((err = load_firmware(chip)) < 0) | 70 | if ((err = load_firmware(chip)) < 0) |
76 | return err; | 71 | return err; |
77 | chip->bad_board = FALSE; | 72 | chip->bad_board = FALSE; |
78 | 73 | ||
79 | if ((err = init_line_levels(chip)) < 0) | ||
80 | return err; | ||
81 | |||
82 | err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); | ||
83 | if (err < 0) | ||
84 | return err; | ||
85 | err = set_professional_spdif(chip, TRUE); | ||
86 | |||
87 | DE_INIT(("init_hw done\n")); | 74 | DE_INIT(("init_hw done\n")); |
88 | return err; | 75 | return err; |
89 | } | 76 | } |
90 | 77 | ||
91 | 78 | ||
92 | 79 | ||
80 | static int set_mixer_defaults(struct echoaudio *chip) | ||
81 | { | ||
82 | chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; | ||
83 | chip->professional_spdif = FALSE; | ||
84 | chip->digital_in_automute = TRUE; | ||
85 | return init_line_levels(chip); | ||
86 | } | ||
87 | |||
88 | |||
89 | |||
93 | static u32 detect_input_clocks(const struct echoaudio *chip) | 90 | static u32 detect_input_clocks(const struct echoaudio *chip) |
94 | { | 91 | { |
95 | u32 clocks_from_dsp, clock_bits; | 92 | u32 clocks_from_dsp, clock_bits; |
@@ -120,7 +117,7 @@ static int load_asic(struct echoaudio *chip) | |||
120 | { | 117 | { |
121 | u32 control_reg; | 118 | u32 control_reg; |
122 | int err; | 119 | int err; |
123 | const struct firmware *asic; | 120 | short asic; |
124 | 121 | ||
125 | if (chip->asic_loaded) | 122 | if (chip->asic_loaded) |
126 | return 0; | 123 | return 0; |
@@ -128,9 +125,9 @@ static int load_asic(struct echoaudio *chip) | |||
128 | mdelay(10); | 125 | mdelay(10); |
129 | 126 | ||
130 | if (chip->device_id == DEVICE_ID_56361) | 127 | if (chip->device_id == DEVICE_ID_56361) |
131 | asic = &card_fw[FW_MONA_361_1_ASIC48]; | 128 | asic = FW_MONA_361_1_ASIC48; |
132 | else | 129 | else |
133 | asic = &card_fw[FW_MONA_301_1_ASIC48]; | 130 | asic = FW_MONA_301_1_ASIC48; |
134 | 131 | ||
135 | err = load_asic_generic(chip, DSP_FNC_LOAD_MONA_PCI_CARD_ASIC, asic); | 132 | err = load_asic_generic(chip, DSP_FNC_LOAD_MONA_PCI_CARD_ASIC, asic); |
136 | if (err < 0) | 133 | if (err < 0) |
@@ -141,7 +138,7 @@ static int load_asic(struct echoaudio *chip) | |||
141 | 138 | ||
142 | /* Do the external one */ | 139 | /* Do the external one */ |
143 | err = load_asic_generic(chip, DSP_FNC_LOAD_MONA_EXTERNAL_ASIC, | 140 | err = load_asic_generic(chip, DSP_FNC_LOAD_MONA_EXTERNAL_ASIC, |
144 | &card_fw[FW_MONA_2_ASIC]); | 141 | FW_MONA_2_ASIC); |
145 | if (err < 0) | 142 | if (err < 0) |
146 | return err; | 143 | return err; |
147 | 144 | ||
@@ -165,22 +162,22 @@ loaded. This function checks the ASIC needed for the new mode and sees | |||
165 | if it matches the one already loaded. */ | 162 | if it matches the one already loaded. */ |
166 | static int switch_asic(struct echoaudio *chip, char double_speed) | 163 | static int switch_asic(struct echoaudio *chip, char double_speed) |
167 | { | 164 | { |
168 | const struct firmware *asic; | ||
169 | int err; | 165 | int err; |
166 | short asic; | ||
170 | 167 | ||
171 | /* Check the clock detect bits to see if this is | 168 | /* Check the clock detect bits to see if this is |
172 | a single-speed clock or a double-speed clock; load | 169 | a single-speed clock or a double-speed clock; load |
173 | a new ASIC if necessary. */ | 170 | a new ASIC if necessary. */ |
174 | if (chip->device_id == DEVICE_ID_56361) { | 171 | if (chip->device_id == DEVICE_ID_56361) { |
175 | if (double_speed) | 172 | if (double_speed) |
176 | asic = &card_fw[FW_MONA_361_1_ASIC96]; | 173 | asic = FW_MONA_361_1_ASIC96; |
177 | else | 174 | else |
178 | asic = &card_fw[FW_MONA_361_1_ASIC48]; | 175 | asic = FW_MONA_361_1_ASIC48; |
179 | } else { | 176 | } else { |
180 | if (double_speed) | 177 | if (double_speed) |
181 | asic = &card_fw[FW_MONA_301_1_ASIC96]; | 178 | asic = FW_MONA_301_1_ASIC96; |
182 | else | 179 | else |
183 | asic = &card_fw[FW_MONA_301_1_ASIC48]; | 180 | asic = FW_MONA_301_1_ASIC48; |
184 | } | 181 | } |
185 | 182 | ||
186 | if (asic != chip->asic_code) { | 183 | if (asic != chip->asic_code) { |
@@ -200,7 +197,7 @@ static int switch_asic(struct echoaudio *chip, char double_speed) | |||
200 | static int set_sample_rate(struct echoaudio *chip, u32 rate) | 197 | static int set_sample_rate(struct echoaudio *chip, u32 rate) |
201 | { | 198 | { |
202 | u32 control_reg, clock; | 199 | u32 control_reg, clock; |
203 | const struct firmware *asic; | 200 | short asic; |
204 | char force_write; | 201 | char force_write; |
205 | 202 | ||
206 | /* Only set the clock for internal mode. */ | 203 | /* Only set the clock for internal mode. */ |
@@ -218,14 +215,14 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate) | |||
218 | if (chip->digital_mode == DIGITAL_MODE_ADAT) | 215 | if (chip->digital_mode == DIGITAL_MODE_ADAT) |
219 | return -EINVAL; | 216 | return -EINVAL; |
220 | if (chip->device_id == DEVICE_ID_56361) | 217 | if (chip->device_id == DEVICE_ID_56361) |
221 | asic = &card_fw[FW_MONA_361_1_ASIC96]; | 218 | asic = FW_MONA_361_1_ASIC96; |
222 | else | 219 | else |
223 | asic = &card_fw[FW_MONA_301_1_ASIC96]; | 220 | asic = FW_MONA_301_1_ASIC96; |
224 | } else { | 221 | } else { |
225 | if (chip->device_id == DEVICE_ID_56361) | 222 | if (chip->device_id == DEVICE_ID_56361) |
226 | asic = &card_fw[FW_MONA_361_1_ASIC48]; | 223 | asic = FW_MONA_361_1_ASIC48; |
227 | else | 224 | else |
228 | asic = &card_fw[FW_MONA_301_1_ASIC48]; | 225 | asic = FW_MONA_301_1_ASIC48; |
229 | } | 226 | } |
230 | 227 | ||
231 | force_write = 0; | 228 | force_write = 0; |
@@ -410,8 +407,8 @@ static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode) | |||
410 | case DIGITAL_MODE_ADAT: | 407 | case DIGITAL_MODE_ADAT: |
411 | /* If the current ASIC is the 96KHz ASIC, switch the ASIC | 408 | /* If the current ASIC is the 96KHz ASIC, switch the ASIC |
412 | and set to 48 KHz */ | 409 | and set to 48 KHz */ |
413 | if (chip->asic_code == &card_fw[FW_MONA_361_1_ASIC96] || | 410 | if (chip->asic_code == FW_MONA_361_1_ASIC96 || |
414 | chip->asic_code == &card_fw[FW_MONA_301_1_ASIC96]) { | 411 | chip->asic_code == FW_MONA_301_1_ASIC96) { |
415 | set_sample_rate(chip, 48000); | 412 | set_sample_rate(chip, 48000); |
416 | } | 413 | } |
417 | control_reg |= GML_ADAT_MODE; | 414 | control_reg |= GML_ADAT_MODE; |
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index 168af67d938e..4203782d7cb7 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c | |||
@@ -76,7 +76,7 @@ MODULE_PARM_DESC(subsystem, "Force card subsystem model."); | |||
76 | /* | 76 | /* |
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 DEFINE_PCI_DEVICE_TABLE(snd_emu10k1_ids) = { |
80 | { PCI_VDEVICE(CREATIVE, 0x0002), 0 }, /* EMU10K1 */ | 80 | { PCI_VDEVICE(CREATIVE, 0x0002), 0 }, /* EMU10K1 */ |
81 | { PCI_VDEVICE(CREATIVE, 0x0004), 1 }, /* Audigy */ | 81 | { PCI_VDEVICE(CREATIVE, 0x0004), 1 }, /* Audigy */ |
82 | { PCI_VDEVICE(CREATIVE, 0x0008), 1 }, /* Audigy 2 Value SB0400 */ | 82 | { PCI_VDEVICE(CREATIVE, 0x0008), 1 }, /* Audigy 2 Value SB0400 */ |
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 1d369ff73805..df47f738098d 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c | |||
@@ -1605,7 +1605,7 @@ static void __devexit snd_emu10k1x_remove(struct pci_dev *pci) | |||
1605 | } | 1605 | } |
1606 | 1606 | ||
1607 | // PCI IDs | 1607 | // PCI IDs |
1608 | static struct pci_device_id snd_emu10k1x_ids[] = { | 1608 | static DEFINE_PCI_DEVICE_TABLE(snd_emu10k1x_ids) = { |
1609 | { PCI_VDEVICE(CREATIVE, 0x0006), 0 }, /* Dell OEM version (EMU10K1) */ | 1609 | { PCI_VDEVICE(CREATIVE, 0x0006), 0 }, /* Dell OEM version (EMU10K1) */ |
1610 | { 0, } | 1610 | { 0, } |
1611 | }; | 1611 | }; |
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 2b82c5c723e1..c7fba5379813 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c | |||
@@ -443,7 +443,7 @@ struct ensoniq { | |||
443 | 443 | ||
444 | static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id); | 444 | static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id); |
445 | 445 | ||
446 | static struct pci_device_id snd_audiopci_ids[] = { | 446 | static DEFINE_PCI_DEVICE_TABLE(snd_audiopci_ids) = { |
447 | #ifdef CHIP1370 | 447 | #ifdef CHIP1370 |
448 | { PCI_VDEVICE(ENSONIQ, 0x5000), 0, }, /* ES1370 */ | 448 | { PCI_VDEVICE(ENSONIQ, 0x5000), 0, }, /* ES1370 */ |
449 | #endif | 449 | #endif |
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index fb83e1ffa5cb..553b75217259 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c | |||
@@ -243,7 +243,7 @@ struct es1938 { | |||
243 | 243 | ||
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 DEFINE_PCI_DEVICE_TABLE(snd_es1938_ids) = { |
247 | { PCI_VDEVICE(ESS, 0x1969), 0, }, /* Solo-1 */ | 247 | { PCI_VDEVICE(ESS, 0x1969), 0, }, /* Solo-1 */ |
248 | { 0, } | 248 | { 0, } |
249 | }; | 249 | }; |
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index a11f453a6b6d..ecaea9fb48ec 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c | |||
@@ -551,7 +551,7 @@ struct es1968 { | |||
551 | 551 | ||
552 | static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id); | 552 | static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id); |
553 | 553 | ||
554 | static struct pci_device_id snd_es1968_ids[] = { | 554 | static DEFINE_PCI_DEVICE_TABLE(snd_es1968_ids) = { |
555 | /* Maestro 1 */ | 555 | /* Maestro 1 */ |
556 | { 0x1285, 0x0100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, TYPE_MAESTRO }, | 556 | { 0x1285, 0x0100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, TYPE_MAESTRO }, |
557 | /* Maestro 2 */ | 557 | /* Maestro 2 */ |
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 83508b3964fb..e1baad74ea4b 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c | |||
@@ -205,7 +205,7 @@ struct fm801 { | |||
205 | #endif | 205 | #endif |
206 | }; | 206 | }; |
207 | 207 | ||
208 | static struct pci_device_id snd_fm801_ids[] = { | 208 | static DEFINE_PCI_DEVICE_TABLE(snd_fm801_ids) = { |
209 | { 0x1319, 0x0801, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* FM801 */ | 209 | { 0x1319, 0x0801, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* FM801 */ |
210 | { 0x5213, 0x0510, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* Gallant Odyssey Sound 4 */ | 210 | { 0x5213, 0x0510, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* Gallant Odyssey Sound 4 */ |
211 | { 0, } | 211 | { 0, } |
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 556cff937be7..567348b05b5a 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig | |||
@@ -157,7 +157,7 @@ config SND_HDA_CODEC_INTELHDMI | |||
157 | 157 | ||
158 | config SND_HDA_ELD | 158 | config SND_HDA_ELD |
159 | def_bool y | 159 | def_bool y |
160 | depends on SND_HDA_CODEC_INTELHDMI | 160 | depends on SND_HDA_CODEC_INTELHDMI || SND_HDA_CODEC_NVHDMI |
161 | 161 | ||
162 | config SND_HDA_CODEC_CIRRUS | 162 | config SND_HDA_CODEC_CIRRUS |
163 | bool "Build Cirrus Logic codec support" | 163 | bool "Build Cirrus Logic codec support" |
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile index 315a1c4f8998..24bc195b02da 100644 --- a/sound/pci/hda/Makefile +++ b/sound/pci/hda/Makefile | |||
@@ -3,7 +3,7 @@ snd-hda-intel-objs := hda_intel.o | |||
3 | snd-hda-codec-y := hda_codec.o | 3 | snd-hda-codec-y := hda_codec.o |
4 | snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o | 4 | snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o |
5 | snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o | 5 | snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o |
6 | # snd-hda-codec-$(CONFIG_SND_HDA_ELD) += hda_eld.o | 6 | snd-hda-codec-$(CONFIG_SND_HDA_ELD) += hda_eld.o |
7 | snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o | 7 | snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o |
8 | snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o | 8 | snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o |
9 | 9 | ||
@@ -18,7 +18,7 @@ snd-hda-codec-ca0110-objs := patch_ca0110.o | |||
18 | snd-hda-codec-conexant-objs := patch_conexant.o | 18 | snd-hda-codec-conexant-objs := patch_conexant.o |
19 | snd-hda-codec-via-objs := patch_via.o | 19 | snd-hda-codec-via-objs := patch_via.o |
20 | snd-hda-codec-nvhdmi-objs := patch_nvhdmi.o | 20 | snd-hda-codec-nvhdmi-objs := patch_nvhdmi.o |
21 | snd-hda-codec-intelhdmi-objs := patch_intelhdmi.o hda_eld.o | 21 | snd-hda-codec-intelhdmi-objs := patch_intelhdmi.o |
22 | 22 | ||
23 | # common driver | 23 | # common driver |
24 | obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o | 24 | obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index f98b47cd6cfb..5bd7cf45f3a5 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -824,6 +824,9 @@ int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list, | |||
824 | struct hda_pincfg *pin; | 824 | struct hda_pincfg *pin; |
825 | unsigned int oldcfg; | 825 | unsigned int oldcfg; |
826 | 826 | ||
827 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) | ||
828 | return -EINVAL; | ||
829 | |||
827 | oldcfg = snd_hda_codec_get_pincfg(codec, nid); | 830 | oldcfg = snd_hda_codec_get_pincfg(codec, nid); |
828 | pin = look_up_pincfg(codec, list, nid); | 831 | pin = look_up_pincfg(codec, list, nid); |
829 | if (!pin) { | 832 | if (!pin) { |
@@ -899,6 +902,25 @@ static void restore_pincfgs(struct hda_codec *codec) | |||
899 | } | 902 | } |
900 | } | 903 | } |
901 | 904 | ||
905 | /** | ||
906 | * snd_hda_shutup_pins - Shut up all pins | ||
907 | * @codec: the HDA codec | ||
908 | * | ||
909 | * Clear all pin controls to shup up before suspend for avoiding click noise. | ||
910 | * The controls aren't cached so that they can be resumed properly. | ||
911 | */ | ||
912 | void snd_hda_shutup_pins(struct hda_codec *codec) | ||
913 | { | ||
914 | int i; | ||
915 | for (i = 0; i < codec->init_pins.used; i++) { | ||
916 | struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); | ||
917 | /* use read here for syncing after issuing each verb */ | ||
918 | snd_hda_codec_read(codec, pin->nid, 0, | ||
919 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
920 | } | ||
921 | } | ||
922 | EXPORT_SYMBOL_HDA(snd_hda_shutup_pins); | ||
923 | |||
902 | static void init_hda_cache(struct hda_cache_rec *cache, | 924 | static void init_hda_cache(struct hda_cache_rec *cache, |
903 | unsigned int record_size); | 925 | unsigned int record_size); |
904 | static void free_hda_cache(struct hda_cache_rec *cache); | 926 | static void free_hda_cache(struct hda_cache_rec *cache); |
@@ -931,6 +953,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) | |||
931 | #endif | 953 | #endif |
932 | list_del(&codec->list); | 954 | list_del(&codec->list); |
933 | snd_array_free(&codec->mixers); | 955 | snd_array_free(&codec->mixers); |
956 | snd_array_free(&codec->nids); | ||
934 | codec->bus->caddr_tbl[codec->addr] = NULL; | 957 | codec->bus->caddr_tbl[codec->addr] = NULL; |
935 | if (codec->patch_ops.free) | 958 | if (codec->patch_ops.free) |
936 | codec->patch_ops.free(codec); | 959 | codec->patch_ops.free(codec); |
@@ -955,8 +978,9 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
955 | * | 978 | * |
956 | * Returns 0 if successful, or a negative error code. | 979 | * Returns 0 if successful, or a negative error code. |
957 | */ | 980 | */ |
958 | int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, | 981 | int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, |
959 | struct hda_codec **codecp) | 982 | unsigned int codec_addr, |
983 | struct hda_codec **codecp) | ||
960 | { | 984 | { |
961 | struct hda_codec *codec; | 985 | struct hda_codec *codec; |
962 | char component[31]; | 986 | char component[31]; |
@@ -985,7 +1009,8 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
985 | mutex_init(&codec->control_mutex); | 1009 | mutex_init(&codec->control_mutex); |
986 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); | 1010 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); |
987 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); | 1011 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); |
988 | snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 60); | 1012 | snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32); |
1013 | snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32); | ||
989 | snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); | 1014 | snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); |
990 | snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); | 1015 | snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); |
991 | if (codec->bus->modelname) { | 1016 | if (codec->bus->modelname) { |
@@ -1162,7 +1187,7 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream); | |||
1162 | */ | 1187 | */ |
1163 | 1188 | ||
1164 | /* FIXME: more better hash key? */ | 1189 | /* FIXME: more better hash key? */ |
1165 | #define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) | 1190 | #define HDA_HASH_KEY(nid, dir, idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) |
1166 | #define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24)) | 1191 | #define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24)) |
1167 | #define HDA_HASH_PARPCM_KEY(nid) (u32)((nid) + (0x03 << 24)) | 1192 | #define HDA_HASH_PARPCM_KEY(nid) (u32)((nid) + (0x03 << 24)) |
1168 | #define HDA_HASH_PARSTR_KEY(nid) (u32)((nid) + (0x04 << 24)) | 1193 | #define HDA_HASH_PARSTR_KEY(nid) (u32)((nid) + (0x04 << 24)) |
@@ -1332,7 +1357,8 @@ u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid) | |||
1332 | if (!codec->no_trigger_sense) { | 1357 | if (!codec->no_trigger_sense) { |
1333 | pincap = snd_hda_query_pin_caps(codec, nid); | 1358 | pincap = snd_hda_query_pin_caps(codec, nid); |
1334 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ | 1359 | if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ |
1335 | snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); | 1360 | snd_hda_codec_read(codec, nid, 0, |
1361 | AC_VERB_SET_PIN_SENSE, 0); | ||
1336 | } | 1362 | } |
1337 | return snd_hda_codec_read(codec, nid, 0, | 1363 | return snd_hda_codec_read(codec, nid, 0, |
1338 | AC_VERB_GET_PIN_SENSE, 0); | 1364 | AC_VERB_GET_PIN_SENSE, 0); |
@@ -1348,8 +1374,8 @@ EXPORT_SYMBOL_HDA(snd_hda_pin_sense); | |||
1348 | */ | 1374 | */ |
1349 | int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid) | 1375 | int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid) |
1350 | { | 1376 | { |
1351 | u32 sense = snd_hda_pin_sense(codec, nid); | 1377 | u32 sense = snd_hda_pin_sense(codec, nid); |
1352 | return !!(sense & AC_PINSENSE_PRESENCE); | 1378 | return !!(sense & AC_PINSENSE_PRESENCE); |
1353 | } | 1379 | } |
1354 | EXPORT_SYMBOL_HDA(snd_hda_jack_detect); | 1380 | EXPORT_SYMBOL_HDA(snd_hda_jack_detect); |
1355 | 1381 | ||
@@ -1708,7 +1734,7 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, | |||
1708 | EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl); | 1734 | EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl); |
1709 | 1735 | ||
1710 | /** | 1736 | /** |
1711 | * snd_hda_ctl-add - Add a control element and assign to the codec | 1737 | * snd_hda_ctl_add - Add a control element and assign to the codec |
1712 | * @codec: HD-audio codec | 1738 | * @codec: HD-audio codec |
1713 | * @nid: corresponding NID (optional) | 1739 | * @nid: corresponding NID (optional) |
1714 | * @kctl: the control element to assign | 1740 | * @kctl: the control element to assign |
@@ -1723,19 +1749,25 @@ EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl); | |||
1723 | * | 1749 | * |
1724 | * snd_hda_ctl_add() checks the control subdev id field whether | 1750 | * snd_hda_ctl_add() checks the control subdev id field whether |
1725 | * #HDA_SUBDEV_NID_FLAG bit is set. If set (and @nid is zero), the lower | 1751 | * #HDA_SUBDEV_NID_FLAG bit is set. If set (and @nid is zero), the lower |
1726 | * bits value is taken as the NID to assign. | 1752 | * bits value is taken as the NID to assign. The #HDA_NID_ITEM_AMP bit |
1753 | * specifies if kctl->private_value is a HDA amplifier value. | ||
1727 | */ | 1754 | */ |
1728 | int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, | 1755 | int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, |
1729 | struct snd_kcontrol *kctl) | 1756 | struct snd_kcontrol *kctl) |
1730 | { | 1757 | { |
1731 | int err; | 1758 | int err; |
1759 | unsigned short flags = 0; | ||
1732 | struct hda_nid_item *item; | 1760 | struct hda_nid_item *item; |
1733 | 1761 | ||
1734 | if (kctl->id.subdevice & HDA_SUBDEV_NID_FLAG) { | 1762 | if (kctl->id.subdevice & HDA_SUBDEV_AMP_FLAG) { |
1763 | flags |= HDA_NID_ITEM_AMP; | ||
1735 | if (nid == 0) | 1764 | if (nid == 0) |
1736 | nid = kctl->id.subdevice & 0xffff; | 1765 | nid = get_amp_nid_(kctl->private_value); |
1737 | kctl->id.subdevice = 0; | ||
1738 | } | 1766 | } |
1767 | if ((kctl->id.subdevice & HDA_SUBDEV_NID_FLAG) != 0 && nid == 0) | ||
1768 | nid = kctl->id.subdevice & 0xffff; | ||
1769 | if (kctl->id.subdevice & (HDA_SUBDEV_NID_FLAG|HDA_SUBDEV_AMP_FLAG)) | ||
1770 | kctl->id.subdevice = 0; | ||
1739 | err = snd_ctl_add(codec->bus->card, kctl); | 1771 | err = snd_ctl_add(codec->bus->card, kctl); |
1740 | if (err < 0) | 1772 | if (err < 0) |
1741 | return err; | 1773 | return err; |
@@ -1744,11 +1776,41 @@ int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, | |||
1744 | return -ENOMEM; | 1776 | return -ENOMEM; |
1745 | item->kctl = kctl; | 1777 | item->kctl = kctl; |
1746 | item->nid = nid; | 1778 | item->nid = nid; |
1779 | item->flags = flags; | ||
1747 | return 0; | 1780 | return 0; |
1748 | } | 1781 | } |
1749 | EXPORT_SYMBOL_HDA(snd_hda_ctl_add); | 1782 | EXPORT_SYMBOL_HDA(snd_hda_ctl_add); |
1750 | 1783 | ||
1751 | /** | 1784 | /** |
1785 | * snd_hda_add_nid - Assign a NID to a control element | ||
1786 | * @codec: HD-audio codec | ||
1787 | * @nid: corresponding NID (optional) | ||
1788 | * @kctl: the control element to assign | ||
1789 | * @index: index to kctl | ||
1790 | * | ||
1791 | * Add the given control element to an array inside the codec instance. | ||
1792 | * This function is used when #snd_hda_ctl_add cannot be used for 1:1 | ||
1793 | * NID:KCTL mapping - for example "Capture Source" selector. | ||
1794 | */ | ||
1795 | int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl, | ||
1796 | unsigned int index, hda_nid_t nid) | ||
1797 | { | ||
1798 | struct hda_nid_item *item; | ||
1799 | |||
1800 | if (nid > 0) { | ||
1801 | item = snd_array_new(&codec->nids); | ||
1802 | if (!item) | ||
1803 | return -ENOMEM; | ||
1804 | item->kctl = kctl; | ||
1805 | item->index = index; | ||
1806 | item->nid = nid; | ||
1807 | return 0; | ||
1808 | } | ||
1809 | return -EINVAL; | ||
1810 | } | ||
1811 | EXPORT_SYMBOL_HDA(snd_hda_add_nid); | ||
1812 | |||
1813 | /** | ||
1752 | * snd_hda_ctls_clear - Clear all controls assigned to the given codec | 1814 | * snd_hda_ctls_clear - Clear all controls assigned to the given codec |
1753 | * @codec: HD-audio codec | 1815 | * @codec: HD-audio codec |
1754 | */ | 1816 | */ |
@@ -1759,6 +1821,7 @@ void snd_hda_ctls_clear(struct hda_codec *codec) | |||
1759 | for (i = 0; i < codec->mixers.used; i++) | 1821 | for (i = 0; i < codec->mixers.used; i++) |
1760 | snd_ctl_remove(codec->bus->card, items[i].kctl); | 1822 | snd_ctl_remove(codec->bus->card, items[i].kctl); |
1761 | snd_array_free(&codec->mixers); | 1823 | snd_array_free(&codec->mixers); |
1824 | snd_array_free(&codec->nids); | ||
1762 | } | 1825 | } |
1763 | 1826 | ||
1764 | /* pseudo device locking | 1827 | /* pseudo device locking |
@@ -1891,7 +1954,7 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name, | |||
1891 | err = snd_hda_ctl_add(codec, 0, kctl); | 1954 | err = snd_hda_ctl_add(codec, 0, kctl); |
1892 | if (err < 0) | 1955 | if (err < 0) |
1893 | return err; | 1956 | return err; |
1894 | 1957 | ||
1895 | for (s = slaves; *s; s++) { | 1958 | for (s = slaves; *s; s++) { |
1896 | struct snd_kcontrol *sctl; | 1959 | struct snd_kcontrol *sctl; |
1897 | int i = 0; | 1960 | int i = 0; |
@@ -2378,27 +2441,27 @@ static struct snd_kcontrol_new dig_mixes[] = { | |||
2378 | { | 2441 | { |
2379 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | 2442 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
2380 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2443 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2381 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK), | 2444 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK), |
2382 | .info = snd_hda_spdif_mask_info, | 2445 | .info = snd_hda_spdif_mask_info, |
2383 | .get = snd_hda_spdif_cmask_get, | 2446 | .get = snd_hda_spdif_cmask_get, |
2384 | }, | 2447 | }, |
2385 | { | 2448 | { |
2386 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | 2449 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
2387 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2450 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2388 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK), | 2451 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK), |
2389 | .info = snd_hda_spdif_mask_info, | 2452 | .info = snd_hda_spdif_mask_info, |
2390 | .get = snd_hda_spdif_pmask_get, | 2453 | .get = snd_hda_spdif_pmask_get, |
2391 | }, | 2454 | }, |
2392 | { | 2455 | { |
2393 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2456 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2394 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), | 2457 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), |
2395 | .info = snd_hda_spdif_mask_info, | 2458 | .info = snd_hda_spdif_mask_info, |
2396 | .get = snd_hda_spdif_default_get, | 2459 | .get = snd_hda_spdif_default_get, |
2397 | .put = snd_hda_spdif_default_put, | 2460 | .put = snd_hda_spdif_default_put, |
2398 | }, | 2461 | }, |
2399 | { | 2462 | { |
2400 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2463 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2401 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), | 2464 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH), |
2402 | .info = snd_hda_spdif_out_switch_info, | 2465 | .info = snd_hda_spdif_out_switch_info, |
2403 | .get = snd_hda_spdif_out_switch_get, | 2466 | .get = snd_hda_spdif_out_switch_get, |
2404 | .put = snd_hda_spdif_out_switch_put, | 2467 | .put = snd_hda_spdif_out_switch_put, |
@@ -2549,7 +2612,7 @@ static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol, | |||
2549 | static struct snd_kcontrol_new dig_in_ctls[] = { | 2612 | static struct snd_kcontrol_new dig_in_ctls[] = { |
2550 | { | 2613 | { |
2551 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2614 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2552 | .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), | 2615 | .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, SWITCH), |
2553 | .info = snd_hda_spdif_in_switch_info, | 2616 | .info = snd_hda_spdif_in_switch_info, |
2554 | .get = snd_hda_spdif_in_switch_get, | 2617 | .get = snd_hda_spdif_in_switch_get, |
2555 | .put = snd_hda_spdif_in_switch_put, | 2618 | .put = snd_hda_spdif_in_switch_put, |
@@ -2557,7 +2620,7 @@ static struct snd_kcontrol_new dig_in_ctls[] = { | |||
2557 | { | 2620 | { |
2558 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | 2621 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
2559 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2622 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2560 | .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT), | 2623 | .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT), |
2561 | .info = snd_hda_spdif_mask_info, | 2624 | .info = snd_hda_spdif_mask_info, |
2562 | .get = snd_hda_spdif_in_status_get, | 2625 | .get = snd_hda_spdif_in_status_get, |
2563 | }, | 2626 | }, |
@@ -2706,7 +2769,8 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
2706 | snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, | 2769 | snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, |
2707 | power_state); | 2770 | power_state); |
2708 | /* partial workaround for "azx_get_response timeout" */ | 2771 | /* partial workaround for "azx_get_response timeout" */ |
2709 | if (power_state == AC_PWRST_D0) | 2772 | if (power_state == AC_PWRST_D0 && |
2773 | (codec->vendor_id & 0xffff0000) == 0x14f10000) | ||
2710 | msleep(10); | 2774 | msleep(10); |
2711 | 2775 | ||
2712 | nid = codec->start_nid; | 2776 | nid = codec->start_nid; |
@@ -2740,7 +2804,6 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
2740 | if (power_state == AC_PWRST_D0) { | 2804 | if (power_state == AC_PWRST_D0) { |
2741 | unsigned long end_time; | 2805 | unsigned long end_time; |
2742 | int state; | 2806 | int state; |
2743 | msleep(10); | ||
2744 | /* wait until the codec reachs to D0 */ | 2807 | /* wait until the codec reachs to D0 */ |
2745 | end_time = jiffies + msecs_to_jiffies(500); | 2808 | end_time = jiffies + msecs_to_jiffies(500); |
2746 | do { | 2809 | do { |
@@ -2822,7 +2885,7 @@ int /*__devinit*/ snd_hda_build_controls(struct hda_bus *bus) | |||
2822 | int err = snd_hda_codec_build_controls(codec); | 2885 | int err = snd_hda_codec_build_controls(codec); |
2823 | if (err < 0) { | 2886 | if (err < 0) { |
2824 | printk(KERN_ERR "hda_codec: cannot build controls" | 2887 | printk(KERN_ERR "hda_codec: cannot build controls" |
2825 | "for #%d (error %d)\n", codec->addr, err); | 2888 | "for #%d (error %d)\n", codec->addr, err); |
2826 | err = snd_hda_codec_reset(codec); | 2889 | err = snd_hda_codec_reset(codec); |
2827 | if (err < 0) { | 2890 | if (err < 0) { |
2828 | printk(KERN_ERR | 2891 | printk(KERN_ERR |
@@ -2918,8 +2981,12 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate, | |||
2918 | val |= channels - 1; | 2981 | val |= channels - 1; |
2919 | 2982 | ||
2920 | switch (snd_pcm_format_width(format)) { | 2983 | switch (snd_pcm_format_width(format)) { |
2921 | case 8: val |= 0x00; break; | 2984 | case 8: |
2922 | case 16: val |= 0x10; break; | 2985 | val |= 0x00; |
2986 | break; | ||
2987 | case 16: | ||
2988 | val |= 0x10; | ||
2989 | break; | ||
2923 | case 20: | 2990 | case 20: |
2924 | case 24: | 2991 | case 24: |
2925 | case 32: | 2992 | case 32: |
@@ -3214,6 +3281,8 @@ const char *snd_hda_pcm_type_name[HDA_PCM_NTYPES] = { | |||
3214 | 3281 | ||
3215 | /* | 3282 | /* |
3216 | * get the empty PCM device number to assign | 3283 | * get the empty PCM device number to assign |
3284 | * | ||
3285 | * note the max device number is limited by HDA_MAX_PCMS, currently 10 | ||
3217 | */ | 3286 | */ |
3218 | static int get_empty_pcm_device(struct hda_bus *bus, int type) | 3287 | static int get_empty_pcm_device(struct hda_bus *bus, int type) |
3219 | { | 3288 | { |
@@ -3235,7 +3304,8 @@ static int get_empty_pcm_device(struct hda_bus *bus, int type) | |||
3235 | if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits)) | 3304 | if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits)) |
3236 | return audio_idx[type][i]; | 3305 | return audio_idx[type][i]; |
3237 | 3306 | ||
3238 | snd_printk(KERN_WARNING "Too many %s devices\n", snd_hda_pcm_type_name[type]); | 3307 | snd_printk(KERN_WARNING "Too many %s devices\n", |
3308 | snd_hda_pcm_type_name[type]); | ||
3239 | return -EAGAIN; | 3309 | return -EAGAIN; |
3240 | } | 3310 | } |
3241 | 3311 | ||
@@ -3273,7 +3343,7 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec) | |||
3273 | err = codec->patch_ops.build_pcms(codec); | 3343 | err = codec->patch_ops.build_pcms(codec); |
3274 | if (err < 0) { | 3344 | if (err < 0) { |
3275 | printk(KERN_ERR "hda_codec: cannot build PCMs" | 3345 | printk(KERN_ERR "hda_codec: cannot build PCMs" |
3276 | "for #%d (error %d)\n", codec->addr, err); | 3346 | "for #%d (error %d)\n", codec->addr, err); |
3277 | err = snd_hda_codec_reset(codec); | 3347 | err = snd_hda_codec_reset(codec); |
3278 | if (err < 0) { | 3348 | if (err < 0) { |
3279 | printk(KERN_ERR | 3349 | printk(KERN_ERR |
@@ -3403,8 +3473,8 @@ EXPORT_SYMBOL_HDA(snd_hda_check_board_config); | |||
3403 | 3473 | ||
3404 | /** | 3474 | /** |
3405 | * snd_hda_check_board_codec_sid_config - compare the current codec | 3475 | * snd_hda_check_board_codec_sid_config - compare the current codec |
3406 | subsystem ID with the | 3476 | subsystem ID with the |
3407 | config table | 3477 | config table |
3408 | 3478 | ||
3409 | This is important for Gateway notebooks with SB450 HDA Audio | 3479 | This is important for Gateway notebooks with SB450 HDA Audio |
3410 | where the vendor ID of the PCI device is: | 3480 | where the vendor ID of the PCI device is: |
@@ -3478,6 +3548,8 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) | |||
3478 | 3548 | ||
3479 | for (; knew->name; knew++) { | 3549 | for (; knew->name; knew++) { |
3480 | struct snd_kcontrol *kctl; | 3550 | struct snd_kcontrol *kctl; |
3551 | if (knew->iface == -1) /* skip this codec private value */ | ||
3552 | continue; | ||
3481 | kctl = snd_ctl_new1(knew, codec); | 3553 | kctl = snd_ctl_new1(knew, codec); |
3482 | if (!kctl) | 3554 | if (!kctl) |
3483 | return -ENOMEM; | 3555 | return -ENOMEM; |
@@ -3542,7 +3614,7 @@ void snd_hda_update_power_acct(struct hda_codec *codec) | |||
3542 | * | 3614 | * |
3543 | * Increment the power-up counter and power up the hardware really when | 3615 | * Increment the power-up counter and power up the hardware really when |
3544 | * not turned on yet. | 3616 | * not turned on yet. |
3545 | */ | 3617 | */ |
3546 | void snd_hda_power_up(struct hda_codec *codec) | 3618 | void snd_hda_power_up(struct hda_codec *codec) |
3547 | { | 3619 | { |
3548 | struct hda_bus *bus = codec->bus; | 3620 | struct hda_bus *bus = codec->bus; |
@@ -3571,7 +3643,7 @@ EXPORT_SYMBOL_HDA(snd_hda_power_up); | |||
3571 | * | 3643 | * |
3572 | * Decrement the power-up counter and schedules the power-off work if | 3644 | * Decrement the power-up counter and schedules the power-off work if |
3573 | * the counter rearches to zero. | 3645 | * the counter rearches to zero. |
3574 | */ | 3646 | */ |
3575 | void snd_hda_power_down(struct hda_codec *codec) | 3647 | void snd_hda_power_down(struct hda_codec *codec) |
3576 | { | 3648 | { |
3577 | --codec->power_count; | 3649 | --codec->power_count; |
@@ -3597,7 +3669,7 @@ EXPORT_SYMBOL_HDA(snd_hda_power_down); | |||
3597 | * | 3669 | * |
3598 | * This function is supposed to be set or called from the check_power_status | 3670 | * This function is supposed to be set or called from the check_power_status |
3599 | * patch ops. | 3671 | * patch ops. |
3600 | */ | 3672 | */ |
3601 | int snd_hda_check_amp_list_power(struct hda_codec *codec, | 3673 | int snd_hda_check_amp_list_power(struct hda_codec *codec, |
3602 | struct hda_loopback_check *check, | 3674 | struct hda_loopback_check *check, |
3603 | hda_nid_t nid) | 3675 | hda_nid_t nid) |
@@ -3765,7 +3837,7 @@ static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid, | |||
3765 | { | 3837 | { |
3766 | /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ | 3838 | /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ |
3767 | if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) | 3839 | if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) |
3768 | set_dig_out_convert(codec, nid, | 3840 | set_dig_out_convert(codec, nid, |
3769 | codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff, | 3841 | codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff, |
3770 | -1); | 3842 | -1); |
3771 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); | 3843 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
@@ -4024,13 +4096,13 @@ static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list) | |||
4024 | /* | 4096 | /* |
4025 | * Sort an associated group of pins according to their sequence numbers. | 4097 | * Sort an associated group of pins according to their sequence numbers. |
4026 | */ | 4098 | */ |
4027 | static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences, | 4099 | static void sort_pins_by_sequence(hda_nid_t *pins, short *sequences, |
4028 | int num_pins) | 4100 | int num_pins) |
4029 | { | 4101 | { |
4030 | int i, j; | 4102 | int i, j; |
4031 | short seq; | 4103 | short seq; |
4032 | hda_nid_t nid; | 4104 | hda_nid_t nid; |
4033 | 4105 | ||
4034 | for (i = 0; i < num_pins; i++) { | 4106 | for (i = 0; i < num_pins; i++) { |
4035 | for (j = i + 1; j < num_pins; j++) { | 4107 | for (j = i + 1; j < num_pins; j++) { |
4036 | if (sequences[i] > sequences[j]) { | 4108 | if (sequences[i] > sequences[j]) { |
@@ -4058,7 +4130,7 @@ static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences, | |||
4058 | * is detected, one of speaker of HP pins is assigned as the primary | 4130 | * is detected, one of speaker of HP pins is assigned as the primary |
4059 | * output, i.e. to line_out_pins[0]. So, line_outs is always positive | 4131 | * output, i.e. to line_out_pins[0]. So, line_outs is always positive |
4060 | * if any analog output exists. | 4132 | * if any analog output exists. |
4061 | * | 4133 | * |
4062 | * The analog input pins are assigned to input_pins array. | 4134 | * The analog input pins are assigned to input_pins array. |
4063 | * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, | 4135 | * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, |
4064 | * respectively. | 4136 | * respectively. |
@@ -4121,9 +4193,9 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, | |||
4121 | case AC_JACK_SPEAKER: | 4193 | case AC_JACK_SPEAKER: |
4122 | seq = get_defcfg_sequence(def_conf); | 4194 | seq = get_defcfg_sequence(def_conf); |
4123 | assoc = get_defcfg_association(def_conf); | 4195 | assoc = get_defcfg_association(def_conf); |
4124 | if (! assoc) | 4196 | if (!assoc) |
4125 | continue; | 4197 | continue; |
4126 | if (! assoc_speaker) | 4198 | if (!assoc_speaker) |
4127 | assoc_speaker = assoc; | 4199 | assoc_speaker = assoc; |
4128 | else if (assoc_speaker != assoc) | 4200 | else if (assoc_speaker != assoc) |
4129 | continue; | 4201 | continue; |
@@ -4221,7 +4293,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, | |||
4221 | cfg->speaker_outs); | 4293 | cfg->speaker_outs); |
4222 | sort_pins_by_sequence(cfg->hp_pins, sequences_hp, | 4294 | sort_pins_by_sequence(cfg->hp_pins, sequences_hp, |
4223 | cfg->hp_outs); | 4295 | cfg->hp_outs); |
4224 | 4296 | ||
4225 | /* if we have only one mic, make it AUTO_PIN_MIC */ | 4297 | /* if we have only one mic, make it AUTO_PIN_MIC */ |
4226 | if (!cfg->input_pins[AUTO_PIN_MIC] && | 4298 | if (!cfg->input_pins[AUTO_PIN_MIC] && |
4227 | cfg->input_pins[AUTO_PIN_FRONT_MIC]) { | 4299 | cfg->input_pins[AUTO_PIN_FRONT_MIC]) { |
@@ -4371,7 +4443,7 @@ EXPORT_SYMBOL_HDA(snd_hda_resume); | |||
4371 | /** | 4443 | /** |
4372 | * snd_array_new - get a new element from the given array | 4444 | * snd_array_new - get a new element from the given array |
4373 | * @array: the array object | 4445 | * @array: the array object |
4374 | * | 4446 | * |
4375 | * Get a new element from the given array. If it exceeds the | 4447 | * Get a new element from the given array. If it exceeds the |
4376 | * pre-allocated array size, re-allocate the array. | 4448 | * pre-allocated array size, re-allocate the array. |
4377 | * | 4449 | * |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 0a770a28e71f..b75da47571e6 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -527,6 +527,9 @@ enum { | |||
527 | /* max. codec address */ | 527 | /* max. codec address */ |
528 | #define HDA_MAX_CODEC_ADDRESS 0x0f | 528 | #define HDA_MAX_CODEC_ADDRESS 0x0f |
529 | 529 | ||
530 | /* max number of PCM devics per card */ | ||
531 | #define HDA_MAX_PCMS 10 | ||
532 | |||
530 | /* | 533 | /* |
531 | * generic arrays | 534 | * generic arrays |
532 | */ | 535 | */ |
@@ -789,6 +792,7 @@ struct hda_codec { | |||
789 | u32 *wcaps; | 792 | u32 *wcaps; |
790 | 793 | ||
791 | struct snd_array mixers; /* list of assigned mixer elements */ | 794 | struct snd_array mixers; /* list of assigned mixer elements */ |
795 | struct snd_array nids; /* list of mapped mixer elements */ | ||
792 | 796 | ||
793 | struct hda_cache_rec amp_cache; /* cache for amp access */ | 797 | struct hda_cache_rec amp_cache; /* cache for amp access */ |
794 | struct hda_cache_rec cmd_cache; /* cache for other commands */ | 798 | struct hda_cache_rec cmd_cache; /* cache for other commands */ |
@@ -898,6 +902,7 @@ int snd_hda_codec_set_pincfg(struct hda_codec *codec, hda_nid_t nid, | |||
898 | unsigned int cfg); | 902 | unsigned int cfg); |
899 | int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list, | 903 | int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list, |
900 | hda_nid_t nid, unsigned int cfg); /* for hwdep */ | 904 | hda_nid_t nid, unsigned int cfg); /* for hwdep */ |
905 | void snd_hda_shutup_pins(struct hda_codec *codec); | ||
901 | 906 | ||
902 | /* | 907 | /* |
903 | * Mixer | 908 | * Mixer |
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index 4228f2fe5956..dcd22446cfc7 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c | |||
@@ -331,6 +331,7 @@ int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid) | |||
331 | return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE, | 331 | return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE, |
332 | AC_DIPSIZE_ELD_BUF); | 332 | AC_DIPSIZE_ELD_BUF); |
333 | } | 333 | } |
334 | EXPORT_SYMBOL_HDA(snd_hdmi_get_eld_size); | ||
334 | 335 | ||
335 | int snd_hdmi_get_eld(struct hdmi_eld *eld, | 336 | int snd_hdmi_get_eld(struct hdmi_eld *eld, |
336 | struct hda_codec *codec, hda_nid_t nid) | 337 | struct hda_codec *codec, hda_nid_t nid) |
@@ -366,6 +367,7 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld, | |||
366 | kfree(buf); | 367 | kfree(buf); |
367 | return ret; | 368 | return ret; |
368 | } | 369 | } |
370 | EXPORT_SYMBOL_HDA(snd_hdmi_get_eld); | ||
369 | 371 | ||
370 | static void hdmi_show_short_audio_desc(struct cea_sad *a) | 372 | static void hdmi_show_short_audio_desc(struct cea_sad *a) |
371 | { | 373 | { |
@@ -404,6 +406,7 @@ void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen) | |||
404 | } | 406 | } |
405 | buf[j] = '\0'; /* necessary when j == 0 */ | 407 | buf[j] = '\0'; /* necessary when j == 0 */ |
406 | } | 408 | } |
409 | EXPORT_SYMBOL_HDA(snd_print_channel_allocation); | ||
407 | 410 | ||
408 | void snd_hdmi_show_eld(struct hdmi_eld *e) | 411 | void snd_hdmi_show_eld(struct hdmi_eld *e) |
409 | { | 412 | { |
@@ -422,6 +425,7 @@ void snd_hdmi_show_eld(struct hdmi_eld *e) | |||
422 | for (i = 0; i < e->sad_count; i++) | 425 | for (i = 0; i < e->sad_count; i++) |
423 | hdmi_show_short_audio_desc(e->sad + i); | 426 | hdmi_show_short_audio_desc(e->sad + i); |
424 | } | 427 | } |
428 | EXPORT_SYMBOL_HDA(snd_hdmi_show_eld); | ||
425 | 429 | ||
426 | #ifdef CONFIG_PROC_FS | 430 | #ifdef CONFIG_PROC_FS |
427 | 431 | ||
@@ -580,6 +584,7 @@ int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, | |||
580 | 584 | ||
581 | return 0; | 585 | return 0; |
582 | } | 586 | } |
587 | EXPORT_SYMBOL_HDA(snd_hda_eld_proc_new); | ||
583 | 588 | ||
584 | void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) | 589 | void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) |
585 | { | 590 | { |
@@ -588,5 +593,6 @@ void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) | |||
588 | eld->proc_entry = NULL; | 593 | eld->proc_entry = NULL; |
589 | } | 594 | } |
590 | } | 595 | } |
596 | EXPORT_SYMBOL_HDA(snd_hda_eld_proc_free); | ||
591 | 597 | ||
592 | #endif /* CONFIG_PROC_FS */ | 598 | #endif /* CONFIG_PROC_FS */ |
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 092c6a7c2ff3..5ea21285ee1f 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -861,7 +861,8 @@ static int build_input_controls(struct hda_codec *codec) | |||
861 | } | 861 | } |
862 | 862 | ||
863 | /* create input MUX if multiple sources are available */ | 863 | /* create input MUX if multiple sources are available */ |
864 | err = snd_hda_ctl_add(codec, 0, snd_ctl_new1(&cap_sel, codec)); | 864 | err = snd_hda_ctl_add(codec, spec->adc_node->nid, |
865 | snd_ctl_new1(&cap_sel, codec)); | ||
865 | if (err < 0) | 866 | if (err < 0) |
866 | return err; | 867 | return err; |
867 | 868 | ||
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index 40ccb419b6e9..a1fc83753cc6 100644 --- a/sound/pci/hda/hda_hwdep.c +++ b/sound/pci/hda/hda_hwdep.c | |||
@@ -293,8 +293,11 @@ static ssize_t type##_store(struct device *dev, \ | |||
293 | { \ | 293 | { \ |
294 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); \ | 294 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); \ |
295 | struct hda_codec *codec = hwdep->private_data; \ | 295 | struct hda_codec *codec = hwdep->private_data; \ |
296 | char *after; \ | 296 | unsigned long val; \ |
297 | codec->type = simple_strtoul(buf, &after, 0); \ | 297 | int err = strict_strtoul(buf, 0, &val); \ |
298 | if (err < 0) \ | ||
299 | return err; \ | ||
300 | codec->type = val; \ | ||
298 | return count; \ | 301 | return count; \ |
299 | } | 302 | } |
300 | 303 | ||
@@ -622,6 +625,10 @@ enum { | |||
622 | LINE_MODE_PINCFG, | 625 | LINE_MODE_PINCFG, |
623 | LINE_MODE_VERB, | 626 | LINE_MODE_VERB, |
624 | LINE_MODE_HINT, | 627 | LINE_MODE_HINT, |
628 | LINE_MODE_VENDOR_ID, | ||
629 | LINE_MODE_SUBSYSTEM_ID, | ||
630 | LINE_MODE_REVISION_ID, | ||
631 | LINE_MODE_CHIP_NAME, | ||
625 | NUM_LINE_MODES, | 632 | NUM_LINE_MODES, |
626 | }; | 633 | }; |
627 | 634 | ||
@@ -651,53 +658,71 @@ static void parse_codec_mode(char *buf, struct hda_bus *bus, | |||
651 | } | 658 | } |
652 | 659 | ||
653 | /* parse the contents after the other command tags, [pincfg], [verb], | 660 | /* parse the contents after the other command tags, [pincfg], [verb], |
654 | * [hint] and [model] | 661 | * [vendor_id], [subsystem_id], [revision_id], [chip_name], [hint] and [model] |
655 | * just pass to the sysfs helper (only when any codec was specified) | 662 | * just pass to the sysfs helper (only when any codec was specified) |
656 | */ | 663 | */ |
657 | static void parse_pincfg_mode(char *buf, struct hda_bus *bus, | 664 | static void parse_pincfg_mode(char *buf, struct hda_bus *bus, |
658 | struct hda_codec **codecp) | 665 | struct hda_codec **codecp) |
659 | { | 666 | { |
660 | if (!*codecp) | ||
661 | return; | ||
662 | parse_user_pin_configs(*codecp, buf); | 667 | parse_user_pin_configs(*codecp, buf); |
663 | } | 668 | } |
664 | 669 | ||
665 | static void parse_verb_mode(char *buf, struct hda_bus *bus, | 670 | static void parse_verb_mode(char *buf, struct hda_bus *bus, |
666 | struct hda_codec **codecp) | 671 | struct hda_codec **codecp) |
667 | { | 672 | { |
668 | if (!*codecp) | ||
669 | return; | ||
670 | parse_init_verbs(*codecp, buf); | 673 | parse_init_verbs(*codecp, buf); |
671 | } | 674 | } |
672 | 675 | ||
673 | static void parse_hint_mode(char *buf, struct hda_bus *bus, | 676 | static void parse_hint_mode(char *buf, struct hda_bus *bus, |
674 | struct hda_codec **codecp) | 677 | struct hda_codec **codecp) |
675 | { | 678 | { |
676 | if (!*codecp) | ||
677 | return; | ||
678 | parse_hints(*codecp, buf); | 679 | parse_hints(*codecp, buf); |
679 | } | 680 | } |
680 | 681 | ||
681 | static void parse_model_mode(char *buf, struct hda_bus *bus, | 682 | static void parse_model_mode(char *buf, struct hda_bus *bus, |
682 | struct hda_codec **codecp) | 683 | struct hda_codec **codecp) |
683 | { | 684 | { |
684 | if (!*codecp) | ||
685 | return; | ||
686 | kfree((*codecp)->modelname); | 685 | kfree((*codecp)->modelname); |
687 | (*codecp)->modelname = kstrdup(buf, GFP_KERNEL); | 686 | (*codecp)->modelname = kstrdup(buf, GFP_KERNEL); |
688 | } | 687 | } |
689 | 688 | ||
689 | static void parse_chip_name_mode(char *buf, struct hda_bus *bus, | ||
690 | struct hda_codec **codecp) | ||
691 | { | ||
692 | kfree((*codecp)->chip_name); | ||
693 | (*codecp)->chip_name = kstrdup(buf, GFP_KERNEL); | ||
694 | } | ||
695 | |||
696 | #define DEFINE_PARSE_ID_MODE(name) \ | ||
697 | static void parse_##name##_mode(char *buf, struct hda_bus *bus, \ | ||
698 | struct hda_codec **codecp) \ | ||
699 | { \ | ||
700 | unsigned long val; \ | ||
701 | if (!strict_strtoul(buf, 0, &val)) \ | ||
702 | (*codecp)->name = val; \ | ||
703 | } | ||
704 | |||
705 | DEFINE_PARSE_ID_MODE(vendor_id); | ||
706 | DEFINE_PARSE_ID_MODE(subsystem_id); | ||
707 | DEFINE_PARSE_ID_MODE(revision_id); | ||
708 | |||
709 | |||
690 | struct hda_patch_item { | 710 | struct hda_patch_item { |
691 | const char *tag; | 711 | const char *tag; |
692 | void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc); | 712 | void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc); |
713 | int need_codec; | ||
693 | }; | 714 | }; |
694 | 715 | ||
695 | static struct hda_patch_item patch_items[NUM_LINE_MODES] = { | 716 | static struct hda_patch_item patch_items[NUM_LINE_MODES] = { |
696 | [LINE_MODE_CODEC] = { "[codec]", parse_codec_mode }, | 717 | [LINE_MODE_CODEC] = { "[codec]", parse_codec_mode, 0 }, |
697 | [LINE_MODE_MODEL] = { "[model]", parse_model_mode }, | 718 | [LINE_MODE_MODEL] = { "[model]", parse_model_mode, 1 }, |
698 | [LINE_MODE_VERB] = { "[verb]", parse_verb_mode }, | 719 | [LINE_MODE_VERB] = { "[verb]", parse_verb_mode, 1 }, |
699 | [LINE_MODE_PINCFG] = { "[pincfg]", parse_pincfg_mode }, | 720 | [LINE_MODE_PINCFG] = { "[pincfg]", parse_pincfg_mode, 1 }, |
700 | [LINE_MODE_HINT] = { "[hint]", parse_hint_mode }, | 721 | [LINE_MODE_HINT] = { "[hint]", parse_hint_mode, 1 }, |
722 | [LINE_MODE_VENDOR_ID] = { "[vendor_id]", parse_vendor_id_mode, 1 }, | ||
723 | [LINE_MODE_SUBSYSTEM_ID] = { "[subsystem_id]", parse_subsystem_id_mode, 1 }, | ||
724 | [LINE_MODE_REVISION_ID] = { "[revision_id]", parse_revision_id_mode, 1 }, | ||
725 | [LINE_MODE_CHIP_NAME] = { "[chip_name]", parse_chip_name_mode, 1 }, | ||
701 | }; | 726 | }; |
702 | 727 | ||
703 | /* check the line starting with '[' -- change the parser mode accodingly */ | 728 | /* check the line starting with '[' -- change the parser mode accodingly */ |
@@ -780,7 +805,8 @@ int snd_hda_load_patch(struct hda_bus *bus, const char *patch) | |||
780 | continue; | 805 | continue; |
781 | if (*buf == '[') | 806 | if (*buf == '[') |
782 | line_mode = parse_line_mode(buf, bus); | 807 | line_mode = parse_line_mode(buf, bus); |
783 | else if (patch_items[line_mode].parser) | 808 | else if (patch_items[line_mode].parser && |
809 | (codec || !patch_items[line_mode].need_codec)) | ||
784 | patch_items[line_mode].parser(buf, bus, &codec); | 810 | patch_items[line_mode].parser(buf, bus, &codec); |
785 | } | 811 | } |
786 | release_firmware(fw); | 812 | release_firmware(fw); |
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index ec9c348336cc..43b7cfb7cffd 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -125,6 +125,7 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," | |||
125 | "{Intel, ICH9}," | 125 | "{Intel, ICH9}," |
126 | "{Intel, ICH10}," | 126 | "{Intel, ICH10}," |
127 | "{Intel, PCH}," | 127 | "{Intel, PCH}," |
128 | "{Intel, CPT}," | ||
128 | "{Intel, SCH}," | 129 | "{Intel, SCH}," |
129 | "{ATI, SB450}," | 130 | "{ATI, SB450}," |
130 | "{ATI, SB600}," | 131 | "{ATI, SB600}," |
@@ -259,8 +260,6 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; | |||
259 | #define AZX_MAX_FRAG 32 | 260 | #define AZX_MAX_FRAG 32 |
260 | /* max buffer size - no h/w limit, you can increase as you like */ | 261 | /* max buffer size - no h/w limit, you can increase as you like */ |
261 | #define AZX_MAX_BUF_SIZE (1024*1024*1024) | 262 | #define AZX_MAX_BUF_SIZE (1024*1024*1024) |
262 | /* max number of PCM devics per card */ | ||
263 | #define AZX_MAX_PCMS 8 | ||
264 | 263 | ||
265 | /* RIRB int mask: overrun[2], response[0] */ | 264 | /* RIRB int mask: overrun[2], response[0] */ |
266 | #define RIRB_INT_RESPONSE 0x01 | 265 | #define RIRB_INT_RESPONSE 0x01 |
@@ -268,7 +267,8 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; | |||
268 | #define RIRB_INT_MASK 0x05 | 267 | #define RIRB_INT_MASK 0x05 |
269 | 268 | ||
270 | /* STATESTS int mask: S3,SD2,SD1,SD0 */ | 269 | /* STATESTS int mask: S3,SD2,SD1,SD0 */ |
271 | #define AZX_MAX_CODECS 4 | 270 | #define AZX_MAX_CODECS 8 |
271 | #define AZX_DEFAULT_CODECS 4 | ||
272 | #define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1) | 272 | #define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1) |
273 | 273 | ||
274 | /* SD_CTL bits */ | 274 | /* SD_CTL bits */ |
@@ -408,7 +408,7 @@ struct azx { | |||
408 | struct azx_dev *azx_dev; | 408 | struct azx_dev *azx_dev; |
409 | 409 | ||
410 | /* PCM */ | 410 | /* PCM */ |
411 | struct snd_pcm *pcm[AZX_MAX_PCMS]; | 411 | struct snd_pcm *pcm[HDA_MAX_PCMS]; |
412 | 412 | ||
413 | /* HD codec */ | 413 | /* HD codec */ |
414 | unsigned short codec_mask; | 414 | unsigned short codec_mask; |
@@ -426,6 +426,7 @@ struct azx { | |||
426 | 426 | ||
427 | /* flags */ | 427 | /* flags */ |
428 | int position_fix; | 428 | int position_fix; |
429 | int poll_count; | ||
429 | unsigned int running :1; | 430 | unsigned int running :1; |
430 | unsigned int initialized :1; | 431 | unsigned int initialized :1; |
431 | unsigned int single_cmd :1; | 432 | unsigned int single_cmd :1; |
@@ -448,6 +449,7 @@ struct azx { | |||
448 | /* driver types */ | 449 | /* driver types */ |
449 | enum { | 450 | enum { |
450 | AZX_DRIVER_ICH, | 451 | AZX_DRIVER_ICH, |
452 | AZX_DRIVER_PCH, | ||
451 | AZX_DRIVER_SCH, | 453 | AZX_DRIVER_SCH, |
452 | AZX_DRIVER_ATI, | 454 | AZX_DRIVER_ATI, |
453 | AZX_DRIVER_ATIHDMI, | 455 | AZX_DRIVER_ATIHDMI, |
@@ -462,6 +464,7 @@ enum { | |||
462 | 464 | ||
463 | static char *driver_short_names[] __devinitdata = { | 465 | static char *driver_short_names[] __devinitdata = { |
464 | [AZX_DRIVER_ICH] = "HDA Intel", | 466 | [AZX_DRIVER_ICH] = "HDA Intel", |
467 | [AZX_DRIVER_PCH] = "HDA Intel PCH", | ||
465 | [AZX_DRIVER_SCH] = "HDA Intel MID", | 468 | [AZX_DRIVER_SCH] = "HDA Intel MID", |
466 | [AZX_DRIVER_ATI] = "HDA ATI SB", | 469 | [AZX_DRIVER_ATI] = "HDA ATI SB", |
467 | [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI", | 470 | [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI", |
@@ -506,7 +509,7 @@ static char *driver_short_names[] __devinitdata = { | |||
506 | #define get_azx_dev(substream) (substream->runtime->private_data) | 509 | #define get_azx_dev(substream) (substream->runtime->private_data) |
507 | 510 | ||
508 | static int azx_acquire_irq(struct azx *chip, int do_disconnect); | 511 | static int azx_acquire_irq(struct azx *chip, int do_disconnect); |
509 | 512 | static int azx_send_cmd(struct hda_bus *bus, unsigned int val); | |
510 | /* | 513 | /* |
511 | * Interface for HD codec | 514 | * Interface for HD codec |
512 | */ | 515 | */ |
@@ -664,11 +667,12 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus, | |||
664 | { | 667 | { |
665 | struct azx *chip = bus->private_data; | 668 | struct azx *chip = bus->private_data; |
666 | unsigned long timeout; | 669 | unsigned long timeout; |
670 | int do_poll = 0; | ||
667 | 671 | ||
668 | again: | 672 | again: |
669 | timeout = jiffies + msecs_to_jiffies(1000); | 673 | timeout = jiffies + msecs_to_jiffies(1000); |
670 | for (;;) { | 674 | for (;;) { |
671 | if (chip->polling_mode) { | 675 | if (chip->polling_mode || do_poll) { |
672 | spin_lock_irq(&chip->reg_lock); | 676 | spin_lock_irq(&chip->reg_lock); |
673 | azx_update_rirb(chip); | 677 | azx_update_rirb(chip); |
674 | spin_unlock_irq(&chip->reg_lock); | 678 | spin_unlock_irq(&chip->reg_lock); |
@@ -676,6 +680,9 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus, | |||
676 | if (!chip->rirb.cmds[addr]) { | 680 | if (!chip->rirb.cmds[addr]) { |
677 | smp_rmb(); | 681 | smp_rmb(); |
678 | bus->rirb_error = 0; | 682 | bus->rirb_error = 0; |
683 | |||
684 | if (!do_poll) | ||
685 | chip->poll_count = 0; | ||
679 | return chip->rirb.res[addr]; /* the last value */ | 686 | return chip->rirb.res[addr]; /* the last value */ |
680 | } | 687 | } |
681 | if (time_after(jiffies, timeout)) | 688 | if (time_after(jiffies, timeout)) |
@@ -688,6 +695,16 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus, | |||
688 | } | 695 | } |
689 | } | 696 | } |
690 | 697 | ||
698 | if (!chip->polling_mode && chip->poll_count < 2) { | ||
699 | snd_printdd(SFX "azx_get_response timeout, " | ||
700 | "polling the codec once: last cmd=0x%08x\n", | ||
701 | chip->last_cmd[addr]); | ||
702 | do_poll = 1; | ||
703 | chip->poll_count++; | ||
704 | goto again; | ||
705 | } | ||
706 | |||
707 | |||
691 | if (!chip->polling_mode) { | 708 | if (!chip->polling_mode) { |
692 | snd_printk(KERN_WARNING SFX "azx_get_response timeout, " | 709 | snd_printk(KERN_WARNING SFX "azx_get_response timeout, " |
693 | "switching to polling mode: last cmd=0x%08x\n", | 710 | "switching to polling mode: last cmd=0x%08x\n", |
@@ -953,8 +970,8 @@ static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev) | |||
953 | azx_dev->insufficient = 1; | 970 | azx_dev->insufficient = 1; |
954 | 971 | ||
955 | /* enable SIE */ | 972 | /* enable SIE */ |
956 | azx_writeb(chip, INTCTL, | 973 | azx_writel(chip, INTCTL, |
957 | azx_readb(chip, INTCTL) | (1 << azx_dev->index)); | 974 | azx_readl(chip, INTCTL) | (1 << azx_dev->index)); |
958 | /* set DMA start and interrupt mask */ | 975 | /* set DMA start and interrupt mask */ |
959 | azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) | | 976 | azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) | |
960 | SD_CTL_DMA_START | SD_INT_MASK); | 977 | SD_CTL_DMA_START | SD_INT_MASK); |
@@ -973,8 +990,8 @@ static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev) | |||
973 | { | 990 | { |
974 | azx_stream_clear(chip, azx_dev); | 991 | azx_stream_clear(chip, azx_dev); |
975 | /* disable SIE */ | 992 | /* disable SIE */ |
976 | azx_writeb(chip, INTCTL, | 993 | azx_writel(chip, INTCTL, |
977 | azx_readb(chip, INTCTL) & ~(1 << azx_dev->index)); | 994 | azx_readl(chip, INTCTL) & ~(1 << azx_dev->index)); |
978 | } | 995 | } |
979 | 996 | ||
980 | 997 | ||
@@ -1050,6 +1067,7 @@ static void azx_init_pci(struct azx *chip) | |||
1050 | 0x01, NVIDIA_HDA_ENABLE_COHBIT); | 1067 | 0x01, NVIDIA_HDA_ENABLE_COHBIT); |
1051 | break; | 1068 | break; |
1052 | case AZX_DRIVER_SCH: | 1069 | case AZX_DRIVER_SCH: |
1070 | case AZX_DRIVER_PCH: | ||
1053 | pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); | 1071 | pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); |
1054 | if (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) { | 1072 | if (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) { |
1055 | pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, | 1073 | pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, |
@@ -1335,7 +1353,7 @@ static void azx_bus_reset(struct hda_bus *bus) | |||
1335 | if (chip->initialized) { | 1353 | if (chip->initialized) { |
1336 | int i; | 1354 | int i; |
1337 | 1355 | ||
1338 | for (i = 0; i < AZX_MAX_PCMS; i++) | 1356 | for (i = 0; i < HDA_MAX_PCMS; i++) |
1339 | snd_pcm_suspend_all(chip->pcm[i]); | 1357 | snd_pcm_suspend_all(chip->pcm[i]); |
1340 | snd_hda_suspend(chip->bus); | 1358 | snd_hda_suspend(chip->bus); |
1341 | snd_hda_resume(chip->bus); | 1359 | snd_hda_resume(chip->bus); |
@@ -1350,6 +1368,7 @@ static void azx_bus_reset(struct hda_bus *bus) | |||
1350 | 1368 | ||
1351 | /* number of codec slots for each chipset: 0 = default slots (i.e. 4) */ | 1369 | /* number of codec slots for each chipset: 0 = default slots (i.e. 4) */ |
1352 | static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = { | 1370 | static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = { |
1371 | [AZX_DRIVER_NVIDIA] = 8, | ||
1353 | [AZX_DRIVER_TERA] = 1, | 1372 | [AZX_DRIVER_TERA] = 1, |
1354 | }; | 1373 | }; |
1355 | 1374 | ||
@@ -1382,7 +1401,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model) | |||
1382 | codecs = 0; | 1401 | codecs = 0; |
1383 | max_slots = azx_max_codecs[chip->driver_type]; | 1402 | max_slots = azx_max_codecs[chip->driver_type]; |
1384 | if (!max_slots) | 1403 | if (!max_slots) |
1385 | max_slots = AZX_MAX_CODECS; | 1404 | max_slots = AZX_DEFAULT_CODECS; |
1386 | 1405 | ||
1387 | /* First try to probe all given codec slots */ | 1406 | /* First try to probe all given codec slots */ |
1388 | for (c = 0; c < max_slots; c++) { | 1407 | for (c = 0; c < max_slots; c++) { |
@@ -1397,7 +1416,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model) | |||
1397 | chip->codec_mask &= ~(1 << c); | 1416 | chip->codec_mask &= ~(1 << c); |
1398 | /* More badly, accessing to a non-existing | 1417 | /* More badly, accessing to a non-existing |
1399 | * codec often screws up the controller chip, | 1418 | * codec often screws up the controller chip, |
1400 | * and distrubs the further communications. | 1419 | * and disturbs the further communications. |
1401 | * Thus if an error occurs during probing, | 1420 | * Thus if an error occurs during probing, |
1402 | * better to reset the controller chip to | 1421 | * better to reset the controller chip to |
1403 | * get back to the sanity state. | 1422 | * get back to the sanity state. |
@@ -1878,6 +1897,9 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) | |||
1878 | 1897 | ||
1879 | if (!bdl_pos_adj[chip->dev_index]) | 1898 | if (!bdl_pos_adj[chip->dev_index]) |
1880 | return 1; /* no delayed ack */ | 1899 | return 1; /* no delayed ack */ |
1900 | if (WARN_ONCE(!azx_dev->period_bytes, | ||
1901 | "hda-intel: zero azx_dev->period_bytes")) | ||
1902 | return 0; /* this shouldn't happen! */ | ||
1881 | if (pos % azx_dev->period_bytes > azx_dev->period_bytes / 2) | 1903 | if (pos % azx_dev->period_bytes > azx_dev->period_bytes / 2) |
1882 | return 0; /* NG - it's below the period boundary */ | 1904 | return 0; /* NG - it's below the period boundary */ |
1883 | return 1; /* OK, it's fine */ | 1905 | return 1; /* OK, it's fine */ |
@@ -1965,7 +1987,7 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec, | |||
1965 | int pcm_dev = cpcm->device; | 1987 | int pcm_dev = cpcm->device; |
1966 | int s, err; | 1988 | int s, err; |
1967 | 1989 | ||
1968 | if (pcm_dev >= AZX_MAX_PCMS) { | 1990 | if (pcm_dev >= HDA_MAX_PCMS) { |
1969 | snd_printk(KERN_ERR SFX "Invalid PCM device number %d\n", | 1991 | snd_printk(KERN_ERR SFX "Invalid PCM device number %d\n", |
1970 | pcm_dev); | 1992 | pcm_dev); |
1971 | return -EINVAL; | 1993 | return -EINVAL; |
@@ -2043,7 +2065,7 @@ static int azx_acquire_irq(struct azx *chip, int do_disconnect) | |||
2043 | { | 2065 | { |
2044 | if (request_irq(chip->pci->irq, azx_interrupt, | 2066 | if (request_irq(chip->pci->irq, azx_interrupt, |
2045 | chip->msi ? 0 : IRQF_SHARED, | 2067 | chip->msi ? 0 : IRQF_SHARED, |
2046 | "HDA Intel", chip)) { | 2068 | "hda_intel", chip)) { |
2047 | printk(KERN_ERR "hda-intel: unable to grab IRQ %d, " | 2069 | printk(KERN_ERR "hda-intel: unable to grab IRQ %d, " |
2048 | "disabling device\n", chip->pci->irq); | 2070 | "disabling device\n", chip->pci->irq); |
2049 | if (do_disconnect) | 2071 | if (do_disconnect) |
@@ -2121,7 +2143,7 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state) | |||
2121 | 2143 | ||
2122 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | 2144 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
2123 | azx_clear_irq_pending(chip); | 2145 | azx_clear_irq_pending(chip); |
2124 | for (i = 0; i < AZX_MAX_PCMS; i++) | 2146 | for (i = 0; i < HDA_MAX_PCMS; i++) |
2125 | snd_pcm_suspend_all(chip->pcm[i]); | 2147 | snd_pcm_suspend_all(chip->pcm[i]); |
2126 | if (chip->initialized) | 2148 | if (chip->initialized) |
2127 | snd_hda_suspend(chip->bus); | 2149 | snd_hda_suspend(chip->bus); |
@@ -2243,9 +2265,12 @@ static int azx_dev_free(struct snd_device *device) | |||
2243 | static struct snd_pci_quirk position_fix_list[] __devinitdata = { | 2265 | static struct snd_pci_quirk position_fix_list[] __devinitdata = { |
2244 | SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), | 2266 | SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), |
2245 | SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB), | 2267 | SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB), |
2268 | SND_PCI_QUIRK(0x1028, 0x01f6, "Dell Latitude 131L", POS_FIX_LPIB), | ||
2246 | SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), | 2269 | SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), |
2270 | SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB), | ||
2247 | SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), | 2271 | SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), |
2248 | SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), | 2272 | SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), |
2273 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar Microtech", POS_FIX_LPIB), | ||
2249 | {} | 2274 | {} |
2250 | }; | 2275 | }; |
2251 | 2276 | ||
@@ -2332,6 +2357,8 @@ static void __devinit check_probe_mask(struct azx *chip, int dev) | |||
2332 | */ | 2357 | */ |
2333 | static struct snd_pci_quirk msi_black_list[] __devinitdata = { | 2358 | static struct snd_pci_quirk msi_black_list[] __devinitdata = { |
2334 | SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */ | 2359 | SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */ |
2360 | SND_PCI_QUIRK(0x1043, 0x81f6, "ASUS", 0), /* nvidia */ | ||
2361 | SND_PCI_QUIRK(0x1849, 0x0888, "ASRock", 0), /* Athlon64 X2 + nvidia */ | ||
2335 | {} | 2362 | {} |
2336 | }; | 2363 | }; |
2337 | 2364 | ||
@@ -2399,6 +2426,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
2399 | if (bdl_pos_adj[dev] < 0) { | 2426 | if (bdl_pos_adj[dev] < 0) { |
2400 | switch (chip->driver_type) { | 2427 | switch (chip->driver_type) { |
2401 | case AZX_DRIVER_ICH: | 2428 | case AZX_DRIVER_ICH: |
2429 | case AZX_DRIVER_PCH: | ||
2402 | bdl_pos_adj[dev] = 1; | 2430 | bdl_pos_adj[dev] = 1; |
2403 | break; | 2431 | break; |
2404 | default: | 2432 | default: |
@@ -2664,7 +2692,7 @@ static void __devexit azx_remove(struct pci_dev *pci) | |||
2664 | } | 2692 | } |
2665 | 2693 | ||
2666 | /* PCI IDs */ | 2694 | /* PCI IDs */ |
2667 | static struct pci_device_id azx_ids[] = { | 2695 | static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { |
2668 | /* ICH 6..10 */ | 2696 | /* ICH 6..10 */ |
2669 | { PCI_DEVICE(0x8086, 0x2668), .driver_data = AZX_DRIVER_ICH }, | 2697 | { PCI_DEVICE(0x8086, 0x2668), .driver_data = AZX_DRIVER_ICH }, |
2670 | { PCI_DEVICE(0x8086, 0x27d8), .driver_data = AZX_DRIVER_ICH }, | 2698 | { PCI_DEVICE(0x8086, 0x27d8), .driver_data = AZX_DRIVER_ICH }, |
@@ -2677,6 +2705,8 @@ static struct pci_device_id azx_ids[] = { | |||
2677 | { PCI_DEVICE(0x8086, 0x3a6e), .driver_data = AZX_DRIVER_ICH }, | 2705 | { PCI_DEVICE(0x8086, 0x3a6e), .driver_data = AZX_DRIVER_ICH }, |
2678 | /* PCH */ | 2706 | /* PCH */ |
2679 | { PCI_DEVICE(0x8086, 0x3b56), .driver_data = AZX_DRIVER_ICH }, | 2707 | { PCI_DEVICE(0x8086, 0x3b56), .driver_data = AZX_DRIVER_ICH }, |
2708 | /* CPT */ | ||
2709 | { PCI_DEVICE(0x8086, 0x1c20), .driver_data = AZX_DRIVER_PCH }, | ||
2680 | /* SCH */ | 2710 | /* SCH */ |
2681 | { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH }, | 2711 | { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH }, |
2682 | /* ATI SB 450/600 */ | 2712 | /* ATI SB 450/600 */ |
@@ -2704,32 +2734,10 @@ static struct pci_device_id azx_ids[] = { | |||
2704 | /* ULI M5461 */ | 2734 | /* ULI M5461 */ |
2705 | { PCI_DEVICE(0x10b9, 0x5461), .driver_data = AZX_DRIVER_ULI }, | 2735 | { PCI_DEVICE(0x10b9, 0x5461), .driver_data = AZX_DRIVER_ULI }, |
2706 | /* NVIDIA MCP */ | 2736 | /* NVIDIA MCP */ |
2707 | { PCI_DEVICE(0x10de, 0x026c), .driver_data = AZX_DRIVER_NVIDIA }, | 2737 | { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID), |
2708 | { PCI_DEVICE(0x10de, 0x0371), .driver_data = AZX_DRIVER_NVIDIA }, | 2738 | .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, |
2709 | { PCI_DEVICE(0x10de, 0x03e4), .driver_data = AZX_DRIVER_NVIDIA }, | 2739 | .class_mask = 0xffffff, |
2710 | { PCI_DEVICE(0x10de, 0x03f0), .driver_data = AZX_DRIVER_NVIDIA }, | 2740 | .driver_data = AZX_DRIVER_NVIDIA }, |
2711 | { PCI_DEVICE(0x10de, 0x044a), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2712 | { PCI_DEVICE(0x10de, 0x044b), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2713 | { PCI_DEVICE(0x10de, 0x055c), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2714 | { PCI_DEVICE(0x10de, 0x055d), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2715 | { PCI_DEVICE(0x10de, 0x0590), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2716 | { PCI_DEVICE(0x10de, 0x0774), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2717 | { PCI_DEVICE(0x10de, 0x0775), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2718 | { PCI_DEVICE(0x10de, 0x0776), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2719 | { PCI_DEVICE(0x10de, 0x0777), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2720 | { PCI_DEVICE(0x10de, 0x07fc), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2721 | { PCI_DEVICE(0x10de, 0x07fd), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2722 | { PCI_DEVICE(0x10de, 0x0ac0), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2723 | { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2724 | { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2725 | { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2726 | { PCI_DEVICE(0x10de, 0x0be2), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2727 | { PCI_DEVICE(0x10de, 0x0be3), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2728 | { PCI_DEVICE(0x10de, 0x0be4), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2729 | { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2730 | { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2731 | { PCI_DEVICE(0x10de, 0x0d96), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2732 | { PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA }, | ||
2733 | /* Teradici */ | 2741 | /* Teradici */ |
2734 | { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, | 2742 | { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, |
2735 | /* Creative X-Fi (CA0110-IBG) */ | 2743 | /* Creative X-Fi (CA0110-IBG) */ |
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 5778ae882b83..7cee364976ff 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -31,6 +31,7 @@ | |||
31 | * in snd_hda_ctl_add(), so that this value won't appear in the outside. | 31 | * in snd_hda_ctl_add(), so that this value won't appear in the outside. |
32 | */ | 32 | */ |
33 | #define HDA_SUBDEV_NID_FLAG (1U << 31) | 33 | #define HDA_SUBDEV_NID_FLAG (1U << 31) |
34 | #define HDA_SUBDEV_AMP_FLAG (1U << 30) | ||
34 | 35 | ||
35 | /* | 36 | /* |
36 | * for mixer controls | 37 | * for mixer controls |
@@ -42,7 +43,7 @@ | |||
42 | /* mono volume with index (index=0,1,...) (channel=1,2) */ | 43 | /* mono volume with index (index=0,1,...) (channel=1,2) */ |
43 | #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ | 44 | #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ |
44 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ | 45 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ |
45 | .subdevice = HDA_SUBDEV_NID_FLAG | (nid), \ | 46 | .subdevice = HDA_SUBDEV_AMP_FLAG, \ |
46 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | 47 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
47 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | 48 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
48 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ | 49 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
@@ -63,7 +64,7 @@ | |||
63 | /* mono mute switch with index (index=0,1,...) (channel=1,2) */ | 64 | /* mono mute switch with index (index=0,1,...) (channel=1,2) */ |
64 | #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ | 65 | #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ |
65 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ | 66 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ |
66 | .subdevice = HDA_SUBDEV_NID_FLAG | (nid), \ | 67 | .subdevice = HDA_SUBDEV_AMP_FLAG, \ |
67 | .info = snd_hda_mixer_amp_switch_info, \ | 68 | .info = snd_hda_mixer_amp_switch_info, \ |
68 | .get = snd_hda_mixer_amp_switch_get, \ | 69 | .get = snd_hda_mixer_amp_switch_get, \ |
69 | .put = snd_hda_mixer_amp_switch_put, \ | 70 | .put = snd_hda_mixer_amp_switch_put, \ |
@@ -81,7 +82,7 @@ | |||
81 | /* special beep mono mute switch with index (index=0,1,...) (channel=1,2) */ | 82 | /* special beep mono mute switch with index (index=0,1,...) (channel=1,2) */ |
82 | #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ | 83 | #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ |
83 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ | 84 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ |
84 | .subdevice = HDA_SUBDEV_NID_FLAG | (nid), \ | 85 | .subdevice = HDA_SUBDEV_AMP_FLAG, \ |
85 | .info = snd_hda_mixer_amp_switch_info, \ | 86 | .info = snd_hda_mixer_amp_switch_info, \ |
86 | .get = snd_hda_mixer_amp_switch_get, \ | 87 | .get = snd_hda_mixer_amp_switch_get, \ |
87 | .put = snd_hda_mixer_amp_switch_put_beep, \ | 88 | .put = snd_hda_mixer_amp_switch_put_beep, \ |
@@ -464,13 +465,20 @@ u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid); | |||
464 | u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid); | 465 | u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid); |
465 | int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid); | 466 | int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid); |
466 | 467 | ||
468 | /* flags for hda_nid_item */ | ||
469 | #define HDA_NID_ITEM_AMP (1<<0) | ||
470 | |||
467 | struct hda_nid_item { | 471 | struct hda_nid_item { |
468 | struct snd_kcontrol *kctl; | 472 | struct snd_kcontrol *kctl; |
473 | unsigned int index; | ||
469 | hda_nid_t nid; | 474 | hda_nid_t nid; |
475 | unsigned short flags; | ||
470 | }; | 476 | }; |
471 | 477 | ||
472 | int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, | 478 | int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, |
473 | struct snd_kcontrol *kctl); | 479 | struct snd_kcontrol *kctl); |
480 | int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl, | ||
481 | unsigned int index, hda_nid_t nid); | ||
474 | void snd_hda_ctls_clear(struct hda_codec *codec); | 482 | void snd_hda_ctls_clear(struct hda_codec *codec); |
475 | 483 | ||
476 | /* | 484 | /* |
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index c9afc04adac8..f97d35de66c4 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c | |||
@@ -61,18 +61,29 @@ static const char *get_wid_type_name(unsigned int wid_value) | |||
61 | return "UNKNOWN Widget"; | 61 | return "UNKNOWN Widget"; |
62 | } | 62 | } |
63 | 63 | ||
64 | static void print_nid_mixers(struct snd_info_buffer *buffer, | 64 | static void print_nid_array(struct snd_info_buffer *buffer, |
65 | struct hda_codec *codec, hda_nid_t nid) | 65 | struct hda_codec *codec, hda_nid_t nid, |
66 | struct snd_array *array) | ||
66 | { | 67 | { |
67 | int i; | 68 | int i; |
68 | struct hda_nid_item *items = codec->mixers.list; | 69 | struct hda_nid_item *items = array->list, *item; |
69 | struct snd_kcontrol *kctl; | 70 | struct snd_kcontrol *kctl; |
70 | for (i = 0; i < codec->mixers.used; i++) { | 71 | for (i = 0; i < array->used; i++) { |
71 | if (items[i].nid == nid) { | 72 | item = &items[i]; |
72 | kctl = items[i].kctl; | 73 | if (item->nid == nid) { |
74 | kctl = item->kctl; | ||
73 | snd_iprintf(buffer, | 75 | snd_iprintf(buffer, |
74 | " Control: name=\"%s\", index=%i, device=%i\n", | 76 | " Control: name=\"%s\", index=%i, device=%i\n", |
75 | kctl->id.name, kctl->id.index, kctl->id.device); | 77 | kctl->id.name, kctl->id.index + item->index, |
78 | kctl->id.device); | ||
79 | if (item->flags & HDA_NID_ITEM_AMP) | ||
80 | snd_iprintf(buffer, | ||
81 | " ControlAmp: chs=%lu, dir=%s, " | ||
82 | "idx=%lu, ofs=%lu\n", | ||
83 | get_amp_channels(kctl), | ||
84 | get_amp_direction(kctl) ? "Out" : "In", | ||
85 | get_amp_index(kctl), | ||
86 | get_amp_offset(kctl)); | ||
76 | } | 87 | } |
77 | } | 88 | } |
78 | } | 89 | } |
@@ -528,7 +539,8 @@ static void print_gpio(struct snd_info_buffer *buffer, | |||
528 | (data & (1<<i)) ? 1 : 0, | 539 | (data & (1<<i)) ? 1 : 0, |
529 | (unsol & (1<<i)) ? 1 : 0); | 540 | (unsol & (1<<i)) ? 1 : 0); |
530 | /* FIXME: add GPO and GPI pin information */ | 541 | /* FIXME: add GPO and GPI pin information */ |
531 | print_nid_mixers(buffer, codec, nid); | 542 | print_nid_array(buffer, codec, nid, &codec->mixers); |
543 | print_nid_array(buffer, codec, nid, &codec->nids); | ||
532 | } | 544 | } |
533 | 545 | ||
534 | static void print_codec_info(struct snd_info_entry *entry, | 546 | static void print_codec_info(struct snd_info_entry *entry, |
@@ -608,7 +620,8 @@ static void print_codec_info(struct snd_info_entry *entry, | |||
608 | snd_iprintf(buffer, " CP"); | 620 | snd_iprintf(buffer, " CP"); |
609 | snd_iprintf(buffer, "\n"); | 621 | snd_iprintf(buffer, "\n"); |
610 | 622 | ||
611 | print_nid_mixers(buffer, codec, nid); | 623 | print_nid_array(buffer, codec, nid, &codec->mixers); |
624 | print_nid_array(buffer, codec, nid, &codec->nids); | ||
612 | print_nid_pcms(buffer, codec, nid); | 625 | print_nid_pcms(buffer, codec, nid); |
613 | 626 | ||
614 | /* volume knob is a special widget that always have connection | 627 | /* volume knob is a special widget that always have connection |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 69a941c7b158..e6d1bdff1b6e 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -174,6 +174,7 @@ static struct snd_kcontrol_new ad_beep_mixer[] = { | |||
174 | static int ad198x_build_controls(struct hda_codec *codec) | 174 | static int ad198x_build_controls(struct hda_codec *codec) |
175 | { | 175 | { |
176 | struct ad198x_spec *spec = codec->spec; | 176 | struct ad198x_spec *spec = codec->spec; |
177 | struct snd_kcontrol *kctl; | ||
177 | unsigned int i; | 178 | unsigned int i; |
178 | int err; | 179 | int err; |
179 | 180 | ||
@@ -208,9 +209,7 @@ static int ad198x_build_controls(struct hda_codec *codec) | |||
208 | if (!kctl) | 209 | if (!kctl) |
209 | return -ENOMEM; | 210 | return -ENOMEM; |
210 | kctl->private_value = spec->beep_amp; | 211 | kctl->private_value = spec->beep_amp; |
211 | err = snd_hda_ctl_add(codec, | 212 | err = snd_hda_ctl_add(codec, 0, kctl); |
212 | get_amp_nid_(spec->beep_amp), | ||
213 | kctl); | ||
214 | if (err < 0) | 213 | if (err < 0) |
215 | return err; | 214 | return err; |
216 | } | 215 | } |
@@ -239,6 +238,27 @@ static int ad198x_build_controls(struct hda_codec *codec) | |||
239 | } | 238 | } |
240 | 239 | ||
241 | ad198x_free_kctls(codec); /* no longer needed */ | 240 | ad198x_free_kctls(codec); /* no longer needed */ |
241 | |||
242 | /* assign Capture Source enums to NID */ | ||
243 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); | ||
244 | if (!kctl) | ||
245 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); | ||
246 | for (i = 0; kctl && i < kctl->count; i++) { | ||
247 | err = snd_hda_add_nid(codec, kctl, i, spec->capsrc_nids[i]); | ||
248 | if (err < 0) | ||
249 | return err; | ||
250 | } | ||
251 | |||
252 | /* assign IEC958 enums to NID */ | ||
253 | kctl = snd_hda_find_mixer_ctl(codec, | ||
254 | SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source"); | ||
255 | if (kctl) { | ||
256 | err = snd_hda_add_nid(codec, kctl, 0, | ||
257 | spec->multiout.dig_out_nid); | ||
258 | if (err < 0) | ||
259 | return err; | ||
260 | } | ||
261 | |||
242 | return 0; | 262 | return 0; |
243 | } | 263 | } |
244 | 264 | ||
@@ -421,6 +441,11 @@ static int ad198x_build_pcms(struct hda_codec *codec) | |||
421 | return 0; | 441 | return 0; |
422 | } | 442 | } |
423 | 443 | ||
444 | static inline void ad198x_shutup(struct hda_codec *codec) | ||
445 | { | ||
446 | snd_hda_shutup_pins(codec); | ||
447 | } | ||
448 | |||
424 | static void ad198x_free_kctls(struct hda_codec *codec) | 449 | static void ad198x_free_kctls(struct hda_codec *codec) |
425 | { | 450 | { |
426 | struct ad198x_spec *spec = codec->spec; | 451 | struct ad198x_spec *spec = codec->spec; |
@@ -434,6 +459,46 @@ static void ad198x_free_kctls(struct hda_codec *codec) | |||
434 | snd_array_free(&spec->kctls); | 459 | snd_array_free(&spec->kctls); |
435 | } | 460 | } |
436 | 461 | ||
462 | static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front, | ||
463 | hda_nid_t hp) | ||
464 | { | ||
465 | struct ad198x_spec *spec = codec->spec; | ||
466 | snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE, | ||
467 | !spec->inv_eapd ? 0x00 : 0x02); | ||
468 | snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE, | ||
469 | !spec->inv_eapd ? 0x00 : 0x02); | ||
470 | } | ||
471 | |||
472 | static void ad198x_power_eapd(struct hda_codec *codec) | ||
473 | { | ||
474 | /* We currently only handle front, HP */ | ||
475 | switch (codec->vendor_id) { | ||
476 | case 0x11d41882: | ||
477 | case 0x11d4882a: | ||
478 | case 0x11d41884: | ||
479 | case 0x11d41984: | ||
480 | case 0x11d41883: | ||
481 | case 0x11d4184a: | ||
482 | case 0x11d4194a: | ||
483 | case 0x11d4194b: | ||
484 | ad198x_power_eapd_write(codec, 0x12, 0x11); | ||
485 | break; | ||
486 | case 0x11d41981: | ||
487 | case 0x11d41983: | ||
488 | ad198x_power_eapd_write(codec, 0x05, 0x06); | ||
489 | break; | ||
490 | case 0x11d41986: | ||
491 | ad198x_power_eapd_write(codec, 0x1b, 0x1a); | ||
492 | break; | ||
493 | case 0x11d41988: | ||
494 | case 0x11d4198b: | ||
495 | case 0x11d4989a: | ||
496 | case 0x11d4989b: | ||
497 | ad198x_power_eapd_write(codec, 0x29, 0x22); | ||
498 | break; | ||
499 | } | ||
500 | } | ||
501 | |||
437 | static void ad198x_free(struct hda_codec *codec) | 502 | static void ad198x_free(struct hda_codec *codec) |
438 | { | 503 | { |
439 | struct ad198x_spec *spec = codec->spec; | 504 | struct ad198x_spec *spec = codec->spec; |
@@ -441,11 +506,29 @@ static void ad198x_free(struct hda_codec *codec) | |||
441 | if (!spec) | 506 | if (!spec) |
442 | return; | 507 | return; |
443 | 508 | ||
509 | ad198x_shutup(codec); | ||
444 | ad198x_free_kctls(codec); | 510 | ad198x_free_kctls(codec); |
445 | kfree(spec); | 511 | kfree(spec); |
446 | snd_hda_detach_beep_device(codec); | 512 | snd_hda_detach_beep_device(codec); |
447 | } | 513 | } |
448 | 514 | ||
515 | #ifdef SND_HDA_NEEDS_RESUME | ||
516 | static int ad198x_suspend(struct hda_codec *codec, pm_message_t state) | ||
517 | { | ||
518 | ad198x_shutup(codec); | ||
519 | ad198x_power_eapd(codec); | ||
520 | return 0; | ||
521 | } | ||
522 | |||
523 | static int ad198x_resume(struct hda_codec *codec) | ||
524 | { | ||
525 | ad198x_init(codec); | ||
526 | snd_hda_codec_resume_amp(codec); | ||
527 | snd_hda_codec_resume_cache(codec); | ||
528 | return 0; | ||
529 | } | ||
530 | #endif | ||
531 | |||
449 | static struct hda_codec_ops ad198x_patch_ops = { | 532 | static struct hda_codec_ops ad198x_patch_ops = { |
450 | .build_controls = ad198x_build_controls, | 533 | .build_controls = ad198x_build_controls, |
451 | .build_pcms = ad198x_build_pcms, | 534 | .build_pcms = ad198x_build_pcms, |
@@ -454,6 +537,11 @@ static struct hda_codec_ops ad198x_patch_ops = { | |||
454 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 537 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
455 | .check_power_status = ad198x_check_power_status, | 538 | .check_power_status = ad198x_check_power_status, |
456 | #endif | 539 | #endif |
540 | #ifdef SND_HDA_NEEDS_RESUME | ||
541 | .suspend = ad198x_suspend, | ||
542 | .resume = ad198x_resume, | ||
543 | #endif | ||
544 | .reboot_notify = ad198x_shutup, | ||
457 | }; | 545 | }; |
458 | 546 | ||
459 | 547 | ||
@@ -701,6 +789,7 @@ static struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = { | |||
701 | { | 789 | { |
702 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 790 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
703 | .name = "External Amplifier", | 791 | .name = "External Amplifier", |
792 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b, | ||
704 | .info = ad198x_eapd_info, | 793 | .info = ad198x_eapd_info, |
705 | .get = ad198x_eapd_get, | 794 | .get = ad198x_eapd_get, |
706 | .put = ad198x_eapd_put, | 795 | .put = ad198x_eapd_put, |
@@ -808,6 +897,7 @@ static struct snd_kcontrol_new ad1986a_automute_master_mixers[] = { | |||
808 | { | 897 | { |
809 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 898 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
810 | .name = "Master Playback Switch", | 899 | .name = "Master Playback Switch", |
900 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
811 | .info = snd_hda_mixer_amp_switch_info, | 901 | .info = snd_hda_mixer_amp_switch_info, |
812 | .get = snd_hda_mixer_amp_switch_get, | 902 | .get = snd_hda_mixer_amp_switch_get, |
813 | .put = ad1986a_hp_master_sw_put, | 903 | .put = ad1986a_hp_master_sw_put, |
@@ -1008,7 +1098,7 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = { | |||
1008 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK), | 1098 | SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK), |
1009 | SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK), | 1099 | SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK), |
1010 | SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK), | 1100 | SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK), |
1011 | SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD), | 1101 | SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba Satellite L40-10Q", AD1986A_3STACK), |
1012 | SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), | 1102 | SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), |
1013 | SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), | 1103 | SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), |
1014 | SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50), | 1104 | SND_PCI_QUIRK(0x144d, 0xc024, "Samsung P50", AD1986A_SAMSUNG_P50), |
@@ -1612,6 +1702,7 @@ static struct snd_kcontrol_new ad1981_hp_mixers[] = { | |||
1612 | HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol), | 1702 | HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol), |
1613 | { | 1703 | { |
1614 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1704 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
1705 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x05, | ||
1615 | .name = "Master Playback Switch", | 1706 | .name = "Master Playback Switch", |
1616 | .info = ad198x_eapd_info, | 1707 | .info = ad198x_eapd_info, |
1617 | .get = ad198x_eapd_get, | 1708 | .get = ad198x_eapd_get, |
@@ -2136,6 +2227,7 @@ static struct snd_kcontrol_new ad1988_laptop_mixers[] = { | |||
2136 | { | 2227 | { |
2137 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2228 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2138 | .name = "External Amplifier", | 2229 | .name = "External Amplifier", |
2230 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x12, | ||
2139 | .info = ad198x_eapd_info, | 2231 | .info = ad198x_eapd_info, |
2140 | .get = ad198x_eapd_get, | 2232 | .get = ad198x_eapd_get, |
2141 | .put = ad198x_eapd_put, | 2233 | .put = ad198x_eapd_put, |
@@ -2257,6 +2349,7 @@ static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = { | |||
2257 | { | 2349 | { |
2258 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2350 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2259 | .name = "IEC958 Playback Source", | 2351 | .name = "IEC958 Playback Source", |
2352 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b, | ||
2260 | .info = ad1988_spdif_playback_source_info, | 2353 | .info = ad1988_spdif_playback_source_info, |
2261 | .get = ad1988_spdif_playback_source_get, | 2354 | .get = ad1988_spdif_playback_source_get, |
2262 | .put = ad1988_spdif_playback_source_put, | 2355 | .put = ad1988_spdif_playback_source_put, |
@@ -2372,6 +2465,12 @@ static struct hda_verb ad1988_spdif_init_verbs[] = { | |||
2372 | { } | 2465 | { } |
2373 | }; | 2466 | }; |
2374 | 2467 | ||
2468 | static struct hda_verb ad1988_spdif_in_init_verbs[] = { | ||
2469 | /* unmute SPDIF input pin */ | ||
2470 | {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
2471 | { } | ||
2472 | }; | ||
2473 | |||
2375 | /* AD1989 has no ADC -> SPDIF route */ | 2474 | /* AD1989 has no ADC -> SPDIF route */ |
2376 | static struct hda_verb ad1989_spdif_init_verbs[] = { | 2475 | static struct hda_verb ad1989_spdif_init_verbs[] = { |
2377 | /* SPDIF-1 out pin */ | 2476 | /* SPDIF-1 out pin */ |
@@ -2589,7 +2688,7 @@ static int add_control(struct ad198x_spec *spec, int type, const char *name, | |||
2589 | if (! knew->name) | 2688 | if (! knew->name) |
2590 | return -ENOMEM; | 2689 | return -ENOMEM; |
2591 | if (get_amp_nid_(val)) | 2690 | if (get_amp_nid_(val)) |
2592 | knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); | 2691 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
2593 | knew->private_value = val; | 2692 | knew->private_value = val; |
2594 | return 0; | 2693 | return 0; |
2595 | } | 2694 | } |
@@ -3107,8 +3206,11 @@ static int patch_ad1988(struct hda_codec *codec) | |||
3107 | ad1988_spdif_init_verbs; | 3206 | ad1988_spdif_init_verbs; |
3108 | } | 3207 | } |
3109 | } | 3208 | } |
3110 | if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a) | 3209 | if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a) { |
3111 | spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; | 3210 | spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; |
3211 | spec->init_verbs[spec->num_init_verbs++] = | ||
3212 | ad1988_spdif_in_init_verbs; | ||
3213 | } | ||
3112 | 3214 | ||
3113 | codec->patch_ops = ad198x_patch_ops; | 3215 | codec->patch_ops = ad198x_patch_ops; |
3114 | switch (board_config) { | 3216 | switch (board_config) { |
@@ -3747,6 +3849,7 @@ static struct snd_kcontrol_new ad1884a_laptop_mixers[] = { | |||
3747 | { | 3849 | { |
3748 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 3850 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
3749 | .name = "Master Playback Switch", | 3851 | .name = "Master Playback Switch", |
3852 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
3750 | .info = snd_hda_mixer_amp_switch_info, | 3853 | .info = snd_hda_mixer_amp_switch_info, |
3751 | .get = snd_hda_mixer_amp_switch_get, | 3854 | .get = snd_hda_mixer_amp_switch_get, |
3752 | .put = ad1884a_mobile_master_sw_put, | 3855 | .put = ad1884a_mobile_master_sw_put, |
@@ -3775,6 +3878,7 @@ static struct snd_kcontrol_new ad1884a_mobile_mixers[] = { | |||
3775 | { | 3878 | { |
3776 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 3879 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
3777 | .name = "Master Playback Switch", | 3880 | .name = "Master Playback Switch", |
3881 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
3778 | .info = snd_hda_mixer_amp_switch_info, | 3882 | .info = snd_hda_mixer_amp_switch_info, |
3779 | .get = snd_hda_mixer_amp_switch_get, | 3883 | .get = snd_hda_mixer_amp_switch_get, |
3780 | .put = ad1884a_mobile_master_sw_put, | 3884 | .put = ad1884a_mobile_master_sw_put, |
@@ -4116,6 +4220,7 @@ static struct snd_kcontrol_new ad1984a_touchsmart_mixers[] = { | |||
4116 | /* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/ | 4220 | /* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/ |
4117 | { | 4221 | { |
4118 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 4222 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
4223 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
4119 | .name = "Master Playback Switch", | 4224 | .name = "Master Playback Switch", |
4120 | .info = snd_hda_mixer_amp_switch_info, | 4225 | .info = snd_hda_mixer_amp_switch_info, |
4121 | .get = snd_hda_mixer_amp_switch_get, | 4226 | .get = snd_hda_mixer_amp_switch_get, |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index fe0423c39598..7de782a5b8f4 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c | |||
@@ -501,7 +501,8 @@ static int add_mute(struct hda_codec *codec, const char *name, int index, | |||
501 | knew.private_value = pval; | 501 | knew.private_value = pval; |
502 | snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]); | 502 | snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]); |
503 | *kctlp = snd_ctl_new1(&knew, codec); | 503 | *kctlp = snd_ctl_new1(&knew, codec); |
504 | return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp); | 504 | (*kctlp)->id.subdevice = HDA_SUBDEV_AMP_FLAG; |
505 | return snd_hda_ctl_add(codec, 0, *kctlp); | ||
505 | } | 506 | } |
506 | 507 | ||
507 | static int add_volume(struct hda_codec *codec, const char *name, | 508 | static int add_volume(struct hda_codec *codec, const char *name, |
@@ -514,7 +515,8 @@ static int add_volume(struct hda_codec *codec, const char *name, | |||
514 | knew.private_value = pval; | 515 | knew.private_value = pval; |
515 | snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]); | 516 | snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]); |
516 | *kctlp = snd_ctl_new1(&knew, codec); | 517 | *kctlp = snd_ctl_new1(&knew, codec); |
517 | return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp); | 518 | (*kctlp)->id.subdevice = HDA_SUBDEV_AMP_FLAG; |
519 | return snd_hda_ctl_add(codec, 0, *kctlp); | ||
518 | } | 520 | } |
519 | 521 | ||
520 | static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) | 522 | static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) |
@@ -751,6 +753,7 @@ static int build_input(struct hda_codec *codec) | |||
751 | spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol); | 753 | spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol); |
752 | for (i = 0; i < 2; i++) { | 754 | for (i = 0; i < 2; i++) { |
753 | struct snd_kcontrol *kctl; | 755 | struct snd_kcontrol *kctl; |
756 | int n; | ||
754 | if (!spec->capture_bind[i]) | 757 | if (!spec->capture_bind[i]) |
755 | return -ENOMEM; | 758 | return -ENOMEM; |
756 | kctl = snd_ctl_new1(&cs_capture_ctls[i], codec); | 759 | kctl = snd_ctl_new1(&cs_capture_ctls[i], codec); |
@@ -760,6 +763,13 @@ static int build_input(struct hda_codec *codec) | |||
760 | err = snd_hda_ctl_add(codec, 0, kctl); | 763 | err = snd_hda_ctl_add(codec, 0, kctl); |
761 | if (err < 0) | 764 | if (err < 0) |
762 | return err; | 765 | return err; |
766 | for (n = 0; n < AUTO_PIN_LAST; n++) { | ||
767 | if (!spec->adc_nid[n]) | ||
768 | continue; | ||
769 | err = snd_hda_add_nid(codec, kctl, 0, spec->adc_nid[i]); | ||
770 | if (err < 0) | ||
771 | return err; | ||
772 | } | ||
763 | } | 773 | } |
764 | 774 | ||
765 | if (spec->num_inputs > 1 && !spec->mic_detect) { | 775 | if (spec->num_inputs > 1 && !spec->mic_detect) { |
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index a45c1169762b..ff60908f4554 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c | |||
@@ -315,7 +315,8 @@ static struct hda_verb cmi9880_allout_init[] = { | |||
315 | static int cmi9880_build_controls(struct hda_codec *codec) | 315 | static int cmi9880_build_controls(struct hda_codec *codec) |
316 | { | 316 | { |
317 | struct cmi_spec *spec = codec->spec; | 317 | struct cmi_spec *spec = codec->spec; |
318 | int err; | 318 | struct snd_kcontrol *kctl; |
319 | int i, err; | ||
319 | 320 | ||
320 | err = snd_hda_add_new_ctls(codec, cmi9880_basic_mixer); | 321 | err = snd_hda_add_new_ctls(codec, cmi9880_basic_mixer); |
321 | if (err < 0) | 322 | if (err < 0) |
@@ -340,6 +341,14 @@ static int cmi9880_build_controls(struct hda_codec *codec) | |||
340 | if (err < 0) | 341 | if (err < 0) |
341 | return err; | 342 | return err; |
342 | } | 343 | } |
344 | |||
345 | /* assign Capture Source enums to NID */ | ||
346 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); | ||
347 | for (i = 0; kctl && i < kctl->count; i++) { | ||
348 | err = snd_hda_add_nid(codec, kctl, i, spec->adc_nids[i]); | ||
349 | if (err < 0) | ||
350 | return err; | ||
351 | } | ||
343 | return 0; | 352 | return 0; |
344 | } | 353 | } |
345 | 354 | ||
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index c578c28f368e..194a28c54992 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -42,10 +42,12 @@ | |||
42 | 42 | ||
43 | /* Conexant 5051 specific */ | 43 | /* Conexant 5051 specific */ |
44 | 44 | ||
45 | #define CXT5051_SPDIF_OUT 0x1C | 45 | #define CXT5051_SPDIF_OUT 0x12 |
46 | #define CXT5051_PORTB_EVENT 0x38 | 46 | #define CXT5051_PORTB_EVENT 0x38 |
47 | #define CXT5051_PORTC_EVENT 0x39 | 47 | #define CXT5051_PORTC_EVENT 0x39 |
48 | 48 | ||
49 | #define AUTO_MIC_PORTB (1 << 1) | ||
50 | #define AUTO_MIC_PORTC (1 << 2) | ||
49 | 51 | ||
50 | struct conexant_jack { | 52 | struct conexant_jack { |
51 | 53 | ||
@@ -74,7 +76,7 @@ struct conexant_spec { | |||
74 | */ | 76 | */ |
75 | unsigned int cur_eapd; | 77 | unsigned int cur_eapd; |
76 | unsigned int hp_present; | 78 | unsigned int hp_present; |
77 | unsigned int no_auto_mic; | 79 | unsigned int auto_mic; |
78 | unsigned int need_dac_fix; | 80 | unsigned int need_dac_fix; |
79 | 81 | ||
80 | /* capture */ | 82 | /* capture */ |
@@ -111,8 +113,23 @@ struct conexant_spec { | |||
111 | 113 | ||
112 | unsigned int dell_automute; | 114 | unsigned int dell_automute; |
113 | unsigned int port_d_mode; | 115 | unsigned int port_d_mode; |
114 | unsigned char ext_mic_bias; | 116 | unsigned int dell_vostro:1; |
115 | unsigned int dell_vostro; | 117 | unsigned int ideapad:1; |
118 | |||
119 | unsigned int ext_mic_present; | ||
120 | unsigned int recording; | ||
121 | void (*capture_prepare)(struct hda_codec *codec); | ||
122 | void (*capture_cleanup)(struct hda_codec *codec); | ||
123 | |||
124 | /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) | ||
125 | * through the microphone jack. | ||
126 | * When the user enables this through a mixer switch, both internal and | ||
127 | * external microphones are disabled. Gain is fixed at 0dB. In this mode, | ||
128 | * we also allow the bias to be configured through a separate mixer | ||
129 | * control. */ | ||
130 | unsigned int dc_enable; | ||
131 | unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ | ||
132 | unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ | ||
116 | }; | 133 | }; |
117 | 134 | ||
118 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, | 135 | static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, |
@@ -185,6 +202,8 @@ static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
185 | struct snd_pcm_substream *substream) | 202 | struct snd_pcm_substream *substream) |
186 | { | 203 | { |
187 | struct conexant_spec *spec = codec->spec; | 204 | struct conexant_spec *spec = codec->spec; |
205 | if (spec->capture_prepare) | ||
206 | spec->capture_prepare(codec); | ||
188 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], | 207 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
189 | stream_tag, 0, format); | 208 | stream_tag, 0, format); |
190 | return 0; | 209 | return 0; |
@@ -196,6 +215,8 @@ static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |||
196 | { | 215 | { |
197 | struct conexant_spec *spec = codec->spec; | 216 | struct conexant_spec *spec = codec->spec; |
198 | snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); | 217 | snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); |
218 | if (spec->capture_cleanup) | ||
219 | spec->capture_cleanup(codec); | ||
199 | return 0; | 220 | return 0; |
200 | } | 221 | } |
201 | 222 | ||
@@ -1585,6 +1606,11 @@ static void cxt5051_update_speaker(struct hda_codec *codec) | |||
1585 | { | 1606 | { |
1586 | struct conexant_spec *spec = codec->spec; | 1607 | struct conexant_spec *spec = codec->spec; |
1587 | unsigned int pinctl; | 1608 | unsigned int pinctl; |
1609 | /* headphone pin */ | ||
1610 | pinctl = (spec->hp_present && spec->cur_eapd) ? PIN_HP : 0; | ||
1611 | snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
1612 | pinctl); | ||
1613 | /* speaker pin */ | ||
1588 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; | 1614 | pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; |
1589 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | 1615 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
1590 | pinctl); | 1616 | pinctl); |
@@ -1608,7 +1634,7 @@ static void cxt5051_portb_automic(struct hda_codec *codec) | |||
1608 | struct conexant_spec *spec = codec->spec; | 1634 | struct conexant_spec *spec = codec->spec; |
1609 | unsigned int present; | 1635 | unsigned int present; |
1610 | 1636 | ||
1611 | if (spec->no_auto_mic) | 1637 | if (!(spec->auto_mic & AUTO_MIC_PORTB)) |
1612 | return; | 1638 | return; |
1613 | present = snd_hda_jack_detect(codec, 0x17); | 1639 | present = snd_hda_jack_detect(codec, 0x17); |
1614 | snd_hda_codec_write(codec, 0x14, 0, | 1640 | snd_hda_codec_write(codec, 0x14, 0, |
@@ -1623,7 +1649,7 @@ static void cxt5051_portc_automic(struct hda_codec *codec) | |||
1623 | unsigned int present; | 1649 | unsigned int present; |
1624 | hda_nid_t new_adc; | 1650 | hda_nid_t new_adc; |
1625 | 1651 | ||
1626 | if (spec->no_auto_mic) | 1652 | if (!(spec->auto_mic & AUTO_MIC_PORTC)) |
1627 | return; | 1653 | return; |
1628 | present = snd_hda_jack_detect(codec, 0x18); | 1654 | present = snd_hda_jack_detect(codec, 0x18); |
1629 | if (present) | 1655 | if (present) |
@@ -1669,13 +1695,7 @@ static void cxt5051_hp_unsol_event(struct hda_codec *codec, | |||
1669 | conexant_report_jack(codec, nid); | 1695 | conexant_report_jack(codec, nid); |
1670 | } | 1696 | } |
1671 | 1697 | ||
1672 | static struct snd_kcontrol_new cxt5051_mixers[] = { | 1698 | static struct snd_kcontrol_new cxt5051_playback_mixers[] = { |
1673 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), | ||
1674 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | ||
1675 | HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT), | ||
1676 | HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT), | ||
1677 | HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT), | ||
1678 | HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT), | ||
1679 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), | 1699 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), |
1680 | { | 1700 | { |
1681 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1701 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
@@ -1685,7 +1705,16 @@ static struct snd_kcontrol_new cxt5051_mixers[] = { | |||
1685 | .put = cxt5051_hp_master_sw_put, | 1705 | .put = cxt5051_hp_master_sw_put, |
1686 | .private_value = 0x1a, | 1706 | .private_value = 0x1a, |
1687 | }, | 1707 | }, |
1708 | {} | ||
1709 | }; | ||
1688 | 1710 | ||
1711 | static struct snd_kcontrol_new cxt5051_capture_mixers[] = { | ||
1712 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), | ||
1713 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | ||
1714 | HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT), | ||
1715 | HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT), | ||
1716 | HDA_CODEC_VOLUME("Docking Mic Volume", 0x15, 0x00, HDA_INPUT), | ||
1717 | HDA_CODEC_MUTE("Docking Mic Switch", 0x15, 0x00, HDA_INPUT), | ||
1689 | {} | 1718 | {} |
1690 | }; | 1719 | }; |
1691 | 1720 | ||
@@ -1694,32 +1723,26 @@ static struct snd_kcontrol_new cxt5051_hp_mixers[] = { | |||
1694 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | 1723 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), |
1695 | HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT), | 1724 | HDA_CODEC_VOLUME("External Mic Volume", 0x15, 0x00, HDA_INPUT), |
1696 | HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT), | 1725 | HDA_CODEC_MUTE("External Mic Switch", 0x15, 0x00, HDA_INPUT), |
1697 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), | ||
1698 | { | ||
1699 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1700 | .name = "Master Playback Switch", | ||
1701 | .info = cxt_eapd_info, | ||
1702 | .get = cxt_eapd_get, | ||
1703 | .put = cxt5051_hp_master_sw_put, | ||
1704 | .private_value = 0x1a, | ||
1705 | }, | ||
1706 | |||
1707 | {} | 1726 | {} |
1708 | }; | 1727 | }; |
1709 | 1728 | ||
1710 | static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { | 1729 | static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = { |
1711 | HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x00, HDA_INPUT), | 1730 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x00, HDA_INPUT), |
1712 | HDA_CODEC_MUTE("Mic Switch", 0x14, 0x00, HDA_INPUT), | 1731 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x00, HDA_INPUT), |
1713 | HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), | 1732 | {} |
1714 | { | 1733 | }; |
1715 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
1716 | .name = "Master Playback Switch", | ||
1717 | .info = cxt_eapd_info, | ||
1718 | .get = cxt_eapd_get, | ||
1719 | .put = cxt5051_hp_master_sw_put, | ||
1720 | .private_value = 0x1a, | ||
1721 | }, | ||
1722 | 1734 | ||
1735 | static struct snd_kcontrol_new cxt5051_f700_mixers[] = { | ||
1736 | HDA_CODEC_VOLUME("Capture Volume", 0x14, 0x01, HDA_INPUT), | ||
1737 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0x01, HDA_INPUT), | ||
1738 | {} | ||
1739 | }; | ||
1740 | |||
1741 | static struct snd_kcontrol_new cxt5051_toshiba_mixers[] = { | ||
1742 | HDA_CODEC_VOLUME("Internal Mic Volume", 0x14, 0x00, HDA_INPUT), | ||
1743 | HDA_CODEC_MUTE("Internal Mic Switch", 0x14, 0x00, HDA_INPUT), | ||
1744 | HDA_CODEC_VOLUME("External Mic Volume", 0x14, 0x01, HDA_INPUT), | ||
1745 | HDA_CODEC_MUTE("External Mic Switch", 0x14, 0x01, HDA_INPUT), | ||
1723 | {} | 1746 | {} |
1724 | }; | 1747 | }; |
1725 | 1748 | ||
@@ -1748,8 +1771,6 @@ static struct hda_verb cxt5051_init_verbs[] = { | |||
1748 | /* EAPD */ | 1771 | /* EAPD */ |
1749 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | 1772 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
1750 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | 1773 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
1751 | {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT}, | ||
1752 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT}, | ||
1753 | { } /* end */ | 1774 | { } /* end */ |
1754 | }; | 1775 | }; |
1755 | 1776 | ||
@@ -1775,7 +1796,6 @@ static struct hda_verb cxt5051_hp_dv6736_init_verbs[] = { | |||
1775 | /* EAPD */ | 1796 | /* EAPD */ |
1776 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | 1797 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
1777 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | 1798 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
1778 | {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT}, | ||
1779 | { } /* end */ | 1799 | { } /* end */ |
1780 | }; | 1800 | }; |
1781 | 1801 | ||
@@ -1807,17 +1827,60 @@ static struct hda_verb cxt5051_lenovo_x200_init_verbs[] = { | |||
1807 | /* EAPD */ | 1827 | /* EAPD */ |
1808 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | 1828 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
1809 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | 1829 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
1810 | {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT}, | ||
1811 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT}, | ||
1812 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | 1830 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, |
1813 | { } /* end */ | 1831 | { } /* end */ |
1814 | }; | 1832 | }; |
1815 | 1833 | ||
1834 | static struct hda_verb cxt5051_f700_init_verbs[] = { | ||
1835 | /* Line in, Mic */ | ||
1836 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, | ||
1837 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
1838 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | ||
1839 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, | ||
1840 | /* SPK */ | ||
1841 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
1842 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
1843 | /* HP, Amp */ | ||
1844 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
1845 | {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
1846 | /* DAC1 */ | ||
1847 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
1848 | /* Record selector: Int mic */ | ||
1849 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, | ||
1850 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, | ||
1851 | /* SPDIF route: PCM */ | ||
1852 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
1853 | /* EAPD */ | ||
1854 | {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | ||
1855 | {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, | ||
1856 | { } /* end */ | ||
1857 | }; | ||
1858 | |||
1859 | static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, | ||
1860 | unsigned int event) | ||
1861 | { | ||
1862 | snd_hda_codec_write(codec, nid, 0, | ||
1863 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
1864 | AC_USRSP_EN | event); | ||
1865 | #ifdef CONFIG_SND_HDA_INPUT_JACK | ||
1866 | conexant_add_jack(codec, nid, SND_JACK_MICROPHONE); | ||
1867 | conexant_report_jack(codec, nid); | ||
1868 | #endif | ||
1869 | } | ||
1870 | |||
1816 | /* initialize jack-sensing, too */ | 1871 | /* initialize jack-sensing, too */ |
1817 | static int cxt5051_init(struct hda_codec *codec) | 1872 | static int cxt5051_init(struct hda_codec *codec) |
1818 | { | 1873 | { |
1874 | struct conexant_spec *spec = codec->spec; | ||
1875 | |||
1819 | conexant_init(codec); | 1876 | conexant_init(codec); |
1820 | conexant_init_jacks(codec); | 1877 | conexant_init_jacks(codec); |
1878 | |||
1879 | if (spec->auto_mic & AUTO_MIC_PORTB) | ||
1880 | cxt5051_init_mic_port(codec, 0x17, CXT5051_PORTB_EVENT); | ||
1881 | if (spec->auto_mic & AUTO_MIC_PORTC) | ||
1882 | cxt5051_init_mic_port(codec, 0x18, CXT5051_PORTC_EVENT); | ||
1883 | |||
1821 | if (codec->patch_ops.unsol_event) { | 1884 | if (codec->patch_ops.unsol_event) { |
1822 | cxt5051_hp_automute(codec); | 1885 | cxt5051_hp_automute(codec); |
1823 | cxt5051_portb_automic(codec); | 1886 | cxt5051_portb_automic(codec); |
@@ -1832,6 +1895,8 @@ enum { | |||
1832 | CXT5051_HP, /* no docking */ | 1895 | CXT5051_HP, /* no docking */ |
1833 | CXT5051_HP_DV6736, /* HP without mic switch */ | 1896 | CXT5051_HP_DV6736, /* HP without mic switch */ |
1834 | CXT5051_LENOVO_X200, /* Lenovo X200 laptop */ | 1897 | CXT5051_LENOVO_X200, /* Lenovo X200 laptop */ |
1898 | CXT5051_F700, /* HP Compaq Presario F700 */ | ||
1899 | CXT5051_TOSHIBA, /* Toshiba M300 & co */ | ||
1835 | CXT5051_MODELS | 1900 | CXT5051_MODELS |
1836 | }; | 1901 | }; |
1837 | 1902 | ||
@@ -1840,11 +1905,15 @@ static const char *cxt5051_models[CXT5051_MODELS] = { | |||
1840 | [CXT5051_HP] = "hp", | 1905 | [CXT5051_HP] = "hp", |
1841 | [CXT5051_HP_DV6736] = "hp-dv6736", | 1906 | [CXT5051_HP_DV6736] = "hp-dv6736", |
1842 | [CXT5051_LENOVO_X200] = "lenovo-x200", | 1907 | [CXT5051_LENOVO_X200] = "lenovo-x200", |
1908 | [CXT5051_F700] = "hp-700", | ||
1909 | [CXT5051_TOSHIBA] = "toshiba", | ||
1843 | }; | 1910 | }; |
1844 | 1911 | ||
1845 | static struct snd_pci_quirk cxt5051_cfg_tbl[] = { | 1912 | static struct snd_pci_quirk cxt5051_cfg_tbl[] = { |
1846 | SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), | 1913 | SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736), |
1847 | SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), | 1914 | SND_PCI_QUIRK(0x103c, 0x360b, "Compaq Presario CQ60", CXT5051_HP), |
1915 | SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), | ||
1916 | SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba M30x", CXT5051_TOSHIBA), | ||
1848 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", | 1917 | SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", |
1849 | CXT5051_LAPTOP), | 1918 | CXT5051_LAPTOP), |
1850 | SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), | 1919 | SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), |
@@ -1872,8 +1941,9 @@ static int patch_cxt5051(struct hda_codec *codec) | |||
1872 | spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; | 1941 | spec->multiout.dig_out_nid = CXT5051_SPDIF_OUT; |
1873 | spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ | 1942 | spec->num_adc_nids = 1; /* not 2; via auto-mic switch */ |
1874 | spec->adc_nids = cxt5051_adc_nids; | 1943 | spec->adc_nids = cxt5051_adc_nids; |
1875 | spec->num_mixers = 1; | 1944 | spec->num_mixers = 2; |
1876 | spec->mixers[0] = cxt5051_mixers; | 1945 | spec->mixers[0] = cxt5051_capture_mixers; |
1946 | spec->mixers[1] = cxt5051_playback_mixers; | ||
1877 | spec->num_init_verbs = 1; | 1947 | spec->num_init_verbs = 1; |
1878 | spec->init_verbs[0] = cxt5051_init_verbs; | 1948 | spec->init_verbs[0] = cxt5051_init_verbs; |
1879 | spec->spdif_route = 0; | 1949 | spec->spdif_route = 0; |
@@ -1887,6 +1957,7 @@ static int patch_cxt5051(struct hda_codec *codec) | |||
1887 | board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, | 1957 | board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, |
1888 | cxt5051_models, | 1958 | cxt5051_models, |
1889 | cxt5051_cfg_tbl); | 1959 | cxt5051_cfg_tbl); |
1960 | spec->auto_mic = AUTO_MIC_PORTB | AUTO_MIC_PORTC; | ||
1890 | switch (board_config) { | 1961 | switch (board_config) { |
1891 | case CXT5051_HP: | 1962 | case CXT5051_HP: |
1892 | spec->mixers[0] = cxt5051_hp_mixers; | 1963 | spec->mixers[0] = cxt5051_hp_mixers; |
@@ -1894,11 +1965,20 @@ static int patch_cxt5051(struct hda_codec *codec) | |||
1894 | case CXT5051_HP_DV6736: | 1965 | case CXT5051_HP_DV6736: |
1895 | spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; | 1966 | spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs; |
1896 | spec->mixers[0] = cxt5051_hp_dv6736_mixers; | 1967 | spec->mixers[0] = cxt5051_hp_dv6736_mixers; |
1897 | spec->no_auto_mic = 1; | 1968 | spec->auto_mic = 0; |
1898 | break; | 1969 | break; |
1899 | case CXT5051_LENOVO_X200: | 1970 | case CXT5051_LENOVO_X200: |
1900 | spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs; | 1971 | spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs; |
1901 | break; | 1972 | break; |
1973 | case CXT5051_F700: | ||
1974 | spec->init_verbs[0] = cxt5051_f700_init_verbs; | ||
1975 | spec->mixers[0] = cxt5051_f700_mixers; | ||
1976 | spec->auto_mic = 0; | ||
1977 | break; | ||
1978 | case CXT5051_TOSHIBA: | ||
1979 | spec->mixers[0] = cxt5051_toshiba_mixers; | ||
1980 | spec->auto_mic = AUTO_MIC_PORTB; | ||
1981 | break; | ||
1902 | } | 1982 | } |
1903 | 1983 | ||
1904 | return 0; | 1984 | return 0; |
@@ -1966,33 +2046,117 @@ static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |||
1966 | return 1; | 2046 | return 1; |
1967 | } | 2047 | } |
1968 | 2048 | ||
2049 | static const struct hda_input_mux cxt5066_olpc_dc_bias = { | ||
2050 | .num_items = 3, | ||
2051 | .items = { | ||
2052 | { "Off", PIN_IN }, | ||
2053 | { "50%", PIN_VREF50 }, | ||
2054 | { "80%", PIN_VREF80 }, | ||
2055 | }, | ||
2056 | }; | ||
2057 | |||
2058 | static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) | ||
2059 | { | ||
2060 | struct conexant_spec *spec = codec->spec; | ||
2061 | /* Even though port F is the DC input, the bias is controlled on port B. | ||
2062 | * we also leave that port as an active input (but unselected) in DC mode | ||
2063 | * just in case that is necessary to make the bias setting take effect. */ | ||
2064 | return snd_hda_codec_write_cache(codec, 0x1a, 0, | ||
2065 | AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
2066 | cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); | ||
2067 | } | ||
2068 | |||
2069 | /* OLPC defers mic widget control until when capture is started because the | ||
2070 | * microphone LED comes on as soon as these settings are put in place. if we | ||
2071 | * did this before recording, it would give the false indication that recording | ||
2072 | * is happening when it is not. */ | ||
2073 | static void cxt5066_olpc_select_mic(struct hda_codec *codec) | ||
2074 | { | ||
2075 | struct conexant_spec *spec = codec->spec; | ||
2076 | if (!spec->recording) | ||
2077 | return; | ||
2078 | |||
2079 | if (spec->dc_enable) { | ||
2080 | /* in DC mode we ignore presence detection and just use the jack | ||
2081 | * through our special DC port */ | ||
2082 | const struct hda_verb enable_dc_mode[] = { | ||
2083 | /* disble internal mic, port C */ | ||
2084 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2085 | |||
2086 | /* enable DC capture, port F */ | ||
2087 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
2088 | {}, | ||
2089 | }; | ||
2090 | |||
2091 | snd_hda_sequence_write(codec, enable_dc_mode); | ||
2092 | /* port B input disabled (and bias set) through the following call */ | ||
2093 | cxt5066_set_olpc_dc_bias(codec); | ||
2094 | return; | ||
2095 | } | ||
2096 | |||
2097 | /* disable DC (port F) */ | ||
2098 | snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
2099 | |||
2100 | /* external mic, port B */ | ||
2101 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
2102 | spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); | ||
2103 | |||
2104 | /* internal mic, port C */ | ||
2105 | snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
2106 | spec->ext_mic_present ? 0 : PIN_VREF80); | ||
2107 | } | ||
2108 | |||
1969 | /* toggle input of built-in and mic jack appropriately */ | 2109 | /* toggle input of built-in and mic jack appropriately */ |
1970 | static void cxt5066_automic(struct hda_codec *codec) | 2110 | static void cxt5066_olpc_automic(struct hda_codec *codec) |
1971 | { | 2111 | { |
1972 | struct conexant_spec *spec = codec->spec; | 2112 | struct conexant_spec *spec = codec->spec; |
2113 | unsigned int present; | ||
2114 | |||
2115 | if (spec->dc_enable) /* don't do presence detection in DC mode */ | ||
2116 | return; | ||
2117 | |||
2118 | present = snd_hda_codec_read(codec, 0x1a, 0, | ||
2119 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
2120 | if (present) | ||
2121 | snd_printdd("CXT5066: external microphone detected\n"); | ||
2122 | else | ||
2123 | snd_printdd("CXT5066: external microphone absent\n"); | ||
2124 | |||
2125 | snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, | ||
2126 | present ? 0 : 1); | ||
2127 | spec->ext_mic_present = !!present; | ||
2128 | |||
2129 | cxt5066_olpc_select_mic(codec); | ||
2130 | } | ||
2131 | |||
2132 | /* toggle input of built-in digital mic and mic jack appropriately */ | ||
2133 | static void cxt5066_vostro_automic(struct hda_codec *codec) | ||
2134 | { | ||
2135 | unsigned int present; | ||
2136 | |||
1973 | struct hda_verb ext_mic_present[] = { | 2137 | struct hda_verb ext_mic_present[] = { |
1974 | /* enable external mic, port B */ | 2138 | /* enable external mic, port B */ |
1975 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, spec->ext_mic_bias}, | 2139 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, |
1976 | 2140 | ||
1977 | /* switch to external mic input */ | 2141 | /* switch to external mic input */ |
1978 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | 2142 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, |
2143 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, | ||
1979 | 2144 | ||
1980 | /* disable internal mic, port C */ | 2145 | /* disable internal digital mic */ |
1981 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | 2146 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
1982 | {} | 2147 | {} |
1983 | }; | 2148 | }; |
1984 | static struct hda_verb ext_mic_absent[] = { | 2149 | static struct hda_verb ext_mic_absent[] = { |
1985 | /* enable internal mic, port C */ | 2150 | /* enable internal mic, port C */ |
1986 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 2151 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
1987 | 2152 | ||
1988 | /* switch to internal mic input */ | 2153 | /* switch to internal mic input */ |
1989 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, | 2154 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
1990 | 2155 | ||
1991 | /* disable external mic, port B */ | 2156 | /* disable external mic, port B */ |
1992 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | 2157 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
1993 | {} | 2158 | {} |
1994 | }; | 2159 | }; |
1995 | unsigned int present; | ||
1996 | 2160 | ||
1997 | present = snd_hda_jack_detect(codec, 0x1a); | 2161 | present = snd_hda_jack_detect(codec, 0x1a); |
1998 | if (present) { | 2162 | if (present) { |
@@ -2005,36 +2169,24 @@ static void cxt5066_automic(struct hda_codec *codec) | |||
2005 | } | 2169 | } |
2006 | 2170 | ||
2007 | /* toggle input of built-in digital mic and mic jack appropriately */ | 2171 | /* toggle input of built-in digital mic and mic jack appropriately */ |
2008 | static void cxt5066_vostro_automic(struct hda_codec *codec) | 2172 | static void cxt5066_ideapad_automic(struct hda_codec *codec) |
2009 | { | 2173 | { |
2010 | struct conexant_spec *spec = codec->spec; | ||
2011 | unsigned int present; | 2174 | unsigned int present; |
2012 | 2175 | ||
2013 | struct hda_verb ext_mic_present[] = { | 2176 | struct hda_verb ext_mic_present[] = { |
2014 | /* enable external mic, port B */ | ||
2015 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, spec->ext_mic_bias}, | ||
2016 | |||
2017 | /* switch to external mic input */ | ||
2018 | {0x17, AC_VERB_SET_CONNECT_SEL, 0}, | ||
2019 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, | 2177 | {0x14, AC_VERB_SET_CONNECT_SEL, 0}, |
2020 | 2178 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | |
2021 | /* disable internal digital mic */ | ||
2022 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | 2179 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
2023 | {} | 2180 | {} |
2024 | }; | 2181 | }; |
2025 | static struct hda_verb ext_mic_absent[] = { | 2182 | static struct hda_verb ext_mic_absent[] = { |
2026 | /* enable internal mic, port C */ | ||
2027 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
2028 | |||
2029 | /* switch to internal mic input */ | ||
2030 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, | 2183 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, |
2031 | 2184 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | |
2032 | /* disable external mic, port B */ | 2185 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
2033 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2034 | {} | 2186 | {} |
2035 | }; | 2187 | }; |
2036 | 2188 | ||
2037 | present = snd_hda_jack_detect(codec, 0x1a); | 2189 | present = snd_hda_jack_detect(codec, 0x1b); |
2038 | if (present) { | 2190 | if (present) { |
2039 | snd_printdd("CXT5066: external microphone detected\n"); | 2191 | snd_printdd("CXT5066: external microphone detected\n"); |
2040 | snd_hda_sequence_write(codec, ext_mic_present); | 2192 | snd_hda_sequence_write(codec, ext_mic_present); |
@@ -2063,15 +2215,18 @@ static void cxt5066_hp_automute(struct hda_codec *codec) | |||
2063 | } | 2215 | } |
2064 | 2216 | ||
2065 | /* unsolicited event for jack sensing */ | 2217 | /* unsolicited event for jack sensing */ |
2066 | static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) | 2218 | static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) |
2067 | { | 2219 | { |
2220 | struct conexant_spec *spec = codec->spec; | ||
2068 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); | 2221 | snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); |
2069 | switch (res >> 26) { | 2222 | switch (res >> 26) { |
2070 | case CONEXANT_HP_EVENT: | 2223 | case CONEXANT_HP_EVENT: |
2071 | cxt5066_hp_automute(codec); | 2224 | cxt5066_hp_automute(codec); |
2072 | break; | 2225 | break; |
2073 | case CONEXANT_MIC_EVENT: | 2226 | case CONEXANT_MIC_EVENT: |
2074 | cxt5066_automic(codec); | 2227 | /* ignore mic events in DC mode; we're always using the jack */ |
2228 | if (!spec->dc_enable) | ||
2229 | cxt5066_olpc_automic(codec); | ||
2075 | break; | 2230 | break; |
2076 | } | 2231 | } |
2077 | } | 2232 | } |
@@ -2090,6 +2245,20 @@ static void cxt5066_vostro_event(struct hda_codec *codec, unsigned int res) | |||
2090 | } | 2245 | } |
2091 | } | 2246 | } |
2092 | 2247 | ||
2248 | /* unsolicited event for jack sensing */ | ||
2249 | static void cxt5066_ideapad_event(struct hda_codec *codec, unsigned int res) | ||
2250 | { | ||
2251 | snd_printdd("CXT5066_ideapad: unsol event %x (%x)\n", res, res >> 26); | ||
2252 | switch (res >> 26) { | ||
2253 | case CONEXANT_HP_EVENT: | ||
2254 | cxt5066_hp_automute(codec); | ||
2255 | break; | ||
2256 | case CONEXANT_MIC_EVENT: | ||
2257 | cxt5066_ideapad_automic(codec); | ||
2258 | break; | ||
2259 | } | ||
2260 | } | ||
2261 | |||
2093 | static const struct hda_input_mux cxt5066_analog_mic_boost = { | 2262 | static const struct hda_input_mux cxt5066_analog_mic_boost = { |
2094 | .num_items = 5, | 2263 | .num_items = 5, |
2095 | .items = { | 2264 | .items = { |
@@ -2101,6 +2270,23 @@ static const struct hda_input_mux cxt5066_analog_mic_boost = { | |||
2101 | }, | 2270 | }, |
2102 | }; | 2271 | }; |
2103 | 2272 | ||
2273 | static void cxt5066_set_mic_boost(struct hda_codec *codec) | ||
2274 | { | ||
2275 | struct conexant_spec *spec = codec->spec; | ||
2276 | snd_hda_codec_write_cache(codec, 0x17, 0, | ||
2277 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
2278 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | | ||
2279 | cxt5066_analog_mic_boost.items[spec->mic_boost].index); | ||
2280 | if (spec->ideapad) { | ||
2281 | /* adjust the internal mic as well...it is not through 0x17 */ | ||
2282 | snd_hda_codec_write_cache(codec, 0x23, 0, | ||
2283 | AC_VERB_SET_AMP_GAIN_MUTE, | ||
2284 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_INPUT | | ||
2285 | cxt5066_analog_mic_boost. | ||
2286 | items[spec->mic_boost].index); | ||
2287 | } | ||
2288 | } | ||
2289 | |||
2104 | static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, | 2290 | static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, |
2105 | struct snd_ctl_elem_info *uinfo) | 2291 | struct snd_ctl_elem_info *uinfo) |
2106 | { | 2292 | { |
@@ -2111,15 +2297,8 @@ static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol, | |||
2111 | struct snd_ctl_elem_value *ucontrol) | 2297 | struct snd_ctl_elem_value *ucontrol) |
2112 | { | 2298 | { |
2113 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2299 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
2114 | int val; | 2300 | struct conexant_spec *spec = codec->spec; |
2115 | hda_nid_t nid = kcontrol->private_value & 0xff; | 2301 | ucontrol->value.enumerated.item[0] = spec->mic_boost; |
2116 | int inout = (kcontrol->private_value & 0x100) ? | ||
2117 | AC_AMP_GET_INPUT : AC_AMP_GET_OUTPUT; | ||
2118 | |||
2119 | val = snd_hda_codec_read(codec, nid, 0, | ||
2120 | AC_VERB_GET_AMP_GAIN_MUTE, inout); | ||
2121 | |||
2122 | ucontrol->value.enumerated.item[0] = val & AC_AMP_GAIN; | ||
2123 | return 0; | 2302 | return 0; |
2124 | } | 2303 | } |
2125 | 2304 | ||
@@ -2127,26 +2306,132 @@ static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
2127 | struct snd_ctl_elem_value *ucontrol) | 2306 | struct snd_ctl_elem_value *ucontrol) |
2128 | { | 2307 | { |
2129 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2308 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
2309 | struct conexant_spec *spec = codec->spec; | ||
2130 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; | 2310 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; |
2131 | unsigned int idx; | 2311 | unsigned int idx; |
2132 | hda_nid_t nid = kcontrol->private_value & 0xff; | 2312 | idx = ucontrol->value.enumerated.item[0]; |
2133 | int inout = (kcontrol->private_value & 0x100) ? | 2313 | if (idx >= imux->num_items) |
2134 | AC_AMP_SET_INPUT : AC_AMP_SET_OUTPUT; | 2314 | idx = imux->num_items - 1; |
2315 | |||
2316 | spec->mic_boost = idx; | ||
2317 | if (!spec->dc_enable) | ||
2318 | cxt5066_set_mic_boost(codec); | ||
2319 | return 1; | ||
2320 | } | ||
2321 | |||
2322 | static void cxt5066_enable_dc(struct hda_codec *codec) | ||
2323 | { | ||
2324 | const struct hda_verb enable_dc_mode[] = { | ||
2325 | /* disable gain */ | ||
2326 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
2327 | |||
2328 | /* switch to DC input */ | ||
2329 | {0x17, AC_VERB_SET_CONNECT_SEL, 3}, | ||
2330 | {} | ||
2331 | }; | ||
2332 | |||
2333 | /* configure as input source */ | ||
2334 | snd_hda_sequence_write(codec, enable_dc_mode); | ||
2335 | cxt5066_olpc_select_mic(codec); /* also sets configured bias */ | ||
2336 | } | ||
2337 | |||
2338 | static void cxt5066_disable_dc(struct hda_codec *codec) | ||
2339 | { | ||
2340 | /* reconfigure input source */ | ||
2341 | cxt5066_set_mic_boost(codec); | ||
2342 | /* automic also selects the right mic if we're recording */ | ||
2343 | cxt5066_olpc_automic(codec); | ||
2344 | } | ||
2345 | |||
2346 | static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, | ||
2347 | struct snd_ctl_elem_value *ucontrol) | ||
2348 | { | ||
2349 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2350 | struct conexant_spec *spec = codec->spec; | ||
2351 | ucontrol->value.integer.value[0] = spec->dc_enable; | ||
2352 | return 0; | ||
2353 | } | ||
2135 | 2354 | ||
2136 | if (!imux->num_items) | 2355 | static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, |
2356 | struct snd_ctl_elem_value *ucontrol) | ||
2357 | { | ||
2358 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2359 | struct conexant_spec *spec = codec->spec; | ||
2360 | int dc_enable = !!ucontrol->value.integer.value[0]; | ||
2361 | |||
2362 | if (dc_enable == spec->dc_enable) | ||
2137 | return 0; | 2363 | return 0; |
2364 | |||
2365 | spec->dc_enable = dc_enable; | ||
2366 | if (dc_enable) | ||
2367 | cxt5066_enable_dc(codec); | ||
2368 | else | ||
2369 | cxt5066_disable_dc(codec); | ||
2370 | |||
2371 | return 1; | ||
2372 | } | ||
2373 | |||
2374 | static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, | ||
2375 | struct snd_ctl_elem_info *uinfo) | ||
2376 | { | ||
2377 | return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); | ||
2378 | } | ||
2379 | |||
2380 | static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, | ||
2381 | struct snd_ctl_elem_value *ucontrol) | ||
2382 | { | ||
2383 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2384 | struct conexant_spec *spec = codec->spec; | ||
2385 | ucontrol->value.enumerated.item[0] = spec->dc_input_bias; | ||
2386 | return 0; | ||
2387 | } | ||
2388 | |||
2389 | static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, | ||
2390 | struct snd_ctl_elem_value *ucontrol) | ||
2391 | { | ||
2392 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2393 | struct conexant_spec *spec = codec->spec; | ||
2394 | const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; | ||
2395 | unsigned int idx; | ||
2396 | |||
2138 | idx = ucontrol->value.enumerated.item[0]; | 2397 | idx = ucontrol->value.enumerated.item[0]; |
2139 | if (idx >= imux->num_items) | 2398 | if (idx >= imux->num_items) |
2140 | idx = imux->num_items - 1; | 2399 | idx = imux->num_items - 1; |
2141 | 2400 | ||
2142 | snd_hda_codec_write_cache(codec, nid, 0, | 2401 | spec->dc_input_bias = idx; |
2143 | AC_VERB_SET_AMP_GAIN_MUTE, | 2402 | if (spec->dc_enable) |
2144 | AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | inout | | 2403 | cxt5066_set_olpc_dc_bias(codec); |
2145 | imux->items[idx].index); | ||
2146 | |||
2147 | return 1; | 2404 | return 1; |
2148 | } | 2405 | } |
2149 | 2406 | ||
2407 | static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) | ||
2408 | { | ||
2409 | struct conexant_spec *spec = codec->spec; | ||
2410 | /* mark as recording and configure the microphone widget so that the | ||
2411 | * recording LED comes on. */ | ||
2412 | spec->recording = 1; | ||
2413 | cxt5066_olpc_select_mic(codec); | ||
2414 | } | ||
2415 | |||
2416 | static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) | ||
2417 | { | ||
2418 | struct conexant_spec *spec = codec->spec; | ||
2419 | const struct hda_verb disable_mics[] = { | ||
2420 | /* disable external mic, port B */ | ||
2421 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2422 | |||
2423 | /* disble internal mic, port C */ | ||
2424 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2425 | |||
2426 | /* disable DC capture, port F */ | ||
2427 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
2428 | {}, | ||
2429 | }; | ||
2430 | |||
2431 | snd_hda_sequence_write(codec, disable_mics); | ||
2432 | spec->recording = 0; | ||
2433 | } | ||
2434 | |||
2150 | static struct hda_input_mux cxt5066_capture_source = { | 2435 | static struct hda_input_mux cxt5066_capture_source = { |
2151 | .num_items = 4, | 2436 | .num_items = 4, |
2152 | .items = { | 2437 | .items = { |
@@ -2187,6 +2472,7 @@ static struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { | |||
2187 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | 2472 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | |
2188 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | | 2473 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
2189 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, | 2474 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, |
2475 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
2190 | .info = snd_hda_mixer_amp_volume_info, | 2476 | .info = snd_hda_mixer_amp_volume_info, |
2191 | .get = snd_hda_mixer_amp_volume_get, | 2477 | .get = snd_hda_mixer_amp_volume_get, |
2192 | .put = snd_hda_mixer_amp_volume_put, | 2478 | .put = snd_hda_mixer_amp_volume_put, |
@@ -2198,6 +2484,24 @@ static struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = { | |||
2198 | {} | 2484 | {} |
2199 | }; | 2485 | }; |
2200 | 2486 | ||
2487 | static struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { | ||
2488 | { | ||
2489 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2490 | .name = "DC Mode Enable Switch", | ||
2491 | .info = snd_ctl_boolean_mono_info, | ||
2492 | .get = cxt5066_olpc_dc_get, | ||
2493 | .put = cxt5066_olpc_dc_put, | ||
2494 | }, | ||
2495 | { | ||
2496 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2497 | .name = "DC Input Bias Enum", | ||
2498 | .info = cxt5066_olpc_dc_bias_enum_info, | ||
2499 | .get = cxt5066_olpc_dc_bias_enum_get, | ||
2500 | .put = cxt5066_olpc_dc_bias_enum_put, | ||
2501 | }, | ||
2502 | {} | ||
2503 | }; | ||
2504 | |||
2201 | static struct snd_kcontrol_new cxt5066_mixers[] = { | 2505 | static struct snd_kcontrol_new cxt5066_mixers[] = { |
2202 | { | 2506 | { |
2203 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2507 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
@@ -2210,11 +2514,10 @@ static struct snd_kcontrol_new cxt5066_mixers[] = { | |||
2210 | 2514 | ||
2211 | { | 2515 | { |
2212 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2516 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2213 | .name = "Ext Mic Boost Capture Enum", | 2517 | .name = "Analog Mic Boost Capture Enum", |
2214 | .info = cxt5066_mic_boost_mux_enum_info, | 2518 | .info = cxt5066_mic_boost_mux_enum_info, |
2215 | .get = cxt5066_mic_boost_mux_enum_get, | 2519 | .get = cxt5066_mic_boost_mux_enum_get, |
2216 | .put = cxt5066_mic_boost_mux_enum_put, | 2520 | .put = cxt5066_mic_boost_mux_enum_put, |
2217 | .private_value = 0x17, | ||
2218 | }, | 2521 | }, |
2219 | 2522 | ||
2220 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), | 2523 | HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), |
@@ -2296,10 +2599,10 @@ static struct hda_verb cxt5066_init_verbs_olpc[] = { | |||
2296 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | 2599 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ |
2297 | 2600 | ||
2298 | /* Port B: external microphone */ | 2601 | /* Port B: external microphone */ |
2299 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, CXT5066_OLPC_EXT_MIC_BIAS}, | 2602 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
2300 | 2603 | ||
2301 | /* Port C: internal microphone */ | 2604 | /* Port C: internal microphone */ |
2302 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | 2605 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
2303 | 2606 | ||
2304 | /* Port D: unused */ | 2607 | /* Port D: unused */ |
2305 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | 2608 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
@@ -2308,7 +2611,7 @@ static struct hda_verb cxt5066_init_verbs_olpc[] = { | |||
2308 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | 2611 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
2309 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | 2612 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ |
2310 | 2613 | ||
2311 | /* Port F: unused */ | 2614 | /* Port F: external DC input through microphone port */ |
2312 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | 2615 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, |
2313 | 2616 | ||
2314 | /* Port G: internal speakers */ | 2617 | /* Port G: internal speakers */ |
@@ -2412,6 +2715,56 @@ static struct hda_verb cxt5066_init_verbs_vostro[] = { | |||
2412 | { } /* end */ | 2715 | { } /* end */ |
2413 | }; | 2716 | }; |
2414 | 2717 | ||
2718 | static struct hda_verb cxt5066_init_verbs_ideapad[] = { | ||
2719 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */ | ||
2720 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */ | ||
2721 | {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port F */ | ||
2722 | {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Port E */ | ||
2723 | |||
2724 | /* Speakers */ | ||
2725 | {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2726 | {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2727 | |||
2728 | /* HP, Amp */ | ||
2729 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
2730 | {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2731 | |||
2732 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
2733 | {0x1c, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ | ||
2734 | |||
2735 | /* DAC1 */ | ||
2736 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
2737 | |||
2738 | /* Node 14 connections: 0x17 0x18 0x23 0x24 0x27 */ | ||
2739 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50}, | ||
2740 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
2741 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2) | 0x50}, | ||
2742 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
2743 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
2744 | {0x14, AC_VERB_SET_CONNECT_SEL, 2}, /* default to internal mic */ | ||
2745 | |||
2746 | /* Audio input selector */ | ||
2747 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x2}, | ||
2748 | {0x17, AC_VERB_SET_CONNECT_SEL, 1}, /* route ext mic */ | ||
2749 | |||
2750 | /* SPDIF route: PCM */ | ||
2751 | {0x20, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
2752 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x0}, | ||
2753 | |||
2754 | {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2755 | {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
2756 | |||
2757 | /* internal microphone */ | ||
2758 | {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* enable int mic */ | ||
2759 | |||
2760 | /* EAPD */ | ||
2761 | {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ | ||
2762 | |||
2763 | {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, | ||
2764 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, | ||
2765 | { } /* end */ | ||
2766 | }; | ||
2767 | |||
2415 | static struct hda_verb cxt5066_init_verbs_portd_lo[] = { | 2768 | static struct hda_verb cxt5066_init_verbs_portd_lo[] = { |
2416 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | 2769 | {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
2417 | { } /* end */ | 2770 | { } /* end */ |
@@ -2428,8 +2781,24 @@ static int cxt5066_init(struct hda_codec *codec) | |||
2428 | cxt5066_hp_automute(codec); | 2781 | cxt5066_hp_automute(codec); |
2429 | if (spec->dell_vostro) | 2782 | if (spec->dell_vostro) |
2430 | cxt5066_vostro_automic(codec); | 2783 | cxt5066_vostro_automic(codec); |
2431 | else | 2784 | else if (spec->ideapad) |
2432 | cxt5066_automic(codec); | 2785 | cxt5066_ideapad_automic(codec); |
2786 | } | ||
2787 | cxt5066_set_mic_boost(codec); | ||
2788 | return 0; | ||
2789 | } | ||
2790 | |||
2791 | static int cxt5066_olpc_init(struct hda_codec *codec) | ||
2792 | { | ||
2793 | struct conexant_spec *spec = codec->spec; | ||
2794 | snd_printdd("CXT5066: init\n"); | ||
2795 | conexant_init(codec); | ||
2796 | cxt5066_hp_automute(codec); | ||
2797 | if (!spec->dc_enable) { | ||
2798 | cxt5066_set_mic_boost(codec); | ||
2799 | cxt5066_olpc_automic(codec); | ||
2800 | } else { | ||
2801 | cxt5066_enable_dc(codec); | ||
2433 | } | 2802 | } |
2434 | return 0; | 2803 | return 0; |
2435 | } | 2804 | } |
@@ -2439,6 +2808,7 @@ enum { | |||
2439 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ | 2808 | CXT5066_DELL_LAPTOP, /* Dell Laptop */ |
2440 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ | 2809 | CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ |
2441 | CXT5066_DELL_VOSTO, /* Dell Vostro 1015i */ | 2810 | CXT5066_DELL_VOSTO, /* Dell Vostro 1015i */ |
2811 | CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ | ||
2442 | CXT5066_MODELS | 2812 | CXT5066_MODELS |
2443 | }; | 2813 | }; |
2444 | 2814 | ||
@@ -2446,7 +2816,8 @@ static const char *cxt5066_models[CXT5066_MODELS] = { | |||
2446 | [CXT5066_LAPTOP] = "laptop", | 2816 | [CXT5066_LAPTOP] = "laptop", |
2447 | [CXT5066_DELL_LAPTOP] = "dell-laptop", | 2817 | [CXT5066_DELL_LAPTOP] = "dell-laptop", |
2448 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", | 2818 | [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", |
2449 | [CXT5066_DELL_VOSTO] = "dell-vostro" | 2819 | [CXT5066_DELL_VOSTO] = "dell-vostro", |
2820 | [CXT5066_IDEAPAD] = "ideapad", | ||
2450 | }; | 2821 | }; |
2451 | 2822 | ||
2452 | static struct snd_pci_quirk cxt5066_cfg_tbl[] = { | 2823 | static struct snd_pci_quirk cxt5066_cfg_tbl[] = { |
@@ -2456,6 +2827,7 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = { | |||
2456 | CXT5066_DELL_LAPTOP), | 2827 | CXT5066_DELL_LAPTOP), |
2457 | SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), | 2828 | SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), |
2458 | SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO), | 2829 | SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO), |
2830 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "ideapad", CXT5066_IDEAPAD), | ||
2459 | {} | 2831 | {} |
2460 | }; | 2832 | }; |
2461 | 2833 | ||
@@ -2470,7 +2842,7 @@ static int patch_cxt5066(struct hda_codec *codec) | |||
2470 | codec->spec = spec; | 2842 | codec->spec = spec; |
2471 | 2843 | ||
2472 | codec->patch_ops = conexant_patch_ops; | 2844 | codec->patch_ops = conexant_patch_ops; |
2473 | codec->patch_ops.init = cxt5066_init; | 2845 | codec->patch_ops.init = conexant_init; |
2474 | 2846 | ||
2475 | spec->dell_automute = 0; | 2847 | spec->dell_automute = 0; |
2476 | spec->multiout.max_channels = 2; | 2848 | spec->multiout.max_channels = 2; |
@@ -2483,7 +2855,6 @@ static int patch_cxt5066(struct hda_codec *codec) | |||
2483 | spec->input_mux = &cxt5066_capture_source; | 2855 | spec->input_mux = &cxt5066_capture_source; |
2484 | 2856 | ||
2485 | spec->port_d_mode = PIN_HP; | 2857 | spec->port_d_mode = PIN_HP; |
2486 | spec->ext_mic_bias = PIN_VREF80; | ||
2487 | 2858 | ||
2488 | spec->num_init_verbs = 1; | 2859 | spec->num_init_verbs = 1; |
2489 | spec->init_verbs[0] = cxt5066_init_verbs; | 2860 | spec->init_verbs[0] = cxt5066_init_verbs; |
@@ -2510,20 +2881,28 @@ static int patch_cxt5066(struct hda_codec *codec) | |||
2510 | spec->dell_automute = 1; | 2881 | spec->dell_automute = 1; |
2511 | break; | 2882 | break; |
2512 | case CXT5066_OLPC_XO_1_5: | 2883 | case CXT5066_OLPC_XO_1_5: |
2513 | codec->patch_ops.unsol_event = cxt5066_unsol_event; | 2884 | codec->patch_ops.init = cxt5066_olpc_init; |
2885 | codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; | ||
2514 | spec->init_verbs[0] = cxt5066_init_verbs_olpc; | 2886 | spec->init_verbs[0] = cxt5066_init_verbs_olpc; |
2515 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | 2887 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; |
2888 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; | ||
2516 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | 2889 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; |
2517 | spec->port_d_mode = 0; | 2890 | spec->port_d_mode = 0; |
2518 | spec->ext_mic_bias = CXT5066_OLPC_EXT_MIC_BIAS; | 2891 | spec->mic_boost = 3; /* default 30dB gain */ |
2519 | 2892 | ||
2520 | /* no S/PDIF out */ | 2893 | /* no S/PDIF out */ |
2521 | spec->multiout.dig_out_nid = 0; | 2894 | spec->multiout.dig_out_nid = 0; |
2522 | 2895 | ||
2523 | /* input source automatically selected */ | 2896 | /* input source automatically selected */ |
2524 | spec->input_mux = NULL; | 2897 | spec->input_mux = NULL; |
2898 | |||
2899 | /* our capture hooks which allow us to turn on the microphone LED | ||
2900 | * at the right time */ | ||
2901 | spec->capture_prepare = cxt5066_olpc_capture_prepare; | ||
2902 | spec->capture_cleanup = cxt5066_olpc_capture_cleanup; | ||
2525 | break; | 2903 | break; |
2526 | case CXT5066_DELL_VOSTO: | 2904 | case CXT5066_DELL_VOSTO: |
2905 | codec->patch_ops.init = cxt5066_init; | ||
2527 | codec->patch_ops.unsol_event = cxt5066_vostro_event; | 2906 | codec->patch_ops.unsol_event = cxt5066_vostro_event; |
2528 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; | 2907 | spec->init_verbs[0] = cxt5066_init_verbs_vostro; |
2529 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; | 2908 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; |
@@ -2531,6 +2910,7 @@ static int patch_cxt5066(struct hda_codec *codec) | |||
2531 | spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; | 2910 | spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; |
2532 | spec->port_d_mode = 0; | 2911 | spec->port_d_mode = 0; |
2533 | spec->dell_vostro = 1; | 2912 | spec->dell_vostro = 1; |
2913 | spec->mic_boost = 3; /* default 30dB gain */ | ||
2534 | snd_hda_attach_beep_device(codec, 0x13); | 2914 | snd_hda_attach_beep_device(codec, 0x13); |
2535 | 2915 | ||
2536 | /* no S/PDIF out */ | 2916 | /* no S/PDIF out */ |
@@ -2539,6 +2919,22 @@ static int patch_cxt5066(struct hda_codec *codec) | |||
2539 | /* input source automatically selected */ | 2919 | /* input source automatically selected */ |
2540 | spec->input_mux = NULL; | 2920 | spec->input_mux = NULL; |
2541 | break; | 2921 | break; |
2922 | case CXT5066_IDEAPAD: | ||
2923 | codec->patch_ops.init = cxt5066_init; | ||
2924 | codec->patch_ops.unsol_event = cxt5066_ideapad_event; | ||
2925 | spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; | ||
2926 | spec->mixers[spec->num_mixers++] = cxt5066_mixers; | ||
2927 | spec->init_verbs[0] = cxt5066_init_verbs_ideapad; | ||
2928 | spec->port_d_mode = 0; | ||
2929 | spec->ideapad = 1; | ||
2930 | spec->mic_boost = 2; /* default 20dB gain */ | ||
2931 | |||
2932 | /* no S/PDIF out */ | ||
2933 | spec->multiout.dig_out_nid = 0; | ||
2934 | |||
2935 | /* input source automatically selected */ | ||
2936 | spec->input_mux = NULL; | ||
2937 | break; | ||
2542 | } | 2938 | } |
2543 | 2939 | ||
2544 | return 0; | 2940 | return 0; |
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c new file mode 100644 index 000000000000..2c2bafbf0258 --- /dev/null +++ b/sound/pci/hda/patch_hdmi.c | |||
@@ -0,0 +1,849 @@ | |||
1 | /* | ||
2 | * | ||
3 | * patch_hdmi.c - routines for HDMI/DisplayPort codecs | ||
4 | * | ||
5 | * Copyright(c) 2008-2010 Intel Corporation. All rights reserved. | ||
6 | * | ||
7 | * Authors: | ||
8 | * Wu Fengguang <wfg@linux.intel.com> | ||
9 | * | ||
10 | * Maintained by: | ||
11 | * Wu Fengguang <wfg@linux.intel.com> | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify it | ||
14 | * under the terms of the GNU General Public License as published by the Free | ||
15 | * Software Foundation; either version 2 of the License, or (at your option) | ||
16 | * any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, but | ||
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
20 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
21 | * for more details. | ||
22 | * | ||
23 | * You should have received a copy of the GNU General Public License | ||
24 | * along with this program; if not, write to the Free Software Foundation, | ||
25 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
26 | */ | ||
27 | |||
28 | |||
29 | struct hdmi_spec { | ||
30 | int num_cvts; | ||
31 | int num_pins; | ||
32 | hda_nid_t cvt[MAX_HDMI_CVTS+1]; /* audio sources */ | ||
33 | hda_nid_t pin[MAX_HDMI_PINS+1]; /* audio sinks */ | ||
34 | |||
35 | /* | ||
36 | * source connection for each pin | ||
37 | */ | ||
38 | hda_nid_t pin_cvt[MAX_HDMI_PINS+1]; | ||
39 | |||
40 | /* | ||
41 | * HDMI sink attached to each pin | ||
42 | */ | ||
43 | struct hdmi_eld sink_eld[MAX_HDMI_PINS]; | ||
44 | |||
45 | /* | ||
46 | * export one pcm per pipe | ||
47 | */ | ||
48 | struct hda_pcm pcm_rec[MAX_HDMI_CVTS]; | ||
49 | |||
50 | /* | ||
51 | * nvhdmi specific | ||
52 | */ | ||
53 | struct hda_multi_out multiout; | ||
54 | unsigned int codec_type; | ||
55 | }; | ||
56 | |||
57 | |||
58 | struct hdmi_audio_infoframe { | ||
59 | u8 type; /* 0x84 */ | ||
60 | u8 ver; /* 0x01 */ | ||
61 | u8 len; /* 0x0a */ | ||
62 | |||
63 | u8 checksum; /* PB0 */ | ||
64 | u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */ | ||
65 | u8 SS01_SF24; | ||
66 | u8 CXT04; | ||
67 | u8 CA; | ||
68 | u8 LFEPBL01_LSV36_DM_INH7; | ||
69 | u8 reserved[5]; /* PB6 - PB10 */ | ||
70 | }; | ||
71 | |||
72 | /* | ||
73 | * CEA speaker placement: | ||
74 | * | ||
75 | * FLH FCH FRH | ||
76 | * FLW FL FLC FC FRC FR FRW | ||
77 | * | ||
78 | * LFE | ||
79 | * TC | ||
80 | * | ||
81 | * RL RLC RC RRC RR | ||
82 | * | ||
83 | * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to | ||
84 | * CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC. | ||
85 | */ | ||
86 | enum cea_speaker_placement { | ||
87 | FL = (1 << 0), /* Front Left */ | ||
88 | FC = (1 << 1), /* Front Center */ | ||
89 | FR = (1 << 2), /* Front Right */ | ||
90 | FLC = (1 << 3), /* Front Left Center */ | ||
91 | FRC = (1 << 4), /* Front Right Center */ | ||
92 | RL = (1 << 5), /* Rear Left */ | ||
93 | RC = (1 << 6), /* Rear Center */ | ||
94 | RR = (1 << 7), /* Rear Right */ | ||
95 | RLC = (1 << 8), /* Rear Left Center */ | ||
96 | RRC = (1 << 9), /* Rear Right Center */ | ||
97 | LFE = (1 << 10), /* Low Frequency Effect */ | ||
98 | FLW = (1 << 11), /* Front Left Wide */ | ||
99 | FRW = (1 << 12), /* Front Right Wide */ | ||
100 | FLH = (1 << 13), /* Front Left High */ | ||
101 | FCH = (1 << 14), /* Front Center High */ | ||
102 | FRH = (1 << 15), /* Front Right High */ | ||
103 | TC = (1 << 16), /* Top Center */ | ||
104 | }; | ||
105 | |||
106 | /* | ||
107 | * ELD SA bits in the CEA Speaker Allocation data block | ||
108 | */ | ||
109 | static int eld_speaker_allocation_bits[] = { | ||
110 | [0] = FL | FR, | ||
111 | [1] = LFE, | ||
112 | [2] = FC, | ||
113 | [3] = RL | RR, | ||
114 | [4] = RC, | ||
115 | [5] = FLC | FRC, | ||
116 | [6] = RLC | RRC, | ||
117 | /* the following are not defined in ELD yet */ | ||
118 | [7] = FLW | FRW, | ||
119 | [8] = FLH | FRH, | ||
120 | [9] = TC, | ||
121 | [10] = FCH, | ||
122 | }; | ||
123 | |||
124 | struct cea_channel_speaker_allocation { | ||
125 | int ca_index; | ||
126 | int speakers[8]; | ||
127 | |||
128 | /* derived values, just for convenience */ | ||
129 | int channels; | ||
130 | int spk_mask; | ||
131 | }; | ||
132 | |||
133 | /* | ||
134 | * ALSA sequence is: | ||
135 | * | ||
136 | * surround40 surround41 surround50 surround51 surround71 | ||
137 | * ch0 front left = = = = | ||
138 | * ch1 front right = = = = | ||
139 | * ch2 rear left = = = = | ||
140 | * ch3 rear right = = = = | ||
141 | * ch4 LFE center center center | ||
142 | * ch5 LFE LFE | ||
143 | * ch6 side left | ||
144 | * ch7 side right | ||
145 | * | ||
146 | * surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR} | ||
147 | */ | ||
148 | static int hdmi_channel_mapping[0x32][8] = { | ||
149 | /* stereo */ | ||
150 | [0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, | ||
151 | /* 2.1 */ | ||
152 | [0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, | ||
153 | /* Dolby Surround */ | ||
154 | [0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 }, | ||
155 | /* surround40 */ | ||
156 | [0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 }, | ||
157 | /* 4ch */ | ||
158 | [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 }, | ||
159 | /* surround41 */ | ||
160 | [0x09] = { 0x00, 0x11, 0x24, 0x34, 0x43, 0xf2, 0xf6, 0xf7 }, | ||
161 | /* surround50 */ | ||
162 | [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 }, | ||
163 | /* surround51 */ | ||
164 | [0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 }, | ||
165 | /* 7.1 */ | ||
166 | [0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 }, | ||
167 | }; | ||
168 | |||
169 | /* | ||
170 | * This is an ordered list! | ||
171 | * | ||
172 | * The preceding ones have better chances to be selected by | ||
173 | * hdmi_setup_channel_allocation(). | ||
174 | */ | ||
175 | static struct cea_channel_speaker_allocation channel_allocations[] = { | ||
176 | /* channel: 7 6 5 4 3 2 1 0 */ | ||
177 | { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } }, | ||
178 | /* 2.1 */ | ||
179 | { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } }, | ||
180 | /* Dolby Surround */ | ||
181 | { .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } }, | ||
182 | /* surround40 */ | ||
183 | { .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } }, | ||
184 | /* surround41 */ | ||
185 | { .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } }, | ||
186 | /* surround50 */ | ||
187 | { .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } }, | ||
188 | /* surround51 */ | ||
189 | { .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } }, | ||
190 | /* 6.1 */ | ||
191 | { .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } }, | ||
192 | /* surround71 */ | ||
193 | { .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } }, | ||
194 | |||
195 | { .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } }, | ||
196 | { .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } }, | ||
197 | { .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } }, | ||
198 | { .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } }, | ||
199 | { .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } }, | ||
200 | { .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } }, | ||
201 | { .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } }, | ||
202 | { .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } }, | ||
203 | { .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } }, | ||
204 | { .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } }, | ||
205 | { .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } }, | ||
206 | { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } }, | ||
207 | { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } }, | ||
208 | { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } }, | ||
209 | { .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } }, | ||
210 | { .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } }, | ||
211 | { .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } }, | ||
212 | { .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } }, | ||
213 | { .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } }, | ||
214 | { .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } }, | ||
215 | { .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } }, | ||
216 | { .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } }, | ||
217 | { .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } }, | ||
218 | { .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } }, | ||
219 | { .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } }, | ||
220 | { .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } }, | ||
221 | { .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } }, | ||
222 | { .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } }, | ||
223 | { .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } }, | ||
224 | { .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } }, | ||
225 | { .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } }, | ||
226 | { .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } }, | ||
227 | { .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } }, | ||
228 | { .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } }, | ||
229 | { .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } }, | ||
230 | { .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } }, | ||
231 | { .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } }, | ||
232 | { .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } }, | ||
233 | { .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } }, | ||
234 | { .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } }, | ||
235 | { .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } }, | ||
236 | }; | ||
237 | |||
238 | |||
239 | /* | ||
240 | * HDMI routines | ||
241 | */ | ||
242 | |||
243 | static int hda_node_index(hda_nid_t *nids, hda_nid_t nid) | ||
244 | { | ||
245 | int i; | ||
246 | |||
247 | for (i = 0; nids[i]; i++) | ||
248 | if (nids[i] == nid) | ||
249 | return i; | ||
250 | |||
251 | snd_printk(KERN_WARNING "HDMI: nid %d not registered\n", nid); | ||
252 | return -EINVAL; | ||
253 | } | ||
254 | |||
255 | static void hdmi_get_show_eld(struct hda_codec *codec, hda_nid_t pin_nid, | ||
256 | struct hdmi_eld *eld) | ||
257 | { | ||
258 | if (!snd_hdmi_get_eld(eld, codec, pin_nid)) | ||
259 | snd_hdmi_show_eld(eld); | ||
260 | } | ||
261 | |||
262 | #ifdef BE_PARANOID | ||
263 | static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, | ||
264 | int *packet_index, int *byte_index) | ||
265 | { | ||
266 | int val; | ||
267 | |||
268 | val = snd_hda_codec_read(codec, pin_nid, 0, | ||
269 | AC_VERB_GET_HDMI_DIP_INDEX, 0); | ||
270 | |||
271 | *packet_index = val >> 5; | ||
272 | *byte_index = val & 0x1f; | ||
273 | } | ||
274 | #endif | ||
275 | |||
276 | static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, | ||
277 | int packet_index, int byte_index) | ||
278 | { | ||
279 | int val; | ||
280 | |||
281 | val = (packet_index << 5) | (byte_index & 0x1f); | ||
282 | |||
283 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); | ||
284 | } | ||
285 | |||
286 | static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, | ||
287 | unsigned char val) | ||
288 | { | ||
289 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); | ||
290 | } | ||
291 | |||
292 | static void hdmi_enable_output(struct hda_codec *codec, hda_nid_t pin_nid) | ||
293 | { | ||
294 | /* Unmute */ | ||
295 | if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) | ||
296 | snd_hda_codec_write(codec, pin_nid, 0, | ||
297 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | ||
298 | /* Enable pin out */ | ||
299 | snd_hda_codec_write(codec, pin_nid, 0, | ||
300 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
301 | } | ||
302 | |||
303 | static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t nid) | ||
304 | { | ||
305 | return 1 + snd_hda_codec_read(codec, nid, 0, | ||
306 | AC_VERB_GET_CVT_CHAN_COUNT, 0); | ||
307 | } | ||
308 | |||
309 | static void hdmi_set_channel_count(struct hda_codec *codec, | ||
310 | hda_nid_t nid, int chs) | ||
311 | { | ||
312 | if (chs != hdmi_get_channel_count(codec, nid)) | ||
313 | snd_hda_codec_write(codec, nid, 0, | ||
314 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); | ||
315 | } | ||
316 | |||
317 | |||
318 | /* | ||
319 | * Channel mapping routines | ||
320 | */ | ||
321 | |||
322 | /* | ||
323 | * Compute derived values in channel_allocations[]. | ||
324 | */ | ||
325 | static void init_channel_allocations(void) | ||
326 | { | ||
327 | int i, j; | ||
328 | struct cea_channel_speaker_allocation *p; | ||
329 | |||
330 | for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { | ||
331 | p = channel_allocations + i; | ||
332 | p->channels = 0; | ||
333 | p->spk_mask = 0; | ||
334 | for (j = 0; j < ARRAY_SIZE(p->speakers); j++) | ||
335 | if (p->speakers[j]) { | ||
336 | p->channels++; | ||
337 | p->spk_mask |= p->speakers[j]; | ||
338 | } | ||
339 | } | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * The transformation takes two steps: | ||
344 | * | ||
345 | * eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask | ||
346 | * spk_mask => (channel_allocations[]) => ai->CA | ||
347 | * | ||
348 | * TODO: it could select the wrong CA from multiple candidates. | ||
349 | */ | ||
350 | static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid, | ||
351 | struct hdmi_audio_infoframe *ai) | ||
352 | { | ||
353 | struct hdmi_spec *spec = codec->spec; | ||
354 | struct hdmi_eld *eld; | ||
355 | int i; | ||
356 | int spk_mask = 0; | ||
357 | int channels = 1 + (ai->CC02_CT47 & 0x7); | ||
358 | char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; | ||
359 | |||
360 | /* | ||
361 | * CA defaults to 0 for basic stereo audio | ||
362 | */ | ||
363 | if (channels <= 2) | ||
364 | return 0; | ||
365 | |||
366 | i = hda_node_index(spec->pin_cvt, nid); | ||
367 | if (i < 0) | ||
368 | return 0; | ||
369 | eld = &spec->sink_eld[i]; | ||
370 | |||
371 | /* | ||
372 | * HDMI sink's ELD info cannot always be retrieved for now, e.g. | ||
373 | * in console or for audio devices. Assume the highest speakers | ||
374 | * configuration, to _not_ prohibit multi-channel audio playback. | ||
375 | */ | ||
376 | if (!eld->spk_alloc) | ||
377 | eld->spk_alloc = 0xffff; | ||
378 | |||
379 | /* | ||
380 | * expand ELD's speaker allocation mask | ||
381 | * | ||
382 | * ELD tells the speaker mask in a compact(paired) form, | ||
383 | * expand ELD's notions to match the ones used by Audio InfoFrame. | ||
384 | */ | ||
385 | for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) { | ||
386 | if (eld->spk_alloc & (1 << i)) | ||
387 | spk_mask |= eld_speaker_allocation_bits[i]; | ||
388 | } | ||
389 | |||
390 | /* search for the first working match in the CA table */ | ||
391 | for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { | ||
392 | if (channels == channel_allocations[i].channels && | ||
393 | (spk_mask & channel_allocations[i].spk_mask) == | ||
394 | channel_allocations[i].spk_mask) { | ||
395 | ai->CA = channel_allocations[i].ca_index; | ||
396 | break; | ||
397 | } | ||
398 | } | ||
399 | |||
400 | snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf)); | ||
401 | snd_printdd("HDMI: select CA 0x%x for %d-channel allocation: %s\n", | ||
402 | ai->CA, channels, buf); | ||
403 | |||
404 | return ai->CA; | ||
405 | } | ||
406 | |||
407 | static void hdmi_debug_channel_mapping(struct hda_codec *codec, | ||
408 | hda_nid_t pin_nid) | ||
409 | { | ||
410 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
411 | int i; | ||
412 | int slot; | ||
413 | |||
414 | for (i = 0; i < 8; i++) { | ||
415 | slot = snd_hda_codec_read(codec, pin_nid, 0, | ||
416 | AC_VERB_GET_HDMI_CHAN_SLOT, i); | ||
417 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", | ||
418 | slot >> 4, slot & 0xf); | ||
419 | } | ||
420 | #endif | ||
421 | } | ||
422 | |||
423 | |||
424 | static void hdmi_setup_channel_mapping(struct hda_codec *codec, | ||
425 | hda_nid_t pin_nid, | ||
426 | struct hdmi_audio_infoframe *ai) | ||
427 | { | ||
428 | int i; | ||
429 | int ca = ai->CA; | ||
430 | int err; | ||
431 | |||
432 | if (hdmi_channel_mapping[ca][1] == 0) { | ||
433 | for (i = 0; i < channel_allocations[ca].channels; i++) | ||
434 | hdmi_channel_mapping[ca][i] = i | (i << 4); | ||
435 | for (; i < 8; i++) | ||
436 | hdmi_channel_mapping[ca][i] = 0xf | (i << 4); | ||
437 | } | ||
438 | |||
439 | for (i = 0; i < 8; i++) { | ||
440 | err = snd_hda_codec_write(codec, pin_nid, 0, | ||
441 | AC_VERB_SET_HDMI_CHAN_SLOT, | ||
442 | hdmi_channel_mapping[ca][i]); | ||
443 | if (err) { | ||
444 | snd_printdd(KERN_NOTICE | ||
445 | "HDMI: channel mapping failed\n"); | ||
446 | break; | ||
447 | } | ||
448 | } | ||
449 | |||
450 | hdmi_debug_channel_mapping(codec, pin_nid); | ||
451 | } | ||
452 | |||
453 | |||
454 | /* | ||
455 | * Audio InfoFrame routines | ||
456 | */ | ||
457 | |||
458 | /* | ||
459 | * Enable Audio InfoFrame Transmission | ||
460 | */ | ||
461 | static void hdmi_start_infoframe_trans(struct hda_codec *codec, | ||
462 | hda_nid_t pin_nid) | ||
463 | { | ||
464 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | ||
465 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, | ||
466 | AC_DIPXMIT_BEST); | ||
467 | } | ||
468 | |||
469 | /* | ||
470 | * Disable Audio InfoFrame Transmission | ||
471 | */ | ||
472 | static void hdmi_stop_infoframe_trans(struct hda_codec *codec, | ||
473 | hda_nid_t pin_nid) | ||
474 | { | ||
475 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | ||
476 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, | ||
477 | AC_DIPXMIT_DISABLE); | ||
478 | } | ||
479 | |||
480 | static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) | ||
481 | { | ||
482 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
483 | int i; | ||
484 | int size; | ||
485 | |||
486 | size = snd_hdmi_get_eld_size(codec, pin_nid); | ||
487 | printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size); | ||
488 | |||
489 | for (i = 0; i < 8; i++) { | ||
490 | size = snd_hda_codec_read(codec, pin_nid, 0, | ||
491 | AC_VERB_GET_HDMI_DIP_SIZE, i); | ||
492 | printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size); | ||
493 | } | ||
494 | #endif | ||
495 | } | ||
496 | |||
497 | static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) | ||
498 | { | ||
499 | #ifdef BE_PARANOID | ||
500 | int i, j; | ||
501 | int size; | ||
502 | int pi, bi; | ||
503 | for (i = 0; i < 8; i++) { | ||
504 | size = snd_hda_codec_read(codec, pin_nid, 0, | ||
505 | AC_VERB_GET_HDMI_DIP_SIZE, i); | ||
506 | if (size == 0) | ||
507 | continue; | ||
508 | |||
509 | hdmi_set_dip_index(codec, pin_nid, i, 0x0); | ||
510 | for (j = 1; j < 1000; j++) { | ||
511 | hdmi_write_dip_byte(codec, pin_nid, 0x0); | ||
512 | hdmi_get_dip_index(codec, pin_nid, &pi, &bi); | ||
513 | if (pi != i) | ||
514 | snd_printd(KERN_INFO "dip index %d: %d != %d\n", | ||
515 | bi, pi, i); | ||
516 | if (bi == 0) /* byte index wrapped around */ | ||
517 | break; | ||
518 | } | ||
519 | snd_printd(KERN_INFO | ||
520 | "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n", | ||
521 | i, size, j); | ||
522 | } | ||
523 | #endif | ||
524 | } | ||
525 | |||
526 | static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai) | ||
527 | { | ||
528 | u8 *bytes = (u8 *)ai; | ||
529 | u8 sum = 0; | ||
530 | int i; | ||
531 | |||
532 | ai->checksum = 0; | ||
533 | |||
534 | for (i = 0; i < sizeof(*ai); i++) | ||
535 | sum += bytes[i]; | ||
536 | |||
537 | ai->checksum = -sum; | ||
538 | } | ||
539 | |||
540 | static void hdmi_fill_audio_infoframe(struct hda_codec *codec, | ||
541 | hda_nid_t pin_nid, | ||
542 | struct hdmi_audio_infoframe *ai) | ||
543 | { | ||
544 | u8 *bytes = (u8 *)ai; | ||
545 | int i; | ||
546 | |||
547 | hdmi_debug_dip_size(codec, pin_nid); | ||
548 | hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ | ||
549 | |||
550 | hdmi_checksum_audio_infoframe(ai); | ||
551 | |||
552 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | ||
553 | for (i = 0; i < sizeof(*ai); i++) | ||
554 | hdmi_write_dip_byte(codec, pin_nid, bytes[i]); | ||
555 | } | ||
556 | |||
557 | static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, | ||
558 | struct hdmi_audio_infoframe *ai) | ||
559 | { | ||
560 | u8 *bytes = (u8 *)ai; | ||
561 | u8 val; | ||
562 | int i; | ||
563 | |||
564 | if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) | ||
565 | != AC_DIPXMIT_BEST) | ||
566 | return false; | ||
567 | |||
568 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | ||
569 | for (i = 0; i < sizeof(*ai); i++) { | ||
570 | val = snd_hda_codec_read(codec, pin_nid, 0, | ||
571 | AC_VERB_GET_HDMI_DIP_DATA, 0); | ||
572 | if (val != bytes[i]) | ||
573 | return false; | ||
574 | } | ||
575 | |||
576 | return true; | ||
577 | } | ||
578 | |||
579 | static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, | ||
580 | struct snd_pcm_substream *substream) | ||
581 | { | ||
582 | struct hdmi_spec *spec = codec->spec; | ||
583 | hda_nid_t pin_nid; | ||
584 | int i; | ||
585 | struct hdmi_audio_infoframe ai = { | ||
586 | .type = 0x84, | ||
587 | .ver = 0x01, | ||
588 | .len = 0x0a, | ||
589 | .CC02_CT47 = substream->runtime->channels - 1, | ||
590 | }; | ||
591 | |||
592 | hdmi_setup_channel_allocation(codec, nid, &ai); | ||
593 | |||
594 | for (i = 0; i < spec->num_pins; i++) { | ||
595 | if (spec->pin_cvt[i] != nid) | ||
596 | continue; | ||
597 | if (!spec->sink_eld[i].monitor_present) | ||
598 | continue; | ||
599 | |||
600 | pin_nid = spec->pin[i]; | ||
601 | if (!hdmi_infoframe_uptodate(codec, pin_nid, &ai)) { | ||
602 | snd_printdd("hdmi_setup_audio_infoframe: " | ||
603 | "cvt=%d pin=%d channels=%d\n", | ||
604 | nid, pin_nid, | ||
605 | substream->runtime->channels); | ||
606 | hdmi_setup_channel_mapping(codec, pin_nid, &ai); | ||
607 | hdmi_stop_infoframe_trans(codec, pin_nid); | ||
608 | hdmi_fill_audio_infoframe(codec, pin_nid, &ai); | ||
609 | hdmi_start_infoframe_trans(codec, pin_nid); | ||
610 | } | ||
611 | } | ||
612 | } | ||
613 | |||
614 | |||
615 | /* | ||
616 | * Unsolicited events | ||
617 | */ | ||
618 | |||
619 | static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) | ||
620 | { | ||
621 | struct hdmi_spec *spec = codec->spec; | ||
622 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; | ||
623 | int pind = !!(res & AC_UNSOL_RES_PD); | ||
624 | int eldv = !!(res & AC_UNSOL_RES_ELDV); | ||
625 | int index; | ||
626 | |||
627 | printk(KERN_INFO | ||
628 | "HDMI hot plug event: Pin=%d Presence_Detect=%d ELD_Valid=%d\n", | ||
629 | tag, pind, eldv); | ||
630 | |||
631 | index = hda_node_index(spec->pin, tag); | ||
632 | if (index < 0) | ||
633 | return; | ||
634 | |||
635 | spec->sink_eld[index].monitor_present = pind; | ||
636 | spec->sink_eld[index].eld_valid = eldv; | ||
637 | |||
638 | if (pind && eldv) { | ||
639 | hdmi_get_show_eld(codec, spec->pin[index], | ||
640 | &spec->sink_eld[index]); | ||
641 | /* TODO: do real things about ELD */ | ||
642 | } | ||
643 | } | ||
644 | |||
645 | static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) | ||
646 | { | ||
647 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; | ||
648 | int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; | ||
649 | int cp_state = !!(res & AC_UNSOL_RES_CP_STATE); | ||
650 | int cp_ready = !!(res & AC_UNSOL_RES_CP_READY); | ||
651 | |||
652 | printk(KERN_INFO | ||
653 | "HDMI CP event: PIN=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", | ||
654 | tag, | ||
655 | subtag, | ||
656 | cp_state, | ||
657 | cp_ready); | ||
658 | |||
659 | /* TODO */ | ||
660 | if (cp_state) | ||
661 | ; | ||
662 | if (cp_ready) | ||
663 | ; | ||
664 | } | ||
665 | |||
666 | |||
667 | static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) | ||
668 | { | ||
669 | struct hdmi_spec *spec = codec->spec; | ||
670 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; | ||
671 | int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; | ||
672 | |||
673 | if (hda_node_index(spec->pin, tag) < 0) { | ||
674 | snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag); | ||
675 | return; | ||
676 | } | ||
677 | |||
678 | if (subtag == 0) | ||
679 | hdmi_intrinsic_event(codec, res); | ||
680 | else | ||
681 | hdmi_non_intrinsic_event(codec, res); | ||
682 | } | ||
683 | |||
684 | /* | ||
685 | * Callbacks | ||
686 | */ | ||
687 | |||
688 | static void hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, | ||
689 | u32 stream_tag, int format) | ||
690 | { | ||
691 | int tag; | ||
692 | int fmt; | ||
693 | |||
694 | tag = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0) >> 4; | ||
695 | fmt = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_STREAM_FORMAT, 0); | ||
696 | |||
697 | snd_printdd("hdmi_setup_stream: " | ||
698 | "NID=0x%x, %sstream=0x%x, %sformat=0x%x\n", | ||
699 | nid, | ||
700 | tag == stream_tag ? "" : "new-", | ||
701 | stream_tag, | ||
702 | fmt == format ? "" : "new-", | ||
703 | format); | ||
704 | |||
705 | if (tag != stream_tag) | ||
706 | snd_hda_codec_write(codec, nid, 0, | ||
707 | AC_VERB_SET_CHANNEL_STREAMID, | ||
708 | stream_tag << 4); | ||
709 | if (fmt != format) | ||
710 | snd_hda_codec_write(codec, nid, 0, | ||
711 | AC_VERB_SET_STREAM_FORMAT, format); | ||
712 | } | ||
713 | |||
714 | /* | ||
715 | * HDA/HDMI auto parsing | ||
716 | */ | ||
717 | |||
718 | static int hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid) | ||
719 | { | ||
720 | struct hdmi_spec *spec = codec->spec; | ||
721 | hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; | ||
722 | int conn_len, curr; | ||
723 | int index; | ||
724 | |||
725 | if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { | ||
726 | snd_printk(KERN_WARNING | ||
727 | "HDMI: pin %d wcaps %#x " | ||
728 | "does not support connection list\n", | ||
729 | pin_nid, get_wcaps(codec, pin_nid)); | ||
730 | return -EINVAL; | ||
731 | } | ||
732 | |||
733 | conn_len = snd_hda_get_connections(codec, pin_nid, conn_list, | ||
734 | HDA_MAX_CONNECTIONS); | ||
735 | if (conn_len > 1) | ||
736 | curr = snd_hda_codec_read(codec, pin_nid, 0, | ||
737 | AC_VERB_GET_CONNECT_SEL, 0); | ||
738 | else | ||
739 | curr = 0; | ||
740 | |||
741 | index = hda_node_index(spec->pin, pin_nid); | ||
742 | if (index < 0) | ||
743 | return -EINVAL; | ||
744 | |||
745 | spec->pin_cvt[index] = conn_list[curr]; | ||
746 | |||
747 | return 0; | ||
748 | } | ||
749 | |||
750 | static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, | ||
751 | struct hdmi_eld *eld) | ||
752 | { | ||
753 | int present = snd_hda_pin_sense(codec, pin_nid); | ||
754 | |||
755 | eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); | ||
756 | eld->eld_valid = !!(present & AC_PINSENSE_ELDV); | ||
757 | |||
758 | if (present & AC_PINSENSE_ELDV) | ||
759 | hdmi_get_show_eld(codec, pin_nid, eld); | ||
760 | } | ||
761 | |||
762 | static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) | ||
763 | { | ||
764 | struct hdmi_spec *spec = codec->spec; | ||
765 | |||
766 | if (spec->num_pins >= MAX_HDMI_PINS) { | ||
767 | snd_printk(KERN_WARNING | ||
768 | "HDMI: no space for pin %d\n", pin_nid); | ||
769 | return -EINVAL; | ||
770 | } | ||
771 | |||
772 | hdmi_present_sense(codec, pin_nid, &spec->sink_eld[spec->num_pins]); | ||
773 | |||
774 | spec->pin[spec->num_pins] = pin_nid; | ||
775 | spec->num_pins++; | ||
776 | |||
777 | /* | ||
778 | * It is assumed that converter nodes come first in the node list and | ||
779 | * hence have been registered and usable now. | ||
780 | */ | ||
781 | return hdmi_read_pin_conn(codec, pin_nid); | ||
782 | } | ||
783 | |||
784 | static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid) | ||
785 | { | ||
786 | struct hdmi_spec *spec = codec->spec; | ||
787 | |||
788 | if (spec->num_cvts >= MAX_HDMI_CVTS) { | ||
789 | snd_printk(KERN_WARNING | ||
790 | "HDMI: no space for converter %d\n", nid); | ||
791 | return -EINVAL; | ||
792 | } | ||
793 | |||
794 | spec->cvt[spec->num_cvts] = nid; | ||
795 | spec->num_cvts++; | ||
796 | |||
797 | return 0; | ||
798 | } | ||
799 | |||
800 | static int hdmi_parse_codec(struct hda_codec *codec) | ||
801 | { | ||
802 | hda_nid_t nid; | ||
803 | int i, nodes; | ||
804 | |||
805 | nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); | ||
806 | if (!nid || nodes < 0) { | ||
807 | snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n"); | ||
808 | return -EINVAL; | ||
809 | } | ||
810 | |||
811 | for (i = 0; i < nodes; i++, nid++) { | ||
812 | unsigned int caps; | ||
813 | unsigned int type; | ||
814 | |||
815 | caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); | ||
816 | type = get_wcaps_type(caps); | ||
817 | |||
818 | if (!(caps & AC_WCAP_DIGITAL)) | ||
819 | continue; | ||
820 | |||
821 | switch (type) { | ||
822 | case AC_WID_AUD_OUT: | ||
823 | if (hdmi_add_cvt(codec, nid) < 0) | ||
824 | return -EINVAL; | ||
825 | break; | ||
826 | case AC_WID_PIN: | ||
827 | caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | ||
828 | if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP))) | ||
829 | continue; | ||
830 | if (hdmi_add_pin(codec, nid) < 0) | ||
831 | return -EINVAL; | ||
832 | break; | ||
833 | } | ||
834 | } | ||
835 | |||
836 | /* | ||
837 | * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event | ||
838 | * can be lost and presence sense verb will become inaccurate if the | ||
839 | * HDA link is powered off at hot plug or hw initialization time. | ||
840 | */ | ||
841 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
842 | if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) & | ||
843 | AC_PWRST_EPSS)) | ||
844 | codec->bus->power_keep_link_on = 1; | ||
845 | #endif | ||
846 | |||
847 | return 0; | ||
848 | } | ||
849 | |||
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c index 918f40378d52..88d035104cc5 100644 --- a/sound/pci/hda/patch_intelhdmi.c +++ b/sound/pci/hda/patch_intelhdmi.c | |||
@@ -40,815 +40,20 @@ | |||
40 | * | 40 | * |
41 | * The HDA correspondence of pipes/ports are converter/pin nodes. | 41 | * The HDA correspondence of pipes/ports are converter/pin nodes. |
42 | */ | 42 | */ |
43 | #define INTEL_HDMI_CVTS 2 | 43 | #define MAX_HDMI_CVTS 2 |
44 | #define INTEL_HDMI_PINS 3 | 44 | #define MAX_HDMI_PINS 3 |
45 | 45 | ||
46 | static char *intel_hdmi_pcm_names[INTEL_HDMI_CVTS] = { | 46 | #include "patch_hdmi.c" |
47 | |||
48 | static char *intel_hdmi_pcm_names[MAX_HDMI_CVTS] = { | ||
47 | "INTEL HDMI 0", | 49 | "INTEL HDMI 0", |
48 | "INTEL HDMI 1", | 50 | "INTEL HDMI 1", |
49 | }; | 51 | }; |
50 | 52 | ||
51 | struct intel_hdmi_spec { | ||
52 | int num_cvts; | ||
53 | int num_pins; | ||
54 | hda_nid_t cvt[INTEL_HDMI_CVTS+1]; /* audio sources */ | ||
55 | hda_nid_t pin[INTEL_HDMI_PINS+1]; /* audio sinks */ | ||
56 | |||
57 | /* | ||
58 | * source connection for each pin | ||
59 | */ | ||
60 | hda_nid_t pin_cvt[INTEL_HDMI_PINS+1]; | ||
61 | |||
62 | /* | ||
63 | * HDMI sink attached to each pin | ||
64 | */ | ||
65 | struct hdmi_eld sink_eld[INTEL_HDMI_PINS]; | ||
66 | |||
67 | /* | ||
68 | * export one pcm per pipe | ||
69 | */ | ||
70 | struct hda_pcm pcm_rec[INTEL_HDMI_CVTS]; | ||
71 | }; | ||
72 | |||
73 | struct hdmi_audio_infoframe { | ||
74 | u8 type; /* 0x84 */ | ||
75 | u8 ver; /* 0x01 */ | ||
76 | u8 len; /* 0x0a */ | ||
77 | |||
78 | u8 checksum; /* PB0 */ | ||
79 | u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */ | ||
80 | u8 SS01_SF24; | ||
81 | u8 CXT04; | ||
82 | u8 CA; | ||
83 | u8 LFEPBL01_LSV36_DM_INH7; | ||
84 | u8 reserved[5]; /* PB6 - PB10 */ | ||
85 | }; | ||
86 | |||
87 | /* | ||
88 | * CEA speaker placement: | ||
89 | * | ||
90 | * FLH FCH FRH | ||
91 | * FLW FL FLC FC FRC FR FRW | ||
92 | * | ||
93 | * LFE | ||
94 | * TC | ||
95 | * | ||
96 | * RL RLC RC RRC RR | ||
97 | * | ||
98 | * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to | ||
99 | * CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC. | ||
100 | */ | ||
101 | enum cea_speaker_placement { | ||
102 | FL = (1 << 0), /* Front Left */ | ||
103 | FC = (1 << 1), /* Front Center */ | ||
104 | FR = (1 << 2), /* Front Right */ | ||
105 | FLC = (1 << 3), /* Front Left Center */ | ||
106 | FRC = (1 << 4), /* Front Right Center */ | ||
107 | RL = (1 << 5), /* Rear Left */ | ||
108 | RC = (1 << 6), /* Rear Center */ | ||
109 | RR = (1 << 7), /* Rear Right */ | ||
110 | RLC = (1 << 8), /* Rear Left Center */ | ||
111 | RRC = (1 << 9), /* Rear Right Center */ | ||
112 | LFE = (1 << 10), /* Low Frequency Effect */ | ||
113 | FLW = (1 << 11), /* Front Left Wide */ | ||
114 | FRW = (1 << 12), /* Front Right Wide */ | ||
115 | FLH = (1 << 13), /* Front Left High */ | ||
116 | FCH = (1 << 14), /* Front Center High */ | ||
117 | FRH = (1 << 15), /* Front Right High */ | ||
118 | TC = (1 << 16), /* Top Center */ | ||
119 | }; | ||
120 | |||
121 | /* | ||
122 | * ELD SA bits in the CEA Speaker Allocation data block | ||
123 | */ | ||
124 | static int eld_speaker_allocation_bits[] = { | ||
125 | [0] = FL | FR, | ||
126 | [1] = LFE, | ||
127 | [2] = FC, | ||
128 | [3] = RL | RR, | ||
129 | [4] = RC, | ||
130 | [5] = FLC | FRC, | ||
131 | [6] = RLC | RRC, | ||
132 | /* the following are not defined in ELD yet */ | ||
133 | [7] = FLW | FRW, | ||
134 | [8] = FLH | FRH, | ||
135 | [9] = TC, | ||
136 | [10] = FCH, | ||
137 | }; | ||
138 | |||
139 | struct cea_channel_speaker_allocation { | ||
140 | int ca_index; | ||
141 | int speakers[8]; | ||
142 | |||
143 | /* derived values, just for convenience */ | ||
144 | int channels; | ||
145 | int spk_mask; | ||
146 | }; | ||
147 | |||
148 | /* | ||
149 | * ALSA sequence is: | ||
150 | * | ||
151 | * surround40 surround41 surround50 surround51 surround71 | ||
152 | * ch0 front left = = = = | ||
153 | * ch1 front right = = = = | ||
154 | * ch2 rear left = = = = | ||
155 | * ch3 rear right = = = = | ||
156 | * ch4 LFE center center center | ||
157 | * ch5 LFE LFE | ||
158 | * ch6 side left | ||
159 | * ch7 side right | ||
160 | * | ||
161 | * surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR} | ||
162 | */ | ||
163 | static int hdmi_channel_mapping[0x32][8] = { | ||
164 | /* stereo */ | ||
165 | [0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, | ||
166 | /* 2.1 */ | ||
167 | [0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, | ||
168 | /* Dolby Surround */ | ||
169 | [0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 }, | ||
170 | /* surround40 */ | ||
171 | [0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 }, | ||
172 | /* 4ch */ | ||
173 | [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 }, | ||
174 | /* surround41 */ | ||
175 | [0x09] = { 0x00, 0x11, 0x24, 0x34, 0x43, 0xf2, 0xf6, 0xf7 }, | ||
176 | /* surround50 */ | ||
177 | [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 }, | ||
178 | /* surround51 */ | ||
179 | [0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 }, | ||
180 | /* 7.1 */ | ||
181 | [0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 }, | ||
182 | }; | ||
183 | |||
184 | /* | ||
185 | * This is an ordered list! | ||
186 | * | ||
187 | * The preceding ones have better chances to be selected by | ||
188 | * hdmi_setup_channel_allocation(). | ||
189 | */ | ||
190 | static struct cea_channel_speaker_allocation channel_allocations[] = { | ||
191 | /* channel: 7 6 5 4 3 2 1 0 */ | ||
192 | { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } }, | ||
193 | /* 2.1 */ | ||
194 | { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } }, | ||
195 | /* Dolby Surround */ | ||
196 | { .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } }, | ||
197 | /* surround40 */ | ||
198 | { .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } }, | ||
199 | /* surround41 */ | ||
200 | { .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } }, | ||
201 | /* surround50 */ | ||
202 | { .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } }, | ||
203 | /* surround51 */ | ||
204 | { .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } }, | ||
205 | /* 6.1 */ | ||
206 | { .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } }, | ||
207 | /* surround71 */ | ||
208 | { .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } }, | ||
209 | |||
210 | { .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } }, | ||
211 | { .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } }, | ||
212 | { .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } }, | ||
213 | { .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } }, | ||
214 | { .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } }, | ||
215 | { .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } }, | ||
216 | { .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } }, | ||
217 | { .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } }, | ||
218 | { .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } }, | ||
219 | { .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } }, | ||
220 | { .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } }, | ||
221 | { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } }, | ||
222 | { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } }, | ||
223 | { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } }, | ||
224 | { .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } }, | ||
225 | { .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } }, | ||
226 | { .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } }, | ||
227 | { .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } }, | ||
228 | { .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } }, | ||
229 | { .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } }, | ||
230 | { .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } }, | ||
231 | { .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } }, | ||
232 | { .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } }, | ||
233 | { .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } }, | ||
234 | { .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } }, | ||
235 | { .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } }, | ||
236 | { .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } }, | ||
237 | { .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } }, | ||
238 | { .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } }, | ||
239 | { .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } }, | ||
240 | { .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } }, | ||
241 | { .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } }, | ||
242 | { .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } }, | ||
243 | { .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } }, | ||
244 | { .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } }, | ||
245 | { .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } }, | ||
246 | { .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } }, | ||
247 | { .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } }, | ||
248 | { .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } }, | ||
249 | { .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } }, | ||
250 | { .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } }, | ||
251 | }; | ||
252 | |||
253 | /* | ||
254 | * HDA/HDMI auto parsing | ||
255 | */ | ||
256 | |||
257 | static int hda_node_index(hda_nid_t *nids, hda_nid_t nid) | ||
258 | { | ||
259 | int i; | ||
260 | |||
261 | for (i = 0; nids[i]; i++) | ||
262 | if (nids[i] == nid) | ||
263 | return i; | ||
264 | |||
265 | snd_printk(KERN_WARNING "HDMI: nid %d not registered\n", nid); | ||
266 | return -EINVAL; | ||
267 | } | ||
268 | |||
269 | static int intel_hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid) | ||
270 | { | ||
271 | struct intel_hdmi_spec *spec = codec->spec; | ||
272 | hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; | ||
273 | int conn_len, curr; | ||
274 | int index; | ||
275 | |||
276 | if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { | ||
277 | snd_printk(KERN_WARNING | ||
278 | "HDMI: pin %d wcaps %#x " | ||
279 | "does not support connection list\n", | ||
280 | pin_nid, get_wcaps(codec, pin_nid)); | ||
281 | return -EINVAL; | ||
282 | } | ||
283 | |||
284 | conn_len = snd_hda_get_connections(codec, pin_nid, conn_list, | ||
285 | HDA_MAX_CONNECTIONS); | ||
286 | if (conn_len > 1) | ||
287 | curr = snd_hda_codec_read(codec, pin_nid, 0, | ||
288 | AC_VERB_GET_CONNECT_SEL, 0); | ||
289 | else | ||
290 | curr = 0; | ||
291 | |||
292 | index = hda_node_index(spec->pin, pin_nid); | ||
293 | if (index < 0) | ||
294 | return -EINVAL; | ||
295 | |||
296 | spec->pin_cvt[index] = conn_list[curr]; | ||
297 | |||
298 | return 0; | ||
299 | } | ||
300 | |||
301 | static void hdmi_get_show_eld(struct hda_codec *codec, hda_nid_t pin_nid, | ||
302 | struct hdmi_eld *eld) | ||
303 | { | ||
304 | if (!snd_hdmi_get_eld(eld, codec, pin_nid)) | ||
305 | snd_hdmi_show_eld(eld); | ||
306 | } | ||
307 | |||
308 | static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, | ||
309 | struct hdmi_eld *eld) | ||
310 | { | ||
311 | int present = snd_hda_pin_sense(codec, pin_nid); | ||
312 | |||
313 | eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); | ||
314 | eld->eld_valid = !!(present & AC_PINSENSE_ELDV); | ||
315 | |||
316 | if (present & AC_PINSENSE_ELDV) | ||
317 | hdmi_get_show_eld(codec, pin_nid, eld); | ||
318 | } | ||
319 | |||
320 | static int intel_hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) | ||
321 | { | ||
322 | struct intel_hdmi_spec *spec = codec->spec; | ||
323 | |||
324 | if (spec->num_pins >= INTEL_HDMI_PINS) { | ||
325 | snd_printk(KERN_WARNING | ||
326 | "HDMI: no space for pin %d \n", pin_nid); | ||
327 | return -EINVAL; | ||
328 | } | ||
329 | |||
330 | hdmi_present_sense(codec, pin_nid, &spec->sink_eld[spec->num_pins]); | ||
331 | |||
332 | spec->pin[spec->num_pins] = pin_nid; | ||
333 | spec->num_pins++; | ||
334 | |||
335 | /* | ||
336 | * It is assumed that converter nodes come first in the node list and | ||
337 | * hence have been registered and usable now. | ||
338 | */ | ||
339 | return intel_hdmi_read_pin_conn(codec, pin_nid); | ||
340 | } | ||
341 | |||
342 | static int intel_hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid) | ||
343 | { | ||
344 | struct intel_hdmi_spec *spec = codec->spec; | ||
345 | |||
346 | if (spec->num_cvts >= INTEL_HDMI_CVTS) { | ||
347 | snd_printk(KERN_WARNING | ||
348 | "HDMI: no space for converter %d \n", nid); | ||
349 | return -EINVAL; | ||
350 | } | ||
351 | |||
352 | spec->cvt[spec->num_cvts] = nid; | ||
353 | spec->num_cvts++; | ||
354 | |||
355 | return 0; | ||
356 | } | ||
357 | |||
358 | static int intel_hdmi_parse_codec(struct hda_codec *codec) | ||
359 | { | ||
360 | hda_nid_t nid; | ||
361 | int i, nodes; | ||
362 | |||
363 | nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); | ||
364 | if (!nid || nodes < 0) { | ||
365 | snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n"); | ||
366 | return -EINVAL; | ||
367 | } | ||
368 | |||
369 | for (i = 0; i < nodes; i++, nid++) { | ||
370 | unsigned int caps; | ||
371 | unsigned int type; | ||
372 | |||
373 | caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); | ||
374 | type = get_wcaps_type(caps); | ||
375 | |||
376 | if (!(caps & AC_WCAP_DIGITAL)) | ||
377 | continue; | ||
378 | |||
379 | switch (type) { | ||
380 | case AC_WID_AUD_OUT: | ||
381 | if (intel_hdmi_add_cvt(codec, nid) < 0) | ||
382 | return -EINVAL; | ||
383 | break; | ||
384 | case AC_WID_PIN: | ||
385 | caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | ||
386 | if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP))) | ||
387 | continue; | ||
388 | if (intel_hdmi_add_pin(codec, nid) < 0) | ||
389 | return -EINVAL; | ||
390 | break; | ||
391 | } | ||
392 | } | ||
393 | |||
394 | /* | ||
395 | * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event | ||
396 | * can be lost and presence sense verb will become inaccurate if the | ||
397 | * HDA link is powered off at hot plug or hw initialization time. | ||
398 | */ | ||
399 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
400 | if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) & | ||
401 | AC_PWRST_EPSS)) | ||
402 | codec->bus->power_keep_link_on = 1; | ||
403 | #endif | ||
404 | |||
405 | return 0; | ||
406 | } | ||
407 | |||
408 | /* | ||
409 | * HDMI routines | ||
410 | */ | ||
411 | |||
412 | #ifdef BE_PARANOID | ||
413 | static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, | ||
414 | int *packet_index, int *byte_index) | ||
415 | { | ||
416 | int val; | ||
417 | |||
418 | val = snd_hda_codec_read(codec, pin_nid, 0, | ||
419 | AC_VERB_GET_HDMI_DIP_INDEX, 0); | ||
420 | |||
421 | *packet_index = val >> 5; | ||
422 | *byte_index = val & 0x1f; | ||
423 | } | ||
424 | #endif | ||
425 | |||
426 | static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, | ||
427 | int packet_index, int byte_index) | ||
428 | { | ||
429 | int val; | ||
430 | |||
431 | val = (packet_index << 5) | (byte_index & 0x1f); | ||
432 | |||
433 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); | ||
434 | } | ||
435 | |||
436 | static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, | ||
437 | unsigned char val) | ||
438 | { | ||
439 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); | ||
440 | } | ||
441 | |||
442 | static void hdmi_enable_output(struct hda_codec *codec, hda_nid_t pin_nid) | ||
443 | { | ||
444 | /* Unmute */ | ||
445 | if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) | ||
446 | snd_hda_codec_write(codec, pin_nid, 0, | ||
447 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); | ||
448 | /* Enable pin out */ | ||
449 | snd_hda_codec_write(codec, pin_nid, 0, | ||
450 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | ||
451 | } | ||
452 | |||
453 | /* | ||
454 | * Enable Audio InfoFrame Transmission | ||
455 | */ | ||
456 | static void hdmi_start_infoframe_trans(struct hda_codec *codec, | ||
457 | hda_nid_t pin_nid) | ||
458 | { | ||
459 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | ||
460 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, | ||
461 | AC_DIPXMIT_BEST); | ||
462 | } | ||
463 | |||
464 | /* | ||
465 | * Disable Audio InfoFrame Transmission | ||
466 | */ | ||
467 | static void hdmi_stop_infoframe_trans(struct hda_codec *codec, | ||
468 | hda_nid_t pin_nid) | ||
469 | { | ||
470 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | ||
471 | snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, | ||
472 | AC_DIPXMIT_DISABLE); | ||
473 | } | ||
474 | |||
475 | static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t nid) | ||
476 | { | ||
477 | return 1 + snd_hda_codec_read(codec, nid, 0, | ||
478 | AC_VERB_GET_CVT_CHAN_COUNT, 0); | ||
479 | } | ||
480 | |||
481 | static void hdmi_set_channel_count(struct hda_codec *codec, | ||
482 | hda_nid_t nid, int chs) | ||
483 | { | ||
484 | if (chs != hdmi_get_channel_count(codec, nid)) | ||
485 | snd_hda_codec_write(codec, nid, 0, | ||
486 | AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); | ||
487 | } | ||
488 | |||
489 | static void hdmi_debug_channel_mapping(struct hda_codec *codec, | ||
490 | hda_nid_t pin_nid) | ||
491 | { | ||
492 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
493 | int i; | ||
494 | int slot; | ||
495 | |||
496 | for (i = 0; i < 8; i++) { | ||
497 | slot = snd_hda_codec_read(codec, pin_nid, 0, | ||
498 | AC_VERB_GET_HDMI_CHAN_SLOT, i); | ||
499 | printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", | ||
500 | slot >> 4, slot & 0xf); | ||
501 | } | ||
502 | #endif | ||
503 | } | ||
504 | |||
505 | |||
506 | /* | ||
507 | * Audio InfoFrame routines | ||
508 | */ | ||
509 | |||
510 | static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) | ||
511 | { | ||
512 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
513 | int i; | ||
514 | int size; | ||
515 | |||
516 | size = snd_hdmi_get_eld_size(codec, pin_nid); | ||
517 | printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size); | ||
518 | |||
519 | for (i = 0; i < 8; i++) { | ||
520 | size = snd_hda_codec_read(codec, pin_nid, 0, | ||
521 | AC_VERB_GET_HDMI_DIP_SIZE, i); | ||
522 | printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size); | ||
523 | } | ||
524 | #endif | ||
525 | } | ||
526 | |||
527 | static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) | ||
528 | { | ||
529 | #ifdef BE_PARANOID | ||
530 | int i, j; | ||
531 | int size; | ||
532 | int pi, bi; | ||
533 | for (i = 0; i < 8; i++) { | ||
534 | size = snd_hda_codec_read(codec, pin_nid, 0, | ||
535 | AC_VERB_GET_HDMI_DIP_SIZE, i); | ||
536 | if (size == 0) | ||
537 | continue; | ||
538 | |||
539 | hdmi_set_dip_index(codec, pin_nid, i, 0x0); | ||
540 | for (j = 1; j < 1000; j++) { | ||
541 | hdmi_write_dip_byte(codec, pin_nid, 0x0); | ||
542 | hdmi_get_dip_index(codec, pin_nid, &pi, &bi); | ||
543 | if (pi != i) | ||
544 | snd_printd(KERN_INFO "dip index %d: %d != %d\n", | ||
545 | bi, pi, i); | ||
546 | if (bi == 0) /* byte index wrapped around */ | ||
547 | break; | ||
548 | } | ||
549 | snd_printd(KERN_INFO | ||
550 | "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n", | ||
551 | i, size, j); | ||
552 | } | ||
553 | #endif | ||
554 | } | ||
555 | |||
556 | static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai) | ||
557 | { | ||
558 | u8 *bytes = (u8 *)ai; | ||
559 | u8 sum = 0; | ||
560 | int i; | ||
561 | |||
562 | ai->checksum = 0; | ||
563 | |||
564 | for (i = 0; i < sizeof(*ai); i++) | ||
565 | sum += bytes[i]; | ||
566 | |||
567 | ai->checksum = - sum; | ||
568 | } | ||
569 | |||
570 | static void hdmi_fill_audio_infoframe(struct hda_codec *codec, | ||
571 | hda_nid_t pin_nid, | ||
572 | struct hdmi_audio_infoframe *ai) | ||
573 | { | ||
574 | u8 *bytes = (u8 *)ai; | ||
575 | int i; | ||
576 | |||
577 | hdmi_debug_dip_size(codec, pin_nid); | ||
578 | hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ | ||
579 | |||
580 | hdmi_checksum_audio_infoframe(ai); | ||
581 | |||
582 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | ||
583 | for (i = 0; i < sizeof(*ai); i++) | ||
584 | hdmi_write_dip_byte(codec, pin_nid, bytes[i]); | ||
585 | } | ||
586 | |||
587 | /* | ||
588 | * Compute derived values in channel_allocations[]. | ||
589 | */ | ||
590 | static void init_channel_allocations(void) | ||
591 | { | ||
592 | int i, j; | ||
593 | struct cea_channel_speaker_allocation *p; | ||
594 | |||
595 | for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { | ||
596 | p = channel_allocations + i; | ||
597 | p->channels = 0; | ||
598 | p->spk_mask = 0; | ||
599 | for (j = 0; j < ARRAY_SIZE(p->speakers); j++) | ||
600 | if (p->speakers[j]) { | ||
601 | p->channels++; | ||
602 | p->spk_mask |= p->speakers[j]; | ||
603 | } | ||
604 | } | ||
605 | } | ||
606 | |||
607 | /* | ||
608 | * The transformation takes two steps: | ||
609 | * | ||
610 | * eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask | ||
611 | * spk_mask => (channel_allocations[]) => ai->CA | ||
612 | * | ||
613 | * TODO: it could select the wrong CA from multiple candidates. | ||
614 | */ | ||
615 | static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid, | ||
616 | struct hdmi_audio_infoframe *ai) | ||
617 | { | ||
618 | struct intel_hdmi_spec *spec = codec->spec; | ||
619 | struct hdmi_eld *eld; | ||
620 | int i; | ||
621 | int spk_mask = 0; | ||
622 | int channels = 1 + (ai->CC02_CT47 & 0x7); | ||
623 | char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; | ||
624 | |||
625 | /* | ||
626 | * CA defaults to 0 for basic stereo audio | ||
627 | */ | ||
628 | if (channels <= 2) | ||
629 | return 0; | ||
630 | |||
631 | i = hda_node_index(spec->pin_cvt, nid); | ||
632 | if (i < 0) | ||
633 | return 0; | ||
634 | eld = &spec->sink_eld[i]; | ||
635 | |||
636 | /* | ||
637 | * HDMI sink's ELD info cannot always be retrieved for now, e.g. | ||
638 | * in console or for audio devices. Assume the highest speakers | ||
639 | * configuration, to _not_ prohibit multi-channel audio playback. | ||
640 | */ | ||
641 | if (!eld->spk_alloc) | ||
642 | eld->spk_alloc = 0xffff; | ||
643 | |||
644 | /* | ||
645 | * expand ELD's speaker allocation mask | ||
646 | * | ||
647 | * ELD tells the speaker mask in a compact(paired) form, | ||
648 | * expand ELD's notions to match the ones used by Audio InfoFrame. | ||
649 | */ | ||
650 | for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) { | ||
651 | if (eld->spk_alloc & (1 << i)) | ||
652 | spk_mask |= eld_speaker_allocation_bits[i]; | ||
653 | } | ||
654 | |||
655 | /* search for the first working match in the CA table */ | ||
656 | for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { | ||
657 | if (channels == channel_allocations[i].channels && | ||
658 | (spk_mask & channel_allocations[i].spk_mask) == | ||
659 | channel_allocations[i].spk_mask) { | ||
660 | ai->CA = channel_allocations[i].ca_index; | ||
661 | break; | ||
662 | } | ||
663 | } | ||
664 | |||
665 | snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf)); | ||
666 | snd_printdd(KERN_INFO | ||
667 | "HDMI: select CA 0x%x for %d-channel allocation: %s\n", | ||
668 | ai->CA, channels, buf); | ||
669 | |||
670 | return ai->CA; | ||
671 | } | ||
672 | |||
673 | static void hdmi_setup_channel_mapping(struct hda_codec *codec, | ||
674 | hda_nid_t pin_nid, | ||
675 | struct hdmi_audio_infoframe *ai) | ||
676 | { | ||
677 | int i; | ||
678 | int ca = ai->CA; | ||
679 | int err; | ||
680 | |||
681 | if (hdmi_channel_mapping[ca][1] == 0) { | ||
682 | for (i = 0; i < channel_allocations[ca].channels; i++) | ||
683 | hdmi_channel_mapping[ca][i] = i | (i << 4); | ||
684 | for (; i < 8; i++) | ||
685 | hdmi_channel_mapping[ca][i] = 0xf | (i << 4); | ||
686 | } | ||
687 | |||
688 | for (i = 0; i < 8; i++) { | ||
689 | err = snd_hda_codec_write(codec, pin_nid, 0, | ||
690 | AC_VERB_SET_HDMI_CHAN_SLOT, | ||
691 | hdmi_channel_mapping[ca][i]); | ||
692 | if (err) { | ||
693 | snd_printdd(KERN_INFO "HDMI: channel mapping failed\n"); | ||
694 | break; | ||
695 | } | ||
696 | } | ||
697 | |||
698 | hdmi_debug_channel_mapping(codec, pin_nid); | ||
699 | } | ||
700 | |||
701 | static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, | ||
702 | struct hdmi_audio_infoframe *ai) | ||
703 | { | ||
704 | u8 *bytes = (u8 *)ai; | ||
705 | u8 val; | ||
706 | int i; | ||
707 | |||
708 | if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) | ||
709 | != AC_DIPXMIT_BEST) | ||
710 | return false; | ||
711 | |||
712 | hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); | ||
713 | for (i = 0; i < sizeof(*ai); i++) { | ||
714 | val = snd_hda_codec_read(codec, pin_nid, 0, | ||
715 | AC_VERB_GET_HDMI_DIP_DATA, 0); | ||
716 | if (val != bytes[i]) | ||
717 | return false; | ||
718 | } | ||
719 | |||
720 | return true; | ||
721 | } | ||
722 | |||
723 | static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, | ||
724 | struct snd_pcm_substream *substream) | ||
725 | { | ||
726 | struct intel_hdmi_spec *spec = codec->spec; | ||
727 | hda_nid_t pin_nid; | ||
728 | int i; | ||
729 | struct hdmi_audio_infoframe ai = { | ||
730 | .type = 0x84, | ||
731 | .ver = 0x01, | ||
732 | .len = 0x0a, | ||
733 | .CC02_CT47 = substream->runtime->channels - 1, | ||
734 | }; | ||
735 | |||
736 | hdmi_setup_channel_allocation(codec, nid, &ai); | ||
737 | |||
738 | for (i = 0; i < spec->num_pins; i++) { | ||
739 | if (spec->pin_cvt[i] != nid) | ||
740 | continue; | ||
741 | if (!spec->sink_eld[i].monitor_present) | ||
742 | continue; | ||
743 | |||
744 | pin_nid = spec->pin[i]; | ||
745 | if (!hdmi_infoframe_uptodate(codec, pin_nid, &ai)) { | ||
746 | hdmi_setup_channel_mapping(codec, pin_nid, &ai); | ||
747 | hdmi_stop_infoframe_trans(codec, pin_nid); | ||
748 | hdmi_fill_audio_infoframe(codec, pin_nid, &ai); | ||
749 | hdmi_start_infoframe_trans(codec, pin_nid); | ||
750 | } | ||
751 | } | ||
752 | } | ||
753 | |||
754 | |||
755 | /* | 53 | /* |
756 | * Unsolicited events | 54 | * HDMI callbacks |
757 | */ | 55 | */ |
758 | 56 | ||
759 | static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) | ||
760 | { | ||
761 | struct intel_hdmi_spec *spec = codec->spec; | ||
762 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; | ||
763 | int pind = !!(res & AC_UNSOL_RES_PD); | ||
764 | int eldv = !!(res & AC_UNSOL_RES_ELDV); | ||
765 | int index; | ||
766 | |||
767 | printk(KERN_INFO | ||
768 | "HDMI hot plug event: Pin=%d Presence_Detect=%d ELD_Valid=%d\n", | ||
769 | tag, pind, eldv); | ||
770 | |||
771 | index = hda_node_index(spec->pin, tag); | ||
772 | if (index < 0) | ||
773 | return; | ||
774 | |||
775 | spec->sink_eld[index].monitor_present = pind; | ||
776 | spec->sink_eld[index].eld_valid = eldv; | ||
777 | |||
778 | if (pind && eldv) { | ||
779 | hdmi_get_show_eld(codec, spec->pin[index], &spec->sink_eld[index]); | ||
780 | /* TODO: do real things about ELD */ | ||
781 | } | ||
782 | } | ||
783 | |||
784 | static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) | ||
785 | { | ||
786 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; | ||
787 | int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; | ||
788 | int cp_state = !!(res & AC_UNSOL_RES_CP_STATE); | ||
789 | int cp_ready = !!(res & AC_UNSOL_RES_CP_READY); | ||
790 | |||
791 | printk(KERN_INFO | ||
792 | "HDMI CP event: PIN=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", | ||
793 | tag, | ||
794 | subtag, | ||
795 | cp_state, | ||
796 | cp_ready); | ||
797 | |||
798 | /* TODO */ | ||
799 | if (cp_state) | ||
800 | ; | ||
801 | if (cp_ready) | ||
802 | ; | ||
803 | } | ||
804 | |||
805 | |||
806 | static void intel_hdmi_unsol_event(struct hda_codec *codec, unsigned int res) | ||
807 | { | ||
808 | struct intel_hdmi_spec *spec = codec->spec; | ||
809 | int tag = res >> AC_UNSOL_RES_TAG_SHIFT; | ||
810 | int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; | ||
811 | |||
812 | if (hda_node_index(spec->pin, tag) < 0) { | ||
813 | snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag); | ||
814 | return; | ||
815 | } | ||
816 | |||
817 | if (subtag == 0) | ||
818 | hdmi_intrinsic_event(codec, res); | ||
819 | else | ||
820 | hdmi_non_intrinsic_event(codec, res); | ||
821 | } | ||
822 | |||
823 | /* | ||
824 | * Callbacks | ||
825 | */ | ||
826 | |||
827 | static void hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, | ||
828 | u32 stream_tag, int format) | ||
829 | { | ||
830 | int tag; | ||
831 | int fmt; | ||
832 | |||
833 | tag = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0) >> 4; | ||
834 | fmt = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_STREAM_FORMAT, 0); | ||
835 | |||
836 | snd_printdd("hdmi_setup_stream: " | ||
837 | "NID=0x%x, %sstream=0x%x, %sformat=0x%x\n", | ||
838 | nid, | ||
839 | tag == stream_tag ? "" : "new-", | ||
840 | stream_tag, | ||
841 | fmt == format ? "" : "new-", | ||
842 | format); | ||
843 | |||
844 | if (tag != stream_tag) | ||
845 | snd_hda_codec_write(codec, nid, 0, | ||
846 | AC_VERB_SET_CHANNEL_STREAMID, stream_tag << 4); | ||
847 | if (fmt != format) | ||
848 | snd_hda_codec_write(codec, nid, 0, | ||
849 | AC_VERB_SET_STREAM_FORMAT, format); | ||
850 | } | ||
851 | |||
852 | static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | 57 | static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
853 | struct hda_codec *codec, | 58 | struct hda_codec *codec, |
854 | unsigned int stream_tag, | 59 | unsigned int stream_tag, |
@@ -882,7 +87,7 @@ static struct hda_pcm_stream intel_hdmi_pcm_playback = { | |||
882 | 87 | ||
883 | static int intel_hdmi_build_pcms(struct hda_codec *codec) | 88 | static int intel_hdmi_build_pcms(struct hda_codec *codec) |
884 | { | 89 | { |
885 | struct intel_hdmi_spec *spec = codec->spec; | 90 | struct hdmi_spec *spec = codec->spec; |
886 | struct hda_pcm *info = spec->pcm_rec; | 91 | struct hda_pcm *info = spec->pcm_rec; |
887 | int i; | 92 | int i; |
888 | 93 | ||
@@ -908,7 +113,7 @@ static int intel_hdmi_build_pcms(struct hda_codec *codec) | |||
908 | 113 | ||
909 | static int intel_hdmi_build_controls(struct hda_codec *codec) | 114 | static int intel_hdmi_build_controls(struct hda_codec *codec) |
910 | { | 115 | { |
911 | struct intel_hdmi_spec *spec = codec->spec; | 116 | struct hdmi_spec *spec = codec->spec; |
912 | int err; | 117 | int err; |
913 | int i; | 118 | int i; |
914 | 119 | ||
@@ -923,7 +128,7 @@ static int intel_hdmi_build_controls(struct hda_codec *codec) | |||
923 | 128 | ||
924 | static int intel_hdmi_init(struct hda_codec *codec) | 129 | static int intel_hdmi_init(struct hda_codec *codec) |
925 | { | 130 | { |
926 | struct intel_hdmi_spec *spec = codec->spec; | 131 | struct hdmi_spec *spec = codec->spec; |
927 | int i; | 132 | int i; |
928 | 133 | ||
929 | for (i = 0; spec->pin[i]; i++) { | 134 | for (i = 0; spec->pin[i]; i++) { |
@@ -937,7 +142,7 @@ static int intel_hdmi_init(struct hda_codec *codec) | |||
937 | 142 | ||
938 | static void intel_hdmi_free(struct hda_codec *codec) | 143 | static void intel_hdmi_free(struct hda_codec *codec) |
939 | { | 144 | { |
940 | struct intel_hdmi_spec *spec = codec->spec; | 145 | struct hdmi_spec *spec = codec->spec; |
941 | int i; | 146 | int i; |
942 | 147 | ||
943 | for (i = 0; i < spec->num_pins; i++) | 148 | for (i = 0; i < spec->num_pins; i++) |
@@ -951,12 +156,12 @@ static struct hda_codec_ops intel_hdmi_patch_ops = { | |||
951 | .free = intel_hdmi_free, | 156 | .free = intel_hdmi_free, |
952 | .build_pcms = intel_hdmi_build_pcms, | 157 | .build_pcms = intel_hdmi_build_pcms, |
953 | .build_controls = intel_hdmi_build_controls, | 158 | .build_controls = intel_hdmi_build_controls, |
954 | .unsol_event = intel_hdmi_unsol_event, | 159 | .unsol_event = hdmi_unsol_event, |
955 | }; | 160 | }; |
956 | 161 | ||
957 | static int patch_intel_hdmi(struct hda_codec *codec) | 162 | static int patch_intel_hdmi(struct hda_codec *codec) |
958 | { | 163 | { |
959 | struct intel_hdmi_spec *spec; | 164 | struct hdmi_spec *spec; |
960 | int i; | 165 | int i; |
961 | 166 | ||
962 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 167 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
@@ -964,7 +169,7 @@ static int patch_intel_hdmi(struct hda_codec *codec) | |||
964 | return -ENOMEM; | 169 | return -ENOMEM; |
965 | 170 | ||
966 | codec->spec = spec; | 171 | codec->spec = spec; |
967 | if (intel_hdmi_parse_codec(codec) < 0) { | 172 | if (hdmi_parse_codec(codec) < 0) { |
968 | codec->spec = NULL; | 173 | codec->spec = NULL; |
969 | kfree(spec); | 174 | kfree(spec); |
970 | return -EINVAL; | 175 | return -EINVAL; |
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index 6afdab09bab7..70669a246902 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c | |||
@@ -29,13 +29,23 @@ | |||
29 | #include "hda_codec.h" | 29 | #include "hda_codec.h" |
30 | #include "hda_local.h" | 30 | #include "hda_local.h" |
31 | 31 | ||
32 | #define MAX_HDMI_CVTS 1 | ||
33 | #define MAX_HDMI_PINS 1 | ||
34 | |||
35 | #include "patch_hdmi.c" | ||
36 | |||
37 | static char *nvhdmi_pcm_names[MAX_HDMI_CVTS] = { | ||
38 | "NVIDIA HDMI", | ||
39 | }; | ||
40 | |||
32 | /* define below to restrict the supported rates and formats */ | 41 | /* define below to restrict the supported rates and formats */ |
33 | /* #define LIMITED_RATE_FMT_SUPPORT */ | 42 | /* #define LIMITED_RATE_FMT_SUPPORT */ |
34 | 43 | ||
35 | struct nvhdmi_spec { | 44 | enum HDACodec { |
36 | struct hda_multi_out multiout; | 45 | HDA_CODEC_NVIDIA_MCP7X, |
37 | 46 | HDA_CODEC_NVIDIA_MCP89, | |
38 | struct hda_pcm pcm_rec; | 47 | HDA_CODEC_NVIDIA_GT21X, |
48 | HDA_CODEC_INVALID | ||
39 | }; | 49 | }; |
40 | 50 | ||
41 | #define Nv_VERB_SET_Channel_Allocation 0xF79 | 51 | #define Nv_VERB_SET_Channel_Allocation 0xF79 |
@@ -43,15 +53,18 @@ struct nvhdmi_spec { | |||
43 | #define Nv_VERB_SET_Audio_Protection_On 0xF98 | 53 | #define Nv_VERB_SET_Audio_Protection_On 0xF98 |
44 | #define Nv_VERB_SET_Audio_Protection_Off 0xF99 | 54 | #define Nv_VERB_SET_Audio_Protection_Off 0xF99 |
45 | 55 | ||
46 | #define Nv_Master_Convert_nid 0x04 | 56 | #define nvhdmi_master_con_nid_7x 0x04 |
47 | #define Nv_Master_Pin_nid 0x05 | 57 | #define nvhdmi_master_pin_nid_7x 0x05 |
48 | 58 | ||
49 | static hda_nid_t nvhdmi_convert_nids[4] = { | 59 | #define nvhdmi_master_con_nid_89 0x04 |
60 | #define nvhdmi_master_pin_nid_89 0x05 | ||
61 | |||
62 | static hda_nid_t nvhdmi_con_nids_7x[4] = { | ||
50 | /*front, rear, clfe, rear_surr */ | 63 | /*front, rear, clfe, rear_surr */ |
51 | 0x6, 0x8, 0xa, 0xc, | 64 | 0x6, 0x8, 0xa, 0xc, |
52 | }; | 65 | }; |
53 | 66 | ||
54 | static struct hda_verb nvhdmi_basic_init[] = { | 67 | static struct hda_verb nvhdmi_basic_init_7x[] = { |
55 | /* set audio protect on */ | 68 | /* set audio protect on */ |
56 | { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1}, | 69 | { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1}, |
57 | /* enable digital output on pin widget */ | 70 | /* enable digital output on pin widget */ |
@@ -84,22 +97,60 @@ static struct hda_verb nvhdmi_basic_init[] = { | |||
84 | */ | 97 | */ |
85 | static int nvhdmi_build_controls(struct hda_codec *codec) | 98 | static int nvhdmi_build_controls(struct hda_codec *codec) |
86 | { | 99 | { |
87 | struct nvhdmi_spec *spec = codec->spec; | 100 | struct hdmi_spec *spec = codec->spec; |
88 | int err; | 101 | int err; |
102 | int i; | ||
89 | 103 | ||
90 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); | 104 | if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) |
91 | if (err < 0) | 105 | || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { |
92 | return err; | 106 | for (i = 0; i < codec->num_pcms; i++) { |
107 | err = snd_hda_create_spdif_out_ctls(codec, | ||
108 | spec->cvt[i]); | ||
109 | if (err < 0) | ||
110 | return err; | ||
111 | } | ||
112 | } else { | ||
113 | err = snd_hda_create_spdif_out_ctls(codec, | ||
114 | spec->multiout.dig_out_nid); | ||
115 | if (err < 0) | ||
116 | return err; | ||
117 | } | ||
93 | 118 | ||
94 | return 0; | 119 | return 0; |
95 | } | 120 | } |
96 | 121 | ||
97 | static int nvhdmi_init(struct hda_codec *codec) | 122 | static int nvhdmi_init(struct hda_codec *codec) |
98 | { | 123 | { |
99 | snd_hda_sequence_write(codec, nvhdmi_basic_init); | 124 | struct hdmi_spec *spec = codec->spec; |
125 | int i; | ||
126 | if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) | ||
127 | || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { | ||
128 | for (i = 0; spec->pin[i]; i++) { | ||
129 | hdmi_enable_output(codec, spec->pin[i]); | ||
130 | snd_hda_codec_write(codec, spec->pin[i], 0, | ||
131 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
132 | AC_USRSP_EN | spec->pin[i]); | ||
133 | } | ||
134 | } else { | ||
135 | snd_hda_sequence_write(codec, nvhdmi_basic_init_7x); | ||
136 | } | ||
100 | return 0; | 137 | return 0; |
101 | } | 138 | } |
102 | 139 | ||
140 | static void nvhdmi_free(struct hda_codec *codec) | ||
141 | { | ||
142 | struct hdmi_spec *spec = codec->spec; | ||
143 | int i; | ||
144 | |||
145 | if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) | ||
146 | || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { | ||
147 | for (i = 0; i < spec->num_pins; i++) | ||
148 | snd_hda_eld_proc_free(codec, &spec->sink_eld[i]); | ||
149 | } | ||
150 | |||
151 | kfree(spec); | ||
152 | } | ||
153 | |||
103 | /* | 154 | /* |
104 | * Digital out | 155 | * Digital out |
105 | */ | 156 | */ |
@@ -107,25 +158,25 @@ static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | |||
107 | struct hda_codec *codec, | 158 | struct hda_codec *codec, |
108 | struct snd_pcm_substream *substream) | 159 | struct snd_pcm_substream *substream) |
109 | { | 160 | { |
110 | struct nvhdmi_spec *spec = codec->spec; | 161 | struct hdmi_spec *spec = codec->spec; |
111 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); | 162 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
112 | } | 163 | } |
113 | 164 | ||
114 | static int nvhdmi_dig_playback_pcm_close_8ch(struct hda_pcm_stream *hinfo, | 165 | static int nvhdmi_dig_playback_pcm_close_8ch_7x(struct hda_pcm_stream *hinfo, |
115 | struct hda_codec *codec, | 166 | struct hda_codec *codec, |
116 | struct snd_pcm_substream *substream) | 167 | struct snd_pcm_substream *substream) |
117 | { | 168 | { |
118 | struct nvhdmi_spec *spec = codec->spec; | 169 | struct hdmi_spec *spec = codec->spec; |
119 | int i; | 170 | int i; |
120 | 171 | ||
121 | snd_hda_codec_write(codec, Nv_Master_Convert_nid, | 172 | snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, |
122 | 0, AC_VERB_SET_CHANNEL_STREAMID, 0); | 173 | 0, AC_VERB_SET_CHANNEL_STREAMID, 0); |
123 | for (i = 0; i < 4; i++) { | 174 | for (i = 0; i < 4; i++) { |
124 | /* set the stream id */ | 175 | /* set the stream id */ |
125 | snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0, | 176 | snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, |
126 | AC_VERB_SET_CHANNEL_STREAMID, 0); | 177 | AC_VERB_SET_CHANNEL_STREAMID, 0); |
127 | /* set the stream format */ | 178 | /* set the stream format */ |
128 | snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0, | 179 | snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, |
129 | AC_VERB_SET_STREAM_FORMAT, 0); | 180 | AC_VERB_SET_STREAM_FORMAT, 0); |
130 | } | 181 | } |
131 | 182 | ||
@@ -136,10 +187,25 @@ static int nvhdmi_dig_playback_pcm_close_2ch(struct hda_pcm_stream *hinfo, | |||
136 | struct hda_codec *codec, | 187 | struct hda_codec *codec, |
137 | struct snd_pcm_substream *substream) | 188 | struct snd_pcm_substream *substream) |
138 | { | 189 | { |
139 | struct nvhdmi_spec *spec = codec->spec; | 190 | struct hdmi_spec *spec = codec->spec; |
140 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); | 191 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
141 | } | 192 | } |
142 | 193 | ||
194 | static int nvhdmi_dig_playback_pcm_prepare_8ch_89(struct hda_pcm_stream *hinfo, | ||
195 | struct hda_codec *codec, | ||
196 | unsigned int stream_tag, | ||
197 | unsigned int format, | ||
198 | struct snd_pcm_substream *substream) | ||
199 | { | ||
200 | hdmi_set_channel_count(codec, hinfo->nid, | ||
201 | substream->runtime->channels); | ||
202 | |||
203 | hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); | ||
204 | |||
205 | hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); | ||
206 | return 0; | ||
207 | } | ||
208 | |||
143 | static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, | 209 | static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, |
144 | struct hda_codec *codec, | 210 | struct hda_codec *codec, |
145 | unsigned int stream_tag, | 211 | unsigned int stream_tag, |
@@ -181,29 +247,29 @@ static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, | |||
181 | /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ | 247 | /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ |
182 | if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) | 248 | if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) |
183 | snd_hda_codec_write(codec, | 249 | snd_hda_codec_write(codec, |
184 | Nv_Master_Convert_nid, | 250 | nvhdmi_master_con_nid_7x, |
185 | 0, | 251 | 0, |
186 | AC_VERB_SET_DIGI_CONVERT_1, | 252 | AC_VERB_SET_DIGI_CONVERT_1, |
187 | codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); | 253 | codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); |
188 | 254 | ||
189 | /* set the stream id */ | 255 | /* set the stream id */ |
190 | snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0, | 256 | snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, |
191 | AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); | 257 | AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); |
192 | 258 | ||
193 | /* set the stream format */ | 259 | /* set the stream format */ |
194 | snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0, | 260 | snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, |
195 | AC_VERB_SET_STREAM_FORMAT, format); | 261 | AC_VERB_SET_STREAM_FORMAT, format); |
196 | 262 | ||
197 | /* turn on again (if needed) */ | 263 | /* turn on again (if needed) */ |
198 | /* enable and set the channel status audio/data flag */ | 264 | /* enable and set the channel status audio/data flag */ |
199 | if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) { | 265 | if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) { |
200 | snd_hda_codec_write(codec, | 266 | snd_hda_codec_write(codec, |
201 | Nv_Master_Convert_nid, | 267 | nvhdmi_master_con_nid_7x, |
202 | 0, | 268 | 0, |
203 | AC_VERB_SET_DIGI_CONVERT_1, | 269 | AC_VERB_SET_DIGI_CONVERT_1, |
204 | codec->spdif_ctls & 0xff); | 270 | codec->spdif_ctls & 0xff); |
205 | snd_hda_codec_write(codec, | 271 | snd_hda_codec_write(codec, |
206 | Nv_Master_Convert_nid, | 272 | nvhdmi_master_con_nid_7x, |
207 | 0, | 273 | 0, |
208 | AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); | 274 | AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); |
209 | } | 275 | } |
@@ -220,19 +286,19 @@ static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, | |||
220 | if (codec->spdif_status_reset && | 286 | if (codec->spdif_status_reset && |
221 | (codec->spdif_ctls & AC_DIG1_ENABLE)) | 287 | (codec->spdif_ctls & AC_DIG1_ENABLE)) |
222 | snd_hda_codec_write(codec, | 288 | snd_hda_codec_write(codec, |
223 | nvhdmi_convert_nids[i], | 289 | nvhdmi_con_nids_7x[i], |
224 | 0, | 290 | 0, |
225 | AC_VERB_SET_DIGI_CONVERT_1, | 291 | AC_VERB_SET_DIGI_CONVERT_1, |
226 | codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); | 292 | codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); |
227 | /* set the stream id */ | 293 | /* set the stream id */ |
228 | snd_hda_codec_write(codec, | 294 | snd_hda_codec_write(codec, |
229 | nvhdmi_convert_nids[i], | 295 | nvhdmi_con_nids_7x[i], |
230 | 0, | 296 | 0, |
231 | AC_VERB_SET_CHANNEL_STREAMID, | 297 | AC_VERB_SET_CHANNEL_STREAMID, |
232 | (stream_tag << 4) | channel_id); | 298 | (stream_tag << 4) | channel_id); |
233 | /* set the stream format */ | 299 | /* set the stream format */ |
234 | snd_hda_codec_write(codec, | 300 | snd_hda_codec_write(codec, |
235 | nvhdmi_convert_nids[i], | 301 | nvhdmi_con_nids_7x[i], |
236 | 0, | 302 | 0, |
237 | AC_VERB_SET_STREAM_FORMAT, | 303 | AC_VERB_SET_STREAM_FORMAT, |
238 | format); | 304 | format); |
@@ -241,12 +307,12 @@ static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, | |||
241 | if (codec->spdif_status_reset && | 307 | if (codec->spdif_status_reset && |
242 | (codec->spdif_ctls & AC_DIG1_ENABLE)) { | 308 | (codec->spdif_ctls & AC_DIG1_ENABLE)) { |
243 | snd_hda_codec_write(codec, | 309 | snd_hda_codec_write(codec, |
244 | nvhdmi_convert_nids[i], | 310 | nvhdmi_con_nids_7x[i], |
245 | 0, | 311 | 0, |
246 | AC_VERB_SET_DIGI_CONVERT_1, | 312 | AC_VERB_SET_DIGI_CONVERT_1, |
247 | codec->spdif_ctls & 0xff); | 313 | codec->spdif_ctls & 0xff); |
248 | snd_hda_codec_write(codec, | 314 | snd_hda_codec_write(codec, |
249 | nvhdmi_convert_nids[i], | 315 | nvhdmi_con_nids_7x[i], |
250 | 0, | 316 | 0, |
251 | AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); | 317 | AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); |
252 | } | 318 | } |
@@ -261,28 +327,47 @@ static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, | |||
261 | return 0; | 327 | return 0; |
262 | } | 328 | } |
263 | 329 | ||
330 | static int nvhdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | ||
331 | struct hda_codec *codec, | ||
332 | struct snd_pcm_substream *substream) | ||
333 | { | ||
334 | return 0; | ||
335 | } | ||
336 | |||
264 | static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream *hinfo, | 337 | static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream *hinfo, |
265 | struct hda_codec *codec, | 338 | struct hda_codec *codec, |
266 | unsigned int stream_tag, | 339 | unsigned int stream_tag, |
267 | unsigned int format, | 340 | unsigned int format, |
268 | struct snd_pcm_substream *substream) | 341 | struct snd_pcm_substream *substream) |
269 | { | 342 | { |
270 | struct nvhdmi_spec *spec = codec->spec; | 343 | struct hdmi_spec *spec = codec->spec; |
271 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, | 344 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, |
272 | format, substream); | 345 | format, substream); |
273 | } | 346 | } |
274 | 347 | ||
275 | static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch = { | 348 | static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_89 = { |
349 | .substreams = 1, | ||
350 | .channels_min = 2, | ||
351 | .rates = SUPPORTED_RATES, | ||
352 | .maxbps = SUPPORTED_MAXBPS, | ||
353 | .formats = SUPPORTED_FORMATS, | ||
354 | .ops = { | ||
355 | .prepare = nvhdmi_dig_playback_pcm_prepare_8ch_89, | ||
356 | .cleanup = nvhdmi_playback_pcm_cleanup, | ||
357 | }, | ||
358 | }; | ||
359 | |||
360 | static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_7x = { | ||
276 | .substreams = 1, | 361 | .substreams = 1, |
277 | .channels_min = 2, | 362 | .channels_min = 2, |
278 | .channels_max = 8, | 363 | .channels_max = 8, |
279 | .nid = Nv_Master_Convert_nid, | 364 | .nid = nvhdmi_master_con_nid_7x, |
280 | .rates = SUPPORTED_RATES, | 365 | .rates = SUPPORTED_RATES, |
281 | .maxbps = SUPPORTED_MAXBPS, | 366 | .maxbps = SUPPORTED_MAXBPS, |
282 | .formats = SUPPORTED_FORMATS, | 367 | .formats = SUPPORTED_FORMATS, |
283 | .ops = { | 368 | .ops = { |
284 | .open = nvhdmi_dig_playback_pcm_open, | 369 | .open = nvhdmi_dig_playback_pcm_open, |
285 | .close = nvhdmi_dig_playback_pcm_close_8ch, | 370 | .close = nvhdmi_dig_playback_pcm_close_8ch_7x, |
286 | .prepare = nvhdmi_dig_playback_pcm_prepare_8ch | 371 | .prepare = nvhdmi_dig_playback_pcm_prepare_8ch |
287 | }, | 372 | }, |
288 | }; | 373 | }; |
@@ -291,7 +376,7 @@ static struct hda_pcm_stream nvhdmi_pcm_digital_playback_2ch = { | |||
291 | .substreams = 1, | 376 | .substreams = 1, |
292 | .channels_min = 2, | 377 | .channels_min = 2, |
293 | .channels_max = 2, | 378 | .channels_max = 2, |
294 | .nid = Nv_Master_Convert_nid, | 379 | .nid = nvhdmi_master_con_nid_7x, |
295 | .rates = SUPPORTED_RATES, | 380 | .rates = SUPPORTED_RATES, |
296 | .maxbps = SUPPORTED_MAXBPS, | 381 | .maxbps = SUPPORTED_MAXBPS, |
297 | .formats = SUPPORTED_FORMATS, | 382 | .formats = SUPPORTED_FORMATS, |
@@ -302,10 +387,36 @@ static struct hda_pcm_stream nvhdmi_pcm_digital_playback_2ch = { | |||
302 | }, | 387 | }, |
303 | }; | 388 | }; |
304 | 389 | ||
305 | static int nvhdmi_build_pcms_8ch(struct hda_codec *codec) | 390 | static int nvhdmi_build_pcms_8ch_89(struct hda_codec *codec) |
391 | { | ||
392 | struct hdmi_spec *spec = codec->spec; | ||
393 | struct hda_pcm *info = spec->pcm_rec; | ||
394 | int i; | ||
395 | |||
396 | codec->num_pcms = spec->num_cvts; | ||
397 | codec->pcm_info = info; | ||
398 | |||
399 | for (i = 0; i < codec->num_pcms; i++, info++) { | ||
400 | unsigned int chans; | ||
401 | |||
402 | chans = get_wcaps(codec, spec->cvt[i]); | ||
403 | chans = get_wcaps_channels(chans); | ||
404 | |||
405 | info->name = nvhdmi_pcm_names[i]; | ||
406 | info->pcm_type = HDA_PCM_TYPE_HDMI; | ||
407 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] | ||
408 | = nvhdmi_pcm_digital_playback_8ch_89; | ||
409 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->cvt[i]; | ||
410 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; | ||
411 | } | ||
412 | |||
413 | return 0; | ||
414 | } | ||
415 | |||
416 | static int nvhdmi_build_pcms_8ch_7x(struct hda_codec *codec) | ||
306 | { | 417 | { |
307 | struct nvhdmi_spec *spec = codec->spec; | 418 | struct hdmi_spec *spec = codec->spec; |
308 | struct hda_pcm *info = &spec->pcm_rec; | 419 | struct hda_pcm *info = spec->pcm_rec; |
309 | 420 | ||
310 | codec->num_pcms = 1; | 421 | codec->num_pcms = 1; |
311 | codec->pcm_info = info; | 422 | codec->pcm_info = info; |
@@ -313,15 +424,15 @@ static int nvhdmi_build_pcms_8ch(struct hda_codec *codec) | |||
313 | info->name = "NVIDIA HDMI"; | 424 | info->name = "NVIDIA HDMI"; |
314 | info->pcm_type = HDA_PCM_TYPE_HDMI; | 425 | info->pcm_type = HDA_PCM_TYPE_HDMI; |
315 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] | 426 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] |
316 | = nvhdmi_pcm_digital_playback_8ch; | 427 | = nvhdmi_pcm_digital_playback_8ch_7x; |
317 | 428 | ||
318 | return 0; | 429 | return 0; |
319 | } | 430 | } |
320 | 431 | ||
321 | static int nvhdmi_build_pcms_2ch(struct hda_codec *codec) | 432 | static int nvhdmi_build_pcms_2ch(struct hda_codec *codec) |
322 | { | 433 | { |
323 | struct nvhdmi_spec *spec = codec->spec; | 434 | struct hdmi_spec *spec = codec->spec; |
324 | struct hda_pcm *info = &spec->pcm_rec; | 435 | struct hda_pcm *info = spec->pcm_rec; |
325 | 436 | ||
326 | codec->num_pcms = 1; | 437 | codec->num_pcms = 1; |
327 | codec->pcm_info = info; | 438 | codec->pcm_info = info; |
@@ -334,14 +445,17 @@ static int nvhdmi_build_pcms_2ch(struct hda_codec *codec) | |||
334 | return 0; | 445 | return 0; |
335 | } | 446 | } |
336 | 447 | ||
337 | static void nvhdmi_free(struct hda_codec *codec) | 448 | static struct hda_codec_ops nvhdmi_patch_ops_8ch_89 = { |
338 | { | 449 | .build_controls = nvhdmi_build_controls, |
339 | kfree(codec->spec); | 450 | .build_pcms = nvhdmi_build_pcms_8ch_89, |
340 | } | 451 | .init = nvhdmi_init, |
452 | .free = nvhdmi_free, | ||
453 | .unsol_event = hdmi_unsol_event, | ||
454 | }; | ||
341 | 455 | ||
342 | static struct hda_codec_ops nvhdmi_patch_ops_8ch = { | 456 | static struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = { |
343 | .build_controls = nvhdmi_build_controls, | 457 | .build_controls = nvhdmi_build_controls, |
344 | .build_pcms = nvhdmi_build_pcms_8ch, | 458 | .build_pcms = nvhdmi_build_pcms_8ch_7x, |
345 | .init = nvhdmi_init, | 459 | .init = nvhdmi_init, |
346 | .free = nvhdmi_free, | 460 | .free = nvhdmi_free, |
347 | }; | 461 | }; |
@@ -353,9 +467,36 @@ static struct hda_codec_ops nvhdmi_patch_ops_2ch = { | |||
353 | .free = nvhdmi_free, | 467 | .free = nvhdmi_free, |
354 | }; | 468 | }; |
355 | 469 | ||
356 | static int patch_nvhdmi_8ch(struct hda_codec *codec) | 470 | static int patch_nvhdmi_8ch_89(struct hda_codec *codec) |
471 | { | ||
472 | struct hdmi_spec *spec; | ||
473 | int i; | ||
474 | |||
475 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
476 | if (spec == NULL) | ||
477 | return -ENOMEM; | ||
478 | |||
479 | codec->spec = spec; | ||
480 | spec->codec_type = HDA_CODEC_NVIDIA_MCP89; | ||
481 | |||
482 | if (hdmi_parse_codec(codec) < 0) { | ||
483 | codec->spec = NULL; | ||
484 | kfree(spec); | ||
485 | return -EINVAL; | ||
486 | } | ||
487 | codec->patch_ops = nvhdmi_patch_ops_8ch_89; | ||
488 | |||
489 | for (i = 0; i < spec->num_pins; i++) | ||
490 | snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i); | ||
491 | |||
492 | init_channel_allocations(); | ||
493 | |||
494 | return 0; | ||
495 | } | ||
496 | |||
497 | static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) | ||
357 | { | 498 | { |
358 | struct nvhdmi_spec *spec; | 499 | struct hdmi_spec *spec; |
359 | 500 | ||
360 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 501 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
361 | if (spec == NULL) | 502 | if (spec == NULL) |
@@ -365,16 +506,17 @@ static int patch_nvhdmi_8ch(struct hda_codec *codec) | |||
365 | 506 | ||
366 | spec->multiout.num_dacs = 0; /* no analog */ | 507 | spec->multiout.num_dacs = 0; /* no analog */ |
367 | spec->multiout.max_channels = 8; | 508 | spec->multiout.max_channels = 8; |
368 | spec->multiout.dig_out_nid = Nv_Master_Convert_nid; | 509 | spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; |
510 | spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; | ||
369 | 511 | ||
370 | codec->patch_ops = nvhdmi_patch_ops_8ch; | 512 | codec->patch_ops = nvhdmi_patch_ops_8ch_7x; |
371 | 513 | ||
372 | return 0; | 514 | return 0; |
373 | } | 515 | } |
374 | 516 | ||
375 | static int patch_nvhdmi_2ch(struct hda_codec *codec) | 517 | static int patch_nvhdmi_2ch(struct hda_codec *codec) |
376 | { | 518 | { |
377 | struct nvhdmi_spec *spec; | 519 | struct hdmi_spec *spec; |
378 | 520 | ||
379 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 521 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
380 | if (spec == NULL) | 522 | if (spec == NULL) |
@@ -384,7 +526,8 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec) | |||
384 | 526 | ||
385 | spec->multiout.num_dacs = 0; /* no analog */ | 527 | spec->multiout.num_dacs = 0; /* no analog */ |
386 | spec->multiout.max_channels = 2; | 528 | spec->multiout.max_channels = 2; |
387 | spec->multiout.dig_out_nid = Nv_Master_Convert_nid; | 529 | spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; |
530 | spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; | ||
388 | 531 | ||
389 | codec->patch_ops = nvhdmi_patch_ops_2ch; | 532 | codec->patch_ops = nvhdmi_patch_ops_2ch; |
390 | 533 | ||
@@ -395,13 +538,24 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec) | |||
395 | * patch entries | 538 | * patch entries |
396 | */ | 539 | */ |
397 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { | 540 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { |
398 | { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | ||
399 | { .id = 0x10de0003, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | ||
400 | { .id = 0x10de0005, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | ||
401 | { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, | ||
402 | { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch }, | ||
403 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, | 541 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, |
404 | { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, | 542 | { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, |
543 | { .id = 0x10de0002, .name = "MCP77/78 HDMI", | ||
544 | .patch = patch_nvhdmi_8ch_7x }, | ||
545 | { .id = 0x10de0003, .name = "MCP77/78 HDMI", | ||
546 | .patch = patch_nvhdmi_8ch_7x }, | ||
547 | { .id = 0x10de0005, .name = "MCP77/78 HDMI", | ||
548 | .patch = patch_nvhdmi_8ch_7x }, | ||
549 | { .id = 0x10de0006, .name = "MCP77/78 HDMI", | ||
550 | .patch = patch_nvhdmi_8ch_7x }, | ||
551 | { .id = 0x10de0007, .name = "MCP79/7A HDMI", | ||
552 | .patch = patch_nvhdmi_8ch_7x }, | ||
553 | { .id = 0x10de000c, .name = "MCP89 HDMI", | ||
554 | .patch = patch_nvhdmi_8ch_89 }, | ||
555 | { .id = 0x10de000b, .name = "GT21x HDMI", | ||
556 | .patch = patch_nvhdmi_8ch_89 }, | ||
557 | { .id = 0x10de000d, .name = "GT240 HDMI", | ||
558 | .patch = patch_nvhdmi_8ch_89 }, | ||
405 | {} /* terminator */ | 559 | {} /* terminator */ |
406 | }; | 560 | }; |
407 | 561 | ||
@@ -412,9 +566,12 @@ MODULE_ALIAS("snd-hda-codec-id:10de0006"); | |||
412 | MODULE_ALIAS("snd-hda-codec-id:10de0007"); | 566 | MODULE_ALIAS("snd-hda-codec-id:10de0007"); |
413 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); | 567 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); |
414 | MODULE_ALIAS("snd-hda-codec-id:10de8001"); | 568 | MODULE_ALIAS("snd-hda-codec-id:10de8001"); |
569 | MODULE_ALIAS("snd-hda-codec-id:10de000c"); | ||
570 | MODULE_ALIAS("snd-hda-codec-id:10de000b"); | ||
571 | MODULE_ALIAS("snd-hda-codec-id:10de000d"); | ||
415 | 572 | ||
416 | MODULE_LICENSE("GPL"); | 573 | MODULE_LICENSE("GPL"); |
417 | MODULE_DESCRIPTION("Nvidia HDMI HD-audio codec"); | 574 | MODULE_DESCRIPTION("NVIDIA HDMI HD-audio codec"); |
418 | 575 | ||
419 | static struct hda_codec_preset_list nvhdmi_list = { | 576 | static struct hda_codec_preset_list nvhdmi_list = { |
420 | .preset = snd_hda_preset_nvhdmi, | 577 | .preset = snd_hda_preset_nvhdmi, |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 3f92def752fd..5d2fbb87b871 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -131,8 +131,10 @@ enum { | |||
131 | enum { | 131 | enum { |
132 | ALC269_BASIC, | 132 | ALC269_BASIC, |
133 | ALC269_QUANTA_FL1, | 133 | ALC269_QUANTA_FL1, |
134 | ALC269_ASUS_AMIC, | 134 | ALC269_AMIC, |
135 | ALC269_ASUS_DMIC, | 135 | ALC269_DMIC, |
136 | ALC269VB_AMIC, | ||
137 | ALC269VB_DMIC, | ||
136 | ALC269_FUJITSU, | 138 | ALC269_FUJITSU, |
137 | ALC269_LIFEBOOK, | 139 | ALC269_LIFEBOOK, |
138 | ALC269_AUTO, | 140 | ALC269_AUTO, |
@@ -207,8 +209,10 @@ enum { | |||
207 | ALC882_ASUS_A7J, | 209 | ALC882_ASUS_A7J, |
208 | ALC882_ASUS_A7M, | 210 | ALC882_ASUS_A7M, |
209 | ALC885_MACPRO, | 211 | ALC885_MACPRO, |
212 | ALC885_MBA21, | ||
210 | ALC885_MBP3, | 213 | ALC885_MBP3, |
211 | ALC885_MB5, | 214 | ALC885_MB5, |
215 | ALC885_MACMINI3, | ||
212 | ALC885_IMAC24, | 216 | ALC885_IMAC24, |
213 | ALC885_IMAC91, | 217 | ALC885_IMAC91, |
214 | ALC883_3ST_2ch_DIG, | 218 | ALC883_3ST_2ch_DIG, |
@@ -338,7 +342,7 @@ struct alc_spec { | |||
338 | void (*init_hook)(struct hda_codec *codec); | 342 | void (*init_hook)(struct hda_codec *codec); |
339 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); | 343 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
340 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 344 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
341 | void (*power_hook)(struct hda_codec *codec, int power); | 345 | void (*power_hook)(struct hda_codec *codec); |
342 | #endif | 346 | #endif |
343 | 347 | ||
344 | /* for pin sensing */ | 348 | /* for pin sensing */ |
@@ -391,7 +395,7 @@ struct alc_config_preset { | |||
391 | void (*init_hook)(struct hda_codec *); | 395 | void (*init_hook)(struct hda_codec *); |
392 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 396 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
393 | struct hda_amp_list *loopbacks; | 397 | struct hda_amp_list *loopbacks; |
394 | void (*power_hook)(struct hda_codec *codec, int power); | 398 | void (*power_hook)(struct hda_codec *codec); |
395 | #endif | 399 | #endif |
396 | }; | 400 | }; |
397 | 401 | ||
@@ -633,6 +637,7 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, | |||
633 | 637 | ||
634 | #define ALC_PIN_MODE(xname, nid, dir) \ | 638 | #define ALC_PIN_MODE(xname, nid, dir) \ |
635 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | 639 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
640 | .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ | ||
636 | .info = alc_pin_mode_info, \ | 641 | .info = alc_pin_mode_info, \ |
637 | .get = alc_pin_mode_get, \ | 642 | .get = alc_pin_mode_get, \ |
638 | .put = alc_pin_mode_put, \ | 643 | .put = alc_pin_mode_put, \ |
@@ -684,6 +689,7 @@ static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, | |||
684 | } | 689 | } |
685 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ | 690 | #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ |
686 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | 691 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
692 | .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ | ||
687 | .info = alc_gpio_data_info, \ | 693 | .info = alc_gpio_data_info, \ |
688 | .get = alc_gpio_data_get, \ | 694 | .get = alc_gpio_data_get, \ |
689 | .put = alc_gpio_data_put, \ | 695 | .put = alc_gpio_data_put, \ |
@@ -738,6 +744,7 @@ static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, | |||
738 | } | 744 | } |
739 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ | 745 | #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ |
740 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | 746 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
747 | .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ | ||
741 | .info = alc_spdif_ctrl_info, \ | 748 | .info = alc_spdif_ctrl_info, \ |
742 | .get = alc_spdif_ctrl_get, \ | 749 | .get = alc_spdif_ctrl_get, \ |
743 | .put = alc_spdif_ctrl_put, \ | 750 | .put = alc_spdif_ctrl_put, \ |
@@ -791,6 +798,7 @@ static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol, | |||
791 | 798 | ||
792 | #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ | 799 | #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ |
793 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ | 800 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ |
801 | .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ | ||
794 | .info = alc_eapd_ctrl_info, \ | 802 | .info = alc_eapd_ctrl_info, \ |
795 | .get = alc_eapd_ctrl_get, \ | 803 | .get = alc_eapd_ctrl_get, \ |
796 | .put = alc_eapd_ctrl_put, \ | 804 | .put = alc_eapd_ctrl_put, \ |
@@ -837,27 +845,6 @@ static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) | |||
837 | spec->init_verbs[spec->num_init_verbs++] = verb; | 845 | spec->init_verbs[spec->num_init_verbs++] = verb; |
838 | } | 846 | } |
839 | 847 | ||
840 | #ifdef CONFIG_PROC_FS | ||
841 | /* | ||
842 | * hook for proc | ||
843 | */ | ||
844 | static void print_realtek_coef(struct snd_info_buffer *buffer, | ||
845 | struct hda_codec *codec, hda_nid_t nid) | ||
846 | { | ||
847 | int coeff; | ||
848 | |||
849 | if (nid != 0x20) | ||
850 | return; | ||
851 | coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0); | ||
852 | snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff); | ||
853 | coeff = snd_hda_codec_read(codec, nid, 0, | ||
854 | AC_VERB_GET_COEF_INDEX, 0); | ||
855 | snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff); | ||
856 | } | ||
857 | #else | ||
858 | #define print_realtek_coef NULL | ||
859 | #endif | ||
860 | |||
861 | /* | 848 | /* |
862 | * set up from the preset table | 849 | * set up from the preset table |
863 | */ | 850 | */ |
@@ -1093,6 +1080,16 @@ static void alc889_coef_init(struct hda_codec *codec) | |||
1093 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); | 1080 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
1094 | } | 1081 | } |
1095 | 1082 | ||
1083 | /* turn on/off EAPD control (only if available) */ | ||
1084 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) | ||
1085 | { | ||
1086 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) | ||
1087 | return; | ||
1088 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) | ||
1089 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | ||
1090 | on ? 2 : 0); | ||
1091 | } | ||
1092 | |||
1096 | static void alc_auto_init_amp(struct hda_codec *codec, int type) | 1093 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
1097 | { | 1094 | { |
1098 | unsigned int tmp; | 1095 | unsigned int tmp; |
@@ -1110,25 +1107,22 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type) | |||
1110 | case ALC_INIT_DEFAULT: | 1107 | case ALC_INIT_DEFAULT: |
1111 | switch (codec->vendor_id) { | 1108 | switch (codec->vendor_id) { |
1112 | case 0x10ec0260: | 1109 | case 0x10ec0260: |
1113 | snd_hda_codec_write(codec, 0x0f, 0, | 1110 | set_eapd(codec, 0x0f, 1); |
1114 | AC_VERB_SET_EAPD_BTLENABLE, 2); | 1111 | set_eapd(codec, 0x10, 1); |
1115 | snd_hda_codec_write(codec, 0x10, 0, | ||
1116 | AC_VERB_SET_EAPD_BTLENABLE, 2); | ||
1117 | break; | 1112 | break; |
1118 | case 0x10ec0262: | 1113 | case 0x10ec0262: |
1119 | case 0x10ec0267: | 1114 | case 0x10ec0267: |
1120 | case 0x10ec0268: | 1115 | case 0x10ec0268: |
1121 | case 0x10ec0269: | 1116 | case 0x10ec0269: |
1117 | case 0x10ec0270: | ||
1122 | case 0x10ec0272: | 1118 | case 0x10ec0272: |
1123 | case 0x10ec0660: | 1119 | case 0x10ec0660: |
1124 | case 0x10ec0662: | 1120 | case 0x10ec0662: |
1125 | case 0x10ec0663: | 1121 | case 0x10ec0663: |
1126 | case 0x10ec0862: | 1122 | case 0x10ec0862: |
1127 | case 0x10ec0889: | 1123 | case 0x10ec0889: |
1128 | snd_hda_codec_write(codec, 0x14, 0, | 1124 | set_eapd(codec, 0x14, 1); |
1129 | AC_VERB_SET_EAPD_BTLENABLE, 2); | 1125 | set_eapd(codec, 0x15, 1); |
1130 | snd_hda_codec_write(codec, 0x15, 0, | ||
1131 | AC_VERB_SET_EAPD_BTLENABLE, 2); | ||
1132 | break; | 1126 | break; |
1133 | } | 1127 | } |
1134 | switch (codec->vendor_id) { | 1128 | switch (codec->vendor_id) { |
@@ -1155,6 +1149,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type) | |||
1155 | case 0x10ec0888: | 1149 | case 0x10ec0888: |
1156 | alc888_coef_init(codec); | 1150 | alc888_coef_init(codec); |
1157 | break; | 1151 | break; |
1152 | #if 0 /* XXX: This may cause the silent output on speaker on some machines */ | ||
1158 | case 0x10ec0267: | 1153 | case 0x10ec0267: |
1159 | case 0x10ec0268: | 1154 | case 0x10ec0268: |
1160 | snd_hda_codec_write(codec, 0x20, 0, | 1155 | snd_hda_codec_write(codec, 0x20, 0, |
@@ -1167,6 +1162,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type) | |||
1167 | AC_VERB_SET_PROC_COEF, | 1162 | AC_VERB_SET_PROC_COEF, |
1168 | tmp | 0x3000); | 1163 | tmp | 0x3000); |
1169 | break; | 1164 | break; |
1165 | #endif /* XXX */ | ||
1170 | } | 1166 | } |
1171 | break; | 1167 | break; |
1172 | } | 1168 | } |
@@ -1258,7 +1254,7 @@ static void alc_init_auto_mic(struct hda_codec *codec) | |||
1258 | */ | 1254 | */ |
1259 | static int alc_subsystem_id(struct hda_codec *codec, | 1255 | static int alc_subsystem_id(struct hda_codec *codec, |
1260 | hda_nid_t porta, hda_nid_t porte, | 1256 | hda_nid_t porta, hda_nid_t porte, |
1261 | hda_nid_t portd) | 1257 | hda_nid_t portd, hda_nid_t porti) |
1262 | { | 1258 | { |
1263 | unsigned int ass, tmp, i; | 1259 | unsigned int ass, tmp, i; |
1264 | unsigned nid; | 1260 | unsigned nid; |
@@ -1284,7 +1280,7 @@ static int alc_subsystem_id(struct hda_codec *codec, | |||
1284 | snd_printd("realtek: No valid SSID, " | 1280 | snd_printd("realtek: No valid SSID, " |
1285 | "checking pincfg 0x%08x for NID 0x%x\n", | 1281 | "checking pincfg 0x%08x for NID 0x%x\n", |
1286 | ass, nid); | 1282 | ass, nid); |
1287 | if (!(ass & 1) && !(ass & 0x100000)) | 1283 | if (!(ass & 1)) |
1288 | return 0; | 1284 | return 0; |
1289 | if ((ass >> 30) != 1) /* no physical connection */ | 1285 | if ((ass >> 30) != 1) /* no physical connection */ |
1290 | return 0; | 1286 | return 0; |
@@ -1344,6 +1340,8 @@ do_sku: | |||
1344 | nid = porte; | 1340 | nid = porte; |
1345 | else if (tmp == 2) | 1341 | else if (tmp == 2) |
1346 | nid = portd; | 1342 | nid = portd; |
1343 | else if (tmp == 3) | ||
1344 | nid = porti; | ||
1347 | else | 1345 | else |
1348 | return 1; | 1346 | return 1; |
1349 | for (i = 0; i < spec->autocfg.line_outs; i++) | 1347 | for (i = 0; i < spec->autocfg.line_outs; i++) |
@@ -1358,9 +1356,10 @@ do_sku: | |||
1358 | } | 1356 | } |
1359 | 1357 | ||
1360 | static void alc_ssid_check(struct hda_codec *codec, | 1358 | static void alc_ssid_check(struct hda_codec *codec, |
1361 | hda_nid_t porta, hda_nid_t porte, hda_nid_t portd) | 1359 | hda_nid_t porta, hda_nid_t porte, |
1360 | hda_nid_t portd, hda_nid_t porti) | ||
1362 | { | 1361 | { |
1363 | if (!alc_subsystem_id(codec, porta, porte, portd)) { | 1362 | if (!alc_subsystem_id(codec, porta, porte, portd, porti)) { |
1364 | struct alc_spec *spec = codec->spec; | 1363 | struct alc_spec *spec = codec->spec; |
1365 | snd_printd("realtek: " | 1364 | snd_printd("realtek: " |
1366 | "Enable default setup for auto mode as fallback\n"); | 1365 | "Enable default setup for auto mode as fallback\n"); |
@@ -1833,16 +1832,6 @@ static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec) | |||
1833 | spec->autocfg.speaker_pins[2] = 0x1b; | 1832 | spec->autocfg.speaker_pins[2] = 0x1b; |
1834 | } | 1833 | } |
1835 | 1834 | ||
1836 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
1837 | static void alc889_power_eapd(struct hda_codec *codec, int power) | ||
1838 | { | ||
1839 | snd_hda_codec_write(codec, 0x14, 0, | ||
1840 | AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0); | ||
1841 | snd_hda_codec_write(codec, 0x15, 0, | ||
1842 | AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0); | ||
1843 | } | ||
1844 | #endif | ||
1845 | |||
1846 | /* | 1835 | /* |
1847 | * ALC880 3-stack model | 1836 | * ALC880 3-stack model |
1848 | * | 1837 | * |
@@ -2445,6 +2434,15 @@ static const char *alc_slave_sws[] = { | |||
2445 | * build control elements | 2434 | * build control elements |
2446 | */ | 2435 | */ |
2447 | 2436 | ||
2437 | #define NID_MAPPING (-1) | ||
2438 | |||
2439 | #define SUBDEV_SPEAKER_ (0 << 6) | ||
2440 | #define SUBDEV_HP_ (1 << 6) | ||
2441 | #define SUBDEV_LINE_ (2 << 6) | ||
2442 | #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) | ||
2443 | #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) | ||
2444 | #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) | ||
2445 | |||
2448 | static void alc_free_kctls(struct hda_codec *codec); | 2446 | static void alc_free_kctls(struct hda_codec *codec); |
2449 | 2447 | ||
2450 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | 2448 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
@@ -2459,8 +2457,11 @@ static struct snd_kcontrol_new alc_beep_mixer[] = { | |||
2459 | static int alc_build_controls(struct hda_codec *codec) | 2457 | static int alc_build_controls(struct hda_codec *codec) |
2460 | { | 2458 | { |
2461 | struct alc_spec *spec = codec->spec; | 2459 | struct alc_spec *spec = codec->spec; |
2462 | int err; | 2460 | struct snd_kcontrol *kctl; |
2463 | int i; | 2461 | struct snd_kcontrol_new *knew; |
2462 | int i, j, err; | ||
2463 | unsigned int u; | ||
2464 | hda_nid_t nid; | ||
2464 | 2465 | ||
2465 | for (i = 0; i < spec->num_mixers; i++) { | 2466 | for (i = 0; i < spec->num_mixers; i++) { |
2466 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | 2467 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
@@ -2501,8 +2502,7 @@ static int alc_build_controls(struct hda_codec *codec) | |||
2501 | if (!kctl) | 2502 | if (!kctl) |
2502 | return -ENOMEM; | 2503 | return -ENOMEM; |
2503 | kctl->private_value = spec->beep_amp; | 2504 | kctl->private_value = spec->beep_amp; |
2504 | err = snd_hda_ctl_add(codec, | 2505 | err = snd_hda_ctl_add(codec, 0, kctl); |
2505 | get_amp_nid_(spec->beep_amp), kctl); | ||
2506 | if (err < 0) | 2506 | if (err < 0) |
2507 | return err; | 2507 | return err; |
2508 | } | 2508 | } |
@@ -2529,6 +2529,75 @@ static int alc_build_controls(struct hda_codec *codec) | |||
2529 | } | 2529 | } |
2530 | 2530 | ||
2531 | alc_free_kctls(codec); /* no longer needed */ | 2531 | alc_free_kctls(codec); /* no longer needed */ |
2532 | |||
2533 | /* assign Capture Source enums to NID */ | ||
2534 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); | ||
2535 | if (!kctl) | ||
2536 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); | ||
2537 | for (i = 0; kctl && i < kctl->count; i++) { | ||
2538 | hda_nid_t *nids = spec->capsrc_nids; | ||
2539 | if (!nids) | ||
2540 | nids = spec->adc_nids; | ||
2541 | err = snd_hda_add_nid(codec, kctl, i, nids[i]); | ||
2542 | if (err < 0) | ||
2543 | return err; | ||
2544 | } | ||
2545 | if (spec->cap_mixer) { | ||
2546 | const char *kname = kctl ? kctl->id.name : NULL; | ||
2547 | for (knew = spec->cap_mixer; knew->name; knew++) { | ||
2548 | if (kname && strcmp(knew->name, kname) == 0) | ||
2549 | continue; | ||
2550 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); | ||
2551 | for (i = 0; kctl && i < kctl->count; i++) { | ||
2552 | err = snd_hda_add_nid(codec, kctl, i, | ||
2553 | spec->adc_nids[i]); | ||
2554 | if (err < 0) | ||
2555 | return err; | ||
2556 | } | ||
2557 | } | ||
2558 | } | ||
2559 | |||
2560 | /* other nid->control mapping */ | ||
2561 | for (i = 0; i < spec->num_mixers; i++) { | ||
2562 | for (knew = spec->mixers[i]; knew->name; knew++) { | ||
2563 | if (knew->iface != NID_MAPPING) | ||
2564 | continue; | ||
2565 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); | ||
2566 | if (kctl == NULL) | ||
2567 | continue; | ||
2568 | u = knew->subdevice; | ||
2569 | for (j = 0; j < 4; j++, u >>= 8) { | ||
2570 | nid = u & 0x3f; | ||
2571 | if (nid == 0) | ||
2572 | continue; | ||
2573 | switch (u & 0xc0) { | ||
2574 | case SUBDEV_SPEAKER_: | ||
2575 | nid = spec->autocfg.speaker_pins[nid]; | ||
2576 | break; | ||
2577 | case SUBDEV_LINE_: | ||
2578 | nid = spec->autocfg.line_out_pins[nid]; | ||
2579 | break; | ||
2580 | case SUBDEV_HP_: | ||
2581 | nid = spec->autocfg.hp_pins[nid]; | ||
2582 | break; | ||
2583 | default: | ||
2584 | continue; | ||
2585 | } | ||
2586 | err = snd_hda_add_nid(codec, kctl, 0, nid); | ||
2587 | if (err < 0) | ||
2588 | return err; | ||
2589 | } | ||
2590 | u = knew->private_value; | ||
2591 | for (j = 0; j < 4; j++, u >>= 8) { | ||
2592 | nid = u & 0xff; | ||
2593 | if (nid == 0) | ||
2594 | continue; | ||
2595 | err = snd_hda_add_nid(codec, kctl, 0, nid); | ||
2596 | if (err < 0) | ||
2597 | return err; | ||
2598 | } | ||
2599 | } | ||
2600 | } | ||
2532 | return 0; | 2601 | return 0; |
2533 | } | 2602 | } |
2534 | 2603 | ||
@@ -3611,6 +3680,11 @@ static int alc_build_pcms(struct hda_codec *codec) | |||
3611 | return 0; | 3680 | return 0; |
3612 | } | 3681 | } |
3613 | 3682 | ||
3683 | static inline void alc_shutup(struct hda_codec *codec) | ||
3684 | { | ||
3685 | snd_hda_shutup_pins(codec); | ||
3686 | } | ||
3687 | |||
3614 | static void alc_free_kctls(struct hda_codec *codec) | 3688 | static void alc_free_kctls(struct hda_codec *codec) |
3615 | { | 3689 | { |
3616 | struct alc_spec *spec = codec->spec; | 3690 | struct alc_spec *spec = codec->spec; |
@@ -3631,17 +3705,44 @@ static void alc_free(struct hda_codec *codec) | |||
3631 | if (!spec) | 3705 | if (!spec) |
3632 | return; | 3706 | return; |
3633 | 3707 | ||
3708 | alc_shutup(codec); | ||
3634 | alc_free_kctls(codec); | 3709 | alc_free_kctls(codec); |
3635 | kfree(spec); | 3710 | kfree(spec); |
3636 | snd_hda_detach_beep_device(codec); | 3711 | snd_hda_detach_beep_device(codec); |
3637 | } | 3712 | } |
3638 | 3713 | ||
3639 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 3714 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
3715 | static void alc_power_eapd(struct hda_codec *codec) | ||
3716 | { | ||
3717 | /* We currently only handle front, HP */ | ||
3718 | switch (codec->vendor_id) { | ||
3719 | case 0x10ec0260: | ||
3720 | set_eapd(codec, 0x0f, 0); | ||
3721 | set_eapd(codec, 0x10, 0); | ||
3722 | break; | ||
3723 | case 0x10ec0262: | ||
3724 | case 0x10ec0267: | ||
3725 | case 0x10ec0268: | ||
3726 | case 0x10ec0269: | ||
3727 | case 0x10ec0270: | ||
3728 | case 0x10ec0272: | ||
3729 | case 0x10ec0660: | ||
3730 | case 0x10ec0662: | ||
3731 | case 0x10ec0663: | ||
3732 | case 0x10ec0862: | ||
3733 | case 0x10ec0889: | ||
3734 | set_eapd(codec, 0x14, 0); | ||
3735 | set_eapd(codec, 0x15, 0); | ||
3736 | break; | ||
3737 | } | ||
3738 | } | ||
3739 | |||
3640 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) | 3740 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) |
3641 | { | 3741 | { |
3642 | struct alc_spec *spec = codec->spec; | 3742 | struct alc_spec *spec = codec->spec; |
3743 | alc_shutup(codec); | ||
3643 | if (spec && spec->power_hook) | 3744 | if (spec && spec->power_hook) |
3644 | spec->power_hook(codec, 0); | 3745 | spec->power_hook(codec); |
3645 | return 0; | 3746 | return 0; |
3646 | } | 3747 | } |
3647 | #endif | 3748 | #endif |
@@ -3649,16 +3750,9 @@ static int alc_suspend(struct hda_codec *codec, pm_message_t state) | |||
3649 | #ifdef SND_HDA_NEEDS_RESUME | 3750 | #ifdef SND_HDA_NEEDS_RESUME |
3650 | static int alc_resume(struct hda_codec *codec) | 3751 | static int alc_resume(struct hda_codec *codec) |
3651 | { | 3752 | { |
3652 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3653 | struct alc_spec *spec = codec->spec; | ||
3654 | #endif | ||
3655 | codec->patch_ops.init(codec); | 3753 | codec->patch_ops.init(codec); |
3656 | snd_hda_codec_resume_amp(codec); | 3754 | snd_hda_codec_resume_amp(codec); |
3657 | snd_hda_codec_resume_cache(codec); | 3755 | snd_hda_codec_resume_cache(codec); |
3658 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
3659 | if (spec && spec->power_hook) | ||
3660 | spec->power_hook(codec, 1); | ||
3661 | #endif | ||
3662 | return 0; | 3756 | return 0; |
3663 | } | 3757 | } |
3664 | #endif | 3758 | #endif |
@@ -3678,6 +3772,7 @@ static struct hda_codec_ops alc_patch_ops = { | |||
3678 | .suspend = alc_suspend, | 3772 | .suspend = alc_suspend, |
3679 | .check_power_status = alc_check_power_status, | 3773 | .check_power_status = alc_check_power_status, |
3680 | #endif | 3774 | #endif |
3775 | .reboot_notify = alc_shutup, | ||
3681 | }; | 3776 | }; |
3682 | 3777 | ||
3683 | 3778 | ||
@@ -3834,6 +3929,7 @@ static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, | |||
3834 | #define PIN_CTL_TEST(xname,nid) { \ | 3929 | #define PIN_CTL_TEST(xname,nid) { \ |
3835 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 3930 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
3836 | .name = xname, \ | 3931 | .name = xname, \ |
3932 | .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ | ||
3837 | .info = alc_test_pin_ctl_info, \ | 3933 | .info = alc_test_pin_ctl_info, \ |
3838 | .get = alc_test_pin_ctl_get, \ | 3934 | .get = alc_test_pin_ctl_get, \ |
3839 | .put = alc_test_pin_ctl_put, \ | 3935 | .put = alc_test_pin_ctl_put, \ |
@@ -3843,6 +3939,7 @@ static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, | |||
3843 | #define PIN_SRC_TEST(xname,nid) { \ | 3939 | #define PIN_SRC_TEST(xname,nid) { \ |
3844 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 3940 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
3845 | .name = xname, \ | 3941 | .name = xname, \ |
3942 | .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ | ||
3846 | .info = alc_test_pin_src_info, \ | 3943 | .info = alc_test_pin_src_info, \ |
3847 | .get = alc_test_pin_src_get, \ | 3944 | .get = alc_test_pin_src_get, \ |
3848 | .put = alc_test_pin_src_put, \ | 3945 | .put = alc_test_pin_src_put, \ |
@@ -4382,7 +4479,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, | |||
4382 | if (!knew->name) | 4479 | if (!knew->name) |
4383 | return -ENOMEM; | 4480 | return -ENOMEM; |
4384 | if (get_amp_nid_(val)) | 4481 | if (get_amp_nid_(val)) |
4385 | knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); | 4482 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
4386 | knew->private_value = val; | 4483 | knew->private_value = val; |
4387 | return 0; | 4484 | return 0; |
4388 | } | 4485 | } |
@@ -4765,7 +4862,7 @@ static int alc880_parse_auto_config(struct hda_codec *codec) | |||
4765 | spec->num_mux_defs = 1; | 4862 | spec->num_mux_defs = 1; |
4766 | spec->input_mux = &spec->private_imux[0]; | 4863 | spec->input_mux = &spec->private_imux[0]; |
4767 | 4864 | ||
4768 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | 4865 | alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); |
4769 | 4866 | ||
4770 | return 1; | 4867 | return 1; |
4771 | } | 4868 | } |
@@ -4818,7 +4915,7 @@ static void fixup_automic_adc(struct hda_codec *codec) | |||
4818 | static void fixup_single_adc(struct hda_codec *codec) | 4915 | static void fixup_single_adc(struct hda_codec *codec) |
4819 | { | 4916 | { |
4820 | struct alc_spec *spec = codec->spec; | 4917 | struct alc_spec *spec = codec->spec; |
4821 | hda_nid_t pin; | 4918 | hda_nid_t pin = 0; |
4822 | int i; | 4919 | int i; |
4823 | 4920 | ||
4824 | /* search for the input pin; there must be only one */ | 4921 | /* search for the input pin; there must be only one */ |
@@ -4969,7 +5066,6 @@ static int patch_alc880(struct hda_codec *codec) | |||
4969 | if (!spec->loopback.amplist) | 5066 | if (!spec->loopback.amplist) |
4970 | spec->loopback.amplist = alc880_loopbacks; | 5067 | spec->loopback.amplist = alc880_loopbacks; |
4971 | #endif | 5068 | #endif |
4972 | codec->proc_widget_hook = print_realtek_coef; | ||
4973 | 5069 | ||
4974 | return 0; | 5070 | return 0; |
4975 | } | 5071 | } |
@@ -5177,6 +5273,7 @@ static struct snd_kcontrol_new alc260_hp_output_mixer[] = { | |||
5177 | { | 5273 | { |
5178 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 5274 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
5179 | .name = "Master Playback Switch", | 5275 | .name = "Master Playback Switch", |
5276 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x11, | ||
5180 | .info = snd_ctl_boolean_mono_info, | 5277 | .info = snd_ctl_boolean_mono_info, |
5181 | .get = alc260_hp_master_sw_get, | 5278 | .get = alc260_hp_master_sw_get, |
5182 | .put = alc260_hp_master_sw_put, | 5279 | .put = alc260_hp_master_sw_put, |
@@ -5215,6 +5312,7 @@ static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { | |||
5215 | { | 5312 | { |
5216 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 5313 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
5217 | .name = "Master Playback Switch", | 5314 | .name = "Master Playback Switch", |
5315 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x11, | ||
5218 | .info = snd_ctl_boolean_mono_info, | 5316 | .info = snd_ctl_boolean_mono_info, |
5219 | .get = alc260_hp_master_sw_get, | 5317 | .get = alc260_hp_master_sw_get, |
5220 | .put = alc260_hp_master_sw_put, | 5318 | .put = alc260_hp_master_sw_put, |
@@ -6298,7 +6396,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec) | |||
6298 | spec->num_mux_defs = 1; | 6396 | spec->num_mux_defs = 1; |
6299 | spec->input_mux = &spec->private_imux[0]; | 6397 | spec->input_mux = &spec->private_imux[0]; |
6300 | 6398 | ||
6301 | alc_ssid_check(codec, 0x10, 0x15, 0x0f); | 6399 | alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0); |
6302 | 6400 | ||
6303 | return 1; | 6401 | return 1; |
6304 | } | 6402 | } |
@@ -6577,7 +6675,6 @@ static int patch_alc260(struct hda_codec *codec) | |||
6577 | if (!spec->loopback.amplist) | 6675 | if (!spec->loopback.amplist) |
6578 | spec->loopback.amplist = alc260_loopbacks; | 6676 | spec->loopback.amplist = alc260_loopbacks; |
6579 | #endif | 6677 | #endif |
6580 | codec->proc_widget_hook = print_realtek_coef; | ||
6581 | 6678 | ||
6582 | return 0; | 6679 | return 0; |
6583 | } | 6680 | } |
@@ -6659,6 +6756,14 @@ static struct hda_input_mux mb5_capture_source = { | |||
6659 | }, | 6756 | }, |
6660 | }; | 6757 | }; |
6661 | 6758 | ||
6759 | static struct hda_input_mux macmini3_capture_source = { | ||
6760 | .num_items = 2, | ||
6761 | .items = { | ||
6762 | { "Line", 0x2 }, | ||
6763 | { "CD", 0x4 }, | ||
6764 | }, | ||
6765 | }; | ||
6766 | |||
6662 | static struct hda_input_mux alc883_3stack_6ch_intel = { | 6767 | static struct hda_input_mux alc883_3stack_6ch_intel = { |
6663 | .num_items = 4, | 6768 | .num_items = 4, |
6664 | .items = { | 6769 | .items = { |
@@ -6847,6 +6952,13 @@ static struct hda_channel_mode alc882_sixstack_modes[2] = { | |||
6847 | { 8, alc882_sixstack_ch8_init }, | 6952 | { 8, alc882_sixstack_ch8_init }, |
6848 | }; | 6953 | }; |
6849 | 6954 | ||
6955 | |||
6956 | /* Macbook Air 2,1 */ | ||
6957 | |||
6958 | static struct hda_channel_mode alc885_mba21_ch_modes[1] = { | ||
6959 | { 2, NULL }, | ||
6960 | }; | ||
6961 | |||
6850 | /* | 6962 | /* |
6851 | * macbook pro ALC885 can switch LineIn to LineOut without losing Mic | 6963 | * macbook pro ALC885 can switch LineIn to LineOut without losing Mic |
6852 | */ | 6964 | */ |
@@ -6907,6 +7019,7 @@ static struct hda_channel_mode alc885_mb5_6ch_modes[2] = { | |||
6907 | { 6, alc885_mb5_ch6_init }, | 7019 | { 6, alc885_mb5_ch6_init }, |
6908 | }; | 7020 | }; |
6909 | 7021 | ||
7022 | #define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes | ||
6910 | 7023 | ||
6911 | /* | 7024 | /* |
6912 | * 2ch mode | 7025 | * 2ch mode |
@@ -7118,6 +7231,15 @@ static struct snd_kcontrol_new alc882_base_mixer[] = { | |||
7118 | { } /* end */ | 7231 | { } /* end */ |
7119 | }; | 7232 | }; |
7120 | 7233 | ||
7234 | /* Macbook Air 2,1 same control for HP and internal Speaker */ | ||
7235 | |||
7236 | static struct snd_kcontrol_new alc885_mba21_mixer[] = { | ||
7237 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | ||
7238 | HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT), | ||
7239 | { } | ||
7240 | }; | ||
7241 | |||
7242 | |||
7121 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { | 7243 | static struct snd_kcontrol_new alc885_mbp3_mixer[] = { |
7122 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | 7244 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
7123 | HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT), | 7245 | HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT), |
@@ -7151,6 +7273,21 @@ static struct snd_kcontrol_new alc885_mb5_mixer[] = { | |||
7151 | { } /* end */ | 7273 | { } /* end */ |
7152 | }; | 7274 | }; |
7153 | 7275 | ||
7276 | static struct snd_kcontrol_new alc885_macmini3_mixer[] = { | ||
7277 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | ||
7278 | HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), | ||
7279 | HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT), | ||
7280 | HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT), | ||
7281 | HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT), | ||
7282 | HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT), | ||
7283 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT), | ||
7284 | HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT), | ||
7285 | HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT), | ||
7286 | HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT), | ||
7287 | HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT), | ||
7288 | { } /* end */ | ||
7289 | }; | ||
7290 | |||
7154 | static struct snd_kcontrol_new alc885_imac91_mixer[] = { | 7291 | static struct snd_kcontrol_new alc885_imac91_mixer[] = { |
7155 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT), | 7292 | HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT), |
7156 | HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT), | 7293 | HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT), |
@@ -7242,29 +7379,18 @@ static struct snd_kcontrol_new alc882_chmode_mixer[] = { | |||
7242 | 7379 | ||
7243 | static struct hda_verb alc882_base_init_verbs[] = { | 7380 | static struct hda_verb alc882_base_init_verbs[] = { |
7244 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | 7381 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
7245 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7246 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7382 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7247 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 7383 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7248 | /* Rear mixer */ | 7384 | /* Rear mixer */ |
7249 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7250 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7385 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7251 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 7386 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7252 | /* CLFE mixer */ | 7387 | /* CLFE mixer */ |
7253 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7254 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7388 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7255 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 7389 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7256 | /* Side mixer */ | 7390 | /* Side mixer */ |
7257 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7258 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7391 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7259 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | 7392 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
7260 | 7393 | ||
7261 | /* mute analog input loopbacks */ | ||
7262 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7263 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7264 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7265 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7266 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7267 | |||
7268 | /* Front Pin: output 0 (0x0c) */ | 7394 | /* Front Pin: output 0 (0x0c) */ |
7269 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | 7395 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
7270 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 7396 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
@@ -7301,14 +7427,8 @@ static struct hda_verb alc882_base_init_verbs[] = { | |||
7301 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | 7427 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
7302 | /* Input mixer2 */ | 7428 | /* Input mixer2 */ |
7303 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 7429 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7304 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7305 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7306 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7307 | /* Input mixer3 */ | 7430 | /* Input mixer3 */ |
7308 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 7431 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7309 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7310 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7311 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7312 | /* ADC2: mute amp left and right */ | 7432 | /* ADC2: mute amp left and right */ |
7313 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7433 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7314 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, | 7434 | {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, |
@@ -7352,26 +7472,17 @@ static struct hda_verb alc_hp15_unsol_verbs[] = { | |||
7352 | 7472 | ||
7353 | static struct hda_verb alc885_init_verbs[] = { | 7473 | static struct hda_verb alc885_init_verbs[] = { |
7354 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | 7474 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
7355 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 7475 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7356 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7476 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
7357 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7358 | /* Rear mixer */ | 7477 | /* Rear mixer */ |
7359 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 7478 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7360 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7479 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
7361 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7362 | /* CLFE mixer */ | 7480 | /* CLFE mixer */ |
7363 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 7481 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7364 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7482 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
7365 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7366 | /* Side mixer */ | 7483 | /* Side mixer */ |
7367 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 7484 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7368 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7485 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
7369 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7370 | |||
7371 | /* mute analog input loopbacks */ | ||
7372 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7373 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7374 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7375 | 7486 | ||
7376 | /* Front HP Pin: output 0 (0x0c) */ | 7487 | /* Front HP Pin: output 0 (0x0c) */ |
7377 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | 7488 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, |
@@ -7405,17 +7516,11 @@ static struct hda_verb alc885_init_verbs[] = { | |||
7405 | 7516 | ||
7406 | /* Mixer elements: 0x18, , 0x1a, 0x1b */ | 7517 | /* Mixer elements: 0x18, , 0x1a, 0x1b */ |
7407 | /* Input mixer1 */ | 7518 | /* Input mixer1 */ |
7408 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, | 7519 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7409 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7410 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7411 | /* Input mixer2 */ | 7520 | /* Input mixer2 */ |
7412 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 7521 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7413 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7414 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7415 | /* Input mixer3 */ | 7522 | /* Input mixer3 */ |
7416 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, | 7523 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7417 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7418 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7419 | /* ADC2: mute amp left and right */ | 7524 | /* ADC2: mute amp left and right */ |
7420 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 7525 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
7421 | /* ADC3: mute amp left and right */ | 7526 | /* ADC3: mute amp left and right */ |
@@ -7557,6 +7662,76 @@ static struct hda_verb alc885_mb5_init_verbs[] = { | |||
7557 | { } | 7662 | { } |
7558 | }; | 7663 | }; |
7559 | 7664 | ||
7665 | /* Macmini 3,1 */ | ||
7666 | static struct hda_verb alc885_macmini3_init_verbs[] = { | ||
7667 | /* DACs */ | ||
7668 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7669 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7670 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7671 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7672 | /* Front mixer */ | ||
7673 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7674 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7675 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7676 | /* Surround mixer */ | ||
7677 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7678 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7679 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7680 | /* LFE mixer */ | ||
7681 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7682 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7683 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7684 | /* HP mixer */ | ||
7685 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7686 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7687 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7688 | /* Front Pin (0x0c) */ | ||
7689 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01}, | ||
7690 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7691 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7692 | /* LFE Pin (0x0e) */ | ||
7693 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01}, | ||
7694 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7695 | {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
7696 | /* HP Pin (0x0f) */ | ||
7697 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
7698 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7699 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
7700 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, | ||
7701 | /* Line In pin */ | ||
7702 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
7703 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7704 | |||
7705 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
7706 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7707 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7708 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7709 | { } | ||
7710 | }; | ||
7711 | |||
7712 | |||
7713 | static struct hda_verb alc885_mba21_init_verbs[] = { | ||
7714 | /*Internal and HP Speaker Mixer*/ | ||
7715 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
7716 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
7717 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
7718 | /*Internal Speaker Pin (0x0c)*/ | ||
7719 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) }, | ||
7720 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7721 | {0x18, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7722 | /* HP Pin: output 0 (0x0e) */ | ||
7723 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, | ||
7724 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
7725 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
7726 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)}, | ||
7727 | /* Line in (is hp when jack connected)*/ | ||
7728 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50}, | ||
7729 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
7730 | |||
7731 | { } | ||
7732 | }; | ||
7733 | |||
7734 | |||
7560 | /* Macbook Pro rev3 */ | 7735 | /* Macbook Pro rev3 */ |
7561 | static struct hda_verb alc885_mbp3_init_verbs[] = { | 7736 | static struct hda_verb alc885_mbp3_init_verbs[] = { |
7562 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | 7737 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ |
@@ -7719,54 +7894,35 @@ static void alc885_imac24_setup(struct hda_codec *codec) | |||
7719 | spec->autocfg.speaker_pins[1] = 0x1a; | 7894 | spec->autocfg.speaker_pins[1] = 0x1a; |
7720 | } | 7895 | } |
7721 | 7896 | ||
7722 | static void alc885_mbp3_setup(struct hda_codec *codec) | 7897 | #define alc885_mb5_setup alc885_imac24_setup |
7723 | { | 7898 | #define alc885_macmini3_setup alc885_imac24_setup |
7724 | struct alc_spec *spec = codec->spec; | ||
7725 | 7899 | ||
7726 | spec->autocfg.hp_pins[0] = 0x15; | 7900 | /* Macbook Air 2,1 */ |
7727 | spec->autocfg.speaker_pins[0] = 0x14; | 7901 | static void alc885_mba21_setup(struct hda_codec *codec) |
7728 | } | ||
7729 | |||
7730 | static void alc885_mb5_automute(struct hda_codec *codec) | ||
7731 | { | 7902 | { |
7732 | unsigned int present; | 7903 | struct alc_spec *spec = codec->spec; |
7733 | |||
7734 | present = snd_hda_codec_read(codec, 0x14, 0, | ||
7735 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | ||
7736 | snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0, | ||
7737 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
7738 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | ||
7739 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
7740 | 7904 | ||
7905 | spec->autocfg.hp_pins[0] = 0x14; | ||
7906 | spec->autocfg.speaker_pins[0] = 0x18; | ||
7741 | } | 7907 | } |
7742 | 7908 | ||
7743 | static void alc885_mb5_unsol_event(struct hda_codec *codec, | ||
7744 | unsigned int res) | ||
7745 | { | ||
7746 | /* Headphone insertion or removal. */ | ||
7747 | if ((res >> 26) == ALC880_HP_EVENT) | ||
7748 | alc885_mb5_automute(codec); | ||
7749 | } | ||
7750 | 7909 | ||
7751 | static void alc885_imac91_automute(struct hda_codec *codec) | ||
7752 | { | ||
7753 | unsigned int present; | ||
7754 | 7910 | ||
7755 | present = snd_hda_codec_read(codec, 0x14, 0, | 7911 | static void alc885_mbp3_setup(struct hda_codec *codec) |
7756 | AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; | 7912 | { |
7757 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 7913 | struct alc_spec *spec = codec->spec; |
7758 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
7759 | snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0, | ||
7760 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
7761 | 7914 | ||
7915 | spec->autocfg.hp_pins[0] = 0x15; | ||
7916 | spec->autocfg.speaker_pins[0] = 0x14; | ||
7762 | } | 7917 | } |
7763 | 7918 | ||
7764 | static void alc885_imac91_unsol_event(struct hda_codec *codec, | 7919 | static void alc885_imac91_setup(struct hda_codec *codec) |
7765 | unsigned int res) | ||
7766 | { | 7920 | { |
7767 | /* Headphone insertion or removal. */ | 7921 | struct alc_spec *spec = codec->spec; |
7768 | if ((res >> 26) == ALC880_HP_EVENT) | 7922 | |
7769 | alc885_imac91_automute(codec); | 7923 | spec->autocfg.hp_pins[0] = 0x14; |
7924 | spec->autocfg.speaker_pins[0] = 0x15; | ||
7925 | spec->autocfg.speaker_pins[1] = 0x1a; | ||
7770 | } | 7926 | } |
7771 | 7927 | ||
7772 | static struct hda_verb alc882_targa_verbs[] = { | 7928 | static struct hda_verb alc882_targa_verbs[] = { |
@@ -7901,18 +8057,6 @@ static struct hda_verb alc883_auto_init_verbs[] = { | |||
7901 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | 8057 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
7902 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 8058 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7903 | 8059 | ||
7904 | /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | ||
7905 | * mixer widget | ||
7906 | * Note: PASD motherboards uses the Line In 2 as the input for | ||
7907 | * front panel mic (mic 2) | ||
7908 | */ | ||
7909 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | ||
7910 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
7911 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
7912 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
7913 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
7914 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
7915 | |||
7916 | /* | 8060 | /* |
7917 | * Set up output mixers (0x0c - 0x0f) | 8061 | * Set up output mixers (0x0c - 0x0f) |
7918 | */ | 8062 | */ |
@@ -7937,16 +8081,9 @@ static struct hda_verb alc883_auto_init_verbs[] = { | |||
7937 | /* FIXME: use matrix-type input source selection */ | 8081 | /* FIXME: use matrix-type input source selection */ |
7938 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | 8082 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ |
7939 | /* Input mixer2 */ | 8083 | /* Input mixer2 */ |
7940 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 8084 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7941 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | ||
7942 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | ||
7943 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | ||
7944 | /* Input mixer3 */ | 8085 | /* Input mixer3 */ |
7945 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, | 8086 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
7946 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, | ||
7947 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, | ||
7948 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, | ||
7949 | |||
7950 | { } | 8087 | { } |
7951 | }; | 8088 | }; |
7952 | 8089 | ||
@@ -8933,6 +9070,8 @@ static const char *alc882_models[ALC882_MODEL_LAST] = { | |||
8933 | [ALC882_ASUS_A7M] = "asus-a7m", | 9070 | [ALC882_ASUS_A7M] = "asus-a7m", |
8934 | [ALC885_MACPRO] = "macpro", | 9071 | [ALC885_MACPRO] = "macpro", |
8935 | [ALC885_MB5] = "mb5", | 9072 | [ALC885_MB5] = "mb5", |
9073 | [ALC885_MACMINI3] = "macmini3", | ||
9074 | [ALC885_MBA21] = "mba21", | ||
8936 | [ALC885_MBP3] = "mbp3", | 9075 | [ALC885_MBP3] = "mbp3", |
8937 | [ALC885_IMAC24] = "imac24", | 9076 | [ALC885_IMAC24] = "imac24", |
8938 | [ALC885_IMAC91] = "imac91", | 9077 | [ALC885_IMAC91] = "imac91", |
@@ -9116,6 +9255,7 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = { | |||
9116 | */ | 9255 | */ |
9117 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5), | 9256 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5), |
9118 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5), | 9257 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5), |
9258 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3), | ||
9119 | {} /* terminator */ | 9259 | {} /* terminator */ |
9120 | }; | 9260 | }; |
9121 | 9261 | ||
@@ -9167,6 +9307,18 @@ static struct alc_config_preset alc882_presets[] = { | |||
9167 | .input_mux = &alc882_capture_source, | 9307 | .input_mux = &alc882_capture_source, |
9168 | .dig_out_nid = ALC882_DIGOUT_NID, | 9308 | .dig_out_nid = ALC882_DIGOUT_NID, |
9169 | }, | 9309 | }, |
9310 | [ALC885_MBA21] = { | ||
9311 | .mixers = { alc885_mba21_mixer }, | ||
9312 | .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs }, | ||
9313 | .num_dacs = 2, | ||
9314 | .dac_nids = alc882_dac_nids, | ||
9315 | .channel_mode = alc885_mba21_ch_modes, | ||
9316 | .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes), | ||
9317 | .input_mux = &alc882_capture_source, | ||
9318 | .unsol_event = alc_automute_amp_unsol_event, | ||
9319 | .setup = alc885_mba21_setup, | ||
9320 | .init_hook = alc_automute_amp, | ||
9321 | }, | ||
9170 | [ALC885_MBP3] = { | 9322 | [ALC885_MBP3] = { |
9171 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, | 9323 | .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, |
9172 | .init_verbs = { alc885_mbp3_init_verbs, | 9324 | .init_verbs = { alc885_mbp3_init_verbs, |
@@ -9194,8 +9346,24 @@ static struct alc_config_preset alc882_presets[] = { | |||
9194 | .input_mux = &mb5_capture_source, | 9346 | .input_mux = &mb5_capture_source, |
9195 | .dig_out_nid = ALC882_DIGOUT_NID, | 9347 | .dig_out_nid = ALC882_DIGOUT_NID, |
9196 | .dig_in_nid = ALC882_DIGIN_NID, | 9348 | .dig_in_nid = ALC882_DIGIN_NID, |
9197 | .unsol_event = alc885_mb5_unsol_event, | 9349 | .unsol_event = alc_automute_amp_unsol_event, |
9198 | .init_hook = alc885_mb5_automute, | 9350 | .setup = alc885_mb5_setup, |
9351 | .init_hook = alc_automute_amp, | ||
9352 | }, | ||
9353 | [ALC885_MACMINI3] = { | ||
9354 | .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer }, | ||
9355 | .init_verbs = { alc885_macmini3_init_verbs, | ||
9356 | alc880_gpio1_init_verbs }, | ||
9357 | .num_dacs = ARRAY_SIZE(alc882_dac_nids), | ||
9358 | .dac_nids = alc882_dac_nids, | ||
9359 | .channel_mode = alc885_macmini3_6ch_modes, | ||
9360 | .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes), | ||
9361 | .input_mux = &macmini3_capture_source, | ||
9362 | .dig_out_nid = ALC882_DIGOUT_NID, | ||
9363 | .dig_in_nid = ALC882_DIGIN_NID, | ||
9364 | .unsol_event = alc_automute_amp_unsol_event, | ||
9365 | .setup = alc885_macmini3_setup, | ||
9366 | .init_hook = alc_automute_amp, | ||
9199 | }, | 9367 | }, |
9200 | [ALC885_MACPRO] = { | 9368 | [ALC885_MACPRO] = { |
9201 | .mixers = { alc882_macpro_mixer }, | 9369 | .mixers = { alc882_macpro_mixer }, |
@@ -9234,8 +9402,9 @@ static struct alc_config_preset alc882_presets[] = { | |||
9234 | .input_mux = &alc882_capture_source, | 9402 | .input_mux = &alc882_capture_source, |
9235 | .dig_out_nid = ALC882_DIGOUT_NID, | 9403 | .dig_out_nid = ALC882_DIGOUT_NID, |
9236 | .dig_in_nid = ALC882_DIGIN_NID, | 9404 | .dig_in_nid = ALC882_DIGIN_NID, |
9237 | .unsol_event = alc885_imac91_unsol_event, | 9405 | .unsol_event = alc_automute_amp_unsol_event, |
9238 | .init_hook = alc885_imac91_automute, | 9406 | .setup = alc885_imac91_setup, |
9407 | .init_hook = alc_automute_amp, | ||
9239 | }, | 9408 | }, |
9240 | [ALC882_TARGA] = { | 9409 | [ALC882_TARGA] = { |
9241 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, | 9410 | .mixers = { alc882_targa_mixer, alc882_chmode_mixer }, |
@@ -9473,6 +9642,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9473 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), | 9642 | .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes), |
9474 | .channel_mode = alc883_3ST_6ch_modes, | 9643 | .channel_mode = alc883_3ST_6ch_modes, |
9475 | .need_dac_fix = 1, | 9644 | .need_dac_fix = 1, |
9645 | .const_channel_count = 6, | ||
9476 | .num_mux_defs = | 9646 | .num_mux_defs = |
9477 | ARRAY_SIZE(alc888_2_capture_sources), | 9647 | ARRAY_SIZE(alc888_2_capture_sources), |
9478 | .input_mux = alc888_2_capture_sources, | 9648 | .input_mux = alc888_2_capture_sources, |
@@ -9522,7 +9692,7 @@ static struct alc_config_preset alc882_presets[] = { | |||
9522 | .setup = alc889_acer_aspire_8930g_setup, | 9692 | .setup = alc889_acer_aspire_8930g_setup, |
9523 | .init_hook = alc_automute_amp, | 9693 | .init_hook = alc_automute_amp, |
9524 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 9694 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
9525 | .power_hook = alc889_power_eapd, | 9695 | .power_hook = alc_power_eapd, |
9526 | #endif | 9696 | #endif |
9527 | }, | 9697 | }, |
9528 | [ALC888_ACER_ASPIRE_7730G] = { | 9698 | [ALC888_ACER_ASPIRE_7730G] = { |
@@ -10057,7 +10227,7 @@ static int alc882_parse_auto_config(struct hda_codec *codec) | |||
10057 | spec->num_mux_defs = 1; | 10227 | spec->num_mux_defs = 1; |
10058 | spec->input_mux = &spec->private_imux[0]; | 10228 | spec->input_mux = &spec->private_imux[0]; |
10059 | 10229 | ||
10060 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | 10230 | alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); |
10061 | 10231 | ||
10062 | err = alc_auto_add_mic_boost(codec); | 10232 | err = alc_auto_add_mic_boost(codec); |
10063 | if (err < 0) | 10233 | if (err < 0) |
@@ -10195,7 +10365,6 @@ static int patch_alc882(struct hda_codec *codec) | |||
10195 | if (!spec->loopback.amplist) | 10365 | if (!spec->loopback.amplist) |
10196 | spec->loopback.amplist = alc882_loopbacks; | 10366 | spec->loopback.amplist = alc882_loopbacks; |
10197 | #endif | 10367 | #endif |
10198 | codec->proc_widget_hook = print_realtek_coef; | ||
10199 | 10368 | ||
10200 | return 0; | 10369 | return 0; |
10201 | } | 10370 | } |
@@ -10318,8 +10487,14 @@ static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol, | |||
10318 | .info = snd_ctl_boolean_mono_info, \ | 10487 | .info = snd_ctl_boolean_mono_info, \ |
10319 | .get = alc262_hp_master_sw_get, \ | 10488 | .get = alc262_hp_master_sw_get, \ |
10320 | .put = alc262_hp_master_sw_put, \ | 10489 | .put = alc262_hp_master_sw_put, \ |
10490 | }, \ | ||
10491 | { \ | ||
10492 | .iface = NID_MAPPING, \ | ||
10493 | .name = "Master Playback Switch", \ | ||
10494 | .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \ | ||
10321 | } | 10495 | } |
10322 | 10496 | ||
10497 | |||
10323 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { | 10498 | static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { |
10324 | ALC262_HP_MASTER_SWITCH, | 10499 | ALC262_HP_MASTER_SWITCH, |
10325 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), | 10500 | HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), |
@@ -10377,7 +10552,7 @@ static void alc262_hp_t5735_setup(struct hda_codec *codec) | |||
10377 | struct alc_spec *spec = codec->spec; | 10552 | struct alc_spec *spec = codec->spec; |
10378 | 10553 | ||
10379 | spec->autocfg.hp_pins[0] = 0x15; | 10554 | spec->autocfg.hp_pins[0] = 0x15; |
10380 | spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */ | 10555 | spec->autocfg.speaker_pins[0] = 0x14; |
10381 | } | 10556 | } |
10382 | 10557 | ||
10383 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { | 10558 | static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = { |
@@ -10477,6 +10652,12 @@ static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol, | |||
10477 | .info = snd_ctl_boolean_mono_info, \ | 10652 | .info = snd_ctl_boolean_mono_info, \ |
10478 | .get = alc262_hippo_master_sw_get, \ | 10653 | .get = alc262_hippo_master_sw_get, \ |
10479 | .put = alc262_hippo_master_sw_put, \ | 10654 | .put = alc262_hippo_master_sw_put, \ |
10655 | }, \ | ||
10656 | { \ | ||
10657 | .iface = NID_MAPPING, \ | ||
10658 | .name = "Master Playback Switch", \ | ||
10659 | .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \ | ||
10660 | (SUBDEV_SPEAKER(0) << 16), \ | ||
10480 | } | 10661 | } |
10481 | 10662 | ||
10482 | static struct snd_kcontrol_new alc262_hippo_mixer[] = { | 10663 | static struct snd_kcontrol_new alc262_hippo_mixer[] = { |
@@ -10957,11 +11138,17 @@ static struct snd_kcontrol_new alc262_fujitsu_mixer[] = { | |||
10957 | { | 11138 | { |
10958 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 11139 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
10959 | .name = "Master Playback Switch", | 11140 | .name = "Master Playback Switch", |
11141 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
10960 | .info = snd_hda_mixer_amp_switch_info, | 11142 | .info = snd_hda_mixer_amp_switch_info, |
10961 | .get = snd_hda_mixer_amp_switch_get, | 11143 | .get = snd_hda_mixer_amp_switch_get, |
10962 | .put = alc262_fujitsu_master_sw_put, | 11144 | .put = alc262_fujitsu_master_sw_put, |
10963 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | 11145 | .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), |
10964 | }, | 11146 | }, |
11147 | { | ||
11148 | .iface = NID_MAPPING, | ||
11149 | .name = "Master Playback Switch", | ||
11150 | .private_value = 0x1b, | ||
11151 | }, | ||
10965 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), | 11152 | HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), |
10966 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), | 11153 | HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), |
10967 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | 11154 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
@@ -10992,6 +11179,7 @@ static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = { | |||
10992 | { | 11179 | { |
10993 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 11180 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
10994 | .name = "Master Playback Switch", | 11181 | .name = "Master Playback Switch", |
11182 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
10995 | .info = snd_hda_mixer_amp_switch_info, | 11183 | .info = snd_hda_mixer_amp_switch_info, |
10996 | .get = snd_hda_mixer_amp_switch_get, | 11184 | .get = snd_hda_mixer_amp_switch_get, |
10997 | .put = alc262_lenovo_3000_master_sw_put, | 11185 | .put = alc262_lenovo_3000_master_sw_put, |
@@ -11146,6 +11334,11 @@ static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = { | |||
11146 | .get = alc_mux_enum_get, | 11334 | .get = alc_mux_enum_get, |
11147 | .put = alc262_ultra_mux_enum_put, | 11335 | .put = alc262_ultra_mux_enum_put, |
11148 | }, | 11336 | }, |
11337 | { | ||
11338 | .iface = NID_MAPPING, | ||
11339 | .name = "Capture Source", | ||
11340 | .private_value = 0x15, | ||
11341 | }, | ||
11149 | { } /* end */ | 11342 | { } /* end */ |
11150 | }; | 11343 | }; |
11151 | 11344 | ||
@@ -11592,7 +11785,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec) | |||
11592 | if (err < 0) | 11785 | if (err < 0) |
11593 | return err; | 11786 | return err; |
11594 | 11787 | ||
11595 | alc_ssid_check(codec, 0x15, 0x14, 0x1b); | 11788 | alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); |
11596 | 11789 | ||
11597 | return 1; | 11790 | return 1; |
11598 | } | 11791 | } |
@@ -11788,9 +11981,9 @@ static struct alc_config_preset alc262_presets[] = { | |||
11788 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | 11981 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
11789 | .channel_mode = alc262_modes, | 11982 | .channel_mode = alc262_modes, |
11790 | .input_mux = &alc262_capture_source, | 11983 | .input_mux = &alc262_capture_source, |
11791 | .unsol_event = alc_automute_amp_unsol_event, | 11984 | .unsol_event = alc_sku_unsol_event, |
11792 | .setup = alc262_hp_t5735_setup, | 11985 | .setup = alc262_hp_t5735_setup, |
11793 | .init_hook = alc_automute_amp, | 11986 | .init_hook = alc_inithook, |
11794 | }, | 11987 | }, |
11795 | [ALC262_HP_RP5700] = { | 11988 | [ALC262_HP_RP5700] = { |
11796 | .mixers = { alc262_hp_rp5700_mixer }, | 11989 | .mixers = { alc262_hp_rp5700_mixer }, |
@@ -12035,7 +12228,6 @@ static int patch_alc262(struct hda_codec *codec) | |||
12035 | if (!spec->loopback.amplist) | 12228 | if (!spec->loopback.amplist) |
12036 | spec->loopback.amplist = alc262_loopbacks; | 12229 | spec->loopback.amplist = alc262_loopbacks; |
12037 | #endif | 12230 | #endif |
12038 | codec->proc_widget_hook = print_realtek_coef; | ||
12039 | 12231 | ||
12040 | return 0; | 12232 | return 0; |
12041 | } | 12233 | } |
@@ -12164,6 +12356,7 @@ static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = { | |||
12164 | { | 12356 | { |
12165 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 12357 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
12166 | .name = "Master Playback Switch", | 12358 | .name = "Master Playback Switch", |
12359 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
12167 | .info = snd_hda_mixer_amp_switch_info, | 12360 | .info = snd_hda_mixer_amp_switch_info, |
12168 | .get = snd_hda_mixer_amp_switch_get, | 12361 | .get = snd_hda_mixer_amp_switch_get, |
12169 | .put = alc268_acer_master_sw_put, | 12362 | .put = alc268_acer_master_sw_put, |
@@ -12179,6 +12372,7 @@ static struct snd_kcontrol_new alc268_acer_mixer[] = { | |||
12179 | { | 12372 | { |
12180 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 12373 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
12181 | .name = "Master Playback Switch", | 12374 | .name = "Master Playback Switch", |
12375 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
12182 | .info = snd_hda_mixer_amp_switch_info, | 12376 | .info = snd_hda_mixer_amp_switch_info, |
12183 | .get = snd_hda_mixer_amp_switch_get, | 12377 | .get = snd_hda_mixer_amp_switch_get, |
12184 | .put = alc268_acer_master_sw_put, | 12378 | .put = alc268_acer_master_sw_put, |
@@ -12196,6 +12390,7 @@ static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = { | |||
12196 | { | 12390 | { |
12197 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 12391 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
12198 | .name = "Master Playback Switch", | 12392 | .name = "Master Playback Switch", |
12393 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
12199 | .info = snd_hda_mixer_amp_switch_info, | 12394 | .info = snd_hda_mixer_amp_switch_info, |
12200 | .get = snd_hda_mixer_amp_switch_get, | 12395 | .get = snd_hda_mixer_amp_switch_get, |
12201 | .put = alc268_acer_master_sw_put, | 12396 | .put = alc268_acer_master_sw_put, |
@@ -12761,7 +12956,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec) | |||
12761 | if (err < 0) | 12956 | if (err < 0) |
12762 | return err; | 12957 | return err; |
12763 | 12958 | ||
12764 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | 12959 | alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); |
12765 | 12960 | ||
12766 | return 1; | 12961 | return 1; |
12767 | } | 12962 | } |
@@ -13098,8 +13293,6 @@ static int patch_alc268(struct hda_codec *codec) | |||
13098 | if (board_config == ALC268_AUTO) | 13293 | if (board_config == ALC268_AUTO) |
13099 | spec->init_hook = alc268_auto_init; | 13294 | spec->init_hook = alc268_auto_init; |
13100 | 13295 | ||
13101 | codec->proc_widget_hook = print_realtek_coef; | ||
13102 | |||
13103 | return 0; | 13296 | return 0; |
13104 | } | 13297 | } |
13105 | 13298 | ||
@@ -13119,6 +13312,15 @@ static hda_nid_t alc269_capsrc_nids[1] = { | |||
13119 | 0x23, | 13312 | 0x23, |
13120 | }; | 13313 | }; |
13121 | 13314 | ||
13315 | static hda_nid_t alc269vb_adc_nids[1] = { | ||
13316 | /* ADC1 */ | ||
13317 | 0x09, | ||
13318 | }; | ||
13319 | |||
13320 | static hda_nid_t alc269vb_capsrc_nids[1] = { | ||
13321 | 0x22, | ||
13322 | }; | ||
13323 | |||
13122 | /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24), | 13324 | /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24), |
13123 | * not a mux! | 13325 | * not a mux! |
13124 | */ | 13326 | */ |
@@ -13148,6 +13350,7 @@ static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = { | |||
13148 | { | 13350 | { |
13149 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 13351 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
13150 | .name = "Master Playback Switch", | 13352 | .name = "Master Playback Switch", |
13353 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
13151 | .info = snd_hda_mixer_amp_switch_info, | 13354 | .info = snd_hda_mixer_amp_switch_info, |
13152 | .get = snd_hda_mixer_amp_switch_get, | 13355 | .get = snd_hda_mixer_amp_switch_get, |
13153 | .put = alc268_acer_master_sw_put, | 13356 | .put = alc268_acer_master_sw_put, |
@@ -13168,6 +13371,7 @@ static struct snd_kcontrol_new alc269_lifebook_mixer[] = { | |||
13168 | { | 13371 | { |
13169 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 13372 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
13170 | .name = "Master Playback Switch", | 13373 | .name = "Master Playback Switch", |
13374 | .subdevice = HDA_SUBDEV_AMP_FLAG, | ||
13171 | .info = snd_hda_mixer_amp_switch_info, | 13375 | .info = snd_hda_mixer_amp_switch_info, |
13172 | .get = snd_hda_mixer_amp_switch_get, | 13376 | .get = snd_hda_mixer_amp_switch_get, |
13173 | .put = alc268_acer_master_sw_put, | 13377 | .put = alc268_acer_master_sw_put, |
@@ -13185,7 +13389,7 @@ static struct snd_kcontrol_new alc269_lifebook_mixer[] = { | |||
13185 | { } | 13389 | { } |
13186 | }; | 13390 | }; |
13187 | 13391 | ||
13188 | static struct snd_kcontrol_new alc269_eeepc_mixer[] = { | 13392 | static struct snd_kcontrol_new alc269_laptop_mixer[] = { |
13189 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | 13393 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), |
13190 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | 13394 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), |
13191 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), | 13395 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), |
@@ -13193,16 +13397,47 @@ static struct snd_kcontrol_new alc269_eeepc_mixer[] = { | |||
13193 | { } /* end */ | 13397 | { } /* end */ |
13194 | }; | 13398 | }; |
13195 | 13399 | ||
13400 | static struct snd_kcontrol_new alc269vb_laptop_mixer[] = { | ||
13401 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT), | ||
13402 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT), | ||
13403 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT), | ||
13404 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT), | ||
13405 | { } /* end */ | ||
13406 | }; | ||
13407 | |||
13196 | /* capture mixer elements */ | 13408 | /* capture mixer elements */ |
13197 | static struct snd_kcontrol_new alc269_epc_capture_mixer[] = { | 13409 | static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = { |
13198 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | 13410 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), |
13199 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | 13411 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), |
13200 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | 13412 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), |
13413 | HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT), | ||
13414 | { } /* end */ | ||
13415 | }; | ||
13416 | |||
13417 | static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = { | ||
13418 | HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), | ||
13419 | HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), | ||
13420 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
13421 | { } /* end */ | ||
13422 | }; | ||
13423 | |||
13424 | static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = { | ||
13425 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | ||
13426 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | ||
13427 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
13428 | HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT), | ||
13429 | { } /* end */ | ||
13430 | }; | ||
13431 | |||
13432 | static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = { | ||
13433 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT), | ||
13434 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT), | ||
13435 | HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), | ||
13201 | { } /* end */ | 13436 | { } /* end */ |
13202 | }; | 13437 | }; |
13203 | 13438 | ||
13204 | /* FSC amilo */ | 13439 | /* FSC amilo */ |
13205 | #define alc269_fujitsu_mixer alc269_eeepc_mixer | 13440 | #define alc269_fujitsu_mixer alc269_laptop_mixer |
13206 | 13441 | ||
13207 | static struct hda_verb alc269_quanta_fl1_verbs[] = { | 13442 | static struct hda_verb alc269_quanta_fl1_verbs[] = { |
13208 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | 13443 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
@@ -13326,6 +13561,8 @@ static void alc269_lifebook_unsol_event(struct hda_codec *codec, | |||
13326 | static void alc269_quanta_fl1_setup(struct hda_codec *codec) | 13561 | static void alc269_quanta_fl1_setup(struct hda_codec *codec) |
13327 | { | 13562 | { |
13328 | struct alc_spec *spec = codec->spec; | 13563 | struct alc_spec *spec = codec->spec; |
13564 | spec->autocfg.hp_pins[0] = 0x15; | ||
13565 | spec->autocfg.speaker_pins[0] = 0x14; | ||
13329 | spec->ext_mic.pin = 0x18; | 13566 | spec->ext_mic.pin = 0x18; |
13330 | spec->ext_mic.mux_idx = 0; | 13567 | spec->ext_mic.mux_idx = 0; |
13331 | spec->int_mic.pin = 0x19; | 13568 | spec->int_mic.pin = 0x19; |
@@ -13345,7 +13582,7 @@ static void alc269_lifebook_init_hook(struct hda_codec *codec) | |||
13345 | alc269_lifebook_mic_autoswitch(codec); | 13582 | alc269_lifebook_mic_autoswitch(codec); |
13346 | } | 13583 | } |
13347 | 13584 | ||
13348 | static struct hda_verb alc269_eeepc_dmic_init_verbs[] = { | 13585 | static struct hda_verb alc269_laptop_dmic_init_verbs[] = { |
13349 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | 13586 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
13350 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x05}, | 13587 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x05}, |
13351 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | 13588 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, |
@@ -13356,7 +13593,7 @@ static struct hda_verb alc269_eeepc_dmic_init_verbs[] = { | |||
13356 | {} | 13593 | {} |
13357 | }; | 13594 | }; |
13358 | 13595 | ||
13359 | static struct hda_verb alc269_eeepc_amic_init_verbs[] = { | 13596 | static struct hda_verb alc269_laptop_amic_init_verbs[] = { |
13360 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, | 13597 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, |
13361 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, | 13598 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x01}, |
13362 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | 13599 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, |
@@ -13366,6 +13603,28 @@ static struct hda_verb alc269_eeepc_amic_init_verbs[] = { | |||
13366 | {} | 13603 | {} |
13367 | }; | 13604 | }; |
13368 | 13605 | ||
13606 | static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = { | ||
13607 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
13608 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x06}, | ||
13609 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | ||
13610 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))}, | ||
13611 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
13612 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | ||
13613 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
13614 | {} | ||
13615 | }; | ||
13616 | |||
13617 | static struct hda_verb alc269vb_laptop_amic_init_verbs[] = { | ||
13618 | {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
13619 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
13620 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 }, | ||
13621 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))}, | ||
13622 | {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
13623 | {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, | ||
13624 | {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, | ||
13625 | {} | ||
13626 | }; | ||
13627 | |||
13369 | /* toggle speaker-output according to the hp-jack state */ | 13628 | /* toggle speaker-output according to the hp-jack state */ |
13370 | static void alc269_speaker_automute(struct hda_codec *codec) | 13629 | static void alc269_speaker_automute(struct hda_codec *codec) |
13371 | { | 13630 | { |
@@ -13383,7 +13642,7 @@ static void alc269_speaker_automute(struct hda_codec *codec) | |||
13383 | } | 13642 | } |
13384 | 13643 | ||
13385 | /* unsolicited event for HP jack sensing */ | 13644 | /* unsolicited event for HP jack sensing */ |
13386 | static void alc269_eeepc_unsol_event(struct hda_codec *codec, | 13645 | static void alc269_laptop_unsol_event(struct hda_codec *codec, |
13387 | unsigned int res) | 13646 | unsigned int res) |
13388 | { | 13647 | { |
13389 | switch (res >> 26) { | 13648 | switch (res >> 26) { |
@@ -13396,9 +13655,11 @@ static void alc269_eeepc_unsol_event(struct hda_codec *codec, | |||
13396 | } | 13655 | } |
13397 | } | 13656 | } |
13398 | 13657 | ||
13399 | static void alc269_eeepc_dmic_setup(struct hda_codec *codec) | 13658 | static void alc269_laptop_dmic_setup(struct hda_codec *codec) |
13400 | { | 13659 | { |
13401 | struct alc_spec *spec = codec->spec; | 13660 | struct alc_spec *spec = codec->spec; |
13661 | spec->autocfg.hp_pins[0] = 0x15; | ||
13662 | spec->autocfg.speaker_pins[0] = 0x14; | ||
13402 | spec->ext_mic.pin = 0x18; | 13663 | spec->ext_mic.pin = 0x18; |
13403 | spec->ext_mic.mux_idx = 0; | 13664 | spec->ext_mic.mux_idx = 0; |
13404 | spec->int_mic.pin = 0x12; | 13665 | spec->int_mic.pin = 0x12; |
@@ -13406,9 +13667,23 @@ static void alc269_eeepc_dmic_setup(struct hda_codec *codec) | |||
13406 | spec->auto_mic = 1; | 13667 | spec->auto_mic = 1; |
13407 | } | 13668 | } |
13408 | 13669 | ||
13409 | static void alc269_eeepc_amic_setup(struct hda_codec *codec) | 13670 | static void alc269vb_laptop_dmic_setup(struct hda_codec *codec) |
13410 | { | 13671 | { |
13411 | struct alc_spec *spec = codec->spec; | 13672 | struct alc_spec *spec = codec->spec; |
13673 | spec->autocfg.hp_pins[0] = 0x15; | ||
13674 | spec->autocfg.speaker_pins[0] = 0x14; | ||
13675 | spec->ext_mic.pin = 0x18; | ||
13676 | spec->ext_mic.mux_idx = 0; | ||
13677 | spec->int_mic.pin = 0x12; | ||
13678 | spec->int_mic.mux_idx = 6; | ||
13679 | spec->auto_mic = 1; | ||
13680 | } | ||
13681 | |||
13682 | static void alc269_laptop_amic_setup(struct hda_codec *codec) | ||
13683 | { | ||
13684 | struct alc_spec *spec = codec->spec; | ||
13685 | spec->autocfg.hp_pins[0] = 0x15; | ||
13686 | spec->autocfg.speaker_pins[0] = 0x14; | ||
13412 | spec->ext_mic.pin = 0x18; | 13687 | spec->ext_mic.pin = 0x18; |
13413 | spec->ext_mic.mux_idx = 0; | 13688 | spec->ext_mic.mux_idx = 0; |
13414 | spec->int_mic.pin = 0x19; | 13689 | spec->int_mic.pin = 0x19; |
@@ -13416,7 +13691,7 @@ static void alc269_eeepc_amic_setup(struct hda_codec *codec) | |||
13416 | spec->auto_mic = 1; | 13691 | spec->auto_mic = 1; |
13417 | } | 13692 | } |
13418 | 13693 | ||
13419 | static void alc269_eeepc_inithook(struct hda_codec *codec) | 13694 | static void alc269_laptop_inithook(struct hda_codec *codec) |
13420 | { | 13695 | { |
13421 | alc269_speaker_automute(codec); | 13696 | alc269_speaker_automute(codec); |
13422 | alc_mic_automute(codec); | 13697 | alc_mic_automute(codec); |
@@ -13429,22 +13704,10 @@ static struct hda_verb alc269_init_verbs[] = { | |||
13429 | /* | 13704 | /* |
13430 | * Unmute ADC0 and set the default input to mic-in | 13705 | * Unmute ADC0 and set the default input to mic-in |
13431 | */ | 13706 | */ |
13432 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 13707 | {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
13433 | |||
13434 | /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the | ||
13435 | * analog-loopback mixer widget | ||
13436 | * Note: PASD motherboards uses the Line In 2 as the input for | ||
13437 | * front panel mic (mic 2) | ||
13438 | */ | ||
13439 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | ||
13440 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
13441 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
13442 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
13443 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
13444 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
13445 | 13708 | ||
13446 | /* | 13709 | /* |
13447 | * Set up output mixers (0x0c - 0x0e) | 13710 | * Set up output mixers (0x02 - 0x03) |
13448 | */ | 13711 | */ |
13449 | /* set vol=0 to output mixers */ | 13712 | /* set vol=0 to output mixers */ |
13450 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | 13713 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, |
@@ -13469,26 +13732,57 @@ static struct hda_verb alc269_init_verbs[] = { | |||
13469 | 13732 | ||
13470 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 13733 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
13471 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | 13734 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, |
13472 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
13473 | {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
13474 | {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
13475 | {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
13476 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
13477 | 13735 | ||
13478 | {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, | 13736 | /* FIXME: use Mux-type input source selection */ |
13479 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, | 13737 | /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ |
13738 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | ||
13739 | {0x23, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
13480 | 13740 | ||
13481 | /* FIXME: use matrix-type input source selection */ | 13741 | /* set EAPD */ |
13742 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | ||
13743 | { } | ||
13744 | }; | ||
13745 | |||
13746 | static struct hda_verb alc269vb_init_verbs[] = { | ||
13747 | /* | ||
13748 | * Unmute ADC0 and set the default input to mic-in | ||
13749 | */ | ||
13750 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
13751 | |||
13752 | /* | ||
13753 | * Set up output mixers (0x02 - 0x03) | ||
13754 | */ | ||
13755 | /* set vol=0 to output mixers */ | ||
13756 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
13757 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
13758 | |||
13759 | /* set up input amps for analog loopback */ | ||
13760 | /* Amp Indices: DAC = 0, mixer = 1 */ | ||
13761 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
13762 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
13763 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
13764 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
13765 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
13766 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
13767 | |||
13768 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
13769 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, | ||
13770 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
13771 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
13772 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
13773 | {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
13774 | {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
13775 | |||
13776 | {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
13777 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
13778 | |||
13779 | /* FIXME: use Mux-type input source selection */ | ||
13482 | /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ | 13780 | /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */ |
13483 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ | 13781 | /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ |
13484 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 13782 | {0x22, AC_VERB_SET_CONNECT_SEL, 0x00}, |
13485 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
13486 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
13487 | {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
13488 | 13783 | ||
13489 | /* set EAPD */ | 13784 | /* set EAPD */ |
13490 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, | 13785 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
13491 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, | ||
13492 | { } | 13786 | { } |
13493 | }; | 13787 | }; |
13494 | 13788 | ||
@@ -13536,6 +13830,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
13536 | struct alc_spec *spec = codec->spec; | 13830 | struct alc_spec *spec = codec->spec; |
13537 | int err; | 13831 | int err; |
13538 | static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; | 13832 | static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
13833 | hda_nid_t real_capsrc_nids; | ||
13539 | 13834 | ||
13540 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, | 13835 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, |
13541 | alc269_ignore); | 13836 | alc269_ignore); |
@@ -13557,11 +13852,20 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
13557 | if (spec->kctls.list) | 13852 | if (spec->kctls.list) |
13558 | add_mixer(spec, spec->kctls.list); | 13853 | add_mixer(spec, spec->kctls.list); |
13559 | 13854 | ||
13560 | add_verb(spec, alc269_init_verbs); | 13855 | if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) { |
13856 | add_verb(spec, alc269vb_init_verbs); | ||
13857 | real_capsrc_nids = alc269vb_capsrc_nids[0]; | ||
13858 | alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21); | ||
13859 | } else { | ||
13860 | add_verb(spec, alc269_init_verbs); | ||
13861 | real_capsrc_nids = alc269_capsrc_nids[0]; | ||
13862 | alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); | ||
13863 | } | ||
13864 | |||
13561 | spec->num_mux_defs = 1; | 13865 | spec->num_mux_defs = 1; |
13562 | spec->input_mux = &spec->private_imux[0]; | 13866 | spec->input_mux = &spec->private_imux[0]; |
13563 | /* set default input source */ | 13867 | /* set default input source */ |
13564 | snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0], | 13868 | snd_hda_codec_write_cache(codec, real_capsrc_nids, |
13565 | 0, AC_VERB_SET_CONNECT_SEL, | 13869 | 0, AC_VERB_SET_CONNECT_SEL, |
13566 | spec->input_mux->items[0].index); | 13870 | spec->input_mux->items[0].index); |
13567 | 13871 | ||
@@ -13572,8 +13876,6 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
13572 | if (!spec->cap_mixer && !spec->no_analog) | 13876 | if (!spec->cap_mixer && !spec->no_analog) |
13573 | set_capture_mixer(codec); | 13877 | set_capture_mixer(codec); |
13574 | 13878 | ||
13575 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | ||
13576 | |||
13577 | return 1; | 13879 | return 1; |
13578 | } | 13880 | } |
13579 | 13881 | ||
@@ -13599,8 +13901,8 @@ static void alc269_auto_init(struct hda_codec *codec) | |||
13599 | static const char *alc269_models[ALC269_MODEL_LAST] = { | 13901 | static const char *alc269_models[ALC269_MODEL_LAST] = { |
13600 | [ALC269_BASIC] = "basic", | 13902 | [ALC269_BASIC] = "basic", |
13601 | [ALC269_QUANTA_FL1] = "quanta", | 13903 | [ALC269_QUANTA_FL1] = "quanta", |
13602 | [ALC269_ASUS_AMIC] = "asus-amic", | 13904 | [ALC269_AMIC] = "laptop-amic", |
13603 | [ALC269_ASUS_DMIC] = "asus-dmic", | 13905 | [ALC269_DMIC] = "laptop-dmic", |
13604 | [ALC269_FUJITSU] = "fujitsu", | 13906 | [ALC269_FUJITSU] = "fujitsu", |
13605 | [ALC269_LIFEBOOK] = "lifebook", | 13907 | [ALC269_LIFEBOOK] = "lifebook", |
13606 | [ALC269_AUTO] = "auto", | 13908 | [ALC269_AUTO] = "auto", |
@@ -13609,43 +13911,57 @@ static const char *alc269_models[ALC269_MODEL_LAST] = { | |||
13609 | static struct snd_pci_quirk alc269_cfg_tbl[] = { | 13911 | static struct snd_pci_quirk alc269_cfg_tbl[] = { |
13610 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), | 13912 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), |
13611 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", | 13913 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
13612 | ALC269_ASUS_AMIC), | 13914 | ALC269_AMIC), |
13613 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC), | 13915 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC), |
13614 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC), | 13916 | SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC), |
13615 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC), | 13917 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC), |
13616 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC), | 13918 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC), |
13617 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC), | 13919 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC), |
13618 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC), | 13920 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC), |
13619 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC), | 13921 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC), |
13620 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC), | 13922 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC), |
13621 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC), | 13923 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC), |
13622 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC), | 13924 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC), |
13623 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC), | 13925 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC), |
13624 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC), | 13926 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC), |
13625 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC), | 13927 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC), |
13626 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC), | 13928 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC), |
13627 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC), | 13929 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC), |
13628 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC), | 13930 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC), |
13629 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC), | 13931 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC), |
13630 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC), | 13932 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC), |
13631 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC), | 13933 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC), |
13632 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC), | 13934 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC), |
13633 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC), | 13935 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC), |
13634 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC), | 13936 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC), |
13635 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC), | 13937 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC), |
13636 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC), | 13938 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC), |
13637 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC), | 13939 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC), |
13638 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC), | 13940 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC), |
13639 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC), | 13941 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC), |
13640 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC), | 13942 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC), |
13943 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC), | ||
13944 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC), | ||
13945 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC), | ||
13946 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC), | ||
13947 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC), | ||
13948 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC), | ||
13949 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC), | ||
13950 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC), | ||
13641 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", | 13951 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901", |
13642 | ALC269_ASUS_DMIC), | 13952 | ALC269_DMIC), |
13643 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", | 13953 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101", |
13644 | ALC269_ASUS_DMIC), | 13954 | ALC269_DMIC), |
13645 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC), | 13955 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC), |
13646 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC), | 13956 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC), |
13647 | SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), | 13957 | SND_PCI_QUIRK(0x104d, 0x9071, "SONY XTB", ALC269_DMIC), |
13648 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), | 13958 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK), |
13959 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC), | ||
13960 | SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU), | ||
13961 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC), | ||
13962 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC), | ||
13963 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC), | ||
13964 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC), | ||
13649 | {} | 13965 | {} |
13650 | }; | 13966 | }; |
13651 | 13967 | ||
@@ -13673,47 +13989,75 @@ static struct alc_config_preset alc269_presets[] = { | |||
13673 | .setup = alc269_quanta_fl1_setup, | 13989 | .setup = alc269_quanta_fl1_setup, |
13674 | .init_hook = alc269_quanta_fl1_init_hook, | 13990 | .init_hook = alc269_quanta_fl1_init_hook, |
13675 | }, | 13991 | }, |
13676 | [ALC269_ASUS_AMIC] = { | 13992 | [ALC269_AMIC] = { |
13677 | .mixers = { alc269_eeepc_mixer }, | 13993 | .mixers = { alc269_laptop_mixer }, |
13678 | .cap_mixer = alc269_epc_capture_mixer, | 13994 | .cap_mixer = alc269_laptop_analog_capture_mixer, |
13679 | .init_verbs = { alc269_init_verbs, | 13995 | .init_verbs = { alc269_init_verbs, |
13680 | alc269_eeepc_amic_init_verbs }, | 13996 | alc269_laptop_amic_init_verbs }, |
13681 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | 13997 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), |
13682 | .dac_nids = alc269_dac_nids, | 13998 | .dac_nids = alc269_dac_nids, |
13683 | .hp_nid = 0x03, | 13999 | .hp_nid = 0x03, |
13684 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | 14000 | .num_channel_mode = ARRAY_SIZE(alc269_modes), |
13685 | .channel_mode = alc269_modes, | 14001 | .channel_mode = alc269_modes, |
13686 | .unsol_event = alc269_eeepc_unsol_event, | 14002 | .unsol_event = alc269_laptop_unsol_event, |
13687 | .setup = alc269_eeepc_amic_setup, | 14003 | .setup = alc269_laptop_amic_setup, |
13688 | .init_hook = alc269_eeepc_inithook, | 14004 | .init_hook = alc269_laptop_inithook, |
13689 | }, | 14005 | }, |
13690 | [ALC269_ASUS_DMIC] = { | 14006 | [ALC269_DMIC] = { |
13691 | .mixers = { alc269_eeepc_mixer }, | 14007 | .mixers = { alc269_laptop_mixer }, |
13692 | .cap_mixer = alc269_epc_capture_mixer, | 14008 | .cap_mixer = alc269_laptop_digital_capture_mixer, |
13693 | .init_verbs = { alc269_init_verbs, | 14009 | .init_verbs = { alc269_init_verbs, |
13694 | alc269_eeepc_dmic_init_verbs }, | 14010 | alc269_laptop_dmic_init_verbs }, |
14011 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | ||
14012 | .dac_nids = alc269_dac_nids, | ||
14013 | .hp_nid = 0x03, | ||
14014 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | ||
14015 | .channel_mode = alc269_modes, | ||
14016 | .unsol_event = alc269_laptop_unsol_event, | ||
14017 | .setup = alc269_laptop_dmic_setup, | ||
14018 | .init_hook = alc269_laptop_inithook, | ||
14019 | }, | ||
14020 | [ALC269VB_AMIC] = { | ||
14021 | .mixers = { alc269vb_laptop_mixer }, | ||
14022 | .cap_mixer = alc269vb_laptop_analog_capture_mixer, | ||
14023 | .init_verbs = { alc269vb_init_verbs, | ||
14024 | alc269vb_laptop_amic_init_verbs }, | ||
13695 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | 14025 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), |
13696 | .dac_nids = alc269_dac_nids, | 14026 | .dac_nids = alc269_dac_nids, |
13697 | .hp_nid = 0x03, | 14027 | .hp_nid = 0x03, |
13698 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | 14028 | .num_channel_mode = ARRAY_SIZE(alc269_modes), |
13699 | .channel_mode = alc269_modes, | 14029 | .channel_mode = alc269_modes, |
13700 | .unsol_event = alc269_eeepc_unsol_event, | 14030 | .unsol_event = alc269_laptop_unsol_event, |
13701 | .setup = alc269_eeepc_dmic_setup, | 14031 | .setup = alc269_laptop_amic_setup, |
13702 | .init_hook = alc269_eeepc_inithook, | 14032 | .init_hook = alc269_laptop_inithook, |
14033 | }, | ||
14034 | [ALC269VB_DMIC] = { | ||
14035 | .mixers = { alc269vb_laptop_mixer }, | ||
14036 | .cap_mixer = alc269vb_laptop_digital_capture_mixer, | ||
14037 | .init_verbs = { alc269vb_init_verbs, | ||
14038 | alc269vb_laptop_dmic_init_verbs }, | ||
14039 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | ||
14040 | .dac_nids = alc269_dac_nids, | ||
14041 | .hp_nid = 0x03, | ||
14042 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | ||
14043 | .channel_mode = alc269_modes, | ||
14044 | .unsol_event = alc269_laptop_unsol_event, | ||
14045 | .setup = alc269vb_laptop_dmic_setup, | ||
14046 | .init_hook = alc269_laptop_inithook, | ||
13703 | }, | 14047 | }, |
13704 | [ALC269_FUJITSU] = { | 14048 | [ALC269_FUJITSU] = { |
13705 | .mixers = { alc269_fujitsu_mixer }, | 14049 | .mixers = { alc269_fujitsu_mixer }, |
13706 | .cap_mixer = alc269_epc_capture_mixer, | 14050 | .cap_mixer = alc269_laptop_digital_capture_mixer, |
13707 | .init_verbs = { alc269_init_verbs, | 14051 | .init_verbs = { alc269_init_verbs, |
13708 | alc269_eeepc_dmic_init_verbs }, | 14052 | alc269_laptop_dmic_init_verbs }, |
13709 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), | 14053 | .num_dacs = ARRAY_SIZE(alc269_dac_nids), |
13710 | .dac_nids = alc269_dac_nids, | 14054 | .dac_nids = alc269_dac_nids, |
13711 | .hp_nid = 0x03, | 14055 | .hp_nid = 0x03, |
13712 | .num_channel_mode = ARRAY_SIZE(alc269_modes), | 14056 | .num_channel_mode = ARRAY_SIZE(alc269_modes), |
13713 | .channel_mode = alc269_modes, | 14057 | .channel_mode = alc269_modes, |
13714 | .unsol_event = alc269_eeepc_unsol_event, | 14058 | .unsol_event = alc269_laptop_unsol_event, |
13715 | .setup = alc269_eeepc_dmic_setup, | 14059 | .setup = alc269_laptop_dmic_setup, |
13716 | .init_hook = alc269_eeepc_inithook, | 14060 | .init_hook = alc269_laptop_inithook, |
13717 | }, | 14061 | }, |
13718 | [ALC269_LIFEBOOK] = { | 14062 | [ALC269_LIFEBOOK] = { |
13719 | .mixers = { alc269_lifebook_mixer }, | 14063 | .mixers = { alc269_lifebook_mixer }, |
@@ -13734,6 +14078,7 @@ static int patch_alc269(struct hda_codec *codec) | |||
13734 | struct alc_spec *spec; | 14078 | struct alc_spec *spec; |
13735 | int board_config; | 14079 | int board_config; |
13736 | int err; | 14080 | int err; |
14081 | int is_alc269vb = 0; | ||
13737 | 14082 | ||
13738 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 14083 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
13739 | if (spec == NULL) | 14084 | if (spec == NULL) |
@@ -13750,6 +14095,7 @@ static int patch_alc269(struct hda_codec *codec) | |||
13750 | alc_free(codec); | 14095 | alc_free(codec); |
13751 | return -ENOMEM; | 14096 | return -ENOMEM; |
13752 | } | 14097 | } |
14098 | is_alc269vb = 1; | ||
13753 | } | 14099 | } |
13754 | 14100 | ||
13755 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, | 14101 | board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, |
@@ -13785,7 +14131,7 @@ static int patch_alc269(struct hda_codec *codec) | |||
13785 | if (board_config != ALC269_AUTO) | 14131 | if (board_config != ALC269_AUTO) |
13786 | setup_preset(codec, &alc269_presets[board_config]); | 14132 | setup_preset(codec, &alc269_presets[board_config]); |
13787 | 14133 | ||
13788 | if (codec->subsystem_id == 0x17aa3bf8) { | 14134 | if (board_config == ALC269_QUANTA_FL1) { |
13789 | /* Due to a hardware problem on Lenovo Ideadpad, we need to | 14135 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
13790 | * fix the sample rate of analog I/O to 44.1kHz | 14136 | * fix the sample rate of analog I/O to 44.1kHz |
13791 | */ | 14137 | */ |
@@ -13798,9 +14144,16 @@ static int patch_alc269(struct hda_codec *codec) | |||
13798 | spec->stream_digital_playback = &alc269_pcm_digital_playback; | 14144 | spec->stream_digital_playback = &alc269_pcm_digital_playback; |
13799 | spec->stream_digital_capture = &alc269_pcm_digital_capture; | 14145 | spec->stream_digital_capture = &alc269_pcm_digital_capture; |
13800 | 14146 | ||
13801 | spec->adc_nids = alc269_adc_nids; | 14147 | if (!is_alc269vb) { |
13802 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); | 14148 | spec->adc_nids = alc269_adc_nids; |
13803 | spec->capsrc_nids = alc269_capsrc_nids; | 14149 | spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); |
14150 | spec->capsrc_nids = alc269_capsrc_nids; | ||
14151 | } else { | ||
14152 | spec->adc_nids = alc269vb_adc_nids; | ||
14153 | spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids); | ||
14154 | spec->capsrc_nids = alc269vb_capsrc_nids; | ||
14155 | } | ||
14156 | |||
13804 | if (!spec->cap_mixer) | 14157 | if (!spec->cap_mixer) |
13805 | set_capture_mixer(codec); | 14158 | set_capture_mixer(codec); |
13806 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); | 14159 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
@@ -13814,7 +14167,6 @@ static int patch_alc269(struct hda_codec *codec) | |||
13814 | if (!spec->loopback.amplist) | 14167 | if (!spec->loopback.amplist) |
13815 | spec->loopback.amplist = alc269_loopbacks; | 14168 | spec->loopback.amplist = alc269_loopbacks; |
13816 | #endif | 14169 | #endif |
13817 | codec->proc_widget_hook = print_realtek_coef; | ||
13818 | 14170 | ||
13819 | return 0; | 14171 | return 0; |
13820 | } | 14172 | } |
@@ -14677,7 +15029,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec) | |||
14677 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | 15029 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); |
14678 | set_capture_mixer(codec); | 15030 | set_capture_mixer(codec); |
14679 | 15031 | ||
14680 | alc_ssid_check(codec, 0x0e, 0x0f, 0x0b); | 15032 | alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0); |
14681 | 15033 | ||
14682 | return 1; | 15034 | return 1; |
14683 | } | 15035 | } |
@@ -14932,13 +15284,16 @@ static int patch_alc861(struct hda_codec *codec) | |||
14932 | spec->vmaster_nid = 0x03; | 15284 | spec->vmaster_nid = 0x03; |
14933 | 15285 | ||
14934 | codec->patch_ops = alc_patch_ops; | 15286 | codec->patch_ops = alc_patch_ops; |
14935 | if (board_config == ALC861_AUTO) | 15287 | if (board_config == ALC861_AUTO) { |
14936 | spec->init_hook = alc861_auto_init; | 15288 | spec->init_hook = alc861_auto_init; |
14937 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 15289 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
15290 | spec->power_hook = alc_power_eapd; | ||
15291 | #endif | ||
15292 | } | ||
15293 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
14938 | if (!spec->loopback.amplist) | 15294 | if (!spec->loopback.amplist) |
14939 | spec->loopback.amplist = alc861_loopbacks; | 15295 | spec->loopback.amplist = alc861_loopbacks; |
14940 | #endif | 15296 | #endif |
14941 | codec->proc_widget_hook = print_realtek_coef; | ||
14942 | 15297 | ||
14943 | return 0; | 15298 | return 0; |
14944 | } | 15299 | } |
@@ -15565,7 +15920,7 @@ static struct alc_config_preset alc861vd_presets[] = { | |||
15565 | static int alc861vd_auto_create_input_ctls(struct hda_codec *codec, | 15920 | static int alc861vd_auto_create_input_ctls(struct hda_codec *codec, |
15566 | const struct auto_pin_cfg *cfg) | 15921 | const struct auto_pin_cfg *cfg) |
15567 | { | 15922 | { |
15568 | return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x22, 0); | 15923 | return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0); |
15569 | } | 15924 | } |
15570 | 15925 | ||
15571 | 15926 | ||
@@ -15801,7 +16156,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec) | |||
15801 | if (err < 0) | 16156 | if (err < 0) |
15802 | return err; | 16157 | return err; |
15803 | 16158 | ||
15804 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | 16159 | alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); |
15805 | 16160 | ||
15806 | return 1; | 16161 | return 1; |
15807 | } | 16162 | } |
@@ -15918,7 +16273,6 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
15918 | if (!spec->loopback.amplist) | 16273 | if (!spec->loopback.amplist) |
15919 | spec->loopback.amplist = alc861vd_loopbacks; | 16274 | spec->loopback.amplist = alc861vd_loopbacks; |
15920 | #endif | 16275 | #endif |
15921 | codec->proc_widget_hook = print_realtek_coef; | ||
15922 | 16276 | ||
15923 | return 0; | 16277 | return 0; |
15924 | } | 16278 | } |
@@ -16385,13 +16739,6 @@ static struct hda_verb alc662_init_verbs[] = { | |||
16385 | /* ADC: mute amp left and right */ | 16739 | /* ADC: mute amp left and right */ |
16386 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | 16740 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, |
16387 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | 16741 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, |
16388 | /* Front mixer: unmute input/output amp left and right (volume = 0) */ | ||
16389 | |||
16390 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
16391 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
16392 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
16393 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
16394 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
16395 | 16742 | ||
16396 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 16743 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
16397 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | 16744 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, |
@@ -16441,6 +16788,28 @@ static struct hda_verb alc662_init_verbs[] = { | |||
16441 | { } | 16788 | { } |
16442 | }; | 16789 | }; |
16443 | 16790 | ||
16791 | static struct hda_verb alc663_init_verbs[] = { | ||
16792 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
16793 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16794 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
16795 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16796 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
16797 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
16798 | { } | ||
16799 | }; | ||
16800 | |||
16801 | static struct hda_verb alc272_init_verbs[] = { | ||
16802 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | ||
16803 | {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, | ||
16804 | {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
16805 | {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16806 | {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, | ||
16807 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
16808 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
16809 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
16810 | { } | ||
16811 | }; | ||
16812 | |||
16444 | static struct hda_verb alc662_sue_init_verbs[] = { | 16813 | static struct hda_verb alc662_sue_init_verbs[] = { |
16445 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, | 16814 | {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT}, |
16446 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, | 16815 | {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT}, |
@@ -16460,61 +16829,6 @@ static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = { | |||
16460 | {} | 16829 | {} |
16461 | }; | 16830 | }; |
16462 | 16831 | ||
16463 | /* | ||
16464 | * generic initialization of ADC, input mixers and output mixers | ||
16465 | */ | ||
16466 | static struct hda_verb alc662_auto_init_verbs[] = { | ||
16467 | /* | ||
16468 | * Unmute ADC and set the default input to mic-in | ||
16469 | */ | ||
16470 | {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
16471 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
16472 | |||
16473 | /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback | ||
16474 | * mixer widget | ||
16475 | * Note: PASD motherboards uses the Line In 2 as the input for front | ||
16476 | * panel mic (mic 2) | ||
16477 | */ | ||
16478 | /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ | ||
16479 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
16480 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
16481 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
16482 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
16483 | {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
16484 | |||
16485 | /* | ||
16486 | * Set up output mixers (0x0c - 0x0f) | ||
16487 | */ | ||
16488 | /* set vol=0 to output mixers */ | ||
16489 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
16490 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
16491 | {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, | ||
16492 | |||
16493 | /* set up input amps for analog loopback */ | ||
16494 | /* Amp Indices: DAC = 0, mixer = 1 */ | ||
16495 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
16496 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
16497 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
16498 | {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
16499 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
16500 | {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
16501 | |||
16502 | |||
16503 | /* FIXME: use matrix-type input source selection */ | ||
16504 | /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ | ||
16505 | /* Input mixer */ | ||
16506 | {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
16507 | {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
16508 | { } | ||
16509 | }; | ||
16510 | |||
16511 | /* additional verbs for ALC663 */ | ||
16512 | static struct hda_verb alc663_auto_init_verbs[] = { | ||
16513 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | ||
16514 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, | ||
16515 | { } | ||
16516 | }; | ||
16517 | |||
16518 | static struct hda_verb alc663_m51va_init_verbs[] = { | 16832 | static struct hda_verb alc663_m51va_init_verbs[] = { |
16519 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | 16833 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
16520 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, | 16834 | {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, |
@@ -17265,6 +17579,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = { | |||
17265 | SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1), | 17579 | SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1), |
17266 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1), | 17580 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1), |
17267 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3), | 17581 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3), |
17582 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1), | ||
17268 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3), | 17583 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3), |
17269 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), | 17584 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), |
17270 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), | 17585 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), |
@@ -17300,6 +17615,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = { | |||
17300 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3), | 17615 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3), |
17301 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3), | 17616 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3), |
17302 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1), | 17617 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1), |
17618 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1), | ||
17303 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1), | 17619 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1), |
17304 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1), | 17620 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1), |
17305 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1), | 17621 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1), |
@@ -17327,6 +17643,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = { | |||
17327 | SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10), | 17643 | SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10), |
17328 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", | 17644 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", |
17329 | ALC662_3ST_6ch_DIG), | 17645 | ALC662_3ST_6ch_DIG), |
17646 | SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13), | ||
17330 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), | 17647 | SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), |
17331 | SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA), | 17648 | SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA), |
17332 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), | 17649 | SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E), |
@@ -17945,15 +18262,23 @@ static int alc662_parse_auto_config(struct hda_codec *codec) | |||
17945 | spec->num_mux_defs = 1; | 18262 | spec->num_mux_defs = 1; |
17946 | spec->input_mux = &spec->private_imux[0]; | 18263 | spec->input_mux = &spec->private_imux[0]; |
17947 | 18264 | ||
17948 | add_verb(spec, alc662_auto_init_verbs); | 18265 | add_verb(spec, alc662_init_verbs); |
17949 | if (codec->vendor_id == 0x10ec0663) | 18266 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
17950 | add_verb(spec, alc663_auto_init_verbs); | 18267 | codec->vendor_id == 0x10ec0665) |
18268 | add_verb(spec, alc663_init_verbs); | ||
18269 | |||
18270 | if (codec->vendor_id == 0x10ec0272) | ||
18271 | add_verb(spec, alc272_init_verbs); | ||
17951 | 18272 | ||
17952 | err = alc_auto_add_mic_boost(codec); | 18273 | err = alc_auto_add_mic_boost(codec); |
17953 | if (err < 0) | 18274 | if (err < 0) |
17954 | return err; | 18275 | return err; |
17955 | 18276 | ||
17956 | alc_ssid_check(codec, 0x15, 0x1b, 0x14); | 18277 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
18278 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) | ||
18279 | alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21); | ||
18280 | else | ||
18281 | alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); | ||
17957 | 18282 | ||
17958 | return 1; | 18283 | return 1; |
17959 | } | 18284 | } |
@@ -18039,11 +18364,20 @@ static int patch_alc662(struct hda_codec *codec) | |||
18039 | 18364 | ||
18040 | if (!spec->cap_mixer) | 18365 | if (!spec->cap_mixer) |
18041 | set_capture_mixer(codec); | 18366 | set_capture_mixer(codec); |
18042 | if (codec->vendor_id == 0x10ec0662) | 18367 | |
18368 | switch (codec->vendor_id) { | ||
18369 | case 0x10ec0662: | ||
18043 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 18370 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
18044 | else | 18371 | break; |
18372 | case 0x10ec0272: | ||
18373 | case 0x10ec0663: | ||
18374 | case 0x10ec0665: | ||
18045 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); | 18375 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
18046 | 18376 | break; | |
18377 | case 0x10ec0273: | ||
18378 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); | ||
18379 | break; | ||
18380 | } | ||
18047 | spec->vmaster_nid = 0x02; | 18381 | spec->vmaster_nid = 0x02; |
18048 | 18382 | ||
18049 | codec->patch_ops = alc_patch_ops; | 18383 | codec->patch_ops = alc_patch_ops; |
@@ -18053,7 +18387,6 @@ static int patch_alc662(struct hda_codec *codec) | |||
18053 | if (!spec->loopback.amplist) | 18387 | if (!spec->loopback.amplist) |
18054 | spec->loopback.amplist = alc662_loopbacks; | 18388 | spec->loopback.amplist = alc662_loopbacks; |
18055 | #endif | 18389 | #endif |
18056 | codec->proc_widget_hook = print_realtek_coef; | ||
18057 | 18390 | ||
18058 | return 0; | 18391 | return 0; |
18059 | } | 18392 | } |
@@ -18094,6 +18427,8 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
18094 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", | 18427 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
18095 | .patch = patch_alc662 }, | 18428 | .patch = patch_alc662 }, |
18096 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, | 18429 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
18430 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, | ||
18431 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, | ||
18097 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, | 18432 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
18098 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, | 18433 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
18099 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, | 18434 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c index 43b436c5d01b..f419ee8d75f0 100644 --- a/sound/pci/hda/patch_si3054.c +++ b/sound/pci/hda/patch_si3054.c | |||
@@ -122,6 +122,7 @@ static int si3054_switch_put(struct snd_kcontrol *kcontrol, | |||
122 | #define SI3054_KCONTROL(kname,reg,mask) { \ | 122 | #define SI3054_KCONTROL(kname,reg,mask) { \ |
123 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 123 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
124 | .name = kname, \ | 124 | .name = kname, \ |
125 | .subdevice = HDA_SUBDEV_NID_FLAG | reg, \ | ||
125 | .info = si3054_switch_info, \ | 126 | .info = si3054_switch_info, \ |
126 | .get = si3054_switch_get, \ | 127 | .get = si3054_switch_get, \ |
127 | .put = si3054_switch_put, \ | 128 | .put = si3054_switch_put, \ |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 799ba2570902..8c416bb18a57 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -568,6 +568,11 @@ static hda_nid_t stac92hd83xxx_pin_nids[10] = { | |||
568 | 0x0f, 0x10, 0x11, 0x1f, 0x20, | 568 | 0x0f, 0x10, 0x11, 0x1f, 0x20, |
569 | }; | 569 | }; |
570 | 570 | ||
571 | static hda_nid_t stac92hd88xxx_pin_nids[10] = { | ||
572 | 0x0a, 0x0b, 0x0c, 0x0d, | ||
573 | 0x0f, 0x11, 0x1f, 0x20, | ||
574 | }; | ||
575 | |||
571 | #define STAC92HD71BXX_NUM_PINS 13 | 576 | #define STAC92HD71BXX_NUM_PINS 13 |
572 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { | 577 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
573 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, | 578 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
@@ -2688,7 +2693,7 @@ static struct snd_kcontrol_new * | |||
2688 | stac_control_new(struct sigmatel_spec *spec, | 2693 | stac_control_new(struct sigmatel_spec *spec, |
2689 | struct snd_kcontrol_new *ktemp, | 2694 | struct snd_kcontrol_new *ktemp, |
2690 | const char *name, | 2695 | const char *name, |
2691 | hda_nid_t nid) | 2696 | unsigned int subdev) |
2692 | { | 2697 | { |
2693 | struct snd_kcontrol_new *knew; | 2698 | struct snd_kcontrol_new *knew; |
2694 | 2699 | ||
@@ -2704,8 +2709,7 @@ stac_control_new(struct sigmatel_spec *spec, | |||
2704 | spec->kctls.alloced--; | 2709 | spec->kctls.alloced--; |
2705 | return NULL; | 2710 | return NULL; |
2706 | } | 2711 | } |
2707 | if (nid) | 2712 | knew->subdevice = subdev; |
2708 | knew->subdevice = HDA_SUBDEV_NID_FLAG | nid; | ||
2709 | return knew; | 2713 | return knew; |
2710 | } | 2714 | } |
2711 | 2715 | ||
@@ -2715,7 +2719,7 @@ static int stac92xx_add_control_temp(struct sigmatel_spec *spec, | |||
2715 | unsigned long val) | 2719 | unsigned long val) |
2716 | { | 2720 | { |
2717 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name, | 2721 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name, |
2718 | get_amp_nid_(val)); | 2722 | HDA_SUBDEV_AMP_FLAG); |
2719 | if (!knew) | 2723 | if (!knew) |
2720 | return -ENOMEM; | 2724 | return -ENOMEM; |
2721 | knew->index = idx; | 2725 | knew->index = idx; |
@@ -2874,6 +2878,13 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) | |||
2874 | 2878 | ||
2875 | conn_len = snd_hda_get_connections(codec, nid, conn, | 2879 | conn_len = snd_hda_get_connections(codec, nid, conn, |
2876 | HDA_MAX_CONNECTIONS); | 2880 | HDA_MAX_CONNECTIONS); |
2881 | /* 92HD88: trace back up the link of nids to find the DAC */ | ||
2882 | while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0])) | ||
2883 | != AC_WID_AUD_OUT)) { | ||
2884 | nid = conn[0]; | ||
2885 | conn_len = snd_hda_get_connections(codec, nid, conn, | ||
2886 | HDA_MAX_CONNECTIONS); | ||
2887 | } | ||
2877 | for (j = 0; j < conn_len; j++) { | 2888 | for (j = 0; j < conn_len; j++) { |
2878 | wcaps = get_wcaps(codec, conn[j]); | 2889 | wcaps = get_wcaps(codec, conn[j]); |
2879 | wtype = get_wcaps_type(wcaps); | 2890 | wtype = get_wcaps_type(wcaps); |
@@ -4160,34 +4171,52 @@ static void stac92xx_power_down(struct hda_codec *codec) | |||
4160 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, | 4171 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
4161 | int enable); | 4172 | int enable); |
4162 | 4173 | ||
4174 | static inline int get_int_hint(struct hda_codec *codec, const char *key, | ||
4175 | int *valp) | ||
4176 | { | ||
4177 | const char *p; | ||
4178 | p = snd_hda_get_hint(codec, key); | ||
4179 | if (p) { | ||
4180 | unsigned long val; | ||
4181 | if (!strict_strtoul(p, 0, &val)) { | ||
4182 | *valp = val; | ||
4183 | return 1; | ||
4184 | } | ||
4185 | } | ||
4186 | return 0; | ||
4187 | } | ||
4188 | |||
4163 | /* override some hints from the hwdep entry */ | 4189 | /* override some hints from the hwdep entry */ |
4164 | static void stac_store_hints(struct hda_codec *codec) | 4190 | static void stac_store_hints(struct hda_codec *codec) |
4165 | { | 4191 | { |
4166 | struct sigmatel_spec *spec = codec->spec; | 4192 | struct sigmatel_spec *spec = codec->spec; |
4167 | const char *p; | ||
4168 | int val; | 4193 | int val; |
4169 | 4194 | ||
4170 | val = snd_hda_get_bool_hint(codec, "hp_detect"); | 4195 | val = snd_hda_get_bool_hint(codec, "hp_detect"); |
4171 | if (val >= 0) | 4196 | if (val >= 0) |
4172 | spec->hp_detect = val; | 4197 | spec->hp_detect = val; |
4173 | p = snd_hda_get_hint(codec, "gpio_mask"); | 4198 | if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) { |
4174 | if (p) { | ||
4175 | spec->gpio_mask = simple_strtoul(p, NULL, 0); | ||
4176 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = | 4199 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = |
4177 | spec->gpio_mask; | 4200 | spec->gpio_mask; |
4178 | } | 4201 | } |
4179 | p = snd_hda_get_hint(codec, "gpio_dir"); | 4202 | if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir)) |
4180 | if (p) | 4203 | spec->gpio_mask &= spec->gpio_mask; |
4181 | spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask; | 4204 | if (get_int_hint(codec, "gpio_data", &spec->gpio_data)) |
4182 | p = snd_hda_get_hint(codec, "gpio_data"); | 4205 | spec->gpio_dir &= spec->gpio_mask; |
4183 | if (p) | 4206 | if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask)) |
4184 | spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask; | 4207 | spec->eapd_mask &= spec->gpio_mask; |
4185 | p = snd_hda_get_hint(codec, "eapd_mask"); | 4208 | if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute)) |
4186 | if (p) | 4209 | spec->gpio_mute &= spec->gpio_mask; |
4187 | spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask; | ||
4188 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); | 4210 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); |
4189 | if (val >= 0) | 4211 | if (val >= 0) |
4190 | spec->eapd_switch = val; | 4212 | spec->eapd_switch = val; |
4213 | get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity); | ||
4214 | if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) { | ||
4215 | spec->gpio_mask |= spec->gpio_led; | ||
4216 | spec->gpio_dir |= spec->gpio_led; | ||
4217 | if (spec->gpio_led_polarity) | ||
4218 | spec->gpio_data |= spec->gpio_led; | ||
4219 | } | ||
4191 | } | 4220 | } |
4192 | 4221 | ||
4193 | static int stac92xx_init(struct hda_codec *codec) | 4222 | static int stac92xx_init(struct hda_codec *codec) |
@@ -4334,6 +4363,12 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4334 | if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) | 4363 | if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) |
4335 | stac_issue_unsol_event(codec, nid); | 4364 | stac_issue_unsol_event(codec, nid); |
4336 | } | 4365 | } |
4366 | |||
4367 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
4368 | /* sync mute LED */ | ||
4369 | if (spec->gpio_led && codec->patch_ops.check_power_status) | ||
4370 | codec->patch_ops.check_power_status(codec, 0x01); | ||
4371 | #endif | ||
4337 | if (spec->dac_list) | 4372 | if (spec->dac_list) |
4338 | stac92xx_power_down(codec); | 4373 | stac92xx_power_down(codec); |
4339 | return 0; | 4374 | return 0; |
@@ -4372,18 +4407,8 @@ static void stac92xx_free_kctls(struct hda_codec *codec) | |||
4372 | static void stac92xx_shutup(struct hda_codec *codec) | 4407 | static void stac92xx_shutup(struct hda_codec *codec) |
4373 | { | 4408 | { |
4374 | struct sigmatel_spec *spec = codec->spec; | 4409 | struct sigmatel_spec *spec = codec->spec; |
4375 | int i; | ||
4376 | hda_nid_t nid; | ||
4377 | 4410 | ||
4378 | /* reset each pin before powering down DAC/ADC to avoid click noise */ | 4411 | snd_hda_shutup_pins(codec); |
4379 | nid = codec->start_nid; | ||
4380 | for (i = 0; i < codec->num_nodes; i++, nid++) { | ||
4381 | unsigned int wcaps = get_wcaps(codec, nid); | ||
4382 | unsigned int wid_type = get_wcaps_type(wcaps); | ||
4383 | if (wid_type == AC_WID_PIN) | ||
4384 | snd_hda_codec_read(codec, nid, 0, | ||
4385 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | ||
4386 | } | ||
4387 | 4412 | ||
4388 | if (spec->eapd_mask) | 4413 | if (spec->eapd_mask) |
4389 | stac_gpio_set(codec, spec->gpio_mask, | 4414 | stac_gpio_set(codec, spec->gpio_mask, |
@@ -4735,19 +4760,14 @@ static int hp_blike_system(u32 subsystem_id); | |||
4735 | static void set_hp_led_gpio(struct hda_codec *codec) | 4760 | static void set_hp_led_gpio(struct hda_codec *codec) |
4736 | { | 4761 | { |
4737 | struct sigmatel_spec *spec = codec->spec; | 4762 | struct sigmatel_spec *spec = codec->spec; |
4738 | switch (codec->vendor_id) { | 4763 | unsigned int gpio; |
4739 | case 0x111d7608: | 4764 | |
4740 | /* GPIO 0 */ | 4765 | gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP); |
4741 | spec->gpio_led = 0x01; | 4766 | gpio &= AC_GPIO_IO_COUNT; |
4742 | break; | 4767 | if (gpio > 3) |
4743 | case 0x111d7600: | 4768 | spec->gpio_led = 0x08; /* GPIO 3 */ |
4744 | case 0x111d7601: | 4769 | else |
4745 | case 0x111d7602: | 4770 | spec->gpio_led = 0x01; /* GPIO 0 */ |
4746 | case 0x111d7603: | ||
4747 | /* GPIO 3 */ | ||
4748 | spec->gpio_led = 0x08; | ||
4749 | break; | ||
4750 | } | ||
4751 | } | 4771 | } |
4752 | 4772 | ||
4753 | /* | 4773 | /* |
@@ -4770,7 +4790,7 @@ static void set_hp_led_gpio(struct hda_codec *codec) | |||
4770 | * Need more information on whether it is true across the entire series. | 4790 | * Need more information on whether it is true across the entire series. |
4771 | * -- kunal | 4791 | * -- kunal |
4772 | */ | 4792 | */ |
4773 | static int find_mute_led_gpio(struct hda_codec *codec) | 4793 | static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity) |
4774 | { | 4794 | { |
4775 | struct sigmatel_spec *spec = codec->spec; | 4795 | struct sigmatel_spec *spec = codec->spec; |
4776 | const struct dmi_device *dev = NULL; | 4796 | const struct dmi_device *dev = NULL; |
@@ -4797,7 +4817,7 @@ static int find_mute_led_gpio(struct hda_codec *codec) | |||
4797 | */ | 4817 | */ |
4798 | if (!hp_blike_system(codec->subsystem_id)) { | 4818 | if (!hp_blike_system(codec->subsystem_id)) { |
4799 | set_hp_led_gpio(codec); | 4819 | set_hp_led_gpio(codec); |
4800 | spec->gpio_led_polarity = 1; | 4820 | spec->gpio_led_polarity = default_polarity; |
4801 | return 1; | 4821 | return 1; |
4802 | } | 4822 | } |
4803 | } | 4823 | } |
@@ -4895,6 +4915,11 @@ static int stac92xx_resume(struct hda_codec *codec) | |||
4895 | stac_issue_unsol_event(codec, | 4915 | stac_issue_unsol_event(codec, |
4896 | spec->autocfg.line_out_pins[0]); | 4916 | spec->autocfg.line_out_pins[0]); |
4897 | } | 4917 | } |
4918 | #ifdef CONFIG_SND_HDA_POWER_SAVE | ||
4919 | /* sync mute LED */ | ||
4920 | if (spec->gpio_led && codec->patch_ops.check_power_status) | ||
4921 | codec->patch_ops.check_power_status(codec, 0x01); | ||
4922 | #endif | ||
4898 | return 0; | 4923 | return 0; |
4899 | } | 4924 | } |
4900 | 4925 | ||
@@ -4914,43 +4939,29 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec, | |||
4914 | hda_nid_t nid) | 4939 | hda_nid_t nid) |
4915 | { | 4940 | { |
4916 | struct sigmatel_spec *spec = codec->spec; | 4941 | struct sigmatel_spec *spec = codec->spec; |
4942 | int i, muted = 1; | ||
4917 | 4943 | ||
4918 | if (nid == 0x10) { | 4944 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
4919 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & | 4945 | nid = spec->multiout.dac_nids[i]; |
4920 | HDA_AMP_MUTE) | 4946 | if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & |
4921 | spec->gpio_data &= ~spec->gpio_led; /* orange */ | 4947 | HDA_AMP_MUTE)) { |
4922 | else | 4948 | muted = 0; /* something heard */ |
4923 | spec->gpio_data |= spec->gpio_led; /* white */ | 4949 | break; |
4924 | |||
4925 | if (!spec->gpio_led_polarity) { | ||
4926 | /* LED state is inverted on these systems */ | ||
4927 | spec->gpio_data ^= spec->gpio_led; | ||
4928 | } | 4950 | } |
4929 | |||
4930 | stac_gpio_set(codec, spec->gpio_mask, | ||
4931 | spec->gpio_dir, | ||
4932 | spec->gpio_data); | ||
4933 | } | 4951 | } |
4952 | if (muted) | ||
4953 | spec->gpio_data &= ~spec->gpio_led; /* orange */ | ||
4954 | else | ||
4955 | spec->gpio_data |= spec->gpio_led; /* white */ | ||
4934 | 4956 | ||
4935 | return 0; | 4957 | if (!spec->gpio_led_polarity) { |
4936 | } | 4958 | /* LED state is inverted on these systems */ |
4937 | 4959 | spec->gpio_data ^= spec->gpio_led; | |
4938 | static int idt92hd83xxx_hp_check_power_status(struct hda_codec *codec, | 4960 | } |
4939 | hda_nid_t nid) | ||
4940 | { | ||
4941 | struct sigmatel_spec *spec = codec->spec; | ||
4942 | 4961 | ||
4943 | if (nid != 0x13) | ||
4944 | return 0; | ||
4945 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & HDA_AMP_MUTE) | ||
4946 | spec->gpio_data |= spec->gpio_led; /* mute LED on */ | ||
4947 | else | ||
4948 | spec->gpio_data &= ~spec->gpio_led; /* mute LED off */ | ||
4949 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data); | 4962 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data); |
4950 | |||
4951 | return 0; | 4963 | return 0; |
4952 | } | 4964 | } |
4953 | |||
4954 | #endif | 4965 | #endif |
4955 | 4966 | ||
4956 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) | 4967 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
@@ -5272,7 +5283,6 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
5272 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; | 5283 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; |
5273 | int err; | 5284 | int err; |
5274 | int num_dacs; | 5285 | int num_dacs; |
5275 | hda_nid_t nid; | ||
5276 | 5286 | ||
5277 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5287 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
5278 | if (spec == NULL) | 5288 | if (spec == NULL) |
@@ -5311,7 +5321,18 @@ again: | |||
5311 | stac92hd83xxx_brd_tbl[spec->board_config]); | 5321 | stac92hd83xxx_brd_tbl[spec->board_config]); |
5312 | 5322 | ||
5313 | switch (codec->vendor_id) { | 5323 | switch (codec->vendor_id) { |
5324 | case 0x111d7666: | ||
5325 | case 0x111d7667: | ||
5326 | case 0x111d7668: | ||
5327 | case 0x111d7669: | ||
5328 | spec->num_pins = ARRAY_SIZE(stac92hd88xxx_pin_nids); | ||
5329 | spec->pin_nids = stac92hd88xxx_pin_nids; | ||
5330 | spec->mono_nid = 0; | ||
5331 | spec->digbeep_nid = 0; | ||
5332 | spec->num_pwrs = 0; | ||
5333 | break; | ||
5314 | case 0x111d7604: | 5334 | case 0x111d7604: |
5335 | case 0x111d76d4: | ||
5315 | case 0x111d7605: | 5336 | case 0x111d7605: |
5316 | case 0x111d76d5: | 5337 | case 0x111d76d5: |
5317 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) | 5338 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) |
@@ -5322,8 +5343,10 @@ again: | |||
5322 | 5343 | ||
5323 | codec->patch_ops = stac92xx_patch_ops; | 5344 | codec->patch_ops = stac92xx_patch_ops; |
5324 | 5345 | ||
5325 | if (spec->board_config == STAC_92HD83XXX_HP) | 5346 | if (find_mute_led_gpio(codec, 0)) |
5326 | spec->gpio_led = 0x01; | 5347 | snd_printd("mute LED gpio %d polarity %d\n", |
5348 | spec->gpio_led, | ||
5349 | spec->gpio_led_polarity); | ||
5327 | 5350 | ||
5328 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 5351 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
5329 | if (spec->gpio_led) { | 5352 | if (spec->gpio_led) { |
@@ -5332,7 +5355,7 @@ again: | |||
5332 | spec->gpio_data |= spec->gpio_led; | 5355 | spec->gpio_data |= spec->gpio_led; |
5333 | /* register check_power_status callback. */ | 5356 | /* register check_power_status callback. */ |
5334 | codec->patch_ops.check_power_status = | 5357 | codec->patch_ops.check_power_status = |
5335 | idt92hd83xxx_hp_check_power_status; | 5358 | stac92xx_hp_check_power_status; |
5336 | } | 5359 | } |
5337 | #endif | 5360 | #endif |
5338 | 5361 | ||
@@ -5352,24 +5375,21 @@ again: | |||
5352 | return err; | 5375 | return err; |
5353 | } | 5376 | } |
5354 | 5377 | ||
5355 | switch (spec->board_config) { | 5378 | /* docking output support */ |
5356 | case STAC_DELL_S14: | 5379 | num_dacs = snd_hda_get_connections(codec, 0xF, |
5357 | nid = 0xf; | ||
5358 | break; | ||
5359 | default: | ||
5360 | nid = 0xe; | ||
5361 | break; | ||
5362 | } | ||
5363 | |||
5364 | num_dacs = snd_hda_get_connections(codec, nid, | ||
5365 | conn, STAC92HD83_DAC_COUNT + 1) - 1; | 5380 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
5366 | if (num_dacs < 0) | 5381 | /* skip non-DAC connections */ |
5367 | num_dacs = STAC92HD83_DAC_COUNT; | 5382 | while (num_dacs >= 0 && |
5368 | 5383 | (get_wcaps_type(get_wcaps(codec, conn[num_dacs])) | |
5369 | /* set port X to select the last DAC | 5384 | != AC_WID_AUD_OUT)) |
5370 | */ | 5385 | num_dacs--; |
5371 | snd_hda_codec_write_cache(codec, nid, 0, | 5386 | /* set port E and F to select the last DAC */ |
5387 | if (num_dacs >= 0) { | ||
5388 | snd_hda_codec_write_cache(codec, 0xE, 0, | ||
5389 | AC_VERB_SET_CONNECT_SEL, num_dacs); | ||
5390 | snd_hda_codec_write_cache(codec, 0xF, 0, | ||
5372 | AC_VERB_SET_CONNECT_SEL, num_dacs); | 5391 | AC_VERB_SET_CONNECT_SEL, num_dacs); |
5392 | } | ||
5373 | 5393 | ||
5374 | codec->proc_widget_hook = stac92hd_proc_hook; | 5394 | codec->proc_widget_hook = stac92hd_proc_hook; |
5375 | 5395 | ||
@@ -5431,6 +5451,54 @@ static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, | |||
5431 | return 0; | 5451 | return 0; |
5432 | } | 5452 | } |
5433 | 5453 | ||
5454 | /* HP dv7 bass switch - GPIO5 */ | ||
5455 | #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info | ||
5456 | static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol, | ||
5457 | struct snd_ctl_elem_value *ucontrol) | ||
5458 | { | ||
5459 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
5460 | struct sigmatel_spec *spec = codec->spec; | ||
5461 | ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20); | ||
5462 | return 0; | ||
5463 | } | ||
5464 | |||
5465 | static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol, | ||
5466 | struct snd_ctl_elem_value *ucontrol) | ||
5467 | { | ||
5468 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
5469 | struct sigmatel_spec *spec = codec->spec; | ||
5470 | unsigned int gpio_data; | ||
5471 | |||
5472 | gpio_data = (spec->gpio_data & ~0x20) | | ||
5473 | (ucontrol->value.integer.value[0] ? 0x20 : 0); | ||
5474 | if (gpio_data == spec->gpio_data) | ||
5475 | return 0; | ||
5476 | spec->gpio_data = gpio_data; | ||
5477 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data); | ||
5478 | return 1; | ||
5479 | } | ||
5480 | |||
5481 | static struct snd_kcontrol_new stac_hp_bass_sw_ctrl = { | ||
5482 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
5483 | .info = stac_hp_bass_gpio_info, | ||
5484 | .get = stac_hp_bass_gpio_get, | ||
5485 | .put = stac_hp_bass_gpio_put, | ||
5486 | }; | ||
5487 | |||
5488 | static int stac_add_hp_bass_switch(struct hda_codec *codec) | ||
5489 | { | ||
5490 | struct sigmatel_spec *spec = codec->spec; | ||
5491 | |||
5492 | if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl, | ||
5493 | "Bass Speaker Playback Switch", 0)) | ||
5494 | return -ENOMEM; | ||
5495 | |||
5496 | spec->gpio_mask |= 0x20; | ||
5497 | spec->gpio_dir |= 0x20; | ||
5498 | spec->gpio_data |= 0x20; | ||
5499 | return 0; | ||
5500 | } | ||
5501 | |||
5434 | static int patch_stac92hd71bxx(struct hda_codec *codec) | 5502 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
5435 | { | 5503 | { |
5436 | struct sigmatel_spec *spec; | 5504 | struct sigmatel_spec *spec; |
@@ -5602,7 +5670,6 @@ again: | |||
5602 | */ | 5670 | */ |
5603 | spec->num_smuxes = 1; | 5671 | spec->num_smuxes = 1; |
5604 | spec->num_dmuxes = 1; | 5672 | spec->num_dmuxes = 1; |
5605 | spec->gpio_led = 0x01; | ||
5606 | /* fallthrough */ | 5673 | /* fallthrough */ |
5607 | case STAC_HP_DV5: | 5674 | case STAC_HP_DV5: |
5608 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); | 5675 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
@@ -5617,8 +5684,6 @@ again: | |||
5617 | spec->num_dmics = 1; | 5684 | spec->num_dmics = 1; |
5618 | spec->num_dmuxes = 1; | 5685 | spec->num_dmuxes = 1; |
5619 | spec->num_smuxes = 1; | 5686 | spec->num_smuxes = 1; |
5620 | /* orange/white mute led on GPIO3, orange=0, white=1 */ | ||
5621 | spec->gpio_led = 0x08; | ||
5622 | break; | 5687 | break; |
5623 | } | 5688 | } |
5624 | 5689 | ||
@@ -5640,7 +5705,7 @@ again: | |||
5640 | } | 5705 | } |
5641 | } | 5706 | } |
5642 | 5707 | ||
5643 | if (find_mute_led_gpio(codec)) | 5708 | if (find_mute_led_gpio(codec, 1)) |
5644 | snd_printd("mute LED gpio %d polarity %d\n", | 5709 | snd_printd("mute LED gpio %d polarity %d\n", |
5645 | spec->gpio_led, | 5710 | spec->gpio_led, |
5646 | spec->gpio_led_polarity); | 5711 | spec->gpio_led_polarity); |
@@ -5674,6 +5739,15 @@ again: | |||
5674 | return err; | 5739 | return err; |
5675 | } | 5740 | } |
5676 | 5741 | ||
5742 | /* enable bass on HP dv7 */ | ||
5743 | if (spec->board_config == STAC_HP_DV5) { | ||
5744 | unsigned int cap; | ||
5745 | cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP); | ||
5746 | cap &= AC_GPIO_IO_COUNT; | ||
5747 | if (cap >= 6) | ||
5748 | stac_add_hp_bass_switch(codec); | ||
5749 | } | ||
5750 | |||
5677 | codec->proc_widget_hook = stac92hd7x_proc_hook; | 5751 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
5678 | 5752 | ||
5679 | return 0; | 5753 | return 0; |
@@ -6172,8 +6246,13 @@ static struct hda_codec_preset snd_hda_preset_sigmatel[] = { | |||
6172 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, | 6246 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
6173 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, | 6247 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
6174 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, | 6248 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
6249 | { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx}, | ||
6175 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, | 6250 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
6176 | { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, | 6251 | { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, |
6252 | { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx}, | ||
6253 | { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx}, | ||
6254 | { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx}, | ||
6255 | { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx}, | ||
6177 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, | 6256 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
6178 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, | 6257 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
6179 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, | 6258 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index b70e26ad263f..9ddc37300f6b 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -54,6 +54,8 @@ | |||
54 | #include "hda_codec.h" | 54 | #include "hda_codec.h" |
55 | #include "hda_local.h" | 55 | #include "hda_local.h" |
56 | 56 | ||
57 | #define NID_MAPPING (-1) | ||
58 | |||
57 | /* amp values */ | 59 | /* amp values */ |
58 | #define AMP_VAL_IDX_SHIFT 19 | 60 | #define AMP_VAL_IDX_SHIFT 19 |
59 | #define AMP_VAL_IDX_MASK (0x0f<<19) | 61 | #define AMP_VAL_IDX_MASK (0x0f<<19) |
@@ -157,6 +159,19 @@ struct via_spec { | |||
157 | #endif | 159 | #endif |
158 | }; | 160 | }; |
159 | 161 | ||
162 | static struct via_spec * via_new_spec(struct hda_codec *codec) | ||
163 | { | ||
164 | struct via_spec *spec; | ||
165 | |||
166 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
167 | if (spec == NULL) | ||
168 | return NULL; | ||
169 | |||
170 | codec->spec = spec; | ||
171 | spec->codec = codec; | ||
172 | return spec; | ||
173 | } | ||
174 | |||
160 | static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) | 175 | static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) |
161 | { | 176 | { |
162 | u32 vendor_id = codec->vendor_id; | 177 | u32 vendor_id = codec->vendor_id; |
@@ -443,11 +458,27 @@ static int via_add_control(struct via_spec *spec, int type, const char *name, | |||
443 | if (!knew->name) | 458 | if (!knew->name) |
444 | return -ENOMEM; | 459 | return -ENOMEM; |
445 | if (get_amp_nid_(val)) | 460 | if (get_amp_nid_(val)) |
446 | knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); | 461 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
447 | knew->private_value = val; | 462 | knew->private_value = val; |
448 | return 0; | 463 | return 0; |
449 | } | 464 | } |
450 | 465 | ||
466 | static struct snd_kcontrol_new *via_clone_control(struct via_spec *spec, | ||
467 | struct snd_kcontrol_new *tmpl) | ||
468 | { | ||
469 | struct snd_kcontrol_new *knew; | ||
470 | |||
471 | snd_array_init(&spec->kctls, sizeof(*knew), 32); | ||
472 | knew = snd_array_new(&spec->kctls); | ||
473 | if (!knew) | ||
474 | return NULL; | ||
475 | *knew = *tmpl; | ||
476 | knew->name = kstrdup(tmpl->name, GFP_KERNEL); | ||
477 | if (!knew->name) | ||
478 | return NULL; | ||
479 | return 0; | ||
480 | } | ||
481 | |||
451 | static void via_free_kctls(struct hda_codec *codec) | 482 | static void via_free_kctls(struct hda_codec *codec) |
452 | { | 483 | { |
453 | struct via_spec *spec = codec->spec; | 484 | struct via_spec *spec = codec->spec; |
@@ -1088,24 +1119,9 @@ static int via_independent_hp_get(struct snd_kcontrol *kcontrol, | |||
1088 | struct snd_ctl_elem_value *ucontrol) | 1119 | struct snd_ctl_elem_value *ucontrol) |
1089 | { | 1120 | { |
1090 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 1121 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
1091 | struct via_spec *spec = codec->spec; | 1122 | hda_nid_t nid = kcontrol->private_value; |
1092 | hda_nid_t nid; | ||
1093 | unsigned int pinsel; | 1123 | unsigned int pinsel; |
1094 | 1124 | ||
1095 | switch (spec->codec_type) { | ||
1096 | case VT1718S: | ||
1097 | nid = 0x34; | ||
1098 | break; | ||
1099 | case VT2002P: | ||
1100 | nid = 0x35; | ||
1101 | break; | ||
1102 | case VT1812: | ||
1103 | nid = 0x3d; | ||
1104 | break; | ||
1105 | default: | ||
1106 | nid = spec->autocfg.hp_pins[0]; | ||
1107 | break; | ||
1108 | } | ||
1109 | /* use !! to translate conn sel 2 for VT1718S */ | 1125 | /* use !! to translate conn sel 2 for VT1718S */ |
1110 | pinsel = !!snd_hda_codec_read(codec, nid, 0, | 1126 | pinsel = !!snd_hda_codec_read(codec, nid, 0, |
1111 | AC_VERB_GET_CONNECT_SEL, | 1127 | AC_VERB_GET_CONNECT_SEL, |
@@ -1127,29 +1143,24 @@ static void activate_ctl(struct hda_codec *codec, const char *name, int active) | |||
1127 | } | 1143 | } |
1128 | } | 1144 | } |
1129 | 1145 | ||
1146 | static hda_nid_t side_mute_channel(struct via_spec *spec) | ||
1147 | { | ||
1148 | switch (spec->codec_type) { | ||
1149 | case VT1708: return 0x1b; | ||
1150 | case VT1709_10CH: return 0x29; | ||
1151 | case VT1708B_8CH: /* fall thru */ | ||
1152 | case VT1708S: return 0x27; | ||
1153 | default: return 0; | ||
1154 | } | ||
1155 | } | ||
1156 | |||
1130 | static int update_side_mute_status(struct hda_codec *codec) | 1157 | static int update_side_mute_status(struct hda_codec *codec) |
1131 | { | 1158 | { |
1132 | /* mute side channel */ | 1159 | /* mute side channel */ |
1133 | struct via_spec *spec = codec->spec; | 1160 | struct via_spec *spec = codec->spec; |
1134 | unsigned int parm = spec->hp_independent_mode | 1161 | unsigned int parm = spec->hp_independent_mode |
1135 | ? AMP_OUT_MUTE : AMP_OUT_UNMUTE; | 1162 | ? AMP_OUT_MUTE : AMP_OUT_UNMUTE; |
1136 | hda_nid_t sw3; | 1163 | hda_nid_t sw3 = side_mute_channel(spec); |
1137 | |||
1138 | switch (spec->codec_type) { | ||
1139 | case VT1708: | ||
1140 | sw3 = 0x1b; | ||
1141 | break; | ||
1142 | case VT1709_10CH: | ||
1143 | sw3 = 0x29; | ||
1144 | break; | ||
1145 | case VT1708B_8CH: | ||
1146 | case VT1708S: | ||
1147 | sw3 = 0x27; | ||
1148 | break; | ||
1149 | default: | ||
1150 | sw3 = 0; | ||
1151 | break; | ||
1152 | } | ||
1153 | 1164 | ||
1154 | if (sw3) | 1165 | if (sw3) |
1155 | snd_hda_codec_write(codec, sw3, 0, AC_VERB_SET_AMP_GAIN_MUTE, | 1166 | snd_hda_codec_write(codec, sw3, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
@@ -1162,28 +1173,11 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol, | |||
1162 | { | 1173 | { |
1163 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 1174 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
1164 | struct via_spec *spec = codec->spec; | 1175 | struct via_spec *spec = codec->spec; |
1165 | hda_nid_t nid = spec->autocfg.hp_pins[0]; | 1176 | hda_nid_t nid = kcontrol->private_value; |
1166 | unsigned int pinsel = ucontrol->value.enumerated.item[0]; | 1177 | unsigned int pinsel = ucontrol->value.enumerated.item[0]; |
1167 | /* Get Independent Mode index of headphone pin widget */ | 1178 | /* Get Independent Mode index of headphone pin widget */ |
1168 | spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel | 1179 | spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel |
1169 | ? 1 : 0; | 1180 | ? 1 : 0; |
1170 | |||
1171 | switch (spec->codec_type) { | ||
1172 | case VT1718S: | ||
1173 | nid = 0x34; | ||
1174 | pinsel = pinsel ? 2 : 0; /* indep HP use AOW4 (index 2) */ | ||
1175 | spec->multiout.num_dacs = 4; | ||
1176 | break; | ||
1177 | case VT2002P: | ||
1178 | nid = 0x35; | ||
1179 | break; | ||
1180 | case VT1812: | ||
1181 | nid = 0x3d; | ||
1182 | break; | ||
1183 | default: | ||
1184 | nid = spec->autocfg.hp_pins[0]; | ||
1185 | break; | ||
1186 | } | ||
1187 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, pinsel); | 1181 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, pinsel); |
1188 | 1182 | ||
1189 | if (spec->multiout.hp_nid && spec->multiout.hp_nid | 1183 | if (spec->multiout.hp_nid && spec->multiout.hp_nid |
@@ -1207,18 +1201,55 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol, | |||
1207 | return 0; | 1201 | return 0; |
1208 | } | 1202 | } |
1209 | 1203 | ||
1210 | static struct snd_kcontrol_new via_hp_mixer[] = { | 1204 | static struct snd_kcontrol_new via_hp_mixer[2] = { |
1211 | { | 1205 | { |
1212 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1206 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
1213 | .name = "Independent HP", | 1207 | .name = "Independent HP", |
1214 | .count = 1, | ||
1215 | .info = via_independent_hp_info, | 1208 | .info = via_independent_hp_info, |
1216 | .get = via_independent_hp_get, | 1209 | .get = via_independent_hp_get, |
1217 | .put = via_independent_hp_put, | 1210 | .put = via_independent_hp_put, |
1218 | }, | 1211 | }, |
1219 | { } /* end */ | 1212 | { |
1213 | .iface = NID_MAPPING, | ||
1214 | .name = "Independent HP", | ||
1215 | }, | ||
1220 | }; | 1216 | }; |
1221 | 1217 | ||
1218 | static int via_hp_build(struct via_spec *spec) | ||
1219 | { | ||
1220 | struct snd_kcontrol_new *knew; | ||
1221 | hda_nid_t nid; | ||
1222 | |||
1223 | knew = via_clone_control(spec, &via_hp_mixer[0]); | ||
1224 | if (knew == NULL) | ||
1225 | return -ENOMEM; | ||
1226 | |||
1227 | switch (spec->codec_type) { | ||
1228 | case VT1718S: | ||
1229 | nid = 0x34; | ||
1230 | break; | ||
1231 | case VT2002P: | ||
1232 | nid = 0x35; | ||
1233 | break; | ||
1234 | case VT1812: | ||
1235 | nid = 0x3d; | ||
1236 | break; | ||
1237 | default: | ||
1238 | nid = spec->autocfg.hp_pins[0]; | ||
1239 | break; | ||
1240 | } | ||
1241 | |||
1242 | knew->subdevice = HDA_SUBDEV_NID_FLAG | nid; | ||
1243 | knew->private_value = nid; | ||
1244 | |||
1245 | knew = via_clone_control(spec, &via_hp_mixer[1]); | ||
1246 | if (knew == NULL) | ||
1247 | return -ENOMEM; | ||
1248 | knew->subdevice = side_mute_channel(spec); | ||
1249 | |||
1250 | return 0; | ||
1251 | } | ||
1252 | |||
1222 | static void notify_aa_path_ctls(struct hda_codec *codec) | 1253 | static void notify_aa_path_ctls(struct hda_codec *codec) |
1223 | { | 1254 | { |
1224 | int i; | 1255 | int i; |
@@ -1376,7 +1407,7 @@ static int via_smart51_put(struct snd_kcontrol *kcontrol, | |||
1376 | return 1; | 1407 | return 1; |
1377 | } | 1408 | } |
1378 | 1409 | ||
1379 | static struct snd_kcontrol_new via_smart51_mixer[] = { | 1410 | static struct snd_kcontrol_new via_smart51_mixer[2] = { |
1380 | { | 1411 | { |
1381 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1412 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
1382 | .name = "Smart 5.1", | 1413 | .name = "Smart 5.1", |
@@ -1385,9 +1416,36 @@ static struct snd_kcontrol_new via_smart51_mixer[] = { | |||
1385 | .get = via_smart51_get, | 1416 | .get = via_smart51_get, |
1386 | .put = via_smart51_put, | 1417 | .put = via_smart51_put, |
1387 | }, | 1418 | }, |
1388 | {} /* end */ | 1419 | { |
1420 | .iface = NID_MAPPING, | ||
1421 | .name = "Smart 5.1", | ||
1422 | } | ||
1389 | }; | 1423 | }; |
1390 | 1424 | ||
1425 | static int via_smart51_build(struct via_spec *spec) | ||
1426 | { | ||
1427 | struct snd_kcontrol_new *knew; | ||
1428 | int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE }; | ||
1429 | hda_nid_t nid; | ||
1430 | int i; | ||
1431 | |||
1432 | knew = via_clone_control(spec, &via_smart51_mixer[0]); | ||
1433 | if (knew == NULL) | ||
1434 | return -ENOMEM; | ||
1435 | |||
1436 | for (i = 0; i < ARRAY_SIZE(index); i++) { | ||
1437 | nid = spec->autocfg.input_pins[index[i]]; | ||
1438 | if (nid) { | ||
1439 | knew = via_clone_control(spec, &via_smart51_mixer[1]); | ||
1440 | if (knew == NULL) | ||
1441 | return -ENOMEM; | ||
1442 | knew->subdevice = nid; | ||
1443 | } | ||
1444 | } | ||
1445 | |||
1446 | return 0; | ||
1447 | } | ||
1448 | |||
1391 | /* capture mixer elements */ | 1449 | /* capture mixer elements */ |
1392 | static struct snd_kcontrol_new vt1708_capture_mixer[] = { | 1450 | static struct snd_kcontrol_new vt1708_capture_mixer[] = { |
1393 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_INPUT), | 1451 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_INPUT), |
@@ -1819,8 +1877,9 @@ static struct hda_pcm_stream vt1708_pcm_digital_capture = { | |||
1819 | static int via_build_controls(struct hda_codec *codec) | 1877 | static int via_build_controls(struct hda_codec *codec) |
1820 | { | 1878 | { |
1821 | struct via_spec *spec = codec->spec; | 1879 | struct via_spec *spec = codec->spec; |
1822 | int err; | 1880 | struct snd_kcontrol *kctl; |
1823 | int i; | 1881 | struct snd_kcontrol_new *knew; |
1882 | int err, i; | ||
1824 | 1883 | ||
1825 | for (i = 0; i < spec->num_mixers; i++) { | 1884 | for (i = 0; i < spec->num_mixers; i++) { |
1826 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | 1885 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
@@ -1845,6 +1904,27 @@ static int via_build_controls(struct hda_codec *codec) | |||
1845 | return err; | 1904 | return err; |
1846 | } | 1905 | } |
1847 | 1906 | ||
1907 | /* assign Capture Source enums to NID */ | ||
1908 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); | ||
1909 | for (i = 0; kctl && i < kctl->count; i++) { | ||
1910 | err = snd_hda_add_nid(codec, kctl, i, spec->mux_nids[i]); | ||
1911 | if (err < 0) | ||
1912 | return err; | ||
1913 | } | ||
1914 | |||
1915 | /* other nid->control mapping */ | ||
1916 | for (i = 0; i < spec->num_mixers; i++) { | ||
1917 | for (knew = spec->mixers[i]; knew->name; knew++) { | ||
1918 | if (knew->iface != NID_MAPPING) | ||
1919 | continue; | ||
1920 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); | ||
1921 | if (kctl == NULL) | ||
1922 | continue; | ||
1923 | err = snd_hda_add_nid(codec, kctl, 0, | ||
1924 | knew->subdevice); | ||
1925 | } | ||
1926 | } | ||
1927 | |||
1848 | /* init power states */ | 1928 | /* init power states */ |
1849 | set_jack_power_state(codec); | 1929 | set_jack_power_state(codec); |
1850 | analog_low_current_mode(codec, 1); | 1930 | analog_low_current_mode(codec, 1); |
@@ -2481,9 +2561,9 @@ static int vt1708_parse_auto_config(struct hda_codec *codec) | |||
2481 | spec->input_mux = &spec->private_imux[0]; | 2561 | spec->input_mux = &spec->private_imux[0]; |
2482 | 2562 | ||
2483 | if (spec->hp_mux) | 2563 | if (spec->hp_mux) |
2484 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 2564 | via_hp_build(spec); |
2485 | 2565 | ||
2486 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | 2566 | via_smart51_build(spec); |
2487 | return 1; | 2567 | return 1; |
2488 | } | 2568 | } |
2489 | 2569 | ||
@@ -2554,12 +2634,10 @@ static int patch_vt1708(struct hda_codec *codec) | |||
2554 | int err; | 2634 | int err; |
2555 | 2635 | ||
2556 | /* create a codec specific record */ | 2636 | /* create a codec specific record */ |
2557 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 2637 | spec = via_new_spec(codec); |
2558 | if (spec == NULL) | 2638 | if (spec == NULL) |
2559 | return -ENOMEM; | 2639 | return -ENOMEM; |
2560 | 2640 | ||
2561 | codec->spec = spec; | ||
2562 | |||
2563 | /* automatic parse from the BIOS config */ | 2641 | /* automatic parse from the BIOS config */ |
2564 | err = vt1708_parse_auto_config(codec); | 2642 | err = vt1708_parse_auto_config(codec); |
2565 | if (err < 0) { | 2643 | if (err < 0) { |
@@ -2597,7 +2675,6 @@ static int patch_vt1708(struct hda_codec *codec) | |||
2597 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 2675 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
2598 | spec->loopback.amplist = vt1708_loopbacks; | 2676 | spec->loopback.amplist = vt1708_loopbacks; |
2599 | #endif | 2677 | #endif |
2600 | spec->codec = codec; | ||
2601 | INIT_DELAYED_WORK(&spec->vt1708_hp_work, vt1708_update_hp_jack_state); | 2678 | INIT_DELAYED_WORK(&spec->vt1708_hp_work, vt1708_update_hp_jack_state); |
2602 | return 0; | 2679 | return 0; |
2603 | } | 2680 | } |
@@ -3010,9 +3087,9 @@ static int vt1709_parse_auto_config(struct hda_codec *codec) | |||
3010 | spec->input_mux = &spec->private_imux[0]; | 3087 | spec->input_mux = &spec->private_imux[0]; |
3011 | 3088 | ||
3012 | if (spec->hp_mux) | 3089 | if (spec->hp_mux) |
3013 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 3090 | via_hp_build(spec); |
3014 | 3091 | ||
3015 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | 3092 | via_smart51_build(spec); |
3016 | return 1; | 3093 | return 1; |
3017 | } | 3094 | } |
3018 | 3095 | ||
@@ -3032,12 +3109,10 @@ static int patch_vt1709_10ch(struct hda_codec *codec) | |||
3032 | int err; | 3109 | int err; |
3033 | 3110 | ||
3034 | /* create a codec specific record */ | 3111 | /* create a codec specific record */ |
3035 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 3112 | spec = via_new_spec(codec); |
3036 | if (spec == NULL) | 3113 | if (spec == NULL) |
3037 | return -ENOMEM; | 3114 | return -ENOMEM; |
3038 | 3115 | ||
3039 | codec->spec = spec; | ||
3040 | |||
3041 | err = vt1709_parse_auto_config(codec); | 3116 | err = vt1709_parse_auto_config(codec); |
3042 | if (err < 0) { | 3117 | if (err < 0) { |
3043 | via_free(codec); | 3118 | via_free(codec); |
@@ -3126,12 +3201,10 @@ static int patch_vt1709_6ch(struct hda_codec *codec) | |||
3126 | int err; | 3201 | int err; |
3127 | 3202 | ||
3128 | /* create a codec specific record */ | 3203 | /* create a codec specific record */ |
3129 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 3204 | spec = via_new_spec(codec); |
3130 | if (spec == NULL) | 3205 | if (spec == NULL) |
3131 | return -ENOMEM; | 3206 | return -ENOMEM; |
3132 | 3207 | ||
3133 | codec->spec = spec; | ||
3134 | |||
3135 | err = vt1709_parse_auto_config(codec); | 3208 | err = vt1709_parse_auto_config(codec); |
3136 | if (err < 0) { | 3209 | if (err < 0) { |
3137 | via_free(codec); | 3210 | via_free(codec); |
@@ -3581,9 +3654,9 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec) | |||
3581 | spec->input_mux = &spec->private_imux[0]; | 3654 | spec->input_mux = &spec->private_imux[0]; |
3582 | 3655 | ||
3583 | if (spec->hp_mux) | 3656 | if (spec->hp_mux) |
3584 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 3657 | via_hp_build(spec); |
3585 | 3658 | ||
3586 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | 3659 | via_smart51_build(spec); |
3587 | return 1; | 3660 | return 1; |
3588 | } | 3661 | } |
3589 | 3662 | ||
@@ -3605,12 +3678,10 @@ static int patch_vt1708B_8ch(struct hda_codec *codec) | |||
3605 | if (get_codec_type(codec) == VT1708BCE) | 3678 | if (get_codec_type(codec) == VT1708BCE) |
3606 | return patch_vt1708S(codec); | 3679 | return patch_vt1708S(codec); |
3607 | /* create a codec specific record */ | 3680 | /* create a codec specific record */ |
3608 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 3681 | spec = via_new_spec(codec); |
3609 | if (spec == NULL) | 3682 | if (spec == NULL) |
3610 | return -ENOMEM; | 3683 | return -ENOMEM; |
3611 | 3684 | ||
3612 | codec->spec = spec; | ||
3613 | |||
3614 | /* automatic parse from the BIOS config */ | 3685 | /* automatic parse from the BIOS config */ |
3615 | err = vt1708B_parse_auto_config(codec); | 3686 | err = vt1708B_parse_auto_config(codec); |
3616 | if (err < 0) { | 3687 | if (err < 0) { |
@@ -3657,12 +3728,10 @@ static int patch_vt1708B_4ch(struct hda_codec *codec) | |||
3657 | int err; | 3728 | int err; |
3658 | 3729 | ||
3659 | /* create a codec specific record */ | 3730 | /* create a codec specific record */ |
3660 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 3731 | spec = via_new_spec(codec); |
3661 | if (spec == NULL) | 3732 | if (spec == NULL) |
3662 | return -ENOMEM; | 3733 | return -ENOMEM; |
3663 | 3734 | ||
3664 | codec->spec = spec; | ||
3665 | |||
3666 | /* automatic parse from the BIOS config */ | 3735 | /* automatic parse from the BIOS config */ |
3667 | err = vt1708B_parse_auto_config(codec); | 3736 | err = vt1708B_parse_auto_config(codec); |
3668 | if (err < 0) { | 3737 | if (err < 0) { |
@@ -4071,9 +4140,9 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec) | |||
4071 | spec->input_mux = &spec->private_imux[0]; | 4140 | spec->input_mux = &spec->private_imux[0]; |
4072 | 4141 | ||
4073 | if (spec->hp_mux) | 4142 | if (spec->hp_mux) |
4074 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 4143 | via_hp_build(spec); |
4075 | 4144 | ||
4076 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | 4145 | via_smart51_build(spec); |
4077 | return 1; | 4146 | return 1; |
4078 | } | 4147 | } |
4079 | 4148 | ||
@@ -4103,12 +4172,10 @@ static int patch_vt1708S(struct hda_codec *codec) | |||
4103 | int err; | 4172 | int err; |
4104 | 4173 | ||
4105 | /* create a codec specific record */ | 4174 | /* create a codec specific record */ |
4106 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 4175 | spec = via_new_spec(codec); |
4107 | if (spec == NULL) | 4176 | if (spec == NULL) |
4108 | return -ENOMEM; | 4177 | return -ENOMEM; |
4109 | 4178 | ||
4110 | codec->spec = spec; | ||
4111 | |||
4112 | /* automatic parse from the BIOS config */ | 4179 | /* automatic parse from the BIOS config */ |
4113 | err = vt1708S_parse_auto_config(codec); | 4180 | err = vt1708S_parse_auto_config(codec); |
4114 | if (err < 0) { | 4181 | if (err < 0) { |
@@ -4443,7 +4510,7 @@ static int vt1702_parse_auto_config(struct hda_codec *codec) | |||
4443 | spec->input_mux = &spec->private_imux[0]; | 4510 | spec->input_mux = &spec->private_imux[0]; |
4444 | 4511 | ||
4445 | if (spec->hp_mux) | 4512 | if (spec->hp_mux) |
4446 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 4513 | via_hp_build(spec); |
4447 | 4514 | ||
4448 | return 1; | 4515 | return 1; |
4449 | } | 4516 | } |
@@ -4464,12 +4531,10 @@ static int patch_vt1702(struct hda_codec *codec) | |||
4464 | int err; | 4531 | int err; |
4465 | 4532 | ||
4466 | /* create a codec specific record */ | 4533 | /* create a codec specific record */ |
4467 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 4534 | spec = via_new_spec(codec); |
4468 | if (spec == NULL) | 4535 | if (spec == NULL) |
4469 | return -ENOMEM; | 4536 | return -ENOMEM; |
4470 | 4537 | ||
4471 | codec->spec = spec; | ||
4472 | |||
4473 | /* automatic parse from the BIOS config */ | 4538 | /* automatic parse from the BIOS config */ |
4474 | err = vt1702_parse_auto_config(codec); | 4539 | err = vt1702_parse_auto_config(codec); |
4475 | if (err < 0) { | 4540 | if (err < 0) { |
@@ -4865,9 +4930,9 @@ static int vt1718S_parse_auto_config(struct hda_codec *codec) | |||
4865 | spec->input_mux = &spec->private_imux[0]; | 4930 | spec->input_mux = &spec->private_imux[0]; |
4866 | 4931 | ||
4867 | if (spec->hp_mux) | 4932 | if (spec->hp_mux) |
4868 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 4933 | via_hp_build(spec); |
4869 | 4934 | ||
4870 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | 4935 | via_smart51_build(spec); |
4871 | 4936 | ||
4872 | return 1; | 4937 | return 1; |
4873 | } | 4938 | } |
@@ -4888,12 +4953,10 @@ static int patch_vt1718S(struct hda_codec *codec) | |||
4888 | int err; | 4953 | int err; |
4889 | 4954 | ||
4890 | /* create a codec specific record */ | 4955 | /* create a codec specific record */ |
4891 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 4956 | spec = via_new_spec(codec); |
4892 | if (spec == NULL) | 4957 | if (spec == NULL) |
4893 | return -ENOMEM; | 4958 | return -ENOMEM; |
4894 | 4959 | ||
4895 | codec->spec = spec; | ||
4896 | |||
4897 | /* automatic parse from the BIOS config */ | 4960 | /* automatic parse from the BIOS config */ |
4898 | err = vt1718S_parse_auto_config(codec); | 4961 | err = vt1718S_parse_auto_config(codec); |
4899 | if (err < 0) { | 4962 | if (err < 0) { |
@@ -5014,6 +5077,7 @@ static struct snd_kcontrol_new vt1716s_dmic_mixer[] = { | |||
5014 | { | 5077 | { |
5015 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 5078 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
5016 | .name = "Digital Mic Capture Switch", | 5079 | .name = "Digital Mic Capture Switch", |
5080 | .subdevice = HDA_SUBDEV_NID_FLAG | 0x26, | ||
5017 | .count = 1, | 5081 | .count = 1, |
5018 | .info = vt1716s_dmic_info, | 5082 | .info = vt1716s_dmic_info, |
5019 | .get = vt1716s_dmic_get, | 5083 | .get = vt1716s_dmic_get, |
@@ -5361,9 +5425,9 @@ static int vt1716S_parse_auto_config(struct hda_codec *codec) | |||
5361 | spec->input_mux = &spec->private_imux[0]; | 5425 | spec->input_mux = &spec->private_imux[0]; |
5362 | 5426 | ||
5363 | if (spec->hp_mux) | 5427 | if (spec->hp_mux) |
5364 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 5428 | via_hp_build(spec); |
5365 | 5429 | ||
5366 | spec->mixers[spec->num_mixers++] = via_smart51_mixer; | 5430 | via_smart51_build(spec); |
5367 | 5431 | ||
5368 | return 1; | 5432 | return 1; |
5369 | } | 5433 | } |
@@ -5384,12 +5448,10 @@ static int patch_vt1716S(struct hda_codec *codec) | |||
5384 | int err; | 5448 | int err; |
5385 | 5449 | ||
5386 | /* create a codec specific record */ | 5450 | /* create a codec specific record */ |
5387 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5451 | spec = via_new_spec(codec); |
5388 | if (spec == NULL) | 5452 | if (spec == NULL) |
5389 | return -ENOMEM; | 5453 | return -ENOMEM; |
5390 | 5454 | ||
5391 | codec->spec = spec; | ||
5392 | |||
5393 | /* automatic parse from the BIOS config */ | 5455 | /* automatic parse from the BIOS config */ |
5394 | err = vt1716S_parse_auto_config(codec); | 5456 | err = vt1716S_parse_auto_config(codec); |
5395 | if (err < 0) { | 5457 | if (err < 0) { |
@@ -5719,7 +5781,7 @@ static int vt2002P_parse_auto_config(struct hda_codec *codec) | |||
5719 | spec->input_mux = &spec->private_imux[0]; | 5781 | spec->input_mux = &spec->private_imux[0]; |
5720 | 5782 | ||
5721 | if (spec->hp_mux) | 5783 | if (spec->hp_mux) |
5722 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 5784 | via_hp_build(spec); |
5723 | 5785 | ||
5724 | return 1; | 5786 | return 1; |
5725 | } | 5787 | } |
@@ -5741,12 +5803,10 @@ static int patch_vt2002P(struct hda_codec *codec) | |||
5741 | int err; | 5803 | int err; |
5742 | 5804 | ||
5743 | /* create a codec specific record */ | 5805 | /* create a codec specific record */ |
5744 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5806 | spec = via_new_spec(codec); |
5745 | if (spec == NULL) | 5807 | if (spec == NULL) |
5746 | return -ENOMEM; | 5808 | return -ENOMEM; |
5747 | 5809 | ||
5748 | codec->spec = spec; | ||
5749 | |||
5750 | /* automatic parse from the BIOS config */ | 5810 | /* automatic parse from the BIOS config */ |
5751 | err = vt2002P_parse_auto_config(codec); | 5811 | err = vt2002P_parse_auto_config(codec); |
5752 | if (err < 0) { | 5812 | if (err < 0) { |
@@ -6070,7 +6130,7 @@ static int vt1812_parse_auto_config(struct hda_codec *codec) | |||
6070 | spec->input_mux = &spec->private_imux[0]; | 6130 | spec->input_mux = &spec->private_imux[0]; |
6071 | 6131 | ||
6072 | if (spec->hp_mux) | 6132 | if (spec->hp_mux) |
6073 | spec->mixers[spec->num_mixers++] = via_hp_mixer; | 6133 | via_hp_build(spec); |
6074 | 6134 | ||
6075 | return 1; | 6135 | return 1; |
6076 | } | 6136 | } |
@@ -6092,12 +6152,10 @@ static int patch_vt1812(struct hda_codec *codec) | |||
6092 | int err; | 6152 | int err; |
6093 | 6153 | ||
6094 | /* create a codec specific record */ | 6154 | /* create a codec specific record */ |
6095 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 6155 | spec = via_new_spec(codec); |
6096 | if (spec == NULL) | 6156 | if (spec == NULL) |
6097 | return -ENOMEM; | 6157 | return -ENOMEM; |
6098 | 6158 | ||
6099 | codec->spec = spec; | ||
6100 | |||
6101 | /* automatic parse from the BIOS config */ | 6159 | /* automatic parse from the BIOS config */ |
6102 | err = vt1812_parse_auto_config(codec); | 6160 | err = vt1812_parse_auto_config(codec); |
6103 | if (err < 0) { | 6161 | if (err < 0) { |
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c index 765d7bd4c3d4..9e66f6d306f8 100644 --- a/sound/pci/ice1712/aureon.c +++ b/sound/pci/ice1712/aureon.c | |||
@@ -703,11 +703,13 @@ static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned sho | |||
703 | { | 703 | { |
704 | unsigned char nvol; | 704 | unsigned char nvol; |
705 | 705 | ||
706 | if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE)) | 706 | if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE)) { |
707 | nvol = 0; | 707 | nvol = 0; |
708 | else | 708 | } else { |
709 | nvol = ((vol % WM_VOL_CNT) * (master % WM_VOL_CNT)) / | 709 | nvol = ((vol % WM_VOL_CNT) * (master % WM_VOL_CNT)) / |
710 | WM_VOL_MAX; | 710 | WM_VOL_MAX; |
711 | nvol += 0x1b; | ||
712 | } | ||
711 | 713 | ||
712 | wm_put(ice, index, nvol); | 714 | wm_put(ice, index, nvol); |
713 | wm_put_nocache(ice, index, 0x180 | nvol); | 715 | wm_put_nocache(ice, index, 0x180 | nvol); |
@@ -778,7 +780,7 @@ static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_ | |||
778 | for (ch = 0; ch < 2; ch++) { | 780 | for (ch = 0; ch < 2; ch++) { |
779 | unsigned int vol = ucontrol->value.integer.value[ch]; | 781 | unsigned int vol = ucontrol->value.integer.value[ch]; |
780 | if (vol > WM_VOL_MAX) | 782 | if (vol > WM_VOL_MAX) |
781 | continue; | 783 | vol = WM_VOL_MAX; |
782 | vol |= spec->master[ch] & WM_VOL_MUTE; | 784 | vol |= spec->master[ch] & WM_VOL_MUTE; |
783 | if (vol != spec->master[ch]) { | 785 | if (vol != spec->master[ch]) { |
784 | int dac; | 786 | int dac; |
@@ -834,8 +836,8 @@ static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value * | |||
834 | for (i = 0; i < voices; i++) { | 836 | for (i = 0; i < voices; i++) { |
835 | unsigned int vol = ucontrol->value.integer.value[i]; | 837 | unsigned int vol = ucontrol->value.integer.value[i]; |
836 | if (vol > WM_VOL_MAX) | 838 | if (vol > WM_VOL_MAX) |
837 | continue; | 839 | vol = WM_VOL_MAX; |
838 | vol |= spec->vol[ofs+i]; | 840 | vol |= spec->vol[ofs+i] & WM_VOL_MUTE; |
839 | if (vol != spec->vol[ofs+i]) { | 841 | if (vol != spec->vol[ofs+i]) { |
840 | spec->vol[ofs+i] = vol; | 842 | spec->vol[ofs+i] = vol; |
841 | idx = WM_DAC_ATTEN + ofs + i; | 843 | idx = WM_DAC_ATTEN + ofs + i; |
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index c7cff6f8168a..4fc6d8bc637e 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c | |||
@@ -106,7 +106,7 @@ module_param_array(dxr_enable, int, NULL, 0444); | |||
106 | MODULE_PARM_DESC(dxr_enable, "Enable DXR support for Terratec DMX6FIRE."); | 106 | 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 DEFINE_PCI_DEVICE_TABLE(snd_ice1712_ids) = { |
110 | { PCI_VDEVICE(ICE, PCI_DEVICE_ID_ICE_1712), 0 }, /* ICE1712 */ | 110 | { PCI_VDEVICE(ICE, PCI_DEVICE_ID_ICE_1712), 0 }, /* ICE1712 */ |
111 | { 0, } | 111 | { 0, } |
112 | }; | 112 | }; |
@@ -1180,6 +1180,10 @@ static int snd_ice1712_playback_pro_open(struct snd_pcm_substream *substream) | |||
1180 | snd_pcm_set_sync(substream); | 1180 | snd_pcm_set_sync(substream); |
1181 | snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); | 1181 | snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); |
1182 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); | 1182 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); |
1183 | if (is_pro_rate_locked(ice)) { | ||
1184 | runtime->hw.rate_min = PRO_RATE_DEFAULT; | ||
1185 | runtime->hw.rate_max = PRO_RATE_DEFAULT; | ||
1186 | } | ||
1183 | 1187 | ||
1184 | if (ice->spdif.ops.open) | 1188 | if (ice->spdif.ops.open) |
1185 | ice->spdif.ops.open(ice, substream); | 1189 | ice->spdif.ops.open(ice, substream); |
@@ -1197,6 +1201,11 @@ static int snd_ice1712_capture_pro_open(struct snd_pcm_substream *substream) | |||
1197 | snd_pcm_set_sync(substream); | 1201 | snd_pcm_set_sync(substream); |
1198 | snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); | 1202 | snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); |
1199 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); | 1203 | snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); |
1204 | if (is_pro_rate_locked(ice)) { | ||
1205 | runtime->hw.rate_min = PRO_RATE_DEFAULT; | ||
1206 | runtime->hw.rate_max = PRO_RATE_DEFAULT; | ||
1207 | } | ||
1208 | |||
1200 | return 0; | 1209 | return 0; |
1201 | } | 1210 | } |
1202 | 1211 | ||
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index ae29073eea93..c1498fa5545f 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c | |||
@@ -94,7 +94,7 @@ MODULE_PARM_DESC(model, "Use the given board model."); | |||
94 | 94 | ||
95 | 95 | ||
96 | /* Both VT1720 and VT1724 have the same PCI IDs */ | 96 | /* Both VT1720 and VT1724 have the same PCI IDs */ |
97 | static const struct pci_device_id snd_vt1724_ids[] = { | 97 | static DEFINE_PCI_DEVICE_TABLE(snd_vt1724_ids) = { |
98 | { PCI_VDEVICE(ICE, PCI_DEVICE_ID_VT1724), 0 }, | 98 | { PCI_VDEVICE(ICE, PCI_DEVICE_ID_VT1724), 0 }, |
99 | { 0, } | 99 | { 0, } |
100 | }; | 100 | }; |
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index b990143636f1..6433e65c9507 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c | |||
@@ -420,7 +420,7 @@ struct intel8x0 { | |||
420 | u32 int_sta_mask; /* interrupt status mask */ | 420 | u32 int_sta_mask; /* interrupt status mask */ |
421 | }; | 421 | }; |
422 | 422 | ||
423 | static struct pci_device_id snd_intel8x0_ids[] = { | 423 | static DEFINE_PCI_DEVICE_TABLE(snd_intel8x0_ids) = { |
424 | { PCI_VDEVICE(INTEL, 0x2415), DEVICE_INTEL }, /* 82801AA */ | 424 | { PCI_VDEVICE(INTEL, 0x2415), DEVICE_INTEL }, /* 82801AA */ |
425 | { PCI_VDEVICE(INTEL, 0x2425), DEVICE_INTEL }, /* 82901AB */ | 425 | { PCI_VDEVICE(INTEL, 0x2425), DEVICE_INTEL }, /* 82901AB */ |
426 | { PCI_VDEVICE(INTEL, 0x2445), DEVICE_INTEL }, /* 82801BA */ | 426 | { PCI_VDEVICE(INTEL, 0x2445), DEVICE_INTEL }, /* 82801BA */ |
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 9e7d12e7673f..13cec1e5ced9 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c | |||
@@ -219,7 +219,7 @@ struct intel8x0m { | |||
219 | unsigned int pcm_pos_shift; | 219 | unsigned int pcm_pos_shift; |
220 | }; | 220 | }; |
221 | 221 | ||
222 | static struct pci_device_id snd_intel8x0m_ids[] = { | 222 | static DEFINE_PCI_DEVICE_TABLE(snd_intel8x0m_ids) = { |
223 | { PCI_VDEVICE(INTEL, 0x2416), DEVICE_INTEL }, /* 82801AA */ | 223 | { PCI_VDEVICE(INTEL, 0x2416), DEVICE_INTEL }, /* 82801AA */ |
224 | { PCI_VDEVICE(INTEL, 0x2426), DEVICE_INTEL }, /* 82901AB */ | 224 | { PCI_VDEVICE(INTEL, 0x2426), DEVICE_INTEL }, /* 82901AB */ |
225 | { PCI_VDEVICE(INTEL, 0x2446), DEVICE_INTEL }, /* 82801BA */ | 225 | { PCI_VDEVICE(INTEL, 0x2446), DEVICE_INTEL }, /* 82801BA */ |
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 7cc38a11e997..6d795700be79 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c | |||
@@ -418,7 +418,7 @@ module_param_array(enable, bool, NULL, 0444); | |||
418 | MODULE_PARM_DESC(enable, "Enable Korg 1212 soundcard."); | 418 | MODULE_PARM_DESC(enable, "Enable Korg 1212 soundcard."); |
419 | MODULE_AUTHOR("Haroldo Gamal <gamal@alternex.com.br>"); | 419 | MODULE_AUTHOR("Haroldo Gamal <gamal@alternex.com.br>"); |
420 | 420 | ||
421 | static struct pci_device_id snd_korg1212_ids[] = { | 421 | static DEFINE_PCI_DEVICE_TABLE(snd_korg1212_ids) = { |
422 | { | 422 | { |
423 | .vendor = 0x10b5, | 423 | .vendor = 0x10b5, |
424 | .device = 0x906d, | 424 | .device = 0x906d, |
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index 11b8c6514b3d..0cca56038cd9 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c | |||
@@ -55,7 +55,7 @@ static const char card_name[] = "LX6464ES"; | |||
55 | 55 | ||
56 | #define PCI_DEVICE_ID_PLX_LX6464ES PCI_DEVICE_ID_PLX_9056 | 56 | #define PCI_DEVICE_ID_PLX_LX6464ES PCI_DEVICE_ID_PLX_9056 |
57 | 57 | ||
58 | static struct pci_device_id snd_lx6464es_ids[] = { | 58 | static DEFINE_PCI_DEVICE_TABLE(snd_lx6464es_ids) = { |
59 | { PCI_DEVICE(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_LX6464ES), | 59 | { PCI_DEVICE(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_LX6464ES), |
60 | .subvendor = PCI_VENDOR_ID_DIGIGRAM, | 60 | .subvendor = PCI_VENDOR_ID_DIGIGRAM, |
61 | .subdevice = PCI_SUBDEVICE_ID_DIGIGRAM_LX6464ES_SERIAL_SUBSYSTEM | 61 | .subdevice = PCI_SUBDEVICE_ID_DIGIGRAM_LX6464ES_SERIAL_SUBSYSTEM |
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 75283fbb4b3f..b64e78139d63 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c | |||
@@ -861,7 +861,7 @@ struct snd_m3 { | |||
861 | /* | 861 | /* |
862 | * pci ids | 862 | * pci ids |
863 | */ | 863 | */ |
864 | static struct pci_device_id snd_m3_ids[] = { | 864 | static DEFINE_PCI_DEVICE_TABLE(snd_m3_ids) = { |
865 | {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO_1, PCI_ANY_ID, PCI_ANY_ID, | 865 | {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO_1, PCI_ANY_ID, PCI_ANY_ID, |
866 | PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, | 866 | PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, |
867 | {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO, PCI_ANY_ID, PCI_ANY_ID, | 867 | {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO, PCI_ANY_ID, PCI_ANY_ID, |
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index a83d1968a845..7e8e7da592a9 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c | |||
@@ -60,7 +60,7 @@ MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard."); | |||
60 | /* | 60 | /* |
61 | */ | 61 | */ |
62 | 62 | ||
63 | static struct pci_device_id snd_mixart_ids[] = { | 63 | static DEFINE_PCI_DEVICE_TABLE(snd_mixart_ids) = { |
64 | { PCI_VDEVICE(MOTOROLA, 0x0003), 0, }, /* MC8240 */ | 64 | { PCI_VDEVICE(MOTOROLA, 0x0003), 0, }, /* MC8240 */ |
65 | { 0, } | 65 | { 0, } |
66 | }; | 66 | }; |
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 97a0731331a1..5a60492ac7b3 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c | |||
@@ -262,7 +262,7 @@ struct nm256 { | |||
262 | /* | 262 | /* |
263 | * PCI ids | 263 | * PCI ids |
264 | */ | 264 | */ |
265 | static struct pci_device_id snd_nm256_ids[] = { | 265 | static DEFINE_PCI_DEVICE_TABLE(snd_nm256_ids) = { |
266 | {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO), 0}, | 266 | {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO), 0}, |
267 | {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO), 0}, | 267 | {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO), 0}, |
268 | {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO), 0}, | 268 | {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO), 0}, |
diff --git a/sound/pci/oxygen/Makefile b/sound/pci/oxygen/Makefile index 389941cf6100..acd8f15f7bff 100644 --- a/sound/pci/oxygen/Makefile +++ b/sound/pci/oxygen/Makefile | |||
@@ -2,7 +2,7 @@ snd-oxygen-lib-objs := oxygen_io.o oxygen_lib.o oxygen_mixer.o oxygen_pcm.o | |||
2 | snd-hifier-objs := hifier.o | 2 | snd-hifier-objs := hifier.o |
3 | snd-oxygen-objs := oxygen.o | 3 | snd-oxygen-objs := oxygen.o |
4 | snd-virtuoso-objs := virtuoso.o xonar_lib.o \ | 4 | snd-virtuoso-objs := virtuoso.o xonar_lib.o \ |
5 | xonar_pcm179x.o xonar_cs43xx.o xonar_hdmi.o | 5 | xonar_pcm179x.o xonar_cs43xx.o xonar_wm87x6.o xonar_hdmi.o |
6 | 6 | ||
7 | obj-$(CONFIG_SND_OXYGEN_LIB) += snd-oxygen-lib.o | 7 | obj-$(CONFIG_SND_OXYGEN_LIB) += snd-oxygen-lib.o |
8 | obj-$(CONFIG_SND_HIFIER) += snd-hifier.o | 8 | obj-$(CONFIG_SND_HIFIER) += snd-hifier.o |
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c index e3c229b63311..5a87d683691f 100644 --- a/sound/pci/oxygen/hifier.c +++ b/sound/pci/oxygen/hifier.c | |||
@@ -48,7 +48,7 @@ MODULE_PARM_DESC(id, "ID string"); | |||
48 | module_param_array(enable, bool, NULL, 0444); | 48 | module_param_array(enable, bool, NULL, 0444); |
49 | MODULE_PARM_DESC(enable, "enable card"); | 49 | MODULE_PARM_DESC(enable, "enable card"); |
50 | 50 | ||
51 | static struct pci_device_id hifier_ids[] __devinitdata = { | 51 | static DEFINE_PCI_DEVICE_TABLE(hifier_ids) = { |
52 | { OXYGEN_PCI_SUBID(0x14c3, 0x1710) }, | 52 | { OXYGEN_PCI_SUBID(0x14c3, 0x1710) }, |
53 | { OXYGEN_PCI_SUBID(0x14c3, 0x1711) }, | 53 | { OXYGEN_PCI_SUBID(0x14c3, 0x1711) }, |
54 | { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, | 54 | { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, |
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index acbedebcffd9..289cb4dacfc7 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c | |||
@@ -72,7 +72,7 @@ enum { | |||
72 | MODEL_CLARO_HALO, /* HT-Omega Claro halo */ | 72 | MODEL_CLARO_HALO, /* HT-Omega Claro halo */ |
73 | }; | 73 | }; |
74 | 74 | ||
75 | static struct pci_device_id oxygen_ids[] __devinitdata = { | 75 | static DEFINE_PCI_DEVICE_TABLE(oxygen_ids) = { |
76 | { OXYGEN_PCI_SUBID(0x10b0, 0x0216), .driver_data = MODEL_CMEDIA_REF }, | 76 | { OXYGEN_PCI_SUBID(0x10b0, 0x0216), .driver_data = MODEL_CMEDIA_REF }, |
77 | { OXYGEN_PCI_SUBID(0x10b0, 0x0218), .driver_data = MODEL_CMEDIA_REF }, | 77 | { OXYGEN_PCI_SUBID(0x10b0, 0x0218), .driver_data = MODEL_CMEDIA_REF }, |
78 | { OXYGEN_PCI_SUBID(0x10b0, 0x0219), .driver_data = MODEL_CMEDIA_REF }, | 78 | { OXYGEN_PCI_SUBID(0x10b0, 0x0219), .driver_data = MODEL_CMEDIA_REF }, |
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index 6accaf9580b2..f03a2f2cffee 100644 --- a/sound/pci/oxygen/virtuoso.c +++ b/sound/pci/oxygen/virtuoso.c | |||
@@ -40,7 +40,7 @@ MODULE_PARM_DESC(id, "ID string"); | |||
40 | module_param_array(enable, bool, NULL, 0444); | 40 | module_param_array(enable, bool, NULL, 0444); |
41 | MODULE_PARM_DESC(enable, "enable card"); | 41 | MODULE_PARM_DESC(enable, "enable card"); |
42 | 42 | ||
43 | static struct pci_device_id xonar_ids[] __devinitdata = { | 43 | static DEFINE_PCI_DEVICE_TABLE(xonar_ids) = { |
44 | { OXYGEN_PCI_SUBID(0x1043, 0x8269) }, | 44 | { OXYGEN_PCI_SUBID(0x1043, 0x8269) }, |
45 | { OXYGEN_PCI_SUBID(0x1043, 0x8275) }, | 45 | { OXYGEN_PCI_SUBID(0x1043, 0x8275) }, |
46 | { OXYGEN_PCI_SUBID(0x1043, 0x82b7) }, | 46 | { OXYGEN_PCI_SUBID(0x1043, 0x82b7) }, |
@@ -49,6 +49,7 @@ static struct pci_device_id xonar_ids[] __devinitdata = { | |||
49 | { OXYGEN_PCI_SUBID(0x1043, 0x834f) }, | 49 | { OXYGEN_PCI_SUBID(0x1043, 0x834f) }, |
50 | { OXYGEN_PCI_SUBID(0x1043, 0x835c) }, | 50 | { OXYGEN_PCI_SUBID(0x1043, 0x835c) }, |
51 | { OXYGEN_PCI_SUBID(0x1043, 0x835d) }, | 51 | { OXYGEN_PCI_SUBID(0x1043, 0x835d) }, |
52 | { OXYGEN_PCI_SUBID(0x1043, 0x838e) }, | ||
52 | { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, | 53 | { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, |
53 | { } | 54 | { } |
54 | }; | 55 | }; |
@@ -61,6 +62,8 @@ static int __devinit get_xonar_model(struct oxygen *chip, | |||
61 | return 0; | 62 | return 0; |
62 | if (get_xonar_cs43xx_model(chip, id) >= 0) | 63 | if (get_xonar_cs43xx_model(chip, id) >= 0) |
63 | return 0; | 64 | return 0; |
65 | if (get_xonar_wm87x6_model(chip, id) >= 0) | ||
66 | return 0; | ||
64 | return -EINVAL; | 67 | return -EINVAL; |
65 | } | 68 | } |
66 | 69 | ||
diff --git a/sound/pci/oxygen/wm8766.h b/sound/pci/oxygen/wm8766.h new file mode 100644 index 000000000000..e0e849a7eaeb --- /dev/null +++ b/sound/pci/oxygen/wm8766.h | |||
@@ -0,0 +1,73 @@ | |||
1 | #ifndef WM8766_H_INCLUDED | ||
2 | #define WM8766_H_INCLUDED | ||
3 | |||
4 | #define WM8766_LDA1 0x00 | ||
5 | #define WM8766_RDA1 0x01 | ||
6 | #define WM8766_DAC_CTRL 0x02 | ||
7 | #define WM8766_INT_CTRL 0x03 | ||
8 | #define WM8766_LDA2 0x04 | ||
9 | #define WM8766_RDA2 0x05 | ||
10 | #define WM8766_LDA3 0x06 | ||
11 | #define WM8766_RDA3 0x07 | ||
12 | #define WM8766_MASTDA 0x08 | ||
13 | #define WM8766_DAC_CTRL2 0x09 | ||
14 | #define WM8766_DAC_CTRL3 0x0a | ||
15 | #define WM8766_MUTE1 0x0c | ||
16 | #define WM8766_MUTE2 0x0f | ||
17 | #define WM8766_RESET 0x1f | ||
18 | |||
19 | /* LDAx/RDAx/MASTDA */ | ||
20 | #define WM8766_ATT_MASK 0x0ff | ||
21 | #define WM8766_UPDATE 0x100 | ||
22 | /* DAC_CTRL */ | ||
23 | #define WM8766_MUTEALL 0x001 | ||
24 | #define WM8766_DEEMPALL 0x002 | ||
25 | #define WM8766_PWDN 0x004 | ||
26 | #define WM8766_ATC 0x008 | ||
27 | #define WM8766_IZD 0x010 | ||
28 | #define WM8766_PL_LEFT_MASK 0x060 | ||
29 | #define WM8766_PL_LEFT_MUTE 0x000 | ||
30 | #define WM8766_PL_LEFT_LEFT 0x020 | ||
31 | #define WM8766_PL_LEFT_RIGHT 0x040 | ||
32 | #define WM8766_PL_LEFT_LRMIX 0x060 | ||
33 | #define WM8766_PL_RIGHT_MASK 0x180 | ||
34 | #define WM8766_PL_RIGHT_MUTE 0x000 | ||
35 | #define WM8766_PL_RIGHT_LEFT 0x080 | ||
36 | #define WM8766_PL_RIGHT_RIGHT 0x100 | ||
37 | #define WM8766_PL_RIGHT_LRMIX 0x180 | ||
38 | /* INT_CTRL */ | ||
39 | #define WM8766_FMT_MASK 0x003 | ||
40 | #define WM8766_FMT_RJUST 0x000 | ||
41 | #define WM8766_FMT_LJUST 0x001 | ||
42 | #define WM8766_FMT_I2S 0x002 | ||
43 | #define WM8766_FMT_DSP 0x003 | ||
44 | #define WM8766_LRP 0x004 | ||
45 | #define WM8766_BCP 0x008 | ||
46 | #define WM8766_IWL_MASK 0x030 | ||
47 | #define WM8766_IWL_16 0x000 | ||
48 | #define WM8766_IWL_20 0x010 | ||
49 | #define WM8766_IWL_24 0x020 | ||
50 | #define WM8766_IWL_32 0x030 | ||
51 | #define WM8766_PHASE_MASK 0x1c0 | ||
52 | /* DAC_CTRL2 */ | ||
53 | #define WM8766_ZCD 0x001 | ||
54 | #define WM8766_DZFM_MASK 0x006 | ||
55 | #define WM8766_DMUTE_MASK 0x038 | ||
56 | #define WM8766_DEEMP_MASK 0x1c0 | ||
57 | /* DAC_CTRL3 */ | ||
58 | #define WM8766_DACPD_MASK 0x00e | ||
59 | #define WM8766_PWRDNALL 0x010 | ||
60 | #define WM8766_MS 0x020 | ||
61 | #define WM8766_RATE_MASK 0x1c0 | ||
62 | #define WM8766_RATE_128 0x000 | ||
63 | #define WM8766_RATE_192 0x040 | ||
64 | #define WM8766_RATE_256 0x080 | ||
65 | #define WM8766_RATE_384 0x0c0 | ||
66 | #define WM8766_RATE_512 0x100 | ||
67 | #define WM8766_RATE_768 0x140 | ||
68 | /* MUTE1 */ | ||
69 | #define WM8766_MPD1 0x040 | ||
70 | /* MUTE2 */ | ||
71 | #define WM8766_MPD2 0x020 | ||
72 | |||
73 | #endif | ||
diff --git a/sound/pci/oxygen/wm8776.h b/sound/pci/oxygen/wm8776.h new file mode 100644 index 000000000000..1a96f5615727 --- /dev/null +++ b/sound/pci/oxygen/wm8776.h | |||
@@ -0,0 +1,177 @@ | |||
1 | #ifndef WM8776_H_INCLUDED | ||
2 | #define WM8776_H_INCLUDED | ||
3 | |||
4 | /* | ||
5 | * the following register names are from: | ||
6 | * wm8776.h -- WM8776 ASoC driver | ||
7 | * | ||
8 | * Copyright 2009 Wolfson Microelectronics plc | ||
9 | * | ||
10 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License version 2 as | ||
14 | * published by the Free Software Foundation. | ||
15 | */ | ||
16 | |||
17 | #define WM8776_HPLVOL 0x00 | ||
18 | #define WM8776_HPRVOL 0x01 | ||
19 | #define WM8776_HPMASTER 0x02 | ||
20 | #define WM8776_DACLVOL 0x03 | ||
21 | #define WM8776_DACRVOL 0x04 | ||
22 | #define WM8776_DACMASTER 0x05 | ||
23 | #define WM8776_PHASESWAP 0x06 | ||
24 | #define WM8776_DACCTRL1 0x07 | ||
25 | #define WM8776_DACMUTE 0x08 | ||
26 | #define WM8776_DACCTRL2 0x09 | ||
27 | #define WM8776_DACIFCTRL 0x0a | ||
28 | #define WM8776_ADCIFCTRL 0x0b | ||
29 | #define WM8776_MSTRCTRL 0x0c | ||
30 | #define WM8776_PWRDOWN 0x0d | ||
31 | #define WM8776_ADCLVOL 0x0e | ||
32 | #define WM8776_ADCRVOL 0x0f | ||
33 | #define WM8776_ALCCTRL1 0x10 | ||
34 | #define WM8776_ALCCTRL2 0x11 | ||
35 | #define WM8776_ALCCTRL3 0x12 | ||
36 | #define WM8776_NOISEGATE 0x13 | ||
37 | #define WM8776_LIMITER 0x14 | ||
38 | #define WM8776_ADCMUX 0x15 | ||
39 | #define WM8776_OUTMUX 0x16 | ||
40 | #define WM8776_RESET 0x17 | ||
41 | |||
42 | |||
43 | /* HPLVOL/HPRVOL/HPMASTER */ | ||
44 | #define WM8776_HPATT_MASK 0x07f | ||
45 | #define WM8776_HPZCEN 0x080 | ||
46 | #define WM8776_UPDATE 0x100 | ||
47 | |||
48 | /* DACLVOL/DACRVOL/DACMASTER */ | ||
49 | #define WM8776_DATT_MASK 0x0ff | ||
50 | /*#define WM8776_UPDATE 0x100*/ | ||
51 | |||
52 | /* PHASESWAP */ | ||
53 | #define WM8776_PH_MASK 0x003 | ||
54 | |||
55 | /* DACCTRL1 */ | ||
56 | #define WM8776_DZCEN 0x001 | ||
57 | #define WM8776_ATC 0x002 | ||
58 | #define WM8776_IZD 0x004 | ||
59 | #define WM8776_TOD 0x008 | ||
60 | #define WM8776_PL_LEFT_MASK 0x030 | ||
61 | #define WM8776_PL_LEFT_MUTE 0x000 | ||
62 | #define WM8776_PL_LEFT_LEFT 0x010 | ||
63 | #define WM8776_PL_LEFT_RIGHT 0x020 | ||
64 | #define WM8776_PL_LEFT_LRMIX 0x030 | ||
65 | #define WM8776_PL_RIGHT_MASK 0x0c0 | ||
66 | #define WM8776_PL_RIGHT_MUTE 0x000 | ||
67 | #define WM8776_PL_RIGHT_LEFT 0x040 | ||
68 | #define WM8776_PL_RIGHT_RIGHT 0x080 | ||
69 | #define WM8776_PL_RIGHT_LRMIX 0x0c0 | ||
70 | |||
71 | /* DACMUTE */ | ||
72 | #define WM8776_DMUTE 0x001 | ||
73 | |||
74 | /* DACCTRL2 */ | ||
75 | #define WM8776_DEEMPH 0x001 | ||
76 | #define WM8776_DZFM_MASK 0x006 | ||
77 | #define WM8776_DZFM_NONE 0x000 | ||
78 | #define WM8776_DZFM_LR 0x002 | ||
79 | #define WM8776_DZFM_BOTH 0x004 | ||
80 | #define WM8776_DZFM_EITHER 0x006 | ||
81 | |||
82 | /* DACIFCTRL */ | ||
83 | #define WM8776_DACFMT_MASK 0x003 | ||
84 | #define WM8776_DACFMT_RJUST 0x000 | ||
85 | #define WM8776_DACFMT_LJUST 0x001 | ||
86 | #define WM8776_DACFMT_I2S 0x002 | ||
87 | #define WM8776_DACFMT_DSP 0x003 | ||
88 | #define WM8776_DACLRP 0x004 | ||
89 | #define WM8776_DACBCP 0x008 | ||
90 | #define WM8776_DACWL_MASK 0x030 | ||
91 | #define WM8776_DACWL_16 0x000 | ||
92 | #define WM8776_DACWL_20 0x010 | ||
93 | #define WM8776_DACWL_24 0x020 | ||
94 | #define WM8776_DACWL_32 0x030 | ||
95 | |||
96 | /* ADCIFCTRL */ | ||
97 | #define WM8776_ADCFMT_MASK 0x003 | ||
98 | #define WM8776_ADCFMT_RJUST 0x000 | ||
99 | #define WM8776_ADCFMT_LJUST 0x001 | ||
100 | #define WM8776_ADCFMT_I2S 0x002 | ||
101 | #define WM8776_ADCFMT_DSP 0x003 | ||
102 | #define WM8776_ADCLRP 0x004 | ||
103 | #define WM8776_ADCBCP 0x008 | ||
104 | #define WM8776_ADCWL_MASK 0x030 | ||
105 | #define WM8776_ADCWL_16 0x000 | ||
106 | #define WM8776_ADCWL_20 0x010 | ||
107 | #define WM8776_ADCWL_24 0x020 | ||
108 | #define WM8776_ADCWL_32 0x030 | ||
109 | #define WM8776_ADCMCLK 0x040 | ||
110 | #define WM8776_ADCHPD 0x100 | ||
111 | |||
112 | /* MSTRCTRL */ | ||
113 | #define WM8776_ADCRATE_MASK 0x007 | ||
114 | #define WM8776_ADCRATE_256 0x002 | ||
115 | #define WM8776_ADCRATE_384 0x003 | ||
116 | #define WM8776_ADCRATE_512 0x004 | ||
117 | #define WM8776_ADCRATE_768 0x005 | ||
118 | #define WM8776_ADCOSR 0x008 | ||
119 | #define WM8776_DACRATE_MASK 0x070 | ||
120 | #define WM8776_DACRATE_128 0x000 | ||
121 | #define WM8776_DACRATE_192 0x010 | ||
122 | #define WM8776_DACRATE_256 0x020 | ||
123 | #define WM8776_DACRATE_384 0x030 | ||
124 | #define WM8776_DACRATE_512 0x040 | ||
125 | #define WM8776_DACRATE_768 0x050 | ||
126 | #define WM8776_DACMS 0x080 | ||
127 | #define WM8776_ADCMS 0x100 | ||
128 | |||
129 | /* PWRDOWN */ | ||
130 | #define WM8776_PDWN 0x001 | ||
131 | #define WM8776_ADCPD 0x002 | ||
132 | #define WM8776_DACPD 0x004 | ||
133 | #define WM8776_HPPD 0x008 | ||
134 | #define WM8776_AINPD 0x040 | ||
135 | |||
136 | /* ADCLVOL/ADCRVOL */ | ||
137 | #define WM8776_AGMASK 0x0ff | ||
138 | #define WM8776_ZCA 0x100 | ||
139 | |||
140 | /* ALCCTRL1 */ | ||
141 | #define WM8776_LCT_MASK 0x00f | ||
142 | #define WM8776_MAXGAIN_MASK 0x070 | ||
143 | #define WM8776_LCSEL_MASK 0x180 | ||
144 | #define WM8776_LCSEL_LIMITER 0x000 | ||
145 | #define WM8776_LCSEL_ALC_RIGHT 0x080 | ||
146 | #define WM8776_LCSEL_ALC_LEFT 0x100 | ||
147 | #define WM8776_LCSEL_ALC_STEREO 0x180 | ||
148 | |||
149 | /* ALCCTRL2 */ | ||
150 | #define WM8776_HLD_MASK 0x00f | ||
151 | #define WM8776_ALCZC 0x080 | ||
152 | #define WM8776_LCEN 0x100 | ||
153 | |||
154 | /* ALCCTRL3 */ | ||
155 | #define WM8776_ATK_MASK 0x00f | ||
156 | #define WM8776_DCY_MASK 0x0f0 | ||
157 | |||
158 | /* NOISEGATE */ | ||
159 | #define WM8776_NGAT 0x001 | ||
160 | #define WM8776_NGTH_MASK 0x01c | ||
161 | |||
162 | /* LIMITER */ | ||
163 | #define WM8776_MAXATTEN_MASK 0x00f | ||
164 | #define WM8776_TRANWIN_MASK 0x070 | ||
165 | |||
166 | /* ADCMUX */ | ||
167 | #define WM8776_AMX_MASK 0x01f | ||
168 | #define WM8776_MUTERA 0x040 | ||
169 | #define WM8776_MUTELA 0x080 | ||
170 | #define WM8776_LRBOTH 0x100 | ||
171 | |||
172 | /* OUTMUX */ | ||
173 | #define WM8776_MX_DAC 0x001 | ||
174 | #define WM8776_MX_AUX 0x002 | ||
175 | #define WM8776_MX_BYPASS 0x004 | ||
176 | |||
177 | #endif | ||
diff --git a/sound/pci/oxygen/xonar.h b/sound/pci/oxygen/xonar.h index 89b3ed814d64..b35343b0a9a5 100644 --- a/sound/pci/oxygen/xonar.h +++ b/sound/pci/oxygen/xonar.h | |||
@@ -35,6 +35,8 @@ int get_xonar_pcm179x_model(struct oxygen *chip, | |||
35 | const struct pci_device_id *id); | 35 | const struct pci_device_id *id); |
36 | int get_xonar_cs43xx_model(struct oxygen *chip, | 36 | int get_xonar_cs43xx_model(struct oxygen *chip, |
37 | const struct pci_device_id *id); | 37 | const struct pci_device_id *id); |
38 | int get_xonar_wm87x6_model(struct oxygen *chip, | ||
39 | const struct pci_device_id *id); | ||
38 | 40 | ||
39 | /* HDMI helper functions */ | 41 | /* HDMI helper functions */ |
40 | 42 | ||
diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c new file mode 100644 index 000000000000..dbc4b89d74e4 --- /dev/null +++ b/sound/pci/oxygen/xonar_wm87x6.c | |||
@@ -0,0 +1,1021 @@ | |||
1 | /* | ||
2 | * card driver for models with WM8776/WM8766 DACs (Xonar DS) | ||
3 | * | ||
4 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> | ||
5 | * | ||
6 | * | ||
7 | * This driver is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License, version 2. | ||
9 | * | ||
10 | * This driver is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this driver; if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | /* | ||
20 | * Xonar DS | ||
21 | * -------- | ||
22 | * | ||
23 | * CMI8788: | ||
24 | * | ||
25 | * SPI 0 -> WM8766 (surround, center/LFE, back) | ||
26 | * SPI 1 -> WM8776 (front, input) | ||
27 | * | ||
28 | * GPIO 4 <- headphone detect | ||
29 | * GPIO 6 -> route input jack to input 1/2 (1/0) | ||
30 | * GPIO 7 -> enable output to speakers | ||
31 | * GPIO 8 -> enable output to speakers | ||
32 | */ | ||
33 | |||
34 | #include <linux/pci.h> | ||
35 | #include <linux/delay.h> | ||
36 | #include <sound/control.h> | ||
37 | #include <sound/core.h> | ||
38 | #include <sound/pcm.h> | ||
39 | #include <sound/pcm_params.h> | ||
40 | #include <sound/tlv.h> | ||
41 | #include "xonar.h" | ||
42 | #include "wm8776.h" | ||
43 | #include "wm8766.h" | ||
44 | |||
45 | #define GPIO_DS_HP_DETECT 0x0010 | ||
46 | #define GPIO_DS_INPUT_ROUTE 0x0040 | ||
47 | #define GPIO_DS_OUTPUT_ENABLE 0x0180 | ||
48 | |||
49 | #define LC_CONTROL_LIMITER 0x40000000 | ||
50 | #define LC_CONTROL_ALC 0x20000000 | ||
51 | |||
52 | struct xonar_wm87x6 { | ||
53 | struct xonar_generic generic; | ||
54 | u16 wm8776_regs[0x17]; | ||
55 | u16 wm8766_regs[0x10]; | ||
56 | struct snd_kcontrol *lc_controls[13]; | ||
57 | }; | ||
58 | |||
59 | static void wm8776_write(struct oxygen *chip, | ||
60 | unsigned int reg, unsigned int value) | ||
61 | { | ||
62 | struct xonar_wm87x6 *data = chip->model_data; | ||
63 | |||
64 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | | ||
65 | OXYGEN_SPI_DATA_LENGTH_2 | | ||
66 | OXYGEN_SPI_CLOCK_160 | | ||
67 | (1 << OXYGEN_SPI_CODEC_SHIFT) | | ||
68 | OXYGEN_SPI_CEN_LATCH_CLOCK_LO, | ||
69 | (reg << 9) | value); | ||
70 | if (reg < ARRAY_SIZE(data->wm8776_regs)) { | ||
71 | if (reg >= WM8776_HPLVOL && reg <= WM8776_DACMASTER) | ||
72 | value &= ~WM8776_UPDATE; | ||
73 | data->wm8776_regs[reg] = value; | ||
74 | } | ||
75 | } | ||
76 | |||
77 | static void wm8776_write_cached(struct oxygen *chip, | ||
78 | unsigned int reg, unsigned int value) | ||
79 | { | ||
80 | struct xonar_wm87x6 *data = chip->model_data; | ||
81 | |||
82 | if (reg >= ARRAY_SIZE(data->wm8776_regs) || | ||
83 | value != data->wm8776_regs[reg]) | ||
84 | wm8776_write(chip, reg, value); | ||
85 | } | ||
86 | |||
87 | static void wm8766_write(struct oxygen *chip, | ||
88 | unsigned int reg, unsigned int value) | ||
89 | { | ||
90 | struct xonar_wm87x6 *data = chip->model_data; | ||
91 | |||
92 | oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | | ||
93 | OXYGEN_SPI_DATA_LENGTH_2 | | ||
94 | OXYGEN_SPI_CLOCK_160 | | ||
95 | (0 << OXYGEN_SPI_CODEC_SHIFT) | | ||
96 | OXYGEN_SPI_CEN_LATCH_CLOCK_LO, | ||
97 | (reg << 9) | value); | ||
98 | if (reg < ARRAY_SIZE(data->wm8766_regs)) | ||
99 | data->wm8766_regs[reg] = value; | ||
100 | } | ||
101 | |||
102 | static void wm8766_write_cached(struct oxygen *chip, | ||
103 | unsigned int reg, unsigned int value) | ||
104 | { | ||
105 | struct xonar_wm87x6 *data = chip->model_data; | ||
106 | |||
107 | if (reg >= ARRAY_SIZE(data->wm8766_regs) || | ||
108 | value != data->wm8766_regs[reg]) { | ||
109 | if ((reg >= WM8766_LDA1 && reg <= WM8766_RDA1) || | ||
110 | (reg >= WM8766_LDA2 && reg <= WM8766_MASTDA)) | ||
111 | value &= ~WM8766_UPDATE; | ||
112 | wm8766_write(chip, reg, value); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | static void wm8776_registers_init(struct oxygen *chip) | ||
117 | { | ||
118 | struct xonar_wm87x6 *data = chip->model_data; | ||
119 | |||
120 | wm8776_write(chip, WM8776_RESET, 0); | ||
121 | wm8776_write(chip, WM8776_DACCTRL1, WM8776_DZCEN | | ||
122 | WM8776_PL_LEFT_LEFT | WM8776_PL_RIGHT_RIGHT); | ||
123 | wm8776_write(chip, WM8776_DACMUTE, chip->dac_mute ? WM8776_DMUTE : 0); | ||
124 | wm8776_write(chip, WM8776_DACIFCTRL, | ||
125 | WM8776_DACFMT_LJUST | WM8776_DACWL_24); | ||
126 | wm8776_write(chip, WM8776_ADCIFCTRL, | ||
127 | data->wm8776_regs[WM8776_ADCIFCTRL]); | ||
128 | wm8776_write(chip, WM8776_MSTRCTRL, data->wm8776_regs[WM8776_MSTRCTRL]); | ||
129 | wm8776_write(chip, WM8776_PWRDOWN, data->wm8776_regs[WM8776_PWRDOWN]); | ||
130 | wm8776_write(chip, WM8776_HPLVOL, data->wm8776_regs[WM8776_HPLVOL]); | ||
131 | wm8776_write(chip, WM8776_HPRVOL, data->wm8776_regs[WM8776_HPRVOL] | | ||
132 | WM8776_UPDATE); | ||
133 | wm8776_write(chip, WM8776_ADCLVOL, data->wm8776_regs[WM8776_ADCLVOL]); | ||
134 | wm8776_write(chip, WM8776_ADCRVOL, data->wm8776_regs[WM8776_ADCRVOL]); | ||
135 | wm8776_write(chip, WM8776_ADCMUX, data->wm8776_regs[WM8776_ADCMUX]); | ||
136 | wm8776_write(chip, WM8776_DACLVOL, chip->dac_volume[0]); | ||
137 | wm8776_write(chip, WM8776_DACRVOL, chip->dac_volume[1] | WM8776_UPDATE); | ||
138 | } | ||
139 | |||
140 | static void wm8766_registers_init(struct oxygen *chip) | ||
141 | { | ||
142 | wm8766_write(chip, WM8766_RESET, 0); | ||
143 | wm8766_write(chip, WM8766_INT_CTRL, WM8766_FMT_LJUST | WM8766_IWL_24); | ||
144 | wm8766_write(chip, WM8766_DAC_CTRL2, | ||
145 | WM8766_ZCD | (chip->dac_mute ? WM8766_DMUTE_MASK : 0)); | ||
146 | wm8766_write(chip, WM8766_LDA1, chip->dac_volume[2]); | ||
147 | wm8766_write(chip, WM8766_RDA1, chip->dac_volume[3]); | ||
148 | wm8766_write(chip, WM8766_LDA2, chip->dac_volume[4]); | ||
149 | wm8766_write(chip, WM8766_RDA2, chip->dac_volume[5]); | ||
150 | wm8766_write(chip, WM8766_LDA3, chip->dac_volume[6]); | ||
151 | wm8766_write(chip, WM8766_RDA3, chip->dac_volume[7] | WM8766_UPDATE); | ||
152 | } | ||
153 | |||
154 | static void wm8776_init(struct oxygen *chip) | ||
155 | { | ||
156 | struct xonar_wm87x6 *data = chip->model_data; | ||
157 | |||
158 | data->wm8776_regs[WM8776_HPLVOL] = (0x79 - 60) | WM8776_HPZCEN; | ||
159 | data->wm8776_regs[WM8776_HPRVOL] = (0x79 - 60) | WM8776_HPZCEN; | ||
160 | data->wm8776_regs[WM8776_ADCIFCTRL] = | ||
161 | WM8776_ADCFMT_LJUST | WM8776_ADCWL_24 | WM8776_ADCMCLK; | ||
162 | data->wm8776_regs[WM8776_MSTRCTRL] = | ||
163 | WM8776_ADCRATE_256 | WM8776_DACRATE_256; | ||
164 | data->wm8776_regs[WM8776_PWRDOWN] = WM8776_HPPD; | ||
165 | data->wm8776_regs[WM8776_ADCLVOL] = 0xa5 | WM8776_ZCA; | ||
166 | data->wm8776_regs[WM8776_ADCRVOL] = 0xa5 | WM8776_ZCA; | ||
167 | data->wm8776_regs[WM8776_ADCMUX] = 0x001; | ||
168 | wm8776_registers_init(chip); | ||
169 | } | ||
170 | |||
171 | static void xonar_ds_init(struct oxygen *chip) | ||
172 | { | ||
173 | struct xonar_wm87x6 *data = chip->model_data; | ||
174 | |||
175 | data->generic.anti_pop_delay = 300; | ||
176 | data->generic.output_enable_bit = GPIO_DS_OUTPUT_ENABLE; | ||
177 | |||
178 | wm8776_init(chip); | ||
179 | wm8766_registers_init(chip); | ||
180 | |||
181 | oxygen_write16_masked(chip, OXYGEN_GPIO_CONTROL, GPIO_DS_INPUT_ROUTE, | ||
182 | GPIO_DS_HP_DETECT | GPIO_DS_INPUT_ROUTE); | ||
183 | oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_DS_INPUT_ROUTE); | ||
184 | oxygen_set_bits16(chip, OXYGEN_GPIO_INTERRUPT_MASK, GPIO_DS_HP_DETECT); | ||
185 | chip->interrupt_mask |= OXYGEN_INT_GPIO; | ||
186 | |||
187 | xonar_enable_output(chip); | ||
188 | |||
189 | snd_component_add(chip->card, "WM8776"); | ||
190 | snd_component_add(chip->card, "WM8766"); | ||
191 | } | ||
192 | |||
193 | static void xonar_ds_cleanup(struct oxygen *chip) | ||
194 | { | ||
195 | xonar_disable_output(chip); | ||
196 | } | ||
197 | |||
198 | static void xonar_ds_suspend(struct oxygen *chip) | ||
199 | { | ||
200 | xonar_ds_cleanup(chip); | ||
201 | } | ||
202 | |||
203 | static void xonar_ds_resume(struct oxygen *chip) | ||
204 | { | ||
205 | wm8776_registers_init(chip); | ||
206 | wm8766_registers_init(chip); | ||
207 | xonar_enable_output(chip); | ||
208 | } | ||
209 | |||
210 | static void wm8776_adc_hardware_filter(unsigned int channel, | ||
211 | struct snd_pcm_hardware *hardware) | ||
212 | { | ||
213 | if (channel == PCM_A) { | ||
214 | hardware->rates = SNDRV_PCM_RATE_32000 | | ||
215 | SNDRV_PCM_RATE_44100 | | ||
216 | SNDRV_PCM_RATE_48000 | | ||
217 | SNDRV_PCM_RATE_64000 | | ||
218 | SNDRV_PCM_RATE_88200 | | ||
219 | SNDRV_PCM_RATE_96000; | ||
220 | hardware->rate_max = 96000; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | static void set_wm87x6_dac_params(struct oxygen *chip, | ||
225 | struct snd_pcm_hw_params *params) | ||
226 | { | ||
227 | } | ||
228 | |||
229 | static void set_wm8776_adc_params(struct oxygen *chip, | ||
230 | struct snd_pcm_hw_params *params) | ||
231 | { | ||
232 | u16 reg; | ||
233 | |||
234 | reg = WM8776_ADCRATE_256 | WM8776_DACRATE_256; | ||
235 | if (params_rate(params) > 48000) | ||
236 | reg |= WM8776_ADCOSR; | ||
237 | wm8776_write_cached(chip, WM8776_MSTRCTRL, reg); | ||
238 | } | ||
239 | |||
240 | static void update_wm8776_volume(struct oxygen *chip) | ||
241 | { | ||
242 | struct xonar_wm87x6 *data = chip->model_data; | ||
243 | u8 to_change; | ||
244 | |||
245 | if (chip->dac_volume[0] == chip->dac_volume[1]) { | ||
246 | if (chip->dac_volume[0] != data->wm8776_regs[WM8776_DACLVOL] || | ||
247 | chip->dac_volume[1] != data->wm8776_regs[WM8776_DACRVOL]) { | ||
248 | wm8776_write(chip, WM8776_DACMASTER, | ||
249 | chip->dac_volume[0] | WM8776_UPDATE); | ||
250 | data->wm8776_regs[WM8776_DACLVOL] = chip->dac_volume[0]; | ||
251 | data->wm8776_regs[WM8776_DACRVOL] = chip->dac_volume[0]; | ||
252 | } | ||
253 | } else { | ||
254 | to_change = (chip->dac_volume[0] != | ||
255 | data->wm8776_regs[WM8776_DACLVOL]) << 0; | ||
256 | to_change |= (chip->dac_volume[1] != | ||
257 | data->wm8776_regs[WM8776_DACLVOL]) << 1; | ||
258 | if (to_change & 1) | ||
259 | wm8776_write(chip, WM8776_DACLVOL, chip->dac_volume[0] | | ||
260 | ((to_change & 2) ? 0 : WM8776_UPDATE)); | ||
261 | if (to_change & 2) | ||
262 | wm8776_write(chip, WM8776_DACRVOL, | ||
263 | chip->dac_volume[1] | WM8776_UPDATE); | ||
264 | } | ||
265 | } | ||
266 | |||
267 | static void update_wm87x6_volume(struct oxygen *chip) | ||
268 | { | ||
269 | static const u8 wm8766_regs[6] = { | ||
270 | WM8766_LDA1, WM8766_RDA1, | ||
271 | WM8766_LDA2, WM8766_RDA2, | ||
272 | WM8766_LDA3, WM8766_RDA3, | ||
273 | }; | ||
274 | struct xonar_wm87x6 *data = chip->model_data; | ||
275 | unsigned int i; | ||
276 | u8 to_change; | ||
277 | |||
278 | update_wm8776_volume(chip); | ||
279 | if (chip->dac_volume[2] == chip->dac_volume[3] && | ||
280 | chip->dac_volume[2] == chip->dac_volume[4] && | ||
281 | chip->dac_volume[2] == chip->dac_volume[5] && | ||
282 | chip->dac_volume[2] == chip->dac_volume[6] && | ||
283 | chip->dac_volume[2] == chip->dac_volume[7]) { | ||
284 | to_change = 0; | ||
285 | for (i = 0; i < 6; ++i) | ||
286 | if (chip->dac_volume[2] != | ||
287 | data->wm8766_regs[wm8766_regs[i]]) | ||
288 | to_change = 1; | ||
289 | if (to_change) { | ||
290 | wm8766_write(chip, WM8766_MASTDA, | ||
291 | chip->dac_volume[2] | WM8766_UPDATE); | ||
292 | for (i = 0; i < 6; ++i) | ||
293 | data->wm8766_regs[wm8766_regs[i]] = | ||
294 | chip->dac_volume[2]; | ||
295 | } | ||
296 | } else { | ||
297 | to_change = 0; | ||
298 | for (i = 0; i < 6; ++i) | ||
299 | to_change |= (chip->dac_volume[2 + i] != | ||
300 | data->wm8766_regs[wm8766_regs[i]]) << i; | ||
301 | for (i = 0; i < 6; ++i) | ||
302 | if (to_change & (1 << i)) | ||
303 | wm8766_write(chip, wm8766_regs[i], | ||
304 | chip->dac_volume[2 + i] | | ||
305 | ((to_change & (0x3e << i)) | ||
306 | ? 0 : WM8766_UPDATE)); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | static void update_wm8776_mute(struct oxygen *chip) | ||
311 | { | ||
312 | wm8776_write_cached(chip, WM8776_DACMUTE, | ||
313 | chip->dac_mute ? WM8776_DMUTE : 0); | ||
314 | } | ||
315 | |||
316 | static void update_wm87x6_mute(struct oxygen *chip) | ||
317 | { | ||
318 | update_wm8776_mute(chip); | ||
319 | wm8766_write_cached(chip, WM8766_DAC_CTRL2, WM8766_ZCD | | ||
320 | (chip->dac_mute ? WM8766_DMUTE_MASK : 0)); | ||
321 | } | ||
322 | |||
323 | static void xonar_ds_gpio_changed(struct oxygen *chip) | ||
324 | { | ||
325 | u16 bits; | ||
326 | |||
327 | bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); | ||
328 | snd_printk(KERN_INFO "HP detect: %d\n", !!(bits & GPIO_DS_HP_DETECT)); | ||
329 | } | ||
330 | |||
331 | static int wm8776_bit_switch_get(struct snd_kcontrol *ctl, | ||
332 | struct snd_ctl_elem_value *value) | ||
333 | { | ||
334 | struct oxygen *chip = ctl->private_data; | ||
335 | struct xonar_wm87x6 *data = chip->model_data; | ||
336 | u16 bit = ctl->private_value & 0xffff; | ||
337 | unsigned int reg_index = (ctl->private_value >> 16) & 0xff; | ||
338 | bool invert = (ctl->private_value >> 24) & 1; | ||
339 | |||
340 | value->value.integer.value[0] = | ||
341 | ((data->wm8776_regs[reg_index] & bit) != 0) ^ invert; | ||
342 | return 0; | ||
343 | } | ||
344 | |||
345 | static int wm8776_bit_switch_put(struct snd_kcontrol *ctl, | ||
346 | struct snd_ctl_elem_value *value) | ||
347 | { | ||
348 | struct oxygen *chip = ctl->private_data; | ||
349 | struct xonar_wm87x6 *data = chip->model_data; | ||
350 | u16 bit = ctl->private_value & 0xffff; | ||
351 | u16 reg_value; | ||
352 | unsigned int reg_index = (ctl->private_value >> 16) & 0xff; | ||
353 | bool invert = (ctl->private_value >> 24) & 1; | ||
354 | int changed; | ||
355 | |||
356 | mutex_lock(&chip->mutex); | ||
357 | reg_value = data->wm8776_regs[reg_index] & ~bit; | ||
358 | if (value->value.integer.value[0] ^ invert) | ||
359 | reg_value |= bit; | ||
360 | changed = reg_value != data->wm8776_regs[reg_index]; | ||
361 | if (changed) | ||
362 | wm8776_write(chip, reg_index, reg_value); | ||
363 | mutex_unlock(&chip->mutex); | ||
364 | return changed; | ||
365 | } | ||
366 | |||
367 | static int wm8776_field_enum_info(struct snd_kcontrol *ctl, | ||
368 | struct snd_ctl_elem_info *info) | ||
369 | { | ||
370 | static const char *const hld[16] = { | ||
371 | "0 ms", "2.67 ms", "5.33 ms", "10.6 ms", | ||
372 | "21.3 ms", "42.7 ms", "85.3 ms", "171 ms", | ||
373 | "341 ms", "683 ms", "1.37 s", "2.73 s", | ||
374 | "5.46 s", "10.9 s", "21.8 s", "43.7 s", | ||
375 | }; | ||
376 | static const char *const atk_lim[11] = { | ||
377 | "0.25 ms", "0.5 ms", "1 ms", "2 ms", | ||
378 | "4 ms", "8 ms", "16 ms", "32 ms", | ||
379 | "64 ms", "128 ms", "256 ms", | ||
380 | }; | ||
381 | static const char *const atk_alc[11] = { | ||
382 | "8.40 ms", "16.8 ms", "33.6 ms", "67.2 ms", | ||
383 | "134 ms", "269 ms", "538 ms", "1.08 s", | ||
384 | "2.15 s", "4.3 s", "8.6 s", | ||
385 | }; | ||
386 | static const char *const dcy_lim[11] = { | ||
387 | "1.2 ms", "2.4 ms", "4.8 ms", "9.6 ms", | ||
388 | "19.2 ms", "38.4 ms", "76.8 ms", "154 ms", | ||
389 | "307 ms", "614 ms", "1.23 s", | ||
390 | }; | ||
391 | static const char *const dcy_alc[11] = { | ||
392 | "33.5 ms", "67.0 ms", "134 ms", "268 ms", | ||
393 | "536 ms", "1.07 s", "2.14 s", "4.29 s", | ||
394 | "8.58 s", "17.2 s", "34.3 s", | ||
395 | }; | ||
396 | static const char *const tranwin[8] = { | ||
397 | "0 us", "62.5 us", "125 us", "250 us", | ||
398 | "500 us", "1 ms", "2 ms", "4 ms", | ||
399 | }; | ||
400 | u8 max; | ||
401 | const char *const *names; | ||
402 | |||
403 | max = (ctl->private_value >> 12) & 0xf; | ||
404 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
405 | info->count = 1; | ||
406 | info->value.enumerated.items = max + 1; | ||
407 | if (info->value.enumerated.item > max) | ||
408 | info->value.enumerated.item = max; | ||
409 | switch ((ctl->private_value >> 24) & 0x1f) { | ||
410 | case WM8776_ALCCTRL2: | ||
411 | names = hld; | ||
412 | break; | ||
413 | case WM8776_ALCCTRL3: | ||
414 | if (((ctl->private_value >> 20) & 0xf) == 0) { | ||
415 | if (ctl->private_value & LC_CONTROL_LIMITER) | ||
416 | names = atk_lim; | ||
417 | else | ||
418 | names = atk_alc; | ||
419 | } else { | ||
420 | if (ctl->private_value & LC_CONTROL_LIMITER) | ||
421 | names = dcy_lim; | ||
422 | else | ||
423 | names = dcy_alc; | ||
424 | } | ||
425 | break; | ||
426 | case WM8776_LIMITER: | ||
427 | names = tranwin; | ||
428 | break; | ||
429 | default: | ||
430 | return -ENXIO; | ||
431 | } | ||
432 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
433 | return 0; | ||
434 | } | ||
435 | |||
436 | static int wm8776_field_volume_info(struct snd_kcontrol *ctl, | ||
437 | struct snd_ctl_elem_info *info) | ||
438 | { | ||
439 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
440 | info->count = 1; | ||
441 | info->value.integer.min = (ctl->private_value >> 8) & 0xf; | ||
442 | info->value.integer.max = (ctl->private_value >> 12) & 0xf; | ||
443 | return 0; | ||
444 | } | ||
445 | |||
446 | static void wm8776_field_set_from_ctl(struct snd_kcontrol *ctl) | ||
447 | { | ||
448 | struct oxygen *chip = ctl->private_data; | ||
449 | struct xonar_wm87x6 *data = chip->model_data; | ||
450 | unsigned int value, reg_index, mode; | ||
451 | u8 min, max, shift; | ||
452 | u16 mask, reg_value; | ||
453 | bool invert; | ||
454 | |||
455 | if ((data->wm8776_regs[WM8776_ALCCTRL1] & WM8776_LCSEL_MASK) == | ||
456 | WM8776_LCSEL_LIMITER) | ||
457 | mode = LC_CONTROL_LIMITER; | ||
458 | else | ||
459 | mode = LC_CONTROL_ALC; | ||
460 | if (!(ctl->private_value & mode)) | ||
461 | return; | ||
462 | |||
463 | value = ctl->private_value & 0xf; | ||
464 | min = (ctl->private_value >> 8) & 0xf; | ||
465 | max = (ctl->private_value >> 12) & 0xf; | ||
466 | mask = (ctl->private_value >> 16) & 0xf; | ||
467 | shift = (ctl->private_value >> 20) & 0xf; | ||
468 | reg_index = (ctl->private_value >> 24) & 0x1f; | ||
469 | invert = (ctl->private_value >> 29) & 0x1; | ||
470 | |||
471 | if (invert) | ||
472 | value = max - (value - min); | ||
473 | reg_value = data->wm8776_regs[reg_index]; | ||
474 | reg_value &= ~(mask << shift); | ||
475 | reg_value |= value << shift; | ||
476 | wm8776_write_cached(chip, reg_index, reg_value); | ||
477 | } | ||
478 | |||
479 | static int wm8776_field_set(struct snd_kcontrol *ctl, unsigned int value) | ||
480 | { | ||
481 | struct oxygen *chip = ctl->private_data; | ||
482 | u8 min, max; | ||
483 | int changed; | ||
484 | |||
485 | min = (ctl->private_value >> 8) & 0xf; | ||
486 | max = (ctl->private_value >> 12) & 0xf; | ||
487 | if (value < min || value > max) | ||
488 | return -EINVAL; | ||
489 | mutex_lock(&chip->mutex); | ||
490 | changed = value != (ctl->private_value & 0xf); | ||
491 | if (changed) { | ||
492 | ctl->private_value = (ctl->private_value & ~0xf) | value; | ||
493 | wm8776_field_set_from_ctl(ctl); | ||
494 | } | ||
495 | mutex_unlock(&chip->mutex); | ||
496 | return changed; | ||
497 | } | ||
498 | |||
499 | static int wm8776_field_enum_get(struct snd_kcontrol *ctl, | ||
500 | struct snd_ctl_elem_value *value) | ||
501 | { | ||
502 | value->value.enumerated.item[0] = ctl->private_value & 0xf; | ||
503 | return 0; | ||
504 | } | ||
505 | |||
506 | static int wm8776_field_volume_get(struct snd_kcontrol *ctl, | ||
507 | struct snd_ctl_elem_value *value) | ||
508 | { | ||
509 | value->value.integer.value[0] = ctl->private_value & 0xf; | ||
510 | return 0; | ||
511 | } | ||
512 | |||
513 | static int wm8776_field_enum_put(struct snd_kcontrol *ctl, | ||
514 | struct snd_ctl_elem_value *value) | ||
515 | { | ||
516 | return wm8776_field_set(ctl, value->value.enumerated.item[0]); | ||
517 | } | ||
518 | |||
519 | static int wm8776_field_volume_put(struct snd_kcontrol *ctl, | ||
520 | struct snd_ctl_elem_value *value) | ||
521 | { | ||
522 | return wm8776_field_set(ctl, value->value.integer.value[0]); | ||
523 | } | ||
524 | |||
525 | static int wm8776_hp_vol_info(struct snd_kcontrol *ctl, | ||
526 | struct snd_ctl_elem_info *info) | ||
527 | { | ||
528 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
529 | info->count = 2; | ||
530 | info->value.integer.min = 0x79 - 60; | ||
531 | info->value.integer.max = 0x7f; | ||
532 | return 0; | ||
533 | } | ||
534 | |||
535 | static int wm8776_hp_vol_get(struct snd_kcontrol *ctl, | ||
536 | struct snd_ctl_elem_value *value) | ||
537 | { | ||
538 | struct oxygen *chip = ctl->private_data; | ||
539 | struct xonar_wm87x6 *data = chip->model_data; | ||
540 | |||
541 | mutex_lock(&chip->mutex); | ||
542 | value->value.integer.value[0] = | ||
543 | data->wm8776_regs[WM8776_HPLVOL] & WM8776_HPATT_MASK; | ||
544 | value->value.integer.value[1] = | ||
545 | data->wm8776_regs[WM8776_HPRVOL] & WM8776_HPATT_MASK; | ||
546 | mutex_unlock(&chip->mutex); | ||
547 | return 0; | ||
548 | } | ||
549 | |||
550 | static int wm8776_hp_vol_put(struct snd_kcontrol *ctl, | ||
551 | struct snd_ctl_elem_value *value) | ||
552 | { | ||
553 | struct oxygen *chip = ctl->private_data; | ||
554 | struct xonar_wm87x6 *data = chip->model_data; | ||
555 | u8 to_update; | ||
556 | |||
557 | mutex_lock(&chip->mutex); | ||
558 | to_update = (value->value.integer.value[0] != | ||
559 | (data->wm8776_regs[WM8776_HPLVOL] & WM8776_HPATT_MASK)) | ||
560 | << 0; | ||
561 | to_update |= (value->value.integer.value[1] != | ||
562 | (data->wm8776_regs[WM8776_HPRVOL] & WM8776_HPATT_MASK)) | ||
563 | << 1; | ||
564 | if (value->value.integer.value[0] == value->value.integer.value[1]) { | ||
565 | if (to_update) { | ||
566 | wm8776_write(chip, WM8776_HPMASTER, | ||
567 | value->value.integer.value[0] | | ||
568 | WM8776_HPZCEN | WM8776_UPDATE); | ||
569 | data->wm8776_regs[WM8776_HPLVOL] = | ||
570 | value->value.integer.value[0] | WM8776_HPZCEN; | ||
571 | data->wm8776_regs[WM8776_HPRVOL] = | ||
572 | value->value.integer.value[0] | WM8776_HPZCEN; | ||
573 | } | ||
574 | } else { | ||
575 | if (to_update & 1) | ||
576 | wm8776_write(chip, WM8776_HPLVOL, | ||
577 | value->value.integer.value[0] | | ||
578 | WM8776_HPZCEN | | ||
579 | ((to_update & 2) ? 0 : WM8776_UPDATE)); | ||
580 | if (to_update & 2) | ||
581 | wm8776_write(chip, WM8776_HPRVOL, | ||
582 | value->value.integer.value[1] | | ||
583 | WM8776_HPZCEN | WM8776_UPDATE); | ||
584 | } | ||
585 | mutex_unlock(&chip->mutex); | ||
586 | return to_update != 0; | ||
587 | } | ||
588 | |||
589 | static int wm8776_input_mux_get(struct snd_kcontrol *ctl, | ||
590 | struct snd_ctl_elem_value *value) | ||
591 | { | ||
592 | struct oxygen *chip = ctl->private_data; | ||
593 | struct xonar_wm87x6 *data = chip->model_data; | ||
594 | unsigned int mux_bit = ctl->private_value; | ||
595 | |||
596 | value->value.integer.value[0] = | ||
597 | !!(data->wm8776_regs[WM8776_ADCMUX] & mux_bit); | ||
598 | return 0; | ||
599 | } | ||
600 | |||
601 | static int wm8776_input_mux_put(struct snd_kcontrol *ctl, | ||
602 | struct snd_ctl_elem_value *value) | ||
603 | { | ||
604 | struct oxygen *chip = ctl->private_data; | ||
605 | struct xonar_wm87x6 *data = chip->model_data; | ||
606 | unsigned int mux_bit = ctl->private_value; | ||
607 | u16 reg; | ||
608 | int changed; | ||
609 | |||
610 | mutex_lock(&chip->mutex); | ||
611 | reg = data->wm8776_regs[WM8776_ADCMUX]; | ||
612 | if (value->value.integer.value[0]) { | ||
613 | reg &= ~0x003; | ||
614 | reg |= mux_bit; | ||
615 | } else | ||
616 | reg &= ~mux_bit; | ||
617 | changed = reg != data->wm8776_regs[WM8776_ADCMUX]; | ||
618 | if (changed) { | ||
619 | oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, | ||
620 | reg & 1 ? GPIO_DS_INPUT_ROUTE : 0, | ||
621 | GPIO_DS_INPUT_ROUTE); | ||
622 | wm8776_write(chip, WM8776_ADCMUX, reg); | ||
623 | } | ||
624 | mutex_unlock(&chip->mutex); | ||
625 | return changed; | ||
626 | } | ||
627 | |||
628 | static int wm8776_input_vol_info(struct snd_kcontrol *ctl, | ||
629 | struct snd_ctl_elem_info *info) | ||
630 | { | ||
631 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
632 | info->count = 2; | ||
633 | info->value.integer.min = 0xa5; | ||
634 | info->value.integer.max = 0xff; | ||
635 | return 0; | ||
636 | } | ||
637 | |||
638 | static int wm8776_input_vol_get(struct snd_kcontrol *ctl, | ||
639 | struct snd_ctl_elem_value *value) | ||
640 | { | ||
641 | struct oxygen *chip = ctl->private_data; | ||
642 | struct xonar_wm87x6 *data = chip->model_data; | ||
643 | |||
644 | mutex_lock(&chip->mutex); | ||
645 | value->value.integer.value[0] = | ||
646 | data->wm8776_regs[WM8776_ADCLVOL] & WM8776_AGMASK; | ||
647 | value->value.integer.value[1] = | ||
648 | data->wm8776_regs[WM8776_ADCRVOL] & WM8776_AGMASK; | ||
649 | mutex_unlock(&chip->mutex); | ||
650 | return 0; | ||
651 | } | ||
652 | |||
653 | static int wm8776_input_vol_put(struct snd_kcontrol *ctl, | ||
654 | struct snd_ctl_elem_value *value) | ||
655 | { | ||
656 | struct oxygen *chip = ctl->private_data; | ||
657 | struct xonar_wm87x6 *data = chip->model_data; | ||
658 | int changed = 0; | ||
659 | |||
660 | mutex_lock(&chip->mutex); | ||
661 | changed = (value->value.integer.value[0] != | ||
662 | (data->wm8776_regs[WM8776_ADCLVOL] & WM8776_AGMASK)) || | ||
663 | (value->value.integer.value[1] != | ||
664 | (data->wm8776_regs[WM8776_ADCRVOL] & WM8776_AGMASK)); | ||
665 | wm8776_write_cached(chip, WM8776_ADCLVOL, | ||
666 | value->value.integer.value[0] | WM8776_ZCA); | ||
667 | wm8776_write_cached(chip, WM8776_ADCRVOL, | ||
668 | value->value.integer.value[1] | WM8776_ZCA); | ||
669 | mutex_unlock(&chip->mutex); | ||
670 | return changed; | ||
671 | } | ||
672 | |||
673 | static int wm8776_level_control_info(struct snd_kcontrol *ctl, | ||
674 | struct snd_ctl_elem_info *info) | ||
675 | { | ||
676 | static const char *const names[3] = { | ||
677 | "None", "Peak Limiter", "Automatic Level Control" | ||
678 | }; | ||
679 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
680 | info->count = 1; | ||
681 | info->value.enumerated.items = 3; | ||
682 | if (info->value.enumerated.item >= 3) | ||
683 | info->value.enumerated.item = 2; | ||
684 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
685 | return 0; | ||
686 | } | ||
687 | |||
688 | static int wm8776_level_control_get(struct snd_kcontrol *ctl, | ||
689 | struct snd_ctl_elem_value *value) | ||
690 | { | ||
691 | struct oxygen *chip = ctl->private_data; | ||
692 | struct xonar_wm87x6 *data = chip->model_data; | ||
693 | |||
694 | if (!(data->wm8776_regs[WM8776_ALCCTRL2] & WM8776_LCEN)) | ||
695 | value->value.enumerated.item[0] = 0; | ||
696 | else if ((data->wm8776_regs[WM8776_ALCCTRL1] & WM8776_LCSEL_MASK) == | ||
697 | WM8776_LCSEL_LIMITER) | ||
698 | value->value.enumerated.item[0] = 1; | ||
699 | else | ||
700 | value->value.enumerated.item[0] = 2; | ||
701 | return 0; | ||
702 | } | ||
703 | |||
704 | static void activate_control(struct oxygen *chip, | ||
705 | struct snd_kcontrol *ctl, unsigned int mode) | ||
706 | { | ||
707 | unsigned int access; | ||
708 | |||
709 | if (ctl->private_value & mode) | ||
710 | access = 0; | ||
711 | else | ||
712 | access = SNDRV_CTL_ELEM_ACCESS_INACTIVE; | ||
713 | if ((ctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_INACTIVE) != access) { | ||
714 | ctl->vd[0].access ^= SNDRV_CTL_ELEM_ACCESS_INACTIVE; | ||
715 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); | ||
716 | } | ||
717 | } | ||
718 | |||
719 | static int wm8776_level_control_put(struct snd_kcontrol *ctl, | ||
720 | struct snd_ctl_elem_value *value) | ||
721 | { | ||
722 | struct oxygen *chip = ctl->private_data; | ||
723 | struct xonar_wm87x6 *data = chip->model_data; | ||
724 | unsigned int mode = 0, i; | ||
725 | u16 ctrl1, ctrl2; | ||
726 | int changed; | ||
727 | |||
728 | if (value->value.enumerated.item[0] >= 3) | ||
729 | return -EINVAL; | ||
730 | mutex_lock(&chip->mutex); | ||
731 | changed = value->value.enumerated.item[0] != ctl->private_value; | ||
732 | if (changed) { | ||
733 | ctl->private_value = value->value.enumerated.item[0]; | ||
734 | ctrl1 = data->wm8776_regs[WM8776_ALCCTRL1]; | ||
735 | ctrl2 = data->wm8776_regs[WM8776_ALCCTRL2]; | ||
736 | switch (value->value.enumerated.item[0]) { | ||
737 | default: | ||
738 | wm8776_write_cached(chip, WM8776_ALCCTRL2, | ||
739 | ctrl2 & ~WM8776_LCEN); | ||
740 | break; | ||
741 | case 1: | ||
742 | wm8776_write_cached(chip, WM8776_ALCCTRL1, | ||
743 | (ctrl1 & ~WM8776_LCSEL_MASK) | | ||
744 | WM8776_LCSEL_LIMITER); | ||
745 | wm8776_write_cached(chip, WM8776_ALCCTRL2, | ||
746 | ctrl2 | WM8776_LCEN); | ||
747 | mode = LC_CONTROL_LIMITER; | ||
748 | break; | ||
749 | case 2: | ||
750 | wm8776_write_cached(chip, WM8776_ALCCTRL1, | ||
751 | (ctrl1 & ~WM8776_LCSEL_MASK) | | ||
752 | WM8776_LCSEL_ALC_STEREO); | ||
753 | wm8776_write_cached(chip, WM8776_ALCCTRL2, | ||
754 | ctrl2 | WM8776_LCEN); | ||
755 | mode = LC_CONTROL_ALC; | ||
756 | break; | ||
757 | } | ||
758 | for (i = 0; i < ARRAY_SIZE(data->lc_controls); ++i) | ||
759 | activate_control(chip, data->lc_controls[i], mode); | ||
760 | } | ||
761 | mutex_unlock(&chip->mutex); | ||
762 | return changed; | ||
763 | } | ||
764 | |||
765 | static int hpf_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) | ||
766 | { | ||
767 | static const char *const names[2] = { | ||
768 | "None", "High-pass Filter" | ||
769 | }; | ||
770 | |||
771 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
772 | info->count = 1; | ||
773 | info->value.enumerated.items = 2; | ||
774 | if (info->value.enumerated.item >= 2) | ||
775 | info->value.enumerated.item = 1; | ||
776 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | ||
777 | return 0; | ||
778 | } | ||
779 | |||
780 | static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | ||
781 | { | ||
782 | struct oxygen *chip = ctl->private_data; | ||
783 | struct xonar_wm87x6 *data = chip->model_data; | ||
784 | |||
785 | value->value.enumerated.item[0] = | ||
786 | !(data->wm8776_regs[WM8776_ADCIFCTRL] & WM8776_ADCHPD); | ||
787 | return 0; | ||
788 | } | ||
789 | |||
790 | static int hpf_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | ||
791 | { | ||
792 | struct oxygen *chip = ctl->private_data; | ||
793 | struct xonar_wm87x6 *data = chip->model_data; | ||
794 | unsigned int reg; | ||
795 | int changed; | ||
796 | |||
797 | mutex_lock(&chip->mutex); | ||
798 | reg = data->wm8776_regs[WM8776_ADCIFCTRL] & ~WM8776_ADCHPD; | ||
799 | if (!value->value.enumerated.item[0]) | ||
800 | reg |= WM8776_ADCHPD; | ||
801 | changed = reg != data->wm8776_regs[WM8776_ADCIFCTRL]; | ||
802 | if (changed) | ||
803 | wm8776_write(chip, WM8776_ADCIFCTRL, reg); | ||
804 | mutex_unlock(&chip->mutex); | ||
805 | return changed; | ||
806 | } | ||
807 | |||
808 | #define WM8776_BIT_SWITCH(xname, reg, bit, invert, flags) { \ | ||
809 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
810 | .name = xname, \ | ||
811 | .info = snd_ctl_boolean_mono_info, \ | ||
812 | .get = wm8776_bit_switch_get, \ | ||
813 | .put = wm8776_bit_switch_put, \ | ||
814 | .private_value = ((reg) << 16) | (bit) | ((invert) << 24) | (flags), \ | ||
815 | } | ||
816 | #define _WM8776_FIELD_CTL(xname, reg, shift, initval, min, max, mask, flags) \ | ||
817 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
818 | .name = xname, \ | ||
819 | .private_value = (initval) | ((min) << 8) | ((max) << 12) | \ | ||
820 | ((mask) << 16) | ((shift) << 20) | ((reg) << 24) | (flags) | ||
821 | #define WM8776_FIELD_CTL_ENUM(xname, reg, shift, init, min, max, mask, flags) {\ | ||
822 | _WM8776_FIELD_CTL(xname " Capture Enum", \ | ||
823 | reg, shift, init, min, max, mask, flags), \ | ||
824 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | ||
825 | SNDRV_CTL_ELEM_ACCESS_INACTIVE, \ | ||
826 | .info = wm8776_field_enum_info, \ | ||
827 | .get = wm8776_field_enum_get, \ | ||
828 | .put = wm8776_field_enum_put, \ | ||
829 | } | ||
830 | #define WM8776_FIELD_CTL_VOLUME(a, b, c, d, e, f, g, h, tlv_p) { \ | ||
831 | _WM8776_FIELD_CTL(a " Capture Volume", b, c, d, e, f, g, h), \ | ||
832 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | ||
833 | SNDRV_CTL_ELEM_ACCESS_INACTIVE | \ | ||
834 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
835 | .info = wm8776_field_volume_info, \ | ||
836 | .get = wm8776_field_volume_get, \ | ||
837 | .put = wm8776_field_volume_put, \ | ||
838 | .tlv = { .p = tlv_p }, \ | ||
839 | } | ||
840 | |||
841 | static const DECLARE_TLV_DB_SCALE(wm87x6_dac_db_scale, -6000, 50, 0); | ||
842 | static const DECLARE_TLV_DB_SCALE(wm8776_adc_db_scale, -2100, 50, 0); | ||
843 | static const DECLARE_TLV_DB_SCALE(wm8776_hp_db_scale, -6000, 100, 0); | ||
844 | static const DECLARE_TLV_DB_SCALE(wm8776_lct_db_scale, -1600, 100, 0); | ||
845 | static const DECLARE_TLV_DB_SCALE(wm8776_maxgain_db_scale, 0, 400, 0); | ||
846 | static const DECLARE_TLV_DB_SCALE(wm8776_ngth_db_scale, -7800, 600, 0); | ||
847 | static const DECLARE_TLV_DB_SCALE(wm8776_maxatten_lim_db_scale, -1200, 100, 0); | ||
848 | static const DECLARE_TLV_DB_SCALE(wm8776_maxatten_alc_db_scale, -2100, 400, 0); | ||
849 | |||
850 | static const struct snd_kcontrol_new ds_controls[] = { | ||
851 | { | ||
852 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
853 | .name = "Headphone Playback Volume", | ||
854 | .info = wm8776_hp_vol_info, | ||
855 | .get = wm8776_hp_vol_get, | ||
856 | .put = wm8776_hp_vol_put, | ||
857 | .tlv = { .p = wm8776_hp_db_scale }, | ||
858 | }, | ||
859 | WM8776_BIT_SWITCH("Headphone Playback Switch", | ||
860 | WM8776_PWRDOWN, WM8776_HPPD, 1, 0), | ||
861 | { | ||
862 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
863 | .name = "Input Capture Volume", | ||
864 | .info = wm8776_input_vol_info, | ||
865 | .get = wm8776_input_vol_get, | ||
866 | .put = wm8776_input_vol_put, | ||
867 | .tlv = { .p = wm8776_adc_db_scale }, | ||
868 | }, | ||
869 | { | ||
870 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
871 | .name = "Line Capture Switch", | ||
872 | .info = snd_ctl_boolean_mono_info, | ||
873 | .get = wm8776_input_mux_get, | ||
874 | .put = wm8776_input_mux_put, | ||
875 | .private_value = 1 << 0, | ||
876 | }, | ||
877 | { | ||
878 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
879 | .name = "Mic Capture Switch", | ||
880 | .info = snd_ctl_boolean_mono_info, | ||
881 | .get = wm8776_input_mux_get, | ||
882 | .put = wm8776_input_mux_put, | ||
883 | .private_value = 1 << 1, | ||
884 | }, | ||
885 | WM8776_BIT_SWITCH("Aux", WM8776_ADCMUX, 1 << 2, 0, 0), | ||
886 | { | ||
887 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
888 | .name = "ADC Filter Capture Enum", | ||
889 | .info = hpf_info, | ||
890 | .get = hpf_get, | ||
891 | .put = hpf_put, | ||
892 | }, | ||
893 | { | ||
894 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
895 | .name = "Level Control Capture Enum", | ||
896 | .info = wm8776_level_control_info, | ||
897 | .get = wm8776_level_control_get, | ||
898 | .put = wm8776_level_control_put, | ||
899 | .private_value = 0, | ||
900 | }, | ||
901 | }; | ||
902 | static const struct snd_kcontrol_new lc_controls[] = { | ||
903 | WM8776_FIELD_CTL_VOLUME("Limiter Threshold", | ||
904 | WM8776_ALCCTRL1, 0, 11, 0, 15, 0xf, | ||
905 | LC_CONTROL_LIMITER, wm8776_lct_db_scale), | ||
906 | WM8776_FIELD_CTL_ENUM("Limiter Attack Time", | ||
907 | WM8776_ALCCTRL3, 0, 2, 0, 10, 0xf, | ||
908 | LC_CONTROL_LIMITER), | ||
909 | WM8776_FIELD_CTL_ENUM("Limiter Decay Time", | ||
910 | WM8776_ALCCTRL3, 4, 3, 0, 10, 0xf, | ||
911 | LC_CONTROL_LIMITER), | ||
912 | WM8776_FIELD_CTL_ENUM("Limiter Transient Window", | ||
913 | WM8776_LIMITER, 4, 2, 0, 7, 0x7, | ||
914 | LC_CONTROL_LIMITER), | ||
915 | WM8776_FIELD_CTL_VOLUME("Limiter Maximum Attenuation", | ||
916 | WM8776_LIMITER, 0, 6, 3, 12, 0xf, | ||
917 | LC_CONTROL_LIMITER, | ||
918 | wm8776_maxatten_lim_db_scale), | ||
919 | WM8776_FIELD_CTL_VOLUME("ALC Target Level", | ||
920 | WM8776_ALCCTRL1, 0, 11, 0, 15, 0xf, | ||
921 | LC_CONTROL_ALC, wm8776_lct_db_scale), | ||
922 | WM8776_FIELD_CTL_ENUM("ALC Attack Time", | ||
923 | WM8776_ALCCTRL3, 0, 2, 0, 10, 0xf, | ||
924 | LC_CONTROL_ALC), | ||
925 | WM8776_FIELD_CTL_ENUM("ALC Decay Time", | ||
926 | WM8776_ALCCTRL3, 4, 3, 0, 10, 0xf, | ||
927 | LC_CONTROL_ALC), | ||
928 | WM8776_FIELD_CTL_VOLUME("ALC Maximum Gain", | ||
929 | WM8776_ALCCTRL1, 4, 7, 1, 7, 0x7, | ||
930 | LC_CONTROL_ALC, wm8776_maxgain_db_scale), | ||
931 | WM8776_FIELD_CTL_VOLUME("ALC Maximum Attenuation", | ||
932 | WM8776_LIMITER, 0, 10, 10, 15, 0xf, | ||
933 | LC_CONTROL_ALC, wm8776_maxatten_alc_db_scale), | ||
934 | WM8776_FIELD_CTL_ENUM("ALC Hold Time", | ||
935 | WM8776_ALCCTRL2, 0, 0, 0, 15, 0xf, | ||
936 | LC_CONTROL_ALC), | ||
937 | WM8776_BIT_SWITCH("Noise Gate Capture Switch", | ||
938 | WM8776_NOISEGATE, WM8776_NGAT, 0, | ||
939 | LC_CONTROL_ALC), | ||
940 | WM8776_FIELD_CTL_VOLUME("Noise Gate Threshold", | ||
941 | WM8776_NOISEGATE, 2, 0, 0, 7, 0x7, | ||
942 | LC_CONTROL_ALC, wm8776_ngth_db_scale), | ||
943 | }; | ||
944 | |||
945 | static int xonar_ds_control_filter(struct snd_kcontrol_new *template) | ||
946 | { | ||
947 | if (!strncmp(template->name, "CD Capture ", 11)) | ||
948 | return 1; /* no CD input */ | ||
949 | return 0; | ||
950 | } | ||
951 | |||
952 | static int xonar_ds_mixer_init(struct oxygen *chip) | ||
953 | { | ||
954 | struct xonar_wm87x6 *data = chip->model_data; | ||
955 | unsigned int i; | ||
956 | struct snd_kcontrol *ctl; | ||
957 | int err; | ||
958 | |||
959 | for (i = 0; i < ARRAY_SIZE(ds_controls); ++i) { | ||
960 | ctl = snd_ctl_new1(&ds_controls[i], chip); | ||
961 | if (!ctl) | ||
962 | return -ENOMEM; | ||
963 | err = snd_ctl_add(chip->card, ctl); | ||
964 | if (err < 0) | ||
965 | return err; | ||
966 | } | ||
967 | BUILD_BUG_ON(ARRAY_SIZE(lc_controls) != ARRAY_SIZE(data->lc_controls)); | ||
968 | for (i = 0; i < ARRAY_SIZE(lc_controls); ++i) { | ||
969 | ctl = snd_ctl_new1(&lc_controls[i], chip); | ||
970 | if (!ctl) | ||
971 | return -ENOMEM; | ||
972 | err = snd_ctl_add(chip->card, ctl); | ||
973 | if (err < 0) | ||
974 | return err; | ||
975 | data->lc_controls[i] = ctl; | ||
976 | } | ||
977 | return 0; | ||
978 | } | ||
979 | |||
980 | static const struct oxygen_model model_xonar_ds = { | ||
981 | .shortname = "Xonar DS", | ||
982 | .longname = "Asus Virtuoso 200", | ||
983 | .chip = "AV200", | ||
984 | .init = xonar_ds_init, | ||
985 | .control_filter = xonar_ds_control_filter, | ||
986 | .mixer_init = xonar_ds_mixer_init, | ||
987 | .cleanup = xonar_ds_cleanup, | ||
988 | .suspend = xonar_ds_suspend, | ||
989 | .resume = xonar_ds_resume, | ||
990 | .pcm_hardware_filter = wm8776_adc_hardware_filter, | ||
991 | .get_i2s_mclk = oxygen_default_i2s_mclk, | ||
992 | .set_dac_params = set_wm87x6_dac_params, | ||
993 | .set_adc_params = set_wm8776_adc_params, | ||
994 | .update_dac_volume = update_wm87x6_volume, | ||
995 | .update_dac_mute = update_wm87x6_mute, | ||
996 | .gpio_changed = xonar_ds_gpio_changed, | ||
997 | .dac_tlv = wm87x6_dac_db_scale, | ||
998 | .model_data_size = sizeof(struct xonar_wm87x6), | ||
999 | .device_config = PLAYBACK_0_TO_I2S | | ||
1000 | PLAYBACK_1_TO_SPDIF | | ||
1001 | CAPTURE_0_FROM_I2S_1, | ||
1002 | .dac_channels = 8, | ||
1003 | .dac_volume_min = 255 - 2*60, | ||
1004 | .dac_volume_max = 255, | ||
1005 | .function_flags = OXYGEN_FUNCTION_SPI, | ||
1006 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1007 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
1008 | }; | ||
1009 | |||
1010 | int __devinit get_xonar_wm87x6_model(struct oxygen *chip, | ||
1011 | const struct pci_device_id *id) | ||
1012 | { | ||
1013 | switch (id->subdevice) { | ||
1014 | case 0x838e: | ||
1015 | chip->model = model_xonar_ds; | ||
1016 | break; | ||
1017 | default: | ||
1018 | return -EINVAL; | ||
1019 | } | ||
1020 | return 0; | ||
1021 | } | ||
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 833e9c7b27c7..95cfde27d25c 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c | |||
@@ -94,7 +94,7 @@ enum { | |||
94 | PCI_ID_LAST | 94 | PCI_ID_LAST |
95 | }; | 95 | }; |
96 | 96 | ||
97 | static struct pci_device_id pcxhr_ids[] = { | 97 | static DEFINE_PCI_DEVICE_TABLE(pcxhr_ids) = { |
98 | { 0x10b5, 0x9656, 0x1369, 0xb001, 0, 0, PCI_ID_VX882HR, }, | 98 | { 0x10b5, 0x9656, 0x1369, 0xb001, 0, 0, PCI_ID_VX882HR, }, |
99 | { 0x10b5, 0x9656, 0x1369, 0xb101, 0, 0, PCI_ID_PCX882HR, }, | 99 | { 0x10b5, 0x9656, 0x1369, 0xb101, 0, 0, PCI_ID_PCX882HR, }, |
100 | { 0x10b5, 0x9656, 0x1369, 0xb201, 0, 0, PCI_ID_VX881HR, }, | 100 | { 0x10b5, 0x9656, 0x1369, 0xb201, 0, 0, PCI_ID_VX881HR, }, |
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index e66ef2b69b5d..ad4462677615 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c | |||
@@ -506,7 +506,7 @@ static int riptide_reset(struct cmdif *cif, struct snd_riptide *chip); | |||
506 | /* | 506 | /* |
507 | */ | 507 | */ |
508 | 508 | ||
509 | static struct pci_device_id snd_riptide_ids[] = { | 509 | static DEFINE_PCI_DEVICE_TABLE(snd_riptide_ids) = { |
510 | { PCI_DEVICE(0x127a, 0x4310) }, | 510 | { PCI_DEVICE(0x127a, 0x4310) }, |
511 | { PCI_DEVICE(0x127a, 0x4320) }, | 511 | { PCI_DEVICE(0x127a, 0x4320) }, |
512 | { PCI_DEVICE(0x127a, 0x4330) }, | 512 | { PCI_DEVICE(0x127a, 0x4330) }, |
@@ -515,7 +515,7 @@ static struct pci_device_id snd_riptide_ids[] = { | |||
515 | }; | 515 | }; |
516 | 516 | ||
517 | #ifdef SUPPORT_JOYSTICK | 517 | #ifdef SUPPORT_JOYSTICK |
518 | static struct pci_device_id snd_riptide_joystick_ids[] __devinitdata = { | 518 | static DEFINE_PCI_DEVICE_TABLE(snd_riptide_joystick_ids) = { |
519 | { PCI_DEVICE(0x127a, 0x4312) }, | 519 | { PCI_DEVICE(0x127a, 0x4312) }, |
520 | { PCI_DEVICE(0x127a, 0x4322) }, | 520 | { PCI_DEVICE(0x127a, 0x4322) }, |
521 | { PCI_DEVICE(0x127a, 0x4332) }, | 521 | { PCI_DEVICE(0x127a, 0x4332) }, |
@@ -1974,9 +1974,9 @@ snd_riptide_proc_read(struct snd_info_entry *entry, | |||
1974 | } | 1974 | } |
1975 | snd_iprintf(buffer, "Paths:\n"); | 1975 | snd_iprintf(buffer, "Paths:\n"); |
1976 | i = getpaths(cif, p); | 1976 | i = getpaths(cif, p); |
1977 | while (i--) { | 1977 | while (i >= 2) { |
1978 | snd_iprintf(buffer, "%x->%x ", p[i - 1], p[i]); | 1978 | i -= 2; |
1979 | i--; | 1979 | snd_iprintf(buffer, "%x->%x ", p[i], p[i + 1]); |
1980 | } | 1980 | } |
1981 | snd_iprintf(buffer, "\n"); | 1981 | snd_iprintf(buffer, "\n"); |
1982 | } | 1982 | } |
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index f977dba7cbd0..d5e1c6eb7b7b 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c | |||
@@ -226,7 +226,7 @@ struct rme32 { | |||
226 | struct snd_kcontrol *spdif_ctl; | 226 | struct snd_kcontrol *spdif_ctl; |
227 | }; | 227 | }; |
228 | 228 | ||
229 | static struct pci_device_id snd_rme32_ids[] = { | 229 | static DEFINE_PCI_DEVICE_TABLE(snd_rme32_ids) = { |
230 | {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32), 0,}, | 230 | {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32), 0,}, |
231 | {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_8), 0,}, | 231 | {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_8), 0,}, |
232 | {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_PRO), 0,}, | 232 | {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_PRO), 0,}, |
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 2ba5c0fd55db..9d5252bc870c 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c | |||
@@ -231,7 +231,7 @@ struct rme96 { | |||
231 | struct snd_kcontrol *spdif_ctl; | 231 | struct snd_kcontrol *spdif_ctl; |
232 | }; | 232 | }; |
233 | 233 | ||
234 | static struct pci_device_id snd_rme96_ids[] = { | 234 | static DEFINE_PCI_DEVICE_TABLE(snd_rme96_ids) = { |
235 | { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96), 0, }, | 235 | { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96), 0, }, |
236 | { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8), 0, }, | 236 | { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8), 0, }, |
237 | { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PRO), 0, }, | 237 | { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PRO), 0, }, |
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 7bb827c7d806..52c6eb57cc3f 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c | |||
@@ -585,7 +585,7 @@ static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_d | |||
585 | } | 585 | } |
586 | 586 | ||
587 | 587 | ||
588 | static struct pci_device_id snd_hdsp_ids[] = { | 588 | static DEFINE_PCI_DEVICE_TABLE(snd_hdsp_ids) = { |
589 | { | 589 | { |
590 | .vendor = PCI_VENDOR_ID_XILINX, | 590 | .vendor = PCI_VENDOR_ID_XILINX, |
591 | .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP, | 591 | .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP, |
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index a1b10d1a384d..3d72c1effeef 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c | |||
@@ -512,7 +512,7 @@ static char channel_map_madi_ss[HDSPM_MAX_CHANNELS] = { | |||
512 | }; | 512 | }; |
513 | 513 | ||
514 | 514 | ||
515 | static struct pci_device_id snd_hdspm_ids[] __devinitdata = { | 515 | static DEFINE_PCI_DEVICE_TABLE(snd_hdspm_ids) = { |
516 | { | 516 | { |
517 | .vendor = PCI_VENDOR_ID_XILINX, | 517 | .vendor = PCI_VENDOR_ID_XILINX, |
518 | .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI, | 518 | .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI, |
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index bc539abb2105..44a3e2d8c556 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c | |||
@@ -314,7 +314,7 @@ static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_d | |||
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | static struct pci_device_id snd_rme9652_ids[] = { | 317 | static DEFINE_PCI_DEVICE_TABLE(snd_rme9652_ids) = { |
318 | { | 318 | { |
319 | .vendor = 0x10ee, | 319 | .vendor = 0x10ee, |
320 | .device = 0x3fc4, | 320 | .device = 0x3fc4, |
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 1a5ff0611072..7e3e8fbc90fe 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c | |||
@@ -48,7 +48,7 @@ MODULE_PARM_DESC(id, "ID string for SiS7019 Audio Accelerator."); | |||
48 | module_param(enable, bool, 0444); | 48 | module_param(enable, bool, 0444); |
49 | MODULE_PARM_DESC(enable, "Enable SiS7019 Audio Accelerator."); | 49 | MODULE_PARM_DESC(enable, "Enable SiS7019 Audio Accelerator."); |
50 | 50 | ||
51 | static struct pci_device_id snd_sis7019_ids[] = { | 51 | static DEFINE_PCI_DEVICE_TABLE(snd_sis7019_ids) = { |
52 | { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x7019) }, | 52 | { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x7019) }, |
53 | { 0, } | 53 | { 0, } |
54 | }; | 54 | }; |
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 1f6406c4534d..337b9facadfd 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c | |||
@@ -242,7 +242,7 @@ struct sonicvibes { | |||
242 | #endif | 242 | #endif |
243 | }; | 243 | }; |
244 | 244 | ||
245 | static struct pci_device_id snd_sonic_ids[] = { | 245 | static DEFINE_PCI_DEVICE_TABLE(snd_sonic_ids) = { |
246 | { PCI_VDEVICE(S3, 0xca00), 0, }, | 246 | { PCI_VDEVICE(S3, 0xca00), 0, }, |
247 | { 0, } | 247 | { 0, } |
248 | }; | 248 | }; |
diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c index 21cef97d478d..6d0581841d7a 100644 --- a/sound/pci/trident/trident.c +++ b/sound/pci/trident/trident.c | |||
@@ -62,7 +62,7 @@ MODULE_PARM_DESC(pcm_channels, "Number of hardware channels assigned for PCM."); | |||
62 | module_param_array(wavetable_size, int, NULL, 0444); | 62 | module_param_array(wavetable_size, int, NULL, 0444); |
63 | MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth."); | 63 | MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth."); |
64 | 64 | ||
65 | static struct pci_device_id snd_trident_ids[] = { | 65 | static DEFINE_PCI_DEVICE_TABLE(snd_trident_ids) = { |
66 | {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX), | 66 | {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX), |
67 | PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, | 67 | PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, |
68 | {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_NX), | 68 | {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_NX), |
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 8a332d2f615c..7e494b6a1d0e 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c | |||
@@ -401,7 +401,7 @@ struct via82xx { | |||
401 | #endif | 401 | #endif |
402 | }; | 402 | }; |
403 | 403 | ||
404 | static struct pci_device_id snd_via82xx_ids[] = { | 404 | static DEFINE_PCI_DEVICE_TABLE(snd_via82xx_ids) = { |
405 | /* 0x1106, 0x3058 */ | 405 | /* 0x1106, 0x3058 */ |
406 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C686_5), TYPE_CARD_VIA686, }, /* 686A */ | 406 | { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C686_5), TYPE_CARD_VIA686, }, /* 686A */ |
407 | /* 0x1106, 0x3059 */ | 407 | /* 0x1106, 0x3059 */ |
@@ -1791,6 +1791,12 @@ static struct ac97_quirk ac97_quirks[] = { | |||
1791 | .type = AC97_TUNE_HP_ONLY | 1791 | .type = AC97_TUNE_HP_ONLY |
1792 | }, | 1792 | }, |
1793 | { | 1793 | { |
1794 | .subvendor = 0x110a, | ||
1795 | .subdevice = 0x0079, | ||
1796 | .name = "Fujitsu Siemens D1289", | ||
1797 | .type = AC97_TUNE_HP_ONLY | ||
1798 | }, | ||
1799 | { | ||
1794 | .subvendor = 0x1019, | 1800 | .subvendor = 0x1019, |
1795 | .subdevice = 0x0a81, | 1801 | .subdevice = 0x0a81, |
1796 | .name = "ECS K7VTA3", | 1802 | .name = "ECS K7VTA3", |
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 47eb61561dfc..f7e8bbbe3953 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c | |||
@@ -260,7 +260,7 @@ struct via82xx_modem { | |||
260 | struct snd_info_entry *proc_entry; | 260 | struct snd_info_entry *proc_entry; |
261 | }; | 261 | }; |
262 | 262 | ||
263 | static struct pci_device_id snd_via82xx_modem_ids[] = { | 263 | static DEFINE_PCI_DEVICE_TABLE(snd_via82xx_modem_ids) = { |
264 | { PCI_VDEVICE(VIA, 0x3068), TYPE_CARD_VIA82XX_MODEM, }, | 264 | { PCI_VDEVICE(VIA, 0x3068), TYPE_CARD_VIA82XX_MODEM, }, |
265 | { 0, } | 265 | { 0, } |
266 | }; | 266 | }; |
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index fc9136c3e0d7..99a9a814be0b 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c | |||
@@ -60,7 +60,7 @@ enum { | |||
60 | VX_PCI_VX222_NEW | 60 | VX_PCI_VX222_NEW |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static struct pci_device_id snd_vx222_ids[] = { | 63 | static DEFINE_PCI_DEVICE_TABLE(snd_vx222_ids) = { |
64 | { 0x10b5, 0x9050, 0x1369, PCI_ANY_ID, 0, 0, VX_PCI_VX222_OLD, }, /* PLX */ | 64 | { 0x10b5, 0x9050, 0x1369, PCI_ANY_ID, 0, 0, VX_PCI_VX222_OLD, }, /* PLX */ |
65 | { 0x10b5, 0x9030, 0x1369, PCI_ANY_ID, 0, 0, VX_PCI_VX222_NEW, }, /* PLX */ | 65 | { 0x10b5, 0x9030, 0x1369, PCI_ANY_ID, 0, 0, VX_PCI_VX222_NEW, }, /* PLX */ |
66 | { 0, } | 66 | { 0, } |
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index e6b18b90d451..80c682113381 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c | |||
@@ -66,7 +66,7 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address"); | |||
66 | module_param_array(rear_switch, bool, NULL, 0444); | 66 | 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 DEFINE_PCI_DEVICE_TABLE(snd_ymfpci_ids) = { |
70 | { PCI_VDEVICE(YAMAHA, 0x0004), 0, }, /* YMF724 */ | 70 | { PCI_VDEVICE(YAMAHA, 0x0004), 0, }, /* YMF724 */ |
71 | { PCI_VDEVICE(YAMAHA, 0x000d), 0, }, /* YMF724F */ | 71 | { PCI_VDEVICE(YAMAHA, 0x000d), 0, }, /* YMF724F */ |
72 | { PCI_VDEVICE(YAMAHA, 0x000a), 0, }, /* YMF740 */ | 72 | { PCI_VDEVICE(YAMAHA, 0x000a), 0, }, /* YMF740 */ |
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index 5cfa608823f7..0d668f471620 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | |||
@@ -21,7 +21,6 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/vmalloc.h> | ||
25 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
26 | #include <sound/core.h> | 25 | #include <sound/core.h> |
27 | #include <sound/asoundef.h> | 26 | #include <sound/asoundef.h> |
@@ -29,49 +28,6 @@ | |||
29 | 28 | ||
30 | 29 | ||
31 | /* | 30 | /* |
32 | * we use a vmalloc'ed (sg-)buffer | ||
33 | */ | ||
34 | |||
35 | /* get the physical page pointer on the given offset */ | ||
36 | static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, unsigned long offset) | ||
37 | { | ||
38 | void *pageptr = subs->runtime->dma_area + offset; | ||
39 | return vmalloc_to_page(pageptr); | ||
40 | } | ||
41 | |||
42 | /* | ||
43 | * hw_params callback | ||
44 | * NOTE: this may be called not only once per pcm open! | ||
45 | */ | ||
46 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) | ||
47 | { | ||
48 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
49 | if (runtime->dma_area) { | ||
50 | if (runtime->dma_bytes >= size) | ||
51 | return 0; /* already enough large */ | ||
52 | vfree(runtime->dma_area); | ||
53 | } | ||
54 | runtime->dma_area = vmalloc_32_user(size); | ||
55 | if (! runtime->dma_area) | ||
56 | return -ENOMEM; | ||
57 | runtime->dma_bytes = size; | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | /* | ||
62 | * hw_free callback | ||
63 | * NOTE: this may be called not only once per pcm open! | ||
64 | */ | ||
65 | static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) | ||
66 | { | ||
67 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
68 | |||
69 | vfree(runtime->dma_area); | ||
70 | runtime->dma_area = NULL; | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | /* | ||
75 | * clear the SRAM contents | 31 | * clear the SRAM contents |
76 | */ | 32 | */ |
77 | static int pdacf_pcm_clear_sram(struct snd_pdacf *chip) | 33 | static int pdacf_pcm_clear_sram(struct snd_pdacf *chip) |
@@ -147,7 +103,8 @@ static int pdacf_pcm_trigger(struct snd_pcm_substream *subs, int cmd) | |||
147 | static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs, | 103 | static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs, |
148 | struct snd_pcm_hw_params *hw_params) | 104 | struct snd_pcm_hw_params *hw_params) |
149 | { | 105 | { |
150 | return snd_pcm_alloc_vmalloc_buffer(subs, params_buffer_bytes(hw_params)); | 106 | return snd_pcm_lib_alloc_vmalloc_32_buffer |
107 | (subs, params_buffer_bytes(hw_params)); | ||
151 | } | 108 | } |
152 | 109 | ||
153 | /* | 110 | /* |
@@ -155,7 +112,7 @@ static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs, | |||
155 | */ | 112 | */ |
156 | static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs) | 113 | static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs) |
157 | { | 114 | { |
158 | return snd_pcm_free_vmalloc_buffer(subs); | 115 | return snd_pcm_lib_free_vmalloc_buffer(subs); |
159 | } | 116 | } |
160 | 117 | ||
161 | /* | 118 | /* |
@@ -319,7 +276,8 @@ static struct snd_pcm_ops pdacf_pcm_capture_ops = { | |||
319 | .prepare = pdacf_pcm_prepare, | 276 | .prepare = pdacf_pcm_prepare, |
320 | .trigger = pdacf_pcm_trigger, | 277 | .trigger = pdacf_pcm_trigger, |
321 | .pointer = pdacf_pcm_capture_pointer, | 278 | .pointer = pdacf_pcm_capture_pointer, |
322 | .page = snd_pcm_get_vmalloc_page, | 279 | .page = snd_pcm_lib_get_vmalloc_page, |
280 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
323 | }; | 281 | }; |
324 | 282 | ||
325 | 283 | ||
diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c index 2e156467b814..b36679384b27 100644 --- a/sound/ppc/awacs.c +++ b/sound/ppc/awacs.c | |||
@@ -751,8 +751,8 @@ static void snd_pmac_awacs_suspend(struct snd_pmac *chip) | |||
751 | 751 | ||
752 | static void snd_pmac_awacs_resume(struct snd_pmac *chip) | 752 | static void snd_pmac_awacs_resume(struct snd_pmac *chip) |
753 | { | 753 | { |
754 | if (machine_is_compatible("PowerBook3,1") | 754 | if (of_machine_is_compatible("PowerBook3,1") |
755 | || machine_is_compatible("PowerBook3,2")) { | 755 | || of_machine_is_compatible("PowerBook3,2")) { |
756 | msleep(100); | 756 | msleep(100); |
757 | snd_pmac_awacs_write_reg(chip, 1, | 757 | snd_pmac_awacs_write_reg(chip, 1, |
758 | chip->awacs_reg[1] & ~MASK_PAROUT); | 758 | chip->awacs_reg[1] & ~MASK_PAROUT); |
@@ -780,16 +780,16 @@ static void snd_pmac_awacs_resume(struct snd_pmac *chip) | |||
780 | } | 780 | } |
781 | #endif /* CONFIG_PM */ | 781 | #endif /* CONFIG_PM */ |
782 | 782 | ||
783 | #define IS_PM7500 (machine_is_compatible("AAPL,7500") \ | 783 | #define IS_PM7500 (of_machine_is_compatible("AAPL,7500") \ |
784 | || machine_is_compatible("AAPL,8500") \ | 784 | || of_machine_is_compatible("AAPL,8500") \ |
785 | || machine_is_compatible("AAPL,9500")) | 785 | || of_machine_is_compatible("AAPL,9500")) |
786 | #define IS_PM5500 (machine_is_compatible("AAPL,e411")) | 786 | #define IS_PM5500 (of_machine_is_compatible("AAPL,e411")) |
787 | #define IS_BEIGE (machine_is_compatible("AAPL,Gossamer")) | 787 | #define IS_BEIGE (of_machine_is_compatible("AAPL,Gossamer")) |
788 | #define IS_IMAC1 (machine_is_compatible("PowerMac2,1")) | 788 | #define IS_IMAC1 (of_machine_is_compatible("PowerMac2,1")) |
789 | #define IS_IMAC2 (machine_is_compatible("PowerMac2,2") \ | 789 | #define IS_IMAC2 (of_machine_is_compatible("PowerMac2,2") \ |
790 | || machine_is_compatible("PowerMac4,1")) | 790 | || of_machine_is_compatible("PowerMac4,1")) |
791 | #define IS_G4AGP (machine_is_compatible("PowerMac3,1")) | 791 | #define IS_G4AGP (of_machine_is_compatible("PowerMac3,1")) |
792 | #define IS_LOMBARD (machine_is_compatible("PowerBook1,1")) | 792 | #define IS_LOMBARD (of_machine_is_compatible("PowerBook1,1")) |
793 | 793 | ||
794 | static int imac1, imac2; | 794 | static int imac1, imac2; |
795 | 795 | ||
diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c index 0accfe49735b..1f72e1c786bf 100644 --- a/sound/ppc/burgundy.c +++ b/sound/ppc/burgundy.c | |||
@@ -582,7 +582,7 @@ static int snd_pmac_burgundy_detect_headphone(struct snd_pmac *chip) | |||
582 | static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify) | 582 | static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify) |
583 | { | 583 | { |
584 | if (chip->auto_mute) { | 584 | if (chip->auto_mute) { |
585 | int imac = machine_is_compatible("iMac"); | 585 | int imac = of_machine_is_compatible("iMac"); |
586 | int reg, oreg; | 586 | int reg, oreg; |
587 | reg = oreg = snd_pmac_burgundy_rcb(chip, | 587 | reg = oreg = snd_pmac_burgundy_rcb(chip, |
588 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); | 588 | MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); |
@@ -620,7 +620,7 @@ static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_noti | |||
620 | */ | 620 | */ |
621 | int __devinit snd_pmac_burgundy_init(struct snd_pmac *chip) | 621 | int __devinit snd_pmac_burgundy_init(struct snd_pmac *chip) |
622 | { | 622 | { |
623 | int imac = machine_is_compatible("iMac"); | 623 | int imac = of_machine_is_compatible("iMac"); |
624 | int i, err; | 624 | int i, err; |
625 | 625 | ||
626 | /* Checks to see the chip is alive and kicking */ | 626 | /* Checks to see the chip is alive and kicking */ |
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 7bc492ee77ec..85081172403f 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c | |||
@@ -922,11 +922,11 @@ static void __devinit detect_byte_swap(struct snd_pmac *chip) | |||
922 | } | 922 | } |
923 | 923 | ||
924 | /* it seems the Pismo & iBook can't byte-swap in hardware. */ | 924 | /* it seems the Pismo & iBook can't byte-swap in hardware. */ |
925 | if (machine_is_compatible("PowerBook3,1") || | 925 | if (of_machine_is_compatible("PowerBook3,1") || |
926 | machine_is_compatible("PowerBook2,1")) | 926 | of_machine_is_compatible("PowerBook2,1")) |
927 | chip->can_byte_swap = 0 ; | 927 | chip->can_byte_swap = 0 ; |
928 | 928 | ||
929 | if (machine_is_compatible("PowerBook2,1")) | 929 | if (of_machine_is_compatible("PowerBook2,1")) |
930 | chip->can_duplex = 0; | 930 | chip->can_duplex = 0; |
931 | } | 931 | } |
932 | 932 | ||
@@ -959,11 +959,11 @@ static int __devinit snd_pmac_detect(struct snd_pmac *chip) | |||
959 | chip->control_mask = MASK_IEPC | MASK_IEE | 0x11; /* default */ | 959 | chip->control_mask = MASK_IEPC | MASK_IEE | 0x11; /* default */ |
960 | 960 | ||
961 | /* check machine type */ | 961 | /* check machine type */ |
962 | if (machine_is_compatible("AAPL,3400/2400") | 962 | if (of_machine_is_compatible("AAPL,3400/2400") |
963 | || machine_is_compatible("AAPL,3500")) | 963 | || of_machine_is_compatible("AAPL,3500")) |
964 | chip->is_pbook_3400 = 1; | 964 | chip->is_pbook_3400 = 1; |
965 | else if (machine_is_compatible("PowerBook1,1") | 965 | else if (of_machine_is_compatible("PowerBook1,1") |
966 | || machine_is_compatible("AAPL,PowerBook1998")) | 966 | || of_machine_is_compatible("AAPL,PowerBook1998")) |
967 | chip->is_pbook_G3 = 1; | 967 | chip->is_pbook_G3 = 1; |
968 | chip->node = of_find_node_by_name(NULL, "awacs"); | 968 | chip->node = of_find_node_by_name(NULL, "awacs"); |
969 | sound = of_node_get(chip->node); | 969 | sound = of_node_get(chip->node); |
@@ -1033,8 +1033,8 @@ static int __devinit snd_pmac_detect(struct snd_pmac *chip) | |||
1033 | } | 1033 | } |
1034 | if (of_device_is_compatible(sound, "tumbler")) { | 1034 | if (of_device_is_compatible(sound, "tumbler")) { |
1035 | chip->model = PMAC_TUMBLER; | 1035 | chip->model = PMAC_TUMBLER; |
1036 | chip->can_capture = machine_is_compatible("PowerMac4,2") | 1036 | chip->can_capture = of_machine_is_compatible("PowerMac4,2") |
1037 | || machine_is_compatible("PowerBook4,1"); | 1037 | || of_machine_is_compatible("PowerBook4,1"); |
1038 | chip->can_duplex = 0; | 1038 | chip->can_duplex = 0; |
1039 | // chip->can_byte_swap = 0; /* FIXME: check this */ | 1039 | // chip->can_byte_swap = 0; /* FIXME: check this */ |
1040 | chip->num_freqs = ARRAY_SIZE(tumbler_freqs); | 1040 | chip->num_freqs = ARRAY_SIZE(tumbler_freqs); |
diff --git a/sound/soc/au1x/Kconfig b/sound/soc/au1x/Kconfig index 410a893aa66b..4b67140fdec3 100644 --- a/sound/soc/au1x/Kconfig +++ b/sound/soc/au1x/Kconfig | |||
@@ -22,11 +22,13 @@ config SND_SOC_AU1XPSC_AC97 | |||
22 | ## | 22 | ## |
23 | ## Boards | 23 | ## Boards |
24 | ## | 24 | ## |
25 | config SND_SOC_SAMPLE_PSC_AC97 | 25 | config SND_SOC_DB1200 |
26 | tristate "Sample Au12x0/Au1550 PSC AC97 sound machine" | 26 | tristate "DB1200 AC97+I2S audio support" |
27 | depends on SND_SOC_AU1XPSC | 27 | depends on SND_SOC_AU1XPSC |
28 | select SND_SOC_AU1XPSC_AC97 | 28 | select SND_SOC_AU1XPSC_AC97 |
29 | select SND_SOC_AC97_CODEC | 29 | select SND_SOC_AC97_CODEC |
30 | select SND_SOC_AU1XPSC_I2S | ||
31 | select SND_SOC_WM8731 | ||
30 | help | 32 | help |
31 | This is a sample AC97 sound machine for use in Au12x0/Au1550 | 33 | Select this option to enable audio (AC97 or I2S) on the |
32 | based systems which have audio on PSC1 (e.g. Db1200 demoboard). | 34 | Alchemy/AMD/RMI DB1200 demoboard. |
diff --git a/sound/soc/au1x/Makefile b/sound/soc/au1x/Makefile index 6c6950b8003a..16873076e8c4 100644 --- a/sound/soc/au1x/Makefile +++ b/sound/soc/au1x/Makefile | |||
@@ -8,6 +8,6 @@ obj-$(CONFIG_SND_SOC_AU1XPSC_I2S) += snd-soc-au1xpsc-i2s.o | |||
8 | obj-$(CONFIG_SND_SOC_AU1XPSC_AC97) += snd-soc-au1xpsc-ac97.o | 8 | obj-$(CONFIG_SND_SOC_AU1XPSC_AC97) += snd-soc-au1xpsc-ac97.o |
9 | 9 | ||
10 | # Boards | 10 | # Boards |
11 | snd-soc-sample-ac97-objs := sample-ac97.o | 11 | snd-soc-db1200-objs := db1200.o |
12 | 12 | ||
13 | obj-$(CONFIG_SND_SOC_SAMPLE_PSC_AC97) += snd-soc-sample-ac97.o | 13 | obj-$(CONFIG_SND_SOC_DB1200) += snd-soc-db1200.o |
diff --git a/sound/soc/au1x/db1200.c b/sound/soc/au1x/db1200.c new file mode 100644 index 000000000000..cdf7be1b9b91 --- /dev/null +++ b/sound/soc/au1x/db1200.c | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | * DB1200 ASoC audio fabric support code. | ||
3 | * | ||
4 | * (c) 2008-9 Manuel Lauss <manuel.lauss@gmail.com> | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | #include <linux/module.h> | ||
9 | #include <linux/moduleparam.h> | ||
10 | #include <linux/timer.h> | ||
11 | #include <linux/interrupt.h> | ||
12 | #include <linux/platform_device.h> | ||
13 | #include <sound/core.h> | ||
14 | #include <sound/pcm.h> | ||
15 | #include <sound/soc.h> | ||
16 | #include <sound/soc-dapm.h> | ||
17 | #include <asm/mach-au1x00/au1000.h> | ||
18 | #include <asm/mach-au1x00/au1xxx_psc.h> | ||
19 | #include <asm/mach-au1x00/au1xxx_dbdma.h> | ||
20 | #include <asm/mach-db1x00/bcsr.h> | ||
21 | |||
22 | #include "../codecs/ac97.h" | ||
23 | #include "../codecs/wm8731.h" | ||
24 | #include "psc.h" | ||
25 | |||
26 | /*------------------------- AC97 PART ---------------------------*/ | ||
27 | |||
28 | static struct snd_soc_dai_link db1200_ac97_dai = { | ||
29 | .name = "AC97", | ||
30 | .stream_name = "AC97 HiFi", | ||
31 | .cpu_dai = &au1xpsc_ac97_dai, | ||
32 | .codec_dai = &ac97_dai, | ||
33 | }; | ||
34 | |||
35 | static struct snd_soc_card db1200_ac97_machine = { | ||
36 | .name = "DB1200_AC97", | ||
37 | .dai_link = &db1200_ac97_dai, | ||
38 | .num_links = 1, | ||
39 | .platform = &au1xpsc_soc_platform, | ||
40 | }; | ||
41 | |||
42 | static struct snd_soc_device db1200_ac97_devdata = { | ||
43 | .card = &db1200_ac97_machine, | ||
44 | .codec_dev = &soc_codec_dev_ac97, | ||
45 | }; | ||
46 | |||
47 | /*------------------------- I2S PART ---------------------------*/ | ||
48 | |||
49 | static int db1200_i2s_startup(struct snd_pcm_substream *substream) | ||
50 | { | ||
51 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
52 | struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; | ||
53 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
54 | int ret; | ||
55 | |||
56 | /* WM8731 has its own 12MHz crystal */ | ||
57 | snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK, | ||
58 | 12000000, SND_SOC_CLOCK_IN); | ||
59 | |||
60 | /* codec is bitclock and lrclk master */ | ||
61 | ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J | | ||
62 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); | ||
63 | if (ret < 0) | ||
64 | goto out; | ||
65 | |||
66 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J | | ||
67 | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); | ||
68 | if (ret < 0) | ||
69 | goto out; | ||
70 | |||
71 | ret = 0; | ||
72 | out: | ||
73 | return ret; | ||
74 | } | ||
75 | |||
76 | static struct snd_soc_ops db1200_i2s_wm8731_ops = { | ||
77 | .startup = db1200_i2s_startup, | ||
78 | }; | ||
79 | |||
80 | static struct snd_soc_dai_link db1200_i2s_dai = { | ||
81 | .name = "WM8731", | ||
82 | .stream_name = "WM8731 PCM", | ||
83 | .cpu_dai = &au1xpsc_i2s_dai, | ||
84 | .codec_dai = &wm8731_dai, | ||
85 | .ops = &db1200_i2s_wm8731_ops, | ||
86 | }; | ||
87 | |||
88 | static struct snd_soc_card db1200_i2s_machine = { | ||
89 | .name = "DB1200_I2S", | ||
90 | .dai_link = &db1200_i2s_dai, | ||
91 | .num_links = 1, | ||
92 | .platform = &au1xpsc_soc_platform, | ||
93 | }; | ||
94 | |||
95 | static struct snd_soc_device db1200_i2s_devdata = { | ||
96 | .card = &db1200_i2s_machine, | ||
97 | .codec_dev = &soc_codec_dev_wm8731, | ||
98 | }; | ||
99 | |||
100 | /*------------------------- COMMON PART ---------------------------*/ | ||
101 | |||
102 | static struct platform_device *db1200_asoc_dev; | ||
103 | |||
104 | static int __init db1200_audio_load(void) | ||
105 | { | ||
106 | int ret; | ||
107 | |||
108 | ret = -ENOMEM; | ||
109 | db1200_asoc_dev = platform_device_alloc("soc-audio", -1); | ||
110 | if (!db1200_asoc_dev) | ||
111 | goto out; | ||
112 | |||
113 | /* DB1200 board setup set PSC1MUX to preferred audio device */ | ||
114 | if (bcsr_read(BCSR_RESETS) & BCSR_RESETS_PSC1MUX) | ||
115 | platform_set_drvdata(db1200_asoc_dev, &db1200_i2s_devdata); | ||
116 | else | ||
117 | platform_set_drvdata(db1200_asoc_dev, &db1200_ac97_devdata); | ||
118 | |||
119 | db1200_ac97_devdata.dev = &db1200_asoc_dev->dev; | ||
120 | db1200_i2s_devdata.dev = &db1200_asoc_dev->dev; | ||
121 | ret = platform_device_add(db1200_asoc_dev); | ||
122 | |||
123 | if (ret) { | ||
124 | platform_device_put(db1200_asoc_dev); | ||
125 | db1200_asoc_dev = NULL; | ||
126 | } | ||
127 | out: | ||
128 | return ret; | ||
129 | } | ||
130 | |||
131 | static void __exit db1200_audio_unload(void) | ||
132 | { | ||
133 | platform_device_unregister(db1200_asoc_dev); | ||
134 | } | ||
135 | |||
136 | module_init(db1200_audio_load); | ||
137 | module_exit(db1200_audio_unload); | ||
138 | |||
139 | MODULE_LICENSE("GPL"); | ||
140 | MODULE_DESCRIPTION("DB1200 ASoC audio support"); | ||
141 | MODULE_AUTHOR("Manuel Lauss"); | ||
diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index 19e4d37eba1c..6d9f4c624949 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c | |||
@@ -51,8 +51,8 @@ struct au1xpsc_audio_dmadata { | |||
51 | struct snd_pcm_substream *substream; | 51 | struct snd_pcm_substream *substream; |
52 | unsigned long curr_period; /* current segment DDMA is working on */ | 52 | unsigned long curr_period; /* current segment DDMA is working on */ |
53 | unsigned long q_period; /* queue period(s) */ | 53 | unsigned long q_period; /* queue period(s) */ |
54 | unsigned long dma_area; /* address of queued DMA area */ | 54 | dma_addr_t dma_area; /* address of queued DMA area */ |
55 | unsigned long dma_area_s; /* start address of DMA area */ | 55 | dma_addr_t dma_area_s; /* start address of DMA area */ |
56 | unsigned long pos; /* current byte position being played */ | 56 | unsigned long pos; /* current byte position being played */ |
57 | unsigned long periods; /* number of SG segments in total */ | 57 | unsigned long periods; /* number of SG segments in total */ |
58 | unsigned long period_bytes; /* size in bytes of one SG segment */ | 58 | unsigned long period_bytes; /* size in bytes of one SG segment */ |
@@ -94,8 +94,7 @@ static const struct snd_pcm_hardware au1xpsc_pcm_hardware = { | |||
94 | 94 | ||
95 | static void au1x_pcm_queue_tx(struct au1xpsc_audio_dmadata *cd) | 95 | static void au1x_pcm_queue_tx(struct au1xpsc_audio_dmadata *cd) |
96 | { | 96 | { |
97 | au1xxx_dbdma_put_source_flags(cd->ddma_chan, | 97 | au1xxx_dbdma_put_source(cd->ddma_chan, cd->dma_area, |
98 | (void *)phys_to_virt(cd->dma_area), | ||
99 | cd->period_bytes, DDMA_FLAGS_IE); | 98 | cd->period_bytes, DDMA_FLAGS_IE); |
100 | 99 | ||
101 | /* update next-to-queue period */ | 100 | /* update next-to-queue period */ |
@@ -109,9 +108,8 @@ static void au1x_pcm_queue_tx(struct au1xpsc_audio_dmadata *cd) | |||
109 | 108 | ||
110 | static void au1x_pcm_queue_rx(struct au1xpsc_audio_dmadata *cd) | 109 | static void au1x_pcm_queue_rx(struct au1xpsc_audio_dmadata *cd) |
111 | { | 110 | { |
112 | au1xxx_dbdma_put_dest_flags(cd->ddma_chan, | 111 | au1xxx_dbdma_put_dest(cd->ddma_chan, cd->dma_area, |
113 | (void *)phys_to_virt(cd->dma_area), | 112 | cd->period_bytes, DDMA_FLAGS_IE); |
114 | cd->period_bytes, DDMA_FLAGS_IE); | ||
115 | 113 | ||
116 | /* update next-to-queue period */ | 114 | /* update next-to-queue period */ |
117 | ++cd->q_period; | 115 | ++cd->q_period; |
@@ -233,7 +231,7 @@ static int au1xpsc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
233 | pcd->substream = substream; | 231 | pcd->substream = substream; |
234 | pcd->period_bytes = params_period_bytes(params); | 232 | pcd->period_bytes = params_period_bytes(params); |
235 | pcd->periods = params_periods(params); | 233 | pcd->periods = params_periods(params); |
236 | pcd->dma_area_s = pcd->dma_area = (unsigned long)runtime->dma_addr; | 234 | pcd->dma_area_s = pcd->dma_area = runtime->dma_addr; |
237 | pcd->q_period = 0; | 235 | pcd->q_period = 0; |
238 | pcd->curr_period = 0; | 236 | pcd->curr_period = 0; |
239 | pcd->pos = 0; | 237 | pcd->pos = 0; |
diff --git a/sound/soc/au1x/sample-ac97.c b/sound/soc/au1x/sample-ac97.c deleted file mode 100644 index 27683eb7905e..000000000000 --- a/sound/soc/au1x/sample-ac97.c +++ /dev/null | |||
@@ -1,144 +0,0 @@ | |||
1 | /* | ||
2 | * Sample Au12x0/Au1550 PSC AC97 sound machine. | ||
3 | * | ||
4 | * Copyright (c) 2007-2008 Manuel Lauss <mano@roarinelk.homelinux.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms outlined in the file COPYING at the root of this | ||
8 | * source archive. | ||
9 | * | ||
10 | * This is a very generic AC97 sound machine driver for boards which | ||
11 | * have (AC97) audio at PSC1 (e.g. DB1200 demoboards). | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/moduleparam.h> | ||
16 | #include <linux/timer.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <sound/core.h> | ||
20 | #include <sound/pcm.h> | ||
21 | #include <sound/soc.h> | ||
22 | #include <sound/soc-dapm.h> | ||
23 | #include <asm/mach-au1x00/au1000.h> | ||
24 | #include <asm/mach-au1x00/au1xxx_psc.h> | ||
25 | #include <asm/mach-au1x00/au1xxx_dbdma.h> | ||
26 | |||
27 | #include "../codecs/ac97.h" | ||
28 | #include "psc.h" | ||
29 | |||
30 | static int au1xpsc_sample_ac97_init(struct snd_soc_codec *codec) | ||
31 | { | ||
32 | snd_soc_dapm_sync(codec); | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | static struct snd_soc_dai_link au1xpsc_sample_ac97_dai = { | ||
37 | .name = "AC97", | ||
38 | .stream_name = "AC97 HiFi", | ||
39 | .cpu_dai = &au1xpsc_ac97_dai, /* see psc-ac97.c */ | ||
40 | .codec_dai = &ac97_dai, /* see codecs/ac97.c */ | ||
41 | .init = au1xpsc_sample_ac97_init, | ||
42 | .ops = NULL, | ||
43 | }; | ||
44 | |||
45 | static struct snd_soc_card au1xpsc_sample_ac97_machine = { | ||
46 | .name = "Au1xxx PSC AC97 Audio", | ||
47 | .dai_link = &au1xpsc_sample_ac97_dai, | ||
48 | .num_links = 1, | ||
49 | }; | ||
50 | |||
51 | static struct snd_soc_device au1xpsc_sample_ac97_devdata = { | ||
52 | .card = &au1xpsc_sample_ac97_machine, | ||
53 | .platform = &au1xpsc_soc_platform, /* see dbdma2.c */ | ||
54 | .codec_dev = &soc_codec_dev_ac97, | ||
55 | }; | ||
56 | |||
57 | static struct resource au1xpsc_psc1_res[] = { | ||
58 | [0] = { | ||
59 | .start = CPHYSADDR(PSC1_BASE_ADDR), | ||
60 | .end = CPHYSADDR(PSC1_BASE_ADDR) + 0x000fffff, | ||
61 | .flags = IORESOURCE_MEM, | ||
62 | }, | ||
63 | [1] = { | ||
64 | #ifdef CONFIG_SOC_AU1200 | ||
65 | .start = AU1200_PSC1_INT, | ||
66 | .end = AU1200_PSC1_INT, | ||
67 | #elif defined(CONFIG_SOC_AU1550) | ||
68 | .start = AU1550_PSC1_INT, | ||
69 | .end = AU1550_PSC1_INT, | ||
70 | #endif | ||
71 | .flags = IORESOURCE_IRQ, | ||
72 | }, | ||
73 | [2] = { | ||
74 | .start = DSCR_CMD0_PSC1_TX, | ||
75 | .end = DSCR_CMD0_PSC1_TX, | ||
76 | .flags = IORESOURCE_DMA, | ||
77 | }, | ||
78 | [3] = { | ||
79 | .start = DSCR_CMD0_PSC1_RX, | ||
80 | .end = DSCR_CMD0_PSC1_RX, | ||
81 | .flags = IORESOURCE_DMA, | ||
82 | }, | ||
83 | }; | ||
84 | |||
85 | static struct platform_device *au1xpsc_sample_ac97_dev; | ||
86 | |||
87 | static int __init au1xpsc_sample_ac97_load(void) | ||
88 | { | ||
89 | int ret; | ||
90 | |||
91 | #ifdef CONFIG_SOC_AU1200 | ||
92 | unsigned long io; | ||
93 | |||
94 | /* modify sys_pinfunc for AC97 on PSC1 */ | ||
95 | io = au_readl(SYS_PINFUNC); | ||
96 | io |= SYS_PINFUNC_P1C; | ||
97 | io &= ~(SYS_PINFUNC_P1A | SYS_PINFUNC_P1B); | ||
98 | au_writel(io, SYS_PINFUNC); | ||
99 | au_sync(); | ||
100 | #endif | ||
101 | |||
102 | ret = -ENOMEM; | ||
103 | |||
104 | /* setup PSC clock source for AC97 part: external clock provided | ||
105 | * by codec. The psc-ac97.c driver depends on this setting! | ||
106 | */ | ||
107 | au_writel(PSC_SEL_CLK_SERCLK, PSC1_BASE_ADDR + PSC_SEL_OFFSET); | ||
108 | au_sync(); | ||
109 | |||
110 | au1xpsc_sample_ac97_dev = platform_device_alloc("soc-audio", -1); | ||
111 | if (!au1xpsc_sample_ac97_dev) | ||
112 | goto out; | ||
113 | |||
114 | au1xpsc_sample_ac97_dev->resource = | ||
115 | kmemdup(au1xpsc_psc1_res, sizeof(struct resource) * | ||
116 | ARRAY_SIZE(au1xpsc_psc1_res), GFP_KERNEL); | ||
117 | au1xpsc_sample_ac97_dev->num_resources = ARRAY_SIZE(au1xpsc_psc1_res); | ||
118 | au1xpsc_sample_ac97_dev->id = 1; | ||
119 | |||
120 | platform_set_drvdata(au1xpsc_sample_ac97_dev, | ||
121 | &au1xpsc_sample_ac97_devdata); | ||
122 | au1xpsc_sample_ac97_devdata.dev = &au1xpsc_sample_ac97_dev->dev; | ||
123 | ret = platform_device_add(au1xpsc_sample_ac97_dev); | ||
124 | |||
125 | if (ret) { | ||
126 | platform_device_put(au1xpsc_sample_ac97_dev); | ||
127 | au1xpsc_sample_ac97_dev = NULL; | ||
128 | } | ||
129 | |||
130 | out: | ||
131 | return ret; | ||
132 | } | ||
133 | |||
134 | static void __exit au1xpsc_sample_ac97_exit(void) | ||
135 | { | ||
136 | platform_device_unregister(au1xpsc_sample_ac97_dev); | ||
137 | } | ||
138 | |||
139 | module_init(au1xpsc_sample_ac97_load); | ||
140 | module_exit(au1xpsc_sample_ac97_exit); | ||
141 | |||
142 | MODULE_LICENSE("GPL"); | ||
143 | MODULE_DESCRIPTION("Au1xxx PSC sample AC97 machine"); | ||
144 | MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>"); | ||
diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c index b9ef7e45891d..b68d99fb6af0 100644 --- a/sound/soc/codecs/ak4104.c +++ b/sound/soc/codecs/ak4104.c | |||
@@ -90,12 +90,10 @@ static int ak4104_spi_write(struct snd_soc_codec *codec, unsigned int reg, | |||
90 | if (reg >= codec->reg_cache_size) | 90 | if (reg >= codec->reg_cache_size) |
91 | return -EINVAL; | 91 | return -EINVAL; |
92 | 92 | ||
93 | reg &= AK4104_REG_MASK; | ||
94 | reg |= AK4104_WRITE; | ||
95 | |||
96 | /* only write to the hardware if value has changed */ | 93 | /* only write to the hardware if value has changed */ |
97 | if (cache[reg] != value) { | 94 | if (cache[reg] != value) { |
98 | u8 tmp[2] = { reg, value }; | 95 | u8 tmp[2] = { (reg & AK4104_REG_MASK) | AK4104_WRITE, value }; |
96 | |||
99 | if (spi_write(spi, tmp, sizeof(tmp))) { | 97 | if (spi_write(spi, tmp, sizeof(tmp))) { |
100 | dev_err(&spi->dev, "SPI write failed\n"); | 98 | dev_err(&spi->dev, "SPI write failed\n"); |
101 | return -EIO; | 99 | return -EIO; |
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index a2763c2e7348..9cd0a66b7663 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c | |||
@@ -137,7 +137,7 @@ static void uda1380_flush_work(struct work_struct *work) | |||
137 | { | 137 | { |
138 | int bit, reg; | 138 | int bit, reg; |
139 | 139 | ||
140 | for_each_bit(bit, &uda1380_cache_dirty, UDA1380_CACHEREGNUM - 0x10) { | 140 | for_each_set_bit(bit, &uda1380_cache_dirty, UDA1380_CACHEREGNUM - 0x10) { |
141 | reg = 0x10 + bit; | 141 | reg = 0x10 + bit; |
142 | pr_debug("uda1380: flush reg %x val %x:\n", reg, | 142 | pr_debug("uda1380: flush reg %x val %x:\n", reg, |
143 | uda1380_read_reg_cache(uda1380_codec, reg)); | 143 | uda1380_read_reg_cache(uda1380_codec, reg)); |
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 718ef912e758..df2c6d9617fb 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c | |||
@@ -1349,7 +1349,7 @@ static irqreturn_t wm8350_hp_jack_handler(int irq, void *data) | |||
1349 | int mask; | 1349 | int mask; |
1350 | struct wm8350_jack_data *jack = NULL; | 1350 | struct wm8350_jack_data *jack = NULL; |
1351 | 1351 | ||
1352 | switch (irq) { | 1352 | switch (irq - wm8350->irq_base) { |
1353 | case WM8350_IRQ_CODEC_JCK_DET_L: | 1353 | case WM8350_IRQ_CODEC_JCK_DET_L: |
1354 | jack = &priv->hpl; | 1354 | jack = &priv->hpl; |
1355 | mask = WM8350_JACK_L_LVL; | 1355 | mask = WM8350_JACK_L_LVL; |
@@ -1424,7 +1424,7 @@ int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which, | |||
1424 | wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena); | 1424 | wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena); |
1425 | 1425 | ||
1426 | /* Sync status */ | 1426 | /* Sync status */ |
1427 | wm8350_hp_jack_handler(irq, priv); | 1427 | wm8350_hp_jack_handler(irq + wm8350->irq_base, priv); |
1428 | 1428 | ||
1429 | return 0; | 1429 | return 0; |
1430 | } | 1430 | } |
@@ -1521,8 +1521,8 @@ static int wm8350_remove(struct platform_device *pdev) | |||
1521 | WM8350_JDL_ENA | WM8350_JDR_ENA); | 1521 | WM8350_JDL_ENA | WM8350_JDR_ENA); |
1522 | wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA); | 1522 | wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA); |
1523 | 1523 | ||
1524 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); | 1524 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, priv); |
1525 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); | 1525 | wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, priv); |
1526 | 1526 | ||
1527 | priv->hpl.jack = NULL; | 1527 | priv->hpl.jack = NULL; |
1528 | priv->hpr.jack = NULL; | 1528 | priv->hpr.jack = NULL; |
diff --git a/sound/soc/fsl/efika-audio-fabric.c b/sound/soc/fsl/efika-audio-fabric.c index 3326e2a1e863..1a5b8e0d6a34 100644 --- a/sound/soc/fsl/efika-audio-fabric.c +++ b/sound/soc/fsl/efika-audio-fabric.c | |||
@@ -55,7 +55,7 @@ static __init int efika_fabric_init(void) | |||
55 | struct platform_device *pdev; | 55 | struct platform_device *pdev; |
56 | int rc; | 56 | int rc; |
57 | 57 | ||
58 | if (!machine_is_compatible("bplan,efika")) | 58 | if (!of_machine_is_compatible("bplan,efika")) |
59 | return -ENODEV; | 59 | return -ENODEV; |
60 | 60 | ||
61 | card.platform = &mpc5200_audio_dma_platform; | 61 | card.platform = &mpc5200_audio_dma_platform; |
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c index b928ef7d28eb..6644cba7cbf2 100644 --- a/sound/soc/fsl/pcm030-audio-fabric.c +++ b/sound/soc/fsl/pcm030-audio-fabric.c | |||
@@ -55,7 +55,7 @@ static __init int pcm030_fabric_init(void) | |||
55 | struct platform_device *pdev; | 55 | struct platform_device *pdev; |
56 | int rc; | 56 | int rc; |
57 | 57 | ||
58 | if (!machine_is_compatible("phytec,pcm030")) | 58 | if (!of_machine_is_compatible("phytec,pcm030")) |
59 | return -ENODEV; | 59 | return -ENODEV; |
60 | 60 | ||
61 | card.platform = &mpc5200_audio_dma_platform; | 61 | card.platform = &mpc5200_audio_dma_platform; |
diff --git a/sound/soc/imx/imx-pcm-fiq.c b/sound/soc/imx/imx-pcm-fiq.c index 5532579ece4d..d9cb9849b033 100644 --- a/sound/soc/imx/imx-pcm-fiq.c +++ b/sound/soc/imx/imx-pcm-fiq.c | |||
@@ -35,22 +35,25 @@ | |||
35 | struct imx_pcm_runtime_data { | 35 | struct imx_pcm_runtime_data { |
36 | int period; | 36 | int period; |
37 | int periods; | 37 | int periods; |
38 | unsigned long dma_addr; | ||
39 | int dma; | ||
40 | unsigned long offset; | 38 | unsigned long offset; |
39 | unsigned long last_offset; | ||
41 | unsigned long size; | 40 | unsigned long size; |
42 | unsigned long period_cnt; | ||
43 | void *buf; | ||
44 | struct timer_list timer; | 41 | struct timer_list timer; |
45 | int period_time; | 42 | int poll_time; |
46 | }; | 43 | }; |
47 | 44 | ||
45 | static inline void imx_ssi_set_next_poll(struct imx_pcm_runtime_data *iprtd) | ||
46 | { | ||
47 | iprtd->timer.expires = jiffies + iprtd->poll_time; | ||
48 | } | ||
49 | |||
48 | static void imx_ssi_timer_callback(unsigned long data) | 50 | static void imx_ssi_timer_callback(unsigned long data) |
49 | { | 51 | { |
50 | struct snd_pcm_substream *substream = (void *)data; | 52 | struct snd_pcm_substream *substream = (void *)data; |
51 | struct snd_pcm_runtime *runtime = substream->runtime; | 53 | struct snd_pcm_runtime *runtime = substream->runtime; |
52 | struct imx_pcm_runtime_data *iprtd = runtime->private_data; | 54 | struct imx_pcm_runtime_data *iprtd = runtime->private_data; |
53 | struct pt_regs regs; | 55 | struct pt_regs regs; |
56 | unsigned long delta; | ||
54 | 57 | ||
55 | get_fiq_regs(®s); | 58 | get_fiq_regs(®s); |
56 | 59 | ||
@@ -59,9 +62,25 @@ static void imx_ssi_timer_callback(unsigned long data) | |||
59 | else | 62 | else |
60 | iprtd->offset = regs.ARM_r9 & 0xffff; | 63 | iprtd->offset = regs.ARM_r9 & 0xffff; |
61 | 64 | ||
62 | iprtd->timer.expires = jiffies + iprtd->period_time; | 65 | /* How much data have we transferred since the last period report? */ |
66 | if (iprtd->offset >= iprtd->last_offset) | ||
67 | delta = iprtd->offset - iprtd->last_offset; | ||
68 | else | ||
69 | delta = runtime->buffer_size + iprtd->offset | ||
70 | - iprtd->last_offset; | ||
71 | |||
72 | /* If we've transferred at least a period then report it and | ||
73 | * reset our poll time */ | ||
74 | if (delta >= runtime->period_size) { | ||
75 | snd_pcm_period_elapsed(substream); | ||
76 | iprtd->last_offset = iprtd->offset; | ||
77 | |||
78 | imx_ssi_set_next_poll(iprtd); | ||
79 | } | ||
80 | |||
81 | /* Restart the timer; if we didn't report we'll run on the next tick */ | ||
63 | add_timer(&iprtd->timer); | 82 | add_timer(&iprtd->timer); |
64 | snd_pcm_period_elapsed(substream); | 83 | |
65 | } | 84 | } |
66 | 85 | ||
67 | static struct fiq_handler fh = { | 86 | static struct fiq_handler fh = { |
@@ -76,9 +95,10 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream, | |||
76 | 95 | ||
77 | iprtd->size = params_buffer_bytes(params); | 96 | iprtd->size = params_buffer_bytes(params); |
78 | iprtd->periods = params_periods(params); | 97 | iprtd->periods = params_periods(params); |
79 | iprtd->period = params_period_bytes(params); | 98 | iprtd->period = params_period_bytes(params) ; |
80 | iprtd->offset = 0; | 99 | iprtd->offset = 0; |
81 | iprtd->period_time = HZ / (params_rate(params) / params_period_size(params)); | 100 | iprtd->last_offset = 0; |
101 | iprtd->poll_time = HZ / (params_rate(params) / params_period_size(params)); | ||
82 | 102 | ||
83 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); | 103 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); |
84 | 104 | ||
@@ -114,7 +134,7 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
114 | case SNDRV_PCM_TRIGGER_START: | 134 | case SNDRV_PCM_TRIGGER_START: |
115 | case SNDRV_PCM_TRIGGER_RESUME: | 135 | case SNDRV_PCM_TRIGGER_RESUME: |
116 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 136 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
117 | iprtd->timer.expires = jiffies + iprtd->period_time; | 137 | imx_ssi_set_next_poll(iprtd); |
118 | add_timer(&iprtd->timer); | 138 | add_timer(&iprtd->timer); |
119 | if (++fiq_enable == 1) | 139 | if (++fiq_enable == 1) |
120 | enable_fiq(imx_pcm_fiq); | 140 | enable_fiq(imx_pcm_fiq); |
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 18ebdc7d0a51..f11963c21873 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig | |||
@@ -6,6 +6,9 @@ config SND_OMAP_SOC_MCBSP | |||
6 | tristate | 6 | tristate |
7 | select OMAP_MCBSP | 7 | select OMAP_MCBSP |
8 | 8 | ||
9 | config SND_OMAP_SOC_MCPDM | ||
10 | tristate | ||
11 | |||
9 | config SND_OMAP_SOC_N810 | 12 | config SND_OMAP_SOC_N810 |
10 | tristate "SoC Audio support for Nokia N810" | 13 | tristate "SoC Audio support for Nokia N810" |
11 | depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C | 14 | depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C |
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 19283e5edfbf..0bc00ca14b37 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile | |||
@@ -1,9 +1,11 @@ | |||
1 | # OMAP Platform Support | 1 | # OMAP Platform Support |
2 | snd-soc-omap-objs := omap-pcm.o | 2 | snd-soc-omap-objs := omap-pcm.o |
3 | snd-soc-omap-mcbsp-objs := omap-mcbsp.o | 3 | snd-soc-omap-mcbsp-objs := omap-mcbsp.o |
4 | snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o | ||
4 | 5 | ||
5 | obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o | 6 | obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o |
6 | obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o | 7 | obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o |
8 | obj-$(CONFIG_SND_OMAP_SOC_MCPDM) += snd-soc-omap-mcpdm.o | ||
7 | 9 | ||
8 | # OMAP Machine Support | 10 | # OMAP Machine Support |
9 | snd-soc-n810-objs := n810.o | 11 | snd-soc-n810-objs := n810.o |
diff --git a/sound/soc/omap/mcpdm.c b/sound/soc/omap/mcpdm.c new file mode 100644 index 000000000000..ad8df6cfae88 --- /dev/null +++ b/sound/soc/omap/mcpdm.c | |||
@@ -0,0 +1,484 @@ | |||
1 | /* | ||
2 | * mcpdm.c -- McPDM interface driver | ||
3 | * | ||
4 | * Author: Jorge Eduardo Candelaria <x0107209@ti.com> | ||
5 | * Copyright (C) 2009 - Texas Instruments, Inc. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * 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., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/device.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/wait.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/err.h> | ||
30 | #include <linux/clk.h> | ||
31 | #include <linux/delay.h> | ||
32 | #include <linux/io.h> | ||
33 | #include <linux/irq.h> | ||
34 | |||
35 | #include "mcpdm.h" | ||
36 | |||
37 | static struct omap_mcpdm *mcpdm; | ||
38 | |||
39 | static inline void omap_mcpdm_write(u16 reg, u32 val) | ||
40 | { | ||
41 | __raw_writel(val, mcpdm->io_base + reg); | ||
42 | } | ||
43 | |||
44 | static inline int omap_mcpdm_read(u16 reg) | ||
45 | { | ||
46 | return __raw_readl(mcpdm->io_base + reg); | ||
47 | } | ||
48 | |||
49 | static void omap_mcpdm_reg_dump(void) | ||
50 | { | ||
51 | dev_dbg(mcpdm->dev, "***********************\n"); | ||
52 | dev_dbg(mcpdm->dev, "IRQSTATUS_RAW: 0x%04x\n", | ||
53 | omap_mcpdm_read(MCPDM_IRQSTATUS_RAW)); | ||
54 | dev_dbg(mcpdm->dev, "IRQSTATUS: 0x%04x\n", | ||
55 | omap_mcpdm_read(MCPDM_IRQSTATUS)); | ||
56 | dev_dbg(mcpdm->dev, "IRQENABLE_SET: 0x%04x\n", | ||
57 | omap_mcpdm_read(MCPDM_IRQENABLE_SET)); | ||
58 | dev_dbg(mcpdm->dev, "IRQENABLE_CLR: 0x%04x\n", | ||
59 | omap_mcpdm_read(MCPDM_IRQENABLE_CLR)); | ||
60 | dev_dbg(mcpdm->dev, "IRQWAKE_EN: 0x%04x\n", | ||
61 | omap_mcpdm_read(MCPDM_IRQWAKE_EN)); | ||
62 | dev_dbg(mcpdm->dev, "DMAENABLE_SET: 0x%04x\n", | ||
63 | omap_mcpdm_read(MCPDM_DMAENABLE_SET)); | ||
64 | dev_dbg(mcpdm->dev, "DMAENABLE_CLR: 0x%04x\n", | ||
65 | omap_mcpdm_read(MCPDM_DMAENABLE_CLR)); | ||
66 | dev_dbg(mcpdm->dev, "DMAWAKEEN: 0x%04x\n", | ||
67 | omap_mcpdm_read(MCPDM_DMAWAKEEN)); | ||
68 | dev_dbg(mcpdm->dev, "CTRL: 0x%04x\n", | ||
69 | omap_mcpdm_read(MCPDM_CTRL)); | ||
70 | dev_dbg(mcpdm->dev, "DN_DATA: 0x%04x\n", | ||
71 | omap_mcpdm_read(MCPDM_DN_DATA)); | ||
72 | dev_dbg(mcpdm->dev, "UP_DATA: 0x%04x\n", | ||
73 | omap_mcpdm_read(MCPDM_UP_DATA)); | ||
74 | dev_dbg(mcpdm->dev, "FIFO_CTRL_DN: 0x%04x\n", | ||
75 | omap_mcpdm_read(MCPDM_FIFO_CTRL_DN)); | ||
76 | dev_dbg(mcpdm->dev, "FIFO_CTRL_UP: 0x%04x\n", | ||
77 | omap_mcpdm_read(MCPDM_FIFO_CTRL_UP)); | ||
78 | dev_dbg(mcpdm->dev, "DN_OFFSET: 0x%04x\n", | ||
79 | omap_mcpdm_read(MCPDM_DN_OFFSET)); | ||
80 | dev_dbg(mcpdm->dev, "***********************\n"); | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * Takes the McPDM module in and out of reset state. | ||
85 | * Uplink and downlink can be reset individually. | ||
86 | */ | ||
87 | static void omap_mcpdm_reset_capture(int reset) | ||
88 | { | ||
89 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); | ||
90 | |||
91 | if (reset) | ||
92 | ctrl |= SW_UP_RST; | ||
93 | else | ||
94 | ctrl &= ~SW_UP_RST; | ||
95 | |||
96 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | ||
97 | } | ||
98 | |||
99 | static void omap_mcpdm_reset_playback(int reset) | ||
100 | { | ||
101 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); | ||
102 | |||
103 | if (reset) | ||
104 | ctrl |= SW_DN_RST; | ||
105 | else | ||
106 | ctrl &= ~SW_DN_RST; | ||
107 | |||
108 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | * Enables the transfer through the PDM interface to/from the Phoenix | ||
113 | * codec by enabling the corresponding UP or DN channels. | ||
114 | */ | ||
115 | void omap_mcpdm_start(int stream) | ||
116 | { | ||
117 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); | ||
118 | |||
119 | if (stream) | ||
120 | ctrl |= mcpdm->up_channels; | ||
121 | else | ||
122 | ctrl |= mcpdm->dn_channels; | ||
123 | |||
124 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | ||
125 | } | ||
126 | |||
127 | /* | ||
128 | * Disables the transfer through the PDM interface to/from the Phoenix | ||
129 | * codec by disabling the corresponding UP or DN channels. | ||
130 | */ | ||
131 | void omap_mcpdm_stop(int stream) | ||
132 | { | ||
133 | int ctrl = omap_mcpdm_read(MCPDM_CTRL); | ||
134 | |||
135 | if (stream) | ||
136 | ctrl &= ~mcpdm->up_channels; | ||
137 | else | ||
138 | ctrl &= ~mcpdm->dn_channels; | ||
139 | |||
140 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | ||
141 | } | ||
142 | |||
143 | /* | ||
144 | * Configures McPDM uplink for audio recording. | ||
145 | * This function should be called before omap_mcpdm_start. | ||
146 | */ | ||
147 | int omap_mcpdm_capture_open(struct omap_mcpdm_link *uplink) | ||
148 | { | ||
149 | int irq_mask = 0; | ||
150 | int ctrl; | ||
151 | |||
152 | if (!uplink) | ||
153 | return -EINVAL; | ||
154 | |||
155 | mcpdm->uplink = uplink; | ||
156 | |||
157 | /* Enable irq request generation */ | ||
158 | irq_mask |= uplink->irq_mask & MCPDM_UPLINK_IRQ_MASK; | ||
159 | omap_mcpdm_write(MCPDM_IRQENABLE_SET, irq_mask); | ||
160 | |||
161 | /* Configure uplink threshold */ | ||
162 | if (uplink->threshold > UP_THRES_MAX) | ||
163 | uplink->threshold = UP_THRES_MAX; | ||
164 | |||
165 | omap_mcpdm_write(MCPDM_FIFO_CTRL_UP, uplink->threshold); | ||
166 | |||
167 | /* Configure DMA controller */ | ||
168 | omap_mcpdm_write(MCPDM_DMAENABLE_SET, DMA_UP_ENABLE); | ||
169 | |||
170 | /* Set pdm out format */ | ||
171 | ctrl = omap_mcpdm_read(MCPDM_CTRL); | ||
172 | ctrl &= ~PDMOUTFORMAT; | ||
173 | ctrl |= uplink->format & PDMOUTFORMAT; | ||
174 | |||
175 | /* Uplink channels */ | ||
176 | mcpdm->up_channels = uplink->channels & (PDM_UP_MASK | PDM_STATUS_MASK); | ||
177 | |||
178 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | ||
179 | |||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | /* | ||
184 | * Configures McPDM downlink for audio playback. | ||
185 | * This function should be called before omap_mcpdm_start. | ||
186 | */ | ||
187 | int omap_mcpdm_playback_open(struct omap_mcpdm_link *downlink) | ||
188 | { | ||
189 | int irq_mask = 0; | ||
190 | int ctrl; | ||
191 | |||
192 | if (!downlink) | ||
193 | return -EINVAL; | ||
194 | |||
195 | mcpdm->downlink = downlink; | ||
196 | |||
197 | /* Enable irq request generation */ | ||
198 | irq_mask |= downlink->irq_mask & MCPDM_DOWNLINK_IRQ_MASK; | ||
199 | omap_mcpdm_write(MCPDM_IRQENABLE_SET, irq_mask); | ||
200 | |||
201 | /* Configure uplink threshold */ | ||
202 | if (downlink->threshold > DN_THRES_MAX) | ||
203 | downlink->threshold = DN_THRES_MAX; | ||
204 | |||
205 | omap_mcpdm_write(MCPDM_FIFO_CTRL_DN, downlink->threshold); | ||
206 | |||
207 | /* Enable DMA request generation */ | ||
208 | omap_mcpdm_write(MCPDM_DMAENABLE_SET, DMA_DN_ENABLE); | ||
209 | |||
210 | /* Set pdm out format */ | ||
211 | ctrl = omap_mcpdm_read(MCPDM_CTRL); | ||
212 | ctrl &= ~PDMOUTFORMAT; | ||
213 | ctrl |= downlink->format & PDMOUTFORMAT; | ||
214 | |||
215 | /* Downlink channels */ | ||
216 | mcpdm->dn_channels = downlink->channels & (PDM_DN_MASK | PDM_CMD_MASK); | ||
217 | |||
218 | omap_mcpdm_write(MCPDM_CTRL, ctrl); | ||
219 | |||
220 | return 0; | ||
221 | } | ||
222 | |||
223 | /* | ||
224 | * Cleans McPDM uplink configuration. | ||
225 | * This function should be called when the stream is closed. | ||
226 | */ | ||
227 | int omap_mcpdm_capture_close(struct omap_mcpdm_link *uplink) | ||
228 | { | ||
229 | int irq_mask = 0; | ||
230 | |||
231 | if (!uplink) | ||
232 | return -EINVAL; | ||
233 | |||
234 | /* Disable irq request generation */ | ||
235 | irq_mask |= uplink->irq_mask & MCPDM_UPLINK_IRQ_MASK; | ||
236 | omap_mcpdm_write(MCPDM_IRQENABLE_CLR, irq_mask); | ||
237 | |||
238 | /* Disable DMA request generation */ | ||
239 | omap_mcpdm_write(MCPDM_DMAENABLE_CLR, DMA_UP_ENABLE); | ||
240 | |||
241 | /* Clear Downlink channels */ | ||
242 | mcpdm->up_channels = 0; | ||
243 | |||
244 | mcpdm->uplink = NULL; | ||
245 | |||
246 | return 0; | ||
247 | } | ||
248 | |||
249 | /* | ||
250 | * Cleans McPDM downlink configuration. | ||
251 | * This function should be called when the stream is closed. | ||
252 | */ | ||
253 | int omap_mcpdm_playback_close(struct omap_mcpdm_link *downlink) | ||
254 | { | ||
255 | int irq_mask = 0; | ||
256 | |||
257 | if (!downlink) | ||
258 | return -EINVAL; | ||
259 | |||
260 | /* Disable irq request generation */ | ||
261 | irq_mask |= downlink->irq_mask & MCPDM_DOWNLINK_IRQ_MASK; | ||
262 | omap_mcpdm_write(MCPDM_IRQENABLE_CLR, irq_mask); | ||
263 | |||
264 | /* Disable DMA request generation */ | ||
265 | omap_mcpdm_write(MCPDM_DMAENABLE_CLR, DMA_DN_ENABLE); | ||
266 | |||
267 | /* clear Downlink channels */ | ||
268 | mcpdm->dn_channels = 0; | ||
269 | |||
270 | mcpdm->downlink = NULL; | ||
271 | |||
272 | return 0; | ||
273 | } | ||
274 | |||
275 | static irqreturn_t omap_mcpdm_irq_handler(int irq, void *dev_id) | ||
276 | { | ||
277 | struct omap_mcpdm *mcpdm_irq = dev_id; | ||
278 | int irq_status; | ||
279 | |||
280 | irq_status = omap_mcpdm_read(MCPDM_IRQSTATUS); | ||
281 | |||
282 | /* Acknowledge irq event */ | ||
283 | omap_mcpdm_write(MCPDM_IRQSTATUS, irq_status); | ||
284 | |||
285 | if (irq & MCPDM_DN_IRQ_FULL) { | ||
286 | dev_err(mcpdm_irq->dev, "DN FIFO error %x\n", irq_status); | ||
287 | omap_mcpdm_reset_playback(1); | ||
288 | omap_mcpdm_playback_open(mcpdm_irq->downlink); | ||
289 | omap_mcpdm_reset_playback(0); | ||
290 | } | ||
291 | |||
292 | if (irq & MCPDM_DN_IRQ_EMPTY) { | ||
293 | dev_err(mcpdm_irq->dev, "DN FIFO error %x\n", irq_status); | ||
294 | omap_mcpdm_reset_playback(1); | ||
295 | omap_mcpdm_playback_open(mcpdm_irq->downlink); | ||
296 | omap_mcpdm_reset_playback(0); | ||
297 | } | ||
298 | |||
299 | if (irq & MCPDM_DN_IRQ) { | ||
300 | dev_dbg(mcpdm_irq->dev, "DN write request\n"); | ||
301 | } | ||
302 | |||
303 | if (irq & MCPDM_UP_IRQ_FULL) { | ||
304 | dev_err(mcpdm_irq->dev, "UP FIFO error %x\n", irq_status); | ||
305 | omap_mcpdm_reset_capture(1); | ||
306 | omap_mcpdm_capture_open(mcpdm_irq->uplink); | ||
307 | omap_mcpdm_reset_capture(0); | ||
308 | } | ||
309 | |||
310 | if (irq & MCPDM_UP_IRQ_EMPTY) { | ||
311 | dev_err(mcpdm_irq->dev, "UP FIFO error %x\n", irq_status); | ||
312 | omap_mcpdm_reset_capture(1); | ||
313 | omap_mcpdm_capture_open(mcpdm_irq->uplink); | ||
314 | omap_mcpdm_reset_capture(0); | ||
315 | } | ||
316 | |||
317 | if (irq & MCPDM_UP_IRQ) { | ||
318 | dev_dbg(mcpdm_irq->dev, "UP write request\n"); | ||
319 | } | ||
320 | |||
321 | return IRQ_HANDLED; | ||
322 | } | ||
323 | |||
324 | int omap_mcpdm_request(void) | ||
325 | { | ||
326 | int ret; | ||
327 | |||
328 | clk_enable(mcpdm->clk); | ||
329 | |||
330 | spin_lock(&mcpdm->lock); | ||
331 | |||
332 | if (!mcpdm->free) { | ||
333 | dev_err(mcpdm->dev, "McPDM interface is in use\n"); | ||
334 | spin_unlock(&mcpdm->lock); | ||
335 | ret = -EBUSY; | ||
336 | goto err; | ||
337 | } | ||
338 | mcpdm->free = 0; | ||
339 | |||
340 | spin_unlock(&mcpdm->lock); | ||
341 | |||
342 | /* Disable lines while request is ongoing */ | ||
343 | omap_mcpdm_write(MCPDM_CTRL, 0x00); | ||
344 | |||
345 | ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, | ||
346 | 0, "McPDM", (void *)mcpdm); | ||
347 | if (ret) { | ||
348 | dev_err(mcpdm->dev, "Request for McPDM IRQ failed\n"); | ||
349 | goto err; | ||
350 | } | ||
351 | |||
352 | return 0; | ||
353 | |||
354 | err: | ||
355 | clk_disable(mcpdm->clk); | ||
356 | return ret; | ||
357 | } | ||
358 | |||
359 | void omap_mcpdm_free(void) | ||
360 | { | ||
361 | spin_lock(&mcpdm->lock); | ||
362 | if (mcpdm->free) { | ||
363 | dev_err(mcpdm->dev, "McPDM interface is already free\n"); | ||
364 | spin_unlock(&mcpdm->lock); | ||
365 | return; | ||
366 | } | ||
367 | mcpdm->free = 1; | ||
368 | spin_unlock(&mcpdm->lock); | ||
369 | |||
370 | clk_disable(mcpdm->clk); | ||
371 | |||
372 | free_irq(mcpdm->irq, (void *)mcpdm); | ||
373 | } | ||
374 | |||
375 | /* Enable/disable DC offset cancelation for the analog | ||
376 | * headset path (PDM channels 1 and 2). | ||
377 | */ | ||
378 | int omap_mcpdm_set_offset(int offset1, int offset2) | ||
379 | { | ||
380 | int offset; | ||
381 | |||
382 | if ((offset1 > DN_OFST_MAX) || (offset2 > DN_OFST_MAX)) | ||
383 | return -EINVAL; | ||
384 | |||
385 | offset = (offset1 << DN_OFST_RX1) | (offset2 << DN_OFST_RX2); | ||
386 | |||
387 | /* offset cancellation for channel 1 */ | ||
388 | if (offset1) | ||
389 | offset |= DN_OFST_RX1_EN; | ||
390 | else | ||
391 | offset &= ~DN_OFST_RX1_EN; | ||
392 | |||
393 | /* offset cancellation for channel 2 */ | ||
394 | if (offset2) | ||
395 | offset |= DN_OFST_RX2_EN; | ||
396 | else | ||
397 | offset &= ~DN_OFST_RX2_EN; | ||
398 | |||
399 | omap_mcpdm_write(MCPDM_DN_OFFSET, offset); | ||
400 | |||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | static int __devinit omap_mcpdm_probe(struct platform_device *pdev) | ||
405 | { | ||
406 | struct resource *res; | ||
407 | int ret = 0; | ||
408 | |||
409 | mcpdm = kzalloc(sizeof(struct omap_mcpdm), GFP_KERNEL); | ||
410 | if (!mcpdm) { | ||
411 | ret = -ENOMEM; | ||
412 | goto exit; | ||
413 | } | ||
414 | |||
415 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
416 | if (res == NULL) { | ||
417 | dev_err(&pdev->dev, "no resource\n"); | ||
418 | goto err_resource; | ||
419 | } | ||
420 | |||
421 | spin_lock_init(&mcpdm->lock); | ||
422 | mcpdm->free = 1; | ||
423 | mcpdm->io_base = ioremap(res->start, resource_size(res)); | ||
424 | if (!mcpdm->io_base) { | ||
425 | ret = -ENOMEM; | ||
426 | goto err_resource; | ||
427 | } | ||
428 | |||
429 | mcpdm->irq = platform_get_irq(pdev, 0); | ||
430 | |||
431 | mcpdm->clk = clk_get(&pdev->dev, "pdm_ck"); | ||
432 | if (IS_ERR(mcpdm->clk)) { | ||
433 | ret = PTR_ERR(mcpdm->clk); | ||
434 | dev_err(&pdev->dev, "unable to get pdm_ck: %d\n", ret); | ||
435 | goto err_clk; | ||
436 | } | ||
437 | |||
438 | mcpdm->dev = &pdev->dev; | ||
439 | platform_set_drvdata(pdev, mcpdm); | ||
440 | |||
441 | return 0; | ||
442 | |||
443 | err_clk: | ||
444 | iounmap(mcpdm->io_base); | ||
445 | err_resource: | ||
446 | kfree(mcpdm); | ||
447 | exit: | ||
448 | return ret; | ||
449 | } | ||
450 | |||
451 | static int __devexit omap_mcpdm_remove(struct platform_device *pdev) | ||
452 | { | ||
453 | struct omap_mcpdm *mcpdm_ptr = platform_get_drvdata(pdev); | ||
454 | |||
455 | platform_set_drvdata(pdev, NULL); | ||
456 | |||
457 | clk_put(mcpdm_ptr->clk); | ||
458 | |||
459 | iounmap(mcpdm_ptr->io_base); | ||
460 | |||
461 | mcpdm_ptr->clk = NULL; | ||
462 | mcpdm_ptr->free = 0; | ||
463 | mcpdm_ptr->dev = NULL; | ||
464 | |||
465 | kfree(mcpdm_ptr); | ||
466 | |||
467 | return 0; | ||
468 | } | ||
469 | |||
470 | static struct platform_driver omap_mcpdm_driver = { | ||
471 | .probe = omap_mcpdm_probe, | ||
472 | .remove = __devexit_p(omap_mcpdm_remove), | ||
473 | .driver = { | ||
474 | .name = "omap-mcpdm", | ||
475 | }, | ||
476 | }; | ||
477 | |||
478 | static struct platform_device *omap_mcpdm_device; | ||
479 | |||
480 | static int __init omap_mcpdm_init(void) | ||
481 | { | ||
482 | return platform_driver_register(&omap_mcpdm_driver); | ||
483 | } | ||
484 | arch_initcall(omap_mcpdm_init); | ||
diff --git a/sound/soc/omap/mcpdm.h b/sound/soc/omap/mcpdm.h new file mode 100644 index 000000000000..7bb326ef0886 --- /dev/null +++ b/sound/soc/omap/mcpdm.h | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | * mcpdm.h -- Defines for McPDM driver | ||
3 | * | ||
4 | * Author: Jorge Eduardo Candelaria <x0107209@ti.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | /* McPDM registers */ | ||
23 | |||
24 | #define MCPDM_REVISION 0x00 | ||
25 | #define MCPDM_SYSCONFIG 0x10 | ||
26 | #define MCPDM_IRQSTATUS_RAW 0x24 | ||
27 | #define MCPDM_IRQSTATUS 0x28 | ||
28 | #define MCPDM_IRQENABLE_SET 0x2C | ||
29 | #define MCPDM_IRQENABLE_CLR 0x30 | ||
30 | #define MCPDM_IRQWAKE_EN 0x34 | ||
31 | #define MCPDM_DMAENABLE_SET 0x38 | ||
32 | #define MCPDM_DMAENABLE_CLR 0x3C | ||
33 | #define MCPDM_DMAWAKEEN 0x40 | ||
34 | #define MCPDM_CTRL 0x44 | ||
35 | #define MCPDM_DN_DATA 0x48 | ||
36 | #define MCPDM_UP_DATA 0x4C | ||
37 | #define MCPDM_FIFO_CTRL_DN 0x50 | ||
38 | #define MCPDM_FIFO_CTRL_UP 0x54 | ||
39 | #define MCPDM_DN_OFFSET 0x58 | ||
40 | |||
41 | /* | ||
42 | * MCPDM_IRQ bit fields | ||
43 | * IRQSTATUS_RAW, IRQSTATUS, IRQENABLE_SET, IRQENABLE_CLR | ||
44 | */ | ||
45 | |||
46 | #define MCPDM_DN_IRQ (1 << 0) | ||
47 | #define MCPDM_DN_IRQ_EMPTY (1 << 1) | ||
48 | #define MCPDM_DN_IRQ_ALMST_EMPTY (1 << 2) | ||
49 | #define MCPDM_DN_IRQ_FULL (1 << 3) | ||
50 | |||
51 | #define MCPDM_UP_IRQ (1 << 8) | ||
52 | #define MCPDM_UP_IRQ_EMPTY (1 << 9) | ||
53 | #define MCPDM_UP_IRQ_ALMST_FULL (1 << 10) | ||
54 | #define MCPDM_UP_IRQ_FULL (1 << 11) | ||
55 | |||
56 | #define MCPDM_DOWNLINK_IRQ_MASK 0x00F | ||
57 | #define MCPDM_UPLINK_IRQ_MASK 0xF00 | ||
58 | |||
59 | /* | ||
60 | * MCPDM_DMAENABLE bit fields | ||
61 | */ | ||
62 | |||
63 | #define DMA_DN_ENABLE 0x1 | ||
64 | #define DMA_UP_ENABLE 0x2 | ||
65 | |||
66 | /* | ||
67 | * MCPDM_CTRL bit fields | ||
68 | */ | ||
69 | |||
70 | #define PDM_UP1_EN 0x0001 | ||
71 | #define PDM_UP2_EN 0x0002 | ||
72 | #define PDM_UP3_EN 0x0004 | ||
73 | #define PDM_DN1_EN 0x0008 | ||
74 | #define PDM_DN2_EN 0x0010 | ||
75 | #define PDM_DN3_EN 0x0020 | ||
76 | #define PDM_DN4_EN 0x0040 | ||
77 | #define PDM_DN5_EN 0x0080 | ||
78 | #define PDMOUTFORMAT 0x0100 | ||
79 | #define CMD_INT 0x0200 | ||
80 | #define STATUS_INT 0x0400 | ||
81 | #define SW_UP_RST 0x0800 | ||
82 | #define SW_DN_RST 0x1000 | ||
83 | #define PDM_UP_MASK 0x007 | ||
84 | #define PDM_DN_MASK 0x0F8 | ||
85 | #define PDM_CMD_MASK 0x200 | ||
86 | #define PDM_STATUS_MASK 0x400 | ||
87 | |||
88 | |||
89 | #define PDMOUTFORMAT_LJUST (0 << 8) | ||
90 | #define PDMOUTFORMAT_RJUST (1 << 8) | ||
91 | |||
92 | /* | ||
93 | * MCPDM_FIFO_CTRL bit fields | ||
94 | */ | ||
95 | |||
96 | #define UP_THRES_MAX 0xF | ||
97 | #define DN_THRES_MAX 0xF | ||
98 | |||
99 | /* | ||
100 | * MCPDM_DN_OFFSET bit fields | ||
101 | */ | ||
102 | |||
103 | #define DN_OFST_RX1_EN 0x0001 | ||
104 | #define DN_OFST_RX2_EN 0x0100 | ||
105 | |||
106 | #define DN_OFST_RX1 1 | ||
107 | #define DN_OFST_RX2 9 | ||
108 | #define DN_OFST_MAX 0x1F | ||
109 | |||
110 | #define MCPDM_UPLINK 1 | ||
111 | #define MCPDM_DOWNLINK 2 | ||
112 | |||
113 | struct omap_mcpdm_link { | ||
114 | int irq_mask; | ||
115 | int threshold; | ||
116 | int format; | ||
117 | int channels; | ||
118 | }; | ||
119 | |||
120 | struct omap_mcpdm_platform_data { | ||
121 | unsigned long phys_base; | ||
122 | u16 irq; | ||
123 | }; | ||
124 | |||
125 | struct omap_mcpdm { | ||
126 | struct device *dev; | ||
127 | unsigned long phys_base; | ||
128 | void __iomem *io_base; | ||
129 | u8 free; | ||
130 | int irq; | ||
131 | |||
132 | spinlock_t lock; | ||
133 | struct omap_mcpdm_platform_data *pdata; | ||
134 | struct clk *clk; | ||
135 | struct omap_mcpdm_link *downlink; | ||
136 | struct omap_mcpdm_link *uplink; | ||
137 | struct completion irq_completion; | ||
138 | |||
139 | int dn_channels; | ||
140 | int up_channels; | ||
141 | }; | ||
142 | |||
143 | extern void omap_mcpdm_start(int stream); | ||
144 | extern void omap_mcpdm_stop(int stream); | ||
145 | extern int omap_mcpdm_capture_open(struct omap_mcpdm_link *uplink); | ||
146 | extern int omap_mcpdm_playback_open(struct omap_mcpdm_link *downlink); | ||
147 | extern int omap_mcpdm_capture_close(struct omap_mcpdm_link *uplink); | ||
148 | extern int omap_mcpdm_playback_close(struct omap_mcpdm_link *downlink); | ||
149 | extern int omap_mcpdm_request(void); | ||
150 | extern void omap_mcpdm_free(void); | ||
151 | extern int omap_mcpdm_set_offset(int offset1, int offset2); | ||
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 6bbbd2ab0ee7..e814a9591f78 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
@@ -39,6 +39,14 @@ | |||
39 | 39 | ||
40 | #define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000) | 40 | #define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000) |
41 | 41 | ||
42 | #define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \ | ||
43 | xhandler_get, xhandler_put) \ | ||
44 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | ||
45 | .info = omap_mcbsp_st_info_volsw, \ | ||
46 | .get = xhandler_get, .put = xhandler_put, \ | ||
47 | .private_value = (unsigned long) &(struct soc_mixer_control) \ | ||
48 | {.min = xmin, .max = xmax} } | ||
49 | |||
42 | struct omap_mcbsp_data { | 50 | struct omap_mcbsp_data { |
43 | unsigned int bus_id; | 51 | unsigned int bus_id; |
44 | struct omap_mcbsp_reg_cfg regs; | 52 | struct omap_mcbsp_reg_cfg regs; |
@@ -82,11 +90,11 @@ static const int omap1_dma_reqs[][2] = {}; | |||
82 | static const unsigned long omap1_mcbsp_port[][2] = {}; | 90 | static const unsigned long omap1_mcbsp_port[][2] = {}; |
83 | #endif | 91 | #endif |
84 | 92 | ||
85 | #if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) | 93 | #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) |
86 | static const int omap24xx_dma_reqs[][2] = { | 94 | static const int omap24xx_dma_reqs[][2] = { |
87 | { OMAP24XX_DMA_MCBSP1_TX, OMAP24XX_DMA_MCBSP1_RX }, | 95 | { OMAP24XX_DMA_MCBSP1_TX, OMAP24XX_DMA_MCBSP1_RX }, |
88 | { OMAP24XX_DMA_MCBSP2_TX, OMAP24XX_DMA_MCBSP2_RX }, | 96 | { OMAP24XX_DMA_MCBSP2_TX, OMAP24XX_DMA_MCBSP2_RX }, |
89 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) | 97 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) |
90 | { OMAP24XX_DMA_MCBSP3_TX, OMAP24XX_DMA_MCBSP3_RX }, | 98 | { OMAP24XX_DMA_MCBSP3_TX, OMAP24XX_DMA_MCBSP3_RX }, |
91 | { OMAP24XX_DMA_MCBSP4_TX, OMAP24XX_DMA_MCBSP4_RX }, | 99 | { OMAP24XX_DMA_MCBSP4_TX, OMAP24XX_DMA_MCBSP4_RX }, |
92 | { OMAP24XX_DMA_MCBSP5_TX, OMAP24XX_DMA_MCBSP5_RX }, | 100 | { OMAP24XX_DMA_MCBSP5_TX, OMAP24XX_DMA_MCBSP5_RX }, |
@@ -124,7 +132,7 @@ static const unsigned long omap2430_mcbsp_port[][2] = { | |||
124 | static const unsigned long omap2430_mcbsp_port[][2] = {}; | 132 | static const unsigned long omap2430_mcbsp_port[][2] = {}; |
125 | #endif | 133 | #endif |
126 | 134 | ||
127 | #if defined(CONFIG_ARCH_OMAP34XX) | 135 | #if defined(CONFIG_ARCH_OMAP3) |
128 | static const unsigned long omap34xx_mcbsp_port[][2] = { | 136 | static const unsigned long omap34xx_mcbsp_port[][2] = { |
129 | { OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR, | 137 | { OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR, |
130 | OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR }, | 138 | OMAP34XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR }, |
@@ -287,6 +295,8 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, | |||
287 | omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma; | 295 | omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma; |
288 | omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port; | 296 | omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port; |
289 | omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode; | 297 | omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode; |
298 | omap_mcbsp_dai_dma_params[id][substream->stream].data_type = | ||
299 | OMAP_DMA_DATA_TYPE_S16; | ||
290 | cpu_dai->dma_data = &omap_mcbsp_dai_dma_params[id][substream->stream]; | 300 | cpu_dai->dma_data = &omap_mcbsp_dai_dma_params[id][substream->stream]; |
291 | 301 | ||
292 | if (mcbsp_data->configured) { | 302 | if (mcbsp_data->configured) { |
@@ -637,6 +647,136 @@ struct snd_soc_dai omap_mcbsp_dai[] = { | |||
637 | 647 | ||
638 | EXPORT_SYMBOL_GPL(omap_mcbsp_dai); | 648 | EXPORT_SYMBOL_GPL(omap_mcbsp_dai); |
639 | 649 | ||
650 | int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol, | ||
651 | struct snd_ctl_elem_info *uinfo) | ||
652 | { | ||
653 | struct soc_mixer_control *mc = | ||
654 | (struct soc_mixer_control *)kcontrol->private_value; | ||
655 | int max = mc->max; | ||
656 | int min = mc->min; | ||
657 | |||
658 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
659 | uinfo->count = 1; | ||
660 | uinfo->value.integer.min = min; | ||
661 | uinfo->value.integer.max = max; | ||
662 | return 0; | ||
663 | } | ||
664 | |||
665 | #define OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(id, channel) \ | ||
666 | static int \ | ||
667 | omap_mcbsp##id##_set_st_ch##channel##_volume(struct snd_kcontrol *kc, \ | ||
668 | struct snd_ctl_elem_value *uc) \ | ||
669 | { \ | ||
670 | struct soc_mixer_control *mc = \ | ||
671 | (struct soc_mixer_control *)kc->private_value; \ | ||
672 | int max = mc->max; \ | ||
673 | int min = mc->min; \ | ||
674 | int val = uc->value.integer.value[0]; \ | ||
675 | \ | ||
676 | if (val < min || val > max) \ | ||
677 | return -EINVAL; \ | ||
678 | \ | ||
679 | /* OMAP McBSP implementation uses index values 0..4 */ \ | ||
680 | return omap_st_set_chgain((id)-1, channel, val); \ | ||
681 | } | ||
682 | |||
683 | #define OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(id, channel) \ | ||
684 | static int \ | ||
685 | omap_mcbsp##id##_get_st_ch##channel##_volume(struct snd_kcontrol *kc, \ | ||
686 | struct snd_ctl_elem_value *uc) \ | ||
687 | { \ | ||
688 | s16 chgain; \ | ||
689 | \ | ||
690 | if (omap_st_get_chgain((id)-1, channel, &chgain)) \ | ||
691 | return -EAGAIN; \ | ||
692 | \ | ||
693 | uc->value.integer.value[0] = chgain; \ | ||
694 | return 0; \ | ||
695 | } | ||
696 | |||
697 | OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 0) | ||
698 | OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 1) | ||
699 | OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 0) | ||
700 | OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 1) | ||
701 | OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 0) | ||
702 | OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 1) | ||
703 | OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 0) | ||
704 | OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 1) | ||
705 | |||
706 | static int omap_mcbsp_st_put_mode(struct snd_kcontrol *kcontrol, | ||
707 | struct snd_ctl_elem_value *ucontrol) | ||
708 | { | ||
709 | struct soc_mixer_control *mc = | ||
710 | (struct soc_mixer_control *)kcontrol->private_value; | ||
711 | u8 value = ucontrol->value.integer.value[0]; | ||
712 | |||
713 | if (value == omap_st_is_enabled(mc->reg)) | ||
714 | return 0; | ||
715 | |||
716 | if (value) | ||
717 | omap_st_enable(mc->reg); | ||
718 | else | ||
719 | omap_st_disable(mc->reg); | ||
720 | |||
721 | return 1; | ||
722 | } | ||
723 | |||
724 | static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol, | ||
725 | struct snd_ctl_elem_value *ucontrol) | ||
726 | { | ||
727 | struct soc_mixer_control *mc = | ||
728 | (struct soc_mixer_control *)kcontrol->private_value; | ||
729 | |||
730 | ucontrol->value.integer.value[0] = omap_st_is_enabled(mc->reg); | ||
731 | return 0; | ||
732 | } | ||
733 | |||
734 | static const struct snd_kcontrol_new omap_mcbsp2_st_controls[] = { | ||
735 | SOC_SINGLE_EXT("McBSP2 Sidetone Switch", 1, 0, 1, 0, | ||
736 | omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode), | ||
737 | OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 0 Volume", | ||
738 | -32768, 32767, | ||
739 | omap_mcbsp2_get_st_ch0_volume, | ||
740 | omap_mcbsp2_set_st_ch0_volume), | ||
741 | OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 1 Volume", | ||
742 | -32768, 32767, | ||
743 | omap_mcbsp2_get_st_ch1_volume, | ||
744 | omap_mcbsp2_set_st_ch1_volume), | ||
745 | }; | ||
746 | |||
747 | static const struct snd_kcontrol_new omap_mcbsp3_st_controls[] = { | ||
748 | SOC_SINGLE_EXT("McBSP3 Sidetone Switch", 2, 0, 1, 0, | ||
749 | omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode), | ||
750 | OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 0 Volume", | ||
751 | -32768, 32767, | ||
752 | omap_mcbsp3_get_st_ch0_volume, | ||
753 | omap_mcbsp3_set_st_ch0_volume), | ||
754 | OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 1 Volume", | ||
755 | -32768, 32767, | ||
756 | omap_mcbsp3_get_st_ch1_volume, | ||
757 | omap_mcbsp3_set_st_ch1_volume), | ||
758 | }; | ||
759 | |||
760 | int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id) | ||
761 | { | ||
762 | if (!cpu_is_omap34xx()) | ||
763 | return -ENODEV; | ||
764 | |||
765 | switch (mcbsp_id) { | ||
766 | case 1: /* McBSP 2 */ | ||
767 | return snd_soc_add_controls(codec, omap_mcbsp2_st_controls, | ||
768 | ARRAY_SIZE(omap_mcbsp2_st_controls)); | ||
769 | case 2: /* McBSP 3 */ | ||
770 | return snd_soc_add_controls(codec, omap_mcbsp3_st_controls, | ||
771 | ARRAY_SIZE(omap_mcbsp3_st_controls)); | ||
772 | default: | ||
773 | break; | ||
774 | } | ||
775 | |||
776 | return -EINVAL; | ||
777 | } | ||
778 | EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls); | ||
779 | |||
640 | static int __init snd_omap_mcbsp_init(void) | 780 | static int __init snd_omap_mcbsp_init(void) |
641 | { | 781 | { |
642 | return snd_soc_register_dais(omap_mcbsp_dai, | 782 | return snd_soc_register_dais(omap_mcbsp_dai, |
diff --git a/sound/soc/omap/omap-mcbsp.h b/sound/soc/omap/omap-mcbsp.h index 647d2f981ab0..6c363e5f4387 100644 --- a/sound/soc/omap/omap-mcbsp.h +++ b/sound/soc/omap/omap-mcbsp.h | |||
@@ -50,11 +50,13 @@ enum omap_mcbsp_div { | |||
50 | #undef NUM_LINKS | 50 | #undef NUM_LINKS |
51 | #define NUM_LINKS 3 | 51 | #define NUM_LINKS 3 |
52 | #endif | 52 | #endif |
53 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) | 53 | #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) |
54 | #undef NUM_LINKS | 54 | #undef NUM_LINKS |
55 | #define NUM_LINKS 5 | 55 | #define NUM_LINKS 5 |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | extern struct snd_soc_dai omap_mcbsp_dai[NUM_LINKS]; | 58 | extern struct snd_soc_dai omap_mcbsp_dai[NUM_LINKS]; |
59 | 59 | ||
60 | int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id); | ||
61 | |||
60 | #endif | 62 | #endif |
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c new file mode 100644 index 000000000000..25f19e4728bf --- /dev/null +++ b/sound/soc/omap/omap-mcpdm.c | |||
@@ -0,0 +1,251 @@ | |||
1 | /* | ||
2 | * omap-mcpdm.c -- OMAP ALSA SoC DAI driver using McPDM port | ||
3 | * | ||
4 | * Copyright (C) 2009 Texas Instruments | ||
5 | * | ||
6 | * Author: Misael Lopez Cruz <x0052729@ti.com> | ||
7 | * Contact: Jorge Eduardo Candelaria <x0107209@ti.com> | ||
8 | * Margarita Olaya <magi.olaya@ti.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * version 2 as published by the Free Software Foundation. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
22 | * 02110-1301 USA | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #include <linux/init.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/device.h> | ||
29 | #include <sound/core.h> | ||
30 | #include <sound/pcm.h> | ||
31 | #include <sound/pcm_params.h> | ||
32 | #include <sound/initval.h> | ||
33 | #include <sound/soc.h> | ||
34 | |||
35 | #include <plat/control.h> | ||
36 | #include <plat/dma.h> | ||
37 | #include <plat/mcbsp.h> | ||
38 | #include "mcpdm.h" | ||
39 | #include "omap-mcpdm.h" | ||
40 | #include "omap-pcm.h" | ||
41 | |||
42 | struct omap_mcpdm_data { | ||
43 | struct omap_mcpdm_link *links; | ||
44 | int active; | ||
45 | }; | ||
46 | |||
47 | static struct omap_mcpdm_link omap_mcpdm_links[] = { | ||
48 | /* downlink */ | ||
49 | { | ||
50 | .irq_mask = MCPDM_DN_IRQ_EMPTY | MCPDM_DN_IRQ_FULL, | ||
51 | .threshold = 1, | ||
52 | .format = PDMOUTFORMAT_LJUST, | ||
53 | }, | ||
54 | /* uplink */ | ||
55 | { | ||
56 | .irq_mask = MCPDM_UP_IRQ_EMPTY | MCPDM_UP_IRQ_FULL, | ||
57 | .threshold = 1, | ||
58 | .format = PDMOUTFORMAT_LJUST, | ||
59 | }, | ||
60 | }; | ||
61 | |||
62 | static struct omap_mcpdm_data mcpdm_data = { | ||
63 | .links = omap_mcpdm_links, | ||
64 | .active = 0, | ||
65 | }; | ||
66 | |||
67 | /* | ||
68 | * Stream DMA parameters | ||
69 | */ | ||
70 | static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = { | ||
71 | { | ||
72 | .name = "Audio playback", | ||
73 | .dma_req = OMAP44XX_DMA_MCPDM_DL, | ||
74 | .data_type = OMAP_DMA_DATA_TYPE_S32, | ||
75 | .sync_mode = OMAP_DMA_SYNC_PACKET, | ||
76 | .packet_size = 16, | ||
77 | .port_addr = OMAP44XX_MCPDM_L3_BASE + MCPDM_DN_DATA, | ||
78 | }, | ||
79 | { | ||
80 | .name = "Audio capture", | ||
81 | .dma_req = OMAP44XX_DMA_MCPDM_UP, | ||
82 | .data_type = OMAP_DMA_DATA_TYPE_S32, | ||
83 | .sync_mode = OMAP_DMA_SYNC_PACKET, | ||
84 | .packet_size = 16, | ||
85 | .port_addr = OMAP44XX_MCPDM_L3_BASE + MCPDM_UP_DATA, | ||
86 | }, | ||
87 | }; | ||
88 | |||
89 | static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream, | ||
90 | struct snd_soc_dai *dai) | ||
91 | { | ||
92 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
93 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
94 | int err = 0; | ||
95 | |||
96 | if (!cpu_dai->active) | ||
97 | err = omap_mcpdm_request(); | ||
98 | |||
99 | return err; | ||
100 | } | ||
101 | |||
102 | static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream, | ||
103 | struct snd_soc_dai *dai) | ||
104 | { | ||
105 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
106 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
107 | |||
108 | if (!cpu_dai->active) | ||
109 | omap_mcpdm_free(); | ||
110 | } | ||
111 | |||
112 | static int omap_mcpdm_dai_trigger(struct snd_pcm_substream *substream, int cmd, | ||
113 | struct snd_soc_dai *dai) | ||
114 | { | ||
115 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
116 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
117 | struct omap_mcpdm_data *mcpdm_priv = cpu_dai->private_data; | ||
118 | int stream = substream->stream; | ||
119 | int err = 0; | ||
120 | |||
121 | switch (cmd) { | ||
122 | case SNDRV_PCM_TRIGGER_START: | ||
123 | case SNDRV_PCM_TRIGGER_RESUME: | ||
124 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
125 | if (!mcpdm_priv->active++) | ||
126 | omap_mcpdm_start(stream); | ||
127 | break; | ||
128 | |||
129 | case SNDRV_PCM_TRIGGER_STOP: | ||
130 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
131 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
132 | if (!--mcpdm_priv->active) | ||
133 | omap_mcpdm_stop(stream); | ||
134 | break; | ||
135 | default: | ||
136 | err = -EINVAL; | ||
137 | } | ||
138 | |||
139 | return err; | ||
140 | } | ||
141 | |||
142 | static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream, | ||
143 | struct snd_pcm_hw_params *params, | ||
144 | struct snd_soc_dai *dai) | ||
145 | { | ||
146 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
147 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
148 | struct omap_mcpdm_data *mcpdm_priv = cpu_dai->private_data; | ||
149 | struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links; | ||
150 | int stream = substream->stream; | ||
151 | int channels, err, link_mask = 0; | ||
152 | |||
153 | cpu_dai->dma_data = &omap_mcpdm_dai_dma_params[stream]; | ||
154 | |||
155 | channels = params_channels(params); | ||
156 | switch (channels) { | ||
157 | case 4: | ||
158 | if (stream == SNDRV_PCM_STREAM_CAPTURE) | ||
159 | /* up to 2 channels for capture */ | ||
160 | return -EINVAL; | ||
161 | link_mask |= 1 << 3; | ||
162 | case 3: | ||
163 | if (stream == SNDRV_PCM_STREAM_CAPTURE) | ||
164 | /* up to 2 channels for capture */ | ||
165 | return -EINVAL; | ||
166 | link_mask |= 1 << 2; | ||
167 | case 2: | ||
168 | link_mask |= 1 << 1; | ||
169 | case 1: | ||
170 | link_mask |= 1 << 0; | ||
171 | break; | ||
172 | default: | ||
173 | /* unsupported number of channels */ | ||
174 | return -EINVAL; | ||
175 | } | ||
176 | |||
177 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
178 | mcpdm_links[stream].channels = link_mask << 3; | ||
179 | err = omap_mcpdm_playback_open(&mcpdm_links[stream]); | ||
180 | } else { | ||
181 | mcpdm_links[stream].channels = link_mask << 0; | ||
182 | err = omap_mcpdm_capture_open(&mcpdm_links[stream]); | ||
183 | } | ||
184 | |||
185 | return err; | ||
186 | } | ||
187 | |||
188 | static int omap_mcpdm_dai_hw_free(struct snd_pcm_substream *substream, | ||
189 | struct snd_soc_dai *dai) | ||
190 | { | ||
191 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
192 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
193 | struct omap_mcpdm_data *mcpdm_priv = cpu_dai->private_data; | ||
194 | struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links; | ||
195 | int stream = substream->stream; | ||
196 | int err; | ||
197 | |||
198 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
199 | err = omap_mcpdm_playback_close(&mcpdm_links[stream]); | ||
200 | else | ||
201 | err = omap_mcpdm_capture_close(&mcpdm_links[stream]); | ||
202 | |||
203 | return err; | ||
204 | } | ||
205 | |||
206 | static struct snd_soc_dai_ops omap_mcpdm_dai_ops = { | ||
207 | .startup = omap_mcpdm_dai_startup, | ||
208 | .shutdown = omap_mcpdm_dai_shutdown, | ||
209 | .trigger = omap_mcpdm_dai_trigger, | ||
210 | .hw_params = omap_mcpdm_dai_hw_params, | ||
211 | .hw_free = omap_mcpdm_dai_hw_free, | ||
212 | }; | ||
213 | |||
214 | #define OMAP_MCPDM_RATES (SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) | ||
215 | #define OMAP_MCPDM_FORMATS (SNDRV_PCM_FMTBIT_S32_LE) | ||
216 | |||
217 | struct snd_soc_dai omap_mcpdm_dai = { | ||
218 | .name = "omap-mcpdm", | ||
219 | .id = -1, | ||
220 | .playback = { | ||
221 | .channels_min = 1, | ||
222 | .channels_max = 4, | ||
223 | .rates = OMAP_MCPDM_RATES, | ||
224 | .formats = OMAP_MCPDM_FORMATS, | ||
225 | }, | ||
226 | .capture = { | ||
227 | .channels_min = 1, | ||
228 | .channels_max = 2, | ||
229 | .rates = OMAP_MCPDM_RATES, | ||
230 | .formats = OMAP_MCPDM_FORMATS, | ||
231 | }, | ||
232 | .ops = &omap_mcpdm_dai_ops, | ||
233 | .private_data = &mcpdm_data, | ||
234 | }; | ||
235 | EXPORT_SYMBOL_GPL(omap_mcpdm_dai); | ||
236 | |||
237 | static int __init snd_omap_mcpdm_init(void) | ||
238 | { | ||
239 | return snd_soc_register_dai(&omap_mcpdm_dai); | ||
240 | } | ||
241 | module_init(snd_omap_mcpdm_init); | ||
242 | |||
243 | static void __exit snd_omap_mcpdm_exit(void) | ||
244 | { | ||
245 | snd_soc_unregister_dai(&omap_mcpdm_dai); | ||
246 | } | ||
247 | module_exit(snd_omap_mcpdm_exit); | ||
248 | |||
249 | MODULE_AUTHOR("Misael Lopez Cruz <x0052729@ti.com>"); | ||
250 | MODULE_DESCRIPTION("OMAP PDM SoC Interface"); | ||
251 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/omap/omap-mcpdm.h b/sound/soc/omap/omap-mcpdm.h new file mode 100644 index 000000000000..73b80d559345 --- /dev/null +++ b/sound/soc/omap/omap-mcpdm.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * omap-mcpdm.h | ||
3 | * | ||
4 | * Copyright (C) 2009 Texas Instruments | ||
5 | * | ||
6 | * Contact: Misael Lopez Cruz <x0052729@ti.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * version 2 as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
20 | * 02110-1301 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __OMAP_MCPDM_H__ | ||
25 | #define __OMAP_MCPDM_H__ | ||
26 | |||
27 | extern struct snd_soc_dai omap_mcpdm_dai; | ||
28 | |||
29 | #endif /* End of __OMAP_MCPDM_H__ */ | ||
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 9db2770e9640..825db385f01f 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c | |||
@@ -37,7 +37,8 @@ static const struct snd_pcm_hardware omap_pcm_hardware = { | |||
37 | SNDRV_PCM_INFO_INTERLEAVED | | 37 | SNDRV_PCM_INFO_INTERLEAVED | |
38 | SNDRV_PCM_INFO_PAUSE | | 38 | SNDRV_PCM_INFO_PAUSE | |
39 | SNDRV_PCM_INFO_RESUME, | 39 | SNDRV_PCM_INFO_RESUME, |
40 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 40 | .formats = SNDRV_PCM_FMTBIT_S16_LE | |
41 | SNDRV_PCM_FMTBIT_S32_LE, | ||
41 | .period_bytes_min = 32, | 42 | .period_bytes_min = 32, |
42 | .period_bytes_max = 64 * 1024, | 43 | .period_bytes_max = 64 * 1024, |
43 | .periods_min = 2, | 44 | .periods_min = 2, |
@@ -149,6 +150,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream) | |||
149 | struct omap_runtime_data *prtd = runtime->private_data; | 150 | struct omap_runtime_data *prtd = runtime->private_data; |
150 | struct omap_pcm_dma_data *dma_data = prtd->dma_data; | 151 | struct omap_pcm_dma_data *dma_data = prtd->dma_data; |
151 | struct omap_dma_channel_params dma_params; | 152 | struct omap_dma_channel_params dma_params; |
153 | int bytes; | ||
152 | 154 | ||
153 | /* return if this is a bufferless transfer e.g. | 155 | /* return if this is a bufferless transfer e.g. |
154 | * codec <--> BT codec or GSM modem -- lg FIXME */ | 156 | * codec <--> BT codec or GSM modem -- lg FIXME */ |
@@ -156,11 +158,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream) | |||
156 | return 0; | 158 | return 0; |
157 | 159 | ||
158 | memset(&dma_params, 0, sizeof(dma_params)); | 160 | memset(&dma_params, 0, sizeof(dma_params)); |
159 | /* | 161 | dma_params.data_type = dma_data->data_type; |
160 | * Note: Regardless of interface data formats supported by OMAP McBSP | ||
161 | * or EAC blocks, internal representation is always fixed 16-bit/sample | ||
162 | */ | ||
163 | dma_params.data_type = OMAP_DMA_DATA_TYPE_S16; | ||
164 | dma_params.trigger = dma_data->dma_req; | 162 | dma_params.trigger = dma_data->dma_req; |
165 | dma_params.sync_mode = dma_data->sync_mode; | 163 | dma_params.sync_mode = dma_data->sync_mode; |
166 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 164 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
@@ -170,6 +168,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream) | |||
170 | dma_params.src_start = runtime->dma_addr; | 168 | dma_params.src_start = runtime->dma_addr; |
171 | dma_params.dst_start = dma_data->port_addr; | 169 | dma_params.dst_start = dma_data->port_addr; |
172 | dma_params.dst_port = OMAP_DMA_PORT_MPUI; | 170 | dma_params.dst_port = OMAP_DMA_PORT_MPUI; |
171 | dma_params.dst_fi = dma_data->packet_size; | ||
173 | } else { | 172 | } else { |
174 | dma_params.src_amode = OMAP_DMA_AMODE_CONSTANT; | 173 | dma_params.src_amode = OMAP_DMA_AMODE_CONSTANT; |
175 | dma_params.dst_amode = OMAP_DMA_AMODE_POST_INC; | 174 | dma_params.dst_amode = OMAP_DMA_AMODE_POST_INC; |
@@ -177,6 +176,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream) | |||
177 | dma_params.src_start = dma_data->port_addr; | 176 | dma_params.src_start = dma_data->port_addr; |
178 | dma_params.dst_start = runtime->dma_addr; | 177 | dma_params.dst_start = runtime->dma_addr; |
179 | dma_params.src_port = OMAP_DMA_PORT_MPUI; | 178 | dma_params.src_port = OMAP_DMA_PORT_MPUI; |
179 | dma_params.src_fi = dma_data->packet_size; | ||
180 | } | 180 | } |
181 | /* | 181 | /* |
182 | * Set DMA transfer frame size equal to ALSA period size and frame | 182 | * Set DMA transfer frame size equal to ALSA period size and frame |
@@ -184,7 +184,8 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream) | |||
184 | * we can transfer the whole ALSA buffer with single DMA transfer but | 184 | * we can transfer the whole ALSA buffer with single DMA transfer but |
185 | * still can get an interrupt at each period bounary | 185 | * still can get an interrupt at each period bounary |
186 | */ | 186 | */ |
187 | dma_params.elem_count = snd_pcm_lib_period_bytes(substream) / 2; | 187 | bytes = snd_pcm_lib_period_bytes(substream); |
188 | dma_params.elem_count = bytes >> dma_data->data_type; | ||
188 | dma_params.frame_count = runtime->periods; | 189 | dma_params.frame_count = runtime->periods; |
189 | omap_set_dma_params(prtd->dma_ch, &dma_params); | 190 | omap_set_dma_params(prtd->dma_ch, &dma_params); |
190 | 191 | ||
diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h index 38a821dd4118..b19975d26907 100644 --- a/sound/soc/omap/omap-pcm.h +++ b/sound/soc/omap/omap-pcm.h | |||
@@ -29,8 +29,10 @@ struct omap_pcm_dma_data { | |||
29 | char *name; /* stream identifier */ | 29 | char *name; /* stream identifier */ |
30 | int dma_req; /* DMA request line */ | 30 | int dma_req; /* DMA request line */ |
31 | unsigned long port_addr; /* transmit/receive register */ | 31 | unsigned long port_addr; /* transmit/receive register */ |
32 | int sync_mode; /* DMA sync mode */ | ||
33 | void (*set_threshold)(struct snd_pcm_substream *substream); | 32 | void (*set_threshold)(struct snd_pcm_substream *substream); |
33 | int data_type; /* data type 8,16,32 */ | ||
34 | int sync_mode; /* DMA sync mode */ | ||
35 | int packet_size; /* packet size only in PACKET mode */ | ||
34 | }; | 36 | }; |
35 | 37 | ||
36 | extern struct snd_soc_platform omap_soc_platform; | 38 | extern struct snd_soc_platform omap_soc_platform; |
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 3c36d24a6c20..993abb730dfa 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c | |||
@@ -388,7 +388,7 @@ static void fsi_soft_all_reset(struct fsi_master *master) | |||
388 | } | 388 | } |
389 | 389 | ||
390 | /* playback interrupt */ | 390 | /* playback interrupt */ |
391 | static int fsi_data_push(struct fsi_priv *fsi) | 391 | static int fsi_data_push(struct fsi_priv *fsi, int startup) |
392 | { | 392 | { |
393 | struct snd_pcm_runtime *runtime; | 393 | struct snd_pcm_runtime *runtime; |
394 | struct snd_pcm_substream *substream = NULL; | 394 | struct snd_pcm_substream *substream = NULL; |
@@ -397,7 +397,7 @@ static int fsi_data_push(struct fsi_priv *fsi) | |||
397 | int fifo_free; | 397 | int fifo_free; |
398 | int width; | 398 | int width; |
399 | u8 *start; | 399 | u8 *start; |
400 | int i, ret, over_period; | 400 | int i, over_period; |
401 | 401 | ||
402 | if (!fsi || | 402 | if (!fsi || |
403 | !fsi->substream || | 403 | !fsi->substream || |
@@ -453,24 +453,26 @@ static int fsi_data_push(struct fsi_priv *fsi) | |||
453 | 453 | ||
454 | fsi->byte_offset += send * width; | 454 | fsi->byte_offset += send * width; |
455 | 455 | ||
456 | ret = 0; | ||
457 | status = fsi_reg_read(fsi, DOFF_ST); | 456 | status = fsi_reg_read(fsi, DOFF_ST); |
458 | if (status & ERR_OVER) { | 457 | if (!startup) { |
459 | struct snd_soc_dai *dai = fsi_get_dai(substream); | 458 | struct snd_soc_dai *dai = fsi_get_dai(substream); |
460 | dev_err(dai->dev, "over run error\n"); | 459 | |
461 | fsi_reg_write(fsi, DOFF_ST, status & ~ST_ERR); | 460 | if (status & ERR_OVER) |
462 | ret = -EIO; | 461 | dev_err(dai->dev, "over run\n"); |
462 | if (status & ERR_UNDER) | ||
463 | dev_err(dai->dev, "under run\n"); | ||
463 | } | 464 | } |
465 | fsi_reg_write(fsi, DOFF_ST, 0); | ||
464 | 466 | ||
465 | fsi_irq_enable(fsi, 1); | 467 | fsi_irq_enable(fsi, 1); |
466 | 468 | ||
467 | if (over_period) | 469 | if (over_period) |
468 | snd_pcm_period_elapsed(substream); | 470 | snd_pcm_period_elapsed(substream); |
469 | 471 | ||
470 | return ret; | 472 | return 0; |
471 | } | 473 | } |
472 | 474 | ||
473 | static int fsi_data_pop(struct fsi_priv *fsi) | 475 | static int fsi_data_pop(struct fsi_priv *fsi, int startup) |
474 | { | 476 | { |
475 | struct snd_pcm_runtime *runtime; | 477 | struct snd_pcm_runtime *runtime; |
476 | struct snd_pcm_substream *substream = NULL; | 478 | struct snd_pcm_substream *substream = NULL; |
@@ -479,7 +481,7 @@ static int fsi_data_pop(struct fsi_priv *fsi) | |||
479 | int fifo_fill; | 481 | int fifo_fill; |
480 | int width; | 482 | int width; |
481 | u8 *start; | 483 | u8 *start; |
482 | int i, ret, over_period; | 484 | int i, over_period; |
483 | 485 | ||
484 | if (!fsi || | 486 | if (!fsi || |
485 | !fsi->substream || | 487 | !fsi->substream || |
@@ -534,21 +536,23 @@ static int fsi_data_pop(struct fsi_priv *fsi) | |||
534 | 536 | ||
535 | fsi->byte_offset += fifo_fill * width; | 537 | fsi->byte_offset += fifo_fill * width; |
536 | 538 | ||
537 | ret = 0; | ||
538 | status = fsi_reg_read(fsi, DIFF_ST); | 539 | status = fsi_reg_read(fsi, DIFF_ST); |
539 | if (status & ERR_UNDER) { | 540 | if (!startup) { |
540 | struct snd_soc_dai *dai = fsi_get_dai(substream); | 541 | struct snd_soc_dai *dai = fsi_get_dai(substream); |
541 | dev_err(dai->dev, "under run error\n"); | 542 | |
542 | fsi_reg_write(fsi, DIFF_ST, status & ~ST_ERR); | 543 | if (status & ERR_OVER) |
543 | ret = -EIO; | 544 | dev_err(dai->dev, "over run\n"); |
545 | if (status & ERR_UNDER) | ||
546 | dev_err(dai->dev, "under run\n"); | ||
544 | } | 547 | } |
548 | fsi_reg_write(fsi, DIFF_ST, 0); | ||
545 | 549 | ||
546 | fsi_irq_enable(fsi, 0); | 550 | fsi_irq_enable(fsi, 0); |
547 | 551 | ||
548 | if (over_period) | 552 | if (over_period) |
549 | snd_pcm_period_elapsed(substream); | 553 | snd_pcm_period_elapsed(substream); |
550 | 554 | ||
551 | return ret; | 555 | return 0; |
552 | } | 556 | } |
553 | 557 | ||
554 | static irqreturn_t fsi_interrupt(int irq, void *data) | 558 | static irqreturn_t fsi_interrupt(int irq, void *data) |
@@ -562,13 +566,13 @@ static irqreturn_t fsi_interrupt(int irq, void *data) | |||
562 | fsi_master_write(master, SOFT_RST, status | 0x00000010); | 566 | fsi_master_write(master, SOFT_RST, status | 0x00000010); |
563 | 567 | ||
564 | if (int_st & INT_A_OUT) | 568 | if (int_st & INT_A_OUT) |
565 | fsi_data_push(&master->fsia); | 569 | fsi_data_push(&master->fsia, 0); |
566 | if (int_st & INT_B_OUT) | 570 | if (int_st & INT_B_OUT) |
567 | fsi_data_push(&master->fsib); | 571 | fsi_data_push(&master->fsib, 0); |
568 | if (int_st & INT_A_IN) | 572 | if (int_st & INT_A_IN) |
569 | fsi_data_pop(&master->fsia); | 573 | fsi_data_pop(&master->fsia, 0); |
570 | if (int_st & INT_B_IN) | 574 | if (int_st & INT_B_IN) |
571 | fsi_data_pop(&master->fsib); | 575 | fsi_data_pop(&master->fsib, 0); |
572 | 576 | ||
573 | fsi_master_write(master, INT_ST, 0x0000000); | 577 | fsi_master_write(master, INT_ST, 0x0000000); |
574 | 578 | ||
@@ -726,7 +730,7 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd, | |||
726 | fsi_stream_push(fsi, substream, | 730 | fsi_stream_push(fsi, substream, |
727 | frames_to_bytes(runtime, runtime->buffer_size), | 731 | frames_to_bytes(runtime, runtime->buffer_size), |
728 | frames_to_bytes(runtime, runtime->period_size)); | 732 | frames_to_bytes(runtime, runtime->period_size)); |
729 | ret = is_play ? fsi_data_push(fsi) : fsi_data_pop(fsi); | 733 | ret = is_play ? fsi_data_push(fsi, 1) : fsi_data_pop(fsi, 1); |
730 | break; | 734 | break; |
731 | case SNDRV_PCM_TRIGGER_STOP: | 735 | case SNDRV_PCM_TRIGGER_STOP: |
732 | fsi_irq_disable(fsi, is_play); | 736 | fsi_irq_disable(fsi, is_play); |
diff --git a/sound/soc/sh/siu.h b/sound/soc/sh/siu.h index 9cc04ab2bce7..c0bfab8fed3d 100644 --- a/sound/soc/sh/siu.h +++ b/sound/soc/sh/siu.h | |||
@@ -72,7 +72,7 @@ struct siu_firmware { | |||
72 | #include <linux/interrupt.h> | 72 | #include <linux/interrupt.h> |
73 | #include <linux/io.h> | 73 | #include <linux/io.h> |
74 | 74 | ||
75 | #include <asm/dma-sh.h> | 75 | #include <asm/dmaengine.h> |
76 | 76 | ||
77 | #include <sound/core.h> | 77 | #include <sound/core.h> |
78 | #include <sound/pcm.h> | 78 | #include <sound/pcm.h> |
diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c index c5efc30f0136..ba7f8d05d977 100644 --- a/sound/soc/sh/siu_pcm.c +++ b/sound/soc/sh/siu_pcm.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <sound/pcm_params.h> | 32 | #include <sound/pcm_params.h> |
33 | #include <sound/soc-dai.h> | 33 | #include <sound/soc-dai.h> |
34 | 34 | ||
35 | #include <asm/dma-sh.h> | 35 | #include <asm/dmaengine.h> |
36 | #include <asm/siu.h> | 36 | #include <asm/siu.h> |
37 | 37 | ||
38 | #include "siu.h" | 38 | #include "siu.h" |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4011ad3dc57a..06c38d1502b7 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -427,24 +427,24 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
427 | if (!runtime->hw.rates) { | 427 | if (!runtime->hw.rates) { |
428 | printk(KERN_ERR "asoc: %s <-> %s No matching rates\n", | 428 | printk(KERN_ERR "asoc: %s <-> %s No matching rates\n", |
429 | codec_dai->name, cpu_dai->name); | 429 | codec_dai->name, cpu_dai->name); |
430 | goto machine_err; | 430 | goto config_err; |
431 | } | 431 | } |
432 | if (!runtime->hw.formats) { | 432 | if (!runtime->hw.formats) { |
433 | printk(KERN_ERR "asoc: %s <-> %s No matching formats\n", | 433 | printk(KERN_ERR "asoc: %s <-> %s No matching formats\n", |
434 | codec_dai->name, cpu_dai->name); | 434 | codec_dai->name, cpu_dai->name); |
435 | goto machine_err; | 435 | goto config_err; |
436 | } | 436 | } |
437 | if (!runtime->hw.channels_min || !runtime->hw.channels_max) { | 437 | if (!runtime->hw.channels_min || !runtime->hw.channels_max) { |
438 | printk(KERN_ERR "asoc: %s <-> %s No matching channels\n", | 438 | printk(KERN_ERR "asoc: %s <-> %s No matching channels\n", |
439 | codec_dai->name, cpu_dai->name); | 439 | codec_dai->name, cpu_dai->name); |
440 | goto machine_err; | 440 | goto config_err; |
441 | } | 441 | } |
442 | 442 | ||
443 | /* Symmetry only applies if we've already got an active stream. */ | 443 | /* Symmetry only applies if we've already got an active stream. */ |
444 | if (cpu_dai->active || codec_dai->active) { | 444 | if (cpu_dai->active || codec_dai->active) { |
445 | ret = soc_pcm_apply_symmetry(substream); | 445 | ret = soc_pcm_apply_symmetry(substream); |
446 | if (ret != 0) | 446 | if (ret != 0) |
447 | goto machine_err; | 447 | goto config_err; |
448 | } | 448 | } |
449 | 449 | ||
450 | pr_debug("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name); | 450 | pr_debug("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name); |
@@ -467,10 +467,14 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
467 | mutex_unlock(&pcm_mutex); | 467 | mutex_unlock(&pcm_mutex); |
468 | return 0; | 468 | return 0; |
469 | 469 | ||
470 | machine_err: | 470 | config_err: |
471 | if (machine->ops && machine->ops->shutdown) | 471 | if (machine->ops && machine->ops->shutdown) |
472 | machine->ops->shutdown(substream); | 472 | machine->ops->shutdown(substream); |
473 | 473 | ||
474 | machine_err: | ||
475 | if (codec_dai->ops->shutdown) | ||
476 | codec_dai->ops->shutdown(substream, codec_dai); | ||
477 | |||
474 | codec_dai_err: | 478 | codec_dai_err: |
475 | if (platform->pcm_ops->close) | 479 | if (platform->pcm_ops->close) |
476 | platform->pcm_ops->close(substream); | 480 | platform->pcm_ops->close(substream); |
@@ -1002,6 +1006,12 @@ static int soc_resume(struct device *dev) | |||
1002 | struct snd_soc_card *card = socdev->card; | 1006 | struct snd_soc_card *card = socdev->card; |
1003 | struct snd_soc_dai *cpu_dai = card->dai_link[0].cpu_dai; | 1007 | struct snd_soc_dai *cpu_dai = card->dai_link[0].cpu_dai; |
1004 | 1008 | ||
1009 | /* If the initialization of this soc device failed, there is no codec | ||
1010 | * associated with it. Just bail out in this case. | ||
1011 | */ | ||
1012 | if (!card->codec) | ||
1013 | return 0; | ||
1014 | |||
1005 | /* AC97 devices might have other drivers hanging off them so | 1015 | /* AC97 devices might have other drivers hanging off them so |
1006 | * need to resume immediately. Other drivers don't have that | 1016 | * need to resume immediately. Other drivers don't have that |
1007 | * problem and may take a substantial amount of time to resume | 1017 | * problem and may take a substantial amount of time to resume |
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig index 73525c048e7f..c570ae3e6d55 100644 --- a/sound/usb/Kconfig +++ b/sound/usb/Kconfig | |||
@@ -21,6 +21,18 @@ config SND_USB_AUDIO | |||
21 | To compile this driver as a module, choose M here: the module | 21 | To compile this driver as a module, choose M here: the module |
22 | will be called snd-usb-audio. | 22 | will be called snd-usb-audio. |
23 | 23 | ||
24 | config SND_USB_UA101 | ||
25 | tristate "Edirol UA-101/UA-1000 driver (EXPERIMENTAL)" | ||
26 | depends on EXPERIMENTAL | ||
27 | select SND_PCM | ||
28 | select SND_RAWMIDI | ||
29 | help | ||
30 | Say Y here to include support for the Edirol UA-101 and UA-1000 | ||
31 | audio/MIDI interfaces. | ||
32 | |||
33 | To compile this driver as a module, choose M here: the module | ||
34 | will be called snd-ua101. | ||
35 | |||
24 | config SND_USB_USX2Y | 36 | config SND_USB_USX2Y |
25 | tristate "Tascam US-122, US-224 and US-428 USB driver" | 37 | tristate "Tascam US-122, US-224 and US-428 USB driver" |
26 | depends on X86 || PPC || ALPHA | 38 | depends on X86 || PPC || ALPHA |
diff --git a/sound/usb/Makefile b/sound/usb/Makefile index abb288bfe35d..5bf64aef9558 100644 --- a/sound/usb/Makefile +++ b/sound/usb/Makefile | |||
@@ -4,9 +4,11 @@ | |||
4 | 4 | ||
5 | snd-usb-audio-objs := usbaudio.o usbmixer.o | 5 | snd-usb-audio-objs := usbaudio.o usbmixer.o |
6 | snd-usb-lib-objs := usbmidi.o | 6 | snd-usb-lib-objs := usbmidi.o |
7 | snd-ua101-objs := ua101.o | ||
7 | 8 | ||
8 | # Toplevel Module Dependency | 9 | # Toplevel Module Dependency |
9 | obj-$(CONFIG_SND_USB_AUDIO) += snd-usb-audio.o snd-usb-lib.o | 10 | obj-$(CONFIG_SND_USB_AUDIO) += snd-usb-audio.o snd-usb-lib.o |
11 | obj-$(CONFIG_SND_USB_UA101) += snd-ua101.o snd-usb-lib.o | ||
10 | obj-$(CONFIG_SND_USB_USX2Y) += snd-usb-lib.o | 12 | obj-$(CONFIG_SND_USB_USX2Y) += snd-usb-lib.o |
11 | obj-$(CONFIG_SND_USB_US122L) += snd-usb-lib.o | 13 | obj-$(CONFIG_SND_USB_US122L) += snd-usb-lib.o |
12 | 14 | ||
diff --git a/sound/usb/caiaq/midi.h b/sound/usb/caiaq/midi.h index 9d16db027fc3..380f984babc9 100644 --- a/sound/usb/caiaq/midi.h +++ b/sound/usb/caiaq/midi.h | |||
@@ -3,6 +3,6 @@ | |||
3 | 3 | ||
4 | int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *dev); | 4 | int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *dev); |
5 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, int port, const char *buf, int len); | 5 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, int port, const char *buf, int len); |
6 | void snd_usb_caiaq_midi_output_done(struct urb* urb); | 6 | void snd_usb_caiaq_midi_output_done(struct urb *urb); |
7 | 7 | ||
8 | #endif /* CAIAQ_MIDI_H */ | 8 | #endif /* CAIAQ_MIDI_H */ |
diff --git a/sound/usb/ua101.c b/sound/usb/ua101.c new file mode 100644 index 000000000000..3d458d3b9962 --- /dev/null +++ b/sound/usb/ua101.c | |||
@@ -0,0 +1,1387 @@ | |||
1 | /* | ||
2 | * Edirol UA-101/UA-1000 driver | ||
3 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> | ||
4 | * | ||
5 | * This driver is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License, version 2. | ||
7 | * | ||
8 | * This driver is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this driver. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include <linux/init.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/usb.h> | ||
21 | #include <linux/usb/audio.h> | ||
22 | #include <sound/core.h> | ||
23 | #include <sound/initval.h> | ||
24 | #include <sound/pcm.h> | ||
25 | #include <sound/pcm_params.h> | ||
26 | #include "usbaudio.h" | ||
27 | |||
28 | MODULE_DESCRIPTION("Edirol UA-101/1000 driver"); | ||
29 | MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); | ||
30 | MODULE_LICENSE("GPL v2"); | ||
31 | MODULE_SUPPORTED_DEVICE("{{Edirol,UA-101},{Edirol,UA-1000}}"); | ||
32 | |||
33 | /* | ||
34 | * Should not be lower than the minimum scheduling delay of the host | ||
35 | * controller. Some Intel controllers need more than one frame; as long as | ||
36 | * that driver doesn't tell us about this, use 1.5 frames just to be sure. | ||
37 | */ | ||
38 | #define MIN_QUEUE_LENGTH 12 | ||
39 | /* Somewhat random. */ | ||
40 | #define MAX_QUEUE_LENGTH 30 | ||
41 | /* | ||
42 | * This magic value optimizes memory usage efficiency for the UA-101's packet | ||
43 | * sizes at all sample rates, taking into account the stupid cache pool sizes | ||
44 | * that usb_buffer_alloc() uses. | ||
45 | */ | ||
46 | #define DEFAULT_QUEUE_LENGTH 21 | ||
47 | |||
48 | #define MAX_PACKET_SIZE 672 /* hardware specific */ | ||
49 | #define MAX_MEMORY_BUFFERS DIV_ROUND_UP(MAX_QUEUE_LENGTH, \ | ||
50 | PAGE_SIZE / MAX_PACKET_SIZE) | ||
51 | |||
52 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | ||
53 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; | ||
54 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; | ||
55 | static unsigned int queue_length = 21; | ||
56 | |||
57 | module_param_array(index, int, NULL, 0444); | ||
58 | MODULE_PARM_DESC(index, "card index"); | ||
59 | module_param_array(id, charp, NULL, 0444); | ||
60 | MODULE_PARM_DESC(id, "ID string"); | ||
61 | module_param_array(enable, bool, NULL, 0444); | ||
62 | MODULE_PARM_DESC(enable, "enable card"); | ||
63 | module_param(queue_length, uint, 0644); | ||
64 | MODULE_PARM_DESC(queue_length, "USB queue length in microframes, " | ||
65 | __stringify(MIN_QUEUE_LENGTH)"-"__stringify(MAX_QUEUE_LENGTH)); | ||
66 | |||
67 | enum { | ||
68 | INTF_PLAYBACK, | ||
69 | INTF_CAPTURE, | ||
70 | INTF_MIDI, | ||
71 | |||
72 | INTF_COUNT | ||
73 | }; | ||
74 | |||
75 | /* bits in struct ua101::states */ | ||
76 | enum { | ||
77 | USB_CAPTURE_RUNNING, | ||
78 | USB_PLAYBACK_RUNNING, | ||
79 | ALSA_CAPTURE_OPEN, | ||
80 | ALSA_PLAYBACK_OPEN, | ||
81 | ALSA_CAPTURE_RUNNING, | ||
82 | ALSA_PLAYBACK_RUNNING, | ||
83 | CAPTURE_URB_COMPLETED, | ||
84 | PLAYBACK_URB_COMPLETED, | ||
85 | DISCONNECTED, | ||
86 | }; | ||
87 | |||
88 | struct ua101 { | ||
89 | struct usb_device *dev; | ||
90 | struct snd_card *card; | ||
91 | struct usb_interface *intf[INTF_COUNT]; | ||
92 | int card_index; | ||
93 | struct snd_pcm *pcm; | ||
94 | struct list_head midi_list; | ||
95 | u64 format_bit; | ||
96 | unsigned int rate; | ||
97 | unsigned int packets_per_second; | ||
98 | spinlock_t lock; | ||
99 | struct mutex mutex; | ||
100 | unsigned long states; | ||
101 | |||
102 | /* FIFO to synchronize playback rate to capture rate */ | ||
103 | unsigned int rate_feedback_start; | ||
104 | unsigned int rate_feedback_count; | ||
105 | u8 rate_feedback[MAX_QUEUE_LENGTH]; | ||
106 | |||
107 | struct list_head ready_playback_urbs; | ||
108 | struct tasklet_struct playback_tasklet; | ||
109 | wait_queue_head_t alsa_capture_wait; | ||
110 | wait_queue_head_t rate_feedback_wait; | ||
111 | wait_queue_head_t alsa_playback_wait; | ||
112 | struct ua101_stream { | ||
113 | struct snd_pcm_substream *substream; | ||
114 | unsigned int usb_pipe; | ||
115 | unsigned int channels; | ||
116 | unsigned int frame_bytes; | ||
117 | unsigned int max_packet_bytes; | ||
118 | unsigned int period_pos; | ||
119 | unsigned int buffer_pos; | ||
120 | unsigned int queue_length; | ||
121 | struct ua101_urb { | ||
122 | struct urb urb; | ||
123 | struct usb_iso_packet_descriptor iso_frame_desc[1]; | ||
124 | struct list_head ready_list; | ||
125 | } *urbs[MAX_QUEUE_LENGTH]; | ||
126 | struct { | ||
127 | unsigned int size; | ||
128 | void *addr; | ||
129 | dma_addr_t dma; | ||
130 | } buffers[MAX_MEMORY_BUFFERS]; | ||
131 | } capture, playback; | ||
132 | }; | ||
133 | |||
134 | static DEFINE_MUTEX(devices_mutex); | ||
135 | static unsigned int devices_used; | ||
136 | static struct usb_driver ua101_driver; | ||
137 | |||
138 | static void abort_alsa_playback(struct ua101 *ua); | ||
139 | static void abort_alsa_capture(struct ua101 *ua); | ||
140 | |||
141 | static const char *usb_error_string(int err) | ||
142 | { | ||
143 | switch (err) { | ||
144 | case -ENODEV: | ||
145 | return "no device"; | ||
146 | case -ENOENT: | ||
147 | return "endpoint not enabled"; | ||
148 | case -EPIPE: | ||
149 | return "endpoint stalled"; | ||
150 | case -ENOSPC: | ||
151 | return "not enough bandwidth"; | ||
152 | case -ESHUTDOWN: | ||
153 | return "device disabled"; | ||
154 | case -EHOSTUNREACH: | ||
155 | return "device suspended"; | ||
156 | case -EINVAL: | ||
157 | case -EAGAIN: | ||
158 | case -EFBIG: | ||
159 | case -EMSGSIZE: | ||
160 | return "internal error"; | ||
161 | default: | ||
162 | return "unknown error"; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | static void abort_usb_capture(struct ua101 *ua) | ||
167 | { | ||
168 | if (test_and_clear_bit(USB_CAPTURE_RUNNING, &ua->states)) { | ||
169 | wake_up(&ua->alsa_capture_wait); | ||
170 | wake_up(&ua->rate_feedback_wait); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | static void abort_usb_playback(struct ua101 *ua) | ||
175 | { | ||
176 | if (test_and_clear_bit(USB_PLAYBACK_RUNNING, &ua->states)) | ||
177 | wake_up(&ua->alsa_playback_wait); | ||
178 | } | ||
179 | |||
180 | static void playback_urb_complete(struct urb *usb_urb) | ||
181 | { | ||
182 | struct ua101_urb *urb = (struct ua101_urb *)usb_urb; | ||
183 | struct ua101 *ua = urb->urb.context; | ||
184 | unsigned long flags; | ||
185 | |||
186 | if (unlikely(urb->urb.status == -ENOENT || /* unlinked */ | ||
187 | urb->urb.status == -ENODEV || /* device removed */ | ||
188 | urb->urb.status == -ECONNRESET || /* unlinked */ | ||
189 | urb->urb.status == -ESHUTDOWN)) { /* device disabled */ | ||
190 | abort_usb_playback(ua); | ||
191 | abort_alsa_playback(ua); | ||
192 | return; | ||
193 | } | ||
194 | |||
195 | if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) { | ||
196 | /* append URB to FIFO */ | ||
197 | spin_lock_irqsave(&ua->lock, flags); | ||
198 | list_add_tail(&urb->ready_list, &ua->ready_playback_urbs); | ||
199 | if (ua->rate_feedback_count > 0) | ||
200 | tasklet_schedule(&ua->playback_tasklet); | ||
201 | ua->playback.substream->runtime->delay -= | ||
202 | urb->urb.iso_frame_desc[0].length / | ||
203 | ua->playback.frame_bytes; | ||
204 | spin_unlock_irqrestore(&ua->lock, flags); | ||
205 | } | ||
206 | } | ||
207 | |||
208 | static void first_playback_urb_complete(struct urb *urb) | ||
209 | { | ||
210 | struct ua101 *ua = urb->context; | ||
211 | |||
212 | urb->complete = playback_urb_complete; | ||
213 | playback_urb_complete(urb); | ||
214 | |||
215 | set_bit(PLAYBACK_URB_COMPLETED, &ua->states); | ||
216 | wake_up(&ua->alsa_playback_wait); | ||
217 | } | ||
218 | |||
219 | /* copy data from the ALSA ring buffer into the URB buffer */ | ||
220 | static bool copy_playback_data(struct ua101_stream *stream, struct urb *urb, | ||
221 | unsigned int frames) | ||
222 | { | ||
223 | struct snd_pcm_runtime *runtime; | ||
224 | unsigned int frame_bytes, frames1; | ||
225 | const u8 *source; | ||
226 | |||
227 | runtime = stream->substream->runtime; | ||
228 | frame_bytes = stream->frame_bytes; | ||
229 | source = runtime->dma_area + stream->buffer_pos * frame_bytes; | ||
230 | if (stream->buffer_pos + frames <= runtime->buffer_size) { | ||
231 | memcpy(urb->transfer_buffer, source, frames * frame_bytes); | ||
232 | } else { | ||
233 | /* wrap around at end of ring buffer */ | ||
234 | frames1 = runtime->buffer_size - stream->buffer_pos; | ||
235 | memcpy(urb->transfer_buffer, source, frames1 * frame_bytes); | ||
236 | memcpy(urb->transfer_buffer + frames1 * frame_bytes, | ||
237 | runtime->dma_area, (frames - frames1) * frame_bytes); | ||
238 | } | ||
239 | |||
240 | stream->buffer_pos += frames; | ||
241 | if (stream->buffer_pos >= runtime->buffer_size) | ||
242 | stream->buffer_pos -= runtime->buffer_size; | ||
243 | stream->period_pos += frames; | ||
244 | if (stream->period_pos >= runtime->period_size) { | ||
245 | stream->period_pos -= runtime->period_size; | ||
246 | return true; | ||
247 | } | ||
248 | return false; | ||
249 | } | ||
250 | |||
251 | static inline void add_with_wraparound(struct ua101 *ua, | ||
252 | unsigned int *value, unsigned int add) | ||
253 | { | ||
254 | *value += add; | ||
255 | if (*value >= ua->playback.queue_length) | ||
256 | *value -= ua->playback.queue_length; | ||
257 | } | ||
258 | |||
259 | static void playback_tasklet(unsigned long data) | ||
260 | { | ||
261 | struct ua101 *ua = (void *)data; | ||
262 | unsigned long flags; | ||
263 | unsigned int frames; | ||
264 | struct ua101_urb *urb; | ||
265 | bool do_period_elapsed = false; | ||
266 | int err; | ||
267 | |||
268 | if (unlikely(!test_bit(USB_PLAYBACK_RUNNING, &ua->states))) | ||
269 | return; | ||
270 | |||
271 | /* | ||
272 | * Synchronizing the playback rate to the capture rate is done by using | ||
273 | * the same sequence of packet sizes for both streams. | ||
274 | * Submitting a playback URB therefore requires both a ready URB and | ||
275 | * the size of the corresponding capture packet, i.e., both playback | ||
276 | * and capture URBs must have been completed. Since the USB core does | ||
277 | * not guarantee that playback and capture complete callbacks are | ||
278 | * called alternately, we use two FIFOs for packet sizes and read URBs; | ||
279 | * submitting playback URBs is possible as long as both FIFOs are | ||
280 | * nonempty. | ||
281 | */ | ||
282 | spin_lock_irqsave(&ua->lock, flags); | ||
283 | while (ua->rate_feedback_count > 0 && | ||
284 | !list_empty(&ua->ready_playback_urbs)) { | ||
285 | /* take packet size out of FIFO */ | ||
286 | frames = ua->rate_feedback[ua->rate_feedback_start]; | ||
287 | add_with_wraparound(ua, &ua->rate_feedback_start, 1); | ||
288 | ua->rate_feedback_count--; | ||
289 | |||
290 | /* take URB out of FIFO */ | ||
291 | urb = list_first_entry(&ua->ready_playback_urbs, | ||
292 | struct ua101_urb, ready_list); | ||
293 | list_del(&urb->ready_list); | ||
294 | |||
295 | /* fill packet with data or silence */ | ||
296 | urb->urb.iso_frame_desc[0].length = | ||
297 | frames * ua->playback.frame_bytes; | ||
298 | if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) | ||
299 | do_period_elapsed |= copy_playback_data(&ua->playback, | ||
300 | &urb->urb, | ||
301 | frames); | ||
302 | else | ||
303 | memset(urb->urb.transfer_buffer, 0, | ||
304 | urb->urb.iso_frame_desc[0].length); | ||
305 | |||
306 | /* and off you go ... */ | ||
307 | err = usb_submit_urb(&urb->urb, GFP_ATOMIC); | ||
308 | if (unlikely(err < 0)) { | ||
309 | spin_unlock_irqrestore(&ua->lock, flags); | ||
310 | abort_usb_playback(ua); | ||
311 | abort_alsa_playback(ua); | ||
312 | dev_err(&ua->dev->dev, "USB request error %d: %s\n", | ||
313 | err, usb_error_string(err)); | ||
314 | return; | ||
315 | } | ||
316 | ua->playback.substream->runtime->delay += frames; | ||
317 | } | ||
318 | spin_unlock_irqrestore(&ua->lock, flags); | ||
319 | if (do_period_elapsed) | ||
320 | snd_pcm_period_elapsed(ua->playback.substream); | ||
321 | } | ||
322 | |||
323 | /* copy data from the URB buffer into the ALSA ring buffer */ | ||
324 | static bool copy_capture_data(struct ua101_stream *stream, struct urb *urb, | ||
325 | unsigned int frames) | ||
326 | { | ||
327 | struct snd_pcm_runtime *runtime; | ||
328 | unsigned int frame_bytes, frames1; | ||
329 | u8 *dest; | ||
330 | |||
331 | runtime = stream->substream->runtime; | ||
332 | frame_bytes = stream->frame_bytes; | ||
333 | dest = runtime->dma_area + stream->buffer_pos * frame_bytes; | ||
334 | if (stream->buffer_pos + frames <= runtime->buffer_size) { | ||
335 | memcpy(dest, urb->transfer_buffer, frames * frame_bytes); | ||
336 | } else { | ||
337 | /* wrap around at end of ring buffer */ | ||
338 | frames1 = runtime->buffer_size - stream->buffer_pos; | ||
339 | memcpy(dest, urb->transfer_buffer, frames1 * frame_bytes); | ||
340 | memcpy(runtime->dma_area, | ||
341 | urb->transfer_buffer + frames1 * frame_bytes, | ||
342 | (frames - frames1) * frame_bytes); | ||
343 | } | ||
344 | |||
345 | stream->buffer_pos += frames; | ||
346 | if (stream->buffer_pos >= runtime->buffer_size) | ||
347 | stream->buffer_pos -= runtime->buffer_size; | ||
348 | stream->period_pos += frames; | ||
349 | if (stream->period_pos >= runtime->period_size) { | ||
350 | stream->period_pos -= runtime->period_size; | ||
351 | return true; | ||
352 | } | ||
353 | return false; | ||
354 | } | ||
355 | |||
356 | static void capture_urb_complete(struct urb *urb) | ||
357 | { | ||
358 | struct ua101 *ua = urb->context; | ||
359 | struct ua101_stream *stream = &ua->capture; | ||
360 | unsigned long flags; | ||
361 | unsigned int frames, write_ptr; | ||
362 | bool do_period_elapsed; | ||
363 | int err; | ||
364 | |||
365 | if (unlikely(urb->status == -ENOENT || /* unlinked */ | ||
366 | urb->status == -ENODEV || /* device removed */ | ||
367 | urb->status == -ECONNRESET || /* unlinked */ | ||
368 | urb->status == -ESHUTDOWN)) /* device disabled */ | ||
369 | goto stream_stopped; | ||
370 | |||
371 | if (urb->status >= 0 && urb->iso_frame_desc[0].status >= 0) | ||
372 | frames = urb->iso_frame_desc[0].actual_length / | ||
373 | stream->frame_bytes; | ||
374 | else | ||
375 | frames = 0; | ||
376 | |||
377 | spin_lock_irqsave(&ua->lock, flags); | ||
378 | |||
379 | if (frames > 0 && test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) | ||
380 | do_period_elapsed = copy_capture_data(stream, urb, frames); | ||
381 | else | ||
382 | do_period_elapsed = false; | ||
383 | |||
384 | if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) { | ||
385 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
386 | if (unlikely(err < 0)) { | ||
387 | spin_unlock_irqrestore(&ua->lock, flags); | ||
388 | dev_err(&ua->dev->dev, "USB request error %d: %s\n", | ||
389 | err, usb_error_string(err)); | ||
390 | goto stream_stopped; | ||
391 | } | ||
392 | |||
393 | /* append packet size to FIFO */ | ||
394 | write_ptr = ua->rate_feedback_start; | ||
395 | add_with_wraparound(ua, &write_ptr, ua->rate_feedback_count); | ||
396 | ua->rate_feedback[write_ptr] = frames; | ||
397 | if (ua->rate_feedback_count < ua->playback.queue_length) { | ||
398 | ua->rate_feedback_count++; | ||
399 | if (ua->rate_feedback_count == | ||
400 | ua->playback.queue_length) | ||
401 | wake_up(&ua->rate_feedback_wait); | ||
402 | } else { | ||
403 | /* | ||
404 | * Ring buffer overflow; this happens when the playback | ||
405 | * stream is not running. Throw away the oldest entry, | ||
406 | * so that the playback stream, when it starts, sees | ||
407 | * the most recent packet sizes. | ||
408 | */ | ||
409 | add_with_wraparound(ua, &ua->rate_feedback_start, 1); | ||
410 | } | ||
411 | if (test_bit(USB_PLAYBACK_RUNNING, &ua->states) && | ||
412 | !list_empty(&ua->ready_playback_urbs)) | ||
413 | tasklet_schedule(&ua->playback_tasklet); | ||
414 | } | ||
415 | |||
416 | spin_unlock_irqrestore(&ua->lock, flags); | ||
417 | |||
418 | if (do_period_elapsed) | ||
419 | snd_pcm_period_elapsed(stream->substream); | ||
420 | |||
421 | return; | ||
422 | |||
423 | stream_stopped: | ||
424 | abort_usb_playback(ua); | ||
425 | abort_usb_capture(ua); | ||
426 | abort_alsa_playback(ua); | ||
427 | abort_alsa_capture(ua); | ||
428 | } | ||
429 | |||
430 | static void first_capture_urb_complete(struct urb *urb) | ||
431 | { | ||
432 | struct ua101 *ua = urb->context; | ||
433 | |||
434 | urb->complete = capture_urb_complete; | ||
435 | capture_urb_complete(urb); | ||
436 | |||
437 | set_bit(CAPTURE_URB_COMPLETED, &ua->states); | ||
438 | wake_up(&ua->alsa_capture_wait); | ||
439 | } | ||
440 | |||
441 | static int submit_stream_urbs(struct ua101 *ua, struct ua101_stream *stream) | ||
442 | { | ||
443 | unsigned int i; | ||
444 | |||
445 | for (i = 0; i < stream->queue_length; ++i) { | ||
446 | int err = usb_submit_urb(&stream->urbs[i]->urb, GFP_KERNEL); | ||
447 | if (err < 0) { | ||
448 | dev_err(&ua->dev->dev, "USB request error %d: %s\n", | ||
449 | err, usb_error_string(err)); | ||
450 | return err; | ||
451 | } | ||
452 | } | ||
453 | return 0; | ||
454 | } | ||
455 | |||
456 | static void kill_stream_urbs(struct ua101_stream *stream) | ||
457 | { | ||
458 | unsigned int i; | ||
459 | |||
460 | for (i = 0; i < stream->queue_length; ++i) | ||
461 | usb_kill_urb(&stream->urbs[i]->urb); | ||
462 | } | ||
463 | |||
464 | static int enable_iso_interface(struct ua101 *ua, unsigned int intf_index) | ||
465 | { | ||
466 | struct usb_host_interface *alts; | ||
467 | |||
468 | alts = ua->intf[intf_index]->cur_altsetting; | ||
469 | if (alts->desc.bAlternateSetting != 1) { | ||
470 | int err = usb_set_interface(ua->dev, | ||
471 | alts->desc.bInterfaceNumber, 1); | ||
472 | if (err < 0) { | ||
473 | dev_err(&ua->dev->dev, | ||
474 | "cannot initialize interface; error %d: %s\n", | ||
475 | err, usb_error_string(err)); | ||
476 | return err; | ||
477 | } | ||
478 | } | ||
479 | return 0; | ||
480 | } | ||
481 | |||
482 | static void disable_iso_interface(struct ua101 *ua, unsigned int intf_index) | ||
483 | { | ||
484 | struct usb_host_interface *alts; | ||
485 | |||
486 | alts = ua->intf[intf_index]->cur_altsetting; | ||
487 | if (alts->desc.bAlternateSetting != 0) { | ||
488 | int err = usb_set_interface(ua->dev, | ||
489 | alts->desc.bInterfaceNumber, 0); | ||
490 | if (err < 0 && !test_bit(DISCONNECTED, &ua->states)) | ||
491 | dev_warn(&ua->dev->dev, | ||
492 | "interface reset failed; error %d: %s\n", | ||
493 | err, usb_error_string(err)); | ||
494 | } | ||
495 | } | ||
496 | |||
497 | static void stop_usb_capture(struct ua101 *ua) | ||
498 | { | ||
499 | clear_bit(USB_CAPTURE_RUNNING, &ua->states); | ||
500 | |||
501 | kill_stream_urbs(&ua->capture); | ||
502 | |||
503 | disable_iso_interface(ua, INTF_CAPTURE); | ||
504 | } | ||
505 | |||
506 | static int start_usb_capture(struct ua101 *ua) | ||
507 | { | ||
508 | int err; | ||
509 | |||
510 | if (test_bit(DISCONNECTED, &ua->states)) | ||
511 | return -ENODEV; | ||
512 | |||
513 | if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) | ||
514 | return 0; | ||
515 | |||
516 | kill_stream_urbs(&ua->capture); | ||
517 | |||
518 | err = enable_iso_interface(ua, INTF_CAPTURE); | ||
519 | if (err < 0) | ||
520 | return err; | ||
521 | |||
522 | clear_bit(CAPTURE_URB_COMPLETED, &ua->states); | ||
523 | ua->capture.urbs[0]->urb.complete = first_capture_urb_complete; | ||
524 | ua->rate_feedback_start = 0; | ||
525 | ua->rate_feedback_count = 0; | ||
526 | |||
527 | set_bit(USB_CAPTURE_RUNNING, &ua->states); | ||
528 | err = submit_stream_urbs(ua, &ua->capture); | ||
529 | if (err < 0) | ||
530 | stop_usb_capture(ua); | ||
531 | return err; | ||
532 | } | ||
533 | |||
534 | static void stop_usb_playback(struct ua101 *ua) | ||
535 | { | ||
536 | clear_bit(USB_PLAYBACK_RUNNING, &ua->states); | ||
537 | |||
538 | kill_stream_urbs(&ua->playback); | ||
539 | |||
540 | tasklet_kill(&ua->playback_tasklet); | ||
541 | |||
542 | disable_iso_interface(ua, INTF_PLAYBACK); | ||
543 | } | ||
544 | |||
545 | static int start_usb_playback(struct ua101 *ua) | ||
546 | { | ||
547 | unsigned int i, frames; | ||
548 | struct urb *urb; | ||
549 | int err = 0; | ||
550 | |||
551 | if (test_bit(DISCONNECTED, &ua->states)) | ||
552 | return -ENODEV; | ||
553 | |||
554 | if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) | ||
555 | return 0; | ||
556 | |||
557 | kill_stream_urbs(&ua->playback); | ||
558 | tasklet_kill(&ua->playback_tasklet); | ||
559 | |||
560 | err = enable_iso_interface(ua, INTF_PLAYBACK); | ||
561 | if (err < 0) | ||
562 | return err; | ||
563 | |||
564 | clear_bit(PLAYBACK_URB_COMPLETED, &ua->states); | ||
565 | ua->playback.urbs[0]->urb.complete = | ||
566 | first_playback_urb_complete; | ||
567 | spin_lock_irq(&ua->lock); | ||
568 | INIT_LIST_HEAD(&ua->ready_playback_urbs); | ||
569 | spin_unlock_irq(&ua->lock); | ||
570 | |||
571 | /* | ||
572 | * We submit the initial URBs all at once, so we have to wait for the | ||
573 | * packet size FIFO to be full. | ||
574 | */ | ||
575 | wait_event(ua->rate_feedback_wait, | ||
576 | ua->rate_feedback_count >= ua->playback.queue_length || | ||
577 | !test_bit(USB_CAPTURE_RUNNING, &ua->states) || | ||
578 | test_bit(DISCONNECTED, &ua->states)); | ||
579 | if (test_bit(DISCONNECTED, &ua->states)) { | ||
580 | stop_usb_playback(ua); | ||
581 | return -ENODEV; | ||
582 | } | ||
583 | if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) { | ||
584 | stop_usb_playback(ua); | ||
585 | return -EIO; | ||
586 | } | ||
587 | |||
588 | for (i = 0; i < ua->playback.queue_length; ++i) { | ||
589 | /* all initial URBs contain silence */ | ||
590 | spin_lock_irq(&ua->lock); | ||
591 | frames = ua->rate_feedback[ua->rate_feedback_start]; | ||
592 | add_with_wraparound(ua, &ua->rate_feedback_start, 1); | ||
593 | ua->rate_feedback_count--; | ||
594 | spin_unlock_irq(&ua->lock); | ||
595 | urb = &ua->playback.urbs[i]->urb; | ||
596 | urb->iso_frame_desc[0].length = | ||
597 | frames * ua->playback.frame_bytes; | ||
598 | memset(urb->transfer_buffer, 0, | ||
599 | urb->iso_frame_desc[0].length); | ||
600 | } | ||
601 | |||
602 | set_bit(USB_PLAYBACK_RUNNING, &ua->states); | ||
603 | err = submit_stream_urbs(ua, &ua->playback); | ||
604 | if (err < 0) | ||
605 | stop_usb_playback(ua); | ||
606 | return err; | ||
607 | } | ||
608 | |||
609 | static void abort_alsa_capture(struct ua101 *ua) | ||
610 | { | ||
611 | if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) | ||
612 | snd_pcm_stop(ua->capture.substream, SNDRV_PCM_STATE_XRUN); | ||
613 | } | ||
614 | |||
615 | static void abort_alsa_playback(struct ua101 *ua) | ||
616 | { | ||
617 | if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) | ||
618 | snd_pcm_stop(ua->playback.substream, SNDRV_PCM_STATE_XRUN); | ||
619 | } | ||
620 | |||
621 | static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream, | ||
622 | unsigned int channels) | ||
623 | { | ||
624 | int err; | ||
625 | |||
626 | substream->runtime->hw.info = | ||
627 | SNDRV_PCM_INFO_MMAP | | ||
628 | SNDRV_PCM_INFO_MMAP_VALID | | ||
629 | SNDRV_PCM_INFO_BATCH | | ||
630 | SNDRV_PCM_INFO_INTERLEAVED | | ||
631 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
632 | SNDRV_PCM_INFO_FIFO_IN_FRAMES; | ||
633 | substream->runtime->hw.formats = ua->format_bit; | ||
634 | substream->runtime->hw.rates = snd_pcm_rate_to_rate_bit(ua->rate); | ||
635 | substream->runtime->hw.rate_min = ua->rate; | ||
636 | substream->runtime->hw.rate_max = ua->rate; | ||
637 | substream->runtime->hw.channels_min = channels; | ||
638 | substream->runtime->hw.channels_max = channels; | ||
639 | substream->runtime->hw.buffer_bytes_max = 45000 * 1024; | ||
640 | substream->runtime->hw.period_bytes_min = 1; | ||
641 | substream->runtime->hw.period_bytes_max = UINT_MAX; | ||
642 | substream->runtime->hw.periods_min = 2; | ||
643 | substream->runtime->hw.periods_max = UINT_MAX; | ||
644 | err = snd_pcm_hw_constraint_minmax(substream->runtime, | ||
645 | SNDRV_PCM_HW_PARAM_PERIOD_TIME, | ||
646 | 1500000 / ua->packets_per_second, | ||
647 | 8192000); | ||
648 | if (err < 0) | ||
649 | return err; | ||
650 | err = snd_pcm_hw_constraint_msbits(substream->runtime, 0, 32, 24); | ||
651 | return err; | ||
652 | } | ||
653 | |||
654 | static int capture_pcm_open(struct snd_pcm_substream *substream) | ||
655 | { | ||
656 | struct ua101 *ua = substream->private_data; | ||
657 | int err; | ||
658 | |||
659 | ua->capture.substream = substream; | ||
660 | err = set_stream_hw(ua, substream, ua->capture.channels); | ||
661 | if (err < 0) | ||
662 | return err; | ||
663 | substream->runtime->hw.fifo_size = | ||
664 | DIV_ROUND_CLOSEST(ua->rate, ua->packets_per_second); | ||
665 | substream->runtime->delay = substream->runtime->hw.fifo_size; | ||
666 | |||
667 | mutex_lock(&ua->mutex); | ||
668 | err = start_usb_capture(ua); | ||
669 | if (err >= 0) | ||
670 | set_bit(ALSA_CAPTURE_OPEN, &ua->states); | ||
671 | mutex_unlock(&ua->mutex); | ||
672 | return err; | ||
673 | } | ||
674 | |||
675 | static int playback_pcm_open(struct snd_pcm_substream *substream) | ||
676 | { | ||
677 | struct ua101 *ua = substream->private_data; | ||
678 | int err; | ||
679 | |||
680 | ua->playback.substream = substream; | ||
681 | err = set_stream_hw(ua, substream, ua->playback.channels); | ||
682 | if (err < 0) | ||
683 | return err; | ||
684 | substream->runtime->hw.fifo_size = | ||
685 | DIV_ROUND_CLOSEST(ua->rate * ua->playback.queue_length, | ||
686 | ua->packets_per_second); | ||
687 | |||
688 | mutex_lock(&ua->mutex); | ||
689 | err = start_usb_capture(ua); | ||
690 | if (err < 0) | ||
691 | goto error; | ||
692 | err = start_usb_playback(ua); | ||
693 | if (err < 0) { | ||
694 | if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states)) | ||
695 | stop_usb_capture(ua); | ||
696 | goto error; | ||
697 | } | ||
698 | set_bit(ALSA_PLAYBACK_OPEN, &ua->states); | ||
699 | error: | ||
700 | mutex_unlock(&ua->mutex); | ||
701 | return err; | ||
702 | } | ||
703 | |||
704 | static int capture_pcm_close(struct snd_pcm_substream *substream) | ||
705 | { | ||
706 | struct ua101 *ua = substream->private_data; | ||
707 | |||
708 | mutex_lock(&ua->mutex); | ||
709 | clear_bit(ALSA_CAPTURE_OPEN, &ua->states); | ||
710 | if (!test_bit(ALSA_PLAYBACK_OPEN, &ua->states)) | ||
711 | stop_usb_capture(ua); | ||
712 | mutex_unlock(&ua->mutex); | ||
713 | return 0; | ||
714 | } | ||
715 | |||
716 | static int playback_pcm_close(struct snd_pcm_substream *substream) | ||
717 | { | ||
718 | struct ua101 *ua = substream->private_data; | ||
719 | |||
720 | mutex_lock(&ua->mutex); | ||
721 | stop_usb_playback(ua); | ||
722 | clear_bit(ALSA_PLAYBACK_OPEN, &ua->states); | ||
723 | if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states)) | ||
724 | stop_usb_capture(ua); | ||
725 | mutex_unlock(&ua->mutex); | ||
726 | return 0; | ||
727 | } | ||
728 | |||
729 | static int capture_pcm_hw_params(struct snd_pcm_substream *substream, | ||
730 | struct snd_pcm_hw_params *hw_params) | ||
731 | { | ||
732 | struct ua101 *ua = substream->private_data; | ||
733 | int err; | ||
734 | |||
735 | mutex_lock(&ua->mutex); | ||
736 | err = start_usb_capture(ua); | ||
737 | mutex_unlock(&ua->mutex); | ||
738 | if (err < 0) | ||
739 | return err; | ||
740 | |||
741 | return snd_pcm_lib_alloc_vmalloc_buffer(substream, | ||
742 | params_buffer_bytes(hw_params)); | ||
743 | } | ||
744 | |||
745 | static int playback_pcm_hw_params(struct snd_pcm_substream *substream, | ||
746 | struct snd_pcm_hw_params *hw_params) | ||
747 | { | ||
748 | struct ua101 *ua = substream->private_data; | ||
749 | int err; | ||
750 | |||
751 | mutex_lock(&ua->mutex); | ||
752 | err = start_usb_capture(ua); | ||
753 | if (err >= 0) | ||
754 | err = start_usb_playback(ua); | ||
755 | mutex_unlock(&ua->mutex); | ||
756 | if (err < 0) | ||
757 | return err; | ||
758 | |||
759 | return snd_pcm_lib_alloc_vmalloc_buffer(substream, | ||
760 | params_buffer_bytes(hw_params)); | ||
761 | } | ||
762 | |||
763 | static int ua101_pcm_hw_free(struct snd_pcm_substream *substream) | ||
764 | { | ||
765 | return snd_pcm_lib_free_vmalloc_buffer(substream); | ||
766 | } | ||
767 | |||
768 | static int capture_pcm_prepare(struct snd_pcm_substream *substream) | ||
769 | { | ||
770 | struct ua101 *ua = substream->private_data; | ||
771 | int err; | ||
772 | |||
773 | mutex_lock(&ua->mutex); | ||
774 | err = start_usb_capture(ua); | ||
775 | mutex_unlock(&ua->mutex); | ||
776 | if (err < 0) | ||
777 | return err; | ||
778 | |||
779 | /* | ||
780 | * The EHCI driver schedules the first packet of an iso stream at 10 ms | ||
781 | * in the future, i.e., no data is actually captured for that long. | ||
782 | * Take the wait here so that the stream is known to be actually | ||
783 | * running when the start trigger has been called. | ||
784 | */ | ||
785 | wait_event(ua->alsa_capture_wait, | ||
786 | test_bit(CAPTURE_URB_COMPLETED, &ua->states) || | ||
787 | !test_bit(USB_CAPTURE_RUNNING, &ua->states)); | ||
788 | if (test_bit(DISCONNECTED, &ua->states)) | ||
789 | return -ENODEV; | ||
790 | if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) | ||
791 | return -EIO; | ||
792 | |||
793 | ua->capture.period_pos = 0; | ||
794 | ua->capture.buffer_pos = 0; | ||
795 | return 0; | ||
796 | } | ||
797 | |||
798 | static int playback_pcm_prepare(struct snd_pcm_substream *substream) | ||
799 | { | ||
800 | struct ua101 *ua = substream->private_data; | ||
801 | int err; | ||
802 | |||
803 | mutex_lock(&ua->mutex); | ||
804 | err = start_usb_capture(ua); | ||
805 | if (err >= 0) | ||
806 | err = start_usb_playback(ua); | ||
807 | mutex_unlock(&ua->mutex); | ||
808 | if (err < 0) | ||
809 | return err; | ||
810 | |||
811 | /* see the comment in capture_pcm_prepare() */ | ||
812 | wait_event(ua->alsa_playback_wait, | ||
813 | test_bit(PLAYBACK_URB_COMPLETED, &ua->states) || | ||
814 | !test_bit(USB_PLAYBACK_RUNNING, &ua->states)); | ||
815 | if (test_bit(DISCONNECTED, &ua->states)) | ||
816 | return -ENODEV; | ||
817 | if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states)) | ||
818 | return -EIO; | ||
819 | |||
820 | substream->runtime->delay = 0; | ||
821 | ua->playback.period_pos = 0; | ||
822 | ua->playback.buffer_pos = 0; | ||
823 | return 0; | ||
824 | } | ||
825 | |||
826 | static int capture_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
827 | { | ||
828 | struct ua101 *ua = substream->private_data; | ||
829 | |||
830 | switch (cmd) { | ||
831 | case SNDRV_PCM_TRIGGER_START: | ||
832 | if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) | ||
833 | return -EIO; | ||
834 | set_bit(ALSA_CAPTURE_RUNNING, &ua->states); | ||
835 | return 0; | ||
836 | case SNDRV_PCM_TRIGGER_STOP: | ||
837 | clear_bit(ALSA_CAPTURE_RUNNING, &ua->states); | ||
838 | return 0; | ||
839 | default: | ||
840 | return -EINVAL; | ||
841 | } | ||
842 | } | ||
843 | |||
844 | static int playback_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
845 | { | ||
846 | struct ua101 *ua = substream->private_data; | ||
847 | |||
848 | switch (cmd) { | ||
849 | case SNDRV_PCM_TRIGGER_START: | ||
850 | if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states)) | ||
851 | return -EIO; | ||
852 | set_bit(ALSA_PLAYBACK_RUNNING, &ua->states); | ||
853 | return 0; | ||
854 | case SNDRV_PCM_TRIGGER_STOP: | ||
855 | clear_bit(ALSA_PLAYBACK_RUNNING, &ua->states); | ||
856 | return 0; | ||
857 | default: | ||
858 | return -EINVAL; | ||
859 | } | ||
860 | } | ||
861 | |||
862 | static inline snd_pcm_uframes_t ua101_pcm_pointer(struct ua101 *ua, | ||
863 | struct ua101_stream *stream) | ||
864 | { | ||
865 | unsigned long flags; | ||
866 | unsigned int pos; | ||
867 | |||
868 | spin_lock_irqsave(&ua->lock, flags); | ||
869 | pos = stream->buffer_pos; | ||
870 | spin_unlock_irqrestore(&ua->lock, flags); | ||
871 | return pos; | ||
872 | } | ||
873 | |||
874 | static snd_pcm_uframes_t capture_pcm_pointer(struct snd_pcm_substream *subs) | ||
875 | { | ||
876 | struct ua101 *ua = subs->private_data; | ||
877 | |||
878 | return ua101_pcm_pointer(ua, &ua->capture); | ||
879 | } | ||
880 | |||
881 | static snd_pcm_uframes_t playback_pcm_pointer(struct snd_pcm_substream *subs) | ||
882 | { | ||
883 | struct ua101 *ua = subs->private_data; | ||
884 | |||
885 | return ua101_pcm_pointer(ua, &ua->playback); | ||
886 | } | ||
887 | |||
888 | static struct snd_pcm_ops capture_pcm_ops = { | ||
889 | .open = capture_pcm_open, | ||
890 | .close = capture_pcm_close, | ||
891 | .ioctl = snd_pcm_lib_ioctl, | ||
892 | .hw_params = capture_pcm_hw_params, | ||
893 | .hw_free = ua101_pcm_hw_free, | ||
894 | .prepare = capture_pcm_prepare, | ||
895 | .trigger = capture_pcm_trigger, | ||
896 | .pointer = capture_pcm_pointer, | ||
897 | .page = snd_pcm_lib_get_vmalloc_page, | ||
898 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
899 | }; | ||
900 | |||
901 | static struct snd_pcm_ops playback_pcm_ops = { | ||
902 | .open = playback_pcm_open, | ||
903 | .close = playback_pcm_close, | ||
904 | .ioctl = snd_pcm_lib_ioctl, | ||
905 | .hw_params = playback_pcm_hw_params, | ||
906 | .hw_free = ua101_pcm_hw_free, | ||
907 | .prepare = playback_pcm_prepare, | ||
908 | .trigger = playback_pcm_trigger, | ||
909 | .pointer = playback_pcm_pointer, | ||
910 | .page = snd_pcm_lib_get_vmalloc_page, | ||
911 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
912 | }; | ||
913 | |||
914 | static const struct uac_format_type_i_discrete_descriptor * | ||
915 | find_format_descriptor(struct usb_interface *interface) | ||
916 | { | ||
917 | struct usb_host_interface *alt; | ||
918 | u8 *extra; | ||
919 | int extralen; | ||
920 | |||
921 | if (interface->num_altsetting != 2) { | ||
922 | dev_err(&interface->dev, "invalid num_altsetting\n"); | ||
923 | return NULL; | ||
924 | } | ||
925 | |||
926 | alt = &interface->altsetting[0]; | ||
927 | if (alt->desc.bNumEndpoints != 0) { | ||
928 | dev_err(&interface->dev, "invalid bNumEndpoints\n"); | ||
929 | return NULL; | ||
930 | } | ||
931 | |||
932 | alt = &interface->altsetting[1]; | ||
933 | if (alt->desc.bNumEndpoints != 1) { | ||
934 | dev_err(&interface->dev, "invalid bNumEndpoints\n"); | ||
935 | return NULL; | ||
936 | } | ||
937 | |||
938 | extra = alt->extra; | ||
939 | extralen = alt->extralen; | ||
940 | while (extralen >= sizeof(struct usb_descriptor_header)) { | ||
941 | struct uac_format_type_i_discrete_descriptor *desc; | ||
942 | |||
943 | desc = (struct uac_format_type_i_discrete_descriptor *)extra; | ||
944 | if (desc->bLength > extralen) { | ||
945 | dev_err(&interface->dev, "descriptor overflow\n"); | ||
946 | return NULL; | ||
947 | } | ||
948 | if (desc->bLength == UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(1) && | ||
949 | desc->bDescriptorType == USB_DT_CS_INTERFACE && | ||
950 | desc->bDescriptorSubtype == UAC_FORMAT_TYPE) { | ||
951 | if (desc->bFormatType != UAC_FORMAT_TYPE_I_PCM || | ||
952 | desc->bSamFreqType != 1) { | ||
953 | dev_err(&interface->dev, | ||
954 | "invalid format type\n"); | ||
955 | return NULL; | ||
956 | } | ||
957 | return desc; | ||
958 | } | ||
959 | extralen -= desc->bLength; | ||
960 | extra += desc->bLength; | ||
961 | } | ||
962 | dev_err(&interface->dev, "sample format descriptor not found\n"); | ||
963 | return NULL; | ||
964 | } | ||
965 | |||
966 | static int detect_usb_format(struct ua101 *ua) | ||
967 | { | ||
968 | const struct uac_format_type_i_discrete_descriptor *fmt_capture; | ||
969 | const struct uac_format_type_i_discrete_descriptor *fmt_playback; | ||
970 | const struct usb_endpoint_descriptor *epd; | ||
971 | unsigned int rate2; | ||
972 | |||
973 | fmt_capture = find_format_descriptor(ua->intf[INTF_CAPTURE]); | ||
974 | fmt_playback = find_format_descriptor(ua->intf[INTF_PLAYBACK]); | ||
975 | if (!fmt_capture || !fmt_playback) | ||
976 | return -ENXIO; | ||
977 | |||
978 | switch (fmt_capture->bSubframeSize) { | ||
979 | case 3: | ||
980 | ua->format_bit = SNDRV_PCM_FMTBIT_S24_3LE; | ||
981 | break; | ||
982 | case 4: | ||
983 | ua->format_bit = SNDRV_PCM_FMTBIT_S32_LE; | ||
984 | break; | ||
985 | default: | ||
986 | dev_err(&ua->dev->dev, "sample width is not 24 or 32 bits\n"); | ||
987 | return -ENXIO; | ||
988 | } | ||
989 | if (fmt_capture->bSubframeSize != fmt_playback->bSubframeSize) { | ||
990 | dev_err(&ua->dev->dev, | ||
991 | "playback/capture sample widths do not match\n"); | ||
992 | return -ENXIO; | ||
993 | } | ||
994 | |||
995 | if (fmt_capture->bBitResolution != 24 || | ||
996 | fmt_playback->bBitResolution != 24) { | ||
997 | dev_err(&ua->dev->dev, "sample width is not 24 bits\n"); | ||
998 | return -ENXIO; | ||
999 | } | ||
1000 | |||
1001 | ua->rate = combine_triple(fmt_capture->tSamFreq[0]); | ||
1002 | rate2 = combine_triple(fmt_playback->tSamFreq[0]); | ||
1003 | if (ua->rate != rate2) { | ||
1004 | dev_err(&ua->dev->dev, | ||
1005 | "playback/capture rates do not match: %u/%u\n", | ||
1006 | rate2, ua->rate); | ||
1007 | return -ENXIO; | ||
1008 | } | ||
1009 | |||
1010 | switch (ua->dev->speed) { | ||
1011 | case USB_SPEED_FULL: | ||
1012 | ua->packets_per_second = 1000; | ||
1013 | break; | ||
1014 | case USB_SPEED_HIGH: | ||
1015 | ua->packets_per_second = 8000; | ||
1016 | break; | ||
1017 | default: | ||
1018 | dev_err(&ua->dev->dev, "unknown device speed\n"); | ||
1019 | return -ENXIO; | ||
1020 | } | ||
1021 | |||
1022 | ua->capture.channels = fmt_capture->bNrChannels; | ||
1023 | ua->playback.channels = fmt_playback->bNrChannels; | ||
1024 | ua->capture.frame_bytes = | ||
1025 | fmt_capture->bSubframeSize * ua->capture.channels; | ||
1026 | ua->playback.frame_bytes = | ||
1027 | fmt_playback->bSubframeSize * ua->playback.channels; | ||
1028 | |||
1029 | epd = &ua->intf[INTF_CAPTURE]->altsetting[1].endpoint[0].desc; | ||
1030 | if (!usb_endpoint_is_isoc_in(epd)) { | ||
1031 | dev_err(&ua->dev->dev, "invalid capture endpoint\n"); | ||
1032 | return -ENXIO; | ||
1033 | } | ||
1034 | ua->capture.usb_pipe = usb_rcvisocpipe(ua->dev, usb_endpoint_num(epd)); | ||
1035 | ua->capture.max_packet_bytes = le16_to_cpu(epd->wMaxPacketSize); | ||
1036 | |||
1037 | epd = &ua->intf[INTF_PLAYBACK]->altsetting[1].endpoint[0].desc; | ||
1038 | if (!usb_endpoint_is_isoc_out(epd)) { | ||
1039 | dev_err(&ua->dev->dev, "invalid playback endpoint\n"); | ||
1040 | return -ENXIO; | ||
1041 | } | ||
1042 | ua->playback.usb_pipe = usb_sndisocpipe(ua->dev, usb_endpoint_num(epd)); | ||
1043 | ua->playback.max_packet_bytes = le16_to_cpu(epd->wMaxPacketSize); | ||
1044 | return 0; | ||
1045 | } | ||
1046 | |||
1047 | static int alloc_stream_buffers(struct ua101 *ua, struct ua101_stream *stream) | ||
1048 | { | ||
1049 | unsigned int remaining_packets, packets, packets_per_page, i; | ||
1050 | size_t size; | ||
1051 | |||
1052 | stream->queue_length = queue_length; | ||
1053 | stream->queue_length = max(stream->queue_length, | ||
1054 | (unsigned int)MIN_QUEUE_LENGTH); | ||
1055 | stream->queue_length = min(stream->queue_length, | ||
1056 | (unsigned int)MAX_QUEUE_LENGTH); | ||
1057 | |||
1058 | /* | ||
1059 | * The cache pool sizes used by usb_buffer_alloc() (128, 512, 2048) are | ||
1060 | * quite bad when used with the packet sizes of this device (e.g. 280, | ||
1061 | * 520, 624). Therefore, we allocate and subdivide entire pages, using | ||
1062 | * a smaller buffer only for the last chunk. | ||
1063 | */ | ||
1064 | remaining_packets = stream->queue_length; | ||
1065 | packets_per_page = PAGE_SIZE / stream->max_packet_bytes; | ||
1066 | for (i = 0; i < ARRAY_SIZE(stream->buffers); ++i) { | ||
1067 | packets = min(remaining_packets, packets_per_page); | ||
1068 | size = packets * stream->max_packet_bytes; | ||
1069 | stream->buffers[i].addr = | ||
1070 | usb_buffer_alloc(ua->dev, size, GFP_KERNEL, | ||
1071 | &stream->buffers[i].dma); | ||
1072 | if (!stream->buffers[i].addr) | ||
1073 | return -ENOMEM; | ||
1074 | stream->buffers[i].size = size; | ||
1075 | remaining_packets -= packets; | ||
1076 | if (!remaining_packets) | ||
1077 | break; | ||
1078 | } | ||
1079 | if (remaining_packets) { | ||
1080 | dev_err(&ua->dev->dev, "too many packets\n"); | ||
1081 | return -ENXIO; | ||
1082 | } | ||
1083 | return 0; | ||
1084 | } | ||
1085 | |||
1086 | static void free_stream_buffers(struct ua101 *ua, struct ua101_stream *stream) | ||
1087 | { | ||
1088 | unsigned int i; | ||
1089 | |||
1090 | for (i = 0; i < ARRAY_SIZE(stream->buffers); ++i) | ||
1091 | usb_buffer_free(ua->dev, | ||
1092 | stream->buffers[i].size, | ||
1093 | stream->buffers[i].addr, | ||
1094 | stream->buffers[i].dma); | ||
1095 | } | ||
1096 | |||
1097 | static int alloc_stream_urbs(struct ua101 *ua, struct ua101_stream *stream, | ||
1098 | void (*urb_complete)(struct urb *)) | ||
1099 | { | ||
1100 | unsigned max_packet_size = stream->max_packet_bytes; | ||
1101 | struct ua101_urb *urb; | ||
1102 | unsigned int b, u = 0; | ||
1103 | |||
1104 | for (b = 0; b < ARRAY_SIZE(stream->buffers); ++b) { | ||
1105 | unsigned int size = stream->buffers[b].size; | ||
1106 | u8 *addr = stream->buffers[b].addr; | ||
1107 | dma_addr_t dma = stream->buffers[b].dma; | ||
1108 | |||
1109 | while (size >= max_packet_size) { | ||
1110 | if (u >= stream->queue_length) | ||
1111 | goto bufsize_error; | ||
1112 | urb = kmalloc(sizeof(*urb), GFP_KERNEL); | ||
1113 | if (!urb) | ||
1114 | return -ENOMEM; | ||
1115 | usb_init_urb(&urb->urb); | ||
1116 | urb->urb.dev = ua->dev; | ||
1117 | urb->urb.pipe = stream->usb_pipe; | ||
1118 | urb->urb.transfer_flags = URB_ISO_ASAP | | ||
1119 | URB_NO_TRANSFER_DMA_MAP; | ||
1120 | urb->urb.transfer_buffer = addr; | ||
1121 | urb->urb.transfer_dma = dma; | ||
1122 | urb->urb.transfer_buffer_length = max_packet_size; | ||
1123 | urb->urb.number_of_packets = 1; | ||
1124 | urb->urb.interval = 1; | ||
1125 | urb->urb.context = ua; | ||
1126 | urb->urb.complete = urb_complete; | ||
1127 | urb->urb.iso_frame_desc[0].offset = 0; | ||
1128 | urb->urb.iso_frame_desc[0].length = max_packet_size; | ||
1129 | stream->urbs[u++] = urb; | ||
1130 | size -= max_packet_size; | ||
1131 | addr += max_packet_size; | ||
1132 | dma += max_packet_size; | ||
1133 | } | ||
1134 | } | ||
1135 | if (u == stream->queue_length) | ||
1136 | return 0; | ||
1137 | bufsize_error: | ||
1138 | dev_err(&ua->dev->dev, "internal buffer size error\n"); | ||
1139 | return -ENXIO; | ||
1140 | } | ||
1141 | |||
1142 | static void free_stream_urbs(struct ua101_stream *stream) | ||
1143 | { | ||
1144 | unsigned int i; | ||
1145 | |||
1146 | for (i = 0; i < stream->queue_length; ++i) | ||
1147 | kfree(stream->urbs[i]); | ||
1148 | } | ||
1149 | |||
1150 | static void free_usb_related_resources(struct ua101 *ua, | ||
1151 | struct usb_interface *interface) | ||
1152 | { | ||
1153 | unsigned int i; | ||
1154 | |||
1155 | free_stream_urbs(&ua->capture); | ||
1156 | free_stream_urbs(&ua->playback); | ||
1157 | free_stream_buffers(ua, &ua->capture); | ||
1158 | free_stream_buffers(ua, &ua->playback); | ||
1159 | |||
1160 | for (i = 0; i < ARRAY_SIZE(ua->intf); ++i) | ||
1161 | if (ua->intf[i]) { | ||
1162 | usb_set_intfdata(ua->intf[i], NULL); | ||
1163 | if (ua->intf[i] != interface) | ||
1164 | usb_driver_release_interface(&ua101_driver, | ||
1165 | ua->intf[i]); | ||
1166 | } | ||
1167 | } | ||
1168 | |||
1169 | static void ua101_card_free(struct snd_card *card) | ||
1170 | { | ||
1171 | struct ua101 *ua = card->private_data; | ||
1172 | |||
1173 | mutex_destroy(&ua->mutex); | ||
1174 | } | ||
1175 | |||
1176 | static int ua101_probe(struct usb_interface *interface, | ||
1177 | const struct usb_device_id *usb_id) | ||
1178 | { | ||
1179 | static const struct snd_usb_midi_endpoint_info midi_ep = { | ||
1180 | .out_cables = 0x0001, | ||
1181 | .in_cables = 0x0001 | ||
1182 | }; | ||
1183 | static const struct snd_usb_audio_quirk midi_quirk = { | ||
1184 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
1185 | .data = &midi_ep | ||
1186 | }; | ||
1187 | static const int intf_numbers[2][3] = { | ||
1188 | { /* UA-101 */ | ||
1189 | [INTF_PLAYBACK] = 0, | ||
1190 | [INTF_CAPTURE] = 1, | ||
1191 | [INTF_MIDI] = 2, | ||
1192 | }, | ||
1193 | { /* UA-1000 */ | ||
1194 | [INTF_CAPTURE] = 1, | ||
1195 | [INTF_PLAYBACK] = 2, | ||
1196 | [INTF_MIDI] = 3, | ||
1197 | }, | ||
1198 | }; | ||
1199 | struct snd_card *card; | ||
1200 | struct ua101 *ua; | ||
1201 | unsigned int card_index, i; | ||
1202 | int is_ua1000; | ||
1203 | const char *name; | ||
1204 | char usb_path[32]; | ||
1205 | int err; | ||
1206 | |||
1207 | is_ua1000 = usb_id->idProduct == 0x0044; | ||
1208 | |||
1209 | if (interface->altsetting->desc.bInterfaceNumber != | ||
1210 | intf_numbers[is_ua1000][0]) | ||
1211 | return -ENODEV; | ||
1212 | |||
1213 | mutex_lock(&devices_mutex); | ||
1214 | |||
1215 | for (card_index = 0; card_index < SNDRV_CARDS; ++card_index) | ||
1216 | if (enable[card_index] && !(devices_used & (1 << card_index))) | ||
1217 | break; | ||
1218 | if (card_index >= SNDRV_CARDS) { | ||
1219 | mutex_unlock(&devices_mutex); | ||
1220 | return -ENOENT; | ||
1221 | } | ||
1222 | err = snd_card_create(index[card_index], id[card_index], THIS_MODULE, | ||
1223 | sizeof(*ua), &card); | ||
1224 | if (err < 0) { | ||
1225 | mutex_unlock(&devices_mutex); | ||
1226 | return err; | ||
1227 | } | ||
1228 | card->private_free = ua101_card_free; | ||
1229 | ua = card->private_data; | ||
1230 | ua->dev = interface_to_usbdev(interface); | ||
1231 | ua->card = card; | ||
1232 | ua->card_index = card_index; | ||
1233 | INIT_LIST_HEAD(&ua->midi_list); | ||
1234 | spin_lock_init(&ua->lock); | ||
1235 | mutex_init(&ua->mutex); | ||
1236 | INIT_LIST_HEAD(&ua->ready_playback_urbs); | ||
1237 | tasklet_init(&ua->playback_tasklet, | ||
1238 | playback_tasklet, (unsigned long)ua); | ||
1239 | init_waitqueue_head(&ua->alsa_capture_wait); | ||
1240 | init_waitqueue_head(&ua->rate_feedback_wait); | ||
1241 | init_waitqueue_head(&ua->alsa_playback_wait); | ||
1242 | |||
1243 | ua->intf[0] = interface; | ||
1244 | for (i = 1; i < ARRAY_SIZE(ua->intf); ++i) { | ||
1245 | ua->intf[i] = usb_ifnum_to_if(ua->dev, | ||
1246 | intf_numbers[is_ua1000][i]); | ||
1247 | if (!ua->intf[i]) { | ||
1248 | dev_err(&ua->dev->dev, "interface %u not found\n", | ||
1249 | intf_numbers[is_ua1000][i]); | ||
1250 | err = -ENXIO; | ||
1251 | goto probe_error; | ||
1252 | } | ||
1253 | err = usb_driver_claim_interface(&ua101_driver, | ||
1254 | ua->intf[i], ua); | ||
1255 | if (err < 0) { | ||
1256 | ua->intf[i] = NULL; | ||
1257 | err = -EBUSY; | ||
1258 | goto probe_error; | ||
1259 | } | ||
1260 | } | ||
1261 | |||
1262 | snd_card_set_dev(card, &interface->dev); | ||
1263 | |||
1264 | err = detect_usb_format(ua); | ||
1265 | if (err < 0) | ||
1266 | goto probe_error; | ||
1267 | |||
1268 | name = usb_id->idProduct == 0x0044 ? "UA-1000" : "UA-101"; | ||
1269 | strcpy(card->driver, "UA-101"); | ||
1270 | strcpy(card->shortname, name); | ||
1271 | usb_make_path(ua->dev, usb_path, sizeof(usb_path)); | ||
1272 | snprintf(ua->card->longname, sizeof(ua->card->longname), | ||
1273 | "EDIROL %s (serial %s), %u Hz at %s, %s speed", name, | ||
1274 | ua->dev->serial ? ua->dev->serial : "?", ua->rate, usb_path, | ||
1275 | ua->dev->speed == USB_SPEED_HIGH ? "high" : "full"); | ||
1276 | |||
1277 | err = alloc_stream_buffers(ua, &ua->capture); | ||
1278 | if (err < 0) | ||
1279 | goto probe_error; | ||
1280 | err = alloc_stream_buffers(ua, &ua->playback); | ||
1281 | if (err < 0) | ||
1282 | goto probe_error; | ||
1283 | |||
1284 | err = alloc_stream_urbs(ua, &ua->capture, capture_urb_complete); | ||
1285 | if (err < 0) | ||
1286 | goto probe_error; | ||
1287 | err = alloc_stream_urbs(ua, &ua->playback, playback_urb_complete); | ||
1288 | if (err < 0) | ||
1289 | goto probe_error; | ||
1290 | |||
1291 | err = snd_pcm_new(card, name, 0, 1, 1, &ua->pcm); | ||
1292 | if (err < 0) | ||
1293 | goto probe_error; | ||
1294 | ua->pcm->private_data = ua; | ||
1295 | strcpy(ua->pcm->name, name); | ||
1296 | snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_pcm_ops); | ||
1297 | snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_pcm_ops); | ||
1298 | |||
1299 | err = snd_usbmidi_create(card, ua->intf[INTF_MIDI], | ||
1300 | &ua->midi_list, &midi_quirk); | ||
1301 | if (err < 0) | ||
1302 | goto probe_error; | ||
1303 | |||
1304 | err = snd_card_register(card); | ||
1305 | if (err < 0) | ||
1306 | goto probe_error; | ||
1307 | |||
1308 | usb_set_intfdata(interface, ua); | ||
1309 | devices_used |= 1 << card_index; | ||
1310 | |||
1311 | mutex_unlock(&devices_mutex); | ||
1312 | return 0; | ||
1313 | |||
1314 | probe_error: | ||
1315 | free_usb_related_resources(ua, interface); | ||
1316 | snd_card_free(card); | ||
1317 | mutex_unlock(&devices_mutex); | ||
1318 | return err; | ||
1319 | } | ||
1320 | |||
1321 | static void ua101_disconnect(struct usb_interface *interface) | ||
1322 | { | ||
1323 | struct ua101 *ua = usb_get_intfdata(interface); | ||
1324 | struct list_head *midi; | ||
1325 | |||
1326 | if (!ua) | ||
1327 | return; | ||
1328 | |||
1329 | mutex_lock(&devices_mutex); | ||
1330 | |||
1331 | set_bit(DISCONNECTED, &ua->states); | ||
1332 | wake_up(&ua->rate_feedback_wait); | ||
1333 | |||
1334 | /* make sure that userspace cannot create new requests */ | ||
1335 | snd_card_disconnect(ua->card); | ||
1336 | |||
1337 | /* make sure that there are no pending USB requests */ | ||
1338 | __list_for_each(midi, &ua->midi_list) | ||
1339 | snd_usbmidi_disconnect(midi); | ||
1340 | abort_alsa_playback(ua); | ||
1341 | abort_alsa_capture(ua); | ||
1342 | mutex_lock(&ua->mutex); | ||
1343 | stop_usb_playback(ua); | ||
1344 | stop_usb_capture(ua); | ||
1345 | mutex_unlock(&ua->mutex); | ||
1346 | |||
1347 | free_usb_related_resources(ua, interface); | ||
1348 | |||
1349 | devices_used &= ~(1 << ua->card_index); | ||
1350 | |||
1351 | snd_card_free_when_closed(ua->card); | ||
1352 | |||
1353 | mutex_unlock(&devices_mutex); | ||
1354 | } | ||
1355 | |||
1356 | static struct usb_device_id ua101_ids[] = { | ||
1357 | { USB_DEVICE(0x0582, 0x0044) }, /* UA-1000 high speed */ | ||
1358 | { USB_DEVICE(0x0582, 0x007d) }, /* UA-101 high speed */ | ||
1359 | { USB_DEVICE(0x0582, 0x008d) }, /* UA-101 full speed */ | ||
1360 | { } | ||
1361 | }; | ||
1362 | MODULE_DEVICE_TABLE(usb, ua101_ids); | ||
1363 | |||
1364 | static struct usb_driver ua101_driver = { | ||
1365 | .name = "snd-ua101", | ||
1366 | .id_table = ua101_ids, | ||
1367 | .probe = ua101_probe, | ||
1368 | .disconnect = ua101_disconnect, | ||
1369 | #if 0 | ||
1370 | .suspend = ua101_suspend, | ||
1371 | .resume = ua101_resume, | ||
1372 | #endif | ||
1373 | }; | ||
1374 | |||
1375 | static int __init alsa_card_ua101_init(void) | ||
1376 | { | ||
1377 | return usb_register(&ua101_driver); | ||
1378 | } | ||
1379 | |||
1380 | static void __exit alsa_card_ua101_exit(void) | ||
1381 | { | ||
1382 | usb_deregister(&ua101_driver); | ||
1383 | mutex_destroy(&devices_mutex); | ||
1384 | } | ||
1385 | |||
1386 | module_init(alsa_card_ua101_init); | ||
1387 | module_exit(alsa_card_ua101_exit); | ||
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 9edef4684978..11b0826b8fe6 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -44,9 +44,11 @@ | |||
44 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
45 | #include <linux/string.h> | 45 | #include <linux/string.h> |
46 | #include <linux/usb.h> | 46 | #include <linux/usb.h> |
47 | #include <linux/vmalloc.h> | ||
48 | #include <linux/moduleparam.h> | 47 | #include <linux/moduleparam.h> |
49 | #include <linux/mutex.h> | 48 | #include <linux/mutex.h> |
49 | #include <linux/usb/audio.h> | ||
50 | #include <linux/usb/ch9.h> | ||
51 | |||
50 | #include <sound/core.h> | 52 | #include <sound/core.h> |
51 | #include <sound/info.h> | 53 | #include <sound/info.h> |
52 | #include <sound/pcm.h> | 54 | #include <sound/pcm.h> |
@@ -170,11 +172,12 @@ struct snd_usb_substream { | |||
170 | unsigned int curpacksize; /* current packet size in bytes (for capture) */ | 172 | unsigned int curpacksize; /* current packet size in bytes (for capture) */ |
171 | unsigned int curframesize; /* current packet size in frames (for capture) */ | 173 | unsigned int curframesize; /* current packet size in frames (for capture) */ |
172 | unsigned int fill_max: 1; /* fill max packet size always */ | 174 | unsigned int fill_max: 1; /* fill max packet size always */ |
175 | unsigned int txfr_quirk:1; /* allow sub-frame alignment */ | ||
173 | unsigned int fmt_type; /* USB audio format type (1-3) */ | 176 | unsigned int fmt_type; /* USB audio format type (1-3) */ |
174 | 177 | ||
175 | unsigned int running: 1; /* running status */ | 178 | unsigned int running: 1; /* running status */ |
176 | 179 | ||
177 | unsigned int hwptr_done; /* processed frame position in the buffer */ | 180 | unsigned int hwptr_done; /* processed byte position in the buffer */ |
178 | unsigned int transfer_done; /* processed frames since last period update */ | 181 | unsigned int transfer_done; /* processed frames since last period update */ |
179 | unsigned long active_mask; /* bitmask of active urbs */ | 182 | unsigned long active_mask; /* bitmask of active urbs */ |
180 | unsigned long unlink_mask; /* bitmask of unlinked urbs */ | 183 | unsigned long unlink_mask; /* bitmask of unlinked urbs */ |
@@ -343,7 +346,7 @@ static int retire_capture_urb(struct snd_usb_substream *subs, | |||
343 | unsigned long flags; | 346 | unsigned long flags; |
344 | unsigned char *cp; | 347 | unsigned char *cp; |
345 | int i; | 348 | int i; |
346 | unsigned int stride, len, oldptr; | 349 | unsigned int stride, frames, bytes, oldptr; |
347 | int period_elapsed = 0; | 350 | int period_elapsed = 0; |
348 | 351 | ||
349 | stride = runtime->frame_bits >> 3; | 352 | stride = runtime->frame_bits >> 3; |
@@ -354,29 +357,39 @@ static int retire_capture_urb(struct snd_usb_substream *subs, | |||
354 | snd_printd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status); | 357 | snd_printd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status); |
355 | // continue; | 358 | // continue; |
356 | } | 359 | } |
357 | len = urb->iso_frame_desc[i].actual_length / stride; | 360 | bytes = urb->iso_frame_desc[i].actual_length; |
358 | if (! len) | 361 | frames = bytes / stride; |
359 | continue; | 362 | if (!subs->txfr_quirk) |
363 | bytes = frames * stride; | ||
364 | if (bytes % (runtime->sample_bits >> 3) != 0) { | ||
365 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
366 | int oldbytes = bytes; | ||
367 | #endif | ||
368 | bytes = frames * stride; | ||
369 | snd_printdd(KERN_ERR "Corrected urb data len. %d->%d\n", | ||
370 | oldbytes, bytes); | ||
371 | } | ||
360 | /* update the current pointer */ | 372 | /* update the current pointer */ |
361 | spin_lock_irqsave(&subs->lock, flags); | 373 | spin_lock_irqsave(&subs->lock, flags); |
362 | oldptr = subs->hwptr_done; | 374 | oldptr = subs->hwptr_done; |
363 | subs->hwptr_done += len; | 375 | subs->hwptr_done += bytes; |
364 | if (subs->hwptr_done >= runtime->buffer_size) | 376 | if (subs->hwptr_done >= runtime->buffer_size * stride) |
365 | subs->hwptr_done -= runtime->buffer_size; | 377 | subs->hwptr_done -= runtime->buffer_size * stride; |
366 | subs->transfer_done += len; | 378 | frames = (bytes + (oldptr % stride)) / stride; |
379 | subs->transfer_done += frames; | ||
367 | if (subs->transfer_done >= runtime->period_size) { | 380 | if (subs->transfer_done >= runtime->period_size) { |
368 | subs->transfer_done -= runtime->period_size; | 381 | subs->transfer_done -= runtime->period_size; |
369 | period_elapsed = 1; | 382 | period_elapsed = 1; |
370 | } | 383 | } |
371 | spin_unlock_irqrestore(&subs->lock, flags); | 384 | spin_unlock_irqrestore(&subs->lock, flags); |
372 | /* copy a data chunk */ | 385 | /* copy a data chunk */ |
373 | if (oldptr + len > runtime->buffer_size) { | 386 | if (oldptr + bytes > runtime->buffer_size * stride) { |
374 | unsigned int cnt = runtime->buffer_size - oldptr; | 387 | unsigned int bytes1 = |
375 | unsigned int blen = cnt * stride; | 388 | runtime->buffer_size * stride - oldptr; |
376 | memcpy(runtime->dma_area + oldptr * stride, cp, blen); | 389 | memcpy(runtime->dma_area + oldptr, cp, bytes1); |
377 | memcpy(runtime->dma_area, cp + blen, len * stride - blen); | 390 | memcpy(runtime->dma_area, cp + bytes1, bytes - bytes1); |
378 | } else { | 391 | } else { |
379 | memcpy(runtime->dma_area + oldptr * stride, cp, len * stride); | 392 | memcpy(runtime->dma_area + oldptr, cp, bytes); |
380 | } | 393 | } |
381 | } | 394 | } |
382 | if (period_elapsed) | 395 | if (period_elapsed) |
@@ -563,34 +576,34 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
563 | struct snd_pcm_runtime *runtime, | 576 | struct snd_pcm_runtime *runtime, |
564 | struct urb *urb) | 577 | struct urb *urb) |
565 | { | 578 | { |
566 | int i, stride, offs; | 579 | int i, stride; |
567 | unsigned int counts; | 580 | unsigned int counts, frames, bytes; |
568 | unsigned long flags; | 581 | unsigned long flags; |
569 | int period_elapsed = 0; | 582 | int period_elapsed = 0; |
570 | struct snd_urb_ctx *ctx = urb->context; | 583 | struct snd_urb_ctx *ctx = urb->context; |
571 | 584 | ||
572 | stride = runtime->frame_bits >> 3; | 585 | stride = runtime->frame_bits >> 3; |
573 | 586 | ||
574 | offs = 0; | 587 | frames = 0; |
575 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ | 588 | urb->dev = ctx->subs->dev; /* we need to set this at each time */ |
576 | urb->number_of_packets = 0; | 589 | urb->number_of_packets = 0; |
577 | spin_lock_irqsave(&subs->lock, flags); | 590 | spin_lock_irqsave(&subs->lock, flags); |
578 | for (i = 0; i < ctx->packets; i++) { | 591 | for (i = 0; i < ctx->packets; i++) { |
579 | counts = snd_usb_audio_next_packet_size(subs); | 592 | counts = snd_usb_audio_next_packet_size(subs); |
580 | /* set up descriptor */ | 593 | /* set up descriptor */ |
581 | urb->iso_frame_desc[i].offset = offs * stride; | 594 | urb->iso_frame_desc[i].offset = frames * stride; |
582 | urb->iso_frame_desc[i].length = counts * stride; | 595 | urb->iso_frame_desc[i].length = counts * stride; |
583 | offs += counts; | 596 | frames += counts; |
584 | urb->number_of_packets++; | 597 | urb->number_of_packets++; |
585 | subs->transfer_done += counts; | 598 | subs->transfer_done += counts; |
586 | if (subs->transfer_done >= runtime->period_size) { | 599 | if (subs->transfer_done >= runtime->period_size) { |
587 | subs->transfer_done -= runtime->period_size; | 600 | subs->transfer_done -= runtime->period_size; |
588 | period_elapsed = 1; | 601 | period_elapsed = 1; |
589 | if (subs->fmt_type == USB_FORMAT_TYPE_II) { | 602 | if (subs->fmt_type == UAC_FORMAT_TYPE_II) { |
590 | if (subs->transfer_done > 0) { | 603 | if (subs->transfer_done > 0) { |
591 | /* FIXME: fill-max mode is not | 604 | /* FIXME: fill-max mode is not |
592 | * supported yet */ | 605 | * supported yet */ |
593 | offs -= subs->transfer_done; | 606 | frames -= subs->transfer_done; |
594 | counts -= subs->transfer_done; | 607 | counts -= subs->transfer_done; |
595 | urb->iso_frame_desc[i].length = | 608 | urb->iso_frame_desc[i].length = |
596 | counts * stride; | 609 | counts * stride; |
@@ -600,7 +613,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
600 | if (i < ctx->packets) { | 613 | if (i < ctx->packets) { |
601 | /* add a transfer delimiter */ | 614 | /* add a transfer delimiter */ |
602 | urb->iso_frame_desc[i].offset = | 615 | urb->iso_frame_desc[i].offset = |
603 | offs * stride; | 616 | frames * stride; |
604 | urb->iso_frame_desc[i].length = 0; | 617 | urb->iso_frame_desc[i].length = 0; |
605 | urb->number_of_packets++; | 618 | urb->number_of_packets++; |
606 | } | 619 | } |
@@ -610,26 +623,25 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
610 | if (period_elapsed) /* finish at the period boundary */ | 623 | if (period_elapsed) /* finish at the period boundary */ |
611 | break; | 624 | break; |
612 | } | 625 | } |
613 | if (subs->hwptr_done + offs > runtime->buffer_size) { | 626 | bytes = frames * stride; |
627 | if (subs->hwptr_done + bytes > runtime->buffer_size * stride) { | ||
614 | /* err, the transferred area goes over buffer boundary. */ | 628 | /* err, the transferred area goes over buffer boundary. */ |
615 | unsigned int len = runtime->buffer_size - subs->hwptr_done; | 629 | unsigned int bytes1 = |
630 | runtime->buffer_size * stride - subs->hwptr_done; | ||
616 | memcpy(urb->transfer_buffer, | 631 | memcpy(urb->transfer_buffer, |
617 | runtime->dma_area + subs->hwptr_done * stride, | 632 | runtime->dma_area + subs->hwptr_done, bytes1); |
618 | len * stride); | 633 | memcpy(urb->transfer_buffer + bytes1, |
619 | memcpy(urb->transfer_buffer + len * stride, | 634 | runtime->dma_area, bytes - bytes1); |
620 | runtime->dma_area, | ||
621 | (offs - len) * stride); | ||
622 | } else { | 635 | } else { |
623 | memcpy(urb->transfer_buffer, | 636 | memcpy(urb->transfer_buffer, |
624 | runtime->dma_area + subs->hwptr_done * stride, | 637 | runtime->dma_area + subs->hwptr_done, bytes); |
625 | offs * stride); | ||
626 | } | 638 | } |
627 | subs->hwptr_done += offs; | 639 | subs->hwptr_done += bytes; |
628 | if (subs->hwptr_done >= runtime->buffer_size) | 640 | if (subs->hwptr_done >= runtime->buffer_size * stride) |
629 | subs->hwptr_done -= runtime->buffer_size; | 641 | subs->hwptr_done -= runtime->buffer_size * stride; |
630 | runtime->delay += offs; | 642 | runtime->delay += frames; |
631 | spin_unlock_irqrestore(&subs->lock, flags); | 643 | spin_unlock_irqrestore(&subs->lock, flags); |
632 | urb->transfer_buffer_length = offs * stride; | 644 | urb->transfer_buffer_length = bytes; |
633 | if (period_elapsed) | 645 | if (period_elapsed) |
634 | snd_pcm_period_elapsed(subs->pcm_substream); | 646 | snd_pcm_period_elapsed(subs->pcm_substream); |
635 | return 0; | 647 | return 0; |
@@ -735,41 +747,6 @@ static void snd_complete_sync_urb(struct urb *urb) | |||
735 | } | 747 | } |
736 | 748 | ||
737 | 749 | ||
738 | /* get the physical page pointer at the given offset */ | ||
739 | static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, | ||
740 | unsigned long offset) | ||
741 | { | ||
742 | void *pageptr = subs->runtime->dma_area + offset; | ||
743 | return vmalloc_to_page(pageptr); | ||
744 | } | ||
745 | |||
746 | /* allocate virtual buffer; may be called more than once */ | ||
747 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) | ||
748 | { | ||
749 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
750 | if (runtime->dma_area) { | ||
751 | if (runtime->dma_bytes >= size) | ||
752 | return 0; /* already large enough */ | ||
753 | vfree(runtime->dma_area); | ||
754 | } | ||
755 | runtime->dma_area = vmalloc_user(size); | ||
756 | if (!runtime->dma_area) | ||
757 | return -ENOMEM; | ||
758 | runtime->dma_bytes = size; | ||
759 | return 0; | ||
760 | } | ||
761 | |||
762 | /* free virtual buffer; may be called more than once */ | ||
763 | static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) | ||
764 | { | ||
765 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
766 | |||
767 | vfree(runtime->dma_area); | ||
768 | runtime->dma_area = NULL; | ||
769 | return 0; | ||
770 | } | ||
771 | |||
772 | |||
773 | /* | 750 | /* |
774 | * unlink active urbs. | 751 | * unlink active urbs. |
775 | */ | 752 | */ |
@@ -937,18 +914,18 @@ static int wait_clear_urbs(struct snd_usb_substream *subs) | |||
937 | 914 | ||
938 | 915 | ||
939 | /* | 916 | /* |
940 | * return the current pcm pointer. just return the hwptr_done value. | 917 | * return the current pcm pointer. just based on the hwptr_done value. |
941 | */ | 918 | */ |
942 | static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream) | 919 | static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream) |
943 | { | 920 | { |
944 | struct snd_usb_substream *subs; | 921 | struct snd_usb_substream *subs; |
945 | snd_pcm_uframes_t hwptr_done; | 922 | unsigned int hwptr_done; |
946 | 923 | ||
947 | subs = (struct snd_usb_substream *)substream->runtime->private_data; | 924 | subs = (struct snd_usb_substream *)substream->runtime->private_data; |
948 | spin_lock(&subs->lock); | 925 | spin_lock(&subs->lock); |
949 | hwptr_done = subs->hwptr_done; | 926 | hwptr_done = subs->hwptr_done; |
950 | spin_unlock(&subs->lock); | 927 | spin_unlock(&subs->lock); |
951 | return hwptr_done; | 928 | return hwptr_done / (substream->runtime->frame_bits >> 3); |
952 | } | 929 | } |
953 | 930 | ||
954 | 931 | ||
@@ -1130,7 +1107,7 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri | |||
1130 | u->packets = (i + 1) * total_packs / subs->nurbs | 1107 | u->packets = (i + 1) * total_packs / subs->nurbs |
1131 | - i * total_packs / subs->nurbs; | 1108 | - i * total_packs / subs->nurbs; |
1132 | u->buffer_size = maxsize * u->packets; | 1109 | u->buffer_size = maxsize * u->packets; |
1133 | if (subs->fmt_type == USB_FORMAT_TYPE_II) | 1110 | if (subs->fmt_type == UAC_FORMAT_TYPE_II) |
1134 | u->packets++; /* for transfer delimiter */ | 1111 | u->packets++; /* for transfer delimiter */ |
1135 | u->urb = usb_alloc_urb(u->packets, GFP_KERNEL); | 1112 | u->urb = usb_alloc_urb(u->packets, GFP_KERNEL); |
1136 | if (!u->urb) | 1113 | if (!u->urb) |
@@ -1206,7 +1183,7 @@ static struct audioformat *find_format(struct snd_usb_substream *subs, unsigned | |||
1206 | if (i >= fp->nr_rates) | 1183 | if (i >= fp->nr_rates) |
1207 | continue; | 1184 | continue; |
1208 | } | 1185 | } |
1209 | attr = fp->ep_attr & EP_ATTR_MASK; | 1186 | attr = fp->ep_attr & USB_ENDPOINT_SYNCTYPE; |
1210 | if (! found) { | 1187 | if (! found) { |
1211 | found = fp; | 1188 | found = fp; |
1212 | cur_attr = attr; | 1189 | cur_attr = attr; |
@@ -1218,14 +1195,14 @@ static struct audioformat *find_format(struct snd_usb_substream *subs, unsigned | |||
1218 | * M-audio audiophile USB. | 1195 | * M-audio audiophile USB. |
1219 | */ | 1196 | */ |
1220 | if (attr != cur_attr) { | 1197 | if (attr != cur_attr) { |
1221 | if ((attr == EP_ATTR_ASYNC && | 1198 | if ((attr == USB_ENDPOINT_SYNC_ASYNC && |
1222 | subs->direction == SNDRV_PCM_STREAM_PLAYBACK) || | 1199 | subs->direction == SNDRV_PCM_STREAM_PLAYBACK) || |
1223 | (attr == EP_ATTR_ADAPTIVE && | 1200 | (attr == USB_ENDPOINT_SYNC_ADAPTIVE && |
1224 | subs->direction == SNDRV_PCM_STREAM_CAPTURE)) | 1201 | subs->direction == SNDRV_PCM_STREAM_CAPTURE)) |
1225 | continue; | 1202 | continue; |
1226 | if ((cur_attr == EP_ATTR_ASYNC && | 1203 | if ((cur_attr == USB_ENDPOINT_SYNC_ASYNC && |
1227 | subs->direction == SNDRV_PCM_STREAM_PLAYBACK) || | 1204 | subs->direction == SNDRV_PCM_STREAM_PLAYBACK) || |
1228 | (cur_attr == EP_ATTR_ADAPTIVE && | 1205 | (cur_attr == USB_ENDPOINT_SYNC_ADAPTIVE && |
1229 | subs->direction == SNDRV_PCM_STREAM_CAPTURE)) { | 1206 | subs->direction == SNDRV_PCM_STREAM_CAPTURE)) { |
1230 | found = fp; | 1207 | found = fp; |
1231 | cur_attr = attr; | 1208 | cur_attr = attr; |
@@ -1255,11 +1232,11 @@ static int init_usb_pitch(struct usb_device *dev, int iface, | |||
1255 | 1232 | ||
1256 | ep = get_endpoint(alts, 0)->bEndpointAddress; | 1233 | ep = get_endpoint(alts, 0)->bEndpointAddress; |
1257 | /* if endpoint has pitch control, enable it */ | 1234 | /* if endpoint has pitch control, enable it */ |
1258 | if (fmt->attributes & EP_CS_ATTR_PITCH_CONTROL) { | 1235 | if (fmt->attributes & UAC_EP_CS_ATTR_PITCH_CONTROL) { |
1259 | data[0] = 1; | 1236 | data[0] = 1; |
1260 | if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, | 1237 | if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, |
1261 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, | 1238 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, |
1262 | PITCH_CONTROL << 8, ep, data, 1, 1000)) < 0) { | 1239 | UAC_EP_CS_ATTR_PITCH_CONTROL << 8, ep, data, 1, 1000)) < 0) { |
1263 | snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n", | 1240 | snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n", |
1264 | dev->devnum, iface, ep); | 1241 | dev->devnum, iface, ep); |
1265 | return err; | 1242 | return err; |
@@ -1278,21 +1255,21 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface, | |||
1278 | 1255 | ||
1279 | ep = get_endpoint(alts, 0)->bEndpointAddress; | 1256 | ep = get_endpoint(alts, 0)->bEndpointAddress; |
1280 | /* if endpoint has sampling rate control, set it */ | 1257 | /* if endpoint has sampling rate control, set it */ |
1281 | if (fmt->attributes & EP_CS_ATTR_SAMPLE_RATE) { | 1258 | if (fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE) { |
1282 | int crate; | 1259 | int crate; |
1283 | data[0] = rate; | 1260 | data[0] = rate; |
1284 | data[1] = rate >> 8; | 1261 | data[1] = rate >> 8; |
1285 | data[2] = rate >> 16; | 1262 | data[2] = rate >> 16; |
1286 | if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, | 1263 | if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, |
1287 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, | 1264 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, |
1288 | SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { | 1265 | UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000)) < 0) { |
1289 | snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n", | 1266 | snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n", |
1290 | dev->devnum, iface, fmt->altsetting, rate, ep); | 1267 | dev->devnum, iface, fmt->altsetting, rate, ep); |
1291 | return err; | 1268 | return err; |
1292 | } | 1269 | } |
1293 | if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR, | 1270 | if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR, |
1294 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, | 1271 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, |
1295 | SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { | 1272 | UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000)) < 0) { |
1296 | snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n", | 1273 | snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n", |
1297 | dev->devnum, iface, fmt->altsetting, ep); | 1274 | dev->devnum, iface, fmt->altsetting, ep); |
1298 | return 0; /* some devices don't support reading */ | 1275 | return 0; /* some devices don't support reading */ |
@@ -1307,6 +1284,47 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface, | |||
1307 | } | 1284 | } |
1308 | 1285 | ||
1309 | /* | 1286 | /* |
1287 | * For E-Mu 0404USB/0202USB/TrackerPre sample rate should be set for device, | ||
1288 | * not for interface. | ||
1289 | */ | ||
1290 | static void set_format_emu_quirk(struct snd_usb_substream *subs, | ||
1291 | struct audioformat *fmt) | ||
1292 | { | ||
1293 | unsigned char emu_samplerate_id = 0; | ||
1294 | |||
1295 | /* When capture is active | ||
1296 | * sample rate shouldn't be changed | ||
1297 | * by playback substream | ||
1298 | */ | ||
1299 | if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) { | ||
1300 | if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE].interface != -1) | ||
1301 | return; | ||
1302 | } | ||
1303 | |||
1304 | switch (fmt->rate_min) { | ||
1305 | case 48000: | ||
1306 | emu_samplerate_id = EMU_QUIRK_SR_48000HZ; | ||
1307 | break; | ||
1308 | case 88200: | ||
1309 | emu_samplerate_id = EMU_QUIRK_SR_88200HZ; | ||
1310 | break; | ||
1311 | case 96000: | ||
1312 | emu_samplerate_id = EMU_QUIRK_SR_96000HZ; | ||
1313 | break; | ||
1314 | case 176400: | ||
1315 | emu_samplerate_id = EMU_QUIRK_SR_176400HZ; | ||
1316 | break; | ||
1317 | case 192000: | ||
1318 | emu_samplerate_id = EMU_QUIRK_SR_192000HZ; | ||
1319 | break; | ||
1320 | default: | ||
1321 | emu_samplerate_id = EMU_QUIRK_SR_44100HZ; | ||
1322 | break; | ||
1323 | } | ||
1324 | snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id); | ||
1325 | } | ||
1326 | |||
1327 | /* | ||
1310 | * find a matching format and set up the interface | 1328 | * find a matching format and set up the interface |
1311 | */ | 1329 | */ |
1312 | static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | 1330 | static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) |
@@ -1369,9 +1387,9 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
1369 | * descriptors which fool us. if it has only one EP, | 1387 | * descriptors which fool us. if it has only one EP, |
1370 | * assume it as adaptive-out or sync-in. | 1388 | * assume it as adaptive-out or sync-in. |
1371 | */ | 1389 | */ |
1372 | attr = fmt->ep_attr & EP_ATTR_MASK; | 1390 | attr = fmt->ep_attr & USB_ENDPOINT_SYNCTYPE; |
1373 | if (((is_playback && attr == EP_ATTR_ASYNC) || | 1391 | if (((is_playback && attr == USB_ENDPOINT_SYNC_ASYNC) || |
1374 | (! is_playback && attr == EP_ATTR_ADAPTIVE)) && | 1392 | (! is_playback && attr == USB_ENDPOINT_SYNC_ADAPTIVE)) && |
1375 | altsd->bNumEndpoints >= 2) { | 1393 | altsd->bNumEndpoints >= 2) { |
1376 | /* check sync-pipe endpoint */ | 1394 | /* check sync-pipe endpoint */ |
1377 | /* ... and check descriptor size before accessing bSynchAddress | 1395 | /* ... and check descriptor size before accessing bSynchAddress |
@@ -1411,7 +1429,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
1411 | } | 1429 | } |
1412 | 1430 | ||
1413 | /* always fill max packet size */ | 1431 | /* always fill max packet size */ |
1414 | if (fmt->attributes & EP_CS_ATTR_FILL_MAX) | 1432 | if (fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX) |
1415 | subs->fill_max = 1; | 1433 | subs->fill_max = 1; |
1416 | 1434 | ||
1417 | if ((err = init_usb_pitch(dev, subs->interface, alts, fmt)) < 0) | 1435 | if ((err = init_usb_pitch(dev, subs->interface, alts, fmt)) < 0) |
@@ -1419,6 +1437,14 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
1419 | 1437 | ||
1420 | subs->cur_audiofmt = fmt; | 1438 | subs->cur_audiofmt = fmt; |
1421 | 1439 | ||
1440 | switch (subs->stream->chip->usb_id) { | ||
1441 | case USB_ID(0x041e, 0x3f02): /* E-Mu 0202 USB */ | ||
1442 | case USB_ID(0x041e, 0x3f04): /* E-Mu 0404 USB */ | ||
1443 | case USB_ID(0x041e, 0x3f0a): /* E-Mu Tracker Pre */ | ||
1444 | set_format_emu_quirk(subs, fmt); | ||
1445 | break; | ||
1446 | } | ||
1447 | |||
1422 | #if 0 | 1448 | #if 0 |
1423 | printk(KERN_DEBUG | 1449 | printk(KERN_DEBUG |
1424 | "setting done: format = %d, rate = %d..%d, channels = %d\n", | 1450 | "setting done: format = %d, rate = %d..%d, channels = %d\n", |
@@ -1449,8 +1475,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream, | |||
1449 | unsigned int channels, rate, format; | 1475 | unsigned int channels, rate, format; |
1450 | int ret, changed; | 1476 | int ret, changed; |
1451 | 1477 | ||
1452 | ret = snd_pcm_alloc_vmalloc_buffer(substream, | 1478 | ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, |
1453 | params_buffer_bytes(hw_params)); | 1479 | params_buffer_bytes(hw_params)); |
1454 | if (ret < 0) | 1480 | if (ret < 0) |
1455 | return ret; | 1481 | return ret; |
1456 | 1482 | ||
@@ -1507,7 +1533,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) | |||
1507 | subs->period_bytes = 0; | 1533 | subs->period_bytes = 0; |
1508 | if (!subs->stream->chip->shutdown) | 1534 | if (!subs->stream->chip->shutdown) |
1509 | release_substream_urbs(subs, 0); | 1535 | release_substream_urbs(subs, 0); |
1510 | return snd_pcm_free_vmalloc_buffer(substream); | 1536 | return snd_pcm_lib_free_vmalloc_buffer(substream); |
1511 | } | 1537 | } |
1512 | 1538 | ||
1513 | /* | 1539 | /* |
@@ -1861,7 +1887,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre | |||
1861 | runtime->hw.channels_min = fp->channels; | 1887 | runtime->hw.channels_min = fp->channels; |
1862 | if (runtime->hw.channels_max < fp->channels) | 1888 | if (runtime->hw.channels_max < fp->channels) |
1863 | runtime->hw.channels_max = fp->channels; | 1889 | runtime->hw.channels_max = fp->channels; |
1864 | if (fp->fmt_type == USB_FORMAT_TYPE_II && fp->frame_size > 0) { | 1890 | if (fp->fmt_type == UAC_FORMAT_TYPE_II && fp->frame_size > 0) { |
1865 | /* FIXME: there might be more than one audio formats... */ | 1891 | /* FIXME: there might be more than one audio formats... */ |
1866 | runtime->hw.period_bytes_min = runtime->hw.period_bytes_max = | 1892 | runtime->hw.period_bytes_min = runtime->hw.period_bytes_max = |
1867 | fp->frame_size; | 1893 | fp->frame_size; |
@@ -1973,7 +1999,8 @@ static struct snd_pcm_ops snd_usb_playback_ops = { | |||
1973 | .prepare = snd_usb_pcm_prepare, | 1999 | .prepare = snd_usb_pcm_prepare, |
1974 | .trigger = snd_usb_pcm_playback_trigger, | 2000 | .trigger = snd_usb_pcm_playback_trigger, |
1975 | .pointer = snd_usb_pcm_pointer, | 2001 | .pointer = snd_usb_pcm_pointer, |
1976 | .page = snd_pcm_get_vmalloc_page, | 2002 | .page = snd_pcm_lib_get_vmalloc_page, |
2003 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
1977 | }; | 2004 | }; |
1978 | 2005 | ||
1979 | static struct snd_pcm_ops snd_usb_capture_ops = { | 2006 | static struct snd_pcm_ops snd_usb_capture_ops = { |
@@ -1985,7 +2012,8 @@ static struct snd_pcm_ops snd_usb_capture_ops = { | |||
1985 | .prepare = snd_usb_pcm_prepare, | 2012 | .prepare = snd_usb_pcm_prepare, |
1986 | .trigger = snd_usb_pcm_capture_trigger, | 2013 | .trigger = snd_usb_pcm_capture_trigger, |
1987 | .pointer = snd_usb_pcm_pointer, | 2014 | .pointer = snd_usb_pcm_pointer, |
1988 | .page = snd_pcm_get_vmalloc_page, | 2015 | .page = snd_pcm_lib_get_vmalloc_page, |
2016 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
1989 | }; | 2017 | }; |
1990 | 2018 | ||
1991 | 2019 | ||
@@ -2093,7 +2121,7 @@ static struct usb_device_id usb_audio_ids [] = { | |||
2093 | #include "usbquirks.h" | 2121 | #include "usbquirks.h" |
2094 | { .match_flags = (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS), | 2122 | { .match_flags = (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS), |
2095 | .bInterfaceClass = USB_CLASS_AUDIO, | 2123 | .bInterfaceClass = USB_CLASS_AUDIO, |
2096 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL }, | 2124 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL }, |
2097 | { } /* Terminating entry */ | 2125 | { } /* Terminating entry */ |
2098 | }; | 2126 | }; |
2099 | 2127 | ||
@@ -2132,7 +2160,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s | |||
2132 | snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", | 2160 | snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", |
2133 | fp->endpoint & USB_ENDPOINT_NUMBER_MASK, | 2161 | fp->endpoint & USB_ENDPOINT_NUMBER_MASK, |
2134 | fp->endpoint & USB_DIR_IN ? "IN" : "OUT", | 2162 | fp->endpoint & USB_DIR_IN ? "IN" : "OUT", |
2135 | sync_types[(fp->ep_attr & EP_ATTR_MASK) >> 2]); | 2163 | sync_types[(fp->ep_attr & USB_ENDPOINT_SYNCTYPE) >> 2]); |
2136 | if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) { | 2164 | if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) { |
2137 | snd_iprintf(buffer, " Rates: %d - %d (continuous)\n", | 2165 | snd_iprintf(buffer, " Rates: %d - %d (continuous)\n", |
2138 | fp->rate_min, fp->rate_max); | 2166 | fp->rate_min, fp->rate_max); |
@@ -2227,6 +2255,7 @@ static void init_substream(struct snd_usb_stream *as, int stream, struct audiofo | |||
2227 | subs->stream = as; | 2255 | subs->stream = as; |
2228 | subs->direction = stream; | 2256 | subs->direction = stream; |
2229 | subs->dev = as->chip->dev; | 2257 | subs->dev = as->chip->dev; |
2258 | subs->txfr_quirk = as->chip->txfr_quirk; | ||
2230 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) { | 2259 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) { |
2231 | subs->ops = audio_urb_ops[stream]; | 2260 | subs->ops = audio_urb_ops[stream]; |
2232 | } else { | 2261 | } else { |
@@ -2394,29 +2423,67 @@ static int is_big_endian_format(struct snd_usb_audio *chip, struct audioformat * | |||
2394 | * @format: the format tag (wFormatTag) | 2423 | * @format: the format tag (wFormatTag) |
2395 | * @fmt: the format type descriptor | 2424 | * @fmt: the format type descriptor |
2396 | */ | 2425 | */ |
2397 | static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audioformat *fp, | 2426 | static int parse_audio_format_i_type(struct snd_usb_audio *chip, |
2398 | int format, unsigned char *fmt) | 2427 | struct audioformat *fp, |
2428 | int format, void *_fmt, | ||
2429 | int protocol) | ||
2399 | { | 2430 | { |
2400 | int pcm_format; | 2431 | int pcm_format, i; |
2401 | int sample_width, sample_bytes; | 2432 | int sample_width, sample_bytes; |
2402 | 2433 | ||
2434 | switch (protocol) { | ||
2435 | case UAC_VERSION_1: { | ||
2436 | struct uac_format_type_i_discrete_descriptor *fmt = _fmt; | ||
2437 | sample_width = fmt->bBitResolution; | ||
2438 | sample_bytes = fmt->bSubframeSize; | ||
2439 | break; | ||
2440 | } | ||
2441 | |||
2442 | case UAC_VERSION_2: { | ||
2443 | struct uac_format_type_i_ext_descriptor *fmt = _fmt; | ||
2444 | sample_width = fmt->bBitResolution; | ||
2445 | sample_bytes = fmt->bSubslotSize; | ||
2446 | |||
2447 | /* | ||
2448 | * FIXME | ||
2449 | * USB audio class v2 devices specify a bitmap of possible | ||
2450 | * audio formats rather than one fix value. For now, we just | ||
2451 | * pick one of them and report that as the only possible | ||
2452 | * value for this setting. | ||
2453 | * The bit allocation map is in fact compatible to the | ||
2454 | * wFormatTag of the v1 AS streaming descriptors, which is why | ||
2455 | * we can simply map the matrix. | ||
2456 | */ | ||
2457 | |||
2458 | for (i = 0; i < 5; i++) | ||
2459 | if (format & (1UL << i)) { | ||
2460 | format = i + 1; | ||
2461 | break; | ||
2462 | } | ||
2463 | |||
2464 | break; | ||
2465 | } | ||
2466 | |||
2467 | default: | ||
2468 | return -EINVAL; | ||
2469 | } | ||
2470 | |||
2403 | /* FIXME: correct endianess and sign? */ | 2471 | /* FIXME: correct endianess and sign? */ |
2404 | pcm_format = -1; | 2472 | pcm_format = -1; |
2405 | sample_width = fmt[6]; | 2473 | |
2406 | sample_bytes = fmt[5]; | ||
2407 | switch (format) { | 2474 | switch (format) { |
2408 | case 0: /* some devices don't define this correctly... */ | 2475 | case UAC_FORMAT_TYPE_I_UNDEFINED: /* some devices don't define this correctly... */ |
2409 | snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", | 2476 | snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", |
2410 | chip->dev->devnum, fp->iface, fp->altsetting); | 2477 | chip->dev->devnum, fp->iface, fp->altsetting); |
2411 | /* fall-through */ | 2478 | /* fall-through */ |
2412 | case USB_AUDIO_FORMAT_PCM: | 2479 | case UAC_FORMAT_TYPE_I_PCM: |
2413 | if (sample_width > sample_bytes * 8) { | 2480 | if (sample_width > sample_bytes * 8) { |
2414 | snd_printk(KERN_INFO "%d:%u:%d : sample bitwidth %d in over sample bytes %d\n", | 2481 | snd_printk(KERN_INFO "%d:%u:%d : sample bitwidth %d in over sample bytes %d\n", |
2415 | chip->dev->devnum, fp->iface, fp->altsetting, | 2482 | chip->dev->devnum, fp->iface, fp->altsetting, |
2416 | sample_width, sample_bytes); | 2483 | sample_width, sample_bytes); |
2417 | } | 2484 | } |
2418 | /* check the format byte size */ | 2485 | /* check the format byte size */ |
2419 | switch (fmt[5]) { | 2486 | switch (sample_bytes) { |
2420 | case 1: | 2487 | case 1: |
2421 | pcm_format = SNDRV_PCM_FORMAT_S8; | 2488 | pcm_format = SNDRV_PCM_FORMAT_S8; |
2422 | break; | 2489 | break; |
@@ -2437,12 +2504,12 @@ static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audiofor | |||
2437 | break; | 2504 | break; |
2438 | default: | 2505 | default: |
2439 | snd_printk(KERN_INFO "%d:%u:%d : unsupported sample bitwidth %d in %d bytes\n", | 2506 | snd_printk(KERN_INFO "%d:%u:%d : unsupported sample bitwidth %d in %d bytes\n", |
2440 | chip->dev->devnum, fp->iface, | 2507 | chip->dev->devnum, fp->iface, fp->altsetting, |
2441 | fp->altsetting, sample_width, sample_bytes); | 2508 | sample_width, sample_bytes); |
2442 | break; | 2509 | break; |
2443 | } | 2510 | } |
2444 | break; | 2511 | break; |
2445 | case USB_AUDIO_FORMAT_PCM8: | 2512 | case UAC_FORMAT_TYPE_I_PCM8: |
2446 | pcm_format = SNDRV_PCM_FORMAT_U8; | 2513 | pcm_format = SNDRV_PCM_FORMAT_U8; |
2447 | 2514 | ||
2448 | /* Dallas DS4201 workaround: it advertises U8 format, but really | 2515 | /* Dallas DS4201 workaround: it advertises U8 format, but really |
@@ -2450,13 +2517,13 @@ static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audiofor | |||
2450 | if (chip->usb_id == USB_ID(0x04fa, 0x4201)) | 2517 | if (chip->usb_id == USB_ID(0x04fa, 0x4201)) |
2451 | pcm_format = SNDRV_PCM_FORMAT_S8; | 2518 | pcm_format = SNDRV_PCM_FORMAT_S8; |
2452 | break; | 2519 | break; |
2453 | case USB_AUDIO_FORMAT_IEEE_FLOAT: | 2520 | case UAC_FORMAT_TYPE_I_IEEE_FLOAT: |
2454 | pcm_format = SNDRV_PCM_FORMAT_FLOAT_LE; | 2521 | pcm_format = SNDRV_PCM_FORMAT_FLOAT_LE; |
2455 | break; | 2522 | break; |
2456 | case USB_AUDIO_FORMAT_ALAW: | 2523 | case UAC_FORMAT_TYPE_I_ALAW: |
2457 | pcm_format = SNDRV_PCM_FORMAT_A_LAW; | 2524 | pcm_format = SNDRV_PCM_FORMAT_A_LAW; |
2458 | break; | 2525 | break; |
2459 | case USB_AUDIO_FORMAT_MU_LAW: | 2526 | case UAC_FORMAT_TYPE_I_MULAW: |
2460 | pcm_format = SNDRV_PCM_FORMAT_MU_LAW; | 2527 | pcm_format = SNDRV_PCM_FORMAT_MU_LAW; |
2461 | break; | 2528 | break; |
2462 | default: | 2529 | default: |
@@ -2470,7 +2537,7 @@ static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audiofor | |||
2470 | 2537 | ||
2471 | /* | 2538 | /* |
2472 | * parse the format descriptor and stores the possible sample rates | 2539 | * parse the format descriptor and stores the possible sample rates |
2473 | * on the audioformat table. | 2540 | * on the audioformat table (audio class v1). |
2474 | * | 2541 | * |
2475 | * @dev: usb device | 2542 | * @dev: usb device |
2476 | * @fp: audioformat record | 2543 | * @fp: audioformat record |
@@ -2478,13 +2545,13 @@ static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audiofor | |||
2478 | * @offset: the start offset of descriptor pointing the rate type | 2545 | * @offset: the start offset of descriptor pointing the rate type |
2479 | * (7 for type I and II, 8 for type II) | 2546 | * (7 for type I and II, 8 for type II) |
2480 | */ | 2547 | */ |
2481 | static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioformat *fp, | 2548 | static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audioformat *fp, |
2482 | unsigned char *fmt, int offset) | 2549 | unsigned char *fmt, int offset) |
2483 | { | 2550 | { |
2484 | int nr_rates = fmt[offset]; | 2551 | int nr_rates = fmt[offset]; |
2485 | 2552 | ||
2486 | if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { | 2553 | if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { |
2487 | snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", | 2554 | snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n", |
2488 | chip->dev->devnum, fp->iface, fp->altsetting); | 2555 | chip->dev->devnum, fp->iface, fp->altsetting); |
2489 | return -1; | 2556 | return -1; |
2490 | } | 2557 | } |
@@ -2513,6 +2580,9 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2513 | chip->usb_id == USB_ID(0x0d8c, 0x0102)) && | 2580 | chip->usb_id == USB_ID(0x0d8c, 0x0102)) && |
2514 | fp->altsetting == 5 && fp->maxpacksize == 392) | 2581 | fp->altsetting == 5 && fp->maxpacksize == 392) |
2515 | rate = 96000; | 2582 | rate = 96000; |
2583 | /* Creative VF0470 Live Cam reports 16 kHz instead of 8kHz */ | ||
2584 | if (rate == 16000 && chip->usb_id == USB_ID(0x041e, 0x4068)) | ||
2585 | rate = 8000; | ||
2516 | fp->rate_table[fp->nr_rates] = rate; | 2586 | fp->rate_table[fp->nr_rates] = rate; |
2517 | if (!fp->rate_min || rate < fp->rate_min) | 2587 | if (!fp->rate_min || rate < fp->rate_min) |
2518 | fp->rate_min = rate; | 2588 | fp->rate_min = rate; |
@@ -2535,14 +2605,87 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2535 | } | 2605 | } |
2536 | 2606 | ||
2537 | /* | 2607 | /* |
2608 | * parse the format descriptor and stores the possible sample rates | ||
2609 | * on the audioformat table (audio class v2). | ||
2610 | */ | ||
2611 | static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, | ||
2612 | struct audioformat *fp, | ||
2613 | struct usb_host_interface *iface) | ||
2614 | { | ||
2615 | struct usb_device *dev = chip->dev; | ||
2616 | unsigned char tmp[2], *data; | ||
2617 | int i, nr_rates, data_size, ret = 0; | ||
2618 | |||
2619 | /* get the number of sample rates first by only fetching 2 bytes */ | ||
2620 | ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, | ||
2621 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | ||
2622 | 0x0100, chip->clock_id << 8, tmp, sizeof(tmp), 1000); | ||
2623 | |||
2624 | if (ret < 0) { | ||
2625 | snd_printk(KERN_ERR "unable to retrieve number of sample rates\n"); | ||
2626 | goto err; | ||
2627 | } | ||
2628 | |||
2629 | nr_rates = (tmp[1] << 8) | tmp[0]; | ||
2630 | data_size = 2 + 12 * nr_rates; | ||
2631 | data = kzalloc(data_size, GFP_KERNEL); | ||
2632 | if (!data) { | ||
2633 | ret = -ENOMEM; | ||
2634 | goto err; | ||
2635 | } | ||
2636 | |||
2637 | /* now get the full information */ | ||
2638 | ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, | ||
2639 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | ||
2640 | 0x0100, chip->clock_id << 8, data, data_size, 1000); | ||
2641 | |||
2642 | if (ret < 0) { | ||
2643 | snd_printk(KERN_ERR "unable to retrieve sample rate range\n"); | ||
2644 | ret = -EINVAL; | ||
2645 | goto err_free; | ||
2646 | } | ||
2647 | |||
2648 | fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); | ||
2649 | if (!fp->rate_table) { | ||
2650 | ret = -ENOMEM; | ||
2651 | goto err_free; | ||
2652 | } | ||
2653 | |||
2654 | fp->nr_rates = 0; | ||
2655 | fp->rate_min = fp->rate_max = 0; | ||
2656 | |||
2657 | for (i = 0; i < nr_rates; i++) { | ||
2658 | int rate = combine_quad(&data[2 + 12 * i]); | ||
2659 | |||
2660 | fp->rate_table[fp->nr_rates] = rate; | ||
2661 | if (!fp->rate_min || rate < fp->rate_min) | ||
2662 | fp->rate_min = rate; | ||
2663 | if (!fp->rate_max || rate > fp->rate_max) | ||
2664 | fp->rate_max = rate; | ||
2665 | fp->rates |= snd_pcm_rate_to_rate_bit(rate); | ||
2666 | fp->nr_rates++; | ||
2667 | } | ||
2668 | |||
2669 | err_free: | ||
2670 | kfree(data); | ||
2671 | err: | ||
2672 | return ret; | ||
2673 | } | ||
2674 | |||
2675 | /* | ||
2538 | * parse the format type I and III descriptors | 2676 | * parse the format type I and III descriptors |
2539 | */ | 2677 | */ |
2540 | static int parse_audio_format_i(struct snd_usb_audio *chip, struct audioformat *fp, | 2678 | static int parse_audio_format_i(struct snd_usb_audio *chip, |
2541 | int format, unsigned char *fmt) | 2679 | struct audioformat *fp, |
2680 | int format, void *_fmt, | ||
2681 | struct usb_host_interface *iface) | ||
2542 | { | 2682 | { |
2543 | int pcm_format; | 2683 | struct usb_interface_descriptor *altsd = get_iface_desc(iface); |
2684 | struct uac_format_type_i_discrete_descriptor *fmt = _fmt; | ||
2685 | int protocol = altsd->bInterfaceProtocol; | ||
2686 | int pcm_format, ret; | ||
2544 | 2687 | ||
2545 | if (fmt[3] == USB_FORMAT_TYPE_III) { | 2688 | if (fmt->bFormatType == UAC_FORMAT_TYPE_III) { |
2546 | /* FIXME: the format type is really IECxxx | 2689 | /* FIXME: the format type is really IECxxx |
2547 | * but we give normal PCM format to get the existing | 2690 | * but we give normal PCM format to get the existing |
2548 | * apps working... | 2691 | * apps working... |
@@ -2560,34 +2703,57 @@ static int parse_audio_format_i(struct snd_usb_audio *chip, struct audioformat * | |||
2560 | pcm_format = SNDRV_PCM_FORMAT_S16_LE; | 2703 | pcm_format = SNDRV_PCM_FORMAT_S16_LE; |
2561 | } | 2704 | } |
2562 | } else { | 2705 | } else { |
2563 | pcm_format = parse_audio_format_i_type(chip, fp, format, fmt); | 2706 | pcm_format = parse_audio_format_i_type(chip, fp, format, fmt, protocol); |
2564 | if (pcm_format < 0) | 2707 | if (pcm_format < 0) |
2565 | return -1; | 2708 | return -1; |
2566 | } | 2709 | } |
2710 | |||
2567 | fp->format = pcm_format; | 2711 | fp->format = pcm_format; |
2568 | fp->channels = fmt[4]; | 2712 | |
2713 | /* gather possible sample rates */ | ||
2714 | /* audio class v1 reports possible sample rates as part of the | ||
2715 | * proprietary class specific descriptor. | ||
2716 | * audio class v2 uses class specific EP0 range requests for that. | ||
2717 | */ | ||
2718 | switch (protocol) { | ||
2719 | case UAC_VERSION_1: | ||
2720 | fp->channels = fmt->bNrChannels; | ||
2721 | ret = parse_audio_format_rates_v1(chip, fp, _fmt, 7); | ||
2722 | break; | ||
2723 | case UAC_VERSION_2: | ||
2724 | /* fp->channels is already set in this case */ | ||
2725 | ret = parse_audio_format_rates_v2(chip, fp, iface); | ||
2726 | break; | ||
2727 | } | ||
2728 | |||
2569 | if (fp->channels < 1) { | 2729 | if (fp->channels < 1) { |
2570 | snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n", | 2730 | snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n", |
2571 | chip->dev->devnum, fp->iface, fp->altsetting, fp->channels); | 2731 | chip->dev->devnum, fp->iface, fp->altsetting, fp->channels); |
2572 | return -1; | 2732 | return -1; |
2573 | } | 2733 | } |
2574 | return parse_audio_format_rates(chip, fp, fmt, 7); | 2734 | |
2735 | return ret; | ||
2575 | } | 2736 | } |
2576 | 2737 | ||
2577 | /* | 2738 | /* |
2578 | * prase the format type II descriptor | 2739 | * parse the format type II descriptor |
2579 | */ | 2740 | */ |
2580 | static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat *fp, | 2741 | static int parse_audio_format_ii(struct snd_usb_audio *chip, |
2581 | int format, unsigned char *fmt) | 2742 | struct audioformat *fp, |
2743 | int format, void *_fmt, | ||
2744 | struct usb_host_interface *iface) | ||
2582 | { | 2745 | { |
2583 | int brate, framesize; | 2746 | int brate, framesize, ret; |
2747 | struct usb_interface_descriptor *altsd = get_iface_desc(iface); | ||
2748 | int protocol = altsd->bInterfaceProtocol; | ||
2749 | |||
2584 | switch (format) { | 2750 | switch (format) { |
2585 | case USB_AUDIO_FORMAT_AC3: | 2751 | case UAC_FORMAT_TYPE_II_AC3: |
2586 | /* FIXME: there is no AC3 format defined yet */ | 2752 | /* FIXME: there is no AC3 format defined yet */ |
2587 | // fp->format = SNDRV_PCM_FORMAT_AC3; | 2753 | // fp->format = SNDRV_PCM_FORMAT_AC3; |
2588 | fp->format = SNDRV_PCM_FORMAT_U8; /* temporarily hack to receive byte streams */ | 2754 | fp->format = SNDRV_PCM_FORMAT_U8; /* temporarily hack to receive byte streams */ |
2589 | break; | 2755 | break; |
2590 | case USB_AUDIO_FORMAT_MPEG: | 2756 | case UAC_FORMAT_TYPE_II_MPEG: |
2591 | fp->format = SNDRV_PCM_FORMAT_MPEG; | 2757 | fp->format = SNDRV_PCM_FORMAT_MPEG; |
2592 | break; | 2758 | break; |
2593 | default: | 2759 | default: |
@@ -2596,26 +2762,46 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat | |||
2596 | fp->format = SNDRV_PCM_FORMAT_MPEG; | 2762 | fp->format = SNDRV_PCM_FORMAT_MPEG; |
2597 | break; | 2763 | break; |
2598 | } | 2764 | } |
2765 | |||
2599 | fp->channels = 1; | 2766 | fp->channels = 1; |
2600 | brate = combine_word(&fmt[4]); /* fmt[4,5] : wMaxBitRate (in kbps) */ | 2767 | |
2601 | framesize = combine_word(&fmt[6]); /* fmt[6,7]: wSamplesPerFrame */ | 2768 | switch (protocol) { |
2602 | snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); | 2769 | case UAC_VERSION_1: { |
2603 | fp->frame_size = framesize; | 2770 | struct uac_format_type_ii_discrete_descriptor *fmt = _fmt; |
2604 | return parse_audio_format_rates(chip, fp, fmt, 8); /* fmt[8..] sample rates */ | 2771 | brate = le16_to_cpu(fmt->wMaxBitRate); |
2772 | framesize = le16_to_cpu(fmt->wSamplesPerFrame); | ||
2773 | snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); | ||
2774 | fp->frame_size = framesize; | ||
2775 | ret = parse_audio_format_rates_v1(chip, fp, _fmt, 8); /* fmt[8..] sample rates */ | ||
2776 | break; | ||
2777 | } | ||
2778 | case UAC_VERSION_2: { | ||
2779 | struct uac_format_type_ii_ext_descriptor *fmt = _fmt; | ||
2780 | brate = le16_to_cpu(fmt->wMaxBitRate); | ||
2781 | framesize = le16_to_cpu(fmt->wSamplesPerFrame); | ||
2782 | snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); | ||
2783 | fp->frame_size = framesize; | ||
2784 | ret = parse_audio_format_rates_v2(chip, fp, iface); | ||
2785 | break; | ||
2786 | } | ||
2787 | } | ||
2788 | |||
2789 | return ret; | ||
2605 | } | 2790 | } |
2606 | 2791 | ||
2607 | static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp, | 2792 | static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp, |
2608 | int format, unsigned char *fmt, int stream) | 2793 | int format, unsigned char *fmt, int stream, |
2794 | struct usb_host_interface *iface) | ||
2609 | { | 2795 | { |
2610 | int err; | 2796 | int err; |
2611 | 2797 | ||
2612 | switch (fmt[3]) { | 2798 | switch (fmt[3]) { |
2613 | case USB_FORMAT_TYPE_I: | 2799 | case UAC_FORMAT_TYPE_I: |
2614 | case USB_FORMAT_TYPE_III: | 2800 | case UAC_FORMAT_TYPE_III: |
2615 | err = parse_audio_format_i(chip, fp, format, fmt); | 2801 | err = parse_audio_format_i(chip, fp, format, fmt, iface); |
2616 | break; | 2802 | break; |
2617 | case USB_FORMAT_TYPE_II: | 2803 | case UAC_FORMAT_TYPE_II: |
2618 | err = parse_audio_format_ii(chip, fp, format, fmt); | 2804 | err = parse_audio_format_ii(chip, fp, format, fmt, iface); |
2619 | break; | 2805 | break; |
2620 | default: | 2806 | default: |
2621 | snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n", | 2807 | snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n", |
@@ -2633,7 +2819,7 @@ static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp | |||
2633 | if (chip->usb_id == USB_ID(0x041e, 0x3000) || | 2819 | if (chip->usb_id == USB_ID(0x041e, 0x3000) || |
2634 | chip->usb_id == USB_ID(0x041e, 0x3020) || | 2820 | chip->usb_id == USB_ID(0x041e, 0x3020) || |
2635 | chip->usb_id == USB_ID(0x041e, 0x3061)) { | 2821 | chip->usb_id == USB_ID(0x041e, 0x3061)) { |
2636 | if (fmt[3] == USB_FORMAT_TYPE_I && | 2822 | if (fmt[3] == UAC_FORMAT_TYPE_I && |
2637 | fp->rates != SNDRV_PCM_RATE_48000 && | 2823 | fp->rates != SNDRV_PCM_RATE_48000 && |
2638 | fp->rates != SNDRV_PCM_RATE_96000) | 2824 | fp->rates != SNDRV_PCM_RATE_96000) |
2639 | return -1; | 2825 | return -1; |
@@ -2662,10 +2848,10 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2662 | struct usb_host_interface *alts; | 2848 | struct usb_host_interface *alts; |
2663 | struct usb_interface_descriptor *altsd; | 2849 | struct usb_interface_descriptor *altsd; |
2664 | int i, altno, err, stream; | 2850 | int i, altno, err, stream; |
2665 | int format; | 2851 | int format = 0, num_channels = 0; |
2666 | struct audioformat *fp = NULL; | 2852 | struct audioformat *fp = NULL; |
2667 | unsigned char *fmt, *csep; | 2853 | unsigned char *fmt, *csep; |
2668 | int num; | 2854 | int num, protocol; |
2669 | 2855 | ||
2670 | dev = chip->dev; | 2856 | dev = chip->dev; |
2671 | 2857 | ||
@@ -2684,10 +2870,11 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2684 | for (i = 0; i < num; i++) { | 2870 | for (i = 0; i < num; i++) { |
2685 | alts = &iface->altsetting[i]; | 2871 | alts = &iface->altsetting[i]; |
2686 | altsd = get_iface_desc(alts); | 2872 | altsd = get_iface_desc(alts); |
2873 | protocol = altsd->bInterfaceProtocol; | ||
2687 | /* skip invalid one */ | 2874 | /* skip invalid one */ |
2688 | if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && | 2875 | if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && |
2689 | altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || | 2876 | altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || |
2690 | (altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING && | 2877 | (altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING && |
2691 | altsd->bInterfaceSubClass != USB_SUBCLASS_VENDOR_SPEC) || | 2878 | altsd->bInterfaceSubClass != USB_SUBCLASS_VENDOR_SPEC) || |
2692 | altsd->bNumEndpoints < 1 || | 2879 | altsd->bNumEndpoints < 1 || |
2693 | le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == 0) | 2880 | le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == 0) |
@@ -2708,30 +2895,65 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2708 | continue; | 2895 | continue; |
2709 | 2896 | ||
2710 | /* get audio formats */ | 2897 | /* get audio formats */ |
2711 | fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, AS_GENERAL); | 2898 | switch (protocol) { |
2712 | if (!fmt) { | 2899 | case UAC_VERSION_1: { |
2713 | snd_printk(KERN_ERR "%d:%u:%d : AS_GENERAL descriptor not found\n", | 2900 | struct uac_as_header_descriptor_v1 *as = |
2714 | dev->devnum, iface_no, altno); | 2901 | snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL); |
2715 | continue; | 2902 | |
2903 | if (!as) { | ||
2904 | snd_printk(KERN_ERR "%d:%u:%d : UAC_AS_GENERAL descriptor not found\n", | ||
2905 | dev->devnum, iface_no, altno); | ||
2906 | continue; | ||
2907 | } | ||
2908 | |||
2909 | if (as->bLength < sizeof(*as)) { | ||
2910 | snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_AS_GENERAL desc\n", | ||
2911 | dev->devnum, iface_no, altno); | ||
2912 | continue; | ||
2913 | } | ||
2914 | |||
2915 | format = le16_to_cpu(as->wFormatTag); /* remember the format value */ | ||
2916 | break; | ||
2716 | } | 2917 | } |
2717 | 2918 | ||
2718 | if (fmt[0] < 7) { | 2919 | case UAC_VERSION_2: { |
2719 | snd_printk(KERN_ERR "%d:%u:%d : invalid AS_GENERAL desc\n", | 2920 | struct uac_as_header_descriptor_v2 *as = |
2720 | dev->devnum, iface_no, altno); | 2921 | snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL); |
2721 | continue; | 2922 | |
2923 | if (!as) { | ||
2924 | snd_printk(KERN_ERR "%d:%u:%d : UAC_AS_GENERAL descriptor not found\n", | ||
2925 | dev->devnum, iface_no, altno); | ||
2926 | continue; | ||
2927 | } | ||
2928 | |||
2929 | if (as->bLength < sizeof(*as)) { | ||
2930 | snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_AS_GENERAL desc\n", | ||
2931 | dev->devnum, iface_no, altno); | ||
2932 | continue; | ||
2933 | } | ||
2934 | |||
2935 | num_channels = as->bNrChannels; | ||
2936 | format = le32_to_cpu(as->bmFormats); | ||
2937 | |||
2938 | break; | ||
2722 | } | 2939 | } |
2723 | 2940 | ||
2724 | format = (fmt[6] << 8) | fmt[5]; /* remember the format value */ | 2941 | default: |
2942 | snd_printk(KERN_ERR "%d:%u:%d : unknown interface protocol %04x\n", | ||
2943 | dev->devnum, iface_no, altno, protocol); | ||
2944 | continue; | ||
2945 | } | ||
2725 | 2946 | ||
2726 | /* get format type */ | 2947 | /* get format type */ |
2727 | fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, FORMAT_TYPE); | 2948 | fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_FORMAT_TYPE); |
2728 | if (!fmt) { | 2949 | if (!fmt) { |
2729 | snd_printk(KERN_ERR "%d:%u:%d : no FORMAT_TYPE desc\n", | 2950 | snd_printk(KERN_ERR "%d:%u:%d : no UAC_FORMAT_TYPE desc\n", |
2730 | dev->devnum, iface_no, altno); | 2951 | dev->devnum, iface_no, altno); |
2731 | continue; | 2952 | continue; |
2732 | } | 2953 | } |
2733 | if (fmt[0] < 8) { | 2954 | if (((protocol == UAC_VERSION_1) && (fmt[0] < 8)) || |
2734 | snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", | 2955 | ((protocol == UAC_VERSION_2) && (fmt[0] != 6))) { |
2956 | snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n", | ||
2735 | dev->devnum, iface_no, altno); | 2957 | dev->devnum, iface_no, altno); |
2736 | continue; | 2958 | continue; |
2737 | } | 2959 | } |
@@ -2744,6 +2966,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2744 | if (fmt[4] == 1 && fmt[5] == 2 && altno == 2 && num == 3 && | 2966 | if (fmt[4] == 1 && fmt[5] == 2 && altno == 2 && num == 3 && |
2745 | fp && fp->altsetting == 1 && fp->channels == 1 && | 2967 | fp && fp->altsetting == 1 && fp->channels == 1 && |
2746 | fp->format == SNDRV_PCM_FORMAT_S16_LE && | 2968 | fp->format == SNDRV_PCM_FORMAT_S16_LE && |
2969 | protocol == UAC_VERSION_1 && | ||
2747 | le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == | 2970 | le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == |
2748 | fp->maxpacksize * 2) | 2971 | fp->maxpacksize * 2) |
2749 | continue; | 2972 | continue; |
@@ -2752,7 +2975,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2752 | /* Creamware Noah has this descriptor after the 2nd endpoint */ | 2975 | /* Creamware Noah has this descriptor after the 2nd endpoint */ |
2753 | if (!csep && altsd->bNumEndpoints >= 2) | 2976 | if (!csep && altsd->bNumEndpoints >= 2) |
2754 | csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT); | 2977 | csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT); |
2755 | if (!csep || csep[0] < 7 || csep[2] != EP_GENERAL) { | 2978 | if (!csep || csep[0] < 7 || csep[2] != UAC_EP_GENERAL) { |
2756 | snd_printk(KERN_WARNING "%d:%u:%d : no or invalid" | 2979 | snd_printk(KERN_WARNING "%d:%u:%d : no or invalid" |
2757 | " class specific endpoint descriptor\n", | 2980 | " class specific endpoint descriptor\n", |
2758 | dev->devnum, iface_no, altno); | 2981 | dev->devnum, iface_no, altno); |
@@ -2772,6 +2995,8 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2772 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | 2995 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; |
2773 | fp->datainterval = parse_datainterval(chip, alts); | 2996 | fp->datainterval = parse_datainterval(chip, alts); |
2774 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 2997 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
2998 | /* num_channels is only set for v2 interfaces */ | ||
2999 | fp->channels = num_channels; | ||
2775 | if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) | 3000 | if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) |
2776 | fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) | 3001 | fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) |
2777 | * (fp->maxpacksize & 0x7ff); | 3002 | * (fp->maxpacksize & 0x7ff); |
@@ -2784,12 +3009,12 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2784 | /* Optoplay sets the sample rate attribute although | 3009 | /* Optoplay sets the sample rate attribute although |
2785 | * it seems not supporting it in fact. | 3010 | * it seems not supporting it in fact. |
2786 | */ | 3011 | */ |
2787 | fp->attributes &= ~EP_CS_ATTR_SAMPLE_RATE; | 3012 | fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE; |
2788 | break; | 3013 | break; |
2789 | case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */ | 3014 | case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */ |
2790 | case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ | 3015 | case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ |
2791 | /* doesn't set the sample rate attribute, but supports it */ | 3016 | /* doesn't set the sample rate attribute, but supports it */ |
2792 | fp->attributes |= EP_CS_ATTR_SAMPLE_RATE; | 3017 | fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE; |
2793 | break; | 3018 | break; |
2794 | case USB_ID(0x047f, 0x0ca1): /* plantronics headset */ | 3019 | case USB_ID(0x047f, 0x0ca1): /* plantronics headset */ |
2795 | case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is | 3020 | case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is |
@@ -2798,16 +3023,16 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2798 | * plantronics headset and Griffin iMic have set adaptive-in | 3023 | * plantronics headset and Griffin iMic have set adaptive-in |
2799 | * although it's really not... | 3024 | * although it's really not... |
2800 | */ | 3025 | */ |
2801 | fp->ep_attr &= ~EP_ATTR_MASK; | 3026 | fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE; |
2802 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) | 3027 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) |
2803 | fp->ep_attr |= EP_ATTR_ADAPTIVE; | 3028 | fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE; |
2804 | else | 3029 | else |
2805 | fp->ep_attr |= EP_ATTR_SYNC; | 3030 | fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC; |
2806 | break; | 3031 | break; |
2807 | } | 3032 | } |
2808 | 3033 | ||
2809 | /* ok, let's parse further... */ | 3034 | /* ok, let's parse further... */ |
2810 | if (parse_audio_format(chip, fp, format, fmt, stream) < 0) { | 3035 | if (parse_audio_format(chip, fp, format, fmt, stream, alts) < 0) { |
2811 | kfree(fp->rate_table); | 3036 | kfree(fp->rate_table); |
2812 | kfree(fp); | 3037 | kfree(fp); |
2813 | continue; | 3038 | continue; |
@@ -2849,6 +3074,65 @@ static void snd_usb_stream_disconnect(struct list_head *head) | |||
2849 | } | 3074 | } |
2850 | } | 3075 | } |
2851 | 3076 | ||
3077 | static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int interface) | ||
3078 | { | ||
3079 | struct usb_device *dev = chip->dev; | ||
3080 | struct usb_host_interface *alts; | ||
3081 | struct usb_interface_descriptor *altsd; | ||
3082 | struct usb_interface *iface = usb_ifnum_to_if(dev, interface); | ||
3083 | |||
3084 | if (!iface) { | ||
3085 | snd_printk(KERN_ERR "%d:%u:%d : does not exist\n", | ||
3086 | dev->devnum, ctrlif, interface); | ||
3087 | return -EINVAL; | ||
3088 | } | ||
3089 | |||
3090 | if (usb_interface_claimed(iface)) { | ||
3091 | snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n", | ||
3092 | dev->devnum, ctrlif, interface); | ||
3093 | return -EINVAL; | ||
3094 | } | ||
3095 | |||
3096 | alts = &iface->altsetting[0]; | ||
3097 | altsd = get_iface_desc(alts); | ||
3098 | if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || | ||
3099 | altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && | ||
3100 | altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) { | ||
3101 | int err = snd_usbmidi_create(chip->card, iface, | ||
3102 | &chip->midi_list, NULL); | ||
3103 | if (err < 0) { | ||
3104 | snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", | ||
3105 | dev->devnum, ctrlif, interface); | ||
3106 | return -EINVAL; | ||
3107 | } | ||
3108 | usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); | ||
3109 | |||
3110 | return 0; | ||
3111 | } | ||
3112 | |||
3113 | if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && | ||
3114 | altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || | ||
3115 | altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING) { | ||
3116 | snd_printdd(KERN_ERR "%d:%u:%d: skipping non-supported interface %d\n", | ||
3117 | dev->devnum, ctrlif, interface, altsd->bInterfaceClass); | ||
3118 | /* skip non-supported classes */ | ||
3119 | return -EINVAL; | ||
3120 | } | ||
3121 | |||
3122 | if (snd_usb_get_speed(dev) == USB_SPEED_LOW) { | ||
3123 | snd_printk(KERN_ERR "low speed audio streaming not supported\n"); | ||
3124 | return -EINVAL; | ||
3125 | } | ||
3126 | |||
3127 | if (! parse_audio_endpoints(chip, interface)) { | ||
3128 | usb_set_interface(dev, interface, 0); /* reset the current interface */ | ||
3129 | usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); | ||
3130 | return -EINVAL; | ||
3131 | } | ||
3132 | |||
3133 | return 0; | ||
3134 | } | ||
3135 | |||
2852 | /* | 3136 | /* |
2853 | * parse audio control descriptor and create pcm/midi streams | 3137 | * parse audio control descriptor and create pcm/midi streams |
2854 | */ | 3138 | */ |
@@ -2856,67 +3140,81 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) | |||
2856 | { | 3140 | { |
2857 | struct usb_device *dev = chip->dev; | 3141 | struct usb_device *dev = chip->dev; |
2858 | struct usb_host_interface *host_iface; | 3142 | struct usb_host_interface *host_iface; |
2859 | struct usb_interface *iface; | 3143 | struct usb_interface_descriptor *altsd; |
2860 | unsigned char *p1; | 3144 | void *control_header; |
2861 | int i, j; | 3145 | int i, protocol; |
2862 | 3146 | ||
2863 | /* find audiocontrol interface */ | 3147 | /* find audiocontrol interface */ |
2864 | host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0]; | 3148 | host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0]; |
2865 | if (!(p1 = snd_usb_find_csint_desc(host_iface->extra, host_iface->extralen, NULL, HEADER))) { | 3149 | control_header = snd_usb_find_csint_desc(host_iface->extra, |
2866 | snd_printk(KERN_ERR "cannot find HEADER\n"); | 3150 | host_iface->extralen, |
2867 | return -EINVAL; | 3151 | NULL, UAC_HEADER); |
2868 | } | 3152 | altsd = get_iface_desc(host_iface); |
2869 | if (! p1[7] || p1[0] < 8 + p1[7]) { | 3153 | protocol = altsd->bInterfaceProtocol; |
2870 | snd_printk(KERN_ERR "invalid HEADER\n"); | 3154 | |
3155 | if (!control_header) { | ||
3156 | snd_printk(KERN_ERR "cannot find UAC_HEADER\n"); | ||
2871 | return -EINVAL; | 3157 | return -EINVAL; |
2872 | } | 3158 | } |
2873 | 3159 | ||
2874 | /* | 3160 | switch (protocol) { |
2875 | * parse all USB audio streaming interfaces | 3161 | case UAC_VERSION_1: { |
2876 | */ | 3162 | struct uac_ac_header_descriptor_v1 *h1 = control_header; |
2877 | for (i = 0; i < p1[7]; i++) { | 3163 | |
2878 | struct usb_host_interface *alts; | 3164 | if (!h1->bInCollection) { |
2879 | struct usb_interface_descriptor *altsd; | 3165 | snd_printk(KERN_INFO "skipping empty audio interface (v1)\n"); |
2880 | j = p1[8 + i]; | 3166 | return -EINVAL; |
2881 | iface = usb_ifnum_to_if(dev, j); | ||
2882 | if (!iface) { | ||
2883 | snd_printk(KERN_ERR "%d:%u:%d : does not exist\n", | ||
2884 | dev->devnum, ctrlif, j); | ||
2885 | continue; | ||
2886 | } | ||
2887 | if (usb_interface_claimed(iface)) { | ||
2888 | snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n", dev->devnum, ctrlif, j); | ||
2889 | continue; | ||
2890 | } | 3167 | } |
2891 | alts = &iface->altsetting[0]; | 3168 | |
2892 | altsd = get_iface_desc(alts); | 3169 | if (h1->bLength < sizeof(*h1) + h1->bInCollection) { |
2893 | if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || | 3170 | snd_printk(KERN_ERR "invalid UAC_HEADER (v1)\n"); |
2894 | altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && | 3171 | return -EINVAL; |
2895 | altsd->bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) { | ||
2896 | int err = snd_usbmidi_create(chip->card, iface, | ||
2897 | &chip->midi_list, NULL); | ||
2898 | if (err < 0) { | ||
2899 | snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j); | ||
2900 | continue; | ||
2901 | } | ||
2902 | usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); | ||
2903 | continue; | ||
2904 | } | 3172 | } |
2905 | if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && | 3173 | |
2906 | altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || | 3174 | for (i = 0; i < h1->bInCollection; i++) |
2907 | altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING) { | 3175 | snd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]); |
2908 | snd_printdd(KERN_ERR "%d:%u:%d: skipping non-supported interface %d\n", dev->devnum, ctrlif, j, altsd->bInterfaceClass); | 3176 | |
2909 | /* skip non-supported classes */ | 3177 | break; |
2910 | continue; | 3178 | } |
3179 | |||
3180 | case UAC_VERSION_2: { | ||
3181 | struct uac_clock_source_descriptor *cs; | ||
3182 | struct usb_interface_assoc_descriptor *assoc = | ||
3183 | usb_ifnum_to_if(dev, ctrlif)->intf_assoc; | ||
3184 | |||
3185 | if (!assoc) { | ||
3186 | snd_printk(KERN_ERR "Audio class v2 interfaces need an interface association\n"); | ||
3187 | return -EINVAL; | ||
2911 | } | 3188 | } |
2912 | if (snd_usb_get_speed(dev) == USB_SPEED_LOW) { | 3189 | |
2913 | snd_printk(KERN_ERR "low speed audio streaming not supported\n"); | 3190 | /* FIXME: for now, we expect there is at least one clock source |
2914 | continue; | 3191 | * descriptor and we always take the first one. |
3192 | * We should properly support devices with multiple clock sources, | ||
3193 | * clock selectors and sample rate conversion units. */ | ||
3194 | |||
3195 | cs = snd_usb_find_csint_desc(host_iface->extra, host_iface->extralen, | ||
3196 | NULL, UAC_CLOCK_SOURCE); | ||
3197 | |||
3198 | if (!cs) { | ||
3199 | snd_printk(KERN_ERR "CLOCK_SOURCE descriptor not found\n"); | ||
3200 | return -EINVAL; | ||
2915 | } | 3201 | } |
2916 | if (! parse_audio_endpoints(chip, j)) { | 3202 | |
2917 | usb_set_interface(dev, j, 0); /* reset the current interface */ | 3203 | chip->clock_id = cs->bClockID; |
2918 | usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); | 3204 | |
3205 | for (i = 0; i < assoc->bInterfaceCount; i++) { | ||
3206 | int intf = assoc->bFirstInterface + i; | ||
3207 | |||
3208 | if (intf != ctrlif) | ||
3209 | snd_usb_create_stream(chip, ctrlif, intf); | ||
2919 | } | 3210 | } |
3211 | |||
3212 | break; | ||
3213 | } | ||
3214 | |||
3215 | default: | ||
3216 | snd_printk(KERN_ERR "unknown protocol version 0x%02x\n", protocol); | ||
3217 | return -EINVAL; | ||
2920 | } | 3218 | } |
2921 | 3219 | ||
2922 | return 0; | 3220 | return 0; |
@@ -3007,7 +3305,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip, | |||
3007 | static const struct audioformat ua_format = { | 3305 | static const struct audioformat ua_format = { |
3008 | .format = SNDRV_PCM_FORMAT_S24_3LE, | 3306 | .format = SNDRV_PCM_FORMAT_S24_3LE, |
3009 | .channels = 2, | 3307 | .channels = 2, |
3010 | .fmt_type = USB_FORMAT_TYPE_I, | 3308 | .fmt_type = UAC_FORMAT_TYPE_I, |
3011 | .altsetting = 1, | 3309 | .altsetting = 1, |
3012 | .altset_idx = 1, | 3310 | .altset_idx = 1, |
3013 | .rates = SNDRV_PCM_RATE_CONTINUOUS, | 3311 | .rates = SNDRV_PCM_RATE_CONTINUOUS, |
@@ -3090,111 +3388,6 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip, | |||
3090 | return 0; | 3388 | return 0; |
3091 | } | 3389 | } |
3092 | 3390 | ||
3093 | /* | ||
3094 | * Create a stream for an Edirol UA-1000 interface. | ||
3095 | */ | ||
3096 | static int create_ua1000_quirk(struct snd_usb_audio *chip, | ||
3097 | struct usb_interface *iface, | ||
3098 | const struct snd_usb_audio_quirk *quirk) | ||
3099 | { | ||
3100 | static const struct audioformat ua1000_format = { | ||
3101 | .format = SNDRV_PCM_FORMAT_S32_LE, | ||
3102 | .fmt_type = USB_FORMAT_TYPE_I, | ||
3103 | .altsetting = 1, | ||
3104 | .altset_idx = 1, | ||
3105 | .attributes = 0, | ||
3106 | .rates = SNDRV_PCM_RATE_CONTINUOUS, | ||
3107 | }; | ||
3108 | struct usb_host_interface *alts; | ||
3109 | struct usb_interface_descriptor *altsd; | ||
3110 | struct audioformat *fp; | ||
3111 | int stream, err; | ||
3112 | |||
3113 | if (iface->num_altsetting != 2) | ||
3114 | return -ENXIO; | ||
3115 | alts = &iface->altsetting[1]; | ||
3116 | altsd = get_iface_desc(alts); | ||
3117 | if (alts->extralen != 11 || alts->extra[1] != USB_DT_CS_INTERFACE || | ||
3118 | altsd->bNumEndpoints != 1) | ||
3119 | return -ENXIO; | ||
3120 | |||
3121 | fp = kmemdup(&ua1000_format, sizeof(*fp), GFP_KERNEL); | ||
3122 | if (!fp) | ||
3123 | return -ENOMEM; | ||
3124 | |||
3125 | fp->channels = alts->extra[4]; | ||
3126 | fp->iface = altsd->bInterfaceNumber; | ||
3127 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | ||
3128 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | ||
3129 | fp->datainterval = parse_datainterval(chip, alts); | ||
3130 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | ||
3131 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]); | ||
3132 | |||
3133 | stream = (fp->endpoint & USB_DIR_IN) | ||
3134 | ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; | ||
3135 | err = add_audio_endpoint(chip, stream, fp); | ||
3136 | if (err < 0) { | ||
3137 | kfree(fp); | ||
3138 | return err; | ||
3139 | } | ||
3140 | /* FIXME: playback must be synchronized to capture */ | ||
3141 | usb_set_interface(chip->dev, fp->iface, 0); | ||
3142 | return 0; | ||
3143 | } | ||
3144 | |||
3145 | /* | ||
3146 | * Create a stream for an Edirol UA-101 interface. | ||
3147 | * Copy, paste and modify from Edirol UA-1000 | ||
3148 | */ | ||
3149 | static int create_ua101_quirk(struct snd_usb_audio *chip, | ||
3150 | struct usb_interface *iface, | ||
3151 | const struct snd_usb_audio_quirk *quirk) | ||
3152 | { | ||
3153 | static const struct audioformat ua101_format = { | ||
3154 | .format = SNDRV_PCM_FORMAT_S32_LE, | ||
3155 | .fmt_type = USB_FORMAT_TYPE_I, | ||
3156 | .altsetting = 1, | ||
3157 | .altset_idx = 1, | ||
3158 | .attributes = 0, | ||
3159 | .rates = SNDRV_PCM_RATE_CONTINUOUS, | ||
3160 | }; | ||
3161 | struct usb_host_interface *alts; | ||
3162 | struct usb_interface_descriptor *altsd; | ||
3163 | struct audioformat *fp; | ||
3164 | int stream, err; | ||
3165 | |||
3166 | if (iface->num_altsetting != 2) | ||
3167 | return -ENXIO; | ||
3168 | alts = &iface->altsetting[1]; | ||
3169 | altsd = get_iface_desc(alts); | ||
3170 | if (alts->extralen != 18 || alts->extra[1] != USB_DT_CS_INTERFACE || | ||
3171 | altsd->bNumEndpoints != 1) | ||
3172 | return -ENXIO; | ||
3173 | |||
3174 | fp = kmemdup(&ua101_format, sizeof(*fp), GFP_KERNEL); | ||
3175 | if (!fp) | ||
3176 | return -ENOMEM; | ||
3177 | |||
3178 | fp->channels = alts->extra[11]; | ||
3179 | fp->iface = altsd->bInterfaceNumber; | ||
3180 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | ||
3181 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | ||
3182 | fp->datainterval = parse_datainterval(chip, alts); | ||
3183 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | ||
3184 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]); | ||
3185 | |||
3186 | stream = (fp->endpoint & USB_DIR_IN) | ||
3187 | ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; | ||
3188 | err = add_audio_endpoint(chip, stream, fp); | ||
3189 | if (err < 0) { | ||
3190 | kfree(fp); | ||
3191 | return err; | ||
3192 | } | ||
3193 | /* FIXME: playback must be synchronized to capture */ | ||
3194 | usb_set_interface(chip->dev, fp->iface, 0); | ||
3195 | return 0; | ||
3196 | } | ||
3197 | |||
3198 | static int snd_usb_create_quirk(struct snd_usb_audio *chip, | 3391 | static int snd_usb_create_quirk(struct snd_usb_audio *chip, |
3199 | struct usb_interface *iface, | 3392 | struct usb_interface *iface, |
3200 | const struct snd_usb_audio_quirk *quirk); | 3393 | const struct snd_usb_audio_quirk *quirk); |
@@ -3232,6 +3425,18 @@ static int ignore_interface_quirk(struct snd_usb_audio *chip, | |||
3232 | return 0; | 3425 | return 0; |
3233 | } | 3426 | } |
3234 | 3427 | ||
3428 | /* | ||
3429 | * Allow alignment on audio sub-slot (channel samples) rather than | ||
3430 | * on audio slots (audio frames) | ||
3431 | */ | ||
3432 | static int create_align_transfer_quirk(struct snd_usb_audio *chip, | ||
3433 | struct usb_interface *iface, | ||
3434 | const struct snd_usb_audio_quirk *quirk) | ||
3435 | { | ||
3436 | chip->txfr_quirk = 1; | ||
3437 | return 1; /* Continue with creating streams and mixer */ | ||
3438 | } | ||
3439 | |||
3235 | 3440 | ||
3236 | /* | 3441 | /* |
3237 | * boot quirks | 3442 | * boot quirks |
@@ -3327,6 +3532,32 @@ static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) | |||
3327 | } | 3532 | } |
3328 | 3533 | ||
3329 | /* | 3534 | /* |
3535 | * This call will put the synth in "USB send" mode, i.e it will send MIDI | ||
3536 | * messages through USB (this is disabled at startup). The synth will | ||
3537 | * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB | ||
3538 | * sign on its LCD. Values here are chosen based on sniffing USB traffic | ||
3539 | * under Windows. | ||
3540 | */ | ||
3541 | static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) | ||
3542 | { | ||
3543 | int err, actual_length; | ||
3544 | |||
3545 | /* "midi send" enable */ | ||
3546 | static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; | ||
3547 | |||
3548 | void *buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); | ||
3549 | if (!buf) | ||
3550 | return -ENOMEM; | ||
3551 | err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x05), buf, | ||
3552 | ARRAY_SIZE(seq), &actual_length, 1000); | ||
3553 | kfree(buf); | ||
3554 | if (err < 0) | ||
3555 | return err; | ||
3556 | |||
3557 | return 0; | ||
3558 | } | ||
3559 | |||
3560 | /* | ||
3330 | * Setup quirks | 3561 | * Setup quirks |
3331 | */ | 3562 | */ |
3332 | #define AUDIOPHILE_SET 0x01 /* if set, parse device_setup */ | 3563 | #define AUDIOPHILE_SET 0x01 /* if set, parse device_setup */ |
@@ -3405,9 +3636,8 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip, | |||
3405 | [QUIRK_MIDI_CME] = create_any_midi_quirk, | 3636 | [QUIRK_MIDI_CME] = create_any_midi_quirk, |
3406 | [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, | 3637 | [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, |
3407 | [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, | 3638 | [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, |
3408 | [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk, | 3639 | [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk, |
3409 | [QUIRK_AUDIO_EDIROL_UA101] = create_ua101_quirk, | 3640 | [QUIRK_AUDIO_ALIGN_TRANSFER] = create_align_transfer_quirk |
3410 | [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk | ||
3411 | }; | 3641 | }; |
3412 | 3642 | ||
3413 | if (quirk->type < QUIRK_TYPE_COUNT) { | 3643 | if (quirk->type < QUIRK_TYPE_COUNT) { |
@@ -3596,7 +3826,6 @@ static void *snd_usb_audio_probe(struct usb_device *dev, | |||
3596 | ifnum = get_iface_desc(alts)->bInterfaceNumber; | 3826 | ifnum = get_iface_desc(alts)->bInterfaceNumber; |
3597 | id = USB_ID(le16_to_cpu(dev->descriptor.idVendor), | 3827 | id = USB_ID(le16_to_cpu(dev->descriptor.idVendor), |
3598 | le16_to_cpu(dev->descriptor.idProduct)); | 3828 | le16_to_cpu(dev->descriptor.idProduct)); |
3599 | |||
3600 | if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum) | 3829 | if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum) |
3601 | goto __err_val; | 3830 | goto __err_val; |
3602 | 3831 | ||
@@ -3624,6 +3853,12 @@ static void *snd_usb_audio_probe(struct usb_device *dev, | |||
3624 | goto __err_val; | 3853 | goto __err_val; |
3625 | } | 3854 | } |
3626 | 3855 | ||
3856 | /* Access Music VirusTI Desktop */ | ||
3857 | if (id == USB_ID(0x133e, 0x0815)) { | ||
3858 | if (snd_usb_accessmusic_boot_quirk(dev) < 0) | ||
3859 | goto __err_val; | ||
3860 | } | ||
3861 | |||
3627 | /* | 3862 | /* |
3628 | * found a config. now register to ALSA | 3863 | * found a config. now register to ALSA |
3629 | */ | 3864 | */ |
@@ -3661,6 +3896,7 @@ static void *snd_usb_audio_probe(struct usb_device *dev, | |||
3661 | } | 3896 | } |
3662 | } | 3897 | } |
3663 | 3898 | ||
3899 | chip->txfr_quirk = 0; | ||
3664 | err = 1; /* continue */ | 3900 | err = 1; /* continue */ |
3665 | if (quirk && quirk->ifnum != QUIRK_NO_INTERFACE) { | 3901 | if (quirk && quirk->ifnum != QUIRK_NO_INTERFACE) { |
3666 | /* need some special handlings */ | 3902 | /* need some special handlings */ |
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 40ba8115fb81..42c299cbf63a 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h | |||
@@ -21,93 +21,6 @@ | |||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | |||
25 | /* | ||
26 | */ | ||
27 | |||
28 | #define USB_SUBCLASS_AUDIO_CONTROL 0x01 | ||
29 | #define USB_SUBCLASS_AUDIO_STREAMING 0x02 | ||
30 | #define USB_SUBCLASS_MIDI_STREAMING 0x03 | ||
31 | #define USB_SUBCLASS_VENDOR_SPEC 0xff | ||
32 | |||
33 | #define HEADER 0x01 | ||
34 | #define INPUT_TERMINAL 0x02 | ||
35 | #define OUTPUT_TERMINAL 0x03 | ||
36 | #define MIXER_UNIT 0x04 | ||
37 | #define SELECTOR_UNIT 0x05 | ||
38 | #define FEATURE_UNIT 0x06 | ||
39 | #define PROCESSING_UNIT 0x07 | ||
40 | #define EXTENSION_UNIT 0x08 | ||
41 | |||
42 | #define AS_GENERAL 0x01 | ||
43 | #define FORMAT_TYPE 0x02 | ||
44 | #define FORMAT_SPECIFIC 0x03 | ||
45 | |||
46 | #define EP_GENERAL 0x01 | ||
47 | |||
48 | #define MS_GENERAL 0x01 | ||
49 | #define MIDI_IN_JACK 0x02 | ||
50 | #define MIDI_OUT_JACK 0x03 | ||
51 | |||
52 | /* endpoint attributes */ | ||
53 | #define EP_ATTR_MASK 0x0c | ||
54 | #define EP_ATTR_ASYNC 0x04 | ||
55 | #define EP_ATTR_ADAPTIVE 0x08 | ||
56 | #define EP_ATTR_SYNC 0x0c | ||
57 | |||
58 | /* cs endpoint attributes */ | ||
59 | #define EP_CS_ATTR_SAMPLE_RATE 0x01 | ||
60 | #define EP_CS_ATTR_PITCH_CONTROL 0x02 | ||
61 | #define EP_CS_ATTR_FILL_MAX 0x80 | ||
62 | |||
63 | /* Audio Class specific Request Codes */ | ||
64 | |||
65 | #define SET_CUR 0x01 | ||
66 | #define GET_CUR 0x81 | ||
67 | #define SET_MIN 0x02 | ||
68 | #define GET_MIN 0x82 | ||
69 | #define SET_MAX 0x03 | ||
70 | #define GET_MAX 0x83 | ||
71 | #define SET_RES 0x04 | ||
72 | #define GET_RES 0x84 | ||
73 | #define SET_MEM 0x05 | ||
74 | #define GET_MEM 0x85 | ||
75 | #define GET_STAT 0xff | ||
76 | |||
77 | /* Terminal Control Selectors */ | ||
78 | |||
79 | #define COPY_PROTECT_CONTROL 0x01 | ||
80 | |||
81 | /* Endpoint Control Selectors */ | ||
82 | |||
83 | #define SAMPLING_FREQ_CONTROL 0x01 | ||
84 | #define PITCH_CONTROL 0x02 | ||
85 | |||
86 | /* Format Types */ | ||
87 | #define USB_FORMAT_TYPE_I 0x01 | ||
88 | #define USB_FORMAT_TYPE_II 0x02 | ||
89 | #define USB_FORMAT_TYPE_III 0x03 | ||
90 | |||
91 | /* type I */ | ||
92 | #define USB_AUDIO_FORMAT_PCM 0x01 | ||
93 | #define USB_AUDIO_FORMAT_PCM8 0x02 | ||
94 | #define USB_AUDIO_FORMAT_IEEE_FLOAT 0x03 | ||
95 | #define USB_AUDIO_FORMAT_ALAW 0x04 | ||
96 | #define USB_AUDIO_FORMAT_MU_LAW 0x05 | ||
97 | |||
98 | /* type II */ | ||
99 | #define USB_AUDIO_FORMAT_MPEG 0x1001 | ||
100 | #define USB_AUDIO_FORMAT_AC3 0x1002 | ||
101 | |||
102 | /* type III */ | ||
103 | #define USB_AUDIO_FORMAT_IEC1937_AC3 0x2001 | ||
104 | #define USB_AUDIO_FORMAT_IEC1937_MPEG1_LAYER1 0x2002 | ||
105 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_NOEXT 0x2003 | ||
106 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_EXT 0x2004 | ||
107 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER1_LS 0x2005 | ||
108 | #define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER23_LS 0x2006 | ||
109 | |||
110 | |||
111 | /* maximum number of endpoints per interface */ | 24 | /* maximum number of endpoints per interface */ |
112 | #define MIDI_MAX_ENDPOINTS 2 | 25 | #define MIDI_MAX_ENDPOINTS 2 |
113 | 26 | ||
@@ -125,9 +38,13 @@ struct snd_usb_audio { | |||
125 | struct snd_card *card; | 38 | struct snd_card *card; |
126 | u32 usb_id; | 39 | u32 usb_id; |
127 | int shutdown; | 40 | int shutdown; |
41 | unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */ | ||
128 | int num_interfaces; | 42 | int num_interfaces; |
129 | int num_suspended_intf; | 43 | int num_suspended_intf; |
130 | 44 | ||
45 | /* for audio class v2 */ | ||
46 | int clock_id; | ||
47 | |||
131 | struct list_head pcm_list; /* list of pcm streams */ | 48 | struct list_head pcm_list; /* list of pcm streams */ |
132 | int pcm_devs; | 49 | int pcm_devs; |
133 | 50 | ||
@@ -158,9 +75,8 @@ enum quirk_type { | |||
158 | QUIRK_MIDI_US122L, | 75 | QUIRK_MIDI_US122L, |
159 | QUIRK_AUDIO_STANDARD_INTERFACE, | 76 | QUIRK_AUDIO_STANDARD_INTERFACE, |
160 | QUIRK_AUDIO_FIXED_ENDPOINT, | 77 | QUIRK_AUDIO_FIXED_ENDPOINT, |
161 | QUIRK_AUDIO_EDIROL_UA1000, | ||
162 | QUIRK_AUDIO_EDIROL_UA101, | ||
163 | QUIRK_AUDIO_EDIROL_UAXX, | 78 | QUIRK_AUDIO_EDIROL_UAXX, |
79 | QUIRK_AUDIO_ALIGN_TRANSFER, | ||
164 | 80 | ||
165 | QUIRK_TYPE_COUNT | 81 | QUIRK_TYPE_COUNT |
166 | }; | 82 | }; |
@@ -195,7 +111,7 @@ struct snd_usb_midi_endpoint_info { | |||
195 | 111 | ||
196 | /* for QUIRK_AUDIO/MIDI_STANDARD_INTERFACE, data is NULL */ | 112 | /* for QUIRK_AUDIO/MIDI_STANDARD_INTERFACE, data is NULL */ |
197 | 113 | ||
198 | /* for QUIRK_AUDIO_EDIROL_UA700_UA25/UA1000, data is NULL */ | 114 | /* for QUIRK_AUDIO_EDIROL_UAXX, data is NULL */ |
199 | 115 | ||
200 | /* for QUIRK_IGNORE_INTERFACE, data is NULL */ | 116 | /* for QUIRK_IGNORE_INTERFACE, data is NULL */ |
201 | 117 | ||
@@ -209,6 +125,16 @@ struct snd_usb_midi_endpoint_info { | |||
209 | /* | 125 | /* |
210 | */ | 126 | */ |
211 | 127 | ||
128 | /*E-mu USB samplerate control quirk*/ | ||
129 | enum { | ||
130 | EMU_QUIRK_SR_44100HZ = 0, | ||
131 | EMU_QUIRK_SR_48000HZ, | ||
132 | EMU_QUIRK_SR_88200HZ, | ||
133 | EMU_QUIRK_SR_96000HZ, | ||
134 | EMU_QUIRK_SR_176400HZ, | ||
135 | EMU_QUIRK_SR_192000HZ | ||
136 | }; | ||
137 | |||
212 | #define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8)) | 138 | #define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8)) |
213 | #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) | 139 | #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) |
214 | #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) | 140 | #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) |
@@ -234,6 +160,9 @@ void snd_usbmidi_input_stop(struct list_head* p); | |||
234 | void snd_usbmidi_input_start(struct list_head* p); | 160 | void snd_usbmidi_input_start(struct list_head* p); |
235 | void snd_usbmidi_disconnect(struct list_head *p); | 161 | void snd_usbmidi_disconnect(struct list_head *p); |
236 | 162 | ||
163 | void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, | ||
164 | unsigned char samplerate_id); | ||
165 | |||
237 | /* | 166 | /* |
238 | * retrieve usb_interface descriptor from the host interface | 167 | * retrieve usb_interface descriptor from the host interface |
239 | * (conditional for compatibility with the older API) | 168 | * (conditional for compatibility with the older API) |
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index 6e89b8368d9a..2c59afd99611 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c | |||
@@ -46,6 +46,8 @@ | |||
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 <linux/wait.h> |
49 | #include <linux/usb/audio.h> | ||
50 | |||
49 | #include <sound/core.h> | 51 | #include <sound/core.h> |
50 | #include <sound/control.h> | 52 | #include <sound/control.h> |
51 | #include <sound/rawmidi.h> | 53 | #include <sound/rawmidi.h> |
@@ -1162,10 +1164,22 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi, | |||
1162 | pipe = usb_sndintpipe(umidi->dev, ep_info->out_ep); | 1164 | pipe = usb_sndintpipe(umidi->dev, ep_info->out_ep); |
1163 | else | 1165 | else |
1164 | pipe = usb_sndbulkpipe(umidi->dev, ep_info->out_ep); | 1166 | pipe = usb_sndbulkpipe(umidi->dev, ep_info->out_ep); |
1165 | if (umidi->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */ | 1167 | switch (umidi->usb_id) { |
1166 | ep->max_transfer = 4; | 1168 | default: |
1167 | else | ||
1168 | ep->max_transfer = usb_maxpacket(umidi->dev, pipe, 1); | 1169 | ep->max_transfer = usb_maxpacket(umidi->dev, pipe, 1); |
1170 | break; | ||
1171 | /* | ||
1172 | * Various chips declare a packet size larger than 4 bytes, but | ||
1173 | * do not actually work with larger packets: | ||
1174 | */ | ||
1175 | case USB_ID(0x0a92, 0x1020): /* ESI M4U */ | ||
1176 | case USB_ID(0x1430, 0x474b): /* RedOctane GH MIDI INTERFACE */ | ||
1177 | case USB_ID(0x15ca, 0x0101): /* Textech USB Midi Cable */ | ||
1178 | case USB_ID(0x15ca, 0x1806): /* Textech USB Midi Cable */ | ||
1179 | case USB_ID(0x1a86, 0x752d): /* QinHeng CH345 "USB2.0-MIDI" */ | ||
1180 | ep->max_transfer = 4; | ||
1181 | break; | ||
1182 | } | ||
1169 | for (i = 0; i < OUTPUT_URBS; ++i) { | 1183 | for (i = 0; i < OUTPUT_URBS; ++i) { |
1170 | buffer = usb_buffer_alloc(umidi->dev, | 1184 | buffer = usb_buffer_alloc(umidi->dev, |
1171 | ep->max_transfer, GFP_KERNEL, | 1185 | ep->max_transfer, GFP_KERNEL, |
@@ -1407,6 +1421,12 @@ static struct port_info { | |||
1407 | EXTERNAL_PORT(0x086a, 0x0001, 8, "%s Broadcast"), | 1421 | EXTERNAL_PORT(0x086a, 0x0001, 8, "%s Broadcast"), |
1408 | EXTERNAL_PORT(0x086a, 0x0002, 8, "%s Broadcast"), | 1422 | EXTERNAL_PORT(0x086a, 0x0002, 8, "%s Broadcast"), |
1409 | EXTERNAL_PORT(0x086a, 0x0003, 4, "%s Broadcast"), | 1423 | EXTERNAL_PORT(0x086a, 0x0003, 4, "%s Broadcast"), |
1424 | /* Access Music Virus TI */ | ||
1425 | EXTERNAL_PORT(0x133e, 0x0815, 0, "%s MIDI"), | ||
1426 | PORT_INFO(0x133e, 0x0815, 1, "%s Synth", 0, | ||
1427 | SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC | | ||
1428 | SNDRV_SEQ_PORT_TYPE_HARDWARE | | ||
1429 | SNDRV_SEQ_PORT_TYPE_SYNTHESIZER), | ||
1410 | }; | 1430 | }; |
1411 | 1431 | ||
1412 | static struct port_info *find_port_info(struct snd_usb_midi* umidi, int number) | 1432 | static struct port_info *find_port_info(struct snd_usb_midi* umidi, int number) |
@@ -1522,7 +1542,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, | |||
1522 | if (hostif->extralen >= 7 && | 1542 | if (hostif->extralen >= 7 && |
1523 | ms_header->bLength >= 7 && | 1543 | ms_header->bLength >= 7 && |
1524 | ms_header->bDescriptorType == USB_DT_CS_INTERFACE && | 1544 | ms_header->bDescriptorType == USB_DT_CS_INTERFACE && |
1525 | ms_header->bDescriptorSubtype == HEADER) | 1545 | ms_header->bDescriptorSubtype == UAC_HEADER) |
1526 | snd_printdd(KERN_INFO "MIDIStreaming version %02x.%02x\n", | 1546 | snd_printdd(KERN_INFO "MIDIStreaming version %02x.%02x\n", |
1527 | ms_header->bcdMSC[1], ms_header->bcdMSC[0]); | 1547 | ms_header->bcdMSC[1], ms_header->bcdMSC[0]); |
1528 | else | 1548 | else |
@@ -1538,7 +1558,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, | |||
1538 | if (hostep->extralen < 4 || | 1558 | if (hostep->extralen < 4 || |
1539 | ms_ep->bLength < 4 || | 1559 | ms_ep->bLength < 4 || |
1540 | ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT || | 1560 | ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT || |
1541 | ms_ep->bDescriptorSubtype != MS_GENERAL) | 1561 | ms_ep->bDescriptorSubtype != UAC_MS_GENERAL) |
1542 | continue; | 1562 | continue; |
1543 | if (usb_endpoint_dir_out(ep)) { | 1563 | if (usb_endpoint_dir_out(ep)) { |
1544 | if (endpoints[epidx].out_ep) { | 1564 | if (endpoints[epidx].out_ep) { |
@@ -1750,9 +1770,9 @@ static int snd_usbmidi_detect_yamaha(struct snd_usb_midi* umidi, | |||
1750 | cs_desc < hostif->extra + hostif->extralen && cs_desc[0] >= 2; | 1770 | cs_desc < hostif->extra + hostif->extralen && cs_desc[0] >= 2; |
1751 | cs_desc += cs_desc[0]) { | 1771 | cs_desc += cs_desc[0]) { |
1752 | if (cs_desc[1] == USB_DT_CS_INTERFACE) { | 1772 | if (cs_desc[1] == USB_DT_CS_INTERFACE) { |
1753 | if (cs_desc[2] == MIDI_IN_JACK) | 1773 | if (cs_desc[2] == UAC_MIDI_IN_JACK) |
1754 | endpoint->in_cables = (endpoint->in_cables << 1) | 1; | 1774 | endpoint->in_cables = (endpoint->in_cables << 1) | 1; |
1755 | else if (cs_desc[2] == MIDI_OUT_JACK) | 1775 | else if (cs_desc[2] == UAC_MIDI_OUT_JACK) |
1756 | endpoint->out_cables = (endpoint->out_cables << 1) | 1; | 1776 | endpoint->out_cables = (endpoint->out_cables << 1) | 1; |
1757 | } | 1777 | } |
1758 | } | 1778 | } |
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index c998220b99c6..8e8f871b74ca 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/string.h> | 33 | #include <linux/string.h> |
34 | #include <linux/usb.h> | 34 | #include <linux/usb.h> |
35 | #include <linux/usb/audio.h> | ||
36 | |||
35 | #include <sound/core.h> | 37 | #include <sound/core.h> |
36 | #include <sound/control.h> | 38 | #include <sound/control.h> |
37 | #include <sound/hwdep.h> | 39 | #include <sound/hwdep.h> |
@@ -69,13 +71,16 @@ static const struct rc_config { | |||
69 | { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */ | 71 | { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */ |
70 | }; | 72 | }; |
71 | 73 | ||
74 | #define MAX_ID_ELEMS 256 | ||
75 | |||
72 | struct usb_mixer_interface { | 76 | struct usb_mixer_interface { |
73 | struct snd_usb_audio *chip; | 77 | struct snd_usb_audio *chip; |
74 | unsigned int ctrlif; | 78 | unsigned int ctrlif; |
75 | struct list_head list; | 79 | struct list_head list; |
76 | unsigned int ignore_ctl_error; | 80 | unsigned int ignore_ctl_error; |
77 | struct urb *urb; | 81 | struct urb *urb; |
78 | struct usb_mixer_elem_info **id_elems; /* array[256], indexed by unit id */ | 82 | /* array[MAX_ID_ELEMS], indexed by unit id */ |
83 | struct usb_mixer_elem_info **id_elems; | ||
79 | 84 | ||
80 | /* Sound Blaster remote control stuff */ | 85 | /* Sound Blaster remote control stuff */ |
81 | const struct rc_config *rc_cfg; | 86 | const struct rc_config *rc_cfg; |
@@ -105,7 +110,7 @@ struct mixer_build { | |||
105 | struct usb_mixer_interface *mixer; | 110 | struct usb_mixer_interface *mixer; |
106 | unsigned char *buffer; | 111 | unsigned char *buffer; |
107 | unsigned int buflen; | 112 | unsigned int buflen; |
108 | DECLARE_BITMAP(unitbitmap, 256); | 113 | DECLARE_BITMAP(unitbitmap, MAX_ID_ELEMS); |
109 | struct usb_audio_term oterm; | 114 | struct usb_audio_term oterm; |
110 | const struct usbmix_name_map *map; | 115 | const struct usbmix_name_map *map; |
111 | const struct usbmix_selector_map *selector_map; | 116 | const struct usbmix_selector_map *selector_map; |
@@ -123,6 +128,7 @@ struct usb_mixer_elem_info { | |||
123 | int channels; | 128 | int channels; |
124 | int val_type; | 129 | int val_type; |
125 | int min, max, res; | 130 | int min, max, res; |
131 | int dBmin, dBmax; | ||
126 | int cached; | 132 | int cached; |
127 | int cache_val[MAX_CHANNELS]; | 133 | int cache_val[MAX_CHANNELS]; |
128 | u8 initialized; | 134 | u8 initialized; |
@@ -186,6 +192,21 @@ enum { | |||
186 | USB_PROC_DCR_RELEASE = 6, | 192 | USB_PROC_DCR_RELEASE = 6, |
187 | }; | 193 | }; |
188 | 194 | ||
195 | /*E-mu 0202(0404) eXtension Unit(XU) control*/ | ||
196 | enum { | ||
197 | USB_XU_CLOCK_RATE = 0xe301, | ||
198 | USB_XU_CLOCK_SOURCE = 0xe302, | ||
199 | USB_XU_DIGITAL_IO_STATUS = 0xe303, | ||
200 | USB_XU_DEVICE_OPTIONS = 0xe304, | ||
201 | USB_XU_DIRECT_MONITORING = 0xe305, | ||
202 | USB_XU_METERING = 0xe306 | ||
203 | }; | ||
204 | enum { | ||
205 | USB_XU_CLOCK_SOURCE_SELECTOR = 0x02, /* clock source*/ | ||
206 | USB_XU_CLOCK_RATE_SELECTOR = 0x03, /* clock rate */ | ||
207 | USB_XU_DIGITAL_FORMAT_SELECTOR = 0x01, /* the spdif format */ | ||
208 | USB_XU_SOFT_LIMIT_SELECTOR = 0x03 /* soft limiter */ | ||
209 | }; | ||
189 | 210 | ||
190 | /* | 211 | /* |
191 | * manual mapping of mixer names | 212 | * manual mapping of mixer names |
@@ -194,42 +215,50 @@ enum { | |||
194 | */ | 215 | */ |
195 | #include "usbmixer_maps.c" | 216 | #include "usbmixer_maps.c" |
196 | 217 | ||
197 | /* get the mapped name if the unit matches */ | 218 | static const struct usbmix_name_map * |
198 | static int check_mapped_name(struct mixer_build *state, int unitid, int control, char *buf, int buflen) | 219 | find_map(struct mixer_build *state, int unitid, int control) |
199 | { | 220 | { |
200 | const struct usbmix_name_map *p; | 221 | const struct usbmix_name_map *p = state->map; |
201 | 222 | ||
202 | if (! state->map) | 223 | if (!p) |
203 | return 0; | 224 | return NULL; |
204 | 225 | ||
205 | for (p = state->map; p->id; p++) { | 226 | for (p = state->map; p->id; p++) { |
206 | if (p->id == unitid && p->name && | 227 | if (p->id == unitid && |
207 | (! control || ! p->control || control == p->control)) { | 228 | (!control || !p->control || control == p->control)) |
208 | buflen--; | 229 | return p; |
209 | return strlcpy(buf, p->name, buflen); | ||
210 | } | ||
211 | } | 230 | } |
212 | return 0; | 231 | return NULL; |
213 | } | 232 | } |
214 | 233 | ||
215 | /* check whether the control should be ignored */ | 234 | /* get the mapped name if the unit matches */ |
216 | static int check_ignored_ctl(struct mixer_build *state, int unitid, int control) | 235 | static int |
236 | check_mapped_name(const struct usbmix_name_map *p, char *buf, int buflen) | ||
217 | { | 237 | { |
218 | const struct usbmix_name_map *p; | 238 | if (!p || !p->name) |
239 | return 0; | ||
240 | |||
241 | buflen--; | ||
242 | return strlcpy(buf, p->name, buflen); | ||
243 | } | ||
219 | 244 | ||
220 | if (! state->map) | 245 | /* check whether the control should be ignored */ |
246 | static inline int | ||
247 | check_ignored_ctl(const struct usbmix_name_map *p) | ||
248 | { | ||
249 | if (!p || p->name || p->dB) | ||
221 | return 0; | 250 | return 0; |
222 | for (p = state->map; p->id; p++) { | 251 | return 1; |
223 | if (p->id == unitid && ! p->name && | 252 | } |
224 | (! control || ! p->control || control == p->control)) { | 253 | |
225 | /* | 254 | /* dB mapping */ |
226 | printk(KERN_DEBUG "ignored control %d:%d\n", | 255 | static inline void check_mapped_dB(const struct usbmix_name_map *p, |
227 | unitid, control); | 256 | struct usb_mixer_elem_info *cval) |
228 | */ | 257 | { |
229 | return 1; | 258 | if (p && p->dB) { |
230 | } | 259 | cval->dBmin = p->dB->min; |
260 | cval->dBmax = p->dB->max; | ||
231 | } | 261 | } |
232 | return 0; | ||
233 | } | 262 | } |
234 | 263 | ||
235 | /* get the mapped selector source name */ | 264 | /* get the mapped selector source name */ |
@@ -257,7 +286,7 @@ static void *find_audio_control_unit(struct mixer_build *state, unsigned char un | |||
257 | p = NULL; | 286 | p = NULL; |
258 | while ((p = snd_usb_find_desc(state->buffer, state->buflen, p, | 287 | while ((p = snd_usb_find_desc(state->buffer, state->buflen, p, |
259 | USB_DT_CS_INTERFACE)) != NULL) { | 288 | USB_DT_CS_INTERFACE)) != NULL) { |
260 | if (p[0] >= 4 && p[2] >= INPUT_TERMINAL && p[2] <= EXTENSION_UNIT && p[3] == unit) | 289 | if (p[0] >= 4 && p[2] >= UAC_INPUT_TERMINAL && p[2] <= UAC_EXTENSION_UNIT_V1 && p[3] == unit) |
261 | return p; | 290 | return p; |
262 | } | 291 | } |
263 | return NULL; | 292 | return NULL; |
@@ -378,14 +407,14 @@ static int get_ctl_value(struct usb_mixer_elem_info *cval, int request, int vali | |||
378 | 407 | ||
379 | static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int *value) | 408 | static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int *value) |
380 | { | 409 | { |
381 | return get_ctl_value(cval, GET_CUR, validx, value); | 410 | return get_ctl_value(cval, UAC_GET_CUR, validx, value); |
382 | } | 411 | } |
383 | 412 | ||
384 | /* channel = 0: master, 1 = first channel */ | 413 | /* channel = 0: master, 1 = first channel */ |
385 | static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval, | 414 | static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval, |
386 | int channel, int *value) | 415 | int channel, int *value) |
387 | { | 416 | { |
388 | return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value); | 417 | return get_ctl_value(cval, UAC_GET_CUR, (cval->control << 8) | channel, value); |
389 | } | 418 | } |
390 | 419 | ||
391 | static int get_cur_mix_value(struct usb_mixer_elem_info *cval, | 420 | static int get_cur_mix_value(struct usb_mixer_elem_info *cval, |
@@ -439,14 +468,14 @@ static int set_ctl_value(struct usb_mixer_elem_info *cval, int request, int vali | |||
439 | 468 | ||
440 | static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int value) | 469 | static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int value) |
441 | { | 470 | { |
442 | return set_ctl_value(cval, SET_CUR, validx, value); | 471 | return set_ctl_value(cval, UAC_SET_CUR, validx, value); |
443 | } | 472 | } |
444 | 473 | ||
445 | static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, | 474 | static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, |
446 | int index, int value) | 475 | int index, int value) |
447 | { | 476 | { |
448 | int err; | 477 | int err; |
449 | err = set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel, | 478 | err = set_ctl_value(cval, UAC_SET_CUR, (cval->control << 8) | channel, |
450 | value); | 479 | value); |
451 | if (err < 0) | 480 | if (err < 0) |
452 | return err; | 481 | return err; |
@@ -466,20 +495,8 @@ static int mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |||
466 | 495 | ||
467 | if (size < sizeof(scale)) | 496 | if (size < sizeof(scale)) |
468 | return -ENOMEM; | 497 | return -ENOMEM; |
469 | /* USB descriptions contain the dB scale in 1/256 dB unit | 498 | scale[2] = cval->dBmin; |
470 | * while ALSA TLV contains in 1/100 dB unit | 499 | scale[3] = cval->dBmax; |
471 | */ | ||
472 | scale[2] = (convert_signed_value(cval, cval->min) * 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 | } | ||
483 | if (copy_to_user(_tlv, scale, sizeof(scale))) | 500 | if (copy_to_user(_tlv, scale, sizeof(scale))) |
484 | return -EFAULT; | 501 | return -EFAULT; |
485 | return 0; | 502 | return 0; |
@@ -588,13 +605,13 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm | |||
588 | if (term_only) | 605 | if (term_only) |
589 | return 0; | 606 | return 0; |
590 | switch (iterm->type >> 16) { | 607 | switch (iterm->type >> 16) { |
591 | case SELECTOR_UNIT: | 608 | case UAC_SELECTOR_UNIT: |
592 | strcpy(name, "Selector"); return 8; | 609 | strcpy(name, "Selector"); return 8; |
593 | case PROCESSING_UNIT: | 610 | case UAC_PROCESSING_UNIT_V1: |
594 | strcpy(name, "Process Unit"); return 12; | 611 | strcpy(name, "Process Unit"); return 12; |
595 | case EXTENSION_UNIT: | 612 | case UAC_EXTENSION_UNIT_V1: |
596 | strcpy(name, "Ext Unit"); return 8; | 613 | strcpy(name, "Ext Unit"); return 8; |
597 | case MIXER_UNIT: | 614 | case UAC_MIXER_UNIT: |
598 | strcpy(name, "Mixer"); return 5; | 615 | strcpy(name, "Mixer"); return 5; |
599 | default: | 616 | default: |
600 | return sprintf(name, "Unit %d", iterm->id); | 617 | return sprintf(name, "Unit %d", iterm->id); |
@@ -633,22 +650,22 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_ | |||
633 | while ((p1 = find_audio_control_unit(state, id)) != NULL) { | 650 | while ((p1 = find_audio_control_unit(state, id)) != NULL) { |
634 | term->id = id; | 651 | term->id = id; |
635 | switch (p1[2]) { | 652 | switch (p1[2]) { |
636 | case INPUT_TERMINAL: | 653 | case UAC_INPUT_TERMINAL: |
637 | term->type = combine_word(p1 + 4); | 654 | term->type = combine_word(p1 + 4); |
638 | term->channels = p1[7]; | 655 | term->channels = p1[7]; |
639 | term->chconfig = combine_word(p1 + 8); | 656 | term->chconfig = combine_word(p1 + 8); |
640 | term->name = p1[11]; | 657 | term->name = p1[11]; |
641 | return 0; | 658 | return 0; |
642 | case FEATURE_UNIT: | 659 | case UAC_FEATURE_UNIT: |
643 | id = p1[4]; | 660 | id = p1[4]; |
644 | break; /* continue to parse */ | 661 | break; /* continue to parse */ |
645 | case MIXER_UNIT: | 662 | case UAC_MIXER_UNIT: |
646 | term->type = p1[2] << 16; /* virtual type */ | 663 | term->type = p1[2] << 16; /* virtual type */ |
647 | term->channels = p1[5 + p1[4]]; | 664 | term->channels = p1[5 + p1[4]]; |
648 | term->chconfig = combine_word(p1 + 6 + p1[4]); | 665 | term->chconfig = combine_word(p1 + 6 + p1[4]); |
649 | term->name = p1[p1[0] - 1]; | 666 | term->name = p1[p1[0] - 1]; |
650 | return 0; | 667 | return 0; |
651 | case SELECTOR_UNIT: | 668 | case UAC_SELECTOR_UNIT: |
652 | /* call recursively to retrieve the channel info */ | 669 | /* call recursively to retrieve the channel info */ |
653 | if (check_input_term(state, p1[5], term) < 0) | 670 | if (check_input_term(state, p1[5], term) < 0) |
654 | return -ENODEV; | 671 | return -ENODEV; |
@@ -656,8 +673,8 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_ | |||
656 | term->id = id; | 673 | term->id = id; |
657 | term->name = p1[9 + p1[0] - 1]; | 674 | term->name = p1[9 + p1[0] - 1]; |
658 | return 0; | 675 | return 0; |
659 | case PROCESSING_UNIT: | 676 | case UAC_PROCESSING_UNIT_V1: |
660 | case EXTENSION_UNIT: | 677 | case UAC_EXTENSION_UNIT_V1: |
661 | if (p1[6] == 1) { | 678 | if (p1[6] == 1) { |
662 | id = p1[7]; | 679 | id = p1[7]; |
663 | break; /* continue to parse */ | 680 | break; /* continue to parse */ |
@@ -720,6 +737,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | |||
720 | cval->min = default_min; | 737 | cval->min = default_min; |
721 | cval->max = cval->min + 1; | 738 | cval->max = cval->min + 1; |
722 | cval->res = 1; | 739 | cval->res = 1; |
740 | cval->dBmin = cval->dBmax = 0; | ||
723 | 741 | ||
724 | if (cval->val_type == USB_MIXER_BOOLEAN || | 742 | if (cval->val_type == USB_MIXER_BOOLEAN || |
725 | cval->val_type == USB_MIXER_INV_BOOLEAN) { | 743 | cval->val_type == USB_MIXER_INV_BOOLEAN) { |
@@ -734,23 +752,23 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | |||
734 | break; | 752 | break; |
735 | } | 753 | } |
736 | } | 754 | } |
737 | if (get_ctl_value(cval, GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || | 755 | if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || |
738 | get_ctl_value(cval, GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { | 756 | get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { |
739 | snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", | 757 | snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", |
740 | cval->id, cval->mixer->ctrlif, cval->control, cval->id); | 758 | cval->id, cval->mixer->ctrlif, cval->control, cval->id); |
741 | return -EINVAL; | 759 | return -EINVAL; |
742 | } | 760 | } |
743 | if (get_ctl_value(cval, GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { | 761 | if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { |
744 | cval->res = 1; | 762 | cval->res = 1; |
745 | } else { | 763 | } else { |
746 | int last_valid_res = cval->res; | 764 | int last_valid_res = cval->res; |
747 | 765 | ||
748 | while (cval->res > 1) { | 766 | while (cval->res > 1) { |
749 | if (set_ctl_value(cval, SET_RES, (cval->control << 8) | minchn, cval->res / 2) < 0) | 767 | if (set_ctl_value(cval, UAC_SET_RES, (cval->control << 8) | minchn, cval->res / 2) < 0) |
750 | break; | 768 | break; |
751 | cval->res /= 2; | 769 | cval->res /= 2; |
752 | } | 770 | } |
753 | if (get_ctl_value(cval, GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) | 771 | if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) |
754 | cval->res = last_valid_res; | 772 | cval->res = last_valid_res; |
755 | } | 773 | } |
756 | if (cval->res == 0) | 774 | if (cval->res == 0) |
@@ -787,6 +805,24 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) | |||
787 | 805 | ||
788 | cval->initialized = 1; | 806 | cval->initialized = 1; |
789 | } | 807 | } |
808 | |||
809 | /* USB descriptions contain the dB scale in 1/256 dB unit | ||
810 | * while ALSA TLV contains in 1/100 dB unit | ||
811 | */ | ||
812 | cval->dBmin = (convert_signed_value(cval, cval->min) * 100) / 256; | ||
813 | cval->dBmax = (convert_signed_value(cval, cval->max) * 100) / 256; | ||
814 | if (cval->dBmin > cval->dBmax) { | ||
815 | /* something is wrong; assume it's either from/to 0dB */ | ||
816 | if (cval->dBmin < 0) | ||
817 | cval->dBmax = 0; | ||
818 | else if (cval->dBmin > 0) | ||
819 | cval->dBmin = 0; | ||
820 | if (cval->dBmin > cval->dBmax) { | ||
821 | /* totally crap, return an error */ | ||
822 | return -EINVAL; | ||
823 | } | ||
824 | } | ||
825 | |||
790 | return 0; | 826 | return 0; |
791 | } | 827 | } |
792 | 828 | ||
@@ -912,6 +948,7 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc, | |||
912 | int nameid = desc[desc[0] - 1]; | 948 | int nameid = desc[desc[0] - 1]; |
913 | struct snd_kcontrol *kctl; | 949 | struct snd_kcontrol *kctl; |
914 | struct usb_mixer_elem_info *cval; | 950 | struct usb_mixer_elem_info *cval; |
951 | const struct usbmix_name_map *map; | ||
915 | 952 | ||
916 | control++; /* change from zero-based to 1-based value */ | 953 | control++; /* change from zero-based to 1-based value */ |
917 | 954 | ||
@@ -920,7 +957,8 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc, | |||
920 | return; | 957 | return; |
921 | } | 958 | } |
922 | 959 | ||
923 | if (check_ignored_ctl(state, unitid, control)) | 960 | map = find_map(state, unitid, control); |
961 | if (check_ignored_ctl(map)) | ||
924 | return; | 962 | return; |
925 | 963 | ||
926 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); | 964 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); |
@@ -954,10 +992,11 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc, | |||
954 | } | 992 | } |
955 | kctl->private_free = usb_mixer_elem_free; | 993 | kctl->private_free = usb_mixer_elem_free; |
956 | 994 | ||
957 | len = check_mapped_name(state, unitid, control, kctl->id.name, sizeof(kctl->id.name)); | 995 | len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); |
958 | mapped_name = len != 0; | 996 | mapped_name = len != 0; |
959 | if (! len && nameid) | 997 | if (! len && nameid) |
960 | len = snd_usb_copy_string_desc(state, nameid, kctl->id.name, sizeof(kctl->id.name)); | 998 | len = snd_usb_copy_string_desc(state, nameid, |
999 | kctl->id.name, sizeof(kctl->id.name)); | ||
961 | 1000 | ||
962 | switch (control) { | 1001 | switch (control) { |
963 | case USB_FEATURE_MUTE: | 1002 | case USB_FEATURE_MUTE: |
@@ -995,6 +1034,7 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc, | |||
995 | kctl->vd[0].access |= | 1034 | kctl->vd[0].access |= |
996 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | | 1035 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
997 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; | 1036 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; |
1037 | check_mapped_dB(map, cval); | ||
998 | } | 1038 | } |
999 | break; | 1039 | break; |
1000 | 1040 | ||
@@ -1048,29 +1088,30 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc, | |||
1048 | * | 1088 | * |
1049 | * most of controlls are defined here. | 1089 | * most of controlls are defined here. |
1050 | */ | 1090 | */ |
1051 | static int parse_audio_feature_unit(struct mixer_build *state, int unitid, unsigned char *ftr) | 1091 | static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void *_ftr) |
1052 | { | 1092 | { |
1053 | int channels, i, j; | 1093 | int channels, i, j; |
1054 | struct usb_audio_term iterm; | 1094 | struct usb_audio_term iterm; |
1055 | unsigned int master_bits, first_ch_bits; | 1095 | unsigned int master_bits, first_ch_bits; |
1056 | int err, csize; | 1096 | int err, csize; |
1097 | struct uac_feature_unit_descriptor *ftr = _ftr; | ||
1057 | 1098 | ||
1058 | if (ftr[0] < 7 || ! (csize = ftr[5]) || ftr[0] < 7 + csize) { | 1099 | if (ftr->bLength < 7 || ! (csize = ftr->bControlSize) || ftr->bLength < 7 + csize) { |
1059 | snd_printk(KERN_ERR "usbaudio: unit %u: invalid FEATURE_UNIT descriptor\n", unitid); | 1100 | snd_printk(KERN_ERR "usbaudio: unit %u: invalid UAC_FEATURE_UNIT descriptor\n", unitid); |
1060 | return -EINVAL; | 1101 | return -EINVAL; |
1061 | } | 1102 | } |
1062 | 1103 | ||
1063 | /* parse the source unit */ | 1104 | /* parse the source unit */ |
1064 | if ((err = parse_audio_unit(state, ftr[4])) < 0) | 1105 | if ((err = parse_audio_unit(state, ftr->bSourceID)) < 0) |
1065 | return err; | 1106 | return err; |
1066 | 1107 | ||
1067 | /* determine the input source type and name */ | 1108 | /* determine the input source type and name */ |
1068 | if (check_input_term(state, ftr[4], &iterm) < 0) | 1109 | if (check_input_term(state, ftr->bSourceID, &iterm) < 0) |
1069 | return -EINVAL; | 1110 | return -EINVAL; |
1070 | 1111 | ||
1071 | channels = (ftr[0] - 7) / csize - 1; | 1112 | channels = (ftr->bLength - 7) / csize - 1; |
1072 | 1113 | ||
1073 | master_bits = snd_usb_combine_bytes(ftr + 6, csize); | 1114 | master_bits = snd_usb_combine_bytes(ftr->controls, csize); |
1074 | /* master configuration quirks */ | 1115 | /* master configuration quirks */ |
1075 | switch (state->chip->usb_id) { | 1116 | switch (state->chip->usb_id) { |
1076 | case USB_ID(0x08bb, 0x2702): | 1117 | case USB_ID(0x08bb, 0x2702): |
@@ -1081,21 +1122,21 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, unsig | |||
1081 | break; | 1122 | break; |
1082 | } | 1123 | } |
1083 | if (channels > 0) | 1124 | if (channels > 0) |
1084 | first_ch_bits = snd_usb_combine_bytes(ftr + 6 + csize, csize); | 1125 | first_ch_bits = snd_usb_combine_bytes(ftr->controls + csize, csize); |
1085 | else | 1126 | else |
1086 | first_ch_bits = 0; | 1127 | first_ch_bits = 0; |
1087 | /* check all control types */ | 1128 | /* check all control types */ |
1088 | for (i = 0; i < 10; i++) { | 1129 | for (i = 0; i < 10; i++) { |
1089 | unsigned int ch_bits = 0; | 1130 | unsigned int ch_bits = 0; |
1090 | for (j = 0; j < channels; j++) { | 1131 | for (j = 0; j < channels; j++) { |
1091 | unsigned int mask = snd_usb_combine_bytes(ftr + 6 + csize * (j+1), csize); | 1132 | unsigned int mask = snd_usb_combine_bytes(ftr->controls + csize * (j+1), csize); |
1092 | if (mask & (1 << i)) | 1133 | if (mask & (1 << i)) |
1093 | ch_bits |= (1 << j); | 1134 | ch_bits |= (1 << j); |
1094 | } | 1135 | } |
1095 | if (ch_bits & 1) /* the first channel must be set (for ease of programming) */ | 1136 | if (ch_bits & 1) /* the first channel must be set (for ease of programming) */ |
1096 | build_feature_ctl(state, ftr, ch_bits, i, &iterm, unitid); | 1137 | build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid); |
1097 | if (master_bits & (1 << i)) | 1138 | if (master_bits & (1 << i)) |
1098 | build_feature_ctl(state, ftr, 0, i, &iterm, unitid); | 1139 | build_feature_ctl(state, _ftr, 0, i, &iterm, unitid); |
1099 | } | 1140 | } |
1100 | 1141 | ||
1101 | return 0; | 1142 | return 0; |
@@ -1122,8 +1163,10 @@ static void build_mixer_unit_ctl(struct mixer_build *state, unsigned char *desc, | |||
1122 | unsigned int num_outs = desc[5 + input_pins]; | 1163 | unsigned int num_outs = desc[5 + input_pins]; |
1123 | unsigned int i, len; | 1164 | unsigned int i, len; |
1124 | struct snd_kcontrol *kctl; | 1165 | struct snd_kcontrol *kctl; |
1166 | const struct usbmix_name_map *map; | ||
1125 | 1167 | ||
1126 | if (check_ignored_ctl(state, unitid, 0)) | 1168 | map = find_map(state, unitid, 0); |
1169 | if (check_ignored_ctl(map)) | ||
1127 | return; | 1170 | return; |
1128 | 1171 | ||
1129 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); | 1172 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); |
@@ -1152,7 +1195,7 @@ static void build_mixer_unit_ctl(struct mixer_build *state, unsigned char *desc, | |||
1152 | } | 1195 | } |
1153 | kctl->private_free = usb_mixer_elem_free; | 1196 | kctl->private_free = usb_mixer_elem_free; |
1154 | 1197 | ||
1155 | len = check_mapped_name(state, unitid, 0, kctl->id.name, sizeof(kctl->id.name)); | 1198 | len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); |
1156 | if (! len) | 1199 | if (! len) |
1157 | len = get_term_name(state, iterm, kctl->id.name, sizeof(kctl->id.name), 0); | 1200 | len = get_term_name(state, iterm, kctl->id.name, sizeof(kctl->id.name), 0); |
1158 | if (! len) | 1201 | if (! len) |
@@ -1330,7 +1373,32 @@ static struct procunit_info procunits[] = { | |||
1330 | { USB_PROC_DCR, "DCR", dcr_proc_info }, | 1373 | { USB_PROC_DCR, "DCR", dcr_proc_info }, |
1331 | { 0 }, | 1374 | { 0 }, |
1332 | }; | 1375 | }; |
1333 | 1376 | /* | |
1377 | * predefined data for extension units | ||
1378 | */ | ||
1379 | static struct procunit_value_info clock_rate_xu_info[] = { | ||
1380 | { USB_XU_CLOCK_RATE_SELECTOR, "Selector", USB_MIXER_U8, 0 }, | ||
1381 | { 0 } | ||
1382 | }; | ||
1383 | static struct procunit_value_info clock_source_xu_info[] = { | ||
1384 | { USB_XU_CLOCK_SOURCE_SELECTOR, "External", USB_MIXER_BOOLEAN }, | ||
1385 | { 0 } | ||
1386 | }; | ||
1387 | static struct procunit_value_info spdif_format_xu_info[] = { | ||
1388 | { USB_XU_DIGITAL_FORMAT_SELECTOR, "SPDIF/AC3", USB_MIXER_BOOLEAN }, | ||
1389 | { 0 } | ||
1390 | }; | ||
1391 | static struct procunit_value_info soft_limit_xu_info[] = { | ||
1392 | { USB_XU_SOFT_LIMIT_SELECTOR, " ", USB_MIXER_BOOLEAN }, | ||
1393 | { 0 } | ||
1394 | }; | ||
1395 | static struct procunit_info extunits[] = { | ||
1396 | { USB_XU_CLOCK_RATE, "Clock rate", clock_rate_xu_info }, | ||
1397 | { USB_XU_CLOCK_SOURCE, "DigitalIn CLK source", clock_source_xu_info }, | ||
1398 | { USB_XU_DIGITAL_IO_STATUS, "DigitalOut format:", spdif_format_xu_info }, | ||
1399 | { USB_XU_DEVICE_OPTIONS, "AnalogueIn Soft Limit", soft_limit_xu_info }, | ||
1400 | { 0 } | ||
1401 | }; | ||
1334 | /* | 1402 | /* |
1335 | * build a processing/extension unit | 1403 | * build a processing/extension unit |
1336 | */ | 1404 | */ |
@@ -1342,6 +1410,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, unsigned | |||
1342 | int i, err, nameid, type, len; | 1410 | int i, err, nameid, type, len; |
1343 | struct procunit_info *info; | 1411 | struct procunit_info *info; |
1344 | struct procunit_value_info *valinfo; | 1412 | struct procunit_value_info *valinfo; |
1413 | const struct usbmix_name_map *map; | ||
1345 | static struct procunit_value_info default_value_info[] = { | 1414 | static struct procunit_value_info default_value_info[] = { |
1346 | { 0x01, "Switch", USB_MIXER_BOOLEAN }, | 1415 | { 0x01, "Switch", USB_MIXER_BOOLEAN }, |
1347 | { 0 } | 1416 | { 0 } |
@@ -1371,7 +1440,8 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, unsigned | |||
1371 | /* FIXME: bitmap might be longer than 8bit */ | 1440 | /* FIXME: bitmap might be longer than 8bit */ |
1372 | if (! (dsc[12 + num_ins] & (1 << (valinfo->control - 1)))) | 1441 | if (! (dsc[12 + num_ins] & (1 << (valinfo->control - 1)))) |
1373 | continue; | 1442 | continue; |
1374 | if (check_ignored_ctl(state, unitid, valinfo->control)) | 1443 | map = find_map(state, unitid, valinfo->control); |
1444 | if (check_ignored_ctl(map)) | ||
1375 | continue; | 1445 | continue; |
1376 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); | 1446 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); |
1377 | if (! cval) { | 1447 | if (! cval) { |
@@ -1391,8 +1461,18 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, unsigned | |||
1391 | cval->max = dsc[15]; | 1461 | cval->max = dsc[15]; |
1392 | cval->res = 1; | 1462 | cval->res = 1; |
1393 | cval->initialized = 1; | 1463 | cval->initialized = 1; |
1394 | } else | 1464 | } else { |
1395 | get_min_max(cval, valinfo->min_value); | 1465 | if (type == USB_XU_CLOCK_RATE) { |
1466 | /* E-Mu USB 0404/0202/TrackerPre | ||
1467 | * samplerate control quirk | ||
1468 | */ | ||
1469 | cval->min = 0; | ||
1470 | cval->max = 5; | ||
1471 | cval->res = 1; | ||
1472 | cval->initialized = 1; | ||
1473 | } else | ||
1474 | get_min_max(cval, valinfo->min_value); | ||
1475 | } | ||
1396 | 1476 | ||
1397 | kctl = snd_ctl_new1(&mixer_procunit_ctl, cval); | 1477 | kctl = snd_ctl_new1(&mixer_procunit_ctl, cval); |
1398 | if (! kctl) { | 1478 | if (! kctl) { |
@@ -1402,8 +1482,9 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, unsigned | |||
1402 | } | 1482 | } |
1403 | kctl->private_free = usb_mixer_elem_free; | 1483 | kctl->private_free = usb_mixer_elem_free; |
1404 | 1484 | ||
1405 | if (check_mapped_name(state, unitid, cval->control, kctl->id.name, sizeof(kctl->id.name))) | 1485 | if (check_mapped_name(map, kctl->id.name, |
1406 | ; | 1486 | sizeof(kctl->id.name))) |
1487 | /* nothing */ ; | ||
1407 | else if (info->name) | 1488 | else if (info->name) |
1408 | strlcpy(kctl->id.name, info->name, sizeof(kctl->id.name)); | 1489 | strlcpy(kctl->id.name, info->name, sizeof(kctl->id.name)); |
1409 | else { | 1490 | else { |
@@ -1433,7 +1514,7 @@ static int parse_audio_processing_unit(struct mixer_build *state, int unitid, un | |||
1433 | 1514 | ||
1434 | static int parse_audio_extension_unit(struct mixer_build *state, int unitid, unsigned char *desc) | 1515 | static int parse_audio_extension_unit(struct mixer_build *state, int unitid, unsigned char *desc) |
1435 | { | 1516 | { |
1436 | return build_audio_procunit(state, unitid, desc, NULL, "Extension Unit"); | 1517 | return build_audio_procunit(state, unitid, desc, extunits, "Extension Unit"); |
1437 | } | 1518 | } |
1438 | 1519 | ||
1439 | 1520 | ||
@@ -1542,6 +1623,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, unsi | |||
1542 | int err; | 1623 | int err; |
1543 | struct usb_mixer_elem_info *cval; | 1624 | struct usb_mixer_elem_info *cval; |
1544 | struct snd_kcontrol *kctl; | 1625 | struct snd_kcontrol *kctl; |
1626 | const struct usbmix_name_map *map; | ||
1545 | char **namelist; | 1627 | char **namelist; |
1546 | 1628 | ||
1547 | if (! num_ins || desc[0] < 5 + num_ins) { | 1629 | if (! num_ins || desc[0] < 5 + num_ins) { |
@@ -1557,7 +1639,8 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, unsi | |||
1557 | if (num_ins == 1) /* only one ? nonsense! */ | 1639 | if (num_ins == 1) /* only one ? nonsense! */ |
1558 | return 0; | 1640 | return 0; |
1559 | 1641 | ||
1560 | if (check_ignored_ctl(state, unitid, 0)) | 1642 | map = find_map(state, unitid, 0); |
1643 | if (check_ignored_ctl(map)) | ||
1561 | return 0; | 1644 | return 0; |
1562 | 1645 | ||
1563 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); | 1646 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); |
@@ -1612,7 +1695,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, unsi | |||
1612 | kctl->private_free = usb_mixer_selector_elem_free; | 1695 | kctl->private_free = usb_mixer_selector_elem_free; |
1613 | 1696 | ||
1614 | nameid = desc[desc[0] - 1]; | 1697 | nameid = desc[desc[0] - 1]; |
1615 | len = check_mapped_name(state, unitid, 0, kctl->id.name, sizeof(kctl->id.name)); | 1698 | len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); |
1616 | if (len) | 1699 | if (len) |
1617 | ; | 1700 | ; |
1618 | else if (nameid) | 1701 | else if (nameid) |
@@ -1656,17 +1739,17 @@ static int parse_audio_unit(struct mixer_build *state, int unitid) | |||
1656 | } | 1739 | } |
1657 | 1740 | ||
1658 | switch (p1[2]) { | 1741 | switch (p1[2]) { |
1659 | case INPUT_TERMINAL: | 1742 | case UAC_INPUT_TERMINAL: |
1660 | return 0; /* NOP */ | 1743 | return 0; /* NOP */ |
1661 | case MIXER_UNIT: | 1744 | case UAC_MIXER_UNIT: |
1662 | return parse_audio_mixer_unit(state, unitid, p1); | 1745 | return parse_audio_mixer_unit(state, unitid, p1); |
1663 | case SELECTOR_UNIT: | 1746 | case UAC_SELECTOR_UNIT: |
1664 | return parse_audio_selector_unit(state, unitid, p1); | 1747 | return parse_audio_selector_unit(state, unitid, p1); |
1665 | case FEATURE_UNIT: | 1748 | case UAC_FEATURE_UNIT: |
1666 | return parse_audio_feature_unit(state, unitid, p1); | 1749 | return parse_audio_feature_unit(state, unitid, p1); |
1667 | case PROCESSING_UNIT: | 1750 | case UAC_PROCESSING_UNIT_V1: |
1668 | return parse_audio_processing_unit(state, unitid, p1); | 1751 | return parse_audio_processing_unit(state, unitid, p1); |
1669 | case EXTENSION_UNIT: | 1752 | case UAC_EXTENSION_UNIT_V1: |
1670 | return parse_audio_extension_unit(state, unitid, p1); | 1753 | return parse_audio_extension_unit(state, unitid, p1); |
1671 | default: | 1754 | default: |
1672 | snd_printk(KERN_ERR "usbaudio: unit %u: unexpected type 0x%02x\n", unitid, p1[2]); | 1755 | snd_printk(KERN_ERR "usbaudio: unit %u: unexpected type 0x%02x\n", unitid, p1[2]); |
@@ -1696,11 +1779,11 @@ static int snd_usb_mixer_dev_free(struct snd_device *device) | |||
1696 | /* | 1779 | /* |
1697 | * create mixer controls | 1780 | * create mixer controls |
1698 | * | 1781 | * |
1699 | * walk through all OUTPUT_TERMINAL descriptors to search for mixers | 1782 | * walk through all UAC_OUTPUT_TERMINAL descriptors to search for mixers |
1700 | */ | 1783 | */ |
1701 | static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) | 1784 | static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) |
1702 | { | 1785 | { |
1703 | unsigned char *desc; | 1786 | struct uac_output_terminal_descriptor_v1 *desc; |
1704 | struct mixer_build state; | 1787 | struct mixer_build state; |
1705 | int err; | 1788 | int err; |
1706 | const struct usbmix_ctl_map *map; | 1789 | const struct usbmix_ctl_map *map; |
@@ -1724,14 +1807,14 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) | |||
1724 | } | 1807 | } |
1725 | 1808 | ||
1726 | desc = NULL; | 1809 | desc = NULL; |
1727 | while ((desc = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, desc, OUTPUT_TERMINAL)) != NULL) { | 1810 | while ((desc = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, desc, UAC_OUTPUT_TERMINAL)) != NULL) { |
1728 | if (desc[0] < 9) | 1811 | if (desc->bLength < 9) |
1729 | continue; /* invalid descriptor? */ | 1812 | continue; /* invalid descriptor? */ |
1730 | set_bit(desc[3], state.unitbitmap); /* mark terminal ID as visited */ | 1813 | set_bit(desc->bTerminalID, state.unitbitmap); /* mark terminal ID as visited */ |
1731 | state.oterm.id = desc[3]; | 1814 | state.oterm.id = desc->bTerminalID; |
1732 | state.oterm.type = combine_word(&desc[4]); | 1815 | state.oterm.type = le16_to_cpu(desc->wTerminalType); |
1733 | state.oterm.name = desc[8]; | 1816 | state.oterm.name = desc->iTerminal; |
1734 | err = parse_audio_unit(&state, desc[7]); | 1817 | err = parse_audio_unit(&state, desc->bSourceID); |
1735 | if (err < 0) | 1818 | if (err < 0) |
1736 | return err; | 1819 | return err; |
1737 | } | 1820 | } |
@@ -1748,6 +1831,46 @@ static void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, | |||
1748 | info->elem_id); | 1831 | info->elem_id); |
1749 | } | 1832 | } |
1750 | 1833 | ||
1834 | static void snd_usb_mixer_dump_cval(struct snd_info_buffer *buffer, | ||
1835 | int unitid, | ||
1836 | struct usb_mixer_elem_info *cval) | ||
1837 | { | ||
1838 | static char *val_types[] = {"BOOLEAN", "INV_BOOLEAN", | ||
1839 | "S8", "U8", "S16", "U16"}; | ||
1840 | snd_iprintf(buffer, " Unit: %i\n", unitid); | ||
1841 | if (cval->elem_id) | ||
1842 | snd_iprintf(buffer, " Control: name=\"%s\", index=%i\n", | ||
1843 | cval->elem_id->name, cval->elem_id->index); | ||
1844 | snd_iprintf(buffer, " Info: id=%i, control=%i, cmask=0x%x, " | ||
1845 | "channels=%i, type=\"%s\"\n", cval->id, | ||
1846 | cval->control, cval->cmask, cval->channels, | ||
1847 | val_types[cval->val_type]); | ||
1848 | snd_iprintf(buffer, " Volume: min=%i, max=%i, dBmin=%i, dBmax=%i\n", | ||
1849 | cval->min, cval->max, cval->dBmin, cval->dBmax); | ||
1850 | } | ||
1851 | |||
1852 | static void snd_usb_mixer_proc_read(struct snd_info_entry *entry, | ||
1853 | struct snd_info_buffer *buffer) | ||
1854 | { | ||
1855 | struct snd_usb_audio *chip = entry->private_data; | ||
1856 | struct usb_mixer_interface *mixer; | ||
1857 | struct usb_mixer_elem_info *cval; | ||
1858 | int unitid; | ||
1859 | |||
1860 | list_for_each_entry(mixer, &chip->mixer_list, list) { | ||
1861 | snd_iprintf(buffer, | ||
1862 | "USB Mixer: usb_id=0x%08x, ctrlif=%i, ctlerr=%i\n", | ||
1863 | chip->usb_id, mixer->ctrlif, | ||
1864 | mixer->ignore_ctl_error); | ||
1865 | snd_iprintf(buffer, "Card: %s\n", chip->card->longname); | ||
1866 | for (unitid = 0; unitid < MAX_ID_ELEMS; unitid++) { | ||
1867 | for (cval = mixer->id_elems[unitid]; cval; | ||
1868 | cval = cval->next_id_elem) | ||
1869 | snd_usb_mixer_dump_cval(buffer, unitid, cval); | ||
1870 | } | ||
1871 | } | ||
1872 | } | ||
1873 | |||
1751 | static void snd_usb_mixer_memory_change(struct usb_mixer_interface *mixer, | 1874 | static void snd_usb_mixer_memory_change(struct usb_mixer_interface *mixer, |
1752 | int unitid) | 1875 | int unitid) |
1753 | { | 1876 | { |
@@ -1924,7 +2047,7 @@ static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer) | |||
1924 | } | 2047 | } |
1925 | mixer->rc_setup_packet->bRequestType = | 2048 | mixer->rc_setup_packet->bRequestType = |
1926 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE; | 2049 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE; |
1927 | mixer->rc_setup_packet->bRequest = GET_MEM; | 2050 | mixer->rc_setup_packet->bRequest = UAC_GET_MEM; |
1928 | mixer->rc_setup_packet->wValue = cpu_to_le16(0); | 2051 | mixer->rc_setup_packet->wValue = cpu_to_le16(0); |
1929 | mixer->rc_setup_packet->wIndex = cpu_to_le16(0); | 2052 | mixer->rc_setup_packet->wIndex = cpu_to_le16(0); |
1930 | mixer->rc_setup_packet->wLength = cpu_to_le16(len); | 2053 | mixer->rc_setup_packet->wLength = cpu_to_le16(len); |
@@ -2047,7 +2170,7 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry, | |||
2047 | snd_iprintf(buffer, "%s: ", jacks[i].name); | 2170 | snd_iprintf(buffer, "%s: ", jacks[i].name); |
2048 | err = snd_usb_ctl_msg(mixer->chip->dev, | 2171 | err = snd_usb_ctl_msg(mixer->chip->dev, |
2049 | usb_rcvctrlpipe(mixer->chip->dev, 0), | 2172 | usb_rcvctrlpipe(mixer->chip->dev, 0), |
2050 | GET_MEM, USB_DIR_IN | USB_TYPE_CLASS | | 2173 | UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS | |
2051 | USB_RECIP_INTERFACE, 0, | 2174 | USB_RECIP_INTERFACE, 0, |
2052 | jacks[i].unitid << 8, buf, 3, 100); | 2175 | jacks[i].unitid << 8, buf, 3, 100); |
2053 | if (err == 3 && (buf[0] == 3 || buf[0] == 6)) | 2176 | if (err == 3 && (buf[0] == 3 || buf[0] == 6)) |
@@ -2109,6 +2232,24 @@ static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer) | |||
2109 | return 0; | 2232 | return 0; |
2110 | } | 2233 | } |
2111 | 2234 | ||
2235 | void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, | ||
2236 | unsigned char samplerate_id) | ||
2237 | { | ||
2238 | struct usb_mixer_interface *mixer; | ||
2239 | struct usb_mixer_elem_info *cval; | ||
2240 | int unitid = 12; /* SamleRate ExtensionUnit ID */ | ||
2241 | |||
2242 | list_for_each_entry(mixer, &chip->mixer_list, list) { | ||
2243 | cval = mixer->id_elems[unitid]; | ||
2244 | if (cval) { | ||
2245 | set_cur_ctl_value(cval, cval->control << 8, | ||
2246 | samplerate_id); | ||
2247 | snd_usb_mixer_notify_id(mixer, unitid); | ||
2248 | } | ||
2249 | break; | ||
2250 | } | ||
2251 | } | ||
2252 | |||
2112 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | 2253 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, |
2113 | int ignore_error) | 2254 | int ignore_error) |
2114 | { | 2255 | { |
@@ -2116,7 +2257,9 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | |||
2116 | .dev_free = snd_usb_mixer_dev_free | 2257 | .dev_free = snd_usb_mixer_dev_free |
2117 | }; | 2258 | }; |
2118 | struct usb_mixer_interface *mixer; | 2259 | struct usb_mixer_interface *mixer; |
2119 | int err; | 2260 | struct snd_info_entry *entry; |
2261 | struct usb_host_interface *host_iface; | ||
2262 | int err, protocol; | ||
2120 | 2263 | ||
2121 | strcpy(chip->card->mixername, "USB Mixer"); | 2264 | strcpy(chip->card->mixername, "USB Mixer"); |
2122 | 2265 | ||
@@ -2126,12 +2269,23 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | |||
2126 | mixer->chip = chip; | 2269 | mixer->chip = chip; |
2127 | mixer->ctrlif = ctrlif; | 2270 | mixer->ctrlif = ctrlif; |
2128 | mixer->ignore_ctl_error = ignore_error; | 2271 | mixer->ignore_ctl_error = ignore_error; |
2129 | mixer->id_elems = kcalloc(256, sizeof(*mixer->id_elems), GFP_KERNEL); | 2272 | mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems), |
2273 | GFP_KERNEL); | ||
2130 | if (!mixer->id_elems) { | 2274 | if (!mixer->id_elems) { |
2131 | kfree(mixer); | 2275 | kfree(mixer); |
2132 | return -ENOMEM; | 2276 | return -ENOMEM; |
2133 | } | 2277 | } |
2134 | 2278 | ||
2279 | host_iface = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0]; | ||
2280 | protocol = host_iface->desc.bInterfaceProtocol; | ||
2281 | |||
2282 | /* FIXME! */ | ||
2283 | if (protocol != UAC_VERSION_1) { | ||
2284 | snd_printk(KERN_WARNING "mixer interface protocol 0x%02x not yet supported\n", | ||
2285 | protocol); | ||
2286 | return 0; | ||
2287 | } | ||
2288 | |||
2135 | if ((err = snd_usb_mixer_controls(mixer)) < 0 || | 2289 | if ((err = snd_usb_mixer_controls(mixer)) < 0 || |
2136 | (err = snd_usb_mixer_status_create(mixer)) < 0) | 2290 | (err = snd_usb_mixer_status_create(mixer)) < 0) |
2137 | goto _error; | 2291 | goto _error; |
@@ -2142,8 +2296,6 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | |||
2142 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) || | 2296 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) || |
2143 | mixer->chip->usb_id == USB_ID(0x041e, 0x3040) || | 2297 | mixer->chip->usb_id == USB_ID(0x041e, 0x3040) || |
2144 | mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) { | 2298 | mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) { |
2145 | struct snd_info_entry *entry; | ||
2146 | |||
2147 | if ((err = snd_audigy2nx_controls_create(mixer)) < 0) | 2299 | if ((err = snd_audigy2nx_controls_create(mixer)) < 0) |
2148 | goto _error; | 2300 | goto _error; |
2149 | if (!snd_card_proc_new(chip->card, "audigy2nx", &entry)) | 2301 | if (!snd_card_proc_new(chip->card, "audigy2nx", &entry)) |
@@ -2161,6 +2313,11 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | |||
2161 | err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops); | 2313 | err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops); |
2162 | if (err < 0) | 2314 | if (err < 0) |
2163 | goto _error; | 2315 | goto _error; |
2316 | |||
2317 | if (list_empty(&chip->mixer_list) && | ||
2318 | !snd_card_proc_new(chip->card, "usbmixer", &entry)) | ||
2319 | snd_info_set_text_ops(entry, chip, snd_usb_mixer_proc_read); | ||
2320 | |||
2164 | list_add(&mixer->list, &chip->mixer_list); | 2321 | list_add(&mixer->list, &chip->mixer_list); |
2165 | return 0; | 2322 | return 0; |
2166 | 2323 | ||
diff --git a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c index 77c35885e21c..79e903a60862 100644 --- a/sound/usb/usbmixer_maps.c +++ b/sound/usb/usbmixer_maps.c | |||
@@ -19,11 +19,16 @@ | |||
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | struct usbmix_dB_map { | ||
23 | u32 min; | ||
24 | u32 max; | ||
25 | }; | ||
22 | 26 | ||
23 | struct usbmix_name_map { | 27 | struct usbmix_name_map { |
24 | int id; | 28 | int id; |
25 | const char *name; | 29 | const char *name; |
26 | int control; | 30 | int control; |
31 | struct usbmix_dB_map *dB; | ||
27 | }; | 32 | }; |
28 | 33 | ||
29 | struct usbmix_selector_map { | 34 | struct usbmix_selector_map { |
@@ -72,7 +77,7 @@ static struct usbmix_name_map extigy_map[] = { | |||
72 | { 8, "Line Playback" }, /* FU */ | 77 | { 8, "Line Playback" }, /* FU */ |
73 | /* 9: IT mic */ | 78 | /* 9: IT mic */ |
74 | { 10, "Mic Playback" }, /* FU */ | 79 | { 10, "Mic Playback" }, /* FU */ |
75 | { 11, "Capture Input Source" }, /* SU */ | 80 | { 11, "Capture Source" }, /* SU */ |
76 | { 12, "Capture" }, /* FU */ | 81 | { 12, "Capture" }, /* FU */ |
77 | /* 13: OT pcm capture */ | 82 | /* 13: OT pcm capture */ |
78 | /* 14: MU (w/o controls) */ | 83 | /* 14: MU (w/o controls) */ |
@@ -102,6 +107,9 @@ static struct usbmix_name_map extigy_map[] = { | |||
102 | * e.g. no Master and fake PCM volume | 107 | * e.g. no Master and fake PCM volume |
103 | * Pavel Mihaylov <bin@bash.info> | 108 | * Pavel Mihaylov <bin@bash.info> |
104 | */ | 109 | */ |
110 | static struct usbmix_dB_map mp3plus_dB_1 = {-4781, 0}; /* just guess */ | ||
111 | static struct usbmix_dB_map mp3plus_dB_2 = {-1781, 618}; /* just guess */ | ||
112 | |||
105 | static struct usbmix_name_map mp3plus_map[] = { | 113 | static struct usbmix_name_map mp3plus_map[] = { |
106 | /* 1: IT pcm */ | 114 | /* 1: IT pcm */ |
107 | /* 2: IT mic */ | 115 | /* 2: IT mic */ |
@@ -110,16 +118,19 @@ static struct usbmix_name_map mp3plus_map[] = { | |||
110 | /* 5: OT digital out */ | 118 | /* 5: OT digital out */ |
111 | /* 6: OT speaker */ | 119 | /* 6: OT speaker */ |
112 | /* 7: OT pcm capture */ | 120 | /* 7: OT pcm capture */ |
113 | { 8, "Capture Input Source" }, /* FU, default PCM Capture Source */ | 121 | { 8, "Capture Source" }, /* FU, default PCM Capture Source */ |
114 | /* (Mic, Input 1 = Line input, Input 2 = Optical input) */ | 122 | /* (Mic, Input 1 = Line input, Input 2 = Optical input) */ |
115 | { 9, "Master Playback" }, /* FU, default Speaker 1 */ | 123 | { 9, "Master Playback" }, /* FU, default Speaker 1 */ |
116 | /* { 10, "Mic Capture", 1 }, */ /* FU, Mic Capture */ | 124 | /* { 10, "Mic Capture", 1 }, */ /* FU, Mic Capture */ |
117 | /* { 10, "Mic Capture", 2 }, */ /* FU, Mic Capture */ | 125 | { 10, /* "Mic Capture", */ NULL, 2, .dB = &mp3plus_dB_2 }, |
126 | /* FU, Mic Capture */ | ||
118 | { 10, "Mic Boost", 7 }, /* FU, default Auto Gain Input */ | 127 | { 10, "Mic Boost", 7 }, /* FU, default Auto Gain Input */ |
119 | { 11, "Line Capture" }, /* FU, default PCM Capture */ | 128 | { 11, "Line Capture", .dB = &mp3plus_dB_2 }, |
129 | /* FU, default PCM Capture */ | ||
120 | { 12, "Digital In Playback" }, /* FU, default PCM 1 */ | 130 | { 12, "Digital In Playback" }, /* FU, default PCM 1 */ |
121 | /* { 13, "Mic Playback" }, */ /* FU, default Mic Playback */ | 131 | { 13, /* "Mic Playback", */ .dB = &mp3plus_dB_1 }, |
122 | { 14, "Line Playback" }, /* FU, default Speaker */ | 132 | /* FU, default Mic Playback */ |
133 | { 14, "Line Playback", .dB = &mp3plus_dB_1 }, /* FU, default Speaker */ | ||
123 | /* 15: MU */ | 134 | /* 15: MU */ |
124 | { 0 } /* terminator */ | 135 | { 0 } /* terminator */ |
125 | }; | 136 | }; |
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h index a892bda03df9..2b426c1fd0e8 100644 --- a/sound/usb/usbquirks.h +++ b/sound/usb/usbquirks.h | |||
@@ -91,7 +91,7 @@ | |||
91 | .idVendor = 0x046d, | 91 | .idVendor = 0x046d, |
92 | .idProduct = 0x0850, | 92 | .idProduct = 0x0850, |
93 | .bInterfaceClass = USB_CLASS_AUDIO, | 93 | .bInterfaceClass = USB_CLASS_AUDIO, |
94 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL | 94 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL |
95 | }, | 95 | }, |
96 | { | 96 | { |
97 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | 97 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | |
@@ -100,7 +100,7 @@ | |||
100 | .idVendor = 0x046d, | 100 | .idVendor = 0x046d, |
101 | .idProduct = 0x08ae, | 101 | .idProduct = 0x08ae, |
102 | .bInterfaceClass = USB_CLASS_AUDIO, | 102 | .bInterfaceClass = USB_CLASS_AUDIO, |
103 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL | 103 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL |
104 | }, | 104 | }, |
105 | { | 105 | { |
106 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | 106 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | |
@@ -109,7 +109,7 @@ | |||
109 | .idVendor = 0x046d, | 109 | .idVendor = 0x046d, |
110 | .idProduct = 0x08c6, | 110 | .idProduct = 0x08c6, |
111 | .bInterfaceClass = USB_CLASS_AUDIO, | 111 | .bInterfaceClass = USB_CLASS_AUDIO, |
112 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL | 112 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL |
113 | }, | 113 | }, |
114 | { | 114 | { |
115 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | 115 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | |
@@ -118,7 +118,7 @@ | |||
118 | .idVendor = 0x046d, | 118 | .idVendor = 0x046d, |
119 | .idProduct = 0x08f0, | 119 | .idProduct = 0x08f0, |
120 | .bInterfaceClass = USB_CLASS_AUDIO, | 120 | .bInterfaceClass = USB_CLASS_AUDIO, |
121 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL | 121 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL |
122 | }, | 122 | }, |
123 | { | 123 | { |
124 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | 124 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | |
@@ -127,7 +127,7 @@ | |||
127 | .idVendor = 0x046d, | 127 | .idVendor = 0x046d, |
128 | .idProduct = 0x08f5, | 128 | .idProduct = 0x08f5, |
129 | .bInterfaceClass = USB_CLASS_AUDIO, | 129 | .bInterfaceClass = USB_CLASS_AUDIO, |
130 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL | 130 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL |
131 | }, | 131 | }, |
132 | { | 132 | { |
133 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | 133 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | |
@@ -136,7 +136,7 @@ | |||
136 | .idVendor = 0x046d, | 136 | .idVendor = 0x046d, |
137 | .idProduct = 0x08f6, | 137 | .idProduct = 0x08f6, |
138 | .bInterfaceClass = USB_CLASS_AUDIO, | 138 | .bInterfaceClass = USB_CLASS_AUDIO, |
139 | .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL | 139 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL |
140 | }, | 140 | }, |
141 | { | 141 | { |
142 | USB_DEVICE(0x046d, 0x0990), | 142 | USB_DEVICE(0x046d, 0x0990), |
@@ -301,7 +301,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
301 | .iface = 1, | 301 | .iface = 1, |
302 | .altsetting = 1, | 302 | .altsetting = 1, |
303 | .altset_idx = 1, | 303 | .altset_idx = 1, |
304 | .attributes = EP_CS_ATTR_FILL_MAX, | 304 | .attributes = UAC_EP_CS_ATTR_FILL_MAX, |
305 | .endpoint = 0x81, | 305 | .endpoint = 0x81, |
306 | .ep_attr = 0x05, | 306 | .ep_attr = 0x05, |
307 | .rates = SNDRV_PCM_RATE_CONTINUOUS, | 307 | .rates = SNDRV_PCM_RATE_CONTINUOUS, |
@@ -1016,36 +1016,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
1016 | } | 1016 | } |
1017 | }, | 1017 | }, |
1018 | { | 1018 | { |
1019 | USB_DEVICE(0x0582, 0x0044), | ||
1020 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
1021 | .vendor_name = "Roland", | ||
1022 | .product_name = "UA-1000", | ||
1023 | .ifnum = QUIRK_ANY_INTERFACE, | ||
1024 | .type = QUIRK_COMPOSITE, | ||
1025 | .data = (const struct snd_usb_audio_quirk[]) { | ||
1026 | { | ||
1027 | .ifnum = 1, | ||
1028 | .type = QUIRK_AUDIO_EDIROL_UA1000 | ||
1029 | }, | ||
1030 | { | ||
1031 | .ifnum = 2, | ||
1032 | .type = QUIRK_AUDIO_EDIROL_UA1000 | ||
1033 | }, | ||
1034 | { | ||
1035 | .ifnum = 3, | ||
1036 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
1037 | .data = & (const struct snd_usb_midi_endpoint_info) { | ||
1038 | .out_cables = 0x0003, | ||
1039 | .in_cables = 0x0003 | ||
1040 | } | ||
1041 | }, | ||
1042 | { | ||
1043 | .ifnum = -1 | ||
1044 | } | ||
1045 | } | ||
1046 | } | ||
1047 | }, | ||
1048 | { | ||
1049 | /* has ID 0x0049 when not in "Advanced Driver" mode */ | 1019 | /* has ID 0x0049 when not in "Advanced Driver" mode */ |
1050 | USB_DEVICE(0x0582, 0x0047), | 1020 | USB_DEVICE(0x0582, 0x0047), |
1051 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | 1021 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { |
@@ -1266,37 +1236,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
1266 | } | 1236 | } |
1267 | } | 1237 | } |
1268 | }, | 1238 | }, |
1269 | /* Roland UA-101 in High-Speed Mode only */ | ||
1270 | { | ||
1271 | USB_DEVICE(0x0582, 0x007d), | ||
1272 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
1273 | .vendor_name = "Roland", | ||
1274 | .product_name = "UA-101", | ||
1275 | .ifnum = QUIRK_ANY_INTERFACE, | ||
1276 | .type = QUIRK_COMPOSITE, | ||
1277 | .data = (const struct snd_usb_audio_quirk[]) { | ||
1278 | { | ||
1279 | .ifnum = 0, | ||
1280 | .type = QUIRK_AUDIO_EDIROL_UA101 | ||
1281 | }, | ||
1282 | { | ||
1283 | .ifnum = 1, | ||
1284 | .type = QUIRK_AUDIO_EDIROL_UA101 | ||
1285 | }, | ||
1286 | { | ||
1287 | .ifnum = 2, | ||
1288 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
1289 | .data = & (const struct snd_usb_midi_endpoint_info) { | ||
1290 | .out_cables = 0x0001, | ||
1291 | .in_cables = 0x0001 | ||
1292 | } | ||
1293 | }, | ||
1294 | { | ||
1295 | .ifnum = -1 | ||
1296 | } | ||
1297 | } | ||
1298 | } | ||
1299 | }, | ||
1300 | { | 1239 | { |
1301 | /* has ID 0x0081 when not in "Advanced Driver" mode */ | 1240 | /* has ID 0x0081 when not in "Advanced Driver" mode */ |
1302 | USB_DEVICE(0x0582, 0x0080), | 1241 | USB_DEVICE(0x0582, 0x0080), |
@@ -2073,6 +2012,33 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
2073 | } | 2012 | } |
2074 | }, | 2013 | }, |
2075 | 2014 | ||
2015 | /* Access Music devices */ | ||
2016 | { | ||
2017 | /* VirusTI Desktop */ | ||
2018 | USB_DEVICE_VENDOR_SPEC(0x133e, 0x0815), | ||
2019 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2020 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2021 | .type = QUIRK_COMPOSITE, | ||
2022 | .data = &(const struct snd_usb_audio_quirk[]) { | ||
2023 | { | ||
2024 | .ifnum = 3, | ||
2025 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
2026 | .data = &(const struct snd_usb_midi_endpoint_info) { | ||
2027 | .out_cables = 0x0003, | ||
2028 | .in_cables = 0x0003 | ||
2029 | } | ||
2030 | }, | ||
2031 | { | ||
2032 | .ifnum = 4, | ||
2033 | .type = QUIRK_IGNORE_INTERFACE | ||
2034 | }, | ||
2035 | { | ||
2036 | .ifnum = -1 | ||
2037 | } | ||
2038 | } | ||
2039 | } | ||
2040 | }, | ||
2041 | |||
2076 | /* */ | 2042 | /* */ |
2077 | { | 2043 | { |
2078 | /* aka. Serato Scratch Live DJ Box */ | 2044 | /* aka. Serato Scratch Live DJ Box */ |
@@ -2105,6 +2071,165 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
2105 | } | 2071 | } |
2106 | }, | 2072 | }, |
2107 | 2073 | ||
2074 | /* Hauppauge HVR-950Q and HVR-850 */ | ||
2075 | { | ||
2076 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7200), | ||
2077 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2078 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2079 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2080 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2081 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, | ||
2082 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2083 | .vendor_name = "Hauppauge", | ||
2084 | .product_name = "HVR-950Q", | ||
2085 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2086 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2087 | } | ||
2088 | }, | ||
2089 | { | ||
2090 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7201), | ||
2091 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2092 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2093 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2094 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2095 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, | ||
2096 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2097 | .vendor_name = "Hauppauge", | ||
2098 | .product_name = "HVR-950Q", | ||
2099 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2100 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2101 | } | ||
2102 | }, | ||
2103 | { | ||
2104 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7202), | ||
2105 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2106 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2107 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2108 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2109 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, | ||
2110 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2111 | .vendor_name = "Hauppauge", | ||
2112 | .product_name = "HVR-950Q", | ||
2113 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2114 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2115 | } | ||
2116 | }, | ||
2117 | { | ||
2118 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7203), | ||
2119 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2120 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2121 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2122 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2123 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, | ||
2124 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2125 | .vendor_name = "Hauppauge", | ||
2126 | .product_name = "HVR-950Q", | ||
2127 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2128 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2129 | } | ||
2130 | }, | ||
2131 | { | ||
2132 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7204), | ||
2133 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2134 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2135 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2136 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2137 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, | ||
2138 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2139 | .vendor_name = "Hauppauge", | ||
2140 | .product_name = "HVR-950Q", | ||
2141 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2142 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2143 | } | ||
2144 | }, | ||
2145 | { | ||
2146 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7205), | ||
2147 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2148 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2149 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2150 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2151 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, | ||
2152 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2153 | .vendor_name = "Hauppauge", | ||
2154 | .product_name = "HVR-950Q", | ||
2155 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2156 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2157 | } | ||
2158 | }, | ||
2159 | { | ||
2160 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7250), | ||
2161 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2162 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2163 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2164 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2165 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, | ||
2166 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2167 | .vendor_name = "Hauppauge", | ||
2168 | .product_name = "HVR-950Q", | ||
2169 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2170 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2171 | } | ||
2172 | }, | ||
2173 | { | ||
2174 | USB_DEVICE_VENDOR_SPEC(0x2040, 0x7230), | ||
2175 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | | ||
2176 | USB_DEVICE_ID_MATCH_INT_CLASS | | ||
2177 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | ||
2178 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
2179 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, | ||
2180 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2181 | .vendor_name = "Hauppauge", | ||
2182 | .product_name = "HVR-850", | ||
2183 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2184 | .type = QUIRK_AUDIO_ALIGN_TRANSFER, | ||
2185 | } | ||
2186 | }, | ||
2187 | |||
2188 | /* Digidesign Mbox */ | ||
2189 | { | ||
2190 | /* Thanks to Clemens Ladisch <clemens@ladisch.de> */ | ||
2191 | USB_DEVICE(0x0dba, 0x1000), | ||
2192 | .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { | ||
2193 | .vendor_name = "Digidesign", | ||
2194 | .product_name = "MBox", | ||
2195 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2196 | .type = QUIRK_COMPOSITE, | ||
2197 | .data = (const struct snd_usb_audio_quirk[]){ | ||
2198 | { | ||
2199 | .ifnum = 0, | ||
2200 | .type = QUIRK_IGNORE_INTERFACE, | ||
2201 | }, | ||
2202 | { | ||
2203 | .ifnum = 1, | ||
2204 | .type = QUIRK_AUDIO_FIXED_ENDPOINT, | ||
2205 | .data = &(const struct audioformat) { | ||
2206 | .format = SNDRV_PCM_FORMAT_S24_3BE, | ||
2207 | .channels = 2, | ||
2208 | .iface = 1, | ||
2209 | .altsetting = 1, | ||
2210 | .altset_idx = 1, | ||
2211 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, | ||
2212 | .endpoint = 0x02, | ||
2213 | .ep_attr = 0x01, | ||
2214 | .maxpacksize = 0x130, | ||
2215 | .rates = SNDRV_PCM_RATE_44100 | | ||
2216 | SNDRV_PCM_RATE_48000, | ||
2217 | .rate_min = 44100, | ||
2218 | .rate_max = 48000, | ||
2219 | .nr_rates = 2, | ||
2220 | .rate_table = (unsigned int[]) { | ||
2221 | 44100, 48000 | ||
2222 | } | ||
2223 | } | ||
2224 | }, | ||
2225 | { | ||
2226 | .ifnum = -1 | ||
2227 | } | ||
2228 | } | ||
2229 | |||
2230 | } | ||
2231 | }, | ||
2232 | |||
2108 | { | 2233 | { |
2109 | /* | 2234 | /* |
2110 | * Some USB MIDI devices don't have an audio control interface, | 2235 | * Some USB MIDI devices don't have an audio control interface, |
@@ -2113,7 +2238,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
2113 | .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | | 2238 | .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | |
2114 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, | 2239 | USB_DEVICE_ID_MATCH_INT_SUBCLASS, |
2115 | .bInterfaceClass = USB_CLASS_AUDIO, | 2240 | .bInterfaceClass = USB_CLASS_AUDIO, |
2116 | .bInterfaceSubClass = USB_SUBCLASS_MIDI_STREAMING, | 2241 | .bInterfaceSubClass = USB_SUBCLASS_MIDISTREAMING, |
2117 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | 2242 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { |
2118 | .ifnum = QUIRK_ANY_INTERFACE, | 2243 | .ifnum = QUIRK_ANY_INTERFACE, |
2119 | .type = QUIRK_MIDI_STANDARD_INTERFACE | 2244 | .type = QUIRK_MIDI_STANDARD_INTERFACE |
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 91bb29666d26..44deb21b1777 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c | |||
@@ -16,6 +16,8 @@ | |||
16 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 16 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/usb.h> | ||
20 | #include <linux/usb/audio.h> | ||
19 | #include <sound/core.h> | 21 | #include <sound/core.h> |
20 | #include <sound/hwdep.h> | 22 | #include <sound/hwdep.h> |
21 | #include <sound/pcm.h> | 23 | #include <sound/pcm.h> |
@@ -315,9 +317,9 @@ static int us122l_set_sample_rate(struct usb_device *dev, int rate) | |||
315 | data[0] = rate; | 317 | data[0] = rate; |
316 | data[1] = rate >> 8; | 318 | data[1] = rate >> 8; |
317 | data[2] = rate >> 16; | 319 | data[2] = rate >> 16; |
318 | err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, | 320 | err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, |
319 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, | 321 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, |
320 | SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000); | 322 | UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000); |
321 | if (err < 0) | 323 | if (err < 0) |
322 | snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", | 324 | snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", |
323 | dev->devnum, rate, ep); | 325 | dev->devnum, rate, ep); |