Re: v4l2 for 2.4.x kernels replaces videodev.h so that kernel no longer compiles

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



Michele Slocovich wrote:
> 
> kernel (2.4.5, patched for i2c 2.6.0) still won-t compile.
> videodevX still working fine together with bttv2 out onto xawtv. (tryed
> multiple times insmod rmmod switching
> back and forth between bttv and bttv2).
> 

OK - try this patch please, it may get everything in synch again (I hope
...)

-justin
diff -urN videodevX/videodev.h videodevX-243/videodev.h
--- videodevX/videodev.h	Thu Jun 14 07:45:23 2001
+++ videodevX-243/videodev.h	Thu Jun 28 11:05:15 2001
@@ -1297,6 +1297,9 @@
 
 struct video_device
 {
+#if LINUX_VERSION_CODE >= 0x020403
+	struct module *owner;
+#endif
 	char name[32];
 	int type;
 	int hardware;
@@ -1321,7 +1324,11 @@
 };
 
 #define VIDEO_MAJOR     81
+#if LINUX_VERSION_CODE >= 0x020405
+extern int video_register_device(struct video_device *, int type, int nr);
+#else
 extern int video_register_device(struct video_device *, int type);
+#endif
 
 #define VFL_TYPE_GRABBER        0
 #define VFL_TYPE_VBI            1
diff -urN videodevX/videodevX.c videodevX-243/videodevX.c
--- videodevX/videodevX.c	Thu Jun 14 07:45:23 2001
+++ videodevX-243/videodevX.c	Thu Jun 28 11:17:11 2001
@@ -346,6 +346,11 @@
 		goto error_out;
 	}
 	vfl->busy=1;		/* In case vfl->open sleeps */
+
+#if LINUX_VERSION_CODE >= 0x020403
+	if(vfl->owner)
+		__MOD_INC_USE_COUNT(vfl->owner);
+#endif
 	unlock_kernel();
 	
 	if(vfl->open)
@@ -354,6 +359,10 @@
 		if(err)
 		{
 			vfl->busy=0;
+#if LINUX_VERSION_CODE >= 0x020403
+			if(vfl->owner)
+				__MOD_DEC_USE_COUNT(vfl->owner);
+#endif
 			return err;
 		}
 	}
@@ -384,6 +393,10 @@
 	if(vfl->close)
 		vfl->close(vfl);
 	vfl->busy=0;
+#if LINUX_VERSION_CODE >= 0x020403
+	if(vfl->owner)
+		__MOD_DEC_USE_COUNT(vfl->owner);
+#endif
 	unlock_kernel();
 	return 0;
 }
@@ -457,6 +470,100 @@
  *	Video For Linux device drivers request registration here.
  */
  
+#if LINUX_VERSION_CODE >= 0x020405
+static DECLARE_MUTEX(videodev_register_lock);
+
+int video_register_device(struct video_device *vfd, int type, int nr)
+{
+	int i=0;
+	int base;
+	int err;
+	int end;
+	char *name_base;
+	char name[16];
+	
+	switch(type)
+	{
+		case VFL_TYPE_GRABBER:
+			base=0;
+			end=64;
+			name_base = "video";
+			break;
+		case VFL_TYPE_VTX:
+			base=192;
+			end=224;
+			name_base = "vtx";
+			break;
+		case VFL_TYPE_VBI:
+			base=224;
+			end=240;
+			name_base = "vbi";
+			break;
+		case VFL_TYPE_RADIO:
+			base=64;
+			end=128;
+			name_base = "radio";
+			break;
+		default:
+			return -1;
+	}
+
+	/* pick a minor number */
+	down(&videodev_register_lock);
+	if (-1 == nr) {
+		/* use first free */
+		for(i=base;i<end;i++)
+			if ((NULL == video_device[i]) &&
+			    (NULL == v4l2_device[i]))
+				break;
+		if (i == end) {
+			up(&videodev_register_lock);
+			return -ENFILE;
+		}
+	} else {
+		/* use the one the driver asked for */
+		i = base+nr;
+		if ((NULL != video_device[i]) ||
+		    (NULL != v4l2_device[i])) {
+			up(&videodev_register_lock);
+			return -ENFILE;
+		}
+	}
+	video_device[i]=vfd;
+	vfd->minor=i;
+	up(&videodev_register_lock);
+
+	/* The init call may sleep so we book the slot out
+	   then call */
+	MOD_INC_USE_COUNT;
+	if(vfd->initialize) {
+		err=vfd->initialize(vfd);
+		if(err<0) {
+			video_device[i]=NULL;
+			MOD_DEC_USE_COUNT;
+			return err;
+		}
+	}
+	sprintf (name, "v4l/%s%d", name_base, i - base);
+	/*
+	 *	Start the device root only. Anything else
+	 *	has serious privacy issues.
+	 */
+	vfd->devfs_handle =
+		devfs_register (NULL, name, DEVFS_FL_DEFAULT,
+				VIDEO_MAJOR, vfd->minor,
+				S_IFCHR | S_IRUSR | S_IWUSR,
+				&video_fops,
+				NULL);
+	
+#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
+	sprintf (name, "%s%d", name_base, i - base);
+	videodev_proc_create_dev (vfd, name);
+#endif
+	return 0;
+}
+
+#else
 int video_register_device(struct video_device *vfd, int type)
 {
 	int i=0;
@@ -540,6 +647,7 @@
 	}
 	return -ENFILE;
 }
+#endif
 
 /*
  *	Unregister an unused video for linux device
@@ -1304,6 +1412,9 @@
 
 static struct file_operations video_fops =
 {
+#if LINUX_VERSION_CODE >= 0x020403
+	owner:		THIS_MODULE,
+#endif
 	llseek:		v4l2_video_llseek,
 	read:		video_read,
 	write:		video_write,

[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux