Mercurial > vloopback
comparison vloopback.c @ 14:647e63ddab46
Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
author | AngelCarpintero |
---|---|
date | Wed, 08 Jul 2009 10:07:31 +0000 |
parents | b904131a3807 |
children | 1011e450be45 |
comparison
equal
deleted
inserted
replaced
13:5971a90f2459 | 14:647e63ddab46 |
---|---|
149 * 13.10.08 (Stephan Berberig & Angel Carpintero) | 149 * 13.10.08 (Stephan Berberig & Angel Carpintero) |
150 * Release to work on 2.6.27 , allow v4l_compat_ioctl32 work in 2.6.27 and a little cleanup | 150 * Release to work on 2.6.27 , allow v4l_compat_ioctl32 work in 2.6.27 and a little cleanup |
151 * in Makefile. | 151 * in Makefile. |
152 * | 152 * |
153 * 22.12.08 (Angel Carpintero) | 153 * 22.12.08 (Angel Carpintero) |
154 * Allow build with kernel 2.6.28 and 2.6.27.git ( struct video_dev has not priv member anymore). | 154 * Allow build with kernel 2.6.28 and 2.6.27.git ( struct video_dev has not priv member anymore). |
155 * | |
156 * 17.05.09 (Peter Holik) | |
157 * Patch to allow work with kernel 2.6.29 | |
158 * | |
155 */ | 159 */ |
156 | 160 |
157 | 161 |
158 #define VLOOPBACK_VERSION "1.2-trunk" | 162 #define VLOOPBACK_VERSION "1.3-trunk" |
159 | 163 |
160 /* Include files common to 2.4 and 2.6 versions */ | 164 /* Include files common to 2.4 and 2.6 versions */ |
161 #include <linux/version.h> /* >= 2.6.14 LINUX_VERSION_CODE */ | 165 #include <linux/version.h> /* >= 2.6.14 LINUX_VERSION_CODE */ |
162 #include <linux/errno.h> | 166 #include <linux/errno.h> |
163 #include <linux/kernel.h> | 167 #include <linux/kernel.h> |
164 #include <linux/module.h> | 168 #include <linux/module.h> |
165 #include <linux/pagemap.h> | 169 #include <linux/pagemap.h> |
170 | |
171 #ifndef CONFIG_VIDEO_V4L1_COMPAT | |
172 #error "need CONFIG_VIDEO_V4L1_COMPAT" | |
173 #endif | |
166 | 174 |
167 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) | 175 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) |
168 #include <media/v4l2-common.h> | 176 #include <media/v4l2-common.h> |
169 #endif | 177 #endif |
170 | 178 |
374 memcpy (arg, loops[nr]->ioctlretdata, _IOC_SIZE(cmd)); | 382 memcpy (arg, loops[nr]->ioctlretdata, _IOC_SIZE(cmd)); |
375 } | 383 } |
376 return 0; | 384 return 0; |
377 } | 385 } |
378 | 386 |
387 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) | |
379 static int vloopback_open(struct inode *inod, struct file *f) | 388 static int vloopback_open(struct inode *inod, struct file *f) |
389 #else | |
390 static int vloopback_open(struct file *f) | |
391 #endif | |
380 { | 392 { |
381 struct video_device *loopdev = video_devdata(f); | 393 struct video_device *loopdev = video_devdata(f); |
382 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data; | 394 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data; |
383 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev); | 395 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev); |
384 int nr = ptr->pipenr; | 396 int nr = ptr->pipenr; |
428 info("Current pid %d", current->pid); | 440 info("Current pid %d", current->pid); |
429 } | 441 } |
430 return 0; | 442 return 0; |
431 } | 443 } |
432 | 444 |
445 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) | |
433 static int vloopback_release(struct inode * inod, struct file *f) | 446 static int vloopback_release(struct inode * inod, struct file *f) |
447 #else | |
448 static int vloopback_release(struct file *f) | |
449 #endif | |
434 { | 450 { |
435 struct video_device *loopdev = video_devdata(f); | 451 struct video_device *loopdev = video_devdata(f); |
436 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data; | 452 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data; |
437 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev); | 453 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev); |
438 int nr = ptr->pipenr; | 454 int nr = ptr->pipenr; |
689 up(&loops[nr]->lock); | 705 up(&loops[nr]->lock); |
690 | 706 |
691 return 0; | 707 return 0; |
692 } | 708 } |
693 | 709 |
710 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) | |
694 static int vloopback_ioctl(struct inode *inod, struct file *f, unsigned int cmd, | 711 static int vloopback_ioctl(struct inode *inod, struct file *f, unsigned int cmd, |
695 unsigned long arg) | 712 unsigned long arg) |
713 #else | |
714 static long vloopback_ioctl(struct file *f, unsigned int cmd, unsigned long arg) | |
715 #endif | |
696 { | 716 { |
697 struct video_device *loopdev = video_devdata(f); | 717 struct video_device *loopdev = video_devdata(f); |
698 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data; | 718 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data; |
699 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev); | 719 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev); |
700 int nr = ptr->pipenr; | 720 int nr = ptr->pipenr; |
1113 } | 1133 } |
1114 } | 1134 } |
1115 return 0; | 1135 return 0; |
1116 } | 1136 } |
1117 | 1137 |
1118 static struct file_operations fileops_template = | 1138 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) |
1139 static const struct file_operations fileops_template = | |
1140 #else | |
1141 static const struct v4l2_file_operations fileops_template = | |
1142 #endif | |
1119 { | 1143 { |
1120 owner: THIS_MODULE, | 1144 owner: THIS_MODULE, |
1121 open: vloopback_open, | 1145 open: vloopback_open, |
1122 release: vloopback_release, | 1146 release: vloopback_release, |
1123 read: vloopback_read, | 1147 read: vloopback_read, |
1124 write: vloopback_write, | 1148 write: vloopback_write, |
1125 poll: vloopback_poll, | 1149 poll: vloopback_poll, |
1126 ioctl: vloopback_ioctl, | 1150 ioctl: vloopback_ioctl, |
1127 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15) | 1151 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) |
1128 compat_ioctl: v4l_compat_ioctl32, | 1152 compat_ioctl: v4l_compat_ioctl32, |
1129 #endif | 1153 #endif |
1130 mmap: vloopback_mmap, | 1154 mmap: vloopback_mmap, |
1131 }; | 1155 }; |
1132 | 1156 |
1155 minor_in = minor_out = -1; /* autoassign */ | 1179 minor_in = minor_out = -1; /* autoassign */ |
1156 } else { | 1180 } else { |
1157 minor_in = 2 * nr + dev_offset; | 1181 minor_in = 2 * nr + dev_offset; |
1158 minor_out = 2 * nr + 1 + dev_offset; | 1182 minor_out = 2 * nr + 1 + dev_offset; |
1159 } | 1183 } |
1160 | |
1161 /* allocate space for this pipe */ | 1184 /* allocate space for this pipe */ |
1162 loops[nr]= kmalloc(sizeof(struct vloopback_pipe), GFP_KERNEL); | 1185 loops[nr]= kmalloc(sizeof(struct vloopback_pipe), GFP_KERNEL); |
1163 | 1186 |
1164 if (!loops[nr]) | 1187 if (!loops[nr]) |
1165 return -ENOMEM; | 1188 return -ENOMEM; |