aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/pac7311.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/pac7311.c')
-rw-r--r--drivers/media/video/gspca/pac7311.c1110
1 files changed, 724 insertions, 386 deletions
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index 815bea6edc44..d4be51843286 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -19,6 +19,36 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22/* Some documentation about various registers as determined by trial and error.
23 When the register addresses differ between the 7202 and the 7311 the 2
24 different addresses are written as 7302addr/7311addr, when one of the 2
25 addresses is a - sign that register description is not valid for the
26 matching IC.
27
28 Register page 1:
29
30 Address Description
31 -/0x08 Unknown compressor related, must always be 8 except when not
32 in 640x480 resolution and page 4 reg 2 <= 3 then set it to 9 !
33 -/0x1b Auto white balance related, bit 0 is AWB enable (inverted)
34 bits 345 seem to toggle per color gains on/off (inverted)
35 0x78 Global control, bit 6 controls the LED (inverted)
36 -/0x80 JPEG compression ratio ? Best not touched
37
38 Register page 3/4:
39
40 Address Description
41 0x02 Clock divider 2-63, fps =~ 60 / val. Must be a multiple of 3 on
42 the 7302, so one of 3, 6, 9, ..., except when between 6 and 12?
43 -/0x0f Master gain 1-245, low value = high gain
44 0x10/- Master gain 0-31
45 -/0x10 Another gain 0-15, limited influence (1-2x gain I guess)
46 0x21 Bitfield: 0-1 unused, 2-3 vflip/hflip, 4-5 unknown, 6-7 unused
47 -/0x27 Seems to toggle various gains on / off, Setting bit 7 seems to
48 completely disable the analog amplification block. Set to 0x68
49 for max gain, 0x14 for minimal gain.
50*/
51
22#define MODULE_NAME "pac7311" 52#define MODULE_NAME "pac7311"
23 53
24#include "gspca.h" 54#include "gspca.h"
@@ -31,18 +61,23 @@ MODULE_LICENSE("GPL");
31struct sd { 61struct sd {
32 struct gspca_dev gspca_dev; /* !! must be the first item */ 62 struct gspca_dev gspca_dev; /* !! must be the first item */
33 63
34 int lum_sum;
35 atomic_t avg_lum;
36 atomic_t do_gain;
37
38 unsigned char brightness; 64 unsigned char brightness;
39 unsigned char contrast; 65 unsigned char contrast;
40 unsigned char colors; 66 unsigned char colors;
67 unsigned char gain;
68 unsigned char exposure;
41 unsigned char autogain; 69 unsigned char autogain;
70 __u8 hflip;
71 __u8 vflip;
72
73 __u8 sensor;
74#define SENSOR_PAC7302 0
75#define SENSOR_PAC7311 1
42 76
43 char ffseq; 77 u8 sof_read;
44 signed char ag_cnt; 78 u8 autogain_ignore_frames;
45#define AG_CNT_START 13 79
80 atomic_t avg_lum;
46}; 81};
47 82
48/* V4L2 controls supported by the driver */ 83/* V4L2 controls supported by the driver */
@@ -54,8 +89,18 @@ static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
54static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); 89static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
55static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); 90static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
56static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 91static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
92static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val);
93static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val);
94static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
95static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
96static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val);
97static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val);
98static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val);
99static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val);
57 100
58static struct ctrl sd_ctrls[] = { 101static struct ctrl sd_ctrls[] = {
102/* This control is pac7302 only */
103#define BRIGHTNESS_IDX 0
59 { 104 {
60 { 105 {
61 .id = V4L2_CID_BRIGHTNESS, 106 .id = V4L2_CID_BRIGHTNESS,
@@ -71,13 +116,15 @@ static struct ctrl sd_ctrls[] = {
71 .set = sd_setbrightness, 116 .set = sd_setbrightness,
72 .get = sd_getbrightness, 117 .get = sd_getbrightness,
73 }, 118 },
119/* This control is for both the 7302 and the 7311 */
74 { 120 {
75 { 121 {
76 .id = V4L2_CID_CONTRAST, 122 .id = V4L2_CID_CONTRAST,
77 .type = V4L2_CTRL_TYPE_INTEGER, 123 .type = V4L2_CTRL_TYPE_INTEGER,
78 .name = "Contrast", 124 .name = "Contrast",
79 .minimum = 0, 125 .minimum = 0,
80 .maximum = 255, 126#define CONTRAST_MAX 255
127 .maximum = CONTRAST_MAX,
81 .step = 1, 128 .step = 1,
82#define CONTRAST_DEF 127 129#define CONTRAST_DEF 127
83 .default_value = CONTRAST_DEF, 130 .default_value = CONTRAST_DEF,
@@ -85,13 +132,16 @@ static struct ctrl sd_ctrls[] = {
85 .set = sd_setcontrast, 132 .set = sd_setcontrast,
86 .get = sd_getcontrast, 133 .get = sd_getcontrast,
87 }, 134 },
135/* This control is pac7302 only */
136#define SATURATION_IDX 2
88 { 137 {
89 { 138 {
90 .id = V4L2_CID_SATURATION, 139 .id = V4L2_CID_SATURATION,
91 .type = V4L2_CTRL_TYPE_INTEGER, 140 .type = V4L2_CTRL_TYPE_INTEGER,
92 .name = "Color", 141 .name = "Saturation",
93 .minimum = 0, 142 .minimum = 0,
94 .maximum = 255, 143#define COLOR_MAX 255
144 .maximum = COLOR_MAX,
95 .step = 1, 145 .step = 1,
96#define COLOR_DEF 127 146#define COLOR_DEF 127
97 .default_value = COLOR_DEF, 147 .default_value = COLOR_DEF,
@@ -99,6 +149,39 @@ static struct ctrl sd_ctrls[] = {
99 .set = sd_setcolors, 149 .set = sd_setcolors,
100 .get = sd_getcolors, 150 .get = sd_getcolors,
101 }, 151 },
152/* All controls below are for both the 7302 and the 7311 */
153 {
154 {
155 .id = V4L2_CID_GAIN,
156 .type = V4L2_CTRL_TYPE_INTEGER,
157 .name = "Gain",
158 .minimum = 0,
159#define GAIN_MAX 255
160 .maximum = GAIN_MAX,
161 .step = 1,
162#define GAIN_DEF 127
163#define GAIN_KNEE 255 /* Gain seems to cause little noise on the pac73xx */
164 .default_value = GAIN_DEF,
165 },
166 .set = sd_setgain,
167 .get = sd_getgain,
168 },
169 {
170 {
171 .id = V4L2_CID_EXPOSURE,
172 .type = V4L2_CTRL_TYPE_INTEGER,
173 .name = "Exposure",
174 .minimum = 0,
175#define EXPOSURE_MAX 255
176 .maximum = EXPOSURE_MAX,
177 .step = 1,
178#define EXPOSURE_DEF 16 /* 32 ms / 30 fps */
179#define EXPOSURE_KNEE 50 /* 100 ms / 10 fps */
180 .default_value = EXPOSURE_DEF,
181 },
182 .set = sd_setexposure,
183 .get = sd_getexposure,
184 },
102 { 185 {
103 { 186 {
104 .id = V4L2_CID_AUTOGAIN, 187 .id = V4L2_CID_AUTOGAIN,
@@ -113,101 +196,207 @@ static struct ctrl sd_ctrls[] = {
113 .set = sd_setautogain, 196 .set = sd_setautogain,
114 .get = sd_getautogain, 197 .get = sd_getautogain,
115 }, 198 },
199 {
200 {
201 .id = V4L2_CID_HFLIP,
202 .type = V4L2_CTRL_TYPE_BOOLEAN,
203 .name = "Mirror",
204 .minimum = 0,
205 .maximum = 1,
206 .step = 1,
207#define HFLIP_DEF 0
208 .default_value = HFLIP_DEF,
209 },
210 .set = sd_sethflip,
211 .get = sd_gethflip,
212 },
213 {
214 {
215 .id = V4L2_CID_VFLIP,
216 .type = V4L2_CTRL_TYPE_BOOLEAN,
217 .name = "Vflip",
218 .minimum = 0,
219 .maximum = 1,
220 .step = 1,
221#define VFLIP_DEF 0
222 .default_value = VFLIP_DEF,
223 },
224 .set = sd_setvflip,
225 .get = sd_getvflip,
226 },
116}; 227};
117 228
118static struct v4l2_pix_format vga_mode[] = { 229static struct v4l2_pix_format vga_mode[] = {
119 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 230 {160, 120, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE,
120 .bytesperline = 160, 231 .bytesperline = 160,
121 .sizeimage = 160 * 120 * 3 / 8 + 590, 232 .sizeimage = 160 * 120 * 3 / 8 + 590,
122 .colorspace = V4L2_COLORSPACE_JPEG, 233 .colorspace = V4L2_COLORSPACE_JPEG,
123 .priv = 2}, 234 .priv = 2},
124 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 235 {320, 240, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE,
125 .bytesperline = 320, 236 .bytesperline = 320,
126 .sizeimage = 320 * 240 * 3 / 8 + 590, 237 .sizeimage = 320 * 240 * 3 / 8 + 590,
127 .colorspace = V4L2_COLORSPACE_JPEG, 238 .colorspace = V4L2_COLORSPACE_JPEG,
128 .priv = 1}, 239 .priv = 1},
129 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, 240 {640, 480, V4L2_PIX_FMT_PJPG, V4L2_FIELD_NONE,
130 .bytesperline = 640, 241 .bytesperline = 640,
131 .sizeimage = 640 * 480 * 3 / 8 + 590, 242 .sizeimage = 640 * 480 * 3 / 8 + 590,
132 .colorspace = V4L2_COLORSPACE_JPEG, 243 .colorspace = V4L2_COLORSPACE_JPEG,
133 .priv = 0}, 244 .priv = 0},
134}; 245};
135 246
136#define PAC7311_JPEG_HEADER_SIZE (sizeof pac7311_jpeg_header) /* (594) */ 247/* pac 7302 */
137 248static const __u8 init_7302[] = {
138static const __u8 pac7311_jpeg_header[] = { 249/* index,value */
139 0xff, 0xd8, 250 0xff, 0x01, /* page 1 */
140 0xff, 0xe0, 0x00, 0x03, 0x20, 251 0x78, 0x00, /* deactivate */
141 0xff, 0xc0, 0x00, 0x11, 0x08, 252 0xff, 0x01,
142 0x01, 0xe0, /* 12: height */ 253 0x78, 0x40, /* led off */
143 0x02, 0x80, /* 14: width */ 254};
144 0x03, /* 16 */ 255static const __u8 start_7302[] = {
145 0x01, 0x21, 0x00, 256/* index, len, [value]* */
146 0x02, 0x11, 0x01, 257 0xff, 1, 0x00, /* page 0 */
147 0x03, 0x11, 0x01, 258 0x00, 12, 0x01, 0x40, 0x40, 0x40, 0x01, 0xe0, 0x02, 0x80,
148 0xff, 0xdb, 0x00, 0x84, 259 0x00, 0x00, 0x00, 0x00,
149 0x00, 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 0x0d, 260 0x0d, 24, 0x03, 0x01, 0x00, 0xb5, 0x07, 0xcb, 0x00, 0x00,
150 0x0e, 0x12, 0x11, 0x10, 0x13, 0x18, 0x28, 0x1a, 0x18, 0x16, 261 0x07, 0xc8, 0x00, 0xea, 0x07, 0xcf, 0x07, 0xf7,
151 0x16, 0x18, 0x31, 0x23, 0x25, 0x1d, 0x28, 0x3a, 0x33, 0x3d, 262 0x07, 0x7e, 0x01, 0x0b, 0x00, 0x00, 0x00, 0x11,
152 0x3c, 0x39, 0x33, 0x38, 0x37, 0x40, 0x48, 0x5c, 0x4e, 0x40, 263 0x26, 2, 0xaa, 0xaa,
153 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 0x51, 0x57, 0x5f, 264 0x2e, 1, 0x31,
154 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71, 0x79, 0x70, 0x64, 265 0x38, 1, 0x01,
155 0x78, 0x5c, 0x65, 0x67, 0x63, 0x01, 0x11, 0x12, 0x12, 0x18, 266 0x3a, 3, 0x14, 0xff, 0x5a,
156 0x15, 0x18, 0x2f, 0x1a, 0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42, 267 0x43, 11, 0x00, 0x0a, 0x18, 0x11, 0x01, 0x2c, 0x88, 0x11,
157 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 268 0x00, 0x54, 0x11,
158 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 269 0x55, 1, 0x00,
159 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 270 0x62, 4, 0x10, 0x1e, 0x1e, 0x18,
160 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 271 0x6b, 1, 0x00,
161 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 272 0x6e, 3, 0x08, 0x06, 0x00,
162 0xff, 0xc4, 0x01, 0xa2, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 273 0x72, 3, 0x00, 0xff, 0x00,
163 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 274 0x7d, 23, 0x01, 0x01, 0x58, 0x46, 0x50, 0x3c, 0x50, 0x3c,
164 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 275 0x54, 0x46, 0x54, 0x56, 0x52, 0x50, 0x52, 0x50,
165 0x09, 0x0a, 0x0b, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 276 0x56, 0x64, 0xa4, 0x00, 0xda, 0x00, 0x00,
166 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 277 0xa2, 10, 0x22, 0x2c, 0x3c, 0x54, 0x69, 0x7c, 0x9c, 0xb9,
167 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 278 0xd2, 0xeb,
168 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 279 0xaf, 1, 0x02,
169 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 280 0xb5, 2, 0x08, 0x08,
170 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 281 0xb8, 2, 0x08, 0x88,
171 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 282 0xc4, 4, 0xae, 0x01, 0x04, 0x01,
172 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 283 0xcc, 1, 0x00,
173 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 284 0xd1, 11, 0x01, 0x30, 0x49, 0x5e, 0x6f, 0x7f, 0x8e, 0xa9,
174 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 285 0xc1, 0xd7, 0xec,
175 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 286 0xdc, 1, 0x01,
176 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 287 0xff, 1, 0x01, /* page 1 */
177 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 288 0x12, 3, 0x02, 0x00, 0x01,
178 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 289 0x3e, 2, 0x00, 0x00,
179 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 290 0x76, 5, 0x01, 0x20, 0x40, 0x00, 0xf2,
180 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 291 0x7c, 1, 0x00,
181 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 292 0x7f, 10, 0x4b, 0x0f, 0x01, 0x2c, 0x02, 0x58, 0x03, 0x20,
182 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 293 0x02, 0x00,
183 0xf9, 0xfa, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 294 0x96, 5, 0x01, 0x10, 0x04, 0x01, 0x04,
184 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 295 0xc8, 14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
185 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 296 0x07, 0x00, 0x01, 0x07, 0x04, 0x01,
186 0x0b, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 297 0xd8, 1, 0x01,
187 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, 298 0xdb, 2, 0x00, 0x01,
188 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 299 0xde, 7, 0x00, 0x01, 0x04, 0x04, 0x00, 0x00, 0x00,
189 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 300 0xe6, 4, 0x00, 0x00, 0x00, 0x01,
190 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 301 0xeb, 1, 0x00,
191 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 302 0xff, 1, 0x02, /* page 2 */
192 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 303 0x22, 1, 0x00,
193 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 304 0xff, 1, 0x03, /* page 3 */
194 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 305 0x00, 255, /* load the page 3 */
195 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 306 0x11, 1, 0x01,
196 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 307 0xff, 1, 0x02, /* page 2 */
197 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 308 0x13, 1, 0x00,
198 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 309 0x22, 4, 0x1f, 0xa4, 0xf0, 0x96,
199 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 310 0x27, 2, 0x14, 0x0c,
200 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 311 0x2a, 5, 0xc8, 0x00, 0x18, 0x12, 0x22,
201 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 312 0x64, 8, 0x00, 0x00, 0xf0, 0x01, 0x14, 0x44, 0x44, 0x44,
202 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 313 0x6e, 1, 0x08,
203 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 314 0xff, 1, 0x01, /* page 1 */
204 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 315 0x78, 1, 0x00,
205 0x11, 0x00, 0x3f, 0x00 316 0, 0 /* end of sequence */
317};
318
319/* page 3 - the value 0xaa says skip the index - see reg_w_page() */
320static const __u8 page3_7302[] = {
321 0x90, 0x40, 0x03, 0x50, 0xc2, 0x01, 0x14, 0x16,
322 0x14, 0x12, 0x00, 0x00, 0x00, 0x02, 0x33, 0x00,
323 0x0f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
324 0x00, 0x00, 0x00, 0x47, 0x01, 0xb3, 0x01, 0x00,
325 0x00, 0x08, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x21,
326 0x00, 0x00, 0x00, 0x54, 0xf4, 0x02, 0x52, 0x54,
327 0xa4, 0xb8, 0xe0, 0x2a, 0xf6, 0x00, 0x00, 0x00,
328 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
329 0x00, 0xfc, 0x00, 0xf2, 0x1f, 0x04, 0x00, 0x00,
330 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x10, 0x00, 0x00,
331 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
332 0x00, 0x40, 0xff, 0x03, 0x19, 0x00, 0x00, 0x00,
333 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
334 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xc8, 0xc8,
335 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50,
336 0x08, 0x10, 0x24, 0x40, 0x00, 0x00, 0x00, 0x00,
337 0x01, 0x00, 0x02, 0x47, 0x00, 0x00, 0x00, 0x00,
338 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
339 0x00, 0x02, 0xfa, 0x00, 0x64, 0x5a, 0x28, 0x00,
340 0x00
341};
342
343/* pac 7311 */
344static const __u8 init_7311[] = {
345 0x78, 0x40, /* Bit_0=start stream, Bit_6=LED */
346 0x78, 0x40, /* Bit_0=start stream, Bit_6=LED */
347 0x78, 0x44, /* Bit_0=start stream, Bit_6=LED */
348 0xff, 0x04,
349 0x27, 0x80,
350 0x28, 0xca,
351 0x29, 0x53,
352 0x2a, 0x0e,
353 0xff, 0x01,
354 0x3e, 0x20,
355};
356
357static const __u8 start_7311[] = {
358/* index, len, [value]* */
359 0xff, 1, 0x01, /* page 1 */
360 0x02, 43, 0x48, 0x0a, 0x40, 0x08, 0x00, 0x00, 0x08, 0x00,
361 0x06, 0xff, 0x11, 0xff, 0x5a, 0x30, 0x90, 0x4c,
362 0x00, 0x07, 0x00, 0x0a, 0x10, 0x00, 0xa0, 0x10,
363 0x02, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x01, 0x00,
364 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
365 0x00, 0x00, 0x00,
366 0x3e, 42, 0x00, 0x00, 0x78, 0x52, 0x4a, 0x52, 0x78, 0x6e,
367 0x48, 0x46, 0x48, 0x6e, 0x5f, 0x49, 0x42, 0x49,
368 0x5f, 0x5f, 0x49, 0x42, 0x49, 0x5f, 0x6e, 0x48,
369 0x46, 0x48, 0x6e, 0x78, 0x52, 0x4a, 0x52, 0x78,
370 0x00, 0x00, 0x09, 0x1b, 0x34, 0x49, 0x5c, 0x9b,
371 0xd0, 0xff,
372 0x78, 6, 0x44, 0x00, 0xf2, 0x01, 0x01, 0x80,
373 0x7f, 18, 0x2a, 0x1c, 0x00, 0xc8, 0x02, 0x58, 0x03, 0x84,
374 0x12, 0x00, 0x1a, 0x04, 0x08, 0x0c, 0x10, 0x14,
375 0x18, 0x20,
376 0x96, 3, 0x01, 0x08, 0x04,
377 0xa0, 4, 0x44, 0x44, 0x44, 0x04,
378 0xf0, 13, 0x01, 0x00, 0x00, 0x00, 0x22, 0x00, 0x20, 0x00,
379 0x3f, 0x00, 0x0a, 0x01, 0x00,
380 0xff, 1, 0x04, /* page 4 */
381 0x00, 254, /* load the page 4 */
382 0x11, 1, 0x01,
383 0, 0 /* end of sequence */
384};
385
386/* page 4 - the value 0xaa says skip the index - see reg_w_page() */
387static const __u8 page4_7311[] = {
388 0xaa, 0xaa, 0x04, 0x54, 0x07, 0x2b, 0x09, 0x0f,
389 0x09, 0x00, 0xaa, 0xaa, 0x07, 0x00, 0x00, 0x62,
390 0x08, 0xaa, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
391 0x00, 0x00, 0x00, 0x03, 0xa0, 0x01, 0xf4, 0xaa,
392 0xaa, 0x00, 0x08, 0xaa, 0x03, 0xaa, 0x00, 0x68,
393 0xca, 0x10, 0x06, 0x78, 0x00, 0x00, 0x00, 0x00,
394 0x23, 0x28, 0x04, 0x11, 0x00, 0x00
206}; 395};
207 396
208static void reg_w_buf(struct gspca_dev *gspca_dev, 397static void reg_w_buf(struct gspca_dev *gspca_dev,
209 __u16 index, 398 __u8 index,
210 const char *buffer, __u16 len) 399 const char *buffer, int len)
211{ 400{
212 memcpy(gspca_dev->usb_buf, buffer, len); 401 memcpy(gspca_dev->usb_buf, buffer, len);
213 usb_control_msg(gspca_dev->dev, 402 usb_control_msg(gspca_dev->dev,
@@ -219,21 +408,9 @@ static void reg_w_buf(struct gspca_dev *gspca_dev,
219 500); 408 500);
220} 409}
221 410
222static __u8 reg_r(struct gspca_dev *gspca_dev,
223 __u16 index)
224{
225 usb_control_msg(gspca_dev->dev,
226 usb_rcvctrlpipe(gspca_dev->dev, 0),
227 0, /* request */
228 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
229 0, /* value */
230 index, gspca_dev->usb_buf, 1,
231 500);
232 return gspca_dev->usb_buf[0];
233}
234 411
235static void reg_w(struct gspca_dev *gspca_dev, 412static void reg_w(struct gspca_dev *gspca_dev,
236 __u16 index, 413 __u8 index,
237 __u8 value) 414 __u8 value)
238{ 415{
239 gspca_dev->usb_buf[0] = value; 416 gspca_dev->usb_buf[0] = value;
@@ -241,10 +418,78 @@ static void reg_w(struct gspca_dev *gspca_dev,
241 usb_sndctrlpipe(gspca_dev->dev, 0), 418 usb_sndctrlpipe(gspca_dev->dev, 0),
242 0, /* request */ 419 0, /* request */
243 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 420 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
244 value, index, gspca_dev->usb_buf, 1, 421 0, index, gspca_dev->usb_buf, 1,
245 500); 422 500);
246} 423}
247 424
425static void reg_w_seq(struct gspca_dev *gspca_dev,
426 const __u8 *seq, int len)
427{
428 while (--len >= 0) {
429 reg_w(gspca_dev, seq[0], seq[1]);
430 seq += 2;
431 }
432}
433
434/* load the beginning of a page */
435static void reg_w_page(struct gspca_dev *gspca_dev,
436 const __u8 *page, int len)
437{
438 int index;
439
440 for (index = 0; index < len; index++) {
441 if (page[index] == 0xaa) /* skip this index */
442 continue;
443 gspca_dev->usb_buf[0] = page[index];
444 usb_control_msg(gspca_dev->dev,
445 usb_sndctrlpipe(gspca_dev->dev, 0),
446 0, /* request */
447 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
448 0, index, gspca_dev->usb_buf, 1,
449 500);
450 }
451}
452
453/* output a variable sequence */
454static void reg_w_var(struct gspca_dev *gspca_dev,
455 const __u8 *seq)
456{
457 int index, len;
458
459 for (;;) {
460 index = *seq++;
461 len = *seq++;
462 switch (len) {
463 case 0:
464 return;
465 case 254:
466 reg_w_page(gspca_dev, page4_7311, sizeof page4_7311);
467 break;
468 case 255:
469 reg_w_page(gspca_dev, page3_7302, sizeof page3_7302);
470 break;
471 default:
472 if (len > 64) {
473 PDEBUG(D_ERR|D_STREAM,
474 "Incorrect variable sequence");
475 return;
476 }
477 while (len > 0) {
478 if (len < 8) {
479 reg_w_buf(gspca_dev, index, seq, len);
480 seq += len;
481 break;
482 }
483 reg_w_buf(gspca_dev, index, seq, 8);
484 seq += 8;
485 index += 8;
486 len -= 8;
487 }
488 }
489 }
490 /* not reached */
491}
492
248/* this function is called at probe time */ 493/* this function is called at probe time */
249static int sd_config(struct gspca_dev *gspca_dev, 494static int sd_config(struct gspca_dev *gspca_dev,
250 const struct usb_device_id *id) 495 const struct usb_device_id *id)
@@ -252,203 +497,245 @@ static int sd_config(struct gspca_dev *gspca_dev,
252 struct sd *sd = (struct sd *) gspca_dev; 497 struct sd *sd = (struct sd *) gspca_dev;
253 struct cam *cam; 498 struct cam *cam;
254 499
255 PDEBUG(D_CONF, "Find Sensor PAC7311");
256 reg_w(gspca_dev, 0x78, 0x40); /* Bit_0=start stream, Bit_7=LED */
257 reg_w(gspca_dev, 0x78, 0x40); /* Bit_0=start stream, Bit_7=LED */
258 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */
259 reg_w(gspca_dev, 0xff, 0x04);
260 reg_w(gspca_dev, 0x27, 0x80);
261 reg_w(gspca_dev, 0x28, 0xca);
262 reg_w(gspca_dev, 0x29, 0x53);
263 reg_w(gspca_dev, 0x2a, 0x0e);
264 reg_w(gspca_dev, 0xff, 0x01);
265 reg_w(gspca_dev, 0x3e, 0x20);
266
267 cam = &gspca_dev->cam; 500 cam = &gspca_dev->cam;
268 cam->epaddr = 0x05; 501 cam->epaddr = 0x05;
269 cam->cam_mode = vga_mode; 502
270 cam->nmodes = ARRAY_SIZE(vga_mode); 503 sd->sensor = id->driver_info;
504 if (sd->sensor == SENSOR_PAC7302) {
505 PDEBUG(D_CONF, "Find Sensor PAC7302");
506 cam->cam_mode = &vga_mode[2]; /* only 640x480 */
507 cam->nmodes = 1;
508 } else {
509 PDEBUG(D_CONF, "Find Sensor PAC7311");
510 cam->cam_mode = vga_mode;
511 cam->nmodes = ARRAY_SIZE(vga_mode);
512 gspca_dev->ctrl_dis = (1 << BRIGHTNESS_IDX)
513 | (1 << SATURATION_IDX);
514 }
271 515
272 sd->brightness = BRIGHTNESS_DEF; 516 sd->brightness = BRIGHTNESS_DEF;
273 sd->contrast = CONTRAST_DEF; 517 sd->contrast = CONTRAST_DEF;
274 sd->colors = COLOR_DEF; 518 sd->colors = COLOR_DEF;
519 sd->gain = GAIN_DEF;
520 sd->exposure = EXPOSURE_DEF;
275 sd->autogain = AUTOGAIN_DEF; 521 sd->autogain = AUTOGAIN_DEF;
276 sd->ag_cnt = -1; 522 sd->hflip = HFLIP_DEF;
523 sd->vflip = VFLIP_DEF;
277 return 0; 524 return 0;
278} 525}
279 526
280static void setbrightness(struct gspca_dev *gspca_dev) 527/* This function is used by pac7302 only */
528static void setbrightcont(struct gspca_dev *gspca_dev)
529{
530 struct sd *sd = (struct sd *) gspca_dev;
531 int i, v;
532 static const __u8 max[10] =
533 {0x29, 0x33, 0x42, 0x5a, 0x6e, 0x80, 0x9f, 0xbb,
534 0xd4, 0xec};
535 static const __u8 delta[10] =
536 {0x35, 0x33, 0x33, 0x2f, 0x2a, 0x25, 0x1e, 0x17,
537 0x11, 0x0b};
538
539 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */
540 for (i = 0; i < 10; i++) {
541 v = max[i];
542 v += (sd->brightness - BRIGHTNESS_MAX)
543 * 150 / BRIGHTNESS_MAX; /* 200 ? */
544 v -= delta[i] * sd->contrast / CONTRAST_MAX;
545 if (v < 0)
546 v = 0;
547 else if (v > 0xff)
548 v = 0xff;
549 reg_w(gspca_dev, 0xa2 + i, v);
550 }
551 reg_w(gspca_dev, 0xdc, 0x01);
552}
553
554/* This function is used by pac7311 only */
555static void setcontrast(struct gspca_dev *gspca_dev)
281{ 556{
282 struct sd *sd = (struct sd *) gspca_dev; 557 struct sd *sd = (struct sd *) gspca_dev;
283 int brightness;
284 558
285/*jfm: inverted?*/
286 brightness = BRIGHTNESS_MAX - sd->brightness;
287 reg_w(gspca_dev, 0xff, 0x04); 559 reg_w(gspca_dev, 0xff, 0x04);
288/* reg_w(gspca_dev, 0x0e, 0x00); */ 560 reg_w(gspca_dev, 0x10, sd->contrast >> 4);
289 reg_w(gspca_dev, 0x0f, brightness);
290 /* load registers to sensor (Bit 0, auto clear) */ 561 /* load registers to sensor (Bit 0, auto clear) */
291 reg_w(gspca_dev, 0x11, 0x01); 562 reg_w(gspca_dev, 0x11, 0x01);
292 PDEBUG(D_CONF|D_STREAM, "brightness: %i", brightness);
293} 563}
294 564
295static void setcontrast(struct gspca_dev *gspca_dev) 565/* This function is used by pac7302 only */
566static void setcolors(struct gspca_dev *gspca_dev)
296{ 567{
297 struct sd *sd = (struct sd *) gspca_dev; 568 struct sd *sd = (struct sd *) gspca_dev;
569 int i, v;
570 static const int a[9] =
571 {217, -212, 0, -101, 170, -67, -38, -315, 355};
572 static const int b[9] =
573 {19, 106, 0, 19, 106, 1, 19, 106, 1};
298 574
299 reg_w(gspca_dev, 0xff, 0x01); 575 reg_w(gspca_dev, 0xff, 0x03); /* page 3 */
300 reg_w(gspca_dev, 0x80, sd->contrast);
301 /* load registers to sensor (Bit 0, auto clear) */
302 reg_w(gspca_dev, 0x11, 0x01); 576 reg_w(gspca_dev, 0x11, 0x01);
303 PDEBUG(D_CONF|D_STREAM, "contrast: %i", sd->contrast); 577 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */
578 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */
579 for (i = 0; i < 9; i++) {
580 v = a[i] * sd->colors / COLOR_MAX + b[i];
581 reg_w(gspca_dev, 0x0f + 2 * i, (v >> 8) & 0x07);
582 reg_w(gspca_dev, 0x0f + 2 * i + 1, v);
583 }
584 reg_w(gspca_dev, 0xdc, 0x01);
585 PDEBUG(D_CONF|D_STREAM, "color: %i", sd->colors);
304} 586}
305 587
306static void setcolors(struct gspca_dev *gspca_dev) 588static void setgain(struct gspca_dev *gspca_dev)
307{ 589{
308 struct sd *sd = (struct sd *) gspca_dev; 590 struct sd *sd = (struct sd *) gspca_dev;
309 591
310 reg_w(gspca_dev, 0xff, 0x01); 592 if (sd->sensor == SENSOR_PAC7302) {
311 reg_w(gspca_dev, 0x10, sd->colors); 593 reg_w(gspca_dev, 0xff, 0x03); /* page 3 */
594 reg_w(gspca_dev, 0x10, sd->gain >> 3);
595 } else {
596 int gain = GAIN_MAX - sd->gain;
597 if (gain < 1)
598 gain = 1;
599 else if (gain > 245)
600 gain = 245;
601 reg_w(gspca_dev, 0xff, 0x04); /* page 4 */
602 reg_w(gspca_dev, 0x0e, 0x00);
603 reg_w(gspca_dev, 0x0f, gain);
604 }
312 /* load registers to sensor (Bit 0, auto clear) */ 605 /* load registers to sensor (Bit 0, auto clear) */
313 reg_w(gspca_dev, 0x11, 0x01); 606 reg_w(gspca_dev, 0x11, 0x01);
314 PDEBUG(D_CONF|D_STREAM, "color: %i", sd->colors);
315} 607}
316 608
317static void setautogain(struct gspca_dev *gspca_dev) 609static void setexposure(struct gspca_dev *gspca_dev)
318{ 610{
319 struct sd *sd = (struct sd *) gspca_dev; 611 struct sd *sd = (struct sd *) gspca_dev;
612 __u8 reg;
613
614 /* register 2 of frame 3/4 contains the clock divider configuring the
615 no fps according to the formula: 60 / reg. sd->exposure is the
616 desired exposure time in ms. */
617 reg = 120 * sd->exposure / 1000;
618 if (reg < 2)
619 reg = 2;
620 else if (reg > 63)
621 reg = 63;
622
623 if (sd->sensor == SENSOR_PAC7302) {
624 /* On the pac7302 reg2 MUST be a multiple of 3, so round it to
625 the nearest multiple of 3, except when between 6 and 12? */
626 if (reg < 6 || reg > 12)
627 reg = ((reg + 1) / 3) * 3;
628 reg_w(gspca_dev, 0xff, 0x03); /* page 3 */
629 reg_w(gspca_dev, 0x02, reg);
630 } else {
631 reg_w(gspca_dev, 0xff, 0x04); /* page 4 */
632 reg_w(gspca_dev, 0x02, reg);
633 /* Page 1 register 8 must always be 0x08 except when not in
634 640x480 mode and Page3/4 reg 2 <= 3 then it must be 9 */
635 reg_w(gspca_dev, 0xff, 0x01);
636 if (gspca_dev->cam.cam_mode[(int)gspca_dev->curr_mode].priv &&
637 reg <= 3)
638 reg_w(gspca_dev, 0x08, 0x09);
639 else
640 reg_w(gspca_dev, 0x08, 0x08);
641 }
642 /* load registers to sensor (Bit 0, auto clear) */
643 reg_w(gspca_dev, 0x11, 0x01);
644}
320 645
321 if (sd->autogain) { 646static void sethvflip(struct gspca_dev *gspca_dev)
322 sd->lum_sum = 0; 647{
323 sd->ag_cnt = AG_CNT_START; 648 struct sd *sd = (struct sd *) gspca_dev;
649 __u8 data;
650
651 if (sd->sensor == SENSOR_PAC7302) {
652 reg_w(gspca_dev, 0xff, 0x03); /* page 3 */
653 data = (sd->hflip ? 0x08 : 0x00)
654 | (sd->vflip ? 0x04 : 0x00);
324 } else { 655 } else {
325 sd->ag_cnt = -1; 656 reg_w(gspca_dev, 0xff, 0x04); /* page 4 */
657 data = (sd->hflip ? 0x04 : 0x00)
658 | (sd->vflip ? 0x08 : 0x00);
326 } 659 }
660 reg_w(gspca_dev, 0x21, data);
661 /* load registers to sensor (Bit 0, auto clear) */
662 reg_w(gspca_dev, 0x11, 0x01);
327} 663}
328 664
329/* this function is called at open time */ 665/* this function is called at probe and resume time */
330static int sd_open(struct gspca_dev *gspca_dev) 666static int sd_init(struct gspca_dev *gspca_dev)
331{ 667{
332 reg_w(gspca_dev, 0x78, 0x00); /* Turn on LED */ 668 struct sd *sd = (struct sd *) gspca_dev;
669
670 if (sd->sensor == SENSOR_PAC7302)
671 reg_w_seq(gspca_dev, init_7302, sizeof init_7302);
672 else
673 reg_w_seq(gspca_dev, init_7311, sizeof init_7311);
674
333 return 0; 675 return 0;
334} 676}
335 677
336static void sd_start(struct gspca_dev *gspca_dev) 678static void sd_start(struct gspca_dev *gspca_dev)
337{ 679{
338 reg_w(gspca_dev, 0xff, 0x01); 680 struct sd *sd = (struct sd *) gspca_dev;
339 reg_w_buf(gspca_dev, 0x0002, "\x48\x0a\x40\x08\x00\x00\x08\x00", 8);
340 reg_w_buf(gspca_dev, 0x000a, "\x06\xff\x11\xff\x5a\x30\x90\x4c", 8);
341 reg_w_buf(gspca_dev, 0x0012, "\x00\x07\x00\x0a\x10\x00\xa0\x10", 8);
342 reg_w_buf(gspca_dev, 0x001a, "\x02\x00\x00\x00\x00\x0b\x01\x00", 8);
343 reg_w_buf(gspca_dev, 0x0022, "\x00\x00\x00\x00\x00\x00\x00\x00", 8);
344 reg_w_buf(gspca_dev, 0x002a, "\x00\x00\x00", 3);
345 reg_w_buf(gspca_dev, 0x003e, "\x00\x00\x78\x52\x4a\x52\x78\x6e", 8);
346 reg_w_buf(gspca_dev, 0x0046, "\x48\x46\x48\x6e\x5f\x49\x42\x49", 8);
347 reg_w_buf(gspca_dev, 0x004e, "\x5f\x5f\x49\x42\x49\x5f\x6e\x48", 8);
348 reg_w_buf(gspca_dev, 0x0056, "\x46\x48\x6e\x78\x52\x4a\x52\x78", 8);
349 reg_w_buf(gspca_dev, 0x005e, "\x00\x00\x09\x1b\x34\x49\x5c\x9b", 8);
350 reg_w_buf(gspca_dev, 0x0066, "\xd0\xff", 2);
351 reg_w_buf(gspca_dev, 0x0078, "\x44\x00\xf2\x01\x01\x80", 6);
352 reg_w_buf(gspca_dev, 0x007f, "\x2a\x1c\x00\xc8\x02\x58\x03\x84", 8);
353 reg_w_buf(gspca_dev, 0x0087, "\x12\x00\x1a\x04\x08\x0c\x10\x14", 8);
354 reg_w_buf(gspca_dev, 0x008f, "\x18\x20", 2);
355 reg_w_buf(gspca_dev, 0x0096, "\x01\x08\x04", 3);
356 reg_w_buf(gspca_dev, 0x00a0, "\x44\x44\x44\x04", 4);
357 reg_w_buf(gspca_dev, 0x00f0, "\x01\x00\x00\x00\x22\x00\x20\x00", 8);
358 reg_w_buf(gspca_dev, 0x00f8, "\x3f\x00\x0a\x01\x00", 5);
359 681
360 reg_w(gspca_dev, 0xff, 0x04); 682 sd->sof_read = 0;
361 reg_w(gspca_dev, 0x02, 0x04); 683
362 reg_w(gspca_dev, 0x03, 0x54); 684 if (sd->sensor == SENSOR_PAC7302) {
363 reg_w(gspca_dev, 0x04, 0x07); 685 reg_w_var(gspca_dev, start_7302);
364 reg_w(gspca_dev, 0x05, 0x2b); 686 setbrightcont(gspca_dev);
365 reg_w(gspca_dev, 0x06, 0x09); 687 setcolors(gspca_dev);
366 reg_w(gspca_dev, 0x07, 0x0f); 688 } else {
367 reg_w(gspca_dev, 0x08, 0x09); 689 reg_w_var(gspca_dev, start_7311);
368 reg_w(gspca_dev, 0x09, 0x00); 690 setcontrast(gspca_dev);
369 reg_w(gspca_dev, 0x0c, 0x07); 691 }
370 reg_w(gspca_dev, 0x0d, 0x00); 692 setgain(gspca_dev);
371 reg_w(gspca_dev, 0x0e, 0x00); 693 setexposure(gspca_dev);
372 reg_w(gspca_dev, 0x0f, 0x62); 694 sethvflip(gspca_dev);
373 reg_w(gspca_dev, 0x10, 0x08);
374 reg_w(gspca_dev, 0x12, 0x07);
375 reg_w(gspca_dev, 0x13, 0x00);
376 reg_w(gspca_dev, 0x14, 0x00);
377 reg_w(gspca_dev, 0x15, 0x00);
378 reg_w(gspca_dev, 0x16, 0x00);
379 reg_w(gspca_dev, 0x17, 0x00);
380 reg_w(gspca_dev, 0x18, 0x00);
381 reg_w(gspca_dev, 0x19, 0x00);
382 reg_w(gspca_dev, 0x1a, 0x00);
383 reg_w(gspca_dev, 0x1b, 0x03);
384 reg_w(gspca_dev, 0x1c, 0xa0);
385 reg_w(gspca_dev, 0x1d, 0x01);
386 reg_w(gspca_dev, 0x1e, 0xf4);
387 reg_w(gspca_dev, 0x21, 0x00);
388 reg_w(gspca_dev, 0x22, 0x08);
389 reg_w(gspca_dev, 0x24, 0x03);
390 reg_w(gspca_dev, 0x26, 0x00);
391 reg_w(gspca_dev, 0x27, 0x01);
392 reg_w(gspca_dev, 0x28, 0xca);
393 reg_w(gspca_dev, 0x29, 0x10);
394 reg_w(gspca_dev, 0x2a, 0x06);
395 reg_w(gspca_dev, 0x2b, 0x78);
396 reg_w(gspca_dev, 0x2c, 0x00);
397 reg_w(gspca_dev, 0x2d, 0x00);
398 reg_w(gspca_dev, 0x2e, 0x00);
399 reg_w(gspca_dev, 0x2f, 0x00);
400 reg_w(gspca_dev, 0x30, 0x23);
401 reg_w(gspca_dev, 0x31, 0x28);
402 reg_w(gspca_dev, 0x32, 0x04);
403 reg_w(gspca_dev, 0x33, 0x11);
404 reg_w(gspca_dev, 0x34, 0x00);
405 reg_w(gspca_dev, 0x35, 0x00);
406 reg_w(gspca_dev, 0x11, 0x01);
407 setcontrast(gspca_dev);
408 setbrightness(gspca_dev);
409 setcolors(gspca_dev);
410 setautogain(gspca_dev);
411 695
412 /* set correct resolution */ 696 /* set correct resolution */
413 switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { 697 switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) {
414 case 2: /* 160x120 */ 698 case 2: /* 160x120 pac7311 */
415 reg_w(gspca_dev, 0xff, 0x04);
416 reg_w(gspca_dev, 0x02, 0x03);
417 reg_w(gspca_dev, 0xff, 0x01); 699 reg_w(gspca_dev, 0xff, 0x01);
418 reg_w(gspca_dev, 0x08, 0x09);
419 reg_w(gspca_dev, 0x17, 0x20); 700 reg_w(gspca_dev, 0x17, 0x20);
420 reg_w(gspca_dev, 0x1b, 0x00);
421/* reg_w(gspca_dev, 0x80, 0x69); */
422 reg_w(gspca_dev, 0x87, 0x10); 701 reg_w(gspca_dev, 0x87, 0x10);
423 break; 702 break;
424 case 1: /* 320x240 */ 703 case 1: /* 320x240 pac7311 */
425 reg_w(gspca_dev, 0xff, 0x04);
426 reg_w(gspca_dev, 0x02, 0x03);
427 reg_w(gspca_dev, 0xff, 0x01); 704 reg_w(gspca_dev, 0xff, 0x01);
428 reg_w(gspca_dev, 0x08, 0x09);
429 reg_w(gspca_dev, 0x17, 0x30); 705 reg_w(gspca_dev, 0x17, 0x30);
430/* reg_w(gspca_dev, 0x80, 0x3f); */
431 reg_w(gspca_dev, 0x87, 0x11); 706 reg_w(gspca_dev, 0x87, 0x11);
432 break; 707 break;
433 case 0: /* 640x480 */ 708 case 0: /* 640x480 */
434 reg_w(gspca_dev, 0xff, 0x04); 709 if (sd->sensor == SENSOR_PAC7302)
435 reg_w(gspca_dev, 0x02, 0x03); 710 break;
436 reg_w(gspca_dev, 0xff, 0x01); 711 reg_w(gspca_dev, 0xff, 0x01);
437 reg_w(gspca_dev, 0x08, 0x08);
438 reg_w(gspca_dev, 0x17, 0x00); 712 reg_w(gspca_dev, 0x17, 0x00);
439/* reg_w(gspca_dev, 0x80, 0x1c); */
440 reg_w(gspca_dev, 0x87, 0x12); 713 reg_w(gspca_dev, 0x87, 0x12);
441 break; 714 break;
442 } 715 }
443 716
717 sd->sof_read = 0;
718 sd->autogain_ignore_frames = 0;
719 atomic_set(&sd->avg_lum, -1);
720
444 /* start stream */ 721 /* start stream */
445 reg_w(gspca_dev, 0xff, 0x01); 722 reg_w(gspca_dev, 0xff, 0x01);
446 reg_w(gspca_dev, 0x78, 0x04); 723 if (sd->sensor == SENSOR_PAC7302)
447 reg_w(gspca_dev, 0x78, 0x05); 724 reg_w(gspca_dev, 0x78, 0x01);
725 else
726 reg_w(gspca_dev, 0x78, 0x05);
448} 727}
449 728
450static void sd_stopN(struct gspca_dev *gspca_dev) 729static void sd_stopN(struct gspca_dev *gspca_dev)
451{ 730{
731 struct sd *sd = (struct sd *) gspca_dev;
732
733 if (sd->sensor == SENSOR_PAC7302) {
734 reg_w(gspca_dev, 0xff, 0x01);
735 reg_w(gspca_dev, 0x78, 0x00);
736 reg_w(gspca_dev, 0x78, 0x00);
737 return;
738 }
452 reg_w(gspca_dev, 0xff, 0x04); 739 reg_w(gspca_dev, 0xff, 0x04);
453 reg_w(gspca_dev, 0x27, 0x80); 740 reg_w(gspca_dev, 0x27, 0x80);
454 reg_w(gspca_dev, 0x28, 0xca); 741 reg_w(gspca_dev, 0x28, 0xca);
@@ -456,187 +743,147 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
456 reg_w(gspca_dev, 0x2a, 0x0e); 743 reg_w(gspca_dev, 0x2a, 0x0e);
457 reg_w(gspca_dev, 0xff, 0x01); 744 reg_w(gspca_dev, 0xff, 0x01);
458 reg_w(gspca_dev, 0x3e, 0x20); 745 reg_w(gspca_dev, 0x3e, 0x20);
459 reg_w(gspca_dev, 0x78, 0x04); /* Bit_0=start stream, Bit_7=LED */ 746 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
460 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ 747 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
461 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */ 748 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
462} 749}
463 750
464static void sd_stop0(struct gspca_dev *gspca_dev) 751static void sd_stop0(struct gspca_dev *gspca_dev)
465{ 752{
466} 753 struct sd *sd = (struct sd *) gspca_dev;
467 754
468/* this function is called at close time */ 755 if (sd->sensor == SENSOR_PAC7302) {
469static void sd_close(struct gspca_dev *gspca_dev) 756 reg_w(gspca_dev, 0xff, 0x01);
470{ 757 reg_w(gspca_dev, 0x78, 0x40);
471 reg_w(gspca_dev, 0xff, 0x04); 758 }
472 reg_w(gspca_dev, 0x27, 0x80);
473 reg_w(gspca_dev, 0x28, 0xca);
474 reg_w(gspca_dev, 0x29, 0x53);
475 reg_w(gspca_dev, 0x2a, 0x0e);
476 reg_w(gspca_dev, 0xff, 0x01);
477 reg_w(gspca_dev, 0x3e, 0x20);
478 reg_w(gspca_dev, 0x78, 0x04); /* Bit_0=start stream, Bit_7=LED */
479 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */
480 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_7=LED */
481} 759}
482 760
761/* Include pac common sof detection functions */
762#include "pac_common.h"
763
483static void do_autogain(struct gspca_dev *gspca_dev) 764static void do_autogain(struct gspca_dev *gspca_dev)
484{ 765{
485 struct sd *sd = (struct sd *) gspca_dev; 766 struct sd *sd = (struct sd *) gspca_dev;
486 int luma; 767 int avg_lum = atomic_read(&sd->avg_lum);
487 int luma_mean = 128; 768 int desired_lum, deadzone;
488 int luma_delta = 20;
489 __u8 spring = 5;
490 int Gbright;
491 769
492 if (!atomic_read(&sd->do_gain)) 770 if (avg_lum == -1)
493 return; 771 return;
494 atomic_set(&sd->do_gain, 0); 772
495 773 if (sd->sensor == SENSOR_PAC7302) {
496 luma = atomic_read(&sd->avg_lum); 774 desired_lum = 270 + sd->brightness * 4;
497 Gbright = reg_r(gspca_dev, 0x02); 775 /* Hack hack, with the 7202 the first exposure step is
498 PDEBUG(D_FRAM, "luma mean %d", luma); 776 pretty large, so if we're about to make the first
499 if (luma < luma_mean - luma_delta || 777 exposure increase make the deadzone large to avoid
500 luma > luma_mean + luma_delta) { 778 oscilating */
501 Gbright += (luma_mean - luma) >> spring; 779 if (desired_lum > avg_lum && sd->gain == GAIN_DEF &&
502 if (Gbright > 0x1a) 780 sd->exposure > EXPOSURE_DEF &&
503 Gbright = 0x1a; 781 sd->exposure < 42)
504 else if (Gbright < 4) 782 deadzone = 90;
505 Gbright = 4; 783 else
506 PDEBUG(D_FRAM, "gbright %d", Gbright); 784 deadzone = 30;
507 reg_w(gspca_dev, 0xff, 0x04); 785 } else {
508 reg_w(gspca_dev, 0x0f, Gbright); 786 desired_lum = 200;
509 /* load registers to sensor (Bit 0, auto clear) */ 787 deadzone = 20;
510 reg_w(gspca_dev, 0x11, 0x01);
511 } 788 }
789
790 if (sd->autogain_ignore_frames > 0)
791 sd->autogain_ignore_frames--;
792 else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum, desired_lum,
793 deadzone, GAIN_KNEE, EXPOSURE_KNEE))
794 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES;
512} 795}
513 796
797static const unsigned char pac7311_jpeg_header1[] = {
798 0xff, 0xd8, 0xff, 0xc0, 0x00, 0x11, 0x08
799};
800
801static const unsigned char pac7311_jpeg_header2[] = {
802 0x03, 0x01, 0x21, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xda,
803 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00
804};
805
806/* this function is run at interrupt level */
514static void sd_pkt_scan(struct gspca_dev *gspca_dev, 807static void sd_pkt_scan(struct gspca_dev *gspca_dev,
515 struct gspca_frame *frame, /* target */ 808 struct gspca_frame *frame, /* target */
516 __u8 *data, /* isoc packet */ 809 __u8 *data, /* isoc packet */
517 int len) /* iso packet length */ 810 int len) /* iso packet length */
518{ 811{
519 struct sd *sd = (struct sd *) gspca_dev; 812 struct sd *sd = (struct sd *) gspca_dev;
520 unsigned char tmpbuf[4]; 813 unsigned char *sof;
521 int i, p, ffseq; 814
522 815 sof = pac_find_sof(gspca_dev, data, len);
523/* if (len < 5) { */ 816 if (sof) {
524 if (len < 6) { 817 unsigned char tmpbuf[4];
525/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 818 int n, lum_offset, footer_length;
526 return; 819
527 } 820 if (sd->sensor == SENSOR_PAC7302) {
528 821 /* 6 bytes after the FF D9 EOF marker a number of lumination
529 ffseq = sd->ffseq; 822 bytes are send corresponding to different parts of the
530 823 image, the 14th and 15th byte after the EOF seem to
531 for (p = 0; p < len - 6; p++) { 824 correspond to the center of the image */
532 if ((data[0 + p] == 0xff) 825 lum_offset = 61 + sizeof pac_sof_marker;
533 && (data[1 + p] == 0xff) 826 footer_length = 74;
534 && (data[2 + p] == 0x00) 827 } else {
535 && (data[3 + p] == 0xff) 828 lum_offset = 24 + sizeof pac_sof_marker;
536 && (data[4 + p] == 0x96)) { 829 footer_length = 26;
537 830 }
538 /* start of frame */
539 if (sd->ag_cnt >= 0 && p > 28) {
540 sd->lum_sum += data[p - 23];
541 if (--sd->ag_cnt < 0) {
542 sd->ag_cnt = AG_CNT_START;
543 atomic_set(&sd->avg_lum,
544 sd->lum_sum / AG_CNT_START);
545 sd->lum_sum = 0;
546 atomic_set(&sd->do_gain, 1);
547 }
548 }
549 831
550 /* copy the end of data to the current frame */ 832 /* Finish decoding current frame */
833 n = (sof - data) - (footer_length + sizeof pac_sof_marker);
834 if (n < 0) {
835 frame->data_end += n;
836 n = 0;
837 }
838 frame = gspca_frame_add(gspca_dev, INTER_PACKET, frame,
839 data, n);
840 if (gspca_dev->last_packet_type != DISCARD_PACKET &&
841 frame->data_end[-2] == 0xff &&
842 frame->data_end[-1] == 0xd9)
551 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 843 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
552 data, p); 844 NULL, 0);
553 845
554 /* put the JPEG header in the new frame */ 846 n = sof - data;
555 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 847 len -= n;
556 (unsigned char *) pac7311_jpeg_header, 848 data = sof;
557 12); 849
850 /* Get average lumination */
851 if (gspca_dev->last_packet_type == LAST_PACKET &&
852 n >= lum_offset)
853 atomic_set(&sd->avg_lum, data[-lum_offset] +
854 data[-lum_offset + 1]);
855 else
856 atomic_set(&sd->avg_lum, -1);
857
858 /* Start the new frame with the jpeg header */
859 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
860 pac7311_jpeg_header1, sizeof(pac7311_jpeg_header1));
861 if (sd->sensor == SENSOR_PAC7302) {
862 /* The PAC7302 has the image rotated 90 degrees */
863 tmpbuf[0] = gspca_dev->width >> 8;
864 tmpbuf[1] = gspca_dev->width & 0xff;
865 tmpbuf[2] = gspca_dev->height >> 8;
866 tmpbuf[3] = gspca_dev->height & 0xff;
867 } else {
558 tmpbuf[0] = gspca_dev->height >> 8; 868 tmpbuf[0] = gspca_dev->height >> 8;
559 tmpbuf[1] = gspca_dev->height & 0xff; 869 tmpbuf[1] = gspca_dev->height & 0xff;
560 tmpbuf[2] = gspca_dev->width >> 8; 870 tmpbuf[2] = gspca_dev->width >> 8;
561 tmpbuf[3] = gspca_dev->width & 0xff; 871 tmpbuf[3] = gspca_dev->width & 0xff;
562 gspca_frame_add(gspca_dev, INTER_PACKET, frame,
563 tmpbuf, 4);
564 gspca_frame_add(gspca_dev, INTER_PACKET, frame,
565 (unsigned char *) &pac7311_jpeg_header[16],
566 PAC7311_JPEG_HEADER_SIZE - 16);
567
568 data += p + 7;
569 len -= p + 7;
570 ffseq = 0;
571 break;
572 } 872 }
873 gspca_frame_add(gspca_dev, INTER_PACKET, frame, tmpbuf, 4);
874 gspca_frame_add(gspca_dev, INTER_PACKET, frame,
875 pac7311_jpeg_header2, sizeof(pac7311_jpeg_header2));
573 } 876 }
574
575 /* remove the 'ff ff ff xx' sequences */
576 switch (ffseq) {
577 case 3:
578 data += 1;
579 len -= 1;
580 break;
581 case 2:
582 if (data[0] == 0xff) {
583 data += 2;
584 len -= 2;
585 frame->data_end -= 2;
586 }
587 break;
588 case 1:
589 if (data[0] == 0xff
590 && data[1] == 0xff) {
591 data += 3;
592 len -= 3;
593 frame->data_end -= 1;
594 }
595 break;
596 }
597 for (i = 0; i < len - 4; i++) {
598 if (data[i] == 0xff
599 && data[i + 1] == 0xff
600 && data[i + 2] == 0xff) {
601 memmove(&data[i], &data[i + 4], len - i - 4);
602 len -= 4;
603 }
604 }
605 ffseq = 0;
606 if (data[len - 4] == 0xff) {
607 if (data[len - 3] == 0xff
608 && data[len - 2] == 0xff) {
609 len -= 4;
610 }
611 } else if (data[len - 3] == 0xff) {
612 if (data[len - 2] == 0xff
613 && data[len - 1] == 0xff)
614 ffseq = 3;
615 } else if (data[len - 2] == 0xff) {
616 if (data[len - 1] == 0xff)
617 ffseq = 2;
618 } else if (data[len - 1] == 0xff)
619 ffseq = 1;
620 sd->ffseq = ffseq;
621 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 877 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
622} 878}
623 879
624static void getbrightness(struct gspca_dev *gspca_dev)
625{
626/* sd->brightness = reg_r(gspca_dev, 0x08);
627 return sd->brightness; */
628/* PDEBUG(D_CONF, "Called pac7311_getbrightness: Not implemented yet"); */
629}
630
631
632
633static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 880static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
634{ 881{
635 struct sd *sd = (struct sd *) gspca_dev; 882 struct sd *sd = (struct sd *) gspca_dev;
636 883
637 sd->brightness = val; 884 sd->brightness = val;
638 if (gspca_dev->streaming) 885 if (gspca_dev->streaming)
639 setbrightness(gspca_dev); 886 setbrightcont(gspca_dev);
640 return 0; 887 return 0;
641} 888}
642 889
@@ -644,7 +891,6 @@ static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
644{ 891{
645 struct sd *sd = (struct sd *) gspca_dev; 892 struct sd *sd = (struct sd *) gspca_dev;
646 893
647 getbrightness(gspca_dev);
648 *val = sd->brightness; 894 *val = sd->brightness;
649 return 0; 895 return 0;
650} 896}
@@ -654,8 +900,12 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
654 struct sd *sd = (struct sd *) gspca_dev; 900 struct sd *sd = (struct sd *) gspca_dev;
655 901
656 sd->contrast = val; 902 sd->contrast = val;
657 if (gspca_dev->streaming) 903 if (gspca_dev->streaming) {
658 setcontrast(gspca_dev); 904 if (sd->sensor == SENSOR_PAC7302)
905 setbrightcont(gspca_dev);
906 else
907 setcontrast(gspca_dev);
908 }
659 return 0; 909 return 0;
660} 910}
661 911
@@ -663,7 +913,6 @@ static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
663{ 913{
664 struct sd *sd = (struct sd *) gspca_dev; 914 struct sd *sd = (struct sd *) gspca_dev;
665 915
666/* getcontrast(gspca_dev); */
667 *val = sd->contrast; 916 *val = sd->contrast;
668 return 0; 917 return 0;
669} 918}
@@ -682,18 +931,66 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
682{ 931{
683 struct sd *sd = (struct sd *) gspca_dev; 932 struct sd *sd = (struct sd *) gspca_dev;
684 933
685/* getcolors(gspca_dev); */
686 *val = sd->colors; 934 *val = sd->colors;
687 return 0; 935 return 0;
688} 936}
689 937
938static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val)
939{
940 struct sd *sd = (struct sd *) gspca_dev;
941
942 sd->gain = val;
943 if (gspca_dev->streaming)
944 setgain(gspca_dev);
945 return 0;
946}
947
948static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val)
949{
950 struct sd *sd = (struct sd *) gspca_dev;
951
952 *val = sd->gain;
953 return 0;
954}
955
956static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val)
957{
958 struct sd *sd = (struct sd *) gspca_dev;
959
960 sd->exposure = val;
961 if (gspca_dev->streaming)
962 setexposure(gspca_dev);
963 return 0;
964}
965
966static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val)
967{
968 struct sd *sd = (struct sd *) gspca_dev;
969
970 *val = sd->exposure;
971 return 0;
972}
973
690static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) 974static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
691{ 975{
692 struct sd *sd = (struct sd *) gspca_dev; 976 struct sd *sd = (struct sd *) gspca_dev;
693 977
694 sd->autogain = val; 978 sd->autogain = val;
695 if (gspca_dev->streaming) 979 /* when switching to autogain set defaults to make sure
696 setautogain(gspca_dev); 980 we are on a valid point of the autogain gain /
981 exposure knee graph, and give this change time to
982 take effect before doing autogain. */
983 if (sd->autogain) {
984 sd->exposure = EXPOSURE_DEF;
985 sd->gain = GAIN_DEF;
986 if (gspca_dev->streaming) {
987 sd->autogain_ignore_frames =
988 PAC_AUTOGAIN_IGNORE_FRAMES;
989 setexposure(gspca_dev);
990 setgain(gspca_dev);
991 }
992 }
993
697 return 0; 994 return 0;
698} 995}
699 996
@@ -705,30 +1002,67 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
705 return 0; 1002 return 0;
706} 1003}
707 1004
1005static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val)
1006{
1007 struct sd *sd = (struct sd *) gspca_dev;
1008
1009 sd->hflip = val;
1010 if (gspca_dev->streaming)
1011 sethvflip(gspca_dev);
1012 return 0;
1013}
1014
1015static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val)
1016{
1017 struct sd *sd = (struct sd *) gspca_dev;
1018
1019 *val = sd->hflip;
1020 return 0;
1021}
1022
1023static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
1024{
1025 struct sd *sd = (struct sd *) gspca_dev;
1026
1027 sd->vflip = val;
1028 if (gspca_dev->streaming)
1029 sethvflip(gspca_dev);
1030 return 0;
1031}
1032
1033static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
1034{
1035 struct sd *sd = (struct sd *) gspca_dev;
1036
1037 *val = sd->vflip;
1038 return 0;
1039}
1040
708/* sub-driver description */ 1041/* sub-driver description */
709static struct sd_desc sd_desc = { 1042static struct sd_desc sd_desc = {
710 .name = MODULE_NAME, 1043 .name = MODULE_NAME,
711 .ctrls = sd_ctrls, 1044 .ctrls = sd_ctrls,
712 .nctrls = ARRAY_SIZE(sd_ctrls), 1045 .nctrls = ARRAY_SIZE(sd_ctrls),
713 .config = sd_config, 1046 .config = sd_config,
714 .open = sd_open, 1047 .init = sd_init,
715 .start = sd_start, 1048 .start = sd_start,
716 .stopN = sd_stopN, 1049 .stopN = sd_stopN,
717 .stop0 = sd_stop0, 1050 .stop0 = sd_stop0,
718 .close = sd_close,
719 .pkt_scan = sd_pkt_scan, 1051 .pkt_scan = sd_pkt_scan,
720 .dq_callback = do_autogain, 1052 .dq_callback = do_autogain,
721}; 1053};
722 1054
723/* -- module initialisation -- */ 1055/* -- module initialisation -- */
724static __devinitdata struct usb_device_id device_table[] = { 1056static __devinitdata struct usb_device_id device_table[] = {
725 {USB_DEVICE(0x093a, 0x2600)}, 1057 {USB_DEVICE(0x093a, 0x2600), .driver_info = SENSOR_PAC7311},
726 {USB_DEVICE(0x093a, 0x2601)}, 1058 {USB_DEVICE(0x093a, 0x2601), .driver_info = SENSOR_PAC7311},
727 {USB_DEVICE(0x093a, 0x2603)}, 1059 {USB_DEVICE(0x093a, 0x2603), .driver_info = SENSOR_PAC7311},
728 {USB_DEVICE(0x093a, 0x2608)}, 1060 {USB_DEVICE(0x093a, 0x2608), .driver_info = SENSOR_PAC7311},
729 {USB_DEVICE(0x093a, 0x260e)}, 1061 {USB_DEVICE(0x093a, 0x260e), .driver_info = SENSOR_PAC7311},
730 {USB_DEVICE(0x093a, 0x260f)}, 1062 {USB_DEVICE(0x093a, 0x260f), .driver_info = SENSOR_PAC7311},
731 {USB_DEVICE(0x093a, 0x2621)}, 1063 {USB_DEVICE(0x093a, 0x2621), .driver_info = SENSOR_PAC7302},
1064 {USB_DEVICE(0x093a, 0x2624), .driver_info = SENSOR_PAC7302},
1065 {USB_DEVICE(0x093a, 0x2626), .driver_info = SENSOR_PAC7302},
732 {} 1066 {}
733}; 1067};
734MODULE_DEVICE_TABLE(usb, device_table); 1068MODULE_DEVICE_TABLE(usb, device_table);
@@ -746,6 +1080,10 @@ static struct usb_driver sd_driver = {
746 .id_table = device_table, 1080 .id_table = device_table,
747 .probe = sd_probe, 1081 .probe = sd_probe,
748 .disconnect = gspca_disconnect, 1082 .disconnect = gspca_disconnect,
1083#ifdef CONFIG_PM
1084 .suspend = gspca_suspend,
1085 .resume = gspca_resume,
1086#endif
749}; 1087};
750 1088
751/* -- module insert / remove -- */ 1089/* -- module insert / remove -- */