From 5e8e7c38533a8f86626e9410fa38f5854a6959df Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 10 Aug 2009 10:05:23 +0200 Subject: sound: fix OSS MIDI output data loss In the 2.1.6 kernel, the output loop in midi_poll() was changed to enable interrupts during the outputc() call. Unfortunately, the check whether the device has accepted the current byte ("ok") was moved behind the code that removes the byte from the output queue, so one byte would be lost every time the hardware FIFO is full. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/oss/midibuf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/oss/midibuf.c b/sound/oss/midibuf.c index a40be0cf1d9..782b3b84dac 100644 --- a/sound/oss/midibuf.c +++ b/sound/oss/midibuf.c @@ -127,15 +127,16 @@ static void midi_poll(unsigned long dummy) for (dev = 0; dev < num_midis; dev++) if (midi_devs[dev] != NULL && midi_out_buf[dev] != NULL) { - int ok = 1; - - while (DATA_AVAIL(midi_out_buf[dev]) && ok) + while (DATA_AVAIL(midi_out_buf[dev])) { + int ok; int c = midi_out_buf[dev]->queue[midi_out_buf[dev]->head]; spin_unlock_irqrestore(&lock,flags);/* Give some time to others */ ok = midi_devs[dev]->outputc(dev, c); spin_lock_irqsave(&lock, flags); + if (!ok) + break; midi_out_buf[dev]->head = (midi_out_buf[dev]->head + 1) % MAX_QUEUE_SIZE; midi_out_buf[dev]->len--; } -- cgit v1.2.3-70-g09d2 From f1d269bac24e5ddb3a0650aaeb4117aa806b99f1 Mon Sep 17 00:00:00 2001 From: Roel Kluin Date: Wed, 26 Aug 2009 12:01:20 +0200 Subject: sound: vwsnd: Fix setting of cfgval and ctlval in li_setup_dma() Since !LI_CCFG_* evaluates to 0, this did not change anything to cfgval and ctlval. Signed-off-by: Roel Kluin Signed-off-by: Takashi Iwai --- sound/oss/vwsnd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c index 187f72750e8..6713110bdc7 100644 --- a/sound/oss/vwsnd.c +++ b/sound/oss/vwsnd.c @@ -628,7 +628,7 @@ static void li_setup_dma(dma_chan_t *chan, ASSERT(!(buffer_paddr & 0xFF)); chan->baseval = (buffer_paddr >> 8) | 1 << (37 - 8); - chan->cfgval = (!LI_CCFG_LOCK | + chan->cfgval = ((chan->cfgval & ~LI_CCFG_LOCK) | SHIFT_FIELD(desc->ad1843_slot, LI_CCFG_SLOT) | desc->direction | mode | @@ -638,9 +638,9 @@ static void li_setup_dma(dma_chan_t *chan, tmask = 13 - fragshift; /* See Lithium DMA Notes above. */ ASSERT(size >= 2 && size <= 7); ASSERT(tmask >= 1 && tmask <= 7); - chan->ctlval = (!LI_CCTL_RESET | + chan->ctlval = ((chan->ctlval & ~LI_CCTL_RESET) | SHIFT_FIELD(size, LI_CCTL_SIZE) | - !LI_CCTL_DMA_ENABLE | + (chan->ctlval & ~LI_CCTL_DMA_ENABLE) | SHIFT_FIELD(tmask, LI_CCTL_TMASK) | SHIFT_FIELD(0, LI_CCTL_TPTR)); -- cgit v1.2.3-70-g09d2 From cbbb05703da4b205bb17fde555d3b2926d8b3194 Mon Sep 17 00:00:00 2001 From: Roel Kluin Date: Mon, 31 Aug 2009 16:32:12 +0200 Subject: ALSA: allocation may fail in snd_pcm_oss_change_params() Allocation may fail, show if it did. Signed-off-by: Roel Kluin [Additional fix for invalid runtime->oss.prepare flag set by tiwai] Signed-off-by: Takashi Iwai --- sound/core/oss/pcm_oss.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index dbe406b8259..d35d61b3292 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -1043,10 +1043,15 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) runtime->oss.channels = params_channels(params); runtime->oss.rate = params_rate(params); - runtime->oss.params = 0; - runtime->oss.prepare = 1; vfree(runtime->oss.buffer); runtime->oss.buffer = vmalloc(runtime->oss.period_bytes); + if (!runtime->oss.buffer) { + err = -ENOMEM; + goto failure; + } + + runtime->oss.params = 0; + runtime->oss.prepare = 1; runtime->oss.buffer_used = 0; if (runtime->dma_area) snd_pcm_format_set_silence(runtime->format, runtime->dma_area, bytes_to_samples(runtime, runtime->dma_bytes)); -- cgit v1.2.3-70-g09d2