Commit 57cb93ad authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA CVS update

D:2003/09/30 10:28:26
C:Control Midlevel,HWDEP Midlevel,ALSA Core,PCM Midlevel,RawMidi Midlevel
C:Timer Midlevel,ALSA<-OSS emulation,ALSA sequencer,EMU8000 driver
C:Digigram VX222 driver,USB generic driver
A:Jaroslav Kysela <perex@suse.cz>
F:core/control.c:1.37->1.38 
F:core/hwdep.c:1.21->1.22 
F:core/init.c:1.38->1.39 
F:core/pcm_lib.c:1.43->1.44 
F:core/pcm_native.c:1.81->1.82 
F:core/rawmidi.c:1.37->1.38 
F:core/timer.c:1.46->1.47 
F:core/oss/pcm_oss.c:1.52->1.53 
F:core/seq/seq_lock.c:1.7->1.8 
F:include/rawmidi.h:1.10->1.11 
F:isa/sb/emu8000_patch.c:1.6->1.7 
F:isa/sb/emu8000_pcm.c:1.10->1.11 
F:pci/vx222/vx222_ops.c:1.2->1.3 
F:usb/usbaudio.c:1.65->1.66 
L:Revised schedule() and set_current_state() calls.
L:Replaced need_resched() with cond_resched() call.
parent f723d1ec
......@@ -46,6 +46,7 @@ typedef struct sndrv_rawmidi_status snd_rawmidi_status_t;
#define SNDRV_RAWMIDI_LFLG_INPUT (1<<1)
#define SNDRV_RAWMIDI_LFLG_OPEN (3<<0)
#define SNDRV_RAWMIDI_LFLG_APPEND (1<<2)
#define SNDRV_RAWMIDI_LFLG_NOOPENLOCK (1<<3)
typedef struct _snd_rawmidi_runtime snd_rawmidi_runtime_t;
typedef struct _snd_rawmidi_substream snd_rawmidi_substream_t;
......
......@@ -822,10 +822,9 @@ static ssize_t snd_ctl_read(struct file *file, char *buffer, size_t count, loff_
}
init_waitqueue_entry(&wait, current);
add_wait_queue(&ctl->change_sleep, &wait);
spin_unlock_irq(&ctl->read_lock);
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irq(&ctl->read_lock);
schedule();
set_current_state(TASK_RUNNING);
remove_wait_queue(&ctl->change_sleep, &wait);
if (signal_pending(current))
return result > 0 ? result : -ERESTARTSYS;
......
......@@ -129,13 +129,14 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
} else
break;
set_current_state(TASK_INTERRUPTIBLE);
up(&hw->open_mutex);
schedule();
down(&hw->open_mutex);
if (signal_pending(current)) {
err = -ERESTARTSYS;
break;
}
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&hw->open_wait, &wait);
if (err >= 0) {
err = snd_card_file_add(hw->card, file);
......
......@@ -697,8 +697,8 @@ int snd_power_wait(snd_card_t *card, unsigned int power_state, struct file *file
}
if (file && (file->f_flags & O_NONBLOCK))
return -EAGAIN;
snd_power_unlock(card);
set_current_state(TASK_UNINTERRUPTIBLE);
snd_power_unlock(card);
schedule_timeout(30 * HZ);
snd_power_lock(card);
}
......
......@@ -1814,7 +1814,6 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
break;
}
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&pcm->open_wait, &wait);
up(&pcm->open_mutex);
if (err < 0)
......
......@@ -2106,11 +2106,11 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(snd_pcm_substream_t *substream,
init_waitqueue_entry(&wait, current);
add_wait_queue(&runtime->sleep, &wait);
while (1) {
set_current_state(TASK_INTERRUPTIBLE);
if (signal_pending(current)) {
state = SIGNALED;
break;
}
set_current_state(TASK_INTERRUPTIBLE);
snd_pcm_stream_unlock_irq(substream);
tout = schedule_timeout(10 * HZ);
snd_pcm_stream_lock_irq(substream);
......@@ -2139,7 +2139,6 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(snd_pcm_substream_t *substream,
}
}
_end_loop:
set_current_state(TASK_RUNNING);
remove_wait_queue(&runtime->sleep, &wait);
switch (state) {
......@@ -2401,11 +2400,11 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(snd_pcm_substream_t *substream, void
init_waitqueue_entry(&wait, current);
add_wait_queue(&runtime->sleep, &wait);
while (1) {
set_current_state(TASK_INTERRUPTIBLE);
if (signal_pending(current)) {
state = SIGNALED;
break;
}
set_current_state(TASK_INTERRUPTIBLE);
snd_pcm_stream_unlock_irq(substream);
tout = schedule_timeout(10 * HZ);
snd_pcm_stream_lock_irq(substream);
......@@ -2435,7 +2434,6 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(snd_pcm_substream_t *substream, void
}
}
_end_loop:
set_current_state(TASK_RUNNING);
remove_wait_queue(&runtime->sleep, &wait);
switch (state) {
......
......@@ -1237,11 +1237,11 @@ static int snd_pcm_playback_drain(snd_pcm_substream_t * substream)
add_wait_queue(&runtime->sleep, &wait);
while (1) {
long tout;
set_current_state(TASK_INTERRUPTIBLE);
if (signal_pending(current)) {
state = SIGNALED;
break;
}
set_current_state(TASK_INTERRUPTIBLE);
snd_pcm_stream_unlock_irq(substream);
tout = schedule_timeout(10 * HZ);
snd_pcm_stream_lock_irq(substream);
......@@ -1254,7 +1254,6 @@ static int snd_pcm_playback_drain(snd_pcm_substream_t * substream)
break;
}
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&runtime->sleep, &wait);
switch (state) {
......@@ -1961,12 +1960,11 @@ int snd_pcm_open(struct inode *inode, struct file *file)
}
init_waitqueue_entry(&wait, current);
add_wait_queue(&pcm->open_wait, &wait);
down(&pcm->open_mutex);
while (1) {
down(&pcm->open_mutex);
err = snd_pcm_open_file(file, pcm, device >= SNDRV_MINOR_PCM_CAPTURE ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK, &pcm_file);
if (err >= 0)
break;
up(&pcm->open_mutex);
if (err == -EAGAIN) {
if (file->f_flags & O_NONBLOCK) {
err = -EBUSY;
......@@ -1975,13 +1973,14 @@ int snd_pcm_open(struct inode *inode, struct file *file)
} else
break;
set_current_state(TASK_INTERRUPTIBLE);
up(&pcm->open_mutex);
schedule();
down(&pcm->open_mutex);
if (signal_pending(current)) {
err = -ERESTARTSYS;
break;
}
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&pcm->open_wait, &wait);
if (err < 0)
goto __error;
......
......@@ -191,7 +191,8 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice,
err = -EFAULT;
goto __error1;
}
down(&rmidi->open_mutex);
if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
down(&rmidi->open_mutex);
if (mode & SNDRV_RAWMIDI_LFLG_INPUT) {
if (!(rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT)) {
err = -ENXIO;
......@@ -320,7 +321,8 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice,
} else {
soutput = NULL;
}
up(&rmidi->open_mutex);
if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
up(&rmidi->open_mutex);
if (rfile) {
rfile->rmidi = rmidi;
rfile->input = sinput;
......@@ -338,7 +340,8 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice,
kfree(output);
}
module_put(rmidi->card->module);
up(&rmidi->open_mutex);
if (!(mode & SNDRV_RAWMIDI_LFLG_NOOPENLOCK))
up(&rmidi->open_mutex);
__error1:
return err;
}
......@@ -392,6 +395,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
fflags = snd_rawmidi_file_flags(file);
if ((file->f_flags & O_APPEND) || maj != CONFIG_SND_MAJOR) /* OSS emul? */
fflags |= SNDRV_RAWMIDI_LFLG_APPEND;
fflags |= SNDRV_RAWMIDI_LFLG_NOOPENLOCK;
rawmidi_file = snd_magic_kmalloc(snd_rawmidi_file_t, 0, GFP_KERNEL);
if (rawmidi_file == NULL) {
snd_card_file_remove(card, file);
......@@ -399,6 +403,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
}
init_waitqueue_entry(&wait, current);
add_wait_queue(&rmidi->open_wait, &wait);
down(&rmidi->open_lock);
while (1) {
subdevice = -1;
down_read(&card->controls_rwsem);
......@@ -421,7 +426,9 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
} else
break;
set_current_state(TASK_INTERRUPTIBLE);
up(&rmidi->open_lock);
schedule();
down(&rmidi->open_lock);
if (signal_pending(current)) {
err = -ERESTARTSYS;
break;
......@@ -433,7 +440,6 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
if (rawmidi_file->output && rawmidi_file->output->runtime)
rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR);
#endif
set_current_state(TASK_RUNNING);
remove_wait_queue(&rmidi->open_wait, &wait);
if (err >= 0) {
file->private_data = rawmidi_file;
......@@ -441,6 +447,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
snd_card_file_remove(card, file);
snd_magic_kfree(rawmidi_file);
}
up(&rmidi->open_lock);
return err;
}
......@@ -950,10 +957,9 @@ static ssize_t snd_rawmidi_read(struct file *file, char *buf, size_t count, loff
}
init_waitqueue_entry(&wait, current);
add_wait_queue(&runtime->sleep, &wait);
spin_unlock_irq(&runtime->lock);
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irq(&runtime->lock);
schedule();
set_current_state(TASK_RUNNING);
remove_wait_queue(&runtime->sleep, &wait);
if (signal_pending(current))
return result > 0 ? result : -ERESTARTSYS;
......@@ -1179,10 +1185,9 @@ static ssize_t snd_rawmidi_write(struct file *file, const char *buf, size_t coun
}
init_waitqueue_entry(&wait, current);
add_wait_queue(&runtime->sleep, &wait);
spin_unlock_irq(&runtime->lock);
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irq(&runtime->lock);
timeout = schedule_timeout(30 * HZ);
set_current_state(TASK_RUNNING);
remove_wait_queue(&runtime->sleep, &wait);
if (signal_pending(current))
return result > 0 ? result : -ERESTARTSYS;
......@@ -1207,10 +1212,9 @@ static ssize_t snd_rawmidi_write(struct file *file, const char *buf, size_t coun
unsigned int last_avail = runtime->avail;
init_waitqueue_entry(&wait, current);
add_wait_queue(&runtime->sleep, &wait);
spin_unlock_irq(&runtime->lock);
set_current_state(TASK_INTERRUPTIBLE);
spin_unlock_irq(&runtime->lock);
timeout = schedule_timeout(30 * HZ);
set_current_state(TASK_RUNNING);
remove_wait_queue(&runtime->sleep, &wait);
if (signal_pending(current))
return result > 0 ? result : -ERESTARTSYS;
......
......@@ -25,44 +25,6 @@
#if defined(CONFIG_SMP) || defined(CONFIG_SND_DEBUG)
#if 0 /* NOT USED */
/* (interruptible) sleep_on during the specified spinlock */
void snd_seq_sleep_in_lock(wait_queue_head_t *p, spinlock_t *lock)
{
wait_queue_t wait;
set_current_state(TASK_INTERRUPTIBLE);
init_waitqueue_entry(&wait, current);
add_wait_queue(p, &wait);
spin_unlock(lock);
schedule();
spin_lock_irq(lock);
remove_wait_queue(p, &wait);
}
/* (interruptible) sleep_on with timeout during the specified spinlock */
long snd_seq_sleep_timeout_in_lock(wait_queue_head_t *p, spinlock_t *lock, long timeout)
{
wait_queue_t wait;
set_current_state(TASK_INTERRUPTIBLE);
init_waitqueue_entry(&wait, current);
add_wait_queue(p, &wait);
spin_unlock(lock);
timeout = schedule_timeout(timeout);
spin_lock_irq(lock);
remove_wait_queue(p, &wait);
return timeout;
}
#endif /* NOT USED */
/* wait until all locks are released */
void snd_use_lock_sync_helper(snd_use_lock_t *lockp, const char *file, int line)
{
......
......@@ -1678,7 +1678,6 @@ static ssize_t snd_timer_user_read(struct file *file, char *buffer, size_t count
spin_lock_irq(&tu->qlock);
remove_wait_queue(&tu->qchange_sleep, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current)) {
err = -ERESTARTSYS;
......
......@@ -233,11 +233,7 @@ snd_emu8000_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp,
/* we may take too long time in this loop.
* so give controls back to kernel if needed.
*/
if (need_resched()) {
if (current->state != TASK_RUNNING)
set_current_state(TASK_RUNNING);
schedule();
}
cond_resched();
if (i == sp->v.loopend &&
(sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP|SNDRV_SFNT_SAMPLE_REVERSE_LOOP)))
......
......@@ -424,13 +424,9 @@ static int emu8k_pcm_trigger(snd_pcm_substream_t *subs, int cmd)
*/
#define CHECK_SCHEDULER() \
do { \
if (need_resched()) {\
if (current->state != TASK_RUNNING)\
set_current_state(TASK_RUNNING);\
schedule();\
if (signal_pending(current))\
return -EAGAIN;\
}\
cond_resched();\
if (signal_pending(current))\
return -EAGAIN;\
} while (0)
......
......@@ -378,11 +378,7 @@ static int vx2_load_xilinx_binary(vx_core_t *chip, const snd_hwdep_dsp_image_t *
if (put_xilinx_data(chip, port, 8, data) < 0)
return -EINVAL;
/* don't take too much time in this loop... */
if (need_resched()) {
if (current->state != TASK_RUNNING)
set_current_state(TASK_RUNNING);
schedule();
}
cond_resched();
}
put_xilinx_data(chip, port, 4, 0xff); /* end signature */
......
......@@ -732,7 +732,6 @@ static int wait_clear_urbs(snd_usb_substream_t *subs)
break;
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(1);
set_current_state(TASK_RUNNING);
} while (--timeout > 0);
if (alive)
snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment