Commit 68a13be8 authored by Mark W. McClelland's avatar Mark W. McClelland Committed by Greg Kroah-Hartman

[PATCH] USB: ov511 1.61 for 2.5.25

Update ov511 driver to version 1.61:

- Remove kernel I2C support and related TV tuner code. It will
  be reimplemented correctly in the 2.x driver series
- Fix warnings when compiling without procfs support
- Fix reg_r() debug message (was printing wrong values)
- Fix printing of hex values
- Fix bogus error handling in ov51x_v4l_open()
- Improve definition of unit_video module param
- Eliminate trailing whitespace, and other code cleanups
- Remove documentation of obsolete module params
parent 7fc26a9e
......@@ -128,16 +128,6 @@ MODULE PARAMETERS:
programs that expect RGB data (e.g. gqcam) to work with this driver. If
your colors look VERY wrong, you may want to change this.
NAME: buf_timeout (Temporarily disabled. Memory is deallocated immediately)
TYPE: integer
DEFAULT: 5 (seconds)
DESC: Number of seconds before unused frame buffers are deallocated.
Previously, memory was allocated upon open() and deallocated upon
close(). Deallocation now occurs only if the driver is closed and this
timeout is reached. If you are capturing frames less frequently than
the default timeout, increase this. This will not make any difference
with programs that capture multiple frames during an open/close cycle.
NAME: cams
TYPE: integer (1-4 for OV511, 1-31 for OV511+)
DEFAULT: 1
......@@ -161,13 +151,6 @@ MODULE PARAMETERS:
DESC: This configures the camera's sensor to transmit a colored test-pattern
instead of an image. This does not work correctly yet.
NAME: sensor_gbr (*** TEMPORARILY DISABLED ***)
TYPE: integer (Boolean)
DEFAULT: 0
DESC: This makes the sensor output GBR422 instead of YUV420. This saves the
driver the trouble of converting YUV to RGB, but it currently does not
work very well (the colors are not quite right)
NAME: dumppix
TYPE: integer (0-2)
DEFAULT: 0
......@@ -259,14 +242,6 @@ MODULE PARAMETERS:
13 VIDEO_PALETTE_YUV422P (YUV 4:2:2 Planar)
15 VIDEO_PALETTE_YUV420P (YUV 4:2:0 Planar, same as 10)
NAME: tuner
TYPE: integer
DEFAULT: -1 (autodetect)
DESC: This sets the exact type of the tuner module in a device. This is set
automatically based on the custom ID of the OV511 device. In cases
where this fails, you can override this auto-detection. Please see
linux/drivers/media/video/tuner.h for a complete list.
NAME: backlight
TYPE: integer (Boolean)
DEFAULT: 0 (off)
......
......@@ -9,7 +9,6 @@
* OV7620 fixes by Charl P. Botha <cpbotha@ieee.org>
* Changes by Claudio Matsuoka <claudio@conectiva.com>
* Original SAA7111A code by Dave Perks <dperks@ibm.net>
* Kernel I2C interface adapted from nt1003 driver
* URB error messages from pwc driver by Nemosoft
* generic_ioctl() code from videodev.c by Gerd Knorr and Alan Cox
* Memory management (rvmalloc) code from bttv driver, by Gerd Knorr and others
......@@ -61,7 +60,7 @@
/*
* Version Information
*/
#define DRIVER_VERSION "v1.60a for Linux 2.5"
#define DRIVER_VERSION "v1.61 for Linux 2.5"
#define EMAIL "mmcclell@bigfoot.com"
#define DRIVER_AUTHOR "Mark McClelland <mmcclell@bigfoot.com> & Bret Wallach \
& Orion Sky Lawlor <olawlor@acm.org> & Kevin Moore & Charl P. Botha \
......@@ -72,7 +71,6 @@
#define ENABLE_Y_QUANTABLE 1
#define ENABLE_UV_QUANTABLE 1
/* If you change this, you must also change the MODULE_PARM definition */
#define OV511_MAX_UNIT_VIDEO 16
/* Pixel count * bytes per YUV420 pixel (1.5) */
......@@ -127,7 +125,6 @@ static int framedrop = -1;
static int fastset;
static int force_palette;
static int tuner = -1;
static int backlight;
static int unit_video[OV511_MAX_UNIT_VIDEO];
static int remove_zeros;
......@@ -194,11 +191,9 @@ MODULE_PARM(fastset, "i");
MODULE_PARM_DESC(fastset, "Allows picture settings to take effect immediately");
MODULE_PARM(force_palette, "i");
MODULE_PARM_DESC(force_palette, "Force the palette to a specific value");
MODULE_PARM(tuner, "i");
MODULE_PARM_DESC(tuner, "Set tuner type, if not autodetected");
MODULE_PARM(backlight, "i");
MODULE_PARM_DESC(backlight, "For objects that are lit from behind");
MODULE_PARM(unit_video, "0-16i");
MODULE_PARM(unit_video, "1-" __MODULE_STRING(OV511_MAX_UNIT_VIDEO) "i");
MODULE_PARM_DESC(unit_video,
"Force use of specific minor number(s). 0 is not allowed.");
MODULE_PARM(remove_zeros, "i");
......@@ -337,12 +332,14 @@ static struct symbolic_list urb_errlist[] = {
**********************************************************************/
static void ov51x_clear_snapshot(struct usb_ov511 *);
static int ov51x_check_snapshot(struct usb_ov511 *);
static inline int sensor_get_picture(struct usb_ov511 *,
struct video_picture *);
#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
static int sensor_get_exposure(struct usb_ov511 *, unsigned char *);
static int ov51x_control_ioctl(struct inode *, struct file *, unsigned int,
unsigned long);
static int ov51x_check_snapshot(struct usb_ov511 *);
#endif
/**********************************************************************
* Memory management
......@@ -692,12 +689,12 @@ reg_r(struct usb_ov511 *ov, unsigned char reg)
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, (__u16)reg, &ov->cbuf[0], 1, HZ);
PDEBUG(5, "0x%02X:0x%02X", reg, ov->cbuf[0]);
if (rc < 0)
if (rc < 0) {
err("reg read: error %d: %s", rc, symbolic(urb_errlist, rc));
else
} else {
rc = ov->cbuf[0];
PDEBUG(5, "0x%02X:0x%02X", reg, ov->cbuf[0]);
}
up(&ov->cbuf_lock);
......@@ -770,10 +767,8 @@ ov511_upload_quan_tables(struct usb_ov511 *ov)
PDEBUG(4, "Uploading quantization tables");
for (i = 0; i < OV511_QUANTABLESIZE / 2; i++)
{
if (ENABLE_Y_QUANTABLE)
{
for (i = 0; i < OV511_QUANTABLESIZE / 2; i++) {
if (ENABLE_Y_QUANTABLE) {
val0 = *pYTable++;
val1 = *pYTable++;
val0 &= 0x0f;
......@@ -784,8 +779,7 @@ ov511_upload_quan_tables(struct usb_ov511 *ov)
return rc;
}
if (ENABLE_UV_QUANTABLE)
{
if (ENABLE_UV_QUANTABLE) {
val0 = *pUVTable++;
val1 = *pUVTable++;
val0 &= 0x0f;
......@@ -813,10 +807,8 @@ ov518_upload_quan_tables(struct usb_ov511 *ov)
PDEBUG(4, "Uploading quantization tables");
for (i = 0; i < OV518_QUANTABLESIZE / 2; i++)
{
if (ENABLE_Y_QUANTABLE)
{
for (i = 0; i < OV518_QUANTABLESIZE / 2; i++) {
if (ENABLE_Y_QUANTABLE) {
val0 = *pYTable++;
val1 = *pYTable++;
val0 &= 0x0f;
......@@ -827,8 +819,7 @@ ov518_upload_quan_tables(struct usb_ov511 *ov)
return rc;
}
if (ENABLE_UV_QUANTABLE)
{
if (ENABLE_UV_QUANTABLE) {
val0 = *pUVTable++;
val1 = *pUVTable++;
val0 &= 0x0f;
......@@ -854,7 +845,7 @@ ov51x_reset(struct usb_ov511 *ov, unsigned char reset_type)
if (ov->bclass == BCL_OV518)
reset_type &= 0xfe;
PDEBUG(4, "Reset: type=0x%X", reset_type);
PDEBUG(4, "Reset: type=0x%02X", reset_type);
rc = reg_w(ov, R51x_SYS_RESET, reset_type);
rc = reg_w(ov, R51x_SYS_RESET, 0);
......@@ -1146,6 +1137,8 @@ i2c_set_slave_internal(struct usb_ov511 *ov, unsigned char slave)
return 0;
}
#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
/* Write to a specific I2C slave ID and register, using the specified mask */
static int
i2c_w_slave(struct usb_ov511 *ov,
......@@ -1201,6 +1194,8 @@ i2c_r_slave(struct usb_ov511 *ov,
return rc;
}
#endif /* defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS) */
/* Sets I2C read and write slave IDs. Returns <0 for error */
static int
ov51x_set_slave_ids(struct usb_ov511 *ov, unsigned char sid)
......@@ -1251,7 +1246,7 @@ dump_i2c_range(struct usb_ov511 *ov, int reg1, int regn)
for (i = reg1; i <= regn; i++) {
rc = i2c_r(ov, i);
info("Sensor[0x%X] = 0x%X", i, rc);
info("Sensor[0x%02X] = 0x%02X", i, rc);
}
}
......@@ -1270,7 +1265,7 @@ dump_reg_range(struct usb_ov511 *ov, int reg1, int regn)
for (i = reg1; i <= regn; i++) {
rc = reg_r(ov, i);
info("OV511[0x%X] = 0x%X", i, rc);
info("OV511[0x%02X] = 0x%02X", i, rc);
}
}
......@@ -1302,20 +1297,6 @@ ov511_dump_regs(struct usb_ov511 *ov)
}
#endif
/**********************************************************************
*
* Kernel I2C Interface (not supported with OV518/OV518+)
*
**********************************************************************/
/* For as-yet unimplemented I2C interface */
static void
call_i2c_clients(struct usb_ov511 *ov, unsigned int cmd,
void *arg)
{
/* Do nothing */
}
/*****************************************************************************/
/* Temporarily stops OV511 from functioning. Must do this before changing
......@@ -1363,9 +1344,9 @@ ov51x_clear_snapshot(struct usb_ov511 *ov)
} else {
err("clear snap: invalid bridge type");
}
}
#if defined(CONFIG_PROC_FS) && defined(CONFIG_VIDEO_PROC_FS)
/* Checks the status of the snapshot button. Returns 1 if it was pressed since
* it was last cleared, and zero in all other cases (including errors) */
static int
......@@ -1388,6 +1369,7 @@ ov51x_check_snapshot(struct usb_ov511 *ov)
return status;
}
#endif
/* This does an initial reset of an OmniVision sensor and ensures that I2C
* is synchronized. Returns <0 for failure.
......@@ -1550,7 +1532,6 @@ ov511_init_compression(struct usb_ov511 *ov)
int rc = 0;
if (!ov->compress_inited) {
reg_w(ov, 0x70, phy);
reg_w(ov, 0x71, phuv);
reg_w(ov, 0x72, pvy);
......@@ -1579,7 +1560,6 @@ ov518_init_compression(struct usb_ov511 *ov)
int rc = 0;
if (!ov->compress_inited) {
if (ov518_upload_quan_tables(ov) < 0) {
err("Error uploading quantization tables");
rc = -EIO;
......@@ -2909,7 +2889,7 @@ mode_init_regs(struct usb_ov511 *ov,
// rc = mode_init_saa_sensor_regs(ov, width, height, mode,
// sub_flag);
PDEBUG(1, "SAA status = 0X%x", i2c_r(ov, 0x1f));
PDEBUG(1, "SAA status = 0x%02X", i2c_r(ov, 0x1f));
break;
default:
err("Unknown sensor");
......@@ -3022,7 +3002,6 @@ decoder_get_input_name(struct usb_ov511 *ov, int input, char *name)
sprintf(name, "CVBS-%d", input);
else // if (input < 8)
sprintf(name, "S-Video-%d", input - 4);
break;
}
default:
......@@ -3092,7 +3071,6 @@ make_8x8(unsigned char *pIn, unsigned char *pOut, int w)
}
pOut += w;
}
}
/*
......@@ -3328,6 +3306,12 @@ decompress(struct usb_ov511 *ov, struct ov511_frame *frame,
}
}
/**********************************************************************
*
* Format conversion
*
**********************************************************************/
/* Fuses even and odd fields together, and doubles width.
* INPUT: an odd field followed by an even field at pIn0, in YUV planar format
* OUTPUT: a normal YUV planar image, with correct aspect ratio
......@@ -4227,14 +4211,15 @@ ov51x_v4l1_open(struct inode *inode, struct file *file)
if (ov->user)
goto out;
err = -ENOMEM;
if (ov51x_alloc(ov))
err = ov51x_alloc(ov);
if (err < 0)
goto out;
ov->sub_flag = 0;
/* In case app doesn't set them... */
if (ov51x_set_default_params(ov) < 0)
err = ov51x_set_default_params(ov);
if (err < 0)
goto out;
/* Make sure frames are reset */
......@@ -4303,6 +4288,7 @@ ov51x_v4l1_close(struct inode *inode, struct file *file)
kfree(ov);
ov = NULL;
}
file->private_data = NULL;
return 0;
......@@ -4331,10 +4317,8 @@ ov51x_v4l1_ioctl_internal(struct inode *inode, struct file *file,
sprintf(b->name, "%s USB Camera",
symbolic(brglist, ov->bridge));
b->type = VID_TYPE_CAPTURE | VID_TYPE_SUBCAPTURE;
if (ov->has_tuner)
b->type |= VID_TYPE_TUNER;
b->channels = ov->num_inputs;
b->audios = ov->has_audio_proc ? 1:0;
b->audios = 0;
b->maxwidth = ov->maxwidth;
b->maxheight = ov->maxheight;
b->minwidth = ov->minwidth;
......@@ -4354,11 +4338,10 @@ ov51x_v4l1_ioctl_internal(struct inode *inode, struct file *file,
}
v->norm = ov->norm;
v->type = (ov->has_tuner) ? VIDEO_TYPE_TV : VIDEO_TYPE_CAMERA;
v->flags = (ov->has_tuner) ? VIDEO_VC_TUNER : 0;
v->flags |= (ov->has_audio_proc) ? VIDEO_VC_AUDIO : 0;
v->type = VIDEO_TYPE_CAMERA;
v->flags = 0;
// v->flags |= (ov->has_decoder) ? VIDEO_VC_NORM : 0;
v->tuners = (ov->has_tuner) ? 1:0;
v->tuners = 0;
decoder_get_input_name(ov, v->channel, v->name);
return 0;
......@@ -4641,7 +4624,6 @@ ov51x_v4l1_ioctl_internal(struct inode *inode, struct file *file,
struct ov511_frame *frame;
int rc;
if (fnum >= OV511_NUMFRAMES) {
err("VIDIOCSYNC: invalid frame (%d)", fnum);
return -EINVAL;
......@@ -4728,92 +4710,6 @@ ov51x_v4l1_ioctl_internal(struct inode *inode, struct file *file,
return 0;
}
case VIDIOCGTUNER:
{
struct video_tuner *v = arg;
PDEBUG(4, "VIDIOCGTUNER");
if (!ov->has_tuner || v->tuner) // Only tuner 0
return -EINVAL;
strcpy(v->name, "Television");
// FIXME: Need a way to get the real values
v->rangelow = 0;
v->rangehigh = ~0;
v->flags = VIDEO_TUNER_PAL | VIDEO_TUNER_NTSC
| VIDEO_TUNER_SECAM;
v->mode = 0; /* FIXME: Not sure what this is yet */
v->signal = 0xFFFF; /* unknown */
call_i2c_clients(ov, cmd, v);
return 0;
}
case VIDIOCSTUNER:
{
struct video_tuner *v = arg;
int err;
PDEBUG(4, "VIDIOCSTUNER");
/* Only no or one tuner for now */
if (!ov->has_tuner || v->tuner)
return -EINVAL;
/* and it only has certain valid modes */
if (v->mode != VIDEO_MODE_PAL &&
v->mode != VIDEO_MODE_NTSC &&
v->mode != VIDEO_MODE_SECAM)
return -EOPNOTSUPP;
/* Is this right/necessary? */
err = decoder_set_norm(ov, v->mode);
if (err)
return err;
call_i2c_clients(ov, cmd, v);
return 0;
}
case VIDIOCGFREQ:
{
unsigned long v = *((unsigned long *) arg);
PDEBUG(4, "VIDIOCGFREQ");
if (!ov->has_tuner)
return -EINVAL;
v = ov->freq;
#if 0
/* FIXME: this is necessary for testing */
v = 46*16;
#endif
return 0;
}
case VIDIOCSFREQ:
{
unsigned long v = *((unsigned long *) arg);
PDEBUG(4, "VIDIOCSFREQ: %lx", v);
if (!ov->has_tuner)
return -EINVAL;
ov->freq = v;
call_i2c_clients(ov, cmd, &v);
return 0;
}
case VIDIOCGAUDIO:
case VIDIOCSAUDIO:
{
/* FIXME: Implement this... */
return 0;
}
default:
PDEBUG(3, "Unsupported IOCtl: 0x%X", cmd);
return -ENOIOCTLCMD;
......@@ -5449,8 +5345,6 @@ ov7xx0_configure(struct usb_ov511 *ov)
/* I don't know what's different about the 76BE yet. */
if (i2c_r(ov, 0x15) & 1) {
info("Sensor is an OV7620AE");
info("PLEASE REPORT THE EXISTENCE OF THIS SENSOR TO");
info("THE DRIVER AUTHOR");
} else {
info("Sensor is an OV76BE");
}
......@@ -5890,12 +5784,8 @@ ov511_configure(struct usb_ov511 *ov)
err("Also include the output of the detection process.");
}
if (ov->customid == 6) { /* USB Life TV (NTSC) */
ov->tuner_type = 8; /* Temic 4036FY5 3X 1981 */
} else if (ov->customid == 70) { /* USB Life TV (PAL/SECAM) */
ov->tuner_type = 3; /* Philips FI1216MF */
if (ov->customid == 70) /* USB Life TV (PAL/SECAM) */
ov->pal = 1;
}
if (write_regvals(ov, aRegvalsInit511)) goto error;
......@@ -6190,7 +6080,6 @@ ov51x_probe(struct usb_device *dev, unsigned int ifnum,
ov->lightfreq = lightfreq;
ov->num_inputs = 1; /* Video decoder init functs. change this */
ov->stop_during_set = !fastset;
ov->tuner_type = tuner;
ov->backlight = backlight;
ov->mirror = mirror;
ov->auto_brt = autobright;
......@@ -6221,7 +6110,7 @@ ov51x_probe(struct usb_device *dev, unsigned int ifnum,
ov->bclass = BCL_OV511;
break;
default:
err("Unknown product ID 0x%x", dev->descriptor.idProduct);
err("Unknown product ID 0x%04x", dev->descriptor.idProduct);
goto error_dealloc;
}
......
......@@ -551,17 +551,11 @@ struct usb_ov511 {
int num_inputs; /* Number of inputs */
int norm; /* NTSC / PAL / SECAM */
int has_decoder; /* Device has a video decoder */
int has_tuner; /* Device has a TV tuner */
int has_audio_proc; /* Device has an audio processor */
int freq; /* Current tuner frequency */
int tuner_type; /* Specific tuner model */
int pal; /* Device is designed for PAL resolution */
/* I2C interface to kernel */
/* I2C interface */
struct semaphore i2c_lock; /* Protect I2C controller regs */
unsigned char primary_i2c_slave; /* I2C write id of sensor */
unsigned char tuner_i2c_slave; /* I2C write id of tuner */
unsigned char audio_i2c_slave; /* I2C write id of audio processor */
/* Control transaction stuff */
unsigned char *cbuf; /* Buffer for payload */
......
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