Here are several more patches. The first patch is just the one to add support for the om6802 sensor with the addition of code to support hvflip, exposure, gain and auto exposure. The chip doesn't have an autogain function since turning on its AE will also control the gain. Hopefully MBOOMA will get back about whether his camera actually works with this patch.
The second patch removes all the defines for the usb VIDs and PIDs. These re only ever used in the device table and really don't provide any useful purupse over just coding the ids in directly. My third patch modifies the AE v4l control to report that is a boolean value. I'm aware that that is somewhat different then the v4l2 specs for this control, however the priority shutter and priority aperture settings don't really make sense for webcams which use an on or off approach for auto exposure. The two options i can think of are either defining our own private auto exposure cid or reusing the one alreayd defined but have the queryctrl ioctl report that it is boolean. Since it seems various other webcam modules in the kernel are doing the second option thats the one i choose. The forth one is an attempt to make the v4l2 controls for gain and exposure unchangeable when auto gain and auto exposure are set. --~--~---------~--~----~------------~-------~--~----~ Lets make microdia webcams plug'n play, (currently plug'n pray) To post to this group, send email to [email protected] Visit us online https://groups.google.com/group/microdia -~----------~----~----~----~------~----~------~--~---
From 06307a76981967c413f5387a729a144b396f1558 Mon Sep 17 00:00:00 2001 From: Brian Johnson <[email protected]> Date: Sat, 10 Jan 2009 21:50:30 -0500 Subject: [PATCH] Added support for om6802 sensor Signed-off-by: Brian Johnson <[email protected]> --- Makefile | 2 +- om6802.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ sn9c20x-dev.c | 10 +++++ sn9c20x-usb.c | 4 +- sn9c20x.h | 7 +++ 5 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 om6802.c diff --git a/Makefile b/Makefile index 45a0506..2c4b2ca 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ include $(src)/.config sn9c20x-objs := sn9c20x-usb.o sn9c20x-v4l2.o sn9c20x-sysfs.o sn9c20x-objs += sn9c20x-dev.o sn9c20x-queue.o -sn9c20x-objs += sn9c20x-bridge.o omnivision.o micron.o hv7131r.o +sn9c20x-objs += sn9c20x-bridge.o omnivision.o micron.o hv7131r.o om6802.o ifeq ($(CONFIG_SN9C20X_DEBUGFS),y) sn9c20x-objs += sn9c20x-debugfs.o diff --git a/om6802.c b/om6802.c new file mode 100644 index 0000000..3aa797a --- /dev/null +++ b/om6802.c @@ -0,0 +1,122 @@ +/** + * @file om6802.c + * @date 2009-1-9 + * + * @brief Common control functions for OM6802 Image Sensor. + * + * @par Licences + * + * 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 + * 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 "sn9c20x.h" +#include "sn9c20x-bridge.h" +#include "micron.h" + +struct sn9c20x_i2c_regs om6802_init[] = { + {0x90, 0x05}, + {0x4d, 0x05}, + {0xc9, 0x58}, + {0x49, 0x85}, + {0x5a, 0xc0}, + {0xdd, 0x18}, + {0xf0, 0x04}, + {0xe9, 0x0f}, + {0xe4, 0xff}, + {0xff, 0xff}, +}; + +int om6802_set_exposure(struct usb_sn9c20x *dev) +{ + int ret; + + __u8 exposure = dev->vsettings.exposure; + + ret = sn9c20x_write_i2c_data(dev, 1, + 0xE4, &exposure); + + return ret; +} + +int om6802_set_gain(struct usb_sn9c20x *dev) +{ + int ret; + + __u8 gain = dev->vsettings.gain; + + ret = sn9c20x_write_i2c_data(dev, 1, + 0xE5, &gain); + + return ret; +} + +int om6802_set_autoexposure(struct usb_sn9c20x *dev) +{ + int ret; + __u8 value; + + ret = sn9c20x_read_i2c_data(dev, 1, 0xE9, &value); + if (ret < 0) + return ret; + + switch (dev->vsettings.auto_exposure) { + case V4L2_EXPOSURE_AUTO: + value |= 0x40; + dev->vsettings.auto_gain = 1; + break; + case V4L2_EXPOSURE_MANUAL: + value &= ~0x40; + dev->vsettings.auto_gain = 0; + break; + case V4L2_EXPOSURE_SHUTTER_PRIORITY: + value &= ~0x40; + dev->vsettings.auto_gain = 0; + break; + case V4L2_EXPOSURE_APERTURE_PRIORITY: + value |= 0x40; + dev->vsettings.auto_gain = 1; + break; + default: + return -EINVAL; + } + + ret = sn9c20x_write_i2c_data(dev, 1, 0xE9, &value); + + return ret; +} + +int om6802_set_hvflip(struct usb_sn9c20x *dev) +{ + int ret; + __u8 value; + + ret = sn9c20x_read_i2c_data(dev, 1, 0xFD, &value); + if (ret < 0) + return ret; + + if (dev->vsettings.hflip) + value |= 0x80; + else + value &= ~0x80; + + if (dev->vsettings.vflip) + value |= 0x40; + else + value &= ~0x40; + + ret = sn9c20x_write_i2c_data(dev, 1, 0xFD, &value); + return ret; +} + diff --git a/sn9c20x-dev.c b/sn9c20x-dev.c index 78eae92..08c6fa0 100644 --- a/sn9c20x-dev.c +++ b/sn9c20x-dev.c @@ -221,6 +221,16 @@ int sn9c20x_initialize_sensor(struct usb_sn9c20x *dev) dev->camera.vstart = 1; UDIA_INFO("Detected HV7131R Sensor.\n"); break; + case OM6802_SENSOR: + sn9c20x_write_i2c_array(dev, om6802_init, 0); + dev->camera.set_hvflip = om6802_set_hvflip; + dev->camera.set_exposure = om6802_set_exposure; + dev->camera.set_exposure = om6802_set_gain; + dev->camera.set_auto_exposure = om6802_set_autoexposure; + dev->camera.hstart = 0; + dev->camera.vstart = 1; + UDIA_INFO("Detected OM6802 Sensor.\n"); + break; default: ret = -EINVAL; UDIA_INFO("Unsupported sensor.\n"); diff --git a/sn9c20x-usb.c b/sn9c20x-usb.c index f001016..8f3d9c5 100644 --- a/sn9c20x-usb.c +++ b/sn9c20x-usb.c @@ -197,7 +197,7 @@ static struct usb_device_id sn9c20x_table[] = { /* SN9C201 + OV7670ISP */ {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6260_PID, OV7670_SENSOR, 0x21)}, /* SN9C201 + OM6802 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6262_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6262_PID, OM6802_SENSOR, 0x34)}, /* SN9C201 + MI0360/MT9V111 */ {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6270_PID, 0, 0)}, /* SN9C201 + S5K53BEB */ @@ -229,7 +229,7 @@ static struct usb_device_id sn9c20x_table[] = { /* SN9C202 + OV7670ISP */ {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62A0_PID, OV7670_SENSOR, 0x21)}, /* SN9C202 + OM6802 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62A2_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62A2_PID, OM6802_SENSOR, 0x34)}, /* SN9C202 + MI0360/MT9V111 */ {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62B0_PID, 0, 0)}, /* SN9C202 + OV9655 */ diff --git a/sn9c20x.h b/sn9c20x.h index d5d2473..425e02c 100644 --- a/sn9c20x.h +++ b/sn9c20x.h @@ -326,6 +326,7 @@ enum sn9c20x_sensors { MT9M001_SENSOR = 9, HV7131R_SENSOR = 10, MT9V112_SENSOR = 11, + OM6802_SENSOR = 12, }; @@ -362,6 +363,7 @@ extern struct sn9c20x_i2c_regs ov9655_init[]; extern struct sn9c20x_i2c_regs ov7660_init[]; extern struct sn9c20x_i2c_regs ov7670_init[]; extern struct sn9c20x_i2c_regs hv7131r_init[]; +extern struct sn9c20x_i2c_regs om6802_init[]; #define SN9C20X_N_FMTS 4 #define SN9C20X_N_MODES 6 @@ -521,4 +523,9 @@ int hv7131r_set_exposure(struct usb_sn9c20x *dev); int hv7131r_set_gain(struct usb_sn9c20x *dev); int hv7131r_set_hvflip(struct usb_sn9c20x *dev); +int om6802_set_hvflip(struct usb_sn9c20x *dev); +int om6802_set_exposure(struct usb_sn9c20x *dev); +int om6802_set_gain(struct usb_sn9c20x *dev); +int om6802_set_autoexposure(struct usb_sn9c20x *dev); + #endif -- 1.5.6.3
From dd6448de21103cd8922327988aa2b516290d3f9a Mon Sep 17 00:00:00 2001 From: Brian Johnson <[email protected]> Date: Sat, 10 Jan 2009 21:50:36 -0500 Subject: [PATCH] Removed USB_*_VID and USB_*_PID defines These were only ever used in one place and did not really add anything useful. Signed-off-by: Brian Johnson <[email protected]> --- sn9c20x-usb.c | 76 ++++++++++++++++++++++++++++---------------------------- sn9c20x.h | 54 ---------------------------------------- 2 files changed, 38 insertions(+), 92 deletions(-) diff --git a/sn9c20x-usb.c b/sn9c20x-usb.c index 8f3d9c5..2d69f2e 100644 --- a/sn9c20x-usb.c +++ b/sn9c20x-usb.c @@ -175,81 +175,81 @@ __u8 log_level = 5; */ static struct usb_device_id sn9c20x_table[] = { /* SN9C201 + MI1300 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6240_PID, MT9M001_SENSOR, 0x5d)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6240, MT9M001_SENSOR, 0x5d)}, /* SN9C201 + MI1310 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6242_PID, MT9M111_SENSOR, 0x5d)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6242, MT9M111_SENSOR, 0x5d)}, /* SN9C201 + S5K4AAFX */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6243_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6243, 0, 0)}, /* SN9C201 + OV9655 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6248_PID, OV9655_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6248, OV9655_SENSOR, 0x30)}, /* SN9C201 + CX1332 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_624B_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x624B, 0, 0)}, /* SN9C201 + MI1320 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_624C_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x624C, 0, 0)}, /* SN9C201 + SOI968 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_624E_PID, SOI968_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x624E, SOI968_SENSOR, 0x30)}, /* SN9C201 + OV9650 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_624F_PID, OV9650_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x624F, OV9650_SENSOR, 0x30)}, /* SN9C201 + OV9650 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6251_PID, OV9650_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6251, OV9650_SENSOR, 0x30)}, /* SN9C201 + OV9650 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6253_PID, OV9650_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6253, OV9650_SENSOR, 0x30)}, /* SN9C201 + OV7670ISP */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6260_PID, OV7670_SENSOR, 0x21)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6260, OV7670_SENSOR, 0x21)}, /* SN9C201 + OM6802 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6262_PID, OM6802_SENSOR, 0x34)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6262, OM6802_SENSOR, 0x34)}, /* SN9C201 + MI0360/MT9V111 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6270_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6270, 0, 0)}, /* SN9C201 + S5K53BEB */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_627A_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x627A, 0, 0)}, /* SN9C201 + OV7660 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_627B_PID, OV7660_SENSOR, 0x21)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x627B, OV7660_SENSOR, 0x21)}, /* SN9C201 + HV7131R */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_627C_PID, HV7131R_SENSOR, 0x11)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x627C, HV7131R_SENSOR, 0x11)}, /* EEPROM */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_627F_PID, OV9650_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x627F, OV9650_SENSOR, 0x30)}, /* SN9C202 + MI1300 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6280_PID, MT9M001_SENSOR, 0x5d)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6280, MT9M001_SENSOR, 0x5d)}, /* SN9C202 + MI1310 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6282_PID, MT9M111_SENSOR, 0x5d)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6282, MT9M111_SENSOR, 0x5d)}, /* SN9C202 + S5K4AAFX */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6283_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6283, 0, 0)}, /* SN9C202 + OV9655 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6288_PID, OV9655_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x6288, OV9655_SENSOR, 0x30)}, /* SN9C202 + ICM107 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_628A_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x628A, 0, 0)}, /* SN9C202 + CX1332 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_628B_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x628B, 0, 0)}, /* SN9C202 + MI1320 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_628C_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x628C, 0, 0)}, /* SN9C202 + SOI968 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_628E_PID, SOI968_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x628E, SOI968_SENSOR, 0x30)}, /* SN9C202 + OV9650 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_628F_PID, OV9650_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x628F, OV9650_SENSOR, 0x30)}, /* SN9C202 + OV7670ISP */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62A0_PID, OV7670_SENSOR, 0x21)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x62A0, OV7670_SENSOR, 0x21)}, /* SN9C202 + OM6802 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62A2_PID, OM6802_SENSOR, 0x34)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x62A2, OM6802_SENSOR, 0x34)}, /* SN9C202 + MI0360/MT9V111 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62B0_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x62B0, 0, 0)}, /* SN9C202 + OV9655 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62B3_PID, OV9655_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x62B3, OV9655_SENSOR, 0x30)}, /* SN9C202 + S5K53BEB */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62BA_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x62BA, 0, 0)}, /* SN9C202 + OV7660 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62BB_PID, OV7660_SENSOR, 0x21)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x62BB, OV7660_SENSOR, 0x21)}, /* SN9C202 + HV7131R */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62BC_PID, HV7131R_SENSOR, 0x11)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x62BC, HV7131R_SENSOR, 0x11)}, /* SN9C202 + OV7663 */ - {SN9C20X_USB_DEVICE(USB_0C45_VID, USB_62BE_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x0C45, 0x62BE, 0, 0)}, /* => 628f (SN9C202 + OV9650) */ - {SN9C20X_USB_DEVICE(USB_045E_VID, USB_00F4_PID, OV9650_SENSOR, 0x30)}, + {SN9C20X_USB_DEVICE(0x045E, 0x00F4, OV9650_SENSOR, 0x30)}, /* => 627b (SN9C201 + OV7660) */ - {SN9C20X_USB_DEVICE(USB_145F_VID, USB_013D_PID, OV7660_SENSOR, 0x21)}, + {SN9C20X_USB_DEVICE(0x145F, 0x013D, OV7660_SENSOR, 0x21)}, /* => 62be (SN9C202 + OV7663 + EEPROM) */ - {SN9C20X_USB_DEVICE(USB_04F2_VID, USB_A128_PID, 0, 0)}, + {SN9C20X_USB_DEVICE(0x04F2, 0xA128, 0, 0)}, /* => 627c (SN9C201 + HV7131R) */ - {SN9C20X_USB_DEVICE(USB_0458_VID, USB_7029_PID, HV7131R_SENSOR, 0x11)}, + {SN9C20X_USB_DEVICE(0x0458, 0x7029, HV7131R_SENSOR, 0x11)}, { } }; diff --git a/sn9c20x.h b/sn9c20x.h index 425e02c..619d283 100644 --- a/sn9c20x.h +++ b/sn9c20x.h @@ -40,60 +40,6 @@ " <[email protected]>" /**< Author of this driver */ #define PREFIX DRIVER_NAME ": " /**< Prefix use for the SN9C20X "printk" */ -#define USB_0C45_VID 0x0c45 /**< Vendor ID of MICRODIA */ -#define USB_045E_VID 0x045e /**< Vendor ID of MICROSOFT */ -#define USB_04F2_VID 0x04f2 /**< Vendor ID of CHICONY */ -#define USB_145F_VID 0x145f /**< Vendor ID of TRUST */ -#define USB_0458_VID 0x0458 /**< Vendor ID of KYE */ - -/* SN9C201: */ -#define USB_6240_PID 0x6240 /**< SN9C201 + MI1300 */ -#define USB_6242_PID 0x6242 /**< SN9C201 + MI1310 */ -#define USB_6243_PID 0x6243 /**< SN9C201 + S5K4AAFX */ -#define USB_6248_PID 0x6248 /**< SN9C201 + OV9655 */ -#define USB_624B_PID 0x624b /**< SN9C201 + CX1332 */ -#define USB_624C_PID 0x624c /**< SN9C201 + MI1320 */ -#define USB_624E_PID 0x624e /**< SN9C201 + SOI968 */ -#define USB_624F_PID 0x624f /**< SN9C201 + OV9650 */ -#define USB_6251_PID 0x6251 /**< SN9C201 + OV9650 */ -#define USB_6253_PID 0x6253 /**< SN9C201 + OV9650 */ -#define USB_6260_PID 0x6260 /**< SN9C201 + OV7670ISP */ -#define USB_6262_PID 0x6262 /**< SN9C201 + OM6802 */ -#define USB_6270_PID 0x6270 /**< SN9C201 + MI0360/MT9V111 */ -#define USB_627A_PID 0x627a /**< SN9C201 + S5K53BEB */ -#define USB_627B_PID 0x627b /**< SN9C201 + OV7660 */ -#define USB_627C_PID 0x627c /**< SN9C201 + HV7131R */ -#define USB_627F_PID 0x627f /**< EEPROM */ -/* SN9C202:*/ -#define USB_6280_PID 0x6280 /**< SN9C202 + MI1300 */ -#define USB_6282_PID 0x6282 /**< SN9C202 + MI1310 */ -#define USB_6283_PID 0x6283 /**< SN9C202 + S5K4AAFX */ -#define USB_6288_PID 0x6288 /**< SN9C202 + OV9655 */ -#define USB_628A_PID 0x628a /**< SN9C202 + ICM107 */ -#define USB_628B_PID 0x628b /**< SN9C202 + CX1332 */ -#define USB_628C_PID 0x628c /**< SN9C202 + MI1320 */ -#define USB_628E_PID 0x628e /**< SN9C202 + SOI968 */ -#define USB_628F_PID 0x628f /**< SN9C202 + OV9650 */ -#define USB_62A0_PID 0x62a0 /**< SN9C202 + OV7670ISP */ -#define USB_62A2_PID 0x62a2 /**< SN9C202 + OM6802 */ -#define USB_62B0_PID 0x62b0 /**< SN9C202 + MI0360/MT9V111 */ -#define USB_62B3_PID 0x62b3 /**< SN9C202 + OV9655 */ -#define USB_62BA_PID 0x62ba /**< SN9C202 + S5K53BEB */ -#define USB_62BB_PID 0x62bb /**< SN9C202 + OV7660 */ -#define USB_62BC_PID 0x62bc /**< SN9C202 + HV7131R */ -#define USB_62BE_PID 0x62be /**< SN9C202 + OV7663 */ - -/* *** "Clone"-devices ***: */ -/* Microsoft LifeCam VX-6000: */ -#define USB_00F4_PID 0x00f4 /**< => 628f (SN9C202 + OV9650) */ -/* Trust WB-3600R: */ -#define USB_013D_PID 0x013d /**< => 627b (SN9C201 + OV7660) */ -/* Chicony Panda 7, Trust WB-3450P: */ -#define USB_A128_PID 0xa128 /**< => 62be (SN9C202 + OV7663) */ -/* Genius Look 320S (KYE Systems Corp)*/ -#define USB_7029_PID 0x7029 /**< => 627c (SN9C201 + HV7131R) */ - - #define SN9C20X_USB_DEVICE(vend, prod, sensor, address) \ .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ USB_DEVICE_ID_MATCH_INT_CLASS, \ -- 1.5.6.3
From def043da5280f0a7866db3200e213044d594e927 Mon Sep 17 00:00:00 2001 From: Brian Johnson <[email protected]> Date: Sun, 11 Jan 2009 02:04:45 -0500 Subject: [PATCH] Make auto exposure a boolean variable. Webcams only really support on off for auto exposure Signed-off-by: Brian Johnson <[email protected]> --- micron.c | 17 ++++------------- om6802.c | 21 ++++----------------- omnivision.c | 15 ++------------- sn9c20x-dev.c | 2 +- sn9c20x-usb.c | 8 ++++---- sn9c20x-v4l2.c | 4 ++-- sn9c20x.h | 6 ------ 7 files changed, 17 insertions(+), 56 deletions(-) diff --git a/micron.c b/micron.c index d9394bb..8b36188 100644 --- a/micron.c +++ b/micron.c @@ -588,22 +588,13 @@ int mt9v111_set_autoexposure(struct usb_sn9c20x *dev) } /* Set new value for register 0x06: */ - switch (dev->vsettings.auto_exposure) { - case V4L2_EXPOSURE_AUTO: + + if (dev->vsettings.auto_exposure) { buf[0] |= MT9V111_IFP_OPMODE_AUTOEXPOSURE; - break; - case V4L2_EXPOSURE_MANUAL: - buf[0] &= ~MT9V111_IFP_OPMODE_AUTOEXPOSURE; - break; - case V4L2_EXPOSURE_SHUTTER_PRIORITY: + } else { buf[0] &= ~MT9V111_IFP_OPMODE_AUTOEXPOSURE; - break; - case V4L2_EXPOSURE_APERTURE_PRIORITY: - buf[0] |= MT9V111_IFP_OPMODE_AUTOEXPOSURE; - break; - default: - return -EINVAL; } + /* Write new value to IFP-register 0x06: */ ret = sn9c20x_write_i2c_data16(dev, 1, MT9V111_IFPREG_OPMODECTL, buf); if (ret < 0) { diff --git a/om6802.c b/om6802.c index 3aa797a..e542cf6 100644 --- a/om6802.c +++ b/om6802.c @@ -71,25 +71,12 @@ int om6802_set_autoexposure(struct usb_sn9c20x *dev) if (ret < 0) return ret; - switch (dev->vsettings.auto_exposure) { - case V4L2_EXPOSURE_AUTO: + dev->vsettings.auto_gain = dev->vsettings.auto_exposure; + + if (dev->vsettings.auto_exposure) { value |= 0x40; - dev->vsettings.auto_gain = 1; - break; - case V4L2_EXPOSURE_MANUAL: - value &= ~0x40; - dev->vsettings.auto_gain = 0; - break; - case V4L2_EXPOSURE_SHUTTER_PRIORITY: + } else { value &= ~0x40; - dev->vsettings.auto_gain = 0; - break; - case V4L2_EXPOSURE_APERTURE_PRIORITY: - value |= 0x40; - dev->vsettings.auto_gain = 1; - break; - default: - return -EINVAL; } ret = sn9c20x_write_i2c_data(dev, 1, 0xE9, &value); diff --git a/omnivision.c b/omnivision.c index cbd5a59..8e4275f 100644 --- a/omnivision.c +++ b/omnivision.c @@ -607,21 +607,10 @@ int soi968_set_autoexposure(struct usb_sn9c20x *dev) if (ret < 0) return ret; - switch (dev->vsettings.auto_exposure) { - case V4L2_EXPOSURE_AUTO: + if (dev->vsettings.auto_exposure) { buf[0] |= 0x01; - break; - case V4L2_EXPOSURE_MANUAL: - buf[0] &= ~0x01; - break; - case V4L2_EXPOSURE_SHUTTER_PRIORITY: + } else { buf[0] &= ~0x01; - break; - case V4L2_EXPOSURE_APERTURE_PRIORITY: - buf[0] |= 0x01; - break; - default: - return -EINVAL; } ret = sn9c20x_write_i2c_data(dev, 1, 0x13, buf); diff --git a/sn9c20x-dev.c b/sn9c20x-dev.c index 08c6fa0..f0ede16 100644 --- a/sn9c20x-dev.c +++ b/sn9c20x-dev.c @@ -253,7 +253,7 @@ int dev_sn9c20x_call_constantly(struct usb_sn9c20x *dev) /*dev_sn9c20x_flip_detection(dev);*/ dev_sn9c20x_button_detection(dev); if (!dev->camera.set_auto_exposure && - dev->vsettings.auto_exposure == V4L2_EXPOSURE_AUTO) { + dev->vsettings.auto_exposure) { dev_sn9c20x_perform_soft_ae(dev); } diff --git a/sn9c20x-usb.c b/sn9c20x-usb.c index 2d69f2e..9d59e8b 100644 --- a/sn9c20x-usb.c +++ b/sn9c20x-usb.c @@ -147,7 +147,7 @@ static __u8 max_buffers = 5; * @var auto_exposure * Module parameter to set the exposure */ -static __u8 auto_exposure; +static __u8 auto_exposure = 1; /** * @var auto_gain @@ -964,10 +964,10 @@ static int __init usb_sn9c20x_init(void) blue_gain = 31; } - if (auto_exposure > 3) { - UDIA_WARNING("Automatic exposure should be 0, 1, 2 or 3! " + if (auto_exposure != 0 && auto_exposure != 1) { + UDIA_WARNING("Automatic exposure should be 0 or 1! " "Defaulting to 0\n"); - auto_exposure = 0; + auto_exposure = 1; } if (auto_gain != 0 && auto_gain != 1) { diff --git a/sn9c20x-v4l2.c b/sn9c20x-v4l2.c index 5c7d47b..58e0486 100644 --- a/sn9c20x-v4l2.c +++ b/sn9c20x-v4l2.c @@ -140,10 +140,10 @@ static struct v4l2_queryctrl sn9c20x_controls[] = { }, { .id = V4L2_CID_EXPOSURE_AUTO, - .type = V4L2_CTRL_TYPE_INTEGER, + .type = V4L2_CTRL_TYPE_BOOLEAN, .name = "Automatic exposure control", .minimum = 0, - .maximum = 3, + .maximum = 1, .step = 1, }, { diff --git a/sn9c20x.h b/sn9c20x.h index 619d283..42f458d 100644 --- a/sn9c20x.h +++ b/sn9c20x.h @@ -52,12 +52,6 @@ #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 25) #define V4L2_CID_SHARPNESS (V4L2_CID_PRIVATE_BASE + 0) #define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_PRIVATE_BASE + 1) -enum v4l2_exposure_auto_type { - V4L2_EXPOSURE_AUTO = 0, - V4L2_EXPOSURE_MANUAL = 1, - V4L2_EXPOSURE_SHUTTER_PRIORITY = 2, - V4L2_EXPOSURE_APERTURE_PRIORITY = 3 -}; #endif #ifndef V4L2_PIX_FMT_SN9C20X_I420 -- 1.5.6.3
From e9667491430cc054be1c4e9ce098fb4ba0f8cb05 Mon Sep 17 00:00:00 2001 From: Brian Johnson <[email protected]> Date: Sun, 11 Jan 2009 02:20:53 -0500 Subject: [PATCH] Modify AWB, AE, and AG When AWB, AE, or AG are turned on, set the read only flag for color gains, exposure or gain controls. Signed-off-by: Brian Johnson <[email protected]> --- sn9c20x-v4l2.c | 36 ++++++++++++++++++++++++++++-------- 1 files changed, 28 insertions(+), 8 deletions(-) diff --git a/sn9c20x-v4l2.c b/sn9c20x-v4l2.c index 58e0486..cb35e2c 100644 --- a/sn9c20x-v4l2.c +++ b/sn9c20x-v4l2.c @@ -750,10 +750,14 @@ int sn9c20x_vidioc_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *ctrl) { int i; + int ret = 0; #ifdef V4L2_CTRL_FLAG_NEXT_CTRL int min; __u32 idnew, idlast; #endif + struct usb_sn9c20x *dev; + + dev = video_get_drvdata(priv); UDIA_DEBUG("VIDIOC_QUERYCTRL id = %d\n", ctrl->id); @@ -773,9 +777,10 @@ int sn9c20x_vidioc_queryctrl(struct file *file, void *priv, UDIA_DEBUG("VIDIOC_QUERYCTRL found\n"); memcpy(ctrl, &sn9c20x_controls[min], sizeof(struct v4l2_queryctrl)); - return 0; - } else - return -EINVAL; + goto done; + } else { + goto error; + } } else #endif { @@ -784,15 +789,22 @@ int sn9c20x_vidioc_queryctrl(struct file *file, void *priv, UDIA_DEBUG("VIDIOC_QUERYCTRL found\n"); memcpy(ctrl, &sn9c20x_controls[i], sizeof(struct v4l2_queryctrl)); - break; + goto done; } } } - if (i >= ARRAY_SIZE(sn9c20x_controls)) - return -EINVAL; - - return 0; +error: + ret = -EINVAL; +done: + if ((ctrl->id == V4L2_CID_GAIN && dev->vsettings.auto_gain) || + (ctrl->id == V4L2_CID_EXPOSURE && dev->vsettings.auto_exposure) || + ((ctrl->id == V4L2_CID_BLUE_BALANCE || + ctrl->id == V4L2_CID_RED_BALANCE) && + dev->vsettings.auto_whitebalance)) { + ctrl->flags |= V4L2_CTRL_FLAG_GRABBED; + } + return ret; } /** @@ -894,6 +906,14 @@ int sn9c20x_vidioc_s_ctrl(struct file *file, void *priv, UDIA_DEBUG("SET CTRL id=%d value=%d\n", ctrl->id, ctrl->value); + if ((ctrl->id == V4L2_CID_GAIN && dev->vsettings.auto_gain) || + (ctrl->id == V4L2_CID_EXPOSURE && dev->vsettings.auto_exposure) || + ((ctrl->id == V4L2_CID_BLUE_BALANCE || + ctrl->id == V4L2_CID_RED_BALANCE) && + dev->vsettings.auto_whitebalance)) { + return -EBUSY; + } + return sn9c20x_set_camera_control(dev, ctrl->id, ctrl->value); -- 1.5.6.3
