Lines Matching refs:gspca_dev

38 	struct gspca_dev gspca_dev;	/* !! must be the first item */
59 static u8 reg_r(struct gspca_dev *gspca_dev, u16 index)
61 struct usb_device *dev = gspca_dev->dev;
64 if (gspca_dev->usb_err < 0)
71 gspca_dev->usb_buf, 1,
74 PDEBUG(D_USBI, "reg_r 0x%x=0x%02x", index, gspca_dev->usb_buf[0]);
77 gspca_dev->usb_err = ret;
81 return gspca_dev->usb_buf[0];
85 static void reg_w(struct gspca_dev *gspca_dev, u16 index, u8 val)
88 struct usb_device *dev = gspca_dev->dev;
90 if (gspca_dev->usb_err < 0)
103 gspca_dev->usb_err = ret;
107 static void reg_w_mask(struct gspca_dev *gspca_dev, u16 index, u8 val, u8 mask)
109 val = (reg_r(gspca_dev, index) & ~mask) | (val & mask);
110 reg_w(gspca_dev, index, val);
114 static int sd_config(struct gspca_dev *gspca_dev,
117 gspca_dev->cam.cam_mode = stk1135_modes;
118 gspca_dev->cam.nmodes = ARRAY_SIZE(stk1135_modes);
122 static int stk1135_serial_wait_ready(struct gspca_dev *gspca_dev)
128 val = reg_r(gspca_dev, STK1135_REG_SICTL + 1);
139 static u8 sensor_read_8(struct gspca_dev *gspca_dev, u8 addr)
141 reg_w(gspca_dev, STK1135_REG_SBUSR, addr);
143 reg_w(gspca_dev, STK1135_REG_SICTL, 0x20);
145 if (stk1135_serial_wait_ready(gspca_dev)) {
150 return reg_r(gspca_dev, STK1135_REG_SBUSR + 1);
153 static u16 sensor_read_16(struct gspca_dev *gspca_dev, u8 addr)
155 return (sensor_read_8(gspca_dev, addr) << 8) |
156 sensor_read_8(gspca_dev, 0xf1);
159 static void sensor_write_8(struct gspca_dev *gspca_dev, u8 addr, u8 data)
162 reg_w(gspca_dev, STK1135_REG_SBUSW, addr);
163 reg_w(gspca_dev, STK1135_REG_SBUSW + 1, data);
165 reg_w(gspca_dev, STK1135_REG_SICTL, 0x01);
167 if (stk1135_serial_wait_ready(gspca_dev)) {
173 static void sensor_write_16(struct gspca_dev *gspca_dev, u8 addr, u16 data)
175 sensor_write_8(gspca_dev, addr, data >> 8);
176 sensor_write_8(gspca_dev, 0xf1, data & 0xff);
179 static void sensor_set_page(struct gspca_dev *gspca_dev, u8 page)
181 struct sd *sd = (struct sd *) gspca_dev;
184 sensor_write_16(gspca_dev, 0xf0, page);
189 static u16 sensor_read(struct gspca_dev *gspca_dev, u16 reg)
191 sensor_set_page(gspca_dev, reg >> 8);
192 return sensor_read_16(gspca_dev, reg & 0xff);
195 static void sensor_write(struct gspca_dev *gspca_dev, u16 reg, u16 val)
197 sensor_set_page(gspca_dev, reg >> 8);
198 sensor_write_16(gspca_dev, reg & 0xff, val);
201 static void sensor_write_mask(struct gspca_dev *gspca_dev,
204 val = (sensor_read(gspca_dev, reg) & ~mask) | (val & mask);
205 sensor_write(gspca_dev, reg, val);
214 static void stk1135_configure_mt9m112(struct gspca_dev *gspca_dev)
316 sensor_write(gspca_dev, cfg[i].reg, cfg[i].val);
319 width = gspca_dev->pixfmt.width;
320 height = gspca_dev->pixfmt.height;
322 sensor_write(gspca_dev, 0x1a7, width);
323 sensor_write(gspca_dev, 0x1aa, height);
325 sensor_write(gspca_dev, 0x0c8, 0x0000);
327 sensor_write(gspca_dev, 0x2c8, 0x0000);
329 sensor_write(gspca_dev, 0x1a1, width);
330 sensor_write(gspca_dev, 0x1a4, height);
332 sensor_write(gspca_dev, 0x0c8, 0x0008);
334 sensor_write(gspca_dev, 0x2c8, 0x040b);
338 static void stk1135_configure_clock(struct gspca_dev *gspca_dev)
341 reg_w(gspca_dev, STK1135_REG_TMGEN, 0x12);
344 reg_w(gspca_dev, STK1135_REG_TCP1 + 0, 0x41);
345 reg_w(gspca_dev, STK1135_REG_TCP1 + 1, 0x00);
346 reg_w(gspca_dev, STK1135_REG_TCP1 + 2, 0x00);
347 reg_w(gspca_dev, STK1135_REG_TCP1 + 3, 0x00);
350 reg_w(gspca_dev, STK1135_REG_SENSO + 0, 0x10);
352 reg_w(gspca_dev, STK1135_REG_SENSO + 1, 0x00);
354 reg_w(gspca_dev, STK1135_REG_SENSO + 3, 0x07);
356 reg_w(gspca_dev, STK1135_REG_PLLFD, 0x06);
358 reg_w(gspca_dev, STK1135_REG_TMGEN, 0x80);
360 reg_w(gspca_dev, STK1135_REG_SENSO + 2, 0x04);
363 reg_w(gspca_dev, STK1135_REG_SICTL + 2, 0x1f);
369 static void stk1135_camera_disable(struct gspca_dev *gspca_dev)
372 reg_w(gspca_dev, STK1135_REG_CIEPO + 2, 0x00);
373 reg_w(gspca_dev, STK1135_REG_CIEPO + 3, 0x00);
375 reg_w_mask(gspca_dev, STK1135_REG_SCTRL, 0x00, 0x80);
378 sensor_write_mask(gspca_dev, 0x00d, 0x0004, 0x000c);
381 reg_w_mask(gspca_dev, STK1135_REG_SENSO + 2, 0x00, 0x01);
383 reg_w(gspca_dev, STK1135_REG_TMGEN, 0x00);
385 reg_w(gspca_dev, STK1135_REG_SENSO + 1, 0x20);
387 reg_w(gspca_dev, STK1135_REG_SENSO, 0x00);
390 reg_w(gspca_dev, STK1135_REG_GCTRL, 0x49);
394 static int sd_init(struct gspca_dev *gspca_dev)
398 struct sd *sd = (struct sd *) gspca_dev;
401 reg_w(gspca_dev, STK1135_REG_GCTRL + 2, 0x78);
403 reg_w(gspca_dev, STK1135_REG_GCTRL, (1 << 5));
405 reg_w(gspca_dev, STK1135_REG_GCTRL + 3, 0x80);
407 reg_w(gspca_dev, STK1135_REG_ICTRL + 1, 0x00);
408 reg_w(gspca_dev, STK1135_REG_ICTRL + 3, 0x03);
410 reg_w(gspca_dev, STK1135_REG_RMCTL + 1, 0x00);
411 reg_w(gspca_dev, STK1135_REG_RMCTL + 3, 0x02);
414 reg_w(gspca_dev, STK1135_REG_SICTL, 0x80);
415 reg_w(gspca_dev, STK1135_REG_SICTL, 0x00);
417 reg_w(gspca_dev, STK1135_REG_SICTL + 3, 0xba);
419 reg_w(gspca_dev, STK1135_REG_ASIC + 3, 0x00);
421 stk1135_configure_clock(gspca_dev);
425 sensor_id = sensor_read(gspca_dev, 0x000);
436 stk1135_camera_disable(gspca_dev);
438 return gspca_dev->usb_err;
442 static int sd_start(struct gspca_dev *gspca_dev)
444 struct sd *sd = (struct sd *) gspca_dev;
448 reg_w(gspca_dev, STK1135_REG_GCTRL, (1 << 5));
450 stk1135_configure_clock(gspca_dev);
453 reg_w(gspca_dev, STK1135_REG_CISPO + 0, 0x00);
454 reg_w(gspca_dev, STK1135_REG_CISPO + 1, 0x00);
455 reg_w(gspca_dev, STK1135_REG_CISPO + 2, 0x00);
456 reg_w(gspca_dev, STK1135_REG_CISPO + 3, 0x00);
459 width = gspca_dev->pixfmt.width;
460 height = gspca_dev->pixfmt.height;
461 reg_w(gspca_dev, STK1135_REG_CIEPO + 0, width & 0xff);
462 reg_w(gspca_dev, STK1135_REG_CIEPO + 1, width >> 8);
463 reg_w(gspca_dev, STK1135_REG_CIEPO + 2, height & 0xff);
464 reg_w(gspca_dev, STK1135_REG_CIEPO + 3, height >> 8);
467 reg_w(gspca_dev, STK1135_REG_SCTRL, 0x20);
469 stk1135_configure_mt9m112(gspca_dev);
472 reg_w_mask(gspca_dev, STK1135_REG_SCTRL, 0x80, 0x80);
474 if (gspca_dev->usb_err >= 0)
476 gspca_dev->alt);
480 return gspca_dev->usb_err;
483 static void sd_stopN(struct gspca_dev *gspca_dev)
485 struct usb_device *dev = gspca_dev->dev;
487 usb_set_interface(dev, gspca_dev->iface, 0);
489 stk1135_camera_disable(gspca_dev);
494 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
498 struct sd *sd = (struct sd *) gspca_dev;
525 gspca_dev->last_packet_type = DISCARD_PACKET;
538 gspca_frame_add(gspca_dev, LAST_PACKET, data, 0);
541 gspca_frame_add(gspca_dev, pkt_type, data + skip, len - skip);
544 static void sethflip(struct gspca_dev *gspca_dev, s32 val)
546 struct sd *sd = (struct sd *) gspca_dev;
550 sensor_write_mask(gspca_dev, 0x020, val ? 0x0002 : 0x0000 , 0x0002);
553 static void setvflip(struct gspca_dev *gspca_dev, s32 val)
555 struct sd *sd = (struct sd *) gspca_dev;
559 sensor_write_mask(gspca_dev, 0x020, val ? 0x0001 : 0x0000 , 0x0001);
562 static void stk1135_dq_callback(struct gspca_dev *gspca_dev)
564 struct sd *sd = (struct sd *) gspca_dev;
568 sethflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip));
569 setvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->vflip));
575 struct gspca_dev *gspca_dev =
576 container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
578 gspca_dev->usb_err = 0;
580 if (!gspca_dev->streaming)
585 sethflip(gspca_dev, ctrl->val);
588 setvflip(gspca_dev, ctrl->val);
592 return gspca_dev->usb_err;
599 static int sd_init_controls(struct gspca_dev *gspca_dev)
601 struct sd *sd = (struct sd *) gspca_dev;
602 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
604 gspca_dev->vdev.ctrl_handler = hdl;
618 static void stk1135_try_fmt(struct gspca_dev *gspca_dev, struct v4l2_format *fmt)
630 static int stk1135_enum_framesizes(struct gspca_dev *gspca_dev,