Commit 011fba7b authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[sound/oss i810] fix OSS fragments

This patch makes userfragsize do what it's meant to do: do not start
DAC/ADC until a full fragment is available.
parent 37b57f6c
...@@ -1449,6 +1449,7 @@ static ssize_t i810_read(struct file *file, char *buffer, size_t count, loff_t * ...@@ -1449,6 +1449,7 @@ static ssize_t i810_read(struct file *file, char *buffer, size_t count, loff_t *
unsigned long flags; unsigned long flags;
unsigned int swptr; unsigned int swptr;
int cnt; int cnt;
int pending;
DECLARE_WAITQUEUE(waita, current); DECLARE_WAITQUEUE(waita, current);
#ifdef DEBUG2 #ifdef DEBUG2
...@@ -1474,6 +1475,8 @@ static ssize_t i810_read(struct file *file, char *buffer, size_t count, loff_t * ...@@ -1474,6 +1475,8 @@ static ssize_t i810_read(struct file *file, char *buffer, size_t count, loff_t *
return -EFAULT; return -EFAULT;
ret = 0; ret = 0;
pending = 0;
add_wait_queue(&dmabuf->wait, &waita); add_wait_queue(&dmabuf->wait, &waita);
while (count > 0) { while (count > 0) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
...@@ -1567,7 +1570,7 @@ static ssize_t i810_read(struct file *file, char *buffer, size_t count, loff_t * ...@@ -1567,7 +1570,7 @@ static ssize_t i810_read(struct file *file, char *buffer, size_t count, loff_t *
continue; continue;
} }
dmabuf->swptr = swptr; dmabuf->swptr = swptr;
dmabuf->count -= cnt; pending = dmabuf->count -= cnt;
spin_unlock_irqrestore(&card->lock, flags); spin_unlock_irqrestore(&card->lock, flags);
count -= cnt; count -= cnt;
...@@ -1575,7 +1578,9 @@ static ssize_t i810_read(struct file *file, char *buffer, size_t count, loff_t * ...@@ -1575,7 +1578,9 @@ static ssize_t i810_read(struct file *file, char *buffer, size_t count, loff_t *
ret += cnt; ret += cnt;
} }
done: done:
i810_update_lvi(state,1); pending = dmabuf->dmasize - pending;
if (dmabuf->enable || pending >= dmabuf->userfragsize)
i810_update_lvi(state, 1);
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
remove_wait_queue(&dmabuf->wait, &waita); remove_wait_queue(&dmabuf->wait, &waita);
...@@ -1592,6 +1597,7 @@ static ssize_t i810_write(struct file *file, const char *buffer, size_t count, l ...@@ -1592,6 +1597,7 @@ static ssize_t i810_write(struct file *file, const char *buffer, size_t count, l
ssize_t ret; ssize_t ret;
unsigned long flags; unsigned long flags;
unsigned int swptr = 0; unsigned int swptr = 0;
int pending;
int cnt; int cnt;
DECLARE_WAITQUEUE(waita, current); DECLARE_WAITQUEUE(waita, current);
...@@ -1617,6 +1623,8 @@ static ssize_t i810_write(struct file *file, const char *buffer, size_t count, l ...@@ -1617,6 +1623,8 @@ static ssize_t i810_write(struct file *file, const char *buffer, size_t count, l
return -EFAULT; return -EFAULT;
ret = 0; ret = 0;
pending = 0;
add_wait_queue(&dmabuf->wait, &waita); add_wait_queue(&dmabuf->wait, &waita);
while (count > 0) { while (count > 0) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
...@@ -1709,7 +1717,7 @@ static ssize_t i810_write(struct file *file, const char *buffer, size_t count, l ...@@ -1709,7 +1717,7 @@ static ssize_t i810_write(struct file *file, const char *buffer, size_t count, l
} }
dmabuf->swptr = swptr; dmabuf->swptr = swptr;
dmabuf->count += cnt; pending = dmabuf->count += cnt;
count -= cnt; count -= cnt;
buffer += cnt; buffer += cnt;
...@@ -1717,7 +1725,8 @@ static ssize_t i810_write(struct file *file, const char *buffer, size_t count, l ...@@ -1717,7 +1725,8 @@ static ssize_t i810_write(struct file *file, const char *buffer, size_t count, l
spin_unlock_irqrestore(&state->card->lock, flags); spin_unlock_irqrestore(&state->card->lock, flags);
} }
ret: ret:
i810_update_lvi(state,0); if (dmabuf->enable || pending >= dmabuf->userfragsize)
i810_update_lvi(state, 0);
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
remove_wait_queue(&dmabuf->wait, &waita); remove_wait_queue(&dmabuf->wait, &waita);
......
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