summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/gspca/spca500.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/video/gspca/spca500.c')
-rw-r--r--linux/drivers/media/video/gspca/spca500.c337
1 files changed, 179 insertions, 158 deletions
diff --git a/linux/drivers/media/video/gspca/spca500.c b/linux/drivers/media/video/gspca/spca500.c
index d35bfabf8..1860fc7f5 100644
--- a/linux/drivers/media/video/gspca/spca500.c
+++ b/linux/drivers/media/video/gspca/spca500.c
@@ -24,8 +24,8 @@
#include "gspca.h"
#include "jpeg.h"
-#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0)
-static const char version[] = "2.1.0";
+#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5)
+static const char version[] = "2.1.5";
MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
MODULE_DESCRIPTION("GSPCA/SPCA500 USB Camera Driver");
@@ -35,7 +35,7 @@ MODULE_LICENSE("GPL");
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
- unsigned char packet[ISO_MAX_SIZE + 128];
+ __u8 packet[ISO_MAX_SIZE + 128];
/* !! no more than 128 ff in an ISO packet */
unsigned char brightness;
@@ -70,58 +70,74 @@ static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
static struct ctrl sd_ctrls[] = {
-#define SD_BRIGHTNESS 0
{
{
.id = V4L2_CID_BRIGHTNESS,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Brightness",
.minimum = 0,
- .maximum = 0xff,
+ .maximum = 255,
.step = 1,
- .default_value = 0x7f,
+#define BRIGHTNESS_DEF 127
+ .default_value = BRIGHTNESS_DEF,
},
.set = sd_setbrightness,
.get = sd_getbrightness,
},
-#define SD_CONTRAST 1
{
{
.id = V4L2_CID_CONTRAST,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Contrast",
.minimum = 0,
- .maximum = 255,
+ .maximum = 63,
.step = 1,
- .default_value = 127,
+#define CONTRAST_DEF 31
+ .default_value = CONTRAST_DEF,
},
.set = sd_setcontrast,
.get = sd_getcontrast,
},
-#define SD_COLOR 2
{
{
.id = V4L2_CID_SATURATION,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Color",
.minimum = 0,
- .maximum = 255,
+ .maximum = 63,
.step = 1,
- .default_value = 127,
+#define COLOR_DEF 31
+ .default_value = COLOR_DEF,
},
.set = sd_setcolors,
.get = sd_getcolors,
},
};
-static struct cam_mode vga_mode[] = {
- {V4L2_PIX_FMT_JPEG, 320, 240, 1},
- {V4L2_PIX_FMT_JPEG, 640, 480, 0},
+static struct v4l2_pix_format vga_mode[] = {
+ {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
+ .bytesperline = 320,
+ .sizeimage = 320 * 240 * 3 / 8 + 590,
+ .colorspace = V4L2_COLORSPACE_JPEG,
+ .priv = 1},
+ {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
+ .bytesperline = 640,
+ .sizeimage = 640 * 480 * 3 / 8 + 590,
+ .colorspace = V4L2_COLORSPACE_JPEG,
+ .priv = 0},
};
-static struct cam_mode sif_mode[] = {
- {V4L2_PIX_FMT_JPEG, 176, 144, 1},
- {V4L2_PIX_FMT_JPEG, 352, 288, 0},
+static struct v4l2_pix_format sif_mode[] = {
+ {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
+ .bytesperline = 176,
+ .sizeimage = 176 * 144 * 3 / 8 + 590,
+ .colorspace = V4L2_COLORSPACE_JPEG,
+ .priv = 1},
+ {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
+ .bytesperline = 352,
+ .sizeimage = 352 * 288 * 3 / 8 + 590,
+ .colorspace = V4L2_COLORSPACE_JPEG,
+ .priv = 0},
};
/* Frame packet header offsets for the spca500 */
@@ -139,7 +155,7 @@ static struct cam_mode sif_mode[] = {
#define SPCA500_OFFSET_DATA 16
#if 0
-static __u16 spca500_read_stats[][3] = {
+static const __u16 spca500_read_stats[][3] = {
{0x0c, 0x0000, 0x0000},
{0x30, 0x03fd, 0x0001},
/* possible values for following call: 0x01b3, 0x01e6, 0x01f7, 0x0218 */
@@ -152,11 +168,11 @@ static __u16 spca500_read_stats[][3] = {
{0x30, 0x0001, 0x0006},
{0x30, 0x0080, 0x0007},
{0x30, 0x0004, 0x0000},
- {0, 0, 0}
+ {}
};
#endif
-static __u16 spca500_visual_defaults[][3] = {
+static const __u16 spca500_visual_defaults[][3] = {
{0x00, 0x0003, 0x816b}, /* SSI not active sync with vsync,
* hue (H byte) = 0,
* saturation/hue enable,
@@ -178,10 +194,9 @@ static __u16 spca500_visual_defaults[][3] = {
{0x00, 0x0001, 0x8202}, /* clock rate compensation = 1/25 sec/frame */
{0x0c, 0x0004, 0x0000},
/* set interface */
-
- {0, 0, 0}
+ {}
};
-static __u16 Clicksmart510_defaults[][3] = {
+static const __u16 Clicksmart510_defaults[][3] = {
{0x00, 0x00, 0x8211},
{0x00, 0x01, 0x82c0},
{0x00, 0x10, 0x82cb},
@@ -310,7 +325,7 @@ static __u16 Clicksmart510_defaults[][3] = {
{}
};
-static unsigned char qtable_creative_pccam[2][64] = {
+static const __u8 qtable_creative_pccam[2][64] = {
{ /* Q-table Y-components */
0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
@@ -331,7 +346,7 @@ static unsigned char qtable_creative_pccam[2][64] = {
0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}
};
-static unsigned char qtable_kodak_ez200[2][64] = {
+static const __u8 qtable_kodak_ez200[2][64] = {
{ /* Q-table Y-components */
0x02, 0x01, 0x01, 0x02, 0x02, 0x04, 0x05, 0x06,
0x01, 0x01, 0x01, 0x02, 0x03, 0x06, 0x06, 0x06,
@@ -352,7 +367,7 @@ static unsigned char qtable_kodak_ez200[2][64] = {
0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a}
};
-static unsigned char qtable_pocketdv[2][64] = {
+static const __u8 qtable_pocketdv[2][64] = {
{ /* Q-table Y-components start registers 0x8800 */
0x06, 0x04, 0x04, 0x06, 0x0a, 0x10, 0x14, 0x18,
0x05, 0x05, 0x06, 0x08, 0x0a, 0x17, 0x18, 0x16,
@@ -374,7 +389,7 @@ static unsigned char qtable_pocketdv[2][64] = {
0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28}
};
-static void spca5xxRegRead(struct usb_device *dev,
+static void reg_r(struct usb_device *dev,
__u16 index,
__u8 *buffer, __u16 length)
{
@@ -386,25 +401,24 @@ static void spca5xxRegRead(struct usb_device *dev,
index, buffer, length, 500);
}
-static int reg_write(struct usb_device *dev,
+static int reg_w(struct usb_device *dev,
__u16 req, __u16 index, __u16 value)
{
int ret;
+ PDEBUG(D_USBO, "reg write: [0x%02x] = 0x%02x", index, value);
ret = usb_control_msg(dev,
usb_sndctrlpipe(dev, 0),
req,
- USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index, NULL, 0, 500);
- PDEBUG(D_USBO, "reg write: [0x%02x] = 0x%02x, 0x%x",
- index, value, ret);
if (ret < 0)
PDEBUG(D_ERR, "reg write: error %d", ret);
return ret;
}
/* returns: negative is error, pos or zero is data */
-static int reg_read(struct usb_device *dev,
+static int reg_r_12(struct usb_device *dev,
__u16 req, /* bRequest */
__u16 index, /* wIndex */
__u16 length) /* wLength (1 or 2 only) */
@@ -422,7 +436,7 @@ static int reg_read(struct usb_device *dev,
buf, length,
500); /* timeout */
if (ret < 0) {
- PDEBUG(D_ERR, "reg_read err %d", ret);
+ PDEBUG(D_ERR, "reg_r_12 err %d", ret);
return -1;
}
return (buf[1] << 8) + buf[0];
@@ -433,13 +447,13 @@ static int reg_read(struct usb_device *dev,
* a reg_read call.
* Returns: negative is error or timeout, zero is success.
*/
-static int reg_readwait(struct usb_device *dev,
+static int reg_r_wait(struct usb_device *dev,
__u16 reg, __u16 index, __u16 value)
{
int ret, cnt = 20;
while (--cnt > 0) {
- ret = reg_read(dev, reg, index, 1);
+ ret = reg_r_12(dev, reg, index, 1);
if (ret == value)
return 0;
msleep(50);
@@ -448,13 +462,13 @@ static int reg_readwait(struct usb_device *dev,
}
static int write_vector(struct gspca_dev *gspca_dev,
- __u16 data[][3])
+ const __u16 data[][3])
{
struct usb_device *dev = gspca_dev->dev;
int ret, i = 0;
while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) {
- ret = reg_write(dev, data[i][0], data[i][2], data[i][1]);
+ ret = reg_w(dev, data[i][0], data[i][2], data[i][1]);
if (ret < 0)
return ret;
i++;
@@ -466,21 +480,21 @@ static int spca50x_setup_qtable(struct gspca_dev *gspca_dev,
unsigned int request,
unsigned int ybase,
unsigned int cbase,
- unsigned char qtable[2][64])
+ const __u8 qtable[2][64])
{
struct usb_device *dev = gspca_dev->dev;
int i, err;
/* loop over y components */
for (i = 0; i < 64; i++) {
- err = reg_write(dev, request, ybase + i, qtable[0][i]);
+ err = reg_w(dev, request, ybase + i, qtable[0][i]);
if (err < 0)
return err;
}
/* loop over c components */
for (i = 0; i < 64; i++) {
- err = reg_write(dev, request, cbase + i, qtable[1][i]);
+ err = reg_w(dev, request, cbase + i, qtable[1][i]);
if (err < 0)
return err;
}
@@ -491,8 +505,8 @@ static void spca500_ping310(struct gspca_dev *gspca_dev)
{
__u8 Data[2];
- spca5xxRegRead(gspca_dev->dev, 0x0d04, Data, 2);
- PDEBUG(D_PACK, "ClickSmart310 ping 0x0d04 0x%02x 0x%02x",
+ reg_r(gspca_dev->dev, 0x0d04, Data, 2);
+ PDEBUG(D_STREAM, "ClickSmart310 ping 0x0d04 0x%02x 0x%02x",
Data[0], Data[1]);
}
@@ -500,26 +514,26 @@ static void spca500_clksmart310_init(struct gspca_dev *gspca_dev)
{
__u8 Data[2];
- spca5xxRegRead(gspca_dev->dev, 0x0d05, Data, 2);
- PDEBUG(D_PACK, "ClickSmart310 init 0x0d05 0x%02x 0x%02x", Data[0],
- Data[1]);
- reg_write(gspca_dev->dev, 0x00, 0x8167, 0x5a);
+ reg_r(gspca_dev->dev, 0x0d05, Data, 2);
+ PDEBUG(D_STREAM, "ClickSmart310 init 0x0d05 0x%02x 0x%02x",
+ Data[0], Data[1]);
+ reg_w(gspca_dev->dev, 0x00, 0x8167, 0x5a);
spca500_ping310(gspca_dev);
- reg_write(gspca_dev->dev, 0x00, 0x8168, 0x22);
- reg_write(gspca_dev->dev, 0x00, 0x816a, 0xc0);
- reg_write(gspca_dev->dev, 0x00, 0x816b, 0x0b);
- reg_write(gspca_dev->dev, 0x00, 0x8169, 0x25);
- reg_write(gspca_dev->dev, 0x00, 0x8157, 0x5b);
- reg_write(gspca_dev->dev, 0x00, 0x8158, 0x5b);
- reg_write(gspca_dev->dev, 0x00, 0x813f, 0x03);
- reg_write(gspca_dev->dev, 0x00, 0x8151, 0x4a);
- reg_write(gspca_dev->dev, 0x00, 0x8153, 0x78);
- reg_write(gspca_dev->dev, 0x00, 0x0d01, 0x04);
+ reg_w(gspca_dev->dev, 0x00, 0x8168, 0x22);
+ reg_w(gspca_dev->dev, 0x00, 0x816a, 0xc0);
+ reg_w(gspca_dev->dev, 0x00, 0x816b, 0x0b);
+ reg_w(gspca_dev->dev, 0x00, 0x8169, 0x25);
+ reg_w(gspca_dev->dev, 0x00, 0x8157, 0x5b);
+ reg_w(gspca_dev->dev, 0x00, 0x8158, 0x5b);
+ reg_w(gspca_dev->dev, 0x00, 0x813f, 0x03);
+ reg_w(gspca_dev->dev, 0x00, 0x8151, 0x4a);
+ reg_w(gspca_dev->dev, 0x00, 0x8153, 0x78);
+ reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x04);
/* 00 for adjust shutter */
- reg_write(gspca_dev->dev, 0x00, 0x0d02, 0x01);
- reg_write(gspca_dev->dev, 0x00, 0x8169, 0x25);
- reg_write(gspca_dev->dev, 0x00, 0x0d01, 0x02);
+ reg_w(gspca_dev->dev, 0x00, 0x0d02, 0x01);
+ reg_w(gspca_dev->dev, 0x00, 0x8169, 0x25);
+ reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x02);
}
static void spca500_setmode(struct gspca_dev *gspca_dev,
@@ -528,14 +542,14 @@ static void spca500_setmode(struct gspca_dev *gspca_dev,
int mode;
/* set x multiplier */
- reg_write(gspca_dev->dev, 0, 0x8001, xmult);
+ reg_w(gspca_dev->dev, 0, 0x8001, xmult);
/* set y multiplier */
- reg_write(gspca_dev->dev, 0, 0x8002, ymult);
+ reg_w(gspca_dev->dev, 0, 0x8002, ymult);
/* use compressed mode, VGA, with mode specific subsample */
- mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode;
- reg_write(gspca_dev->dev, 0, 0x8003, mode << 4);
+ mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
+ reg_w(gspca_dev->dev, 0, 0x8003, mode << 4);
}
static int spca500_full_reset(struct gspca_dev *gspca_dev)
@@ -543,20 +557,20 @@ static int spca500_full_reset(struct gspca_dev *gspca_dev)
int err;
/* send the reset command */
- err = reg_write(gspca_dev->dev, 0xe0, 0x0001, 0x0000);
+ err = reg_w(gspca_dev->dev, 0xe0, 0x0001, 0x0000);
if (err < 0)
return err;
/* wait for the reset to complete */
- err = reg_readwait(gspca_dev->dev, 0x06, 0x0000, 0x0000);
+ err = reg_r_wait(gspca_dev->dev, 0x06, 0x0000, 0x0000);
if (err < 0)
return err;
- err = reg_write(gspca_dev->dev, 0xe0, 0x0000, 0x0000);
+ err = reg_w(gspca_dev->dev, 0xe0, 0x0000, 0x0000);
if (err < 0)
return err;
- err = reg_readwait(gspca_dev->dev, 0x06, 0, 0);
+ err = reg_r_wait(gspca_dev->dev, 0x06, 0, 0);
if (err < 0) {
- PDEBUG(D_ERR, "reg_readwait() failed");
+ PDEBUG(D_ERR, "reg_r_wait() failed");
return err;
}
/* all ok */
@@ -579,7 +593,7 @@ static int spca500_synch310(struct gspca_dev *gspca_dev)
}
spca500_ping310(gspca_dev);
- spca5xxRegRead(gspca_dev->dev, 0x0d00, &Data, 1);
+ reg_r(gspca_dev->dev, 0x0d00, &Data, 1);
/* need alt setting here */
PDEBUG(D_PACK, "ClickSmart310 sync alt: %d", gspca_dev->alt);
@@ -603,12 +617,12 @@ static void spca500_reinit(struct gspca_dev *gspca_dev)
/* some unknow command from Aiptek pocket dv and family300 */
- reg_write(gspca_dev->dev, 0x00, 0x0d01, 0x01);
- reg_write(gspca_dev->dev, 0x00, 0x0d03, 0x00);
- reg_write(gspca_dev->dev, 0x00, 0x0d02, 0x01);
+ reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x01);
+ reg_w(gspca_dev->dev, 0x00, 0x0d03, 0x00);
+ reg_w(gspca_dev->dev, 0x00, 0x0d02, 0x01);
/* enable drop packet */
- reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001);
+ reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001);
err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840,
qtable_pocketdv);
@@ -616,22 +630,22 @@ static void spca500_reinit(struct gspca_dev *gspca_dev)
PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed on init");
/* set qtable index */
- reg_write(gspca_dev->dev, 0x00, 0x8880, 2);
+ reg_w(gspca_dev->dev, 0x00, 0x8880, 2);
/* family cam Quicksmart stuff */
- reg_write(gspca_dev->dev, 0x00, 0x800a, 0x00);
+ reg_w(gspca_dev->dev, 0x00, 0x800a, 0x00);
/* Set agc transfer: synced inbetween frames */
- reg_write(gspca_dev->dev, 0x00, 0x820f, 0x01);
+ reg_w(gspca_dev->dev, 0x00, 0x820f, 0x01);
/* Init SDRAM - needed for SDRAM access */
- reg_write(gspca_dev->dev, 0x00, 0x870a, 0x04);
+ reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04);
/*Start init sequence or stream */
- reg_write(gspca_dev->dev, 0, 0x8003, 0x00);
+ reg_w(gspca_dev->dev, 0, 0x8003, 0x00);
/* switch to video camera mode */
- reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004);
+ reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004);
msleep(2000);
- if (reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44) != 0)
- spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1);
- reg_write(gspca_dev->dev, 0x00, 0x816b, Data);
+ if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0)
+ reg_r(gspca_dev->dev, 0x816b, &Data, 1);
+ reg_w(gspca_dev->dev, 0x00, 0x816b, Data);
}
/* this function is called at probe time */
@@ -751,9 +765,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->nmodes = sizeof sif_mode / sizeof sif_mode[0];
}
sd->qindex = 5;
- sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
- sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
- sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
+ sd->brightness = BRIGHTNESS_DEF;
+ sd->contrast = CONTRAST_DEF;
+ sd->colors = COLOR_DEF;
return 0;
}
@@ -788,7 +802,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
}
/* is there a sensor here ? */
- spca5xxRegRead(gspca_dev->dev, 0x8a04, &Data, 1);
+ reg_r(gspca_dev->dev, 0x8a04, &Data, 1);
PDEBUG(D_STREAM, "Spca500 Sensor Address 0x%02X", Data);
PDEBUG(D_STREAM, "Spca500 curr_mode: %d Xmult: 0x%02X, Ymult: 0x%02X",
gspca_dev->curr_mode, xmult, ymult);
@@ -799,33 +813,33 @@ static void sd_start(struct gspca_dev *gspca_dev)
spca500_setmode(gspca_dev, xmult, ymult);
/* enable drop packet */
- reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001);
- reg_write(gspca_dev->dev, 0x00, 0x8880, 3);
+ reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001);
+ reg_w(gspca_dev->dev, 0x00, 0x8880, 3);
err = spca50x_setup_qtable(gspca_dev,
0x00, 0x8800, 0x8840,
qtable_creative_pccam);
if (err < 0)
PDEBUG(D_ERR, "spca50x_setup_qtable failed");
/* Init SDRAM - needed for SDRAM access */
- reg_write(gspca_dev->dev, 0x00, 0x870a, 0x04);
+ reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04);
/* switch to video camera mode */
- reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004);
+ reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004);
msleep(500);
- if (reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44) != 0)
- PDEBUG(D_ERR, "reg_readwait() failed");
+ if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0)
+ PDEBUG(D_ERR, "reg_r_wait() failed");
- spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1);
- reg_write(gspca_dev->dev, 0x00, 0x816b, Data);
+ reg_r(gspca_dev->dev, 0x816b, &Data, 1);
+ reg_w(gspca_dev->dev, 0x00, 0x816b, Data);
spca500_synch310(gspca_dev);
write_vector(gspca_dev, spca500_visual_defaults);
spca500_setmode(gspca_dev, xmult, ymult);
/* enable drop packet */
- reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001);
+ reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001);
PDEBUG(D_ERR, "failed to enable drop packet");
- reg_write(gspca_dev->dev, 0x00, 0x8880, 3);
+ reg_w(gspca_dev->dev, 0x00, 0x8880, 3);
err = spca50x_setup_qtable(gspca_dev,
0x00, 0x8800, 0x8840,
qtable_creative_pccam);
@@ -833,16 +847,16 @@ static void sd_start(struct gspca_dev *gspca_dev)
PDEBUG(D_ERR, "spca50x_setup_qtable failed");
/* Init SDRAM - needed for SDRAM access */
- reg_write(gspca_dev->dev, 0x00, 0x870a, 0x04);
+ reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04);
/* switch to video camera mode */
- reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004);
+ reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004);
- if (reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44) != 0)
- PDEBUG(D_ERR, "reg_readwait() failed");
+ if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0)
+ PDEBUG(D_ERR, "reg_r_wait() failed");
- spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1);
- reg_write(gspca_dev->dev, 0x00, 0x816b, Data);
+ reg_r(gspca_dev->dev, 0x816b, &Data, 1);
+ reg_w(gspca_dev->dev, 0x00, 0x816b, Data);
break;
case CreativePCCam300: /* Creative PC-CAM 300 640x480 CCD */
case IntelPocketPCCamera: /* FIXME: Temporary fix for
@@ -855,10 +869,10 @@ static void sd_start(struct gspca_dev *gspca_dev)
PDEBUG(D_ERR, "spca500_full_reset failed");
/* enable drop packet */
- err = reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001);
+ err = reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001);
if (err < 0)
PDEBUG(D_ERR, "failed to enable drop packet");
- reg_write(gspca_dev->dev, 0x00, 0x8880, 3);
+ reg_w(gspca_dev->dev, 0x00, 0x8880, 3);
err = spca50x_setup_qtable(gspca_dev,
0x00, 0x8800, 0x8840,
qtable_creative_pccam);
@@ -866,18 +880,18 @@ static void sd_start(struct gspca_dev *gspca_dev)
PDEBUG(D_ERR, "spca50x_setup_qtable failed");
spca500_setmode(gspca_dev, xmult, ymult);
- reg_write(gspca_dev->dev, 0x20, 0x0001, 0x0004);
+ reg_w(gspca_dev->dev, 0x20, 0x0001, 0x0004);
/* switch to video camera mode */
- reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004);
+ reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004);
- if (reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44) != 0)
- PDEBUG(D_ERR, "reg_readwait() failed");
+ if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0)
+ PDEBUG(D_ERR, "reg_r_wait() failed");
- spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1);
- reg_write(gspca_dev->dev, 0x00, 0x816b, Data);
+ reg_r(gspca_dev->dev, 0x816b, &Data, 1);
+ reg_w(gspca_dev->dev, 0x00, 0x816b, Data);
- /* write_vector(gspca_dev, spca500_visual_defaults); */
+/* write_vector(gspca_dev, spca500_visual_defaults); */
break;
case KodakEZ200: /* Kodak EZ200 */
@@ -886,8 +900,8 @@ static void sd_start(struct gspca_dev *gspca_dev)
if (err < 0)
PDEBUG(D_ERR, "spca500_full_reset failed");
/* enable drop packet */
- reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001);
- reg_write(gspca_dev->dev, 0x00, 0x8880, 0);
+ reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001);
+ reg_w(gspca_dev->dev, 0x00, 0x8880, 0);
err = spca50x_setup_qtable(gspca_dev,
0x00, 0x8800, 0x8840,
qtable_kodak_ez200);
@@ -895,18 +909,18 @@ static void sd_start(struct gspca_dev *gspca_dev)
PDEBUG(D_ERR, "spca50x_setup_qtable failed");
spca500_setmode(gspca_dev, xmult, ymult);
- reg_write(gspca_dev->dev, 0x20, 0x0001, 0x0004);
+ reg_w(gspca_dev->dev, 0x20, 0x0001, 0x0004);
/* switch to video camera mode */
- reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004);
+ reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004);
- if (reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44) != 0)
- PDEBUG(D_ERR, "reg_readwait() failed");
+ if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0)
+ PDEBUG(D_ERR, "reg_r_wait() failed");
- spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1);
- reg_write(gspca_dev->dev, 0x00, 0x816b, Data);
+ reg_r(gspca_dev->dev, 0x816b, &Data, 1);
+ reg_w(gspca_dev->dev, 0x00, 0x816b, Data);
- /* write_vector(gspca_dev, spca500_visual_defaults); */
+/* write_vector(gspca_dev, spca500_visual_defaults); */
break;
case BenqDC1016:
@@ -919,56 +933,56 @@ static void sd_start(struct gspca_dev *gspca_dev)
case ToptroIndus:
case AgfaCl20:
spca500_reinit(gspca_dev);
- reg_write(gspca_dev->dev, 0x00, 0x0d01, 0x01);
+ reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x01);
/* enable drop packet */
- reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001);
+ reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001);
err = spca50x_setup_qtable(gspca_dev,
0x00, 0x8800, 0x8840, qtable_pocketdv);
if (err < 0)
PDEBUG(D_ERR, "spca50x_setup_qtable failed");
- reg_write(gspca_dev->dev, 0x00, 0x8880, 2);
+ reg_w(gspca_dev->dev, 0x00, 0x8880, 2);
/* familycam Quicksmart pocketDV stuff */
- reg_write(gspca_dev->dev, 0x00, 0x800a, 0x00);
+ reg_w(gspca_dev->dev, 0x00, 0x800a, 0x00);
/* Set agc transfer: synced inbetween frames */
- reg_write(gspca_dev->dev, 0x00, 0x820f, 0x01);
+ reg_w(gspca_dev->dev, 0x00, 0x820f, 0x01);
/* Init SDRAM - needed for SDRAM access */
- reg_write(gspca_dev->dev, 0x00, 0x870a, 0x04);
+ reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04);
spca500_setmode(gspca_dev, xmult, ymult);
/* switch to video camera mode */
- reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004);
+ reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004);
- reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44);
+ reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44);
- spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1);
- reg_write(gspca_dev->dev, 0x00, 0x816b, Data);
+ reg_r(gspca_dev->dev, 0x816b, &Data, 1);
+ reg_w(gspca_dev->dev, 0x00, 0x816b, Data);
break;
case LogitechTraveler:
case LogitechClickSmart510:
- reg_write(gspca_dev->dev, 0x02, 0x00, 0x00);
+ reg_w(gspca_dev->dev, 0x02, 0x00, 0x00);
/* enable drop packet */
- reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001);
+ reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001);
err = spca50x_setup_qtable(gspca_dev,
0x00, 0x8800,
0x8840, qtable_creative_pccam);
if (err < 0)
PDEBUG(D_ERR, "spca50x_setup_qtable failed");
- reg_write(gspca_dev->dev, 0x00, 0x8880, 3);
- reg_write(gspca_dev->dev, 0x00, 0x800a, 0x00);
+ reg_w(gspca_dev->dev, 0x00, 0x8880, 3);
+ reg_w(gspca_dev->dev, 0x00, 0x800a, 0x00);
/* Init SDRAM - needed for SDRAM access */
- reg_write(gspca_dev->dev, 0x00, 0x870a, 0x04);
+ reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04);
spca500_setmode(gspca_dev, xmult, ymult);
/* switch to video camera mode */
- reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004);
- reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44);
+ reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004);
+ reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44);
- spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1);
- reg_write(gspca_dev->dev, 0x00, 0x816b, Data);
+ reg_r(gspca_dev->dev, 0x816b, &Data, 1);
+ reg_w(gspca_dev->dev, 0x00, 0x816b, Data);
write_vector(gspca_dev, Clicksmart510_defaults);
break;
}
@@ -976,13 +990,13 @@ static void sd_start(struct gspca_dev *gspca_dev)
static void sd_stopN(struct gspca_dev *gspca_dev)
{
- __u8 data = 0;
+ __u8 data;
- reg_write(gspca_dev->dev, 0, 0x8003, 0x00);
+ reg_w(gspca_dev->dev, 0, 0x8003, 0x00);
/* switch to video camera mode */
- reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004);
- spca5xxRegRead(gspca_dev->dev, 0x8000, &data, 1);
+ reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004);
+ reg_r(gspca_dev->dev, 0x8000, &data, 1);
PDEBUG(D_STREAM, "stop SPCA500 done reg8000: 0x%2x", data);
}
@@ -996,13 +1010,13 @@ static void sd_close(struct gspca_dev *gspca_dev)
static void sd_pkt_scan(struct gspca_dev *gspca_dev,
struct gspca_frame *frame, /* target */
- unsigned char *data, /* isoc packet */
+ __u8 *data, /* isoc packet */
int len) /* iso packet length */
{
struct sd *sd = (struct sd *) gspca_dev;
int i;
- unsigned char *s, *d;
- static unsigned char ffd9[] = {0xff, 0xd9};
+ __u8 *s, *d;
+ static __u8 ffd9[] = {0xff, 0xd9};
/* frames are jpeg 4.1.1 without 0xff escape */
if (data[0] == 0xff) {
@@ -1014,9 +1028,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
ffd9, 2);
/* put the JPEG header in the new frame */
- jpeg_put_header(gspca_dev, frame,
- ((struct sd *) gspca_dev)->qindex,
- 0x22);
+ jpeg_put_header(gspca_dev, frame, sd->qindex, 0x22);
data += SPCA500_OFFSET_DATA;
len -= SPCA500_OFFSET_DATA;
@@ -1048,43 +1060,52 @@ static void setbrightness(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
- reg_write(gspca_dev->dev, 0x00, 0x8167,
+ reg_w(gspca_dev->dev, 0x00, 0x8167,
(__u8) (sd->brightness - 128));
}
static void getbrightness(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
+ int ret;
- sd->brightness = reg_read(gspca_dev->dev, 0x00, 0x8167, 1) + 128;
+ ret = reg_r_12(gspca_dev->dev, 0x00, 0x8167, 1);
+ if (ret >= 0)
+ sd->brightness = ret + 128;
}
static void setcontrast(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
- reg_write(gspca_dev->dev, 0x00, 0x8168, sd->contrast >> 2);
+ reg_w(gspca_dev->dev, 0x00, 0x8168, sd->contrast);
}
static void getcontrast(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
+ int ret;
- sd->contrast = reg_read(gspca_dev->dev, 0x0, 0x8168, 1) << 2;
+ ret = reg_r_12(gspca_dev->dev, 0x0, 0x8168, 1);
+ if (ret >= 0)
+ sd->contrast = ret;
}
static void setcolors(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
- reg_write(gspca_dev->dev, 0x00, 0x8169, sd->colors >> 2);
+ reg_w(gspca_dev->dev, 0x00, 0x8169, sd->colors);
}
static void getcolors(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
+ int ret;
- sd->colors = reg_read(gspca_dev->dev, 0x0, 0x8169, 1) << 2;
+ ret = reg_r_12(gspca_dev->dev, 0x0, 0x8169, 1);
+ if (ret >= 0)
+ sd->colors = ret;
}
static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
@@ -1148,7 +1169,7 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
static struct sd_desc sd_desc = {
.name = MODULE_NAME,
.ctrls = sd_ctrls,
- .nctrls = sizeof sd_ctrls / sizeof sd_ctrls[0],
+ .nctrls = ARRAY_SIZE(sd_ctrls),
.config = sd_config,
.open = sd_open,
.start = sd_start,
@@ -1160,7 +1181,7 @@ static struct sd_desc sd_desc = {
/* -- module initialisation -- */
#define DVNM(name) .driver_info = (kernel_ulong_t) name
-static __devinitdata struct usb_device_id device_table[] = {
+static const __devinitdata struct usb_device_id device_table[] = {
{USB_DEVICE(0x040a, 0x0300), DVNM("Kodak EZ200")},
{USB_DEVICE(0x041e, 0x400a), DVNM("Creative PC-CAM 300")},
{USB_DEVICE(0x046d, 0x0890), DVNM("Logitech QuickCam traveler")},