blob: 6eb813e7b714de3c564120b4737c6625444482e2 [file] [log] [blame]
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -03001/*
2 * Mars-Semi MR97311A library
3 * Copyright (C) 2005 <bradlch@hotmail.com>
4 *
5 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#define MODULE_NAME "mars"
23
24#include "gspca.h"
25#include "jpeg.h"
26
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030027MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
28MODULE_DESCRIPTION("GSPCA/Mars USB Camera Driver");
29MODULE_LICENSE("GPL");
30
31/* specific webcam descriptor */
32struct sd {
33 struct gspca_dev gspca_dev; /* !! must be the first item */
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -030034
35 u8 brightness;
36 u8 colors;
37 u8 gamma;
38 u8 sharpness;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -030039 u8 quality;
40
41 u8 *jpeg_hdr;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030042};
43
44/* V4L2 controls supported by the driver */
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -030045static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
46static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
47static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
48static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
49static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
50static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
51static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
52static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
53
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -030054static struct ctrl sd_ctrls[] = {
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -030055 {
56 {
57 .id = V4L2_CID_BRIGHTNESS,
58 .type = V4L2_CTRL_TYPE_INTEGER,
59 .name = "Brightness",
60 .minimum = 0,
61 .maximum = 30,
62 .step = 1,
63#define BRIGHTNESS_DEF 15
64 .default_value = BRIGHTNESS_DEF,
65 },
66 .set = sd_setbrightness,
67 .get = sd_getbrightness,
68 },
69 {
70 {
71 .id = V4L2_CID_SATURATION,
72 .type = V4L2_CTRL_TYPE_INTEGER,
73 .name = "Color",
Jean-Francois Moine253bae52009-02-28 08:09:24 -030074 .minimum = 1,
75 .maximum = 255,
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -030076 .step = 1,
Jean-Francois Moine253bae52009-02-28 08:09:24 -030077#define COLOR_DEF 200
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -030078 .default_value = COLOR_DEF,
79 },
80 .set = sd_setcolors,
81 .get = sd_getcolors,
82 },
83 {
84 {
85 .id = V4L2_CID_GAMMA,
86 .type = V4L2_CTRL_TYPE_INTEGER,
87 .name = "Gamma",
88 .minimum = 0,
89 .maximum = 3,
90 .step = 1,
91#define GAMMA_DEF 1
92 .default_value = GAMMA_DEF,
93 },
94 .set = sd_setgamma,
95 .get = sd_getgamma,
96 },
97 {
98 {
99 .id = V4L2_CID_SHARPNESS,
100 .type = V4L2_CTRL_TYPE_INTEGER,
101 .name = "Sharpness",
102 .minimum = 0,
103 .maximum = 2,
104 .step = 1,
105#define SHARPNESS_DEF 1
106 .default_value = SHARPNESS_DEF,
107 },
108 .set = sd_setsharpness,
109 .get = sd_getsharpness,
110 },
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300111};
112
Jean-Francois Moinecc611b82008-12-29 07:49:41 -0300113static const struct v4l2_pix_format vga_mode[] = {
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300114 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
115 .bytesperline = 320,
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300116 .sizeimage = 320 * 240 * 3 / 8 + 590,
Jean-Francois Moinec2446b32008-07-05 11:49:20 -0300117 .colorspace = V4L2_COLORSPACE_JPEG,
118 .priv = 2},
119 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
120 .bytesperline = 640,
121 .sizeimage = 640 * 480 * 3 / 8 + 590,
122 .colorspace = V4L2_COLORSPACE_JPEG,
123 .priv = 1},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300124};
125
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300126static const __u8 mi_data[0x20] = {
127/* 01 02 03 04 05 06 07 08 */
128 0x48, 0x22, 0x01, 0x47, 0x10, 0x00, 0x00, 0x00,
129/* 09 0a 0b 0c 0d 0e 0f 10 */
130 0x00, 0x01, 0x30, 0x01, 0x30, 0x01, 0x30, 0x01,
131/* 11 12 13 14 15 16 17 18 */
132 0x30, 0x00, 0x04, 0x00, 0x06, 0x01, 0xe2, 0x02,
133/* 19 1a 1b 1c 1d 1e 1f 20 */
134 0x82, 0x00, 0x20, 0x17, 0x80, 0x08, 0x0c, 0x00
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300135};
136
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300137/* write <len> bytes from gspca_dev->usb_buf */
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300138static int reg_w(struct gspca_dev *gspca_dev,
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300139 int len)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300140{
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300141 int alen, ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300142
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300143 ret = usb_bulk_msg(gspca_dev->dev,
144 usb_sndbulkpipe(gspca_dev->dev, 4),
145 gspca_dev->usb_buf,
146 len,
147 &alen,
148 500); /* timeout in milliseconds */
149 if (ret < 0)
150 PDEBUG(D_ERR, "reg write [%02x] error %d",
151 gspca_dev->usb_buf[0], ret);
152 return ret;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300153}
154
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300155static void mi_w(struct gspca_dev *gspca_dev,
156 u8 addr,
157 u8 value)
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300158{
159 gspca_dev->usb_buf[0] = 0x1f;
160 gspca_dev->usb_buf[1] = 0; /* control byte */
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300161 gspca_dev->usb_buf[2] = addr;
162 gspca_dev->usb_buf[3] = value;
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300163
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300164 reg_w(gspca_dev, 4);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300165}
166
167/* this function is called at probe time */
168static int sd_config(struct gspca_dev *gspca_dev,
169 const struct usb_device_id *id)
170{
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300171 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300172 struct cam *cam;
173
174 cam = &gspca_dev->cam;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300175 cam->cam_mode = vga_mode;
Julia Lawall80297122008-11-12 23:18:21 -0300176 cam->nmodes = ARRAY_SIZE(vga_mode);
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300177 sd->brightness = BRIGHTNESS_DEF;
178 sd->colors = COLOR_DEF;
179 sd->gamma = GAMMA_DEF;
180 sd->sharpness = SHARPNESS_DEF;
Jean-Francois Moine71cb2762009-03-03 05:33:41 -0300181 sd->quality = 50;
Jean-Francois Moine625deb32009-01-15 06:11:49 -0300182 gspca_dev->nbalt = 9; /* use the altsetting 08 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300183 return 0;
184}
185
Jean-Francois Moine012d6b02008-09-03 17:12:16 -0300186/* this function is called at probe and resume time */
187static int sd_init(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300188{
189 return 0;
190}
191
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -0300192static int sd_start(struct gspca_dev *gspca_dev)
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300193{
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300194 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300195 int err_code;
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300196 u8 *data;
Jean-Francois Moine253bae52009-02-28 08:09:24 -0300197 int i;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300198
Jean-Francois Moine71cb2762009-03-03 05:33:41 -0300199 /* create the JPEG header */
200 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
201 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
202 0x21); /* JPEG 422 */
203 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
204
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300205 data = gspca_dev->usb_buf;
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300206
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300207 data[0] = 0x01; /* address */
208 data[1] = 0x01;
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300209 err_code = reg_w(gspca_dev, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300210 if (err_code < 0)
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -0300211 return err_code;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300212
213 /*
214 Initialize the MR97113 chip register
215 */
216 data[0] = 0x00; /* address */
217 data[1] = 0x0c | 0x01; /* reg 0 */
218 data[2] = 0x01; /* reg 1 */
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300219 data[3] = gspca_dev->width / 8; /* h_size , reg 2 */
220 data[4] = gspca_dev->height / 8; /* v_size , reg 3 */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300221 data[5] = 0x30; /* reg 4, MI, PAS5101 :
222 * 0x30 for 24mhz , 0x28 for 12mhz */
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300223 data[6] = 0x02; /* reg 5, H start - was 0x04 */
224 data[7] = sd->gamma * 0x40; /* reg 0x06: gamma */
225 data[8] = 0x01; /* reg 7, V start - was 0x03 */
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300226/* if (h_size == 320 ) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300227/* data[9]= 0x56; * reg 8, 24MHz, 2:1 scale down */
228/* else */
229 data[9] = 0x52; /* reg 8, 24MHz, no scale down */
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300230/*jfm: from win trace*/
231 data[10] = 0x18;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300232
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300233 err_code = reg_w(gspca_dev, 11);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300234 if (err_code < 0)
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -0300235 return err_code;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300236
237 data[0] = 0x23; /* address */
238 data[1] = 0x09; /* reg 35, append frame header */
239
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300240 err_code = reg_w(gspca_dev, 2);
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300241 if (err_code < 0)
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -0300242 return err_code;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300243
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300244 data[0] = 0x3c; /* address */
245/* if (gspca_dev->width == 1280) */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300246/* data[1] = 200; * reg 60, pc-cam frame size
247 * (unit: 4KB) 800KB */
248/* else */
249 data[1] = 50; /* 50 reg 60, pc-cam frame size
250 * (unit: 4KB) 200KB */
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300251 err_code = reg_w(gspca_dev, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300252 if (err_code < 0)
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -0300253 return err_code;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300254
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300255 /* auto dark-gain */
256 data[0] = 0x5e; /* address */
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300257 data[1] = 0; /* reg 94, Y Gain (auto) */
258/*jfm: from win trace*/
Jean-Francois Moine253bae52009-02-28 08:09:24 -0300259 /* reg 0x5f/0x60 (LE) = saturation */
260 /* h (60): xxxx x100
261 * l (5f): xxxx x000 */
262 data[2] = sd->colors << 3;
263 data[3] = ((sd->colors >> 2) & 0xf8) | 0x04;
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300264 data[4] = sd->brightness; /* reg 0x61 = brightness */
265 data[5] = 0x00;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300266
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300267 err_code = reg_w(gspca_dev, 6);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300268 if (err_code < 0)
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -0300269 return err_code;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300270
271 data[0] = 0x67;
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300272/*jfm: from win trace*/
273 data[1] = sd->sharpness * 4 + 3;
274 data[2] = 0x14;
275 err_code = reg_w(gspca_dev, 3);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300276 if (err_code < 0)
Jean-Francois Moine72ab97c2008-09-20 06:39:08 -0300277 return err_code;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300278
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300279 data[0] = 0x69;
280 data[1] = 0x2f;
281 data[2] = 0x28;
282 data[3] = 0x42;
283 err_code = reg_w(gspca_dev, 4);
284 if (err_code < 0)
285 return err_code;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300286
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300287 data[0] = 0x63;
288 data[1] = 0x07;
289 err_code = reg_w(gspca_dev, 2);
290/*jfm: win trace - many writes here to reg 0x64*/
291 if (err_code < 0)
292 return err_code;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300293
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300294 /* initialize the MI sensor */
295 for (i = 0; i < sizeof mi_data; i++)
296 mi_w(gspca_dev, i + 1, mi_data[i]);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300297
298 data[0] = 0x00;
299 data[1] = 0x4d; /* ISOC transfering enable... */
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300300 reg_w(gspca_dev, 2);
301 return 0;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300302}
303
304static void sd_stopN(struct gspca_dev *gspca_dev)
305{
306 int result;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300307
Jean-Francois Moine739570b2008-07-14 09:38:29 -0300308 gspca_dev->usb_buf[0] = 1;
309 gspca_dev->usb_buf[1] = 0;
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300310 result = reg_w(gspca_dev, 2);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300311 if (result < 0)
312 PDEBUG(D_ERR, "Camera Stop failed");
313}
314
Jean-Francois Moine71cb2762009-03-03 05:33:41 -0300315static void sd_stop0(struct gspca_dev *gspca_dev)
316{
317 struct sd *sd = (struct sd *) gspca_dev;
318
319 kfree(sd->jpeg_hdr);
320}
321
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300322static void sd_pkt_scan(struct gspca_dev *gspca_dev,
323 struct gspca_frame *frame, /* target */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300324 __u8 *data, /* isoc packet */
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300325 int len) /* iso packet length */
326{
Jean-Francois Moine71cb2762009-03-03 05:33:41 -0300327 struct sd *sd = (struct sd *) gspca_dev;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300328 int p;
329
330 if (len < 6) {
331/* gspca_dev->last_packet_type = DISCARD_PACKET; */
332 return;
333 }
334 for (p = 0; p < len - 6; p++) {
335 if (data[0 + p] == 0xff
336 && data[1 + p] == 0xff
337 && data[2 + p] == 0x00
338 && data[3 + p] == 0xff
339 && data[4 + p] == 0x96) {
340 if (data[5 + p] == 0x64
341 || data[5 + p] == 0x65
342 || data[5 + p] == 0x66
343 || data[5 + p] == 0x67) {
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300344 PDEBUG(D_PACK, "sof offset: %d len: %d",
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300345 p, len);
346 frame = gspca_frame_add(gspca_dev, LAST_PACKET,
Jean-Francois Moine0a32ef32009-01-08 16:30:58 -0300347 frame, data, p);
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300348
349 /* put the JPEG header */
Jean-Francois Moine71cb2762009-03-03 05:33:41 -0300350 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
351 sd->jpeg_hdr, JPEG_HDR_SZ);
Jean-Francois Moine0a32ef32009-01-08 16:30:58 -0300352 data += p + 16;
353 len -= p + 16;
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300354 break;
355 }
356 }
357 }
358 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
359}
360
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300361static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
362{
363 struct sd *sd = (struct sd *) gspca_dev;
364
365 sd->brightness = val;
366 if (gspca_dev->streaming) {
367 gspca_dev->usb_buf[0] = 0x61;
368 gspca_dev->usb_buf[1] = val;
369 reg_w(gspca_dev, 2);
370 }
371 return 0;
372}
373
374static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
375{
376 struct sd *sd = (struct sd *) gspca_dev;
377
378 *val = sd->brightness;
379 return 0;
380}
381
382static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
383{
384 struct sd *sd = (struct sd *) gspca_dev;
385
386 sd->colors = val;
387 if (gspca_dev->streaming) {
Jean-Francois Moine253bae52009-02-28 08:09:24 -0300388
389 /* see sd_start */
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300390 gspca_dev->usb_buf[0] = 0x5f;
Jean-Francois Moine253bae52009-02-28 08:09:24 -0300391 gspca_dev->usb_buf[1] = sd->colors << 3;
392 gspca_dev->usb_buf[2] = ((sd->colors >> 2) & 0xf8) | 0x04;
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300393 reg_w(gspca_dev, 3);
394 }
395 return 0;
396}
397
398static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
399{
400 struct sd *sd = (struct sd *) gspca_dev;
401
402 *val = sd->colors;
403 return 0;
404}
405
406static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
407{
408 struct sd *sd = (struct sd *) gspca_dev;
409
410 sd->gamma = val;
411 if (gspca_dev->streaming) {
412 gspca_dev->usb_buf[0] = 0x06;
413 gspca_dev->usb_buf[1] = val * 0x40;
414 reg_w(gspca_dev, 2);
415 }
416 return 0;
417}
418
419static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
420{
421 struct sd *sd = (struct sd *) gspca_dev;
422
423 *val = sd->gamma;
424 return 0;
425}
426
427static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
428{
429 struct sd *sd = (struct sd *) gspca_dev;
430
431 sd->sharpness = val;
432 if (gspca_dev->streaming) {
433 gspca_dev->usb_buf[0] = 0x67;
434 gspca_dev->usb_buf[1] = val * 4 + 3;
435 reg_w(gspca_dev, 2);
436 }
437 return 0;
438}
439
440static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
441{
442 struct sd *sd = (struct sd *) gspca_dev;
443
444 *val = sd->sharpness;
445 return 0;
446}
447
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300448/* sub-driver description */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300449static const struct sd_desc sd_desc = {
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300450 .name = MODULE_NAME,
451 .ctrls = sd_ctrls,
452 .nctrls = ARRAY_SIZE(sd_ctrls),
453 .config = sd_config,
Jean-Francois Moine012d6b02008-09-03 17:12:16 -0300454 .init = sd_init,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300455 .start = sd_start,
456 .stopN = sd_stopN,
Jean-Francois Moine71cb2762009-03-03 05:33:41 -0300457 .stop0 = sd_stop0,
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300458 .pkt_scan = sd_pkt_scan,
459};
460
461/* -- module initialisation -- */
Jean-Francois Moinea5ae2062008-07-04 11:16:16 -0300462static const __devinitdata struct usb_device_id device_table[] = {
Jean-Francois Moine9d64fdb2008-07-25 08:53:03 -0300463 {USB_DEVICE(0x093a, 0x050f)},
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300464 {}
465};
466MODULE_DEVICE_TABLE(usb, device_table);
467
468/* -- device connect -- */
469static int sd_probe(struct usb_interface *intf,
470 const struct usb_device_id *id)
471{
472 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
473 THIS_MODULE);
474}
475
476static struct usb_driver sd_driver = {
477 .name = MODULE_NAME,
478 .id_table = device_table,
479 .probe = sd_probe,
480 .disconnect = gspca_disconnect,
Jean-Francois Moine6a709742008-09-03 16:48:10 -0300481#ifdef CONFIG_PM
482 .suspend = gspca_suspend,
483 .resume = gspca_resume,
484#endif
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300485};
486
487/* -- module insert / remove -- */
488static int __init sd_mod_init(void)
489{
Alexey Klimovf69e9522009-01-01 13:02:07 -0300490 int ret;
Jean-Francois Moinea0306bf2009-01-08 16:29:38 -0300491
Alexey Klimovf69e9522009-01-01 13:02:07 -0300492 ret = usb_register(&sd_driver);
493 if (ret < 0)
Alexey Klimove6b14842009-01-01 13:04:58 -0300494 return ret;
Jean-Francois Moine10b0e962008-07-22 05:35:10 -0300495 PDEBUG(D_PROBE, "registered");
Jean-Francois Moine6a7eba22008-06-30 15:50:11 -0300496 return 0;
497}
498static void __exit sd_mod_exit(void)
499{
500 usb_deregister(&sd_driver);
501 PDEBUG(D_PROBE, "deregistered");
502}
503
504module_init(sd_mod_init);
505module_exit(sd_mod_exit);