aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sonixj.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-09-08 20:55:21 -0400
committerDan Williams <dan.j.williams@intel.com>2009-09-08 20:55:21 -0400
commitbbb20089a3275a19e475dbc21320c3742e3ca423 (patch)
tree216fdc1cbef450ca688135c5b8969169482d9a48 /drivers/media/video/gspca/sonixj.c
parent3e48e656903e9fd8bc805c6a2c4264d7808d315b (diff)
parent657a77fa7284d8ae28dfa48f1dc5d919bf5b2843 (diff)
Merge branch 'dmaengine' into async-tx-next
Conflicts: crypto/async_tx/async_xor.c drivers/dma/ioat/dma_v2.h drivers/dma/ioat/pci.c drivers/md/raid5.c
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r--drivers/media/video/gspca/sonixj.c247
1 files changed, 186 insertions, 61 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index c72e19d3ac37..0d02f41fa7d0 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -46,6 +46,7 @@ struct sd {
46 u8 gamma; 46 u8 gamma;
47 u8 vflip; /* ov7630/ov7648 only */ 47 u8 vflip; /* ov7630/ov7648 only */
48 u8 infrared; /* mt9v111 only */ 48 u8 infrared; /* mt9v111 only */
49 u8 freq; /* ov76xx only */
49 u8 quality; /* image quality */ 50 u8 quality; /* image quality */
50#define QUALITY_MIN 60 51#define QUALITY_MIN 60
51#define QUALITY_MAX 95 52#define QUALITY_MAX 95
@@ -62,7 +63,6 @@ struct sd {
62#define BRIDGE_SN9C105 1 63#define BRIDGE_SN9C105 1
63#define BRIDGE_SN9C110 2 64#define BRIDGE_SN9C110 2
64#define BRIDGE_SN9C120 3 65#define BRIDGE_SN9C120 3
65#define BRIDGE_SN9C325 4
66 u8 sensor; /* Type of image sensor chip */ 66 u8 sensor; /* Type of image sensor chip */
67#define SENSOR_HV7131R 0 67#define SENSOR_HV7131R 0
68#define SENSOR_MI0360 1 68#define SENSOR_MI0360 1
@@ -97,8 +97,11 @@ static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
97static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); 97static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
98static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val); 98static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
99static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val); 99static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
100static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
101static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
100 102
101static struct ctrl sd_ctrls[] = { 103static struct ctrl sd_ctrls[] = {
104#define BRIGHTNESS_IDX 0
102 { 105 {
103 { 106 {
104 .id = V4L2_CID_BRIGHTNESS, 107 .id = V4L2_CID_BRIGHTNESS,
@@ -114,6 +117,7 @@ static struct ctrl sd_ctrls[] = {
114 .set = sd_setbrightness, 117 .set = sd_setbrightness,
115 .get = sd_getbrightness, 118 .get = sd_getbrightness,
116 }, 119 },
120#define CONTRAST_IDX 1
117 { 121 {
118 { 122 {
119 .id = V4L2_CID_CONTRAST, 123 .id = V4L2_CID_CONTRAST,
@@ -129,20 +133,22 @@ static struct ctrl sd_ctrls[] = {
129 .set = sd_setcontrast, 133 .set = sd_setcontrast,
130 .get = sd_getcontrast, 134 .get = sd_getcontrast,
131 }, 135 },
136#define COLOR_IDX 2
132 { 137 {
133 { 138 {
134 .id = V4L2_CID_SATURATION, 139 .id = V4L2_CID_SATURATION,
135 .type = V4L2_CTRL_TYPE_INTEGER, 140 .type = V4L2_CTRL_TYPE_INTEGER,
136 .name = "Color", 141 .name = "Saturation",
137 .minimum = 0, 142 .minimum = 0,
138 .maximum = 40, 143 .maximum = 40,
139 .step = 1, 144 .step = 1,
140#define COLOR_DEF 32 145#define COLOR_DEF 25
141 .default_value = COLOR_DEF, 146 .default_value = COLOR_DEF,
142 }, 147 },
143 .set = sd_setcolors, 148 .set = sd_setcolors,
144 .get = sd_getcolors, 149 .get = sd_getcolors,
145 }, 150 },
151#define BLUE_BALANCE_IDX 3
146 { 152 {
147 { 153 {
148 .id = V4L2_CID_BLUE_BALANCE, 154 .id = V4L2_CID_BLUE_BALANCE,
@@ -157,6 +163,7 @@ static struct ctrl sd_ctrls[] = {
157 .set = sd_setblue_balance, 163 .set = sd_setblue_balance,
158 .get = sd_getblue_balance, 164 .get = sd_getblue_balance,
159 }, 165 },
166#define RED_BALANCE_IDX 4
160 { 167 {
161 { 168 {
162 .id = V4L2_CID_RED_BALANCE, 169 .id = V4L2_CID_RED_BALANCE,
@@ -171,6 +178,7 @@ static struct ctrl sd_ctrls[] = {
171 .set = sd_setred_balance, 178 .set = sd_setred_balance,
172 .get = sd_getred_balance, 179 .get = sd_getred_balance,
173 }, 180 },
181#define GAMMA_IDX 5
174 { 182 {
175 { 183 {
176 .id = V4L2_CID_GAMMA, 184 .id = V4L2_CID_GAMMA,
@@ -185,7 +193,7 @@ static struct ctrl sd_ctrls[] = {
185 .set = sd_setgamma, 193 .set = sd_setgamma,
186 .get = sd_getgamma, 194 .get = sd_getgamma,
187 }, 195 },
188#define AUTOGAIN_IDX 5 196#define AUTOGAIN_IDX 6
189 { 197 {
190 { 198 {
191 .id = V4L2_CID_AUTOGAIN, 199 .id = V4L2_CID_AUTOGAIN,
@@ -201,7 +209,7 @@ static struct ctrl sd_ctrls[] = {
201 .get = sd_getautogain, 209 .get = sd_getautogain,
202 }, 210 },
203/* ov7630/ov7648 only */ 211/* ov7630/ov7648 only */
204#define VFLIP_IDX 6 212#define VFLIP_IDX 7
205 { 213 {
206 { 214 {
207 .id = V4L2_CID_VFLIP, 215 .id = V4L2_CID_VFLIP,
@@ -210,14 +218,14 @@ static struct ctrl sd_ctrls[] = {
210 .minimum = 0, 218 .minimum = 0,
211 .maximum = 1, 219 .maximum = 1,
212 .step = 1, 220 .step = 1,
213#define VFLIP_DEF 0 /* vflip def = 1 for ov7630 */ 221#define VFLIP_DEF 0
214 .default_value = VFLIP_DEF, 222 .default_value = VFLIP_DEF,
215 }, 223 },
216 .set = sd_setvflip, 224 .set = sd_setvflip,
217 .get = sd_getvflip, 225 .get = sd_getvflip,
218 }, 226 },
219/* mt9v111 only */ 227/* mt9v111 only */
220#define INFRARED_IDX 7 228#define INFRARED_IDX 8
221 { 229 {
222 { 230 {
223 .id = V4L2_CID_INFRARED, 231 .id = V4L2_CID_INFRARED,
@@ -232,28 +240,44 @@ static struct ctrl sd_ctrls[] = {
232 .set = sd_setinfrared, 240 .set = sd_setinfrared,
233 .get = sd_getinfrared, 241 .get = sd_getinfrared,
234 }, 242 },
243/* ov7630/ov7648/ov7660 only */
244#define FREQ_IDX 9
245 {
246 {
247 .id = V4L2_CID_POWER_LINE_FREQUENCY,
248 .type = V4L2_CTRL_TYPE_MENU,
249 .name = "Light frequency filter",
250 .minimum = 0,
251 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
252 .step = 1,
253#define FREQ_DEF 2
254 .default_value = FREQ_DEF,
255 },
256 .set = sd_setfreq,
257 .get = sd_getfreq,
258 },
235}; 259};
236 260
237/* table of the disabled controls */ 261/* table of the disabled controls */
238static __u32 ctrl_dis[] = { 262static __u32 ctrl_dis[] = {
239 (1 << INFRARED_IDX) | (1 << VFLIP_IDX), 263 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
240 /* SENSOR_HV7131R 0 */ 264 /* SENSOR_HV7131R 0 */
241 (1 << INFRARED_IDX) | (1 << VFLIP_IDX), 265 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
242 /* SENSOR_MI0360 1 */ 266 /* SENSOR_MI0360 1 */
243 (1 << INFRARED_IDX) | (1 << VFLIP_IDX), 267 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
244 /* SENSOR_MO4000 2 */ 268 /* SENSOR_MO4000 2 */
245 (1 << VFLIP_IDX), 269 (1 << VFLIP_IDX) | (1 << FREQ_IDX),
246 /* SENSOR_MT9V111 3 */ 270 /* SENSOR_MT9V111 3 */
247 (1 << INFRARED_IDX) | (1 << VFLIP_IDX), 271 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
248 /* SENSOR_OM6802 4 */ 272 /* SENSOR_OM6802 4 */
249 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX), 273 (1 << INFRARED_IDX),
250 /* SENSOR_OV7630 5 */ 274 /* SENSOR_OV7630 5 */
251 (1 << INFRARED_IDX), 275 (1 << INFRARED_IDX),
252 /* SENSOR_OV7648 6 */ 276 /* SENSOR_OV7648 6 */
253 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), 277 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
254 /* SENSOR_OV7660 7 */ 278 /* SENSOR_OV7660 7 */
255 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), 279 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) |
256 /* SENSOR_SP80708 8 */ 280 (1 << FREQ_IDX), /* SENSOR_SP80708 8 */
257}; 281};
258 282
259static const struct v4l2_pix_format vga_mode[] = { 283static const struct v4l2_pix_format vga_mode[] = {
@@ -269,7 +293,8 @@ static const struct v4l2_pix_format vga_mode[] = {
269 .priv = 1}, 293 .priv = 1},
270 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 294 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
271 .bytesperline = 640, 295 .bytesperline = 640,
272 .sizeimage = 640 * 480 * 3 / 8 + 590, 296 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
297 .sizeimage = 640 * 480 * 3 / 4 + 590,
273 .colorspace = V4L2_COLORSPACE_JPEG, 298 .colorspace = V4L2_COLORSPACE_JPEG,
274 .priv = 0}, 299 .priv = 0},
275}; 300};
@@ -354,9 +379,9 @@ static const u8 sn_ov7648[0x1c] = {
354 379
355static const u8 sn_ov7660[0x1c] = { 380static const u8 sn_ov7660[0x1c] = {
356/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ 381/* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
357 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, 382 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
358/* reg8 reg9 rega regb regc regd rege regf */ 383/* reg8 reg9 rega regb regc regd rege regf */
359 0x81, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10, 384 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
360/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ 385/* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
361 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20, 386 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
362/* reg18 reg19 reg1a reg1b */ 387/* reg18 reg19 reg1a reg1b */
@@ -605,7 +630,9 @@ static const u8 ov7630_sensor_init[][8] = {
605/* win: i2c_r from 00 to 80 */ 630/* win: i2c_r from 00 to 80 */
606 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, 631 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
607 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10}, 632 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
608 {0xd1, 0x21, 0x11, 0x00, 0x48, 0xc0, 0x00, 0x10}, 633/* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
634 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
635 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
609 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10}, 636 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
610 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, 637 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
611 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, 638 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
@@ -639,9 +666,8 @@ static const u8 ov7630_sensor_init[][8] = {
639 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, 666 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
640 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10}, 667 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
641/* */ 668/* */
642 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10}, 669/* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
643 {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, 670/* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
644 {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10},
645/* */ 671/* */
646 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10}, 672 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
647/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */ 673/* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
@@ -674,7 +700,7 @@ static const u8 ov7648_sensor_init[][8] = {
674 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10}, 700 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
675/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */ 701/* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
676/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */ 702/* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
677 {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, 703/* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
678/*...*/ 704/*...*/
679/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */ 705/* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
680/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN 706/* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
@@ -757,6 +783,7 @@ static const u8 ov7660_sensor_init[][8] = {
757 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */ 783 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
758 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */ 784 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
759 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */ 785 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
786 {0xb1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
760/****** (some exchanges in the win trace) ******/ 787/****** (some exchanges in the win trace) ******/
761 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */ 788 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
762 /* bits[3..0]reserved */ 789 /* bits[3..0]reserved */
@@ -1065,9 +1092,9 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
1065 struct sd *sd = (struct sd *) gspca_dev; 1092 struct sd *sd = (struct sd *) gspca_dev;
1066 const u8 *reg9a; 1093 const u8 *reg9a;
1067 static const u8 reg9a_def[] = 1094 static const u8 reg9a_def[] =
1068 {0x08, 0x40, 0x20, 0x10, 0x00, 0x04}; 1095 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1069 static const u8 reg9a_sn9c325[] = 1096 static const u8 reg9a_spec[] =
1070 {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20}; 1097 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
1071 static const u8 regd4[] = {0x60, 0x00, 0x00}; 1098 static const u8 regd4[] = {0x60, 0x00, 0x00};
1072 1099
1073 reg_w1(gspca_dev, 0xf1, 0x00); 1100 reg_w1(gspca_dev, 0xf1, 0x00);
@@ -1077,9 +1104,10 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
1077 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2); 1104 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
1078 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2); 1105 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
1079 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */ 1106 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
1080 switch (sd->bridge) { 1107 switch (sd->sensor) {
1081 case BRIDGE_SN9C325: 1108 case SENSOR_OV7660:
1082 reg9a = reg9a_sn9c325; 1109 case SENSOR_SP80708:
1110 reg9a = reg9a_spec;
1083 break; 1111 break;
1084 default: 1112 default:
1085 reg9a = reg9a_def; 1113 reg9a = reg9a_def;
@@ -1104,7 +1132,6 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
1104 reg_w1(gspca_dev, 0x17, 0x64); 1132 reg_w1(gspca_dev, 0x17, 0x64);
1105 reg_w1(gspca_dev, 0x01, 0x42); 1133 reg_w1(gspca_dev, 0x01, 0x42);
1106 break; 1134 break;
1107/*jfm: from win trace */
1108 case SENSOR_OV7630: 1135 case SENSOR_OV7630:
1109 reg_w1(gspca_dev, 0x01, 0x61); 1136 reg_w1(gspca_dev, 0x01, 0x61);
1110 reg_w1(gspca_dev, 0x17, 0xe2); 1137 reg_w1(gspca_dev, 0x17, 0xe2);
@@ -1114,18 +1141,15 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
1114 case SENSOR_OV7648: 1141 case SENSOR_OV7648:
1115 reg_w1(gspca_dev, 0x01, 0x63); 1142 reg_w1(gspca_dev, 0x01, 0x63);
1116 reg_w1(gspca_dev, 0x17, 0x20); 1143 reg_w1(gspca_dev, 0x17, 0x20);
1144 reg_w1(gspca_dev, 0x01, 0x62);
1117 reg_w1(gspca_dev, 0x01, 0x42); 1145 reg_w1(gspca_dev, 0x01, 0x42);
1118 break; 1146 break;
1119/*jfm: from win trace */
1120 case SENSOR_OV7660: 1147 case SENSOR_OV7660:
1121 if (sd->bridge == BRIDGE_SN9C120) { 1148 reg_w1(gspca_dev, 0x01, 0x61);
1122 reg_w1(gspca_dev, 0x01, 0x61); 1149 reg_w1(gspca_dev, 0x17, 0x20);
1123 reg_w1(gspca_dev, 0x17, 0x20); 1150 reg_w1(gspca_dev, 0x01, 0x60);
1124 reg_w1(gspca_dev, 0x01, 0x60); 1151 reg_w1(gspca_dev, 0x01, 0x40);
1125 reg_w1(gspca_dev, 0x01, 0x40); 1152 break;
1126 break;
1127 }
1128 /* fall thru */
1129 case SENSOR_SP80708: 1153 case SENSOR_SP80708:
1130 reg_w1(gspca_dev, 0x01, 0x63); 1154 reg_w1(gspca_dev, 0x01, 0x63);
1131 reg_w1(gspca_dev, 0x17, 0x20); 1155 reg_w1(gspca_dev, 0x17, 0x20);
@@ -1134,6 +1158,9 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
1134 mdelay(100); 1158 mdelay(100);
1135 reg_w1(gspca_dev, 0x02, 0x62); 1159 reg_w1(gspca_dev, 0x02, 0x62);
1136 break; 1160 break;
1161/* case SENSOR_HV7131R: */
1162/* case SENSOR_MI0360: */
1163/* case SENSOR_MO4000: */
1137 default: 1164 default:
1138 reg_w1(gspca_dev, 0x01, 0x43); 1165 reg_w1(gspca_dev, 0x01, 0x43);
1139 reg_w1(gspca_dev, 0x17, 0x61); 1166 reg_w1(gspca_dev, 0x17, 0x61);
@@ -1280,6 +1307,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
1280 cam = &gspca_dev->cam; 1307 cam = &gspca_dev->cam;
1281 cam->cam_mode = vga_mode; 1308 cam->cam_mode = vga_mode;
1282 cam->nmodes = ARRAY_SIZE(vga_mode); 1309 cam->nmodes = ARRAY_SIZE(vga_mode);
1310 cam->npkt = 24; /* 24 packets per ISOC message */
1283 1311
1284 sd->bridge = id->driver_info >> 16; 1312 sd->bridge = id->driver_info >> 16;
1285 sd->sensor = id->driver_info >> 8; 1313 sd->sensor = id->driver_info >> 8;
@@ -1293,11 +1321,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
1293 sd->gamma = GAMMA_DEF; 1321 sd->gamma = GAMMA_DEF;
1294 sd->autogain = AUTOGAIN_DEF; 1322 sd->autogain = AUTOGAIN_DEF;
1295 sd->ag_cnt = -1; 1323 sd->ag_cnt = -1;
1296 if (sd->sensor != SENSOR_OV7630) 1324 sd->vflip = VFLIP_DEF;
1297 sd->vflip = 0;
1298 else
1299 sd->vflip = 1;
1300 sd->infrared = INFRARED_DEF; 1325 sd->infrared = INFRARED_DEF;
1326 sd->freq = FREQ_DEF;
1301 sd->quality = QUALITY_DEF; 1327 sd->quality = QUALITY_DEF;
1302 sd->jpegqual = 80; 1328 sd->jpegqual = 80;
1303 1329
@@ -1568,7 +1594,7 @@ static void setautogain(struct gspca_dev *gspca_dev)
1568 else 1594 else
1569 comb = 0xa0; 1595 comb = 0xa0;
1570 if (sd->autogain) 1596 if (sd->autogain)
1571 comb |= 0x02; 1597 comb |= 0x03;
1572 i2c_w1(&sd->gspca_dev, 0x13, comb); 1598 i2c_w1(&sd->gspca_dev, 0x13, comb);
1573 return; 1599 return;
1574 } 1600 }
@@ -1584,12 +1610,15 @@ static void setvflip(struct sd *sd)
1584{ 1610{
1585 u8 comn; 1611 u8 comn;
1586 1612
1587 if (sd->sensor == SENSOR_OV7630) 1613 if (sd->sensor == SENSOR_OV7630) {
1588 comn = 0x02; 1614 comn = 0x02;
1589 else 1615 if (!sd->vflip)
1616 comn |= 0x80;
1617 } else {
1590 comn = 0x06; 1618 comn = 0x06;
1591 if (sd->vflip) 1619 if (sd->vflip)
1592 comn |= 0x80; 1620 comn |= 0x80;
1621 }
1593 i2c_w1(&sd->gspca_dev, 0x75, comn); 1622 i2c_w1(&sd->gspca_dev, 0x75, comn);
1594} 1623}
1595 1624
@@ -1601,6 +1630,58 @@ static void setinfrared(struct sd *sd)
1601 sd->infrared ? 0x66 : 0x64); 1630 sd->infrared ? 0x66 : 0x64);
1602} 1631}
1603 1632
1633static void setfreq(struct gspca_dev *gspca_dev)
1634{
1635 struct sd *sd = (struct sd *) gspca_dev;
1636
1637 if (sd->sensor == SENSOR_OV7660) {
1638 switch (sd->freq) {
1639 case 0: /* Banding filter disabled */
1640 i2c_w1(gspca_dev, 0x13, 0xdf);
1641 break;
1642 case 1: /* 50 hz */
1643 i2c_w1(gspca_dev, 0x13, 0xff);
1644 i2c_w1(gspca_dev, 0x3b, 0x0a);
1645 break;
1646 case 2: /* 60 hz */
1647 i2c_w1(gspca_dev, 0x13, 0xff);
1648 i2c_w1(gspca_dev, 0x3b, 0x02);
1649 break;
1650 }
1651 } else {
1652 u8 reg2a = 0, reg2b = 0, reg2d = 0;
1653
1654 /* Get reg2a / reg2d base values */
1655 switch (sd->sensor) {
1656 case SENSOR_OV7630:
1657 reg2a = 0x08;
1658 reg2d = 0x01;
1659 break;
1660 case SENSOR_OV7648:
1661 reg2a = 0x11;
1662 reg2d = 0x81;
1663 break;
1664 }
1665
1666 switch (sd->freq) {
1667 case 0: /* Banding filter disabled */
1668 break;
1669 case 1: /* 50 hz (filter on and framerate adj) */
1670 reg2a |= 0x80;
1671 reg2b = 0xac;
1672 reg2d |= 0x04;
1673 break;
1674 case 2: /* 60 hz (filter on, no framerate adj) */
1675 reg2a |= 0x80;
1676 reg2d |= 0x04;
1677 break;
1678 }
1679 i2c_w1(gspca_dev, 0x2a, reg2a);
1680 i2c_w1(gspca_dev, 0x2b, reg2b);
1681 i2c_w1(gspca_dev, 0x2d, reg2d);
1682 }
1683}
1684
1604static void setjpegqual(struct gspca_dev *gspca_dev) 1685static void setjpegqual(struct gspca_dev *gspca_dev)
1605{ 1686{
1606 struct sd *sd = (struct sd *) gspca_dev; 1687 struct sd *sd = (struct sd *) gspca_dev;
@@ -1683,13 +1764,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
1683 case SENSOR_OV7648: 1764 case SENSOR_OV7648:
1684 reg17 = 0x20; 1765 reg17 = 0x20;
1685 break; 1766 break;
1686/*jfm: from win trace */
1687 case SENSOR_OV7660: 1767 case SENSOR_OV7660:
1688 if (sd->bridge == BRIDGE_SN9C120) { 1768 reg17 = 0xa0;
1689 reg17 = 0xa0; 1769 break;
1690 break;
1691 }
1692 /* fall thru */
1693 default: 1770 default:
1694 reg17 = 0x60; 1771 reg17 = 0x60;
1695 break; 1772 break;
@@ -1714,16 +1791,17 @@ static int sd_start(struct gspca_dev *gspca_dev)
1714 reg_w1(gspca_dev, 0x9a, 0x0a); 1791 reg_w1(gspca_dev, 0x9a, 0x0a);
1715 reg_w1(gspca_dev, 0x99, 0x60); 1792 reg_w1(gspca_dev, 0x99, 0x60);
1716 break; 1793 break;
1794 case SENSOR_OV7660:
1795 reg_w1(gspca_dev, 0x9a, 0x05);
1796 if (sd->bridge == BRIDGE_SN9C105)
1797 reg_w1(gspca_dev, 0x99, 0xff);
1798 else
1799 reg_w1(gspca_dev, 0x99, 0x5b);
1800 break;
1717 case SENSOR_SP80708: 1801 case SENSOR_SP80708:
1718 reg_w1(gspca_dev, 0x9a, 0x05); 1802 reg_w1(gspca_dev, 0x9a, 0x05);
1719 reg_w1(gspca_dev, 0x99, 0x59); 1803 reg_w1(gspca_dev, 0x99, 0x59);
1720 break; 1804 break;
1721 case SENSOR_OV7660:
1722 if (sd->bridge == BRIDGE_SN9C120) {
1723 reg_w1(gspca_dev, 0x9a, 0x05);
1724 break;
1725 }
1726 /* fall thru */
1727 default: 1805 default:
1728 reg_w1(gspca_dev, 0x9a, 0x08); 1806 reg_w1(gspca_dev, 0x9a, 0x08);
1729 reg_w1(gspca_dev, 0x99, 0x59); 1807 reg_w1(gspca_dev, 0x99, 0x59);
@@ -1830,6 +1908,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
1830 setbrightness(gspca_dev); 1908 setbrightness(gspca_dev);
1831 setcontrast(gspca_dev); 1909 setcontrast(gspca_dev);
1832 setautogain(gspca_dev); 1910 setautogain(gspca_dev);
1911 setfreq(gspca_dev);
1833 return 0; 1912 return 0;
1834} 1913}
1835 1914
@@ -2133,6 +2212,24 @@ static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2133 return 0; 2212 return 0;
2134} 2213}
2135 2214
2215static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
2216{
2217 struct sd *sd = (struct sd *) gspca_dev;
2218
2219 sd->freq = val;
2220 if (gspca_dev->streaming)
2221 setfreq(gspca_dev);
2222 return 0;
2223}
2224
2225static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2226{
2227 struct sd *sd = (struct sd *) gspca_dev;
2228
2229 *val = sd->freq;
2230 return 0;
2231}
2232
2136static int sd_set_jcomp(struct gspca_dev *gspca_dev, 2233static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2137 struct v4l2_jpegcompression *jcomp) 2234 struct v4l2_jpegcompression *jcomp)
2138{ 2235{
@@ -2161,6 +2258,27 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2161 return 0; 2258 return 0;
2162} 2259}
2163 2260
2261static int sd_querymenu(struct gspca_dev *gspca_dev,
2262 struct v4l2_querymenu *menu)
2263{
2264 switch (menu->id) {
2265 case V4L2_CID_POWER_LINE_FREQUENCY:
2266 switch (menu->index) {
2267 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2268 strcpy((char *) menu->name, "NoFliker");
2269 return 0;
2270 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2271 strcpy((char *) menu->name, "50 Hz");
2272 return 0;
2273 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2274 strcpy((char *) menu->name, "60 Hz");
2275 return 0;
2276 }
2277 break;
2278 }
2279 return -EINVAL;
2280}
2281
2164/* sub-driver description */ 2282/* sub-driver description */
2165static const struct sd_desc sd_desc = { 2283static const struct sd_desc sd_desc = {
2166 .name = MODULE_NAME, 2284 .name = MODULE_NAME,
@@ -2175,6 +2293,7 @@ static const struct sd_desc sd_desc = {
2175 .dq_callback = do_autogain, 2293 .dq_callback = do_autogain,
2176 .get_jcomp = sd_get_jcomp, 2294 .get_jcomp = sd_get_jcomp,
2177 .set_jcomp = sd_set_jcomp, 2295 .set_jcomp = sd_set_jcomp,
2296 .querymenu = sd_querymenu,
2178}; 2297};
2179 2298
2180/* -- module initialisation -- */ 2299/* -- module initialisation -- */
@@ -2193,6 +2312,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
2193 {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)}, 2312 {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)},
2194 {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)}, 2313 {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)},
2195 {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)}, 2314 {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)},
2315 {USB_DEVICE(0x06f8, 0x3008), BSI(SN9C105, OV7660, 0x21)},
2196 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, HV7131R, 0x11)}, 2316 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, HV7131R, 0x11)},
2197/* bw600.inf: 2317/* bw600.inf:
2198 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, MI0360, 0x5d)}, */ 2318 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, MI0360, 0x5d)}, */
@@ -2211,7 +2331,12 @@ static const __devinitdata struct usb_device_id device_table[] = {
2211#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 2331#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2212 {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)}, 2332 {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)},
2213#endif 2333#endif
2334 {USB_DEVICE(0x0c45, 0x6100), BSI(SN9C120, MI0360, 0x5d)}, /*sn9c128*/
2214/* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */ 2335/* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */
2336 {USB_DEVICE(0x0c45, 0x610a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c128*/
2337 {USB_DEVICE(0x0c45, 0x610b), BSI(SN9C120, OV7660, 0x21)}, /*sn9c128*/
2338 {USB_DEVICE(0x0c45, 0x610c), BSI(SN9C120, HV7131R, 0x11)}, /*sn9c128*/
2339 {USB_DEVICE(0x0c45, 0x610e), BSI(SN9C120, OV7630, 0x21)}, /*sn9c128*/
2215/* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */ 2340/* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */
2216/* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */ 2341/* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */
2217 {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C110, OM6802, 0x21)}, /*sn9c325?*/ 2342 {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C110, OM6802, 0x21)}, /*sn9c325?*/
@@ -2229,7 +2354,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
2229 {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)}, 2354 {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)},
2230#endif 2355#endif
2231 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, 2356 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)},
2232/* {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x??)}, */ 2357 {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x21)},
2233 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)}, 2358 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)},
2234 {} 2359 {}
2235}; 2360};