aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca
diff options
context:
space:
mode:
authorHans de Goede <j.w.r.degoede@hhs.nl>2008-09-03 16:12:15 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-09-03 17:37:29 -0400
commite2ad2a54ad1e0f8d7c9e49c38b552a630e015af3 (patch)
tree1af025f537a1bcda332054f37351d668c82f3a30 /drivers/media/video/gspca
parent0f523c2ff6b5ab3b4412cf56dee77ac57be24103 (diff)
V4L/DVB (8816): gspca: Set disabled ctrls and fix a register pb with ovxxxx in sonixb.
- set some controls as disabled instead of copying the device descr. - in the ov6650 / 7650 exposure code clamp reg 11 before (instead of after) using it to calculate reg 10. - disable brightness (instead of ignoring it) for the TAS5110. Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl> Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r--drivers/media/video/gspca/sonixb.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index e535ced79f16..735d4260f2f8 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -31,9 +31,6 @@ MODULE_LICENSE("GPL");
31/* specific webcam descriptor */ 31/* specific webcam descriptor */
32struct sd { 32struct sd {
33 struct gspca_dev gspca_dev; /* !! must be the first item */ 33 struct gspca_dev gspca_dev; /* !! must be the first item */
34
35 struct sd_desc sd_desc; /* our nctrls differ dependend upon the
36 sensor, so we use a per cam copy */
37 atomic_t avg_lum; 34 atomic_t avg_lum;
38 35
39 unsigned char gain; 36 unsigned char gain;
@@ -60,9 +57,8 @@ struct sd {
60 57
61/* flags used in the device id table */ 58/* flags used in the device id table */
62#define F_GAIN 0x01 /* has gain */ 59#define F_GAIN 0x01 /* has gain */
63#define F_AUTO 0x02 /* has autogain */ 60#define F_SIF 0x02 /* sif or vga */
64#define F_SIF 0x04 /* sif or vga */ 61#define F_H18 0x04 /* long (18 b) or short (12 b) frame header */
65#define F_H18 0x08 /* long (18 b) or short (12 b) frame header */
66 62
67#define COMP2 0x8f 63#define COMP2 0x8f
68#define COMP 0xc7 /* 0x87 //0x07 */ 64#define COMP 0xc7 /* 0x87 //0x07 */
@@ -95,6 +91,7 @@ static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
95static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); 91static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
96 92
97static struct ctrl sd_ctrls[] = { 93static struct ctrl sd_ctrls[] = {
94#define BRIGHTNESS_IDX 0
98 { 95 {
99 { 96 {
100 .id = V4L2_CID_BRIGHTNESS, 97 .id = V4L2_CID_BRIGHTNESS,
@@ -109,6 +106,7 @@ static struct ctrl sd_ctrls[] = {
109 .set = sd_setbrightness, 106 .set = sd_setbrightness,
110 .get = sd_getbrightness, 107 .get = sd_getbrightness,
111 }, 108 },
109#define GAIN_IDX 1
112 { 110 {
113 { 111 {
114 .id = V4L2_CID_GAIN, 112 .id = V4L2_CID_GAIN,
@@ -124,6 +122,7 @@ static struct ctrl sd_ctrls[] = {
124 .set = sd_setgain, 122 .set = sd_setgain,
125 .get = sd_getgain, 123 .get = sd_getgain,
126 }, 124 },
125#define EXPOSURE_IDX 2
127 { 126 {
128 { 127 {
129 .id = V4L2_CID_EXPOSURE, 128 .id = V4L2_CID_EXPOSURE,
@@ -140,6 +139,7 @@ static struct ctrl sd_ctrls[] = {
140 .set = sd_setexposure, 139 .set = sd_setexposure,
141 .get = sd_getexposure, 140 .get = sd_getexposure,
142 }, 141 },
142#define AUTOGAIN_IDX 3
143 { 143 {
144 { 144 {
145 .id = V4L2_CID_AUTOGAIN, 145 .id = V4L2_CID_AUTOGAIN,
@@ -155,6 +155,7 @@ static struct ctrl sd_ctrls[] = {
155 .set = sd_setautogain, 155 .set = sd_setautogain,
156 .get = sd_getautogain, 156 .get = sd_getautogain,
157 }, 157 },
158#define FREQ_IDX 4
158 { 159 {
159 { 160 {
160 .id = V4L2_CID_POWER_LINE_FREQUENCY, 161 .id = V4L2_CID_POWER_LINE_FREQUENCY,
@@ -545,9 +546,6 @@ static void setbrightness(struct gspca_dev *gspca_dev)
545 goto err; 546 goto err;
546 break; 547 break;
547 } 548 }
548 case SENSOR_TAS5110:
549 /* FIXME figure out howto control brightness on TAS5110 */
550 break;
551 } 549 }
552 return; 550 return;
553err: 551err:
@@ -665,6 +663,11 @@ static void setexposure(struct gspca_dev *gspca_dev)
665 else if (reg11 > 16) 663 else if (reg11 > 16)
666 reg11 = 16; 664 reg11 = 16;
667 665
666 /* In 640x480, if the reg11 has less than 3, the image is
667 unstable (not enough bandwidth). */
668 if (gspca_dev->width == 640 && reg11 < 3)
669 reg11 = 3;
670
668 /* frame exposure time in ms = 1000 * reg11 / 30 -> 671 /* frame exposure time in ms = 1000 * reg11 / 30 ->
669 reg10 = sd->exposure * 2 * reg10_max / (1000 * reg11 / 30) */ 672 reg10 = sd->exposure * 2 * reg10_max / (1000 * reg11 / 30) */
670 reg10 = (sd->exposure * 60 * reg10_max) / (1000 * reg11); 673 reg10 = (sd->exposure * 60 * reg10_max) / (1000 * reg11);
@@ -678,11 +681,6 @@ static void setexposure(struct gspca_dev *gspca_dev)
678 else if (reg10 > reg10_max) 681 else if (reg10 > reg10_max)
679 reg10 = reg10_max; 682 reg10 = reg10_max;
680 683
681 /* In 640x480, if the reg11 has less than 3, the image is
682 unstable (not enough bandwidth). */
683 if (gspca_dev->width == 640 && reg11 < 3)
684 reg11 = 3;
685
686 /* Write reg 10 and reg11 low nibble */ 684 /* Write reg 10 and reg11 low nibble */
687 i2c[1] = sd->sensor_addr; 685 i2c[1] = sd->sensor_addr;
688 i2c[3] = reg10; 686 i2c[3] = reg10;
@@ -759,23 +757,17 @@ static int sd_config(struct gspca_dev *gspca_dev,
759 struct cam *cam; 757 struct cam *cam;
760 int sif = 0; 758 int sif = 0;
761 759
762 /* nctrls depends upon the sensor, so we use a per cam copy */
763 memcpy(&sd->sd_desc, gspca_dev->sd_desc, sizeof(struct sd_desc));
764 gspca_dev->sd_desc = &sd->sd_desc;
765
766 /* copy the webcam info from the device id */ 760 /* copy the webcam info from the device id */
767 sd->sensor = (id->driver_info >> 24) & 0xff; 761 sd->sensor = (id->driver_info >> 24) & 0xff;
768 if (id->driver_info & (F_GAIN << 16)) 762 if (id->driver_info & (F_GAIN << 16))
769 sd->sensor_has_gain = 1; 763 sd->sensor_has_gain = 1;
770 if (id->driver_info & (F_AUTO << 16))
771 sd->sd_desc.dq_callback = do_autogain;
772 if (id->driver_info & (F_SIF << 16)) 764 if (id->driver_info & (F_SIF << 16))
773 sif = 1; 765 sif = 1;
774 if (id->driver_info & (F_H18 << 16)) 766 if (id->driver_info & (F_H18 << 16))
775 sd->fr_h_sz = 18; /* size of frame header */ 767 sd->fr_h_sz = 18; /* size of frame header */
776 else 768 else
777 sd->fr_h_sz = 12; 769 sd->fr_h_sz = 12;
778 sd->sd_desc.nctrls = (id->driver_info >> 8) & 0xff; 770 gspca_dev->ctrl_dis = (id->driver_info >> 8) & 0xff;
779 sd->sensor_addr = id->driver_info & 0xff; 771 sd->sensor_addr = id->driver_info & 0xff;
780 772
781 cam = &gspca_dev->cam; 773 cam = &gspca_dev->cam;
@@ -790,7 +782,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
790 sd->brightness = BRIGHTNESS_DEF; 782 sd->brightness = BRIGHTNESS_DEF;
791 sd->gain = GAIN_DEF; 783 sd->gain = GAIN_DEF;
792 sd->exposure = EXPOSURE_DEF; 784 sd->exposure = EXPOSURE_DEF;
793 sd->autogain = AUTOGAIN_DEF; 785 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
786 sd->autogain = 0; /* Disable do_autogain callback */
787 else
788 sd->autogain = AUTOGAIN_DEF;
794 sd->freq = FREQ_DEF; 789 sd->freq = FREQ_DEF;
795 790
796 return 0; 791 return 0;
@@ -1169,50 +1164,55 @@ static const struct sd_desc sd_desc = {
1169 .close = sd_close, 1164 .close = sd_close,
1170 .pkt_scan = sd_pkt_scan, 1165 .pkt_scan = sd_pkt_scan,
1171 .querymenu = sd_querymenu, 1166 .querymenu = sd_querymenu,
1167 .dq_callback = do_autogain,
1172}; 1168};
1173 1169
1174/* -- module initialisation -- */ 1170/* -- module initialisation -- */
1175#define SFCI(sensor, flags, nctrls, i2c_addr) \ 1171#define SFCI(sensor, flags, disable_ctrls, i2c_addr) \
1176 .driver_info = (SENSOR_ ## sensor << 24) \ 1172 .driver_info = (SENSOR_ ## sensor << 24) \
1177 | ((flags) << 16) \ 1173 | ((flags) << 16) \
1178 | ((nctrls) << 8) \ 1174 | ((disable_ctrls) << 8) \
1179 | (i2c_addr) 1175 | (i2c_addr)
1176#define NO_EXPO ((1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX))
1177#define NO_FREQ (1 << FREQ_IDX)
1178#define NO_BRIGHTNESS (1 << BRIGHTNESS_IDX)
1179
1180static __devinitdata struct usb_device_id device_table[] = { 1180static __devinitdata struct usb_device_id device_table[] = {
1181#ifndef CONFIG_USB_SN9C102 1181#ifndef CONFIG_USB_SN9C102
1182 {USB_DEVICE(0x0c45, 0x6001), /* SN9C102 */ 1182 {USB_DEVICE(0x0c45, 0x6001), /* SN9C102 */
1183 SFCI(TAS5110, F_GAIN|F_AUTO|F_SIF, 4, 0)}, 1183 SFCI(TAS5110, F_GAIN|F_SIF, NO_BRIGHTNESS|NO_FREQ, 0)},
1184 {USB_DEVICE(0x0c45, 0x6005), /* SN9C101 */ 1184 {USB_DEVICE(0x0c45, 0x6005), /* SN9C101 */
1185 SFCI(TAS5110, F_GAIN|F_AUTO|F_SIF, 4, 0)}, 1185 SFCI(TAS5110, F_GAIN|F_SIF, NO_BRIGHTNESS|NO_FREQ, 0)},
1186 {USB_DEVICE(0x0c45, 0x6007), /* SN9C101 */ 1186 {USB_DEVICE(0x0c45, 0x6007), /* SN9C101 */
1187 SFCI(TAS5110, F_GAIN|F_AUTO|F_SIF, 4, 0)}, 1187 SFCI(TAS5110, F_GAIN|F_SIF, NO_BRIGHTNESS|NO_FREQ, 0)},
1188 {USB_DEVICE(0x0c45, 0x6009), /* SN9C101 */ 1188 {USB_DEVICE(0x0c45, 0x6009), /* SN9C101 */
1189 SFCI(PAS106, F_SIF, 2, 0)}, 1189 SFCI(PAS106, F_SIF, NO_EXPO|NO_FREQ, 0)},
1190 {USB_DEVICE(0x0c45, 0x600d), /* SN9C101 */ 1190 {USB_DEVICE(0x0c45, 0x600d), /* SN9C101 */
1191 SFCI(PAS106, F_SIF, 2, 0)}, 1191 SFCI(PAS106, F_SIF, NO_EXPO|NO_FREQ, 0)},
1192#endif 1192#endif
1193 {USB_DEVICE(0x0c45, 0x6011), /* SN9C101 - SN9C101G */ 1193 {USB_DEVICE(0x0c45, 0x6011), /* SN9C101 - SN9C101G */
1194 SFCI(OV6650, F_GAIN|F_AUTO|F_SIF, 5, 0x60)}, 1194 SFCI(OV6650, F_GAIN|F_SIF, 0, 0x60)},
1195#ifndef CONFIG_USB_SN9C102 1195#ifndef CONFIG_USB_SN9C102
1196 {USB_DEVICE(0x0c45, 0x6019), /* SN9C101 */ 1196 {USB_DEVICE(0x0c45, 0x6019), /* SN9C101 */
1197 SFCI(OV7630, F_GAIN|F_AUTO, 5, 0x21)}, 1197 SFCI(OV7630, F_GAIN, 0, 0x21)},
1198 {USB_DEVICE(0x0c45, 0x6024), /* SN9C102 */ 1198 {USB_DEVICE(0x0c45, 0x6024), /* SN9C102 */
1199 SFCI(TAS5130CXX, 0, 2, 0)}, 1199 SFCI(TAS5130CXX, 0, NO_EXPO|NO_FREQ, 0)},
1200 {USB_DEVICE(0x0c45, 0x6025), /* SN9C102 */ 1200 {USB_DEVICE(0x0c45, 0x6025), /* SN9C102 */
1201 SFCI(TAS5130CXX, 0, 2, 0)}, 1201 SFCI(TAS5130CXX, 0, NO_EXPO|NO_FREQ, 0)},
1202 {USB_DEVICE(0x0c45, 0x6028), /* SN9C102 */ 1202 {USB_DEVICE(0x0c45, 0x6028), /* SN9C102 */
1203 SFCI(PAS202, 0, 2, 0)}, 1203 SFCI(PAS202, 0, NO_EXPO|NO_FREQ, 0)},
1204 {USB_DEVICE(0x0c45, 0x6029), /* SN9C101 */ 1204 {USB_DEVICE(0x0c45, 0x6029), /* SN9C101 */
1205 SFCI(PAS106, F_SIF, 2, 0)}, 1205 SFCI(PAS106, F_SIF, NO_EXPO|NO_FREQ, 0)},
1206 {USB_DEVICE(0x0c45, 0x602c), /* SN9C102 */ 1206 {USB_DEVICE(0x0c45, 0x602c), /* SN9C102 */
1207 SFCI(OV7630, F_GAIN|F_AUTO, 5, 0x21)}, 1207 SFCI(OV7630, F_GAIN, 0, 0x21)},
1208 {USB_DEVICE(0x0c45, 0x602d), /* SN9C102 */ 1208 {USB_DEVICE(0x0c45, 0x602d), /* SN9C102 */
1209 SFCI(HV7131R, 0, 2, 0)}, 1209 SFCI(HV7131R, 0, NO_EXPO|NO_FREQ, 0)},
1210 {USB_DEVICE(0x0c45, 0x602e), /* SN9C102 */ 1210 {USB_DEVICE(0x0c45, 0x602e), /* SN9C102 */
1211 SFCI(OV7630, F_GAIN|F_AUTO, 5, 0x21)}, 1211 SFCI(OV7630, F_GAIN, 0, 0x21)},
1212 {USB_DEVICE(0x0c45, 0x60af), /* SN9C103 */ 1212 {USB_DEVICE(0x0c45, 0x60af), /* SN9C103 */
1213 SFCI(PAS202, F_H18, 2, 0)}, 1213 SFCI(PAS202, F_H18, NO_EXPO|NO_FREQ, 0)},
1214 {USB_DEVICE(0x0c45, 0x60b0), /* SN9C103 */ 1214 {USB_DEVICE(0x0c45, 0x60b0), /* SN9C103 */
1215 SFCI(OV7630, F_GAIN|F_AUTO|F_H18, 5, 0x21)}, 1215 SFCI(OV7630, F_GAIN|F_H18, 0, 0x21)},
1216#endif 1216#endif
1217 {} 1217 {}
1218}; 1218};