Commit a966f3e7 authored by Luca Risolia's avatar Luca Risolia Committed by Greg Kroah-Hartman

[PATCH] USB: SN9C10x driver updates and bugfixes

SN9C10x driver updates and bugfixes.

Changes: + new, - removed, * cleanup, @ bugfix:

@ fix poll()
@ Remove bad get_ctrl()'s
* Reduce ioctl stack usage
* Remove final ";" from some macro definitions
* Better support for SN9C103
+ Add sn9c102_write_regs()
+ Add 0x0c45/0x602d to the list of SN9C10x based devices
+ Add support for OV7630 image sensors
+ Provide support for the built-in microphone interface of the SN9C103
+ Documentation updates
+ Add 0x0c45/0x602e to the list of SN9C10x based devices
Signed-off-by: default avatarLuca Risolia <luca.risolia@studio.unibo.it>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ec7dc8d2
......@@ -17,16 +17,15 @@ Index
7. Module parameters
8. Optional device control through "sysfs"
9. Supported devices
10. How to add plug-in's for new image sensors
11. Notes for V4L2 application developers
12. Video frame formats
13. Contact information
14. Credits
10. Notes for V4L2 application developers
11. Video frame formats
12. Contact information
13. Credits
1. Copyright
============
Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it>
Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it>
2. Disclaimer
......@@ -54,9 +53,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4. Overview and features
========================
This driver attempts to support the video and audio streaming capabilities of
the devices mounting the SONiX SN9C101, SN9C102 and SN9C103 PC Camera
Controllers.
This driver attempts to support the video interface of the devices mounting the
SONiX SN9C101, SN9C102 and SN9C103 PC Camera Controllers.
It's worth to note that SONiX has never collaborated with the author during the
development of this project, despite several requests for enough detailed
......@@ -78,6 +76,7 @@ Some of the features of the driver are:
- available mmap or read/poll methods for video streaming through isochronous
data transfers;
- automatic detection of image sensor;
- support for built-in microphone interface;
- support for any window resolutions and optional panning within the maximum
pixel area of image sensor;
- image downscaling with arbitrary scaling factors from 1, 2 and 4 in both
......@@ -96,7 +95,7 @@ Some of the features of the driver are:
parameters" paragraph);
- up to 64 cameras can be handled at the same time; they can be connected and
disconnected from the host many times without turning off the computer, if
your system supports hotplugging;
the system supports hotplugging;
- no known bugs.
......@@ -125,6 +124,21 @@ necessary:
CONFIG_USB_UHCI_HCD=m
CONFIG_USB_OHCI_HCD=m
The SN9C103 controller also provides a built-in microphone interface. It is
supported by the USB Audio driver thanks to the ALSA API:
# Sound
#
CONFIG_SOUND=y
# Advanced Linux Sound Architecture
#
CONFIG_SND=m
# USB devices
#
CONFIG_SND_USB_AUDIO=m
And finally:
# USB Multimedia devices
......@@ -153,7 +167,7 @@ analyze kernel messages and verify that the loading process has gone well:
Module parameters are listed below:
-------------------------------------------------------------------------------
Name: video_nr
Type: int array (min = 0, max = 64)
Type: short array (min = 0, max = 64)
Syntax: <-1|n[,...]>
Description: Specify V4L2 minor mode number:
-1 = use next available
......@@ -165,19 +179,19 @@ Description: Specify V4L2 minor mode number:
other camera.
Default: -1
-------------------------------------------------------------------------------
Name: force_munmap;
Name: force_munmap
Type: bool array (min = 0, max = 64)
Syntax: <0|1[,...]>
Description: Force the application to unmap previously mapped buffer memory
before calling any VIDIOC_S_CROP or VIDIOC_S_FMT ioctl's. Not
all the applications support this feature. This parameter is
specific for each detected camera.
0 = do not force memory unmapping"
1 = force memory unmapping (save memory)"
0 = do not force memory unmapping
1 = force memory unmapping (save memory)
Default: 0
-------------------------------------------------------------------------------
Name: debug
Type: int
Type: ushort
Syntax: <n>
Description: Debugging information level, from 0 to 3:
0 = none (use carefully)
......@@ -187,7 +201,7 @@ Description: Debugging information level, from 0 to 3:
Level 3 is useful for testing only, when only one device
is used. It also shows some more informations about the
hardware being detected. This parameter can be changed at
runtime thanks to the /sys filesystem.
runtime thanks to the /sys filesystem interface.
Default: 2
-------------------------------------------------------------------------------
......@@ -236,7 +250,7 @@ serialized.
The sysfs interface also provides the "frame_header" entry, which exports the
frame header of the most recent requested and captured video frame. The header
is 12-bytes long and is appended to every video frame by the SN9C10x
is always 18-bytes long and is appended to every video frame by the SN9C10x
controllers. As an example, this additional information can be used by the user
application for implementing auto-exposure features via software.
......@@ -250,7 +264,8 @@ Byte # Value Description
0x03 0xC4 Frame synchronisation pattern.
0x04 0xC4 Frame synchronisation pattern.
0x05 0x96 Frame synchronisation pattern.
0x06 0x00 or 0x01 Unknown meaning. The exact value depends on the chip.
0x06 0xXX Unknown meaning. The exact value depends on the chip;
possible values are 0x00, 0x01 and 0x20.
0x07 0xXX Variable value, whose bits are ff00uzzc, where ff is a
frame counter, u is unknown, zz is a size indicator
(00 = VGA, 01 = SIF, 10 = QSIF) and c stands for
......@@ -267,12 +282,23 @@ Byte # Value Description
times the area outside of the specified AE area. For
images that are not pure white, the value scales down
according to relative whiteness.
according to relative whiteness.
The following bytes are used by the SN9C103 bridge only:
0x0C 0xXX Unknown meaning
0x0D 0xXX Unknown meaning
0x0E 0xXX Unknown meaning
0x0F 0xXX Unknown meaning
0x10 0xXX Unknown meaning
0x11 0xXX Unknown meaning
The AE area (sx, sy, ex, ey) in the active window can be set by programming the
registers 0x1c, 0x1d, 0x1e and 0x1f of the SN9C10x controllers, where one unit
corresponds to 32 pixels.
[1] The frame header has been documented by Bertrik Sikken.
[1] Part of the meaning of the frame header has been documented by Bertrik
Sikken.
9. Supported devices
......@@ -298,6 +324,7 @@ Vendor ID Product ID
0x0c45 0x602b
0x0c45 0x602c
0x0c45 0x602d
0x0c45 0x602e
0x0c45 0x6030
0x0c45 0x6080
0x0c45 0x6082
......@@ -348,18 +375,7 @@ appreciated. Non-available hardware will not be supported by the author of this
driver.
10. How to add plug-in's for new image sensors
==============================================
It should be easy to write plug-in's for new sensors by using the small API
that has been created for this purpose, which is present in "sn9c102_sensor.h"
(documentation is included there). As an example, have a look at the code in
"sn9c102_pas106b.c", which uses the mentioned interface.
At the moment, possible unsupported image sensors are: CIS-VF10 (VGA),
OV7620 (VGA), OV7630 (VGA).
11. Notes for V4L2 application developers
10. Notes for V4L2 application developers
=========================================
This driver follows the V4L2 API specifications. In particular, it enforces two
rules:
......@@ -394,7 +410,7 @@ initialized (as described in the documentation of the API for the image sensors
supplied by this driver).
12. Video frame formats [1]
11. Video frame formats [1]
=======================
The SN9C10x PC Camera Controllers can send images in two possible video
formats over the USB: either native "Sequential RGB Bayer" or Huffman
......@@ -455,7 +471,7 @@ The following Huffman codes have been found:
documented by Bertrik Sikken.
13. Contact information
12. Contact information
=======================
The author may be contacted by e-mail at <luca.risolia@studio.unibo.it>.
......@@ -464,7 +480,7 @@ GPG/PGP encrypted e-mail's are accepted. The GPG key ID of the author is
the fingerprint is: '88E8 F32F 7244 68BA 3958 5D40 99DA 5D2A FCE6 35A4'.
14. Credits
13. Credits
===========
Many thanks to following persons for their contribute (listed in alphabetical
order):
......@@ -480,5 +496,5 @@ order):
- Bertrik Sikken, who reverse-engineered and documented the Huffman compression
algorithm used in the SN9C10x controllers and implemented the first decoder;
- Mizuno Takafumi for the donation of a webcam;
- An "anonymous" donator (who didn't want his name to be revealed) for the
- an "anonymous" donator (who didn't want his name to be revealed) for the
donation of a webcam.
/***************************************************************************
* V4L2 driver for SN9C10x PC Camera Controllers *
* *
* Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
* Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
* *
* 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 *
......@@ -53,11 +53,11 @@
/*****************************************************************************/
#define SN9C102_MODULE_NAME "V4L2 driver for SN9C10x PC Camera Controllers"
#define SN9C102_MODULE_AUTHOR "(C) 2004-2005 Luca Risolia"
#define SN9C102_MODULE_AUTHOR "(C) 2004-2006 Luca Risolia"
#define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
#define SN9C102_MODULE_LICENSE "GPL"
#define SN9C102_MODULE_VERSION "1:1.24a"
#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 24)
#define SN9C102_MODULE_VERSION "1:1.25"
#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 25)
enum sn9c102_bridge {
BRIDGE_SN9C101 = 0x01,
......@@ -102,12 +102,13 @@ enum sn9c102_stream_state {
STREAM_ON,
};
typedef char sn9c103_sof_header_t[18];
typedef char sn9c102_sof_header_t[12];
typedef char sn9c102_eof_header_t[4];
struct sn9c102_sysfs_attr {
u8 reg, i2c_reg;
sn9c102_sof_header_t frame_header;
sn9c103_sof_header_t frame_header;
};
struct sn9c102_module_param {
......@@ -140,8 +141,8 @@ struct sn9c102_device {
struct v4l2_jpegcompression compression;
struct sn9c102_sysfs_attr sysfs;
sn9c102_sof_header_t sof_header;
u16 reg[32];
sn9c103_sof_header_t sof_header;
u16 reg[63];
struct sn9c102_module_param module_param;
......@@ -170,7 +171,7 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
#undef KDBG
#ifdef SN9C102_DEBUG
# define DBG(level, fmt, args...) \
{ \
do { \
if (debug >= (level)) { \
if ((level) == 1) \
dev_err(&cam->dev, fmt "\n", ## args); \
......@@ -180,9 +181,9 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
dev_info(&cam->dev, "[%s:%d] " fmt "\n", \
__FUNCTION__, __LINE__ , ## args); \
} \
}
} while (0)
# define KDBG(level, fmt, args...) \
{ \
do { \
if (debug >= (level)) { \
if ((level) == 1 || (level) == 2) \
pr_info("sn9c102: " fmt "\n", ## args); \
......@@ -190,17 +191,17 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \
__LINE__ , ## args); \
} \
}
} while (0)
#else
# define KDBG(level, fmt, args...) do {;} while(0);
# define DBG(level, fmt, args...) do {;} while(0);
# define KDBG(level, fmt, args...) do {;} while(0)
# define DBG(level, fmt, args...) do {;} while(0)
#endif
#undef PDBG
#define PDBG(fmt, args...) \
dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args);
dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args)
#undef PDBGG
#define PDBGG(fmt, args...) do {;} while(0); /* placeholder */
#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
#endif /* _SN9C102_H_ */
This diff is collapsed.
......@@ -2,7 +2,7 @@
* Plug-in for HV7131D image sensor connected to the SN9C10x PC Camera *
* Controllers *
* *
* Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
* Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
* *
* 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 *
......
......@@ -2,7 +2,7 @@
* Plug-in for MI-0343 image sensor connected to the SN9C10x PC Camera *
* Controllers *
* *
* Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
* Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
* *
* 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 *
......
......@@ -2,7 +2,7 @@
* Plug-in for OV7630 image sensor connected to the SN9C10x PC Camera *
* Controllers *
* *
* Copyright (C) 2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
* Copyright (C) 2005-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
* *
* 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 *
......@@ -375,8 +375,10 @@ int sn9c102_probe_ov7630(struct sn9c102_device* cam)
sn9c102_attach_sensor(cam, &ov7630);
if (le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x608f &&
le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x602c)
if (le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x602c &&
le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x602d &&
le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x608f &&
le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x60b0)
return -ENODEV;
err += sn9c102_write_reg(cam, 0x01, 0x01);
......
......@@ -2,7 +2,7 @@
* Plug-in for PAS106B image sensor connected to the SN9C10x PC Camera *
* Controllers *
* *
* Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
* Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
* *
* 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 *
......
/***************************************************************************
* API for image sensors connected to the SN9C10x PC Camera Controllers *
* *
* Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
* Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
* *
* 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 *
......@@ -92,7 +92,18 @@ extern void
sn9c102_attach_sensor(struct sn9c102_device* cam,
struct sn9c102_sensor* sensor);
/* Each SN9C10X camera has proper PID/VID identifiers. Add them here in case.*/
/*
Each SN9C10x camera has proper PID/VID identifiers.
SN9C103 supports multiple interfaces, but we only handle the video class
interface.
*/
#define SN9C102_USB_DEVICE(vend, prod, intclass) \
.match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
USB_DEVICE_ID_MATCH_INT_CLASS, \
.idVendor = (vend), \
.idProduct = (prod), \
.bInterfaceClass = (intclass)
#define SN9C102_ID_TABLE \
static const struct usb_device_id sn9c102_id_table[] = { \
{ USB_DEVICE(0x0c45, 0x6001), }, /* TAS5110C1B */ \
......@@ -107,33 +118,34 @@ static const struct usb_device_id sn9c102_id_table[] = { \
{ USB_DEVICE(0x0c45, 0x602b), }, /* MI-0343 */ \
{ USB_DEVICE(0x0c45, 0x602c), }, /* OV7630 */ \
{ USB_DEVICE(0x0c45, 0x602d), }, \
{ USB_DEVICE(0x0c45, 0x602e), }, /* OV7630 */ \
{ USB_DEVICE(0x0c45, 0x6030), }, /* MI03x */ \
{ USB_DEVICE(0x0c45, 0x6080), }, \
{ USB_DEVICE(0x0c45, 0x6082), }, /* MI0343 and MI0360 */ \
{ USB_DEVICE(0x0c45, 0x6083), }, /* HV7131[D|E1] */ \
{ USB_DEVICE(0x0c45, 0x6088), }, \
{ USB_DEVICE(0x0c45, 0x608a), }, \
{ USB_DEVICE(0x0c45, 0x608b), }, \
{ USB_DEVICE(0x0c45, 0x608c), }, /* HV7131x */ \
{ USB_DEVICE(0x0c45, 0x608e), }, /* CIS-VF10 */ \
{ USB_DEVICE(0x0c45, 0x608f), }, /* OV7630 */ \
{ USB_DEVICE(0x0c45, 0x60a0), }, \
{ USB_DEVICE(0x0c45, 0x60a2), }, \
{ USB_DEVICE(0x0c45, 0x60a3), }, \
{ USB_DEVICE(0x0c45, 0x60a8), }, /* PAS106B */ \
{ USB_DEVICE(0x0c45, 0x60aa), }, /* TAS5130D1B */ \
{ USB_DEVICE(0x0c45, 0x60ab), }, /* TAS5110C1B */ \
{ USB_DEVICE(0x0c45, 0x60ac), }, \
{ USB_DEVICE(0x0c45, 0x60ae), }, \
{ USB_DEVICE(0x0c45, 0x60af), }, /* PAS202BCB */ \
{ USB_DEVICE(0x0c45, 0x60b0), }, \
{ USB_DEVICE(0x0c45, 0x60b2), }, \
{ USB_DEVICE(0x0c45, 0x60b3), }, \
{ USB_DEVICE(0x0c45, 0x60b8), }, \
{ USB_DEVICE(0x0c45, 0x60ba), }, \
{ USB_DEVICE(0x0c45, 0x60bb), }, \
{ USB_DEVICE(0x0c45, 0x60bc), }, \
{ USB_DEVICE(0x0c45, 0x60be), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x6080, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x6082, 0xff), }, /* MI0343 & MI0360 */ \
{ SN9C102_USB_DEVICE(0x0c45, 0x6083, 0xff), }, /* HV7131[D|E1] */ \
{ SN9C102_USB_DEVICE(0x0c45, 0x6088, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x608a, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x608b, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x608c, 0xff), }, /* HV7131x */ \
{ SN9C102_USB_DEVICE(0x0c45, 0x608e, 0xff), }, /* CIS-VF10 */ \
{ SN9C102_USB_DEVICE(0x0c45, 0x608f, 0xff), }, /* OV7630 */ \
{ SN9C102_USB_DEVICE(0x0c45, 0x60a0, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60a2, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60a3, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60a8, 0xff), }, /* PAS106B */ \
{ SN9C102_USB_DEVICE(0x0c45, 0x60aa, 0xff), }, /* TAS5130D1B */ \
{ SN9C102_USB_DEVICE(0x0c45, 0x60ab, 0xff), }, /* TAS5110C1B */ \
{ SN9C102_USB_DEVICE(0x0c45, 0x60ac, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60ae, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60af, 0xff), }, /* PAS202BCB */ \
{ SN9C102_USB_DEVICE(0x0c45, 0x60b0, 0xff), }, /* OV7630 (?) */ \
{ SN9C102_USB_DEVICE(0x0c45, 0x60b2, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60b3, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60b8, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60ba, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60bb, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60bc, 0xff), }, \
{ SN9C102_USB_DEVICE(0x0c45, 0x60be, 0xff), }, \
{ } \
};
......@@ -177,6 +189,7 @@ extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value);
extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address);
/* I/O on registers in the bridge. Could be used by the sensor methods too */
extern int sn9c102_write_regs(struct sn9c102_device*, u8* buff, u16 index);
extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index);
extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index);
......
......@@ -2,7 +2,7 @@
* Plug-in for TAS5110C1B image sensor connected to the SN9C10x PC Camera *
* Controllers *
* *
* Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
* Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
* *
* 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 *
......
......@@ -2,7 +2,7 @@
* Plug-in for TAS5130D1B image sensor connected to the SN9C10x PC Camera *
* Controllers *
* *
* Copyright (C) 2004-2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
* Copyright (C) 2004-2006 by Luca Risolia <luca.risolia@studio.unibo.it> *
* *
* 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 *
......
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