[PATCH] zoran: more fixes

Trent Piepho <[email protected]>
Newsgroups gmane.comp.video.mjpeg.devel
Message-ID <[email protected]>
I figured out what was keeping tvtime from being able to switch inputs.  It
was a problem with restarting capture after stopping it like I thought.
The fix ended up being simple, but finding what exactly was the problem was
a pain.

With this patch tvtime is working ok.  You will of course need to make sure
the horizontal resolution is small enough to fit in the v4l capture buffer.

mplayer works for uncompressed capture.  mplayer's v4l2 driver has a flaw in
that it doesn't set format/width/height in one single call to S_FMT, but tries
to set them one at a time.  So if you request 160x120 RGB32, it will first try
S_FMT 640x480 RGB32.  While 160x120 will fit in a 128k buffer, 640x480 wont,
so the S_FMT fails.  The zoran driver could do a better job of handling S_FMT
calls that aren't possible.

With a patch to mplayer, mjpeg capture mostly works now.  It looks like
mplayer only decodes the first field of full frame mjpeg captures.

xawtv still has problems.  It will work when first started, but it doesn't
work if you do something that starts/stops capture.  From the debug output,
xawtv and driver appear to be capturing frames just fine, xawtv just doesn't
display anything.

The full series can be found at http://linuxtv.org/hg/~tap/zoran

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Mjpeg-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mjpeg-developer
zr_graboff.patch (text/plain, 3.3 KB)
From: Trent Piepho <[email protected]>

zr36067: Turn off raw capture properly

From: Trent Piepho <[email protected]>

When raw capture was turned off the current capturing frame, v4l_grab_frame,
wasn't reset to NO_GRAB_ACTIVE.  If capture was turned back on, the driver
would think this frame was currently being captured, and wait for it to
complete before starting a new frame.  The hardware on the other hand would
not be actively capturing a frame.  The result was the driver would wait
forever for v4l_grab_frame to be captured.

Some calls to zr36057_set_memgrab(0) were missing spin-locks, which have been
added.

Signed-off-by: Trent Piepho <[email protected]>

diff --git a/linux/drivers/media/video/zoran_device.c b/linux/drivers/media/video/zoran_device.c
--- a/linux/drivers/media/video/zoran_device.c
+++ b/linux/drivers/media/video/zoran_device.c
@@ -614,11 +614,10 @@ zr36057_set_memgrab (struct zoran *zr,
 		     int           mode)
 {
 	if (mode) {
-		if (btread(ZR36057_VSSFGR) &
-		    (ZR36057_VSSFGR_SnapShot | ZR36057_VSSFGR_FrameGrab))
+		if (btread(ZR36057_VSSFGR) & ZR36057_VSSFGR_SnapShot)
 			dprintk(1,
 				KERN_WARNING
-				"%s: zr36057_set_memgrab(1) with SnapShot or FrameGrab on!?\n",
+				"%s: zr36057_set_memgrab(1) with SnapShot on!?\n",
 				ZR_DEVNAME(zr));
 
 		/* switch on VSync interrupts */
@@ -635,10 +634,11 @@ zr36057_set_memgrab (struct zoran *zr,
 
 		zr->v4l_memgrab_active = 1;
 	} else {
-		zr->v4l_memgrab_active = 0;
-
 		/* switch off VSync interrupts */
 		btand(~zr->card.vsync_int, ZR36057_ICR);	// SW
+
+		zr->v4l_memgrab_active = 0;
+		zr->v4l_grab_frame = NO_GRAB_ACTIVE;
 
 		/* reenable grabbing to screen if it was running */
 		if (zr->v4l_overlay_active) {
diff --git a/linux/drivers/media/video/zoran_driver.c b/linux/drivers/media/video/zoran_driver.c
--- a/linux/drivers/media/video/zoran_driver.c
+++ b/linux/drivers/media/video/zoran_driver.c
@@ -1243,10 +1243,14 @@ zoran_close_end_session (struct file *fi
 
 	/* v4l capture */
 	if (fh->v4l_buffers.active != ZORAN_FREE) {
+		long flags;
+
+		spin_lock_irqsave(&zr->spinlock, flags);
 		zr36057_set_memgrab(zr, 0);
 		zr->v4l_buffers.allocated = 0;
 		zr->v4l_buffers.active = fh->v4l_buffers.active =
 		    ZORAN_FREE;
+		spin_unlock_irqrestore(&zr->spinlock, flags);
 	}
 
 	/* v4l buffers */
@@ -3511,8 +3515,13 @@ zoran_do_ioctl (struct inode *inode,
 				goto strmoff_unlock_and_return;
 
 			/* unload capture */
-			if (zr->v4l_memgrab_active)
+			if (zr->v4l_memgrab_active) {
+				long flags;
+
+				spin_lock_irqsave(&zr->spinlock, flags);
 				zr36057_set_memgrab(zr, 0);
+				spin_unlock_irqrestore(&zr->spinlock, flags);
+			}
 
 			for (i = 0; i < fh->v4l_buffers.num_buffers; i++)
 				zr->v4l_buffers.buffer[i].state =
@@ -4447,11 +4456,15 @@ zoran_vm_close (struct vm_area_struct *v
 				mutex_lock(&zr->resource_lock);
 
 				if (fh->v4l_buffers.active != ZORAN_FREE) {
+					long flags;
+
+					spin_lock_irqsave(&zr->spinlock, flags);
 					zr36057_set_memgrab(zr, 0);
 					zr->v4l_buffers.allocated = 0;
 					zr->v4l_buffers.active =
 					    fh->v4l_buffers.active =
 					    ZORAN_FREE;
+					spin_unlock_irqrestore(&zr->spinlock, flags);
 				}
 				//v4l_fbuffer_free(file);
 				fh->v4l_buffers.allocated = 0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.