diff options
Diffstat (limited to 'drivers/media/video/gspca/pac7311.c')
-rw-r--r-- | drivers/media/video/gspca/pac7311.c | 336 |
1 files changed, 161 insertions, 175 deletions
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c index 1a2347aa7157..5c052e31be4a 100644 --- a/drivers/media/video/gspca/pac7311.c +++ b/drivers/media/video/gspca/pac7311.c | |||
@@ -23,8 +23,8 @@ | |||
23 | 23 | ||
24 | #include "gspca.h" | 24 | #include "gspca.h" |
25 | 25 | ||
26 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5) | 26 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7) |
27 | static const char version[] = "2.1.5"; | 27 | static const char version[] = "2.1.7"; |
28 | 28 | ||
29 | MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li"); | 29 | MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li"); |
30 | MODULE_DESCRIPTION("Pixart PAC7311"); | 30 | MODULE_DESCRIPTION("Pixart PAC7311"); |
@@ -206,46 +206,43 @@ static const __u8 pac7311_jpeg_header[] = { | |||
206 | 0x11, 0x00, 0x3f, 0x00 | 206 | 0x11, 0x00, 0x3f, 0x00 |
207 | }; | 207 | }; |
208 | 208 | ||
209 | static void reg_w(struct usb_device *dev, | 209 | static void reg_w_buf(struct gspca_dev *gspca_dev, |
210 | __u16 index, | 210 | __u16 index, |
211 | const char *buffer, __u16 len) | 211 | const char *buffer, __u16 len) |
212 | { | 212 | { |
213 | __u8 tmpbuf[8]; | 213 | memcpy(gspca_dev->usb_buf, buffer, len); |
214 | 214 | usb_control_msg(gspca_dev->dev, | |
215 | memcpy(tmpbuf, buffer, len); | 215 | usb_sndctrlpipe(gspca_dev->dev, 0), |
216 | usb_control_msg(dev, | ||
217 | usb_sndctrlpipe(dev, 0), | ||
218 | 1, /* request */ | 216 | 1, /* request */ |
219 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 217 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
220 | 0, /* value */ | 218 | 0, /* value */ |
221 | index, tmpbuf, len, | 219 | index, gspca_dev->usb_buf, len, |
222 | 500); | 220 | 500); |
223 | } | 221 | } |
224 | 222 | ||
225 | static void pac7311_reg_read(struct usb_device *dev, __u16 index, | 223 | static __u8 reg_r(struct gspca_dev *gspca_dev, |
226 | __u8 *buffer) | 224 | __u16 index) |
227 | { | 225 | { |
228 | usb_control_msg(dev, | 226 | usb_control_msg(gspca_dev->dev, |
229 | usb_rcvctrlpipe(dev, 0), | 227 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
230 | 0, /* request */ | 228 | 0, /* request */ |
231 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 229 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
232 | 0, /* value */ | 230 | 0, /* value */ |
233 | index, buffer, 1, | 231 | index, gspca_dev->usb_buf, 1, |
234 | 500); | 232 | 500); |
233 | return gspca_dev->usb_buf[0]; | ||
235 | } | 234 | } |
236 | 235 | ||
237 | static void pac7311_reg_write(struct usb_device *dev, | 236 | static void reg_w(struct gspca_dev *gspca_dev, |
238 | __u16 index, | 237 | __u16 index, |
239 | __u8 value) | 238 | __u8 value) |
240 | { | 239 | { |
241 | __u8 buf; | 240 | gspca_dev->usb_buf[0] = value; |
242 | 241 | usb_control_msg(gspca_dev->dev, | |
243 | buf = value; | 242 | usb_sndctrlpipe(gspca_dev->dev, 0), |
244 | usb_control_msg(dev, | ||
245 | usb_sndctrlpipe(dev, 0), | ||
246 | 0, /* request */ | 243 | 0, /* request */ |
247 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 244 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
248 | value, index, &buf, 1, | 245 | value, index, gspca_dev->usb_buf, 1, |
249 | 500); | 246 | 500); |
250 | } | 247 | } |
251 | 248 | ||
@@ -254,20 +251,19 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
254 | const struct usb_device_id *id) | 251 | const struct usb_device_id *id) |
255 | { | 252 | { |
256 | struct sd *sd = (struct sd *) gspca_dev; | 253 | struct sd *sd = (struct sd *) gspca_dev; |
257 | struct usb_device *dev = gspca_dev->dev; | ||
258 | struct cam *cam; | 254 | struct cam *cam; |
259 | 255 | ||
260 | PDEBUG(D_CONF, "Find Sensor PAC7311"); | 256 | PDEBUG(D_CONF, "Find Sensor PAC7311"); |
261 | pac7311_reg_write(dev, 0x78, 0x40); /* Bit_0=start stream, Bit_7=LED */ | 257 | reg_w(gspca_dev, 0x78, 0x40); /* Bit_0=start stream, Bit_7=LED */ |
262 | pac7311_reg_write(dev, 0x78, 0x40); /* Bit_0=start stream, Bit_7=LED */ | 258 | reg_w(gspca_dev, 0x78, 0x40); /* Bit_0=start stream, Bit_7=LED */ |
263 | pac7311_reg_write(dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ | 259 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ |
264 | pac7311_reg_write(dev, 0xff, 0x04); | 260 | reg_w(gspca_dev, 0xff, 0x04); |
265 | pac7311_reg_write(dev, 0x27, 0x80); | 261 | reg_w(gspca_dev, 0x27, 0x80); |
266 | pac7311_reg_write(dev, 0x28, 0xca); | 262 | reg_w(gspca_dev, 0x28, 0xca); |
267 | pac7311_reg_write(dev, 0x29, 0x53); | 263 | reg_w(gspca_dev, 0x29, 0x53); |
268 | pac7311_reg_write(dev, 0x2a, 0x0e); | 264 | reg_w(gspca_dev, 0x2a, 0x0e); |
269 | pac7311_reg_write(dev, 0xff, 0x01); | 265 | reg_w(gspca_dev, 0xff, 0x01); |
270 | pac7311_reg_write(dev, 0x3e, 0x20); | 266 | reg_w(gspca_dev, 0x3e, 0x20); |
271 | 267 | ||
272 | cam = &gspca_dev->cam; | 268 | cam = &gspca_dev->cam; |
273 | cam->dev_name = (char *) id->driver_info; | 269 | cam->dev_name = (char *) id->driver_info; |
@@ -289,11 +285,11 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
289 | 285 | ||
290 | /*jfm: inverted?*/ | 286 | /*jfm: inverted?*/ |
291 | brightness = BRIGHTNESS_MAX - sd->brightness; | 287 | brightness = BRIGHTNESS_MAX - sd->brightness; |
292 | pac7311_reg_write(gspca_dev->dev, 0xff, 0x04); | 288 | reg_w(gspca_dev, 0xff, 0x04); |
293 | /* pac7311_reg_write(gspca_dev->dev, 0x0e, 0x00); */ | 289 | /* reg_w(gspca_dev, 0x0e, 0x00); */ |
294 | pac7311_reg_write(gspca_dev->dev, 0x0f, brightness); | 290 | reg_w(gspca_dev, 0x0f, brightness); |
295 | /* load registers to sensor (Bit 0, auto clear) */ | 291 | /* load registers to sensor (Bit 0, auto clear) */ |
296 | pac7311_reg_write(gspca_dev->dev, 0x11, 0x01); | 292 | reg_w(gspca_dev, 0x11, 0x01); |
297 | PDEBUG(D_CONF|D_STREAM, "brightness: %i", brightness); | 293 | PDEBUG(D_CONF|D_STREAM, "brightness: %i", brightness); |
298 | } | 294 | } |
299 | 295 | ||
@@ -301,10 +297,10 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
301 | { | 297 | { |
302 | struct sd *sd = (struct sd *) gspca_dev; | 298 | struct sd *sd = (struct sd *) gspca_dev; |
303 | 299 | ||
304 | pac7311_reg_write(gspca_dev->dev, 0xff, 0x01); | 300 | reg_w(gspca_dev, 0xff, 0x01); |
305 | pac7311_reg_write(gspca_dev->dev, 0x80, sd->contrast); | 301 | reg_w(gspca_dev, 0x80, sd->contrast); |
306 | /* load registers to sensor (Bit 0, auto clear) */ | 302 | /* load registers to sensor (Bit 0, auto clear) */ |
307 | pac7311_reg_write(gspca_dev->dev, 0x11, 0x01); | 303 | reg_w(gspca_dev, 0x11, 0x01); |
308 | PDEBUG(D_CONF|D_STREAM, "contrast: %i", sd->contrast); | 304 | PDEBUG(D_CONF|D_STREAM, "contrast: %i", sd->contrast); |
309 | } | 305 | } |
310 | 306 | ||
@@ -312,94 +308,93 @@ static void setcolors(struct gspca_dev *gspca_dev) | |||
312 | { | 308 | { |
313 | struct sd *sd = (struct sd *) gspca_dev; | 309 | struct sd *sd = (struct sd *) gspca_dev; |
314 | 310 | ||
315 | pac7311_reg_write(gspca_dev->dev, 0xff, 0x01); | 311 | reg_w(gspca_dev, 0xff, 0x01); |
316 | pac7311_reg_write(gspca_dev->dev, 0x10, sd->colors); | 312 | reg_w(gspca_dev, 0x10, sd->colors); |
317 | /* load registers to sensor (Bit 0, auto clear) */ | 313 | /* load registers to sensor (Bit 0, auto clear) */ |
318 | pac7311_reg_write(gspca_dev->dev, 0x11, 0x01); | 314 | reg_w(gspca_dev, 0x11, 0x01); |
319 | PDEBUG(D_CONF|D_STREAM, "color: %i", sd->colors); | 315 | PDEBUG(D_CONF|D_STREAM, "color: %i", sd->colors); |
320 | } | 316 | } |
321 | 317 | ||
322 | /* this function is called at open time */ | 318 | /* this function is called at open time */ |
323 | static int sd_open(struct gspca_dev *gspca_dev) | 319 | static int sd_open(struct gspca_dev *gspca_dev) |
324 | { | 320 | { |
325 | pac7311_reg_write(gspca_dev->dev, 0x78, 0x00); /* Turn on LED */ | 321 | reg_w(gspca_dev, 0x78, 0x00); /* Turn on LED */ |
326 | return 0; | 322 | return 0; |
327 | } | 323 | } |
328 | 324 | ||
329 | static void sd_start(struct gspca_dev *gspca_dev) | 325 | static void sd_start(struct gspca_dev *gspca_dev) |
330 | { | 326 | { |
331 | struct usb_device *dev = gspca_dev->dev; | ||
332 | struct sd *sd = (struct sd *) gspca_dev; | 327 | struct sd *sd = (struct sd *) gspca_dev; |
333 | 328 | ||
334 | pac7311_reg_write(dev, 0xff, 0x01); | 329 | reg_w(gspca_dev, 0xff, 0x01); |
335 | reg_w(dev, 0x0002, "\x48\x0a\x40\x08\x00\x00\x08\x00", 8); | 330 | reg_w_buf(gspca_dev, 0x0002, "\x48\x0a\x40\x08\x00\x00\x08\x00", 8); |
336 | reg_w(dev, 0x000a, "\x06\xff\x11\xff\x5a\x30\x90\x4c", 8); | 331 | reg_w_buf(gspca_dev, 0x000a, "\x06\xff\x11\xff\x5a\x30\x90\x4c", 8); |
337 | reg_w(dev, 0x0012, "\x00\x07\x00\x0a\x10\x00\xa0\x10", 8); | 332 | reg_w_buf(gspca_dev, 0x0012, "\x00\x07\x00\x0a\x10\x00\xa0\x10", 8); |
338 | reg_w(dev, 0x001a, "\x02\x00\x00\x00\x00\x0b\x01\x00", 8); | 333 | reg_w_buf(gspca_dev, 0x001a, "\x02\x00\x00\x00\x00\x0b\x01\x00", 8); |
339 | reg_w(dev, 0x0022, "\x00\x00\x00\x00\x00\x00\x00\x00", 8); | 334 | reg_w_buf(gspca_dev, 0x0022, "\x00\x00\x00\x00\x00\x00\x00\x00", 8); |
340 | reg_w(dev, 0x002a, "\x00\x00\x00", 3); | 335 | reg_w_buf(gspca_dev, 0x002a, "\x00\x00\x00", 3); |
341 | reg_w(dev, 0x003e, "\x00\x00\x78\x52\x4a\x52\x78\x6e", 8); | 336 | reg_w_buf(gspca_dev, 0x003e, "\x00\x00\x78\x52\x4a\x52\x78\x6e", 8); |
342 | reg_w(dev, 0x0046, "\x48\x46\x48\x6e\x5f\x49\x42\x49", 8); | 337 | reg_w_buf(gspca_dev, 0x0046, "\x48\x46\x48\x6e\x5f\x49\x42\x49", 8); |
343 | reg_w(dev, 0x004e, "\x5f\x5f\x49\x42\x49\x5f\x6e\x48", 8); | 338 | reg_w_buf(gspca_dev, 0x004e, "\x5f\x5f\x49\x42\x49\x5f\x6e\x48", 8); |
344 | reg_w(dev, 0x0056, "\x46\x48\x6e\x78\x52\x4a\x52\x78", 8); | 339 | reg_w_buf(gspca_dev, 0x0056, "\x46\x48\x6e\x78\x52\x4a\x52\x78", 8); |
345 | reg_w(dev, 0x005e, "\x00\x00\x09\x1b\x34\x49\x5c\x9b", 8); | 340 | reg_w_buf(gspca_dev, 0x005e, "\x00\x00\x09\x1b\x34\x49\x5c\x9b", 8); |
346 | reg_w(dev, 0x0066, "\xd0\xff", 2); | 341 | reg_w_buf(gspca_dev, 0x0066, "\xd0\xff", 2); |
347 | reg_w(dev, 0x0078, "\x44\x00\xf2\x01\x01\x80", 6); | 342 | reg_w_buf(gspca_dev, 0x0078, "\x44\x00\xf2\x01\x01\x80", 6); |
348 | reg_w(dev, 0x007f, "\x2a\x1c\x00\xc8\x02\x58\x03\x84", 8); | 343 | reg_w_buf(gspca_dev, 0x007f, "\x2a\x1c\x00\xc8\x02\x58\x03\x84", 8); |
349 | reg_w(dev, 0x0087, "\x12\x00\x1a\x04\x08\x0c\x10\x14", 8); | 344 | reg_w_buf(gspca_dev, 0x0087, "\x12\x00\x1a\x04\x08\x0c\x10\x14", 8); |
350 | reg_w(dev, 0x008f, "\x18\x20", 2); | 345 | reg_w_buf(gspca_dev, 0x008f, "\x18\x20", 2); |
351 | reg_w(dev, 0x0096, "\x01\x08\x04", 3); | 346 | reg_w_buf(gspca_dev, 0x0096, "\x01\x08\x04", 3); |
352 | reg_w(dev, 0x00a0, "\x44\x44\x44\x04", 4); | 347 | reg_w_buf(gspca_dev, 0x00a0, "\x44\x44\x44\x04", 4); |
353 | reg_w(dev, 0x00f0, "\x01\x00\x00\x00\x22\x00\x20\x00", 8); | 348 | reg_w_buf(gspca_dev, 0x00f0, "\x01\x00\x00\x00\x22\x00\x20\x00", 8); |
354 | reg_w(dev, 0x00f8, "\x3f\x00\x0a\x01\x00", 5); | 349 | reg_w_buf(gspca_dev, 0x00f8, "\x3f\x00\x0a\x01\x00", 5); |
355 | 350 | ||
356 | pac7311_reg_write(dev, 0xff, 0x04); | 351 | reg_w(gspca_dev, 0xff, 0x04); |
357 | pac7311_reg_write(dev, 0x02, 0x04); | 352 | reg_w(gspca_dev, 0x02, 0x04); |
358 | pac7311_reg_write(dev, 0x03, 0x54); | 353 | reg_w(gspca_dev, 0x03, 0x54); |
359 | pac7311_reg_write(dev, 0x04, 0x07); | 354 | reg_w(gspca_dev, 0x04, 0x07); |
360 | pac7311_reg_write(dev, 0x05, 0x2b); | 355 | reg_w(gspca_dev, 0x05, 0x2b); |
361 | pac7311_reg_write(dev, 0x06, 0x09); | 356 | reg_w(gspca_dev, 0x06, 0x09); |
362 | pac7311_reg_write(dev, 0x07, 0x0f); | 357 | reg_w(gspca_dev, 0x07, 0x0f); |
363 | pac7311_reg_write(dev, 0x08, 0x09); | 358 | reg_w(gspca_dev, 0x08, 0x09); |
364 | pac7311_reg_write(dev, 0x09, 0x00); | 359 | reg_w(gspca_dev, 0x09, 0x00); |
365 | pac7311_reg_write(dev, 0x0c, 0x07); | 360 | reg_w(gspca_dev, 0x0c, 0x07); |
366 | pac7311_reg_write(dev, 0x0d, 0x00); | 361 | reg_w(gspca_dev, 0x0d, 0x00); |
367 | pac7311_reg_write(dev, 0x0e, 0x00); | 362 | reg_w(gspca_dev, 0x0e, 0x00); |
368 | pac7311_reg_write(dev, 0x0f, 0x62); | 363 | reg_w(gspca_dev, 0x0f, 0x62); |
369 | pac7311_reg_write(dev, 0x10, 0x08); | 364 | reg_w(gspca_dev, 0x10, 0x08); |
370 | pac7311_reg_write(dev, 0x12, 0x07); | 365 | reg_w(gspca_dev, 0x12, 0x07); |
371 | pac7311_reg_write(dev, 0x13, 0x00); | 366 | reg_w(gspca_dev, 0x13, 0x00); |
372 | pac7311_reg_write(dev, 0x14, 0x00); | 367 | reg_w(gspca_dev, 0x14, 0x00); |
373 | pac7311_reg_write(dev, 0x15, 0x00); | 368 | reg_w(gspca_dev, 0x15, 0x00); |
374 | pac7311_reg_write(dev, 0x16, 0x00); | 369 | reg_w(gspca_dev, 0x16, 0x00); |
375 | pac7311_reg_write(dev, 0x17, 0x00); | 370 | reg_w(gspca_dev, 0x17, 0x00); |
376 | pac7311_reg_write(dev, 0x18, 0x00); | 371 | reg_w(gspca_dev, 0x18, 0x00); |
377 | pac7311_reg_write(dev, 0x19, 0x00); | 372 | reg_w(gspca_dev, 0x19, 0x00); |
378 | pac7311_reg_write(dev, 0x1a, 0x00); | 373 | reg_w(gspca_dev, 0x1a, 0x00); |
379 | pac7311_reg_write(dev, 0x1b, 0x03); | 374 | reg_w(gspca_dev, 0x1b, 0x03); |
380 | pac7311_reg_write(dev, 0x1c, 0xa0); | 375 | reg_w(gspca_dev, 0x1c, 0xa0); |
381 | pac7311_reg_write(dev, 0x1d, 0x01); | 376 | reg_w(gspca_dev, 0x1d, 0x01); |
382 | pac7311_reg_write(dev, 0x1e, 0xf4); | 377 | reg_w(gspca_dev, 0x1e, 0xf4); |
383 | pac7311_reg_write(dev, 0x21, 0x00); | 378 | reg_w(gspca_dev, 0x21, 0x00); |
384 | pac7311_reg_write(dev, 0x22, 0x08); | 379 | reg_w(gspca_dev, 0x22, 0x08); |
385 | pac7311_reg_write(dev, 0x24, 0x03); | 380 | reg_w(gspca_dev, 0x24, 0x03); |
386 | pac7311_reg_write(dev, 0x26, 0x00); | 381 | reg_w(gspca_dev, 0x26, 0x00); |
387 | pac7311_reg_write(dev, 0x27, 0x01); | 382 | reg_w(gspca_dev, 0x27, 0x01); |
388 | pac7311_reg_write(dev, 0x28, 0xca); | 383 | reg_w(gspca_dev, 0x28, 0xca); |
389 | pac7311_reg_write(dev, 0x29, 0x10); | 384 | reg_w(gspca_dev, 0x29, 0x10); |
390 | pac7311_reg_write(dev, 0x2a, 0x06); | 385 | reg_w(gspca_dev, 0x2a, 0x06); |
391 | pac7311_reg_write(dev, 0x2b, 0x78); | 386 | reg_w(gspca_dev, 0x2b, 0x78); |
392 | pac7311_reg_write(dev, 0x2c, 0x00); | 387 | reg_w(gspca_dev, 0x2c, 0x00); |
393 | pac7311_reg_write(dev, 0x2d, 0x00); | 388 | reg_w(gspca_dev, 0x2d, 0x00); |
394 | pac7311_reg_write(dev, 0x2e, 0x00); | 389 | reg_w(gspca_dev, 0x2e, 0x00); |
395 | pac7311_reg_write(dev, 0x2f, 0x00); | 390 | reg_w(gspca_dev, 0x2f, 0x00); |
396 | pac7311_reg_write(dev, 0x30, 0x23); | 391 | reg_w(gspca_dev, 0x30, 0x23); |
397 | pac7311_reg_write(dev, 0x31, 0x28); | 392 | reg_w(gspca_dev, 0x31, 0x28); |
398 | pac7311_reg_write(dev, 0x32, 0x04); | 393 | reg_w(gspca_dev, 0x32, 0x04); |
399 | pac7311_reg_write(dev, 0x33, 0x11); | 394 | reg_w(gspca_dev, 0x33, 0x11); |
400 | pac7311_reg_write(dev, 0x34, 0x00); | 395 | reg_w(gspca_dev, 0x34, 0x00); |
401 | pac7311_reg_write(dev, 0x35, 0x00); | 396 | reg_w(gspca_dev, 0x35, 0x00); |
402 | pac7311_reg_write(dev, 0x11, 0x01); | 397 | reg_w(gspca_dev, 0x11, 0x01); |
403 | setcontrast(gspca_dev); | 398 | setcontrast(gspca_dev); |
404 | setbrightness(gspca_dev); | 399 | setbrightness(gspca_dev); |
405 | setcolors(gspca_dev); | 400 | setcolors(gspca_dev); |
@@ -407,39 +402,39 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
407 | /* set correct resolution */ | 402 | /* set correct resolution */ |
408 | switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { | 403 | switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { |
409 | case 2: /* 160x120 */ | 404 | case 2: /* 160x120 */ |
410 | pac7311_reg_write(dev, 0xff, 0x04); | 405 | reg_w(gspca_dev, 0xff, 0x04); |
411 | pac7311_reg_write(dev, 0x02, 0x03); | 406 | reg_w(gspca_dev, 0x02, 0x03); |
412 | pac7311_reg_write(dev, 0xff, 0x01); | 407 | reg_w(gspca_dev, 0xff, 0x01); |
413 | pac7311_reg_write(dev, 0x08, 0x09); | 408 | reg_w(gspca_dev, 0x08, 0x09); |
414 | pac7311_reg_write(dev, 0x17, 0x20); | 409 | reg_w(gspca_dev, 0x17, 0x20); |
415 | pac7311_reg_write(dev, 0x1b, 0x00); | 410 | reg_w(gspca_dev, 0x1b, 0x00); |
416 | /* pac7311_reg_write(dev, 0x80, 0x69); */ | 411 | /* reg_w(gspca_dev, 0x80, 0x69); */ |
417 | pac7311_reg_write(dev, 0x87, 0x10); | 412 | reg_w(gspca_dev, 0x87, 0x10); |
418 | break; | 413 | break; |
419 | case 1: /* 320x240 */ | 414 | case 1: /* 320x240 */ |
420 | pac7311_reg_write(dev, 0xff, 0x04); | 415 | reg_w(gspca_dev, 0xff, 0x04); |
421 | pac7311_reg_write(dev, 0x02, 0x03); | 416 | reg_w(gspca_dev, 0x02, 0x03); |
422 | pac7311_reg_write(dev, 0xff, 0x01); | 417 | reg_w(gspca_dev, 0xff, 0x01); |
423 | pac7311_reg_write(dev, 0x08, 0x09); | 418 | reg_w(gspca_dev, 0x08, 0x09); |
424 | pac7311_reg_write(dev, 0x17, 0x30); | 419 | reg_w(gspca_dev, 0x17, 0x30); |
425 | /* pac7311_reg_write(dev, 0x80, 0x3f); */ | 420 | /* reg_w(gspca_dev, 0x80, 0x3f); */ |
426 | pac7311_reg_write(dev, 0x87, 0x11); | 421 | reg_w(gspca_dev, 0x87, 0x11); |
427 | break; | 422 | break; |
428 | case 0: /* 640x480 */ | 423 | case 0: /* 640x480 */ |
429 | pac7311_reg_write(dev, 0xff, 0x04); | 424 | reg_w(gspca_dev, 0xff, 0x04); |
430 | pac7311_reg_write(dev, 0x02, 0x03); | 425 | reg_w(gspca_dev, 0x02, 0x03); |
431 | pac7311_reg_write(dev, 0xff, 0x01); | 426 | reg_w(gspca_dev, 0xff, 0x01); |
432 | pac7311_reg_write(dev, 0x08, 0x08); | 427 | reg_w(gspca_dev, 0x08, 0x08); |
433 | pac7311_reg_write(dev, 0x17, 0x00); | 428 | reg_w(gspca_dev, 0x17, 0x00); |
434 | /* pac7311_reg_write(dev, 0x80, 0x1c); */ | 429 | /* reg_w(gspca_dev, 0x80, 0x1c); */ |
435 | pac7311_reg_write(dev, 0x87, 0x12); | 430 | reg_w(gspca_dev, 0x87, 0x12); |
436 | break; | 431 | break; |
437 | } | 432 | } |
438 | 433 | ||
439 | /* start stream */ | 434 | /* start stream */ |
440 | pac7311_reg_write(dev, 0xff, 0x01); | 435 | reg_w(gspca_dev, 0xff, 0x01); |
441 | pac7311_reg_write(dev, 0x78, 0x04); | 436 | reg_w(gspca_dev, 0x78, 0x04); |
442 | pac7311_reg_write(dev, 0x78, 0x05); | 437 | reg_w(gspca_dev, 0x78, 0x05); |
443 | 438 | ||
444 | if (sd->autogain) { | 439 | if (sd->autogain) { |
445 | sd->ag_cnt = AG_CNT_START; | 440 | sd->ag_cnt = AG_CNT_START; |
@@ -451,18 +446,16 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
451 | 446 | ||
452 | static void sd_stopN(struct gspca_dev *gspca_dev) | 447 | static void sd_stopN(struct gspca_dev *gspca_dev) |
453 | { | 448 | { |
454 | struct usb_device *dev = gspca_dev->dev; | 449 | reg_w(gspca_dev, 0xff, 0x04); |
455 | 450 | reg_w(gspca_dev, 0x27, 0x80); | |
456 | pac7311_reg_write(dev, 0xff, 0x04); | 451 | reg_w(gspca_dev, 0x28, 0xca); |
457 | pac7311_reg_write(dev, 0x27, 0x80); | 452 | reg_w(gspca_dev, 0x29, 0x53); |
458 | pac7311_reg_write(dev, 0x28, 0xca); | 453 | reg_w(gspca_dev, 0x2a, 0x0e); |
459 | pac7311_reg_write(dev, 0x29, 0x53); | 454 | reg_w(gspca_dev, 0xff, 0x01); |
460 | pac7311_reg_write(dev, 0x2a, 0x0e); | 455 | reg_w(gspca_dev, 0x3e, 0x20); |
461 | pac7311_reg_write(dev, 0xff, 0x01); | 456 | reg_w(gspca_dev, 0x78, 0x04); /* Bit_0=start stream, Bit_7=LED */ |
462 | pac7311_reg_write(dev, 0x3e, 0x20); | 457 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ |
463 | pac7311_reg_write(dev, 0x78, 0x04); /* Bit_0=start stream, Bit_7=LED */ | 458 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ |
464 | pac7311_reg_write(dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ | ||
465 | pac7311_reg_write(dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ | ||
466 | } | 459 | } |
467 | 460 | ||
468 | static void sd_stop0(struct gspca_dev *gspca_dev) | 461 | static void sd_stop0(struct gspca_dev *gspca_dev) |
@@ -472,18 +465,16 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
472 | /* this function is called at close time */ | 465 | /* this function is called at close time */ |
473 | static void sd_close(struct gspca_dev *gspca_dev) | 466 | static void sd_close(struct gspca_dev *gspca_dev) |
474 | { | 467 | { |
475 | struct usb_device *dev = gspca_dev->dev; | 468 | reg_w(gspca_dev, 0xff, 0x04); |
476 | 469 | reg_w(gspca_dev, 0x27, 0x80); | |
477 | pac7311_reg_write(dev, 0xff, 0x04); | 470 | reg_w(gspca_dev, 0x28, 0xca); |
478 | pac7311_reg_write(dev, 0x27, 0x80); | 471 | reg_w(gspca_dev, 0x29, 0x53); |
479 | pac7311_reg_write(dev, 0x28, 0xca); | 472 | reg_w(gspca_dev, 0x2a, 0x0e); |
480 | pac7311_reg_write(dev, 0x29, 0x53); | 473 | reg_w(gspca_dev, 0xff, 0x01); |
481 | pac7311_reg_write(dev, 0x2a, 0x0e); | 474 | reg_w(gspca_dev, 0x3e, 0x20); |
482 | pac7311_reg_write(dev, 0xff, 0x01); | 475 | reg_w(gspca_dev, 0x78, 0x04); /* Bit_0=start stream, Bit_7=LED */ |
483 | pac7311_reg_write(dev, 0x3e, 0x20); | 476 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ |
484 | pac7311_reg_write(dev, 0x78, 0x04); /* Bit_0=start stream, Bit_7=LED */ | 477 | reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ |
485 | pac7311_reg_write(dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ | ||
486 | pac7311_reg_write(dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ | ||
487 | } | 478 | } |
488 | 479 | ||
489 | static void setautogain(struct gspca_dev *gspca_dev, int luma) | 480 | static void setautogain(struct gspca_dev *gspca_dev, int luma) |
@@ -491,11 +482,9 @@ static void setautogain(struct gspca_dev *gspca_dev, int luma) | |||
491 | int luma_mean = 128; | 482 | int luma_mean = 128; |
492 | int luma_delta = 20; | 483 | int luma_delta = 20; |
493 | __u8 spring = 5; | 484 | __u8 spring = 5; |
494 | __u8 Pxclk; | ||
495 | int Gbright; | 485 | int Gbright; |
496 | 486 | ||
497 | pac7311_reg_read(gspca_dev->dev, 0x02, &Pxclk); | 487 | Gbright = reg_r(gspca_dev, 0x02); |
498 | Gbright = Pxclk; | ||
499 | PDEBUG(D_FRAM, "luma mean %d", luma); | 488 | PDEBUG(D_FRAM, "luma mean %d", luma); |
500 | if (luma < luma_mean - luma_delta || | 489 | if (luma < luma_mean - luma_delta || |
501 | luma > luma_mean + luma_delta) { | 490 | luma > luma_mean + luma_delta) { |
@@ -505,10 +494,10 @@ static void setautogain(struct gspca_dev *gspca_dev, int luma) | |||
505 | else if (Gbright < 4) | 494 | else if (Gbright < 4) |
506 | Gbright = 4; | 495 | Gbright = 4; |
507 | PDEBUG(D_FRAM, "gbright %d", Gbright); | 496 | PDEBUG(D_FRAM, "gbright %d", Gbright); |
508 | pac7311_reg_write(gspca_dev->dev, 0xff, 0x04); | 497 | reg_w(gspca_dev, 0xff, 0x04); |
509 | pac7311_reg_write(gspca_dev->dev, 0x0f, Gbright); | 498 | reg_w(gspca_dev, 0x0f, Gbright); |
510 | /* load registers to sensor (Bit 0, auto clear) */ | 499 | /* load registers to sensor (Bit 0, auto clear) */ |
511 | pac7311_reg_write(gspca_dev->dev, 0x11, 0x01); | 500 | reg_w(gspca_dev, 0x11, 0x01); |
512 | } | 501 | } |
513 | } | 502 | } |
514 | 503 | ||
@@ -623,11 +612,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
623 | 612 | ||
624 | static void getbrightness(struct gspca_dev *gspca_dev) | 613 | static void getbrightness(struct gspca_dev *gspca_dev) |
625 | { | 614 | { |
626 | /* __u8 brightness = 0; | 615 | /* sd->brightness = reg_r(gspca_dev, 0x08); |
627 | 616 | return sd->brightness; */ | |
628 | pac7311_reg_read(gspca_dev->dev, 0x0008, &brightness); | ||
629 | spca50x->brightness = brightness; | ||
630 | return spca50x->brightness; */ | ||
631 | /* PDEBUG(D_CONF, "Called pac7311_getbrightness: Not implemented yet"); */ | 617 | /* PDEBUG(D_CONF, "Called pac7311_getbrightness: Not implemented yet"); */ |
632 | } | 618 | } |
633 | 619 | ||