1 diff -Nur linux-2.6.7-rc3.org/drivers/usb/media/Kconfig linux-2.6.7-rc3/drivers/usb/media/Kconfig
2 --- linux-2.6.7-rc3.org/drivers/usb/media/Kconfig 2004-06-09 09:31:57.000000000 +0200
3 +++ linux-2.6.7-rc3/drivers/usb/media/Kconfig 2004-06-09 09:38:59.000000000 +0200
5 To compile this driver as a module, choose M here: the
6 module will be called pwc.
9 + tristate "PWCX decompressor module"
13 tristate "USB SE401 Camera support"
14 depends on USB && VIDEO_DEV
15 diff -Nur linux-2.6.7-rc3.org/drivers/usb/media/Makefile linux-2.6.7-rc3/drivers/usb/media/Makefile
16 --- linux-2.6.7-rc3.org/drivers/usb/media/Makefile 2004-06-07 21:13:34.000000000 +0200
17 +++ linux-2.6.7-rc3/drivers/usb/media/Makefile 2004-06-09 09:38:59.000000000 +0200
21 pwc-objs := pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o
22 +pwcx-objs := pwcx-glue.o libpwcx.a
24 obj-$(CONFIG_USB_DABUSB) += dabusb.o
25 obj-$(CONFIG_USB_DSBR) += dsbr100.o
27 obj-$(CONFIG_USB_KONICAWC) += konicawc.o usbvideo.o
28 obj-$(CONFIG_USB_OV511) += ov511.o
29 obj-$(CONFIG_USB_PWC) += pwc.o
30 +obj-$(CONFIG_USB_PWCX) += pwcx.o
31 obj-$(CONFIG_USB_SE401) += se401.o
32 obj-$(CONFIG_USB_STV680) += stv680.o
33 obj-$(CONFIG_USB_VICAM) += vicam.o usbvideo.o
34 diff -Nur linux-2.6.7-rc3.org/drivers/usb/media/pwc-ctrl.c linux-2.6.7-rc3/drivers/usb/media/pwc-ctrl.c
35 --- linux-2.6.7-rc3.org/drivers/usb/media/pwc-ctrl.c 2004-06-07 21:15:11.000000000 +0200
36 +++ linux-2.6.7-rc3/drivers/usb/media/pwc-ctrl.c 2004-05-07 00:52:23.000000000 +0200
38 #include <asm/uaccess.h>
40 #include <asm/errno.h>
41 +#include <linux/version.h>
44 #include "pwc-ioctl.h"
46 Debug("Failed to send video command... %d\n", ret);
49 - if (pEntry->compressed && pdev->decompressor != NULL)
50 - pdev->decompressor->init(pdev->release, buf, pdev->decompress_data);
52 + if (pEntry->compressed && pdev->decompressor != 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
53 + pdev->decompressor->init(pdev->type, pdev->release, buf, pdev->decompress_data);
56 + memcpy(pdev->cmd_buf, buf, 3);
58 /* Set various parameters */
59 pdev->vframes = frames;
65 - if (pChoose->bandlength > 0)
66 - pdev->decompressor->init(pdev->release, buf, pdev->decompress_data);
68 + if (pChoose->bandlength > 0 && pdev->decompressor != 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
69 + pdev->decompressor->init(pdev->type, pdev->release, buf, pdev->decompress_data);
72 + memcpy(pdev->cmd_buf, buf, 13);
74 /* Set various parameters */
75 pdev->vframes = frames;
79 static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, int compression, int snapshot)
81 - struct Kiara_table_entry *pChoose;
82 + struct Kiara_table_entry *pChoose = 0;
84 unsigned char buf[12];
86 + struct Kiara_table_entry RawEntry = {6, 773, 1272, {0xAD, 0xF4, 0x10, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}};
88 if (size >= PSZ_MAX || frames < 5 || frames > 30 || compression < 0 || compression > 3)
90 if (size == PSZ_VGA && frames > 15)
92 fps = (frames / 5) - 1;
94 - /* Find a supported framerate with progressively higher compression ratios
95 - if the preferred ratio is not available.
98 - if (pdev->decompressor == NULL) {
100 - Debug("Trying to find uncompressed mode.\n");
102 - pChoose = &Kiara_table[size][fps][0];
104 + /* special case: VGA @ 5 fps and snapshot is raw bayer mode */
105 + if (size == PSZ_VGA && frames == 5 && snapshot)
107 + /* Only available in case the raw palette is selected or
108 + we have the decompressor available. This mode is
109 + only available in compressed form
111 + if (pdev->vpalette == VIDEO_PALETTE_RAW || pdev->decompressor != NULL)
113 + Info("Choosing VGA/5 BAYER mode (%d).\n", pdev->vpalette);
114 + pChoose = &RawEntry;
118 + Info("VGA/5 BAYER mode _must_ have a decompressor available, or use RAW palette.\n");
122 - while (compression <= 3) {
123 - pChoose = &Kiara_table[size][fps][compression];
124 - if (pChoose->alternate != 0)
129 + /* Find a supported framerate with progressively higher compression ratios
130 + if the preferred ratio is not available.
131 + Skip this step when using RAW modes.
133 + if (pdev->decompressor == NULL && pdev->vpalette != VIDEO_PALETTE_RAW) {
135 + Debug("Trying to find uncompressed mode.\n");
137 + pChoose = &Kiara_table[size][fps][0];
140 + while (compression <= 3) {
141 + pChoose = &Kiara_table[size][fps][compression];
142 + if (pChoose->alternate != 0)
148 if (pChoose == NULL || pChoose->alternate == 0)
149 return -ENOENT; /* Not supported. */
154 - if (pChoose->bandlength > 0)
155 - pdev->decompressor->init(pdev->release, buf, pdev->decompress_data);
157 + if (pChoose->bandlength > 0 && pdev->decompressor != 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
158 + pdev->decompressor->init(pdev->type, pdev->release, buf, pdev->decompress_data);
160 + pdev->cmd_len = 12;
161 + memcpy(pdev->cmd_buf, buf, 12);
163 pdev->vframes = frames;
165 @@ -403,15 +433,15 @@
166 pdev->valternate = pChoose->alternate;
167 pdev->image = pwc_image_sizes[size];
168 pdev->vbandlength = pChoose->bandlength;
169 - if (pChoose->bandlength > 0)
170 - pdev->frame_size = (pChoose->bandlength * pdev->image.y) / 4;
172 + if (pdev->vbandlength > 0)
173 + pdev->frame_size = (pdev->vbandlength * pdev->image.y) / 4;
175 pdev->frame_size = (pdev->image.x * pdev->image.y * 12) / 8;
176 - pdev->frame_size += (pdev->frame_header_size + pdev->frame_trailer_size);
183 @pdev: device structure
184 @width: viewport width
185 @@ -422,14 +452,18 @@
187 int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot)
194 + Trace(TRACE_FLOW, "set_video_mode(%dx%d @ %d, palette %d).\n", width, height, frames, pdev->vpalette);
195 size = pwc_decode_size(pdev, width, height);
197 Debug("Could not find suitable size.\n");
201 + Debug("decode_size = %d.\n", size);
209 pdev->view.x = width;
210 pdev->view.y = height;
211 + pdev->frame_total_size = pdev->frame_size + pdev->frame_header_size + pdev->frame_trailer_size;
212 pwc_set_image_buffer_size(pdev);
213 Trace(TRACE_SIZE, "Set viewport to %dx%d, image size is %dx%d.\n", width, height, pwc_image_sizes[size].x, pwc_image_sizes[size].y);
215 @@ -467,23 +502,33 @@
217 void pwc_set_image_buffer_size(struct pwc_device *pdev)
219 - int factor, i, filler = 0;
220 + int i, factor = 0, filler = 0;
224 + /* for PALETTE_YUV420P */
225 + switch(pdev->vpalette)
227 + case VIDEO_PALETTE_YUV420P:
231 + case VIDEO_PALETTE_RAW:
232 + factor = 6; /* can be uncompressed YUV420P */
237 /* Set sizes in bytes */
238 pdev->image.size = pdev->image.x * pdev->image.y * factor / 4;
239 pdev->view.size = pdev->view.x * pdev->view.y * factor / 4;
241 /* Align offset, or you'll get some very weird results in
242 - YUV420 mode... x must be multiple of 4 (to get the Y's in
243 + YUV420 mode... x must be multiple of 4 (to get the Y's in
244 place), and y even (or you'll mixup U & V). This is less of a
247 pdev->offset.x = ((pdev->view.x - pdev->image.x) / 2) & 0xFFFC;
248 pdev->offset.y = ((pdev->view.y - pdev->image.y) / 2) & 0xFFFE;
251 /* Fill buffers with gray or black */
252 for (i = 0; i < MAX_IMAGES; i++) {
253 if (pdev->image_ptr[i] != NULL)
254 @@ -1670,19 +1594,34 @@
256 case VIDIOCPWCMPTSTATUS:
258 - struct pwc_mpt_status *status = arg;
260 if (pdev->features & FEATURE_MOTOR_PANTILT)
262 - ret = pwc_mpt_get_status(pdev, status);
263 + ARG_DEF(struct pwc_mpt_status, status)
265 + ret = pwc_mpt_get_status(pdev, ARGA(status));
278 + case VIDIOCPWCGVIDCMD:
280 + ARG_DEF(struct pwc_video_command, cmd);
282 + ARGR(cmd).type = pdev->type;
283 + ARGR(cmd).release = pdev->release;
284 + ARGR(cmd).command_len = pdev->cmd_len;
285 + memcpy(&ARGR(cmd).command_buf, pdev->cmd_buf, pdev->cmd_len);
286 + ARGR(cmd).bandlength = pdev->vbandlength;
287 + ARGR(cmd).frame_size = pdev->frame_size;
295 diff -Nur linux-2.6.7-rc3.org/drivers/usb/media/pwc-if.c linux-2.6.7-rc3/drivers/usb/media/pwc-if.c
296 --- linux-2.6.7-rc3.org/drivers/usb/media/pwc-if.c 2004-06-09 09:31:57.000000000 +0200
297 +++ linux-2.6.7-rc3/drivers/usb/media/pwc-if.c 2004-05-07 00:52:23.000000000 +0200
299 { USB_DEVICE(0x041E, 0x400C) }, /* Creative Webcam 5 */
300 { USB_DEVICE(0x041E, 0x4011) }, /* Creative Webcam Pro Ex */
301 { USB_DEVICE(0x04CC, 0x8116) }, /* Afina Eye */
302 + { USB_DEVICE(0x06BE, 0x8116) }, /* new Afina Eye */
303 { USB_DEVICE(0x0d81, 0x1910) }, /* Visionite */
304 { USB_DEVICE(0x0d81, 0x1900) },
308 static int pwc_video_open(struct inode *inode, struct file *file);
309 static int pwc_video_close(struct inode *inode, struct file *file);
310 +static void pwc_video_release(struct video_device *);
311 static ssize_t pwc_video_read(struct file *file, char *buf,
312 size_t count, loff_t *ppos);
313 static unsigned int pwc_video_poll(struct file *file, poll_table *wait);
317 /* ...copy data to frame buffer, if possible */
318 - if (flen + fbuf->filled > pdev->frame_size) {
319 - Trace(TRACE_FLOW, "Frame buffer overflow (flen = %d, frame_size = %d).\n", flen, pdev->frame_size);
320 + if (flen + fbuf->filled > pdev->frame_total_size) {
321 + Trace(TRACE_FLOW, "Frame buffer overflow (flen = %d, frame_total_size = %d).\n", flen, pdev->frame_total_size);
322 pdev->vsync = 0; /* Hmm, let's wait for an EOF (end-of-frame) */
323 pdev->vframes_error++;
328 /* Check for underflow first */
329 - if (fbuf->filled < pdev->frame_size) {
330 + if (fbuf->filled < pdev->frame_total_size) {
331 Trace(TRACE_FLOW, "Frame buffer underflow (%d bytes); discarded.\n", fbuf->filled);
332 pdev->vframes_error++;
338 - struct usb_interface *intf;
339 - struct usb_host_interface *idesc = NULL;
340 + struct usb_host_interface *idesc;
345 /* Get the current alternate interface, adjust packet size */
346 if (!udev->actconfig)
348 - intf = usb_ifnum_to_if(udev, 0);
350 - idesc = usb_altnum_to_altsetting(intf, pdev->valternate);
351 + idesc = &udev->actconfig->interface[0]->altsetting[pdev->valternate];
357 Err("isoc_init() submit_urb %d failed with error %d\n", i, ret);
359 - Trace(TRACE_OPEN, "URB 0x%p submitted.\n", pdev->sbuf[i].urb);
360 + Trace(TRACE_MEMORY, "URB 0x%p submitted.\n", pdev->sbuf[i].urb);
364 @@ -972,24 +971,28 @@
365 Trace(TRACE_OPEN, "Doing first time initialization.\n");
368 - if (pwc_trace & TRACE_OPEN) {
369 + if (pwc_trace & TRACE_OPEN)
371 /* Query sensor type */
372 const char *sensor_type = NULL;
375 - i = pwc_get_cmos_sensor(pdev);
377 - case -1: /* Unknown, show nothing */; break;
378 - case 0x00: sensor_type = "Hyundai CMOS sensor"; break;
379 - case 0x20: sensor_type = "Sony CCD sensor + TDA8787"; break;
380 - case 0x2E: sensor_type = "Sony CCD sensor + Exas 98L59"; break;
381 - case 0x2F: sensor_type = "Sony CCD sensor + ADI 9804"; break;
382 - case 0x30: sensor_type = "Sharp CCD sensor + TDA8787"; break;
383 - case 0x3E: sensor_type = "Sharp CCD sensor + Exas 98L59"; break;
384 - case 0x3F: sensor_type = "Sharp CCD sensor + ADI 9804"; break;
385 - case 0x40: sensor_type = "UPA 1021 sensor"; break;
386 - case 0x100: sensor_type = "VGA sensor"; break;
387 - case 0x101: sensor_type = "PAL MR sensor"; break;
388 - default: sensor_type = "unknown type of sensor"; break;
389 + ret = pwc_get_cmos_sensor(pdev, &i);
393 + case 0x00: sensor_type = "Hyundai CMOS sensor"; break;
394 + case 0x20: sensor_type = "Sony CCD sensor + TDA8787"; break;
395 + case 0x2E: sensor_type = "Sony CCD sensor + Exas 98L59"; break;
396 + case 0x2F: sensor_type = "Sony CCD sensor + ADI 9804"; break;
397 + case 0x30: sensor_type = "Sharp CCD sensor + TDA8787"; break;
398 + case 0x3E: sensor_type = "Sharp CCD sensor + Exas 98L59"; break;
399 + case 0x3F: sensor_type = "Sharp CCD sensor + ADI 9804"; break;
400 + case 0x40: sensor_type = "UPA 1021 sensor"; break;
401 + case 0x100: sensor_type = "VGA sensor"; break;
402 + case 0x101: sensor_type = "PAL MR sensor"; break;
403 + default: sensor_type = "unknown type of sensor"; break;
406 if (sensor_type != NULL)
407 Info("This %s camera is equipped with a %s (%d).\n", pdev->vdev.name, sensor_type, i);
408 @@ -1120,6 +1124,12 @@
412 +static void pwc_video_release(struct video_device *vfd)
414 + Trace(TRACE_OPEN, "pwc_video_release() called. Nothing to do here. Honestly.\n");
419 * FIXME: what about two parallel reads ????
420 * ANSWER: Not supported. You can't open the device more than once,
421 @@ -1139,6 +1149,7 @@
422 struct pwc_device *pdev;
423 int noblock = file->f_flags & O_NONBLOCK;
424 DECLARE_WAITQUEUE(wait, current);
427 Trace(TRACE_READ, "video_read(0x%p, %p, %d) called.\n", vdev, buf, count);
429 @@ -1175,20 +1186,25 @@
431 remove_wait_queue(&pdev->frameq, &wait);
432 set_current_state(TASK_RUNNING);
435 /* Decompress and release frame */
436 if (pwc_handle_frame(pdev))
440 Trace(TRACE_READ, "Copying data to user space.\n");
441 + if (pdev->vpalette == VIDEO_PALETTE_RAW)
442 + bytes_to_read = pdev->frame_size;
444 + bytes_to_read = pdev->view.size;
446 /* copy bytes to user space; we allow for partial reads */
447 - if (count + pdev->image_read_pos > pdev->view.size)
448 - count = pdev->view.size - pdev->image_read_pos;
449 + if (count + pdev->image_read_pos > bytes_to_read)
450 + count = bytes_to_read - pdev->image_read_pos;
451 if (copy_to_user(buf, pdev->image_ptr[pdev->fill_image] + pdev->image_read_pos, count))
453 pdev->image_read_pos += count;
454 - if (pdev->image_read_pos >= pdev->view.size) { /* All data has been read */
455 + if (pdev->image_read_pos >= bytes_to_read) { /* All data has been read */
456 pdev->image_read_pos = 0;
457 pwc_next_image(pdev);
459 @@ -1278,8 +1294,6 @@
460 struct video_picture *p = arg;
463 - p->colour = 0x8000;
465 val = pwc_get_brightness(pdev);
468 @@ -1302,11 +1316,11 @@
472 - p->palette = VIDEO_PALETTE_YUV420P;
473 + p->palette = pdev->vpalette;
474 p->hue = 0xFFFF; /* N/A */
481 struct video_picture *p = arg;
482 @@ -1318,13 +1332,22 @@
483 is used exactly once in the uncompress
486 - if (p->palette && p->palette != VIDEO_PALETTE_YUV420P) {
489 pwc_set_brightness(pdev, p->brightness);
490 pwc_set_contrast(pdev, p->contrast);
491 pwc_set_gamma(pdev, p->whiteness);
492 pwc_set_saturation(pdev, p->colour);
493 + if (p->palette && p->palette != pdev->vpalette) {
494 + switch (p->palette) {
495 + case VIDEO_PALETTE_YUV420P:
496 + case VIDEO_PALETTE_RAW:
497 + pdev->vpalette = p->palette;
498 + return pwc_try_video_mode(pdev, pdev->image.x, pdev->image.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot);
508 @@ -1398,13 +1421,23 @@
509 various palettes... The driver doesn't support
510 such small images, so I'm working around it.
512 - if (vm->format && vm->format != VIDEO_PALETTE_YUV420P)
517 + switch (vm->format)
519 + case VIDEO_PALETTE_YUV420P:
520 + case VIDEO_PALETTE_RAW:
528 if ((vm->width != pdev->view.x || vm->height != pdev->view.y) &&
529 (vm->width >= pdev->view_min.x && vm->height >= pdev->view_min.y)) {
533 Trace(TRACE_OPEN, "VIDIOCMCAPTURE: changing size to please xawtv :-(.\n");
534 ret = pwc_try_video_mode(pdev, vm->width, vm->height, pdev->vframes, pdev->vcompression, pdev->vsnapshot);
536 @@ -1636,12 +1669,12 @@
540 - Info("Philips PCVC730K (ToUCam Fun) USB webcam detected.\n");
541 + Info("Philips PCVC730K (ToUCam Fun)/PCVC830 (ToUCam II) USB webcam detected.\n");
542 name = "Philips 730 webcam";
546 - Info("Philips PCVC740K (ToUCam Pro) USB webcam detected.\n");
547 + Info("Philips PCVC740K (ToUCam Pro)/PCVC840 (ToUCam II) USB webcam detected.\n");
548 name = "Philips 740 webcam";
551 @@ -1755,17 +1788,44 @@
555 - else if (vendor_id == 0x04cc) {
556 + else if (vendor_id == 0x04cc) {
559 Info("Sotec Afina Eye USB webcam detected.\n");
560 name = "Sotec Afina Eye";
569 + else if (vendor_id == 0x06be) {
570 + switch(product_id) {
572 + /* Basicly the same as the Sotec Afina Eye */
573 + Info("AME CU-001 USB webcam detected.\n");
574 + name = "AME CU-001";
582 + else if (vendor_id == 0x06be) {
583 + switch(product_id) {
585 + /* This is essentially the same cam as the Sotec Afina Eye */
586 + Info("AME Co. Afina Eye USB webcam detected.\n");
587 + name = "AME Co. Afina Eye";
596 else if (vendor_id == 0x0d81) {
598 @@ -1815,8 +1875,6 @@
599 pdev->angle_range.pan_max = 7000;
600 pdev->angle_range.tilt_min = -3000;
601 pdev->angle_range.tilt_max = 2500;
602 - pdev->angle_range.zoom_min = -1;
603 - pdev->angle_range.zoom_max = -1;
606 init_MUTEX(&pdev->modlock);
607 @@ -1848,7 +1906,7 @@
611 - pdev->vdev.release = video_device_release;
612 + pdev->vdev.release = pwc_video_release;
613 i = video_register_device(&pdev->vdev, VFL_TYPE_GRABBER, video_nr);
615 Err("Failed to register as video device (%d).\n", i);
616 @@ -1971,7 +2029,7 @@
617 MODULE_PARM_DESC(dev_hint, "Device node hints");
619 MODULE_DESCRIPTION("Philips & OEM USB webcam driver");
620 -MODULE_AUTHOR("Nemosoft Unv. <nemosoft@smcc.demon.nl>");
621 +MODULE_AUTHOR("Nemosoft Unv. <webcam@smcc.demon.nl>");
622 MODULE_LICENSE("GPL");
624 static int __init usb_pwc_init(void)
625 @@ -1979,9 +2037,10 @@
627 char *sizenames[PSZ_MAX] = { "sqcif", "qsif", "qcif", "sif", "cif", "vga" };
629 - Info("Philips PCA645/646 + PCVC675/680/690 + PCVC730/740/750 webcam module version " PWC_VERSION " loaded.\n");
630 - Info("Also supports the Askey VC010, various Logitech QuickCams, Samsung MPC-C10 and MPC-C30,\n");
631 - Info("the Creative WebCam 5, SOTEC Afina Eye and Visionite VCS-UC300 and VCS-UM100.\n");
632 + Info("Philips webcam module version " PWC_VERSION " loaded.\n");
633 + Info("Supports Philips PCA645/646, PCVC675/680/690, PCVC720[40]/730/740/750 & PCVC830/840.\n");
634 + Info("Also supports the Askey VC010, various Logitech Quickcams, Samsung MPC-C10 and MPC-C30,\n");
635 + Info("the Creative WebCam 5 & Pro Ex, SOTEC Afina Eye and Visionite VCS-UC300 and VCS-UM100.\n");
638 if (fps < 4 || fps > 30) {
639 diff -Nur linux-2.6.7-rc3.org/drivers/usb/media/pwc-ioctl.h linux-2.6.7-rc3/drivers/usb/media/pwc-ioctl.h
640 --- linux-2.6.7-rc3.org/drivers/usb/media/pwc-ioctl.h 2004-06-07 21:14:11.000000000 +0200
641 +++ linux-2.6.7-rc3/drivers/usb/media/pwc-ioctl.h 2004-05-07 00:52:23.000000000 +0200
643 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
646 -/* This is pwc-ioctl.h belonging to PWC 8.10 */
647 +/* This is pwc-ioctl.h belonging to PWC 8.12.1
648 + It contains structures and defines to communicate from user space
649 + directly to the driver.
655 - 2001/08/03 Alvarado Added ioctl constants to access methods for
656 + 2001/08/03 Alvarado Added ioctl constants to access methods for
657 changing white balance and red/blue gains
658 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE
659 + 2003/12/13 Nemosft Unv. Some modifications to make interfacing to
663 /* These are private ioctl() commands, specific for the Philips webcams.
664 They contain functions not found in other webcams, and settings not
665 - specified in the Video4Linux API.
667 + specified in the Video4Linux API.
669 The #define names are built up like follows:
670 VIDIOC VIDeo IOCtl prefix
676 + /* Enumeration of image sizes */
677 +#define PSZ_SQCIF 0x00
678 +#define PSZ_QSIF 0x01
679 +#define PSZ_QCIF 0x02
680 +#define PSZ_SIF 0x03
681 +#define PSZ_CIF 0x04
682 +#define PSZ_VGA 0x05
686 /* The frame rate is encoded in the video_window.flags parameter using
687 the upper 16 bits, since some flags are defined nowadays. The following
688 defines provide a mask and shift to filter out this value.
690 - In 'Snapshot' mode the camera freezes its automatic exposure and colour
692 + In 'Snapshot' mode the camera freezes its automatic exposure and colour
695 #define PWC_FPS_SHIFT 16
697 #define PWC_FPS_SNAPSHOT 0x00400000
700 +/* structure for transfering x & y coordinates */
703 + int x, y; /* guess what */
704 + int size; /* size, or offset */
708 +/* Used with VIDIOCPWCPROBE */
714 'read_red' and 'read_blue' are read-only.
717 struct pwc_whitebalance
721 #define PWC_MPT_TILT 0x02
722 #define PWC_MPT_TIMEOUT 0x04 /* for status */
724 -/* Set angles; when absolute = 1, the angle is absolute and the
725 +/* Set angles; when absolute != 0, the angle is absolute and the
726 driver calculates the relative offset for you. This can only
727 be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns
729 @@ -127,18 +147,14 @@
730 int absolute; /* write-only */
731 int pan; /* degrees * 100 */
732 int tilt; /* degress * 100 */
733 - int zoom; /* N/A, set to -1 */
736 /* Range of angles of the camera, both horizontally and vertically.
737 - The zoom is not used, maybe in the future...
742 int pan_min, pan_max; /* degrees * 100 */
743 int tilt_min, tilt_max;
744 - int zoom_min, zoom_max; /* -1, -1 */
747 struct pwc_mpt_status
752 +/* This is used for out-of-kernel decompression. With it, you can get
753 + all the necessary information to initialize and use the decompressor
754 + routines in standalone applications.
756 +struct pwc_video_command
758 + int type; /* camera type (645, 675, 730, etc.) */
759 + int release; /* release number */
761 + int size; /* one of PSZ_* */
763 + int command_len; /* length of USB video command */
764 + unsigned char command_buf[13]; /* Actual USB video command */
765 + int bandlength; /* >0 = compressed */
766 + int frame_size; /* Size of one (un)compressed frame */
769 +/* Flags for PWCX subroutines. Not all modules honour all flags. */
770 +#define PWCX_FLAG_PLANAR 0x0001
771 +#define PWCX_FLAG_BAYER 0x0008
774 +/* IOCTL definitions */
776 /* Restore user settings */
777 #define VIDIOCPWCRUSER _IO('v', 192)
778 /* Save user settings */
779 @@ -172,13 +212,13 @@
780 /* This is a probe function; since so many devices are supported, it
781 becomes difficult to include all the names in programs that want to
782 check for the enhanced Philips stuff. So in stead, try this PROBE;
783 - it returns a structure with the original name, and the corresponding
784 + it returns a structure with the original name, and the corresponding
786 To use, fill the structure with zeroes, call PROBE and if that succeeds,
787 compare the name with that returned from VIDIOCGCAP; they should be the
788 same. If so, you can be assured it is a Philips (OEM) cam and the type
792 #define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe)
794 /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */
796 #define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles)
797 #define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles)
798 #define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status)
801 + /* Get the USB set-video command; needed for initializing libpwcx */
802 +#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command)
805 diff -Nur linux-2.6.7-rc3.org/drivers/usb/media/pwc-misc.c linux-2.6.7-rc3/drivers/usb/media/pwc-misc.c
806 --- linux-2.6.7-rc3.org/drivers/usb/media/pwc-misc.c 2004-06-07 21:14:05.000000000 +0200
807 +++ linux-2.6.7-rc3/drivers/usb/media/pwc-misc.c 2004-05-07 00:52:23.000000000 +0200
812 - /* Make sure we don't go beyond our max size */
813 - if (width > pdev->view_max.x || height > pdev->view_max.y)
815 + /* Make sure we don't go beyond our max size.
816 + NB: we have different limits for RAW and normal modes. In case
817 + you don't have the decompressor loaded or use RAW mode,
818 + the maximum viewable size is smaller.
820 + if (pdev->vpalette == VIDEO_PALETTE_RAW)
822 + if (width > pdev->abs_max.x || height > pdev->abs_max.y)
824 + Debug("VIDEO_PALETTE_RAW: going beyond abs_max.\n");
830 + if (width > pdev->view_max.x || height > pdev->view_max.y)
832 + Debug("VIDEO_PALETTE_ not RAW: going beyond view_max.\n");
837 /* Find the largest size supported by the camera that fits into the
842 for (i = 0; i < PSZ_MAX; i++) {
844 pdev->view_min.y = 96;
845 pdev->view_max.x = 352;
846 pdev->view_max.y = 288;
847 + pdev->abs_max.x = 352;
848 + pdev->abs_max.y = 288;
849 pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF;
850 pdev->vcinterface = 2;
853 if (pdev->decompressor != NULL) {
854 pdev->view_max.x = 640;
855 pdev->view_max.y = 480;
856 - pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
859 pdev->view_max.x = 352;
860 pdev->view_max.y = 288;
861 - pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF;
863 + pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
864 + pdev->abs_max.x = 640;
865 + pdev->abs_max.y = 480;
866 pdev->vcinterface = 3;
868 pdev->frame_header_size = 0;
870 if (pdev->decompressor != NULL) {
871 pdev->view_max.x = 640;
872 pdev->view_max.y = 480;
873 - pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
876 - /* Tell CIF, even though SIF really is the maximum, but some tools really need CIF */
877 + /* We use CIF, not SIF since some tools really need CIF. So we cheat a bit. */
878 pdev->view_max.x = 352;
879 pdev->view_max.y = 288;
880 - pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF;
882 + pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
883 + pdev->abs_max.x = 640;
884 + pdev->abs_max.y = 480;
885 pdev->vcinterface = 3;
887 pdev->frame_header_size = TOUCAM_HEADER_SIZE;
888 pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE;
891 + pdev->vpalette = VIDEO_PALETTE_YUV420P; /* default */
892 pdev->view_min.size = pdev->view_min.x * pdev->view_min.y;
893 pdev->view_max.size = pdev->view_max.x * pdev->view_max.y;
894 - /* length of image, in YUV format */
895 - pdev->len_per_image = (pdev->view_max.size * 3) / 2;
896 + /* length of image, in YUV format; always allocate enough memory. */
897 + pdev->len_per_image = (pdev->abs_max.x * pdev->abs_max.y * 3) / 2;
901 diff -Nur linux-2.6.7-rc3.org/drivers/usb/media/pwc-uncompress.c linux-2.6.7-rc3/drivers/usb/media/pwc-uncompress.c
902 --- linux-2.6.7-rc3.org/drivers/usb/media/pwc-uncompress.c 2004-06-07 21:14:25.000000000 +0200
903 +++ linux-2.6.7-rc3/drivers/usb/media/pwc-uncompress.c 2004-05-07 00:52:23.000000000 +0200
905 themselves. It also has a decompressor wrapper function.
908 +#include <asm/current.h>
909 #include <asm/types.h>
910 +// #include <linux/sched.h>
913 #include "pwc-uncompress.h"
915 image = pdev->image_ptr[pdev->fill_image];
920 yuv = fbuf->data + pdev->frame_header_size; /* Skip header */
921 - if (pdev->vbandlength == 0) {
923 + /* Raw format; that's easy... */
924 + if (pdev->vpalette == VIDEO_PALETTE_RAW)
926 + memcpy(image, yuv, pdev->frame_size);
930 + if (pdev->vbandlength == 0) {
931 /* Uncompressed mode. We copy the data into the output buffer,
932 using the viewport size (which may be larger than the image
933 size). Unfortunately we have to do a bit of byte stuffing
934 to get the desired output format/size.
937 - * We do some byte shuffling here to go from the
939 + * We do some byte shuffling here to go from the
940 * native format to YUV420P.
943 @@ -140,15 +149,21 @@
944 dstu += (stride >> 1);
948 - /* Compressed; the decompressor routines will write the data
950 + /* Compressed; the decompressor routines will write the data
951 in planar format immediately.
955 + flags = PWCX_FLAG_PLANAR;
956 + if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot)
957 + flags |= PWCX_FLAG_BAYER;
959 if (pdev->decompressor)
960 pdev->decompressor->decompress(
961 &pdev->image, &pdev->view, &pdev->offset,
965 pdev->decompress_data, pdev->vbandlength);
967 return -ENXIO; /* No such device or address: missing decompressor */
968 diff -Nur linux-2.6.7-rc3.org/drivers/usb/media/pwc-uncompress.h linux-2.6.7-rc3/drivers/usb/media/pwc-uncompress.h
969 --- linux-2.6.7-rc3.org/drivers/usb/media/pwc-uncompress.h 2004-06-07 21:14:03.000000000 +0200
970 +++ linux-2.6.7-rc3/drivers/usb/media/pwc-uncompress.h 2004-05-07 00:52:23.000000000 +0200
972 #define PWC_UNCOMPRESS_H
974 #include <linux/config.h>
975 +#include <linux/linkage.h>
976 #include <linux/list.h>
980 +/* from pwc-dec.h */
981 +#define PWCX_FLAG_PLANAR 0x0001
989 int type; /* type of camera (645, 680, etc) */
990 int table_size; /* memory needed */
992 - void (* init)(int release, void *buffer, void *table); /* Initialization routine; should be called after each set_video_mode */
993 - void (* exit)(void); /* Cleanup routine */
994 - void (* decompress)(struct pwc_coord *image, struct pwc_coord *view, struct pwc_coord *offset,
995 - void *src, void *dst, int planar,
996 + asmlinkage void (* init)(int type, int release, void *buffer, void *table); /* Initialization routine; should be called after each set_video_mode */
997 + asmlinkage void (* exit)(void); /* Cleanup routine */
998 + asmlinkage void (* decompress)(struct pwc_coord *image, struct pwc_coord *view, struct pwc_coord *offset,
999 + void *src, void *dst, int flags,
1000 void *table, int bandlength);
1001 void (* lock)(void); /* make sure module cannot be unloaded */
1002 void (* unlock)(void); /* release lock on module */
1003 diff -Nur linux-2.6.7-rc3.org/drivers/usb/media/pwc.h linux-2.6.7-rc3/drivers/usb/media/pwc.h
1004 --- linux-2.6.7-rc3.org/drivers/usb/media/pwc.h 2004-06-07 21:14:34.000000000 +0200
1005 +++ linux-2.6.7-rc3/drivers/usb/media/pwc.h 2004-05-07 00:52:23.000000000 +0200
1008 #include <linux/config.h>
1009 #include <linux/module.h>
1010 -#include <linux/smp_lock.h>
1011 -#include <linux/spinlock.h>
1012 #include <linux/usb.h>
1013 +#include <linux/spinlock.h>
1014 #include <linux/videodev.h>
1015 #include <linux/wait.h>
1017 +#include <linux/smp_lock.h>
1018 #include <asm/semaphore.h>
1019 #include <asm/errno.h>
1022 #define FEATURE_MOTOR_PANTILT 0x0001
1025 -#define PWC_MAJOR 8
1026 -#define PWC_MINOR 12
1027 -#define PWC_VERSION "8.12"
1028 +#define PWC_MAJOR 9
1029 +#define PWC_MINOR 0
1030 +#define PWC_VERSION "9.0-BETA-2"
1031 #define PWC_NAME "pwc"
1033 /* Turn certain features on/off */
1035 /* Absolute maximum number of buffers available for mmap() */
1036 #define MAX_IMAGES 10
1040 - int x, y; /* guess what */
1041 - int size; /* size, or offset */
1044 /* The following structures were based on cpia.h. Why reinvent the wheel? :-) */
1048 int vcinterface; /* video control interface */
1049 int valternate; /* alternate interface needed */
1050 int vframes, vsize; /* frames-per-second & size (see PSZ_*) */
1051 + int vpalette; /* palette: 420P, RAW or RGBBAYER */
1052 int vframe_count; /* received frames */
1053 int vframes_dumped; /* counter for dumped frames */
1054 int vframes_error; /* frames received in error */
1056 char vsnapshot; /* snapshot mode */
1057 char vsync; /* used by isoc handler */
1058 char vmirror; /* for ToUCaM series */
1061 + unsigned char cmd_buf[13];
1063 /* The image acquisition requires 3 to 4 steps:
1064 1. data is gathered in short packets from the USB controller
1066 struct pwc_frame_buf *full_frames, *full_frames_tail; /* all filled frames */
1067 struct pwc_frame_buf *fill_frame; /* frame currently being filled */
1068 struct pwc_frame_buf *read_frame; /* frame currently read by user process */
1070 int frame_header_size, frame_trailer_size;
1072 + int frame_total_size; /* including header & trailer */
1075 int sequence; /* Debugging aid */
1077 a gray or black border. view_min <= image <= view <= view_max;
1079 int image_mask; /* bitmask of supported sizes */
1080 - struct pwc_coord view_min, view_max; /* minimum and maximum sizes */
1081 + struct pwc_coord view_min, view_max; /* minimum and maximum viewable sizes */
1082 + struct pwc_coord abs_max; /* maximum supported size with compression */
1083 struct pwc_coord image, view; /* image and viewport size */
1084 struct pwc_coord offset; /* offset within the viewport */
1086 @@ -213,16 +212,6 @@
1090 -/* Enumeration of image sizes */
1091 -#define PSZ_SQCIF 0x00
1092 -#define PSZ_QSIF 0x01
1093 -#define PSZ_QCIF 0x02
1094 -#define PSZ_SIF 0x03
1095 -#define PSZ_CIF 0x04
1096 -#define PSZ_VGA 0x05
1104 extern int pwc_set_saturation(struct pwc_device *pdev, int value);
1105 extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value);
1106 extern int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value);
1107 -extern int pwc_get_cmos_sensor(struct pwc_device *pdev);
1108 +extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor);
1110 /* Power down or up the camera; not supported by all models */
1111 extern int pwc_camera_power(struct pwc_device *pdev, int power);