aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorAndoni Zubimendi <andoni.zubimendi@gmail.com>2008-07-10 10:12:24 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:26:04 -0400
commit51fc8e3bc03aeddc557d3084d08425eb4cb8ed41 (patch)
tree9d04482662da8888f7ee1c56dc0255532134f221 /drivers/media
parentdcef3237b652e1c02093feac0f443485a144f035 (diff)
V4L/DVB (8349): gspca: SN9C103 OV7630 fixes in sonixb.
Signed-off-by: Andoni Zubimendi <andoni.zubimendi@gmail.com> Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/gspca/sonixb.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index 274df69e6f6d..5d2313198807 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -24,8 +24,8 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5) 27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
28static const char version[] = "2.1.5"; 28static const char version[] = "2.1.7";
29 29
30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 30MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
31MODULE_DESCRIPTION("GSPCA/SN9C102 USB Camera Driver"); 31MODULE_DESCRIPTION("GSPCA/SN9C102 USB Camera Driver");
@@ -87,7 +87,6 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
87static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 87static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
88 88
89static struct ctrl sd_ctrls[] = { 89static struct ctrl sd_ctrls[] = {
90#define SD_BRIGHTNESS 0
91 { 90 {
92 { 91 {
93 .id = V4L2_CID_BRIGHTNESS, 92 .id = V4L2_CID_BRIGHTNESS,
@@ -102,7 +101,6 @@ static struct ctrl sd_ctrls[] = {
102 .set = sd_setbrightness, 101 .set = sd_setbrightness,
103 .get = sd_getbrightness, 102 .get = sd_getbrightness,
104 }, 103 },
105#define SD_GAIN 1
106 { 104 {
107 { 105 {
108 .id = V4L2_CID_GAIN, 106 .id = V4L2_CID_GAIN,
@@ -118,7 +116,6 @@ static struct ctrl sd_ctrls[] = {
118 .set = sd_setgain, 116 .set = sd_setgain,
119 .get = sd_getgain, 117 .get = sd_getgain,
120 }, 118 },
121#define SD_EXPOSURE 2
122 { 119 {
123 { 120 {
124 .id = V4L2_CID_EXPOSURE, 121 .id = V4L2_CID_EXPOSURE,
@@ -135,7 +132,6 @@ static struct ctrl sd_ctrls[] = {
135 .set = sd_setexposure, 132 .set = sd_setexposure,
136 .get = sd_getexposure, 133 .get = sd_getexposure,
137 }, 134 },
138#define SD_AUTOGAIN 3
139 { 135 {
140 { 136 {
141 .id = V4L2_CID_AUTOGAIN, 137 .id = V4L2_CID_AUTOGAIN,
@@ -144,7 +140,8 @@ static struct ctrl sd_ctrls[] = {
144 .minimum = 0, 140 .minimum = 0,
145 .maximum = 1, 141 .maximum = 1,
146 .step = 1, 142 .step = 1,
147 .default_value = 1, 143#define AUTOGAIN_DEF 1
144 .default_value = AUTOGAIN_DEF,
148 .flags = 0, 145 .flags = 0,
149 }, 146 },
150 .set = sd_setautogain, 147 .set = sd_setautogain,
@@ -246,10 +243,12 @@ static const __u8 initOv7630[] = {
246static const __u8 initOv7630_3[] = { 243static const __u8 initOv7630_3[] = {
247 0x44, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0x80, /* r01 .. r08 */ 244 0x44, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0x80, /* r01 .. r08 */
248 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, /* r09 .. r10 */ 245 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, /* r09 .. r10 */
249 0x00, 0x02, 0x01, 0x0a, /* r11 .. r14 */ 246 0x00, 0x01, 0x01, 0x0a, /* r11 .. r14 */
250 0x28, 0x1e, /* H & V sizes r15 .. r16 */ 247 0x16, 0x12, /* H & V sizes r15 .. r16 */
251 0x68, COMP1, MCK_INIT1, /* r17 .. r19 */ 248 0x68, 0x8f, MCK_INIT1, /* r17 .. r19 */
252 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c /* r1a .. r1f */ 249 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c, 0x00, /* r1a .. r20 */
250 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, /* r21 .. r28 */
251 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0xff /* r29 .. r30 */
253}; 252};
254static const __u8 ov7630_sensor_init_com[][8] = { 253static const __u8 ov7630_sensor_init_com[][8] = {
255 {0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, 254 {0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10},
@@ -280,14 +279,14 @@ static const __u8 ov7630_sensor_init[][8] = {
280 {0xa0, 0x21, 0x00, 0x10, 0xbd, 0x06, 0xf6, 0x15}, /* gain */ 279 {0xa0, 0x21, 0x00, 0x10, 0xbd, 0x06, 0xf6, 0x15}, /* gain */
281}; 280};
282static const __u8 ov7630_sensor_init_3[][8] = { 281static const __u8 ov7630_sensor_init_3[][8] = {
283 {0xa0, 0x21, 0x10, 0x36, 0xbd, 0x06, 0xf6, 0x16}, /* exposure */ 282 {0xa0, 0x21, 0x10, 0x83, 0xbd, 0x06, 0xf6, 0x16}, /* exposure */
284 {0xa0, 0x21, 0x76, 0x03, 0xbd, 0x06, 0xf6, 0x16}, 283 {0xa0, 0x21, 0x76, 0x00, 0xbd, 0x06, 0xf6, 0x16},
285 {0xa0, 0x21, 0x11, 0x01, 0xbd, 0x06, 0xf6, 0x16}, 284 {0xa0, 0x21, 0x11, 0x00, 0xbd, 0x06, 0xf6, 0x16},
286 {0xa0, 0x21, 0x00, 0x10, 0xbd, 0x06, 0xf6, 0x15}, /* gain */ 285 {0xa0, 0x21, 0x00, 0x10, 0xbd, 0x06, 0xf6, 0x15}, /* gain */
287/* {0xb0, 0x21, 0x2a, 0xc0, 0x3c, 0x06, 0xf6, 0x1d}, 286/* {0xb0, 0x21, 0x2a, 0xc0, 0x3c, 0x06, 0xf6, 0x1d},
288 * a0 1c,a0 1f,c0 3c frame rate ?line interval from ov6630 */ 287 * a0 1c,a0 1f,c0 3c frame rate ?line interval from ov6630 */
289/* {0xb0, 0x21, 0x2a, 0xa0, 0x1f, 0x06, 0xf6, 0x1d}, * from win */ 288/* {0xb0, 0x21, 0x2a, 0xa0, 0x1f, 0x06, 0xf6, 0x1d}, * from win */
290 {0xb0, 0x21, 0x2a, 0xa0, 0x1c, 0x06, 0xf6, 0x1d}, 289 {0xb0, 0x21, 0x2a, 0x80, 0x60, 0x06, 0xf6, 0x1d},
291}; 290};
292 291
293static const __u8 initPas106[] = { 292static const __u8 initPas106[] = {
@@ -403,7 +402,7 @@ static void reg_w(struct usb_device *dev,
403 const __u8 *buffer, 402 const __u8 *buffer,
404 int len) 403 int len)
405{ 404{
406 __u8 tmpbuf[32]; 405 __u8 tmpbuf[48];
407 406
408#ifdef CONFIG_VIDEO_ADV_DEBUG 407#ifdef CONFIG_VIDEO_ADV_DEBUG
409 if (len > sizeof tmpbuf) { 408 if (len > sizeof tmpbuf) {
@@ -554,14 +553,15 @@ static void setsensorgain(struct gspca_dev *gspca_dev)
554 i2c[4] = 255 - gain; 553 i2c[4] = 255 - gain;
555 if (i2c_w(gspca_dev->dev, i2c) < 0) 554 if (i2c_w(gspca_dev->dev, i2c) < 0)
556 goto err; 555 goto err;
557 break; } 556 break;
558 557 }
559 case SENSOR_OV6650: { 558 case SENSOR_OV6650: {
560 __u8 i2c[] = {0xa0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}; 559 __u8 i2c[] = {0xa0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10};
561 i2c[3] = gain; 560 i2c[3] = gain;
562 if (i2c_w(gspca_dev->dev, i2c) < 0) 561 if (i2c_w(gspca_dev->dev, i2c) < 0)
563 goto err; 562 goto err;
564 break; } 563 break;
564 }
565 } 565 }
566 return; 566 return;
567err: 567err:
@@ -605,7 +605,8 @@ static void setexposure(struct gspca_dev *gspca_dev)
605 reg = 15; 605 reg = 15;
606 reg = (reg << 4) | 0x0b; 606 reg = (reg << 4) | 0x0b;
607 reg_w(gspca_dev->dev, 0x19, &reg, 1); 607 reg_w(gspca_dev->dev, 0x19, &reg, 1);
608 break; } 608 break;
609 }
609 case SENSOR_OV6650: { 610 case SENSOR_OV6650: {
610 __u8 i2c[] = {0xa0, 0x60, 0x11, 0xc0, 0x00, 0x00, 0x00, 0x10}; 611 __u8 i2c[] = {0xa0, 0x60, 0x11, 0xc0, 0x00, 0x00, 0x00, 0x10};
611 i2c[3] = 30 / fps - 1; 612 i2c[3] = 30 / fps - 1;
@@ -614,7 +615,8 @@ static void setexposure(struct gspca_dev *gspca_dev)
614 i2c[3] |= 0xc0; 615 i2c[3] |= 0xc0;
615 if (i2c_w(gspca_dev->dev, i2c) < 0) 616 if (i2c_w(gspca_dev->dev, i2c) < 0)
616 PDEBUG(D_ERR, "i2c error exposure"); 617 PDEBUG(D_ERR, "i2c error exposure");
617 break; } 618 break;
619 }
618 } 620 }
619} 621}
620 622
@@ -641,7 +643,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
641{ 643{
642 struct sd *sd = (struct sd *) gspca_dev; 644 struct sd *sd = (struct sd *) gspca_dev;
643 struct cam *cam; 645 struct cam *cam;
644/* __u16 vendor; */
645 __u16 product; 646 __u16 product;
646 int sif = 0; 647 int sif = 0;
647 648
@@ -650,11 +651,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
650 gspca_dev->sd_desc = &sd->sd_desc; 651 gspca_dev->sd_desc = &sd->sd_desc;
651 652
652 sd->fr_h_sz = 12; /* default size of the frame header */ 653 sd->fr_h_sz = 12; /* default size of the frame header */
653 sd->sd_desc.nctrls = 2; /* default no ctrls */ 654 sd->sd_desc.nctrls = 2; /* default nb of ctrls */
654 655
655/* vendor = id->idVendor; */
656 product = id->idProduct; 656 product = id->idProduct;
657/* switch (vendor) { */ 657/* switch (id->idVendor) { */
658/* case 0x0c45: * Sonix */ 658/* case 0x0c45: * Sonix */
659 switch (product) { 659 switch (product) {
660 case 0x6001: /* SN9C102 */ 660 case 0x6001: /* SN9C102 */
@@ -711,15 +711,15 @@ static int sd_config(struct gspca_dev *gspca_dev,
711 cam->epaddr = 0x01; 711 cam->epaddr = 0x01;
712 if (!sif) { 712 if (!sif) {
713 cam->cam_mode = vga_mode; 713 cam->cam_mode = vga_mode;
714 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 714 cam->nmodes = ARRAY_SIZE(vga_mode);
715 } else { 715 } else {
716 cam->cam_mode = sif_mode; 716 cam->cam_mode = sif_mode;
717 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0]; 717 cam->nmodes = ARRAY_SIZE(sif_mode);
718 } 718 }
719 sd->brightness = BRIGHTNESS_DEF; 719 sd->brightness = BRIGHTNESS_DEF;
720 sd->gain = GAIN_DEF; 720 sd->gain = GAIN_DEF;
721 sd->exposure = EXPOSURE_DEF; 721 sd->exposure = EXPOSURE_DEF;
722 sd->autogain = 1; 722 sd->autogain = AUTOGAIN_DEF;
723 if (sd->sensor == SENSOR_OV7630_3) /* jfm: from win trace */ 723 if (sd->sensor == SENSOR_OV7630_3) /* jfm: from win trace */
724 reg_w(gspca_dev->dev, 0x01, probe_ov7630, sizeof probe_ov7630); 724 reg_w(gspca_dev->dev, 0x01, probe_ov7630, sizeof probe_ov7630);
725 return 0; 725 return 0;
@@ -762,6 +762,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
762 const __u8 *sn9c10x; 762 const __u8 *sn9c10x;
763 __u8 reg01, reg17; 763 __u8 reg01, reg17;
764 __u8 reg17_19[3]; 764 __u8 reg17_19[3];
765 static const __u8 reg15[2] = { 0x28, 0x1e };
765 766
766 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 767 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
767 switch (sd->sensor) { 768 switch (sd->sensor) {
@@ -824,7 +825,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
824 case SENSOR_OV7630_3: 825 case SENSOR_OV7630_3:
825 reg01 = 0x44; 826 reg01 = 0x44;
826 reg17 = 0x68; 827 reg17 = 0x68;
827 l = 0x10; 828 l = sizeof initOv7630_3;
828 break; 829 break;
829 default: 830 default:
830 reg01 = sn9c10x[0]; 831 reg01 = sn9c10x[0];
@@ -882,18 +883,21 @@ static void sd_start(struct gspca_dev *gspca_dev)
882 break; 883 break;
883 } 884 }
884 /* H_size V_size 0x28, 0x1e maybe 640x480 */ 885 /* H_size V_size 0x28, 0x1e maybe 640x480 */
885 reg_w(dev, 0x15, &sn9c10x[0x15 - 1], 2); 886 reg_w(dev, 0x15, reg15, 2);
886 /* compression register */ 887 /* compression register */
887 reg_w(dev, 0x18, &reg17_19[1], 1); 888 reg_w(dev, 0x18, &reg17_19[1], 1);
888 /* H_start */ /*fixme: not ov7630*/ 889 if (sd->sensor != SENSOR_OV7630_3) {
889 reg_w(dev, 0x12, &sn9c10x[0x12 - 1], 1); 890 /* H_start */
890 /* V_START */ /*fixme: not ov7630*/ 891 reg_w(dev, 0x12, &sn9c10x[0x12 - 1], 1);
891 reg_w(dev, 0x13, &sn9c10x[0x13 - 1], 1); 892 /* V_START */
893 reg_w(dev, 0x13, &sn9c10x[0x13 - 1], 1);
894 }
892 /* reset 0x17 SensorClk enable inv Clk 0x60 */ 895 /* reset 0x17 SensorClk enable inv Clk 0x60 */
893 /*fixme: ov7630 [17]=68 8f (+20 if 102)*/ 896 /*fixme: ov7630 [17]=68 8f (+20 if 102)*/
894 reg_w(dev, 0x17, &reg17_19[0], 1); 897 reg_w(dev, 0x17, &reg17_19[0], 1);
895 /*MCKSIZE ->3 */ /*fixme: not ov7630*/ 898 /*MCKSIZE ->3 */ /*fixme: not ov7630*/
896 reg_w(dev, 0x19, &reg17_19[2], 1); 899 if (sd->sensor != SENSOR_OV7630_3)
900 reg_w(dev, 0x19, &reg17_19[2], 1);
897 /* AE_STRX AE_STRY AE_ENDX AE_ENDY */ 901 /* AE_STRX AE_STRY AE_ENDX AE_ENDY */
898 reg_w(dev, 0x1c, &sn9c10x[0x1c - 1], 4); 902 reg_w(dev, 0x1c, &sn9c10x[0x1c - 1], 4);
899 /* Enable video transfert */ 903 /* Enable video transfert */
@@ -912,7 +916,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
912 916
913static void sd_stopN(struct gspca_dev *gspca_dev) 917static void sd_stopN(struct gspca_dev *gspca_dev)
914{ 918{
915 __u8 ByteSend = 0; 919 __u8 ByteSend;
916 920
917 ByteSend = 0x09; /* 0X00 */ 921 ByteSend = 0x09; /* 0X00 */
918 reg_w(gspca_dev->dev, 0x01, &ByteSend, 1); 922 reg_w(gspca_dev->dev, 0x01, &ByteSend, 1);