summaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/gspca/ov519.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/usb/gspca/ov519.c')
-rw-r--r--drivers/media/usb/gspca/ov519.c155
1 files changed, 82 insertions, 73 deletions
diff --git a/drivers/media/usb/gspca/ov519.c b/drivers/media/usb/gspca/ov519.c
index 1b30434b72ef..10fcbe9e8614 100644
--- a/drivers/media/usb/gspca/ov519.c
+++ b/drivers/media/usb/gspca/ov519.c
@@ -2016,8 +2016,8 @@ static void reg_w(struct sd *sd, u16 index, u16 value)
req = 0x0a;
/* fall through */
case BRIDGE_W9968CF:
- PDEBUG(D_USBO, "SET %02x %04x %04x",
- req, value, index);
+ gspca_dbg(gspca_dev, D_USBO, "SET %02x %04x %04x\n",
+ req, value, index);
ret = usb_control_msg(sd->gspca_dev.dev,
usb_sndctrlpipe(sd->gspca_dev.dev, 0),
req,
@@ -2028,8 +2028,8 @@ static void reg_w(struct sd *sd, u16 index, u16 value)
req = 1;
}
- PDEBUG(D_USBO, "SET %02x 0000 %04x %02x",
- req, index, value);
+ gspca_dbg(gspca_dev, D_USBO, "SET %02x 0000 %04x %02x\n",
+ req, index, value);
sd->gspca_dev.usb_buf[0] = value;
ret = usb_control_msg(sd->gspca_dev.dev,
usb_sndctrlpipe(sd->gspca_dev.dev, 0),
@@ -2039,7 +2039,7 @@ static void reg_w(struct sd *sd, u16 index, u16 value)
sd->gspca_dev.usb_buf, 1, 500);
leave:
if (ret < 0) {
- PERR("reg_w %02x failed %d\n", index, ret);
+ gspca_err(gspca_dev, "reg_w %02x failed %d\n", index, ret);
sd->gspca_dev.usb_err = ret;
return;
}
@@ -2078,10 +2078,10 @@ static int reg_r(struct sd *sd, u16 index)
if (ret >= 0) {
ret = sd->gspca_dev.usb_buf[0];
- PDEBUG(D_USBI, "GET %02x 0000 %04x %02x",
- req, index, ret);
+ gspca_dbg(gspca_dev, D_USBI, "GET %02x 0000 %04x %02x\n",
+ req, index, ret);
} else {
- PERR("reg_r %02x failed %d\n", index, ret);
+ gspca_err(gspca_dev, "reg_r %02x failed %d\n", index, ret);
sd->gspca_dev.usb_err = ret;
}
@@ -2109,7 +2109,7 @@ static int reg_r8(struct sd *sd,
if (ret >= 0) {
ret = sd->gspca_dev.usb_buf[0];
} else {
- PERR("reg_r8 %02x failed %d\n", index, ret);
+ gspca_err(gspca_dev, "reg_r8 %02x failed %d\n", index, ret);
sd->gspca_dev.usb_err = ret;
}
@@ -2165,7 +2165,7 @@ static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n)
0, index,
sd->gspca_dev.usb_buf, n, 500);
if (ret < 0) {
- PERR("reg_w32 %02x failed %d\n", index, ret);
+ gspca_err(gspca_dev, "reg_w32 %02x failed %d\n", index, ret);
sd->gspca_dev.usb_err = ret;
}
}
@@ -2175,7 +2175,7 @@ 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);
+ gspca_dbg(gspca_dev, D_USBO, "ov511_i2c_w %02x %02x\n", reg, value);
/* Three byte write cycle */
for (retries = 6; ; ) {
@@ -2198,7 +2198,7 @@ static void ov511_i2c_w(struct sd *sd, u8 reg, u8 value)
if ((rc & 2) == 0) /* Ack? */
break;
if (--retries < 0) {
- PDEBUG(D_USBO, "i2c write retries exhausted");
+ gspca_dbg(gspca_dev, D_USBO, "i2c write retries exhausted\n");
return;
}
}
@@ -2231,7 +2231,7 @@ static int ov511_i2c_r(struct sd *sd, u8 reg)
reg_w(sd, R511_I2C_CTL, 0x10);
if (--retries < 0) {
- PDEBUG(D_USBI, "i2c write retries exhausted");
+ gspca_dbg(gspca_dev, D_USBI, "i2c write retries exhausted\n");
return -1;
}
}
@@ -2255,14 +2255,14 @@ static int ov511_i2c_r(struct sd *sd, u8 reg)
reg_w(sd, R511_I2C_CTL, 0x10);
if (--retries < 0) {
- PDEBUG(D_USBI, "i2c read retries exhausted");
+ gspca_dbg(gspca_dev, D_USBI, "i2c read retries exhausted\n");
return -1;
}
}
value = reg_r(sd, R51x_I2C_DATA);
- PDEBUG(D_USBI, "ov511_i2c_r %02x %02x", reg, value);
+ gspca_dbg(gspca_dev, D_USBI, "ov511_i2c_r %02x %02x\n", reg, value);
/* This is needed to make i2c_w() work */
reg_w(sd, R511_I2C_CTL, 0x05);
@@ -2281,7 +2281,7 @@ static void ov518_i2c_w(struct sd *sd,
{
struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
- PDEBUG(D_USBO, "ov518_i2c_w %02x %02x", reg, value);
+ gspca_dbg(gspca_dev, D_USBO, "ov518_i2c_w %02x %02x\n", reg, value);
/* Select camera register */
reg_w(sd, R51x_I2C_SADDR_3, reg);
@@ -2321,7 +2321,7 @@ static int ov518_i2c_r(struct sd *sd, u8 reg)
reg_r8(sd, R518_I2C_CTL);
value = reg_r(sd, R51x_I2C_DATA);
- PDEBUG(D_USBI, "ov518_i2c_r %02x %02x", reg, value);
+ gspca_dbg(gspca_dev, D_USBI, "ov518_i2c_r %02x %02x\n", reg, value);
return value;
}
@@ -2340,11 +2340,11 @@ static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value)
(u16) value, (u16) reg, NULL, 0, 500);
if (ret < 0) {
- PERR("ovfx2_i2c_w %02x failed %d\n", reg, ret);
+ gspca_err(gspca_dev, "ovfx2_i2c_w %02x failed %d\n", reg, ret);
sd->gspca_dev.usb_err = ret;
}
- PDEBUG(D_USBO, "ovfx2_i2c_w %02x %02x", reg, value);
+ gspca_dbg(gspca_dev, D_USBO, "ovfx2_i2c_w %02x %02x\n", reg, value);
}
static int ovfx2_i2c_r(struct sd *sd, u8 reg)
@@ -2363,9 +2363,10 @@ static int ovfx2_i2c_r(struct sd *sd, u8 reg)
if (ret >= 0) {
ret = sd->gspca_dev.usb_buf[0];
- PDEBUG(D_USBI, "ovfx2_i2c_r %02x %02x", reg, ret);
+ gspca_dbg(gspca_dev, D_USBI, "ovfx2_i2c_r %02x %02x\n",
+ reg, ret);
} else {
- PERR("ovfx2_i2c_r %02x failed %d\n", reg, ret);
+ gspca_err(gspca_dev, "ovfx2_i2c_r %02x failed %d\n", reg, ret);
sd->gspca_dev.usb_err = ret;
}
@@ -2464,7 +2465,7 @@ static inline void ov51x_stop(struct sd *sd)
{
struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
- PDEBUG(D_STREAM, "stopping");
+ gspca_dbg(gspca_dev, D_STREAM, "stopping\n");
sd->stopped = 1;
switch (sd->bridge) {
case BRIDGE_OV511:
@@ -2495,7 +2496,7 @@ static inline void ov51x_restart(struct sd *sd)
{
struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
- PDEBUG(D_STREAM, "restarting");
+ gspca_dbg(gspca_dev, D_STREAM, "restarting\n");
if (!sd->stopped)
return;
sd->stopped = 0;
@@ -2546,7 +2547,8 @@ static int init_ov_sensor(struct sd *sd, u8 slave)
for (i = 0; i < i2c_detect_tries; i++) {
if (i2c_r(sd, OV7610_REG_ID_HIGH) == 0x7f &&
i2c_r(sd, OV7610_REG_ID_LOW) == 0xa2) {
- PDEBUG(D_PROBE, "I2C synced in %d attempt(s)", i);
+ gspca_dbg(gspca_dev, D_PROBE, "I2C synced in %d attempt(s)\n",
+ i);
return 0;
}
@@ -2617,11 +2619,11 @@ static void ov_hires_configure(struct sd *sd)
int high, low;
if (sd->bridge != BRIDGE_OVFX2) {
- PERR("error hires sensors only supported with ovfx2\n");
+ gspca_err(gspca_dev, "error hires sensors only supported with ovfx2\n");
return;
}
- PDEBUG(D_PROBE, "starting ov hires configuration");
+ gspca_dbg(gspca_dev, D_PROBE, "starting ov hires configuration\n");
/* Detect sensor (sub)type */
high = i2c_r(sd, 0x0a);
@@ -2631,28 +2633,29 @@ static void ov_hires_configure(struct sd *sd)
case 0x96:
switch (low) {
case 0x40:
- PDEBUG(D_PROBE, "Sensor is a OV2610");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is a OV2610\n");
sd->sensor = SEN_OV2610;
return;
case 0x41:
- PDEBUG(D_PROBE, "Sensor is a OV2610AE");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is a OV2610AE\n");
sd->sensor = SEN_OV2610AE;
return;
case 0xb1:
- PDEBUG(D_PROBE, "Sensor is a OV9600");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is a OV9600\n");
sd->sensor = SEN_OV9600;
return;
}
break;
case 0x36:
if ((low & 0x0f) == 0x00) {
- PDEBUG(D_PROBE, "Sensor is a OV3610");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is a OV3610\n");
sd->sensor = SEN_OV3610;
return;
}
break;
}
- PERR("Error unknown sensor type: %02x%02x\n", high, low);
+ gspca_err(gspca_dev, "Error unknown sensor type: %02x%02x\n",
+ high, low);
}
/* This initializes the OV8110, OV8610 sensor. The OV8110 uses
@@ -2663,18 +2666,19 @@ static void ov8xx0_configure(struct sd *sd)
struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int rc;
- PDEBUG(D_PROBE, "starting ov8xx0 configuration");
+ gspca_dbg(gspca_dev, D_PROBE, "starting ov8xx0 configuration\n");
/* Detect sensor (sub)type */
rc = i2c_r(sd, OV7610_REG_COM_I);
if (rc < 0) {
- PERR("Error detecting sensor type");
+ gspca_err(gspca_dev, "Error detecting sensor type\n");
return;
}
if ((rc & 3) == 1)
sd->sensor = SEN_OV8610;
else
- PERR("Unknown image sensor version: %d\n", rc & 3);
+ gspca_err(gspca_dev, "Unknown image sensor version: %d\n",
+ rc & 3);
}
/* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses
@@ -2685,7 +2689,7 @@ 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");
+ gspca_dbg(gspca_dev, D_PROBE, "starting OV7xx0 configuration\n");
/* Detect sensor (sub)type */
rc = i2c_r(sd, OV7610_REG_COM_I);
@@ -2693,7 +2697,7 @@ static void ov7xx0_configure(struct sd *sd)
/* add OV7670 here
* it appears to be wrongly detected as a 7610 by default */
if (rc < 0) {
- PERR("Error detecting sensor type\n");
+ gspca_err(gspca_dev, "Error detecting sensor type\n");
return;
}
if ((rc & 3) == 3) {
@@ -2702,65 +2706,68 @@ static void ov7xx0_configure(struct sd *sd)
low = i2c_r(sd, 0x0b);
/* info("%x, %x", high, low); */
if (high == 0x76 && (low & 0xf0) == 0x70) {
- PDEBUG(D_PROBE, "Sensor is an OV76%02x", low);
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV76%02x\n",
+ low);
sd->sensor = SEN_OV7670;
} else {
- PDEBUG(D_PROBE, "Sensor is an OV7610");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7610\n");
sd->sensor = SEN_OV7610;
}
} else if ((rc & 3) == 1) {
/* I don't know what's different about the 76BE yet. */
if (i2c_r(sd, 0x15) & 1) {
- PDEBUG(D_PROBE, "Sensor is an OV7620AE");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7620AE\n");
sd->sensor = SEN_OV7620AE;
} else {
- PDEBUG(D_PROBE, "Sensor is an OV76BE");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV76BE\n");
sd->sensor = SEN_OV76BE;
}
} else if ((rc & 3) == 0) {
/* try to read product id registers */
high = i2c_r(sd, 0x0a);
if (high < 0) {
- PERR("Error detecting camera chip PID\n");
+ gspca_err(gspca_dev, "Error detecting camera chip PID\n");
return;
}
low = i2c_r(sd, 0x0b);
if (low < 0) {
- PERR("Error detecting camera chip VER\n");
+ gspca_err(gspca_dev, "Error detecting camera chip VER\n");
return;
}
if (high == 0x76) {
switch (low) {
case 0x30:
- PERR("Sensor is an OV7630/OV7635\n");
- PERR("7630 is not supported by this driver\n");
+ gspca_err(gspca_dev, "Sensor is an OV7630/OV7635\n");
+ gspca_err(gspca_dev, "7630 is not supported by this driver\n");
return;
case 0x40:
- PDEBUG(D_PROBE, "Sensor is an OV7645");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7645\n");
sd->sensor = SEN_OV7640; /* FIXME */
break;
case 0x45:
- PDEBUG(D_PROBE, "Sensor is an OV7645B");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7645B\n");
sd->sensor = SEN_OV7640; /* FIXME */
break;
case 0x48:
- PDEBUG(D_PROBE, "Sensor is an OV7648");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7648\n");
sd->sensor = SEN_OV7648;
break;
case 0x60:
- PDEBUG(D_PROBE, "Sensor is a OV7660");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is a OV7660\n");
sd->sensor = SEN_OV7660;
break;
default:
- PERR("Unknown sensor: 0x76%02x\n", low);
+ gspca_err(gspca_dev, "Unknown sensor: 0x76%02x\n",
+ low);
return;
}
} else {
- PDEBUG(D_PROBE, "Sensor is an OV7620");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV7620\n");
sd->sensor = SEN_OV7620;
}
} else {
- PERR("Unknown image sensor version: %d\n", rc & 3);
+ gspca_err(gspca_dev, "Unknown image sensor version: %d\n",
+ rc & 3);
}
}
@@ -2770,12 +2777,12 @@ static void ov6xx0_configure(struct sd *sd)
struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
int rc;
- PDEBUG(D_PROBE, "starting OV6xx0 configuration");
+ gspca_dbg(gspca_dev, D_PROBE, "starting OV6xx0 configuration\n");
/* Detect sensor (sub)type */
rc = i2c_r(sd, OV7610_REG_COM_I);
if (rc < 0) {
- PERR("Error detecting sensor type\n");
+ gspca_err(gspca_dev, "Error detecting sensor type\n");
return;
}
@@ -2789,22 +2796,23 @@ static void ov6xx0_configure(struct sd *sd)
break;
case 0x01:
sd->sensor = SEN_OV6620;
- PDEBUG(D_PROBE, "Sensor is an OV6620");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV6620\n");
break;
case 0x02:
sd->sensor = SEN_OV6630;
- PDEBUG(D_PROBE, "Sensor is an OV66308AE");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV66308AE\n");
break;
case 0x03:
sd->sensor = SEN_OV66308AF;
- PDEBUG(D_PROBE, "Sensor is an OV66308AF");
+ gspca_dbg(gspca_dev, D_PROBE, "Sensor is an OV66308AF\n");
break;
case 0x90:
sd->sensor = SEN_OV6630;
pr_warn("WARNING: Sensor is an OV66307. Your camera may have been misdetected in previous driver versions.\n");
break;
default:
- PERR("FATAL: Unknown sensor version: 0x%02x\n", rc);
+ gspca_err(gspca_dev, "FATAL: Unknown sensor version: 0x%02x\n",
+ rc);
return;
}
@@ -2906,7 +2914,7 @@ static void ov51x_upload_quan_tables(struct sd *sd)
unsigned char val0, val1;
int i, size, reg = R51x_COMP_LUT_BEGIN;
- PDEBUG(D_PROBE, "Uploading quantization tables");
+ gspca_dbg(gspca_dev, D_PROBE, "Uploading quantization tables\n");
if (sd->bridge == BRIDGE_OV511 || sd->bridge == BRIDGE_OV511PLUS) {
pYTable = yQuanTable511;
@@ -2984,7 +2992,8 @@ static void ov511_configure(struct gspca_dev *gspca_dev)
{ 0x77, 0x04 },
};
- PDEBUG(D_PROBE, "Device custom id %x", reg_r(sd, R51x_SYS_CUST_ID));
+ gspca_dbg(gspca_dev, D_PROBE, "Device custom id %x\n",
+ reg_r(sd, R51x_SYS_CUST_ID));
write_regvals(sd, init_511, ARRAY_SIZE(init_511));
@@ -3054,7 +3063,7 @@ static void ov518_configure(struct gspca_dev *gspca_dev)
/* First 5 bits of custom ID reg are a revision ID on OV518 */
sd->revision = reg_r(sd, R51x_SYS_CUST_ID) & 0x1f;
- PDEBUG(D_PROBE, "Device revision %d", sd->revision);
+ gspca_dbg(gspca_dev, D_PROBE, "Device revision %d\n", sd->revision);
write_regvals(sd, init_518, ARRAY_SIZE(init_518));
@@ -3295,7 +3304,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
} else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) {
ov_hires_configure(sd);
} else {
- PERR("Can't determine sensor slave IDs\n");
+ gspca_err(gspca_dev, "Can't determine sensor slave IDs\n");
goto error;
}
@@ -3428,7 +3437,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
}
return gspca_dev->usb_err;
error:
- PERR("OV519 Config failed");
+ gspca_err(gspca_dev, "OV519 Config failed\n");
return -EINVAL;
}
@@ -3463,7 +3472,7 @@ static void ov511_mode_init_regs(struct sd *sd)
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) {
- PERR("Couldn't get altsetting\n");
+ gspca_err(gspca_dev, "Couldn't get altsetting\n");
sd->gspca_dev.usb_err = -EIO;
return;
}
@@ -3589,7 +3598,7 @@ static void ov518_mode_init_regs(struct sd *sd)
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) {
- PERR("Couldn't get altsetting\n");
+ gspca_err(gspca_dev, "Couldn't get altsetting\n");
sd->gspca_dev.usb_err = -EIO;
return;
}
@@ -3861,8 +3870,8 @@ static void ov519_mode_init_regs(struct sd *sd)
}
break;
case SEN_OV7670: /* guesses, based on 7640 */
- PDEBUG(D_STREAM, "Setting framerate to %d fps",
- (sd->frame_rate == 0) ? 15 : sd->frame_rate);
+ gspca_dbg(gspca_dev, D_STREAM, "Setting framerate to %d fps\n",
+ (sd->frame_rate == 0) ? 15 : sd->frame_rate);
reg_w(sd, 0xa4, 0x10);
switch (sd->frame_rate) {
case 30:
@@ -4323,10 +4332,10 @@ static void ov511_pkt_scan(struct gspca_dev *gspca_dev,
/* Frame end */
if ((in[9] + 1) * 8 != gspca_dev->pixfmt.width ||
(in[10] + 1) * 8 != gspca_dev->pixfmt.height) {
- PERR("Invalid frame size, got: %dx%d, requested: %dx%d\n",
- (in[9] + 1) * 8, (in[10] + 1) * 8,
- gspca_dev->pixfmt.width,
- gspca_dev->pixfmt.height);
+ gspca_err(gspca_dev, "Invalid frame size, got: %dx%d, requested: %dx%d\n",
+ (in[9] + 1) * 8, (in[10] + 1) * 8,
+ gspca_dev->pixfmt.width,
+ gspca_dev->pixfmt.height);
gspca_dev->last_packet_type = DISCARD_PACKET;
return;
}
@@ -4374,8 +4383,8 @@ static void ov518_pkt_scan(struct gspca_dev *gspca_dev,
except that they may contain part of the footer), are
numbered 0 */
else if (sd->packet_nr == 0 || data[len]) {
- PERR("Invalid packet nr: %d (expect: %d)",
- (int)data[len], (int)sd->packet_nr);
+ gspca_err(gspca_dev, "Invalid packet nr: %d (expect: %d)\n",
+ (int)data[len], (int)sd->packet_nr);
gspca_dev->last_packet_type = DISCARD_PACKET;
return;
}
@@ -4918,7 +4927,7 @@ static int sd_init_controls(struct gspca_dev *gspca_dev)
QUALITY_MIN, QUALITY_MAX, 1, QUALITY_DEF);
if (hdl->error) {
- PERR("Could not initialize controls\n");
+ gspca_err(gspca_dev, "Could not initialize controls\n");
return hdl->error;
}
if (gspca_dev->autogain)