aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/zc3xx.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-01-06 21:32:12 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-06 21:32:12 -0500
commit9e9bc9736756f25d6c47b4eba0ebf25b20a6f153 (patch)
tree647240f479c5f23910c3e6194d1c35b6ba54d75e /drivers/media/video/gspca/zc3xx.c
parent3c0cb7c31c206aaedb967e44b98442bbeb17a6c4 (diff)
parente3c92215198cb6aa00ad38db2780faa6b72e0a3f (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (255 commits) [media] radio-aimslab.c: Fix gcc 4.5+ bug [media] cx25821: Fix compilation breakage due to BKL dependency [media] v4l2-compat-ioctl32: fix compile warning [media] zoran: fix compiler warning [media] tda18218: fix compile warning [media] ngene: fix compile warning [media] DVB: IR support for TechnoTrend CT-3650 [media] cx23885, cimax2.c: Fix case of two CAM insertion irq [media] ir-nec-decoder: fix repeat key issue [media] staging: se401 depends on USB [media] staging: usbvideo/vicam depends on USB [media] soc_camera: Add the ability to bind regulators to soc_camedra devices [media] V4L2: Add a v4l2-subdev (soc-camera) driver for OmniVision OV2640 sensor [media] v4l: soc-camera: switch to .unlocked_ioctl [media] v4l: ov772x: simplify pointer dereference [media] ov9640: fix OmniVision OV9640 sensor driver's priv data retrieving [media] ov9640: use macro to request OmniVision OV9640 sensor private data [media] ivtv-i2c: Fix two warnings [media] staging/lirc: Update lirc TODO files [media] cx88: Remove the obsolete i2c_adapter.id field ...
Diffstat (limited to 'drivers/media/video/gspca/zc3xx.c')
-rw-r--r--drivers/media/video/gspca/zc3xx.c292
1 files changed, 84 insertions, 208 deletions
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index c7e1970ca284..14b85d483163 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -35,16 +35,23 @@ static int force_sensor = -1;
35#define QUANT_VAL 1 /* quantization table */ 35#define QUANT_VAL 1 /* quantization table */
36#include "zc3xx-reg.h" 36#include "zc3xx-reg.h"
37 37
38/* controls */
39enum e_ctrl {
40 BRIGHTNESS,
41 CONTRAST,
42 GAMMA,
43 AUTOGAIN,
44 LIGHTFREQ,
45 SHARPNESS,
46 NCTRLS /* number of controls */
47};
48
38/* specific webcam descriptor */ 49/* specific webcam descriptor */
39struct sd { 50struct sd {
40 struct gspca_dev gspca_dev; /* !! must be the first item */ 51 struct gspca_dev gspca_dev; /* !! must be the first item */
41 52
42 u8 brightness; 53 struct gspca_ctrl ctrls[NCTRLS];
43 u8 contrast; 54
44 u8 gamma;
45 u8 autogain;
46 u8 lightfreq;
47 u8 sharpness;
48 u8 quality; /* image quality */ 55 u8 quality; /* image quality */
49#define QUALITY_MIN 50 56#define QUALITY_MIN 50
50#define QUALITY_MAX 80 57#define QUALITY_MAX 80
@@ -64,6 +71,7 @@ enum sensors {
64 SENSOR_ADCM2700, 71 SENSOR_ADCM2700,
65 SENSOR_CS2102, 72 SENSOR_CS2102,
66 SENSOR_CS2102K, 73 SENSOR_CS2102K,
74 SENSOR_GC0303,
67 SENSOR_GC0305, 75 SENSOR_GC0305,
68 SENSOR_HDCS2020b, 76 SENSOR_HDCS2020b,
69 SENSOR_HV7131B, 77 SENSOR_HV7131B,
@@ -79,26 +87,17 @@ enum sensors {
79 SENSOR_PB0330, 87 SENSOR_PB0330,
80 SENSOR_PO2030, 88 SENSOR_PO2030,
81 SENSOR_TAS5130C, 89 SENSOR_TAS5130C,
82 SENSOR_TAS5130C_VF0250,
83 SENSOR_MAX 90 SENSOR_MAX
84}; 91};
85 92
86/* V4L2 controls supported by the driver */ 93/* V4L2 controls supported by the driver */
87static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); 94static void setcontrast(struct gspca_dev *gspca_dev);
88static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); 95static void setautogain(struct gspca_dev *gspca_dev);
89static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); 96static void setlightfreq(struct gspca_dev *gspca_dev);
90static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); 97static void setsharpness(struct gspca_dev *gspca_dev);
91static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); 98
92static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 99static const struct ctrl sd_ctrls[NCTRLS] = {
93static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val); 100[BRIGHTNESS] = {
94static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
95static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
96static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
97static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
98static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
99
100static const struct ctrl sd_ctrls[] = {
101 {
102 { 101 {
103 .id = V4L2_CID_BRIGHTNESS, 102 .id = V4L2_CID_BRIGHTNESS,
104 .type = V4L2_CTRL_TYPE_INTEGER, 103 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -106,13 +105,11 @@ static const struct ctrl sd_ctrls[] = {
106 .minimum = 0, 105 .minimum = 0,
107 .maximum = 255, 106 .maximum = 255,
108 .step = 1, 107 .step = 1,
109#define BRIGHTNESS_DEF 128 108 .default_value = 128,
110 .default_value = BRIGHTNESS_DEF,
111 }, 109 },
112 .set = sd_setbrightness, 110 .set_control = setcontrast
113 .get = sd_getbrightness,
114 }, 111 },
115 { 112[CONTRAST] = {
116 { 113 {
117 .id = V4L2_CID_CONTRAST, 114 .id = V4L2_CID_CONTRAST,
118 .type = V4L2_CTRL_TYPE_INTEGER, 115 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -120,13 +117,11 @@ static const struct ctrl sd_ctrls[] = {
120 .minimum = 0, 117 .minimum = 0,
121 .maximum = 255, 118 .maximum = 255,
122 .step = 1, 119 .step = 1,
123#define CONTRAST_DEF 128 120 .default_value = 128,
124 .default_value = CONTRAST_DEF,
125 }, 121 },
126 .set = sd_setcontrast, 122 .set_control = setcontrast
127 .get = sd_getcontrast,
128 }, 123 },
129 { 124[GAMMA] = {
130 { 125 {
131 .id = V4L2_CID_GAMMA, 126 .id = V4L2_CID_GAMMA,
132 .type = V4L2_CTRL_TYPE_INTEGER, 127 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -136,10 +131,9 @@ static const struct ctrl sd_ctrls[] = {
136 .step = 1, 131 .step = 1,
137 .default_value = 4, 132 .default_value = 4,
138 }, 133 },
139 .set = sd_setgamma, 134 .set_control = setcontrast
140 .get = sd_getgamma,
141 }, 135 },
142 { 136[AUTOGAIN] = {
143 { 137 {
144 .id = V4L2_CID_AUTOGAIN, 138 .id = V4L2_CID_AUTOGAIN,
145 .type = V4L2_CTRL_TYPE_BOOLEAN, 139 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -147,14 +141,11 @@ static const struct ctrl sd_ctrls[] = {
147 .minimum = 0, 141 .minimum = 0,
148 .maximum = 1, 142 .maximum = 1,
149 .step = 1, 143 .step = 1,
150#define AUTOGAIN_DEF 1 144 .default_value = 1,
151 .default_value = AUTOGAIN_DEF,
152 }, 145 },
153 .set = sd_setautogain, 146 .set_control = setautogain
154 .get = sd_getautogain,
155 }, 147 },
156#define LIGHTFREQ_IDX 4 148[LIGHTFREQ] = {
157 {
158 { 149 {
159 .id = V4L2_CID_POWER_LINE_FREQUENCY, 150 .id = V4L2_CID_POWER_LINE_FREQUENCY,
160 .type = V4L2_CTRL_TYPE_MENU, 151 .type = V4L2_CTRL_TYPE_MENU,
@@ -162,13 +153,11 @@ static const struct ctrl sd_ctrls[] = {
162 .minimum = 0, 153 .minimum = 0,
163 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ 154 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
164 .step = 1, 155 .step = 1,
165#define FREQ_DEF 0 156 .default_value = 0,
166 .default_value = FREQ_DEF,
167 }, 157 },
168 .set = sd_setfreq, 158 .set_control = setlightfreq
169 .get = sd_getfreq,
170 }, 159 },
171 { 160[SHARPNESS] = {
172 { 161 {
173 .id = V4L2_CID_SHARPNESS, 162 .id = V4L2_CID_SHARPNESS,
174 .type = V4L2_CTRL_TYPE_INTEGER, 163 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -176,11 +165,9 @@ static const struct ctrl sd_ctrls[] = {
176 .minimum = 0, 165 .minimum = 0,
177 .maximum = 3, 166 .maximum = 3,
178 .step = 1, 167 .step = 1,
179#define SHARPNESS_DEF 2 168 .default_value = 2,
180 .default_value = SHARPNESS_DEF,
181 }, 169 },
182 .set = sd_setsharpness, 170 .set_control = setsharpness
183 .get = sd_getsharpness,
184 }, 171 },
185}; 172};
186 173
@@ -4499,7 +4486,7 @@ static const struct usb_action mt9v111_3_Initial[] = {
4499 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, 4486 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
4500 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING}, 4487 {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
4501 {0xa0, 0x0a, ZC3XX_R010_CMOSSENSORSELECT}, 4488 {0xa0, 0x0a, ZC3XX_R010_CMOSSENSORSELECT},
4502 {0xa0, 0x04, ZC3XX_R002_CLOCKSELECT}, 4489 {0xa0, 0x00, ZC3XX_R002_CLOCKSELECT},
4503 {0xa0, 0x02, ZC3XX_R003_FRAMEWIDTHHIGH}, 4490 {0xa0, 0x02, ZC3XX_R003_FRAMEWIDTHHIGH},
4504 {0xa0, 0x80, ZC3XX_R004_FRAMEWIDTHLOW}, 4491 {0xa0, 0x80, ZC3XX_R004_FRAMEWIDTHLOW},
4505 {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH}, 4492 {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH},
@@ -5406,7 +5393,7 @@ static const struct usb_action tas5130c_NoFlikerScale[] = {
5406 {} 5393 {}
5407}; 5394};
5408 5395
5409static const struct usb_action tas5130c_vf0250_InitialScale[] = { 5396static const struct usb_action gc0303_InitialScale[] = {
5410 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc, */ 5397 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc, */
5411 {0xa0, 0x02, ZC3XX_R008_CLOCKSETTING}, /* 00,08,02,cc, */ 5398 {0xa0, 0x02, ZC3XX_R008_CLOCKSETTING}, /* 00,08,02,cc, */
5412 {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc, */ 5399 {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc, */
@@ -5473,7 +5460,7 @@ static const struct usb_action tas5130c_vf0250_InitialScale[] = {
5473 {} 5460 {}
5474}; 5461};
5475 5462
5476static const struct usb_action tas5130c_vf0250_Initial[] = { 5463static const struct usb_action gc0303_Initial[] = {
5477 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc, */ 5464 {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL}, /* 00,00,01,cc, */
5478 {0xa0, 0x02, ZC3XX_R008_CLOCKSETTING}, /* 00,08,02,cc, */ 5465 {0xa0, 0x02, ZC3XX_R008_CLOCKSETTING}, /* 00,08,02,cc, */
5479 {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc, */ 5466 {0xa0, 0x01, ZC3XX_R010_CMOSSENSORSELECT}, /* 00,10,01,cc, */
@@ -5538,7 +5525,7 @@ static const struct usb_action tas5130c_vf0250_Initial[] = {
5538 {0xa0, 0x65, ZC3XX_R118_BGAIN}, /* 01,18,65,cc */ 5525 {0xa0, 0x65, ZC3XX_R118_BGAIN}, /* 01,18,65,cc */
5539 {} 5526 {}
5540}; 5527};
5541static const struct usb_action tas5130c_vf0250_50HZScale[] = { 5528static const struct usb_action gc0303_50HZScale[] = {
5542 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ 5529 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */
5543 {0xaa, 0x83, 0x0001}, /* 00,83,01,aa */ 5530 {0xaa, 0x83, 0x0001}, /* 00,83,01,aa */
5544 {0xaa, 0x84, 0x00aa}, /* 00,84,aa,aa */ 5531 {0xaa, 0x84, 0x00aa}, /* 00,84,aa,aa */
@@ -5562,7 +5549,7 @@ static const struct usb_action tas5130c_vf0250_50HZScale[] = {
5562 {} 5549 {}
5563}; 5550};
5564 5551
5565static const struct usb_action tas5130c_vf0250_50HZ[] = { 5552static const struct usb_action gc0303_50HZ[] = {
5566 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ 5553 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */
5567 {0xaa, 0x83, 0x0003}, /* 00,83,03,aa */ 5554 {0xaa, 0x83, 0x0003}, /* 00,83,03,aa */
5568 {0xaa, 0x84, 0x0054}, /* 00,84,54,aa */ 5555 {0xaa, 0x84, 0x0054}, /* 00,84,54,aa */
@@ -5586,7 +5573,7 @@ static const struct usb_action tas5130c_vf0250_50HZ[] = {
5586 {} 5573 {}
5587}; 5574};
5588 5575
5589static const struct usb_action tas5130c_vf0250_60HZScale[] = { 5576static const struct usb_action gc0303_60HZScale[] = {
5590 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ 5577 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */
5591 {0xaa, 0x83, 0x0001}, /* 00,83,01,aa */ 5578 {0xaa, 0x83, 0x0001}, /* 00,83,01,aa */
5592 {0xaa, 0x84, 0x0062}, /* 00,84,62,aa */ 5579 {0xaa, 0x84, 0x0062}, /* 00,84,62,aa */
@@ -5610,7 +5597,7 @@ static const struct usb_action tas5130c_vf0250_60HZScale[] = {
5610 {} 5597 {}
5611}; 5598};
5612 5599
5613static const struct usb_action tas5130c_vf0250_60HZ[] = { 5600static const struct usb_action gc0303_60HZ[] = {
5614 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ 5601 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */
5615 {0xaa, 0x83, 0x0002}, /* 00,83,02,aa */ 5602 {0xaa, 0x83, 0x0002}, /* 00,83,02,aa */
5616 {0xaa, 0x84, 0x00c4}, /* 00,84,c4,aa */ 5603 {0xaa, 0x84, 0x00c4}, /* 00,84,c4,aa */
@@ -5634,7 +5621,7 @@ static const struct usb_action tas5130c_vf0250_60HZ[] = {
5634 {} 5621 {}
5635}; 5622};
5636 5623
5637static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = { 5624static const struct usb_action gc0303_NoFlikerScale[] = {
5638 {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc, */ 5625 {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc, */
5639 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ 5626 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */
5640 {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */ 5627 {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */
@@ -5656,7 +5643,7 @@ static const struct usb_action tas5130c_vf0250_NoFlikerScale[] = {
5656 {} 5643 {}
5657}; 5644};
5658 5645
5659static const struct usb_action tas5130c_vf0250_NoFliker[] = { 5646static const struct usb_action gc0303_NoFliker[] = {
5660 {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc, */ 5647 {0xa0, 0x0c, ZC3XX_R100_OPERATIONMODE}, /* 01,00,0c,cc, */
5661 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */ 5648 {0xaa, 0x82, 0x0000}, /* 00,82,00,aa */
5662 {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */ 5649 {0xaa, 0x83, 0x0000}, /* 00,83,00,aa */
@@ -5833,12 +5820,13 @@ static void setmatrix(struct gspca_dev *gspca_dev)
5833 {0x60, 0xf0, 0xf0, 0xf0, 0x60, 0xf0, 0xf0, 0xf0, 0x60}; 5820 {0x60, 0xf0, 0xf0, 0xf0, 0x60, 0xf0, 0xf0, 0xf0, 0x60};
5834 static const u8 tas5130c_matrix[9] = 5821 static const u8 tas5130c_matrix[9] =
5835 {0x68, 0xec, 0xec, 0xec, 0x68, 0xec, 0xec, 0xec, 0x68}; 5822 {0x68, 0xec, 0xec, 0xec, 0x68, 0xec, 0xec, 0xec, 0x68};
5836 static const u8 vf0250_matrix[9] = 5823 static const u8 gc0303_matrix[9] =
5837 {0x7b, 0xea, 0xea, 0xea, 0x7b, 0xea, 0xea, 0xea, 0x7b}; 5824 {0x7b, 0xea, 0xea, 0xea, 0x7b, 0xea, 0xea, 0xea, 0x7b};
5838 static const u8 *matrix_tb[SENSOR_MAX] = { 5825 static const u8 *matrix_tb[SENSOR_MAX] = {
5839 [SENSOR_ADCM2700] = adcm2700_matrix, 5826 [SENSOR_ADCM2700] = adcm2700_matrix,
5840 [SENSOR_CS2102] = ov7620_matrix, 5827 [SENSOR_CS2102] = ov7620_matrix,
5841 [SENSOR_CS2102K] = NULL, 5828 [SENSOR_CS2102K] = NULL,
5829 [SENSOR_GC0303] = gc0303_matrix,
5842 [SENSOR_GC0305] = gc0305_matrix, 5830 [SENSOR_GC0305] = gc0305_matrix,
5843 [SENSOR_HDCS2020b] = NULL, 5831 [SENSOR_HDCS2020b] = NULL,
5844 [SENSOR_HV7131B] = NULL, 5832 [SENSOR_HV7131B] = NULL,
@@ -5854,7 +5842,6 @@ static void setmatrix(struct gspca_dev *gspca_dev)
5854 [SENSOR_PB0330] = gc0305_matrix, 5842 [SENSOR_PB0330] = gc0305_matrix,
5855 [SENSOR_PO2030] = po2030_matrix, 5843 [SENSOR_PO2030] = po2030_matrix,
5856 [SENSOR_TAS5130C] = tas5130c_matrix, 5844 [SENSOR_TAS5130C] = tas5130c_matrix,
5857 [SENSOR_TAS5130C_VF0250] = vf0250_matrix,
5858 }; 5845 };
5859 5846
5860 matrix = matrix_tb[sd->sensor]; 5847 matrix = matrix_tb[sd->sensor];
@@ -5875,7 +5862,7 @@ static void setsharpness(struct gspca_dev *gspca_dev)
5875 {0x10, 0x1e} 5862 {0x10, 0x1e}
5876 }; 5863 };
5877 5864
5878 sharpness = sd->sharpness; 5865 sharpness = sd->ctrls[SHARPNESS].val;
5879 reg_w(gspca_dev, sharpness_tb[sharpness][0], 0x01c6); 5866 reg_w(gspca_dev, sharpness_tb[sharpness][0], 0x01c6);
5880 reg_r(gspca_dev, 0x01c8); 5867 reg_r(gspca_dev, 0x01c8);
5881 reg_r(gspca_dev, 0x01c9); 5868 reg_r(gspca_dev, 0x01c9);
@@ -5910,10 +5897,10 @@ static void setcontrast(struct gspca_dev *gspca_dev)
5910 0xe0, 0xeb, 0xf4, 0xff, 0xff, 0xff, 0xff, 0xff}, 5897 0xe0, 0xeb, 0xf4, 0xff, 0xff, 0xff, 0xff, 0xff},
5911 }; 5898 };
5912 5899
5913 Tgamma = gamma_tb[sd->gamma - 1]; 5900 Tgamma = gamma_tb[sd->ctrls[GAMMA].val - 1];
5914 5901
5915 contrast = ((int) sd->contrast - 128); /* -128 / 127 */ 5902 contrast = ((int) sd->ctrls[CONTRAST].val - 128); /* -128 / 127 */
5916 brightness = ((int) sd->brightness - 128); /* -128 / 92 */ 5903 brightness = ((int) sd->ctrls[BRIGHTNESS].val - 128); /* -128 / 92 */
5917 adj = 0; 5904 adj = 0;
5918 gp1 = gp2 = 0; 5905 gp1 = gp2 = 0;
5919 for (i = 0; i < 16; i++) { 5906 for (i = 0; i < 16; i++) {
@@ -5994,6 +5981,10 @@ static void setlightfreq(struct gspca_dev *gspca_dev)
5994 {cs2102_NoFliker, cs2102_NoFlikerScale, 5981 {cs2102_NoFliker, cs2102_NoFlikerScale,
5995 NULL, NULL, /* currently disabled */ 5982 NULL, NULL, /* currently disabled */
5996 NULL, NULL}, 5983 NULL, NULL},
5984 [SENSOR_GC0303] =
5985 {gc0303_NoFliker, gc0303_NoFlikerScale,
5986 gc0303_50HZ, gc0303_50HZScale,
5987 gc0303_60HZ, gc0303_60HZScale},
5997 [SENSOR_GC0305] = 5988 [SENSOR_GC0305] =
5998 {gc0305_NoFliker, gc0305_NoFliker, 5989 {gc0305_NoFliker, gc0305_NoFliker,
5999 gc0305_50HZ, gc0305_50HZ, 5990 gc0305_50HZ, gc0305_50HZ,
@@ -6054,14 +6045,10 @@ static void setlightfreq(struct gspca_dev *gspca_dev)
6054 {tas5130c_NoFliker, tas5130c_NoFlikerScale, 6045 {tas5130c_NoFliker, tas5130c_NoFlikerScale,
6055 tas5130c_50HZ, tas5130c_50HZScale, 6046 tas5130c_50HZ, tas5130c_50HZScale,
6056 tas5130c_60HZ, tas5130c_60HZScale}, 6047 tas5130c_60HZ, tas5130c_60HZScale},
6057 [SENSOR_TAS5130C_VF0250] =
6058 {tas5130c_vf0250_NoFliker, tas5130c_vf0250_NoFlikerScale,
6059 tas5130c_vf0250_50HZ, tas5130c_vf0250_50HZScale,
6060 tas5130c_vf0250_60HZ, tas5130c_vf0250_60HZScale},
6061 }; 6048 };
6062 6049
6063 i = sd->lightfreq * 2; 6050 i = sd->ctrls[LIGHTFREQ].val * 2;
6064 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 6051 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
6065 if (mode) 6052 if (mode)
6066 i++; /* 320x240 */ 6053 i++; /* 320x240 */
6067 zc3_freq = freq_tb[sd->sensor][i]; 6054 zc3_freq = freq_tb[sd->sensor][i];
@@ -6070,14 +6057,14 @@ static void setlightfreq(struct gspca_dev *gspca_dev)
6070 usb_exchange(gspca_dev, zc3_freq); 6057 usb_exchange(gspca_dev, zc3_freq);
6071 switch (sd->sensor) { 6058 switch (sd->sensor) {
6072 case SENSOR_GC0305: 6059 case SENSOR_GC0305:
6073 if (mode /* if 320x240 */ 6060 if (mode /* if 320x240 */
6074 && sd->lightfreq == 1) /* and 50Hz */ 6061 && sd->ctrls[LIGHTFREQ].val == 1) /* and 50Hz */
6075 reg_w(gspca_dev, 0x85, 0x018d); 6062 reg_w(gspca_dev, 0x85, 0x018d);
6076 /* win: 0x80, 0x018d */ 6063 /* win: 0x80, 0x018d */
6077 break; 6064 break;
6078 case SENSOR_OV7620: 6065 case SENSOR_OV7620:
6079 if (!mode) { /* if 640x480 */ 6066 if (!mode) { /* if 640x480 */
6080 if (sd->lightfreq != 0) /* and 50 or 60 Hz */ 6067 if (sd->ctrls[LIGHTFREQ].val != 0) /* and filter */
6081 reg_w(gspca_dev, 0x40, 0x0002); 6068 reg_w(gspca_dev, 0x40, 0x0002);
6082 else 6069 else
6083 reg_w(gspca_dev, 0x44, 0x0002); 6070 reg_w(gspca_dev, 0x44, 0x0002);
@@ -6094,7 +6081,7 @@ static void setautogain(struct gspca_dev *gspca_dev)
6094 struct sd *sd = (struct sd *) gspca_dev; 6081 struct sd *sd = (struct sd *) gspca_dev;
6095 u8 autoval; 6082 u8 autoval;
6096 6083
6097 if (sd->autogain) 6084 if (sd->ctrls[AUTOGAIN].val)
6098 autoval = 0x42; 6085 autoval = 0x42;
6099 else 6086 else
6100 autoval = 0x02; 6087 autoval = 0x02;
@@ -6330,8 +6317,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
6330 retword = i2c_read(gspca_dev, 0x00); 6317 retword = i2c_read(gspca_dev, 0x00);
6331 if (retword != 0) { 6318 if (retword != 0) {
6332 PDEBUG(D_PROBE, "probe 3wr vga type %02x", retword); 6319 PDEBUG(D_PROBE, "probe 3wr vga type %02x", retword);
6333 if (retword == 0x0011) /* VF0250 */ 6320 if (retword == 0x0011) /* gc0303 */
6334 return 0x0250; 6321 return 0x0303;
6335 if (retword == 0x0029) /* gc0305 */ 6322 if (retword == 0x0029) /* gc0305 */
6336 send_unknown(gspca_dev, SENSOR_GC0305); 6323 send_unknown(gspca_dev, SENSOR_GC0305);
6337 return retword; 6324 return retword;
@@ -6392,7 +6379,7 @@ static int zcxx_probeSensor(struct gspca_dev *gspca_dev)
6392 switch (sd->sensor) { 6379 switch (sd->sensor) {
6393 case SENSOR_MC501CB: 6380 case SENSOR_MC501CB:
6394 return -1; /* don't probe */ 6381 return -1; /* don't probe */
6395 case SENSOR_TAS5130C_VF0250: 6382 case SENSOR_GC0303:
6396 /* may probe but with no write in reg 0x0010 */ 6383 /* may probe but with no write in reg 0x0010 */
6397 return -1; /* don't probe */ 6384 return -1; /* don't probe */
6398 case SENSOR_PAS106: 6385 case SENSOR_PAS106:
@@ -6421,11 +6408,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
6421 /* define some sensors from the vendor/product */ 6408 /* define some sensors from the vendor/product */
6422 sd->sensor = id->driver_info; 6409 sd->sensor = id->driver_info;
6423 6410
6424 sd->sharpness = SHARPNESS_DEF; 6411 gspca_dev->cam.ctrls = sd->ctrls;
6425 sd->brightness = BRIGHTNESS_DEF;
6426 sd->contrast = CONTRAST_DEF;
6427 sd->autogain = AUTOGAIN_DEF;
6428 sd->lightfreq = FREQ_DEF;
6429 sd->quality = QUALITY_DEF; 6412 sd->quality = QUALITY_DEF;
6430 6413
6431 return 0; 6414 return 0;
@@ -6441,6 +6424,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
6441 [SENSOR_ADCM2700] = 4, 6424 [SENSOR_ADCM2700] = 4,
6442 [SENSOR_CS2102] = 4, 6425 [SENSOR_CS2102] = 4,
6443 [SENSOR_CS2102K] = 5, 6426 [SENSOR_CS2102K] = 5,
6427 [SENSOR_GC0303] = 3,
6444 [SENSOR_GC0305] = 4, 6428 [SENSOR_GC0305] = 4,
6445 [SENSOR_HDCS2020b] = 4, 6429 [SENSOR_HDCS2020b] = 4,
6446 [SENSOR_HV7131B] = 4, 6430 [SENSOR_HV7131B] = 4,
@@ -6456,12 +6440,12 @@ static int sd_init(struct gspca_dev *gspca_dev)
6456 [SENSOR_PB0330] = 4, 6440 [SENSOR_PB0330] = 4,
6457 [SENSOR_PO2030] = 4, 6441 [SENSOR_PO2030] = 4,
6458 [SENSOR_TAS5130C] = 3, 6442 [SENSOR_TAS5130C] = 3,
6459 [SENSOR_TAS5130C_VF0250] = 3,
6460 }; 6443 };
6461 static const u8 mode_tb[SENSOR_MAX] = { 6444 static const u8 mode_tb[SENSOR_MAX] = {
6462 [SENSOR_ADCM2700] = 2, 6445 [SENSOR_ADCM2700] = 2,
6463 [SENSOR_CS2102] = 1, 6446 [SENSOR_CS2102] = 1,
6464 [SENSOR_CS2102K] = 1, 6447 [SENSOR_CS2102K] = 1,
6448 [SENSOR_GC0303] = 1,
6465 [SENSOR_GC0305] = 1, 6449 [SENSOR_GC0305] = 1,
6466 [SENSOR_HDCS2020b] = 1, 6450 [SENSOR_HDCS2020b] = 1,
6467 [SENSOR_HV7131B] = 1, 6451 [SENSOR_HV7131B] = 1,
@@ -6477,7 +6461,6 @@ static int sd_init(struct gspca_dev *gspca_dev)
6477 [SENSOR_PB0330] = 1, 6461 [SENSOR_PB0330] = 1,
6478 [SENSOR_PO2030] = 1, 6462 [SENSOR_PO2030] = 1,
6479 [SENSOR_TAS5130C] = 1, 6463 [SENSOR_TAS5130C] = 1,
6480 [SENSOR_TAS5130C_VF0250] = 1,
6481 }; 6464 };
6482 6465
6483 sensor = zcxx_probeSensor(gspca_dev); 6466 sensor = zcxx_probeSensor(gspca_dev);
@@ -6493,8 +6476,8 @@ static int sd_init(struct gspca_dev *gspca_dev)
6493 case SENSOR_MC501CB: 6476 case SENSOR_MC501CB:
6494 PDEBUG(D_PROBE, "Sensor MC501CB"); 6477 PDEBUG(D_PROBE, "Sensor MC501CB");
6495 break; 6478 break;
6496 case SENSOR_TAS5130C_VF0250: 6479 case SENSOR_GC0303:
6497 PDEBUG(D_PROBE, "Sensor Tas5130 (VF0250)"); 6480 PDEBUG(D_PROBE, "Sensor GC0303");
6498 break; 6481 break;
6499 default: 6482 default:
6500 warn("Unknown sensor - set to TAS5130C"); 6483 warn("Unknown sensor - set to TAS5130C");
@@ -6581,14 +6564,14 @@ static int sd_init(struct gspca_dev *gspca_dev)
6581 PDEBUG(D_PROBE, "Find Sensor GC0305"); 6564 PDEBUG(D_PROBE, "Find Sensor GC0305");
6582 sd->sensor = SENSOR_GC0305; 6565 sd->sensor = SENSOR_GC0305;
6583 break; 6566 break;
6584 case 0x0250: 6567 case 0x0303:
6585 PDEBUG(D_PROBE, "Sensor Tas5130 (VF0250)"); 6568 PDEBUG(D_PROBE, "Sensor GC0303");
6586 sd->sensor = SENSOR_TAS5130C_VF0250; 6569 sd->sensor = SENSOR_GC0303;
6587 break; 6570 break;
6588 case 0x2030: 6571 case 0x2030:
6589 PDEBUG(D_PROBE, "Find Sensor PO2030"); 6572 PDEBUG(D_PROBE, "Find Sensor PO2030");
6590 sd->sensor = SENSOR_PO2030; 6573 sd->sensor = SENSOR_PO2030;
6591 sd->sharpness = 0; /* from win traces */ 6574 sd->ctrls[SHARPNESS].def = 0; /* from win traces */
6592 break; 6575 break;
6593 case 0x7620: 6576 case 0x7620:
6594 PDEBUG(D_PROBE, "Find Sensor OV7620"); 6577 PDEBUG(D_PROBE, "Find Sensor OV7620");
@@ -6629,11 +6612,12 @@ static int sd_init(struct gspca_dev *gspca_dev)
6629 cam->nmodes = ARRAY_SIZE(broken_vga_mode); 6612 cam->nmodes = ARRAY_SIZE(broken_vga_mode);
6630 break; 6613 break;
6631 } 6614 }
6632 sd->gamma = gamma[sd->sensor]; 6615
6616 sd->ctrls[GAMMA].def = gamma[sd->sensor];
6633 6617
6634 switch (sd->sensor) { 6618 switch (sd->sensor) {
6635 case SENSOR_OV7630C: 6619 case SENSOR_OV7630C:
6636 gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX); 6620 gspca_dev->ctrl_dis = (1 << LIGHTFREQ);
6637 break; 6621 break;
6638 } 6622 }
6639 6623
@@ -6653,6 +6637,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
6653 {cs2102_Initial, cs2102_InitialScale}, 6637 {cs2102_Initial, cs2102_InitialScale},
6654 [SENSOR_CS2102K] = 6638 [SENSOR_CS2102K] =
6655 {cs2102K_Initial, cs2102K_InitialScale}, 6639 {cs2102K_Initial, cs2102K_InitialScale},
6640 [SENSOR_GC0303] =
6641 {gc0303_Initial, gc0303_InitialScale},
6656 [SENSOR_GC0305] = 6642 [SENSOR_GC0305] =
6657 {gc0305_Initial, gc0305_InitialScale}, 6643 {gc0305_Initial, gc0305_InitialScale},
6658 [SENSOR_HDCS2020b] = 6644 [SENSOR_HDCS2020b] =
@@ -6683,8 +6669,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
6683 {po2030_Initial, po2030_InitialScale}, 6669 {po2030_Initial, po2030_InitialScale},
6684 [SENSOR_TAS5130C] = 6670 [SENSOR_TAS5130C] =
6685 {tas5130c_Initial, tas5130c_InitialScale}, 6671 {tas5130c_Initial, tas5130c_InitialScale},
6686 [SENSOR_TAS5130C_VF0250] =
6687 {tas5130c_vf0250_Initial, tas5130c_vf0250_InitialScale},
6688 }; 6672 };
6689 6673
6690 /* create the JPEG header */ 6674 /* create the JPEG header */
@@ -6709,7 +6693,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
6709 case SENSOR_OV7620: 6693 case SENSOR_OV7620:
6710 case SENSOR_PO2030: 6694 case SENSOR_PO2030:
6711 case SENSOR_TAS5130C: 6695 case SENSOR_TAS5130C:
6712 case SENSOR_TAS5130C_VF0250: 6696 case SENSOR_GC0303:
6713/* msleep(100); * ?? */ 6697/* msleep(100); * ?? */
6714 reg_r(gspca_dev, 0x0002); /* --> 0x40 */ 6698 reg_r(gspca_dev, 0x0002); /* --> 0x40 */
6715 reg_w(gspca_dev, 0x09, 0x01ad); /* (from win traces) */ 6699 reg_w(gspca_dev, 0x09, 0x01ad); /* (from win traces) */
@@ -6843,114 +6827,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
6843 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); 6827 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
6844} 6828}
6845 6829
6846static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
6847{
6848 struct sd *sd = (struct sd *) gspca_dev;
6849
6850 sd->brightness = val;
6851 if (gspca_dev->streaming)
6852 setcontrast(gspca_dev);
6853 return gspca_dev->usb_err;
6854}
6855
6856static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
6857{
6858 struct sd *sd = (struct sd *) gspca_dev;
6859
6860 *val = sd->brightness;
6861 return 0;
6862}
6863
6864static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
6865{
6866 struct sd *sd = (struct sd *) gspca_dev;
6867
6868 sd->contrast = val;
6869 if (gspca_dev->streaming)
6870 setcontrast(gspca_dev);
6871 return gspca_dev->usb_err;
6872}
6873
6874static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
6875{
6876 struct sd *sd = (struct sd *) gspca_dev;
6877
6878 *val = sd->contrast;
6879 return 0;
6880}
6881
6882static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
6883{
6884 struct sd *sd = (struct sd *) gspca_dev;
6885
6886 sd->autogain = val;
6887 if (gspca_dev->streaming)
6888 setautogain(gspca_dev);
6889 return gspca_dev->usb_err;
6890}
6891
6892static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
6893{
6894 struct sd *sd = (struct sd *) gspca_dev;
6895
6896 *val = sd->autogain;
6897 return 0;
6898}
6899
6900static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
6901{
6902 struct sd *sd = (struct sd *) gspca_dev;
6903
6904 sd->gamma = val;
6905 if (gspca_dev->streaming)
6906 setcontrast(gspca_dev);
6907 return gspca_dev->usb_err;
6908}
6909
6910static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
6911{
6912 struct sd *sd = (struct sd *) gspca_dev;
6913
6914 *val = sd->gamma;
6915 return 0;
6916}
6917
6918static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
6919{
6920 struct sd *sd = (struct sd *) gspca_dev;
6921
6922 sd->lightfreq = val;
6923 if (gspca_dev->streaming)
6924 setlightfreq(gspca_dev);
6925 return gspca_dev->usb_err;
6926}
6927
6928static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
6929{
6930 struct sd *sd = (struct sd *) gspca_dev;
6931
6932 *val = sd->lightfreq;
6933 return 0;
6934}
6935
6936static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
6937{
6938 struct sd *sd = (struct sd *) gspca_dev;
6939
6940 sd->sharpness = val;
6941 if (gspca_dev->streaming)
6942 setsharpness(gspca_dev);
6943 return gspca_dev->usb_err;
6944}
6945
6946static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
6947{
6948 struct sd *sd = (struct sd *) gspca_dev;
6949
6950 *val = sd->sharpness;
6951 return 0;
6952}
6953
6954static int sd_querymenu(struct gspca_dev *gspca_dev, 6830static int sd_querymenu(struct gspca_dev *gspca_dev,
6955 struct v4l2_querymenu *menu) 6831 struct v4l2_querymenu *menu)
6956{ 6832{
@@ -7045,8 +6921,8 @@ static const __devinitdata struct usb_device_id device_table[] = {
7045 {USB_DEVICE(0x041e, 0x4035), .driver_info = SENSOR_PAS106}, 6921 {USB_DEVICE(0x041e, 0x4035), .driver_info = SENSOR_PAS106},
7046 {USB_DEVICE(0x041e, 0x4036)}, 6922 {USB_DEVICE(0x041e, 0x4036)},
7047 {USB_DEVICE(0x041e, 0x403a)}, 6923 {USB_DEVICE(0x041e, 0x403a)},
7048 {USB_DEVICE(0x041e, 0x4051), .driver_info = SENSOR_TAS5130C_VF0250}, 6924 {USB_DEVICE(0x041e, 0x4051), .driver_info = SENSOR_GC0303},
7049 {USB_DEVICE(0x041e, 0x4053), .driver_info = SENSOR_TAS5130C_VF0250}, 6925 {USB_DEVICE(0x041e, 0x4053), .driver_info = SENSOR_GC0303},
7050 {USB_DEVICE(0x0458, 0x7007)}, 6926 {USB_DEVICE(0x0458, 0x7007)},
7051 {USB_DEVICE(0x0458, 0x700c)}, 6927 {USB_DEVICE(0x0458, 0x700c)},
7052 {USB_DEVICE(0x0458, 0x700f)}, 6928 {USB_DEVICE(0x0458, 0x700f)},
@@ -7066,8 +6942,8 @@ static const __devinitdata struct usb_device_id device_table[] = {
7066 {USB_DEVICE(0x046d, 0x08af)}, 6942 {USB_DEVICE(0x046d, 0x08af)},
7067 {USB_DEVICE(0x046d, 0x08b9)}, 6943 {USB_DEVICE(0x046d, 0x08b9)},
7068 {USB_DEVICE(0x046d, 0x08d7)}, 6944 {USB_DEVICE(0x046d, 0x08d7)},
7069 {USB_DEVICE(0x046d, 0x08d9)},
7070 {USB_DEVICE(0x046d, 0x08d8)}, 6945 {USB_DEVICE(0x046d, 0x08d8)},
6946 {USB_DEVICE(0x046d, 0x08d9)},
7071 {USB_DEVICE(0x046d, 0x08da)}, 6947 {USB_DEVICE(0x046d, 0x08da)},
7072 {USB_DEVICE(0x046d, 0x08dd), .driver_info = SENSOR_MC501CB}, 6948 {USB_DEVICE(0x046d, 0x08dd), .driver_info = SENSOR_MC501CB},
7073 {USB_DEVICE(0x0471, 0x0325), .driver_info = SENSOR_PAS106}, 6949 {USB_DEVICE(0x0471, 0x0325), .driver_info = SENSOR_PAS106},