aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/m5602
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/m5602')
-rw-r--r--drivers/media/video/gspca/m5602/m5602_bridge.h29
-rw-r--r--drivers/media/video/gspca/m5602/m5602_core.c46
-rw-r--r--drivers/media/video/gspca/m5602/m5602_mt9m111.c18
-rw-r--r--drivers/media/video/gspca/m5602/m5602_mt9m111.h7
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov9650.c40
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov9650.h3
-rw-r--r--drivers/media/video/gspca/m5602/m5602_po1030.c90
-rw-r--r--drivers/media/video/gspca/m5602/m5602_po1030.h46
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k4aa.c22
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k4aa.h3
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k83a.c6
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k83a.h4
-rw-r--r--drivers/media/video/gspca/m5602/m5602_sensor.h2
13 files changed, 187 insertions, 129 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_bridge.h b/drivers/media/video/gspca/m5602/m5602_bridge.h
index c786d7d3d44a..1a37ae4bc82d 100644
--- a/drivers/media/video/gspca/m5602/m5602_bridge.h
+++ b/drivers/media/video/gspca/m5602/m5602_bridge.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * USB Driver for ALi m5602 based webcams 2 * USB Driver for ALi m5602 based webcams
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -25,33 +25,6 @@
25 25
26/*****************************************************************************/ 26/*****************************************************************************/
27 27
28#undef PDEBUG
29#undef info
30#undef err
31
32#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \
33 format "\n" , ## arg)
34#define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \
35 format "\n" , ## arg)
36
37/* Debug parameters */
38#define DBG_INIT 0x1
39#define DBG_PROBE 0x2
40#define DBG_V4L2 0x4
41#define DBG_TRACE 0x8
42#define DBG_DATA 0x10
43#define DBG_V4L2_CID 0x20
44#define DBG_GSPCA 0x40
45
46#define PDEBUG(level, fmt, args...) \
47 do { \
48 if (m5602_debug & level) \
49 info("[%s:%d] " fmt, __func__, __LINE__ , \
50 ## args); \
51 } while (0)
52
53/*****************************************************************************/
54
55#define M5602_XB_SENSOR_TYPE 0x00 28#define M5602_XB_SENSOR_TYPE 0x00
56#define M5602_XB_SENSOR_CTRL 0x01 29#define M5602_XB_SENSOR_CTRL 0x01
57#define M5602_XB_LINE_OF_FRAME_H 0x02 30#define M5602_XB_LINE_OF_FRAME_H 0x02
diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c
index 19d5e351ccc1..fd6ce384b487 100644
--- a/drivers/media/video/gspca/m5602/m5602_core.c
+++ b/drivers/media/video/gspca/m5602/m5602_core.c
@@ -1,7 +1,7 @@
1/* 1 /*
2 * USB Driver for ALi m5602 based webcams 2 * USB Driver for ALi m5602 based webcams
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -26,7 +26,6 @@
26int force_sensor; 26int force_sensor;
27int dump_bridge; 27int dump_bridge;
28int dump_sensor; 28int dump_sensor;
29unsigned int m5602_debug;
30 29
31static const __devinitdata struct usb_device_id m5602_table[] = { 30static const __devinitdata struct usb_device_id m5602_table[] = {
32 {USB_DEVICE(0x0402, 0x5602)}, 31 {USB_DEVICE(0x0402, 0x5602)},
@@ -48,7 +47,7 @@ int m5602_read_bridge(struct sd *sd, u8 address, u8 *i2c_data)
48 1, M5602_URB_MSG_TIMEOUT); 47 1, M5602_URB_MSG_TIMEOUT);
49 *i2c_data = buf[0]; 48 *i2c_data = buf[0];
50 49
51 PDEBUG(DBG_TRACE, "Reading bridge register 0x%x containing 0x%x", 50 PDEBUG(D_CONF, "Reading bridge register 0x%x containing 0x%x",
52 address, *i2c_data); 51 address, *i2c_data);
53 52
54 /* usb_control_msg(...) returns the number of bytes sent upon success, 53 /* usb_control_msg(...) returns the number of bytes sent upon success,
@@ -63,7 +62,7 @@ int m5602_write_bridge(struct sd *sd, u8 address, u8 i2c_data)
63 struct usb_device *udev = sd->gspca_dev.dev; 62 struct usb_device *udev = sd->gspca_dev.dev;
64 __u8 *buf = sd->gspca_dev.usb_buf; 63 __u8 *buf = sd->gspca_dev.usb_buf;
65 64
66 PDEBUG(DBG_TRACE, "Writing bridge register 0x%x with 0x%x", 65 PDEBUG(D_CONF, "Writing bridge register 0x%x with 0x%x",
67 address, i2c_data); 66 address, i2c_data);
68 67
69 memcpy(buf, bridge_urb_skeleton, 68 memcpy(buf, bridge_urb_skeleton,
@@ -91,7 +90,8 @@ static void m5602_dump_bridge(struct sd *sd)
91 m5602_read_bridge(sd, i, &val); 90 m5602_read_bridge(sd, i, &val);
92 info("ALi m5602 address 0x%x contains 0x%x", i, val); 91 info("ALi m5602 address 0x%x contains 0x%x", i, val);
93 } 92 }
94 info("Warning: The camera probably won't work until it's power cycled"); 93 info("Warning: The ALi m5602 webcam probably won't work "
94 "until it's power cycled");
95} 95}
96 96
97static int m5602_probe_sensor(struct sd *sd) 97static int m5602_probe_sensor(struct sd *sd)
@@ -135,7 +135,7 @@ static int m5602_init(struct gspca_dev *gspca_dev)
135 struct sd *sd = (struct sd *) gspca_dev; 135 struct sd *sd = (struct sd *) gspca_dev;
136 int err; 136 int err;
137 137
138 PDEBUG(DBG_TRACE, "Initializing ALi m5602 webcam"); 138 PDEBUG(D_CONF, "Initializing ALi m5602 webcam");
139 /* Run the init sequence */ 139 /* Run the init sequence */
140 err = sd->sensor->init(sd); 140 err = sd->sensor->init(sd);
141 141
@@ -146,16 +146,18 @@ static int m5602_start_transfer(struct gspca_dev *gspca_dev)
146{ 146{
147 struct sd *sd = (struct sd *) gspca_dev; 147 struct sd *sd = (struct sd *) gspca_dev;
148 __u8 *buf = sd->gspca_dev.usb_buf; 148 __u8 *buf = sd->gspca_dev.usb_buf;
149 int err;
149 150
150 /* Send start command to the camera */ 151 /* Send start command to the camera */
151 const u8 buffer[4] = {0x13, 0xf9, 0x0f, 0x01}; 152 const u8 buffer[4] = {0x13, 0xf9, 0x0f, 0x01};
152 memcpy(buf, buffer, sizeof(buffer)); 153 memcpy(buf, buffer, sizeof(buffer));
153 usb_control_msg(gspca_dev->dev, usb_sndctrlpipe(gspca_dev->dev, 0), 154 err = usb_control_msg(gspca_dev->dev,
154 0x04, 0x40, 0x19, 0x0000, buf, 155 usb_sndctrlpipe(gspca_dev->dev, 0),
155 4, M5602_URB_MSG_TIMEOUT); 156 0x04, 0x40, 0x19, 0x0000, buf,
157 4, M5602_URB_MSG_TIMEOUT);
156 158
157 PDEBUG(DBG_V4L2, "Transfer started"); 159 PDEBUG(D_STREAM, "Transfer started");
158 return 0; 160 return (err < 0) ? err : 0;
159} 161}
160 162
161static void m5602_urb_complete(struct gspca_dev *gspca_dev, 163static void m5602_urb_complete(struct gspca_dev *gspca_dev,
@@ -165,14 +167,14 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev,
165 struct sd *sd = (struct sd *) gspca_dev; 167 struct sd *sd = (struct sd *) gspca_dev;
166 168
167 if (len < 6) { 169 if (len < 6) {
168 PDEBUG(DBG_DATA, "Packet is less than 6 bytes"); 170 PDEBUG(D_PACK, "Packet is less than 6 bytes");
169 return; 171 return;
170 } 172 }
171 173
172 /* Frame delimiter: ff xx xx xx ff ff */ 174 /* Frame delimiter: ff xx xx xx ff ff */
173 if (data[0] == 0xff && data[4] == 0xff && data[5] == 0xff && 175 if (data[0] == 0xff && data[4] == 0xff && data[5] == 0xff &&
174 data[2] != sd->frame_id) { 176 data[2] != sd->frame_id) {
175 PDEBUG(DBG_DATA, "Frame delimiter detected"); 177 PDEBUG(D_FRAM, "Frame delimiter detected");
176 sd->frame_id = data[2]; 178 sd->frame_id = data[2];
177 179
178 /* Remove the extra fluff appended on each header */ 180 /* Remove the extra fluff appended on each header */
@@ -187,7 +189,7 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev,
187 /* Create a new frame */ 189 /* Create a new frame */
188 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); 190 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len);
189 191
190 PDEBUG(DBG_V4L2, "Starting new frame %d", 192 PDEBUG(D_FRAM, "Starting new frame %d",
191 sd->frame_count); 193 sd->frame_count);
192 194
193 } else { 195 } else {
@@ -198,7 +200,7 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev,
198 len -= 4; 200 len -= 4;
199 201
200 if (cur_frame_len + len <= frame->v4l2_buf.length) { 202 if (cur_frame_len + len <= frame->v4l2_buf.length) {
201 PDEBUG(DBG_DATA, "Continuing frame %d copying %d bytes", 203 PDEBUG(D_FRAM, "Continuing frame %d copying %d bytes",
202 sd->frame_count, len); 204 sd->frame_count, len);
203 205
204 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 206 gspca_frame_add(gspca_dev, INTER_PACKET, frame,
@@ -234,8 +236,6 @@ static int m5602_configure(struct gspca_dev *gspca_dev,
234 struct cam *cam; 236 struct cam *cam;
235 int err; 237 int err;
236 238
237 PDEBUG(DBG_GSPCA, "m5602_configure start");
238
239 cam = &gspca_dev->cam; 239 cam = &gspca_dev->cam;
240 cam->epaddr = M5602_ISOC_ENDPOINT_ADDR; 240 cam->epaddr = M5602_ISOC_ENDPOINT_ADDR;
241 sd->desc = &sd_desc; 241 sd->desc = &sd_desc;
@@ -248,11 +248,10 @@ static int m5602_configure(struct gspca_dev *gspca_dev,
248 if (err) 248 if (err)
249 goto fail; 249 goto fail;
250 250
251 PDEBUG(DBG_GSPCA, "m5602_configure end");
252 return 0; 251 return 0;
253 252
254fail: 253fail:
255 PDEBUG(DBG_GSPCA, "m5602_configure failed"); 254 PDEBUG(D_ERR, "ALi m5602 webcam failed");
256 cam->cam_mode = NULL; 255 cam->cam_mode = NULL;
257 cam->nmodes = 0; 256 cam->nmodes = 0;
258 257
@@ -282,13 +281,13 @@ static int __init mod_m5602_init(void)
282{ 281{
283 if (usb_register(&sd_driver) < 0) 282 if (usb_register(&sd_driver) < 0)
284 return -1; 283 return -1;
285 PDEBUG(D_PROBE, "m5602 module registered"); 284 PDEBUG(D_PROBE, "registered");
286 return 0; 285 return 0;
287} 286}
288static void __exit mod_m5602_exit(void) 287static void __exit mod_m5602_exit(void)
289{ 288{
290 usb_deregister(&sd_driver); 289 usb_deregister(&sd_driver);
291 PDEBUG(D_PROBE, "m5602 module deregistered"); 290 PDEBUG(D_PROBE, "deregistered");
292} 291}
293 292
294module_init(mod_m5602_init); 293module_init(mod_m5602_init);
@@ -297,9 +296,6 @@ module_exit(mod_m5602_exit);
297MODULE_AUTHOR(DRIVER_AUTHOR); 296MODULE_AUTHOR(DRIVER_AUTHOR);
298MODULE_DESCRIPTION(DRIVER_DESC); 297MODULE_DESCRIPTION(DRIVER_DESC);
299MODULE_LICENSE("GPL"); 298MODULE_LICENSE("GPL");
300module_param_named(debug, m5602_debug, int, S_IRUGO | S_IWUSR);
301MODULE_PARM_DESC(debug, "toggles debug on/off");
302
303module_param(force_sensor, int, S_IRUGO | S_IWUSR); 299module_param(force_sensor, int, S_IRUGO | S_IWUSR);
304MODULE_PARM_DESC(force_sensor, 300MODULE_PARM_DESC(force_sensor,
305 "force detection of sensor, " 301 "force detection of sensor, "
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.c b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
index 566d4925a0e8..fb700c2d055a 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.c
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the mt9m111 sensor 2 * Driver for the mt9m111 sensor
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -107,7 +107,7 @@ int mt9m111_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
107 err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, 107 err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B,
108 data, 2); 108 data, 2);
109 *val = data[0] & MT9M111_RMB_MIRROR_ROWS; 109 *val = data[0] & MT9M111_RMB_MIRROR_ROWS;
110 PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); 110 PDEBUG(D_V4L2, "Read vertical flip %d", *val);
111 111
112 return (err < 0) ? err : 0; 112 return (err < 0) ? err : 0;
113} 113}
@@ -118,7 +118,7 @@ int mt9m111_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
118 u8 data[2] = {0x00, 0x00}; 118 u8 data[2] = {0x00, 0x00};
119 struct sd *sd = (struct sd *) gspca_dev; 119 struct sd *sd = (struct sd *) gspca_dev;
120 120
121 PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); 121 PDEBUG(D_V4L2, "Set vertical flip to %d", val);
122 122
123 /* Set the correct page map */ 123 /* Set the correct page map */
124 err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); 124 err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2);
@@ -145,7 +145,7 @@ int mt9m111_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
145 err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, 145 err = mt9m111_read_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B,
146 data, 2); 146 data, 2);
147 *val = data[0] & MT9M111_RMB_MIRROR_COLS; 147 *val = data[0] & MT9M111_RMB_MIRROR_COLS;
148 PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); 148 PDEBUG(D_V4L2, "Read horizontal flip %d", *val);
149 149
150 return (err < 0) ? err : 0; 150 return (err < 0) ? err : 0;
151} 151}
@@ -156,7 +156,7 @@ int mt9m111_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
156 u8 data[2] = {0x00, 0x00}; 156 u8 data[2] = {0x00, 0x00};
157 struct sd *sd = (struct sd *) gspca_dev; 157 struct sd *sd = (struct sd *) gspca_dev;
158 158
159 PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", val); 159 PDEBUG(D_V4L2, "Set horizontal flip to %d", val);
160 160
161 /* Set the correct page map */ 161 /* Set the correct page map */
162 err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); 162 err = mt9m111_write_sensor(sd, MT9M111_PAGE_MAP, data, 2);
@@ -188,7 +188,7 @@ int mt9m111_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
188 ((tmp & (1 << 8)) * 2) | 188 ((tmp & (1 << 8)) * 2) |
189 (tmp & 0x7f); 189 (tmp & 0x7f);
190 190
191 PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 191 PDEBUG(D_V4L2, "Read gain %d", *val);
192 192
193 return (err < 0) ? err : 0; 193 return (err < 0) ? err : 0;
194} 194}
@@ -222,7 +222,7 @@ int mt9m111_set_gain(struct gspca_dev *gspca_dev, __s32 val)
222 222
223 data[1] = (tmp & 0xff00) >> 8; 223 data[1] = (tmp & 0xff00) >> 8;
224 data[0] = (tmp & 0xff); 224 data[0] = (tmp & 0xff);
225 PDEBUG(DBG_V4L2_CID, "tmp=%d, data[1]=%d, data[0]=%d", tmp, 225 PDEBUG(D_V4L2, "tmp=%d, data[1]=%d, data[0]=%d", tmp,
226 data[1], data[0]); 226 data[1], data[0]);
227 227
228 err = mt9m111_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, 228 err = mt9m111_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN,
@@ -257,7 +257,7 @@ int mt9m111_read_sensor(struct sd *sd, const u8 address,
257 for (i = 0; i < len && !err; i++) { 257 for (i = 0; i < len && !err; i++) {
258 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 258 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i]));
259 259
260 PDEBUG(DBG_TRACE, "Reading sensor register " 260 PDEBUG(D_CONF, "Reading sensor register "
261 "0x%x contains 0x%x ", address, *i2c_data); 261 "0x%x contains 0x%x ", address, *i2c_data);
262 } 262 }
263out: 263out:
@@ -290,7 +290,7 @@ int mt9m111_write_sensor(struct sd *sd, const u8 address,
290 memcpy(p, sensor_urb_skeleton + 16, 4); 290 memcpy(p, sensor_urb_skeleton + 16, 4);
291 p[3] = i2c_data[i]; 291 p[3] = i2c_data[i];
292 p += 4; 292 p += 4;
293 PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 293 PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x",
294 address, i2c_data[i]); 294 address, i2c_data[i]);
295 } 295 }
296 296
diff --git a/drivers/media/video/gspca/m5602/m5602_mt9m111.h b/drivers/media/video/gspca/m5602/m5602_mt9m111.h
index 79a5d8878190..315209d5aeef 100644
--- a/drivers/media/video/gspca/m5602/m5602_mt9m111.h
+++ b/drivers/media/video/gspca/m5602/m5602_mt9m111.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the mt9m111 sensor 2 * Driver for the mt9m111 sensor
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -82,7 +82,6 @@
82/* Kernel module parameters */ 82/* Kernel module parameters */
83extern int force_sensor; 83extern int force_sensor;
84extern int dump_sensor; 84extern int dump_sensor;
85extern unsigned int m5602_debug;
86 85
87int mt9m111_probe(struct sd *sd); 86int mt9m111_probe(struct sd *sd);
88int mt9m111_init(struct sd *sd); 87int mt9m111_init(struct sd *sd);
@@ -152,8 +151,8 @@ static struct m5602_sensor mt9m111 = {
152 .default_value = DEFAULT_GAIN, 151 .default_value = DEFAULT_GAIN,
153 .flags = V4L2_CTRL_FLAG_SLIDER 152 .flags = V4L2_CTRL_FLAG_SLIDER
154 }, 153 },
155 .set = mt9m111_set_hflip, 154 .set = mt9m111_set_gain,
156 .get = mt9m111_get_hflip 155 .get = mt9m111_get_gain
157 } 156 }
158 }, 157 },
159 158
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.c b/drivers/media/video/gspca/m5602/m5602_ov9650.c
index 31c5896250e7..837c7e47661c 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov9650.c
+++ b/drivers/media/video/gspca/m5602/m5602_ov9650.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the ov9650 sensor 2 * Driver for the ov9650 sensor
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -40,7 +40,7 @@ int ov9650_read_sensor(struct sd *sd, const u8 address,
40 for (i = 0; i < len; i++) { 40 for (i = 0; i < len; i++) {
41 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 41 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i]));
42 42
43 PDEBUG(DBG_TRACE, "Reading sensor register " 43 PDEBUG(D_CONF, "Reading sensor register "
44 "0x%x containing 0x%x ", address, *i2c_data); 44 "0x%x containing 0x%x ", address, *i2c_data);
45 } 45 }
46 return (err < 0) ? err : 0; 46 return (err < 0) ? err : 0;
@@ -72,7 +72,7 @@ int ov9650_write_sensor(struct sd *sd, const u8 address,
72 memcpy(p, sensor_urb_skeleton + 16, 4); 72 memcpy(p, sensor_urb_skeleton + 16, 4);
73 p[3] = i2c_data[i]; 73 p[3] = i2c_data[i];
74 p += 4; 74 p += 4;
75 PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 75 PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x",
76 address, i2c_data[i]); 76 address, i2c_data[i]);
77 } 77 }
78 78
@@ -199,7 +199,7 @@ int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
199 goto out; 199 goto out;
200 *val |= (i2c_data & 0x3f) << 10; 200 *val |= (i2c_data & 0x3f) << 10;
201 201
202 PDEBUG(DBG_V4L2_CID, "Read exposure %d", *val); 202 PDEBUG(D_V4L2, "Read exposure %d", *val);
203out: 203out:
204 return (err < 0) ? err : 0; 204 return (err < 0) ? err : 0;
205} 205}
@@ -210,7 +210,7 @@ int ov9650_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
210 u8 i2c_data; 210 u8 i2c_data;
211 int err; 211 int err;
212 212
213 PDEBUG(DBG_V4L2_CID, "Set exposure to %d", 213 PDEBUG(D_V4L2, "Set exposure to %d",
214 val & 0xffff); 214 val & 0xffff);
215 215
216 /* The 6 MSBs */ 216 /* The 6 MSBs */
@@ -246,7 +246,7 @@ int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
246 246
247 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 247 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1);
248 *val |= i2c_data; 248 *val |= i2c_data;
249 PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 249 PDEBUG(D_V4L2, "Read gain %d", *val);
250 return (err < 0) ? err : 0; 250 return (err < 0) ? err : 0;
251} 251}
252 252
@@ -280,7 +280,7 @@ int ov9650_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val)
280 err = ov9650_read_sensor(sd, OV9650_RED, &i2c_data, 1); 280 err = ov9650_read_sensor(sd, OV9650_RED, &i2c_data, 1);
281 *val = i2c_data; 281 *val = i2c_data;
282 282
283 PDEBUG(DBG_V4L2_CID, "Read red gain %d", *val); 283 PDEBUG(D_V4L2, "Read red gain %d", *val);
284 284
285 return (err < 0) ? err : 0; 285 return (err < 0) ? err : 0;
286} 286}
@@ -291,7 +291,7 @@ int ov9650_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
291 u8 i2c_data; 291 u8 i2c_data;
292 struct sd *sd = (struct sd *) gspca_dev; 292 struct sd *sd = (struct sd *) gspca_dev;
293 293
294 PDEBUG(DBG_V4L2_CID, "Set red gain to %d", 294 PDEBUG(D_V4L2, "Set red gain to %d",
295 val & 0xff); 295 val & 0xff);
296 296
297 i2c_data = val & 0xff; 297 i2c_data = val & 0xff;
@@ -309,7 +309,7 @@ int ov9650_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val)
309 err = ov9650_read_sensor(sd, OV9650_BLUE, &i2c_data, 1); 309 err = ov9650_read_sensor(sd, OV9650_BLUE, &i2c_data, 1);
310 *val = i2c_data; 310 *val = i2c_data;
311 311
312 PDEBUG(DBG_V4L2_CID, "Read blue gain %d", *val); 312 PDEBUG(D_V4L2, "Read blue gain %d", *val);
313 313
314 return (err < 0) ? err : 0; 314 return (err < 0) ? err : 0;
315} 315}
@@ -320,7 +320,7 @@ int ov9650_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
320 u8 i2c_data; 320 u8 i2c_data;
321 struct sd *sd = (struct sd *) gspca_dev; 321 struct sd *sd = (struct sd *) gspca_dev;
322 322
323 PDEBUG(DBG_V4L2_CID, "Set blue gain to %d", 323 PDEBUG(D_V4L2, "Set blue gain to %d",
324 val & 0xff); 324 val & 0xff);
325 325
326 i2c_data = val & 0xff; 326 i2c_data = val & 0xff;
@@ -340,7 +340,7 @@ int ov9650_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
340 *val = ((i2c_data & OV9650_HFLIP) >> 5) ? 0 : 1; 340 *val = ((i2c_data & OV9650_HFLIP) >> 5) ? 0 : 1;
341 else 341 else
342 *val = (i2c_data & OV9650_HFLIP) >> 5; 342 *val = (i2c_data & OV9650_HFLIP) >> 5;
343 PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); 343 PDEBUG(D_V4L2, "Read horizontal flip %d", *val);
344 344
345 return (err < 0) ? err : 0; 345 return (err < 0) ? err : 0;
346} 346}
@@ -351,7 +351,7 @@ int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
351 u8 i2c_data; 351 u8 i2c_data;
352 struct sd *sd = (struct sd *) gspca_dev; 352 struct sd *sd = (struct sd *) gspca_dev;
353 353
354 PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", val); 354 PDEBUG(D_V4L2, "Set horizontal flip to %d", val);
355 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 355 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1);
356 if (err < 0) 356 if (err < 0)
357 goto out; 357 goto out;
@@ -379,7 +379,7 @@ int ov9650_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
379 *val = ((i2c_data & 0x10) >> 4) ? 0 : 1; 379 *val = ((i2c_data & 0x10) >> 4) ? 0 : 1;
380 else 380 else
381 *val = (i2c_data & 0x10) >> 4; 381 *val = (i2c_data & 0x10) >> 4;
382 PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); 382 PDEBUG(D_V4L2, "Read vertical flip %d", *val);
383 383
384 return (err < 0) ? err : 0; 384 return (err < 0) ? err : 0;
385} 385}
@@ -390,7 +390,7 @@ int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
390 u8 i2c_data; 390 u8 i2c_data;
391 struct sd *sd = (struct sd *) gspca_dev; 391 struct sd *sd = (struct sd *) gspca_dev;
392 392
393 PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); 393 PDEBUG(D_V4L2, "Set vertical flip to %d", val);
394 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 394 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1);
395 if (err < 0) 395 if (err < 0)
396 goto out; 396 goto out;
@@ -420,7 +420,7 @@ int ov9650_get_brightness(struct gspca_dev *gspca_dev, __s32 *val)
420 420
421 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 421 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1);
422 *val |= i2c_data; 422 *val |= i2c_data;
423 PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 423 PDEBUG(D_V4L2, "Read gain %d", *val);
424out: 424out:
425 return (err < 0) ? err : 0; 425 return (err < 0) ? err : 0;
426} 426}
@@ -431,7 +431,7 @@ int ov9650_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
431 u8 i2c_data; 431 u8 i2c_data;
432 struct sd *sd = (struct sd *) gspca_dev; 432 struct sd *sd = (struct sd *) gspca_dev;
433 433
434 PDEBUG(DBG_V4L2_CID, "Set gain to %d", val & 0x3ff); 434 PDEBUG(D_V4L2, "Set gain to %d", val & 0x3ff);
435 435
436 /* Read the OV9650_VREF register first to avoid 436 /* Read the OV9650_VREF register first to avoid
437 corrupting the VREF high and low bits */ 437 corrupting the VREF high and low bits */
@@ -461,7 +461,7 @@ int ov9650_get_auto_white_balance(struct gspca_dev *gspca_dev, __s32 *val)
461 461
462 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 462 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
463 *val = (i2c_data & OV9650_AWB_EN) >> 1; 463 *val = (i2c_data & OV9650_AWB_EN) >> 1;
464 PDEBUG(DBG_V4L2_CID, "Read auto white balance %d", *val); 464 PDEBUG(D_V4L2, "Read auto white balance %d", *val);
465 465
466 return (err < 0) ? err : 0; 466 return (err < 0) ? err : 0;
467} 467}
@@ -472,7 +472,7 @@ int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val)
472 u8 i2c_data; 472 u8 i2c_data;
473 struct sd *sd = (struct sd *) gspca_dev; 473 struct sd *sd = (struct sd *) gspca_dev;
474 474
475 PDEBUG(DBG_V4L2_CID, "Set auto white balance to %d", val); 475 PDEBUG(D_V4L2, "Set auto white balance to %d", val);
476 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 476 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
477 if (err < 0) 477 if (err < 0)
478 goto out; 478 goto out;
@@ -491,7 +491,7 @@ int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val)
491 491
492 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 492 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
493 *val = (i2c_data & OV9650_AGC_EN) >> 2; 493 *val = (i2c_data & OV9650_AGC_EN) >> 2;
494 PDEBUG(DBG_V4L2_CID, "Read auto gain control %d", *val); 494 PDEBUG(D_V4L2, "Read auto gain control %d", *val);
495 495
496 return (err < 0) ? err : 0; 496 return (err < 0) ? err : 0;
497} 497}
@@ -502,7 +502,7 @@ int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val)
502 u8 i2c_data; 502 u8 i2c_data;
503 struct sd *sd = (struct sd *) gspca_dev; 503 struct sd *sd = (struct sd *) gspca_dev;
504 504
505 PDEBUG(DBG_V4L2_CID, "Set auto gain control to %d", val); 505 PDEBUG(D_V4L2, "Set auto gain control to %d", val);
506 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 506 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
507 if (err < 0) 507 if (err < 0)
508 goto out; 508 goto out;
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.h b/drivers/media/video/gspca/m5602/m5602_ov9650.h
index 2f29cb056f30..065632f0378e 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov9650.h
+++ b/drivers/media/video/gspca/m5602/m5602_ov9650.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the ov9650 sensor 2 * Driver for the ov9650 sensor
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -121,7 +121,6 @@
121/* Kernel module parameters */ 121/* Kernel module parameters */
122extern int force_sensor; 122extern int force_sensor;
123extern int dump_sensor; 123extern int dump_sensor;
124extern unsigned int m5602_debug;
125 124
126int ov9650_probe(struct sd *sd); 125int ov9650_probe(struct sd *sd);
127int ov9650_init(struct sd *sd); 126int ov9650_init(struct sd *sd);
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.c b/drivers/media/video/gspca/m5602/m5602_po1030.c
index 08c015bde115..d17ac52566e6 100644
--- a/drivers/media/video/gspca/m5602/m5602_po1030.c
+++ b/drivers/media/video/gspca/m5602/m5602_po1030.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the po1030 sensor 2 * Driver for the po1030 sensor
3 * 3 *
4 * Copyright (c) 2008 Erik Andren 4 * Copyright (c) 2008 Erik Andrén
5 * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -82,7 +82,7 @@ int po1030_read_sensor(struct sd *sd, const u8 address,
82 for (i = 0; i < len; i++) { 82 for (i = 0; i < len; i++) {
83 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 83 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i]));
84 84
85 PDEBUG(DBG_TRACE, "Reading sensor register " 85 PDEBUG(D_CONF, "Reading sensor register "
86 "0x%x containing 0x%x ", address, *i2c_data); 86 "0x%x containing 0x%x ", address, *i2c_data);
87 } 87 }
88 return (err < 0) ? err : 0; 88 return (err < 0) ? err : 0;
@@ -112,7 +112,7 @@ int po1030_write_sensor(struct sd *sd, const u8 address,
112 memcpy(p, sensor_urb_skeleton + 16, 4); 112 memcpy(p, sensor_urb_skeleton + 16, 4);
113 p[3] = i2c_data[i]; 113 p[3] = i2c_data[i];
114 p += 4; 114 p += 4;
115 PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 115 PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x",
116 address, i2c_data[i]); 116 address, i2c_data[i]);
117 } 117 }
118 118
@@ -185,7 +185,7 @@ int po1030_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
185 &i2c_data, 1); 185 &i2c_data, 1);
186 *val |= i2c_data; 186 *val |= i2c_data;
187 187
188 PDEBUG(DBG_V4L2_CID, "Exposure read as %d", *val); 188 PDEBUG(D_V4L2, "Exposure read as %d", *val);
189out: 189out:
190 return (err < 0) ? err : 0; 190 return (err < 0) ? err : 0;
191} 191}
@@ -196,10 +196,10 @@ int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
196 u8 i2c_data; 196 u8 i2c_data;
197 int err; 197 int err;
198 198
199 PDEBUG(DBG_V4L2, "Set exposure to %d", val & 0xffff); 199 PDEBUG(D_V4L2, "Set exposure to %d", val & 0xffff);
200 200
201 i2c_data = ((val & 0xff00) >> 8); 201 i2c_data = ((val & 0xff00) >> 8);
202 PDEBUG(DBG_V4L2, "Set exposure to high byte to 0x%x", 202 PDEBUG(D_V4L2, "Set exposure to high byte to 0x%x",
203 i2c_data); 203 i2c_data);
204 204
205 err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_H, 205 err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_H,
@@ -208,7 +208,7 @@ int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
208 goto out; 208 goto out;
209 209
210 i2c_data = (val & 0xff); 210 i2c_data = (val & 0xff);
211 PDEBUG(DBG_V4L2, "Set exposure to low byte to 0x%x", 211 PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x",
212 i2c_data); 212 i2c_data);
213 err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_M, 213 err = po1030_write_sensor(sd, PO1030_REG_INTEGLINES_M,
214 &i2c_data, 1); 214 &i2c_data, 1);
@@ -226,7 +226,71 @@ int po1030_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
226 err = po1030_read_sensor(sd, PO1030_REG_GLOBALGAIN, 226 err = po1030_read_sensor(sd, PO1030_REG_GLOBALGAIN,
227 &i2c_data, 1); 227 &i2c_data, 1);
228 *val = i2c_data; 228 *val = i2c_data;
229 PDEBUG(DBG_V4L2_CID, "Read global gain %d", *val); 229 PDEBUG(D_V4L2, "Read global gain %d", *val);
230
231 return (err < 0) ? err : 0;
232}
233
234int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
235{
236 struct sd *sd = (struct sd *) gspca_dev;
237 u8 i2c_data;
238 int err;
239
240 err = po1030_read_sensor(sd, PO1030_REG_CONTROL2,
241 &i2c_data, 1);
242
243 *val = (i2c_data >> 7) & 0x01 ;
244
245 PDEBUG(D_V4L2, "Read hflip %d", *val);
246
247 return (err < 0) ? err : 0;
248}
249
250int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
251{
252 struct sd *sd = (struct sd *) gspca_dev;
253 u8 i2c_data;
254 int err;
255
256 PDEBUG(D_V4L2, "Set hflip %d", val);
257
258 i2c_data = (val & 0x01) << 7;
259
260 err = po1030_write_sensor(sd, PO1030_REG_CONTROL2,
261 &i2c_data, 1);
262
263 return (err < 0) ? err : 0;
264}
265
266int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
267{
268 struct sd *sd = (struct sd *) gspca_dev;
269 u8 i2c_data;
270 int err;
271
272 err = po1030_read_sensor(sd, PO1030_REG_GLOBALGAIN,
273 &i2c_data, 1);
274
275 *val = (i2c_data >> 6) & 0x01;
276
277 PDEBUG(D_V4L2, "Read vflip %d", *val);
278
279 return (err < 0) ? err : 0;
280}
281
282int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
283{
284 struct sd *sd = (struct sd *) gspca_dev;
285 u8 i2c_data;
286 int err;
287
288 PDEBUG(D_V4L2, "Set vflip %d", val);
289
290 i2c_data = (val & 0x01) << 6;
291
292 err = po1030_write_sensor(sd, PO1030_REG_CONTROL2,
293 &i2c_data, 1);
230 294
231 return (err < 0) ? err : 0; 295 return (err < 0) ? err : 0;
232} 296}
@@ -238,7 +302,7 @@ int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val)
238 int err; 302 int err;
239 303
240 i2c_data = val & 0xff; 304 i2c_data = val & 0xff;
241 PDEBUG(DBG_V4L2, "Set global gain to %d", i2c_data); 305 PDEBUG(D_V4L2, "Set global gain to %d", i2c_data);
242 err = po1030_write_sensor(sd, PO1030_REG_GLOBALGAIN, 306 err = po1030_write_sensor(sd, PO1030_REG_GLOBALGAIN,
243 &i2c_data, 1); 307 &i2c_data, 1);
244 return (err < 0) ? err : 0; 308 return (err < 0) ? err : 0;
@@ -253,7 +317,7 @@ int po1030_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val)
253 err = po1030_read_sensor(sd, PO1030_REG_RED_GAIN, 317 err = po1030_read_sensor(sd, PO1030_REG_RED_GAIN,
254 &i2c_data, 1); 318 &i2c_data, 1);
255 *val = i2c_data; 319 *val = i2c_data;
256 PDEBUG(DBG_V4L2_CID, "Read red gain %d", *val); 320 PDEBUG(D_V4L2, "Read red gain %d", *val);
257 return (err < 0) ? err : 0; 321 return (err < 0) ? err : 0;
258} 322}
259 323
@@ -264,7 +328,7 @@ int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val)
264 int err; 328 int err;
265 329
266 i2c_data = val & 0xff; 330 i2c_data = val & 0xff;
267 PDEBUG(DBG_V4L2, "Set red gain to %d", i2c_data); 331 PDEBUG(D_V4L2, "Set red gain to %d", i2c_data);
268 err = po1030_write_sensor(sd, PO1030_REG_RED_GAIN, 332 err = po1030_write_sensor(sd, PO1030_REG_RED_GAIN,
269 &i2c_data, 1); 333 &i2c_data, 1);
270 return (err < 0) ? err : 0; 334 return (err < 0) ? err : 0;
@@ -279,7 +343,7 @@ int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val)
279 err = po1030_read_sensor(sd, PO1030_REG_BLUE_GAIN, 343 err = po1030_read_sensor(sd, PO1030_REG_BLUE_GAIN,
280 &i2c_data, 1); 344 &i2c_data, 1);
281 *val = i2c_data; 345 *val = i2c_data;
282 PDEBUG(DBG_V4L2_CID, "Read blue gain %d", *val); 346 PDEBUG(D_V4L2, "Read blue gain %d", *val);
283 347
284 return (err < 0) ? err : 0; 348 return (err < 0) ? err : 0;
285} 349}
@@ -290,7 +354,7 @@ int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val)
290 u8 i2c_data; 354 u8 i2c_data;
291 int err; 355 int err;
292 i2c_data = val & 0xff; 356 i2c_data = val & 0xff;
293 PDEBUG(DBG_V4L2, "Set blue gain to %d", i2c_data); 357 PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data);
294 err = po1030_write_sensor(sd, PO1030_REG_BLUE_GAIN, 358 err = po1030_write_sensor(sd, PO1030_REG_BLUE_GAIN,
295 &i2c_data, 1); 359 &i2c_data, 1);
296 360
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.h b/drivers/media/video/gspca/m5602/m5602_po1030.h
index 68f34c97bf44..a0b75ff61d79 100644
--- a/drivers/media/video/gspca/m5602/m5602_po1030.h
+++ b/drivers/media/video/gspca/m5602/m5602_po1030.h
@@ -1,8 +1,7 @@
1/* 1/*
2 * Driver for the po1030 sensor. 2 * Driver for the po1030 sensor.
3 * This is probably a pixel plus sensor but we haven't identified it yet
4 * 3 *
5 * Copyright (c) 2008 Erik Andren 4 * Copyright (c) 2008 Erik Andrén
6 * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (c) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
7 * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (c) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
8 * 7 *
@@ -109,10 +108,13 @@
109#define PO1030_REG_YCONTRAST 0x74 108#define PO1030_REG_YCONTRAST 0x74
110#define PO1030_REG_YSATURATION 0x75 109#define PO1030_REG_YSATURATION 0x75
111 110
111#define PO1030_HFLIP (1 << 7)
112#define PO1030_VFLIP (1 << 6)
113
112/*****************************************************************************/ 114/*****************************************************************************/
113 115
114#define PO1030_GLOBAL_GAIN_DEFAULT 0x12 116#define PO1030_GLOBAL_GAIN_DEFAULT 0x12
115#define PO1030_EXPOSURE_DEFAULT 0xf0ff 117#define PO1030_EXPOSURE_DEFAULT 0x0085
116#define PO1030_BLUE_GAIN_DEFAULT 0x40 118#define PO1030_BLUE_GAIN_DEFAULT 0x40
117#define PO1030_RED_GAIN_DEFAULT 0x40 119#define PO1030_RED_GAIN_DEFAULT 0x40
118 120
@@ -121,7 +123,6 @@
121/* Kernel module parameters */ 123/* Kernel module parameters */
122extern int force_sensor; 124extern int force_sensor;
123extern int dump_sensor; 125extern int dump_sensor;
124extern unsigned int m5602_debug;
125 126
126int po1030_probe(struct sd *sd); 127int po1030_probe(struct sd *sd);
127int po1030_init(struct sd *sd); 128int po1030_init(struct sd *sd);
@@ -142,6 +143,10 @@ int po1030_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val);
142int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val); 143int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val);
143int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val); 144int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val);
144int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val); 145int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val);
146int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);
147int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
148int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);
149int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
145 150
146static struct m5602_sensor po1030 = { 151static struct m5602_sensor po1030 = {
147 .name = "PO1030", 152 .name = "PO1030",
@@ -152,7 +157,7 @@ static struct m5602_sensor po1030 = {
152 .init = po1030_init, 157 .init = po1030_init,
153 .power_down = po1030_power_down, 158 .power_down = po1030_power_down,
154 159
155 .nctrls = 4, 160 .nctrls = 6,
156 .ctrls = { 161 .ctrls = {
157 { 162 {
158 { 163 {
@@ -160,7 +165,7 @@ static struct m5602_sensor po1030 = {
160 .type = V4L2_CTRL_TYPE_INTEGER, 165 .type = V4L2_CTRL_TYPE_INTEGER,
161 .name = "gain", 166 .name = "gain",
162 .minimum = 0x00, 167 .minimum = 0x00,
163 .maximum = 0xff, 168 .maximum = 0x4f,
164 .step = 0x1, 169 .step = 0x1,
165 .default_value = PO1030_GLOBAL_GAIN_DEFAULT, 170 .default_value = PO1030_GLOBAL_GAIN_DEFAULT,
166 .flags = V4L2_CTRL_FLAG_SLIDER 171 .flags = V4L2_CTRL_FLAG_SLIDER
@@ -173,7 +178,7 @@ static struct m5602_sensor po1030 = {
173 .type = V4L2_CTRL_TYPE_INTEGER, 178 .type = V4L2_CTRL_TYPE_INTEGER,
174 .name = "exposure", 179 .name = "exposure",
175 .minimum = 0x00, 180 .minimum = 0x00,
176 .maximum = 0xffff, 181 .maximum = 0x02ff,
177 .step = 0x1, 182 .step = 0x1,
178 .default_value = PO1030_EXPOSURE_DEFAULT, 183 .default_value = PO1030_EXPOSURE_DEFAULT,
179 .flags = V4L2_CTRL_FLAG_SLIDER 184 .flags = V4L2_CTRL_FLAG_SLIDER
@@ -206,8 +211,33 @@ static struct m5602_sensor po1030 = {
206 }, 211 },
207 .set = po1030_set_blue_balance, 212 .set = po1030_set_blue_balance,
208 .get = po1030_get_blue_balance 213 .get = po1030_get_blue_balance
214 }, {
215 {
216 .id = V4L2_CID_HFLIP,
217 .type = V4L2_CTRL_TYPE_BOOLEAN,
218 .name = "horizontal flip",
219 .minimum = 0,
220 .maximum = 1,
221 .step = 1,
222 .default_value = 0,
223 },
224 .set = po1030_set_hflip,
225 .get = po1030_get_hflip
226 }, {
227 {
228 .id = V4L2_CID_VFLIP,
229 .type = V4L2_CTRL_TYPE_BOOLEAN,
230 .name = "vertical flip",
231 .minimum = 0,
232 .maximum = 1,
233 .step = 1,
234 .default_value = 0,
235 },
236 .set = po1030_set_vflip,
237 .get = po1030_get_vflip
209 } 238 }
210 }, 239 },
240
211 .nmodes = 1, 241 .nmodes = 1,
212 .modes = { 242 .modes = {
213 { 243 {
@@ -381,7 +411,7 @@ static const unsigned char init_po1030[][4] =
381 411
382 /* Set the y window to 1 */ 412 /* Set the y window to 1 */
383 {SENSOR, PO1030_REG_WINDOWY_H, 0x00}, 413 {SENSOR, PO1030_REG_WINDOWY_H, 0x00},
384 {SENSOR, PO1030_REG_WINDOWX_L, 0x01}, 414 {SENSOR, PO1030_REG_WINDOWY_L, 0x01},
385 415
386 {SENSOR, PO1030_REG_WINDOWWIDTH_H, 0x02}, 416 {SENSOR, PO1030_REG_WINDOWWIDTH_H, 0x02},
387 {SENSOR, PO1030_REG_WINDOWWIDTH_L, 0x87}, 417 {SENSOR, PO1030_REG_WINDOWWIDTH_L, 0x87},
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
index 68202565325d..14b1eac5b812 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the s5k4aa sensor 2 * Driver for the s5k4aa sensor
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -117,7 +117,7 @@ int s5k4aa_read_sensor(struct sd *sd, const u8 address,
117 for (i = 0; (i < len) & !err; i++) { 117 for (i = 0; (i < len) & !err; i++) {
118 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 118 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i]));
119 119
120 PDEBUG(DBG_TRACE, "Reading sensor register " 120 PDEBUG(D_CONF, "Reading sensor register "
121 "0x%x containing 0x%x ", address, *i2c_data); 121 "0x%x containing 0x%x ", address, *i2c_data);
122 } 122 }
123out: 123out:
@@ -150,7 +150,7 @@ int s5k4aa_write_sensor(struct sd *sd, const u8 address,
150 memcpy(p, sensor_urb_skeleton + 16, 4); 150 memcpy(p, sensor_urb_skeleton + 16, 4);
151 p[3] = i2c_data[i]; 151 p[3] = i2c_data[i];
152 p += 4; 152 p += 4;
153 PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 153 PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x",
154 address, i2c_data[i]); 154 address, i2c_data[i]);
155 } 155 }
156 156
@@ -248,7 +248,7 @@ int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
248 *val = data << 8; 248 *val = data << 8;
249 err = s5k4aa_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1); 249 err = s5k4aa_read_sensor(sd, S5K4AA_EXPOSURE_LO, &data, 1);
250 *val |= data; 250 *val |= data;
251 PDEBUG(DBG_V4L2_CID, "Read exposure %d", *val); 251 PDEBUG(D_V4L2, "Read exposure %d", *val);
252out: 252out:
253 return (err < 0) ? err : 0; 253 return (err < 0) ? err : 0;
254} 254}
@@ -259,7 +259,7 @@ int s5k4aa_set_exposure(struct gspca_dev *gspca_dev, __s32 val)
259 u8 data = S5K4AA_PAGE_MAP_2; 259 u8 data = S5K4AA_PAGE_MAP_2;
260 int err; 260 int err;
261 261
262 PDEBUG(DBG_V4L2_CID, "Set exposure to %d", val); 262 PDEBUG(D_V4L2, "Set exposure to %d", val);
263 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 263 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
264 if (err < 0) 264 if (err < 0)
265 goto out; 265 goto out;
@@ -285,7 +285,7 @@ int s5k4aa_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
285 285
286 err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 286 err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
287 *val = (data & S5K4AA_RM_V_FLIP) >> 7; 287 *val = (data & S5K4AA_RM_V_FLIP) >> 7;
288 PDEBUG(DBG_V4L2_CID, "Read vertical flip %d", *val); 288 PDEBUG(D_V4L2, "Read vertical flip %d", *val);
289 289
290out: 290out:
291 return (err < 0) ? err : 0; 291 return (err < 0) ? err : 0;
@@ -297,7 +297,7 @@ int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
297 u8 data = S5K4AA_PAGE_MAP_2; 297 u8 data = S5K4AA_PAGE_MAP_2;
298 int err; 298 int err;
299 299
300 PDEBUG(DBG_V4L2_CID, "Set vertical flip to %d", val); 300 PDEBUG(D_V4L2, "Set vertical flip to %d", val);
301 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 301 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
302 if (err < 0) 302 if (err < 0)
303 goto out; 303 goto out;
@@ -341,7 +341,7 @@ int s5k4aa_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
341 341
342 err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 342 err = s5k4aa_read_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
343 *val = (data & S5K4AA_RM_H_FLIP) >> 6; 343 *val = (data & S5K4AA_RM_H_FLIP) >> 6;
344 PDEBUG(DBG_V4L2_CID, "Read horizontal flip %d", *val); 344 PDEBUG(D_V4L2, "Read horizontal flip %d", *val);
345out: 345out:
346 return (err < 0) ? err : 0; 346 return (err < 0) ? err : 0;
347} 347}
@@ -352,7 +352,7 @@ int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
352 u8 data = S5K4AA_PAGE_MAP_2; 352 u8 data = S5K4AA_PAGE_MAP_2;
353 int err; 353 int err;
354 354
355 PDEBUG(DBG_V4L2_CID, "Set horizontal flip to %d", 355 PDEBUG(D_V4L2, "Set horizontal flip to %d",
356 val); 356 val);
357 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 357 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
358 if (err < 0) 358 if (err < 0)
@@ -397,7 +397,7 @@ int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
397 397
398 err = s5k4aa_read_sensor(sd, S5K4AA_GAIN_2, &data, 1); 398 err = s5k4aa_read_sensor(sd, S5K4AA_GAIN_2, &data, 1);
399 *val = data; 399 *val = data;
400 PDEBUG(DBG_V4L2_CID, "Read gain %d", *val); 400 PDEBUG(D_V4L2, "Read gain %d", *val);
401 401
402out: 402out:
403 return (err < 0) ? err : 0; 403 return (err < 0) ? err : 0;
@@ -409,7 +409,7 @@ int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val)
409 u8 data = S5K4AA_PAGE_MAP_2; 409 u8 data = S5K4AA_PAGE_MAP_2;
410 int err; 410 int err;
411 411
412 PDEBUG(DBG_V4L2_CID, "Set gain to %d", val); 412 PDEBUG(D_V4L2, "Set gain to %d", val);
413 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); 413 err = s5k4aa_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1);
414 if (err < 0) 414 if (err < 0)
415 goto out; 415 goto out;
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
index bb7f7e3e90af..eaef67655afa 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
+++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the s5k4aa sensor 2 * Driver for the s5k4aa sensor
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -63,7 +63,6 @@
63/* Kernel module parameters */ 63/* Kernel module parameters */
64extern int force_sensor; 64extern int force_sensor;
65extern int dump_sensor; 65extern int dump_sensor;
66extern unsigned int m5602_debug;
67 66
68int s5k4aa_probe(struct sd *sd); 67int s5k4aa_probe(struct sd *sd);
69int s5k4aa_init(struct sd *sd); 68int s5k4aa_init(struct sd *sd);
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.c b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
index b4b33c2d0499..8988a728e0b4 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k83a.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the s5k83a sensor 2 * Driver for the s5k83a sensor
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -101,7 +101,7 @@ int s5k83a_read_sensor(struct sd *sd, const u8 address,
101 for (i = 0; i < len && !len; i++) { 101 for (i = 0; i < len && !len; i++) {
102 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i])); 102 err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i]));
103 103
104 PDEBUG(DBG_TRACE, "Reading sensor register " 104 PDEBUG(D_CONF, "Reading sensor register "
105 "0x%x containing 0x%x ", address, *i2c_data); 105 "0x%x containing 0x%x ", address, *i2c_data);
106 } 106 }
107 107
@@ -135,7 +135,7 @@ int s5k83a_write_sensor(struct sd *sd, const u8 address,
135 memcpy(p, sensor_urb_skeleton + 16, 4); 135 memcpy(p, sensor_urb_skeleton + 16, 4);
136 p[3] = i2c_data[i]; 136 p[3] = i2c_data[i];
137 p += 4; 137 p += 4;
138 PDEBUG(DBG_TRACE, "Writing sensor register 0x%x with 0x%x", 138 PDEBUG(D_CONF, "Writing sensor register 0x%x with 0x%x",
139 address, i2c_data[i]); 139 address, i2c_data[i]);
140 } 140 }
141 141
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.h b/drivers/media/video/gspca/m5602/m5602_s5k83a.h
index 833708eb5a42..ee3ee9cfca1d 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k83a.h
+++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the s5k83a sensor 2 * Driver for the s5k83a sensor
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *
@@ -41,8 +41,6 @@
41/* Kernel module parameters */ 41/* Kernel module parameters */
42extern int force_sensor; 42extern int force_sensor;
43extern int dump_sensor; 43extern int dump_sensor;
44extern unsigned int m5602_debug;
45
46 44
47int s5k83a_probe(struct sd *sd); 45int s5k83a_probe(struct sd *sd);
48int s5k83a_init(struct sd *sd); 46int s5k83a_init(struct sd *sd);
diff --git a/drivers/media/video/gspca/m5602/m5602_sensor.h b/drivers/media/video/gspca/m5602/m5602_sensor.h
index 930fcaab4416..60c9a48e0c02 100644
--- a/drivers/media/video/gspca/m5602/m5602_sensor.h
+++ b/drivers/media/video/gspca/m5602/m5602_sensor.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * USB Driver for ALi m5602 based webcams 2 * USB Driver for ALi m5602 based webcams
3 * 3 *
4 * Copyright (C) 2008 Erik Andren 4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. 5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> 6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
7 * 7 *