Commit bf7f0b98 authored by Jean-Francois Moine's avatar Jean-Francois Moine Committed by Mauro Carvalho Chehab

V4L/DVB (8193): gspca: Input buffer may be changed on reg write.

Done for conex, etoms, pac7311, sonixj, t613 and tv8532.
Code cleanup for some other subdrivers.
Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 0d2a722d
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
#define CONEX_CAM 1 /* special JPEG header */ #define CONEX_CAM 1 /* special JPEG header */
#include "jpeg.h" #include "jpeg.h"
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0) #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 3)
static const char version[] = "2.1.0"; static const char version[] = "2.1.3";
MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver"); MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver");
...@@ -114,21 +114,29 @@ static void reg_r(struct usb_device *dev, ...@@ -114,21 +114,29 @@ static void reg_r(struct usb_device *dev,
0, 0,
index, buffer, length, index, buffer, length,
500); 500);
PDEBUG(D_USBI, "reg read i:%02x -> %02x", index, *buffer); PDEBUG(D_USBI, "reg read [%02x] -> %02x ..", index, *buffer);
} }
static void reg_w(struct usb_device *dev, static void reg_w(struct usb_device *dev,
__u16 index, __u16 index,
const __u8 *buffer, __u16 length) const __u8 *buffer, __u16 len)
{ {
PDEBUG(D_USBO, "reg write i:%02x = %02x", index, *buffer); __u8 tmpbuf[8];
#ifdef CONFIG_VIDEO_ADV_DEBUG
if (len > sizeof tmpbuf) {
PDEBUG(D_ERR|D_PACK, "reg_w: buffer overflow");
return;
}
PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer);
#endif
memcpy(tmpbuf, buffer, len);
usb_control_msg(dev, usb_control_msg(dev,
usb_sndctrlpipe(dev, 0), usb_sndctrlpipe(dev, 0),
0, 0,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, 0,
index, (__u8 *) buffer, length, index, tmpbuf, len, 500);
500);
} }
static const __u8 cx_sensor_init[][4] = { static const __u8 cx_sensor_init[][4] = {
...@@ -269,7 +277,7 @@ static void cx_sensor(struct gspca_dev*gspca_dev) ...@@ -269,7 +277,7 @@ static void cx_sensor(struct gspca_dev*gspca_dev)
reg_w(gspca_dev->dev, 0x0071, reg71b, 4); reg_w(gspca_dev->dev, 0x0071, reg71b, 4);
break; break;
default: default:
/* case 2: */ /* case 2: */
reg_w(gspca_dev->dev, 0x0071, reg71c, 4); reg_w(gspca_dev->dev, 0x0071, reg71c, 4);
break; break;
case 3: case 3:
...@@ -662,8 +670,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev) ...@@ -662,8 +670,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
for (i = 0; i < 27; i++) { for (i = 0; i < 27; i++) {
if (i == 26) if (i == 26)
length = 2; length = 2;
reg_w(gspca_dev->dev, 0x0008, reg_w(gspca_dev->dev, 0x0008, cxjpeg_640[i], length);
cxjpeg_640[i], length);
} }
Reg55 = 0x28; Reg55 = 0x28;
break; break;
...@@ -671,8 +678,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev) ...@@ -671,8 +678,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
for (i = 0; i < 27; i++) { for (i = 0; i < 27; i++) {
if (i == 26) if (i == 26)
length = 2; length = 2;
reg_w(gspca_dev->dev, 0x0008, reg_w(gspca_dev->dev, 0x0008, cxjpeg_352[i], length);
cxjpeg_352[i], length);
} }
Reg55 = 0x16; Reg55 = 0x16;
break; break;
...@@ -681,8 +687,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev) ...@@ -681,8 +687,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
for (i = 0; i < 27; i++) { for (i = 0; i < 27; i++) {
if (i == 26) if (i == 26)
length = 2; length = 2;
reg_w(gspca_dev->dev, 0x0008, reg_w(gspca_dev->dev, 0x0008, cxjpeg_320[i], length);
cxjpeg_320[i], length);
} }
Reg55 = 0x14; Reg55 = 0x14;
break; break;
...@@ -690,8 +695,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev) ...@@ -690,8 +695,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
for (i = 0; i < 27; i++) { for (i = 0; i < 27; i++) {
if (i == 26) if (i == 26)
length = 2; length = 2;
reg_w(gspca_dev->dev, 0x0008, reg_w(gspca_dev->dev, 0x0008, cxjpeg_176[i], length);
cxjpeg_176[i], length);
} }
Reg55 = 0x0B; Reg55 = 0x0B;
break; break;
...@@ -731,8 +735,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev) ...@@ -731,8 +735,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev)
for (i = 0; i < 18; i++) { for (i = 0; i < 18; i++) {
if (i == 17) if (i == 17)
length = 2; length = 2;
reg_w(gspca_dev->dev, 0x0008, reg_w(gspca_dev->dev, 0x0008, cxjpeg_qtable[i], length);
cxjpeg_qtable[i], length);
} }
reg_r(gspca_dev->dev, 0x0002, &val, 1); /* 0x00 */ reg_r(gspca_dev->dev, 0x0002, &val, 1); /* 0x00 */
...@@ -866,7 +869,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev) ...@@ -866,7 +869,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
reg_w(gspca_dev->dev, 0x0053, &val, 1); reg_w(gspca_dev->dev, 0x0053, &val, 1);
while (retry--) { while (retry--) {
/* reg_r (gspca_dev->dev,0x00,0x00,0x0002,&val,1);*/ /* reg_r(gspca_dev->dev, 0x0002, &val, 1);*/
reg_r(gspca_dev->dev, 0x0053, &val, 1); reg_r(gspca_dev->dev, 0x0053, &val, 1);
if (val == 0) if (val == 0)
break; break;
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "gspca.h" #include "gspca.h"
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0) #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 3)
static const char version[] = "2.1.0"; static const char version[] = "2.1.3";
MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
MODULE_DESCRIPTION("Etoms USB Camera Driver"); MODULE_DESCRIPTION("Etoms USB Camera Driver");
...@@ -213,7 +213,7 @@ static __u8 I2c3[] = { 0x12, 0x05 }; ...@@ -213,7 +213,7 @@ static __u8 I2c3[] = { 0x12, 0x05 };
static __u8 I2c4[] = { 0x41, 0x08 }; static __u8 I2c4[] = { 0x41, 0x08 };
static void Et_RegRead(struct usb_device *dev, static void reg_r(struct usb_device *dev,
__u16 index, __u8 *buffer, int len) __u16 index, __u8 *buffer, int len)
{ {
usb_control_msg(dev, usb_control_msg(dev,
...@@ -223,14 +223,17 @@ static void Et_RegRead(struct usb_device *dev, ...@@ -223,14 +223,17 @@ static void Et_RegRead(struct usb_device *dev,
0, index, buffer, len, 500); 0, index, buffer, len, 500);
} }
static void Et_RegWrite(struct usb_device *dev, static void reg_w(struct usb_device *dev,
__u16 index, __u8 *buffer, __u16 len) __u16 index, __u8 *buffer, __u16 len)
{ {
__u8 tmpbuf[8];
memcpy(tmpbuf, buffer, len);
usb_control_msg(dev, usb_control_msg(dev,
usb_sndctrlpipe(dev, 0), usb_sndctrlpipe(dev, 0),
0, 0,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
0, index, buffer, len, 500); 0, index, tmpbuf, len, 500);
} }
static int Et_i2cwrite(struct usb_device *dev, __u8 reg, __u8 *buffer, static int Et_i2cwrite(struct usb_device *dev, __u8 reg, __u8 *buffer,
...@@ -243,14 +246,14 @@ static int Et_i2cwrite(struct usb_device *dev, __u8 reg, __u8 *buffer, ...@@ -243,14 +246,14 @@ static int Et_i2cwrite(struct usb_device *dev, __u8 reg, __u8 *buffer,
ptchcount = (((length & 0x07) << 4) | (mode & 0x03)); ptchcount = (((length & 0x07) << 4) | (mode & 0x03));
/* set the base address */ /* set the base address */
Et_RegWrite(dev, ET_I2C_BASE, &base, 1); reg_w(dev, ET_I2C_BASE, &base, 1);
/* set count and prefetch */ /* set count and prefetch */
Et_RegWrite(dev, ET_I2C_COUNT, &ptchcount, 1); reg_w(dev, ET_I2C_COUNT, &ptchcount, 1);
/* set the register base */ /* set the register base */
Et_RegWrite(dev, ET_I2C_REG, &reg, 1); reg_w(dev, ET_I2C_REG, &reg, 1);
j = length - 1; j = length - 1;
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
Et_RegWrite(dev, (ET_I2C_DATA0 + j), &buffer[j], 1); reg_w(dev, (ET_I2C_DATA0 + j), &buffer[j], 1);
j--; j--;
} }
return 0; return 0;
...@@ -267,17 +270,17 @@ static int Et_i2cread(struct usb_device *dev, __u8 reg, __u8 *buffer, ...@@ -267,17 +270,17 @@ static int Et_i2cread(struct usb_device *dev, __u8 reg, __u8 *buffer,
ptchcount = (((length & 0x07) << 4) | (mode & 0x03)); ptchcount = (((length & 0x07) << 4) | (mode & 0x03));
/* set the base address */ /* set the base address */
Et_RegWrite(dev, ET_I2C_BASE, &base, 1); reg_w(dev, ET_I2C_BASE, &base, 1);
/* set count and prefetch */ /* set count and prefetch */
Et_RegWrite(dev, ET_I2C_COUNT, &ptchcount, 1); reg_w(dev, ET_I2C_COUNT, &ptchcount, 1);
/* set the register base */ /* set the register base */
Et_RegWrite(dev, ET_I2C_REG, &reg, 1); reg_w(dev, ET_I2C_REG, &reg, 1);
Et_RegWrite(dev, ET_I2C_PREFETCH, &prefetch, 1); reg_w(dev, ET_I2C_PREFETCH, &prefetch, 1);
prefetch = 0x00; prefetch = 0x00;
Et_RegWrite(dev, ET_I2C_PREFETCH, &prefetch, 1); reg_w(dev, ET_I2C_PREFETCH, &prefetch, 1);
j = length - 1; j = length - 1;
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
Et_RegRead(dev, (ET_I2C_DATA0 + j), &buffer[j], 1); reg_r(dev, (ET_I2C_DATA0 + j), &buffer[j], 1);
j--; j--;
} }
return 0; return 0;
...@@ -289,7 +292,7 @@ static int Et_WaitStatus(struct usb_device *dev) ...@@ -289,7 +292,7 @@ static int Et_WaitStatus(struct usb_device *dev)
int retry = 10; int retry = 10;
while (retry--) { while (retry--) {
Et_RegRead(dev, ET_ClCK, &bytereceived, 1); reg_r(dev, ET_ClCK, &bytereceived, 1);
if (bytereceived != 0) if (bytereceived != 0)
return 1; return 1;
} }
...@@ -301,7 +304,7 @@ static int Et_videoOff(struct usb_device *dev) ...@@ -301,7 +304,7 @@ static int Et_videoOff(struct usb_device *dev)
int err; int err;
__u8 stopvideo = 0; __u8 stopvideo = 0;
Et_RegWrite(dev, ET_GPIO_OUT, &stopvideo, 1); reg_w(dev, ET_GPIO_OUT, &stopvideo, 1);
err = Et_WaitStatus(dev); err = Et_WaitStatus(dev);
if (!err) if (!err)
PDEBUG(D_ERR, "timeout Et_waitStatus VideoON"); PDEBUG(D_ERR, "timeout Et_waitStatus VideoON");
...@@ -313,7 +316,7 @@ static int Et_videoOn(struct usb_device *dev) ...@@ -313,7 +316,7 @@ static int Et_videoOn(struct usb_device *dev)
int err; int err;
__u8 startvideo = 0x10; /* set Bit5 */ __u8 startvideo = 0x10; /* set Bit5 */
Et_RegWrite(dev, ET_GPIO_OUT, &startvideo, 1); reg_w(dev, ET_GPIO_OUT, &startvideo, 1);
err = Et_WaitStatus(dev); err = Et_WaitStatus(dev);
if (!err) if (!err)
PDEBUG(D_ERR, "timeout Et_waitStatus VideoOFF"); PDEBUG(D_ERR, "timeout Et_waitStatus VideoOFF");
...@@ -329,156 +332,156 @@ static void Et_init2(struct gspca_dev *gspca_dev) ...@@ -329,156 +332,156 @@ static void Et_init2(struct gspca_dev *gspca_dev)
PDEBUG(D_STREAM, "Open Init2 ET"); PDEBUG(D_STREAM, "Open Init2 ET");
value = 0x2f; value = 0x2f;
Et_RegWrite(dev, ET_GPIO_DIR_CTRL, &value, 1); reg_w(dev, ET_GPIO_DIR_CTRL, &value, 1);
value = 0x10; value = 0x10;
Et_RegWrite(dev, ET_GPIO_OUT, &value, 1); reg_w(dev, ET_GPIO_OUT, &value, 1);
Et_RegRead(dev, ET_GPIO_IN, &received, 1); reg_r(dev, ET_GPIO_IN, &received, 1);
value = 0x14; /* 0x14 // 0x16 enabled pattern */ value = 0x14; /* 0x14 // 0x16 enabled pattern */
Et_RegWrite(dev, ET_ClCK, &value, 1); reg_w(dev, ET_ClCK, &value, 1);
value = 0x1b; value = 0x1b;
Et_RegWrite(dev, ET_CTRL, &value, 1); reg_w(dev, ET_CTRL, &value, 1);
/* compression et subsampling */ /* compression et subsampling */
if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode) if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode)
value = ET_COMP_VAL1; /* 320 */ value = ET_COMP_VAL1; /* 320 */
else else
value = ET_COMP_VAL0; /* 640 */ value = ET_COMP_VAL0; /* 640 */
Et_RegWrite(dev, ET_COMP, &value, 1); reg_w(dev, ET_COMP, &value, 1);
value = 0x1f; value = 0x1f;
Et_RegWrite(dev, ET_MAXQt, &value, 1); reg_w(dev, ET_MAXQt, &value, 1);
value = 0x04; value = 0x04;
Et_RegWrite(dev, ET_MINQt, &value, 1); reg_w(dev, ET_MINQt, &value, 1);
/* undocumented registers */ /* undocumented registers */
value = 0xff; value = 0xff;
Et_RegWrite(dev, ET_REG1d, &value, 1); reg_w(dev, ET_REG1d, &value, 1);
value = 0xff; value = 0xff;
Et_RegWrite(dev, ET_REG1e, &value, 1); reg_w(dev, ET_REG1e, &value, 1);
value = 0xff; value = 0xff;
Et_RegWrite(dev, ET_REG1f, &value, 1); reg_w(dev, ET_REG1f, &value, 1);
value = 0x35; value = 0x35;
Et_RegWrite(dev, ET_REG20, &value, 1); reg_w(dev, ET_REG20, &value, 1);
value = 0x01; value = 0x01;
Et_RegWrite(dev, ET_REG21, &value, 1); reg_w(dev, ET_REG21, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_REG22, &value, 1); reg_w(dev, ET_REG22, &value, 1);
value = 0xff; value = 0xff;
Et_RegWrite(dev, ET_REG23, &value, 1); reg_w(dev, ET_REG23, &value, 1);
value = 0xff; value = 0xff;
Et_RegWrite(dev, ET_REG24, &value, 1); reg_w(dev, ET_REG24, &value, 1);
value = 0x0f; value = 0x0f;
Et_RegWrite(dev, ET_REG25, &value, 1); reg_w(dev, ET_REG25, &value, 1);
/* colors setting */ /* colors setting */
value = 0x11; value = 0x11;
Et_RegWrite(dev, 0x30, &value, 1); /* 0x30 */ reg_w(dev, 0x30, &value, 1); /* 0x30 */
value = 0x40; value = 0x40;
Et_RegWrite(dev, 0x31, &value, 1); reg_w(dev, 0x31, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, 0x32, &value, 1); reg_w(dev, 0x32, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_O_RED, &value, 1); /* 0x34 */ reg_w(dev, ET_O_RED, &value, 1); /* 0x34 */
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_O_GREEN1, &value, 1); reg_w(dev, ET_O_GREEN1, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_O_BLUE, &value, 1); reg_w(dev, ET_O_BLUE, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_O_GREEN2, &value, 1); reg_w(dev, ET_O_GREEN2, &value, 1);
/*************/ /*************/
value = 0x80; value = 0x80;
Et_RegWrite(dev, ET_G_RED, &value, 1); /* 0x4d */ reg_w(dev, ET_G_RED, &value, 1); /* 0x4d */
value = 0x80; value = 0x80;
Et_RegWrite(dev, ET_G_GREEN1, &value, 1); reg_w(dev, ET_G_GREEN1, &value, 1);
value = 0x80; value = 0x80;
Et_RegWrite(dev, ET_G_BLUE, &value, 1); reg_w(dev, ET_G_BLUE, &value, 1);
value = 0x80; value = 0x80;
Et_RegWrite(dev, ET_G_GREEN2, &value, 1); reg_w(dev, ET_G_GREEN2, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_G_GR_H, &value, 1); reg_w(dev, ET_G_GR_H, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_G_GB_H, &value, 1); /* 0x52 */ reg_w(dev, ET_G_GB_H, &value, 1); /* 0x52 */
/* Window control registers */ /* Window control registers */
value = 0x80; /* use cmc_out */ value = 0x80; /* use cmc_out */
Et_RegWrite(dev, 0x61, &value, 1); reg_w(dev, 0x61, &value, 1);
value = 0x02; value = 0x02;
Et_RegWrite(dev, 0x62, &value, 1); reg_w(dev, 0x62, &value, 1);
value = 0x03; value = 0x03;
Et_RegWrite(dev, 0x63, &value, 1); reg_w(dev, 0x63, &value, 1);
value = 0x14; value = 0x14;
Et_RegWrite(dev, 0x64, &value, 1); reg_w(dev, 0x64, &value, 1);
value = 0x0e; value = 0x0e;
Et_RegWrite(dev, 0x65, &value, 1); reg_w(dev, 0x65, &value, 1);
value = 0x02; value = 0x02;
Et_RegWrite(dev, 0x66, &value, 1); reg_w(dev, 0x66, &value, 1);
value = 0x02; value = 0x02;
Et_RegWrite(dev, 0x67, &value, 1); reg_w(dev, 0x67, &value, 1);
/**************************************/ /**************************************/
value = 0x8f; value = 0x8f;
Et_RegWrite(dev, ET_SYNCHRO, &value, 1); /* 0x68 */ reg_w(dev, ET_SYNCHRO, &value, 1); /* 0x68 */
value = 0x69; /* 0x6a //0x69 */ value = 0x69; /* 0x6a //0x69 */
Et_RegWrite(dev, ET_STARTX, &value, 1); reg_w(dev, ET_STARTX, &value, 1);
value = 0x0d; /* 0x0d //0x0c */ value = 0x0d; /* 0x0d //0x0c */
Et_RegWrite(dev, ET_STARTY, &value, 1); reg_w(dev, ET_STARTY, &value, 1);
value = 0x80; value = 0x80;
Et_RegWrite(dev, ET_WIDTH_LOW, &value, 1); reg_w(dev, ET_WIDTH_LOW, &value, 1);
value = 0xe0; value = 0xe0;
Et_RegWrite(dev, ET_HEIGTH_LOW, &value, 1); reg_w(dev, ET_HEIGTH_LOW, &value, 1);
value = 0x60; value = 0x60;
Et_RegWrite(dev, ET_W_H_HEIGTH, &value, 1); /* 6d */ reg_w(dev, ET_W_H_HEIGTH, &value, 1); /* 6d */
value = 0x86; value = 0x86;
Et_RegWrite(dev, ET_REG6e, &value, 1); reg_w(dev, ET_REG6e, &value, 1);
value = 0x01; value = 0x01;
Et_RegWrite(dev, ET_REG6f, &value, 1); reg_w(dev, ET_REG6f, &value, 1);
value = 0x26; value = 0x26;
Et_RegWrite(dev, ET_REG70, &value, 1); reg_w(dev, ET_REG70, &value, 1);
value = 0x7a; value = 0x7a;
Et_RegWrite(dev, ET_REG71, &value, 1); reg_w(dev, ET_REG71, &value, 1);
value = 0x01; value = 0x01;
Et_RegWrite(dev, ET_REG72, &value, 1); reg_w(dev, ET_REG72, &value, 1);
/* Clock Pattern registers ***************** */ /* Clock Pattern registers ***************** */
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_REG73, &value, 1); reg_w(dev, ET_REG73, &value, 1);
value = 0x18; /* 0x28 */ value = 0x18; /* 0x28 */
Et_RegWrite(dev, ET_REG74, &value, 1); reg_w(dev, ET_REG74, &value, 1);
value = 0x0f; /* 0x01 */ value = 0x0f; /* 0x01 */
Et_RegWrite(dev, ET_REG75, &value, 1); reg_w(dev, ET_REG75, &value, 1);
/**********************************************/ /**********************************************/
value = 0x20; value = 0x20;
Et_RegWrite(dev, 0x8a, &value, 1); reg_w(dev, 0x8a, &value, 1);
value = 0x0f; value = 0x0f;
Et_RegWrite(dev, 0x8d, &value, 1); reg_w(dev, 0x8d, &value, 1);
value = 0x08; value = 0x08;
Et_RegWrite(dev, 0x8e, &value, 1); reg_w(dev, 0x8e, &value, 1);
/**************************************/ /**************************************/
value = 0x08; value = 0x08;
Et_RegWrite(dev, 0x03, &value, 1); reg_w(dev, 0x03, &value, 1);
value = 0x03; value = 0x03;
Et_RegWrite(dev, ET_PXL_CLK, &value, 1); reg_w(dev, ET_PXL_CLK, &value, 1);
value = 0xff; value = 0xff;
Et_RegWrite(dev, 0x81, &value, 1); reg_w(dev, 0x81, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, 0x80, &value, 1); reg_w(dev, 0x80, &value, 1);
value = 0xff; value = 0xff;
Et_RegWrite(dev, 0x81, &value, 1); reg_w(dev, 0x81, &value, 1);
value = 0x20; value = 0x20;
Et_RegWrite(dev, 0x80, &value, 1); reg_w(dev, 0x80, &value, 1);
value = 0x01; value = 0x01;
Et_RegWrite(dev, 0x03, &value, 1); reg_w(dev, 0x03, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, 0x03, &value, 1); reg_w(dev, 0x03, &value, 1);
value = 0x08; value = 0x08;
Et_RegWrite(dev, 0x03, &value, 1); reg_w(dev, 0x03, &value, 1);
/********************************************/ /********************************************/
/* Et_RegRead(dev,0x0,ET_I2C_BASE,&received,1); /* reg_r(dev,0x0,ET_I2C_BASE,&received,1);
always 0x40 as the pas106 ??? */ always 0x40 as the pas106 ??? */
/* set the sensor */ /* set the sensor */
if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode) { if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode) {
value = 0x04; /* 320 */ value = 0x04; /* 320 */
Et_RegWrite(dev, ET_PXL_CLK, &value, 1); reg_w(dev, ET_PXL_CLK, &value, 1);
/* now set by fifo the FormatLine setting */ /* now set by fifo the FormatLine setting */
Et_RegWrite(dev, 0x62, FormLine, 6); reg_w(dev, 0x62, FormLine, 6);
} else { /* 640 */ } else { /* 640 */
/* setting PixelClock /* setting PixelClock
0x03 mean 24/(3+1) = 6 Mhz 0x03 mean 24/(3+1) = 6 Mhz
...@@ -487,24 +490,24 @@ static void Et_init2(struct gspca_dev *gspca_dev) ...@@ -487,24 +490,24 @@ static void Et_init2(struct gspca_dev *gspca_dev)
0x17 -> 24/(23+1) = 1 Mhz 0x17 -> 24/(23+1) = 1 Mhz
*/ */
value = 0x1e; /* 0x17 */ value = 0x1e; /* 0x17 */
Et_RegWrite(dev, ET_PXL_CLK, &value, 1); reg_w(dev, ET_PXL_CLK, &value, 1);
/* now set by fifo the FormatLine setting */ /* now set by fifo the FormatLine setting */
Et_RegWrite(dev, 0x62, FormLine, 6); reg_w(dev, 0x62, FormLine, 6);
} }
/* set exposure times [ 0..0x78] 0->longvalue 0x78->shortvalue */ /* set exposure times [ 0..0x78] 0->longvalue 0x78->shortvalue */
value = 0x47; /* 0x47; */ value = 0x47; /* 0x47; */
Et_RegWrite(dev, 0x81, &value, 1); reg_w(dev, 0x81, &value, 1);
value = 0x40; /* 0x40; */ value = 0x40; /* 0x40; */
Et_RegWrite(dev, 0x80, &value, 1); reg_w(dev, 0x80, &value, 1);
/* Pedro change */ /* Pedro change */
/* Brightness change Brith+ decrease value */ /* Brightness change Brith+ decrease value */
/* Brigth- increase value */ /* Brigth- increase value */
/* original value = 0x70; */ /* original value = 0x70; */
value = 0x30; /* 0x20; */ value = 0x30; /* 0x20; */
Et_RegWrite(dev, 0x81, &value, 1); /* set brightness */ reg_w(dev, 0x81, &value, 1); /* set brightness */
value = 0x20; /* 0x20; */ value = 0x20; /* 0x20; */
Et_RegWrite(dev, 0x80, &value, 1); reg_w(dev, 0x80, &value, 1);
} }
static void setcolors(struct gspca_dev *gspca_dev) static void setcolors(struct gspca_dev *gspca_dev)
...@@ -554,16 +557,16 @@ static void Et_init1(struct gspca_dev *gspca_dev) ...@@ -554,16 +557,16 @@ static void Et_init1(struct gspca_dev *gspca_dev)
PDEBUG(D_STREAM, "Open Init1 ET"); PDEBUG(D_STREAM, "Open Init1 ET");
value = 7; value = 7;
Et_RegWrite(dev, ET_GPIO_DIR_CTRL, &value, 1); reg_w(dev, ET_GPIO_DIR_CTRL, &value, 1);
Et_RegRead(dev, ET_GPIO_IN, &received, 1); reg_r(dev, ET_GPIO_IN, &received, 1);
value = 1; value = 1;
Et_RegWrite(dev, ET_RESET_ALL, &value, 1); reg_w(dev, ET_RESET_ALL, &value, 1);
value = 0; value = 0;
Et_RegWrite(dev, ET_RESET_ALL, &value, 1); reg_w(dev, ET_RESET_ALL, &value, 1);
value = 0x10; value = 0x10;
Et_RegWrite(dev, ET_ClCK, &value, 1); reg_w(dev, ET_ClCK, &value, 1);
value = 0x19; value = 0x19;
Et_RegWrite(dev, ET_CTRL, &value, 1); reg_w(dev, ET_CTRL, &value, 1);
/* compression et subsampling */ /* compression et subsampling */
if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode) if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode)
value = ET_COMP_VAL1; value = ET_COMP_VAL1;
...@@ -573,77 +576,77 @@ static void Et_init1(struct gspca_dev *gspca_dev) ...@@ -573,77 +576,77 @@ static void Et_init1(struct gspca_dev *gspca_dev)
PDEBUG(D_STREAM, "Open mode %d Compression %d", PDEBUG(D_STREAM, "Open mode %d Compression %d",
gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode, gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode,
value); value);
Et_RegWrite(dev, ET_COMP, &value, 1); reg_w(dev, ET_COMP, &value, 1);
value = 0x1d; value = 0x1d;
Et_RegWrite(dev, ET_MAXQt, &value, 1); reg_w(dev, ET_MAXQt, &value, 1);
value = 0x02; value = 0x02;
Et_RegWrite(dev, ET_MINQt, &value, 1); reg_w(dev, ET_MINQt, &value, 1);
/* undocumented registers */ /* undocumented registers */
value = 0xff; value = 0xff;
Et_RegWrite(dev, ET_REG1d, &value, 1); reg_w(dev, ET_REG1d, &value, 1);
value = 0xff; value = 0xff;
Et_RegWrite(dev, ET_REG1e, &value, 1); reg_w(dev, ET_REG1e, &value, 1);
value = 0xff; value = 0xff;
Et_RegWrite(dev, ET_REG1f, &value, 1); reg_w(dev, ET_REG1f, &value, 1);
value = 0x35; value = 0x35;
Et_RegWrite(dev, ET_REG20, &value, 1); reg_w(dev, ET_REG20, &value, 1);
value = 0x01; value = 0x01;
Et_RegWrite(dev, ET_REG21, &value, 1); reg_w(dev, ET_REG21, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_REG22, &value, 1); reg_w(dev, ET_REG22, &value, 1);
value = 0xf7; value = 0xf7;
Et_RegWrite(dev, ET_REG23, &value, 1); reg_w(dev, ET_REG23, &value, 1);
value = 0xff; value = 0xff;
Et_RegWrite(dev, ET_REG24, &value, 1); reg_w(dev, ET_REG24, &value, 1);
value = 0x07; value = 0x07;
Et_RegWrite(dev, ET_REG25, &value, 1); reg_w(dev, ET_REG25, &value, 1);
/* colors setting */ /* colors setting */
value = 0x80; value = 0x80;
Et_RegWrite(dev, ET_G_RED, &value, 1); reg_w(dev, ET_G_RED, &value, 1);
value = 0x80; value = 0x80;
Et_RegWrite(dev, ET_G_GREEN1, &value, 1); reg_w(dev, ET_G_GREEN1, &value, 1);
value = 0x80; value = 0x80;
Et_RegWrite(dev, ET_G_BLUE, &value, 1); reg_w(dev, ET_G_BLUE, &value, 1);
value = 0x80; value = 0x80;
Et_RegWrite(dev, ET_G_GREEN2, &value, 1); reg_w(dev, ET_G_GREEN2, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_G_GR_H, &value, 1); reg_w(dev, ET_G_GR_H, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_G_GB_H, &value, 1); reg_w(dev, ET_G_GB_H, &value, 1);
/* Window control registers */ /* Window control registers */
value = 0xf0; value = 0xf0;
Et_RegWrite(dev, ET_SYNCHRO, &value, 1); reg_w(dev, ET_SYNCHRO, &value, 1);
value = 0x56; /* 0x56 */ value = 0x56; /* 0x56 */
Et_RegWrite(dev, ET_STARTX, &value, 1); reg_w(dev, ET_STARTX, &value, 1);
value = 0x05; /* 0x04 */ value = 0x05; /* 0x04 */
Et_RegWrite(dev, ET_STARTY, &value, 1); reg_w(dev, ET_STARTY, &value, 1);
value = 0x60; value = 0x60;
Et_RegWrite(dev, ET_WIDTH_LOW, &value, 1); reg_w(dev, ET_WIDTH_LOW, &value, 1);
value = 0x20; value = 0x20;
Et_RegWrite(dev, ET_HEIGTH_LOW, &value, 1); reg_w(dev, ET_HEIGTH_LOW, &value, 1);
value = 0x50; value = 0x50;
Et_RegWrite(dev, ET_W_H_HEIGTH, &value, 1); reg_w(dev, ET_W_H_HEIGTH, &value, 1);
value = 0x86; value = 0x86;
Et_RegWrite(dev, ET_REG6e, &value, 1); reg_w(dev, ET_REG6e, &value, 1);
value = 0x01; value = 0x01;
Et_RegWrite(dev, ET_REG6f, &value, 1); reg_w(dev, ET_REG6f, &value, 1);
value = 0x86; value = 0x86;
Et_RegWrite(dev, ET_REG70, &value, 1); reg_w(dev, ET_REG70, &value, 1);
value = 0x14; value = 0x14;
Et_RegWrite(dev, ET_REG71, &value, 1); reg_w(dev, ET_REG71, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_REG72, &value, 1); reg_w(dev, ET_REG72, &value, 1);
/* Clock Pattern registers */ /* Clock Pattern registers */
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_REG73, &value, 1); reg_w(dev, ET_REG73, &value, 1);
value = 0x00; value = 0x00;
Et_RegWrite(dev, ET_REG74, &value, 1); reg_w(dev, ET_REG74, &value, 1);
value = 0x0a; value = 0x0a;
Et_RegWrite(dev, ET_REG75, &value, 1); reg_w(dev, ET_REG75, &value, 1);
value = 0x04; value = 0x04;
Et_RegWrite(dev, ET_I2C_CLK, &value, 1); reg_w(dev, ET_I2C_CLK, &value, 1);
value = 0x01; value = 0x01;
Et_RegWrite(dev, ET_PXL_CLK, &value, 1); reg_w(dev, ET_PXL_CLK, &value, 1);
/* set the sensor */ /* set the sensor */
if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode) { if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode) {
I2c0[0] = 0x06; I2c0[0] = 0x06;
...@@ -679,7 +682,7 @@ static void Et_init1(struct gspca_dev *gspca_dev) ...@@ -679,7 +682,7 @@ static void Et_init1(struct gspca_dev *gspca_dev)
/* magnetude and sign bit for DAC */ /* magnetude and sign bit for DAC */
Et_i2cwrite(dev, PAS106_REG7, I2c4, sizeof I2c4, 1); Et_i2cwrite(dev, PAS106_REG7, I2c4, sizeof I2c4, 1);
/* now set by fifo the whole colors setting */ /* now set by fifo the whole colors setting */
Et_RegWrite(dev, ET_G_RED, GainRGBG, 6); reg_w(dev, ET_G_RED, GainRGBG, 6);
getcolors(gspca_dev); getcolors(gspca_dev);
setcolors(gspca_dev); setcolors(gspca_dev);
} }
...@@ -738,7 +741,7 @@ static int sd_open(struct gspca_dev *gspca_dev) ...@@ -738,7 +741,7 @@ static int sd_open(struct gspca_dev *gspca_dev)
else else
Et_init2(gspca_dev); Et_init2(gspca_dev);
value = 0x08; value = 0x08;
Et_RegWrite(dev, ET_RESET_ALL, &value, 1); reg_w(dev, ET_RESET_ALL, &value, 1);
err = Et_videoOff(dev); err = Et_videoOff(dev);
PDEBUG(D_STREAM, "Et_Init_VideoOff %d", err); PDEBUG(D_STREAM, "Et_Init_VideoOff %d", err);
return 0; return 0;
...@@ -758,7 +761,7 @@ static void sd_start(struct gspca_dev *gspca_dev) ...@@ -758,7 +761,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
Et_init2(gspca_dev); Et_init2(gspca_dev);
value = 0x08; value = 0x08;
Et_RegWrite(dev, ET_RESET_ALL, &value, 1); reg_w(dev, ET_RESET_ALL, &value, 1);
err = Et_videoOn(dev); err = Et_videoOn(dev);
PDEBUG(D_STREAM, "Et_VideoOn %d", err); PDEBUG(D_STREAM, "Et_VideoOn %d", err);
} }
...@@ -787,7 +790,7 @@ static void setbrightness(struct gspca_dev *gspca_dev) ...@@ -787,7 +790,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
__u8 brightness = sd->brightness; __u8 brightness = sd->brightness;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
Et_RegWrite(gspca_dev->dev, (ET_O_RED + i), &brightness, 1); reg_w(gspca_dev->dev, (ET_O_RED + i), &brightness, 1);
} }
static void getbrightness(struct gspca_dev *gspca_dev) static void getbrightness(struct gspca_dev *gspca_dev)
...@@ -798,7 +801,7 @@ static void getbrightness(struct gspca_dev *gspca_dev) ...@@ -798,7 +801,7 @@ static void getbrightness(struct gspca_dev *gspca_dev)
__u8 value = 0; __u8 value = 0;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
Et_RegRead(gspca_dev->dev, (ET_O_RED + i), &value, 1); reg_r(gspca_dev->dev, (ET_O_RED + i), &value, 1);
brightness += value; brightness += value;
} }
sd->brightness = brightness >> 3; sd->brightness = brightness >> 3;
...@@ -811,7 +814,7 @@ static void setcontrast(struct gspca_dev *gspca_dev) ...@@ -811,7 +814,7 @@ static void setcontrast(struct gspca_dev *gspca_dev)
__u8 contrast = sd->contrast; __u8 contrast = sd->contrast;
memset(RGBG, contrast, sizeof RGBG - 2); memset(RGBG, contrast, sizeof RGBG - 2);
Et_RegWrite(gspca_dev->dev, ET_G_RED, RGBG, 6); reg_w(gspca_dev->dev, ET_G_RED, RGBG, 6);
} }
static void getcontrast(struct gspca_dev *gspca_dev) static void getcontrast(struct gspca_dev *gspca_dev)
...@@ -822,7 +825,7 @@ static void getcontrast(struct gspca_dev *gspca_dev) ...@@ -822,7 +825,7 @@ static void getcontrast(struct gspca_dev *gspca_dev)
__u8 value = 0; __u8 value = 0;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
Et_RegRead(gspca_dev->dev, (ET_G_RED + i), &value, 1); reg_r(gspca_dev->dev, (ET_G_RED + i), &value, 1);
contrast += value; contrast += value;
} }
sd->contrast = contrast >> 2; sd->contrast = contrast >> 2;
...@@ -870,7 +873,7 @@ static void setautogain(struct gspca_dev *gspca_dev) ...@@ -870,7 +873,7 @@ static void setautogain(struct gspca_dev *gspca_dev)
__u8 r, g, b; __u8 r, g, b;
Gbright = Et_getgainG(gspca_dev); Gbright = Et_getgainG(gspca_dev);
Et_RegRead(dev, ET_LUMA_CENTER, GRBG, 4); reg_r(dev, ET_LUMA_CENTER, GRBG, 4);
g = (GRBG[0] + GRBG[3]) >> 1; g = (GRBG[0] + GRBG[3]) >> 1;
r = GRBG[1]; r = GRBG[1];
b = GRBG[2]; b = GRBG[2];
......
...@@ -79,49 +79,35 @@ enum { ...@@ -79,49 +79,35 @@ enum {
}; };
static int pcam_reg_write(struct usb_device *dev, static int pcam_reg_write(struct usb_device *dev,
__u16 index, unsigned char *value, int length) __u16 index, __u8 *value, int len)
{ {
int rc; int rc;
rc = usb_control_msg(dev, rc = usb_control_msg(dev,
usb_sndbulkpipe(dev, 4), usb_sndbulkpipe(dev, 4),
0x12, 0x12,
/* ?? 0xc8 = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_??? !? */ /* ?? 0xc8 = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_??? !? */
0xc8, 0xc8,
0, /* value */ 0, /* value */
index, value, length, 500); index, value, len, 500);
PDEBUG(D_USBO, "reg write: 0x%02X , result = 0x%x", index, rc);
if (rc < 0) if (rc < 0)
PDEBUG(D_ERR, "reg write: error %d", rc); PDEBUG(D_ERR, "reg write [%02x] error %d", index, rc);
return rc; return rc;
} }
static void MISensor_BulkWrite(struct usb_device *dev, unsigned short *pch, static void MISensor_BulkWrite(struct usb_device *dev,
char Address) unsigned short *pch,
char Address)
{ {
int result; __u8 data[6];
unsigned char data[6];
data[0] = 0x1f; data[0] = 0x1f;
data[1] = 0; data[1] = 0; /* control byte */
data[2] = Address; data[2] = Address;
data[3] = *pch >> 8; /* high byte */ data[3] = *pch >> 8; /* high byte */
data[4] = *pch; /* low byte */ data[4] = *pch; /* low byte */
data[5] = 0;
result = usb_control_msg(dev,
usb_sndbulkpipe(dev, 4),
0x12,
/* ?? 0xc8 = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_??? !? */
0xc8,
0, /* value */
Address, /* index */
data, 5, 500);
PDEBUG(D_USBO, "bulk write 0x%02x = 0x%04x", Address, *pch);
if (result < 0) pcam_reg_write(dev, Address, data, 5);
PDEBUG(D_ERR, "reg write: error %d", result);
} }
/* this function is called at probe time */ /* this function is called at probe time */
...@@ -167,7 +153,7 @@ static void sd_start(struct gspca_dev *gspca_dev) ...@@ -167,7 +153,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
data[0] = 0x01; /* address */ data[0] = 0x01; /* address */
data[1] = 0x01; data[1] = 0x01;
err_code = pcam_reg_write(dev, data[0], data, 0x02); err_code = pcam_reg_write(dev, data[0], data, 2);
if (err_code < 0) if (err_code < 0)
return; return;
...@@ -193,14 +179,14 @@ static void sd_start(struct gspca_dev *gspca_dev) ...@@ -193,14 +179,14 @@ static void sd_start(struct gspca_dev *gspca_dev)
data[10] = 0x5d; /* reg 9, I2C device address data[10] = 0x5d; /* reg 9, I2C device address
* [for PAS5101 (0x40)] [for MI (0x5d)] */ * [for PAS5101 (0x40)] [for MI (0x5d)] */
err_code = pcam_reg_write(dev, data[0], data, 0x0b); err_code = pcam_reg_write(dev, data[0], data, 11);
if (err_code < 0) if (err_code < 0)
return; return;
data[0] = 0x23; /* address */ data[0] = 0x23; /* address */
data[1] = 0x09; /* reg 35, append frame header */ data[1] = 0x09; /* reg 35, append frame header */
err_code = pcam_reg_write(dev, data[0], data, 0x02); err_code = pcam_reg_write(dev, data[0], data, 2);
if (err_code < 0) { if (err_code < 0) {
PDEBUG(D_ERR, "Register write failed"); PDEBUG(D_ERR, "Register write failed");
return; return;
...@@ -213,7 +199,7 @@ static void sd_start(struct gspca_dev *gspca_dev) ...@@ -213,7 +199,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
/* else */ /* else */
data[1] = 50; /* 50 reg 60, pc-cam frame size data[1] = 50; /* 50 reg 60, pc-cam frame size
* (unit: 4KB) 200KB */ * (unit: 4KB) 200KB */
err_code = pcam_reg_write(dev, data[0], data, 0x02); err_code = pcam_reg_write(dev, data[0], data, 2);
if (err_code < 0) if (err_code < 0)
return; return;
...@@ -255,13 +241,13 @@ static void sd_start(struct gspca_dev *gspca_dev) ...@@ -255,13 +241,13 @@ static void sd_start(struct gspca_dev *gspca_dev)
/* auto dark-gain */ /* auto dark-gain */
data[0] = 0x5e; /* address */ data[0] = 0x5e; /* address */
err_code = pcam_reg_write(dev, data[0], data, 0x06); err_code = pcam_reg_write(dev, data[0], data, 6);
if (err_code < 0) if (err_code < 0)
return; return;
data[0] = 0x67; data[0] = 0x67;
data[1] = 0x13; /* reg 103, first pixel B, disable sharpness */ data[1] = 0x13; /* reg 103, first pixel B, disable sharpness */
err_code = pcam_reg_write(dev, data[0], data, 0x02); err_code = pcam_reg_write(dev, data[0], data, 2);
if (err_code < 0) if (err_code < 0)
return; return;
...@@ -340,7 +326,7 @@ static void sd_start(struct gspca_dev *gspca_dev) ...@@ -340,7 +326,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
data[0] = 0x00; data[0] = 0x00;
data[1] = 0x4d; /* ISOC transfering enable... */ data[1] = 0x4d; /* ISOC transfering enable... */
pcam_reg_write(dev, data[0], data, 0x02); pcam_reg_write(dev, data[0], data, 2);
} }
static void sd_stopN(struct gspca_dev *gspca_dev) static void sd_stopN(struct gspca_dev *gspca_dev)
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include "gspca.h" #include "gspca.h"
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0) #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 3)
static const char version[] = "2.1.0"; static const char version[] = "2.1.3";
MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li"); MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li");
MODULE_DESCRIPTION("Pixart PAC7311"); MODULE_DESCRIPTION("Pixart PAC7311");
...@@ -195,16 +195,18 @@ const unsigned char pac7311_jpeg_header[] = { ...@@ -195,16 +195,18 @@ const unsigned char pac7311_jpeg_header[] = {
}; };
static void reg_w(struct usb_device *dev, static void reg_w(struct usb_device *dev,
__u16 req,
__u16 value,
__u16 index, __u16 index,
__u8 *buffer, __u16 length) char *buffer, __u16 len)
{ {
__u8 tmpbuf[8];
memcpy(tmpbuf, buffer, len);
usb_control_msg(dev, usb_control_msg(dev,
usb_sndctrlpipe(dev, 0), usb_sndctrlpipe(dev, 0),
req, 1, /* request */
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index, buffer, length, 0, /* value */
index, tmpbuf, len,
500); 500);
} }
...@@ -227,7 +229,12 @@ static void pac7311_reg_write(struct usb_device *dev, ...@@ -227,7 +229,12 @@ static void pac7311_reg_write(struct usb_device *dev,
__u8 buf; __u8 buf;
buf = value; buf = value;
reg_w(dev, 0x00, value, index, &buf, 1); usb_control_msg(dev,
usb_sndctrlpipe(dev, 0),
0, /* request */
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index, &buf, 1,
500);
} }
/* this function is called at probe time */ /* this function is called at probe time */
...@@ -313,26 +320,26 @@ static void sd_start(struct gspca_dev *gspca_dev) ...@@ -313,26 +320,26 @@ static void sd_start(struct gspca_dev *gspca_dev)
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
pac7311_reg_write(dev, 0xff, 0x01); pac7311_reg_write(dev, 0xff, 0x01);
reg_w(dev, 0x01, 0, 0x0002, "\x48\x0a\x40\x08\x00\x00\x08\x00", 8); reg_w(dev, 0x0002, "\x48\x0a\x40\x08\x00\x00\x08\x00", 8);
reg_w(dev, 0x01, 0, 0x000a, "\x06\xff\x11\xff\x5a\x30\x90\x4c", 8); reg_w(dev, 0x000a, "\x06\xff\x11\xff\x5a\x30\x90\x4c", 8);
reg_w(dev, 0x01, 0, 0x0012, "\x00\x07\x00\x0a\x10\x00\xa0\x10", 8); reg_w(dev, 0x0012, "\x00\x07\x00\x0a\x10\x00\xa0\x10", 8);
reg_w(dev, 0x01, 0, 0x001a, "\x02\x00\x00\x00\x00\x0b\x01\x00", 8); reg_w(dev, 0x001a, "\x02\x00\x00\x00\x00\x0b\x01\x00", 8);
reg_w(dev, 0x01, 0, 0x0022, "\x00\x00\x00\x00\x00\x00\x00\x00", 8); reg_w(dev, 0x0022, "\x00\x00\x00\x00\x00\x00\x00\x00", 8);
reg_w(dev, 0x01, 0, 0x002a, "\x00\x00\x00", 3); reg_w(dev, 0x002a, "\x00\x00\x00", 3);
reg_w(dev, 0x01, 0, 0x003e, "\x00\x00\x78\x52\x4a\x52\x78\x6e", 8); reg_w(dev, 0x003e, "\x00\x00\x78\x52\x4a\x52\x78\x6e", 8);
reg_w(dev, 0x01, 0, 0x0046, "\x48\x46\x48\x6e\x5f\x49\x42\x49", 8); reg_w(dev, 0x0046, "\x48\x46\x48\x6e\x5f\x49\x42\x49", 8);
reg_w(dev, 0x01, 0, 0x004e, "\x5f\x5f\x49\x42\x49\x5f\x6e\x48", 8); reg_w(dev, 0x004e, "\x5f\x5f\x49\x42\x49\x5f\x6e\x48", 8);
reg_w(dev, 0x01, 0, 0x0056, "\x46\x48\x6e\x78\x52\x4a\x52\x78", 8); reg_w(dev, 0x0056, "\x46\x48\x6e\x78\x52\x4a\x52\x78", 8);
reg_w(dev, 0x01, 0, 0x005e, "\x00\x00\x09\x1b\x34\x49\x5c\x9b", 8); reg_w(dev, 0x005e, "\x00\x00\x09\x1b\x34\x49\x5c\x9b", 8);
reg_w(dev, 0x01, 0, 0x0066, "\xd0\xff", 2); reg_w(dev, 0x0066, "\xd0\xff", 2);
reg_w(dev, 0x01, 0, 0x0078, "\x44\x00\xf2\x01\x01\x80", 6); reg_w(dev, 0x0078, "\x44\x00\xf2\x01\x01\x80", 6);
reg_w(dev, 0x01, 0, 0x007f, "\x2a\x1c\x00\xc8\x02\x58\x03\x84", 8); reg_w(dev, 0x007f, "\x2a\x1c\x00\xc8\x02\x58\x03\x84", 8);
reg_w(dev, 0x01, 0, 0x0087, "\x12\x00\x1a\x04\x08\x0c\x10\x14", 8); reg_w(dev, 0x0087, "\x12\x00\x1a\x04\x08\x0c\x10\x14", 8);
reg_w(dev, 0x01, 0, 0x008f, "\x18\x20", 2); reg_w(dev, 0x008f, "\x18\x20", 2);
reg_w(dev, 0x01, 0, 0x0096, "\x01\x08\x04", 3); reg_w(dev, 0x0096, "\x01\x08\x04", 3);
reg_w(dev, 0x01, 0, 0x00a0, "\x44\x44\x44\x04", 4); reg_w(dev, 0x00a0, "\x44\x44\x44\x04", 4);
reg_w(dev, 0x01, 0, 0x00f0, "\x01\x00\x00\x00\x22\x00\x20\x00", 8); reg_w(dev, 0x00f0, "\x01\x00\x00\x00\x22\x00\x20\x00", 8);
reg_w(dev, 0x01, 0, 0x00f8, "\x3f\x00\x0a\x01\x00", 5); reg_w(dev, 0x00f8, "\x3f\x00\x0a\x01\x00", 5);
pac7311_reg_write(dev, 0xff, 0x04); pac7311_reg_write(dev, 0xff, 0x04);
pac7311_reg_write(dev, 0x02, 0x04); pac7311_reg_write(dev, 0x02, 0x04);
......
...@@ -334,7 +334,7 @@ static void reg_r(struct usb_device *dev, ...@@ -334,7 +334,7 @@ static void reg_r(struct usb_device *dev,
static void reg_w(struct usb_device *dev, static void reg_w(struct usb_device *dev,
__u16 value, __u16 value,
const __u8 *buffer, const __u8 *buffer,
__u16 len) int len)
{ {
__u8 tmpbuf[32]; __u8 tmpbuf[32];
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include "gspca.h" #include "gspca.h"
#include "jpeg.h" #include "jpeg.h"
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0) #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 3)
static const char version[] = "2.1.0"; static const char version[] = "2.1.3";
MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
...@@ -515,15 +515,24 @@ static void reg_r(struct usb_device *dev, ...@@ -515,15 +515,24 @@ static void reg_r(struct usb_device *dev,
static void reg_w(struct usb_device *dev, static void reg_w(struct usb_device *dev,
__u16 value, __u16 value,
__u8 *buffer, const __u8 *buffer,
int len) int len)
{ {
__u8 tmpbuf[64];
#ifdef CONFIG_VIDEO_ADV_DEBUG
if (len > sizeof tmpbuf) {
PDEBUG(D_ERR|D_PACK, "reg_w: buffer overflow");
return;
}
#endif
memcpy(tmpbuf, buffer, len);
usb_control_msg(dev, usb_control_msg(dev,
usb_sndctrlpipe(dev, 0), usb_sndctrlpipe(dev, 0),
0x08, 0x08,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
value, 0, value, 0,
buffer, len, tmpbuf, len,
500); 500);
} }
......
...@@ -377,7 +377,7 @@ static int reg_write(struct usb_device *dev, ...@@ -377,7 +377,7 @@ static int reg_write(struct usb_device *dev,
ret = usb_control_msg(dev, ret = usb_control_msg(dev,
usb_sndctrlpipe(dev, 0), usb_sndctrlpipe(dev, 0),
req, req,
USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index, NULL, 0, 500); value, index, NULL, 0, 500);
PDEBUG(D_USBO, "reg write: [0x%02x] = 0x%02x, 0x%x", PDEBUG(D_USBO, "reg write: [0x%02x] = 0x%02x, 0x%x",
index, value, ret); index, value, ret);
......
...@@ -456,7 +456,7 @@ static int reg_write(struct usb_device *dev, ...@@ -456,7 +456,7 @@ static int reg_write(struct usb_device *dev,
ret = usb_control_msg(dev, ret = usb_control_msg(dev,
usb_sndctrlpipe(dev, 0), usb_sndctrlpipe(dev, 0),
req, req,
USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index, NULL, 0, 500); value, index, NULL, 0, 500);
PDEBUG(D_PACK, "reg write: 0x%02x,0x%02x:0x%02x, 0x%x", PDEBUG(D_PACK, "reg write: 0x%02x,0x%02x:0x%02x, 0x%x",
req, index, value, ret); req, index, value, ret);
......
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#define MODULE_NAME "t613" #define MODULE_NAME "t613"
#include "gspca.h" #include "gspca.h"
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0) #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 3)
static const char version[] = "2.1.0"; static const char version[] = "2.1.3";
struct control_menu_info { struct control_menu_info {
int value; int value;
...@@ -366,13 +366,22 @@ static void t16RegRead(struct usb_device *dev, ...@@ -366,13 +366,22 @@ static void t16RegRead(struct usb_device *dev,
static void t16RegWrite(struct usb_device *dev, static void t16RegWrite(struct usb_device *dev,
__u16 value, __u16 value,
__u16 index, __u8 *buffer, __u16 length) __u16 index, __u8 *buffer, __u16 len)
{ {
__u8 tmpbuf[70];
#ifdef CONFIG_VIDEO_ADV_DEBUG
if (len > sizeof tmpbuf) {
PDEBUG(D_ERR|D_PACK, "reg_w: buffer overflow");
return;
}
#endif
memcpy(tmpbuf, buffer, len);
usb_control_msg(dev, usb_control_msg(dev,
usb_sndctrlpipe(dev, 0), usb_sndctrlpipe(dev, 0),
0, /* request */ 0, /* request */
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index, buffer, length, 500); value, index, tmpbuf, len, 500);
} }
/* this function is called at probe time */ /* this function is called at probe time */
...@@ -491,24 +500,24 @@ static int init_default_parameters(struct gspca_dev *gspca_dev) ...@@ -491,24 +500,24 @@ static int init_default_parameters(struct gspca_dev *gspca_dev)
t16RegWrite(dev, 0x00, 0x3880, 0x00, 0x0); t16RegWrite(dev, 0x00, 0x3880, 0x00, 0x0);
t16RegWrite(dev, 0x00, 0x3880, 0x00, 0x0); t16RegWrite(dev, 0x00, 0x3880, 0x00, 0x0);
t16RegWrite(dev, 0x00, 0x338e, 0x00, 0x0); t16RegWrite(dev, 0x00, 0x338e, 0x00, 0x0);
t16RegWrite(dev, 0x01, 00, nset5, 0x04); t16RegWrite(dev, 0x01, 0x0000, nset5, 0x04);
t16RegWrite(dev, 0x00, 0x00a9, 0x00, 0x0); t16RegWrite(dev, 0x00, 0x00a9, 0x00, 0x0);
t16RegWrite(dev, 0x01, 00, nset6, 0x22); t16RegWrite(dev, 0x01, 0x0000, nset6, 0x22);
t16RegWrite(dev, 0x00, 0x86bb, 0x00, 0x0); t16RegWrite(dev, 0x00, 0x86bb, 0x00, 0x0);
t16RegWrite(dev, 0x00, 0x4aa6, 0x00, 0x0); t16RegWrite(dev, 0x00, 0x4aa6, 0x00, 0x0);
t16RegWrite(dev, 0x01, 00, missing, 0x08); t16RegWrite(dev, 0x01, 0x0000, missing, 0x08);
t16RegWrite(dev, 0x00, 0x2087, 0x00, 0x0); t16RegWrite(dev, 0x00, 0x2087, 0x00, 0x0);
t16RegWrite(dev, 0x00, 0x2088, 0x00, 0x0); t16RegWrite(dev, 0x00, 0x2088, 0x00, 0x0);
t16RegWrite(dev, 0x00, 0x2089, 0x00, 0x0); t16RegWrite(dev, 0x00, 0x2089, 0x00, 0x0);
t16RegWrite(dev, 0x01, 00, nset7, 0x4); t16RegWrite(dev, 0x01, 0x0000, nset7, 0x04);
t16RegWrite(dev, 0x01, 00, nset10, 0x06); t16RegWrite(dev, 0x01, 0x0000, nset10, 0x06);
t16RegWrite(dev, 0x01, 00, nset8, 0x06); t16RegWrite(dev, 0x01, 0x0000, nset8, 0x06);
t16RegWrite(dev, 0x01, 00, nset9, 0x04); t16RegWrite(dev, 0x01, 0x0000, nset9, 0x04);
t16RegWrite(dev, 0x00, 0x2880, 0x00, 0x0); t16RegWrite(dev, 0x00, 0x2880, 0x00, 0x00);
t16RegWrite(dev, 0x01, 0x0000, nset2, 0x14); t16RegWrite(dev, 0x01, 0x0000, nset2, 0x14);
t16RegWrite(dev, 0x01, 0x0000, nset3, 0x12); t16RegWrite(dev, 0x01, 0x0000, nset3, 0x12);
t16RegWrite(dev, 0x01, 0x0000, nset4, 0x12); t16RegWrite(dev, 0x01, 0x0000, nset4, 0x12);
......
...@@ -192,8 +192,7 @@ static void tv_8532WriteEEprom(struct gspca_dev *gspca_dev) ...@@ -192,8 +192,7 @@ static void tv_8532WriteEEprom(struct gspca_dev *gspca_dev)
datacmd = 0xb0;; datacmd = 0xb0;;
reg_w(dev, TV8532_GPIO, &datacmd, 1); reg_w(dev, TV8532_GPIO, &datacmd, 1);
datacmd = TV8532_CMD_EEprom_Open; datacmd = TV8532_CMD_EEprom_Open;
reg_w(dev, TV8532_CTRL, &datacmd, reg_w(dev, TV8532_CTRL, &datacmd, 1);
1);
/* msleep(1); */ /* msleep(1); */
while (tv_8532_eeprom_data[i]) { while (tv_8532_eeprom_data[i]) {
reg = (tv_8532_eeprom_data[i] & 0xff000000) >> 24; reg = (tv_8532_eeprom_data[i] & 0xff000000) >> 24;
...@@ -390,8 +389,7 @@ static int sd_open(struct gspca_dev *gspca_dev) ...@@ -390,8 +389,7 @@ static int sd_open(struct gspca_dev *gspca_dev)
tv_8532_setReg(gspca_dev); tv_8532_setReg(gspca_dev);
/*************************************************/ /*************************************************/
data = 0x0b; data = 0x0b;
reg_w(dev, TV8532_GPIO_OE, &data, reg_w(dev, TV8532_GPIO_OE, &data, 1);
1);
/*************************************************/ /*************************************************/
tv_8532_setReg(gspca_dev); tv_8532_setReg(gspca_dev);
/*************************************************/ /*************************************************/
...@@ -417,8 +415,7 @@ static void setbrightness(struct gspca_dev *gspca_dev) ...@@ -417,8 +415,7 @@ static void setbrightness(struct gspca_dev *gspca_dev)
static void sd_start(struct gspca_dev *gspca_dev) static void sd_start(struct gspca_dev *gspca_dev)
{ {
struct usb_device *dev = gspca_dev->dev; struct usb_device *dev = gspca_dev->dev;
__u8 data = 0; __u8 data;
__u8 dataStart = 0;
__u8 value[2]; __u8 value[2];
data = 0x32; data = 0x32;
...@@ -459,8 +456,8 @@ static void sd_start(struct gspca_dev *gspca_dev) ...@@ -459,8 +456,8 @@ static void sd_start(struct gspca_dev *gspca_dev)
reg_w(dev, TV8532_POINT_L, &data, 1); /* 0x2d */ reg_w(dev, TV8532_POINT_L, &data, 1); /* 0x2d */
data = TESTPTH; /* 0x04; */ data = TESTPTH; /* 0x04; */
reg_w(dev, TV8532_POINT_H, &data, 1); /* 0x2e */ reg_w(dev, TV8532_POINT_H, &data, 1); /* 0x2e */
dataStart = TESTPTBL; /* 0x04; */ data = TESTPTBL; /* 0x04; */
reg_w(dev, TV8532_POINTB_L, &dataStart, 1); /* 0x2f */ reg_w(dev, TV8532_POINTB_L, &data, 1); /* 0x2f */
data = TESTPTBH; /* 0x04; */ data = TESTPTBH; /* 0x04; */
reg_w(dev, TV8532_POINTB_H, &data, 1); /* 0x30 */ reg_w(dev, TV8532_POINTB_H, &data, 1); /* 0x30 */
data = TV8532_CMD_UPDATE; data = TV8532_CMD_UPDATE;
......
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