This is the W996[87]CF driver source code in pure text, for submission to
the Linux kernel 2.4 and 2.6.

The code to be submitted has been sent to the USB manteiner as well.

There are six files below (separated by "-" lines), in order:
1) w9968cf.h
2) w9968cf.externaldef.h
3) w9968cf_decoder.h
4) w9968cf.c (for Linux 2.6)
5) w9968cf.c (for Linux 2.4)
6) w9968cf.txt

The optional module, which provides some video post-processing functions like
video decoding, colour conversion and upscaling, has not been attached to this
text, since they are usually done in user-space context.
The complete source code can be found at: http://go.lamarinapunto.com .

---------------------------------- w9968cf.h ----------------------------------

/***************************************************************************
 * Video4Linux driver for W996[87]CF JPEG USB Dual Mode Camera Chip.       *
 *                                                                         *
 * Copyright (C) 2002 2003 by Luca Risolia <[EMAIL PROTECTED]>            *
 *                                                                         *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.               *
 ***************************************************************************/

#ifndef _W9968CF_H_
#define _W9968CF_H_

#include <linux/videodev.h>
#include <linux/usb.h>
#include <linux/i2c.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/wait.h>
#include <linux/config.h>
#include <asm/semaphore.h>
#include <asm/types.h>

#include "w9968cf_externaldef.h"


/****************************************************************************
 * Default values                                                           *
 ****************************************************************************/

#define W9968CF_PPMOD_LOAD     1  /* automatic 'w9968cf-pp' module loading */

/* Comment/uncomment the following line to enable/disable debugging messages */
#define W9968CF_DEBUG

/* These have effect only if W9968CF_DEBUG is defined */
#define W9968CF_DEBUG_LEVEL    2 /* from 0 to 6. 0 for no debug informations */
#define W9968CF_SPECIFIC_DEBUG 0 /* 0 or 1 */

#define W9968CF_MAX_DEVICES    32
#define W9968CF_SIMCAMS        W9968CF_MAX_DEVICES /* simultaneous cameras */

#define W9968CF_MAX_BUFFERS   32
#define W9968CF_BUFFERS       2 /* n. of frame buffers from 2 to MAX_BUFFERS */

/* Maximum data payload sizes in bytes for alternate settings */
static const u16 wMaxPacketSize[] = {1023, 959, 895, 831, 767, 703, 639, 575,
                                      511, 447, 383, 319, 255, 191, 127,  63};
#define W9968CF_PACKET_SIZE      1023 /* according to wMaxPacketSizes[] */
#define W9968CF_MIN_PACKET_SIZE  63 /* minimum value */
#define W9968CF_ISO_PACKETS      5 /* n.of packets for isochronous transfers */
#define W9968CF_USB_CTRL_TIMEOUT HZ /* timeout for usb control commands */
#define W9968CF_URBS             2 /* n. of scheduled URBs for ISO transfer */

#define W9968CF_I2C_BUS_DELAY    4 /* delay in us for I2C bit r/w operations */
#define W9968CF_I2C_RW_RETRIES   10 /* number of max I2C r/w retries */
#define W9968CF_I2C_RW_DELAY     20 /* delay in ms after each retry */

/* Available video formats */
struct w9968cf_format {
        const u16 palette;
        const u16 depth;
        const u8 compression;
};

static const struct w9968cf_format w9968cf_formatlist[] = {
        { VIDEO_PALETTE_UYVY,    16, 0 }, /* original video */
        { VIDEO_PALETTE_YUV422P, 16, 1 }, /* with JPEG compression */
        { VIDEO_PALETTE_YUV420P, 12, 1 }, /* with JPEG compression */
        { VIDEO_PALETTE_YUV420,  12, 1 }, /* same as YUV420P */
        { VIDEO_PALETTE_YUYV,    16, 0 }, /* software conversion */
        { VIDEO_PALETTE_YUV422,  16, 0 }, /* software conversion */
        { VIDEO_PALETTE_GREY,     8, 0 }, /* software conversion */
        { VIDEO_PALETTE_RGB555,  16, 0 }, /* software conversion */
        { VIDEO_PALETTE_RGB565,  16, 0 }, /* software conversion */
        { VIDEO_PALETTE_RGB24,   24, 0 }, /* software conversion */
        { VIDEO_PALETTE_RGB32,   32, 0 }, /* software conversion */
        { 0,                      0, 0 }  /* 0 is a terminating entry */
};

#define W9968CF_DECOMP_MODE      2 /* decomp:0=disable,1=force,2=any formats */
#define W9968CF_NODECOMP_PALETTE VIDEO_PALETTE_UYVY    /* when decomp = 0 */
#define W9968CF_DECOMP_PALETTE   VIDEO_PALETTE_YUV420P /* when decomp = 1 */
#define W9968CF_PALETTE          VIDEO_PALETTE_UYVY    /* when decomp = 2 */

#define W9968CF_FORCE_RGB        0  /* read RGB instead of BGR, yes=1/no=0 */

#define W9968CF_MAX_WIDTH      800 /* should be >= 640 */
#define W9968CF_MAX_HEIGHT     600 /* should be >= 480 */
#define W9968CF_WIDTH          320 /* from 128 to 352, multiple of 16 */
#define W9968CF_HEIGHT         240 /* from  96 to 288, multiple of 16 */

#define W9968CF_CLAMPING       0 /* 0 disable, 1 enable video data clamping */
#define W9968CF_FILTER_TYPE    0 /* 0 disable  1 (1-2-1), 2 (2-3-6-3-2) */
#define W9968CF_DOUBLE_BUFFER  1 /* 0 disable, 1 enable double buffer */
#define W9968CF_LARGEVIEW      1 /* 0 disable, 1 enable */
#define W9968CF_SOFT_SCALING   0 /* 0 disable, 1 enable */

#define W9968CF_SENSOR_MONO    0 /* 0 not monochrome, 1 monochrome sensor */
#define W9968CF_BRIGHTNESS     31000 /* from 0 to 65535 */
#define W9968CF_HUE            32768 /* from 0 to 65535 */
#define W9968CF_COLOUR         32768 /* from 0 to 65535 */
#define W9968CF_CONTRAST       50000 /* from 0 to 65535 */
#define W9968CF_WHITENESS      32768 /* from 0 to 65535 */

#define W9968CF_AUTOBRIGHT     0 /* 0 disable, 1 enable automatic brightness */
#define W9968CF_AUTOEXP        1 /* 0 disable, 1 enable automatic exposure */
#define W9968CF_LIGHTFREQ      50 /* light frequency. 50Hz (Europe) or 60Hz */
#define W9968CF_BANDINGFILTER  0 /* 0 disable, 1 enable banding filter */
#define W9968CF_BACKLIGHT      0 /* 0 or 1, 1=object is lit from behind */
#define W9968CF_MIRROR         0 /* 0 or 1 [don't] reverse image horizontally*/

#define W9968CF_CLOCKDIV         -1 /* -1 = automatic clock divisor */
#define W9968CF_DEF_CLOCKDIVISOR  0 /* default sensor clock divisor value */


/****************************************************************************
 * Globals                                                                  *
 ****************************************************************************/

#define W9968CF_MODULE_NAME     "V4L driver for W996[87]CF JPEG USB " \
                                "Dual Mode Camera Chip"
#define W9968CF_MODULE_VERSION  "v1.21 for Linux 2.6"
#define W9968CF_MODULE_AUTHOR   "(C) 2002 2003 Luca Risolia"
#define W9968CF_AUTHOR_EMAIL    "<[EMAIL PROTECTED]>"

static u8 w9968cf_ppmod_present; /* status flag: yes=1, no=0 */

static const struct usb_device_id winbond_id_table[] = {
        {
                /* Creative Labs Video Blaster WebCam Go Plus */
                USB_DEVICE(0x041e, 0x4003),
                .driver_info = (unsigned long)"w9968cf",
        },
        {
                /* Generic W996[87]CF JPEG USB Dual Mode Camera */
                USB_DEVICE(0x1046, 0x9967),
                .driver_info = (unsigned long)"w9968cf",
        },
        { } /* terminating entry */
};

MODULE_DEVICE_TABLE(usb, winbond_id_table);

/* W996[87]CF camera models, internal ids: */
enum w9968cf_model_id {
        W9968CF_MOD_GENERIC = 1, /* Generic W996[87]CF based device */
        W9968CF_MOD_CLVBWGP = 11,/*Creative Labs Video Blaster WebCam Go Plus*/
        W9968CF_MOD_ADPA5R = 21, /* Aroma Digi Pen ADG-5000 Refurbished */
        W9986CF_MOD_AU = 31,     /* AVerTV USB */
        W9968CF_MOD_CLVBWG = 34, /* Creative Labs Video Blaster WebCam Go */
        W9968CF_MOD_DLLDK = 37,  /* Die Lebon LDC-D35A Digital Kamera */
        W9968CF_MOD_EEEMC = 40,   /* Ezonics EZ-802 EZMega Cam */
        W9968CF_MOD_ODPVDMPC = 43,/* OPCOM Digi Pen VGA Dual Mode Pen Camera */
};

enum w9968cf_frame_status {
        F_READY,            /* finished grabbing & ready to be read/synced */
        F_GRABBING,         /* in the process of being grabbed into */
        F_ERROR,            /* something bad happened while processing */
        F_UNUSED            /* unused (no VIDIOCMCAPTURE) */
};

struct w9968cf_frame_t {
        void* buffer;
        u32 length;
        enum w9968cf_frame_status status;
        struct w9968cf_frame_t* next;
        u8 queued;
};

enum w9968cf_pp_flag {
        PP_NONE = 0x00,
        PP_UPSCALE = 0x01,
        PP_SWAP_YUV_BYTES = 0x02,
        PP_DECOMPRESSION = 0x04,
        PP_UYVY_TO_RGBX = 0x08,
};

struct list_head w9968cf_dev_list; /* head of V4L registered cameras list */
LIST_HEAD(w9968cf_dev_list);
struct semaphore w9968cf_devlist_sem; /* semaphore for list traversal */

/* Main device driver structure */
struct w9968cf_device {
        enum w9968cf_model_id id;   /* private device identifier */

        struct video_device v4ldev; /* V4L structure */
        struct list_head v4llist;   /* entry of the list of V4L cameras */

        struct usb_device* usbdev;           /* -> main USB structure */
        struct urb* urb[W9968CF_URBS];       /* -> USB request block structs */
        void* transfer_buffer[W9968CF_URBS]; /* -> ISO transfer buffers */
        u16* control_buffer;                 /* -> buffer for control req.*/
        u16* data_buffer;                    /* -> data to send to the FSB */

        struct w9968cf_frame_t frame[W9968CF_MAX_BUFFERS];
        struct w9968cf_frame_t frame_tmp;  /* temporary frame */
        struct w9968cf_frame_t* frame_current; /* -> frame being grabbed */
        struct w9968cf_frame_t* requested_frame[W9968CF_MAX_BUFFERS];
        void* pp_buffer; /* -> helper buffer for post-processing routines */

        u8 max_buffers,   /* number of requested buffers */
           force_palette, /* yes=1/no=0 */
           force_rgb,     /* read RGB instead of BGR, yes=1, no=0 */
           double_buffer, /* hardware double buffering yes=1/no=0 */
           clamping,      /* video data clamping yes=1/no=0 */
           filter_type,   /* 0=disabled, 1=3 tap, 2=5 tap filter */
           capture,       /* 0=disabled, 1=enabled */
           largeview,     /* 0=disabled, 1=enabled */
           decomp_mode,   /* 0=disabled, 1=forced, 2=allowed */
           soft_scaling;  /* software image scaling, 0=enabled, 1=disabled */

        struct video_picture picture; /* current window settings */
        struct video_window window;   /* current picture settings */

        u16 hw_depth,    /* depth (used by the chip) */
            hw_palette,  /* palette (used by the chip) */
            hw_width,    /* width (used by the chip) */
            hw_height,   /* height (used by the chip) */
            hs_polarity, /* 0=negative sync pulse, 1=positive sync pulse */
            vs_polarity; /* 0=negative sync pulse, 1=positive sync pulse */

        enum w9968cf_pp_flag pp_flag; /* post-processing routines in use */

        u8 nbuffers,      /* number of allocated frame buffers */
           altsetting,    /* camera alternate setting */
           disconnected,  /* flag: yes=1, no=0 */
           misconfigured, /* flag: yes=1, no=0 */
           users,         /* flag: number of users holding the device */
           streaming;     /* flag: yes=1, no=0 */

        int sensor; /* type of image sensor chip (CC_*) */

        /* Determined by sensor type */
        u16 maxwidth,
            maxheight,
            minwidth,
            minheight,
            start_cropx,
            start_cropy;

        u8  auto_brt,     /* auto brightness enabled flag */
            auto_exp,     /* auto exposure enabled flag */
            backlight,    /* backlight exposure algorithm flag */
            mirror,       /* image is reversed horizontally */
            lightfreq,    /* power (lighting) frequency */
            bandfilt;     /* banding filter enabled flag */
        s8  clockdiv;     /* clock divisor */
        int sensor_mono;  /* sensor is (probably) monochrome */

        /* I2C interface to kernel */
        struct i2c_adapter i2c_adapter;
        struct i2c_client* sensor_client;

#if defined(CONFIG_VIDEO_PROC_FS)
        /* /proc entries, relative to /proc/video/w9968cf/ */
        struct proc_dir_entry *proc_dev;   /* rw per-device entry */
#endif

        /* Locks */
        struct semaphore dev_sem,    /* for probe, disconnect,open and close */
                         fileop_sem; /* for read and ioctl */
#if defined(CONFIG_VIDEO_PROC_FS)
        struct semaphore procfs_sem; /* for /proc read/write calls */
#endif
        spinlock_t urb_lock,   /* for submit_urb() and unlink_urb() */
                   flist_lock; /* for requested frame list accesses */
        char command[16]; /* name of the program holding the device */
        wait_queue_head_t open, wait_queue;
};

#define W9968CF_HW_BUF_SIZE 640*480*2 /* buf. size for original video frames */

#define SENSOR_FORMAT          VIDEO_PALETTE_UYVY
#define SENSOR_FATAL_ERROR(rc) ((rc) < 0 && (rc) != -EPERM)


/****************************************************************************
 * Macros and other constants                                               *
 ****************************************************************************/

#undef DBG
#ifdef W9968CF_DEBUG
#       define DBG(level, fmt, args...) \
{ \
if ( ((specific_debug) && (debug == (level))) || \
     ((!specific_debug) && (debug >= (level))) ) { \
        if ((level) == 1) \
                err(fmt, ## args); \
        else if ((level) == 2 || (level) == 3) \
                info(fmt, ## args); \
        else if ((level) == 4) \
                warn(fmt, ## args); \
        else if ((level) >= 5) \
                info("[%s,%d] " fmt, \
                     __PRETTY_FUNCTION__, __LINE__ , ## args); \
} \
}
#else
        /* Not debugging: nothing */
#       define DBG(level, fmt, args...) do {;} while(0);
#endif

#undef PDBG
#undef PDBGG
#define PDBG(fmt, args...) info("[%s, %d] "fmt, \
                                __PRETTY_FUNCTION__, __LINE__ , ## args);
#define PDBGG(fmt, args...) do {;} while(0); /* nothing: it's a placeholder */

#endif /* _W9968CF_H_ */


----------------------------- w9968cf_externaldef.h ---------------------------

/***************************************************************************
 * Various definitions for compatibility with external modules.            *
 * This file is part of the W996[87]CF driver for Linux.                   *
 *                                                                         *
 * Copyright (C) 2002 2003 by Luca Risolia <[EMAIL PROTECTED]>            *
 *                                                                         *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.               *
 ***************************************************************************/

#ifndef _W9968CF_EXTERNALDEF_H_
#define _W9968CF_EXTERNALDEF_H_

#include <linux/videodev.h>
#include <linux/i2c.h>
#include <asm/ioctl.h>
#include <asm/types.h>

/* Need official assignments for these. */

#ifndef VID_HARDWARE_W9968CF
#       define VID_HARDWARE_W9968CF 255 /* arbitrary */
#endif

#ifndef I2C_HW_SMBUS_W9968CF
#       define I2C_HW_SMBUS_W9968CF 0xfc /* in this case, don't change */
#endif

#ifndef I2C_DRIVERID_OVCAMCHIP
#       define I2C_DRIVERID_OVCAMCHIP   0xf00f
#endif

/* The following values have been copied from the "ovcamchip" module. */

/* Controls */
enum {
        OVCAMCHIP_CID_CONT,       /* Contrast */
        OVCAMCHIP_CID_BRIGHT,     /* Brightness */
        OVCAMCHIP_CID_SAT,        /* Saturation */
        OVCAMCHIP_CID_HUE,        /* Hue */
        OVCAMCHIP_CID_EXP,        /* Exposure */
        OVCAMCHIP_CID_FREQ,       /* Light frequency */
        OVCAMCHIP_CID_BANDFILT,   /* Banding filter */
        OVCAMCHIP_CID_AUTOBRIGHT, /* Auto brightness */
        OVCAMCHIP_CID_AUTOEXP,    /* Auto exposure */
        OVCAMCHIP_CID_BACKLIGHT,  /* Back light compensation */
        OVCAMCHIP_CID_MIRROR,     /* Mirror horizontally */
};

/* I2C addresses */
#define OV7xx0_SID   (0x42 >> 1)
#define OV6xx0_SID   (0xC0 >> 1)

/* Sensor types */
enum {
        CC_UNKNOWN,
        CC_OV76BE,
        CC_OV7610,
        CC_OV7620,
        CC_OV7620AE,
        CC_OV6620,
        CC_OV6630,
        CC_OV6630AE,
        CC_OV6630AF,
};

/* API */
struct ovcamchip_control {
        __u32 id;
        __s32 value;
};

struct ovcamchip_window {
        int x;
        int y;
        int width;
        int height;
        int format;
        int quarter;            /* Scale width and height down 2x */

        /* This stuff will be removed eventually */
        int clockdiv;           /* Clock divisor setting */
};

/* Commands.
   You must call OVCAMCHIP_CMD_INITIALIZE before any of other commands */
#define OVCAMCHIP_CMD_Q_SUBTYPE  _IOR  (0x88, 0x00, int)
#define OVCAMCHIP_CMD_INITIALIZE _IOW  (0x88, 0x01, int)
#define OVCAMCHIP_CMD_S_CTRL     _IOW  (0x88, 0x02, struct ovcamchip_control)
#define OVCAMCHIP_CMD_G_CTRL     _IOWR (0x88, 0x03, struct ovcamchip_control)
#define OVCAMCHIP_CMD_S_MODE     _IOW  (0x88, 0x04, struct ovcamchip_window)
#define OVCAMCHIP_MAX_CMD        _IO   (0x88, 0x3f)

#endif /* _W9968CF_EXTERNALDEF_H_ */


------------------------------ w9968cf_decoder.h ------------------------------

/***************************************************************************
 * Video decoder for the W996[87]CF driver for Linux.                      *
 *                                                                         *
 * Copyright (C) 2003 by Luca Risolia <[EMAIL PROTECTED]>                 *
 *                                                                         *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.               *
 ***************************************************************************/

#ifndef _W9968CF_DECODER_H_
#define _W9968CF_DECODER_H_

static const unsigned char Y_QUANTABLE[64] = {
        16,  11,  10,  16,  24,  40,  51,  61,
        12,  12,  14,  19,  26,  58,  60,  55,
        14,  13,  16,  24,  40,  57,  69,  56,
        14,  17,  22,  29,  51,  87,  80,  62,
        18,  22,  37,  56,  68, 109, 103,  77,
        24,  35,  55,  64,  81, 104, 113,  92,
        49,  64,  78,  87, 103, 121, 120, 101,
        72,  92,  95,  98, 112, 100, 103,  99
};

static const unsigned char UV_QUANTABLE[64] = {
        17,  18,  24,  47,  99,  99,  99,  99,
        18,  21,  26,  66,  99,  99,  99,  99,
        24,  26,  56,  99,  99,  99,  99,  99,
        47,  66,  99,  99,  99,  99,  99,  99,
        99,  99,  99,  99,  99,  99,  99,  99,
        99,  99,  99,  99,  99,  99,  99,  99,
        99,  99,  99,  99,  99,  99,  99,  99,
        99,  99,  99,  99,  99,  99,  99,  99
};

#define W9968CF_DEC_ERR_CORRUPTED_DATA  -1
#define W9968CF_DEC_ERR_BUF_OVERFLOW    -2
#define W9968CF_DEC_ERR_NO_SOI          -3
#define W9968CF_DEC_ERR_NO_SOF0         -4
#define W9968CF_DEC_ERR_NO_SOS          -5
#define W9968CF_DEC_ERR_NO_EOI          -6

extern void w9968cf_init_decoder(void);
extern int w9968cf_check_headers(const unsigned char* Pin,
                                 const unsigned long BUF_SIZE);
extern int w9968cf_decode(const char* Pin, const unsigned long BUF_SIZE,
                          const unsigned W, const unsigned H, char* Pout);

#endif /* _W9968CF_DECODER_H_ */


-------------------------- w9968cf.c (for Linux 2.6) --------------------------

/***************************************************************************
 * Video4Linux driver for W996[87]CF JPEG USB Dual Mode Camera Chip.       *
 *                                                                         *
 * Copyright (C) 2002 2003 by Luca Risolia <[EMAIL PROTECTED]>            *
 *                                                                         *
 * - Memory management code from bttv driver by Ralph Metzler,             *
 *   Marcus Metzler and Gerd Knorr.                                        *
 * - I2C interface to kernel, high-level sensor control routines and some  *
 *   symbolic names from OV511 driver by Mark W. McClelland.               *
 * - Low-level I2C write function by Piotr Czerczak.                       *
 * - Low-level I2C read function by Frédéric Jouault.                      *
 *                                                                         *
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.               *
 ***************************************************************************/

#include <linux/version.h>
#include <linux/module.h>
#include <linux/kmod.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/ioctl.h>
#include <linux/proc_fs.h>
#include <linux/delay.h>
#include <asm/page.h>
#include <asm/uaccess.h>

#include "w9968cf.h"
#include "w9968cf_decoder.h"



/****************************************************************************
 * Modules paramaters                                                       *
 ****************************************************************************/

static u8 ppmod_load = W9968CF_PPMOD_LOAD;
static u8 simcams = W9968CF_SIMCAMS;
static int video_nr[]={[0 ... W9968CF_MAX_DEVICES-1] = -1}; /* -1=first free */
static u16 packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1]=W9968CF_PACKET_SIZE};
static u8 max_buffers[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_BUFFERS};
static u8 double_buffer[] = {[0 ... W9968CF_MAX_DEVICES-1] =
                             W9968CF_DOUBLE_BUFFER};
static u8 clamping[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLAMPING};
static u8 filter_type[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_FILTER_TYPE};
static u8 largeview[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_LARGEVIEW};
static u8 decomp_mode[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_DECOMP_MODE};
static u8 soft_scaling[]= {[0 ... W9968CF_MAX_DEVICES-1]=W9968CF_SOFT_SCALING};
static u8 force_palette[] = {[0 ... W9968CF_MAX_DEVICES-1] = 0};
static u8 force_rgb[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_FORCE_RGB};
static u8 autobright[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOBRIGHT};
static u8 autoexp[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOEXP};
static u8 lightfreq[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_LIGHTFREQ};
static u8 bandingfilter[] = {[0 ... W9968CF_MAX_DEVICES-1]=
                             W9968CF_BANDINGFILTER};
static int clockdiv[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLOCKDIV};
static u8 backlight[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_BACKLIGHT};
static u8 mirror[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_MIRROR};
static u8 sensor_mono[] = {[0 ... W9968CF_MAX_DEVICES-1]=W9968CF_SENSOR_MONO};
static u16 brightness[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_BRIGHTNESS};
static u16 hue[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_HUE};
static u16 colour[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_COLOUR};
static u16 contrast[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CONTRAST};
static u16 whiteness[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_WHITENESS};
#ifdef W9968CF_DEBUG
static u8 debug = W9968CF_DEBUG_LEVEL;
static u8 specific_debug = W9968CF_SPECIFIC_DEBUG;
#endif

MODULE_AUTHOR("Luca Risolia <[EMAIL PROTECTED]>");

MODULE_DESCRIPTION("Video4Linux driver for "
                   "W996[87]CF JPEG USB Dual Mode Camera Chip");

MODULE_SUPPORTED_DEVICE("Video");

MODULE_LICENSE("GPL");

MODULE_PARM(ppmod_load, "i");
MODULE_PARM(simcams, "i");
MODULE_PARM(video_nr, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(packet_size, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(max_buffers, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(double_buffer, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(clamping, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(filter_type, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(largeview, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(decomp_mode, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(soft_scaling, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(force_palette, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(force_rgb, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "i");
MODULE_PARM(autobright, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(autoexp, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(lightfreq, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(bandingfilter, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(clockdiv, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(backlight, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(mirror, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(sensor_mono, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(brightness, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(hue, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(colour, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(contrast, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
MODULE_PARM(whiteness, "0-" __MODULE_STRING(W9968CF_MAX_DEVICES) "l");
#ifdef W9968CF_DEBUG
MODULE_PARM(debug, "i");
MODULE_PARM(specific_debug, "i");
#endif

MODULE_PARM_DESC(ppmod_load,
                 "\n<0|1> Automatic 'w9968cf-pp' module loading."
                 "\n0 disable, 1 enable."
                 "\nIf enabled, every time an application attempts to open a"
                 "\ncamera, 'insmod' searches for the video post-processing"
                 "\nmodule in the system and loads it automatically (if not"
                 "\npresent). The 'w9968cf-pp' module adds extra image"
                 "\nmanipulation functions to the 'w9968cf' module, like"
                 "\nsoftware up-scaling,colour conversions and video decoding."
                 "\nDefault value is "__MODULE_STRING(W9968CF_PPMOD_LOAD)"."
                 "\n");
MODULE_PARM_DESC(simcams,
                 "\n<n> Number of cameras allowed to stream simultaneously."
                 "\nn may vary from 0 to "
                 __MODULE_STRING(W9968CF_MAX_DEVICES)"."
                 "\nDefault value is "__MODULE_STRING(W9968CF_SIMCAMS)"."
                 "\n");
MODULE_PARM_DESC(video_nr,
                 "\n<-1|n[,...]> Specify V4L minor mode number."
                 "\n -1 = use next available (default)"
                 "\n  n = use minor number n (integer >= 0)"
                 "\nYou can specify " __MODULE_STRING(W9968CF_MAX_DEVICES)
                 " cameras this way."
                 "\nFor example:"
                 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
                 "\nthe second camera and use auto for the first"
                 "\none and for every other camera."
                 "\n");
MODULE_PARM_DESC(packet_size,
                 "\n<n[,...]> Specify the maximum data payload"
                 "\nsize in bytes for alternate settings, for each device."
                 "\nn is scaled between 63 and 1023 "
                 "(default is "__MODULE_STRING(W9968CF_PACKET_SIZE)")."
                 "\n");
MODULE_PARM_DESC(max_buffers,
                 "\n<n[,...]> Only for advanced users."
                 "\nSpecify the maximum number of video frame buffers"
                 "\nto allocate for each device, from 2 to "
                 __MODULE_STRING(W9968CF_MAX_BUFFERS)
                 ". (default is "__MODULE_STRING(W9968CF_BUFFERS)")."
                 "\n");
MODULE_PARM_DESC(double_buffer,
                 "\n<0|1[,...]> "
                 "Hardware double buffering: 0 disabled, 1 enabled."
                 "\nIt should be enabled if you want smooth video output: if"
                 "\nyou obtain out of sync. video, disable it at all, or try"
                 "\nto decrease the 'clockdiv' module paramater value."
                 "\nDefault value is "__MODULE_STRING(W9968CF_DOUBLE_BUFFER)
                 " for every device."
                 "\n");
MODULE_PARM_DESC(clamping,
                 "\n<0|1[,...]> Video data clamping: 0 disabled, 1 enabled."
                 "\nDefault value is "__MODULE_STRING(W9968CF_CLAMPING)
                 " for every device."
                 "\n");
MODULE_PARM_DESC(filter_type,
                 "\n<0|1|2[,...]> Video filter type."
                 "\n0 none, 1 (1-2-1) 3-tap filter, "
                 "2 (2-3-6-3-2) 5-tap filter."
                 "\nDefault value is "__MODULE_STRING(W9968CF_FILTER_TYPE)
                 " for every device."
                 "\nThe filter is used to reduce noise and aliasing artifacts"
                 "\nproduced by the CCD or CMOS sensor, and the scaling"
                 " process."
                 "\n");
MODULE_PARM_DESC(largeview,
                 "\n<0|1[,...]> Large view: 0 disabled, 1 enabled."
                 "\nDefault value is "__MODULE_STRING(W9968CF_LARGEVIEW)
                 " for every device."
                 "\n");
MODULE_PARM_DESC(soft_scaling,
                 "\n<0|1[,...]> Software scaling (for non-compressed video):"
                 "\n0 disabled, 1 enabled."
                 "\nDisable it if you have a slow CPU or you don't have"
                 " enough memory."
                 "\nDefault value is "__MODULE_STRING(W9968CF_SOFT_SCALING)
                 " for every device."



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to