Commit d43fa32f authored by Jean-Francois Moine's avatar Jean-Francois Moine Committed by Mauro Carvalho Chehab

V4L/DVB (8156): Many bug fixes, zc3xx added.

Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 4aa0d037
obj-$(CONFIG_GSPCA) += gspca_main.o gspca_pac207.o gspca_stk014.o obj-$(CONFIG_GSPCA) += gspca_main.o \
gspca_pac207.o gspca_stk014.o gspca_zc3xx.o
gspca_main-objs := gspca.o gspca_main-objs := gspca.o
gspca_pac207-objs := pac207.o gspca_pac207-objs := pac207.o
gspca_stk014-objs := stk014.o gspca_stk014-objs := stk014.o
gspca_zc3xx-objs := zc3xx.o
This diff is collapsed.
...@@ -25,6 +25,7 @@ extern int gspca_debug; ...@@ -25,6 +25,7 @@ extern int gspca_debug;
#define D_PACK 0x20 #define D_PACK 0x20
#define D_USBI 0x40 #define D_USBI 0x40
#define D_USBO 0x80 #define D_USBO 0x80
#define D_V4L2 0x0100
#else #else
#define PDEBUG(level, fmt, args...) #define PDEBUG(level, fmt, args...)
#endif #endif
...@@ -46,9 +47,9 @@ extern int gspca_debug; ...@@ -46,9 +47,9 @@ extern int gspca_debug;
#define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */ #define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */
/* ISOC transfers */ /* ISOC transfers */
#define NURBS 4 /* number of URBs */ #define MAX_NURBS 32 /* max number of URBs (read & userptr) */
#define ISO_MAX_PKT 32 /* max number of packets in an ISOC transfer */ #define ISO_MAX_PKT 32 /* max number of packets in an ISOC transfer */
#define ISO_MAX_SIZE 0x10000 /* max size of one URB buffer (64 Kb) */ #define ISO_MAX_SIZE 0x8000 /* max size of one URB buffer (32 Kb) */
/* device information - set at probe time */ /* device information - set at probe time */
struct cam_mode { struct cam_mode {
...@@ -123,13 +124,14 @@ struct gspca_frame { ...@@ -123,13 +124,14 @@ struct gspca_frame {
struct gspca_dev { struct gspca_dev {
struct video_device vdev; /* !! must be the first item */ struct video_device vdev; /* !! must be the first item */
struct file_operations fops;
struct usb_device *dev; struct usb_device *dev;
struct file *capt_file; /* file doing video capture */ struct file *capt_file; /* file doing video capture */
struct cam cam; /* device information */ struct cam cam; /* device information */
const struct sd_desc *sd_desc; /* subdriver description */ const struct sd_desc *sd_desc; /* subdriver description */
struct urb *urb[NURBS]; struct urb *urb[MAX_NURBS];
__u8 *frbuf; /* buffer for nframes */ __u8 *frbuf; /* buffer for nframes */
struct gspca_frame frame[GSPCA_MAX_FRAMES]; struct gspca_frame frame[GSPCA_MAX_FRAMES];
...@@ -155,15 +157,21 @@ struct gspca_dev { ...@@ -155,15 +157,21 @@ struct gspca_dev {
struct mutex queue_lock; /* ISOC queue protection */ struct mutex queue_lock; /* ISOC queue protection */
__u32 sequence; /* frame sequence number */ __u32 sequence; /* frame sequence number */
char streaming; char streaming;
char users; /* # open */ char users; /* number of opens */
char present; /* device connected */ char present; /* device connected */
char nbufread; /* number of buffers for read() */ char nbufread; /* number of buffers for read() */
char nurbs; /* number of allocated URBs */
char memory; /* memory type (V4L2_MEMORY_xxx) */
__u8 urb_in; /* URB pointers - used when !mmap */
__u8 urb_out;
__u8 nbalt; /* number of USB alternate settings */
}; };
int gspca_dev_probe(struct usb_interface *intf, int gspca_dev_probe(struct usb_interface *intf,
const struct usb_device_id *id, const struct usb_device_id *id,
const struct sd_desc *sd_desc, const struct sd_desc *sd_desc,
int dev_size); int dev_size,
struct module *module);
void gspca_disconnect(struct usb_interface *intf); void gspca_disconnect(struct usb_interface *intf);
struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev, struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
int packet_type, int packet_type,
......
...@@ -265,7 +265,7 @@ static unsigned char eoh[] = { ...@@ -265,7 +265,7 @@ static unsigned char eoh[] = {
0x02, 0x11, 0x01, /* samples CbCr - quant CbCr */ 0x02, 0x11, 0x01, /* samples CbCr - quant CbCr */
0x03, 0x11, 0x01, 0x03, 0x11, 0x01,
0xff, 0xda, 0x00, 0x0c, /* SOS (start of scan */ 0xff, 0xda, 0x00, 0x0c, /* SOS (start of scan) */
0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00
}; };
#endif #endif
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
#include "gspca.h" #include "gspca.h"
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 1) #define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 2, 15)
static const char version[] = "0.1.1"; static const char version[] = "0.2.15";
MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>"); MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>");
MODULE_DESCRIPTION("Pixart PAC207"); MODULE_DESCRIPTION("Pixart PAC207");
...@@ -188,7 +188,8 @@ static const __u8 pac207_sensor_init[][8] = { ...@@ -188,7 +188,8 @@ static const __u8 pac207_sensor_init[][8] = {
/* 48 reg_72 Rate Control end BalSize_4a =0x36 */ /* 48 reg_72 Rate Control end BalSize_4a =0x36 */
static const __u8 PacReg72[] = { 0x00, 0x00, 0x36, 0x00 }; static const __u8 PacReg72[] = { 0x00, 0x00, 0x36, 0x00 };
static const char pac207_sof_marker[5] = { 0xff, 0xff, 0x00, 0xff, 0x96 }; static const unsigned char pac207_sof_marker[5] =
{ 0xff, 0xff, 0x00, 0xff, 0x96 };
int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index, int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index,
const u8 *buffer, u16 length) const u8 *buffer, u16 length)
...@@ -330,8 +331,9 @@ static void sd_start(struct gspca_dev *gspca_dev) ...@@ -330,8 +331,9 @@ static void sd_start(struct gspca_dev *gspca_dev)
if (gspca_dev->width == 176) { /* 176x144 */ if (gspca_dev->width == 176) { /* 176x144 */
mode |= 0x01; mode |= 0x01;
PDEBUG(D_STREAM, "pac207_start mode 176x144"); PDEBUG(D_STREAM, "pac207_start mode 176x144");
} else/* 352x288 */ } else { /* 352x288 */
PDEBUG(D_STREAM, "pac207_start mode 352x288"); PDEBUG(D_STREAM, "pac207_start mode 352x288");
}
pac207_write_reg(gspca_dev, 0x41, mode); pac207_write_reg(gspca_dev, 0x41, mode);
pac207_write_reg(gspca_dev, 0x13, 0x01); /* Bit 0, auto clear */ pac207_write_reg(gspca_dev, 0x13, 0x01); /* Bit 0, auto clear */
...@@ -425,7 +427,7 @@ void init_pixart_decoder(void) ...@@ -425,7 +427,7 @@ void init_pixart_decoder(void)
} }
/* auto gain and exposure algorithm based on the knee algorithm described here: /* auto gain and exposure algorithm based on the knee algorithm described here:
http://ytse.tricolour.net/docs/LowLightOptimization.html */ * <http://ytse.tricolour.net/docs/LowLightOptimization.html> */
static void pac207_do_auto_gain(struct gspca_dev *gspca_dev) static void pac207_do_auto_gain(struct gspca_dev *gspca_dev)
{ {
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
...@@ -508,9 +510,10 @@ static unsigned char *pac207_find_sof(struct gspca_dev *gspca_dev, ...@@ -508,9 +510,10 @@ static unsigned char *pac207_find_sof(struct gspca_dev *gspca_dev,
sd->sof_read = 0; sd->sof_read = 0;
return m + i + 1; return m + i + 1;
} }
} else } else {
sd->sof_read = 0; sd->sof_read = 0;
} }
}
return NULL; return NULL;
} }
...@@ -556,9 +559,9 @@ static int pac207_decompress_row(struct gspca_dev *gspca_dev, ...@@ -556,9 +559,9 @@ static int pac207_decompress_row(struct gspca_dev *gspca_dev,
decoder_state->line_read++; decoder_state->line_read++;
decoder_state->get_abs = 0; decoder_state->get_abs = 0;
} else { } else {
if (table[code].is_abs) if (table[code].is_abs) {
decoder_state->get_abs = 1; decoder_state->get_abs = 1;
else { } else {
/* relative to left pixel */ /* relative to left pixel */
val = outp[-2] + val = outp[-2] +
table[code].val; table[code].val;
...@@ -894,13 +897,13 @@ static struct sd_desc sd_desc = { ...@@ -894,13 +897,13 @@ static struct sd_desc sd_desc = {
#define DVNM(name) .driver_info = (kernel_ulong_t) name #define DVNM(name) .driver_info = (kernel_ulong_t) name
static __devinitdata struct usb_device_id device_table[] = { static __devinitdata struct usb_device_id device_table[] = {
{USB_DEVICE(0x041e, 0x4028), DVNM("Creative Webcam Vista Plus")}, {USB_DEVICE(0x041e, 0x4028), DVNM("Creative Webcam Vista Plus")},
{USB_DEVICE(0x093a, 0x2460), DVNM("PAC207 Qtec Webcam 100")}, {USB_DEVICE(0x093a, 0x2460), DVNM("Q-Tec Webcam 100")},
{USB_DEVICE(0x093a, 0x2463), DVNM("Philips spc200nc pac207")}, {USB_DEVICE(0x093a, 0x2463), DVNM("Philips spc200nc pac207")},
{USB_DEVICE(0x093a, 0x2464), DVNM("Labtec Webcam 1200")}, {USB_DEVICE(0x093a, 0x2464), DVNM("Labtec Webcam 1200")},
{USB_DEVICE(0x093a, 0x2468), DVNM("PAC207")}, {USB_DEVICE(0x093a, 0x2468), DVNM("PAC207")},
{USB_DEVICE(0x093a, 0x2470), DVNM("Genius GF112")}, {USB_DEVICE(0x093a, 0x2470), DVNM("Genius GF112")},
{USB_DEVICE(0x093a, 0x2471), DVNM("PAC207 Genius VideoCam ge111")}, {USB_DEVICE(0x093a, 0x2471), DVNM("Genius VideoCam GE111")},
{USB_DEVICE(0x093a, 0x2472), DVNM("PAC207 Genius VideoCam ge110")}, {USB_DEVICE(0x093a, 0x2472), DVNM("Genius VideoCam GE110")},
{USB_DEVICE(0x2001, 0xf115), DVNM("D-Link DSB-C120")}, {USB_DEVICE(0x2001, 0xf115), DVNM("D-Link DSB-C120")},
{} {}
}; };
...@@ -910,8 +913,8 @@ MODULE_DEVICE_TABLE(usb, device_table); ...@@ -910,8 +913,8 @@ MODULE_DEVICE_TABLE(usb, device_table);
static int sd_probe(struct usb_interface *intf, static int sd_probe(struct usb_interface *intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
PDEBUG(D_PROBE, "camera probe"); return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd)); THIS_MODULE);
} }
static struct usb_driver sd_driver = { static struct usb_driver sd_driver = {
......
/* /*
* Syntek DV4000 (STK014) subdriver * Syntek DV4000 (STK014) subdriver
* *
* Copyright (C) Jean-Francois Moine (http://moinejf.free.fr) * Copyright (C) 2008 Jean-Francois Moine (http://moinejf.free.fr)
* *
* 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
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
* 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
*
*/ */
#define MODULE_NAME "stk014" #define MODULE_NAME "stk014"
...@@ -24,8 +23,8 @@ ...@@ -24,8 +23,8 @@
#include "gspca.h" #include "gspca.h"
#include "jpeg.h" #include "jpeg.h"
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 1, 0) #define DRIVER_VERSION_NUMBER KERNEL_VERSION(0, 2, 7)
static const char version[] = "0.1.0"; static const char version[] = "0.2.7";
MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver"); MODULE_DESCRIPTION("Syntek DV4000 (STK014) USB Camera Driver");
...@@ -389,64 +388,32 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -389,64 +388,32 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
unsigned char *data, /* isoc packet */ unsigned char *data, /* isoc packet */
int len) /* iso packet length */ int len) /* iso packet length */
{ {
int l;
static unsigned char ffd9[] = {0xff, 0xd9}; static unsigned char ffd9[] = {0xff, 0xd9};
/* a frame starts with: /* a frame starts with:
* - 0xff 0xfe * - 0xff 0xfe
* - 0x08 0x00 // length (little endian ?!) * - 0x08 0x00 - length (little endian ?!)
* - 4 bytes = size of whole frame (big endian - including header) * - 4 bytes = size of whole frame (BE - including header)
* - 0x00 0x0c * - 0x00 0x0c
* - 0xff 0xd8 * - 0xff 0xd8
* - .. JPEG image with escape sequences (ff 00) * - .. JPEG image with escape sequences (ff 00)
* (without ending - ff d9)
*/ */
if (data[0] == 0xff && data[1] == 0xfe) { if (data[0] == 0xff && data[1] == 0xfe) {
if (gspca_dev->last_packet_type == INTER_PACKET) { frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
PDEBUG(D_ERR|D_FRAM, "sof actual l: %d init l: %d", ffd9, 2);
frame->data_end - frame->data,
frame->v4l2_buf.bytesused);
}
/* put the JPEG headaer */ /* put the JPEG 411 header */
jpeg_put_header(gspca_dev, frame, sd_quant, 0x22); jpeg_put_header(gspca_dev, frame, sd_quant, 0x22);
/* beginning of the frame */ /* beginning of the frame */
#define STKHDRSZ 12 #define STKHDRSZ 12
l = (data[4] << 24) /* frame size */
+ (data[5] << 16)
+ (data[6] << 8)
+ data[7]
- STKHDRSZ
+ (frame->data_end - frame->data)
+ 2; /* EOF (ff d9) */
gspca_frame_add(gspca_dev, INTER_PACKET, frame, gspca_frame_add(gspca_dev, INTER_PACKET, frame,
data + STKHDRSZ, len - STKHDRSZ); data + STKHDRSZ, len - STKHDRSZ);
#undef STKHDRSZ #undef STKHDRSZ
frame->v4l2_buf.bytesused = l;
return;
}
if (gspca_dev->last_packet_type != INTER_PACKET) {
if (gspca_dev->last_packet_type == LAST_PACKET) {
PDEBUG(D_ERR|D_PACK, "mof actual l: %d init l: %d",
frame->data_end - frame->data,
frame->v4l2_buf.bytesused);
}
return; return;
} }
/* intermediate packet */
l = frame->data_end - frame->data;
if (len < frame->v4l2_buf.bytesused - 2 - l) {
gspca_frame_add(gspca_dev, INTER_PACKET, frame,
data, len);
return;
}
/* last packet */
if (len > frame->v4l2_buf.bytesused - 2 - l)
len = frame->v4l2_buf.bytesused - 2 - l;
gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
gspca_frame_add(gspca_dev, LAST_PACKET, frame, ffd9, 2);
} }
static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
...@@ -529,8 +496,8 @@ MODULE_DEVICE_TABLE(usb, device_table); ...@@ -529,8 +496,8 @@ MODULE_DEVICE_TABLE(usb, device_table);
static int sd_probe(struct usb_interface *intf, static int sd_probe(struct usb_interface *intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
PDEBUG(D_PROBE, "camera probe"); return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd)); THIS_MODULE);
} }
static struct usb_driver sd_driver = { static struct usb_driver sd_driver = {
......
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