Commit c260fe936de6a52010a3247f9c3e8da47d9726e8

Authored by Theodore Kilgore
Committed by Mauro Carvalho Chehab
1 parent c1ea5b7424

V4L/DVB: gspca_mr97310a: Simplify sensor detection

Simplify sensor detection a bit (share more of the code between cif and vga
cameras). Also remove an unnecessary write from zero_the_pointer().

Signed-off-by: Theodore Kilgore <kilgota@banach.math.auburn.edu>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

Showing 1 changed file with 10 additions and 13 deletions Side-by-side Diff

drivers/media/video/gspca/mr97310a.c
... ... @@ -327,7 +327,6 @@
327 327 if (err_code < 0)
328 328 return err_code;
329 329  
330   - err_code = mr_write(gspca_dev, 1);
331 330 data[0] = 0x19;
332 331 data[1] = 0x51;
333 332 err_code = mr_write(gspca_dev, 2);
334 333  
... ... @@ -460,12 +459,14 @@
460 459 if (err_code < 0)
461 460 return err_code;
462 461  
  462 + /* Now, the query for sensor type. */
  463 + err_code = cam_get_response16(gspca_dev, 0x07, 1);
  464 + if (err_code < 0)
  465 + return err_code;
  466 +
463 467 if (id->idProduct == 0x0110 || id->idProduct == 0x010e) {
464 468 sd->cam_type = CAM_TYPE_CIF;
465 469 cam->nmodes--;
466   - err_code = cam_get_response16(gspca_dev, 0x06, 1);
467   - if (err_code < 0)
468   - return err_code;
469 470 /*
470 471 * All but one of the known CIF cameras share the same USB ID,
471 472 * but two different init routines are in use, and the control
... ... @@ -473,7 +474,7 @@
473 474 * of the two known varieties is connected!
474 475 *
475 476 * A list of known CIF cameras follows. They all report either
476   - * 0002 for type 0 or 0003 for type 1.
  477 + * 0200 for type 0 or 0300 for type 1.
477 478 * If you have another to report, please do
478 479 *
479 480 * Name sd->sensor_type reported by
... ... @@ -487,7 +488,7 @@
487 488 * Philips dig. keych. 1 T. Kilgore
488 489 * Trust Spyc@m 100 1 A. Jacobs
489 490 */
490   - switch (gspca_dev->usb_buf[1]) {
  491 + switch (gspca_dev->usb_buf[0]) {
491 492 case 2:
492 493 sd->sensor_type = 0;
493 494 break;
494 495  
... ... @@ -504,13 +505,9 @@
504 505 } else {
505 506 sd->cam_type = CAM_TYPE_VGA;
506 507  
507   - err_code = cam_get_response16(gspca_dev, 0x07, 1);
508   - if (err_code < 0)
509   - return err_code;
510   -
511 508 /*
512   - * Here is a table of the responses to the previous command
513   - * from the known MR97310A VGA cameras.
  509 + * Here is a table of the responses to the query for sensor
  510 + * type, from the known MR97310A VGA cameras.
514 511 *
515 512 * Name gspca_dev->usb_buf[] sd->sensor_type
516 513 * sd->do_lcd_stop
... ... @@ -560,7 +557,7 @@
560 557 PDEBUG(D_PROBE, "MR97310A VGA camera detected, sensor: %d",
561 558 sd->sensor_type);
562 559 }
563   - /* Stop streaming as we've started it to probe the sensor type. */
  560 + /* Stop streaming as we've started it only to probe the sensor type. */
564 561 sd_stopN(gspca_dev);
565 562  
566 563 if (force_sensor_type != -1) {