patch-2.3.19 linux/drivers/char/bw-qcam.c

Next file: linux/drivers/char/bw-qcam.h
Previous file: linux/drivers/char/buz.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.18/linux/drivers/char/bw-qcam.c linux/drivers/char/bw-qcam.c
@@ -76,18 +76,19 @@
 #include <linux/sched.h>
 #include <linux/version.h>
 #include <linux/videodev.h>
+#include <asm/semaphore.h>
 #include <asm/uaccess.h>
 
 #include "bw-qcam.h"
 
+static unsigned int maxpoll=250;   /* Maximum busy-loop count for qcam I/O */
+static unsigned int yieldlines=4;  /* Yield after this many during capture */
+
 #if LINUX_VERSION_CODE >= 0x020117
 MODULE_PARM(maxpoll,"i");
 MODULE_PARM(yieldlines,"i");   
 #endif
 
-static unsigned int maxpoll=250;   /* Maximum busy-loop count for qcam I/O */
-static unsigned int yieldlines=4;  /* Yield after this many during capture */
-
 extern __inline__ int read_lpstatus(struct qcam_device *q)
 {
 	return parport_read_status(q->pport);
@@ -174,6 +175,8 @@
 	}
 	
 	memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
+	
+	init_MUTEX(&q->lock);
 
 	q->port_mode = (QC_ANY | QC_NOTSET);
 	q->width = 320;
@@ -817,14 +820,12 @@
 			qcam->contrast = p.contrast>>8;
 			qcam->whitebal = p.whiteness>>8;
 			qcam->bpp = p.depth;
-			
+
+			down(&qcam->lock);			
 			qc_setscanmode(qcam);
+			up(&qcam->lock);
 			qcam->status |= QC_PARAM_CHANGE;
 
-/*			parport_claim_or_block(qcam->pdev);
-			qc_set(qcam);
-			parport_release(qcam->pdev);
-*/
 			return 0;
 		}
 		case VIDIOCSWIN:
@@ -855,7 +856,9 @@
 				qcam->height = 240;
 				qcam->transfer_scale = 1;
 			}
+			down(&qcam->lock);
 			qc_setscanmode(qcam);
+			up(&qcam->lock);
 			
 			/* We must update the camera before we grab. We could
 			   just have changed the grab size */
@@ -904,7 +907,9 @@
 	struct qcam_device *qcam=(struct qcam_device *)v;
 	int len;
 	parport_claim_or_block(qcam->pdev);
-	/* Probably should have a semaphore against multiple users */
+	
+	down(&qcam->lock);
+	
 	qc_reset(qcam);
 
 	/* Update the camera parameters if we need to */
@@ -912,6 +917,9 @@
 		qc_set(qcam);
 
 	len=qc_capture(qcam, buf,count);
+	
+	up(&qcam->lock);
+	
 	parport_release(qcam->pdev);
 	return len;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)