aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorJean-François Moine <moinejf@free.fr>2012-03-19 03:55:16 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-03-19 21:32:35 -0400
commitff38d58ec08e347f01fc380f774cedde6dec4103 (patch)
tree0758b717c9f433a30a26f299e9919c6aeda6d4d7 /drivers/media
parentccbaba430241805076ebd16f90d8456c20bc796a (diff)
[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: Jean-François Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/gspca/sn9c20x.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
index 896cff925fbb..7e71aa2d2522 100644
--- a/drivers/media/video/gspca/sn9c20x.c
+++ b/drivers/media/video/gspca/sn9c20x.c
@@ -1,5 +1,7 @@
1/* 1/*
2 * Sonix sn9c201 sn9c202 library 2 * Sonix sn9c201 sn9c202 library
3 *
4 * Copyright (C) 2012 Jean-Francois Moine <http://moinejf.free.fr>
3 * Copyright (C) 2008-2009 microdia project <microdia@googlegroups.com> 5 * Copyright (C) 2008-2009 microdia project <microdia@googlegroups.com>
4 * Copyright (C) 2009 Brian Johnson <brijohn@gmail.com> 6 * Copyright (C) 2009 Brian Johnson <brijohn@gmail.com>
5 * 7 *
@@ -33,8 +35,6 @@ MODULE_AUTHOR("Brian Johnson <brijohn@gmail.com>, "
33MODULE_DESCRIPTION("GSPCA/SN9C20X USB Camera Driver"); 35MODULE_DESCRIPTION("GSPCA/SN9C20X USB Camera Driver");
34MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
35 37
36#define MODULE_NAME "sn9c20x"
37
38/* 38/*
39 * Pixel format private data 39 * Pixel format private data
40 */ 40 */
@@ -1133,13 +1133,13 @@ static void reg_w(struct gspca_dev *gspca_dev, u16 reg,
1133 1133
1134static void reg_w1(struct gspca_dev *gspca_dev, u16 reg, const u8 value) 1134static void reg_w1(struct gspca_dev *gspca_dev, u16 reg, const u8 value)
1135{ 1135{
1136 u8 data[1] = {value}; 1136 reg_w(gspca_dev, reg, &value, 1);
1137 reg_w(gspca_dev, reg, data, 1);
1138} 1137}
1139 1138
1140static void i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer) 1139static void i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer)
1141{ 1140{
1142 int i; 1141 int i;
1142
1143 reg_w(gspca_dev, 0x10c0, buffer, 8); 1143 reg_w(gspca_dev, 0x10c0, buffer, 8);
1144 for (i = 0; i < 5; i++) { 1144 for (i = 0; i < 5; i++) {
1145 reg_r(gspca_dev, 0x10c0, 1); 1145 reg_r(gspca_dev, 0x10c0, 1);
@@ -1161,7 +1161,6 @@ static void i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer)
1161static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) 1161static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1162{ 1162{
1163 struct sd *sd = (struct sd *) gspca_dev; 1163 struct sd *sd = (struct sd *) gspca_dev;
1164
1165 u8 row[8]; 1164 u8 row[8];
1166 1165
1167 /* 1166 /*
@@ -1201,8 +1200,8 @@ static void i2c_w2(struct gspca_dev *gspca_dev, u8 reg, u16 val)
1201 row[0] = 0x81 | (3 << 4); 1200 row[0] = 0x81 | (3 << 4);
1202 row[1] = sd->i2c_addr; 1201 row[1] = sd->i2c_addr;
1203 row[2] = reg; 1202 row[2] = reg;
1204 row[3] = (val >> 8) & 0xff; 1203 row[3] = val >> 8;
1205 row[4] = val & 0xff; 1204 row[4] = val;
1206 row[5] = 0x00; 1205 row[5] = 0x00;
1207 row[6] = 0x00; 1206 row[6] = 0x00;
1208 row[7] = 0x10; 1207 row[7] = 0x10;
@@ -1587,8 +1586,9 @@ static void set_hvflip(struct gspca_dev *gspca_dev)
1587 if (vflip) { 1586 if (vflip) {
1588 value |= 0x10; 1587 value |= 0x10;
1589 sd->vstart = 2; 1588 sd->vstart = 2;
1590 } else 1589 } else {
1591 sd->vstart = 3; 1590 sd->vstart = 3;
1591 }
1592 reg_w1(gspca_dev, 0x1182, sd->vstart); 1592 reg_w1(gspca_dev, 0x1182, sd->vstart);
1593 i2c_w1(gspca_dev, 0x1e, value); 1593 i2c_w1(gspca_dev, 0x1e, value);
1594 break; 1594 break;
@@ -1741,6 +1741,7 @@ static int sd_dbg_g_register(struct gspca_dev *gspca_dev,
1741 struct v4l2_dbg_register *reg) 1741 struct v4l2_dbg_register *reg)
1742{ 1742{
1743 struct sd *sd = (struct sd *) gspca_dev; 1743 struct sd *sd = (struct sd *) gspca_dev;
1744
1744 switch (reg->match.type) { 1745 switch (reg->match.type) {
1745 case V4L2_CHIP_MATCH_HOST: 1746 case V4L2_CHIP_MATCH_HOST:
1746 if (reg->match.addr != 0) 1747 if (reg->match.addr != 0)
@@ -1768,6 +1769,7 @@ static int sd_dbg_s_register(struct gspca_dev *gspca_dev,
1768 struct v4l2_dbg_register *reg) 1769 struct v4l2_dbg_register *reg)
1769{ 1770{
1770 struct sd *sd = (struct sd *) gspca_dev; 1771 struct sd *sd = (struct sd *) gspca_dev;
1772
1771 switch (reg->match.type) { 1773 switch (reg->match.type) {
1772 case V4L2_CHIP_MATCH_HOST: 1774 case V4L2_CHIP_MATCH_HOST:
1773 if (reg->match.addr != 0) 1775 if (reg->match.addr != 0)
@@ -1822,9 +1824,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
1822 cam = &gspca_dev->cam; 1824 cam = &gspca_dev->cam;
1823 cam->needs_full_bandwidth = 1; 1825 cam->needs_full_bandwidth = 1;
1824 1826
1825 sd->sensor = (id->driver_info >> 8) & 0xff; 1827 sd->sensor = id->driver_info >> 8;
1826 sd->i2c_addr = id->driver_info & 0xff; 1828 sd->i2c_addr = id->driver_info;
1827 sd->flags = (id->driver_info >> 16) & 0xff; 1829 sd->flags = id->driver_info >> 16;
1828 1830
1829 switch (sd->sensor) { 1831 switch (sd->sensor) {
1830 case SENSOR_MT9M112: 1832 case SENSOR_MT9M112:
@@ -1918,6 +1920,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
1918 mt9v_init_sensor(gspca_dev); 1920 mt9v_init_sensor(gspca_dev);
1919 if (gspca_dev->usb_err < 0) 1921 if (gspca_dev->usb_err < 0)
1920 break; 1922 break;
1923 pr_info("MT9VPRB sensor detected\n");
1921 break; 1924 break;
1922 case SENSOR_MT9M111: 1925 case SENSOR_MT9M111:
1923 mt9m111_init_sensor(gspca_dev); 1926 mt9m111_init_sensor(gspca_dev);
@@ -1943,7 +1946,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
1943 pr_info("HV7131R sensor detected\n"); 1946 pr_info("HV7131R sensor detected\n");
1944 break; 1947 break;
1945 default: 1948 default:
1946 pr_info("Unsupported Sensor\n"); 1949 pr_err("Unsupported sensor\n");
1947 gspca_dev->usb_err = -ENODEV; 1950 gspca_dev->usb_err = -ENODEV;
1948 } 1951 }
1949 1952
@@ -1954,6 +1957,7 @@ static void configure_sensor_output(struct gspca_dev *gspca_dev, int mode)
1954{ 1957{
1955 struct sd *sd = (struct sd *) gspca_dev; 1958 struct sd *sd = (struct sd *) gspca_dev;
1956 u8 value; 1959 u8 value;
1960
1957 switch (sd->sensor) { 1961 switch (sd->sensor) {
1958 case SENSOR_SOI968: 1962 case SENSOR_SOI968:
1959 if (mode & MODE_SXGA) { 1963 if (mode & MODE_SXGA) {
@@ -2036,6 +2040,7 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev)
2036 break; 2040 break;
2037 default: /* >= 640x480 */ 2041 default: /* >= 640x480 */
2038 gspca_dev->alt = 9; 2042 gspca_dev->alt = 9;
2043 break;
2039 } 2044 }
2040 } 2045 }
2041 2046
@@ -2242,15 +2247,15 @@ static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2242 int len) /* interrupt packet length */ 2247 int len) /* interrupt packet length */
2243{ 2248{
2244 struct sd *sd = (struct sd *) gspca_dev; 2249 struct sd *sd = (struct sd *) gspca_dev;
2245 int ret = -EINVAL; 2250
2246 if (!(sd->flags & HAS_NO_BUTTON) && len == 1) { 2251 if (!(sd->flags & HAS_NO_BUTTON) && len == 1) {
2247 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); 2252 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2248 input_sync(gspca_dev->input_dev); 2253 input_sync(gspca_dev->input_dev);
2249 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); 2254 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2250 input_sync(gspca_dev->input_dev); 2255 input_sync(gspca_dev->input_dev);
2251 ret = 0; 2256 return 0;
2252 } 2257 }
2253 return ret; 2258 return -EINVAL;
2254} 2259}
2255#endif 2260#endif
2256 2261
@@ -2303,9 +2308,11 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2303 int len) /* iso packet length */ 2308 int len) /* iso packet length */
2304{ 2309{
2305 struct sd *sd = (struct sd *) gspca_dev; 2310 struct sd *sd = (struct sd *) gspca_dev;
2306 int avg_lum; 2311 int avg_lum, is_jpeg;
2307 static u8 frame_header[] = 2312 static u8 frame_header[] =
2308 {0xff, 0xff, 0x00, 0xc4, 0xc4, 0x96}; 2313 {0xff, 0xff, 0x00, 0xc4, 0xc4, 0x96};
2314
2315 is_jpeg = (sd->fmt & 0x03) == 0;
2309 if (len >= 64 && memcmp(data, frame_header, 6) == 0) { 2316 if (len >= 64 && memcmp(data, frame_header, 6) == 0) {
2310 avg_lum = ((data[35] >> 2) & 3) | 2317 avg_lum = ((data[35] >> 2) & 3) |
2311 (data[20] << 2) | 2318 (data[20] << 2) |
@@ -2334,8 +2341,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2334 avg_lum >>= 9; 2341 avg_lum >>= 9;
2335 atomic_set(&sd->avg_lum, avg_lum); 2342 atomic_set(&sd->avg_lum, avg_lum);
2336 2343
2337 if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv 2344 if (is_jpeg)
2338 & MODE_JPEG)
2339 transfer_check(gspca_dev, data); 2345 transfer_check(gspca_dev, data);
2340 2346
2341 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); 2347 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
@@ -2345,8 +2351,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2345 data += 64; 2351 data += 64;
2346 } 2352 }
2347 if (gspca_dev->last_packet_type == LAST_PACKET) { 2353 if (gspca_dev->last_packet_type == LAST_PACKET) {
2348 if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv 2354 if (is_jpeg) {
2349 & MODE_JPEG) {
2350 gspca_frame_add(gspca_dev, FIRST_PACKET, 2355 gspca_frame_add(gspca_dev, FIRST_PACKET,
2351 sd->jpeg_hdr, JPEG_HDR_SZ); 2356 sd->jpeg_hdr, JPEG_HDR_SZ);
2352 gspca_frame_add(gspca_dev, INTER_PACKET, 2357 gspca_frame_add(gspca_dev, INTER_PACKET,
@@ -2357,8 +2362,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2357 } 2362 }
2358 } else { 2363 } else {
2359 /* if JPEG, count the packets and their size */ 2364 /* if JPEG, count the packets and their size */
2360 if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv 2365 if (is_jpeg) {
2361 & MODE_JPEG) {
2362 sd->npkt++; 2366 sd->npkt++;
2363 sd->pktsz += len; 2367 sd->pktsz += len;
2364 } 2368 }
@@ -2368,7 +2372,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2368 2372
2369/* sub-driver description */ 2373/* sub-driver description */
2370static const struct sd_desc sd_desc = { 2374static const struct sd_desc sd_desc = {
2371 .name = MODULE_NAME, 2375 .name = KBUILD_MODNAME,
2372 .ctrls = sd_ctrls, 2376 .ctrls = sd_ctrls,
2373 .nctrls = ARRAY_SIZE(sd_ctrls), 2377 .nctrls = ARRAY_SIZE(sd_ctrls),
2374 .config = sd_config, 2378 .config = sd_config,
@@ -2445,7 +2449,7 @@ static int sd_probe(struct usb_interface *intf,
2445} 2449}
2446 2450
2447static struct usb_driver sd_driver = { 2451static struct usb_driver sd_driver = {
2448 .name = MODULE_NAME, 2452 .name = KBUILD_MODNAME,
2449 .id_table = device_table, 2453 .id_table = device_table,
2450 .probe = sd_probe, 2454 .probe = sd_probe,
2451 .disconnect = gspca_disconnect, 2455 .disconnect = gspca_disconnect,