diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-20 11:49:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-20 11:49:08 -0400 |
commit | babd90b274e6b43a7dc7bb08562bf566cbabdbf8 (patch) | |
tree | 266ea84c2da087c719247cba965477e522344417 | |
parent | 424de91dd6163808729d7082de55c319e1096bee (diff) | |
parent | 186c3117f8aac0b2ac5290aaed254fcfdcc937de (diff) |
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 ASUS P5GD1 model
[ALSA] hda - Fix ALC262 fujitsu model
snd-pcsp: use HRTIMER_CB_SOFTIRQ
-rw-r--r-- | sound/drivers/pcsp/pcsp.c | 2 | ||||
-rw-r--r-- | sound/drivers/pcsp/pcsp_lib.c | 37 | ||||
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 48 |
3 files changed, 34 insertions, 53 deletions
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index 54a1f9036c66..1899cf0685bc 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c | |||
@@ -96,7 +96,7 @@ static int __devinit snd_card_pcsp_probe(int devnum, struct device *dev) | |||
96 | return -EINVAL; | 96 | return -EINVAL; |
97 | 97 | ||
98 | hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | 98 | hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
99 | pcsp_chip.timer.cb_mode = HRTIMER_CB_IRQSAFE; | 99 | pcsp_chip.timer.cb_mode = HRTIMER_CB_SOFTIRQ; |
100 | pcsp_chip.timer.function = pcsp_do_timer; | 100 | pcsp_chip.timer.function = pcsp_do_timer; |
101 | 101 | ||
102 | card = snd_card_new(index, id, THIS_MODULE, 0); | 102 | card = snd_card_new(index, id, THIS_MODULE, 0); |
diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c index 7ad4a1534b2b..e341f3f83b6a 100644 --- a/sound/drivers/pcsp/pcsp_lib.c +++ b/sound/drivers/pcsp/pcsp_lib.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/moduleparam.h> | 10 | #include <linux/moduleparam.h> |
11 | #include <sound/pcm.h> | 11 | #include <sound/pcm.h> |
12 | #include <linux/interrupt.h> | ||
13 | #include <asm/io.h> | 12 | #include <asm/io.h> |
14 | #include "pcsp.h" | 13 | #include "pcsp.h" |
15 | 14 | ||
@@ -20,34 +19,8 @@ MODULE_PARM_DESC(nforce_wa, "Apply NForce chipset workaround " | |||
20 | 19 | ||
21 | #define DMIX_WANTS_S16 1 | 20 | #define DMIX_WANTS_S16 1 |
22 | 21 | ||
23 | static void pcsp_start_timer(unsigned long dummy) | ||
24 | { | ||
25 | hrtimer_start(&pcsp_chip.timer, ktime_set(0, 0), HRTIMER_MODE_REL); | ||
26 | } | ||
27 | |||
28 | /* | ||
29 | * We need the hrtimer_start as a tasklet to avoid | ||
30 | * the nasty locking problem. :( | ||
31 | * The problem: | ||
32 | * - The timer handler is called with the cpu_base->lock | ||
33 | * already held by hrtimer code. | ||
34 | * - snd_pcm_period_elapsed() takes the | ||
35 | * substream->self_group.lock. | ||
36 | * So far so good. | ||
37 | * But the snd_pcsp_trigger() is called with the | ||
38 | * substream->self_group.lock held, and it calls | ||
39 | * hrtimer_start(), which takes the cpu_base->lock. | ||
40 | * You see the problem. We have the code pathes | ||
41 | * which take two locks in a reverse order. This | ||
42 | * can deadlock and the lock validator complains. | ||
43 | * The only solution I could find was to move the | ||
44 | * hrtimer_start() into a tasklet. -stsp | ||
45 | */ | ||
46 | static DECLARE_TASKLET(pcsp_start_timer_tasklet, pcsp_start_timer, 0); | ||
47 | |||
48 | enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle) | 22 | enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle) |
49 | { | 23 | { |
50 | unsigned long flags; | ||
51 | unsigned char timer_cnt, val; | 24 | unsigned char timer_cnt, val; |
52 | int fmt_size, periods_elapsed; | 25 | int fmt_size, periods_elapsed; |
53 | u64 ns; | 26 | u64 ns; |
@@ -66,9 +39,7 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle) | |||
66 | return HRTIMER_RESTART; | 39 | return HRTIMER_RESTART; |
67 | } | 40 | } |
68 | 41 | ||
69 | /* hrtimer calls us from both hardirq and softirq contexts, | 42 | spin_lock_irq(&chip->substream_lock); |
70 | * so irqsave :( */ | ||
71 | spin_lock_irqsave(&chip->substream_lock, flags); | ||
72 | /* Takashi Iwai says regarding this extra lock: | 43 | /* Takashi Iwai says regarding this extra lock: |
73 | 44 | ||
74 | If the irq handler handles some data on the DMA buffer, it should | 45 | If the irq handler handles some data on the DMA buffer, it should |
@@ -139,7 +110,7 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle) | |||
139 | chip->period_ptr %= buffer_bytes; | 110 | chip->period_ptr %= buffer_bytes; |
140 | } | 111 | } |
141 | 112 | ||
142 | spin_unlock_irqrestore(&chip->substream_lock, flags); | 113 | spin_unlock_irq(&chip->substream_lock); |
143 | 114 | ||
144 | if (!atomic_read(&chip->timer_active)) | 115 | if (!atomic_read(&chip->timer_active)) |
145 | return HRTIMER_NORESTART; | 116 | return HRTIMER_NORESTART; |
@@ -153,7 +124,7 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle) | |||
153 | exit_nr_unlock2: | 124 | exit_nr_unlock2: |
154 | snd_pcm_stream_unlock(substream); | 125 | snd_pcm_stream_unlock(substream); |
155 | exit_nr_unlock1: | 126 | exit_nr_unlock1: |
156 | spin_unlock_irqrestore(&chip->substream_lock, flags); | 127 | spin_unlock_irq(&chip->substream_lock); |
157 | return HRTIMER_NORESTART; | 128 | return HRTIMER_NORESTART; |
158 | } | 129 | } |
159 | 130 | ||
@@ -174,7 +145,7 @@ static void pcsp_start_playing(struct snd_pcsp *chip) | |||
174 | atomic_set(&chip->timer_active, 1); | 145 | atomic_set(&chip->timer_active, 1); |
175 | chip->thalf = 0; | 146 | chip->thalf = 0; |
176 | 147 | ||
177 | tasklet_schedule(&pcsp_start_timer_tasklet); | 148 | hrtimer_start(&pcsp_chip.timer, ktime_set(0, 0), HRTIMER_MODE_REL); |
178 | } | 149 | } |
179 | 150 | ||
180 | static void pcsp_stop_playing(struct snd_pcsp *chip) | 151 | static void pcsp_stop_playing(struct snd_pcsp *chip) |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 6d4df45e81e0..864b2f598c38 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -2981,7 +2981,7 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = { | |||
2981 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ | 2981 | /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */ |
2982 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), | 2982 | SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG), |
2983 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), | 2983 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG), |
2984 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS), | 2984 | SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG), |
2985 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), | 2985 | SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), |
2986 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), | 2986 | SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), |
2987 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), | 2987 | SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), |
@@ -8757,35 +8757,39 @@ static struct hda_input_mux alc262_HP_D7000_capture_source = { | |||
8757 | }, | 8757 | }, |
8758 | }; | 8758 | }; |
8759 | 8759 | ||
8760 | /* mute/unmute internal speaker according to the hp jack and mute state */ | 8760 | /* mute/unmute internal speaker according to the hp jacks and mute state */ |
8761 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) | 8761 | static void alc262_fujitsu_automute(struct hda_codec *codec, int force) |
8762 | { | 8762 | { |
8763 | struct alc_spec *spec = codec->spec; | 8763 | struct alc_spec *spec = codec->spec; |
8764 | unsigned int mute; | 8764 | unsigned int mute; |
8765 | 8765 | ||
8766 | if (force || !spec->sense_updated) { | 8766 | if (force || !spec->sense_updated) { |
8767 | unsigned int present_int_hp, present_dock_hp; | 8767 | unsigned int present; |
8768 | /* need to execute and sync at first */ | 8768 | /* need to execute and sync at first */ |
8769 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); | 8769 | snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); |
8770 | present_int_hp = snd_hda_codec_read(codec, 0x14, 0, | 8770 | /* check laptop HP jack */ |
8771 | AC_VERB_GET_PIN_SENSE, 0); | 8771 | present = snd_hda_codec_read(codec, 0x14, 0, |
8772 | snd_hda_codec_read(codec, 0x1B, 0, AC_VERB_SET_PIN_SENSE, 0); | 8772 | AC_VERB_GET_PIN_SENSE, 0); |
8773 | present_dock_hp = snd_hda_codec_read(codec, 0x1b, 0, | 8773 | /* need to execute and sync at first */ |
8774 | AC_VERB_GET_PIN_SENSE, 0); | 8774 | snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); |
8775 | spec->jack_present = (present_int_hp & 0x80000000) != 0; | 8775 | /* check docking HP jack */ |
8776 | spec->jack_present |= (present_dock_hp & 0x80000000) != 0; | 8776 | present |= snd_hda_codec_read(codec, 0x1b, 0, |
8777 | AC_VERB_GET_PIN_SENSE, 0); | ||
8778 | if (present & AC_PINSENSE_PRESENCE) | ||
8779 | spec->jack_present = 1; | ||
8780 | else | ||
8781 | spec->jack_present = 0; | ||
8777 | spec->sense_updated = 1; | 8782 | spec->sense_updated = 1; |
8778 | } | 8783 | } |
8779 | if (spec->jack_present) { | 8784 | /* unmute internal speaker only if both HPs are unplugged and |
8780 | /* mute internal speaker */ | 8785 | * master switch is on |
8781 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8786 | */ |
8782 | HDA_AMP_MUTE, HDA_AMP_MUTE); | 8787 | if (spec->jack_present) |
8783 | } else { | 8788 | mute = HDA_AMP_MUTE; |
8784 | /* unmute internal speaker if necessary */ | 8789 | else |
8785 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); | 8790 | mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0); |
8786 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, | 8791 | snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, |
8787 | HDA_AMP_MUTE, mute); | 8792 | HDA_AMP_MUTE, mute); |
8788 | } | ||
8789 | } | 8793 | } |
8790 | 8794 | ||
8791 | /* unsolicited event for HP jack sensing */ | 8795 | /* unsolicited event for HP jack sensing */ |
@@ -8797,6 +8801,11 @@ static void alc262_fujitsu_unsol_event(struct hda_codec *codec, | |||
8797 | alc262_fujitsu_automute(codec, 1); | 8801 | alc262_fujitsu_automute(codec, 1); |
8798 | } | 8802 | } |
8799 | 8803 | ||
8804 | static void alc262_fujitsu_init_hook(struct hda_codec *codec) | ||
8805 | { | ||
8806 | alc262_fujitsu_automute(codec, 1); | ||
8807 | } | ||
8808 | |||
8800 | /* bind volumes of both NID 0x0c and 0x0d */ | 8809 | /* bind volumes of both NID 0x0c and 0x0d */ |
8801 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { | 8810 | static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = { |
8802 | .ops = &snd_hda_bind_vol, | 8811 | .ops = &snd_hda_bind_vol, |
@@ -9570,6 +9579,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
9570 | .channel_mode = alc262_modes, | 9579 | .channel_mode = alc262_modes, |
9571 | .input_mux = &alc262_fujitsu_capture_source, | 9580 | .input_mux = &alc262_fujitsu_capture_source, |
9572 | .unsol_event = alc262_fujitsu_unsol_event, | 9581 | .unsol_event = alc262_fujitsu_unsol_event, |
9582 | .init_hook = alc262_fujitsu_init_hook, | ||
9573 | }, | 9583 | }, |
9574 | [ALC262_HP_BPC] = { | 9584 | [ALC262_HP_BPC] = { |
9575 | .mixers = { alc262_HP_BPC_mixer }, | 9585 | .mixers = { alc262_HP_BPC_mixer }, |