21 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23 #define MODULE_NAME "stk014"
28 MODULE_AUTHOR(
"Jean-Francois Moine <http://moinejf.free.fr>");
43 .sizeimage = 320 * 240 * 3 / 8 + 590,
48 .sizeimage = 640 * 480 * 3 / 8 + 590,
57 struct usb_device *
dev = gspca_dev->
dev;
70 pr_err(
"reg_r err %d\n", ret);
78 static void reg_w(
struct gspca_dev *gspca_dev,
81 struct usb_device *dev = gspca_dev->
dev;
95 pr_err(
"reg_w err %d\n", ret);
101 static void rcv_val(
struct gspca_dev *gspca_dev,
104 struct usb_device *dev = gspca_dev->
dev;
107 reg_w(gspca_dev, 0x634, (ads >> 16) & 0xff);
108 reg_w(gspca_dev, 0x635, (ads >> 8) & 0xff);
109 reg_w(gspca_dev, 0x636, ads & 0xff);
110 reg_w(gspca_dev, 0x637, 0);
111 reg_w(gspca_dev, 0x638, 4);
112 reg_w(gspca_dev, 0x639, 0);
113 reg_w(gspca_dev, 0x63a, 0);
114 reg_w(gspca_dev, 0x63b, 0);
115 reg_w(gspca_dev, 0x630, 5);
119 usb_rcvbulkpipe(dev, 0x05),
125 pr_err(
"rcv_val err %d\n", ret);
131 static void snd_val(
struct gspca_dev *gspca_dev,
135 struct usb_device *dev = gspca_dev->
dev;
139 if (ads == 0x003f08) {
140 reg_r(gspca_dev, 0x0704);
141 seq = reg_r(gspca_dev, 0x0705);
142 reg_r(gspca_dev, 0x0650);
143 reg_w(gspca_dev, 0x654, seq);
145 reg_w(gspca_dev, 0x654, (ads >> 16) & 0xff);
147 reg_w(gspca_dev, 0x655, (ads >> 8) & 0xff);
148 reg_w(gspca_dev, 0x656, ads & 0xff);
149 reg_w(gspca_dev, 0x657, 0);
150 reg_w(gspca_dev, 0x658, 0x04);
151 reg_w(gspca_dev, 0x659, 0);
152 reg_w(gspca_dev, 0x65a, 0);
153 reg_w(gspca_dev, 0x65b, 0);
154 reg_w(gspca_dev, 0x650, 5);
157 gspca_dev->
usb_buf[0] = val >> 24;
158 gspca_dev->
usb_buf[1] = val >> 16;
159 gspca_dev->
usb_buf[2] = val >> 8;
162 usb_sndbulkpipe(dev, 6),
168 pr_err(
"snd_val err %d\n", ret);
171 if (ads == 0x003f08) {
174 reg_w(gspca_dev, 0x705, seq);
180 static void set_par(
struct gspca_dev *gspca_dev,
183 snd_val(gspca_dev, 0x003f08, parval);
186 static void setbrightness(
struct gspca_dev *gspca_dev,
s32 val)
192 set_par(gspca_dev, parval);
195 static void setcontrast(
struct gspca_dev *gspca_dev,
s32 val)
201 set_par(gspca_dev, parval);
204 static void setcolors(
struct gspca_dev *gspca_dev,
s32 val)
210 set_par(gspca_dev, parval);
213 static void setlightfreq(
struct gspca_dev *gspca_dev,
s32 val)
215 set_par(gspca_dev, val == 1
221 static int sd_config(
struct gspca_dev *gspca_dev,
224 gspca_dev->
cam.cam_mode = vga_mode;
230 static int sd_init(
struct gspca_dev *gspca_dev)
236 ret = reg_r(gspca_dev, 0x0740);
239 pr_err(
"init reg: 0x%02x\n", ret);
247 static int sd_start(
struct gspca_dev *gspca_dev)
249 struct sd *
sd = (
struct sd *) gspca_dev;
260 set_par(gspca_dev, 0x10000000);
261 set_par(gspca_dev, 0x00000000);
262 set_par(gspca_dev, 0x8002e001);
263 set_par(gspca_dev, 0x14000000);
264 if (gspca_dev->
width > 320)
268 set_par(gspca_dev, value);
273 pr_err(
"set intf %d %d failed\n",
278 reg_r(gspca_dev, 0x0630);
279 rcv_val(gspca_dev, 0x000020);
280 reg_r(gspca_dev, 0x0650);
281 snd_val(gspca_dev, 0x000020, 0xffffffff);
282 reg_w(gspca_dev, 0x0620, 0);
283 reg_w(gspca_dev, 0x0630, 0);
284 reg_w(gspca_dev, 0x0640, 0);
285 reg_w(gspca_dev, 0x0650, 0);
286 reg_w(gspca_dev, 0x0660, 0);
287 set_par(gspca_dev, 0x09800000);
288 set_par(gspca_dev, 0x0a800000);
289 set_par(gspca_dev, 0x0b800000);
290 set_par(gspca_dev, 0x0d030000);
293 set_par(gspca_dev, 0x01000000);
294 set_par(gspca_dev, 0x01000000);
296 PDEBUG(D_STREAM,
"camera started alt: 0x%02x",
302 static void sd_stopN(
struct gspca_dev *gspca_dev)
304 struct usb_device *dev = gspca_dev->
dev;
306 set_par(gspca_dev, 0x02000000);
307 set_par(gspca_dev, 0x02000000);
309 reg_r(gspca_dev, 0x0630);
310 rcv_val(gspca_dev, 0x000020);
311 reg_r(gspca_dev, 0x0650);
312 snd_val(gspca_dev, 0x000020, 0xffffffff);
313 reg_w(gspca_dev, 0x0620, 0);
314 reg_w(gspca_dev, 0x0630, 0);
315 reg_w(gspca_dev, 0x0640, 0);
316 reg_w(gspca_dev, 0x0650, 0);
317 reg_w(gspca_dev, 0x0660, 0);
318 PDEBUG(D_STREAM,
"camera stopped");
321 static void sd_pkt_scan(
struct gspca_dev *gspca_dev,
325 struct sd *sd = (
struct sd *) gspca_dev;
326 static unsigned char ffd9[] = {0xff, 0xd9};
337 if (data[0] == 0xff && data[1] == 0xfe) {
355 struct gspca_dev *gspca_dev =
365 setbrightness(gspca_dev, ctrl->
val);
368 setcontrast(gspca_dev, ctrl->
val);
371 setcolors(gspca_dev, ctrl->
val);
374 setlightfreq(gspca_dev, ctrl->
val);
384 static int sd_init_controls(
struct gspca_dev *gspca_dev)
388 gspca_dev->
vdev.ctrl_handler = hdl;
402 pr_err(
"Could not initialize controls\n");
413 .init_controls = sd_init_controls,
416 .pkt_scan = sd_pkt_scan,
421 {USB_DEVICE(0x05e1, 0x0893)},
434 static struct usb_driver sd_driver = {
436 .id_table = device_table,
440 .suspend = gspca_suspend,
441 .resume = gspca_resume,
442 .reset_resume = gspca_resume,