Merge branch 'topic/misc' into for-linus

+7107 -2334
+26 -1
Documentation/sound/alsa/ALSA-Configuration.txt
··· 482 482 483 483 reference_rate - reference sample rate, 44100 or 48000 (default) 484 484 multiple - multiple to ref. sample rate, 1 or 2 (default) 485 + subsystem - override the PCI SSID for probing; the value 486 + consists of SSVID << 16 | SSDID. The default is 487 + zero, which means no override. 485 488 486 489 This module supports multiple cards. 487 490 ··· 1125 1122 dma2 - DMA # for InterWave chip (0,1,3,5,6,7,-1=disable) 1126 1123 1127 1124 This module supports multiple cards, autoprobe and ISA PnP. 1125 + 1126 + Module snd-jazz16 1127 + ------------------- 1128 + 1129 + Module for Media Vision Jazz16 chipset. The chipset consists of 3 chips: 1130 + MVD1216 + MVA416 + MVA514. 1131 + 1132 + port - port # for SB DSP chip (0x210,0x220,0x230,0x240,0x250,0x260) 1133 + irq - IRQ # for SB DSP chip (3,5,7,9,10,15) 1134 + dma8 - DMA # for SB DSP chip (1,3) 1135 + dma16 - DMA # for SB DSP chip (5,7) 1136 + mpu_port - MPU-401 port # (0x300,0x310,0x320,0x330) 1137 + mpu_irq - MPU-401 irq # (2,3,5,7) 1138 + 1139 + This module supports multiple cards. 1128 1140 1129 1141 Module snd-korg1212 1130 1142 ------------------- ··· 1809 1791 1810 1792 The power-management is supported. 1811 1793 1794 + Module snd-ua101 1795 + ---------------- 1796 + 1797 + Module for the Edirol UA-101 audio/MIDI interface. 1798 + 1799 + This module supports multiple devices, autoprobe and hotplugging. 1800 + 1812 1801 Module snd-usb-audio 1813 1802 -------------------- 1814 1803 ··· 1948 1923 ------------------- 1949 1924 1950 1925 Module for sound cards based on the Asus AV100/AV200 chips, 1951 - i.e., Xonar D1, DX, D2, D2X, HDAV1.3 (Deluxe), Essence ST 1926 + i.e., Xonar D1, DX, D2, D2X, DS, HDAV1.3 (Deluxe), Essence ST 1952 1927 (Deluxe) and Essence STX. 1953 1928 1954 1929 This module supports autoprobe and multiple cards.
+3 -3
drivers/usb/gadget/f_audio.c
··· 60 60 #define UAC_DT_TOTAL_LENGTH (UAC_DT_AC_HEADER_LENGTH + UAC_DT_INPUT_TERMINAL_SIZE \ 61 61 + UAC_DT_OUTPUT_TERMINAL_SIZE + UAC_DT_FEATURE_UNIT_SIZE(0)) 62 62 /* B.3.2 Class-Specific AC Interface Descriptor */ 63 - static struct uac_ac_header_descriptor_2 ac_header_desc = { 63 + static struct uac_ac_header_descriptor_v1_2 ac_header_desc = { 64 64 .bLength = UAC_DT_AC_HEADER_LENGTH, 65 65 .bDescriptorType = USB_DT_CS_INTERFACE, 66 66 .bDescriptorSubtype = UAC_HEADER, ··· 124 124 }; 125 125 126 126 #define OUTPUT_TERMINAL_ID 3 127 - static struct uac_output_terminal_descriptor output_terminal_desc = { 127 + static struct uac_output_terminal_descriptor_v1 output_terminal_desc = { 128 128 .bLength = UAC_DT_OUTPUT_TERMINAL_SIZE, 129 129 .bDescriptorType = USB_DT_CS_INTERFACE, 130 130 .bDescriptorSubtype = UAC_OUTPUT_TERMINAL, ··· 154 154 }; 155 155 156 156 /* B.4.2 Class-Specific AS Interface Descriptor */ 157 - static struct uac_as_header_descriptor as_header_desc = { 157 + static struct uac_as_header_descriptor_v1 as_header_desc = { 158 158 .bLength = UAC_DT_AS_HEADER_SIZE, 159 159 .bDescriptorType = USB_DT_CS_INTERFACE, 160 160 .bDescriptorSubtype = UAC_AS_GENERAL,
+1 -1
drivers/usb/gadget/gmidi.c
··· 237 237 }; 238 238 239 239 /* B.3.2 Class-Specific AC Interface Descriptor */ 240 - static const struct uac_ac_header_descriptor_1 ac_header_desc = { 240 + static const struct uac_ac_header_descriptor_v1_1 ac_header_desc = { 241 241 .bLength = UAC_DT_AC_HEADER_SIZE(1), 242 242 .bDescriptorType = USB_DT_CS_INTERFACE, 243 243 .bDescriptorSubtype = USB_MS_HEADER,
+114 -6
include/linux/usb/audio.h
··· 25 25 #define USB_SUBCLASS_AUDIOSTREAMING 0x02 26 26 #define USB_SUBCLASS_MIDISTREAMING 0x03 27 27 28 + #define UAC_VERSION_1 0x00 29 + #define UAC_VERSION_2 0x20 30 + 28 31 /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */ 29 32 #define UAC_HEADER 0x01 30 33 #define UAC_INPUT_TERMINAL 0x02 ··· 35 32 #define UAC_MIXER_UNIT 0x04 36 33 #define UAC_SELECTOR_UNIT 0x05 37 34 #define UAC_FEATURE_UNIT 0x06 38 - #define UAC_PROCESSING_UNIT 0x07 39 - #define UAC_EXTENSION_UNIT 0x08 35 + #define UAC_PROCESSING_UNIT_V1 0x07 36 + #define UAC_EXTENSION_UNIT_V1 0x08 37 + 38 + /* UAC v2.0 types */ 39 + #define UAC_EFFECT_UNIT 0x07 40 + #define UAC_PROCESSING_UNIT_V2 0x08 41 + #define UAC_EXTENSION_UNIT_V2 0x09 42 + #define UAC_CLOCK_SOURCE 0x0a 43 + #define UAC_CLOCK_SELECTOR 0x0b 44 + #define UAC_CLOCK_MULTIPLIER 0x0c 45 + #define UAC_SAMPLE_RATE_CONVERTER 0x0d 40 46 41 47 /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */ 42 48 #define UAC_AS_GENERAL 0x01 ··· 78 66 79 67 #define UAC_GET_STAT 0xff 80 68 69 + /* Audio class v2.0 handles all the parameter calls differently */ 70 + #define UAC2_CS_CUR 0x01 71 + #define UAC2_CS_RANGE 0x02 72 + 81 73 /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ 82 74 #define UAC_MS_HEADER 0x01 83 75 #define UAC_MIDI_IN_JACK 0x02 ··· 97 81 98 82 /* Terminal Control Selectors */ 99 83 /* 4.3.2 Class-Specific AC Interface Descriptor */ 100 - struct uac_ac_header_descriptor { 84 + struct uac_ac_header_descriptor_v1 { 101 85 __u8 bLength; /* 8 + n */ 102 86 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 103 87 __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ ··· 111 95 112 96 /* As above, but more useful for defining your own descriptors: */ 113 97 #define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \ 114 - struct uac_ac_header_descriptor_##n { \ 98 + struct uac_ac_header_descriptor_v1_##n { \ 115 99 __u8 bLength; \ 116 100 __u8 bDescriptorType; \ 117 101 __u8 bDescriptorSubtype; \ ··· 146 130 #define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205 147 131 #define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206 148 132 133 + /* Terminals - control selectors */ 134 + 135 + #define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01 136 + 149 137 /* 4.3.2.2 Output Terminal Descriptor */ 150 - struct uac_output_terminal_descriptor { 138 + struct uac_output_terminal_descriptor_v1 { 151 139 __u8 bLength; /* in bytes: 9 */ 152 140 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ 153 141 __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */ ··· 191 171 } __attribute__ ((packed)) 192 172 193 173 /* 4.5.2 Class-Specific AS Interface Descriptor */ 194 - struct uac_as_header_descriptor { 174 + struct uac_as_header_descriptor_v1 { 195 175 __u8 bLength; /* in bytes: 7 */ 196 176 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 197 177 __u8 bDescriptorSubtype; /* AS_GENERAL */ ··· 199 179 __u8 bDelay; /* Delay introduced by the data path */ 200 180 __le16 wFormatTag; /* The Audio Data Format */ 201 181 } __attribute__ ((packed)); 182 + 183 + struct uac_as_header_descriptor_v2 { 184 + __u8 bLength; 185 + __u8 bDescriptorType; 186 + __u8 bDescriptorSubtype; 187 + __u8 bTerminalLink; 188 + __u8 bmControls; 189 + __u8 bFormatType; 190 + __u32 bmFormats; 191 + __u8 bNrChannels; 192 + __u32 bmChannelConfig; 193 + __u8 iChannelNames; 194 + } __attribute__((packed)); 202 195 203 196 #define UAC_DT_AS_HEADER_SIZE 7 204 197 ··· 265 232 266 233 #define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3)) 267 234 235 + struct uac_format_type_i_ext_descriptor { 236 + __u8 bLength; 237 + __u8 bDescriptorType; 238 + __u8 bDescriptorSubtype; 239 + __u8 bSubslotSize; 240 + __u8 bFormatType; 241 + __u8 bBitResolution; 242 + __u8 bHeaderLength; 243 + __u8 bControlSize; 244 + __u8 bSideBandProtocol; 245 + } __attribute__((packed)); 246 + 247 + 248 + /* Formats - Audio Data Format Type I Codes */ 249 + 250 + #define UAC_FORMAT_TYPE_II_MPEG 0x1001 251 + #define UAC_FORMAT_TYPE_II_AC3 0x1002 252 + 253 + struct uac_format_type_ii_discrete_descriptor { 254 + __u8 bLength; 255 + __u8 bDescriptorType; 256 + __u8 bDescriptorSubtype; 257 + __u8 bFormatType; 258 + __le16 wMaxBitRate; 259 + __le16 wSamplesPerFrame; 260 + __u8 bSamFreqType; 261 + __u8 tSamFreq[][3]; 262 + } __attribute__((packed)); 263 + 264 + struct uac_format_type_ii_ext_descriptor { 265 + __u8 bLength; 266 + __u8 bDescriptorType; 267 + __u8 bDescriptorSubtype; 268 + __u8 bFormatType; 269 + __u16 wMaxBitRate; 270 + __u16 wSamplesPerFrame; 271 + __u8 bHeaderLength; 272 + __u8 bSideBandProtocol; 273 + } __attribute__((packed)); 274 + 275 + /* type III */ 276 + #define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001 277 + #define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002 278 + #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003 279 + #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004 280 + #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005 281 + #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006 282 + 268 283 /* Formats - A.2 Format Type Codes */ 269 284 #define UAC_FORMAT_TYPE_UNDEFINED 0x0 270 285 #define UAC_FORMAT_TYPE_I 0x1 271 286 #define UAC_FORMAT_TYPE_II 0x2 272 287 #define UAC_FORMAT_TYPE_III 0x3 288 + #define UAC_EXT_FORMAT_TYPE_I 0x81 289 + #define UAC_EXT_FORMAT_TYPE_II 0x82 290 + #define UAC_EXT_FORMAT_TYPE_III 0x83 273 291 274 292 struct uac_iso_endpoint_descriptor { 275 293 __u8 bLength; /* in bytes: 7 */ ··· 336 252 #define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02 337 253 #define UAC_EP_CS_ATTR_FILL_MAX 0x80 338 254 255 + /* Audio class v2.0: CLOCK_SOURCE descriptor */ 256 + 257 + struct uac_clock_source_descriptor { 258 + __u8 bLength; 259 + __u8 bDescriptorType; 260 + __u8 bDescriptorSubtype; 261 + __u8 bClockID; 262 + __u8 bmAttributes; 263 + __u8 bmControls; 264 + __u8 bAssocTerminal; 265 + __u8 iClockSource; 266 + } __attribute__((packed)); 267 + 339 268 /* A.10.2 Feature Unit Control Selectors */ 269 + 270 + struct uac_feature_unit_descriptor { 271 + __u8 bLength; 272 + __u8 bDescriptorType; 273 + __u8 bDescriptorSubtype; 274 + __u8 bUnitID; 275 + __u8 bSourceID; 276 + __u8 bControlSize; 277 + __u8 controls[0]; /* variable length */ 278 + } __attribute__((packed)); 279 + 340 280 #define UAC_FU_CONTROL_UNDEFINED 0x00 341 281 #define UAC_MUTE_CONTROL 0x01 342 282 #define UAC_VOLUME_CONTROL 0x02
+3
include/sound/core.h
··· 458 458 const struct snd_pci_quirk * 459 459 snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list); 460 460 461 + const struct snd_pci_quirk * 462 + snd_pci_quirk_lookup_id(u16 vendor, u16 device, 463 + const struct snd_pci_quirk *list); 461 464 462 465 #endif /* __SOUND_CORE_H */
+4 -2
include/sound/cs46xx_dsp_spos.h
··· 118 118 119 119 struct snd_info_entry *proc_info; 120 120 int ref_count; 121 - spinlock_t lock; 122 121 123 - int deleted; 122 + u16 volume[2]; 123 + unsigned int deleted :1; 124 + unsigned int updated :1; 125 + unsigned int volume_set :1; 124 126 }; 125 127 126 128 struct dsp_task_descriptor {
+53 -1
include/sound/pcm.h
··· 262 262 unsigned int mask; 263 263 }; 264 264 265 + struct snd_pcm_hwptr_log; 266 + 265 267 struct snd_pcm_runtime { 266 268 /* -- Status -- */ 267 269 struct snd_pcm_substream *trigger_master; ··· 312 310 struct snd_pcm_mmap_control *control; 313 311 314 312 /* -- locking / scheduling -- */ 315 - wait_queue_head_t sleep; 313 + unsigned int twake: 1; /* do transfer (!poll) wakeup */ 314 + wait_queue_head_t sleep; /* poll sleep */ 315 + wait_queue_head_t tsleep; /* transfer sleep */ 316 316 struct fasync_struct *fasync; 317 317 318 318 /* -- private section -- */ ··· 343 339 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) 344 340 /* -- OSS things -- */ 345 341 struct snd_pcm_oss_runtime oss; 342 + #endif 343 + 344 + #ifdef CONFIG_SND_PCM_XRUN_DEBUG 345 + struct snd_pcm_hwptr_log *hwptr_log; 346 346 #endif 347 347 }; 348 348 ··· 842 834 int snd_pcm_lib_interleave_len(struct snd_pcm_substream *substream); 843 835 int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, 844 836 unsigned int cmd, void *arg); 837 + int snd_pcm_update_state(struct snd_pcm_substream *substream, 838 + struct snd_pcm_runtime *runtime); 845 839 int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream); 846 840 int snd_pcm_playback_xrun_check(struct snd_pcm_substream *substream); 847 841 int snd_pcm_capture_xrun_check(struct snd_pcm_substream *substream); ··· 915 905 int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size); 916 906 int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream); 917 907 908 + int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream, 909 + size_t size, gfp_t gfp_flags); 910 + int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream); 911 + struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, 912 + unsigned long offset); 913 + #if 0 /* for kernel-doc */ 914 + /** 915 + * snd_pcm_lib_alloc_vmalloc_buffer - allocate virtual DMA buffer 916 + * @substream: the substream to allocate the buffer to 917 + * @size: the requested buffer size, in bytes 918 + * 919 + * Allocates the PCM substream buffer using vmalloc(), i.e., the memory is 920 + * contiguous in kernel virtual space, but not in physical memory. Use this 921 + * if the buffer is accessed by kernel code but not by device DMA. 922 + * 923 + * Returns 1 if the buffer was changed, 0 if not changed, or a negative error 924 + * code. 925 + */ 926 + static int snd_pcm_lib_alloc_vmalloc_buffer 927 + (struct snd_pcm_substream *substream, size_t size); 928 + /** 929 + * snd_pcm_lib_alloc_vmalloc_32_buffer - allocate 32-bit-addressable buffer 930 + * @substream: the substream to allocate the buffer to 931 + * @size: the requested buffer size, in bytes 932 + * 933 + * This function works like snd_pcm_lib_alloc_vmalloc_buffer(), but uses 934 + * vmalloc_32(), i.e., the pages are allocated from 32-bit-addressable memory. 935 + */ 936 + static int snd_pcm_lib_alloc_vmalloc_32_buffer 937 + (struct snd_pcm_substream *substream, size_t size); 938 + #endif 939 + #define snd_pcm_lib_alloc_vmalloc_buffer(subs, size) \ 940 + _snd_pcm_lib_alloc_vmalloc_buffer \ 941 + (subs, size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO) 942 + #define snd_pcm_lib_alloc_vmalloc_32_buffer(subs, size) \ 943 + _snd_pcm_lib_alloc_vmalloc_buffer \ 944 + (subs, size, GFP_KERNEL | GFP_DMA32 | __GFP_ZERO) 945 + 918 946 #ifdef CONFIG_SND_DMA_SGBUF 919 947 /* 920 948 * SG-buffer handling ··· 1022 974 #define SNDRV_PCM_INFO_MMAP_IOMEM 0 1023 975 #define snd_pcm_lib_mmap_iomem NULL 1024 976 #endif 977 + 978 + int snd_pcm_lib_mmap_noncached(struct snd_pcm_substream *substream, 979 + struct vm_area_struct *area); 980 + #define snd_pcm_lib_mmap_vmalloc snd_pcm_lib_mmap_noncached 1025 981 1026 982 static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max) 1027 983 {
+1 -1
include/sound/pcm_oss.h
··· 61 61 struct snd_pcm_plugin *plugin_first; 62 62 struct snd_pcm_plugin *plugin_last; 63 63 #endif 64 - unsigned int prev_hw_ptr_interrupt; 64 + unsigned int prev_hw_ptr_period; 65 65 }; 66 66 67 67 struct snd_pcm_oss_file {
+1
include/sound/sb.h
··· 33 33 SB_HW_20, 34 34 SB_HW_201, 35 35 SB_HW_PRO, 36 + SB_HW_JAZZ16, /* Media Vision Jazz16 */ 36 37 SB_HW_16, 37 38 SB_HW_16CSP, /* SB16 with CSP chip */ 38 39 SB_HW_ALS100, /* Avance Logic ALS100 chip */
+1 -1
include/sound/version.h
··· 1 1 /* include/version.h */ 2 - #define CONFIG_SND_VERSION "1.0.21" 2 + #define CONFIG_SND_VERSION "1.0.22.1" 3 3 #define CONFIG_SND_DATE ""
+4 -3
sound/core/control.c
··· 237 237 access = ncontrol->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : 238 238 (ncontrol->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE| 239 239 SNDRV_CTL_ELEM_ACCESS_INACTIVE| 240 - SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE| 241 - SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)); 240 + SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE| 241 + SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND| 242 + SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)); 242 243 kctl.info = ncontrol->info; 243 244 kctl.get = ncontrol->get; 244 245 kctl.put = ncontrol->put; ··· 1100 1099 1101 1100 if (copy_from_user(&tlv, _tlv, sizeof(tlv))) 1102 1101 return -EFAULT; 1103 - if (tlv.length < sizeof(unsigned int) * 3) 1102 + if (tlv.length < sizeof(unsigned int) * 2) 1104 1103 return -EINVAL; 1105 1104 down_read(&card->controls_rwsem); 1106 1105 kctl = snd_ctl_find_numid(card, tlv.numid);
+32 -10
sound/core/misc.c
··· 101 101 #ifdef CONFIG_PCI 102 102 #include <linux/pci.h> 103 103 /** 104 + * snd_pci_quirk_lookup_id - look up a PCI SSID quirk list 105 + * @vendor: PCI SSV id 106 + * @device: PCI SSD id 107 + * @list: quirk list, terminated by a null entry 108 + * 109 + * Look through the given quirk list and finds a matching entry 110 + * with the same PCI SSID. When subdevice is 0, all subdevice 111 + * values may match. 112 + * 113 + * Returns the matched entry pointer, or NULL if nothing matched. 114 + */ 115 + const struct snd_pci_quirk * 116 + snd_pci_quirk_lookup_id(u16 vendor, u16 device, 117 + const struct snd_pci_quirk *list) 118 + { 119 + const struct snd_pci_quirk *q; 120 + 121 + for (q = list; q->subvendor; q++) { 122 + if (q->subvendor != vendor) 123 + continue; 124 + if (!q->subdevice || 125 + (device & q->subdevice_mask) == q->subdevice) 126 + return q; 127 + } 128 + return NULL; 129 + } 130 + EXPORT_SYMBOL(snd_pci_quirk_lookup_id); 131 + 132 + /** 104 133 * snd_pci_quirk_lookup - look up a PCI SSID quirk list 105 134 * @pci: pci_dev handle 106 135 * @list: quirk list, terminated by a null entry ··· 143 114 const struct snd_pci_quirk * 144 115 snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list) 145 116 { 146 - const struct snd_pci_quirk *q; 147 - 148 - for (q = list; q->subvendor; q++) { 149 - if (q->subvendor != pci->subsystem_vendor) 150 - continue; 151 - if (!q->subdevice || 152 - (pci->subsystem_device & q->subdevice_mask) == q->subdevice) 153 - return q; 154 - } 155 - return NULL; 117 + return snd_pci_quirk_lookup_id(pci->subsystem_vendor, 118 + pci->subsystem_device, 119 + list); 156 120 } 157 121 EXPORT_SYMBOL(snd_pci_quirk_lookup); 158 122 #endif
+22 -9
sound/core/oss/pcm_oss.c
··· 632 632 return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes); 633 633 } 634 634 635 + static inline 636 + snd_pcm_uframes_t get_hw_ptr_period(struct snd_pcm_runtime *runtime) 637 + { 638 + return runtime->hw_ptr_interrupt; 639 + } 640 + 635 641 /* define extended formats in the recent OSS versions (if any) */ 636 642 /* linear formats */ 637 643 #define AFMT_S32_LE 0x00001000 ··· 1108 1102 return err; 1109 1103 } 1110 1104 runtime->oss.prepare = 0; 1111 - runtime->oss.prev_hw_ptr_interrupt = 0; 1105 + runtime->oss.prev_hw_ptr_period = 0; 1112 1106 runtime->oss.period_ptr = 0; 1113 1107 runtime->oss.buffer_used = 0; 1114 1108 ··· 1956 1950 return result; 1957 1951 } 1958 1952 1959 - static void snd_pcm_oss_simulate_fill(struct snd_pcm_substream *substream, snd_pcm_uframes_t hw_ptr) 1953 + static void snd_pcm_oss_simulate_fill(struct snd_pcm_substream *substream, 1954 + snd_pcm_uframes_t hw_ptr) 1960 1955 { 1961 1956 struct snd_pcm_runtime *runtime = substream->runtime; 1962 1957 snd_pcm_uframes_t appl_ptr; ··· 1993 1986 if (runtime->oss.trigger) 1994 1987 goto _skip1; 1995 1988 if (atomic_read(&psubstream->mmap_count)) 1996 - snd_pcm_oss_simulate_fill(psubstream, runtime->hw_ptr_interrupt); 1989 + snd_pcm_oss_simulate_fill(psubstream, 1990 + get_hw_ptr_period(runtime)); 1997 1991 runtime->oss.trigger = 1; 1998 1992 runtime->start_threshold = 1; 1999 1993 cmd = SNDRV_PCM_IOCTL_START; ··· 2113 2105 info.ptr = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr % runtime->buffer_size); 2114 2106 if (atomic_read(&substream->mmap_count)) { 2115 2107 snd_pcm_sframes_t n; 2116 - n = (delay = runtime->hw_ptr_interrupt) - runtime->oss.prev_hw_ptr_interrupt; 2108 + delay = get_hw_ptr_period(runtime); 2109 + n = delay - runtime->oss.prev_hw_ptr_period; 2117 2110 if (n < 0) 2118 2111 n += runtime->boundary; 2119 2112 info.blocks = n / runtime->period_size; 2120 - runtime->oss.prev_hw_ptr_interrupt = delay; 2113 + runtime->oss.prev_hw_ptr_period = delay; 2121 2114 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 2122 2115 snd_pcm_oss_simulate_fill(substream, delay); 2123 2116 info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX; ··· 2682 2673 { 2683 2674 struct snd_pcm_runtime *runtime = substream->runtime; 2684 2675 if (atomic_read(&substream->mmap_count)) 2685 - return runtime->oss.prev_hw_ptr_interrupt != runtime->hw_ptr_interrupt; 2676 + return runtime->oss.prev_hw_ptr_period != 2677 + get_hw_ptr_period(runtime); 2686 2678 else 2687 - return snd_pcm_playback_avail(runtime) >= runtime->oss.period_frames; 2679 + return snd_pcm_playback_avail(runtime) >= 2680 + runtime->oss.period_frames; 2688 2681 } 2689 2682 2690 2683 static int snd_pcm_oss_capture_ready(struct snd_pcm_substream *substream) 2691 2684 { 2692 2685 struct snd_pcm_runtime *runtime = substream->runtime; 2693 2686 if (atomic_read(&substream->mmap_count)) 2694 - return runtime->oss.prev_hw_ptr_interrupt != runtime->hw_ptr_interrupt; 2687 + return runtime->oss.prev_hw_ptr_period != 2688 + get_hw_ptr_period(runtime); 2695 2689 else 2696 - return snd_pcm_capture_avail(runtime) >= runtime->oss.period_frames; 2690 + return snd_pcm_capture_avail(runtime) >= 2691 + runtime->oss.period_frames; 2697 2692 } 2698 2693 2699 2694 static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait)
+5
sound/core/pcm.c
··· 894 894 memset((void*)runtime->control, 0, size); 895 895 896 896 init_waitqueue_head(&runtime->sleep); 897 + init_waitqueue_head(&runtime->tsleep); 897 898 898 899 runtime->status->state = SNDRV_PCM_STATE_OPEN; 899 900 ··· 922 921 snd_free_pages((void*)runtime->control, 923 922 PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))); 924 923 kfree(runtime->hw_constraints.rules); 924 + #ifdef CONFIG_SND_PCM_XRUN_DEBUG 925 + if (runtime->hwptr_log) 926 + kfree(runtime->hwptr_log); 927 + #endif 925 928 kfree(runtime); 926 929 substream->runtime = NULL; 927 930 put_pid(substream->pid);
+246 -201
sound/core/pcm_lib.c
··· 126 126 } 127 127 } 128 128 129 - #ifdef CONFIG_SND_PCM_XRUN_DEBUG 130 - #define xrun_debug(substream, mask) ((substream)->pstr->xrun_debug & (mask)) 131 - #else 132 - #define xrun_debug(substream, mask) 0 133 - #endif 134 - 135 - #define dump_stack_on_xrun(substream) do { \ 136 - if (xrun_debug(substream, 2)) \ 137 - dump_stack(); \ 138 - } while (0) 139 - 140 129 static void pcm_debug_name(struct snd_pcm_substream *substream, 141 130 char *name, size_t len) 142 131 { ··· 136 147 substream->number); 137 148 } 138 149 150 + #define XRUN_DEBUG_BASIC (1<<0) 151 + #define XRUN_DEBUG_STACK (1<<1) /* dump also stack */ 152 + #define XRUN_DEBUG_JIFFIESCHECK (1<<2) /* do jiffies check */ 153 + #define XRUN_DEBUG_PERIODUPDATE (1<<3) /* full period update info */ 154 + #define XRUN_DEBUG_HWPTRUPDATE (1<<4) /* full hwptr update info */ 155 + #define XRUN_DEBUG_LOG (1<<5) /* show last 10 positions on err */ 156 + #define XRUN_DEBUG_LOGONCE (1<<6) /* do above only once */ 157 + 158 + #ifdef CONFIG_SND_PCM_XRUN_DEBUG 159 + 160 + #define xrun_debug(substream, mask) \ 161 + ((substream)->pstr->xrun_debug & (mask)) 162 + 163 + #define dump_stack_on_xrun(substream) do { \ 164 + if (xrun_debug(substream, XRUN_DEBUG_STACK)) \ 165 + dump_stack(); \ 166 + } while (0) 167 + 139 168 static void xrun(struct snd_pcm_substream *substream) 140 169 { 141 170 struct snd_pcm_runtime *runtime = substream->runtime; ··· 161 154 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) 162 155 snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); 163 156 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); 164 - if (xrun_debug(substream, 1)) { 157 + if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { 165 158 char name[16]; 166 159 pcm_debug_name(substream, name, sizeof(name)); 167 160 snd_printd(KERN_DEBUG "XRUN: %s\n", name); ··· 169 162 } 170 163 } 171 164 172 - static snd_pcm_uframes_t 173 - snd_pcm_update_hw_ptr_pos(struct snd_pcm_substream *substream, 174 - struct snd_pcm_runtime *runtime) 175 - { 176 - snd_pcm_uframes_t pos; 165 + #define hw_ptr_error(substream, fmt, args...) \ 166 + do { \ 167 + if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { \ 168 + xrun_log_show(substream); \ 169 + if (printk_ratelimit()) { \ 170 + snd_printd("PCM: " fmt, ##args); \ 171 + } \ 172 + dump_stack_on_xrun(substream); \ 173 + } \ 174 + } while (0) 177 175 178 - pos = substream->ops->pointer(substream); 179 - if (pos == SNDRV_PCM_POS_XRUN) 180 - return pos; /* XRUN */ 181 - if (pos >= runtime->buffer_size) { 182 - if (printk_ratelimit()) { 183 - char name[16]; 184 - pcm_debug_name(substream, name, sizeof(name)); 185 - snd_printd(KERN_ERR "BUG: %s, pos = 0x%lx, " 186 - "buffer size = 0x%lx, period size = 0x%lx\n", 187 - name, pos, runtime->buffer_size, 188 - runtime->period_size); 189 - } 190 - pos = 0; 176 + #define XRUN_LOG_CNT 10 177 + 178 + struct hwptr_log_entry { 179 + unsigned long jiffies; 180 + snd_pcm_uframes_t pos; 181 + snd_pcm_uframes_t period_size; 182 + snd_pcm_uframes_t buffer_size; 183 + snd_pcm_uframes_t old_hw_ptr; 184 + snd_pcm_uframes_t hw_ptr_base; 185 + }; 186 + 187 + struct snd_pcm_hwptr_log { 188 + unsigned int idx; 189 + unsigned int hit: 1; 190 + struct hwptr_log_entry entries[XRUN_LOG_CNT]; 191 + }; 192 + 193 + static void xrun_log(struct snd_pcm_substream *substream, 194 + snd_pcm_uframes_t pos) 195 + { 196 + struct snd_pcm_runtime *runtime = substream->runtime; 197 + struct snd_pcm_hwptr_log *log = runtime->hwptr_log; 198 + struct hwptr_log_entry *entry; 199 + 200 + if (log == NULL) { 201 + log = kzalloc(sizeof(*log), GFP_ATOMIC); 202 + if (log == NULL) 203 + return; 204 + runtime->hwptr_log = log; 205 + } else { 206 + if (xrun_debug(substream, XRUN_DEBUG_LOGONCE) && log->hit) 207 + return; 191 208 } 192 - pos -= pos % runtime->min_align; 193 - return pos; 209 + entry = &log->entries[log->idx]; 210 + entry->jiffies = jiffies; 211 + entry->pos = pos; 212 + entry->period_size = runtime->period_size; 213 + entry->buffer_size = runtime->buffer_size;; 214 + entry->old_hw_ptr = runtime->status->hw_ptr; 215 + entry->hw_ptr_base = runtime->hw_ptr_base; 216 + log->idx = (log->idx + 1) % XRUN_LOG_CNT; 194 217 } 195 218 196 - static int snd_pcm_update_hw_ptr_post(struct snd_pcm_substream *substream, 197 - struct snd_pcm_runtime *runtime) 219 + static void xrun_log_show(struct snd_pcm_substream *substream) 220 + { 221 + struct snd_pcm_hwptr_log *log = substream->runtime->hwptr_log; 222 + struct hwptr_log_entry *entry; 223 + char name[16]; 224 + unsigned int idx; 225 + int cnt; 226 + 227 + if (log == NULL) 228 + return; 229 + if (xrun_debug(substream, XRUN_DEBUG_LOGONCE) && log->hit) 230 + return; 231 + pcm_debug_name(substream, name, sizeof(name)); 232 + for (cnt = 0, idx = log->idx; cnt < XRUN_LOG_CNT; cnt++) { 233 + entry = &log->entries[idx]; 234 + if (entry->period_size == 0) 235 + break; 236 + snd_printd("hwptr log: %s: j=%lu, pos=%ld/%ld/%ld, " 237 + "hwptr=%ld/%ld\n", 238 + name, entry->jiffies, (unsigned long)entry->pos, 239 + (unsigned long)entry->period_size, 240 + (unsigned long)entry->buffer_size, 241 + (unsigned long)entry->old_hw_ptr, 242 + (unsigned long)entry->hw_ptr_base); 243 + idx++; 244 + idx %= XRUN_LOG_CNT; 245 + } 246 + log->hit = 1; 247 + } 248 + 249 + #else /* ! CONFIG_SND_PCM_XRUN_DEBUG */ 250 + 251 + #define xrun_debug(substream, mask) 0 252 + #define xrun(substream) do { } while (0) 253 + #define hw_ptr_error(substream, fmt, args...) do { } while (0) 254 + #define xrun_log(substream, pos) do { } while (0) 255 + #define xrun_log_show(substream) do { } while (0) 256 + 257 + #endif 258 + 259 + int snd_pcm_update_state(struct snd_pcm_substream *substream, 260 + struct snd_pcm_runtime *runtime) 198 261 { 199 262 snd_pcm_uframes_t avail; 200 263 ··· 286 209 } 287 210 } 288 211 if (avail >= runtime->control->avail_min) 289 - wake_up(&runtime->sleep); 212 + wake_up(runtime->twake ? &runtime->tsleep : &runtime->sleep); 290 213 return 0; 291 214 } 292 215 293 - #define hw_ptr_error(substream, fmt, args...) \ 294 - do { \ 295 - if (xrun_debug(substream, 1)) { \ 296 - if (printk_ratelimit()) { \ 297 - snd_printd("PCM: " fmt, ##args); \ 298 - } \ 299 - dump_stack_on_xrun(substream); \ 300 - } \ 301 - } while (0) 302 - 303 - static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) 216 + static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, 217 + unsigned int in_interrupt) 304 218 { 305 219 struct snd_pcm_runtime *runtime = substream->runtime; 306 220 snd_pcm_uframes_t pos; 307 - snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_ptr_interrupt, hw_base; 221 + snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base; 308 222 snd_pcm_sframes_t hdelta, delta; 309 223 unsigned long jdelta; 310 224 311 225 old_hw_ptr = runtime->status->hw_ptr; 312 - pos = snd_pcm_update_hw_ptr_pos(substream, runtime); 226 + pos = substream->ops->pointer(substream); 313 227 if (pos == SNDRV_PCM_POS_XRUN) { 314 228 xrun(substream); 315 229 return -EPIPE; 316 230 } 317 - if (xrun_debug(substream, 8)) { 318 - char name[16]; 319 - pcm_debug_name(substream, name, sizeof(name)); 320 - snd_printd("period_update: %s: pos=0x%x/0x%x/0x%x, " 321 - "hwptr=0x%lx, hw_base=0x%lx, hw_intr=0x%lx\n", 322 - name, (unsigned int)pos, 323 - (unsigned int)runtime->period_size, 324 - (unsigned int)runtime->buffer_size, 325 - (unsigned long)old_hw_ptr, 326 - (unsigned long)runtime->hw_ptr_base, 327 - (unsigned long)runtime->hw_ptr_interrupt); 231 + if (pos >= runtime->buffer_size) { 232 + if (printk_ratelimit()) { 233 + char name[16]; 234 + pcm_debug_name(substream, name, sizeof(name)); 235 + xrun_log_show(substream); 236 + snd_printd(KERN_ERR "BUG: %s, pos = %ld, " 237 + "buffer size = %ld, period size = %ld\n", 238 + name, pos, runtime->buffer_size, 239 + runtime->period_size); 240 + } 241 + pos = 0; 328 242 } 243 + pos -= pos % runtime->min_align; 244 + if (xrun_debug(substream, XRUN_DEBUG_LOG)) 245 + xrun_log(substream, pos); 329 246 hw_base = runtime->hw_ptr_base; 330 247 new_hw_ptr = hw_base + pos; 331 - hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size; 332 - delta = new_hw_ptr - hw_ptr_interrupt; 333 - if (hw_ptr_interrupt >= runtime->boundary) { 334 - hw_ptr_interrupt -= runtime->boundary; 335 - if (hw_base < runtime->boundary / 2) 336 - /* hw_base was already lapped; recalc delta */ 337 - delta = new_hw_ptr - hw_ptr_interrupt; 338 - } 339 - if (delta < 0) { 340 - if (runtime->periods == 1 || new_hw_ptr < old_hw_ptr) 341 - delta += runtime->buffer_size; 342 - if (delta < 0) { 343 - hw_ptr_error(substream, 344 - "Unexpected hw_pointer value " 345 - "(stream=%i, pos=%ld, intr_ptr=%ld)\n", 346 - substream->stream, (long)pos, 347 - (long)hw_ptr_interrupt); 348 - #if 1 349 - /* simply skipping the hwptr update seems more 350 - * robust in some cases, e.g. on VMware with 351 - * inaccurate timer source 352 - */ 353 - return 0; /* skip this update */ 354 - #else 355 - /* rebase to interrupt position */ 356 - hw_base = new_hw_ptr = hw_ptr_interrupt; 357 - /* align hw_base to buffer_size */ 358 - hw_base -= hw_base % runtime->buffer_size; 359 - delta = 0; 360 - #endif 361 - } else { 248 + if (in_interrupt) { 249 + /* we know that one period was processed */ 250 + /* delta = "expected next hw_ptr" for in_interrupt != 0 */ 251 + delta = runtime->hw_ptr_interrupt + runtime->period_size; 252 + if (delta > new_hw_ptr) { 362 253 hw_base += runtime->buffer_size; 363 254 if (hw_base >= runtime->boundary) 364 255 hw_base = 0; 365 256 new_hw_ptr = hw_base + pos; 257 + goto __delta; 366 258 } 259 + } 260 + /* new_hw_ptr might be lower than old_hw_ptr in case when */ 261 + /* pointer crosses the end of the ring buffer */ 262 + if (new_hw_ptr < old_hw_ptr) { 263 + hw_base += runtime->buffer_size; 264 + if (hw_base >= runtime->boundary) 265 + hw_base = 0; 266 + new_hw_ptr = hw_base + pos; 267 + } 268 + __delta: 269 + delta = (new_hw_ptr - old_hw_ptr) % runtime->boundary; 270 + if (xrun_debug(substream, in_interrupt ? 271 + XRUN_DEBUG_PERIODUPDATE : XRUN_DEBUG_HWPTRUPDATE)) { 272 + char name[16]; 273 + pcm_debug_name(substream, name, sizeof(name)); 274 + snd_printd("%s_update: %s: pos=%u/%u/%u, " 275 + "hwptr=%ld/%ld/%ld/%ld\n", 276 + in_interrupt ? "period" : "hwptr", 277 + name, 278 + (unsigned int)pos, 279 + (unsigned int)runtime->period_size, 280 + (unsigned int)runtime->buffer_size, 281 + (unsigned long)delta, 282 + (unsigned long)old_hw_ptr, 283 + (unsigned long)new_hw_ptr, 284 + (unsigned long)runtime->hw_ptr_base); 285 + } 286 + /* something must be really wrong */ 287 + if (delta >= runtime->buffer_size + runtime->period_size) { 288 + hw_ptr_error(substream, 289 + "Unexpected hw_pointer value %s" 290 + "(stream=%i, pos=%ld, new_hw_ptr=%ld, " 291 + "old_hw_ptr=%ld)\n", 292 + in_interrupt ? "[Q] " : "[P]", 293 + substream->stream, (long)pos, 294 + (long)new_hw_ptr, (long)old_hw_ptr); 295 + return 0; 367 296 } 368 297 369 298 /* Do jiffies check only in xrun_debug mode */ 370 - if (!xrun_debug(substream, 4)) 299 + if (!xrun_debug(substream, XRUN_DEBUG_JIFFIESCHECK)) 371 300 goto no_jiffies_check; 372 301 373 302 /* Skip the jiffies check for hardwares with BATCH flag. ··· 382 299 */ 383 300 if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) 384 301 goto no_jiffies_check; 385 - hdelta = new_hw_ptr - old_hw_ptr; 302 + hdelta = delta; 386 303 if (hdelta < runtime->delay) 387 304 goto no_jiffies_check; 388 305 hdelta -= runtime->delay; ··· 391 308 delta = jdelta / 392 309 (((runtime->period_size * HZ) / runtime->rate) 393 310 + HZ/100); 311 + /* move new_hw_ptr according jiffies not pos variable */ 312 + new_hw_ptr = old_hw_ptr; 313 + hw_base = delta; 314 + /* use loop to avoid checks for delta overflows */ 315 + /* the delta value is small or zero in most cases */ 316 + while (delta > 0) { 317 + new_hw_ptr += runtime->period_size; 318 + if (new_hw_ptr >= runtime->boundary) 319 + new_hw_ptr -= runtime->boundary; 320 + delta--; 321 + } 322 + /* align hw_base to buffer_size */ 394 323 hw_ptr_error(substream, 395 - "hw_ptr skipping! [Q] " 324 + "hw_ptr skipping! %s" 396 325 "(pos=%ld, delta=%ld, period=%ld, " 397 - "jdelta=%lu/%lu/%lu)\n", 326 + "jdelta=%lu/%lu/%lu, hw_ptr=%ld/%ld)\n", 327 + in_interrupt ? "[Q] " : "", 398 328 (long)pos, (long)hdelta, 399 329 (long)runtime->period_size, jdelta, 400 - ((hdelta * HZ) / runtime->rate), delta); 401 - hw_ptr_interrupt = runtime->hw_ptr_interrupt + 402 - runtime->period_size * delta; 403 - if (hw_ptr_interrupt >= runtime->boundary) 404 - hw_ptr_interrupt -= runtime->boundary; 405 - /* rebase to interrupt position */ 406 - hw_base = new_hw_ptr = hw_ptr_interrupt; 407 - /* align hw_base to buffer_size */ 408 - hw_base -= hw_base % runtime->buffer_size; 330 + ((hdelta * HZ) / runtime->rate), hw_base, 331 + (unsigned long)old_hw_ptr, 332 + (unsigned long)new_hw_ptr); 333 + /* reset values to proper state */ 409 334 delta = 0; 335 + hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size); 410 336 } 411 337 no_jiffies_check: 412 338 if (delta > runtime->period_size + runtime->period_size / 2) { 413 339 hw_ptr_error(substream, 414 - "Lost interrupts? " 415 - "(stream=%i, delta=%ld, intr_ptr=%ld)\n", 340 + "Lost interrupts? %s" 341 + "(stream=%i, delta=%ld, new_hw_ptr=%ld, " 342 + "old_hw_ptr=%ld)\n", 343 + in_interrupt ? "[Q] " : "", 416 344 substream->stream, (long)delta, 417 - (long)hw_ptr_interrupt); 418 - /* rebase hw_ptr_interrupt */ 419 - hw_ptr_interrupt = 420 - new_hw_ptr - new_hw_ptr % runtime->period_size; 345 + (long)new_hw_ptr, 346 + (long)old_hw_ptr); 421 347 } 422 - runtime->hw_ptr_interrupt = hw_ptr_interrupt; 348 + 349 + if (runtime->status->hw_ptr == new_hw_ptr) 350 + return 0; 423 351 424 352 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 425 353 runtime->silence_size > 0) 426 354 snd_pcm_playback_silence(substream, new_hw_ptr); 427 355 428 - if (runtime->status->hw_ptr == new_hw_ptr) 429 - return 0; 430 - 356 + if (in_interrupt) { 357 + runtime->hw_ptr_interrupt = new_hw_ptr - 358 + (new_hw_ptr % runtime->period_size); 359 + } 431 360 runtime->hw_ptr_base = hw_base; 432 361 runtime->status->hw_ptr = new_hw_ptr; 433 362 runtime->hw_ptr_jiffies = jiffies; 434 363 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) 435 364 snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); 436 365 437 - return snd_pcm_update_hw_ptr_post(substream, runtime); 366 + return snd_pcm_update_state(substream, runtime); 438 367 } 439 368 440 369 /* CAUTION: call it with irq disabled */ 441 370 int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) 442 371 { 443 - struct snd_pcm_runtime *runtime = substream->runtime; 444 - snd_pcm_uframes_t pos; 445 - snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base; 446 - snd_pcm_sframes_t delta; 447 - unsigned long jdelta; 448 - 449 - old_hw_ptr = runtime->status->hw_ptr; 450 - pos = snd_pcm_update_hw_ptr_pos(substream, runtime); 451 - if (pos == SNDRV_PCM_POS_XRUN) { 452 - xrun(substream); 453 - return -EPIPE; 454 - } 455 - if (xrun_debug(substream, 16)) { 456 - char name[16]; 457 - pcm_debug_name(substream, name, sizeof(name)); 458 - snd_printd("hw_update: %s: pos=0x%x/0x%x/0x%x, " 459 - "hwptr=0x%lx, hw_base=0x%lx, hw_intr=0x%lx\n", 460 - name, (unsigned int)pos, 461 - (unsigned int)runtime->period_size, 462 - (unsigned int)runtime->buffer_size, 463 - (unsigned long)old_hw_ptr, 464 - (unsigned long)runtime->hw_ptr_base, 465 - (unsigned long)runtime->hw_ptr_interrupt); 466 - } 467 - 468 - hw_base = runtime->hw_ptr_base; 469 - new_hw_ptr = hw_base + pos; 470 - 471 - delta = new_hw_ptr - old_hw_ptr; 472 - jdelta = jiffies - runtime->hw_ptr_jiffies; 473 - if (delta < 0) { 474 - delta += runtime->buffer_size; 475 - if (delta < 0) { 476 - hw_ptr_error(substream, 477 - "Unexpected hw_pointer value [2] " 478 - "(stream=%i, pos=%ld, old_ptr=%ld, jdelta=%li)\n", 479 - substream->stream, (long)pos, 480 - (long)old_hw_ptr, jdelta); 481 - return 0; 482 - } 483 - hw_base += runtime->buffer_size; 484 - if (hw_base >= runtime->boundary) 485 - hw_base = 0; 486 - new_hw_ptr = hw_base + pos; 487 - } 488 - /* Do jiffies check only in xrun_debug mode */ 489 - if (!xrun_debug(substream, 4)) 490 - goto no_jiffies_check; 491 - if (delta < runtime->delay) 492 - goto no_jiffies_check; 493 - delta -= runtime->delay; 494 - if (((delta * HZ) / runtime->rate) > jdelta + HZ/100) { 495 - hw_ptr_error(substream, 496 - "hw_ptr skipping! " 497 - "(pos=%ld, delta=%ld, period=%ld, jdelta=%lu/%lu)\n", 498 - (long)pos, (long)delta, 499 - (long)runtime->period_size, jdelta, 500 - ((delta * HZ) / runtime->rate)); 501 - return 0; 502 - } 503 - no_jiffies_check: 504 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 505 - runtime->silence_size > 0) 506 - snd_pcm_playback_silence(substream, new_hw_ptr); 507 - 508 - if (runtime->status->hw_ptr == new_hw_ptr) 509 - return 0; 510 - 511 - runtime->hw_ptr_base = hw_base; 512 - runtime->status->hw_ptr = new_hw_ptr; 513 - runtime->hw_ptr_jiffies = jiffies; 514 - if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) 515 - snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); 516 - 517 - return snd_pcm_update_hw_ptr_post(substream, runtime); 372 + return snd_pcm_update_hw_ptr0(substream, 0); 518 373 } 519 374 520 375 /** ··· 766 745 unsigned int rats_count, struct snd_ratnum *rats, 767 746 unsigned int *nump, unsigned int *denp) 768 747 { 769 - unsigned int best_num, best_diff, best_den; 748 + unsigned int best_num, best_den; 749 + int best_diff; 770 750 unsigned int k; 771 751 struct snd_interval t; 772 752 int err; 753 + unsigned int result_num, result_den; 754 + int result_diff; 773 755 774 756 best_num = best_den = best_diff = 0; 775 757 for (k = 0; k < rats_count; ++k) { ··· 794 770 den -= r; 795 771 } 796 772 diff = num - q * den; 773 + if (diff < 0) 774 + diff = -diff; 797 775 if (best_num == 0 || 798 776 diff * best_den < best_diff * den) { 799 777 best_diff = diff; ··· 810 784 t.min = div_down(best_num, best_den); 811 785 t.openmin = !!(best_num % best_den); 812 786 787 + result_num = best_num; 788 + result_diff = best_diff; 789 + result_den = best_den; 813 790 best_num = best_den = best_diff = 0; 814 791 for (k = 0; k < rats_count; ++k) { 815 792 unsigned int num = rats[k].num; ··· 835 806 den += rats[k].den_step - r; 836 807 } 837 808 diff = q * den - num; 809 + if (diff < 0) 810 + diff = -diff; 838 811 if (best_num == 0 || 839 812 diff * best_den < best_diff * den) { 840 813 best_diff = diff; ··· 856 825 return err; 857 826 858 827 if (snd_interval_single(i)) { 828 + if (best_diff * result_den < result_diff * best_den) { 829 + result_num = best_num; 830 + result_den = best_den; 831 + } 859 832 if (nump) 860 - *nump = best_num; 833 + *nump = result_num; 861 834 if (denp) 862 - *denp = best_den; 835 + *denp = result_den; 863 836 } 864 837 return err; 865 838 } ··· 1678 1643 1679 1644 snd_pcm_stream_lock_irqsave(substream, flags); 1680 1645 if (!snd_pcm_running(substream) || 1681 - snd_pcm_update_hw_ptr_interrupt(substream) < 0) 1646 + snd_pcm_update_hw_ptr0(substream, 1) < 0) 1682 1647 goto _end; 1683 1648 1684 1649 if (substream->timer_running) ··· 1709 1674 long tout; 1710 1675 1711 1676 init_waitqueue_entry(&wait, current); 1712 - add_wait_queue(&runtime->sleep, &wait); 1677 + add_wait_queue(&runtime->tsleep, &wait); 1713 1678 for (;;) { 1714 1679 if (signal_pending(current)) { 1715 1680 err = -ERESTARTSYS; ··· 1752 1717 break; 1753 1718 } 1754 1719 _endloop: 1755 - remove_wait_queue(&runtime->sleep, &wait); 1720 + remove_wait_queue(&runtime->tsleep, &wait); 1756 1721 *availp = avail; 1757 1722 return err; 1758 1723 } ··· 1811 1776 goto _end_unlock; 1812 1777 } 1813 1778 1779 + runtime->twake = 1; 1814 1780 while (size > 0) { 1815 1781 snd_pcm_uframes_t frames, appl_ptr, appl_ofs; 1816 1782 snd_pcm_uframes_t avail; ··· 1833 1797 if (frames > cont) 1834 1798 frames = cont; 1835 1799 if (snd_BUG_ON(!frames)) { 1800 + runtime->twake = 0; 1836 1801 snd_pcm_stream_unlock_irq(substream); 1837 1802 return -EINVAL; 1838 1803 } 1839 1804 appl_ptr = runtime->control->appl_ptr; 1840 1805 appl_ofs = appl_ptr % runtime->buffer_size; 1841 1806 snd_pcm_stream_unlock_irq(substream); 1842 - if ((err = transfer(substream, appl_ofs, data, offset, frames)) < 0) 1843 - goto _end; 1807 + err = transfer(substream, appl_ofs, data, offset, frames); 1844 1808 snd_pcm_stream_lock_irq(substream); 1809 + if (err < 0) 1810 + goto _end_unlock; 1845 1811 switch (runtime->status->state) { 1846 1812 case SNDRV_PCM_STATE_XRUN: 1847 1813 err = -EPIPE; ··· 1872 1834 } 1873 1835 } 1874 1836 _end_unlock: 1837 + runtime->twake = 0; 1838 + if (xfer > 0 && err >= 0) 1839 + snd_pcm_update_state(substream, runtime); 1875 1840 snd_pcm_stream_unlock_irq(substream); 1876 - _end: 1877 1841 return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; 1878 1842 } 1879 1843 ··· 2033 1993 goto _end_unlock; 2034 1994 } 2035 1995 1996 + runtime->twake = 1; 2036 1997 while (size > 0) { 2037 1998 snd_pcm_uframes_t frames, appl_ptr, appl_ofs; 2038 1999 snd_pcm_uframes_t avail; ··· 2062 2021 if (frames > cont) 2063 2022 frames = cont; 2064 2023 if (snd_BUG_ON(!frames)) { 2024 + runtime->twake = 0; 2065 2025 snd_pcm_stream_unlock_irq(substream); 2066 2026 return -EINVAL; 2067 2027 } 2068 2028 appl_ptr = runtime->control->appl_ptr; 2069 2029 appl_ofs = appl_ptr % runtime->buffer_size; 2070 2030 snd_pcm_stream_unlock_irq(substream); 2071 - if ((err = transfer(substream, appl_ofs, data, offset, frames)) < 0) 2072 - goto _end; 2031 + err = transfer(substream, appl_ofs, data, offset, frames); 2073 2032 snd_pcm_stream_lock_irq(substream); 2033 + if (err < 0) 2034 + goto _end_unlock; 2074 2035 switch (runtime->status->state) { 2075 2036 case SNDRV_PCM_STATE_XRUN: 2076 2037 err = -EPIPE; ··· 2095 2052 xfer += frames; 2096 2053 } 2097 2054 _end_unlock: 2055 + runtime->twake = 0; 2056 + if (xfer > 0 && err >= 0) 2057 + snd_pcm_update_state(substream, runtime); 2098 2058 snd_pcm_stream_unlock_irq(substream); 2099 - _end: 2100 2059 return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; 2101 2060 } 2102 2061
+55
sound/core/pcm_memory.c
··· 23 23 #include <linux/time.h> 24 24 #include <linux/init.h> 25 25 #include <linux/moduleparam.h> 26 + #include <linux/vmalloc.h> 26 27 #include <sound/core.h> 27 28 #include <sound/pcm.h> 28 29 #include <sound/info.h> ··· 435 434 } 436 435 437 436 EXPORT_SYMBOL(snd_pcm_lib_free_pages); 437 + 438 + int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream, 439 + size_t size, gfp_t gfp_flags) 440 + { 441 + struct snd_pcm_runtime *runtime; 442 + 443 + if (PCM_RUNTIME_CHECK(substream)) 444 + return -EINVAL; 445 + runtime = substream->runtime; 446 + if (runtime->dma_area) { 447 + if (runtime->dma_bytes >= size) 448 + return 0; /* already large enough */ 449 + vfree(runtime->dma_area); 450 + } 451 + runtime->dma_area = __vmalloc(size, gfp_flags, PAGE_KERNEL); 452 + if (!runtime->dma_area) 453 + return -ENOMEM; 454 + runtime->dma_bytes = size; 455 + return 1; 456 + } 457 + EXPORT_SYMBOL(_snd_pcm_lib_alloc_vmalloc_buffer); 458 + 459 + /** 460 + * snd_pcm_lib_free_vmalloc_buffer - free vmalloc buffer 461 + * @substream: the substream with a buffer allocated by 462 + * snd_pcm_lib_alloc_vmalloc_buffer() 463 + */ 464 + int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream) 465 + { 466 + struct snd_pcm_runtime *runtime; 467 + 468 + if (PCM_RUNTIME_CHECK(substream)) 469 + return -EINVAL; 470 + runtime = substream->runtime; 471 + vfree(runtime->dma_area); 472 + runtime->dma_area = NULL; 473 + return 0; 474 + } 475 + EXPORT_SYMBOL(snd_pcm_lib_free_vmalloc_buffer); 476 + 477 + /** 478 + * snd_pcm_lib_get_vmalloc_page - map vmalloc buffer offset to page struct 479 + * @substream: the substream with a buffer allocated by 480 + * snd_pcm_lib_alloc_vmalloc_buffer() 481 + * @offset: offset in the buffer 482 + * 483 + * This function is to be used as the page callback in the PCM ops. 484 + */ 485 + struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, 486 + unsigned long offset) 487 + { 488 + return vmalloc_to_page(substream->runtime->dma_area + offset); 489 + } 490 + EXPORT_SYMBOL(snd_pcm_lib_get_vmalloc_page);
+52 -7
sound/core/pcm_native.c
··· 27 27 #include <linux/pm_qos_params.h> 28 28 #include <linux/uio.h> 29 29 #include <linux/dma-mapping.h> 30 + #include <linux/math64.h> 30 31 #include <sound/core.h> 31 32 #include <sound/control.h> 32 33 #include <sound/info.h> ··· 367 366 return usecs; 368 367 } 369 368 369 + static int calc_boundary(struct snd_pcm_runtime *runtime) 370 + { 371 + u_int64_t boundary; 372 + 373 + boundary = (u_int64_t)runtime->buffer_size * 374 + (u_int64_t)runtime->period_size; 375 + #if BITS_PER_LONG < 64 376 + /* try to find lowest common multiple for buffer and period */ 377 + if (boundary > LONG_MAX - runtime->buffer_size) { 378 + u_int32_t remainder = -1; 379 + u_int32_t divident = runtime->buffer_size; 380 + u_int32_t divisor = runtime->period_size; 381 + while (remainder) { 382 + remainder = divident % divisor; 383 + if (remainder) { 384 + divident = divisor; 385 + divisor = remainder; 386 + } 387 + } 388 + boundary = div_u64(boundary, divisor); 389 + if (boundary > LONG_MAX - runtime->buffer_size) 390 + return -ERANGE; 391 + } 392 + #endif 393 + if (boundary == 0) 394 + return -ERANGE; 395 + runtime->boundary = boundary; 396 + while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) 397 + runtime->boundary *= 2; 398 + return 0; 399 + } 400 + 370 401 static int snd_pcm_hw_params(struct snd_pcm_substream *substream, 371 402 struct snd_pcm_hw_params *params) 372 403 { ··· 474 441 runtime->stop_threshold = runtime->buffer_size; 475 442 runtime->silence_threshold = 0; 476 443 runtime->silence_size = 0; 477 - runtime->boundary = runtime->buffer_size; 478 - while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) 479 - runtime->boundary *= 2; 444 + err = calc_boundary(runtime); 445 + if (err < 0) 446 + goto _error; 480 447 481 448 snd_pcm_timer_resolution_change(substream); 482 449 runtime->status->state = SNDRV_PCM_STATE_SETUP; ··· 549 516 struct snd_pcm_sw_params *params) 550 517 { 551 518 struct snd_pcm_runtime *runtime; 519 + int err; 552 520 553 521 if (PCM_RUNTIME_CHECK(substream)) 554 522 return -ENXIO; ··· 574 540 if (params->silence_threshold > runtime->buffer_size) 575 541 return -EINVAL; 576 542 } 543 + err = 0; 577 544 snd_pcm_stream_lock_irq(substream); 578 545 runtime->tstamp_mode = params->tstamp_mode; 579 546 runtime->period_step = params->period_step; ··· 588 553 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 589 554 runtime->silence_size > 0) 590 555 snd_pcm_playback_silence(substream, ULONG_MAX); 591 - wake_up(&runtime->sleep); 556 + err = snd_pcm_update_state(substream, runtime); 592 557 } 593 558 snd_pcm_stream_unlock_irq(substream); 594 - return 0; 559 + return err; 595 560 } 596 561 597 562 static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, ··· 952 917 runtime->status->state = state; 953 918 } 954 919 wake_up(&runtime->sleep); 920 + wake_up(&runtime->tsleep); 955 921 } 956 922 957 923 static struct action_ops snd_pcm_action_stop = { ··· 1038 1002 SNDRV_TIMER_EVENT_MPAUSE, 1039 1003 &runtime->trigger_tstamp); 1040 1004 wake_up(&runtime->sleep); 1005 + wake_up(&runtime->tsleep); 1041 1006 } else { 1042 1007 runtime->status->state = SNDRV_PCM_STATE_RUNNING; 1043 1008 if (substream->timer) ··· 1096 1059 runtime->status->suspended_state = runtime->status->state; 1097 1060 runtime->status->state = SNDRV_PCM_STATE_SUSPENDED; 1098 1061 wake_up(&runtime->sleep); 1062 + wake_up(&runtime->tsleep); 1099 1063 } 1100 1064 1101 1065 static struct action_ops snd_pcm_action_suspend = { ··· 3200 3162 long size; 3201 3163 unsigned long offset; 3202 3164 3203 - #ifdef pgprot_noncached 3204 3165 area->vm_page_prot = pgprot_noncached(area->vm_page_prot); 3205 - #endif 3206 3166 area->vm_flags |= VM_IO; 3207 3167 size = area->vm_end - area->vm_start; 3208 3168 offset = area->vm_pgoff << PAGE_SHIFT; ··· 3213 3177 3214 3178 EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem); 3215 3179 #endif /* SNDRV_PCM_INFO_MMAP */ 3180 + 3181 + /* mmap callback with pgprot_noncached */ 3182 + int snd_pcm_lib_mmap_noncached(struct snd_pcm_substream *substream, 3183 + struct vm_area_struct *area) 3184 + { 3185 + area->vm_page_prot = pgprot_noncached(area->vm_page_prot); 3186 + return snd_pcm_default_mmap(substream, area); 3187 + } 3188 + EXPORT_SYMBOL(snd_pcm_lib_mmap_noncached); 3216 3189 3217 3190 /* 3218 3191 * mmap DMA buffer
+1 -1
sound/core/seq/seq_clientmgr.c
··· 2190 2190 if (p->cmd == cmd) 2191 2191 return p->func(client, arg); 2192 2192 } 2193 - snd_printd("seq unknown ioctl() 0x%x (type='%c', number=0x%2x)\n", 2193 + snd_printd("seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n", 2194 2194 cmd, _IOC_TYPE(cmd), _IOC_NR(cmd)); 2195 2195 return -ENOTTY; 2196 2196 }
+13 -14
sound/core/seq/seq_timer.c
··· 33 33 34 34 #define SKEW_BASE 0x10000 /* 16bit shift */ 35 35 36 - static void snd_seq_timer_set_tick_resolution(struct snd_seq_timer_tick *tick, 37 - int tempo, int ppq) 36 + static void snd_seq_timer_set_tick_resolution(struct snd_seq_timer *tmr) 38 37 { 39 - if (tempo < 1000000) 40 - tick->resolution = (tempo * 1000) / ppq; 38 + if (tmr->tempo < 1000000) 39 + tmr->tick.resolution = (tmr->tempo * 1000) / tmr->ppq; 41 40 else { 42 41 /* might overflow.. */ 43 42 unsigned int s; 44 - s = tempo % ppq; 45 - s = (s * 1000) / ppq; 46 - tick->resolution = (tempo / ppq) * 1000; 47 - tick->resolution += s; 43 + s = tmr->tempo % tmr->ppq; 44 + s = (s * 1000) / tmr->ppq; 45 + tmr->tick.resolution = (tmr->tempo / tmr->ppq) * 1000; 46 + tmr->tick.resolution += s; 48 47 } 49 - if (tick->resolution <= 0) 50 - tick->resolution = 1; 51 - snd_seq_timer_update_tick(tick, 0); 48 + if (tmr->tick.resolution <= 0) 49 + tmr->tick.resolution = 1; 50 + snd_seq_timer_update_tick(&tmr->tick, 0); 52 51 } 53 52 54 53 /* create new timer (constructor) */ ··· 95 96 /* setup defaults */ 96 97 tmr->ppq = 96; /* 96 PPQ */ 97 98 tmr->tempo = 500000; /* 120 BPM */ 98 - snd_seq_timer_set_tick_resolution(&tmr->tick, tmr->tempo, tmr->ppq); 99 + snd_seq_timer_set_tick_resolution(tmr); 99 100 tmr->running = 0; 100 101 101 102 tmr->type = SNDRV_SEQ_TIMER_ALSA; ··· 179 180 spin_lock_irqsave(&tmr->lock, flags); 180 181 if ((unsigned int)tempo != tmr->tempo) { 181 182 tmr->tempo = tempo; 182 - snd_seq_timer_set_tick_resolution(&tmr->tick, tmr->tempo, tmr->ppq); 183 + snd_seq_timer_set_tick_resolution(tmr); 183 184 } 184 185 spin_unlock_irqrestore(&tmr->lock, flags); 185 186 return 0; ··· 204 205 } 205 206 206 207 tmr->ppq = ppq; 207 - snd_seq_timer_set_tick_resolution(&tmr->tick, tmr->tempo, tmr->ppq); 208 + snd_seq_timer_set_tick_resolution(tmr); 208 209 spin_unlock_irqrestore(&tmr->lock, flags); 209 210 return 0; 210 211 }
+180 -110
sound/drivers/dummy.c
··· 45 45 #define MAX_PCM_SUBSTREAMS 128 46 46 #define MAX_MIDI_DEVICES 2 47 47 48 - #if 0 /* emu10k1 emulation */ 49 - #define MAX_BUFFER_SIZE (128 * 1024) 50 - static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime) 51 - { 52 - int err; 53 - err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 54 - if (err < 0) 55 - return err; 56 - err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX); 57 - if (err < 0) 58 - return err; 59 - return 0; 60 - } 61 - #define add_playback_constraints emu10k1_playback_constraints 62 - #endif 63 - 64 - #if 0 /* RME9652 emulation */ 65 - #define MAX_BUFFER_SIZE (26 * 64 * 1024) 66 - #define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE 67 - #define USE_CHANNELS_MIN 26 68 - #define USE_CHANNELS_MAX 26 69 - #define USE_PERIODS_MIN 2 70 - #define USE_PERIODS_MAX 2 71 - #endif 72 - 73 - #if 0 /* ICE1712 emulation */ 74 - #define MAX_BUFFER_SIZE (256 * 1024) 75 - #define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE 76 - #define USE_CHANNELS_MIN 10 77 - #define USE_CHANNELS_MAX 10 78 - #define USE_PERIODS_MIN 1 79 - #define USE_PERIODS_MAX 1024 80 - #endif 81 - 82 - #if 0 /* UDA1341 emulation */ 83 - #define MAX_BUFFER_SIZE (16380) 84 - #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE 85 - #define USE_CHANNELS_MIN 2 86 - #define USE_CHANNELS_MAX 2 87 - #define USE_PERIODS_MIN 2 88 - #define USE_PERIODS_MAX 255 89 - #endif 90 - 91 - #if 0 /* simple AC97 bridge (intel8x0) with 48kHz AC97 only codec */ 92 - #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE 93 - #define USE_CHANNELS_MIN 2 94 - #define USE_CHANNELS_MAX 2 95 - #define USE_RATE SNDRV_PCM_RATE_48000 96 - #define USE_RATE_MIN 48000 97 - #define USE_RATE_MAX 48000 98 - #endif 99 - 100 - #if 0 /* CA0106 */ 101 - #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE 102 - #define USE_CHANNELS_MIN 2 103 - #define USE_CHANNELS_MAX 2 104 - #define USE_RATE (SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_96000|SNDRV_PCM_RATE_192000) 105 - #define USE_RATE_MIN 48000 106 - #define USE_RATE_MAX 192000 107 - #define MAX_BUFFER_SIZE ((65536-64)*8) 108 - #define MAX_PERIOD_SIZE (65536-64) 109 - #define USE_PERIODS_MIN 2 110 - #define USE_PERIODS_MAX 8 111 - #endif 112 - 113 - 114 48 /* defaults */ 115 - #ifndef MAX_BUFFER_SIZE 116 49 #define MAX_BUFFER_SIZE (64*1024) 117 - #endif 118 - #ifndef MAX_PERIOD_SIZE 50 + #define MIN_PERIOD_SIZE 64 119 51 #define MAX_PERIOD_SIZE MAX_BUFFER_SIZE 120 - #endif 121 - #ifndef USE_FORMATS 122 52 #define USE_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE) 123 - #endif 124 - #ifndef USE_RATE 125 53 #define USE_RATE SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000 126 54 #define USE_RATE_MIN 5500 127 55 #define USE_RATE_MAX 48000 128 - #endif 129 - #ifndef USE_CHANNELS_MIN 130 56 #define USE_CHANNELS_MIN 1 131 - #endif 132 - #ifndef USE_CHANNELS_MAX 133 57 #define USE_CHANNELS_MAX 2 134 - #endif 135 - #ifndef USE_PERIODS_MIN 136 58 #define USE_PERIODS_MIN 1 137 - #endif 138 - #ifndef USE_PERIODS_MAX 139 59 #define USE_PERIODS_MAX 1024 140 - #endif 141 - #ifndef add_playback_constraints 142 - #define add_playback_constraints(x) 0 143 - #endif 144 - #ifndef add_capture_constraints 145 - #define add_capture_constraints(x) 0 146 - #endif 147 60 148 61 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 149 62 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 150 63 static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; 64 + static char *model[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = NULL}; 151 65 static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 152 66 static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 8}; 153 67 //static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; ··· 76 162 MODULE_PARM_DESC(id, "ID string for dummy soundcard."); 77 163 module_param_array(enable, bool, NULL, 0444); 78 164 MODULE_PARM_DESC(enable, "Enable this dummy soundcard."); 165 + module_param_array(model, charp, NULL, 0444); 166 + MODULE_PARM_DESC(model, "Soundcard model."); 79 167 module_param_array(pcm_devs, int, NULL, 0444); 80 168 MODULE_PARM_DESC(pcm_devs, "PCM devices # (0-4) for dummy driver."); 81 169 module_param_array(pcm_substreams, int, NULL, 0444); ··· 109 193 snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *); 110 194 }; 111 195 196 + struct dummy_model { 197 + const char *name; 198 + int (*playback_constraints)(struct snd_pcm_runtime *runtime); 199 + int (*capture_constraints)(struct snd_pcm_runtime *runtime); 200 + u64 formats; 201 + size_t buffer_bytes_max; 202 + size_t period_bytes_min; 203 + size_t period_bytes_max; 204 + unsigned int periods_min; 205 + unsigned int periods_max; 206 + unsigned int rates; 207 + unsigned int rate_min; 208 + unsigned int rate_max; 209 + unsigned int channels_min; 210 + unsigned int channels_max; 211 + }; 212 + 112 213 struct snd_dummy { 113 214 struct snd_card *card; 215 + struct dummy_model *model; 114 216 struct snd_pcm *pcm; 217 + struct snd_pcm_hardware pcm_hw; 115 218 spinlock_t mixer_lock; 116 219 int mixer_volume[MIXER_ADDR_LAST+1][2]; 117 220 int capture_source[MIXER_ADDR_LAST+1][2]; 118 221 const struct dummy_timer_ops *timer_ops; 222 + }; 223 + 224 + /* 225 + * card models 226 + */ 227 + 228 + static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime) 229 + { 230 + int err; 231 + err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 232 + if (err < 0) 233 + return err; 234 + err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX); 235 + if (err < 0) 236 + return err; 237 + return 0; 238 + } 239 + 240 + struct dummy_model model_emu10k1 = { 241 + .name = "emu10k1", 242 + .playback_constraints = emu10k1_playback_constraints, 243 + .buffer_bytes_max = 128 * 1024, 244 + }; 245 + 246 + struct dummy_model model_rme9652 = { 247 + .name = "rme9652", 248 + .buffer_bytes_max = 26 * 64 * 1024, 249 + .formats = SNDRV_PCM_FMTBIT_S32_LE, 250 + .channels_min = 26, 251 + .channels_max = 26, 252 + .periods_min = 2, 253 + .periods_max = 2, 254 + }; 255 + 256 + struct dummy_model model_ice1712 = { 257 + .name = "ice1712", 258 + .buffer_bytes_max = 256 * 1024, 259 + .formats = SNDRV_PCM_FMTBIT_S32_LE, 260 + .channels_min = 10, 261 + .channels_max = 10, 262 + .periods_min = 1, 263 + .periods_max = 1024, 264 + }; 265 + 266 + struct dummy_model model_uda1341 = { 267 + .name = "uda1341", 268 + .buffer_bytes_max = 16380, 269 + .formats = SNDRV_PCM_FMTBIT_S16_LE, 270 + .channels_min = 2, 271 + .channels_max = 2, 272 + .periods_min = 2, 273 + .periods_max = 255, 274 + }; 275 + 276 + struct dummy_model model_ac97 = { 277 + .name = "ac97", 278 + .formats = SNDRV_PCM_FMTBIT_S16_LE, 279 + .channels_min = 2, 280 + .channels_max = 2, 281 + .rates = SNDRV_PCM_RATE_48000, 282 + .rate_min = 48000, 283 + .rate_max = 48000, 284 + }; 285 + 286 + struct dummy_model model_ca0106 = { 287 + .name = "ca0106", 288 + .formats = SNDRV_PCM_FMTBIT_S16_LE, 289 + .buffer_bytes_max = ((65536-64)*8), 290 + .period_bytes_max = (65536-64), 291 + .periods_min = 2, 292 + .periods_max = 8, 293 + .channels_min = 2, 294 + .channels_max = 2, 295 + .rates = SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_96000|SNDRV_PCM_RATE_192000, 296 + .rate_min = 48000, 297 + .rate_max = 192000, 298 + }; 299 + 300 + struct dummy_model *dummy_models[] = { 301 + &model_emu10k1, 302 + &model_rme9652, 303 + &model_ice1712, 304 + &model_uda1341, 305 + &model_ac97, 306 + &model_ca0106, 307 + NULL 119 308 }; 120 309 121 310 /* ··· 530 509 .channels_min = USE_CHANNELS_MIN, 531 510 .channels_max = USE_CHANNELS_MAX, 532 511 .buffer_bytes_max = MAX_BUFFER_SIZE, 533 - .period_bytes_min = 64, 512 + .period_bytes_min = MIN_PERIOD_SIZE, 534 513 .period_bytes_max = MAX_PERIOD_SIZE, 535 514 .periods_min = USE_PERIODS_MIN, 536 515 .periods_max = USE_PERIODS_MAX, ··· 559 538 static int dummy_pcm_open(struct snd_pcm_substream *substream) 560 539 { 561 540 struct snd_dummy *dummy = snd_pcm_substream_chip(substream); 541 + struct dummy_model *model = dummy->model; 562 542 struct snd_pcm_runtime *runtime = substream->runtime; 563 543 int err; 564 544 ··· 573 551 if (err < 0) 574 552 return err; 575 553 576 - runtime->hw = dummy_pcm_hardware; 554 + runtime->hw = dummy->pcm_hw; 577 555 if (substream->pcm->device & 1) { 578 556 runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; 579 557 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; ··· 582 560 runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP | 583 561 SNDRV_PCM_INFO_MMAP_VALID); 584 562 585 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 586 - err = add_playback_constraints(substream->runtime); 587 - else 588 - err = add_capture_constraints(substream->runtime); 563 + if (model == NULL) 564 + return 0; 565 + 566 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 567 + if (model->playback_constraints) 568 + err = model->playback_constraints(substream->runtime); 569 + } else { 570 + if (model->capture_constraints) 571 + err = model->capture_constraints(substream->runtime); 572 + } 589 573 if (err < 0) { 590 574 dummy->timer_ops->free(substream); 591 575 return err; ··· 851 823 /* 852 824 * proc interface 853 825 */ 854 - static void print_formats(struct snd_info_buffer *buffer) 826 + static void print_formats(struct snd_dummy *dummy, 827 + struct snd_info_buffer *buffer) 855 828 { 856 829 int i; 857 830 858 831 for (i = 0; i < SNDRV_PCM_FORMAT_LAST; i++) { 859 - if (dummy_pcm_hardware.formats & (1ULL << i)) 832 + if (dummy->pcm_hw.formats & (1ULL << i)) 860 833 snd_iprintf(buffer, " %s", snd_pcm_format_name(i)); 861 834 } 862 835 } 863 836 864 - static void print_rates(struct snd_info_buffer *buffer) 837 + static void print_rates(struct snd_dummy *dummy, 838 + struct snd_info_buffer *buffer) 865 839 { 866 840 static int rates[] = { 867 841 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, ··· 871 841 }; 872 842 int i; 873 843 874 - if (dummy_pcm_hardware.rates & SNDRV_PCM_RATE_CONTINUOUS) 844 + if (dummy->pcm_hw.rates & SNDRV_PCM_RATE_CONTINUOUS) 875 845 snd_iprintf(buffer, " continuous"); 876 - if (dummy_pcm_hardware.rates & SNDRV_PCM_RATE_KNOT) 846 + if (dummy->pcm_hw.rates & SNDRV_PCM_RATE_KNOT) 877 847 snd_iprintf(buffer, " knot"); 878 848 for (i = 0; i < ARRAY_SIZE(rates); i++) 879 - if (dummy_pcm_hardware.rates & (1 << i)) 849 + if (dummy->pcm_hw.rates & (1 << i)) 880 850 snd_iprintf(buffer, " %d", rates[i]); 881 851 } 882 852 883 - #define get_dummy_int_ptr(ofs) \ 884 - (unsigned int *)((char *)&dummy_pcm_hardware + (ofs)) 885 - #define get_dummy_ll_ptr(ofs) \ 886 - (unsigned long long *)((char *)&dummy_pcm_hardware + (ofs)) 853 + #define get_dummy_int_ptr(dummy, ofs) \ 854 + (unsigned int *)((char *)&((dummy)->pcm_hw) + (ofs)) 855 + #define get_dummy_ll_ptr(dummy, ofs) \ 856 + (unsigned long long *)((char *)&((dummy)->pcm_hw) + (ofs)) 887 857 888 858 struct dummy_hw_field { 889 859 const char *name; ··· 914 884 static void dummy_proc_read(struct snd_info_entry *entry, 915 885 struct snd_info_buffer *buffer) 916 886 { 887 + struct snd_dummy *dummy = entry->private_data; 917 888 int i; 918 889 919 890 for (i = 0; i < ARRAY_SIZE(fields); i++) { 920 891 snd_iprintf(buffer, "%s ", fields[i].name); 921 892 if (fields[i].size == sizeof(int)) 922 893 snd_iprintf(buffer, fields[i].format, 923 - *get_dummy_int_ptr(fields[i].offset)); 894 + *get_dummy_int_ptr(dummy, fields[i].offset)); 924 895 else 925 896 snd_iprintf(buffer, fields[i].format, 926 - *get_dummy_ll_ptr(fields[i].offset)); 897 + *get_dummy_ll_ptr(dummy, fields[i].offset)); 927 898 if (!strcmp(fields[i].name, "formats")) 928 - print_formats(buffer); 899 + print_formats(dummy, buffer); 929 900 else if (!strcmp(fields[i].name, "rates")) 930 - print_rates(buffer); 901 + print_rates(dummy, buffer); 931 902 snd_iprintf(buffer, "\n"); 932 903 } 933 904 } ··· 936 905 static void dummy_proc_write(struct snd_info_entry *entry, 937 906 struct snd_info_buffer *buffer) 938 907 { 908 + struct snd_dummy *dummy = entry->private_data; 939 909 char line[64]; 940 910 941 911 while (!snd_info_get_line(buffer, line, sizeof(line))) { ··· 956 924 if (strict_strtoull(item, 0, &val)) 957 925 continue; 958 926 if (fields[i].size == sizeof(int)) 959 - *get_dummy_int_ptr(fields[i].offset) = val; 927 + *get_dummy_int_ptr(dummy, fields[i].offset) = val; 960 928 else 961 - *get_dummy_ll_ptr(fields[i].offset) = val; 929 + *get_dummy_ll_ptr(dummy, fields[i].offset) = val; 962 930 } 963 931 } 964 932 ··· 970 938 snd_info_set_text_ops(entry, chip, dummy_proc_read); 971 939 entry->c.text.write = dummy_proc_write; 972 940 entry->mode |= S_IWUSR; 941 + entry->private_data = chip; 973 942 } 974 943 } 975 944 #else ··· 981 948 { 982 949 struct snd_card *card; 983 950 struct snd_dummy *dummy; 951 + struct dummy_model *m = NULL, **mdl; 984 952 int idx, err; 985 953 int dev = devptr->id; 986 954 ··· 991 957 return err; 992 958 dummy = card->private_data; 993 959 dummy->card = card; 960 + for (mdl = dummy_models; *mdl && model[dev]; mdl++) { 961 + if (strcmp(model[dev], (*mdl)->name) == 0) { 962 + printk(KERN_INFO 963 + "snd-dummy: Using model '%s' for card %i\n", 964 + (*mdl)->name, card->number); 965 + m = dummy->model = *mdl; 966 + break; 967 + } 968 + } 994 969 for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) { 995 970 if (pcm_substreams[dev] < 1) 996 971 pcm_substreams[dev] = 1; ··· 1009 966 if (err < 0) 1010 967 goto __nodev; 1011 968 } 969 + 970 + dummy->pcm_hw = dummy_pcm_hardware; 971 + if (m) { 972 + if (m->formats) 973 + dummy->pcm_hw.formats = m->formats; 974 + if (m->buffer_bytes_max) 975 + dummy->pcm_hw.buffer_bytes_max = m->buffer_bytes_max; 976 + if (m->period_bytes_min) 977 + dummy->pcm_hw.period_bytes_min = m->period_bytes_min; 978 + if (m->period_bytes_max) 979 + dummy->pcm_hw.period_bytes_max = m->period_bytes_max; 980 + if (m->periods_min) 981 + dummy->pcm_hw.periods_min = m->periods_min; 982 + if (m->periods_max) 983 + dummy->pcm_hw.periods_max = m->periods_max; 984 + if (m->rates) 985 + dummy->pcm_hw.rates = m->rates; 986 + if (m->rate_min) 987 + dummy->pcm_hw.rate_min = m->rate_min; 988 + if (m->rate_max) 989 + dummy->pcm_hw.rate_max = m->rate_max; 990 + if (m->channels_min) 991 + dummy->pcm_hw.channels_min = m->channels_min; 992 + if (m->channels_max) 993 + dummy->pcm_hw.channels_max = m->channels_max; 994 + } 995 + 1012 996 err = snd_card_dummy_new_mixer(dummy); 1013 997 if (err < 0) 1014 998 goto __nodev;
+7 -54
sound/drivers/vx/vx_pcm.c
··· 46 46 */ 47 47 48 48 #include <linux/slab.h> 49 - #include <linux/vmalloc.h> 50 49 #include <linux/delay.h> 51 50 #include <sound/core.h> 52 51 #include <sound/asoundef.h> 53 52 #include <sound/pcm.h> 54 53 #include <sound/vx_core.h> 55 54 #include "vx_cmd.h" 56 - 57 - 58 - /* 59 - * we use a vmalloc'ed (sg-)buffer 60 - */ 61 - 62 - /* get the physical page pointer on the given offset */ 63 - static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, 64 - unsigned long offset) 65 - { 66 - void *pageptr = subs->runtime->dma_area + offset; 67 - return vmalloc_to_page(pageptr); 68 - } 69 - 70 - /* 71 - * allocate a buffer via vmalloc_32(). 72 - * called from hw_params 73 - * NOTE: this may be called not only once per pcm open! 74 - */ 75 - static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) 76 - { 77 - struct snd_pcm_runtime *runtime = subs->runtime; 78 - if (runtime->dma_area) { 79 - /* already allocated */ 80 - if (runtime->dma_bytes >= size) 81 - return 0; /* already enough large */ 82 - vfree(runtime->dma_area); 83 - } 84 - runtime->dma_area = vmalloc_32(size); 85 - if (! runtime->dma_area) 86 - return -ENOMEM; 87 - memset(runtime->dma_area, 0, size); 88 - runtime->dma_bytes = size; 89 - return 1; /* changed */ 90 - } 91 - 92 - /* 93 - * free the buffer. 94 - * called from hw_free callback 95 - * NOTE: this may be called not only once per pcm open! 96 - */ 97 - static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) 98 - { 99 - struct snd_pcm_runtime *runtime = subs->runtime; 100 - 101 - vfree(runtime->dma_area); 102 - runtime->dma_area = NULL; 103 - return 0; 104 - } 105 55 106 56 107 57 /* ··· 815 865 static int vx_pcm_hw_params(struct snd_pcm_substream *subs, 816 866 struct snd_pcm_hw_params *hw_params) 817 867 { 818 - return snd_pcm_alloc_vmalloc_buffer(subs, params_buffer_bytes(hw_params)); 868 + return snd_pcm_lib_alloc_vmalloc_32_buffer 869 + (subs, params_buffer_bytes(hw_params)); 819 870 } 820 871 821 872 /* ··· 824 873 */ 825 874 static int vx_pcm_hw_free(struct snd_pcm_substream *subs) 826 875 { 827 - return snd_pcm_free_vmalloc_buffer(subs); 876 + return snd_pcm_lib_free_vmalloc_buffer(subs); 828 877 } 829 878 830 879 /* ··· 904 953 .prepare = vx_pcm_prepare, 905 954 .trigger = vx_pcm_trigger, 906 955 .pointer = vx_pcm_playback_pointer, 907 - .page = snd_pcm_get_vmalloc_page, 956 + .page = snd_pcm_lib_get_vmalloc_page, 957 + .mmap = snd_pcm_lib_mmap_vmalloc, 908 958 }; 909 959 910 960 ··· 1125 1173 .prepare = vx_pcm_prepare, 1126 1174 .trigger = vx_pcm_trigger, 1127 1175 .pointer = vx_pcm_capture_pointer, 1128 - .page = snd_pcm_get_vmalloc_page, 1176 + .page = snd_pcm_lib_get_vmalloc_page, 1177 + .mmap = snd_pcm_lib_mmap_vmalloc, 1129 1178 }; 1130 1179 1131 1180
+20 -17
sound/isa/Kconfig
··· 63 63 will be called snd-ad1848. 64 64 65 65 config SND_ALS100 66 - tristate "Avance Logic ALS100/ALS120" 66 + tristate "Diamond Tech. DT-019x and Avance Logic ALSxxx" 67 67 depends on PNP 68 68 select ISAPNP 69 69 select SND_OPL3_LIB 70 70 select SND_MPU401_UART 71 71 select SND_SB16_DSP 72 72 help 73 - Say Y here to include support for soundcards based on Avance 74 - Logic ALS100, ALS110, ALS120 and ALS200 chips. 73 + Say Y here to include support for soundcards based on the 74 + Diamond Technologies DT-019X or Avance Logic chips: ALS007, 75 + ALS100, ALS110, ALS120 and ALS200 chips. 75 76 76 77 To compile this driver as a module, choose M here: the module 77 78 will be called snd-als100. ··· 127 126 128 127 To compile this driver as a module, choose M here: the module 129 128 will be called snd-cs4236. 130 - 131 - config SND_DT019X 132 - tristate "Diamond Technologies DT-019X, Avance Logic ALS-007" 133 - depends on PNP 134 - select ISAPNP 135 - select SND_OPL3_LIB 136 - select SND_MPU401_UART 137 - select SND_SB16_DSP 138 - help 139 - Say Y here to include support for soundcards based on the 140 - Diamond Technologies DT-019X or Avance Logic ALS-007 chips. 141 - 142 - To compile this driver as a module, choose M here: the module 143 - will be called snd-dt019x. 144 129 145 130 config SND_ES968 146 131 tristate "Generic ESS ES968 driver" ··· 238 251 239 252 To compile this driver as a module, choose M here: the module 240 253 will be called snd-interwave-stb. 254 + 255 + config SND_JAZZ16 256 + tristate "Media Vision Jazz16 card and compatibles" 257 + select SND_OPL3_LIB 258 + select SND_MPU401_UART 259 + select SND_SB8_DSP 260 + help 261 + Say Y here to include support for soundcards based on the 262 + Media Vision Jazz16 chipset: digital chip MVD1216 (Jazz16), 263 + codec MVA416 (CS4216) and mixer MVA514 (ICS2514). 264 + Media Vision's Jazz16 cards were sold under names Pro Sonic 16, 265 + Premium 3-D and Pro 3-D. There were also OEMs cards with the 266 + Jazz16 chipset. 267 + 268 + To compile this driver as a module, choose M here: the module 269 + will be called snd-jazz16. 241 270 242 271 config SND_OPL3SA2 243 272 tristate "Yamaha OPL3-SA2/SA3"
-2
sound/isa/Makefile
··· 7 7 snd-als100-objs := als100.o 8 8 snd-azt2320-objs := azt2320.o 9 9 snd-cmi8330-objs := cmi8330.o 10 - snd-dt019x-objs := dt019x.o 11 10 snd-es18xx-objs := es18xx.o 12 11 snd-opl3sa2-objs := opl3sa2.o 13 12 snd-sc6000-objs := sc6000.o ··· 18 19 obj-$(CONFIG_SND_ALS100) += snd-als100.o 19 20 obj-$(CONFIG_SND_AZT2320) += snd-azt2320.o 20 21 obj-$(CONFIG_SND_CMI8330) += snd-cmi8330.o 21 - obj-$(CONFIG_SND_DT019X) += snd-dt019x.o 22 22 obj-$(CONFIG_SND_ES18XX) += snd-es18xx.o 23 23 obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o 24 24 obj-$(CONFIG_SND_SC6000) += snd-sc6000.o
+86 -35
sound/isa/als100.c
··· 2 2 /* 3 3 card-als100.c - driver for Avance Logic ALS100 based soundcards. 4 4 Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it> 5 + Copyright (C) 1999-2002 by Massimo Piccioni <dafastidio@libero.it> 5 6 6 7 Thanks to Pierfrancesco 'qM2' Passerini. 8 + 9 + Generalised for soundcards based on DT-0196 and ALS-007 chips 10 + by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>: June 2002. 7 11 8 12 This program is free software; you can redistribute it and/or modify 9 13 it under the terms of the GNU General Public License as published by ··· 37 33 38 34 #define PFX "als100: " 39 35 40 - MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); 41 - MODULE_DESCRIPTION("Avance Logic ALS1X0"); 42 - MODULE_LICENSE("GPL"); 43 - MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS100 - PRO16PNP}," 36 + MODULE_DESCRIPTION("Avance Logic ALS007/ALS1X0"); 37 + MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X}," 38 + "{Avance Logic ALS-007}}" 39 + "{{Avance Logic,ALS100 - PRO16PNP}," 44 40 "{Avance Logic,ALS110}," 45 41 "{Avance Logic,ALS120}," 46 42 "{Avance Logic,ALS200}," ··· 49 45 "{Avance Logic,ALS120}," 50 46 "{RTL,RTL3000}}"); 51 47 48 + MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); 49 + MODULE_LICENSE("GPL"); 50 + 52 51 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 53 52 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 54 - static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 53 + static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 55 54 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 56 55 static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 57 56 static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ ··· 64 57 static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ 65 58 66 59 module_param_array(index, int, NULL, 0444); 67 - MODULE_PARM_DESC(index, "Index value for als100 based soundcard."); 60 + MODULE_PARM_DESC(index, "Index value for Avance Logic based soundcard."); 68 61 module_param_array(id, charp, NULL, 0444); 69 - MODULE_PARM_DESC(id, "ID string for als100 based soundcard."); 62 + MODULE_PARM_DESC(id, "ID string for Avance Logic based soundcard."); 70 63 module_param_array(enable, bool, NULL, 0444); 71 - MODULE_PARM_DESC(enable, "Enable als100 based soundcard."); 64 + MODULE_PARM_DESC(enable, "Enable Avance Logic based soundcard."); 65 + 66 + MODULE_ALIAS("snd-dt019x"); 72 67 73 68 struct snd_card_als100 { 74 - int dev_no; 75 69 struct pnp_dev *dev; 76 70 struct pnp_dev *devmpu; 77 71 struct pnp_dev *devopl; ··· 80 72 }; 81 73 82 74 static struct pnp_card_device_id snd_als100_pnpids[] = { 75 + /* DT197A30 */ 76 + { .id = "RWB1688", 77 + .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, 78 + .driver_data = SB_HW_DT019X }, 79 + /* DT0196 / ALS-007 */ 80 + { .id = "ALS0007", 81 + .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, 82 + .driver_data = SB_HW_DT019X }, 83 83 /* ALS100 - PRO16PNP */ 84 - { .id = "ALS0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } } }, 84 + { .id = "ALS0001", 85 + .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, 86 + .driver_data = SB_HW_ALS100 }, 85 87 /* ALS110 - MF1000 - Digimate 3D Sound */ 86 - { .id = "ALS0110", .devs = { { "@@@1001" }, { "@X@1001" }, { "@H@1001" } } }, 88 + { .id = "ALS0110", 89 + .devs = { { "@@@1001" }, { "@X@1001" }, { "@H@1001" } }, 90 + .driver_data = SB_HW_ALS100 }, 87 91 /* ALS120 */ 88 - { .id = "ALS0120", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } }, 92 + { .id = "ALS0120", 93 + .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } }, 94 + .driver_data = SB_HW_ALS100 }, 89 95 /* ALS200 */ 90 - { .id = "ALS0200", .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0001" } } }, 96 + { .id = "ALS0200", 97 + .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0001" } }, 98 + .driver_data = SB_HW_ALS100 }, 91 99 /* ALS200 OEM */ 92 - { .id = "ALS0200", .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0020" } } }, 100 + { .id = "ALS0200", 101 + .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0020" } }, 102 + .driver_data = SB_HW_ALS100 }, 93 103 /* RTL3000 */ 94 - { .id = "RTL3000", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } }, 95 - { .id = "", } /* end */ 104 + { .id = "RTL3000", 105 + .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } }, 106 + .driver_data = SB_HW_ALS100 }, 107 + { .id = "" } /* end */ 96 108 }; 97 109 98 110 MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids); 99 - 100 - #define DRIVER_NAME "snd-card-als100" 101 111 102 112 static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, 103 113 struct pnp_card_link *card, ··· 139 113 return err; 140 114 } 141 115 port[dev] = pnp_port_start(pdev, 0); 142 - dma8[dev] = pnp_dma(pdev, 1); 143 - dma16[dev] = pnp_dma(pdev, 0); 116 + if (id->driver_data == SB_HW_DT019X) 117 + dma8[dev] = pnp_dma(pdev, 0); 118 + else { 119 + dma8[dev] = pnp_dma(pdev, 1); 120 + dma16[dev] = pnp_dma(pdev, 0); 121 + } 144 122 irq[dev] = pnp_irq(pdev, 0); 145 123 146 124 pdev = acard->devmpu; ··· 205 175 } 206 176 snd_card_set_dev(card, &pcard->card->dev); 207 177 208 - if ((error = snd_sbdsp_create(card, port[dev], 209 - irq[dev], 210 - snd_sb16dsp_interrupt, 211 - dma8[dev], 212 - dma16[dev], 213 - SB_HW_ALS100, &chip)) < 0) { 178 + if (pid->driver_data == SB_HW_DT019X) 179 + dma16[dev] = -1; 180 + 181 + error = snd_sbdsp_create(card, port[dev], irq[dev], 182 + snd_sb16dsp_interrupt, 183 + dma8[dev], dma16[dev], 184 + pid->driver_data, 185 + &chip); 186 + if (error < 0) { 214 187 snd_card_free(card); 215 188 return error; 216 189 } 217 190 acard->chip = chip; 218 191 219 - strcpy(card->driver, "ALS100"); 220 - strcpy(card->shortname, "Avance Logic ALS100"); 221 - sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", 222 - card->shortname, chip->name, chip->port, 223 - irq[dev], dma8[dev], dma16[dev]); 192 + if (pid->driver_data == SB_HW_DT019X) { 193 + strcpy(card->driver, "DT-019X"); 194 + strcpy(card->shortname, "Diamond Tech. DT-019X"); 195 + sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", 196 + card->shortname, chip->name, chip->port, 197 + irq[dev], dma8[dev]); 198 + } else { 199 + strcpy(card->driver, "ALS100"); 200 + strcpy(card->shortname, "Avance Logic ALS100"); 201 + sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", 202 + card->shortname, chip->name, chip->port, 203 + irq[dev], dma8[dev], dma16[dev]); 204 + } 224 205 225 206 if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { 226 207 snd_card_free(card); ··· 244 203 } 245 204 246 205 if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { 247 - if (snd_mpu401_uart_new(card, 0, MPU401_HW_ALS100, 206 + int mpu_type = MPU401_HW_ALS100; 207 + 208 + if (mpu_irq[dev] == SNDRV_AUTO_IRQ) 209 + mpu_irq[dev] = -1; 210 + 211 + if (pid->driver_data == SB_HW_DT019X) 212 + mpu_type = MPU401_HW_MPU401; 213 + 214 + if (snd_mpu401_uart_new(card, 0, 215 + mpu_type, 248 216 mpu_port[dev], 0, 249 - mpu_irq[dev], IRQF_DISABLED, 217 + mpu_irq[dev], 218 + mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, 250 219 NULL) < 0) 251 220 snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]); 252 221 } ··· 342 291 343 292 static struct pnp_card_driver als100_pnpc_driver = { 344 293 .flags = PNP_DRIVER_RES_DISABLE, 345 - .name = "als100", 294 + .name = "als100", 346 295 .id_table = snd_als100_pnpids, 347 296 .probe = snd_als100_pnp_detect, 348 297 .remove = __devexit_p(snd_als100_pnp_remove), ··· 363 312 if (!als100_devices) { 364 313 pnp_unregister_card_driver(&als100_pnpc_driver); 365 314 #ifdef MODULE 366 - snd_printk(KERN_ERR "no ALS100 based soundcards found\n"); 315 + snd_printk(KERN_ERR "no Avance Logic based soundcards found\n"); 367 316 #endif 368 317 return -ENODEV; 369 318 }
-321
sound/isa/dt019x.c
··· 1 - 2 - /* 3 - dt019x.c - driver for Diamond Technologies DT-0197H based soundcards. 4 - Copyright (C) 1999, 2002 by Massimo Piccioni <dafastidio@libero.it> 5 - 6 - Generalised for soundcards based on DT-0196 and ALS-007 chips 7 - by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>: June 2002. 8 - 9 - This program is free software; you can redistribute it and/or modify 10 - it under the terms of the GNU General Public License as published by 11 - the Free Software Foundation; either version 2 of the License, or 12 - (at your option) any later version. 13 - 14 - This program is distributed in the hope that it will be useful, 15 - but WITHOUT ANY WARRANTY; without even the implied warranty of 16 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 - GNU General Public License for more details. 18 - 19 - You should have received a copy of the GNU General Public License 20 - along with this program; if not, write to the Free Software 21 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 - */ 23 - 24 - #include <linux/init.h> 25 - #include <linux/wait.h> 26 - #include <linux/pnp.h> 27 - #include <linux/moduleparam.h> 28 - #include <sound/core.h> 29 - #include <sound/initval.h> 30 - #include <sound/mpu401.h> 31 - #include <sound/opl3.h> 32 - #include <sound/sb.h> 33 - 34 - #define PFX "dt019x: " 35 - 36 - MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); 37 - MODULE_DESCRIPTION("Diamond Technologies DT-019X / Avance Logic ALS-007"); 38 - MODULE_LICENSE("GPL"); 39 - MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X}," 40 - "{Avance Logic ALS-007}}"); 41 - 42 - static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 43 - static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 44 - static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 45 - static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 46 - static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 47 - static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 48 - static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* PnP setup */ 49 - static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* PnP setup */ 50 - static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ 51 - 52 - module_param_array(index, int, NULL, 0444); 53 - MODULE_PARM_DESC(index, "Index value for DT-019X based soundcard."); 54 - module_param_array(id, charp, NULL, 0444); 55 - MODULE_PARM_DESC(id, "ID string for DT-019X based soundcard."); 56 - module_param_array(enable, bool, NULL, 0444); 57 - MODULE_PARM_DESC(enable, "Enable DT-019X based soundcard."); 58 - 59 - struct snd_card_dt019x { 60 - struct pnp_dev *dev; 61 - struct pnp_dev *devmpu; 62 - struct pnp_dev *devopl; 63 - struct snd_sb *chip; 64 - }; 65 - 66 - static struct pnp_card_device_id snd_dt019x_pnpids[] = { 67 - /* DT197A30 */ 68 - { .id = "RWB1688", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, 69 - /* DT0196 / ALS-007 */ 70 - { .id = "ALS0007", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, 71 - { .id = "", } 72 - }; 73 - 74 - MODULE_DEVICE_TABLE(pnp_card, snd_dt019x_pnpids); 75 - 76 - 77 - #define DRIVER_NAME "snd-card-dt019x" 78 - 79 - 80 - static int __devinit snd_card_dt019x_pnp(int dev, struct snd_card_dt019x *acard, 81 - struct pnp_card_link *card, 82 - const struct pnp_card_device_id *pid) 83 - { 84 - struct pnp_dev *pdev; 85 - int err; 86 - 87 - acard->dev = pnp_request_card_device(card, pid->devs[0].id, NULL); 88 - if (acard->dev == NULL) 89 - return -ENODEV; 90 - 91 - acard->devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); 92 - acard->devopl = pnp_request_card_device(card, pid->devs[2].id, NULL); 93 - 94 - pdev = acard->dev; 95 - 96 - err = pnp_activate_dev(pdev); 97 - if (err < 0) { 98 - snd_printk(KERN_ERR PFX "DT-019X AUDIO pnp configure failure\n"); 99 - return err; 100 - } 101 - 102 - port[dev] = pnp_port_start(pdev, 0); 103 - dma8[dev] = pnp_dma(pdev, 0); 104 - irq[dev] = pnp_irq(pdev, 0); 105 - snd_printdd("dt019x: found audio interface: port=0x%lx, irq=0x%x, dma=0x%x\n", 106 - port[dev],irq[dev],dma8[dev]); 107 - 108 - pdev = acard->devmpu; 109 - if (pdev != NULL) { 110 - err = pnp_activate_dev(pdev); 111 - if (err < 0) { 112 - pnp_release_card_device(pdev); 113 - snd_printk(KERN_ERR PFX "DT-019X MPU401 pnp configure failure, skipping\n"); 114 - goto __mpu_error; 115 - } 116 - mpu_port[dev] = pnp_port_start(pdev, 0); 117 - mpu_irq[dev] = pnp_irq(pdev, 0); 118 - snd_printdd("dt019x: found MPU-401: port=0x%lx, irq=0x%x\n", 119 - mpu_port[dev],mpu_irq[dev]); 120 - } else { 121 - __mpu_error: 122 - acard->devmpu = NULL; 123 - mpu_port[dev] = -1; 124 - } 125 - 126 - pdev = acard->devopl; 127 - if (pdev != NULL) { 128 - err = pnp_activate_dev(pdev); 129 - if (err < 0) { 130 - pnp_release_card_device(pdev); 131 - snd_printk(KERN_ERR PFX "DT-019X OPL3 pnp configure failure, skipping\n"); 132 - goto __fm_error; 133 - } 134 - fm_port[dev] = pnp_port_start(pdev, 0); 135 - snd_printdd("dt019x: found OPL3 synth: port=0x%lx\n",fm_port[dev]); 136 - } else { 137 - __fm_error: 138 - acard->devopl = NULL; 139 - fm_port[dev] = -1; 140 - } 141 - 142 - return 0; 143 - } 144 - 145 - static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) 146 - { 147 - int error; 148 - struct snd_sb *chip; 149 - struct snd_card *card; 150 - struct snd_card_dt019x *acard; 151 - struct snd_opl3 *opl3; 152 - 153 - error = snd_card_create(index[dev], id[dev], THIS_MODULE, 154 - sizeof(struct snd_card_dt019x), &card); 155 - if (error < 0) 156 - return error; 157 - acard = card->private_data; 158 - 159 - snd_card_set_dev(card, &pcard->card->dev); 160 - if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) { 161 - snd_card_free(card); 162 - return error; 163 - } 164 - 165 - if ((error = snd_sbdsp_create(card, port[dev], 166 - irq[dev], 167 - snd_sb16dsp_interrupt, 168 - dma8[dev], 169 - -1, 170 - SB_HW_DT019X, 171 - &chip)) < 0) { 172 - snd_card_free(card); 173 - return error; 174 - } 175 - acard->chip = chip; 176 - 177 - strcpy(card->driver, "DT-019X"); 178 - strcpy(card->shortname, "Diamond Tech. DT-019X"); 179 - sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", 180 - card->shortname, chip->name, chip->port, 181 - irq[dev], dma8[dev]); 182 - 183 - if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { 184 - snd_card_free(card); 185 - return error; 186 - } 187 - if ((error = snd_sbmixer_new(chip)) < 0) { 188 - snd_card_free(card); 189 - return error; 190 - } 191 - 192 - if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { 193 - if (mpu_irq[dev] == SNDRV_AUTO_IRQ) 194 - mpu_irq[dev] = -1; 195 - if (snd_mpu401_uart_new(card, 0, 196 - /* MPU401_HW_SB,*/ 197 - MPU401_HW_MPU401, 198 - mpu_port[dev], 0, 199 - mpu_irq[dev], 200 - mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, 201 - NULL) < 0) 202 - snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx ?\n", mpu_port[dev]); 203 - } 204 - 205 - if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { 206 - if (snd_opl3_create(card, 207 - fm_port[dev], 208 - fm_port[dev] + 2, 209 - OPL3_HW_AUTO, 0, &opl3) < 0) { 210 - snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx ?\n", 211 - fm_port[dev], fm_port[dev] + 2); 212 - } else { 213 - if ((error = snd_opl3_timer_new(opl3, 0, 1)) < 0) { 214 - snd_card_free(card); 215 - return error; 216 - } 217 - if ((error = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { 218 - snd_card_free(card); 219 - return error; 220 - } 221 - } 222 - } 223 - 224 - if ((error = snd_card_register(card)) < 0) { 225 - snd_card_free(card); 226 - return error; 227 - } 228 - pnp_set_card_drvdata(pcard, card); 229 - return 0; 230 - } 231 - 232 - static unsigned int __devinitdata dt019x_devices; 233 - 234 - static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card, 235 - const struct pnp_card_device_id *pid) 236 - { 237 - static int dev; 238 - int res; 239 - 240 - for ( ; dev < SNDRV_CARDS; dev++) { 241 - if (!enable[dev]) 242 - continue; 243 - res = snd_card_dt019x_probe(dev, card, pid); 244 - if (res < 0) 245 - return res; 246 - dev++; 247 - dt019x_devices++; 248 - return 0; 249 - } 250 - return -ENODEV; 251 - } 252 - 253 - static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard) 254 - { 255 - snd_card_free(pnp_get_card_drvdata(pcard)); 256 - pnp_set_card_drvdata(pcard, NULL); 257 - } 258 - 259 - #ifdef CONFIG_PM 260 - static int snd_dt019x_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) 261 - { 262 - struct snd_card *card = pnp_get_card_drvdata(pcard); 263 - struct snd_card_dt019x *acard = card->private_data; 264 - struct snd_sb *chip = acard->chip; 265 - 266 - snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 267 - snd_pcm_suspend_all(chip->pcm); 268 - snd_sbmixer_suspend(chip); 269 - return 0; 270 - } 271 - 272 - static int snd_dt019x_pnp_resume(struct pnp_card_link *pcard) 273 - { 274 - struct snd_card *card = pnp_get_card_drvdata(pcard); 275 - struct snd_card_dt019x *acard = card->private_data; 276 - struct snd_sb *chip = acard->chip; 277 - 278 - snd_sbdsp_reset(chip); 279 - snd_sbmixer_resume(chip); 280 - snd_power_change_state(card, SNDRV_CTL_POWER_D0); 281 - return 0; 282 - } 283 - #endif 284 - 285 - static struct pnp_card_driver dt019x_pnpc_driver = { 286 - .flags = PNP_DRIVER_RES_DISABLE, 287 - .name = "dt019x", 288 - .id_table = snd_dt019x_pnpids, 289 - .probe = snd_dt019x_pnp_probe, 290 - .remove = __devexit_p(snd_dt019x_pnp_remove), 291 - #ifdef CONFIG_PM 292 - .suspend = snd_dt019x_pnp_suspend, 293 - .resume = snd_dt019x_pnp_resume, 294 - #endif 295 - }; 296 - 297 - static int __init alsa_card_dt019x_init(void) 298 - { 299 - int err; 300 - 301 - err = pnp_register_card_driver(&dt019x_pnpc_driver); 302 - if (err) 303 - return err; 304 - 305 - if (!dt019x_devices) { 306 - pnp_unregister_card_driver(&dt019x_pnpc_driver); 307 - #ifdef MODULE 308 - snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n"); 309 - #endif 310 - return -ENODEV; 311 - } 312 - return 0; 313 - } 314 - 315 - static void __exit alsa_card_dt019x_exit(void) 316 - { 317 - pnp_unregister_card_driver(&dt019x_pnpc_driver); 318 - } 319 - 320 - module_init(alsa_card_dt019x_init) 321 - module_exit(alsa_card_dt019x_exit)
+93
sound/isa/opti9xx/opti92x-ad1848.c
··· 33 33 #include <asm/io.h> 34 34 #include <asm/dma.h> 35 35 #include <sound/core.h> 36 + #include <sound/tlv.h> 36 37 #include <sound/wss.h> 37 38 #include <sound/mpu401.h> 38 39 #include <sound/opl3.h> ··· 547 546 548 547 #ifdef OPTi93X 549 548 549 + static const DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_step, -9300, 300, 0); 550 + static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0); 551 + static const DECLARE_TLV_DB_SCALE(db_scale_4bit_12db_max, -3300, 300, 0); 552 + 553 + static struct snd_kcontrol_new snd_opti93x_controls[] = { 554 + WSS_DOUBLE("Master Playback Switch", 0, 555 + OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), 556 + WSS_DOUBLE_TLV("Master Playback Volume", 0, 557 + OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1, 558 + db_scale_5bit_3db_step), 559 + WSS_DOUBLE_TLV("PCM Playback Volume", 0, 560 + CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1, 561 + db_scale_5bit), 562 + WSS_DOUBLE_TLV("FM Playback Volume", 0, 563 + CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1, 564 + db_scale_4bit_12db_max), 565 + WSS_DOUBLE("Line Playback Switch", 0, 566 + CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), 567 + WSS_DOUBLE_TLV("Line Playback Volume", 0, 568 + CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1, 569 + db_scale_4bit_12db_max), 570 + WSS_DOUBLE("Mic Playback Switch", 0, 571 + OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1), 572 + WSS_DOUBLE_TLV("Mic Playback Volume", 0, 573 + OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1, 574 + db_scale_4bit_12db_max), 575 + WSS_DOUBLE_TLV("CD Playback Volume", 0, 576 + CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1, 577 + db_scale_4bit_12db_max), 578 + WSS_DOUBLE("Aux Playback Switch", 0, 579 + OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1), 580 + WSS_DOUBLE_TLV("Aux Playback Volume", 0, 581 + OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1, 582 + db_scale_4bit_12db_max), 583 + }; 584 + 585 + static int __devinit snd_opti93x_mixer(struct snd_wss *chip) 586 + { 587 + struct snd_card *card; 588 + unsigned int idx; 589 + struct snd_ctl_elem_id id1, id2; 590 + int err; 591 + 592 + if (snd_BUG_ON(!chip || !chip->pcm)) 593 + return -EINVAL; 594 + 595 + card = chip->card; 596 + 597 + strcpy(card->mixername, chip->pcm->name); 598 + 599 + memset(&id1, 0, sizeof(id1)); 600 + memset(&id2, 0, sizeof(id2)); 601 + id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 602 + /* reassign AUX0 switch to CD */ 603 + strcpy(id1.name, "Aux Playback Switch"); 604 + strcpy(id2.name, "CD Playback Switch"); 605 + err = snd_ctl_rename_id(card, &id1, &id2); 606 + if (err < 0) { 607 + snd_printk(KERN_ERR "Cannot rename opti93x control\n"); 608 + return err; 609 + } 610 + /* reassign AUX1 switch to FM */ 611 + strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; 612 + strcpy(id2.name, "FM Playback Switch"); 613 + err = snd_ctl_rename_id(card, &id1, &id2); 614 + if (err < 0) { 615 + snd_printk(KERN_ERR "Cannot rename opti93x control\n"); 616 + return err; 617 + } 618 + /* remove AUX1 volume */ 619 + strcpy(id1.name, "Aux Playback Volume"); id1.index = 1; 620 + snd_ctl_remove_id(card, &id1); 621 + 622 + /* Replace WSS volume controls with OPTi93x volume controls */ 623 + id1.index = 0; 624 + for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) { 625 + strcpy(id1.name, snd_opti93x_controls[idx].name); 626 + snd_ctl_remove_id(card, &id1); 627 + 628 + err = snd_ctl_add(card, 629 + snd_ctl_new1(&snd_opti93x_controls[idx], chip)); 630 + if (err < 0) 631 + return err; 632 + } 633 + return 0; 634 + } 635 + 550 636 static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) 551 637 { 552 638 struct snd_opti9xx *chip = dev_id; ··· 842 754 error = snd_wss_mixer(codec); 843 755 if (error < 0) 844 756 return error; 757 + #ifdef OPTi93X 758 + error = snd_opti93x_mixer(codec); 759 + if (error < 0) 760 + return error; 761 + #endif 845 762 #ifdef CS4231 846 763 error = snd_wss_timer(codec, 0, &timer); 847 764 if (error < 0)
+2
sound/isa/sb/Makefile
··· 12 12 snd-sbawe-objs := sbawe.o emu8000.o 13 13 snd-emu8000-synth-objs := emu8000_synth.o emu8000_callback.o emu8000_patch.o emu8000_pcm.o 14 14 snd-es968-objs := es968.o 15 + snd-jazz16-objs := jazz16.o 15 16 16 17 # Toplevel Module Dependency 17 18 obj-$(CONFIG_SND_SB_COMMON) += snd-sb-common.o ··· 22 21 obj-$(CONFIG_SND_SB16) += snd-sb16.o 23 22 obj-$(CONFIG_SND_SBAWE) += snd-sbawe.o 24 23 obj-$(CONFIG_SND_ES968) += snd-es968.o 24 + obj-$(CONFIG_SND_JAZZ16) += snd-jazz16.o 25 25 ifeq ($(CONFIG_SND_SB16_CSP),y) 26 26 obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o 27 27 obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o
+404
sound/isa/sb/jazz16.c
··· 1 + 2 + /* 3 + * jazz16.c - driver for Media Vision Jazz16 based soundcards. 4 + * Copyright (C) 2009 Krzysztof Helt <krzysztof.h1@wp.pl> 5 + * Based on patches posted by Rask Ingemann Lambertsen and Rene Herman. 6 + * Based on OSS Sound Blaster driver. 7 + * 8 + * This file is subject to the terms and conditions of the GNU General Public 9 + * License. See the file COPYING in the main directory of this archive for 10 + * more details. 11 + * 12 + */ 13 + 14 + #include <linux/init.h> 15 + #include <linux/module.h> 16 + #include <linux/io.h> 17 + #include <asm/dma.h> 18 + #include <linux/isa.h> 19 + #include <sound/core.h> 20 + #include <sound/mpu401.h> 21 + #include <sound/opl3.h> 22 + #include <sound/sb.h> 23 + #define SNDRV_LEGACY_FIND_FREE_IRQ 24 + #define SNDRV_LEGACY_FIND_FREE_DMA 25 + #include <sound/initval.h> 26 + 27 + #define PFX "jazz16: " 28 + 29 + MODULE_DESCRIPTION("Media Vision Jazz16"); 30 + MODULE_SUPPORTED_DEVICE("{{Media Vision ??? }," 31 + "{RTL,RTL3000}}"); 32 + 33 + MODULE_AUTHOR("Krzysztof Helt <krzysztof.h1@wp.pl>"); 34 + MODULE_LICENSE("GPL"); 35 + 36 + static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 37 + static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 38 + static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 39 + static unsigned long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; 40 + static unsigned long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; 41 + static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; 42 + static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; 43 + static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; 44 + static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; 45 + 46 + module_param_array(index, int, NULL, 0444); 47 + MODULE_PARM_DESC(index, "Index value for Media Vision Jazz16 based soundcard."); 48 + module_param_array(id, charp, NULL, 0444); 49 + MODULE_PARM_DESC(id, "ID string for Media Vision Jazz16 based soundcard."); 50 + module_param_array(enable, bool, NULL, 0444); 51 + MODULE_PARM_DESC(enable, "Enable Media Vision Jazz16 based soundcard."); 52 + module_param_array(port, long, NULL, 0444); 53 + MODULE_PARM_DESC(port, "Port # for jazz16 driver."); 54 + module_param_array(mpu_port, long, NULL, 0444); 55 + MODULE_PARM_DESC(mpu_port, "MPU-401 port # for jazz16 driver."); 56 + module_param_array(irq, int, NULL, 0444); 57 + MODULE_PARM_DESC(irq, "IRQ # for jazz16 driver."); 58 + module_param_array(mpu_irq, int, NULL, 0444); 59 + MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for jazz16 driver."); 60 + module_param_array(dma8, int, NULL, 0444); 61 + MODULE_PARM_DESC(dma8, "DMA8 # for jazz16 driver."); 62 + module_param_array(dma16, int, NULL, 0444); 63 + MODULE_PARM_DESC(dma16, "DMA16 # for jazz16 driver."); 64 + 65 + #define SB_JAZZ16_WAKEUP 0xaf 66 + #define SB_JAZZ16_SET_PORTS 0x50 67 + #define SB_DSP_GET_JAZZ_BRD_REV 0xfa 68 + #define SB_JAZZ16_SET_DMAINTR 0xfb 69 + #define SB_DSP_GET_JAZZ_MODEL 0xfe 70 + 71 + struct snd_card_jazz16 { 72 + struct snd_sb *chip; 73 + }; 74 + 75 + static irqreturn_t jazz16_interrupt(int irq, void *chip) 76 + { 77 + return snd_sb8dsp_interrupt(chip); 78 + } 79 + 80 + static int __devinit jazz16_configure_ports(unsigned long port, 81 + unsigned long mpu_port, int idx) 82 + { 83 + unsigned char val; 84 + 85 + if (!request_region(0x201, 1, "jazz16 config")) { 86 + snd_printk(KERN_ERR "config port region is already in use.\n"); 87 + return -EBUSY; 88 + } 89 + outb(SB_JAZZ16_WAKEUP - idx, 0x201); 90 + udelay(100); 91 + outb(SB_JAZZ16_SET_PORTS + idx, 0x201); 92 + udelay(100); 93 + val = port & 0x70; 94 + val |= (mpu_port & 0x30) >> 4; 95 + outb(val, 0x201); 96 + 97 + release_region(0x201, 1); 98 + return 0; 99 + } 100 + 101 + static int __devinit jazz16_detect_board(unsigned long port, 102 + unsigned long mpu_port) 103 + { 104 + int err; 105 + int val; 106 + struct snd_sb chip; 107 + 108 + if (!request_region(port, 0x10, "jazz16")) { 109 + snd_printk(KERN_ERR "I/O port region is already in use.\n"); 110 + return -EBUSY; 111 + } 112 + /* just to call snd_sbdsp_command/reset/get_byte() */ 113 + chip.port = port; 114 + 115 + err = snd_sbdsp_reset(&chip); 116 + if (err < 0) 117 + for (val = 0; val < 4; val++) { 118 + err = jazz16_configure_ports(port, mpu_port, val); 119 + if (err < 0) 120 + break; 121 + 122 + err = snd_sbdsp_reset(&chip); 123 + if (!err) 124 + break; 125 + } 126 + if (err < 0) { 127 + err = -ENODEV; 128 + goto err_unmap; 129 + } 130 + if (!snd_sbdsp_command(&chip, SB_DSP_GET_JAZZ_BRD_REV)) { 131 + err = -EBUSY; 132 + goto err_unmap; 133 + } 134 + val = snd_sbdsp_get_byte(&chip); 135 + if (val >= 0x30) 136 + snd_sbdsp_get_byte(&chip); 137 + 138 + if ((val & 0xf0) != 0x10) { 139 + err = -ENODEV; 140 + goto err_unmap; 141 + } 142 + if (!snd_sbdsp_command(&chip, SB_DSP_GET_JAZZ_MODEL)) { 143 + err = -EBUSY; 144 + goto err_unmap; 145 + } 146 + snd_sbdsp_get_byte(&chip); 147 + err = snd_sbdsp_get_byte(&chip); 148 + snd_printd("Media Vision Jazz16 board detected: rev 0x%x, model 0x%x\n", 149 + val, err); 150 + 151 + err = 0; 152 + 153 + err_unmap: 154 + release_region(port, 0x10); 155 + return err; 156 + } 157 + 158 + static int __devinit jazz16_configure_board(struct snd_sb *chip, int mpu_irq) 159 + { 160 + static unsigned char jazz_irq_bits[] = { 0, 0, 2, 3, 0, 1, 0, 4, 161 + 0, 2, 5, 0, 0, 0, 0, 6 }; 162 + static unsigned char jazz_dma_bits[] = { 0, 1, 0, 2, 0, 3, 0, 4 }; 163 + 164 + if (jazz_dma_bits[chip->dma8] == 0 || 165 + jazz_dma_bits[chip->dma16] == 0 || 166 + jazz_irq_bits[chip->irq] == 0) 167 + return -EINVAL; 168 + 169 + if (!snd_sbdsp_command(chip, SB_JAZZ16_SET_DMAINTR)) 170 + return -EBUSY; 171 + 172 + if (!snd_sbdsp_command(chip, 173 + jazz_dma_bits[chip->dma8] | 174 + (jazz_dma_bits[chip->dma16] << 4))) 175 + return -EBUSY; 176 + 177 + if (!snd_sbdsp_command(chip, 178 + jazz_irq_bits[chip->irq] | 179 + (jazz_irq_bits[mpu_irq] << 4))) 180 + return -EBUSY; 181 + 182 + return 0; 183 + } 184 + 185 + static int __devinit snd_jazz16_match(struct device *devptr, unsigned int dev) 186 + { 187 + if (!enable[dev]) 188 + return 0; 189 + if (port[dev] == SNDRV_AUTO_PORT) { 190 + snd_printk(KERN_ERR "please specify port\n"); 191 + return 0; 192 + } else if (port[dev] == 0x200 || (port[dev] & ~0x270)) { 193 + snd_printk(KERN_ERR "incorrect port specified\n"); 194 + return 0; 195 + } 196 + if (dma8[dev] != SNDRV_AUTO_DMA && 197 + dma8[dev] != 1 && dma8[dev] != 3) { 198 + snd_printk(KERN_ERR "dma8 must be 1 or 3\n"); 199 + return 0; 200 + } 201 + if (dma16[dev] != SNDRV_AUTO_DMA && 202 + dma16[dev] != 5 && dma16[dev] != 7) { 203 + snd_printk(KERN_ERR "dma16 must be 5 or 7\n"); 204 + return 0; 205 + } 206 + if (mpu_port[dev] != SNDRV_AUTO_PORT && 207 + (mpu_port[dev] & ~0x030) != 0x300) { 208 + snd_printk(KERN_ERR "incorrect mpu_port specified\n"); 209 + return 0; 210 + } 211 + if (mpu_irq[dev] != SNDRV_AUTO_DMA && 212 + mpu_irq[dev] != 2 && mpu_irq[dev] != 3 && 213 + mpu_irq[dev] != 5 && mpu_irq[dev] != 7) { 214 + snd_printk(KERN_ERR "mpu_irq must be 2, 3, 5 or 7\n"); 215 + return 0; 216 + } 217 + return 1; 218 + } 219 + 220 + static int __devinit snd_jazz16_probe(struct device *devptr, unsigned int dev) 221 + { 222 + struct snd_card *card; 223 + struct snd_card_jazz16 *jazz16; 224 + struct snd_sb *chip; 225 + struct snd_opl3 *opl3; 226 + static int possible_irqs[] = {2, 3, 5, 7, 9, 10, 15, -1}; 227 + static int possible_dmas8[] = {1, 3, -1}; 228 + static int possible_dmas16[] = {5, 7, -1}; 229 + int err, xirq, xdma8, xdma16, xmpu_port, xmpu_irq; 230 + 231 + err = snd_card_create(index[dev], id[dev], THIS_MODULE, 232 + sizeof(struct snd_card_jazz16), &card); 233 + if (err < 0) 234 + return err; 235 + 236 + jazz16 = card->private_data; 237 + 238 + xirq = irq[dev]; 239 + if (xirq == SNDRV_AUTO_IRQ) { 240 + xirq = snd_legacy_find_free_irq(possible_irqs); 241 + if (xirq < 0) { 242 + snd_printk(KERN_ERR "unable to find a free IRQ\n"); 243 + err = -EBUSY; 244 + goto err_free; 245 + } 246 + } 247 + xdma8 = dma8[dev]; 248 + if (xdma8 == SNDRV_AUTO_DMA) { 249 + xdma8 = snd_legacy_find_free_dma(possible_dmas8); 250 + if (xdma8 < 0) { 251 + snd_printk(KERN_ERR "unable to find a free DMA8\n"); 252 + err = -EBUSY; 253 + goto err_free; 254 + } 255 + } 256 + xdma16 = dma16[dev]; 257 + if (xdma16 == SNDRV_AUTO_DMA) { 258 + xdma16 = snd_legacy_find_free_dma(possible_dmas16); 259 + if (xdma16 < 0) { 260 + snd_printk(KERN_ERR "unable to find a free DMA16\n"); 261 + err = -EBUSY; 262 + goto err_free; 263 + } 264 + } 265 + 266 + xmpu_port = mpu_port[dev]; 267 + if (xmpu_port == SNDRV_AUTO_PORT) 268 + xmpu_port = 0; 269 + err = jazz16_detect_board(port[dev], xmpu_port); 270 + if (err < 0) { 271 + printk(KERN_ERR "Media Vision Jazz16 board not detected\n"); 272 + goto err_free; 273 + } 274 + err = snd_sbdsp_create(card, port[dev], irq[dev], 275 + jazz16_interrupt, 276 + dma8[dev], dma16[dev], 277 + SB_HW_JAZZ16, 278 + &chip); 279 + if (err < 0) 280 + goto err_free; 281 + 282 + xmpu_irq = mpu_irq[dev]; 283 + if (xmpu_irq == SNDRV_AUTO_IRQ || mpu_port[dev] == SNDRV_AUTO_PORT) 284 + xmpu_irq = 0; 285 + err = jazz16_configure_board(chip, xmpu_irq); 286 + if (err < 0) { 287 + printk(KERN_ERR "Media Vision Jazz16 configuration failed\n"); 288 + goto err_free; 289 + } 290 + 291 + jazz16->chip = chip; 292 + 293 + strcpy(card->driver, "jazz16"); 294 + strcpy(card->shortname, "Media Vision Jazz16"); 295 + sprintf(card->longname, 296 + "Media Vision Jazz16 at 0x%lx, irq %d, dma8 %d, dma16 %d", 297 + port[dev], xirq, xdma8, xdma16); 298 + 299 + err = snd_sb8dsp_pcm(chip, 0, NULL); 300 + if (err < 0) 301 + goto err_free; 302 + err = snd_sbmixer_new(chip); 303 + if (err < 0) 304 + goto err_free; 305 + 306 + err = snd_opl3_create(card, chip->port, chip->port + 2, 307 + OPL3_HW_AUTO, 1, &opl3); 308 + if (err < 0) 309 + snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", 310 + chip->port, chip->port + 2); 311 + else { 312 + err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); 313 + if (err < 0) 314 + goto err_free; 315 + } 316 + if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { 317 + if (mpu_irq[dev] == SNDRV_AUTO_IRQ) 318 + mpu_irq[dev] = -1; 319 + 320 + if (snd_mpu401_uart_new(card, 0, 321 + MPU401_HW_MPU401, 322 + mpu_port[dev], 0, 323 + mpu_irq[dev], 324 + mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, 325 + NULL) < 0) 326 + snd_printk(KERN_ERR "no MPU-401 device at 0x%lx\n", 327 + mpu_port[dev]); 328 + } 329 + 330 + snd_card_set_dev(card, devptr); 331 + 332 + err = snd_card_register(card); 333 + if (err < 0) 334 + goto err_free; 335 + 336 + dev_set_drvdata(devptr, card); 337 + return 0; 338 + 339 + err_free: 340 + snd_card_free(card); 341 + return err; 342 + } 343 + 344 + static int __devexit snd_jazz16_remove(struct device *devptr, unsigned int dev) 345 + { 346 + struct snd_card *card = dev_get_drvdata(devptr); 347 + 348 + dev_set_drvdata(devptr, NULL); 349 + snd_card_free(card); 350 + return 0; 351 + } 352 + 353 + #ifdef CONFIG_PM 354 + static int snd_jazz16_suspend(struct device *pdev, unsigned int n, 355 + pm_message_t state) 356 + { 357 + struct snd_card *card = dev_get_drvdata(pdev); 358 + struct snd_card_jazz16 *acard = card->private_data; 359 + struct snd_sb *chip = acard->chip; 360 + 361 + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 362 + snd_pcm_suspend_all(chip->pcm); 363 + snd_sbmixer_suspend(chip); 364 + return 0; 365 + } 366 + 367 + static int snd_jazz16_resume(struct device *pdev, unsigned int n) 368 + { 369 + struct snd_card *card = dev_get_drvdata(pdev); 370 + struct snd_card_jazz16 *acard = card->private_data; 371 + struct snd_sb *chip = acard->chip; 372 + 373 + snd_sbdsp_reset(chip); 374 + snd_sbmixer_resume(chip); 375 + snd_power_change_state(card, SNDRV_CTL_POWER_D0); 376 + return 0; 377 + } 378 + #endif 379 + 380 + static struct isa_driver snd_jazz16_driver = { 381 + .match = snd_jazz16_match, 382 + .probe = snd_jazz16_probe, 383 + .remove = __devexit_p(snd_jazz16_remove), 384 + #ifdef CONFIG_PM 385 + .suspend = snd_jazz16_suspend, 386 + .resume = snd_jazz16_resume, 387 + #endif 388 + .driver = { 389 + .name = "jazz16" 390 + }, 391 + }; 392 + 393 + static int __init alsa_card_jazz16_init(void) 394 + { 395 + return isa_register_driver(&snd_jazz16_driver, SNDRV_CARDS); 396 + } 397 + 398 + static void __exit alsa_card_jazz16_exit(void) 399 + { 400 + isa_unregister_driver(&snd_jazz16_driver); 401 + } 402 + 403 + module_init(alsa_card_jazz16_init) 404 + module_exit(alsa_card_jazz16_exit)
+102 -16
sound/isa/sb/sb8_main.c
··· 106 106 struct snd_sb *chip = snd_pcm_substream_chip(substream); 107 107 struct snd_pcm_runtime *runtime = substream->runtime; 108 108 unsigned int mixreg, rate, size, count; 109 + unsigned char format; 110 + unsigned char stereo = runtime->channels > 1; 111 + int dma; 109 112 110 113 rate = runtime->rate; 111 114 switch (chip->hardware) { 115 + case SB_HW_JAZZ16: 116 + if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) { 117 + if (chip->mode & SB_MODE_CAPTURE_16) 118 + return -EBUSY; 119 + else 120 + chip->mode |= SB_MODE_PLAYBACK_16; 121 + } 122 + chip->playback_format = SB_DSP_LO_OUTPUT_AUTO; 123 + break; 112 124 case SB_HW_PRO: 113 125 if (runtime->channels > 1) { 114 126 if (snd_BUG_ON(rate != SB8_RATE(11025) && ··· 145 133 default: 146 134 return -EINVAL; 147 135 } 136 + if (chip->mode & SB_MODE_PLAYBACK_16) { 137 + format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT; 138 + dma = chip->dma16; 139 + } else { 140 + format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT; 141 + chip->mode |= SB_MODE_PLAYBACK_8; 142 + dma = chip->dma8; 143 + } 148 144 size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream); 149 145 count = chip->p_period_size = snd_pcm_lib_period_bytes(substream); 150 146 spin_lock_irqsave(&chip->reg_lock, flags); 151 147 snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON); 152 - if (runtime->channels > 1) { 148 + if (chip->hardware == SB_HW_JAZZ16) 149 + snd_sbdsp_command(chip, format); 150 + else if (stereo) { 153 151 /* set playback stereo mode */ 154 152 spin_lock(&chip->mixer_lock); 155 153 mixreg = snd_sbmixer_read(chip, SB_DSP_STEREO_SW); ··· 169 147 /* Soundblaster hardware programming reference guide, 3-23 */ 170 148 snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT); 171 149 runtime->dma_area[0] = 0x80; 172 - snd_dma_program(chip->dma8, runtime->dma_addr, 1, DMA_MODE_WRITE); 150 + snd_dma_program(dma, runtime->dma_addr, 1, DMA_MODE_WRITE); 173 151 /* force interrupt */ 174 - chip->mode = SB_MODE_HALT; 175 152 snd_sbdsp_command(chip, SB_DSP_OUTPUT); 176 153 snd_sbdsp_command(chip, 0); 177 154 snd_sbdsp_command(chip, 0); 178 155 } 179 156 snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); 180 - if (runtime->channels > 1) { 157 + if (stereo) { 181 158 snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); 182 159 spin_lock(&chip->mixer_lock); 183 160 /* save output filter status and turn it off */ ··· 189 168 snd_sbdsp_command(chip, 256 - runtime->rate_den); 190 169 } 191 170 if (chip->playback_format != SB_DSP_OUTPUT) { 171 + if (chip->mode & SB_MODE_PLAYBACK_16) 172 + count /= 2; 192 173 count--; 193 174 snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); 194 175 snd_sbdsp_command(chip, count & 0xff); 195 176 snd_sbdsp_command(chip, count >> 8); 196 177 } 197 178 spin_unlock_irqrestore(&chip->reg_lock, flags); 198 - snd_dma_program(chip->dma8, runtime->dma_addr, 179 + snd_dma_program(dma, runtime->dma_addr, 199 180 size, DMA_MODE_WRITE | DMA_AUTOINIT); 200 181 return 0; 201 182 } ··· 235 212 snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); 236 213 } 237 214 spin_unlock_irqrestore(&chip->reg_lock, flags); 238 - chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_PLAYBACK_8 : SB_MODE_HALT; 239 215 return 0; 240 216 } 241 217 ··· 256 234 struct snd_sb *chip = snd_pcm_substream_chip(substream); 257 235 struct snd_pcm_runtime *runtime = substream->runtime; 258 236 unsigned int mixreg, rate, size, count; 237 + unsigned char format; 238 + unsigned char stereo = runtime->channels > 1; 239 + int dma; 259 240 260 241 rate = runtime->rate; 261 242 switch (chip->hardware) { 243 + case SB_HW_JAZZ16: 244 + if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) { 245 + if (chip->mode & SB_MODE_PLAYBACK_16) 246 + return -EBUSY; 247 + else 248 + chip->mode |= SB_MODE_CAPTURE_16; 249 + } 250 + chip->capture_format = SB_DSP_LO_INPUT_AUTO; 251 + break; 262 252 case SB_HW_PRO: 263 253 if (runtime->channels > 1) { 264 254 if (snd_BUG_ON(rate != SB8_RATE(11025) && ··· 296 262 default: 297 263 return -EINVAL; 298 264 } 265 + if (chip->mode & SB_MODE_CAPTURE_16) { 266 + format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT; 267 + dma = chip->dma16; 268 + } else { 269 + format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT; 270 + chip->mode |= SB_MODE_CAPTURE_8; 271 + dma = chip->dma8; 272 + } 299 273 size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream); 300 274 count = chip->c_period_size = snd_pcm_lib_period_bytes(substream); 301 275 spin_lock_irqsave(&chip->reg_lock, flags); 302 276 snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); 303 - if (runtime->channels > 1) 277 + if (chip->hardware == SB_HW_JAZZ16) 278 + snd_sbdsp_command(chip, format); 279 + else if (stereo) 304 280 snd_sbdsp_command(chip, SB_DSP_STEREO_8BIT); 305 281 snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); 306 - if (runtime->channels > 1) { 282 + if (stereo) { 307 283 snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); 308 284 spin_lock(&chip->mixer_lock); 309 285 /* save input filter status and turn it off */ ··· 326 282 snd_sbdsp_command(chip, 256 - runtime->rate_den); 327 283 } 328 284 if (chip->capture_format != SB_DSP_INPUT) { 285 + if (chip->mode & SB_MODE_PLAYBACK_16) 286 + count /= 2; 329 287 count--; 330 288 snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); 331 289 snd_sbdsp_command(chip, count & 0xff); 332 290 snd_sbdsp_command(chip, count >> 8); 333 291 } 334 292 spin_unlock_irqrestore(&chip->reg_lock, flags); 335 - snd_dma_program(chip->dma8, runtime->dma_addr, 293 + snd_dma_program(dma, runtime->dma_addr, 336 294 size, DMA_MODE_READ | DMA_AUTOINIT); 337 295 return 0; 338 296 } ··· 374 328 snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); 375 329 } 376 330 spin_unlock_irqrestore(&chip->reg_lock, flags); 377 - chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_CAPTURE_8 : SB_MODE_HALT; 378 331 return 0; 379 332 } 380 333 ··· 384 339 385 340 snd_sb_ack_8bit(chip); 386 341 switch (chip->mode) { 387 - case SB_MODE_PLAYBACK_8: /* ok.. playback is active */ 342 + case SB_MODE_PLAYBACK_16: /* ok.. playback is active */ 343 + if (chip->hardware != SB_HW_JAZZ16) 344 + break; 345 + /* fallthru */ 346 + case SB_MODE_PLAYBACK_8: 388 347 substream = chip->playback_substream; 389 348 runtime = substream->runtime; 390 349 if (chip->playback_format == SB_DSP_OUTPUT) 391 350 snd_sb8_playback_trigger(substream, SNDRV_PCM_TRIGGER_START); 392 351 snd_pcm_period_elapsed(substream); 393 352 break; 353 + case SB_MODE_CAPTURE_16: 354 + if (chip->hardware != SB_HW_JAZZ16) 355 + break; 356 + /* fallthru */ 394 357 case SB_MODE_CAPTURE_8: 395 358 substream = chip->capture_substream; 396 359 runtime = substream->runtime; ··· 414 361 { 415 362 struct snd_sb *chip = snd_pcm_substream_chip(substream); 416 363 size_t ptr; 364 + int dma; 417 365 418 - if (chip->mode != SB_MODE_PLAYBACK_8) 366 + if (chip->mode & SB_MODE_PLAYBACK_8) 367 + dma = chip->dma8; 368 + else if (chip->mode & SB_MODE_PLAYBACK_16) 369 + dma = chip->dma16; 370 + else 419 371 return 0; 420 - ptr = snd_dma_pointer(chip->dma8, chip->p_dma_size); 372 + ptr = snd_dma_pointer(dma, chip->p_dma_size); 421 373 return bytes_to_frames(substream->runtime, ptr); 422 374 } 423 375 ··· 430 372 { 431 373 struct snd_sb *chip = snd_pcm_substream_chip(substream); 432 374 size_t ptr; 375 + int dma; 433 376 434 - if (chip->mode != SB_MODE_CAPTURE_8) 377 + if (chip->mode & SB_MODE_CAPTURE_8) 378 + dma = chip->dma8; 379 + else if (chip->mode & SB_MODE_CAPTURE_16) 380 + dma = chip->dma16; 381 + else 435 382 return 0; 436 - ptr = snd_dma_pointer(chip->dma8, chip->c_dma_size); 383 + ptr = snd_dma_pointer(dma, chip->c_dma_size); 437 384 return bytes_to_frames(substream->runtime, ptr); 438 385 } 439 386 ··· 509 446 runtime->hw = snd_sb8_capture; 510 447 } 511 448 switch (chip->hardware) { 449 + case SB_HW_JAZZ16: 450 + if (chip->dma16 == 5 || chip->dma16 == 7) 451 + runtime->hw.formats |= SNDRV_PCM_FMTBIT_S16_LE; 452 + runtime->hw.rates |= SNDRV_PCM_RATE_8000_48000; 453 + runtime->hw.rate_min = 4000; 454 + runtime->hw.rate_max = 50000; 455 + runtime->hw.channels_max = 2; 456 + break; 512 457 case SB_HW_PRO: 513 458 runtime->hw.rate_max = 44100; 514 459 runtime->hw.channels_max = 2; ··· 539 468 } 540 469 snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 541 470 &hw_constraints_clock); 471 + if (chip->dma8 > 3 || chip->dma16 >= 0) { 472 + snd_pcm_hw_constraint_step(runtime, 0, 473 + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 2); 474 + snd_pcm_hw_constraint_step(runtime, 0, 475 + SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 2); 476 + runtime->hw.buffer_bytes_max = 128 * 1024 * 1024; 477 + runtime->hw.period_bytes_max = 128 * 1024 * 1024; 478 + } 542 479 return 0; 543 480 } 544 481 ··· 559 480 chip->capture_substream = NULL; 560 481 spin_lock_irqsave(&chip->open_lock, flags); 561 482 chip->open &= ~SB_OPEN_PCM; 483 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 484 + chip->mode &= ~SB_MODE_PLAYBACK; 485 + else 486 + chip->mode &= ~SB_MODE_CAPTURE; 562 487 spin_unlock_irqrestore(&chip->open_lock, flags); 563 488 return 0; 564 489 } ··· 598 515 struct snd_card *card = chip->card; 599 516 struct snd_pcm *pcm; 600 517 int err; 518 + size_t max_prealloc = 64 * 1024; 601 519 602 520 if (rpcm) 603 521 *rpcm = NULL; ··· 611 527 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); 612 528 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); 613 529 530 + if (chip->dma8 > 3 || chip->dma16 >= 0) 531 + max_prealloc = 128 * 1024; 614 532 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 615 533 snd_dma_isa_data(), 616 - 64*1024, 64*1024); 534 + 64*1024, max_prealloc); 617 535 618 536 if (rpcm) 619 537 *rpcm = pcm;
+3
sound/isa/sb/sb_common.c
··· 170 170 case SB_HW_CS5530: 171 171 str = "16 (CS5530)"; 172 172 break; 173 + case SB_HW_JAZZ16: 174 + str = "Pro (Jazz16)"; 175 + break; 173 176 default: 174 177 return -ENODEV; 175 178 }
+118 -215
sound/isa/sb/sb_mixer.c
··· 528 528 * SB 2.0 specific mixer elements 529 529 */ 530 530 531 - static struct sbmix_elem snd_sb20_ctl_master_play_vol = 532 - SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7); 533 - static struct sbmix_elem snd_sb20_ctl_pcm_play_vol = 534 - SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3); 535 - static struct sbmix_elem snd_sb20_ctl_synth_play_vol = 536 - SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7); 537 - static struct sbmix_elem snd_sb20_ctl_cd_play_vol = 538 - SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7); 539 - 540 - static struct sbmix_elem *snd_sb20_controls[] = { 541 - &snd_sb20_ctl_master_play_vol, 542 - &snd_sb20_ctl_pcm_play_vol, 543 - &snd_sb20_ctl_synth_play_vol, 544 - &snd_sb20_ctl_cd_play_vol 531 + static struct sbmix_elem snd_sb20_controls[] = { 532 + SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7), 533 + SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3), 534 + SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7), 535 + SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7) 545 536 }; 546 537 547 538 static unsigned char snd_sb20_init_values[][2] = { ··· 543 552 /* 544 553 * SB Pro specific mixer elements 545 554 */ 546 - static struct sbmix_elem snd_sbpro_ctl_master_play_vol = 547 - SB_DOUBLE("Master Playback Volume", SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7); 548 - static struct sbmix_elem snd_sbpro_ctl_pcm_play_vol = 549 - SB_DOUBLE("PCM Playback Volume", SB_DSP_PCM_DEV, SB_DSP_PCM_DEV, 5, 1, 7); 550 - static struct sbmix_elem snd_sbpro_ctl_pcm_play_filter = 551 - SB_SINGLE("PCM Playback Filter", SB_DSP_PLAYBACK_FILT, 5, 1); 552 - static struct sbmix_elem snd_sbpro_ctl_synth_play_vol = 553 - SB_DOUBLE("Synth Playback Volume", SB_DSP_FM_DEV, SB_DSP_FM_DEV, 5, 1, 7); 554 - static struct sbmix_elem snd_sbpro_ctl_cd_play_vol = 555 - SB_DOUBLE("CD Playback Volume", SB_DSP_CD_DEV, SB_DSP_CD_DEV, 5, 1, 7); 556 - static struct sbmix_elem snd_sbpro_ctl_line_play_vol = 557 - SB_DOUBLE("Line Playback Volume", SB_DSP_LINE_DEV, SB_DSP_LINE_DEV, 5, 1, 7); 558 - static struct sbmix_elem snd_sbpro_ctl_mic_play_vol = 559 - SB_SINGLE("Mic Playback Volume", SB_DSP_MIC_DEV, 1, 3); 560 - static struct sbmix_elem snd_sbpro_ctl_capture_source = 555 + static struct sbmix_elem snd_sbpro_controls[] = { 556 + SB_DOUBLE("Master Playback Volume", 557 + SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7), 558 + SB_DOUBLE("PCM Playback Volume", 559 + SB_DSP_PCM_DEV, SB_DSP_PCM_DEV, 5, 1, 7), 560 + SB_SINGLE("PCM Playback Filter", SB_DSP_PLAYBACK_FILT, 5, 1), 561 + SB_DOUBLE("Synth Playback Volume", 562 + SB_DSP_FM_DEV, SB_DSP_FM_DEV, 5, 1, 7), 563 + SB_DOUBLE("CD Playback Volume", SB_DSP_CD_DEV, SB_DSP_CD_DEV, 5, 1, 7), 564 + SB_DOUBLE("Line Playback Volume", 565 + SB_DSP_LINE_DEV, SB_DSP_LINE_DEV, 5, 1, 7), 566 + SB_SINGLE("Mic Playback Volume", SB_DSP_MIC_DEV, 1, 3), 561 567 { 562 568 .name = "Capture Source", 563 569 .type = SB_MIX_CAPTURE_PRO 564 - }; 565 - static struct sbmix_elem snd_sbpro_ctl_capture_filter = 566 - SB_SINGLE("Capture Filter", SB_DSP_CAPTURE_FILT, 5, 1); 567 - static struct sbmix_elem snd_sbpro_ctl_capture_low_filter = 568 - SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 1); 569 - 570 - static struct sbmix_elem *snd_sbpro_controls[] = { 571 - &snd_sbpro_ctl_master_play_vol, 572 - &snd_sbpro_ctl_pcm_play_vol, 573 - &snd_sbpro_ctl_pcm_play_filter, 574 - &snd_sbpro_ctl_synth_play_vol, 575 - &snd_sbpro_ctl_cd_play_vol, 576 - &snd_sbpro_ctl_line_play_vol, 577 - &snd_sbpro_ctl_mic_play_vol, 578 - &snd_sbpro_ctl_capture_source, 579 - &snd_sbpro_ctl_capture_filter, 580 - &snd_sbpro_ctl_capture_low_filter 570 + }, 571 + SB_SINGLE("Capture Filter", SB_DSP_CAPTURE_FILT, 5, 1), 572 + SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 1) 581 573 }; 582 574 583 575 static unsigned char snd_sbpro_init_values[][2] = { ··· 572 598 /* 573 599 * SB16 specific mixer elements 574 600 */ 575 - static struct sbmix_elem snd_sb16_ctl_master_play_vol = 576 - SB_DOUBLE("Master Playback Volume", SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31); 577 - static struct sbmix_elem snd_sb16_ctl_3d_enhance_switch = 578 - SB_SINGLE("3D Enhancement Switch", SB_DSP4_3DSE, 0, 1); 579 - static struct sbmix_elem snd_sb16_ctl_tone_bass = 580 - SB_DOUBLE("Tone Control - Bass", SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15); 581 - static struct sbmix_elem snd_sb16_ctl_tone_treble = 582 - SB_DOUBLE("Tone Control - Treble", SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15); 583 - static struct sbmix_elem snd_sb16_ctl_pcm_play_vol = 584 - SB_DOUBLE("PCM Playback Volume", SB_DSP4_PCM_DEV, (SB_DSP4_PCM_DEV + 1), 3, 3, 31); 585 - static struct sbmix_elem snd_sb16_ctl_synth_capture_route = 586 - SB16_INPUT_SW("Synth Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 6, 5); 587 - static struct sbmix_elem snd_sb16_ctl_synth_play_vol = 588 - SB_DOUBLE("Synth Playback Volume", SB_DSP4_SYNTH_DEV, (SB_DSP4_SYNTH_DEV + 1), 3, 3, 31); 589 - static struct sbmix_elem snd_sb16_ctl_cd_capture_route = 590 - SB16_INPUT_SW("CD Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 2, 1); 591 - static struct sbmix_elem snd_sb16_ctl_cd_play_switch = 592 - SB_DOUBLE("CD Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1); 593 - static struct sbmix_elem snd_sb16_ctl_cd_play_vol = 594 - SB_DOUBLE("CD Playback Volume", SB_DSP4_CD_DEV, (SB_DSP4_CD_DEV + 1), 3, 3, 31); 595 - static struct sbmix_elem snd_sb16_ctl_line_capture_route = 596 - SB16_INPUT_SW("Line Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 4, 3); 597 - static struct sbmix_elem snd_sb16_ctl_line_play_switch = 598 - SB_DOUBLE("Line Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1); 599 - static struct sbmix_elem snd_sb16_ctl_line_play_vol = 600 - SB_DOUBLE("Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31); 601 - static struct sbmix_elem snd_sb16_ctl_mic_capture_route = 602 - SB16_INPUT_SW("Mic Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0); 603 - static struct sbmix_elem snd_sb16_ctl_mic_play_switch = 604 - SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1); 605 - static struct sbmix_elem snd_sb16_ctl_mic_play_vol = 606 - SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31); 607 - static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol = 608 - SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3); 609 - static struct sbmix_elem snd_sb16_ctl_capture_vol = 610 - SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3); 611 - static struct sbmix_elem snd_sb16_ctl_play_vol = 612 - SB_DOUBLE("Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3); 613 - static struct sbmix_elem snd_sb16_ctl_auto_mic_gain = 614 - SB_SINGLE("Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1); 615 - 616 - static struct sbmix_elem *snd_sb16_controls[] = { 617 - &snd_sb16_ctl_master_play_vol, 618 - &snd_sb16_ctl_3d_enhance_switch, 619 - &snd_sb16_ctl_tone_bass, 620 - &snd_sb16_ctl_tone_treble, 621 - &snd_sb16_ctl_pcm_play_vol, 622 - &snd_sb16_ctl_synth_capture_route, 623 - &snd_sb16_ctl_synth_play_vol, 624 - &snd_sb16_ctl_cd_capture_route, 625 - &snd_sb16_ctl_cd_play_switch, 626 - &snd_sb16_ctl_cd_play_vol, 627 - &snd_sb16_ctl_line_capture_route, 628 - &snd_sb16_ctl_line_play_switch, 629 - &snd_sb16_ctl_line_play_vol, 630 - &snd_sb16_ctl_mic_capture_route, 631 - &snd_sb16_ctl_mic_play_switch, 632 - &snd_sb16_ctl_mic_play_vol, 633 - &snd_sb16_ctl_pc_speaker_vol, 634 - &snd_sb16_ctl_capture_vol, 635 - &snd_sb16_ctl_play_vol, 636 - &snd_sb16_ctl_auto_mic_gain 601 + static struct sbmix_elem snd_sb16_controls[] = { 602 + SB_DOUBLE("Master Playback Volume", 603 + SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31), 604 + SB_DOUBLE("PCM Playback Volume", 605 + SB_DSP4_PCM_DEV, (SB_DSP4_PCM_DEV + 1), 3, 3, 31), 606 + SB16_INPUT_SW("Synth Capture Route", 607 + SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 6, 5), 608 + SB_DOUBLE("Synth Playback Volume", 609 + SB_DSP4_SYNTH_DEV, (SB_DSP4_SYNTH_DEV + 1), 3, 3, 31), 610 + SB16_INPUT_SW("CD Capture Route", 611 + SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 2, 1), 612 + SB_DOUBLE("CD Playback Switch", 613 + SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1), 614 + SB_DOUBLE("CD Playback Volume", 615 + SB_DSP4_CD_DEV, (SB_DSP4_CD_DEV + 1), 3, 3, 31), 616 + SB16_INPUT_SW("Mic Capture Route", 617 + SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0), 618 + SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), 619 + SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), 620 + SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3), 621 + SB_DOUBLE("Capture Volume", 622 + SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3), 623 + SB_DOUBLE("Playback Volume", 624 + SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3), 625 + SB16_INPUT_SW("Line Capture Route", 626 + SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 4, 3), 627 + SB_DOUBLE("Line Playback Switch", 628 + SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1), 629 + SB_DOUBLE("Line Playback Volume", 630 + SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31), 631 + SB_SINGLE("Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1), 632 + SB_SINGLE("3D Enhancement Switch", SB_DSP4_3DSE, 0, 1), 633 + SB_DOUBLE("Tone Control - Bass", 634 + SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15), 635 + SB_DOUBLE("Tone Control - Treble", 636 + SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15) 637 637 }; 638 638 639 639 static unsigned char snd_sb16_init_values[][2] = { ··· 626 678 /* 627 679 * DT019x specific mixer elements 628 680 */ 629 - static struct sbmix_elem snd_dt019x_ctl_master_play_vol = 630 - SB_DOUBLE("Master Playback Volume", SB_DT019X_MASTER_DEV, SB_DT019X_MASTER_DEV, 4,0, 15); 631 - static struct sbmix_elem snd_dt019x_ctl_pcm_play_vol = 632 - SB_DOUBLE("PCM Playback Volume", SB_DT019X_PCM_DEV, SB_DT019X_PCM_DEV, 4,0, 15); 633 - static struct sbmix_elem snd_dt019x_ctl_synth_play_vol = 634 - SB_DOUBLE("Synth Playback Volume", SB_DT019X_SYNTH_DEV, SB_DT019X_SYNTH_DEV, 4,0, 15); 635 - static struct sbmix_elem snd_dt019x_ctl_cd_play_vol = 636 - SB_DOUBLE("CD Playback Volume", SB_DT019X_CD_DEV, SB_DT019X_CD_DEV, 4,0, 15); 637 - static struct sbmix_elem snd_dt019x_ctl_mic_play_vol = 638 - SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7); 639 - static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol = 640 - SB_SINGLE("Beep Volume", SB_DT019X_SPKR_DEV, 0, 7); 641 - static struct sbmix_elem snd_dt019x_ctl_line_play_vol = 642 - SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15); 643 - static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch = 644 - SB_DOUBLE("PCM Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2,1, 1); 645 - static struct sbmix_elem snd_dt019x_ctl_synth_play_switch = 646 - SB_DOUBLE("Synth Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4,3, 1); 647 - static struct sbmix_elem snd_dt019x_ctl_capture_source = 681 + static struct sbmix_elem snd_dt019x_controls[] = { 682 + /* ALS4000 below has some parts which we might be lacking, 683 + * e.g. snd_als4000_ctl_mono_playback_switch - check it! */ 684 + SB_DOUBLE("Master Playback Volume", 685 + SB_DT019X_MASTER_DEV, SB_DT019X_MASTER_DEV, 4, 0, 15), 686 + SB_DOUBLE("PCM Playback Switch", 687 + SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1), 688 + SB_DOUBLE("PCM Playback Volume", 689 + SB_DT019X_PCM_DEV, SB_DT019X_PCM_DEV, 4, 0, 15), 690 + SB_DOUBLE("Synth Playback Switch", 691 + SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4, 3, 1), 692 + SB_DOUBLE("Synth Playback Volume", 693 + SB_DT019X_SYNTH_DEV, SB_DT019X_SYNTH_DEV, 4, 0, 15), 694 + SB_DOUBLE("CD Playback Switch", 695 + SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1), 696 + SB_DOUBLE("CD Playback Volume", 697 + SB_DT019X_CD_DEV, SB_DT019X_CD_DEV, 4, 0, 15), 698 + SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), 699 + SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7), 700 + SB_SINGLE("Beep Volume", SB_DT019X_SPKR_DEV, 0, 7), 701 + SB_DOUBLE("Line Playback Switch", 702 + SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1), 703 + SB_DOUBLE("Line Playback Volume", 704 + SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4, 0, 15), 648 705 { 649 706 .name = "Capture Source", 650 707 .type = SB_MIX_CAPTURE_DT019X 651 - }; 652 - 653 - static struct sbmix_elem *snd_dt019x_controls[] = { 654 - /* ALS4000 below has some parts which we might be lacking, 655 - * e.g. snd_als4000_ctl_mono_playback_switch - check it! */ 656 - &snd_dt019x_ctl_master_play_vol, 657 - &snd_dt019x_ctl_pcm_play_vol, 658 - &snd_dt019x_ctl_synth_play_vol, 659 - &snd_dt019x_ctl_cd_play_vol, 660 - &snd_dt019x_ctl_mic_play_vol, 661 - &snd_dt019x_ctl_pc_speaker_vol, 662 - &snd_dt019x_ctl_line_play_vol, 663 - &snd_sb16_ctl_mic_play_switch, 664 - &snd_sb16_ctl_cd_play_switch, 665 - &snd_sb16_ctl_line_play_switch, 666 - &snd_dt019x_ctl_pcm_play_switch, 667 - &snd_dt019x_ctl_synth_play_switch, 668 - &snd_dt019x_ctl_capture_source 708 + } 669 709 }; 670 710 671 711 static unsigned char snd_dt019x_init_values[][2] = { ··· 671 735 /* 672 736 * ALS4000 specific mixer elements 673 737 */ 674 - static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch = 675 - SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1); 676 - static struct sbmix_elem snd_als4k_ctl_master_mono_capture_route = { 738 + static struct sbmix_elem snd_als4000_controls[] = { 739 + SB_DOUBLE("PCM Playback Switch", 740 + SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1), 741 + SB_DOUBLE("Synth Playback Switch", 742 + SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4, 3, 1), 743 + SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03), 744 + SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1), 745 + { 677 746 .name = "Master Mono Capture Route", 678 747 .type = SB_MIX_MONO_CAPTURE_ALS4K 679 - }; 680 - static struct sbmix_elem snd_als4000_ctl_mono_playback_switch = 681 - SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1); 682 - static struct sbmix_elem snd_als4000_ctl_mic_20db_boost = 683 - SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03); 684 - static struct sbmix_elem snd_als4000_ctl_mixer_analog_loopback = 685 - SB_SINGLE("Analog Loopback Switch", SB_ALS4000_MIC_IN_GAIN, 7, 0x01); 686 - static struct sbmix_elem snd_als4000_ctl_mixer_digital_loopback = 748 + }, 749 + SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1), 750 + SB_SINGLE("Analog Loopback Switch", SB_ALS4000_MIC_IN_GAIN, 7, 0x01), 751 + SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01), 687 752 SB_SINGLE("Digital Loopback Switch", 688 - SB_ALS4000_CR3_CONFIGURATION, 7, 0x01); 689 - /* FIXME: functionality of 3D controls might be swapped, I didn't find 690 - * a description of how to identify what is supposed to be what */ 691 - static struct sbmix_elem snd_als4000_3d_control_switch = 692 - SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01); 693 - static struct sbmix_elem snd_als4000_3d_control_ratio = 694 - SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07); 695 - static struct sbmix_elem snd_als4000_3d_control_freq = 753 + SB_ALS4000_CR3_CONFIGURATION, 7, 0x01), 754 + /* FIXME: functionality of 3D controls might be swapped, I didn't find 755 + * a description of how to identify what is supposed to be what */ 756 + SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07), 696 757 /* FIXME: maybe there's actually some standard 3D ctrl name for it?? */ 697 - SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03); 698 - static struct sbmix_elem snd_als4000_3d_control_delay = 758 + SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03), 699 759 /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay, 700 760 * but what ALSA 3D attribute is that actually? "Center", "Depth", 701 761 * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */ 702 - SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f); 703 - static struct sbmix_elem snd_als4000_3d_control_poweroff_switch = 704 - SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01); 705 - static struct sbmix_elem snd_als4000_ctl_3db_freq_control_switch = 762 + SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f), 763 + SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01), 706 764 SB_SINGLE("Master Playback 8kHz / 20kHz LPF Switch", 707 - SB_ALS4000_FMDAC, 5, 0x01); 765 + SB_ALS4000_FMDAC, 5, 0x01), 708 766 #ifdef NOT_AVAILABLE 709 - static struct sbmix_elem snd_als4000_ctl_fmdac = 710 - SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01); 711 - static struct sbmix_elem snd_als4000_ctl_qsound = 712 - SB_SINGLE("QSound Mode", SB_ALS4000_QSOUND, 1, 0x1f); 713 - #endif 714 - 715 - static struct sbmix_elem *snd_als4000_controls[] = { 716 - /* ALS4000a.PDF regs page */ 717 - &snd_sb16_ctl_master_play_vol, /* MX30/31 12 */ 718 - &snd_dt019x_ctl_pcm_play_switch, /* MX4C 16 */ 719 - &snd_sb16_ctl_pcm_play_vol, /* MX32/33 12 */ 720 - &snd_sb16_ctl_synth_capture_route, /* MX3D/3E 14 */ 721 - &snd_dt019x_ctl_synth_play_switch, /* MX4C 16 */ 722 - &snd_sb16_ctl_synth_play_vol, /* MX34/35 12/13 */ 723 - &snd_sb16_ctl_cd_capture_route, /* MX3D/3E 14 */ 724 - &snd_sb16_ctl_cd_play_switch, /* MX3C 14 */ 725 - &snd_sb16_ctl_cd_play_vol, /* MX36/37 13 */ 726 - &snd_sb16_ctl_line_capture_route, /* MX3D/3E 14 */ 727 - &snd_sb16_ctl_line_play_switch, /* MX3C 14 */ 728 - &snd_sb16_ctl_line_play_vol, /* MX38/39 13 */ 729 - &snd_sb16_ctl_mic_capture_route, /* MX3D/3E 14 */ 730 - &snd_als4000_ctl_mic_20db_boost, /* MX4D 16 */ 731 - &snd_sb16_ctl_mic_play_switch, /* MX3C 14 */ 732 - &snd_sb16_ctl_mic_play_vol, /* MX3A 13 */ 733 - &snd_sb16_ctl_pc_speaker_vol, /* MX3B 14 */ 734 - &snd_sb16_ctl_capture_vol, /* MX3F/40 15 */ 735 - &snd_sb16_ctl_play_vol, /* MX41/42 15 */ 736 - &snd_als4000_ctl_master_mono_playback_switch, /* MX4C 16 */ 737 - &snd_als4k_ctl_master_mono_capture_route, /* MX4B 16 */ 738 - &snd_als4000_ctl_mono_playback_switch, /* MX4C 16 */ 739 - &snd_als4000_ctl_mixer_analog_loopback, /* MX4D 16 */ 740 - &snd_als4000_ctl_mixer_digital_loopback, /* CR3 21 */ 741 - &snd_als4000_3d_control_switch, /* MX50 17 */ 742 - &snd_als4000_3d_control_ratio, /* MX50 17 */ 743 - &snd_als4000_3d_control_freq, /* MX50 17 */ 744 - &snd_als4000_3d_control_delay, /* MX51 18 */ 745 - &snd_als4000_3d_control_poweroff_switch, /* MX51 18 */ 746 - &snd_als4000_ctl_3db_freq_control_switch, /* MX4F 17 */ 747 - #ifdef NOT_AVAILABLE 748 - &snd_als4000_ctl_fmdac, 749 - &snd_als4000_ctl_qsound, 767 + SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01), 768 + SB_SINGLE("QSound Mode", SB_ALS4000_QSOUND, 1, 0x1f), 750 769 #endif 751 770 }; 752 771 ··· 720 829 { SB_ALS4000_MIC_IN_GAIN, 0 }, 721 830 }; 722 831 723 - 724 832 /* 725 833 */ 726 834 static int snd_sbmixer_init(struct snd_sb *chip, 727 - struct sbmix_elem **controls, 835 + struct sbmix_elem *controls, 728 836 int controls_count, 729 837 unsigned char map[][2], 730 838 int map_count, ··· 746 856 } 747 857 748 858 for (idx = 0; idx < controls_count; idx++) { 749 - if ((err = snd_sbmixer_add_ctl_elem(chip, controls[idx])) < 0) 859 + err = snd_sbmixer_add_ctl_elem(chip, &controls[idx]); 860 + if (err < 0) 750 861 return err; 751 862 } 752 863 snd_component_add(card, name); ··· 779 888 return err; 780 889 break; 781 890 case SB_HW_PRO: 891 + case SB_HW_JAZZ16: 782 892 if ((err = snd_sbmixer_init(chip, 783 893 snd_sbpro_controls, 784 894 ARRAY_SIZE(snd_sbpro_controls), ··· 800 908 return err; 801 909 break; 802 910 case SB_HW_ALS4000: 911 + /* use only the first 16 controls from SB16 */ 912 + err = snd_sbmixer_init(chip, 913 + snd_sb16_controls, 914 + 16, 915 + snd_sb16_init_values, 916 + ARRAY_SIZE(snd_sb16_init_values), 917 + "ALS4000"); 918 + if (err < 0) 919 + return err; 803 920 if ((err = snd_sbmixer_init(chip, 804 921 snd_als4000_controls, 805 922 ARRAY_SIZE(snd_als4000_controls), ··· 930 1029 save_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); 931 1030 break; 932 1031 case SB_HW_PRO: 1032 + case SB_HW_JAZZ16: 933 1033 save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); 934 1034 break; 935 1035 case SB_HW_16: ··· 957 1055 restore_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); 958 1056 break; 959 1057 case SB_HW_PRO: 1058 + case SB_HW_JAZZ16: 960 1059 restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); 961 1060 break; 962 1061 case SB_HW_16:
+14 -64
sound/isa/wss/wss_lib.c
··· 2014 2014 case WSS_HW_INTERWAVE: 2015 2015 ptexts = gusmax_texts; 2016 2016 break; 2017 + case WSS_HW_OPTI93X: 2017 2018 case WSS_HW_OPL3SA2: 2018 2019 ptexts = opl3sa_texts; 2019 2020 break; ··· 2247 2246 CS4231_MONO_CTRL, 5, 1, 0), 2248 2247 }; 2249 2248 2250 - static struct snd_kcontrol_new snd_opti93x_controls[] = { 2251 - WSS_DOUBLE("Master Playback Switch", 0, 2252 - OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), 2253 - WSS_DOUBLE_TLV("Master Playback Volume", 0, 2254 - OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1, 2255 - db_scale_6bit), 2256 - WSS_DOUBLE("PCM Playback Switch", 0, 2257 - CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), 2258 - WSS_DOUBLE("PCM Playback Volume", 0, 2259 - CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1), 2260 - WSS_DOUBLE("FM Playback Switch", 0, 2261 - CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), 2262 - WSS_DOUBLE("FM Playback Volume", 0, 2263 - CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1), 2264 - WSS_DOUBLE("Line Playback Switch", 0, 2265 - CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), 2266 - WSS_DOUBLE("Line Playback Volume", 0, 2267 - CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1), 2268 - WSS_DOUBLE("Mic Playback Switch", 0, 2269 - OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1), 2270 - WSS_DOUBLE("Mic Playback Volume", 0, 2271 - OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1), 2272 - WSS_DOUBLE("Mic Boost", 0, 2273 - CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), 2274 - WSS_DOUBLE("CD Playback Switch", 0, 2275 - CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), 2276 - WSS_DOUBLE("CD Playback Volume", 0, 2277 - CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1), 2278 - WSS_DOUBLE("Aux Playback Switch", 0, 2279 - OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1), 2280 - WSS_DOUBLE("Aux Playback Volume", 0, 2281 - OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1), 2282 - WSS_DOUBLE("Capture Volume", 0, 2283 - CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), 2284 - { 2285 - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2286 - .name = "Capture Source", 2287 - .info = snd_wss_info_mux, 2288 - .get = snd_wss_get_mux, 2289 - .put = snd_wss_put_mux, 2290 - } 2291 - }; 2292 - 2293 2249 int snd_wss_mixer(struct snd_wss *chip) 2294 2250 { 2295 2251 struct snd_card *card; 2296 2252 unsigned int idx; 2297 2253 int err; 2254 + int count = ARRAY_SIZE(snd_wss_controls); 2298 2255 2299 2256 if (snd_BUG_ON(!chip || !chip->pcm)) 2300 2257 return -EINVAL; ··· 2261 2302 2262 2303 strcpy(card->mixername, chip->pcm->name); 2263 2304 2264 - if (chip->hardware == WSS_HW_OPTI93X) 2265 - for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) { 2266 - err = snd_ctl_add(card, 2267 - snd_ctl_new1(&snd_opti93x_controls[idx], 2268 - chip)); 2269 - if (err < 0) 2270 - return err; 2271 - } 2272 - else { 2273 - int count = ARRAY_SIZE(snd_wss_controls); 2305 + /* Use only the first 11 entries on AD1848 */ 2306 + if (chip->hardware & WSS_HW_AD1848_MASK) 2307 + count = 11; 2308 + /* There is no loopback on OPTI93X */ 2309 + else if (chip->hardware == WSS_HW_OPTI93X) 2310 + count = 9; 2274 2311 2275 - /* Use only the first 11 entries on AD1848 */ 2276 - if (chip->hardware & WSS_HW_AD1848_MASK) 2277 - count = 11; 2278 - 2279 - for (idx = 0; idx < count; idx++) { 2280 - err = snd_ctl_add(card, 2281 - snd_ctl_new1(&snd_wss_controls[idx], 2282 - chip)); 2283 - if (err < 0) 2284 - return err; 2285 - } 2312 + for (idx = 0; idx < count; idx++) { 2313 + err = snd_ctl_add(card, 2314 + snd_ctl_new1(&snd_wss_controls[idx], 2315 + chip)); 2316 + if (err < 0) 2317 + return err; 2286 2318 } 2287 2319 return 0; 2288 2320 }
+9 -25
sound/mips/sgio2audio.c
··· 26 26 #include <linux/delay.h> 27 27 #include <linux/spinlock.h> 28 28 #include <linux/gfp.h> 29 - #include <linux/vmalloc.h> 30 29 #include <linux/interrupt.h> 31 30 #include <linux/dma-mapping.h> 32 31 #include <linux/platform_device.h> ··· 602 603 static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream, 603 604 struct snd_pcm_hw_params *hw_params) 604 605 { 605 - struct snd_pcm_runtime *runtime = substream->runtime; 606 - int size = params_buffer_bytes(hw_params); 607 - 608 - /* alloc virtual 'dma' area */ 609 - if (runtime->dma_area) 610 - vfree(runtime->dma_area); 611 - runtime->dma_area = vmalloc_user(size); 612 - if (runtime->dma_area == NULL) 613 - return -ENOMEM; 614 - runtime->dma_bytes = size; 615 - return 0; 606 + return snd_pcm_lib_alloc_vmalloc_buffer(substream, 607 + params_buffer_bytes(hw_params)); 616 608 } 617 609 618 610 /* hw_free callback */ 619 611 static int snd_sgio2audio_pcm_hw_free(struct snd_pcm_substream *substream) 620 612 { 621 - vfree(substream->runtime->dma_area); 622 - substream->runtime->dma_area = NULL; 623 - return 0; 613 + return snd_pcm_lib_free_vmalloc_buffer(substream); 624 614 } 625 615 626 616 /* prepare callback */ ··· 680 692 chip->channel[chan->idx].pos); 681 693 } 682 694 683 - /* get the physical page pointer on the given offset */ 684 - static struct page *snd_sgio2audio_page(struct snd_pcm_substream *substream, 685 - unsigned long offset) 686 - { 687 - return vmalloc_to_page(substream->runtime->dma_area + offset); 688 - } 689 - 690 695 /* operators */ 691 696 static struct snd_pcm_ops snd_sgio2audio_playback1_ops = { 692 697 .open = snd_sgio2audio_playback1_open, ··· 690 709 .prepare = snd_sgio2audio_pcm_prepare, 691 710 .trigger = snd_sgio2audio_pcm_trigger, 692 711 .pointer = snd_sgio2audio_pcm_pointer, 693 - .page = snd_sgio2audio_page, 712 + .page = snd_pcm_lib_get_vmalloc_page, 713 + .mmap = snd_pcm_lib_mmap_vmalloc, 694 714 }; 695 715 696 716 static struct snd_pcm_ops snd_sgio2audio_playback2_ops = { ··· 703 721 .prepare = snd_sgio2audio_pcm_prepare, 704 722 .trigger = snd_sgio2audio_pcm_trigger, 705 723 .pointer = snd_sgio2audio_pcm_pointer, 706 - .page = snd_sgio2audio_page, 724 + .page = snd_pcm_lib_get_vmalloc_page, 725 + .mmap = snd_pcm_lib_mmap_vmalloc, 707 726 }; 708 727 709 728 static struct snd_pcm_ops snd_sgio2audio_capture_ops = { ··· 716 733 .prepare = snd_sgio2audio_pcm_prepare, 717 734 .trigger = snd_sgio2audio_pcm_trigger, 718 735 .pointer = snd_sgio2audio_pcm_pointer, 719 - .page = snd_sgio2audio_page, 736 + .page = snd_pcm_lib_get_vmalloc_page, 737 + .mmap = snd_pcm_lib_mmap_vmalloc, 720 738 }; 721 739 722 740 /*
+1 -1
sound/oss/kahlua.c
··· 198 198 * 5530 only. The 5510/5520 decode is different. 199 199 */ 200 200 201 - static struct pci_device_id id_tbl[] = { 201 + static DEFINE_PCI_DEVICE_TABLE(id_tbl) = { 202 202 { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO), 0 }, 203 203 { } 204 204 };
+22 -13
sound/oss/soundcard.c
··· 328 328 return mixer_devs[mixdev]->ioctl(mixdev, cmd, arg); 329 329 } 330 330 331 - static int sound_ioctl(struct inode *inode, struct file *file, 332 - unsigned int cmd, unsigned long arg) 331 + static long sound_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 333 332 { 334 333 int len = 0, dtype; 335 - int dev = iminor(inode); 334 + int dev = iminor(file->f_dentry->d_inode); 335 + long ret = -EINVAL; 336 336 void __user *p = (void __user *)arg; 337 337 338 338 if (_SIOC_DIR(cmd) != _SIOC_NONE && _SIOC_DIR(cmd) != 0) { ··· 353 353 if (cmd == OSS_GETVERSION) 354 354 return __put_user(SOUND_VERSION, (int __user *)p); 355 355 356 + lock_kernel(); 356 357 if (_IOC_TYPE(cmd) == 'M' && num_mixers > 0 && /* Mixer ioctl */ 357 358 (dev & 0x0f) != SND_DEV_CTL) { 358 359 dtype = dev & 0x0f; ··· 361 360 case SND_DEV_DSP: 362 361 case SND_DEV_DSP16: 363 362 case SND_DEV_AUDIO: 364 - return sound_mixer_ioctl(audio_devs[dev >> 4]->mixer_dev, 363 + ret = sound_mixer_ioctl(audio_devs[dev >> 4]->mixer_dev, 365 364 cmd, p); 366 - 365 + break; 367 366 default: 368 - return sound_mixer_ioctl(dev >> 4, cmd, p); 367 + ret = sound_mixer_ioctl(dev >> 4, cmd, p); 368 + break; 369 369 } 370 + unlock_kernel(); 371 + return ret; 370 372 } 373 + 371 374 switch (dev & 0x0f) { 372 375 case SND_DEV_CTL: 373 376 if (cmd == SOUND_MIXER_GETLEVELS) 374 - return get_mixer_levels(p); 375 - if (cmd == SOUND_MIXER_SETLEVELS) 376 - return set_mixer_levels(p); 377 - return sound_mixer_ioctl(dev >> 4, cmd, p); 377 + ret = get_mixer_levels(p); 378 + else if (cmd == SOUND_MIXER_SETLEVELS) 379 + ret = set_mixer_levels(p); 380 + else 381 + ret = sound_mixer_ioctl(dev >> 4, cmd, p); 382 + break; 378 383 379 384 case SND_DEV_SEQ: 380 385 case SND_DEV_SEQ2: 381 - return sequencer_ioctl(dev, file, cmd, p); 386 + ret = sequencer_ioctl(dev, file, cmd, p); 387 + break; 382 388 383 389 case SND_DEV_DSP: 384 390 case SND_DEV_DSP16: ··· 398 390 break; 399 391 400 392 } 401 - return -EINVAL; 393 + unlock_kernel(); 394 + return ret; 402 395 } 403 396 404 397 static unsigned int sound_poll(struct file *file, poll_table * wait) ··· 499 490 .read = sound_read, 500 491 .write = sound_write, 501 492 .poll = sound_poll, 502 - .ioctl = sound_ioctl, 493 + .unlocked_ioctl = sound_ioctl, 503 494 .mmap = sound_mmap, 504 495 .open = sound_open, 505 496 .release = sound_release,
+1
sound/pci/Kconfig
··· 789 789 Say Y here to include support for sound cards based on the 790 790 Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, 791 791 Essence ST (Deluxe), and Essence STX. 792 + Support for the DS is experimental. 792 793 Support for the HDAV1.3 (Deluxe) is very experimental. 793 794 794 795 To compile this driver as a module, choose M here: the module
+1 -16
sound/pci/ac97/ac97_patch.c
··· 544 544 return 0; 545 545 } 546 546 547 - static int patch_wolfson_wm9705_specific(struct snd_ac97 * ac97) 548 - { 549 - int err, i; 550 - for (i = 0; i < ARRAY_SIZE(wm97xx_snd_ac97_controls); i++) { 551 - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97))) < 0) 552 - return err; 553 - } 554 - snd_ac97_write_cache(ac97, 0x72, 0x0808); 555 - return 0; 556 - } 557 - 558 - static struct snd_ac97_build_ops patch_wolfson_wm9705_ops = { 559 - .build_specific = patch_wolfson_wm9705_specific, 560 - }; 561 - 562 547 static int patch_wolfson05(struct snd_ac97 * ac97) 563 548 { 564 549 /* WM9705, WM9710 */ 565 - ac97->build_ops = &patch_wolfson_wm9705_ops; 550 + ac97->build_ops = &patch_wolfson_wm9703_ops; 566 551 #ifdef CONFIG_TOUCHSCREEN_WM9705 567 552 /* WM9705 touchscreen uses AUX and VIDEO for touch */ 568 553 ac97->flags |= AC97_HAS_NO_VIDEO | AC97_HAS_NO_AUX;
+1 -1
sound/pci/ad1889.c
··· 1048 1048 pci_set_drvdata(pci, NULL); 1049 1049 } 1050 1050 1051 - static struct pci_device_id snd_ad1889_ids[] = { 1051 + static DEFINE_PCI_DEVICE_TABLE(snd_ad1889_ids) = { 1052 1052 { PCI_DEVICE(PCI_VENDOR_ID_ANALOG_DEVICES, PCI_DEVICE_ID_AD1889JS) }, 1053 1053 { 0, }, 1054 1054 };
+1 -1
sound/pci/ali5451/ali5451.c
··· 275 275 #endif 276 276 }; 277 277 278 - static struct pci_device_id snd_ali_ids[] = { 278 + static DEFINE_PCI_DEVICE_TABLE(snd_ali_ids) = { 279 279 {PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5451), 0, 0, 0}, 280 280 {0, } 281 281 };
+1 -1
sound/pci/als300.c
··· 145 145 int block_counter_register; 146 146 }; 147 147 148 - static struct pci_device_id snd_als300_ids[] = { 148 + static DEFINE_PCI_DEVICE_TABLE(snd_als300_ids) = { 149 149 { 0x4005, 0x0300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALS300 }, 150 150 { 0x4005, 0x0308, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DEVICE_ALS300_PLUS }, 151 151 { 0, }
+1 -1
sound/pci/als4000.c
··· 117 117 #endif 118 118 }; 119 119 120 - static struct pci_device_id snd_als4000_ids[] = { 120 + static DEFINE_PCI_DEVICE_TABLE(snd_als4000_ids) = { 121 121 { 0x4005, 0x4000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ALS4000 */ 122 122 { 0, } 123 123 };
+1 -1
sound/pci/atiixp.c
··· 286 286 287 287 /* 288 288 */ 289 - static struct pci_device_id snd_atiixp_ids[] = { 289 + static DEFINE_PCI_DEVICE_TABLE(snd_atiixp_ids) = { 290 290 { PCI_VDEVICE(ATI, 0x4341), 0 }, /* SB200 */ 291 291 { PCI_VDEVICE(ATI, 0x4361), 0 }, /* SB300 */ 292 292 { PCI_VDEVICE(ATI, 0x4370), 0 }, /* SB400 */
+1 -1
sound/pci/atiixp_modem.c
··· 261 261 262 262 /* 263 263 */ 264 - static struct pci_device_id snd_atiixp_ids[] = { 264 + static DEFINE_PCI_DEVICE_TABLE(snd_atiixp_ids) = { 265 265 { PCI_VDEVICE(ATI, 0x434d), 0 }, /* SB200 */ 266 266 { PCI_VDEVICE(ATI, 0x4378), 0 }, /* SB400 */ 267 267 { 0, }
+1 -1
sound/pci/au88x0/au8810.c
··· 1 1 #include "au8810.h" 2 2 #include "au88x0.h" 3 - static struct pci_device_id snd_vortex_ids[] = { 3 + static DEFINE_PCI_DEVICE_TABLE(snd_vortex_ids) = { 4 4 {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_ADVANTAGE), 1,}, 5 5 {0,} 6 6 };
+1 -1
sound/pci/au88x0/au8820.c
··· 1 1 #include "au8820.h" 2 2 #include "au88x0.h" 3 - static struct pci_device_id snd_vortex_ids[] = { 3 + static DEFINE_PCI_DEVICE_TABLE(snd_vortex_ids) = { 4 4 {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_1), 0,}, 5 5 {0,} 6 6 };
+1 -1
sound/pci/au88x0/au8830.c
··· 1 1 #include "au8830.h" 2 2 #include "au88x0.h" 3 - static struct pci_device_id snd_vortex_ids[] = { 3 + static DEFINE_PCI_DEVICE_TABLE(snd_vortex_ids) = { 4 4 {PCI_VDEVICE(AUREAL, PCI_DEVICE_ID_AUREAL_VORTEX_2), 0,}, 5 5 {0,} 6 6 };
+1 -1
sound/pci/aw2/aw2-alsa.c
··· 164 164 module_param_array(enable, bool, NULL, 0444); 165 165 MODULE_PARM_DESC(enable, "Enable Audiowerk2 soundcard."); 166 166 167 - static struct pci_device_id snd_aw2_ids[] = { 167 + static DEFINE_PCI_DEVICE_TABLE(snd_aw2_ids) = { 168 168 {PCI_VENDOR_ID_SAA7146, PCI_DEVICE_ID_SAA7146, 0, 0, 169 169 0, 0, 0}, 170 170 {0}
+1 -1
sound/pci/azt3328.c
··· 350 350 #endif 351 351 }; 352 352 353 - static const struct pci_device_id snd_azf3328_ids[] = { 353 + static DEFINE_PCI_DEVICE_TABLE(snd_azf3328_ids) = { 354 354 { 0x122D, 0x50DC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* PCI168/3328 */ 355 355 { 0x122D, 0x80DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* 3328 */ 356 356 { 0, }
+2 -2
sound/pci/bt87x.c
··· 795 795 .driver_data = SND_BT87X_BOARD_ ## id } 796 796 /* driver_data is the card id for that device */ 797 797 798 - static struct pci_device_id snd_bt87x_ids[] = { 798 + static DEFINE_PCI_DEVICE_TABLE(snd_bt87x_ids) = { 799 799 /* Hauppauge WinTV series */ 800 800 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0x13eb, GENERIC), 801 801 /* Hauppauge WinTV series */ ··· 964 964 965 965 /* default entries for all Bt87x cards - it's not exported */ 966 966 /* driver_data is set to 0 to call detection */ 967 - static struct pci_device_id snd_bt87x_default_ids[] __devinitdata = { 967 + static DEFINE_PCI_DEVICE_TABLE(snd_bt87x_default_ids) = { 968 968 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, PCI_ANY_ID, PCI_ANY_ID, UNKNOWN), 969 969 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, PCI_ANY_ID, PCI_ANY_ID, UNKNOWN), 970 970 { }
+1 -1
sound/pci/ca0106/ca0106_main.c
··· 1875 1875 #endif 1876 1876 1877 1877 // PCI IDs 1878 - static struct pci_device_id snd_ca0106_ids[] = { 1878 + static DEFINE_PCI_DEVICE_TABLE(snd_ca0106_ids) = { 1879 1879 { PCI_VDEVICE(CREATIVE, 0x0007), 0 }, /* Audigy LS or Live 24bit */ 1880 1880 { 0, } 1881 1881 };
+2 -2
sound/pci/cmipci.c
··· 2796 2796 #endif 2797 2797 2798 2798 2799 - static struct pci_device_id snd_cmipci_ids[] = { 2799 + static DEFINE_PCI_DEVICE_TABLE(snd_cmipci_ids) = { 2800 2800 {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338A), 0}, 2801 2801 {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8338B), 0}, 2802 2802 {PCI_VDEVICE(CMEDIA, PCI_DEVICE_ID_CMEDIA_CM8738), 0}, ··· 3018 3018 int integrated_midi = 0; 3019 3019 char modelstr[16]; 3020 3020 int pcm_index, pcm_spdif_index; 3021 - static struct pci_device_id intel_82437vx[] = { 3021 + static DEFINE_PCI_DEVICE_TABLE(intel_82437vx) = { 3022 3022 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX) }, 3023 3023 { }, 3024 3024 };
+1 -1
sound/pci/cs4281.c
··· 494 494 495 495 static irqreturn_t snd_cs4281_interrupt(int irq, void *dev_id); 496 496 497 - static struct pci_device_id snd_cs4281_ids[] = { 497 + static DEFINE_PCI_DEVICE_TABLE(snd_cs4281_ids) = { 498 498 { PCI_VDEVICE(CIRRUS, 0x6005), 0, }, /* CS4281 */ 499 499 { 0, } 500 500 };
+1 -1
sound/pci/cs46xx/cs46xx.c
··· 64 64 module_param_array(mmap_valid, bool, NULL, 0444); 65 65 MODULE_PARM_DESC(mmap_valid, "Support OSS mmap."); 66 66 67 - static struct pci_device_id snd_cs46xx_ids[] = { 67 + static DEFINE_PCI_DEVICE_TABLE(snd_cs46xx_ids) = { 68 68 { PCI_VDEVICE(CIRRUS, 0x6001), 0, }, /* CS4280 */ 69 69 { PCI_VDEVICE(CIRRUS, 0x6003), 0, }, /* CS4612 */ 70 70 { PCI_VDEVICE(CIRRUS, 0x6004), 0, }, /* CS4615 */
+16 -6
sound/pci/cs46xx/cs46xx_lib.c
··· 2238 2238 2239 2239 /* set the desired CODEC mode */ 2240 2240 if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) { 2241 - snd_printdd("cs46xx: CODOEC1 mode %04x\n",0x0); 2242 - snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x0); 2241 + snd_printdd("cs46xx: CODEC1 mode %04x\n", 0x0); 2242 + snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x0); 2243 2243 } else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) { 2244 - snd_printdd("cs46xx: CODOEC2 mode %04x\n",0x3); 2245 - snd_cs46xx_ac97_write(ac97,AC97_CSR_ACMODE,0x3); 2244 + snd_printdd("cs46xx: CODEC2 mode %04x\n", 0x3); 2245 + snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x3); 2246 2246 } else { 2247 2247 snd_BUG(); /* should never happen ... */ 2248 2248 } ··· 2266 2266 return; 2267 2267 2268 2268 /* test if we can write to the record gain volume register */ 2269 - snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a05); 2269 + snd_ac97_write(ac97, AC97_REC_GAIN, 0x8a05); 2270 2270 if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05) 2271 2271 return; 2272 2272 ··· 3597 3597 #ifdef CONFIG_PM 3598 3598 static unsigned int saved_regs[] = { 3599 3599 BA0_ACOSV, 3600 - BA0_ASER_FADDR, 3600 + /*BA0_ASER_FADDR,*/ 3601 3601 BA0_ASER_MASTER, 3602 3602 BA1_PVOL, 3603 3603 BA1_CVOL, ··· 3644 3644 #ifdef CONFIG_SND_CS46XX_NEW_DSP 3645 3645 int i; 3646 3646 #endif 3647 + unsigned int tmp; 3647 3648 3648 3649 pci_set_power_state(pci, PCI_D0); 3649 3650 pci_restore_state(pci); ··· 3685 3684 3686 3685 snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); 3687 3686 snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); 3687 + 3688 + /* 3689 + * Stop capture DMA. 3690 + */ 3691 + tmp = snd_cs46xx_peek(chip, BA1_CCTL); 3692 + chip->capt.ctl = tmp & 0x0000ffff; 3693 + snd_cs46xx_poke(chip, BA1_CCTL, tmp & 0xffff0000); 3694 + 3695 + mdelay(5); 3688 3696 3689 3697 /* reset playback/capture */ 3690 3698 snd_cs46xx_set_play_sample_rate(chip, 8000);
+38 -4
sound/pci/cs46xx/dsp_spos.c
··· 298 298 if (ins->scbs[i].deleted) continue; 299 299 300 300 cs46xx_dsp_proc_free_scb_desc ( (ins->scbs + i) ); 301 + #ifdef CONFIG_PM 302 + kfree(ins->scbs[i].data); 303 + #endif 301 304 } 302 305 303 306 kfree(ins->code.data); ··· 977 974 978 975 index = find_free_scb_index (ins); 979 976 977 + memset(&ins->scbs[index], 0, sizeof(ins->scbs[index])); 980 978 strcpy(ins->scbs[index].scb_name, name); 981 979 ins->scbs[index].address = dest; 982 980 ins->scbs[index].index = index; 983 - ins->scbs[index].proc_info = NULL; 984 981 ins->scbs[index].ref_count = 1; 985 - ins->scbs[index].deleted = 0; 986 - spin_lock_init(&ins->scbs[index].lock); 987 982 988 983 desc = (ins->scbs + index); 989 984 ins->scbs[index].scb_symbol = add_symbol (chip, name, dest, SYMBOL_PARAMETER); ··· 1023 1022 return desc; 1024 1023 } 1025 1024 1025 + #define SCB_BYTES (0x10 * 4) 1026 + 1026 1027 struct dsp_scb_descriptor * 1027 1028 cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 dest) 1028 1029 { 1029 1030 struct dsp_scb_descriptor * desc; 1031 + 1032 + #ifdef CONFIG_PM 1033 + /* copy the data for resume */ 1034 + scb_data = kmemdup(scb_data, SCB_BYTES, GFP_KERNEL); 1035 + if (!scb_data) 1036 + return NULL; 1037 + #endif 1030 1038 1031 1039 desc = _map_scb (chip,name,dest); 1032 1040 if (desc) { ··· 1043 1033 _dsp_create_scb(chip,scb_data,dest); 1044 1034 } else { 1045 1035 snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n"); 1036 + #ifdef CONFIG_PM 1037 + kfree(scb_data); 1038 + #endif 1046 1039 } 1047 1040 1048 1041 return desc; ··· 2001 1988 continue; 2002 1989 _dsp_create_scb(chip, s->data, s->address); 2003 1990 } 2004 - 1991 + for (i = 0; i < ins->nscb; i++) { 1992 + struct dsp_scb_descriptor *s = &ins->scbs[i]; 1993 + if (s->deleted) 1994 + continue; 1995 + if (s->updated) 1996 + cs46xx_dsp_spos_update_scb(chip, s); 1997 + if (s->volume_set) 1998 + cs46xx_dsp_scb_set_volume(chip, s, 1999 + s->volume[0], s->volume[1]); 2000 + } 2001 + if (ins->spdif_status_out & DSP_SPDIF_STATUS_HW_ENABLED) { 2002 + cs46xx_dsp_enable_spdif_hw(chip); 2003 + snd_cs46xx_poke(chip, (ins->ref_snoop_scb->address + 2) << 2, 2004 + (OUTPUT_SNOOP_BUFFER + 0x10) << 0x10); 2005 + if (ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN) 2006 + cs46xx_poke_via_dsp(chip, SP_SPDOUT_CSUV, 2007 + ins->spdif_csuv_stream); 2008 + } 2009 + if (chip->dsp_spos_instance->spdif_status_in) { 2010 + cs46xx_poke_via_dsp(chip, SP_ASER_COUNTDOWN, 0x80000005); 2011 + cs46xx_poke_via_dsp(chip, SP_SPDIN_CONTROL, 0x800003ff); 2012 + } 2005 2013 return 0; 2006 2014 } 2007 2015 #endif
+4
sound/pci/cs46xx/dsp_spos.h
··· 212 212 (scb->address + SCBsubListPtr) << 2, 213 213 (scb->sub_list_ptr->address << 0x10) | 214 214 (scb->next_scb_ptr->address)); 215 + scb->updated = 1; 215 216 } 216 217 217 218 static inline void cs46xx_dsp_scb_set_volume (struct snd_cs46xx * chip, ··· 223 222 224 223 snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl) << 2, val); 225 224 snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl + 1) << 2, val); 225 + scb->volume_set = 1; 226 + scb->volume[0] = left; 227 + scb->volume[1] = right; 226 228 } 227 229 #endif /* __DSP_SPOS_H__ */ 228 230 #endif /* CONFIG_SND_CS46XX_NEW_DSP */
+15 -18
sound/pci/cs46xx/dsp_spos_scb_lib.c
··· 115 115 static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb) 116 116 { 117 117 struct dsp_spos_instance * ins = chip->dsp_spos_instance; 118 - unsigned long flags; 119 118 120 119 if ( scb->parent_scb_ptr ) { 121 120 /* unlink parent SCB */ ··· 152 153 scb->next_scb_ptr = ins->the_null_scb; 153 154 } 154 155 155 - spin_lock_irqsave(&chip->reg_lock, flags); 156 - 157 156 /* update parent first entry in DSP RAM */ 158 157 cs46xx_dsp_spos_update_scb(chip,scb->parent_scb_ptr); 159 158 ··· 159 162 cs46xx_dsp_spos_update_scb(chip,scb); 160 163 161 164 scb->parent_scb_ptr = NULL; 162 - spin_unlock_irqrestore(&chip->reg_lock, flags); 163 165 } 164 166 } 165 167 ··· 193 197 goto _end; 194 198 #endif 195 199 196 - spin_lock_irqsave(&scb->lock, flags); 200 + spin_lock_irqsave(&chip->reg_lock, flags); 197 201 _dsp_unlink_scb (chip,scb); 198 - spin_unlock_irqrestore(&scb->lock, flags); 202 + spin_unlock_irqrestore(&chip->reg_lock, flags); 199 203 200 204 cs46xx_dsp_proc_free_scb_desc(scb); 201 205 if (snd_BUG_ON(!scb->scb_symbol)) ··· 203 207 remove_symbol (chip,scb->scb_symbol); 204 208 205 209 ins->scbs[scb->index].deleted = 1; 210 + #ifdef CONFIG_PM 211 + kfree(ins->scbs[scb->index].data); 212 + ins->scbs[scb->index].data = NULL; 213 + #endif 206 214 207 215 if (scb->index < ins->scb_highest_frag_index) 208 216 ins->scb_highest_frag_index = scb->index; ··· 1508 1508 chip->dsp_spos_instance->npcm_channels <= 0)) 1509 1509 return -EIO; 1510 1510 1511 - spin_lock(&pcm_channel->src_scb->lock); 1512 - 1511 + spin_lock_irqsave(&chip->reg_lock, flags); 1513 1512 if (pcm_channel->unlinked) { 1514 - spin_unlock(&pcm_channel->src_scb->lock); 1513 + spin_unlock_irqrestore(&chip->reg_lock, flags); 1515 1514 return -EIO; 1516 1515 } 1517 1516 1518 - spin_lock_irqsave(&chip->reg_lock, flags); 1519 1517 pcm_channel->unlinked = 1; 1520 - spin_unlock_irqrestore(&chip->reg_lock, flags); 1521 1518 1522 1519 _dsp_unlink_scb (chip,pcm_channel->pcm_reader_scb); 1520 + spin_unlock_irqrestore(&chip->reg_lock, flags); 1523 1521 1524 - spin_unlock(&pcm_channel->src_scb->lock); 1525 1522 return 0; 1526 1523 } 1527 1524 ··· 1530 1533 struct dsp_scb_descriptor * src_scb = pcm_channel->src_scb; 1531 1534 unsigned long flags; 1532 1535 1533 - spin_lock(&pcm_channel->src_scb->lock); 1536 + spin_lock_irqsave(&chip->reg_lock, flags); 1534 1537 1535 1538 if (pcm_channel->unlinked == 0) { 1536 - spin_unlock(&pcm_channel->src_scb->lock); 1539 + spin_unlock_irqrestore(&chip->reg_lock, flags); 1537 1540 return -EIO; 1538 1541 } 1539 1542 ··· 1549 1552 snd_BUG_ON(pcm_channel->pcm_reader_scb->parent_scb_ptr); 1550 1553 pcm_channel->pcm_reader_scb->parent_scb_ptr = parent_scb; 1551 1554 1552 - spin_lock_irqsave(&chip->reg_lock, flags); 1553 - 1554 1555 /* update SCB entry in DSP RAM */ 1555 1556 cs46xx_dsp_spos_update_scb(chip,pcm_channel->pcm_reader_scb); 1556 1557 ··· 1557 1562 1558 1563 pcm_channel->unlinked = 0; 1559 1564 spin_unlock_irqrestore(&chip->reg_lock, flags); 1560 - 1561 - spin_unlock(&pcm_channel->src_scb->lock); 1562 1565 return 0; 1563 1566 } 1564 1567 ··· 1589 1596 1590 1597 int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) 1591 1598 { 1599 + unsigned long flags; 1600 + 1592 1601 if (snd_BUG_ON(!src->parent_scb_ptr)) 1593 1602 return -EINVAL; 1594 1603 1595 1604 /* mute SCB */ 1596 1605 cs46xx_dsp_scb_set_volume (chip,src,0,0); 1597 1606 1607 + spin_lock_irqsave(&chip->reg_lock, flags); 1598 1608 _dsp_unlink_scb (chip,src); 1609 + spin_unlock_irqrestore(&chip->reg_lock, flags); 1599 1610 1600 1611 return 0; 1601 1612 }
+1 -1
sound/pci/cs5530.c
··· 58 58 unsigned long pci_base; 59 59 }; 60 60 61 - static struct pci_device_id snd_cs5530_ids[] = { 61 + static DEFINE_PCI_DEVICE_TABLE(snd_cs5530_ids) = { 62 62 {PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_AUDIO, PCI_ANY_ID, 63 63 PCI_ANY_ID, 0, 0}, 64 64 {0,}
+1 -1
sound/pci/cs5535audio/cs5535audio.c
··· 66 66 module_param_array(enable, bool, NULL, 0444); 67 67 MODULE_PARM_DESC(enable, "Enable " DRIVER_NAME); 68 68 69 - static struct pci_device_id snd_cs5535audio_ids[] = { 69 + static DEFINE_PCI_DEVICE_TABLE(snd_cs5535audio_ids) = { 70 70 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO) }, 71 71 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO) }, 72 72 {}
+15 -8
sound/pci/ctxfi/ctatc.c
··· 1214 1214 return ct_atc_destroy(atc); 1215 1215 } 1216 1216 1217 - static int __devinit atc_identify_card(struct ct_atc *atc) 1217 + static int __devinit atc_identify_card(struct ct_atc *atc, unsigned int ssid) 1218 1218 { 1219 1219 const struct snd_pci_quirk *p; 1220 1220 const struct snd_pci_quirk *list; 1221 + u16 vendor_id, device_id; 1221 1222 1222 1223 switch (atc->chip_type) { 1223 1224 case ATC20K1: ··· 1232 1231 default: 1233 1232 return -ENOENT; 1234 1233 } 1235 - p = snd_pci_quirk_lookup(atc->pci, list); 1234 + if (ssid) { 1235 + vendor_id = ssid >> 16; 1236 + device_id = ssid & 0xffff; 1237 + } else { 1238 + vendor_id = atc->pci->subsystem_vendor; 1239 + device_id = atc->pci->subsystem_device; 1240 + } 1241 + p = snd_pci_quirk_lookup_id(vendor_id, device_id, list); 1236 1242 if (p) { 1237 1243 if (p->value < 0) { 1238 1244 printk(KERN_ERR "ctxfi: " 1239 1245 "Device %04x:%04x is black-listed\n", 1240 - atc->pci->subsystem_vendor, 1241 - atc->pci->subsystem_device); 1246 + vendor_id, device_id); 1242 1247 return -ENOENT; 1243 1248 } 1244 1249 atc->model = p->value; ··· 1257 1250 atc->model_name = ct_subsys_name[atc->model]; 1258 1251 snd_printd("ctxfi: chip %s model %s (%04x:%04x) is found\n", 1259 1252 atc->chip_name, atc->model_name, 1260 - atc->pci->subsystem_vendor, 1261 - atc->pci->subsystem_device); 1253 + vendor_id, device_id); 1262 1254 return 0; 1263 1255 } 1264 1256 ··· 1631 1625 1632 1626 int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, 1633 1627 unsigned int rsr, unsigned int msr, 1634 - int chip_type, struct ct_atc **ratc) 1628 + int chip_type, unsigned int ssid, 1629 + struct ct_atc **ratc) 1635 1630 { 1636 1631 struct ct_atc *atc; 1637 1632 static struct snd_device_ops ops = { ··· 1658 1651 mutex_init(&atc->atc_mutex); 1659 1652 1660 1653 /* Find card model */ 1661 - err = atc_identify_card(atc); 1654 + err = atc_identify_card(atc, ssid); 1662 1655 if (err < 0) { 1663 1656 printk(KERN_ERR "ctatc: Card not recognised\n"); 1664 1657 goto error1;
+1 -1
sound/pci/ctxfi/ctatc.h
··· 148 148 149 149 int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, 150 150 unsigned int rsr, unsigned int msr, int chip_type, 151 - struct ct_atc **ratc); 151 + unsigned int subsysid, struct ct_atc **ratc); 152 152 int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc); 153 153 154 154 #endif /* CTATC_H */
+5 -2
sound/pci/ctxfi/xfi.c
··· 32 32 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 33 33 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 34 34 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 35 + static unsigned int subsystem[SNDRV_CARDS]; 35 36 36 37 module_param_array(index, int, NULL, 0444); 37 38 MODULE_PARM_DESC(index, "Index value for Creative X-Fi driver"); ··· 40 39 MODULE_PARM_DESC(id, "ID string for Creative X-Fi driver"); 41 40 module_param_array(enable, bool, NULL, 0444); 42 41 MODULE_PARM_DESC(enable, "Enable Creative X-Fi driver"); 42 + module_param_array(subsystem, int, NULL, 0444); 43 + MODULE_PARM_DESC(subsystem, "Override subsystem ID for Creative X-Fi driver"); 43 44 44 - static struct pci_device_id ct_pci_dev_ids[] = { 45 + static DEFINE_PCI_DEVICE_TABLE(ct_pci_dev_ids) = { 45 46 /* only X-Fi is supported, so... */ 46 47 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K1), 47 48 .driver_data = ATC20K1, ··· 88 85 multiple = 2; 89 86 } 90 87 err = ct_atc_create(card, pci, reference_rate, multiple, 91 - pci_id->driver_data, &atc); 88 + pci_id->driver_data, subsystem[dev], &atc); 92 89 if (err < 0) 93 90 goto error; 94 91
+1 -1
sound/pci/echoaudio/darla20.c
··· 63 63 {0, "darla20_dsp.fw"} 64 64 }; 65 65 66 - static struct pci_device_id snd_echo_ids[] = { 66 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 67 67 {0x1057, 0x1801, 0xECC0, 0x0010, 0, 0, 0}, /* DSP 56301 Darla20 rev.0 */ 68 68 {0,} 69 69 };
+8 -4
sound/pci/echoaudio/darla20_dsp.c
··· 45 45 chip->device_id = device_id; 46 46 chip->subdevice_id = subdevice_id; 47 47 chip->bad_board = TRUE; 48 - chip->dsp_code_to_load = &card_fw[FW_DARLA20_DSP]; 48 + chip->dsp_code_to_load = FW_DARLA20_DSP; 49 49 chip->spdif_status = GD_SPDIF_STATUS_UNDEF; 50 50 chip->clock_state = GD_CLOCK_UNDEF; 51 51 /* Since this card has no ASIC, mark it as loaded so everything ··· 57 57 return err; 58 58 chip->bad_board = FALSE; 59 59 60 - if ((err = init_line_levels(chip)) < 0) 61 - return err; 62 - 63 60 DE_INIT(("init_hw done\n")); 64 61 return err; 62 + } 63 + 64 + 65 + 66 + static int set_mixer_defaults(struct echoaudio *chip) 67 + { 68 + return init_line_levels(chip); 65 69 } 66 70 67 71
+1 -1
sound/pci/echoaudio/darla24.c
··· 67 67 {0, "darla24_dsp.fw"} 68 68 }; 69 69 70 - static struct pci_device_id snd_echo_ids[] = { 70 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 71 71 {0x1057, 0x1801, 0xECC0, 0x0040, 0, 0, 0}, /* DSP 56301 Darla24 rev.0 */ 72 72 {0x1057, 0x1801, 0xECC0, 0x0041, 0, 0, 0}, /* DSP 56301 Darla24 rev.1 */ 73 73 {0,}
+8 -4
sound/pci/echoaudio/darla24_dsp.c
··· 45 45 chip->device_id = device_id; 46 46 chip->subdevice_id = subdevice_id; 47 47 chip->bad_board = TRUE; 48 - chip->dsp_code_to_load = &card_fw[FW_DARLA24_DSP]; 48 + chip->dsp_code_to_load = FW_DARLA24_DSP; 49 49 /* Since this card has no ASIC, mark it as loaded so everything 50 50 works OK */ 51 51 chip->asic_loaded = TRUE; ··· 56 56 return err; 57 57 chip->bad_board = FALSE; 58 58 59 - if ((err = init_line_levels(chip)) < 0) 60 - return err; 61 - 62 59 DE_INIT(("init_hw done\n")); 63 60 return err; 61 + } 62 + 63 + 64 + 65 + static int set_mixer_defaults(struct echoaudio *chip) 66 + { 67 + return init_line_levels(chip); 64 68 } 65 69 66 70
+1 -1
sound/pci/echoaudio/echo3g.c
··· 81 81 {0, "3g_asic.fw"} 82 82 }; 83 83 84 - static struct pci_device_id snd_echo_ids[] = { 84 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 85 85 {0x1057, 0x3410, 0xECC0, 0x0100, 0, 0, 0}, /* Echo 3G */ 86 86 {0,} 87 87 };
+13 -15
sound/pci/echoaudio/echo3g_dsp.c
··· 61 61 chip->subdevice_id = subdevice_id; 62 62 chip->bad_board = TRUE; 63 63 chip->has_midi = TRUE; 64 - chip->dsp_code_to_load = &card_fw[FW_ECHO3G_DSP]; 64 + chip->dsp_code_to_load = FW_ECHO3G_DSP; 65 65 66 66 /* Load the DSP code and the ASIC on the PCI card and get 67 67 what type of external box is attached */ ··· 97 97 chip->digital_modes = ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | 98 98 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | 99 99 ECHOCAPS_HAS_DIGITAL_MODE_ADAT; 100 - chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; 101 - chip->professional_spdif = FALSE; 102 - chip->non_audio_spdif = FALSE; 103 - chip->bad_board = FALSE; 104 - 105 - if ((err = init_line_levels(chip)) < 0) 106 - return err; 107 - err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 108 - if (err < 0) 109 - return err; 110 - err = set_phantom_power(chip, 0); 111 - if (err < 0) 112 - return err; 113 - err = set_professional_spdif(chip, TRUE); 114 100 115 101 DE_INIT(("init_hw done\n")); 116 102 return err; 103 + } 104 + 105 + 106 + 107 + static int set_mixer_defaults(struct echoaudio *chip) 108 + { 109 + chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; 110 + chip->professional_spdif = FALSE; 111 + chip->non_audio_spdif = FALSE; 112 + chip->bad_board = FALSE; 113 + chip->phantom_power = FALSE; 114 + return init_line_levels(chip); 117 115 } 118 116 119 117
+182 -19
sound/pci/echoaudio/echoaudio.c
··· 36 36 static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999}; 37 37 static const DECLARE_TLV_DB_SCALE(db_scale_output_gain, -12800, 100, 1); 38 38 39 + 40 + 39 41 static int get_firmware(const struct firmware **fw_entry, 40 - const struct firmware *frm, struct echoaudio *chip) 42 + struct echoaudio *chip, const short fw_index) 41 43 { 42 44 int err; 43 45 char name[30]; 44 - DE_ACT(("firmware requested: %s\n", frm->data)); 45 - snprintf(name, sizeof(name), "ea/%s", frm->data); 46 - if ((err = request_firmware(fw_entry, name, pci_device(chip))) < 0) 46 + 47 + #ifdef CONFIG_PM 48 + if (chip->fw_cache[fw_index]) { 49 + DE_ACT(("firmware requested: %s is cached\n", card_fw[fw_index].data)); 50 + *fw_entry = chip->fw_cache[fw_index]; 51 + return 0; 52 + } 53 + #endif 54 + 55 + DE_ACT(("firmware requested: %s\n", card_fw[fw_index].data)); 56 + snprintf(name, sizeof(name), "ea/%s", card_fw[fw_index].data); 57 + err = request_firmware(fw_entry, name, pci_device(chip)); 58 + if (err < 0) 47 59 snd_printk(KERN_ERR "get_firmware(): Firmware not available (%d)\n", err); 60 + #ifdef CONFIG_PM 61 + else 62 + chip->fw_cache[fw_index] = *fw_entry; 63 + #endif 48 64 return err; 49 65 } 50 66 67 + 68 + 51 69 static void free_firmware(const struct firmware *fw_entry) 52 70 { 71 + #ifdef CONFIG_PM 72 + DE_ACT(("firmware not released (kept in cache)\n")); 73 + #else 53 74 release_firmware(fw_entry); 54 75 DE_ACT(("firmware released\n")); 76 + #endif 77 + } 78 + 79 + 80 + 81 + static void free_firmware_cache(struct echoaudio *chip) 82 + { 83 + #ifdef CONFIG_PM 84 + int i; 85 + 86 + for (i = 0; i < 8 ; i++) 87 + if (chip->fw_cache[i]) { 88 + release_firmware(chip->fw_cache[i]); 89 + DE_ACT(("release_firmware(%d)\n", i)); 90 + } 91 + 92 + DE_ACT(("firmware_cache released\n")); 93 + #endif 55 94 } 56 95 57 96 ··· 753 714 754 715 spin_lock(&chip->lock); 755 716 switch (cmd) { 717 + case SNDRV_PCM_TRIGGER_RESUME: 718 + DE_ACT(("pcm_trigger resume\n")); 756 719 case SNDRV_PCM_TRIGGER_START: 757 720 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 758 721 DE_ACT(("pcm_trigger start\n")); ··· 778 737 err = start_transport(chip, channelmask, 779 738 chip->pipe_cyclic_mask); 780 739 break; 740 + case SNDRV_PCM_TRIGGER_SUSPEND: 741 + DE_ACT(("pcm_trigger suspend\n")); 781 742 case SNDRV_PCM_TRIGGER_STOP: 782 743 DE_ACT(("pcm_trigger stop\n")); 783 744 for (i = 0; i < DSP_MAXPIPES; i++) { ··· 1919 1876 pci_disable_device(chip->pci); 1920 1877 1921 1878 /* release chip data */ 1879 + free_firmware_cache(chip); 1922 1880 kfree(chip); 1923 1881 DE_INIT(("Chip freed.\n")); 1924 1882 return 0; ··· 1957 1913 return err; 1958 1914 pci_set_master(pci); 1959 1915 1960 - /* allocate a chip-specific data */ 1961 - chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1962 - if (!chip) { 1963 - pci_disable_device(pci); 1964 - return -ENOMEM; 1916 + /* Allocate chip if needed */ 1917 + if (!*rchip) { 1918 + chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1919 + if (!chip) { 1920 + pci_disable_device(pci); 1921 + return -ENOMEM; 1922 + } 1923 + DE_INIT(("chip=%p\n", chip)); 1924 + spin_lock_init(&chip->lock); 1925 + chip->card = card; 1926 + chip->pci = pci; 1927 + chip->irq = -1; 1928 + atomic_set(&chip->opencount, 0); 1929 + mutex_init(&chip->mode_mutex); 1930 + chip->can_set_rate = 1; 1931 + } else { 1932 + /* If this was called from the resume function, chip is 1933 + * already allocated and it contains current card settings. 1934 + */ 1935 + chip = *rchip; 1965 1936 } 1966 - DE_INIT(("chip=%p\n", chip)); 1967 - 1968 - spin_lock_init(&chip->lock); 1969 - chip->card = card; 1970 - chip->pci = pci; 1971 - chip->irq = -1; 1972 1937 1973 1938 /* PCI resource allocation */ 1974 1939 chip->dsp_registers_phys = pci_resource_start(pci, 0); ··· 2017 1964 chip->comm_page = (struct comm_page *)chip->commpage_dma_buf.area; 2018 1965 2019 1966 err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); 2020 - if (err) { 1967 + if (err >= 0) 1968 + err = set_mixer_defaults(chip); 1969 + if (err < 0) { 2021 1970 DE_INIT(("init_hw err=%d\n", err)); 2022 1971 snd_echo_free(chip); 2023 1972 return err; ··· 2030 1975 snd_echo_free(chip); 2031 1976 return err; 2032 1977 } 2033 - atomic_set(&chip->opencount, 0); 2034 - mutex_init(&chip->mode_mutex); 2035 - chip->can_set_rate = 1; 2036 1978 *rchip = chip; 2037 1979 /* Init done ! */ 2038 1980 return 0; ··· 2062 2010 2063 2011 snd_card_set_dev(card, &pci->dev); 2064 2012 2013 + chip = NULL; /* Tells snd_echo_create to allocate chip */ 2065 2014 if ((err = snd_echo_create(card, pci, &chip)) < 0) { 2066 2015 snd_card_free(card); 2067 2016 return err; ··· 2202 2149 2203 2150 2204 2151 2152 + #if defined(CONFIG_PM) 2153 + 2154 + static int snd_echo_suspend(struct pci_dev *pci, pm_message_t state) 2155 + { 2156 + struct echoaudio *chip = pci_get_drvdata(pci); 2157 + 2158 + DE_INIT(("suspend start\n")); 2159 + snd_pcm_suspend_all(chip->analog_pcm); 2160 + snd_pcm_suspend_all(chip->digital_pcm); 2161 + 2162 + #ifdef ECHOCARD_HAS_MIDI 2163 + /* This call can sleep */ 2164 + if (chip->midi_out) 2165 + snd_echo_midi_output_trigger(chip->midi_out, 0); 2166 + #endif 2167 + spin_lock_irq(&chip->lock); 2168 + if (wait_handshake(chip)) { 2169 + spin_unlock_irq(&chip->lock); 2170 + return -EIO; 2171 + } 2172 + clear_handshake(chip); 2173 + if (send_vector(chip, DSP_VC_GO_COMATOSE) < 0) { 2174 + spin_unlock_irq(&chip->lock); 2175 + return -EIO; 2176 + } 2177 + spin_unlock_irq(&chip->lock); 2178 + 2179 + chip->dsp_code = NULL; 2180 + free_irq(chip->irq, chip); 2181 + chip->irq = -1; 2182 + pci_save_state(pci); 2183 + pci_disable_device(pci); 2184 + 2185 + DE_INIT(("suspend done\n")); 2186 + return 0; 2187 + } 2188 + 2189 + 2190 + 2191 + static int snd_echo_resume(struct pci_dev *pci) 2192 + { 2193 + struct echoaudio *chip = pci_get_drvdata(pci); 2194 + struct comm_page *commpage, *commpage_bak; 2195 + u32 pipe_alloc_mask; 2196 + int err; 2197 + 2198 + DE_INIT(("resume start\n")); 2199 + pci_restore_state(pci); 2200 + commpage_bak = kmalloc(sizeof(struct echoaudio), GFP_KERNEL); 2201 + commpage = chip->comm_page; 2202 + memcpy(commpage_bak, commpage, sizeof(struct comm_page)); 2203 + 2204 + err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); 2205 + if (err < 0) { 2206 + kfree(commpage_bak); 2207 + DE_INIT(("resume init_hw err=%d\n", err)); 2208 + snd_echo_free(chip); 2209 + return err; 2210 + } 2211 + DE_INIT(("resume init OK\n")); 2212 + 2213 + /* Temporarily set chip->pipe_alloc_mask=0 otherwise 2214 + * restore_dsp_settings() fails. 2215 + */ 2216 + pipe_alloc_mask = chip->pipe_alloc_mask; 2217 + chip->pipe_alloc_mask = 0; 2218 + err = restore_dsp_rettings(chip); 2219 + chip->pipe_alloc_mask = pipe_alloc_mask; 2220 + if (err < 0) { 2221 + kfree(commpage_bak); 2222 + return err; 2223 + } 2224 + DE_INIT(("resume restore OK\n")); 2225 + 2226 + memcpy(&commpage->audio_format, &commpage_bak->audio_format, 2227 + sizeof(commpage->audio_format)); 2228 + memcpy(&commpage->sglist_addr, &commpage_bak->sglist_addr, 2229 + sizeof(commpage->sglist_addr)); 2230 + memcpy(&commpage->midi_output, &commpage_bak->midi_output, 2231 + sizeof(commpage->midi_output)); 2232 + kfree(commpage_bak); 2233 + 2234 + if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED, 2235 + ECHOCARD_NAME, chip)) { 2236 + snd_echo_free(chip); 2237 + snd_printk(KERN_ERR "cannot grab irq\n"); 2238 + return -EBUSY; 2239 + } 2240 + chip->irq = pci->irq; 2241 + DE_INIT(("resume irq=%d\n", chip->irq)); 2242 + 2243 + #ifdef ECHOCARD_HAS_MIDI 2244 + if (chip->midi_input_enabled) 2245 + enable_midi_input(chip, TRUE); 2246 + if (chip->midi_out) 2247 + snd_echo_midi_output_trigger(chip->midi_out, 1); 2248 + #endif 2249 + 2250 + DE_INIT(("resume done\n")); 2251 + return 0; 2252 + } 2253 + 2254 + #endif /* CONFIG_PM */ 2255 + 2256 + 2257 + 2205 2258 static void __devexit snd_echo_remove(struct pci_dev *pci) 2206 2259 { 2207 2260 struct echoaudio *chip; ··· 2330 2171 .id_table = snd_echo_ids, 2331 2172 .probe = snd_echo_probe, 2332 2173 .remove = __devexit_p(snd_echo_remove), 2174 + #ifdef CONFIG_PM 2175 + .suspend = snd_echo_suspend, 2176 + .resume = snd_echo_resume, 2177 + #endif /* CONFIG_PM */ 2333 2178 }; 2334 2179 2335 2180
+8 -3
sound/pci/echoaudio/echoaudio.h
··· 442 442 u16 device_id, subdevice_id; 443 443 u16 *dsp_code; /* Current DSP code loaded, 444 444 * NULL if nothing loaded */ 445 - const struct firmware *dsp_code_to_load;/* DSP code to load */ 446 - const struct firmware *asic_code; /* Current ASIC code */ 445 + short dsp_code_to_load; /* DSP code to load */ 446 + short asic_code; /* Current ASIC code */ 447 447 u32 comm_page_phys; /* Physical address of the 448 448 * memory seen by DSP */ 449 449 volatile u32 __iomem *dsp_registers; /* DSP's register base */ 450 450 u32 active_mask; /* Chs. active mask or 451 451 * punks out */ 452 + #ifdef CONFIG_PM 453 + const struct firmware *fw_cache[8]; /* Cached firmwares */ 454 + #endif 452 455 453 456 #ifdef ECHOCARD_HAS_MIDI 454 457 u16 mtc_state; /* State for MIDI input parsing state machine */ ··· 467 464 static int wait_handshake(struct echoaudio *chip); 468 465 static int send_vector(struct echoaudio *chip, u32 command); 469 466 static int get_firmware(const struct firmware **fw_entry, 470 - const struct firmware *frm, struct echoaudio *chip); 467 + struct echoaudio *chip, const short fw_index); 471 468 static void free_firmware(const struct firmware *fw_entry); 472 469 473 470 #ifdef ECHOCARD_HAS_MIDI 474 471 static int enable_midi_input(struct echoaudio *chip, char enable); 472 + static void snd_echo_midi_output_trigger( 473 + struct snd_rawmidi_substream *substream, int up); 475 474 static int midi_service_irq(struct echoaudio *chip); 476 475 static int __devinit snd_echo_midi_create(struct snd_card *card, 477 476 struct echoaudio *chip);
+2 -3
sound/pci/echoaudio/echoaudio_3g.c
··· 227 227 /* Give the DSP a few milliseconds to settle down */ 228 228 mdelay(2); 229 229 230 - err = load_asic_generic(chip, DSP_FNC_LOAD_3G_ASIC, 231 - &card_fw[FW_3G_ASIC]); 230 + err = load_asic_generic(chip, DSP_FNC_LOAD_3G_ASIC, FW_3G_ASIC); 232 231 if (err < 0) 233 232 return err; 234 233 235 - chip->asic_code = &card_fw[FW_3G_ASIC]; 234 + chip->asic_code = FW_3G_ASIC; 236 235 237 236 /* Now give the new ASIC some time to set up */ 238 237 msleep(1000);
+92 -71
sound/pci/echoaudio/echoaudio_dsp.c
··· 175 175 #ifdef ECHOCARD_HAS_ASIC 176 176 177 177 /* Load ASIC code - done after the DSP is loaded */ 178 - static int load_asic_generic(struct echoaudio *chip, u32 cmd, 179 - const struct firmware *asic) 178 + static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic) 180 179 { 181 180 const struct firmware *fw; 182 181 int err; 183 182 u32 i, size; 184 183 u8 *code; 185 184 186 - if ((err = get_firmware(&fw, asic, chip)) < 0) { 185 + err = get_firmware(&fw, chip, asic); 186 + if (err < 0) { 187 187 snd_printk(KERN_WARNING "Firmware not found !\n"); 188 188 return err; 189 189 } ··· 245 245 return 0; 246 246 } 247 247 248 - if ((i = get_firmware(&fw, &card_fw[FW_361_LOADER], chip)) < 0) { 248 + i = get_firmware(&fw, chip, FW_361_LOADER); 249 + if (i < 0) { 249 250 snd_printk(KERN_WARNING "Firmware not found !\n"); 250 251 return i; 251 252 } ··· 486 485 chip->dsp_code = NULL; 487 486 } 488 487 489 - if ((err = get_firmware(&fw, chip->dsp_code_to_load, chip)) < 0) 488 + err = get_firmware(&fw, chip, chip->dsp_code_to_load); 489 + if (err < 0) 490 490 return err; 491 491 err = load_dsp(chip, (u16 *)fw->data); 492 492 free_firmware(fw); ··· 496 494 497 495 if ((box_type = load_asic(chip)) < 0) 498 496 return box_type; /* error */ 499 - 500 - if ((err = restore_dsp_rettings(chip)) < 0) 501 - return err; 502 497 503 498 return box_type; 504 499 } ··· 656 657 657 658 static int restore_dsp_rettings(struct echoaudio *chip) 658 659 { 659 - int err; 660 + int i, o, err; 660 661 DE_INIT(("restore_dsp_settings\n")); 661 662 662 663 if ((err = check_asic_status(chip)) < 0) 663 664 return err; 664 665 665 - /* @ Gina20/Darla20 only. Should be harmless for other cards. */ 666 + /* Gina20/Darla20 only. Should be harmless for other cards. */ 666 667 chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF; 667 668 chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF; 668 669 chip->comm_page->handshake = 0xffffffff; 669 670 670 - if ((err = set_sample_rate(chip, chip->sample_rate)) < 0) 671 + /* Restore output busses */ 672 + for (i = 0; i < num_busses_out(chip); i++) { 673 + err = set_output_gain(chip, i, chip->output_gain[i]); 674 + if (err < 0) 675 + return err; 676 + } 677 + 678 + #ifdef ECHOCARD_HAS_VMIXER 679 + for (i = 0; i < num_pipes_out(chip); i++) 680 + for (o = 0; o < num_busses_out(chip); o++) { 681 + err = set_vmixer_gain(chip, o, i, 682 + chip->vmixer_gain[o][i]); 683 + if (err < 0) 684 + return err; 685 + } 686 + if (update_vmixer_level(chip) < 0) 687 + return -EIO; 688 + #endif /* ECHOCARD_HAS_VMIXER */ 689 + 690 + #ifdef ECHOCARD_HAS_MONITOR 691 + for (o = 0; o < num_busses_out(chip); o++) 692 + for (i = 0; i < num_busses_in(chip); i++) { 693 + err = set_monitor_gain(chip, o, i, 694 + chip->monitor_gain[o][i]); 695 + if (err < 0) 696 + return err; 697 + } 698 + #endif /* ECHOCARD_HAS_MONITOR */ 699 + 700 + #ifdef ECHOCARD_HAS_INPUT_GAIN 701 + for (i = 0; i < num_busses_in(chip); i++) { 702 + err = set_input_gain(chip, i, chip->input_gain[i]); 703 + if (err < 0) 704 + return err; 705 + } 706 + #endif /* ECHOCARD_HAS_INPUT_GAIN */ 707 + 708 + err = update_output_line_level(chip); 709 + if (err < 0) 671 710 return err; 672 711 673 - if (chip->meters_enabled) 674 - if (send_vector(chip, DSP_VC_METERS_ON) < 0) 675 - return -EIO; 712 + err = update_input_line_level(chip); 713 + if (err < 0) 714 + return err; 715 + 716 + err = set_sample_rate(chip, chip->sample_rate); 717 + if (err < 0) 718 + return err; 719 + 720 + if (chip->meters_enabled) { 721 + err = send_vector(chip, DSP_VC_METERS_ON); 722 + if (err < 0) 723 + return err; 724 + } 725 + 726 + #ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH 727 + if (set_digital_mode(chip, chip->digital_mode) < 0) 728 + return -EIO; 729 + #endif 730 + 731 + #ifdef ECHOCARD_HAS_DIGITAL_IO 732 + if (set_professional_spdif(chip, chip->professional_spdif) < 0) 733 + return -EIO; 734 + #endif 735 + 736 + #ifdef ECHOCARD_HAS_PHANTOM_POWER 737 + if (set_phantom_power(chip, chip->phantom_power) < 0) 738 + return -EIO; 739 + #endif 676 740 677 741 #ifdef ECHOCARD_HAS_EXTERNAL_CLOCK 742 + /* set_input_clock() also restores automute setting */ 678 743 if (set_input_clock(chip, chip->input_clock) < 0) 679 744 return -EIO; 680 745 #endif ··· 748 685 return -EIO; 749 686 #endif 750 687 751 - if (update_output_line_level(chip) < 0) 752 - return -EIO; 753 - 754 - if (update_input_line_level(chip) < 0) 755 - return -EIO; 756 - 757 - #ifdef ECHOCARD_HAS_VMIXER 758 - if (update_vmixer_level(chip) < 0) 759 - return -EIO; 760 - #endif 761 - 762 688 if (wait_handshake(chip) < 0) 763 689 return -EIO; 764 690 clear_handshake(chip); 691 + if (send_vector(chip, DSP_VC_UPDATE_FLAGS) < 0) 692 + return -EIO; 765 693 766 694 DE_INIT(("restore_dsp_rettings done\n")); 767 - return send_vector(chip, DSP_VC_UPDATE_FLAGS); 695 + return 0; 768 696 } 769 697 770 698 ··· 972 918 chip->card_name = ECHOCARD_NAME; 973 919 chip->bad_board = TRUE; /* Set TRUE until DSP loaded */ 974 920 chip->dsp_code = NULL; /* Current DSP code not loaded */ 975 - chip->digital_mode = DIGITAL_MODE_NONE; 976 - chip->input_clock = ECHO_CLOCK_INTERNAL; 977 - chip->output_clock = ECHO_CLOCK_WORD; 978 921 chip->asic_loaded = FALSE; 979 922 memset(chip->comm_page, 0, sizeof(struct comm_page)); 980 923 ··· 982 931 chip->comm_page->midi_out_free_count = 983 932 cpu_to_le32(DSP_MIDI_OUT_FIFO_SIZE); 984 933 chip->comm_page->sample_rate = cpu_to_le32(44100); 985 - chip->sample_rate = 44100; 986 934 987 935 /* Set line levels so we don't blast any inputs on startup */ 988 936 memset(chip->comm_page->monitors, ECHOGAIN_MUTED, MONITOR_ARRAY_SIZE); ··· 992 942 993 943 994 944 995 - /* This function initializes the several volume controls for busses and pipes. 996 - This MUST be called after the DSP is up and running ! */ 945 + /* This function initializes the chip structure with default values, ie. all 946 + * muted and internal clock source. Then it copies the settings to the DSP. 947 + * This MUST be called after the DSP is up and running ! 948 + */ 997 949 static int init_line_levels(struct echoaudio *chip) 998 950 { 999 - int st, i, o; 1000 - 1001 951 DE_INIT(("init_line_levels\n")); 1002 - 1003 - /* Mute output busses */ 1004 - for (i = 0; i < num_busses_out(chip); i++) 1005 - if ((st = set_output_gain(chip, i, ECHOGAIN_MUTED))) 1006 - return st; 1007 - if ((st = update_output_line_level(chip))) 1008 - return st; 1009 - 1010 - #ifdef ECHOCARD_HAS_VMIXER 1011 - /* Mute the Vmixer */ 1012 - for (i = 0; i < num_pipes_out(chip); i++) 1013 - for (o = 0; o < num_busses_out(chip); o++) 1014 - if ((st = set_vmixer_gain(chip, o, i, ECHOGAIN_MUTED))) 1015 - return st; 1016 - if ((st = update_vmixer_level(chip))) 1017 - return st; 1018 - #endif /* ECHOCARD_HAS_VMIXER */ 1019 - 1020 - #ifdef ECHOCARD_HAS_MONITOR 1021 - /* Mute the monitor mixer */ 1022 - for (o = 0; o < num_busses_out(chip); o++) 1023 - for (i = 0; i < num_busses_in(chip); i++) 1024 - if ((st = set_monitor_gain(chip, o, i, ECHOGAIN_MUTED))) 1025 - return st; 1026 - if ((st = update_output_line_level(chip))) 1027 - return st; 1028 - #endif /* ECHOCARD_HAS_MONITOR */ 1029 - 1030 - #ifdef ECHOCARD_HAS_INPUT_GAIN 1031 - for (i = 0; i < num_busses_in(chip); i++) 1032 - if ((st = set_input_gain(chip, i, ECHOGAIN_MUTED))) 1033 - return st; 1034 - if ((st = update_input_line_level(chip))) 1035 - return st; 1036 - #endif /* ECHOCARD_HAS_INPUT_GAIN */ 1037 - 1038 - return 0; 952 + memset(chip->output_gain, ECHOGAIN_MUTED, sizeof(chip->output_gain)); 953 + memset(chip->input_gain, ECHOGAIN_MUTED, sizeof(chip->input_gain)); 954 + memset(chip->monitor_gain, ECHOGAIN_MUTED, sizeof(chip->monitor_gain)); 955 + memset(chip->vmixer_gain, ECHOGAIN_MUTED, sizeof(chip->vmixer_gain)); 956 + chip->input_clock = ECHO_CLOCK_INTERNAL; 957 + chip->output_clock = ECHO_CLOCK_WORD; 958 + chip->sample_rate = 44100; 959 + return restore_dsp_rettings(chip); 1039 960 } 1040 961 1041 962
+1 -1
sound/pci/echoaudio/gina20.c
··· 67 67 {0, "gina20_dsp.fw"} 68 68 }; 69 69 70 - static struct pci_device_id snd_echo_ids[] = { 70 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 71 71 {0x1057, 0x1801, 0xECC0, 0x0020, 0, 0, 0}, /* DSP 56301 Gina20 rev.0 */ 72 72 {0,} 73 73 };
+9 -6
sound/pci/echoaudio/gina20_dsp.c
··· 49 49 chip->device_id = device_id; 50 50 chip->subdevice_id = subdevice_id; 51 51 chip->bad_board = TRUE; 52 - chip->dsp_code_to_load = &card_fw[FW_GINA20_DSP]; 52 + chip->dsp_code_to_load = FW_GINA20_DSP; 53 53 chip->spdif_status = GD_SPDIF_STATUS_UNDEF; 54 54 chip->clock_state = GD_CLOCK_UNDEF; 55 55 /* Since this card has no ASIC, mark it as loaded so everything ··· 62 62 return err; 63 63 chip->bad_board = FALSE; 64 64 65 - if ((err = init_line_levels(chip)) < 0) 66 - return err; 67 - 68 - err = set_professional_spdif(chip, TRUE); 69 - 70 65 DE_INIT(("init_hw done\n")); 71 66 return err; 67 + } 68 + 69 + 70 + 71 + static int set_mixer_defaults(struct echoaudio *chip) 72 + { 73 + chip->professional_spdif = FALSE; 74 + return init_line_levels(chip); 72 75 } 73 76 74 77
+1 -1
sound/pci/echoaudio/gina24.c
··· 85 85 {0, "gina24_361_asic.fw"} 86 86 }; 87 87 88 - static struct pci_device_id snd_echo_ids[] = { 88 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 89 89 {0x1057, 0x1801, 0xECC0, 0x0050, 0, 0, 0}, /* DSP 56301 Gina24 rev.0 */ 90 90 {0x1057, 0x1801, 0xECC0, 0x0051, 0, 0, 0}, /* DSP 56301 Gina24 rev.1 */ 91 91 {0x1057, 0x3410, 0xECC0, 0x0050, 0, 0, 0}, /* DSP 56361 Gina24 rev.0 */
+19 -19
sound/pci/echoaudio/gina24_dsp.c
··· 33 33 static int set_input_clock(struct echoaudio *chip, u16 clock); 34 34 static int set_professional_spdif(struct echoaudio *chip, char prof); 35 35 static int set_digital_mode(struct echoaudio *chip, u8 mode); 36 - static int load_asic_generic(struct echoaudio *chip, u32 cmd, 37 - const struct firmware *asic); 36 + static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic); 38 37 static int check_asic_status(struct echoaudio *chip); 39 38 40 39 ··· 57 58 ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF | 58 59 ECHO_CLOCK_BIT_ESYNC | ECHO_CLOCK_BIT_ESYNC96 | 59 60 ECHO_CLOCK_BIT_ADAT; 60 - chip->professional_spdif = FALSE; 61 - chip->digital_in_automute = TRUE; 62 - chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; 63 61 64 62 /* Gina24 comes in both '301 and '361 flavors */ 65 63 if (chip->device_id == DEVICE_ID_56361) { 66 - chip->dsp_code_to_load = &card_fw[FW_GINA24_361_DSP]; 64 + chip->dsp_code_to_load = FW_GINA24_361_DSP; 67 65 chip->digital_modes = 68 66 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | 69 67 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | 70 68 ECHOCAPS_HAS_DIGITAL_MODE_ADAT; 71 69 } else { 72 - chip->dsp_code_to_load = &card_fw[FW_GINA24_301_DSP]; 70 + chip->dsp_code_to_load = FW_GINA24_301_DSP; 73 71 chip->digital_modes = 74 72 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | 75 73 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | ··· 78 82 return err; 79 83 chip->bad_board = FALSE; 80 84 81 - if ((err = init_line_levels(chip)) < 0) 82 - return err; 83 - err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 84 - if (err < 0) 85 - return err; 86 - err = set_professional_spdif(chip, TRUE); 87 - 88 85 DE_INIT(("init_hw done\n")); 89 86 return err; 87 + } 88 + 89 + 90 + 91 + static int set_mixer_defaults(struct echoaudio *chip) 92 + { 93 + chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; 94 + chip->professional_spdif = FALSE; 95 + chip->digital_in_automute = TRUE; 96 + return init_line_levels(chip); 90 97 } 91 98 92 99 ··· 124 125 { 125 126 u32 control_reg; 126 127 int err; 127 - const struct firmware *fw; 128 + short asic; 128 129 129 130 if (chip->asic_loaded) 130 131 return 1; ··· 134 135 135 136 /* Pick the correct ASIC for '301 or '361 Gina24 */ 136 137 if (chip->device_id == DEVICE_ID_56361) 137 - fw = &card_fw[FW_GINA24_361_ASIC]; 138 + asic = FW_GINA24_361_ASIC; 138 139 else 139 - fw = &card_fw[FW_GINA24_301_ASIC]; 140 + asic = FW_GINA24_301_ASIC; 140 141 141 - if ((err = load_asic_generic(chip, DSP_FNC_LOAD_GINA24_ASIC, fw)) < 0) 142 + err = load_asic_generic(chip, DSP_FNC_LOAD_GINA24_ASIC, asic); 143 + if (err < 0) 142 144 return err; 143 145 144 - chip->asic_code = fw; 146 + chip->asic_code = asic; 145 147 146 148 /* Now give the new ASIC a little time to set up */ 147 149 mdelay(10);
+1 -1
sound/pci/echoaudio/indigo.c
··· 68 68 {0, "indigo_dsp.fw"} 69 69 }; 70 70 71 - static struct pci_device_id snd_echo_ids[] = { 71 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 72 72 {0x1057, 0x3410, 0xECC0, 0x0090, 0, 0, 0}, /* Indigo */ 73 73 {0,} 74 74 };
+8 -4
sound/pci/echoaudio/indigo_dsp.c
··· 50 50 chip->device_id = device_id; 51 51 chip->subdevice_id = subdevice_id; 52 52 chip->bad_board = TRUE; 53 - chip->dsp_code_to_load = &card_fw[FW_INDIGO_DSP]; 53 + chip->dsp_code_to_load = FW_INDIGO_DSP; 54 54 /* Since this card has no ASIC, mark it as loaded so everything 55 55 works OK */ 56 56 chip->asic_loaded = TRUE; ··· 60 60 return err; 61 61 chip->bad_board = FALSE; 62 62 63 - if ((err = init_line_levels(chip)) < 0) 64 - return err; 65 - 66 63 DE_INIT(("init_hw done\n")); 67 64 return err; 65 + } 66 + 67 + 68 + 69 + static int set_mixer_defaults(struct echoaudio *chip) 70 + { 71 + return init_line_levels(chip); 68 72 } 69 73 70 74
+1
sound/pci/echoaudio/indigo_express_dsp.c
··· 61 61 62 62 control_reg |= clock; 63 63 if (control_reg != old_control_reg) { 64 + DE_ACT(("set_sample_rate: %d clock %d\n", rate, clock)); 64 65 chip->comm_page->control_register = cpu_to_le32(control_reg); 65 66 chip->sample_rate = rate; 66 67 clear_handshake(chip);
+1 -1
sound/pci/echoaudio/indigodj.c
··· 68 68 {0, "indigo_dj_dsp.fw"} 69 69 }; 70 70 71 - static struct pci_device_id snd_echo_ids[] = { 71 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 72 72 {0x1057, 0x3410, 0xECC0, 0x00B0, 0, 0, 0}, /* Indigo DJ*/ 73 73 {0,} 74 74 };
+8 -4
sound/pci/echoaudio/indigodj_dsp.c
··· 50 50 chip->device_id = device_id; 51 51 chip->subdevice_id = subdevice_id; 52 52 chip->bad_board = TRUE; 53 - chip->dsp_code_to_load = &card_fw[FW_INDIGO_DJ_DSP]; 53 + chip->dsp_code_to_load = FW_INDIGO_DJ_DSP; 54 54 /* Since this card has no ASIC, mark it as loaded so everything 55 55 works OK */ 56 56 chip->asic_loaded = TRUE; ··· 60 60 return err; 61 61 chip->bad_board = FALSE; 62 62 63 - if ((err = init_line_levels(chip)) < 0) 64 - return err; 65 - 66 63 DE_INIT(("init_hw done\n")); 67 64 return err; 65 + } 66 + 67 + 68 + 69 + static int set_mixer_defaults(struct echoaudio *chip) 70 + { 71 + return init_line_levels(chip); 68 72 } 69 73 70 74
+1 -1
sound/pci/echoaudio/indigodjx.c
··· 68 68 {0, "indigo_djx_dsp.fw"} 69 69 }; 70 70 71 - static struct pci_device_id snd_echo_ids[] = { 71 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 72 72 {0x1057, 0x3410, 0xECC0, 0x00E0, 0, 0, 0}, /* Indigo DJx*/ 73 73 {0,} 74 74 };
+8 -5
sound/pci/echoaudio/indigodjx_dsp.c
··· 48 48 chip->device_id = device_id; 49 49 chip->subdevice_id = subdevice_id; 50 50 chip->bad_board = TRUE; 51 - chip->dsp_code_to_load = &card_fw[FW_INDIGO_DJX_DSP]; 51 + chip->dsp_code_to_load = FW_INDIGO_DJX_DSP; 52 52 /* Since this card has no ASIC, mark it as loaded so everything 53 53 works OK */ 54 54 chip->asic_loaded = TRUE; ··· 59 59 return err; 60 60 chip->bad_board = FALSE; 61 61 62 - err = init_line_levels(chip); 63 - if (err < 0) 64 - return err; 65 - 66 62 DE_INIT(("init_hw done\n")); 67 63 return err; 64 + } 65 + 66 + 67 + 68 + static int set_mixer_defaults(struct echoaudio *chip) 69 + { 70 + return init_line_levels(chip); 68 71 }
+1 -1
sound/pci/echoaudio/indigoio.c
··· 69 69 {0, "indigo_io_dsp.fw"} 70 70 }; 71 71 72 - static struct pci_device_id snd_echo_ids[] = { 72 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 73 73 {0x1057, 0x3410, 0xECC0, 0x00A0, 0, 0, 0}, /* Indigo IO*/ 74 74 {0,} 75 75 };
+8 -4
sound/pci/echoaudio/indigoio_dsp.c
··· 50 50 chip->device_id = device_id; 51 51 chip->subdevice_id = subdevice_id; 52 52 chip->bad_board = TRUE; 53 - chip->dsp_code_to_load = &card_fw[FW_INDIGO_IO_DSP]; 53 + chip->dsp_code_to_load = FW_INDIGO_IO_DSP; 54 54 /* Since this card has no ASIC, mark it as loaded so everything 55 55 works OK */ 56 56 chip->asic_loaded = TRUE; ··· 60 60 return err; 61 61 chip->bad_board = FALSE; 62 62 63 - if ((err = init_line_levels(chip)) < 0) 64 - return err; 65 - 66 63 DE_INIT(("init_hw done\n")); 67 64 return err; 65 + } 66 + 67 + 68 + 69 + static int set_mixer_defaults(struct echoaudio *chip) 70 + { 71 + return init_line_levels(chip); 68 72 } 69 73 70 74
+1 -1
sound/pci/echoaudio/indigoiox.c
··· 69 69 {0, "indigo_iox_dsp.fw"} 70 70 }; 71 71 72 - static struct pci_device_id snd_echo_ids[] = { 72 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 73 73 {0x1057, 0x3410, 0xECC0, 0x00D0, 0, 0, 0}, /* Indigo IOx */ 74 74 {0,} 75 75 };
+8 -5
sound/pci/echoaudio/indigoiox_dsp.c
··· 48 48 chip->device_id = device_id; 49 49 chip->subdevice_id = subdevice_id; 50 50 chip->bad_board = TRUE; 51 - chip->dsp_code_to_load = &card_fw[FW_INDIGO_IOX_DSP]; 51 + chip->dsp_code_to_load = FW_INDIGO_IOX_DSP; 52 52 /* Since this card has no ASIC, mark it as loaded so everything 53 53 works OK */ 54 54 chip->asic_loaded = TRUE; ··· 59 59 return err; 60 60 chip->bad_board = FALSE; 61 61 62 - err = init_line_levels(chip); 63 - if (err < 0) 64 - return err; 65 - 66 62 DE_INIT(("init_hw done\n")); 67 63 return err; 64 + } 65 + 66 + 67 + 68 + static int set_mixer_defaults(struct echoaudio *chip) 69 + { 70 + return init_line_levels(chip); 68 71 }
+1 -1
sound/pci/echoaudio/layla20.c
··· 76 76 {0, "layla20_asic.fw"} 77 77 }; 78 78 79 - static struct pci_device_id snd_echo_ids[] = { 79 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 80 80 {0x1057, 0x1801, 0xECC0, 0x0030, 0, 0, 0}, /* DSP 56301 Layla20 rev.0 */ 81 81 {0x1057, 0x1801, 0xECC0, 0x0031, 0, 0, 0}, /* DSP 56301 Layla20 rev.1 */ 82 82 {0,}
+11 -9
sound/pci/echoaudio/layla20_dsp.c
··· 31 31 32 32 static int read_dsp(struct echoaudio *chip, u32 *data); 33 33 static int set_professional_spdif(struct echoaudio *chip, char prof); 34 - static int load_asic_generic(struct echoaudio *chip, u32 cmd, 35 - const struct firmware *asic); 34 + static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic); 36 35 static int check_asic_status(struct echoaudio *chip); 37 36 static int update_flags(struct echoaudio *chip); 38 37 ··· 53 54 chip->subdevice_id = subdevice_id; 54 55 chip->bad_board = TRUE; 55 56 chip->has_midi = TRUE; 56 - chip->dsp_code_to_load = &card_fw[FW_LAYLA20_DSP]; 57 + chip->dsp_code_to_load = FW_LAYLA20_DSP; 57 58 chip->input_clock_types = 58 59 ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF | 59 60 ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_SUPER; ··· 64 65 return err; 65 66 chip->bad_board = FALSE; 66 67 67 - if ((err = init_line_levels(chip)) < 0) 68 - return err; 69 - 70 - err = set_professional_spdif(chip, TRUE); 71 - 72 68 DE_INIT(("init_hw done\n")); 73 69 return err; 70 + } 71 + 72 + 73 + 74 + static int set_mixer_defaults(struct echoaudio *chip) 75 + { 76 + chip->professional_spdif = FALSE; 77 + return init_line_levels(chip); 74 78 } 75 79 76 80 ··· 146 144 return 0; 147 145 148 146 err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA_ASIC, 149 - &card_fw[FW_LAYLA20_ASIC]); 147 + FW_LAYLA20_ASIC); 150 148 if (err < 0) 151 149 return err; 152 150
+1 -1
sound/pci/echoaudio/layla24.c
··· 87 87 {0, "layla24_2S_asic.fw"} 88 88 }; 89 89 90 - static struct pci_device_id snd_echo_ids[] = { 90 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 91 91 {0x1057, 0x3410, 0xECC0, 0x0060, 0, 0, 0}, /* DSP 56361 Layla24 rev.0 */ 92 92 {0,} 93 93 };
+19 -18
sound/pci/echoaudio/layla24_dsp.c
··· 32 32 static int set_input_clock(struct echoaudio *chip, u16 clock); 33 33 static int set_professional_spdif(struct echoaudio *chip, char prof); 34 34 static int set_digital_mode(struct echoaudio *chip, u8 mode); 35 - static int load_asic_generic(struct echoaudio *chip, u32 cmd, 36 - const struct firmware *asic); 35 + static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic); 37 36 static int check_asic_status(struct echoaudio *chip); 38 37 39 38 ··· 53 54 chip->subdevice_id = subdevice_id; 54 55 chip->bad_board = TRUE; 55 56 chip->has_midi = TRUE; 56 - chip->dsp_code_to_load = &card_fw[FW_LAYLA24_DSP]; 57 + chip->dsp_code_to_load = FW_LAYLA24_DSP; 57 58 chip->input_clock_types = 58 59 ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF | 59 60 ECHO_CLOCK_BIT_WORD | ECHO_CLOCK_BIT_ADAT; ··· 61 62 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | 62 63 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | 63 64 ECHOCAPS_HAS_DIGITAL_MODE_ADAT; 64 - chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; 65 - chip->professional_spdif = FALSE; 66 - chip->digital_in_automute = TRUE; 67 65 68 66 if ((err = load_firmware(chip)) < 0) 69 67 return err; ··· 69 73 if ((err = init_line_levels(chip)) < 0) 70 74 return err; 71 75 72 - err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 73 - if (err < 0) 74 - return err; 75 - err = set_professional_spdif(chip, TRUE); 76 - 77 76 DE_INIT(("init_hw done\n")); 78 77 return err; 78 + } 79 + 80 + 81 + 82 + static int set_mixer_defaults(struct echoaudio *chip) 83 + { 84 + chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; 85 + chip->professional_spdif = FALSE; 86 + chip->digital_in_automute = TRUE; 87 + return init_line_levels(chip); 79 88 } 80 89 81 90 ··· 124 123 125 124 /* Load the ASIC for the PCI card */ 126 125 err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA24_PCI_CARD_ASIC, 127 - &card_fw[FW_LAYLA24_1_ASIC]); 126 + FW_LAYLA24_1_ASIC); 128 127 if (err < 0) 129 128 return err; 130 129 131 - chip->asic_code = &card_fw[FW_LAYLA24_2S_ASIC]; 130 + chip->asic_code = FW_LAYLA24_2S_ASIC; 132 131 133 132 /* Now give the new ASIC a little time to set up */ 134 133 mdelay(10); 135 134 136 135 /* Do the external one */ 137 136 err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA24_EXTERNAL_ASIC, 138 - &card_fw[FW_LAYLA24_2S_ASIC]); 137 + FW_LAYLA24_2S_ASIC); 139 138 if (err < 0) 140 139 return FALSE; 141 140 ··· 300 299 /* Depending on what digital mode you want, Layla24 needs different ASICs 301 300 loaded. This function checks the ASIC needed for the new mode and sees 302 301 if it matches the one already loaded. */ 303 - static int switch_asic(struct echoaudio *chip, const struct firmware *asic) 302 + static int switch_asic(struct echoaudio *chip, short asic) 304 303 { 305 304 s8 *monitors; 306 305 ··· 336 335 { 337 336 u32 control_reg; 338 337 int err, incompatible_clock; 339 - const struct firmware *asic; 338 + short asic; 340 339 341 340 /* Set clock to "internal" if it's not compatible with the new mode */ 342 341 incompatible_clock = FALSE; ··· 345 344 case DIGITAL_MODE_SPDIF_RCA: 346 345 if (chip->input_clock == ECHO_CLOCK_ADAT) 347 346 incompatible_clock = TRUE; 348 - asic = &card_fw[FW_LAYLA24_2S_ASIC]; 347 + asic = FW_LAYLA24_2S_ASIC; 349 348 break; 350 349 case DIGITAL_MODE_ADAT: 351 350 if (chip->input_clock == ECHO_CLOCK_SPDIF) 352 351 incompatible_clock = TRUE; 353 - asic = &card_fw[FW_LAYLA24_2A_ASIC]; 352 + asic = FW_LAYLA24_2A_ASIC; 354 353 break; 355 354 default: 356 355 DE_ACT(("Digital mode not supported: %d\n", mode));
+1 -1
sound/pci/echoaudio/mia.c
··· 77 77 {0, "mia_dsp.fw"} 78 78 }; 79 79 80 - static struct pci_device_id snd_echo_ids[] = { 80 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 81 81 {0x1057, 0x3410, 0xECC0, 0x0080, 0, 0, 0}, /* DSP 56361 Mia rev.0 */ 82 82 {0x1057, 0x3410, 0xECC0, 0x0081, 0, 0, 0}, /* DSP 56361 Mia rev.1 */ 83 83 {0,}
+8 -4
sound/pci/echoaudio/mia_dsp.c
··· 53 53 chip->device_id = device_id; 54 54 chip->subdevice_id = subdevice_id; 55 55 chip->bad_board = TRUE; 56 - chip->dsp_code_to_load = &card_fw[FW_MIA_DSP]; 56 + chip->dsp_code_to_load = FW_MIA_DSP; 57 57 /* Since this card has no ASIC, mark it as loaded so everything 58 58 works OK */ 59 59 chip->asic_loaded = TRUE; ··· 66 66 return err; 67 67 chip->bad_board = FALSE; 68 68 69 - if ((err = init_line_levels(chip))) 70 - return err; 71 - 72 69 DE_INIT(("init_hw done\n")); 73 70 return err; 71 + } 72 + 73 + 74 + 75 + static int set_mixer_defaults(struct echoaudio *chip) 76 + { 77 + return init_line_levels(chip); 74 78 } 75 79 76 80
+1 -1
sound/pci/echoaudio/mona.c
··· 92 92 {0, "mona_2_asic.fw"} 93 93 }; 94 94 95 - static struct pci_device_id snd_echo_ids[] = { 95 + static DEFINE_PCI_DEVICE_TABLE(snd_echo_ids) = { 96 96 {0x1057, 0x1801, 0xECC0, 0x0070, 0, 0, 0}, /* DSP 56301 Mona rev.0 */ 97 97 {0x1057, 0x1801, 0xECC0, 0x0071, 0, 0, 0}, /* DSP 56301 Mona rev.1 */ 98 98 {0x1057, 0x1801, 0xECC0, 0x0072, 0, 0, 0}, /* DSP 56301 Mona rev.2 */
+29 -32
sound/pci/echoaudio/mona_dsp.c
··· 33 33 static int set_input_clock(struct echoaudio *chip, u16 clock); 34 34 static int set_professional_spdif(struct echoaudio *chip, char prof); 35 35 static int set_digital_mode(struct echoaudio *chip, u8 mode); 36 - static int load_asic_generic(struct echoaudio *chip, u32 cmd, 37 - const struct firmware *asic); 36 + static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic); 38 37 static int check_asic_status(struct echoaudio *chip); 39 38 40 39 ··· 63 64 64 65 /* Mona comes in both '301 and '361 flavors */ 65 66 if (chip->device_id == DEVICE_ID_56361) 66 - chip->dsp_code_to_load = &card_fw[FW_MONA_361_DSP]; 67 + chip->dsp_code_to_load = FW_MONA_361_DSP; 67 68 else 68 - chip->dsp_code_to_load = &card_fw[FW_MONA_301_DSP]; 69 - 70 - chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; 71 - chip->professional_spdif = FALSE; 72 - chip->digital_in_automute = TRUE; 69 + chip->dsp_code_to_load = FW_MONA_301_DSP; 73 70 74 71 if ((err = load_firmware(chip)) < 0) 75 72 return err; 76 73 chip->bad_board = FALSE; 77 74 78 - if ((err = init_line_levels(chip)) < 0) 79 - return err; 80 - 81 - err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA); 82 - if (err < 0) 83 - return err; 84 - err = set_professional_spdif(chip, TRUE); 85 - 86 75 DE_INIT(("init_hw done\n")); 87 76 return err; 77 + } 78 + 79 + 80 + 81 + static int set_mixer_defaults(struct echoaudio *chip) 82 + { 83 + chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; 84 + chip->professional_spdif = FALSE; 85 + chip->digital_in_automute = TRUE; 86 + return init_line_levels(chip); 88 87 } 89 88 90 89 ··· 117 120 { 118 121 u32 control_reg; 119 122 int err; 120 - const struct firmware *asic; 123 + short asic; 121 124 122 125 if (chip->asic_loaded) 123 126 return 0; ··· 125 128 mdelay(10); 126 129 127 130 if (chip->device_id == DEVICE_ID_56361) 128 - asic = &card_fw[FW_MONA_361_1_ASIC48]; 131 + asic = FW_MONA_361_1_ASIC48; 129 132 else 130 - asic = &card_fw[FW_MONA_301_1_ASIC48]; 133 + asic = FW_MONA_301_1_ASIC48; 131 134 132 135 err = load_asic_generic(chip, DSP_FNC_LOAD_MONA_PCI_CARD_ASIC, asic); 133 136 if (err < 0) ··· 138 141 139 142 /* Do the external one */ 140 143 err = load_asic_generic(chip, DSP_FNC_LOAD_MONA_EXTERNAL_ASIC, 141 - &card_fw[FW_MONA_2_ASIC]); 144 + FW_MONA_2_ASIC); 142 145 if (err < 0) 143 146 return err; 144 147 ··· 162 165 if it matches the one already loaded. */ 163 166 static int switch_asic(struct echoaudio *chip, char double_speed) 164 167 { 165 - const struct firmware *asic; 166 168 int err; 169 + short asic; 167 170 168 171 /* Check the clock detect bits to see if this is 169 172 a single-speed clock or a double-speed clock; load 170 173 a new ASIC if necessary. */ 171 174 if (chip->device_id == DEVICE_ID_56361) { 172 175 if (double_speed) 173 - asic = &card_fw[FW_MONA_361_1_ASIC96]; 176 + asic = FW_MONA_361_1_ASIC96; 174 177 else 175 - asic = &card_fw[FW_MONA_361_1_ASIC48]; 178 + asic = FW_MONA_361_1_ASIC48; 176 179 } else { 177 180 if (double_speed) 178 - asic = &card_fw[FW_MONA_301_1_ASIC96]; 181 + asic = FW_MONA_301_1_ASIC96; 179 182 else 180 - asic = &card_fw[FW_MONA_301_1_ASIC48]; 183 + asic = FW_MONA_301_1_ASIC48; 181 184 } 182 185 183 186 if (asic != chip->asic_code) { ··· 197 200 static int set_sample_rate(struct echoaudio *chip, u32 rate) 198 201 { 199 202 u32 control_reg, clock; 200 - const struct firmware *asic; 203 + short asic; 201 204 char force_write; 202 205 203 206 /* Only set the clock for internal mode. */ ··· 215 218 if (chip->digital_mode == DIGITAL_MODE_ADAT) 216 219 return -EINVAL; 217 220 if (chip->device_id == DEVICE_ID_56361) 218 - asic = &card_fw[FW_MONA_361_1_ASIC96]; 221 + asic = FW_MONA_361_1_ASIC96; 219 222 else 220 - asic = &card_fw[FW_MONA_301_1_ASIC96]; 223 + asic = FW_MONA_301_1_ASIC96; 221 224 } else { 222 225 if (chip->device_id == DEVICE_ID_56361) 223 - asic = &card_fw[FW_MONA_361_1_ASIC48]; 226 + asic = FW_MONA_361_1_ASIC48; 224 227 else 225 - asic = &card_fw[FW_MONA_301_1_ASIC48]; 228 + asic = FW_MONA_301_1_ASIC48; 226 229 } 227 230 228 231 force_write = 0; ··· 407 410 case DIGITAL_MODE_ADAT: 408 411 /* If the current ASIC is the 96KHz ASIC, switch the ASIC 409 412 and set to 48 KHz */ 410 - if (chip->asic_code == &card_fw[FW_MONA_361_1_ASIC96] || 411 - chip->asic_code == &card_fw[FW_MONA_301_1_ASIC96]) { 413 + if (chip->asic_code == FW_MONA_361_1_ASIC96 || 414 + chip->asic_code == FW_MONA_301_1_ASIC96) { 412 415 set_sample_rate(chip, 48000); 413 416 } 414 417 control_reg |= GML_ADAT_MODE;
+1 -1
sound/pci/emu10k1/emu10k1.c
··· 76 76 /* 77 77 * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value Model:SB0400 78 78 */ 79 - static struct pci_device_id snd_emu10k1_ids[] = { 79 + static DEFINE_PCI_DEVICE_TABLE(snd_emu10k1_ids) = { 80 80 { PCI_VDEVICE(CREATIVE, 0x0002), 0 }, /* EMU10K1 */ 81 81 { PCI_VDEVICE(CREATIVE, 0x0004), 1 }, /* Audigy */ 82 82 { PCI_VDEVICE(CREATIVE, 0x0008), 1 }, /* Audigy 2 Value SB0400 */
+1 -1
sound/pci/emu10k1/emu10k1x.c
··· 1605 1605 } 1606 1606 1607 1607 // PCI IDs 1608 - static struct pci_device_id snd_emu10k1x_ids[] = { 1608 + static DEFINE_PCI_DEVICE_TABLE(snd_emu10k1x_ids) = { 1609 1609 { PCI_VDEVICE(CREATIVE, 0x0006), 0 }, /* Dell OEM version (EMU10K1) */ 1610 1610 { 0, } 1611 1611 };
+1 -1
sound/pci/ens1370.c
··· 443 443 444 444 static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id); 445 445 446 - static struct pci_device_id snd_audiopci_ids[] = { 446 + static DEFINE_PCI_DEVICE_TABLE(snd_audiopci_ids) = { 447 447 #ifdef CHIP1370 448 448 { PCI_VDEVICE(ENSONIQ, 0x5000), 0, }, /* ES1370 */ 449 449 #endif
+1 -1
sound/pci/es1938.c
··· 243 243 244 244 static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id); 245 245 246 - static struct pci_device_id snd_es1938_ids[] = { 246 + static DEFINE_PCI_DEVICE_TABLE(snd_es1938_ids) = { 247 247 { PCI_VDEVICE(ESS, 0x1969), 0, }, /* Solo-1 */ 248 248 { 0, } 249 249 };
+1 -1
sound/pci/es1968.c
··· 551 551 552 552 static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id); 553 553 554 - static struct pci_device_id snd_es1968_ids[] = { 554 + static DEFINE_PCI_DEVICE_TABLE(snd_es1968_ids) = { 555 555 /* Maestro 1 */ 556 556 { 0x1285, 0x0100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, TYPE_MAESTRO }, 557 557 /* Maestro 2 */
+1 -1
sound/pci/fm801.c
··· 205 205 #endif 206 206 }; 207 207 208 - static struct pci_device_id snd_fm801_ids[] = { 208 + static DEFINE_PCI_DEVICE_TABLE(snd_fm801_ids) = { 209 209 { 0x1319, 0x0801, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* FM801 */ 210 210 { 0x5213, 0x0510, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* Gallant Odyssey Sound 4 */ 211 211 { 0, }
+69 -6
sound/pci/hda/hda_codec.c
··· 824 824 struct hda_pincfg *pin; 825 825 unsigned int oldcfg; 826 826 827 + if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 828 + return -EINVAL; 829 + 827 830 oldcfg = snd_hda_codec_get_pincfg(codec, nid); 828 831 pin = look_up_pincfg(codec, list, nid); 829 832 if (!pin) { ··· 902 899 } 903 900 } 904 901 902 + /** 903 + * snd_hda_shutup_pins - Shut up all pins 904 + * @codec: the HDA codec 905 + * 906 + * Clear all pin controls to shup up before suspend for avoiding click noise. 907 + * The controls aren't cached so that they can be resumed properly. 908 + */ 909 + void snd_hda_shutup_pins(struct hda_codec *codec) 910 + { 911 + int i; 912 + for (i = 0; i < codec->init_pins.used; i++) { 913 + struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); 914 + /* use read here for syncing after issuing each verb */ 915 + snd_hda_codec_read(codec, pin->nid, 0, 916 + AC_VERB_SET_PIN_WIDGET_CONTROL, 0); 917 + } 918 + } 919 + EXPORT_SYMBOL_HDA(snd_hda_shutup_pins); 920 + 905 921 static void init_hda_cache(struct hda_cache_rec *cache, 906 922 unsigned int record_size); 907 923 static void free_hda_cache(struct hda_cache_rec *cache); ··· 953 931 #endif 954 932 list_del(&codec->list); 955 933 snd_array_free(&codec->mixers); 934 + snd_array_free(&codec->nids); 956 935 codec->bus->caddr_tbl[codec->addr] = NULL; 957 936 if (codec->patch_ops.free) 958 937 codec->patch_ops.free(codec); ··· 1008 985 mutex_init(&codec->control_mutex); 1009 986 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); 1010 987 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); 1011 - snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 60); 988 + snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32); 989 + snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32); 1012 990 snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); 1013 991 snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); 1014 992 if (codec->bus->modelname) { ··· 1732 1708 EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl); 1733 1709 1734 1710 /** 1735 - * snd_hda_ctl-add - Add a control element and assign to the codec 1711 + * snd_hda_ctl_add - Add a control element and assign to the codec 1736 1712 * @codec: HD-audio codec 1737 1713 * @nid: corresponding NID (optional) 1738 1714 * @kctl: the control element to assign ··· 1747 1723 * 1748 1724 * snd_hda_ctl_add() checks the control subdev id field whether 1749 1725 * #HDA_SUBDEV_NID_FLAG bit is set. If set (and @nid is zero), the lower 1750 - * bits value is taken as the NID to assign. 1726 + * bits value is taken as the NID to assign. The #HDA_NID_ITEM_AMP bit 1727 + * specifies if kctl->private_value is a HDA amplifier value. 1751 1728 */ 1752 1729 int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, 1753 1730 struct snd_kcontrol *kctl) 1754 1731 { 1755 1732 int err; 1733 + unsigned short flags = 0; 1756 1734 struct hda_nid_item *item; 1757 1735 1758 - if (kctl->id.subdevice & HDA_SUBDEV_NID_FLAG) { 1736 + if (kctl->id.subdevice & HDA_SUBDEV_AMP_FLAG) { 1737 + flags |= HDA_NID_ITEM_AMP; 1759 1738 if (nid == 0) 1760 - nid = kctl->id.subdevice & 0xffff; 1761 - kctl->id.subdevice = 0; 1739 + nid = get_amp_nid_(kctl->private_value); 1762 1740 } 1741 + if ((kctl->id.subdevice & HDA_SUBDEV_NID_FLAG) != 0 && nid == 0) 1742 + nid = kctl->id.subdevice & 0xffff; 1743 + if (kctl->id.subdevice & (HDA_SUBDEV_NID_FLAG|HDA_SUBDEV_AMP_FLAG)) 1744 + kctl->id.subdevice = 0; 1763 1745 err = snd_ctl_add(codec->bus->card, kctl); 1764 1746 if (err < 0) 1765 1747 return err; ··· 1774 1744 return -ENOMEM; 1775 1745 item->kctl = kctl; 1776 1746 item->nid = nid; 1747 + item->flags = flags; 1777 1748 return 0; 1778 1749 } 1779 1750 EXPORT_SYMBOL_HDA(snd_hda_ctl_add); 1751 + 1752 + /** 1753 + * snd_hda_add_nid - Assign a NID to a control element 1754 + * @codec: HD-audio codec 1755 + * @nid: corresponding NID (optional) 1756 + * @kctl: the control element to assign 1757 + * @index: index to kctl 1758 + * 1759 + * Add the given control element to an array inside the codec instance. 1760 + * This function is used when #snd_hda_ctl_add cannot be used for 1:1 1761 + * NID:KCTL mapping - for example "Capture Source" selector. 1762 + */ 1763 + int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl, 1764 + unsigned int index, hda_nid_t nid) 1765 + { 1766 + struct hda_nid_item *item; 1767 + 1768 + if (nid > 0) { 1769 + item = snd_array_new(&codec->nids); 1770 + if (!item) 1771 + return -ENOMEM; 1772 + item->kctl = kctl; 1773 + item->index = index; 1774 + item->nid = nid; 1775 + return 0; 1776 + } 1777 + return -EINVAL; 1778 + } 1779 + EXPORT_SYMBOL_HDA(snd_hda_add_nid); 1780 1780 1781 1781 /** 1782 1782 * snd_hda_ctls_clear - Clear all controls assigned to the given codec ··· 1819 1759 for (i = 0; i < codec->mixers.used; i++) 1820 1760 snd_ctl_remove(codec->bus->card, items[i].kctl); 1821 1761 snd_array_free(&codec->mixers); 1762 + snd_array_free(&codec->nids); 1822 1763 } 1823 1764 1824 1765 /* pseudo device locking ··· 3539 3478 3540 3479 for (; knew->name; knew++) { 3541 3480 struct snd_kcontrol *kctl; 3481 + if (knew->iface == -1) /* skip this codec private value */ 3482 + continue; 3542 3483 kctl = snd_ctl_new1(knew, codec); 3543 3484 if (!kctl) 3544 3485 return -ENOMEM;
+2
sound/pci/hda/hda_codec.h
··· 789 789 u32 *wcaps; 790 790 791 791 struct snd_array mixers; /* list of assigned mixer elements */ 792 + struct snd_array nids; /* list of mapped mixer elements */ 792 793 793 794 struct hda_cache_rec amp_cache; /* cache for amp access */ 794 795 struct hda_cache_rec cmd_cache; /* cache for other commands */ ··· 899 898 unsigned int cfg); 900 899 int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list, 901 900 hda_nid_t nid, unsigned int cfg); /* for hwdep */ 901 + void snd_hda_shutup_pins(struct hda_codec *codec); 902 902 903 903 /* 904 904 * Mixer
+2 -1
sound/pci/hda/hda_generic.c
··· 861 861 } 862 862 863 863 /* create input MUX if multiple sources are available */ 864 - err = snd_hda_ctl_add(codec, 0, snd_ctl_new1(&cap_sel, codec)); 864 + err = snd_hda_ctl_add(codec, spec->adc_node->nid, 865 + snd_ctl_new1(&cap_sel, codec)); 865 866 if (err < 0) 866 867 return err; 867 868
+5 -2
sound/pci/hda/hda_hwdep.c
··· 293 293 { \ 294 294 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \ 295 295 struct hda_codec *codec = hwdep->private_data; \ 296 - char *after; \ 297 - codec->type = simple_strtoul(buf, &after, 0); \ 296 + unsigned long val; \ 297 + int err = strict_strtoul(buf, 0, &val); \ 298 + if (err < 0) \ 299 + return err; \ 300 + codec->type = val; \ 298 301 return count; \ 299 302 } 300 303
+5 -27
sound/pci/hda/hda_intel.c
··· 2683 2683 } 2684 2684 2685 2685 /* PCI IDs */ 2686 - static struct pci_device_id azx_ids[] = { 2686 + static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { 2687 2687 /* ICH 6..10 */ 2688 2688 { PCI_DEVICE(0x8086, 0x2668), .driver_data = AZX_DRIVER_ICH }, 2689 2689 { PCI_DEVICE(0x8086, 0x27d8), .driver_data = AZX_DRIVER_ICH }, ··· 2723 2723 /* ULI M5461 */ 2724 2724 { PCI_DEVICE(0x10b9, 0x5461), .driver_data = AZX_DRIVER_ULI }, 2725 2725 /* NVIDIA MCP */ 2726 - { PCI_DEVICE(0x10de, 0x026c), .driver_data = AZX_DRIVER_NVIDIA }, 2727 - { PCI_DEVICE(0x10de, 0x0371), .driver_data = AZX_DRIVER_NVIDIA }, 2728 - { PCI_DEVICE(0x10de, 0x03e4), .driver_data = AZX_DRIVER_NVIDIA }, 2729 - { PCI_DEVICE(0x10de, 0x03f0), .driver_data = AZX_DRIVER_NVIDIA }, 2730 - { PCI_DEVICE(0x10de, 0x044a), .driver_data = AZX_DRIVER_NVIDIA }, 2731 - { PCI_DEVICE(0x10de, 0x044b), .driver_data = AZX_DRIVER_NVIDIA }, 2732 - { PCI_DEVICE(0x10de, 0x055c), .driver_data = AZX_DRIVER_NVIDIA }, 2733 - { PCI_DEVICE(0x10de, 0x055d), .driver_data = AZX_DRIVER_NVIDIA }, 2734 - { PCI_DEVICE(0x10de, 0x0590), .driver_data = AZX_DRIVER_NVIDIA }, 2735 - { PCI_DEVICE(0x10de, 0x0774), .driver_data = AZX_DRIVER_NVIDIA }, 2736 - { PCI_DEVICE(0x10de, 0x0775), .driver_data = AZX_DRIVER_NVIDIA }, 2737 - { PCI_DEVICE(0x10de, 0x0776), .driver_data = AZX_DRIVER_NVIDIA }, 2738 - { PCI_DEVICE(0x10de, 0x0777), .driver_data = AZX_DRIVER_NVIDIA }, 2739 - { PCI_DEVICE(0x10de, 0x07fc), .driver_data = AZX_DRIVER_NVIDIA }, 2740 - { PCI_DEVICE(0x10de, 0x07fd), .driver_data = AZX_DRIVER_NVIDIA }, 2741 - { PCI_DEVICE(0x10de, 0x0ac0), .driver_data = AZX_DRIVER_NVIDIA }, 2742 - { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA }, 2743 - { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA }, 2744 - { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA }, 2745 - { PCI_DEVICE(0x10de, 0x0be2), .driver_data = AZX_DRIVER_NVIDIA }, 2746 - { PCI_DEVICE(0x10de, 0x0be3), .driver_data = AZX_DRIVER_NVIDIA }, 2747 - { PCI_DEVICE(0x10de, 0x0be4), .driver_data = AZX_DRIVER_NVIDIA }, 2748 - { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA }, 2749 - { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA }, 2750 - { PCI_DEVICE(0x10de, 0x0d96), .driver_data = AZX_DRIVER_NVIDIA }, 2751 - { PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA }, 2726 + { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID), 2727 + .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2728 + .class_mask = 0xffffff, 2729 + .driver_data = AZX_DRIVER_NVIDIA }, 2752 2730 /* Teradici */ 2753 2731 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, 2754 2732 /* Creative X-Fi (CA0110-IBG) */
+11 -3
sound/pci/hda/hda_local.h
··· 31 31 * in snd_hda_ctl_add(), so that this value won't appear in the outside. 32 32 */ 33 33 #define HDA_SUBDEV_NID_FLAG (1U << 31) 34 + #define HDA_SUBDEV_AMP_FLAG (1U << 30) 34 35 35 36 /* 36 37 * for mixer controls ··· 43 42 /* mono volume with index (index=0,1,...) (channel=1,2) */ 44 43 #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ 45 44 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ 46 - .subdevice = HDA_SUBDEV_NID_FLAG | (nid), \ 45 + .subdevice = HDA_SUBDEV_AMP_FLAG, \ 47 46 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ 48 47 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ 49 48 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ ··· 64 63 /* mono mute switch with index (index=0,1,...) (channel=1,2) */ 65 64 #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ 66 65 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ 67 - .subdevice = HDA_SUBDEV_NID_FLAG | (nid), \ 66 + .subdevice = HDA_SUBDEV_AMP_FLAG, \ 68 67 .info = snd_hda_mixer_amp_switch_info, \ 69 68 .get = snd_hda_mixer_amp_switch_get, \ 70 69 .put = snd_hda_mixer_amp_switch_put, \ ··· 82 81 /* special beep mono mute switch with index (index=0,1,...) (channel=1,2) */ 83 82 #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ 84 83 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ 85 - .subdevice = HDA_SUBDEV_NID_FLAG | (nid), \ 84 + .subdevice = HDA_SUBDEV_AMP_FLAG, \ 86 85 .info = snd_hda_mixer_amp_switch_info, \ 87 86 .get = snd_hda_mixer_amp_switch_get, \ 88 87 .put = snd_hda_mixer_amp_switch_put_beep, \ ··· 465 464 u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid); 466 465 int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid); 467 466 467 + /* flags for hda_nid_item */ 468 + #define HDA_NID_ITEM_AMP (1<<0) 469 + 468 470 struct hda_nid_item { 469 471 struct snd_kcontrol *kctl; 472 + unsigned int index; 470 473 hda_nid_t nid; 474 + unsigned short flags; 471 475 }; 472 476 473 477 int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, 474 478 struct snd_kcontrol *kctl); 479 + int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl, 480 + unsigned int index, hda_nid_t nid); 475 481 void snd_hda_ctls_clear(struct hda_codec *codec); 476 482 477 483 /*
+22 -9
sound/pci/hda/hda_proc.c
··· 61 61 return "UNKNOWN Widget"; 62 62 } 63 63 64 - static void print_nid_mixers(struct snd_info_buffer *buffer, 65 - struct hda_codec *codec, hda_nid_t nid) 64 + static void print_nid_array(struct snd_info_buffer *buffer, 65 + struct hda_codec *codec, hda_nid_t nid, 66 + struct snd_array *array) 66 67 { 67 68 int i; 68 - struct hda_nid_item *items = codec->mixers.list; 69 + struct hda_nid_item *items = array->list, *item; 69 70 struct snd_kcontrol *kctl; 70 - for (i = 0; i < codec->mixers.used; i++) { 71 - if (items[i].nid == nid) { 72 - kctl = items[i].kctl; 71 + for (i = 0; i < array->used; i++) { 72 + item = &items[i]; 73 + if (item->nid == nid) { 74 + kctl = item->kctl; 73 75 snd_iprintf(buffer, 74 76 " Control: name=\"%s\", index=%i, device=%i\n", 75 - kctl->id.name, kctl->id.index, kctl->id.device); 77 + kctl->id.name, kctl->id.index + item->index, 78 + kctl->id.device); 79 + if (item->flags & HDA_NID_ITEM_AMP) 80 + snd_iprintf(buffer, 81 + " ControlAmp: chs=%lu, dir=%s, " 82 + "idx=%lu, ofs=%lu\n", 83 + get_amp_channels(kctl), 84 + get_amp_direction(kctl) ? "Out" : "In", 85 + get_amp_index(kctl), 86 + get_amp_offset(kctl)); 76 87 } 77 88 } 78 89 } ··· 539 528 (data & (1<<i)) ? 1 : 0, 540 529 (unsol & (1<<i)) ? 1 : 0); 541 530 /* FIXME: add GPO and GPI pin information */ 542 - print_nid_mixers(buffer, codec, nid); 531 + print_nid_array(buffer, codec, nid, &codec->mixers); 532 + print_nid_array(buffer, codec, nid, &codec->nids); 543 533 } 544 534 545 535 static void print_codec_info(struct snd_info_entry *entry, ··· 620 608 snd_iprintf(buffer, " CP"); 621 609 snd_iprintf(buffer, "\n"); 622 610 623 - print_nid_mixers(buffer, codec, nid); 611 + print_nid_array(buffer, codec, nid, &codec->mixers); 612 + print_nid_array(buffer, codec, nid, &codec->nids); 624 613 print_nid_pcms(buffer, codec, nid); 625 614 626 615 /* volume knob is a special widget that always have connection
+110 -5
sound/pci/hda/patch_analog.c
··· 174 174 static int ad198x_build_controls(struct hda_codec *codec) 175 175 { 176 176 struct ad198x_spec *spec = codec->spec; 177 + struct snd_kcontrol *kctl; 177 178 unsigned int i; 178 179 int err; 179 180 ··· 209 208 if (!kctl) 210 209 return -ENOMEM; 211 210 kctl->private_value = spec->beep_amp; 212 - err = snd_hda_ctl_add(codec, 213 - get_amp_nid_(spec->beep_amp), 214 - kctl); 211 + err = snd_hda_ctl_add(codec, 0, kctl); 215 212 if (err < 0) 216 213 return err; 217 214 } ··· 238 239 } 239 240 240 241 ad198x_free_kctls(codec); /* no longer needed */ 242 + 243 + /* assign Capture Source enums to NID */ 244 + kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); 245 + if (!kctl) 246 + kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); 247 + for (i = 0; kctl && i < kctl->count; i++) { 248 + err = snd_hda_add_nid(codec, kctl, i, spec->capsrc_nids[i]); 249 + if (err < 0) 250 + return err; 251 + } 252 + 253 + /* assign IEC958 enums to NID */ 254 + kctl = snd_hda_find_mixer_ctl(codec, 255 + SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source"); 256 + if (kctl) { 257 + err = snd_hda_add_nid(codec, kctl, 0, 258 + spec->multiout.dig_out_nid); 259 + if (err < 0) 260 + return err; 261 + } 262 + 241 263 return 0; 242 264 } 243 265 ··· 441 421 return 0; 442 422 } 443 423 424 + static inline void ad198x_shutup(struct hda_codec *codec) 425 + { 426 + snd_hda_shutup_pins(codec); 427 + } 428 + 444 429 static void ad198x_free_kctls(struct hda_codec *codec) 445 430 { 446 431 struct ad198x_spec *spec = codec->spec; ··· 459 434 snd_array_free(&spec->kctls); 460 435 } 461 436 437 + static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front, 438 + hda_nid_t hp) 439 + { 440 + struct ad198x_spec *spec = codec->spec; 441 + snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE, 442 + !spec->inv_eapd ? 0x00 : 0x02); 443 + snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE, 444 + !spec->inv_eapd ? 0x00 : 0x02); 445 + } 446 + 447 + static void ad198x_power_eapd(struct hda_codec *codec) 448 + { 449 + /* We currently only handle front, HP */ 450 + switch (codec->vendor_id) { 451 + case 0x11d41882: 452 + case 0x11d4882a: 453 + case 0x11d41884: 454 + case 0x11d41984: 455 + case 0x11d41883: 456 + case 0x11d4184a: 457 + case 0x11d4194a: 458 + case 0x11d4194b: 459 + ad198x_power_eapd_write(codec, 0x12, 0x11); 460 + break; 461 + case 0x11d41981: 462 + case 0x11d41983: 463 + ad198x_power_eapd_write(codec, 0x05, 0x06); 464 + break; 465 + case 0x11d41986: 466 + ad198x_power_eapd_write(codec, 0x1b, 0x1a); 467 + break; 468 + case 0x11d41988: 469 + case 0x11d4198b: 470 + case 0x11d4989a: 471 + case 0x11d4989b: 472 + ad198x_power_eapd_write(codec, 0x29, 0x22); 473 + break; 474 + } 475 + } 476 + 462 477 static void ad198x_free(struct hda_codec *codec) 463 478 { 464 479 struct ad198x_spec *spec = codec->spec; ··· 506 441 if (!spec) 507 442 return; 508 443 444 + ad198x_shutup(codec); 509 445 ad198x_free_kctls(codec); 510 446 kfree(spec); 511 447 snd_hda_detach_beep_device(codec); 512 448 } 449 + 450 + #ifdef SND_HDA_NEEDS_RESUME 451 + static int ad198x_suspend(struct hda_codec *codec, pm_message_t state) 452 + { 453 + ad198x_shutup(codec); 454 + ad198x_power_eapd(codec); 455 + return 0; 456 + } 457 + 458 + static int ad198x_resume(struct hda_codec *codec) 459 + { 460 + ad198x_init(codec); 461 + snd_hda_codec_resume_amp(codec); 462 + snd_hda_codec_resume_cache(codec); 463 + return 0; 464 + } 465 + #endif 513 466 514 467 static struct hda_codec_ops ad198x_patch_ops = { 515 468 .build_controls = ad198x_build_controls, ··· 537 454 #ifdef CONFIG_SND_HDA_POWER_SAVE 538 455 .check_power_status = ad198x_check_power_status, 539 456 #endif 457 + #ifdef SND_HDA_NEEDS_RESUME 458 + .suspend = ad198x_suspend, 459 + .resume = ad198x_resume, 460 + #endif 461 + .reboot_notify = ad198x_shutup, 540 462 }; 541 463 542 464 ··· 789 701 { 790 702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 791 703 .name = "External Amplifier", 704 + .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b, 792 705 .info = ad198x_eapd_info, 793 706 .get = ad198x_eapd_get, 794 707 .put = ad198x_eapd_put, ··· 897 808 { 898 809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 899 810 .name = "Master Playback Switch", 811 + .subdevice = HDA_SUBDEV_AMP_FLAG, 900 812 .info = snd_hda_mixer_amp_switch_info, 901 813 .get = snd_hda_mixer_amp_switch_get, 902 814 .put = ad1986a_hp_master_sw_put, ··· 1702 1612 HDA_BIND_VOL("Master Playback Volume", &ad1981_hp_bind_master_vol), 1703 1613 { 1704 1614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1615 + .subdevice = HDA_SUBDEV_NID_FLAG | 0x05, 1705 1616 .name = "Master Playback Switch", 1706 1617 .info = ad198x_eapd_info, 1707 1618 .get = ad198x_eapd_get, ··· 2227 2136 { 2228 2137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2229 2138 .name = "External Amplifier", 2139 + .subdevice = HDA_SUBDEV_NID_FLAG | 0x12, 2230 2140 .info = ad198x_eapd_info, 2231 2141 .get = ad198x_eapd_get, 2232 2142 .put = ad198x_eapd_put, ··· 2349 2257 { 2350 2258 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2351 2259 .name = "IEC958 Playback Source", 2260 + .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b, 2352 2261 .info = ad1988_spdif_playback_source_info, 2353 2262 .get = ad1988_spdif_playback_source_get, 2354 2263 .put = ad1988_spdif_playback_source_put, ··· 2462 2369 /* SPDIF out pin */ 2463 2370 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ 2464 2371 2372 + { } 2373 + }; 2374 + 2375 + static struct hda_verb ad1988_spdif_in_init_verbs[] = { 2376 + /* unmute SPDIF input pin */ 2377 + {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2465 2378 { } 2466 2379 }; 2467 2380 ··· 2688 2589 if (! knew->name) 2689 2590 return -ENOMEM; 2690 2591 if (get_amp_nid_(val)) 2691 - knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); 2592 + knew->subdevice = HDA_SUBDEV_AMP_FLAG; 2692 2593 knew->private_value = val; 2693 2594 return 0; 2694 2595 } ··· 3206 3107 ad1988_spdif_init_verbs; 3207 3108 } 3208 3109 } 3209 - if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a) 3110 + if (spec->dig_in_nid && codec->vendor_id < 0x11d4989a) { 3210 3111 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; 3112 + spec->init_verbs[spec->num_init_verbs++] = 3113 + ad1988_spdif_in_init_verbs; 3114 + } 3211 3115 3212 3116 codec->patch_ops = ad198x_patch_ops; 3213 3117 switch (board_config) { ··· 3849 3747 { 3850 3748 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3851 3749 .name = "Master Playback Switch", 3750 + .subdevice = HDA_SUBDEV_AMP_FLAG, 3852 3751 .info = snd_hda_mixer_amp_switch_info, 3853 3752 .get = snd_hda_mixer_amp_switch_get, 3854 3753 .put = ad1884a_mobile_master_sw_put, ··· 3878 3775 { 3879 3776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3880 3777 .name = "Master Playback Switch", 3778 + .subdevice = HDA_SUBDEV_AMP_FLAG, 3881 3779 .info = snd_hda_mixer_amp_switch_info, 3882 3780 .get = snd_hda_mixer_amp_switch_get, 3883 3781 .put = ad1884a_mobile_master_sw_put, ··· 4220 4116 /* HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),*/ 4221 4117 { 4222 4118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4119 + .subdevice = HDA_SUBDEV_AMP_FLAG, 4223 4120 .name = "Master Playback Switch", 4224 4121 .info = snd_hda_mixer_amp_switch_info, 4225 4122 .get = snd_hda_mixer_amp_switch_get,
+12 -2
sound/pci/hda/patch_cirrus.c
··· 501 501 knew.private_value = pval; 502 502 snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]); 503 503 *kctlp = snd_ctl_new1(&knew, codec); 504 - return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp); 504 + (*kctlp)->id.subdevice = HDA_SUBDEV_AMP_FLAG; 505 + return snd_hda_ctl_add(codec, 0, *kctlp); 505 506 } 506 507 507 508 static int add_volume(struct hda_codec *codec, const char *name, ··· 515 514 knew.private_value = pval; 516 515 snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]); 517 516 *kctlp = snd_ctl_new1(&knew, codec); 518 - return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp); 517 + (*kctlp)->id.subdevice = HDA_SUBDEV_AMP_FLAG; 518 + return snd_hda_ctl_add(codec, 0, *kctlp); 519 519 } 520 520 521 521 static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) ··· 753 751 spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol); 754 752 for (i = 0; i < 2; i++) { 755 753 struct snd_kcontrol *kctl; 754 + int n; 756 755 if (!spec->capture_bind[i]) 757 756 return -ENOMEM; 758 757 kctl = snd_ctl_new1(&cs_capture_ctls[i], codec); ··· 763 760 err = snd_hda_ctl_add(codec, 0, kctl); 764 761 if (err < 0) 765 762 return err; 763 + for (n = 0; n < AUTO_PIN_LAST; n++) { 764 + if (!spec->adc_nid[n]) 765 + continue; 766 + err = snd_hda_add_nid(codec, kctl, 0, spec->adc_nid[i]); 767 + if (err < 0) 768 + return err; 769 + } 766 770 } 767 771 768 772 if (spec->num_inputs > 1 && !spec->mic_detect) {
+10 -1
sound/pci/hda/patch_cmedia.c
··· 315 315 static int cmi9880_build_controls(struct hda_codec *codec) 316 316 { 317 317 struct cmi_spec *spec = codec->spec; 318 - int err; 318 + struct snd_kcontrol *kctl; 319 + int i, err; 319 320 320 321 err = snd_hda_add_new_ctls(codec, cmi9880_basic_mixer); 321 322 if (err < 0) ··· 338 337 } 339 338 if (spec->dig_in_nid) { 340 339 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 340 + if (err < 0) 341 + return err; 342 + } 343 + 344 + /* assign Capture Source enums to NID */ 345 + kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); 346 + for (i = 0; kctl && i < kctl->count; i++) { 347 + err = snd_hda_add_nid(codec, kctl, i, spec->adc_nids[i]); 341 348 if (err < 0) 342 349 return err; 343 350 }
+324 -61
sound/pci/hda/patch_conexant.c
··· 111 111 112 112 unsigned int dell_automute; 113 113 unsigned int port_d_mode; 114 - unsigned char ext_mic_bias; 115 114 unsigned int dell_vostro; 115 + 116 + unsigned int ext_mic_present; 117 + unsigned int recording; 118 + void (*capture_prepare)(struct hda_codec *codec); 119 + void (*capture_cleanup)(struct hda_codec *codec); 120 + 121 + /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors) 122 + * through the microphone jack. 123 + * When the user enables this through a mixer switch, both internal and 124 + * external microphones are disabled. Gain is fixed at 0dB. In this mode, 125 + * we also allow the bias to be configured through a separate mixer 126 + * control. */ 127 + unsigned int dc_enable; 128 + unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ 129 + unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ 116 130 }; 117 131 118 132 static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, ··· 199 185 struct snd_pcm_substream *substream) 200 186 { 201 187 struct conexant_spec *spec = codec->spec; 188 + if (spec->capture_prepare) 189 + spec->capture_prepare(codec); 202 190 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 203 191 stream_tag, 0, format); 204 192 return 0; ··· 212 196 { 213 197 struct conexant_spec *spec = codec->spec; 214 198 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); 199 + if (spec->capture_cleanup) 200 + spec->capture_cleanup(codec); 215 201 return 0; 216 202 } 217 203 ··· 1741 1723 {} 1742 1724 }; 1743 1725 1726 + static struct snd_kcontrol_new cxt5051_f700_mixers[] = { 1727 + HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x01, HDA_INPUT), 1728 + HDA_CODEC_MUTE("Mic Switch", 0x14, 0x01, HDA_INPUT), 1729 + HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT), 1730 + { 1731 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1732 + .name = "Master Playback Switch", 1733 + .info = cxt_eapd_info, 1734 + .get = cxt_eapd_get, 1735 + .put = cxt5051_hp_master_sw_put, 1736 + .private_value = 0x1a, 1737 + }, 1738 + 1739 + {} 1740 + }; 1741 + 1744 1742 static struct hda_verb cxt5051_init_verbs[] = { 1745 1743 /* Line in, Mic */ 1746 1744 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, ··· 1847 1813 { } /* end */ 1848 1814 }; 1849 1815 1816 + static struct hda_verb cxt5051_f700_init_verbs[] = { 1817 + /* Line in, Mic */ 1818 + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x03}, 1819 + {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1820 + {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1821 + {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0}, 1822 + /* SPK */ 1823 + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1824 + {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 1825 + /* HP, Amp */ 1826 + {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1827 + {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, 1828 + /* DAC1 */ 1829 + {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1830 + /* Record selector: Int mic */ 1831 + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44}, 1832 + {0x14, AC_VERB_SET_CONNECT_SEL, 0x1}, 1833 + /* SPDIF route: PCM */ 1834 + {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0}, 1835 + /* EAPD */ 1836 + {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 1837 + {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT}, 1838 + {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT}, 1839 + { } /* end */ 1840 + }; 1841 + 1850 1842 /* initialize jack-sensing, too */ 1851 1843 static int cxt5051_init(struct hda_codec *codec) 1852 1844 { ··· 1892 1832 CXT5051_HP, /* no docking */ 1893 1833 CXT5051_HP_DV6736, /* HP without mic switch */ 1894 1834 CXT5051_LENOVO_X200, /* Lenovo X200 laptop */ 1835 + CXT5051_F700, /* HP Compaq Presario F700 */ 1895 1836 CXT5051_MODELS 1896 1837 }; 1897 1838 ··· 1901 1840 [CXT5051_HP] = "hp", 1902 1841 [CXT5051_HP_DV6736] = "hp-dv6736", 1903 1842 [CXT5051_LENOVO_X200] = "lenovo-x200", 1843 + [CXT5051_F700] = "hp 700" 1904 1844 }; 1905 1845 1906 1846 static struct snd_pci_quirk cxt5051_cfg_tbl[] = { ··· 1911 1849 CXT5051_LAPTOP), 1912 1850 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), 1913 1851 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200), 1852 + SND_PCI_QUIRK(0x103c, 0x30ea, "Compaq Presario F700", CXT5051_F700), 1914 1853 {} 1915 1854 }; 1916 1855 ··· 1961 1898 break; 1962 1899 case CXT5051_LENOVO_X200: 1963 1900 spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs; 1901 + break; 1902 + case CXT5051_F700: 1903 + spec->init_verbs[0] = cxt5051_f700_init_verbs; 1904 + spec->mixers[0] = cxt5051_f700_mixers; 1905 + spec->no_auto_mic = 1; 1964 1906 break; 1965 1907 } 1966 1908 ··· 2034 1966 return 1; 2035 1967 } 2036 1968 2037 - /* toggle input of built-in and mic jack appropriately */ 2038 - static void cxt5066_automic(struct hda_codec *codec) 1969 + static const struct hda_input_mux cxt5066_olpc_dc_bias = { 1970 + .num_items = 3, 1971 + .items = { 1972 + { "Off", PIN_IN }, 1973 + { "50%", PIN_VREF50 }, 1974 + { "80%", PIN_VREF80 }, 1975 + }, 1976 + }; 1977 + 1978 + static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec) 2039 1979 { 2040 1980 struct conexant_spec *spec = codec->spec; 2041 - struct hda_verb ext_mic_present[] = { 2042 - /* enable external mic, port B */ 2043 - {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, spec->ext_mic_bias}, 1981 + /* Even though port F is the DC input, the bias is controlled on port B. 1982 + * we also leave that port as an active input (but unselected) in DC mode 1983 + * just in case that is necessary to make the bias setting take effect. */ 1984 + return snd_hda_codec_write_cache(codec, 0x1a, 0, 1985 + AC_VERB_SET_PIN_WIDGET_CONTROL, 1986 + cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index); 1987 + } 2044 1988 2045 - /* switch to external mic input */ 2046 - {0x17, AC_VERB_SET_CONNECT_SEL, 0}, 1989 + /* OLPC defers mic widget control until when capture is started because the 1990 + * microphone LED comes on as soon as these settings are put in place. if we 1991 + * did this before recording, it would give the false indication that recording 1992 + * is happening when it is not. */ 1993 + static void cxt5066_olpc_select_mic(struct hda_codec *codec) 1994 + { 1995 + struct conexant_spec *spec = codec->spec; 1996 + if (!spec->recording) 1997 + return; 2047 1998 2048 - /* disable internal mic, port C */ 2049 - {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2050 - {} 2051 - }; 2052 - static struct hda_verb ext_mic_absent[] = { 2053 - /* enable internal mic, port C */ 2054 - {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1999 + if (spec->dc_enable) { 2000 + /* in DC mode we ignore presence detection and just use the jack 2001 + * through our special DC port */ 2002 + const struct hda_verb enable_dc_mode[] = { 2003 + /* disble internal mic, port C */ 2004 + {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2055 2005 2056 - /* switch to internal mic input */ 2057 - {0x17, AC_VERB_SET_CONNECT_SEL, 1}, 2006 + /* enable DC capture, port F */ 2007 + {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2008 + {}, 2009 + }; 2058 2010 2059 - /* disable external mic, port B */ 2060 - {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2061 - {} 2062 - }; 2011 + snd_hda_sequence_write(codec, enable_dc_mode); 2012 + /* port B input disabled (and bias set) through the following call */ 2013 + cxt5066_set_olpc_dc_bias(codec); 2014 + return; 2015 + } 2016 + 2017 + /* disable DC (port F) */ 2018 + snd_hda_codec_write(codec, 0x1e, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0); 2019 + 2020 + /* external mic, port B */ 2021 + snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 2022 + spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0); 2023 + 2024 + /* internal mic, port C */ 2025 + snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 2026 + spec->ext_mic_present ? 0 : PIN_VREF80); 2027 + } 2028 + 2029 + /* toggle input of built-in and mic jack appropriately */ 2030 + static void cxt5066_olpc_automic(struct hda_codec *codec) 2031 + { 2032 + struct conexant_spec *spec = codec->spec; 2063 2033 unsigned int present; 2064 2034 2065 - present = snd_hda_jack_detect(codec, 0x1a); 2066 - if (present) { 2035 + if (spec->dc_enable) /* don't do presence detection in DC mode */ 2036 + return; 2037 + 2038 + present = snd_hda_codec_read(codec, 0x1a, 0, 2039 + AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 2040 + if (present) 2067 2041 snd_printdd("CXT5066: external microphone detected\n"); 2068 - snd_hda_sequence_write(codec, ext_mic_present); 2069 - } else { 2042 + else 2070 2043 snd_printdd("CXT5066: external microphone absent\n"); 2071 - snd_hda_sequence_write(codec, ext_mic_absent); 2072 - } 2044 + 2045 + snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2046 + present ? 0 : 1); 2047 + spec->ext_mic_present = !!present; 2048 + 2049 + cxt5066_olpc_select_mic(codec); 2073 2050 } 2074 2051 2075 2052 /* toggle input of built-in digital mic and mic jack appropriately */ 2076 2053 static void cxt5066_vostro_automic(struct hda_codec *codec) 2077 2054 { 2078 - struct conexant_spec *spec = codec->spec; 2079 2055 unsigned int present; 2080 2056 2081 2057 struct hda_verb ext_mic_present[] = { 2082 2058 /* enable external mic, port B */ 2083 - {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, spec->ext_mic_bias}, 2059 + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2084 2060 2085 2061 /* switch to external mic input */ 2086 2062 {0x17, AC_VERB_SET_CONNECT_SEL, 0}, ··· 2175 2063 } 2176 2064 2177 2065 /* unsolicited event for jack sensing */ 2178 - static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) 2066 + static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res) 2179 2067 { 2068 + struct conexant_spec *spec = codec->spec; 2180 2069 snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 2181 2070 switch (res >> 26) { 2182 2071 case CONEXANT_HP_EVENT: 2183 2072 cxt5066_hp_automute(codec); 2184 2073 break; 2185 2074 case CONEXANT_MIC_EVENT: 2186 - cxt5066_automic(codec); 2075 + /* ignore mic events in DC mode; we're always using the jack */ 2076 + if (!spec->dc_enable) 2077 + cxt5066_olpc_automic(codec); 2187 2078 break; 2188 2079 } 2189 2080 } ··· 2216 2101 }, 2217 2102 }; 2218 2103 2104 + static int cxt5066_set_mic_boost(struct hda_codec *codec) 2105 + { 2106 + struct conexant_spec *spec = codec->spec; 2107 + return snd_hda_codec_write_cache(codec, 0x17, 0, 2108 + AC_VERB_SET_AMP_GAIN_MUTE, 2109 + AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT | 2110 + cxt5066_analog_mic_boost.items[spec->mic_boost].index); 2111 + } 2112 + 2219 2113 static int cxt5066_mic_boost_mux_enum_info(struct snd_kcontrol *kcontrol, 2220 2114 struct snd_ctl_elem_info *uinfo) 2221 2115 { ··· 2235 2111 struct snd_ctl_elem_value *ucontrol) 2236 2112 { 2237 2113 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2238 - int val; 2239 - hda_nid_t nid = kcontrol->private_value & 0xff; 2240 - int inout = (kcontrol->private_value & 0x100) ? 2241 - AC_AMP_GET_INPUT : AC_AMP_GET_OUTPUT; 2242 - 2243 - val = snd_hda_codec_read(codec, nid, 0, 2244 - AC_VERB_GET_AMP_GAIN_MUTE, inout); 2245 - 2246 - ucontrol->value.enumerated.item[0] = val & AC_AMP_GAIN; 2114 + struct conexant_spec *spec = codec->spec; 2115 + ucontrol->value.enumerated.item[0] = spec->mic_boost; 2247 2116 return 0; 2248 2117 } 2249 2118 ··· 2244 2127 struct snd_ctl_elem_value *ucontrol) 2245 2128 { 2246 2129 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2130 + struct conexant_spec *spec = codec->spec; 2247 2131 const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 2248 2132 unsigned int idx; 2249 - hda_nid_t nid = kcontrol->private_value & 0xff; 2250 - int inout = (kcontrol->private_value & 0x100) ? 2251 - AC_AMP_SET_INPUT : AC_AMP_SET_OUTPUT; 2252 - 2253 - if (!imux->num_items) 2254 - return 0; 2255 2133 idx = ucontrol->value.enumerated.item[0]; 2256 2134 if (idx >= imux->num_items) 2257 2135 idx = imux->num_items - 1; 2258 2136 2259 - snd_hda_codec_write_cache(codec, nid, 0, 2260 - AC_VERB_SET_AMP_GAIN_MUTE, 2261 - AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | inout | 2262 - imux->items[idx].index); 2137 + spec->mic_boost = idx; 2138 + if (!spec->dc_enable) 2139 + cxt5066_set_mic_boost(codec); 2140 + return 1; 2141 + } 2142 + 2143 + static void cxt5066_enable_dc(struct hda_codec *codec) 2144 + { 2145 + const struct hda_verb enable_dc_mode[] = { 2146 + /* disable gain */ 2147 + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2148 + 2149 + /* switch to DC input */ 2150 + {0x17, AC_VERB_SET_CONNECT_SEL, 3}, 2151 + {} 2152 + }; 2153 + 2154 + /* configure as input source */ 2155 + snd_hda_sequence_write(codec, enable_dc_mode); 2156 + cxt5066_olpc_select_mic(codec); /* also sets configured bias */ 2157 + } 2158 + 2159 + static void cxt5066_disable_dc(struct hda_codec *codec) 2160 + { 2161 + /* reconfigure input source */ 2162 + cxt5066_set_mic_boost(codec); 2163 + /* automic also selects the right mic if we're recording */ 2164 + cxt5066_olpc_automic(codec); 2165 + } 2166 + 2167 + static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol, 2168 + struct snd_ctl_elem_value *ucontrol) 2169 + { 2170 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2171 + struct conexant_spec *spec = codec->spec; 2172 + ucontrol->value.integer.value[0] = spec->dc_enable; 2173 + return 0; 2174 + } 2175 + 2176 + static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol, 2177 + struct snd_ctl_elem_value *ucontrol) 2178 + { 2179 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2180 + struct conexant_spec *spec = codec->spec; 2181 + int dc_enable = !!ucontrol->value.integer.value[0]; 2182 + 2183 + if (dc_enable == spec->dc_enable) 2184 + return 0; 2185 + 2186 + spec->dc_enable = dc_enable; 2187 + if (dc_enable) 2188 + cxt5066_enable_dc(codec); 2189 + else 2190 + cxt5066_disable_dc(codec); 2263 2191 2264 2192 return 1; 2193 + } 2194 + 2195 + static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol, 2196 + struct snd_ctl_elem_info *uinfo) 2197 + { 2198 + return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo); 2199 + } 2200 + 2201 + static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol, 2202 + struct snd_ctl_elem_value *ucontrol) 2203 + { 2204 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2205 + struct conexant_spec *spec = codec->spec; 2206 + ucontrol->value.enumerated.item[0] = spec->dc_input_bias; 2207 + return 0; 2208 + } 2209 + 2210 + static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol, 2211 + struct snd_ctl_elem_value *ucontrol) 2212 + { 2213 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2214 + struct conexant_spec *spec = codec->spec; 2215 + const struct hda_input_mux *imux = &cxt5066_analog_mic_boost; 2216 + unsigned int idx; 2217 + 2218 + idx = ucontrol->value.enumerated.item[0]; 2219 + if (idx >= imux->num_items) 2220 + idx = imux->num_items - 1; 2221 + 2222 + spec->dc_input_bias = idx; 2223 + if (spec->dc_enable) 2224 + cxt5066_set_olpc_dc_bias(codec); 2225 + return 1; 2226 + } 2227 + 2228 + static void cxt5066_olpc_capture_prepare(struct hda_codec *codec) 2229 + { 2230 + struct conexant_spec *spec = codec->spec; 2231 + /* mark as recording and configure the microphone widget so that the 2232 + * recording LED comes on. */ 2233 + spec->recording = 1; 2234 + cxt5066_olpc_select_mic(codec); 2235 + } 2236 + 2237 + static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec) 2238 + { 2239 + struct conexant_spec *spec = codec->spec; 2240 + const struct hda_verb disable_mics[] = { 2241 + /* disable external mic, port B */ 2242 + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2243 + 2244 + /* disble internal mic, port C */ 2245 + {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2246 + 2247 + /* disable DC capture, port F */ 2248 + {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2249 + {}, 2250 + }; 2251 + 2252 + snd_hda_sequence_write(codec, disable_mics); 2253 + spec->recording = 0; 2265 2254 } 2266 2255 2267 2256 static struct hda_input_mux cxt5066_capture_source = { ··· 2410 2187 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 2411 2188 SNDRV_CTL_ELEM_ACCESS_TLV_READ | 2412 2189 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, 2190 + .subdevice = HDA_SUBDEV_AMP_FLAG, 2413 2191 .info = snd_hda_mixer_amp_volume_info, 2414 2192 .get = snd_hda_mixer_amp_volume_get, 2415 2193 .put = snd_hda_mixer_amp_volume_put, ··· 2418 2194 /* offset by 28 volume steps to limit minimum gain to -46dB */ 2419 2195 .private_value = 2420 2196 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28), 2197 + }, 2198 + {} 2199 + }; 2200 + 2201 + static struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = { 2202 + { 2203 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2204 + .name = "DC Mode Enable Switch", 2205 + .info = snd_ctl_boolean_mono_info, 2206 + .get = cxt5066_olpc_dc_get, 2207 + .put = cxt5066_olpc_dc_put, 2208 + }, 2209 + { 2210 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2211 + .name = "DC Input Bias Enum", 2212 + .info = cxt5066_olpc_dc_bias_enum_info, 2213 + .get = cxt5066_olpc_dc_bias_enum_get, 2214 + .put = cxt5066_olpc_dc_bias_enum_put, 2421 2215 }, 2422 2216 {} 2423 2217 }; ··· 2452 2210 2453 2211 { 2454 2212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2455 - .name = "Ext Mic Boost Capture Enum", 2213 + .name = "Analog Mic Boost Capture Enum", 2456 2214 .info = cxt5066_mic_boost_mux_enum_info, 2457 2215 .get = cxt5066_mic_boost_mux_enum_get, 2458 2216 .put = cxt5066_mic_boost_mux_enum_put, 2459 - .private_value = 0x17, 2460 2217 }, 2461 2218 2462 2219 HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others), ··· 2537 2296 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */ 2538 2297 2539 2298 /* Port B: external microphone */ 2540 - {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, CXT5066_OLPC_EXT_MIC_BIAS}, 2299 + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2541 2300 2542 2301 /* Port C: internal microphone */ 2543 - {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2302 + {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2544 2303 2545 2304 /* Port D: unused */ 2546 2305 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, ··· 2549 2308 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2550 2309 {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */ 2551 2310 2552 - /* Port F: unused */ 2311 + /* Port F: external DC input through microphone port */ 2553 2312 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2554 2313 2555 2314 /* Port G: internal speakers */ ··· 2669 2428 cxt5066_hp_automute(codec); 2670 2429 if (spec->dell_vostro) 2671 2430 cxt5066_vostro_automic(codec); 2672 - else 2673 - cxt5066_automic(codec); 2431 + } 2432 + cxt5066_set_mic_boost(codec); 2433 + return 0; 2434 + } 2435 + 2436 + static int cxt5066_olpc_init(struct hda_codec *codec) 2437 + { 2438 + struct conexant_spec *spec = codec->spec; 2439 + snd_printdd("CXT5066: init\n"); 2440 + conexant_init(codec); 2441 + cxt5066_hp_automute(codec); 2442 + if (!spec->dc_enable) { 2443 + cxt5066_set_mic_boost(codec); 2444 + cxt5066_olpc_automic(codec); 2445 + } else { 2446 + cxt5066_enable_dc(codec); 2674 2447 } 2675 2448 return 0; 2676 2449 } ··· 2725 2470 codec->spec = spec; 2726 2471 2727 2472 codec->patch_ops = conexant_patch_ops; 2728 - codec->patch_ops.init = cxt5066_init; 2473 + codec->patch_ops.init = conexant_init; 2729 2474 2730 2475 spec->dell_automute = 0; 2731 2476 spec->multiout.max_channels = 2; ··· 2738 2483 spec->input_mux = &cxt5066_capture_source; 2739 2484 2740 2485 spec->port_d_mode = PIN_HP; 2741 - spec->ext_mic_bias = PIN_VREF80; 2742 2486 2743 2487 spec->num_init_verbs = 1; 2744 2488 spec->init_verbs[0] = cxt5066_init_verbs; ··· 2764 2510 spec->dell_automute = 1; 2765 2511 break; 2766 2512 case CXT5066_OLPC_XO_1_5: 2767 - codec->patch_ops.unsol_event = cxt5066_unsol_event; 2513 + codec->patch_ops.init = cxt5066_olpc_init; 2514 + codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; 2768 2515 spec->init_verbs[0] = cxt5066_init_verbs_olpc; 2769 2516 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 2517 + spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc; 2770 2518 spec->mixers[spec->num_mixers++] = cxt5066_mixers; 2771 2519 spec->port_d_mode = 0; 2772 - spec->ext_mic_bias = CXT5066_OLPC_EXT_MIC_BIAS; 2520 + spec->mic_boost = 3; /* default 30dB gain */ 2773 2521 2774 2522 /* no S/PDIF out */ 2775 2523 spec->multiout.dig_out_nid = 0; 2776 2524 2777 2525 /* input source automatically selected */ 2778 2526 spec->input_mux = NULL; 2527 + 2528 + /* our capture hooks which allow us to turn on the microphone LED 2529 + * at the right time */ 2530 + spec->capture_prepare = cxt5066_olpc_capture_prepare; 2531 + spec->capture_cleanup = cxt5066_olpc_capture_cleanup; 2779 2532 break; 2780 2533 case CXT5066_DELL_VOSTO: 2534 + codec->patch_ops.init = cxt5066_init; 2781 2535 codec->patch_ops.unsol_event = cxt5066_vostro_event; 2782 2536 spec->init_verbs[0] = cxt5066_init_verbs_vostro; 2783 2537 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; ··· 2793 2531 spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; 2794 2532 spec->port_d_mode = 0; 2795 2533 spec->dell_vostro = 1; 2534 + spec->mic_boost = 3; /* default 30dB gain */ 2796 2535 snd_hda_attach_beep_device(codec, 0x13); 2797 2536 2798 2537 /* no S/PDIF out */
+167 -25
sound/pci/hda/patch_realtek.c
··· 338 338 void (*init_hook)(struct hda_codec *codec); 339 339 void (*unsol_event)(struct hda_codec *codec, unsigned int res); 340 340 #ifdef CONFIG_SND_HDA_POWER_SAVE 341 - void (*power_hook)(struct hda_codec *codec, int power); 341 + void (*power_hook)(struct hda_codec *codec); 342 342 #endif 343 343 344 344 /* for pin sensing */ ··· 391 391 void (*init_hook)(struct hda_codec *); 392 392 #ifdef CONFIG_SND_HDA_POWER_SAVE 393 393 struct hda_amp_list *loopbacks; 394 - void (*power_hook)(struct hda_codec *codec, int power); 394 + void (*power_hook)(struct hda_codec *codec); 395 395 #endif 396 396 }; 397 397 ··· 633 633 634 634 #define ALC_PIN_MODE(xname, nid, dir) \ 635 635 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 636 + .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ 636 637 .info = alc_pin_mode_info, \ 637 638 .get = alc_pin_mode_get, \ 638 639 .put = alc_pin_mode_put, \ ··· 685 684 } 686 685 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \ 687 686 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 687 + .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ 688 688 .info = alc_gpio_data_info, \ 689 689 .get = alc_gpio_data_get, \ 690 690 .put = alc_gpio_data_put, \ ··· 740 738 } 741 739 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \ 742 740 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 741 + .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ 743 742 .info = alc_spdif_ctrl_info, \ 744 743 .get = alc_spdif_ctrl_get, \ 745 744 .put = alc_spdif_ctrl_put, \ ··· 794 791 795 792 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \ 796 793 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 794 + .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ 797 795 .info = alc_eapd_ctrl_info, \ 798 796 .get = alc_eapd_ctrl_get, \ 799 797 .put = alc_eapd_ctrl_put, \ ··· 1844 1840 spec->autocfg.speaker_pins[2] = 0x1b; 1845 1841 } 1846 1842 1847 - #ifdef CONFIG_SND_HDA_POWER_SAVE 1848 - static void alc889_power_eapd(struct hda_codec *codec, int power) 1849 - { 1850 - set_eapd(codec, 0x14, power); 1851 - set_eapd(codec, 0x15, power); 1852 - } 1853 - #endif 1854 - 1855 1843 /* 1856 1844 * ALC880 3-stack model 1857 1845 * ··· 2446 2450 * build control elements 2447 2451 */ 2448 2452 2453 + #define NID_MAPPING (-1) 2454 + 2455 + #define SUBDEV_SPEAKER_ (0 << 6) 2456 + #define SUBDEV_HP_ (1 << 6) 2457 + #define SUBDEV_LINE_ (2 << 6) 2458 + #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) 2459 + #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) 2460 + #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) 2461 + 2449 2462 static void alc_free_kctls(struct hda_codec *codec); 2450 2463 2451 2464 #ifdef CONFIG_SND_HDA_INPUT_BEEP ··· 2469 2464 static int alc_build_controls(struct hda_codec *codec) 2470 2465 { 2471 2466 struct alc_spec *spec = codec->spec; 2472 - int err; 2473 - int i; 2467 + struct snd_kcontrol *kctl; 2468 + struct snd_kcontrol_new *knew; 2469 + int i, j, err; 2470 + unsigned int u; 2471 + hda_nid_t nid; 2474 2472 2475 2473 for (i = 0; i < spec->num_mixers; i++) { 2476 2474 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); ··· 2514 2506 if (!kctl) 2515 2507 return -ENOMEM; 2516 2508 kctl->private_value = spec->beep_amp; 2517 - err = snd_hda_ctl_add(codec, 2518 - get_amp_nid_(spec->beep_amp), kctl); 2509 + err = snd_hda_ctl_add(codec, 0, kctl); 2519 2510 if (err < 0) 2520 2511 return err; 2521 2512 } ··· 2541 2534 } 2542 2535 2543 2536 alc_free_kctls(codec); /* no longer needed */ 2537 + 2538 + /* assign Capture Source enums to NID */ 2539 + kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); 2540 + if (!kctl) 2541 + kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); 2542 + for (i = 0; kctl && i < kctl->count; i++) { 2543 + hda_nid_t *nids = spec->capsrc_nids; 2544 + if (!nids) 2545 + nids = spec->adc_nids; 2546 + err = snd_hda_add_nid(codec, kctl, i, nids[i]); 2547 + if (err < 0) 2548 + return err; 2549 + } 2550 + if (spec->cap_mixer) { 2551 + const char *kname = kctl ? kctl->id.name : NULL; 2552 + for (knew = spec->cap_mixer; knew->name; knew++) { 2553 + if (kname && strcmp(knew->name, kname) == 0) 2554 + continue; 2555 + kctl = snd_hda_find_mixer_ctl(codec, knew->name); 2556 + for (i = 0; kctl && i < kctl->count; i++) { 2557 + err = snd_hda_add_nid(codec, kctl, i, 2558 + spec->adc_nids[i]); 2559 + if (err < 0) 2560 + return err; 2561 + } 2562 + } 2563 + } 2564 + 2565 + /* other nid->control mapping */ 2566 + for (i = 0; i < spec->num_mixers; i++) { 2567 + for (knew = spec->mixers[i]; knew->name; knew++) { 2568 + if (knew->iface != NID_MAPPING) 2569 + continue; 2570 + kctl = snd_hda_find_mixer_ctl(codec, knew->name); 2571 + if (kctl == NULL) 2572 + continue; 2573 + u = knew->subdevice; 2574 + for (j = 0; j < 4; j++, u >>= 8) { 2575 + nid = u & 0x3f; 2576 + if (nid == 0) 2577 + continue; 2578 + switch (u & 0xc0) { 2579 + case SUBDEV_SPEAKER_: 2580 + nid = spec->autocfg.speaker_pins[nid]; 2581 + break; 2582 + case SUBDEV_LINE_: 2583 + nid = spec->autocfg.line_out_pins[nid]; 2584 + break; 2585 + case SUBDEV_HP_: 2586 + nid = spec->autocfg.hp_pins[nid]; 2587 + break; 2588 + default: 2589 + continue; 2590 + } 2591 + err = snd_hda_add_nid(codec, kctl, 0, nid); 2592 + if (err < 0) 2593 + return err; 2594 + } 2595 + u = knew->private_value; 2596 + for (j = 0; j < 4; j++, u >>= 8) { 2597 + nid = u & 0xff; 2598 + if (nid == 0) 2599 + continue; 2600 + err = snd_hda_add_nid(codec, kctl, 0, nid); 2601 + if (err < 0) 2602 + return err; 2603 + } 2604 + } 2605 + } 2544 2606 return 0; 2545 2607 } 2546 2608 ··· 3692 3616 return 0; 3693 3617 } 3694 3618 3619 + static inline void alc_shutup(struct hda_codec *codec) 3620 + { 3621 + snd_hda_shutup_pins(codec); 3622 + } 3623 + 3695 3624 static void alc_free_kctls(struct hda_codec *codec) 3696 3625 { 3697 3626 struct alc_spec *spec = codec->spec; ··· 3717 3636 if (!spec) 3718 3637 return; 3719 3638 3639 + alc_shutup(codec); 3720 3640 alc_free_kctls(codec); 3721 3641 kfree(spec); 3722 3642 snd_hda_detach_beep_device(codec); 3723 3643 } 3724 3644 3725 3645 #ifdef CONFIG_SND_HDA_POWER_SAVE 3646 + static void alc_power_eapd(struct hda_codec *codec) 3647 + { 3648 + /* We currently only handle front, HP */ 3649 + switch (codec->vendor_id) { 3650 + case 0x10ec0260: 3651 + snd_hda_codec_write(codec, 0x0f, 0, 3652 + AC_VERB_SET_EAPD_BTLENABLE, 0x00); 3653 + snd_hda_codec_write(codec, 0x10, 0, 3654 + AC_VERB_SET_EAPD_BTLENABLE, 0x00); 3655 + break; 3656 + case 0x10ec0262: 3657 + case 0x10ec0267: 3658 + case 0x10ec0268: 3659 + case 0x10ec0269: 3660 + case 0x10ec0272: 3661 + case 0x10ec0660: 3662 + case 0x10ec0662: 3663 + case 0x10ec0663: 3664 + case 0x10ec0862: 3665 + case 0x10ec0889: 3666 + snd_hda_codec_write(codec, 0x14, 0, 3667 + AC_VERB_SET_EAPD_BTLENABLE, 0x00); 3668 + snd_hda_codec_write(codec, 0x15, 0, 3669 + AC_VERB_SET_EAPD_BTLENABLE, 0x00); 3670 + break; 3671 + } 3672 + } 3673 + 3726 3674 static int alc_suspend(struct hda_codec *codec, pm_message_t state) 3727 3675 { 3728 3676 struct alc_spec *spec = codec->spec; 3677 + alc_shutup(codec); 3729 3678 if (spec && spec->power_hook) 3730 - spec->power_hook(codec, 0); 3679 + spec->power_hook(codec); 3731 3680 return 0; 3732 3681 } 3733 3682 #endif ··· 3765 3654 #ifdef SND_HDA_NEEDS_RESUME 3766 3655 static int alc_resume(struct hda_codec *codec) 3767 3656 { 3768 - #ifdef CONFIG_SND_HDA_POWER_SAVE 3769 - struct alc_spec *spec = codec->spec; 3770 - #endif 3771 3657 codec->patch_ops.init(codec); 3772 3658 snd_hda_codec_resume_amp(codec); 3773 3659 snd_hda_codec_resume_cache(codec); 3774 - #ifdef CONFIG_SND_HDA_POWER_SAVE 3775 - if (spec && spec->power_hook) 3776 - spec->power_hook(codec, 1); 3777 - #endif 3778 3660 return 0; 3779 3661 } 3780 3662 #endif ··· 3787 3683 .suspend = alc_suspend, 3788 3684 .check_power_status = alc_check_power_status, 3789 3685 #endif 3686 + .reboot_notify = alc_shutup, 3790 3687 }; 3791 3688 3792 3689 ··· 3944 3839 #define PIN_CTL_TEST(xname,nid) { \ 3945 3840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3946 3841 .name = xname, \ 3842 + .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ 3947 3843 .info = alc_test_pin_ctl_info, \ 3948 3844 .get = alc_test_pin_ctl_get, \ 3949 3845 .put = alc_test_pin_ctl_put, \ ··· 3954 3848 #define PIN_SRC_TEST(xname,nid) { \ 3955 3849 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3956 3850 .name = xname, \ 3851 + .subdevice = HDA_SUBDEV_NID_FLAG | nid, \ 3957 3852 .info = alc_test_pin_src_info, \ 3958 3853 .get = alc_test_pin_src_get, \ 3959 3854 .put = alc_test_pin_src_put, \ ··· 4494 4387 if (!knew->name) 4495 4388 return -ENOMEM; 4496 4389 if (get_amp_nid_(val)) 4497 - knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); 4390 + knew->subdevice = HDA_SUBDEV_AMP_FLAG; 4498 4391 knew->private_value = val; 4499 4392 return 0; 4500 4393 } ··· 5289 5182 { 5290 5183 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5291 5184 .name = "Master Playback Switch", 5185 + .subdevice = HDA_SUBDEV_NID_FLAG | 0x11, 5292 5186 .info = snd_ctl_boolean_mono_info, 5293 5187 .get = alc260_hp_master_sw_get, 5294 5188 .put = alc260_hp_master_sw_put, ··· 5328 5220 { 5329 5221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5330 5222 .name = "Master Playback Switch", 5223 + .subdevice = HDA_SUBDEV_NID_FLAG | 0x11, 5331 5224 .info = snd_ctl_boolean_mono_info, 5332 5225 .get = alc260_hp_master_sw_get, 5333 5226 .put = alc260_hp_master_sw_put, ··· 9637 9528 .setup = alc889_acer_aspire_8930g_setup, 9638 9529 .init_hook = alc_automute_amp, 9639 9530 #ifdef CONFIG_SND_HDA_POWER_SAVE 9640 - .power_hook = alc889_power_eapd, 9531 + .power_hook = alc_power_eapd, 9641 9532 #endif 9642 9533 }, 9643 9534 [ALC888_ACER_ASPIRE_7730G] = { ··· 10433 10324 .info = snd_ctl_boolean_mono_info, \ 10434 10325 .get = alc262_hp_master_sw_get, \ 10435 10326 .put = alc262_hp_master_sw_put, \ 10327 + }, \ 10328 + { \ 10329 + .iface = NID_MAPPING, \ 10330 + .name = "Master Playback Switch", \ 10331 + .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \ 10436 10332 } 10333 + 10437 10334 10438 10335 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = { 10439 10336 ALC262_HP_MASTER_SWITCH, ··· 10598 10483 .info = snd_ctl_boolean_mono_info, \ 10599 10484 .get = alc262_hippo_master_sw_get, \ 10600 10485 .put = alc262_hippo_master_sw_put, \ 10486 + }, \ 10487 + { \ 10488 + .iface = NID_MAPPING, \ 10489 + .name = "Master Playback Switch", \ 10490 + .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \ 10491 + (SUBDEV_SPEAKER(0) << 16), \ 10601 10492 } 10602 10493 10603 10494 static struct snd_kcontrol_new alc262_hippo_mixer[] = { ··· 11084 10963 { 11085 10964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11086 10965 .name = "Master Playback Switch", 10966 + .subdevice = HDA_SUBDEV_AMP_FLAG, 11087 10967 .info = snd_hda_mixer_amp_switch_info, 11088 10968 .get = snd_hda_mixer_amp_switch_get, 11089 10969 .put = alc262_fujitsu_master_sw_put, 11090 10970 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), 10971 + }, 10972 + { 10973 + .iface = NID_MAPPING, 10974 + .name = "Master Playback Switch", 10975 + .private_value = 0x1b, 11091 10976 }, 11092 10977 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 11093 10978 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), ··· 11125 10998 { 11126 10999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 11127 11000 .name = "Master Playback Switch", 11001 + .subdevice = HDA_SUBDEV_AMP_FLAG, 11128 11002 .info = snd_hda_mixer_amp_switch_info, 11129 11003 .get = snd_hda_mixer_amp_switch_get, 11130 11004 .put = alc262_lenovo_3000_master_sw_put, ··· 11279 11151 .info = alc_mux_enum_info, 11280 11152 .get = alc_mux_enum_get, 11281 11153 .put = alc262_ultra_mux_enum_put, 11154 + }, 11155 + { 11156 + .iface = NID_MAPPING, 11157 + .name = "Capture Source", 11158 + .private_value = 0x15, 11282 11159 }, 11283 11160 { } /* end */ 11284 11161 }; ··· 12303 12170 { 12304 12171 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12305 12172 .name = "Master Playback Switch", 12173 + .subdevice = HDA_SUBDEV_AMP_FLAG, 12306 12174 .info = snd_hda_mixer_amp_switch_info, 12307 12175 .get = snd_hda_mixer_amp_switch_get, 12308 12176 .put = alc268_acer_master_sw_put, ··· 12319 12185 { 12320 12186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12321 12187 .name = "Master Playback Switch", 12188 + .subdevice = HDA_SUBDEV_AMP_FLAG, 12322 12189 .info = snd_hda_mixer_amp_switch_info, 12323 12190 .get = snd_hda_mixer_amp_switch_get, 12324 12191 .put = alc268_acer_master_sw_put, ··· 12337 12202 { 12338 12203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 12339 12204 .name = "Master Playback Switch", 12205 + .subdevice = HDA_SUBDEV_AMP_FLAG, 12340 12206 .info = snd_hda_mixer_amp_switch_info, 12341 12207 .get = snd_hda_mixer_amp_switch_get, 12342 12208 .put = alc268_acer_master_sw_put, ··· 13291 13155 { 13292 13156 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13293 13157 .name = "Master Playback Switch", 13158 + .subdevice = HDA_SUBDEV_AMP_FLAG, 13294 13159 .info = snd_hda_mixer_amp_switch_info, 13295 13160 .get = snd_hda_mixer_amp_switch_get, 13296 13161 .put = alc268_acer_master_sw_put, ··· 13312 13175 { 13313 13176 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 13314 13177 .name = "Master Playback Switch", 13178 + .subdevice = HDA_SUBDEV_AMP_FLAG, 13315 13179 .info = snd_hda_mixer_amp_switch_info, 13316 13180 .get = snd_hda_mixer_amp_switch_get, 13317 13181 .put = alc268_acer_master_sw_put, ··· 15077 14939 spec->vmaster_nid = 0x03; 15078 14940 15079 14941 codec->patch_ops = alc_patch_ops; 15080 - if (board_config == ALC861_AUTO) 14942 + if (board_config == ALC861_AUTO) { 15081 14943 spec->init_hook = alc861_auto_init; 14944 + #ifdef CONFIG_SND_HDA_POWER_SAVE 14945 + spec->power_hook = alc_power_eapd; 14946 + #endif 14947 + } 15082 14948 #ifdef CONFIG_SND_HDA_POWER_SAVE 15083 14949 if (!spec->loopback.amplist) 15084 14950 spec->loopback.amplist = alc861_loopbacks;
+1
sound/pci/hda/patch_si3054.c
··· 122 122 #define SI3054_KCONTROL(kname,reg,mask) { \ 123 123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 124 124 .name = kname, \ 125 + .subdevice = HDA_SUBDEV_NID_FLAG | reg, \ 125 126 .info = si3054_switch_info, \ 126 127 .get = si3054_switch_get, \ 127 128 .put = si3054_switch_put, \
+92 -28
sound/pci/hda/patch_sigmatel.c
··· 2688 2688 stac_control_new(struct sigmatel_spec *spec, 2689 2689 struct snd_kcontrol_new *ktemp, 2690 2690 const char *name, 2691 - hda_nid_t nid) 2691 + unsigned int subdev) 2692 2692 { 2693 2693 struct snd_kcontrol_new *knew; 2694 2694 ··· 2704 2704 spec->kctls.alloced--; 2705 2705 return NULL; 2706 2706 } 2707 - if (nid) 2708 - knew->subdevice = HDA_SUBDEV_NID_FLAG | nid; 2707 + knew->subdevice = subdev; 2709 2708 return knew; 2710 2709 } 2711 2710 ··· 2714 2715 unsigned long val) 2715 2716 { 2716 2717 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name, 2717 - get_amp_nid_(val)); 2718 + HDA_SUBDEV_AMP_FLAG); 2718 2719 if (!knew) 2719 2720 return -ENOMEM; 2720 2721 knew->index = idx; ··· 4159 4160 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, 4160 4161 int enable); 4161 4162 4163 + static inline int get_int_hint(struct hda_codec *codec, const char *key, 4164 + int *valp) 4165 + { 4166 + const char *p; 4167 + p = snd_hda_get_hint(codec, key); 4168 + if (p) { 4169 + unsigned long val; 4170 + if (!strict_strtoul(p, 0, &val)) { 4171 + *valp = val; 4172 + return 1; 4173 + } 4174 + } 4175 + return 0; 4176 + } 4177 + 4162 4178 /* override some hints from the hwdep entry */ 4163 4179 static void stac_store_hints(struct hda_codec *codec) 4164 4180 { 4165 4181 struct sigmatel_spec *spec = codec->spec; 4166 - const char *p; 4167 4182 int val; 4168 4183 4169 4184 val = snd_hda_get_bool_hint(codec, "hp_detect"); 4170 4185 if (val >= 0) 4171 4186 spec->hp_detect = val; 4172 - p = snd_hda_get_hint(codec, "gpio_mask"); 4173 - if (p) { 4174 - spec->gpio_mask = simple_strtoul(p, NULL, 0); 4187 + if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) { 4175 4188 spec->eapd_mask = spec->gpio_dir = spec->gpio_data = 4176 4189 spec->gpio_mask; 4177 4190 } 4178 - p = snd_hda_get_hint(codec, "gpio_dir"); 4179 - if (p) 4180 - spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask; 4181 - p = snd_hda_get_hint(codec, "gpio_data"); 4182 - if (p) 4183 - spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask; 4184 - p = snd_hda_get_hint(codec, "eapd_mask"); 4185 - if (p) 4186 - spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask; 4191 + if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir)) 4192 + spec->gpio_mask &= spec->gpio_mask; 4193 + if (get_int_hint(codec, "gpio_data", &spec->gpio_data)) 4194 + spec->gpio_dir &= spec->gpio_mask; 4195 + if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask)) 4196 + spec->eapd_mask &= spec->gpio_mask; 4197 + if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute)) 4198 + spec->gpio_mute &= spec->gpio_mask; 4187 4199 val = snd_hda_get_bool_hint(codec, "eapd_switch"); 4188 4200 if (val >= 0) 4189 4201 spec->eapd_switch = val; 4202 + get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity); 4203 + if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) { 4204 + spec->gpio_mask |= spec->gpio_led; 4205 + spec->gpio_dir |= spec->gpio_led; 4206 + if (spec->gpio_led_polarity) 4207 + spec->gpio_data |= spec->gpio_led; 4208 + } 4190 4209 } 4191 4210 4192 4211 static int stac92xx_init(struct hda_codec *codec) ··· 4389 4372 static void stac92xx_shutup(struct hda_codec *codec) 4390 4373 { 4391 4374 struct sigmatel_spec *spec = codec->spec; 4392 - int i; 4393 - hda_nid_t nid; 4394 4375 4395 - /* reset each pin before powering down DAC/ADC to avoid click noise */ 4396 - nid = codec->start_nid; 4397 - for (i = 0; i < codec->num_nodes; i++, nid++) { 4398 - unsigned int wcaps = get_wcaps(codec, nid); 4399 - unsigned int wid_type = get_wcaps_type(wcaps); 4400 - if (wid_type == AC_WID_PIN) 4401 - snd_hda_codec_read(codec, nid, 0, 4402 - AC_VERB_SET_PIN_WIDGET_CONTROL, 0); 4403 - } 4376 + snd_hda_shutup_pins(codec); 4404 4377 4405 4378 if (spec->eapd_mask) 4406 4379 stac_gpio_set(codec, spec->gpio_mask, ··· 5438 5431 return 0; 5439 5432 } 5440 5433 5434 + /* HP dv7 bass switch - GPIO5 */ 5435 + #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info 5436 + static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol, 5437 + struct snd_ctl_elem_value *ucontrol) 5438 + { 5439 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 5440 + struct sigmatel_spec *spec = codec->spec; 5441 + ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20); 5442 + return 0; 5443 + } 5444 + 5445 + static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol, 5446 + struct snd_ctl_elem_value *ucontrol) 5447 + { 5448 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 5449 + struct sigmatel_spec *spec = codec->spec; 5450 + unsigned int gpio_data; 5451 + 5452 + gpio_data = (spec->gpio_data & ~0x20) | 5453 + (ucontrol->value.integer.value[0] ? 0x20 : 0); 5454 + if (gpio_data == spec->gpio_data) 5455 + return 0; 5456 + spec->gpio_data = gpio_data; 5457 + stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data); 5458 + return 1; 5459 + } 5460 + 5461 + static struct snd_kcontrol_new stac_hp_bass_sw_ctrl = { 5462 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5463 + .info = stac_hp_bass_gpio_info, 5464 + .get = stac_hp_bass_gpio_get, 5465 + .put = stac_hp_bass_gpio_put, 5466 + }; 5467 + 5468 + static int stac_add_hp_bass_switch(struct hda_codec *codec) 5469 + { 5470 + struct sigmatel_spec *spec = codec->spec; 5471 + 5472 + if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl, 5473 + "Bass Speaker Playback Switch", 0)) 5474 + return -ENOMEM; 5475 + 5476 + spec->gpio_mask |= 0x20; 5477 + spec->gpio_dir |= 0x20; 5478 + spec->gpio_data |= 0x20; 5479 + return 0; 5480 + } 5481 + 5441 5482 static int patch_stac92hd71bxx(struct hda_codec *codec) 5442 5483 { 5443 5484 struct sigmatel_spec *spec; ··· 5727 5672 if (err < 0) { 5728 5673 stac92xx_free(codec); 5729 5674 return err; 5675 + } 5676 + 5677 + /* enable bass on HP dv7 */ 5678 + if (spec->board_config == STAC_HP_DV5) { 5679 + unsigned int cap; 5680 + cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP); 5681 + cap &= AC_GPIO_IO_COUNT; 5682 + if (cap >= 6) 5683 + stac_add_hp_bass_switch(codec); 5730 5684 } 5731 5685 5732 5686 codec->proc_widget_hook = stac92hd7x_proc_hook;
+166 -108
sound/pci/hda/patch_via.c
··· 54 54 #include "hda_codec.h" 55 55 #include "hda_local.h" 56 56 57 + #define NID_MAPPING (-1) 58 + 57 59 /* amp values */ 58 60 #define AMP_VAL_IDX_SHIFT 19 59 61 #define AMP_VAL_IDX_MASK (0x0f<<19) ··· 158 156 struct hda_loopback_check loopback; 159 157 #endif 160 158 }; 159 + 160 + static struct via_spec * via_new_spec(struct hda_codec *codec) 161 + { 162 + struct via_spec *spec; 163 + 164 + spec = kzalloc(sizeof(*spec), GFP_KERNEL); 165 + if (spec == NULL) 166 + return NULL; 167 + 168 + codec->spec = spec; 169 + spec->codec = codec; 170 + return spec; 171 + } 161 172 162 173 static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) 163 174 { ··· 458 443 if (!knew->name) 459 444 return -ENOMEM; 460 445 if (get_amp_nid_(val)) 461 - knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); 446 + knew->subdevice = HDA_SUBDEV_AMP_FLAG; 462 447 knew->private_value = val; 448 + return 0; 449 + } 450 + 451 + static struct snd_kcontrol_new *via_clone_control(struct via_spec *spec, 452 + struct snd_kcontrol_new *tmpl) 453 + { 454 + struct snd_kcontrol_new *knew; 455 + 456 + snd_array_init(&spec->kctls, sizeof(*knew), 32); 457 + knew = snd_array_new(&spec->kctls); 458 + if (!knew) 459 + return NULL; 460 + *knew = *tmpl; 461 + knew->name = kstrdup(tmpl->name, GFP_KERNEL); 462 + if (!knew->name) 463 + return NULL; 463 464 return 0; 464 465 } 465 466 ··· 1119 1088 struct snd_ctl_elem_value *ucontrol) 1120 1089 { 1121 1090 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1122 - struct via_spec *spec = codec->spec; 1123 - hda_nid_t nid; 1091 + hda_nid_t nid = kcontrol->private_value; 1124 1092 unsigned int pinsel; 1125 1093 1126 - switch (spec->codec_type) { 1127 - case VT1718S: 1128 - nid = 0x34; 1129 - break; 1130 - case VT2002P: 1131 - nid = 0x35; 1132 - break; 1133 - case VT1812: 1134 - nid = 0x3d; 1135 - break; 1136 - default: 1137 - nid = spec->autocfg.hp_pins[0]; 1138 - break; 1139 - } 1140 1094 /* use !! to translate conn sel 2 for VT1718S */ 1141 1095 pinsel = !!snd_hda_codec_read(codec, nid, 0, 1142 1096 AC_VERB_GET_CONNECT_SEL, ··· 1143 1127 } 1144 1128 } 1145 1129 1130 + static hda_nid_t side_mute_channel(struct via_spec *spec) 1131 + { 1132 + switch (spec->codec_type) { 1133 + case VT1708: return 0x1b; 1134 + case VT1709_10CH: return 0x29; 1135 + case VT1708B_8CH: /* fall thru */ 1136 + case VT1708S: return 0x27; 1137 + default: return 0; 1138 + } 1139 + } 1140 + 1146 1141 static int update_side_mute_status(struct hda_codec *codec) 1147 1142 { 1148 1143 /* mute side channel */ 1149 1144 struct via_spec *spec = codec->spec; 1150 1145 unsigned int parm = spec->hp_independent_mode 1151 1146 ? AMP_OUT_MUTE : AMP_OUT_UNMUTE; 1152 - hda_nid_t sw3; 1153 - 1154 - switch (spec->codec_type) { 1155 - case VT1708: 1156 - sw3 = 0x1b; 1157 - break; 1158 - case VT1709_10CH: 1159 - sw3 = 0x29; 1160 - break; 1161 - case VT1708B_8CH: 1162 - case VT1708S: 1163 - sw3 = 0x27; 1164 - break; 1165 - default: 1166 - sw3 = 0; 1167 - break; 1168 - } 1147 + hda_nid_t sw3 = side_mute_channel(spec); 1169 1148 1170 1149 if (sw3) 1171 1150 snd_hda_codec_write(codec, sw3, 0, AC_VERB_SET_AMP_GAIN_MUTE, ··· 1173 1162 { 1174 1163 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1175 1164 struct via_spec *spec = codec->spec; 1176 - hda_nid_t nid = spec->autocfg.hp_pins[0]; 1165 + hda_nid_t nid = kcontrol->private_value; 1177 1166 unsigned int pinsel = ucontrol->value.enumerated.item[0]; 1178 1167 /* Get Independent Mode index of headphone pin widget */ 1179 1168 spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel 1180 1169 ? 1 : 0; 1181 - 1182 - switch (spec->codec_type) { 1183 - case VT1718S: 1184 - nid = 0x34; 1185 - pinsel = pinsel ? 2 : 0; /* indep HP use AOW4 (index 2) */ 1186 - spec->multiout.num_dacs = 4; 1187 - break; 1188 - case VT2002P: 1189 - nid = 0x35; 1190 - break; 1191 - case VT1812: 1192 - nid = 0x3d; 1193 - break; 1194 - default: 1195 - nid = spec->autocfg.hp_pins[0]; 1196 - break; 1197 - } 1198 1170 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, pinsel); 1199 1171 1200 1172 if (spec->multiout.hp_nid && spec->multiout.hp_nid ··· 1201 1207 return 0; 1202 1208 } 1203 1209 1204 - static struct snd_kcontrol_new via_hp_mixer[] = { 1210 + static struct snd_kcontrol_new via_hp_mixer[2] = { 1205 1211 { 1206 1212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1207 1213 .name = "Independent HP", 1208 - .count = 1, 1209 1214 .info = via_independent_hp_info, 1210 1215 .get = via_independent_hp_get, 1211 1216 .put = via_independent_hp_put, 1212 1217 }, 1213 - { } /* end */ 1218 + { 1219 + .iface = NID_MAPPING, 1220 + .name = "Independent HP", 1221 + }, 1214 1222 }; 1223 + 1224 + static int via_hp_build(struct via_spec *spec) 1225 + { 1226 + struct snd_kcontrol_new *knew; 1227 + hda_nid_t nid; 1228 + 1229 + knew = via_clone_control(spec, &via_hp_mixer[0]); 1230 + if (knew == NULL) 1231 + return -ENOMEM; 1232 + 1233 + switch (spec->codec_type) { 1234 + case VT1718S: 1235 + nid = 0x34; 1236 + break; 1237 + case VT2002P: 1238 + nid = 0x35; 1239 + break; 1240 + case VT1812: 1241 + nid = 0x3d; 1242 + break; 1243 + default: 1244 + nid = spec->autocfg.hp_pins[0]; 1245 + break; 1246 + } 1247 + 1248 + knew->subdevice = HDA_SUBDEV_NID_FLAG | nid; 1249 + knew->private_value = nid; 1250 + 1251 + knew = via_clone_control(spec, &via_hp_mixer[1]); 1252 + if (knew == NULL) 1253 + return -ENOMEM; 1254 + knew->subdevice = side_mute_channel(spec); 1255 + 1256 + return 0; 1257 + } 1215 1258 1216 1259 static void notify_aa_path_ctls(struct hda_codec *codec) 1217 1260 { ··· 1407 1376 return 1; 1408 1377 } 1409 1378 1410 - static struct snd_kcontrol_new via_smart51_mixer[] = { 1379 + static struct snd_kcontrol_new via_smart51_mixer[2] = { 1411 1380 { 1412 1381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1413 1382 .name = "Smart 5.1", ··· 1416 1385 .get = via_smart51_get, 1417 1386 .put = via_smart51_put, 1418 1387 }, 1419 - {} /* end */ 1388 + { 1389 + .iface = NID_MAPPING, 1390 + .name = "Smart 5.1", 1391 + } 1420 1392 }; 1393 + 1394 + static int via_smart51_build(struct via_spec *spec) 1395 + { 1396 + struct snd_kcontrol_new *knew; 1397 + int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE }; 1398 + hda_nid_t nid; 1399 + int i; 1400 + 1401 + knew = via_clone_control(spec, &via_smart51_mixer[0]); 1402 + if (knew == NULL) 1403 + return -ENOMEM; 1404 + 1405 + for (i = 0; i < ARRAY_SIZE(index); i++) { 1406 + nid = spec->autocfg.input_pins[index[i]]; 1407 + if (nid) { 1408 + knew = via_clone_control(spec, &via_smart51_mixer[1]); 1409 + if (knew == NULL) 1410 + return -ENOMEM; 1411 + knew->subdevice = nid; 1412 + } 1413 + } 1414 + 1415 + return 0; 1416 + } 1421 1417 1422 1418 /* capture mixer elements */ 1423 1419 static struct snd_kcontrol_new vt1708_capture_mixer[] = { ··· 1877 1819 static int via_build_controls(struct hda_codec *codec) 1878 1820 { 1879 1821 struct via_spec *spec = codec->spec; 1880 - int err; 1881 - int i; 1822 + struct snd_kcontrol *kctl; 1823 + struct snd_kcontrol_new *knew; 1824 + int err, i; 1882 1825 1883 1826 for (i = 0; i < spec->num_mixers; i++) { 1884 1827 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); ··· 1902 1843 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 1903 1844 if (err < 0) 1904 1845 return err; 1846 + } 1847 + 1848 + /* assign Capture Source enums to NID */ 1849 + kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); 1850 + for (i = 0; kctl && i < kctl->count; i++) { 1851 + err = snd_hda_add_nid(codec, kctl, i, spec->mux_nids[i]); 1852 + if (err < 0) 1853 + return err; 1854 + } 1855 + 1856 + /* other nid->control mapping */ 1857 + for (i = 0; i < spec->num_mixers; i++) { 1858 + for (knew = spec->mixers[i]; knew->name; knew++) { 1859 + if (knew->iface != NID_MAPPING) 1860 + continue; 1861 + kctl = snd_hda_find_mixer_ctl(codec, knew->name); 1862 + if (kctl == NULL) 1863 + continue; 1864 + err = snd_hda_add_nid(codec, kctl, 0, 1865 + knew->subdevice); 1866 + } 1905 1867 } 1906 1868 1907 1869 /* init power states */ ··· 2561 2481 spec->input_mux = &spec->private_imux[0]; 2562 2482 2563 2483 if (spec->hp_mux) 2564 - spec->mixers[spec->num_mixers++] = via_hp_mixer; 2484 + via_hp_build(spec); 2565 2485 2566 - spec->mixers[spec->num_mixers++] = via_smart51_mixer; 2486 + via_smart51_build(spec); 2567 2487 return 1; 2568 2488 } 2569 2489 ··· 2634 2554 int err; 2635 2555 2636 2556 /* create a codec specific record */ 2637 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 2557 + spec = via_new_spec(codec); 2638 2558 if (spec == NULL) 2639 2559 return -ENOMEM; 2640 - 2641 - codec->spec = spec; 2642 2560 2643 2561 /* automatic parse from the BIOS config */ 2644 2562 err = vt1708_parse_auto_config(codec); ··· 2675 2597 #ifdef CONFIG_SND_HDA_POWER_SAVE 2676 2598 spec->loopback.amplist = vt1708_loopbacks; 2677 2599 #endif 2678 - spec->codec = codec; 2679 2600 INIT_DELAYED_WORK(&spec->vt1708_hp_work, vt1708_update_hp_jack_state); 2680 2601 return 0; 2681 2602 } ··· 3087 3010 spec->input_mux = &spec->private_imux[0]; 3088 3011 3089 3012 if (spec->hp_mux) 3090 - spec->mixers[spec->num_mixers++] = via_hp_mixer; 3013 + via_hp_build(spec); 3091 3014 3092 - spec->mixers[spec->num_mixers++] = via_smart51_mixer; 3015 + via_smart51_build(spec); 3093 3016 return 1; 3094 3017 } 3095 3018 ··· 3109 3032 int err; 3110 3033 3111 3034 /* create a codec specific record */ 3112 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3035 + spec = via_new_spec(codec); 3113 3036 if (spec == NULL) 3114 3037 return -ENOMEM; 3115 - 3116 - codec->spec = spec; 3117 3038 3118 3039 err = vt1709_parse_auto_config(codec); 3119 3040 if (err < 0) { ··· 3201 3126 int err; 3202 3127 3203 3128 /* create a codec specific record */ 3204 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3129 + spec = via_new_spec(codec); 3205 3130 if (spec == NULL) 3206 3131 return -ENOMEM; 3207 - 3208 - codec->spec = spec; 3209 3132 3210 3133 err = vt1709_parse_auto_config(codec); 3211 3134 if (err < 0) { ··· 3654 3581 spec->input_mux = &spec->private_imux[0]; 3655 3582 3656 3583 if (spec->hp_mux) 3657 - spec->mixers[spec->num_mixers++] = via_hp_mixer; 3584 + via_hp_build(spec); 3658 3585 3659 - spec->mixers[spec->num_mixers++] = via_smart51_mixer; 3586 + via_smart51_build(spec); 3660 3587 return 1; 3661 3588 } 3662 3589 ··· 3678 3605 if (get_codec_type(codec) == VT1708BCE) 3679 3606 return patch_vt1708S(codec); 3680 3607 /* create a codec specific record */ 3681 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3608 + spec = via_new_spec(codec); 3682 3609 if (spec == NULL) 3683 3610 return -ENOMEM; 3684 - 3685 - codec->spec = spec; 3686 3611 3687 3612 /* automatic parse from the BIOS config */ 3688 3613 err = vt1708B_parse_auto_config(codec); ··· 3728 3657 int err; 3729 3658 3730 3659 /* create a codec specific record */ 3731 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3660 + spec = via_new_spec(codec); 3732 3661 if (spec == NULL) 3733 3662 return -ENOMEM; 3734 - 3735 - codec->spec = spec; 3736 3663 3737 3664 /* automatic parse from the BIOS config */ 3738 3665 err = vt1708B_parse_auto_config(codec); ··· 4140 4071 spec->input_mux = &spec->private_imux[0]; 4141 4072 4142 4073 if (spec->hp_mux) 4143 - spec->mixers[spec->num_mixers++] = via_hp_mixer; 4074 + via_hp_build(spec); 4144 4075 4145 - spec->mixers[spec->num_mixers++] = via_smart51_mixer; 4076 + via_smart51_build(spec); 4146 4077 return 1; 4147 4078 } 4148 4079 ··· 4172 4103 int err; 4173 4104 4174 4105 /* create a codec specific record */ 4175 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4106 + spec = via_new_spec(codec); 4176 4107 if (spec == NULL) 4177 4108 return -ENOMEM; 4178 - 4179 - codec->spec = spec; 4180 4109 4181 4110 /* automatic parse from the BIOS config */ 4182 4111 err = vt1708S_parse_auto_config(codec); ··· 4510 4443 spec->input_mux = &spec->private_imux[0]; 4511 4444 4512 4445 if (spec->hp_mux) 4513 - spec->mixers[spec->num_mixers++] = via_hp_mixer; 4446 + via_hp_build(spec); 4514 4447 4515 4448 return 1; 4516 4449 } ··· 4531 4464 int err; 4532 4465 4533 4466 /* create a codec specific record */ 4534 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4467 + spec = via_new_spec(codec); 4535 4468 if (spec == NULL) 4536 4469 return -ENOMEM; 4537 - 4538 - codec->spec = spec; 4539 4470 4540 4471 /* automatic parse from the BIOS config */ 4541 4472 err = vt1702_parse_auto_config(codec); ··· 4930 4865 spec->input_mux = &spec->private_imux[0]; 4931 4866 4932 4867 if (spec->hp_mux) 4933 - spec->mixers[spec->num_mixers++] = via_hp_mixer; 4868 + via_hp_build(spec); 4934 4869 4935 - spec->mixers[spec->num_mixers++] = via_smart51_mixer; 4870 + via_smart51_build(spec); 4936 4871 4937 4872 return 1; 4938 4873 } ··· 4953 4888 int err; 4954 4889 4955 4890 /* create a codec specific record */ 4956 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4891 + spec = via_new_spec(codec); 4957 4892 if (spec == NULL) 4958 4893 return -ENOMEM; 4959 - 4960 - codec->spec = spec; 4961 4894 4962 4895 /* automatic parse from the BIOS config */ 4963 4896 err = vt1718S_parse_auto_config(codec); ··· 5077 5014 { 5078 5015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5079 5016 .name = "Digital Mic Capture Switch", 5017 + .subdevice = HDA_SUBDEV_NID_FLAG | 0x26, 5080 5018 .count = 1, 5081 5019 .info = vt1716s_dmic_info, 5082 5020 .get = vt1716s_dmic_get, ··· 5425 5361 spec->input_mux = &spec->private_imux[0]; 5426 5362 5427 5363 if (spec->hp_mux) 5428 - spec->mixers[spec->num_mixers++] = via_hp_mixer; 5364 + via_hp_build(spec); 5429 5365 5430 - spec->mixers[spec->num_mixers++] = via_smart51_mixer; 5366 + via_smart51_build(spec); 5431 5367 5432 5368 return 1; 5433 5369 } ··· 5448 5384 int err; 5449 5385 5450 5386 /* create a codec specific record */ 5451 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5387 + spec = via_new_spec(codec); 5452 5388 if (spec == NULL) 5453 5389 return -ENOMEM; 5454 - 5455 - codec->spec = spec; 5456 5390 5457 5391 /* automatic parse from the BIOS config */ 5458 5392 err = vt1716S_parse_auto_config(codec); ··· 5781 5719 spec->input_mux = &spec->private_imux[0]; 5782 5720 5783 5721 if (spec->hp_mux) 5784 - spec->mixers[spec->num_mixers++] = via_hp_mixer; 5722 + via_hp_build(spec); 5785 5723 5786 5724 return 1; 5787 5725 } ··· 5803 5741 int err; 5804 5742 5805 5743 /* create a codec specific record */ 5806 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5744 + spec = via_new_spec(codec); 5807 5745 if (spec == NULL) 5808 5746 return -ENOMEM; 5809 - 5810 - codec->spec = spec; 5811 5747 5812 5748 /* automatic parse from the BIOS config */ 5813 5749 err = vt2002P_parse_auto_config(codec); ··· 6130 6070 spec->input_mux = &spec->private_imux[0]; 6131 6071 6132 6072 if (spec->hp_mux) 6133 - spec->mixers[spec->num_mixers++] = via_hp_mixer; 6073 + via_hp_build(spec); 6134 6074 6135 6075 return 1; 6136 6076 } ··· 6152 6092 int err; 6153 6093 6154 6094 /* create a codec specific record */ 6155 - spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6095 + spec = via_new_spec(codec); 6156 6096 if (spec == NULL) 6157 6097 return -ENOMEM; 6158 - 6159 - codec->spec = spec; 6160 6098 6161 6099 /* automatic parse from the BIOS config */ 6162 6100 err = vt1812_parse_auto_config(codec);
+10 -1
sound/pci/ice1712/ice1712.c
··· 106 106 MODULE_PARM_DESC(dxr_enable, "Enable DXR support for Terratec DMX6FIRE."); 107 107 108 108 109 - static const struct pci_device_id snd_ice1712_ids[] = { 109 + static DEFINE_PCI_DEVICE_TABLE(snd_ice1712_ids) = { 110 110 { PCI_VDEVICE(ICE, PCI_DEVICE_ID_ICE_1712), 0 }, /* ICE1712 */ 111 111 { 0, } 112 112 }; ··· 1180 1180 snd_pcm_set_sync(substream); 1181 1181 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); 1182 1182 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); 1183 + if (is_pro_rate_locked(ice)) { 1184 + runtime->hw.rate_min = PRO_RATE_DEFAULT; 1185 + runtime->hw.rate_max = PRO_RATE_DEFAULT; 1186 + } 1183 1187 1184 1188 if (ice->spdif.ops.open) 1185 1189 ice->spdif.ops.open(ice, substream); ··· 1201 1197 snd_pcm_set_sync(substream); 1202 1198 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); 1203 1199 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); 1200 + if (is_pro_rate_locked(ice)) { 1201 + runtime->hw.rate_min = PRO_RATE_DEFAULT; 1202 + runtime->hw.rate_max = PRO_RATE_DEFAULT; 1203 + } 1204 + 1204 1205 return 0; 1205 1206 } 1206 1207
+1 -1
sound/pci/ice1712/ice1724.c
··· 94 94 95 95 96 96 /* Both VT1720 and VT1724 have the same PCI IDs */ 97 - static const struct pci_device_id snd_vt1724_ids[] = { 97 + static DEFINE_PCI_DEVICE_TABLE(snd_vt1724_ids) = { 98 98 { PCI_VDEVICE(ICE, PCI_DEVICE_ID_VT1724), 0 }, 99 99 { 0, } 100 100 };
+1 -1
sound/pci/intel8x0.c
··· 420 420 u32 int_sta_mask; /* interrupt status mask */ 421 421 }; 422 422 423 - static struct pci_device_id snd_intel8x0_ids[] = { 423 + static DEFINE_PCI_DEVICE_TABLE(snd_intel8x0_ids) = { 424 424 { PCI_VDEVICE(INTEL, 0x2415), DEVICE_INTEL }, /* 82801AA */ 425 425 { PCI_VDEVICE(INTEL, 0x2425), DEVICE_INTEL }, /* 82901AB */ 426 426 { PCI_VDEVICE(INTEL, 0x2445), DEVICE_INTEL }, /* 82801BA */
+1 -1
sound/pci/intel8x0m.c
··· 219 219 unsigned int pcm_pos_shift; 220 220 }; 221 221 222 - static struct pci_device_id snd_intel8x0m_ids[] = { 222 + static DEFINE_PCI_DEVICE_TABLE(snd_intel8x0m_ids) = { 223 223 { PCI_VDEVICE(INTEL, 0x2416), DEVICE_INTEL }, /* 82801AA */ 224 224 { PCI_VDEVICE(INTEL, 0x2426), DEVICE_INTEL }, /* 82901AB */ 225 225 { PCI_VDEVICE(INTEL, 0x2446), DEVICE_INTEL }, /* 82801BA */
+1 -1
sound/pci/korg1212/korg1212.c
··· 418 418 MODULE_PARM_DESC(enable, "Enable Korg 1212 soundcard."); 419 419 MODULE_AUTHOR("Haroldo Gamal <gamal@alternex.com.br>"); 420 420 421 - static struct pci_device_id snd_korg1212_ids[] = { 421 + static DEFINE_PCI_DEVICE_TABLE(snd_korg1212_ids) = { 422 422 { 423 423 .vendor = 0x10b5, 424 424 .device = 0x906d,
+1 -1
sound/pci/lx6464es/lx6464es.c
··· 55 55 56 56 #define PCI_DEVICE_ID_PLX_LX6464ES PCI_DEVICE_ID_PLX_9056 57 57 58 - static struct pci_device_id snd_lx6464es_ids[] = { 58 + static DEFINE_PCI_DEVICE_TABLE(snd_lx6464es_ids) = { 59 59 { PCI_DEVICE(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_LX6464ES), 60 60 .subvendor = PCI_VENDOR_ID_DIGIGRAM, 61 61 .subdevice = PCI_SUBDEVICE_ID_DIGIGRAM_LX6464ES_SERIAL_SUBSYSTEM
+1 -1
sound/pci/maestro3.c
··· 861 861 /* 862 862 * pci ids 863 863 */ 864 - static struct pci_device_id snd_m3_ids[] = { 864 + static DEFINE_PCI_DEVICE_TABLE(snd_m3_ids) = { 865 865 {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO_1, PCI_ANY_ID, PCI_ANY_ID, 866 866 PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, 867 867 {PCI_VENDOR_ID_ESS, PCI_DEVICE_ID_ESS_ALLEGRO, PCI_ANY_ID, PCI_ANY_ID,
+1 -1
sound/pci/mixart/mixart.c
··· 60 60 /* 61 61 */ 62 62 63 - static struct pci_device_id snd_mixart_ids[] = { 63 + static DEFINE_PCI_DEVICE_TABLE(snd_mixart_ids) = { 64 64 { PCI_VDEVICE(MOTOROLA, 0x0003), 0, }, /* MC8240 */ 65 65 { 0, } 66 66 };
+1 -1
sound/pci/nm256/nm256.c
··· 262 262 /* 263 263 * PCI ids 264 264 */ 265 - static struct pci_device_id snd_nm256_ids[] = { 265 + static DEFINE_PCI_DEVICE_TABLE(snd_nm256_ids) = { 266 266 {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO), 0}, 267 267 {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO), 0}, 268 268 {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO), 0},
+1 -1
sound/pci/oxygen/Makefile
··· 2 2 snd-hifier-objs := hifier.o 3 3 snd-oxygen-objs := oxygen.o 4 4 snd-virtuoso-objs := virtuoso.o xonar_lib.o \ 5 - xonar_pcm179x.o xonar_cs43xx.o xonar_hdmi.o 5 + xonar_pcm179x.o xonar_cs43xx.o xonar_wm87x6.o xonar_hdmi.o 6 6 7 7 obj-$(CONFIG_SND_OXYGEN_LIB) += snd-oxygen-lib.o 8 8 obj-$(CONFIG_SND_HIFIER) += snd-hifier.o
+1 -1
sound/pci/oxygen/hifier.c
··· 48 48 module_param_array(enable, bool, NULL, 0444); 49 49 MODULE_PARM_DESC(enable, "enable card"); 50 50 51 - static struct pci_device_id hifier_ids[] __devinitdata = { 51 + static DEFINE_PCI_DEVICE_TABLE(hifier_ids) = { 52 52 { OXYGEN_PCI_SUBID(0x14c3, 0x1710) }, 53 53 { OXYGEN_PCI_SUBID(0x14c3, 0x1711) }, 54 54 { OXYGEN_PCI_SUBID_BROKEN_EEPROM },
+1 -1
sound/pci/oxygen/oxygen.c
··· 72 72 MODEL_CLARO_HALO, /* HT-Omega Claro halo */ 73 73 }; 74 74 75 - static struct pci_device_id oxygen_ids[] __devinitdata = { 75 + static DEFINE_PCI_DEVICE_TABLE(oxygen_ids) = { 76 76 { OXYGEN_PCI_SUBID(0x10b0, 0x0216), .driver_data = MODEL_CMEDIA_REF }, 77 77 { OXYGEN_PCI_SUBID(0x10b0, 0x0218), .driver_data = MODEL_CMEDIA_REF }, 78 78 { OXYGEN_PCI_SUBID(0x10b0, 0x0219), .driver_data = MODEL_CMEDIA_REF },
+4 -1
sound/pci/oxygen/virtuoso.c
··· 40 40 module_param_array(enable, bool, NULL, 0444); 41 41 MODULE_PARM_DESC(enable, "enable card"); 42 42 43 - static struct pci_device_id xonar_ids[] __devinitdata = { 43 + static DEFINE_PCI_DEVICE_TABLE(xonar_ids) = { 44 44 { OXYGEN_PCI_SUBID(0x1043, 0x8269) }, 45 45 { OXYGEN_PCI_SUBID(0x1043, 0x8275) }, 46 46 { OXYGEN_PCI_SUBID(0x1043, 0x82b7) }, ··· 49 49 { OXYGEN_PCI_SUBID(0x1043, 0x834f) }, 50 50 { OXYGEN_PCI_SUBID(0x1043, 0x835c) }, 51 51 { OXYGEN_PCI_SUBID(0x1043, 0x835d) }, 52 + { OXYGEN_PCI_SUBID(0x1043, 0x838e) }, 52 53 { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, 53 54 { } 54 55 }; ··· 61 60 if (get_xonar_pcm179x_model(chip, id) >= 0) 62 61 return 0; 63 62 if (get_xonar_cs43xx_model(chip, id) >= 0) 63 + return 0; 64 + if (get_xonar_wm87x6_model(chip, id) >= 0) 64 65 return 0; 65 66 return -EINVAL; 66 67 }
+73
sound/pci/oxygen/wm8766.h
··· 1 + #ifndef WM8766_H_INCLUDED 2 + #define WM8766_H_INCLUDED 3 + 4 + #define WM8766_LDA1 0x00 5 + #define WM8766_RDA1 0x01 6 + #define WM8766_DAC_CTRL 0x02 7 + #define WM8766_INT_CTRL 0x03 8 + #define WM8766_LDA2 0x04 9 + #define WM8766_RDA2 0x05 10 + #define WM8766_LDA3 0x06 11 + #define WM8766_RDA3 0x07 12 + #define WM8766_MASTDA 0x08 13 + #define WM8766_DAC_CTRL2 0x09 14 + #define WM8766_DAC_CTRL3 0x0a 15 + #define WM8766_MUTE1 0x0c 16 + #define WM8766_MUTE2 0x0f 17 + #define WM8766_RESET 0x1f 18 + 19 + /* LDAx/RDAx/MASTDA */ 20 + #define WM8766_ATT_MASK 0x0ff 21 + #define WM8766_UPDATE 0x100 22 + /* DAC_CTRL */ 23 + #define WM8766_MUTEALL 0x001 24 + #define WM8766_DEEMPALL 0x002 25 + #define WM8766_PWDN 0x004 26 + #define WM8766_ATC 0x008 27 + #define WM8766_IZD 0x010 28 + #define WM8766_PL_LEFT_MASK 0x060 29 + #define WM8766_PL_LEFT_MUTE 0x000 30 + #define WM8766_PL_LEFT_LEFT 0x020 31 + #define WM8766_PL_LEFT_RIGHT 0x040 32 + #define WM8766_PL_LEFT_LRMIX 0x060 33 + #define WM8766_PL_RIGHT_MASK 0x180 34 + #define WM8766_PL_RIGHT_MUTE 0x000 35 + #define WM8766_PL_RIGHT_LEFT 0x080 36 + #define WM8766_PL_RIGHT_RIGHT 0x100 37 + #define WM8766_PL_RIGHT_LRMIX 0x180 38 + /* INT_CTRL */ 39 + #define WM8766_FMT_MASK 0x003 40 + #define WM8766_FMT_RJUST 0x000 41 + #define WM8766_FMT_LJUST 0x001 42 + #define WM8766_FMT_I2S 0x002 43 + #define WM8766_FMT_DSP 0x003 44 + #define WM8766_LRP 0x004 45 + #define WM8766_BCP 0x008 46 + #define WM8766_IWL_MASK 0x030 47 + #define WM8766_IWL_16 0x000 48 + #define WM8766_IWL_20 0x010 49 + #define WM8766_IWL_24 0x020 50 + #define WM8766_IWL_32 0x030 51 + #define WM8766_PHASE_MASK 0x1c0 52 + /* DAC_CTRL2 */ 53 + #define WM8766_ZCD 0x001 54 + #define WM8766_DZFM_MASK 0x006 55 + #define WM8766_DMUTE_MASK 0x038 56 + #define WM8766_DEEMP_MASK 0x1c0 57 + /* DAC_CTRL3 */ 58 + #define WM8766_DACPD_MASK 0x00e 59 + #define WM8766_PWRDNALL 0x010 60 + #define WM8766_MS 0x020 61 + #define WM8766_RATE_MASK 0x1c0 62 + #define WM8766_RATE_128 0x000 63 + #define WM8766_RATE_192 0x040 64 + #define WM8766_RATE_256 0x080 65 + #define WM8766_RATE_384 0x0c0 66 + #define WM8766_RATE_512 0x100 67 + #define WM8766_RATE_768 0x140 68 + /* MUTE1 */ 69 + #define WM8766_MPD1 0x040 70 + /* MUTE2 */ 71 + #define WM8766_MPD2 0x020 72 + 73 + #endif
+177
sound/pci/oxygen/wm8776.h
··· 1 + #ifndef WM8776_H_INCLUDED 2 + #define WM8776_H_INCLUDED 3 + 4 + /* 5 + * the following register names are from: 6 + * wm8776.h -- WM8776 ASoC driver 7 + * 8 + * Copyright 2009 Wolfson Microelectronics plc 9 + * 10 + * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 11 + * 12 + * This program is free software; you can redistribute it and/or modify 13 + * it under the terms of the GNU General Public License version 2 as 14 + * published by the Free Software Foundation. 15 + */ 16 + 17 + #define WM8776_HPLVOL 0x00 18 + #define WM8776_HPRVOL 0x01 19 + #define WM8776_HPMASTER 0x02 20 + #define WM8776_DACLVOL 0x03 21 + #define WM8776_DACRVOL 0x04 22 + #define WM8776_DACMASTER 0x05 23 + #define WM8776_PHASESWAP 0x06 24 + #define WM8776_DACCTRL1 0x07 25 + #define WM8776_DACMUTE 0x08 26 + #define WM8776_DACCTRL2 0x09 27 + #define WM8776_DACIFCTRL 0x0a 28 + #define WM8776_ADCIFCTRL 0x0b 29 + #define WM8776_MSTRCTRL 0x0c 30 + #define WM8776_PWRDOWN 0x0d 31 + #define WM8776_ADCLVOL 0x0e 32 + #define WM8776_ADCRVOL 0x0f 33 + #define WM8776_ALCCTRL1 0x10 34 + #define WM8776_ALCCTRL2 0x11 35 + #define WM8776_ALCCTRL3 0x12 36 + #define WM8776_NOISEGATE 0x13 37 + #define WM8776_LIMITER 0x14 38 + #define WM8776_ADCMUX 0x15 39 + #define WM8776_OUTMUX 0x16 40 + #define WM8776_RESET 0x17 41 + 42 + 43 + /* HPLVOL/HPRVOL/HPMASTER */ 44 + #define WM8776_HPATT_MASK 0x07f 45 + #define WM8776_HPZCEN 0x080 46 + #define WM8776_UPDATE 0x100 47 + 48 + /* DACLVOL/DACRVOL/DACMASTER */ 49 + #define WM8776_DATT_MASK 0x0ff 50 + /*#define WM8776_UPDATE 0x100*/ 51 + 52 + /* PHASESWAP */ 53 + #define WM8776_PH_MASK 0x003 54 + 55 + /* DACCTRL1 */ 56 + #define WM8776_DZCEN 0x001 57 + #define WM8776_ATC 0x002 58 + #define WM8776_IZD 0x004 59 + #define WM8776_TOD 0x008 60 + #define WM8776_PL_LEFT_MASK 0x030 61 + #define WM8776_PL_LEFT_MUTE 0x000 62 + #define WM8776_PL_LEFT_LEFT 0x010 63 + #define WM8776_PL_LEFT_RIGHT 0x020 64 + #define WM8776_PL_LEFT_LRMIX 0x030 65 + #define WM8776_PL_RIGHT_MASK 0x0c0 66 + #define WM8776_PL_RIGHT_MUTE 0x000 67 + #define WM8776_PL_RIGHT_LEFT 0x040 68 + #define WM8776_PL_RIGHT_RIGHT 0x080 69 + #define WM8776_PL_RIGHT_LRMIX 0x0c0 70 + 71 + /* DACMUTE */ 72 + #define WM8776_DMUTE 0x001 73 + 74 + /* DACCTRL2 */ 75 + #define WM8776_DEEMPH 0x001 76 + #define WM8776_DZFM_MASK 0x006 77 + #define WM8776_DZFM_NONE 0x000 78 + #define WM8776_DZFM_LR 0x002 79 + #define WM8776_DZFM_BOTH 0x004 80 + #define WM8776_DZFM_EITHER 0x006 81 + 82 + /* DACIFCTRL */ 83 + #define WM8776_DACFMT_MASK 0x003 84 + #define WM8776_DACFMT_RJUST 0x000 85 + #define WM8776_DACFMT_LJUST 0x001 86 + #define WM8776_DACFMT_I2S 0x002 87 + #define WM8776_DACFMT_DSP 0x003 88 + #define WM8776_DACLRP 0x004 89 + #define WM8776_DACBCP 0x008 90 + #define WM8776_DACWL_MASK 0x030 91 + #define WM8776_DACWL_16 0x000 92 + #define WM8776_DACWL_20 0x010 93 + #define WM8776_DACWL_24 0x020 94 + #define WM8776_DACWL_32 0x030 95 + 96 + /* ADCIFCTRL */ 97 + #define WM8776_ADCFMT_MASK 0x003 98 + #define WM8776_ADCFMT_RJUST 0x000 99 + #define WM8776_ADCFMT_LJUST 0x001 100 + #define WM8776_ADCFMT_I2S 0x002 101 + #define WM8776_ADCFMT_DSP 0x003 102 + #define WM8776_ADCLRP 0x004 103 + #define WM8776_ADCBCP 0x008 104 + #define WM8776_ADCWL_MASK 0x030 105 + #define WM8776_ADCWL_16 0x000 106 + #define WM8776_ADCWL_20 0x010 107 + #define WM8776_ADCWL_24 0x020 108 + #define WM8776_ADCWL_32 0x030 109 + #define WM8776_ADCMCLK 0x040 110 + #define WM8776_ADCHPD 0x100 111 + 112 + /* MSTRCTRL */ 113 + #define WM8776_ADCRATE_MASK 0x007 114 + #define WM8776_ADCRATE_256 0x002 115 + #define WM8776_ADCRATE_384 0x003 116 + #define WM8776_ADCRATE_512 0x004 117 + #define WM8776_ADCRATE_768 0x005 118 + #define WM8776_ADCOSR 0x008 119 + #define WM8776_DACRATE_MASK 0x070 120 + #define WM8776_DACRATE_128 0x000 121 + #define WM8776_DACRATE_192 0x010 122 + #define WM8776_DACRATE_256 0x020 123 + #define WM8776_DACRATE_384 0x030 124 + #define WM8776_DACRATE_512 0x040 125 + #define WM8776_DACRATE_768 0x050 126 + #define WM8776_DACMS 0x080 127 + #define WM8776_ADCMS 0x100 128 + 129 + /* PWRDOWN */ 130 + #define WM8776_PDWN 0x001 131 + #define WM8776_ADCPD 0x002 132 + #define WM8776_DACPD 0x004 133 + #define WM8776_HPPD 0x008 134 + #define WM8776_AINPD 0x040 135 + 136 + /* ADCLVOL/ADCRVOL */ 137 + #define WM8776_AGMASK 0x0ff 138 + #define WM8776_ZCA 0x100 139 + 140 + /* ALCCTRL1 */ 141 + #define WM8776_LCT_MASK 0x00f 142 + #define WM8776_MAXGAIN_MASK 0x070 143 + #define WM8776_LCSEL_MASK 0x180 144 + #define WM8776_LCSEL_LIMITER 0x000 145 + #define WM8776_LCSEL_ALC_RIGHT 0x080 146 + #define WM8776_LCSEL_ALC_LEFT 0x100 147 + #define WM8776_LCSEL_ALC_STEREO 0x180 148 + 149 + /* ALCCTRL2 */ 150 + #define WM8776_HLD_MASK 0x00f 151 + #define WM8776_ALCZC 0x080 152 + #define WM8776_LCEN 0x100 153 + 154 + /* ALCCTRL3 */ 155 + #define WM8776_ATK_MASK 0x00f 156 + #define WM8776_DCY_MASK 0x0f0 157 + 158 + /* NOISEGATE */ 159 + #define WM8776_NGAT 0x001 160 + #define WM8776_NGTH_MASK 0x01c 161 + 162 + /* LIMITER */ 163 + #define WM8776_MAXATTEN_MASK 0x00f 164 + #define WM8776_TRANWIN_MASK 0x070 165 + 166 + /* ADCMUX */ 167 + #define WM8776_AMX_MASK 0x01f 168 + #define WM8776_MUTERA 0x040 169 + #define WM8776_MUTELA 0x080 170 + #define WM8776_LRBOTH 0x100 171 + 172 + /* OUTMUX */ 173 + #define WM8776_MX_DAC 0x001 174 + #define WM8776_MX_AUX 0x002 175 + #define WM8776_MX_BYPASS 0x004 176 + 177 + #endif
+2
sound/pci/oxygen/xonar.h
··· 35 35 const struct pci_device_id *id); 36 36 int get_xonar_cs43xx_model(struct oxygen *chip, 37 37 const struct pci_device_id *id); 38 + int get_xonar_wm87x6_model(struct oxygen *chip, 39 + const struct pci_device_id *id); 38 40 39 41 /* HDMI helper functions */ 40 42
+1021
sound/pci/oxygen/xonar_wm87x6.c
··· 1 + /* 2 + * card driver for models with WM8776/WM8766 DACs (Xonar DS) 3 + * 4 + * Copyright (c) Clemens Ladisch <clemens@ladisch.de> 5 + * 6 + * 7 + * This driver is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License, version 2. 9 + * 10 + * This driver is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this driver; if not, see <http://www.gnu.org/licenses/>. 17 + */ 18 + 19 + /* 20 + * Xonar DS 21 + * -------- 22 + * 23 + * CMI8788: 24 + * 25 + * SPI 0 -> WM8766 (surround, center/LFE, back) 26 + * SPI 1 -> WM8776 (front, input) 27 + * 28 + * GPIO 4 <- headphone detect 29 + * GPIO 6 -> route input jack to input 1/2 (1/0) 30 + * GPIO 7 -> enable output to speakers 31 + * GPIO 8 -> enable output to speakers 32 + */ 33 + 34 + #include <linux/pci.h> 35 + #include <linux/delay.h> 36 + #include <sound/control.h> 37 + #include <sound/core.h> 38 + #include <sound/pcm.h> 39 + #include <sound/pcm_params.h> 40 + #include <sound/tlv.h> 41 + #include "xonar.h" 42 + #include "wm8776.h" 43 + #include "wm8766.h" 44 + 45 + #define GPIO_DS_HP_DETECT 0x0010 46 + #define GPIO_DS_INPUT_ROUTE 0x0040 47 + #define GPIO_DS_OUTPUT_ENABLE 0x0180 48 + 49 + #define LC_CONTROL_LIMITER 0x40000000 50 + #define LC_CONTROL_ALC 0x20000000 51 + 52 + struct xonar_wm87x6 { 53 + struct xonar_generic generic; 54 + u16 wm8776_regs[0x17]; 55 + u16 wm8766_regs[0x10]; 56 + struct snd_kcontrol *lc_controls[13]; 57 + }; 58 + 59 + static void wm8776_write(struct oxygen *chip, 60 + unsigned int reg, unsigned int value) 61 + { 62 + struct xonar_wm87x6 *data = chip->model_data; 63 + 64 + oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | 65 + OXYGEN_SPI_DATA_LENGTH_2 | 66 + OXYGEN_SPI_CLOCK_160 | 67 + (1 << OXYGEN_SPI_CODEC_SHIFT) | 68 + OXYGEN_SPI_CEN_LATCH_CLOCK_LO, 69 + (reg << 9) | value); 70 + if (reg < ARRAY_SIZE(data->wm8776_regs)) { 71 + if (reg >= WM8776_HPLVOL || reg <= WM8776_DACMASTER) 72 + value &= ~WM8776_UPDATE; 73 + data->wm8776_regs[reg] = value; 74 + } 75 + } 76 + 77 + static void wm8776_write_cached(struct oxygen *chip, 78 + unsigned int reg, unsigned int value) 79 + { 80 + struct xonar_wm87x6 *data = chip->model_data; 81 + 82 + if (reg >= ARRAY_SIZE(data->wm8776_regs) || 83 + value != data->wm8776_regs[reg]) 84 + wm8776_write(chip, reg, value); 85 + } 86 + 87 + static void wm8766_write(struct oxygen *chip, 88 + unsigned int reg, unsigned int value) 89 + { 90 + struct xonar_wm87x6 *data = chip->model_data; 91 + 92 + oxygen_write_spi(chip, OXYGEN_SPI_TRIGGER | 93 + OXYGEN_SPI_DATA_LENGTH_2 | 94 + OXYGEN_SPI_CLOCK_160 | 95 + (0 << OXYGEN_SPI_CODEC_SHIFT) | 96 + OXYGEN_SPI_CEN_LATCH_CLOCK_LO, 97 + (reg << 9) | value); 98 + if (reg < ARRAY_SIZE(data->wm8766_regs)) 99 + data->wm8766_regs[reg] = value; 100 + } 101 + 102 + static void wm8766_write_cached(struct oxygen *chip, 103 + unsigned int reg, unsigned int value) 104 + { 105 + struct xonar_wm87x6 *data = chip->model_data; 106 + 107 + if (reg >= ARRAY_SIZE(data->wm8766_regs) || 108 + value != data->wm8766_regs[reg]) { 109 + if ((reg >= WM8766_LDA1 && reg <= WM8766_RDA1) || 110 + (reg >= WM8766_LDA2 && reg <= WM8766_MASTDA)) 111 + value &= ~WM8766_UPDATE; 112 + wm8766_write(chip, reg, value); 113 + } 114 + } 115 + 116 + static void wm8776_registers_init(struct oxygen *chip) 117 + { 118 + struct xonar_wm87x6 *data = chip->model_data; 119 + 120 + wm8776_write(chip, WM8776_RESET, 0); 121 + wm8776_write(chip, WM8776_DACCTRL1, WM8776_DZCEN | 122 + WM8776_PL_LEFT_LEFT | WM8776_PL_RIGHT_RIGHT); 123 + wm8776_write(chip, WM8776_DACMUTE, chip->dac_mute ? WM8776_DMUTE : 0); 124 + wm8776_write(chip, WM8776_DACIFCTRL, 125 + WM8776_DACFMT_LJUST | WM8776_DACWL_24); 126 + wm8776_write(chip, WM8776_ADCIFCTRL, 127 + data->wm8776_regs[WM8776_ADCIFCTRL]); 128 + wm8776_write(chip, WM8776_MSTRCTRL, data->wm8776_regs[WM8776_MSTRCTRL]); 129 + wm8776_write(chip, WM8776_PWRDOWN, data->wm8776_regs[WM8776_PWRDOWN]); 130 + wm8776_write(chip, WM8776_HPLVOL, data->wm8776_regs[WM8776_HPLVOL]); 131 + wm8776_write(chip, WM8776_HPRVOL, data->wm8776_regs[WM8776_HPRVOL] | 132 + WM8776_UPDATE); 133 + wm8776_write(chip, WM8776_ADCLVOL, data->wm8776_regs[WM8776_ADCLVOL]); 134 + wm8776_write(chip, WM8776_ADCRVOL, data->wm8776_regs[WM8776_ADCRVOL]); 135 + wm8776_write(chip, WM8776_ADCMUX, data->wm8776_regs[WM8776_ADCMUX]); 136 + wm8776_write(chip, WM8776_DACLVOL, chip->dac_volume[0]); 137 + wm8776_write(chip, WM8776_DACRVOL, chip->dac_volume[1] | WM8776_UPDATE); 138 + } 139 + 140 + static void wm8766_registers_init(struct oxygen *chip) 141 + { 142 + wm8766_write(chip, WM8766_RESET, 0); 143 + wm8766_write(chip, WM8766_INT_CTRL, WM8766_FMT_LJUST | WM8766_IWL_24); 144 + wm8766_write(chip, WM8766_DAC_CTRL2, 145 + WM8766_ZCD | (chip->dac_mute ? WM8766_DMUTE_MASK : 0)); 146 + wm8766_write(chip, WM8766_LDA1, chip->dac_volume[2]); 147 + wm8766_write(chip, WM8766_RDA1, chip->dac_volume[3]); 148 + wm8766_write(chip, WM8766_LDA2, chip->dac_volume[4]); 149 + wm8766_write(chip, WM8766_RDA2, chip->dac_volume[5]); 150 + wm8766_write(chip, WM8766_LDA3, chip->dac_volume[6]); 151 + wm8766_write(chip, WM8766_RDA3, chip->dac_volume[7] | WM8766_UPDATE); 152 + } 153 + 154 + static void wm8776_init(struct oxygen *chip) 155 + { 156 + struct xonar_wm87x6 *data = chip->model_data; 157 + 158 + data->wm8776_regs[WM8776_HPLVOL] = (0x79 - 60) | WM8776_HPZCEN; 159 + data->wm8776_regs[WM8776_HPRVOL] = (0x79 - 60) | WM8776_HPZCEN; 160 + data->wm8776_regs[WM8776_ADCIFCTRL] = 161 + WM8776_ADCFMT_LJUST | WM8776_ADCWL_24 | WM8776_ADCMCLK; 162 + data->wm8776_regs[WM8776_MSTRCTRL] = 163 + WM8776_ADCRATE_256 | WM8776_DACRATE_256; 164 + data->wm8776_regs[WM8776_PWRDOWN] = WM8776_HPPD; 165 + data->wm8776_regs[WM8776_ADCLVOL] = 0xa5 | WM8776_ZCA; 166 + data->wm8776_regs[WM8776_ADCRVOL] = 0xa5 | WM8776_ZCA; 167 + data->wm8776_regs[WM8776_ADCMUX] = 0x001; 168 + wm8776_registers_init(chip); 169 + } 170 + 171 + static void xonar_ds_init(struct oxygen *chip) 172 + { 173 + struct xonar_wm87x6 *data = chip->model_data; 174 + 175 + data->generic.anti_pop_delay = 300; 176 + data->generic.output_enable_bit = GPIO_DS_OUTPUT_ENABLE; 177 + 178 + wm8776_init(chip); 179 + wm8766_registers_init(chip); 180 + 181 + oxygen_write16_masked(chip, OXYGEN_GPIO_CONTROL, GPIO_DS_INPUT_ROUTE, 182 + GPIO_DS_HP_DETECT | GPIO_DS_INPUT_ROUTE); 183 + oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_DS_INPUT_ROUTE); 184 + oxygen_set_bits16(chip, OXYGEN_GPIO_INTERRUPT_MASK, GPIO_DS_HP_DETECT); 185 + chip->interrupt_mask |= OXYGEN_INT_GPIO; 186 + 187 + xonar_enable_output(chip); 188 + 189 + snd_component_add(chip->card, "WM8776"); 190 + snd_component_add(chip->card, "WM8766"); 191 + } 192 + 193 + static void xonar_ds_cleanup(struct oxygen *chip) 194 + { 195 + xonar_disable_output(chip); 196 + } 197 + 198 + static void xonar_ds_suspend(struct oxygen *chip) 199 + { 200 + xonar_ds_cleanup(chip); 201 + } 202 + 203 + static void xonar_ds_resume(struct oxygen *chip) 204 + { 205 + wm8776_registers_init(chip); 206 + wm8766_registers_init(chip); 207 + xonar_enable_output(chip); 208 + } 209 + 210 + static void wm8776_adc_hardware_filter(unsigned int channel, 211 + struct snd_pcm_hardware *hardware) 212 + { 213 + if (channel == PCM_A) { 214 + hardware->rates = SNDRV_PCM_RATE_32000 | 215 + SNDRV_PCM_RATE_44100 | 216 + SNDRV_PCM_RATE_48000 | 217 + SNDRV_PCM_RATE_64000 | 218 + SNDRV_PCM_RATE_88200 | 219 + SNDRV_PCM_RATE_96000; 220 + hardware->rate_max = 96000; 221 + } 222 + } 223 + 224 + static void set_wm87x6_dac_params(struct oxygen *chip, 225 + struct snd_pcm_hw_params *params) 226 + { 227 + } 228 + 229 + static void set_wm8776_adc_params(struct oxygen *chip, 230 + struct snd_pcm_hw_params *params) 231 + { 232 + u16 reg; 233 + 234 + reg = WM8776_ADCRATE_256 | WM8776_DACRATE_256; 235 + if (params_rate(params) > 48000) 236 + reg |= WM8776_ADCOSR; 237 + wm8776_write_cached(chip, WM8776_MSTRCTRL, reg); 238 + } 239 + 240 + static void update_wm8776_volume(struct oxygen *chip) 241 + { 242 + struct xonar_wm87x6 *data = chip->model_data; 243 + u8 to_change; 244 + 245 + if (chip->dac_volume[0] == chip->dac_volume[1]) { 246 + if (chip->dac_volume[0] != data->wm8776_regs[WM8776_DACLVOL] || 247 + chip->dac_volume[1] != data->wm8776_regs[WM8776_DACRVOL]) { 248 + wm8776_write(chip, WM8776_DACMASTER, 249 + chip->dac_volume[0] | WM8776_UPDATE); 250 + data->wm8776_regs[WM8776_DACLVOL] = chip->dac_volume[0]; 251 + data->wm8776_regs[WM8776_DACRVOL] = chip->dac_volume[0]; 252 + } 253 + } else { 254 + to_change = (chip->dac_volume[0] != 255 + data->wm8776_regs[WM8776_DACLVOL]) << 0; 256 + to_change |= (chip->dac_volume[1] != 257 + data->wm8776_regs[WM8776_DACLVOL]) << 1; 258 + if (to_change & 1) 259 + wm8776_write(chip, WM8776_DACLVOL, chip->dac_volume[0] | 260 + ((to_change & 2) ? 0 : WM8776_UPDATE)); 261 + if (to_change & 2) 262 + wm8776_write(chip, WM8776_DACRVOL, 263 + chip->dac_volume[1] | WM8776_UPDATE); 264 + } 265 + } 266 + 267 + static void update_wm87x6_volume(struct oxygen *chip) 268 + { 269 + static const u8 wm8766_regs[6] = { 270 + WM8766_LDA1, WM8766_RDA1, 271 + WM8766_LDA2, WM8766_RDA2, 272 + WM8766_LDA3, WM8766_RDA3, 273 + }; 274 + struct xonar_wm87x6 *data = chip->model_data; 275 + unsigned int i; 276 + u8 to_change; 277 + 278 + update_wm8776_volume(chip); 279 + if (chip->dac_volume[2] == chip->dac_volume[3] && 280 + chip->dac_volume[2] == chip->dac_volume[4] && 281 + chip->dac_volume[2] == chip->dac_volume[5] && 282 + chip->dac_volume[2] == chip->dac_volume[6] && 283 + chip->dac_volume[2] == chip->dac_volume[7]) { 284 + to_change = 0; 285 + for (i = 0; i < 6; ++i) 286 + if (chip->dac_volume[2] != 287 + data->wm8766_regs[wm8766_regs[i]]) 288 + to_change = 1; 289 + if (to_change) { 290 + wm8766_write(chip, WM8766_MASTDA, 291 + chip->dac_volume[2] | WM8766_UPDATE); 292 + for (i = 0; i < 6; ++i) 293 + data->wm8766_regs[wm8766_regs[i]] = 294 + chip->dac_volume[2]; 295 + } 296 + } else { 297 + to_change = 0; 298 + for (i = 0; i < 6; ++i) 299 + to_change |= (chip->dac_volume[2 + i] != 300 + data->wm8766_regs[wm8766_regs[i]]) << i; 301 + for (i = 0; i < 6; ++i) 302 + if (to_change & (1 << i)) 303 + wm8766_write(chip, wm8766_regs[i], 304 + chip->dac_volume[2 + i] | 305 + ((to_change & (0x3e << i)) 306 + ? 0 : WM8766_UPDATE)); 307 + } 308 + } 309 + 310 + static void update_wm8776_mute(struct oxygen *chip) 311 + { 312 + wm8776_write_cached(chip, WM8776_DACMUTE, 313 + chip->dac_mute ? WM8776_DMUTE : 0); 314 + } 315 + 316 + static void update_wm87x6_mute(struct oxygen *chip) 317 + { 318 + update_wm8776_mute(chip); 319 + wm8766_write_cached(chip, WM8766_DAC_CTRL2, WM8766_ZCD | 320 + (chip->dac_mute ? WM8766_DMUTE_MASK : 0)); 321 + } 322 + 323 + static void xonar_ds_gpio_changed(struct oxygen *chip) 324 + { 325 + u16 bits; 326 + 327 + bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); 328 + snd_printk(KERN_INFO "HP detect: %d\n", !!(bits & GPIO_DS_HP_DETECT)); 329 + } 330 + 331 + static int wm8776_bit_switch_get(struct snd_kcontrol *ctl, 332 + struct snd_ctl_elem_value *value) 333 + { 334 + struct oxygen *chip = ctl->private_data; 335 + struct xonar_wm87x6 *data = chip->model_data; 336 + u16 bit = ctl->private_value & 0xffff; 337 + unsigned int reg_index = (ctl->private_value >> 16) & 0xff; 338 + bool invert = (ctl->private_value >> 24) & 1; 339 + 340 + value->value.integer.value[0] = 341 + ((data->wm8776_regs[reg_index] & bit) != 0) ^ invert; 342 + return 0; 343 + } 344 + 345 + static int wm8776_bit_switch_put(struct snd_kcontrol *ctl, 346 + struct snd_ctl_elem_value *value) 347 + { 348 + struct oxygen *chip = ctl->private_data; 349 + struct xonar_wm87x6 *data = chip->model_data; 350 + u16 bit = ctl->private_value & 0xffff; 351 + u16 reg_value; 352 + unsigned int reg_index = (ctl->private_value >> 16) & 0xff; 353 + bool invert = (ctl->private_value >> 24) & 1; 354 + int changed; 355 + 356 + mutex_lock(&chip->mutex); 357 + reg_value = data->wm8776_regs[reg_index] & ~bit; 358 + if (value->value.integer.value[0] ^ invert) 359 + reg_value |= bit; 360 + changed = reg_value != data->wm8776_regs[reg_index]; 361 + if (changed) 362 + wm8776_write(chip, reg_index, reg_value); 363 + mutex_unlock(&chip->mutex); 364 + return changed; 365 + } 366 + 367 + static int wm8776_field_enum_info(struct snd_kcontrol *ctl, 368 + struct snd_ctl_elem_info *info) 369 + { 370 + static const char *const hld[16] = { 371 + "0 ms", "2.67 ms", "5.33 ms", "10.6 ms", 372 + "21.3 ms", "42.7 ms", "85.3 ms", "171 ms", 373 + "341 ms", "683 ms", "1.37 s", "2.73 s", 374 + "5.46 s", "10.9 s", "21.8 s", "43.7 s", 375 + }; 376 + static const char *const atk_lim[11] = { 377 + "0.25 ms", "0.5 ms", "1 ms", "2 ms", 378 + "4 ms", "8 ms", "16 ms", "32 ms", 379 + "64 ms", "128 ms", "256 ms", 380 + }; 381 + static const char *const atk_alc[11] = { 382 + "8.40 ms", "16.8 ms", "33.6 ms", "67.2 ms", 383 + "134 ms", "269 ms", "538 ms", "1.08 s", 384 + "2.15 s", "4.3 s", "8.6 s", 385 + }; 386 + static const char *const dcy_lim[11] = { 387 + "1.2 ms", "2.4 ms", "4.8 ms", "9.6 ms", 388 + "19.2 ms", "38.4 ms", "76.8 ms", "154 ms", 389 + "307 ms", "614 ms", "1.23 s", 390 + }; 391 + static const char *const dcy_alc[11] = { 392 + "33.5 ms", "67.0 ms", "134 ms", "268 ms", 393 + "536 ms", "1.07 s", "2.14 s", "4.29 s", 394 + "8.58 s", "17.2 s", "34.3 s", 395 + }; 396 + static const char *const tranwin[8] = { 397 + "0 us", "62.5 us", "125 us", "250 us", 398 + "500 us", "1 ms", "2 ms", "4 ms", 399 + }; 400 + u8 max; 401 + const char *const *names; 402 + 403 + max = (ctl->private_value >> 12) & 0xf; 404 + info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 405 + info->count = 1; 406 + info->value.enumerated.items = max + 1; 407 + if (info->value.enumerated.item > max) 408 + info->value.enumerated.item = max; 409 + switch ((ctl->private_value >> 24) & 0x1f) { 410 + case WM8776_ALCCTRL2: 411 + names = hld; 412 + break; 413 + case WM8776_ALCCTRL3: 414 + if (((ctl->private_value >> 20) & 0xf) == 0) { 415 + if (ctl->private_value & LC_CONTROL_LIMITER) 416 + names = atk_lim; 417 + else 418 + names = atk_alc; 419 + } else { 420 + if (ctl->private_value & LC_CONTROL_LIMITER) 421 + names = dcy_lim; 422 + else 423 + names = dcy_alc; 424 + } 425 + break; 426 + case WM8776_LIMITER: 427 + names = tranwin; 428 + break; 429 + default: 430 + return -ENXIO; 431 + } 432 + strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); 433 + return 0; 434 + } 435 + 436 + static int wm8776_field_volume_info(struct snd_kcontrol *ctl, 437 + struct snd_ctl_elem_info *info) 438 + { 439 + info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 440 + info->count = 1; 441 + info->value.integer.min = (ctl->private_value >> 8) & 0xf; 442 + info->value.integer.max = (ctl->private_value >> 12) & 0xf; 443 + return 0; 444 + } 445 + 446 + static void wm8776_field_set_from_ctl(struct snd_kcontrol *ctl) 447 + { 448 + struct oxygen *chip = ctl->private_data; 449 + struct xonar_wm87x6 *data = chip->model_data; 450 + unsigned int value, reg_index, mode; 451 + u8 min, max, shift; 452 + u16 mask, reg_value; 453 + bool invert; 454 + 455 + if ((data->wm8776_regs[WM8776_ALCCTRL1] & WM8776_LCSEL_MASK) == 456 + WM8776_LCSEL_LIMITER) 457 + mode = LC_CONTROL_LIMITER; 458 + else 459 + mode = LC_CONTROL_ALC; 460 + if (!(ctl->private_value & mode)) 461 + return; 462 + 463 + value = ctl->private_value & 0xf; 464 + min = (ctl->private_value >> 8) & 0xf; 465 + max = (ctl->private_value >> 12) & 0xf; 466 + mask = (ctl->private_value >> 16) & 0xf; 467 + shift = (ctl->private_value >> 20) & 0xf; 468 + reg_index = (ctl->private_value >> 24) & 0x1f; 469 + invert = (ctl->private_value >> 29) & 0x1; 470 + 471 + if (invert) 472 + value = max - (value - min); 473 + reg_value = data->wm8776_regs[reg_index]; 474 + reg_value &= ~(mask << shift); 475 + reg_value |= value << shift; 476 + wm8776_write_cached(chip, reg_index, reg_value); 477 + } 478 + 479 + static int wm8776_field_set(struct snd_kcontrol *ctl, unsigned int value) 480 + { 481 + struct oxygen *chip = ctl->private_data; 482 + u8 min, max; 483 + int changed; 484 + 485 + min = (ctl->private_value >> 8) & 0xf; 486 + max = (ctl->private_value >> 12) & 0xf; 487 + if (value < min || value > max) 488 + return -EINVAL; 489 + mutex_lock(&chip->mutex); 490 + changed = value != (ctl->private_value & 0xf); 491 + if (changed) { 492 + ctl->private_value = (ctl->private_value & ~0xf) | value; 493 + wm8776_field_set_from_ctl(ctl); 494 + } 495 + mutex_unlock(&chip->mutex); 496 + return changed; 497 + } 498 + 499 + static int wm8776_field_enum_get(struct snd_kcontrol *ctl, 500 + struct snd_ctl_elem_value *value) 501 + { 502 + value->value.enumerated.item[0] = ctl->private_value & 0xf; 503 + return 0; 504 + } 505 + 506 + static int wm8776_field_volume_get(struct snd_kcontrol *ctl, 507 + struct snd_ctl_elem_value *value) 508 + { 509 + value->value.integer.value[0] = ctl->private_value & 0xf; 510 + return 0; 511 + } 512 + 513 + static int wm8776_field_enum_put(struct snd_kcontrol *ctl, 514 + struct snd_ctl_elem_value *value) 515 + { 516 + return wm8776_field_set(ctl, value->value.enumerated.item[0]); 517 + } 518 + 519 + static int wm8776_field_volume_put(struct snd_kcontrol *ctl, 520 + struct snd_ctl_elem_value *value) 521 + { 522 + return wm8776_field_set(ctl, value->value.integer.value[0]); 523 + } 524 + 525 + static int wm8776_hp_vol_info(struct snd_kcontrol *ctl, 526 + struct snd_ctl_elem_info *info) 527 + { 528 + info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 529 + info->count = 2; 530 + info->value.integer.min = 0x79 - 60; 531 + info->value.integer.max = 0x7f; 532 + return 0; 533 + } 534 + 535 + static int wm8776_hp_vol_get(struct snd_kcontrol *ctl, 536 + struct snd_ctl_elem_value *value) 537 + { 538 + struct oxygen *chip = ctl->private_data; 539 + struct xonar_wm87x6 *data = chip->model_data; 540 + 541 + mutex_lock(&chip->mutex); 542 + value->value.integer.value[0] = 543 + data->wm8776_regs[WM8776_HPLVOL] & WM8776_HPATT_MASK; 544 + value->value.integer.value[1] = 545 + data->wm8776_regs[WM8776_HPRVOL] & WM8776_HPATT_MASK; 546 + mutex_unlock(&chip->mutex); 547 + return 0; 548 + } 549 + 550 + static int wm8776_hp_vol_put(struct snd_kcontrol *ctl, 551 + struct snd_ctl_elem_value *value) 552 + { 553 + struct oxygen *chip = ctl->private_data; 554 + struct xonar_wm87x6 *data = chip->model_data; 555 + u8 to_update; 556 + 557 + mutex_lock(&chip->mutex); 558 + to_update = (value->value.integer.value[0] != 559 + (data->wm8776_regs[WM8776_HPLVOL] & WM8776_HPATT_MASK)) 560 + << 0; 561 + to_update |= (value->value.integer.value[1] != 562 + (data->wm8776_regs[WM8776_HPRVOL] & WM8776_HPATT_MASK)) 563 + << 1; 564 + if (value->value.integer.value[0] == value->value.integer.value[1]) { 565 + if (to_update) { 566 + wm8776_write(chip, WM8776_HPMASTER, 567 + value->value.integer.value[0] | 568 + WM8776_HPZCEN | WM8776_UPDATE); 569 + data->wm8776_regs[WM8776_HPLVOL] = 570 + value->value.integer.value[0] | WM8776_HPZCEN; 571 + data->wm8776_regs[WM8776_HPRVOL] = 572 + value->value.integer.value[0] | WM8776_HPZCEN; 573 + } 574 + } else { 575 + if (to_update & 1) 576 + wm8776_write(chip, WM8776_HPLVOL, 577 + value->value.integer.value[0] | 578 + WM8776_HPZCEN | 579 + ((to_update & 2) ? 0 : WM8776_UPDATE)); 580 + if (to_update & 2) 581 + wm8776_write(chip, WM8776_HPRVOL, 582 + value->value.integer.value[1] | 583 + WM8776_HPZCEN | WM8776_UPDATE); 584 + } 585 + mutex_unlock(&chip->mutex); 586 + return to_update != 0; 587 + } 588 + 589 + static int wm8776_input_mux_get(struct snd_kcontrol *ctl, 590 + struct snd_ctl_elem_value *value) 591 + { 592 + struct oxygen *chip = ctl->private_data; 593 + struct xonar_wm87x6 *data = chip->model_data; 594 + unsigned int mux_bit = ctl->private_value; 595 + 596 + value->value.integer.value[0] = 597 + !!(data->wm8776_regs[WM8776_ADCMUX] & mux_bit); 598 + return 0; 599 + } 600 + 601 + static int wm8776_input_mux_put(struct snd_kcontrol *ctl, 602 + struct snd_ctl_elem_value *value) 603 + { 604 + struct oxygen *chip = ctl->private_data; 605 + struct xonar_wm87x6 *data = chip->model_data; 606 + unsigned int mux_bit = ctl->private_value; 607 + u16 reg; 608 + int changed; 609 + 610 + mutex_lock(&chip->mutex); 611 + reg = data->wm8776_regs[WM8776_ADCMUX]; 612 + if (value->value.integer.value[0]) { 613 + reg &= ~0x003; 614 + reg |= mux_bit; 615 + } else 616 + reg &= ~mux_bit; 617 + changed = reg != data->wm8776_regs[WM8776_ADCMUX]; 618 + if (changed) { 619 + oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, 620 + reg & 1 ? GPIO_DS_INPUT_ROUTE : 0, 621 + GPIO_DS_INPUT_ROUTE); 622 + wm8776_write(chip, WM8776_ADCMUX, reg); 623 + } 624 + mutex_unlock(&chip->mutex); 625 + return changed; 626 + } 627 + 628 + static int wm8776_input_vol_info(struct snd_kcontrol *ctl, 629 + struct snd_ctl_elem_info *info) 630 + { 631 + info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 632 + info->count = 2; 633 + info->value.integer.min = 0xa5; 634 + info->value.integer.max = 0xff; 635 + return 0; 636 + } 637 + 638 + static int wm8776_input_vol_get(struct snd_kcontrol *ctl, 639 + struct snd_ctl_elem_value *value) 640 + { 641 + struct oxygen *chip = ctl->private_data; 642 + struct xonar_wm87x6 *data = chip->model_data; 643 + 644 + mutex_lock(&chip->mutex); 645 + value->value.integer.value[0] = 646 + data->wm8776_regs[WM8776_ADCLVOL] & WM8776_AGMASK; 647 + value->value.integer.value[1] = 648 + data->wm8776_regs[WM8776_ADCRVOL] & WM8776_AGMASK; 649 + mutex_unlock(&chip->mutex); 650 + return 0; 651 + } 652 + 653 + static int wm8776_input_vol_put(struct snd_kcontrol *ctl, 654 + struct snd_ctl_elem_value *value) 655 + { 656 + struct oxygen *chip = ctl->private_data; 657 + struct xonar_wm87x6 *data = chip->model_data; 658 + int changed = 0; 659 + 660 + mutex_lock(&chip->mutex); 661 + changed = (value->value.integer.value[0] != 662 + (data->wm8776_regs[WM8776_ADCLVOL] & WM8776_AGMASK)) || 663 + (value->value.integer.value[1] != 664 + (data->wm8776_regs[WM8776_ADCRVOL] & WM8776_AGMASK)); 665 + wm8776_write_cached(chip, WM8776_ADCLVOL, 666 + value->value.integer.value[0] | WM8776_ZCA); 667 + wm8776_write_cached(chip, WM8776_ADCRVOL, 668 + value->value.integer.value[1] | WM8776_ZCA); 669 + mutex_unlock(&chip->mutex); 670 + return changed; 671 + } 672 + 673 + static int wm8776_level_control_info(struct snd_kcontrol *ctl, 674 + struct snd_ctl_elem_info *info) 675 + { 676 + static const char *const names[3] = { 677 + "None", "Peak Limiter", "Automatic Level Control" 678 + }; 679 + info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 680 + info->count = 1; 681 + info->value.enumerated.items = 3; 682 + if (info->value.enumerated.item >= 3) 683 + info->value.enumerated.item = 2; 684 + strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); 685 + return 0; 686 + } 687 + 688 + static int wm8776_level_control_get(struct snd_kcontrol *ctl, 689 + struct snd_ctl_elem_value *value) 690 + { 691 + struct oxygen *chip = ctl->private_data; 692 + struct xonar_wm87x6 *data = chip->model_data; 693 + 694 + if (!(data->wm8776_regs[WM8776_ALCCTRL2] & WM8776_LCEN)) 695 + value->value.enumerated.item[0] = 0; 696 + else if ((data->wm8776_regs[WM8776_ALCCTRL1] & WM8776_LCSEL_MASK) == 697 + WM8776_LCSEL_LIMITER) 698 + value->value.enumerated.item[0] = 1; 699 + else 700 + value->value.enumerated.item[0] = 2; 701 + return 0; 702 + } 703 + 704 + static void activate_control(struct oxygen *chip, 705 + struct snd_kcontrol *ctl, unsigned int mode) 706 + { 707 + unsigned int access; 708 + 709 + if (ctl->private_value & mode) 710 + access = 0; 711 + else 712 + access = SNDRV_CTL_ELEM_ACCESS_INACTIVE; 713 + if ((ctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_INACTIVE) != access) { 714 + ctl->vd[0].access ^= SNDRV_CTL_ELEM_ACCESS_INACTIVE; 715 + snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); 716 + } 717 + } 718 + 719 + static int wm8776_level_control_put(struct snd_kcontrol *ctl, 720 + struct snd_ctl_elem_value *value) 721 + { 722 + struct oxygen *chip = ctl->private_data; 723 + struct xonar_wm87x6 *data = chip->model_data; 724 + unsigned int mode = 0, i; 725 + u16 ctrl1, ctrl2; 726 + int changed; 727 + 728 + if (value->value.enumerated.item[0] >= 3) 729 + return -EINVAL; 730 + mutex_lock(&chip->mutex); 731 + changed = value->value.enumerated.item[0] != ctl->private_value; 732 + if (changed) { 733 + ctl->private_value = value->value.enumerated.item[0]; 734 + ctrl1 = data->wm8776_regs[WM8776_ALCCTRL1]; 735 + ctrl2 = data->wm8776_regs[WM8776_ALCCTRL2]; 736 + switch (value->value.enumerated.item[0]) { 737 + default: 738 + wm8776_write_cached(chip, WM8776_ALCCTRL2, 739 + ctrl2 & ~WM8776_LCEN); 740 + break; 741 + case 1: 742 + wm8776_write_cached(chip, WM8776_ALCCTRL1, 743 + (ctrl1 & ~WM8776_LCSEL_MASK) | 744 + WM8776_LCSEL_LIMITER); 745 + wm8776_write_cached(chip, WM8776_ALCCTRL2, 746 + ctrl2 | WM8776_LCEN); 747 + mode = LC_CONTROL_LIMITER; 748 + break; 749 + case 2: 750 + wm8776_write_cached(chip, WM8776_ALCCTRL1, 751 + (ctrl1 & ~WM8776_LCSEL_MASK) | 752 + WM8776_LCSEL_ALC_STEREO); 753 + wm8776_write_cached(chip, WM8776_ALCCTRL2, 754 + ctrl2 | WM8776_LCEN); 755 + mode = LC_CONTROL_ALC; 756 + break; 757 + } 758 + for (i = 0; i < ARRAY_SIZE(data->lc_controls); ++i) 759 + activate_control(chip, data->lc_controls[i], mode); 760 + } 761 + mutex_unlock(&chip->mutex); 762 + return changed; 763 + } 764 + 765 + static int hpf_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) 766 + { 767 + static const char *const names[2] = { 768 + "None", "High-pass Filter" 769 + }; 770 + 771 + info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 772 + info->count = 1; 773 + info->value.enumerated.items = 2; 774 + if (info->value.enumerated.item >= 2) 775 + info->value.enumerated.item = 1; 776 + strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); 777 + return 0; 778 + } 779 + 780 + static int hpf_get(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) 781 + { 782 + struct oxygen *chip = ctl->private_data; 783 + struct xonar_wm87x6 *data = chip->model_data; 784 + 785 + value->value.enumerated.item[0] = 786 + !(data->wm8776_regs[WM8776_ADCIFCTRL] & WM8776_ADCHPD); 787 + return 0; 788 + } 789 + 790 + static int hpf_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) 791 + { 792 + struct oxygen *chip = ctl->private_data; 793 + struct xonar_wm87x6 *data = chip->model_data; 794 + unsigned int reg; 795 + int changed; 796 + 797 + mutex_lock(&chip->mutex); 798 + reg = data->wm8776_regs[WM8776_ADCIFCTRL] & ~WM8776_ADCHPD; 799 + if (!value->value.enumerated.item[0]) 800 + reg |= WM8776_ADCHPD; 801 + changed = reg != data->wm8776_regs[WM8776_ADCIFCTRL]; 802 + if (changed) 803 + wm8776_write(chip, WM8776_ADCIFCTRL, reg); 804 + mutex_unlock(&chip->mutex); 805 + return changed; 806 + } 807 + 808 + #define WM8776_BIT_SWITCH(xname, reg, bit, invert, flags) { \ 809 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 810 + .name = xname, \ 811 + .info = snd_ctl_boolean_mono_info, \ 812 + .get = wm8776_bit_switch_get, \ 813 + .put = wm8776_bit_switch_put, \ 814 + .private_value = ((reg) << 16) | (bit) | ((invert) << 24) | (flags), \ 815 + } 816 + #define _WM8776_FIELD_CTL(xname, reg, shift, initval, min, max, mask, flags) \ 817 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 818 + .name = xname, \ 819 + .private_value = (initval) | ((min) << 8) | ((max) << 12) | \ 820 + ((mask) << 16) | ((shift) << 20) | ((reg) << 24) | (flags) 821 + #define WM8776_FIELD_CTL_ENUM(xname, reg, shift, init, min, max, mask, flags) {\ 822 + _WM8776_FIELD_CTL(xname " Capture Enum", \ 823 + reg, shift, init, min, max, mask, flags), \ 824 + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ 825 + SNDRV_CTL_ELEM_ACCESS_INACTIVE, \ 826 + .info = wm8776_field_enum_info, \ 827 + .get = wm8776_field_enum_get, \ 828 + .put = wm8776_field_enum_put, \ 829 + } 830 + #define WM8776_FIELD_CTL_VOLUME(a, b, c, d, e, f, g, h, tlv_p) { \ 831 + _WM8776_FIELD_CTL(a " Capture Volume", b, c, d, e, f, g, h), \ 832 + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ 833 + SNDRV_CTL_ELEM_ACCESS_INACTIVE | \ 834 + SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ 835 + .info = wm8776_field_volume_info, \ 836 + .get = wm8776_field_volume_get, \ 837 + .put = wm8776_field_volume_put, \ 838 + .tlv = { .p = tlv_p }, \ 839 + } 840 + 841 + static const DECLARE_TLV_DB_SCALE(wm87x6_dac_db_scale, -6000, 50, 0); 842 + static const DECLARE_TLV_DB_SCALE(wm8776_adc_db_scale, -2100, 50, 0); 843 + static const DECLARE_TLV_DB_SCALE(wm8776_hp_db_scale, -6000, 100, 0); 844 + static const DECLARE_TLV_DB_SCALE(wm8776_lct_db_scale, -1600, 100, 0); 845 + static const DECLARE_TLV_DB_SCALE(wm8776_maxgain_db_scale, 0, 400, 0); 846 + static const DECLARE_TLV_DB_SCALE(wm8776_ngth_db_scale, -7800, 600, 0); 847 + static const DECLARE_TLV_DB_SCALE(wm8776_maxatten_lim_db_scale, -1200, 100, 0); 848 + static const DECLARE_TLV_DB_SCALE(wm8776_maxatten_alc_db_scale, -2100, 400, 0); 849 + 850 + static const struct snd_kcontrol_new ds_controls[] = { 851 + { 852 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 853 + .name = "Headphone Playback Volume", 854 + .info = wm8776_hp_vol_info, 855 + .get = wm8776_hp_vol_get, 856 + .put = wm8776_hp_vol_put, 857 + .tlv = { .p = wm8776_hp_db_scale }, 858 + }, 859 + WM8776_BIT_SWITCH("Headphone Playback Switch", 860 + WM8776_PWRDOWN, WM8776_HPPD, 1, 0), 861 + { 862 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 863 + .name = "Input Capture Volume", 864 + .info = wm8776_input_vol_info, 865 + .get = wm8776_input_vol_get, 866 + .put = wm8776_input_vol_put, 867 + .tlv = { .p = wm8776_adc_db_scale }, 868 + }, 869 + { 870 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 871 + .name = "Line Capture Switch", 872 + .info = snd_ctl_boolean_mono_info, 873 + .get = wm8776_input_mux_get, 874 + .put = wm8776_input_mux_put, 875 + .private_value = 1 << 0, 876 + }, 877 + { 878 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 879 + .name = "Mic Capture Switch", 880 + .info = snd_ctl_boolean_mono_info, 881 + .get = wm8776_input_mux_get, 882 + .put = wm8776_input_mux_put, 883 + .private_value = 1 << 1, 884 + }, 885 + WM8776_BIT_SWITCH("Aux", WM8776_ADCMUX, 1 << 2, 0, 0), 886 + { 887 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 888 + .name = "ADC Filter Capture Enum", 889 + .info = hpf_info, 890 + .get = hpf_get, 891 + .put = hpf_put, 892 + }, 893 + { 894 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 895 + .name = "Level Control Capture Enum", 896 + .info = wm8776_level_control_info, 897 + .get = wm8776_level_control_get, 898 + .put = wm8776_level_control_put, 899 + .private_value = 0, 900 + }, 901 + }; 902 + static const struct snd_kcontrol_new lc_controls[] = { 903 + WM8776_FIELD_CTL_VOLUME("Limiter Threshold", 904 + WM8776_ALCCTRL1, 0, 11, 0, 15, 0xf, 905 + LC_CONTROL_LIMITER, wm8776_lct_db_scale), 906 + WM8776_FIELD_CTL_ENUM("Limiter Attack Time", 907 + WM8776_ALCCTRL3, 0, 2, 0, 10, 0xf, 908 + LC_CONTROL_LIMITER), 909 + WM8776_FIELD_CTL_ENUM("Limiter Decay Time", 910 + WM8776_ALCCTRL3, 4, 3, 0, 10, 0xf, 911 + LC_CONTROL_LIMITER), 912 + WM8776_FIELD_CTL_ENUM("Limiter Transient Window", 913 + WM8776_LIMITER, 4, 2, 0, 7, 0x7, 914 + LC_CONTROL_LIMITER), 915 + WM8776_FIELD_CTL_VOLUME("Limiter Maximum Attenuation", 916 + WM8776_LIMITER, 0, 6, 3, 12, 0xf, 917 + LC_CONTROL_LIMITER, 918 + wm8776_maxatten_lim_db_scale), 919 + WM8776_FIELD_CTL_VOLUME("ALC Target Level", 920 + WM8776_ALCCTRL1, 0, 11, 0, 15, 0xf, 921 + LC_CONTROL_ALC, wm8776_lct_db_scale), 922 + WM8776_FIELD_CTL_ENUM("ALC Attack Time", 923 + WM8776_ALCCTRL3, 0, 2, 0, 10, 0xf, 924 + LC_CONTROL_ALC), 925 + WM8776_FIELD_CTL_ENUM("ALC Decay Time", 926 + WM8776_ALCCTRL3, 4, 3, 0, 10, 0xf, 927 + LC_CONTROL_ALC), 928 + WM8776_FIELD_CTL_VOLUME("ALC Maximum Gain", 929 + WM8776_ALCCTRL1, 4, 7, 1, 7, 0x7, 930 + LC_CONTROL_ALC, wm8776_maxgain_db_scale), 931 + WM8776_FIELD_CTL_VOLUME("ALC Maximum Attenuation", 932 + WM8776_LIMITER, 0, 10, 10, 15, 0xf, 933 + LC_CONTROL_ALC, wm8776_maxatten_alc_db_scale), 934 + WM8776_FIELD_CTL_ENUM("ALC Hold Time", 935 + WM8776_ALCCTRL2, 0, 0, 0, 15, 0xf, 936 + LC_CONTROL_ALC), 937 + WM8776_BIT_SWITCH("Noise Gate Capture Switch", 938 + WM8776_NOISEGATE, WM8776_NGAT, 0, 939 + LC_CONTROL_ALC), 940 + WM8776_FIELD_CTL_VOLUME("Noise Gate Threshold", 941 + WM8776_NOISEGATE, 2, 0, 0, 7, 0x7, 942 + LC_CONTROL_ALC, wm8776_ngth_db_scale), 943 + }; 944 + 945 + static int xonar_ds_control_filter(struct snd_kcontrol_new *template) 946 + { 947 + if (!strncmp(template->name, "CD Capture ", 11)) 948 + return 1; /* no CD input */ 949 + return 0; 950 + } 951 + 952 + static int xonar_ds_mixer_init(struct oxygen *chip) 953 + { 954 + struct xonar_wm87x6 *data = chip->model_data; 955 + unsigned int i; 956 + struct snd_kcontrol *ctl; 957 + int err; 958 + 959 + for (i = 0; i < ARRAY_SIZE(ds_controls); ++i) { 960 + ctl = snd_ctl_new1(&ds_controls[i], chip); 961 + if (!ctl) 962 + return -ENOMEM; 963 + err = snd_ctl_add(chip->card, ctl); 964 + if (err < 0) 965 + return err; 966 + } 967 + BUILD_BUG_ON(ARRAY_SIZE(lc_controls) != ARRAY_SIZE(data->lc_controls)); 968 + for (i = 0; i < ARRAY_SIZE(lc_controls); ++i) { 969 + ctl = snd_ctl_new1(&lc_controls[i], chip); 970 + if (!ctl) 971 + return -ENOMEM; 972 + err = snd_ctl_add(chip->card, ctl); 973 + if (err < 0) 974 + return err; 975 + data->lc_controls[i] = ctl; 976 + } 977 + return 0; 978 + } 979 + 980 + static const struct oxygen_model model_xonar_ds = { 981 + .shortname = "Xonar DS", 982 + .longname = "Asus Virtuoso 200", 983 + .chip = "AV200", 984 + .init = xonar_ds_init, 985 + .control_filter = xonar_ds_control_filter, 986 + .mixer_init = xonar_ds_mixer_init, 987 + .cleanup = xonar_ds_cleanup, 988 + .suspend = xonar_ds_suspend, 989 + .resume = xonar_ds_resume, 990 + .pcm_hardware_filter = wm8776_adc_hardware_filter, 991 + .get_i2s_mclk = oxygen_default_i2s_mclk, 992 + .set_dac_params = set_wm87x6_dac_params, 993 + .set_adc_params = set_wm8776_adc_params, 994 + .update_dac_volume = update_wm87x6_volume, 995 + .update_dac_mute = update_wm87x6_mute, 996 + .gpio_changed = xonar_ds_gpio_changed, 997 + .dac_tlv = wm87x6_dac_db_scale, 998 + .model_data_size = sizeof(struct xonar_wm87x6), 999 + .device_config = PLAYBACK_0_TO_I2S | 1000 + PLAYBACK_1_TO_SPDIF | 1001 + CAPTURE_0_FROM_I2S_1, 1002 + .dac_channels = 8, 1003 + .dac_volume_min = 255 - 2*60, 1004 + .dac_volume_max = 255, 1005 + .function_flags = OXYGEN_FUNCTION_SPI, 1006 + .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 1007 + .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 1008 + }; 1009 + 1010 + int __devinit get_xonar_wm87x6_model(struct oxygen *chip, 1011 + const struct pci_device_id *id) 1012 + { 1013 + switch (id->subdevice) { 1014 + case 0x838e: 1015 + chip->model = model_xonar_ds; 1016 + break; 1017 + default: 1018 + return -EINVAL; 1019 + } 1020 + return 0; 1021 + }
+1 -1
sound/pci/pcxhr/pcxhr.c
··· 94 94 PCI_ID_LAST 95 95 }; 96 96 97 - static struct pci_device_id pcxhr_ids[] = { 97 + static DEFINE_PCI_DEVICE_TABLE(pcxhr_ids) = { 98 98 { 0x10b5, 0x9656, 0x1369, 0xb001, 0, 0, PCI_ID_VX882HR, }, 99 99 { 0x10b5, 0x9656, 0x1369, 0xb101, 0, 0, PCI_ID_PCX882HR, }, 100 100 { 0x10b5, 0x9656, 0x1369, 0xb201, 0, 0, PCI_ID_VX881HR, },
+2 -2
sound/pci/riptide/riptide.c
··· 506 506 /* 507 507 */ 508 508 509 - static struct pci_device_id snd_riptide_ids[] = { 509 + static DEFINE_PCI_DEVICE_TABLE(snd_riptide_ids) = { 510 510 { PCI_DEVICE(0x127a, 0x4310) }, 511 511 { PCI_DEVICE(0x127a, 0x4320) }, 512 512 { PCI_DEVICE(0x127a, 0x4330) }, ··· 515 515 }; 516 516 517 517 #ifdef SUPPORT_JOYSTICK 518 - static struct pci_device_id snd_riptide_joystick_ids[] __devinitdata = { 518 + static DEFINE_PCI_DEVICE_TABLE(snd_riptide_joystick_ids) = { 519 519 { PCI_DEVICE(0x127a, 0x4312) }, 520 520 { PCI_DEVICE(0x127a, 0x4322) }, 521 521 { PCI_DEVICE(0x127a, 0x4332) },
+1 -1
sound/pci/rme32.c
··· 226 226 struct snd_kcontrol *spdif_ctl; 227 227 }; 228 228 229 - static struct pci_device_id snd_rme32_ids[] = { 229 + static DEFINE_PCI_DEVICE_TABLE(snd_rme32_ids) = { 230 230 {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32), 0,}, 231 231 {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_8), 0,}, 232 232 {PCI_VDEVICE(XILINX_RME, PCI_DEVICE_ID_RME_DIGI32_PRO), 0,},
+1 -1
sound/pci/rme96.c
··· 231 231 struct snd_kcontrol *spdif_ctl; 232 232 }; 233 233 234 - static struct pci_device_id snd_rme96_ids[] = { 234 + static DEFINE_PCI_DEVICE_TABLE(snd_rme96_ids) = { 235 235 { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96), 0, }, 236 236 { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8), 0, }, 237 237 { PCI_VDEVICE(XILINX, PCI_DEVICE_ID_RME_DIGI96_8_PRO), 0, },
+1 -1
sound/pci/rme9652/hdsp.c
··· 585 585 } 586 586 587 587 588 - static struct pci_device_id snd_hdsp_ids[] = { 588 + static DEFINE_PCI_DEVICE_TABLE(snd_hdsp_ids) = { 589 589 { 590 590 .vendor = PCI_VENDOR_ID_XILINX, 591 591 .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP,
+1 -1
sound/pci/rme9652/hdspm.c
··· 512 512 }; 513 513 514 514 515 - static struct pci_device_id snd_hdspm_ids[] __devinitdata = { 515 + static DEFINE_PCI_DEVICE_TABLE(snd_hdspm_ids) = { 516 516 { 517 517 .vendor = PCI_VENDOR_ID_XILINX, 518 518 .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI,
+1 -1
sound/pci/rme9652/rme9652.c
··· 314 314 } 315 315 316 316 317 - static struct pci_device_id snd_rme9652_ids[] = { 317 + static DEFINE_PCI_DEVICE_TABLE(snd_rme9652_ids) = { 318 318 { 319 319 .vendor = 0x10ee, 320 320 .device = 0x3fc4,
+1 -1
sound/pci/sis7019.c
··· 48 48 module_param(enable, bool, 0444); 49 49 MODULE_PARM_DESC(enable, "Enable SiS7019 Audio Accelerator."); 50 50 51 - static struct pci_device_id snd_sis7019_ids[] = { 51 + static DEFINE_PCI_DEVICE_TABLE(snd_sis7019_ids) = { 52 52 { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x7019) }, 53 53 { 0, } 54 54 };
+1 -1
sound/pci/sonicvibes.c
··· 242 242 #endif 243 243 }; 244 244 245 - static struct pci_device_id snd_sonic_ids[] = { 245 + static DEFINE_PCI_DEVICE_TABLE(snd_sonic_ids) = { 246 246 { PCI_VDEVICE(S3, 0xca00), 0, }, 247 247 { 0, } 248 248 };
+1 -1
sound/pci/trident/trident.c
··· 62 62 module_param_array(wavetable_size, int, NULL, 0444); 63 63 MODULE_PARM_DESC(wavetable_size, "Maximum memory size in kB for wavetable synth."); 64 64 65 - static struct pci_device_id snd_trident_ids[] = { 65 + static DEFINE_PCI_DEVICE_TABLE(snd_trident_ids) = { 66 66 {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX), 67 67 PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0}, 68 68 {PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_NX),
+1 -1
sound/pci/via82xx.c
··· 401 401 #endif 402 402 }; 403 403 404 - static struct pci_device_id snd_via82xx_ids[] = { 404 + static DEFINE_PCI_DEVICE_TABLE(snd_via82xx_ids) = { 405 405 /* 0x1106, 0x3058 */ 406 406 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C686_5), TYPE_CARD_VIA686, }, /* 686A */ 407 407 /* 0x1106, 0x3059 */
+1 -1
sound/pci/via82xx_modem.c
··· 260 260 struct snd_info_entry *proc_entry; 261 261 }; 262 262 263 - static struct pci_device_id snd_via82xx_modem_ids[] = { 263 + static DEFINE_PCI_DEVICE_TABLE(snd_via82xx_modem_ids) = { 264 264 { PCI_VDEVICE(VIA, 0x3068), TYPE_CARD_VIA82XX_MODEM, }, 265 265 { 0, } 266 266 };
+1 -1
sound/pci/vx222/vx222.c
··· 60 60 VX_PCI_VX222_NEW 61 61 }; 62 62 63 - static struct pci_device_id snd_vx222_ids[] = { 63 + static DEFINE_PCI_DEVICE_TABLE(snd_vx222_ids) = { 64 64 { 0x10b5, 0x9050, 0x1369, PCI_ANY_ID, 0, 0, VX_PCI_VX222_OLD, }, /* PLX */ 65 65 { 0x10b5, 0x9030, 0x1369, PCI_ANY_ID, 0, 0, VX_PCI_VX222_NEW, }, /* PLX */ 66 66 { 0, }
+1 -1
sound/pci/ymfpci/ymfpci.c
··· 66 66 module_param_array(rear_switch, bool, NULL, 0444); 67 67 MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch"); 68 68 69 - static struct pci_device_id snd_ymfpci_ids[] = { 69 + static DEFINE_PCI_DEVICE_TABLE(snd_ymfpci_ids) = { 70 70 { PCI_VDEVICE(YAMAHA, 0x0004), 0, }, /* YMF724 */ 71 71 { PCI_VDEVICE(YAMAHA, 0x000d), 0, }, /* YMF724F */ 72 72 { PCI_VDEVICE(YAMAHA, 0x000a), 0, }, /* YMF740 */
+5 -47
sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
··· 21 21 */ 22 22 23 23 #include <linux/slab.h> 24 - #include <linux/vmalloc.h> 25 24 #include <linux/delay.h> 26 25 #include <sound/core.h> 27 26 #include <sound/asoundef.h> 28 27 #include "pdaudiocf.h" 29 28 30 - 31 - /* 32 - * we use a vmalloc'ed (sg-)buffer 33 - */ 34 - 35 - /* get the physical page pointer on the given offset */ 36 - static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, unsigned long offset) 37 - { 38 - void *pageptr = subs->runtime->dma_area + offset; 39 - return vmalloc_to_page(pageptr); 40 - } 41 - 42 - /* 43 - * hw_params callback 44 - * NOTE: this may be called not only once per pcm open! 45 - */ 46 - static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) 47 - { 48 - struct snd_pcm_runtime *runtime = subs->runtime; 49 - if (runtime->dma_area) { 50 - if (runtime->dma_bytes >= size) 51 - return 0; /* already enough large */ 52 - vfree(runtime->dma_area); 53 - } 54 - runtime->dma_area = vmalloc_32_user(size); 55 - if (! runtime->dma_area) 56 - return -ENOMEM; 57 - runtime->dma_bytes = size; 58 - return 0; 59 - } 60 - 61 - /* 62 - * hw_free callback 63 - * NOTE: this may be called not only once per pcm open! 64 - */ 65 - static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) 66 - { 67 - struct snd_pcm_runtime *runtime = subs->runtime; 68 - 69 - vfree(runtime->dma_area); 70 - runtime->dma_area = NULL; 71 - return 0; 72 - } 73 29 74 30 /* 75 31 * clear the SRAM contents ··· 103 147 static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs, 104 148 struct snd_pcm_hw_params *hw_params) 105 149 { 106 - return snd_pcm_alloc_vmalloc_buffer(subs, params_buffer_bytes(hw_params)); 150 + return snd_pcm_lib_alloc_vmalloc_32_buffer 151 + (subs, params_buffer_bytes(hw_params)); 107 152 } 108 153 109 154 /* ··· 112 155 */ 113 156 static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs) 114 157 { 115 - return snd_pcm_free_vmalloc_buffer(subs); 158 + return snd_pcm_lib_free_vmalloc_buffer(subs); 116 159 } 117 160 118 161 /* ··· 276 319 .prepare = pdacf_pcm_prepare, 277 320 .trigger = pdacf_pcm_trigger, 278 321 .pointer = pdacf_pcm_capture_pointer, 279 - .page = snd_pcm_get_vmalloc_page, 322 + .page = snd_pcm_lib_get_vmalloc_page, 323 + .mmap = snd_pcm_lib_mmap_vmalloc, 280 324 }; 281 325 282 326
+12
sound/usb/Kconfig
··· 21 21 To compile this driver as a module, choose M here: the module 22 22 will be called snd-usb-audio. 23 23 24 + config SND_USB_UA101 25 + tristate "Edirol UA-101 driver (EXPERIMENTAL)" 26 + depends on EXPERIMENTAL 27 + select SND_PCM 28 + select SND_RAWMIDI 29 + help 30 + Say Y here to include support for the Edirol UA-101 audio/MIDI 31 + interface. 32 + 33 + To compile this driver as a module, choose M here: the module 34 + will be called snd-ua101. 35 + 24 36 config SND_USB_USX2Y 25 37 tristate "Tascam US-122, US-224 and US-428 USB driver" 26 38 depends on X86 || PPC || ALPHA
+2
sound/usb/Makefile
··· 4 4 5 5 snd-usb-audio-objs := usbaudio.o usbmixer.o 6 6 snd-usb-lib-objs := usbmidi.o 7 + snd-ua101-objs := ua101.o 7 8 8 9 # Toplevel Module Dependency 9 10 obj-$(CONFIG_SND_USB_AUDIO) += snd-usb-audio.o snd-usb-lib.o 11 + obj-$(CONFIG_SND_USB_UA101) += snd-ua101.o snd-usb-lib.o 10 12 obj-$(CONFIG_SND_USB_USX2Y) += snd-usb-lib.o 11 13 obj-$(CONFIG_SND_USB_US122L) += snd-usb-lib.o 12 14
+1421
sound/usb/ua101.c
··· 1 + /* 2 + * Edirol UA-101 driver 3 + * Copyright (c) Clemens Ladisch <clemens@ladisch.de> 4 + * 5 + * This driver is free software: you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License, version 2. 7 + * 8 + * This driver is distributed in the hope that it will be useful, 9 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 + * GNU General Public License for more details. 12 + * 13 + * You should have received a copy of the GNU General Public License 14 + * along with this driver. If not, see <http://www.gnu.org/licenses/>. 15 + */ 16 + 17 + #include <linux/init.h> 18 + #include <linux/module.h> 19 + #include <linux/slab.h> 20 + #include <linux/usb.h> 21 + #include <linux/usb/audio.h> 22 + #include <sound/core.h> 23 + #include <sound/initval.h> 24 + #include <sound/pcm.h> 25 + #include <sound/pcm_params.h> 26 + #include "usbaudio.h" 27 + 28 + MODULE_DESCRIPTION("Edirol UA-101 driver"); 29 + MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); 30 + MODULE_LICENSE("GPL v2"); 31 + MODULE_SUPPORTED_DEVICE("{{Edirol,UA-101}}"); 32 + 33 + /* I use my UA-1A for testing because I don't have a UA-101 ... */ 34 + #define UA1A_HACK 35 + 36 + /* 37 + * Should not be lower than the minimum scheduling delay of the host 38 + * controller. Some Intel controllers need more than one frame; as long as 39 + * that driver doesn't tell us about this, use 1.5 frames just to be sure. 40 + */ 41 + #define MIN_QUEUE_LENGTH 12 42 + /* Somewhat random. */ 43 + #define MAX_QUEUE_LENGTH 30 44 + /* 45 + * This magic value optimizes memory usage efficiency for the UA-101's packet 46 + * sizes at all sample rates, taking into account the stupid cache pool sizes 47 + * that usb_buffer_alloc() uses. 48 + */ 49 + #define DEFAULT_QUEUE_LENGTH 21 50 + 51 + #define MAX_PACKET_SIZE 672 /* hardware specific */ 52 + #define MAX_MEMORY_BUFFERS DIV_ROUND_UP(MAX_QUEUE_LENGTH, \ 53 + PAGE_SIZE / MAX_PACKET_SIZE) 54 + 55 + static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 56 + static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 57 + static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 58 + static unsigned int queue_length = 21; 59 + 60 + module_param_array(index, int, NULL, 0444); 61 + MODULE_PARM_DESC(index, "card index"); 62 + module_param_array(id, charp, NULL, 0444); 63 + MODULE_PARM_DESC(id, "ID string"); 64 + module_param_array(enable, bool, NULL, 0444); 65 + MODULE_PARM_DESC(enable, "enable card"); 66 + module_param(queue_length, uint, 0644); 67 + MODULE_PARM_DESC(queue_length, "USB queue length in microframes, " 68 + __stringify(MIN_QUEUE_LENGTH)"-"__stringify(MAX_QUEUE_LENGTH)); 69 + 70 + enum { 71 + INTF_PLAYBACK, 72 + INTF_CAPTURE, 73 + INTF_MIDI, 74 + 75 + INTF_COUNT 76 + }; 77 + 78 + /* bits in struct ua101::states */ 79 + enum { 80 + USB_CAPTURE_RUNNING, 81 + USB_PLAYBACK_RUNNING, 82 + ALSA_CAPTURE_OPEN, 83 + ALSA_PLAYBACK_OPEN, 84 + ALSA_CAPTURE_RUNNING, 85 + ALSA_PLAYBACK_RUNNING, 86 + CAPTURE_URB_COMPLETED, 87 + PLAYBACK_URB_COMPLETED, 88 + DISCONNECTED, 89 + }; 90 + 91 + struct ua101 { 92 + struct usb_device *dev; 93 + struct snd_card *card; 94 + struct usb_interface *intf[INTF_COUNT]; 95 + int card_index; 96 + struct snd_pcm *pcm; 97 + struct list_head midi_list; 98 + u64 format_bit; 99 + unsigned int rate; 100 + unsigned int packets_per_second; 101 + spinlock_t lock; 102 + struct mutex mutex; 103 + unsigned long states; 104 + 105 + /* FIFO to synchronize playback rate to capture rate */ 106 + unsigned int rate_feedback_start; 107 + unsigned int rate_feedback_count; 108 + u8 rate_feedback[MAX_QUEUE_LENGTH]; 109 + 110 + struct list_head ready_playback_urbs; 111 + struct tasklet_struct playback_tasklet; 112 + wait_queue_head_t alsa_capture_wait; 113 + wait_queue_head_t rate_feedback_wait; 114 + wait_queue_head_t alsa_playback_wait; 115 + struct ua101_stream { 116 + struct snd_pcm_substream *substream; 117 + unsigned int usb_pipe; 118 + unsigned int channels; 119 + unsigned int frame_bytes; 120 + unsigned int max_packet_bytes; 121 + unsigned int period_pos; 122 + unsigned int buffer_pos; 123 + unsigned int queue_length; 124 + struct ua101_urb { 125 + struct urb urb; 126 + struct usb_iso_packet_descriptor iso_frame_desc[1]; 127 + struct list_head ready_list; 128 + } *urbs[MAX_QUEUE_LENGTH]; 129 + struct { 130 + unsigned int size; 131 + void *addr; 132 + dma_addr_t dma; 133 + } buffers[MAX_MEMORY_BUFFERS]; 134 + } capture, playback; 135 + 136 + unsigned int fps[10]; 137 + unsigned int frame_counter; 138 + }; 139 + 140 + static DEFINE_MUTEX(devices_mutex); 141 + static unsigned int devices_used; 142 + static struct usb_driver ua101_driver; 143 + 144 + static void abort_alsa_playback(struct ua101 *ua); 145 + static void abort_alsa_capture(struct ua101 *ua); 146 + 147 + static const char *usb_error_string(int err) 148 + { 149 + switch (err) { 150 + case -ENODEV: 151 + return "no device"; 152 + case -ENOENT: 153 + return "endpoint not enabled"; 154 + case -EPIPE: 155 + return "endpoint stalled"; 156 + case -ENOSPC: 157 + return "not enough bandwidth"; 158 + case -ESHUTDOWN: 159 + return "device disabled"; 160 + case -EHOSTUNREACH: 161 + return "device suspended"; 162 + case -EINVAL: 163 + case -EAGAIN: 164 + case -EFBIG: 165 + case -EMSGSIZE: 166 + return "internal error"; 167 + default: 168 + return "unknown error"; 169 + } 170 + } 171 + 172 + static void abort_usb_capture(struct ua101 *ua) 173 + { 174 + if (test_and_clear_bit(USB_CAPTURE_RUNNING, &ua->states)) { 175 + wake_up(&ua->alsa_capture_wait); 176 + wake_up(&ua->rate_feedback_wait); 177 + } 178 + } 179 + 180 + static void abort_usb_playback(struct ua101 *ua) 181 + { 182 + if (test_and_clear_bit(USB_PLAYBACK_RUNNING, &ua->states)) 183 + wake_up(&ua->alsa_playback_wait); 184 + } 185 + 186 + static void playback_urb_complete(struct urb *usb_urb) 187 + { 188 + struct ua101_urb *urb = (struct ua101_urb *)usb_urb; 189 + struct ua101 *ua = urb->urb.context; 190 + unsigned long flags; 191 + 192 + if (unlikely(urb->urb.status == -ENOENT || /* unlinked */ 193 + urb->urb.status == -ENODEV || /* device removed */ 194 + urb->urb.status == -ECONNRESET || /* unlinked */ 195 + urb->urb.status == -ESHUTDOWN)) { /* device disabled */ 196 + abort_usb_playback(ua); 197 + abort_alsa_playback(ua); 198 + return; 199 + } 200 + 201 + if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) { 202 + /* append URB to FIFO */ 203 + spin_lock_irqsave(&ua->lock, flags); 204 + list_add_tail(&urb->ready_list, &ua->ready_playback_urbs); 205 + if (ua->rate_feedback_count > 0) 206 + tasklet_schedule(&ua->playback_tasklet); 207 + ua->playback.substream->runtime->delay -= 208 + urb->urb.iso_frame_desc[0].length / 209 + ua->playback.frame_bytes; 210 + spin_unlock_irqrestore(&ua->lock, flags); 211 + } 212 + } 213 + 214 + static void first_playback_urb_complete(struct urb *urb) 215 + { 216 + struct ua101 *ua = urb->context; 217 + 218 + urb->complete = playback_urb_complete; 219 + playback_urb_complete(urb); 220 + 221 + set_bit(PLAYBACK_URB_COMPLETED, &ua->states); 222 + wake_up(&ua->alsa_playback_wait); 223 + } 224 + 225 + /* copy data from the ALSA ring buffer into the URB buffer */ 226 + static bool copy_playback_data(struct ua101_stream *stream, struct urb *urb, 227 + unsigned int frames) 228 + { 229 + struct snd_pcm_runtime *runtime; 230 + unsigned int frame_bytes, frames1; 231 + const u8 *source; 232 + 233 + runtime = stream->substream->runtime; 234 + frame_bytes = stream->frame_bytes; 235 + source = runtime->dma_area + stream->buffer_pos * frame_bytes; 236 + if (stream->buffer_pos + frames <= runtime->buffer_size) { 237 + memcpy(urb->transfer_buffer, source, frames * frame_bytes); 238 + } else { 239 + /* wrap around at end of ring buffer */ 240 + frames1 = runtime->buffer_size - stream->buffer_pos; 241 + memcpy(urb->transfer_buffer, source, frames1 * frame_bytes); 242 + memcpy(urb->transfer_buffer + frames1 * frame_bytes, 243 + runtime->dma_area, (frames - frames1) * frame_bytes); 244 + } 245 + 246 + stream->buffer_pos += frames; 247 + if (stream->buffer_pos >= runtime->buffer_size) 248 + stream->buffer_pos -= runtime->buffer_size; 249 + stream->period_pos += frames; 250 + if (stream->period_pos >= runtime->period_size) { 251 + stream->period_pos -= runtime->period_size; 252 + return true; 253 + } 254 + return false; 255 + } 256 + 257 + static inline void add_with_wraparound(struct ua101 *ua, 258 + unsigned int *value, unsigned int add) 259 + { 260 + *value += add; 261 + if (*value >= ua->playback.queue_length) 262 + *value -= ua->playback.queue_length; 263 + } 264 + 265 + static void playback_tasklet(unsigned long data) 266 + { 267 + struct ua101 *ua = (void *)data; 268 + unsigned long flags; 269 + unsigned int frames; 270 + struct ua101_urb *urb; 271 + bool do_period_elapsed = false; 272 + int err; 273 + 274 + if (unlikely(!test_bit(USB_PLAYBACK_RUNNING, &ua->states))) 275 + return; 276 + 277 + /* 278 + * Synchronizing the playback rate to the capture rate is done by using 279 + * the same sequence of packet sizes for both streams. 280 + * Submitting a playback URB therefore requires both a ready URB and 281 + * the size of the corresponding capture packet, i.e., both playback 282 + * and capture URBs must have been completed. Since the USB core does 283 + * not guarantee that playback and capture complete callbacks are 284 + * called alternately, we use two FIFOs for packet sizes and read URBs; 285 + * submitting playback URBs is possible as long as both FIFOs are 286 + * nonempty. 287 + */ 288 + spin_lock_irqsave(&ua->lock, flags); 289 + while (ua->rate_feedback_count > 0 && 290 + !list_empty(&ua->ready_playback_urbs)) { 291 + /* take packet size out of FIFO */ 292 + frames = ua->rate_feedback[ua->rate_feedback_start]; 293 + add_with_wraparound(ua, &ua->rate_feedback_start, 1); 294 + ua->rate_feedback_count--; 295 + 296 + /* take URB out of FIFO */ 297 + urb = list_first_entry(&ua->ready_playback_urbs, 298 + struct ua101_urb, ready_list); 299 + list_del(&urb->ready_list); 300 + 301 + /* fill packet with data or silence */ 302 + urb->urb.iso_frame_desc[0].length = 303 + frames * ua->playback.frame_bytes; 304 + if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) 305 + do_period_elapsed |= copy_playback_data(&ua->playback, 306 + &urb->urb, 307 + frames); 308 + else 309 + memset(urb->urb.transfer_buffer, 0, 310 + urb->urb.iso_frame_desc[0].length); 311 + 312 + /* and off you go ... */ 313 + err = usb_submit_urb(&urb->urb, GFP_ATOMIC); 314 + if (unlikely(err < 0)) { 315 + spin_unlock_irqrestore(&ua->lock, flags); 316 + abort_usb_playback(ua); 317 + abort_alsa_playback(ua); 318 + dev_err(&ua->dev->dev, "USB request error %d: %s\n", 319 + err, usb_error_string(err)); 320 + return; 321 + } 322 + ua->playback.substream->runtime->delay += frames; 323 + } 324 + spin_unlock_irqrestore(&ua->lock, flags); 325 + if (do_period_elapsed) 326 + snd_pcm_period_elapsed(ua->playback.substream); 327 + } 328 + 329 + /* copy data from the URB buffer into the ALSA ring buffer */ 330 + static bool copy_capture_data(struct ua101_stream *stream, struct urb *urb, 331 + unsigned int frames) 332 + { 333 + struct snd_pcm_runtime *runtime; 334 + unsigned int frame_bytes, frames1; 335 + u8 *dest; 336 + 337 + runtime = stream->substream->runtime; 338 + frame_bytes = stream->frame_bytes; 339 + dest = runtime->dma_area + stream->buffer_pos * frame_bytes; 340 + if (stream->buffer_pos + frames <= runtime->buffer_size) { 341 + memcpy(dest, urb->transfer_buffer, frames * frame_bytes); 342 + } else { 343 + /* wrap around at end of ring buffer */ 344 + frames1 = runtime->buffer_size - stream->buffer_pos; 345 + memcpy(dest, urb->transfer_buffer, frames1 * frame_bytes); 346 + memcpy(runtime->dma_area, 347 + urb->transfer_buffer + frames1 * frame_bytes, 348 + (frames - frames1) * frame_bytes); 349 + } 350 + 351 + stream->buffer_pos += frames; 352 + if (stream->buffer_pos >= runtime->buffer_size) 353 + stream->buffer_pos -= runtime->buffer_size; 354 + stream->period_pos += frames; 355 + if (stream->period_pos >= runtime->period_size) { 356 + stream->period_pos -= runtime->period_size; 357 + return true; 358 + } 359 + return false; 360 + } 361 + 362 + static void capture_urb_complete(struct urb *urb) 363 + { 364 + struct ua101 *ua = urb->context; 365 + struct ua101_stream *stream = &ua->capture; 366 + unsigned long flags; 367 + unsigned int frames, write_ptr; 368 + bool do_period_elapsed; 369 + int err; 370 + 371 + if (unlikely(urb->status == -ENOENT || /* unlinked */ 372 + urb->status == -ENODEV || /* device removed */ 373 + urb->status == -ECONNRESET || /* unlinked */ 374 + urb->status == -ESHUTDOWN)) /* device disabled */ 375 + goto stream_stopped; 376 + 377 + if (urb->status >= 0 && urb->iso_frame_desc[0].status >= 0) 378 + frames = urb->iso_frame_desc[0].actual_length / 379 + stream->frame_bytes; 380 + else 381 + frames = 0; 382 + 383 + spin_lock_irqsave(&ua->lock, flags); 384 + 385 + if (frames > 0 && test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) 386 + do_period_elapsed = copy_capture_data(stream, urb, frames); 387 + else 388 + do_period_elapsed = false; 389 + 390 + if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) { 391 + err = usb_submit_urb(urb, GFP_ATOMIC); 392 + if (unlikely(err < 0)) { 393 + spin_unlock_irqrestore(&ua->lock, flags); 394 + dev_err(&ua->dev->dev, "USB request error %d: %s\n", 395 + err, usb_error_string(err)); 396 + goto stream_stopped; 397 + } 398 + 399 + /* append packet size to FIFO */ 400 + write_ptr = ua->rate_feedback_start; 401 + add_with_wraparound(ua, &write_ptr, ua->rate_feedback_count); 402 + ua->rate_feedback[write_ptr] = frames; 403 + if (ua->rate_feedback_count < ua->playback.queue_length) { 404 + ua->rate_feedback_count++; 405 + if (ua->rate_feedback_count == 406 + ua->playback.queue_length) 407 + wake_up(&ua->rate_feedback_wait); 408 + } else { 409 + /* 410 + * Ring buffer overflow; this happens when the playback 411 + * stream is not running. Throw away the oldest entry, 412 + * so that the playback stream, when it starts, sees 413 + * the most recent packet sizes. 414 + */ 415 + add_with_wraparound(ua, &ua->rate_feedback_start, 1); 416 + } 417 + if (test_bit(USB_PLAYBACK_RUNNING, &ua->states) && 418 + !list_empty(&ua->ready_playback_urbs)) 419 + tasklet_schedule(&ua->playback_tasklet); 420 + } 421 + 422 + spin_unlock_irqrestore(&ua->lock, flags); 423 + 424 + if (do_period_elapsed) 425 + snd_pcm_period_elapsed(stream->substream); 426 + 427 + /* for debugging: measure the sample rate relative to the USB clock */ 428 + ua->fps[ua->frame_counter++ / ua->packets_per_second] += frames; 429 + if (ua->frame_counter >= ARRAY_SIZE(ua->fps) * ua->packets_per_second) { 430 + printk(KERN_DEBUG "capture rate:"); 431 + for (frames = 0; frames < ARRAY_SIZE(ua->fps); ++frames) 432 + printk(KERN_CONT " %u", ua->fps[frames]); 433 + printk(KERN_CONT "\n"); 434 + memset(ua->fps, 0, sizeof(ua->fps)); 435 + ua->frame_counter = 0; 436 + } 437 + return; 438 + 439 + stream_stopped: 440 + abort_usb_playback(ua); 441 + abort_usb_capture(ua); 442 + abort_alsa_playback(ua); 443 + abort_alsa_capture(ua); 444 + } 445 + 446 + static void first_capture_urb_complete(struct urb *urb) 447 + { 448 + struct ua101 *ua = urb->context; 449 + 450 + urb->complete = capture_urb_complete; 451 + capture_urb_complete(urb); 452 + 453 + set_bit(CAPTURE_URB_COMPLETED, &ua->states); 454 + wake_up(&ua->alsa_capture_wait); 455 + } 456 + 457 + static int submit_stream_urbs(struct ua101 *ua, struct ua101_stream *stream) 458 + { 459 + unsigned int i; 460 + 461 + for (i = 0; i < stream->queue_length; ++i) { 462 + int err = usb_submit_urb(&stream->urbs[i]->urb, GFP_KERNEL); 463 + if (err < 0) { 464 + dev_err(&ua->dev->dev, "USB request error %d: %s\n", 465 + err, usb_error_string(err)); 466 + return err; 467 + } 468 + } 469 + return 0; 470 + } 471 + 472 + static void kill_stream_urbs(struct ua101_stream *stream) 473 + { 474 + unsigned int i; 475 + 476 + for (i = 0; i < stream->queue_length; ++i) 477 + usb_kill_urb(&stream->urbs[i]->urb); 478 + } 479 + 480 + static int enable_iso_interface(struct ua101 *ua, unsigned int intf_index) 481 + { 482 + struct usb_host_interface *alts; 483 + 484 + alts = ua->intf[intf_index]->cur_altsetting; 485 + if (alts->desc.bAlternateSetting != 1) { 486 + int err = usb_set_interface(ua->dev, 487 + alts->desc.bInterfaceNumber, 1); 488 + if (err < 0) { 489 + dev_err(&ua->dev->dev, 490 + "cannot initialize interface; error %d: %s\n", 491 + err, usb_error_string(err)); 492 + return err; 493 + } 494 + } 495 + return 0; 496 + } 497 + 498 + static void disable_iso_interface(struct ua101 *ua, unsigned int intf_index) 499 + { 500 + struct usb_host_interface *alts; 501 + 502 + alts = ua->intf[intf_index]->cur_altsetting; 503 + if (alts->desc.bAlternateSetting != 0) { 504 + int err = usb_set_interface(ua->dev, 505 + alts->desc.bInterfaceNumber, 0); 506 + if (err < 0 && !test_bit(DISCONNECTED, &ua->states)) 507 + dev_warn(&ua->dev->dev, 508 + "interface reset failed; error %d: %s\n", 509 + err, usb_error_string(err)); 510 + } 511 + } 512 + 513 + static void stop_usb_capture(struct ua101 *ua) 514 + { 515 + clear_bit(USB_CAPTURE_RUNNING, &ua->states); 516 + 517 + kill_stream_urbs(&ua->capture); 518 + 519 + disable_iso_interface(ua, INTF_CAPTURE); 520 + } 521 + 522 + static int start_usb_capture(struct ua101 *ua) 523 + { 524 + int err; 525 + 526 + if (test_bit(DISCONNECTED, &ua->states)) 527 + return -ENODEV; 528 + 529 + if (test_bit(USB_CAPTURE_RUNNING, &ua->states)) 530 + return 0; 531 + 532 + kill_stream_urbs(&ua->capture); 533 + 534 + err = enable_iso_interface(ua, INTF_CAPTURE); 535 + if (err < 0) 536 + return err; 537 + 538 + clear_bit(CAPTURE_URB_COMPLETED, &ua->states); 539 + ua->capture.urbs[0]->urb.complete = first_capture_urb_complete; 540 + ua->rate_feedback_start = 0; 541 + ua->rate_feedback_count = 0; 542 + 543 + set_bit(USB_CAPTURE_RUNNING, &ua->states); 544 + err = submit_stream_urbs(ua, &ua->capture); 545 + if (err < 0) 546 + stop_usb_capture(ua); 547 + return err; 548 + } 549 + 550 + static void stop_usb_playback(struct ua101 *ua) 551 + { 552 + clear_bit(USB_PLAYBACK_RUNNING, &ua->states); 553 + 554 + kill_stream_urbs(&ua->playback); 555 + 556 + tasklet_kill(&ua->playback_tasklet); 557 + 558 + disable_iso_interface(ua, INTF_PLAYBACK); 559 + } 560 + 561 + static int start_usb_playback(struct ua101 *ua) 562 + { 563 + unsigned int i, frames; 564 + struct urb *urb; 565 + int err = 0; 566 + 567 + if (test_bit(DISCONNECTED, &ua->states)) 568 + return -ENODEV; 569 + 570 + if (test_bit(USB_PLAYBACK_RUNNING, &ua->states)) 571 + return 0; 572 + 573 + kill_stream_urbs(&ua->playback); 574 + tasklet_kill(&ua->playback_tasklet); 575 + 576 + err = enable_iso_interface(ua, INTF_PLAYBACK); 577 + if (err < 0) 578 + return err; 579 + 580 + clear_bit(PLAYBACK_URB_COMPLETED, &ua->states); 581 + ua->playback.urbs[0]->urb.complete = 582 + first_playback_urb_complete; 583 + spin_lock_irq(&ua->lock); 584 + INIT_LIST_HEAD(&ua->ready_playback_urbs); 585 + spin_unlock_irq(&ua->lock); 586 + 587 + /* 588 + * We submit the initial URBs all at once, so we have to wait for the 589 + * packet size FIFO to be full. 590 + */ 591 + wait_event(ua->rate_feedback_wait, 592 + ua->rate_feedback_count >= ua->playback.queue_length || 593 + !test_bit(USB_CAPTURE_RUNNING, &ua->states) || 594 + test_bit(DISCONNECTED, &ua->states)); 595 + if (test_bit(DISCONNECTED, &ua->states)) { 596 + stop_usb_playback(ua); 597 + return -ENODEV; 598 + } 599 + if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) { 600 + stop_usb_playback(ua); 601 + return -EIO; 602 + } 603 + 604 + for (i = 0; i < ua->playback.queue_length; ++i) { 605 + /* all initial URBs contain silence */ 606 + spin_lock_irq(&ua->lock); 607 + frames = ua->rate_feedback[ua->rate_feedback_start]; 608 + add_with_wraparound(ua, &ua->rate_feedback_start, 1); 609 + ua->rate_feedback_count--; 610 + spin_unlock_irq(&ua->lock); 611 + urb = &ua->playback.urbs[i]->urb; 612 + urb->iso_frame_desc[0].length = 613 + frames * ua->playback.frame_bytes; 614 + memset(urb->transfer_buffer, 0, 615 + urb->iso_frame_desc[0].length); 616 + } 617 + 618 + set_bit(USB_PLAYBACK_RUNNING, &ua->states); 619 + err = submit_stream_urbs(ua, &ua->playback); 620 + if (err < 0) 621 + stop_usb_playback(ua); 622 + return err; 623 + } 624 + 625 + static void abort_alsa_capture(struct ua101 *ua) 626 + { 627 + if (test_bit(ALSA_CAPTURE_RUNNING, &ua->states)) 628 + snd_pcm_stop(ua->capture.substream, SNDRV_PCM_STATE_XRUN); 629 + } 630 + 631 + static void abort_alsa_playback(struct ua101 *ua) 632 + { 633 + if (test_bit(ALSA_PLAYBACK_RUNNING, &ua->states)) 634 + snd_pcm_stop(ua->playback.substream, SNDRV_PCM_STATE_XRUN); 635 + } 636 + 637 + static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream, 638 + unsigned int channels) 639 + { 640 + int err; 641 + 642 + substream->runtime->hw.info = 643 + SNDRV_PCM_INFO_MMAP | 644 + SNDRV_PCM_INFO_MMAP_VALID | 645 + SNDRV_PCM_INFO_BATCH | 646 + SNDRV_PCM_INFO_INTERLEAVED | 647 + SNDRV_PCM_INFO_BLOCK_TRANSFER | 648 + SNDRV_PCM_INFO_FIFO_IN_FRAMES; 649 + substream->runtime->hw.formats = ua->format_bit; 650 + substream->runtime->hw.rates = snd_pcm_rate_to_rate_bit(ua->rate); 651 + substream->runtime->hw.rate_min = ua->rate; 652 + substream->runtime->hw.rate_max = ua->rate; 653 + substream->runtime->hw.channels_min = channels; 654 + substream->runtime->hw.channels_max = channels; 655 + substream->runtime->hw.buffer_bytes_max = 45000 * 1024; 656 + substream->runtime->hw.period_bytes_min = 1; 657 + substream->runtime->hw.period_bytes_max = UINT_MAX; 658 + substream->runtime->hw.periods_min = 2; 659 + substream->runtime->hw.periods_max = UINT_MAX; 660 + err = snd_pcm_hw_constraint_minmax(substream->runtime, 661 + SNDRV_PCM_HW_PARAM_PERIOD_TIME, 662 + 1500000 / ua->packets_per_second, 663 + 8192000); 664 + if (err < 0) 665 + return err; 666 + err = snd_pcm_hw_constraint_msbits(substream->runtime, 0, 32, 24); 667 + return err; 668 + } 669 + 670 + static int capture_pcm_open(struct snd_pcm_substream *substream) 671 + { 672 + struct ua101 *ua = substream->private_data; 673 + int err; 674 + 675 + ua->capture.substream = substream; 676 + err = set_stream_hw(ua, substream, ua->capture.channels); 677 + if (err < 0) 678 + return err; 679 + substream->runtime->hw.fifo_size = 680 + DIV_ROUND_CLOSEST(ua->rate, ua->packets_per_second); 681 + substream->runtime->delay = substream->runtime->hw.fifo_size; 682 + 683 + mutex_lock(&ua->mutex); 684 + err = start_usb_capture(ua); 685 + if (err >= 0) 686 + set_bit(ALSA_CAPTURE_OPEN, &ua->states); 687 + mutex_unlock(&ua->mutex); 688 + return err; 689 + } 690 + 691 + static int playback_pcm_open(struct snd_pcm_substream *substream) 692 + { 693 + struct ua101 *ua = substream->private_data; 694 + int err; 695 + 696 + ua->playback.substream = substream; 697 + err = set_stream_hw(ua, substream, ua->playback.channels); 698 + if (err < 0) 699 + return err; 700 + substream->runtime->hw.fifo_size = 701 + DIV_ROUND_CLOSEST(ua->rate * ua->playback.queue_length, 702 + ua->packets_per_second); 703 + 704 + mutex_lock(&ua->mutex); 705 + err = start_usb_capture(ua); 706 + if (err < 0) 707 + goto error; 708 + err = start_usb_playback(ua); 709 + if (err < 0) { 710 + if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states)) 711 + stop_usb_capture(ua); 712 + goto error; 713 + } 714 + set_bit(ALSA_PLAYBACK_OPEN, &ua->states); 715 + error: 716 + mutex_unlock(&ua->mutex); 717 + return err; 718 + } 719 + 720 + static int capture_pcm_close(struct snd_pcm_substream *substream) 721 + { 722 + struct ua101 *ua = substream->private_data; 723 + 724 + mutex_lock(&ua->mutex); 725 + clear_bit(ALSA_CAPTURE_OPEN, &ua->states); 726 + if (!test_bit(ALSA_PLAYBACK_OPEN, &ua->states)) 727 + stop_usb_capture(ua); 728 + mutex_unlock(&ua->mutex); 729 + return 0; 730 + } 731 + 732 + static int playback_pcm_close(struct snd_pcm_substream *substream) 733 + { 734 + struct ua101 *ua = substream->private_data; 735 + 736 + mutex_lock(&ua->mutex); 737 + stop_usb_playback(ua); 738 + clear_bit(ALSA_PLAYBACK_OPEN, &ua->states); 739 + if (!test_bit(ALSA_CAPTURE_OPEN, &ua->states)) 740 + stop_usb_capture(ua); 741 + mutex_unlock(&ua->mutex); 742 + return 0; 743 + } 744 + 745 + static int capture_pcm_hw_params(struct snd_pcm_substream *substream, 746 + struct snd_pcm_hw_params *hw_params) 747 + { 748 + struct ua101 *ua = substream->private_data; 749 + int err; 750 + 751 + mutex_lock(&ua->mutex); 752 + err = start_usb_capture(ua); 753 + mutex_unlock(&ua->mutex); 754 + if (err < 0) 755 + return err; 756 + 757 + return snd_pcm_lib_alloc_vmalloc_buffer(substream, 758 + params_buffer_bytes(hw_params)); 759 + } 760 + 761 + static int playback_pcm_hw_params(struct snd_pcm_substream *substream, 762 + struct snd_pcm_hw_params *hw_params) 763 + { 764 + struct ua101 *ua = substream->private_data; 765 + int err; 766 + 767 + mutex_lock(&ua->mutex); 768 + err = start_usb_capture(ua); 769 + if (err >= 0) 770 + err = start_usb_playback(ua); 771 + mutex_unlock(&ua->mutex); 772 + if (err < 0) 773 + return err; 774 + 775 + return snd_pcm_lib_alloc_vmalloc_buffer(substream, 776 + params_buffer_bytes(hw_params)); 777 + } 778 + 779 + static int ua101_pcm_hw_free(struct snd_pcm_substream *substream) 780 + { 781 + return snd_pcm_lib_free_vmalloc_buffer(substream); 782 + } 783 + 784 + static int capture_pcm_prepare(struct snd_pcm_substream *substream) 785 + { 786 + struct ua101 *ua = substream->private_data; 787 + int err; 788 + 789 + mutex_lock(&ua->mutex); 790 + err = start_usb_capture(ua); 791 + mutex_unlock(&ua->mutex); 792 + if (err < 0) 793 + return err; 794 + 795 + /* 796 + * The EHCI driver schedules the first packet of an iso stream at 10 ms 797 + * in the future, i.e., no data is actually captured for that long. 798 + * Take the wait here so that the stream is known to be actually 799 + * running when the start trigger has been called. 800 + */ 801 + wait_event(ua->alsa_capture_wait, 802 + test_bit(CAPTURE_URB_COMPLETED, &ua->states) || 803 + !test_bit(USB_CAPTURE_RUNNING, &ua->states)); 804 + if (test_bit(DISCONNECTED, &ua->states)) 805 + return -ENODEV; 806 + if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) 807 + return -EIO; 808 + 809 + ua->capture.period_pos = 0; 810 + ua->capture.buffer_pos = 0; 811 + return 0; 812 + } 813 + 814 + static int playback_pcm_prepare(struct snd_pcm_substream *substream) 815 + { 816 + struct ua101 *ua = substream->private_data; 817 + int err; 818 + 819 + mutex_lock(&ua->mutex); 820 + err = start_usb_capture(ua); 821 + if (err >= 0) 822 + err = start_usb_playback(ua); 823 + mutex_unlock(&ua->mutex); 824 + if (err < 0) 825 + return err; 826 + 827 + /* see the comment in capture_pcm_prepare() */ 828 + wait_event(ua->alsa_playback_wait, 829 + test_bit(PLAYBACK_URB_COMPLETED, &ua->states) || 830 + !test_bit(USB_PLAYBACK_RUNNING, &ua->states)); 831 + if (test_bit(DISCONNECTED, &ua->states)) 832 + return -ENODEV; 833 + if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states)) 834 + return -EIO; 835 + 836 + substream->runtime->delay = 0; 837 + ua->playback.period_pos = 0; 838 + ua->playback.buffer_pos = 0; 839 + return 0; 840 + } 841 + 842 + static int capture_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 843 + { 844 + struct ua101 *ua = substream->private_data; 845 + 846 + switch (cmd) { 847 + case SNDRV_PCM_TRIGGER_START: 848 + if (!test_bit(USB_CAPTURE_RUNNING, &ua->states)) 849 + return -EIO; 850 + set_bit(ALSA_CAPTURE_RUNNING, &ua->states); 851 + return 0; 852 + case SNDRV_PCM_TRIGGER_STOP: 853 + clear_bit(ALSA_CAPTURE_RUNNING, &ua->states); 854 + return 0; 855 + default: 856 + return -EINVAL; 857 + } 858 + } 859 + 860 + static int playback_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 861 + { 862 + struct ua101 *ua = substream->private_data; 863 + 864 + switch (cmd) { 865 + case SNDRV_PCM_TRIGGER_START: 866 + if (!test_bit(USB_PLAYBACK_RUNNING, &ua->states)) 867 + return -EIO; 868 + set_bit(ALSA_PLAYBACK_RUNNING, &ua->states); 869 + return 0; 870 + case SNDRV_PCM_TRIGGER_STOP: 871 + clear_bit(ALSA_PLAYBACK_RUNNING, &ua->states); 872 + return 0; 873 + default: 874 + return -EINVAL; 875 + } 876 + } 877 + 878 + static inline snd_pcm_uframes_t ua101_pcm_pointer(struct ua101 *ua, 879 + struct ua101_stream *stream) 880 + { 881 + unsigned long flags; 882 + unsigned int pos; 883 + 884 + spin_lock_irqsave(&ua->lock, flags); 885 + pos = stream->buffer_pos; 886 + spin_unlock_irqrestore(&ua->lock, flags); 887 + return pos; 888 + } 889 + 890 + static snd_pcm_uframes_t capture_pcm_pointer(struct snd_pcm_substream *subs) 891 + { 892 + struct ua101 *ua = subs->private_data; 893 + 894 + return ua101_pcm_pointer(ua, &ua->capture); 895 + } 896 + 897 + static snd_pcm_uframes_t playback_pcm_pointer(struct snd_pcm_substream *subs) 898 + { 899 + struct ua101 *ua = subs->private_data; 900 + 901 + return ua101_pcm_pointer(ua, &ua->playback); 902 + } 903 + 904 + static struct snd_pcm_ops capture_pcm_ops = { 905 + .open = capture_pcm_open, 906 + .close = capture_pcm_close, 907 + .ioctl = snd_pcm_lib_ioctl, 908 + .hw_params = capture_pcm_hw_params, 909 + .hw_free = ua101_pcm_hw_free, 910 + .prepare = capture_pcm_prepare, 911 + .trigger = capture_pcm_trigger, 912 + .pointer = capture_pcm_pointer, 913 + .page = snd_pcm_lib_get_vmalloc_page, 914 + .mmap = snd_pcm_lib_mmap_vmalloc, 915 + }; 916 + 917 + static struct snd_pcm_ops playback_pcm_ops = { 918 + .open = playback_pcm_open, 919 + .close = playback_pcm_close, 920 + .ioctl = snd_pcm_lib_ioctl, 921 + .hw_params = playback_pcm_hw_params, 922 + .hw_free = ua101_pcm_hw_free, 923 + .prepare = playback_pcm_prepare, 924 + .trigger = playback_pcm_trigger, 925 + .pointer = playback_pcm_pointer, 926 + .page = snd_pcm_lib_get_vmalloc_page, 927 + .mmap = snd_pcm_lib_mmap_vmalloc, 928 + }; 929 + 930 + static const struct uac_format_type_i_discrete_descriptor * 931 + find_format_descriptor(struct usb_interface *interface) 932 + { 933 + struct usb_host_interface *alt; 934 + u8 *extra; 935 + int extralen; 936 + 937 + if (interface->num_altsetting != 2) { 938 + dev_err(&interface->dev, "invalid num_altsetting\n"); 939 + return NULL; 940 + } 941 + 942 + alt = &interface->altsetting[0]; 943 + if (alt->desc.bNumEndpoints != 0) { 944 + dev_err(&interface->dev, "invalid bNumEndpoints\n"); 945 + return NULL; 946 + } 947 + 948 + alt = &interface->altsetting[1]; 949 + if (alt->desc.bNumEndpoints != 1) { 950 + dev_err(&interface->dev, "invalid bNumEndpoints\n"); 951 + return NULL; 952 + } 953 + 954 + extra = alt->extra; 955 + extralen = alt->extralen; 956 + while (extralen >= sizeof(struct usb_descriptor_header)) { 957 + struct uac_format_type_i_discrete_descriptor *desc; 958 + 959 + desc = (struct uac_format_type_i_discrete_descriptor *)extra; 960 + if (desc->bLength > extralen) { 961 + dev_err(&interface->dev, "descriptor overflow\n"); 962 + return NULL; 963 + } 964 + if (desc->bLength == UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(1) && 965 + desc->bDescriptorType == USB_DT_CS_INTERFACE && 966 + desc->bDescriptorSubtype == UAC_FORMAT_TYPE) { 967 + if (desc->bFormatType != UAC_FORMAT_TYPE_I_PCM || 968 + desc->bSamFreqType != 1) { 969 + dev_err(&interface->dev, 970 + "invalid format type\n"); 971 + return NULL; 972 + } 973 + return desc; 974 + } 975 + extralen -= desc->bLength; 976 + extra += desc->bLength; 977 + } 978 + dev_err(&interface->dev, "sample format descriptor not found\n"); 979 + return NULL; 980 + } 981 + 982 + static int detect_usb_format(struct ua101 *ua) 983 + { 984 + const struct uac_format_type_i_discrete_descriptor *fmt_capture; 985 + const struct uac_format_type_i_discrete_descriptor *fmt_playback; 986 + const struct usb_endpoint_descriptor *epd; 987 + unsigned int rate2; 988 + 989 + fmt_capture = find_format_descriptor(ua->intf[INTF_CAPTURE]); 990 + fmt_playback = find_format_descriptor(ua->intf[INTF_PLAYBACK]); 991 + if (!fmt_capture || !fmt_playback) 992 + return -ENXIO; 993 + 994 + switch (fmt_capture->bSubframeSize) { 995 + case 3: 996 + ua->format_bit = SNDRV_PCM_FMTBIT_S24_3LE; 997 + break; 998 + case 4: 999 + ua->format_bit = SNDRV_PCM_FMTBIT_S32_LE; 1000 + break; 1001 + default: 1002 + dev_err(&ua->dev->dev, "sample width is not 24 or 32 bits\n"); 1003 + return -ENXIO; 1004 + } 1005 + if (fmt_capture->bSubframeSize != fmt_playback->bSubframeSize) { 1006 + dev_err(&ua->dev->dev, 1007 + "playback/capture sample widths do not match\n"); 1008 + return -ENXIO; 1009 + } 1010 + 1011 + if (fmt_capture->bBitResolution != 24 || 1012 + fmt_playback->bBitResolution != 24) { 1013 + dev_err(&ua->dev->dev, "sample width is not 24 bits\n"); 1014 + return -ENXIO; 1015 + } 1016 + 1017 + ua->rate = combine_triple(fmt_capture->tSamFreq[0]); 1018 + rate2 = combine_triple(fmt_playback->tSamFreq[0]); 1019 + if (ua->rate != rate2) { 1020 + dev_err(&ua->dev->dev, 1021 + "playback/capture rates do not match: %u/%u\n", 1022 + rate2, ua->rate); 1023 + return -ENXIO; 1024 + } 1025 + 1026 + switch (ua->dev->speed) { 1027 + case USB_SPEED_FULL: 1028 + ua->packets_per_second = 1000; 1029 + break; 1030 + case USB_SPEED_HIGH: 1031 + ua->packets_per_second = 8000; 1032 + break; 1033 + default: 1034 + dev_err(&ua->dev->dev, "unknown device speed\n"); 1035 + return -ENXIO; 1036 + } 1037 + 1038 + ua->capture.channels = fmt_capture->bNrChannels; 1039 + ua->playback.channels = fmt_playback->bNrChannels; 1040 + ua->capture.frame_bytes = 1041 + fmt_capture->bSubframeSize * ua->capture.channels; 1042 + ua->playback.frame_bytes = 1043 + fmt_playback->bSubframeSize * ua->playback.channels; 1044 + 1045 + epd = &ua->intf[INTF_CAPTURE]->altsetting[1].endpoint[0].desc; 1046 + if (!usb_endpoint_is_isoc_in(epd)) { 1047 + dev_err(&ua->dev->dev, "invalid capture endpoint\n"); 1048 + return -ENXIO; 1049 + } 1050 + ua->capture.usb_pipe = usb_rcvisocpipe(ua->dev, usb_endpoint_num(epd)); 1051 + ua->capture.max_packet_bytes = le16_to_cpu(epd->wMaxPacketSize); 1052 + 1053 + epd = &ua->intf[INTF_PLAYBACK]->altsetting[1].endpoint[0].desc; 1054 + if (!usb_endpoint_is_isoc_out(epd)) { 1055 + dev_err(&ua->dev->dev, "invalid playback endpoint\n"); 1056 + return -ENXIO; 1057 + } 1058 + ua->playback.usb_pipe = usb_sndisocpipe(ua->dev, usb_endpoint_num(epd)); 1059 + ua->playback.max_packet_bytes = le16_to_cpu(epd->wMaxPacketSize); 1060 + return 0; 1061 + } 1062 + 1063 + static int alloc_stream_buffers(struct ua101 *ua, struct ua101_stream *stream) 1064 + { 1065 + unsigned int remaining_packets, packets, packets_per_page, i; 1066 + size_t size; 1067 + 1068 + stream->queue_length = queue_length; 1069 + stream->queue_length = max(stream->queue_length, 1070 + (unsigned int)MIN_QUEUE_LENGTH); 1071 + stream->queue_length = min(stream->queue_length, 1072 + (unsigned int)MAX_QUEUE_LENGTH); 1073 + 1074 + /* 1075 + * The cache pool sizes used by usb_buffer_alloc() (128, 512, 2048) are 1076 + * quite bad when used with the packet sizes of this device (e.g. 280, 1077 + * 520, 624). Therefore, we allocate and subdivide entire pages, using 1078 + * a smaller buffer only for the last chunk. 1079 + */ 1080 + remaining_packets = stream->queue_length; 1081 + packets_per_page = PAGE_SIZE / stream->max_packet_bytes; 1082 + for (i = 0; i < ARRAY_SIZE(stream->buffers); ++i) { 1083 + packets = min(remaining_packets, packets_per_page); 1084 + size = packets * stream->max_packet_bytes; 1085 + stream->buffers[i].addr = 1086 + usb_buffer_alloc(ua->dev, size, GFP_KERNEL, 1087 + &stream->buffers[i].dma); 1088 + if (!stream->buffers[i].addr) 1089 + return -ENOMEM; 1090 + stream->buffers[i].size = size; 1091 + remaining_packets -= packets; 1092 + if (!remaining_packets) 1093 + break; 1094 + } 1095 + if (remaining_packets) { 1096 + dev_err(&ua->dev->dev, "too many packets\n"); 1097 + return -ENXIO; 1098 + } 1099 + return 0; 1100 + } 1101 + 1102 + static void free_stream_buffers(struct ua101 *ua, struct ua101_stream *stream) 1103 + { 1104 + unsigned int i; 1105 + 1106 + for (i = 0; i < ARRAY_SIZE(stream->buffers); ++i) 1107 + usb_buffer_free(ua->dev, 1108 + stream->buffers[i].size, 1109 + stream->buffers[i].addr, 1110 + stream->buffers[i].dma); 1111 + } 1112 + 1113 + static int alloc_stream_urbs(struct ua101 *ua, struct ua101_stream *stream, 1114 + void (*urb_complete)(struct urb *)) 1115 + { 1116 + unsigned max_packet_size = stream->max_packet_bytes; 1117 + struct ua101_urb *urb; 1118 + unsigned int b, u = 0; 1119 + 1120 + for (b = 0; b < ARRAY_SIZE(stream->buffers); ++b) { 1121 + unsigned int size = stream->buffers[b].size; 1122 + u8 *addr = stream->buffers[b].addr; 1123 + dma_addr_t dma = stream->buffers[b].dma; 1124 + 1125 + while (size >= max_packet_size) { 1126 + if (u >= stream->queue_length) 1127 + goto bufsize_error; 1128 + urb = kmalloc(sizeof(*urb), GFP_KERNEL); 1129 + if (!urb) 1130 + return -ENOMEM; 1131 + usb_init_urb(&urb->urb); 1132 + urb->urb.dev = ua->dev; 1133 + urb->urb.pipe = stream->usb_pipe; 1134 + urb->urb.transfer_flags = URB_ISO_ASAP | 1135 + URB_NO_TRANSFER_DMA_MAP; 1136 + urb->urb.transfer_buffer = addr; 1137 + urb->urb.transfer_dma = dma; 1138 + urb->urb.transfer_buffer_length = max_packet_size; 1139 + urb->urb.number_of_packets = 1; 1140 + urb->urb.interval = 1; 1141 + urb->urb.context = ua; 1142 + urb->urb.complete = urb_complete; 1143 + urb->urb.iso_frame_desc[0].offset = 0; 1144 + urb->urb.iso_frame_desc[0].length = max_packet_size; 1145 + stream->urbs[u++] = urb; 1146 + size -= max_packet_size; 1147 + addr += max_packet_size; 1148 + dma += max_packet_size; 1149 + } 1150 + } 1151 + if (u == stream->queue_length) 1152 + return 0; 1153 + bufsize_error: 1154 + dev_err(&ua->dev->dev, "internal buffer size error\n"); 1155 + return -ENXIO; 1156 + } 1157 + 1158 + static void free_stream_urbs(struct ua101_stream *stream) 1159 + { 1160 + unsigned int i; 1161 + 1162 + for (i = 0; i < stream->queue_length; ++i) 1163 + kfree(stream->urbs[i]); 1164 + } 1165 + 1166 + static void free_usb_related_resources(struct ua101 *ua, 1167 + struct usb_interface *interface) 1168 + { 1169 + unsigned int i; 1170 + 1171 + free_stream_urbs(&ua->capture); 1172 + free_stream_urbs(&ua->playback); 1173 + free_stream_buffers(ua, &ua->capture); 1174 + free_stream_buffers(ua, &ua->playback); 1175 + 1176 + for (i = 0; i < ARRAY_SIZE(ua->intf); ++i) 1177 + if (ua->intf[i]) { 1178 + usb_set_intfdata(ua->intf[i], NULL); 1179 + if (ua->intf[i] != interface) 1180 + usb_driver_release_interface(&ua101_driver, 1181 + ua->intf[i]); 1182 + } 1183 + } 1184 + 1185 + static void ua101_card_free(struct snd_card *card) 1186 + { 1187 + struct ua101 *ua = card->private_data; 1188 + 1189 + mutex_destroy(&ua->mutex); 1190 + } 1191 + 1192 + static int ua101_probe(struct usb_interface *interface, 1193 + const struct usb_device_id *usb_id) 1194 + { 1195 + static const struct snd_usb_midi_endpoint_info midi_ep = { 1196 + .out_cables = 0x0001, 1197 + .in_cables = 0x0001 1198 + }; 1199 + static const struct snd_usb_audio_quirk midi_quirk = { 1200 + .type = QUIRK_MIDI_FIXED_ENDPOINT, 1201 + .data = &midi_ep 1202 + }; 1203 + struct snd_card *card; 1204 + struct ua101 *ua; 1205 + unsigned int card_index, i; 1206 + char usb_path[32]; 1207 + int err; 1208 + 1209 + if (interface->altsetting->desc.bInterfaceNumber != 0) 1210 + return -ENODEV; 1211 + 1212 + mutex_lock(&devices_mutex); 1213 + 1214 + for (card_index = 0; card_index < SNDRV_CARDS; ++card_index) 1215 + if (enable[card_index] && !(devices_used & (1 << card_index))) 1216 + break; 1217 + if (card_index >= SNDRV_CARDS) { 1218 + mutex_unlock(&devices_mutex); 1219 + return -ENOENT; 1220 + } 1221 + err = snd_card_create(index[card_index], id[card_index], THIS_MODULE, 1222 + sizeof(*ua), &card); 1223 + if (err < 0) { 1224 + mutex_unlock(&devices_mutex); 1225 + return err; 1226 + } 1227 + card->private_free = ua101_card_free; 1228 + ua = card->private_data; 1229 + ua->dev = interface_to_usbdev(interface); 1230 + ua->card = card; 1231 + ua->card_index = card_index; 1232 + INIT_LIST_HEAD(&ua->midi_list); 1233 + spin_lock_init(&ua->lock); 1234 + mutex_init(&ua->mutex); 1235 + INIT_LIST_HEAD(&ua->ready_playback_urbs); 1236 + tasklet_init(&ua->playback_tasklet, 1237 + playback_tasklet, (unsigned long)ua); 1238 + init_waitqueue_head(&ua->alsa_capture_wait); 1239 + init_waitqueue_head(&ua->rate_feedback_wait); 1240 + init_waitqueue_head(&ua->alsa_playback_wait); 1241 + 1242 + #ifdef UA1A_HACK 1243 + if (ua->dev->descriptor.idProduct == cpu_to_le16(0x0018)) { 1244 + ua->intf[2] = interface; 1245 + ua->intf[0] = usb_ifnum_to_if(ua->dev, 1); 1246 + ua->intf[1] = usb_ifnum_to_if(ua->dev, 2); 1247 + usb_driver_claim_interface(&ua101_driver, ua->intf[0], ua); 1248 + usb_driver_claim_interface(&ua101_driver, ua->intf[1], ua); 1249 + } else { 1250 + #endif 1251 + ua->intf[0] = interface; 1252 + for (i = 1; i < ARRAY_SIZE(ua->intf); ++i) { 1253 + ua->intf[i] = usb_ifnum_to_if(ua->dev, i); 1254 + if (!ua->intf[i]) { 1255 + dev_err(&ua->dev->dev, "interface %u not found\n", i); 1256 + err = -ENXIO; 1257 + goto probe_error; 1258 + } 1259 + err = usb_driver_claim_interface(&ua101_driver, 1260 + ua->intf[i], ua); 1261 + if (err < 0) { 1262 + ua->intf[i] = NULL; 1263 + err = -EBUSY; 1264 + goto probe_error; 1265 + } 1266 + } 1267 + #ifdef UA1A_HACK 1268 + } 1269 + #endif 1270 + 1271 + snd_card_set_dev(card, &interface->dev); 1272 + 1273 + #ifdef UA1A_HACK 1274 + if (ua->dev->descriptor.idProduct == cpu_to_le16(0x0018)) { 1275 + ua->format_bit = SNDRV_PCM_FMTBIT_S16_LE; 1276 + ua->rate = 44100; 1277 + ua->packets_per_second = 1000; 1278 + ua->capture.channels = 2; 1279 + ua->playback.channels = 2; 1280 + ua->capture.frame_bytes = 4; 1281 + ua->playback.frame_bytes = 4; 1282 + ua->capture.usb_pipe = usb_rcvisocpipe(ua->dev, 2); 1283 + ua->playback.usb_pipe = usb_sndisocpipe(ua->dev, 1); 1284 + ua->capture.max_packet_bytes = 192; 1285 + ua->playback.max_packet_bytes = 192; 1286 + } else { 1287 + #endif 1288 + err = detect_usb_format(ua); 1289 + if (err < 0) 1290 + goto probe_error; 1291 + #ifdef UA1A_HACK 1292 + } 1293 + #endif 1294 + 1295 + strcpy(card->driver, "UA-101"); 1296 + strcpy(card->shortname, "UA-101"); 1297 + usb_make_path(ua->dev, usb_path, sizeof(usb_path)); 1298 + snprintf(ua->card->longname, sizeof(ua->card->longname), 1299 + "EDIROL UA-101 (serial %s), %u Hz at %s, %s speed", 1300 + ua->dev->serial ? ua->dev->serial : "?", ua->rate, usb_path, 1301 + ua->dev->speed == USB_SPEED_HIGH ? "high" : "full"); 1302 + 1303 + err = alloc_stream_buffers(ua, &ua->capture); 1304 + if (err < 0) 1305 + goto probe_error; 1306 + err = alloc_stream_buffers(ua, &ua->playback); 1307 + if (err < 0) 1308 + goto probe_error; 1309 + 1310 + err = alloc_stream_urbs(ua, &ua->capture, capture_urb_complete); 1311 + if (err < 0) 1312 + goto probe_error; 1313 + err = alloc_stream_urbs(ua, &ua->playback, playback_urb_complete); 1314 + if (err < 0) 1315 + goto probe_error; 1316 + 1317 + err = snd_pcm_new(card, "UA-101", 0, 1, 1, &ua->pcm); 1318 + if (err < 0) 1319 + goto probe_error; 1320 + ua->pcm->private_data = ua; 1321 + strcpy(ua->pcm->name, "UA-101"); 1322 + snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_pcm_ops); 1323 + snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_pcm_ops); 1324 + 1325 + #ifdef UA1A_HACK 1326 + if (ua->dev->descriptor.idProduct != cpu_to_le16(0x0018)) { 1327 + #endif 1328 + err = snd_usbmidi_create(card, ua->intf[INTF_MIDI], 1329 + &ua->midi_list, &midi_quirk); 1330 + if (err < 0) 1331 + goto probe_error; 1332 + #ifdef UA1A_HACK 1333 + } 1334 + #endif 1335 + 1336 + err = snd_card_register(card); 1337 + if (err < 0) 1338 + goto probe_error; 1339 + 1340 + usb_set_intfdata(interface, ua); 1341 + devices_used |= 1 << card_index; 1342 + 1343 + mutex_unlock(&devices_mutex); 1344 + return 0; 1345 + 1346 + probe_error: 1347 + free_usb_related_resources(ua, interface); 1348 + snd_card_free(card); 1349 + mutex_unlock(&devices_mutex); 1350 + return err; 1351 + } 1352 + 1353 + static void ua101_disconnect(struct usb_interface *interface) 1354 + { 1355 + struct ua101 *ua = usb_get_intfdata(interface); 1356 + struct list_head *midi; 1357 + 1358 + if (!ua) 1359 + return; 1360 + 1361 + mutex_lock(&devices_mutex); 1362 + 1363 + set_bit(DISCONNECTED, &ua->states); 1364 + wake_up(&ua->rate_feedback_wait); 1365 + 1366 + /* make sure that userspace cannot create new requests */ 1367 + snd_card_disconnect(ua->card); 1368 + 1369 + /* make sure that there are no pending USB requests */ 1370 + __list_for_each(midi, &ua->midi_list) 1371 + snd_usbmidi_disconnect(midi); 1372 + abort_alsa_playback(ua); 1373 + abort_alsa_capture(ua); 1374 + mutex_lock(&ua->mutex); 1375 + stop_usb_playback(ua); 1376 + stop_usb_capture(ua); 1377 + mutex_unlock(&ua->mutex); 1378 + 1379 + free_usb_related_resources(ua, interface); 1380 + 1381 + devices_used &= ~(1 << ua->card_index); 1382 + 1383 + snd_card_free_when_closed(ua->card); 1384 + 1385 + mutex_unlock(&devices_mutex); 1386 + } 1387 + 1388 + static struct usb_device_id ua101_ids[] = { 1389 + #ifdef UA1A_HACK 1390 + { USB_DEVICE(0x0582, 0x0018) }, 1391 + #endif 1392 + { USB_DEVICE(0x0582, 0x007d) }, 1393 + { USB_DEVICE(0x0582, 0x008d) }, 1394 + { } 1395 + }; 1396 + MODULE_DEVICE_TABLE(usb, ua101_ids); 1397 + 1398 + static struct usb_driver ua101_driver = { 1399 + .name = "snd-ua101", 1400 + .id_table = ua101_ids, 1401 + .probe = ua101_probe, 1402 + .disconnect = ua101_disconnect, 1403 + #if 0 1404 + .suspend = ua101_suspend, 1405 + .resume = ua101_resume, 1406 + #endif 1407 + }; 1408 + 1409 + static int __init alsa_card_ua101_init(void) 1410 + { 1411 + return usb_register(&ua101_driver); 1412 + } 1413 + 1414 + static void __exit alsa_card_ua101_exit(void) 1415 + { 1416 + usb_deregister(&ua101_driver); 1417 + mutex_destroy(&devices_mutex); 1418 + } 1419 + 1420 + module_init(alsa_card_ua101_init); 1421 + module_exit(alsa_card_ua101_exit);
+564 -277
sound/usb/usbaudio.c
··· 44 44 #include <linux/slab.h> 45 45 #include <linux/string.h> 46 46 #include <linux/usb.h> 47 - #include <linux/vmalloc.h> 48 47 #include <linux/moduleparam.h> 49 48 #include <linux/mutex.h> 49 + #include <linux/usb/audio.h> 50 + #include <linux/usb/ch9.h> 51 + 50 52 #include <sound/core.h> 51 53 #include <sound/info.h> 52 54 #include <sound/pcm.h> ··· 172 170 unsigned int curpacksize; /* current packet size in bytes (for capture) */ 173 171 unsigned int curframesize; /* current packet size in frames (for capture) */ 174 172 unsigned int fill_max: 1; /* fill max packet size always */ 173 + unsigned int txfr_quirk:1; /* allow sub-frame alignment */ 175 174 unsigned int fmt_type; /* USB audio format type (1-3) */ 176 175 177 176 unsigned int running: 1; /* running status */ 178 177 179 - unsigned int hwptr_done; /* processed frame position in the buffer */ 178 + unsigned int hwptr_done; /* processed byte position in the buffer */ 180 179 unsigned int transfer_done; /* processed frames since last period update */ 181 180 unsigned long active_mask; /* bitmask of active urbs */ 182 181 unsigned long unlink_mask; /* bitmask of unlinked urbs */ ··· 346 343 unsigned long flags; 347 344 unsigned char *cp; 348 345 int i; 349 - unsigned int stride, len, oldptr; 346 + unsigned int stride, frames, bytes, oldptr; 350 347 int period_elapsed = 0; 351 348 352 349 stride = runtime->frame_bits >> 3; ··· 357 354 snd_printd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status); 358 355 // continue; 359 356 } 360 - len = urb->iso_frame_desc[i].actual_length / stride; 361 - if (! len) 362 - continue; 357 + bytes = urb->iso_frame_desc[i].actual_length; 358 + frames = bytes / stride; 359 + if (!subs->txfr_quirk) 360 + bytes = frames * stride; 361 + if (bytes % (runtime->sample_bits >> 3) != 0) { 362 + #ifdef CONFIG_SND_DEBUG_VERBOSE 363 + int oldbytes = bytes; 364 + #endif 365 + bytes = frames * stride; 366 + snd_printdd(KERN_ERR "Corrected urb data len. %d->%d\n", 367 + oldbytes, bytes); 368 + } 363 369 /* update the current pointer */ 364 370 spin_lock_irqsave(&subs->lock, flags); 365 371 oldptr = subs->hwptr_done; 366 - subs->hwptr_done += len; 367 - if (subs->hwptr_done >= runtime->buffer_size) 368 - subs->hwptr_done -= runtime->buffer_size; 369 - subs->transfer_done += len; 372 + subs->hwptr_done += bytes; 373 + if (subs->hwptr_done >= runtime->buffer_size * stride) 374 + subs->hwptr_done -= runtime->buffer_size * stride; 375 + frames = (bytes + (oldptr % stride)) / stride; 376 + subs->transfer_done += frames; 370 377 if (subs->transfer_done >= runtime->period_size) { 371 378 subs->transfer_done -= runtime->period_size; 372 379 period_elapsed = 1; 373 380 } 374 381 spin_unlock_irqrestore(&subs->lock, flags); 375 382 /* copy a data chunk */ 376 - if (oldptr + len > runtime->buffer_size) { 377 - unsigned int cnt = runtime->buffer_size - oldptr; 378 - unsigned int blen = cnt * stride; 379 - memcpy(runtime->dma_area + oldptr * stride, cp, blen); 380 - memcpy(runtime->dma_area, cp + blen, len * stride - blen); 383 + if (oldptr + bytes > runtime->buffer_size * stride) { 384 + unsigned int bytes1 = 385 + runtime->buffer_size * stride - oldptr; 386 + memcpy(runtime->dma_area + oldptr, cp, bytes1); 387 + memcpy(runtime->dma_area, cp + bytes1, bytes - bytes1); 381 388 } else { 382 - memcpy(runtime->dma_area + oldptr * stride, cp, len * stride); 389 + memcpy(runtime->dma_area + oldptr, cp, bytes); 383 390 } 384 391 } 385 392 if (period_elapsed) ··· 576 563 struct snd_pcm_runtime *runtime, 577 564 struct urb *urb) 578 565 { 579 - int i, stride, offs; 580 - unsigned int counts; 566 + int i, stride; 567 + unsigned int counts, frames, bytes; 581 568 unsigned long flags; 582 569 int period_elapsed = 0; 583 570 struct snd_urb_ctx *ctx = urb->context; 584 571 585 572 stride = runtime->frame_bits >> 3; 586 573 587 - offs = 0; 574 + frames = 0; 588 575 urb->dev = ctx->subs->dev; /* we need to set this at each time */ 589 576 urb->number_of_packets = 0; 590 577 spin_lock_irqsave(&subs->lock, flags); 591 578 for (i = 0; i < ctx->packets; i++) { 592 579 counts = snd_usb_audio_next_packet_size(subs); 593 580 /* set up descriptor */ 594 - urb->iso_frame_desc[i].offset = offs * stride; 581 + urb->iso_frame_desc[i].offset = frames * stride; 595 582 urb->iso_frame_desc[i].length = counts * stride; 596 - offs += counts; 583 + frames += counts; 597 584 urb->number_of_packets++; 598 585 subs->transfer_done += counts; 599 586 if (subs->transfer_done >= runtime->period_size) { 600 587 subs->transfer_done -= runtime->period_size; 601 588 period_elapsed = 1; 602 - if (subs->fmt_type == USB_FORMAT_TYPE_II) { 589 + if (subs->fmt_type == UAC_FORMAT_TYPE_II) { 603 590 if (subs->transfer_done > 0) { 604 591 /* FIXME: fill-max mode is not 605 592 * supported yet */ 606 - offs -= subs->transfer_done; 593 + frames -= subs->transfer_done; 607 594 counts -= subs->transfer_done; 608 595 urb->iso_frame_desc[i].length = 609 596 counts * stride; ··· 613 600 if (i < ctx->packets) { 614 601 /* add a transfer delimiter */ 615 602 urb->iso_frame_desc[i].offset = 616 - offs * stride; 603 + frames * stride; 617 604 urb->iso_frame_desc[i].length = 0; 618 605 urb->number_of_packets++; 619 606 } ··· 623 610 if (period_elapsed) /* finish at the period boundary */ 624 611 break; 625 612 } 626 - if (subs->hwptr_done + offs > runtime->buffer_size) { 613 + bytes = frames * stride; 614 + if (subs->hwptr_done + bytes > runtime->buffer_size * stride) { 627 615 /* err, the transferred area goes over buffer boundary. */ 628 - unsigned int len = runtime->buffer_size - subs->hwptr_done; 616 + unsigned int bytes1 = 617 + runtime->buffer_size * stride - subs->hwptr_done; 629 618 memcpy(urb->transfer_buffer, 630 - runtime->dma_area + subs->hwptr_done * stride, 631 - len * stride); 632 - memcpy(urb->transfer_buffer + len * stride, 633 - runtime->dma_area, 634 - (offs - len) * stride); 619 + runtime->dma_area + subs->hwptr_done, bytes1); 620 + memcpy(urb->transfer_buffer + bytes1, 621 + runtime->dma_area, bytes - bytes1); 635 622 } else { 636 623 memcpy(urb->transfer_buffer, 637 - runtime->dma_area + subs->hwptr_done * stride, 638 - offs * stride); 624 + runtime->dma_area + subs->hwptr_done, bytes); 639 625 } 640 - subs->hwptr_done += offs; 641 - if (subs->hwptr_done >= runtime->buffer_size) 642 - subs->hwptr_done -= runtime->buffer_size; 643 - runtime->delay += offs; 626 + subs->hwptr_done += bytes; 627 + if (subs->hwptr_done >= runtime->buffer_size * stride) 628 + subs->hwptr_done -= runtime->buffer_size * stride; 629 + runtime->delay += frames; 644 630 spin_unlock_irqrestore(&subs->lock, flags); 645 - urb->transfer_buffer_length = offs * stride; 631 + urb->transfer_buffer_length = bytes; 646 632 if (period_elapsed) 647 633 snd_pcm_period_elapsed(subs->pcm_substream); 648 634 return 0; ··· 744 732 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); 745 733 } 746 734 } 747 - } 748 - 749 - 750 - /* get the physical page pointer at the given offset */ 751 - static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, 752 - unsigned long offset) 753 - { 754 - void *pageptr = subs->runtime->dma_area + offset; 755 - return vmalloc_to_page(pageptr); 756 - } 757 - 758 - /* allocate virtual buffer; may be called more than once */ 759 - static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) 760 - { 761 - struct snd_pcm_runtime *runtime = subs->runtime; 762 - if (runtime->dma_area) { 763 - if (runtime->dma_bytes >= size) 764 - return 0; /* already large enough */ 765 - vfree(runtime->dma_area); 766 - } 767 - runtime->dma_area = vmalloc_user(size); 768 - if (!runtime->dma_area) 769 - return -ENOMEM; 770 - runtime->dma_bytes = size; 771 - return 0; 772 - } 773 - 774 - /* free virtual buffer; may be called more than once */ 775 - static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) 776 - { 777 - struct snd_pcm_runtime *runtime = subs->runtime; 778 - 779 - vfree(runtime->dma_area); 780 - runtime->dma_area = NULL; 781 - return 0; 782 735 } 783 736 784 737 ··· 914 937 915 938 916 939 /* 917 - * return the current pcm pointer. just return the hwptr_done value. 940 + * return the current pcm pointer. just based on the hwptr_done value. 918 941 */ 919 942 static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream) 920 943 { 921 944 struct snd_usb_substream *subs; 922 - snd_pcm_uframes_t hwptr_done; 945 + unsigned int hwptr_done; 923 946 924 947 subs = (struct snd_usb_substream *)substream->runtime->private_data; 925 948 spin_lock(&subs->lock); 926 949 hwptr_done = subs->hwptr_done; 927 950 spin_unlock(&subs->lock); 928 - return hwptr_done; 951 + return hwptr_done / (substream->runtime->frame_bits >> 3); 929 952 } 930 953 931 954 ··· 1107 1130 u->packets = (i + 1) * total_packs / subs->nurbs 1108 1131 - i * total_packs / subs->nurbs; 1109 1132 u->buffer_size = maxsize * u->packets; 1110 - if (subs->fmt_type == USB_FORMAT_TYPE_II) 1133 + if (subs->fmt_type == UAC_FORMAT_TYPE_II) 1111 1134 u->packets++; /* for transfer delimiter */ 1112 1135 u->urb = usb_alloc_urb(u->packets, GFP_KERNEL); 1113 1136 if (!u->urb) ··· 1183 1206 if (i >= fp->nr_rates) 1184 1207 continue; 1185 1208 } 1186 - attr = fp->ep_attr & EP_ATTR_MASK; 1209 + attr = fp->ep_attr & USB_ENDPOINT_SYNCTYPE; 1187 1210 if (! found) { 1188 1211 found = fp; 1189 1212 cur_attr = attr; ··· 1195 1218 * M-audio audiophile USB. 1196 1219 */ 1197 1220 if (attr != cur_attr) { 1198 - if ((attr == EP_ATTR_ASYNC && 1221 + if ((attr == USB_ENDPOINT_SYNC_ASYNC && 1199 1222 subs->direction == SNDRV_PCM_STREAM_PLAYBACK) || 1200 - (attr == EP_ATTR_ADAPTIVE && 1223 + (attr == USB_ENDPOINT_SYNC_ADAPTIVE && 1201 1224 subs->direction == SNDRV_PCM_STREAM_CAPTURE)) 1202 1225 continue; 1203 - if ((cur_attr == EP_ATTR_ASYNC && 1226 + if ((cur_attr == USB_ENDPOINT_SYNC_ASYNC && 1204 1227 subs->direction == SNDRV_PCM_STREAM_PLAYBACK) || 1205 - (cur_attr == EP_ATTR_ADAPTIVE && 1228 + (cur_attr == USB_ENDPOINT_SYNC_ADAPTIVE && 1206 1229 subs->direction == SNDRV_PCM_STREAM_CAPTURE)) { 1207 1230 found = fp; 1208 1231 cur_attr = attr; ··· 1232 1255 1233 1256 ep = get_endpoint(alts, 0)->bEndpointAddress; 1234 1257 /* if endpoint has pitch control, enable it */ 1235 - if (fmt->attributes & EP_CS_ATTR_PITCH_CONTROL) { 1258 + if (fmt->attributes & UAC_EP_CS_ATTR_PITCH_CONTROL) { 1236 1259 data[0] = 1; 1237 - if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, 1260 + if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, 1238 1261 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 1239 - PITCH_CONTROL << 8, ep, data, 1, 1000)) < 0) { 1262 + UAC_EP_CS_ATTR_PITCH_CONTROL << 8, ep, data, 1, 1000)) < 0) { 1240 1263 snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n", 1241 1264 dev->devnum, iface, ep); 1242 1265 return err; ··· 1255 1278 1256 1279 ep = get_endpoint(alts, 0)->bEndpointAddress; 1257 1280 /* if endpoint has sampling rate control, set it */ 1258 - if (fmt->attributes & EP_CS_ATTR_SAMPLE_RATE) { 1281 + if (fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE) { 1259 1282 int crate; 1260 1283 data[0] = rate; 1261 1284 data[1] = rate >> 8; 1262 1285 data[2] = rate >> 16; 1263 - if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, 1286 + if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, 1264 1287 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 1265 - SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { 1288 + UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000)) < 0) { 1266 1289 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n", 1267 1290 dev->devnum, iface, fmt->altsetting, rate, ep); 1268 1291 return err; 1269 1292 } 1270 - if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR, 1293 + if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR, 1271 1294 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, 1272 - SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { 1295 + UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000)) < 0) { 1273 1296 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n", 1274 1297 dev->devnum, iface, fmt->altsetting, ep); 1275 1298 return 0; /* some devices don't support reading */ ··· 1281 1304 } 1282 1305 } 1283 1306 return 0; 1307 + } 1308 + 1309 + /* 1310 + * For E-Mu 0404USB/0202USB/TrackerPre sample rate should be set for device, 1311 + * not for interface. 1312 + */ 1313 + static void set_format_emu_quirk(struct snd_usb_substream *subs, 1314 + struct audioformat *fmt) 1315 + { 1316 + unsigned char emu_samplerate_id = 0; 1317 + 1318 + /* When capture is active 1319 + * sample rate shouldn't be changed 1320 + * by playback substream 1321 + */ 1322 + if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) { 1323 + if (subs->stream->substream[SNDRV_PCM_STREAM_CAPTURE].interface != -1) 1324 + return; 1325 + } 1326 + 1327 + switch (fmt->rate_min) { 1328 + case 48000: 1329 + emu_samplerate_id = EMU_QUIRK_SR_48000HZ; 1330 + break; 1331 + case 88200: 1332 + emu_samplerate_id = EMU_QUIRK_SR_88200HZ; 1333 + break; 1334 + case 96000: 1335 + emu_samplerate_id = EMU_QUIRK_SR_96000HZ; 1336 + break; 1337 + case 176400: 1338 + emu_samplerate_id = EMU_QUIRK_SR_176400HZ; 1339 + break; 1340 + case 192000: 1341 + emu_samplerate_id = EMU_QUIRK_SR_192000HZ; 1342 + break; 1343 + default: 1344 + emu_samplerate_id = EMU_QUIRK_SR_44100HZ; 1345 + break; 1346 + } 1347 + snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id); 1284 1348 } 1285 1349 1286 1350 /* ··· 1387 1369 * descriptors which fool us. if it has only one EP, 1388 1370 * assume it as adaptive-out or sync-in. 1389 1371 */ 1390 - attr = fmt->ep_attr & EP_ATTR_MASK; 1391 - if (((is_playback && attr == EP_ATTR_ASYNC) || 1392 - (! is_playback && attr == EP_ATTR_ADAPTIVE)) && 1372 + attr = fmt->ep_attr & USB_ENDPOINT_SYNCTYPE; 1373 + if (((is_playback && attr == USB_ENDPOINT_SYNC_ASYNC) || 1374 + (! is_playback && attr == USB_ENDPOINT_SYNC_ADAPTIVE)) && 1393 1375 altsd->bNumEndpoints >= 2) { 1394 1376 /* check sync-pipe endpoint */ 1395 1377 /* ... and check descriptor size before accessing bSynchAddress ··· 1429 1411 } 1430 1412 1431 1413 /* always fill max packet size */ 1432 - if (fmt->attributes & EP_CS_ATTR_FILL_MAX) 1414 + if (fmt->attributes & UAC_EP_CS_ATTR_FILL_MAX) 1433 1415 subs->fill_max = 1; 1434 1416 1435 1417 if ((err = init_usb_pitch(dev, subs->interface, alts, fmt)) < 0) 1436 1418 return err; 1437 1419 1438 1420 subs->cur_audiofmt = fmt; 1421 + 1422 + switch (subs->stream->chip->usb_id) { 1423 + case USB_ID(0x041e, 0x3f02): /* E-Mu 0202 USB */ 1424 + case USB_ID(0x041e, 0x3f04): /* E-Mu 0404 USB */ 1425 + case USB_ID(0x041e, 0x3f0a): /* E-Mu Tracker Pre */ 1426 + set_format_emu_quirk(subs, fmt); 1427 + break; 1428 + } 1439 1429 1440 1430 #if 0 1441 1431 printk(KERN_DEBUG ··· 1475 1449 unsigned int channels, rate, format; 1476 1450 int ret, changed; 1477 1451 1478 - ret = snd_pcm_alloc_vmalloc_buffer(substream, 1479 - params_buffer_bytes(hw_params)); 1452 + ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, 1453 + params_buffer_bytes(hw_params)); 1480 1454 if (ret < 0) 1481 1455 return ret; 1482 1456 ··· 1533 1507 subs->period_bytes = 0; 1534 1508 if (!subs->stream->chip->shutdown) 1535 1509 release_substream_urbs(subs, 0); 1536 - return snd_pcm_free_vmalloc_buffer(substream); 1510 + return snd_pcm_lib_free_vmalloc_buffer(substream); 1537 1511 } 1538 1512 1539 1513 /* ··· 1887 1861 runtime->hw.channels_min = fp->channels; 1888 1862 if (runtime->hw.channels_max < fp->channels) 1889 1863 runtime->hw.channels_max = fp->channels; 1890 - if (fp->fmt_type == USB_FORMAT_TYPE_II && fp->frame_size > 0) { 1864 + if (fp->fmt_type == UAC_FORMAT_TYPE_II && fp->frame_size > 0) { 1891 1865 /* FIXME: there might be more than one audio formats... */ 1892 1866 runtime->hw.period_bytes_min = runtime->hw.period_bytes_max = 1893 1867 fp->frame_size; ··· 1999 1973 .prepare = snd_usb_pcm_prepare, 2000 1974 .trigger = snd_usb_pcm_playback_trigger, 2001 1975 .pointer = snd_usb_pcm_pointer, 2002 - .page = snd_pcm_get_vmalloc_page, 1976 + .page = snd_pcm_lib_get_vmalloc_page, 1977 + .mmap = snd_pcm_lib_mmap_vmalloc, 2003 1978 }; 2004 1979 2005 1980 static struct snd_pcm_ops snd_usb_capture_ops = { ··· 2012 1985 .prepare = snd_usb_pcm_prepare, 2013 1986 .trigger = snd_usb_pcm_capture_trigger, 2014 1987 .pointer = snd_usb_pcm_pointer, 2015 - .page = snd_pcm_get_vmalloc_page, 1988 + .page = snd_pcm_lib_get_vmalloc_page, 1989 + .mmap = snd_pcm_lib_mmap_vmalloc, 2016 1990 }; 2017 1991 2018 1992 ··· 2121 2093 #include "usbquirks.h" 2122 2094 { .match_flags = (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS), 2123 2095 .bInterfaceClass = USB_CLASS_AUDIO, 2124 - .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL }, 2096 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL }, 2125 2097 { } /* Terminating entry */ 2126 2098 }; 2127 2099 ··· 2160 2132 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", 2161 2133 fp->endpoint & USB_ENDPOINT_NUMBER_MASK, 2162 2134 fp->endpoint & USB_DIR_IN ? "IN" : "OUT", 2163 - sync_types[(fp->ep_attr & EP_ATTR_MASK) >> 2]); 2135 + sync_types[(fp->ep_attr & USB_ENDPOINT_SYNCTYPE) >> 2]); 2164 2136 if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) { 2165 2137 snd_iprintf(buffer, " Rates: %d - %d (continuous)\n", 2166 2138 fp->rate_min, fp->rate_max); ··· 2255 2227 subs->stream = as; 2256 2228 subs->direction = stream; 2257 2229 subs->dev = as->chip->dev; 2230 + subs->txfr_quirk = as->chip->txfr_quirk; 2258 2231 if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) { 2259 2232 subs->ops = audio_urb_ops[stream]; 2260 2233 } else { ··· 2423 2394 * @format: the format tag (wFormatTag) 2424 2395 * @fmt: the format type descriptor 2425 2396 */ 2426 - static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audioformat *fp, 2427 - int format, unsigned char *fmt) 2397 + static int parse_audio_format_i_type(struct snd_usb_audio *chip, 2398 + struct audioformat *fp, 2399 + int format, void *_fmt, 2400 + int protocol) 2428 2401 { 2429 - int pcm_format; 2402 + int pcm_format, i; 2430 2403 int sample_width, sample_bytes; 2404 + 2405 + switch (protocol) { 2406 + case UAC_VERSION_1: { 2407 + struct uac_format_type_i_discrete_descriptor *fmt = _fmt; 2408 + sample_width = fmt->bBitResolution; 2409 + sample_bytes = fmt->bSubframeSize; 2410 + break; 2411 + } 2412 + 2413 + case UAC_VERSION_2: { 2414 + struct uac_format_type_i_ext_descriptor *fmt = _fmt; 2415 + sample_width = fmt->bBitResolution; 2416 + sample_bytes = fmt->bSubslotSize; 2417 + 2418 + /* 2419 + * FIXME 2420 + * USB audio class v2 devices specify a bitmap of possible 2421 + * audio formats rather than one fix value. For now, we just 2422 + * pick one of them and report that as the only possible 2423 + * value for this setting. 2424 + * The bit allocation map is in fact compatible to the 2425 + * wFormatTag of the v1 AS streaming descriptors, which is why 2426 + * we can simply map the matrix. 2427 + */ 2428 + 2429 + for (i = 0; i < 5; i++) 2430 + if (format & (1UL << i)) { 2431 + format = i + 1; 2432 + break; 2433 + } 2434 + 2435 + break; 2436 + } 2437 + 2438 + default: 2439 + return -EINVAL; 2440 + } 2431 2441 2432 2442 /* FIXME: correct endianess and sign? */ 2433 2443 pcm_format = -1; 2434 - sample_width = fmt[6]; 2435 - sample_bytes = fmt[5]; 2444 + 2436 2445 switch (format) { 2437 - case 0: /* some devices don't define this correctly... */ 2446 + case UAC_FORMAT_TYPE_I_UNDEFINED: /* some devices don't define this correctly... */ 2438 2447 snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", 2439 2448 chip->dev->devnum, fp->iface, fp->altsetting); 2440 2449 /* fall-through */ 2441 - case USB_AUDIO_FORMAT_PCM: 2450 + case UAC_FORMAT_TYPE_I_PCM: 2442 2451 if (sample_width > sample_bytes * 8) { 2443 2452 snd_printk(KERN_INFO "%d:%u:%d : sample bitwidth %d in over sample bytes %d\n", 2444 2453 chip->dev->devnum, fp->iface, fp->altsetting, 2445 2454 sample_width, sample_bytes); 2446 2455 } 2447 2456 /* check the format byte size */ 2448 - switch (fmt[5]) { 2457 + printk(" XXXXX SAMPLE BYTES %d\n", sample_bytes); 2458 + switch (sample_bytes) { 2449 2459 case 1: 2450 2460 pcm_format = SNDRV_PCM_FORMAT_S8; 2451 2461 break; ··· 2505 2437 break; 2506 2438 default: 2507 2439 snd_printk(KERN_INFO "%d:%u:%d : unsupported sample bitwidth %d in %d bytes\n", 2508 - chip->dev->devnum, fp->iface, 2509 - fp->altsetting, sample_width, sample_bytes); 2440 + chip->dev->devnum, fp->iface, fp->altsetting, 2441 + sample_width, sample_bytes); 2510 2442 break; 2511 2443 } 2512 2444 break; 2513 - case USB_AUDIO_FORMAT_PCM8: 2445 + case UAC_FORMAT_TYPE_I_PCM8: 2514 2446 pcm_format = SNDRV_PCM_FORMAT_U8; 2515 2447 2516 2448 /* Dallas DS4201 workaround: it advertises U8 format, but really ··· 2518 2450 if (chip->usb_id == USB_ID(0x04fa, 0x4201)) 2519 2451 pcm_format = SNDRV_PCM_FORMAT_S8; 2520 2452 break; 2521 - case USB_AUDIO_FORMAT_IEEE_FLOAT: 2453 + case UAC_FORMAT_TYPE_I_IEEE_FLOAT: 2522 2454 pcm_format = SNDRV_PCM_FORMAT_FLOAT_LE; 2523 2455 break; 2524 - case USB_AUDIO_FORMAT_ALAW: 2456 + case UAC_FORMAT_TYPE_I_ALAW: 2525 2457 pcm_format = SNDRV_PCM_FORMAT_A_LAW; 2526 2458 break; 2527 - case USB_AUDIO_FORMAT_MU_LAW: 2459 + case UAC_FORMAT_TYPE_I_MULAW: 2528 2460 pcm_format = SNDRV_PCM_FORMAT_MU_LAW; 2529 2461 break; 2530 2462 default: ··· 2538 2470 2539 2471 /* 2540 2472 * parse the format descriptor and stores the possible sample rates 2541 - * on the audioformat table. 2473 + * on the audioformat table (audio class v1). 2542 2474 * 2543 2475 * @dev: usb device 2544 2476 * @fp: audioformat record ··· 2546 2478 * @offset: the start offset of descriptor pointing the rate type 2547 2479 * (7 for type I and II, 8 for type II) 2548 2480 */ 2549 - static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioformat *fp, 2550 - unsigned char *fmt, int offset) 2481 + static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audioformat *fp, 2482 + unsigned char *fmt, int offset) 2551 2483 { 2552 2484 int nr_rates = fmt[offset]; 2553 2485 2554 2486 if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { 2555 - snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", 2487 + snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n", 2556 2488 chip->dev->devnum, fp->iface, fp->altsetting); 2557 2489 return -1; 2558 2490 } ··· 2603 2535 } 2604 2536 2605 2537 /* 2538 + * parse the format descriptor and stores the possible sample rates 2539 + * on the audioformat table (audio class v2). 2540 + */ 2541 + static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, 2542 + struct audioformat *fp, 2543 + struct usb_host_interface *iface) 2544 + { 2545 + struct usb_device *dev = chip->dev; 2546 + unsigned char tmp[2], *data; 2547 + int i, nr_rates, data_size, ret = 0; 2548 + 2549 + /* get the number of sample rates first by only fetching 2 bytes */ 2550 + ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, 2551 + USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 2552 + 0x0100, chip->clock_id << 8, tmp, sizeof(tmp), 1000); 2553 + 2554 + if (ret < 0) { 2555 + snd_printk(KERN_ERR "unable to retrieve number of sample rates\n"); 2556 + goto err; 2557 + } 2558 + 2559 + nr_rates = (tmp[1] << 8) | tmp[0]; 2560 + data_size = 2 + 12 * nr_rates; 2561 + data = kzalloc(data_size, GFP_KERNEL); 2562 + if (!data) { 2563 + ret = -ENOMEM; 2564 + goto err; 2565 + } 2566 + 2567 + /* now get the full information */ 2568 + ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, 2569 + USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, 2570 + 0x0100, chip->clock_id << 8, data, data_size, 1000); 2571 + 2572 + if (ret < 0) { 2573 + snd_printk(KERN_ERR "unable to retrieve sample rate range\n"); 2574 + ret = -EINVAL; 2575 + goto err_free; 2576 + } 2577 + 2578 + fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); 2579 + if (!fp->rate_table) { 2580 + ret = -ENOMEM; 2581 + goto err_free; 2582 + } 2583 + 2584 + fp->nr_rates = 0; 2585 + fp->rate_min = fp->rate_max = 0; 2586 + 2587 + for (i = 0; i < nr_rates; i++) { 2588 + int rate = combine_quad(&data[2 + 12 * i]); 2589 + 2590 + fp->rate_table[fp->nr_rates] = rate; 2591 + if (!fp->rate_min || rate < fp->rate_min) 2592 + fp->rate_min = rate; 2593 + if (!fp->rate_max || rate > fp->rate_max) 2594 + fp->rate_max = rate; 2595 + fp->rates |= snd_pcm_rate_to_rate_bit(rate); 2596 + fp->nr_rates++; 2597 + } 2598 + 2599 + err_free: 2600 + kfree(data); 2601 + err: 2602 + return ret; 2603 + } 2604 + 2605 + /* 2606 2606 * parse the format type I and III descriptors 2607 2607 */ 2608 - static int parse_audio_format_i(struct snd_usb_audio *chip, struct audioformat *fp, 2609 - int format, unsigned char *fmt) 2608 + static int parse_audio_format_i(struct snd_usb_audio *chip, 2609 + struct audioformat *fp, 2610 + int format, void *_fmt, 2611 + struct usb_host_interface *iface) 2610 2612 { 2611 - int pcm_format; 2613 + struct usb_interface_descriptor *altsd = get_iface_desc(iface); 2614 + struct uac_format_type_i_discrete_descriptor *fmt = _fmt; 2615 + int protocol = altsd->bInterfaceProtocol; 2616 + int pcm_format, ret; 2612 2617 2613 - if (fmt[3] == USB_FORMAT_TYPE_III) { 2618 + if (fmt->bFormatType == UAC_FORMAT_TYPE_III) { 2614 2619 /* FIXME: the format type is really IECxxx 2615 2620 * but we give normal PCM format to get the existing 2616 2621 * apps working... ··· 2701 2560 pcm_format = SNDRV_PCM_FORMAT_S16_LE; 2702 2561 } 2703 2562 } else { 2704 - pcm_format = parse_audio_format_i_type(chip, fp, format, fmt); 2563 + pcm_format = parse_audio_format_i_type(chip, fp, format, fmt, protocol); 2705 2564 if (pcm_format < 0) 2706 2565 return -1; 2707 2566 } 2567 + 2708 2568 fp->format = pcm_format; 2709 - fp->channels = fmt[4]; 2569 + 2570 + /* gather possible sample rates */ 2571 + /* audio class v1 reports possible sample rates as part of the 2572 + * proprietary class specific descriptor. 2573 + * audio class v2 uses class specific EP0 range requests for that. 2574 + */ 2575 + switch (protocol) { 2576 + case UAC_VERSION_1: 2577 + fp->channels = fmt->bNrChannels; 2578 + ret = parse_audio_format_rates_v1(chip, fp, _fmt, 7); 2579 + break; 2580 + case UAC_VERSION_2: 2581 + /* fp->channels is already set in this case */ 2582 + ret = parse_audio_format_rates_v2(chip, fp, iface); 2583 + break; 2584 + } 2585 + 2710 2586 if (fp->channels < 1) { 2711 2587 snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n", 2712 2588 chip->dev->devnum, fp->iface, fp->altsetting, fp->channels); 2713 2589 return -1; 2714 2590 } 2715 - return parse_audio_format_rates(chip, fp, fmt, 7); 2591 + 2592 + return ret; 2716 2593 } 2717 2594 2718 2595 /* 2719 - * prase the format type II descriptor 2596 + * parse the format type II descriptor 2720 2597 */ 2721 - static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat *fp, 2722 - int format, unsigned char *fmt) 2598 + static int parse_audio_format_ii(struct snd_usb_audio *chip, 2599 + struct audioformat *fp, 2600 + int format, void *_fmt, 2601 + struct usb_host_interface *iface) 2723 2602 { 2724 - int brate, framesize; 2603 + int brate, framesize, ret; 2604 + struct usb_interface_descriptor *altsd = get_iface_desc(iface); 2605 + int protocol = altsd->bInterfaceProtocol; 2606 + 2725 2607 switch (format) { 2726 - case USB_AUDIO_FORMAT_AC3: 2608 + case UAC_FORMAT_TYPE_II_AC3: 2727 2609 /* FIXME: there is no AC3 format defined yet */ 2728 2610 // fp->format = SNDRV_PCM_FORMAT_AC3; 2729 2611 fp->format = SNDRV_PCM_FORMAT_U8; /* temporarily hack to receive byte streams */ 2730 2612 break; 2731 - case USB_AUDIO_FORMAT_MPEG: 2613 + case UAC_FORMAT_TYPE_II_MPEG: 2732 2614 fp->format = SNDRV_PCM_FORMAT_MPEG; 2733 2615 break; 2734 2616 default: ··· 2760 2596 fp->format = SNDRV_PCM_FORMAT_MPEG; 2761 2597 break; 2762 2598 } 2599 + 2763 2600 fp->channels = 1; 2764 - brate = combine_word(&fmt[4]); /* fmt[4,5] : wMaxBitRate (in kbps) */ 2765 - framesize = combine_word(&fmt[6]); /* fmt[6,7]: wSamplesPerFrame */ 2766 - snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); 2767 - fp->frame_size = framesize; 2768 - return parse_audio_format_rates(chip, fp, fmt, 8); /* fmt[8..] sample rates */ 2601 + 2602 + switch (protocol) { 2603 + case UAC_VERSION_1: { 2604 + struct uac_format_type_ii_discrete_descriptor *fmt = _fmt; 2605 + brate = le16_to_cpu(fmt->wMaxBitRate); 2606 + framesize = le16_to_cpu(fmt->wSamplesPerFrame); 2607 + snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); 2608 + fp->frame_size = framesize; 2609 + ret = parse_audio_format_rates_v1(chip, fp, _fmt, 8); /* fmt[8..] sample rates */ 2610 + break; 2611 + } 2612 + case UAC_VERSION_2: { 2613 + struct uac_format_type_ii_ext_descriptor *fmt = _fmt; 2614 + brate = le16_to_cpu(fmt->wMaxBitRate); 2615 + framesize = le16_to_cpu(fmt->wSamplesPerFrame); 2616 + snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); 2617 + fp->frame_size = framesize; 2618 + ret = parse_audio_format_rates_v2(chip, fp, iface); 2619 + break; 2620 + } 2621 + } 2622 + 2623 + return ret; 2769 2624 } 2770 2625 2771 2626 static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp, 2772 - int format, unsigned char *fmt, int stream) 2627 + int format, unsigned char *fmt, int stream, 2628 + struct usb_host_interface *iface) 2773 2629 { 2774 2630 int err; 2775 2631 2776 2632 switch (fmt[3]) { 2777 - case USB_FORMAT_TYPE_I: 2778 - case USB_FORMAT_TYPE_III: 2779 - err = parse_audio_format_i(chip, fp, format, fmt); 2633 + case UAC_FORMAT_TYPE_I: 2634 + case UAC_FORMAT_TYPE_III: 2635 + err = parse_audio_format_i(chip, fp, format, fmt, iface); 2780 2636 break; 2781 - case USB_FORMAT_TYPE_II: 2782 - err = parse_audio_format_ii(chip, fp, format, fmt); 2637 + case UAC_FORMAT_TYPE_II: 2638 + err = parse_audio_format_ii(chip, fp, format, fmt, iface); 2783 2639 break; 2784 2640 default: 2785 2641 snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n", ··· 2817 2633 if (chip->usb_id == USB_ID(0x041e, 0x3000) || 2818 2634 chip->usb_id == USB_ID(0x041e, 0x3020) || 2819 2635 chip->usb_id == USB_ID(0x041e, 0x3061)) { 2820 - if (fmt[3] == USB_FORMAT_TYPE_I && 2636 + if (fmt[3] == UAC_FORMAT_TYPE_I && 2821 2637 fp->rates != SNDRV_PCM_RATE_48000 && 2822 2638 fp->rates != SNDRV_PCM_RATE_96000) 2823 2639 return -1; ··· 2846 2662 struct usb_host_interface *alts; 2847 2663 struct usb_interface_descriptor *altsd; 2848 2664 int i, altno, err, stream; 2849 - int format; 2665 + int format = 0, num_channels = 0; 2850 2666 struct audioformat *fp = NULL; 2851 2667 unsigned char *fmt, *csep; 2852 - int num; 2668 + int num, protocol; 2853 2669 2854 2670 dev = chip->dev; 2855 2671 ··· 2868 2684 for (i = 0; i < num; i++) { 2869 2685 alts = &iface->altsetting[i]; 2870 2686 altsd = get_iface_desc(alts); 2687 + protocol = altsd->bInterfaceProtocol; 2871 2688 /* skip invalid one */ 2872 2689 if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && 2873 2690 altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || 2874 - (altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING && 2691 + (altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING && 2875 2692 altsd->bInterfaceSubClass != USB_SUBCLASS_VENDOR_SPEC) || 2876 2693 altsd->bNumEndpoints < 1 || 2877 2694 le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == 0) ··· 2893 2708 continue; 2894 2709 2895 2710 /* get audio formats */ 2896 - fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, AS_GENERAL); 2897 - if (!fmt) { 2898 - snd_printk(KERN_ERR "%d:%u:%d : AS_GENERAL descriptor not found\n", 2899 - dev->devnum, iface_no, altno); 2900 - continue; 2711 + switch (protocol) { 2712 + case UAC_VERSION_1: { 2713 + struct uac_as_header_descriptor_v1 *as = 2714 + snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL); 2715 + 2716 + if (!as) { 2717 + snd_printk(KERN_ERR "%d:%u:%d : UAC_AS_GENERAL descriptor not found\n", 2718 + dev->devnum, iface_no, altno); 2719 + continue; 2720 + } 2721 + 2722 + if (as->bLength < sizeof(*as)) { 2723 + snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_AS_GENERAL desc\n", 2724 + dev->devnum, iface_no, altno); 2725 + continue; 2726 + } 2727 + 2728 + format = le16_to_cpu(as->wFormatTag); /* remember the format value */ 2729 + break; 2901 2730 } 2902 2731 2903 - if (fmt[0] < 7) { 2904 - snd_printk(KERN_ERR "%d:%u:%d : invalid AS_GENERAL desc\n", 2905 - dev->devnum, iface_no, altno); 2906 - continue; 2732 + case UAC_VERSION_2: { 2733 + struct uac_as_header_descriptor_v2 *as = 2734 + snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL); 2735 + 2736 + if (!as) { 2737 + snd_printk(KERN_ERR "%d:%u:%d : UAC_AS_GENERAL descriptor not found\n", 2738 + dev->devnum, iface_no, altno); 2739 + continue; 2740 + } 2741 + 2742 + if (as->bLength < sizeof(*as)) { 2743 + snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_AS_GENERAL desc\n", 2744 + dev->devnum, iface_no, altno); 2745 + continue; 2746 + } 2747 + 2748 + num_channels = as->bNrChannels; 2749 + format = le32_to_cpu(as->bmFormats); 2750 + 2751 + break; 2907 2752 } 2908 2753 2909 - format = (fmt[6] << 8) | fmt[5]; /* remember the format value */ 2754 + default: 2755 + snd_printk(KERN_ERR "%d:%u:%d : unknown interface protocol %04x\n", 2756 + dev->devnum, iface_no, altno, protocol); 2757 + continue; 2758 + } 2910 2759 2911 2760 /* get format type */ 2912 - fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, FORMAT_TYPE); 2761 + fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_FORMAT_TYPE); 2913 2762 if (!fmt) { 2914 - snd_printk(KERN_ERR "%d:%u:%d : no FORMAT_TYPE desc\n", 2763 + snd_printk(KERN_ERR "%d:%u:%d : no UAC_FORMAT_TYPE desc\n", 2915 2764 dev->devnum, iface_no, altno); 2916 2765 continue; 2917 2766 } 2918 - if (fmt[0] < 8) { 2919 - snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", 2767 + if (((protocol == UAC_VERSION_1) && (fmt[0] < 8)) || 2768 + ((protocol == UAC_VERSION_2) && (fmt[0] != 6))) { 2769 + snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n", 2920 2770 dev->devnum, iface_no, altno); 2921 2771 continue; 2922 2772 } ··· 2964 2744 if (fmt[4] == 1 && fmt[5] == 2 && altno == 2 && num == 3 && 2965 2745 fp && fp->altsetting == 1 && fp->channels == 1 && 2966 2746 fp->format == SNDRV_PCM_FORMAT_S16_LE && 2747 + protocol == UAC_VERSION_1 && 2967 2748 le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == 2968 2749 fp->maxpacksize * 2) 2969 2750 continue; ··· 2973 2752 /* Creamware Noah has this descriptor after the 2nd endpoint */ 2974 2753 if (!csep && altsd->bNumEndpoints >= 2) 2975 2754 csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT); 2976 - if (!csep || csep[0] < 7 || csep[2] != EP_GENERAL) { 2755 + if (!csep || csep[0] < 7 || csep[2] != UAC_EP_GENERAL) { 2977 2756 snd_printk(KERN_WARNING "%d:%u:%d : no or invalid" 2978 2757 " class specific endpoint descriptor\n", 2979 2758 dev->devnum, iface_no, altno); ··· 2993 2772 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 2994 2773 fp->datainterval = parse_datainterval(chip, alts); 2995 2774 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 2775 + /* num_channels is only set for v2 interfaces */ 2776 + fp->channels = num_channels; 2996 2777 if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) 2997 2778 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) 2998 2779 * (fp->maxpacksize & 0x7ff); ··· 3007 2784 /* Optoplay sets the sample rate attribute although 3008 2785 * it seems not supporting it in fact. 3009 2786 */ 3010 - fp->attributes &= ~EP_CS_ATTR_SAMPLE_RATE; 2787 + fp->attributes &= ~UAC_EP_CS_ATTR_SAMPLE_RATE; 3011 2788 break; 3012 2789 case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */ 3013 2790 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */ 3014 2791 /* doesn't set the sample rate attribute, but supports it */ 3015 - fp->attributes |= EP_CS_ATTR_SAMPLE_RATE; 2792 + fp->attributes |= UAC_EP_CS_ATTR_SAMPLE_RATE; 3016 2793 break; 3017 2794 case USB_ID(0x047f, 0x0ca1): /* plantronics headset */ 3018 2795 case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is ··· 3021 2798 * plantronics headset and Griffin iMic have set adaptive-in 3022 2799 * although it's really not... 3023 2800 */ 3024 - fp->ep_attr &= ~EP_ATTR_MASK; 2801 + fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE; 3025 2802 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 3026 - fp->ep_attr |= EP_ATTR_ADAPTIVE; 2803 + fp->ep_attr |= USB_ENDPOINT_SYNC_ADAPTIVE; 3027 2804 else 3028 - fp->ep_attr |= EP_ATTR_SYNC; 2805 + fp->ep_attr |= USB_ENDPOINT_SYNC_SYNC; 3029 2806 break; 3030 2807 } 3031 2808 3032 2809 /* ok, let's parse further... */ 3033 - if (parse_audio_format(chip, fp, format, fmt, stream) < 0) { 2810 + if (parse_audio_format(chip, fp, format, fmt, stream, alts) < 0) { 3034 2811 kfree(fp->rate_table); 3035 2812 kfree(fp); 3036 2813 continue; ··· 3072 2849 } 3073 2850 } 3074 2851 2852 + static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int interface) 2853 + { 2854 + struct usb_device *dev = chip->dev; 2855 + struct usb_host_interface *alts; 2856 + struct usb_interface_descriptor *altsd; 2857 + struct usb_interface *iface = usb_ifnum_to_if(dev, interface); 2858 + 2859 + if (!iface) { 2860 + snd_printk(KERN_ERR "%d:%u:%d : does not exist\n", 2861 + dev->devnum, ctrlif, interface); 2862 + return -EINVAL; 2863 + } 2864 + 2865 + if (usb_interface_claimed(iface)) { 2866 + snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n", 2867 + dev->devnum, ctrlif, interface); 2868 + return -EINVAL; 2869 + } 2870 + 2871 + alts = &iface->altsetting[0]; 2872 + altsd = get_iface_desc(alts); 2873 + if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || 2874 + altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && 2875 + altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) { 2876 + int err = snd_usbmidi_create(chip->card, iface, 2877 + &chip->midi_list, NULL); 2878 + if (err < 0) { 2879 + snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", 2880 + dev->devnum, ctrlif, interface); 2881 + return -EINVAL; 2882 + } 2883 + usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); 2884 + 2885 + return 0; 2886 + } 2887 + 2888 + if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && 2889 + altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || 2890 + altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING) { 2891 + snd_printdd(KERN_ERR "%d:%u:%d: skipping non-supported interface %d\n", 2892 + dev->devnum, ctrlif, interface, altsd->bInterfaceClass); 2893 + /* skip non-supported classes */ 2894 + return -EINVAL; 2895 + } 2896 + 2897 + if (snd_usb_get_speed(dev) == USB_SPEED_LOW) { 2898 + snd_printk(KERN_ERR "low speed audio streaming not supported\n"); 2899 + return -EINVAL; 2900 + } 2901 + 2902 + if (! parse_audio_endpoints(chip, interface)) { 2903 + usb_set_interface(dev, interface, 0); /* reset the current interface */ 2904 + usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); 2905 + return -EINVAL; 2906 + } 2907 + 2908 + return 0; 2909 + } 2910 + 3075 2911 /* 3076 2912 * parse audio control descriptor and create pcm/midi streams 3077 2913 */ ··· 3138 2856 { 3139 2857 struct usb_device *dev = chip->dev; 3140 2858 struct usb_host_interface *host_iface; 3141 - struct usb_interface *iface; 3142 - unsigned char *p1; 3143 - int i, j; 2859 + struct usb_interface_descriptor *altsd; 2860 + void *control_header; 2861 + int i, protocol; 3144 2862 3145 2863 /* find audiocontrol interface */ 3146 2864 host_iface = &usb_ifnum_to_if(dev, ctrlif)->altsetting[0]; 3147 - if (!(p1 = snd_usb_find_csint_desc(host_iface->extra, host_iface->extralen, NULL, HEADER))) { 3148 - snd_printk(KERN_ERR "cannot find HEADER\n"); 3149 - return -EINVAL; 3150 - } 3151 - if (! p1[7] || p1[0] < 8 + p1[7]) { 3152 - snd_printk(KERN_ERR "invalid HEADER\n"); 2865 + control_header = snd_usb_find_csint_desc(host_iface->extra, 2866 + host_iface->extralen, 2867 + NULL, UAC_HEADER); 2868 + altsd = get_iface_desc(host_iface); 2869 + protocol = altsd->bInterfaceProtocol; 2870 + 2871 + if (!control_header) { 2872 + snd_printk(KERN_ERR "cannot find UAC_HEADER\n"); 3153 2873 return -EINVAL; 3154 2874 } 3155 2875 3156 - /* 3157 - * parse all USB audio streaming interfaces 3158 - */ 3159 - for (i = 0; i < p1[7]; i++) { 3160 - struct usb_host_interface *alts; 3161 - struct usb_interface_descriptor *altsd; 3162 - j = p1[8 + i]; 3163 - iface = usb_ifnum_to_if(dev, j); 3164 - if (!iface) { 3165 - snd_printk(KERN_ERR "%d:%u:%d : does not exist\n", 3166 - dev->devnum, ctrlif, j); 3167 - continue; 2876 + switch (protocol) { 2877 + case UAC_VERSION_1: { 2878 + struct uac_ac_header_descriptor_v1 *h1 = control_header; 2879 + 2880 + if (!h1->bInCollection) { 2881 + snd_printk(KERN_INFO "skipping empty audio interface (v1)\n"); 2882 + return -EINVAL; 3168 2883 } 3169 - if (usb_interface_claimed(iface)) { 3170 - snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n", dev->devnum, ctrlif, j); 3171 - continue; 2884 + 2885 + if (h1->bLength < sizeof(*h1) + h1->bInCollection) { 2886 + snd_printk(KERN_ERR "invalid UAC_HEADER (v1)\n"); 2887 + return -EINVAL; 3172 2888 } 3173 - alts = &iface->altsetting[0]; 3174 - altsd = get_iface_desc(alts); 3175 - if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || 3176 - altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && 3177 - altsd->bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) { 3178 - int err = snd_usbmidi_create(chip->card, iface, 3179 - &chip->midi_list, NULL); 3180 - if (err < 0) { 3181 - snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j); 3182 - continue; 3183 - } 3184 - usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); 3185 - continue; 2889 + 2890 + for (i = 0; i < h1->bInCollection; i++) 2891 + snd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]); 2892 + 2893 + break; 2894 + } 2895 + 2896 + case UAC_VERSION_2: { 2897 + struct uac_clock_source_descriptor *cs; 2898 + struct usb_interface_assoc_descriptor *assoc = 2899 + usb_ifnum_to_if(dev, ctrlif)->intf_assoc; 2900 + 2901 + if (!assoc) { 2902 + snd_printk(KERN_ERR "Audio class v2 interfaces need an interface association\n"); 2903 + return -EINVAL; 3186 2904 } 3187 - if ((altsd->bInterfaceClass != USB_CLASS_AUDIO && 3188 - altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || 3189 - altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING) { 3190 - snd_printdd(KERN_ERR "%d:%u:%d: skipping non-supported interface %d\n", dev->devnum, ctrlif, j, altsd->bInterfaceClass); 3191 - /* skip non-supported classes */ 3192 - continue; 2905 + 2906 + /* FIXME: for now, we expect there is at least one clock source 2907 + * descriptor and we always take the first one. 2908 + * We should properly support devices with multiple clock sources, 2909 + * clock selectors and sample rate conversion units. */ 2910 + 2911 + cs = snd_usb_find_csint_desc(host_iface->extra, host_iface->extralen, 2912 + NULL, UAC_CLOCK_SOURCE); 2913 + 2914 + if (!cs) { 2915 + snd_printk(KERN_ERR "CLOCK_SOURCE descriptor not found\n"); 2916 + return -EINVAL; 3193 2917 } 3194 - if (snd_usb_get_speed(dev) == USB_SPEED_LOW) { 3195 - snd_printk(KERN_ERR "low speed audio streaming not supported\n"); 3196 - continue; 2918 + 2919 + chip->clock_id = cs->bClockID; 2920 + 2921 + for (i = 0; i < assoc->bInterfaceCount; i++) { 2922 + int intf = assoc->bFirstInterface + i; 2923 + 2924 + if (intf != ctrlif) 2925 + snd_usb_create_stream(chip, ctrlif, intf); 3197 2926 } 3198 - if (! parse_audio_endpoints(chip, j)) { 3199 - usb_set_interface(dev, j, 0); /* reset the current interface */ 3200 - usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L); 3201 - } 2927 + 2928 + break; 2929 + } 2930 + 2931 + default: 2932 + snd_printk(KERN_ERR "unknown protocol version 0x%02x\n", protocol); 2933 + return -EINVAL; 3202 2934 } 3203 2935 3204 2936 return 0; ··· 3303 3007 static const struct audioformat ua_format = { 3304 3008 .format = SNDRV_PCM_FORMAT_S24_3LE, 3305 3009 .channels = 2, 3306 - .fmt_type = USB_FORMAT_TYPE_I, 3010 + .fmt_type = UAC_FORMAT_TYPE_I, 3307 3011 .altsetting = 1, 3308 3012 .altset_idx = 1, 3309 3013 .rates = SNDRV_PCM_RATE_CONTINUOUS, ··· 3395 3099 { 3396 3100 static const struct audioformat ua1000_format = { 3397 3101 .format = SNDRV_PCM_FORMAT_S32_LE, 3398 - .fmt_type = USB_FORMAT_TYPE_I, 3102 + .fmt_type = UAC_FORMAT_TYPE_I, 3399 3103 .altsetting = 1, 3400 3104 .altset_idx = 1, 3401 3105 .attributes = 0, ··· 3425 3129 fp->datainterval = parse_datainterval(chip, alts); 3426 3130 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 3427 3131 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]); 3428 - 3429 - stream = (fp->endpoint & USB_DIR_IN) 3430 - ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; 3431 - err = add_audio_endpoint(chip, stream, fp); 3432 - if (err < 0) { 3433 - kfree(fp); 3434 - return err; 3435 - } 3436 - /* FIXME: playback must be synchronized to capture */ 3437 - usb_set_interface(chip->dev, fp->iface, 0); 3438 - return 0; 3439 - } 3440 - 3441 - /* 3442 - * Create a stream for an Edirol UA-101 interface. 3443 - * Copy, paste and modify from Edirol UA-1000 3444 - */ 3445 - static int create_ua101_quirk(struct snd_usb_audio *chip, 3446 - struct usb_interface *iface, 3447 - const struct snd_usb_audio_quirk *quirk) 3448 - { 3449 - static const struct audioformat ua101_format = { 3450 - .format = SNDRV_PCM_FORMAT_S32_LE, 3451 - .fmt_type = USB_FORMAT_TYPE_I, 3452 - .altsetting = 1, 3453 - .altset_idx = 1, 3454 - .attributes = 0, 3455 - .rates = SNDRV_PCM_RATE_CONTINUOUS, 3456 - }; 3457 - struct usb_host_interface *alts; 3458 - struct usb_interface_descriptor *altsd; 3459 - struct audioformat *fp; 3460 - int stream, err; 3461 - 3462 - if (iface->num_altsetting != 2) 3463 - return -ENXIO; 3464 - alts = &iface->altsetting[1]; 3465 - altsd = get_iface_desc(alts); 3466 - if (alts->extralen != 18 || alts->extra[1] != USB_DT_CS_INTERFACE || 3467 - altsd->bNumEndpoints != 1) 3468 - return -ENXIO; 3469 - 3470 - fp = kmemdup(&ua101_format, sizeof(*fp), GFP_KERNEL); 3471 - if (!fp) 3472 - return -ENOMEM; 3473 - 3474 - fp->channels = alts->extra[11]; 3475 - fp->iface = altsd->bInterfaceNumber; 3476 - fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 3477 - fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 3478 - fp->datainterval = parse_datainterval(chip, alts); 3479 - fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 3480 - fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]); 3481 3132 3482 3133 stream = (fp->endpoint & USB_DIR_IN) 3483 3134 ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK; ··· 3473 3230 const struct snd_usb_audio_quirk *quirk) 3474 3231 { 3475 3232 return 0; 3233 + } 3234 + 3235 + /* 3236 + * Allow alignment on audio sub-slot (channel samples) rather than 3237 + * on audio slots (audio frames) 3238 + */ 3239 + static int create_align_transfer_quirk(struct snd_usb_audio *chip, 3240 + struct usb_interface *iface, 3241 + const struct snd_usb_audio_quirk *quirk) 3242 + { 3243 + chip->txfr_quirk = 1; 3244 + return 1; /* Continue with creating streams and mixer */ 3476 3245 } 3477 3246 3478 3247 ··· 3582 3327 } 3583 3328 3584 3329 /* 3330 + * This call will put the synth in "USB send" mode, i.e it will send MIDI 3331 + * messages through USB (this is disabled at startup). The synth will 3332 + * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB 3333 + * sign on its LCD. Values here are chosen based on sniffing USB traffic 3334 + * under Windows. 3335 + */ 3336 + static int snd_usb_accessmusic_boot_quirk(struct usb_device *dev) 3337 + { 3338 + int err, actual_length; 3339 + 3340 + /* "midi send" enable */ 3341 + static const u8 seq[] = { 0x4e, 0x73, 0x52, 0x01 }; 3342 + 3343 + void *buf = kmemdup(seq, ARRAY_SIZE(seq), GFP_KERNEL); 3344 + if (!buf) 3345 + return -ENOMEM; 3346 + err = usb_interrupt_msg(dev, usb_sndintpipe(dev, 0x05), buf, 3347 + ARRAY_SIZE(seq), &actual_length, 1000); 3348 + kfree(buf); 3349 + if (err < 0) 3350 + return err; 3351 + 3352 + return 0; 3353 + } 3354 + 3355 + /* 3585 3356 * Setup quirks 3586 3357 */ 3587 3358 #define AUDIOPHILE_SET 0x01 /* if set, parse device_setup */ ··· 3687 3406 [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, 3688 3407 [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, 3689 3408 [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk, 3690 - [QUIRK_AUDIO_EDIROL_UA101] = create_ua101_quirk, 3691 - [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk 3409 + [QUIRK_AUDIO_EDIROL_UAXX] = create_uaxx_quirk, 3410 + [QUIRK_AUDIO_ALIGN_TRANSFER] = create_align_transfer_quirk 3692 3411 }; 3693 3412 3694 3413 if (quirk->type < QUIRK_TYPE_COUNT) { ··· 3877 3596 ifnum = get_iface_desc(alts)->bInterfaceNumber; 3878 3597 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor), 3879 3598 le16_to_cpu(dev->descriptor.idProduct)); 3880 - 3881 3599 if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum) 3882 3600 goto __err_val; 3883 3601 ··· 3901 3621 /* C-Media CM6206 / CM106-Like Sound Device */ 3902 3622 if (id == USB_ID(0x0d8c, 0x0102)) { 3903 3623 if (snd_usb_cm6206_boot_quirk(dev) < 0) 3624 + goto __err_val; 3625 + } 3626 + 3627 + /* Access Music VirusTI Desktop */ 3628 + if (id == USB_ID(0x133e, 0x0815)) { 3629 + if (snd_usb_accessmusic_boot_quirk(dev) < 0) 3904 3630 goto __err_val; 3905 3631 } 3906 3632 ··· 3947 3661 } 3948 3662 } 3949 3663 3664 + chip->txfr_quirk = 0; 3950 3665 err = 1; /* continue */ 3951 3666 if (quirk && quirk->ifnum != QUIRK_NO_INTERFACE) { 3952 3667 /* need some special handlings */
+18 -88
sound/usb/usbaudio.h
··· 21 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 22 */ 23 23 24 - 25 - /* 26 - */ 27 - 28 - #define USB_SUBCLASS_AUDIO_CONTROL 0x01 29 - #define USB_SUBCLASS_AUDIO_STREAMING 0x02 30 - #define USB_SUBCLASS_MIDI_STREAMING 0x03 31 - #define USB_SUBCLASS_VENDOR_SPEC 0xff 32 - 33 - #define HEADER 0x01 34 - #define INPUT_TERMINAL 0x02 35 - #define OUTPUT_TERMINAL 0x03 36 - #define MIXER_UNIT 0x04 37 - #define SELECTOR_UNIT 0x05 38 - #define FEATURE_UNIT 0x06 39 - #define PROCESSING_UNIT 0x07 40 - #define EXTENSION_UNIT 0x08 41 - 42 - #define AS_GENERAL 0x01 43 - #define FORMAT_TYPE 0x02 44 - #define FORMAT_SPECIFIC 0x03 45 - 46 - #define EP_GENERAL 0x01 47 - 48 - #define MS_GENERAL 0x01 49 - #define MIDI_IN_JACK 0x02 50 - #define MIDI_OUT_JACK 0x03 51 - 52 - /* endpoint attributes */ 53 - #define EP_ATTR_MASK 0x0c 54 - #define EP_ATTR_ASYNC 0x04 55 - #define EP_ATTR_ADAPTIVE 0x08 56 - #define EP_ATTR_SYNC 0x0c 57 - 58 - /* cs endpoint attributes */ 59 - #define EP_CS_ATTR_SAMPLE_RATE 0x01 60 - #define EP_CS_ATTR_PITCH_CONTROL 0x02 61 - #define EP_CS_ATTR_FILL_MAX 0x80 62 - 63 - /* Audio Class specific Request Codes */ 64 - 65 - #define SET_CUR 0x01 66 - #define GET_CUR 0x81 67 - #define SET_MIN 0x02 68 - #define GET_MIN 0x82 69 - #define SET_MAX 0x03 70 - #define GET_MAX 0x83 71 - #define SET_RES 0x04 72 - #define GET_RES 0x84 73 - #define SET_MEM 0x05 74 - #define GET_MEM 0x85 75 - #define GET_STAT 0xff 76 - 77 - /* Terminal Control Selectors */ 78 - 79 - #define COPY_PROTECT_CONTROL 0x01 80 - 81 - /* Endpoint Control Selectors */ 82 - 83 - #define SAMPLING_FREQ_CONTROL 0x01 84 - #define PITCH_CONTROL 0x02 85 - 86 - /* Format Types */ 87 - #define USB_FORMAT_TYPE_I 0x01 88 - #define USB_FORMAT_TYPE_II 0x02 89 - #define USB_FORMAT_TYPE_III 0x03 90 - 91 - /* type I */ 92 - #define USB_AUDIO_FORMAT_PCM 0x01 93 - #define USB_AUDIO_FORMAT_PCM8 0x02 94 - #define USB_AUDIO_FORMAT_IEEE_FLOAT 0x03 95 - #define USB_AUDIO_FORMAT_ALAW 0x04 96 - #define USB_AUDIO_FORMAT_MU_LAW 0x05 97 - 98 - /* type II */ 99 - #define USB_AUDIO_FORMAT_MPEG 0x1001 100 - #define USB_AUDIO_FORMAT_AC3 0x1002 101 - 102 - /* type III */ 103 - #define USB_AUDIO_FORMAT_IEC1937_AC3 0x2001 104 - #define USB_AUDIO_FORMAT_IEC1937_MPEG1_LAYER1 0x2002 105 - #define USB_AUDIO_FORMAT_IEC1937_MPEG2_NOEXT 0x2003 106 - #define USB_AUDIO_FORMAT_IEC1937_MPEG2_EXT 0x2004 107 - #define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER1_LS 0x2005 108 - #define USB_AUDIO_FORMAT_IEC1937_MPEG2_LAYER23_LS 0x2006 109 - 110 - 111 24 /* maximum number of endpoints per interface */ 112 25 #define MIDI_MAX_ENDPOINTS 2 113 26 ··· 38 125 struct snd_card *card; 39 126 u32 usb_id; 40 127 int shutdown; 128 + unsigned int txfr_quirk:1; /* Subframe boundaries on transfers */ 41 129 int num_interfaces; 42 130 int num_suspended_intf; 131 + 132 + /* for audio class v2 */ 133 + int clock_id; 43 134 44 135 struct list_head pcm_list; /* list of pcm streams */ 45 136 int pcm_devs; ··· 76 159 QUIRK_AUDIO_STANDARD_INTERFACE, 77 160 QUIRK_AUDIO_FIXED_ENDPOINT, 78 161 QUIRK_AUDIO_EDIROL_UA1000, 79 - QUIRK_AUDIO_EDIROL_UA101, 80 162 QUIRK_AUDIO_EDIROL_UAXX, 163 + QUIRK_AUDIO_ALIGN_TRANSFER, 81 164 82 165 QUIRK_TYPE_COUNT 83 166 }; ··· 126 209 /* 127 210 */ 128 211 212 + /*E-mu USB samplerate control quirk*/ 213 + enum { 214 + EMU_QUIRK_SR_44100HZ = 0, 215 + EMU_QUIRK_SR_48000HZ, 216 + EMU_QUIRK_SR_88200HZ, 217 + EMU_QUIRK_SR_96000HZ, 218 + EMU_QUIRK_SR_176400HZ, 219 + EMU_QUIRK_SR_192000HZ 220 + }; 221 + 129 222 #define combine_word(s) ((*(s)) | ((unsigned int)(s)[1] << 8)) 130 223 #define combine_triple(s) (combine_word(s) | ((unsigned int)(s)[2] << 16)) 131 224 #define combine_quad(s) (combine_triple(s) | ((unsigned int)(s)[3] << 24)) ··· 160 233 void snd_usbmidi_input_stop(struct list_head* p); 161 234 void snd_usbmidi_input_start(struct list_head* p); 162 235 void snd_usbmidi_disconnect(struct list_head *p); 236 + 237 + void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, 238 + unsigned char samplerate_id); 163 239 164 240 /* 165 241 * retrieve usb_interface descriptor from the host interface
+12 -4
sound/usb/usbmidi.c
··· 46 46 #include <linux/timer.h> 47 47 #include <linux/usb.h> 48 48 #include <linux/wait.h> 49 + #include <linux/usb/audio.h> 50 + 49 51 #include <sound/core.h> 50 52 #include <sound/control.h> 51 53 #include <sound/rawmidi.h> ··· 1421 1419 EXTERNAL_PORT(0x086a, 0x0001, 8, "%s Broadcast"), 1422 1420 EXTERNAL_PORT(0x086a, 0x0002, 8, "%s Broadcast"), 1423 1421 EXTERNAL_PORT(0x086a, 0x0003, 4, "%s Broadcast"), 1422 + /* Access Music Virus TI */ 1423 + EXTERNAL_PORT(0x133e, 0x0815, 0, "%s MIDI"), 1424 + PORT_INFO(0x133e, 0x0815, 1, "%s Synth", 0, 1425 + SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC | 1426 + SNDRV_SEQ_PORT_TYPE_HARDWARE | 1427 + SNDRV_SEQ_PORT_TYPE_SYNTHESIZER), 1424 1428 }; 1425 1429 1426 1430 static struct port_info *find_port_info(struct snd_usb_midi* umidi, int number) ··· 1542 1534 if (hostif->extralen >= 7 && 1543 1535 ms_header->bLength >= 7 && 1544 1536 ms_header->bDescriptorType == USB_DT_CS_INTERFACE && 1545 - ms_header->bDescriptorSubtype == HEADER) 1537 + ms_header->bDescriptorSubtype == UAC_HEADER) 1546 1538 snd_printdd(KERN_INFO "MIDIStreaming version %02x.%02x\n", 1547 1539 ms_header->bcdMSC[1], ms_header->bcdMSC[0]); 1548 1540 else ··· 1558 1550 if (hostep->extralen < 4 || 1559 1551 ms_ep->bLength < 4 || 1560 1552 ms_ep->bDescriptorType != USB_DT_CS_ENDPOINT || 1561 - ms_ep->bDescriptorSubtype != MS_GENERAL) 1553 + ms_ep->bDescriptorSubtype != UAC_MS_GENERAL) 1562 1554 continue; 1563 1555 if (usb_endpoint_dir_out(ep)) { 1564 1556 if (endpoints[epidx].out_ep) { ··· 1770 1762 cs_desc < hostif->extra + hostif->extralen && cs_desc[0] >= 2; 1771 1763 cs_desc += cs_desc[0]) { 1772 1764 if (cs_desc[1] == USB_DT_CS_INTERFACE) { 1773 - if (cs_desc[2] == MIDI_IN_JACK) 1765 + if (cs_desc[2] == UAC_MIDI_IN_JACK) 1774 1766 endpoint->in_cables = (endpoint->in_cables << 1) | 1; 1775 - else if (cs_desc[2] == MIDI_OUT_JACK) 1767 + else if (cs_desc[2] == UAC_MIDI_OUT_JACK) 1776 1768 endpoint->out_cables = (endpoint->out_cables << 1) | 1; 1777 1769 } 1778 1770 }
+264 -107
sound/usb/usbmixer.c
··· 32 32 #include <linux/slab.h> 33 33 #include <linux/string.h> 34 34 #include <linux/usb.h> 35 + #include <linux/usb/audio.h> 36 + 35 37 #include <sound/core.h> 36 38 #include <sound/control.h> 37 39 #include <sound/hwdep.h> ··· 71 69 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */ 72 70 }; 73 71 72 + #define MAX_ID_ELEMS 256 73 + 74 74 struct usb_mixer_interface { 75 75 struct snd_usb_audio *chip; 76 76 unsigned int ctrlif; 77 77 struct list_head list; 78 78 unsigned int ignore_ctl_error; 79 79 struct urb *urb; 80 - struct usb_mixer_elem_info **id_elems; /* array[256], indexed by unit id */ 80 + /* array[MAX_ID_ELEMS], indexed by unit id */ 81 + struct usb_mixer_elem_info **id_elems; 81 82 82 83 /* Sound Blaster remote control stuff */ 83 84 const struct rc_config *rc_cfg; ··· 110 105 struct usb_mixer_interface *mixer; 111 106 unsigned char *buffer; 112 107 unsigned int buflen; 113 - DECLARE_BITMAP(unitbitmap, 256); 108 + DECLARE_BITMAP(unitbitmap, MAX_ID_ELEMS); 114 109 struct usb_audio_term oterm; 115 110 const struct usbmix_name_map *map; 116 111 const struct usbmix_selector_map *selector_map; ··· 128 123 int channels; 129 124 int val_type; 130 125 int min, max, res; 126 + int dBmin, dBmax; 131 127 int cached; 132 128 int cache_val[MAX_CHANNELS]; 133 129 u8 initialized; ··· 192 186 USB_PROC_DCR_RELEASE = 6, 193 187 }; 194 188 189 + /*E-mu 0202(0404) eXtension Unit(XU) control*/ 190 + enum { 191 + USB_XU_CLOCK_RATE = 0xe301, 192 + USB_XU_CLOCK_SOURCE = 0xe302, 193 + USB_XU_DIGITAL_IO_STATUS = 0xe303, 194 + USB_XU_DEVICE_OPTIONS = 0xe304, 195 + USB_XU_DIRECT_MONITORING = 0xe305, 196 + USB_XU_METERING = 0xe306 197 + }; 198 + enum { 199 + USB_XU_CLOCK_SOURCE_SELECTOR = 0x02, /* clock source*/ 200 + USB_XU_CLOCK_RATE_SELECTOR = 0x03, /* clock rate */ 201 + USB_XU_DIGITAL_FORMAT_SELECTOR = 0x01, /* the spdif format */ 202 + USB_XU_SOFT_LIMIT_SELECTOR = 0x03 /* soft limiter */ 203 + }; 195 204 196 205 /* 197 206 * manual mapping of mixer names ··· 215 194 */ 216 195 #include "usbmixer_maps.c" 217 196 218 - /* get the mapped name if the unit matches */ 219 - static int check_mapped_name(struct mixer_build *state, int unitid, int control, char *buf, int buflen) 197 + static const struct usbmix_name_map * 198 + find_map(struct mixer_build *state, int unitid, int control) 220 199 { 221 - const struct usbmix_name_map *p; 200 + const struct usbmix_name_map *p = state->map; 222 201 223 - if (! state->map) 224 - return 0; 202 + if (!p) 203 + return NULL; 225 204 226 205 for (p = state->map; p->id; p++) { 227 - if (p->id == unitid && p->name && 228 - (! control || ! p->control || control == p->control)) { 229 - buflen--; 230 - return strlcpy(buf, p->name, buflen); 231 - } 206 + if (p->id == unitid && 207 + (!control || !p->control || control == p->control)) 208 + return p; 232 209 } 233 - return 0; 210 + return NULL; 211 + } 212 + 213 + /* get the mapped name if the unit matches */ 214 + static int 215 + check_mapped_name(const struct usbmix_name_map *p, char *buf, int buflen) 216 + { 217 + if (!p || !p->name) 218 + return 0; 219 + 220 + buflen--; 221 + return strlcpy(buf, p->name, buflen); 234 222 } 235 223 236 224 /* check whether the control should be ignored */ 237 - static int check_ignored_ctl(struct mixer_build *state, int unitid, int control) 225 + static inline int 226 + check_ignored_ctl(const struct usbmix_name_map *p) 238 227 { 239 - const struct usbmix_name_map *p; 240 - 241 - if (! state->map) 228 + if (!p || p->name || p->dB) 242 229 return 0; 243 - for (p = state->map; p->id; p++) { 244 - if (p->id == unitid && ! p->name && 245 - (! control || ! p->control || control == p->control)) { 246 - /* 247 - printk(KERN_DEBUG "ignored control %d:%d\n", 248 - unitid, control); 249 - */ 250 - return 1; 251 - } 230 + return 1; 231 + } 232 + 233 + /* dB mapping */ 234 + static inline void check_mapped_dB(const struct usbmix_name_map *p, 235 + struct usb_mixer_elem_info *cval) 236 + { 237 + if (p && p->dB) { 238 + cval->dBmin = p->dB->min; 239 + cval->dBmax = p->dB->max; 252 240 } 253 - return 0; 254 241 } 255 242 256 243 /* get the mapped selector source name */ ··· 286 257 p = NULL; 287 258 while ((p = snd_usb_find_desc(state->buffer, state->buflen, p, 288 259 USB_DT_CS_INTERFACE)) != NULL) { 289 - if (p[0] >= 4 && p[2] >= INPUT_TERMINAL && p[2] <= EXTENSION_UNIT && p[3] == unit) 260 + if (p[0] >= 4 && p[2] >= UAC_INPUT_TERMINAL && p[2] <= UAC_EXTENSION_UNIT_V1 && p[3] == unit) 290 261 return p; 291 262 } 292 263 return NULL; ··· 407 378 408 379 static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int *value) 409 380 { 410 - return get_ctl_value(cval, GET_CUR, validx, value); 381 + return get_ctl_value(cval, UAC_GET_CUR, validx, value); 411 382 } 412 383 413 384 /* channel = 0: master, 1 = first channel */ 414 385 static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval, 415 386 int channel, int *value) 416 387 { 417 - return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value); 388 + return get_ctl_value(cval, UAC_GET_CUR, (cval->control << 8) | channel, value); 418 389 } 419 390 420 391 static int get_cur_mix_value(struct usb_mixer_elem_info *cval, ··· 468 439 469 440 static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int value) 470 441 { 471 - return set_ctl_value(cval, SET_CUR, validx, value); 442 + return set_ctl_value(cval, UAC_SET_CUR, validx, value); 472 443 } 473 444 474 445 static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, 475 446 int index, int value) 476 447 { 477 448 int err; 478 - err = set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel, 449 + err = set_ctl_value(cval, UAC_SET_CUR, (cval->control << 8) | channel, 479 450 value); 480 451 if (err < 0) 481 452 return err; ··· 495 466 496 467 if (size < sizeof(scale)) 497 468 return -ENOMEM; 498 - /* USB descriptions contain the dB scale in 1/256 dB unit 499 - * while ALSA TLV contains in 1/100 dB unit 500 - */ 501 - scale[2] = (convert_signed_value(cval, cval->min) * 100) / 256; 502 - scale[3] = (convert_signed_value(cval, cval->max) * 100) / 256; 503 - if (scale[3] <= scale[2]) { 504 - /* something is wrong; assume it's either from/to 0dB */ 505 - if (scale[2] < 0) 506 - scale[3] = 0; 507 - else if (scale[2] > 0) 508 - scale[2] = 0; 509 - else /* totally crap, return an error */ 510 - return -EINVAL; 511 - } 469 + scale[2] = cval->dBmin; 470 + scale[3] = cval->dBmax; 512 471 if (copy_to_user(_tlv, scale, sizeof(scale))) 513 472 return -EFAULT; 514 473 return 0; ··· 605 588 if (term_only) 606 589 return 0; 607 590 switch (iterm->type >> 16) { 608 - case SELECTOR_UNIT: 591 + case UAC_SELECTOR_UNIT: 609 592 strcpy(name, "Selector"); return 8; 610 - case PROCESSING_UNIT: 593 + case UAC_PROCESSING_UNIT_V1: 611 594 strcpy(name, "Process Unit"); return 12; 612 - case EXTENSION_UNIT: 595 + case UAC_EXTENSION_UNIT_V1: 613 596 strcpy(name, "Ext Unit"); return 8; 614 - case MIXER_UNIT: 597 + case UAC_MIXER_UNIT: 615 598 strcpy(name, "Mixer"); return 5; 616 599 default: 617 600 return sprintf(name, "Unit %d", iterm->id); ··· 650 633 while ((p1 = find_audio_control_unit(state, id)) != NULL) { 651 634 term->id = id; 652 635 switch (p1[2]) { 653 - case INPUT_TERMINAL: 636 + case UAC_INPUT_TERMINAL: 654 637 term->type = combine_word(p1 + 4); 655 638 term->channels = p1[7]; 656 639 term->chconfig = combine_word(p1 + 8); 657 640 term->name = p1[11]; 658 641 return 0; 659 - case FEATURE_UNIT: 642 + case UAC_FEATURE_UNIT: 660 643 id = p1[4]; 661 644 break; /* continue to parse */ 662 - case MIXER_UNIT: 645 + case UAC_MIXER_UNIT: 663 646 term->type = p1[2] << 16; /* virtual type */ 664 647 term->channels = p1[5 + p1[4]]; 665 648 term->chconfig = combine_word(p1 + 6 + p1[4]); 666 649 term->name = p1[p1[0] - 1]; 667 650 return 0; 668 - case SELECTOR_UNIT: 651 + case UAC_SELECTOR_UNIT: 669 652 /* call recursively to retrieve the channel info */ 670 653 if (check_input_term(state, p1[5], term) < 0) 671 654 return -ENODEV; ··· 673 656 term->id = id; 674 657 term->name = p1[9 + p1[0] - 1]; 675 658 return 0; 676 - case PROCESSING_UNIT: 677 - case EXTENSION_UNIT: 659 + case UAC_PROCESSING_UNIT_V1: 660 + case UAC_EXTENSION_UNIT_V1: 678 661 if (p1[6] == 1) { 679 662 id = p1[7]; 680 663 break; /* continue to parse */ ··· 737 720 cval->min = default_min; 738 721 cval->max = cval->min + 1; 739 722 cval->res = 1; 723 + cval->dBmin = cval->dBmax = 0; 740 724 741 725 if (cval->val_type == USB_MIXER_BOOLEAN || 742 726 cval->val_type == USB_MIXER_INV_BOOLEAN) { ··· 752 734 break; 753 735 } 754 736 } 755 - if (get_ctl_value(cval, GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || 756 - get_ctl_value(cval, GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { 737 + if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || 738 + get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { 757 739 snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", 758 740 cval->id, cval->mixer->ctrlif, cval->control, cval->id); 759 741 return -EINVAL; 760 742 } 761 - if (get_ctl_value(cval, GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { 743 + if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { 762 744 cval->res = 1; 763 745 } else { 764 746 int last_valid_res = cval->res; 765 747 766 748 while (cval->res > 1) { 767 - if (set_ctl_value(cval, SET_RES, (cval->control << 8) | minchn, cval->res / 2) < 0) 749 + if (set_ctl_value(cval, UAC_SET_RES, (cval->control << 8) | minchn, cval->res / 2) < 0) 768 750 break; 769 751 cval->res /= 2; 770 752 } 771 - if (get_ctl_value(cval, GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) 753 + if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) 772 754 cval->res = last_valid_res; 773 755 } 774 756 if (cval->res == 0) ··· 805 787 806 788 cval->initialized = 1; 807 789 } 790 + 791 + /* USB descriptions contain the dB scale in 1/256 dB unit 792 + * while ALSA TLV contains in 1/100 dB unit 793 + */ 794 + cval->dBmin = (convert_signed_value(cval, cval->min) * 100) / 256; 795 + cval->dBmax = (convert_signed_value(cval, cval->max) * 100) / 256; 796 + if (cval->dBmin > cval->dBmax) { 797 + /* something is wrong; assume it's either from/to 0dB */ 798 + if (cval->dBmin < 0) 799 + cval->dBmax = 0; 800 + else if (cval->dBmin > 0) 801 + cval->dBmin = 0; 802 + if (cval->dBmin > cval->dBmax) { 803 + /* totally crap, return an error */ 804 + return -EINVAL; 805 + } 806 + } 807 + 808 808 return 0; 809 809 } 810 810 ··· 948 912 int nameid = desc[desc[0] - 1]; 949 913 struct snd_kcontrol *kctl; 950 914 struct usb_mixer_elem_info *cval; 915 + const struct usbmix_name_map *map; 951 916 952 917 control++; /* change from zero-based to 1-based value */ 953 918 ··· 957 920 return; 958 921 } 959 922 960 - if (check_ignored_ctl(state, unitid, control)) 923 + map = find_map(state, unitid, control); 924 + if (check_ignored_ctl(map)) 961 925 return; 962 926 963 927 cval = kzalloc(sizeof(*cval), GFP_KERNEL); ··· 992 954 } 993 955 kctl->private_free = usb_mixer_elem_free; 994 956 995 - len = check_mapped_name(state, unitid, control, kctl->id.name, sizeof(kctl->id.name)); 957 + len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); 996 958 mapped_name = len != 0; 997 959 if (! len && nameid) 998 - len = snd_usb_copy_string_desc(state, nameid, kctl->id.name, sizeof(kctl->id.name)); 960 + len = snd_usb_copy_string_desc(state, nameid, 961 + kctl->id.name, sizeof(kctl->id.name)); 999 962 1000 963 switch (control) { 1001 964 case USB_FEATURE_MUTE: ··· 1034 995 kctl->vd[0].access |= 1035 996 SNDRV_CTL_ELEM_ACCESS_TLV_READ | 1036 997 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; 998 + check_mapped_dB(map, cval); 1037 999 } 1038 1000 break; 1039 1001 ··· 1088 1048 * 1089 1049 * most of controlls are defined here. 1090 1050 */ 1091 - static int parse_audio_feature_unit(struct mixer_build *state, int unitid, unsigned char *ftr) 1051 + static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void *_ftr) 1092 1052 { 1093 1053 int channels, i, j; 1094 1054 struct usb_audio_term iterm; 1095 1055 unsigned int master_bits, first_ch_bits; 1096 1056 int err, csize; 1057 + struct uac_feature_unit_descriptor *ftr = _ftr; 1097 1058 1098 - if (ftr[0] < 7 || ! (csize = ftr[5]) || ftr[0] < 7 + csize) { 1099 - snd_printk(KERN_ERR "usbaudio: unit %u: invalid FEATURE_UNIT descriptor\n", unitid); 1059 + if (ftr->bLength < 7 || ! (csize = ftr->bControlSize) || ftr->bLength < 7 + csize) { 1060 + snd_printk(KERN_ERR "usbaudio: unit %u: invalid UAC_FEATURE_UNIT descriptor\n", unitid); 1100 1061 return -EINVAL; 1101 1062 } 1102 1063 1103 1064 /* parse the source unit */ 1104 - if ((err = parse_audio_unit(state, ftr[4])) < 0) 1065 + if ((err = parse_audio_unit(state, ftr->bSourceID)) < 0) 1105 1066 return err; 1106 1067 1107 1068 /* determine the input source type and name */ 1108 - if (check_input_term(state, ftr[4], &iterm) < 0) 1069 + if (check_input_term(state, ftr->bSourceID, &iterm) < 0) 1109 1070 return -EINVAL; 1110 1071 1111 - channels = (ftr[0] - 7) / csize - 1; 1072 + channels = (ftr->bLength - 7) / csize - 1; 1112 1073 1113 - master_bits = snd_usb_combine_bytes(ftr + 6, csize); 1074 + master_bits = snd_usb_combine_bytes(ftr->controls, csize); 1114 1075 /* master configuration quirks */ 1115 1076 switch (state->chip->usb_id) { 1116 1077 case USB_ID(0x08bb, 0x2702): ··· 1122 1081 break; 1123 1082 } 1124 1083 if (channels > 0) 1125 - first_ch_bits = snd_usb_combine_bytes(ftr + 6 + csize, csize); 1084 + first_ch_bits = snd_usb_combine_bytes(ftr->controls + csize, csize); 1126 1085 else 1127 1086 first_ch_bits = 0; 1128 1087 /* check all control types */ 1129 1088 for (i = 0; i < 10; i++) { 1130 1089 unsigned int ch_bits = 0; 1131 1090 for (j = 0; j < channels; j++) { 1132 - unsigned int mask = snd_usb_combine_bytes(ftr + 6 + csize * (j+1), csize); 1091 + unsigned int mask = snd_usb_combine_bytes(ftr->controls + csize * (j+1), csize); 1133 1092 if (mask & (1 << i)) 1134 1093 ch_bits |= (1 << j); 1135 1094 } 1136 1095 if (ch_bits & 1) /* the first channel must be set (for ease of programming) */ 1137 - build_feature_ctl(state, ftr, ch_bits, i, &iterm, unitid); 1096 + build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid); 1138 1097 if (master_bits & (1 << i)) 1139 - build_feature_ctl(state, ftr, 0, i, &iterm, unitid); 1098 + build_feature_ctl(state, _ftr, 0, i, &iterm, unitid); 1140 1099 } 1141 1100 1142 1101 return 0; ··· 1163 1122 unsigned int num_outs = desc[5 + input_pins]; 1164 1123 unsigned int i, len; 1165 1124 struct snd_kcontrol *kctl; 1125 + const struct usbmix_name_map *map; 1166 1126 1167 - if (check_ignored_ctl(state, unitid, 0)) 1127 + map = find_map(state, unitid, 0); 1128 + if (check_ignored_ctl(map)) 1168 1129 return; 1169 1130 1170 1131 cval = kzalloc(sizeof(*cval), GFP_KERNEL); ··· 1195 1152 } 1196 1153 kctl->private_free = usb_mixer_elem_free; 1197 1154 1198 - len = check_mapped_name(state, unitid, 0, kctl->id.name, sizeof(kctl->id.name)); 1155 + len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); 1199 1156 if (! len) 1200 1157 len = get_term_name(state, iterm, kctl->id.name, sizeof(kctl->id.name), 0); 1201 1158 if (! len) ··· 1373 1330 { USB_PROC_DCR, "DCR", dcr_proc_info }, 1374 1331 { 0 }, 1375 1332 }; 1376 - 1333 + /* 1334 + * predefined data for extension units 1335 + */ 1336 + static struct procunit_value_info clock_rate_xu_info[] = { 1337 + { USB_XU_CLOCK_RATE_SELECTOR, "Selector", USB_MIXER_U8, 0 }, 1338 + { 0 } 1339 + }; 1340 + static struct procunit_value_info clock_source_xu_info[] = { 1341 + { USB_XU_CLOCK_SOURCE_SELECTOR, "External", USB_MIXER_BOOLEAN }, 1342 + { 0 } 1343 + }; 1344 + static struct procunit_value_info spdif_format_xu_info[] = { 1345 + { USB_XU_DIGITAL_FORMAT_SELECTOR, "SPDIF/AC3", USB_MIXER_BOOLEAN }, 1346 + { 0 } 1347 + }; 1348 + static struct procunit_value_info soft_limit_xu_info[] = { 1349 + { USB_XU_SOFT_LIMIT_SELECTOR, " ", USB_MIXER_BOOLEAN }, 1350 + { 0 } 1351 + }; 1352 + static struct procunit_info extunits[] = { 1353 + { USB_XU_CLOCK_RATE, "Clock rate", clock_rate_xu_info }, 1354 + { USB_XU_CLOCK_SOURCE, "DigitalIn CLK source", clock_source_xu_info }, 1355 + { USB_XU_DIGITAL_IO_STATUS, "DigitalOut format:", spdif_format_xu_info }, 1356 + { USB_XU_DEVICE_OPTIONS, "AnalogueIn Soft Limit", soft_limit_xu_info }, 1357 + { 0 } 1358 + }; 1377 1359 /* 1378 1360 * build a processing/extension unit 1379 1361 */ ··· 1410 1342 int i, err, nameid, type, len; 1411 1343 struct procunit_info *info; 1412 1344 struct procunit_value_info *valinfo; 1345 + const struct usbmix_name_map *map; 1413 1346 static struct procunit_value_info default_value_info[] = { 1414 1347 { 0x01, "Switch", USB_MIXER_BOOLEAN }, 1415 1348 { 0 } ··· 1440 1371 /* FIXME: bitmap might be longer than 8bit */ 1441 1372 if (! (dsc[12 + num_ins] & (1 << (valinfo->control - 1)))) 1442 1373 continue; 1443 - if (check_ignored_ctl(state, unitid, valinfo->control)) 1374 + map = find_map(state, unitid, valinfo->control); 1375 + if (check_ignored_ctl(map)) 1444 1376 continue; 1445 1377 cval = kzalloc(sizeof(*cval), GFP_KERNEL); 1446 1378 if (! cval) { ··· 1461 1391 cval->max = dsc[15]; 1462 1392 cval->res = 1; 1463 1393 cval->initialized = 1; 1464 - } else 1465 - get_min_max(cval, valinfo->min_value); 1394 + } else { 1395 + if (type == USB_XU_CLOCK_RATE) { 1396 + /* E-Mu USB 0404/0202/TrackerPre 1397 + * samplerate control quirk 1398 + */ 1399 + cval->min = 0; 1400 + cval->max = 5; 1401 + cval->res = 1; 1402 + cval->initialized = 1; 1403 + } else 1404 + get_min_max(cval, valinfo->min_value); 1405 + } 1466 1406 1467 1407 kctl = snd_ctl_new1(&mixer_procunit_ctl, cval); 1468 1408 if (! kctl) { ··· 1482 1402 } 1483 1403 kctl->private_free = usb_mixer_elem_free; 1484 1404 1485 - if (check_mapped_name(state, unitid, cval->control, kctl->id.name, sizeof(kctl->id.name))) 1486 - ; 1405 + if (check_mapped_name(map, kctl->id.name, 1406 + sizeof(kctl->id.name))) 1407 + /* nothing */ ; 1487 1408 else if (info->name) 1488 1409 strlcpy(kctl->id.name, info->name, sizeof(kctl->id.name)); 1489 1410 else { ··· 1514 1433 1515 1434 static int parse_audio_extension_unit(struct mixer_build *state, int unitid, unsigned char *desc) 1516 1435 { 1517 - return build_audio_procunit(state, unitid, desc, NULL, "Extension Unit"); 1436 + return build_audio_procunit(state, unitid, desc, extunits, "Extension Unit"); 1518 1437 } 1519 1438 1520 1439 ··· 1623 1542 int err; 1624 1543 struct usb_mixer_elem_info *cval; 1625 1544 struct snd_kcontrol *kctl; 1545 + const struct usbmix_name_map *map; 1626 1546 char **namelist; 1627 1547 1628 1548 if (! num_ins || desc[0] < 5 + num_ins) { ··· 1639 1557 if (num_ins == 1) /* only one ? nonsense! */ 1640 1558 return 0; 1641 1559 1642 - if (check_ignored_ctl(state, unitid, 0)) 1560 + map = find_map(state, unitid, 0); 1561 + if (check_ignored_ctl(map)) 1643 1562 return 0; 1644 1563 1645 1564 cval = kzalloc(sizeof(*cval), GFP_KERNEL); ··· 1695 1612 kctl->private_free = usb_mixer_selector_elem_free; 1696 1613 1697 1614 nameid = desc[desc[0] - 1]; 1698 - len = check_mapped_name(state, unitid, 0, kctl->id.name, sizeof(kctl->id.name)); 1615 + len = check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)); 1699 1616 if (len) 1700 1617 ; 1701 1618 else if (nameid) ··· 1739 1656 } 1740 1657 1741 1658 switch (p1[2]) { 1742 - case INPUT_TERMINAL: 1659 + case UAC_INPUT_TERMINAL: 1743 1660 return 0; /* NOP */ 1744 - case MIXER_UNIT: 1661 + case UAC_MIXER_UNIT: 1745 1662 return parse_audio_mixer_unit(state, unitid, p1); 1746 - case SELECTOR_UNIT: 1663 + case UAC_SELECTOR_UNIT: 1747 1664 return parse_audio_selector_unit(state, unitid, p1); 1748 - case FEATURE_UNIT: 1665 + case UAC_FEATURE_UNIT: 1749 1666 return parse_audio_feature_unit(state, unitid, p1); 1750 - case PROCESSING_UNIT: 1667 + case UAC_PROCESSING_UNIT_V1: 1751 1668 return parse_audio_processing_unit(state, unitid, p1); 1752 - case EXTENSION_UNIT: 1669 + case UAC_EXTENSION_UNIT_V1: 1753 1670 return parse_audio_extension_unit(state, unitid, p1); 1754 1671 default: 1755 1672 snd_printk(KERN_ERR "usbaudio: unit %u: unexpected type 0x%02x\n", unitid, p1[2]); ··· 1779 1696 /* 1780 1697 * create mixer controls 1781 1698 * 1782 - * walk through all OUTPUT_TERMINAL descriptors to search for mixers 1699 + * walk through all UAC_OUTPUT_TERMINAL descriptors to search for mixers 1783 1700 */ 1784 1701 static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) 1785 1702 { 1786 - unsigned char *desc; 1703 + struct uac_output_terminal_descriptor_v1 *desc; 1787 1704 struct mixer_build state; 1788 1705 int err; 1789 1706 const struct usbmix_ctl_map *map; ··· 1807 1724 } 1808 1725 1809 1726 desc = NULL; 1810 - while ((desc = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, desc, OUTPUT_TERMINAL)) != NULL) { 1811 - if (desc[0] < 9) 1727 + while ((desc = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, desc, UAC_OUTPUT_TERMINAL)) != NULL) { 1728 + if (desc->bLength < 9) 1812 1729 continue; /* invalid descriptor? */ 1813 - set_bit(desc[3], state.unitbitmap); /* mark terminal ID as visited */ 1814 - state.oterm.id = desc[3]; 1815 - state.oterm.type = combine_word(&desc[4]); 1816 - state.oterm.name = desc[8]; 1817 - err = parse_audio_unit(&state, desc[7]); 1730 + set_bit(desc->bTerminalID, state.unitbitmap); /* mark terminal ID as visited */ 1731 + state.oterm.id = desc->bTerminalID; 1732 + state.oterm.type = le16_to_cpu(desc->wTerminalType); 1733 + state.oterm.name = desc->iTerminal; 1734 + err = parse_audio_unit(&state, desc->bSourceID); 1818 1735 if (err < 0) 1819 1736 return err; 1820 1737 } ··· 1829 1746 for (info = mixer->id_elems[unitid]; info; info = info->next_id_elem) 1830 1747 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, 1831 1748 info->elem_id); 1749 + } 1750 + 1751 + static void snd_usb_mixer_dump_cval(struct snd_info_buffer *buffer, 1752 + int unitid, 1753 + struct usb_mixer_elem_info *cval) 1754 + { 1755 + static char *val_types[] = {"BOOLEAN", "INV_BOOLEAN", 1756 + "S8", "U8", "S16", "U16"}; 1757 + snd_iprintf(buffer, " Unit: %i\n", unitid); 1758 + if (cval->elem_id) 1759 + snd_iprintf(buffer, " Control: name=\"%s\", index=%i\n", 1760 + cval->elem_id->name, cval->elem_id->index); 1761 + snd_iprintf(buffer, " Info: id=%i, control=%i, cmask=0x%x, " 1762 + "channels=%i, type=\"%s\"\n", cval->id, 1763 + cval->control, cval->cmask, cval->channels, 1764 + val_types[cval->val_type]); 1765 + snd_iprintf(buffer, " Volume: min=%i, max=%i, dBmin=%i, dBmax=%i\n", 1766 + cval->min, cval->max, cval->dBmin, cval->dBmax); 1767 + } 1768 + 1769 + static void snd_usb_mixer_proc_read(struct snd_info_entry *entry, 1770 + struct snd_info_buffer *buffer) 1771 + { 1772 + struct snd_usb_audio *chip = entry->private_data; 1773 + struct usb_mixer_interface *mixer; 1774 + struct usb_mixer_elem_info *cval; 1775 + int unitid; 1776 + 1777 + list_for_each_entry(mixer, &chip->mixer_list, list) { 1778 + snd_iprintf(buffer, 1779 + "USB Mixer: usb_id=0x%08x, ctrlif=%i, ctlerr=%i\n", 1780 + chip->usb_id, mixer->ctrlif, 1781 + mixer->ignore_ctl_error); 1782 + snd_iprintf(buffer, "Card: %s\n", chip->card->longname); 1783 + for (unitid = 0; unitid < MAX_ID_ELEMS; unitid++) { 1784 + for (cval = mixer->id_elems[unitid]; cval; 1785 + cval = cval->next_id_elem) 1786 + snd_usb_mixer_dump_cval(buffer, unitid, cval); 1787 + } 1788 + } 1832 1789 } 1833 1790 1834 1791 static void snd_usb_mixer_memory_change(struct usb_mixer_interface *mixer, ··· 2047 1924 } 2048 1925 mixer->rc_setup_packet->bRequestType = 2049 1926 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE; 2050 - mixer->rc_setup_packet->bRequest = GET_MEM; 1927 + mixer->rc_setup_packet->bRequest = UAC_GET_MEM; 2051 1928 mixer->rc_setup_packet->wValue = cpu_to_le16(0); 2052 1929 mixer->rc_setup_packet->wIndex = cpu_to_le16(0); 2053 1930 mixer->rc_setup_packet->wLength = cpu_to_le16(len); ··· 2170 2047 snd_iprintf(buffer, "%s: ", jacks[i].name); 2171 2048 err = snd_usb_ctl_msg(mixer->chip->dev, 2172 2049 usb_rcvctrlpipe(mixer->chip->dev, 0), 2173 - GET_MEM, USB_DIR_IN | USB_TYPE_CLASS | 2050 + UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS | 2174 2051 USB_RECIP_INTERFACE, 0, 2175 2052 jacks[i].unitid << 8, buf, 3, 100); 2176 2053 if (err == 3 && (buf[0] == 3 || buf[0] == 6)) ··· 2232 2109 return 0; 2233 2110 } 2234 2111 2112 + void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, 2113 + unsigned char samplerate_id) 2114 + { 2115 + struct usb_mixer_interface *mixer; 2116 + struct usb_mixer_elem_info *cval; 2117 + int unitid = 12; /* SamleRate ExtensionUnit ID */ 2118 + 2119 + list_for_each_entry(mixer, &chip->mixer_list, list) { 2120 + cval = mixer->id_elems[unitid]; 2121 + if (cval) { 2122 + set_cur_ctl_value(cval, cval->control << 8, 2123 + samplerate_id); 2124 + snd_usb_mixer_notify_id(mixer, unitid); 2125 + } 2126 + break; 2127 + } 2128 + } 2129 + 2235 2130 int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, 2236 2131 int ignore_error) 2237 2132 { ··· 2257 2116 .dev_free = snd_usb_mixer_dev_free 2258 2117 }; 2259 2118 struct usb_mixer_interface *mixer; 2260 - int err; 2119 + struct snd_info_entry *entry; 2120 + struct usb_host_interface *host_iface; 2121 + int err, protocol; 2261 2122 2262 2123 strcpy(chip->card->mixername, "USB Mixer"); 2263 2124 ··· 2269 2126 mixer->chip = chip; 2270 2127 mixer->ctrlif = ctrlif; 2271 2128 mixer->ignore_ctl_error = ignore_error; 2272 - mixer->id_elems = kcalloc(256, sizeof(*mixer->id_elems), GFP_KERNEL); 2129 + mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems), 2130 + GFP_KERNEL); 2273 2131 if (!mixer->id_elems) { 2274 2132 kfree(mixer); 2275 2133 return -ENOMEM; 2134 + } 2135 + 2136 + host_iface = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0]; 2137 + protocol = host_iface->desc.bInterfaceProtocol; 2138 + 2139 + /* FIXME! */ 2140 + if (protocol != UAC_VERSION_1) { 2141 + snd_printk(KERN_WARNING "mixer interface protocol 0x%02x not yet supported\n", 2142 + protocol); 2143 + return 0; 2276 2144 } 2277 2145 2278 2146 if ((err = snd_usb_mixer_controls(mixer)) < 0 || ··· 2296 2142 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) || 2297 2143 mixer->chip->usb_id == USB_ID(0x041e, 0x3040) || 2298 2144 mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) { 2299 - struct snd_info_entry *entry; 2300 - 2301 2145 if ((err = snd_audigy2nx_controls_create(mixer)) < 0) 2302 2146 goto _error; 2303 2147 if (!snd_card_proc_new(chip->card, "audigy2nx", &entry)) ··· 2313 2161 err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops); 2314 2162 if (err < 0) 2315 2163 goto _error; 2164 + 2165 + if (list_empty(&chip->mixer_list) && 2166 + !snd_card_proc_new(chip->card, "usbmixer", &entry)) 2167 + snd_info_set_text_ops(entry, chip, snd_usb_mixer_proc_read); 2168 + 2316 2169 list_add(&mixer->list, &chip->mixer_list); 2317 2170 return 0; 2318 2171
+17 -6
sound/usb/usbmixer_maps.c
··· 19 19 * 20 20 */ 21 21 22 + struct usbmix_dB_map { 23 + u32 min; 24 + u32 max; 25 + }; 22 26 23 27 struct usbmix_name_map { 24 28 int id; 25 29 const char *name; 26 30 int control; 31 + struct usbmix_dB_map *dB; 27 32 }; 28 33 29 34 struct usbmix_selector_map { ··· 77 72 { 8, "Line Playback" }, /* FU */ 78 73 /* 9: IT mic */ 79 74 { 10, "Mic Playback" }, /* FU */ 80 - { 11, "Capture Input Source" }, /* SU */ 75 + { 11, "Capture Source" }, /* SU */ 81 76 { 12, "Capture" }, /* FU */ 82 77 /* 13: OT pcm capture */ 83 78 /* 14: MU (w/o controls) */ ··· 107 102 * e.g. no Master and fake PCM volume 108 103 * Pavel Mihaylov <bin@bash.info> 109 104 */ 105 + static struct usbmix_dB_map mp3plus_dB_1 = {-4781, 0}; /* just guess */ 106 + static struct usbmix_dB_map mp3plus_dB_2 = {-1781, 618}; /* just guess */ 107 + 110 108 static struct usbmix_name_map mp3plus_map[] = { 111 109 /* 1: IT pcm */ 112 110 /* 2: IT mic */ ··· 118 110 /* 5: OT digital out */ 119 111 /* 6: OT speaker */ 120 112 /* 7: OT pcm capture */ 121 - { 8, "Capture Input Source" }, /* FU, default PCM Capture Source */ 113 + { 8, "Capture Source" }, /* FU, default PCM Capture Source */ 122 114 /* (Mic, Input 1 = Line input, Input 2 = Optical input) */ 123 115 { 9, "Master Playback" }, /* FU, default Speaker 1 */ 124 116 /* { 10, "Mic Capture", 1 }, */ /* FU, Mic Capture */ 125 - /* { 10, "Mic Capture", 2 }, */ /* FU, Mic Capture */ 117 + { 10, /* "Mic Capture", */ NULL, 2, .dB = &mp3plus_dB_2 }, 118 + /* FU, Mic Capture */ 126 119 { 10, "Mic Boost", 7 }, /* FU, default Auto Gain Input */ 127 - { 11, "Line Capture" }, /* FU, default PCM Capture */ 120 + { 11, "Line Capture", .dB = &mp3plus_dB_2 }, 121 + /* FU, default PCM Capture */ 128 122 { 12, "Digital In Playback" }, /* FU, default PCM 1 */ 129 - /* { 13, "Mic Playback" }, */ /* FU, default Mic Playback */ 130 - { 14, "Line Playback" }, /* FU, default Speaker */ 123 + { 13, /* "Mic Playback", */ .dB = &mp3plus_dB_1 }, 124 + /* FU, default Mic Playback */ 125 + { 14, "Line Playback", .dB = &mp3plus_dB_1 }, /* FU, default Speaker */ 131 126 /* 15: MU */ 132 127 { 0 } /* terminator */ 133 128 };
+194 -39
sound/usb/usbquirks.h
··· 91 91 .idVendor = 0x046d, 92 92 .idProduct = 0x0850, 93 93 .bInterfaceClass = USB_CLASS_AUDIO, 94 - .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 94 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL 95 95 }, 96 96 { 97 97 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ··· 100 100 .idVendor = 0x046d, 101 101 .idProduct = 0x08ae, 102 102 .bInterfaceClass = USB_CLASS_AUDIO, 103 - .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 103 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL 104 104 }, 105 105 { 106 106 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ··· 109 109 .idVendor = 0x046d, 110 110 .idProduct = 0x08c6, 111 111 .bInterfaceClass = USB_CLASS_AUDIO, 112 - .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 112 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL 113 113 }, 114 114 { 115 115 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ··· 118 118 .idVendor = 0x046d, 119 119 .idProduct = 0x08f0, 120 120 .bInterfaceClass = USB_CLASS_AUDIO, 121 - .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 121 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL 122 122 }, 123 123 { 124 124 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ··· 127 127 .idVendor = 0x046d, 128 128 .idProduct = 0x08f5, 129 129 .bInterfaceClass = USB_CLASS_AUDIO, 130 - .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 130 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL 131 131 }, 132 132 { 133 133 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | ··· 136 136 .idVendor = 0x046d, 137 137 .idProduct = 0x08f6, 138 138 .bInterfaceClass = USB_CLASS_AUDIO, 139 - .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL 139 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL 140 140 }, 141 141 { 142 142 USB_DEVICE(0x046d, 0x0990), ··· 301 301 .iface = 1, 302 302 .altsetting = 1, 303 303 .altset_idx = 1, 304 - .attributes = EP_CS_ATTR_FILL_MAX, 304 + .attributes = UAC_EP_CS_ATTR_FILL_MAX, 305 305 .endpoint = 0x81, 306 306 .ep_attr = 0x05, 307 307 .rates = SNDRV_PCM_RATE_CONTINUOUS, ··· 1266 1266 } 1267 1267 } 1268 1268 }, 1269 - /* Roland UA-101 in High-Speed Mode only */ 1270 - { 1271 - USB_DEVICE(0x0582, 0x007d), 1272 - .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { 1273 - .vendor_name = "Roland", 1274 - .product_name = "UA-101", 1275 - .ifnum = QUIRK_ANY_INTERFACE, 1276 - .type = QUIRK_COMPOSITE, 1277 - .data = (const struct snd_usb_audio_quirk[]) { 1278 - { 1279 - .ifnum = 0, 1280 - .type = QUIRK_AUDIO_EDIROL_UA101 1281 - }, 1282 - { 1283 - .ifnum = 1, 1284 - .type = QUIRK_AUDIO_EDIROL_UA101 1285 - }, 1286 - { 1287 - .ifnum = 2, 1288 - .type = QUIRK_MIDI_FIXED_ENDPOINT, 1289 - .data = & (const struct snd_usb_midi_endpoint_info) { 1290 - .out_cables = 0x0001, 1291 - .in_cables = 0x0001 1292 - } 1293 - }, 1294 - { 1295 - .ifnum = -1 1296 - } 1297 - } 1298 - } 1299 - }, 1300 1269 { 1301 1270 /* has ID 0x0081 when not in "Advanced Driver" mode */ 1302 1271 USB_DEVICE(0x0582, 0x0080), ··· 2042 2073 } 2043 2074 }, 2044 2075 2076 + /* Access Music devices */ 2077 + { 2078 + /* VirusTI Desktop */ 2079 + USB_DEVICE_VENDOR_SPEC(0x133e, 0x0815), 2080 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2081 + .ifnum = QUIRK_ANY_INTERFACE, 2082 + .type = QUIRK_COMPOSITE, 2083 + .data = &(const struct snd_usb_audio_quirk[]) { 2084 + { 2085 + .ifnum = 3, 2086 + .type = QUIRK_MIDI_FIXED_ENDPOINT, 2087 + .data = &(const struct snd_usb_midi_endpoint_info) { 2088 + .out_cables = 0x0003, 2089 + .in_cables = 0x0003 2090 + } 2091 + }, 2092 + { 2093 + .ifnum = 4, 2094 + .type = QUIRK_IGNORE_INTERFACE 2095 + }, 2096 + { 2097 + .ifnum = -1 2098 + } 2099 + } 2100 + } 2101 + }, 2102 + 2045 2103 /* */ 2046 2104 { 2047 2105 /* aka. Serato Scratch Live DJ Box */ ··· 2101 2105 } 2102 2106 }, 2103 2107 2108 + /* Hauppauge HVR-950Q and HVR-850 */ 2109 + { 2110 + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7200), 2111 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2112 + USB_DEVICE_ID_MATCH_INT_CLASS | 2113 + USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2114 + .bInterfaceClass = USB_CLASS_AUDIO, 2115 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, 2116 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2117 + .vendor_name = "Hauppauge", 2118 + .product_name = "HVR-950Q", 2119 + .ifnum = QUIRK_ANY_INTERFACE, 2120 + .type = QUIRK_AUDIO_ALIGN_TRANSFER, 2121 + } 2122 + }, 2123 + { 2124 + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7201), 2125 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2126 + USB_DEVICE_ID_MATCH_INT_CLASS | 2127 + USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2128 + .bInterfaceClass = USB_CLASS_AUDIO, 2129 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, 2130 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2131 + .vendor_name = "Hauppauge", 2132 + .product_name = "HVR-950Q", 2133 + .ifnum = QUIRK_ANY_INTERFACE, 2134 + .type = QUIRK_AUDIO_ALIGN_TRANSFER, 2135 + } 2136 + }, 2137 + { 2138 + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7202), 2139 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2140 + USB_DEVICE_ID_MATCH_INT_CLASS | 2141 + USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2142 + .bInterfaceClass = USB_CLASS_AUDIO, 2143 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, 2144 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2145 + .vendor_name = "Hauppauge", 2146 + .product_name = "HVR-950Q", 2147 + .ifnum = QUIRK_ANY_INTERFACE, 2148 + .type = QUIRK_AUDIO_ALIGN_TRANSFER, 2149 + } 2150 + }, 2151 + { 2152 + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7203), 2153 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2154 + USB_DEVICE_ID_MATCH_INT_CLASS | 2155 + USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2156 + .bInterfaceClass = USB_CLASS_AUDIO, 2157 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, 2158 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2159 + .vendor_name = "Hauppauge", 2160 + .product_name = "HVR-950Q", 2161 + .ifnum = QUIRK_ANY_INTERFACE, 2162 + .type = QUIRK_AUDIO_ALIGN_TRANSFER, 2163 + } 2164 + }, 2165 + { 2166 + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7204), 2167 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2168 + USB_DEVICE_ID_MATCH_INT_CLASS | 2169 + USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2170 + .bInterfaceClass = USB_CLASS_AUDIO, 2171 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, 2172 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2173 + .vendor_name = "Hauppauge", 2174 + .product_name = "HVR-950Q", 2175 + .ifnum = QUIRK_ANY_INTERFACE, 2176 + .type = QUIRK_AUDIO_ALIGN_TRANSFER, 2177 + } 2178 + }, 2179 + { 2180 + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7205), 2181 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2182 + USB_DEVICE_ID_MATCH_INT_CLASS | 2183 + USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2184 + .bInterfaceClass = USB_CLASS_AUDIO, 2185 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, 2186 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2187 + .vendor_name = "Hauppauge", 2188 + .product_name = "HVR-950Q", 2189 + .ifnum = QUIRK_ANY_INTERFACE, 2190 + .type = QUIRK_AUDIO_ALIGN_TRANSFER, 2191 + } 2192 + }, 2193 + { 2194 + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7250), 2195 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2196 + USB_DEVICE_ID_MATCH_INT_CLASS | 2197 + USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2198 + .bInterfaceClass = USB_CLASS_AUDIO, 2199 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, 2200 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2201 + .vendor_name = "Hauppauge", 2202 + .product_name = "HVR-950Q", 2203 + .ifnum = QUIRK_ANY_INTERFACE, 2204 + .type = QUIRK_AUDIO_ALIGN_TRANSFER, 2205 + } 2206 + }, 2207 + { 2208 + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7230), 2209 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | 2210 + USB_DEVICE_ID_MATCH_INT_CLASS | 2211 + USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2212 + .bInterfaceClass = USB_CLASS_AUDIO, 2213 + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, 2214 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2215 + .vendor_name = "Hauppauge", 2216 + .product_name = "HVR-850", 2217 + .ifnum = QUIRK_ANY_INTERFACE, 2218 + .type = QUIRK_AUDIO_ALIGN_TRANSFER, 2219 + } 2220 + }, 2221 + 2222 + /* Digidesign Mbox */ 2223 + { 2224 + /* Thanks to Clemens Ladisch <clemens@ladisch.de> */ 2225 + USB_DEVICE(0x0dba, 0x1000), 2226 + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { 2227 + .vendor_name = "Digidesign", 2228 + .product_name = "MBox", 2229 + .ifnum = QUIRK_ANY_INTERFACE, 2230 + .type = QUIRK_COMPOSITE, 2231 + .data = (const struct snd_usb_audio_quirk[]){ 2232 + { 2233 + .ifnum = 0, 2234 + .type = QUIRK_IGNORE_INTERFACE, 2235 + }, 2236 + { 2237 + .ifnum = 1, 2238 + .type = QUIRK_AUDIO_FIXED_ENDPOINT, 2239 + .data = &(const struct audioformat) { 2240 + .format = SNDRV_PCM_FORMAT_S24_3BE, 2241 + .channels = 2, 2242 + .iface = 1, 2243 + .altsetting = 1, 2244 + .altset_idx = 1, 2245 + .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, 2246 + .endpoint = 0x02, 2247 + .ep_attr = 0x01, 2248 + .maxpacksize = 0x130, 2249 + .rates = SNDRV_PCM_RATE_44100 | 2250 + SNDRV_PCM_RATE_48000, 2251 + .rate_min = 44100, 2252 + .rate_max = 48000, 2253 + .nr_rates = 2, 2254 + .rate_table = (unsigned int[]) { 2255 + 44100, 48000 2256 + } 2257 + } 2258 + }, 2259 + { 2260 + .ifnum = -1 2261 + } 2262 + } 2263 + 2264 + } 2265 + }, 2266 + 2104 2267 { 2105 2268 /* 2106 2269 * Some USB MIDI devices don't have an audio control interface, ··· 2268 2113 .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | 2269 2114 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 2270 2115 .bInterfaceClass = USB_CLASS_AUDIO, 2271 - .bInterfaceSubClass = USB_SUBCLASS_MIDI_STREAMING, 2116 + .bInterfaceSubClass = USB_SUBCLASS_MIDISTREAMING, 2272 2117 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { 2273 2118 .ifnum = QUIRK_ANY_INTERFACE, 2274 2119 .type = QUIRK_MIDI_STANDARD_INTERFACE
+4 -2
sound/usb/usx2y/us122l.c
··· 16 16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 17 */ 18 18 19 + #include <linux/usb.h> 20 + #include <linux/usb/audio.h> 19 21 #include <sound/core.h> 20 22 #include <sound/hwdep.h> 21 23 #include <sound/pcm.h> ··· 317 315 data[0] = rate; 318 316 data[1] = rate >> 8; 319 317 data[2] = rate >> 16; 320 - err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, 318 + err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, 321 319 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 322 - SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000); 320 + UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000); 323 321 if (err < 0) 324 322 snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", 325 323 dev->devnum, rate, ep);