Lines Matching refs:gspca_dev

25 	struct gspca_dev gspca_dev;	/* !! must be the first item */
46 static u8 reg_r(struct gspca_dev *gspca_dev, u16 index)
48 struct usb_device *dev = gspca_dev->dev;
51 if (gspca_dev->usb_err < 0)
58 gspca_dev->usb_buf, 1,
61 gspca_dbg(gspca_dev, D_USBI, "reg_r 0x%x=0x%02x\n",
62 index, gspca_dev->usb_buf[0]);
65 gspca_dev->usb_err = ret;
69 return gspca_dev->usb_buf[0];
73 static void reg_w(struct gspca_dev *gspca_dev, u16 index, u8 val)
76 struct usb_device *dev = gspca_dev->dev;
78 if (gspca_dev->usb_err < 0)
88 gspca_dbg(gspca_dev, D_USBO, "reg_w 0x%x:=0x%02x\n", index, val);
91 gspca_dev->usb_err = ret;
95 static void reg_w_mask(struct gspca_dev *gspca_dev, u16 index, u8 val, u8 mask)
97 val = (reg_r(gspca_dev, index) & ~mask) | (val & mask);
98 reg_w(gspca_dev, index, val);
102 static int sd_config(struct gspca_dev *gspca_dev,
105 gspca_dev->cam.cam_mode = stk1135_modes;
106 gspca_dev->cam.nmodes = ARRAY_SIZE(stk1135_modes);
110 static int stk1135_serial_wait_ready(struct gspca_dev *gspca_dev)
116 val = reg_r(gspca_dev, STK1135_REG_SICTL + 1);
127 static u8 sensor_read_8(struct gspca_dev *gspca_dev, u8 addr)
129 reg_w(gspca_dev, STK1135_REG_SBUSR, addr);
131 reg_w(gspca_dev, STK1135_REG_SICTL, 0x20);
133 if (stk1135_serial_wait_ready(gspca_dev)) {
138 return reg_r(gspca_dev, STK1135_REG_SBUSR + 1);
141 static u16 sensor_read_16(struct gspca_dev *gspca_dev, u8 addr)
143 return (sensor_read_8(gspca_dev, addr) << 8) |
144 sensor_read_8(gspca_dev, 0xf1);
147 static void sensor_write_8(struct gspca_dev *gspca_dev, u8 addr, u8 data)
150 reg_w(gspca_dev, STK1135_REG_SBUSW, addr);
151 reg_w(gspca_dev, STK1135_REG_SBUSW + 1, data);
153 reg_w(gspca_dev, STK1135_REG_SICTL, 0x01);
155 if (stk1135_serial_wait_ready(gspca_dev)) {
161 static void sensor_write_16(struct gspca_dev *gspca_dev, u8 addr, u16 data)
163 sensor_write_8(gspca_dev, addr, data >> 8);
164 sensor_write_8(gspca_dev, 0xf1, data & 0xff);
167 static void sensor_set_page(struct gspca_dev *gspca_dev, u8 page)
169 struct sd *sd = (struct sd *) gspca_dev;
172 sensor_write_16(gspca_dev, 0xf0, page);
177 static u16 sensor_read(struct gspca_dev *gspca_dev, u16 reg)
179 sensor_set_page(gspca_dev, reg >> 8);
180 return sensor_read_16(gspca_dev, reg & 0xff);
183 static void sensor_write(struct gspca_dev *gspca_dev, u16 reg, u16 val)
185 sensor_set_page(gspca_dev, reg >> 8);
186 sensor_write_16(gspca_dev, reg & 0xff, val);
189 static void sensor_write_mask(struct gspca_dev *gspca_dev,
192 val = (sensor_read(gspca_dev, reg) & ~mask) | (val & mask);
193 sensor_write(gspca_dev, reg, val);
202 static void stk1135_configure_mt9m112(struct gspca_dev *gspca_dev)
304 sensor_write(gspca_dev, cfg[i].reg, cfg[i].val);
307 width = gspca_dev->pixfmt.width;
308 height = gspca_dev->pixfmt.height;
310 sensor_write(gspca_dev, 0x1a7, width);
311 sensor_write(gspca_dev, 0x1aa, height);
313 sensor_write(gspca_dev, 0x0c8, 0x0000);
315 sensor_write(gspca_dev, 0x2c8, 0x0000);
317 sensor_write(gspca_dev, 0x1a1, width);
318 sensor_write(gspca_dev, 0x1a4, height);
320 sensor_write(gspca_dev, 0x0c8, 0x0008);
322 sensor_write(gspca_dev, 0x2c8, 0x040b);
326 static void stk1135_configure_clock(struct gspca_dev *gspca_dev)
329 reg_w(gspca_dev, STK1135_REG_TMGEN, 0x12);
332 reg_w(gspca_dev, STK1135_REG_TCP1 + 0, 0x41);
333 reg_w(gspca_dev, STK1135_REG_TCP1 + 1, 0x00);
334 reg_w(gspca_dev, STK1135_REG_TCP1 + 2, 0x00);
335 reg_w(gspca_dev, STK1135_REG_TCP1 + 3, 0x00);
338 reg_w(gspca_dev, STK1135_REG_SENSO + 0, 0x10);
340 reg_w(gspca_dev, STK1135_REG_SENSO + 1, 0x00);
342 reg_w(gspca_dev, STK1135_REG_SENSO + 3, 0x07);
344 reg_w(gspca_dev, STK1135_REG_PLLFD, 0x06);
346 reg_w(gspca_dev, STK1135_REG_TMGEN, 0x80);
348 reg_w(gspca_dev, STK1135_REG_SENSO + 2, 0x04);
351 reg_w(gspca_dev, STK1135_REG_SICTL + 2, 0x1f);
357 static void stk1135_camera_disable(struct gspca_dev *gspca_dev)
360 reg_w(gspca_dev, STK1135_REG_CIEPO + 2, 0x00);
361 reg_w(gspca_dev, STK1135_REG_CIEPO + 3, 0x00);
363 reg_w_mask(gspca_dev, STK1135_REG_SCTRL, 0x00, 0x80);
366 sensor_write_mask(gspca_dev, 0x00d, 0x0004, 0x000c);
369 reg_w_mask(gspca_dev, STK1135_REG_SENSO + 2, 0x00, 0x01);
371 reg_w(gspca_dev, STK1135_REG_TMGEN, 0x00);
373 reg_w(gspca_dev, STK1135_REG_SENSO + 1, 0x20);
375 reg_w(gspca_dev, STK1135_REG_SENSO, 0x00);
378 reg_w(gspca_dev, STK1135_REG_GCTRL, 0x49);
382 static int sd_init(struct gspca_dev *gspca_dev)
386 struct sd *sd = (struct sd *) gspca_dev;
389 reg_w(gspca_dev, STK1135_REG_GCTRL + 2, 0x78);
391 reg_w(gspca_dev, STK1135_REG_GCTRL, (1 << 5));
393 reg_w(gspca_dev, STK1135_REG_GCTRL + 3, 0x80);
395 reg_w(gspca_dev, STK1135_REG_ICTRL + 1, 0x00);
396 reg_w(gspca_dev, STK1135_REG_ICTRL + 3, 0x03);
398 reg_w(gspca_dev, STK1135_REG_RMCTL + 1, 0x00);
399 reg_w(gspca_dev, STK1135_REG_RMCTL + 3, 0x02);
402 reg_w(gspca_dev, STK1135_REG_SICTL, 0x80);
403 reg_w(gspca_dev, STK1135_REG_SICTL, 0x00);
405 reg_w(gspca_dev, STK1135_REG_SICTL + 3, 0xba);
407 reg_w(gspca_dev, STK1135_REG_ASIC + 3, 0x00);
409 stk1135_configure_clock(gspca_dev);
413 sensor_id = sensor_read(gspca_dev, 0x000);
424 stk1135_camera_disable(gspca_dev);
426 return gspca_dev->usb_err;
430 static int sd_start(struct gspca_dev *gspca_dev)
432 struct sd *sd = (struct sd *) gspca_dev;
436 reg_w(gspca_dev, STK1135_REG_GCTRL, (1 << 5));
438 stk1135_configure_clock(gspca_dev);
441 reg_w(gspca_dev, STK1135_REG_CISPO + 0, 0x00);
442 reg_w(gspca_dev, STK1135_REG_CISPO + 1, 0x00);
443 reg_w(gspca_dev, STK1135_REG_CISPO + 2, 0x00);
444 reg_w(gspca_dev, STK1135_REG_CISPO + 3, 0x00);
447 width = gspca_dev->pixfmt.width;
448 height = gspca_dev->pixfmt.height;
449 reg_w(gspca_dev, STK1135_REG_CIEPO + 0, width & 0xff);
450 reg_w(gspca_dev, STK1135_REG_CIEPO + 1, width >> 8);
451 reg_w(gspca_dev, STK1135_REG_CIEPO + 2, height & 0xff);
452 reg_w(gspca_dev, STK1135_REG_CIEPO + 3, height >> 8);
455 reg_w(gspca_dev, STK1135_REG_SCTRL, 0x20);
457 stk1135_configure_mt9m112(gspca_dev);
460 reg_w_mask(gspca_dev, STK1135_REG_SCTRL, 0x80, 0x80);
462 if (gspca_dev->usb_err >= 0)
463 gspca_dbg(gspca_dev, D_STREAM, "camera started alt: 0x%02x\n",
464 gspca_dev->alt);
468 return gspca_dev->usb_err;
471 static void sd_stopN(struct gspca_dev *gspca_dev)
473 struct usb_device *dev = gspca_dev->dev;
475 usb_set_interface(dev, gspca_dev->iface, 0);
477 stk1135_camera_disable(gspca_dev);
479 gspca_dbg(gspca_dev, D_STREAM, "camera stopped\n");
482 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
486 struct sd *sd = (struct sd *) gspca_dev;
494 gspca_dbg(gspca_dev, D_PACK, "received short packet (less than 4 bytes)\n");
510 gspca_dbg(gspca_dev, D_PACK, "received out-of-sequence packet\n");
513 gspca_dev->last_packet_type = DISCARD_PACKET;
526 gspca_frame_add(gspca_dev, LAST_PACKET, data, 0);
529 gspca_frame_add(gspca_dev, pkt_type, data + skip, len - skip);
532 static void sethflip(struct gspca_dev *gspca_dev, s32 val)
534 struct sd *sd = (struct sd *) gspca_dev;
538 sensor_write_mask(gspca_dev, 0x020, val ? 0x0002 : 0x0000 , 0x0002);
541 static void setvflip(struct gspca_dev *gspca_dev, s32 val)
543 struct sd *sd = (struct sd *) gspca_dev;
547 sensor_write_mask(gspca_dev, 0x020, val ? 0x0001 : 0x0000 , 0x0001);
550 static void stk1135_dq_callback(struct gspca_dev *gspca_dev)
552 struct sd *sd = (struct sd *) gspca_dev;
556 sethflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->hflip));
557 setvflip(gspca_dev, v4l2_ctrl_g_ctrl(sd->vflip));
563 struct gspca_dev *gspca_dev =
564 container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
566 gspca_dev->usb_err = 0;
568 if (!gspca_dev->streaming)
573 sethflip(gspca_dev, ctrl->val);
576 setvflip(gspca_dev, ctrl->val);
580 return gspca_dev->usb_err;
587 static int sd_init_controls(struct gspca_dev *gspca_dev)
589 struct sd *sd = (struct sd *) gspca_dev;
590 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler;
592 gspca_dev->vdev.ctrl_handler = hdl;
606 static void stk1135_try_fmt(struct gspca_dev *gspca_dev, struct v4l2_format *fmt)
618 static int stk1135_enum_framesizes(struct gspca_dev *gspca_dev,