Commit 2b455db6 authored by Luc Saillard's avatar Luc Saillard Committed by Mauro Carvalho Chehab

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: default avatarLuc Saillard <luc@saillard.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent d9e12f25
...@@ -7,6 +7,7 @@ config USB_PWC ...@@ -7,6 +7,7 @@ config USB_PWC
* Philips PCA645, PCA646 * Philips PCA645, PCA646
* Philips PCVC675, PCVC680, PCVC690 * Philips PCVC675, PCVC680, PCVC690
* Philips PCVC720/40, PCVC730, PCVC740, PCVC750 * Philips PCVC720/40, PCVC730, PCVC740, PCVC750
* Philips SPC900NC
* Askey VC010 * Askey VC010
* Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro' * Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro'
and 'Orbit'/'Sphere' and 'Orbit'/'Sphere'
...@@ -19,10 +20,18 @@ config USB_PWC ...@@ -19,10 +20,18 @@ config USB_PWC
and never will be, but the 665 and 720/20 are supported by other and never will be, but the 665 and 720/20 are supported by other
drivers. drivers.
See <file:Documentation/usb/philips.txt> for more information and Some newer logitech webcams are not handled by this driver but by the
installation instructions. Usb Video Class driver (linux-uvc).
The built-in microphone is enabled by selecting USB Audio support. The built-in microphone is enabled by selecting USB Audio support.
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called pwc. module will be called pwc.
config USB_PWC_DEBUG
bool "USB Philips Cameras verbose debug"
depends USB_PWC
help
Say Y here in order to have the pwc driver generate verbose debugging
messages.
A special module options 'trace' is used to control the verbosity.
pwc-objs := pwc-if.o pwc-misc.o pwc-ctrl.o pwc-uncompress.o pwc-timon.o pwc-kiara.o pwc-objs := pwc-if.o pwc-misc.o pwc-ctrl.o pwc-v4l.o pwc-uncompress.o
pwc-objs += pwc-dec1.o pwc-dec23.o pwc-kiara.o pwc-timon.o
obj-$(CONFIG_USB_PWC) += pwc.o obj-$(CONFIG_USB_PWC) += pwc.o
ifeq ($(CONFIG_USB_PWC_DEBUG),y)
EXTRA_CFLAGS += -DCONFIG_PWC_DEBUG=1
else
EXTRA_CFLAGS += -DCONFIG_PWC_DEBUG=0
endif
This diff is collapsed.
/* Linux driver for Philips webcam
Decompression for chipset version 1
(C) 2004-2006 Luc Saillard (luc@saillard.org)
NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
driver and thus may have bugs that are not present in the original version.
Please send bug reports and support requests to <luc@saillard.org>.
The decompression routines have been implemented by reverse-engineering the
Nemosoft binary pwcx module. Caveat emptor.
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "pwc-dec1.h"
void pwc_dec1_init(int type, int release, void *buffer, void *table)
{
}
void pwc_dec1_exit(void)
{
}
int pwc_dec1_alloc(struct pwc_device *pwc)
{
pwc->decompress_data = kmalloc(sizeof(struct pwc_dec1_private), GFP_KERNEL);
if (pwc->decompress_data == NULL)
return -ENOMEM;
return 0;
}
/* Linux driver for Philips webcam
(C) 2004-2006 Luc Saillard (luc@saillard.org)
NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
driver and thus may have bugs that are not present in the original version.
Please send bug reports and support requests to <luc@saillard.org>.
The decompression routines have been implemented by reverse-engineering the
Nemosoft binary pwcx module. Caveat emptor.
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PWC_DEC1_H
#define PWC_DEC1_H
#include "pwc.h"
struct pwc_dec1_private
{
int version;
};
int pwc_dec1_alloc(struct pwc_device *pwc);
void pwc_dec1_init(int type, int release, void *buffer, void *private_data);
void pwc_dec1_exit(void);
#endif
This diff is collapsed.
/* Linux driver for Philips webcam
(C) 2004-2006 Luc Saillard (luc@saillard.org)
NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
driver and thus may have bugs that are not present in the original version.
Please send bug reports and support requests to <luc@saillard.org>.
The decompression routines have been implemented by reverse-engineering the
Nemosoft binary pwcx module. Caveat emptor.
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PWC_DEC23_H
#define PWC_DEC23_H
#include "pwc.h"
struct pwc_dec23_private
{
unsigned int scalebits;
unsigned int nbitsmask, nbits; /* Number of bits of a color in the compressed stream */
unsigned int reservoir;
unsigned int nbits_in_reservoir;
const unsigned char *stream;
int temp_colors[16];
unsigned char table_0004_pass1[16][1024];
unsigned char table_0004_pass2[16][1024];
unsigned char table_8004_pass1[16][256];
unsigned char table_8004_pass2[16][256];
unsigned int table_subblock[256][12];
unsigned char table_bitpowermask[8][256];
unsigned int table_d800[256];
unsigned int table_dc00[256];
};
int pwc_dec23_alloc(struct pwc_device *pwc);
int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd);
void pwc_dec23_exit(void);
void pwc_dec23_decompress(const struct pwc_device *pwc,
const void *src,
void *dst,
int flags);
#endif
/* vim: set cino= formatoptions=croql cindent shiftwidth=8 tabstop=8: */
This diff is collapsed.
This diff is collapsed.
/* Linux driver for Philips webcam /* Linux driver for Philips webcam
(C) 2004 Luc Saillard (luc@saillard.org) (C) 2004-2006 Luc Saillard (luc@saillard.org)
NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
driver and thus may have bugs that are not present in the original version. driver and thus may have bugs that are not present in the original version.
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#ifndef PWC_KIARA_H #ifndef PWC_KIARA_H
#define PWC_KIARA_H #define PWC_KIARA_H
#include "pwc-ioctl.h" #include <media/pwc-ioctl.h>
struct Kiara_table_entry struct Kiara_table_entry
{ {
...@@ -37,8 +37,8 @@ struct Kiara_table_entry ...@@ -37,8 +37,8 @@ struct Kiara_table_entry
unsigned char mode[12]; /* precomputed mode settings for cam */ unsigned char mode[12]; /* precomputed mode settings for cam */
}; };
const extern struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4]; extern const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4];
const extern unsigned int KiaraRomTable[8][2][16][8]; extern const unsigned int KiaraRomTable[8][2][16][8];
#endif #endif
......
/* Linux driver for Philips webcam /* Linux driver for Philips webcam
Various miscellaneous functions and tables. Various miscellaneous functions and tables.
(C) 1999-2003 Nemosoft Unv. (C) 1999-2003 Nemosoft Unv.
(C) 2004 Luc Saillard (luc@saillard.org) (C) 2004-2006 Luc Saillard (luc@saillard.org)
NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
driver and thus may have bugs that are not present in the original version. driver and thus may have bugs that are not present in the original version.
...@@ -24,18 +24,17 @@ ...@@ -24,18 +24,17 @@
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 "pwc.h" #include "pwc.h"
struct pwc_coord pwc_image_sizes[PSZ_MAX] = const struct pwc_coord pwc_image_sizes[PSZ_MAX] =
{ {
{ 128, 96, 0 }, { 128, 96, 0 }, /* sqcif */
{ 160, 120, 0 }, { 160, 120, 0 }, /* qsif */
{ 176, 144, 0 }, { 176, 144, 0 }, /* qcif */
{ 320, 240, 0 }, { 320, 240, 0 }, /* sif */
{ 352, 288, 0 }, { 352, 288, 0 }, /* cif */
{ 640, 480, 0 }, { 640, 480, 0 }, /* vga */
}; };
/* x,y -> PSZ_ */ /* x,y -> PSZ_ */
...@@ -52,7 +51,7 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height) ...@@ -52,7 +51,7 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height)
{ {
if (width > pdev->abs_max.x || height > pdev->abs_max.y) if (width > pdev->abs_max.x || height > pdev->abs_max.y)
{ {
Debug("VIDEO_PALETTE_RAW: going beyond abs_max.\n"); PWC_DEBUG_SIZE("VIDEO_PALETTE_RAW: going beyond abs_max.\n");
return -1; return -1;
} }
} }
...@@ -60,7 +59,7 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height) ...@@ -60,7 +59,7 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height)
{ {
if (width > pdev->view_max.x || height > pdev->view_max.y) if (width > pdev->view_max.x || height > pdev->view_max.y)
{ {
Debug("VIDEO_PALETTE_ not RAW: going beyond view_max.\n"); PWC_DEBUG_SIZE("VIDEO_PALETTE_not RAW: going beyond view_max.\n");
return -1; return -1;
} }
} }
...@@ -81,9 +80,8 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height) ...@@ -81,9 +80,8 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height)
/* initialize variables depending on type and decompressor*/ /* initialize variables depending on type and decompressor*/
void pwc_construct(struct pwc_device *pdev) void pwc_construct(struct pwc_device *pdev)
{ {
switch(pdev->type) { if (DEVICE_USE_CODEC1(pdev->type)) {
case 645:
case 646:
pdev->view_min.x = 128; pdev->view_min.x = 128;
pdev->view_min.y = 96; pdev->view_min.y = 96;
pdev->view_max.x = 352; pdev->view_max.x = 352;
...@@ -95,10 +93,23 @@ void pwc_construct(struct pwc_device *pdev) ...@@ -95,10 +93,23 @@ void pwc_construct(struct pwc_device *pdev)
pdev->vendpoint = 4; pdev->vendpoint = 4;
pdev->frame_header_size = 0; pdev->frame_header_size = 0;
pdev->frame_trailer_size = 0; pdev->frame_trailer_size = 0;
break;
case 675: } else if (DEVICE_USE_CODEC3(pdev->type)) {
case 680:
case 690: pdev->view_min.x = 160;
pdev->view_min.y = 120;
pdev->view_max.x = 640;
pdev->view_max.y = 480;
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->vendpoint = 5;
pdev->frame_header_size = TOUCAM_HEADER_SIZE;
pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE;
} else /* if (DEVICE_USE_CODEC2(pdev->type)) */ {
pdev->view_min.x = 128; pdev->view_min.x = 128;
pdev->view_min.y = 96; pdev->view_min.y = 96;
/* Anthill bug #38: PWC always reports max size, even without PWCX */ /* Anthill bug #38: PWC always reports max size, even without PWCX */
...@@ -111,30 +122,12 @@ void pwc_construct(struct pwc_device *pdev) ...@@ -111,30 +122,12 @@ void pwc_construct(struct pwc_device *pdev)
pdev->vendpoint = 4; pdev->vendpoint = 4;
pdev->frame_header_size = 0; pdev->frame_header_size = 0;
pdev->frame_trailer_size = 0; pdev->frame_trailer_size = 0;
break;
case 720:
case 730:
case 740:
case 750:
pdev->view_min.x = 160;
pdev->view_min.y = 120;
pdev->view_max.x = 640;
pdev->view_max.y = 480;
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->vendpoint = 5;
pdev->frame_header_size = TOUCAM_HEADER_SIZE;
pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE;
break;
} }
Debug("type = %d\n",pdev->type);
pdev->vpalette = VIDEO_PALETTE_YUV420P; /* default */ 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; always allocate enough memory. */ /* length of image, in YUV format; always allocate enough memory. */
pdev->len_per_image = (pdev->abs_max.x * pdev->abs_max.y * 3) / 2; pdev->len_per_image = PAGE_ALIGN((pdev->abs_max.x * pdev->abs_max.y * 3) / 2);
} }
This diff is collapsed.
/* Linux driver for Philips webcam /* Linux driver for Philips webcam
(C) 2004 Luc Saillard (luc@saillard.org) (C) 2004-2006 Luc Saillard (luc@saillard.org)
NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
driver and thus may have bugs that are not present in the original version. driver and thus may have bugs that are not present in the original version.
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#ifndef PWC_TIMON_H #ifndef PWC_TIMON_H
#define PWC_TIMON_H #define PWC_TIMON_H
#include "pwc-ioctl.h" #include <media/pwc-ioctl.h>
struct Timon_table_entry struct Timon_table_entry
{ {
...@@ -52,8 +52,8 @@ struct Timon_table_entry ...@@ -52,8 +52,8 @@ struct Timon_table_entry
unsigned char mode[13]; /* precomputed mode settings for cam */ unsigned char mode[13]; /* precomputed mode settings for cam */
}; };
const extern struct Timon_table_entry Timon_table[PSZ_MAX][6][4]; extern const struct Timon_table_entry Timon_table[PSZ_MAX][6][4];
const extern unsigned int TimonRomTable [16][2][16][8]; extern const unsigned int TimonRomTable [16][2][16][8];
#endif #endif
......
/* Linux driver for Philips webcam /* Linux driver for Philips webcam
Decompression frontend. Decompression frontend.
(C) 1999-2003 Nemosoft Unv. (C) 1999-2003 Nemosoft Unv.
(C) 2004 Luc Saillard (luc@saillard.org) (C) 2004-2006 Luc Saillard (luc@saillard.org)
NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
driver and thus may have bugs that are not present in the original version. driver and thus may have bugs that are not present in the original version.
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
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
vim: set ts=8:
*/ */
#include <asm/current.h> #include <asm/current.h>
...@@ -29,6 +31,8 @@ ...@@ -29,6 +31,8 @@
#include "pwc.h" #include "pwc.h"
#include "pwc-uncompress.h" #include "pwc-uncompress.h"
#include "pwc-dec1.h"
#include "pwc-dec23.h"
int pwc_decompress(struct pwc_device *pdev) int pwc_decompress(struct pwc_device *pdev)
{ {
...@@ -40,36 +44,36 @@ int pwc_decompress(struct pwc_device *pdev) ...@@ -40,36 +44,36 @@ int pwc_decompress(struct pwc_device *pdev)
if (pdev == NULL) if (pdev == NULL)
return -EFAULT; return -EFAULT;
#if defined(__KERNEL__) && defined(PWC_MAGIC)
if (pdev->magic != PWC_MAGIC) {
Err("pwc_decompress(): magic failed.\n");
return -EFAULT;
}
#endif
fbuf = pdev->read_frame; fbuf = pdev->read_frame;
if (fbuf == NULL) if (fbuf == NULL)
return -EFAULT; return -EFAULT;
image = pdev->image_ptr[pdev->fill_image]; image = pdev->image_data;
if (!image) image += pdev->images[pdev->fill_image].offset;
return -EFAULT;
yuv = fbuf->data + pdev->frame_header_size; /* Skip header */ yuv = fbuf->data + pdev->frame_header_size; /* Skip header */
/* Raw format; that's easy... */ /* Raw format; that's easy... */
if (pdev->vpalette == VIDEO_PALETTE_RAW) if (pdev->vpalette == VIDEO_PALETTE_RAW)
{ {
memcpy(image, yuv, pdev->frame_size); struct pwc_raw_frame *raw_frame = image;
raw_frame->type = cpu_to_le16(pdev->type);
raw_frame->vbandlength = cpu_to_le16(pdev->vbandlength);
/* cmd_buf is always 4 bytes, but sometimes, only the
* first 3 bytes is filled (Nala case). We can
* determine this using the type of the webcam */
memcpy(raw_frame->cmd, pdev->cmd_buf, 4);
memcpy(raw_frame+1, yuv, pdev->frame_size);
return 0; return 0;
} }
if (pdev->vbandlength == 0) { if (pdev->vbandlength == 0) {
/* Uncompressed mode. We copy the data into the output buffer, /* Uncompressed mode.
using the viewport size (which may be larger than the image * We copy the data into the output buffer, using the viewport
size). Unfortunately we have to do a bit of byte stuffing * size (which may be larger than the image size).
to get the desired output format/size. * Unfortunately we have to do a bit of byte stuffing 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.
*/ */
...@@ -103,44 +107,32 @@ int pwc_decompress(struct pwc_device *pdev) ...@@ -103,44 +107,32 @@ int pwc_decompress(struct pwc_device *pdev)
else else
dstu += (stride >> 1); dstu += (stride >> 1);
} }
return 0;
} }
else {
/* Compressed; the decompressor routines will write the data
in planar format immediately.
*/
int flags;
flags = PWCX_FLAG_PLANAR; /*
if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot) * Compressed;
{ * the decompressor routines will write the data in planar format
printk(KERN_ERR "pwc: Mode Bayer is not supported for now\n"); * immediately.
flags |= PWCX_FLAG_BAYER; */
if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot) {
PWC_ERROR("Mode Bayer is not supported for now\n");
/* flags |= PWCX_FLAG_BAYER; */
return -ENXIO; /* No such device or address: missing decompressor */ return -ENXIO; /* No such device or address: missing decompressor */
} }
#if 0 if (DEVICE_USE_CODEC1(pdev->type)) {
switch (pdev->type)
{
case 675:
case 680:
case 690:
case 720:
case 730:
case 740:
case 750:
pwc_dec23_decompress(&pdev->image, &pdev->view,
&pdev->offset, yuv, image, flags,
pdev->decompress_data, pdev->vbandlength);
break;
case 645:
case 646:
/* TODO & FIXME */ /* TODO & FIXME */
return -ENXIO; /* Missing decompressor */ PWC_ERROR("This chipset is not supported for now\n");
break; return -ENXIO; /* No such device or address: missing decompressor */
}
#endif } else {
pwc_dec23_decompress(pdev, yuv, image, PWCX_FLAG_PLANAR);
} }
return 0; return 0;
} }
/* vim: set cino= formatoptions=croql cindent shiftwidth=8 tabstop=8: */
/* (C) 1999-2003 Nemosoft Unv. /* (C) 1999-2003 Nemosoft Unv.
(C) 2004 Luc Saillard (luc@saillard.org) (C) 2004-2006 Luc Saillard (luc@saillard.org)
NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
driver and thus may have bugs that are not present in the original version. driver and thus may have bugs that are not present in the original version.
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <linux/config.h> #include <linux/config.h>
#include "pwc-ioctl.h" #include <media/pwc-ioctl.h>
/* from pwc-dec.h */ /* from pwc-dec.h */
#define PWCX_FLAG_PLANAR 0x0001 #define PWCX_FLAG_PLANAR 0x0001
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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