annotate vloopback.c @ 15:1011e450be45

Update to allow compile with 2.6.31
author AngelCarpintero
date Fri, 11 Sep 2009 10:02:42 +0000
parents 647e63ddab46
children 2dbe2489381e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1 /*
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
2 * vloopback.c
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
3 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
4 * Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2000
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
5 * Additional copyright by the contributing authors in the
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
6 * change history below, 2000-2007
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
7 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
8 * Published under the GNU Public License.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
9 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
10 * The Video loopback Loopback Device is no longer systematically maintained.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
11 * The project is a secondary project for the project "motion" found at
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
12 * http://motion.sourceforge.net/ and
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
13 * http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
14 * and with the vloopback stored at
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
15 * http://www.lavrsen.dk/twiki/bin/view/Motion/Video loopbackFourLinuxLoopbackDevice
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
16 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
17 * CHANGE HISTORY
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
18 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
19 * UPDATED: Jeroen Vreeken.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
20 * Added locks for smp machines. UNTESTED!
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
21 * Made the driver much more cpu friendly by using
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
22 * a wait queue.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
23 * Went from vmalloc to rvmalloc (yes, I stole the code
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
24 * like everybody else) and implemented mmap.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
25 * Implemented VIDIOCGUNIT and removed size/palette checks
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
26 * in VIDIOCSYNC.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
27 * Cleaned up a lot of code.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
28 * Changed locks to semaphores.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
29 * Disabled changing size while somebody is using mmap
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
30 * Changed mapped check to open check, also don't allow
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
31 * a open for write while somebody is reading.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
32 * Added /proc support
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
33 * Set dumped count to zero at open.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
34 * Modified /proc layout (added vloopbacks entry)
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
35 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
36 * 05.10.00 (MTS) Added Linux 2.2 support
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
37 * 06.10.00 (J Vreeken) Fixed 2.2 support to make things work under 2.4 again.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
38 * 17.10.00 (J Vreeken) Added zero copy mode
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
39 * 19.10.00 (J Vreeken) Added SIGIO on device close.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
40 * 24.10.00 (J Vreeken) Modified 2.2 stuff and removed spinlock.h
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
41 * released 0.81
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
42 * 27.10.00 (J Vreeken) Implemented poll
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
43 * released 0.82
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
44 * 17.01.01 (J Vreeken) support for xawtv
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
45 * Implemented VIDIOCGFBUF
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
46 * Additional checks on framebuffer freeing.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
47 * released 0.83
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
48 * 31.01.01 (J Vreeken) Removed need for 'struct ioctl', use _IOC_SIZE() and
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
49 * IOC_IN instead.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
50 * Change the ioctlnr passing to 'unsigned long int'
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
51 * Instead of just one byte.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
52 * THIS BREAKS COMPATIBILITY WITH PREVIOUS VERSIONS!!!
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
53 * 29.06.01 (J Vreeken) Added dev_offset module option
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
54 * Made vloopback_template sane
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
55 * Added double buffering support
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
56 * Made vloopback less verbose
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
57 * 20.11.01 (tibit) Made dev_offset option sane
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
58 * "Fixed" zerocopy mode by defining the ioctl
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
59 * VIDIOCSINVALID. An application which provides data
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
60 * has to issue it when it encounters an error in
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
61 * ioctl processing. See dummy.c for examples.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
62 * 26.11.03 (Kenneth Lavrsen)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
63 * released 0.91
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
64 * 0.91 is the combination of the 0.90-tibit by
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
65 * Tilmann Bitterberg and an update of the Makefile by
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
66 * Roberto Carvajal.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
67 * 23.01.05 (W Brack)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
68 * (don't know what happened to the comments for 0.92
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
69 * and 0.93, but I tentatively named this one as 0.99)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
70 * enhanced for linux-2.6, with #ifdef to keep it
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
71 * compatible with linux-2.4. For linux versions
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
72 * > 2.5, I changed the memory management
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
73 * routines to the "more modern" way, most of it
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
74 * shamelessly copied from other drivers. I also
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
75 * added in the code necessary to avoid the "videodev
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
76 * has no release callback" message when installing.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
77 * For versions < 2.5, I updated the routines to be
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
78 * closer to several other drivers.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
79 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
80 * 04.02.05 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
81 * Fixed version number to 0.93-pre1.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
82 * Fixed warning for interruptible_sleep_on() deprecated and added
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
83 * wait_event_interruptible compatible with 2.6.x and 2.7.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
84 * Fixed memory manager for kernel version > 2.6.9.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
85 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
86 * 07.02.05 (Kenneth Lavrsen)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
87 * Changed version to 0.94.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
88 * Released as formal released version
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
89 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
90 * 20.02.05 (W Brack)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
91 * Fixed error with wait_event_interruptible.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
92 * Fixed crash when pipe source was stopped before dest.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
93 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
94 * 20.02.05 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
95 * Added install and uninstall in Makefile.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
96 *
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
97 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
98 * 25.04.05 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
99 * Included Samuel Audet's patch, it checks if the input is already
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
100 * opened in write mode.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
101 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
102 * 02.05.05 (Kenneth Lavrsen)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
103 * Released 0.95-snap2 formerly as 0.95
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
104 *
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
105 * 10.05.05 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
106 * Added MODULE_VERSION(), fixed create_pipes when video_register_device() returns
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
107 * -ENFILE .
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
108 * Fix warnings about checking return value from copy_to_user() and copy_from_user() functions.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
109 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
110 * 14.11.05 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
111 * Added <linux/version.h> that includes LINUX_VERSION_CODE and KERNEL_VERSION to fix
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
112 * compilation agains kernel 2.6.14 , change version to 0.97-snap1
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
113 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
114 * 19.12.05 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
115 * Added to example option to choose between rgb24 or yuv420p palettes.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
116 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
117 * 31.12.05 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
118 * Fixed examples, remove perror calls and add support to dummy.c for sysfs.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
119 *
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
120 * 04.06.06 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
121 * Add module_param() for kernel > 2.5 because MODULE_PARAM() macro is obsolete.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
122 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
123 * 17.06.06 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
124 * Release version 1.0 with some fixes and code clean up. Added a Jack Bates contribution
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
125 * to allow build a kernel module in debian way.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
126 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
127 * 26.06.06 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
128 * Added some improvements in Makefile. Fix a problem to compile in Suse.
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
129 *
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
130 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
131 * 02.11.06 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
132 * Make compatible with new kernel stable version 2.6.18, Many functions and declarations has
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
133 * been moved to media/v42l-dev.h and remove from videodev.h/videodev2.h
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
134 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
135 * 18.01.07 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
136 * Change -ENOIOCTLCMD by more appropiate error -ENOTTY.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
137 *
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
138 * 18.05.08 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
139 * Release 1.1-rc1 as 1.1 stable working with 2.6.24
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
140 *
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
141 * 17.08.08 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
142 * kill_proc() deprecated ,pid API changed , type and owner not available in
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
143 * video_device struct, added param debug.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
144 *
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
145 * 24.08.08 (Angel Carpintero)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
146 * Added compat_iotcl32 init in fopsl, replace tabs by 4 spaces in source code,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
147 * add number of buffers as module param.
10
bce647a9dd4b Some changes to allow working with stock kernel 2.6.27
AngelCarpintero
parents: 8
diff changeset
148 *
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
149 * 13.10.08 (Stephan Berberig & Angel Carpintero)
10
bce647a9dd4b Some changes to allow working with stock kernel 2.6.27
AngelCarpintero
parents: 8
diff changeset
150 * Release to work on 2.6.27 , allow v4l_compat_ioctl32 work in 2.6.27 and a little cleanup
bce647a9dd4b Some changes to allow working with stock kernel 2.6.27
AngelCarpintero
parents: 8
diff changeset
151 * in Makefile.
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
152 *
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
153 * 22.12.08 (Angel Carpintero)
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
154 * Allow build with kernel 2.6.28 and 2.6.27.git ( struct video_dev has not priv member anymore).
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
155 *
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
156 * 17.05.09 (Peter Holik)
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
157 * Patch to allow work with kernel 2.6.29
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
158 *
15
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
159 * 05.08.09 (Angel Carpintero)
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
160 * Allow to compile with kernel 2.6.30.*
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
161 *
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
162 * 11.09.09 (Angel Carpintero)
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
163 * Allow to compile with kernel 2.6.31
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
164 */
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
165
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
166
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
167 #define VLOOPBACK_VERSION "1.3-trunk"
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
168
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
169 /* Include files common to 2.4 and 2.6 versions */
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
170 #include <linux/version.h> /* >= 2.6.14 LINUX_VERSION_CODE */
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
171 #include <linux/errno.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
172 #include <linux/kernel.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
173 #include <linux/module.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
174 #include <linux/pagemap.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
175
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
176 #ifndef CONFIG_VIDEO_V4L1_COMPAT
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
177 #error "need CONFIG_VIDEO_V4L1_COMPAT"
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
178 #endif
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
179
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
180 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
181 #include <media/v4l2-common.h>
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
182 #endif
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
183
10
bce647a9dd4b Some changes to allow working with stock kernel 2.6.27
AngelCarpintero
parents: 8
diff changeset
184 /* v4l_compat_ioctl32 */
bce647a9dd4b Some changes to allow working with stock kernel 2.6.27
AngelCarpintero
parents: 8
diff changeset
185 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
15
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
186 #ifdef __KERNEL__
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
187 #undef __KERNEL__
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
188 #endif
10
bce647a9dd4b Some changes to allow working with stock kernel 2.6.27
AngelCarpintero
parents: 8
diff changeset
189 #include <media/v4l2-ioctl.h>
bce647a9dd4b Some changes to allow working with stock kernel 2.6.27
AngelCarpintero
parents: 8
diff changeset
190 #endif
bce647a9dd4b Some changes to allow working with stock kernel 2.6.27
AngelCarpintero
parents: 8
diff changeset
191
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
192 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
193 #define vd_private_data dev.driver_data
15
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
194 #ifndef __KERNEL__
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
195 #define __KERNEL__
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
196 #endif
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
197 #else
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
198 #define vd_private_data priv
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
199 #endif
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
200
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
201 #include <linux/videodev.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
202 #include <linux/vmalloc.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
203 #include <linux/wait.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
204
15
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
205
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
206 /* Include files which are unique to versions */
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
207 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
208 #include <asm/ioctl.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
209 #include <asm/page.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
210 #include <asm/pgtable.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
211 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
212 #ifndef remap_pfn_range
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
213 #define remap_pfn_range(a,b,c,d,e) \
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
214 remap_page_range((a),(b),(c)<<PAGE_SHIFT,(d),(e))
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
215 #endif
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
216 #ifndef vmalloc_to_pfn
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
217 #define vmalloc_to_pfn(a) page_to_pfn(vmalloc_to_page((a)))
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
218 #endif
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
219 #endif
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
220 #include <asm/uaccess.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
221 #include <linux/init.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
222 #include <linux/device.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
223 #else
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
224 #include <linux/mm.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
225 #include <linux/slab.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
226 #include <linux/wrapper.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
227 #include <asm/io.h>
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
228 #endif
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
229
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
230 #define VIDIOCSINVALID _IO('v',BASE_VIDIOCPRIVATE+1)
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
231
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
232 #define verbose(format, arg...) if (printk_ratelimit()) \
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
233 printk(KERN_INFO "[%s] %s: " format "\n" "", \
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
234 __FUNCTION__, __FILE__, ## arg)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
235
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
236 #define info(format, arg...) if (printk_ratelimit()) \
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
237 printk(KERN_INFO "[%s] : " format "\n" "", \
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
238 __FUNCTION__, ## arg)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
239
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
240 #define LOG_NODEBUG 0
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
241 #define LOG_FUNCTIONS 1
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
242 #define LOG_IOCTL 2
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
243 #define LOG_VERBOSE 3
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
244
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
245 struct vloopback_private {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
246 int pipenr;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
247 int in; /* bool , is being feed ? */
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
248 };
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
249
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
250 typedef struct vloopback_private *priv_ptr;
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
251
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
252 struct vloopback_pipe {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
253 struct video_device *vloopin;
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
254 struct video_device *vloopout;
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
255 char *buffer;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
256 unsigned long buflength;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
257 unsigned int width, height;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
258 unsigned int palette;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
259 unsigned long frameswrite;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
260 unsigned long framesread;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
261 unsigned long framesdumped;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
262 unsigned int wopen;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
263 unsigned int ropen;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
264 struct semaphore lock;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
265 wait_queue_head_t wait;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
266 unsigned int frame;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
267 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
268 unsigned int pid;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
269 #else
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
270 struct pid *pid;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
271 #endif
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
272 unsigned int zerocopy;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
273 unsigned long int ioctlnr;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
274 unsigned int invalid_ioctl; /* 0 .. none invalid; 1 .. invalid */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
275 unsigned int ioctllength;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
276 char *ioctldata;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
277 char *ioctlretdata;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
278 };
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
279
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
280 #define MAX_PIPES 16
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
281 #define N_BUFFS 2 /* Number of buffers used for pipes */
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
282
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
283 static struct vloopback_pipe *loops[MAX_PIPES];
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
284 static int nr_o_pipes = 0;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
285 static int pipes = -1;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
286 static int spares = 0;
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
287 static unsigned int num_buffers = N_BUFFS;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
288 static int pipesused = 0;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
289 static int dev_offset = -1;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
290 static unsigned int debug = LOG_NODEBUG;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
291
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
292 /**********************************************************************
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
293 *
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
294 * Memory management - revised for 2.6 kernels
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
295 *
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
296 **********************************************************************/
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
297 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
298 /* Here we want the physical address of the memory.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
299 * This is used when initializing the contents of the
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
300 * area and marking the pages as reserved.
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
301 */
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
302 static inline unsigned long kvirt_to_pa(unsigned long adr)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
303 {
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
304 unsigned long kva;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
305
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
306 kva = (unsigned long)page_address(vmalloc_to_page((void *)adr));
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
307 kva |= adr & (PAGE_SIZE-1); /* restore the offset */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
308 return __pa(kva);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
309 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
310 #endif
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
311
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
312 static void *rvmalloc(unsigned long size)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
313 {
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
314 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
315 struct page *page;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
316 #endif
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
317 void *mem;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
318 unsigned long adr;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
319
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
320 size = PAGE_ALIGN(size);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
321 mem = vmalloc_32(size);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
322 if (!mem)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
323 return NULL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
324 memset(mem, 0, size); /* Clear the ram out, no junk to the user */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
325 adr = (unsigned long) mem;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
326 while (size > 0) {
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
327 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
328 page = vmalloc_to_page((void *)adr);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
329 mem_map_reserve(page);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
330 #else
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
331 SetPageReserved(vmalloc_to_page((void *)adr));
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
332 #endif
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
333 adr += PAGE_SIZE;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
334 size -= PAGE_SIZE;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
335 }
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
336
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
337 return mem;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
338 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
339
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
340 static void rvfree(void *mem, unsigned long size)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
341 {
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
342 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
343 struct page *page;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
344 #endif
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
345 unsigned long adr;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
346
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
347 if (!mem)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
348 return;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
349
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
350 adr = (unsigned long) mem;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
351 while ((long) size > 0) {
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
352 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
353 page = vmalloc_to_page((void *)adr);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
354 mem_map_unreserve(page);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
355 #else
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
356 ClearPageReserved(vmalloc_to_page((void *)adr));
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
357 #endif
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
358 adr += PAGE_SIZE;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
359 size -= PAGE_SIZE;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
360 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
361 vfree(mem);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
362 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
363
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
364
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
365 static int create_pipe(int nr);
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
366
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
367 static int fake_ioctl(int nr, unsigned long int cmd, void *arg)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
368 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
369 unsigned long fw;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
370
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
371 if (debug > LOG_NODEBUG)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
372 info("Video loopback %d cmd %lu", nr, cmd);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
373
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
374 loops[nr]->ioctlnr = cmd;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
375 memcpy(loops[nr]->ioctldata, arg, _IOC_SIZE(cmd));
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
376 loops[nr]->ioctllength = _IOC_SIZE(cmd);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
377
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
378 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
379 kill_proc(loops[nr]->pid, SIGIO, 1); /* Signal the pipe feeder */
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
380 #else
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
381 kill_pid(loops[nr]->pid, SIGIO, 1);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
382 #endif
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
383
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
384 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
385 fw = loops[nr]->frameswrite;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
386 wait_event_interruptible(loops[nr]->wait, fw != loops[nr]->frameswrite);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
387 #else
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
388 interruptible_sleep_on(&loops[nr]->wait);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
389 #endif
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
390 if (cmd & IOC_IN) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
391 if (memcmp (arg, loops[nr]->ioctlretdata, _IOC_SIZE(cmd)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
392 return 1;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
393 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
394 memcpy (arg, loops[nr]->ioctlretdata, _IOC_SIZE(cmd));
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
395 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
396 return 0;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
397 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
398
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
399 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
400 static int vloopback_open(struct inode *inod, struct file *f)
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
401 #else
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
402 static int vloopback_open(struct file *f)
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
403 #endif
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
404 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
405 struct video_device *loopdev = video_devdata(f);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
406 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
407 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
408 int nr = ptr->pipenr;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
409
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
410 if (debug > LOG_NODEBUG)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
411 info("Video loopback %d", nr);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
412
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
413 /* Only allow a output to be opened if there is someone feeding
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
414 * the pipe.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
415 */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
416 if (!ptr->in) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
417 if (loops[nr]->buffer == NULL)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
418 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
419
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
420 loops[nr]->framesread = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
421 loops[nr]->ropen = 1;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
422 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
423 if (loops[nr]->ropen || loops[nr]->wopen)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
424 return -EBUSY;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
425
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
426 loops[nr]->framesdumped = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
427 loops[nr]->frameswrite = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
428 loops[nr]->wopen = 1;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
429 loops[nr]->zerocopy = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
430 loops[nr]->ioctlnr = -1;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
431 pipesused++;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
432 if (nr_o_pipes-pipesused<spares) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
433 if (!create_pipe(nr_o_pipes)) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
434 info("Creating extra spare pipe");
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
435 info("Loopback %d registered, input: video%d, output: video%d",
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
436 nr_o_pipes,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
437 loops[nr_o_pipes]->vloopin->minor,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
438 loops[nr_o_pipes]->vloopout->minor
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
439 );
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
440 nr_o_pipes++;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
441 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
442 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
443 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
444 loops[nr]->pid = current->pid;
15
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
445 #elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)
1011e450be45 Update to allow compile with 2.6.31
AngelCarpintero
parents: 14
diff changeset
446 loops[nr]->pid = find_pid_ns(current->pid,0);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
447 #else
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
448 // TODO : Check in stable 2.6.27
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
449 loops[nr]->pid = task_pid(find_task_by_vpid(current->pid));
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
450 //loops[nr]->pid = task_pid(current);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
451 #endif
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
452
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
453 if (debug > LOG_NODEBUG)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
454 info("Current pid %d", current->pid);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
455 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
456 return 0;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
457 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
458
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
459 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
460 static int vloopback_release(struct inode * inod, struct file *f)
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
461 #else
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
462 static int vloopback_release(struct file *f)
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
463 #endif
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
464 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
465 struct video_device *loopdev = video_devdata(f);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
466 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
467 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
468 int nr = ptr->pipenr;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
469
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
470 if (debug > LOG_NODEBUG)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
471 info("Video loopback %d", nr);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
472
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
473 if (ptr->in) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
474 down(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
475 if (loops[nr]->buffer && !loops[nr]->ropen) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
476 rvfree(loops[nr]->buffer, loops[nr]->buflength * num_buffers);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
477 loops[nr]->buffer = NULL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
478 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
479
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
480 up(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
481 loops[nr]->frameswrite++;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
482
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
483 if (waitqueue_active(&loops[nr]->wait))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
484 wake_up(&loops[nr]->wait);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
485
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
486 loops[nr]->width = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
487 loops[nr]->height = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
488 loops[nr]->palette = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
489 loops[nr]->wopen = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
490 pipesused--;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
491 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
492 down(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
493
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
494 if (loops[nr]->buffer && !loops[nr]->wopen) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
495 rvfree(loops[nr]->buffer, loops[nr]->buflength * num_buffers);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
496 loops[nr]->buffer = NULL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
497 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
498
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
499 up(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
500 loops[nr]->ropen = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
501
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
502 if (loops[nr]->zerocopy && loops[nr]->buffer) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
503 loops[nr]->ioctlnr = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
504 loops[nr]->ioctllength = 0;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
505 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
506 kill_proc(loops[nr]->pid, SIGIO, 1);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
507 #else
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
508 kill_pid(loops[nr]->pid, SIGIO, 1);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
509 #endif
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
510 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
511 }
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
512
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
513 return 0;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
514 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
515
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
516 static ssize_t vloopback_write(struct file *f, const char *buf,
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
517 size_t count, loff_t *offset)
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
518 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
519 struct video_device *loopdev = video_devdata(f);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
520 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
521 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
522 int nr = ptr->pipenr;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
523 unsigned long realcount = count;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
524
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
525 if (debug > LOG_IOCTL)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
526 info("Video loopback %d", nr);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
527
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
528 if (!ptr->in)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
529 return -EINVAL;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
530
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
531 if (loops[nr]->zerocopy)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
532 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
533
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
534 if (loops[nr]->buffer == NULL)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
535 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
536
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
537 /* Anybody want some pictures??? */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
538 if (!waitqueue_active(&loops[nr]->wait)) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
539 loops[nr]->framesdumped++;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
540 return realcount;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
541 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
542
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
543 down(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
544 if (!loops[nr]->buffer) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
545 up(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
546 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
547 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
548
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
549 if (realcount > loops[nr]->buflength) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
550 realcount = loops[nr]->buflength;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
551 info("Too much data for Video loopback %d ! Only %ld bytes used.",
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
552 nr, realcount);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
553 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
554
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
555 if (copy_from_user(loops[nr]->buffer + loops[nr]->frame * loops[nr]->buflength,
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
556 buf, realcount))
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
557 return -EFAULT;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
558
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
559 loops[nr]->frame = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
560 up(&loops[nr]->lock);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
561
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
562 loops[nr]->frameswrite++;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
563 wake_up(&loops[nr]->wait);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
564
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
565 return realcount;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
566 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
567
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
568 static ssize_t vloopback_read(struct file * f, char * buf, size_t count,
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
569 loff_t *offset)
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
570 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
571 struct video_device *loopdev = video_devdata(f);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
572 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
573 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
574 int nr = ptr->pipenr;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
575 unsigned long realcount = count;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
576
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
577 if (debug > LOG_IOCTL)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
578 info("Video loopback %d", nr);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
579
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
580 if (loops[nr]->zerocopy) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
581 if (ptr->in) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
582 if (realcount > loops[nr]->ioctllength + sizeof(unsigned long int))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
583 realcount = loops[nr]->ioctllength + sizeof(unsigned long int);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
584
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
585 if (copy_to_user(buf , &loops[nr]->ioctlnr, sizeof(unsigned long int)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
586 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
587
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
588 if (copy_to_user(buf + sizeof(unsigned long int), loops[nr]->ioctldata,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
589 realcount - sizeof(unsigned long int)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
590 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
591
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
592 if (loops[nr]->ioctlnr == 0)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
593 loops[nr]->ioctlnr = -1;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
594
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
595 return realcount;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
596 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
597 struct video_window vidwin;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
598 struct video_mmap vidmmap;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
599 struct video_picture vidpic;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
600
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
601 fake_ioctl(nr, VIDIOCGWIN, &vidwin);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
602 fake_ioctl(nr, VIDIOCGPICT, &vidpic);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
603
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
604 vidmmap.height = vidwin.height;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
605 vidmmap.width = vidwin.width;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
606 vidmmap.format = vidpic.palette;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
607 vidmmap.frame = 0;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
608
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
609 if (fake_ioctl(nr, VIDIOCMCAPTURE, &vidmmap))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
610 return 0;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
611
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
612 if (fake_ioctl(nr, VIDIOCSYNC, &vidmmap))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
613 return 0;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
614
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
615 realcount = vidwin.height * vidwin.width * vidpic.depth;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
616 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
617 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
618
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
619 if (ptr->in)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
620 return -EINVAL;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
621
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
622 if (realcount > loops[nr]->buflength) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
623 realcount = loops[nr]->buflength;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
624 info("Not so much data in buffer! for Video loopback %d", nr);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
625 }
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
626
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
627 if (!loops[nr]->zerocopy) {
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
628 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
629 unsigned long fw = loops[nr]->frameswrite;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
630
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
631 wait_event_interruptible(loops[nr]->wait, fw != loops[nr]->frameswrite);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
632 #else
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
633 interruptible_sleep_on(&loops[nr]->wait);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
634 #endif
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
635 }
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
636
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
637 down(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
638 if (!loops[nr]->buffer) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
639 up(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
640 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
641 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
642
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
643 if (copy_to_user(buf, loops[nr]->buffer, realcount))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
644 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
645
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
646 up(&loops[nr]->lock);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
647
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
648 loops[nr]->framesread++;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
649 return realcount;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
650 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
651
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
652 static int vloopback_mmap(struct file *f, struct vm_area_struct *vma)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
653 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
654 struct video_device *loopdev = video_devdata(f);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
655 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
656 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
657 int nr = ptr->pipenr;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
658 unsigned long start = (unsigned long)vma->vm_start;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
659 long size = vma->vm_end - vma->vm_start;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
660 unsigned long page, pos;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
661
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
662 if (debug > LOG_NODEBUG)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
663 info("Video loopback %d", nr);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
664
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
665 down(&loops[nr]->lock);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
666
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
667 if (ptr->in) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
668 loops[nr]->zerocopy = 1;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
669
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
670 if (loops[nr]->ropen) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
671 info("Can't change size while opened for read in Video loopback %d",
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
672 nr);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
673 up(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
674 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
675 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
676
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
677 if (!size) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
678 up(&loops[nr]->lock);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
679 info("Invalid size Video loopback %d", nr);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
680 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
681 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
682
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
683 if (loops[nr]->buffer)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
684 rvfree(loops[nr]->buffer, loops[nr]->buflength * num_buffers);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
685
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
686 loops[nr]->buflength = size;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
687 loops[nr]->buffer = rvmalloc(loops[nr]->buflength * num_buffers);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
688 }
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
689
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
690 if (loops[nr]->buffer == NULL) {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
691 up(&loops[nr]->lock);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
692 return -EINVAL;
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
693 }
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
694
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
695 if (size > (((num_buffers * loops[nr]->buflength) + PAGE_SIZE - 1)
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
696 & ~(PAGE_SIZE - 1))) {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
697 up(&loops[nr]->lock);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
698 return -EINVAL;
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
699 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
700
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
701 pos = (unsigned long)loops[nr]->buffer;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
702
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
703 while (size > 0) {
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
704 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
705 page = kvirt_to_pa(pos);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
706 if (remap_page_range(vma,start, page, PAGE_SIZE, PAGE_SHARED)) {
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
707 #else
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
708 page = vmalloc_to_pfn((void *)pos);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
709 if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
710 #endif
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
711 up(&loops[nr]->lock);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
712 return -EAGAIN;
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
713 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
714 start += PAGE_SIZE;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
715 pos += PAGE_SIZE;
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
716 size -= PAGE_SIZE;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
717 }
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
718
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
719 up(&loops[nr]->lock);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
720
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
721 return 0;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
722 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
723
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
724 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
725 static int vloopback_ioctl(struct inode *inod, struct file *f, unsigned int cmd,
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
726 unsigned long arg)
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
727 #else
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
728 static long vloopback_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
729 #endif
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
730 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
731 struct video_device *loopdev = video_devdata(f);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
732 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
733 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
734 int nr = ptr->pipenr;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
735 int i;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
736
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
737 if (debug > LOG_NODEBUG)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
738 info("Video loopback %d cmd %u", nr, cmd);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
739
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
740 if (loops[nr]->zerocopy) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
741 if (!ptr->in) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
742 loops[nr]->ioctlnr = cmd;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
743 loops[nr]->ioctllength = _IOC_SIZE(cmd);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
744 /* info("DEBUG: vl_ioctl: !loop->in"); */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
745 /* info("DEBUG: vl_ioctl: cmd %lu", cmd); */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
746 /* info("DEBUG: vl_ioctl: len %lu", loops[nr]->ioctllength); */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
747 if (copy_from_user(loops[nr]->ioctldata, (void*)arg, _IOC_SIZE(cmd)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
748 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
749 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
750 kill_proc(loops[nr]->pid, SIGIO, 1);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
751 #else
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
752 kill_pid(loops[nr]->pid, SIGIO, 1);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
753 #endif
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
754
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
755 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
756 wait_event_interruptible(loops[nr]->wait, loops[nr]->ioctlnr == -1);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
757 #else
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
758 interruptible_sleep_on(&loops[nr]->wait);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
759 #endif
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
760
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
761 if (loops[nr]->invalid_ioctl) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
762 info ("There was an invalid ioctl in Video loopback %d", nr);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
763 loops[nr]->invalid_ioctl = 0;
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
764 return -ENOTTY;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
765 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
766
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
767 if (cmd & IOC_IN && !(cmd & IOC_OUT)) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
768 //info("DEBUG: vl_ioctl: cmd & IOC_IN 1");
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
769 if (memcmp(loops[nr]->ioctlretdata, loops[nr]->ioctldata, _IOC_SIZE(cmd)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
770 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
771
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
772 //info("DEBUG: vl_ioctl: cmd & IOC_IN 2");
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
773 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
774 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
775 if (copy_to_user((void*)arg, loops[nr]->ioctlretdata, _IOC_SIZE(cmd)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
776 return -EFAULT;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
777 //info("DEBUG: vl_ioctl: !(cmd & IOC_IN) 1");
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
778 return 0;
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
779 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
780 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
781 if ((loops[nr]->ioctlnr != cmd) && (cmd != (VIDIOCSINVALID))) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
782 /* wrong ioctl */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
783 info("Wrong IOCTL %u in Video loopback %d", cmd, nr);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
784 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
785 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
786
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
787 if (cmd == VIDIOCSINVALID) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
788 loops[nr]->invalid_ioctl = 1;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
789 } else if (copy_from_user(loops[nr]->ioctlretdata,
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
790 (void*)arg, loops[nr]->ioctllength)) {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
791 return -EFAULT;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
792 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
793
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
794 loops[nr]->ioctlnr = -1;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
795
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
796 if (waitqueue_active(&loops[nr]->wait))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
797 wake_up(&loops[nr]->wait);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
798
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
799 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
800 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
801 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
802
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
803 switch(cmd)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
804 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
805 /* Get capabilities */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
806 case VIDIOCGCAP:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
807 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
808 struct video_capability b;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
809 if (ptr->in) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
810 sprintf(b.name, "Video loopback %d input", nr);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
811 b.type = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
812 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
813 sprintf(b.name, "Video loopback %d output", nr);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
814 b.type = VID_TYPE_CAPTURE;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
815 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
816
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
817 b.channels = 1;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
818 b.audios = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
819 b.maxwidth = loops[nr]->width;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
820 b.maxheight = loops[nr]->height;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
821 b.minwidth = 20;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
822 b.minheight = 20;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
823
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
824 if (copy_to_user((void*)arg, &b, sizeof(b)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
825 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
826
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
827 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
828 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
829 /* Get channel info (sources) */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
830 case VIDIOCGCHAN:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
831 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
832 struct video_channel v;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
833 if (copy_from_user(&v, (void*)arg, sizeof(v)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
834 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
835
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
836 if (v.channel != 0) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
837 info("VIDIOCGCHAN: Invalid Channel, was %d", v.channel);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
838 v.channel = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
839 //return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
840 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
841
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
842 v.flags = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
843 v.tuners = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
844 v.norm = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
845 v.type = VIDEO_TYPE_CAMERA;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
846 /*strcpy(v.name, "Loopback"); -- tibit */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
847 strcpy(v.name, "Composite1");
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
848
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
849 if (copy_to_user((void*)arg, &v, sizeof(v)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
850 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
851
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
852 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
853 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
854 /* Set channel */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
855 case VIDIOCSCHAN:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
856 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
857 int v;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
858
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
859 if (copy_from_user(&v, (void*)arg, sizeof(v)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
860 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
861
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
862 if (v != 0) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
863 info("VIDIOCSCHAN: Invalid Channel, was %d", v);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
864 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
865 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
866
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
867 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
868 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
869 /* Get tuner abilities */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
870 case VIDIOCGTUNER:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
871 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
872 struct video_tuner v;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
873
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
874 if (copy_from_user(&v, (void*)arg, sizeof(v)) != 0)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
875 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
876
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
877 if (v.tuner) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
878 info("VIDIOCGTUNER: Invalid Tuner, was %d", v.tuner);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
879 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
880 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
881
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
882 strcpy(v.name, "Format");
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
883 v.rangelow = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
884 v.rangehigh = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
885 v.flags = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
886 v.mode = VIDEO_MODE_AUTO;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
887
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
888 if (copy_to_user((void*)arg,&v, sizeof(v)) != 0)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
889 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
890
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
891 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
892 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
893 /* Get picture properties */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
894 case VIDIOCGPICT:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
895 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
896 struct video_picture p;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
897
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
898 p.colour = 0x8000;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
899 p.hue = 0x8000;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
900 p.brightness = 0x8000;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
901 p.contrast = 0x8000;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
902 p.whiteness = 0x8000;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
903 p.depth = 0x8000;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
904 p.palette = loops[nr]->palette;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
905
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
906 if (copy_to_user((void*)arg, &p, sizeof(p)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
907 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
908
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
909 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
910 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
911 /* Set picture properties */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
912 case VIDIOCSPICT:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
913 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
914 struct video_picture p;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
915
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
916 if (copy_from_user(&p, (void*)arg, sizeof(p)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
917 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
918
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
919 if (!ptr->in) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
920 if (p.palette != loops[nr]->palette)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
921 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
922 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
923 loops[nr]->palette = p.palette;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
924 }
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
925
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
926 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
927 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
928 /* Get the video overlay window */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
929 case VIDIOCGWIN:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
930 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
931 struct video_window vw;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
932
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
933 vw.x = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
934 vw.y = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
935 vw.width = loops[nr]->width;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
936 vw.height = loops[nr]->height;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
937 vw.chromakey = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
938 vw.flags = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
939 vw.clipcount = 0;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
940
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
941 if (copy_to_user((void*)arg, &vw, sizeof(vw)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
942 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
943
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
944 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
945 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
946 /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
947 case VIDIOCSWIN:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
948 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
949 struct video_window vw;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
950
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
951 if (copy_from_user(&vw, (void*)arg, sizeof(vw)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
952 return -EFAULT;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
953
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
954 if (vw.flags)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
955 return -EINVAL;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
956
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
957 if (vw.clipcount)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
958 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
959
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
960 if (loops[nr]->height == vw.height &&
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
961 loops[nr]->width == vw.width)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
962 return 0;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
963
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
964 if (!ptr->in) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
965 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
966 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
967 loops[nr]->height = vw.height;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
968 loops[nr]->width = vw.width;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
969 /* Make sure nobody is using the buffer while we
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
970 fool around with it.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
971 We are also not allowing changes while
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
972 somebody using mmap has the output open.
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
973 */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
974 down(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
975 if (loops[nr]->ropen) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
976 info("Can't change size while opened for read");
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
977 up(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
978 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
979 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
980
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
981 if (loops[nr]->buffer)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
982 rvfree(loops[nr]->buffer, loops[nr]->buflength * num_buffers);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
983
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
984 loops[nr]->buflength = vw.width * vw.height * 4;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
985 loops[nr]->buffer = rvmalloc(loops[nr]->buflength * num_buffers);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
986 up(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
987 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
988 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
989 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
990 /* Memory map buffer info */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
991 case VIDIOCGMBUF:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
992 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
993 struct video_mbuf vm;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
994
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
995 vm.size = loops[nr]->buflength * num_buffers;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
996 vm.frames = num_buffers;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
997 for (i = 0; i < vm.frames; i++)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
998 vm.offsets[i] = i * loops[nr]->buflength;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
999
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1000 if (copy_to_user((void*)arg, &vm, sizeof(vm)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1001 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1002
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1003 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1004 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1005 /* Grab frames */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1006 case VIDIOCMCAPTURE:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1007 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1008 struct video_mmap vm;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1009
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1010 if (ptr->in)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1011 return -EINVAL;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1012
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1013 if (!loops[nr]->buffer)
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1014 return -EINVAL;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1015
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1016 if (copy_from_user(&vm, (void*)arg, sizeof(vm)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1017 return -EFAULT;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1018
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1019 if (vm.format != loops[nr]->palette)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1020 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1021
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1022 if (vm.frame > num_buffers)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1023 return -EINVAL;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1024
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1025 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1026 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1027 /* Sync with mmap grabbing */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1028 case VIDIOCSYNC:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1029 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1030 int frame;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1031 unsigned long fw;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1032
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1033 if (copy_from_user((void *)&frame, (void*)arg, sizeof(int)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1034 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1035
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1036 if (ptr->in)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1037 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1038
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1039 if (!loops[nr]->buffer)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1040 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1041
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1042 /* Ok, everything should be alright since the program
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1043 should have called VIDIOMCAPTURE and we are ready to
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1044 do the 'capturing' */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1045 //if (frame > 1)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1046 if (frame > num_buffers-1)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1047 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1048
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1049 loops[nr]->frame = frame;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1050 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1051 fw = loops[nr]->frameswrite;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1052 wait_event_interruptible(loops[nr]->wait, fw != loops[nr]->frameswrite);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1053 #else
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1054 interruptible_sleep_on(&loops[nr]->wait);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1055 #endif
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1056 if (!loops[nr]->buffer) /* possibly released during sleep */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1057 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1058
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1059 loops[nr]->framesread++;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1060
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1061 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1062 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1063 /* Get attached units */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1064 case VIDIOCGUNIT:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1065 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1066 struct video_unit vu;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1067
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1068 if (ptr->in)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1069 vu.video = loops[nr]->vloopout->minor;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1070 else
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1071 vu.video = loops[nr]->vloopin->minor;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1072
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1073 vu.vbi = VIDEO_NO_UNIT;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1074 vu.radio = VIDEO_NO_UNIT;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1075 vu.audio = VIDEO_NO_UNIT;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1076 vu.teletext = VIDEO_NO_UNIT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1077
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1078 if (copy_to_user((void*)arg, &vu, sizeof(vu)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1079 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1080
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1081 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1082 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1083 /* Get frame buffer */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1084 case VIDIOCGFBUF:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1085 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1086 struct video_buffer vb;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1087
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1088 memset(&vb, 0, sizeof(vb));
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1089 vb.base = NULL;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1090
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1091 if (copy_to_user((void *)arg, (void *)&vb, sizeof(vb)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1092 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1093
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1094 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1095 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1096 /* Start, end capture */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1097 case VIDIOCCAPTURE:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1098 {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1099 int start;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1100
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1101 if (copy_from_user(&start, (void*)arg, sizeof(int)))
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1102 return -EFAULT;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1103
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1104 if (start) {
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1105 info ("Video loopback %d Capture started", nr);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1106 } else {
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1107 info ("Video loopback %d Capture stopped", nr);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1108 }
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1109
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1110 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1111 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1112 case VIDIOCGFREQ:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1113 case VIDIOCSFREQ:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1114 case VIDIOCGAUDIO:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1115 case VIDIOCSAUDIO:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1116 return -EINVAL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1117 case VIDIOCKEY:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1118 return 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1119 default:
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1120 return -ENOTTY;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1121 //return -ENOIOCTLCMD;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1122 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1123 return 0;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1124 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1125
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1126 static unsigned int vloopback_poll(struct file *f, struct poll_table_struct *wait)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1127 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1128 struct video_device *loopdev = video_devdata(f);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1129 priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1130 //priv_ptr ptr = (priv_ptr)video_get_drvdata(loopdev);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1131 int nr = ptr->pipenr;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1132
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1133 if (debug > LOG_NODEBUG)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1134 info("Video loopback %d", nr);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1135
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1136 if (loopdev == NULL)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1137 return -EFAULT;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1138
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1139 if (!ptr->in)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1140 return 0;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1141
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1142 if (loops[nr]->ioctlnr != -1) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1143 if (loops[nr]->zerocopy) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1144 return (POLLIN | POLLPRI | POLLOUT | POLLRDNORM);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1145 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1146 return (POLLOUT);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1147 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1148 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1149 return 0;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1150 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1151
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
1152 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
1153 static const struct file_operations fileops_template =
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
1154 #else
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
1155 static const struct v4l2_file_operations fileops_template =
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
1156 #endif
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1157 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1158 owner: THIS_MODULE,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1159 open: vloopback_open,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1160 release: vloopback_release,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1161 read: vloopback_read,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1162 write: vloopback_write,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1163 poll: vloopback_poll,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1164 ioctl: vloopback_ioctl,
14
647e63ddab46 Apply patch with some fix from Peter Holik to allow compile and work with kernel 2.6.29
AngelCarpintero
parents: 11
diff changeset
1165 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1166 compat_ioctl: v4l_compat_ioctl32,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1167 #endif
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1168 mmap: vloopback_mmap,
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1169 };
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1170
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1171 static struct video_device vloopback_template =
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1172 {
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1173 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1174 owner: THIS_MODULE,
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1175 type: VID_TYPE_CAPTURE,
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1176 #endif
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1177 minor: -1,
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1178 name: "Video Loopback",
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1179 fops: &fileops_template,
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1180 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1181 release: video_device_release,
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1182 #endif
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1183 };
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1184
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1185 static int create_pipe(int nr)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1186 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1187 int minor_in, minor_out , ret;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1188
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1189 if (debug > LOG_NODEBUG)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1190 info("Video loopback %d", nr);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1191
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1192 if (dev_offset == -1) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1193 minor_in = minor_out = -1; /* autoassign */
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1194 } else {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1195 minor_in = 2 * nr + dev_offset;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1196 minor_out = 2 * nr + 1 + dev_offset;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1197 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1198 /* allocate space for this pipe */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1199 loops[nr]= kmalloc(sizeof(struct vloopback_pipe), GFP_KERNEL);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1200
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1201 if (!loops[nr])
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1202 return -ENOMEM;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1203 /* set up a new video device plus our private area */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1204 loops[nr]->vloopin = video_device_alloc();
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1205
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1206 if (loops[nr]->vloopin == NULL)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1207 return -ENOMEM;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1208 *loops[nr]->vloopin = vloopback_template;
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1209
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1210 loops[nr]->vloopin->vd_private_data = kmalloc(sizeof(struct vloopback_private),
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1211 GFP_KERNEL);
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1212
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1213 if (loops[nr]->vloopin->vd_private_data == NULL) {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1214 kfree(loops[nr]->vloopin);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1215 return -ENOMEM;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1216 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1217 /* repeat for the output device */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1218 loops[nr]->vloopout = video_device_alloc();
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1219
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1220 if (loops[nr]->vloopout == NULL) {
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1221 kfree(loops[nr]->vloopin->vd_private_data);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1222 kfree(loops[nr]->vloopin);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1223 return -ENOMEM;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1224 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1225 *loops[nr]->vloopout = vloopback_template;
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1226 loops[nr]->vloopout->vd_private_data = kmalloc(sizeof(struct vloopback_private),
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1227 GFP_KERNEL);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1228
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1229 if (loops[nr]->vloopout->vd_private_data == NULL) {
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1230 kfree(loops[nr]->vloopin->vd_private_data);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1231 kfree(loops[nr]->vloopin);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1232 kfree(loops[nr]->vloopout);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1233 return -ENOMEM;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1234 }
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1235
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1236 ((priv_ptr)loops[nr]->vloopin->vd_private_data)->pipenr = nr;
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1237 ((priv_ptr)loops[nr]->vloopout->vd_private_data)->pipenr = nr;
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1238 loops[nr]->invalid_ioctl = 0; /* tibit */
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1239 loops[nr]->buffer = NULL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1240 loops[nr]->width = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1241 loops[nr]->height = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1242 loops[nr]->palette = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1243 loops[nr]->frameswrite = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1244 loops[nr]->framesread = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1245 loops[nr]->framesdumped = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1246 loops[nr]->wopen = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1247 loops[nr]->ropen = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1248 loops[nr]->frame = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1249
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1250 ((priv_ptr)loops[nr]->vloopin->vd_private_data)->in = 1;
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1251 ((priv_ptr)loops[nr]->vloopout->vd_private_data)->in = 0;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1252 sprintf(loops[nr]->vloopin->name, "Video loopback %d input", nr);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1253 sprintf(loops[nr]->vloopout->name, "Video loopback %d output", nr);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1254
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1255 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1256 loops[nr]->vloopin->type = 0;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1257 loops[nr]->vloopout->type = VID_TYPE_CAPTURE;
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1258 #endif
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1259 loops[nr]->vloopout->minor = minor_out;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1260 loops[nr]->vloopin->minor = minor_in;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1261
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1262 init_waitqueue_head(&loops[nr]->wait);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1263 init_MUTEX(&loops[nr]->lock);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1264
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1265 ret = video_register_device(loops[nr]->vloopin, VFL_TYPE_GRABBER, minor_in);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1266
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1267 if ((ret == -1 ) || ( ret == -23 )) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1268 info("error registering device %s", loops[nr]->vloopin->name);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1269 kfree(loops[nr]->vloopin->vd_private_data);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1270 kfree(loops[nr]->vloopin);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1271 kfree(loops[nr]->vloopout->vd_private_data);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1272 kfree(loops[nr]->vloopout);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1273 kfree(loops[nr]);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1274 loops[nr] = NULL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1275 return ret;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1276 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1277
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1278 ret = video_register_device(loops[nr]->vloopout, VFL_TYPE_GRABBER, minor_out);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1279
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1280 if ((ret ==-1) || (ret == -23)) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1281 info("error registering device %s", loops[nr]->vloopout->name);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1282 kfree(loops[nr]->vloopin->vd_private_data);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1283 video_unregister_device(loops[nr]->vloopin);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1284 kfree(loops[nr]->vloopout->vd_private_data);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1285 kfree(loops[nr]->vloopout);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1286 kfree(loops[nr]);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1287 loops[nr] = NULL;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1288 return ret;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1289 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1290
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1291 loops[nr]->ioctldata = kmalloc(1024, GFP_KERNEL);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1292 loops[nr]->ioctlretdata = kmalloc(1024, GFP_KERNEL);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1293 return 0;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1294 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1295
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1296
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1297 /****************************************************************************
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1298 * init stuff
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1299 ****************************************************************************/
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1300
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1301
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1302 MODULE_AUTHOR("J.B. Vreeken (pe1rxq@amsat.org)");
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1303 MODULE_DESCRIPTION("Video4linux loopback device.");
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1304
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1305 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1306 module_param(pipes, int, 000);
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1307 #else
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1308 MODULE_PARM(pipes, "i");
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1309 #endif
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1310
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1311 MODULE_PARM_DESC(pipes, " Nr of pipes to create (each pipe uses two video devices)");
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1312
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1313 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1314 module_param(spares, int, 000);
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1315 #else
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1316 MODULE_PARM(spares, "i");
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1317 #endif
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1318
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1319 MODULE_PARM_DESC(spares, " Nr of spare pipes that should be created");
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1320
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1321 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1322 module_param(num_buffers, int, 000);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1323 #else
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1324 MODULE_PARM(num_buffers, "i");
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1325 #endif
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1326
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1327 MODULE_PARM_DESC(num_buffers, " Prefered numbers of internal buffers to map (default 2)");
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1328
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1329
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1330 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1331 module_param(dev_offset, int, 000);
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1332 #else
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1333 MODULE_PARM(dev_offset_param, "i");
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1334 #endif
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1335
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1336 MODULE_PARM_DESC(dev_offset, " Prefered offset for video device numbers");
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1337
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1338
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1339 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1340 module_param(debug, int, 000);
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1341 #else
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1342 MODULE_PARM(debug_param, "i");
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1343 #endif
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1344
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1345 MODULE_PARM_DESC(debug, " Enable module debug level 0-3 (by default 0)");
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1346
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1347 MODULE_LICENSE("GPL");
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1348 MODULE_VERSION( VLOOPBACK_VERSION );
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1349
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1350 static int __init vloopback_init(void)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1351 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1352 int i, ret;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1353
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1354 info("video4linux loopback driver v"VLOOPBACK_VERSION);
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1355
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1356 if (pipes == -1)
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1357 pipes = 1;
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1358
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1359 if (pipes > MAX_PIPES) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1360 pipes = MAX_PIPES;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1361 info("Nr of pipes is limited to: %d", MAX_PIPES);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1362 }
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1363
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1364 if (num_buffers < N_BUFFS) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1365 num_buffers = N_BUFFS;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1366 info("Nr of buffer set to default value %d", N_BUFFS);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1367 }
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1368
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1369 for (i = 0; i < pipes; i++) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1370
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1371 ret = create_pipe(i);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1372
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1373 if (ret == 0) {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1374 info("Loopback %d registered, input: video%d,"
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1375 " output: video%d",
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1376 i, loops[i]->vloopin->minor,
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1377 loops[i]->vloopout->minor);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1378 info("Loopback %d , Using %d buffers", i, num_buffers);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1379 nr_o_pipes = i + 1;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1380 } else {
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1381 return ret;
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1382 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1383 }
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1384 return 0;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1385 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1386
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1387 static void __exit cleanup_vloopback_module(void)
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1388 {
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1389 int i;
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1390
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1391 info("Unregistering video4linux loopback devices");
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1392
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1393 for (i = 0; i < nr_o_pipes; i++) {
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1394 if (loops[i]) {
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1395 kfree(loops[i]->vloopin->vd_private_data);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1396 video_unregister_device(loops[i]->vloopin);
11
b904131a3807 Allow to build with kernel 2.6.27.git and 2.6.28-rc9
AngelCarpintero
parents: 10
diff changeset
1397 kfree(loops[i]->vloopout->vd_private_data);
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1398 video_unregister_device(loops[i]->vloopout);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1399
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1400 if (loops[i]->buffer)
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1401 rvfree(loops[i]->buffer, loops[i]->buflength * num_buffers);
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1402
8
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1403 kfree(loops[i]->ioctldata);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1404 kfree(loops[i]->ioctlretdata);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1405 kfree(loops[i]);
80590d10a596 Added num of buffers as a module param, indent code using spaces instead of tabs
AngelCarpintero
parents: 7
diff changeset
1406 }
7
2fce9e157b8d Added some work around to work with kernel 2.6.27-rc3, added debug param.
AngelCarpintero
parents: 4
diff changeset
1407 }
0
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1408 }
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1409
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1410 module_init(vloopback_init);
5f21a4dddc0c Initial checkin
KennethLavrsen
parents:
diff changeset
1411 module_exit(cleanup_vloopback_module);