aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-01-06 05:55:20 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-01-19 08:45:06 -0500
commit0d0d7ef71ec6ba6abb680478f7d0514584b8277f (patch)
tree3db57842d968a82ff94ceeda505490e9d7a00804
parentf913c001cd6084db0e3486b832234d2fe4513ff6 (diff)
[media] gspca_sonixb: Fix TAS5110D sensor gain control
Also fix the issue of the image being mirrored. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/gspca/sonixb.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index e88097f3d7ed..5c8420e5c02e 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -525,10 +525,18 @@ static const __u8 initTas5110d[] = {
525 0x00, 0x00, 0x00, 0x41, 0x09, 0x0a, 525 0x00, 0x00, 0x00, 0x41, 0x09, 0x0a,
526 0x16, 0x12, 0x60, 0x86, 0x2b, 526 0x16, 0x12, 0x60, 0x86, 0x2b,
527}; 527};
528static const __u8 tas5110_sensor_init[][8] = { 528/* tas5110c is 3 wire, tas5110d is 2 wire (regular i2c) */
529static const __u8 tas5110c_sensor_init[][8] = {
529 {0x30, 0x11, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10}, 530 {0x30, 0x11, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10},
530 {0x30, 0x11, 0x02, 0x20, 0xa9, 0x00, 0x00, 0x10}, 531 {0x30, 0x11, 0x02, 0x20, 0xa9, 0x00, 0x00, 0x10},
531 {0xa0, 0x61, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x17}, 532};
533/* Known TAS5110D registers
534 * reg02: gain, bit order reversed!! 0 == max gain, 255 == min gain
535 * reg03: bit3: vflip, bit4: ~hflip, bit7: ~gainboost (~ == inverted)
536 * Note: writing reg03 seems to only work when written together with 02
537 */
538static const __u8 tas5110d_sensor_init[][8] = {
539 {0xa0, 0x61, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x17}, /* reset */
532}; 540};
533 541
534static const __u8 initTas5130[] = { 542static const __u8 initTas5130[] = {
@@ -552,9 +560,9 @@ SENS(initOv6650, ov6650_sensor_init, F_GAIN|F_SIF, 0, 0x60),
552SENS(initOv7630, ov7630_sensor_init, F_GAIN, 0, 0x21), 560SENS(initOv7630, ov7630_sensor_init, F_GAIN, 0, 0x21),
553SENS(initPas106, pas106_sensor_init, F_GAIN|F_SIF, NO_FREQ, 0), 561SENS(initPas106, pas106_sensor_init, F_GAIN|F_SIF, NO_FREQ, 0),
554SENS(initPas202, pas202_sensor_init, F_GAIN, NO_FREQ, 0), 562SENS(initPas202, pas202_sensor_init, F_GAIN, NO_FREQ, 0),
555SENS(initTas5110c, tas5110_sensor_init, F_GAIN|F_SIF|F_COARSE_EXPO, 563SENS(initTas5110c, tas5110c_sensor_init, F_GAIN|F_SIF|F_COARSE_EXPO,
556 NO_BRIGHTNESS|NO_FREQ, 0), 564 NO_BRIGHTNESS|NO_FREQ, 0),
557SENS(initTas5110d, tas5110_sensor_init, F_GAIN|F_SIF|F_COARSE_EXPO, 565SENS(initTas5110d, tas5110d_sensor_init, F_GAIN|F_SIF|F_COARSE_EXPO,
558 NO_BRIGHTNESS|NO_FREQ, 0), 566 NO_BRIGHTNESS|NO_FREQ, 0),
559SENS(initTas5130, tas5130_sensor_init, 0, NO_EXPO|NO_FREQ, 0), 567SENS(initTas5130, tas5130_sensor_init, 0, NO_EXPO|NO_FREQ, 0),
560}; 568};
@@ -705,8 +713,7 @@ static void setsensorgain(struct gspca_dev *gspca_dev)
705 goto err; 713 goto err;
706 break; 714 break;
707 } 715 }
708 case SENSOR_TAS5110C: 716 case SENSOR_TAS5110C: {
709 case SENSOR_TAS5110D: {
710 __u8 i2c[] = 717 __u8 i2c[] =
711 {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}; 718 {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10};
712 719
@@ -715,6 +722,23 @@ static void setsensorgain(struct gspca_dev *gspca_dev)
715 goto err; 722 goto err;
716 break; 723 break;
717 } 724 }
725 case SENSOR_TAS5110D: {
726 __u8 i2c[] = {
727 0xb0, 0x61, 0x02, 0x00, 0x10, 0x00, 0x00, 0x17 };
728 gain = 255 - gain;
729 /* The bits in the register are the wrong way around!! */
730 i2c[3] |= (gain & 0x80) >> 7;
731 i2c[3] |= (gain & 0x40) >> 5;
732 i2c[3] |= (gain & 0x20) >> 3;
733 i2c[3] |= (gain & 0x10) >> 1;
734 i2c[3] |= (gain & 0x08) << 1;
735 i2c[3] |= (gain & 0x04) << 3;
736 i2c[3] |= (gain & 0x02) << 5;
737 i2c[3] |= (gain & 0x01) << 7;
738 if (i2c_w(gspca_dev, i2c) < 0)
739 goto err;
740 break;
741 }
718 742
719 case SENSOR_OV6650: 743 case SENSOR_OV6650:
720 gain >>= 1; 744 gain >>= 1;