Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6:
ALSA: hda - Fix mute control with some ALC262 models
ALSA: snd_usb_caiaq: add support for Audio2DJ
ALSA: pcm - Fix hwptr buffer-size overlap bug
ALSA: pcm - Fix warnings in debug loggings
ALSA: pcm - Add logging of hwptr updates and interrupt updates
ASoC: tlv320aic3x: Enable PLL when not bypassed
ALSA: hda - Restore GPIO1 properly at resume with AD1984A
ALSA: ctxfi - Fix uninitialized error checks
ALSA: hda - Use snprintf() to be safer
ALSA: usb-audio - Volume control quirk for QuickCam E 3500
ALSA: pcm - Fix regressions with VMware

+107 -39
+5
Documentation/sound/alsa/Procfile.txt
··· 101 bit 0 = Enable XRUN/jiffies debug messages 102 bit 1 = Show stack trace at XRUN / jiffies check 103 bit 2 = Enable additional jiffies check 104 105 When the bit 0 is set, the driver will show the messages to 106 kernel log when an xrun is detected. The debug message is ··· 118 values, but can be lead to too much corrections for a (mostly 119 buggy) hardware that doesn't give smooth pointer updates. 120 This feature is enabled via the bit 2. 121 122 card*/pcm*/sub*/info 123 The general information of this PCM sub-stream.
··· 101 bit 0 = Enable XRUN/jiffies debug messages 102 bit 1 = Show stack trace at XRUN / jiffies check 103 bit 2 = Enable additional jiffies check 104 + bit 3 = Log hwptr update at each period interrupt 105 + bit 4 = Log hwptr update at each snd_pcm_update_hw_ptr() 106 107 When the bit 0 is set, the driver will show the messages to 108 kernel log when an xrun is detected. The debug message is ··· 116 values, but can be lead to too much corrections for a (mostly 117 buggy) hardware that doesn't give smooth pointer updates. 118 This feature is enabled via the bit 2. 119 + 120 + Bits 3 and 4 are for logging the hwptr records. Note that 121 + these will give flood of kernel messages. 122 123 card*/pcm*/sub*/info 124 The general information of this PCM sub-stream.
+35 -1
sound/core/pcm_lib.c
··· 233 xrun(substream); 234 return -EPIPE; 235 } 236 hw_base = runtime->hw_ptr_base; 237 new_hw_ptr = hw_base + pos; 238 hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size; ··· 256 delta = new_hw_ptr - hw_ptr_interrupt; 257 } 258 if (delta < 0) { 259 - delta += runtime->buffer_size; 260 if (delta < 0) { 261 hw_ptr_error(substream, 262 "Unexpected hw_pointer value " 263 "(stream=%i, pos=%ld, intr_ptr=%ld)\n", 264 substream->stream, (long)pos, 265 (long)hw_ptr_interrupt); 266 /* rebase to interrupt position */ 267 hw_base = new_hw_ptr = hw_ptr_interrupt; 268 /* align hw_base to buffer_size */ 269 hw_base -= hw_base % runtime->buffer_size; 270 delta = 0; 271 } else { 272 hw_base += runtime->buffer_size; 273 if (hw_base >= runtime->boundary) ··· 365 xrun(substream); 366 return -EPIPE; 367 } 368 hw_base = runtime->hw_ptr_base; 369 new_hw_ptr = hw_base + pos; 370
··· 233 xrun(substream); 234 return -EPIPE; 235 } 236 + if (xrun_debug(substream, 8)) { 237 + char name[16]; 238 + pcm_debug_name(substream, name, sizeof(name)); 239 + snd_printd("period_update: %s: pos=0x%x/0x%x/0x%x, " 240 + "hwptr=0x%lx, hw_base=0x%lx, hw_intr=0x%lx\n", 241 + name, (unsigned int)pos, 242 + (unsigned int)runtime->period_size, 243 + (unsigned int)runtime->buffer_size, 244 + (unsigned long)old_hw_ptr, 245 + (unsigned long)runtime->hw_ptr_base, 246 + (unsigned long)runtime->hw_ptr_interrupt); 247 + } 248 hw_base = runtime->hw_ptr_base; 249 new_hw_ptr = hw_base + pos; 250 hw_ptr_interrupt = runtime->hw_ptr_interrupt + runtime->period_size; ··· 244 delta = new_hw_ptr - hw_ptr_interrupt; 245 } 246 if (delta < 0) { 247 + if (runtime->periods == 1 || new_hw_ptr < old_hw_ptr) 248 + delta += runtime->buffer_size; 249 if (delta < 0) { 250 hw_ptr_error(substream, 251 "Unexpected hw_pointer value " 252 "(stream=%i, pos=%ld, intr_ptr=%ld)\n", 253 substream->stream, (long)pos, 254 (long)hw_ptr_interrupt); 255 + #if 1 256 + /* simply skipping the hwptr update seems more 257 + * robust in some cases, e.g. on VMware with 258 + * inaccurate timer source 259 + */ 260 + return 0; /* skip this update */ 261 + #else 262 /* rebase to interrupt position */ 263 hw_base = new_hw_ptr = hw_ptr_interrupt; 264 /* align hw_base to buffer_size */ 265 hw_base -= hw_base % runtime->buffer_size; 266 delta = 0; 267 + #endif 268 } else { 269 hw_base += runtime->buffer_size; 270 if (hw_base >= runtime->boundary) ··· 344 xrun(substream); 345 return -EPIPE; 346 } 347 + if (xrun_debug(substream, 16)) { 348 + char name[16]; 349 + pcm_debug_name(substream, name, sizeof(name)); 350 + snd_printd("hw_update: %s: pos=0x%x/0x%x/0x%x, " 351 + "hwptr=0x%lx, hw_base=0x%lx, hw_intr=0x%lx\n", 352 + name, (unsigned int)pos, 353 + (unsigned int)runtime->period_size, 354 + (unsigned int)runtime->buffer_size, 355 + (unsigned long)old_hw_ptr, 356 + (unsigned long)runtime->hw_ptr_base, 357 + (unsigned long)runtime->hw_ptr_interrupt); 358 + } 359 + 360 hw_base = runtime->hw_ptr_base; 361 new_hw_ptr = hw_base + pos; 362
+6 -8
sound/pci/ctxfi/ctamixer.c
··· 242 243 /* Allocate mem for amixer resource */ 244 amixer = kzalloc(sizeof(*amixer), GFP_KERNEL); 245 - if (NULL == amixer) { 246 - err = -ENOMEM; 247 - return err; 248 - } 249 250 /* Check whether there are sufficient 251 * amixer resources to meet request. */ 252 spin_lock_irqsave(&mgr->mgr_lock, flags); 253 for (i = 0; i < desc->msr; i++) { 254 err = mgr_get_resource(&mgr->mgr, 1, &idx); ··· 396 397 /* Allocate mem for sum resource */ 398 sum = kzalloc(sizeof(*sum), GFP_KERNEL); 399 - if (NULL == sum) { 400 - err = -ENOMEM; 401 - return err; 402 - } 403 404 /* Check whether there are sufficient sum resources to meet request. */ 405 spin_lock_irqsave(&mgr->mgr_lock, flags); 406 for (i = 0; i < desc->msr; i++) { 407 err = mgr_get_resource(&mgr->mgr, 1, &idx);
··· 242 243 /* Allocate mem for amixer resource */ 244 amixer = kzalloc(sizeof(*amixer), GFP_KERNEL); 245 + if (!amixer) 246 + return -ENOMEM; 247 248 /* Check whether there are sufficient 249 * amixer resources to meet request. */ 250 + err = 0; 251 spin_lock_irqsave(&mgr->mgr_lock, flags); 252 for (i = 0; i < desc->msr; i++) { 253 err = mgr_get_resource(&mgr->mgr, 1, &idx); ··· 397 398 /* Allocate mem for sum resource */ 399 sum = kzalloc(sizeof(*sum), GFP_KERNEL); 400 + if (!sum) 401 + return -ENOMEM; 402 403 /* Check whether there are sufficient sum resources to meet request. */ 404 + err = 0; 405 spin_lock_irqsave(&mgr->mgr_lock, flags); 406 for (i = 0; i < desc->msr; i++) { 407 err = mgr_get_resource(&mgr->mgr, 1, &idx);
+3 -4
sound/pci/ctxfi/ctsrc.c
··· 724 725 /* Allocate mem for SRCIMP resource */ 726 srcimp = kzalloc(sizeof(*srcimp), GFP_KERNEL); 727 - if (NULL == srcimp) { 728 - err = -ENOMEM; 729 - return err; 730 - } 731 732 /* Check whether there are sufficient SRCIMP resources. */ 733 spin_lock_irqsave(&mgr->mgr_lock, flags); 734 for (i = 0; i < desc->msr; i++) { 735 err = mgr_get_resource(&mgr->mgr, 1, &idx);
··· 724 725 /* Allocate mem for SRCIMP resource */ 726 srcimp = kzalloc(sizeof(*srcimp), GFP_KERNEL); 727 + if (!srcimp) 728 + return -ENOMEM; 729 730 /* Check whether there are sufficient SRCIMP resources. */ 731 + err = 0; 732 spin_lock_irqsave(&mgr->mgr_lock, flags); 733 for (i = 0; i < desc->msr; i++) { 734 err = mgr_get_resource(&mgr->mgr, 1, &idx);
+1 -1
sound/pci/hda/patch_analog.c
··· 3754 int mute = (!ucontrol->value.integer.value[0] && 3755 !ucontrol->value.integer.value[1]); 3756 /* toggle GPIO1 according to the mute state */ 3757 - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 3758 mute ? 0x02 : 0x0); 3759 return ret; 3760 }
··· 3754 int mute = (!ucontrol->value.integer.value[0] && 3755 !ucontrol->value.integer.value[1]); 3756 /* toggle GPIO1 according to the mute state */ 3757 + snd_hda_codec_write_cache(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 3758 mute ? 0x02 : 0x0); 3759 return ret; 3760 }
+16 -17
sound/pci/hda/patch_realtek.c
··· 10631 alc262_lenovo_3000_automute(codec, 1); 10632 } 10633 10634 /* bind hp and internal speaker mute (with plug check) */ 10635 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, 10636 struct snd_ctl_elem_value *ucontrol) ··· 10651 long *valp = ucontrol->value.integer.value; 10652 int change; 10653 10654 - change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0, 10655 - HDA_AMP_MUTE, 10656 - valp ? 0 : HDA_AMP_MUTE); 10657 - change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 10658 - HDA_AMP_MUTE, 10659 - valp ? 0 : HDA_AMP_MUTE); 10660 - 10661 if (change) 10662 alc262_fujitsu_automute(codec, 0); 10663 return change; ··· 10687 long *valp = ucontrol->value.integer.value; 10688 int change; 10689 10690 - change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, 10691 - HDA_AMP_MUTE, 10692 - valp ? 0 : HDA_AMP_MUTE); 10693 - 10694 if (change) 10695 alc262_lenovo_3000_automute(codec, 0); 10696 return change; ··· 11858 long *valp = ucontrol->value.integer.value; 11859 int change; 11860 11861 - change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 11862 - HDA_AMP_MUTE, 11863 - valp[0] ? 0 : HDA_AMP_MUTE); 11864 - change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 11865 - HDA_AMP_MUTE, 11866 - valp[1] ? 0 : HDA_AMP_MUTE); 11867 if (change) 11868 alc268_acer_automute(codec, 0); 11869 return change;
··· 10631 alc262_lenovo_3000_automute(codec, 1); 10632 } 10633 10634 + static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid, 10635 + int dir, int idx, long *valp) 10636 + { 10637 + int i, change = 0; 10638 + 10639 + for (i = 0; i < 2; i++, valp++) 10640 + change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx, 10641 + HDA_AMP_MUTE, 10642 + *valp ? 0 : HDA_AMP_MUTE); 10643 + return change; 10644 + } 10645 + 10646 /* bind hp and internal speaker mute (with plug check) */ 10647 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol, 10648 struct snd_ctl_elem_value *ucontrol) ··· 10639 long *valp = ucontrol->value.integer.value; 10640 int change; 10641 10642 + change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp); 10643 + change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp); 10644 if (change) 10645 alc262_fujitsu_automute(codec, 0); 10646 return change; ··· 10680 long *valp = ucontrol->value.integer.value; 10681 int change; 10682 10683 + change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp); 10684 if (change) 10685 alc262_lenovo_3000_automute(codec, 0); 10686 return change; ··· 11854 long *valp = ucontrol->value.integer.value; 11855 int change; 11856 11857 + change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp); 11858 if (change) 11859 alc268_acer_automute(codec, 0); 11860 return change;
+1 -1
sound/pci/hda/patch_sigmatel.c
··· 4066 jack->nid = nid; 4067 jack->type = type; 4068 4069 - sprintf(name, "%s at %s %s Jack", 4070 snd_hda_get_jack_type(def_conf), 4071 snd_hda_get_jack_connectivity(def_conf), 4072 snd_hda_get_jack_location(def_conf));
··· 4066 jack->nid = nid; 4067 jack->type = type; 4068 4069 + snprintf(name, sizeof(name), "%s at %s %s Jack", 4070 snd_hda_get_jack_type(def_conf), 4071 snd_hda_get_jack_connectivity(def_conf), 4072 snd_hda_get_jack_location(def_conf));
+10 -1
sound/soc/codecs/tlv320aic3x.c
··· 767 int codec_clk = 0, bypass_pll = 0, fsref, last_clk = 0; 768 u8 data, r, p, pll_q, pll_p = 1, pll_r = 1, pll_j = 1; 769 u16 pll_d = 1; 770 771 /* select data word length */ 772 data = ··· 802 pll_q &= 0xf; 803 aic3x_write(codec, AIC3X_PLL_PROGA_REG, pll_q << PLLQ_SHIFT); 804 aic3x_write(codec, AIC3X_GPIOB_REG, CODEC_CLKIN_CLKDIV); 805 - } else 806 aic3x_write(codec, AIC3X_GPIOB_REG, CODEC_CLKIN_PLLDIV); 807 808 /* Route Left DAC to left channel input and 809 * right DAC to right channel input */
··· 767 int codec_clk = 0, bypass_pll = 0, fsref, last_clk = 0; 768 u8 data, r, p, pll_q, pll_p = 1, pll_r = 1, pll_j = 1; 769 u16 pll_d = 1; 770 + u8 reg; 771 772 /* select data word length */ 773 data = ··· 801 pll_q &= 0xf; 802 aic3x_write(codec, AIC3X_PLL_PROGA_REG, pll_q << PLLQ_SHIFT); 803 aic3x_write(codec, AIC3X_GPIOB_REG, CODEC_CLKIN_CLKDIV); 804 + /* disable PLL if it is bypassed */ 805 + reg = aic3x_read_reg_cache(codec, AIC3X_PLL_PROGA_REG); 806 + aic3x_write(codec, AIC3X_PLL_PROGA_REG, reg & ~PLL_ENABLE); 807 + 808 + } else { 809 aic3x_write(codec, AIC3X_GPIOB_REG, CODEC_CLKIN_PLLDIV); 810 + /* enable PLL when it is used */ 811 + reg = aic3x_read_reg_cache(codec, AIC3X_PLL_PROGA_REG); 812 + aic3x_write(codec, AIC3X_PLL_PROGA_REG, reg | PLL_ENABLE); 813 + } 814 815 /* Route Left DAC to left channel input and 816 * right DAC to right channel input */
+1
sound/usb/Kconfig
··· 48 * Native Instruments Kore Controller 49 * Native Instruments Kore Controller 2 50 * Native Instruments Audio Kontrol 1 51 * Native Instruments Audio 4 DJ 52 * Native Instruments Audio 8 DJ 53 * Native Instruments Guitar Rig Session I/O
··· 48 * Native Instruments Kore Controller 49 * Native Instruments Kore Controller 2 50 * Native Instruments Audio Kontrol 1 51 + * Native Instruments Audio 2 DJ 52 * Native Instruments Audio 4 DJ 53 * Native Instruments Audio 8 DJ 54 * Native Instruments Guitar Rig Session I/O
+1
sound/usb/caiaq/audio.c
··· 646 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): 647 dev->samplerates |= SNDRV_PCM_RATE_192000; 648 /* fall thru */ 649 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): 650 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): 651 dev->samplerates |= SNDRV_PCM_RATE_88200;
··· 646 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): 647 dev->samplerates |= SNDRV_PCM_RATE_192000; 648 /* fall thru */ 649 + case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO2DJ): 650 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): 651 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): 652 dev->samplerates |= SNDRV_PCM_RATE_88200;
+7 -1
sound/usb/caiaq/device.c
··· 35 #include "input.h" 36 37 MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 38 - MODULE_DESCRIPTION("caiaq USB audio, version 1.3.18"); 39 MODULE_LICENSE("GPL"); 40 MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," 41 "{Native Instruments, RigKontrol3}," 42 "{Native Instruments, Kore Controller}," 43 "{Native Instruments, Kore Controller 2}," 44 "{Native Instruments, Audio Kontrol 1}," 45 "{Native Instruments, Audio 4 DJ}," 46 "{Native Instruments, Audio 8 DJ}," 47 "{Native Instruments, Session I/O}," ··· 121 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 122 .idVendor = USB_VID_NATIVEINSTRUMENTS, 123 .idProduct = USB_PID_AUDIO4DJ 124 }, 125 { /* terminator */ } 126 };
··· 35 #include "input.h" 36 37 MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 38 + MODULE_DESCRIPTION("caiaq USB audio, version 1.3.19"); 39 MODULE_LICENSE("GPL"); 40 MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," 41 "{Native Instruments, RigKontrol3}," 42 "{Native Instruments, Kore Controller}," 43 "{Native Instruments, Kore Controller 2}," 44 "{Native Instruments, Audio Kontrol 1}," 45 + "{Native Instruments, Audio 2 DJ}," 46 "{Native Instruments, Audio 4 DJ}," 47 "{Native Instruments, Audio 8 DJ}," 48 "{Native Instruments, Session I/O}," ··· 120 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 121 .idVendor = USB_VID_NATIVEINSTRUMENTS, 122 .idProduct = USB_PID_AUDIO4DJ 123 + }, 124 + { 125 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 126 + .idVendor = USB_VID_NATIVEINSTRUMENTS, 127 + .idProduct = USB_PID_AUDIO2DJ 128 }, 129 { /* terminator */ } 130 };
+1
sound/usb/caiaq/device.h
··· 10 #define USB_PID_KORECONTROLLER 0x4711 11 #define USB_PID_KORECONTROLLER2 0x4712 12 #define USB_PID_AK1 0x0815 13 #define USB_PID_AUDIO4DJ 0x0839 14 #define USB_PID_AUDIO8DJ 0x1978 15 #define USB_PID_SESSIONIO 0x1915
··· 10 #define USB_PID_KORECONTROLLER 0x4711 11 #define USB_PID_KORECONTROLLER2 0x4712 12 #define USB_PID_AK1 0x0815 13 + #define USB_PID_AUDIO2DJ 0x041c 14 #define USB_PID_AUDIO4DJ 0x0839 15 #define USB_PID_AUDIO8DJ 0x1978 16 #define USB_PID_SESSIONIO 0x1915
+20 -5
sound/usb/usbmixer.c
··· 990 break; 991 } 992 993 - /* quirk for UDA1321/N101 */ 994 - /* note that detection between firmware 2.1.1.7 (N101) and later 2.1.1.21 */ 995 - /* is not very clear from datasheets */ 996 - /* I hope that the min value is -15360 for newer firmware --jk */ 997 switch (state->chip->usb_id) { 998 case USB_ID(0x0471, 0x0101): 999 case USB_ID(0x0471, 0x0104): 1000 case USB_ID(0x0471, 0x0105): 1001 case USB_ID(0x0672, 0x1041): 1002 if (!strcmp(kctl->id.name, "PCM Playback Volume") && 1003 cval->min == -15616) { 1004 - snd_printk(KERN_INFO "using volume control quirk for the UDA1321/N101 chip\n"); 1005 cval->max = -256; 1006 } 1007 } 1008 1009 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
··· 990 break; 991 } 992 993 + /* volume control quirks */ 994 switch (state->chip->usb_id) { 995 case USB_ID(0x0471, 0x0101): 996 case USB_ID(0x0471, 0x0104): 997 case USB_ID(0x0471, 0x0105): 998 case USB_ID(0x0672, 0x1041): 999 + /* quirk for UDA1321/N101. 1000 + * note that detection between firmware 2.1.1.7 (N101) 1001 + * and later 2.1.1.21 is not very clear from datasheets. 1002 + * I hope that the min value is -15360 for newer firmware --jk 1003 + */ 1004 if (!strcmp(kctl->id.name, "PCM Playback Volume") && 1005 cval->min == -15616) { 1006 + snd_printk(KERN_INFO 1007 + "set volume quirk for UDA1321/N101 chip\n"); 1008 cval->max = -256; 1009 } 1010 + break; 1011 + 1012 + case USB_ID(0x046d, 0x09a4): 1013 + if (!strcmp(kctl->id.name, "Mic Capture Volume")) { 1014 + snd_printk(KERN_INFO 1015 + "set volume quirk for QuickCam E3500\n"); 1016 + cval->min = 6080; 1017 + cval->max = 8768; 1018 + cval->res = 192; 1019 + } 1020 + break; 1021 + 1022 } 1023 1024 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",