Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: cinergyT2: which kernel/usb module to use?



Stefan Lucke wrote:

Quoting Holger Waechtler:

:) sounds like we need the evil counter-hack to get peace...

can you please try the attached patch and test if it solves your problem?


Found your mail now. Will test it this evening.

The thing that puzzels me is that "pending_fe_events" is only
incremented, neither initialized nor decremented or reset to zero.

oops - sure, you are absolutely right, it should get reset in GET_EVENT -- this line got lost in my edits somehow. Please try the patch below. Keep in mind that neither this nor the event handling code in dvb_frontend.c is multi-client-safe, better just don't use FE_GET_EVENT anywhere in your application, this will also simplify porting to new API versions.

Holger

? build-2.4/include/linux
Index: linux/drivers/media/dvb/cinergyT2/cinergyT2.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/cinergyT2/cinergyT2.c,v
retrieving revision 1.15.2.3
diff -p -u -p -u -r1.15.2.3 cinergyT2.c
--- linux/drivers/media/dvb/cinergyT2/cinergyT2.c	27 Nov 2004 19:15:22 -0000	1.15.2.3
+++ linux/drivers/media/dvb/cinergyT2/cinergyT2.c	30 Nov 2004 12:00:15 -0000
@@ -176,6 +176,7 @@ struct cinergyt2 {
 	struct work_struct query_work;
 
 	wait_queue_head_t poll_wq;
+	int pending_fe_events;
 
 	void *streambuf;
 	dma_addr_t streambuf_dmahandle;
@@ -663,6 +664,13 @@ int cinergyt2_ioctl (struct inode *inode
 		 *  are trivial to fill as soon FE_GET_FRONTEND is done.
 		 */
 		struct dvb_frontend_event *e = (void *) arg;
+		if (cinergyt2->pending_fe_events == 0) {
+			if (file->f_flags & O_NONBLOCK)
+				return -EWOULDBLOCK;
+			wait_event_interruptible(cinergyt2->poll_wq,
+						 cinergyt2->pending_fe_events > 0);
+		}
+		cinergyt2->pending_fe_events = 0;
 		return cinergyt2_ioctl(inode, file, FE_READ_STATUS,
 					(unsigned long) &e->status);
 	}
@@ -695,7 +703,7 @@ int cinergyt2_mmap(struct file *file, st
 		goto bailout;
 	}
 
-        vma->vm_flags |= (VM_IO | VM_DONTCOPY);
+	vma->vm_flags |= (VM_IO | VM_DONTCOPY);
 	vma->vm_file = file;
 
 	ret = remap_pfn_range(vma, vma->vm_start,
@@ -711,11 +719,11 @@ bailout:
 
 static
 struct file_operations cinergyt2_fops = {
-	.owner          = THIS_MODULE,
+	.owner		= THIS_MODULE,
 	.ioctl		= cinergyt2_ioctl,
-	.poll           = cinergyt2_poll,
-	.open           = cinergyt2_open,
-	.release        = cinergyt2_release,
+	.poll		= cinergyt2_poll,
+	.open		= cinergyt2_open,
+	.release	= cinergyt2_release,
 /*	.mmap		= cinergyt2_mmap*/
 };
 
@@ -800,8 +808,10 @@ static void cinergyt2_query (void *data)
 	unc += le32_to_cpu(s->uncorrected_block_count);
 	s->uncorrected_block_count = unc;
 
-	if (lock_bits != s->lock_bits)
+	if (lock_bits != s->lock_bits) {
 		wake_up_interruptible(&cinergyt2->poll_wq);
+		cinergyt2->pending_fe_events++;
+	}
 
 	schedule_delayed_work(&cinergyt2->query_work,
 			      msecs_to_jiffies(QUERY_INTERVAL));

Home | Main Index | Thread Index