public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Hunold <hunold@linuxtv.org>
To: torvalds@osdl.org, akpm@osdl.org, linux-kernel@vger.kernel.org,
	hunold@linuxtv.org
Subject: [PATCH 4/9] DVB core update
Date: Mon, 23 Feb 2004 16:04:56 -0500	[thread overview]
Message-ID: <107757028289@convergence.de> (raw)
In-Reply-To: <1077570282137@convergence.de>

- [DVB] - dvb-core: replace usage of sleep_on_...() with wait_event_interruptible_timeout()
- [DVB] - dvb-core: fix dvb_ringbuffer_read/write() buffer pointer bug
- [DVB] video: added VIDEO_EVENT_FRAME_RATE_CHANGED and VIDEO_GET_FRAME_RATE ioctl
diff -uNrwB --new-file xx-linux-2.6.3/drivers/media/dvb/dvb-core/dvb_frontend.c linux-2.6.3.p/drivers/media/dvb/dvb-core/dvb_frontend.c
--- xx-linux-2.6.3/drivers/media/dvb/dvb-core/dvb_frontend.c	2004-02-23 12:34:27.000000000 +0100
+++ linux-2.6.3.p/drivers/media/dvb/dvb-core/dvb_frontend.c	2004-02-09 18:30:22.000000000 +0100
@@ -426,6 +426,7 @@
 static int dvb_frontend_thread (void *data)
 {
 	struct dvb_frontend_data *fe = (struct dvb_frontend_data *) data;
+	unsigned long timeout;
 	char name [15];
 	int quality = 0, delay = 3*HZ;
 	fe_status_t s;
@@ -442,12 +443,14 @@
 	dvb_call_frontend_notifiers (fe, 0);
 	dvb_frontend_init (fe);
 
-	while (!dvb_frontend_is_exiting (fe)) {
+	while (1) {
 		up (&fe->sem);      /* is locked when we enter the thread... */
 
-		interruptible_sleep_on_timeout (&fe->wait_queue, delay);
-		if (signal_pending(current))
+		timeout = wait_event_interruptible_timeout(fe->wait_queue,0 != dvb_frontend_is_exiting (fe), delay);
+		if (-ERESTARTSYS == timeout || 0 != dvb_frontend_is_exiting (fe)) {
+			/* got signal or quitting */
 			break;
+		}
 
 		if (down_interruptible (&fe->sem))
 			break;
@@ -455,9 +458,6 @@
 		if (fe->lost_sync_count == -1)
 			continue;
 
-		if (dvb_frontend_is_exiting (fe))
-			break;
-
 		dvb_frontend_internal_ioctl (&fe->frontend, FE_READ_STATUS, &s);
 
 		update_delay (&quality, &delay, s & FE_HAS_LOCK);
@@ -509,6 +509,8 @@
 
 static void dvb_frontend_stop (struct dvb_frontend_data *fe)
 {
+	unsigned long ret;
+	
 	dprintk ("%s\n", __FUNCTION__);
 
 		fe->exit = 1;
@@ -526,10 +528,16 @@
 		return;
 	}
 
+	/* wake up the frontend thread, so it notices that fe->exit == 1 */
 		wake_up_interruptible (&fe->wait_queue);
-	interruptible_sleep_on(&fe->wait_queue);
 
-	/* paranoia check */
+	/* wait until the frontend thread has exited */
+	ret = wait_event_interruptible(fe->wait_queue,0 == fe->thread_pid);
+	if (-ERESTARTSYS != ret) {
+		return;
+	}
+
+	/* paranoia check in case a signal arrived */
 	if (fe->thread_pid)
 		printk("dvb_frontend_stop: warning: thread PID %d won't exit\n",
 				fe->thread_pid);
diff -uNrwB --new-file xx-linux-2.6.3/drivers/media/dvb/dvb-core/dvb_ringbuffer.c linux-2.6.3.p/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
--- xx-linux-2.6.3/drivers/media/dvb/dvb-core/dvb_ringbuffer.c	2004-01-09 09:22:39.000000000 +0100
+++ linux-2.6.3.p/drivers/media/dvb/dvb-core/dvb_ringbuffer.c	2004-02-23 12:52:31.000000000 +0100
@@ -123,7 +123,7 @@
                 if (copy_to_user(buf, rbuf->data+rbuf->pread, todo))
                         return -EFAULT;
 
-        rbuf->pread = (rbuf->pread + len) % rbuf->size;
+        rbuf->pread = (rbuf->pread + todo) % rbuf->size;
 
         return len;
 }
@@ -155,7 +155,7 @@
                 if (copy_from_user(rbuf->data+rbuf->pwrite, buf, todo)) 
                         return -EFAULT;
 
-        rbuf->pwrite = (rbuf->pwrite + len) % rbuf->size;
+        rbuf->pwrite = (rbuf->pwrite + todo) % rbuf->size;
 
 	return len;
 }
diff -uNrwB --new-file xx-linux-2.6.3/include/linux/dvb/video.h linux-2.6.3.p/include/linux/dvb/video.h
--- xx-linux-2.6.3/include/linux/dvb/video.h	2003-12-18 12:55:30.000000000 +0100
+++ linux-2.6.3.p/include/linux/dvb/video.h	2004-02-02 19:28:30.000000000 +0100
@@ -81,9 +81,11 @@
 struct video_event { 
         int32_t type; 
 #define VIDEO_EVENT_SIZE_CHANGED 1
+#define VIDEO_EVENT_FRAME_RATE_CHANGED	2
         time_t timestamp;
 	union { 
 	        video_size_t size;
+		unsigned int frame_rate;	/* in frames per 1000sec */
 	} u; 
 };
 
@@ -194,6 +196,7 @@
 #define VIDEO_GET_NAVI             _IOR('o', 52, video_navi_pack_t)
 #define VIDEO_SET_ATTRIBUTES       _IO('o', 53)
 #define VIDEO_GET_SIZE             _IOR('o', 55, video_size_t)
+#define VIDEO_GET_FRAME_RATE       _IOR('o', 56, unsigned int)
 
 #endif /*_DVBVIDEO_H_*/
 



  reply	other threads:[~2004-02-23 21:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-23 21:04 [PATCH 0/9] LinuxTV.org DVB update Michael Hunold
2004-02-23 21:04 ` [PATCH 1/9] Update the DVB subsystem docs Michael Hunold
2004-02-23 21:04   ` [PATCH 2/9] Update saa7146 driver core Michael Hunold
2004-02-23 21:04     ` [PATCH 3/9] Minor DVB Skystar2 updates Michael Hunold
2004-02-23 21:04       ` Michael Hunold [this message]
2004-02-23 21:04         ` [PATCH 5/9] Misc. DVB frontend updates Michael Hunold
2004-02-23 21:05           ` [PATCH 6/9] stv0299 DVB frontend update Michael Hunold
2004-02-23 21:05             ` [PATCH 7/9] tda1004x " Michael Hunold
2004-02-23 21:05               ` [PATCH 8/9] av7110 DVB driver update Michael Hunold
2004-02-23 21:05                 ` [PATCH 9/9] TTUSB-Budget " Michael Hunold
2004-02-23 21:18               ` [PATCH 7/9] tda1004x DVB frontend update Christoph Hellwig
2004-02-23 22:47                 ` Michael Hunold
2004-02-23 22:54                   ` Christoph Hellwig
2004-02-23 23:01                     ` Michael Hunold
2004-02-23 22:09               ` Andrew Morton
2004-02-23 22:52                 ` Michael Hunold
2004-02-23 23:11                   ` Andrew Morton
2004-02-23 23:15                   ` Ralph Metzler
2004-02-24 11:34                   ` Marcel Holtmann
2004-02-23 22:23   ` [PATCH 1/9] Update the DVB subsystem docs Richard B. Johnson
2004-02-23 22:57     ` Michael Hunold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=107757028289@convergence.de \
    --to=hunold@linuxtv.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox