/* check the packet status and length */
if (urb0->iso_frame_desc[i].actual_length != SD_PKT_SZ
|| urb->iso_frame_desc[i].actual_length != SD_PKT_SZ) {
- PDEBUG(D_ERR, "ISOC bad lengths %d / %d",
+ PERR("ISOC bad lengths %d / %d",
urb0->iso_frame_desc[i].actual_length,
urb->iso_frame_desc[i].actual_length);
gspca_dev->last_packet_type = DISCARD_PACKET;
{
struct usb_device *dev = gspca_dev->dev;
-#ifdef GSPCA_DEBUG
if (len > USB_BUF_SZ) {
- pr_err("reg_r: buffer overflow\n");
+ PERR("reg_r: buffer overflow\n");
return;
}
-#endif
+
usb_control_msg(dev,
usb_rcvctrlpipe(dev, 0),
0,
{
struct usb_device *dev = gspca_dev->dev;
-#ifdef GSPCA_DEBUG
if (len > USB_BUF_SZ) {
- pr_err("reg_w: buffer overflow\n");
+ PERR("reg_w: buffer overflow\n");
return;
}
PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer);
-#endif
+
memcpy(gspca_dev->usb_buf, buffer, len);
usb_control_msg(dev,
usb_sndctrlpipe(dev, 0),
reg_w_val(gspca_dev, 0x0053, 0x00);
} while (--retry);
if (retry == 0)
- PDEBUG(D_ERR, "Damned Errors sending jpeg Table");
+ PERR("Damned Errors sending jpeg Table");
/* send the qtable now */
reg_r(gspca_dev, 0x0001, 1); /* -> 0x18 */
length = 8;
pipe = usb_sndctrlpipe(gspca_dev->dev, 0);
requesttype = USB_TYPE_VENDOR | USB_RECIP_DEVICE;
} else {
- PDEBUG(D_ERR, "Unexpected first byte of command: %x",
- command[0]);
+ PERR("Unexpected first byte of command: %x", command[0]);
return -EINVAL;
}
params->qx3.cradled = 0;
}
-static void printstatus(struct cam_params *params)
+static void printstatus(struct gspca_dev *gspca_dev, struct cam_params *params)
{
PDEBUG(D_PROBE, "status: %02x %02x %02x %02x %02x %02x %02x %02x",
params->status.systemState, params->status.grabState,
if (sd->params.status.systemState != LO_POWER_STATE) {
if (sd->params.status.systemState != WARM_BOOT_STATE) {
- PDEBUG(D_ERR,
- "unexpected state after lo power cmd: %02x",
- sd->params.status.systemState);
- printstatus(&sd->params);
+ PERR("unexpected state after lo power cmd: %02x",
+ sd->params.status.systemState);
+ printstatus(gspca_dev, &sd->params);
}
return -EIO;
}
return ret;
if (sd->params.status.systemState != HI_POWER_STATE) {
- PDEBUG(D_ERR, "unexpected state after hi power cmd: %02x",
- sd->params.status.systemState);
- printstatus(&sd->params);
+ PERR("unexpected state after hi power cmd: %02x",
+ sd->params.status.systemState);
+ printstatus(gspca_dev, &sd->params);
return -EIO;
}
sd->params.version.firmwareVersion = 0;
get_version_information(gspca_dev);
if (sd->params.version.firmwareVersion != 1) {
- PDEBUG(D_ERR, "only firmware version 1 is supported (got: %d)",
- sd->params.version.firmwareVersion);
+ PERR("only firmware version 1 is supported (got: %d)",
+ sd->params.version.firmwareVersion);
return -ENODEV;
}
/* Start the camera in low power mode */
if (goto_low_power(gspca_dev)) {
if (sd->params.status.systemState != WARM_BOOT_STATE) {
- PDEBUG(D_ERR, "unexpected systemstate: %02x",
- sd->params.status.systemState);
- printstatus(&sd->params);
+ PERR("unexpected systemstate: %02x",
+ sd->params.status.systemState);
+ printstatus(gspca_dev, &sd->params);
return -ENODEV;
}
return ret;
if (sd->params.status.fatalError) {
- PDEBUG(D_ERR, "fatal_error: %04x, vp_status: %04x",
- sd->params.status.fatalError,
- sd->params.status.vpStatus);
+ PERR("fatal_error: %04x, vp_status: %04x",
+ sd->params.status.fatalError, sd->params.status.vpStatus);
return -EIO;
}
{
struct usb_device *dev = gspca_dev->dev;
-#ifdef GSPCA_DEBUG
if (len > USB_BUF_SZ) {
- pr_err("reg_r: buffer overflow\n");
+ PERR("reg_r: buffer overflow\n");
return;
}
-#endif
+
usb_control_msg(dev,
usb_rcvctrlpipe(dev, 0),
0,
{
struct usb_device *dev = gspca_dev->dev;
-#ifdef GSPCA_DEBUG
if (len > USB_BUF_SZ) {
pr_err("reg_w: buffer overflow\n");
return;
}
PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer);
-#endif
+
memcpy(gspca_dev->usb_buf, buffer, len);
usb_control_msg(dev,
usb_sndctrlpipe(dev, 0),
: 0); /* stopvideo */
ret = Et_WaitStatus(gspca_dev);
if (ret != 0)
- PDEBUG(D_ERR, "timeout video on/off");
+ PERR("timeout video on/off");
return ret;
}
pr_err("ctrl transfer failed %4d [p%02x r%d v%04x i%04x len%d]\n",
r, pref, req, val, index, len);
else if (len > 1 && r < len)
- PDEBUG(D_ERR, "short ctrl transfer %d/%d", r, len);
+ PERR("short ctrl transfer %d/%d", r, len);
msleep(1);
MODULE_LICENSE("GPL");
MODULE_VERSION(GSPCA_VERSION);
-#ifdef GSPCA_DEBUG
-int gspca_debug = D_ERR | D_PROBE;
+int gspca_debug;
EXPORT_SYMBOL(gspca_debug);
-static void PDEBUG_MODE(char *txt, __u32 pixfmt, int w, int h)
+static void PDEBUG_MODE(struct gspca_dev *gspca_dev, int debug, char *txt,
+ __u32 pixfmt, int w, int h)
{
if ((pixfmt >> 24) >= '0' && (pixfmt >> 24) <= 'z') {
- PDEBUG(D_CONF|D_STREAM, "%s %c%c%c%c %dx%d",
+ PDEBUG(debug, "%s %c%c%c%c %dx%d",
txt,
pixfmt & 0xff,
(pixfmt >> 8) & 0xff,
pixfmt >> 24,
w, h);
} else {
- PDEBUG(D_CONF|D_STREAM, "%s 0x%08x %dx%d",
+ PDEBUG(debug, "%s 0x%08x %dx%d",
txt,
pixfmt,
w, h);
}
}
-#else
-#define PDEBUG_MODE(txt, pixfmt, w, h)
-#endif
/* specific memory types - !! should be different from V4L2_MEMORY_xxx */
#define GSPCA_MEMORY_NO 0 /* V4L2_MEMORY_xxx starts from 1 */
case 0:
if (gspca_dev->sd_desc->int_pkt_scan(gspca_dev,
urb->transfer_buffer, urb->actual_length) < 0) {
- PDEBUG(D_ERR, "Unknown packet received");
+ PERR("Unknown packet received");
}
break;
break;
default:
- PDEBUG(D_ERR, "URB error %i, resubmitting", urb->status);
+ PERR("URB error %i, resubmitting", urb->status);
urb->status = 0;
ret = 0;
}
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
ret = usb_submit_urb(urb, GFP_KERNEL);
if (ret < 0) {
- PDEBUG(D_ERR, "submit int URB failed with error %i", ret);
+ PERR("submit int URB failed with error %i", ret);
goto error_submit;
}
gspca_dev->int_urb = urb;
if (gspca_dev->frozen)
return;
#endif
- PDEBUG(D_ERR|D_PACK, "urb status: %d", urb->status);
+ PERR("urb status: %d", urb->status);
urb->status = 0;
goto resubmit;
}
if (gspca_dev->frozen)
return;
#endif
- PDEBUG(D_ERR|D_PACK, "urb status: %d", urb->status);
+ PERR("urb status: %d", urb->status);
urb->status = 0;
goto resubmit;
}
/* append the packet to the frame buffer */
if (len > 0) {
if (gspca_dev->image_len + len > gspca_dev->frsz) {
- PDEBUG(D_ERR|D_PACK, "frame overflow %d > %d",
+ PERR("frame overflow %d > %d",
gspca_dev->image_len + len,
gspca_dev->frsz);
packet_type = DISCARD_PACKET;
/* the bandwidth is not wide enough
* negotiate or try a lower alternate setting */
retry:
- PDEBUG(D_ERR|D_STREAM,
- "alt %d - bandwidth not wide enough - trying again",
- alt);
+ PERR("alt %d - bandwidth not wide enough, trying again", alt);
msleep(20); /* wait for kill complete */
if (gspca_dev->sd_desc->isoc_nego) {
ret = gspca_dev->sd_desc->isoc_nego(gspca_dev);
w = fmt->fmt.pix.width;
h = fmt->fmt.pix.height;
-#ifdef GSPCA_DEBUG
- if (gspca_debug & D_CONF)
- PDEBUG_MODE("try fmt cap", fmt->fmt.pix.pixelformat, w, h);
-#endif
+ PDEBUG_MODE(gspca_dev, D_CONF, "try fmt cap",
+ fmt->fmt.pix.pixelformat, w, h);
+
/* search the closest mode for width and height */
mode = wxh_to_mode(gspca_dev, w, h);
fmt->fmt.pix.pixelformat);
if (mode2 >= 0)
mode = mode2;
-/* else
- ; * no chance, return this mode */
}
fmt->fmt.pix = gspca_dev->cam.cam_mode[mode];
/* some drivers use priv internally, zero it before giving it to
if (!try_module_get(gspca_dev->module))
return -ENODEV;
-#ifdef GSPCA_DEBUG
- /* activate the v4l2 debug */
- if (gspca_debug & D_V4L2)
- gspca_dev->vdev.debug |= V4L2_DEBUG_IOCTL
- | V4L2_DEBUG_IOCTL_ARG;
- else
- gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL
- | V4L2_DEBUG_IOCTL_ARG);
-#endif
return v4l2_fh_open(file);
}
if (ret < 0)
goto out;
}
-#ifdef GSPCA_DEBUG
- if (gspca_debug & D_STREAM) {
- PDEBUG_MODE("stream on OK",
- gspca_dev->pixfmt,
- gspca_dev->width,
- gspca_dev->height);
- }
-#endif
+ PDEBUG_MODE(gspca_dev, D_STREAM, "stream on OK", gspca_dev->pixfmt,
+ gspca_dev->width, gspca_dev->height);
ret = 0;
out:
mutex_unlock(&gspca_dev->queue_lock);
if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr,
frame->data,
frame->v4l2_buf.bytesused)) {
- PDEBUG(D_ERR|D_STREAM,
- "dqbuf cp to user failed");
+ PERR("dqbuf cp to user failed");
ret = -EFAULT;
}
}
count = frame->v4l2_buf.bytesused;
ret = copy_to_user(data, frame->data, count);
if (ret != 0) {
- PDEBUG(D_ERR|D_STREAM,
- "read cp to user lack %d / %zd", ret, count);
+ PERR("read cp to user lack %d / %zd", ret, count);
ret = -EFAULT;
goto out;
}
module_init(gspca_init);
module_exit(gspca_exit);
-#ifdef GSPCA_DEBUG
module_param_named(debug, gspca_debug, int, 0644);
MODULE_PARM_DESC(debug,
- "Debug (bit) 0x01:error 0x02:probe 0x04:config"
- " 0x08:stream 0x10:frame 0x20:packet"
- " 0x0100: v4l2");
-#endif
+ "1:probe 2:config 3:stream 4:frame 5:packet 6:usbi 7:usbo");
#include <media/v4l2-device.h>
#include <linux/mutex.h>
-/* compilation option */
-/*#define GSPCA_DEBUG 1*/
-#ifdef GSPCA_DEBUG
-/* GSPCA our debug messages */
+
+/* GSPCA debug codes */
+
+#define D_PROBE 1
+#define D_CONF 2
+#define D_STREAM 3
+#define D_FRAM 4
+#define D_PACK 5
+#define D_USBI 6
+#define D_USBO 7
+
extern int gspca_debug;
-#define PDEBUG(level, fmt, ...) \
-do { \
- if (gspca_debug & (level)) \
- pr_info(fmt, ##__VA_ARGS__); \
-} while (0)
-
-#define D_ERR 0x01
-#define D_PROBE 0x02
-#define D_CONF 0x04
-#define D_STREAM 0x08
-#define D_FRAM 0x10
-#define D_PACK 0x20
-#define D_USBI 0x00
-#define D_USBO 0x00
-#define D_V4L2 0x0100
-#else
-#define PDEBUG(level, fmt, ...) do {} while(0)
-#endif
+
+
+#define PDEBUG(level, fmt, ...) \
+ v4l2_dbg(level, gspca_debug, &gspca_dev->v4l2_dev, fmt, ##__VA_ARGS__)
+
+#define PERR(fmt, ...) \
+ v4l2_err(&gspca_dev->v4l2_dev, fmt, ##__VA_ARGS__)
#define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */
/* image transfers */
msleep(2);
setfreq(gspca_dev, v4l2_ctrl_g_ctrl(sd->freq));
if (gspca_dev->usb_err < 0)
- PDEBUG(D_ERR, "Start streaming command failed");
+ PERR("Start streaming command failed");
return gspca_dev->usb_err;
}
if (gspca_dev->frozen)
return;
#endif
- PDEBUG(D_ERR, "urb status: %d", urb->status);
+ PERR("urb status: %d", urb->status);
st = usb_submit_urb(urb, GFP_ATOMIC);
if (st < 0)
pr_err("resubmit urb error %d\n", st);
sd->last_data_urb = NULL;
if (!data_urb || data_urb->start_frame != status_urb->start_frame) {
- PDEBUG(D_ERR|D_PACK, "lost sync on frames");
+ PERR("lost sync on frames");
goto resubmit;
}
if (data_urb->number_of_packets != status_urb->number_of_packets) {
- PDEBUG(D_ERR|D_PACK,
- "no packets does not match, data: %d, status: %d",
- data_urb->number_of_packets,
- status_urb->number_of_packets);
+ PERR("no packets does not match, data: %d, status: %d",
+ data_urb->number_of_packets,
+ status_urb->number_of_packets);
goto resubmit;
}
for (i = 0; i < status_urb->number_of_packets; i++) {
if (data_urb->iso_frame_desc[i].status ||
status_urb->iso_frame_desc[i].status) {
- PDEBUG(D_ERR|D_PACK,
- "pkt %d data-status %d, status-status %d", i,
- data_urb->iso_frame_desc[i].status,
- status_urb->iso_frame_desc[i].status);
+ PERR("pkt %d data-status %d, status-status %d", i,
+ data_urb->iso_frame_desc[i].status,
+ status_urb->iso_frame_desc[i].status);
gspca_dev->last_packet_type = DISCARD_PACKET;
continue;
}
if (status_urb->iso_frame_desc[i].actual_length != 1) {
- PDEBUG(D_ERR|D_PACK,
- "bad status packet length %d",
- status_urb->iso_frame_desc[i].actual_length);
+ PERR("bad status packet length %d",
+ status_urb->iso_frame_desc[i].actual_length);
gspca_dev->last_packet_type = DISCARD_PACKET;
continue;
}
if (data_urb) {
st = usb_submit_urb(data_urb, GFP_ATOMIC);
if (st < 0)
- PDEBUG(D_ERR|D_PACK,
- "usb_submit_urb(data_urb) ret %d", st);
+ PERR("usb_submit_urb(data_urb) ret %d", st);
}
st = usb_submit_urb(status_urb, GFP_ATOMIC);
if (st < 0)
- pr_err("usb_submit_urb(status_urb) ret %d\n", st);
+ PERR("usb_submit_urb(status_urb) ret %d\n", st);
}
static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
int m5602_read_bridge(struct sd *sd, const u8 address, u8 *i2c_data)
{
int err;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
struct usb_device *udev = sd->gspca_dev.dev;
__u8 *buf = sd->gspca_dev.usb_buf;
int m5602_write_bridge(struct sd *sd, const u8 address, const u8 i2c_data)
{
int err;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
struct usb_device *udev = sd->gspca_dev.dev;
__u8 *buf = sd->gspca_dev.usb_buf;
u8 *i2c_data, const u8 len)
{
int err, i;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
if (!len || len > sd->sensor->i2c_regW)
return -EINVAL;
{
int err, i;
u8 *p;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
struct usb_device *udev = sd->gspca_dev.dev;
__u8 *buf = sd->gspca_dev.usb_buf;
return 0;
fail:
- PDEBUG(D_ERR, "ALi m5602 webcam failed");
+ PERR("ALi m5602 webcam failed");
cam->cam_mode = NULL;
cam->nmodes = 0;
{
u8 data[2] = {0x00, 0x00};
int i;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
if (force_sensor) {
if (force_sensor == MT9M111_SENSOR) {
int i, err = 0;
u8 data[2];
struct cam *cam = &sd->gspca_dev.cam;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int width = cam->cam_mode[sd->gspca_dev.curr_mode].width - 1;
int height = cam->cam_mode[sd->gspca_dev.curr_mode].height;
switch (width) {
case 640:
- PDEBUG(D_V4L2, "Configuring camera for VGA mode");
+ PDEBUG(D_CONF, "Configuring camera for VGA mode");
break;
case 320:
- PDEBUG(D_V4L2, "Configuring camera for QVGA mode");
+ PDEBUG(D_CONF, "Configuring camera for QVGA mode");
break;
}
return err;
int hflip;
int vflip;
- PDEBUG(D_V4L2, "Set hvflip to %d %d", sd->hflip->val, sd->vflip->val);
+ PDEBUG(D_CONF, "Set hvflip to %d %d", sd->hflip->val, sd->vflip->val);
/* The mt9m111 is flipped by default */
hflip = !sd->hflip->val;
err = m5602_write_sensor(sd, MT9M111_CP_OPERATING_MODE_CTL, data, 2);
- PDEBUG(D_V4L2, "Set auto white balance %d", val);
+ PDEBUG(D_CONF, "Set auto white balance %d", val);
return err;
}
data[1] = (tmp & 0xff);
data[0] = (tmp & 0xff00) >> 8;
- PDEBUG(D_V4L2, "tmp=%d, data[1]=%d, data[0]=%d", tmp,
+ PDEBUG(D_CONF, "tmp=%d, data[1]=%d, data[0]=%d", tmp,
data[1], data[0]);
err = m5602_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN,
data[1] = (val & 0xff);
data[0] = (val & 0xff00) >> 8;
- PDEBUG(D_V4L2, "Set green balance %d", val);
+ PDEBUG(D_CONF, "Set green balance %d", val);
err = m5602_write_sensor(sd, MT9M111_SC_GREEN_1_GAIN,
data, 2);
if (err < 0)
data[1] = (val & 0xff);
data[0] = (val & 0xff00) >> 8;
- PDEBUG(D_V4L2, "Set blue balance %d", val);
+ PDEBUG(D_CONF, "Set blue balance %d", val);
return m5602_write_sensor(sd, MT9M111_SC_BLUE_GAIN,
data, 2);
data[1] = (val & 0xff);
data[0] = (val & 0xff00) >> 8;
- PDEBUG(D_V4L2, "Set red balance %d", val);
+ PDEBUG(D_CONF, "Set red balance %d", val);
return m5602_write_sensor(sd, MT9M111_SC_RED_GAIN,
data, 2);
u8 i2c_data = val;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Setting gain to %d", val);
+ PDEBUG(D_CONF, "Setting gain to %d", val);
err = m5602_write_sensor(sd, OV7660_GAIN, &i2c_data, 1);
return err;
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Set auto white balance to %d", val);
+ PDEBUG(D_CONF, "Set auto white balance to %d", val);
err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1);
if (err < 0)
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Set auto gain control to %d", val);
+ PDEBUG(D_CONF, "Set auto gain control to %d", val);
err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1);
if (err < 0)
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Set auto exposure control to %d", val);
+ PDEBUG(D_CONF, "Set auto exposure control to %d", val);
err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1);
if (err < 0)
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Set hvflip to %d, %d", sd->hflip->val, sd->vflip->val);
+ PDEBUG(D_CONF, "Set hvflip to %d, %d", sd->hflip->val, sd->vflip->val);
i2c_data = (sd->hflip->val << 5) | (sd->vflip->val << 4);
{
int err = 0;
u8 prod_id = 0, ver_id = 0, i;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
if (force_sensor) {
if (force_sensor == OV9650_SENSOR) {
int height = cam->cam_mode[sd->gspca_dev.curr_mode].height;
int ver_offs = cam->cam_mode[sd->gspca_dev.curr_mode].priv;
int hor_offs = OV9650_LEFT_OFFSET;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
if ((!dmi_check_system(ov9650_flip_dmi_table) &&
sd->vflip->val) ||
switch (width) {
case 640:
- PDEBUG(D_V4L2, "Configuring camera for VGA mode");
+ PDEBUG(D_CONF, "Configuring camera for VGA mode");
data = OV9650_VGA_SELECT | OV9650_RGB_SELECT |
OV9650_RAW_RGB_SELECT;
break;
case 352:
- PDEBUG(D_V4L2, "Configuring camera for CIF mode");
+ PDEBUG(D_CONF, "Configuring camera for CIF mode");
data = OV9650_CIF_SELECT | OV9650_RGB_SELECT |
OV9650_RAW_RGB_SELECT;
break;
case 320:
- PDEBUG(D_V4L2, "Configuring camera for QVGA mode");
+ PDEBUG(D_CONF, "Configuring camera for QVGA mode");
data = OV9650_QVGA_SELECT | OV9650_RGB_SELECT |
OV9650_RAW_RGB_SELECT;
break;
case 176:
- PDEBUG(D_V4L2, "Configuring camera for QCIF mode");
+ PDEBUG(D_CONF, "Configuring camera for QCIF mode");
data = OV9650_QCIF_SELECT | OV9650_RGB_SELECT |
OV9650_RAW_RGB_SELECT;
u8 i2c_data;
int err;
- PDEBUG(D_V4L2, "Set exposure to %d", val);
+ PDEBUG(D_CONF, "Set exposure to %d", val);
/* The 6 MSBs */
i2c_data = (val >> 10) & 0x3f;
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Setting gain to %d", val);
+ PDEBUG(D_CONF, "Setting gain to %d", val);
/* The 2 MSB */
/* Read the OV9650_VREF register first to avoid
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Set red gain to %d", val);
+ PDEBUG(D_CONF, "Set red gain to %d", val);
i2c_data = val & 0xff;
err = m5602_write_sensor(sd, OV9650_RED, &i2c_data, 1);
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Set blue gain to %d", val);
+ PDEBUG(D_CONF, "Set blue gain to %d", val);
i2c_data = val & 0xff;
err = m5602_write_sensor(sd, OV9650_BLUE, &i2c_data, 1);
int hflip = sd->hflip->val;
int vflip = sd->vflip->val;
- PDEBUG(D_V4L2, "Set hvflip to %d %d", hflip, vflip);
+ PDEBUG(D_CONF, "Set hvflip to %d %d", hflip, vflip);
if (dmi_check_system(ov9650_flip_dmi_table))
vflip = !vflip;
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Set auto exposure control to %d", val);
+ PDEBUG(D_CONF, "Set auto exposure control to %d", val);
err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
if (err < 0)
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Set auto white balance to %d", val);
+ PDEBUG(D_CONF, "Set auto white balance to %d", val);
err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
if (err < 0)
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Set auto gain control to %d", val);
+ PDEBUG(D_CONF, "Set auto gain control to %d", val);
err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
if (err < 0)
int po1030_probe(struct sd *sd)
{
u8 dev_id_h = 0, i;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
if (force_sensor) {
if (force_sensor == PO1030_SENSOR) {
u8 i2c_data;
int err;
- PDEBUG(D_V4L2, "Set exposure to %d", val & 0xffff);
+ PDEBUG(D_CONF, "Set exposure to %d", val & 0xffff);
i2c_data = ((val & 0xff00) >> 8);
- PDEBUG(D_V4L2, "Set exposure to high byte to 0x%x",
+ PDEBUG(D_CONF, "Set exposure to high byte to 0x%x",
i2c_data);
err = m5602_write_sensor(sd, PO1030_INTEGLINES_H,
return err;
i2c_data = (val & 0xff);
- PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x",
+ PDEBUG(D_CONF, "Set exposure to low byte to 0x%x",
i2c_data);
err = m5602_write_sensor(sd, PO1030_INTEGLINES_M,
&i2c_data, 1);
int err;
i2c_data = val & 0xff;
- PDEBUG(D_V4L2, "Set global gain to %d", i2c_data);
+ PDEBUG(D_CONF, "Set global gain to %d", i2c_data);
err = m5602_write_sensor(sd, PO1030_GLOBALGAIN,
&i2c_data, 1);
return err;
u8 i2c_data;
int err;
- PDEBUG(D_V4L2, "Set hvflip %d %d", sd->hflip->val, sd->vflip->val);
+ PDEBUG(D_CONF, "Set hvflip %d %d", sd->hflip->val, sd->vflip->val);
err = m5602_read_sensor(sd, PO1030_CONTROL2, &i2c_data, 1);
if (err < 0)
return err;
int err;
i2c_data = val & 0xff;
- PDEBUG(D_V4L2, "Set red gain to %d", i2c_data);
+ PDEBUG(D_CONF, "Set red gain to %d", i2c_data);
err = m5602_write_sensor(sd, PO1030_RED_GAIN,
&i2c_data, 1);
return err;
int err;
i2c_data = val & 0xff;
- PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data);
+ PDEBUG(D_CONF, "Set blue gain to %d", i2c_data);
err = m5602_write_sensor(sd, PO1030_BLUE_GAIN,
&i2c_data, 1);
int err;
i2c_data = val & 0xff;
- PDEBUG(D_V4L2, "Set green gain to %d", i2c_data);
+ PDEBUG(D_CONF, "Set green gain to %d", i2c_data);
err = m5602_write_sensor(sd, PO1030_GREEN_1_GAIN,
&i2c_data, 1);
if (err < 0)
return err;
- PDEBUG(D_V4L2, "Set auto white balance to %d", val);
+ PDEBUG(D_CONF, "Set auto white balance to %d", val);
i2c_data = (i2c_data & 0xfe) | (val & 0x01);
err = m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1);
return err;
if (err < 0)
return err;
- PDEBUG(D_V4L2, "Set auto exposure to %d", val);
+ PDEBUG(D_CONF, "Set auto exposure to %d", val);
val = (val == V4L2_EXPOSURE_AUTO);
i2c_data = (i2c_data & 0xfd) | ((val & 0x01) << 1);
return m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1);
{
u8 prod_id[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const u8 expected_prod_id[6] = {0x00, 0x10, 0x00, 0x4b, 0x33, 0x75};
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int i, err = 0;
if (force_sensor) {
int i, err = 0;
u8 data[2];
struct cam *cam = &sd->gspca_dev.cam;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
switch (cam->cam_mode[sd->gspca_dev.curr_mode].width) {
case 1280:
- PDEBUG(D_V4L2, "Configuring camera for SXGA mode");
+ PDEBUG(D_CONF, "Configuring camera for SXGA mode");
for (i = 0; i < ARRAY_SIZE(SXGA_s5k4aa); i++) {
switch (SXGA_s5k4aa[i][0]) {
break;
case 640:
- PDEBUG(D_V4L2, "Configuring camera for VGA mode");
+ PDEBUG(D_CONF, "Configuring camera for VGA mode");
for (i = 0; i < ARRAY_SIZE(VGA_s5k4aa); i++) {
switch (VGA_s5k4aa[i][0]) {
u8 data = S5K4AA_PAGE_MAP_2;
int err;
- PDEBUG(D_V4L2, "Set exposure to %d", val);
+ PDEBUG(D_CONF, "Set exposure to %d", val);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
return err;
int hflip = sd->hflip->val;
int vflip = sd->vflip->val;
- PDEBUG(D_V4L2, "Set hvflip %d %d", hflip, vflip);
+ PDEBUG(D_CONF, "Set hvflip %d %d", hflip, vflip);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
return err;
u8 data = S5K4AA_PAGE_MAP_2;
int err;
- PDEBUG(D_V4L2, "Set gain to %d", val);
+ PDEBUG(D_CONF, "Set gain to %d", val);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
return err;
u8 data = S5K4AA_PAGE_MAP_2;
int err;
- PDEBUG(D_V4L2, "Set brightness to %d", val);
+ PDEBUG(D_CONF, "Set brightness to %d", val);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
return err;
u8 data = S5K4AA_PAGE_MAP_2;
int err;
- PDEBUG(D_V4L2, "Set noise to %d", val);
+ PDEBUG(D_CONF, "Set noise to %d", val);
err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
if (err < 0)
return err;
{
u8 prod_id = 0, ver_id = 0;
int i, err = 0;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
if (force_sensor) {
if (force_sensor == S5K83A_SENSOR) {
return err_code;
}
if (status != 0x0a)
- PDEBUG(D_ERR, "status is %02x", status);
+ PERR("status is %02x", status);
tries = 0;
while (tries < 4) {
gspca_dev->usb_buf[0] = 0x01;
gspca_dev->usb_buf[1] = 0x00;
if (mr_write(gspca_dev, 2) < 0)
- PDEBUG(D_ERR, "Stream Stop failed");
+ PERR("Stream Stop failed");
}
static void lcd_stop(struct gspca_dev *gspca_dev)
gspca_dev->usb_buf[0] = 0x19;
gspca_dev->usb_buf[1] = 0x54;
if (mr_write(gspca_dev, 2) < 0)
- PDEBUG(D_ERR, "LCD Stop failed");
+ PERR("LCD Stop failed");
}
static int isoc_enable(struct gspca_dev *gspca_dev)
struct sd *sd = (struct sd *) gspca_dev;
unsigned char *sof;
- sof = pac_find_sof(&sd->sof_read, data, len);
+ sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len);
if (sof) {
int n;
/* Write a OV519 register */
static void reg_w(struct sd *sd, u16 index, u16 value)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int ret, req = 0;
if (sd->gspca_dev.usb_err < 0)
sd->gspca_dev.usb_buf, 1, 500);
leave:
if (ret < 0) {
- pr_err("reg_w %02x failed %d\n", index, ret);
+ PERR("reg_w %02x failed %d\n", index, ret);
sd->gspca_dev.usb_err = ret;
return;
}
/* returns: negative is error, pos or zero is data */
static int reg_r(struct sd *sd, u16 index)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int ret;
int req;
PDEBUG(D_USBI, "GET %02x 0000 %04x %02x",
req, index, ret);
} else {
- pr_err("reg_r %02x failed %d\n", index, ret);
+ PERR("reg_r %02x failed %d\n", index, ret);
sd->gspca_dev.usb_err = ret;
}
static int reg_r8(struct sd *sd,
u16 index)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int ret;
if (sd->gspca_dev.usb_err < 0)
if (ret >= 0) {
ret = sd->gspca_dev.usb_buf[0];
} else {
- pr_err("reg_r8 %02x failed %d\n", index, ret);
+ PERR("reg_r8 %02x failed %d\n", index, ret);
sd->gspca_dev.usb_err = ret;
}
*/
static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int ret;
if (sd->gspca_dev.usb_err < 0)
0, index,
sd->gspca_dev.usb_buf, n, 500);
if (ret < 0) {
- pr_err("reg_w32 %02x failed %d\n", index, ret);
+ PERR("reg_w32 %02x failed %d\n", index, ret);
sd->gspca_dev.usb_err = ret;
}
}
static void ov511_i2c_w(struct sd *sd, u8 reg, u8 value)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int rc, retries;
PDEBUG(D_USBO, "ov511_i2c_w %02x %02x", reg, value);
static int ov511_i2c_r(struct sd *sd, u8 reg)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int rc, value, retries;
/* Two byte write cycle */
u8 reg,
u8 value)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
+
PDEBUG(D_USBO, "ov518_i2c_w %02x %02x", reg, value);
/* Select camera register */
*/
static int ov518_i2c_r(struct sd *sd, u8 reg)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int value;
/* Select camera register */
static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int ret;
if (sd->gspca_dev.usb_err < 0)
(u16) value, (u16) reg, NULL, 0, 500);
if (ret < 0) {
- pr_err("ovfx2_i2c_w %02x failed %d\n", reg, ret);
+ PERR("ovfx2_i2c_w %02x failed %d\n", reg, ret);
sd->gspca_dev.usb_err = ret;
}
static int ovfx2_i2c_r(struct sd *sd, u8 reg)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int ret;
if (sd->gspca_dev.usb_err < 0)
ret = sd->gspca_dev.usb_buf[0];
PDEBUG(D_USBI, "ovfx2_i2c_r %02x %02x", reg, ret);
} else {
- pr_err("ovfx2_i2c_r %02x failed %d\n", reg, ret);
+ PERR("ovfx2_i2c_r %02x failed %d\n", reg, ret);
sd->gspca_dev.usb_err = ret;
}
* registers while the camera is streaming */
static inline void ov51x_stop(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
+
PDEBUG(D_STREAM, "stopping");
sd->stopped = 1;
switch (sd->bridge) {
* actually stopped (for performance). */
static inline void ov51x_restart(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
+
PDEBUG(D_STREAM, "restarting");
if (!sd->stopped)
return;
static int init_ov_sensor(struct sd *sd, u8 slave)
{
int i;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
ov51x_set_slave_ids(sd, slave);
/* This initializes the OV2x10 / OV3610 / OV3620 / OV9600 */
static void ov_hires_configure(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int high, low;
if (sd->bridge != BRIDGE_OVFX2) {
- pr_err("error hires sensors only supported with ovfx2\n");
+ PERR("error hires sensors only supported with ovfx2\n");
return;
}
}
break;
}
- pr_err("Error unknown sensor type: %02x%02x\n", high, low);
+ PERR("Error unknown sensor type: %02x%02x\n", high, low);
}
/* This initializes the OV8110, OV8610 sensor. The OV8110 uses
*/
static void ov8xx0_configure(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int rc;
PDEBUG(D_PROBE, "starting ov8xx0 configuration");
/* Detect sensor (sub)type */
rc = i2c_r(sd, OV7610_REG_COM_I);
if (rc < 0) {
- PDEBUG(D_ERR, "Error detecting sensor type");
+ PERR("Error detecting sensor type");
return;
}
if ((rc & 3) == 1)
sd->sensor = SEN_OV8610;
else
- pr_err("Unknown image sensor version: %d\n", rc & 3);
+ PERR("Unknown image sensor version: %d\n", rc & 3);
}
/* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses
*/
static void ov7xx0_configure(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int rc, high, low;
PDEBUG(D_PROBE, "starting OV7xx0 configuration");
/* add OV7670 here
* it appears to be wrongly detected as a 7610 by default */
if (rc < 0) {
- pr_err("Error detecting sensor type\n");
+ PERR("Error detecting sensor type\n");
return;
}
if ((rc & 3) == 3) {
/* try to read product id registers */
high = i2c_r(sd, 0x0a);
if (high < 0) {
- pr_err("Error detecting camera chip PID\n");
+ PERR("Error detecting camera chip PID\n");
return;
}
low = i2c_r(sd, 0x0b);
if (low < 0) {
- pr_err("Error detecting camera chip VER\n");
+ PERR("Error detecting camera chip VER\n");
return;
}
if (high == 0x76) {
switch (low) {
case 0x30:
- pr_err("Sensor is an OV7630/OV7635\n");
- pr_err("7630 is not supported by this driver\n");
+ PERR("Sensor is an OV7630/OV7635\n");
+ PERR("7630 is not supported by this driver\n");
return;
case 0x40:
PDEBUG(D_PROBE, "Sensor is an OV7645");
sd->sensor = SEN_OV7660;
break;
default:
- pr_err("Unknown sensor: 0x76%02x\n", low);
+ PERR("Unknown sensor: 0x76%02x\n", low);
return;
}
} else {
sd->sensor = SEN_OV7620;
}
} else {
- pr_err("Unknown image sensor version: %d\n", rc & 3);
+ PERR("Unknown image sensor version: %d\n", rc & 3);
}
}
/* This initializes the OV6620, OV6630, OV6630AE, or OV6630AF sensor. */
static void ov6xx0_configure(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int rc;
+
PDEBUG(D_PROBE, "starting OV6xx0 configuration");
/* Detect sensor (sub)type */
rc = i2c_r(sd, OV7610_REG_COM_I);
if (rc < 0) {
- pr_err("Error detecting sensor type\n");
+ PERR("Error detecting sensor type\n");
return;
}
pr_warn("WARNING: Sensor is an OV66307. Your camera may have been misdetected in previous driver versions.\n");
break;
default:
- pr_err("FATAL: Unknown sensor version: 0x%02x\n", rc);
+ PERR("FATAL: Unknown sensor version: 0x%02x\n", rc);
return;
}
7, 7, 7, 7, 7, 7, 8, 8
};
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
const unsigned char *pYTable, *pUVTable;
unsigned char val0, val1;
int i, size, reg = R51x_COMP_LUT_BEGIN;
} else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) {
ov_hires_configure(sd);
} else {
- pr_err("Can't determine sensor slave IDs\n");
+ PERR("Can't determine sensor slave IDs\n");
goto error;
}
}
return gspca_dev->usb_err;
error:
- PDEBUG(D_ERR, "OV519 Config failed");
+ PERR("OV519 Config failed");
return -EINVAL;
}
*/
static void ov511_mode_init_regs(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int hsegs, vsegs, packet_size, fps, needed;
int interlaced = 0;
struct usb_host_interface *alt;
intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
if (!alt) {
- pr_err("Couldn't get altsetting\n");
+ PERR("Couldn't get altsetting\n");
sd->gspca_dev.usb_err = -EIO;
return;
}
*/
static void ov518_mode_init_regs(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int hsegs, vsegs, packet_size;
struct usb_host_interface *alt;
struct usb_interface *intf;
intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
if (!alt) {
- pr_err("Couldn't get altsetting\n");
+ PERR("Couldn't get altsetting\n");
sd->gspca_dev.usb_err = -EIO;
return;
}
/* windows reads 0x55 at this point, why? */
};
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
+
/******** Set the mode ********/
switch (sd->sensor) {
default:
static void mode_init_ov_sensor_regs(struct sd *sd)
{
- struct gspca_dev *gspca_dev;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int qvga, xstart, xend, ystart, yend;
u8 v;
- gspca_dev = &sd->gspca_dev;
qvga = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 1;
/******** Mode (VGA/QVGA) and sensor specific regs ********/
/* Frame end */
if ((in[9] + 1) * 8 != gspca_dev->width ||
(in[10] + 1) * 8 != gspca_dev->height) {
- PDEBUG(D_ERR, "Invalid frame size, got: %dx%d,"
+ PERR("Invalid frame size, got: %dx%d,"
" requested: %dx%d\n",
(in[9] + 1) * 8, (in[10] + 1) * 8,
gspca_dev->width, gspca_dev->height);
except that they may contain part of the footer), are
numbered 0 */
else if (sd->packet_nr == 0 || data[len]) {
- PDEBUG(D_ERR, "Invalid packet nr: %d (expect: %d)",
+ PERR("Invalid packet nr: %d (expect: %d)",
(int)data[len], (int)sd->packet_nr);
gspca_dev->last_packet_type = DISCARD_PACKET;
return;
QUALITY_MIN, QUALITY_MAX, 1, QUALITY_DEF);
if (hdl->error) {
- pr_err("Could not initialize controls\n");
+ PERR("Could not initialize controls\n");
return hdl->error;
}
if (gspca_dev->autogain)
case 0x03:
break;
default:
- PDEBUG(D_ERR, "sccb status 0x%02x, attempt %d/5",
+ PERR("sccb status 0x%02x, attempt %d/5",
data, i + 1);
}
}
struct sd *sd = (struct sd *) gspca_dev;
unsigned char *sof;
- sof = pac_find_sof(&sd->sof_read, data, len);
+ sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len);
if (sof) {
int n;
reg_w_page(gspca_dev, page3, page3_len);
break;
default:
-#ifdef GSPCA_DEBUG
if (len > USB_BUF_SZ) {
- PDEBUG(D_ERR|D_STREAM,
- "Incorrect variable sequence");
+ PERR("Incorrect variable sequence");
return;
}
-#endif
while (len > 0) {
if (len < 8) {
reg_w_buf(gspca_dev,
u8 *image;
u8 *sof;
- sof = pac_find_sof(&sd->sof_read, data, len);
+ sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len);
if (sof) {
int n, lum_offset, footer_length;
break;
default:
if (len > USB_BUF_SZ) {
- PDEBUG(D_ERR|D_STREAM,
- "Incorrect variable sequence");
+ PERR("Incorrect variable sequence");
return;
}
while (len > 0) {
u8 *image;
unsigned char *sof;
- sof = pac_find_sof(&sd->sof_read, data, len);
+ sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len);
if (sof) {
int n, lum_offset, footer_length;
+----------+
*/
-static unsigned char *pac_find_sof(u8 *sof_read,
+static unsigned char *pac_find_sof(struct gspca_dev *gspca_dev, u8 *sof_read,
unsigned char *m, int len)
{
int i;
result = sn9c2028_read1(gspca_dev);
if (result < 0)
- PDEBUG(D_ERR, "Camera Stop read failed");
+ PERR("Camera Stop read failed");
memset(data, 0, 6);
data[0] = 0x14;
result = sn9c2028_command(gspca_dev, data);
if (result < 0)
- PDEBUG(D_ERR, "Camera Stop command failed");
+ PERR("Camera Stop command failed");
}
/* Include sn9c2028 sof detection functions */
if (gspca_dev->usb_err < 0)
return;
-#ifdef GSPCA_DEBUG
if (len > USB_BUF_SZ) {
- pr_err("reg_r: buffer overflow\n");
+ PERR("reg_r: buffer overflow\n");
return;
}
-#endif
+
ret = usb_control_msg(gspca_dev->dev,
usb_rcvctrlpipe(gspca_dev->dev, 0),
0,
return;
PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
value, buffer[0], buffer[1]);
-#ifdef GSPCA_DEBUG
+
if (len > USB_BUF_SZ) {
- pr_err("reg_w: buffer overflow\n");
+ PERR("reg_w: buffer overflow\n");
return;
}
-#endif
+
memcpy(gspca_dev->usb_buf, buffer, len);
ret = usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0),
w += 15;
msleep(w);
} while (--i > 0);
- PDEBUG(D_ERR, "wait_status_0 timeout");
+ PERR("wait_status_0 timeout");
gspca_dev->usb_err = -ETIME;
}
return;
}
} while (--i > 0);
- PDEBUG(D_ERR, "wait_status_1 timeout");
+ PERR("wait_status_1 timeout");
gspca_dev->usb_err = -ETIME;
}
return err;
err = reg_r_wait(gspca_dev, 0x06, 0, 0);
if (err < 0) {
- PDEBUG(D_ERR, "reg_r_wait() failed");
+ PERR("reg_r_wait() failed");
return err;
}
/* all ok */
static int spca500_synch310(struct gspca_dev *gspca_dev)
{
if (usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0) < 0) {
- PDEBUG(D_ERR, "Set packet size: set interface error");
+ PERR("Set packet size: set interface error");
goto error;
}
spca500_ping310(gspca_dev);
if (usb_set_interface(gspca_dev->dev,
gspca_dev->iface,
gspca_dev->alt) < 0) {
- PDEBUG(D_ERR, "Set packet size: set interface error");
+ PERR("Set packet size: set interface error");
goto error;
}
return 0;
err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840,
qtable_pocketdv);
if (err < 0)
- PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed on init");
+ PERR("spca50x_setup_qtable failed on init");
/* set qtable index */
reg_w(gspca_dev, 0x00, 0x8880, 2);
0x00, 0x8800, 0x8840,
qtable_creative_pccam);
if (err < 0)
- PDEBUG(D_ERR, "spca50x_setup_qtable failed");
+ PERR("spca50x_setup_qtable failed");
/* Init SDRAM - needed for SDRAM access */
reg_w(gspca_dev, 0x00, 0x870a, 0x04);
reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
msleep(500);
if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
- PDEBUG(D_ERR, "reg_r_wait() failed");
+ PERR("reg_r_wait() failed");
reg_r(gspca_dev, 0x816b, 1);
Data = gspca_dev->usb_buf[0];
/* enable drop packet */
err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
if (err < 0)
- PDEBUG(D_ERR, "failed to enable drop packet");
+ PERR("failed to enable drop packet");
reg_w(gspca_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");
+ PERR("spca50x_setup_qtable failed");
/* Init SDRAM - needed for SDRAM access */
reg_w(gspca_dev, 0x00, 0x870a, 0x04);
reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
- PDEBUG(D_ERR, "reg_r_wait() failed");
+ PERR("reg_r_wait() failed");
reg_r(gspca_dev, 0x816b, 1);
Data = gspca_dev->usb_buf[0];
/* do a full reset */
err = spca500_full_reset(gspca_dev);
if (err < 0)
- PDEBUG(D_ERR, "spca500_full_reset failed");
+ PERR("spca500_full_reset failed");
/* enable drop packet */
err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
if (err < 0)
- PDEBUG(D_ERR, "failed to enable drop packet");
+ PERR("failed to enable drop packet");
reg_w(gspca_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");
+ PERR("spca50x_setup_qtable failed");
spca500_setmode(gspca_dev, xmult, ymult);
reg_w(gspca_dev, 0x20, 0x0001, 0x0004);
reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
- PDEBUG(D_ERR, "reg_r_wait() failed");
+ PERR("reg_r_wait() failed");
reg_r(gspca_dev, 0x816b, 1);
Data = gspca_dev->usb_buf[0];
/* do a full reset */
err = spca500_full_reset(gspca_dev);
if (err < 0)
- PDEBUG(D_ERR, "spca500_full_reset failed");
+ PERR("spca500_full_reset failed");
/* enable drop packet */
reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
reg_w(gspca_dev, 0x00, 0x8880, 0);
0x00, 0x8800, 0x8840,
qtable_kodak_ez200);
if (err < 0)
- PDEBUG(D_ERR, "spca50x_setup_qtable failed");
+ PERR("spca50x_setup_qtable failed");
spca500_setmode(gspca_dev, xmult, ymult);
reg_w(gspca_dev, 0x20, 0x0001, 0x0004);
reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
- PDEBUG(D_ERR, "reg_r_wait() failed");
+ PERR("reg_r_wait() failed");
reg_r(gspca_dev, 0x816b, 1);
Data = gspca_dev->usb_buf[0];
err = spca50x_setup_qtable(gspca_dev,
0x00, 0x8800, 0x8840, qtable_pocketdv);
if (err < 0)
- PDEBUG(D_ERR, "spca50x_setup_qtable failed");
+ PERR("spca50x_setup_qtable failed");
reg_w(gspca_dev, 0x00, 0x8880, 2);
/* familycam Quicksmart pocketDV stuff */
0x00, 0x8800,
0x8840, qtable_creative_pccam);
if (err < 0)
- PDEBUG(D_ERR, "spca50x_setup_qtable failed");
+ PERR("spca50x_setup_qtable failed");
reg_w(gspca_dev, 0x00, 0x8880, 3);
reg_w(gspca_dev, 0x00, 0x800a, 0x00);
/* Init SDRAM - needed for SDRAM access */
{}
};
-static int reg_write(struct usb_device *dev,
- __u16 req, __u16 index, __u16 value)
+static int reg_write(struct gspca_dev *gspca_dev,
+ __u16 req, __u16 index, __u16 value)
{
int ret;
+ struct usb_device *dev = gspca_dev->dev;
ret = usb_control_msg(dev,
usb_sndctrlpipe(dev, 0),
}
-static int write_vector(struct gspca_dev *gspca_dev,
- const __u16 data[][3])
+static int write_vector(struct gspca_dev *gspca_dev, 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_write(gspca_dev, data[i][0], data[i][2],
+ data[i][1]);
if (ret < 0) {
- PDEBUG(D_ERR,
- "Reg write failed for 0x%02x,0x%02x,0x%02x",
+ PERR("Reg write failed for 0x%02x,0x%02x,0x%02x",
data[i][0], data[i][1], data[i][2]);
return ret;
}
static void setbrightness(struct gspca_dev *gspca_dev, s32 val)
{
- reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x12, val);
+ reg_write(gspca_dev, SPCA501_REG_CCDSP, 0x12, val);
}
static void setcontrast(struct gspca_dev *gspca_dev, s32 val)
{
- reg_write(gspca_dev->dev, 0x00, 0x00,
- (val >> 8) & 0xff);
- reg_write(gspca_dev->dev, 0x00, 0x01,
- val & 0xff);
+ reg_write(gspca_dev, 0x00, 0x00, (val >> 8) & 0xff);
+ reg_write(gspca_dev, 0x00, 0x01, val & 0xff);
}
static void setcolors(struct gspca_dev *gspca_dev, s32 val)
{
- reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x0c, val);
+ reg_write(gspca_dev, SPCA501_REG_CCDSP, 0x0c, val);
}
static void setblue_balance(struct gspca_dev *gspca_dev, s32 val)
{
- reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x11, val);
+ reg_write(gspca_dev, SPCA501_REG_CCDSP, 0x11, val);
}
static void setred_balance(struct gspca_dev *gspca_dev, s32 val)
{
- reg_write(gspca_dev->dev, SPCA501_REG_CCDSP, 0x13, val);
+ reg_write(gspca_dev, SPCA501_REG_CCDSP, 0x13, val);
}
/* this function is called at probe time */
static int sd_start(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
int mode;
switch (sd->subtype) {
/* Enable ISO packet machine CTRL reg=2,
* index=1 bitmask=0x2 (bit ordinal 1) */
- reg_write(dev, SPCA50X_REG_USB, 0x6, 0x94);
+ reg_write(gspca_dev, SPCA50X_REG_USB, 0x6, 0x94);
switch (mode) {
case 0: /* 640x480 */
- reg_write(dev, SPCA50X_REG_USB, 0x07, 0x004a);
+ reg_write(gspca_dev, SPCA50X_REG_USB, 0x07, 0x004a);
break;
case 1: /* 320x240 */
- reg_write(dev, SPCA50X_REG_USB, 0x07, 0x104a);
+ reg_write(gspca_dev, SPCA50X_REG_USB, 0x07, 0x104a);
break;
default:
/* case 2: * 160x120 */
- reg_write(dev, SPCA50X_REG_USB, 0x07, 0x204a);
+ reg_write(gspca_dev, SPCA50X_REG_USB, 0x07, 0x204a);
break;
}
- reg_write(dev, SPCA501_REG_CTLRL, 0x01, 0x02);
+ reg_write(gspca_dev, SPCA501_REG_CTLRL, 0x01, 0x02);
return 0;
}
{
/* Disable ISO packet
* machine CTRL reg=2, index=1 bitmask=0x0 (bit ordinal 1) */
- reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x01, 0x00);
+ reg_write(gspca_dev, SPCA501_REG_CTLRL, 0x01, 0x00);
}
/* called on streamoff with alt 0 and on disconnect */
{
if (!gspca_dev->present)
return;
- reg_write(gspca_dev->dev, SPCA501_REG_CTLRL, 0x05, 0x00);
+ reg_write(gspca_dev, SPCA501_REG_CTLRL, 0x05, 0x00);
}
static void sd_pkt_scan(struct gspca_dev *gspca_dev,
{}
};
-static int reg_write(struct usb_device *dev,
+static int reg_write(struct gspca_dev *gspca_dev,
u16 req, u16 index, u16 value)
{
int ret;
+ struct usb_device *dev = gspca_dev->dev;
ret = usb_control_msg(dev,
usb_sndctrlpipe(dev, 0),
static int write_vector(struct gspca_dev *gspca_dev,
const u8 data[][3])
{
- struct usb_device *dev = gspca_dev->dev;
int ret, i = 0;
while (data[i][0] != 0) {
- ret = reg_write(dev, data[i][0], data[i][2], data[i][1]);
+ ret = reg_write(gspca_dev, data[i][0], data[i][2],
+ data[i][1]);
if (ret < 0)
return ret;
i++;
static void setbrightness(struct gspca_dev *gspca_dev, s32 brightness)
{
- reg_write(gspca_dev->dev, 0x05, 0x00, (255 - brightness) >> 6);
- reg_write(gspca_dev->dev, 0x05, 0x01, (255 - brightness) << 2);
+ reg_write(gspca_dev, 0x05, 0x00, (255 - brightness) >> 6);
+ reg_write(gspca_dev, 0x05, 0x01, (255 - brightness) << 2);
}
static int sd_start(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
int ret, mode;
static u8 mode_tb[][3] = {
/* r00 r06 r07 */
ret = reg_read(gspca_dev, 0x06, 0x16);
if (ret < 0) {
- PDEBUG(D_ERR|D_CONF,
- "register read failed err: %d",
- ret);
+ PERR("register read failed err: %d", ret);
return ret;
}
if (ret != 0x0101) {
ret);
}
- ret = reg_write(gspca_dev->dev, 0x06, 0x16, 0x0a);
+ ret = reg_write(gspca_dev, 0x06, 0x16, 0x0a);
if (ret < 0)
return ret;
- reg_write(gspca_dev->dev, 0x05, 0xc2, 0x12);
+ reg_write(gspca_dev, 0x05, 0xc2, 0x12);
/* necessary because without it we can see stream
* only once after loading module */
/* stopping usb registers Tomasz change */
- reg_write(dev, 0x02, 0x00, 0x00);
+ reg_write(gspca_dev, 0x02, 0x00, 0x00);
mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
- reg_write(dev, SPCA50X_REG_COMPRESS, 0x00, mode_tb[mode][0]);
- reg_write(dev, SPCA50X_REG_COMPRESS, 0x06, mode_tb[mode][1]);
- reg_write(dev, SPCA50X_REG_COMPRESS, 0x07, mode_tb[mode][2]);
+ reg_write(gspca_dev, SPCA50X_REG_COMPRESS, 0x00, mode_tb[mode][0]);
+ reg_write(gspca_dev, SPCA50X_REG_COMPRESS, 0x06, mode_tb[mode][1]);
+ reg_write(gspca_dev, SPCA50X_REG_COMPRESS, 0x07, mode_tb[mode][2]);
- return reg_write(dev, SPCA50X_REG_USB,
+ return reg_write(gspca_dev, SPCA50X_REG_USB,
SPCA50X_USB_CTRL,
SPCA50X_CUSB_ENABLE);
}
static void sd_stopN(struct gspca_dev *gspca_dev)
{
/* Disable ISO packet machine */
- reg_write(gspca_dev->dev, 0x02, 0x00, 0x00);
+ reg_write(gspca_dev, 0x02, 0x00, 0x00);
}
/* called on streamoff with alt 0 and on disconnect */
return;
/* This maybe reset or power control */
- reg_write(gspca_dev->dev, 0x03, 0x03, 0x20);
- reg_write(gspca_dev->dev, 0x03, 0x01, 0x00);
- reg_write(gspca_dev->dev, 0x03, 0x00, 0x01);
- reg_write(gspca_dev->dev, 0x05, 0x10, 0x01);
- reg_write(gspca_dev->dev, 0x05, 0x11, 0x0f);
+ reg_write(gspca_dev, 0x03, 0x03, 0x20);
+ reg_write(gspca_dev, 0x03, 0x01, 0x00);
+ reg_write(gspca_dev, 0x03, 0x00, 0x01);
+ reg_write(gspca_dev, 0x05, 0x10, 0x01);
+ reg_write(gspca_dev, 0x05, 0x11, 0x0f);
}
static void sd_pkt_scan(struct gspca_dev *gspca_dev,
{}
};
-static int reg_write(struct usb_device *dev,
- u16 index, u16 value)
+static int reg_write(struct gspca_dev *gspca_dev, u16 index, u16 value)
{
int ret;
+ struct usb_device *dev = gspca_dev->dev;
ret = usb_control_msg(dev,
usb_sndctrlpipe(dev, 0),
static int ssi_w(struct gspca_dev *gspca_dev,
u16 reg, u16 val)
{
- struct usb_device *dev = gspca_dev->dev;
int ret, retry;
- ret = reg_write(dev, 0x8802, reg >> 8);
+ ret = reg_write(gspca_dev, 0x8802, reg >> 8);
if (ret < 0)
goto out;
- ret = reg_write(dev, 0x8801, reg & 0x00ff);
+ ret = reg_write(gspca_dev, 0x8801, reg & 0x00ff);
if (ret < 0)
goto out;
if ((reg & 0xff00) == 0x1000) { /* if 2 bytes */
- ret = reg_write(dev, 0x8805, val & 0x00ff);
+ ret = reg_write(gspca_dev, 0x8805, val & 0x00ff);
if (ret < 0)
goto out;
val >>= 8;
}
- ret = reg_write(dev, 0x8800, val);
+ ret = reg_write(gspca_dev, 0x8800, val);
if (ret < 0)
goto out;
if (gspca_dev->usb_buf[0] == 0)
break;
if (--retry <= 0) {
- PDEBUG(D_ERR, "ssi_w busy %02x",
- gspca_dev->usb_buf[0]);
+ PERR("ssi_w busy %02x", gspca_dev->usb_buf[0]);
ret = -1;
break;
}
static int write_vector(struct gspca_dev *gspca_dev,
const u16 (*data)[2])
{
- struct usb_device *dev = gspca_dev->dev;
int ret = 0;
while ((*data)[1] != 0) {
if ((*data)[1] == 0xdd00) /* delay */
msleep((*data)[0]);
else
- ret = reg_write(dev, (*data)[1], (*data)[0]);
+ ret = reg_write(gspca_dev, (*data)[1],
+ (*data)[0]);
} else {
ret = ssi_w(gspca_dev, (*data)[1], (*data)[0]);
}
spca508cs110_init_data, /* MicroInnovationIC200 4 */
spca508_init_data, /* ViewQuestVQ110 5 */
};
-
-#ifdef GSPCA_DEBUG
int data1, data2;
/* Read from global register the USB product and vendor IDs, just to
data1 = reg_read(gspca_dev, 0x8621);
PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1);
-#endif
cam = &gspca_dev->cam;
cam->cam_mode = sif_mode;
int mode;
mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
- reg_write(gspca_dev->dev, 0x8500, mode);
+ reg_write(gspca_dev, 0x8500, mode);
switch (mode) {
case 0:
case 1:
- reg_write(gspca_dev->dev, 0x8700, 0x28); /* clock */
+ reg_write(gspca_dev, 0x8700, 0x28); /* clock */
break;
default:
/* case 2: */
/* case 3: */
- reg_write(gspca_dev->dev, 0x8700, 0x23); /* clock */
+ reg_write(gspca_dev, 0x8700, 0x23); /* clock */
break;
}
- reg_write(gspca_dev->dev, 0x8112, 0x10 | 0x20);
+ reg_write(gspca_dev, 0x8112, 0x10 | 0x20);
return 0;
}
static void sd_stopN(struct gspca_dev *gspca_dev)
{
/* Video ISO disable, Video Drop Packet enable: */
- reg_write(gspca_dev->dev, 0x8112, 0x20);
+ reg_write(gspca_dev, 0x8112, 0x20);
}
static void sd_pkt_scan(struct gspca_dev *gspca_dev,
static void setbrightness(struct gspca_dev *gspca_dev, s32 brightness)
{
/* MX seem contrast */
- reg_write(gspca_dev->dev, 0x8651, brightness);
- reg_write(gspca_dev->dev, 0x8652, brightness);
- reg_write(gspca_dev->dev, 0x8653, brightness);
- reg_write(gspca_dev->dev, 0x8654, brightness);
+ reg_write(gspca_dev, 0x8651, brightness);
+ reg_write(gspca_dev, 0x8652, brightness);
+ reg_write(gspca_dev, 0x8653, brightness);
+ reg_write(gspca_dev, 0x8654, brightness);
}
static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
{}
};
-static void reg_w_val(struct usb_device *dev, __u16 index, __u8 value)
+static void reg_w_val(struct gspca_dev *gspca_dev, __u16 index, __u8 value)
{
int ret;
+ struct usb_device *dev = gspca_dev->dev;
ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
0, /* request */
static void write_vector(struct gspca_dev *gspca_dev,
const __u16 data[][2])
{
- struct usb_device *dev = gspca_dev->dev;
int i;
i = 0;
while (data[i][1] != 0) {
- reg_w_val(dev, data[i][1], data[i][0]);
+ reg_w_val(gspca_dev, data[i][1], data[i][0]);
i++;
}
}
{
int retry = 60;
- reg_w_val(gspca_dev->dev, 0x8801, reg);
- reg_w_val(gspca_dev->dev, 0x8805, value);
- reg_w_val(gspca_dev->dev, 0x8800, value >> 8);
+ reg_w_val(gspca_dev, 0x8801, reg);
+ reg_w_val(gspca_dev, 0x8805, value);
+ reg_w_val(gspca_dev, 0x8800, value >> 8);
do {
reg_r(gspca_dev, 0x8803, 1);
if (!gspca_dev->usb_buf[0])
int retry = 60;
__u8 value;
- reg_w_val(gspca_dev->dev, 0x8804, 0x92);
- reg_w_val(gspca_dev->dev, 0x8801, reg);
- reg_w_val(gspca_dev->dev, 0x8802, mode | 0x01);
+ reg_w_val(gspca_dev, 0x8804, 0x92);
+ reg_w_val(gspca_dev, 0x8801, reg);
+ reg_w_val(gspca_dev, 0x8802, mode | 0x01);
do {
reg_r(gspca_dev, 0x8803, 1);
if (!gspca_dev->usb_buf[0]) {
write_sensor_72a(gspca_dev, rev72a_init_sensor1);
write_vector(gspca_dev, rev72a_init_data2);
write_sensor_72a(gspca_dev, rev72a_init_sensor2);
- reg_w_val(gspca_dev->dev, 0x8112, 0x30);
+ reg_w_val(gspca_dev, 0x8112, 0x30);
return 0;
}
static void setbrightness(struct gspca_dev *gspca_dev, s32 val)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
__u16 reg;
if (sd->chip_revision == Rev012A)
else
reg = 0x8611;
- reg_w_val(dev, reg + 0, val); /* R */
- reg_w_val(dev, reg + 1, val); /* Gr */
- reg_w_val(dev, reg + 2, val); /* B */
- reg_w_val(dev, reg + 3, val); /* Gb */
+ reg_w_val(gspca_dev, reg + 0, val); /* R */
+ reg_w_val(gspca_dev, reg + 1, val); /* Gr */
+ reg_w_val(gspca_dev, reg + 2, val); /* B */
+ reg_w_val(gspca_dev, reg + 3, val); /* Gb */
}
static void setwhite(struct gspca_dev *gspca_dev, s32 white, s32 contrast)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
__u8 blue, red;
__u16 reg;
reg = 0x8651;
red += contrast - 0x20;
blue += contrast - 0x20;
- reg_w_val(dev, 0x8652, contrast + 0x20); /* Gr */
- reg_w_val(dev, 0x8654, contrast + 0x20); /* Gb */
+ reg_w_val(gspca_dev, 0x8652, contrast + 0x20); /* Gr */
+ reg_w_val(gspca_dev, 0x8654, contrast + 0x20); /* Gb */
}
- reg_w_val(dev, reg, red);
- reg_w_val(dev, reg + 2, blue);
+ reg_w_val(gspca_dev, reg, red);
+ reg_w_val(gspca_dev, reg + 2, blue);
}
/* rev 12a only */
static int sd_start_12a(struct gspca_dev *gspca_dev)
{
- struct usb_device *dev = gspca_dev->dev;
int mode;
static const __u8 Reg8391[8] =
{0x92, 0x30, 0x20, 0x00, 0x0c, 0x00, 0x00, 0x00};
mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
if (mode <= 1) {
/* Use compression on 320x240 and above */
- reg_w_val(dev, 0x8500, 0x10 | mode);
+ reg_w_val(gspca_dev, 0x8500, 0x10 | mode);
} else {
/* I couldn't get the compression to work below 320x240
* Fortunately at these resolutions the bandwidth
* is sufficient to push raw frames at ~20fps */
- reg_w_val(dev, 0x8500, mode);
+ reg_w_val(gspca_dev, 0x8500, mode);
} /* -- qq@kuku.eu.org */
gspca_dev->usb_buf[0] = 0xaa;
gspca_dev->usb_buf[1] = 0x00;
reg_w_buf(gspca_dev, 0x8307, 2);
/* clock - lower 0x8X values lead to fps > 30 */
- reg_w_val(gspca_dev->dev, 0x8700, 0x8a);
+ reg_w_val(gspca_dev, 0x8700, 0x8a);
/* 0x8f 0x85 0x27 clock */
- reg_w_val(gspca_dev->dev, 0x8112, 0x1e | 0x20);
- reg_w_val(gspca_dev->dev, 0x850b, 0x03);
+ reg_w_val(gspca_dev, 0x8112, 0x1e | 0x20);
+ reg_w_val(gspca_dev, 0x850b, 0x03);
memcpy(gspca_dev->usb_buf, Reg8391, 8);
reg_w_buf(gspca_dev, 0x8391, 8);
reg_w_buf(gspca_dev, 0x8390, 8);
/* Led ON (bit 3 -> 0 */
- reg_w_val(gspca_dev->dev, 0x8114, 0x00);
+ reg_w_val(gspca_dev, 0x8114, 0x00);
return 0;
}
static int sd_start_72a(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
- struct usb_device *dev = gspca_dev->dev;
int Clck;
int mode;
Clck = 0x21;
break;
}
- reg_w_val(dev, 0x8700, Clck); /* 0x27 clock */
- reg_w_val(dev, 0x8702, 0x81);
- reg_w_val(dev, 0x8500, mode); /* mode */
+ reg_w_val(gspca_dev, 0x8700, Clck); /* 0x27 clock */
+ reg_w_val(gspca_dev, 0x8702, 0x81);
+ reg_w_val(gspca_dev, 0x8500, mode); /* mode */
write_sensor_72a(gspca_dev, rev72a_init_sensor2);
setwhite(gspca_dev, v4l2_ctrl_g_ctrl(sd->hue),
v4l2_ctrl_g_ctrl(sd->contrast));
/* setbrightness(gspca_dev); * fixme: bad values */
setautogain(gspca_dev, v4l2_ctrl_g_ctrl(sd->autogain));
- reg_w_val(dev, 0x8112, 0x10 | 0x20);
+ reg_w_val(gspca_dev, 0x8112, 0x10 | 0x20);
return 0;
}
struct sd *sd = (struct sd *) gspca_dev;
if (sd->chip_revision == Rev012A) {
- reg_w_val(gspca_dev->dev, 0x8112, 0x0e);
+ reg_w_val(gspca_dev, 0x8112, 0x0e);
/* Led Off (bit 3 -> 1 */
- reg_w_val(gspca_dev->dev, 0x8114, 0x08);
+ reg_w_val(gspca_dev, 0x8114, 0x08);
} else {
- reg_w_val(gspca_dev->dev, 0x8112, 0x20);
-/* reg_w_val(gspca_dev->dev, 0x8102, 0x00); ?? */
+ reg_w_val(gspca_dev, 0x8112, 0x20);
+/* reg_w_val(gspca_dev, 0x8102, 0x00); ?? */
}
}
/* This should never happen */
if (len < 2) {
- PDEBUG(D_ERR, "Short SOF packet, ignoring");
+ PERR("Short SOF packet, ignoring");
gspca_dev->last_packet_type = DISCARD_PACKET;
return;
}
}
if (ret < 0) {
- PDEBUG(D_ERR, "Start streaming command failed");
+ PERR("Start streaming command failed");
return ret;
}
/* Start the workqueue function to do the streaming */
ret = sq905c_command(gspca_dev, SQ905C_GET_ID, 0);
if (ret < 0) {
- PDEBUG(D_ERR, "Get version command failed");
+ PERR("Get version command failed");
return ret;
}
ret = sq905c_read(gspca_dev, 0xf5, 0, 20);
if (ret < 0) {
- PDEBUG(D_ERR, "Reading version command failed");
+ PERR("Reading version command failed");
return ret;
}
/* Note we leave out the usb id and the manufacturing date */
}
if (ret < 0) {
- PDEBUG(D_ERR, "Start streaming command failed");
+ PERR("Start streaming command failed");
return ret;
}
/* Start the workqueue function to do the streaming */
if (gspca_dev->usb_err < 0)
return;
-#ifdef GSPCA_DEBUG
if ((batchsize - 1) * 3 > USB_BUF_SZ) {
- pr_err("Bug: usb_buf overflow\n");
+ PERR("Bug: usb_buf overflow\n");
gspca_dev->usb_err = -ENOMEM;
return;
}
-#endif
for (;;) {
len = ncmds;
static int stv0680_handle_error(struct gspca_dev *gspca_dev, int ret)
{
stv_sndctrl(gspca_dev, 0, 0x80, 0, 0x02); /* Get Last Error */
- PDEBUG(D_ERR, "last error: %i, command = 0x%x",
+ PERR("last error: %i, command = 0x%x",
gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]);
return ret;
}
gspca_dev->usb_buf[0] = 0x0f;
if (stv_sndctrl(gspca_dev, 0, 0x87, 0, 0x08) != 0x08) {
- PDEBUG(D_ERR, "Get_Camera_Mode failed");
+ PERR("Get_Camera_Mode failed");
return stv0680_handle_error(gspca_dev, -EIO);
}
gspca_dev->usb_buf[0] = mode;
if (stv_sndctrl(gspca_dev, 3, 0x07, 0x0100, 0x08) != 0x08) {
- PDEBUG(D_ERR, "Set_Camera_Mode failed");
+ PERR("Set_Camera_Mode failed");
return stv0680_handle_error(gspca_dev, -EIO);
}
/* Verify we got what we've asked for */
if (stv0680_get_video_mode(gspca_dev) != mode) {
- PDEBUG(D_ERR, "Error setting camera video mode!");
+ PERR("Error setting camera video mode!");
return -EIO;
}
/* ping camera to be sure STV0680 is present */
if (stv_sndctrl(gspca_dev, 0, 0x88, 0x5678, 0x02) != 0x02 ||
gspca_dev->usb_buf[0] != 0x56 || gspca_dev->usb_buf[1] != 0x78) {
- PDEBUG(D_ERR, "STV(e): camera ping failed!!");
+ PERR("STV(e): camera ping failed!!");
return stv0680_handle_error(gspca_dev, -ENODEV);
}
if (stv_sndctrl(gspca_dev, 2, 0x06, 0x0200, 0x22) != 0x22 ||
gspca_dev->usb_buf[7] != 0xa0 || gspca_dev->usb_buf[8] != 0x23) {
- PDEBUG(D_ERR, "Could not get descriptor 0200.");
+ PERR("Could not get descriptor 0200.");
return stv0680_handle_error(gspca_dev, -ENODEV);
}
if (stv_sndctrl(gspca_dev, 0, 0x8a, 0, 0x02) != 0x02)
return stv0680_handle_error(gspca_dev, -ENODEV);
if (!(gspca_dev->usb_buf[7] & 0x09)) {
- PDEBUG(D_ERR, "Camera supports neither CIF nor QVGA mode");
+ PERR("Camera supports neither CIF nor QVGA mode");
return -ENODEV;
}
if (gspca_dev->usb_buf[7] & 0x01)
int stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data)
{
int err;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
struct usb_device *udev = sd->gspca_dev.dev;
__u8 *buf = sd->gspca_dev.usb_buf;
+
u8 len = (i2c_data > 0xff) ? 2 : 1;
buf[0] = i2c_data & 0xff;
int stv06xx_read_bridge(struct sd *sd, u16 address, u8 *i2c_data)
{
int err;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
struct usb_device *udev = sd->gspca_dev.dev;
__u8 *buf = sd->gspca_dev.usb_buf;
int stv06xx_write_sensor_bytes(struct sd *sd, const u8 *data, u8 len)
{
int err, i, j;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
struct usb_device *udev = sd->gspca_dev.dev;
__u8 *buf = sd->gspca_dev.usb_buf;
int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len)
{
int err, i, j;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
struct usb_device *udev = sd->gspca_dev.dev;
__u8 *buf = sd->gspca_dev.usb_buf;
int stv06xx_read_sensor(struct sd *sd, const u8 address, u16 *value)
{
int err;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
struct usb_device *udev = sd->gspca_dev.dev;
__u8 *buf = sd->gspca_dev.usb_buf;
intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
if (!alt) {
- PDEBUG(D_ERR, "Couldn't get altsetting");
+ PERR("Couldn't get altsetting");
return -EIO;
}
ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1);
if (ret < 0)
- PDEBUG(D_ERR|D_STREAM, "set alt 1 err %d", ret);
+ PERR("set alt 1 err %d", ret);
return ret;
}
len -= 4;
if (len < chunk_len) {
- PDEBUG(D_ERR, "URB packet length is smaller"
+ PERR("URB packet length is smaller"
" than the specified chunk length");
gspca_dev->last_packet_type = DISCARD_PACKET;
return;
sd->to_skip = gspca_dev->width * 4;
if (chunk_len)
- PDEBUG(D_ERR, "Chunk length is "
+ PERR("Chunk length is "
"non-zero on a SOF");
break;
NULL, 0);
if (chunk_len)
- PDEBUG(D_ERR, "Chunk length is "
+ PERR("Chunk length is "
"non-zero on a EOF");
break;
static int sd_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
- PDEBUG(D_PROBE, "Probing for a stv06xx device");
return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
THIS_MODULE);
}
if (err < 0)
return err;
}
- PDEBUG(D_V4L2, "Writing exposure %d, rowexp %d, srowexp %d",
+ PDEBUG(D_CONF, "Writing exposure %d, rowexp %d, srowexp %d",
val, rowexp, srowexp);
return err;
}
static int hdcs_set_gain(struct gspca_dev *gspca_dev, __s32 val)
{
- PDEBUG(D_V4L2, "Writing gain %d", val);
+ PDEBUG(D_CONF, "Writing gain %d", val);
return hdcs_set_gains((struct sd *) gspca_dev,
val & 0xff);
}
static int hdcs_start(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
+
PDEBUG(D_STREAM, "Starting stream");
return hdcs_set_state(sd, HDCS_STATE_RUN);
static int hdcs_stop(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
+
PDEBUG(D_STREAM, "Halting stream");
return hdcs_set_state(sd, HDCS_STATE_SLEEP);
int err, packet_size, max_packet_size;
struct usb_host_interface *alt;
struct usb_interface *intf;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
struct cam *cam = &sd->gspca_dev.cam;
u32 mode = cam->cam_mode[sd->gspca_dev.curr_mode].priv;
static int pb0100_stop(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int err;
err = stv06xx_write_sensor(sd, PB_ABORTFRAME, 1);
err = stv06xx_write_sensor(sd, PB_G1GAIN, val);
if (!err)
err = stv06xx_write_sensor(sd, PB_G2GAIN, val);
- PDEBUG(D_V4L2, "Set green gain to %d, status: %d", val, err);
+ PDEBUG(D_CONF, "Set green gain to %d, status: %d", val, err);
if (!err)
err = pb0100_set_red_balance(gspca_dev, ctrls->red->val);
val = 255;
err = stv06xx_write_sensor(sd, PB_RGAIN, val);
- PDEBUG(D_V4L2, "Set red gain to %d, status: %d", val, err);
+ PDEBUG(D_CONF, "Set red gain to %d, status: %d", val, err);
return err;
}
val = 255;
err = stv06xx_write_sensor(sd, PB_BGAIN, val);
- PDEBUG(D_V4L2, "Set blue gain to %d, status: %d", val, err);
+ PDEBUG(D_CONF, "Set blue gain to %d, status: %d", val, err);
return err;
}
int err;
err = stv06xx_write_sensor(sd, PB_RINTTIME, val);
- PDEBUG(D_V4L2, "Set exposure to %d, status: %d", val, err);
+ PDEBUG(D_CONF, "Set exposure to %d, status: %d", val, err);
return err;
}
val = 0;
err = stv06xx_write_sensor(sd, PB_EXPGAIN, val);
- PDEBUG(D_V4L2, "Set autogain to %d (natural: %d), status: %d",
+ PDEBUG(D_CONF, "Set autogain to %d (natural: %d), status: %d",
val, ctrls->natural->val, err);
return err;
if (!err)
err = stv06xx_write_sensor(sd, PB_R22, darkpixels);
- PDEBUG(D_V4L2, "Set autogain target to %d, status: %d", val, err);
+ PDEBUG(D_CONF, "Set autogain target to %d, status: %d", val, err);
return err;
}
static int st6422_stop(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
+
PDEBUG(D_STREAM, "Halting stream");
return 0;
static int vv6410_start(struct sd *sd)
{
int err;
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
struct cam *cam = &sd->gspca_dev.cam;
u32 priv = cam->cam_mode[sd->gspca_dev.curr_mode].priv;
static int vv6410_stop(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int err;
/* Turn off LED */
else
i2c_data &= ~VV6410_HFLIP;
- PDEBUG(D_V4L2, "Set horizontal flip to %d", val);
+ PDEBUG(D_CONF, "Set horizontal flip to %d", val);
err = stv06xx_write_sensor(sd, VV6410_DATAFORMAT, i2c_data);
return (err < 0) ? err : 0;
else
i2c_data &= ~VV6410_VFLIP;
- PDEBUG(D_V4L2, "Set vertical flip to %d", val);
+ PDEBUG(D_CONF, "Set vertical flip to %d", val);
err = stv06xx_write_sensor(sd, VV6410_DATAFORMAT, i2c_data);
return (err < 0) ? err : 0;
int err;
struct sd *sd = (struct sd *) gspca_dev;
- PDEBUG(D_V4L2, "Set analog gain to %d", val);
+ PDEBUG(D_CONF, "Set analog gain to %d", val);
err = stv06xx_write_sensor(sd, VV6410_ANALOGGAIN, 0xf0 | (val & 0xf));
return (err < 0) ? err : 0;
fine = val % VV6410_CIF_LINELENGTH;
coarse = min(512, val / VV6410_CIF_LINELENGTH);
- PDEBUG(D_V4L2, "Set coarse exposure to %d, fine expsure to %d",
+ PDEBUG(D_CONF, "Set coarse exposure to %d, fine expsure to %d",
coarse, fine);
err = stv06xx_write_sensor(sd, VV6410_FINEH, fine >> 8);
{
int ret;
-#ifdef GSPCA_DEBUG
if (len > USB_BUF_SZ) {
- pr_err("reg_r: buffer overflow\n");
+ PERR("reg_r: buffer overflow\n");
return;
}
-#endif
if (gspca_dev->usb_err < 0)
return;
ret = usb_control_msg(gspca_dev->dev,
PDEBUG(D_FRAM, "after wait 0x%04x", gspca_dev->usb_buf[0]);
}
-#ifdef GSPCA_DEBUG
static void spca504_read_info(struct gspca_dev *gspca_dev)
{
int i;
u8 info[6];
+ if (gspca_debug < D_STREAM)
+ return;
+
for (i = 0; i < 6; i++) {
reg_r(gspca_dev, 0, i, 1);
info[i] = gspca_dev->usb_buf[0];
info[0], info[1], info[2],
info[3], info[4], info[5]);
}
-#endif
static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
u8 req,
}
}
-#ifdef GSPCA_DEBUG
static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
{
u8 *data;
+ if (gspca_debug < D_STREAM)
+ return;
+
data = gspca_dev->usb_buf;
reg_r(gspca_dev, 0x20, 0, 5);
PDEBUG(D_STREAM, "FirmWare: %d %d %d %d %d",
reg_r(gspca_dev, 0x23, 0, 64);
reg_r(gspca_dev, 0x23, 1, 64);
}
-#endif
static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
{
reg_w_riv(gspca_dev, 0x31, 0, 0);
spca504B_WaitCmdStatus(gspca_dev);
spca504B_PollingDataReady(gspca_dev);
-#ifdef GSPCA_DEBUG
spca50x_GetFirmware(gspca_dev);
-#endif
+
reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */
reg_r(gspca_dev, 0x24, 8, 1);
/* fall thru */
case BRIDGE_SPCA533:
spca504B_PollingDataReady(gspca_dev);
-#ifdef GSPCA_DEBUG
spca50x_GetFirmware(gspca_dev);
-#endif
break;
case BRIDGE_SPCA536:
-#ifdef GSPCA_DEBUG
spca50x_GetFirmware(gspca_dev);
-#endif
reg_r(gspca_dev, 0x00, 0x5002, 1);
reg_w_1(gspca_dev, 0x24, 0, 0, 0);
reg_r(gspca_dev, 0x24, 0, 1);
/* case BRIDGE_SPCA504: */
PDEBUG(D_STREAM, "Opening SPCA504");
if (sd->subtype == AiptekMiniPenCam13) {
-#ifdef GSPCA_DEBUG
spca504_read_info(gspca_dev);
-#endif
/* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
spca504A_acknowledged_command(gspca_dev, 0x24,
break;
case BRIDGE_SPCA504:
if (sd->subtype == AiptekMiniPenCam13) {
-#ifdef GSPCA_DEBUG
spca504_read_info(gspca_dev);
-#endif
/* Set AE AWB Banding Type 3-> 50Hz 2-> 60Hz */
spca504A_acknowledged_command(gspca_dev, 0x24,
0, 0, 0x9d, 1);
} else {
spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
-#ifdef GSPCA_DEBUG
spca504_read_info(gspca_dev);
-#endif
spca504_acknowledged_command(gspca_dev, 0x24, 8, 3);
spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
}
u16 len)
{
reg_r_i(gspca_dev, req, index, len);
-#ifdef GSPCA_DEBUG
if (gspca_dev->usb_err < 0)
return;
if (len == 1)
else
PDEBUG(D_USBI, "GET %02x 0001 %04x %*ph",
req, index, 3, gspca_dev->usb_buf);
-#endif
}
static void reg_w_i(struct gspca_dev *gspca_dev,
u16 value,
u16 index)
{
-#ifdef GSPCA_DEBUG
if (gspca_dev->usb_err < 0)
return;
PDEBUG(D_USBO, "SET %02x %04x %04x", req, value, index);
-#endif
reg_w_i(gspca_dev, req, value, index);
}
if (value == 0 && ptsensor_info->IdAdd == 0x82)
value = read_sensor_register(gspca_dev, 0x83);
if (value != 0) {
- PDEBUG(D_ERR|D_PROBE, "Sensor ID %04x (%d)",
- value, i);
+ PDEBUG(D_PROBE, "Sensor ID %04x (%d)", value, i);
if (value == ptsensor_info->VpId)
return ptsensor_info->sensorId;
{
int retry;
-#ifdef GSPCA_DEBUG
if (gspca_dev->usb_err < 0)
return;
if (size == 1)
PDEBUG(D_USBO, "i2c_w %02x %02x", reg, *val);
else
PDEBUG(D_USBO, "i2c_w %02x %02x%02x", reg, *val, val[1]);
-#endif
reg_r_i(gspca_dev, 0xa1, 0xb33f, 1);
/*fixme:should check if (!(gspca_dev->usb_buf[0] & 0x02)) error*/
reg_w_i(gspca_dev, 0xa0, size, 0xb334);
static void w9968cf_smbus_read_ack(struct sd *sd)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int sda;
/* Ensure SDA is high before raising clock to avoid a spurious stop */
/* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */
static void w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
u16* data = (u16 *)sd->gspca_dev.usb_buf;
data[0] = 0x082f | ((sd->sensor_addr & 0x80) ? 0x1500 : 0x0);
/* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */
static int w9968cf_i2c_r(struct sd *sd, u8 reg)
{
+ struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int ret = 0;
u8 value;
ret = value;
PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value);
} else
- PDEBUG(D_ERR, "i2c read [0x%02x] failed", reg);
+ PERR("i2c read [0x%02x] failed", reg);
return ret;
}
retword |= i2c_read(gspca_dev, 0x01); /* ID 1 */
PDEBUG(D_PROBE, "probe 3wr vga 2 0x%04x", retword);
if (retword == 0x2030) {
-#ifdef GSPCA_DEBUG
u8 retbyte;
retbyte = i2c_read(gspca_dev, 0x02); /* revision number */
PDEBUG(D_PROBE, "sensor PO2030 rev 0x%02x", retbyte);
-#endif
+
send_unknown(gspca_dev, SENSOR_PO2030);
return retword;
}