Commit ff38d58e authored by Jean-François Moine's avatar Jean-François Moine Committed by Mauro Carvalho Chehab

[media] gspca - sn9c20x: Cleanup source

- copyright change
- use the kbuild module name for messages
- remove useless code
- add/remove blank lines, parenthesis, braces
- add/change some information messages
Signed-off-by: default avatarJean-François Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent ccbaba43
/* /*
* Sonix sn9c201 sn9c202 library * Sonix sn9c201 sn9c202 library
*
* Copyright (C) 2012 Jean-Francois Moine <http://moinejf.free.fr>
* Copyright (C) 2008-2009 microdia project <microdia@googlegroups.com> * Copyright (C) 2008-2009 microdia project <microdia@googlegroups.com>
* Copyright (C) 2009 Brian Johnson <brijohn@gmail.com> * Copyright (C) 2009 Brian Johnson <brijohn@gmail.com>
* *
...@@ -33,8 +35,6 @@ MODULE_AUTHOR("Brian Johnson <brijohn@gmail.com>, " ...@@ -33,8 +35,6 @@ MODULE_AUTHOR("Brian Johnson <brijohn@gmail.com>, "
MODULE_DESCRIPTION("GSPCA/SN9C20X USB Camera Driver"); MODULE_DESCRIPTION("GSPCA/SN9C20X USB Camera Driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
#define MODULE_NAME "sn9c20x"
/* /*
* Pixel format private data * Pixel format private data
*/ */
...@@ -1133,13 +1133,13 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 reg, ...@@ -1133,13 +1133,13 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 reg,
static void reg_w1(struct gspca_dev *gspca_dev, u16 reg, const u8 value) static void reg_w1(struct gspca_dev *gspca_dev, u16 reg, const u8 value)
{ {
u8 data[1] = {value}; reg_w(gspca_dev, reg, &value, 1);
reg_w(gspca_dev, reg, data, 1);
} }
static void i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer) static void i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer)
{ {
int i; int i;
reg_w(gspca_dev, 0x10c0, buffer, 8); reg_w(gspca_dev, 0x10c0, buffer, 8);
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
reg_r(gspca_dev, 0x10c0, 1); reg_r(gspca_dev, 0x10c0, 1);
...@@ -1161,7 +1161,6 @@ static void i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer) ...@@ -1161,7 +1161,6 @@ static void i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer)
static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
{ {
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
u8 row[8]; u8 row[8];
/* /*
...@@ -1201,8 +1200,8 @@ static void i2c_w2(struct gspca_dev *gspca_dev, u8 reg, u16 val) ...@@ -1201,8 +1200,8 @@ static void i2c_w2(struct gspca_dev *gspca_dev, u8 reg, u16 val)
row[0] = 0x81 | (3 << 4); row[0] = 0x81 | (3 << 4);
row[1] = sd->i2c_addr; row[1] = sd->i2c_addr;
row[2] = reg; row[2] = reg;
row[3] = (val >> 8) & 0xff; row[3] = val >> 8;
row[4] = val & 0xff; row[4] = val;
row[5] = 0x00; row[5] = 0x00;
row[6] = 0x00; row[6] = 0x00;
row[7] = 0x10; row[7] = 0x10;
...@@ -1587,8 +1586,9 @@ static void set_hvflip(struct gspca_dev *gspca_dev) ...@@ -1587,8 +1586,9 @@ static void set_hvflip(struct gspca_dev *gspca_dev)
if (vflip) { if (vflip) {
value |= 0x10; value |= 0x10;
sd->vstart = 2; sd->vstart = 2;
} else } else {
sd->vstart = 3; sd->vstart = 3;
}
reg_w1(gspca_dev, 0x1182, sd->vstart); reg_w1(gspca_dev, 0x1182, sd->vstart);
i2c_w1(gspca_dev, 0x1e, value); i2c_w1(gspca_dev, 0x1e, value);
break; break;
...@@ -1741,6 +1741,7 @@ static int sd_dbg_g_register(struct gspca_dev *gspca_dev, ...@@ -1741,6 +1741,7 @@ static int sd_dbg_g_register(struct gspca_dev *gspca_dev,
struct v4l2_dbg_register *reg) struct v4l2_dbg_register *reg)
{ {
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
switch (reg->match.type) { switch (reg->match.type) {
case V4L2_CHIP_MATCH_HOST: case V4L2_CHIP_MATCH_HOST:
if (reg->match.addr != 0) if (reg->match.addr != 0)
...@@ -1768,6 +1769,7 @@ static int sd_dbg_s_register(struct gspca_dev *gspca_dev, ...@@ -1768,6 +1769,7 @@ static int sd_dbg_s_register(struct gspca_dev *gspca_dev,
struct v4l2_dbg_register *reg) struct v4l2_dbg_register *reg)
{ {
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
switch (reg->match.type) { switch (reg->match.type) {
case V4L2_CHIP_MATCH_HOST: case V4L2_CHIP_MATCH_HOST:
if (reg->match.addr != 0) if (reg->match.addr != 0)
...@@ -1822,9 +1824,9 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -1822,9 +1824,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam = &gspca_dev->cam; cam = &gspca_dev->cam;
cam->needs_full_bandwidth = 1; cam->needs_full_bandwidth = 1;
sd->sensor = (id->driver_info >> 8) & 0xff; sd->sensor = id->driver_info >> 8;
sd->i2c_addr = id->driver_info & 0xff; sd->i2c_addr = id->driver_info;
sd->flags = (id->driver_info >> 16) & 0xff; sd->flags = id->driver_info >> 16;
switch (sd->sensor) { switch (sd->sensor) {
case SENSOR_MT9M112: case SENSOR_MT9M112:
...@@ -1918,6 +1920,7 @@ static int sd_init(struct gspca_dev *gspca_dev) ...@@ -1918,6 +1920,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
mt9v_init_sensor(gspca_dev); mt9v_init_sensor(gspca_dev);
if (gspca_dev->usb_err < 0) if (gspca_dev->usb_err < 0)
break; break;
pr_info("MT9VPRB sensor detected\n");
break; break;
case SENSOR_MT9M111: case SENSOR_MT9M111:
mt9m111_init_sensor(gspca_dev); mt9m111_init_sensor(gspca_dev);
...@@ -1943,7 +1946,7 @@ static int sd_init(struct gspca_dev *gspca_dev) ...@@ -1943,7 +1946,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
pr_info("HV7131R sensor detected\n"); pr_info("HV7131R sensor detected\n");
break; break;
default: default:
pr_info("Unsupported Sensor\n"); pr_err("Unsupported sensor\n");
gspca_dev->usb_err = -ENODEV; gspca_dev->usb_err = -ENODEV;
} }
...@@ -1954,6 +1957,7 @@ static void configure_sensor_output(struct gspca_dev *gspca_dev, int mode) ...@@ -1954,6 +1957,7 @@ static void configure_sensor_output(struct gspca_dev *gspca_dev, int mode)
{ {
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
u8 value; u8 value;
switch (sd->sensor) { switch (sd->sensor) {
case SENSOR_SOI968: case SENSOR_SOI968:
if (mode & MODE_SXGA) { if (mode & MODE_SXGA) {
...@@ -2036,6 +2040,7 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev) ...@@ -2036,6 +2040,7 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev)
break; break;
default: /* >= 640x480 */ default: /* >= 640x480 */
gspca_dev->alt = 9; gspca_dev->alt = 9;
break;
} }
} }
...@@ -2242,15 +2247,15 @@ static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -2242,15 +2247,15 @@ static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
int len) /* interrupt packet length */ int len) /* interrupt packet length */
{ {
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
int ret = -EINVAL;
if (!(sd->flags & HAS_NO_BUTTON) && len == 1) { if (!(sd->flags & HAS_NO_BUTTON) && len == 1) {
input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
input_sync(gspca_dev->input_dev); input_sync(gspca_dev->input_dev);
input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
input_sync(gspca_dev->input_dev); input_sync(gspca_dev->input_dev);
ret = 0; return 0;
} }
return ret; return -EINVAL;
} }
#endif #endif
...@@ -2303,9 +2308,11 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -2303,9 +2308,11 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
int len) /* iso packet length */ int len) /* iso packet length */
{ {
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
int avg_lum; int avg_lum, is_jpeg;
static u8 frame_header[] = static u8 frame_header[] =
{0xff, 0xff, 0x00, 0xc4, 0xc4, 0x96}; {0xff, 0xff, 0x00, 0xc4, 0xc4, 0x96};
is_jpeg = (sd->fmt & 0x03) == 0;
if (len >= 64 && memcmp(data, frame_header, 6) == 0) { if (len >= 64 && memcmp(data, frame_header, 6) == 0) {
avg_lum = ((data[35] >> 2) & 3) | avg_lum = ((data[35] >> 2) & 3) |
(data[20] << 2) | (data[20] << 2) |
...@@ -2334,8 +2341,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -2334,8 +2341,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
avg_lum >>= 9; avg_lum >>= 9;
atomic_set(&sd->avg_lum, avg_lum); atomic_set(&sd->avg_lum, avg_lum);
if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv if (is_jpeg)
& MODE_JPEG)
transfer_check(gspca_dev, data); transfer_check(gspca_dev, data);
gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
...@@ -2345,8 +2351,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -2345,8 +2351,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
data += 64; data += 64;
} }
if (gspca_dev->last_packet_type == LAST_PACKET) { if (gspca_dev->last_packet_type == LAST_PACKET) {
if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv if (is_jpeg) {
& MODE_JPEG) {
gspca_frame_add(gspca_dev, FIRST_PACKET, gspca_frame_add(gspca_dev, FIRST_PACKET,
sd->jpeg_hdr, JPEG_HDR_SZ); sd->jpeg_hdr, JPEG_HDR_SZ);
gspca_frame_add(gspca_dev, INTER_PACKET, gspca_frame_add(gspca_dev, INTER_PACKET,
...@@ -2357,8 +2362,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -2357,8 +2362,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
} }
} else { } else {
/* if JPEG, count the packets and their size */ /* if JPEG, count the packets and their size */
if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv if (is_jpeg) {
& MODE_JPEG) {
sd->npkt++; sd->npkt++;
sd->pktsz += len; sd->pktsz += len;
} }
...@@ -2368,7 +2372,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -2368,7 +2372,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
/* sub-driver description */ /* sub-driver description */
static const struct sd_desc sd_desc = { static const struct sd_desc sd_desc = {
.name = MODULE_NAME, .name = KBUILD_MODNAME,
.ctrls = sd_ctrls, .ctrls = sd_ctrls,
.nctrls = ARRAY_SIZE(sd_ctrls), .nctrls = ARRAY_SIZE(sd_ctrls),
.config = sd_config, .config = sd_config,
...@@ -2445,7 +2449,7 @@ static int sd_probe(struct usb_interface *intf, ...@@ -2445,7 +2449,7 @@ static int sd_probe(struct usb_interface *intf,
} }
static struct usb_driver sd_driver = { static struct usb_driver sd_driver = {
.name = MODULE_NAME, .name = KBUILD_MODNAME,
.id_table = device_table, .id_table = device_table,
.probe = sd_probe, .probe = sd_probe,
.disconnect = gspca_disconnect, .disconnect = gspca_disconnect,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment