From 7997d24f33eaab50ed1e9068f8326e6e0dd706cf Mon Sep 17 00:00:00 2001 From: Giovanni Maruzzelli Date: Tue, 14 Dec 2010 06:45:43 -0600 Subject: [PATCH] skypopen: tweaking the OSS audio driver --- src/mod/endpoints/mod_skypopen/oss/main.c | 29 ++++++++++++++-------- src/mod/endpoints/mod_skypopen/oss/scull.h | 2 ++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/mod/endpoints/mod_skypopen/oss/main.c b/src/mod/endpoints/mod_skypopen/oss/main.c index c1228d63f1..925441b254 100644 --- a/src/mod/endpoints/mod_skypopen/oss/main.c +++ b/src/mod/endpoints/mod_skypopen/oss/main.c @@ -67,6 +67,7 @@ void my_timer_callback_inq( unsigned long data ) { struct scull_dev *dev = (void *)data; + dev->readable=1; wake_up_interruptible(&dev->inq); mod_timer( &dev->timer_inq, jiffies + msecs_to_jiffies(GIOVA_SLEEP) ); @@ -76,6 +77,7 @@ void my_timer_callback_outq( unsigned long data ) { struct scull_dev *dev = (void *)data; + dev->writable=1; wake_up_interruptible(&dev->outq); mod_timer( &dev->timer_outq, jiffies + msecs_to_jiffies(GIOVA_SLEEP) ); } @@ -130,11 +132,11 @@ static int scull_c_open(struct inode *inode, struct file *filp) struct scull_dev *dev; dev_t key; - if (!current->tgid) { - printk("Process \"%s\" has no tgid\n", current->comm); + if (!current->pid) { + printk("Process \"%s\" has no pid\n", current->comm); return -EINVAL; } - key = current->tgid; + key = current->pid; /* look for a scullc device in the list */ spin_lock(&scull_c_lock); @@ -170,12 +172,14 @@ ssize_t scull_read(struct file *filp, char __user *buf, size_t count, { struct scull_dev *dev = filp->private_data; - DEFINE_WAIT(wait); - prepare_to_wait(&dev->inq, &wait, TASK_INTERRUPTIBLE); - schedule(); - finish_wait(&dev->inq, &wait); + //DEFINE_WAIT(wait); + //prepare_to_wait(&dev->inq, &wait, TASK_INTERRUPTIBLE); + //schedule(); + //finish_wait(&dev->inq, &wait); //memset(buf, 255, count); + wait_event_interruptible(dev->inq, dev->readable); + dev->readable=0; return count; } @@ -184,10 +188,13 @@ ssize_t scull_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) { struct scull_dev *dev = filp->private_data; - DEFINE_WAIT(wait); - prepare_to_wait(&dev->outq, &wait, TASK_INTERRUPTIBLE); - schedule(); - finish_wait(&dev->outq, &wait); + //DEFINE_WAIT(wait); + //prepare_to_wait(&dev->outq, &wait, TASK_INTERRUPTIBLE); + //schedule(); + //finish_wait(&dev->outq, &wait); + + wait_event_interruptible(dev->outq, dev->writable); + dev->writable=0; return count; diff --git a/src/mod/endpoints/mod_skypopen/oss/scull.h b/src/mod/endpoints/mod_skypopen/oss/scull.h index e86281bd94..565b8b38b7 100644 --- a/src/mod/endpoints/mod_skypopen/oss/scull.h +++ b/src/mod/endpoints/mod_skypopen/oss/scull.h @@ -34,6 +34,8 @@ struct scull_dev { wait_queue_head_t outq; /* read and write queues */ struct timer_list timer_inq; struct timer_list timer_outq; + int readable; + int writable; //unsigned long read_howmany; //unsigned long write_howmany; //unsigned long read_sleeped_acc;