diff options
author | Luc Saillard <luc@saillard.org> | 2006-04-24 09:29:46 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-25 00:58:20 -0400 |
commit | 2b455db6d456ef2d44808a8377fd3bc832e08317 (patch) | |
tree | b7b7bcabd53f9bb58d7f69eb6d012735dacd31c7 /drivers/media/video/pwc/pwc-if.c | |
parent | d9e12f25cf538d103426946121d214dff332efbb (diff) |
V4L/DVB (3835): [PATCH] update pwc driver
Add v4l2 compatibility
Include the decompressor (legal problem has been resolv by Alan Cox)
Faster decoder and easier to maintain, optimize, ...
Can export to userland compressed stream
Support more cameras, lot of bugs are fixed.
Signed-off-by: Luc Saillard <luc@saillard.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pwc/pwc-if.c')
-rw-r--r-- | drivers/media/video/pwc/pwc-if.c | 1335 |
1 files changed, 560 insertions, 775 deletions
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index 41418294a32b..98059c8d6f69 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* Linux driver for Philips webcam | 1 | /* Linux driver for Philips webcam |
2 | USB and Video4Linux interface part. | 2 | USB and Video4Linux interface part. |
3 | (C) 1999-2004 Nemosoft Unv. | 3 | (C) 1999-2004 Nemosoft Unv. |
4 | (C) 2004 Luc Saillard (luc@saillard.org) | 4 | (C) 2004-2006 Luc Saillard (luc@saillard.org) |
5 | 5 | ||
6 | NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx | 6 | NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx |
7 | driver and thus may have bugs that are not present in the original version. | 7 | driver and thus may have bugs that are not present in the original version. |
@@ -62,18 +62,21 @@ | |||
62 | #include <linux/poll.h> | 62 | #include <linux/poll.h> |
63 | #include <linux/slab.h> | 63 | #include <linux/slab.h> |
64 | #include <linux/vmalloc.h> | 64 | #include <linux/vmalloc.h> |
65 | #include <linux/version.h> | ||
65 | #include <asm/io.h> | 66 | #include <asm/io.h> |
67 | #include <linux/moduleparam.h> | ||
66 | 68 | ||
67 | #include "pwc.h" | 69 | #include "pwc.h" |
68 | #include "pwc-ioctl.h" | ||
69 | #include "pwc-kiara.h" | 70 | #include "pwc-kiara.h" |
70 | #include "pwc-timon.h" | 71 | #include "pwc-timon.h" |
72 | #include "pwc-dec23.h" | ||
73 | #include "pwc-dec1.h" | ||
71 | #include "pwc-uncompress.h" | 74 | #include "pwc-uncompress.h" |
72 | 75 | ||
73 | /* Function prototypes and driver templates */ | 76 | /* Function prototypes and driver templates */ |
74 | 77 | ||
75 | /* hotplug device table support */ | 78 | /* hotplug device table support */ |
76 | static struct usb_device_id pwc_device_table [] = { | 79 | static const struct usb_device_id pwc_device_table [] = { |
77 | { USB_DEVICE(0x0471, 0x0302) }, /* Philips models */ | 80 | { USB_DEVICE(0x0471, 0x0302) }, /* Philips models */ |
78 | { USB_DEVICE(0x0471, 0x0303) }, | 81 | { USB_DEVICE(0x0471, 0x0303) }, |
79 | { USB_DEVICE(0x0471, 0x0304) }, | 82 | { USB_DEVICE(0x0471, 0x0304) }, |
@@ -81,9 +84,10 @@ static struct usb_device_id pwc_device_table [] = { | |||
81 | { USB_DEVICE(0x0471, 0x0308) }, | 84 | { USB_DEVICE(0x0471, 0x0308) }, |
82 | { USB_DEVICE(0x0471, 0x030C) }, | 85 | { USB_DEVICE(0x0471, 0x030C) }, |
83 | { USB_DEVICE(0x0471, 0x0310) }, | 86 | { USB_DEVICE(0x0471, 0x0310) }, |
84 | { USB_DEVICE(0x0471, 0x0311) }, | 87 | { USB_DEVICE(0x0471, 0x0311) }, /* Philips ToUcam PRO II */ |
85 | { USB_DEVICE(0x0471, 0x0312) }, | 88 | { USB_DEVICE(0x0471, 0x0312) }, |
86 | { USB_DEVICE(0x0471, 0x0313) }, /* the 'new' 720K */ | 89 | { USB_DEVICE(0x0471, 0x0313) }, /* the 'new' 720K */ |
90 | { USB_DEVICE(0x0471, 0x0329) }, /* Philips SPC 900NC PC Camera */ | ||
87 | { USB_DEVICE(0x069A, 0x0001) }, /* Askey */ | 91 | { USB_DEVICE(0x069A, 0x0001) }, /* Askey */ |
88 | { USB_DEVICE(0x046D, 0x08B0) }, /* Logitech QuickCam Pro 3000 */ | 92 | { USB_DEVICE(0x046D, 0x08B0) }, /* Logitech QuickCam Pro 3000 */ |
89 | { USB_DEVICE(0x046D, 0x08B1) }, /* Logitech QuickCam Notebook Pro */ | 93 | { USB_DEVICE(0x046D, 0x08B1) }, /* Logitech QuickCam Notebook Pro */ |
@@ -94,8 +98,9 @@ static struct usb_device_id pwc_device_table [] = { | |||
94 | { USB_DEVICE(0x046D, 0x08B6) }, /* Logitech (reserved) */ | 98 | { USB_DEVICE(0x046D, 0x08B6) }, /* Logitech (reserved) */ |
95 | { USB_DEVICE(0x046D, 0x08B7) }, /* Logitech (reserved) */ | 99 | { USB_DEVICE(0x046D, 0x08B7) }, /* Logitech (reserved) */ |
96 | { USB_DEVICE(0x046D, 0x08B8) }, /* Logitech (reserved) */ | 100 | { USB_DEVICE(0x046D, 0x08B8) }, /* Logitech (reserved) */ |
97 | { USB_DEVICE(0x055D, 0x9000) }, /* Samsung */ | 101 | { USB_DEVICE(0x055D, 0x9000) }, /* Samsung MPC-C10 */ |
98 | { USB_DEVICE(0x055D, 0x9001) }, | 102 | { USB_DEVICE(0x055D, 0x9001) }, /* Samsung MPC-C30 */ |
103 | { USB_DEVICE(0x055D, 0x9002) }, /* Samsung SNC-35E (Ver3.0) */ | ||
99 | { USB_DEVICE(0x041E, 0x400C) }, /* Creative Webcam 5 */ | 104 | { USB_DEVICE(0x041E, 0x400C) }, /* Creative Webcam 5 */ |
100 | { USB_DEVICE(0x041E, 0x4011) }, /* Creative Webcam Pro Ex */ | 105 | { USB_DEVICE(0x041E, 0x4011) }, /* Creative Webcam Pro Ex */ |
101 | { USB_DEVICE(0x04CC, 0x8116) }, /* Afina Eye */ | 106 | { USB_DEVICE(0x04CC, 0x8116) }, /* Afina Eye */ |
@@ -122,11 +127,13 @@ static struct usb_driver pwc_driver = { | |||
122 | static int default_size = PSZ_QCIF; | 127 | static int default_size = PSZ_QCIF; |
123 | static int default_fps = 10; | 128 | static int default_fps = 10; |
124 | static int default_fbufs = 3; /* Default number of frame buffers */ | 129 | static int default_fbufs = 3; /* Default number of frame buffers */ |
125 | static int default_mbufs = 2; /* Default number of mmap() buffers */ | 130 | int pwc_mbufs = 2; /* Default number of mmap() buffers */ |
126 | int pwc_trace = TRACE_MODULE | TRACE_FLOW | TRACE_PWCX; | 131 | #if CONFIG_PWC_DEBUG |
132 | int pwc_trace = PWC_DEBUG_LEVEL; | ||
133 | #endif | ||
127 | static int power_save = 0; | 134 | static int power_save = 0; |
128 | static int led_on = 100, led_off = 0; /* defaults to LED that is on while in use */ | 135 | static int led_on = 100, led_off = 0; /* defaults to LED that is on while in use */ |
129 | static int pwc_preferred_compression = 2; /* 0..3 = uncompressed..high */ | 136 | int pwc_preferred_compression = 1; /* 0..3 = uncompressed..high */ |
130 | static struct { | 137 | static struct { |
131 | int type; | 138 | int type; |
132 | char serial_number[30]; | 139 | char serial_number[30]; |
@@ -138,7 +145,7 @@ static struct { | |||
138 | 145 | ||
139 | static int pwc_video_open(struct inode *inode, struct file *file); | 146 | static int pwc_video_open(struct inode *inode, struct file *file); |
140 | static int pwc_video_close(struct inode *inode, struct file *file); | 147 | static int pwc_video_close(struct inode *inode, struct file *file); |
141 | static ssize_t pwc_video_read(struct file *file, char __user * buf, | 148 | static ssize_t pwc_video_read(struct file *file, char __user *buf, |
142 | size_t count, loff_t *ppos); | 149 | size_t count, loff_t *ppos); |
143 | static unsigned int pwc_video_poll(struct file *file, poll_table *wait); | 150 | static unsigned int pwc_video_poll(struct file *file, poll_table *wait); |
144 | static int pwc_video_ioctl(struct inode *inode, struct file *file, | 151 | static int pwc_video_ioctl(struct inode *inode, struct file *file, |
@@ -153,7 +160,6 @@ static struct file_operations pwc_fops = { | |||
153 | .poll = pwc_video_poll, | 160 | .poll = pwc_video_poll, |
154 | .mmap = pwc_video_mmap, | 161 | .mmap = pwc_video_mmap, |
155 | .ioctl = pwc_video_ioctl, | 162 | .ioctl = pwc_video_ioctl, |
156 | .compat_ioctl = v4l_compat_ioctl32, | ||
157 | .llseek = no_llseek, | 163 | .llseek = no_llseek, |
158 | }; | 164 | }; |
159 | static struct video_device pwc_template = { | 165 | static struct video_device pwc_template = { |
@@ -203,52 +209,44 @@ static struct video_device pwc_template = { | |||
203 | /* Here we want the physical address of the memory. | 209 | /* Here we want the physical address of the memory. |
204 | * This is used when initializing the contents of the area. | 210 | * This is used when initializing the contents of the area. |
205 | */ | 211 | */ |
206 | static inline unsigned long kvirt_to_pa(unsigned long adr) | ||
207 | { | ||
208 | unsigned long kva, ret; | ||
209 | 212 | ||
210 | kva = (unsigned long) page_address(vmalloc_to_page((void *)adr)); | ||
211 | kva |= adr & (PAGE_SIZE-1); /* restore the offset */ | ||
212 | ret = __pa(kva); | ||
213 | return ret; | ||
214 | } | ||
215 | 213 | ||
216 | static void * rvmalloc(unsigned long size) | 214 | |
215 | static void *pwc_rvmalloc(unsigned long size) | ||
217 | { | 216 | { |
218 | void * mem; | 217 | void * mem; |
219 | unsigned long adr; | 218 | unsigned long adr; |
220 | 219 | ||
221 | size=PAGE_ALIGN(size); | ||
222 | mem=vmalloc_32(size); | 220 | mem=vmalloc_32(size); |
223 | if (mem) | 221 | if (!mem) |
224 | { | 222 | return NULL; |
225 | memset(mem, 0, size); /* Clear the ram out, no junk to the user */ | 223 | |
226 | adr=(unsigned long) mem; | 224 | memset(mem, 0, size); /* Clear the ram out, no junk to the user */ |
227 | while (size > 0) | 225 | adr=(unsigned long) mem; |
228 | { | 226 | while (size > 0) |
229 | SetPageReserved(vmalloc_to_page((void *)adr)); | 227 | { |
230 | adr+=PAGE_SIZE; | 228 | SetPageReserved(vmalloc_to_page((void *)adr)); |
231 | size-=PAGE_SIZE; | 229 | adr += PAGE_SIZE; |
232 | } | 230 | size -= PAGE_SIZE; |
233 | } | 231 | } |
234 | return mem; | 232 | return mem; |
235 | } | 233 | } |
236 | 234 | ||
237 | static void rvfree(void * mem, unsigned long size) | 235 | static void pwc_rvfree(void * mem, unsigned long size) |
238 | { | 236 | { |
239 | unsigned long adr; | 237 | unsigned long adr; |
240 | 238 | ||
241 | if (mem) | 239 | if (!mem) |
242 | { | 240 | return; |
243 | adr=(unsigned long) mem; | 241 | |
244 | while ((long) size > 0) | 242 | adr=(unsigned long) mem; |
245 | { | 243 | while ((long) size > 0) |
246 | ClearPageReserved(vmalloc_to_page((void *)adr)); | 244 | { |
247 | adr+=PAGE_SIZE; | 245 | ClearPageReserved(vmalloc_to_page((void *)adr)); |
248 | size-=PAGE_SIZE; | 246 | adr += PAGE_SIZE; |
249 | } | 247 | size -= PAGE_SIZE; |
250 | vfree(mem); | 248 | } |
251 | } | 249 | vfree(mem); |
252 | } | 250 | } |
253 | 251 | ||
254 | 252 | ||
@@ -256,100 +254,83 @@ static void rvfree(void * mem, unsigned long size) | |||
256 | 254 | ||
257 | static int pwc_allocate_buffers(struct pwc_device *pdev) | 255 | static int pwc_allocate_buffers(struct pwc_device *pdev) |
258 | { | 256 | { |
259 | int i; | 257 | int i, err; |
260 | void *kbuf; | 258 | void *kbuf; |
261 | 259 | ||
262 | Trace(TRACE_MEMORY, ">> pwc_allocate_buffers(pdev = 0x%p)\n", pdev); | 260 | PWC_DEBUG_MEMORY(">> pwc_allocate_buffers(pdev = 0x%p)\n", pdev); |
263 | 261 | ||
264 | if (pdev == NULL) | 262 | if (pdev == NULL) |
265 | return -ENXIO; | 263 | return -ENXIO; |
266 | 264 | ||
267 | #ifdef PWC_MAGIC | 265 | /* Allocate Isochronuous pipe buffers */ |
268 | if (pdev->magic != PWC_MAGIC) { | ||
269 | Err("allocate_buffers(): magic failed.\n"); | ||
270 | return -ENXIO; | ||
271 | } | ||
272 | #endif | ||
273 | /* Allocate Isochronous pipe buffers */ | ||
274 | for (i = 0; i < MAX_ISO_BUFS; i++) { | 266 | for (i = 0; i < MAX_ISO_BUFS; i++) { |
275 | if (pdev->sbuf[i].data == NULL) { | 267 | if (pdev->sbuf[i].data == NULL) { |
276 | kbuf = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL); | 268 | kbuf = kzalloc(ISO_BUFFER_SIZE, GFP_KERNEL); |
277 | if (kbuf == NULL) { | 269 | if (kbuf == NULL) { |
278 | Err("Failed to allocate iso buffer %d.\n", i); | 270 | PWC_ERROR("Failed to allocate iso buffer %d.\n", i); |
279 | return -ENOMEM; | 271 | return -ENOMEM; |
280 | } | 272 | } |
281 | Trace(TRACE_MEMORY, "Allocated iso buffer at %p.\n", kbuf); | 273 | PWC_DEBUG_MEMORY("Allocated iso buffer at %p.\n", kbuf); |
282 | pdev->sbuf[i].data = kbuf; | 274 | pdev->sbuf[i].data = kbuf; |
283 | memset(kbuf, 0, ISO_BUFFER_SIZE); | ||
284 | } | 275 | } |
285 | } | 276 | } |
286 | 277 | ||
287 | /* Allocate frame buffer structure */ | 278 | /* Allocate frame buffer structure */ |
288 | if (pdev->fbuf == NULL) { | 279 | if (pdev->fbuf == NULL) { |
289 | kbuf = kmalloc(default_fbufs * sizeof(struct pwc_frame_buf), GFP_KERNEL); | 280 | kbuf = kzalloc(default_fbufs * sizeof(struct pwc_frame_buf), GFP_KERNEL); |
290 | if (kbuf == NULL) { | 281 | if (kbuf == NULL) { |
291 | Err("Failed to allocate frame buffer structure.\n"); | 282 | PWC_ERROR("Failed to allocate frame buffer structure.\n"); |
292 | return -ENOMEM; | 283 | return -ENOMEM; |
293 | } | 284 | } |
294 | Trace(TRACE_MEMORY, "Allocated frame buffer structure at %p.\n", kbuf); | 285 | PWC_DEBUG_MEMORY("Allocated frame buffer structure at %p.\n", kbuf); |
295 | pdev->fbuf = kbuf; | 286 | pdev->fbuf = kbuf; |
296 | memset(kbuf, 0, default_fbufs * sizeof(struct pwc_frame_buf)); | ||
297 | } | 287 | } |
288 | |||
298 | /* create frame buffers, and make circular ring */ | 289 | /* create frame buffers, and make circular ring */ |
299 | for (i = 0; i < default_fbufs; i++) { | 290 | for (i = 0; i < default_fbufs; i++) { |
300 | if (pdev->fbuf[i].data == NULL) { | 291 | if (pdev->fbuf[i].data == NULL) { |
301 | kbuf = vmalloc(PWC_FRAME_SIZE); /* need vmalloc since frame buffer > 128K */ | 292 | kbuf = vmalloc(PWC_FRAME_SIZE); /* need vmalloc since frame buffer > 128K */ |
302 | if (kbuf == NULL) { | 293 | if (kbuf == NULL) { |
303 | Err("Failed to allocate frame buffer %d.\n", i); | 294 | PWC_ERROR("Failed to allocate frame buffer %d.\n", i); |
304 | return -ENOMEM; | 295 | return -ENOMEM; |
305 | } | 296 | } |
306 | Trace(TRACE_MEMORY, "Allocated frame buffer %d at %p.\n", i, kbuf); | 297 | PWC_DEBUG_MEMORY("Allocated frame buffer %d at %p.\n", i, kbuf); |
307 | pdev->fbuf[i].data = kbuf; | 298 | pdev->fbuf[i].data = kbuf; |
308 | memset(kbuf, 128, PWC_FRAME_SIZE); | 299 | memset(kbuf, 0, PWC_FRAME_SIZE); |
309 | } | 300 | } |
310 | } | 301 | } |
311 | 302 | ||
312 | /* Allocate decompressor table space */ | 303 | /* Allocate decompressor table space */ |
313 | kbuf = NULL; | 304 | if (DEVICE_USE_CODEC1(pdev->type)) |
314 | switch (pdev->type) | 305 | err = pwc_dec1_alloc(pdev); |
315 | { | 306 | else |
316 | case 675: | 307 | err = pwc_dec23_alloc(pdev); |
317 | case 680: | 308 | |
318 | case 690: | 309 | if (err) { |
319 | case 720: | 310 | PWC_ERROR("Failed to allocate decompress table.\n"); |
320 | case 730: | 311 | return err; |
321 | case 740: | 312 | } |
322 | case 750: | ||
323 | #if 0 | ||
324 | Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private)); | ||
325 | kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */ | ||
326 | break; | ||
327 | case 645: | ||
328 | case 646: | ||
329 | /* TODO & FIXME */ | ||
330 | kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); | ||
331 | break; | ||
332 | #endif | ||
333 | ; | ||
334 | } | ||
335 | pdev->decompress_data = kbuf; | ||
336 | 313 | ||
337 | /* Allocate image buffer; double buffer for mmap() */ | 314 | /* Allocate image buffer; double buffer for mmap() */ |
338 | kbuf = rvmalloc(default_mbufs * pdev->len_per_image); | 315 | kbuf = pwc_rvmalloc(pwc_mbufs * pdev->len_per_image); |
339 | if (kbuf == NULL) { | 316 | if (kbuf == NULL) { |
340 | Err("Failed to allocate image buffer(s). needed (%d)\n",default_mbufs * pdev->len_per_image); | 317 | PWC_ERROR("Failed to allocate image buffer(s). needed (%d)\n", |
318 | pwc_mbufs * pdev->len_per_image); | ||
341 | return -ENOMEM; | 319 | return -ENOMEM; |
342 | } | 320 | } |
343 | Trace(TRACE_MEMORY, "Allocated image buffer at %p.\n", kbuf); | 321 | PWC_DEBUG_MEMORY("Allocated image buffer at %p.\n", kbuf); |
344 | pdev->image_data = kbuf; | 322 | pdev->image_data = kbuf; |
345 | for (i = 0; i < default_mbufs; i++) | 323 | for (i = 0; i < pwc_mbufs; i++) { |
346 | pdev->image_ptr[i] = kbuf + i * pdev->len_per_image; | 324 | pdev->images[i].offset = i * pdev->len_per_image; |
347 | for (; i < MAX_IMAGES; i++) | 325 | pdev->images[i].vma_use_count = 0; |
348 | pdev->image_ptr[i] = NULL; | 326 | } |
327 | for (; i < MAX_IMAGES; i++) { | ||
328 | pdev->images[i].offset = 0; | ||
329 | } | ||
349 | 330 | ||
350 | kbuf = NULL; | 331 | kbuf = NULL; |
351 | 332 | ||
352 | Trace(TRACE_MEMORY, "<< pwc_allocate_buffers()\n"); | 333 | PWC_DEBUG_MEMORY("<< pwc_allocate_buffers()\n"); |
353 | return 0; | 334 | return 0; |
354 | } | 335 | } |
355 | 336 | ||
@@ -357,21 +338,14 @@ static void pwc_free_buffers(struct pwc_device *pdev) | |||
357 | { | 338 | { |
358 | int i; | 339 | int i; |
359 | 340 | ||
360 | Trace(TRACE_MEMORY, "Entering free_buffers(%p).\n", pdev); | 341 | PWC_DEBUG_MEMORY("Entering free_buffers(%p).\n", pdev); |
361 | 342 | ||
362 | if (pdev == NULL) | 343 | if (pdev == NULL) |
363 | return; | 344 | return; |
364 | #ifdef PWC_MAGIC | ||
365 | if (pdev->magic != PWC_MAGIC) { | ||
366 | Err("free_buffers(): magic failed.\n"); | ||
367 | return; | ||
368 | } | ||
369 | #endif | ||
370 | |||
371 | /* Release Iso-pipe buffers */ | 345 | /* Release Iso-pipe buffers */ |
372 | for (i = 0; i < MAX_ISO_BUFS; i++) | 346 | for (i = 0; i < MAX_ISO_BUFS; i++) |
373 | if (pdev->sbuf[i].data != NULL) { | 347 | if (pdev->sbuf[i].data != NULL) { |
374 | Trace(TRACE_MEMORY, "Freeing ISO buffer at %p.\n", pdev->sbuf[i].data); | 348 | PWC_DEBUG_MEMORY("Freeing ISO buffer at %p.\n", pdev->sbuf[i].data); |
375 | kfree(pdev->sbuf[i].data); | 349 | kfree(pdev->sbuf[i].data); |
376 | pdev->sbuf[i].data = NULL; | 350 | pdev->sbuf[i].data = NULL; |
377 | } | 351 | } |
@@ -380,7 +354,7 @@ static void pwc_free_buffers(struct pwc_device *pdev) | |||
380 | if (pdev->fbuf != NULL) { | 354 | if (pdev->fbuf != NULL) { |
381 | for (i = 0; i < default_fbufs; i++) { | 355 | for (i = 0; i < default_fbufs; i++) { |
382 | if (pdev->fbuf[i].data != NULL) { | 356 | if (pdev->fbuf[i].data != NULL) { |
383 | Trace(TRACE_MEMORY, "Freeing frame buffer %d at %p.\n", i, pdev->fbuf[i].data); | 357 | PWC_DEBUG_MEMORY("Freeing frame buffer %d at %p.\n", i, pdev->fbuf[i].data); |
384 | vfree(pdev->fbuf[i].data); | 358 | vfree(pdev->fbuf[i].data); |
385 | pdev->fbuf[i].data = NULL; | 359 | pdev->fbuf[i].data = NULL; |
386 | } | 360 | } |
@@ -391,20 +365,19 @@ static void pwc_free_buffers(struct pwc_device *pdev) | |||
391 | 365 | ||
392 | /* Intermediate decompression buffer & tables */ | 366 | /* Intermediate decompression buffer & tables */ |
393 | if (pdev->decompress_data != NULL) { | 367 | if (pdev->decompress_data != NULL) { |
394 | Trace(TRACE_MEMORY, "Freeing decompression buffer at %p.\n", pdev->decompress_data); | 368 | PWC_DEBUG_MEMORY("Freeing decompression buffer at %p.\n", pdev->decompress_data); |
395 | kfree(pdev->decompress_data); | 369 | kfree(pdev->decompress_data); |
396 | pdev->decompress_data = NULL; | 370 | pdev->decompress_data = NULL; |
397 | } | 371 | } |
398 | pdev->decompressor = NULL; | ||
399 | 372 | ||
400 | /* Release image buffers */ | 373 | /* Release image buffers */ |
401 | if (pdev->image_data != NULL) { | 374 | if (pdev->image_data != NULL) { |
402 | Trace(TRACE_MEMORY, "Freeing image buffer at %p.\n", pdev->image_data); | 375 | PWC_DEBUG_MEMORY("Freeing image buffer at %p.\n", pdev->image_data); |
403 | rvfree(pdev->image_data, default_mbufs * pdev->len_per_image); | 376 | pwc_rvfree(pdev->image_data, pwc_mbufs * pdev->len_per_image); |
404 | } | 377 | } |
405 | pdev->image_data = NULL; | 378 | pdev->image_data = NULL; |
406 | 379 | ||
407 | Trace(TRACE_MEMORY, "Leaving free_buffers().\n"); | 380 | PWC_DEBUG_MEMORY("Leaving free_buffers().\n"); |
408 | } | 381 | } |
409 | 382 | ||
410 | /* The frame & image buffer mess. | 383 | /* The frame & image buffer mess. |
@@ -464,7 +437,7 @@ static void pwc_free_buffers(struct pwc_device *pdev) | |||
464 | /** | 437 | /** |
465 | \brief Find next frame buffer to fill. Take from empty or full list, whichever comes first. | 438 | \brief Find next frame buffer to fill. Take from empty or full list, whichever comes first. |
466 | */ | 439 | */ |
467 | static inline int pwc_next_fill_frame(struct pwc_device *pdev) | 440 | static int pwc_next_fill_frame(struct pwc_device *pdev) |
468 | { | 441 | { |
469 | int ret; | 442 | int ret; |
470 | unsigned long flags; | 443 | unsigned long flags; |
@@ -489,23 +462,17 @@ static inline int pwc_next_fill_frame(struct pwc_device *pdev) | |||
489 | } | 462 | } |
490 | else { | 463 | else { |
491 | /* Hmm. Take it from the full list */ | 464 | /* Hmm. Take it from the full list */ |
492 | #if PWC_DEBUG | ||
493 | /* sanity check */ | 465 | /* sanity check */ |
494 | if (pdev->full_frames == NULL) { | 466 | if (pdev->full_frames == NULL) { |
495 | Err("Neither empty or full frames available!\n"); | 467 | PWC_ERROR("Neither empty or full frames available!\n"); |
496 | spin_unlock_irqrestore(&pdev->ptrlock, flags); | 468 | spin_unlock_irqrestore(&pdev->ptrlock, flags); |
497 | return -EINVAL; | 469 | return -EINVAL; |
498 | } | 470 | } |
499 | #endif | ||
500 | pdev->fill_frame = pdev->full_frames; | 471 | pdev->fill_frame = pdev->full_frames; |
501 | pdev->full_frames = pdev->full_frames->next; | 472 | pdev->full_frames = pdev->full_frames->next; |
502 | ret = 1; | 473 | ret = 1; |
503 | } | 474 | } |
504 | pdev->fill_frame->next = NULL; | 475 | pdev->fill_frame->next = NULL; |
505 | #if PWC_DEBUG | ||
506 | Trace(TRACE_SEQUENCE, "Assigning sequence number %d.\n", pdev->sequence); | ||
507 | pdev->fill_frame->sequence = pdev->sequence++; | ||
508 | #endif | ||
509 | spin_unlock_irqrestore(&pdev->ptrlock, flags); | 476 | spin_unlock_irqrestore(&pdev->ptrlock, flags); |
510 | return ret; | 477 | return ret; |
511 | } | 478 | } |
@@ -521,6 +488,8 @@ static void pwc_reset_buffers(struct pwc_device *pdev) | |||
521 | int i; | 488 | int i; |
522 | unsigned long flags; | 489 | unsigned long flags; |
523 | 490 | ||
491 | PWC_DEBUG_MEMORY(">> %s __enter__\n", __FUNCTION__); | ||
492 | |||
524 | spin_lock_irqsave(&pdev->ptrlock, flags); | 493 | spin_lock_irqsave(&pdev->ptrlock, flags); |
525 | pdev->full_frames = NULL; | 494 | pdev->full_frames = NULL; |
526 | pdev->full_frames_tail = NULL; | 495 | pdev->full_frames_tail = NULL; |
@@ -540,13 +509,15 @@ static void pwc_reset_buffers(struct pwc_device *pdev) | |||
540 | pdev->image_read_pos = 0; | 509 | pdev->image_read_pos = 0; |
541 | pdev->fill_image = 0; | 510 | pdev->fill_image = 0; |
542 | spin_unlock_irqrestore(&pdev->ptrlock, flags); | 511 | spin_unlock_irqrestore(&pdev->ptrlock, flags); |
512 | |||
513 | PWC_DEBUG_MEMORY("<< %s __leaving__\n", __FUNCTION__); | ||
543 | } | 514 | } |
544 | 515 | ||
545 | 516 | ||
546 | /** | 517 | /** |
547 | \brief Do all the handling for getting one frame: get pointer, decompress, advance pointers. | 518 | \brief Do all the handling for getting one frame: get pointer, decompress, advance pointers. |
548 | */ | 519 | */ |
549 | static int pwc_handle_frame(struct pwc_device *pdev) | 520 | int pwc_handle_frame(struct pwc_device *pdev) |
550 | { | 521 | { |
551 | int ret = 0; | 522 | int ret = 0; |
552 | unsigned long flags; | 523 | unsigned long flags; |
@@ -556,41 +527,40 @@ static int pwc_handle_frame(struct pwc_device *pdev) | |||
556 | we can release the lock after this without problems */ | 527 | we can release the lock after this without problems */ |
557 | if (pdev->read_frame != NULL) { | 528 | if (pdev->read_frame != NULL) { |
558 | /* This can't theoretically happen */ | 529 | /* This can't theoretically happen */ |
559 | Err("Huh? Read frame still in use?\n"); | 530 | PWC_ERROR("Huh? Read frame still in use?\n"); |
531 | spin_unlock_irqrestore(&pdev->ptrlock, flags); | ||
532 | return ret; | ||
533 | } | ||
534 | |||
535 | |||
536 | if (pdev->full_frames == NULL) { | ||
537 | PWC_ERROR("Woops. No frames ready.\n"); | ||
560 | } | 538 | } |
561 | else { | 539 | else { |
562 | if (pdev->full_frames == NULL) { | 540 | pdev->read_frame = pdev->full_frames; |
563 | Err("Woops. No frames ready.\n"); | 541 | pdev->full_frames = pdev->full_frames->next; |
542 | pdev->read_frame->next = NULL; | ||
543 | } | ||
544 | |||
545 | if (pdev->read_frame != NULL) { | ||
546 | /* Decompression is a lenghty process, so it's outside of the lock. | ||
547 | This gives the isoc_handler the opportunity to fill more frames | ||
548 | in the mean time. | ||
549 | */ | ||
550 | spin_unlock_irqrestore(&pdev->ptrlock, flags); | ||
551 | ret = pwc_decompress(pdev); | ||
552 | spin_lock_irqsave(&pdev->ptrlock, flags); | ||
553 | |||
554 | /* We're done with read_buffer, tack it to the end of the empty buffer list */ | ||
555 | if (pdev->empty_frames == NULL) { | ||
556 | pdev->empty_frames = pdev->read_frame; | ||
557 | pdev->empty_frames_tail = pdev->empty_frames; | ||
564 | } | 558 | } |
565 | else { | 559 | else { |
566 | pdev->read_frame = pdev->full_frames; | 560 | pdev->empty_frames_tail->next = pdev->read_frame; |
567 | pdev->full_frames = pdev->full_frames->next; | 561 | pdev->empty_frames_tail = pdev->read_frame; |
568 | pdev->read_frame->next = NULL; | ||
569 | } | ||
570 | |||
571 | if (pdev->read_frame != NULL) { | ||
572 | #if PWC_DEBUG | ||
573 | Trace(TRACE_SEQUENCE, "Decompressing frame %d\n", pdev->read_frame->sequence); | ||
574 | #endif | ||
575 | /* Decompression is a lenghty process, so it's outside of the lock. | ||
576 | This gives the isoc_handler the opportunity to fill more frames | ||
577 | in the mean time. | ||
578 | */ | ||
579 | spin_unlock_irqrestore(&pdev->ptrlock, flags); | ||
580 | ret = pwc_decompress(pdev); | ||
581 | spin_lock_irqsave(&pdev->ptrlock, flags); | ||
582 | |||
583 | /* We're done with read_buffer, tack it to the end of the empty buffer list */ | ||
584 | if (pdev->empty_frames == NULL) { | ||
585 | pdev->empty_frames = pdev->read_frame; | ||
586 | pdev->empty_frames_tail = pdev->empty_frames; | ||
587 | } | ||
588 | else { | ||
589 | pdev->empty_frames_tail->next = pdev->read_frame; | ||
590 | pdev->empty_frames_tail = pdev->read_frame; | ||
591 | } | ||
592 | pdev->read_frame = NULL; | ||
593 | } | 562 | } |
563 | pdev->read_frame = NULL; | ||
594 | } | 564 | } |
595 | spin_unlock_irqrestore(&pdev->ptrlock, flags); | 565 | spin_unlock_irqrestore(&pdev->ptrlock, flags); |
596 | return ret; | 566 | return ret; |
@@ -599,12 +569,114 @@ static int pwc_handle_frame(struct pwc_device *pdev) | |||
599 | /** | 569 | /** |
600 | \brief Advance pointers of image buffer (after each user request) | 570 | \brief Advance pointers of image buffer (after each user request) |
601 | */ | 571 | */ |
602 | static inline void pwc_next_image(struct pwc_device *pdev) | 572 | void pwc_next_image(struct pwc_device *pdev) |
603 | { | 573 | { |
604 | pdev->image_used[pdev->fill_image] = 0; | 574 | pdev->image_used[pdev->fill_image] = 0; |
605 | pdev->fill_image = (pdev->fill_image + 1) % default_mbufs; | 575 | pdev->fill_image = (pdev->fill_image + 1) % pwc_mbufs; |
606 | } | 576 | } |
607 | 577 | ||
578 | /** | ||
579 | * Print debug information when a frame is discarded because all of our buffer | ||
580 | * is full | ||
581 | */ | ||
582 | static void pwc_frame_dumped(struct pwc_device *pdev) | ||
583 | { | ||
584 | pdev->vframes_dumped++; | ||
585 | if (pdev->vframe_count < FRAME_LOWMARK) | ||
586 | return; | ||
587 | |||
588 | if (pdev->vframes_dumped < 20) | ||
589 | PWC_DEBUG_FLOW("Dumping frame %d\n", pdev->vframe_count); | ||
590 | else if (pdev->vframes_dumped == 20) | ||
591 | PWC_DEBUG_FLOW("Dumping frame %d (last message)\n", | ||
592 | pdev->vframe_count); | ||
593 | } | ||
594 | |||
595 | static int pwc_rcv_short_packet(struct pwc_device *pdev, const struct pwc_frame_buf *fbuf) | ||
596 | { | ||
597 | int awake = 0; | ||
598 | |||
599 | /* The ToUCam Fun CMOS sensor causes the firmware to send 2 or 3 bogus | ||
600 | frames on the USB wire after an exposure change. This conditition is | ||
601 | however detected in the cam and a bit is set in the header. | ||
602 | */ | ||
603 | if (pdev->type == 730) { | ||
604 | unsigned char *ptr = (unsigned char *)fbuf->data; | ||
605 | |||
606 | if (ptr[1] == 1 && ptr[0] & 0x10) { | ||
607 | PWC_TRACE("Hyundai CMOS sensor bug. Dropping frame.\n"); | ||
608 | pdev->drop_frames += 2; | ||
609 | pdev->vframes_error++; | ||
610 | } | ||
611 | if ((ptr[0] ^ pdev->vmirror) & 0x01) { | ||
612 | if (ptr[0] & 0x01) { | ||
613 | pdev->snapshot_button_status = 1; | ||
614 | PWC_TRACE("Snapshot button pressed.\n"); | ||
615 | } | ||
616 | else { | ||
617 | PWC_TRACE("Snapshot button released.\n"); | ||
618 | } | ||
619 | } | ||
620 | if ((ptr[0] ^ pdev->vmirror) & 0x02) { | ||
621 | if (ptr[0] & 0x02) | ||
622 | PWC_TRACE("Image is mirrored.\n"); | ||
623 | else | ||
624 | PWC_TRACE("Image is normal.\n"); | ||
625 | } | ||
626 | pdev->vmirror = ptr[0] & 0x03; | ||
627 | /* Sometimes the trailer of the 730 is still sent as a 4 byte packet | ||
628 | after a short frame; this condition is filtered out specifically. A 4 byte | ||
629 | frame doesn't make sense anyway. | ||
630 | So we get either this sequence: | ||
631 | drop_bit set -> 4 byte frame -> short frame -> good frame | ||
632 | Or this one: | ||
633 | drop_bit set -> short frame -> good frame | ||
634 | So we drop either 3 or 2 frames in all! | ||
635 | */ | ||
636 | if (fbuf->filled == 4) | ||
637 | pdev->drop_frames++; | ||
638 | } | ||
639 | else if (pdev->type == 740 || pdev->type == 720) { | ||
640 | unsigned char *ptr = (unsigned char *)fbuf->data; | ||
641 | if ((ptr[0] ^ pdev->vmirror) & 0x01) { | ||
642 | if (ptr[0] & 0x01) { | ||
643 | pdev->snapshot_button_status = 1; | ||
644 | PWC_TRACE("Snapshot button pressed.\n"); | ||
645 | } | ||
646 | else | ||
647 | PWC_TRACE("Snapshot button released.\n"); | ||
648 | } | ||
649 | pdev->vmirror = ptr[0] & 0x03; | ||
650 | } | ||
651 | |||
652 | /* In case we were instructed to drop the frame, do so silently. | ||
653 | The buffer pointers are not updated either (but the counters are reset below). | ||
654 | */ | ||
655 | if (pdev->drop_frames > 0) | ||
656 | pdev->drop_frames--; | ||
657 | else { | ||
658 | /* Check for underflow first */ | ||
659 | if (fbuf->filled < pdev->frame_total_size) { | ||
660 | PWC_DEBUG_FLOW("Frame buffer underflow (%d bytes);" | ||
661 | " discarded.\n", fbuf->filled); | ||
662 | pdev->vframes_error++; | ||
663 | } | ||
664 | else { | ||
665 | /* Send only once per EOF */ | ||
666 | awake = 1; /* delay wake_ups */ | ||
667 | |||
668 | /* Find our next frame to fill. This will always succeed, since we | ||
669 | * nick a frame from either empty or full list, but if we had to | ||
670 | * take it from the full list, it means a frame got dropped. | ||
671 | */ | ||
672 | if (pwc_next_fill_frame(pdev)) | ||
673 | pwc_frame_dumped(pdev); | ||
674 | |||
675 | } | ||
676 | } /* !drop_frames */ | ||
677 | pdev->vframe_count++; | ||
678 | return awake; | ||
679 | } | ||
608 | 680 | ||
609 | /* This gets called for the Isochronous pipe (video). This is done in | 681 | /* This gets called for the Isochronous pipe (video). This is done in |
610 | * interrupt time, so it has to be fast, not crash, and not stall. Neat. | 682 | * interrupt time, so it has to be fast, not crash, and not stall. Neat. |
@@ -620,17 +692,12 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs) | |||
620 | awake = 0; | 692 | awake = 0; |
621 | pdev = (struct pwc_device *)urb->context; | 693 | pdev = (struct pwc_device *)urb->context; |
622 | if (pdev == NULL) { | 694 | if (pdev == NULL) { |
623 | Err("isoc_handler() called with NULL device?!\n"); | 695 | PWC_ERROR("isoc_handler() called with NULL device?!\n"); |
624 | return; | 696 | return; |
625 | } | 697 | } |
626 | #ifdef PWC_MAGIC | 698 | |
627 | if (pdev->magic != PWC_MAGIC) { | ||
628 | Err("isoc_handler() called with bad magic!\n"); | ||
629 | return; | ||
630 | } | ||
631 | #endif | ||
632 | if (urb->status == -ENOENT || urb->status == -ECONNRESET) { | 699 | if (urb->status == -ENOENT || urb->status == -ECONNRESET) { |
633 | Trace(TRACE_OPEN, "pwc_isoc_handler(): URB (%p) unlinked %ssynchronuously.\n", urb, urb->status == -ENOENT ? "" : "a"); | 700 | PWC_DEBUG_OPEN("URB (%p) unlinked %ssynchronuously.\n", urb, urb->status == -ENOENT ? "" : "a"); |
634 | return; | 701 | return; |
635 | } | 702 | } |
636 | if (urb->status != -EINPROGRESS && urb->status != 0) { | 703 | if (urb->status != -EINPROGRESS && urb->status != 0) { |
@@ -645,13 +712,13 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs) | |||
645 | case -EILSEQ: errmsg = "CRC/Timeout (could be anything)"; break; | 712 | case -EILSEQ: errmsg = "CRC/Timeout (could be anything)"; break; |
646 | case -ETIMEDOUT: errmsg = "NAK (device does not respond)"; break; | 713 | case -ETIMEDOUT: errmsg = "NAK (device does not respond)"; break; |
647 | } | 714 | } |
648 | Trace(TRACE_FLOW, "pwc_isoc_handler() called with status %d [%s].\n", urb->status, errmsg); | 715 | PWC_DEBUG_FLOW("pwc_isoc_handler() called with status %d [%s].\n", urb->status, errmsg); |
649 | /* Give up after a number of contiguous errors on the USB bus. | 716 | /* Give up after a number of contiguous errors on the USB bus. |
650 | Appearantly something is wrong so we simulate an unplug event. | 717 | Appearantly something is wrong so we simulate an unplug event. |
651 | */ | 718 | */ |
652 | if (++pdev->visoc_errors > MAX_ISOC_ERRORS) | 719 | if (++pdev->visoc_errors > MAX_ISOC_ERRORS) |
653 | { | 720 | { |
654 | Info("Too many ISOC errors, bailing out.\n"); | 721 | PWC_INFO("Too many ISOC errors, bailing out.\n"); |
655 | pdev->error_status = EIO; | 722 | pdev->error_status = EIO; |
656 | awake = 1; | 723 | awake = 1; |
657 | wake_up_interruptible(&pdev->frameq); | 724 | wake_up_interruptible(&pdev->frameq); |
@@ -661,7 +728,7 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs) | |||
661 | 728 | ||
662 | fbuf = pdev->fill_frame; | 729 | fbuf = pdev->fill_frame; |
663 | if (fbuf == NULL) { | 730 | if (fbuf == NULL) { |
664 | Err("pwc_isoc_handler without valid fill frame.\n"); | 731 | PWC_ERROR("pwc_isoc_handler without valid fill frame.\n"); |
665 | awake = 1; | 732 | awake = 1; |
666 | goto handler_end; | 733 | goto handler_end; |
667 | } | 734 | } |
@@ -688,7 +755,7 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs) | |||
688 | 755 | ||
689 | /* ...copy data to frame buffer, if possible */ | 756 | /* ...copy data to frame buffer, if possible */ |
690 | if (flen + fbuf->filled > pdev->frame_total_size) { | 757 | if (flen + fbuf->filled > pdev->frame_total_size) { |
691 | Trace(TRACE_FLOW, "Frame buffer overflow (flen = %d, frame_total_size = %d).\n", flen, pdev->frame_total_size); | 758 | PWC_DEBUG_FLOW("Frame buffer overflow (flen = %d, frame_total_size = %d).\n", flen, pdev->frame_total_size); |
692 | pdev->vsync = 0; /* Hmm, let's wait for an EOF (end-of-frame) */ | 759 | pdev->vsync = 0; /* Hmm, let's wait for an EOF (end-of-frame) */ |
693 | pdev->vframes_error++; | 760 | pdev->vframes_error++; |
694 | } | 761 | } |
@@ -704,96 +771,28 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs) | |||
704 | /* Shorter packet... We probably have the end of an image-frame; | 771 | /* Shorter packet... We probably have the end of an image-frame; |
705 | wake up read() process and let select()/poll() do something. | 772 | wake up read() process and let select()/poll() do something. |
706 | Decompression is done in user time over there. | 773 | Decompression is done in user time over there. |
707 | */ | 774 | */ |
708 | if (pdev->vsync == 2) { | 775 | if (pdev->vsync == 2) { |
709 | /* The ToUCam Fun CMOS sensor causes the firmware to send 2 or 3 bogus | 776 | if (pwc_rcv_short_packet(pdev, fbuf)) { |
710 | frames on the USB wire after an exposure change. This conditition is | 777 | awake = 1; |
711 | however detected in the cam and a bit is set in the header. | 778 | fbuf = pdev->fill_frame; |
712 | */ | ||
713 | if (pdev->type == 730) { | ||
714 | unsigned char *ptr = (unsigned char *)fbuf->data; | ||
715 | |||
716 | if (ptr[1] == 1 && ptr[0] & 0x10) { | ||
717 | #if PWC_DEBUG | ||
718 | Debug("Hyundai CMOS sensor bug. Dropping frame %d.\n", fbuf->sequence); | ||
719 | #endif | ||
720 | pdev->drop_frames += 2; | ||
721 | pdev->vframes_error++; | ||
722 | } | ||
723 | if ((ptr[0] ^ pdev->vmirror) & 0x01) { | ||
724 | if (ptr[0] & 0x01) | ||
725 | Info("Snapshot button pressed.\n"); | ||
726 | else | ||
727 | Info("Snapshot button released.\n"); | ||
728 | } | ||
729 | if ((ptr[0] ^ pdev->vmirror) & 0x02) { | ||
730 | if (ptr[0] & 0x02) | ||
731 | Info("Image is mirrored.\n"); | ||
732 | else | ||
733 | Info("Image is normal.\n"); | ||
734 | } | ||
735 | pdev->vmirror = ptr[0] & 0x03; | ||
736 | /* Sometimes the trailer of the 730 is still sent as a 4 byte packet | ||
737 | after a short frame; this condition is filtered out specifically. A 4 byte | ||
738 | frame doesn't make sense anyway. | ||
739 | So we get either this sequence: | ||
740 | drop_bit set -> 4 byte frame -> short frame -> good frame | ||
741 | Or this one: | ||
742 | drop_bit set -> short frame -> good frame | ||
743 | So we drop either 3 or 2 frames in all! | ||
744 | */ | ||
745 | if (fbuf->filled == 4) | ||
746 | pdev->drop_frames++; | ||
747 | } | 779 | } |
748 | |||
749 | /* In case we were instructed to drop the frame, do so silently. | ||
750 | The buffer pointers are not updated either (but the counters are reset below). | ||
751 | */ | ||
752 | if (pdev->drop_frames > 0) | ||
753 | pdev->drop_frames--; | ||
754 | else { | ||
755 | /* Check for underflow first */ | ||
756 | if (fbuf->filled < pdev->frame_total_size) { | ||
757 | Trace(TRACE_FLOW, "Frame buffer underflow (%d bytes); discarded.\n", fbuf->filled); | ||
758 | pdev->vframes_error++; | ||
759 | } | ||
760 | else { | ||
761 | /* Send only once per EOF */ | ||
762 | awake = 1; /* delay wake_ups */ | ||
763 | |||
764 | /* Find our next frame to fill. This will always succeed, since we | ||
765 | * nick a frame from either empty or full list, but if we had to | ||
766 | * take it from the full list, it means a frame got dropped. | ||
767 | */ | ||
768 | if (pwc_next_fill_frame(pdev)) { | ||
769 | pdev->vframes_dumped++; | ||
770 | if ((pdev->vframe_count > FRAME_LOWMARK) && (pwc_trace & TRACE_FLOW)) { | ||
771 | if (pdev->vframes_dumped < 20) | ||
772 | Trace(TRACE_FLOW, "Dumping frame %d.\n", pdev->vframe_count); | ||
773 | if (pdev->vframes_dumped == 20) | ||
774 | Trace(TRACE_FLOW, "Dumping frame %d (last message).\n", pdev->vframe_count); | ||
775 | } | ||
776 | } | ||
777 | fbuf = pdev->fill_frame; | ||
778 | } | ||
779 | } /* !drop_frames */ | ||
780 | pdev->vframe_count++; | ||
781 | } | 780 | } |
782 | fbuf->filled = 0; | 781 | fbuf->filled = 0; |
783 | fillptr = fbuf->data; | 782 | fillptr = fbuf->data; |
784 | pdev->vsync = 1; | 783 | pdev->vsync = 1; |
785 | } /* .. flen < last_packet_size */ | 784 | } |
785 | |||
786 | pdev->vlast_packet_size = flen; | 786 | pdev->vlast_packet_size = flen; |
787 | } /* ..status == 0 */ | 787 | } /* ..status == 0 */ |
788 | #if PWC_DEBUG | ||
789 | /* This is normally not interesting to the user, unless you are really debugging something */ | ||
790 | else { | 788 | else { |
789 | /* This is normally not interesting to the user, unless | ||
790 | * you are really debugging something */ | ||
791 | static int iso_error = 0; | 791 | static int iso_error = 0; |
792 | iso_error++; | 792 | iso_error++; |
793 | if (iso_error < 20) | 793 | if (iso_error < 20) |
794 | Trace(TRACE_FLOW, "Iso frame %d of USB has error %d\n", i, fst); | 794 | PWC_DEBUG_FLOW("Iso frame %d of USB has error %d\n", i, fst); |
795 | } | 795 | } |
796 | #endif | ||
797 | } | 796 | } |
798 | 797 | ||
799 | handler_end: | 798 | handler_end: |
@@ -803,11 +802,11 @@ handler_end: | |||
803 | urb->dev = pdev->udev; | 802 | urb->dev = pdev->udev; |
804 | i = usb_submit_urb(urb, GFP_ATOMIC); | 803 | i = usb_submit_urb(urb, GFP_ATOMIC); |
805 | if (i != 0) | 804 | if (i != 0) |
806 | Err("Error (%d) re-submitting urb in pwc_isoc_handler.\n", i); | 805 | PWC_ERROR("Error (%d) re-submitting urb in pwc_isoc_handler.\n", i); |
807 | } | 806 | } |
808 | 807 | ||
809 | 808 | ||
810 | static int pwc_isoc_init(struct pwc_device *pdev) | 809 | int pwc_isoc_init(struct pwc_device *pdev) |
811 | { | 810 | { |
812 | struct usb_device *udev; | 811 | struct usb_device *udev; |
813 | struct urb *urb; | 812 | struct urb *urb; |
@@ -826,7 +825,6 @@ static int pwc_isoc_init(struct pwc_device *pdev) | |||
826 | /* Get the current alternate interface, adjust packet size */ | 825 | /* Get the current alternate interface, adjust packet size */ |
827 | if (!udev->actconfig) | 826 | if (!udev->actconfig) |
828 | return -EFAULT; | 827 | return -EFAULT; |
829 | |||
830 | intf = usb_ifnum_to_if(udev, 0); | 828 | intf = usb_ifnum_to_if(udev, 0); |
831 | if (intf) | 829 | if (intf) |
832 | idesc = usb_altnum_to_altsetting(intf, pdev->valternate); | 830 | idesc = usb_altnum_to_altsetting(intf, pdev->valternate); |
@@ -836,20 +834,21 @@ static int pwc_isoc_init(struct pwc_device *pdev) | |||
836 | 834 | ||
837 | /* Search video endpoint */ | 835 | /* Search video endpoint */ |
838 | pdev->vmax_packet_size = -1; | 836 | pdev->vmax_packet_size = -1; |
839 | for (i = 0; i < idesc->desc.bNumEndpoints; i++) | 837 | for (i = 0; i < idesc->desc.bNumEndpoints; i++) { |
840 | if ((idesc->endpoint[i].desc.bEndpointAddress & 0xF) == pdev->vendpoint) { | 838 | if ((idesc->endpoint[i].desc.bEndpointAddress & 0xF) == pdev->vendpoint) { |
841 | pdev->vmax_packet_size = le16_to_cpu(idesc->endpoint[i].desc.wMaxPacketSize); | 839 | pdev->vmax_packet_size = le16_to_cpu(idesc->endpoint[i].desc.wMaxPacketSize); |
842 | break; | 840 | break; |
843 | } | 841 | } |
842 | } | ||
844 | 843 | ||
845 | if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) { | 844 | if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) { |
846 | Err("Failed to find packet size for video endpoint in current alternate setting.\n"); | 845 | PWC_ERROR("Failed to find packet size for video endpoint in current alternate setting.\n"); |
847 | return -ENFILE; /* Odd error, that should be noticeable */ | 846 | return -ENFILE; /* Odd error, that should be noticeable */ |
848 | } | 847 | } |
849 | 848 | ||
850 | /* Set alternate interface */ | 849 | /* Set alternate interface */ |
851 | ret = 0; | 850 | ret = 0; |
852 | Trace(TRACE_OPEN, "Setting alternate interface %d\n", pdev->valternate); | 851 | PWC_DEBUG_OPEN("Setting alternate interface %d\n", pdev->valternate); |
853 | ret = usb_set_interface(pdev->udev, 0, pdev->valternate); | 852 | ret = usb_set_interface(pdev->udev, 0, pdev->valternate); |
854 | if (ret < 0) | 853 | if (ret < 0) |
855 | return ret; | 854 | return ret; |
@@ -857,12 +856,12 @@ static int pwc_isoc_init(struct pwc_device *pdev) | |||
857 | for (i = 0; i < MAX_ISO_BUFS; i++) { | 856 | for (i = 0; i < MAX_ISO_BUFS; i++) { |
858 | urb = usb_alloc_urb(ISO_FRAMES_PER_DESC, GFP_KERNEL); | 857 | urb = usb_alloc_urb(ISO_FRAMES_PER_DESC, GFP_KERNEL); |
859 | if (urb == NULL) { | 858 | if (urb == NULL) { |
860 | Err("Failed to allocate urb %d\n", i); | 859 | PWC_ERROR("Failed to allocate urb %d\n", i); |
861 | ret = -ENOMEM; | 860 | ret = -ENOMEM; |
862 | break; | 861 | break; |
863 | } | 862 | } |
864 | pdev->sbuf[i].urb = urb; | 863 | pdev->sbuf[i].urb = urb; |
865 | Trace(TRACE_MEMORY, "Allocated URB at 0x%p\n", urb); | 864 | PWC_DEBUG_MEMORY("Allocated URB at 0x%p\n", urb); |
866 | } | 865 | } |
867 | if (ret) { | 866 | if (ret) { |
868 | /* De-allocate in reverse order */ | 867 | /* De-allocate in reverse order */ |
@@ -899,24 +898,26 @@ static int pwc_isoc_init(struct pwc_device *pdev) | |||
899 | for (i = 0; i < MAX_ISO_BUFS; i++) { | 898 | for (i = 0; i < MAX_ISO_BUFS; i++) { |
900 | ret = usb_submit_urb(pdev->sbuf[i].urb, GFP_KERNEL); | 899 | ret = usb_submit_urb(pdev->sbuf[i].urb, GFP_KERNEL); |
901 | if (ret) | 900 | if (ret) |
902 | Err("isoc_init() submit_urb %d failed with error %d\n", i, ret); | 901 | PWC_ERROR("isoc_init() submit_urb %d failed with error %d\n", i, ret); |
903 | else | 902 | else |
904 | Trace(TRACE_MEMORY, "URB 0x%p submitted.\n", pdev->sbuf[i].urb); | 903 | PWC_DEBUG_MEMORY("URB 0x%p submitted.\n", pdev->sbuf[i].urb); |
905 | } | 904 | } |
906 | 905 | ||
907 | /* All is done... */ | 906 | /* All is done... */ |
908 | pdev->iso_init = 1; | 907 | pdev->iso_init = 1; |
909 | Trace(TRACE_OPEN, "<< pwc_isoc_init()\n"); | 908 | PWC_DEBUG_OPEN("<< pwc_isoc_init()\n"); |
910 | return 0; | 909 | return 0; |
911 | } | 910 | } |
912 | 911 | ||
913 | static void pwc_isoc_cleanup(struct pwc_device *pdev) | 912 | void pwc_isoc_cleanup(struct pwc_device *pdev) |
914 | { | 913 | { |
915 | int i; | 914 | int i; |
916 | 915 | ||
917 | Trace(TRACE_OPEN, ">> pwc_isoc_cleanup()\n"); | 916 | PWC_DEBUG_OPEN(">> pwc_isoc_cleanup()\n"); |
918 | if (pdev == NULL) | 917 | if (pdev == NULL) |
919 | return; | 918 | return; |
919 | if (pdev->iso_init == 0) | ||
920 | return; | ||
920 | 921 | ||
921 | /* Unlinking ISOC buffers one by one */ | 922 | /* Unlinking ISOC buffers one by one */ |
922 | for (i = 0; i < MAX_ISO_BUFS; i++) { | 923 | for (i = 0; i < MAX_ISO_BUFS; i++) { |
@@ -925,10 +926,10 @@ static void pwc_isoc_cleanup(struct pwc_device *pdev) | |||
925 | urb = pdev->sbuf[i].urb; | 926 | urb = pdev->sbuf[i].urb; |
926 | if (urb != 0) { | 927 | if (urb != 0) { |
927 | if (pdev->iso_init) { | 928 | if (pdev->iso_init) { |
928 | Trace(TRACE_MEMORY, "Unlinking URB %p\n", urb); | 929 | PWC_DEBUG_MEMORY("Unlinking URB %p\n", urb); |
929 | usb_kill_urb(urb); | 930 | usb_kill_urb(urb); |
930 | } | 931 | } |
931 | Trace(TRACE_MEMORY, "Freeing URB\n"); | 932 | PWC_DEBUG_MEMORY("Freeing URB\n"); |
932 | usb_free_urb(urb); | 933 | usb_free_urb(urb); |
933 | pdev->sbuf[i].urb = NULL; | 934 | pdev->sbuf[i].urb = NULL; |
934 | } | 935 | } |
@@ -938,12 +939,12 @@ static void pwc_isoc_cleanup(struct pwc_device *pdev) | |||
938 | is signalled by EPIPE) | 939 | is signalled by EPIPE) |
939 | */ | 940 | */ |
940 | if (pdev->error_status && pdev->error_status != EPIPE) { | 941 | if (pdev->error_status && pdev->error_status != EPIPE) { |
941 | Trace(TRACE_OPEN, "Setting alternate interface 0.\n"); | 942 | PWC_DEBUG_OPEN("Setting alternate interface 0.\n"); |
942 | usb_set_interface(pdev->udev, 0, 0); | 943 | usb_set_interface(pdev->udev, 0, 0); |
943 | } | 944 | } |
944 | 945 | ||
945 | pdev->iso_init = 0; | 946 | pdev->iso_init = 0; |
946 | Trace(TRACE_OPEN, "<< pwc_isoc_cleanup()\n"); | 947 | PWC_DEBUG_OPEN("<< pwc_isoc_cleanup()\n"); |
947 | } | 948 | } |
948 | 949 | ||
949 | int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot) | 950 | int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot) |
@@ -957,18 +958,18 @@ int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_f | |||
957 | /* Try to set video mode... */ | 958 | /* Try to set video mode... */ |
958 | start = ret = pwc_set_video_mode(pdev, width, height, new_fps, new_compression, new_snapshot); | 959 | start = ret = pwc_set_video_mode(pdev, width, height, new_fps, new_compression, new_snapshot); |
959 | if (ret) { | 960 | if (ret) { |
960 | Trace(TRACE_FLOW, "pwc_set_video_mode attempt 1 failed.\n"); | 961 | PWC_DEBUG_FLOW("pwc_set_video_mode attempt 1 failed.\n"); |
961 | /* That failed... restore old mode (we know that worked) */ | 962 | /* That failed... restore old mode (we know that worked) */ |
962 | start = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot); | 963 | start = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot); |
963 | if (start) { | 964 | if (start) { |
964 | Trace(TRACE_FLOW, "pwc_set_video_mode attempt 2 failed.\n"); | 965 | PWC_DEBUG_FLOW("pwc_set_video_mode attempt 2 failed.\n"); |
965 | } | 966 | } |
966 | } | 967 | } |
967 | if (start == 0) | 968 | if (start == 0) |
968 | { | 969 | { |
969 | if (pwc_isoc_init(pdev) < 0) | 970 | if (pwc_isoc_init(pdev) < 0) |
970 | { | 971 | { |
971 | Info("Failed to restart ISOC transfers in pwc_try_video_mode.\n"); | 972 | PWC_WARNING("Failed to restart ISOC transfers in pwc_try_video_mode.\n"); |
972 | ret = -EAGAIN; /* let's try again, who knows if it works a second time */ | 973 | ret = -EAGAIN; /* let's try again, who knows if it works a second time */ |
973 | } | 974 | } |
974 | } | 975 | } |
@@ -976,54 +977,129 @@ int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_f | |||
976 | return ret; /* Return original error code */ | 977 | return ret; /* Return original error code */ |
977 | } | 978 | } |
978 | 979 | ||
980 | /********* | ||
981 | * sysfs | ||
982 | *********/ | ||
983 | static struct pwc_device *cd_to_pwc(struct class_device *cd) | ||
984 | { | ||
985 | struct video_device *vdev = to_video_device(cd); | ||
986 | return video_get_drvdata(vdev); | ||
987 | } | ||
988 | |||
989 | static ssize_t show_pan_tilt(struct class_device *class_dev, char *buf) | ||
990 | { | ||
991 | struct pwc_device *pdev = cd_to_pwc(class_dev); | ||
992 | return sprintf(buf, "%d %d\n", pdev->pan_angle, pdev->tilt_angle); | ||
993 | } | ||
994 | |||
995 | static ssize_t store_pan_tilt(struct class_device *class_dev, const char *buf, | ||
996 | size_t count) | ||
997 | { | ||
998 | struct pwc_device *pdev = cd_to_pwc(class_dev); | ||
999 | int pan, tilt; | ||
1000 | int ret = -EINVAL; | ||
1001 | |||
1002 | if (strncmp(buf, "reset", 5) == 0) | ||
1003 | ret = pwc_mpt_reset(pdev, 0x3); | ||
1004 | |||
1005 | else if (sscanf(buf, "%d %d", &pan, &tilt) > 0) | ||
1006 | ret = pwc_mpt_set_angle(pdev, pan, tilt); | ||
1007 | |||
1008 | if (ret < 0) | ||
1009 | return ret; | ||
1010 | return strlen(buf); | ||
1011 | } | ||
1012 | static CLASS_DEVICE_ATTR(pan_tilt, S_IRUGO | S_IWUSR, show_pan_tilt, | ||
1013 | store_pan_tilt); | ||
1014 | |||
1015 | static ssize_t show_snapshot_button_status(struct class_device *class_dev, char *buf) | ||
1016 | { | ||
1017 | struct pwc_device *pdev = cd_to_pwc(class_dev); | ||
1018 | int status = pdev->snapshot_button_status; | ||
1019 | pdev->snapshot_button_status = 0; | ||
1020 | return sprintf(buf, "%d\n", status); | ||
1021 | } | ||
1022 | |||
1023 | static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status, | ||
1024 | NULL); | ||
1025 | |||
1026 | static void pwc_create_sysfs_files(struct video_device *vdev) | ||
1027 | { | ||
1028 | struct pwc_device *pdev = video_get_drvdata(vdev); | ||
1029 | if (pdev->features & FEATURE_MOTOR_PANTILT) | ||
1030 | video_device_create_file(vdev, &class_device_attr_pan_tilt); | ||
1031 | video_device_create_file(vdev, &class_device_attr_button); | ||
1032 | } | ||
1033 | |||
1034 | static void pwc_remove_sysfs_files(struct video_device *vdev) | ||
1035 | { | ||
1036 | struct pwc_device *pdev = video_get_drvdata(vdev); | ||
1037 | if (pdev->features & FEATURE_MOTOR_PANTILT) | ||
1038 | video_device_remove_file(vdev, &class_device_attr_pan_tilt); | ||
1039 | video_device_remove_file(vdev, &class_device_attr_button); | ||
1040 | } | ||
1041 | |||
1042 | #if CONFIG_PWC_DEBUG | ||
1043 | static const char *pwc_sensor_type_to_string(unsigned int sensor_type) | ||
1044 | { | ||
1045 | switch(sensor_type) { | ||
1046 | case 0x00: | ||
1047 | return "Hyundai CMOS sensor"; | ||
1048 | case 0x20: | ||
1049 | return "Sony CCD sensor + TDA8787"; | ||
1050 | case 0x2E: | ||
1051 | return "Sony CCD sensor + Exas 98L59"; | ||
1052 | case 0x2F: | ||
1053 | return "Sony CCD sensor + ADI 9804"; | ||
1054 | case 0x30: | ||
1055 | return "Sharp CCD sensor + TDA8787"; | ||
1056 | case 0x3E: | ||
1057 | return "Sharp CCD sensor + Exas 98L59"; | ||
1058 | case 0x3F: | ||
1059 | return "Sharp CCD sensor + ADI 9804"; | ||
1060 | case 0x40: | ||
1061 | return "UPA 1021 sensor"; | ||
1062 | case 0x100: | ||
1063 | return "VGA sensor"; | ||
1064 | case 0x101: | ||
1065 | return "PAL MR sensor"; | ||
1066 | default: | ||
1067 | return "unknown type of sensor"; | ||
1068 | } | ||
1069 | } | ||
1070 | #endif | ||
979 | 1071 | ||
980 | /***************************************************************************/ | 1072 | /***************************************************************************/ |
981 | /* Video4Linux functions */ | 1073 | /* Video4Linux functions */ |
982 | 1074 | ||
983 | static int pwc_video_open(struct inode *inode, struct file *file) | 1075 | static int pwc_video_open(struct inode *inode, struct file *file) |
984 | { | 1076 | { |
985 | int i; | 1077 | int i, ret; |
986 | struct video_device *vdev = video_devdata(file); | 1078 | struct video_device *vdev = video_devdata(file); |
987 | struct pwc_device *pdev; | 1079 | struct pwc_device *pdev; |
988 | 1080 | ||
989 | Trace(TRACE_OPEN, ">> video_open called(vdev = 0x%p).\n", vdev); | 1081 | PWC_DEBUG_OPEN(">> video_open called(vdev = 0x%p).\n", vdev); |
990 | 1082 | ||
991 | pdev = (struct pwc_device *)vdev->priv; | 1083 | pdev = (struct pwc_device *)vdev->priv; |
992 | if (pdev == NULL) | 1084 | if (pdev == NULL) |
993 | BUG(); | 1085 | BUG(); |
994 | if (pdev->vopen) | 1086 | if (pdev->vopen) { |
1087 | PWC_DEBUG_OPEN("I'm busy, someone is using the device.\n"); | ||
995 | return -EBUSY; | 1088 | return -EBUSY; |
1089 | } | ||
996 | 1090 | ||
997 | down(&pdev->modlock); | 1091 | down(&pdev->modlock); |
998 | if (!pdev->usb_init) { | 1092 | if (!pdev->usb_init) { |
999 | Trace(TRACE_OPEN, "Doing first time initialization.\n"); | 1093 | PWC_DEBUG_OPEN("Doing first time initialization.\n"); |
1000 | pdev->usb_init = 1; | 1094 | pdev->usb_init = 1; |
1001 | 1095 | ||
1002 | if (pwc_trace & TRACE_OPEN) | 1096 | /* Query sensor type */ |
1097 | ret = pwc_get_cmos_sensor(pdev, &i); | ||
1098 | if (ret >= 0) | ||
1003 | { | 1099 | { |
1004 | /* Query sensor type */ | 1100 | PWC_DEBUG_OPEN("This %s camera is equipped with a %s (%d).\n", |
1005 | const char *sensor_type = NULL; | 1101 | pdev->vdev->name, |
1006 | int ret; | 1102 | pwc_sensor_type_to_string(i), i); |
1007 | |||
1008 | ret = pwc_get_cmos_sensor(pdev, &i); | ||
1009 | if (ret >= 0) | ||
1010 | { | ||
1011 | switch(i) { | ||
1012 | case 0x00: sensor_type = "Hyundai CMOS sensor"; break; | ||
1013 | case 0x20: sensor_type = "Sony CCD sensor + TDA8787"; break; | ||
1014 | case 0x2E: sensor_type = "Sony CCD sensor + Exas 98L59"; break; | ||
1015 | case 0x2F: sensor_type = "Sony CCD sensor + ADI 9804"; break; | ||
1016 | case 0x30: sensor_type = "Sharp CCD sensor + TDA8787"; break; | ||
1017 | case 0x3E: sensor_type = "Sharp CCD sensor + Exas 98L59"; break; | ||
1018 | case 0x3F: sensor_type = "Sharp CCD sensor + ADI 9804"; break; | ||
1019 | case 0x40: sensor_type = "UPA 1021 sensor"; break; | ||
1020 | case 0x100: sensor_type = "VGA sensor"; break; | ||
1021 | case 0x101: sensor_type = "PAL MR sensor"; break; | ||
1022 | default: sensor_type = "unknown type of sensor"; break; | ||
1023 | } | ||
1024 | } | ||
1025 | if (sensor_type != NULL) | ||
1026 | Info("This %s camera is equipped with a %s (%d).\n", pdev->vdev->name, sensor_type, i); | ||
1027 | } | 1103 | } |
1028 | } | 1104 | } |
1029 | 1105 | ||
@@ -1031,34 +1107,32 @@ static int pwc_video_open(struct inode *inode, struct file *file) | |||
1031 | if (power_save) { | 1107 | if (power_save) { |
1032 | i = pwc_camera_power(pdev, 1); | 1108 | i = pwc_camera_power(pdev, 1); |
1033 | if (i < 0) | 1109 | if (i < 0) |
1034 | Info("Failed to restore power to the camera! (%d)\n", i); | 1110 | PWC_DEBUG_OPEN("Failed to restore power to the camera! (%d)\n", i); |
1035 | } | 1111 | } |
1036 | /* Set LED on/off time */ | 1112 | /* Set LED on/off time */ |
1037 | if (pwc_set_leds(pdev, led_on, led_off) < 0) | 1113 | if (pwc_set_leds(pdev, led_on, led_off) < 0) |
1038 | Info("Failed to set LED on/off time.\n"); | 1114 | PWC_DEBUG_OPEN("Failed to set LED on/off time.\n"); |
1039 | 1115 | ||
1040 | pwc_construct(pdev); /* set min/max sizes correct */ | 1116 | pwc_construct(pdev); /* set min/max sizes correct */ |
1041 | 1117 | ||
1042 | /* So far, so good. Allocate memory. */ | 1118 | /* So far, so good. Allocate memory. */ |
1043 | i = pwc_allocate_buffers(pdev); | 1119 | i = pwc_allocate_buffers(pdev); |
1044 | if (i < 0) { | 1120 | if (i < 0) { |
1045 | Trace(TRACE_OPEN, "Failed to allocate buffer memory.\n"); | 1121 | PWC_DEBUG_OPEN("Failed to allocate buffers memory.\n"); |
1122 | pwc_free_buffers(pdev); | ||
1046 | up(&pdev->modlock); | 1123 | up(&pdev->modlock); |
1047 | return i; | 1124 | return i; |
1048 | } | 1125 | } |
1049 | 1126 | ||
1050 | /* Reset buffers & parameters */ | 1127 | /* Reset buffers & parameters */ |
1051 | pwc_reset_buffers(pdev); | 1128 | pwc_reset_buffers(pdev); |
1052 | for (i = 0; i < default_mbufs; i++) | 1129 | for (i = 0; i < pwc_mbufs; i++) |
1053 | pdev->image_used[i] = 0; | 1130 | pdev->image_used[i] = 0; |
1054 | pdev->vframe_count = 0; | 1131 | pdev->vframe_count = 0; |
1055 | pdev->vframes_dumped = 0; | 1132 | pdev->vframes_dumped = 0; |
1056 | pdev->vframes_error = 0; | 1133 | pdev->vframes_error = 0; |
1057 | pdev->visoc_errors = 0; | 1134 | pdev->visoc_errors = 0; |
1058 | pdev->error_status = 0; | 1135 | pdev->error_status = 0; |
1059 | #if PWC_DEBUG | ||
1060 | pdev->sequence = 0; | ||
1061 | #endif | ||
1062 | pwc_construct(pdev); /* set min/max sizes correct */ | 1136 | pwc_construct(pdev); /* set min/max sizes correct */ |
1063 | 1137 | ||
1064 | /* Set some defaults */ | 1138 | /* Set some defaults */ |
@@ -1070,29 +1144,44 @@ static int pwc_video_open(struct inode *inode, struct file *file) | |||
1070 | */ | 1144 | */ |
1071 | i = pwc_set_video_mode(pdev, pwc_image_sizes[pdev->vsize].x, pwc_image_sizes[pdev->vsize].y, pdev->vframes, pdev->vcompression, 0); | 1145 | i = pwc_set_video_mode(pdev, pwc_image_sizes[pdev->vsize].x, pwc_image_sizes[pdev->vsize].y, pdev->vframes, pdev->vcompression, 0); |
1072 | if (i) { | 1146 | if (i) { |
1073 | Trace(TRACE_OPEN, "First attempt at set_video_mode failed.\n"); | 1147 | unsigned int default_resolution; |
1074 | if (pdev->type == 730 || pdev->type == 740 || pdev->type == 750) | 1148 | PWC_DEBUG_OPEN("First attempt at set_video_mode failed.\n"); |
1075 | i = pwc_set_video_mode(pdev, pwc_image_sizes[PSZ_QSIF].x, pwc_image_sizes[PSZ_QSIF].y, 10, pdev->vcompression, 0); | 1149 | if (pdev->type>= 730) |
1150 | default_resolution = PSZ_QSIF; | ||
1076 | else | 1151 | else |
1077 | i = pwc_set_video_mode(pdev, pwc_image_sizes[PSZ_QCIF].x, pwc_image_sizes[PSZ_QCIF].y, 10, pdev->vcompression, 0); | 1152 | default_resolution = PSZ_QCIF; |
1153 | |||
1154 | i = pwc_set_video_mode(pdev, | ||
1155 | pwc_image_sizes[default_resolution].x, | ||
1156 | pwc_image_sizes[default_resolution].y, | ||
1157 | 10, | ||
1158 | pdev->vcompression, | ||
1159 | 0); | ||
1078 | } | 1160 | } |
1079 | if (i) { | 1161 | if (i) { |
1080 | Trace(TRACE_OPEN, "Second attempt at set_video_mode failed.\n"); | 1162 | PWC_DEBUG_OPEN("Second attempt at set_video_mode failed.\n"); |
1163 | pwc_free_buffers(pdev); | ||
1081 | up(&pdev->modlock); | 1164 | up(&pdev->modlock); |
1082 | return i; | 1165 | return i; |
1083 | } | 1166 | } |
1084 | 1167 | ||
1085 | i = pwc_isoc_init(pdev); | 1168 | i = pwc_isoc_init(pdev); |
1086 | if (i) { | 1169 | if (i) { |
1087 | Trace(TRACE_OPEN, "Failed to init ISOC stuff = %d.\n", i); | 1170 | PWC_DEBUG_OPEN("Failed to init ISOC stuff = %d.\n", i); |
1171 | pwc_isoc_cleanup(pdev); | ||
1172 | pwc_free_buffers(pdev); | ||
1088 | up(&pdev->modlock); | 1173 | up(&pdev->modlock); |
1089 | return i; | 1174 | return i; |
1090 | } | 1175 | } |
1091 | 1176 | ||
1177 | /* Initialize the webcam to sane value */ | ||
1178 | pwc_set_brightness(pdev, 0x7fff); | ||
1179 | pwc_set_agc(pdev, 1, 0); | ||
1180 | |||
1092 | pdev->vopen++; | 1181 | pdev->vopen++; |
1093 | file->private_data = vdev; | 1182 | file->private_data = vdev; |
1094 | up(&pdev->modlock); | 1183 | up(&pdev->modlock); |
1095 | Trace(TRACE_OPEN, "<< video_open() returns 0.\n"); | 1184 | PWC_DEBUG_OPEN("<< video_open() returns 0.\n"); |
1096 | return 0; | 1185 | return 0; |
1097 | } | 1186 | } |
1098 | 1187 | ||
@@ -1103,35 +1192,23 @@ static int pwc_video_close(struct inode *inode, struct file *file) | |||
1103 | struct pwc_device *pdev; | 1192 | struct pwc_device *pdev; |
1104 | int i; | 1193 | int i; |
1105 | 1194 | ||
1106 | Trace(TRACE_OPEN, ">> video_close called(vdev = 0x%p).\n", vdev); | 1195 | PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev); |
1107 | 1196 | ||
1108 | pdev = (struct pwc_device *)vdev->priv; | 1197 | pdev = (struct pwc_device *)vdev->priv; |
1109 | if (pdev->vopen == 0) | 1198 | if (pdev->vopen == 0) |
1110 | Info("video_close() called on closed device?\n"); | 1199 | PWC_DEBUG_MODULE("video_close() called on closed device?\n"); |
1111 | 1200 | ||
1112 | /* Dump statistics, but only if a reasonable amount of frames were | 1201 | /* Dump statistics, but only if a reasonable amount of frames were |
1113 | processed (to prevent endless log-entries in case of snap-shot | 1202 | processed (to prevent endless log-entries in case of snap-shot |
1114 | programs) | 1203 | programs) |
1115 | */ | 1204 | */ |
1116 | if (pdev->vframe_count > 20) | 1205 | if (pdev->vframe_count > 20) |
1117 | Info("Closing video device: %d frames received, dumped %d frames, %d frames with errors.\n", pdev->vframe_count, pdev->vframes_dumped, pdev->vframes_error); | 1206 | PWC_DEBUG_MODULE("Closing video device: %d frames received, dumped %d frames, %d frames with errors.\n", pdev->vframe_count, pdev->vframes_dumped, pdev->vframes_error); |
1118 | 1207 | ||
1119 | switch (pdev->type) | 1208 | if (DEVICE_USE_CODEC1(pdev->type)) |
1120 | { | 1209 | pwc_dec1_exit(); |
1121 | case 675: | 1210 | else |
1122 | case 680: | 1211 | pwc_dec23_exit(); |
1123 | case 690: | ||
1124 | case 720: | ||
1125 | case 730: | ||
1126 | case 740: | ||
1127 | case 750: | ||
1128 | /* pwc_dec23_exit(); *//* Timon & Kiara */ | ||
1129 | break; | ||
1130 | case 645: | ||
1131 | case 646: | ||
1132 | /* pwc_dec1_exit(); */ | ||
1133 | break; | ||
1134 | } | ||
1135 | 1212 | ||
1136 | pwc_isoc_cleanup(pdev); | 1213 | pwc_isoc_cleanup(pdev); |
1137 | pwc_free_buffers(pdev); | 1214 | pwc_free_buffers(pdev); |
@@ -1140,15 +1217,15 @@ static int pwc_video_close(struct inode *inode, struct file *file) | |||
1140 | if (pdev->error_status != EPIPE) { | 1217 | if (pdev->error_status != EPIPE) { |
1141 | /* Turn LEDs off */ | 1218 | /* Turn LEDs off */ |
1142 | if (pwc_set_leds(pdev, 0, 0) < 0) | 1219 | if (pwc_set_leds(pdev, 0, 0) < 0) |
1143 | Info("Failed to set LED on/off time.\n"); | 1220 | PWC_DEBUG_MODULE("Failed to set LED on/off time.\n"); |
1144 | if (power_save) { | 1221 | if (power_save) { |
1145 | i = pwc_camera_power(pdev, 0); | 1222 | i = pwc_camera_power(pdev, 0); |
1146 | if (i < 0) | 1223 | if (i < 0) |
1147 | Err("Failed to power down camera (%d)\n", i); | 1224 | PWC_ERROR("Failed to power down camera (%d)\n", i); |
1148 | } | 1225 | } |
1149 | } | 1226 | } |
1150 | pdev->vopen = 0; | 1227 | pdev->vopen--; |
1151 | Trace(TRACE_OPEN, "<< video_close()\n"); | 1228 | PWC_DEBUG_OPEN("<< video_close() vopen=%d\n", pdev->vopen); |
1152 | return 0; | 1229 | return 0; |
1153 | } | 1230 | } |
1154 | 1231 | ||
@@ -1164,7 +1241,7 @@ static int pwc_video_close(struct inode *inode, struct file *file) | |||
1164 | device is tricky anyhow. | 1241 | device is tricky anyhow. |
1165 | */ | 1242 | */ |
1166 | 1243 | ||
1167 | static ssize_t pwc_video_read(struct file *file, char __user * buf, | 1244 | static ssize_t pwc_video_read(struct file *file, char __user *buf, |
1168 | size_t count, loff_t *ppos) | 1245 | size_t count, loff_t *ppos) |
1169 | { | 1246 | { |
1170 | struct video_device *vdev = file->private_data; | 1247 | struct video_device *vdev = file->private_data; |
@@ -1172,8 +1249,10 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf, | |||
1172 | int noblock = file->f_flags & O_NONBLOCK; | 1249 | int noblock = file->f_flags & O_NONBLOCK; |
1173 | DECLARE_WAITQUEUE(wait, current); | 1250 | DECLARE_WAITQUEUE(wait, current); |
1174 | int bytes_to_read; | 1251 | int bytes_to_read; |
1252 | void *image_buffer_addr; | ||
1175 | 1253 | ||
1176 | Trace(TRACE_READ, "video_read(0x%p, %p, %zu) called.\n", vdev, buf, count); | 1254 | PWC_DEBUG_READ("pwc_video_read(vdev=0x%p, buf=%p, count=%zd) called.\n", |
1255 | vdev, buf, count); | ||
1177 | if (vdev == NULL) | 1256 | if (vdev == NULL) |
1178 | return -EFAULT; | 1257 | return -EFAULT; |
1179 | pdev = vdev->priv; | 1258 | pdev = vdev->priv; |
@@ -1214,16 +1293,19 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf, | |||
1214 | return -EFAULT; | 1293 | return -EFAULT; |
1215 | } | 1294 | } |
1216 | 1295 | ||
1217 | Trace(TRACE_READ, "Copying data to user space.\n"); | 1296 | PWC_DEBUG_READ("Copying data to user space.\n"); |
1218 | if (pdev->vpalette == VIDEO_PALETTE_RAW) | 1297 | if (pdev->vpalette == VIDEO_PALETTE_RAW) |
1219 | bytes_to_read = pdev->frame_size; | 1298 | bytes_to_read = pdev->frame_size + sizeof(struct pwc_raw_frame); |
1220 | else | 1299 | else |
1221 | bytes_to_read = pdev->view.size; | 1300 | bytes_to_read = pdev->view.size; |
1222 | 1301 | ||
1223 | /* copy bytes to user space; we allow for partial reads */ | 1302 | /* copy bytes to user space; we allow for partial reads */ |
1224 | if (count + pdev->image_read_pos > bytes_to_read) | 1303 | if (count + pdev->image_read_pos > bytes_to_read) |
1225 | count = bytes_to_read - pdev->image_read_pos; | 1304 | count = bytes_to_read - pdev->image_read_pos; |
1226 | if (copy_to_user(buf, pdev->image_ptr[pdev->fill_image] + pdev->image_read_pos, count)) | 1305 | image_buffer_addr = pdev->image_data; |
1306 | image_buffer_addr += pdev->images[pdev->fill_image].offset; | ||
1307 | image_buffer_addr += pdev->image_read_pos; | ||
1308 | if (copy_to_user(buf, image_buffer_addr, count)) | ||
1227 | return -EFAULT; | 1309 | return -EFAULT; |
1228 | pdev->image_read_pos += count; | 1310 | pdev->image_read_pos += count; |
1229 | if (pdev->image_read_pos >= bytes_to_read) { /* All data has been read */ | 1311 | if (pdev->image_read_pos >= bytes_to_read) { /* All data has been read */ |
@@ -1253,370 +1335,56 @@ static unsigned int pwc_video_poll(struct file *file, poll_table *wait) | |||
1253 | return 0; | 1335 | return 0; |
1254 | } | 1336 | } |
1255 | 1337 | ||
1256 | static int pwc_video_do_ioctl(struct inode *inode, struct file *file, | ||
1257 | unsigned int cmd, void *arg) | ||
1258 | { | ||
1259 | struct video_device *vdev = file->private_data; | ||
1260 | struct pwc_device *pdev; | ||
1261 | DECLARE_WAITQUEUE(wait, current); | ||
1262 | |||
1263 | if (vdev == NULL) | ||
1264 | return -EFAULT; | ||
1265 | pdev = vdev->priv; | ||
1266 | if (pdev == NULL) | ||
1267 | return -EFAULT; | ||
1268 | |||
1269 | switch (cmd) { | ||
1270 | /* Query cabapilities */ | ||
1271 | case VIDIOCGCAP: | ||
1272 | { | ||
1273 | struct video_capability *caps = arg; | ||
1274 | |||
1275 | strcpy(caps->name, vdev->name); | ||
1276 | caps->type = VID_TYPE_CAPTURE; | ||
1277 | caps->channels = 1; | ||
1278 | caps->audios = 1; | ||
1279 | caps->minwidth = pdev->view_min.x; | ||
1280 | caps->minheight = pdev->view_min.y; | ||
1281 | caps->maxwidth = pdev->view_max.x; | ||
1282 | caps->maxheight = pdev->view_max.y; | ||
1283 | break; | ||
1284 | } | ||
1285 | |||
1286 | /* Channel functions (simulate 1 channel) */ | ||
1287 | case VIDIOCGCHAN: | ||
1288 | { | ||
1289 | struct video_channel *v = arg; | ||
1290 | |||
1291 | if (v->channel != 0) | ||
1292 | return -EINVAL; | ||
1293 | v->flags = 0; | ||
1294 | v->tuners = 0; | ||
1295 | v->type = VIDEO_TYPE_CAMERA; | ||
1296 | strcpy(v->name, "Webcam"); | ||
1297 | return 0; | ||
1298 | } | ||
1299 | |||
1300 | case VIDIOCSCHAN: | ||
1301 | { | ||
1302 | /* The spec says the argument is an integer, but | ||
1303 | the bttv driver uses a video_channel arg, which | ||
1304 | makes sense becasue it also has the norm flag. | ||
1305 | */ | ||
1306 | struct video_channel *v = arg; | ||
1307 | if (v->channel != 0) | ||
1308 | return -EINVAL; | ||
1309 | return 0; | ||
1310 | } | ||
1311 | |||
1312 | |||
1313 | /* Picture functions; contrast etc. */ | ||
1314 | case VIDIOCGPICT: | ||
1315 | { | ||
1316 | struct video_picture *p = arg; | ||
1317 | int val; | ||
1318 | |||
1319 | val = pwc_get_brightness(pdev); | ||
1320 | if (val >= 0) | ||
1321 | p->brightness = val; | ||
1322 | else | ||
1323 | p->brightness = 0xffff; | ||
1324 | val = pwc_get_contrast(pdev); | ||
1325 | if (val >= 0) | ||
1326 | p->contrast = val; | ||
1327 | else | ||
1328 | p->contrast = 0xffff; | ||
1329 | /* Gamma, Whiteness, what's the difference? :) */ | ||
1330 | val = pwc_get_gamma(pdev); | ||
1331 | if (val >= 0) | ||
1332 | p->whiteness = val; | ||
1333 | else | ||
1334 | p->whiteness = 0xffff; | ||
1335 | val = pwc_get_saturation(pdev); | ||
1336 | if (val >= 0) | ||
1337 | p->colour = val; | ||
1338 | else | ||
1339 | p->colour = 0xffff; | ||
1340 | p->depth = 24; | ||
1341 | p->palette = pdev->vpalette; | ||
1342 | p->hue = 0xFFFF; /* N/A */ | ||
1343 | break; | ||
1344 | } | ||
1345 | |||
1346 | case VIDIOCSPICT: | ||
1347 | { | ||
1348 | struct video_picture *p = arg; | ||
1349 | /* | ||
1350 | * FIXME: Suppose we are mid read | ||
1351 | ANSWER: No problem: the firmware of the camera | ||
1352 | can handle brightness/contrast/etc | ||
1353 | changes at _any_ time, and the palette | ||
1354 | is used exactly once in the uncompress | ||
1355 | routine. | ||
1356 | */ | ||
1357 | pwc_set_brightness(pdev, p->brightness); | ||
1358 | pwc_set_contrast(pdev, p->contrast); | ||
1359 | pwc_set_gamma(pdev, p->whiteness); | ||
1360 | pwc_set_saturation(pdev, p->colour); | ||
1361 | if (p->palette && p->palette != pdev->vpalette) { | ||
1362 | switch (p->palette) { | ||
1363 | case VIDEO_PALETTE_YUV420P: | ||
1364 | case VIDEO_PALETTE_RAW: | ||
1365 | pdev->vpalette = p->palette; | ||
1366 | return pwc_try_video_mode(pdev, pdev->image.x, pdev->image.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot); | ||
1367 | break; | ||
1368 | default: | ||
1369 | return -EINVAL; | ||
1370 | break; | ||
1371 | } | ||
1372 | } | ||
1373 | break; | ||
1374 | } | ||
1375 | |||
1376 | /* Window/size parameters */ | ||
1377 | case VIDIOCGWIN: | ||
1378 | { | ||
1379 | struct video_window *vw = arg; | ||
1380 | |||
1381 | vw->x = 0; | ||
1382 | vw->y = 0; | ||
1383 | vw->width = pdev->view.x; | ||
1384 | vw->height = pdev->view.y; | ||
1385 | vw->chromakey = 0; | ||
1386 | vw->flags = (pdev->vframes << PWC_FPS_SHIFT) | | ||
1387 | (pdev->vsnapshot ? PWC_FPS_SNAPSHOT : 0); | ||
1388 | break; | ||
1389 | } | ||
1390 | |||
1391 | case VIDIOCSWIN: | ||
1392 | { | ||
1393 | struct video_window *vw = arg; | ||
1394 | int fps, snapshot, ret; | ||
1395 | |||
1396 | fps = (vw->flags & PWC_FPS_FRMASK) >> PWC_FPS_SHIFT; | ||
1397 | snapshot = vw->flags & PWC_FPS_SNAPSHOT; | ||
1398 | if (fps == 0) | ||
1399 | fps = pdev->vframes; | ||
1400 | if (pdev->view.x == vw->width && pdev->view.y && fps == pdev->vframes && snapshot == pdev->vsnapshot) | ||
1401 | return 0; | ||
1402 | ret = pwc_try_video_mode(pdev, vw->width, vw->height, fps, pdev->vcompression, snapshot); | ||
1403 | if (ret) | ||
1404 | return ret; | ||
1405 | break; | ||
1406 | } | ||
1407 | |||
1408 | /* We don't have overlay support (yet) */ | ||
1409 | case VIDIOCGFBUF: | ||
1410 | { | ||
1411 | struct video_buffer *vb = arg; | ||
1412 | |||
1413 | memset(vb,0,sizeof(*vb)); | ||
1414 | break; | ||
1415 | } | ||
1416 | |||
1417 | /* mmap() functions */ | ||
1418 | case VIDIOCGMBUF: | ||
1419 | { | ||
1420 | /* Tell the user program how much memory is needed for a mmap() */ | ||
1421 | struct video_mbuf *vm = arg; | ||
1422 | int i; | ||
1423 | |||
1424 | memset(vm, 0, sizeof(*vm)); | ||
1425 | vm->size = default_mbufs * pdev->len_per_image; | ||
1426 | vm->frames = default_mbufs; /* double buffering should be enough for most applications */ | ||
1427 | for (i = 0; i < default_mbufs; i++) | ||
1428 | vm->offsets[i] = i * pdev->len_per_image; | ||
1429 | break; | ||
1430 | } | ||
1431 | |||
1432 | case VIDIOCMCAPTURE: | ||
1433 | { | ||
1434 | /* Start capture into a given image buffer (called 'frame' in video_mmap structure) */ | ||
1435 | struct video_mmap *vm = arg; | ||
1436 | |||
1437 | Trace(TRACE_READ, "VIDIOCMCAPTURE: %dx%d, frame %d, format %d\n", vm->width, vm->height, vm->frame, vm->format); | ||
1438 | if (vm->frame < 0 || vm->frame >= default_mbufs) | ||
1439 | return -EINVAL; | ||
1440 | |||
1441 | /* xawtv is nasty. It probes the available palettes | ||
1442 | by setting a very small image size and trying | ||
1443 | various palettes... The driver doesn't support | ||
1444 | such small images, so I'm working around it. | ||
1445 | */ | ||
1446 | if (vm->format) | ||
1447 | { | ||
1448 | switch (vm->format) | ||
1449 | { | ||
1450 | case VIDEO_PALETTE_YUV420P: | ||
1451 | case VIDEO_PALETTE_RAW: | ||
1452 | break; | ||
1453 | default: | ||
1454 | return -EINVAL; | ||
1455 | break; | ||
1456 | } | ||
1457 | } | ||
1458 | |||
1459 | if ((vm->width != pdev->view.x || vm->height != pdev->view.y) && | ||
1460 | (vm->width >= pdev->view_min.x && vm->height >= pdev->view_min.y)) { | ||
1461 | int ret; | ||
1462 | |||
1463 | Trace(TRACE_OPEN, "VIDIOCMCAPTURE: changing size to please xawtv :-(.\n"); | ||
1464 | ret = pwc_try_video_mode(pdev, vm->width, vm->height, pdev->vframes, pdev->vcompression, pdev->vsnapshot); | ||
1465 | if (ret) | ||
1466 | return ret; | ||
1467 | } /* ... size mismatch */ | ||
1468 | |||
1469 | /* FIXME: should we lock here? */ | ||
1470 | if (pdev->image_used[vm->frame]) | ||
1471 | return -EBUSY; /* buffer wasn't available. Bummer */ | ||
1472 | pdev->image_used[vm->frame] = 1; | ||
1473 | |||
1474 | /* Okay, we're done here. In the SYNC call we wait until a | ||
1475 | frame comes available, then expand image into the given | ||
1476 | buffer. | ||
1477 | In contrast to the CPiA cam the Philips cams deliver a | ||
1478 | constant stream, almost like a grabber card. Also, | ||
1479 | we have separate buffers for the rawdata and the image, | ||
1480 | meaning we can nearly always expand into the requested buffer. | ||
1481 | */ | ||
1482 | Trace(TRACE_READ, "VIDIOCMCAPTURE done.\n"); | ||
1483 | break; | ||
1484 | } | ||
1485 | |||
1486 | case VIDIOCSYNC: | ||
1487 | { | ||
1488 | /* The doc says: "Whenever a buffer is used it should | ||
1489 | call VIDIOCSYNC to free this frame up and continue." | ||
1490 | |||
1491 | The only odd thing about this whole procedure is | ||
1492 | that MCAPTURE flags the buffer as "in use", and | ||
1493 | SYNC immediately unmarks it, while it isn't | ||
1494 | after SYNC that you know that the buffer actually | ||
1495 | got filled! So you better not start a CAPTURE in | ||
1496 | the same frame immediately (use double buffering). | ||
1497 | This is not a problem for this cam, since it has | ||
1498 | extra intermediate buffers, but a hardware | ||
1499 | grabber card will then overwrite the buffer | ||
1500 | you're working on. | ||
1501 | */ | ||
1502 | int *mbuf = arg; | ||
1503 | int ret; | ||
1504 | |||
1505 | Trace(TRACE_READ, "VIDIOCSYNC called (%d).\n", *mbuf); | ||
1506 | |||
1507 | /* bounds check */ | ||
1508 | if (*mbuf < 0 || *mbuf >= default_mbufs) | ||
1509 | return -EINVAL; | ||
1510 | /* check if this buffer was requested anyway */ | ||
1511 | if (pdev->image_used[*mbuf] == 0) | ||
1512 | return -EINVAL; | ||
1513 | |||
1514 | /* Add ourselves to the frame wait-queue. | ||
1515 | |||
1516 | FIXME: needs auditing for safety. | ||
1517 | QUESTION: In what respect? I think that using the | ||
1518 | frameq is safe now. | ||
1519 | */ | ||
1520 | add_wait_queue(&pdev->frameq, &wait); | ||
1521 | while (pdev->full_frames == NULL) { | ||
1522 | if (pdev->error_status) { | ||
1523 | remove_wait_queue(&pdev->frameq, &wait); | ||
1524 | set_current_state(TASK_RUNNING); | ||
1525 | return -pdev->error_status; | ||
1526 | } | ||
1527 | |||
1528 | if (signal_pending(current)) { | ||
1529 | remove_wait_queue(&pdev->frameq, &wait); | ||
1530 | set_current_state(TASK_RUNNING); | ||
1531 | return -ERESTARTSYS; | ||
1532 | } | ||
1533 | schedule(); | ||
1534 | set_current_state(TASK_INTERRUPTIBLE); | ||
1535 | } | ||
1536 | remove_wait_queue(&pdev->frameq, &wait); | ||
1537 | set_current_state(TASK_RUNNING); | ||
1538 | |||
1539 | /* The frame is ready. Expand in the image buffer | ||
1540 | requested by the user. I don't care if you | ||
1541 | mmap() 5 buffers and request data in this order: | ||
1542 | buffer 4 2 3 0 1 2 3 0 4 3 1 . . . | ||
1543 | Grabber hardware may not be so forgiving. | ||
1544 | */ | ||
1545 | Trace(TRACE_READ, "VIDIOCSYNC: frame ready.\n"); | ||
1546 | pdev->fill_image = *mbuf; /* tell in which buffer we want the image to be expanded */ | ||
1547 | /* Decompress, etc */ | ||
1548 | ret = pwc_handle_frame(pdev); | ||
1549 | pdev->image_used[*mbuf] = 0; | ||
1550 | if (ret) | ||
1551 | return -EFAULT; | ||
1552 | break; | ||
1553 | } | ||
1554 | |||
1555 | case VIDIOCGAUDIO: | ||
1556 | { | ||
1557 | struct video_audio *v = arg; | ||
1558 | |||
1559 | strcpy(v->name, "Microphone"); | ||
1560 | v->audio = -1; /* unknown audio minor */ | ||
1561 | v->flags = 0; | ||
1562 | v->mode = VIDEO_SOUND_MONO; | ||
1563 | v->volume = 0; | ||
1564 | v->bass = 0; | ||
1565 | v->treble = 0; | ||
1566 | v->balance = 0x8000; | ||
1567 | v->step = 1; | ||
1568 | break; | ||
1569 | } | ||
1570 | |||
1571 | case VIDIOCSAUDIO: | ||
1572 | { | ||
1573 | /* Dummy: nothing can be set */ | ||
1574 | break; | ||
1575 | } | ||
1576 | |||
1577 | case VIDIOCGUNIT: | ||
1578 | { | ||
1579 | struct video_unit *vu = arg; | ||
1580 | |||
1581 | vu->video = pdev->vdev->minor & 0x3F; | ||
1582 | vu->audio = -1; /* not known yet */ | ||
1583 | vu->vbi = -1; | ||
1584 | vu->radio = -1; | ||
1585 | vu->teletext = -1; | ||
1586 | break; | ||
1587 | } | ||
1588 | default: | ||
1589 | return pwc_ioctl(pdev, cmd, arg); | ||
1590 | } /* ..switch */ | ||
1591 | return 0; | ||
1592 | } | ||
1593 | |||
1594 | static int pwc_video_ioctl(struct inode *inode, struct file *file, | 1338 | static int pwc_video_ioctl(struct inode *inode, struct file *file, |
1595 | unsigned int cmd, unsigned long arg) | 1339 | unsigned int cmd, unsigned long arg) |
1596 | { | 1340 | { |
1597 | return video_usercopy(inode, file, cmd, arg, pwc_video_do_ioctl); | 1341 | return video_usercopy(inode, file, cmd, arg, pwc_video_do_ioctl); |
1598 | } | 1342 | } |
1599 | 1343 | ||
1600 | |||
1601 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma) | 1344 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma) |
1602 | { | 1345 | { |
1603 | struct video_device *vdev = file->private_data; | 1346 | struct video_device *vdev = file->private_data; |
1604 | struct pwc_device *pdev; | 1347 | struct pwc_device *pdev; |
1605 | unsigned long start = vma->vm_start; | 1348 | unsigned long start; |
1606 | unsigned long size = vma->vm_end-vma->vm_start; | 1349 | unsigned long size; |
1607 | unsigned long page, pos; | 1350 | unsigned long page, pos = 0; |
1351 | int index; | ||
1608 | 1352 | ||
1609 | Trace(TRACE_MEMORY, "mmap(0x%p, 0x%lx, %lu) called.\n", vdev, start, size); | 1353 | PWC_DEBUG_MEMORY(">> %s\n", __FUNCTION__); |
1610 | pdev = vdev->priv; | 1354 | pdev = vdev->priv; |
1355 | size = vma->vm_end - vma->vm_start; | ||
1356 | start = vma->vm_start; | ||
1611 | 1357 | ||
1612 | vma->vm_flags |= VM_IO; | 1358 | /* Find the idx buffer for this mapping */ |
1359 | for (index = 0; index < pwc_mbufs; index++) { | ||
1360 | pos = pdev->images[index].offset; | ||
1361 | if ((pos>>PAGE_SHIFT) == vma->vm_pgoff) | ||
1362 | break; | ||
1363 | } | ||
1364 | if (index == MAX_IMAGES) | ||
1365 | return -EINVAL; | ||
1366 | if (index == 0) { | ||
1367 | /* | ||
1368 | * Special case for v4l1. In v4l1, we map only one big buffer, | ||
1369 | * but in v4l2 each buffer is mapped | ||
1370 | */ | ||
1371 | unsigned long total_size; | ||
1372 | total_size = pwc_mbufs * pdev->len_per_image; | ||
1373 | if (size != pdev->len_per_image && size != total_size) { | ||
1374 | PWC_ERROR("Wrong size (%lu) needed to be len_per_image=%d or total_size=%lu\n", | ||
1375 | size, pdev->len_per_image, total_size); | ||
1376 | return -EINVAL; | ||
1377 | } | ||
1378 | } else if (size > pdev->len_per_image) | ||
1379 | return -EINVAL; | ||
1380 | |||
1381 | vma->vm_flags |= VM_IO; /* from 2.6.9-acX */ | ||
1613 | 1382 | ||
1614 | pos = (unsigned long)pdev->image_data; | 1383 | pos += (unsigned long)pdev->image_data; |
1615 | while (size > 0) { | 1384 | while (size > 0) { |
1616 | page = vmalloc_to_pfn((void *)pos); | 1385 | page = vmalloc_to_pfn((void *)pos); |
1617 | if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) | 1386 | if (remap_pfn_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) |
1618 | return -EAGAIN; | 1387 | return -EAGAIN; |
1619 | |||
1620 | start += PAGE_SIZE; | 1388 | start += PAGE_SIZE; |
1621 | pos += PAGE_SIZE; | 1389 | pos += PAGE_SIZE; |
1622 | if (size > PAGE_SIZE) | 1390 | if (size > PAGE_SIZE) |
@@ -1624,7 +1392,6 @@ static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma) | |||
1624 | else | 1392 | else |
1625 | size = 0; | 1393 | size = 0; |
1626 | } | 1394 | } |
1627 | |||
1628 | return 0; | 1395 | return 0; |
1629 | } | 1396 | } |
1630 | 1397 | ||
@@ -1645,10 +1412,12 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1645 | int video_nr = -1; /* default: use next available device */ | 1412 | int video_nr = -1; /* default: use next available device */ |
1646 | char serial_number[30], *name; | 1413 | char serial_number[30], *name; |
1647 | 1414 | ||
1415 | vendor_id = le16_to_cpu(udev->descriptor.idVendor); | ||
1416 | product_id = le16_to_cpu(udev->descriptor.idProduct); | ||
1417 | |||
1648 | /* Check if we can handle this device */ | 1418 | /* Check if we can handle this device */ |
1649 | Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n", | 1419 | PWC_DEBUG_PROBE("probe() called [%04X %04X], if %d\n", |
1650 | le16_to_cpu(udev->descriptor.idVendor), | 1420 | vendor_id, product_id, |
1651 | le16_to_cpu(udev->descriptor.idProduct), | ||
1652 | intf->altsetting->desc.bInterfaceNumber); | 1421 | intf->altsetting->desc.bInterfaceNumber); |
1653 | 1422 | ||
1654 | /* the interfaces are probed one by one. We are only interested in the | 1423 | /* the interfaces are probed one by one. We are only interested in the |
@@ -1658,61 +1427,63 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1658 | if (intf->altsetting->desc.bInterfaceNumber > 0) | 1427 | if (intf->altsetting->desc.bInterfaceNumber > 0) |
1659 | return -ENODEV; | 1428 | return -ENODEV; |
1660 | 1429 | ||
1661 | vendor_id = le16_to_cpu(udev->descriptor.idVendor); | ||
1662 | product_id = le16_to_cpu(udev->descriptor.idProduct); | ||
1663 | |||
1664 | if (vendor_id == 0x0471) { | 1430 | if (vendor_id == 0x0471) { |
1665 | switch (product_id) { | 1431 | switch (product_id) { |
1666 | case 0x0302: | 1432 | case 0x0302: |
1667 | Info("Philips PCA645VC USB webcam detected.\n"); | 1433 | PWC_INFO("Philips PCA645VC USB webcam detected.\n"); |
1668 | name = "Philips 645 webcam"; | 1434 | name = "Philips 645 webcam"; |
1669 | type_id = 645; | 1435 | type_id = 645; |
1670 | break; | 1436 | break; |
1671 | case 0x0303: | 1437 | case 0x0303: |
1672 | Info("Philips PCA646VC USB webcam detected.\n"); | 1438 | PWC_INFO("Philips PCA646VC USB webcam detected.\n"); |
1673 | name = "Philips 646 webcam"; | 1439 | name = "Philips 646 webcam"; |
1674 | type_id = 646; | 1440 | type_id = 646; |
1675 | break; | 1441 | break; |
1676 | case 0x0304: | 1442 | case 0x0304: |
1677 | Info("Askey VC010 type 2 USB webcam detected.\n"); | 1443 | PWC_INFO("Askey VC010 type 2 USB webcam detected.\n"); |
1678 | name = "Askey VC010 webcam"; | 1444 | name = "Askey VC010 webcam"; |
1679 | type_id = 646; | 1445 | type_id = 646; |
1680 | break; | 1446 | break; |
1681 | case 0x0307: | 1447 | case 0x0307: |
1682 | Info("Philips PCVC675K (Vesta) USB webcam detected.\n"); | 1448 | PWC_INFO("Philips PCVC675K (Vesta) USB webcam detected.\n"); |
1683 | name = "Philips 675 webcam"; | 1449 | name = "Philips 675 webcam"; |
1684 | type_id = 675; | 1450 | type_id = 675; |
1685 | break; | 1451 | break; |
1686 | case 0x0308: | 1452 | case 0x0308: |
1687 | Info("Philips PCVC680K (Vesta Pro) USB webcam detected.\n"); | 1453 | PWC_INFO("Philips PCVC680K (Vesta Pro) USB webcam detected.\n"); |
1688 | name = "Philips 680 webcam"; | 1454 | name = "Philips 680 webcam"; |
1689 | type_id = 680; | 1455 | type_id = 680; |
1690 | break; | 1456 | break; |
1691 | case 0x030C: | 1457 | case 0x030C: |
1692 | Info("Philips PCVC690K (Vesta Pro Scan) USB webcam detected.\n"); | 1458 | PWC_INFO("Philips PCVC690K (Vesta Pro Scan) USB webcam detected.\n"); |
1693 | name = "Philips 690 webcam"; | 1459 | name = "Philips 690 webcam"; |
1694 | type_id = 690; | 1460 | type_id = 690; |
1695 | break; | 1461 | break; |
1696 | case 0x0310: | 1462 | case 0x0310: |
1697 | Info("Philips PCVC730K (ToUCam Fun)/PCVC830 (ToUCam II) USB webcam detected.\n"); | 1463 | PWC_INFO("Philips PCVC730K (ToUCam Fun)/PCVC830 (ToUCam II) USB webcam detected.\n"); |
1698 | name = "Philips 730 webcam"; | 1464 | name = "Philips 730 webcam"; |
1699 | type_id = 730; | 1465 | type_id = 730; |
1700 | break; | 1466 | break; |
1701 | case 0x0311: | 1467 | case 0x0311: |
1702 | Info("Philips PCVC740K (ToUCam Pro)/PCVC840 (ToUCam II) USB webcam detected.\n"); | 1468 | PWC_INFO("Philips PCVC740K (ToUCam Pro)/PCVC840 (ToUCam II) USB webcam detected.\n"); |
1703 | name = "Philips 740 webcam"; | 1469 | name = "Philips 740 webcam"; |
1704 | type_id = 740; | 1470 | type_id = 740; |
1705 | break; | 1471 | break; |
1706 | case 0x0312: | 1472 | case 0x0312: |
1707 | Info("Philips PCVC750K (ToUCam Pro Scan) USB webcam detected.\n"); | 1473 | PWC_INFO("Philips PCVC750K (ToUCam Pro Scan) USB webcam detected.\n"); |
1708 | name = "Philips 750 webcam"; | 1474 | name = "Philips 750 webcam"; |
1709 | type_id = 750; | 1475 | type_id = 750; |
1710 | break; | 1476 | break; |
1711 | case 0x0313: | 1477 | case 0x0313: |
1712 | Info("Philips PCVC720K/40 (ToUCam XS) USB webcam detected.\n"); | 1478 | PWC_INFO("Philips PCVC720K/40 (ToUCam XS) USB webcam detected.\n"); |
1713 | name = "Philips 720K/40 webcam"; | 1479 | name = "Philips 720K/40 webcam"; |
1714 | type_id = 720; | 1480 | type_id = 720; |
1715 | break; | 1481 | break; |
1482 | case 0x0329: | ||
1483 | PWC_INFO("Philips SPC 900NC USB webcam detected.\n"); | ||
1484 | name = "Philips SPC 900NC webcam"; | ||
1485 | type_id = 720; | ||
1486 | break; | ||
1716 | default: | 1487 | default: |
1717 | return -ENODEV; | 1488 | return -ENODEV; |
1718 | break; | 1489 | break; |
@@ -1721,7 +1492,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1721 | else if (vendor_id == 0x069A) { | 1492 | else if (vendor_id == 0x069A) { |
1722 | switch(product_id) { | 1493 | switch(product_id) { |
1723 | case 0x0001: | 1494 | case 0x0001: |
1724 | Info("Askey VC010 type 1 USB webcam detected.\n"); | 1495 | PWC_INFO("Askey VC010 type 1 USB webcam detected.\n"); |
1725 | name = "Askey VC010 webcam"; | 1496 | name = "Askey VC010 webcam"; |
1726 | type_id = 645; | 1497 | type_id = 645; |
1727 | break; | 1498 | break; |
@@ -1733,32 +1504,33 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1733 | else if (vendor_id == 0x046d) { | 1504 | else if (vendor_id == 0x046d) { |
1734 | switch(product_id) { | 1505 | switch(product_id) { |
1735 | case 0x08b0: | 1506 | case 0x08b0: |
1736 | Info("Logitech QuickCam Pro 3000 USB webcam detected.\n"); | 1507 | PWC_INFO("Logitech QuickCam Pro 3000 USB webcam detected.\n"); |
1737 | name = "Logitech QuickCam Pro 3000"; | 1508 | name = "Logitech QuickCam Pro 3000"; |
1738 | type_id = 740; /* CCD sensor */ | 1509 | type_id = 740; /* CCD sensor */ |
1739 | break; | 1510 | break; |
1740 | case 0x08b1: | 1511 | case 0x08b1: |
1741 | Info("Logitech QuickCam Notebook Pro USB webcam detected.\n"); | 1512 | PWC_INFO("Logitech QuickCam Notebook Pro USB webcam detected.\n"); |
1742 | name = "Logitech QuickCam Notebook Pro"; | 1513 | name = "Logitech QuickCam Notebook Pro"; |
1743 | type_id = 740; /* CCD sensor */ | 1514 | type_id = 740; /* CCD sensor */ |
1744 | break; | 1515 | break; |
1745 | case 0x08b2: | 1516 | case 0x08b2: |
1746 | Info("Logitech QuickCam 4000 Pro USB webcam detected.\n"); | 1517 | PWC_INFO("Logitech QuickCam 4000 Pro USB webcam detected.\n"); |
1747 | name = "Logitech QuickCam Pro 4000"; | 1518 | name = "Logitech QuickCam Pro 4000"; |
1748 | type_id = 740; /* CCD sensor */ | 1519 | type_id = 740; /* CCD sensor */ |
1749 | break; | 1520 | break; |
1750 | case 0x08b3: | 1521 | case 0x08b3: |
1751 | Info("Logitech QuickCam Zoom USB webcam detected.\n"); | 1522 | PWC_INFO("Logitech QuickCam Zoom USB webcam detected.\n"); |
1752 | name = "Logitech QuickCam Zoom"; | 1523 | name = "Logitech QuickCam Zoom"; |
1753 | type_id = 740; /* CCD sensor */ | 1524 | type_id = 740; /* CCD sensor */ |
1754 | break; | 1525 | break; |
1755 | case 0x08B4: | 1526 | case 0x08B4: |
1756 | Info("Logitech QuickCam Zoom (new model) USB webcam detected.\n"); | 1527 | PWC_INFO("Logitech QuickCam Zoom (new model) USB webcam detected.\n"); |
1757 | name = "Logitech QuickCam Zoom"; | 1528 | name = "Logitech QuickCam Zoom"; |
1758 | type_id = 740; /* CCD sensor */ | 1529 | type_id = 740; /* CCD sensor */ |
1530 | power_save = 1; | ||
1759 | break; | 1531 | break; |
1760 | case 0x08b5: | 1532 | case 0x08b5: |
1761 | Info("Logitech QuickCam Orbit/Sphere USB webcam detected.\n"); | 1533 | PWC_INFO("Logitech QuickCam Orbit/Sphere USB webcam detected.\n"); |
1762 | name = "Logitech QuickCam Orbit"; | 1534 | name = "Logitech QuickCam Orbit"; |
1763 | type_id = 740; /* CCD sensor */ | 1535 | type_id = 740; /* CCD sensor */ |
1764 | features |= FEATURE_MOTOR_PANTILT; | 1536 | features |= FEATURE_MOTOR_PANTILT; |
@@ -1766,7 +1538,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1766 | case 0x08b6: | 1538 | case 0x08b6: |
1767 | case 0x08b7: | 1539 | case 0x08b7: |
1768 | case 0x08b8: | 1540 | case 0x08b8: |
1769 | Info("Logitech QuickCam detected (reserved ID).\n"); | 1541 | PWC_INFO("Logitech QuickCam detected (reserved ID).\n"); |
1770 | name = "Logitech QuickCam (res.)"; | 1542 | name = "Logitech QuickCam (res.)"; |
1771 | type_id = 730; /* Assuming CMOS */ | 1543 | type_id = 730; /* Assuming CMOS */ |
1772 | break; | 1544 | break; |
@@ -1782,15 +1554,20 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1782 | */ | 1554 | */ |
1783 | switch(product_id) { | 1555 | switch(product_id) { |
1784 | case 0x9000: | 1556 | case 0x9000: |
1785 | Info("Samsung MPC-C10 USB webcam detected.\n"); | 1557 | PWC_INFO("Samsung MPC-C10 USB webcam detected.\n"); |
1786 | name = "Samsung MPC-C10"; | 1558 | name = "Samsung MPC-C10"; |
1787 | type_id = 675; | 1559 | type_id = 675; |
1788 | break; | 1560 | break; |
1789 | case 0x9001: | 1561 | case 0x9001: |
1790 | Info("Samsung MPC-C30 USB webcam detected.\n"); | 1562 | PWC_INFO("Samsung MPC-C30 USB webcam detected.\n"); |
1791 | name = "Samsung MPC-C30"; | 1563 | name = "Samsung MPC-C30"; |
1792 | type_id = 675; | 1564 | type_id = 675; |
1793 | break; | 1565 | break; |
1566 | case 0x9002: | ||
1567 | PWC_INFO("Samsung SNC-35E (v3.0) USB webcam detected.\n"); | ||
1568 | name = "Samsung MPC-C30"; | ||
1569 | type_id = 740; | ||
1570 | break; | ||
1794 | default: | 1571 | default: |
1795 | return -ENODEV; | 1572 | return -ENODEV; |
1796 | break; | 1573 | break; |
@@ -1799,12 +1576,12 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1799 | else if (vendor_id == 0x041e) { | 1576 | else if (vendor_id == 0x041e) { |
1800 | switch(product_id) { | 1577 | switch(product_id) { |
1801 | case 0x400c: | 1578 | case 0x400c: |
1802 | Info("Creative Labs Webcam 5 detected.\n"); | 1579 | PWC_INFO("Creative Labs Webcam 5 detected.\n"); |
1803 | name = "Creative Labs Webcam 5"; | 1580 | name = "Creative Labs Webcam 5"; |
1804 | type_id = 730; | 1581 | type_id = 730; |
1805 | break; | 1582 | break; |
1806 | case 0x4011: | 1583 | case 0x4011: |
1807 | Info("Creative Labs Webcam Pro Ex detected.\n"); | 1584 | PWC_INFO("Creative Labs Webcam Pro Ex detected.\n"); |
1808 | name = "Creative Labs Webcam Pro Ex"; | 1585 | name = "Creative Labs Webcam Pro Ex"; |
1809 | type_id = 740; | 1586 | type_id = 740; |
1810 | break; | 1587 | break; |
@@ -1816,7 +1593,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1816 | else if (vendor_id == 0x04cc) { | 1593 | else if (vendor_id == 0x04cc) { |
1817 | switch(product_id) { | 1594 | switch(product_id) { |
1818 | case 0x8116: | 1595 | case 0x8116: |
1819 | Info("Sotec Afina Eye USB webcam detected.\n"); | 1596 | PWC_INFO("Sotec Afina Eye USB webcam detected.\n"); |
1820 | name = "Sotec Afina Eye"; | 1597 | name = "Sotec Afina Eye"; |
1821 | type_id = 730; | 1598 | type_id = 730; |
1822 | break; | 1599 | break; |
@@ -1829,7 +1606,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1829 | switch(product_id) { | 1606 | switch(product_id) { |
1830 | case 0x8116: | 1607 | case 0x8116: |
1831 | /* This is essentially the same cam as the Sotec Afina Eye */ | 1608 | /* This is essentially the same cam as the Sotec Afina Eye */ |
1832 | Info("AME Co. Afina Eye USB webcam detected.\n"); | 1609 | PWC_INFO("AME Co. Afina Eye USB webcam detected.\n"); |
1833 | name = "AME Co. Afina Eye"; | 1610 | name = "AME Co. Afina Eye"; |
1834 | type_id = 750; | 1611 | type_id = 750; |
1835 | break; | 1612 | break; |
@@ -1842,12 +1619,12 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1842 | else if (vendor_id == 0x0d81) { | 1619 | else if (vendor_id == 0x0d81) { |
1843 | switch(product_id) { | 1620 | switch(product_id) { |
1844 | case 0x1900: | 1621 | case 0x1900: |
1845 | Info("Visionite VCS-UC300 USB webcam detected.\n"); | 1622 | PWC_INFO("Visionite VCS-UC300 USB webcam detected.\n"); |
1846 | name = "Visionite VCS-UC300"; | 1623 | name = "Visionite VCS-UC300"; |
1847 | type_id = 740; /* CCD sensor */ | 1624 | type_id = 740; /* CCD sensor */ |
1848 | break; | 1625 | break; |
1849 | case 0x1910: | 1626 | case 0x1910: |
1850 | Info("Visionite VCS-UM100 USB webcam detected.\n"); | 1627 | PWC_INFO("Visionite VCS-UM100 USB webcam detected.\n"); |
1851 | name = "Visionite VCS-UM100"; | 1628 | name = "Visionite VCS-UM100"; |
1852 | type_id = 730; /* CMOS sensor */ | 1629 | type_id = 730; /* CMOS sensor */ |
1853 | break; | 1630 | break; |
@@ -1861,15 +1638,15 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1861 | 1638 | ||
1862 | memset(serial_number, 0, 30); | 1639 | memset(serial_number, 0, 30); |
1863 | usb_string(udev, udev->descriptor.iSerialNumber, serial_number, 29); | 1640 | usb_string(udev, udev->descriptor.iSerialNumber, serial_number, 29); |
1864 | Trace(TRACE_PROBE, "Device serial number is %s\n", serial_number); | 1641 | PWC_DEBUG_PROBE("Device serial number is %s\n", serial_number); |
1865 | 1642 | ||
1866 | if (udev->descriptor.bNumConfigurations > 1) | 1643 | if (udev->descriptor.bNumConfigurations > 1) |
1867 | Info("Warning: more than 1 configuration available.\n"); | 1644 | PWC_WARNING("Warning: more than 1 configuration available.\n"); |
1868 | 1645 | ||
1869 | /* Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device */ | 1646 | /* Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device */ |
1870 | pdev = kzalloc(sizeof(struct pwc_device), GFP_KERNEL); | 1647 | pdev = kzalloc(sizeof(struct pwc_device), GFP_KERNEL); |
1871 | if (pdev == NULL) { | 1648 | if (pdev == NULL) { |
1872 | Err("Oops, could not allocate memory for pwc_device.\n"); | 1649 | PWC_ERROR("Oops, could not allocate memory for pwc_device.\n"); |
1873 | return -ENOMEM; | 1650 | return -ENOMEM; |
1874 | } | 1651 | } |
1875 | pdev->type = type_id; | 1652 | pdev->type = type_id; |
@@ -1900,17 +1677,18 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1900 | pdev->vdev = video_device_alloc(); | 1677 | pdev->vdev = video_device_alloc(); |
1901 | if (pdev->vdev == 0) | 1678 | if (pdev->vdev == 0) |
1902 | { | 1679 | { |
1903 | Err("Err, cannot allocate video_device struture. Failing probe."); | 1680 | PWC_ERROR("Err, cannot allocate video_device struture. Failing probe."); |
1904 | kfree(pdev); | 1681 | kfree(pdev); |
1905 | return -ENOMEM; | 1682 | return -ENOMEM; |
1906 | } | 1683 | } |
1907 | memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); | 1684 | memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); |
1685 | pdev->vdev->dev = &(udev->dev); | ||
1908 | strcpy(pdev->vdev->name, name); | 1686 | strcpy(pdev->vdev->name, name); |
1909 | pdev->vdev->owner = THIS_MODULE; | 1687 | pdev->vdev->owner = THIS_MODULE; |
1910 | video_set_drvdata(pdev->vdev, pdev); | 1688 | video_set_drvdata(pdev->vdev, pdev); |
1911 | 1689 | ||
1912 | pdev->release = le16_to_cpu(udev->descriptor.bcdDevice); | 1690 | pdev->release = le16_to_cpu(udev->descriptor.bcdDevice); |
1913 | Trace(TRACE_PROBE, "Release: %04x\n", pdev->release); | 1691 | PWC_DEBUG_PROBE("Release: %04x\n", pdev->release); |
1914 | 1692 | ||
1915 | /* Now search device_hint[] table for a match, so we can hint a node number. */ | 1693 | /* Now search device_hint[] table for a match, so we can hint a node number. */ |
1916 | for (hint = 0; hint < MAX_DEV_HINTS; hint++) { | 1694 | for (hint = 0; hint < MAX_DEV_HINTS; hint++) { |
@@ -1920,7 +1698,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1920 | if ((device_hint[hint].serial_number[0] == '*') || !strcmp(device_hint[hint].serial_number, serial_number)) { | 1698 | if ((device_hint[hint].serial_number[0] == '*') || !strcmp(device_hint[hint].serial_number, serial_number)) { |
1921 | /* match! */ | 1699 | /* match! */ |
1922 | video_nr = device_hint[hint].device_node; | 1700 | video_nr = device_hint[hint].device_node; |
1923 | Trace(TRACE_PROBE, "Found hint, will try to register as /dev/video%d\n", video_nr); | 1701 | PWC_DEBUG_PROBE("Found hint, will try to register as /dev/video%d\n", video_nr); |
1924 | break; | 1702 | break; |
1925 | } | 1703 | } |
1926 | } | 1704 | } |
@@ -1929,21 +1707,27 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1929 | pdev->vdev->release = video_device_release; | 1707 | pdev->vdev->release = video_device_release; |
1930 | i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr); | 1708 | i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr); |
1931 | if (i < 0) { | 1709 | if (i < 0) { |
1932 | Err("Failed to register as video device (%d).\n", i); | 1710 | PWC_ERROR("Failed to register as video device (%d).\n", i); |
1933 | video_device_release(pdev->vdev); /* Drip... drip... drip... */ | 1711 | video_device_release(pdev->vdev); /* Drip... drip... drip... */ |
1934 | kfree(pdev); /* Oops, no memory leaks please */ | 1712 | kfree(pdev); /* Oops, no memory leaks please */ |
1935 | return -EIO; | 1713 | return -EIO; |
1936 | } | 1714 | } |
1937 | else { | 1715 | else { |
1938 | Info("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F); | 1716 | PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F); |
1939 | } | 1717 | } |
1940 | 1718 | ||
1941 | /* occupy slot */ | 1719 | /* occupy slot */ |
1942 | if (hint < MAX_DEV_HINTS) | 1720 | if (hint < MAX_DEV_HINTS) |
1943 | device_hint[hint].pdev = pdev; | 1721 | device_hint[hint].pdev = pdev; |
1944 | 1722 | ||
1945 | Trace(TRACE_PROBE, "probe() function returning struct at 0x%p.\n", pdev); | 1723 | PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev); |
1946 | usb_set_intfdata (intf, pdev); | 1724 | usb_set_intfdata (intf, pdev); |
1725 | pwc_create_sysfs_files(pdev->vdev); | ||
1726 | |||
1727 | /* Set the leds off */ | ||
1728 | pwc_set_leds(pdev, 0, 0); | ||
1729 | pwc_camera_power(pdev, 0); | ||
1730 | |||
1947 | return 0; | 1731 | return 0; |
1948 | } | 1732 | } |
1949 | 1733 | ||
@@ -1957,27 +1741,21 @@ static void usb_pwc_disconnect(struct usb_interface *intf) | |||
1957 | pdev = usb_get_intfdata (intf); | 1741 | pdev = usb_get_intfdata (intf); |
1958 | usb_set_intfdata (intf, NULL); | 1742 | usb_set_intfdata (intf, NULL); |
1959 | if (pdev == NULL) { | 1743 | if (pdev == NULL) { |
1960 | Err("pwc_disconnect() Called without private pointer.\n"); | 1744 | PWC_ERROR("pwc_disconnect() Called without private pointer.\n"); |
1961 | goto disconnect_out; | 1745 | goto disconnect_out; |
1962 | } | 1746 | } |
1963 | if (pdev->udev == NULL) { | 1747 | if (pdev->udev == NULL) { |
1964 | Err("pwc_disconnect() already called for %p\n", pdev); | 1748 | PWC_ERROR("pwc_disconnect() already called for %p\n", pdev); |
1965 | goto disconnect_out; | 1749 | goto disconnect_out; |
1966 | } | 1750 | } |
1967 | if (pdev->udev != interface_to_usbdev(intf)) { | 1751 | if (pdev->udev != interface_to_usbdev(intf)) { |
1968 | Err("pwc_disconnect() Woops: pointer mismatch udev/pdev.\n"); | 1752 | PWC_ERROR("pwc_disconnect() Woops: pointer mismatch udev/pdev.\n"); |
1969 | goto disconnect_out; | ||
1970 | } | ||
1971 | #ifdef PWC_MAGIC | ||
1972 | if (pdev->magic != PWC_MAGIC) { | ||
1973 | Err("pwc_disconnect() Magic number failed. Consult your scrolls and try again.\n"); | ||
1974 | goto disconnect_out; | 1753 | goto disconnect_out; |
1975 | } | 1754 | } |
1976 | #endif | ||
1977 | 1755 | ||
1978 | /* We got unplugged; this is signalled by an EPIPE error code */ | 1756 | /* We got unplugged; this is signalled by an EPIPE error code */ |
1979 | if (pdev->vopen) { | 1757 | if (pdev->vopen) { |
1980 | Info("Disconnected while webcam is in use!\n"); | 1758 | PWC_INFO("Disconnected while webcam is in use!\n"); |
1981 | pdev->error_status = EPIPE; | 1759 | pdev->error_status = EPIPE; |
1982 | } | 1760 | } |
1983 | 1761 | ||
@@ -1987,7 +1765,8 @@ static void usb_pwc_disconnect(struct usb_interface *intf) | |||
1987 | while (pdev->vopen) | 1765 | while (pdev->vopen) |
1988 | schedule(); | 1766 | schedule(); |
1989 | /* Device is now closed, so we can safely unregister it */ | 1767 | /* Device is now closed, so we can safely unregister it */ |
1990 | Trace(TRACE_PROBE, "Unregistering video device in disconnect().\n"); | 1768 | PWC_DEBUG_PROBE("Unregistering video device in disconnect().\n"); |
1769 | pwc_remove_sysfs_files(pdev->vdev); | ||
1991 | video_unregister_device(pdev->vdev); | 1770 | video_unregister_device(pdev->vdev); |
1992 | 1771 | ||
1993 | /* Free memory (don't set pdev to 0 just yet) */ | 1772 | /* Free memory (don't set pdev to 0 just yet) */ |
@@ -2021,58 +1800,64 @@ static int pwc_atoi(const char *s) | |||
2021 | * Initialization code & module stuff | 1800 | * Initialization code & module stuff |
2022 | */ | 1801 | */ |
2023 | 1802 | ||
2024 | static char size[10]; | 1803 | static char *size; |
2025 | static int fps = 0; | 1804 | static int fps; |
2026 | static int fbufs = 0; | 1805 | static int fbufs; |
2027 | static int mbufs = 0; | 1806 | static int mbufs; |
2028 | static int trace = -1; | ||
2029 | static int compression = -1; | 1807 | static int compression = -1; |
2030 | static int leds[2] = { -1, -1 }; | 1808 | static int leds[2] = { -1, -1 }; |
2031 | static char *dev_hint[MAX_DEV_HINTS] = { }; | 1809 | static int leds_nargs; |
1810 | static char *dev_hint[MAX_DEV_HINTS]; | ||
1811 | static int dev_hint_nargs; | ||
1812 | |||
1813 | module_param(size, charp, 0444); | ||
1814 | module_param(fps, int, 0444); | ||
1815 | module_param(fbufs, int, 0444); | ||
1816 | module_param(mbufs, int, 0444); | ||
1817 | #if CONFIG_PWC_DEBUG | ||
1818 | module_param_named(trace, pwc_trace, int, 0644); | ||
1819 | #endif | ||
1820 | module_param(power_save, int, 0444); | ||
1821 | module_param(compression, int, 0444); | ||
1822 | module_param_array(leds, int, &leds_nargs, 0444); | ||
1823 | module_param_array(dev_hint, charp, &dev_hint_nargs, 0444); | ||
2032 | 1824 | ||
2033 | module_param_string(size, size, sizeof(size), 0); | ||
2034 | MODULE_PARM_DESC(size, "Initial image size. One of sqcif, qsif, qcif, sif, cif, vga"); | 1825 | MODULE_PARM_DESC(size, "Initial image size. One of sqcif, qsif, qcif, sif, cif, vga"); |
2035 | module_param(fps, int, 0000); | ||
2036 | MODULE_PARM_DESC(fps, "Initial frames per second. Varies with model, useful range 5-30"); | 1826 | MODULE_PARM_DESC(fps, "Initial frames per second. Varies with model, useful range 5-30"); |
2037 | module_param(fbufs, int, 0000); | ||
2038 | MODULE_PARM_DESC(fbufs, "Number of internal frame buffers to reserve"); | 1827 | MODULE_PARM_DESC(fbufs, "Number of internal frame buffers to reserve"); |
2039 | module_param(mbufs, int, 0000); | ||
2040 | MODULE_PARM_DESC(mbufs, "Number of external (mmap()ed) image buffers"); | 1828 | MODULE_PARM_DESC(mbufs, "Number of external (mmap()ed) image buffers"); |
2041 | module_param(trace, int, 0000); | ||
2042 | MODULE_PARM_DESC(trace, "For debugging purposes"); | 1829 | MODULE_PARM_DESC(trace, "For debugging purposes"); |
2043 | module_param(power_save, bool, 0000); | ||
2044 | MODULE_PARM_DESC(power_save, "Turn power save feature in camera on or off"); | 1830 | MODULE_PARM_DESC(power_save, "Turn power save feature in camera on or off"); |
2045 | module_param(compression, int, 0000); | ||
2046 | MODULE_PARM_DESC(compression, "Preferred compression quality. Range 0 (uncompressed) to 3 (high compression)"); | 1831 | MODULE_PARM_DESC(compression, "Preferred compression quality. Range 0 (uncompressed) to 3 (high compression)"); |
2047 | module_param_array(leds, int, NULL, 0000); | ||
2048 | MODULE_PARM_DESC(leds, "LED on,off time in milliseconds"); | 1832 | MODULE_PARM_DESC(leds, "LED on,off time in milliseconds"); |
2049 | module_param_array(dev_hint, charp, NULL, 0000); | ||
2050 | MODULE_PARM_DESC(dev_hint, "Device node hints"); | 1833 | MODULE_PARM_DESC(dev_hint, "Device node hints"); |
2051 | 1834 | ||
2052 | MODULE_DESCRIPTION("Philips & OEM USB webcam driver"); | 1835 | MODULE_DESCRIPTION("Philips & OEM USB webcam driver"); |
2053 | MODULE_AUTHOR("Luc Saillard <luc@saillard.org>"); | 1836 | MODULE_AUTHOR("Luc Saillard <luc@saillard.org>"); |
2054 | MODULE_LICENSE("GPL"); | 1837 | MODULE_LICENSE("GPL"); |
1838 | MODULE_ALIAS("pwcx"); | ||
1839 | MODULE_VERSION( PWC_VERSION ); | ||
2055 | 1840 | ||
2056 | static int __init usb_pwc_init(void) | 1841 | static int __init usb_pwc_init(void) |
2057 | { | 1842 | { |
2058 | int i, sz; | 1843 | int i, sz; |
2059 | char *sizenames[PSZ_MAX] = { "sqcif", "qsif", "qcif", "sif", "cif", "vga" }; | 1844 | char *sizenames[PSZ_MAX] = { "sqcif", "qsif", "qcif", "sif", "cif", "vga" }; |
2060 | 1845 | ||
2061 | Info("Philips webcam module version " PWC_VERSION " loaded.\n"); | 1846 | PWC_INFO("Philips webcam module version " PWC_VERSION " loaded.\n"); |
2062 | Info("Supports Philips PCA645/646, PCVC675/680/690, PCVC720[40]/730/740/750 & PCVC830/840.\n"); | 1847 | PWC_INFO("Supports Philips PCA645/646, PCVC675/680/690, PCVC720[40]/730/740/750 & PCVC830/840.\n"); |
2063 | Info("Also supports the Askey VC010, various Logitech Quickcams, Samsung MPC-C10 and MPC-C30,\n"); | 1848 | PWC_INFO("Also supports the Askey VC010, various Logitech Quickcams, Samsung MPC-C10 and MPC-C30,\n"); |
2064 | Info("the Creative WebCam 5 & Pro Ex, SOTEC Afina Eye and Visionite VCS-UC300 and VCS-UM100.\n"); | 1849 | PWC_INFO("the Creative WebCam 5 & Pro Ex, SOTEC Afina Eye and Visionite VCS-UC300 and VCS-UM100.\n"); |
2065 | 1850 | ||
2066 | if (fps) { | 1851 | if (fps) { |
2067 | if (fps < 4 || fps > 30) { | 1852 | if (fps < 4 || fps > 30) { |
2068 | Err("Framerate out of bounds (4-30).\n"); | 1853 | PWC_ERROR("Framerate out of bounds (4-30).\n"); |
2069 | return -EINVAL; | 1854 | return -EINVAL; |
2070 | } | 1855 | } |
2071 | default_fps = fps; | 1856 | default_fps = fps; |
2072 | Info("Default framerate set to %d.\n", default_fps); | 1857 | PWC_DEBUG_MODULE("Default framerate set to %d.\n", default_fps); |
2073 | } | 1858 | } |
2074 | 1859 | ||
2075 | if (size[0]) { | 1860 | if (size) { |
2076 | /* string; try matching with array */ | 1861 | /* string; try matching with array */ |
2077 | for (sz = 0; sz < PSZ_MAX; sz++) { | 1862 | for (sz = 0; sz < PSZ_MAX; sz++) { |
2078 | if (!strcmp(sizenames[sz], size)) { /* Found! */ | 1863 | if (!strcmp(sizenames[sz], size)) { /* Found! */ |
@@ -2081,41 +1866,42 @@ static int __init usb_pwc_init(void) | |||
2081 | } | 1866 | } |
2082 | } | 1867 | } |
2083 | if (sz == PSZ_MAX) { | 1868 | if (sz == PSZ_MAX) { |
2084 | Err("Size not recognized; try size=[sqcif | qsif | qcif | sif | cif | vga].\n"); | 1869 | PWC_ERROR("Size not recognized; try size=[sqcif | qsif | qcif | sif | cif | vga].\n"); |
2085 | return -EINVAL; | 1870 | return -EINVAL; |
2086 | } | 1871 | } |
2087 | Info("Default image size set to %s [%dx%d].\n", sizenames[default_size], pwc_image_sizes[default_size].x, pwc_image_sizes[default_size].y); | 1872 | PWC_DEBUG_MODULE("Default image size set to %s [%dx%d].\n", sizenames[default_size], pwc_image_sizes[default_size].x, pwc_image_sizes[default_size].y); |
2088 | } | 1873 | } |
2089 | if (mbufs) { | 1874 | if (mbufs) { |
2090 | if (mbufs < 1 || mbufs > MAX_IMAGES) { | 1875 | if (mbufs < 1 || mbufs > MAX_IMAGES) { |
2091 | Err("Illegal number of mmap() buffers; use a number between 1 and %d.\n", MAX_IMAGES); | 1876 | PWC_ERROR("Illegal number of mmap() buffers; use a number between 1 and %d.\n", MAX_IMAGES); |
2092 | return -EINVAL; | 1877 | return -EINVAL; |
2093 | } | 1878 | } |
2094 | default_mbufs = mbufs; | 1879 | pwc_mbufs = mbufs; |
2095 | Info("Number of image buffers set to %d.\n", default_mbufs); | 1880 | PWC_DEBUG_MODULE("Number of image buffers set to %d.\n", pwc_mbufs); |
2096 | } | 1881 | } |
2097 | if (fbufs) { | 1882 | if (fbufs) { |
2098 | if (fbufs < 2 || fbufs > MAX_FRAMES) { | 1883 | if (fbufs < 2 || fbufs > MAX_FRAMES) { |
2099 | Err("Illegal number of frame buffers; use a number between 2 and %d.\n", MAX_FRAMES); | 1884 | PWC_ERROR("Illegal number of frame buffers; use a number between 2 and %d.\n", MAX_FRAMES); |
2100 | return -EINVAL; | 1885 | return -EINVAL; |
2101 | } | 1886 | } |
2102 | default_fbufs = fbufs; | 1887 | default_fbufs = fbufs; |
2103 | Info("Number of frame buffers set to %d.\n", default_fbufs); | 1888 | PWC_DEBUG_MODULE("Number of frame buffers set to %d.\n", default_fbufs); |
2104 | } | 1889 | } |
2105 | if (trace >= 0) { | 1890 | #if CONFIG_PWC_DEBUG |
2106 | Info("Trace options: 0x%04x\n", trace); | 1891 | if (pwc_trace >= 0) { |
2107 | pwc_trace = trace; | 1892 | PWC_DEBUG_MODULE("Trace options: 0x%04x\n", pwc_trace); |
2108 | } | 1893 | } |
1894 | #endif | ||
2109 | if (compression >= 0) { | 1895 | if (compression >= 0) { |
2110 | if (compression > 3) { | 1896 | if (compression > 3) { |
2111 | Err("Invalid compression setting; use a number between 0 (uncompressed) and 3 (high).\n"); | 1897 | PWC_ERROR("Invalid compression setting; use a number between 0 (uncompressed) and 3 (high).\n"); |
2112 | return -EINVAL; | 1898 | return -EINVAL; |
2113 | } | 1899 | } |
2114 | pwc_preferred_compression = compression; | 1900 | pwc_preferred_compression = compression; |
2115 | Info("Preferred compression set to %d.\n", pwc_preferred_compression); | 1901 | PWC_DEBUG_MODULE("Preferred compression set to %d.\n", pwc_preferred_compression); |
2116 | } | 1902 | } |
2117 | if (power_save) | 1903 | if (power_save) |
2118 | Info("Enabling power save on open/close.\n"); | 1904 | PWC_DEBUG_MODULE("Enabling power save on open/close.\n"); |
2119 | if (leds[0] >= 0) | 1905 | if (leds[0] >= 0) |
2120 | led_on = leds[0]; | 1906 | led_on = leds[0]; |
2121 | if (leds[1] >= 0) | 1907 | if (leds[1] >= 0) |
@@ -2146,14 +1932,14 @@ static int __init usb_pwc_init(void) | |||
2146 | dot++; | 1932 | dot++; |
2147 | /* Few sanity checks */ | 1933 | /* Few sanity checks */ |
2148 | if (*dot != '\0' && dot > colon) { | 1934 | if (*dot != '\0' && dot > colon) { |
2149 | Err("Malformed camera hint: the colon must be after the dot.\n"); | 1935 | PWC_ERROR("Malformed camera hint: the colon must be after the dot.\n"); |
2150 | return -EINVAL; | 1936 | return -EINVAL; |
2151 | } | 1937 | } |
2152 | 1938 | ||
2153 | if (*colon == '\0') { | 1939 | if (*colon == '\0') { |
2154 | /* No colon */ | 1940 | /* No colon */ |
2155 | if (*dot != '\0') { | 1941 | if (*dot != '\0') { |
2156 | Err("Malformed camera hint: no colon + device node given.\n"); | 1942 | PWC_ERROR("Malformed camera hint: no colon + device node given.\n"); |
2157 | return -EINVAL; | 1943 | return -EINVAL; |
2158 | } | 1944 | } |
2159 | else { | 1945 | else { |
@@ -2178,28 +1964,27 @@ static int __init usb_pwc_init(void) | |||
2178 | device_hint[i].serial_number[k] = '\0'; | 1964 | device_hint[i].serial_number[k] = '\0'; |
2179 | } | 1965 | } |
2180 | } | 1966 | } |
2181 | #if PWC_DEBUG | 1967 | PWC_TRACE("device_hint[%d]:\n", i); |
2182 | Debug("device_hint[%d]:\n", i); | 1968 | PWC_TRACE(" type : %d\n", device_hint[i].type); |
2183 | Debug(" type : %d\n", device_hint[i].type); | 1969 | PWC_TRACE(" serial# : %s\n", device_hint[i].serial_number); |
2184 | Debug(" serial# : %s\n", device_hint[i].serial_number); | 1970 | PWC_TRACE(" node : %d\n", device_hint[i].device_node); |
2185 | Debug(" node : %d\n", device_hint[i].device_node); | ||
2186 | #endif | ||
2187 | } | 1971 | } |
2188 | else | 1972 | else |
2189 | device_hint[i].type = 0; /* not filled */ | 1973 | device_hint[i].type = 0; /* not filled */ |
2190 | } /* ..for MAX_DEV_HINTS */ | 1974 | } /* ..for MAX_DEV_HINTS */ |
2191 | 1975 | ||
2192 | Trace(TRACE_PROBE, "Registering driver at address 0x%p.\n", &pwc_driver); | 1976 | PWC_DEBUG_PROBE("Registering driver at address 0x%p.\n", &pwc_driver); |
2193 | return usb_register(&pwc_driver); | 1977 | return usb_register(&pwc_driver); |
2194 | } | 1978 | } |
2195 | 1979 | ||
2196 | static void __exit usb_pwc_exit(void) | 1980 | static void __exit usb_pwc_exit(void) |
2197 | { | 1981 | { |
2198 | Trace(TRACE_MODULE, "Deregistering driver.\n"); | 1982 | PWC_DEBUG_MODULE("Deregistering driver.\n"); |
2199 | usb_deregister(&pwc_driver); | 1983 | usb_deregister(&pwc_driver); |
2200 | Info("Philips webcam module removed.\n"); | 1984 | PWC_INFO("Philips webcam module removed.\n"); |
2201 | } | 1985 | } |
2202 | 1986 | ||
2203 | module_init(usb_pwc_init); | 1987 | module_init(usb_pwc_init); |
2204 | module_exit(usb_pwc_exit); | 1988 | module_exit(usb_pwc_exit); |
2205 | 1989 | ||
1990 | /* vim: set cino= formatoptions=croql cindent shiftwidth=8 tabstop=8: */ | ||