spca500.c 29.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/*
 * SPCA500 chip based cameras initialization data
 *
 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#define MODULE_NAME "spca500"

#include "gspca.h"
#include "jpeg.h"

MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
MODULE_DESCRIPTION("GSPCA/SPCA500 USB Camera Driver");
MODULE_LICENSE("GPL");

/* specific webcam descriptor */
struct sd {
	struct gspca_dev gspca_dev;		/* !! must be the first item */

	unsigned char brightness;
	unsigned char contrast;
	unsigned char colors;
38
	u8 quality;
39 40 41
#define QUALITY_MIN 70
#define QUALITY_MAX 95
#define QUALITY_DEF 85
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

	char subtype;
#define AgfaCl20 0
#define AiptekPocketDV 1
#define BenqDC1016 2
#define CreativePCCam300 3
#define DLinkDSC350 4
#define Gsmartmini 5
#define IntelPocketPCCamera 6
#define KodakEZ200 7
#define LogitechClickSmart310 8
#define LogitechClickSmart510 9
#define LogitechTraveler 10
#define MustekGsmart300 11
#define Optimedia 12
#define PalmPixDC85 13
#define ToptroIndus 14
59 60

	u8 *jpeg_hdr;
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
};

/* V4L2 controls supported by the driver */
static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);

static struct ctrl sd_ctrls[] = {
	{
	    {
		.id      = V4L2_CID_BRIGHTNESS,
		.type    = V4L2_CTRL_TYPE_INTEGER,
		.name    = "Brightness",
		.minimum = 0,
78
		.maximum = 255,
79
		.step    = 1,
80 81
#define BRIGHTNESS_DEF 127
		.default_value = BRIGHTNESS_DEF,
82 83 84 85 86 87 88 89 90 91
	    },
	    .set = sd_setbrightness,
	    .get = sd_getbrightness,
	},
	{
	    {
		.id      = V4L2_CID_CONTRAST,
		.type    = V4L2_CTRL_TYPE_INTEGER,
		.name    = "Contrast",
		.minimum = 0,
92
		.maximum = 63,
93
		.step    = 1,
94 95
#define CONTRAST_DEF 31
		.default_value = CONTRAST_DEF,
96 97 98 99 100 101 102 103 104 105
	    },
	    .set = sd_setcontrast,
	    .get = sd_getcontrast,
	},
	{
	    {
		.id      = V4L2_CID_SATURATION,
		.type    = V4L2_CTRL_TYPE_INTEGER,
		.name    = "Color",
		.minimum = 0,
106
		.maximum = 63,
107
		.step    = 1,
108 109
#define COLOR_DEF 31
		.default_value = COLOR_DEF,
110 111 112 113 114 115
	    },
	    .set = sd_setcolors,
	    .get = sd_getcolors,
	},
};

116
static const struct v4l2_pix_format vga_mode[] = {
117 118 119 120 121 122 123 124 125 126
	{320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
		.bytesperline = 320,
		.sizeimage = 320 * 240 * 3 / 8 + 590,
		.colorspace = V4L2_COLORSPACE_JPEG,
		.priv = 1},
	{640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
		.bytesperline = 640,
		.sizeimage = 640 * 480 * 3 / 8 + 590,
		.colorspace = V4L2_COLORSPACE_JPEG,
		.priv = 0},
127 128
};

129
static const struct v4l2_pix_format sif_mode[] = {
130 131 132 133 134 135 136 137 138 139
	{176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
		.bytesperline = 176,
		.sizeimage = 176 * 144 * 3 / 8 + 590,
		.colorspace = V4L2_COLORSPACE_JPEG,
		.priv = 1},
	{352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
		.bytesperline = 352,
		.sizeimage = 352 * 288 * 3 / 8 + 590,
		.colorspace = V4L2_COLORSPACE_JPEG,
		.priv = 0},
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
};

/* Frame packet header offsets for the spca500 */
#define SPCA500_OFFSET_PADDINGLB 2
#define SPCA500_OFFSET_PADDINGHB 3
#define SPCA500_OFFSET_MODE      4
#define SPCA500_OFFSET_IMGWIDTH  5
#define SPCA500_OFFSET_IMGHEIGHT 6
#define SPCA500_OFFSET_IMGMODE   7
#define SPCA500_OFFSET_QTBLINDEX 8
#define SPCA500_OFFSET_FRAMSEQ   9
#define SPCA500_OFFSET_CDSPINFO  10
#define SPCA500_OFFSET_GPIO      11
#define SPCA500_OFFSET_AUGPIO    12
#define SPCA500_OFFSET_DATA      16


157
static const __u16 spca500_visual_defaults[][3] = {
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
	{0x00, 0x0003, 0x816b},	/* SSI not active sync with vsync,
				 * hue (H byte) = 0,
				 * saturation/hue enable,
				 * brightness/contrast enable.
				 */
	{0x00, 0x0000, 0x8167},	/* brightness = 0 */
	{0x00, 0x0020, 0x8168},	/* contrast = 0 */
	{0x00, 0x0003, 0x816b},	/* SSI not active sync with vsync,
				 * hue (H byte) = 0, saturation/hue enable,
				 * brightness/contrast enable.
				 * was 0x0003, now 0x0000.
				 */
	{0x00, 0x0000, 0x816a},	/* hue (L byte) = 0 */
	{0x00, 0x0020, 0x8169},	/* saturation = 0x20 */
	{0x00, 0x0050, 0x8157},	/* edge gain high threshold */
	{0x00, 0x0030, 0x8158},	/* edge gain low threshold */
	{0x00, 0x0028, 0x8159},	/* edge bandwidth high threshold */
	{0x00, 0x000a, 0x815a},	/* edge bandwidth low threshold */
	{0x00, 0x0001, 0x8202},	/* clock rate compensation = 1/25 sec/frame */
	{0x0c, 0x0004, 0x0000},
	/* set interface */
179
	{}
180
};
181
static const __u16 Clicksmart510_defaults[][3] = {
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
	{0x00, 0x00, 0x8211},
	{0x00, 0x01, 0x82c0},
	{0x00, 0x10, 0x82cb},
	{0x00, 0x0f, 0x800d},
	{0x00, 0x82, 0x8225},
	{0x00, 0x21, 0x8228},
	{0x00, 0x00, 0x8203},
	{0x00, 0x00, 0x8204},
	{0x00, 0x08, 0x8205},
	{0x00, 0xf8, 0x8206},
	{0x00, 0x28, 0x8207},
	{0x00, 0xa0, 0x8208},
	{0x00, 0x08, 0x824a},
	{0x00, 0x08, 0x8214},
	{0x00, 0x80, 0x82c1},
	{0x00, 0x00, 0x82c2},
	{0x00, 0x00, 0x82ca},
	{0x00, 0x80, 0x82c1},
	{0x00, 0x04, 0x82c2},
	{0x00, 0x00, 0x82ca},
	{0x00, 0xfc, 0x8100},
	{0x00, 0xfc, 0x8105},
	{0x00, 0x30, 0x8101},
	{0x00, 0x00, 0x8102},
	{0x00, 0x00, 0x8103},
	{0x00, 0x66, 0x8107},
	{0x00, 0x00, 0x816b},
	{0x00, 0x00, 0x8155},
	{0x00, 0x01, 0x8156},
	{0x00, 0x60, 0x8157},
	{0x00, 0x40, 0x8158},
	{0x00, 0x0a, 0x8159},
	{0x00, 0x06, 0x815a},
	{0x00, 0x00, 0x813f},
	{0x00, 0x00, 0x8200},
	{0x00, 0x19, 0x8201},
	{0x00, 0x00, 0x82c1},
	{0x00, 0xa0, 0x82c2},
	{0x00, 0x00, 0x82ca},
	{0x00, 0x00, 0x8117},
	{0x00, 0x00, 0x8118},
	{0x00, 0x65, 0x8119},
	{0x00, 0x00, 0x811a},
	{0x00, 0x00, 0x811b},
	{0x00, 0x55, 0x811c},
	{0x00, 0x65, 0x811d},
	{0x00, 0x55, 0x811e},
	{0x00, 0x16, 0x811f},
	{0x00, 0x19, 0x8120},
	{0x00, 0x80, 0x8103},
	{0x00, 0x83, 0x816b},
	{0x00, 0x25, 0x8168},
	{0x00, 0x01, 0x820f},
	{0x00, 0xff, 0x8115},
	{0x00, 0x48, 0x8116},
	{0x00, 0x50, 0x8151},
	{0x00, 0x40, 0x8152},
	{0x00, 0x78, 0x8153},
	{0x00, 0x40, 0x8154},
	{0x00, 0x00, 0x8167},
	{0x00, 0x20, 0x8168},
	{0x00, 0x00, 0x816a},
	{0x00, 0x03, 0x816b},
	{0x00, 0x20, 0x8169},
	{0x00, 0x60, 0x8157},
	{0x00, 0x00, 0x8190},
	{0x00, 0x00, 0x81a1},
	{0x00, 0x00, 0x81b2},
	{0x00, 0x27, 0x8191},
	{0x00, 0x27, 0x81a2},
	{0x00, 0x27, 0x81b3},
	{0x00, 0x4b, 0x8192},
	{0x00, 0x4b, 0x81a3},
	{0x00, 0x4b, 0x81b4},
	{0x00, 0x66, 0x8193},
	{0x00, 0x66, 0x81a4},
	{0x00, 0x66, 0x81b5},
	{0x00, 0x79, 0x8194},
	{0x00, 0x79, 0x81a5},
	{0x00, 0x79, 0x81b6},
	{0x00, 0x8a, 0x8195},
	{0x00, 0x8a, 0x81a6},
	{0x00, 0x8a, 0x81b7},
	{0x00, 0x9b, 0x8196},
	{0x00, 0x9b, 0x81a7},
	{0x00, 0x9b, 0x81b8},
	{0x00, 0xa6, 0x8197},
	{0x00, 0xa6, 0x81a8},
	{0x00, 0xa6, 0x81b9},
	{0x00, 0xb2, 0x8198},
	{0x00, 0xb2, 0x81a9},
	{0x00, 0xb2, 0x81ba},
	{0x00, 0xbe, 0x8199},
	{0x00, 0xbe, 0x81aa},
	{0x00, 0xbe, 0x81bb},
	{0x00, 0xc8, 0x819a},
	{0x00, 0xc8, 0x81ab},
	{0x00, 0xc8, 0x81bc},
	{0x00, 0xd2, 0x819b},
	{0x00, 0xd2, 0x81ac},
	{0x00, 0xd2, 0x81bd},
	{0x00, 0xdb, 0x819c},
	{0x00, 0xdb, 0x81ad},
	{0x00, 0xdb, 0x81be},
	{0x00, 0xe4, 0x819d},
	{0x00, 0xe4, 0x81ae},
	{0x00, 0xe4, 0x81bf},
	{0x00, 0xed, 0x819e},
	{0x00, 0xed, 0x81af},
	{0x00, 0xed, 0x81c0},
	{0x00, 0xf7, 0x819f},
	{0x00, 0xf7, 0x81b0},
	{0x00, 0xf7, 0x81c1},
	{0x00, 0xff, 0x81a0},
	{0x00, 0xff, 0x81b1},
	{0x00, 0xff, 0x81c2},
	{0x00, 0x03, 0x8156},
	{0x00, 0x00, 0x8211},
	{0x00, 0x20, 0x8168},
	{0x00, 0x01, 0x8202},
	{0x00, 0x30, 0x8101},
	{0x00, 0x00, 0x8111},
	{0x00, 0x00, 0x8112},
	{0x00, 0x00, 0x8113},
	{0x00, 0x00, 0x8114},
	{}
};

310
static const __u8 qtable_creative_pccam[2][64] = {
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
	{				/* Q-table Y-components */
	 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
	 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
	 0x04, 0x04, 0x05, 0x07, 0x0c, 0x11, 0x15, 0x11,
	 0x04, 0x05, 0x07, 0x09, 0x0f, 0x1a, 0x18, 0x13,
	 0x05, 0x07, 0x0b, 0x11, 0x14, 0x21, 0x1f, 0x17,
	 0x07, 0x0b, 0x11, 0x13, 0x18, 0x1f, 0x22, 0x1c,
	 0x0f, 0x13, 0x17, 0x1a, 0x1f, 0x24, 0x24, 0x1e,
	 0x16, 0x1c, 0x1d, 0x1d, 0x22, 0x1e, 0x1f, 0x1e},
	{				/* Q-table C-components */
	 0x05, 0x05, 0x07, 0x0e, 0x1e, 0x1e, 0x1e, 0x1e,
	 0x05, 0x06, 0x08, 0x14, 0x1e, 0x1e, 0x1e, 0x1e,
	 0x07, 0x08, 0x11, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
	 0x0e, 0x14, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
	 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
	 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
	 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
	 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e}
};

331
static const __u8 qtable_kodak_ez200[2][64] = {
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
	{				/* Q-table Y-components */
	 0x02, 0x01, 0x01, 0x02, 0x02, 0x04, 0x05, 0x06,
	 0x01, 0x01, 0x01, 0x02, 0x03, 0x06, 0x06, 0x06,
	 0x01, 0x01, 0x02, 0x02, 0x04, 0x06, 0x07, 0x06,
	 0x01, 0x02, 0x02, 0x03, 0x05, 0x09, 0x08, 0x06,
	 0x02, 0x02, 0x04, 0x06, 0x07, 0x0b, 0x0a, 0x08,
	 0x02, 0x04, 0x06, 0x06, 0x08, 0x0a, 0x0b, 0x09,
	 0x05, 0x06, 0x08, 0x09, 0x0a, 0x0c, 0x0c, 0x0a,
	 0x07, 0x09, 0x0a, 0x0a, 0x0b, 0x0a, 0x0a, 0x0a},
	{				/* Q-table C-components */
	 0x02, 0x02, 0x02, 0x05, 0x0a, 0x0a, 0x0a, 0x0a,
	 0x02, 0x02, 0x03, 0x07, 0x0a, 0x0a, 0x0a, 0x0a,
	 0x02, 0x03, 0x06, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
	 0x05, 0x07, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
	 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
	 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
	 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
	 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a}
};

352
static const __u8 qtable_pocketdv[2][64] = {
353
	{		/* Q-table Y-components start registers 0x8800 */
354 355 356 357 358 359 360 361 362
	 0x06, 0x04, 0x04, 0x06, 0x0a, 0x10, 0x14, 0x18,
	 0x05, 0x05, 0x06, 0x08, 0x0a, 0x17, 0x18, 0x16,
	 0x06, 0x05, 0x06, 0x0a, 0x10, 0x17, 0x1c, 0x16,
	 0x06, 0x07, 0x09, 0x0c, 0x14, 0x23, 0x20, 0x19,
	 0x07, 0x09, 0x0f, 0x16, 0x1b, 0x2c, 0x29, 0x1f,
	 0x0a, 0x0e, 0x16, 0x1a, 0x20, 0x2a, 0x2d, 0x25,
	 0x14, 0x1a, 0x1f, 0x23, 0x29, 0x30, 0x30, 0x28,
	 0x1d, 0x25, 0x26, 0x27, 0x2d, 0x28, 0x29, 0x28,
	 },
363
	{		/* Q-table C-components start registers 0x8840 */
364 365 366 367 368 369 370 371 372 373
	 0x07, 0x07, 0x0a, 0x13, 0x28, 0x28, 0x28, 0x28,
	 0x07, 0x08, 0x0a, 0x1a, 0x28, 0x28, 0x28, 0x28,
	 0x0a, 0x0a, 0x16, 0x28, 0x28, 0x28, 0x28, 0x28,
	 0x13, 0x1a, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
	 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
	 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
	 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
	 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28}
};

374 375 376 377
/* read 'len' bytes to gspca_dev->usb_buf */
static void reg_r(struct gspca_dev *gspca_dev,
		  __u16 index,
		  __u16 length)
378
{
379 380
	usb_control_msg(gspca_dev->dev,
			usb_rcvctrlpipe(gspca_dev->dev, 0),
381 382 383
			0,
			USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
			0,		/* value */
384
			index, gspca_dev->usb_buf, length, 500);
385 386
}

387
static int reg_w(struct gspca_dev *gspca_dev,
388 389 390 391
		     __u16 req, __u16 index, __u16 value)
{
	int ret;

392
	PDEBUG(D_USBO, "reg write: [0x%02x] = 0x%02x", index, value);
393 394
	ret = usb_control_msg(gspca_dev->dev,
			usb_sndctrlpipe(gspca_dev->dev, 0),
395
			req,
396
			USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
397 398 399 400 401 402 403
			value, index, NULL, 0, 500);
	if (ret < 0)
		PDEBUG(D_ERR, "reg write: error %d", ret);
	return ret;
}

/* returns: negative is error, pos or zero is data */
404
static int reg_r_12(struct gspca_dev *gspca_dev,
405 406 407 408 409 410
			__u16 req,	/* bRequest */
			__u16 index,	/* wIndex */
			__u16 length)	/* wLength (1 or 2 only) */
{
	int ret;

411 412 413
	gspca_dev->usb_buf[1] = 0;
	ret = usb_control_msg(gspca_dev->dev,
			usb_rcvctrlpipe(gspca_dev->dev, 0),
414 415 416 417
			req,
			USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
			0,		/* value */
			index,
418
			gspca_dev->usb_buf, length,
419 420
			500);		/* timeout */
	if (ret < 0) {
421
		PDEBUG(D_ERR, "reg_r_12 err %d", ret);
422 423
		return -1;
	}
424
	return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0];
425 426 427 428 429 430 431
}

/*
 * Simple function to wait for a given 8-bit value to be returned from
 * a reg_read call.
 * Returns: negative is error or timeout, zero is success.
 */
432
static int reg_r_wait(struct gspca_dev *gspca_dev,
433 434 435 436 437
			__u16 reg, __u16 index, __u16 value)
{
	int ret, cnt = 20;

	while (--cnt > 0) {
438
		ret = reg_r_12(gspca_dev, reg, index, 1);
439 440 441 442 443 444 445 446
		if (ret == value)
			return 0;
		msleep(50);
	}
	return -EIO;
}

static int write_vector(struct gspca_dev *gspca_dev,
447
			const __u16 data[][3])
448 449 450 451
{
	int ret, i = 0;

	while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) {
452
		ret = reg_w(gspca_dev, data[i][0], data[i][2], data[i][1]);
453 454 455 456 457 458 459 460 461 462 463
		if (ret < 0)
			return ret;
		i++;
	}
	return 0;
}

static int spca50x_setup_qtable(struct gspca_dev *gspca_dev,
				unsigned int request,
				unsigned int ybase,
				unsigned int cbase,
464
				const __u8 qtable[2][64])
465 466 467 468 469
{
	int i, err;

	/* loop over y components */
	for (i = 0; i < 64; i++) {
470
		err = reg_w(gspca_dev, request, ybase + i, qtable[0][i]);
471 472 473 474 475 476
		if (err < 0)
			return err;
	}

	/* loop over c components */
	for (i = 0; i < 64; i++) {
477
		err = reg_w(gspca_dev, request, cbase + i, qtable[1][i]);
478 479 480 481 482 483 484 485
		if (err < 0)
			return err;
	}
	return 0;
}

static void spca500_ping310(struct gspca_dev *gspca_dev)
{
486
	reg_r(gspca_dev, 0x0d04, 2);
487
	PDEBUG(D_STREAM, "ClickSmart310 ping 0x0d04 0x%02x 0x%02x",
488
		gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]);
489 490 491 492
}

static void spca500_clksmart310_init(struct gspca_dev *gspca_dev)
{
493
	reg_r(gspca_dev, 0x0d05, 2);
494
	PDEBUG(D_STREAM, "ClickSmart310 init 0x0d05 0x%02x 0x%02x",
495 496
		gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]);
	reg_w(gspca_dev, 0x00, 0x8167, 0x5a);
497 498
	spca500_ping310(gspca_dev);

499 500 501 502 503 504 505 506 507 508
	reg_w(gspca_dev, 0x00, 0x8168, 0x22);
	reg_w(gspca_dev, 0x00, 0x816a, 0xc0);
	reg_w(gspca_dev, 0x00, 0x816b, 0x0b);
	reg_w(gspca_dev, 0x00, 0x8169, 0x25);
	reg_w(gspca_dev, 0x00, 0x8157, 0x5b);
	reg_w(gspca_dev, 0x00, 0x8158, 0x5b);
	reg_w(gspca_dev, 0x00, 0x813f, 0x03);
	reg_w(gspca_dev, 0x00, 0x8151, 0x4a);
	reg_w(gspca_dev, 0x00, 0x8153, 0x78);
	reg_w(gspca_dev, 0x00, 0x0d01, 0x04);
509
						/* 00 for adjust shutter */
510 511 512
	reg_w(gspca_dev, 0x00, 0x0d02, 0x01);
	reg_w(gspca_dev, 0x00, 0x8169, 0x25);
	reg_w(gspca_dev, 0x00, 0x0d01, 0x02);
513 514 515 516 517 518 519 520
}

static void spca500_setmode(struct gspca_dev *gspca_dev,
			__u8 xmult, __u8 ymult)
{
	int mode;

	/* set x multiplier */
521
	reg_w(gspca_dev, 0, 0x8001, xmult);
522 523

	/* set y multiplier */
524
	reg_w(gspca_dev, 0, 0x8002, ymult);
525 526

	/* use compressed mode, VGA, with mode specific subsample */
527
	mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
528
	reg_w(gspca_dev, 0, 0x8003, mode << 4);
529 530 531 532 533 534 535
}

static int spca500_full_reset(struct gspca_dev *gspca_dev)
{
	int err;

	/* send the reset command */
536
	err = reg_w(gspca_dev, 0xe0, 0x0001, 0x0000);
537 538 539 540
	if (err < 0)
		return err;

	/* wait for the reset to complete */
541
	err = reg_r_wait(gspca_dev, 0x06, 0x0000, 0x0000);
542 543
	if (err < 0)
		return err;
544
	err = reg_w(gspca_dev, 0xe0, 0x0000, 0x0000);
545 546
	if (err < 0)
		return err;
547
	err = reg_r_wait(gspca_dev, 0x06, 0, 0);
548
	if (err < 0) {
549
		PDEBUG(D_ERR, "reg_r_wait() failed");
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
		return err;
	}
	/* all ok */
	return 0;
}

/* Synchro the Bridge with sensor */
/* Maybe that will work on all spca500 chip */
/* because i only own a clicksmart310 try for that chip */
/* using spca50x_set_packet_size() cause an Ooops here */
/* usb_set_interface from kernel 2.6.x clear all the urb stuff */
/* up-port the same feature as in 2.4.x kernel */
static int spca500_synch310(struct gspca_dev *gspca_dev)
{
	if (usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0) < 0) {
		PDEBUG(D_ERR, "Set packet size: set interface error");
		goto error;
	}
	spca500_ping310(gspca_dev);

570
	reg_r(gspca_dev, 0x0d00, 1);
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593

	/* need alt setting here */
	PDEBUG(D_PACK, "ClickSmart310 sync alt: %d", gspca_dev->alt);

	/* Windoze use pipe with altsetting 6 why 7 here */
	if (usb_set_interface(gspca_dev->dev,
				gspca_dev->iface,
				gspca_dev->alt) < 0) {
		PDEBUG(D_ERR, "Set packet size: set interface error");
		goto error;
	}
	return 0;
error:
	return -EBUSY;
}

static void spca500_reinit(struct gspca_dev *gspca_dev)
{
	int err;
	__u8 Data;

	/* some unknow command from Aiptek pocket dv and family300 */

594 595 596
	reg_w(gspca_dev, 0x00, 0x0d01, 0x01);
	reg_w(gspca_dev, 0x00, 0x0d03, 0x00);
	reg_w(gspca_dev, 0x00, 0x0d02, 0x01);
597 598

	/* enable drop packet */
599
	reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
600 601 602 603 604 605 606

	err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840,
				 qtable_pocketdv);
	if (err < 0)
		PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed on init");

	/* set qtable index */
607
	reg_w(gspca_dev, 0x00, 0x8880, 2);
608
	/* family cam Quicksmart stuff */
609
	reg_w(gspca_dev, 0x00, 0x800a, 0x00);
610
	/* Set agc transfer: synced inbetween frames */
611
	reg_w(gspca_dev, 0x00, 0x820f, 0x01);
612
	/* Init SDRAM - needed for SDRAM access */
613
	reg_w(gspca_dev, 0x00, 0x870a, 0x04);
614
	/*Start init sequence or stream */
615
	reg_w(gspca_dev, 0, 0x8003, 0x00);
616
	/* switch to video camera mode */
617
	reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
618
	msleep(2000);
619 620 621 622 623
	if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) {
		reg_r(gspca_dev, 0x816b, 1);
		Data = gspca_dev->usb_buf[0];
		reg_w(gspca_dev, 0x00, 0x816b, Data);
	}
624 625 626 627 628 629 630 631
}

/* this function is called at probe time */
static int sd_config(struct gspca_dev *gspca_dev,
			const struct usb_device_id *id)
{
	struct sd *sd = (struct sd *) gspca_dev;
	struct cam *cam;
632

633
	cam = &gspca_dev->cam;
634
	sd->subtype = id->driver_info;
635 636
	if (sd->subtype != LogitechClickSmart310) {
		cam->cam_mode = vga_mode;
637
		cam->nmodes = ARRAY_SIZE(vga_mode);
638 639
	} else {
		cam->cam_mode = sif_mode;
640
		cam->nmodes = ARRAY_SIZE(sif_mode);
641
	}
642 643 644
	sd->brightness = BRIGHTNESS_DEF;
	sd->contrast = CONTRAST_DEF;
	sd->colors = COLOR_DEF;
645
	sd->quality = QUALITY_DEF;
646 647 648
	return 0;
}

649 650
/* this function is called at probe and resume time */
static int sd_init(struct gspca_dev *gspca_dev)
651 652 653 654 655 656 657 658 659 660 661 662 663
{
	struct sd *sd = (struct sd *) gspca_dev;

	/* initialisation of spca500 based cameras is deferred */
	PDEBUG(D_STREAM, "SPCA500 init");
	if (sd->subtype == LogitechClickSmart310)
		spca500_clksmart310_init(gspca_dev);
/*	else
		spca500_initialise(gspca_dev); */
	PDEBUG(D_STREAM, "SPCA500 init done");
	return 0;
}

664
static int sd_start(struct gspca_dev *gspca_dev)
665 666 667 668 669 670
{
	struct sd *sd = (struct sd *) gspca_dev;
	int err;
	__u8 Data;
	__u8 xmult, ymult;

671 672
	/* create the JPEG header */
	sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
673 674
	if (!sd->jpeg_hdr)
		return -ENOMEM;
675 676 677 678
	jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
			0x22);		/* JPEG 411 */
	jpeg_set_qual(sd->jpeg_hdr, sd->quality);

679 680 681 682 683 684 685 686 687
	if (sd->subtype == LogitechClickSmart310) {
		xmult = 0x16;
		ymult = 0x12;
	} else {
		xmult = 0x28;
		ymult = 0x1e;
	}

	/* is there a sensor here ? */
688 689 690 691
	reg_r(gspca_dev, 0x8a04, 1);
	PDEBUG(D_STREAM, "Spca500 Sensor Address 0x%02x",
		gspca_dev->usb_buf[0]);
	PDEBUG(D_STREAM, "Spca500 curr_mode: %d Xmult: 0x%02x, Ymult: 0x%02x",
692 693 694 695 696 697 698 699
		gspca_dev->curr_mode, xmult, ymult);

	/* setup qtable */
	switch (sd->subtype) {
	case LogitechClickSmart310:
		 spca500_setmode(gspca_dev, xmult, ymult);

		/* enable drop packet */
700 701
		reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
		reg_w(gspca_dev, 0x00, 0x8880, 3);
702 703 704 705 706 707
		err = spca50x_setup_qtable(gspca_dev,
					   0x00, 0x8800, 0x8840,
					   qtable_creative_pccam);
		if (err < 0)
			PDEBUG(D_ERR, "spca50x_setup_qtable failed");
		/* Init SDRAM - needed for SDRAM access */
708
		reg_w(gspca_dev, 0x00, 0x870a, 0x04);
709 710

		/* switch to video camera mode */
711
		reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
712
		msleep(500);
713
		if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
714
			PDEBUG(D_ERR, "reg_r_wait() failed");
715

716 717 718
		reg_r(gspca_dev, 0x816b, 1);
		Data = gspca_dev->usb_buf[0];
		reg_w(gspca_dev, 0x00, 0x816b, Data);
719 720 721 722 723 724

		spca500_synch310(gspca_dev);

		write_vector(gspca_dev, spca500_visual_defaults);
		spca500_setmode(gspca_dev, xmult, ymult);
		/* enable drop packet */
725 726
		err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
		if (err < 0)
727
			PDEBUG(D_ERR, "failed to enable drop packet");
728
		reg_w(gspca_dev, 0x00, 0x8880, 3);
729 730 731 732 733 734 735
		err = spca50x_setup_qtable(gspca_dev,
					   0x00, 0x8800, 0x8840,
					   qtable_creative_pccam);
		if (err < 0)
			PDEBUG(D_ERR, "spca50x_setup_qtable failed");

		/* Init SDRAM - needed for SDRAM access */
736
		reg_w(gspca_dev, 0x00, 0x870a, 0x04);
737 738

		/* switch to video camera mode */
739
		reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
740

741
		if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
742
			PDEBUG(D_ERR, "reg_r_wait() failed");
743

744 745 746
		reg_r(gspca_dev, 0x816b, 1);
		Data = gspca_dev->usb_buf[0];
		reg_w(gspca_dev, 0x00, 0x816b, Data);
747 748 749 750 751 752 753
		break;
	case CreativePCCam300:		/* Creative PC-CAM 300 640x480 CCD */
	case IntelPocketPCCamera:	/* FIXME: Temporary fix for
					 *	Intel Pocket PC Camera
					 *	- NWG (Sat 29th March 2003) */

		/* do a full reset */
754 755
		err = spca500_full_reset(gspca_dev);
		if (err < 0)
756 757 758
			PDEBUG(D_ERR, "spca500_full_reset failed");

		/* enable drop packet */
759
		err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
760 761
		if (err < 0)
			PDEBUG(D_ERR, "failed to enable drop packet");
762
		reg_w(gspca_dev, 0x00, 0x8880, 3);
763 764 765 766 767 768 769
		err = spca50x_setup_qtable(gspca_dev,
					   0x00, 0x8800, 0x8840,
					   qtable_creative_pccam);
		if (err < 0)
			PDEBUG(D_ERR, "spca50x_setup_qtable failed");

		spca500_setmode(gspca_dev, xmult, ymult);
770
		reg_w(gspca_dev, 0x20, 0x0001, 0x0004);
771 772

		/* switch to video camera mode */
773
		reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
774

775
		if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
776
			PDEBUG(D_ERR, "reg_r_wait() failed");
777

778 779 780
		reg_r(gspca_dev, 0x816b, 1);
		Data = gspca_dev->usb_buf[0];
		reg_w(gspca_dev, 0x00, 0x816b, Data);
781

782
/*		write_vector(gspca_dev, spca500_visual_defaults); */
783 784 785 786 787 788 789 790
		break;
	case KodakEZ200:		/* Kodak EZ200 */

		/* do a full reset */
		err = spca500_full_reset(gspca_dev);
		if (err < 0)
			PDEBUG(D_ERR, "spca500_full_reset failed");
		/* enable drop packet */
791 792
		reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
		reg_w(gspca_dev, 0x00, 0x8880, 0);
793 794 795 796 797 798 799
		err = spca50x_setup_qtable(gspca_dev,
					   0x00, 0x8800, 0x8840,
					   qtable_kodak_ez200);
		if (err < 0)
			PDEBUG(D_ERR, "spca50x_setup_qtable failed");
		spca500_setmode(gspca_dev, xmult, ymult);

800
		reg_w(gspca_dev, 0x20, 0x0001, 0x0004);
801 802

		/* switch to video camera mode */
803
		reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
804

805
		if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0)
806
			PDEBUG(D_ERR, "reg_r_wait() failed");
807

808 809 810
		reg_r(gspca_dev, 0x816b, 1);
		Data = gspca_dev->usb_buf[0];
		reg_w(gspca_dev, 0x00, 0x816b, Data);
811

812
/*		write_vector(gspca_dev, spca500_visual_defaults); */
813 814 815 816 817 818 819 820 821 822 823 824
		break;

	case BenqDC1016:
	case DLinkDSC350:		/* FamilyCam 300 */
	case AiptekPocketDV:		/* Aiptek PocketDV */
	case Gsmartmini:		/*Mustek Gsmart Mini */
	case MustekGsmart300:		/* Mustek Gsmart 300 */
	case PalmPixDC85:
	case Optimedia:
	case ToptroIndus:
	case AgfaCl20:
		spca500_reinit(gspca_dev);
825
		reg_w(gspca_dev, 0x00, 0x0d01, 0x01);
826
		/* enable drop packet */
827
		reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
828 829 830 831 832

		err = spca50x_setup_qtable(gspca_dev,
				   0x00, 0x8800, 0x8840, qtable_pocketdv);
		if (err < 0)
			PDEBUG(D_ERR, "spca50x_setup_qtable failed");
833
		reg_w(gspca_dev, 0x00, 0x8880, 2);
834 835

		/* familycam Quicksmart pocketDV stuff */
836
		reg_w(gspca_dev, 0x00, 0x800a, 0x00);
837
		/* Set agc transfer: synced inbetween frames */
838
		reg_w(gspca_dev, 0x00, 0x820f, 0x01);
839
		/* Init SDRAM - needed for SDRAM access */
840
		reg_w(gspca_dev, 0x00, 0x870a, 0x04);
841

842
		spca500_setmode(gspca_dev, xmult, ymult);
843
		/* switch to video camera mode */
844
		reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
845

846
		reg_r_wait(gspca_dev, 0, 0x8000, 0x44);
847

848 849 850
		reg_r(gspca_dev, 0x816b, 1);
		Data = gspca_dev->usb_buf[0];
		reg_w(gspca_dev, 0x00, 0x816b, Data);
851 852 853
		break;
	case LogitechTraveler:
	case LogitechClickSmart510:
854
		reg_w(gspca_dev, 0x02, 0x00, 0x00);
855
		/* enable drop packet */
856
		reg_w(gspca_dev, 0x00, 0x850a, 0x0001);
857 858 859 860 861 862

		err = spca50x_setup_qtable(gspca_dev,
					0x00, 0x8800,
					0x8840, qtable_creative_pccam);
		if (err < 0)
			PDEBUG(D_ERR, "spca50x_setup_qtable failed");
863 864
		reg_w(gspca_dev, 0x00, 0x8880, 3);
		reg_w(gspca_dev, 0x00, 0x800a, 0x00);
865
		/* Init SDRAM - needed for SDRAM access */
866
		reg_w(gspca_dev, 0x00, 0x870a, 0x04);
867 868 869 870

		spca500_setmode(gspca_dev, xmult, ymult);

		/* switch to video camera mode */
871 872
		reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
		reg_r_wait(gspca_dev, 0, 0x8000, 0x44);
873

874 875 876
		reg_r(gspca_dev, 0x816b, 1);
		Data = gspca_dev->usb_buf[0];
		reg_w(gspca_dev, 0x00, 0x816b, Data);
877 878 879
		write_vector(gspca_dev, Clicksmart510_defaults);
		break;
	}
880
	return 0;
881 882 883 884
}

static void sd_stopN(struct gspca_dev *gspca_dev)
{
885
	reg_w(gspca_dev, 0, 0x8003, 0x00);
886 887

	/* switch to video camera mode */
888 889 890 891
	reg_w(gspca_dev, 0x00, 0x8000, 0x0004);
	reg_r(gspca_dev, 0x8000, 1);
	PDEBUG(D_STREAM, "stop SPCA500 done reg8000: 0x%2x",
		gspca_dev->usb_buf[0]);
892 893
}

894 895 896 897 898 899 900
static void sd_stop0(struct gspca_dev *gspca_dev)
{
	struct sd *sd = (struct sd *) gspca_dev;

	kfree(sd->jpeg_hdr);
}

901 902
static void sd_pkt_scan(struct gspca_dev *gspca_dev,
			struct gspca_frame *frame,	/* target */
903
			__u8 *data,			/* isoc packet */
904 905 906 907
			int len)			/* iso packet length */
{
	struct sd *sd = (struct sd *) gspca_dev;
	int i;
908
	static __u8 ffd9[] = {0xff, 0xd9};
909 910 911 912 913 914 915 916 917 918 919

/* frames are jpeg 4.1.1 without 0xff escape */
	if (data[0] == 0xff) {
		if (data[1] != 0x01) {	/* drop packet */
/*			gspca_dev->last_packet_type = DISCARD_PACKET; */
			return;
		}
		frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
					ffd9, 2);

		/* put the JPEG header in the new frame */
920 921
		gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
			sd->jpeg_hdr, JPEG_HDR_SZ);
922 923 924 925 926 927 928 929 930

		data += SPCA500_OFFSET_DATA;
		len -= SPCA500_OFFSET_DATA;
	} else {
		data += 1;
		len -= 1;
	}

	/* add 0x00 after 0xff */
931 932 933 934 935 936 937 938 939 940 941 942 943
	i = 0;
	do {
		if (data[i] == 0xff) {
			gspca_frame_add(gspca_dev, INTER_PACKET, frame,
					data, i + 1);
			len -= i;
			data += i;
			*data = 0x00;
			i = 0;
		}
		i++;
	} while (i < len);
	gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
944 945 946 947 948 949
}

static void setbrightness(struct gspca_dev *gspca_dev)
{
	struct sd *sd = (struct sd *) gspca_dev;

950
	reg_w(gspca_dev, 0x00, 0x8167,
951 952 953 954 955 956 957
			(__u8) (sd->brightness - 128));
}

static void setcontrast(struct gspca_dev *gspca_dev)
{
	struct sd *sd = (struct sd *) gspca_dev;

958
	reg_w(gspca_dev, 0x00, 0x8168, sd->contrast);
959 960 961 962 963 964
}

static void setcolors(struct gspca_dev *gspca_dev)
{
	struct sd *sd = (struct sd *) gspca_dev;

965
	reg_w(gspca_dev, 0x00, 0x8169, sd->colors);
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
}

static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
{
	struct sd *sd = (struct sd *) gspca_dev;

	sd->brightness = val;
	if (gspca_dev->streaming)
		setbrightness(gspca_dev);
	return 0;
}

static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
{
	struct sd *sd = (struct sd *) gspca_dev;

	*val = sd->brightness;
	return 0;
}

static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
{
	struct sd *sd = (struct sd *) gspca_dev;

	sd->contrast = val;
	if (gspca_dev->streaming)
		setcontrast(gspca_dev);
	return 0;
}

static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
{
	struct sd *sd = (struct sd *) gspca_dev;

	*val = sd->contrast;
	return 0;
}

static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
{
	struct sd *sd = (struct sd *) gspca_dev;

	sd->colors = val;
	if (gspca_dev->streaming)
		setcolors(gspca_dev);
	return 0;
}

static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
{
	struct sd *sd = (struct sd *) gspca_dev;

	*val = sd->colors;
	return 0;
}

1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
static int sd_set_jcomp(struct gspca_dev *gspca_dev,
			struct v4l2_jpegcompression *jcomp)
{
	struct sd *sd = (struct sd *) gspca_dev;

	if (jcomp->quality < QUALITY_MIN)
		sd->quality = QUALITY_MIN;
	else if (jcomp->quality > QUALITY_MAX)
		sd->quality = QUALITY_MAX;
	else
		sd->quality = jcomp->quality;
	if (gspca_dev->streaming)
		jpeg_set_qual(sd->jpeg_hdr, sd->quality);
	return 0;
}

static int sd_get_jcomp(struct gspca_dev *gspca_dev,
			struct v4l2_jpegcompression *jcomp)
{
	struct sd *sd = (struct sd *) gspca_dev;

	memset(jcomp, 0, sizeof *jcomp);
	jcomp->quality = sd->quality;
	jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
			| V4L2_JPEG_MARKER_DQT;
	return 0;
}

1050 1051 1052 1053
/* sub-driver description */
static struct sd_desc sd_desc = {
	.name = MODULE_NAME,
	.ctrls = sd_ctrls,
1054
	.nctrls = ARRAY_SIZE(sd_ctrls),
1055
	.config = sd_config,
1056
	.init = sd_init,
1057 1058
	.start = sd_start,
	.stopN = sd_stopN,
1059
	.stop0 = sd_stop0,
1060
	.pkt_scan = sd_pkt_scan,
1061 1062
	.get_jcomp = sd_get_jcomp,
	.set_jcomp = sd_set_jcomp,
1063 1064 1065
};

/* -- module initialisation -- */
1066
static const __devinitdata struct usb_device_id device_table[] = {
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081
	{USB_DEVICE(0x040a, 0x0300), .driver_info = KodakEZ200},
	{USB_DEVICE(0x041e, 0x400a), .driver_info = CreativePCCam300},
	{USB_DEVICE(0x046d, 0x0890), .driver_info = LogitechTraveler},
	{USB_DEVICE(0x046d, 0x0900), .driver_info = LogitechClickSmart310},
	{USB_DEVICE(0x046d, 0x0901), .driver_info = LogitechClickSmart510},
	{USB_DEVICE(0x04a5, 0x300c), .driver_info = BenqDC1016},
	{USB_DEVICE(0x04fc, 0x7333), .driver_info = PalmPixDC85},
	{USB_DEVICE(0x055f, 0xc200), .driver_info = MustekGsmart300},
	{USB_DEVICE(0x055f, 0xc220), .driver_info = Gsmartmini},
	{USB_DEVICE(0x06bd, 0x0404), .driver_info = AgfaCl20},
	{USB_DEVICE(0x06be, 0x0800), .driver_info = Optimedia},
	{USB_DEVICE(0x084d, 0x0003), .driver_info = DLinkDSC350},
	{USB_DEVICE(0x08ca, 0x0103), .driver_info = AiptekPocketDV},
	{USB_DEVICE(0x2899, 0x012c), .driver_info = ToptroIndus},
	{USB_DEVICE(0x8086, 0x0630), .driver_info = IntelPocketPCCamera},
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098
	{}
};
MODULE_DEVICE_TABLE(usb, device_table);

/* -- device connect -- */
static int sd_probe(struct usb_interface *intf,
			const struct usb_device_id *id)
{
	return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
				THIS_MODULE);
}

static struct usb_driver sd_driver = {
	.name = MODULE_NAME,
	.id_table = device_table,
	.probe = sd_probe,
	.disconnect = gspca_disconnect,
1099 1100 1101 1102
#ifdef CONFIG_PM
	.suspend = gspca_suspend,
	.resume = gspca_resume,
#endif
1103 1104 1105 1106 1107
};

/* -- module insert / remove -- */
static int __init sd_mod_init(void)
{
1108 1109 1110
	int ret;
	ret = usb_register(&sd_driver);
	if (ret < 0)
1111
		return ret;
1112
	PDEBUG(D_PROBE, "registered");
1113 1114 1115 1116 1117 1118 1119 1120 1121 1122
	return 0;
}
static void __exit sd_mod_exit(void)
{
	usb_deregister(&sd_driver);
	PDEBUG(D_PROBE, "deregistered");
}

module_init(sd_mod_init);
module_exit(sd_mod_exit);