Commit a38f5292 authored by Nemosoft Unv's avatar Nemosoft Unv Committed by Greg Kroah-Hartman

[PATCH] USB: PWC 9.0.1

Attached you will find patches that will bring the PWC driver in the kernel
up to version 9.0.1 from 8.12 (9.0 wasn't accepted at first). Patches are
against 2.4.26 and 2.6.7. The main difference with 9.0 is that the
video_relase() routine is now hopefully in line with kernel requirements.
I've also added one more ioctl() call, upon request.

I'm also slightly in the dark on the status of the PWC in the 2.6 kernel;
I've seen two patches: the first was a bad one, since it would crash your
kernel when you unplug the cam. I've seen a second patch to reverse the
first one, but I don't know if that went in. Either way, you might get a
conflict in pwc-if.c in and about the pwc_video_release() routine; this
patch was generated against the clean 2.6.7 kernel source. Should you need
or want to fix it manually, this patch should remove the
pwc_video_release() in the 2.6 kernel.
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 70247c61
This file contains some additional information for the Philips webcams. This file contains some additional information for the Philips and OEM webcams.
E-mail: webcam@smcc.demon.nl Last updated: 2001-09-24 E-mail: webcam@smcc.demon.nl Last updated: 2004-01-19
Site: http://www.smcc.demon.nl/webcam/
The main webpage for the Philips driver is http://www.smcc.demon.nl/webcam/.
It contains a lot of extra information, a FAQ, and the binary plugin As of this moment, the following cameras are supported:
'PWCX'. This plugin contains decompression routines that allow you to * Philips PCA645
use higher image sizes and framerates; in addition the webcam uses less * Philips PCA646
bandwidth on the USB bus (handy if you want to run more than 1 camera * Philips PCVC675
simultaneously). These routines fall under an NDA, and may therefor not be * Philips PCVC680
distributed as source; however, its use is completely optional. * Philips PCVC690
* Philips PCVC720/40
* Philips PCVC730
* Philips PCVC740
* Philips PCVC750
* Askey VC010
* Creative Labs Webcam 5
* Creative Labs Webcam Pro Ex
* Logitech QuickCam 3000 Pro
* Logitech QuickCam 4000 Pro
* Logitech QuickCam Notebook Pro
* Logitech QuickCam Zoom
* Logitech QuickCam Orbit
* Logitech QuickCam Sphere
* Samsung MPC-C10
* Samsung MPC-C30
* Sotec Afina Eye
* AME CU-001
* Visionite VCS-UM100
* Visionite VCS-UC300
The main webpage for the Philips driver is at the address above. It contains
a lot of extra information, a FAQ, and the binary plugin 'PWCX'. This plugin
contains decompression routines that allow you to use higher image sizes and
framerates; in addition the webcam uses less bandwidth on the USB bus (handy
if you want to run more than 1 camera simultaneously). These routines fall
under a NDA, and may therefor not be distributed as source; however, its use
is completely optional.
You can build this code either into your kernel, or as a module. I recommend You can build this code either into your kernel, or as a module. I recommend
the latter, since it makes troubleshooting a lot easier. The built-in the latter, since it makes troubleshooting a lot easier. The built-in
...@@ -27,14 +54,14 @@ fps ...@@ -27,14 +54,14 @@ fps
Specifies the desired framerate. Is an integer in the range of 4-30. Specifies the desired framerate. Is an integer in the range of 4-30.
fbufs fbufs
This parameter specifies the number of internal buffers to use for storing This paramter specifies the number of internal buffers to use for storing
frames from the cam. This will help if the process that reads images from frames from the cam. This will help if the process that reads images from
the cam is a bit slow or momentarily busy. However, on slow machines it the cam is a bit slow or momentarely busy. However, on slow machines it
only introduces lag, so choose carefully. The default is 3, which is only introduces lag, so choose carefully. The default is 3, which is
reasonable. You can set it between 2 and 5. reasonable. You can set it between 2 and 5.
mbufs mbufs
This is an integer between 1 and 4. It will tell the module the number of This is an integer between 1 and 10. It will tell the module the number of
buffers to reserve for mmap(), VIDIOCCGMBUF, VIDIOCMCAPTURE and friends. buffers to reserve for mmap(), VIDIOCCGMBUF, VIDIOCMCAPTURE and friends.
The default is 2, which is adequate for most applications (double The default is 2, which is adequate for most applications (double
buffering). buffering).
...@@ -45,9 +72,9 @@ mbufs ...@@ -45,9 +72,9 @@ mbufs
slack when your program is behind. But you need a multi-threaded or slack when your program is behind. But you need a multi-threaded or
forked program to really take advantage of these buffers. forked program to really take advantage of these buffers.
The absolute maximum is 4, but don't set it too high! Every buffer takes The absolute maximum is 10, but don't set it too high! Every buffer takes
up 1.22 MB of RAM, so unless you have a lot of memory setting this to up 460 KB of RAM, so unless you have a lot of memory setting this to
something more than 2 is an absolute waste. This memory is only something more than 4 is an absolute waste. This memory is only
allocated during open(), so nothing is wasted when the camera is not in allocated during open(), so nothing is wasted when the camera is not in
use. use.
...@@ -74,9 +101,10 @@ compression (only useful with the plugin) ...@@ -74,9 +101,10 @@ compression (only useful with the plugin)
introduce some unwanted artefacts. The default is 2, medium compression. introduce some unwanted artefacts. The default is 2, medium compression.
See the FAQ on the website for an overview of which modes require See the FAQ on the website for an overview of which modes require
compression. compression.
The compression parameter only applies to the Vesta & ToUCam cameras. The compression parameter does not apply to the 645 and 646 cameras
The 645 and 646 have fixed compression parameters. and OEM models derived from those (only a few). Most cams honour this
parameter.
leds leds
This settings takes 2 integers, that define the on/off time for the LED This settings takes 2 integers, that define the on/off time for the LED
...@@ -89,14 +117,17 @@ leds ...@@ -89,14 +117,17 @@ leds
leds=0,0 leds=0,0
the LED never goes on, making it suitable for silent survaillance. the LED never goes on, making it suitable for silent surveillance.
By default the camera's LED is on solid while in use, and turned off By default the camera's LED is on solid while in use, and turned off
when the camera is not used anymore. when the camera is not used anymore.
This parameter works only with the ToUCam range of cameras (730, 740, This parameter works only with the ToUCam range of cameras (720, 730, 740,
750). For other cameras this command is silently ignored, and the LED 750) and OEMs. For other cameras this command is silently ignored, and
cannot be controlled. the LED cannot be controlled.
Finally: this parameters does not take effect UNTIL the first time you
open the camera device. Until then, the LED remains on.
dev_hint dev_hint
A long standing problem with USB devices is their dynamic nature: you A long standing problem with USB devices is their dynamic nature: you
...@@ -126,7 +157,7 @@ dev_hint ...@@ -126,7 +157,7 @@ dev_hint
other cameras will get the first free other cameras will get the first free
available slot (see below). available slot (see below).
dev_hint=645:1,680=2 The PCA645 camera will get /dev/video1, dev_hint=645:1,680:2 The PCA645 camera will get /dev/video1,
and a PCVC680 /dev/video2. and a PCVC680 /dev/video2.
dev_hint=645.0123:3,645.4567:0 The PCA645 camera with serialnumber dev_hint=645.0123:3,645.4567:0 The PCA645 camera with serialnumber
...@@ -176,13 +207,16 @@ trace ...@@ -176,13 +207,16 @@ trace
64 0x40 Show viewport and image sizes Off 64 0x40 Show viewport and image sizes Off
128 0x80 PWCX debugging Off
For example, to trace the open() & read() fuctions, sum 8 + 4 = 12, For example, to trace the open() & read() fuctions, sum 8 + 4 = 12,
so you would supply trace=12 during insmod or modprobe. If so you would supply trace=12 during insmod or modprobe. If
you want to turn the initialization and probing tracing off, set trace=0. you want to turn the initialization and probing tracing off, set trace=0.
The default value for trace is 35 (0x23). The default value for trace is 35 (0x23).
Example:
Example:
# modprobe pwc size=cif fps=15 power_save=1 # modprobe pwc size=cif fps=15 power_save=1
...@@ -192,7 +226,7 @@ cameras. Each camera has its own set of buffers. ...@@ -192,7 +226,7 @@ cameras. Each camera has its own set of buffers.
size and fps only specify defaults when you open() the device; this is to size and fps only specify defaults when you open() the device; this is to
accommodate some tools that don't set the size. You can change these accommodate some tools that don't set the size. You can change these
settings after open() with the Video4Linux ioctl() calls. The default of settings after open() with the Video4Linux ioctl() calls. The default of
defaults is QCIF size at 10 fps, BGR order. defaults is QCIF size at 10 fps.
The compression parameter is semiglobal; it sets the initial compression The compression parameter is semiglobal; it sets the initial compression
preference for all camera's, but this parameter can be set per camera with preference for all camera's, but this parameter can be set per camera with
...@@ -200,4 +234,3 @@ the VIDIOCPWCSCQUAL ioctl() call. ...@@ -200,4 +234,3 @@ the VIDIOCPWCSCQUAL ioctl() call.
All parameters are optional. All parameters are optional.
This diff is collapsed.
This diff is collapsed.
#ifndef PWC_IOCTL_H #ifndef PWC_IOCTL_H
#define PWC_IOCTL_H #define PWC_IOCTL_H
/* (C) 2001-2003 Nemosoft Unv. webcam@smcc.demon.nl /* (C) 2001-2004 Nemosoft Unv. webcam@smcc.demon.nl
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
...@@ -18,19 +18,24 @@ ...@@ -18,19 +18,24 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* This is pwc-ioctl.h belonging to PWC 8.10 */ /* This is pwc-ioctl.h belonging to PWC 8.12.1
It contains structures and defines to communicate from user space
directly to the driver.
*/
/* /*
Changes Changes
2001/08/03 Alvarado Added ioctl constants to access methods for 2001/08/03 Alvarado Added ioctl constants to access methods for
changing white balance and red/blue gains changing white balance and red/blue gains
2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE
2003/12/13 Nemosft Unv. Some modifications to make interfacing to
PWCX easier
*/ */
/* These are private ioctl() commands, specific for the Philips webcams. /* These are private ioctl() commands, specific for the Philips webcams.
They contain functions not found in other webcams, and settings not They contain functions not found in other webcams, and settings not
specified in the Video4Linux API. specified in the Video4Linux API.
The #define names are built up like follows: The #define names are built up like follows:
VIDIOC VIDeo IOCtl prefix VIDIOC VIDeo IOCtl prefix
PWC Philps WebCam PWC Philps WebCam
...@@ -40,13 +45,21 @@ ...@@ -40,13 +45,21 @@
*/ */
/* Enumeration of image sizes */
#define PSZ_SQCIF 0x00
#define PSZ_QSIF 0x01
#define PSZ_QCIF 0x02
#define PSZ_SIF 0x03
#define PSZ_CIF 0x04
#define PSZ_VGA 0x05
#define PSZ_MAX 6
/* The frame rate is encoded in the video_window.flags parameter using /* The frame rate is encoded in the video_window.flags parameter using
the upper 16 bits, since some flags are defined nowadays. The following the upper 16 bits, since some flags are defined nowadays. The following
defines provide a mask and shift to filter out this value. defines provide a mask and shift to filter out this value.
In 'Snapshot' mode the camera freezes its automatic exposure and colour In 'Snapshot' mode the camera freezes its automatic exposure and colour
balance controls. balance controls.
*/ */
#define PWC_FPS_SHIFT 16 #define PWC_FPS_SHIFT 16
...@@ -55,14 +68,26 @@ ...@@ -55,14 +68,26 @@
#define PWC_FPS_SNAPSHOT 0x00400000 #define PWC_FPS_SNAPSHOT 0x00400000
/* structure for transfering x & y coordinates */
struct pwc_coord
{
int x, y; /* guess what */
int size; /* size, or offset */
};
/* Used with VIDIOCPWCPROBE */
struct pwc_probe struct pwc_probe
{ {
char name[32]; char name[32];
int type; int type;
}; };
struct pwc_serial
{
char serial[30]; /* String with serial number. Contains terminating 0 */
};
/* pwc_whitebalance.mode values */ /* pwc_whitebalance.mode values */
#define PWC_WB_INDOOR 0 #define PWC_WB_INDOOR 0
#define PWC_WB_OUTDOOR 1 #define PWC_WB_OUTDOOR 1
...@@ -78,7 +103,6 @@ struct pwc_probe ...@@ -78,7 +103,6 @@ struct pwc_probe
otherwise undefined. otherwise undefined.
'read_red' and 'read_blue' are read-only. 'read_red' and 'read_blue' are read-only.
*/ */
struct pwc_whitebalance struct pwc_whitebalance
{ {
int mode; int mode;
...@@ -117,7 +141,7 @@ struct pwc_imagesize ...@@ -117,7 +141,7 @@ struct pwc_imagesize
#define PWC_MPT_TILT 0x02 #define PWC_MPT_TILT 0x02
#define PWC_MPT_TIMEOUT 0x04 /* for status */ #define PWC_MPT_TIMEOUT 0x04 /* for status */
/* Set angles; when absolute = 1, the angle is absolute and the /* Set angles; when absolute != 0, the angle is absolute and the
driver calculates the relative offset for you. This can only driver calculates the relative offset for you. This can only
be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns
absolute angles. absolute angles.
...@@ -127,18 +151,14 @@ struct pwc_mpt_angles ...@@ -127,18 +151,14 @@ struct pwc_mpt_angles
int absolute; /* write-only */ int absolute; /* write-only */
int pan; /* degrees * 100 */ int pan; /* degrees * 100 */
int tilt; /* degress * 100 */ int tilt; /* degress * 100 */
int zoom; /* N/A, set to -1 */
}; };
/* Range of angles of the camera, both horizontally and vertically. /* Range of angles of the camera, both horizontally and vertically.
The zoom is not used, maybe in the future...
*/ */
struct pwc_mpt_range struct pwc_mpt_range
{ {
int pan_min, pan_max; /* degrees * 100 */ int pan_min, pan_max; /* degrees * 100 */
int tilt_min, tilt_max; int tilt_min, tilt_max;
int zoom_min, zoom_max; /* -1, -1 */
}; };
struct pwc_mpt_status struct pwc_mpt_status
...@@ -149,6 +169,30 @@ struct pwc_mpt_status ...@@ -149,6 +169,30 @@ struct pwc_mpt_status
}; };
/* This is used for out-of-kernel decompression. With it, you can get
all the necessary information to initialize and use the decompressor
routines in standalone applications.
*/
struct pwc_video_command
{
int type; /* camera type (645, 675, 730, etc.) */
int release; /* release number */
int size; /* one of PSZ_* */
int alternate;
int command_len; /* length of USB video command */
unsigned char command_buf[13]; /* Actual USB video command */
int bandlength; /* >0 = compressed */
int frame_size; /* Size of one (un)compressed frame */
};
/* Flags for PWCX subroutines. Not all modules honour all flags. */
#define PWCX_FLAG_PLANAR 0x0001
#define PWCX_FLAG_BAYER 0x0008
/* IOCTL definitions */
/* Restore user settings */ /* Restore user settings */
#define VIDIOCPWCRUSER _IO('v', 192) #define VIDIOCPWCRUSER _IO('v', 192)
/* Save user settings */ /* Save user settings */
...@@ -169,16 +213,19 @@ struct pwc_mpt_status ...@@ -169,16 +213,19 @@ struct pwc_mpt_status
#define VIDIOCPWCGCQUAL _IOR('v', 195, int) #define VIDIOCPWCGCQUAL _IOR('v', 195, int)
/* Retrieve serial number of camera */
#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial)
/* This is a probe function; since so many devices are supported, it /* This is a probe function; since so many devices are supported, it
becomes difficult to include all the names in programs that want to becomes difficult to include all the names in programs that want to
check for the enhanced Philips stuff. So in stead, try this PROBE; check for the enhanced Philips stuff. So in stead, try this PROBE;
it returns a structure with the original name, and the corresponding it returns a structure with the original name, and the corresponding
Philips type. Philips type.
To use, fill the structure with zeroes, call PROBE and if that succeeds, To use, fill the structure with zeroes, call PROBE and if that succeeds,
compare the name with that returned from VIDIOCGCAP; they should be the compare the name with that returned from VIDIOCGCAP; they should be the
same. If so, you can be assured it is a Philips (OEM) cam and the type same. If so, you can be assured it is a Philips (OEM) cam and the type
is valid. is valid.
*/ */
#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe) #define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe)
/* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */ /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */
...@@ -225,5 +272,8 @@ struct pwc_mpt_status ...@@ -225,5 +272,8 @@ struct pwc_mpt_status
#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles) #define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles)
#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles) #define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles)
#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status) #define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status)
/* Get the USB set-video command; needed for initializing libpwcx */
#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command)
#endif #endif
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <linux/slab.h> #include <linux/slab.h>
#include "pwc.h" #include "pwc.h"
struct pwc_coord pwc_image_sizes[PSZ_MAX] = struct pwc_coord pwc_image_sizes[PSZ_MAX] =
{ {
{ 128, 96, 0 }, { 128, 96, 0 },
{ 160, 120, 0 }, { 160, 120, 0 },
...@@ -36,11 +36,30 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height) ...@@ -36,11 +36,30 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height)
{ {
int i, find; int i, find;
/* Make sure we don't go beyond our max size */ /* Make sure we don't go beyond our max size.
if (width > pdev->view_max.x || height > pdev->view_max.y) NB: we have different limits for RAW and normal modes. In case
return -1; you don't have the decompressor loaded or use RAW mode,
the maximum viewable size is smaller.
*/
if (pdev->vpalette == VIDEO_PALETTE_RAW)
{
if (width > pdev->abs_max.x || height > pdev->abs_max.y)
{
Debug("VIDEO_PALETTE_RAW: going beyond abs_max.\n");
return -1;
}
}
else
{
if (width > pdev->view_max.x || height > pdev->view_max.y)
{
Debug("VIDEO_PALETTE_ not RAW: going beyond view_max.\n");
return -1;
}
}
/* Find the largest size supported by the camera that fits into the /* Find the largest size supported by the camera that fits into the
requested size. requested size.
*/ */
find = -1; find = -1;
for (i = 0; i < PSZ_MAX; i++) { for (i = 0; i < PSZ_MAX; i++) {
...@@ -62,6 +81,8 @@ void pwc_construct(struct pwc_device *pdev) ...@@ -62,6 +81,8 @@ void pwc_construct(struct pwc_device *pdev)
pdev->view_min.y = 96; pdev->view_min.y = 96;
pdev->view_max.x = 352; pdev->view_max.x = 352;
pdev->view_max.y = 288; pdev->view_max.y = 288;
pdev->abs_max.x = 352;
pdev->abs_max.y = 288;
pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF; pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF;
pdev->vcinterface = 2; pdev->vcinterface = 2;
pdev->vendpoint = 4; pdev->vendpoint = 4;
...@@ -77,13 +98,14 @@ void pwc_construct(struct pwc_device *pdev) ...@@ -77,13 +98,14 @@ void pwc_construct(struct pwc_device *pdev)
if (pdev->decompressor != NULL) { if (pdev->decompressor != NULL) {
pdev->view_max.x = 640; pdev->view_max.x = 640;
pdev->view_max.y = 480; pdev->view_max.y = 480;
pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
} }
else { else {
pdev->view_max.x = 352; pdev->view_max.x = 352;
pdev->view_max.y = 288; pdev->view_max.y = 288;
pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF;
} }
pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
pdev->abs_max.x = 640;
pdev->abs_max.y = 480;
pdev->vcinterface = 3; pdev->vcinterface = 3;
pdev->vendpoint = 4; pdev->vendpoint = 4;
pdev->frame_header_size = 0; pdev->frame_header_size = 0;
...@@ -99,24 +121,26 @@ void pwc_construct(struct pwc_device *pdev) ...@@ -99,24 +121,26 @@ void pwc_construct(struct pwc_device *pdev)
if (pdev->decompressor != NULL) { if (pdev->decompressor != NULL) {
pdev->view_max.x = 640; pdev->view_max.x = 640;
pdev->view_max.y = 480; pdev->view_max.y = 480;
pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
} }
else { else {
/* Tell CIF, even though SIF really is the maximum, but some tools really need CIF */ /* We use CIF, not SIF since some tools really need CIF. So we cheat a bit. */
pdev->view_max.x = 352; pdev->view_max.x = 352;
pdev->view_max.y = 288; pdev->view_max.y = 288;
pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF;
} }
pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
pdev->abs_max.x = 640;
pdev->abs_max.y = 480;
pdev->vcinterface = 3; pdev->vcinterface = 3;
pdev->vendpoint = 5; pdev->vendpoint = 5;
pdev->frame_header_size = TOUCAM_HEADER_SIZE; pdev->frame_header_size = TOUCAM_HEADER_SIZE;
pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE; pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE;
break; break;
} }
pdev->vpalette = VIDEO_PALETTE_YUV420P; /* default */
pdev->view_min.size = pdev->view_min.x * pdev->view_min.y; pdev->view_min.size = pdev->view_min.x * pdev->view_min.y;
pdev->view_max.size = pdev->view_max.x * pdev->view_max.y; pdev->view_max.size = pdev->view_max.x * pdev->view_max.y;
/* length of image, in YUV format */ /* length of image, in YUV format; always allocate enough memory. */
pdev->len_per_image = (pdev->view_max.size * 3) / 2; pdev->len_per_image = (pdev->abs_max.x * pdev->abs_max.y * 3) / 2;
} }
/* Linux driver for Philips webcam /* Linux driver for Philips webcam
Decompression frontend. Decompression frontend.
(C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl) (C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
themselves. It also has a decompressor wrapper function. themselves. It also has a decompressor wrapper function.
*/ */
#include <asm/current.h>
#include <asm/types.h> #include <asm/types.h>
// #include <linux/sched.h>
#include "pwc.h" #include "pwc.h"
#include "pwc-uncompress.h" #include "pwc-uncompress.h"
...@@ -81,7 +83,6 @@ int pwc_decompress(struct pwc_device *pdev) ...@@ -81,7 +83,6 @@ int pwc_decompress(struct pwc_device *pdev)
u16 *src; u16 *src;
u16 *dsty, *dstu, *dstv; u16 *dsty, *dstu, *dstv;
if (pdev == NULL) if (pdev == NULL)
return -EFAULT; return -EFAULT;
#if defined(__KERNEL__) && defined(PWC_MAGIC) #if defined(__KERNEL__) && defined(PWC_MAGIC)
...@@ -97,16 +98,24 @@ int pwc_decompress(struct pwc_device *pdev) ...@@ -97,16 +98,24 @@ int pwc_decompress(struct pwc_device *pdev)
image = pdev->image_ptr[pdev->fill_image]; image = pdev->image_ptr[pdev->fill_image];
if (!image) if (!image)
return -EFAULT; return -EFAULT;
yuv = fbuf->data + pdev->frame_header_size; /* Skip header */ yuv = fbuf->data + pdev->frame_header_size; /* Skip header */
if (pdev->vbandlength == 0) {
/* Raw format; that's easy... */
if (pdev->vpalette == VIDEO_PALETTE_RAW)
{
memcpy(image, yuv, pdev->frame_size);
return 0;
}
if (pdev->vbandlength == 0) {
/* Uncompressed mode. We copy the data into the output buffer, /* Uncompressed mode. We copy the data into the output buffer,
using the viewport size (which may be larger than the image using the viewport size (which may be larger than the image
size). Unfortunately we have to do a bit of byte stuffing size). Unfortunately we have to do a bit of byte stuffing
to get the desired output format/size. to get the desired output format/size.
*/ */
/* /*
* We do some byte shuffling here to go from the * We do some byte shuffling here to go from the
* native format to YUV420P. * native format to YUV420P.
*/ */
src = (u16 *)yuv; src = (u16 *)yuv;
...@@ -140,15 +149,21 @@ int pwc_decompress(struct pwc_device *pdev) ...@@ -140,15 +149,21 @@ int pwc_decompress(struct pwc_device *pdev)
dstu += (stride >> 1); dstu += (stride >> 1);
} }
} }
else { else {
/* Compressed; the decompressor routines will write the data /* Compressed; the decompressor routines will write the data
in planar format immediately. in planar format immediately.
*/ */
int flags;
flags = PWCX_FLAG_PLANAR;
if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot)
flags |= PWCX_FLAG_BAYER;
if (pdev->decompressor) if (pdev->decompressor)
pdev->decompressor->decompress( pdev->decompressor->decompress(
&pdev->image, &pdev->view, &pdev->offset, &pdev->image, &pdev->view, &pdev->offset,
yuv, image, yuv, image,
1, flags,
pdev->decompress_data, pdev->vbandlength); pdev->decompress_data, pdev->vbandlength);
else else
return -ENXIO; /* No such device or address: missing decompressor */ return -ENXIO; /* No such device or address: missing decompressor */
......
...@@ -24,9 +24,15 @@ ...@@ -24,9 +24,15 @@
#define PWC_UNCOMPRESS_H #define PWC_UNCOMPRESS_H
#include <linux/config.h> #include <linux/config.h>
#include <linux/linkage.h>
#include <linux/list.h> #include <linux/list.h>
#include "pwc.h" #include "pwc-ioctl.h"
/* from pwc-dec.h */
#define PWCX_FLAG_PLANAR 0x0001
/* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -42,10 +48,10 @@ struct pwc_decompressor ...@@ -42,10 +48,10 @@ struct pwc_decompressor
int type; /* type of camera (645, 680, etc) */ int type; /* type of camera (645, 680, etc) */
int table_size; /* memory needed */ int table_size; /* memory needed */
void (* init)(int release, void *buffer, void *table); /* Initialization routine; should be called after each set_video_mode */ asmlinkage void (* init)(int type, int release, void *buffer, void *table); /* Initialization routine; should be called after each set_video_mode */
void (* exit)(void); /* Cleanup routine */ asmlinkage void (* exit)(void); /* Cleanup routine */
void (* decompress)(struct pwc_coord *image, struct pwc_coord *view, struct pwc_coord *offset, asmlinkage void (* decompress)(struct pwc_coord *image, struct pwc_coord *view, struct pwc_coord *offset,
void *src, void *dst, int planar, void *src, void *dst, int flags,
void *table, int bandlength); void *table, int bandlength);
void (* lock)(void); /* make sure module cannot be unloaded */ void (* lock)(void); /* make sure module cannot be unloaded */
void (* unlock)(void); /* release lock on module */ void (* unlock)(void); /* release lock on module */
......
...@@ -22,15 +22,15 @@ ...@@ -22,15 +22,15 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/smp_lock.h>
#include <linux/spinlock.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/spinlock.h>
#include <linux/videodev.h> #include <linux/videodev.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/smp_lock.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/errno.h> #include <asm/errno.h>
#include "pwc-uncompress.h"
#include "pwc-ioctl.h" #include "pwc-ioctl.h"
/* Defines and structures for the Philips webcam */ /* Defines and structures for the Philips webcam */
...@@ -65,9 +65,9 @@ ...@@ -65,9 +65,9 @@
#define FEATURE_MOTOR_PANTILT 0x0001 #define FEATURE_MOTOR_PANTILT 0x0001
/* Version block */ /* Version block */
#define PWC_MAJOR 8 #define PWC_MAJOR 9
#define PWC_MINOR 12 #define PWC_MINOR 0
#define PWC_VERSION "8.12" #define PWC_VERSION "9.0.1"
#define PWC_NAME "pwc" #define PWC_NAME "pwc"
/* Turn certain features on/off */ /* Turn certain features on/off */
...@@ -90,12 +90,6 @@ ...@@ -90,12 +90,6 @@
/* Absolute maximum number of buffers available for mmap() */ /* Absolute maximum number of buffers available for mmap() */
#define MAX_IMAGES 10 #define MAX_IMAGES 10
struct pwc_coord
{
int x, y; /* guess what */
int size; /* size, or offset */
};
/* The following structures were based on cpia.h. Why reinvent the wheel? :-) */ /* The following structures were based on cpia.h. Why reinvent the wheel? :-) */
struct pwc_iso_buf struct pwc_iso_buf
{ {
...@@ -118,7 +112,7 @@ struct pwc_frame_buf ...@@ -118,7 +112,7 @@ struct pwc_frame_buf
struct pwc_device struct pwc_device
{ {
struct video_device vdev; struct video_device *vdev;
#ifdef PWC_MAGIC #ifdef PWC_MAGIC
int magic; int magic;
#endif #endif
...@@ -128,6 +122,7 @@ struct pwc_device ...@@ -128,6 +122,7 @@ struct pwc_device
int type; /* type of cam (645, 646, 675, 680, 690, 720, 730, 740, 750) */ int type; /* type of cam (645, 646, 675, 680, 690, 720, 730, 740, 750) */
int release; /* release number */ int release; /* release number */
int features; /* feature bits */ int features; /* feature bits */
char serial[30]; /* serial number (string) */
int error_status; /* set when something goes wrong with the cam (unplugged, USB errors) */ int error_status; /* set when something goes wrong with the cam (unplugged, USB errors) */
int usb_init; /* set when the cam has been initialized over USB */ int usb_init; /* set when the cam has been initialized over USB */
...@@ -137,6 +132,7 @@ struct pwc_device ...@@ -137,6 +132,7 @@ struct pwc_device
int vcinterface; /* video control interface */ int vcinterface; /* video control interface */
int valternate; /* alternate interface needed */ int valternate; /* alternate interface needed */
int vframes, vsize; /* frames-per-second & size (see PSZ_*) */ int vframes, vsize; /* frames-per-second & size (see PSZ_*) */
int vpalette; /* palette: 420P, RAW or RGBBAYER */
int vframe_count; /* received frames */ int vframe_count; /* received frames */
int vframes_dumped; /* counter for dumped frames */ int vframes_dumped; /* counter for dumped frames */
int vframes_error; /* frames received in error */ int vframes_error; /* frames received in error */
...@@ -148,6 +144,9 @@ struct pwc_device ...@@ -148,6 +144,9 @@ struct pwc_device
char vsnapshot; /* snapshot mode */ char vsnapshot; /* snapshot mode */
char vsync; /* used by isoc handler */ char vsync; /* used by isoc handler */
char vmirror; /* for ToUCaM series */ char vmirror; /* for ToUCaM series */
int cmd_len;
unsigned char cmd_buf[13];
/* The image acquisition requires 3 to 4 steps: /* The image acquisition requires 3 to 4 steps:
1. data is gathered in short packets from the USB controller 1. data is gathered in short packets from the USB controller
...@@ -169,8 +168,9 @@ struct pwc_device ...@@ -169,8 +168,9 @@ struct pwc_device
struct pwc_frame_buf *full_frames, *full_frames_tail; /* all filled frames */ struct pwc_frame_buf *full_frames, *full_frames_tail; /* all filled frames */
struct pwc_frame_buf *fill_frame; /* frame currently being filled */ struct pwc_frame_buf *fill_frame; /* frame currently being filled */
struct pwc_frame_buf *read_frame; /* frame currently read by user process */ struct pwc_frame_buf *read_frame; /* frame currently read by user process */
int frame_size;
int frame_header_size, frame_trailer_size; int frame_header_size, frame_trailer_size;
int frame_size;
int frame_total_size; /* including header & trailer */
int drop_frames; int drop_frames;
#if PWC_DEBUG #if PWC_DEBUG
int sequence; /* Debugging aid */ int sequence; /* Debugging aid */
...@@ -187,7 +187,8 @@ struct pwc_device ...@@ -187,7 +187,8 @@ struct pwc_device
a gray or black border. view_min <= image <= view <= view_max; a gray or black border. view_min <= image <= view <= view_max;
*/ */
int image_mask; /* bitmask of supported sizes */ int image_mask; /* bitmask of supported sizes */
struct pwc_coord view_min, view_max; /* minimum and maximum sizes */ struct pwc_coord view_min, view_max; /* minimum and maximum viewable sizes */
struct pwc_coord abs_max; /* maximum supported size with compression */
struct pwc_coord image, view; /* image and viewport size */ struct pwc_coord image, view; /* image and viewport size */
struct pwc_coord offset; /* offset within the viewport */ struct pwc_coord offset; /* offset within the viewport */
...@@ -213,16 +214,6 @@ struct pwc_device ...@@ -213,16 +214,6 @@ struct pwc_device
#endif #endif
}; };
/* Enumeration of image sizes */
#define PSZ_SQCIF 0x00
#define PSZ_QSIF 0x01
#define PSZ_QCIF 0x02
#define PSZ_SIF 0x03
#define PSZ_CIF 0x04
#define PSZ_VGA 0x05
#define PSZ_MAX 6
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -259,7 +250,7 @@ extern int pwc_get_saturation(struct pwc_device *pdev); ...@@ -259,7 +250,7 @@ extern int pwc_get_saturation(struct pwc_device *pdev);
extern int pwc_set_saturation(struct pwc_device *pdev, int value); extern int pwc_set_saturation(struct pwc_device *pdev, int value);
extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value); extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value);
extern int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value); extern int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value);
extern int pwc_get_cmos_sensor(struct pwc_device *pdev); extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor);
/* Power down or up the camera; not supported by all models */ /* Power down or up the camera; not supported by all models */
extern int pwc_camera_power(struct pwc_device *pdev, int power); extern int pwc_camera_power(struct pwc_device *pdev, int power);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment