summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/gspca/sonixj.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/video/gspca/sonixj.c')
-rw-r--r--linux/drivers/media/video/gspca/sonixj.c546
1 files changed, 276 insertions, 270 deletions
diff --git a/linux/drivers/media/video/gspca/sonixj.c b/linux/drivers/media/video/gspca/sonixj.c
index 785ca2e50..9bdd2256f 100644
--- a/linux/drivers/media/video/gspca/sonixj.c
+++ b/linux/drivers/media/video/gspca/sonixj.c
@@ -24,8 +24,8 @@
#include "gspca.h"
#include "jpeg.h"
-#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5)
-static const char version[] = "2.1.5";
+#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
+static const char version[] = "2.1.7";
MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
@@ -47,20 +47,19 @@ struct sd {
#define AG_CNT_START 13
char qindex;
+ unsigned char bridge;
+#define BRIDGE_SN9C102P 0
+#define BRIDGE_SN9C105 1
+#define BRIDGE_SN9C110 2
+#define BRIDGE_SN9C120 3
+#define BRIDGE_SN9C325 4
char sensor; /* Type of image sensor chip */
#define SENSOR_HV7131R 0
#define SENSOR_MI0360 1
#define SENSOR_MO4000 2
#define SENSOR_OV7648 3
#define SENSOR_OV7660 4
- unsigned char customid;
-#define SN9C102P 0
-#define SN9C105 1
-#define SN9C110 2
-#define SN9C120 3
-#define SN9C325 4
unsigned char i2c_base;
- unsigned char i2c_ctrl_reg;
};
/* V4L2 controls supported by the driver */
@@ -152,36 +151,36 @@ static struct v4l2_pix_format vga_mode[] = {
/*Data from sn9c102p+hv71331r */
static const __u8 sn_hv7131[] = {
- 0x00, 0x03, 0x64, 0x00, 0x1A, 0x20, 0x20, 0x20, 0xA1, 0x11,
/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 reg9 */
- 0x02, 0x09, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, /* 00 */
+ 0x00, 0x03, 0x64, 0x00, 0x1A, 0x20, 0x20, 0x20, 0xA1, 0x11,
/* rega regb regc regd rege regf reg10 reg11 */
- 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41, 0x0a, 0x00, 0x00, 0x00,
+ 0x02, 0x09, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, /* 00 */
/* reg12 reg13 reg14 reg15 reg16 reg17 reg18 reg19 reg1a reg1b */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41, 0x0a, 0x00, 0x00, 0x00,
/* reg1c reg1d reg1e reg1f reg20 reg21 reg22 reg23 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const __u8 sn_mi0360[] = {
- 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0xb1, 0x5d,
/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 reg9 */
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00,
+ 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0xb1, 0x5d,
/* rega regb regc regd rege regf reg10 reg11 */
- 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61, 0x06, 0x00, 0x00, 0x00,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00,
/* reg12 reg13 reg14 reg15 reg16 reg17 reg18 reg19 reg1a reg1b */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61, 0x06, 0x00, 0x00, 0x00,
/* reg1c reg1d reg1e reg1f reg20 reg21 reg22 reg23 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const __u8 sn_mo4000[] = {
- 0x12, 0x23, 0x60, 0x00, 0x1A, 0x00, 0x20, 0x18, 0x81,
/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 */
- 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
+ 0x12, 0x23, 0x60, 0x00, 0x1A, 0x00, 0x20, 0x18, 0x81,
/* reg9 rega regb regc regd rege regf reg10 reg11*/
- 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40, 0x08, 0x00, 0x00,
+ 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
/* reg12 reg13 reg14 reg15 reg16 reg17 reg18 reg19 reg1a*/
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x25, 0x39, 0x4b,
+ 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40, 0x08, 0x00, 0x00,
/* reg1b reg1c reg1d reg1e reg1f reg20 reg21 reg22 reg23*/
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x25, 0x39, 0x4b,
0x5c, 0x6b, 0x79, 0x87, 0x95, 0xa2, 0xaf, 0xbb, 0xc7,
0xd3, 0xdf, 0xea, 0xf5
};
@@ -199,7 +198,7 @@ static const __u8 sn_ov7660[] = {
/* reg9 rega regb regc regd rege regf reg10 reg11*/
0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
/* reg12 reg13 reg14 reg15 reg16 reg17 reg18 reg19 reg1a*/
- 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20, 0x07, 0x00, 0x00,
+ 0x01, 0x01, 0x14, 0x28, 0x1e, 0x00, 0x07, 0x00, 0x00,
/* reg1b reg1c reg1d reg1e reg1f reg20 reg21 reg22 reg23*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
#else
@@ -227,6 +226,10 @@ static const __u8 regsn20[] = {
0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
};
+static const __u8 regsn20_sn9c120[] = {
+ 0x00, 0x25, 0x3c, 0x50, 0x62, 0x72, 0x81, 0x90,
+ 0x9e, 0xab, 0xb8, 0xc5, 0xd1, 0xdd, 0xe9, 0xf4, 0xff
+};
static const __u8 regsn20_sn9c325[] = {
0x0a, 0x3a, 0x56, 0x6c, 0x7e, 0x8d, 0x9a, 0xa4,
0xaf, 0xbb, 0xc5, 0xcd, 0xd5, 0xde, 0xe8, 0xed, 0xf5
@@ -238,6 +241,21 @@ static const __u8 reg84[] = {
/* 0x00, 0x00, 0x00, 0x00, 0x00 */
0xf7, 0x0f, 0x0a, 0x00, 0x00
};
+static const __u8 reg84_sn9c120_1[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x00, 0x00
+};
+static const __u8 reg84_sn9c120_2[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x02, 0x3b
+};
+static const __u8 reg84_sn9c120_3[] = {
+ 0x14, 0x00, 0x27, 0x00, 0x08, 0x00, 0xeb, 0x0f,
+ 0xd5, 0x0f, 0x42, 0x00, 0x41, 0x00, 0xca, 0x0f,
+ 0xf5, 0x0f, 0x0c, 0x02, 0x3b
+};
static const __u8 reg84_sn9c325[] = {
0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe4, 0x0f,
0xd3, 0x0f, 0x4b, 0x00, 0x48, 0x00, 0xc0, 0x0f,
@@ -357,17 +375,15 @@ static const __u8 ov7660_sensor_init[][8] = {
{0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
/* Outformat ?? rawRGB */
{0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
-/* {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
- * GAIN BLUE RED VREF */
- {0xd1, 0x21, 0x00, 0x01, 0x74, 0x74, 0x00, 0x10},
+ {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
+/* {0xd1, 0x21, 0x00, 0x01, 0x74, 0x74, 0x00, 0x10}, */
/* GAIN BLUE RED VREF */
{0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
/* COM 1 BAVE GEAVE AECHH */
{0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
{0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
-/* {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xf8, 0x10},
- * AECH CLKRC COM7 COM8 */
- {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
+ {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xf8, 0x10},
+/* {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10}, */
/* AECH CLKRC COM7 COM8 */
{0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
{0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
@@ -376,9 +392,8 @@ static const __u8 ov7660_sensor_init[][8] = {
{0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
{0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
/* BOS GBOS GROS ROS (BGGR offset) */
-/* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10},
- * AEW AEB VPT BBIAS */
- {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
+ {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10},
+/* {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10}, */
/* AEW AEB VPT BBIAS */
{0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
/* GbBIAS RSVD EXHCH EXHCL */
@@ -428,14 +443,15 @@ static const __u8 ov7660_sensor_init[][8] = {
{0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* 0x20 */
{0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
{0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
- {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10},
-/* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, */
+/* {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, */
+ {0xa1, 0x21, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x10},
+ {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10},
/****** (some exchanges in the win trace) ******/
{0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
{0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10},/* dummy line low */
{0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
{0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
-/* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, */
+ {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10},
/****** (some exchanges in the win trace) ******/
/**********startsensor KO if changed !!****/
{0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
@@ -523,42 +539,40 @@ static const __u8 qtable4[] = {
0x29, 0x29, 0x29, 0x29
};
-static void reg_r(struct usb_device *dev,
- __u16 value,
- __u8 *buffer, int len)
+/* read <len> bytes (len < sizeof gspca_dev->usb_buf) to gspca_dev->usb_buf */
+static void reg_r(struct gspca_dev *gspca_dev,
+ __u16 value, int len)
{
- usb_control_msg(dev,
- usb_rcvctrlpipe(dev, 0),
+ usb_control_msg(gspca_dev->dev,
+ usb_rcvctrlpipe(gspca_dev->dev, 0),
0,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
value, 0,
- buffer, len,
+ gspca_dev->usb_buf, len,
500);
}
-static void reg_w(struct usb_device *dev,
+static void reg_w(struct gspca_dev *gspca_dev,
__u16 value,
const __u8 *buffer,
int len)
{
- if (len < 16) {
- __u8 tmpbuf[16];
-
- memcpy(tmpbuf, buffer, len);
- usb_control_msg(dev,
- usb_sndctrlpipe(dev, 0),
+ if (len <= sizeof gspca_dev->usb_buf) {
+ memcpy(gspca_dev->usb_buf, buffer, len);
+ usb_control_msg(gspca_dev->dev,
+ usb_sndctrlpipe(gspca_dev->dev, 0),
0x08,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
value, 0,
- tmpbuf, len,
+ gspca_dev->usb_buf, len,
500);
} else {
__u8 *tmpbuf;
tmpbuf = kmalloc(len, GFP_KERNEL);
memcpy(tmpbuf, buffer, len);
- usb_control_msg(dev,
- usb_sndctrlpipe(dev, 0),
+ usb_control_msg(gspca_dev->dev,
+ usb_sndctrlpipe(gspca_dev->dev, 0),
0x08,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
value, 0,
@@ -568,16 +582,15 @@ static void reg_w(struct usb_device *dev,
}
}
-/* write 2 bytes */
+/* I2C write 2 bytes */
static void i2c_w2(struct gspca_dev *gspca_dev,
const __u8 *buffer)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
__u8 mode[8];
/* is i2c ready */
- mode[0] = sd->i2c_ctrl_reg | (2 << 4);
+ mode[0] = 0x81 | (2 << 4);
mode[1] = sd->i2c_base;
mode[2] = buffer[0];
mode[3] = buffer[1];
@@ -585,25 +598,24 @@ static void i2c_w2(struct gspca_dev *gspca_dev,
mode[5] = 0;
mode[6] = 0;
mode[7] = 0x10;
- reg_w(dev, 0x08, mode, 8);
+ reg_w(gspca_dev, 0x08, mode, 8);
}
-/* write 8 bytes */
-static void i2c_w8(struct usb_device *dev, const __u8 *buffer)
+/* I2C write 8 bytes */
+static void i2c_w8(struct gspca_dev *gspca_dev,
+ const __u8 *buffer)
{
- reg_w(dev, 0x08, buffer, 8);
+ reg_w(gspca_dev, 0x08, buffer, 8);
msleep(1);
}
-/* read 5 bytes */
-static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg,
- __u8 *buffer)
+/* read 5 bytes in gspca_dev->usb_buf */
+static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
__u8 mode[8];
- mode[0] = sd->i2c_ctrl_reg | 0x10;
+ mode[0] = 0x81 | 0x10;
mode[1] = sd->i2c_base;
mode[2] = reg;
mode[3] = 0;
@@ -611,40 +623,39 @@ static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg,
mode[5] = 0;
mode[6] = 0;
mode[7] = 0x10;
- i2c_w8(dev, mode);
- mode[0] = sd->i2c_ctrl_reg | (5 << 4) | 0x02;
+ i2c_w8(gspca_dev, mode);
+ mode[0] = 0x81 | (5 << 4) | 0x02;
mode[2] = 0;
- i2c_w8(dev, mode);
- reg_r(dev, 0x0a, buffer, 5);
+ i2c_w8(gspca_dev, mode);
+ reg_r(gspca_dev, 0x0a, 5);
}
static int probesensor(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
__u8 reg02;
static const __u8 datasend[] = { 2, 0 };
/* reg val1 val2 val3 val4 */
- __u8 datarecd[6];
i2c_w2(gspca_dev, datasend);
/* should write 0xa1 0x11 0x02 0x00 0x00 0x00 0x00 the 0x10 is add by i2cw */
msleep(10);
reg02 = 0x66;
- reg_w(dev, 0x02, &reg02, 1); /* Gpio on */
+ reg_w(gspca_dev, 0x02, &reg02, 1); /* Gpio on */
msleep(10);
- i2c_r5(gspca_dev, 0, datarecd); /* read sensor id */
- if (datarecd[0] == 0x02
- && datarecd[1] == 0x09
- && datarecd[2] == 0x01
- && datarecd[3] == 0x00
- && datarecd[4] == 0x00) {
+ i2c_r5(gspca_dev, 0); /* read sensor id */
+ if (gspca_dev->usb_buf[0] == 0x02
+ && gspca_dev->usb_buf[1] == 0x09
+ && gspca_dev->usb_buf[2] == 0x01
+ && gspca_dev->usb_buf[3] == 0x00
+ && gspca_dev->usb_buf[4] == 0x00) {
PDEBUG(D_PROBE, "Find Sensor sn9c102P HV7131R");
sd->sensor = SENSOR_HV7131R;
return SENSOR_HV7131R;
}
PDEBUG(D_PROBE, "Find Sensor %d %d %d",
- datarecd[0], datarecd[1], datarecd[2]);
+ gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
+ gspca_dev->usb_buf[2]);
PDEBUG(D_PROBE, "Sensor sn9c102P Not found");
return -ENODEV;
}
@@ -653,7 +664,6 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
const __u8 *sn9c1xx)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
__u8 data;
__u8 regF1;
const __u8 *reg9a;
@@ -666,56 +676,55 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
regF1 = 0x00;
- reg_w(dev, 0xf1, &regF1, 1);
-
- reg_w(dev, 0x01, &sn9c1xx[0], 1); /*fixme:jfm was [1] en v1*/
+ reg_w(gspca_dev, 0xf1, &regF1, 1);
+ reg_w(gspca_dev, 0x01, &sn9c1xx[0], 1); /*fixme:jfm was [1] en v1*/
/* configure gpio */
- reg_w(dev, 0x01, &sn9c1xx[1], 2);
- reg_w(dev, 0x08, &sn9c1xx[8], 2);
- reg_w(dev, 0x17, &sn9c1xx[0x17], 3);
- switch (sd->customid) {
- case SN9C325:
+ reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
+ reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
+ reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm was 3 */
+ switch (sd->bridge) {
+ case BRIDGE_SN9C325:
reg9a = reg9a_sn9c325;
break;
- case SN9C120:
+ case BRIDGE_SN9C120:
reg9a = reg9a_sn9c120;
break;
default:
reg9a = reg9a_def;
break;
}
- reg_w(dev, 0x9a, reg9a, 6);
+ reg_w(gspca_dev, 0x9a, reg9a, 6);
data = 0x60; /*fixme:jfm 60 00 00 (3) */
- reg_w(dev, 0xd4, &data, 1);
+ reg_w(gspca_dev, 0xd4, &data, 1);
- reg_w(dev, 0x03, &sn9c1xx[3], 0x0f);
+ reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
- switch (sd->customid) {
- case SN9C120: /* from win trace */
+ switch (sd->bridge) {
+ case BRIDGE_SN9C120: /* from win trace */
data = 0x61;
- reg_w(dev, 0x01, &data, 1);
+ reg_w(gspca_dev, 0x01, &data, 1);
data = 0x20;
- reg_w(dev, 0x17, &data, 1);
+ reg_w(gspca_dev, 0x17, &data, 1);
data = 0x60;
- reg_w(dev, 0x01, &data, 1);
+ reg_w(gspca_dev, 0x01, &data, 1);
break;
- case SN9C325:
+ case BRIDGE_SN9C325:
data = 0x43;
- reg_w(dev, 0x01, &data, 1);
+ reg_w(gspca_dev, 0x01, &data, 1);
data = 0xae;
- reg_w(dev, 0x17, &data, 1);
+ reg_w(gspca_dev, 0x17, &data, 1);
data = 0x42;
- reg_w(dev, 0x01, &data, 1);
+ reg_w(gspca_dev, 0x01, &data, 1);
break;
default:
data = 0x43;
- reg_w(dev, 0x01, &data, 1);
+ reg_w(gspca_dev, 0x01, &data, 1);
data = 0x61;
- reg_w(dev, 0x17, &data, 1);
+ reg_w(gspca_dev, 0x17, &data, 1);
data = 0x42;
- reg_w(dev, 0x01, &data, 1);
+ reg_w(gspca_dev, 0x01, &data, 1);
}
if (sd->sensor == SENSOR_HV7131R) {
@@ -728,24 +737,22 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
static void hv7131R_InitSensor(struct gspca_dev *gspca_dev)
{
int i = 0;
- struct usb_device *dev = gspca_dev->dev;
static const __u8 SetSensorClk[] = /* 0x08 Mclk */
{ 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 };
while (hv7131r_sensor_init[i][0]) {
- i2c_w8(dev, hv7131r_sensor_init[i]);
+ i2c_w8(gspca_dev, hv7131r_sensor_init[i]);
i++;
}
- i2c_w8(dev, SetSensorClk);
+ i2c_w8(gspca_dev, SetSensorClk);
}
static void mi0360_InitSensor(struct gspca_dev *gspca_dev)
{
int i = 0;
- struct usb_device *dev = gspca_dev->dev;
while (mi0360_sensor_init[i][0]) {
- i2c_w8(dev, mi0360_sensor_init[i]);
+ i2c_w8(gspca_dev, mi0360_sensor_init[i]);
i++;
}
}
@@ -753,21 +760,19 @@ static void mi0360_InitSensor(struct gspca_dev *gspca_dev)
static void mo4000_InitSensor(struct gspca_dev *gspca_dev)
{
int i = 0;
- struct usb_device *dev = gspca_dev->dev;
while (mo4000_sensor_init[i][0]) {
- i2c_w8(dev, mo4000_sensor_init[i]);
+ i2c_w8(gspca_dev, mo4000_sensor_init[i]);
i++;
}
}
static void ov7648_InitSensor(struct gspca_dev *gspca_dev)
{
- struct usb_device *dev = gspca_dev->dev;
int i = 0;
while (ov7648_sensor_init[i][0]) {
- i2c_w8(dev, ov7648_sensor_init[i]);
+ i2c_w8(gspca_dev, ov7648_sensor_init[i]);
i++;
}
}
@@ -775,10 +780,9 @@ static void ov7648_InitSensor(struct gspca_dev *gspca_dev)
static void ov7660_InitSensor(struct gspca_dev *gspca_dev)
{
int i = 0;
- struct usb_device *dev = gspca_dev->dev;
while (ov7660_sensor_init[i][0]) {
- i2c_w8(dev, ov7660_sensor_init[i]);
+ i2c_w8(gspca_dev, ov7660_sensor_init[i]);
i++;
}
}
@@ -799,9 +803,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
case 0x0458: /* Genius */
/* switch (product) {
case 0x7025: */
- sd->customid = SN9C120;
+ sd->bridge = BRIDGE_SN9C120;
sd->sensor = SENSOR_MI0360;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x5d;
/* break;
} */
@@ -810,9 +813,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
/* switch (product) {
case 0x00f5:
case 0x00f7: */
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_OV7660;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x21;
/* break;
} */
@@ -822,9 +824,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
case 0x0327:
case 0x0328:
case 0x0330: */
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_MI0360;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x5d;
/* break;
} */
@@ -832,161 +833,137 @@ static int sd_config(struct gspca_dev *gspca_dev,
case 0x0c45: /* Sonix */
switch (product) {
case 0x6040:
- sd->customid = SN9C102P;
- sd->sensor = SENSOR_MI0360; /* from BW600.inf */
-/* sd->sensor = SENSOR_HV7131R; * gspcav1 value */
- sd->i2c_ctrl_reg = 0x81;
+ sd->bridge = BRIDGE_SN9C102P;
+/* sd->sensor = SENSOR_MI0360; * from BW600.inf */
+/*fixme: MI0360 base=5d ? */
+ sd->sensor = SENSOR_HV7131R; /* gspcav1 value */
sd->i2c_base = 0x11;
break;
/* case 0x607a: * from BW600.inf
- sd->customid = SN9C102P;
+ sd->bridge = BRIDGE_SN9C102P;
sd->sensor = SENSOR_OV7648;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
case 0x607c:
- sd->customid = SN9C102P;
+ sd->bridge = BRIDGE_SN9C102P;
sd->sensor = SENSOR_HV7131R;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x11;
break;
/* case 0x607e: * from BW600.inf
- sd->customid = SN9C102P;
+ sd->bridge = BRIDGE_SN9C102P;
sd->sensor = SENSOR_OV7630;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
case 0x60c0:
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_MI0360;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x5d;
break;
/* case 0x60c8: * from BW600.inf
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_OM6801;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
/* case 0x60cc: * from BW600.inf
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_HV7131GP;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
case 0x60ec:
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_MO4000;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x21;
break;
/* case 0x60ef: * from BW600.inf
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_ICM105C;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
/* case 0x60fa: * from BW600.inf
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_OV7648;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
case 0x60fb:
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_OV7660;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x21;
break;
case 0x60fc:
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_HV7131R;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x11;
break;
/* case 0x60fe: * from BW600.inf
- sd->customid = SN9C105;
+ sd->bridge = BRIDGE_SN9C105;
sd->sensor = SENSOR_OV7630;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
/* case 0x6108: * from BW600.inf
- sd->customid = SN9C120;
+ sd->bridge = BRIDGE_SN9C120;
sd->sensor = SENSOR_OM6801;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
/* case 0x6122: * from BW600.inf
- sd->customid = SN9C110;
+ sd->bridge = BRIDGE_SN9C110;
sd->sensor = SENSOR_ICM105C;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
case 0x612a:
-/* sd->customid = SN9C110; * in BW600.inf */
- sd->customid = SN9C325;
+/* sd->bridge = BRIDGE_SN9C110; * in BW600.inf */
+ sd->bridge = BRIDGE_SN9C325;
sd->sensor = SENSOR_OV7648;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x21;
+/*fixme: sensor_init has base = 00 et 6e!*/
break;
/* case 0x6123: * from BW600.inf
- sd->customid = SN9C110;
+ sd->bridge = BRIDGE_SN9C110;
sd->sensor = SENSOR_SanyoCCD;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
case 0x612c:
- sd->customid = SN9C110;
+ sd->bridge = BRIDGE_SN9C110;
sd->sensor = SENSOR_MO4000;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x21;
break;
/* case 0x612e: * from BW600.inf
- sd->customid = SN9C110;
+ sd->bridge = BRIDGE_SN9C110;
sd->sensor = SENSOR_OV7630;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
/* case 0x612f: * from BW600.inf
- sd->customid = SN9C110;
+ sd->bridge = BRIDGE_SN9C110;
sd->sensor = SENSOR_ICM105C;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
case 0x6130:
- sd->customid = SN9C120;
+ sd->bridge = BRIDGE_SN9C120;
sd->sensor = SENSOR_MI0360;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x5d;
break;
case 0x6138:
- sd->customid = SN9C120;
+ sd->bridge = BRIDGE_SN9C120;
sd->sensor = SENSOR_MO4000;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x21;
break;
/* case 0x613a: * from BW600.inf
- sd->customid = SN9C120;
+ sd->bridge = BRIDGE_SN9C120;
sd->sensor = SENSOR_OV7648;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
case 0x613b:
- sd->customid = SN9C120;
+ sd->bridge = BRIDGE_SN9C120;
sd->sensor = SENSOR_OV7660;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x21;
break;
case 0x613c:
- sd->customid = SN9C120;
+ sd->bridge = BRIDGE_SN9C120;
sd->sensor = SENSOR_HV7131R;
- sd->i2c_ctrl_reg = 0x81;
sd->i2c_base = 0x11;
break;
/* case 0x613e: * from BW600.inf
- sd->customid = SN9C120;
+ sd->bridge = BRIDGE_SN9C120;
sd->sensor = SENSOR_OV7630;
- sd->i2c_ctrl_reg = 0x??;
sd->i2c_base = 0x??;
break; */
}
@@ -1016,51 +993,52 @@ static int sd_config(struct gspca_dev *gspca_dev,
static int sd_open(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
/* const __u8 *sn9c1xx; */
__u8 regF1;
__u8 regGpio[] = { 0x29, 0x74 };
- /* setup a selector by customid */
+ /* setup a selector by bridge */
regF1 = 0x01;
- reg_w(dev, 0xf1, &regF1, 1);
- reg_r(dev, 0x00, &regF1, 1); /* -> regF1 = 0x00 */
- reg_w(dev, 0xf1, &regF1, 1);
- reg_r(dev, 0x00, &regF1, 1);
- switch (sd->customid) {
- case SN9C102P:
+ reg_w(gspca_dev, 0xf1, &regF1, 1);
+ reg_r(gspca_dev, 0x00, 1); /* -> regF1 = 0x00 */
+ regF1 = gspca_dev->usb_buf[0];
+ reg_w(gspca_dev, 0xf1, &regF1, 1);
+ reg_r(gspca_dev, 0x00, 1);
+ regF1 = gspca_dev->usb_buf[0];
+ switch (sd->bridge) {
+ case BRIDGE_SN9C102P:
if (regF1 != 0x11)
return -ENODEV;
- reg_w(dev, 0x02, &regGpio[1], 1);
+ reg_w(gspca_dev, 0x02, &regGpio[1], 1);
break;
- case SN9C105:
+ case BRIDGE_SN9C105:
if (regF1 != 0x11)
return -ENODEV;
- reg_w(dev, 0x02, regGpio, 2);
+ reg_w(gspca_dev, 0x02, regGpio, 2);
break;
- case SN9C110:
+ case BRIDGE_SN9C110:
if (regF1 != 0x12)
return -ENODEV;
regGpio[1] = 0x62;
- reg_w(dev, 0x02, &regGpio[1], 1);
+ reg_w(gspca_dev, 0x02, &regGpio[1], 1);
break;
- case SN9C120:
+ case BRIDGE_SN9C120:
if (regF1 != 0x12)
return -ENODEV;
regGpio[1] = 0x70;
- reg_w(dev, 0x02, regGpio, 2);
+ reg_w(gspca_dev, 0x02, regGpio, 2);
break;
default:
-/* case SN9C325: */
+/* case BRIDGE_SN9C325: */
if (regF1 != 0x12)
return -ENODEV;
regGpio[1] = 0x62;
- reg_w(dev, 0x02, &regGpio[1], 1);
+ reg_w(gspca_dev, 0x02, &regGpio[1], 1);
break;
}
regF1 = 0x01;
- reg_w(dev, 0xf1, &regF1, 1);
+ reg_w(gspca_dev, 0xf1, &regF1, 1);
#if 1 /*jfm: from win trace*/
return 0;
@@ -1089,7 +1067,7 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev,
Expodoit[3] = expo >> 16;
Expodoit[4] = expo >> 8;
Expodoit[5] = expo;
- i2c_w8(gspca_dev->dev, Expodoit);
+ i2c_w8(gspca_dev, Expodoit);
break;
}
case SENSOR_MI0360: {
@@ -1102,9 +1080,9 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev,
expo = 0x0001;
expoMi[3] = expo >> 8;
expoMi[4] = expo;
- i2c_w8(gspca_dev->dev, expoMi);
- i2c_w8(gspca_dev->dev, doit);
- i2c_w8(gspca_dev->dev, sensorgo);
+ i2c_w8(gspca_dev, expoMi);
+ i2c_w8(gspca_dev, doit);
+ i2c_w8(gspca_dev, sensorgo);
break;
}
case SENSOR_MO4000: {
@@ -1118,11 +1096,11 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev,
else if (expo < 0x0001)
expo = 0x0001;
expoMof[3] = (expo & 0x03fc) >> 2;
- i2c_w8(gspca_dev->dev, expoMof);
+ i2c_w8(gspca_dev, expoMof);
expoMo10[3] = ((expo & 0x1c00) >> 10)
| ((expo & 0x0003) << 4);
- i2c_w8(gspca_dev->dev, expoMo10);
- i2c_w8(gspca_dev->dev, gainMo);
+ i2c_w8(gspca_dev, expoMo10);
+ i2c_w8(gspca_dev, gainMo);
PDEBUG(D_CONF, "set exposure %d",
((expoMo10[3] & 0x07) << 10)
| (expoMof[3] << 2)
@@ -1161,7 +1139,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
}
k2 = sd->brightness >> 10;
- reg_w(gspca_dev->dev, 0x96, &k2, 1);
+ reg_w(gspca_dev, 0x96, &k2, 1);
}
static void setcontrast(struct gspca_dev *gspca_dev)
@@ -1176,7 +1154,7 @@ static void setcontrast(struct gspca_dev *gspca_dev)
contrast[2] = k2;
contrast[0] = (k2 + 1) >> 1;
contrast[4] = (k2 + 1) / 5;
- reg_w(gspca_dev->dev, 0x84, contrast, 6);
+ reg_w(gspca_dev, 0x84, contrast, 6);
}
static void setcolors(struct gspca_dev *gspca_dev)
@@ -1190,14 +1168,13 @@ static void setcolors(struct gspca_dev *gspca_dev)
data = (colour + 32) & 0x7f; /* blue */
else
data = (-colour + 32) & 0x7f; /* red */
- reg_w(gspca_dev->dev, 0x05, &data, 1);
+ reg_w(gspca_dev, 0x05, &data, 1);
}
/* -- start the camera -- */
static void sd_start(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
int i;
__u8 data;
__u8 reg1;
@@ -1219,45 +1196,73 @@ static void sd_start(struct gspca_dev *gspca_dev)
/*fixme:jfm this sequence should appear at end of sd_start */
/* with
data = 0x44;
- reg_w(dev, 0x01, &data, 1); */
- reg_w(dev, 0x15, &sn9c1xx[0x15], 1);
- reg_w(dev, 0x16, &sn9c1xx[0x16], 1);
- reg_w(dev, 0x12, &sn9c1xx[0x12], 1);
- reg_w(dev, 0x13, &sn9c1xx[0x13], 1);
- reg_w(dev, 0x18, &sn9c1xx[0x18], 1);
- reg_w(dev, 0xd2, &DC29[0], 1);
- reg_w(dev, 0xd3, &DC29[1], 1);
- reg_w(dev, 0xc6, &DC29[2], 1);
- reg_w(dev, 0xc7, &DC29[3], 1);
- reg_w(dev, 0xc8, &DC29[4], 1);
- reg_w(dev, 0xc9, &DC29[5], 1);
+ reg_w(gspca_dev, 0x01, &data, 1); */
+ reg_w(gspca_dev, 0x15, &sn9c1xx[0x15], 1);
+ reg_w(gspca_dev, 0x16, &sn9c1xx[0x16], 1);
+ reg_w(gspca_dev, 0x12, &sn9c1xx[0x12], 1);
+ reg_w(gspca_dev, 0x13, &sn9c1xx[0x13], 1);
+ reg_w(gspca_dev, 0x18, &sn9c1xx[0x18], 1);
+ reg_w(gspca_dev, 0xd2, &DC29[0], 1);
+ reg_w(gspca_dev, 0xd3, &DC29[1], 1);
+ reg_w(gspca_dev, 0xc6, &DC29[2], 1);
+ reg_w(gspca_dev, 0xc7, &DC29[3], 1);
+ reg_w(gspca_dev, 0xc8, &DC29[4], 1);
+ reg_w(gspca_dev, 0xc9, &DC29[5], 1);
/*fixme:jfm end of ending sequence */
- reg_w(dev, 0x18, &sn9c1xx[0x18], 1);
- if (sd->customid == SN9C325)
+ reg_w(gspca_dev, 0x18, &sn9c1xx[0x18], 1);
+ switch (sd->bridge) {
+ case BRIDGE_SN9C325:
data = 0xae;
- else
+ break;
+ case BRIDGE_SN9C120:
+ data = 0xa0;
+ break;
+ default:
data = 0x60;
- reg_w(dev, 0x17, &data, 1);
- reg_w(dev, 0x05, &sn9c1xx[5], 1);
- reg_w(dev, 0x07, &sn9c1xx[7], 1);
- reg_w(dev, 0x06, &sn9c1xx[6], 1);
- reg_w(dev, 0x14, &sn9c1xx[0x14], 1);
- if (sd->customid == SN9C325) {
- reg_w(dev, 0x20, regsn20_sn9c325, 0x11);
+ break;
+ }
+ reg_w(gspca_dev, 0x17, &data, 1);
+ reg_w(gspca_dev, 0x05, &sn9c1xx[5], 1);
+ reg_w(gspca_dev, 0x07, &sn9c1xx[7], 1);
+ reg_w(gspca_dev, 0x06, &sn9c1xx[6], 1);
+ reg_w(gspca_dev, 0x14, &sn9c1xx[0x14], 1);
+ switch (sd->bridge) {
+ case BRIDGE_SN9C325:
+ reg_w(gspca_dev, 0x20, regsn20_sn9c325,
+ sizeof regsn20_sn9c325);
for (i = 0; i < 8; i++)
- reg_w(dev, 0x84, reg84_sn9c325, 0x15);
+ reg_w(gspca_dev, 0x84, reg84_sn9c325,
+ sizeof reg84_sn9c325);
data = 0x0a;
- reg_w(dev, 0x9a, &data, 1);
+ reg_w(gspca_dev, 0x9a, &data, 1);
data = 0x60;
- reg_w(dev, 0x99, &data, 1);
- } else {
- reg_w(dev, 0x20, regsn20, 0x11);
+ reg_w(gspca_dev, 0x99, &data, 1);
+ break;
+ case BRIDGE_SN9C120:
+ reg_w(gspca_dev, 0x20, regsn20_sn9c120,
+ sizeof regsn20_sn9c120);
+ for (i = 0; i < 2; i++)
+ reg_w(gspca_dev, 0x84, reg84_sn9c120_1,
+ sizeof reg84_sn9c120_1);
+ for (i = 0; i < 6; i++)
+ reg_w(gspca_dev, 0x84, reg84_sn9c120_2,
+ sizeof reg84_sn9c120_2);
+ reg_w(gspca_dev, 0x84, reg84_sn9c120_3,
+ sizeof reg84_sn9c120_3);
+ data = 0x05;
+ reg_w(gspca_dev, 0x9a, &data, 1);
+ data = 0x5b;
+ reg_w(gspca_dev, 0x99, &data, 1);
+ break;
+ default:
+ reg_w(gspca_dev, 0x20, regsn20, sizeof regsn20);
for (i = 0; i < 8; i++)
- reg_w(dev, 0x84, reg84, 0x15);
+ reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
data = 0x08;
- reg_w(dev, 0x9a, &data, 1);
+ reg_w(gspca_dev, 0x9a, &data, 1);
data = 0x59;
- reg_w(dev, 0x99, &data, 1);
+ reg_w(gspca_dev, 0x99, &data, 1);
+ break;
}
mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
@@ -1315,38 +1320,38 @@ static void sd_start(struct gspca_dev *gspca_dev)
}
break;
}
- reg_w(dev, 0xc0, C0, 6);
- switch (sd->customid) {
- case SN9C120: /*jfm ?? */
- reg_w(dev, 0xca, CA_sn9c120, 4);
+ reg_w(gspca_dev, 0xc0, C0, 6);
+ switch (sd->bridge) {
+ case BRIDGE_SN9C120: /*jfm ?? */
+ reg_w(gspca_dev, 0xca, CA_sn9c120, 4);
break;
default:
- reg_w(dev, 0xca, CA, 4);
+ reg_w(gspca_dev, 0xca, CA, 4);
break;
}
- switch (sd->customid) {
- case SN9C120: /*jfm ?? */
- case SN9C325:
- reg_w(dev, 0xce, CE_sn9c325, 4);
+ switch (sd->bridge) {
+ case BRIDGE_SN9C120: /*jfm ?? */
+ case BRIDGE_SN9C325:
+ reg_w(gspca_dev, 0xce, CE_sn9c325, 4);
break;
default:
- reg_w(dev, 0xce, CE, 4);
+ reg_w(gspca_dev, 0xce, CE, 4);
/* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
break;
}
/* here change size mode 0 -> VGA; 1 -> CIF */
data = 0x40 | sn9c1xx[0x18] | (mode << 4);
- reg_w(dev, 0x18, &data, 1);
+ reg_w(gspca_dev, 0x18, &data, 1);
- reg_w(dev, 0x100, qtable4, 0x40);
- reg_w(dev, 0x140, qtable4 + 0x40, 0x40);
+ reg_w(gspca_dev, 0x100, qtable4, 0x40);
+ reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40);
data = sn9c1xx[0x18] | (mode << 4);
- reg_w(dev, 0x18, &data, 1);
+ reg_w(gspca_dev, 0x18, &data, 1);
- reg_w(dev, 0x17, &reg17, 1);
- reg_w(dev, 0x01, &reg1, 1);
+ reg_w(gspca_dev, 0x17, &reg17, 1);
+ reg_w(gspca_dev, 0x01, &reg1, 1);
setbrightness(gspca_dev);
setcontrast(gspca_dev);
}
@@ -1354,7 +1359,6 @@ static void sd_start(struct gspca_dev *gspca_dev)
static void sd_stopN(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
static const __u8 stophv7131[] =
{ 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
static const __u8 stopmi0360[] =
@@ -1366,11 +1370,11 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
data = 0x0b;
switch (sd->sensor) {
case SENSOR_HV7131R:
- i2c_w8(dev, stophv7131);
+ i2c_w8(gspca_dev, stophv7131);
data = 0x2b;
break;
case SENSOR_MI0360:
- i2c_w8(dev, stopmi0360);
+ i2c_w8(gspca_dev, stopmi0360);
data = 0x29;
break;
case SENSOR_MO4000:
@@ -1383,12 +1387,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
break;
}
sn9c1xx = sn_tb[(int) sd->sensor];
- reg_w(dev, 0x01, &sn9c1xx[1], 1);
- reg_w(dev, 0x17, &sn9c1xx[0x17], 1);
- reg_w(dev, 0x01, &sn9c1xx[1], 1);
- reg_w(dev, 0x01, &data, 1);
+ reg_w(gspca_dev, 0x01, &sn9c1xx[1], 1);
+ reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 1);
+ reg_w(gspca_dev, 0x01, &sn9c1xx[1], 1);
+ reg_w(gspca_dev, 0x01, &data, 1);
regF1 = 0x01;
- reg_w(dev, 0xf1, &regF1, 1);
+ reg_w(gspca_dev, 0xf1, &regF1, 1);
}
static void sd_stop0(struct gspca_dev *gspca_dev)
@@ -1484,33 +1488,35 @@ static unsigned int getexposure(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
__u8 hexpo, mexpo, lexpo;
- __u8 expo[6];
switch (sd->sensor) {
case SENSOR_HV7131R:
/* read sensor exposure */
- i2c_r5(gspca_dev, 0x25, expo);
- return (expo[0] << 16) | (expo[1] << 8) | expo[2];
+ i2c_r5(gspca_dev, 0x25);
+ return (gspca_dev->usb_buf[0] << 16)
+ | (gspca_dev->usb_buf[1] << 8)
+ | gspca_dev->usb_buf[2];
case SENSOR_MI0360:
/* read sensor exposure */
- i2c_r5(gspca_dev, 0x09, expo);
- return (expo[0] << 8) | expo[1];
+ i2c_r5(gspca_dev, 0x09);
+ return (gspca_dev->usb_buf[0] << 8)
+ | gspca_dev->usb_buf[1];
case SENSOR_MO4000:
- i2c_r5(gspca_dev, 0x0e, expo);
- hexpo = 0; /* expo[1] & 0x07; */
- mexpo = 0x40; /* expo[2] &0xff; */
- lexpo = (expo[1] & 0x30) >> 4;
+ i2c_r5(gspca_dev, 0x0e);
+ hexpo = 0; /* gspca_dev->usb_buf[1] & 0x07; */
+ mexpo = 0x40; /* gspca_dev->usb_buf[2] & 0xff; */
+ lexpo = (gspca_dev->usb_buf[1] & 0x30) >> 4;
PDEBUG(D_CONF, "exposure %d",
(hexpo << 10) | (mexpo << 2) | lexpo);
return (hexpo << 10) | (mexpo << 2) | lexpo;
default:
/* case SENSOR_OV7660: */
/* read sensor exposure */
- i2c_r5(gspca_dev, 0x04, expo);
- hexpo = expo[3] & 0x2f;
- lexpo = expo[0] & 0x02;
- i2c_r5(gspca_dev, 0x08, expo);
- mexpo = expo[2];
+ i2c_r5(gspca_dev, 0x04);
+ hexpo = gspca_dev->usb_buf[3] & 0x2f;
+ lexpo = gspca_dev->usb_buf[0] & 0x02;
+ i2c_r5(gspca_dev, 0x08);
+ mexpo = gspca_dev->usb_buf[2];
return (hexpo << 10) | (mexpo << 2) | lexpo;
}
}