diff options
84 files changed, 3272 insertions, 1517 deletions
diff --git a/Documentation/DocBook/writing-an-alsa-driver.tmpl b/Documentation/DocBook/writing-an-alsa-driver.tmpl index bd6fee22c4dd..06741e925985 100644 --- a/Documentation/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/DocBook/writing-an-alsa-driver.tmpl | |||
@@ -6164,14 +6164,12 @@ struct _snd_pcm_runtime { | |||
6164 | 6164 | ||
6165 | <para> | 6165 | <para> |
6166 | The macro takes an conditional expression to evaluate. | 6166 | The macro takes an conditional expression to evaluate. |
6167 | When <constant>CONFIG_SND_DEBUG</constant>, is set, the | 6167 | When <constant>CONFIG_SND_DEBUG</constant>, is set, if the |
6168 | expression is actually evaluated. If it's non-zero, it shows | 6168 | expression is non-zero, it shows the warning message such as |
6169 | the warning message such as | ||
6170 | <computeroutput>BUG? (xxx)</computeroutput> | 6169 | <computeroutput>BUG? (xxx)</computeroutput> |
6171 | normally followed by stack trace. It returns the evaluated | 6170 | normally followed by stack trace. |
6172 | value. | 6171 | |
6173 | When no <constant>CONFIG_SND_DEBUG</constant> is set, this | 6172 | In both cases it returns the evaluated value. |
6174 | macro always returns zero. | ||
6175 | </para> | 6173 | </para> |
6176 | 6174 | ||
6177 | </section> | 6175 | </section> |
diff --git a/Documentation/sound/alsa/HD-Audio.txt b/Documentation/sound/alsa/HD-Audio.txt index d4faa63ff352..c3c912d023cc 100644 --- a/Documentation/sound/alsa/HD-Audio.txt +++ b/Documentation/sound/alsa/HD-Audio.txt | |||
@@ -461,11 +461,13 @@ The generic parser supports the following hints: | |||
461 | the corresponding mixer control, if available | 461 | the corresponding mixer control, if available |
462 | - add_stereo_mix_input (bool): add the stereo mix (analog-loopback | 462 | - add_stereo_mix_input (bool): add the stereo mix (analog-loopback |
463 | mix) to the input mux if available | 463 | mix) to the input mux if available |
464 | - add_out_jack_modes (bool): add "xxx Jack Mode" enum controls to each | 464 | - add_jack_modes (bool): add "xxx Jack Mode" enum controls to each |
465 | output jack for allowing to change the headphone amp capability | 465 | I/O jack for allowing to change the headphone amp and mic bias VREF |
466 | - add_in_jack_modes (bool): add "xxx Jack Mode" enum controls to each | 466 | capabilities |
467 | input jack for allowing to change the mic bias vref | ||
468 | - power_down_unused (bool): power down the unused widgets | 467 | - power_down_unused (bool): power down the unused widgets |
468 | - add_hp_mic (bool): add the headphone to capture source if possible | ||
469 | - hp_mic_detect (bool): enable/disable the hp/mic shared input for a | ||
470 | single built-in mic case; default true | ||
469 | - mixer_nid (int): specifies the widget NID of the analog-loopback | 471 | - mixer_nid (int): specifies the widget NID of the analog-loopback |
470 | mixer | 472 | mixer |
471 | 473 | ||
diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h index ed13053153f4..c5f2158ab00e 100644 --- a/include/linux/usb/audio-v2.h +++ b/include/linux/usb/audio-v2.h | |||
@@ -170,6 +170,8 @@ struct uac2_as_header_descriptor { | |||
170 | __u8 iChannelNames; | 170 | __u8 iChannelNames; |
171 | } __attribute__((packed)); | 171 | } __attribute__((packed)); |
172 | 172 | ||
173 | #define UAC2_FORMAT_TYPE_I_RAW_DATA (1 << 31) | ||
174 | |||
173 | /* 4.10.1.2 Class-Specific AS Isochronous Audio Data Endpoint Descriptor */ | 175 | /* 4.10.1.2 Class-Specific AS Isochronous Audio Data Endpoint Descriptor */ |
174 | 176 | ||
175 | struct uac2_iso_endpoint_descriptor { | 177 | struct uac2_iso_endpoint_descriptor { |
diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h index ff6c74153fa1..9031a26249b5 100644 --- a/include/sound/compress_driver.h +++ b/include/sound/compress_driver.h | |||
@@ -56,8 +56,6 @@ struct snd_compr_runtime { | |||
56 | u64 buffer_size; | 56 | u64 buffer_size; |
57 | u32 fragment_size; | 57 | u32 fragment_size; |
58 | u32 fragments; | 58 | u32 fragments; |
59 | u64 hw_pointer; | ||
60 | u64 app_pointer; | ||
61 | u64 total_bytes_available; | 59 | u64 total_bytes_available; |
62 | u64 total_bytes_transferred; | 60 | u64 total_bytes_transferred; |
63 | wait_queue_head_t sleep; | 61 | wait_queue_head_t sleep; |
@@ -121,7 +119,7 @@ struct snd_compr_ops { | |||
121 | int (*trigger)(struct snd_compr_stream *stream, int cmd); | 119 | int (*trigger)(struct snd_compr_stream *stream, int cmd); |
122 | int (*pointer)(struct snd_compr_stream *stream, | 120 | int (*pointer)(struct snd_compr_stream *stream, |
123 | struct snd_compr_tstamp *tstamp); | 121 | struct snd_compr_tstamp *tstamp); |
124 | int (*copy)(struct snd_compr_stream *stream, const char __user *buf, | 122 | int (*copy)(struct snd_compr_stream *stream, char __user *buf, |
125 | size_t count); | 123 | size_t count); |
126 | int (*mmap)(struct snd_compr_stream *stream, | 124 | int (*mmap)(struct snd_compr_stream *stream, |
127 | struct vm_area_struct *vma); | 125 | struct vm_area_struct *vma); |
diff --git a/include/sound/control.h b/include/sound/control.h index 8332e865c759..34bc93d80d55 100644 --- a/include/sound/control.h +++ b/include/sound/control.h | |||
@@ -189,7 +189,6 @@ int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave, | |||
189 | * | 189 | * |
190 | * Add a virtual slave control to the given master element created via | 190 | * Add a virtual slave control to the given master element created via |
191 | * snd_ctl_create_virtual_master() beforehand. | 191 | * snd_ctl_create_virtual_master() beforehand. |
192 | * Returns zero if successful or a negative error code. | ||
193 | * | 192 | * |
194 | * All slaves must be the same type (returning the same information | 193 | * All slaves must be the same type (returning the same information |
195 | * via info callback). The function doesn't check it, so it's your | 194 | * via info callback). The function doesn't check it, so it's your |
@@ -199,6 +198,8 @@ int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave, | |||
199 | * at most two channels, | 198 | * at most two channels, |
200 | * logarithmic volume control (dB level) thus no linear volume, | 199 | * logarithmic volume control (dB level) thus no linear volume, |
201 | * master can only attenuate the volume without gain | 200 | * master can only attenuate the volume without gain |
201 | * | ||
202 | * Return: Zero if successful or a negative error code. | ||
202 | */ | 203 | */ |
203 | static inline int | 204 | static inline int |
204 | snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave) | 205 | snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave) |
@@ -219,6 +220,8 @@ snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave) | |||
219 | * When the control peeks the hardware values directly and the value | 220 | * When the control peeks the hardware values directly and the value |
220 | * can be changed by other means than the put callback of the element, | 221 | * can be changed by other means than the put callback of the element, |
221 | * this function should be used to keep the value always up-to-date. | 222 | * this function should be used to keep the value always up-to-date. |
223 | * | ||
224 | * Return: Zero if successful or a negative error code. | ||
222 | */ | 225 | */ |
223 | static inline int | 226 | static inline int |
224 | snd_ctl_add_slave_uncached(struct snd_kcontrol *master, | 227 | snd_ctl_add_slave_uncached(struct snd_kcontrol *master, |
diff --git a/include/sound/core.h b/include/sound/core.h index 7cede2d6aa86..5bfe5136441c 100644 --- a/include/sound/core.h +++ b/include/sound/core.h | |||
@@ -229,7 +229,7 @@ int snd_register_device_for_dev(int type, struct snd_card *card, | |||
229 | * This function uses the card's device pointer to link to the | 229 | * This function uses the card's device pointer to link to the |
230 | * correct &struct device. | 230 | * correct &struct device. |
231 | * | 231 | * |
232 | * Returns zero if successful, or a negative error code on failure. | 232 | * Return: Zero if successful, or a negative error code on failure. |
233 | */ | 233 | */ |
234 | static inline int snd_register_device(int type, struct snd_card *card, int dev, | 234 | static inline int snd_register_device(int type, struct snd_card *card, int dev, |
235 | const struct file_operations *f_ops, | 235 | const struct file_operations *f_ops, |
@@ -379,18 +379,10 @@ void __snd_printk(unsigned int level, const char *file, int line, | |||
379 | * snd_BUG_ON - debugging check macro | 379 | * snd_BUG_ON - debugging check macro |
380 | * @cond: condition to evaluate | 380 | * @cond: condition to evaluate |
381 | * | 381 | * |
382 | * When CONFIG_SND_DEBUG is set, this macro evaluates the given condition, | 382 | * Has the same behavior as WARN_ON when CONFIG_SND_DEBUG is set, |
383 | * and call WARN() and returns the value if it's non-zero. | 383 | * otherwise just evaluates the conditional and returns the value. |
384 | * | ||
385 | * When CONFIG_SND_DEBUG is not set, this just returns zero, and the given | ||
386 | * condition is ignored. | ||
387 | * | ||
388 | * NOTE: the argument won't be evaluated at all when CONFIG_SND_DEBUG=n. | ||
389 | * Thus, don't put any statement that influences on the code behavior, | ||
390 | * such as pre/post increment, to the argument of this macro. | ||
391 | * If you want to evaluate and give a warning, use standard WARN_ON(). | ||
392 | */ | 384 | */ |
393 | #define snd_BUG_ON(cond) WARN((cond), "BUG? (%s)\n", __stringify(cond)) | 385 | #define snd_BUG_ON(cond) WARN_ON((cond)) |
394 | 386 | ||
395 | #else /* !CONFIG_SND_DEBUG */ | 387 | #else /* !CONFIG_SND_DEBUG */ |
396 | 388 | ||
@@ -400,11 +392,11 @@ __printf(2, 3) | |||
400 | static inline void _snd_printd(int level, const char *format, ...) {} | 392 | static inline void _snd_printd(int level, const char *format, ...) {} |
401 | 393 | ||
402 | #define snd_BUG() do { } while (0) | 394 | #define snd_BUG() do { } while (0) |
403 | static inline int __snd_bug_on(int cond) | 395 | |
404 | { | 396 | #define snd_BUG_ON(condition) ({ \ |
405 | return 0; | 397 | int __ret_warn_on = !!(condition); \ |
406 | } | 398 | unlikely(__ret_warn_on); \ |
407 | #define snd_BUG_ON(cond) __snd_bug_on(0 && (cond)) /* always false */ | 399 | }) |
408 | 400 | ||
409 | #endif /* CONFIG_SND_DEBUG */ | 401 | #endif /* CONFIG_SND_DEBUG */ |
410 | 402 | ||
diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index f841ba4bacb8..dfb42ca6d043 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h | |||
@@ -1787,6 +1787,7 @@ struct snd_emu10k1 { | |||
1787 | unsigned int next_free_voice; | 1787 | unsigned int next_free_voice; |
1788 | 1788 | ||
1789 | const struct firmware *firmware; | 1789 | const struct firmware *firmware; |
1790 | const struct firmware *dock_fw; | ||
1790 | 1791 | ||
1791 | #ifdef CONFIG_PM_SLEEP | 1792 | #ifdef CONFIG_PM_SLEEP |
1792 | unsigned int *saved_ptr; | 1793 | unsigned int *saved_ptr; |
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 45c1981c9ca2..1b0c6484e71a 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h | |||
@@ -181,6 +181,8 @@ struct snd_pcm_ops { | |||
181 | #define SNDRV_PCM_FMTBIT_G723_24_1B _SNDRV_PCM_FMTBIT(G723_24_1B) | 181 | #define SNDRV_PCM_FMTBIT_G723_24_1B _SNDRV_PCM_FMTBIT(G723_24_1B) |
182 | #define SNDRV_PCM_FMTBIT_G723_40 _SNDRV_PCM_FMTBIT(G723_40) | 182 | #define SNDRV_PCM_FMTBIT_G723_40 _SNDRV_PCM_FMTBIT(G723_40) |
183 | #define SNDRV_PCM_FMTBIT_G723_40_1B _SNDRV_PCM_FMTBIT(G723_40_1B) | 183 | #define SNDRV_PCM_FMTBIT_G723_40_1B _SNDRV_PCM_FMTBIT(G723_40_1B) |
184 | #define SNDRV_PCM_FMTBIT_DSD_U8 _SNDRV_PCM_FMTBIT(DSD_U8) | ||
185 | #define SNDRV_PCM_FMTBIT_DSD_U16_LE _SNDRV_PCM_FMTBIT(DSD_U16_LE) | ||
184 | 186 | ||
185 | #ifdef SNDRV_LITTLE_ENDIAN | 187 | #ifdef SNDRV_LITTLE_ENDIAN |
186 | #define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE | 188 | #define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE |
@@ -659,7 +661,7 @@ static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime | |||
659 | * | 661 | * |
660 | * Checks whether enough free space is available on the playback buffer. | 662 | * Checks whether enough free space is available on the playback buffer. |
661 | * | 663 | * |
662 | * Returns non-zero if available, or zero if not. | 664 | * Return: Non-zero if available, or zero if not. |
663 | */ | 665 | */ |
664 | static inline int snd_pcm_playback_ready(struct snd_pcm_substream *substream) | 666 | static inline int snd_pcm_playback_ready(struct snd_pcm_substream *substream) |
665 | { | 667 | { |
@@ -673,7 +675,7 @@ static inline int snd_pcm_playback_ready(struct snd_pcm_substream *substream) | |||
673 | * | 675 | * |
674 | * Checks whether enough capture data is available on the capture buffer. | 676 | * Checks whether enough capture data is available on the capture buffer. |
675 | * | 677 | * |
676 | * Returns non-zero if available, or zero if not. | 678 | * Return: Non-zero if available, or zero if not. |
677 | */ | 679 | */ |
678 | static inline int snd_pcm_capture_ready(struct snd_pcm_substream *substream) | 680 | static inline int snd_pcm_capture_ready(struct snd_pcm_substream *substream) |
679 | { | 681 | { |
@@ -685,10 +687,10 @@ static inline int snd_pcm_capture_ready(struct snd_pcm_substream *substream) | |||
685 | * snd_pcm_playback_data - check whether any data exists on the playback buffer | 687 | * snd_pcm_playback_data - check whether any data exists on the playback buffer |
686 | * @substream: the pcm substream instance | 688 | * @substream: the pcm substream instance |
687 | * | 689 | * |
688 | * Checks whether any data exists on the playback buffer. If stop_threshold | 690 | * Checks whether any data exists on the playback buffer. |
689 | * is bigger or equal to boundary, then this function returns always non-zero. | ||
690 | * | 691 | * |
691 | * Returns non-zero if exists, or zero if not. | 692 | * Return: Non-zero if any data exists, or zero if not. If stop_threshold |
693 | * is bigger or equal to boundary, then this function returns always non-zero. | ||
692 | */ | 694 | */ |
693 | static inline int snd_pcm_playback_data(struct snd_pcm_substream *substream) | 695 | static inline int snd_pcm_playback_data(struct snd_pcm_substream *substream) |
694 | { | 696 | { |
@@ -705,7 +707,7 @@ static inline int snd_pcm_playback_data(struct snd_pcm_substream *substream) | |||
705 | * | 707 | * |
706 | * Checks whether the playback buffer is empty. | 708 | * Checks whether the playback buffer is empty. |
707 | * | 709 | * |
708 | * Returns non-zero if empty, or zero if not. | 710 | * Return: Non-zero if empty, or zero if not. |
709 | */ | 711 | */ |
710 | static inline int snd_pcm_playback_empty(struct snd_pcm_substream *substream) | 712 | static inline int snd_pcm_playback_empty(struct snd_pcm_substream *substream) |
711 | { | 713 | { |
@@ -719,7 +721,7 @@ static inline int snd_pcm_playback_empty(struct snd_pcm_substream *substream) | |||
719 | * | 721 | * |
720 | * Checks whether the capture buffer is empty. | 722 | * Checks whether the capture buffer is empty. |
721 | * | 723 | * |
722 | * Returns non-zero if empty, or zero if not. | 724 | * Return: Non-zero if empty, or zero if not. |
723 | */ | 725 | */ |
724 | static inline int snd_pcm_capture_empty(struct snd_pcm_substream *substream) | 726 | static inline int snd_pcm_capture_empty(struct snd_pcm_substream *substream) |
725 | { | 727 | { |
@@ -852,7 +854,7 @@ int snd_pcm_format_big_endian(snd_pcm_format_t format); | |||
852 | * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian | 854 | * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian |
853 | * @format: the format to check | 855 | * @format: the format to check |
854 | * | 856 | * |
855 | * Returns 1 if the given PCM format is CPU-endian, 0 if | 857 | * Return: 1 if the given PCM format is CPU-endian, 0 if |
856 | * opposite, or a negative error code if endian not specified. | 858 | * opposite, or a negative error code if endian not specified. |
857 | */ | 859 | */ |
858 | int snd_pcm_format_cpu_endian(snd_pcm_format_t format); | 860 | int snd_pcm_format_cpu_endian(snd_pcm_format_t format); |
@@ -963,7 +965,7 @@ struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, | |||
963 | * contiguous in kernel virtual space, but not in physical memory. Use this | 965 | * contiguous in kernel virtual space, but not in physical memory. Use this |
964 | * if the buffer is accessed by kernel code but not by device DMA. | 966 | * if the buffer is accessed by kernel code but not by device DMA. |
965 | * | 967 | * |
966 | * Returns 1 if the buffer was changed, 0 if not changed, or a negative error | 968 | * Return: 1 if the buffer was changed, 0 if not changed, or a negative error |
967 | * code. | 969 | * code. |
968 | */ | 970 | */ |
969 | static int snd_pcm_lib_alloc_vmalloc_buffer | 971 | static int snd_pcm_lib_alloc_vmalloc_buffer |
@@ -975,6 +977,9 @@ static int snd_pcm_lib_alloc_vmalloc_buffer | |||
975 | * | 977 | * |
976 | * This function works like snd_pcm_lib_alloc_vmalloc_buffer(), but uses | 978 | * This function works like snd_pcm_lib_alloc_vmalloc_buffer(), but uses |
977 | * vmalloc_32(), i.e., the pages are allocated from 32-bit-addressable memory. | 979 | * vmalloc_32(), i.e., the pages are allocated from 32-bit-addressable memory. |
980 | * | ||
981 | * Return: 1 if the buffer was changed, 0 if not changed, or a negative error | ||
982 | * code. | ||
978 | */ | 983 | */ |
979 | static int snd_pcm_lib_alloc_vmalloc_32_buffer | 984 | static int snd_pcm_lib_alloc_vmalloc_32_buffer |
980 | (struct snd_pcm_substream *substream, size_t size); | 985 | (struct snd_pcm_substream *substream, size_t size); |
@@ -1070,6 +1075,8 @@ const char *snd_pcm_format_name(snd_pcm_format_t format); | |||
1070 | /** | 1075 | /** |
1071 | * snd_pcm_stream_str - Get a string naming the direction of a stream | 1076 | * snd_pcm_stream_str - Get a string naming the direction of a stream |
1072 | * @substream: the pcm substream instance | 1077 | * @substream: the pcm substream instance |
1078 | * | ||
1079 | * Return: A string naming the direction of the stream. | ||
1073 | */ | 1080 | */ |
1074 | static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream) | 1081 | static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream) |
1075 | { | 1082 | { |
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index 1774a5c3ef10..e3983d508272 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h | |||
@@ -214,7 +214,9 @@ typedef int __bitwise snd_pcm_format_t; | |||
214 | #define SNDRV_PCM_FORMAT_G723_24_1B ((__force snd_pcm_format_t) 45) /* 1 sample in 1 byte */ | 214 | #define SNDRV_PCM_FORMAT_G723_24_1B ((__force snd_pcm_format_t) 45) /* 1 sample in 1 byte */ |
215 | #define SNDRV_PCM_FORMAT_G723_40 ((__force snd_pcm_format_t) 46) /* 8 Samples in 5 bytes */ | 215 | #define SNDRV_PCM_FORMAT_G723_40 ((__force snd_pcm_format_t) 46) /* 8 Samples in 5 bytes */ |
216 | #define SNDRV_PCM_FORMAT_G723_40_1B ((__force snd_pcm_format_t) 47) /* 1 sample in 1 byte */ | 216 | #define SNDRV_PCM_FORMAT_G723_40_1B ((__force snd_pcm_format_t) 47) /* 1 sample in 1 byte */ |
217 | #define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_G723_40_1B | 217 | #define SNDRV_PCM_FORMAT_DSD_U8 ((__force snd_pcm_format_t) 48) /* DSD, 1-byte samples DSD (x8) */ |
218 | #define SNDRV_PCM_FORMAT_DSD_U16_LE ((__force snd_pcm_format_t) 49) /* DSD, 2-byte samples DSD (x16), little endian */ | ||
219 | #define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_DSD_U16_LE | ||
218 | 220 | ||
219 | #ifdef SNDRV_LITTLE_ENDIAN | 221 | #ifdef SNDRV_LITTLE_ENDIAN |
220 | #define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE | 222 | #define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE |
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index c84abc886e90..a0bc47f8dcf7 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c | |||
@@ -28,11 +28,13 @@ | |||
28 | #include <linux/file.h> | 28 | #include <linux/file.h> |
29 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
30 | #include <linux/list.h> | 30 | #include <linux/list.h> |
31 | #include <linux/math64.h> | ||
31 | #include <linux/mm.h> | 32 | #include <linux/mm.h> |
32 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
33 | #include <linux/poll.h> | 34 | #include <linux/poll.h> |
34 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
35 | #include <linux/sched.h> | 36 | #include <linux/sched.h> |
37 | #include <linux/types.h> | ||
36 | #include <linux/uio.h> | 38 | #include <linux/uio.h> |
37 | #include <linux/uaccess.h> | 39 | #include <linux/uaccess.h> |
38 | #include <linux/module.h> | 40 | #include <linux/module.h> |
@@ -152,26 +154,23 @@ static int snd_compr_update_tstamp(struct snd_compr_stream *stream, | |||
152 | stream->ops->pointer(stream, tstamp); | 154 | stream->ops->pointer(stream, tstamp); |
153 | pr_debug("dsp consumed till %d total %d bytes\n", | 155 | pr_debug("dsp consumed till %d total %d bytes\n", |
154 | tstamp->byte_offset, tstamp->copied_total); | 156 | tstamp->byte_offset, tstamp->copied_total); |
155 | stream->runtime->hw_pointer = tstamp->byte_offset; | 157 | if (stream->direction == SND_COMPRESS_PLAYBACK) |
156 | stream->runtime->total_bytes_transferred = tstamp->copied_total; | 158 | stream->runtime->total_bytes_transferred = tstamp->copied_total; |
159 | else | ||
160 | stream->runtime->total_bytes_available = tstamp->copied_total; | ||
157 | return 0; | 161 | return 0; |
158 | } | 162 | } |
159 | 163 | ||
160 | static size_t snd_compr_calc_avail(struct snd_compr_stream *stream, | 164 | static size_t snd_compr_calc_avail(struct snd_compr_stream *stream, |
161 | struct snd_compr_avail *avail) | 165 | struct snd_compr_avail *avail) |
162 | { | 166 | { |
163 | long avail_calc; /*this needs to be signed variable */ | ||
164 | |||
165 | memset(avail, 0, sizeof(*avail)); | 167 | memset(avail, 0, sizeof(*avail)); |
166 | snd_compr_update_tstamp(stream, &avail->tstamp); | 168 | snd_compr_update_tstamp(stream, &avail->tstamp); |
167 | /* Still need to return avail even if tstamp can't be filled in */ | 169 | /* Still need to return avail even if tstamp can't be filled in */ |
168 | 170 | ||
169 | /* FIXME: This needs to be different for capture stream, | ||
170 | available is # of compressed data, for playback it's | ||
171 | remainder of buffer */ | ||
172 | |||
173 | if (stream->runtime->total_bytes_available == 0 && | 171 | if (stream->runtime->total_bytes_available == 0 && |
174 | stream->runtime->state == SNDRV_PCM_STATE_SETUP) { | 172 | stream->runtime->state == SNDRV_PCM_STATE_SETUP && |
173 | stream->direction == SND_COMPRESS_PLAYBACK) { | ||
175 | pr_debug("detected init and someone forgot to do a write\n"); | 174 | pr_debug("detected init and someone forgot to do a write\n"); |
176 | return stream->runtime->buffer_size; | 175 | return stream->runtime->buffer_size; |
177 | } | 176 | } |
@@ -180,26 +179,22 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream, | |||
180 | stream->runtime->total_bytes_transferred); | 179 | stream->runtime->total_bytes_transferred); |
181 | if (stream->runtime->total_bytes_available == | 180 | if (stream->runtime->total_bytes_available == |
182 | stream->runtime->total_bytes_transferred) { | 181 | stream->runtime->total_bytes_transferred) { |
183 | pr_debug("both pointers are same, returning full avail\n"); | 182 | if (stream->direction == SND_COMPRESS_PLAYBACK) { |
184 | return stream->runtime->buffer_size; | 183 | pr_debug("both pointers are same, returning full avail\n"); |
184 | return stream->runtime->buffer_size; | ||
185 | } else { | ||
186 | pr_debug("both pointers are same, returning no avail\n"); | ||
187 | return 0; | ||
188 | } | ||
185 | } | 189 | } |
186 | 190 | ||
187 | /* FIXME: this routine isn't consistent, in one test we use | 191 | avail->avail = stream->runtime->total_bytes_available - |
188 | * cumulative values and in the other byte offsets. Do we | 192 | stream->runtime->total_bytes_transferred; |
189 | * really need the byte offsets if the cumulative values have | 193 | if (stream->direction == SND_COMPRESS_PLAYBACK) |
190 | * been updated? In the PCM interface app_ptr and hw_ptr are | 194 | avail->avail = stream->runtime->buffer_size - avail->avail; |
191 | * already cumulative */ | ||
192 | 195 | ||
193 | avail_calc = stream->runtime->buffer_size - | 196 | pr_debug("ret avail as %lld\n", avail->avail); |
194 | (stream->runtime->app_pointer - stream->runtime->hw_pointer); | 197 | return avail->avail; |
195 | pr_debug("calc avail as %ld, app_ptr %lld, hw+ptr %lld\n", avail_calc, | ||
196 | stream->runtime->app_pointer, | ||
197 | stream->runtime->hw_pointer); | ||
198 | if (avail_calc >= stream->runtime->buffer_size) | ||
199 | avail_calc -= stream->runtime->buffer_size; | ||
200 | pr_debug("ret avail as %ld\n", avail_calc); | ||
201 | avail->avail = avail_calc; | ||
202 | return avail_calc; | ||
203 | } | 198 | } |
204 | 199 | ||
205 | static inline size_t snd_compr_get_avail(struct snd_compr_stream *stream) | 200 | static inline size_t snd_compr_get_avail(struct snd_compr_stream *stream) |
@@ -230,21 +225,24 @@ static int snd_compr_write_data(struct snd_compr_stream *stream, | |||
230 | void *dstn; | 225 | void *dstn; |
231 | size_t copy; | 226 | size_t copy; |
232 | struct snd_compr_runtime *runtime = stream->runtime; | 227 | struct snd_compr_runtime *runtime = stream->runtime; |
228 | /* 64-bit Modulus */ | ||
229 | u64 app_pointer = div64_u64(runtime->total_bytes_available, | ||
230 | runtime->buffer_size); | ||
231 | app_pointer = runtime->total_bytes_available - | ||
232 | (app_pointer * runtime->buffer_size); | ||
233 | 233 | ||
234 | dstn = runtime->buffer + runtime->app_pointer; | 234 | dstn = runtime->buffer + app_pointer; |
235 | pr_debug("copying %ld at %lld\n", | 235 | pr_debug("copying %ld at %lld\n", |
236 | (unsigned long)count, runtime->app_pointer); | 236 | (unsigned long)count, app_pointer); |
237 | if (count < runtime->buffer_size - runtime->app_pointer) { | 237 | if (count < runtime->buffer_size - app_pointer) { |
238 | if (copy_from_user(dstn, buf, count)) | 238 | if (copy_from_user(dstn, buf, count)) |
239 | return -EFAULT; | 239 | return -EFAULT; |
240 | runtime->app_pointer += count; | ||
241 | } else { | 240 | } else { |
242 | copy = runtime->buffer_size - runtime->app_pointer; | 241 | copy = runtime->buffer_size - app_pointer; |
243 | if (copy_from_user(dstn, buf, copy)) | 242 | if (copy_from_user(dstn, buf, copy)) |
244 | return -EFAULT; | 243 | return -EFAULT; |
245 | if (copy_from_user(runtime->buffer, buf + copy, count - copy)) | 244 | if (copy_from_user(runtime->buffer, buf + copy, count - copy)) |
246 | return -EFAULT; | 245 | return -EFAULT; |
247 | runtime->app_pointer = count - copy; | ||
248 | } | 246 | } |
249 | /* if DSP cares, let it know data has been written */ | 247 | /* if DSP cares, let it know data has been written */ |
250 | if (stream->ops->ack) | 248 | if (stream->ops->ack) |
@@ -278,10 +276,12 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf, | |||
278 | if (avail > count) | 276 | if (avail > count) |
279 | avail = count; | 277 | avail = count; |
280 | 278 | ||
281 | if (stream->ops->copy) | 279 | if (stream->ops->copy) { |
282 | retval = stream->ops->copy(stream, buf, avail); | 280 | char __user* cbuf = (char __user*)buf; |
283 | else | 281 | retval = stream->ops->copy(stream, cbuf, avail); |
282 | } else { | ||
284 | retval = snd_compr_write_data(stream, buf, avail); | 283 | retval = snd_compr_write_data(stream, buf, avail); |
284 | } | ||
285 | if (retval > 0) | 285 | if (retval > 0) |
286 | stream->runtime->total_bytes_available += retval; | 286 | stream->runtime->total_bytes_available += retval; |
287 | 287 | ||
@@ -300,7 +300,41 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf, | |||
300 | static ssize_t snd_compr_read(struct file *f, char __user *buf, | 300 | static ssize_t snd_compr_read(struct file *f, char __user *buf, |
301 | size_t count, loff_t *offset) | 301 | size_t count, loff_t *offset) |
302 | { | 302 | { |
303 | return -ENXIO; | 303 | struct snd_compr_file *data = f->private_data; |
304 | struct snd_compr_stream *stream; | ||
305 | size_t avail; | ||
306 | int retval; | ||
307 | |||
308 | if (snd_BUG_ON(!data)) | ||
309 | return -EFAULT; | ||
310 | |||
311 | stream = &data->stream; | ||
312 | mutex_lock(&stream->device->lock); | ||
313 | |||
314 | /* read is allowed when stream is running */ | ||
315 | if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) { | ||
316 | retval = -EBADFD; | ||
317 | goto out; | ||
318 | } | ||
319 | |||
320 | avail = snd_compr_get_avail(stream); | ||
321 | pr_debug("avail returned %ld\n", (unsigned long)avail); | ||
322 | /* calculate how much we can read from buffer */ | ||
323 | if (avail > count) | ||
324 | avail = count; | ||
325 | |||
326 | if (stream->ops->copy) { | ||
327 | retval = stream->ops->copy(stream, buf, avail); | ||
328 | } else { | ||
329 | retval = -ENXIO; | ||
330 | goto out; | ||
331 | } | ||
332 | if (retval > 0) | ||
333 | stream->runtime->total_bytes_transferred += retval; | ||
334 | |||
335 | out: | ||
336 | mutex_unlock(&stream->device->lock); | ||
337 | return retval; | ||
304 | } | 338 | } |
305 | 339 | ||
306 | static int snd_compr_mmap(struct file *f, struct vm_area_struct *vma) | 340 | static int snd_compr_mmap(struct file *f, struct vm_area_struct *vma) |
@@ -375,6 +409,7 @@ snd_compr_get_caps(struct snd_compr_stream *stream, unsigned long arg) | |||
375 | if (!stream->ops->get_caps) | 409 | if (!stream->ops->get_caps) |
376 | return -ENXIO; | 410 | return -ENXIO; |
377 | 411 | ||
412 | memset(&caps, 0, sizeof(caps)); | ||
378 | retval = stream->ops->get_caps(stream, &caps); | 413 | retval = stream->ops->get_caps(stream, &caps); |
379 | if (retval) | 414 | if (retval) |
380 | goto out; | 415 | goto out; |
@@ -393,7 +428,7 @@ snd_compr_get_codec_caps(struct snd_compr_stream *stream, unsigned long arg) | |||
393 | if (!stream->ops->get_codec_caps) | 428 | if (!stream->ops->get_codec_caps) |
394 | return -ENXIO; | 429 | return -ENXIO; |
395 | 430 | ||
396 | caps = kmalloc(sizeof(*caps), GFP_KERNEL); | 431 | caps = kzalloc(sizeof(*caps), GFP_KERNEL); |
397 | if (!caps) | 432 | if (!caps) |
398 | return -ENOMEM; | 433 | return -ENOMEM; |
399 | 434 | ||
@@ -485,9 +520,14 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) | |||
485 | retval = stream->ops->set_params(stream, params); | 520 | retval = stream->ops->set_params(stream, params); |
486 | if (retval) | 521 | if (retval) |
487 | goto out; | 522 | goto out; |
488 | stream->runtime->state = SNDRV_PCM_STATE_SETUP; | 523 | |
489 | stream->metadata_set = false; | 524 | stream->metadata_set = false; |
490 | stream->next_track = false; | 525 | stream->next_track = false; |
526 | |||
527 | if (stream->direction == SND_COMPRESS_PLAYBACK) | ||
528 | stream->runtime->state = SNDRV_PCM_STATE_SETUP; | ||
529 | else | ||
530 | stream->runtime->state = SNDRV_PCM_STATE_PREPARED; | ||
491 | } else { | 531 | } else { |
492 | return -EPERM; | 532 | return -EPERM; |
493 | } | 533 | } |
@@ -505,7 +545,7 @@ snd_compr_get_params(struct snd_compr_stream *stream, unsigned long arg) | |||
505 | if (!stream->ops->get_params) | 545 | if (!stream->ops->get_params) |
506 | return -EBADFD; | 546 | return -EBADFD; |
507 | 547 | ||
508 | params = kmalloc(sizeof(*params), GFP_KERNEL); | 548 | params = kzalloc(sizeof(*params), GFP_KERNEL); |
509 | if (!params) | 549 | if (!params) |
510 | return -ENOMEM; | 550 | return -ENOMEM; |
511 | retval = stream->ops->get_params(stream, params); | 551 | retval = stream->ops->get_params(stream, params); |
@@ -622,8 +662,6 @@ static int snd_compr_stop(struct snd_compr_stream *stream) | |||
622 | if (!retval) { | 662 | if (!retval) { |
623 | stream->runtime->state = SNDRV_PCM_STATE_SETUP; | 663 | stream->runtime->state = SNDRV_PCM_STATE_SETUP; |
624 | wake_up(&stream->runtime->sleep); | 664 | wake_up(&stream->runtime->sleep); |
625 | stream->runtime->hw_pointer = 0; | ||
626 | stream->runtime->app_pointer = 0; | ||
627 | stream->runtime->total_bytes_available = 0; | 665 | stream->runtime->total_bytes_available = 0; |
628 | stream->runtime->total_bytes_transferred = 0; | 666 | stream->runtime->total_bytes_transferred = 0; |
629 | } | 667 | } |
diff --git a/sound/core/control.c b/sound/core/control.c index 8c7c2c9bba61..d8aa206e8bde 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -190,7 +190,7 @@ EXPORT_SYMBOL(snd_ctl_notify); | |||
190 | * Allocates a new struct snd_kcontrol instance and copies the given template | 190 | * Allocates a new struct snd_kcontrol instance and copies the given template |
191 | * to the new instance. It does not copy volatile data (access). | 191 | * to the new instance. It does not copy volatile data (access). |
192 | * | 192 | * |
193 | * Returns the pointer of the new instance, or NULL on failure. | 193 | * Return: The pointer of the new instance, or %NULL on failure. |
194 | */ | 194 | */ |
195 | static struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, | 195 | static struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, |
196 | unsigned int access) | 196 | unsigned int access) |
@@ -224,7 +224,7 @@ static struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, | |||
224 | * template. When the access field of ncontrol is 0, it's assumed as | 224 | * template. When the access field of ncontrol is 0, it's assumed as |
225 | * READWRITE access. When the count field is 0, it's assumes as one. | 225 | * READWRITE access. When the count field is 0, it's assumes as one. |
226 | * | 226 | * |
227 | * Returns the pointer of the newly generated instance, or NULL on failure. | 227 | * Return: The pointer of the newly generated instance, or %NULL on failure. |
228 | */ | 228 | */ |
229 | struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol, | 229 | struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol, |
230 | void *private_data) | 230 | void *private_data) |
@@ -322,9 +322,10 @@ static int snd_ctl_find_hole(struct snd_card *card, unsigned int count) | |||
322 | * snd_ctl_new1() to the given card. Assigns also an unique | 322 | * snd_ctl_new1() to the given card. Assigns also an unique |
323 | * numid used for fast search. | 323 | * numid used for fast search. |
324 | * | 324 | * |
325 | * Returns zero if successful, or a negative error code on failure. | ||
326 | * | ||
327 | * It frees automatically the control which cannot be added. | 325 | * It frees automatically the control which cannot be added. |
326 | * | ||
327 | * Return: Zero if successful, or a negative error code on failure. | ||
328 | * | ||
328 | */ | 329 | */ |
329 | int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) | 330 | int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) |
330 | { | 331 | { |
@@ -380,9 +381,9 @@ EXPORT_SYMBOL(snd_ctl_add); | |||
380 | * and the add_on_replace flag is set, the control is added. If the | 381 | * and the add_on_replace flag is set, the control is added. If the |
381 | * control exists, it is destroyed first. | 382 | * control exists, it is destroyed first. |
382 | * | 383 | * |
383 | * Returns zero if successful, or a negative error code on failure. | ||
384 | * | ||
385 | * It frees automatically the control which cannot be added or replaced. | 384 | * It frees automatically the control which cannot be added or replaced. |
385 | * | ||
386 | * Return: Zero if successful, or a negative error code on failure. | ||
386 | */ | 387 | */ |
387 | int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, | 388 | int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, |
388 | bool add_on_replace) | 389 | bool add_on_replace) |
@@ -442,8 +443,8 @@ EXPORT_SYMBOL(snd_ctl_replace); | |||
442 | * Removes the control from the card and then releases the instance. | 443 | * Removes the control from the card and then releases the instance. |
443 | * You don't need to call snd_ctl_free_one(). You must be in | 444 | * You don't need to call snd_ctl_free_one(). You must be in |
444 | * the write lock - down_write(&card->controls_rwsem). | 445 | * the write lock - down_write(&card->controls_rwsem). |
445 | * | 446 | * |
446 | * Returns 0 if successful, or a negative error code on failure. | 447 | * Return: 0 if successful, or a negative error code on failure. |
447 | */ | 448 | */ |
448 | int snd_ctl_remove(struct snd_card *card, struct snd_kcontrol *kcontrol) | 449 | int snd_ctl_remove(struct snd_card *card, struct snd_kcontrol *kcontrol) |
449 | { | 450 | { |
@@ -470,8 +471,8 @@ EXPORT_SYMBOL(snd_ctl_remove); | |||
470 | * | 471 | * |
471 | * Finds the control instance with the given id, removes it from the | 472 | * Finds the control instance with the given id, removes it from the |
472 | * card list and releases it. | 473 | * card list and releases it. |
473 | * | 474 | * |
474 | * Returns 0 if successful, or a negative error code on failure. | 475 | * Return: 0 if successful, or a negative error code on failure. |
475 | */ | 476 | */ |
476 | int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id) | 477 | int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id) |
477 | { | 478 | { |
@@ -498,8 +499,8 @@ EXPORT_SYMBOL(snd_ctl_remove_id); | |||
498 | * | 499 | * |
499 | * Finds the control instance with the given id, removes it from the | 500 | * Finds the control instance with the given id, removes it from the |
500 | * card list and releases it. | 501 | * card list and releases it. |
501 | * | 502 | * |
502 | * Returns 0 if successful, or a negative error code on failure. | 503 | * Return: 0 if successful, or a negative error code on failure. |
503 | */ | 504 | */ |
504 | static int snd_ctl_remove_user_ctl(struct snd_ctl_file * file, | 505 | static int snd_ctl_remove_user_ctl(struct snd_ctl_file * file, |
505 | struct snd_ctl_elem_id *id) | 506 | struct snd_ctl_elem_id *id) |
@@ -541,7 +542,7 @@ error: | |||
541 | * Finds the control instance with the given id, and activate or | 542 | * Finds the control instance with the given id, and activate or |
542 | * inactivate the control together with notification, if changed. | 543 | * inactivate the control together with notification, if changed. |
543 | * | 544 | * |
544 | * Returns 0 if unchanged, 1 if changed, or a negative error code on failure. | 545 | * Return: 0 if unchanged, 1 if changed, or a negative error code on failure. |
545 | */ | 546 | */ |
546 | int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id, | 547 | int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id, |
547 | int active) | 548 | int active) |
@@ -587,7 +588,7 @@ EXPORT_SYMBOL_GPL(snd_ctl_activate_id); | |||
587 | * Finds the control with the old id from the card, and replaces the | 588 | * Finds the control with the old id from the card, and replaces the |
588 | * id with the new one. | 589 | * id with the new one. |
589 | * | 590 | * |
590 | * Returns zero if successful, or a negative error code on failure. | 591 | * Return: Zero if successful, or a negative error code on failure. |
591 | */ | 592 | */ |
592 | int snd_ctl_rename_id(struct snd_card *card, struct snd_ctl_elem_id *src_id, | 593 | int snd_ctl_rename_id(struct snd_card *card, struct snd_ctl_elem_id *src_id, |
593 | struct snd_ctl_elem_id *dst_id) | 594 | struct snd_ctl_elem_id *dst_id) |
@@ -616,10 +617,11 @@ EXPORT_SYMBOL(snd_ctl_rename_id); | |||
616 | * | 617 | * |
617 | * Finds the control instance with the given number-id from the card. | 618 | * Finds the control instance with the given number-id from the card. |
618 | * | 619 | * |
619 | * Returns the pointer of the instance if found, or NULL if not. | ||
620 | * | ||
621 | * The caller must down card->controls_rwsem before calling this function | 620 | * The caller must down card->controls_rwsem before calling this function |
622 | * (if the race condition can happen). | 621 | * (if the race condition can happen). |
622 | * | ||
623 | * Return: The pointer of the instance if found, or %NULL if not. | ||
624 | * | ||
623 | */ | 625 | */ |
624 | struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid) | 626 | struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid) |
625 | { | 627 | { |
@@ -643,10 +645,11 @@ EXPORT_SYMBOL(snd_ctl_find_numid); | |||
643 | * | 645 | * |
644 | * Finds the control instance with the given id from the card. | 646 | * Finds the control instance with the given id from the card. |
645 | * | 647 | * |
646 | * Returns the pointer of the instance if found, or NULL if not. | ||
647 | * | ||
648 | * The caller must down card->controls_rwsem before calling this function | 648 | * The caller must down card->controls_rwsem before calling this function |
649 | * (if the race condition can happen). | 649 | * (if the race condition can happen). |
650 | * | ||
651 | * Return: The pointer of the instance if found, or %NULL if not. | ||
652 | * | ||
650 | */ | 653 | */ |
651 | struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card, | 654 | struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card, |
652 | struct snd_ctl_elem_id *id) | 655 | struct snd_ctl_elem_id *id) |
@@ -1710,6 +1713,8 @@ EXPORT_SYMBOL(snd_ctl_boolean_stereo_info); | |||
1710 | * Sets all required fields in @info to their appropriate values. | 1713 | * Sets all required fields in @info to their appropriate values. |
1711 | * If the control's accessibility is not the default (readable and writable), | 1714 | * If the control's accessibility is not the default (readable and writable), |
1712 | * the caller has to fill @info->access. | 1715 | * the caller has to fill @info->access. |
1716 | * | ||
1717 | * Return: Zero. | ||
1713 | */ | 1718 | */ |
1714 | int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels, | 1719 | int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels, |
1715 | unsigned int items, const char *const names[]) | 1720 | unsigned int items, const char *const names[]) |
diff --git a/sound/core/device.c b/sound/core/device.c index f03cb5444a5a..df88defed176 100644 --- a/sound/core/device.c +++ b/sound/core/device.c | |||
@@ -39,7 +39,7 @@ | |||
39 | * The data pointer plays a role as the identifier, too, so the | 39 | * The data pointer plays a role as the identifier, too, so the |
40 | * pointer address must be unique and unchanged. | 40 | * pointer address must be unique and unchanged. |
41 | * | 41 | * |
42 | * Returns zero if successful, or a negative error code on failure. | 42 | * Return: Zero if successful, or a negative error code on failure. |
43 | */ | 43 | */ |
44 | int snd_device_new(struct snd_card *card, snd_device_type_t type, | 44 | int snd_device_new(struct snd_card *card, snd_device_type_t type, |
45 | void *device_data, struct snd_device_ops *ops) | 45 | void *device_data, struct snd_device_ops *ops) |
@@ -73,7 +73,7 @@ EXPORT_SYMBOL(snd_device_new); | |||
73 | * callbacks, dev_disconnect and dev_free, corresponding to the state. | 73 | * callbacks, dev_disconnect and dev_free, corresponding to the state. |
74 | * Then release the device. | 74 | * Then release the device. |
75 | * | 75 | * |
76 | * Returns zero if successful, or a negative error code on failure or if the | 76 | * Return: Zero if successful, or a negative error code on failure or if the |
77 | * device not found. | 77 | * device not found. |
78 | */ | 78 | */ |
79 | int snd_device_free(struct snd_card *card, void *device_data) | 79 | int snd_device_free(struct snd_card *card, void *device_data) |
@@ -116,7 +116,7 @@ EXPORT_SYMBOL(snd_device_free); | |||
116 | * | 116 | * |
117 | * Usually called from snd_card_disconnect(). | 117 | * Usually called from snd_card_disconnect(). |
118 | * | 118 | * |
119 | * Returns zero if successful, or a negative error code on failure or if the | 119 | * Return: Zero if successful, or a negative error code on failure or if the |
120 | * device not found. | 120 | * device not found. |
121 | */ | 121 | */ |
122 | int snd_device_disconnect(struct snd_card *card, void *device_data) | 122 | int snd_device_disconnect(struct snd_card *card, void *device_data) |
@@ -151,7 +151,7 @@ int snd_device_disconnect(struct snd_card *card, void *device_data) | |||
151 | * but it can be called later if any new devices are created after | 151 | * but it can be called later if any new devices are created after |
152 | * invocation of snd_card_register(). | 152 | * invocation of snd_card_register(). |
153 | * | 153 | * |
154 | * Returns zero if successful, or a negative error code on failure or if the | 154 | * Return: Zero if successful, or a negative error code on failure or if the |
155 | * device not found. | 155 | * device not found. |
156 | */ | 156 | */ |
157 | int snd_device_register(struct snd_card *card, void *device_data) | 157 | int snd_device_register(struct snd_card *card, void *device_data) |
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 3f7f6628cf7b..d105073298cb 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c | |||
@@ -356,7 +356,7 @@ static const struct file_operations snd_hwdep_f_ops = | |||
356 | * The callbacks (hwdep->ops) must be set on the returned instance | 356 | * The callbacks (hwdep->ops) must be set on the returned instance |
357 | * after this call manually by the caller. | 357 | * after this call manually by the caller. |
358 | * | 358 | * |
359 | * Returns zero if successful, or a negative error code on failure. | 359 | * Return: Zero if successful, or a negative error code on failure. |
360 | */ | 360 | */ |
361 | int snd_hwdep_new(struct snd_card *card, char *id, int device, | 361 | int snd_hwdep_new(struct snd_card *card, char *id, int device, |
362 | struct snd_hwdep **rhwdep) | 362 | struct snd_hwdep **rhwdep) |
diff --git a/sound/core/info.c b/sound/core/info.c index 5bb97e7d325a..c9042b4d3695 100644 --- a/sound/core/info.c +++ b/sound/core/info.c | |||
@@ -89,7 +89,7 @@ static int resize_info_buffer(struct snd_info_buffer *buffer, | |||
89 | char *nbuf; | 89 | char *nbuf; |
90 | 90 | ||
91 | nsize = PAGE_ALIGN(nsize); | 91 | nsize = PAGE_ALIGN(nsize); |
92 | nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL); | 92 | nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL | __GFP_ZERO); |
93 | if (! nbuf) | 93 | if (! nbuf) |
94 | return -ENOMEM; | 94 | return -ENOMEM; |
95 | 95 | ||
@@ -105,7 +105,7 @@ static int resize_info_buffer(struct snd_info_buffer *buffer, | |||
105 | * | 105 | * |
106 | * Outputs the string on the procfs buffer just like printf(). | 106 | * Outputs the string on the procfs buffer just like printf(). |
107 | * | 107 | * |
108 | * Returns the size of output string. | 108 | * Return: The size of output string, or a negative error code. |
109 | */ | 109 | */ |
110 | int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...) | 110 | int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...) |
111 | { | 111 | { |
@@ -353,7 +353,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) | |||
353 | goto __nomem; | 353 | goto __nomem; |
354 | data->rbuffer = buffer; | 354 | data->rbuffer = buffer; |
355 | buffer->len = PAGE_SIZE; | 355 | buffer->len = PAGE_SIZE; |
356 | buffer->buffer = kmalloc(buffer->len, GFP_KERNEL); | 356 | buffer->buffer = kzalloc(buffer->len, GFP_KERNEL); |
357 | if (buffer->buffer == NULL) | 357 | if (buffer->buffer == NULL) |
358 | goto __nomem; | 358 | goto __nomem; |
359 | } | 359 | } |
@@ -694,32 +694,27 @@ int snd_info_card_free(struct snd_card *card) | |||
694 | * | 694 | * |
695 | * Reads one line from the buffer and stores the string. | 695 | * Reads one line from the buffer and stores the string. |
696 | * | 696 | * |
697 | * Returns zero if successful, or 1 if error or EOF. | 697 | * Return: Zero if successful, or 1 if error or EOF. |
698 | */ | 698 | */ |
699 | int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) | 699 | int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) |
700 | { | 700 | { |
701 | int c = -1; | 701 | int c = -1; |
702 | 702 | ||
703 | if (snd_BUG_ON(!buffer || !buffer->buffer)) | ||
704 | return 1; | ||
703 | if (len <= 0 || buffer->stop || buffer->error) | 705 | if (len <= 0 || buffer->stop || buffer->error) |
704 | return 1; | 706 | return 1; |
705 | while (--len > 0) { | 707 | while (!buffer->stop) { |
706 | c = buffer->buffer[buffer->curr++]; | 708 | c = buffer->buffer[buffer->curr++]; |
707 | if (c == '\n') { | 709 | if (buffer->curr >= buffer->size) |
708 | if (buffer->curr >= buffer->size) | ||
709 | buffer->stop = 1; | ||
710 | break; | ||
711 | } | ||
712 | *line++ = c; | ||
713 | if (buffer->curr >= buffer->size) { | ||
714 | buffer->stop = 1; | 710 | buffer->stop = 1; |
711 | if (c == '\n') | ||
715 | break; | 712 | break; |
713 | if (len) { | ||
714 | len--; | ||
715 | *line++ = c; | ||
716 | } | 716 | } |
717 | } | 717 | } |
718 | while (c != '\n' && !buffer->stop) { | ||
719 | c = buffer->buffer[buffer->curr++]; | ||
720 | if (buffer->curr >= buffer->size) | ||
721 | buffer->stop = 1; | ||
722 | } | ||
723 | *line = '\0'; | 718 | *line = '\0'; |
724 | return 0; | 719 | return 0; |
725 | } | 720 | } |
@@ -735,7 +730,7 @@ EXPORT_SYMBOL(snd_info_get_line); | |||
735 | * Parses the original string and copy a token to the given | 730 | * Parses the original string and copy a token to the given |
736 | * string buffer. | 731 | * string buffer. |
737 | * | 732 | * |
738 | * Returns the updated pointer of the original string so that | 733 | * Return: The updated pointer of the original string so that |
739 | * it can be used for the next call. | 734 | * it can be used for the next call. |
740 | */ | 735 | */ |
741 | const char *snd_info_get_str(char *dest, const char *src, int len) | 736 | const char *snd_info_get_str(char *dest, const char *src, int len) |
@@ -774,7 +769,7 @@ EXPORT_SYMBOL(snd_info_get_str); | |||
774 | * Usually called from other functions such as | 769 | * Usually called from other functions such as |
775 | * snd_info_create_card_entry(). | 770 | * snd_info_create_card_entry(). |
776 | * | 771 | * |
777 | * Returns the pointer of the new instance, or NULL on failure. | 772 | * Return: The pointer of the new instance, or %NULL on failure. |
778 | */ | 773 | */ |
779 | static struct snd_info_entry *snd_info_create_entry(const char *name) | 774 | static struct snd_info_entry *snd_info_create_entry(const char *name) |
780 | { | 775 | { |
@@ -803,7 +798,7 @@ static struct snd_info_entry *snd_info_create_entry(const char *name) | |||
803 | * | 798 | * |
804 | * Creates a new info entry and assigns it to the given module. | 799 | * Creates a new info entry and assigns it to the given module. |
805 | * | 800 | * |
806 | * Returns the pointer of the new instance, or NULL on failure. | 801 | * Return: The pointer of the new instance, or %NULL on failure. |
807 | */ | 802 | */ |
808 | struct snd_info_entry *snd_info_create_module_entry(struct module * module, | 803 | struct snd_info_entry *snd_info_create_module_entry(struct module * module, |
809 | const char *name, | 804 | const char *name, |
@@ -827,7 +822,7 @@ EXPORT_SYMBOL(snd_info_create_module_entry); | |||
827 | * | 822 | * |
828 | * Creates a new info entry and assigns it to the given card. | 823 | * Creates a new info entry and assigns it to the given card. |
829 | * | 824 | * |
830 | * Returns the pointer of the new instance, or NULL on failure. | 825 | * Return: The pointer of the new instance, or %NULL on failure. |
831 | */ | 826 | */ |
832 | struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, | 827 | struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, |
833 | const char *name, | 828 | const char *name, |
@@ -893,7 +888,7 @@ static int snd_info_dev_register_entry(struct snd_device *device) | |||
893 | * For releasing this entry, use snd_device_free() instead of | 888 | * For releasing this entry, use snd_device_free() instead of |
894 | * snd_info_free_entry(). | 889 | * snd_info_free_entry(). |
895 | * | 890 | * |
896 | * Returns zero if successful, or a negative error code on failure. | 891 | * Return: Zero if successful, or a negative error code on failure. |
897 | */ | 892 | */ |
898 | int snd_card_proc_new(struct snd_card *card, const char *name, | 893 | int snd_card_proc_new(struct snd_card *card, const char *name, |
899 | struct snd_info_entry **entryp) | 894 | struct snd_info_entry **entryp) |
@@ -949,7 +944,7 @@ EXPORT_SYMBOL(snd_info_free_entry); | |||
949 | * | 944 | * |
950 | * Registers the proc info entry. | 945 | * Registers the proc info entry. |
951 | * | 946 | * |
952 | * Returns zero if successful, or a negative error code on failure. | 947 | * Return: Zero if successful, or a negative error code on failure. |
953 | */ | 948 | */ |
954 | int snd_info_register(struct snd_info_entry * entry) | 949 | int snd_info_register(struct snd_info_entry * entry) |
955 | { | 950 | { |
diff --git a/sound/core/init.c b/sound/core/init.c index 7b012d15c2cf..6ef06400dfc8 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -144,7 +144,7 @@ static inline int init_info_for_card(struct snd_card *card) | |||
144 | * space for the driver to use freely. The allocated struct is stored | 144 | * space for the driver to use freely. The allocated struct is stored |
145 | * in the given card_ret pointer. | 145 | * in the given card_ret pointer. |
146 | * | 146 | * |
147 | * Returns zero if successful or a negative error code. | 147 | * Return: Zero if successful or a negative error code. |
148 | */ | 148 | */ |
149 | int snd_card_create(int idx, const char *xid, | 149 | int snd_card_create(int idx, const char *xid, |
150 | struct module *module, int extra_size, | 150 | struct module *module, int extra_size, |
@@ -337,7 +337,7 @@ static const struct file_operations snd_shutdown_f_ops = | |||
337 | * | 337 | * |
338 | * Disconnects all APIs from the file-operations (user space). | 338 | * Disconnects all APIs from the file-operations (user space). |
339 | * | 339 | * |
340 | * Returns zero, otherwise a negative error code. | 340 | * Return: Zero, otherwise a negative error code. |
341 | * | 341 | * |
342 | * Note: The current implementation replaces all active file->f_op with special | 342 | * Note: The current implementation replaces all active file->f_op with special |
343 | * dummy file operations (they do nothing except release). | 343 | * dummy file operations (they do nothing except release). |
@@ -415,7 +415,7 @@ EXPORT_SYMBOL(snd_card_disconnect); | |||
415 | * devices automatically. That is, you don't have to release the devices | 415 | * devices automatically. That is, you don't have to release the devices |
416 | * by yourself. | 416 | * by yourself. |
417 | * | 417 | * |
418 | * Returns zero. Frees all associated devices and frees the control | 418 | * Return: Zero. Frees all associated devices and frees the control |
419 | * interface associated to given soundcard. | 419 | * interface associated to given soundcard. |
420 | */ | 420 | */ |
421 | static int snd_card_do_free(struct snd_card *card) | 421 | static int snd_card_do_free(struct snd_card *card) |
@@ -677,7 +677,7 @@ static struct device_attribute card_number_attrs = | |||
677 | * external accesses. Thus, you should call this function at the end | 677 | * external accesses. Thus, you should call this function at the end |
678 | * of the initialization of the card. | 678 | * of the initialization of the card. |
679 | * | 679 | * |
680 | * Returns zero otherwise a negative error code if the registration failed. | 680 | * Return: Zero otherwise a negative error code if the registration failed. |
681 | */ | 681 | */ |
682 | int snd_card_register(struct snd_card *card) | 682 | int snd_card_register(struct snd_card *card) |
683 | { | 683 | { |
@@ -849,7 +849,7 @@ int __exit snd_card_info_done(void) | |||
849 | * This function adds the component id string to the supported list. | 849 | * This function adds the component id string to the supported list. |
850 | * The component can be referred from the alsa-lib. | 850 | * The component can be referred from the alsa-lib. |
851 | * | 851 | * |
852 | * Returns zero otherwise a negative error code. | 852 | * Return: Zero otherwise a negative error code. |
853 | */ | 853 | */ |
854 | 854 | ||
855 | int snd_component_add(struct snd_card *card, const char *component) | 855 | int snd_component_add(struct snd_card *card, const char *component) |
@@ -883,7 +883,7 @@ EXPORT_SYMBOL(snd_component_add); | |||
883 | * This linked-list is used to keep tracking the connection state, | 883 | * This linked-list is used to keep tracking the connection state, |
884 | * and to avoid the release of busy resources by hotplug. | 884 | * and to avoid the release of busy resources by hotplug. |
885 | * | 885 | * |
886 | * Returns zero or a negative error code. | 886 | * Return: zero or a negative error code. |
887 | */ | 887 | */ |
888 | int snd_card_file_add(struct snd_card *card, struct file *file) | 888 | int snd_card_file_add(struct snd_card *card, struct file *file) |
889 | { | 889 | { |
@@ -920,7 +920,7 @@ EXPORT_SYMBOL(snd_card_file_add); | |||
920 | * called beforehand, it processes the pending release of | 920 | * called beforehand, it processes the pending release of |
921 | * resources. | 921 | * resources. |
922 | * | 922 | * |
923 | * Returns zero or a negative error code. | 923 | * Return: Zero or a negative error code. |
924 | */ | 924 | */ |
925 | int snd_card_file_remove(struct snd_card *card, struct file *file) | 925 | int snd_card_file_remove(struct snd_card *card, struct file *file) |
926 | { | 926 | { |
@@ -959,6 +959,8 @@ EXPORT_SYMBOL(snd_card_file_remove); | |||
959 | * | 959 | * |
960 | * Waits until the power-state is changed. | 960 | * Waits until the power-state is changed. |
961 | * | 961 | * |
962 | * Return: Zero if successful, or a negative error code. | ||
963 | * | ||
962 | * Note: the power lock must be active before call. | 964 | * Note: the power lock must be active before call. |
963 | */ | 965 | */ |
964 | int snd_power_wait(struct snd_card *card, unsigned int power_state) | 966 | int snd_power_wait(struct snd_card *card, unsigned int power_state) |
diff --git a/sound/core/isadma.c b/sound/core/isadma.c index c0f1208bb7df..e2b386156a4c 100644 --- a/sound/core/isadma.c +++ b/sound/core/isadma.c | |||
@@ -81,7 +81,7 @@ EXPORT_SYMBOL(snd_dma_disable); | |||
81 | * @dma: the dma number | 81 | * @dma: the dma number |
82 | * @size: the dma transfer size | 82 | * @size: the dma transfer size |
83 | * | 83 | * |
84 | * Returns the current pointer in DMA tranfer buffer in bytes | 84 | * Return: The current pointer in DMA transfer buffer in bytes. |
85 | */ | 85 | */ |
86 | unsigned int snd_dma_pointer(unsigned long dma, unsigned int size) | 86 | unsigned int snd_dma_pointer(unsigned long dma, unsigned int size) |
87 | { | 87 | { |
diff --git a/sound/core/jack.c b/sound/core/jack.c index a06b1651fcba..b35fe7345c20 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c | |||
@@ -98,8 +98,8 @@ static int snd_jack_dev_register(struct snd_device *device) | |||
98 | * | 98 | * |
99 | * Creates a new jack object. | 99 | * Creates a new jack object. |
100 | * | 100 | * |
101 | * Returns zero if successful, or a negative error code on failure. | 101 | * Return: Zero if successful, or a negative error code on failure. |
102 | * On success jjack will be initialised. | 102 | * On success @jjack will be initialised. |
103 | */ | 103 | */ |
104 | int snd_jack_new(struct snd_card *card, const char *id, int type, | 104 | int snd_jack_new(struct snd_card *card, const char *id, int type, |
105 | struct snd_jack **jjack) | 105 | struct snd_jack **jjack) |
@@ -189,6 +189,8 @@ EXPORT_SYMBOL(snd_jack_set_parent); | |||
189 | * using this abstraction. | 189 | * using this abstraction. |
190 | * | 190 | * |
191 | * This function may only be called prior to registration of the jack. | 191 | * This function may only be called prior to registration of the jack. |
192 | * | ||
193 | * Return: Zero if successful, or a negative error code on failure. | ||
192 | */ | 194 | */ |
193 | int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type, | 195 | int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type, |
194 | int keytype) | 196 | int keytype) |
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 691569238435..bdf826f4fe0c 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c | |||
@@ -81,7 +81,7 @@ static inline void dec_snd_pages(int order) | |||
81 | * | 81 | * |
82 | * Allocates the physically contiguous pages with the given size. | 82 | * Allocates the physically contiguous pages with the given size. |
83 | * | 83 | * |
84 | * Returns the pointer of the buffer, or NULL if no enoguh memory. | 84 | * Return: The pointer of the buffer, or %NULL if no enough memory. |
85 | */ | 85 | */ |
86 | void *snd_malloc_pages(size_t size, gfp_t gfp_flags) | 86 | void *snd_malloc_pages(size_t size, gfp_t gfp_flags) |
87 | { | 87 | { |
@@ -175,9 +175,9 @@ static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr, | |||
175 | * | 175 | * |
176 | * Calls the memory-allocator function for the corresponding | 176 | * Calls the memory-allocator function for the corresponding |
177 | * buffer type. | 177 | * buffer type. |
178 | * | 178 | * |
179 | * Returns zero if the buffer with the given size is allocated successfully, | 179 | * Return: Zero if the buffer with the given size is allocated successfully, |
180 | * other a negative value at error. | 180 | * otherwise a negative value on error. |
181 | */ | 181 | */ |
182 | int snd_dma_alloc_pages(int type, struct device *device, size_t size, | 182 | int snd_dma_alloc_pages(int type, struct device *device, size_t size, |
183 | struct snd_dma_buffer *dmab) | 183 | struct snd_dma_buffer *dmab) |
@@ -229,9 +229,9 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size, | |||
229 | * buffer type. When no space is left, this function reduces the size and | 229 | * buffer type. When no space is left, this function reduces the size and |
230 | * tries to allocate again. The size actually allocated is stored in | 230 | * tries to allocate again. The size actually allocated is stored in |
231 | * res_size argument. | 231 | * res_size argument. |
232 | * | 232 | * |
233 | * Returns zero if the buffer with the given size is allocated successfully, | 233 | * Return: Zero if the buffer with the given size is allocated successfully, |
234 | * other a negative value at error. | 234 | * otherwise a negative value on error. |
235 | */ | 235 | */ |
236 | int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size, | 236 | int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size, |
237 | struct snd_dma_buffer *dmab) | 237 | struct snd_dma_buffer *dmab) |
@@ -292,7 +292,7 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab) | |||
292 | * Looks for the reserved-buffer list and re-uses if the same buffer | 292 | * Looks for the reserved-buffer list and re-uses if the same buffer |
293 | * is found in the list. When the buffer is found, it's removed from the free list. | 293 | * is found in the list. When the buffer is found, it's removed from the free list. |
294 | * | 294 | * |
295 | * Returns the size of buffer if the buffer is found, or zero if not found. | 295 | * Return: The size of buffer if the buffer is found, or zero if not found. |
296 | */ | 296 | */ |
297 | size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) | 297 | size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) |
298 | { | 298 | { |
@@ -326,8 +326,8 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) | |||
326 | * @id: the buffer id | 326 | * @id: the buffer id |
327 | * | 327 | * |
328 | * Reserves the given buffer as a reserved buffer. | 328 | * Reserves the given buffer as a reserved buffer. |
329 | * | 329 | * |
330 | * Returns zero if successful, or a negative code at error. | 330 | * Return: Zero if successful, or a negative code on error. |
331 | */ | 331 | */ |
332 | int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id) | 332 | int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id) |
333 | { | 333 | { |
diff --git a/sound/core/memory.c b/sound/core/memory.c index 66a278d0b04e..36c0f1a2e189 100644 --- a/sound/core/memory.c +++ b/sound/core/memory.c | |||
@@ -33,7 +33,7 @@ | |||
33 | * | 33 | * |
34 | * Copies the data from mmio-space to user-space. | 34 | * Copies the data from mmio-space to user-space. |
35 | * | 35 | * |
36 | * Returns zero if successful, or non-zero on failure. | 36 | * Return: Zero if successful, or non-zero on failure. |
37 | */ | 37 | */ |
38 | int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count) | 38 | int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count) |
39 | { | 39 | { |
@@ -66,7 +66,7 @@ EXPORT_SYMBOL(copy_to_user_fromio); | |||
66 | * | 66 | * |
67 | * Copies the data from user-space to mmio-space. | 67 | * Copies the data from user-space to mmio-space. |
68 | * | 68 | * |
69 | * Returns zero if successful, or non-zero on failure. | 69 | * Return: Zero if successful, or non-zero on failure. |
70 | */ | 70 | */ |
71 | int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count) | 71 | int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count) |
72 | { | 72 | { |
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 61798f85d030..17f45e8aa89c 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -209,6 +209,8 @@ static char *snd_pcm_format_names[] = { | |||
209 | FORMAT(G723_24_1B), | 209 | FORMAT(G723_24_1B), |
210 | FORMAT(G723_40), | 210 | FORMAT(G723_40), |
211 | FORMAT(G723_40_1B), | 211 | FORMAT(G723_40_1B), |
212 | FORMAT(DSD_U8), | ||
213 | FORMAT(DSD_U16_LE), | ||
212 | }; | 214 | }; |
213 | 215 | ||
214 | const char *snd_pcm_format_name(snd_pcm_format_t format) | 216 | const char *snd_pcm_format_name(snd_pcm_format_t format) |
@@ -637,7 +639,7 @@ static inline int snd_pcm_substream_proc_done(struct snd_pcm_substream *substrea | |||
637 | * calling this, i.e. zero must be given to the argument of | 639 | * calling this, i.e. zero must be given to the argument of |
638 | * snd_pcm_new(). | 640 | * snd_pcm_new(). |
639 | * | 641 | * |
640 | * Returns zero if successful, or a negative error code on failure. | 642 | * Return: Zero if successful, or a negative error code on failure. |
641 | */ | 643 | */ |
642 | int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) | 644 | int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) |
643 | { | 645 | { |
@@ -759,7 +761,7 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device, | |||
759 | * The pcm operators have to be set afterwards to the new instance | 761 | * The pcm operators have to be set afterwards to the new instance |
760 | * via snd_pcm_set_ops(). | 762 | * via snd_pcm_set_ops(). |
761 | * | 763 | * |
762 | * Returns zero if successful, or a negative error code on failure. | 764 | * Return: Zero if successful, or a negative error code on failure. |
763 | */ | 765 | */ |
764 | int snd_pcm_new(struct snd_card *card, const char *id, int device, | 766 | int snd_pcm_new(struct snd_card *card, const char *id, int device, |
765 | int playback_count, int capture_count, struct snd_pcm **rpcm) | 767 | int playback_count, int capture_count, struct snd_pcm **rpcm) |
@@ -787,7 +789,7 @@ EXPORT_SYMBOL(snd_pcm_new); | |||
787 | * The pcm operators have to be set afterwards to the new instance | 789 | * The pcm operators have to be set afterwards to the new instance |
788 | * via snd_pcm_set_ops(). | 790 | * via snd_pcm_set_ops(). |
789 | * | 791 | * |
790 | * Returns zero if successful, or a negative error code on failure. | 792 | * Return: Zero if successful, or a negative error code on failure. |
791 | */ | 793 | */ |
792 | int snd_pcm_new_internal(struct snd_card *card, const char *id, int device, | 794 | int snd_pcm_new_internal(struct snd_card *card, const char *id, int device, |
793 | int playback_count, int capture_count, | 795 | int playback_count, int capture_count, |
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index c4840ff75d00..41b3dfe68698 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -666,7 +666,8 @@ static inline unsigned int muldiv32(unsigned int a, unsigned int b, | |||
666 | * The interval is changed to the range satisfying both intervals. | 666 | * The interval is changed to the range satisfying both intervals. |
667 | * The interval status (min, max, integer, etc.) are evaluated. | 667 | * The interval status (min, max, integer, etc.) are evaluated. |
668 | * | 668 | * |
669 | * Returns non-zero if the value is changed, zero if not changed. | 669 | * Return: Positive if the value is changed, zero if it's not changed, or a |
670 | * negative error code. | ||
670 | */ | 671 | */ |
671 | int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v) | 672 | int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v) |
672 | { | 673 | { |
@@ -865,7 +866,8 @@ void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k, | |||
865 | * @nump: pointer to store the resultant numerator | 866 | * @nump: pointer to store the resultant numerator |
866 | * @denp: pointer to store the resultant denominator | 867 | * @denp: pointer to store the resultant denominator |
867 | * | 868 | * |
868 | * Returns non-zero if the value is changed, zero if not changed. | 869 | * Return: Positive if the value is changed, zero if it's not changed, or a |
870 | * negative error code. | ||
869 | */ | 871 | */ |
870 | int snd_interval_ratnum(struct snd_interval *i, | 872 | int snd_interval_ratnum(struct snd_interval *i, |
871 | unsigned int rats_count, struct snd_ratnum *rats, | 873 | unsigned int rats_count, struct snd_ratnum *rats, |
@@ -983,7 +985,8 @@ EXPORT_SYMBOL(snd_interval_ratnum); | |||
983 | * @nump: pointer to store the resultant numerator | 985 | * @nump: pointer to store the resultant numerator |
984 | * @denp: pointer to store the resultant denominator | 986 | * @denp: pointer to store the resultant denominator |
985 | * | 987 | * |
986 | * Returns non-zero if the value is changed, zero if not changed. | 988 | * Return: Positive if the value is changed, zero if it's not changed, or a |
989 | * negative error code. | ||
987 | */ | 990 | */ |
988 | static int snd_interval_ratden(struct snd_interval *i, | 991 | static int snd_interval_ratden(struct snd_interval *i, |
989 | unsigned int rats_count, struct snd_ratden *rats, | 992 | unsigned int rats_count, struct snd_ratden *rats, |
@@ -1082,7 +1085,8 @@ static int snd_interval_ratden(struct snd_interval *i, | |||
1082 | * When mask is non-zero, only the elements corresponding to bit 1 are | 1085 | * When mask is non-zero, only the elements corresponding to bit 1 are |
1083 | * evaluated. | 1086 | * evaluated. |
1084 | * | 1087 | * |
1085 | * Returns non-zero if the value is changed, zero if not changed. | 1088 | * Return: Positive if the value is changed, zero if it's not changed, or a |
1089 | * negative error code. | ||
1086 | */ | 1090 | */ |
1087 | int snd_interval_list(struct snd_interval *i, unsigned int count, | 1091 | int snd_interval_list(struct snd_interval *i, unsigned int count, |
1088 | const unsigned int *list, unsigned int mask) | 1092 | const unsigned int *list, unsigned int mask) |
@@ -1142,7 +1146,7 @@ static int snd_interval_step(struct snd_interval *i, unsigned int min, unsigned | |||
1142 | * @private: the private data pointer passed to function | 1146 | * @private: the private data pointer passed to function |
1143 | * @dep: the dependent variables | 1147 | * @dep: the dependent variables |
1144 | * | 1148 | * |
1145 | * Returns zero if successful, or a negative error code on failure. | 1149 | * Return: Zero if successful, or a negative error code on failure. |
1146 | */ | 1150 | */ |
1147 | int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, | 1151 | int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, |
1148 | int var, | 1152 | int var, |
@@ -1200,6 +1204,8 @@ EXPORT_SYMBOL(snd_pcm_hw_rule_add); | |||
1200 | * @mask: the bitmap mask | 1204 | * @mask: the bitmap mask |
1201 | * | 1205 | * |
1202 | * Apply the constraint of the given bitmap mask to a 32-bit mask parameter. | 1206 | * Apply the constraint of the given bitmap mask to a 32-bit mask parameter. |
1207 | * | ||
1208 | * Return: Zero if successful, or a negative error code on failure. | ||
1203 | */ | 1209 | */ |
1204 | int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, | 1210 | int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, |
1205 | u_int32_t mask) | 1211 | u_int32_t mask) |
@@ -1220,6 +1226,8 @@ int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param | |||
1220 | * @mask: the 64bit bitmap mask | 1226 | * @mask: the 64bit bitmap mask |
1221 | * | 1227 | * |
1222 | * Apply the constraint of the given bitmap mask to a 64-bit mask parameter. | 1228 | * Apply the constraint of the given bitmap mask to a 64-bit mask parameter. |
1229 | * | ||
1230 | * Return: Zero if successful, or a negative error code on failure. | ||
1223 | */ | 1231 | */ |
1224 | int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, | 1232 | int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, |
1225 | u_int64_t mask) | 1233 | u_int64_t mask) |
@@ -1240,6 +1248,9 @@ int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_par | |||
1240 | * @var: hw_params variable to apply the integer constraint | 1248 | * @var: hw_params variable to apply the integer constraint |
1241 | * | 1249 | * |
1242 | * Apply the constraint of integer to an interval parameter. | 1250 | * Apply the constraint of integer to an interval parameter. |
1251 | * | ||
1252 | * Return: Positive if the value is changed, zero if it's not changed, or a | ||
1253 | * negative error code. | ||
1243 | */ | 1254 | */ |
1244 | int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var) | 1255 | int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var) |
1245 | { | 1256 | { |
@@ -1257,6 +1268,9 @@ EXPORT_SYMBOL(snd_pcm_hw_constraint_integer); | |||
1257 | * @max: the maximal value | 1268 | * @max: the maximal value |
1258 | * | 1269 | * |
1259 | * Apply the min/max range constraint to an interval parameter. | 1270 | * Apply the min/max range constraint to an interval parameter. |
1271 | * | ||
1272 | * Return: Positive if the value is changed, zero if it's not changed, or a | ||
1273 | * negative error code. | ||
1260 | */ | 1274 | */ |
1261 | int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, | 1275 | int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, |
1262 | unsigned int min, unsigned int max) | 1276 | unsigned int min, unsigned int max) |
@@ -1288,6 +1302,8 @@ static int snd_pcm_hw_rule_list(struct snd_pcm_hw_params *params, | |||
1288 | * @l: list | 1302 | * @l: list |
1289 | * | 1303 | * |
1290 | * Apply the list of constraints to an interval parameter. | 1304 | * Apply the list of constraints to an interval parameter. |
1305 | * | ||
1306 | * Return: Zero if successful, or a negative error code on failure. | ||
1291 | */ | 1307 | */ |
1292 | int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, | 1308 | int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, |
1293 | unsigned int cond, | 1309 | unsigned int cond, |
@@ -1322,6 +1338,8 @@ static int snd_pcm_hw_rule_ratnums(struct snd_pcm_hw_params *params, | |||
1322 | * @cond: condition bits | 1338 | * @cond: condition bits |
1323 | * @var: hw_params variable to apply the ratnums constraint | 1339 | * @var: hw_params variable to apply the ratnums constraint |
1324 | * @r: struct snd_ratnums constriants | 1340 | * @r: struct snd_ratnums constriants |
1341 | * | ||
1342 | * Return: Zero if successful, or a negative error code on failure. | ||
1325 | */ | 1343 | */ |
1326 | int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, | 1344 | int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, |
1327 | unsigned int cond, | 1345 | unsigned int cond, |
@@ -1355,6 +1373,8 @@ static int snd_pcm_hw_rule_ratdens(struct snd_pcm_hw_params *params, | |||
1355 | * @cond: condition bits | 1373 | * @cond: condition bits |
1356 | * @var: hw_params variable to apply the ratdens constraint | 1374 | * @var: hw_params variable to apply the ratdens constraint |
1357 | * @r: struct snd_ratdens constriants | 1375 | * @r: struct snd_ratdens constriants |
1376 | * | ||
1377 | * Return: Zero if successful, or a negative error code on failure. | ||
1358 | */ | 1378 | */ |
1359 | int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, | 1379 | int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, |
1360 | unsigned int cond, | 1380 | unsigned int cond, |
@@ -1386,6 +1406,8 @@ static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params, | |||
1386 | * @cond: condition bits | 1406 | * @cond: condition bits |
1387 | * @width: sample bits width | 1407 | * @width: sample bits width |
1388 | * @msbits: msbits width | 1408 | * @msbits: msbits width |
1409 | * | ||
1410 | * Return: Zero if successful, or a negative error code on failure. | ||
1389 | */ | 1411 | */ |
1390 | int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, | 1412 | int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, |
1391 | unsigned int cond, | 1413 | unsigned int cond, |
@@ -1414,6 +1436,8 @@ static int snd_pcm_hw_rule_step(struct snd_pcm_hw_params *params, | |||
1414 | * @cond: condition bits | 1436 | * @cond: condition bits |
1415 | * @var: hw_params variable to apply the step constraint | 1437 | * @var: hw_params variable to apply the step constraint |
1416 | * @step: step size | 1438 | * @step: step size |
1439 | * | ||
1440 | * Return: Zero if successful, or a negative error code on failure. | ||
1417 | */ | 1441 | */ |
1418 | int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime, | 1442 | int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime, |
1419 | unsigned int cond, | 1443 | unsigned int cond, |
@@ -1444,6 +1468,8 @@ static int snd_pcm_hw_rule_pow2(struct snd_pcm_hw_params *params, struct snd_pcm | |||
1444 | * @runtime: PCM runtime instance | 1468 | * @runtime: PCM runtime instance |
1445 | * @cond: condition bits | 1469 | * @cond: condition bits |
1446 | * @var: hw_params variable to apply the power-of-2 constraint | 1470 | * @var: hw_params variable to apply the power-of-2 constraint |
1471 | * | ||
1472 | * Return: Zero if successful, or a negative error code on failure. | ||
1447 | */ | 1473 | */ |
1448 | int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime, | 1474 | int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime, |
1449 | unsigned int cond, | 1475 | unsigned int cond, |
@@ -1470,6 +1496,8 @@ static int snd_pcm_hw_rule_noresample_func(struct snd_pcm_hw_params *params, | |||
1470 | * snd_pcm_hw_rule_noresample - add a rule to allow disabling hw resampling | 1496 | * snd_pcm_hw_rule_noresample - add a rule to allow disabling hw resampling |
1471 | * @runtime: PCM runtime instance | 1497 | * @runtime: PCM runtime instance |
1472 | * @base_rate: the rate at which the hardware does not resample | 1498 | * @base_rate: the rate at which the hardware does not resample |
1499 | * | ||
1500 | * Return: Zero if successful, or a negative error code on failure. | ||
1473 | */ | 1501 | */ |
1474 | int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime, | 1502 | int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime, |
1475 | unsigned int base_rate) | 1503 | unsigned int base_rate) |
@@ -1519,8 +1547,8 @@ EXPORT_SYMBOL(_snd_pcm_hw_params_any); | |||
1519 | * @var: parameter to retrieve | 1547 | * @var: parameter to retrieve |
1520 | * @dir: pointer to the direction (-1,0,1) or %NULL | 1548 | * @dir: pointer to the direction (-1,0,1) or %NULL |
1521 | * | 1549 | * |
1522 | * Return the value for field @var if it's fixed in configuration space | 1550 | * Return: The value for field @var if it's fixed in configuration space |
1523 | * defined by @params. Return -%EINVAL otherwise. | 1551 | * defined by @params. -%EINVAL otherwise. |
1524 | */ | 1552 | */ |
1525 | int snd_pcm_hw_param_value(const struct snd_pcm_hw_params *params, | 1553 | int snd_pcm_hw_param_value(const struct snd_pcm_hw_params *params, |
1526 | snd_pcm_hw_param_t var, int *dir) | 1554 | snd_pcm_hw_param_t var, int *dir) |
@@ -1591,7 +1619,8 @@ static int _snd_pcm_hw_param_first(struct snd_pcm_hw_params *params, | |||
1591 | * | 1619 | * |
1592 | * Inside configuration space defined by @params remove from @var all | 1620 | * Inside configuration space defined by @params remove from @var all |
1593 | * values > minimum. Reduce configuration space accordingly. | 1621 | * values > minimum. Reduce configuration space accordingly. |
1594 | * Return the minimum. | 1622 | * |
1623 | * Return: The minimum, or a negative error code on failure. | ||
1595 | */ | 1624 | */ |
1596 | int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm, | 1625 | int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm, |
1597 | struct snd_pcm_hw_params *params, | 1626 | struct snd_pcm_hw_params *params, |
@@ -1637,7 +1666,8 @@ static int _snd_pcm_hw_param_last(struct snd_pcm_hw_params *params, | |||
1637 | * | 1666 | * |
1638 | * Inside configuration space defined by @params remove from @var all | 1667 | * Inside configuration space defined by @params remove from @var all |
1639 | * values < maximum. Reduce configuration space accordingly. | 1668 | * values < maximum. Reduce configuration space accordingly. |
1640 | * Return the maximum. | 1669 | * |
1670 | * Return: The maximum, or a negative error code on failure. | ||
1641 | */ | 1671 | */ |
1642 | int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm, | 1672 | int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm, |
1643 | struct snd_pcm_hw_params *params, | 1673 | struct snd_pcm_hw_params *params, |
@@ -1665,6 +1695,8 @@ EXPORT_SYMBOL(snd_pcm_hw_param_last); | |||
1665 | * The configuration chosen is that obtained fixing in this order: | 1695 | * The configuration chosen is that obtained fixing in this order: |
1666 | * first access, first format, first subformat, min channels, | 1696 | * first access, first format, first subformat, min channels, |
1667 | * min rate, min period time, max buffer size, min tick time | 1697 | * min rate, min period time, max buffer size, min tick time |
1698 | * | ||
1699 | * Return: Zero if successful, or a negative error code on failure. | ||
1668 | */ | 1700 | */ |
1669 | int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm, | 1701 | int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm, |
1670 | struct snd_pcm_hw_params *params) | 1702 | struct snd_pcm_hw_params *params) |
@@ -1771,7 +1803,7 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream, | |||
1771 | * Processes the generic ioctl commands for PCM. | 1803 | * Processes the generic ioctl commands for PCM. |
1772 | * Can be passed as the ioctl callback for PCM ops. | 1804 | * Can be passed as the ioctl callback for PCM ops. |
1773 | * | 1805 | * |
1774 | * Returns zero if successful, or a negative error code on failure. | 1806 | * Return: Zero if successful, or a negative error code on failure. |
1775 | */ | 1807 | */ |
1776 | int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, | 1808 | int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, |
1777 | unsigned int cmd, void *arg) | 1809 | unsigned int cmd, void *arg) |
@@ -2510,7 +2542,7 @@ static void pcm_chmap_ctl_private_free(struct snd_kcontrol *kcontrol) | |||
2510 | * @info_ret: store struct snd_pcm_chmap instance if non-NULL | 2542 | * @info_ret: store struct snd_pcm_chmap instance if non-NULL |
2511 | * | 2543 | * |
2512 | * Create channel-mapping control elements assigned to the given PCM stream(s). | 2544 | * Create channel-mapping control elements assigned to the given PCM stream(s). |
2513 | * Returns zero if succeed, or a negative error value. | 2545 | * Return: Zero if successful, or a negative error value. |
2514 | */ | 2546 | */ |
2515 | int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, | 2547 | int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, |
2516 | const struct snd_pcm_chmap_elem *chmap, | 2548 | const struct snd_pcm_chmap_elem *chmap, |
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index 69e01c4fc32d..0af622c34e19 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c | |||
@@ -95,7 +95,7 @@ static void snd_pcm_lib_preallocate_dma_free(struct snd_pcm_substream *substream | |||
95 | * | 95 | * |
96 | * Releases the pre-allocated buffer of the given substream. | 96 | * Releases the pre-allocated buffer of the given substream. |
97 | * | 97 | * |
98 | * Returns zero if successful, or a negative error code on failure. | 98 | * Return: Zero if successful, or a negative error code on failure. |
99 | */ | 99 | */ |
100 | int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) | 100 | int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) |
101 | { | 101 | { |
@@ -115,7 +115,7 @@ int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) | |||
115 | * | 115 | * |
116 | * Releases all the pre-allocated buffers on the given pcm. | 116 | * Releases all the pre-allocated buffers on the given pcm. |
117 | * | 117 | * |
118 | * Returns zero if successful, or a negative error code on failure. | 118 | * Return: Zero if successful, or a negative error code on failure. |
119 | */ | 119 | */ |
120 | int snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm) | 120 | int snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm) |
121 | { | 121 | { |
@@ -265,7 +265,7 @@ static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream, | |||
265 | * destruction time. The dma_buf_id must be unique for all systems | 265 | * destruction time. The dma_buf_id must be unique for all systems |
266 | * (in the same DMA buffer type) e.g. using snd_dma_pci_buf_id(). | 266 | * (in the same DMA buffer type) e.g. using snd_dma_pci_buf_id(). |
267 | * | 267 | * |
268 | * Returns zero if successful, or a negative error code on failure. | 268 | * Return: Zero if successful, or a negative error code on failure. |
269 | */ | 269 | */ |
270 | int snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream, | 270 | int snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream, |
271 | int type, struct device *data, | 271 | int type, struct device *data, |
@@ -289,7 +289,7 @@ EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages); | |||
289 | * Do pre-allocation to all substreams of the given pcm for the | 289 | * Do pre-allocation to all substreams of the given pcm for the |
290 | * specified DMA type. | 290 | * specified DMA type. |
291 | * | 291 | * |
292 | * Returns zero if successful, or a negative error code on failure. | 292 | * Return: Zero if successful, or a negative error code on failure. |
293 | */ | 293 | */ |
294 | int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm, | 294 | int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm, |
295 | int type, void *data, | 295 | int type, void *data, |
@@ -313,8 +313,9 @@ EXPORT_SYMBOL(snd_pcm_lib_preallocate_pages_for_all); | |||
313 | * @substream: the pcm substream instance | 313 | * @substream: the pcm substream instance |
314 | * @offset: the buffer offset | 314 | * @offset: the buffer offset |
315 | * | 315 | * |
316 | * Returns the page struct at the given buffer offset. | ||
317 | * Used as the page callback of PCM ops. | 316 | * Used as the page callback of PCM ops. |
317 | * | ||
318 | * Return: The page struct at the given buffer offset. %NULL on failure. | ||
318 | */ | 319 | */ |
319 | struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigned long offset) | 320 | struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigned long offset) |
320 | { | 321 | { |
@@ -337,7 +338,7 @@ EXPORT_SYMBOL(snd_pcm_sgbuf_ops_page); | |||
337 | * Allocates the DMA buffer on the BUS type given earlier to | 338 | * Allocates the DMA buffer on the BUS type given earlier to |
338 | * snd_pcm_lib_preallocate_xxx_pages(). | 339 | * snd_pcm_lib_preallocate_xxx_pages(). |
339 | * | 340 | * |
340 | * Returns 1 if the buffer is changed, 0 if not changed, or a negative | 341 | * Return: 1 if the buffer is changed, 0 if not changed, or a negative |
341 | * code on failure. | 342 | * code on failure. |
342 | */ | 343 | */ |
343 | int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size) | 344 | int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size) |
@@ -390,7 +391,7 @@ EXPORT_SYMBOL(snd_pcm_lib_malloc_pages); | |||
390 | * | 391 | * |
391 | * Releases the DMA buffer allocated via snd_pcm_lib_malloc_pages(). | 392 | * Releases the DMA buffer allocated via snd_pcm_lib_malloc_pages(). |
392 | * | 393 | * |
393 | * Returns zero if successful, or a negative error code on failure. | 394 | * Return: Zero if successful, or a negative error code on failure. |
394 | */ | 395 | */ |
395 | int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) | 396 | int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) |
396 | { | 397 | { |
@@ -437,6 +438,8 @@ EXPORT_SYMBOL(_snd_pcm_lib_alloc_vmalloc_buffer); | |||
437 | * snd_pcm_lib_free_vmalloc_buffer - free vmalloc buffer | 438 | * snd_pcm_lib_free_vmalloc_buffer - free vmalloc buffer |
438 | * @substream: the substream with a buffer allocated by | 439 | * @substream: the substream with a buffer allocated by |
439 | * snd_pcm_lib_alloc_vmalloc_buffer() | 440 | * snd_pcm_lib_alloc_vmalloc_buffer() |
441 | * | ||
442 | * Return: Zero if successful, or a negative error code on failure. | ||
440 | */ | 443 | */ |
441 | int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream) | 444 | int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream) |
442 | { | 445 | { |
@@ -458,6 +461,8 @@ EXPORT_SYMBOL(snd_pcm_lib_free_vmalloc_buffer); | |||
458 | * @offset: offset in the buffer | 461 | * @offset: offset in the buffer |
459 | * | 462 | * |
460 | * This function is to be used as the page callback in the PCM ops. | 463 | * This function is to be used as the page callback in the PCM ops. |
464 | * | ||
465 | * Return: The page struct, or %NULL on failure. | ||
461 | */ | 466 | */ |
462 | struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, | 467 | struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, |
463 | unsigned long offset) | 468 | unsigned long offset) |
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index d4fc1bfbe457..43f24cce3dec 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c | |||
@@ -140,6 +140,14 @@ static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = { | |||
140 | .width = 5, .phys = 5, .le = -1, .signd = -1, | 140 | .width = 5, .phys = 5, .le = -1, .signd = -1, |
141 | .silence = {}, | 141 | .silence = {}, |
142 | }, | 142 | }, |
143 | [SNDRV_PCM_FORMAT_DSD_U8] = { | ||
144 | .width = 8, .phys = 8, .le = 1, .signd = 0, | ||
145 | .silence = {}, | ||
146 | }, | ||
147 | [SNDRV_PCM_FORMAT_DSD_U16_LE] = { | ||
148 | .width = 16, .phys = 16, .le = 1, .signd = 0, | ||
149 | .silence = {}, | ||
150 | }, | ||
143 | /* FIXME: the following three formats are not defined properly yet */ | 151 | /* FIXME: the following three formats are not defined properly yet */ |
144 | [SNDRV_PCM_FORMAT_MPEG] = { | 152 | [SNDRV_PCM_FORMAT_MPEG] = { |
145 | .le = -1, .signd = -1, | 153 | .le = -1, .signd = -1, |
@@ -213,7 +221,7 @@ static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = { | |||
213 | * snd_pcm_format_signed - Check the PCM format is signed linear | 221 | * snd_pcm_format_signed - Check the PCM format is signed linear |
214 | * @format: the format to check | 222 | * @format: the format to check |
215 | * | 223 | * |
216 | * Returns 1 if the given PCM format is signed linear, 0 if unsigned | 224 | * Return: 1 if the given PCM format is signed linear, 0 if unsigned |
217 | * linear, and a negative error code for non-linear formats. | 225 | * linear, and a negative error code for non-linear formats. |
218 | */ | 226 | */ |
219 | int snd_pcm_format_signed(snd_pcm_format_t format) | 227 | int snd_pcm_format_signed(snd_pcm_format_t format) |
@@ -232,7 +240,7 @@ EXPORT_SYMBOL(snd_pcm_format_signed); | |||
232 | * snd_pcm_format_unsigned - Check the PCM format is unsigned linear | 240 | * snd_pcm_format_unsigned - Check the PCM format is unsigned linear |
233 | * @format: the format to check | 241 | * @format: the format to check |
234 | * | 242 | * |
235 | * Returns 1 if the given PCM format is unsigned linear, 0 if signed | 243 | * Return: 1 if the given PCM format is unsigned linear, 0 if signed |
236 | * linear, and a negative error code for non-linear formats. | 244 | * linear, and a negative error code for non-linear formats. |
237 | */ | 245 | */ |
238 | int snd_pcm_format_unsigned(snd_pcm_format_t format) | 246 | int snd_pcm_format_unsigned(snd_pcm_format_t format) |
@@ -251,7 +259,7 @@ EXPORT_SYMBOL(snd_pcm_format_unsigned); | |||
251 | * snd_pcm_format_linear - Check the PCM format is linear | 259 | * snd_pcm_format_linear - Check the PCM format is linear |
252 | * @format: the format to check | 260 | * @format: the format to check |
253 | * | 261 | * |
254 | * Returns 1 if the given PCM format is linear, 0 if not. | 262 | * Return: 1 if the given PCM format is linear, 0 if not. |
255 | */ | 263 | */ |
256 | int snd_pcm_format_linear(snd_pcm_format_t format) | 264 | int snd_pcm_format_linear(snd_pcm_format_t format) |
257 | { | 265 | { |
@@ -264,7 +272,7 @@ EXPORT_SYMBOL(snd_pcm_format_linear); | |||
264 | * snd_pcm_format_little_endian - Check the PCM format is little-endian | 272 | * snd_pcm_format_little_endian - Check the PCM format is little-endian |
265 | * @format: the format to check | 273 | * @format: the format to check |
266 | * | 274 | * |
267 | * Returns 1 if the given PCM format is little-endian, 0 if | 275 | * Return: 1 if the given PCM format is little-endian, 0 if |
268 | * big-endian, or a negative error code if endian not specified. | 276 | * big-endian, or a negative error code if endian not specified. |
269 | */ | 277 | */ |
270 | int snd_pcm_format_little_endian(snd_pcm_format_t format) | 278 | int snd_pcm_format_little_endian(snd_pcm_format_t format) |
@@ -283,7 +291,7 @@ EXPORT_SYMBOL(snd_pcm_format_little_endian); | |||
283 | * snd_pcm_format_big_endian - Check the PCM format is big-endian | 291 | * snd_pcm_format_big_endian - Check the PCM format is big-endian |
284 | * @format: the format to check | 292 | * @format: the format to check |
285 | * | 293 | * |
286 | * Returns 1 if the given PCM format is big-endian, 0 if | 294 | * Return: 1 if the given PCM format is big-endian, 0 if |
287 | * little-endian, or a negative error code if endian not specified. | 295 | * little-endian, or a negative error code if endian not specified. |
288 | */ | 296 | */ |
289 | int snd_pcm_format_big_endian(snd_pcm_format_t format) | 297 | int snd_pcm_format_big_endian(snd_pcm_format_t format) |
@@ -302,7 +310,7 @@ EXPORT_SYMBOL(snd_pcm_format_big_endian); | |||
302 | * snd_pcm_format_width - return the bit-width of the format | 310 | * snd_pcm_format_width - return the bit-width of the format |
303 | * @format: the format to check | 311 | * @format: the format to check |
304 | * | 312 | * |
305 | * Returns the bit-width of the format, or a negative error code | 313 | * Return: The bit-width of the format, or a negative error code |
306 | * if unknown format. | 314 | * if unknown format. |
307 | */ | 315 | */ |
308 | int snd_pcm_format_width(snd_pcm_format_t format) | 316 | int snd_pcm_format_width(snd_pcm_format_t format) |
@@ -321,7 +329,7 @@ EXPORT_SYMBOL(snd_pcm_format_width); | |||
321 | * snd_pcm_format_physical_width - return the physical bit-width of the format | 329 | * snd_pcm_format_physical_width - return the physical bit-width of the format |
322 | * @format: the format to check | 330 | * @format: the format to check |
323 | * | 331 | * |
324 | * Returns the physical bit-width of the format, or a negative error code | 332 | * Return: The physical bit-width of the format, or a negative error code |
325 | * if unknown format. | 333 | * if unknown format. |
326 | */ | 334 | */ |
327 | int snd_pcm_format_physical_width(snd_pcm_format_t format) | 335 | int snd_pcm_format_physical_width(snd_pcm_format_t format) |
@@ -341,7 +349,7 @@ EXPORT_SYMBOL(snd_pcm_format_physical_width); | |||
341 | * @format: the format to check | 349 | * @format: the format to check |
342 | * @samples: sampling rate | 350 | * @samples: sampling rate |
343 | * | 351 | * |
344 | * Returns the byte size of the given samples for the format, or a | 352 | * Return: The byte size of the given samples for the format, or a |
345 | * negative error code if unknown format. | 353 | * negative error code if unknown format. |
346 | */ | 354 | */ |
347 | ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples) | 355 | ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples) |
@@ -358,7 +366,7 @@ EXPORT_SYMBOL(snd_pcm_format_size); | |||
358 | * snd_pcm_format_silence_64 - return the silent data in 8 bytes array | 366 | * snd_pcm_format_silence_64 - return the silent data in 8 bytes array |
359 | * @format: the format to check | 367 | * @format: the format to check |
360 | * | 368 | * |
361 | * Returns the format pattern to fill or NULL if error. | 369 | * Return: The format pattern to fill or %NULL if error. |
362 | */ | 370 | */ |
363 | const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format) | 371 | const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format) |
364 | { | 372 | { |
@@ -379,7 +387,7 @@ EXPORT_SYMBOL(snd_pcm_format_silence_64); | |||
379 | * | 387 | * |
380 | * Sets the silence data on the buffer for the given samples. | 388 | * Sets the silence data on the buffer for the given samples. |
381 | * | 389 | * |
382 | * Returns zero if successful, or a negative error code on failure. | 390 | * Return: Zero if successful, or a negative error code on failure. |
383 | */ | 391 | */ |
384 | int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int samples) | 392 | int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int samples) |
385 | { | 393 | { |
@@ -449,7 +457,7 @@ EXPORT_SYMBOL(snd_pcm_format_set_silence); | |||
449 | * Determines the rate_min and rate_max fields from the rates bits of | 457 | * Determines the rate_min and rate_max fields from the rates bits of |
450 | * the given runtime->hw. | 458 | * the given runtime->hw. |
451 | * | 459 | * |
452 | * Returns zero if successful. | 460 | * Return: Zero if successful. |
453 | */ | 461 | */ |
454 | int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime) | 462 | int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime) |
455 | { | 463 | { |
@@ -475,7 +483,7 @@ EXPORT_SYMBOL(snd_pcm_limit_hw_rates); | |||
475 | * snd_pcm_rate_to_rate_bit - converts sample rate to SNDRV_PCM_RATE_xxx bit | 483 | * snd_pcm_rate_to_rate_bit - converts sample rate to SNDRV_PCM_RATE_xxx bit |
476 | * @rate: the sample rate to convert | 484 | * @rate: the sample rate to convert |
477 | * | 485 | * |
478 | * Returns the SNDRV_PCM_RATE_xxx flag that corresponds to the given rate, or | 486 | * Return: The SNDRV_PCM_RATE_xxx flag that corresponds to the given rate, or |
479 | * SNDRV_PCM_RATE_KNOT for an unknown rate. | 487 | * SNDRV_PCM_RATE_KNOT for an unknown rate. |
480 | */ | 488 | */ |
481 | unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate) | 489 | unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate) |
@@ -493,8 +501,8 @@ EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit); | |||
493 | * snd_pcm_rate_bit_to_rate - converts SNDRV_PCM_RATE_xxx bit to sample rate | 501 | * snd_pcm_rate_bit_to_rate - converts SNDRV_PCM_RATE_xxx bit to sample rate |
494 | * @rate_bit: the rate bit to convert | 502 | * @rate_bit: the rate bit to convert |
495 | * | 503 | * |
496 | * Returns the sample rate that corresponds to the given SNDRV_PCM_RATE_xxx flag | 504 | * Return: The sample rate that corresponds to the given SNDRV_PCM_RATE_xxx flag |
497 | * or 0 for an unknown rate bit | 505 | * or 0 for an unknown rate bit. |
498 | */ | 506 | */ |
499 | unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit) | 507 | unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit) |
500 | { | 508 | { |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index eb560fa32321..23e3c46cd0a4 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -898,6 +898,8 @@ static struct action_ops snd_pcm_action_start = { | |||
898 | /** | 898 | /** |
899 | * snd_pcm_start - start all linked streams | 899 | * snd_pcm_start - start all linked streams |
900 | * @substream: the PCM substream instance | 900 | * @substream: the PCM substream instance |
901 | * | ||
902 | * Return: Zero if successful, or a negative error code. | ||
901 | */ | 903 | */ |
902 | int snd_pcm_start(struct snd_pcm_substream *substream) | 904 | int snd_pcm_start(struct snd_pcm_substream *substream) |
903 | { | 905 | { |
@@ -951,6 +953,8 @@ static struct action_ops snd_pcm_action_stop = { | |||
951 | * @state: PCM state after stopping the stream | 953 | * @state: PCM state after stopping the stream |
952 | * | 954 | * |
953 | * The state of each stream is then changed to the given state unconditionally. | 955 | * The state of each stream is then changed to the given state unconditionally. |
956 | * | ||
957 | * Return: Zero if succesful, or a negative error code. | ||
954 | */ | 958 | */ |
955 | int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) | 959 | int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) |
956 | { | 960 | { |
@@ -965,6 +969,8 @@ EXPORT_SYMBOL(snd_pcm_stop); | |||
965 | * | 969 | * |
966 | * After stopping, the state is changed to SETUP. | 970 | * After stopping, the state is changed to SETUP. |
967 | * Unlike snd_pcm_stop(), this affects only the given stream. | 971 | * Unlike snd_pcm_stop(), this affects only the given stream. |
972 | * | ||
973 | * Return: Zero if succesful, or a negative error code. | ||
968 | */ | 974 | */ |
969 | int snd_pcm_drain_done(struct snd_pcm_substream *substream) | 975 | int snd_pcm_drain_done(struct snd_pcm_substream *substream) |
970 | { | 976 | { |
@@ -1098,6 +1104,9 @@ static struct action_ops snd_pcm_action_suspend = { | |||
1098 | * @substream: the PCM substream | 1104 | * @substream: the PCM substream |
1099 | * | 1105 | * |
1100 | * After this call, all streams are changed to SUSPENDED state. | 1106 | * After this call, all streams are changed to SUSPENDED state. |
1107 | * | ||
1108 | * Return: Zero if successful (or @substream is %NULL), or a negative error | ||
1109 | * code. | ||
1101 | */ | 1110 | */ |
1102 | int snd_pcm_suspend(struct snd_pcm_substream *substream) | 1111 | int snd_pcm_suspend(struct snd_pcm_substream *substream) |
1103 | { | 1112 | { |
@@ -1120,6 +1129,8 @@ EXPORT_SYMBOL(snd_pcm_suspend); | |||
1120 | * @pcm: the PCM instance | 1129 | * @pcm: the PCM instance |
1121 | * | 1130 | * |
1122 | * After this call, all streams are changed to SUSPENDED state. | 1131 | * After this call, all streams are changed to SUSPENDED state. |
1132 | * | ||
1133 | * Return: Zero if successful (or @pcm is %NULL), or a negative error code. | ||
1123 | */ | 1134 | */ |
1124 | int snd_pcm_suspend_all(struct snd_pcm *pcm) | 1135 | int snd_pcm_suspend_all(struct snd_pcm *pcm) |
1125 | { | 1136 | { |
@@ -1343,6 +1354,8 @@ static struct action_ops snd_pcm_action_prepare = { | |||
1343 | * snd_pcm_prepare - prepare the PCM substream to be triggerable | 1354 | * snd_pcm_prepare - prepare the PCM substream to be triggerable |
1344 | * @substream: the PCM substream instance | 1355 | * @substream: the PCM substream instance |
1345 | * @file: file to refer f_flags | 1356 | * @file: file to refer f_flags |
1357 | * | ||
1358 | * Return: Zero if successful, or a negative error code. | ||
1346 | */ | 1359 | */ |
1347 | static int snd_pcm_prepare(struct snd_pcm_substream *substream, | 1360 | static int snd_pcm_prepare(struct snd_pcm_substream *substream, |
1348 | struct file *file) | 1361 | struct file *file) |
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 1bb95aeea084..7b596b5751db 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
@@ -863,7 +863,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card, | |||
863 | * | 863 | * |
864 | * Reads the data from the internal buffer. | 864 | * Reads the data from the internal buffer. |
865 | * | 865 | * |
866 | * Returns the size of read data, or a negative error code on failure. | 866 | * Return: The size of read data, or a negative error code on failure. |
867 | */ | 867 | */ |
868 | int snd_rawmidi_receive(struct snd_rawmidi_substream *substream, | 868 | int snd_rawmidi_receive(struct snd_rawmidi_substream *substream, |
869 | const unsigned char *buffer, int count) | 869 | const unsigned char *buffer, int count) |
@@ -1024,8 +1024,8 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun | |||
1024 | /** | 1024 | /** |
1025 | * snd_rawmidi_transmit_empty - check whether the output buffer is empty | 1025 | * snd_rawmidi_transmit_empty - check whether the output buffer is empty |
1026 | * @substream: the rawmidi substream | 1026 | * @substream: the rawmidi substream |
1027 | * | 1027 | * |
1028 | * Returns 1 if the internal output buffer is empty, 0 if not. | 1028 | * Return: 1 if the internal output buffer is empty, 0 if not. |
1029 | */ | 1029 | */ |
1030 | int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream) | 1030 | int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream) |
1031 | { | 1031 | { |
@@ -1055,7 +1055,7 @@ int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream) | |||
1055 | * and call snd_rawmidi_transmit_ack() after the transmission is | 1055 | * and call snd_rawmidi_transmit_ack() after the transmission is |
1056 | * finished. | 1056 | * finished. |
1057 | * | 1057 | * |
1058 | * Returns the size of copied data, or a negative error code on failure. | 1058 | * Return: The size of copied data, or a negative error code on failure. |
1059 | */ | 1059 | */ |
1060 | int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream, | 1060 | int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream, |
1061 | unsigned char *buffer, int count) | 1061 | unsigned char *buffer, int count) |
@@ -1107,7 +1107,7 @@ int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream, | |||
1107 | * the given size and updates the condition. | 1107 | * the given size and updates the condition. |
1108 | * Call after the transmission is finished. | 1108 | * Call after the transmission is finished. |
1109 | * | 1109 | * |
1110 | * Returns the advanced size if successful, or a negative error code on failure. | 1110 | * Return: The advanced size if successful, or a negative error code on failure. |
1111 | */ | 1111 | */ |
1112 | int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count) | 1112 | int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count) |
1113 | { | 1113 | { |
@@ -1140,7 +1140,7 @@ int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count) | |||
1140 | * | 1140 | * |
1141 | * Copies data from the buffer to the device and advances the pointer. | 1141 | * Copies data from the buffer to the device and advances the pointer. |
1142 | * | 1142 | * |
1143 | * Returns the copied size if successful, or a negative error code on failure. | 1143 | * Return: The copied size if successful, or a negative error code on failure. |
1144 | */ | 1144 | */ |
1145 | int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream, | 1145 | int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream, |
1146 | unsigned char *buffer, int count) | 1146 | unsigned char *buffer, int count) |
@@ -1438,7 +1438,7 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, | |||
1438 | * Creates a new rawmidi instance. | 1438 | * Creates a new rawmidi instance. |
1439 | * Use snd_rawmidi_set_ops() to set the operators to the new instance. | 1439 | * Use snd_rawmidi_set_ops() to set the operators to the new instance. |
1440 | * | 1440 | * |
1441 | * Returns zero if successful, or a negative error code on failure. | 1441 | * Return: Zero if successful, or a negative error code on failure. |
1442 | */ | 1442 | */ |
1443 | int snd_rawmidi_new(struct snd_card *card, char *id, int device, | 1443 | int snd_rawmidi_new(struct snd_card *card, char *id, int device, |
1444 | int output_count, int input_count, | 1444 | int output_count, int input_count, |
diff --git a/sound/core/sound.c b/sound/core/sound.c index 70ccdab74153..f002bd911dae 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c | |||
@@ -102,6 +102,9 @@ static void snd_request_other(int minor) | |||
102 | * This function increments the reference counter of the card instance | 102 | * This function increments the reference counter of the card instance |
103 | * if an associated instance with the given minor number and type is found. | 103 | * if an associated instance with the given minor number and type is found. |
104 | * The caller must call snd_card_unref() appropriately later. | 104 | * The caller must call snd_card_unref() appropriately later. |
105 | * | ||
106 | * Return: The user data pointer if the specified device is found. %NULL | ||
107 | * otherwise. | ||
105 | */ | 108 | */ |
106 | void *snd_lookup_minor_data(unsigned int minor, int type) | 109 | void *snd_lookup_minor_data(unsigned int minor, int type) |
107 | { | 110 | { |
@@ -261,7 +264,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) | |||
261 | * Registers an ALSA device file for the given card. | 264 | * Registers an ALSA device file for the given card. |
262 | * The operators have to be set in reg parameter. | 265 | * The operators have to be set in reg parameter. |
263 | * | 266 | * |
264 | * Returns zero if successful, or a negative error code on failure. | 267 | * Return: Zero if successful, or a negative error code on failure. |
265 | */ | 268 | */ |
266 | int snd_register_device_for_dev(int type, struct snd_card *card, int dev, | 269 | int snd_register_device_for_dev(int type, struct snd_card *card, int dev, |
267 | const struct file_operations *f_ops, | 270 | const struct file_operations *f_ops, |
@@ -339,7 +342,7 @@ static int find_snd_minor(int type, struct snd_card *card, int dev) | |||
339 | * Unregisters the device file already registered via | 342 | * Unregisters the device file already registered via |
340 | * snd_register_device(). | 343 | * snd_register_device(). |
341 | * | 344 | * |
342 | * Returns zero if sucecessful, or a negative error code on failure | 345 | * Return: Zero if successful, or a negative error code on failure. |
343 | */ | 346 | */ |
344 | int snd_unregister_device(int type, struct snd_card *card, int dev) | 347 | int snd_unregister_device(int type, struct snd_card *card, int dev) |
345 | { | 348 | { |
diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c index 0097f3619faa..02f90b4f8b86 100644 --- a/sound/core/vmaster.c +++ b/sound/core/vmaster.c | |||
@@ -365,8 +365,7 @@ static void master_free(struct snd_kcontrol *kcontrol) | |||
365 | * @name: name string of the control element to create | 365 | * @name: name string of the control element to create |
366 | * @tlv: optional TLV int array for dB information | 366 | * @tlv: optional TLV int array for dB information |
367 | * | 367 | * |
368 | * Creates a virtual matster control with the given name string. | 368 | * Creates a virtual master control with the given name string. |
369 | * Returns the created control element, or NULL for errors (ENOMEM). | ||
370 | * | 369 | * |
371 | * After creating a vmaster element, you can add the slave controls | 370 | * After creating a vmaster element, you can add the slave controls |
372 | * via snd_ctl_add_slave() or snd_ctl_add_slave_uncached(). | 371 | * via snd_ctl_add_slave() or snd_ctl_add_slave_uncached(). |
@@ -375,6 +374,8 @@ static void master_free(struct snd_kcontrol *kcontrol) | |||
375 | * for dB scale of the master control. It should be a single element | 374 | * for dB scale of the master control. It should be a single element |
376 | * with #SNDRV_CTL_TLVT_DB_SCALE, #SNDRV_CTL_TLV_DB_MINMAX or | 375 | * with #SNDRV_CTL_TLVT_DB_SCALE, #SNDRV_CTL_TLV_DB_MINMAX or |
377 | * #SNDRV_CTL_TLVT_DB_MINMAX_MUTE type, and should be the max 0dB. | 376 | * #SNDRV_CTL_TLVT_DB_MINMAX_MUTE type, and should be the max 0dB. |
377 | * | ||
378 | * Return: The created control element, or %NULL for errors (ENOMEM). | ||
378 | */ | 379 | */ |
379 | struct snd_kcontrol *snd_ctl_make_virtual_master(char *name, | 380 | struct snd_kcontrol *snd_ctl_make_virtual_master(char *name, |
380 | const unsigned int *tlv) | 381 | const unsigned int *tlv) |
@@ -426,6 +427,8 @@ EXPORT_SYMBOL(snd_ctl_make_virtual_master); | |||
426 | * | 427 | * |
427 | * Adds the given hook to the vmaster control element so that it's called | 428 | * Adds the given hook to the vmaster control element so that it's called |
428 | * at each time when the value is changed. | 429 | * at each time when the value is changed. |
430 | * | ||
431 | * Return: Zero. | ||
429 | */ | 432 | */ |
430 | int snd_ctl_add_vmaster_hook(struct snd_kcontrol *kcontrol, | 433 | int snd_ctl_add_vmaster_hook(struct snd_kcontrol *kcontrol, |
431 | void (*hook)(void *private_data, int), | 434 | void (*hook)(void *private_data, int), |
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig index 7d02c322ed93..8545da99b183 100644 --- a/sound/drivers/Kconfig +++ b/sound/drivers/Kconfig | |||
@@ -87,7 +87,7 @@ config SND_ALOOP | |||
87 | configured number of substreams (see the pcm_substreams module | 87 | configured number of substreams (see the pcm_substreams module |
88 | parameter). | 88 | parameter). |
89 | 89 | ||
90 | The looback device allow time sychronization with an external | 90 | The loopback device allows time sychronization with an external |
91 | timing source using the time shift universal control (+-20% | 91 | timing source using the time shift universal control (+-20% |
92 | of system time). | 92 | of system time). |
93 | 93 | ||
diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index 4608c2ca43f8..e3a90d043f03 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c | |||
@@ -129,6 +129,8 @@ static void _snd_mpu401_uart_interrupt(struct snd_mpu401 *mpu) | |||
129 | * @dev_id: mpu401 instance | 129 | * @dev_id: mpu401 instance |
130 | * | 130 | * |
131 | * Processes the interrupt for MPU401-UART i/o. | 131 | * Processes the interrupt for MPU401-UART i/o. |
132 | * | ||
133 | * Return: %IRQ_HANDLED if the interrupt was handled. %IRQ_NONE otherwise. | ||
132 | */ | 134 | */ |
133 | irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id) | 135 | irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id) |
134 | { | 136 | { |
@@ -148,6 +150,8 @@ EXPORT_SYMBOL(snd_mpu401_uart_interrupt); | |||
148 | * @dev_id: mpu401 instance | 150 | * @dev_id: mpu401 instance |
149 | * | 151 | * |
150 | * Processes the interrupt for MPU401-UART output. | 152 | * Processes the interrupt for MPU401-UART output. |
153 | * | ||
154 | * Return: %IRQ_HANDLED if the interrupt was handled. %IRQ_NONE otherwise. | ||
151 | */ | 155 | */ |
152 | irqreturn_t snd_mpu401_uart_interrupt_tx(int irq, void *dev_id) | 156 | irqreturn_t snd_mpu401_uart_interrupt_tx(int irq, void *dev_id) |
153 | { | 157 | { |
@@ -519,7 +523,7 @@ static void snd_mpu401_uart_free(struct snd_rawmidi *rmidi) | |||
519 | * not the mpu401 instance itself. To access to the mpu401 instance, | 523 | * not the mpu401 instance itself. To access to the mpu401 instance, |
520 | * cast from rawmidi->private_data (with struct snd_mpu401 magic-cast). | 524 | * cast from rawmidi->private_data (with struct snd_mpu401 magic-cast). |
521 | * | 525 | * |
522 | * Returns zero if successful, or a negative error code. | 526 | * Return: Zero if successful, or a negative error code. |
523 | */ | 527 | */ |
524 | int snd_mpu401_uart_new(struct snd_card *card, int device, | 528 | int snd_mpu401_uart_new(struct snd_card *card, int device, |
525 | unsigned short hardware, | 529 | unsigned short hardware, |
diff --git a/sound/oss/sb_common.c b/sound/oss/sb_common.c index 7d42c5418d1b..851a1da46be1 100644 --- a/sound/oss/sb_common.c +++ b/sound/oss/sb_common.c | |||
@@ -626,13 +626,12 @@ int sb_dsp_detect(struct address_info *hw_config, int pci, int pciio, struct sb_ | |||
626 | */ | 626 | */ |
627 | 627 | ||
628 | 628 | ||
629 | detected_devc = kmalloc(sizeof(sb_devc), GFP_KERNEL); | 629 | detected_devc = kmemdup(devc, sizeof(sb_devc), GFP_KERNEL); |
630 | if (detected_devc == NULL) | 630 | if (detected_devc == NULL) |
631 | { | 631 | { |
632 | printk(KERN_ERR "sb: Can't allocate memory for device information\n"); | 632 | printk(KERN_ERR "sb: Can't allocate memory for device information\n"); |
633 | return 0; | 633 | return 0; |
634 | } | 634 | } |
635 | memcpy(detected_devc, devc, sizeof(sb_devc)); | ||
636 | MDB(printk(KERN_INFO "SB %d.%02d detected OK (%x)\n", devc->major, devc->minor, hw_config->io_base)); | 635 | MDB(printk(KERN_INFO "SB %d.%02d detected OK (%x)\n", devc->major, devc->minor, hw_config->io_base)); |
637 | return 1; | 636 | return 1; |
638 | } | 637 | } |
diff --git a/sound/oss/uart401.c b/sound/oss/uart401.c index 8e514a676a0d..5433c6f5eca2 100644 --- a/sound/oss/uart401.c +++ b/sound/oss/uart401.c | |||
@@ -352,23 +352,26 @@ int probe_uart401(struct address_info *hw_config, struct module *owner) | |||
352 | goto cleanup_irq; | 352 | goto cleanup_irq; |
353 | } | 353 | } |
354 | conf_printf(name, hw_config); | 354 | conf_printf(name, hw_config); |
355 | midi_devs[devc->my_dev] = kmalloc(sizeof(struct midi_operations), GFP_KERNEL); | 355 | midi_devs[devc->my_dev] = kmemdup(&uart401_operations, |
356 | sizeof(struct midi_operations), | ||
357 | GFP_KERNEL); | ||
356 | if (!midi_devs[devc->my_dev]) { | 358 | if (!midi_devs[devc->my_dev]) { |
357 | printk(KERN_ERR "uart401: Failed to allocate memory\n"); | 359 | printk(KERN_ERR "uart401: Failed to allocate memory\n"); |
358 | goto cleanup_unload_mididev; | 360 | goto cleanup_unload_mididev; |
359 | } | 361 | } |
360 | memcpy(midi_devs[devc->my_dev], &uart401_operations, sizeof(struct midi_operations)); | ||
361 | 362 | ||
362 | if (owner) | 363 | if (owner) |
363 | midi_devs[devc->my_dev]->owner = owner; | 364 | midi_devs[devc->my_dev]->owner = owner; |
364 | 365 | ||
365 | midi_devs[devc->my_dev]->devc = devc; | 366 | midi_devs[devc->my_dev]->devc = devc; |
366 | midi_devs[devc->my_dev]->converter = kmalloc(sizeof(struct synth_operations), GFP_KERNEL); | 367 | midi_devs[devc->my_dev]->converter = kmemdup(&std_midi_synth, |
368 | sizeof(struct synth_operations), | ||
369 | GFP_KERNEL); | ||
370 | |||
367 | if (!midi_devs[devc->my_dev]->converter) { | 371 | if (!midi_devs[devc->my_dev]->converter) { |
368 | printk(KERN_WARNING "uart401: Failed to allocate memory\n"); | 372 | printk(KERN_WARNING "uart401: Failed to allocate memory\n"); |
369 | goto cleanup_midi_devs; | 373 | goto cleanup_midi_devs; |
370 | } | 374 | } |
371 | memcpy(midi_devs[devc->my_dev]->converter, &std_midi_synth, sizeof(struct synth_operations)); | ||
372 | strcpy(midi_devs[devc->my_dev]->info.name, name); | 375 | strcpy(midi_devs[devc->my_dev]->info.name, name); |
373 | midi_devs[devc->my_dev]->converter->id = "UART401"; | 376 | midi_devs[devc->my_dev]->converter->id = "UART401"; |
374 | midi_devs[devc->my_dev]->converter->midi_dev = devc->my_dev; | 377 | midi_devs[devc->my_dev]->converter->midi_dev = devc->my_dev; |
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 8b0f99688303..d37c683cfd7a 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c | |||
@@ -299,7 +299,7 @@ EXPORT_SYMBOL(snd_ac97_write); | |||
299 | * Reads a value from the given register. This will invoke the read | 299 | * Reads a value from the given register. This will invoke the read |
300 | * callback directly after the register check. | 300 | * callback directly after the register check. |
301 | * | 301 | * |
302 | * Returns the read value. | 302 | * Return: The read value. |
303 | */ | 303 | */ |
304 | unsigned short snd_ac97_read(struct snd_ac97 *ac97, unsigned short reg) | 304 | unsigned short snd_ac97_read(struct snd_ac97 *ac97, unsigned short reg) |
305 | { | 305 | { |
@@ -352,7 +352,7 @@ EXPORT_SYMBOL(snd_ac97_write_cache); | |||
352 | * Compares the value with the register cache and updates the value | 352 | * Compares the value with the register cache and updates the value |
353 | * only when the value is changed. | 353 | * only when the value is changed. |
354 | * | 354 | * |
355 | * Returns 1 if the value is changed, 0 if no change, or a negative | 355 | * Return: 1 if the value is changed, 0 if no change, or a negative |
356 | * code on failure. | 356 | * code on failure. |
357 | */ | 357 | */ |
358 | int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) | 358 | int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) |
@@ -384,7 +384,7 @@ EXPORT_SYMBOL(snd_ac97_update); | |||
384 | * Updates the masked-bits on the given register only when the value | 384 | * Updates the masked-bits on the given register only when the value |
385 | * is changed. | 385 | * is changed. |
386 | * | 386 | * |
387 | * Returns 1 if the bits are changed, 0 if no change, or a negative | 387 | * Return: 1 if the bits are changed, 0 if no change, or a negative |
388 | * code on failure. | 388 | * code on failure. |
389 | */ | 389 | */ |
390 | int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value) | 390 | int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value) |
@@ -1836,7 +1836,7 @@ void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, int m | |||
1836 | * snd_ac97_get_short_name - retrieve codec name | 1836 | * snd_ac97_get_short_name - retrieve codec name |
1837 | * @ac97: the codec instance | 1837 | * @ac97: the codec instance |
1838 | * | 1838 | * |
1839 | * Returns the short identifying name of the codec. | 1839 | * Return: The short identifying name of the codec. |
1840 | */ | 1840 | */ |
1841 | const char *snd_ac97_get_short_name(struct snd_ac97 *ac97) | 1841 | const char *snd_ac97_get_short_name(struct snd_ac97 *ac97) |
1842 | { | 1842 | { |
@@ -1910,7 +1910,7 @@ static int ac97_reset_wait(struct snd_ac97 *ac97, int timeout, int with_modem) | |||
1910 | * The AC97 bus instance is registered as a low-level device, so you don't | 1910 | * The AC97 bus instance is registered as a low-level device, so you don't |
1911 | * have to release it manually. | 1911 | * have to release it manually. |
1912 | * | 1912 | * |
1913 | * Returns zero if successful, or a negative error code on failure. | 1913 | * Return: Zero if successful, or a negative error code on failure. |
1914 | */ | 1914 | */ |
1915 | int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops, | 1915 | int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops, |
1916 | void *private_data, struct snd_ac97_bus **rbus) | 1916 | void *private_data, struct snd_ac97_bus **rbus) |
@@ -2006,7 +2006,7 @@ static void do_update_power(struct work_struct *work) | |||
2006 | * The ac97 instance is registered as a low-level device, so you don't | 2006 | * The ac97 instance is registered as a low-level device, so you don't |
2007 | * have to release it manually. | 2007 | * have to release it manually. |
2008 | * | 2008 | * |
2009 | * Returns zero if successful, or a negative error code on failure. | 2009 | * Return: Zero if successful, or a negative error code on failure. |
2010 | */ | 2010 | */ |
2011 | int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, struct snd_ac97 **rac97) | 2011 | int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, struct snd_ac97 **rac97) |
2012 | { | 2012 | { |
@@ -2373,6 +2373,8 @@ static struct ac97_power_reg power_regs[PWIDX_SIZE] = { | |||
2373 | * @powerup: non-zero when power up the part | 2373 | * @powerup: non-zero when power up the part |
2374 | * | 2374 | * |
2375 | * Update the AC97 powerdown register bits of the given part. | 2375 | * Update the AC97 powerdown register bits of the given part. |
2376 | * | ||
2377 | * Return: Zero. | ||
2376 | */ | 2378 | */ |
2377 | int snd_ac97_update_power(struct snd_ac97 *ac97, int reg, int powerup) | 2379 | int snd_ac97_update_power(struct snd_ac97 *ac97, int reg, int powerup) |
2378 | { | 2380 | { |
@@ -2885,7 +2887,7 @@ static int apply_quirk_str(struct snd_ac97 *ac97, const char *typestr) | |||
2885 | * headphone (true line-out) control as "Master". | 2887 | * headphone (true line-out) control as "Master". |
2886 | * The quirk-list must be terminated with a zero-filled entry. | 2888 | * The quirk-list must be terminated with a zero-filled entry. |
2887 | * | 2889 | * |
2888 | * Returns zero if successful, or a negative error code on failure. | 2890 | * Return: Zero if successful, or a negative error code on failure. |
2889 | */ | 2891 | */ |
2890 | 2892 | ||
2891 | int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, const char *override) | 2893 | int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, const char *override) |
diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c index f1488fc176d5..eab0fc9ff2e0 100644 --- a/sound/pci/ac97/ac97_pcm.c +++ b/sound/pci/ac97/ac97_pcm.c | |||
@@ -253,7 +253,7 @@ static int set_spdif_rate(struct snd_ac97 *ac97, unsigned short rate) | |||
253 | * AC97_SPDIF is accepted as a pseudo register to modify the SPDIF | 253 | * AC97_SPDIF is accepted as a pseudo register to modify the SPDIF |
254 | * status bits. | 254 | * status bits. |
255 | * | 255 | * |
256 | * Returns zero if successful, or a negative error code on failure. | 256 | * Return: Zero if successful, or a negative error code on failure. |
257 | */ | 257 | */ |
258 | int snd_ac97_set_rate(struct snd_ac97 *ac97, int reg, unsigned int rate) | 258 | int snd_ac97_set_rate(struct snd_ac97 *ac97, int reg, unsigned int rate) |
259 | { | 259 | { |
@@ -440,6 +440,8 @@ static unsigned int get_rates(struct ac97_pcm *pcm, unsigned int cidx, unsigned | |||
440 | * It assigns available AC97 slots for given PCMs. If none or only | 440 | * It assigns available AC97 slots for given PCMs. If none or only |
441 | * some slots are available, pcm->xxx.slots and pcm->xxx.rslots[] members | 441 | * some slots are available, pcm->xxx.slots and pcm->xxx.rslots[] members |
442 | * are reduced and might be zero. | 442 | * are reduced and might be zero. |
443 | * | ||
444 | * Return: Zero if successful, or a negative error code on failure. | ||
443 | */ | 445 | */ |
444 | int snd_ac97_pcm_assign(struct snd_ac97_bus *bus, | 446 | int snd_ac97_pcm_assign(struct snd_ac97_bus *bus, |
445 | unsigned short pcms_count, | 447 | unsigned short pcms_count, |
@@ -562,6 +564,8 @@ EXPORT_SYMBOL(snd_ac97_pcm_assign); | |||
562 | * @slots: a subset of allocated slots (snd_ac97_pcm_assign) for this pcm | 564 | * @slots: a subset of allocated slots (snd_ac97_pcm_assign) for this pcm |
563 | * | 565 | * |
564 | * It locks the specified slots and sets the given rate to AC97 registers. | 566 | * It locks the specified slots and sets the given rate to AC97 registers. |
567 | * | ||
568 | * Return: Zero if successful, or a negative error code on failure. | ||
565 | */ | 569 | */ |
566 | int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate, | 570 | int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate, |
567 | enum ac97_pcm_cfg cfg, unsigned short slots) | 571 | enum ac97_pcm_cfg cfg, unsigned short slots) |
@@ -644,6 +648,8 @@ EXPORT_SYMBOL(snd_ac97_pcm_open); | |||
644 | * @pcm: the ac97 pcm instance | 648 | * @pcm: the ac97 pcm instance |
645 | * | 649 | * |
646 | * It frees the locked AC97 slots. | 650 | * It frees the locked AC97 slots. |
651 | * | ||
652 | * Return: Zero. | ||
647 | */ | 653 | */ |
648 | int snd_ac97_pcm_close(struct ac97_pcm *pcm) | 654 | int snd_ac97_pcm_close(struct ac97_pcm *pcm) |
649 | { | 655 | { |
@@ -718,6 +724,8 @@ static int double_rate_hw_constraint_channels(struct snd_pcm_hw_params *params, | |||
718 | * | 724 | * |
719 | * Installs the hardware constraint rules to prevent using double rates and | 725 | * Installs the hardware constraint rules to prevent using double rates and |
720 | * more than two channels at the same time. | 726 | * more than two channels at the same time. |
727 | * | ||
728 | * Return: Zero if successful, or a negative error code on failure. | ||
721 | */ | 729 | */ |
722 | int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime) | 730 | int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime) |
723 | { | 731 | { |
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index e6b016693240..bdd888ec9a84 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c | |||
@@ -657,14 +657,14 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu) | |||
657 | return 0; | 657 | return 0; |
658 | } | 658 | } |
659 | 659 | ||
660 | static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu) | 660 | static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, |
661 | const struct firmware *fw_entry) | ||
661 | { | 662 | { |
662 | int n, i; | 663 | int n, i; |
663 | int reg; | 664 | int reg; |
664 | int value; | 665 | int value; |
665 | unsigned int write_post; | 666 | unsigned int write_post; |
666 | unsigned long flags; | 667 | unsigned long flags; |
667 | const struct firmware *fw_entry = emu->firmware; | ||
668 | 668 | ||
669 | if (!fw_entry) | 669 | if (!fw_entry) |
670 | return -EIO; | 670 | return -EIO; |
@@ -725,9 +725,34 @@ static int emu1010_firmware_thread(void *data) | |||
725 | /* Return to Audio Dock programming mode */ | 725 | /* Return to Audio Dock programming mode */ |
726 | snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); | 726 | snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); |
727 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK); | 727 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK); |
728 | err = snd_emu1010_load_firmware(emu); | 728 | |
729 | if (err != 0) | 729 | if (!emu->dock_fw) { |
730 | continue; | 730 | const char *filename = NULL; |
731 | switch (emu->card_capabilities->emu_model) { | ||
732 | case EMU_MODEL_EMU1010: | ||
733 | filename = DOCK_FILENAME; | ||
734 | break; | ||
735 | case EMU_MODEL_EMU1010B: | ||
736 | filename = MICRO_DOCK_FILENAME; | ||
737 | break; | ||
738 | case EMU_MODEL_EMU1616: | ||
739 | filename = MICRO_DOCK_FILENAME; | ||
740 | break; | ||
741 | } | ||
742 | if (filename) { | ||
743 | err = request_firmware(&emu->dock_fw, | ||
744 | filename, | ||
745 | &emu->pci->dev); | ||
746 | if (err) | ||
747 | continue; | ||
748 | } | ||
749 | } | ||
750 | |||
751 | if (emu->dock_fw) { | ||
752 | err = snd_emu1010_load_firmware(emu, emu->dock_fw); | ||
753 | if (err) | ||
754 | continue; | ||
755 | } | ||
731 | 756 | ||
732 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0); | 757 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0); |
733 | snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, ®); | 758 | snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, ®); |
@@ -862,7 +887,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) | |||
862 | filename, emu->firmware->size); | 887 | filename, emu->firmware->size); |
863 | } | 888 | } |
864 | 889 | ||
865 | err = snd_emu1010_load_firmware(emu); | 890 | err = snd_emu1010_load_firmware(emu, emu->firmware); |
866 | if (err != 0) { | 891 | if (err != 0) { |
867 | snd_printk(KERN_INFO "emu1010: Loading Firmware failed\n"); | 892 | snd_printk(KERN_INFO "emu1010: Loading Firmware failed\n"); |
868 | return err; | 893 | return err; |
@@ -1253,6 +1278,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu) | |||
1253 | kthread_stop(emu->emu1010.firmware_thread); | 1278 | kthread_stop(emu->emu1010.firmware_thread); |
1254 | if (emu->firmware) | 1279 | if (emu->firmware) |
1255 | release_firmware(emu->firmware); | 1280 | release_firmware(emu->firmware); |
1281 | if (emu->dock_fw) | ||
1282 | release_firmware(emu->dock_fw); | ||
1256 | if (emu->irq >= 0) | 1283 | if (emu->irq >= 0) |
1257 | free_irq(emu->irq, emu); | 1284 | free_irq(emu->irq, emu); |
1258 | /* remove reserved page */ | 1285 | /* remove reserved page */ |
diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index a3ea76a4c9d2..7c11d46b84d3 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c | |||
@@ -119,6 +119,32 @@ static bool check_pincap_validity(struct hda_codec *codec, hda_nid_t pin, | |||
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | static bool can_be_headset_mic(struct hda_codec *codec, | ||
123 | struct auto_pin_cfg_item *item, | ||
124 | int seq_number) | ||
125 | { | ||
126 | int attr; | ||
127 | unsigned int def_conf; | ||
128 | if (item->type != AUTO_PIN_MIC) | ||
129 | return false; | ||
130 | |||
131 | if (item->is_headset_mic || item->is_headphone_mic) | ||
132 | return false; /* Already assigned */ | ||
133 | |||
134 | def_conf = snd_hda_codec_get_pincfg(codec, item->pin); | ||
135 | attr = snd_hda_get_input_pin_attr(def_conf); | ||
136 | if (attr <= INPUT_PIN_ATTR_DOCK) | ||
137 | return false; | ||
138 | |||
139 | if (seq_number >= 0) { | ||
140 | int seq = get_defcfg_sequence(def_conf); | ||
141 | if (seq != seq_number) | ||
142 | return false; | ||
143 | } | ||
144 | |||
145 | return true; | ||
146 | } | ||
147 | |||
122 | /* | 148 | /* |
123 | * Parse all pin widgets and store the useful pin nids to cfg | 149 | * Parse all pin widgets and store the useful pin nids to cfg |
124 | * | 150 | * |
@@ -260,6 +286,38 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, | |||
260 | } | 286 | } |
261 | } | 287 | } |
262 | 288 | ||
289 | /* Find a pin that could be a headset or headphone mic */ | ||
290 | if (cond_flags & HDA_PINCFG_HEADSET_MIC || cond_flags & HDA_PINCFG_HEADPHONE_MIC) { | ||
291 | bool hsmic = !!(cond_flags & HDA_PINCFG_HEADSET_MIC); | ||
292 | bool hpmic = !!(cond_flags & HDA_PINCFG_HEADPHONE_MIC); | ||
293 | for (i = 0; (hsmic || hpmic) && (i < cfg->num_inputs); i++) | ||
294 | if (hsmic && can_be_headset_mic(codec, &cfg->inputs[i], 0xc)) { | ||
295 | cfg->inputs[i].is_headset_mic = 1; | ||
296 | hsmic = false; | ||
297 | } else if (hpmic && can_be_headset_mic(codec, &cfg->inputs[i], 0xd)) { | ||
298 | cfg->inputs[i].is_headphone_mic = 1; | ||
299 | hpmic = false; | ||
300 | } | ||
301 | |||
302 | /* If we didn't find our sequence number mark, fall back to any sequence number */ | ||
303 | for (i = 0; (hsmic || hpmic) && (i < cfg->num_inputs); i++) { | ||
304 | if (!can_be_headset_mic(codec, &cfg->inputs[i], -1)) | ||
305 | continue; | ||
306 | if (hsmic) { | ||
307 | cfg->inputs[i].is_headset_mic = 1; | ||
308 | hsmic = false; | ||
309 | } else if (hpmic) { | ||
310 | cfg->inputs[i].is_headphone_mic = 1; | ||
311 | hpmic = false; | ||
312 | } | ||
313 | } | ||
314 | |||
315 | if (hsmic) | ||
316 | snd_printdd("Told to look for a headset mic, but didn't find any.\n"); | ||
317 | if (hpmic) | ||
318 | snd_printdd("Told to look for a headphone mic, but didn't find any.\n"); | ||
319 | } | ||
320 | |||
263 | /* FIX-UP: | 321 | /* FIX-UP: |
264 | * If no line-out is defined but multiple HPs are found, | 322 | * If no line-out is defined but multiple HPs are found, |
265 | * some of them might be the real line-outs. | 323 | * some of them might be the real line-outs. |
@@ -388,6 +446,7 @@ EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr); | |||
388 | */ | 446 | */ |
389 | 447 | ||
390 | static const char *hda_get_input_pin_label(struct hda_codec *codec, | 448 | static const char *hda_get_input_pin_label(struct hda_codec *codec, |
449 | const struct auto_pin_cfg_item *item, | ||
391 | hda_nid_t pin, bool check_location) | 450 | hda_nid_t pin, bool check_location) |
392 | { | 451 | { |
393 | unsigned int def_conf; | 452 | unsigned int def_conf; |
@@ -400,6 +459,10 @@ static const char *hda_get_input_pin_label(struct hda_codec *codec, | |||
400 | 459 | ||
401 | switch (get_defcfg_device(def_conf)) { | 460 | switch (get_defcfg_device(def_conf)) { |
402 | case AC_JACK_MIC_IN: | 461 | case AC_JACK_MIC_IN: |
462 | if (item && item->is_headset_mic) | ||
463 | return "Headset Mic"; | ||
464 | if (item && item->is_headphone_mic) | ||
465 | return "Headphone Mic"; | ||
403 | if (!check_location) | 466 | if (!check_location) |
404 | return "Mic"; | 467 | return "Mic"; |
405 | attr = snd_hda_get_input_pin_attr(def_conf); | 468 | attr = snd_hda_get_input_pin_attr(def_conf); |
@@ -480,7 +543,8 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec, | |||
480 | has_multiple_pins = 1; | 543 | has_multiple_pins = 1; |
481 | if (has_multiple_pins && type == AUTO_PIN_MIC) | 544 | if (has_multiple_pins && type == AUTO_PIN_MIC) |
482 | has_multiple_pins &= check_mic_location_need(codec, cfg, input); | 545 | has_multiple_pins &= check_mic_location_need(codec, cfg, input); |
483 | return hda_get_input_pin_label(codec, cfg->inputs[input].pin, | 546 | return hda_get_input_pin_label(codec, &cfg->inputs[input], |
547 | cfg->inputs[input].pin, | ||
484 | has_multiple_pins); | 548 | has_multiple_pins); |
485 | } | 549 | } |
486 | EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); | 550 | EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); |
@@ -649,7 +713,7 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, | |||
649 | } | 713 | } |
650 | } | 714 | } |
651 | if (!name) | 715 | if (!name) |
652 | name = hda_get_input_pin_label(codec, nid, true); | 716 | name = hda_get_input_pin_label(codec, NULL, nid, true); |
653 | break; | 717 | break; |
654 | } | 718 | } |
655 | if (!name) | 719 | if (!name) |
diff --git a/sound/pci/hda/hda_auto_parser.h b/sound/pci/hda/hda_auto_parser.h index f74807138b49..e941f604f5e5 100644 --- a/sound/pci/hda/hda_auto_parser.h +++ b/sound/pci/hda/hda_auto_parser.h | |||
@@ -36,6 +36,8 @@ enum { | |||
36 | struct auto_pin_cfg_item { | 36 | struct auto_pin_cfg_item { |
37 | hda_nid_t pin; | 37 | hda_nid_t pin; |
38 | int type; | 38 | int type; |
39 | unsigned int is_headset_mic:1; | ||
40 | unsigned int is_headphone_mic:1; /* Mic-only in headphone jack */ | ||
39 | }; | 41 | }; |
40 | 42 | ||
41 | struct auto_pin_cfg; | 43 | struct auto_pin_cfg; |
@@ -78,8 +80,10 @@ struct auto_pin_cfg { | |||
78 | }; | 80 | }; |
79 | 81 | ||
80 | /* bit-flags for snd_hda_parse_pin_def_config() behavior */ | 82 | /* bit-flags for snd_hda_parse_pin_def_config() behavior */ |
81 | #define HDA_PINCFG_NO_HP_FIXUP (1 << 0) /* no HP-split */ | 83 | #define HDA_PINCFG_NO_HP_FIXUP (1 << 0) /* no HP-split */ |
82 | #define HDA_PINCFG_NO_LO_FIXUP (1 << 1) /* don't take other outs as LO */ | 84 | #define HDA_PINCFG_NO_LO_FIXUP (1 << 1) /* don't take other outs as LO */ |
85 | #define HDA_PINCFG_HEADSET_MIC (1 << 2) /* Try to find headset mic; mark seq number as 0xc to trigger */ | ||
86 | #define HDA_PINCFG_HEADPHONE_MIC (1 << 3) /* Try to find headphone mic; mark seq number as 0xd to trigger */ | ||
83 | 87 | ||
84 | int snd_hda_parse_pin_defcfg(struct hda_codec *codec, | 88 | int snd_hda_parse_pin_defcfg(struct hda_codec *codec, |
85 | struct auto_pin_cfg *cfg, | 89 | struct auto_pin_cfg *cfg, |
@@ -90,4 +94,25 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec, | |||
90 | #define snd_hda_parse_pin_def_config(codec, cfg, ignore) \ | 94 | #define snd_hda_parse_pin_def_config(codec, cfg, ignore) \ |
91 | snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0) | 95 | snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0) |
92 | 96 | ||
97 | static inline int auto_cfg_hp_outs(const struct auto_pin_cfg *cfg) | ||
98 | { | ||
99 | return (cfg->line_out_type == AUTO_PIN_HP_OUT) ? | ||
100 | cfg->line_outs : cfg->hp_outs; | ||
101 | } | ||
102 | static inline const hda_nid_t *auto_cfg_hp_pins(const struct auto_pin_cfg *cfg) | ||
103 | { | ||
104 | return (cfg->line_out_type == AUTO_PIN_HP_OUT) ? | ||
105 | cfg->line_out_pins : cfg->hp_pins; | ||
106 | } | ||
107 | static inline int auto_cfg_speaker_outs(const struct auto_pin_cfg *cfg) | ||
108 | { | ||
109 | return (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) ? | ||
110 | cfg->line_outs : cfg->speaker_outs; | ||
111 | } | ||
112 | static inline const hda_nid_t *auto_cfg_speaker_pins(const struct auto_pin_cfg *cfg) | ||
113 | { | ||
114 | return (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) ? | ||
115 | cfg->line_out_pins : cfg->speaker_pins; | ||
116 | } | ||
117 | |||
93 | #endif /* __SOUND_HDA_AUTO_PARSER_H */ | 118 | #endif /* __SOUND_HDA_AUTO_PARSER_H */ |
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index 0849aac449f2..63c99090a4ec 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
@@ -39,13 +39,23 @@ static void snd_hda_generate_beep(struct work_struct *work) | |||
39 | struct hda_beep *beep = | 39 | struct hda_beep *beep = |
40 | container_of(work, struct hda_beep, beep_work); | 40 | container_of(work, struct hda_beep, beep_work); |
41 | struct hda_codec *codec = beep->codec; | 41 | struct hda_codec *codec = beep->codec; |
42 | int tone; | ||
42 | 43 | ||
43 | if (!beep->enabled) | 44 | if (!beep->enabled) |
44 | return; | 45 | return; |
45 | 46 | ||
47 | tone = beep->tone; | ||
48 | if (tone && !beep->playing) { | ||
49 | snd_hda_power_up(codec); | ||
50 | beep->playing = 1; | ||
51 | } | ||
46 | /* generate tone */ | 52 | /* generate tone */ |
47 | snd_hda_codec_write(codec, beep->nid, 0, | 53 | snd_hda_codec_write(codec, beep->nid, 0, |
48 | AC_VERB_SET_BEEP_CONTROL, beep->tone); | 54 | AC_VERB_SET_BEEP_CONTROL, tone); |
55 | if (!tone && beep->playing) { | ||
56 | beep->playing = 0; | ||
57 | snd_hda_power_down(codec); | ||
58 | } | ||
49 | } | 59 | } |
50 | 60 | ||
51 | /* (non-standard) Linear beep tone calculation for IDT/STAC codecs | 61 | /* (non-standard) Linear beep tone calculation for IDT/STAC codecs |
@@ -115,14 +125,23 @@ static int snd_hda_beep_event(struct input_dev *dev, unsigned int type, | |||
115 | return 0; | 125 | return 0; |
116 | } | 126 | } |
117 | 127 | ||
128 | static void turn_off_beep(struct hda_beep *beep) | ||
129 | { | ||
130 | cancel_work_sync(&beep->beep_work); | ||
131 | if (beep->playing) { | ||
132 | /* turn off beep */ | ||
133 | snd_hda_codec_write(beep->codec, beep->nid, 0, | ||
134 | AC_VERB_SET_BEEP_CONTROL, 0); | ||
135 | beep->playing = 0; | ||
136 | snd_hda_power_down(beep->codec); | ||
137 | } | ||
138 | } | ||
139 | |||
118 | static void snd_hda_do_detach(struct hda_beep *beep) | 140 | static void snd_hda_do_detach(struct hda_beep *beep) |
119 | { | 141 | { |
120 | input_unregister_device(beep->dev); | 142 | input_unregister_device(beep->dev); |
121 | beep->dev = NULL; | 143 | beep->dev = NULL; |
122 | cancel_work_sync(&beep->beep_work); | 144 | turn_off_beep(beep); |
123 | /* turn off beep for sure */ | ||
124 | snd_hda_codec_write(beep->codec, beep->nid, 0, | ||
125 | AC_VERB_SET_BEEP_CONTROL, 0); | ||
126 | } | 145 | } |
127 | 146 | ||
128 | static int snd_hda_do_attach(struct hda_beep *beep) | 147 | static int snd_hda_do_attach(struct hda_beep *beep) |
@@ -170,12 +189,8 @@ int snd_hda_enable_beep_device(struct hda_codec *codec, int enable) | |||
170 | enable = !!enable; | 189 | enable = !!enable; |
171 | if (beep->enabled != enable) { | 190 | if (beep->enabled != enable) { |
172 | beep->enabled = enable; | 191 | beep->enabled = enable; |
173 | if (!enable) { | 192 | if (!enable) |
174 | cancel_work_sync(&beep->beep_work); | 193 | turn_off_beep(beep); |
175 | /* turn off beep */ | ||
176 | snd_hda_codec_write(beep->codec, beep->nid, 0, | ||
177 | AC_VERB_SET_BEEP_CONTROL, 0); | ||
178 | } | ||
179 | return 1; | 194 | return 1; |
180 | } | 195 | } |
181 | return 0; | 196 | return 0; |
@@ -198,7 +213,7 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) | |||
198 | snprintf(beep->phys, sizeof(beep->phys), | 213 | snprintf(beep->phys, sizeof(beep->phys), |
199 | "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr); | 214 | "card%d/codec#%d/beep0", codec->bus->card->number, codec->addr); |
200 | /* enable linear scale */ | 215 | /* enable linear scale */ |
201 | snd_hda_codec_write(codec, nid, 0, | 216 | snd_hda_codec_write_cache(codec, nid, 0, |
202 | AC_VERB_SET_DIGI_CONVERT_2, 0x01); | 217 | AC_VERB_SET_DIGI_CONVERT_2, 0x01); |
203 | 218 | ||
204 | beep->nid = nid; | 219 | beep->nid = nid; |
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h index 4dc6933bc655..cb88464676b6 100644 --- a/sound/pci/hda/hda_beep.h +++ b/sound/pci/hda/hda_beep.h | |||
@@ -36,6 +36,7 @@ struct hda_beep { | |||
36 | hda_nid_t nid; | 36 | hda_nid_t nid; |
37 | unsigned int enabled:1; | 37 | unsigned int enabled:1; |
38 | unsigned int linear_tone:1; /* linear tone for IDT/STAC codec */ | 38 | unsigned int linear_tone:1; /* linear tone for IDT/STAC codec */ |
39 | unsigned int playing:1; | ||
39 | struct work_struct beep_work; /* scheduled task for beep event */ | 40 | struct work_struct beep_work; /* scheduled task for beep event */ |
40 | struct mutex mutex; | 41 | struct mutex mutex; |
41 | }; | 42 | }; |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 4aba7646dd9c..6f9b64700f6e 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -1065,8 +1065,14 @@ int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list, | |||
1065 | { | 1065 | { |
1066 | struct hda_pincfg *pin; | 1066 | struct hda_pincfg *pin; |
1067 | 1067 | ||
1068 | /* the check below may be invalid when pins are added by a fixup | ||
1069 | * dynamically (e.g. via snd_hda_codec_update_widgets()), so disabled | ||
1070 | * for now | ||
1071 | */ | ||
1072 | /* | ||
1068 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) | 1073 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
1069 | return -EINVAL; | 1074 | return -EINVAL; |
1075 | */ | ||
1070 | 1076 | ||
1071 | pin = look_up_pincfg(codec, list, nid); | 1077 | pin = look_up_pincfg(codec, list, nid); |
1072 | if (!pin) { | 1078 | if (!pin) { |
@@ -1300,8 +1306,6 @@ static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, | |||
1300 | 1306 | ||
1301 | static unsigned int hda_set_power_state(struct hda_codec *codec, | 1307 | static unsigned int hda_set_power_state(struct hda_codec *codec, |
1302 | unsigned int power_state); | 1308 | unsigned int power_state); |
1303 | static unsigned int default_power_filter(struct hda_codec *codec, hda_nid_t nid, | ||
1304 | unsigned int power_state); | ||
1305 | 1309 | ||
1306 | /** | 1310 | /** |
1307 | * snd_hda_codec_new - create a HDA codec | 1311 | * snd_hda_codec_new - create a HDA codec |
@@ -1422,7 +1426,6 @@ int snd_hda_codec_new(struct hda_bus *bus, | |||
1422 | #endif | 1426 | #endif |
1423 | codec->epss = snd_hda_codec_get_supported_ps(codec, fg, | 1427 | codec->epss = snd_hda_codec_get_supported_ps(codec, fg, |
1424 | AC_PWRST_EPSS); | 1428 | AC_PWRST_EPSS); |
1425 | codec->power_filter = default_power_filter; | ||
1426 | 1429 | ||
1427 | /* power-up all before initialization */ | 1430 | /* power-up all before initialization */ |
1428 | hda_set_power_state(codec, AC_PWRST_D0); | 1431 | hda_set_power_state(codec, AC_PWRST_D0); |
@@ -2787,6 +2790,11 @@ void snd_hda_sync_vmaster_hook(struct hda_vmaster_mute_hook *hook) | |||
2787 | { | 2790 | { |
2788 | if (!hook->hook || !hook->codec) | 2791 | if (!hook->hook || !hook->codec) |
2789 | return; | 2792 | return; |
2793 | /* don't call vmaster hook in the destructor since it might have | ||
2794 | * been already destroyed | ||
2795 | */ | ||
2796 | if (hook->codec->bus->shutdown) | ||
2797 | return; | ||
2790 | switch (hook->mute_mode) { | 2798 | switch (hook->mute_mode) { |
2791 | case HDA_VMUTE_FOLLOW_MASTER: | 2799 | case HDA_VMUTE_FOLLOW_MASTER: |
2792 | snd_ctl_sync_vmaster_hook(hook->sw_kctl); | 2800 | snd_ctl_sync_vmaster_hook(hook->sw_kctl); |
@@ -3770,8 +3778,9 @@ static unsigned int hda_sync_power_state(struct hda_codec *codec, | |||
3770 | } | 3778 | } |
3771 | 3779 | ||
3772 | /* don't power down the widget if it controls eapd and EAPD_BTLENABLE is set */ | 3780 | /* don't power down the widget if it controls eapd and EAPD_BTLENABLE is set */ |
3773 | static unsigned int default_power_filter(struct hda_codec *codec, hda_nid_t nid, | 3781 | unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec, |
3774 | unsigned int power_state) | 3782 | hda_nid_t nid, |
3783 | unsigned int power_state) | ||
3775 | { | 3784 | { |
3776 | if (power_state == AC_PWRST_D3 && | 3785 | if (power_state == AC_PWRST_D3 && |
3777 | get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_PIN && | 3786 | get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_PIN && |
@@ -3783,6 +3792,7 @@ static unsigned int default_power_filter(struct hda_codec *codec, hda_nid_t nid, | |||
3783 | } | 3792 | } |
3784 | return power_state; | 3793 | return power_state; |
3785 | } | 3794 | } |
3795 | EXPORT_SYMBOL_HDA(snd_hda_codec_eapd_power_filter); | ||
3786 | 3796 | ||
3787 | /* | 3797 | /* |
3788 | * set power state of the codec, and return the power state | 3798 | * set power state of the codec, and return the power state |
@@ -3827,8 +3837,8 @@ static void sync_power_up_states(struct hda_codec *codec) | |||
3827 | hda_nid_t nid = codec->start_nid; | 3837 | hda_nid_t nid = codec->start_nid; |
3828 | int i; | 3838 | int i; |
3829 | 3839 | ||
3830 | /* don't care if no or standard filter is used */ | 3840 | /* don't care if no filter is used */ |
3831 | if (!codec->power_filter || codec->power_filter == default_power_filter) | 3841 | if (!codec->power_filter) |
3832 | return; | 3842 | return; |
3833 | 3843 | ||
3834 | for (i = 0; i < codec->num_nodes; i++, nid++) { | 3844 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
@@ -5546,14 +5556,12 @@ void *snd_array_new(struct snd_array *array) | |||
5546 | if (array->used >= array->alloced) { | 5556 | if (array->used >= array->alloced) { |
5547 | int num = array->alloced + array->alloc_align; | 5557 | int num = array->alloced + array->alloc_align; |
5548 | int size = (num + 1) * array->elem_size; | 5558 | int size = (num + 1) * array->elem_size; |
5549 | int oldsize = array->alloced * array->elem_size; | ||
5550 | void *nlist; | 5559 | void *nlist; |
5551 | if (snd_BUG_ON(num >= 4096)) | 5560 | if (snd_BUG_ON(num >= 4096)) |
5552 | return NULL; | 5561 | return NULL; |
5553 | nlist = krealloc(array->list, size, GFP_KERNEL); | 5562 | nlist = krealloc(array->list, size, GFP_KERNEL | __GFP_ZERO); |
5554 | if (!nlist) | 5563 | if (!nlist) |
5555 | return NULL; | 5564 | return NULL; |
5556 | memset(nlist + oldsize, 0, size - oldsize); | ||
5557 | array->list = nlist; | 5565 | array->list = nlist; |
5558 | array->alloced = num; | 5566 | array->alloced = num; |
5559 | } | 5567 | } |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 23ca1722aff1..c93f9021f452 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -757,6 +757,9 @@ struct hda_pcm_ops { | |||
757 | struct snd_pcm_substream *substream); | 757 | struct snd_pcm_substream *substream); |
758 | int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec, | 758 | int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec, |
759 | struct snd_pcm_substream *substream); | 759 | struct snd_pcm_substream *substream); |
760 | unsigned int (*get_delay)(struct hda_pcm_stream *info, | ||
761 | struct hda_codec *codec, | ||
762 | struct snd_pcm_substream *substream); | ||
760 | }; | 763 | }; |
761 | 764 | ||
762 | /* PCM information for each substream */ | 765 | /* PCM information for each substream */ |
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 2dbe767be16b..ac079f93c535 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "hda_local.h" | 34 | #include "hda_local.h" |
35 | #include "hda_auto_parser.h" | 35 | #include "hda_auto_parser.h" |
36 | #include "hda_jack.h" | 36 | #include "hda_jack.h" |
37 | #include "hda_beep.h" | ||
37 | #include "hda_generic.h" | 38 | #include "hda_generic.h" |
38 | 39 | ||
39 | 40 | ||
@@ -150,15 +151,25 @@ static void parse_user_hints(struct hda_codec *codec) | |||
150 | val = snd_hda_get_bool_hint(codec, "add_stereo_mix_input"); | 151 | val = snd_hda_get_bool_hint(codec, "add_stereo_mix_input"); |
151 | if (val >= 0) | 152 | if (val >= 0) |
152 | spec->add_stereo_mix_input = !!val; | 153 | spec->add_stereo_mix_input = !!val; |
154 | /* the following two are just for compatibility */ | ||
153 | val = snd_hda_get_bool_hint(codec, "add_out_jack_modes"); | 155 | val = snd_hda_get_bool_hint(codec, "add_out_jack_modes"); |
154 | if (val >= 0) | 156 | if (val >= 0) |
155 | spec->add_out_jack_modes = !!val; | 157 | spec->add_jack_modes = !!val; |
156 | val = snd_hda_get_bool_hint(codec, "add_in_jack_modes"); | 158 | val = snd_hda_get_bool_hint(codec, "add_in_jack_modes"); |
157 | if (val >= 0) | 159 | if (val >= 0) |
158 | spec->add_in_jack_modes = !!val; | 160 | spec->add_jack_modes = !!val; |
161 | val = snd_hda_get_bool_hint(codec, "add_jack_modes"); | ||
162 | if (val >= 0) | ||
163 | spec->add_jack_modes = !!val; | ||
159 | val = snd_hda_get_bool_hint(codec, "power_down_unused"); | 164 | val = snd_hda_get_bool_hint(codec, "power_down_unused"); |
160 | if (val >= 0) | 165 | if (val >= 0) |
161 | spec->power_down_unused = !!val; | 166 | spec->power_down_unused = !!val; |
167 | val = snd_hda_get_bool_hint(codec, "add_hp_mic"); | ||
168 | if (val >= 0) | ||
169 | spec->hp_mic = !!val; | ||
170 | val = snd_hda_get_bool_hint(codec, "hp_mic_detect"); | ||
171 | if (val >= 0) | ||
172 | spec->suppress_hp_mic_detect = !val; | ||
162 | 173 | ||
163 | if (!snd_hda_get_int_hint(codec, "mixer_nid", &val)) | 174 | if (!snd_hda_get_int_hint(codec, "mixer_nid", &val)) |
164 | spec->mixer_nid = val; | 175 | spec->mixer_nid = val; |
@@ -996,7 +1007,7 @@ enum { | |||
996 | /* Primary DAC shared with main surrounds */ | 1007 | /* Primary DAC shared with main surrounds */ |
997 | BAD_SHARED_SURROUND = 0x100, | 1008 | BAD_SHARED_SURROUND = 0x100, |
998 | /* No independent HP possible */ | 1009 | /* No independent HP possible */ |
999 | BAD_NO_INDEP_HP = 0x40, | 1010 | BAD_NO_INDEP_HP = 0x10, |
1000 | /* Primary DAC shared with main CLFE */ | 1011 | /* Primary DAC shared with main CLFE */ |
1001 | BAD_SHARED_CLFE = 0x10, | 1012 | BAD_SHARED_CLFE = 0x10, |
1002 | /* Primary DAC shared with extra surrounds */ | 1013 | /* Primary DAC shared with extra surrounds */ |
@@ -1051,16 +1062,7 @@ static int assign_out_path_ctls(struct hda_codec *codec, struct nid_path *path) | |||
1051 | return badness; | 1062 | return badness; |
1052 | } | 1063 | } |
1053 | 1064 | ||
1054 | struct badness_table { | 1065 | const struct badness_table hda_main_out_badness = { |
1055 | int no_primary_dac; /* no primary DAC */ | ||
1056 | int no_dac; /* no secondary DACs */ | ||
1057 | int shared_primary; /* primary DAC is shared with main output */ | ||
1058 | int shared_surr; /* secondary DAC shared with main or primary */ | ||
1059 | int shared_clfe; /* third DAC shared with main or primary */ | ||
1060 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ | ||
1061 | }; | ||
1062 | |||
1063 | static struct badness_table main_out_badness = { | ||
1064 | .no_primary_dac = BAD_NO_PRIMARY_DAC, | 1066 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
1065 | .no_dac = BAD_NO_DAC, | 1067 | .no_dac = BAD_NO_DAC, |
1066 | .shared_primary = BAD_NO_PRIMARY_DAC, | 1068 | .shared_primary = BAD_NO_PRIMARY_DAC, |
@@ -1068,8 +1070,9 @@ static struct badness_table main_out_badness = { | |||
1068 | .shared_clfe = BAD_SHARED_CLFE, | 1070 | .shared_clfe = BAD_SHARED_CLFE, |
1069 | .shared_surr_main = BAD_SHARED_SURROUND, | 1071 | .shared_surr_main = BAD_SHARED_SURROUND, |
1070 | }; | 1072 | }; |
1073 | EXPORT_SYMBOL_HDA(hda_main_out_badness); | ||
1071 | 1074 | ||
1072 | static struct badness_table extra_out_badness = { | 1075 | const struct badness_table hda_extra_out_badness = { |
1073 | .no_primary_dac = BAD_NO_DAC, | 1076 | .no_primary_dac = BAD_NO_DAC, |
1074 | .no_dac = BAD_NO_DAC, | 1077 | .no_dac = BAD_NO_DAC, |
1075 | .shared_primary = BAD_NO_EXTRA_DAC, | 1078 | .shared_primary = BAD_NO_EXTRA_DAC, |
@@ -1077,6 +1080,7 @@ static struct badness_table extra_out_badness = { | |||
1077 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, | 1080 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
1078 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, | 1081 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
1079 | }; | 1082 | }; |
1083 | EXPORT_SYMBOL_HDA(hda_extra_out_badness); | ||
1080 | 1084 | ||
1081 | /* get the DAC of the primary output corresponding to the given array index */ | 1085 | /* get the DAC of the primary output corresponding to the given array index */ |
1082 | static hda_nid_t get_primary_out(struct hda_codec *codec, int idx) | 1086 | static hda_nid_t get_primary_out(struct hda_codec *codec, int idx) |
@@ -1367,22 +1371,25 @@ static int check_aamix_out_path(struct hda_codec *codec, int path_idx) | |||
1367 | { | 1371 | { |
1368 | struct hda_gen_spec *spec = codec->spec; | 1372 | struct hda_gen_spec *spec = codec->spec; |
1369 | struct nid_path *path; | 1373 | struct nid_path *path; |
1370 | hda_nid_t dac, pin; | 1374 | hda_nid_t path_dac, dac, pin; |
1371 | 1375 | ||
1372 | path = snd_hda_get_path_from_idx(codec, path_idx); | 1376 | path = snd_hda_get_path_from_idx(codec, path_idx); |
1373 | if (!path || !path->depth || | 1377 | if (!path || !path->depth || |
1374 | is_nid_contained(path, spec->mixer_nid)) | 1378 | is_nid_contained(path, spec->mixer_nid)) |
1375 | return 0; | 1379 | return 0; |
1376 | dac = path->path[0]; | 1380 | path_dac = path->path[0]; |
1381 | dac = spec->private_dac_nids[0]; | ||
1377 | pin = path->path[path->depth - 1]; | 1382 | pin = path->path[path->depth - 1]; |
1378 | path = snd_hda_add_new_path(codec, dac, pin, spec->mixer_nid); | 1383 | path = snd_hda_add_new_path(codec, dac, pin, spec->mixer_nid); |
1379 | if (!path) { | 1384 | if (!path) { |
1380 | if (dac != spec->multiout.dac_nids[0]) | 1385 | if (dac != path_dac) |
1381 | dac = spec->multiout.dac_nids[0]; | 1386 | dac = path_dac; |
1382 | else if (spec->multiout.hp_out_nid[0]) | 1387 | else if (spec->multiout.hp_out_nid[0]) |
1383 | dac = spec->multiout.hp_out_nid[0]; | 1388 | dac = spec->multiout.hp_out_nid[0]; |
1384 | else if (spec->multiout.extra_out_nid[0]) | 1389 | else if (spec->multiout.extra_out_nid[0]) |
1385 | dac = spec->multiout.extra_out_nid[0]; | 1390 | dac = spec->multiout.extra_out_nid[0]; |
1391 | else | ||
1392 | dac = 0; | ||
1386 | if (dac) | 1393 | if (dac) |
1387 | path = snd_hda_add_new_path(codec, dac, pin, | 1394 | path = snd_hda_add_new_path(codec, dac, pin, |
1388 | spec->mixer_nid); | 1395 | spec->mixer_nid); |
@@ -1507,7 +1514,7 @@ static int fill_and_eval_dacs(struct hda_codec *codec, | |||
1507 | 1514 | ||
1508 | badness += try_assign_dacs(codec, cfg->line_outs, cfg->line_out_pins, | 1515 | badness += try_assign_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
1509 | spec->private_dac_nids, spec->out_paths, | 1516 | spec->private_dac_nids, spec->out_paths, |
1510 | &main_out_badness); | 1517 | spec->main_out_badness); |
1511 | 1518 | ||
1512 | if (fill_mio_first && | 1519 | if (fill_mio_first && |
1513 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { | 1520 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
@@ -1522,7 +1529,7 @@ static int fill_and_eval_dacs(struct hda_codec *codec, | |||
1522 | err = try_assign_dacs(codec, cfg->hp_outs, cfg->hp_pins, | 1529 | err = try_assign_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
1523 | spec->multiout.hp_out_nid, | 1530 | spec->multiout.hp_out_nid, |
1524 | spec->hp_paths, | 1531 | spec->hp_paths, |
1525 | &extra_out_badness); | 1532 | spec->extra_out_badness); |
1526 | if (err < 0) | 1533 | if (err < 0) |
1527 | return err; | 1534 | return err; |
1528 | badness += err; | 1535 | badness += err; |
@@ -1532,7 +1539,7 @@ static int fill_and_eval_dacs(struct hda_codec *codec, | |||
1532 | cfg->speaker_pins, | 1539 | cfg->speaker_pins, |
1533 | spec->multiout.extra_out_nid, | 1540 | spec->multiout.extra_out_nid, |
1534 | spec->speaker_paths, | 1541 | spec->speaker_paths, |
1535 | &extra_out_badness); | 1542 | spec->extra_out_badness); |
1536 | if (err < 0) | 1543 | if (err < 0) |
1537 | return err; | 1544 | return err; |
1538 | badness += err; | 1545 | badness += err; |
@@ -1926,6 +1933,17 @@ static int create_speaker_out_ctls(struct hda_codec *codec) | |||
1926 | * independent HP controls | 1933 | * independent HP controls |
1927 | */ | 1934 | */ |
1928 | 1935 | ||
1936 | /* update HP auto-mute state too */ | ||
1937 | static void update_hp_automute_hook(struct hda_codec *codec) | ||
1938 | { | ||
1939 | struct hda_gen_spec *spec = codec->spec; | ||
1940 | |||
1941 | if (spec->hp_automute_hook) | ||
1942 | spec->hp_automute_hook(codec, NULL); | ||
1943 | else | ||
1944 | snd_hda_gen_hp_automute(codec, NULL); | ||
1945 | } | ||
1946 | |||
1929 | static int indep_hp_info(struct snd_kcontrol *kcontrol, | 1947 | static int indep_hp_info(struct snd_kcontrol *kcontrol, |
1930 | struct snd_ctl_elem_info *uinfo) | 1948 | struct snd_ctl_elem_info *uinfo) |
1931 | { | 1949 | { |
@@ -1986,12 +2004,7 @@ static int indep_hp_put(struct snd_kcontrol *kcontrol, | |||
1986 | else | 2004 | else |
1987 | *dacp = spec->alt_dac_nid; | 2005 | *dacp = spec->alt_dac_nid; |
1988 | 2006 | ||
1989 | /* update HP auto-mute state too */ | 2007 | update_hp_automute_hook(codec); |
1990 | if (spec->hp_automute_hook) | ||
1991 | spec->hp_automute_hook(codec, NULL); | ||
1992 | else | ||
1993 | snd_hda_gen_hp_automute(codec, NULL); | ||
1994 | |||
1995 | ret = 1; | 2008 | ret = 1; |
1996 | } | 2009 | } |
1997 | unlock: | 2010 | unlock: |
@@ -2072,6 +2085,14 @@ get_multiio_path(struct hda_codec *codec, int idx) | |||
2072 | 2085 | ||
2073 | static void update_automute_all(struct hda_codec *codec); | 2086 | static void update_automute_all(struct hda_codec *codec); |
2074 | 2087 | ||
2088 | /* Default value to be passed as aamix argument for snd_hda_activate_path(); | ||
2089 | * used for output paths | ||
2090 | */ | ||
2091 | static bool aamix_default(struct hda_gen_spec *spec) | ||
2092 | { | ||
2093 | return !spec->have_aamix_ctl || spec->aamix_mode; | ||
2094 | } | ||
2095 | |||
2075 | static int set_multi_io(struct hda_codec *codec, int idx, bool output) | 2096 | static int set_multi_io(struct hda_codec *codec, int idx, bool output) |
2076 | { | 2097 | { |
2077 | struct hda_gen_spec *spec = codec->spec; | 2098 | struct hda_gen_spec *spec = codec->spec; |
@@ -2087,11 +2108,11 @@ static int set_multi_io(struct hda_codec *codec, int idx, bool output) | |||
2087 | 2108 | ||
2088 | if (output) { | 2109 | if (output) { |
2089 | set_pin_target(codec, nid, PIN_OUT, true); | 2110 | set_pin_target(codec, nid, PIN_OUT, true); |
2090 | snd_hda_activate_path(codec, path, true, true); | 2111 | snd_hda_activate_path(codec, path, true, aamix_default(spec)); |
2091 | set_pin_eapd(codec, nid, true); | 2112 | set_pin_eapd(codec, nid, true); |
2092 | } else { | 2113 | } else { |
2093 | set_pin_eapd(codec, nid, false); | 2114 | set_pin_eapd(codec, nid, false); |
2094 | snd_hda_activate_path(codec, path, false, true); | 2115 | snd_hda_activate_path(codec, path, false, aamix_default(spec)); |
2095 | set_pin_target(codec, nid, spec->multi_io[idx].ctl_in, true); | 2116 | set_pin_target(codec, nid, spec->multi_io[idx].ctl_in, true); |
2096 | path_power_down_sync(codec, path); | 2117 | path_power_down_sync(codec, path); |
2097 | } | 2118 | } |
@@ -2182,8 +2203,8 @@ static void update_aamix_paths(struct hda_codec *codec, bool do_mix, | |||
2182 | snd_hda_activate_path(codec, mix_path, true, true); | 2203 | snd_hda_activate_path(codec, mix_path, true, true); |
2183 | path_power_down_sync(codec, nomix_path); | 2204 | path_power_down_sync(codec, nomix_path); |
2184 | } else { | 2205 | } else { |
2185 | snd_hda_activate_path(codec, mix_path, false, true); | 2206 | snd_hda_activate_path(codec, mix_path, false, false); |
2186 | snd_hda_activate_path(codec, nomix_path, true, true); | 2207 | snd_hda_activate_path(codec, nomix_path, true, false); |
2187 | path_power_down_sync(codec, mix_path); | 2208 | path_power_down_sync(codec, mix_path); |
2188 | } | 2209 | } |
2189 | } | 2210 | } |
@@ -2240,63 +2261,95 @@ static int create_loopback_mixing_ctl(struct hda_codec *codec) | |||
2240 | static void call_update_outputs(struct hda_codec *codec); | 2261 | static void call_update_outputs(struct hda_codec *codec); |
2241 | 2262 | ||
2242 | /* for shared I/O, change the pin-control accordingly */ | 2263 | /* for shared I/O, change the pin-control accordingly */ |
2243 | static void update_shared_mic_hp(struct hda_codec *codec, bool set_as_mic) | 2264 | static void update_hp_mic(struct hda_codec *codec, int adc_mux, bool force) |
2244 | { | 2265 | { |
2245 | struct hda_gen_spec *spec = codec->spec; | 2266 | struct hda_gen_spec *spec = codec->spec; |
2267 | bool as_mic; | ||
2246 | unsigned int val; | 2268 | unsigned int val; |
2247 | hda_nid_t pin = spec->autocfg.inputs[1].pin; | 2269 | hda_nid_t pin; |
2248 | /* NOTE: this assumes that there are only two inputs, the | ||
2249 | * first is the real internal mic and the second is HP/mic jack. | ||
2250 | */ | ||
2251 | 2270 | ||
2252 | val = snd_hda_get_default_vref(codec, pin); | 2271 | pin = spec->hp_mic_pin; |
2272 | as_mic = spec->cur_mux[adc_mux] == spec->hp_mic_mux_idx; | ||
2273 | |||
2274 | if (!force) { | ||
2275 | val = snd_hda_codec_get_pin_target(codec, pin); | ||
2276 | if (as_mic) { | ||
2277 | if (val & PIN_IN) | ||
2278 | return; | ||
2279 | } else { | ||
2280 | if (val & PIN_OUT) | ||
2281 | return; | ||
2282 | } | ||
2283 | } | ||
2253 | 2284 | ||
2254 | /* This pin does not have vref caps - let's enable vref on pin 0x18 | 2285 | val = snd_hda_get_default_vref(codec, pin); |
2255 | instead, as suggested by Realtek */ | 2286 | /* if the HP pin doesn't support VREF and the codec driver gives an |
2287 | * alternative pin, set up the VREF on that pin instead | ||
2288 | */ | ||
2256 | if (val == AC_PINCTL_VREF_HIZ && spec->shared_mic_vref_pin) { | 2289 | if (val == AC_PINCTL_VREF_HIZ && spec->shared_mic_vref_pin) { |
2257 | const hda_nid_t vref_pin = spec->shared_mic_vref_pin; | 2290 | const hda_nid_t vref_pin = spec->shared_mic_vref_pin; |
2258 | unsigned int vref_val = snd_hda_get_default_vref(codec, vref_pin); | 2291 | unsigned int vref_val = snd_hda_get_default_vref(codec, vref_pin); |
2259 | if (vref_val != AC_PINCTL_VREF_HIZ) | 2292 | if (vref_val != AC_PINCTL_VREF_HIZ) |
2260 | snd_hda_set_pin_ctl_cache(codec, vref_pin, | 2293 | snd_hda_set_pin_ctl_cache(codec, vref_pin, |
2261 | PIN_IN | (set_as_mic ? vref_val : 0)); | 2294 | PIN_IN | (as_mic ? vref_val : 0)); |
2262 | } | 2295 | } |
2263 | 2296 | ||
2264 | val = set_as_mic ? val | PIN_IN : PIN_HP; | 2297 | if (!spec->hp_mic_jack_modes) { |
2265 | set_pin_target(codec, pin, val, true); | 2298 | if (as_mic) |
2266 | 2299 | val |= PIN_IN; | |
2267 | spec->automute_speaker = !set_as_mic; | 2300 | else |
2268 | call_update_outputs(codec); | 2301 | val = PIN_HP; |
2302 | set_pin_target(codec, pin, val, true); | ||
2303 | update_hp_automute_hook(codec); | ||
2304 | } | ||
2269 | } | 2305 | } |
2270 | 2306 | ||
2271 | /* create a shared input with the headphone out */ | 2307 | /* create a shared input with the headphone out */ |
2272 | static int create_shared_input(struct hda_codec *codec) | 2308 | static int create_hp_mic(struct hda_codec *codec) |
2273 | { | 2309 | { |
2274 | struct hda_gen_spec *spec = codec->spec; | 2310 | struct hda_gen_spec *spec = codec->spec; |
2275 | struct auto_pin_cfg *cfg = &spec->autocfg; | 2311 | struct auto_pin_cfg *cfg = &spec->autocfg; |
2276 | unsigned int defcfg; | 2312 | unsigned int defcfg; |
2277 | hda_nid_t nid; | 2313 | hda_nid_t nid; |
2278 | 2314 | ||
2279 | /* only one internal input pin? */ | 2315 | if (!spec->hp_mic) { |
2280 | if (cfg->num_inputs != 1) | 2316 | if (spec->suppress_hp_mic_detect) |
2281 | return 0; | 2317 | return 0; |
2282 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); | 2318 | /* automatic detection: only if no input or a single internal |
2283 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) | 2319 | * input pin is found, try to detect the shared hp/mic |
2320 | */ | ||
2321 | if (cfg->num_inputs > 1) | ||
2322 | return 0; | ||
2323 | else if (cfg->num_inputs == 1) { | ||
2324 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); | ||
2325 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) | ||
2326 | return 0; | ||
2327 | } | ||
2328 | } | ||
2329 | |||
2330 | spec->hp_mic = 0; /* clear once */ | ||
2331 | if (cfg->num_inputs >= AUTO_CFG_MAX_INS) | ||
2284 | return 0; | 2332 | return 0; |
2285 | 2333 | ||
2286 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) | 2334 | nid = 0; |
2287 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ | 2335 | if (cfg->line_out_type == AUTO_PIN_HP_OUT && cfg->line_outs > 0) |
2288 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) | 2336 | nid = cfg->line_out_pins[0]; |
2289 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ | 2337 | else if (cfg->hp_outs > 0) |
2290 | else | 2338 | nid = cfg->hp_pins[0]; |
2291 | return 0; /* both not available */ | 2339 | if (!nid) |
2340 | return 0; | ||
2292 | 2341 | ||
2293 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) | 2342 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
2294 | return 0; /* no input */ | 2343 | return 0; /* no input */ |
2295 | 2344 | ||
2296 | cfg->inputs[1].pin = nid; | 2345 | cfg->inputs[cfg->num_inputs].pin = nid; |
2297 | cfg->inputs[1].type = AUTO_PIN_MIC; | 2346 | cfg->inputs[cfg->num_inputs].type = AUTO_PIN_MIC; |
2298 | cfg->num_inputs = 2; | 2347 | cfg->inputs[cfg->num_inputs].is_headphone_mic = 1; |
2299 | spec->shared_mic_hp = 1; | 2348 | cfg->num_inputs++; |
2349 | spec->hp_mic = 1; | ||
2350 | spec->hp_mic_pin = nid; | ||
2351 | /* we can't handle auto-mic together with HP-mic */ | ||
2352 | spec->suppress_auto_mic = 1; | ||
2300 | snd_printdd("hda-codec: Enable shared I/O jack on NID 0x%x\n", nid); | 2353 | snd_printdd("hda-codec: Enable shared I/O jack on NID 0x%x\n", nid); |
2301 | return 0; | 2354 | return 0; |
2302 | } | 2355 | } |
@@ -2304,13 +2357,17 @@ static int create_shared_input(struct hda_codec *codec) | |||
2304 | /* | 2357 | /* |
2305 | * output jack mode | 2358 | * output jack mode |
2306 | */ | 2359 | */ |
2360 | |||
2361 | static int create_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t pin); | ||
2362 | |||
2363 | static const char * const out_jack_texts[] = { | ||
2364 | "Line Out", "Headphone Out", | ||
2365 | }; | ||
2366 | |||
2307 | static int out_jack_mode_info(struct snd_kcontrol *kcontrol, | 2367 | static int out_jack_mode_info(struct snd_kcontrol *kcontrol, |
2308 | struct snd_ctl_elem_info *uinfo) | 2368 | struct snd_ctl_elem_info *uinfo) |
2309 | { | 2369 | { |
2310 | static const char * const texts[] = { | 2370 | return snd_hda_enum_helper_info(kcontrol, uinfo, 2, out_jack_texts); |
2311 | "Line Out", "Headphone Out", | ||
2312 | }; | ||
2313 | return snd_hda_enum_helper_info(kcontrol, uinfo, 2, texts); | ||
2314 | } | 2371 | } |
2315 | 2372 | ||
2316 | static int out_jack_mode_get(struct snd_kcontrol *kcontrol, | 2373 | static int out_jack_mode_get(struct snd_kcontrol *kcontrol, |
@@ -2372,6 +2429,17 @@ static void get_jack_mode_name(struct hda_codec *codec, hda_nid_t pin, | |||
2372 | ; | 2429 | ; |
2373 | } | 2430 | } |
2374 | 2431 | ||
2432 | static int get_out_jack_num_items(struct hda_codec *codec, hda_nid_t pin) | ||
2433 | { | ||
2434 | struct hda_gen_spec *spec = codec->spec; | ||
2435 | if (spec->add_jack_modes) { | ||
2436 | unsigned int pincap = snd_hda_query_pin_caps(codec, pin); | ||
2437 | if ((pincap & AC_PINCAP_OUT) && (pincap & AC_PINCAP_HP_DRV)) | ||
2438 | return 2; | ||
2439 | } | ||
2440 | return 1; | ||
2441 | } | ||
2442 | |||
2375 | static int create_out_jack_modes(struct hda_codec *codec, int num_pins, | 2443 | static int create_out_jack_modes(struct hda_codec *codec, int num_pins, |
2376 | hda_nid_t *pins) | 2444 | hda_nid_t *pins) |
2377 | { | 2445 | { |
@@ -2380,8 +2448,13 @@ static int create_out_jack_modes(struct hda_codec *codec, int num_pins, | |||
2380 | 2448 | ||
2381 | for (i = 0; i < num_pins; i++) { | 2449 | for (i = 0; i < num_pins; i++) { |
2382 | hda_nid_t pin = pins[i]; | 2450 | hda_nid_t pin = pins[i]; |
2383 | unsigned int pincap = snd_hda_query_pin_caps(codec, pin); | 2451 | if (pin == spec->hp_mic_pin) { |
2384 | if ((pincap & AC_PINCAP_OUT) && (pincap & AC_PINCAP_HP_DRV)) { | 2452 | int ret = create_hp_mic_jack_mode(codec, pin); |
2453 | if (ret < 0) | ||
2454 | return ret; | ||
2455 | continue; | ||
2456 | } | ||
2457 | if (get_out_jack_num_items(codec, pin) > 1) { | ||
2385 | struct snd_kcontrol_new *knew; | 2458 | struct snd_kcontrol_new *knew; |
2386 | char name[44]; | 2459 | char name[44]; |
2387 | get_jack_mode_name(codec, pin, name, sizeof(name)); | 2460 | get_jack_mode_name(codec, pin, name, sizeof(name)); |
@@ -2502,12 +2575,24 @@ static const struct snd_kcontrol_new in_jack_mode_enum = { | |||
2502 | .put = in_jack_mode_put, | 2575 | .put = in_jack_mode_put, |
2503 | }; | 2576 | }; |
2504 | 2577 | ||
2578 | static int get_in_jack_num_items(struct hda_codec *codec, hda_nid_t pin) | ||
2579 | { | ||
2580 | struct hda_gen_spec *spec = codec->spec; | ||
2581 | int nitems = 0; | ||
2582 | if (spec->add_jack_modes) | ||
2583 | nitems = hweight32(get_vref_caps(codec, pin)); | ||
2584 | return nitems ? nitems : 1; | ||
2585 | } | ||
2586 | |||
2505 | static int create_in_jack_mode(struct hda_codec *codec, hda_nid_t pin) | 2587 | static int create_in_jack_mode(struct hda_codec *codec, hda_nid_t pin) |
2506 | { | 2588 | { |
2507 | struct hda_gen_spec *spec = codec->spec; | 2589 | struct hda_gen_spec *spec = codec->spec; |
2508 | unsigned int defcfg; | ||
2509 | struct snd_kcontrol_new *knew; | 2590 | struct snd_kcontrol_new *knew; |
2510 | char name[44]; | 2591 | char name[44]; |
2592 | unsigned int defcfg; | ||
2593 | |||
2594 | if (pin == spec->hp_mic_pin) | ||
2595 | return 0; /* already done in create_out_jack_mode() */ | ||
2511 | 2596 | ||
2512 | /* no jack mode for fixed pins */ | 2597 | /* no jack mode for fixed pins */ |
2513 | defcfg = snd_hda_codec_get_pincfg(codec, pin); | 2598 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
@@ -2515,7 +2600,7 @@ static int create_in_jack_mode(struct hda_codec *codec, hda_nid_t pin) | |||
2515 | return 0; | 2600 | return 0; |
2516 | 2601 | ||
2517 | /* no multiple vref caps? */ | 2602 | /* no multiple vref caps? */ |
2518 | if (hweight32(get_vref_caps(codec, pin)) <= 1) | 2603 | if (get_in_jack_num_items(codec, pin) <= 1) |
2519 | return 0; | 2604 | return 0; |
2520 | 2605 | ||
2521 | get_jack_mode_name(codec, pin, name, sizeof(name)); | 2606 | get_jack_mode_name(codec, pin, name, sizeof(name)); |
@@ -2526,6 +2611,132 @@ static int create_in_jack_mode(struct hda_codec *codec, hda_nid_t pin) | |||
2526 | return 0; | 2611 | return 0; |
2527 | } | 2612 | } |
2528 | 2613 | ||
2614 | /* | ||
2615 | * HP/mic shared jack mode | ||
2616 | */ | ||
2617 | static int hp_mic_jack_mode_info(struct snd_kcontrol *kcontrol, | ||
2618 | struct snd_ctl_elem_info *uinfo) | ||
2619 | { | ||
2620 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2621 | hda_nid_t nid = kcontrol->private_value; | ||
2622 | int out_jacks = get_out_jack_num_items(codec, nid); | ||
2623 | int in_jacks = get_in_jack_num_items(codec, nid); | ||
2624 | const char *text = NULL; | ||
2625 | int idx; | ||
2626 | |||
2627 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
2628 | uinfo->count = 1; | ||
2629 | uinfo->value.enumerated.items = out_jacks + in_jacks; | ||
2630 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
2631 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | ||
2632 | idx = uinfo->value.enumerated.item; | ||
2633 | if (idx < out_jacks) { | ||
2634 | if (out_jacks > 1) | ||
2635 | text = out_jack_texts[idx]; | ||
2636 | else | ||
2637 | text = "Headphone Out"; | ||
2638 | } else { | ||
2639 | idx -= out_jacks; | ||
2640 | if (in_jacks > 1) { | ||
2641 | unsigned int vref_caps = get_vref_caps(codec, nid); | ||
2642 | text = vref_texts[get_vref_idx(vref_caps, idx)]; | ||
2643 | } else | ||
2644 | text = "Mic In"; | ||
2645 | } | ||
2646 | |||
2647 | strcpy(uinfo->value.enumerated.name, text); | ||
2648 | return 0; | ||
2649 | } | ||
2650 | |||
2651 | static int get_cur_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t nid) | ||
2652 | { | ||
2653 | int out_jacks = get_out_jack_num_items(codec, nid); | ||
2654 | int in_jacks = get_in_jack_num_items(codec, nid); | ||
2655 | unsigned int val = snd_hda_codec_get_pin_target(codec, nid); | ||
2656 | int idx = 0; | ||
2657 | |||
2658 | if (val & PIN_OUT) { | ||
2659 | if (out_jacks > 1 && val == PIN_HP) | ||
2660 | idx = 1; | ||
2661 | } else if (val & PIN_IN) { | ||
2662 | idx = out_jacks; | ||
2663 | if (in_jacks > 1) { | ||
2664 | unsigned int vref_caps = get_vref_caps(codec, nid); | ||
2665 | val &= AC_PINCTL_VREFEN; | ||
2666 | idx += cvt_from_vref_idx(vref_caps, val); | ||
2667 | } | ||
2668 | } | ||
2669 | return idx; | ||
2670 | } | ||
2671 | |||
2672 | static int hp_mic_jack_mode_get(struct snd_kcontrol *kcontrol, | ||
2673 | struct snd_ctl_elem_value *ucontrol) | ||
2674 | { | ||
2675 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2676 | hda_nid_t nid = kcontrol->private_value; | ||
2677 | ucontrol->value.enumerated.item[0] = | ||
2678 | get_cur_hp_mic_jack_mode(codec, nid); | ||
2679 | return 0; | ||
2680 | } | ||
2681 | |||
2682 | static int hp_mic_jack_mode_put(struct snd_kcontrol *kcontrol, | ||
2683 | struct snd_ctl_elem_value *ucontrol) | ||
2684 | { | ||
2685 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
2686 | hda_nid_t nid = kcontrol->private_value; | ||
2687 | int out_jacks = get_out_jack_num_items(codec, nid); | ||
2688 | int in_jacks = get_in_jack_num_items(codec, nid); | ||
2689 | unsigned int val, oldval, idx; | ||
2690 | |||
2691 | oldval = get_cur_hp_mic_jack_mode(codec, nid); | ||
2692 | idx = ucontrol->value.enumerated.item[0]; | ||
2693 | if (oldval == idx) | ||
2694 | return 0; | ||
2695 | |||
2696 | if (idx < out_jacks) { | ||
2697 | if (out_jacks > 1) | ||
2698 | val = idx ? PIN_HP : PIN_OUT; | ||
2699 | else | ||
2700 | val = PIN_HP; | ||
2701 | } else { | ||
2702 | idx -= out_jacks; | ||
2703 | if (in_jacks > 1) { | ||
2704 | unsigned int vref_caps = get_vref_caps(codec, nid); | ||
2705 | val = snd_hda_codec_get_pin_target(codec, nid); | ||
2706 | val &= ~(AC_PINCTL_VREFEN | PIN_HP); | ||
2707 | val |= get_vref_idx(vref_caps, idx) | PIN_IN; | ||
2708 | } else | ||
2709 | val = snd_hda_get_default_vref(codec, nid); | ||
2710 | } | ||
2711 | snd_hda_set_pin_ctl_cache(codec, nid, val); | ||
2712 | update_hp_automute_hook(codec); | ||
2713 | |||
2714 | return 1; | ||
2715 | } | ||
2716 | |||
2717 | static const struct snd_kcontrol_new hp_mic_jack_mode_enum = { | ||
2718 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2719 | .info = hp_mic_jack_mode_info, | ||
2720 | .get = hp_mic_jack_mode_get, | ||
2721 | .put = hp_mic_jack_mode_put, | ||
2722 | }; | ||
2723 | |||
2724 | static int create_hp_mic_jack_mode(struct hda_codec *codec, hda_nid_t pin) | ||
2725 | { | ||
2726 | struct hda_gen_spec *spec = codec->spec; | ||
2727 | struct snd_kcontrol_new *knew; | ||
2728 | |||
2729 | if (get_out_jack_num_items(codec, pin) <= 1 && | ||
2730 | get_in_jack_num_items(codec, pin) <= 1) | ||
2731 | return 0; /* no need */ | ||
2732 | knew = snd_hda_gen_add_kctl(spec, "Headphone Mic Jack Mode", | ||
2733 | &hp_mic_jack_mode_enum); | ||
2734 | if (!knew) | ||
2735 | return -ENOMEM; | ||
2736 | knew->private_value = pin; | ||
2737 | spec->hp_mic_jack_modes = 1; | ||
2738 | return 0; | ||
2739 | } | ||
2529 | 2740 | ||
2530 | /* | 2741 | /* |
2531 | * Parse input paths | 2742 | * Parse input paths |
@@ -2648,7 +2859,6 @@ static int check_dyn_adc_switch(struct hda_codec *codec) | |||
2648 | unsigned int ok_bits; | 2859 | unsigned int ok_bits; |
2649 | int i, n, nums; | 2860 | int i, n, nums; |
2650 | 2861 | ||
2651 | again: | ||
2652 | nums = 0; | 2862 | nums = 0; |
2653 | ok_bits = 0; | 2863 | ok_bits = 0; |
2654 | for (n = 0; n < spec->num_adc_nids; n++) { | 2864 | for (n = 0; n < spec->num_adc_nids; n++) { |
@@ -2663,12 +2873,6 @@ static int check_dyn_adc_switch(struct hda_codec *codec) | |||
2663 | } | 2873 | } |
2664 | 2874 | ||
2665 | if (!ok_bits) { | 2875 | if (!ok_bits) { |
2666 | if (spec->shared_mic_hp) { | ||
2667 | spec->shared_mic_hp = 0; | ||
2668 | imux->num_items = 1; | ||
2669 | goto again; | ||
2670 | } | ||
2671 | |||
2672 | /* check whether ADC-switch is possible */ | 2876 | /* check whether ADC-switch is possible */ |
2673 | for (i = 0; i < imux->num_items; i++) { | 2877 | for (i = 0; i < imux->num_items; i++) { |
2674 | for (n = 0; n < spec->num_adc_nids; n++) { | 2878 | for (n = 0; n < spec->num_adc_nids; n++) { |
@@ -2701,7 +2905,8 @@ static int check_dyn_adc_switch(struct hda_codec *codec) | |||
2701 | spec->num_adc_nids = nums; | 2905 | spec->num_adc_nids = nums; |
2702 | } | 2906 | } |
2703 | 2907 | ||
2704 | if (imux->num_items == 1 || spec->shared_mic_hp) { | 2908 | if (imux->num_items == 1 || |
2909 | (imux->num_items == 2 && spec->hp_mic)) { | ||
2705 | snd_printdd("hda-codec: reducing to a single ADC\n"); | 2910 | snd_printdd("hda-codec: reducing to a single ADC\n"); |
2706 | spec->num_adc_nids = 1; /* reduce to a single ADC */ | 2911 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
2707 | } | 2912 | } |
@@ -2738,6 +2943,8 @@ static int parse_capture_source(struct hda_codec *codec, hda_nid_t pin, | |||
2738 | snd_hda_get_path_idx(codec, path); | 2943 | snd_hda_get_path_idx(codec, path); |
2739 | 2944 | ||
2740 | if (!imux_added) { | 2945 | if (!imux_added) { |
2946 | if (spec->hp_mic_pin == pin) | ||
2947 | spec->hp_mic_mux_idx = imux->num_items; | ||
2741 | spec->imux_pins[imux->num_items] = pin; | 2948 | spec->imux_pins[imux->num_items] = pin; |
2742 | snd_hda_add_imux_item(imux, label, cfg_idx, NULL); | 2949 | snd_hda_add_imux_item(imux, label, cfg_idx, NULL); |
2743 | imux_added = true; | 2950 | imux_added = true; |
@@ -2812,7 +3019,8 @@ static int create_input_ctls(struct hda_codec *codec) | |||
2812 | val = PIN_IN; | 3019 | val = PIN_IN; |
2813 | if (cfg->inputs[i].type == AUTO_PIN_MIC) | 3020 | if (cfg->inputs[i].type == AUTO_PIN_MIC) |
2814 | val |= snd_hda_get_default_vref(codec, pin); | 3021 | val |= snd_hda_get_default_vref(codec, pin); |
2815 | set_pin_target(codec, pin, val, false); | 3022 | if (pin != spec->hp_mic_pin) |
3023 | set_pin_target(codec, pin, val, false); | ||
2816 | 3024 | ||
2817 | if (mixer) { | 3025 | if (mixer) { |
2818 | if (is_reachable_path(codec, pin, mixer)) { | 3026 | if (is_reachable_path(codec, pin, mixer)) { |
@@ -2830,7 +3038,7 @@ static int create_input_ctls(struct hda_codec *codec) | |||
2830 | if (err < 0) | 3038 | if (err < 0) |
2831 | return err; | 3039 | return err; |
2832 | 3040 | ||
2833 | if (spec->add_in_jack_modes) { | 3041 | if (spec->add_jack_modes) { |
2834 | err = create_in_jack_mode(codec, pin); | 3042 | err = create_in_jack_mode(codec, pin); |
2835 | if (err < 0) | 3043 | if (err < 0) |
2836 | return err; | 3044 | return err; |
@@ -3462,8 +3670,8 @@ static int mux_select(struct hda_codec *codec, unsigned int adc_idx, | |||
3462 | 3670 | ||
3463 | spec->cur_mux[adc_idx] = idx; | 3671 | spec->cur_mux[adc_idx] = idx; |
3464 | 3672 | ||
3465 | if (spec->shared_mic_hp) | 3673 | if (spec->hp_mic) |
3466 | update_shared_mic_hp(codec, spec->cur_mux[adc_idx]); | 3674 | update_hp_mic(codec, adc_idx, false); |
3467 | 3675 | ||
3468 | if (spec->dyn_adc_switch) | 3676 | if (spec->dyn_adc_switch) |
3469 | dyn_adc_pcm_resetup(codec, idx); | 3677 | dyn_adc_pcm_resetup(codec, idx); |
@@ -3511,18 +3719,21 @@ static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins, | |||
3511 | 3719 | ||
3512 | for (i = 0; i < num_pins; i++) { | 3720 | for (i = 0; i < num_pins; i++) { |
3513 | hda_nid_t nid = pins[i]; | 3721 | hda_nid_t nid = pins[i]; |
3514 | unsigned int val; | 3722 | unsigned int val, oldval; |
3515 | if (!nid) | 3723 | if (!nid) |
3516 | break; | 3724 | break; |
3725 | oldval = snd_hda_codec_get_pin_target(codec, nid); | ||
3726 | if (oldval & PIN_IN) | ||
3727 | continue; /* no mute for inputs */ | ||
3517 | /* don't reset VREF value in case it's controlling | 3728 | /* don't reset VREF value in case it's controlling |
3518 | * the amp (see alc861_fixup_asus_amp_vref_0f()) | 3729 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
3519 | */ | 3730 | */ |
3520 | if (spec->keep_vref_in_automute) | 3731 | if (spec->keep_vref_in_automute) |
3521 | val = snd_hda_codec_get_pin_target(codec, nid) & ~PIN_HP; | 3732 | val = oldval & ~PIN_HP; |
3522 | else | 3733 | else |
3523 | val = 0; | 3734 | val = 0; |
3524 | if (!mute) | 3735 | if (!mute) |
3525 | val |= snd_hda_codec_get_pin_target(codec, nid); | 3736 | val |= oldval; |
3526 | /* here we call update_pin_ctl() so that the pinctl is changed | 3737 | /* here we call update_pin_ctl() so that the pinctl is changed |
3527 | * without changing the pinctl target value; | 3738 | * without changing the pinctl target value; |
3528 | * the original target value will be still referred at the | 3739 | * the original target value will be still referred at the |
@@ -3543,8 +3754,7 @@ void snd_hda_gen_update_outputs(struct hda_codec *codec) | |||
3543 | * in general, HP pins/amps control should be enabled in all cases, | 3754 | * in general, HP pins/amps control should be enabled in all cases, |
3544 | * but currently set only for master_mute, just to be safe | 3755 | * but currently set only for master_mute, just to be safe |
3545 | */ | 3756 | */ |
3546 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ | 3757 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
3547 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), | ||
3548 | spec->autocfg.hp_pins, spec->master_mute); | 3758 | spec->autocfg.hp_pins, spec->master_mute); |
3549 | 3759 | ||
3550 | if (!spec->automute_speaker) | 3760 | if (!spec->automute_speaker) |
@@ -3649,10 +3859,7 @@ static void update_automute_all(struct hda_codec *codec) | |||
3649 | { | 3859 | { |
3650 | struct hda_gen_spec *spec = codec->spec; | 3860 | struct hda_gen_spec *spec = codec->spec; |
3651 | 3861 | ||
3652 | if (spec->hp_automute_hook) | 3862 | update_hp_automute_hook(codec); |
3653 | spec->hp_automute_hook(codec, NULL); | ||
3654 | else | ||
3655 | snd_hda_gen_hp_automute(codec, NULL); | ||
3656 | if (spec->line_automute_hook) | 3863 | if (spec->line_automute_hook) |
3657 | spec->line_automute_hook(codec, NULL); | 3864 | spec->line_automute_hook(codec, NULL); |
3658 | else | 3865 | else |
@@ -3978,6 +4185,11 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec, | |||
3978 | cfg = &spec->autocfg; | 4185 | cfg = &spec->autocfg; |
3979 | } | 4186 | } |
3980 | 4187 | ||
4188 | if (!spec->main_out_badness) | ||
4189 | spec->main_out_badness = &hda_main_out_badness; | ||
4190 | if (!spec->extra_out_badness) | ||
4191 | spec->extra_out_badness = &hda_extra_out_badness; | ||
4192 | |||
3981 | fill_all_dac_nids(codec); | 4193 | fill_all_dac_nids(codec); |
3982 | 4194 | ||
3983 | if (!cfg->line_outs) { | 4195 | if (!cfg->line_outs) { |
@@ -4024,7 +4236,7 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec, | |||
4024 | err = create_loopback_mixing_ctl(codec); | 4236 | err = create_loopback_mixing_ctl(codec); |
4025 | if (err < 0) | 4237 | if (err < 0) |
4026 | return err; | 4238 | return err; |
4027 | err = create_shared_input(codec); | 4239 | err = create_hp_mic(codec); |
4028 | if (err < 0) | 4240 | if (err < 0) |
4029 | return err; | 4241 | return err; |
4030 | err = create_input_ctls(codec); | 4242 | err = create_input_ctls(codec); |
@@ -4050,11 +4262,9 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec, | |||
4050 | if (err < 0) | 4262 | if (err < 0) |
4051 | return err; | 4263 | return err; |
4052 | 4264 | ||
4053 | if (!spec->shared_mic_hp) { | 4265 | err = check_auto_mic_availability(codec); |
4054 | err = check_auto_mic_availability(codec); | 4266 | if (err < 0) |
4055 | if (err < 0) | 4267 | return err; |
4056 | return err; | ||
4057 | } | ||
4058 | 4268 | ||
4059 | err = create_capture_mixers(codec); | 4269 | err = create_capture_mixers(codec); |
4060 | if (err < 0) | 4270 | if (err < 0) |
@@ -4064,7 +4274,7 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec, | |||
4064 | if (err < 0) | 4274 | if (err < 0) |
4065 | return err; | 4275 | return err; |
4066 | 4276 | ||
4067 | if (spec->add_out_jack_modes) { | 4277 | if (spec->add_jack_modes) { |
4068 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { | 4278 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
4069 | err = create_out_jack_modes(codec, cfg->line_outs, | 4279 | err = create_out_jack_modes(codec, cfg->line_outs, |
4070 | cfg->line_out_pins); | 4280 | cfg->line_out_pins); |
@@ -4085,6 +4295,12 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec, | |||
4085 | if (spec->power_down_unused) | 4295 | if (spec->power_down_unused) |
4086 | codec->power_filter = snd_hda_gen_path_power_filter; | 4296 | codec->power_filter = snd_hda_gen_path_power_filter; |
4087 | 4297 | ||
4298 | if (!spec->no_analog && spec->beep_nid) { | ||
4299 | err = snd_hda_attach_beep_device(codec, spec->beep_nid); | ||
4300 | if (err < 0) | ||
4301 | return err; | ||
4302 | } | ||
4303 | |||
4088 | return 1; | 4304 | return 1; |
4089 | } | 4305 | } |
4090 | EXPORT_SYMBOL_HDA(snd_hda_gen_parse_auto_config); | 4306 | EXPORT_SYMBOL_HDA(snd_hda_gen_parse_auto_config); |
@@ -4161,17 +4377,6 @@ int snd_hda_gen_build_controls(struct hda_codec *codec) | |||
4161 | 4377 | ||
4162 | free_kctls(spec); /* no longer needed */ | 4378 | free_kctls(spec); /* no longer needed */ |
4163 | 4379 | ||
4164 | if (spec->shared_mic_hp) { | ||
4165 | int err; | ||
4166 | int nid = spec->autocfg.inputs[1].pin; | ||
4167 | err = snd_hda_jack_add_kctl(codec, nid, "Headphone Mic", 0); | ||
4168 | if (err < 0) | ||
4169 | return err; | ||
4170 | err = snd_hda_jack_detect_enable(codec, nid, 0); | ||
4171 | if (err < 0) | ||
4172 | return err; | ||
4173 | } | ||
4174 | |||
4175 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); | 4380 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
4176 | if (err < 0) | 4381 | if (err < 0) |
4177 | return err; | 4382 | return err; |
@@ -4729,7 +4934,8 @@ static void set_output_and_unmute(struct hda_codec *codec, int path_idx) | |||
4729 | return; | 4934 | return; |
4730 | pin = path->path[path->depth - 1]; | 4935 | pin = path->path[path->depth - 1]; |
4731 | restore_pin_ctl(codec, pin); | 4936 | restore_pin_ctl(codec, pin); |
4732 | snd_hda_activate_path(codec, path, path->active, true); | 4937 | snd_hda_activate_path(codec, path, path->active, |
4938 | aamix_default(codec->spec)); | ||
4733 | set_pin_eapd(codec, pin, path->active); | 4939 | set_pin_eapd(codec, pin, path->active); |
4734 | } | 4940 | } |
4735 | 4941 | ||
@@ -4779,7 +4985,8 @@ static void init_multi_io(struct hda_codec *codec) | |||
4779 | if (!spec->multi_io[i].ctl_in) | 4985 | if (!spec->multi_io[i].ctl_in) |
4780 | spec->multi_io[i].ctl_in = | 4986 | spec->multi_io[i].ctl_in = |
4781 | snd_hda_codec_get_pin_target(codec, pin); | 4987 | snd_hda_codec_get_pin_target(codec, pin); |
4782 | snd_hda_activate_path(codec, path, path->active, true); | 4988 | snd_hda_activate_path(codec, path, path->active, |
4989 | aamix_default(spec)); | ||
4783 | } | 4990 | } |
4784 | } | 4991 | } |
4785 | 4992 | ||
@@ -4826,11 +5033,10 @@ static void init_input_src(struct hda_codec *codec) | |||
4826 | snd_hda_activate_path(codec, path, active, false); | 5033 | snd_hda_activate_path(codec, path, active, false); |
4827 | } | 5034 | } |
4828 | } | 5035 | } |
5036 | if (spec->hp_mic) | ||
5037 | update_hp_mic(codec, c, true); | ||
4829 | } | 5038 | } |
4830 | 5039 | ||
4831 | if (spec->shared_mic_hp) | ||
4832 | update_shared_mic_hp(codec, spec->cur_mux[0]); | ||
4833 | |||
4834 | if (spec->cap_sync_hook) | 5040 | if (spec->cap_sync_hook) |
4835 | spec->cap_sync_hook(codec, NULL); | 5041 | spec->cap_sync_hook(codec, NULL); |
4836 | } | 5042 | } |
@@ -4911,6 +5117,7 @@ EXPORT_SYMBOL_HDA(snd_hda_gen_init); | |||
4911 | */ | 5117 | */ |
4912 | void snd_hda_gen_free(struct hda_codec *codec) | 5118 | void snd_hda_gen_free(struct hda_codec *codec) |
4913 | { | 5119 | { |
5120 | snd_hda_detach_beep_device(codec); | ||
4914 | snd_hda_gen_spec_free(codec->spec); | 5121 | snd_hda_gen_spec_free(codec->spec); |
4915 | kfree(codec->spec); | 5122 | kfree(codec->spec); |
4916 | codec->spec = NULL; | 5123 | codec->spec = NULL; |
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h index 009b57be96d3..54e665160379 100644 --- a/sound/pci/hda/hda_generic.h +++ b/sound/pci/hda/hda_generic.h | |||
@@ -76,6 +76,19 @@ enum { | |||
76 | HDA_GEN_PCM_ACT_CLOSE, | 76 | HDA_GEN_PCM_ACT_CLOSE, |
77 | }; | 77 | }; |
78 | 78 | ||
79 | /* DAC assignment badness table */ | ||
80 | struct badness_table { | ||
81 | int no_primary_dac; /* no primary DAC */ | ||
82 | int no_dac; /* no secondary DACs */ | ||
83 | int shared_primary; /* primary DAC is shared with main output */ | ||
84 | int shared_surr; /* secondary DAC shared with main or primary */ | ||
85 | int shared_clfe; /* third DAC shared with main or primary */ | ||
86 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ | ||
87 | }; | ||
88 | |||
89 | extern const struct badness_table hda_main_out_badness; | ||
90 | extern const struct badness_table hda_extra_out_badness; | ||
91 | |||
79 | struct hda_gen_spec { | 92 | struct hda_gen_spec { |
80 | char stream_name_analog[32]; /* analog PCM stream */ | 93 | char stream_name_analog[32]; /* analog PCM stream */ |
81 | const struct hda_pcm_stream *stream_analog_playback; | 94 | const struct hda_pcm_stream *stream_analog_playback; |
@@ -145,7 +158,10 @@ struct hda_gen_spec { | |||
145 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; | 158 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
146 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; | 159 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
147 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; | 160 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
161 | /* shared hp/mic */ | ||
148 | hda_nid_t shared_mic_vref_pin; | 162 | hda_nid_t shared_mic_vref_pin; |
163 | hda_nid_t hp_mic_pin; | ||
164 | int hp_mic_mux_idx; | ||
149 | 165 | ||
150 | /* DAC/ADC lists */ | 166 | /* DAC/ADC lists */ |
151 | int num_all_dacs; | 167 | int num_all_dacs; |
@@ -200,7 +216,8 @@ struct hda_gen_spec { | |||
200 | 216 | ||
201 | /* other parse behavior flags */ | 217 | /* other parse behavior flags */ |
202 | unsigned int need_dac_fix:1; /* need to limit DACs for multi channels */ | 218 | unsigned int need_dac_fix:1; /* need to limit DACs for multi channels */ |
203 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ | 219 | unsigned int hp_mic:1; /* Allow HP as a mic-in */ |
220 | unsigned int suppress_hp_mic_detect:1; /* Don't detect HP/mic */ | ||
204 | unsigned int no_primary_hp:1; /* Don't prefer HP pins to speaker pins */ | 221 | unsigned int no_primary_hp:1; /* Don't prefer HP pins to speaker pins */ |
205 | unsigned int multi_cap_vol:1; /* allow multiple capture xxx volumes */ | 222 | unsigned int multi_cap_vol:1; /* allow multiple capture xxx volumes */ |
206 | unsigned int inv_dmic_split:1; /* inverted dmic w/a for conexant */ | 223 | unsigned int inv_dmic_split:1; /* inverted dmic w/a for conexant */ |
@@ -209,8 +226,7 @@ struct hda_gen_spec { | |||
209 | unsigned int indep_hp:1; /* independent HP supported */ | 226 | unsigned int indep_hp:1; /* independent HP supported */ |
210 | unsigned int prefer_hp_amp:1; /* enable HP amp for speaker if any */ | 227 | unsigned int prefer_hp_amp:1; /* enable HP amp for speaker if any */ |
211 | unsigned int add_stereo_mix_input:1; /* add aamix as a capture src */ | 228 | unsigned int add_stereo_mix_input:1; /* add aamix as a capture src */ |
212 | unsigned int add_out_jack_modes:1; /* add output jack mode enum ctls */ | 229 | unsigned int add_jack_modes:1; /* add i/o jack mode enum ctls */ |
213 | unsigned int add_in_jack_modes:1; /* add input jack mode enum ctls */ | ||
214 | unsigned int power_down_unused:1; /* power down unused widgets */ | 230 | unsigned int power_down_unused:1; /* power down unused widgets */ |
215 | 231 | ||
216 | /* other internal flags */ | 232 | /* other internal flags */ |
@@ -218,10 +234,18 @@ struct hda_gen_spec { | |||
218 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ | 234 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
219 | unsigned int indep_hp_enabled:1; /* independent HP enabled */ | 235 | unsigned int indep_hp_enabled:1; /* independent HP enabled */ |
220 | unsigned int have_aamix_ctl:1; | 236 | unsigned int have_aamix_ctl:1; |
237 | unsigned int hp_mic_jack_modes:1; | ||
238 | |||
239 | /* badness tables for output path evaluations */ | ||
240 | const struct badness_table *main_out_badness; | ||
241 | const struct badness_table *extra_out_badness; | ||
221 | 242 | ||
222 | /* loopback mixing mode */ | 243 | /* loopback mixing mode */ |
223 | bool aamix_mode; | 244 | bool aamix_mode; |
224 | 245 | ||
246 | /* digital beep */ | ||
247 | hda_nid_t beep_nid; | ||
248 | |||
225 | /* for virtual master */ | 249 | /* for virtual master */ |
226 | hda_nid_t vmaster_nid; | 250 | hda_nid_t vmaster_nid; |
227 | unsigned int vmaster_tlv[4]; | 251 | unsigned int vmaster_tlv[4]; |
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index bcd40ee488e3..7b213d589ef6 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -1889,6 +1889,26 @@ static void azx_timecounter_init(struct snd_pcm_substream *substream, | |||
1889 | tc->cycle_last = last; | 1889 | tc->cycle_last = last; |
1890 | } | 1890 | } |
1891 | 1891 | ||
1892 | static u64 azx_adjust_codec_delay(struct snd_pcm_substream *substream, | ||
1893 | u64 nsec) | ||
1894 | { | ||
1895 | struct azx_pcm *apcm = snd_pcm_substream_chip(substream); | ||
1896 | struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; | ||
1897 | u64 codec_frames, codec_nsecs; | ||
1898 | |||
1899 | if (!hinfo->ops.get_delay) | ||
1900 | return nsec; | ||
1901 | |||
1902 | codec_frames = hinfo->ops.get_delay(hinfo, apcm->codec, substream); | ||
1903 | codec_nsecs = div_u64(codec_frames * 1000000000LL, | ||
1904 | substream->runtime->rate); | ||
1905 | |||
1906 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
1907 | return nsec + codec_nsecs; | ||
1908 | |||
1909 | return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0; | ||
1910 | } | ||
1911 | |||
1892 | static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream, | 1912 | static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream, |
1893 | struct timespec *ts) | 1913 | struct timespec *ts) |
1894 | { | 1914 | { |
@@ -1897,6 +1917,7 @@ static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream, | |||
1897 | 1917 | ||
1898 | nsec = timecounter_read(&azx_dev->azx_tc); | 1918 | nsec = timecounter_read(&azx_dev->azx_tc); |
1899 | nsec = div_u64(nsec, 3); /* can be optimized */ | 1919 | nsec = div_u64(nsec, 3); /* can be optimized */ |
1920 | nsec = azx_adjust_codec_delay(substream, nsec); | ||
1900 | 1921 | ||
1901 | *ts = ns_to_timespec(nsec); | 1922 | *ts = ns_to_timespec(nsec); |
1902 | 1923 | ||
@@ -2349,8 +2370,11 @@ static unsigned int azx_get_position(struct azx *chip, | |||
2349 | struct azx_dev *azx_dev, | 2370 | struct azx_dev *azx_dev, |
2350 | bool with_check) | 2371 | bool with_check) |
2351 | { | 2372 | { |
2373 | struct snd_pcm_substream *substream = azx_dev->substream; | ||
2374 | struct azx_pcm *apcm = snd_pcm_substream_chip(substream); | ||
2352 | unsigned int pos; | 2375 | unsigned int pos; |
2353 | int stream = azx_dev->substream->stream; | 2376 | int stream = substream->stream; |
2377 | struct hda_pcm_stream *hinfo = apcm->hinfo[stream]; | ||
2354 | int delay = 0; | 2378 | int delay = 0; |
2355 | 2379 | ||
2356 | switch (chip->position_fix[stream]) { | 2380 | switch (chip->position_fix[stream]) { |
@@ -2381,7 +2405,7 @@ static unsigned int azx_get_position(struct azx *chip, | |||
2381 | pos = 0; | 2405 | pos = 0; |
2382 | 2406 | ||
2383 | /* calculate runtime delay from LPIB */ | 2407 | /* calculate runtime delay from LPIB */ |
2384 | if (azx_dev->substream->runtime && | 2408 | if (substream->runtime && |
2385 | chip->position_fix[stream] == POS_FIX_POSBUF && | 2409 | chip->position_fix[stream] == POS_FIX_POSBUF && |
2386 | (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { | 2410 | (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) { |
2387 | unsigned int lpib_pos = azx_sd_readl(azx_dev, SD_LPIB); | 2411 | unsigned int lpib_pos = azx_sd_readl(azx_dev, SD_LPIB); |
@@ -2399,9 +2423,16 @@ static unsigned int azx_get_position(struct azx *chip, | |||
2399 | delay = 0; | 2423 | delay = 0; |
2400 | chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; | 2424 | chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY; |
2401 | } | 2425 | } |
2402 | azx_dev->substream->runtime->delay = | 2426 | delay = bytes_to_frames(substream->runtime, delay); |
2403 | bytes_to_frames(azx_dev->substream->runtime, delay); | ||
2404 | } | 2427 | } |
2428 | |||
2429 | if (substream->runtime) { | ||
2430 | if (hinfo->ops.get_delay) | ||
2431 | delay += hinfo->ops.get_delay(hinfo, apcm->codec, | ||
2432 | substream); | ||
2433 | substream->runtime->delay = delay; | ||
2434 | } | ||
2435 | |||
2405 | trace_azx_get_position(chip, azx_dev, pos, delay); | 2436 | trace_azx_get_position(chip, azx_dev, pos, delay); |
2406 | return pos; | 2437 | return pos; |
2407 | } | 2438 | } |
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index 1d035efeff4f..9e0a95288f46 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c | |||
@@ -394,7 +394,8 @@ static int get_unique_index(struct hda_codec *codec, const char *name, int idx) | |||
394 | } | 394 | } |
395 | 395 | ||
396 | static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid, | 396 | static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid, |
397 | const struct auto_pin_cfg *cfg) | 397 | const struct auto_pin_cfg *cfg, |
398 | const char *base_name) | ||
398 | { | 399 | { |
399 | unsigned int def_conf, conn; | 400 | unsigned int def_conf, conn; |
400 | char name[44]; | 401 | char name[44]; |
@@ -410,7 +411,11 @@ static int add_jack_kctl(struct hda_codec *codec, hda_nid_t nid, | |||
410 | phantom_jack = (conn != AC_JACK_PORT_COMPLEX) || | 411 | phantom_jack = (conn != AC_JACK_PORT_COMPLEX) || |
411 | !is_jack_detectable(codec, nid); | 412 | !is_jack_detectable(codec, nid); |
412 | 413 | ||
413 | snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), &idx); | 414 | if (base_name) { |
415 | strlcpy(name, base_name, sizeof(name)); | ||
416 | idx = 0; | ||
417 | } else | ||
418 | snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), &idx); | ||
414 | if (phantom_jack) | 419 | if (phantom_jack) |
415 | /* Example final name: "Internal Mic Phantom Jack" */ | 420 | /* Example final name: "Internal Mic Phantom Jack" */ |
416 | strncat(name, " Phantom", sizeof(name) - strlen(name) - 1); | 421 | strncat(name, " Phantom", sizeof(name) - strlen(name) - 1); |
@@ -433,39 +438,51 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec, | |||
433 | const hda_nid_t *p; | 438 | const hda_nid_t *p; |
434 | int i, err; | 439 | int i, err; |
435 | 440 | ||
441 | for (i = 0; i < cfg->num_inputs; i++) { | ||
442 | /* If we have headphone mics; make sure they get the right name | ||
443 | before grabbed by output pins */ | ||
444 | if (cfg->inputs[i].is_headphone_mic) { | ||
445 | if (auto_cfg_hp_outs(cfg) == 1) | ||
446 | err = add_jack_kctl(codec, auto_cfg_hp_pins(cfg)[0], | ||
447 | cfg, "Headphone Mic"); | ||
448 | else | ||
449 | err = add_jack_kctl(codec, cfg->inputs[i].pin, | ||
450 | cfg, "Headphone Mic"); | ||
451 | } else | ||
452 | err = add_jack_kctl(codec, cfg->inputs[i].pin, cfg, | ||
453 | NULL); | ||
454 | if (err < 0) | ||
455 | return err; | ||
456 | } | ||
457 | |||
436 | for (i = 0, p = cfg->line_out_pins; i < cfg->line_outs; i++, p++) { | 458 | for (i = 0, p = cfg->line_out_pins; i < cfg->line_outs; i++, p++) { |
437 | err = add_jack_kctl(codec, *p, cfg); | 459 | err = add_jack_kctl(codec, *p, cfg, NULL); |
438 | if (err < 0) | 460 | if (err < 0) |
439 | return err; | 461 | return err; |
440 | } | 462 | } |
441 | for (i = 0, p = cfg->hp_pins; i < cfg->hp_outs; i++, p++) { | 463 | for (i = 0, p = cfg->hp_pins; i < cfg->hp_outs; i++, p++) { |
442 | if (*p == *cfg->line_out_pins) /* might be duplicated */ | 464 | if (*p == *cfg->line_out_pins) /* might be duplicated */ |
443 | break; | 465 | break; |
444 | err = add_jack_kctl(codec, *p, cfg); | 466 | err = add_jack_kctl(codec, *p, cfg, NULL); |
445 | if (err < 0) | 467 | if (err < 0) |
446 | return err; | 468 | return err; |
447 | } | 469 | } |
448 | for (i = 0, p = cfg->speaker_pins; i < cfg->speaker_outs; i++, p++) { | 470 | for (i = 0, p = cfg->speaker_pins; i < cfg->speaker_outs; i++, p++) { |
449 | if (*p == *cfg->line_out_pins) /* might be duplicated */ | 471 | if (*p == *cfg->line_out_pins) /* might be duplicated */ |
450 | break; | 472 | break; |
451 | err = add_jack_kctl(codec, *p, cfg); | 473 | err = add_jack_kctl(codec, *p, cfg, NULL); |
452 | if (err < 0) | ||
453 | return err; | ||
454 | } | ||
455 | for (i = 0; i < cfg->num_inputs; i++) { | ||
456 | err = add_jack_kctl(codec, cfg->inputs[i].pin, cfg); | ||
457 | if (err < 0) | 474 | if (err < 0) |
458 | return err; | 475 | return err; |
459 | } | 476 | } |
460 | for (i = 0, p = cfg->dig_out_pins; i < cfg->dig_outs; i++, p++) { | 477 | for (i = 0, p = cfg->dig_out_pins; i < cfg->dig_outs; i++, p++) { |
461 | err = add_jack_kctl(codec, *p, cfg); | 478 | err = add_jack_kctl(codec, *p, cfg, NULL); |
462 | if (err < 0) | 479 | if (err < 0) |
463 | return err; | 480 | return err; |
464 | } | 481 | } |
465 | err = add_jack_kctl(codec, cfg->dig_in_pin, cfg); | 482 | err = add_jack_kctl(codec, cfg->dig_in_pin, cfg, NULL); |
466 | if (err < 0) | 483 | if (err < 0) |
467 | return err; | 484 | return err; |
468 | err = add_jack_kctl(codec, cfg->mono_out_pin, cfg); | 485 | err = add_jack_kctl(codec, cfg->mono_out_pin, cfg, NULL); |
469 | if (err < 0) | 486 | if (err < 0) |
470 | return err; | 487 | return err; |
471 | return 0; | 488 | return 0; |
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 83b7486c8eff..e0bf7534fa1f 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -670,6 +670,10 @@ snd_hda_check_power_state(struct hda_codec *codec, hda_nid_t nid, | |||
670 | return (state != target_state); | 670 | return (state != target_state); |
671 | } | 671 | } |
672 | 672 | ||
673 | unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec, | ||
674 | hda_nid_t nid, | ||
675 | unsigned int power_state); | ||
676 | |||
673 | /* | 677 | /* |
674 | * AMP control callbacks | 678 | * AMP control callbacks |
675 | */ | 679 | */ |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index df8014b27596..977b0d878dae 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -43,7 +43,6 @@ struct ad198x_spec { | |||
43 | hda_nid_t eapd_nid; | 43 | hda_nid_t eapd_nid; |
44 | 44 | ||
45 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ | 45 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
46 | hda_nid_t beep_dev_nid; | ||
47 | 46 | ||
48 | #ifdef ENABLE_AD_STATIC_QUIRKS | 47 | #ifdef ENABLE_AD_STATIC_QUIRKS |
49 | const struct snd_kcontrol_new *mixers[6]; | 48 | const struct snd_kcontrol_new *mixers[6]; |
@@ -609,7 +608,7 @@ static const struct hda_codec_ops ad198x_auto_patch_ops = { | |||
609 | .build_controls = ad198x_auto_build_controls, | 608 | .build_controls = ad198x_auto_build_controls, |
610 | .build_pcms = snd_hda_gen_build_pcms, | 609 | .build_pcms = snd_hda_gen_build_pcms, |
611 | .init = snd_hda_gen_init, | 610 | .init = snd_hda_gen_init, |
612 | .free = ad198x_free, | 611 | .free = snd_hda_gen_free, |
613 | .unsol_event = snd_hda_jack_unsol_event, | 612 | .unsol_event = snd_hda_jack_unsol_event, |
614 | #ifdef CONFIG_PM | 613 | #ifdef CONFIG_PM |
615 | .check_power_status = snd_hda_gen_check_power_status, | 614 | .check_power_status = snd_hda_gen_check_power_status, |
@@ -638,12 +637,6 @@ static int ad198x_parse_auto_config(struct hda_codec *codec) | |||
638 | if (err < 0) | 637 | if (err < 0) |
639 | return err; | 638 | return err; |
640 | 639 | ||
641 | if (spec->beep_dev_nid) { | ||
642 | err = snd_hda_attach_beep_device(codec, spec->beep_dev_nid); | ||
643 | if (err < 0) | ||
644 | return err; | ||
645 | } | ||
646 | |||
647 | codec->patch_ops = ad198x_auto_patch_ops; | 640 | codec->patch_ops = ad198x_auto_patch_ops; |
648 | 641 | ||
649 | return 0; | 642 | return 0; |
@@ -1240,7 +1233,7 @@ static int ad1986a_parse_auto_config(struct hda_codec *codec) | |||
1240 | codec->inv_eapd = 1; | 1233 | codec->inv_eapd = 1; |
1241 | 1234 | ||
1242 | spec->gen.mixer_nid = 0x07; | 1235 | spec->gen.mixer_nid = 0x07; |
1243 | spec->beep_dev_nid = 0x19; | 1236 | spec->gen.beep_nid = 0x19; |
1244 | set_beep_amp(spec, 0x18, 0, HDA_OUTPUT); | 1237 | set_beep_amp(spec, 0x18, 0, HDA_OUTPUT); |
1245 | 1238 | ||
1246 | /* AD1986A has a hardware problem that it can't share a stream | 1239 | /* AD1986A has a hardware problem that it can't share a stream |
@@ -1256,7 +1249,7 @@ static int ad1986a_parse_auto_config(struct hda_codec *codec) | |||
1256 | 1249 | ||
1257 | err = ad198x_parse_auto_config(codec); | 1250 | err = ad198x_parse_auto_config(codec); |
1258 | if (err < 0) { | 1251 | if (err < 0) { |
1259 | ad198x_free(codec); | 1252 | snd_hda_gen_free(codec); |
1260 | return err; | 1253 | return err; |
1261 | } | 1254 | } |
1262 | 1255 | ||
@@ -1673,7 +1666,7 @@ static int ad1983_parse_auto_config(struct hda_codec *codec) | |||
1673 | return err; | 1666 | return err; |
1674 | spec = codec->spec; | 1667 | spec = codec->spec; |
1675 | 1668 | ||
1676 | spec->beep_dev_nid = 0x10; | 1669 | spec->gen.beep_nid = 0x10; |
1677 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); | 1670 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
1678 | err = ad198x_parse_auto_config(codec); | 1671 | err = ad198x_parse_auto_config(codec); |
1679 | if (err < 0) | 1672 | if (err < 0) |
@@ -1684,7 +1677,7 @@ static int ad1983_parse_auto_config(struct hda_codec *codec) | |||
1684 | return 0; | 1677 | return 0; |
1685 | 1678 | ||
1686 | error: | 1679 | error: |
1687 | ad198x_free(codec); | 1680 | snd_hda_gen_free(codec); |
1688 | return err; | 1681 | return err; |
1689 | } | 1682 | } |
1690 | 1683 | ||
@@ -2187,7 +2180,7 @@ static int ad1981_parse_auto_config(struct hda_codec *codec) | |||
2187 | spec = codec->spec; | 2180 | spec = codec->spec; |
2188 | 2181 | ||
2189 | spec->gen.mixer_nid = 0x0e; | 2182 | spec->gen.mixer_nid = 0x0e; |
2190 | spec->beep_dev_nid = 0x10; | 2183 | spec->gen.beep_nid = 0x10; |
2191 | set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT); | 2184 | set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT); |
2192 | 2185 | ||
2193 | snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups); | 2186 | snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups); |
@@ -2205,7 +2198,7 @@ static int ad1981_parse_auto_config(struct hda_codec *codec) | |||
2205 | return 0; | 2198 | return 0; |
2206 | 2199 | ||
2207 | error: | 2200 | error: |
2208 | ad198x_free(codec); | 2201 | snd_hda_gen_free(codec); |
2209 | return err; | 2202 | return err; |
2210 | } | 2203 | } |
2211 | 2204 | ||
@@ -3236,7 +3229,7 @@ static int ad1988_parse_auto_config(struct hda_codec *codec) | |||
3236 | 3229 | ||
3237 | spec->gen.mixer_nid = 0x20; | 3230 | spec->gen.mixer_nid = 0x20; |
3238 | spec->gen.mixer_merge_nid = 0x21; | 3231 | spec->gen.mixer_merge_nid = 0x21; |
3239 | spec->beep_dev_nid = 0x10; | 3232 | spec->gen.beep_nid = 0x10; |
3240 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); | 3233 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
3241 | err = ad198x_parse_auto_config(codec); | 3234 | err = ad198x_parse_auto_config(codec); |
3242 | if (err < 0) | 3235 | if (err < 0) |
@@ -3247,7 +3240,7 @@ static int ad1988_parse_auto_config(struct hda_codec *codec) | |||
3247 | return 0; | 3240 | return 0; |
3248 | 3241 | ||
3249 | error: | 3242 | error: |
3250 | ad198x_free(codec); | 3243 | snd_hda_gen_free(codec); |
3251 | return err; | 3244 | return err; |
3252 | } | 3245 | } |
3253 | 3246 | ||
@@ -3653,7 +3646,7 @@ static int ad1884_parse_auto_config(struct hda_codec *codec) | |||
3653 | spec = codec->spec; | 3646 | spec = codec->spec; |
3654 | 3647 | ||
3655 | spec->gen.mixer_nid = 0x20; | 3648 | spec->gen.mixer_nid = 0x20; |
3656 | spec->beep_dev_nid = 0x10; | 3649 | spec->gen.beep_nid = 0x10; |
3657 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); | 3650 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
3658 | 3651 | ||
3659 | snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups); | 3652 | snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups); |
@@ -3671,7 +3664,7 @@ static int ad1884_parse_auto_config(struct hda_codec *codec) | |||
3671 | return 0; | 3664 | return 0; |
3672 | 3665 | ||
3673 | error: | 3666 | error: |
3674 | ad198x_free(codec); | 3667 | snd_hda_gen_free(codec); |
3675 | return err; | 3668 | return err; |
3676 | } | 3669 | } |
3677 | 3670 | ||
@@ -5155,7 +5148,7 @@ static int ad1882_parse_auto_config(struct hda_codec *codec) | |||
5155 | 5148 | ||
5156 | spec->gen.mixer_nid = 0x20; | 5149 | spec->gen.mixer_nid = 0x20; |
5157 | spec->gen.mixer_merge_nid = 0x21; | 5150 | spec->gen.mixer_merge_nid = 0x21; |
5158 | spec->beep_dev_nid = 0x10; | 5151 | spec->gen.beep_nid = 0x10; |
5159 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); | 5152 | set_beep_amp(spec, 0x10, 0, HDA_OUTPUT); |
5160 | err = ad198x_parse_auto_config(codec); | 5153 | err = ad198x_parse_auto_config(codec); |
5161 | if (err < 0) | 5154 | if (err < 0) |
@@ -5166,7 +5159,7 @@ static int ad1882_parse_auto_config(struct hda_codec *codec) | |||
5166 | return 0; | 5159 | return 0; |
5167 | 5160 | ||
5168 | error: | 5161 | error: |
5169 | ad198x_free(codec); | 5162 | snd_hda_gen_free(codec); |
5170 | return err; | 5163 | return err; |
5171 | } | 5164 | } |
5172 | 5165 | ||
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 0792b5725f9c..90ff7a3f72df 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c | |||
@@ -131,6 +131,13 @@ enum { | |||
131 | /* Effects values size*/ | 131 | /* Effects values size*/ |
132 | #define EFFECT_VALS_MAX_COUNT 12 | 132 | #define EFFECT_VALS_MAX_COUNT 12 |
133 | 133 | ||
134 | /* Latency introduced by DSP blocks in milliseconds. */ | ||
135 | #define DSP_CAPTURE_INIT_LATENCY 0 | ||
136 | #define DSP_CRYSTAL_VOICE_LATENCY 124 | ||
137 | #define DSP_PLAYBACK_INIT_LATENCY 13 | ||
138 | #define DSP_PLAY_ENHANCEMENT_LATENCY 30 | ||
139 | #define DSP_SPEAKER_OUT_LATENCY 7 | ||
140 | |||
134 | struct ct_effect { | 141 | struct ct_effect { |
135 | char name[44]; | 142 | char name[44]; |
136 | hda_nid_t nid; | 143 | hda_nid_t nid; |
@@ -741,6 +748,9 @@ struct ca0132_spec { | |||
741 | long voicefx_val; | 748 | long voicefx_val; |
742 | long cur_mic_boost; | 749 | long cur_mic_boost; |
743 | 750 | ||
751 | struct hda_codec *codec; | ||
752 | struct delayed_work unsol_hp_work; | ||
753 | |||
744 | #ifdef ENABLE_TUNING_CONTROLS | 754 | #ifdef ENABLE_TUNING_CONTROLS |
745 | long cur_ctl_vals[TUNING_CTLS_COUNT]; | 755 | long cur_ctl_vals[TUNING_CTLS_COUNT]; |
746 | #endif | 756 | #endif |
@@ -2740,6 +2750,31 @@ static int ca0132_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | |||
2740 | return 0; | 2750 | return 0; |
2741 | } | 2751 | } |
2742 | 2752 | ||
2753 | static unsigned int ca0132_playback_pcm_delay(struct hda_pcm_stream *info, | ||
2754 | struct hda_codec *codec, | ||
2755 | struct snd_pcm_substream *substream) | ||
2756 | { | ||
2757 | struct ca0132_spec *spec = codec->spec; | ||
2758 | unsigned int latency = DSP_PLAYBACK_INIT_LATENCY; | ||
2759 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
2760 | |||
2761 | if (spec->dsp_state != DSP_DOWNLOADED) | ||
2762 | return 0; | ||
2763 | |||
2764 | /* Add latency if playback enhancement and either effect is enabled. */ | ||
2765 | if (spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]) { | ||
2766 | if ((spec->effects_switch[SURROUND - EFFECT_START_NID]) || | ||
2767 | (spec->effects_switch[DIALOG_PLUS - EFFECT_START_NID])) | ||
2768 | latency += DSP_PLAY_ENHANCEMENT_LATENCY; | ||
2769 | } | ||
2770 | |||
2771 | /* Applying Speaker EQ adds latency as well. */ | ||
2772 | if (spec->cur_out_type == SPEAKER_OUT) | ||
2773 | latency += DSP_SPEAKER_OUT_LATENCY; | ||
2774 | |||
2775 | return (latency * runtime->rate) / 1000; | ||
2776 | } | ||
2777 | |||
2743 | /* | 2778 | /* |
2744 | * Digital out | 2779 | * Digital out |
2745 | */ | 2780 | */ |
@@ -2808,6 +2843,23 @@ static int ca0132_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |||
2808 | return 0; | 2843 | return 0; |
2809 | } | 2844 | } |
2810 | 2845 | ||
2846 | static unsigned int ca0132_capture_pcm_delay(struct hda_pcm_stream *info, | ||
2847 | struct hda_codec *codec, | ||
2848 | struct snd_pcm_substream *substream) | ||
2849 | { | ||
2850 | struct ca0132_spec *spec = codec->spec; | ||
2851 | unsigned int latency = DSP_CAPTURE_INIT_LATENCY; | ||
2852 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
2853 | |||
2854 | if (spec->dsp_state != DSP_DOWNLOADED) | ||
2855 | return 0; | ||
2856 | |||
2857 | if (spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID]) | ||
2858 | latency += DSP_CRYSTAL_VOICE_LATENCY; | ||
2859 | |||
2860 | return (latency * runtime->rate) / 1000; | ||
2861 | } | ||
2862 | |||
2811 | /* | 2863 | /* |
2812 | * Controls stuffs. | 2864 | * Controls stuffs. |
2813 | */ | 2865 | */ |
@@ -3227,6 +3279,14 @@ exit: | |||
3227 | return err < 0 ? err : 0; | 3279 | return err < 0 ? err : 0; |
3228 | } | 3280 | } |
3229 | 3281 | ||
3282 | static void ca0132_unsol_hp_delayed(struct work_struct *work) | ||
3283 | { | ||
3284 | struct ca0132_spec *spec = container_of( | ||
3285 | to_delayed_work(work), struct ca0132_spec, unsol_hp_work); | ||
3286 | ca0132_select_out(spec->codec); | ||
3287 | snd_hda_jack_report_sync(spec->codec); | ||
3288 | } | ||
3289 | |||
3230 | static void ca0132_set_dmic(struct hda_codec *codec, int enable); | 3290 | static void ca0132_set_dmic(struct hda_codec *codec, int enable); |
3231 | static int ca0132_mic_boost_set(struct hda_codec *codec, long val); | 3291 | static int ca0132_mic_boost_set(struct hda_codec *codec, long val); |
3232 | static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val); | 3292 | static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val); |
@@ -3991,7 +4051,8 @@ static struct hda_pcm_stream ca0132_pcm_analog_playback = { | |||
3991 | .channels_max = 6, | 4051 | .channels_max = 6, |
3992 | .ops = { | 4052 | .ops = { |
3993 | .prepare = ca0132_playback_pcm_prepare, | 4053 | .prepare = ca0132_playback_pcm_prepare, |
3994 | .cleanup = ca0132_playback_pcm_cleanup | 4054 | .cleanup = ca0132_playback_pcm_cleanup, |
4055 | .get_delay = ca0132_playback_pcm_delay, | ||
3995 | }, | 4056 | }, |
3996 | }; | 4057 | }; |
3997 | 4058 | ||
@@ -4001,7 +4062,8 @@ static struct hda_pcm_stream ca0132_pcm_analog_capture = { | |||
4001 | .channels_max = 2, | 4062 | .channels_max = 2, |
4002 | .ops = { | 4063 | .ops = { |
4003 | .prepare = ca0132_capture_pcm_prepare, | 4064 | .prepare = ca0132_capture_pcm_prepare, |
4004 | .cleanup = ca0132_capture_pcm_cleanup | 4065 | .cleanup = ca0132_capture_pcm_cleanup, |
4066 | .get_delay = ca0132_capture_pcm_delay, | ||
4005 | }, | 4067 | }, |
4006 | }; | 4068 | }; |
4007 | 4069 | ||
@@ -4399,8 +4461,7 @@ static void ca0132_process_dsp_response(struct hda_codec *codec) | |||
4399 | 4461 | ||
4400 | static void ca0132_unsol_event(struct hda_codec *codec, unsigned int res) | 4462 | static void ca0132_unsol_event(struct hda_codec *codec, unsigned int res) |
4401 | { | 4463 | { |
4402 | snd_printdd(KERN_INFO "ca0132_unsol_event: 0x%x\n", res); | 4464 | struct ca0132_spec *spec = codec->spec; |
4403 | |||
4404 | 4465 | ||
4405 | if (((res >> AC_UNSOL_RES_TAG_SHIFT) & 0x3f) == UNSOL_TAG_DSP) { | 4466 | if (((res >> AC_UNSOL_RES_TAG_SHIFT) & 0x3f) == UNSOL_TAG_DSP) { |
4406 | ca0132_process_dsp_response(codec); | 4467 | ca0132_process_dsp_response(codec); |
@@ -4412,8 +4473,13 @@ static void ca0132_unsol_event(struct hda_codec *codec, unsigned int res) | |||
4412 | 4473 | ||
4413 | switch (res) { | 4474 | switch (res) { |
4414 | case UNSOL_TAG_HP: | 4475 | case UNSOL_TAG_HP: |
4415 | ca0132_select_out(codec); | 4476 | /* Delay enabling the HP amp, to let the mic-detection |
4416 | snd_hda_jack_report_sync(codec); | 4477 | * state machine run. |
4478 | */ | ||
4479 | cancel_delayed_work_sync(&spec->unsol_hp_work); | ||
4480 | queue_delayed_work(codec->bus->workq, | ||
4481 | &spec->unsol_hp_work, | ||
4482 | msecs_to_jiffies(500)); | ||
4417 | break; | 4483 | break; |
4418 | case UNSOL_TAG_AMIC1: | 4484 | case UNSOL_TAG_AMIC1: |
4419 | ca0132_select_mic(codec); | 4485 | ca0132_select_mic(codec); |
@@ -4588,6 +4654,7 @@ static void ca0132_free(struct hda_codec *codec) | |||
4588 | { | 4654 | { |
4589 | struct ca0132_spec *spec = codec->spec; | 4655 | struct ca0132_spec *spec = codec->spec; |
4590 | 4656 | ||
4657 | cancel_delayed_work_sync(&spec->unsol_hp_work); | ||
4591 | snd_hda_power_up(codec); | 4658 | snd_hda_power_up(codec); |
4592 | snd_hda_sequence_write(codec, spec->base_exit_verbs); | 4659 | snd_hda_sequence_write(codec, spec->base_exit_verbs); |
4593 | ca0132_exit_chip(codec); | 4660 | ca0132_exit_chip(codec); |
@@ -4653,6 +4720,7 @@ static int patch_ca0132(struct hda_codec *codec) | |||
4653 | if (!spec) | 4720 | if (!spec) |
4654 | return -ENOMEM; | 4721 | return -ENOMEM; |
4655 | codec->spec = spec; | 4722 | codec->spec = spec; |
4723 | spec->codec = codec; | ||
4656 | 4724 | ||
4657 | spec->num_mixers = 1; | 4725 | spec->num_mixers = 1; |
4658 | spec->mixers[0] = ca0132_mixer; | 4726 | spec->mixers[0] = ca0132_mixer; |
@@ -4663,6 +4731,8 @@ static int patch_ca0132(struct hda_codec *codec) | |||
4663 | spec->init_verbs[1] = ca0132_init_verbs1; | 4731 | spec->init_verbs[1] = ca0132_init_verbs1; |
4664 | spec->num_init_verbs = 2; | 4732 | spec->num_init_verbs = 2; |
4665 | 4733 | ||
4734 | INIT_DELAYED_WORK(&spec->unsol_hp_work, ca0132_unsol_hp_delayed); | ||
4735 | |||
4666 | ca0132_init_chip(codec); | 4736 | ca0132_init_chip(codec); |
4667 | 4737 | ||
4668 | ca0132_config(codec); | 4738 | ca0132_config(codec); |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 0d9c58f13560..bd8d46cca2b3 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c | |||
@@ -68,6 +68,7 @@ enum { | |||
68 | enum { | 68 | enum { |
69 | CS421X_CDB4210, | 69 | CS421X_CDB4210, |
70 | CS421X_SENSE_B, | 70 | CS421X_SENSE_B, |
71 | CS421X_STUMPY, | ||
71 | }; | 72 | }; |
72 | 73 | ||
73 | /* Vendor-specific processing widget */ | 74 | /* Vendor-specific processing widget */ |
@@ -538,6 +539,7 @@ static int patch_cs420x(struct hda_codec *codec) | |||
538 | /* CS4210 board names */ | 539 | /* CS4210 board names */ |
539 | static const struct hda_model_fixup cs421x_models[] = { | 540 | static const struct hda_model_fixup cs421x_models[] = { |
540 | { .id = CS421X_CDB4210, .name = "cdb4210" }, | 541 | { .id = CS421X_CDB4210, .name = "cdb4210" }, |
542 | { .id = CS421X_STUMPY, .name = "stumpy" }, | ||
541 | {} | 543 | {} |
542 | }; | 544 | }; |
543 | 545 | ||
@@ -559,6 +561,17 @@ static const struct hda_pintbl cdb4210_pincfgs[] = { | |||
559 | {} /* terminator */ | 561 | {} /* terminator */ |
560 | }; | 562 | }; |
561 | 563 | ||
564 | /* Stumpy ChromeBox */ | ||
565 | static const struct hda_pintbl stumpy_pincfgs[] = { | ||
566 | { 0x05, 0x022120f0 }, | ||
567 | { 0x06, 0x901700f0 }, | ||
568 | { 0x07, 0x02a120f0 }, | ||
569 | { 0x08, 0x77a70037 }, | ||
570 | { 0x09, 0x77a6003e }, | ||
571 | { 0x0a, 0x434510f0 }, | ||
572 | {} /* terminator */ | ||
573 | }; | ||
574 | |||
562 | /* Setup GPIO/SENSE for each board (if used) */ | 575 | /* Setup GPIO/SENSE for each board (if used) */ |
563 | static void cs421x_fixup_sense_b(struct hda_codec *codec, | 576 | static void cs421x_fixup_sense_b(struct hda_codec *codec, |
564 | const struct hda_fixup *fix, int action) | 577 | const struct hda_fixup *fix, int action) |
@@ -578,7 +591,11 @@ static const struct hda_fixup cs421x_fixups[] = { | |||
578 | [CS421X_SENSE_B] = { | 591 | [CS421X_SENSE_B] = { |
579 | .type = HDA_FIXUP_FUNC, | 592 | .type = HDA_FIXUP_FUNC, |
580 | .v.func = cs421x_fixup_sense_b, | 593 | .v.func = cs421x_fixup_sense_b, |
581 | } | 594 | }, |
595 | [CS421X_STUMPY] = { | ||
596 | .type = HDA_FIXUP_PINS, | ||
597 | .v.pins = stumpy_pincfgs, | ||
598 | }, | ||
582 | }; | 599 | }; |
583 | 600 | ||
584 | static const struct hda_verb cs421x_coef_init_verbs[] = { | 601 | static const struct hda_verb cs421x_coef_init_verbs[] = { |
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 2a89d1eefeb6..549964395770 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -139,8 +139,12 @@ struct conexant_spec { | |||
139 | 139 | ||
140 | 140 | ||
141 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | 141 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
142 | #define set_beep_amp(spec, nid, idx, dir) \ | 142 | static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid, |
143 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) | 143 | int idx, int dir) |
144 | { | ||
145 | spec->gen.beep_nid = nid; | ||
146 | spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); | ||
147 | } | ||
144 | /* additional beep mixers; the actual parameters are overwritten at build */ | 148 | /* additional beep mixers; the actual parameters are overwritten at build */ |
145 | static const struct snd_kcontrol_new cxt_beep_mixer[] = { | 149 | static const struct snd_kcontrol_new cxt_beep_mixer[] = { |
146 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), | 150 | HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), |
@@ -3191,17 +3195,11 @@ static int cx_auto_build_controls(struct hda_codec *codec) | |||
3191 | return 0; | 3195 | return 0; |
3192 | } | 3196 | } |
3193 | 3197 | ||
3194 | static void cx_auto_free(struct hda_codec *codec) | ||
3195 | { | ||
3196 | snd_hda_detach_beep_device(codec); | ||
3197 | snd_hda_gen_free(codec); | ||
3198 | } | ||
3199 | |||
3200 | static const struct hda_codec_ops cx_auto_patch_ops = { | 3198 | static const struct hda_codec_ops cx_auto_patch_ops = { |
3201 | .build_controls = cx_auto_build_controls, | 3199 | .build_controls = cx_auto_build_controls, |
3202 | .build_pcms = snd_hda_gen_build_pcms, | 3200 | .build_pcms = snd_hda_gen_build_pcms, |
3203 | .init = snd_hda_gen_init, | 3201 | .init = snd_hda_gen_init, |
3204 | .free = cx_auto_free, | 3202 | .free = snd_hda_gen_free, |
3205 | .unsol_event = snd_hda_jack_unsol_event, | 3203 | .unsol_event = snd_hda_jack_unsol_event, |
3206 | #ifdef CONFIG_PM | 3204 | #ifdef CONFIG_PM |
3207 | .check_power_status = snd_hda_gen_check_power_status, | 3205 | .check_power_status = snd_hda_gen_check_power_status, |
@@ -3356,7 +3354,6 @@ static int patch_conexant_auto(struct hda_codec *codec) | |||
3356 | switch (codec->vendor_id) { | 3354 | switch (codec->vendor_id) { |
3357 | case 0x14f15045: | 3355 | case 0x14f15045: |
3358 | codec->single_adc_amp = 1; | 3356 | codec->single_adc_amp = 1; |
3359 | codec->power_filter = NULL; /* Needs speaker amp to D3 to avoid click */ | ||
3360 | break; | 3357 | break; |
3361 | case 0x14f15047: | 3358 | case 0x14f15047: |
3362 | codec->pin_amp_workaround = 1; | 3359 | codec->pin_amp_workaround = 1; |
@@ -3396,8 +3393,6 @@ static int patch_conexant_auto(struct hda_codec *codec) | |||
3396 | goto error; | 3393 | goto error; |
3397 | 3394 | ||
3398 | codec->patch_ops = cx_auto_patch_ops; | 3395 | codec->patch_ops = cx_auto_patch_ops; |
3399 | if (spec->beep_amp) | ||
3400 | snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp)); | ||
3401 | 3396 | ||
3402 | /* Some laptops with Conexant chips show stalls in S3 resume, | 3397 | /* Some laptops with Conexant chips show stalls in S3 resume, |
3403 | * which falls into the single-cmd mode. | 3398 | * which falls into the single-cmd mode. |
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index de8ac5c07fd0..32930e668854 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c | |||
@@ -44,16 +44,6 @@ static bool static_hdmi_pcm; | |||
44 | module_param(static_hdmi_pcm, bool, 0644); | 44 | module_param(static_hdmi_pcm, bool, 0644); |
45 | MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info"); | 45 | MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info"); |
46 | 46 | ||
47 | /* | ||
48 | * The HDMI/DisplayPort configuration can be highly dynamic. A graphics device | ||
49 | * could support N independent pipes, each of them can be connected to one or | ||
50 | * more ports (DVI, HDMI or DisplayPort). | ||
51 | * | ||
52 | * The HDA correspondence of pipes/ports are converter/pin nodes. | ||
53 | */ | ||
54 | #define MAX_HDMI_CVTS 8 | ||
55 | #define MAX_HDMI_PINS 8 | ||
56 | |||
57 | struct hdmi_spec_per_cvt { | 47 | struct hdmi_spec_per_cvt { |
58 | hda_nid_t cvt_nid; | 48 | hda_nid_t cvt_nid; |
59 | int assigned; | 49 | int assigned; |
@@ -80,16 +70,17 @@ struct hdmi_spec_per_pin { | |||
80 | bool non_pcm; | 70 | bool non_pcm; |
81 | bool chmap_set; /* channel-map override by ALSA API? */ | 71 | bool chmap_set; /* channel-map override by ALSA API? */ |
82 | unsigned char chmap[8]; /* ALSA API channel-map */ | 72 | unsigned char chmap[8]; /* ALSA API channel-map */ |
73 | char pcm_name[8]; /* filled in build_pcm callbacks */ | ||
83 | }; | 74 | }; |
84 | 75 | ||
85 | struct hdmi_spec { | 76 | struct hdmi_spec { |
86 | int num_cvts; | 77 | int num_cvts; |
87 | struct hdmi_spec_per_cvt cvts[MAX_HDMI_CVTS]; | 78 | struct snd_array cvts; /* struct hdmi_spec_per_cvt */ |
88 | hda_nid_t cvt_nids[MAX_HDMI_CVTS]; | 79 | hda_nid_t cvt_nids[4]; /* only for haswell fix */ |
89 | 80 | ||
90 | int num_pins; | 81 | int num_pins; |
91 | struct hdmi_spec_per_pin pins[MAX_HDMI_PINS]; | 82 | struct snd_array pins; /* struct hdmi_spec_per_pin */ |
92 | struct hda_pcm pcm_rec[MAX_HDMI_PINS]; | 83 | struct snd_array pcm_rec; /* struct hda_pcm */ |
93 | unsigned int channels_max; /* max over all cvts */ | 84 | unsigned int channels_max; /* max over all cvts */ |
94 | 85 | ||
95 | struct hdmi_eld temp_eld; | 86 | struct hdmi_eld temp_eld; |
@@ -304,12 +295,19 @@ static struct cea_channel_speaker_allocation channel_allocations[] = { | |||
304 | * HDMI routines | 295 | * HDMI routines |
305 | */ | 296 | */ |
306 | 297 | ||
298 | #define get_pin(spec, idx) \ | ||
299 | ((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx)) | ||
300 | #define get_cvt(spec, idx) \ | ||
301 | ((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx)) | ||
302 | #define get_pcm_rec(spec, idx) \ | ||
303 | ((struct hda_pcm *)snd_array_elem(&spec->pcm_rec, idx)) | ||
304 | |||
307 | static int pin_nid_to_pin_index(struct hdmi_spec *spec, hda_nid_t pin_nid) | 305 | static int pin_nid_to_pin_index(struct hdmi_spec *spec, hda_nid_t pin_nid) |
308 | { | 306 | { |
309 | int pin_idx; | 307 | int pin_idx; |
310 | 308 | ||
311 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) | 309 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) |
312 | if (spec->pins[pin_idx].pin_nid == pin_nid) | 310 | if (get_pin(spec, pin_idx)->pin_nid == pin_nid) |
313 | return pin_idx; | 311 | return pin_idx; |
314 | 312 | ||
315 | snd_printk(KERN_WARNING "HDMI: pin nid %d not registered\n", pin_nid); | 313 | snd_printk(KERN_WARNING "HDMI: pin nid %d not registered\n", pin_nid); |
@@ -322,7 +320,7 @@ static int hinfo_to_pin_index(struct hdmi_spec *spec, | |||
322 | int pin_idx; | 320 | int pin_idx; |
323 | 321 | ||
324 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) | 322 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) |
325 | if (&spec->pcm_rec[pin_idx].stream[0] == hinfo) | 323 | if (get_pcm_rec(spec, pin_idx)->stream == hinfo) |
326 | return pin_idx; | 324 | return pin_idx; |
327 | 325 | ||
328 | snd_printk(KERN_WARNING "HDMI: hinfo %p not registered\n", hinfo); | 326 | snd_printk(KERN_WARNING "HDMI: hinfo %p not registered\n", hinfo); |
@@ -334,7 +332,7 @@ static int cvt_nid_to_cvt_index(struct hdmi_spec *spec, hda_nid_t cvt_nid) | |||
334 | int cvt_idx; | 332 | int cvt_idx; |
335 | 333 | ||
336 | for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) | 334 | for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) |
337 | if (spec->cvts[cvt_idx].cvt_nid == cvt_nid) | 335 | if (get_cvt(spec, cvt_idx)->cvt_nid == cvt_nid) |
338 | return cvt_idx; | 336 | return cvt_idx; |
339 | 337 | ||
340 | snd_printk(KERN_WARNING "HDMI: cvt nid %d not registered\n", cvt_nid); | 338 | snd_printk(KERN_WARNING "HDMI: cvt nid %d not registered\n", cvt_nid); |
@@ -352,7 +350,7 @@ static int hdmi_eld_ctl_info(struct snd_kcontrol *kcontrol, | |||
352 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; | 350 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; |
353 | 351 | ||
354 | pin_idx = kcontrol->private_value; | 352 | pin_idx = kcontrol->private_value; |
355 | eld = &spec->pins[pin_idx].sink_eld; | 353 | eld = &get_pin(spec, pin_idx)->sink_eld; |
356 | 354 | ||
357 | mutex_lock(&eld->lock); | 355 | mutex_lock(&eld->lock); |
358 | uinfo->count = eld->eld_valid ? eld->eld_size : 0; | 356 | uinfo->count = eld->eld_valid ? eld->eld_size : 0; |
@@ -370,7 +368,7 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol, | |||
370 | int pin_idx; | 368 | int pin_idx; |
371 | 369 | ||
372 | pin_idx = kcontrol->private_value; | 370 | pin_idx = kcontrol->private_value; |
373 | eld = &spec->pins[pin_idx].sink_eld; | 371 | eld = &get_pin(spec, pin_idx)->sink_eld; |
374 | 372 | ||
375 | mutex_lock(&eld->lock); | 373 | mutex_lock(&eld->lock); |
376 | if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data)) { | 374 | if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data)) { |
@@ -410,11 +408,11 @@ static int hdmi_create_eld_ctl(struct hda_codec *codec, int pin_idx, | |||
410 | kctl->private_value = pin_idx; | 408 | kctl->private_value = pin_idx; |
411 | kctl->id.device = device; | 409 | kctl->id.device = device; |
412 | 410 | ||
413 | err = snd_hda_ctl_add(codec, spec->pins[pin_idx].pin_nid, kctl); | 411 | err = snd_hda_ctl_add(codec, get_pin(spec, pin_idx)->pin_nid, kctl); |
414 | if (err < 0) | 412 | if (err < 0) |
415 | return err; | 413 | return err; |
416 | 414 | ||
417 | spec->pins[pin_idx].eld_ctl = kctl; | 415 | get_pin(spec, pin_idx)->eld_ctl = kctl; |
418 | return 0; | 416 | return 0; |
419 | } | 417 | } |
420 | 418 | ||
@@ -875,14 +873,14 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, int pin_idx, | |||
875 | struct snd_pcm_substream *substream) | 873 | struct snd_pcm_substream *substream) |
876 | { | 874 | { |
877 | struct hdmi_spec *spec = codec->spec; | 875 | struct hdmi_spec *spec = codec->spec; |
878 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; | 876 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
879 | hda_nid_t pin_nid = per_pin->pin_nid; | 877 | hda_nid_t pin_nid = per_pin->pin_nid; |
880 | int channels = substream->runtime->channels; | 878 | int channels = substream->runtime->channels; |
881 | struct hdmi_eld *eld; | 879 | struct hdmi_eld *eld; |
882 | int ca; | 880 | int ca; |
883 | union audio_infoframe ai; | 881 | union audio_infoframe ai; |
884 | 882 | ||
885 | eld = &spec->pins[pin_idx].sink_eld; | 883 | eld = &per_pin->sink_eld; |
886 | if (!eld->monitor_present) | 884 | if (!eld->monitor_present) |
887 | return; | 885 | return; |
888 | 886 | ||
@@ -977,7 +975,7 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) | |||
977 | if (pin_idx < 0) | 975 | if (pin_idx < 0) |
978 | return; | 976 | return; |
979 | 977 | ||
980 | hdmi_present_sense(&spec->pins[pin_idx], 1); | 978 | hdmi_present_sense(get_pin(spec, pin_idx), 1); |
981 | snd_hda_jack_report_sync(codec); | 979 | snd_hda_jack_report_sync(codec); |
982 | } | 980 | } |
983 | 981 | ||
@@ -1020,6 +1018,41 @@ static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) | |||
1020 | hdmi_non_intrinsic_event(codec, res); | 1018 | hdmi_non_intrinsic_event(codec, res); |
1021 | } | 1019 | } |
1022 | 1020 | ||
1021 | static void haswell_verify_pin_D0(struct hda_codec *codec, hda_nid_t nid) | ||
1022 | { | ||
1023 | int pwr, lamp, ramp; | ||
1024 | |||
1025 | pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); | ||
1026 | pwr = (pwr & AC_PWRST_ACTUAL) >> AC_PWRST_ACTUAL_SHIFT; | ||
1027 | if (pwr != AC_PWRST_D0) { | ||
1028 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, | ||
1029 | AC_PWRST_D0); | ||
1030 | msleep(40); | ||
1031 | pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); | ||
1032 | pwr = (pwr & AC_PWRST_ACTUAL) >> AC_PWRST_ACTUAL_SHIFT; | ||
1033 | snd_printd("Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr); | ||
1034 | } | ||
1035 | |||
1036 | lamp = snd_hda_codec_read(codec, nid, 0, | ||
1037 | AC_VERB_GET_AMP_GAIN_MUTE, | ||
1038 | AC_AMP_GET_LEFT | AC_AMP_GET_OUTPUT); | ||
1039 | ramp = snd_hda_codec_read(codec, nid, 0, | ||
1040 | AC_VERB_GET_AMP_GAIN_MUTE, | ||
1041 | AC_AMP_GET_RIGHT | AC_AMP_GET_OUTPUT); | ||
1042 | if (lamp != ramp) { | ||
1043 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, | ||
1044 | AC_AMP_SET_RIGHT | AC_AMP_SET_OUTPUT | lamp); | ||
1045 | |||
1046 | lamp = snd_hda_codec_read(codec, nid, 0, | ||
1047 | AC_VERB_GET_AMP_GAIN_MUTE, | ||
1048 | AC_AMP_GET_LEFT | AC_AMP_GET_OUTPUT); | ||
1049 | ramp = snd_hda_codec_read(codec, nid, 0, | ||
1050 | AC_VERB_GET_AMP_GAIN_MUTE, | ||
1051 | AC_AMP_GET_RIGHT | AC_AMP_GET_OUTPUT); | ||
1052 | snd_printd("Haswell HDMI audio: Mute after set on pin 0x%x: [0x%x 0x%x]\n", nid, lamp, ramp); | ||
1053 | } | ||
1054 | } | ||
1055 | |||
1023 | /* | 1056 | /* |
1024 | * Callbacks | 1057 | * Callbacks |
1025 | */ | 1058 | */ |
@@ -1034,6 +1067,9 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, | |||
1034 | int pinctl; | 1067 | int pinctl; |
1035 | int new_pinctl = 0; | 1068 | int new_pinctl = 0; |
1036 | 1069 | ||
1070 | if (codec->vendor_id == 0x80862807) | ||
1071 | haswell_verify_pin_D0(codec, pin_nid); | ||
1072 | |||
1037 | if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { | 1073 | if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { |
1038 | pinctl = snd_hda_codec_read(codec, pin_nid, 0, | 1074 | pinctl = snd_hda_codec_read(codec, pin_nid, 0, |
1039 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 1075 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
@@ -1083,12 +1119,12 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, | |||
1083 | pin_idx = hinfo_to_pin_index(spec, hinfo); | 1119 | pin_idx = hinfo_to_pin_index(spec, hinfo); |
1084 | if (snd_BUG_ON(pin_idx < 0)) | 1120 | if (snd_BUG_ON(pin_idx < 0)) |
1085 | return -EINVAL; | 1121 | return -EINVAL; |
1086 | per_pin = &spec->pins[pin_idx]; | 1122 | per_pin = get_pin(spec, pin_idx); |
1087 | eld = &per_pin->sink_eld; | 1123 | eld = &per_pin->sink_eld; |
1088 | 1124 | ||
1089 | /* Dynamically assign converter to stream */ | 1125 | /* Dynamically assign converter to stream */ |
1090 | for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { | 1126 | for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { |
1091 | per_cvt = &spec->cvts[cvt_idx]; | 1127 | per_cvt = get_cvt(spec, cvt_idx); |
1092 | 1128 | ||
1093 | /* Must not already be assigned */ | 1129 | /* Must not already be assigned */ |
1094 | if (per_cvt->assigned) | 1130 | if (per_cvt->assigned) |
@@ -1151,7 +1187,7 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, | |||
1151 | static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) | 1187 | static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) |
1152 | { | 1188 | { |
1153 | struct hdmi_spec *spec = codec->spec; | 1189 | struct hdmi_spec *spec = codec->spec; |
1154 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; | 1190 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
1155 | hda_nid_t pin_nid = per_pin->pin_nid; | 1191 | hda_nid_t pin_nid = per_pin->pin_nid; |
1156 | 1192 | ||
1157 | if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { | 1193 | if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { |
@@ -1275,14 +1311,13 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) | |||
1275 | if (get_defcfg_connect(config) == AC_JACK_PORT_NONE) | 1311 | if (get_defcfg_connect(config) == AC_JACK_PORT_NONE) |
1276 | return 0; | 1312 | return 0; |
1277 | 1313 | ||
1278 | if (snd_BUG_ON(spec->num_pins >= MAX_HDMI_PINS)) | ||
1279 | return -E2BIG; | ||
1280 | |||
1281 | if (codec->vendor_id == 0x80862807) | 1314 | if (codec->vendor_id == 0x80862807) |
1282 | intel_haswell_fixup_connect_list(codec, pin_nid); | 1315 | intel_haswell_fixup_connect_list(codec, pin_nid); |
1283 | 1316 | ||
1284 | pin_idx = spec->num_pins; | 1317 | pin_idx = spec->num_pins; |
1285 | per_pin = &spec->pins[pin_idx]; | 1318 | per_pin = snd_array_new(&spec->pins); |
1319 | if (!per_pin) | ||
1320 | return -ENOMEM; | ||
1286 | 1321 | ||
1287 | per_pin->pin_nid = pin_nid; | 1322 | per_pin->pin_nid = pin_nid; |
1288 | per_pin->non_pcm = false; | 1323 | per_pin->non_pcm = false; |
@@ -1299,19 +1334,16 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) | |||
1299 | static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) | 1334 | static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) |
1300 | { | 1335 | { |
1301 | struct hdmi_spec *spec = codec->spec; | 1336 | struct hdmi_spec *spec = codec->spec; |
1302 | int cvt_idx; | ||
1303 | struct hdmi_spec_per_cvt *per_cvt; | 1337 | struct hdmi_spec_per_cvt *per_cvt; |
1304 | unsigned int chans; | 1338 | unsigned int chans; |
1305 | int err; | 1339 | int err; |
1306 | 1340 | ||
1307 | if (snd_BUG_ON(spec->num_cvts >= MAX_HDMI_CVTS)) | ||
1308 | return -E2BIG; | ||
1309 | |||
1310 | chans = get_wcaps(codec, cvt_nid); | 1341 | chans = get_wcaps(codec, cvt_nid); |
1311 | chans = get_wcaps_channels(chans); | 1342 | chans = get_wcaps_channels(chans); |
1312 | 1343 | ||
1313 | cvt_idx = spec->num_cvts; | 1344 | per_cvt = snd_array_new(&spec->cvts); |
1314 | per_cvt = &spec->cvts[cvt_idx]; | 1345 | if (!per_cvt) |
1346 | return -ENOMEM; | ||
1315 | 1347 | ||
1316 | per_cvt->cvt_nid = cvt_nid; | 1348 | per_cvt->cvt_nid = cvt_nid; |
1317 | per_cvt->channels_min = 2; | 1349 | per_cvt->channels_min = 2; |
@@ -1328,7 +1360,9 @@ static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) | |||
1328 | if (err < 0) | 1360 | if (err < 0) |
1329 | return err; | 1361 | return err; |
1330 | 1362 | ||
1331 | spec->cvt_nids[spec->num_cvts++] = cvt_nid; | 1363 | if (spec->num_cvts < ARRAY_SIZE(spec->cvt_nids)) |
1364 | spec->cvt_nids[spec->num_cvts] = cvt_nid; | ||
1365 | spec->num_cvts++; | ||
1332 | 1366 | ||
1333 | return 0; | 1367 | return 0; |
1334 | } | 1368 | } |
@@ -1384,13 +1418,6 @@ static int hdmi_parse_codec(struct hda_codec *codec) | |||
1384 | 1418 | ||
1385 | /* | 1419 | /* |
1386 | */ | 1420 | */ |
1387 | static char *get_hdmi_pcm_name(int idx) | ||
1388 | { | ||
1389 | static char names[MAX_HDMI_PINS][8]; | ||
1390 | sprintf(&names[idx][0], "HDMI %d", idx); | ||
1391 | return &names[idx][0]; | ||
1392 | } | ||
1393 | |||
1394 | static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) | 1421 | static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) |
1395 | { | 1422 | { |
1396 | struct hda_spdif_out *spdif; | 1423 | struct hda_spdif_out *spdif; |
@@ -1417,7 +1444,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
1417 | hda_nid_t cvt_nid = hinfo->nid; | 1444 | hda_nid_t cvt_nid = hinfo->nid; |
1418 | struct hdmi_spec *spec = codec->spec; | 1445 | struct hdmi_spec *spec = codec->spec; |
1419 | int pin_idx = hinfo_to_pin_index(spec, hinfo); | 1446 | int pin_idx = hinfo_to_pin_index(spec, hinfo); |
1420 | hda_nid_t pin_nid = spec->pins[pin_idx].pin_nid; | 1447 | hda_nid_t pin_nid = get_pin(spec, pin_idx)->pin_nid; |
1421 | bool non_pcm; | 1448 | bool non_pcm; |
1422 | 1449 | ||
1423 | non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); | 1450 | non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); |
@@ -1450,7 +1477,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo, | |||
1450 | cvt_idx = cvt_nid_to_cvt_index(spec, hinfo->nid); | 1477 | cvt_idx = cvt_nid_to_cvt_index(spec, hinfo->nid); |
1451 | if (snd_BUG_ON(cvt_idx < 0)) | 1478 | if (snd_BUG_ON(cvt_idx < 0)) |
1452 | return -EINVAL; | 1479 | return -EINVAL; |
1453 | per_cvt = &spec->cvts[cvt_idx]; | 1480 | per_cvt = get_cvt(spec, cvt_idx); |
1454 | 1481 | ||
1455 | snd_BUG_ON(!per_cvt->assigned); | 1482 | snd_BUG_ON(!per_cvt->assigned); |
1456 | per_cvt->assigned = 0; | 1483 | per_cvt->assigned = 0; |
@@ -1459,7 +1486,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo, | |||
1459 | pin_idx = hinfo_to_pin_index(spec, hinfo); | 1486 | pin_idx = hinfo_to_pin_index(spec, hinfo); |
1460 | if (snd_BUG_ON(pin_idx < 0)) | 1487 | if (snd_BUG_ON(pin_idx < 0)) |
1461 | return -EINVAL; | 1488 | return -EINVAL; |
1462 | per_pin = &spec->pins[pin_idx]; | 1489 | per_pin = get_pin(spec, pin_idx); |
1463 | 1490 | ||
1464 | snd_hda_spdif_ctls_unassign(codec, pin_idx); | 1491 | snd_hda_spdif_ctls_unassign(codec, pin_idx); |
1465 | per_pin->chmap_set = false; | 1492 | per_pin->chmap_set = false; |
@@ -1553,7 +1580,7 @@ static int hdmi_chmap_ctl_get(struct snd_kcontrol *kcontrol, | |||
1553 | struct hda_codec *codec = info->private_data; | 1580 | struct hda_codec *codec = info->private_data; |
1554 | struct hdmi_spec *spec = codec->spec; | 1581 | struct hdmi_spec *spec = codec->spec; |
1555 | int pin_idx = kcontrol->private_value; | 1582 | int pin_idx = kcontrol->private_value; |
1556 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; | 1583 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
1557 | int i; | 1584 | int i; |
1558 | 1585 | ||
1559 | for (i = 0; i < ARRAY_SIZE(per_pin->chmap); i++) | 1586 | for (i = 0; i < ARRAY_SIZE(per_pin->chmap); i++) |
@@ -1568,7 +1595,7 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, | |||
1568 | struct hda_codec *codec = info->private_data; | 1595 | struct hda_codec *codec = info->private_data; |
1569 | struct hdmi_spec *spec = codec->spec; | 1596 | struct hdmi_spec *spec = codec->spec; |
1570 | int pin_idx = kcontrol->private_value; | 1597 | int pin_idx = kcontrol->private_value; |
1571 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; | 1598 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
1572 | unsigned int ctl_idx; | 1599 | unsigned int ctl_idx; |
1573 | struct snd_pcm_substream *substream; | 1600 | struct snd_pcm_substream *substream; |
1574 | unsigned char chmap[8]; | 1601 | unsigned char chmap[8]; |
@@ -1613,9 +1640,14 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec) | |||
1613 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { | 1640 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { |
1614 | struct hda_pcm *info; | 1641 | struct hda_pcm *info; |
1615 | struct hda_pcm_stream *pstr; | 1642 | struct hda_pcm_stream *pstr; |
1616 | 1643 | struct hdmi_spec_per_pin *per_pin; | |
1617 | info = &spec->pcm_rec[pin_idx]; | 1644 | |
1618 | info->name = get_hdmi_pcm_name(pin_idx); | 1645 | per_pin = get_pin(spec, pin_idx); |
1646 | sprintf(per_pin->pcm_name, "HDMI %d", pin_idx); | ||
1647 | info = snd_array_new(&spec->pcm_rec); | ||
1648 | if (!info) | ||
1649 | return -ENOMEM; | ||
1650 | info->name = per_pin->pcm_name; | ||
1619 | info->pcm_type = HDA_PCM_TYPE_HDMI; | 1651 | info->pcm_type = HDA_PCM_TYPE_HDMI; |
1620 | info->own_chmap = true; | 1652 | info->own_chmap = true; |
1621 | 1653 | ||
@@ -1626,7 +1658,7 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec) | |||
1626 | } | 1658 | } |
1627 | 1659 | ||
1628 | codec->num_pcms = spec->num_pins; | 1660 | codec->num_pcms = spec->num_pins; |
1629 | codec->pcm_info = spec->pcm_rec; | 1661 | codec->pcm_info = spec->pcm_rec.list; |
1630 | 1662 | ||
1631 | return 0; | 1663 | return 0; |
1632 | } | 1664 | } |
@@ -1635,8 +1667,8 @@ static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx) | |||
1635 | { | 1667 | { |
1636 | char hdmi_str[32] = "HDMI/DP"; | 1668 | char hdmi_str[32] = "HDMI/DP"; |
1637 | struct hdmi_spec *spec = codec->spec; | 1669 | struct hdmi_spec *spec = codec->spec; |
1638 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; | 1670 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
1639 | int pcmdev = spec->pcm_rec[pin_idx].device; | 1671 | int pcmdev = get_pcm_rec(spec, pin_idx)->device; |
1640 | 1672 | ||
1641 | if (pcmdev > 0) | 1673 | if (pcmdev > 0) |
1642 | sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev); | 1674 | sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev); |
@@ -1654,7 +1686,7 @@ static int generic_hdmi_build_controls(struct hda_codec *codec) | |||
1654 | int pin_idx; | 1686 | int pin_idx; |
1655 | 1687 | ||
1656 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { | 1688 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { |
1657 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; | 1689 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
1658 | 1690 | ||
1659 | err = generic_hdmi_build_jack(codec, pin_idx); | 1691 | err = generic_hdmi_build_jack(codec, pin_idx); |
1660 | if (err < 0) | 1692 | if (err < 0) |
@@ -1669,9 +1701,8 @@ static int generic_hdmi_build_controls(struct hda_codec *codec) | |||
1669 | snd_hda_spdif_ctls_unassign(codec, pin_idx); | 1701 | snd_hda_spdif_ctls_unassign(codec, pin_idx); |
1670 | 1702 | ||
1671 | /* add control for ELD Bytes */ | 1703 | /* add control for ELD Bytes */ |
1672 | err = hdmi_create_eld_ctl(codec, | 1704 | err = hdmi_create_eld_ctl(codec, pin_idx, |
1673 | pin_idx, | 1705 | get_pcm_rec(spec, pin_idx)->device); |
1674 | spec->pcm_rec[pin_idx].device); | ||
1675 | 1706 | ||
1676 | if (err < 0) | 1707 | if (err < 0) |
1677 | return err; | 1708 | return err; |
@@ -1709,7 +1740,7 @@ static int generic_hdmi_init_per_pins(struct hda_codec *codec) | |||
1709 | int pin_idx; | 1740 | int pin_idx; |
1710 | 1741 | ||
1711 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { | 1742 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { |
1712 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; | 1743 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
1713 | struct hdmi_eld *eld = &per_pin->sink_eld; | 1744 | struct hdmi_eld *eld = &per_pin->sink_eld; |
1714 | 1745 | ||
1715 | per_pin->codec = codec; | 1746 | per_pin->codec = codec; |
@@ -1726,7 +1757,7 @@ static int generic_hdmi_init(struct hda_codec *codec) | |||
1726 | int pin_idx; | 1757 | int pin_idx; |
1727 | 1758 | ||
1728 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { | 1759 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { |
1729 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; | 1760 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
1730 | hda_nid_t pin_nid = per_pin->pin_nid; | 1761 | hda_nid_t pin_nid = per_pin->pin_nid; |
1731 | 1762 | ||
1732 | hdmi_init_pin(codec, pin_nid); | 1763 | hdmi_init_pin(codec, pin_nid); |
@@ -1735,13 +1766,27 @@ static int generic_hdmi_init(struct hda_codec *codec) | |||
1735 | return 0; | 1766 | return 0; |
1736 | } | 1767 | } |
1737 | 1768 | ||
1769 | static void hdmi_array_init(struct hdmi_spec *spec, int nums) | ||
1770 | { | ||
1771 | snd_array_init(&spec->pins, sizeof(struct hdmi_spec_per_pin), nums); | ||
1772 | snd_array_init(&spec->cvts, sizeof(struct hdmi_spec_per_cvt), nums); | ||
1773 | snd_array_init(&spec->pcm_rec, sizeof(struct hda_pcm), nums); | ||
1774 | } | ||
1775 | |||
1776 | static void hdmi_array_free(struct hdmi_spec *spec) | ||
1777 | { | ||
1778 | snd_array_free(&spec->pins); | ||
1779 | snd_array_free(&spec->cvts); | ||
1780 | snd_array_free(&spec->pcm_rec); | ||
1781 | } | ||
1782 | |||
1738 | static void generic_hdmi_free(struct hda_codec *codec) | 1783 | static void generic_hdmi_free(struct hda_codec *codec) |
1739 | { | 1784 | { |
1740 | struct hdmi_spec *spec = codec->spec; | 1785 | struct hdmi_spec *spec = codec->spec; |
1741 | int pin_idx; | 1786 | int pin_idx; |
1742 | 1787 | ||
1743 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { | 1788 | for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { |
1744 | struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx]; | 1789 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); |
1745 | struct hdmi_eld *eld = &per_pin->sink_eld; | 1790 | struct hdmi_eld *eld = &per_pin->sink_eld; |
1746 | 1791 | ||
1747 | cancel_delayed_work(&per_pin->work); | 1792 | cancel_delayed_work(&per_pin->work); |
@@ -1749,6 +1794,7 @@ static void generic_hdmi_free(struct hda_codec *codec) | |||
1749 | } | 1794 | } |
1750 | 1795 | ||
1751 | flush_workqueue(codec->bus->workq); | 1796 | flush_workqueue(codec->bus->workq); |
1797 | hdmi_array_free(spec); | ||
1752 | kfree(spec); | 1798 | kfree(spec); |
1753 | } | 1799 | } |
1754 | 1800 | ||
@@ -1775,6 +1821,7 @@ static void intel_haswell_fixup_connect_list(struct hda_codec *codec, | |||
1775 | 1821 | ||
1776 | /* override pins connection list */ | 1822 | /* override pins connection list */ |
1777 | snd_printdd("hdmi: haswell: override pin connection 0x%x\n", nid); | 1823 | snd_printdd("hdmi: haswell: override pin connection 0x%x\n", nid); |
1824 | nconns = max(spec->num_cvts, 4); | ||
1778 | snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids); | 1825 | snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids); |
1779 | } | 1826 | } |
1780 | 1827 | ||
@@ -1855,6 +1902,7 @@ static int patch_generic_hdmi(struct hda_codec *codec) | |||
1855 | return -ENOMEM; | 1902 | return -ENOMEM; |
1856 | 1903 | ||
1857 | codec->spec = spec; | 1904 | codec->spec = spec; |
1905 | hdmi_array_init(spec, 4); | ||
1858 | 1906 | ||
1859 | snd_hda_pick_fixup(codec, hdmi_models, hdmi_fixup_tbl, hdmi_fixups); | 1907 | snd_hda_pick_fixup(codec, hdmi_models, hdmi_fixup_tbl, hdmi_fixups); |
1860 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | 1908 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
@@ -1882,24 +1930,30 @@ static int patch_generic_hdmi(struct hda_codec *codec) | |||
1882 | static int simple_playback_build_pcms(struct hda_codec *codec) | 1930 | static int simple_playback_build_pcms(struct hda_codec *codec) |
1883 | { | 1931 | { |
1884 | struct hdmi_spec *spec = codec->spec; | 1932 | struct hdmi_spec *spec = codec->spec; |
1885 | struct hda_pcm *info = spec->pcm_rec; | 1933 | struct hda_pcm *info; |
1886 | unsigned int chans; | 1934 | unsigned int chans; |
1887 | struct hda_pcm_stream *pstr; | 1935 | struct hda_pcm_stream *pstr; |
1936 | struct hdmi_spec_per_cvt *per_cvt; | ||
1888 | 1937 | ||
1889 | codec->num_pcms = 1; | 1938 | per_cvt = get_cvt(spec, 0); |
1890 | codec->pcm_info = info; | 1939 | chans = get_wcaps(codec, per_cvt->cvt_nid); |
1891 | |||
1892 | chans = get_wcaps(codec, spec->cvts[0].cvt_nid); | ||
1893 | chans = get_wcaps_channels(chans); | 1940 | chans = get_wcaps_channels(chans); |
1894 | 1941 | ||
1895 | info->name = get_hdmi_pcm_name(0); | 1942 | info = snd_array_new(&spec->pcm_rec); |
1943 | if (!info) | ||
1944 | return -ENOMEM; | ||
1945 | info->name = get_pin(spec, 0)->pcm_name; | ||
1946 | sprintf(info->name, "HDMI 0"); | ||
1896 | info->pcm_type = HDA_PCM_TYPE_HDMI; | 1947 | info->pcm_type = HDA_PCM_TYPE_HDMI; |
1897 | pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; | 1948 | pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; |
1898 | *pstr = spec->pcm_playback; | 1949 | *pstr = spec->pcm_playback; |
1899 | pstr->nid = spec->cvts[0].cvt_nid; | 1950 | pstr->nid = per_cvt->cvt_nid; |
1900 | if (pstr->channels_max <= 2 && chans && chans <= 16) | 1951 | if (pstr->channels_max <= 2 && chans && chans <= 16) |
1901 | pstr->channels_max = chans; | 1952 | pstr->channels_max = chans; |
1902 | 1953 | ||
1954 | codec->num_pcms = 1; | ||
1955 | codec->pcm_info = info; | ||
1956 | |||
1903 | return 0; | 1957 | return 0; |
1904 | } | 1958 | } |
1905 | 1959 | ||
@@ -1919,11 +1973,12 @@ static void simple_hdmi_unsol_event(struct hda_codec *codec, | |||
1919 | static int simple_playback_build_controls(struct hda_codec *codec) | 1973 | static int simple_playback_build_controls(struct hda_codec *codec) |
1920 | { | 1974 | { |
1921 | struct hdmi_spec *spec = codec->spec; | 1975 | struct hdmi_spec *spec = codec->spec; |
1976 | struct hdmi_spec_per_cvt *per_cvt; | ||
1922 | int err; | 1977 | int err; |
1923 | 1978 | ||
1924 | err = snd_hda_create_spdif_out_ctls(codec, | 1979 | per_cvt = get_cvt(spec, 0); |
1925 | spec->cvts[0].cvt_nid, | 1980 | err = snd_hda_create_spdif_out_ctls(codec, per_cvt->cvt_nid, |
1926 | spec->cvts[0].cvt_nid); | 1981 | per_cvt->cvt_nid); |
1927 | if (err < 0) | 1982 | if (err < 0) |
1928 | return err; | 1983 | return err; |
1929 | return simple_hdmi_build_jack(codec, 0); | 1984 | return simple_hdmi_build_jack(codec, 0); |
@@ -1932,7 +1987,8 @@ static int simple_playback_build_controls(struct hda_codec *codec) | |||
1932 | static int simple_playback_init(struct hda_codec *codec) | 1987 | static int simple_playback_init(struct hda_codec *codec) |
1933 | { | 1988 | { |
1934 | struct hdmi_spec *spec = codec->spec; | 1989 | struct hdmi_spec *spec = codec->spec; |
1935 | hda_nid_t pin = spec->pins[0].pin_nid; | 1990 | struct hdmi_spec_per_pin *per_pin = get_pin(spec, 0); |
1991 | hda_nid_t pin = per_pin->pin_nid; | ||
1936 | 1992 | ||
1937 | snd_hda_codec_write(codec, pin, 0, | 1993 | snd_hda_codec_write(codec, pin, 0, |
1938 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | 1994 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); |
@@ -1948,6 +2004,7 @@ static void simple_playback_free(struct hda_codec *codec) | |||
1948 | { | 2004 | { |
1949 | struct hdmi_spec *spec = codec->spec; | 2005 | struct hdmi_spec *spec = codec->spec; |
1950 | 2006 | ||
2007 | hdmi_array_free(spec); | ||
1951 | kfree(spec); | 2008 | kfree(spec); |
1952 | } | 2009 | } |
1953 | 2010 | ||
@@ -2111,20 +2168,29 @@ static int patch_simple_hdmi(struct hda_codec *codec, | |||
2111 | hda_nid_t cvt_nid, hda_nid_t pin_nid) | 2168 | hda_nid_t cvt_nid, hda_nid_t pin_nid) |
2112 | { | 2169 | { |
2113 | struct hdmi_spec *spec; | 2170 | struct hdmi_spec *spec; |
2171 | struct hdmi_spec_per_cvt *per_cvt; | ||
2172 | struct hdmi_spec_per_pin *per_pin; | ||
2114 | 2173 | ||
2115 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 2174 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
2116 | if (!spec) | 2175 | if (!spec) |
2117 | return -ENOMEM; | 2176 | return -ENOMEM; |
2118 | 2177 | ||
2119 | codec->spec = spec; | 2178 | codec->spec = spec; |
2179 | hdmi_array_init(spec, 1); | ||
2120 | 2180 | ||
2121 | spec->multiout.num_dacs = 0; /* no analog */ | 2181 | spec->multiout.num_dacs = 0; /* no analog */ |
2122 | spec->multiout.max_channels = 2; | 2182 | spec->multiout.max_channels = 2; |
2123 | spec->multiout.dig_out_nid = cvt_nid; | 2183 | spec->multiout.dig_out_nid = cvt_nid; |
2124 | spec->num_cvts = 1; | 2184 | spec->num_cvts = 1; |
2125 | spec->num_pins = 1; | 2185 | spec->num_pins = 1; |
2126 | spec->cvts[0].cvt_nid = cvt_nid; | 2186 | per_pin = snd_array_new(&spec->pins); |
2127 | spec->pins[0].pin_nid = pin_nid; | 2187 | per_cvt = snd_array_new(&spec->cvts); |
2188 | if (!per_pin || !per_cvt) { | ||
2189 | simple_playback_free(codec); | ||
2190 | return -ENOMEM; | ||
2191 | } | ||
2192 | per_cvt->cvt_nid = cvt_nid; | ||
2193 | per_pin->pin_nid = pin_nid; | ||
2128 | spec->pcm_playback = simple_pcm_playback; | 2194 | spec->pcm_playback = simple_pcm_playback; |
2129 | 2195 | ||
2130 | codec->patch_ops = simple_hdmi_patch_ops; | 2196 | codec->patch_ops = simple_hdmi_patch_ops; |
@@ -2201,9 +2267,11 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
2201 | int i; | 2267 | int i; |
2202 | struct hdmi_spec *spec = codec->spec; | 2268 | struct hdmi_spec *spec = codec->spec; |
2203 | struct hda_spdif_out *spdif; | 2269 | struct hda_spdif_out *spdif; |
2270 | struct hdmi_spec_per_cvt *per_cvt; | ||
2204 | 2271 | ||
2205 | mutex_lock(&codec->spdif_mutex); | 2272 | mutex_lock(&codec->spdif_mutex); |
2206 | spdif = snd_hda_spdif_out_of_nid(codec, spec->cvts[0].cvt_nid); | 2273 | per_cvt = get_cvt(spec, 0); |
2274 | spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); | ||
2207 | 2275 | ||
2208 | chs = substream->runtime->channels; | 2276 | chs = substream->runtime->channels; |
2209 | 2277 | ||
@@ -2325,13 +2393,17 @@ static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) | |||
2325 | { | 2393 | { |
2326 | struct hdmi_spec *spec = codec->spec; | 2394 | struct hdmi_spec *spec = codec->spec; |
2327 | int err = simple_playback_build_pcms(codec); | 2395 | int err = simple_playback_build_pcms(codec); |
2328 | spec->pcm_rec[0].own_chmap = true; | 2396 | if (!err) { |
2397 | struct hda_pcm *info = get_pcm_rec(spec, 0); | ||
2398 | info->own_chmap = true; | ||
2399 | } | ||
2329 | return err; | 2400 | return err; |
2330 | } | 2401 | } |
2331 | 2402 | ||
2332 | static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) | 2403 | static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) |
2333 | { | 2404 | { |
2334 | struct hdmi_spec *spec = codec->spec; | 2405 | struct hdmi_spec *spec = codec->spec; |
2406 | struct hda_pcm *info; | ||
2335 | struct snd_pcm_chmap *chmap; | 2407 | struct snd_pcm_chmap *chmap; |
2336 | int err; | 2408 | int err; |
2337 | 2409 | ||
@@ -2340,7 +2412,8 @@ static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) | |||
2340 | return err; | 2412 | return err; |
2341 | 2413 | ||
2342 | /* add channel maps */ | 2414 | /* add channel maps */ |
2343 | err = snd_pcm_add_chmap_ctls(spec->pcm_rec[0].pcm, | 2415 | info = get_pcm_rec(spec, 0); |
2416 | err = snd_pcm_add_chmap_ctls(info->pcm, | ||
2344 | SNDRV_PCM_STREAM_PLAYBACK, | 2417 | SNDRV_PCM_STREAM_PLAYBACK, |
2345 | snd_pcm_alt_chmaps, 8, 0, &chmap); | 2418 | snd_pcm_alt_chmaps, 8, 0, &chmap); |
2346 | if (err < 0) | 2419 | if (err < 0) |
@@ -2395,6 +2468,7 @@ static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
2395 | struct snd_pcm_substream *substream) | 2468 | struct snd_pcm_substream *substream) |
2396 | { | 2469 | { |
2397 | struct hdmi_spec *spec = codec->spec; | 2470 | struct hdmi_spec *spec = codec->spec; |
2471 | struct hdmi_spec_per_cvt *per_cvt = get_cvt(spec, 0); | ||
2398 | int chans = substream->runtime->channels; | 2472 | int chans = substream->runtime->channels; |
2399 | int i, err; | 2473 | int i, err; |
2400 | 2474 | ||
@@ -2402,11 +2476,11 @@ static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
2402 | substream); | 2476 | substream); |
2403 | if (err < 0) | 2477 | if (err < 0) |
2404 | return err; | 2478 | return err; |
2405 | snd_hda_codec_write(codec, spec->cvts[0].cvt_nid, 0, | 2479 | snd_hda_codec_write(codec, per_cvt->cvt_nid, 0, |
2406 | AC_VERB_SET_CVT_CHAN_COUNT, chans - 1); | 2480 | AC_VERB_SET_CVT_CHAN_COUNT, chans - 1); |
2407 | /* FIXME: XXX */ | 2481 | /* FIXME: XXX */ |
2408 | for (i = 0; i < chans; i++) { | 2482 | for (i = 0; i < chans; i++) { |
2409 | snd_hda_codec_write(codec, spec->cvts[0].cvt_nid, 0, | 2483 | snd_hda_codec_write(codec, per_cvt->cvt_nid, 0, |
2410 | AC_VERB_SET_HDMI_CHAN_SLOT, | 2484 | AC_VERB_SET_HDMI_CHAN_SLOT, |
2411 | (i << 4) | i); | 2485 | (i << 4) | i); |
2412 | } | 2486 | } |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f15c36bde540..6bf47f7326ad 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include "hda_codec.h" | 34 | #include "hda_codec.h" |
35 | #include "hda_local.h" | 35 | #include "hda_local.h" |
36 | #include "hda_auto_parser.h" | 36 | #include "hda_auto_parser.h" |
37 | #include "hda_beep.h" | ||
38 | #include "hda_jack.h" | 37 | #include "hda_jack.h" |
39 | #include "hda_generic.h" | 38 | #include "hda_generic.h" |
40 | 39 | ||
@@ -53,6 +52,20 @@ enum { | |||
53 | ALC_INIT_GPIO3, | 52 | ALC_INIT_GPIO3, |
54 | }; | 53 | }; |
55 | 54 | ||
55 | enum { | ||
56 | ALC_HEADSET_MODE_UNKNOWN, | ||
57 | ALC_HEADSET_MODE_UNPLUGGED, | ||
58 | ALC_HEADSET_MODE_HEADSET, | ||
59 | ALC_HEADSET_MODE_MIC, | ||
60 | ALC_HEADSET_MODE_HEADPHONE, | ||
61 | }; | ||
62 | |||
63 | enum { | ||
64 | ALC_HEADSET_TYPE_UNKNOWN, | ||
65 | ALC_HEADSET_TYPE_CTIA, | ||
66 | ALC_HEADSET_TYPE_OMTP, | ||
67 | }; | ||
68 | |||
56 | struct alc_customize_define { | 69 | struct alc_customize_define { |
57 | unsigned int sku_cfg; | 70 | unsigned int sku_cfg; |
58 | unsigned char port_connectivity; | 71 | unsigned char port_connectivity; |
@@ -86,6 +99,13 @@ struct alc_spec { | |||
86 | int mute_led_polarity; | 99 | int mute_led_polarity; |
87 | hda_nid_t mute_led_nid; | 100 | hda_nid_t mute_led_nid; |
88 | 101 | ||
102 | unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */ | ||
103 | |||
104 | hda_nid_t headset_mic_pin; | ||
105 | hda_nid_t headphone_mic_pin; | ||
106 | int current_headset_mode; | ||
107 | int current_headset_type; | ||
108 | |||
89 | /* hooks */ | 109 | /* hooks */ |
90 | void (*init_hook)(struct hda_codec *codec); | 110 | void (*init_hook)(struct hda_codec *codec); |
91 | #ifdef CONFIG_PM | 111 | #ifdef CONFIG_PM |
@@ -805,17 +825,7 @@ static inline void alc_shutup(struct hda_codec *codec) | |||
805 | snd_hda_shutup_pins(codec); | 825 | snd_hda_shutup_pins(codec); |
806 | } | 826 | } |
807 | 827 | ||
808 | static void alc_free(struct hda_codec *codec) | 828 | #define alc_free snd_hda_gen_free |
809 | { | ||
810 | struct alc_spec *spec = codec->spec; | ||
811 | |||
812 | if (!spec) | ||
813 | return; | ||
814 | |||
815 | snd_hda_gen_spec_free(&spec->gen); | ||
816 | snd_hda_detach_beep_device(codec); | ||
817 | kfree(spec); | ||
818 | } | ||
819 | 829 | ||
820 | #ifdef CONFIG_PM | 830 | #ifdef CONFIG_PM |
821 | static void alc_power_eapd(struct hda_codec *codec) | 831 | static void alc_power_eapd(struct hda_codec *codec) |
@@ -1401,6 +1411,7 @@ static int patch_alc880(struct hda_codec *codec) | |||
1401 | 1411 | ||
1402 | spec = codec->spec; | 1412 | spec = codec->spec; |
1403 | spec->gen.need_dac_fix = 1; | 1413 | spec->gen.need_dac_fix = 1; |
1414 | spec->gen.beep_nid = 0x01; | ||
1404 | 1415 | ||
1405 | snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, | 1416 | snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
1406 | alc880_fixups); | 1417 | alc880_fixups); |
@@ -1411,12 +1422,8 @@ static int patch_alc880(struct hda_codec *codec) | |||
1411 | if (err < 0) | 1422 | if (err < 0) |
1412 | goto error; | 1423 | goto error; |
1413 | 1424 | ||
1414 | if (!spec->gen.no_analog) { | 1425 | if (!spec->gen.no_analog) |
1415 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
1416 | if (err < 0) | ||
1417 | goto error; | ||
1418 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 1426 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
1419 | } | ||
1420 | 1427 | ||
1421 | codec->patch_ops = alc_patch_ops; | 1428 | codec->patch_ops = alc_patch_ops; |
1422 | codec->patch_ops.unsol_event = alc880_unsol_event; | 1429 | codec->patch_ops.unsol_event = alc880_unsol_event; |
@@ -1455,6 +1462,7 @@ enum { | |||
1455 | ALC260_FIXUP_HP_B1900, | 1462 | ALC260_FIXUP_HP_B1900, |
1456 | ALC260_FIXUP_KN1, | 1463 | ALC260_FIXUP_KN1, |
1457 | ALC260_FIXUP_FSC_S7020, | 1464 | ALC260_FIXUP_FSC_S7020, |
1465 | ALC260_FIXUP_FSC_S7020_JWSE, | ||
1458 | }; | 1466 | }; |
1459 | 1467 | ||
1460 | static void alc260_gpio1_automute(struct hda_codec *codec) | 1468 | static void alc260_gpio1_automute(struct hda_codec *codec) |
@@ -1516,14 +1524,17 @@ static void alc260_fixup_fsc_s7020(struct hda_codec *codec, | |||
1516 | const struct hda_fixup *fix, int action) | 1524 | const struct hda_fixup *fix, int action) |
1517 | { | 1525 | { |
1518 | struct alc_spec *spec = codec->spec; | 1526 | struct alc_spec *spec = codec->spec; |
1519 | 1527 | if (action == HDA_FIXUP_ACT_PROBE) | |
1520 | switch (action) { | ||
1521 | case HDA_FIXUP_ACT_PRE_PROBE: | ||
1522 | spec->gen.add_out_jack_modes = 1; | ||
1523 | break; | ||
1524 | case HDA_FIXUP_ACT_PROBE: | ||
1525 | spec->init_amp = ALC_INIT_NONE; | 1528 | spec->init_amp = ALC_INIT_NONE; |
1526 | break; | 1529 | } |
1530 | |||
1531 | static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec, | ||
1532 | const struct hda_fixup *fix, int action) | ||
1533 | { | ||
1534 | struct alc_spec *spec = codec->spec; | ||
1535 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | ||
1536 | spec->gen.add_jack_modes = 1; | ||
1537 | spec->gen.hp_mic = 1; | ||
1527 | } | 1538 | } |
1528 | } | 1539 | } |
1529 | 1540 | ||
@@ -1586,6 +1597,12 @@ static const struct hda_fixup alc260_fixups[] = { | |||
1586 | .type = HDA_FIXUP_FUNC, | 1597 | .type = HDA_FIXUP_FUNC, |
1587 | .v.func = alc260_fixup_fsc_s7020, | 1598 | .v.func = alc260_fixup_fsc_s7020, |
1588 | }, | 1599 | }, |
1600 | [ALC260_FIXUP_FSC_S7020_JWSE] = { | ||
1601 | .type = HDA_FIXUP_FUNC, | ||
1602 | .v.func = alc260_fixup_fsc_s7020_jwse, | ||
1603 | .chained = true, | ||
1604 | .chain_id = ALC260_FIXUP_FSC_S7020, | ||
1605 | }, | ||
1589 | }; | 1606 | }; |
1590 | 1607 | ||
1591 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { | 1608 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
@@ -1602,6 +1619,14 @@ static const struct snd_pci_quirk alc260_fixup_tbl[] = { | |||
1602 | {} | 1619 | {} |
1603 | }; | 1620 | }; |
1604 | 1621 | ||
1622 | static const struct hda_model_fixup alc260_fixup_models[] = { | ||
1623 | {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"}, | ||
1624 | {.id = ALC260_FIXUP_COEF, .name = "coef"}, | ||
1625 | {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"}, | ||
1626 | {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"}, | ||
1627 | {} | ||
1628 | }; | ||
1629 | |||
1605 | /* | 1630 | /* |
1606 | */ | 1631 | */ |
1607 | static int patch_alc260(struct hda_codec *codec) | 1632 | static int patch_alc260(struct hda_codec *codec) |
@@ -1619,8 +1644,10 @@ static int patch_alc260(struct hda_codec *codec) | |||
1619 | * it's almost harmless. | 1644 | * it's almost harmless. |
1620 | */ | 1645 | */ |
1621 | spec->gen.prefer_hp_amp = 1; | 1646 | spec->gen.prefer_hp_amp = 1; |
1647 | spec->gen.beep_nid = 0x01; | ||
1622 | 1648 | ||
1623 | snd_hda_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); | 1649 | snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl, |
1650 | alc260_fixups); | ||
1624 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | 1651 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
1625 | 1652 | ||
1626 | /* automatic parse from the BIOS config */ | 1653 | /* automatic parse from the BIOS config */ |
@@ -1628,12 +1655,8 @@ static int patch_alc260(struct hda_codec *codec) | |||
1628 | if (err < 0) | 1655 | if (err < 0) |
1629 | goto error; | 1656 | goto error; |
1630 | 1657 | ||
1631 | if (!spec->gen.no_analog) { | 1658 | if (!spec->gen.no_analog) |
1632 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
1633 | if (err < 0) | ||
1634 | goto error; | ||
1635 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); | 1659 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
1636 | } | ||
1637 | 1660 | ||
1638 | codec->patch_ops = alc_patch_ops; | 1661 | codec->patch_ops = alc_patch_ops; |
1639 | spec->shutup = alc_eapd_shutup; | 1662 | spec->shutup = alc_eapd_shutup; |
@@ -2132,17 +2155,16 @@ static int patch_alc882(struct hda_codec *codec) | |||
2132 | 2155 | ||
2133 | alc_auto_parse_customize_define(codec); | 2156 | alc_auto_parse_customize_define(codec); |
2134 | 2157 | ||
2158 | if (has_cdefine_beep(codec)) | ||
2159 | spec->gen.beep_nid = 0x01; | ||
2160 | |||
2135 | /* automatic parse from the BIOS config */ | 2161 | /* automatic parse from the BIOS config */ |
2136 | err = alc882_parse_auto_config(codec); | 2162 | err = alc882_parse_auto_config(codec); |
2137 | if (err < 0) | 2163 | if (err < 0) |
2138 | goto error; | 2164 | goto error; |
2139 | 2165 | ||
2140 | if (!spec->gen.no_analog && has_cdefine_beep(codec)) { | 2166 | if (!spec->gen.no_analog && spec->gen.beep_nid) |
2141 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
2142 | if (err < 0) | ||
2143 | goto error; | ||
2144 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 2167 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
2145 | } | ||
2146 | 2168 | ||
2147 | codec->patch_ops = alc_patch_ops; | 2169 | codec->patch_ops = alc_patch_ops; |
2148 | 2170 | ||
@@ -2295,17 +2317,16 @@ static int patch_alc262(struct hda_codec *codec) | |||
2295 | 2317 | ||
2296 | alc_auto_parse_customize_define(codec); | 2318 | alc_auto_parse_customize_define(codec); |
2297 | 2319 | ||
2320 | if (has_cdefine_beep(codec)) | ||
2321 | spec->gen.beep_nid = 0x01; | ||
2322 | |||
2298 | /* automatic parse from the BIOS config */ | 2323 | /* automatic parse from the BIOS config */ |
2299 | err = alc262_parse_auto_config(codec); | 2324 | err = alc262_parse_auto_config(codec); |
2300 | if (err < 0) | 2325 | if (err < 0) |
2301 | goto error; | 2326 | goto error; |
2302 | 2327 | ||
2303 | if (!spec->gen.no_analog && has_cdefine_beep(codec)) { | 2328 | if (!spec->gen.no_analog && spec->gen.beep_nid) |
2304 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
2305 | if (err < 0) | ||
2306 | goto error; | ||
2307 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 2329 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
2308 | } | ||
2309 | 2330 | ||
2310 | codec->patch_ops = alc_patch_ops; | 2331 | codec->patch_ops = alc_patch_ops; |
2311 | spec->shutup = alc_eapd_shutup; | 2332 | spec->shutup = alc_eapd_shutup; |
@@ -2386,16 +2407,7 @@ static const struct snd_pci_quirk alc268_fixup_tbl[] = { | |||
2386 | static int alc268_parse_auto_config(struct hda_codec *codec) | 2407 | static int alc268_parse_auto_config(struct hda_codec *codec) |
2387 | { | 2408 | { |
2388 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; | 2409 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
2389 | struct alc_spec *spec = codec->spec; | 2410 | return alc_parse_auto_config(codec, NULL, alc268_ssids); |
2390 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); | ||
2391 | if (err > 0) { | ||
2392 | if (!spec->gen.no_analog && | ||
2393 | spec->gen.autocfg.speaker_pins[0] != 0x1d) { | ||
2394 | add_mixer(spec, alc268_beep_mixer); | ||
2395 | snd_hda_add_verbs(codec, alc268_beep_init_verbs); | ||
2396 | } | ||
2397 | } | ||
2398 | return err; | ||
2399 | } | 2411 | } |
2400 | 2412 | ||
2401 | /* | 2413 | /* |
@@ -2403,7 +2415,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec) | |||
2403 | static int patch_alc268(struct hda_codec *codec) | 2415 | static int patch_alc268(struct hda_codec *codec) |
2404 | { | 2416 | { |
2405 | struct alc_spec *spec; | 2417 | struct alc_spec *spec; |
2406 | int i, has_beep, err; | 2418 | int err; |
2407 | 2419 | ||
2408 | /* ALC268 has no aa-loopback mixer */ | 2420 | /* ALC268 has no aa-loopback mixer */ |
2409 | err = alc_alloc_spec(codec, 0); | 2421 | err = alc_alloc_spec(codec, 0); |
@@ -2411,6 +2423,7 @@ static int patch_alc268(struct hda_codec *codec) | |||
2411 | return err; | 2423 | return err; |
2412 | 2424 | ||
2413 | spec = codec->spec; | 2425 | spec = codec->spec; |
2426 | spec->gen.beep_nid = 0x01; | ||
2414 | 2427 | ||
2415 | snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); | 2428 | snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); |
2416 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | 2429 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
@@ -2420,18 +2433,10 @@ static int patch_alc268(struct hda_codec *codec) | |||
2420 | if (err < 0) | 2433 | if (err < 0) |
2421 | goto error; | 2434 | goto error; |
2422 | 2435 | ||
2423 | has_beep = 0; | 2436 | if (err > 0 && !spec->gen.no_analog && |
2424 | for (i = 0; i < spec->num_mixers; i++) { | 2437 | spec->gen.autocfg.speaker_pins[0] != 0x1d) { |
2425 | if (spec->mixers[i] == alc268_beep_mixer) { | 2438 | add_mixer(spec, alc268_beep_mixer); |
2426 | has_beep = 1; | 2439 | snd_hda_add_verbs(codec, alc268_beep_init_verbs); |
2427 | break; | ||
2428 | } | ||
2429 | } | ||
2430 | |||
2431 | if (has_beep) { | ||
2432 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
2433 | if (err < 0) | ||
2434 | goto error; | ||
2435 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) | 2440 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
2436 | /* override the amp caps for beep generator */ | 2441 | /* override the amp caps for beep generator */ |
2437 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, | 2442 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
@@ -2515,6 +2520,7 @@ enum { | |||
2515 | ALC269_TYPE_ALC280, | 2520 | ALC269_TYPE_ALC280, |
2516 | ALC269_TYPE_ALC282, | 2521 | ALC269_TYPE_ALC282, |
2517 | ALC269_TYPE_ALC284, | 2522 | ALC269_TYPE_ALC284, |
2523 | ALC269_TYPE_ALC286, | ||
2518 | }; | 2524 | }; |
2519 | 2525 | ||
2520 | /* | 2526 | /* |
@@ -2538,6 +2544,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
2538 | case ALC269_TYPE_ALC269VB: | 2544 | case ALC269_TYPE_ALC269VB: |
2539 | case ALC269_TYPE_ALC269VD: | 2545 | case ALC269_TYPE_ALC269VD: |
2540 | case ALC269_TYPE_ALC282: | 2546 | case ALC269_TYPE_ALC282: |
2547 | case ALC269_TYPE_ALC286: | ||
2541 | ssids = alc269_ssids; | 2548 | ssids = alc269_ssids; |
2542 | break; | 2549 | break; |
2543 | default: | 2550 | default: |
@@ -2631,7 +2638,8 @@ static void alc271_fixup_dmic(struct hda_codec *codec, | |||
2631 | }; | 2638 | }; |
2632 | unsigned int cfg; | 2639 | unsigned int cfg; |
2633 | 2640 | ||
2634 | if (strcmp(codec->chip_name, "ALC271X")) | 2641 | if (strcmp(codec->chip_name, "ALC271X") && |
2642 | strcmp(codec->chip_name, "ALC269VB")) | ||
2635 | return; | 2643 | return; |
2636 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); | 2644 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
2637 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) | 2645 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
@@ -2693,6 +2701,34 @@ static void alc269_fixup_quanta_mute(struct hda_codec *codec, | |||
2693 | spec->gen.automute_hook = alc269_quanta_automute; | 2701 | spec->gen.automute_hook = alc269_quanta_automute; |
2694 | } | 2702 | } |
2695 | 2703 | ||
2704 | static void alc269_x101_hp_automute_hook(struct hda_codec *codec, | ||
2705 | struct hda_jack_tbl *jack) | ||
2706 | { | ||
2707 | struct alc_spec *spec = codec->spec; | ||
2708 | int vref; | ||
2709 | msleep(200); | ||
2710 | snd_hda_gen_hp_automute(codec, jack); | ||
2711 | |||
2712 | vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0; | ||
2713 | msleep(100); | ||
2714 | snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
2715 | vref); | ||
2716 | msleep(500); | ||
2717 | snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, | ||
2718 | vref); | ||
2719 | } | ||
2720 | |||
2721 | static void alc269_fixup_x101_headset_mic(struct hda_codec *codec, | ||
2722 | const struct hda_fixup *fix, int action) | ||
2723 | { | ||
2724 | struct alc_spec *spec = codec->spec; | ||
2725 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | ||
2726 | spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; | ||
2727 | spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook; | ||
2728 | } | ||
2729 | } | ||
2730 | |||
2731 | |||
2696 | /* update mute-LED according to the speaker mute state via mic VREF pin */ | 2732 | /* update mute-LED according to the speaker mute state via mic VREF pin */ |
2697 | static void alc269_fixup_mic_mute_hook(void *private_data, int enabled) | 2733 | static void alc269_fixup_mic_mute_hook(void *private_data, int enabled) |
2698 | { | 2734 | { |
@@ -2757,6 +2793,356 @@ static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec, | |||
2757 | } | 2793 | } |
2758 | } | 2794 | } |
2759 | 2795 | ||
2796 | /* turn on/off mute LED per vmaster hook */ | ||
2797 | static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled) | ||
2798 | { | ||
2799 | struct hda_codec *codec = private_data; | ||
2800 | struct alc_spec *spec = codec->spec; | ||
2801 | unsigned int oldval = spec->gpio_led; | ||
2802 | |||
2803 | if (enabled) | ||
2804 | spec->gpio_led &= ~0x08; | ||
2805 | else | ||
2806 | spec->gpio_led |= 0x08; | ||
2807 | if (spec->gpio_led != oldval) | ||
2808 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, | ||
2809 | spec->gpio_led); | ||
2810 | } | ||
2811 | |||
2812 | /* turn on/off mic-mute LED per capture hook */ | ||
2813 | static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec, | ||
2814 | struct snd_ctl_elem_value *ucontrol) | ||
2815 | { | ||
2816 | struct alc_spec *spec = codec->spec; | ||
2817 | unsigned int oldval = spec->gpio_led; | ||
2818 | |||
2819 | if (!ucontrol) | ||
2820 | return; | ||
2821 | |||
2822 | if (ucontrol->value.integer.value[0] || | ||
2823 | ucontrol->value.integer.value[1]) | ||
2824 | spec->gpio_led &= ~0x10; | ||
2825 | else | ||
2826 | spec->gpio_led |= 0x10; | ||
2827 | if (spec->gpio_led != oldval) | ||
2828 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, | ||
2829 | spec->gpio_led); | ||
2830 | } | ||
2831 | |||
2832 | static void alc269_fixup_hp_gpio_led(struct hda_codec *codec, | ||
2833 | const struct hda_fixup *fix, int action) | ||
2834 | { | ||
2835 | struct alc_spec *spec = codec->spec; | ||
2836 | static const struct hda_verb gpio_init[] = { | ||
2837 | { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 }, | ||
2838 | { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 }, | ||
2839 | {} | ||
2840 | }; | ||
2841 | |||
2842 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | ||
2843 | spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook; | ||
2844 | spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook; | ||
2845 | spec->gpio_led = 0; | ||
2846 | snd_hda_add_verbs(codec, gpio_init); | ||
2847 | } | ||
2848 | } | ||
2849 | |||
2850 | static void alc_headset_mode_unplugged(struct hda_codec *codec) | ||
2851 | { | ||
2852 | int val; | ||
2853 | |||
2854 | switch (codec->vendor_id) { | ||
2855 | case 0x10ec0283: | ||
2856 | alc_write_coef_idx(codec, 0x1b, 0x0c0b); | ||
2857 | alc_write_coef_idx(codec, 0x45, 0xc429); | ||
2858 | val = alc_read_coef_idx(codec, 0x35); | ||
2859 | alc_write_coef_idx(codec, 0x35, val & 0xbfff); | ||
2860 | alc_write_coef_idx(codec, 0x06, 0x2104); | ||
2861 | alc_write_coef_idx(codec, 0x1a, 0x0001); | ||
2862 | alc_write_coef_idx(codec, 0x26, 0x0004); | ||
2863 | alc_write_coef_idx(codec, 0x32, 0x42a3); | ||
2864 | break; | ||
2865 | case 0x10ec0292: | ||
2866 | alc_write_coef_idx(codec, 0x76, 0x000e); | ||
2867 | alc_write_coef_idx(codec, 0x6c, 0x2400); | ||
2868 | alc_write_coef_idx(codec, 0x18, 0x7308); | ||
2869 | alc_write_coef_idx(codec, 0x6b, 0xc429); | ||
2870 | break; | ||
2871 | case 0x10ec0668: | ||
2872 | alc_write_coef_idx(codec, 0x15, 0x0d40); | ||
2873 | alc_write_coef_idx(codec, 0xb7, 0x802b); | ||
2874 | break; | ||
2875 | } | ||
2876 | snd_printdd("Headset jack set to unplugged mode.\n"); | ||
2877 | } | ||
2878 | |||
2879 | |||
2880 | static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, | ||
2881 | hda_nid_t mic_pin) | ||
2882 | { | ||
2883 | int val; | ||
2884 | |||
2885 | switch (codec->vendor_id) { | ||
2886 | case 0x10ec0283: | ||
2887 | alc_write_coef_idx(codec, 0x45, 0xc429); | ||
2888 | snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); | ||
2889 | val = alc_read_coef_idx(codec, 0x35); | ||
2890 | alc_write_coef_idx(codec, 0x35, val | 1<<14); | ||
2891 | alc_write_coef_idx(codec, 0x06, 0x2100); | ||
2892 | alc_write_coef_idx(codec, 0x1a, 0x0021); | ||
2893 | alc_write_coef_idx(codec, 0x26, 0x008c); | ||
2894 | snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); | ||
2895 | break; | ||
2896 | case 0x10ec0292: | ||
2897 | snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); | ||
2898 | alc_write_coef_idx(codec, 0x19, 0xa208); | ||
2899 | alc_write_coef_idx(codec, 0x2e, 0xacf0); | ||
2900 | break; | ||
2901 | case 0x10ec0668: | ||
2902 | alc_write_coef_idx(codec, 0x11, 0x0001); | ||
2903 | snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); | ||
2904 | alc_write_coef_idx(codec, 0xb7, 0x802b); | ||
2905 | alc_write_coef_idx(codec, 0xb5, 0x1040); | ||
2906 | val = alc_read_coef_idx(codec, 0xc3); | ||
2907 | alc_write_coef_idx(codec, 0xc3, val | 1<<12); | ||
2908 | snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); | ||
2909 | break; | ||
2910 | } | ||
2911 | snd_printdd("Headset jack set to mic-in mode.\n"); | ||
2912 | } | ||
2913 | |||
2914 | static void alc_headset_mode_default(struct hda_codec *codec) | ||
2915 | { | ||
2916 | switch (codec->vendor_id) { | ||
2917 | case 0x10ec0283: | ||
2918 | alc_write_coef_idx(codec, 0x06, 0x2100); | ||
2919 | alc_write_coef_idx(codec, 0x32, 0x4ea3); | ||
2920 | break; | ||
2921 | case 0x10ec0292: | ||
2922 | alc_write_coef_idx(codec, 0x76, 0x000e); | ||
2923 | alc_write_coef_idx(codec, 0x6c, 0x2400); | ||
2924 | alc_write_coef_idx(codec, 0x6b, 0xc429); | ||
2925 | alc_write_coef_idx(codec, 0x18, 0x7308); | ||
2926 | break; | ||
2927 | case 0x10ec0668: | ||
2928 | alc_write_coef_idx(codec, 0x11, 0x0041); | ||
2929 | alc_write_coef_idx(codec, 0x15, 0x0d40); | ||
2930 | alc_write_coef_idx(codec, 0xb7, 0x802b); | ||
2931 | break; | ||
2932 | } | ||
2933 | snd_printdd("Headset jack set to headphone (default) mode.\n"); | ||
2934 | } | ||
2935 | |||
2936 | /* Iphone type */ | ||
2937 | static void alc_headset_mode_ctia(struct hda_codec *codec) | ||
2938 | { | ||
2939 | switch (codec->vendor_id) { | ||
2940 | case 0x10ec0283: | ||
2941 | alc_write_coef_idx(codec, 0x45, 0xd429); | ||
2942 | alc_write_coef_idx(codec, 0x1b, 0x0c2b); | ||
2943 | alc_write_coef_idx(codec, 0x32, 0x4ea3); | ||
2944 | break; | ||
2945 | case 0x10ec0292: | ||
2946 | alc_write_coef_idx(codec, 0x6b, 0xd429); | ||
2947 | alc_write_coef_idx(codec, 0x76, 0x0008); | ||
2948 | alc_write_coef_idx(codec, 0x18, 0x7388); | ||
2949 | break; | ||
2950 | case 0x10ec0668: | ||
2951 | alc_write_coef_idx(codec, 0x15, 0x0d60); | ||
2952 | alc_write_coef_idx(codec, 0xc3, 0x0000); | ||
2953 | break; | ||
2954 | } | ||
2955 | snd_printdd("Headset jack set to iPhone-style headset mode.\n"); | ||
2956 | } | ||
2957 | |||
2958 | /* Nokia type */ | ||
2959 | static void alc_headset_mode_omtp(struct hda_codec *codec) | ||
2960 | { | ||
2961 | switch (codec->vendor_id) { | ||
2962 | case 0x10ec0283: | ||
2963 | alc_write_coef_idx(codec, 0x45, 0xe429); | ||
2964 | alc_write_coef_idx(codec, 0x1b, 0x0c2b); | ||
2965 | alc_write_coef_idx(codec, 0x32, 0x4ea3); | ||
2966 | break; | ||
2967 | case 0x10ec0292: | ||
2968 | alc_write_coef_idx(codec, 0x6b, 0xe429); | ||
2969 | alc_write_coef_idx(codec, 0x76, 0x0008); | ||
2970 | alc_write_coef_idx(codec, 0x18, 0x7388); | ||
2971 | break; | ||
2972 | case 0x10ec0668: | ||
2973 | alc_write_coef_idx(codec, 0x15, 0x0d50); | ||
2974 | alc_write_coef_idx(codec, 0xc3, 0x0000); | ||
2975 | break; | ||
2976 | } | ||
2977 | snd_printdd("Headset jack set to Nokia-style headset mode.\n"); | ||
2978 | } | ||
2979 | |||
2980 | static void alc_determine_headset_type(struct hda_codec *codec) | ||
2981 | { | ||
2982 | int val; | ||
2983 | bool is_ctia = false; | ||
2984 | struct alc_spec *spec = codec->spec; | ||
2985 | |||
2986 | switch (codec->vendor_id) { | ||
2987 | case 0x10ec0283: | ||
2988 | alc_write_coef_idx(codec, 0x45, 0xd029); | ||
2989 | msleep(300); | ||
2990 | val = alc_read_coef_idx(codec, 0x46); | ||
2991 | is_ctia = (val & 0x0070) == 0x0070; | ||
2992 | break; | ||
2993 | case 0x10ec0292: | ||
2994 | alc_write_coef_idx(codec, 0x6b, 0xd429); | ||
2995 | msleep(300); | ||
2996 | val = alc_read_coef_idx(codec, 0x6c); | ||
2997 | is_ctia = (val & 0x001c) == 0x001c; | ||
2998 | break; | ||
2999 | case 0x10ec0668: | ||
3000 | alc_write_coef_idx(codec, 0x11, 0x0001); | ||
3001 | alc_write_coef_idx(codec, 0xb7, 0x802b); | ||
3002 | alc_write_coef_idx(codec, 0x15, 0x0d60); | ||
3003 | alc_write_coef_idx(codec, 0xc3, 0x0c00); | ||
3004 | msleep(300); | ||
3005 | val = alc_read_coef_idx(codec, 0xbe); | ||
3006 | is_ctia = (val & 0x1c02) == 0x1c02; | ||
3007 | break; | ||
3008 | } | ||
3009 | |||
3010 | snd_printdd("Headset jack detected iPhone-style headset: %s\n", | ||
3011 | is_ctia ? "yes" : "no"); | ||
3012 | spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP; | ||
3013 | } | ||
3014 | |||
3015 | static void alc_update_headset_mode(struct hda_codec *codec) | ||
3016 | { | ||
3017 | struct alc_spec *spec = codec->spec; | ||
3018 | |||
3019 | hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]]; | ||
3020 | hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; | ||
3021 | |||
3022 | int new_headset_mode; | ||
3023 | |||
3024 | if (!snd_hda_jack_detect(codec, hp_pin)) | ||
3025 | new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED; | ||
3026 | else if (mux_pin == spec->headset_mic_pin) | ||
3027 | new_headset_mode = ALC_HEADSET_MODE_HEADSET; | ||
3028 | else if (mux_pin == spec->headphone_mic_pin) | ||
3029 | new_headset_mode = ALC_HEADSET_MODE_MIC; | ||
3030 | else | ||
3031 | new_headset_mode = ALC_HEADSET_MODE_HEADPHONE; | ||
3032 | |||
3033 | if (new_headset_mode == spec->current_headset_mode) | ||
3034 | return; | ||
3035 | |||
3036 | switch (new_headset_mode) { | ||
3037 | case ALC_HEADSET_MODE_UNPLUGGED: | ||
3038 | alc_headset_mode_unplugged(codec); | ||
3039 | spec->gen.hp_jack_present = false; | ||
3040 | break; | ||
3041 | case ALC_HEADSET_MODE_HEADSET: | ||
3042 | if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN) | ||
3043 | alc_determine_headset_type(codec); | ||
3044 | if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA) | ||
3045 | alc_headset_mode_ctia(codec); | ||
3046 | else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP) | ||
3047 | alc_headset_mode_omtp(codec); | ||
3048 | spec->gen.hp_jack_present = true; | ||
3049 | break; | ||
3050 | case ALC_HEADSET_MODE_MIC: | ||
3051 | alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin); | ||
3052 | spec->gen.hp_jack_present = false; | ||
3053 | break; | ||
3054 | case ALC_HEADSET_MODE_HEADPHONE: | ||
3055 | alc_headset_mode_default(codec); | ||
3056 | spec->gen.hp_jack_present = true; | ||
3057 | break; | ||
3058 | } | ||
3059 | if (new_headset_mode != ALC_HEADSET_MODE_MIC) { | ||
3060 | snd_hda_set_pin_ctl_cache(codec, hp_pin, | ||
3061 | AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); | ||
3062 | if (spec->headphone_mic_pin) | ||
3063 | snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin, | ||
3064 | PIN_VREFHIZ); | ||
3065 | } | ||
3066 | spec->current_headset_mode = new_headset_mode; | ||
3067 | |||
3068 | snd_hda_gen_update_outputs(codec); | ||
3069 | } | ||
3070 | |||
3071 | static void alc_update_headset_mode_hook(struct hda_codec *codec, | ||
3072 | struct snd_ctl_elem_value *ucontrol) | ||
3073 | { | ||
3074 | alc_update_headset_mode(codec); | ||
3075 | } | ||
3076 | |||
3077 | static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_tbl *jack) | ||
3078 | { | ||
3079 | struct alc_spec *spec = codec->spec; | ||
3080 | spec->current_headset_type = ALC_HEADSET_MODE_UNKNOWN; | ||
3081 | snd_hda_gen_hp_automute(codec, jack); | ||
3082 | } | ||
3083 | |||
3084 | static void alc_probe_headset_mode(struct hda_codec *codec) | ||
3085 | { | ||
3086 | int i; | ||
3087 | struct alc_spec *spec = codec->spec; | ||
3088 | struct auto_pin_cfg *cfg = &spec->gen.autocfg; | ||
3089 | |||
3090 | /* Find mic pins */ | ||
3091 | for (i = 0; i < cfg->num_inputs; i++) { | ||
3092 | if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin) | ||
3093 | spec->headset_mic_pin = cfg->inputs[i].pin; | ||
3094 | if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin) | ||
3095 | spec->headphone_mic_pin = cfg->inputs[i].pin; | ||
3096 | } | ||
3097 | |||
3098 | spec->gen.cap_sync_hook = alc_update_headset_mode_hook; | ||
3099 | spec->gen.automute_hook = alc_update_headset_mode; | ||
3100 | spec->gen.hp_automute_hook = alc_update_headset_jack_cb; | ||
3101 | } | ||
3102 | |||
3103 | static void alc_fixup_headset_mode(struct hda_codec *codec, | ||
3104 | const struct hda_fixup *fix, int action) | ||
3105 | { | ||
3106 | struct alc_spec *spec = codec->spec; | ||
3107 | |||
3108 | switch (action) { | ||
3109 | case HDA_FIXUP_ACT_PRE_PROBE: | ||
3110 | spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC; | ||
3111 | break; | ||
3112 | case HDA_FIXUP_ACT_PROBE: | ||
3113 | alc_probe_headset_mode(codec); | ||
3114 | break; | ||
3115 | case HDA_FIXUP_ACT_INIT: | ||
3116 | spec->current_headset_mode = 0; | ||
3117 | alc_update_headset_mode(codec); | ||
3118 | break; | ||
3119 | } | ||
3120 | } | ||
3121 | |||
3122 | static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec, | ||
3123 | const struct hda_fixup *fix, int action) | ||
3124 | { | ||
3125 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | ||
3126 | struct alc_spec *spec = codec->spec; | ||
3127 | spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; | ||
3128 | } | ||
3129 | else | ||
3130 | alc_fixup_headset_mode(codec, fix, action); | ||
3131 | } | ||
3132 | |||
3133 | static void alc_fixup_headset_mode_alc668(struct hda_codec *codec, | ||
3134 | const struct hda_fixup *fix, int action) | ||
3135 | { | ||
3136 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { | ||
3137 | int val; | ||
3138 | alc_write_coef_idx(codec, 0xc4, 0x8000); | ||
3139 | val = alc_read_coef_idx(codec, 0xc2); | ||
3140 | alc_write_coef_idx(codec, 0xc2, val & 0xfe); | ||
3141 | snd_hda_set_pin_ctl_cache(codec, 0x18, 0); | ||
3142 | } | ||
3143 | alc_fixup_headset_mode(codec, fix, action); | ||
3144 | } | ||
3145 | |||
2760 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, | 3146 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, |
2761 | const struct hda_fixup *fix, | 3147 | const struct hda_fixup *fix, |
2762 | int action) | 3148 | int action) |
@@ -2772,6 +3158,38 @@ static void alc271_hp_gate_mic_jack(struct hda_codec *codec, | |||
2772 | } | 3158 | } |
2773 | } | 3159 | } |
2774 | 3160 | ||
3161 | static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec, | ||
3162 | const struct hda_fixup *fix, | ||
3163 | int action) | ||
3164 | { | ||
3165 | struct alc_spec *spec = codec->spec; | ||
3166 | struct auto_pin_cfg *cfg = &spec->gen.autocfg; | ||
3167 | int i; | ||
3168 | |||
3169 | /* The mic boosts on level 2 and 3 are too noisy | ||
3170 | on the internal mic input. | ||
3171 | Therefore limit the boost to 0 or 1. */ | ||
3172 | |||
3173 | if (action != HDA_FIXUP_ACT_PROBE) | ||
3174 | return; | ||
3175 | |||
3176 | for (i = 0; i < cfg->num_inputs; i++) { | ||
3177 | hda_nid_t nid = cfg->inputs[i].pin; | ||
3178 | unsigned int defcfg; | ||
3179 | if (cfg->inputs[i].type != AUTO_PIN_MIC) | ||
3180 | continue; | ||
3181 | defcfg = snd_hda_codec_get_pincfg(codec, nid); | ||
3182 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) | ||
3183 | continue; | ||
3184 | |||
3185 | snd_hda_override_amp_caps(codec, nid, HDA_INPUT, | ||
3186 | (0x00 << AC_AMPCAP_OFFSET_SHIFT) | | ||
3187 | (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) | | ||
3188 | (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) | | ||
3189 | (0 << AC_AMPCAP_MUTE_SHIFT)); | ||
3190 | } | ||
3191 | } | ||
3192 | |||
2775 | enum { | 3193 | enum { |
2776 | ALC269_FIXUP_SONY_VAIO, | 3194 | ALC269_FIXUP_SONY_VAIO, |
2777 | ALC275_FIXUP_SONY_VAIO_GPIO2, | 3195 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
@@ -2792,11 +3210,21 @@ enum { | |||
2792 | ALC269_FIXUP_HP_MUTE_LED, | 3210 | ALC269_FIXUP_HP_MUTE_LED, |
2793 | ALC269_FIXUP_HP_MUTE_LED_MIC1, | 3211 | ALC269_FIXUP_HP_MUTE_LED_MIC1, |
2794 | ALC269_FIXUP_HP_MUTE_LED_MIC2, | 3212 | ALC269_FIXUP_HP_MUTE_LED_MIC2, |
3213 | ALC269_FIXUP_HP_GPIO_LED, | ||
2795 | ALC269_FIXUP_INV_DMIC, | 3214 | ALC269_FIXUP_INV_DMIC, |
2796 | ALC269_FIXUP_LENOVO_DOCK, | 3215 | ALC269_FIXUP_LENOVO_DOCK, |
2797 | ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, | 3216 | ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, |
3217 | ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, | ||
3218 | ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, | ||
3219 | ALC269_FIXUP_HEADSET_MODE, | ||
3220 | ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, | ||
3221 | ALC269_FIXUP_ASUS_X101_FUNC, | ||
3222 | ALC269_FIXUP_ASUS_X101_VERB, | ||
3223 | ALC269_FIXUP_ASUS_X101, | ||
2798 | ALC271_FIXUP_AMIC_MIC2, | 3224 | ALC271_FIXUP_AMIC_MIC2, |
2799 | ALC271_FIXUP_HP_GATE_MIC_JACK, | 3225 | ALC271_FIXUP_HP_GATE_MIC_JACK, |
3226 | ALC269_FIXUP_ACER_AC700, | ||
3227 | ALC269_FIXUP_LIMIT_INT_MIC_BOOST, | ||
2800 | }; | 3228 | }; |
2801 | 3229 | ||
2802 | static const struct hda_fixup alc269_fixups[] = { | 3230 | static const struct hda_fixup alc269_fixups[] = { |
@@ -2931,6 +3359,10 @@ static const struct hda_fixup alc269_fixups[] = { | |||
2931 | .type = HDA_FIXUP_FUNC, | 3359 | .type = HDA_FIXUP_FUNC, |
2932 | .v.func = alc269_fixup_hp_mute_led_mic2, | 3360 | .v.func = alc269_fixup_hp_mute_led_mic2, |
2933 | }, | 3361 | }, |
3362 | [ALC269_FIXUP_HP_GPIO_LED] = { | ||
3363 | .type = HDA_FIXUP_FUNC, | ||
3364 | .v.func = alc269_fixup_hp_gpio_led, | ||
3365 | }, | ||
2934 | [ALC269_FIXUP_INV_DMIC] = { | 3366 | [ALC269_FIXUP_INV_DMIC] = { |
2935 | .type = HDA_FIXUP_FUNC, | 3367 | .type = HDA_FIXUP_FUNC, |
2936 | .v.func = alc_fixup_inv_dmic_0x12, | 3368 | .v.func = alc_fixup_inv_dmic_0x12, |
@@ -2949,6 +3381,59 @@ static const struct hda_fixup alc269_fixups[] = { | |||
2949 | .type = HDA_FIXUP_FUNC, | 3381 | .type = HDA_FIXUP_FUNC, |
2950 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, | 3382 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
2951 | }, | 3383 | }, |
3384 | [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = { | ||
3385 | .type = HDA_FIXUP_PINS, | ||
3386 | .v.pins = (const struct hda_pintbl[]) { | ||
3387 | { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ | ||
3388 | { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */ | ||
3389 | { } | ||
3390 | }, | ||
3391 | .chained = true, | ||
3392 | .chain_id = ALC269_FIXUP_HEADSET_MODE | ||
3393 | }, | ||
3394 | [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = { | ||
3395 | .type = HDA_FIXUP_PINS, | ||
3396 | .v.pins = (const struct hda_pintbl[]) { | ||
3397 | { 0x16, 0x21014020 }, /* dock line out */ | ||
3398 | { 0x19, 0x21a19030 }, /* dock mic */ | ||
3399 | { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */ | ||
3400 | { } | ||
3401 | }, | ||
3402 | .chained = true, | ||
3403 | .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC | ||
3404 | }, | ||
3405 | [ALC269_FIXUP_HEADSET_MODE] = { | ||
3406 | .type = HDA_FIXUP_FUNC, | ||
3407 | .v.func = alc_fixup_headset_mode, | ||
3408 | }, | ||
3409 | [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = { | ||
3410 | .type = HDA_FIXUP_FUNC, | ||
3411 | .v.func = alc_fixup_headset_mode_no_hp_mic, | ||
3412 | }, | ||
3413 | [ALC269_FIXUP_ASUS_X101_FUNC] = { | ||
3414 | .type = HDA_FIXUP_FUNC, | ||
3415 | .v.func = alc269_fixup_x101_headset_mic, | ||
3416 | }, | ||
3417 | [ALC269_FIXUP_ASUS_X101_VERB] = { | ||
3418 | .type = HDA_FIXUP_VERBS, | ||
3419 | .v.verbs = (const struct hda_verb[]) { | ||
3420 | {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, | ||
3421 | {0x20, AC_VERB_SET_COEF_INDEX, 0x08}, | ||
3422 | {0x20, AC_VERB_SET_PROC_COEF, 0x0310}, | ||
3423 | { } | ||
3424 | }, | ||
3425 | .chained = true, | ||
3426 | .chain_id = ALC269_FIXUP_ASUS_X101_FUNC | ||
3427 | }, | ||
3428 | [ALC269_FIXUP_ASUS_X101] = { | ||
3429 | .type = HDA_FIXUP_PINS, | ||
3430 | .v.pins = (const struct hda_pintbl[]) { | ||
3431 | { 0x18, 0x04a1182c }, /* Headset mic */ | ||
3432 | { } | ||
3433 | }, | ||
3434 | .chained = true, | ||
3435 | .chain_id = ALC269_FIXUP_ASUS_X101_VERB | ||
3436 | }, | ||
2952 | [ALC271_FIXUP_AMIC_MIC2] = { | 3437 | [ALC271_FIXUP_AMIC_MIC2] = { |
2953 | .type = HDA_FIXUP_PINS, | 3438 | .type = HDA_FIXUP_PINS, |
2954 | .v.pins = (const struct hda_pintbl[]) { | 3439 | .v.pins = (const struct hda_pintbl[]) { |
@@ -2965,29 +3450,72 @@ static const struct hda_fixup alc269_fixups[] = { | |||
2965 | .chained = true, | 3450 | .chained = true, |
2966 | .chain_id = ALC271_FIXUP_AMIC_MIC2, | 3451 | .chain_id = ALC271_FIXUP_AMIC_MIC2, |
2967 | }, | 3452 | }, |
3453 | [ALC269_FIXUP_ACER_AC700] = { | ||
3454 | .type = HDA_FIXUP_PINS, | ||
3455 | .v.pins = (const struct hda_pintbl[]) { | ||
3456 | { 0x12, 0x99a3092f }, /* int-mic */ | ||
3457 | { 0x14, 0x99130110 }, /* speaker */ | ||
3458 | { 0x18, 0x03a11c20 }, /* mic */ | ||
3459 | { 0x1e, 0x0346101e }, /* SPDIF1 */ | ||
3460 | { 0x21, 0x0321101f }, /* HP out */ | ||
3461 | { } | ||
3462 | }, | ||
3463 | .chained = true, | ||
3464 | .chain_id = ALC271_FIXUP_DMIC, | ||
3465 | }, | ||
3466 | [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = { | ||
3467 | .type = HDA_FIXUP_FUNC, | ||
3468 | .v.func = alc269_fixup_limit_int_mic_boost, | ||
3469 | }, | ||
2968 | }; | 3470 | }; |
2969 | 3471 | ||
2970 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { | 3472 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
2971 | SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), | 3473 | SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), |
2972 | SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), | 3474 | SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), |
3475 | SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), | ||
3476 | SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), | ||
3477 | SND_PCI_QUIRK(0x1028, 0x05c4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3478 | SND_PCI_QUIRK(0x1028, 0x05c5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3479 | SND_PCI_QUIRK(0x1028, 0x05c6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3480 | SND_PCI_QUIRK(0x1028, 0x05c7, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3481 | SND_PCI_QUIRK(0x1028, 0x05c8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3482 | SND_PCI_QUIRK(0x1028, 0x05c9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3483 | SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), | ||
3484 | SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), | ||
3485 | SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3486 | SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3487 | SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3488 | SND_PCI_QUIRK(0x1028, 0x05ec, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3489 | SND_PCI_QUIRK(0x1028, 0x05ed, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3490 | SND_PCI_QUIRK(0x1028, 0x05ee, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3491 | SND_PCI_QUIRK(0x1028, 0x05f3, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3492 | SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3493 | SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
3494 | SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | ||
2973 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), | 3495 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), |
3496 | SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED), | ||
2974 | SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), | 3497 | SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
2975 | SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), | 3498 | SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), |
2976 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED), | 3499 | SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED), |
3500 | SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), | ||
3501 | SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), | ||
2977 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), | 3502 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
2978 | SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), | 3503 | SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), |
3504 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), | ||
2979 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), | 3505 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
2980 | SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), | 3506 | SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), |
2981 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), | 3507 | SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), |
2982 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), | 3508 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
2983 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), | 3509 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
2984 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), | 3510 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
2985 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), | 3511 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
3512 | SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101), | ||
2986 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), | 3513 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
2987 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), | 3514 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
2988 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), | 3515 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
2989 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), | 3516 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
2990 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), | 3517 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
3518 | SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700), | ||
2991 | SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK), | 3519 | SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK), |
2992 | SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK), | 3520 | SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK), |
2993 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), | 3521 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
@@ -3063,6 +3591,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = { | |||
3063 | {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, | 3591 | {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, |
3064 | {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, | 3592 | {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
3065 | {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, | 3593 | {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, |
3594 | {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"}, | ||
3066 | {} | 3595 | {} |
3067 | }; | 3596 | }; |
3068 | 3597 | ||
@@ -3131,6 +3660,9 @@ static int patch_alc269(struct hda_codec *codec) | |||
3131 | 3660 | ||
3132 | alc_auto_parse_customize_define(codec); | 3661 | alc_auto_parse_customize_define(codec); |
3133 | 3662 | ||
3663 | if (has_cdefine_beep(codec)) | ||
3664 | spec->gen.beep_nid = 0x01; | ||
3665 | |||
3134 | switch (codec->vendor_id) { | 3666 | switch (codec->vendor_id) { |
3135 | case 0x10ec0269: | 3667 | case 0x10ec0269: |
3136 | spec->codec_variant = ALC269_TYPE_ALC269VA; | 3668 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
@@ -3172,6 +3704,9 @@ static int patch_alc269(struct hda_codec *codec) | |||
3172 | case 0x10ec0292: | 3704 | case 0x10ec0292: |
3173 | spec->codec_variant = ALC269_TYPE_ALC284; | 3705 | spec->codec_variant = ALC269_TYPE_ALC284; |
3174 | break; | 3706 | break; |
3707 | case 0x10ec0286: | ||
3708 | spec->codec_variant = ALC269_TYPE_ALC286; | ||
3709 | break; | ||
3175 | } | 3710 | } |
3176 | 3711 | ||
3177 | /* automatic parse from the BIOS config */ | 3712 | /* automatic parse from the BIOS config */ |
@@ -3179,12 +3714,8 @@ static int patch_alc269(struct hda_codec *codec) | |||
3179 | if (err < 0) | 3714 | if (err < 0) |
3180 | goto error; | 3715 | goto error; |
3181 | 3716 | ||
3182 | if (!spec->gen.no_analog && has_cdefine_beep(codec)) { | 3717 | if (!spec->gen.no_analog && spec->gen.beep_nid) |
3183 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
3184 | if (err < 0) | ||
3185 | goto error; | ||
3186 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); | 3718 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
3187 | } | ||
3188 | 3719 | ||
3189 | codec->patch_ops = alc_patch_ops; | 3720 | codec->patch_ops = alc_patch_ops; |
3190 | #ifdef CONFIG_PM | 3721 | #ifdef CONFIG_PM |
@@ -3292,6 +3823,7 @@ static int patch_alc861(struct hda_codec *codec) | |||
3292 | return err; | 3823 | return err; |
3293 | 3824 | ||
3294 | spec = codec->spec; | 3825 | spec = codec->spec; |
3826 | spec->gen.beep_nid = 0x23; | ||
3295 | 3827 | ||
3296 | snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); | 3828 | snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
3297 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | 3829 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
@@ -3301,12 +3833,8 @@ static int patch_alc861(struct hda_codec *codec) | |||
3301 | if (err < 0) | 3833 | if (err < 0) |
3302 | goto error; | 3834 | goto error; |
3303 | 3835 | ||
3304 | if (!spec->gen.no_analog) { | 3836 | if (!spec->gen.no_analog) |
3305 | err = snd_hda_attach_beep_device(codec, 0x23); | ||
3306 | if (err < 0) | ||
3307 | goto error; | ||
3308 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); | 3837 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
3309 | } | ||
3310 | 3838 | ||
3311 | codec->patch_ops = alc_patch_ops; | 3839 | codec->patch_ops = alc_patch_ops; |
3312 | #ifdef CONFIG_PM | 3840 | #ifdef CONFIG_PM |
@@ -3387,6 +3915,7 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
3387 | return err; | 3915 | return err; |
3388 | 3916 | ||
3389 | spec = codec->spec; | 3917 | spec = codec->spec; |
3918 | spec->gen.beep_nid = 0x23; | ||
3390 | 3919 | ||
3391 | snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); | 3920 | snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
3392 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); | 3921 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
@@ -3396,12 +3925,8 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
3396 | if (err < 0) | 3925 | if (err < 0) |
3397 | goto error; | 3926 | goto error; |
3398 | 3927 | ||
3399 | if (!spec->gen.no_analog) { | 3928 | if (!spec->gen.no_analog) |
3400 | err = snd_hda_attach_beep_device(codec, 0x23); | ||
3401 | if (err < 0) | ||
3402 | goto error; | ||
3403 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 3929 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
3404 | } | ||
3405 | 3930 | ||
3406 | codec->patch_ops = alc_patch_ops; | 3931 | codec->patch_ops = alc_patch_ops; |
3407 | 3932 | ||
@@ -3480,6 +4005,8 @@ enum { | |||
3480 | ALC662_FIXUP_NO_JACK_DETECT, | 4005 | ALC662_FIXUP_NO_JACK_DETECT, |
3481 | ALC662_FIXUP_ZOTAC_Z68, | 4006 | ALC662_FIXUP_ZOTAC_Z68, |
3482 | ALC662_FIXUP_INV_DMIC, | 4007 | ALC662_FIXUP_INV_DMIC, |
4008 | ALC668_FIXUP_DELL_MIC_NO_PRESENCE, | ||
4009 | ALC668_FIXUP_HEADSET_MODE, | ||
3483 | }; | 4010 | }; |
3484 | 4011 | ||
3485 | static const struct hda_fixup alc662_fixups[] = { | 4012 | static const struct hda_fixup alc662_fixups[] = { |
@@ -3640,6 +4167,20 @@ static const struct hda_fixup alc662_fixups[] = { | |||
3640 | .type = HDA_FIXUP_FUNC, | 4167 | .type = HDA_FIXUP_FUNC, |
3641 | .v.func = alc_fixup_inv_dmic_0x12, | 4168 | .v.func = alc_fixup_inv_dmic_0x12, |
3642 | }, | 4169 | }, |
4170 | [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = { | ||
4171 | .type = HDA_FIXUP_PINS, | ||
4172 | .v.pins = (const struct hda_pintbl[]) { | ||
4173 | { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */ | ||
4174 | { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */ | ||
4175 | { } | ||
4176 | }, | ||
4177 | .chained = true, | ||
4178 | .chain_id = ALC668_FIXUP_HEADSET_MODE | ||
4179 | }, | ||
4180 | [ALC668_FIXUP_HEADSET_MODE] = { | ||
4181 | .type = HDA_FIXUP_FUNC, | ||
4182 | .v.func = alc_fixup_headset_mode_alc668, | ||
4183 | }, | ||
3643 | }; | 4184 | }; |
3644 | 4185 | ||
3645 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { | 4186 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
@@ -3648,6 +4189,8 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = { | |||
3648 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), | 4189 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
3649 | SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), | 4190 | SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), |
3650 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), | 4191 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
4192 | SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), | ||
4193 | SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), | ||
3651 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), | 4194 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
3652 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), | 4195 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
3653 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), | 4196 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
@@ -3784,10 +4327,14 @@ static int patch_alc662(struct hda_codec *codec) | |||
3784 | 4327 | ||
3785 | alc_auto_parse_customize_define(codec); | 4328 | alc_auto_parse_customize_define(codec); |
3786 | 4329 | ||
4330 | if (has_cdefine_beep(codec)) | ||
4331 | spec->gen.beep_nid = 0x01; | ||
4332 | |||
3787 | if ((alc_get_coef0(codec) & (1 << 14)) && | 4333 | if ((alc_get_coef0(codec) & (1 << 14)) && |
3788 | codec->bus->pci->subsystem_vendor == 0x1025 && | 4334 | codec->bus->pci->subsystem_vendor == 0x1025 && |
3789 | spec->cdefine.platform_type == 1) { | 4335 | spec->cdefine.platform_type == 1) { |
3790 | if (alc_codec_rename(codec, "ALC272X") < 0) | 4336 | err = alc_codec_rename(codec, "ALC272X"); |
4337 | if (err < 0) | ||
3791 | goto error; | 4338 | goto error; |
3792 | } | 4339 | } |
3793 | 4340 | ||
@@ -3796,10 +4343,7 @@ static int patch_alc662(struct hda_codec *codec) | |||
3796 | if (err < 0) | 4343 | if (err < 0) |
3797 | goto error; | 4344 | goto error; |
3798 | 4345 | ||
3799 | if (!spec->gen.no_analog && has_cdefine_beep(codec)) { | 4346 | if (!spec->gen.no_analog && spec->gen.beep_nid) { |
3800 | err = snd_hda_attach_beep_device(codec, 0x1); | ||
3801 | if (err < 0) | ||
3802 | goto error; | ||
3803 | switch (codec->vendor_id) { | 4347 | switch (codec->vendor_id) { |
3804 | case 0x10ec0662: | 4348 | case 0x10ec0662: |
3805 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 4349 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
@@ -3878,6 +4422,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
3878 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, | 4422 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, |
3879 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, | 4423 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, |
3880 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, | 4424 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, |
4425 | { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 }, | ||
3881 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, | 4426 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, |
3882 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, | 4427 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, |
3883 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", | 4428 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index dafe04ae8c72..1d9d6427e0bf 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -211,7 +211,6 @@ struct sigmatel_spec { | |||
211 | 211 | ||
212 | /* beep widgets */ | 212 | /* beep widgets */ |
213 | hda_nid_t anabeep_nid; | 213 | hda_nid_t anabeep_nid; |
214 | hda_nid_t digbeep_nid; | ||
215 | 214 | ||
216 | /* SPDIF-out mux */ | 215 | /* SPDIF-out mux */ |
217 | const char * const *spdif_labels; | 216 | const char * const *spdif_labels; |
@@ -3529,8 +3528,12 @@ static int stac_parse_auto_config(struct hda_codec *codec) | |||
3529 | { | 3528 | { |
3530 | struct sigmatel_spec *spec = codec->spec; | 3529 | struct sigmatel_spec *spec = codec->spec; |
3531 | int err; | 3530 | int err; |
3531 | int flags = 0; | ||
3532 | 3532 | ||
3533 | err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); | 3533 | if (spec->headset_jack) |
3534 | flags |= HDA_PINCFG_HEADSET_MIC; | ||
3535 | |||
3536 | err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, flags); | ||
3534 | if (err < 0) | 3537 | if (err < 0) |
3535 | return err; | 3538 | return err; |
3536 | 3539 | ||
@@ -3560,16 +3563,13 @@ static int stac_parse_auto_config(struct hda_codec *codec) | |||
3560 | 3563 | ||
3561 | /* setup digital beep controls and input device */ | 3564 | /* setup digital beep controls and input device */ |
3562 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | 3565 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
3563 | if (spec->digbeep_nid > 0) { | 3566 | if (spec->gen.beep_nid) { |
3564 | hda_nid_t nid = spec->digbeep_nid; | 3567 | hda_nid_t nid = spec->gen.beep_nid; |
3565 | unsigned int caps; | 3568 | unsigned int caps; |
3566 | 3569 | ||
3567 | err = stac_auto_create_beep_ctls(codec, nid); | 3570 | err = stac_auto_create_beep_ctls(codec, nid); |
3568 | if (err < 0) | 3571 | if (err < 0) |
3569 | return err; | 3572 | return err; |
3570 | err = snd_hda_attach_beep_device(codec, nid); | ||
3571 | if (err < 0) | ||
3572 | return err; | ||
3573 | if (codec->beep) { | 3573 | if (codec->beep) { |
3574 | /* IDT/STAC codecs have linear beep tone parameter */ | 3574 | /* IDT/STAC codecs have linear beep tone parameter */ |
3575 | codec->beep->linear_tone = spec->linear_tone_beep; | 3575 | codec->beep->linear_tone = spec->linear_tone_beep; |
@@ -3657,17 +3657,7 @@ static void stac_shutup(struct hda_codec *codec) | |||
3657 | ~spec->eapd_mask); | 3657 | ~spec->eapd_mask); |
3658 | } | 3658 | } |
3659 | 3659 | ||
3660 | static void stac_free(struct hda_codec *codec) | 3660 | #define stac_free snd_hda_gen_free |
3661 | { | ||
3662 | struct sigmatel_spec *spec = codec->spec; | ||
3663 | |||
3664 | if (!spec) | ||
3665 | return; | ||
3666 | |||
3667 | snd_hda_gen_spec_free(&spec->gen); | ||
3668 | kfree(spec); | ||
3669 | snd_hda_detach_beep_device(codec); | ||
3670 | } | ||
3671 | 3661 | ||
3672 | #ifdef CONFIG_PROC_FS | 3662 | #ifdef CONFIG_PROC_FS |
3673 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, | 3663 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
@@ -3797,6 +3787,7 @@ static int patch_stac9200(struct hda_codec *codec) | |||
3797 | spec->gen.own_eapd_ctl = 1; | 3787 | spec->gen.own_eapd_ctl = 1; |
3798 | 3788 | ||
3799 | codec->patch_ops = stac_patch_ops; | 3789 | codec->patch_ops = stac_patch_ops; |
3790 | codec->power_filter = snd_hda_codec_eapd_power_filter; | ||
3800 | 3791 | ||
3801 | snd_hda_add_verbs(codec, stac9200_eapd_init); | 3792 | snd_hda_add_verbs(codec, stac9200_eapd_init); |
3802 | 3793 | ||
@@ -3884,7 +3875,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec) | |||
3884 | spec->aloopback_mask = 0x01; | 3875 | spec->aloopback_mask = 0x01; |
3885 | spec->aloopback_shift = 8; | 3876 | spec->aloopback_shift = 8; |
3886 | 3877 | ||
3887 | spec->digbeep_nid = 0x1c; | 3878 | spec->gen.beep_nid = 0x1c; /* digital beep */ |
3888 | 3879 | ||
3889 | /* GPIO0 High = Enable EAPD */ | 3880 | /* GPIO0 High = Enable EAPD */ |
3890 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; | 3881 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
@@ -3968,7 +3959,7 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
3968 | spec->gen.power_down_unused = 1; | 3959 | spec->gen.power_down_unused = 1; |
3969 | spec->gen.mixer_nid = 0x1b; | 3960 | spec->gen.mixer_nid = 0x1b; |
3970 | 3961 | ||
3971 | spec->digbeep_nid = 0x21; | 3962 | spec->gen.beep_nid = 0x21; /* digital beep */ |
3972 | spec->pwr_nids = stac92hd83xxx_pwr_nids; | 3963 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
3973 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); | 3964 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
3974 | spec->default_polarity = -1; /* no default cfg */ | 3965 | spec->default_polarity = -1; /* no default cfg */ |
@@ -4016,7 +4007,7 @@ static int patch_stac92hd95(struct hda_codec *codec) | |||
4016 | spec->gen.own_eapd_ctl = 1; | 4007 | spec->gen.own_eapd_ctl = 1; |
4017 | spec->gen.power_down_unused = 1; | 4008 | spec->gen.power_down_unused = 1; |
4018 | 4009 | ||
4019 | spec->digbeep_nid = 0x19; | 4010 | spec->gen.beep_nid = 0x19; /* digital beep */ |
4020 | spec->pwr_nids = stac92hd95_pwr_nids; | 4011 | spec->pwr_nids = stac92hd95_pwr_nids; |
4021 | spec->num_pwrs = ARRAY_SIZE(stac92hd95_pwr_nids); | 4012 | spec->num_pwrs = ARRAY_SIZE(stac92hd95_pwr_nids); |
4022 | spec->default_polarity = -1; /* no default cfg */ | 4013 | spec->default_polarity = -1; /* no default cfg */ |
@@ -4091,7 +4082,7 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) | |||
4091 | spec->aloopback_shift = 0; | 4082 | spec->aloopback_shift = 0; |
4092 | 4083 | ||
4093 | spec->powerdown_adcs = 1; | 4084 | spec->powerdown_adcs = 1; |
4094 | spec->digbeep_nid = 0x26; | 4085 | spec->gen.beep_nid = 0x26; /* digital beep */ |
4095 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); | 4086 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
4096 | spec->pwr_nids = stac92hd71bxx_pwr_nids; | 4087 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
4097 | 4088 | ||
@@ -4173,7 +4164,7 @@ static int patch_stac927x(struct hda_codec *codec) | |||
4173 | spec->have_spdif_mux = 1; | 4164 | spec->have_spdif_mux = 1; |
4174 | spec->spdif_labels = stac927x_spdif_labels; | 4165 | spec->spdif_labels = stac927x_spdif_labels; |
4175 | 4166 | ||
4176 | spec->digbeep_nid = 0x23; | 4167 | spec->gen.beep_nid = 0x23; /* digital beep */ |
4177 | 4168 | ||
4178 | /* GPIO0 High = Enable EAPD */ | 4169 | /* GPIO0 High = Enable EAPD */ |
4179 | spec->eapd_mask = spec->gpio_mask = 0x01; | 4170 | spec->eapd_mask = spec->gpio_mask = 0x01; |
@@ -4232,7 +4223,7 @@ static int patch_stac9205(struct hda_codec *codec) | |||
4232 | spec->gen.own_eapd_ctl = 1; | 4223 | spec->gen.own_eapd_ctl = 1; |
4233 | spec->have_spdif_mux = 1; | 4224 | spec->have_spdif_mux = 1; |
4234 | 4225 | ||
4235 | spec->digbeep_nid = 0x23; | 4226 | spec->gen.beep_nid = 0x23; /* digital beep */ |
4236 | 4227 | ||
4237 | snd_hda_add_verbs(codec, stac9205_core_init); | 4228 | snd_hda_add_verbs(codec, stac9205_core_init); |
4238 | spec->aloopback_ctl = &stac9205_loopback; | 4229 | spec->aloopback_ctl = &stac9205_loopback; |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index c35338a8771d..e0dadcf2030d 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -626,11 +626,31 @@ static void via_set_jack_unsol_events(struct hda_codec *codec) | |||
626 | } | 626 | } |
627 | } | 627 | } |
628 | 628 | ||
629 | static const struct badness_table via_main_out_badness = { | ||
630 | .no_primary_dac = 0x10000, | ||
631 | .no_dac = 0x4000, | ||
632 | .shared_primary = 0x10000, | ||
633 | .shared_surr = 0x20, | ||
634 | .shared_clfe = 0x20, | ||
635 | .shared_surr_main = 0x20, | ||
636 | }; | ||
637 | static const struct badness_table via_extra_out_badness = { | ||
638 | .no_primary_dac = 0x4000, | ||
639 | .no_dac = 0x4000, | ||
640 | .shared_primary = 0x12, | ||
641 | .shared_surr = 0x20, | ||
642 | .shared_clfe = 0x20, | ||
643 | .shared_surr_main = 0x10, | ||
644 | }; | ||
645 | |||
629 | static int via_parse_auto_config(struct hda_codec *codec) | 646 | static int via_parse_auto_config(struct hda_codec *codec) |
630 | { | 647 | { |
631 | struct via_spec *spec = codec->spec; | 648 | struct via_spec *spec = codec->spec; |
632 | int err; | 649 | int err; |
633 | 650 | ||
651 | spec->gen.main_out_badness = &via_main_out_badness; | ||
652 | spec->gen.extra_out_badness = &via_extra_out_badness; | ||
653 | |||
634 | err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); | 654 | err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); |
635 | if (err < 0) | 655 | if (err < 0) |
636 | return err; | 656 | return err; |
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 223c3d9cc69e..9ea05e956474 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c | |||
@@ -969,6 +969,7 @@ static int snd_hdspm_create_pcm(struct snd_card *card, | |||
969 | struct hdspm *hdspm); | 969 | struct hdspm *hdspm); |
970 | 970 | ||
971 | static inline void snd_hdspm_initialize_midi_flush(struct hdspm *hdspm); | 971 | static inline void snd_hdspm_initialize_midi_flush(struct hdspm *hdspm); |
972 | static inline int hdspm_get_pll_freq(struct hdspm *hdspm); | ||
972 | static int hdspm_update_simple_mixer_controls(struct hdspm *hdspm); | 973 | static int hdspm_update_simple_mixer_controls(struct hdspm *hdspm); |
973 | static int hdspm_autosync_ref(struct hdspm *hdspm); | 974 | static int hdspm_autosync_ref(struct hdspm *hdspm); |
974 | static int snd_hdspm_set_defaults(struct hdspm *hdspm); | 975 | static int snd_hdspm_set_defaults(struct hdspm *hdspm); |
@@ -1075,6 +1076,20 @@ static int snd_hdspm_use_is_exclusive(struct hdspm *hdspm) | |||
1075 | return ret; | 1076 | return ret; |
1076 | } | 1077 | } |
1077 | 1078 | ||
1079 | /* round arbitary sample rates to commonly known rates */ | ||
1080 | static int hdspm_round_frequency(int rate) | ||
1081 | { | ||
1082 | if (rate < 38050) | ||
1083 | return 32000; | ||
1084 | if (rate < 46008) | ||
1085 | return 44100; | ||
1086 | else | ||
1087 | return 48000; | ||
1088 | } | ||
1089 | |||
1090 | static int hdspm_tco_sync_check(struct hdspm *hdspm); | ||
1091 | static int hdspm_sync_in_sync_check(struct hdspm *hdspm); | ||
1092 | |||
1078 | /* check for external sample rate */ | 1093 | /* check for external sample rate */ |
1079 | static int hdspm_external_sample_rate(struct hdspm *hdspm) | 1094 | static int hdspm_external_sample_rate(struct hdspm *hdspm) |
1080 | { | 1095 | { |
@@ -1216,22 +1231,45 @@ static int hdspm_external_sample_rate(struct hdspm *hdspm) | |||
1216 | break; | 1231 | break; |
1217 | } | 1232 | } |
1218 | 1233 | ||
1219 | /* QS and DS rates normally can not be detected | 1234 | } /* endif HDSPM_madiLock */ |
1220 | * automatically by the card. Only exception is MADI | 1235 | |
1221 | * in 96k frame mode. | 1236 | /* check sample rate from TCO or SYNC_IN */ |
1222 | * | 1237 | { |
1223 | * So if we read SS values (32 .. 48k), check for | 1238 | bool is_valid_input = 0; |
1224 | * user-provided DS/QS bits in the control register | 1239 | bool has_sync = 0; |
1225 | * and multiply the base frequency accordingly. | 1240 | |
1226 | */ | 1241 | syncref = hdspm_autosync_ref(hdspm); |
1227 | if (rate <= 48000) { | 1242 | if (HDSPM_AUTOSYNC_FROM_TCO == syncref) { |
1228 | if (hdspm->control_register & HDSPM_QuadSpeed) | 1243 | is_valid_input = 1; |
1229 | rate *= 4; | 1244 | has_sync = (HDSPM_SYNC_CHECK_SYNC == |
1230 | else if (hdspm->control_register & | 1245 | hdspm_tco_sync_check(hdspm)); |
1231 | HDSPM_DoubleSpeed) | 1246 | } else if (HDSPM_AUTOSYNC_FROM_SYNC_IN == syncref) { |
1232 | rate *= 2; | 1247 | is_valid_input = 1; |
1248 | has_sync = (HDSPM_SYNC_CHECK_SYNC == | ||
1249 | hdspm_sync_in_sync_check(hdspm)); | ||
1250 | } | ||
1251 | |||
1252 | if (is_valid_input && has_sync) { | ||
1253 | rate = hdspm_round_frequency( | ||
1254 | hdspm_get_pll_freq(hdspm)); | ||
1233 | } | 1255 | } |
1234 | } | 1256 | } |
1257 | |||
1258 | /* QS and DS rates normally can not be detected | ||
1259 | * automatically by the card. Only exception is MADI | ||
1260 | * in 96k frame mode. | ||
1261 | * | ||
1262 | * So if we read SS values (32 .. 48k), check for | ||
1263 | * user-provided DS/QS bits in the control register | ||
1264 | * and multiply the base frequency accordingly. | ||
1265 | */ | ||
1266 | if (rate <= 48000) { | ||
1267 | if (hdspm->control_register & HDSPM_QuadSpeed) | ||
1268 | rate *= 4; | ||
1269 | else if (hdspm->control_register & | ||
1270 | HDSPM_DoubleSpeed) | ||
1271 | rate *= 2; | ||
1272 | } | ||
1235 | break; | 1273 | break; |
1236 | } | 1274 | } |
1237 | 1275 | ||
@@ -1979,16 +2017,25 @@ static void hdspm_midi_tasklet(unsigned long arg) | |||
1979 | /* get the system sample rate which is set */ | 2017 | /* get the system sample rate which is set */ |
1980 | 2018 | ||
1981 | 2019 | ||
2020 | static inline int hdspm_get_pll_freq(struct hdspm *hdspm) | ||
2021 | { | ||
2022 | unsigned int period, rate; | ||
2023 | |||
2024 | period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ); | ||
2025 | rate = hdspm_calc_dds_value(hdspm, period); | ||
2026 | |||
2027 | return rate; | ||
2028 | } | ||
2029 | |||
1982 | /** | 2030 | /** |
1983 | * Calculate the real sample rate from the | 2031 | * Calculate the real sample rate from the |
1984 | * current DDS value. | 2032 | * current DDS value. |
1985 | **/ | 2033 | **/ |
1986 | static int hdspm_get_system_sample_rate(struct hdspm *hdspm) | 2034 | static int hdspm_get_system_sample_rate(struct hdspm *hdspm) |
1987 | { | 2035 | { |
1988 | unsigned int period, rate; | 2036 | unsigned int rate; |
1989 | 2037 | ||
1990 | period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ); | 2038 | rate = hdspm_get_pll_freq(hdspm); |
1991 | rate = hdspm_calc_dds_value(hdspm, period); | ||
1992 | 2039 | ||
1993 | if (rate > 207000) { | 2040 | if (rate > 207000) { |
1994 | /* Unreasonable high sample rate as seen on PCI MADI cards. */ | 2041 | /* Unreasonable high sample rate as seen on PCI MADI cards. */ |
@@ -2128,6 +2175,16 @@ static int hdspm_get_s1_sample_rate(struct hdspm *hdspm, unsigned int idx) | |||
2128 | return (status >> (idx*4)) & 0xF; | 2175 | return (status >> (idx*4)) & 0xF; |
2129 | } | 2176 | } |
2130 | 2177 | ||
2178 | #define ENUMERATED_CTL_INFO(info, texts) \ | ||
2179 | { \ | ||
2180 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; \ | ||
2181 | uinfo->count = 1; \ | ||
2182 | uinfo->value.enumerated.items = ARRAY_SIZE(texts); \ | ||
2183 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) \ | ||
2184 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; \ | ||
2185 | strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); \ | ||
2186 | } | ||
2187 | |||
2131 | 2188 | ||
2132 | 2189 | ||
2133 | #define HDSPM_AUTOSYNC_SAMPLE_RATE(xname, xindex) \ | 2190 | #define HDSPM_AUTOSYNC_SAMPLE_RATE(xname, xindex) \ |
@@ -2143,14 +2200,7 @@ static int hdspm_get_s1_sample_rate(struct hdspm *hdspm, unsigned int idx) | |||
2143 | static int snd_hdspm_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, | 2200 | static int snd_hdspm_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, |
2144 | struct snd_ctl_elem_info *uinfo) | 2201 | struct snd_ctl_elem_info *uinfo) |
2145 | { | 2202 | { |
2146 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 2203 | ENUMERATED_CTL_INFO(uinfo, texts_freq); |
2147 | uinfo->count = 1; | ||
2148 | uinfo->value.enumerated.items = 10; | ||
2149 | |||
2150 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
2151 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; | ||
2152 | strcpy(uinfo->value.enumerated.name, | ||
2153 | texts_freq[uinfo->value.enumerated.item]); | ||
2154 | return 0; | 2204 | return 0; |
2155 | } | 2205 | } |
2156 | 2206 | ||
@@ -2316,15 +2366,7 @@ static int snd_hdspm_info_system_clock_mode(struct snd_kcontrol *kcontrol, | |||
2316 | struct snd_ctl_elem_info *uinfo) | 2366 | struct snd_ctl_elem_info *uinfo) |
2317 | { | 2367 | { |
2318 | static char *texts[] = { "Master", "AutoSync" }; | 2368 | static char *texts[] = { "Master", "AutoSync" }; |
2319 | 2369 | ENUMERATED_CTL_INFO(uinfo, texts); | |
2320 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
2321 | uinfo->count = 1; | ||
2322 | uinfo->value.enumerated.items = 2; | ||
2323 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
2324 | uinfo->value.enumerated.item = | ||
2325 | uinfo->value.enumerated.items - 1; | ||
2326 | strcpy(uinfo->value.enumerated.name, | ||
2327 | texts[uinfo->value.enumerated.item]); | ||
2328 | return 0; | 2370 | return 0; |
2329 | } | 2371 | } |
2330 | 2372 | ||
@@ -2888,6 +2930,112 @@ static int snd_hdspm_get_autosync_ref(struct snd_kcontrol *kcontrol, | |||
2888 | return 0; | 2930 | return 0; |
2889 | } | 2931 | } |
2890 | 2932 | ||
2933 | |||
2934 | |||
2935 | #define HDSPM_TCO_VIDEO_INPUT_FORMAT(xname, xindex) \ | ||
2936 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
2937 | .name = xname, \ | ||
2938 | .access = SNDRV_CTL_ELEM_ACCESS_READ |\ | ||
2939 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ | ||
2940 | .info = snd_hdspm_info_tco_video_input_format, \ | ||
2941 | .get = snd_hdspm_get_tco_video_input_format, \ | ||
2942 | } | ||
2943 | |||
2944 | static int snd_hdspm_info_tco_video_input_format(struct snd_kcontrol *kcontrol, | ||
2945 | struct snd_ctl_elem_info *uinfo) | ||
2946 | { | ||
2947 | static char *texts[] = {"No video", "NTSC", "PAL"}; | ||
2948 | ENUMERATED_CTL_INFO(uinfo, texts); | ||
2949 | return 0; | ||
2950 | } | ||
2951 | |||
2952 | static int snd_hdspm_get_tco_video_input_format(struct snd_kcontrol *kcontrol, | ||
2953 | struct snd_ctl_elem_value *ucontrol) | ||
2954 | { | ||
2955 | u32 status; | ||
2956 | int ret = 0; | ||
2957 | |||
2958 | struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); | ||
2959 | status = hdspm_read(hdspm, HDSPM_RD_TCO + 4); | ||
2960 | switch (status & (HDSPM_TCO1_Video_Input_Format_NTSC | | ||
2961 | HDSPM_TCO1_Video_Input_Format_PAL)) { | ||
2962 | case HDSPM_TCO1_Video_Input_Format_NTSC: | ||
2963 | /* ntsc */ | ||
2964 | ret = 1; | ||
2965 | break; | ||
2966 | case HDSPM_TCO1_Video_Input_Format_PAL: | ||
2967 | /* pal */ | ||
2968 | ret = 2; | ||
2969 | break; | ||
2970 | default: | ||
2971 | /* no video */ | ||
2972 | ret = 0; | ||
2973 | break; | ||
2974 | } | ||
2975 | ucontrol->value.enumerated.item[0] = ret; | ||
2976 | return 0; | ||
2977 | } | ||
2978 | |||
2979 | |||
2980 | |||
2981 | #define HDSPM_TCO_LTC_FRAMES(xname, xindex) \ | ||
2982 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
2983 | .name = xname, \ | ||
2984 | .access = SNDRV_CTL_ELEM_ACCESS_READ |\ | ||
2985 | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ | ||
2986 | .info = snd_hdspm_info_tco_ltc_frames, \ | ||
2987 | .get = snd_hdspm_get_tco_ltc_frames, \ | ||
2988 | } | ||
2989 | |||
2990 | static int snd_hdspm_info_tco_ltc_frames(struct snd_kcontrol *kcontrol, | ||
2991 | struct snd_ctl_elem_info *uinfo) | ||
2992 | { | ||
2993 | static char *texts[] = {"No lock", "24 fps", "25 fps", "29.97 fps", | ||
2994 | "30 fps"}; | ||
2995 | ENUMERATED_CTL_INFO(uinfo, texts); | ||
2996 | return 0; | ||
2997 | } | ||
2998 | |||
2999 | static int hdspm_tco_ltc_frames(struct hdspm *hdspm) | ||
3000 | { | ||
3001 | u32 status; | ||
3002 | int ret = 0; | ||
3003 | |||
3004 | status = hdspm_read(hdspm, HDSPM_RD_TCO + 4); | ||
3005 | if (status & HDSPM_TCO1_LTC_Input_valid) { | ||
3006 | switch (status & (HDSPM_TCO1_LTC_Format_LSB | | ||
3007 | HDSPM_TCO1_LTC_Format_MSB)) { | ||
3008 | case 0: | ||
3009 | /* 24 fps */ | ||
3010 | ret = 1; | ||
3011 | break; | ||
3012 | case HDSPM_TCO1_LTC_Format_LSB: | ||
3013 | /* 25 fps */ | ||
3014 | ret = 2; | ||
3015 | break; | ||
3016 | case HDSPM_TCO1_LTC_Format_MSB: | ||
3017 | /* 25 fps */ | ||
3018 | ret = 3; | ||
3019 | break; | ||
3020 | default: | ||
3021 | /* 30 fps */ | ||
3022 | ret = 4; | ||
3023 | break; | ||
3024 | } | ||
3025 | } | ||
3026 | |||
3027 | return ret; | ||
3028 | } | ||
3029 | |||
3030 | static int snd_hdspm_get_tco_ltc_frames(struct snd_kcontrol *kcontrol, | ||
3031 | struct snd_ctl_elem_value *ucontrol) | ||
3032 | { | ||
3033 | struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); | ||
3034 | |||
3035 | ucontrol->value.enumerated.item[0] = hdspm_tco_ltc_frames(hdspm); | ||
3036 | return 0; | ||
3037 | } | ||
3038 | |||
2891 | #define HDSPM_TOGGLE_SETTING(xname, xindex) \ | 3039 | #define HDSPM_TOGGLE_SETTING(xname, xindex) \ |
2892 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 3040 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
2893 | .name = xname, \ | 3041 | .name = xname, \ |
@@ -2974,17 +3122,7 @@ static int snd_hdspm_info_input_select(struct snd_kcontrol *kcontrol, | |||
2974 | struct snd_ctl_elem_info *uinfo) | 3122 | struct snd_ctl_elem_info *uinfo) |
2975 | { | 3123 | { |
2976 | static char *texts[] = { "optical", "coaxial" }; | 3124 | static char *texts[] = { "optical", "coaxial" }; |
2977 | 3125 | ENUMERATED_CTL_INFO(uinfo, texts); | |
2978 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
2979 | uinfo->count = 1; | ||
2980 | uinfo->value.enumerated.items = 2; | ||
2981 | |||
2982 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
2983 | uinfo->value.enumerated.item = | ||
2984 | uinfo->value.enumerated.items - 1; | ||
2985 | strcpy(uinfo->value.enumerated.name, | ||
2986 | texts[uinfo->value.enumerated.item]); | ||
2987 | |||
2988 | return 0; | 3126 | return 0; |
2989 | } | 3127 | } |
2990 | 3128 | ||
@@ -3046,17 +3184,7 @@ static int snd_hdspm_info_ds_wire(struct snd_kcontrol *kcontrol, | |||
3046 | struct snd_ctl_elem_info *uinfo) | 3184 | struct snd_ctl_elem_info *uinfo) |
3047 | { | 3185 | { |
3048 | static char *texts[] = { "Single", "Double" }; | 3186 | static char *texts[] = { "Single", "Double" }; |
3049 | 3187 | ENUMERATED_CTL_INFO(uinfo, texts); | |
3050 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
3051 | uinfo->count = 1; | ||
3052 | uinfo->value.enumerated.items = 2; | ||
3053 | |||
3054 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
3055 | uinfo->value.enumerated.item = | ||
3056 | uinfo->value.enumerated.items - 1; | ||
3057 | strcpy(uinfo->value.enumerated.name, | ||
3058 | texts[uinfo->value.enumerated.item]); | ||
3059 | |||
3060 | return 0; | 3188 | return 0; |
3061 | } | 3189 | } |
3062 | 3190 | ||
@@ -3129,17 +3257,7 @@ static int snd_hdspm_info_qs_wire(struct snd_kcontrol *kcontrol, | |||
3129 | struct snd_ctl_elem_info *uinfo) | 3257 | struct snd_ctl_elem_info *uinfo) |
3130 | { | 3258 | { |
3131 | static char *texts[] = { "Single", "Double", "Quad" }; | 3259 | static char *texts[] = { "Single", "Double", "Quad" }; |
3132 | 3260 | ENUMERATED_CTL_INFO(uinfo, texts); | |
3133 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
3134 | uinfo->count = 1; | ||
3135 | uinfo->value.enumerated.items = 3; | ||
3136 | |||
3137 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
3138 | uinfo->value.enumerated.item = | ||
3139 | uinfo->value.enumerated.items - 1; | ||
3140 | strcpy(uinfo->value.enumerated.name, | ||
3141 | texts[uinfo->value.enumerated.item]); | ||
3142 | |||
3143 | return 0; | 3261 | return 0; |
3144 | } | 3262 | } |
3145 | 3263 | ||
@@ -3215,17 +3333,7 @@ static int snd_hdspm_info_madi_speedmode(struct snd_kcontrol *kcontrol, | |||
3215 | struct snd_ctl_elem_info *uinfo) | 3333 | struct snd_ctl_elem_info *uinfo) |
3216 | { | 3334 | { |
3217 | static char *texts[] = { "Single", "Double", "Quad" }; | 3335 | static char *texts[] = { "Single", "Double", "Quad" }; |
3218 | 3336 | ENUMERATED_CTL_INFO(uinfo, texts); | |
3219 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
3220 | uinfo->count = 1; | ||
3221 | uinfo->value.enumerated.items = 3; | ||
3222 | |||
3223 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
3224 | uinfo->value.enumerated.item = | ||
3225 | uinfo->value.enumerated.items - 1; | ||
3226 | strcpy(uinfo->value.enumerated.name, | ||
3227 | texts[uinfo->value.enumerated.item]); | ||
3228 | |||
3229 | return 0; | 3337 | return 0; |
3230 | } | 3338 | } |
3231 | 3339 | ||
@@ -3445,19 +3553,30 @@ static int snd_hdspm_put_playback_mixer(struct snd_kcontrol *kcontrol, | |||
3445 | .get = snd_hdspm_get_sync_check \ | 3553 | .get = snd_hdspm_get_sync_check \ |
3446 | } | 3554 | } |
3447 | 3555 | ||
3556 | #define HDSPM_TCO_LOCK_CHECK(xname, xindex) \ | ||
3557 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
3558 | .name = xname, \ | ||
3559 | .private_value = xindex, \ | ||
3560 | .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ | ||
3561 | .info = snd_hdspm_tco_info_lock_check, \ | ||
3562 | .get = snd_hdspm_get_sync_check \ | ||
3563 | } | ||
3564 | |||
3565 | |||
3448 | 3566 | ||
3449 | static int snd_hdspm_info_sync_check(struct snd_kcontrol *kcontrol, | 3567 | static int snd_hdspm_info_sync_check(struct snd_kcontrol *kcontrol, |
3450 | struct snd_ctl_elem_info *uinfo) | 3568 | struct snd_ctl_elem_info *uinfo) |
3451 | { | 3569 | { |
3452 | static char *texts[] = { "No Lock", "Lock", "Sync", "N/A" }; | 3570 | static char *texts[] = { "No Lock", "Lock", "Sync", "N/A" }; |
3453 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 3571 | ENUMERATED_CTL_INFO(uinfo, texts); |
3454 | uinfo->count = 1; | 3572 | return 0; |
3455 | uinfo->value.enumerated.items = 4; | 3573 | } |
3456 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | 3574 | |
3457 | uinfo->value.enumerated.item = | 3575 | static int snd_hdspm_tco_info_lock_check(struct snd_kcontrol *kcontrol, |
3458 | uinfo->value.enumerated.items - 1; | 3576 | struct snd_ctl_elem_info *uinfo) |
3459 | strcpy(uinfo->value.enumerated.name, | 3577 | { |
3460 | texts[uinfo->value.enumerated.item]); | 3578 | static char *texts[] = { "No Lock", "Lock" }; |
3579 | ENUMERATED_CTL_INFO(uinfo, texts); | ||
3461 | return 0; | 3580 | return 0; |
3462 | } | 3581 | } |
3463 | 3582 | ||
@@ -3590,6 +3709,14 @@ static int hdspm_aes_sync_check(struct hdspm *hdspm, int idx) | |||
3590 | return 0; | 3709 | return 0; |
3591 | } | 3710 | } |
3592 | 3711 | ||
3712 | static int hdspm_tco_input_check(struct hdspm *hdspm, u32 mask) | ||
3713 | { | ||
3714 | u32 status; | ||
3715 | status = hdspm_read(hdspm, HDSPM_RD_TCO + 4); | ||
3716 | |||
3717 | return (status & mask) ? 1 : 0; | ||
3718 | } | ||
3719 | |||
3593 | 3720 | ||
3594 | static int hdspm_tco_sync_check(struct hdspm *hdspm) | 3721 | static int hdspm_tco_sync_check(struct hdspm *hdspm) |
3595 | { | 3722 | { |
@@ -3697,6 +3824,22 @@ static int snd_hdspm_get_sync_check(struct snd_kcontrol *kcontrol, | |||
3697 | 3824 | ||
3698 | } | 3825 | } |
3699 | 3826 | ||
3827 | if (hdspm->tco) { | ||
3828 | switch (kcontrol->private_value) { | ||
3829 | case 11: | ||
3830 | /* Check TCO for lock state of its current input */ | ||
3831 | val = hdspm_tco_input_check(hdspm, HDSPM_TCO1_TCO_lock); | ||
3832 | break; | ||
3833 | case 12: | ||
3834 | /* Check TCO for valid time code on LTC input. */ | ||
3835 | val = hdspm_tco_input_check(hdspm, | ||
3836 | HDSPM_TCO1_LTC_Input_valid); | ||
3837 | break; | ||
3838 | default: | ||
3839 | break; | ||
3840 | } | ||
3841 | } | ||
3842 | |||
3700 | if (-1 == val) | 3843 | if (-1 == val) |
3701 | val = 3; | 3844 | val = 3; |
3702 | 3845 | ||
@@ -3813,17 +3956,7 @@ static int snd_hdspm_info_tco_sample_rate(struct snd_kcontrol *kcontrol, | |||
3813 | struct snd_ctl_elem_info *uinfo) | 3956 | struct snd_ctl_elem_info *uinfo) |
3814 | { | 3957 | { |
3815 | static char *texts[] = { "44.1 kHz", "48 kHz" }; | 3958 | static char *texts[] = { "44.1 kHz", "48 kHz" }; |
3816 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 3959 | ENUMERATED_CTL_INFO(uinfo, texts); |
3817 | uinfo->count = 1; | ||
3818 | uinfo->value.enumerated.items = 2; | ||
3819 | |||
3820 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
3821 | uinfo->value.enumerated.item = | ||
3822 | uinfo->value.enumerated.items - 1; | ||
3823 | |||
3824 | strcpy(uinfo->value.enumerated.name, | ||
3825 | texts[uinfo->value.enumerated.item]); | ||
3826 | |||
3827 | return 0; | 3960 | return 0; |
3828 | } | 3961 | } |
3829 | 3962 | ||
@@ -3869,17 +4002,7 @@ static int snd_hdspm_info_tco_pull(struct snd_kcontrol *kcontrol, | |||
3869 | struct snd_ctl_elem_info *uinfo) | 4002 | struct snd_ctl_elem_info *uinfo) |
3870 | { | 4003 | { |
3871 | static char *texts[] = { "0", "+ 0.1 %", "- 0.1 %", "+ 4 %", "- 4 %" }; | 4004 | static char *texts[] = { "0", "+ 0.1 %", "- 0.1 %", "+ 4 %", "- 4 %" }; |
3872 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 4005 | ENUMERATED_CTL_INFO(uinfo, texts); |
3873 | uinfo->count = 1; | ||
3874 | uinfo->value.enumerated.items = 5; | ||
3875 | |||
3876 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
3877 | uinfo->value.enumerated.item = | ||
3878 | uinfo->value.enumerated.items - 1; | ||
3879 | |||
3880 | strcpy(uinfo->value.enumerated.name, | ||
3881 | texts[uinfo->value.enumerated.item]); | ||
3882 | |||
3883 | return 0; | 4006 | return 0; |
3884 | } | 4007 | } |
3885 | 4008 | ||
@@ -3924,17 +4047,7 @@ static int snd_hdspm_info_tco_wck_conversion(struct snd_kcontrol *kcontrol, | |||
3924 | struct snd_ctl_elem_info *uinfo) | 4047 | struct snd_ctl_elem_info *uinfo) |
3925 | { | 4048 | { |
3926 | static char *texts[] = { "1:1", "44.1 -> 48", "48 -> 44.1" }; | 4049 | static char *texts[] = { "1:1", "44.1 -> 48", "48 -> 44.1" }; |
3927 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 4050 | ENUMERATED_CTL_INFO(uinfo, texts); |
3928 | uinfo->count = 1; | ||
3929 | uinfo->value.enumerated.items = 3; | ||
3930 | |||
3931 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
3932 | uinfo->value.enumerated.item = | ||
3933 | uinfo->value.enumerated.items - 1; | ||
3934 | |||
3935 | strcpy(uinfo->value.enumerated.name, | ||
3936 | texts[uinfo->value.enumerated.item]); | ||
3937 | |||
3938 | return 0; | 4051 | return 0; |
3939 | } | 4052 | } |
3940 | 4053 | ||
@@ -3981,17 +4094,7 @@ static int snd_hdspm_info_tco_frame_rate(struct snd_kcontrol *kcontrol, | |||
3981 | { | 4094 | { |
3982 | static char *texts[] = { "24 fps", "25 fps", "29.97fps", | 4095 | static char *texts[] = { "24 fps", "25 fps", "29.97fps", |
3983 | "29.97 dfps", "30 fps", "30 dfps" }; | 4096 | "29.97 dfps", "30 fps", "30 dfps" }; |
3984 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 4097 | ENUMERATED_CTL_INFO(uinfo, texts); |
3985 | uinfo->count = 1; | ||
3986 | uinfo->value.enumerated.items = 6; | ||
3987 | |||
3988 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
3989 | uinfo->value.enumerated.item = | ||
3990 | uinfo->value.enumerated.items - 1; | ||
3991 | |||
3992 | strcpy(uinfo->value.enumerated.name, | ||
3993 | texts[uinfo->value.enumerated.item]); | ||
3994 | |||
3995 | return 0; | 4098 | return 0; |
3996 | } | 4099 | } |
3997 | 4100 | ||
@@ -4037,17 +4140,7 @@ static int snd_hdspm_info_tco_sync_source(struct snd_kcontrol *kcontrol, | |||
4037 | struct snd_ctl_elem_info *uinfo) | 4140 | struct snd_ctl_elem_info *uinfo) |
4038 | { | 4141 | { |
4039 | static char *texts[] = { "LTC", "Video", "WCK" }; | 4142 | static char *texts[] = { "LTC", "Video", "WCK" }; |
4040 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 4143 | ENUMERATED_CTL_INFO(uinfo, texts); |
4041 | uinfo->count = 1; | ||
4042 | uinfo->value.enumerated.items = 3; | ||
4043 | |||
4044 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) | ||
4045 | uinfo->value.enumerated.item = | ||
4046 | uinfo->value.enumerated.items - 1; | ||
4047 | |||
4048 | strcpy(uinfo->value.enumerated.name, | ||
4049 | texts[uinfo->value.enumerated.item]); | ||
4050 | |||
4051 | return 0; | 4144 | return 0; |
4052 | } | 4145 | } |
4053 | 4146 | ||
@@ -4145,6 +4238,7 @@ static struct snd_kcontrol_new snd_hdspm_controls_madi[] = { | |||
4145 | HDSPM_SYNC_CHECK("SYNC IN SyncCheck", 3), | 4238 | HDSPM_SYNC_CHECK("SYNC IN SyncCheck", 3), |
4146 | HDSPM_TOGGLE_SETTING("Line Out", HDSPM_LineOut), | 4239 | HDSPM_TOGGLE_SETTING("Line Out", HDSPM_LineOut), |
4147 | HDSPM_TOGGLE_SETTING("TX 64 channels mode", HDSPM_TX_64ch), | 4240 | HDSPM_TOGGLE_SETTING("TX 64 channels mode", HDSPM_TX_64ch), |
4241 | HDSPM_TOGGLE_SETTING("Disable 96K frames", HDSPM_SMUX), | ||
4148 | HDSPM_TOGGLE_SETTING("Clear Track Marker", HDSPM_clr_tms), | 4242 | HDSPM_TOGGLE_SETTING("Clear Track Marker", HDSPM_clr_tms), |
4149 | HDSPM_TOGGLE_SETTING("Safe Mode", HDSPM_AutoInp), | 4243 | HDSPM_TOGGLE_SETTING("Safe Mode", HDSPM_AutoInp), |
4150 | HDSPM_INPUT_SELECT("Input Select", 0), | 4244 | HDSPM_INPUT_SELECT("Input Select", 0), |
@@ -4272,7 +4366,11 @@ static struct snd_kcontrol_new snd_hdspm_controls_tco[] = { | |||
4272 | HDSPM_TCO_WCK_CONVERSION("TCO WCK Conversion", 0), | 4366 | HDSPM_TCO_WCK_CONVERSION("TCO WCK Conversion", 0), |
4273 | HDSPM_TCO_FRAME_RATE("TCO Frame Rate", 0), | 4367 | HDSPM_TCO_FRAME_RATE("TCO Frame Rate", 0), |
4274 | HDSPM_TCO_SYNC_SOURCE("TCO Sync Source", 0), | 4368 | HDSPM_TCO_SYNC_SOURCE("TCO Sync Source", 0), |
4275 | HDSPM_TCO_WORD_TERM("TCO Word Term", 0) | 4369 | HDSPM_TCO_WORD_TERM("TCO Word Term", 0), |
4370 | HDSPM_TCO_LOCK_CHECK("TCO Input Check", 11), | ||
4371 | HDSPM_TCO_LOCK_CHECK("TCO LTC Valid", 12), | ||
4372 | HDSPM_TCO_LTC_FRAMES("TCO Detected Frame Rate", 0), | ||
4373 | HDSPM_TCO_VIDEO_INPUT_FORMAT("Video Input Format", 0) | ||
4276 | }; | 4374 | }; |
4277 | 4375 | ||
4278 | 4376 | ||
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 29093a306ea2..3853f7eb3f28 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c | |||
@@ -315,7 +315,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, | |||
315 | } | 315 | } |
316 | 316 | ||
317 | static int soc_compr_copy(struct snd_compr_stream *cstream, | 317 | static int soc_compr_copy(struct snd_compr_stream *cstream, |
318 | const char __user *buf, size_t count) | 318 | char __user *buf, size_t count) |
319 | { | 319 | { |
320 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 320 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
321 | struct snd_soc_platform *platform = rtd->platform; | 321 | struct snd_soc_platform *platform = rtd->platform; |
@@ -384,7 +384,14 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) | |||
384 | /* check client and interface hw capabilities */ | 384 | /* check client and interface hw capabilities */ |
385 | snprintf(new_name, sizeof(new_name), "%s %s-%d", | 385 | snprintf(new_name, sizeof(new_name), "%s %s-%d", |
386 | rtd->dai_link->stream_name, codec_dai->name, num); | 386 | rtd->dai_link->stream_name, codec_dai->name, num); |
387 | direction = SND_COMPRESS_PLAYBACK; | 387 | |
388 | if (codec_dai->driver->playback.channels_min) | ||
389 | direction = SND_COMPRESS_PLAYBACK; | ||
390 | else if (codec_dai->driver->capture.channels_min) | ||
391 | direction = SND_COMPRESS_CAPTURE; | ||
392 | else | ||
393 | return -EINVAL; | ||
394 | |||
388 | compr = kzalloc(sizeof(*compr), GFP_KERNEL); | 395 | compr = kzalloc(sizeof(*compr), GFP_KERNEL); |
389 | if (compr == NULL) { | 396 | if (compr == NULL) { |
390 | snd_printk(KERN_ERR "Cannot allocate compr\n"); | 397 | snd_printk(KERN_ERR "Cannot allocate compr\n"); |
diff --git a/sound/sound_core.c b/sound/sound_core.c index bb23009edc8d..359753fc24e1 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c | |||
@@ -352,7 +352,9 @@ static struct sound_unit *chains[SOUND_STEP]; | |||
352 | * @dev: device pointer | 352 | * @dev: device pointer |
353 | * | 353 | * |
354 | * Allocate a special sound device by minor number from the sound | 354 | * Allocate a special sound device by minor number from the sound |
355 | * subsystem. The allocated number is returned on success. On failure | 355 | * subsystem. |
356 | * | ||
357 | * Return: The allocated number is returned on success. On failure, | ||
356 | * a negative error code is returned. | 358 | * a negative error code is returned. |
357 | */ | 359 | */ |
358 | 360 | ||
@@ -436,8 +438,10 @@ EXPORT_SYMBOL(register_sound_special); | |||
436 | * @dev: Unit number to allocate | 438 | * @dev: Unit number to allocate |
437 | * | 439 | * |
438 | * Allocate a mixer device. Unit is the number of the mixer requested. | 440 | * Allocate a mixer device. Unit is the number of the mixer requested. |
439 | * Pass -1 to request the next free mixer unit. On success the allocated | 441 | * Pass -1 to request the next free mixer unit. |
440 | * number is returned, on failure a negative error code is returned. | 442 | * |
443 | * Return: On success, the allocated number is returned. On failure, | ||
444 | * a negative error code is returned. | ||
441 | */ | 445 | */ |
442 | 446 | ||
443 | int register_sound_mixer(const struct file_operations *fops, int dev) | 447 | int register_sound_mixer(const struct file_operations *fops, int dev) |
@@ -454,8 +458,10 @@ EXPORT_SYMBOL(register_sound_mixer); | |||
454 | * @dev: Unit number to allocate | 458 | * @dev: Unit number to allocate |
455 | * | 459 | * |
456 | * Allocate a midi device. Unit is the number of the midi device requested. | 460 | * Allocate a midi device. Unit is the number of the midi device requested. |
457 | * Pass -1 to request the next free midi unit. On success the allocated | 461 | * Pass -1 to request the next free midi unit. |
458 | * number is returned, on failure a negative error code is returned. | 462 | * |
463 | * Return: On success, the allocated number is returned. On failure, | ||
464 | * a negative error code is returned. | ||
459 | */ | 465 | */ |
460 | 466 | ||
461 | int register_sound_midi(const struct file_operations *fops, int dev) | 467 | int register_sound_midi(const struct file_operations *fops, int dev) |
@@ -477,11 +483,13 @@ EXPORT_SYMBOL(register_sound_midi); | |||
477 | * @dev: Unit number to allocate | 483 | * @dev: Unit number to allocate |
478 | * | 484 | * |
479 | * Allocate a DSP device. Unit is the number of the DSP requested. | 485 | * Allocate a DSP device. Unit is the number of the DSP requested. |
480 | * Pass -1 to request the next free DSP unit. On success the allocated | 486 | * Pass -1 to request the next free DSP unit. |
481 | * number is returned, on failure a negative error code is returned. | ||
482 | * | 487 | * |
483 | * This function allocates both the audio and dsp device entries together | 488 | * This function allocates both the audio and dsp device entries together |
484 | * and will always allocate them as a matching pair - eg dsp3/audio3 | 489 | * and will always allocate them as a matching pair - eg dsp3/audio3 |
490 | * | ||
491 | * Return: On success, the allocated number is returned. On failure, | ||
492 | * a negative error code is returned. | ||
485 | */ | 493 | */ |
486 | 494 | ||
487 | int register_sound_dsp(const struct file_operations *fops, int dev) | 495 | int register_sound_dsp(const struct file_operations *fops, int dev) |
diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index 4dd60d8a4889..a1a24b979ed2 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c | |||
@@ -1075,10 +1075,11 @@ out: | |||
1075 | return 0; | 1075 | return 0; |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | #ifdef CONFIG_PM | 1078 | #ifdef CONFIG_PM_SLEEP |
1079 | static int snd_at73c213_suspend(struct spi_device *spi, pm_message_t msg) | 1079 | |
1080 | static int snd_at73c213_suspend(struct device *dev) | ||
1080 | { | 1081 | { |
1081 | struct snd_card *card = dev_get_drvdata(&spi->dev); | 1082 | struct snd_card *card = dev_get_drvdata(dev); |
1082 | struct snd_at73c213 *chip = card->private_data; | 1083 | struct snd_at73c213 *chip = card->private_data; |
1083 | 1084 | ||
1084 | ssc_writel(chip->ssc->regs, CR, SSC_BIT(CR_TXDIS)); | 1085 | ssc_writel(chip->ssc->regs, CR, SSC_BIT(CR_TXDIS)); |
@@ -1087,9 +1088,9 @@ static int snd_at73c213_suspend(struct spi_device *spi, pm_message_t msg) | |||
1087 | return 0; | 1088 | return 0; |
1088 | } | 1089 | } |
1089 | 1090 | ||
1090 | static int snd_at73c213_resume(struct spi_device *spi) | 1091 | static int snd_at73c213_resume(struct device *dev) |
1091 | { | 1092 | { |
1092 | struct snd_card *card = dev_get_drvdata(&spi->dev); | 1093 | struct snd_card *card = dev_get_drvdata(dev); |
1093 | struct snd_at73c213 *chip = card->private_data; | 1094 | struct snd_at73c213 *chip = card->private_data; |
1094 | 1095 | ||
1095 | clk_enable(chip->board->dac_clk); | 1096 | clk_enable(chip->board->dac_clk); |
@@ -1097,18 +1098,21 @@ static int snd_at73c213_resume(struct spi_device *spi) | |||
1097 | 1098 | ||
1098 | return 0; | 1099 | return 0; |
1099 | } | 1100 | } |
1101 | |||
1102 | static SIMPLE_DEV_PM_OPS(at73c213_pm_ops, snd_at73c213_suspend, | ||
1103 | snd_at73c213_resume); | ||
1104 | #define AT73C213_PM_OPS (&at73c213_pm_ops) | ||
1105 | |||
1100 | #else | 1106 | #else |
1101 | #define snd_at73c213_suspend NULL | 1107 | #define AT73C213_PM_OPS NULL |
1102 | #define snd_at73c213_resume NULL | ||
1103 | #endif | 1108 | #endif |
1104 | 1109 | ||
1105 | static struct spi_driver at73c213_driver = { | 1110 | static struct spi_driver at73c213_driver = { |
1106 | .driver = { | 1111 | .driver = { |
1107 | .name = "at73c213", | 1112 | .name = "at73c213", |
1113 | .pm = AT73C213_PM_OPS, | ||
1108 | }, | 1114 | }, |
1109 | .probe = snd_at73c213_probe, | 1115 | .probe = snd_at73c213_probe, |
1110 | .suspend = snd_at73c213_suspend, | ||
1111 | .resume = snd_at73c213_resume, | ||
1112 | .remove = snd_at73c213_remove, | 1116 | .remove = snd_at73c213_remove, |
1113 | }; | 1117 | }; |
1114 | 1118 | ||
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index fde9a7a29cb6..67330af21b0e 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/device.h> | ||
19 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
20 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
21 | #include <linux/init.h> | 22 | #include <linux/init.h> |
@@ -39,8 +40,8 @@ | |||
39 | #define ENDPOINT_CAPTURE 2 | 40 | #define ENDPOINT_CAPTURE 2 |
40 | #define ENDPOINT_PLAYBACK 6 | 41 | #define ENDPOINT_PLAYBACK 6 |
41 | 42 | ||
42 | #define MAKE_CHECKBYTE(dev,stream,i) \ | 43 | #define MAKE_CHECKBYTE(cdev,stream,i) \ |
43 | (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) | 44 | (stream << 1) | (~(i / (cdev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) |
44 | 45 | ||
45 | static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { | 46 | static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { |
46 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 47 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
@@ -60,32 +61,32 @@ static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { | |||
60 | }; | 61 | }; |
61 | 62 | ||
62 | static void | 63 | static void |
63 | activate_substream(struct snd_usb_caiaqdev *dev, | 64 | activate_substream(struct snd_usb_caiaqdev *cdev, |
64 | struct snd_pcm_substream *sub) | 65 | struct snd_pcm_substream *sub) |
65 | { | 66 | { |
66 | spin_lock(&dev->spinlock); | 67 | spin_lock(&cdev->spinlock); |
67 | 68 | ||
68 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) | 69 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) |
69 | dev->sub_playback[sub->number] = sub; | 70 | cdev->sub_playback[sub->number] = sub; |
70 | else | 71 | else |
71 | dev->sub_capture[sub->number] = sub; | 72 | cdev->sub_capture[sub->number] = sub; |
72 | 73 | ||
73 | spin_unlock(&dev->spinlock); | 74 | spin_unlock(&cdev->spinlock); |
74 | } | 75 | } |
75 | 76 | ||
76 | static void | 77 | static void |
77 | deactivate_substream(struct snd_usb_caiaqdev *dev, | 78 | deactivate_substream(struct snd_usb_caiaqdev *cdev, |
78 | struct snd_pcm_substream *sub) | 79 | struct snd_pcm_substream *sub) |
79 | { | 80 | { |
80 | unsigned long flags; | 81 | unsigned long flags; |
81 | spin_lock_irqsave(&dev->spinlock, flags); | 82 | spin_lock_irqsave(&cdev->spinlock, flags); |
82 | 83 | ||
83 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) | 84 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) |
84 | dev->sub_playback[sub->number] = NULL; | 85 | cdev->sub_playback[sub->number] = NULL; |
85 | else | 86 | else |
86 | dev->sub_capture[sub->number] = NULL; | 87 | cdev->sub_capture[sub->number] = NULL; |
87 | 88 | ||
88 | spin_unlock_irqrestore(&dev->spinlock, flags); | 89 | spin_unlock_irqrestore(&cdev->spinlock, flags); |
89 | } | 90 | } |
90 | 91 | ||
91 | static int | 92 | static int |
@@ -98,28 +99,30 @@ all_substreams_zero(struct snd_pcm_substream **subs) | |||
98 | return 1; | 99 | return 1; |
99 | } | 100 | } |
100 | 101 | ||
101 | static int stream_start(struct snd_usb_caiaqdev *dev) | 102 | static int stream_start(struct snd_usb_caiaqdev *cdev) |
102 | { | 103 | { |
103 | int i, ret; | 104 | int i, ret; |
105 | struct device *dev = caiaqdev_to_dev(cdev); | ||
104 | 106 | ||
105 | debug("%s(%p)\n", __func__, dev); | 107 | dev_dbg(dev, "%s(%p)\n", __func__, cdev); |
106 | 108 | ||
107 | if (dev->streaming) | 109 | if (cdev->streaming) |
108 | return -EINVAL; | 110 | return -EINVAL; |
109 | 111 | ||
110 | memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); | 112 | memset(cdev->sub_playback, 0, sizeof(cdev->sub_playback)); |
111 | memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); | 113 | memset(cdev->sub_capture, 0, sizeof(cdev->sub_capture)); |
112 | dev->input_panic = 0; | 114 | cdev->input_panic = 0; |
113 | dev->output_panic = 0; | 115 | cdev->output_panic = 0; |
114 | dev->first_packet = 4; | 116 | cdev->first_packet = 4; |
115 | dev->streaming = 1; | 117 | cdev->streaming = 1; |
116 | dev->warned = 0; | 118 | cdev->warned = 0; |
117 | 119 | ||
118 | for (i = 0; i < N_URBS; i++) { | 120 | for (i = 0; i < N_URBS; i++) { |
119 | ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC); | 121 | ret = usb_submit_urb(cdev->data_urbs_in[i], GFP_ATOMIC); |
120 | if (ret) { | 122 | if (ret) { |
121 | log("unable to trigger read #%d! (ret %d)\n", i, ret); | 123 | dev_err(dev, "unable to trigger read #%d! (ret %d)\n", |
122 | dev->streaming = 0; | 124 | i, ret); |
125 | cdev->streaming = 0; | ||
123 | return -EPIPE; | 126 | return -EPIPE; |
124 | } | 127 | } |
125 | } | 128 | } |
@@ -127,46 +130,51 @@ static int stream_start(struct snd_usb_caiaqdev *dev) | |||
127 | return 0; | 130 | return 0; |
128 | } | 131 | } |
129 | 132 | ||
130 | static void stream_stop(struct snd_usb_caiaqdev *dev) | 133 | static void stream_stop(struct snd_usb_caiaqdev *cdev) |
131 | { | 134 | { |
132 | int i; | 135 | int i; |
136 | struct device *dev = caiaqdev_to_dev(cdev); | ||
133 | 137 | ||
134 | debug("%s(%p)\n", __func__, dev); | 138 | dev_dbg(dev, "%s(%p)\n", __func__, cdev); |
135 | if (!dev->streaming) | 139 | if (!cdev->streaming) |
136 | return; | 140 | return; |
137 | 141 | ||
138 | dev->streaming = 0; | 142 | cdev->streaming = 0; |
139 | 143 | ||
140 | for (i = 0; i < N_URBS; i++) { | 144 | for (i = 0; i < N_URBS; i++) { |
141 | usb_kill_urb(dev->data_urbs_in[i]); | 145 | usb_kill_urb(cdev->data_urbs_in[i]); |
142 | 146 | ||
143 | if (test_bit(i, &dev->outurb_active_mask)) | 147 | if (test_bit(i, &cdev->outurb_active_mask)) |
144 | usb_kill_urb(dev->data_urbs_out[i]); | 148 | usb_kill_urb(cdev->data_urbs_out[i]); |
145 | } | 149 | } |
146 | 150 | ||
147 | dev->outurb_active_mask = 0; | 151 | cdev->outurb_active_mask = 0; |
148 | } | 152 | } |
149 | 153 | ||
150 | static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream) | 154 | static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream) |
151 | { | 155 | { |
152 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); | 156 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream); |
153 | debug("%s(%p)\n", __func__, substream); | 157 | struct device *dev = caiaqdev_to_dev(cdev); |
154 | substream->runtime->hw = dev->pcm_info; | 158 | |
159 | dev_dbg(dev, "%s(%p)\n", __func__, substream); | ||
160 | substream->runtime->hw = cdev->pcm_info; | ||
155 | snd_pcm_limit_hw_rates(substream->runtime); | 161 | snd_pcm_limit_hw_rates(substream->runtime); |
162 | |||
156 | return 0; | 163 | return 0; |
157 | } | 164 | } |
158 | 165 | ||
159 | static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) | 166 | static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) |
160 | { | 167 | { |
161 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); | 168 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream); |
169 | struct device *dev = caiaqdev_to_dev(cdev); | ||
162 | 170 | ||
163 | debug("%s(%p)\n", __func__, substream); | 171 | dev_dbg(dev, "%s(%p)\n", __func__, substream); |
164 | if (all_substreams_zero(dev->sub_playback) && | 172 | if (all_substreams_zero(cdev->sub_playback) && |
165 | all_substreams_zero(dev->sub_capture)) { | 173 | all_substreams_zero(cdev->sub_capture)) { |
166 | /* when the last client has stopped streaming, | 174 | /* when the last client has stopped streaming, |
167 | * all sample rates are allowed again */ | 175 | * all sample rates are allowed again */ |
168 | stream_stop(dev); | 176 | stream_stop(cdev); |
169 | dev->pcm_info.rates = dev->samplerates; | 177 | cdev->pcm_info.rates = cdev->samplerates; |
170 | } | 178 | } |
171 | 179 | ||
172 | return 0; | 180 | return 0; |
@@ -175,15 +183,13 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) | |||
175 | static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, | 183 | static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, |
176 | struct snd_pcm_hw_params *hw_params) | 184 | struct snd_pcm_hw_params *hw_params) |
177 | { | 185 | { |
178 | debug("%s(%p)\n", __func__, sub); | ||
179 | return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params)); | 186 | return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params)); |
180 | } | 187 | } |
181 | 188 | ||
182 | static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) | 189 | static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) |
183 | { | 190 | { |
184 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); | 191 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); |
185 | debug("%s(%p)\n", __func__, sub); | 192 | deactivate_substream(cdev, sub); |
186 | deactivate_substream(dev, sub); | ||
187 | return snd_pcm_lib_free_pages(sub); | 193 | return snd_pcm_lib_free_pages(sub); |
188 | } | 194 | } |
189 | 195 | ||
@@ -199,15 +205,16 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
199 | { | 205 | { |
200 | int bytes_per_sample, bpp, ret, i; | 206 | int bytes_per_sample, bpp, ret, i; |
201 | int index = substream->number; | 207 | int index = substream->number; |
202 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); | 208 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream); |
203 | struct snd_pcm_runtime *runtime = substream->runtime; | 209 | struct snd_pcm_runtime *runtime = substream->runtime; |
210 | struct device *dev = caiaqdev_to_dev(cdev); | ||
204 | 211 | ||
205 | debug("%s(%p)\n", __func__, substream); | 212 | dev_dbg(dev, "%s(%p)\n", __func__, substream); |
206 | 213 | ||
207 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 214 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
208 | int out_pos; | 215 | int out_pos; |
209 | 216 | ||
210 | switch (dev->spec.data_alignment) { | 217 | switch (cdev->spec.data_alignment) { |
211 | case 0: | 218 | case 0: |
212 | case 2: | 219 | case 2: |
213 | out_pos = BYTES_PER_SAMPLE + 1; | 220 | out_pos = BYTES_PER_SAMPLE + 1; |
@@ -218,12 +225,12 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
218 | break; | 225 | break; |
219 | } | 226 | } |
220 | 227 | ||
221 | dev->period_out_count[index] = out_pos; | 228 | cdev->period_out_count[index] = out_pos; |
222 | dev->audio_out_buf_pos[index] = out_pos; | 229 | cdev->audio_out_buf_pos[index] = out_pos; |
223 | } else { | 230 | } else { |
224 | int in_pos; | 231 | int in_pos; |
225 | 232 | ||
226 | switch (dev->spec.data_alignment) { | 233 | switch (cdev->spec.data_alignment) { |
227 | case 0: | 234 | case 0: |
228 | in_pos = BYTES_PER_SAMPLE + 2; | 235 | in_pos = BYTES_PER_SAMPLE + 2; |
229 | break; | 236 | break; |
@@ -236,44 +243,44 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
236 | break; | 243 | break; |
237 | } | 244 | } |
238 | 245 | ||
239 | dev->period_in_count[index] = in_pos; | 246 | cdev->period_in_count[index] = in_pos; |
240 | dev->audio_in_buf_pos[index] = in_pos; | 247 | cdev->audio_in_buf_pos[index] = in_pos; |
241 | } | 248 | } |
242 | 249 | ||
243 | if (dev->streaming) | 250 | if (cdev->streaming) |
244 | return 0; | 251 | return 0; |
245 | 252 | ||
246 | /* the first client that opens a stream defines the sample rate | 253 | /* the first client that opens a stream defines the sample rate |
247 | * setting for all subsequent calls, until the last client closed. */ | 254 | * setting for all subsequent calls, until the last client closed. */ |
248 | for (i=0; i < ARRAY_SIZE(rates); i++) | 255 | for (i=0; i < ARRAY_SIZE(rates); i++) |
249 | if (runtime->rate == rates[i]) | 256 | if (runtime->rate == rates[i]) |
250 | dev->pcm_info.rates = 1 << i; | 257 | cdev->pcm_info.rates = 1 << i; |
251 | 258 | ||
252 | snd_pcm_limit_hw_rates(runtime); | 259 | snd_pcm_limit_hw_rates(runtime); |
253 | 260 | ||
254 | bytes_per_sample = BYTES_PER_SAMPLE; | 261 | bytes_per_sample = BYTES_PER_SAMPLE; |
255 | if (dev->spec.data_alignment >= 2) | 262 | if (cdev->spec.data_alignment >= 2) |
256 | bytes_per_sample++; | 263 | bytes_per_sample++; |
257 | 264 | ||
258 | bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) | 265 | bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) |
259 | * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams; | 266 | * bytes_per_sample * CHANNELS_PER_STREAM * cdev->n_streams; |
260 | 267 | ||
261 | if (bpp > MAX_ENDPOINT_SIZE) | 268 | if (bpp > MAX_ENDPOINT_SIZE) |
262 | bpp = MAX_ENDPOINT_SIZE; | 269 | bpp = MAX_ENDPOINT_SIZE; |
263 | 270 | ||
264 | ret = snd_usb_caiaq_set_audio_params(dev, runtime->rate, | 271 | ret = snd_usb_caiaq_set_audio_params(cdev, runtime->rate, |
265 | runtime->sample_bits, bpp); | 272 | runtime->sample_bits, bpp); |
266 | if (ret) | 273 | if (ret) |
267 | return ret; | 274 | return ret; |
268 | 275 | ||
269 | ret = stream_start(dev); | 276 | ret = stream_start(cdev); |
270 | if (ret) | 277 | if (ret) |
271 | return ret; | 278 | return ret; |
272 | 279 | ||
273 | dev->output_running = 0; | 280 | cdev->output_running = 0; |
274 | wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ); | 281 | wait_event_timeout(cdev->prepare_wait_queue, cdev->output_running, HZ); |
275 | if (!dev->output_running) { | 282 | if (!cdev->output_running) { |
276 | stream_stop(dev); | 283 | stream_stop(cdev); |
277 | return -EPIPE; | 284 | return -EPIPE; |
278 | } | 285 | } |
279 | 286 | ||
@@ -282,18 +289,19 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
282 | 289 | ||
283 | static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd) | 290 | static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd) |
284 | { | 291 | { |
285 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); | 292 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); |
293 | struct device *dev = caiaqdev_to_dev(cdev); | ||
286 | 294 | ||
287 | debug("%s(%p) cmd %d\n", __func__, sub, cmd); | 295 | dev_dbg(dev, "%s(%p) cmd %d\n", __func__, sub, cmd); |
288 | 296 | ||
289 | switch (cmd) { | 297 | switch (cmd) { |
290 | case SNDRV_PCM_TRIGGER_START: | 298 | case SNDRV_PCM_TRIGGER_START: |
291 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 299 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
292 | activate_substream(dev, sub); | 300 | activate_substream(cdev, sub); |
293 | break; | 301 | break; |
294 | case SNDRV_PCM_TRIGGER_STOP: | 302 | case SNDRV_PCM_TRIGGER_STOP: |
295 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 303 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
296 | deactivate_substream(dev, sub); | 304 | deactivate_substream(cdev, sub); |
297 | break; | 305 | break; |
298 | default: | 306 | default: |
299 | return -EINVAL; | 307 | return -EINVAL; |
@@ -306,25 +314,25 @@ static snd_pcm_uframes_t | |||
306 | snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub) | 314 | snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub) |
307 | { | 315 | { |
308 | int index = sub->number; | 316 | int index = sub->number; |
309 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); | 317 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); |
310 | snd_pcm_uframes_t ptr; | 318 | snd_pcm_uframes_t ptr; |
311 | 319 | ||
312 | spin_lock(&dev->spinlock); | 320 | spin_lock(&cdev->spinlock); |
313 | 321 | ||
314 | if (dev->input_panic || dev->output_panic) { | 322 | if (cdev->input_panic || cdev->output_panic) { |
315 | ptr = SNDRV_PCM_POS_XRUN; | 323 | ptr = SNDRV_PCM_POS_XRUN; |
316 | goto unlock; | 324 | goto unlock; |
317 | } | 325 | } |
318 | 326 | ||
319 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) | 327 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) |
320 | ptr = bytes_to_frames(sub->runtime, | 328 | ptr = bytes_to_frames(sub->runtime, |
321 | dev->audio_out_buf_pos[index]); | 329 | cdev->audio_out_buf_pos[index]); |
322 | else | 330 | else |
323 | ptr = bytes_to_frames(sub->runtime, | 331 | ptr = bytes_to_frames(sub->runtime, |
324 | dev->audio_in_buf_pos[index]); | 332 | cdev->audio_in_buf_pos[index]); |
325 | 333 | ||
326 | unlock: | 334 | unlock: |
327 | spin_unlock(&dev->spinlock); | 335 | spin_unlock(&cdev->spinlock); |
328 | return ptr; | 336 | return ptr; |
329 | } | 337 | } |
330 | 338 | ||
@@ -340,21 +348,21 @@ static struct snd_pcm_ops snd_usb_caiaq_ops = { | |||
340 | .pointer = snd_usb_caiaq_pcm_pointer | 348 | .pointer = snd_usb_caiaq_pcm_pointer |
341 | }; | 349 | }; |
342 | 350 | ||
343 | static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, | 351 | static void check_for_elapsed_periods(struct snd_usb_caiaqdev *cdev, |
344 | struct snd_pcm_substream **subs) | 352 | struct snd_pcm_substream **subs) |
345 | { | 353 | { |
346 | int stream, pb, *cnt; | 354 | int stream, pb, *cnt; |
347 | struct snd_pcm_substream *sub; | 355 | struct snd_pcm_substream *sub; |
348 | 356 | ||
349 | for (stream = 0; stream < dev->n_streams; stream++) { | 357 | for (stream = 0; stream < cdev->n_streams; stream++) { |
350 | sub = subs[stream]; | 358 | sub = subs[stream]; |
351 | if (!sub) | 359 | if (!sub) |
352 | continue; | 360 | continue; |
353 | 361 | ||
354 | pb = snd_pcm_lib_period_bytes(sub); | 362 | pb = snd_pcm_lib_period_bytes(sub); |
355 | cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ? | 363 | cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ? |
356 | &dev->period_out_count[stream] : | 364 | &cdev->period_out_count[stream] : |
357 | &dev->period_in_count[stream]; | 365 | &cdev->period_in_count[stream]; |
358 | 366 | ||
359 | if (*cnt >= pb) { | 367 | if (*cnt >= pb) { |
360 | snd_pcm_period_elapsed(sub); | 368 | snd_pcm_period_elapsed(sub); |
@@ -363,7 +371,7 @@ static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, | |||
363 | } | 371 | } |
364 | } | 372 | } |
365 | 373 | ||
366 | static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev, | 374 | static void read_in_urb_mode0(struct snd_usb_caiaqdev *cdev, |
367 | const struct urb *urb, | 375 | const struct urb *urb, |
368 | const struct usb_iso_packet_descriptor *iso) | 376 | const struct usb_iso_packet_descriptor *iso) |
369 | { | 377 | { |
@@ -371,27 +379,27 @@ static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev, | |||
371 | struct snd_pcm_substream *sub; | 379 | struct snd_pcm_substream *sub; |
372 | int stream, i; | 380 | int stream, i; |
373 | 381 | ||
374 | if (all_substreams_zero(dev->sub_capture)) | 382 | if (all_substreams_zero(cdev->sub_capture)) |
375 | return; | 383 | return; |
376 | 384 | ||
377 | for (i = 0; i < iso->actual_length;) { | 385 | for (i = 0; i < iso->actual_length;) { |
378 | for (stream = 0; stream < dev->n_streams; stream++, i++) { | 386 | for (stream = 0; stream < cdev->n_streams; stream++, i++) { |
379 | sub = dev->sub_capture[stream]; | 387 | sub = cdev->sub_capture[stream]; |
380 | if (sub) { | 388 | if (sub) { |
381 | struct snd_pcm_runtime *rt = sub->runtime; | 389 | struct snd_pcm_runtime *rt = sub->runtime; |
382 | char *audio_buf = rt->dma_area; | 390 | char *audio_buf = rt->dma_area; |
383 | int sz = frames_to_bytes(rt, rt->buffer_size); | 391 | int sz = frames_to_bytes(rt, rt->buffer_size); |
384 | audio_buf[dev->audio_in_buf_pos[stream]++] | 392 | audio_buf[cdev->audio_in_buf_pos[stream]++] |
385 | = usb_buf[i]; | 393 | = usb_buf[i]; |
386 | dev->period_in_count[stream]++; | 394 | cdev->period_in_count[stream]++; |
387 | if (dev->audio_in_buf_pos[stream] == sz) | 395 | if (cdev->audio_in_buf_pos[stream] == sz) |
388 | dev->audio_in_buf_pos[stream] = 0; | 396 | cdev->audio_in_buf_pos[stream] = 0; |
389 | } | 397 | } |
390 | } | 398 | } |
391 | } | 399 | } |
392 | } | 400 | } |
393 | 401 | ||
394 | static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev, | 402 | static void read_in_urb_mode2(struct snd_usb_caiaqdev *cdev, |
395 | const struct urb *urb, | 403 | const struct urb *urb, |
396 | const struct usb_iso_packet_descriptor *iso) | 404 | const struct usb_iso_packet_descriptor *iso) |
397 | { | 405 | { |
@@ -401,48 +409,49 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev, | |||
401 | int stream, i; | 409 | int stream, i; |
402 | 410 | ||
403 | for (i = 0; i < iso->actual_length;) { | 411 | for (i = 0; i < iso->actual_length;) { |
404 | if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { | 412 | if (i % (cdev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { |
405 | for (stream = 0; | 413 | for (stream = 0; |
406 | stream < dev->n_streams; | 414 | stream < cdev->n_streams; |
407 | stream++, i++) { | 415 | stream++, i++) { |
408 | if (dev->first_packet) | 416 | if (cdev->first_packet) |
409 | continue; | 417 | continue; |
410 | 418 | ||
411 | check_byte = MAKE_CHECKBYTE(dev, stream, i); | 419 | check_byte = MAKE_CHECKBYTE(cdev, stream, i); |
412 | 420 | ||
413 | if ((usb_buf[i] & 0x3f) != check_byte) | 421 | if ((usb_buf[i] & 0x3f) != check_byte) |
414 | dev->input_panic = 1; | 422 | cdev->input_panic = 1; |
415 | 423 | ||
416 | if (usb_buf[i] & 0x80) | 424 | if (usb_buf[i] & 0x80) |
417 | dev->output_panic = 1; | 425 | cdev->output_panic = 1; |
418 | } | 426 | } |
419 | } | 427 | } |
420 | dev->first_packet = 0; | 428 | cdev->first_packet = 0; |
421 | 429 | ||
422 | for (stream = 0; stream < dev->n_streams; stream++, i++) { | 430 | for (stream = 0; stream < cdev->n_streams; stream++, i++) { |
423 | sub = dev->sub_capture[stream]; | 431 | sub = cdev->sub_capture[stream]; |
424 | if (dev->input_panic) | 432 | if (cdev->input_panic) |
425 | usb_buf[i] = 0; | 433 | usb_buf[i] = 0; |
426 | 434 | ||
427 | if (sub) { | 435 | if (sub) { |
428 | struct snd_pcm_runtime *rt = sub->runtime; | 436 | struct snd_pcm_runtime *rt = sub->runtime; |
429 | char *audio_buf = rt->dma_area; | 437 | char *audio_buf = rt->dma_area; |
430 | int sz = frames_to_bytes(rt, rt->buffer_size); | 438 | int sz = frames_to_bytes(rt, rt->buffer_size); |
431 | audio_buf[dev->audio_in_buf_pos[stream]++] = | 439 | audio_buf[cdev->audio_in_buf_pos[stream]++] = |
432 | usb_buf[i]; | 440 | usb_buf[i]; |
433 | dev->period_in_count[stream]++; | 441 | cdev->period_in_count[stream]++; |
434 | if (dev->audio_in_buf_pos[stream] == sz) | 442 | if (cdev->audio_in_buf_pos[stream] == sz) |
435 | dev->audio_in_buf_pos[stream] = 0; | 443 | cdev->audio_in_buf_pos[stream] = 0; |
436 | } | 444 | } |
437 | } | 445 | } |
438 | } | 446 | } |
439 | } | 447 | } |
440 | 448 | ||
441 | static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, | 449 | static void read_in_urb_mode3(struct snd_usb_caiaqdev *cdev, |
442 | const struct urb *urb, | 450 | const struct urb *urb, |
443 | const struct usb_iso_packet_descriptor *iso) | 451 | const struct usb_iso_packet_descriptor *iso) |
444 | { | 452 | { |
445 | unsigned char *usb_buf = urb->transfer_buffer + iso->offset; | 453 | unsigned char *usb_buf = urb->transfer_buffer + iso->offset; |
454 | struct device *dev = caiaqdev_to_dev(cdev); | ||
446 | int stream, i; | 455 | int stream, i; |
447 | 456 | ||
448 | /* paranoia check */ | 457 | /* paranoia check */ |
@@ -450,12 +459,12 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, | |||
450 | return; | 459 | return; |
451 | 460 | ||
452 | for (i = 0; i < iso->actual_length;) { | 461 | for (i = 0; i < iso->actual_length;) { |
453 | for (stream = 0; stream < dev->n_streams; stream++) { | 462 | for (stream = 0; stream < cdev->n_streams; stream++) { |
454 | struct snd_pcm_substream *sub = dev->sub_capture[stream]; | 463 | struct snd_pcm_substream *sub = cdev->sub_capture[stream]; |
455 | char *audio_buf = NULL; | 464 | char *audio_buf = NULL; |
456 | int c, n, sz = 0; | 465 | int c, n, sz = 0; |
457 | 466 | ||
458 | if (sub && !dev->input_panic) { | 467 | if (sub && !cdev->input_panic) { |
459 | struct snd_pcm_runtime *rt = sub->runtime; | 468 | struct snd_pcm_runtime *rt = sub->runtime; |
460 | audio_buf = rt->dma_area; | 469 | audio_buf = rt->dma_area; |
461 | sz = frames_to_bytes(rt, rt->buffer_size); | 470 | sz = frames_to_bytes(rt, rt->buffer_size); |
@@ -465,23 +474,23 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, | |||
465 | /* 3 audio data bytes, followed by 1 check byte */ | 474 | /* 3 audio data bytes, followed by 1 check byte */ |
466 | if (audio_buf) { | 475 | if (audio_buf) { |
467 | for (n = 0; n < BYTES_PER_SAMPLE; n++) { | 476 | for (n = 0; n < BYTES_PER_SAMPLE; n++) { |
468 | audio_buf[dev->audio_in_buf_pos[stream]++] = usb_buf[i+n]; | 477 | audio_buf[cdev->audio_in_buf_pos[stream]++] = usb_buf[i+n]; |
469 | 478 | ||
470 | if (dev->audio_in_buf_pos[stream] == sz) | 479 | if (cdev->audio_in_buf_pos[stream] == sz) |
471 | dev->audio_in_buf_pos[stream] = 0; | 480 | cdev->audio_in_buf_pos[stream] = 0; |
472 | } | 481 | } |
473 | 482 | ||
474 | dev->period_in_count[stream] += BYTES_PER_SAMPLE; | 483 | cdev->period_in_count[stream] += BYTES_PER_SAMPLE; |
475 | } | 484 | } |
476 | 485 | ||
477 | i += BYTES_PER_SAMPLE; | 486 | i += BYTES_PER_SAMPLE; |
478 | 487 | ||
479 | if (usb_buf[i] != ((stream << 1) | c) && | 488 | if (usb_buf[i] != ((stream << 1) | c) && |
480 | !dev->first_packet) { | 489 | !cdev->first_packet) { |
481 | if (!dev->input_panic) | 490 | if (!cdev->input_panic) |
482 | printk(" EXPECTED: %02x got %02x, c %d, stream %d, i %d\n", | 491 | dev_warn(dev, " EXPECTED: %02x got %02x, c %d, stream %d, i %d\n", |
483 | ((stream << 1) | c), usb_buf[i], c, stream, i); | 492 | ((stream << 1) | c), usb_buf[i], c, stream, i); |
484 | dev->input_panic = 1; | 493 | cdev->input_panic = 1; |
485 | } | 494 | } |
486 | 495 | ||
487 | i++; | 496 | i++; |
@@ -489,41 +498,43 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, | |||
489 | } | 498 | } |
490 | } | 499 | } |
491 | 500 | ||
492 | if (dev->first_packet > 0) | 501 | if (cdev->first_packet > 0) |
493 | dev->first_packet--; | 502 | cdev->first_packet--; |
494 | } | 503 | } |
495 | 504 | ||
496 | static void read_in_urb(struct snd_usb_caiaqdev *dev, | 505 | static void read_in_urb(struct snd_usb_caiaqdev *cdev, |
497 | const struct urb *urb, | 506 | const struct urb *urb, |
498 | const struct usb_iso_packet_descriptor *iso) | 507 | const struct usb_iso_packet_descriptor *iso) |
499 | { | 508 | { |
500 | if (!dev->streaming) | 509 | struct device *dev = caiaqdev_to_dev(cdev); |
510 | |||
511 | if (!cdev->streaming) | ||
501 | return; | 512 | return; |
502 | 513 | ||
503 | if (iso->actual_length < dev->bpp) | 514 | if (iso->actual_length < cdev->bpp) |
504 | return; | 515 | return; |
505 | 516 | ||
506 | switch (dev->spec.data_alignment) { | 517 | switch (cdev->spec.data_alignment) { |
507 | case 0: | 518 | case 0: |
508 | read_in_urb_mode0(dev, urb, iso); | 519 | read_in_urb_mode0(cdev, urb, iso); |
509 | break; | 520 | break; |
510 | case 2: | 521 | case 2: |
511 | read_in_urb_mode2(dev, urb, iso); | 522 | read_in_urb_mode2(cdev, urb, iso); |
512 | break; | 523 | break; |
513 | case 3: | 524 | case 3: |
514 | read_in_urb_mode3(dev, urb, iso); | 525 | read_in_urb_mode3(cdev, urb, iso); |
515 | break; | 526 | break; |
516 | } | 527 | } |
517 | 528 | ||
518 | if ((dev->input_panic || dev->output_panic) && !dev->warned) { | 529 | if ((cdev->input_panic || cdev->output_panic) && !cdev->warned) { |
519 | debug("streaming error detected %s %s\n", | 530 | dev_warn(dev, "streaming error detected %s %s\n", |
520 | dev->input_panic ? "(input)" : "", | 531 | cdev->input_panic ? "(input)" : "", |
521 | dev->output_panic ? "(output)" : ""); | 532 | cdev->output_panic ? "(output)" : ""); |
522 | dev->warned = 1; | 533 | cdev->warned = 1; |
523 | } | 534 | } |
524 | } | 535 | } |
525 | 536 | ||
526 | static void fill_out_urb_mode_0(struct snd_usb_caiaqdev *dev, | 537 | static void fill_out_urb_mode_0(struct snd_usb_caiaqdev *cdev, |
527 | struct urb *urb, | 538 | struct urb *urb, |
528 | const struct usb_iso_packet_descriptor *iso) | 539 | const struct usb_iso_packet_descriptor *iso) |
529 | { | 540 | { |
@@ -532,32 +543,32 @@ static void fill_out_urb_mode_0(struct snd_usb_caiaqdev *dev, | |||
532 | int stream, i; | 543 | int stream, i; |
533 | 544 | ||
534 | for (i = 0; i < iso->length;) { | 545 | for (i = 0; i < iso->length;) { |
535 | for (stream = 0; stream < dev->n_streams; stream++, i++) { | 546 | for (stream = 0; stream < cdev->n_streams; stream++, i++) { |
536 | sub = dev->sub_playback[stream]; | 547 | sub = cdev->sub_playback[stream]; |
537 | if (sub) { | 548 | if (sub) { |
538 | struct snd_pcm_runtime *rt = sub->runtime; | 549 | struct snd_pcm_runtime *rt = sub->runtime; |
539 | char *audio_buf = rt->dma_area; | 550 | char *audio_buf = rt->dma_area; |
540 | int sz = frames_to_bytes(rt, rt->buffer_size); | 551 | int sz = frames_to_bytes(rt, rt->buffer_size); |
541 | usb_buf[i] = | 552 | usb_buf[i] = |
542 | audio_buf[dev->audio_out_buf_pos[stream]]; | 553 | audio_buf[cdev->audio_out_buf_pos[stream]]; |
543 | dev->period_out_count[stream]++; | 554 | cdev->period_out_count[stream]++; |
544 | dev->audio_out_buf_pos[stream]++; | 555 | cdev->audio_out_buf_pos[stream]++; |
545 | if (dev->audio_out_buf_pos[stream] == sz) | 556 | if (cdev->audio_out_buf_pos[stream] == sz) |
546 | dev->audio_out_buf_pos[stream] = 0; | 557 | cdev->audio_out_buf_pos[stream] = 0; |
547 | } else | 558 | } else |
548 | usb_buf[i] = 0; | 559 | usb_buf[i] = 0; |
549 | } | 560 | } |
550 | 561 | ||
551 | /* fill in the check bytes */ | 562 | /* fill in the check bytes */ |
552 | if (dev->spec.data_alignment == 2 && | 563 | if (cdev->spec.data_alignment == 2 && |
553 | i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == | 564 | i % (cdev->n_streams * BYTES_PER_SAMPLE_USB) == |
554 | (dev->n_streams * CHANNELS_PER_STREAM)) | 565 | (cdev->n_streams * CHANNELS_PER_STREAM)) |
555 | for (stream = 0; stream < dev->n_streams; stream++, i++) | 566 | for (stream = 0; stream < cdev->n_streams; stream++, i++) |
556 | usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i); | 567 | usb_buf[i] = MAKE_CHECKBYTE(cdev, stream, i); |
557 | } | 568 | } |
558 | } | 569 | } |
559 | 570 | ||
560 | static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, | 571 | static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *cdev, |
561 | struct urb *urb, | 572 | struct urb *urb, |
562 | const struct usb_iso_packet_descriptor *iso) | 573 | const struct usb_iso_packet_descriptor *iso) |
563 | { | 574 | { |
@@ -565,8 +576,8 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, | |||
565 | int stream, i; | 576 | int stream, i; |
566 | 577 | ||
567 | for (i = 0; i < iso->length;) { | 578 | for (i = 0; i < iso->length;) { |
568 | for (stream = 0; stream < dev->n_streams; stream++) { | 579 | for (stream = 0; stream < cdev->n_streams; stream++) { |
569 | struct snd_pcm_substream *sub = dev->sub_playback[stream]; | 580 | struct snd_pcm_substream *sub = cdev->sub_playback[stream]; |
570 | char *audio_buf = NULL; | 581 | char *audio_buf = NULL; |
571 | int c, n, sz = 0; | 582 | int c, n, sz = 0; |
572 | 583 | ||
@@ -579,17 +590,17 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, | |||
579 | for (c = 0; c < CHANNELS_PER_STREAM; c++) { | 590 | for (c = 0; c < CHANNELS_PER_STREAM; c++) { |
580 | for (n = 0; n < BYTES_PER_SAMPLE; n++) { | 591 | for (n = 0; n < BYTES_PER_SAMPLE; n++) { |
581 | if (audio_buf) { | 592 | if (audio_buf) { |
582 | usb_buf[i+n] = audio_buf[dev->audio_out_buf_pos[stream]++]; | 593 | usb_buf[i+n] = audio_buf[cdev->audio_out_buf_pos[stream]++]; |
583 | 594 | ||
584 | if (dev->audio_out_buf_pos[stream] == sz) | 595 | if (cdev->audio_out_buf_pos[stream] == sz) |
585 | dev->audio_out_buf_pos[stream] = 0; | 596 | cdev->audio_out_buf_pos[stream] = 0; |
586 | } else { | 597 | } else { |
587 | usb_buf[i+n] = 0; | 598 | usb_buf[i+n] = 0; |
588 | } | 599 | } |
589 | } | 600 | } |
590 | 601 | ||
591 | if (audio_buf) | 602 | if (audio_buf) |
592 | dev->period_out_count[stream] += BYTES_PER_SAMPLE; | 603 | cdev->period_out_count[stream] += BYTES_PER_SAMPLE; |
593 | 604 | ||
594 | i += BYTES_PER_SAMPLE; | 605 | i += BYTES_PER_SAMPLE; |
595 | 606 | ||
@@ -600,17 +611,17 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, | |||
600 | } | 611 | } |
601 | } | 612 | } |
602 | 613 | ||
603 | static inline void fill_out_urb(struct snd_usb_caiaqdev *dev, | 614 | static inline void fill_out_urb(struct snd_usb_caiaqdev *cdev, |
604 | struct urb *urb, | 615 | struct urb *urb, |
605 | const struct usb_iso_packet_descriptor *iso) | 616 | const struct usb_iso_packet_descriptor *iso) |
606 | { | 617 | { |
607 | switch (dev->spec.data_alignment) { | 618 | switch (cdev->spec.data_alignment) { |
608 | case 0: | 619 | case 0: |
609 | case 2: | 620 | case 2: |
610 | fill_out_urb_mode_0(dev, urb, iso); | 621 | fill_out_urb_mode_0(cdev, urb, iso); |
611 | break; | 622 | break; |
612 | case 3: | 623 | case 3: |
613 | fill_out_urb_mode_3(dev, urb, iso); | 624 | fill_out_urb_mode_3(cdev, urb, iso); |
614 | break; | 625 | break; |
615 | } | 626 | } |
616 | } | 627 | } |
@@ -618,7 +629,8 @@ static inline void fill_out_urb(struct snd_usb_caiaqdev *dev, | |||
618 | static void read_completed(struct urb *urb) | 629 | static void read_completed(struct urb *urb) |
619 | { | 630 | { |
620 | struct snd_usb_caiaq_cb_info *info = urb->context; | 631 | struct snd_usb_caiaq_cb_info *info = urb->context; |
621 | struct snd_usb_caiaqdev *dev; | 632 | struct snd_usb_caiaqdev *cdev; |
633 | struct device *dev; | ||
622 | struct urb *out = NULL; | 634 | struct urb *out = NULL; |
623 | int i, frame, len, send_it = 0, outframe = 0; | 635 | int i, frame, len, send_it = 0, outframe = 0; |
624 | size_t offset = 0; | 636 | size_t offset = 0; |
@@ -626,20 +638,21 @@ static void read_completed(struct urb *urb) | |||
626 | if (urb->status || !info) | 638 | if (urb->status || !info) |
627 | return; | 639 | return; |
628 | 640 | ||
629 | dev = info->dev; | 641 | cdev = info->cdev; |
642 | dev = caiaqdev_to_dev(cdev); | ||
630 | 643 | ||
631 | if (!dev->streaming) | 644 | if (!cdev->streaming) |
632 | return; | 645 | return; |
633 | 646 | ||
634 | /* find an unused output urb that is unused */ | 647 | /* find an unused output urb that is unused */ |
635 | for (i = 0; i < N_URBS; i++) | 648 | for (i = 0; i < N_URBS; i++) |
636 | if (test_and_set_bit(i, &dev->outurb_active_mask) == 0) { | 649 | if (test_and_set_bit(i, &cdev->outurb_active_mask) == 0) { |
637 | out = dev->data_urbs_out[i]; | 650 | out = cdev->data_urbs_out[i]; |
638 | break; | 651 | break; |
639 | } | 652 | } |
640 | 653 | ||
641 | if (!out) { | 654 | if (!out) { |
642 | log("Unable to find an output urb to use\n"); | 655 | dev_err(dev, "Unable to find an output urb to use\n"); |
643 | goto requeue; | 656 | goto requeue; |
644 | } | 657 | } |
645 | 658 | ||
@@ -656,12 +669,12 @@ static void read_completed(struct urb *urb) | |||
656 | offset += len; | 669 | offset += len; |
657 | 670 | ||
658 | if (len > 0) { | 671 | if (len > 0) { |
659 | spin_lock(&dev->spinlock); | 672 | spin_lock(&cdev->spinlock); |
660 | fill_out_urb(dev, out, &out->iso_frame_desc[outframe]); | 673 | fill_out_urb(cdev, out, &out->iso_frame_desc[outframe]); |
661 | read_in_urb(dev, urb, &urb->iso_frame_desc[frame]); | 674 | read_in_urb(cdev, urb, &urb->iso_frame_desc[frame]); |
662 | spin_unlock(&dev->spinlock); | 675 | spin_unlock(&cdev->spinlock); |
663 | check_for_elapsed_periods(dev, dev->sub_playback); | 676 | check_for_elapsed_periods(cdev, cdev->sub_playback); |
664 | check_for_elapsed_periods(dev, dev->sub_capture); | 677 | check_for_elapsed_periods(cdev, cdev->sub_capture); |
665 | send_it = 1; | 678 | send_it = 1; |
666 | } | 679 | } |
667 | 680 | ||
@@ -674,7 +687,7 @@ static void read_completed(struct urb *urb) | |||
674 | usb_submit_urb(out, GFP_ATOMIC); | 687 | usb_submit_urb(out, GFP_ATOMIC); |
675 | } else { | 688 | } else { |
676 | struct snd_usb_caiaq_cb_info *oinfo = out->context; | 689 | struct snd_usb_caiaq_cb_info *oinfo = out->context; |
677 | clear_bit(oinfo->index, &dev->outurb_active_mask); | 690 | clear_bit(oinfo->index, &cdev->outurb_active_mask); |
678 | } | 691 | } |
679 | 692 | ||
680 | requeue: | 693 | requeue: |
@@ -693,21 +706,22 @@ requeue: | |||
693 | static void write_completed(struct urb *urb) | 706 | static void write_completed(struct urb *urb) |
694 | { | 707 | { |
695 | struct snd_usb_caiaq_cb_info *info = urb->context; | 708 | struct snd_usb_caiaq_cb_info *info = urb->context; |
696 | struct snd_usb_caiaqdev *dev = info->dev; | 709 | struct snd_usb_caiaqdev *cdev = info->cdev; |
697 | 710 | ||
698 | if (!dev->output_running) { | 711 | if (!cdev->output_running) { |
699 | dev->output_running = 1; | 712 | cdev->output_running = 1; |
700 | wake_up(&dev->prepare_wait_queue); | 713 | wake_up(&cdev->prepare_wait_queue); |
701 | } | 714 | } |
702 | 715 | ||
703 | clear_bit(info->index, &dev->outurb_active_mask); | 716 | clear_bit(info->index, &cdev->outurb_active_mask); |
704 | } | 717 | } |
705 | 718 | ||
706 | static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | 719 | static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret) |
707 | { | 720 | { |
708 | int i, frame; | 721 | int i, frame; |
709 | struct urb **urbs; | 722 | struct urb **urbs; |
710 | struct usb_device *usb_dev = dev->chip.dev; | 723 | struct usb_device *usb_dev = cdev->chip.dev; |
724 | struct device *dev = caiaqdev_to_dev(cdev); | ||
711 | unsigned int pipe; | 725 | unsigned int pipe; |
712 | 726 | ||
713 | pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? | 727 | pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? |
@@ -716,7 +730,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
716 | 730 | ||
717 | urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL); | 731 | urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL); |
718 | if (!urbs) { | 732 | if (!urbs) { |
719 | log("unable to kmalloc() urbs, OOM!?\n"); | 733 | dev_err(dev, "unable to kmalloc() urbs, OOM!?\n"); |
720 | *ret = -ENOMEM; | 734 | *ret = -ENOMEM; |
721 | return NULL; | 735 | return NULL; |
722 | } | 736 | } |
@@ -724,7 +738,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
724 | for (i = 0; i < N_URBS; i++) { | 738 | for (i = 0; i < N_URBS; i++) { |
725 | urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL); | 739 | urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL); |
726 | if (!urbs[i]) { | 740 | if (!urbs[i]) { |
727 | log("unable to usb_alloc_urb(), OOM!?\n"); | 741 | dev_err(dev, "unable to usb_alloc_urb(), OOM!?\n"); |
728 | *ret = -ENOMEM; | 742 | *ret = -ENOMEM; |
729 | return urbs; | 743 | return urbs; |
730 | } | 744 | } |
@@ -732,7 +746,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
732 | urbs[i]->transfer_buffer = | 746 | urbs[i]->transfer_buffer = |
733 | kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); | 747 | kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); |
734 | if (!urbs[i]->transfer_buffer) { | 748 | if (!urbs[i]->transfer_buffer) { |
735 | log("unable to kmalloc() transfer buffer, OOM!?\n"); | 749 | dev_err(dev, "unable to kmalloc() transfer buffer, OOM!?\n"); |
736 | *ret = -ENOMEM; | 750 | *ret = -ENOMEM; |
737 | return urbs; | 751 | return urbs; |
738 | } | 752 | } |
@@ -749,7 +763,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
749 | urbs[i]->pipe = pipe; | 763 | urbs[i]->pipe = pipe; |
750 | urbs[i]->transfer_buffer_length = FRAMES_PER_URB | 764 | urbs[i]->transfer_buffer_length = FRAMES_PER_URB |
751 | * BYTES_PER_FRAME; | 765 | * BYTES_PER_FRAME; |
752 | urbs[i]->context = &dev->data_cb_info[i]; | 766 | urbs[i]->context = &cdev->data_cb_info[i]; |
753 | urbs[i]->interval = 1; | 767 | urbs[i]->interval = 1; |
754 | urbs[i]->transfer_flags = URB_ISO_ASAP; | 768 | urbs[i]->transfer_flags = URB_ISO_ASAP; |
755 | urbs[i]->number_of_packets = FRAMES_PER_URB; | 769 | urbs[i]->number_of_packets = FRAMES_PER_URB; |
@@ -780,110 +794,113 @@ static void free_urbs(struct urb **urbs) | |||
780 | kfree(urbs); | 794 | kfree(urbs); |
781 | } | 795 | } |
782 | 796 | ||
783 | int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | 797 | int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev) |
784 | { | 798 | { |
785 | int i, ret; | 799 | int i, ret; |
800 | struct device *dev = caiaqdev_to_dev(cdev); | ||
786 | 801 | ||
787 | dev->n_audio_in = max(dev->spec.num_analog_audio_in, | 802 | cdev->n_audio_in = max(cdev->spec.num_analog_audio_in, |
788 | dev->spec.num_digital_audio_in) / | 803 | cdev->spec.num_digital_audio_in) / |
789 | CHANNELS_PER_STREAM; | 804 | CHANNELS_PER_STREAM; |
790 | dev->n_audio_out = max(dev->spec.num_analog_audio_out, | 805 | cdev->n_audio_out = max(cdev->spec.num_analog_audio_out, |
791 | dev->spec.num_digital_audio_out) / | 806 | cdev->spec.num_digital_audio_out) / |
792 | CHANNELS_PER_STREAM; | 807 | CHANNELS_PER_STREAM; |
793 | dev->n_streams = max(dev->n_audio_in, dev->n_audio_out); | 808 | cdev->n_streams = max(cdev->n_audio_in, cdev->n_audio_out); |
794 | 809 | ||
795 | debug("dev->n_audio_in = %d\n", dev->n_audio_in); | 810 | dev_dbg(dev, "cdev->n_audio_in = %d\n", cdev->n_audio_in); |
796 | debug("dev->n_audio_out = %d\n", dev->n_audio_out); | 811 | dev_dbg(dev, "cdev->n_audio_out = %d\n", cdev->n_audio_out); |
797 | debug("dev->n_streams = %d\n", dev->n_streams); | 812 | dev_dbg(dev, "cdev->n_streams = %d\n", cdev->n_streams); |
798 | 813 | ||
799 | if (dev->n_streams > MAX_STREAMS) { | 814 | if (cdev->n_streams > MAX_STREAMS) { |
800 | log("unable to initialize device, too many streams.\n"); | 815 | dev_err(dev, "unable to initialize device, too many streams.\n"); |
801 | return -EINVAL; | 816 | return -EINVAL; |
802 | } | 817 | } |
803 | 818 | ||
804 | ret = snd_pcm_new(dev->chip.card, dev->product_name, 0, | 819 | ret = snd_pcm_new(cdev->chip.card, cdev->product_name, 0, |
805 | dev->n_audio_out, dev->n_audio_in, &dev->pcm); | 820 | cdev->n_audio_out, cdev->n_audio_in, &cdev->pcm); |
806 | 821 | ||
807 | if (ret < 0) { | 822 | if (ret < 0) { |
808 | log("snd_pcm_new() returned %d\n", ret); | 823 | dev_err(dev, "snd_pcm_new() returned %d\n", ret); |
809 | return ret; | 824 | return ret; |
810 | } | 825 | } |
811 | 826 | ||
812 | dev->pcm->private_data = dev; | 827 | cdev->pcm->private_data = cdev; |
813 | strlcpy(dev->pcm->name, dev->product_name, sizeof(dev->pcm->name)); | 828 | strlcpy(cdev->pcm->name, cdev->product_name, sizeof(cdev->pcm->name)); |
814 | 829 | ||
815 | memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); | 830 | memset(cdev->sub_playback, 0, sizeof(cdev->sub_playback)); |
816 | memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); | 831 | memset(cdev->sub_capture, 0, sizeof(cdev->sub_capture)); |
817 | 832 | ||
818 | memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware, | 833 | memcpy(&cdev->pcm_info, &snd_usb_caiaq_pcm_hardware, |
819 | sizeof(snd_usb_caiaq_pcm_hardware)); | 834 | sizeof(snd_usb_caiaq_pcm_hardware)); |
820 | 835 | ||
821 | /* setup samplerates */ | 836 | /* setup samplerates */ |
822 | dev->samplerates = dev->pcm_info.rates; | 837 | cdev->samplerates = cdev->pcm_info.rates; |
823 | switch (dev->chip.usb_id) { | 838 | switch (cdev->chip.usb_id) { |
824 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 839 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
825 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 840 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
826 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO): | 841 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO): |
827 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): | 842 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): |
828 | dev->samplerates |= SNDRV_PCM_RATE_192000; | 843 | cdev->samplerates |= SNDRV_PCM_RATE_192000; |
829 | /* fall thru */ | 844 | /* fall thru */ |
830 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO2DJ): | 845 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO2DJ): |
831 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): | 846 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): |
832 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 847 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
833 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORAUDIO2): | 848 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORAUDIO2): |
834 | dev->samplerates |= SNDRV_PCM_RATE_88200; | 849 | cdev->samplerates |= SNDRV_PCM_RATE_88200; |
835 | break; | 850 | break; |
836 | } | 851 | } |
837 | 852 | ||
838 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, | 853 | snd_pcm_set_ops(cdev->pcm, SNDRV_PCM_STREAM_PLAYBACK, |
839 | &snd_usb_caiaq_ops); | 854 | &snd_usb_caiaq_ops); |
840 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, | 855 | snd_pcm_set_ops(cdev->pcm, SNDRV_PCM_STREAM_CAPTURE, |
841 | &snd_usb_caiaq_ops); | 856 | &snd_usb_caiaq_ops); |
842 | 857 | ||
843 | snd_pcm_lib_preallocate_pages_for_all(dev->pcm, | 858 | snd_pcm_lib_preallocate_pages_for_all(cdev->pcm, |
844 | SNDRV_DMA_TYPE_CONTINUOUS, | 859 | SNDRV_DMA_TYPE_CONTINUOUS, |
845 | snd_dma_continuous_data(GFP_KERNEL), | 860 | snd_dma_continuous_data(GFP_KERNEL), |
846 | MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); | 861 | MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); |
847 | 862 | ||
848 | dev->data_cb_info = | 863 | cdev->data_cb_info = |
849 | kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, | 864 | kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, |
850 | GFP_KERNEL); | 865 | GFP_KERNEL); |
851 | 866 | ||
852 | if (!dev->data_cb_info) | 867 | if (!cdev->data_cb_info) |
853 | return -ENOMEM; | 868 | return -ENOMEM; |
854 | 869 | ||
855 | dev->outurb_active_mask = 0; | 870 | cdev->outurb_active_mask = 0; |
856 | BUILD_BUG_ON(N_URBS > (sizeof(dev->outurb_active_mask) * 8)); | 871 | BUILD_BUG_ON(N_URBS > (sizeof(cdev->outurb_active_mask) * 8)); |
857 | 872 | ||
858 | for (i = 0; i < N_URBS; i++) { | 873 | for (i = 0; i < N_URBS; i++) { |
859 | dev->data_cb_info[i].dev = dev; | 874 | cdev->data_cb_info[i].cdev = cdev; |
860 | dev->data_cb_info[i].index = i; | 875 | cdev->data_cb_info[i].index = i; |
861 | } | 876 | } |
862 | 877 | ||
863 | dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret); | 878 | cdev->data_urbs_in = alloc_urbs(cdev, SNDRV_PCM_STREAM_CAPTURE, &ret); |
864 | if (ret < 0) { | 879 | if (ret < 0) { |
865 | kfree(dev->data_cb_info); | 880 | kfree(cdev->data_cb_info); |
866 | free_urbs(dev->data_urbs_in); | 881 | free_urbs(cdev->data_urbs_in); |
867 | return ret; | 882 | return ret; |
868 | } | 883 | } |
869 | 884 | ||
870 | dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret); | 885 | cdev->data_urbs_out = alloc_urbs(cdev, SNDRV_PCM_STREAM_PLAYBACK, &ret); |
871 | if (ret < 0) { | 886 | if (ret < 0) { |
872 | kfree(dev->data_cb_info); | 887 | kfree(cdev->data_cb_info); |
873 | free_urbs(dev->data_urbs_in); | 888 | free_urbs(cdev->data_urbs_in); |
874 | free_urbs(dev->data_urbs_out); | 889 | free_urbs(cdev->data_urbs_out); |
875 | return ret; | 890 | return ret; |
876 | } | 891 | } |
877 | 892 | ||
878 | return 0; | 893 | return 0; |
879 | } | 894 | } |
880 | 895 | ||
881 | void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev) | 896 | void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev) |
882 | { | 897 | { |
883 | debug("%s(%p)\n", __func__, dev); | 898 | struct device *dev = caiaqdev_to_dev(cdev); |
884 | stream_stop(dev); | 899 | |
885 | free_urbs(dev->data_urbs_in); | 900 | dev_dbg(dev, "%s(%p)\n", __func__, cdev); |
886 | free_urbs(dev->data_urbs_out); | 901 | stream_stop(cdev); |
887 | kfree(dev->data_cb_info); | 902 | free_urbs(cdev->data_urbs_in); |
903 | free_urbs(cdev->data_urbs_out); | ||
904 | kfree(cdev->data_cb_info); | ||
888 | } | 905 | } |
889 | 906 | ||
diff --git a/sound/usb/caiaq/audio.h b/sound/usb/caiaq/audio.h index 8ab1f8d9529e..bdf155300a8a 100644 --- a/sound/usb/caiaq/audio.h +++ b/sound/usb/caiaq/audio.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef CAIAQ_AUDIO_H | 1 | #ifndef CAIAQ_AUDIO_H |
2 | #define CAIAQ_AUDIO_H | 2 | #define CAIAQ_AUDIO_H |
3 | 3 | ||
4 | int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev); | 4 | int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev); |
5 | void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev); | 5 | void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev); |
6 | 6 | ||
7 | #endif /* CAIAQ_AUDIO_H */ | 7 | #endif /* CAIAQ_AUDIO_H */ |
diff --git a/sound/usb/caiaq/control.c b/sound/usb/caiaq/control.c index adb8d03267a0..ae6b50f9ed56 100644 --- a/sound/usb/caiaq/control.c +++ b/sound/usb/caiaq/control.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/device.h> | ||
20 | #include <linux/init.h> | 21 | #include <linux/init.h> |
21 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
22 | #include <sound/control.h> | 23 | #include <sound/control.h> |
@@ -32,7 +33,7 @@ static int control_info(struct snd_kcontrol *kcontrol, | |||
32 | struct snd_ctl_elem_info *uinfo) | 33 | struct snd_ctl_elem_info *uinfo) |
33 | { | 34 | { |
34 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); | 35 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); |
35 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); | 36 | struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card); |
36 | int pos = kcontrol->private_value; | 37 | int pos = kcontrol->private_value; |
37 | int is_intval = pos & CNT_INTVAL; | 38 | int is_intval = pos & CNT_INTVAL; |
38 | int maxval = 63; | 39 | int maxval = 63; |
@@ -40,7 +41,7 @@ static int control_info(struct snd_kcontrol *kcontrol, | |||
40 | uinfo->count = 1; | 41 | uinfo->count = 1; |
41 | pos &= ~CNT_INTVAL; | 42 | pos &= ~CNT_INTVAL; |
42 | 43 | ||
43 | switch (dev->chip.usb_id) { | 44 | switch (cdev->chip.usb_id) { |
44 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 45 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
45 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): | 46 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): |
46 | if (pos == 0) { | 47 | if (pos == 0) { |
@@ -78,15 +79,15 @@ static int control_get(struct snd_kcontrol *kcontrol, | |||
78 | struct snd_ctl_elem_value *ucontrol) | 79 | struct snd_ctl_elem_value *ucontrol) |
79 | { | 80 | { |
80 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); | 81 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); |
81 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); | 82 | struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card); |
82 | int pos = kcontrol->private_value; | 83 | int pos = kcontrol->private_value; |
83 | 84 | ||
84 | if (pos & CNT_INTVAL) | 85 | if (pos & CNT_INTVAL) |
85 | ucontrol->value.integer.value[0] | 86 | ucontrol->value.integer.value[0] |
86 | = dev->control_state[pos & ~CNT_INTVAL]; | 87 | = cdev->control_state[pos & ~CNT_INTVAL]; |
87 | else | 88 | else |
88 | ucontrol->value.integer.value[0] | 89 | ucontrol->value.integer.value[0] |
89 | = !!(dev->control_state[pos / 8] & (1 << pos % 8)); | 90 | = !!(cdev->control_state[pos / 8] & (1 << pos % 8)); |
90 | 91 | ||
91 | return 0; | 92 | return 0; |
92 | } | 93 | } |
@@ -95,43 +96,43 @@ static int control_put(struct snd_kcontrol *kcontrol, | |||
95 | struct snd_ctl_elem_value *ucontrol) | 96 | struct snd_ctl_elem_value *ucontrol) |
96 | { | 97 | { |
97 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); | 98 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); |
98 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); | 99 | struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card); |
99 | int pos = kcontrol->private_value; | 100 | int pos = kcontrol->private_value; |
100 | int v = ucontrol->value.integer.value[0]; | 101 | int v = ucontrol->value.integer.value[0]; |
101 | unsigned char cmd = EP1_CMD_WRITE_IO; | 102 | unsigned char cmd = EP1_CMD_WRITE_IO; |
102 | 103 | ||
103 | if (dev->chip.usb_id == | 104 | if (cdev->chip.usb_id == |
104 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1)) | 105 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1)) |
105 | cmd = EP1_CMD_DIMM_LEDS; | 106 | cmd = EP1_CMD_DIMM_LEDS; |
106 | 107 | ||
107 | if (pos & CNT_INTVAL) { | 108 | if (pos & CNT_INTVAL) { |
108 | int i = pos & ~CNT_INTVAL; | 109 | int i = pos & ~CNT_INTVAL; |
109 | 110 | ||
110 | dev->control_state[i] = v; | 111 | cdev->control_state[i] = v; |
111 | 112 | ||
112 | if (dev->chip.usb_id == | 113 | if (cdev->chip.usb_id == |
113 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4)) { | 114 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4)) { |
114 | int actual_len; | 115 | int actual_len; |
115 | 116 | ||
116 | dev->ep8_out_buf[0] = i; | 117 | cdev->ep8_out_buf[0] = i; |
117 | dev->ep8_out_buf[1] = v; | 118 | cdev->ep8_out_buf[1] = v; |
118 | 119 | ||
119 | usb_bulk_msg(dev->chip.dev, | 120 | usb_bulk_msg(cdev->chip.dev, |
120 | usb_sndbulkpipe(dev->chip.dev, 8), | 121 | usb_sndbulkpipe(cdev->chip.dev, 8), |
121 | dev->ep8_out_buf, sizeof(dev->ep8_out_buf), | 122 | cdev->ep8_out_buf, sizeof(cdev->ep8_out_buf), |
122 | &actual_len, 200); | 123 | &actual_len, 200); |
123 | } else { | 124 | } else { |
124 | snd_usb_caiaq_send_command(dev, cmd, | 125 | snd_usb_caiaq_send_command(cdev, cmd, |
125 | dev->control_state, sizeof(dev->control_state)); | 126 | cdev->control_state, sizeof(cdev->control_state)); |
126 | } | 127 | } |
127 | } else { | 128 | } else { |
128 | if (v) | 129 | if (v) |
129 | dev->control_state[pos / 8] |= 1 << (pos % 8); | 130 | cdev->control_state[pos / 8] |= 1 << (pos % 8); |
130 | else | 131 | else |
131 | dev->control_state[pos / 8] &= ~(1 << (pos % 8)); | 132 | cdev->control_state[pos / 8] &= ~(1 << (pos % 8)); |
132 | 133 | ||
133 | snd_usb_caiaq_send_command(dev, cmd, | 134 | snd_usb_caiaq_send_command(cdev, cmd, |
134 | dev->control_state, sizeof(dev->control_state)); | 135 | cdev->control_state, sizeof(cdev->control_state)); |
135 | } | 136 | } |
136 | 137 | ||
137 | return 1; | 138 | return 1; |
@@ -490,7 +491,7 @@ static struct caiaq_controller kontrols4_controller[] = { | |||
490 | }; | 491 | }; |
491 | 492 | ||
492 | static int add_controls(struct caiaq_controller *c, int num, | 493 | static int add_controls(struct caiaq_controller *c, int num, |
493 | struct snd_usb_caiaqdev *dev) | 494 | struct snd_usb_caiaqdev *cdev) |
494 | { | 495 | { |
495 | int i, ret; | 496 | int i, ret; |
496 | struct snd_kcontrol *kc; | 497 | struct snd_kcontrol *kc; |
@@ -498,8 +499,8 @@ static int add_controls(struct caiaq_controller *c, int num, | |||
498 | for (i = 0; i < num; i++, c++) { | 499 | for (i = 0; i < num; i++, c++) { |
499 | kcontrol_template.name = c->name; | 500 | kcontrol_template.name = c->name; |
500 | kcontrol_template.private_value = c->index; | 501 | kcontrol_template.private_value = c->index; |
501 | kc = snd_ctl_new1(&kcontrol_template, dev); | 502 | kc = snd_ctl_new1(&kcontrol_template, cdev); |
502 | ret = snd_ctl_add(dev->chip.card, kc); | 503 | ret = snd_ctl_add(cdev->chip.card, kc); |
503 | if (ret < 0) | 504 | if (ret < 0) |
504 | return ret; | 505 | return ret; |
505 | } | 506 | } |
@@ -507,50 +508,50 @@ static int add_controls(struct caiaq_controller *c, int num, | |||
507 | return 0; | 508 | return 0; |
508 | } | 509 | } |
509 | 510 | ||
510 | int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev) | 511 | int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev) |
511 | { | 512 | { |
512 | int ret = 0; | 513 | int ret = 0; |
513 | 514 | ||
514 | switch (dev->chip.usb_id) { | 515 | switch (cdev->chip.usb_id) { |
515 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 516 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
516 | ret = add_controls(ak1_controller, | 517 | ret = add_controls(ak1_controller, |
517 | ARRAY_SIZE(ak1_controller), dev); | 518 | ARRAY_SIZE(ak1_controller), cdev); |
518 | break; | 519 | break; |
519 | 520 | ||
520 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 521 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
521 | ret = add_controls(rk2_controller, | 522 | ret = add_controls(rk2_controller, |
522 | ARRAY_SIZE(rk2_controller), dev); | 523 | ARRAY_SIZE(rk2_controller), cdev); |
523 | break; | 524 | break; |
524 | 525 | ||
525 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 526 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
526 | ret = add_controls(rk3_controller, | 527 | ret = add_controls(rk3_controller, |
527 | ARRAY_SIZE(rk3_controller), dev); | 528 | ARRAY_SIZE(rk3_controller), cdev); |
528 | break; | 529 | break; |
529 | 530 | ||
530 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | 531 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): |
531 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): | 532 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): |
532 | ret = add_controls(kore_controller, | 533 | ret = add_controls(kore_controller, |
533 | ARRAY_SIZE(kore_controller), dev); | 534 | ARRAY_SIZE(kore_controller), cdev); |
534 | break; | 535 | break; |
535 | 536 | ||
536 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 537 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
537 | ret = add_controls(a8dj_controller, | 538 | ret = add_controls(a8dj_controller, |
538 | ARRAY_SIZE(a8dj_controller), dev); | 539 | ARRAY_SIZE(a8dj_controller), cdev); |
539 | break; | 540 | break; |
540 | 541 | ||
541 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): | 542 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): |
542 | ret = add_controls(a4dj_controller, | 543 | ret = add_controls(a4dj_controller, |
543 | ARRAY_SIZE(a4dj_controller), dev); | 544 | ARRAY_SIZE(a4dj_controller), cdev); |
544 | break; | 545 | break; |
545 | 546 | ||
546 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 547 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
547 | ret = add_controls(kontrolx1_controller, | 548 | ret = add_controls(kontrolx1_controller, |
548 | ARRAY_SIZE(kontrolx1_controller), dev); | 549 | ARRAY_SIZE(kontrolx1_controller), cdev); |
549 | break; | 550 | break; |
550 | 551 | ||
551 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): | 552 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): |
552 | ret = add_controls(kontrols4_controller, | 553 | ret = add_controls(kontrols4_controller, |
553 | ARRAY_SIZE(kontrols4_controller), dev); | 554 | ARRAY_SIZE(kontrols4_controller), cdev); |
554 | break; | 555 | break; |
555 | } | 556 | } |
556 | 557 | ||
diff --git a/sound/usb/caiaq/control.h b/sound/usb/caiaq/control.h index 2e7ab1aa4fb3..501c4883aef6 100644 --- a/sound/usb/caiaq/control.h +++ b/sound/usb/caiaq/control.h | |||
@@ -1,6 +1,6 @@ | |||
1 | #ifndef CAIAQ_CONTROL_H | 1 | #ifndef CAIAQ_CONTROL_H |
2 | #define CAIAQ_CONTROL_H | 2 | #define CAIAQ_CONTROL_H |
3 | 3 | ||
4 | int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev); | 4 | int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev); |
5 | 5 | ||
6 | #endif /* CAIAQ_CONTROL_H */ | 6 | #endif /* CAIAQ_CONTROL_H */ |
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index e4d6dbb0342d..48b63ccc78c7 100644 --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c | |||
@@ -20,6 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/moduleparam.h> | 22 | #include <linux/moduleparam.h> |
23 | #include <linux/device.h> | ||
23 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | #include <linux/init.h> | 26 | #include <linux/init.h> |
@@ -158,67 +159,68 @@ static struct usb_device_id snd_usb_id_table[] = { | |||
158 | static void usb_ep1_command_reply_dispatch (struct urb* urb) | 159 | static void usb_ep1_command_reply_dispatch (struct urb* urb) |
159 | { | 160 | { |
160 | int ret; | 161 | int ret; |
161 | struct snd_usb_caiaqdev *dev = urb->context; | 162 | struct device *dev = &urb->dev->dev; |
163 | struct snd_usb_caiaqdev *cdev = urb->context; | ||
162 | unsigned char *buf = urb->transfer_buffer; | 164 | unsigned char *buf = urb->transfer_buffer; |
163 | 165 | ||
164 | if (urb->status || !dev) { | 166 | if (urb->status || !cdev) { |
165 | log("received EP1 urb->status = %i\n", urb->status); | 167 | dev_warn(dev, "received EP1 urb->status = %i\n", urb->status); |
166 | return; | 168 | return; |
167 | } | 169 | } |
168 | 170 | ||
169 | switch(buf[0]) { | 171 | switch(buf[0]) { |
170 | case EP1_CMD_GET_DEVICE_INFO: | 172 | case EP1_CMD_GET_DEVICE_INFO: |
171 | memcpy(&dev->spec, buf+1, sizeof(struct caiaq_device_spec)); | 173 | memcpy(&cdev->spec, buf+1, sizeof(struct caiaq_device_spec)); |
172 | dev->spec.fw_version = le16_to_cpu(dev->spec.fw_version); | 174 | cdev->spec.fw_version = le16_to_cpu(cdev->spec.fw_version); |
173 | debug("device spec (firmware %d): audio: %d in, %d out, " | 175 | dev_dbg(dev, "device spec (firmware %d): audio: %d in, %d out, " |
174 | "MIDI: %d in, %d out, data alignment %d\n", | 176 | "MIDI: %d in, %d out, data alignment %d\n", |
175 | dev->spec.fw_version, | 177 | cdev->spec.fw_version, |
176 | dev->spec.num_analog_audio_in, | 178 | cdev->spec.num_analog_audio_in, |
177 | dev->spec.num_analog_audio_out, | 179 | cdev->spec.num_analog_audio_out, |
178 | dev->spec.num_midi_in, | 180 | cdev->spec.num_midi_in, |
179 | dev->spec.num_midi_out, | 181 | cdev->spec.num_midi_out, |
180 | dev->spec.data_alignment); | 182 | cdev->spec.data_alignment); |
181 | 183 | ||
182 | dev->spec_received++; | 184 | cdev->spec_received++; |
183 | wake_up(&dev->ep1_wait_queue); | 185 | wake_up(&cdev->ep1_wait_queue); |
184 | break; | 186 | break; |
185 | case EP1_CMD_AUDIO_PARAMS: | 187 | case EP1_CMD_AUDIO_PARAMS: |
186 | dev->audio_parm_answer = buf[1]; | 188 | cdev->audio_parm_answer = buf[1]; |
187 | wake_up(&dev->ep1_wait_queue); | 189 | wake_up(&cdev->ep1_wait_queue); |
188 | break; | 190 | break; |
189 | case EP1_CMD_MIDI_READ: | 191 | case EP1_CMD_MIDI_READ: |
190 | snd_usb_caiaq_midi_handle_input(dev, buf[1], buf + 3, buf[2]); | 192 | snd_usb_caiaq_midi_handle_input(cdev, buf[1], buf + 3, buf[2]); |
191 | break; | 193 | break; |
192 | case EP1_CMD_READ_IO: | 194 | case EP1_CMD_READ_IO: |
193 | if (dev->chip.usb_id == | 195 | if (cdev->chip.usb_id == |
194 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) { | 196 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) { |
195 | if (urb->actual_length > sizeof(dev->control_state)) | 197 | if (urb->actual_length > sizeof(cdev->control_state)) |
196 | urb->actual_length = sizeof(dev->control_state); | 198 | urb->actual_length = sizeof(cdev->control_state); |
197 | memcpy(dev->control_state, buf + 1, urb->actual_length); | 199 | memcpy(cdev->control_state, buf + 1, urb->actual_length); |
198 | wake_up(&dev->ep1_wait_queue); | 200 | wake_up(&cdev->ep1_wait_queue); |
199 | break; | 201 | break; |
200 | } | 202 | } |
201 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT | 203 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT |
202 | case EP1_CMD_READ_ERP: | 204 | case EP1_CMD_READ_ERP: |
203 | case EP1_CMD_READ_ANALOG: | 205 | case EP1_CMD_READ_ANALOG: |
204 | snd_usb_caiaq_input_dispatch(dev, buf, urb->actual_length); | 206 | snd_usb_caiaq_input_dispatch(cdev, buf, urb->actual_length); |
205 | #endif | 207 | #endif |
206 | break; | 208 | break; |
207 | } | 209 | } |
208 | 210 | ||
209 | dev->ep1_in_urb.actual_length = 0; | 211 | cdev->ep1_in_urb.actual_length = 0; |
210 | ret = usb_submit_urb(&dev->ep1_in_urb, GFP_ATOMIC); | 212 | ret = usb_submit_urb(&cdev->ep1_in_urb, GFP_ATOMIC); |
211 | if (ret < 0) | 213 | if (ret < 0) |
212 | log("unable to submit urb. OOM!?\n"); | 214 | dev_err(dev, "unable to submit urb. OOM!?\n"); |
213 | } | 215 | } |
214 | 216 | ||
215 | int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, | 217 | int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, |
216 | unsigned char command, | 218 | unsigned char command, |
217 | const unsigned char *buffer, | 219 | const unsigned char *buffer, |
218 | int len) | 220 | int len) |
219 | { | 221 | { |
220 | int actual_len; | 222 | int actual_len; |
221 | struct usb_device *usb_dev = dev->chip.dev; | 223 | struct usb_device *usb_dev = cdev->chip.dev; |
222 | 224 | ||
223 | if (!usb_dev) | 225 | if (!usb_dev) |
224 | return -EIO; | 226 | return -EIO; |
@@ -227,18 +229,19 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, | |||
227 | len = EP1_BUFSIZE - 1; | 229 | len = EP1_BUFSIZE - 1; |
228 | 230 | ||
229 | if (buffer && len > 0) | 231 | if (buffer && len > 0) |
230 | memcpy(dev->ep1_out_buf+1, buffer, len); | 232 | memcpy(cdev->ep1_out_buf+1, buffer, len); |
231 | 233 | ||
232 | dev->ep1_out_buf[0] = command; | 234 | cdev->ep1_out_buf[0] = command; |
233 | return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), | 235 | return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), |
234 | dev->ep1_out_buf, len+1, &actual_len, 200); | 236 | cdev->ep1_out_buf, len+1, &actual_len, 200); |
235 | } | 237 | } |
236 | 238 | ||
237 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | 239 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, |
238 | int rate, int depth, int bpp) | 240 | int rate, int depth, int bpp) |
239 | { | 241 | { |
240 | int ret; | 242 | int ret; |
241 | char tmp[5]; | 243 | char tmp[5]; |
244 | struct device *dev = caiaqdev_to_dev(cdev); | ||
242 | 245 | ||
243 | switch (rate) { | 246 | switch (rate) { |
244 | case 44100: tmp[0] = SAMPLERATE_44100; break; | 247 | case 44100: tmp[0] = SAMPLERATE_44100; break; |
@@ -259,49 +262,50 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | |||
259 | tmp[3] = bpp >> 8; | 262 | tmp[3] = bpp >> 8; |
260 | tmp[4] = 1; /* packets per microframe */ | 263 | tmp[4] = 1; /* packets per microframe */ |
261 | 264 | ||
262 | debug("setting audio params: %d Hz, %d bits, %d bpp\n", | 265 | dev_dbg(dev, "setting audio params: %d Hz, %d bits, %d bpp\n", |
263 | rate, depth, bpp); | 266 | rate, depth, bpp); |
264 | 267 | ||
265 | dev->audio_parm_answer = -1; | 268 | cdev->audio_parm_answer = -1; |
266 | ret = snd_usb_caiaq_send_command(dev, EP1_CMD_AUDIO_PARAMS, | 269 | ret = snd_usb_caiaq_send_command(cdev, EP1_CMD_AUDIO_PARAMS, |
267 | tmp, sizeof(tmp)); | 270 | tmp, sizeof(tmp)); |
268 | 271 | ||
269 | if (ret) | 272 | if (ret) |
270 | return ret; | 273 | return ret; |
271 | 274 | ||
272 | if (!wait_event_timeout(dev->ep1_wait_queue, | 275 | if (!wait_event_timeout(cdev->ep1_wait_queue, |
273 | dev->audio_parm_answer >= 0, HZ)) | 276 | cdev->audio_parm_answer >= 0, HZ)) |
274 | return -EPIPE; | 277 | return -EPIPE; |
275 | 278 | ||
276 | if (dev->audio_parm_answer != 1) | 279 | if (cdev->audio_parm_answer != 1) |
277 | debug("unable to set the device's audio params\n"); | 280 | dev_dbg(dev, "unable to set the device's audio params\n"); |
278 | else | 281 | else |
279 | dev->bpp = bpp; | 282 | cdev->bpp = bpp; |
280 | 283 | ||
281 | return dev->audio_parm_answer == 1 ? 0 : -EINVAL; | 284 | return cdev->audio_parm_answer == 1 ? 0 : -EINVAL; |
282 | } | 285 | } |
283 | 286 | ||
284 | int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *dev, | 287 | int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *cdev, |
285 | int digital, int analog, int erp) | 288 | int digital, int analog, int erp) |
286 | { | 289 | { |
287 | char tmp[3] = { digital, analog, erp }; | 290 | char tmp[3] = { digital, analog, erp }; |
288 | return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, | 291 | return snd_usb_caiaq_send_command(cdev, EP1_CMD_AUTO_MSG, |
289 | tmp, sizeof(tmp)); | 292 | tmp, sizeof(tmp)); |
290 | } | 293 | } |
291 | 294 | ||
292 | static void setup_card(struct snd_usb_caiaqdev *dev) | 295 | static void setup_card(struct snd_usb_caiaqdev *cdev) |
293 | { | 296 | { |
294 | int ret; | 297 | int ret; |
295 | char val[4]; | 298 | char val[4]; |
299 | struct device *dev = caiaqdev_to_dev(cdev); | ||
296 | 300 | ||
297 | /* device-specific startup specials */ | 301 | /* device-specific startup specials */ |
298 | switch (dev->chip.usb_id) { | 302 | switch (cdev->chip.usb_id) { |
299 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 303 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
300 | /* RigKontrol2 - display centered dash ('-') */ | 304 | /* RigKontrol2 - display centered dash ('-') */ |
301 | val[0] = 0x00; | 305 | val[0] = 0x00; |
302 | val[1] = 0x00; | 306 | val[1] = 0x00; |
303 | val[2] = 0x01; | 307 | val[2] = 0x01; |
304 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 3); | 308 | snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 3); |
305 | break; | 309 | break; |
306 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 310 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
307 | /* RigKontrol2 - display two centered dashes ('--') */ | 311 | /* RigKontrol2 - display two centered dashes ('--') */ |
@@ -309,69 +313,69 @@ static void setup_card(struct snd_usb_caiaqdev *dev) | |||
309 | val[1] = 0x40; | 313 | val[1] = 0x40; |
310 | val[2] = 0x40; | 314 | val[2] = 0x40; |
311 | val[3] = 0x00; | 315 | val[3] = 0x00; |
312 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 4); | 316 | snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 4); |
313 | break; | 317 | break; |
314 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 318 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
315 | /* Audio Kontrol 1 - make USB-LED stop blinking */ | 319 | /* Audio Kontrol 1 - make USB-LED stop blinking */ |
316 | val[0] = 0x00; | 320 | val[0] = 0x00; |
317 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 1); | 321 | snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 1); |
318 | break; | 322 | break; |
319 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 323 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
320 | /* Audio 8 DJ - trigger read of current settings */ | 324 | /* Audio 8 DJ - trigger read of current settings */ |
321 | dev->control_state[0] = 0xff; | 325 | cdev->control_state[0] = 0xff; |
322 | snd_usb_caiaq_set_auto_msg(dev, 1, 0, 0); | 326 | snd_usb_caiaq_set_auto_msg(cdev, 1, 0, 0); |
323 | snd_usb_caiaq_send_command(dev, EP1_CMD_READ_IO, NULL, 0); | 327 | snd_usb_caiaq_send_command(cdev, EP1_CMD_READ_IO, NULL, 0); |
324 | 328 | ||
325 | if (!wait_event_timeout(dev->ep1_wait_queue, | 329 | if (!wait_event_timeout(cdev->ep1_wait_queue, |
326 | dev->control_state[0] != 0xff, HZ)) | 330 | cdev->control_state[0] != 0xff, HZ)) |
327 | return; | 331 | return; |
328 | 332 | ||
329 | /* fix up some defaults */ | 333 | /* fix up some defaults */ |
330 | if ((dev->control_state[1] != 2) || | 334 | if ((cdev->control_state[1] != 2) || |
331 | (dev->control_state[2] != 3) || | 335 | (cdev->control_state[2] != 3) || |
332 | (dev->control_state[4] != 2)) { | 336 | (cdev->control_state[4] != 2)) { |
333 | dev->control_state[1] = 2; | 337 | cdev->control_state[1] = 2; |
334 | dev->control_state[2] = 3; | 338 | cdev->control_state[2] = 3; |
335 | dev->control_state[4] = 2; | 339 | cdev->control_state[4] = 2; |
336 | snd_usb_caiaq_send_command(dev, | 340 | snd_usb_caiaq_send_command(cdev, |
337 | EP1_CMD_WRITE_IO, dev->control_state, 6); | 341 | EP1_CMD_WRITE_IO, cdev->control_state, 6); |
338 | } | 342 | } |
339 | 343 | ||
340 | break; | 344 | break; |
341 | } | 345 | } |
342 | 346 | ||
343 | if (dev->spec.num_analog_audio_out + | 347 | if (cdev->spec.num_analog_audio_out + |
344 | dev->spec.num_analog_audio_in + | 348 | cdev->spec.num_analog_audio_in + |
345 | dev->spec.num_digital_audio_out + | 349 | cdev->spec.num_digital_audio_out + |
346 | dev->spec.num_digital_audio_in > 0) { | 350 | cdev->spec.num_digital_audio_in > 0) { |
347 | ret = snd_usb_caiaq_audio_init(dev); | 351 | ret = snd_usb_caiaq_audio_init(cdev); |
348 | if (ret < 0) | 352 | if (ret < 0) |
349 | log("Unable to set up audio system (ret=%d)\n", ret); | 353 | dev_err(dev, "Unable to set up audio system (ret=%d)\n", ret); |
350 | } | 354 | } |
351 | 355 | ||
352 | if (dev->spec.num_midi_in + | 356 | if (cdev->spec.num_midi_in + |
353 | dev->spec.num_midi_out > 0) { | 357 | cdev->spec.num_midi_out > 0) { |
354 | ret = snd_usb_caiaq_midi_init(dev); | 358 | ret = snd_usb_caiaq_midi_init(cdev); |
355 | if (ret < 0) | 359 | if (ret < 0) |
356 | log("Unable to set up MIDI system (ret=%d)\n", ret); | 360 | dev_err(dev, "Unable to set up MIDI system (ret=%d)\n", ret); |
357 | } | 361 | } |
358 | 362 | ||
359 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT | 363 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT |
360 | ret = snd_usb_caiaq_input_init(dev); | 364 | ret = snd_usb_caiaq_input_init(cdev); |
361 | if (ret < 0) | 365 | if (ret < 0) |
362 | log("Unable to set up input system (ret=%d)\n", ret); | 366 | dev_err(dev, "Unable to set up input system (ret=%d)\n", ret); |
363 | #endif | 367 | #endif |
364 | 368 | ||
365 | /* finally, register the card and all its sub-instances */ | 369 | /* finally, register the card and all its sub-instances */ |
366 | ret = snd_card_register(dev->chip.card); | 370 | ret = snd_card_register(cdev->chip.card); |
367 | if (ret < 0) { | 371 | if (ret < 0) { |
368 | log("snd_card_register() returned %d\n", ret); | 372 | dev_err(dev, "snd_card_register() returned %d\n", ret); |
369 | snd_card_free(dev->chip.card); | 373 | snd_card_free(cdev->chip.card); |
370 | } | 374 | } |
371 | 375 | ||
372 | ret = snd_usb_caiaq_control_init(dev); | 376 | ret = snd_usb_caiaq_control_init(cdev); |
373 | if (ret < 0) | 377 | if (ret < 0) |
374 | log("Unable to set up control system (ret=%d)\n", ret); | 378 | dev_err(dev, "Unable to set up control system (ret=%d)\n", ret); |
375 | } | 379 | } |
376 | 380 | ||
377 | static int create_card(struct usb_device *usb_dev, | 381 | static int create_card(struct usb_device *usb_dev, |
@@ -381,7 +385,7 @@ static int create_card(struct usb_device *usb_dev, | |||
381 | int devnum; | 385 | int devnum; |
382 | int err; | 386 | int err; |
383 | struct snd_card *card; | 387 | struct snd_card *card; |
384 | struct snd_usb_caiaqdev *dev; | 388 | struct snd_usb_caiaqdev *cdev; |
385 | 389 | ||
386 | for (devnum = 0; devnum < SNDRV_CARDS; devnum++) | 390 | for (devnum = 0; devnum < SNDRV_CARDS; devnum++) |
387 | if (enable[devnum] && !snd_card_used[devnum]) | 391 | if (enable[devnum] && !snd_card_used[devnum]) |
@@ -395,65 +399,66 @@ static int create_card(struct usb_device *usb_dev, | |||
395 | if (err < 0) | 399 | if (err < 0) |
396 | return err; | 400 | return err; |
397 | 401 | ||
398 | dev = caiaqdev(card); | 402 | cdev = caiaqdev(card); |
399 | dev->chip.dev = usb_dev; | 403 | cdev->chip.dev = usb_dev; |
400 | dev->chip.card = card; | 404 | cdev->chip.card = card; |
401 | dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), | 405 | cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), |
402 | le16_to_cpu(usb_dev->descriptor.idProduct)); | 406 | le16_to_cpu(usb_dev->descriptor.idProduct)); |
403 | spin_lock_init(&dev->spinlock); | 407 | spin_lock_init(&cdev->spinlock); |
404 | snd_card_set_dev(card, &intf->dev); | 408 | snd_card_set_dev(card, &intf->dev); |
405 | 409 | ||
406 | *cardp = card; | 410 | *cardp = card; |
407 | return 0; | 411 | return 0; |
408 | } | 412 | } |
409 | 413 | ||
410 | static int init_card(struct snd_usb_caiaqdev *dev) | 414 | static int init_card(struct snd_usb_caiaqdev *cdev) |
411 | { | 415 | { |
412 | char *c, usbpath[32]; | 416 | char *c, usbpath[32]; |
413 | struct usb_device *usb_dev = dev->chip.dev; | 417 | struct usb_device *usb_dev = cdev->chip.dev; |
414 | struct snd_card *card = dev->chip.card; | 418 | struct snd_card *card = cdev->chip.card; |
419 | struct device *dev = caiaqdev_to_dev(cdev); | ||
415 | int err, len; | 420 | int err, len; |
416 | 421 | ||
417 | if (usb_set_interface(usb_dev, 0, 1) != 0) { | 422 | if (usb_set_interface(usb_dev, 0, 1) != 0) { |
418 | log("can't set alt interface.\n"); | 423 | dev_err(dev, "can't set alt interface.\n"); |
419 | return -EIO; | 424 | return -EIO; |
420 | } | 425 | } |
421 | 426 | ||
422 | usb_init_urb(&dev->ep1_in_urb); | 427 | usb_init_urb(&cdev->ep1_in_urb); |
423 | usb_init_urb(&dev->midi_out_urb); | 428 | usb_init_urb(&cdev->midi_out_urb); |
424 | 429 | ||
425 | usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, | 430 | usb_fill_bulk_urb(&cdev->ep1_in_urb, usb_dev, |
426 | usb_rcvbulkpipe(usb_dev, 0x1), | 431 | usb_rcvbulkpipe(usb_dev, 0x1), |
427 | dev->ep1_in_buf, EP1_BUFSIZE, | 432 | cdev->ep1_in_buf, EP1_BUFSIZE, |
428 | usb_ep1_command_reply_dispatch, dev); | 433 | usb_ep1_command_reply_dispatch, cdev); |
429 | 434 | ||
430 | usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, | 435 | usb_fill_bulk_urb(&cdev->midi_out_urb, usb_dev, |
431 | usb_sndbulkpipe(usb_dev, 0x1), | 436 | usb_sndbulkpipe(usb_dev, 0x1), |
432 | dev->midi_out_buf, EP1_BUFSIZE, | 437 | cdev->midi_out_buf, EP1_BUFSIZE, |
433 | snd_usb_caiaq_midi_output_done, dev); | 438 | snd_usb_caiaq_midi_output_done, cdev); |
434 | 439 | ||
435 | init_waitqueue_head(&dev->ep1_wait_queue); | 440 | init_waitqueue_head(&cdev->ep1_wait_queue); |
436 | init_waitqueue_head(&dev->prepare_wait_queue); | 441 | init_waitqueue_head(&cdev->prepare_wait_queue); |
437 | 442 | ||
438 | if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) | 443 | if (usb_submit_urb(&cdev->ep1_in_urb, GFP_KERNEL) != 0) |
439 | return -EIO; | 444 | return -EIO; |
440 | 445 | ||
441 | err = snd_usb_caiaq_send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); | 446 | err = snd_usb_caiaq_send_command(cdev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); |
442 | if (err) | 447 | if (err) |
443 | return err; | 448 | return err; |
444 | 449 | ||
445 | if (!wait_event_timeout(dev->ep1_wait_queue, dev->spec_received, HZ)) | 450 | if (!wait_event_timeout(cdev->ep1_wait_queue, cdev->spec_received, HZ)) |
446 | return -ENODEV; | 451 | return -ENODEV; |
447 | 452 | ||
448 | usb_string(usb_dev, usb_dev->descriptor.iManufacturer, | 453 | usb_string(usb_dev, usb_dev->descriptor.iManufacturer, |
449 | dev->vendor_name, CAIAQ_USB_STR_LEN); | 454 | cdev->vendor_name, CAIAQ_USB_STR_LEN); |
450 | 455 | ||
451 | usb_string(usb_dev, usb_dev->descriptor.iProduct, | 456 | usb_string(usb_dev, usb_dev->descriptor.iProduct, |
452 | dev->product_name, CAIAQ_USB_STR_LEN); | 457 | cdev->product_name, CAIAQ_USB_STR_LEN); |
453 | 458 | ||
454 | strlcpy(card->driver, MODNAME, sizeof(card->driver)); | 459 | strlcpy(card->driver, MODNAME, sizeof(card->driver)); |
455 | strlcpy(card->shortname, dev->product_name, sizeof(card->shortname)); | 460 | strlcpy(card->shortname, cdev->product_name, sizeof(card->shortname)); |
456 | strlcpy(card->mixername, dev->product_name, sizeof(card->mixername)); | 461 | strlcpy(card->mixername, cdev->product_name, sizeof(card->mixername)); |
457 | 462 | ||
458 | /* if the id was not passed as module option, fill it with a shortened | 463 | /* if the id was not passed as module option, fill it with a shortened |
459 | * version of the product string which does not contain any | 464 | * version of the product string which does not contain any |
@@ -473,11 +478,10 @@ static int init_card(struct snd_usb_caiaqdev *dev) | |||
473 | } | 478 | } |
474 | 479 | ||
475 | usb_make_path(usb_dev, usbpath, sizeof(usbpath)); | 480 | usb_make_path(usb_dev, usbpath, sizeof(usbpath)); |
476 | snprintf(card->longname, sizeof(card->longname), | 481 | snprintf(card->longname, sizeof(card->longname), "%s %s (%s)", |
477 | "%s %s (%s)", | 482 | cdev->vendor_name, cdev->product_name, usbpath); |
478 | dev->vendor_name, dev->product_name, usbpath); | ||
479 | 483 | ||
480 | setup_card(dev); | 484 | setup_card(cdev); |
481 | return 0; | 485 | return 0; |
482 | } | 486 | } |
483 | 487 | ||
@@ -486,9 +490,9 @@ static int snd_probe(struct usb_interface *intf, | |||
486 | { | 490 | { |
487 | int ret; | 491 | int ret; |
488 | struct snd_card *card = NULL; | 492 | struct snd_card *card = NULL; |
489 | struct usb_device *device = interface_to_usbdev(intf); | 493 | struct usb_device *usb_dev = interface_to_usbdev(intf); |
490 | 494 | ||
491 | ret = create_card(device, intf, &card); | 495 | ret = create_card(usb_dev, intf, &card); |
492 | 496 | ||
493 | if (ret < 0) | 497 | if (ret < 0) |
494 | return ret; | 498 | return ret; |
@@ -496,7 +500,7 @@ static int snd_probe(struct usb_interface *intf, | |||
496 | usb_set_intfdata(intf, card); | 500 | usb_set_intfdata(intf, card); |
497 | ret = init_card(caiaqdev(card)); | 501 | ret = init_card(caiaqdev(card)); |
498 | if (ret < 0) { | 502 | if (ret < 0) { |
499 | log("unable to init card! (ret=%d)\n", ret); | 503 | dev_err(&usb_dev->dev, "unable to init card! (ret=%d)\n", ret); |
500 | snd_card_free(card); | 504 | snd_card_free(card); |
501 | return ret; | 505 | return ret; |
502 | } | 506 | } |
@@ -506,24 +510,25 @@ static int snd_probe(struct usb_interface *intf, | |||
506 | 510 | ||
507 | static void snd_disconnect(struct usb_interface *intf) | 511 | static void snd_disconnect(struct usb_interface *intf) |
508 | { | 512 | { |
509 | struct snd_usb_caiaqdev *dev; | ||
510 | struct snd_card *card = usb_get_intfdata(intf); | 513 | struct snd_card *card = usb_get_intfdata(intf); |
511 | 514 | struct device *dev = intf->usb_dev; | |
512 | debug("%s(%p)\n", __func__, intf); | 515 | struct snd_usb_caiaqdev *cdev; |
513 | 516 | ||
514 | if (!card) | 517 | if (!card) |
515 | return; | 518 | return; |
516 | 519 | ||
517 | dev = caiaqdev(card); | 520 | cdev = caiaqdev(card); |
521 | dev_dbg(dev, "%s(%p)\n", __func__, intf); | ||
522 | |||
518 | snd_card_disconnect(card); | 523 | snd_card_disconnect(card); |
519 | 524 | ||
520 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT | 525 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT |
521 | snd_usb_caiaq_input_free(dev); | 526 | snd_usb_caiaq_input_free(cdev); |
522 | #endif | 527 | #endif |
523 | snd_usb_caiaq_audio_free(dev); | 528 | snd_usb_caiaq_audio_free(cdev); |
524 | 529 | ||
525 | usb_kill_urb(&dev->ep1_in_urb); | 530 | usb_kill_urb(&cdev->ep1_in_urb); |
526 | usb_kill_urb(&dev->midi_out_urb); | 531 | usb_kill_urb(&cdev->midi_out_urb); |
527 | 532 | ||
528 | snd_card_free(card); | 533 | snd_card_free(card); |
529 | usb_reset_device(interface_to_usbdev(intf)); | 534 | usb_reset_device(interface_to_usbdev(intf)); |
@@ -539,4 +544,3 @@ static struct usb_driver snd_usb_driver = { | |||
539 | }; | 544 | }; |
540 | 545 | ||
541 | module_usb_driver(snd_usb_driver); | 546 | module_usb_driver(snd_usb_driver); |
542 | |||
diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h index 562b0bff9c41..ad102fac6942 100644 --- a/sound/usb/caiaq/device.h +++ b/sound/usb/caiaq/device.h | |||
@@ -25,16 +25,7 @@ | |||
25 | #define CAIAQ_USB_STR_LEN 0xff | 25 | #define CAIAQ_USB_STR_LEN 0xff |
26 | #define MAX_STREAMS 32 | 26 | #define MAX_STREAMS 32 |
27 | 27 | ||
28 | //#define SND_USB_CAIAQ_DEBUG | ||
29 | |||
30 | #define MODNAME "snd-usb-caiaq" | 28 | #define MODNAME "snd-usb-caiaq" |
31 | #define log(x...) snd_printk(KERN_WARNING MODNAME" log: " x) | ||
32 | |||
33 | #ifdef SND_USB_CAIAQ_DEBUG | ||
34 | #define debug(x...) snd_printk(KERN_WARNING MODNAME " debug: " x) | ||
35 | #else | ||
36 | #define debug(x...) do { } while(0) | ||
37 | #endif | ||
38 | 29 | ||
39 | #define EP1_CMD_GET_DEVICE_INFO 0x1 | 30 | #define EP1_CMD_GET_DEVICE_INFO 0x1 |
40 | #define EP1_CMD_READ_ERP 0x2 | 31 | #define EP1_CMD_READ_ERP 0x2 |
@@ -124,15 +115,16 @@ struct snd_usb_caiaqdev { | |||
124 | }; | 115 | }; |
125 | 116 | ||
126 | struct snd_usb_caiaq_cb_info { | 117 | struct snd_usb_caiaq_cb_info { |
127 | struct snd_usb_caiaqdev *dev; | 118 | struct snd_usb_caiaqdev *cdev; |
128 | int index; | 119 | int index; |
129 | }; | 120 | }; |
130 | 121 | ||
131 | #define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data) | 122 | #define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data) |
123 | #define caiaqdev_to_dev(d) (d->chip.card->dev) | ||
132 | 124 | ||
133 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp); | 125 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, int rate, int depth, int bbp); |
134 | int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp); | 126 | int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *cdev, int digital, int analog, int erp); |
135 | int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, | 127 | int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, |
136 | unsigned char command, | 128 | unsigned char command, |
137 | const unsigned char *buffer, | 129 | const unsigned char *buffer, |
138 | int len); | 130 | int len); |
diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c index 26a121b42c3c..efc70ae915c5 100644 --- a/sound/usb/caiaq/input.c +++ b/sound/usb/caiaq/input.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/device.h> | ||
19 | #include <linux/gfp.h> | 20 | #include <linux/gfp.h> |
20 | #include <linux/init.h> | 21 | #include <linux/init.h> |
21 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
@@ -199,55 +200,55 @@ static unsigned int decode_erp(unsigned char a, unsigned char b) | |||
199 | #undef HIGH_PEAK | 200 | #undef HIGH_PEAK |
200 | #undef LOW_PEAK | 201 | #undef LOW_PEAK |
201 | 202 | ||
202 | static inline void snd_caiaq_input_report_abs(struct snd_usb_caiaqdev *dev, | 203 | static inline void snd_caiaq_input_report_abs(struct snd_usb_caiaqdev *cdev, |
203 | int axis, const unsigned char *buf, | 204 | int axis, const unsigned char *buf, |
204 | int offset) | 205 | int offset) |
205 | { | 206 | { |
206 | input_report_abs(dev->input_dev, axis, | 207 | input_report_abs(cdev->input_dev, axis, |
207 | (buf[offset * 2] << 8) | buf[offset * 2 + 1]); | 208 | (buf[offset * 2] << 8) | buf[offset * 2 + 1]); |
208 | } | 209 | } |
209 | 210 | ||
210 | static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *dev, | 211 | static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *cdev, |
211 | const unsigned char *buf, | 212 | const unsigned char *buf, |
212 | unsigned int len) | 213 | unsigned int len) |
213 | { | 214 | { |
214 | struct input_dev *input_dev = dev->input_dev; | 215 | struct input_dev *input_dev = cdev->input_dev; |
215 | 216 | ||
216 | switch (dev->chip.usb_id) { | 217 | switch (cdev->chip.usb_id) { |
217 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 218 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
218 | snd_caiaq_input_report_abs(dev, ABS_X, buf, 2); | 219 | snd_caiaq_input_report_abs(cdev, ABS_X, buf, 2); |
219 | snd_caiaq_input_report_abs(dev, ABS_Y, buf, 0); | 220 | snd_caiaq_input_report_abs(cdev, ABS_Y, buf, 0); |
220 | snd_caiaq_input_report_abs(dev, ABS_Z, buf, 1); | 221 | snd_caiaq_input_report_abs(cdev, ABS_Z, buf, 1); |
221 | break; | 222 | break; |
222 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 223 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
223 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | 224 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): |
224 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): | 225 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): |
225 | snd_caiaq_input_report_abs(dev, ABS_X, buf, 0); | 226 | snd_caiaq_input_report_abs(cdev, ABS_X, buf, 0); |
226 | snd_caiaq_input_report_abs(dev, ABS_Y, buf, 1); | 227 | snd_caiaq_input_report_abs(cdev, ABS_Y, buf, 1); |
227 | snd_caiaq_input_report_abs(dev, ABS_Z, buf, 2); | 228 | snd_caiaq_input_report_abs(cdev, ABS_Z, buf, 2); |
228 | break; | 229 | break; |
229 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 230 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
230 | snd_caiaq_input_report_abs(dev, ABS_HAT0X, buf, 4); | 231 | snd_caiaq_input_report_abs(cdev, ABS_HAT0X, buf, 4); |
231 | snd_caiaq_input_report_abs(dev, ABS_HAT0Y, buf, 2); | 232 | snd_caiaq_input_report_abs(cdev, ABS_HAT0Y, buf, 2); |
232 | snd_caiaq_input_report_abs(dev, ABS_HAT1X, buf, 6); | 233 | snd_caiaq_input_report_abs(cdev, ABS_HAT1X, buf, 6); |
233 | snd_caiaq_input_report_abs(dev, ABS_HAT1Y, buf, 1); | 234 | snd_caiaq_input_report_abs(cdev, ABS_HAT1Y, buf, 1); |
234 | snd_caiaq_input_report_abs(dev, ABS_HAT2X, buf, 7); | 235 | snd_caiaq_input_report_abs(cdev, ABS_HAT2X, buf, 7); |
235 | snd_caiaq_input_report_abs(dev, ABS_HAT2Y, buf, 0); | 236 | snd_caiaq_input_report_abs(cdev, ABS_HAT2Y, buf, 0); |
236 | snd_caiaq_input_report_abs(dev, ABS_HAT3X, buf, 5); | 237 | snd_caiaq_input_report_abs(cdev, ABS_HAT3X, buf, 5); |
237 | snd_caiaq_input_report_abs(dev, ABS_HAT3Y, buf, 3); | 238 | snd_caiaq_input_report_abs(cdev, ABS_HAT3Y, buf, 3); |
238 | break; | 239 | break; |
239 | } | 240 | } |
240 | 241 | ||
241 | input_sync(input_dev); | 242 | input_sync(input_dev); |
242 | } | 243 | } |
243 | 244 | ||
244 | static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev, | 245 | static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *cdev, |
245 | const char *buf, unsigned int len) | 246 | const char *buf, unsigned int len) |
246 | { | 247 | { |
247 | struct input_dev *input_dev = dev->input_dev; | 248 | struct input_dev *input_dev = cdev->input_dev; |
248 | int i; | 249 | int i; |
249 | 250 | ||
250 | switch (dev->chip.usb_id) { | 251 | switch (cdev->chip.usb_id) { |
251 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 252 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
252 | i = decode_erp(buf[0], buf[1]); | 253 | i = decode_erp(buf[0], buf[1]); |
253 | input_report_abs(input_dev, ABS_X, i); | 254 | input_report_abs(input_dev, ABS_X, i); |
@@ -299,10 +300,10 @@ static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev, | |||
299 | } | 300 | } |
300 | } | 301 | } |
301 | 302 | ||
302 | static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, | 303 | static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *cdev, |
303 | unsigned char *buf, unsigned int len) | 304 | unsigned char *buf, unsigned int len) |
304 | { | 305 | { |
305 | struct input_dev *input_dev = dev->input_dev; | 306 | struct input_dev *input_dev = cdev->input_dev; |
306 | unsigned short *keycode = input_dev->keycode; | 307 | unsigned short *keycode = input_dev->keycode; |
307 | int i; | 308 | int i; |
308 | 309 | ||
@@ -317,17 +318,17 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, | |||
317 | input_report_key(input_dev, keycode[i], | 318 | input_report_key(input_dev, keycode[i], |
318 | buf[i / 8] & (1 << (i % 8))); | 319 | buf[i / 8] & (1 << (i % 8))); |
319 | 320 | ||
320 | switch (dev->chip.usb_id) { | 321 | switch (cdev->chip.usb_id) { |
321 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | 322 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): |
322 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): | 323 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): |
323 | input_report_abs(dev->input_dev, ABS_MISC, 255 - buf[4]); | 324 | input_report_abs(cdev->input_dev, ABS_MISC, 255 - buf[4]); |
324 | break; | 325 | break; |
325 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 326 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
326 | /* rotary encoders */ | 327 | /* rotary encoders */ |
327 | input_report_abs(dev->input_dev, ABS_X, buf[5] & 0xf); | 328 | input_report_abs(cdev->input_dev, ABS_X, buf[5] & 0xf); |
328 | input_report_abs(dev->input_dev, ABS_Y, buf[5] >> 4); | 329 | input_report_abs(cdev->input_dev, ABS_Y, buf[5] >> 4); |
329 | input_report_abs(dev->input_dev, ABS_Z, buf[6] & 0xf); | 330 | input_report_abs(cdev->input_dev, ABS_Z, buf[6] & 0xf); |
330 | input_report_abs(dev->input_dev, ABS_MISC, buf[6] >> 4); | 331 | input_report_abs(cdev->input_dev, ABS_MISC, buf[6] >> 4); |
331 | break; | 332 | break; |
332 | } | 333 | } |
333 | 334 | ||
@@ -336,10 +337,12 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, | |||
336 | 337 | ||
337 | #define TKS4_MSGBLOCK_SIZE 16 | 338 | #define TKS4_MSGBLOCK_SIZE 16 |
338 | 339 | ||
339 | static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev, | 340 | static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *cdev, |
340 | const unsigned char *buf, | 341 | const unsigned char *buf, |
341 | unsigned int len) | 342 | unsigned int len) |
342 | { | 343 | { |
344 | struct device *dev = caiaqdev_to_dev(cdev); | ||
345 | |||
343 | while (len) { | 346 | while (len) { |
344 | unsigned int i, block_id = (buf[0] << 8) | buf[1]; | 347 | unsigned int i, block_id = (buf[0] << 8) | buf[1]; |
345 | 348 | ||
@@ -347,126 +350,126 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev, | |||
347 | case 0: | 350 | case 0: |
348 | /* buttons */ | 351 | /* buttons */ |
349 | for (i = 0; i < KONTROLS4_BUTTONS; i++) | 352 | for (i = 0; i < KONTROLS4_BUTTONS; i++) |
350 | input_report_key(dev->input_dev, KONTROLS4_BUTTON(i), | 353 | input_report_key(cdev->input_dev, KONTROLS4_BUTTON(i), |
351 | (buf[4 + (i / 8)] >> (i % 8)) & 1); | 354 | (buf[4 + (i / 8)] >> (i % 8)) & 1); |
352 | break; | 355 | break; |
353 | 356 | ||
354 | case 1: | 357 | case 1: |
355 | /* left wheel */ | 358 | /* left wheel */ |
356 | input_report_abs(dev->input_dev, KONTROLS4_ABS(36), buf[9] | ((buf[8] & 0x3) << 8)); | 359 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(36), buf[9] | ((buf[8] & 0x3) << 8)); |
357 | /* right wheel */ | 360 | /* right wheel */ |
358 | input_report_abs(dev->input_dev, KONTROLS4_ABS(37), buf[13] | ((buf[12] & 0x3) << 8)); | 361 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(37), buf[13] | ((buf[12] & 0x3) << 8)); |
359 | 362 | ||
360 | /* rotary encoders */ | 363 | /* rotary encoders */ |
361 | input_report_abs(dev->input_dev, KONTROLS4_ABS(38), buf[3] & 0xf); | 364 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(38), buf[3] & 0xf); |
362 | input_report_abs(dev->input_dev, KONTROLS4_ABS(39), buf[4] >> 4); | 365 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(39), buf[4] >> 4); |
363 | input_report_abs(dev->input_dev, KONTROLS4_ABS(40), buf[4] & 0xf); | 366 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(40), buf[4] & 0xf); |
364 | input_report_abs(dev->input_dev, KONTROLS4_ABS(41), buf[5] >> 4); | 367 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(41), buf[5] >> 4); |
365 | input_report_abs(dev->input_dev, KONTROLS4_ABS(42), buf[5] & 0xf); | 368 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(42), buf[5] & 0xf); |
366 | input_report_abs(dev->input_dev, KONTROLS4_ABS(43), buf[6] >> 4); | 369 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(43), buf[6] >> 4); |
367 | input_report_abs(dev->input_dev, KONTROLS4_ABS(44), buf[6] & 0xf); | 370 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(44), buf[6] & 0xf); |
368 | input_report_abs(dev->input_dev, KONTROLS4_ABS(45), buf[7] >> 4); | 371 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(45), buf[7] >> 4); |
369 | input_report_abs(dev->input_dev, KONTROLS4_ABS(46), buf[7] & 0xf); | 372 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(46), buf[7] & 0xf); |
370 | 373 | ||
371 | break; | 374 | break; |
372 | case 2: | 375 | case 2: |
373 | /* Volume Fader Channel D */ | 376 | /* Volume Fader Channel D */ |
374 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(0), buf, 1); | 377 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(0), buf, 1); |
375 | /* Volume Fader Channel B */ | 378 | /* Volume Fader Channel B */ |
376 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(1), buf, 2); | 379 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(1), buf, 2); |
377 | /* Volume Fader Channel A */ | 380 | /* Volume Fader Channel A */ |
378 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(2), buf, 3); | 381 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(2), buf, 3); |
379 | /* Volume Fader Channel C */ | 382 | /* Volume Fader Channel C */ |
380 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(3), buf, 4); | 383 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(3), buf, 4); |
381 | /* Loop Volume */ | 384 | /* Loop Volume */ |
382 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(4), buf, 6); | 385 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(4), buf, 6); |
383 | /* Crossfader */ | 386 | /* Crossfader */ |
384 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(7), buf, 7); | 387 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(7), buf, 7); |
385 | 388 | ||
386 | break; | 389 | break; |
387 | 390 | ||
388 | case 3: | 391 | case 3: |
389 | /* Tempo Fader R */ | 392 | /* Tempo Fader R */ |
390 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(6), buf, 3); | 393 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(6), buf, 3); |
391 | /* Tempo Fader L */ | 394 | /* Tempo Fader L */ |
392 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(5), buf, 4); | 395 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(5), buf, 4); |
393 | /* Mic Volume */ | 396 | /* Mic Volume */ |
394 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(8), buf, 6); | 397 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(8), buf, 6); |
395 | /* Cue Mix */ | 398 | /* Cue Mix */ |
396 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(9), buf, 7); | 399 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(9), buf, 7); |
397 | 400 | ||
398 | break; | 401 | break; |
399 | 402 | ||
400 | case 4: | 403 | case 4: |
401 | /* Wheel distance sensor L */ | 404 | /* Wheel distance sensor L */ |
402 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(10), buf, 1); | 405 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(10), buf, 1); |
403 | /* Wheel distance sensor R */ | 406 | /* Wheel distance sensor R */ |
404 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(11), buf, 2); | 407 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(11), buf, 2); |
405 | /* Channel D EQ - Filter */ | 408 | /* Channel D EQ - Filter */ |
406 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(12), buf, 3); | 409 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(12), buf, 3); |
407 | /* Channel D EQ - Low */ | 410 | /* Channel D EQ - Low */ |
408 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(13), buf, 4); | 411 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(13), buf, 4); |
409 | /* Channel D EQ - Mid */ | 412 | /* Channel D EQ - Mid */ |
410 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(14), buf, 5); | 413 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(14), buf, 5); |
411 | /* Channel D EQ - Hi */ | 414 | /* Channel D EQ - Hi */ |
412 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(15), buf, 6); | 415 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(15), buf, 6); |
413 | /* FX2 - dry/wet */ | 416 | /* FX2 - dry/wet */ |
414 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(16), buf, 7); | 417 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(16), buf, 7); |
415 | 418 | ||
416 | break; | 419 | break; |
417 | 420 | ||
418 | case 5: | 421 | case 5: |
419 | /* FX2 - 1 */ | 422 | /* FX2 - 1 */ |
420 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(17), buf, 1); | 423 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(17), buf, 1); |
421 | /* FX2 - 2 */ | 424 | /* FX2 - 2 */ |
422 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(18), buf, 2); | 425 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(18), buf, 2); |
423 | /* FX2 - 3 */ | 426 | /* FX2 - 3 */ |
424 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(19), buf, 3); | 427 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(19), buf, 3); |
425 | /* Channel B EQ - Filter */ | 428 | /* Channel B EQ - Filter */ |
426 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(20), buf, 4); | 429 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(20), buf, 4); |
427 | /* Channel B EQ - Low */ | 430 | /* Channel B EQ - Low */ |
428 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(21), buf, 5); | 431 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(21), buf, 5); |
429 | /* Channel B EQ - Mid */ | 432 | /* Channel B EQ - Mid */ |
430 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(22), buf, 6); | 433 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(22), buf, 6); |
431 | /* Channel B EQ - Hi */ | 434 | /* Channel B EQ - Hi */ |
432 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(23), buf, 7); | 435 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(23), buf, 7); |
433 | 436 | ||
434 | break; | 437 | break; |
435 | 438 | ||
436 | case 6: | 439 | case 6: |
437 | /* Channel A EQ - Filter */ | 440 | /* Channel A EQ - Filter */ |
438 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(24), buf, 1); | 441 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(24), buf, 1); |
439 | /* Channel A EQ - Low */ | 442 | /* Channel A EQ - Low */ |
440 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(25), buf, 2); | 443 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(25), buf, 2); |
441 | /* Channel A EQ - Mid */ | 444 | /* Channel A EQ - Mid */ |
442 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(26), buf, 3); | 445 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(26), buf, 3); |
443 | /* Channel A EQ - Hi */ | 446 | /* Channel A EQ - Hi */ |
444 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(27), buf, 4); | 447 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(27), buf, 4); |
445 | /* Channel C EQ - Filter */ | 448 | /* Channel C EQ - Filter */ |
446 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(28), buf, 5); | 449 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(28), buf, 5); |
447 | /* Channel C EQ - Low */ | 450 | /* Channel C EQ - Low */ |
448 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(29), buf, 6); | 451 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(29), buf, 6); |
449 | /* Channel C EQ - Mid */ | 452 | /* Channel C EQ - Mid */ |
450 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(30), buf, 7); | 453 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(30), buf, 7); |
451 | 454 | ||
452 | break; | 455 | break; |
453 | 456 | ||
454 | case 7: | 457 | case 7: |
455 | /* Channel C EQ - Hi */ | 458 | /* Channel C EQ - Hi */ |
456 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(31), buf, 1); | 459 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(31), buf, 1); |
457 | /* FX1 - wet/dry */ | 460 | /* FX1 - wet/dry */ |
458 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(32), buf, 2); | 461 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(32), buf, 2); |
459 | /* FX1 - 1 */ | 462 | /* FX1 - 1 */ |
460 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(33), buf, 3); | 463 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(33), buf, 3); |
461 | /* FX1 - 2 */ | 464 | /* FX1 - 2 */ |
462 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(34), buf, 4); | 465 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(34), buf, 4); |
463 | /* FX1 - 3 */ | 466 | /* FX1 - 3 */ |
464 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(35), buf, 5); | 467 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(35), buf, 5); |
465 | 468 | ||
466 | break; | 469 | break; |
467 | 470 | ||
468 | default: | 471 | default: |
469 | debug("%s(): bogus block (id %d)\n", | 472 | dev_dbg(dev, "%s(): bogus block (id %d)\n", |
470 | __func__, block_id); | 473 | __func__, block_id); |
471 | return; | 474 | return; |
472 | } | 475 | } |
@@ -475,12 +478,12 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev, | |||
475 | buf += TKS4_MSGBLOCK_SIZE; | 478 | buf += TKS4_MSGBLOCK_SIZE; |
476 | } | 479 | } |
477 | 480 | ||
478 | input_sync(dev->input_dev); | 481 | input_sync(cdev->input_dev); |
479 | } | 482 | } |
480 | 483 | ||
481 | #define MASCHINE_MSGBLOCK_SIZE 2 | 484 | #define MASCHINE_MSGBLOCK_SIZE 2 |
482 | 485 | ||
483 | static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *dev, | 486 | static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *cdev, |
484 | const unsigned char *buf, | 487 | const unsigned char *buf, |
485 | unsigned int len) | 488 | unsigned int len) |
486 | { | 489 | { |
@@ -491,65 +494,66 @@ static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *dev, | |||
491 | pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]); | 494 | pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]); |
492 | pad_id = pressure >> 12; | 495 | pad_id = pressure >> 12; |
493 | 496 | ||
494 | input_report_abs(dev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff); | 497 | input_report_abs(cdev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff); |
495 | } | 498 | } |
496 | 499 | ||
497 | input_sync(dev->input_dev); | 500 | input_sync(cdev->input_dev); |
498 | } | 501 | } |
499 | 502 | ||
500 | static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb) | 503 | static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb) |
501 | { | 504 | { |
502 | struct snd_usb_caiaqdev *dev = urb->context; | 505 | struct snd_usb_caiaqdev *cdev = urb->context; |
503 | unsigned char *buf = urb->transfer_buffer; | 506 | unsigned char *buf = urb->transfer_buffer; |
507 | struct device *dev = &urb->dev->dev; | ||
504 | int ret; | 508 | int ret; |
505 | 509 | ||
506 | if (urb->status || !dev || urb != dev->ep4_in_urb) | 510 | if (urb->status || !cdev || urb != cdev->ep4_in_urb) |
507 | return; | 511 | return; |
508 | 512 | ||
509 | switch (dev->chip.usb_id) { | 513 | switch (cdev->chip.usb_id) { |
510 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 514 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
511 | if (urb->actual_length < 24) | 515 | if (urb->actual_length < 24) |
512 | goto requeue; | 516 | goto requeue; |
513 | 517 | ||
514 | if (buf[0] & 0x3) | 518 | if (buf[0] & 0x3) |
515 | snd_caiaq_input_read_io(dev, buf + 1, 7); | 519 | snd_caiaq_input_read_io(cdev, buf + 1, 7); |
516 | 520 | ||
517 | if (buf[0] & 0x4) | 521 | if (buf[0] & 0x4) |
518 | snd_caiaq_input_read_analog(dev, buf + 8, 16); | 522 | snd_caiaq_input_read_analog(cdev, buf + 8, 16); |
519 | 523 | ||
520 | break; | 524 | break; |
521 | 525 | ||
522 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): | 526 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): |
523 | snd_usb_caiaq_tks4_dispatch(dev, buf, urb->actual_length); | 527 | snd_usb_caiaq_tks4_dispatch(cdev, buf, urb->actual_length); |
524 | break; | 528 | break; |
525 | 529 | ||
526 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): | 530 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): |
527 | if (urb->actual_length < (MASCHINE_PADS * MASCHINE_MSGBLOCK_SIZE)) | 531 | if (urb->actual_length < (MASCHINE_PADS * MASCHINE_MSGBLOCK_SIZE)) |
528 | goto requeue; | 532 | goto requeue; |
529 | 533 | ||
530 | snd_usb_caiaq_maschine_dispatch(dev, buf, urb->actual_length); | 534 | snd_usb_caiaq_maschine_dispatch(cdev, buf, urb->actual_length); |
531 | break; | 535 | break; |
532 | } | 536 | } |
533 | 537 | ||
534 | requeue: | 538 | requeue: |
535 | dev->ep4_in_urb->actual_length = 0; | 539 | cdev->ep4_in_urb->actual_length = 0; |
536 | ret = usb_submit_urb(dev->ep4_in_urb, GFP_ATOMIC); | 540 | ret = usb_submit_urb(cdev->ep4_in_urb, GFP_ATOMIC); |
537 | if (ret < 0) | 541 | if (ret < 0) |
538 | log("unable to submit urb. OOM!?\n"); | 542 | dev_err(dev, "unable to submit urb. OOM!?\n"); |
539 | } | 543 | } |
540 | 544 | ||
541 | static int snd_usb_caiaq_input_open(struct input_dev *idev) | 545 | static int snd_usb_caiaq_input_open(struct input_dev *idev) |
542 | { | 546 | { |
543 | struct snd_usb_caiaqdev *dev = input_get_drvdata(idev); | 547 | struct snd_usb_caiaqdev *cdev = input_get_drvdata(idev); |
544 | 548 | ||
545 | if (!dev) | 549 | if (!cdev) |
546 | return -EINVAL; | 550 | return -EINVAL; |
547 | 551 | ||
548 | switch (dev->chip.usb_id) { | 552 | switch (cdev->chip.usb_id) { |
549 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 553 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
550 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): | 554 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): |
551 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): | 555 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): |
552 | if (usb_submit_urb(dev->ep4_in_urb, GFP_KERNEL) != 0) | 556 | if (usb_submit_urb(cdev->ep4_in_urb, GFP_KERNEL) != 0) |
553 | return -EIO; | 557 | return -EIO; |
554 | break; | 558 | break; |
555 | } | 559 | } |
@@ -559,43 +563,43 @@ static int snd_usb_caiaq_input_open(struct input_dev *idev) | |||
559 | 563 | ||
560 | static void snd_usb_caiaq_input_close(struct input_dev *idev) | 564 | static void snd_usb_caiaq_input_close(struct input_dev *idev) |
561 | { | 565 | { |
562 | struct snd_usb_caiaqdev *dev = input_get_drvdata(idev); | 566 | struct snd_usb_caiaqdev *cdev = input_get_drvdata(idev); |
563 | 567 | ||
564 | if (!dev) | 568 | if (!cdev) |
565 | return; | 569 | return; |
566 | 570 | ||
567 | switch (dev->chip.usb_id) { | 571 | switch (cdev->chip.usb_id) { |
568 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 572 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
569 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): | 573 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): |
570 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): | 574 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): |
571 | usb_kill_urb(dev->ep4_in_urb); | 575 | usb_kill_urb(cdev->ep4_in_urb); |
572 | break; | 576 | break; |
573 | } | 577 | } |
574 | } | 578 | } |
575 | 579 | ||
576 | void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev, | 580 | void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *cdev, |
577 | char *buf, | 581 | char *buf, |
578 | unsigned int len) | 582 | unsigned int len) |
579 | { | 583 | { |
580 | if (!dev->input_dev || len < 1) | 584 | if (!cdev->input_dev || len < 1) |
581 | return; | 585 | return; |
582 | 586 | ||
583 | switch (buf[0]) { | 587 | switch (buf[0]) { |
584 | case EP1_CMD_READ_ANALOG: | 588 | case EP1_CMD_READ_ANALOG: |
585 | snd_caiaq_input_read_analog(dev, buf + 1, len - 1); | 589 | snd_caiaq_input_read_analog(cdev, buf + 1, len - 1); |
586 | break; | 590 | break; |
587 | case EP1_CMD_READ_ERP: | 591 | case EP1_CMD_READ_ERP: |
588 | snd_caiaq_input_read_erp(dev, buf + 1, len - 1); | 592 | snd_caiaq_input_read_erp(cdev, buf + 1, len - 1); |
589 | break; | 593 | break; |
590 | case EP1_CMD_READ_IO: | 594 | case EP1_CMD_READ_IO: |
591 | snd_caiaq_input_read_io(dev, buf + 1, len - 1); | 595 | snd_caiaq_input_read_io(cdev, buf + 1, len - 1); |
592 | break; | 596 | break; |
593 | } | 597 | } |
594 | } | 598 | } |
595 | 599 | ||
596 | int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | 600 | int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev) |
597 | { | 601 | { |
598 | struct usb_device *usb_dev = dev->chip.dev; | 602 | struct usb_device *usb_dev = cdev->chip.dev; |
599 | struct input_dev *input; | 603 | struct input_dev *input; |
600 | int i, ret = 0; | 604 | int i, ret = 0; |
601 | 605 | ||
@@ -603,49 +607,49 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
603 | if (!input) | 607 | if (!input) |
604 | return -ENOMEM; | 608 | return -ENOMEM; |
605 | 609 | ||
606 | usb_make_path(usb_dev, dev->phys, sizeof(dev->phys)); | 610 | usb_make_path(usb_dev, cdev->phys, sizeof(cdev->phys)); |
607 | strlcat(dev->phys, "/input0", sizeof(dev->phys)); | 611 | strlcat(cdev->phys, "/input0", sizeof(cdev->phys)); |
608 | 612 | ||
609 | input->name = dev->product_name; | 613 | input->name = cdev->product_name; |
610 | input->phys = dev->phys; | 614 | input->phys = cdev->phys; |
611 | usb_to_input_id(usb_dev, &input->id); | 615 | usb_to_input_id(usb_dev, &input->id); |
612 | input->dev.parent = &usb_dev->dev; | 616 | input->dev.parent = &usb_dev->dev; |
613 | 617 | ||
614 | input_set_drvdata(input, dev); | 618 | input_set_drvdata(input, cdev); |
615 | 619 | ||
616 | switch (dev->chip.usb_id) { | 620 | switch (cdev->chip.usb_id) { |
617 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 621 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
618 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 622 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
619 | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | | 623 | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
620 | BIT_MASK(ABS_Z); | 624 | BIT_MASK(ABS_Z); |
621 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk2)); | 625 | BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_rk2)); |
622 | memcpy(dev->keycode, keycode_rk2, sizeof(keycode_rk2)); | 626 | memcpy(cdev->keycode, keycode_rk2, sizeof(keycode_rk2)); |
623 | input->keycodemax = ARRAY_SIZE(keycode_rk2); | 627 | input->keycodemax = ARRAY_SIZE(keycode_rk2); |
624 | input_set_abs_params(input, ABS_X, 0, 4096, 0, 10); | 628 | input_set_abs_params(input, ABS_X, 0, 4096, 0, 10); |
625 | input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); | 629 | input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); |
626 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); | 630 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); |
627 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); | 631 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 0); |
628 | break; | 632 | break; |
629 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 633 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
630 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 634 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
631 | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | | 635 | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
632 | BIT_MASK(ABS_Z); | 636 | BIT_MASK(ABS_Z); |
633 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk3)); | 637 | BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_rk3)); |
634 | memcpy(dev->keycode, keycode_rk3, sizeof(keycode_rk3)); | 638 | memcpy(cdev->keycode, keycode_rk3, sizeof(keycode_rk3)); |
635 | input->keycodemax = ARRAY_SIZE(keycode_rk3); | 639 | input->keycodemax = ARRAY_SIZE(keycode_rk3); |
636 | input_set_abs_params(input, ABS_X, 0, 1024, 0, 10); | 640 | input_set_abs_params(input, ABS_X, 0, 1024, 0, 10); |
637 | input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10); | 641 | input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10); |
638 | input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10); | 642 | input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10); |
639 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); | 643 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 0); |
640 | break; | 644 | break; |
641 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 645 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
642 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 646 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
643 | input->absbit[0] = BIT_MASK(ABS_X); | 647 | input->absbit[0] = BIT_MASK(ABS_X); |
644 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_ak1)); | 648 | BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_ak1)); |
645 | memcpy(dev->keycode, keycode_ak1, sizeof(keycode_ak1)); | 649 | memcpy(cdev->keycode, keycode_ak1, sizeof(keycode_ak1)); |
646 | input->keycodemax = ARRAY_SIZE(keycode_ak1); | 650 | input->keycodemax = ARRAY_SIZE(keycode_ak1); |
647 | input_set_abs_params(input, ABS_X, 0, 999, 0, 10); | 651 | input_set_abs_params(input, ABS_X, 0, 999, 0, 10); |
648 | snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5); | 652 | snd_usb_caiaq_set_auto_msg(cdev, 1, 0, 5); |
649 | break; | 653 | break; |
650 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | 654 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): |
651 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): | 655 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): |
@@ -657,8 +661,8 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
657 | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | | 661 | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
658 | BIT_MASK(ABS_Z); | 662 | BIT_MASK(ABS_Z); |
659 | input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); | 663 | input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); |
660 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_kore)); | 664 | BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_kore)); |
661 | memcpy(dev->keycode, keycode_kore, sizeof(keycode_kore)); | 665 | memcpy(cdev->keycode, keycode_kore, sizeof(keycode_kore)); |
662 | input->keycodemax = ARRAY_SIZE(keycode_kore); | 666 | input->keycodemax = ARRAY_SIZE(keycode_kore); |
663 | input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10); | 667 | input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10); |
664 | input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10); | 668 | input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10); |
@@ -672,7 +676,7 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
672 | input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); | 676 | input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); |
673 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); | 677 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); |
674 | input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1); | 678 | input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1); |
675 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); | 679 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5); |
676 | break; | 680 | break; |
677 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 681 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
678 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 682 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
@@ -683,9 +687,9 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
683 | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | | 687 | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
684 | BIT_MASK(ABS_Z); | 688 | BIT_MASK(ABS_Z); |
685 | input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); | 689 | input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); |
686 | BUILD_BUG_ON(sizeof(dev->keycode) < KONTROLX1_INPUTS); | 690 | BUILD_BUG_ON(sizeof(cdev->keycode) < KONTROLX1_INPUTS); |
687 | for (i = 0; i < KONTROLX1_INPUTS; i++) | 691 | for (i = 0; i < KONTROLX1_INPUTS; i++) |
688 | dev->keycode[i] = BTN_MISC + i; | 692 | cdev->keycode[i] = BTN_MISC + i; |
689 | input->keycodemax = KONTROLX1_INPUTS; | 693 | input->keycodemax = KONTROLX1_INPUTS; |
690 | 694 | ||
691 | /* analog potentiometers */ | 695 | /* analog potentiometers */ |
@@ -704,26 +708,26 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
704 | input_set_abs_params(input, ABS_Z, 0, 0xf, 0, 1); | 708 | input_set_abs_params(input, ABS_Z, 0, 0xf, 0, 1); |
705 | input_set_abs_params(input, ABS_MISC, 0, 0xf, 0, 1); | 709 | input_set_abs_params(input, ABS_MISC, 0, 0xf, 0, 1); |
706 | 710 | ||
707 | dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); | 711 | cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); |
708 | if (!dev->ep4_in_urb) { | 712 | if (!cdev->ep4_in_urb) { |
709 | ret = -ENOMEM; | 713 | ret = -ENOMEM; |
710 | goto exit_free_idev; | 714 | goto exit_free_idev; |
711 | } | 715 | } |
712 | 716 | ||
713 | usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, | 717 | usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev, |
714 | usb_rcvbulkpipe(usb_dev, 0x4), | 718 | usb_rcvbulkpipe(usb_dev, 0x4), |
715 | dev->ep4_in_buf, EP4_BUFSIZE, | 719 | cdev->ep4_in_buf, EP4_BUFSIZE, |
716 | snd_usb_caiaq_ep4_reply_dispatch, dev); | 720 | snd_usb_caiaq_ep4_reply_dispatch, cdev); |
717 | 721 | ||
718 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); | 722 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5); |
719 | 723 | ||
720 | break; | 724 | break; |
721 | 725 | ||
722 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): | 726 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): |
723 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 727 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
724 | BUILD_BUG_ON(sizeof(dev->keycode) < KONTROLS4_BUTTONS); | 728 | BUILD_BUG_ON(sizeof(cdev->keycode) < KONTROLS4_BUTTONS); |
725 | for (i = 0; i < KONTROLS4_BUTTONS; i++) | 729 | for (i = 0; i < KONTROLS4_BUTTONS; i++) |
726 | dev->keycode[i] = KONTROLS4_BUTTON(i); | 730 | cdev->keycode[i] = KONTROLS4_BUTTON(i); |
727 | input->keycodemax = KONTROLS4_BUTTONS; | 731 | input->keycodemax = KONTROLS4_BUTTONS; |
728 | 732 | ||
729 | for (i = 0; i < KONTROLS4_AXIS; i++) { | 733 | for (i = 0; i < KONTROLS4_AXIS; i++) { |
@@ -743,18 +747,18 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
743 | for (i = 0; i < 9; i++) | 747 | for (i = 0; i < 9; i++) |
744 | input_set_abs_params(input, KONTROLS4_ABS(38+i), 0, 0xf, 0, 1); | 748 | input_set_abs_params(input, KONTROLS4_ABS(38+i), 0, 0xf, 0, 1); |
745 | 749 | ||
746 | dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); | 750 | cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); |
747 | if (!dev->ep4_in_urb) { | 751 | if (!cdev->ep4_in_urb) { |
748 | ret = -ENOMEM; | 752 | ret = -ENOMEM; |
749 | goto exit_free_idev; | 753 | goto exit_free_idev; |
750 | } | 754 | } |
751 | 755 | ||
752 | usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, | 756 | usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev, |
753 | usb_rcvbulkpipe(usb_dev, 0x4), | 757 | usb_rcvbulkpipe(usb_dev, 0x4), |
754 | dev->ep4_in_buf, EP4_BUFSIZE, | 758 | cdev->ep4_in_buf, EP4_BUFSIZE, |
755 | snd_usb_caiaq_ep4_reply_dispatch, dev); | 759 | snd_usb_caiaq_ep4_reply_dispatch, cdev); |
756 | 760 | ||
757 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); | 761 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5); |
758 | 762 | ||
759 | break; | 763 | break; |
760 | 764 | ||
@@ -767,8 +771,8 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
767 | BIT_MASK(ABS_RX) | BIT_MASK(ABS_RY) | | 771 | BIT_MASK(ABS_RX) | BIT_MASK(ABS_RY) | |
768 | BIT_MASK(ABS_RZ); | 772 | BIT_MASK(ABS_RZ); |
769 | 773 | ||
770 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_maschine)); | 774 | BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_maschine)); |
771 | memcpy(dev->keycode, keycode_maschine, sizeof(keycode_maschine)); | 775 | memcpy(cdev->keycode, keycode_maschine, sizeof(keycode_maschine)); |
772 | input->keycodemax = ARRAY_SIZE(keycode_maschine); | 776 | input->keycodemax = ARRAY_SIZE(keycode_maschine); |
773 | 777 | ||
774 | for (i = 0; i < MASCHINE_PADS; i++) { | 778 | for (i = 0; i < MASCHINE_PADS; i++) { |
@@ -788,18 +792,18 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
788 | input_set_abs_params(input, ABS_RY, 0, 999, 0, 10); | 792 | input_set_abs_params(input, ABS_RY, 0, 999, 0, 10); |
789 | input_set_abs_params(input, ABS_RZ, 0, 999, 0, 10); | 793 | input_set_abs_params(input, ABS_RZ, 0, 999, 0, 10); |
790 | 794 | ||
791 | dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); | 795 | cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); |
792 | if (!dev->ep4_in_urb) { | 796 | if (!cdev->ep4_in_urb) { |
793 | ret = -ENOMEM; | 797 | ret = -ENOMEM; |
794 | goto exit_free_idev; | 798 | goto exit_free_idev; |
795 | } | 799 | } |
796 | 800 | ||
797 | usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, | 801 | usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev, |
798 | usb_rcvbulkpipe(usb_dev, 0x4), | 802 | usb_rcvbulkpipe(usb_dev, 0x4), |
799 | dev->ep4_in_buf, EP4_BUFSIZE, | 803 | cdev->ep4_in_buf, EP4_BUFSIZE, |
800 | snd_usb_caiaq_ep4_reply_dispatch, dev); | 804 | snd_usb_caiaq_ep4_reply_dispatch, cdev); |
801 | 805 | ||
802 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); | 806 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5); |
803 | break; | 807 | break; |
804 | 808 | ||
805 | default: | 809 | default: |
@@ -809,12 +813,12 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
809 | 813 | ||
810 | input->open = snd_usb_caiaq_input_open; | 814 | input->open = snd_usb_caiaq_input_open; |
811 | input->close = snd_usb_caiaq_input_close; | 815 | input->close = snd_usb_caiaq_input_close; |
812 | input->keycode = dev->keycode; | 816 | input->keycode = cdev->keycode; |
813 | input->keycodesize = sizeof(unsigned short); | 817 | input->keycodesize = sizeof(unsigned short); |
814 | for (i = 0; i < input->keycodemax; i++) | 818 | for (i = 0; i < input->keycodemax; i++) |
815 | __set_bit(dev->keycode[i], input->keybit); | 819 | __set_bit(cdev->keycode[i], input->keybit); |
816 | 820 | ||
817 | dev->input_dev = input; | 821 | cdev->input_dev = input; |
818 | 822 | ||
819 | ret = input_register_device(input); | 823 | ret = input_register_device(input); |
820 | if (ret < 0) | 824 | if (ret < 0) |
@@ -824,19 +828,19 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
824 | 828 | ||
825 | exit_free_idev: | 829 | exit_free_idev: |
826 | input_free_device(input); | 830 | input_free_device(input); |
827 | dev->input_dev = NULL; | 831 | cdev->input_dev = NULL; |
828 | return ret; | 832 | return ret; |
829 | } | 833 | } |
830 | 834 | ||
831 | void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev) | 835 | void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev) |
832 | { | 836 | { |
833 | if (!dev || !dev->input_dev) | 837 | if (!cdev || !cdev->input_dev) |
834 | return; | 838 | return; |
835 | 839 | ||
836 | usb_kill_urb(dev->ep4_in_urb); | 840 | usb_kill_urb(cdev->ep4_in_urb); |
837 | usb_free_urb(dev->ep4_in_urb); | 841 | usb_free_urb(cdev->ep4_in_urb); |
838 | dev->ep4_in_urb = NULL; | 842 | cdev->ep4_in_urb = NULL; |
839 | 843 | ||
840 | input_unregister_device(dev->input_dev); | 844 | input_unregister_device(cdev->input_dev); |
841 | dev->input_dev = NULL; | 845 | cdev->input_dev = NULL; |
842 | } | 846 | } |
diff --git a/sound/usb/caiaq/input.h b/sound/usb/caiaq/input.h index ced535577864..6014e2713a60 100644 --- a/sound/usb/caiaq/input.h +++ b/sound/usb/caiaq/input.h | |||
@@ -1,8 +1,8 @@ | |||
1 | #ifndef CAIAQ_INPUT_H | 1 | #ifndef CAIAQ_INPUT_H |
2 | #define CAIAQ_INPUT_H | 2 | #define CAIAQ_INPUT_H |
3 | 3 | ||
4 | void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev, char *buf, unsigned int len); | 4 | void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *cdev, char *buf, unsigned int len); |
5 | int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev); | 5 | int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev); |
6 | void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev); | 6 | void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev); |
7 | 7 | ||
8 | #endif | 8 | #endif |
diff --git a/sound/usb/caiaq/midi.c b/sound/usb/caiaq/midi.c index a1a47088fd0c..2d7588461b33 100644 --- a/sound/usb/caiaq/midi.c +++ b/sound/usb/caiaq/midi.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/device.h> | ||
19 | #include <linux/usb.h> | 20 | #include <linux/usb.h> |
20 | #include <linux/gfp.h> | 21 | #include <linux/gfp.h> |
21 | #include <sound/rawmidi.h> | 22 | #include <sound/rawmidi.h> |
@@ -37,12 +38,12 @@ static int snd_usb_caiaq_midi_input_close(struct snd_rawmidi_substream *substrea | |||
37 | 38 | ||
38 | static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) | 39 | static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) |
39 | { | 40 | { |
40 | struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; | 41 | struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data; |
41 | 42 | ||
42 | if (!dev) | 43 | if (!cdev) |
43 | return; | 44 | return; |
44 | 45 | ||
45 | dev->midi_receive_substream = up ? substream : NULL; | 46 | cdev->midi_receive_substream = up ? substream : NULL; |
46 | } | 47 | } |
47 | 48 | ||
48 | 49 | ||
@@ -53,49 +54,50 @@ static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substrea | |||
53 | 54 | ||
54 | static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream) | 55 | static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream) |
55 | { | 56 | { |
56 | struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; | 57 | struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data; |
57 | if (dev->midi_out_active) { | 58 | if (cdev->midi_out_active) { |
58 | usb_kill_urb(&dev->midi_out_urb); | 59 | usb_kill_urb(&cdev->midi_out_urb); |
59 | dev->midi_out_active = 0; | 60 | cdev->midi_out_active = 0; |
60 | } | 61 | } |
61 | return 0; | 62 | return 0; |
62 | } | 63 | } |
63 | 64 | ||
64 | static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev, | 65 | static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *cdev, |
65 | struct snd_rawmidi_substream *substream) | 66 | struct snd_rawmidi_substream *substream) |
66 | { | 67 | { |
67 | int len, ret; | 68 | int len, ret; |
69 | struct device *dev = caiaqdev_to_dev(cdev); | ||
68 | 70 | ||
69 | dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; | 71 | cdev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; |
70 | dev->midi_out_buf[1] = 0; /* port */ | 72 | cdev->midi_out_buf[1] = 0; /* port */ |
71 | len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3, | 73 | len = snd_rawmidi_transmit(substream, cdev->midi_out_buf + 3, |
72 | EP1_BUFSIZE - 3); | 74 | EP1_BUFSIZE - 3); |
73 | 75 | ||
74 | if (len <= 0) | 76 | if (len <= 0) |
75 | return; | 77 | return; |
76 | 78 | ||
77 | dev->midi_out_buf[2] = len; | 79 | cdev->midi_out_buf[2] = len; |
78 | dev->midi_out_urb.transfer_buffer_length = len+3; | 80 | cdev->midi_out_urb.transfer_buffer_length = len+3; |
79 | 81 | ||
80 | ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC); | 82 | ret = usb_submit_urb(&cdev->midi_out_urb, GFP_ATOMIC); |
81 | if (ret < 0) | 83 | if (ret < 0) |
82 | log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," | 84 | dev_err(dev, |
83 | "ret=%d, len=%d\n", | 85 | "snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," |
84 | substream, ret, len); | 86 | "ret=%d, len=%d\n", substream, ret, len); |
85 | else | 87 | else |
86 | dev->midi_out_active = 1; | 88 | cdev->midi_out_active = 1; |
87 | } | 89 | } |
88 | 90 | ||
89 | static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) | 91 | static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) |
90 | { | 92 | { |
91 | struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; | 93 | struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data; |
92 | 94 | ||
93 | if (up) { | 95 | if (up) { |
94 | dev->midi_out_substream = substream; | 96 | cdev->midi_out_substream = substream; |
95 | if (!dev->midi_out_active) | 97 | if (!cdev->midi_out_active) |
96 | snd_usb_caiaq_midi_send(dev, substream); | 98 | snd_usb_caiaq_midi_send(cdev, substream); |
97 | } else { | 99 | } else { |
98 | dev->midi_out_substream = NULL; | 100 | cdev->midi_out_substream = NULL; |
99 | } | 101 | } |
100 | } | 102 | } |
101 | 103 | ||
@@ -114,13 +116,13 @@ static struct snd_rawmidi_ops snd_usb_caiaq_midi_input = | |||
114 | .trigger = snd_usb_caiaq_midi_input_trigger, | 116 | .trigger = snd_usb_caiaq_midi_input_trigger, |
115 | }; | 117 | }; |
116 | 118 | ||
117 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, | 119 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *cdev, |
118 | int port, const char *buf, int len) | 120 | int port, const char *buf, int len) |
119 | { | 121 | { |
120 | if (!dev->midi_receive_substream) | 122 | if (!cdev->midi_receive_substream) |
121 | return; | 123 | return; |
122 | 124 | ||
123 | snd_rawmidi_receive(dev->midi_receive_substream, buf, len); | 125 | snd_rawmidi_receive(cdev->midi_receive_substream, buf, len); |
124 | } | 126 | } |
125 | 127 | ||
126 | int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) | 128 | int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) |
@@ -160,15 +162,14 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) | |||
160 | 162 | ||
161 | void snd_usb_caiaq_midi_output_done(struct urb* urb) | 163 | void snd_usb_caiaq_midi_output_done(struct urb* urb) |
162 | { | 164 | { |
163 | struct snd_usb_caiaqdev *dev = urb->context; | 165 | struct snd_usb_caiaqdev *cdev = urb->context; |
164 | 166 | ||
165 | dev->midi_out_active = 0; | 167 | cdev->midi_out_active = 0; |
166 | if (urb->status != 0) | 168 | if (urb->status != 0) |
167 | return; | 169 | return; |
168 | 170 | ||
169 | if (!dev->midi_out_substream) | 171 | if (!cdev->midi_out_substream) |
170 | return; | 172 | return; |
171 | 173 | ||
172 | snd_usb_caiaq_midi_send(dev, dev->midi_out_substream); | 174 | snd_usb_caiaq_midi_send(cdev, cdev->midi_out_substream); |
173 | } | 175 | } |
174 | |||
diff --git a/sound/usb/caiaq/midi.h b/sound/usb/caiaq/midi.h index 380f984babc9..60bf3442b283 100644 --- a/sound/usb/caiaq/midi.h +++ b/sound/usb/caiaq/midi.h | |||
@@ -1,8 +1,9 @@ | |||
1 | #ifndef CAIAQ_MIDI_H | 1 | #ifndef CAIAQ_MIDI_H |
2 | #define CAIAQ_MIDI_H | 2 | #define CAIAQ_MIDI_H |
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 *cdev); |
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 *cdev, |
6 | int port, const char *buf, int len); | ||
6 | void snd_usb_caiaq_midi_output_done(struct urb *urb); | 7 | void snd_usb_caiaq_midi_output_done(struct urb *urb); |
7 | 8 | ||
8 | #endif /* CAIAQ_MIDI_H */ | 9 | #endif /* CAIAQ_MIDI_H */ |
diff --git a/sound/usb/card.c b/sound/usb/card.c index 2da8ad75fd96..1a033177b83f 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c | |||
@@ -82,6 +82,7 @@ static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; | |||
82 | static int nrpacks = 8; /* max. number of packets per urb */ | 82 | static int nrpacks = 8; /* max. number of packets per urb */ |
83 | static int device_setup[SNDRV_CARDS]; /* device parameter for this card */ | 83 | static int device_setup[SNDRV_CARDS]; /* device parameter for this card */ |
84 | static bool ignore_ctl_error; | 84 | static bool ignore_ctl_error; |
85 | static bool autoclock = true; | ||
85 | 86 | ||
86 | module_param_array(index, int, NULL, 0444); | 87 | module_param_array(index, int, NULL, 0444); |
87 | MODULE_PARM_DESC(index, "Index value for the USB audio adapter."); | 88 | MODULE_PARM_DESC(index, "Index value for the USB audio adapter."); |
@@ -100,6 +101,8 @@ MODULE_PARM_DESC(device_setup, "Specific device setup (if needed)."); | |||
100 | module_param(ignore_ctl_error, bool, 0444); | 101 | module_param(ignore_ctl_error, bool, 0444); |
101 | MODULE_PARM_DESC(ignore_ctl_error, | 102 | MODULE_PARM_DESC(ignore_ctl_error, |
102 | "Ignore errors from USB controller for mixer interfaces."); | 103 | "Ignore errors from USB controller for mixer interfaces."); |
104 | module_param(autoclock, bool, 0444); | ||
105 | MODULE_PARM_DESC(autoclock, "Enable auto-clock selection for UAC2 devices (default: yes)."); | ||
103 | 106 | ||
104 | /* | 107 | /* |
105 | * we keep the snd_usb_audio_t instances by ourselves for merging | 108 | * we keep the snd_usb_audio_t instances by ourselves for merging |
@@ -354,6 +357,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx, | |||
354 | chip->card = card; | 357 | chip->card = card; |
355 | chip->setup = device_setup[idx]; | 358 | chip->setup = device_setup[idx]; |
356 | chip->nrpacks = nrpacks; | 359 | chip->nrpacks = nrpacks; |
360 | chip->autoclock = autoclock; | ||
357 | chip->probing = 1; | 361 | chip->probing = 1; |
358 | 362 | ||
359 | chip->usb_id = USB_ID(le16_to_cpu(dev->descriptor.idVendor), | 363 | chip->usb_id = USB_ID(le16_to_cpu(dev->descriptor.idVendor), |
@@ -627,7 +631,9 @@ int snd_usb_autoresume(struct snd_usb_audio *chip) | |||
627 | int err = -ENODEV; | 631 | int err = -ENODEV; |
628 | 632 | ||
629 | down_read(&chip->shutdown_rwsem); | 633 | down_read(&chip->shutdown_rwsem); |
630 | if (!chip->shutdown && !chip->probing) | 634 | if (chip->probing) |
635 | err = 0; | ||
636 | else if (!chip->shutdown) | ||
631 | err = usb_autopm_get_interface(chip->pm_intf); | 637 | err = usb_autopm_get_interface(chip->pm_intf); |
632 | up_read(&chip->shutdown_rwsem); | 638 | up_read(&chip->shutdown_rwsem); |
633 | 639 | ||
@@ -645,7 +651,6 @@ void snd_usb_autosuspend(struct snd_usb_audio *chip) | |||
645 | static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) | 651 | static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) |
646 | { | 652 | { |
647 | struct snd_usb_audio *chip = usb_get_intfdata(intf); | 653 | struct snd_usb_audio *chip = usb_get_intfdata(intf); |
648 | struct list_head *p; | ||
649 | struct snd_usb_stream *as; | 654 | struct snd_usb_stream *as; |
650 | struct usb_mixer_interface *mixer; | 655 | struct usb_mixer_interface *mixer; |
651 | 656 | ||
@@ -655,8 +660,7 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) | |||
655 | if (!PMSG_IS_AUTO(message)) { | 660 | if (!PMSG_IS_AUTO(message)) { |
656 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); | 661 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); |
657 | if (!chip->num_suspended_intf++) { | 662 | if (!chip->num_suspended_intf++) { |
658 | list_for_each(p, &chip->pcm_list) { | 663 | list_for_each_entry(as, &chip->pcm_list, list) { |
659 | as = list_entry(p, struct snd_usb_stream, list); | ||
660 | snd_pcm_suspend_all(as->pcm); | 664 | snd_pcm_suspend_all(as->pcm); |
661 | as->substream[0].need_setup_ep = | 665 | as->substream[0].need_setup_ep = |
662 | as->substream[1].need_setup_ep = true; | 666 | as->substream[1].need_setup_ep = true; |
@@ -716,8 +720,7 @@ static struct usb_device_id usb_audio_ids [] = { | |||
716 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL }, | 720 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL }, |
717 | { } /* Terminating entry */ | 721 | { } /* Terminating entry */ |
718 | }; | 722 | }; |
719 | 723 | MODULE_DEVICE_TABLE(usb, usb_audio_ids); | |
720 | MODULE_DEVICE_TABLE (usb, usb_audio_ids); | ||
721 | 724 | ||
722 | /* | 725 | /* |
723 | * entry point for linux usb interface | 726 | * entry point for linux usb interface |
diff --git a/sound/usb/card.h b/sound/usb/card.h index 8a751b4887ea..bf2889a2cae5 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h | |||
@@ -28,6 +28,8 @@ struct audioformat { | |||
28 | unsigned int *rate_table; /* rate table */ | 28 | unsigned int *rate_table; /* rate table */ |
29 | unsigned char clock; /* associated clock */ | 29 | unsigned char clock; /* associated clock */ |
30 | struct snd_pcm_chmap_elem *chmap; /* (optional) channel map */ | 30 | struct snd_pcm_chmap_elem *chmap; /* (optional) channel map */ |
31 | bool dsd_dop; /* add DOP headers in case of DSD samples */ | ||
32 | bool dsd_bitrev; /* reverse the bits of each DSD sample */ | ||
31 | }; | 33 | }; |
32 | 34 | ||
33 | struct snd_usb_substream; | 35 | struct snd_usb_substream; |
@@ -116,6 +118,7 @@ struct snd_usb_substream { | |||
116 | unsigned int altset_idx; /* USB data format: index of alternate setting */ | 118 | unsigned int altset_idx; /* USB data format: index of alternate setting */ |
117 | unsigned int txfr_quirk:1; /* allow sub-frame alignment */ | 119 | unsigned int txfr_quirk:1; /* allow sub-frame alignment */ |
118 | unsigned int fmt_type; /* USB audio format type (1-3) */ | 120 | unsigned int fmt_type; /* USB audio format type (1-3) */ |
121 | unsigned int pkt_offset_adj; /* Bytes to drop from beginning of packets (for non-compliant devices) */ | ||
119 | 122 | ||
120 | unsigned int running: 1; /* running status */ | 123 | unsigned int running: 1; /* running status */ |
121 | 124 | ||
@@ -138,6 +141,12 @@ struct snd_usb_substream { | |||
138 | 141 | ||
139 | int last_frame_number; /* stored frame number */ | 142 | int last_frame_number; /* stored frame number */ |
140 | int last_delay; /* stored delay */ | 143 | int last_delay; /* stored delay */ |
144 | |||
145 | struct { | ||
146 | int marker; | ||
147 | int channel; | ||
148 | int byte_idx; | ||
149 | } dsd_dop; | ||
141 | }; | 150 | }; |
142 | 151 | ||
143 | struct snd_usb_stream { | 152 | struct snd_usb_stream { |
diff --git a/sound/usb/clock.c b/sound/usb/clock.c index 9e2703a25156..b0ec3643eb62 100644 --- a/sound/usb/clock.c +++ b/sound/usb/clock.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "card.h" | 32 | #include "card.h" |
33 | #include "helper.h" | 33 | #include "helper.h" |
34 | #include "clock.h" | 34 | #include "clock.h" |
35 | #include "quirks.h" | ||
35 | 36 | ||
36 | static struct uac_clock_source_descriptor * | 37 | static struct uac_clock_source_descriptor * |
37 | snd_usb_find_clock_source(struct usb_host_interface *ctrl_iface, | 38 | snd_usb_find_clock_source(struct usb_host_interface *ctrl_iface, |
@@ -99,6 +100,41 @@ static int uac_clock_selector_get_val(struct snd_usb_audio *chip, int selector_i | |||
99 | return buf; | 100 | return buf; |
100 | } | 101 | } |
101 | 102 | ||
103 | static int uac_clock_selector_set_val(struct snd_usb_audio *chip, int selector_id, | ||
104 | unsigned char pin) | ||
105 | { | ||
106 | int ret; | ||
107 | |||
108 | ret = snd_usb_ctl_msg(chip->dev, usb_sndctrlpipe(chip->dev, 0), | ||
109 | UAC2_CS_CUR, | ||
110 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, | ||
111 | UAC2_CX_CLOCK_SELECTOR << 8, | ||
112 | snd_usb_ctrl_intf(chip) | (selector_id << 8), | ||
113 | &pin, sizeof(pin)); | ||
114 | if (ret < 0) | ||
115 | return ret; | ||
116 | |||
117 | if (ret != sizeof(pin)) { | ||
118 | snd_printk(KERN_ERR | ||
119 | "usb-audio:%d: setting selector (id %d) unexpected length %d\n", | ||
120 | chip->dev->devnum, selector_id, ret); | ||
121 | return -EINVAL; | ||
122 | } | ||
123 | |||
124 | ret = uac_clock_selector_get_val(chip, selector_id); | ||
125 | if (ret < 0) | ||
126 | return ret; | ||
127 | |||
128 | if (ret != pin) { | ||
129 | snd_printk(KERN_ERR | ||
130 | "usb-audio:%d: setting selector (id %d) to %x failed (current: %d)\n", | ||
131 | chip->dev->devnum, selector_id, pin, ret); | ||
132 | return -EINVAL; | ||
133 | } | ||
134 | |||
135 | return ret; | ||
136 | } | ||
137 | |||
102 | static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id) | 138 | static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id) |
103 | { | 139 | { |
104 | int err; | 140 | int err; |
@@ -131,7 +167,8 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id) | |||
131 | } | 167 | } |
132 | 168 | ||
133 | static int __uac_clock_find_source(struct snd_usb_audio *chip, | 169 | static int __uac_clock_find_source(struct snd_usb_audio *chip, |
134 | int entity_id, unsigned long *visited) | 170 | int entity_id, unsigned long *visited, |
171 | bool validate) | ||
135 | { | 172 | { |
136 | struct uac_clock_source_descriptor *source; | 173 | struct uac_clock_source_descriptor *source; |
137 | struct uac_clock_selector_descriptor *selector; | 174 | struct uac_clock_selector_descriptor *selector; |
@@ -148,12 +185,19 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, | |||
148 | 185 | ||
149 | /* first, see if the ID we're looking for is a clock source already */ | 186 | /* first, see if the ID we're looking for is a clock source already */ |
150 | source = snd_usb_find_clock_source(chip->ctrl_intf, entity_id); | 187 | source = snd_usb_find_clock_source(chip->ctrl_intf, entity_id); |
151 | if (source) | 188 | if (source) { |
152 | return source->bClockID; | 189 | entity_id = source->bClockID; |
190 | if (validate && !uac_clock_source_is_valid(chip, entity_id)) { | ||
191 | snd_printk(KERN_ERR "usb-audio:%d: clock source %d is not valid, cannot use\n", | ||
192 | chip->dev->devnum, entity_id); | ||
193 | return -ENXIO; | ||
194 | } | ||
195 | return entity_id; | ||
196 | } | ||
153 | 197 | ||
154 | selector = snd_usb_find_clock_selector(chip->ctrl_intf, entity_id); | 198 | selector = snd_usb_find_clock_selector(chip->ctrl_intf, entity_id); |
155 | if (selector) { | 199 | if (selector) { |
156 | int ret; | 200 | int ret, i, cur; |
157 | 201 | ||
158 | /* the entity ID we are looking for is a selector. | 202 | /* the entity ID we are looking for is a selector. |
159 | * find out what it currently selects */ | 203 | * find out what it currently selects */ |
@@ -164,22 +208,49 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, | |||
164 | /* Selector values are one-based */ | 208 | /* Selector values are one-based */ |
165 | 209 | ||
166 | if (ret > selector->bNrInPins || ret < 1) { | 210 | if (ret > selector->bNrInPins || ret < 1) { |
167 | printk(KERN_ERR | 211 | snd_printk(KERN_ERR |
168 | "%s(): selector reported illegal value, id %d, ret %d\n", | 212 | "%s(): selector reported illegal value, id %d, ret %d\n", |
169 | __func__, selector->bClockID, ret); | 213 | __func__, selector->bClockID, ret); |
170 | 214 | ||
171 | return -EINVAL; | 215 | return -EINVAL; |
172 | } | 216 | } |
173 | 217 | ||
174 | return __uac_clock_find_source(chip, selector->baCSourceID[ret-1], | 218 | cur = ret; |
175 | visited); | 219 | ret = __uac_clock_find_source(chip, selector->baCSourceID[ret - 1], |
220 | visited, validate); | ||
221 | if (!validate || ret > 0 || !chip->autoclock) | ||
222 | return ret; | ||
223 | |||
224 | /* The current clock source is invalid, try others. */ | ||
225 | for (i = 1; i <= selector->bNrInPins; i++) { | ||
226 | int err; | ||
227 | |||
228 | if (i == cur) | ||
229 | continue; | ||
230 | |||
231 | ret = __uac_clock_find_source(chip, selector->baCSourceID[i - 1], | ||
232 | visited, true); | ||
233 | if (ret < 0) | ||
234 | continue; | ||
235 | |||
236 | err = uac_clock_selector_set_val(chip, entity_id, i); | ||
237 | if (err < 0) | ||
238 | continue; | ||
239 | |||
240 | snd_printk(KERN_INFO | ||
241 | "usb-audio:%d: found and selected valid clock source %d\n", | ||
242 | chip->dev->devnum, ret); | ||
243 | return ret; | ||
244 | } | ||
245 | |||
246 | return -ENXIO; | ||
176 | } | 247 | } |
177 | 248 | ||
178 | /* FIXME: multipliers only act as pass-thru element for now */ | 249 | /* FIXME: multipliers only act as pass-thru element for now */ |
179 | multiplier = snd_usb_find_clock_multiplier(chip->ctrl_intf, entity_id); | 250 | multiplier = snd_usb_find_clock_multiplier(chip->ctrl_intf, entity_id); |
180 | if (multiplier) | 251 | if (multiplier) |
181 | return __uac_clock_find_source(chip, multiplier->bCSourceID, | 252 | return __uac_clock_find_source(chip, multiplier->bCSourceID, |
182 | visited); | 253 | visited, validate); |
183 | 254 | ||
184 | return -EINVAL; | 255 | return -EINVAL; |
185 | } | 256 | } |
@@ -195,11 +266,12 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, | |||
195 | * | 266 | * |
196 | * Returns the clock source UnitID (>=0) on success, or an error. | 267 | * Returns the clock source UnitID (>=0) on success, or an error. |
197 | */ | 268 | */ |
198 | int snd_usb_clock_find_source(struct snd_usb_audio *chip, int entity_id) | 269 | int snd_usb_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
270 | bool validate) | ||
199 | { | 271 | { |
200 | DECLARE_BITMAP(visited, 256); | 272 | DECLARE_BITMAP(visited, 256); |
201 | memset(visited, 0, sizeof(visited)); | 273 | memset(visited, 0, sizeof(visited)); |
202 | return __uac_clock_find_source(chip, entity_id, visited); | 274 | return __uac_clock_find_source(chip, entity_id, visited, validate); |
203 | } | 275 | } |
204 | 276 | ||
205 | static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface, | 277 | static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface, |
@@ -247,66 +319,71 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface, | |||
247 | return 0; | 319 | return 0; |
248 | } | 320 | } |
249 | 321 | ||
250 | static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, | 322 | static int get_sample_rate_v2(struct snd_usb_audio *chip, int iface, |
251 | struct usb_host_interface *alts, | 323 | int altsetting, int clock) |
252 | struct audioformat *fmt, int rate) | ||
253 | { | 324 | { |
254 | struct usb_device *dev = chip->dev; | 325 | struct usb_device *dev = chip->dev; |
255 | unsigned char data[4]; | 326 | __le32 data; |
256 | int err, cur_rate, prev_rate; | 327 | int err; |
257 | int clock = snd_usb_clock_find_source(chip, fmt->clock); | ||
258 | |||
259 | if (clock < 0) | ||
260 | return clock; | ||
261 | |||
262 | if (!uac_clock_source_is_valid(chip, clock)) { | ||
263 | /* TODO: should we try to find valid clock setups by ourself? */ | ||
264 | snd_printk(KERN_ERR "%d:%d:%d: clock source %d is not valid, cannot use\n", | ||
265 | dev->devnum, iface, fmt->altsetting, clock); | ||
266 | return -ENXIO; | ||
267 | } | ||
268 | 328 | ||
269 | err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, | 329 | err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, |
270 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | 330 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, |
271 | UAC2_CS_CONTROL_SAM_FREQ << 8, | 331 | UAC2_CS_CONTROL_SAM_FREQ << 8, |
272 | snd_usb_ctrl_intf(chip) | (clock << 8), | 332 | snd_usb_ctrl_intf(chip) | (clock << 8), |
273 | data, sizeof(data)); | 333 | &data, sizeof(data)); |
274 | if (err < 0) { | 334 | if (err < 0) { |
275 | snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", | 335 | snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2): err %d\n", |
276 | dev->devnum, iface, fmt->altsetting); | 336 | dev->devnum, iface, altsetting, err); |
277 | prev_rate = 0; | 337 | return 0; |
278 | } else { | ||
279 | prev_rate = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); | ||
280 | } | 338 | } |
281 | 339 | ||
282 | data[0] = rate; | 340 | return le32_to_cpu(data); |
283 | data[1] = rate >> 8; | 341 | } |
284 | data[2] = rate >> 16; | ||
285 | data[3] = rate >> 24; | ||
286 | if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, | ||
287 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, | ||
288 | UAC2_CS_CONTROL_SAM_FREQ << 8, | ||
289 | snd_usb_ctrl_intf(chip) | (clock << 8), | ||
290 | data, sizeof(data))) < 0) { | ||
291 | snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n", | ||
292 | dev->devnum, iface, fmt->altsetting, rate); | ||
293 | return err; | ||
294 | } | ||
295 | 342 | ||
296 | err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, | 343 | static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, |
297 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | 344 | struct usb_host_interface *alts, |
298 | UAC2_CS_CONTROL_SAM_FREQ << 8, | 345 | struct audioformat *fmt, int rate) |
299 | snd_usb_ctrl_intf(chip) | (clock << 8), | 346 | { |
300 | data, sizeof(data)); | 347 | struct usb_device *dev = chip->dev; |
301 | if (err < 0) { | 348 | __le32 data; |
302 | snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", | 349 | int err, cur_rate, prev_rate; |
303 | dev->devnum, iface, fmt->altsetting); | 350 | int clock; |
304 | cur_rate = 0; | 351 | bool writeable; |
352 | struct uac_clock_source_descriptor *cs_desc; | ||
353 | |||
354 | clock = snd_usb_clock_find_source(chip, fmt->clock, true); | ||
355 | if (clock < 0) | ||
356 | return clock; | ||
357 | |||
358 | prev_rate = get_sample_rate_v2(chip, iface, fmt->altsetting, clock); | ||
359 | |||
360 | cs_desc = snd_usb_find_clock_source(chip->ctrl_intf, clock); | ||
361 | writeable = uac2_control_is_writeable(cs_desc->bmControls, UAC2_CS_CONTROL_SAM_FREQ - 1); | ||
362 | if (writeable) { | ||
363 | data = cpu_to_le32(rate); | ||
364 | err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, | ||
365 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, | ||
366 | UAC2_CS_CONTROL_SAM_FREQ << 8, | ||
367 | snd_usb_ctrl_intf(chip) | (clock << 8), | ||
368 | &data, sizeof(data)); | ||
369 | if (err < 0) { | ||
370 | snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2): err %d\n", | ||
371 | dev->devnum, iface, fmt->altsetting, rate, err); | ||
372 | return err; | ||
373 | } | ||
374 | |||
375 | cur_rate = get_sample_rate_v2(chip, iface, fmt->altsetting, clock); | ||
305 | } else { | 376 | } else { |
306 | cur_rate = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); | 377 | cur_rate = prev_rate; |
307 | } | 378 | } |
308 | 379 | ||
309 | if (cur_rate != rate) { | 380 | if (cur_rate != rate) { |
381 | if (!writeable) { | ||
382 | snd_printk(KERN_WARNING | ||
383 | "%d:%d:%d: freq mismatch (RO clock): req %d, clock runs @%d\n", | ||
384 | dev->devnum, iface, fmt->altsetting, rate, cur_rate); | ||
385 | return -ENXIO; | ||
386 | } | ||
310 | snd_printd(KERN_WARNING | 387 | snd_printd(KERN_WARNING |
311 | "current rate %d is different from the runtime rate %d\n", | 388 | "current rate %d is different from the runtime rate %d\n", |
312 | cur_rate, rate); | 389 | cur_rate, rate); |
@@ -316,7 +393,9 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, | |||
316 | * interface is active. */ | 393 | * interface is active. */ |
317 | if (rate != prev_rate) { | 394 | if (rate != prev_rate) { |
318 | usb_set_interface(dev, iface, 0); | 395 | usb_set_interface(dev, iface, 0); |
396 | snd_usb_set_interface_quirk(dev); | ||
319 | usb_set_interface(dev, iface, fmt->altsetting); | 397 | usb_set_interface(dev, iface, fmt->altsetting); |
398 | snd_usb_set_interface_quirk(dev); | ||
320 | } | 399 | } |
321 | 400 | ||
322 | return 0; | 401 | return 0; |
diff --git a/sound/usb/clock.h b/sound/usb/clock.h index 46630936d31f..d592e4a29856 100644 --- a/sound/usb/clock.h +++ b/sound/usb/clock.h | |||
@@ -5,6 +5,7 @@ int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface, | |||
5 | struct usb_host_interface *alts, | 5 | struct usb_host_interface *alts, |
6 | struct audioformat *fmt, int rate); | 6 | struct audioformat *fmt, int rate); |
7 | 7 | ||
8 | int snd_usb_clock_find_source(struct snd_usb_audio *chip, int entity_id); | 8 | int snd_usb_clock_find_source(struct snd_usb_audio *chip, int entity_id, |
9 | bool validate); | ||
9 | 10 | ||
10 | #endif /* __USBAUDIO_CLOCK_H */ | 11 | #endif /* __USBAUDIO_CLOCK_H */ |
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 21049b882ee6..32d0b41a1ff6 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c | |||
@@ -128,7 +128,7 @@ static const char *usb_error_string(int err) | |||
128 | * Determine whether an endpoint is driven by an implicit feedback | 128 | * Determine whether an endpoint is driven by an implicit feedback |
129 | * data endpoint source. | 129 | * data endpoint source. |
130 | */ | 130 | */ |
131 | int snd_usb_endpoint_implict_feedback_sink(struct snd_usb_endpoint *ep) | 131 | int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep) |
132 | { | 132 | { |
133 | return ep->sync_master && | 133 | return ep->sync_master && |
134 | ep->sync_master->type == SND_USB_ENDPOINT_TYPE_DATA && | 134 | ep->sync_master->type == SND_USB_ENDPOINT_TYPE_DATA && |
@@ -363,7 +363,7 @@ static void snd_complete_urb(struct urb *urb) | |||
363 | if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags))) | 363 | if (unlikely(!test_bit(EP_FLAG_RUNNING, &ep->flags))) |
364 | goto exit_clear; | 364 | goto exit_clear; |
365 | 365 | ||
366 | if (snd_usb_endpoint_implict_feedback_sink(ep)) { | 366 | if (snd_usb_endpoint_implicit_feedback_sink(ep)) { |
367 | unsigned long flags; | 367 | unsigned long flags; |
368 | 368 | ||
369 | spin_lock_irqsave(&ep->lock, flags); | 369 | spin_lock_irqsave(&ep->lock, flags); |
@@ -415,14 +415,12 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip, | |||
415 | struct usb_host_interface *alts, | 415 | struct usb_host_interface *alts, |
416 | int ep_num, int direction, int type) | 416 | int ep_num, int direction, int type) |
417 | { | 417 | { |
418 | struct list_head *p; | ||
419 | struct snd_usb_endpoint *ep; | 418 | struct snd_usb_endpoint *ep; |
420 | int is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK; | 419 | int is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK; |
421 | 420 | ||
422 | mutex_lock(&chip->mutex); | 421 | mutex_lock(&chip->mutex); |
423 | 422 | ||
424 | list_for_each(p, &chip->ep_list) { | 423 | list_for_each_entry(ep, &chip->ep_list, list) { |
425 | ep = list_entry(p, struct snd_usb_endpoint, list); | ||
426 | if (ep->ep_num == ep_num && | 424 | if (ep->ep_num == ep_num && |
427 | ep->iface == alts->desc.bInterfaceNumber && | 425 | ep->iface == alts->desc.bInterfaceNumber && |
428 | ep->alt_idx == alts->desc.bAlternateSetting) { | 426 | ep->alt_idx == alts->desc.bAlternateSetting) { |
@@ -580,6 +578,15 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep, | |||
580 | int is_playback = usb_pipeout(ep->pipe); | 578 | int is_playback = usb_pipeout(ep->pipe); |
581 | int frame_bits = snd_pcm_format_physical_width(pcm_format) * channels; | 579 | int frame_bits = snd_pcm_format_physical_width(pcm_format) * channels; |
582 | 580 | ||
581 | if (pcm_format == SNDRV_PCM_FORMAT_DSD_U16_LE && fmt->dsd_dop) { | ||
582 | /* | ||
583 | * When operating in DSD DOP mode, the size of a sample frame | ||
584 | * in hardware differs from the actual physical format width | ||
585 | * because we need to make room for the DOP markers. | ||
586 | */ | ||
587 | frame_bits += channels << 3; | ||
588 | } | ||
589 | |||
583 | ep->datainterval = fmt->datainterval; | 590 | ep->datainterval = fmt->datainterval; |
584 | ep->stride = frame_bits >> 3; | 591 | ep->stride = frame_bits >> 3; |
585 | ep->silence_value = pcm_format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0; | 592 | ep->silence_value = pcm_format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0; |
@@ -607,7 +614,7 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep, | |||
607 | else | 614 | else |
608 | packs_per_ms = 1; | 615 | packs_per_ms = 1; |
609 | 616 | ||
610 | if (is_playback && !snd_usb_endpoint_implict_feedback_sink(ep)) { | 617 | if (is_playback && !snd_usb_endpoint_implicit_feedback_sink(ep)) { |
611 | urb_packs = max(ep->chip->nrpacks, 1); | 618 | urb_packs = max(ep->chip->nrpacks, 1); |
612 | urb_packs = min(urb_packs, (unsigned int) MAX_PACKS); | 619 | urb_packs = min(urb_packs, (unsigned int) MAX_PACKS); |
613 | } else { | 620 | } else { |
@@ -616,11 +623,11 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep, | |||
616 | 623 | ||
617 | urb_packs *= packs_per_ms; | 624 | urb_packs *= packs_per_ms; |
618 | 625 | ||
619 | if (sync_ep && !snd_usb_endpoint_implict_feedback_sink(ep)) | 626 | if (sync_ep && !snd_usb_endpoint_implicit_feedback_sink(ep)) |
620 | urb_packs = min(urb_packs, 1U << sync_ep->syncinterval); | 627 | urb_packs = min(urb_packs, 1U << sync_ep->syncinterval); |
621 | 628 | ||
622 | /* decide how many packets to be used */ | 629 | /* decide how many packets to be used */ |
623 | if (is_playback && !snd_usb_endpoint_implict_feedback_sink(ep)) { | 630 | if (is_playback && !snd_usb_endpoint_implicit_feedback_sink(ep)) { |
624 | unsigned int minsize, maxpacks; | 631 | unsigned int minsize, maxpacks; |
625 | /* determine how small a packet can be */ | 632 | /* determine how small a packet can be */ |
626 | minsize = (ep->freqn >> (16 - ep->datainterval)) | 633 | minsize = (ep->freqn >> (16 - ep->datainterval)) |
@@ -847,7 +854,7 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, bool can_sleep) | |||
847 | 854 | ||
848 | set_bit(EP_FLAG_RUNNING, &ep->flags); | 855 | set_bit(EP_FLAG_RUNNING, &ep->flags); |
849 | 856 | ||
850 | if (snd_usb_endpoint_implict_feedback_sink(ep)) { | 857 | if (snd_usb_endpoint_implicit_feedback_sink(ep)) { |
851 | for (i = 0; i < ep->nurbs; i++) { | 858 | for (i = 0; i < ep->nurbs; i++) { |
852 | struct snd_urb_ctx *ctx = ep->urb + i; | 859 | struct snd_urb_ctx *ctx = ep->urb + i; |
853 | list_add_tail(&ctx->ready_list, &ep->ready_playback_urbs); | 860 | list_add_tail(&ctx->ready_list, &ep->ready_playback_urbs); |
@@ -990,7 +997,7 @@ void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep, | |||
990 | * and add it to the list of pending urbs. queue_pending_output_urbs() | 997 | * and add it to the list of pending urbs. queue_pending_output_urbs() |
991 | * will take care of them later. | 998 | * will take care of them later. |
992 | */ | 999 | */ |
993 | if (snd_usb_endpoint_implict_feedback_sink(ep) && | 1000 | if (snd_usb_endpoint_implicit_feedback_sink(ep) && |
994 | ep->use_count != 0) { | 1001 | ep->use_count != 0) { |
995 | 1002 | ||
996 | /* implicit feedback case */ | 1003 | /* implicit feedback case */ |
diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h index 447902dd8a4a..2287adf5ca59 100644 --- a/sound/usb/endpoint.h +++ b/sound/usb/endpoint.h | |||
@@ -23,7 +23,7 @@ int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); | |||
23 | int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); | 23 | int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); |
24 | void snd_usb_endpoint_free(struct list_head *head); | 24 | void snd_usb_endpoint_free(struct list_head *head); |
25 | 25 | ||
26 | int snd_usb_endpoint_implict_feedback_sink(struct snd_usb_endpoint *ep); | 26 | int snd_usb_endpoint_implicit_feedback_sink(struct snd_usb_endpoint *ep); |
27 | int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep); | 27 | int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep); |
28 | 28 | ||
29 | void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep, | 29 | void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep, |
diff --git a/sound/usb/format.c b/sound/usb/format.c index e831ee4238bb..020ede0259eb 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c | |||
@@ -43,11 +43,11 @@ | |||
43 | */ | 43 | */ |
44 | static u64 parse_audio_format_i_type(struct snd_usb_audio *chip, | 44 | static u64 parse_audio_format_i_type(struct snd_usb_audio *chip, |
45 | struct audioformat *fp, | 45 | struct audioformat *fp, |
46 | int format, void *_fmt, | 46 | unsigned int format, void *_fmt, |
47 | int protocol) | 47 | int protocol) |
48 | { | 48 | { |
49 | int sample_width, sample_bytes; | 49 | int sample_width, sample_bytes; |
50 | u64 pcm_formats; | 50 | u64 pcm_formats = 0; |
51 | 51 | ||
52 | switch (protocol) { | 52 | switch (protocol) { |
53 | case UAC_VERSION_1: | 53 | case UAC_VERSION_1: |
@@ -63,14 +63,17 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip, | |||
63 | struct uac_format_type_i_ext_descriptor *fmt = _fmt; | 63 | struct uac_format_type_i_ext_descriptor *fmt = _fmt; |
64 | sample_width = fmt->bBitResolution; | 64 | sample_width = fmt->bBitResolution; |
65 | sample_bytes = fmt->bSubslotSize; | 65 | sample_bytes = fmt->bSubslotSize; |
66 | |||
67 | if (format & UAC2_FORMAT_TYPE_I_RAW_DATA) | ||
68 | pcm_formats |= SNDRV_PCM_FMTBIT_SPECIAL; | ||
69 | |||
66 | format <<= 1; | 70 | format <<= 1; |
67 | break; | 71 | break; |
68 | } | 72 | } |
69 | } | 73 | } |
70 | 74 | ||
71 | pcm_formats = 0; | 75 | if ((pcm_formats == 0) && |
72 | 76 | (format == 0 || format == (1 << UAC_FORMAT_TYPE_I_UNDEFINED))) { | |
73 | if (format == 0 || format == (1 << UAC_FORMAT_TYPE_I_UNDEFINED)) { | ||
74 | /* some devices don't define this correctly... */ | 77 | /* some devices don't define this correctly... */ |
75 | snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", | 78 | snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", |
76 | chip->dev->devnum, fp->iface, fp->altsetting); | 79 | chip->dev->devnum, fp->iface, fp->altsetting); |
@@ -133,6 +136,9 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip, | |||
133 | snd_printk(KERN_INFO "%d:%u:%d : unsupported format bits %#x\n", | 136 | snd_printk(KERN_INFO "%d:%u:%d : unsupported format bits %#x\n", |
134 | chip->dev->devnum, fp->iface, fp->altsetting, format); | 137 | chip->dev->devnum, fp->iface, fp->altsetting, format); |
135 | } | 138 | } |
139 | |||
140 | pcm_formats |= snd_usb_interface_dsd_format_quirks(chip, fp, sample_bytes); | ||
141 | |||
136 | return pcm_formats; | 142 | return pcm_formats; |
137 | } | 143 | } |
138 | 144 | ||
@@ -277,7 +283,7 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, | |||
277 | struct usb_device *dev = chip->dev; | 283 | struct usb_device *dev = chip->dev; |
278 | unsigned char tmp[2], *data; | 284 | unsigned char tmp[2], *data; |
279 | int nr_triplets, data_size, ret = 0; | 285 | int nr_triplets, data_size, ret = 0; |
280 | int clock = snd_usb_clock_find_source(chip, fp->clock); | 286 | int clock = snd_usb_clock_find_source(chip, fp->clock, false); |
281 | 287 | ||
282 | if (clock < 0) { | 288 | if (clock < 0) { |
283 | snd_printk(KERN_ERR "%s(): unable to find clock source (clock %d)\n", | 289 | snd_printk(KERN_ERR "%s(): unable to find clock source (clock %d)\n", |
@@ -353,7 +359,7 @@ err: | |||
353 | * parse the format type I and III descriptors | 359 | * parse the format type I and III descriptors |
354 | */ | 360 | */ |
355 | static int parse_audio_format_i(struct snd_usb_audio *chip, | 361 | static int parse_audio_format_i(struct snd_usb_audio *chip, |
356 | struct audioformat *fp, int format, | 362 | struct audioformat *fp, unsigned int format, |
357 | struct uac_format_type_i_continuous_descriptor *fmt, | 363 | struct uac_format_type_i_continuous_descriptor *fmt, |
358 | struct usb_host_interface *iface) | 364 | struct usb_host_interface *iface) |
359 | { | 365 | { |
@@ -473,8 +479,9 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, | |||
473 | return ret; | 479 | return ret; |
474 | } | 480 | } |
475 | 481 | ||
476 | int snd_usb_parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp, | 482 | int snd_usb_parse_audio_format(struct snd_usb_audio *chip, |
477 | int format, struct uac_format_type_i_continuous_descriptor *fmt, | 483 | struct audioformat *fp, unsigned int format, |
484 | struct uac_format_type_i_continuous_descriptor *fmt, | ||
478 | int stream, struct usb_host_interface *iface) | 485 | int stream, struct usb_host_interface *iface) |
479 | { | 486 | { |
480 | int err; | 487 | int err; |
diff --git a/sound/usb/format.h b/sound/usb/format.h index 387924f0af85..6f315226f320 100644 --- a/sound/usb/format.h +++ b/sound/usb/format.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #define __USBAUDIO_FORMAT_H | 2 | #define __USBAUDIO_FORMAT_H |
3 | 3 | ||
4 | int snd_usb_parse_audio_format(struct snd_usb_audio *chip, | 4 | int snd_usb_parse_audio_format(struct snd_usb_audio *chip, |
5 | struct audioformat *fp, int format, | 5 | struct audioformat *fp, unsigned int format, |
6 | struct uac_format_type_i_continuous_descriptor *fmt, | 6 | struct uac_format_type_i_continuous_descriptor *fmt, |
7 | int stream, struct usb_host_interface *iface); | 7 | int stream, struct usb_host_interface *iface); |
8 | 8 | ||
diff --git a/sound/usb/helper.c b/sound/usb/helper.c index c1db28f874c2..620902463c6e 100644 --- a/sound/usb/helper.c +++ b/sound/usb/helper.c | |||
@@ -86,14 +86,22 @@ int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, | |||
86 | { | 86 | { |
87 | int err; | 87 | int err; |
88 | void *buf = NULL; | 88 | void *buf = NULL; |
89 | int timeout; | ||
89 | 90 | ||
90 | if (size > 0) { | 91 | if (size > 0) { |
91 | buf = kmemdup(data, size, GFP_KERNEL); | 92 | buf = kmemdup(data, size, GFP_KERNEL); |
92 | if (!buf) | 93 | if (!buf) |
93 | return -ENOMEM; | 94 | return -ENOMEM; |
94 | } | 95 | } |
96 | |||
97 | if (requesttype & USB_DIR_IN) | ||
98 | timeout = USB_CTRL_GET_TIMEOUT; | ||
99 | else | ||
100 | timeout = USB_CTRL_SET_TIMEOUT; | ||
101 | |||
95 | err = usb_control_msg(dev, pipe, request, requesttype, | 102 | err = usb_control_msg(dev, pipe, request, requesttype, |
96 | value, index, buf, size, 1000); | 103 | value, index, buf, size, timeout); |
104 | |||
97 | if (size > 0) { | 105 | if (size > 0) { |
98 | memcpy(data, buf, size); | 106 | memcpy(data, buf, size); |
99 | kfree(buf); | 107 | kfree(buf); |
diff --git a/sound/usb/midi.c b/sound/usb/midi.c index 34b9bb7fe87c..8e01fa4991c5 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c | |||
@@ -126,7 +126,6 @@ struct snd_usb_midi { | |||
126 | struct snd_usb_midi_in_endpoint *in; | 126 | struct snd_usb_midi_in_endpoint *in; |
127 | } endpoints[MIDI_MAX_ENDPOINTS]; | 127 | } endpoints[MIDI_MAX_ENDPOINTS]; |
128 | unsigned long input_triggered; | 128 | unsigned long input_triggered; |
129 | bool autopm_reference; | ||
130 | unsigned int opened[2]; | 129 | unsigned int opened[2]; |
131 | unsigned char disconnected; | 130 | unsigned char disconnected; |
132 | unsigned char input_running; | 131 | unsigned char input_running; |
@@ -1040,7 +1039,6 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir, | |||
1040 | { | 1039 | { |
1041 | struct snd_usb_midi* umidi = substream->rmidi->private_data; | 1040 | struct snd_usb_midi* umidi = substream->rmidi->private_data; |
1042 | struct snd_kcontrol *ctl; | 1041 | struct snd_kcontrol *ctl; |
1043 | int err; | ||
1044 | 1042 | ||
1045 | down_read(&umidi->disc_rwsem); | 1043 | down_read(&umidi->disc_rwsem); |
1046 | if (umidi->disconnected) { | 1044 | if (umidi->disconnected) { |
@@ -1051,13 +1049,6 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir, | |||
1051 | mutex_lock(&umidi->mutex); | 1049 | mutex_lock(&umidi->mutex); |
1052 | if (open) { | 1050 | if (open) { |
1053 | if (!umidi->opened[0] && !umidi->opened[1]) { | 1051 | if (!umidi->opened[0] && !umidi->opened[1]) { |
1054 | err = usb_autopm_get_interface(umidi->iface); | ||
1055 | umidi->autopm_reference = err >= 0; | ||
1056 | if (err < 0 && err != -EACCES) { | ||
1057 | mutex_unlock(&umidi->mutex); | ||
1058 | up_read(&umidi->disc_rwsem); | ||
1059 | return -EIO; | ||
1060 | } | ||
1061 | if (umidi->roland_load_ctl) { | 1052 | if (umidi->roland_load_ctl) { |
1062 | ctl = umidi->roland_load_ctl; | 1053 | ctl = umidi->roland_load_ctl; |
1063 | ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; | 1054 | ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; |
@@ -1080,8 +1071,6 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir, | |||
1080 | snd_ctl_notify(umidi->card, | 1071 | snd_ctl_notify(umidi->card, |
1081 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); | 1072 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
1082 | } | 1073 | } |
1083 | if (umidi->autopm_reference) | ||
1084 | usb_autopm_put_interface(umidi->iface); | ||
1085 | } | 1074 | } |
1086 | } | 1075 | } |
1087 | mutex_unlock(&umidi->mutex); | 1076 | mutex_unlock(&umidi->mutex); |
@@ -1455,6 +1444,7 @@ void snd_usbmidi_disconnect(struct list_head* p) | |||
1455 | } | 1444 | } |
1456 | del_timer_sync(&umidi->error_timer); | 1445 | del_timer_sync(&umidi->error_timer); |
1457 | } | 1446 | } |
1447 | EXPORT_SYMBOL(snd_usbmidi_disconnect); | ||
1458 | 1448 | ||
1459 | static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi) | 1449 | static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi) |
1460 | { | 1450 | { |
@@ -1465,10 +1455,9 @@ static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi) | |||
1465 | static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi, | 1455 | static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi, |
1466 | int stream, int number) | 1456 | int stream, int number) |
1467 | { | 1457 | { |
1468 | struct list_head* list; | 1458 | struct snd_rawmidi_substream *substream; |
1469 | 1459 | ||
1470 | list_for_each(list, &umidi->rmidi->streams[stream].substreams) { | 1460 | list_for_each_entry(substream, &umidi->rmidi->streams[stream].substreams, list) { |
1471 | struct snd_rawmidi_substream *substream = list_entry(list, struct snd_rawmidi_substream, list); | ||
1472 | if (substream->number == number) | 1461 | if (substream->number == number) |
1473 | return substream; | 1462 | return substream; |
1474 | } | 1463 | } |
@@ -2091,6 +2080,7 @@ void snd_usbmidi_input_stop(struct list_head* p) | |||
2091 | } | 2080 | } |
2092 | umidi->input_running = 0; | 2081 | umidi->input_running = 0; |
2093 | } | 2082 | } |
2083 | EXPORT_SYMBOL(snd_usbmidi_input_stop); | ||
2094 | 2084 | ||
2095 | static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep) | 2085 | static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep) |
2096 | { | 2086 | { |
@@ -2120,6 +2110,7 @@ void snd_usbmidi_input_start(struct list_head* p) | |||
2120 | snd_usbmidi_input_start_ep(umidi->endpoints[i].in); | 2110 | snd_usbmidi_input_start_ep(umidi->endpoints[i].in); |
2121 | umidi->input_running = 1; | 2111 | umidi->input_running = 1; |
2122 | } | 2112 | } |
2113 | EXPORT_SYMBOL(snd_usbmidi_input_start); | ||
2123 | 2114 | ||
2124 | /* | 2115 | /* |
2125 | * Creates and registers everything needed for a MIDI streaming interface. | 2116 | * Creates and registers everything needed for a MIDI streaming interface. |
@@ -2256,11 +2247,9 @@ int snd_usbmidi_create(struct snd_card *card, | |||
2256 | return err; | 2247 | return err; |
2257 | } | 2248 | } |
2258 | 2249 | ||
2250 | usb_autopm_get_interface_no_resume(umidi->iface); | ||
2251 | |||
2259 | list_add_tail(&umidi->list, midi_list); | 2252 | list_add_tail(&umidi->list, midi_list); |
2260 | return 0; | 2253 | return 0; |
2261 | } | 2254 | } |
2262 | |||
2263 | EXPORT_SYMBOL(snd_usbmidi_create); | 2255 | EXPORT_SYMBOL(snd_usbmidi_create); |
2264 | EXPORT_SYMBOL(snd_usbmidi_input_stop); | ||
2265 | EXPORT_SYMBOL(snd_usbmidi_input_start); | ||
2266 | EXPORT_SYMBOL(snd_usbmidi_disconnect); | ||
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index f94397b42aa5..9723f3ceb155 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/bitrev.h> | ||
19 | #include <linux/ratelimit.h> | 20 | #include <linux/ratelimit.h> |
20 | #include <linux/usb.h> | 21 | #include <linux/usb.h> |
21 | #include <linux/usb/audio.h> | 22 | #include <linux/usb/audio.h> |
@@ -94,13 +95,11 @@ static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream | |||
94 | */ | 95 | */ |
95 | static struct audioformat *find_format(struct snd_usb_substream *subs) | 96 | static struct audioformat *find_format(struct snd_usb_substream *subs) |
96 | { | 97 | { |
97 | struct list_head *p; | 98 | struct audioformat *fp; |
98 | struct audioformat *found = NULL; | 99 | struct audioformat *found = NULL; |
99 | int cur_attr = 0, attr; | 100 | int cur_attr = 0, attr; |
100 | 101 | ||
101 | list_for_each(p, &subs->fmt_list) { | 102 | list_for_each_entry(fp, &subs->fmt_list, list) { |
102 | struct audioformat *fp; | ||
103 | fp = list_entry(p, struct audioformat, list); | ||
104 | if (!(fp->formats & (1uLL << subs->pcm_format))) | 103 | if (!(fp->formats & (1uLL << subs->pcm_format))) |
105 | continue; | 104 | continue; |
106 | if (fp->channels != subs->channels) | 105 | if (fp->channels != subs->channels) |
@@ -350,6 +349,8 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
350 | fmt->iface, fmt->altsetting); | 349 | fmt->iface, fmt->altsetting); |
351 | subs->interface = fmt->iface; | 350 | subs->interface = fmt->iface; |
352 | subs->altset_idx = fmt->altset_idx; | 351 | subs->altset_idx = fmt->altset_idx; |
352 | |||
353 | snd_usb_set_interface_quirk(dev); | ||
353 | } | 354 | } |
354 | 355 | ||
355 | subs->data_endpoint = snd_usb_add_endpoint(subs->stream->chip, | 356 | subs->data_endpoint = snd_usb_add_endpoint(subs->stream->chip, |
@@ -802,7 +803,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params, | |||
802 | struct snd_pcm_hw_rule *rule) | 803 | struct snd_pcm_hw_rule *rule) |
803 | { | 804 | { |
804 | struct snd_usb_substream *subs = rule->private; | 805 | struct snd_usb_substream *subs = rule->private; |
805 | struct list_head *p; | 806 | struct audioformat *fp; |
806 | struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); | 807 | struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); |
807 | unsigned int rmin, rmax; | 808 | unsigned int rmin, rmax; |
808 | int changed; | 809 | int changed; |
@@ -810,9 +811,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params, | |||
810 | hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max); | 811 | hwc_debug("hw_rule_rate: (%d,%d)\n", it->min, it->max); |
811 | changed = 0; | 812 | changed = 0; |
812 | rmin = rmax = 0; | 813 | rmin = rmax = 0; |
813 | list_for_each(p, &subs->fmt_list) { | 814 | list_for_each_entry(fp, &subs->fmt_list, list) { |
814 | struct audioformat *fp; | ||
815 | fp = list_entry(p, struct audioformat, list); | ||
816 | if (!hw_check_valid_format(subs, params, fp)) | 815 | if (!hw_check_valid_format(subs, params, fp)) |
817 | continue; | 816 | continue; |
818 | if (changed++) { | 817 | if (changed++) { |
@@ -856,7 +855,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, | |||
856 | struct snd_pcm_hw_rule *rule) | 855 | struct snd_pcm_hw_rule *rule) |
857 | { | 856 | { |
858 | struct snd_usb_substream *subs = rule->private; | 857 | struct snd_usb_substream *subs = rule->private; |
859 | struct list_head *p; | 858 | struct audioformat *fp; |
860 | struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); | 859 | struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); |
861 | unsigned int rmin, rmax; | 860 | unsigned int rmin, rmax; |
862 | int changed; | 861 | int changed; |
@@ -864,9 +863,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, | |||
864 | hwc_debug("hw_rule_channels: (%d,%d)\n", it->min, it->max); | 863 | hwc_debug("hw_rule_channels: (%d,%d)\n", it->min, it->max); |
865 | changed = 0; | 864 | changed = 0; |
866 | rmin = rmax = 0; | 865 | rmin = rmax = 0; |
867 | list_for_each(p, &subs->fmt_list) { | 866 | list_for_each_entry(fp, &subs->fmt_list, list) { |
868 | struct audioformat *fp; | ||
869 | fp = list_entry(p, struct audioformat, list); | ||
870 | if (!hw_check_valid_format(subs, params, fp)) | 867 | if (!hw_check_valid_format(subs, params, fp)) |
871 | continue; | 868 | continue; |
872 | if (changed++) { | 869 | if (changed++) { |
@@ -909,7 +906,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params, | |||
909 | struct snd_pcm_hw_rule *rule) | 906 | struct snd_pcm_hw_rule *rule) |
910 | { | 907 | { |
911 | struct snd_usb_substream *subs = rule->private; | 908 | struct snd_usb_substream *subs = rule->private; |
912 | struct list_head *p; | 909 | struct audioformat *fp; |
913 | struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); | 910 | struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); |
914 | u64 fbits; | 911 | u64 fbits; |
915 | u32 oldbits[2]; | 912 | u32 oldbits[2]; |
@@ -917,9 +914,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params, | |||
917 | 914 | ||
918 | hwc_debug("hw_rule_format: %x:%x\n", fmt->bits[0], fmt->bits[1]); | 915 | hwc_debug("hw_rule_format: %x:%x\n", fmt->bits[0], fmt->bits[1]); |
919 | fbits = 0; | 916 | fbits = 0; |
920 | list_for_each(p, &subs->fmt_list) { | 917 | list_for_each_entry(fp, &subs->fmt_list, list) { |
921 | struct audioformat *fp; | ||
922 | fp = list_entry(p, struct audioformat, list); | ||
923 | if (!hw_check_valid_format(subs, params, fp)) | 918 | if (!hw_check_valid_format(subs, params, fp)) |
924 | continue; | 919 | continue; |
925 | fbits |= fp->formats; | 920 | fbits |= fp->formats; |
@@ -1027,7 +1022,7 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime, | |||
1027 | 1022 | ||
1028 | static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) | 1023 | static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) |
1029 | { | 1024 | { |
1030 | struct list_head *p; | 1025 | struct audioformat *fp; |
1031 | unsigned int pt, ptmin; | 1026 | unsigned int pt, ptmin; |
1032 | int param_period_time_if_needed; | 1027 | int param_period_time_if_needed; |
1033 | int err; | 1028 | int err; |
@@ -1041,9 +1036,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre | |||
1041 | runtime->hw.rates = 0; | 1036 | runtime->hw.rates = 0; |
1042 | ptmin = UINT_MAX; | 1037 | ptmin = UINT_MAX; |
1043 | /* check min/max rates and channels */ | 1038 | /* check min/max rates and channels */ |
1044 | list_for_each(p, &subs->fmt_list) { | 1039 | list_for_each_entry(fp, &subs->fmt_list, list) { |
1045 | struct audioformat *fp; | ||
1046 | fp = list_entry(p, struct audioformat, list); | ||
1047 | runtime->hw.rates |= fp->rates; | 1040 | runtime->hw.rates |= fp->rates; |
1048 | if (runtime->hw.rate_min > fp->rate_min) | 1041 | if (runtime->hw.rate_min > fp->rate_min) |
1049 | runtime->hw.rate_min = fp->rate_min; | 1042 | runtime->hw.rate_min = fp->rate_min; |
@@ -1128,6 +1121,12 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction) | |||
1128 | runtime->private_data = subs; | 1121 | runtime->private_data = subs; |
1129 | subs->pcm_substream = substream; | 1122 | subs->pcm_substream = substream; |
1130 | /* runtime PM is also done there */ | 1123 | /* runtime PM is also done there */ |
1124 | |||
1125 | /* initialize DSD/DOP context */ | ||
1126 | subs->dsd_dop.byte_idx = 0; | ||
1127 | subs->dsd_dop.channel = 0; | ||
1128 | subs->dsd_dop.marker = 1; | ||
1129 | |||
1131 | return setup_hw_info(runtime, subs); | 1130 | return setup_hw_info(runtime, subs); |
1132 | } | 1131 | } |
1133 | 1132 | ||
@@ -1170,7 +1169,7 @@ static void retire_capture_urb(struct snd_usb_substream *subs, | |||
1170 | stride = runtime->frame_bits >> 3; | 1169 | stride = runtime->frame_bits >> 3; |
1171 | 1170 | ||
1172 | for (i = 0; i < urb->number_of_packets; i++) { | 1171 | for (i = 0; i < urb->number_of_packets; i++) { |
1173 | cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset; | 1172 | cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset + subs->pkt_offset_adj; |
1174 | if (urb->iso_frame_desc[i].status && printk_ratelimit()) { | 1173 | if (urb->iso_frame_desc[i].status && printk_ratelimit()) { |
1175 | snd_printdd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status); | 1174 | snd_printdd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status); |
1176 | // continue; | 1175 | // continue; |
@@ -1222,6 +1221,61 @@ static void retire_capture_urb(struct snd_usb_substream *subs, | |||
1222 | snd_pcm_period_elapsed(subs->pcm_substream); | 1221 | snd_pcm_period_elapsed(subs->pcm_substream); |
1223 | } | 1222 | } |
1224 | 1223 | ||
1224 | static inline void fill_playback_urb_dsd_dop(struct snd_usb_substream *subs, | ||
1225 | struct urb *urb, unsigned int bytes) | ||
1226 | { | ||
1227 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; | ||
1228 | unsigned int stride = runtime->frame_bits >> 3; | ||
1229 | unsigned int dst_idx = 0; | ||
1230 | unsigned int src_idx = subs->hwptr_done; | ||
1231 | unsigned int wrap = runtime->buffer_size * stride; | ||
1232 | u8 *dst = urb->transfer_buffer; | ||
1233 | u8 *src = runtime->dma_area; | ||
1234 | u8 marker[] = { 0x05, 0xfa }; | ||
1235 | |||
1236 | /* | ||
1237 | * The DSP DOP format defines a way to transport DSD samples over | ||
1238 | * normal PCM data endpoints. It requires stuffing of marker bytes | ||
1239 | * (0x05 and 0xfa, alternating per sample frame), and then expects | ||
1240 | * 2 additional bytes of actual payload. The whole frame is stored | ||
1241 | * LSB. | ||
1242 | * | ||
1243 | * Hence, for a stereo transport, the buffer layout looks like this, | ||
1244 | * where L refers to left channel samples and R to right. | ||
1245 | * | ||
1246 | * L1 L2 0x05 R1 R2 0x05 L3 L4 0xfa R3 R4 0xfa | ||
1247 | * L5 L6 0x05 R5 R6 0x05 L7 L8 0xfa R7 R8 0xfa | ||
1248 | * ..... | ||
1249 | * | ||
1250 | */ | ||
1251 | |||
1252 | while (bytes--) { | ||
1253 | if (++subs->dsd_dop.byte_idx == 3) { | ||
1254 | /* frame boundary? */ | ||
1255 | dst[dst_idx++] = marker[subs->dsd_dop.marker]; | ||
1256 | src_idx += 2; | ||
1257 | subs->dsd_dop.byte_idx = 0; | ||
1258 | |||
1259 | if (++subs->dsd_dop.channel % runtime->channels == 0) { | ||
1260 | /* alternate the marker */ | ||
1261 | subs->dsd_dop.marker++; | ||
1262 | subs->dsd_dop.marker %= ARRAY_SIZE(marker); | ||
1263 | subs->dsd_dop.channel = 0; | ||
1264 | } | ||
1265 | } else { | ||
1266 | /* stuff the DSD payload */ | ||
1267 | int idx = (src_idx + subs->dsd_dop.byte_idx - 1) % wrap; | ||
1268 | |||
1269 | if (subs->cur_audiofmt->dsd_bitrev) | ||
1270 | dst[dst_idx++] = bitrev8(src[idx]); | ||
1271 | else | ||
1272 | dst[dst_idx++] = src[idx]; | ||
1273 | |||
1274 | subs->hwptr_done++; | ||
1275 | } | ||
1276 | } | ||
1277 | } | ||
1278 | |||
1225 | static void prepare_playback_urb(struct snd_usb_substream *subs, | 1279 | static void prepare_playback_urb(struct snd_usb_substream *subs, |
1226 | struct urb *urb) | 1280 | struct urb *urb) |
1227 | { | 1281 | { |
@@ -1244,8 +1298,8 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, | |||
1244 | counts = snd_usb_endpoint_next_packet_size(ep); | 1298 | counts = snd_usb_endpoint_next_packet_size(ep); |
1245 | 1299 | ||
1246 | /* set up descriptor */ | 1300 | /* set up descriptor */ |
1247 | urb->iso_frame_desc[i].offset = frames * stride; | 1301 | urb->iso_frame_desc[i].offset = frames * ep->stride; |
1248 | urb->iso_frame_desc[i].length = counts * stride; | 1302 | urb->iso_frame_desc[i].length = counts * ep->stride; |
1249 | frames += counts; | 1303 | frames += counts; |
1250 | urb->number_of_packets++; | 1304 | urb->number_of_packets++; |
1251 | subs->transfer_done += counts; | 1305 | subs->transfer_done += counts; |
@@ -1259,14 +1313,14 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, | |||
1259 | frames -= subs->transfer_done; | 1313 | frames -= subs->transfer_done; |
1260 | counts -= subs->transfer_done; | 1314 | counts -= subs->transfer_done; |
1261 | urb->iso_frame_desc[i].length = | 1315 | urb->iso_frame_desc[i].length = |
1262 | counts * stride; | 1316 | counts * ep->stride; |
1263 | subs->transfer_done = 0; | 1317 | subs->transfer_done = 0; |
1264 | } | 1318 | } |
1265 | i++; | 1319 | i++; |
1266 | if (i < ctx->packets) { | 1320 | if (i < ctx->packets) { |
1267 | /* add a transfer delimiter */ | 1321 | /* add a transfer delimiter */ |
1268 | urb->iso_frame_desc[i].offset = | 1322 | urb->iso_frame_desc[i].offset = |
1269 | frames * stride; | 1323 | frames * ep->stride; |
1270 | urb->iso_frame_desc[i].length = 0; | 1324 | urb->iso_frame_desc[i].length = 0; |
1271 | urb->number_of_packets++; | 1325 | urb->number_of_packets++; |
1272 | } | 1326 | } |
@@ -1274,23 +1328,43 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, | |||
1274 | } | 1328 | } |
1275 | } | 1329 | } |
1276 | if (period_elapsed && | 1330 | if (period_elapsed && |
1277 | !snd_usb_endpoint_implict_feedback_sink(subs->data_endpoint)) /* finish at the period boundary */ | 1331 | !snd_usb_endpoint_implicit_feedback_sink(subs->data_endpoint)) /* finish at the period boundary */ |
1278 | break; | 1332 | break; |
1279 | } | 1333 | } |
1280 | bytes = frames * stride; | 1334 | bytes = frames * ep->stride; |
1281 | if (subs->hwptr_done + bytes > runtime->buffer_size * stride) { | 1335 | |
1282 | /* err, the transferred area goes over buffer boundary. */ | 1336 | if (unlikely(subs->pcm_format == SNDRV_PCM_FORMAT_DSD_U16_LE && |
1283 | unsigned int bytes1 = | 1337 | subs->cur_audiofmt->dsd_dop)) { |
1284 | runtime->buffer_size * stride - subs->hwptr_done; | 1338 | fill_playback_urb_dsd_dop(subs, urb, bytes); |
1285 | memcpy(urb->transfer_buffer, | 1339 | } else if (unlikely(subs->pcm_format == SNDRV_PCM_FORMAT_DSD_U8 && |
1286 | runtime->dma_area + subs->hwptr_done, bytes1); | 1340 | subs->cur_audiofmt->dsd_bitrev)) { |
1287 | memcpy(urb->transfer_buffer + bytes1, | 1341 | /* bit-reverse the bytes */ |
1288 | runtime->dma_area, bytes - bytes1); | 1342 | u8 *buf = urb->transfer_buffer; |
1343 | for (i = 0; i < bytes; i++) { | ||
1344 | int idx = (subs->hwptr_done + i) | ||
1345 | % (runtime->buffer_size * stride); | ||
1346 | buf[i] = bitrev8(runtime->dma_area[idx]); | ||
1347 | } | ||
1348 | |||
1349 | subs->hwptr_done += bytes; | ||
1289 | } else { | 1350 | } else { |
1290 | memcpy(urb->transfer_buffer, | 1351 | /* usual PCM */ |
1291 | runtime->dma_area + subs->hwptr_done, bytes); | 1352 | if (subs->hwptr_done + bytes > runtime->buffer_size * stride) { |
1353 | /* err, the transferred area goes over buffer boundary. */ | ||
1354 | unsigned int bytes1 = | ||
1355 | runtime->buffer_size * stride - subs->hwptr_done; | ||
1356 | memcpy(urb->transfer_buffer, | ||
1357 | runtime->dma_area + subs->hwptr_done, bytes1); | ||
1358 | memcpy(urb->transfer_buffer + bytes1, | ||
1359 | runtime->dma_area, bytes - bytes1); | ||
1360 | } else { | ||
1361 | memcpy(urb->transfer_buffer, | ||
1362 | runtime->dma_area + subs->hwptr_done, bytes); | ||
1363 | } | ||
1364 | |||
1365 | subs->hwptr_done += bytes; | ||
1292 | } | 1366 | } |
1293 | subs->hwptr_done += bytes; | 1367 | |
1294 | if (subs->hwptr_done >= runtime->buffer_size * stride) | 1368 | if (subs->hwptr_done >= runtime->buffer_size * stride) |
1295 | subs->hwptr_done -= runtime->buffer_size * stride; | 1369 | subs->hwptr_done -= runtime->buffer_size * stride; |
1296 | 1370 | ||
@@ -1318,8 +1392,8 @@ static void retire_playback_urb(struct snd_usb_substream *subs, | |||
1318 | { | 1392 | { |
1319 | unsigned long flags; | 1393 | unsigned long flags; |
1320 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; | 1394 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
1321 | int stride = runtime->frame_bits >> 3; | 1395 | struct snd_usb_endpoint *ep = subs->data_endpoint; |
1322 | int processed = urb->transfer_buffer_length / stride; | 1396 | int processed = urb->transfer_buffer_length / ep->stride; |
1323 | int est_delay; | 1397 | int est_delay; |
1324 | 1398 | ||
1325 | /* ignore the delay accounting when procssed=0 is given, i.e. | 1399 | /* ignore the delay accounting when procssed=0 is given, i.e. |
diff --git a/sound/usb/proc.c b/sound/usb/proc.c index d218f763501f..0182ef634d8b 100644 --- a/sound/usb/proc.c +++ b/sound/usb/proc.c | |||
@@ -73,15 +73,14 @@ void snd_usb_audio_create_proc(struct snd_usb_audio *chip) | |||
73 | */ | 73 | */ |
74 | static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct snd_info_buffer *buffer) | 74 | static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct snd_info_buffer *buffer) |
75 | { | 75 | { |
76 | struct list_head *p; | 76 | struct audioformat *fp; |
77 | static char *sync_types[4] = { | 77 | static char *sync_types[4] = { |
78 | "NONE", "ASYNC", "ADAPTIVE", "SYNC" | 78 | "NONE", "ASYNC", "ADAPTIVE", "SYNC" |
79 | }; | 79 | }; |
80 | 80 | ||
81 | list_for_each(p, &subs->fmt_list) { | 81 | list_for_each_entry(fp, &subs->fmt_list, list) { |
82 | struct audioformat *fp; | ||
83 | snd_pcm_format_t fmt; | 82 | snd_pcm_format_t fmt; |
84 | fp = list_entry(p, struct audioformat, list); | 83 | |
85 | snd_iprintf(buffer, " Interface %d\n", fp->iface); | 84 | snd_iprintf(buffer, " Interface %d\n", fp->iface); |
86 | snd_iprintf(buffer, " Altset %d\n", fp->altsetting); | 85 | snd_iprintf(buffer, " Altset %d\n", fp->altsetting); |
87 | snd_iprintf(buffer, " Format:"); | 86 | snd_iprintf(buffer, " Format:"); |
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index c39f898b15d2..7f1722f82c89 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h | |||
@@ -353,6 +353,84 @@ YAMAHA_DEVICE(0x105d, NULL), | |||
353 | } | 353 | } |
354 | } | 354 | } |
355 | }, | 355 | }, |
356 | { | ||
357 | USB_DEVICE(0x0499, 0x1507), | ||
358 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
359 | /* .vendor_name = "Yamaha", */ | ||
360 | /* .product_name = "THR10", */ | ||
361 | .ifnum = QUIRK_ANY_INTERFACE, | ||
362 | .type = QUIRK_COMPOSITE, | ||
363 | .data = (const struct snd_usb_audio_quirk[]) { | ||
364 | { | ||
365 | .ifnum = 1, | ||
366 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
367 | }, | ||
368 | { | ||
369 | .ifnum = 2, | ||
370 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
371 | }, | ||
372 | { | ||
373 | .ifnum = 3, | ||
374 | .type = QUIRK_MIDI_YAMAHA | ||
375 | }, | ||
376 | { | ||
377 | .ifnum = -1 | ||
378 | } | ||
379 | } | ||
380 | } | ||
381 | }, | ||
382 | { | ||
383 | USB_DEVICE(0x0499, 0x150a), | ||
384 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
385 | /* .vendor_name = "Yamaha", */ | ||
386 | /* .product_name = "THR5A", */ | ||
387 | .ifnum = QUIRK_ANY_INTERFACE, | ||
388 | .type = QUIRK_COMPOSITE, | ||
389 | .data = (const struct snd_usb_audio_quirk[]) { | ||
390 | { | ||
391 | .ifnum = 1, | ||
392 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
393 | }, | ||
394 | { | ||
395 | .ifnum = 2, | ||
396 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
397 | }, | ||
398 | { | ||
399 | .ifnum = 3, | ||
400 | .type = QUIRK_MIDI_YAMAHA | ||
401 | }, | ||
402 | { | ||
403 | .ifnum = -1 | ||
404 | } | ||
405 | } | ||
406 | } | ||
407 | }, | ||
408 | { | ||
409 | USB_DEVICE(0x0499, 0x150c), | ||
410 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
411 | /* .vendor_name = "Yamaha", */ | ||
412 | /* .product_name = "THR10C", */ | ||
413 | .ifnum = QUIRK_ANY_INTERFACE, | ||
414 | .type = QUIRK_COMPOSITE, | ||
415 | .data = (const struct snd_usb_audio_quirk[]) { | ||
416 | { | ||
417 | .ifnum = 1, | ||
418 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
419 | }, | ||
420 | { | ||
421 | .ifnum = 2, | ||
422 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
423 | }, | ||
424 | { | ||
425 | .ifnum = 3, | ||
426 | .type = QUIRK_MIDI_YAMAHA | ||
427 | }, | ||
428 | { | ||
429 | .ifnum = -1 | ||
430 | } | ||
431 | } | ||
432 | } | ||
433 | }, | ||
356 | YAMAHA_DEVICE(0x2000, "DGP-7"), | 434 | YAMAHA_DEVICE(0x2000, "DGP-7"), |
357 | YAMAHA_DEVICE(0x2001, "DGP-5"), | 435 | YAMAHA_DEVICE(0x2001, "DGP-5"), |
358 | YAMAHA_DEVICE(0x2002, NULL), | 436 | YAMAHA_DEVICE(0x2002, NULL), |
@@ -2748,6 +2826,46 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
2748 | } | 2826 | } |
2749 | }, | 2827 | }, |
2750 | { | 2828 | { |
2829 | USB_DEVICE(0x1235, 0x0018), | ||
2830 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
2831 | .vendor_name = "Novation", | ||
2832 | .product_name = "Twitch", | ||
2833 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2834 | .type = QUIRK_COMPOSITE, | ||
2835 | .data = (const struct snd_usb_audio_quirk[]) { | ||
2836 | { | ||
2837 | .ifnum = 0, | ||
2838 | .type = QUIRK_AUDIO_FIXED_ENDPOINT, | ||
2839 | .data = & (const struct audioformat) { | ||
2840 | .formats = SNDRV_PCM_FMTBIT_S24_3LE, | ||
2841 | .channels = 4, | ||
2842 | .iface = 0, | ||
2843 | .altsetting = 1, | ||
2844 | .altset_idx = 1, | ||
2845 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, | ||
2846 | .endpoint = 0x01, | ||
2847 | .ep_attr = USB_ENDPOINT_XFER_ISOC, | ||
2848 | .rates = SNDRV_PCM_RATE_44100 | | ||
2849 | SNDRV_PCM_RATE_48000, | ||
2850 | .rate_min = 44100, | ||
2851 | .rate_max = 48000, | ||
2852 | .nr_rates = 2, | ||
2853 | .rate_table = (unsigned int[]) { | ||
2854 | 44100, 48000 | ||
2855 | } | ||
2856 | } | ||
2857 | }, | ||
2858 | { | ||
2859 | .ifnum = 1, | ||
2860 | .type = QUIRK_MIDI_RAW_BYTES | ||
2861 | }, | ||
2862 | { | ||
2863 | .ifnum = -1 | ||
2864 | } | ||
2865 | } | ||
2866 | } | ||
2867 | }, | ||
2868 | { | ||
2751 | USB_DEVICE_VENDOR_SPEC(0x1235, 0x4661), | 2869 | USB_DEVICE_VENDOR_SPEC(0x1235, 0x4661), |
2752 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | 2870 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { |
2753 | .vendor_name = "Novation", | 2871 | .vendor_name = "Novation", |
@@ -2996,7 +3114,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
2996 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, | 3114 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, |
2997 | .endpoint = 0x02, | 3115 | .endpoint = 0x02, |
2998 | .ep_attr = 0x01, | 3116 | .ep_attr = 0x01, |
2999 | .maxpacksize = 0x130, | ||
3000 | .rates = SNDRV_PCM_RATE_44100 | | 3117 | .rates = SNDRV_PCM_RATE_44100 | |
3001 | SNDRV_PCM_RATE_48000, | 3118 | SNDRV_PCM_RATE_48000, |
3002 | .rate_min = 44100, | 3119 | .rate_min = 44100, |
@@ -3044,7 +3161,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
3044 | .attributes = 0x00, | 3161 | .attributes = 0x00, |
3045 | .endpoint = 0x03, | 3162 | .endpoint = 0x03, |
3046 | .ep_attr = USB_ENDPOINT_SYNC_ASYNC, | 3163 | .ep_attr = USB_ENDPOINT_SYNC_ASYNC, |
3047 | .maxpacksize = 0x128, | ||
3048 | .rates = SNDRV_PCM_RATE_48000, | 3164 | .rates = SNDRV_PCM_RATE_48000, |
3049 | .rate_min = 48000, | 3165 | .rate_min = 48000, |
3050 | .rate_max = 48000, | 3166 | .rate_max = 48000, |
@@ -3070,7 +3186,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
3070 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, | 3186 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, |
3071 | .endpoint = 0x85, | 3187 | .endpoint = 0x85, |
3072 | .ep_attr = USB_ENDPOINT_SYNC_SYNC, | 3188 | .ep_attr = USB_ENDPOINT_SYNC_SYNC, |
3073 | .maxpacksize = 0x128, | ||
3074 | .rates = SNDRV_PCM_RATE_48000, | 3189 | .rates = SNDRV_PCM_RATE_48000, |
3075 | .rate_min = 48000, | 3190 | .rate_min = 48000, |
3076 | .rate_max = 48000, | 3191 | .rate_max = 48000, |
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 9c5ab22358b1..3879eae7e874 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c | |||
@@ -165,8 +165,10 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip, | |||
165 | return -EINVAL; | 165 | return -EINVAL; |
166 | } | 166 | } |
167 | alts = &iface->altsetting[fp->altset_idx]; | 167 | alts = &iface->altsetting[fp->altset_idx]; |
168 | fp->datainterval = snd_usb_parse_datainterval(chip, alts); | 168 | if (fp->datainterval == 0) |
169 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 169 | fp->datainterval = snd_usb_parse_datainterval(chip, alts); |
170 | if (fp->maxpacksize == 0) | ||
171 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | ||
170 | usb_set_interface(chip->dev, fp->iface, 0); | 172 | usb_set_interface(chip->dev, fp->iface, 0); |
171 | snd_usb_init_pitch(chip, fp->iface, alts, fp); | 173 | snd_usb_init_pitch(chip, fp->iface, alts, fp); |
172 | snd_usb_init_sample_rate(chip, fp->iface, alts, fp, fp->rate_max); | 174 | snd_usb_init_sample_rate(chip, fp->iface, alts, fp, fp->rate_max); |
@@ -446,6 +448,17 @@ static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) | |||
446 | } | 448 | } |
447 | 449 | ||
448 | /* | 450 | /* |
451 | * Novation Twitch DJ controller | ||
452 | */ | ||
453 | static int snd_usb_twitch_boot_quirk(struct usb_device *dev) | ||
454 | { | ||
455 | /* preemptively set up the device because otherwise the | ||
456 | * raw MIDI endpoints are not active */ | ||
457 | usb_set_interface(dev, 0, 1); | ||
458 | return 0; | ||
459 | } | ||
460 | |||
461 | /* | ||
449 | * This call will put the synth in "USB send" mode, i.e it will send MIDI | 462 | * This call will put the synth in "USB send" mode, i.e it will send MIDI |
450 | * messages through USB (this is disabled at startup). The synth will | 463 | * messages through USB (this is disabled at startup). The synth will |
451 | * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB | 464 | * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB |
@@ -746,6 +759,10 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev, | |||
746 | /* Digidesign Mbox 2 */ | 759 | /* Digidesign Mbox 2 */ |
747 | return snd_usb_mbox2_boot_quirk(dev); | 760 | return snd_usb_mbox2_boot_quirk(dev); |
748 | 761 | ||
762 | case USB_ID(0x1235, 0x0018): | ||
763 | /* Focusrite Novation Twitch */ | ||
764 | return snd_usb_twitch_boot_quirk(dev); | ||
765 | |||
749 | case USB_ID(0x133e, 0x0815): | 766 | case USB_ID(0x133e, 0x0815): |
750 | /* Access Music VirusTI Desktop */ | 767 | /* Access Music VirusTI Desktop */ |
751 | return snd_usb_accessmusic_boot_quirk(dev); | 768 | return snd_usb_accessmusic_boot_quirk(dev); |
@@ -837,6 +854,7 @@ static void set_format_emu_quirk(struct snd_usb_substream *subs, | |||
837 | break; | 854 | break; |
838 | } | 855 | } |
839 | snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id); | 856 | snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id); |
857 | subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0; | ||
840 | } | 858 | } |
841 | 859 | ||
842 | void snd_usb_set_format_quirk(struct snd_usb_substream *subs, | 860 | void snd_usb_set_format_quirk(struct snd_usb_substream *subs, |
@@ -875,6 +893,16 @@ void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep) | |||
875 | ep->skip_packets = 16; | 893 | ep->skip_packets = 16; |
876 | } | 894 | } |
877 | 895 | ||
896 | void snd_usb_set_interface_quirk(struct usb_device *dev) | ||
897 | { | ||
898 | /* | ||
899 | * "Playback Design" products need a 50ms delay after setting the | ||
900 | * USB interface. | ||
901 | */ | ||
902 | if (le16_to_cpu(dev->descriptor.idVendor) == 0x23ba) | ||
903 | mdelay(50); | ||
904 | } | ||
905 | |||
878 | void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, | 906 | void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, |
879 | __u8 request, __u8 requesttype, __u16 value, | 907 | __u8 request, __u8 requesttype, __u16 value, |
880 | __u16 index, void *data, __u16 size) | 908 | __u16 index, void *data, __u16 size) |
@@ -888,3 +916,31 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, | |||
888 | mdelay(20); | 916 | mdelay(20); |
889 | } | 917 | } |
890 | 918 | ||
919 | /* | ||
920 | * snd_usb_interface_dsd_format_quirks() is called from format.c to | ||
921 | * augment the PCM format bit-field for DSD types. The UAC standards | ||
922 | * don't have a designated bit field to denote DSD-capable interfaces, | ||
923 | * hence all hardware that is known to support this format has to be | ||
924 | * listed here. | ||
925 | */ | ||
926 | u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, | ||
927 | struct audioformat *fp, | ||
928 | unsigned int sample_bytes) | ||
929 | { | ||
930 | /* Playback Designs */ | ||
931 | if (le16_to_cpu(chip->dev->descriptor.idVendor) == 0x23ba) { | ||
932 | switch (fp->altsetting) { | ||
933 | case 1: | ||
934 | fp->dsd_dop = true; | ||
935 | return SNDRV_PCM_FMTBIT_DSD_U16_LE; | ||
936 | case 2: | ||
937 | fp->dsd_bitrev = true; | ||
938 | return SNDRV_PCM_FMTBIT_DSD_U8; | ||
939 | case 3: | ||
940 | fp->dsd_bitrev = true; | ||
941 | return SNDRV_PCM_FMTBIT_DSD_U16_LE; | ||
942 | } | ||
943 | } | ||
944 | |||
945 | return 0; | ||
946 | } | ||
diff --git a/sound/usb/quirks.h b/sound/usb/quirks.h index 0ca9e91067a6..665e972a1b40 100644 --- a/sound/usb/quirks.h +++ b/sound/usb/quirks.h | |||
@@ -26,8 +26,13 @@ int snd_usb_is_big_endian_format(struct snd_usb_audio *chip, | |||
26 | 26 | ||
27 | void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep); | 27 | void snd_usb_endpoint_start_quirk(struct snd_usb_endpoint *ep); |
28 | 28 | ||
29 | void snd_usb_set_interface_quirk(struct usb_device *dev); | ||
29 | void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, | 30 | void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, |
30 | __u8 request, __u8 requesttype, __u16 value, | 31 | __u8 request, __u8 requesttype, __u16 value, |
31 | __u16 index, void *data, __u16 size); | 32 | __u16 index, void *data, __u16 size); |
32 | 33 | ||
34 | u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip, | ||
35 | struct audioformat *fp, | ||
36 | unsigned int sample_bytes); | ||
37 | |||
33 | #endif /* __USBAUDIO_QUIRKS_H */ | 38 | #endif /* __USBAUDIO_QUIRKS_H */ |
diff --git a/sound/usb/stream.c b/sound/usb/stream.c index ad181d538bd9..7db2f8958e79 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c | |||
@@ -42,12 +42,11 @@ | |||
42 | */ | 42 | */ |
43 | static void free_substream(struct snd_usb_substream *subs) | 43 | static void free_substream(struct snd_usb_substream *subs) |
44 | { | 44 | { |
45 | struct list_head *p, *n; | 45 | struct audioformat *fp, *n; |
46 | 46 | ||
47 | if (!subs->num_formats) | 47 | if (!subs->num_formats) |
48 | return; /* not initialized */ | 48 | return; /* not initialized */ |
49 | list_for_each_safe(p, n, &subs->fmt_list) { | 49 | list_for_each_entry_safe(fp, n, &subs->fmt_list, list) { |
50 | struct audioformat *fp = list_entry(p, struct audioformat, list); | ||
51 | kfree(fp->rate_table); | 50 | kfree(fp->rate_table); |
52 | kfree(fp->chmap); | 51 | kfree(fp->chmap); |
53 | kfree(fp); | 52 | kfree(fp); |
@@ -94,6 +93,7 @@ static void snd_usb_init_substream(struct snd_usb_stream *as, | |||
94 | subs->dev = as->chip->dev; | 93 | subs->dev = as->chip->dev; |
95 | subs->txfr_quirk = as->chip->txfr_quirk; | 94 | subs->txfr_quirk = as->chip->txfr_quirk; |
96 | subs->speed = snd_usb_get_speed(subs->dev); | 95 | subs->speed = snd_usb_get_speed(subs->dev); |
96 | subs->pkt_offset_adj = 0; | ||
97 | 97 | ||
98 | snd_usb_set_pcm_ops(as->pcm, stream); | 98 | snd_usb_set_pcm_ops(as->pcm, stream); |
99 | 99 | ||
@@ -313,14 +313,12 @@ int snd_usb_add_audio_stream(struct snd_usb_audio *chip, | |||
313 | int stream, | 313 | int stream, |
314 | struct audioformat *fp) | 314 | struct audioformat *fp) |
315 | { | 315 | { |
316 | struct list_head *p; | ||
317 | struct snd_usb_stream *as; | 316 | struct snd_usb_stream *as; |
318 | struct snd_usb_substream *subs; | 317 | struct snd_usb_substream *subs; |
319 | struct snd_pcm *pcm; | 318 | struct snd_pcm *pcm; |
320 | int err; | 319 | int err; |
321 | 320 | ||
322 | list_for_each(p, &chip->pcm_list) { | 321 | list_for_each_entry(as, &chip->pcm_list, list) { |
323 | as = list_entry(p, struct snd_usb_stream, list); | ||
324 | if (as->fmt_type != fp->fmt_type) | 322 | if (as->fmt_type != fp->fmt_type) |
325 | continue; | 323 | continue; |
326 | subs = &as->substream[stream]; | 324 | subs = &as->substream[stream]; |
@@ -332,8 +330,7 @@ int snd_usb_add_audio_stream(struct snd_usb_audio *chip, | |||
332 | } | 330 | } |
333 | } | 331 | } |
334 | /* look for an empty stream */ | 332 | /* look for an empty stream */ |
335 | list_for_each(p, &chip->pcm_list) { | 333 | list_for_each_entry(as, &chip->pcm_list, list) { |
336 | as = list_entry(p, struct snd_usb_stream, list); | ||
337 | if (as->fmt_type != fp->fmt_type) | 334 | if (as->fmt_type != fp->fmt_type) |
338 | continue; | 335 | continue; |
339 | subs = &as->substream[stream]; | 336 | subs = &as->substream[stream]; |
@@ -396,6 +393,14 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip, | |||
396 | if (!csep && altsd->bNumEndpoints >= 2) | 393 | if (!csep && altsd->bNumEndpoints >= 2) |
397 | csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT); | 394 | csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT); |
398 | 395 | ||
396 | /* | ||
397 | * If we can't locate the USB_DT_CS_ENDPOINT descriptor in the extra | ||
398 | * bytes after the first endpoint, go search the entire interface. | ||
399 | * Some devices have it directly *before* the standard endpoint. | ||
400 | */ | ||
401 | if (!csep) | ||
402 | csep = snd_usb_find_desc(alts->extra, alts->extralen, NULL, USB_DT_CS_ENDPOINT); | ||
403 | |||
399 | if (!csep || csep->bLength < 7 || | 404 | if (!csep || csep->bLength < 7 || |
400 | csep->bDescriptorSubtype != UAC_EP_GENERAL) { | 405 | csep->bDescriptorSubtype != UAC_EP_GENERAL) { |
401 | snd_printk(KERN_WARNING "%d:%u:%d : no or invalid" | 406 | snd_printk(KERN_WARNING "%d:%u:%d : no or invalid" |
@@ -463,7 +468,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) | |||
463 | struct usb_host_interface *alts; | 468 | struct usb_host_interface *alts; |
464 | struct usb_interface_descriptor *altsd; | 469 | struct usb_interface_descriptor *altsd; |
465 | int i, altno, err, stream; | 470 | int i, altno, err, stream; |
466 | int format = 0, num_channels = 0; | 471 | unsigned int format = 0, num_channels = 0; |
467 | struct audioformat *fp = NULL; | 472 | struct audioformat *fp = NULL; |
468 | int num, protocol, clock = 0; | 473 | int num, protocol, clock = 0; |
469 | struct uac_format_type_i_continuous_descriptor *fmt; | 474 | struct uac_format_type_i_continuous_descriptor *fmt; |
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 1ac3fd9cc5a6..bc43bcaddf4d 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h | |||
@@ -56,6 +56,7 @@ struct snd_usb_audio { | |||
56 | 56 | ||
57 | int setup; /* from the 'device_setup' module param */ | 57 | int setup; /* from the 'device_setup' module param */ |
58 | int nrpacks; /* from the 'nrpacks' module param */ | 58 | int nrpacks; /* from the 'nrpacks' module param */ |
59 | bool autoclock; /* from the 'autoclock' module param */ | ||
59 | 60 | ||
60 | struct usb_host_interface *ctrl_intf; /* the audio control interface */ | 61 | struct usb_host_interface *ctrl_intf; /* the audio control interface */ |
61 | }; | 62 | }; |