Commit e30bea61 authored by Tony Lindgren's avatar Tony Lindgren

Merge with /home/tmlind/src/kernel/linux-omap-2.6

parents cc2b1490 8d8133d4
...@@ -99,6 +99,7 @@ endif ...@@ -99,6 +99,7 @@ endif
config TOUCHSCREEN_OMAP config TOUCHSCREEN_OMAP
tristate "OMAP touchscreen input driver" tristate "OMAP touchscreen input driver"
depends on INPUT && INPUT_TOUCHSCREEN && ARCH_OMAP depends on INPUT && INPUT_TOUCHSCREEN && ARCH_OMAP
select OMAP_TSC2101
help help
Say Y here if you have an OMAP based board with touchscreen Say Y here if you have an OMAP based board with touchscreen
attached to it, e.g. OMAP Innovator, OSK, H2 or H3 attached to it, e.g. OMAP Innovator, OSK, H2 or H3
......
...@@ -202,7 +202,7 @@ static int omap_tsc2101_configure(void) ...@@ -202,7 +202,7 @@ static int omap_tsc2101_configure(void)
{ {
unsigned long uwire_flags = 0; unsigned long uwire_flags = 0;
#if CONFIG_MACH_OMAP_H3 #ifdef CONFIG_MACH_OMAP_H3
int err = 0; int err = 0;
u8 ioExpanderVal = 0; u8 ioExpanderVal = 0;
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <linux/sysrq.h> #include <linux/sysrq.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/completion.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -210,7 +211,8 @@ int audio_setup_buf(audio_stream_t * s) ...@@ -210,7 +211,8 @@ int audio_setup_buf(audio_stream_t * s)
s->started = 0; s->started = 0;
s->bytecount = 0; s->bytecount = 0;
s->fragcount = 0; s->fragcount = 0;
sema_init(&s->sem, s->nbfrags); init_completion(&s->wfc);
s->wfc.done = s->nbfrags;
FN_OUT(0); FN_OUT(0);
return 0; return 0;
err: err:
...@@ -469,7 +471,9 @@ void audio_prime_rx(audio_state_t * state) ...@@ -469,7 +471,9 @@ void audio_prime_rx(audio_state_t * state)
audio_process_dma(state->output_stream); audio_process_dma(state->output_stream);
} }
is->pending_frags = is->nbfrags; is->pending_frags = is->nbfrags;
sema_init(&is->sem, 0); init_completion(&is->wfc);
is->wfc.done = 0;
is->active = 1; is->active = 1;
audio_process_dma(is); audio_process_dma(is);
...@@ -535,7 +539,9 @@ int audio_sync(struct file *file) ...@@ -535,7 +539,9 @@ int audio_sync(struct file *file)
*/ */
b = &s->buffers[s->usr_head]; b = &s->buffers[s->usr_head];
if (b->offset &= ~3) { if (b->offset &= ~3) {
down(&s->sem); /* Wait for a buffer to become free */
if (wait_for_completion_interruptible(&s->wfc))
return 0;
/* /*
* HACK ALERT ! * HACK ALERT !
* To avoid increased complexity in the rest of the code * To avoid increased complexity in the rest of the code
...@@ -568,7 +574,7 @@ int audio_sync(struct file *file) ...@@ -568,7 +574,7 @@ int audio_sync(struct file *file)
/* Let's wait for all buffers to complete */ /* Let's wait for all buffers to complete */
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&s->wq, &wait); add_wait_queue(&s->wq, &wait);
while ((s->pending_frags || (atomic_read(&s->sem.count) < s->nbfrags)) while ((s->pending_frags || (s->wfc.done < s->nbfrags))
&& !signal_pending(current)) { && !signal_pending(current)) {
schedule(); schedule();
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
...@@ -652,7 +658,8 @@ void audio_reset(audio_stream_t * s) ...@@ -652,7 +658,8 @@ void audio_reset(audio_stream_t * s)
s->buffers[s->usr_head].offset = 0; s->buffers[s->usr_head].offset = 0;
s->usr_head = s->dma_head; s->usr_head = s->dma_head;
s->pending_frags = 0; s->pending_frags = 0;
sema_init(&s->sem, s->nbfrags); init_completion(&s->wfc);
s->wfc.done = s->nbfrags;
} }
s->active = 0; s->active = 0;
s->stopped = 0; s->stopped = 0;
...@@ -864,7 +871,6 @@ static void sound_dma_irq_handler(int sound_curr_lch, u16 ch_status, void *data) ...@@ -864,7 +871,6 @@ static void sound_dma_irq_handler(int sound_curr_lch, u16 ch_status, void *data)
tasklet_schedule(&audio_isr_work2); tasklet_schedule(&audio_isr_work2);
work_item_running = 0; work_item_running = 0;
} }
FN_OUT(0); FN_OUT(0);
return; return;
} }
...@@ -893,14 +899,13 @@ static void audio_dma_callback(int lch, u16 ch_status, void *data) ...@@ -893,14 +899,13 @@ static void audio_dma_callback(int lch, u16 ch_status, void *data)
s->dma_tail = 0; s->dma_tail = 0;
if (!s->mapped) if (!s->mapped)
up(&s->sem); complete(&s->wfc);
else else
s->pending_frags++; s->pending_frags++;
wake_up(&s->wq); wake_up(&s->wq);
} }
audio_process_dma(s);
FN_OUT(0); FN_OUT(0);
return; return;
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <linux/sysrq.h> #include <linux/sysrq.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/completion.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -442,6 +443,7 @@ int audio_register_codec(audio_state_t * codec_state) ...@@ -442,6 +443,7 @@ int audio_register_codec(audio_state_t * codec_state)
} }
memcpy(&audio_state, codec_state, sizeof(audio_state_t)); memcpy(&audio_state, codec_state, sizeof(audio_state_t));
sema_init(&audio_state.sem, 1);
ret = platform_device_register(&omap_audio_device); ret = platform_device_register(&omap_audio_device);
if (ret != 0) { if (ret != 0) {
...@@ -531,13 +533,12 @@ audio_write(struct file *file, const char __user *buffer, ...@@ -531,13 +533,12 @@ audio_write(struct file *file, const char __user *buffer,
/* Wait for a buffer to become free */ /* Wait for a buffer to become free */
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
ret = -EAGAIN; ret = -EAGAIN;
if (down_trylock(&s->sem)) if (!s->wfc.done)
break;
} else {
ret = -ERESTARTSYS;
if (down_interruptible(&s->sem))
break; break;
} }
ret = -ERESTARTSYS;
if (wait_for_completion_interruptible(&s->wfc))
break;
/* Feed the current buffer */ /* Feed the current buffer */
chunksize = s->fragsize - b->offset; chunksize = s->fragsize - b->offset;
...@@ -546,7 +547,7 @@ audio_write(struct file *file, const char __user *buffer, ...@@ -546,7 +547,7 @@ audio_write(struct file *file, const char __user *buffer,
DPRINTK("write %d to %d\n", chunksize, s->usr_head); DPRINTK("write %d to %d\n", chunksize, s->usr_head);
if (copy_from_user(b->data + b->offset, buffer, chunksize)) { if (copy_from_user(b->data + b->offset, buffer, chunksize)) {
printk(KERN_ERR "Audio: CopyFrom User failed \n"); printk(KERN_ERR "Audio: CopyFrom User failed \n");
up(&s->sem); complete(&s->wfc);
return -EFAULT; return -EFAULT;
} }
...@@ -555,7 +556,7 @@ audio_write(struct file *file, const char __user *buffer, ...@@ -555,7 +556,7 @@ audio_write(struct file *file, const char __user *buffer,
b->offset += chunksize; b->offset += chunksize;
if (b->offset < s->fragsize) { if (b->offset < s->fragsize) {
up(&s->sem); complete(&s->wfc);
break; break;
} }
...@@ -617,13 +618,12 @@ audio_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos) ...@@ -617,13 +618,12 @@ audio_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos)
/* Wait for a buffer to become full */ /* Wait for a buffer to become full */
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
ret = -EAGAIN; ret = -EAGAIN;
if (down_trylock(&s->sem)) if (!s->wfc.done)
break;
} else {
ret = -ERESTARTSYS;
if (down_interruptible(&s->sem))
break; break;
} }
ret = -ERESTARTSYS;
if (wait_for_completion_interruptible(&s->wfc))
break;
/* Grab data from the current buffer */ /* Grab data from the current buffer */
chunksize = s->fragsize - b->offset; chunksize = s->fragsize - b->offset;
...@@ -631,14 +631,14 @@ audio_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos) ...@@ -631,14 +631,14 @@ audio_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos)
chunksize = count; chunksize = count;
DPRINTK("read %d from %d\n", chunksize, s->usr_head); DPRINTK("read %d from %d\n", chunksize, s->usr_head);
if (copy_to_user(buffer, b->data + b->offset, chunksize)) { if (copy_to_user(buffer, b->data + b->offset, chunksize)) {
up(&s->sem); complete(&s->wfc);
return -EFAULT; return -EFAULT;
} }
buffer += chunksize; buffer += chunksize;
count -= chunksize; count -= chunksize;
b->offset += chunksize; b->offset += chunksize;
if (b->offset < s->fragsize) { if (b->offset < s->fragsize) {
up(&s->sem); complete(&s->wfc);
break; break;
} }
...@@ -748,12 +748,12 @@ audio_poll(struct file *file, struct poll_table_struct *wait) ...@@ -748,12 +748,12 @@ audio_poll(struct file *file, struct poll_table_struct *wait)
if (file->f_mode & FMODE_READ) if (file->f_mode & FMODE_READ)
if ((is->mapped && is->bytecount > 0) || if ((is->mapped && is->bytecount > 0) ||
(!is->mapped && atomic_read(&is->sem.count) > 0)) (!is->mapped && is->wfc.done > 0))
mask |= POLLIN | POLLRDNORM; mask |= POLLIN | POLLRDNORM;
if (file->f_mode & FMODE_WRITE) if (file->f_mode & FMODE_WRITE)
if ((os->mapped && os->bytecount > 0) || if ((os->mapped && os->bytecount > 0) ||
(!os->mapped && atomic_read(&os->sem.count) > 0)) (!os->mapped && os->wfc.done > 0))
mask |= POLLOUT | POLLWRNORM; mask |= POLLOUT | POLLWRNORM;
DPRINTK("audio_poll() returned mask of %s%s\n", DPRINTK("audio_poll() returned mask of %s%s\n",
...@@ -897,7 +897,8 @@ audio_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -897,7 +897,8 @@ audio_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
local_irq_save(flags); local_irq_save(flags);
if (os->mapped && !os->pending_frags) { if (os->mapped && !os->pending_frags) {
os->pending_frags = os->nbfrags; os->pending_frags = os->nbfrags;
sema_init(&os->sem, 0); init_completion(&os->wfc);
os->wfc.done = 0;
os->active = 1; os->active = 1;
} }
os->stopped = 0; os->stopped = 0;
...@@ -958,7 +959,7 @@ audio_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -958,7 +959,7 @@ audio_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
FN_OUT(19); FN_OUT(19);
return -ENOMEM; return -ENOMEM;
} }
inf.bytes = atomic_read(&s->sem.count) * s->fragsize; inf.bytes = s->wfc.done * s->fragsize;
inf.fragments = inf.bytes / s->fragsize; inf.fragments = inf.bytes / s->fragsize;
inf.fragsize = s->fragsize; inf.fragsize = s->fragsize;
......
...@@ -67,7 +67,7 @@ typedef struct { ...@@ -67,7 +67,7 @@ typedef struct {
int input_or_output; /* Direction of this data stream */ int input_or_output; /* Direction of this data stream */
int bytecount; /* nbr of processed bytes */ int bytecount; /* nbr of processed bytes */
int fragcount; /* nbr of fragment transitions */ int fragcount; /* nbr of fragment transitions */
struct semaphore sem; /* account for fragment usage */ struct completion wfc; /* wait for "nbfrags" fragment completion */
wait_queue_head_t wq; /* for poll */ wait_queue_head_t wq; /* for poll */
int dma_spinref; /* DMA is spinning */ int dma_spinref; /* DMA is spinning */
unsigned mapped:1; /* mmap()'ed buffers */ unsigned mapped:1; /* mmap()'ed buffers */
......
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