From 2e9bf247066a293ebcd4672ddd487808ab5f2d1b Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sat, 18 Jul 2009 11:48:19 +0200 Subject: [PATCH 1/7] ALSA: hda_codec: Check for invalid zero connections To prevent "Too many connections" message and the error path for some HDMI codecs (which makes onboard audio unusable), check for invalid zero connections for CONNECT_LIST verb. Signed-off-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 26d255de6beb..88480c0c58a0 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -332,6 +332,12 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, AC_VERB_GET_CONNECT_LIST, i); range_val = !!(parm & (1 << (shift-1))); /* ranges */ val = parm & mask; + if (val == 0) { + snd_printk(KERN_WARNING "hda_codec: " + "invalid CONNECT_LIST verb %x[%i]:%x\n", + nid, i, parm); + return 0; + } parm >>= shift; if (range_val) { /* ranges between the previous and this one */ From fcb2954b9621dfeaca92f6a11dac69cfdfaa6705 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 18 Jul 2009 17:26:14 +0200 Subject: [PATCH 2/7] ALSA: sound/isa: convert nested spin_lock_irqsave to spin_lock If spin_lock_irqsave is called twice in a row with the same second argument, the interrupt state at the point of the second call overwrites the value saved by the first call. Indeed, the second call does not need to save the interrupt state, so it is changed to a simple spin_lock. The semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ expression lock1,lock2; expression flags; @@ *spin_lock_irqsave(lock1,flags) ... when != flags *spin_lock_irqsave(lock2,flags) // Signed-off-by: Julia Lawall Signed-off-by: Takashi Iwai --- sound/isa/gus/gus_pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index edb11eefdfe3..2dcf45bf7293 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -795,13 +795,13 @@ static int snd_gf1_pcm_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ if (!(pcmp->flags & SNDRV_GF1_PCM_PFLG_ACTIVE)) continue; /* load real volume - better precision */ - spin_lock_irqsave(&gus->reg_lock, flags); + spin_lock(&gus->reg_lock); snd_gf1_select_voice(gus, pvoice->number); snd_gf1_ctrl_stop(gus, SNDRV_GF1_VB_VOLUME_CONTROL); vol = pvoice == pcmp->pvoices[0] ? gus->gf1.pcm_volume_level_left : gus->gf1.pcm_volume_level_right; snd_gf1_write16(gus, SNDRV_GF1_VW_VOLUME, vol); pcmp->final_volume = 1; - spin_unlock_irqrestore(&gus->reg_lock, flags); + spin_unlock(&gus->reg_lock); } spin_unlock_irqrestore(&gus->voice_alloc, flags); return change; From f96e0808212ca284cc9398d7cd3f573786c1d890 Mon Sep 17 00:00:00 2001 From: Jaswinder Singh Rajput Date: Sun, 19 Jul 2009 21:58:34 +0530 Subject: [PATCH 3/7] ALSA: OSS sequencer should be initialized after snd_seq_system_client_init When build SND_SEQUENCER in kernel then OSS sequencer(alsa_seq_oss_init) is initialized before System (snd_seq_system_client_init) which leads to memory leak : unreferenced object 0xf6b0e680 (size 256): comm "swapper", pid 1, jiffies 4294670753 backtrace: [] create_object+0x135/0x204 [] kmemleak_alloc+0x26/0x4c [] kmem_cache_alloc+0x72/0xff [] seq_create_client1+0x22/0x160 [] snd_seq_create_kernel_client+0x72/0xef [] snd_seq_oss_create_client+0x86/0x142 [] alsa_seq_oss_init+0xf6/0x155 [] do_one_initcall+0x4f/0x111 [] kernel_init+0x115/0x166 [] kernel_thread_helper+0x7/0x10 [] 0xffffffff unreferenced object 0xf688a580 (size 64): comm "swapper", pid 1, jiffies 4294670753 backtrace: [] create_object+0x135/0x204 [] kmemleak_alloc+0x26/0x4c [] kmem_cache_alloc+0x72/0xff [] snd_seq_pool_new+0x1c/0xb8 [] seq_create_client1+0x87/0x160 [] snd_seq_create_kernel_client+0x72/0xef [] snd_seq_oss_create_client+0x86/0x142 [] alsa_seq_oss_init+0xf6/0x155 [] do_one_initcall+0x4f/0x111 [] kernel_init+0x115/0x166 [] kernel_thread_helper+0x7/0x10 [] 0xffffffff unreferenced object 0xf6b0e480 (size 256): comm "swapper", pid 1, jiffies 4294670754 backtrace: [] create_object+0x135/0x204 [] kmemleak_alloc+0x26/0x4c [] kmem_cache_alloc+0x72/0xff [] snd_seq_create_port+0x51/0x21c [] snd_seq_ioctl_create_port+0x57/0x13c [] snd_seq_do_ioctl+0x4a/0x69 [] snd_seq_kernel_client_ctl+0x33/0x49 [] snd_seq_oss_create_client+0xf5/0x142 [] alsa_seq_oss_init+0xf6/0x155 [] do_one_initcall+0x4f/0x111 [] kernel_init+0x115/0x166 [] kernel_thread_helper+0x7/0x10 [] 0xffffffff The correct order should be : System (snd_seq_system_client_init) should be initialized before OSS sequencer(alsa_seq_oss_init) which is equivalent to : 1. insmod sound/core/seq/snd-seq-device.ko 2. insmod sound/core/seq/snd-seq.ko 3. insmod sound/core/seq/snd-seq-midi-event.ko 4. insmod sound/core/seq/oss/snd-seq-oss.ko Including sound/core/seq/oss/Makefile after other seq modules fixes the ordering and memory leak. Signed-off-by: Jaswinder Singh Rajput Signed-off-by: Takashi Iwai --- sound/core/seq/Makefile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sound/core/seq/Makefile b/sound/core/seq/Makefile index 1bcb360330e5..941f64a853eb 100644 --- a/sound/core/seq/Makefile +++ b/sound/core/seq/Makefile @@ -3,10 +3,6 @@ # Copyright (c) 1999 by Jaroslav Kysela # -ifeq ($(CONFIG_SND_SEQUENCER_OSS),y) - obj-$(CONFIG_SND_SEQUENCER) += oss/ -endif - snd-seq-device-objs := seq_device.o snd-seq-objs := seq.o seq_lock.o seq_clientmgr.o seq_memory.o seq_queue.o \ seq_fifo.o seq_prioq.o seq_timer.o \ @@ -19,7 +15,8 @@ snd-seq-virmidi-objs := seq_virmidi.o obj-$(CONFIG_SND_SEQUENCER) += snd-seq.o snd-seq-device.o ifeq ($(CONFIG_SND_SEQUENCER_OSS),y) -obj-$(CONFIG_SND_SEQUENCER) += snd-seq-midi-event.o + obj-$(CONFIG_SND_SEQUENCER) += snd-seq-midi-event.o + obj-$(CONFIG_SND_SEQUENCER) += oss/ endif obj-$(CONFIG_SND_SEQ_DUMMY) += snd-seq-dummy.o From 42b95f0c6b524b5a670dd17533a3522db368f600 Mon Sep 17 00:00:00 2001 From: Hao Song Date: Mon, 20 Jul 2009 15:01:16 +0800 Subject: [PATCH 4/7] ALSA: hda - Add quirk for Gateway T6834c laptop Gateway T6834c laptops need EAPD always on while the default behavior for the STAC9205 reference board is to turn it off upon every HP plug. By using the special "eapd" model, which is first introduced for Gateway T1616 laptops for this same reason, this peculiarity can be properly handled. Signed-off-by: Hao Song Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 41b5b3a18c1e..d9b89ba2b653 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -2378,6 +2378,7 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = { SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, "Dell Vostro 1500", STAC_9205_DELL_M42), /* Gateway */ + SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), {} /* terminator */ }; From b04add956616b6d89ff21da749b46ad2bd58ef32 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Jul 2009 08:01:36 +0200 Subject: [PATCH 5/7] ALSA: hda - Fix pin-setup for Sony VAIO with STAC9872 codecs The recent rewrite of the codec parser for STAC9872 caused a regression for some Sony VAIO models that don't give proper pin default configs by BIOS. Even using model=vaio doesn't work because the pin definitions are set after the pin overrides. This patch fixes the pin definitions in patch_stac9872() to be put in the right place before the pin overrides. Also the patch adds the new quirk entry for VAIO F/S to have the correct pin default configs. Signed-off-by: Takashi Iwai Cc: --- sound/pci/hda/patch_sigmatel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index d9b89ba2b653..da7f9f65c047 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -5855,6 +5855,8 @@ static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = { }; static struct snd_pci_quirk stac9872_cfg_tbl[] = { + SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0, + "Sony VAIO F/S", STAC_9872_VAIO), {} /* terminator */ }; @@ -5867,6 +5869,8 @@ static int patch_stac9872(struct hda_codec *codec) if (spec == NULL) return -ENOMEM; codec->spec = spec; + spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); + spec->pin_nids = stac9872_pin_nids; spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, stac9872_models, @@ -5878,8 +5882,6 @@ static int patch_stac9872(struct hda_codec *codec) stac92xx_set_config_regs(codec, stac9872_brd_tbl[spec->board_config]); - spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); - spec->pin_nids = stac9872_pin_nids; spec->multiout.dac_nids = spec->dac_nids; spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); spec->adc_nids = stac9872_adc_nids; From 34fdeb2d07102e07ecafe79dec170bd6733f2e56 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Jul 2009 15:42:51 +0200 Subject: [PATCH 6/7] ALSA: ca0106 - Fix the max capture buffer size The capture buffer size with 64kB seems broken with CA0106. At least, either the update timing or the DMA position is wrong, and this screws up pulseaudio badly. This patch restricts the max buffer size less than that to make life a bit easier. Signed-off-by: Takashi Iwai Cc: --- sound/pci/ca0106/ca0106_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 57b992a5c057..700f15ea16d4 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -325,9 +325,9 @@ static struct snd_pcm_hardware snd_ca0106_capture_hw = { .rate_max = 192000, .channels_min = 2, .channels_max = 2, - .buffer_bytes_max = ((65536 - 64) * 8), + .buffer_bytes_max = 65536 - 128, .period_bytes_min = 64, - .period_bytes_max = (65536 - 64), + .period_bytes_max = 32768 - 64, .periods_min = 2, .periods_max = 2, .fifo_size = 0, From 55fe27f7e2c9d24ce870136bd99ae67b020122d1 Mon Sep 17 00:00:00 2001 From: Frank Roth Date: Mon, 20 Jul 2009 17:00:14 +0200 Subject: [PATCH 7/7] ALSA: ctxfi: Swapped SURROUND-SIDE channels on emu20k2 On Soundblaster X-FI Titanium with emu20k2 the SIDE and SURROUND channels were swapped and wrong. I double checked it with connector colors and creative soundblaster windows drivers. So I swapped them to the true order. Now "speaker-test -c6" and "speaker-test -c8" are working fine. Signed-off-by: Frank Roth Signed-off-by: Takashi Iwai --- sound/pci/ctxfi/ctdaio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index 082e35c08c02..deb6cfa73600 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c @@ -57,9 +57,9 @@ struct daio_rsc_idx idx_20k1[NUM_DAIOTYP] = { struct daio_rsc_idx idx_20k2[NUM_DAIOTYP] = { [LINEO1] = {.left = 0x40, .right = 0x41}, - [LINEO2] = {.left = 0x70, .right = 0x71}, + [LINEO2] = {.left = 0x60, .right = 0x61}, [LINEO3] = {.left = 0x50, .right = 0x51}, - [LINEO4] = {.left = 0x60, .right = 0x61}, + [LINEO4] = {.left = 0x70, .right = 0x71}, [LINEIM] = {.left = 0x45, .right = 0xc5}, [SPDIFOO] = {.left = 0x00, .right = 0x01}, [SPDIFIO] = {.left = 0x05, .right = 0x85},