Index: pwc.h =================================================================== --- pwc.h (revision 79) +++ pwc.h (revision 82) @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -96,8 +97,10 @@ /* Absolute maximum number of buffers available for mmap() */ #define MAX_IMAGES 10 -#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C',1) -#define V4L2_PIX_FMT_PWC23 v4l2_fourcc('P','W','C',23) +#ifndef V4L2_PIX_FMT_PWC1 +#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1') +#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2') +#endif /* The following structures were based on cpia.h. Why reinvent the wheel? :-) */ struct pwc_iso_buf @@ -219,6 +222,7 @@ struct pwc_mpt_range angle_range; int pan_angle; /* in degrees * 100 */ int tilt_angle; /* absolute angle; 0,0 is home position */ + int snapshot_button_status; /* set to 1 when the user push the button, reset to 0 when this value is read */ /*** Misc. data ***/ wait_queue_head_t frameq; /* When waiting for a frame to finish... */ Index: pwc-if.c =================================================================== --- pwc-if.c (revision 79) +++ pwc-if.c (revision 82) @@ -715,8 +715,10 @@ pdev->vframes_error++; } if ((ptr[0] ^ pdev->vmirror) & 0x01) { - if (ptr[0] & 0x01) + if (ptr[0] & 0x01) { + pdev->snapshot_button_status = 1; Info("Snapshot button pressed.\n"); + } else Info("Snapshot button released.\n"); } @@ -739,6 +741,17 @@ if (fbuf->filled == 4) pdev->drop_frames++; } + else if (pdev->type == 740) { + unsigned char *ptr = (unsigned char *)fbuf->data; + if ((ptr[0] ^ pdev->vmirror) & 0x01) { + if (ptr[0] & 0x01) { + pdev->snapshot_button_status = 1; + Info("Snapshot button pressed.\n"); + } + else + Info("Snapshot button released.\n"); + } + } /* In case we were instructed to drop the frame, do so silently. The buffer pointers are not updated either (but the counters are reset below). @@ -1013,11 +1026,23 @@ static CLASS_DEVICE_ATTR(pan_tilt, S_IRUGO | S_IWUSR, show_pan_tilt, store_pan_tilt); +static ssize_t show_snapshot_button_status(struct class_device *class_dev, char *buf) +{ + struct pwc_device *pdev = cd_to_pwc(class_dev); + int status = pdev->snapshot_button_status; + pdev->snapshot_button_status = 0; + return sprintf(buf, "%d\n", status); +} + +static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status, + NULL); + static void pwc_create_sysfs_files(struct video_device *vdev) { struct pwc_device *pdev = video_get_drvdata(vdev); if (pdev->features & FEATURE_MOTOR_PANTILT) video_device_create_file(vdev, &class_device_attr_pan_tilt); + video_device_create_file(vdev, &class_device_attr_button); } static void pwc_remove_sysfs_files(struct video_device *vdev) @@ -1025,6 +1050,7 @@ struct pwc_device *pdev = video_get_drvdata(vdev); if (pdev->features & FEATURE_MOTOR_PANTILT) video_device_remove_file(vdev, &class_device_attr_pan_tilt); + video_device_remove_file(vdev, &class_device_attr_button); } /***************************************************************************/ Index: pwc-ctrl.c =================================================================== --- pwc-ctrl.c (revision 79) +++ pwc-ctrl.c (revision 82) @@ -237,9 +237,6 @@ if (pEntry->alternate == 0) return -EINVAL; - if (pEntry->compressed) - return -ENOENT; /* Not supported. */ - memcpy(buf, pEntry->mode, 3); ret = send_video_command(pdev->udev, pdev->vendpoint, buf, 3); if (ret < 0) { Index: pwc-v4l.c =================================================================== --- pwc-v4l.c (revision 79) +++ pwc-v4l.c (revision 82) @@ -659,7 +659,7 @@ { case 0: /* RAW format */ - f->pixelformat = V4L2_PIX_FMT_PWC23; + f->pixelformat = pdev->type<=646?V4L2_PIX_FMT_PWC1:V4L2_PIX_FMT_PWC2; f->flags = V4L2_FMT_FLAG_COMPRESSED; strlcpy(f->description,"Raw Philips Webcam",sizeof(f->description)); break;