Lines Matching refs:gspca_dev

73 	struct gspca_dev gspca_dev;  /* !! must be the first item */  member
92 static void sd_stopN(struct gspca_dev *gspca_dev);
123 static int mr_write(struct gspca_dev *gspca_dev, int len) in mr_write() argument
127 rc = usb_bulk_msg(gspca_dev->dev, in mr_write()
128 usb_sndbulkpipe(gspca_dev->dev, 4), in mr_write()
129 gspca_dev->usb_buf, len, NULL, 500); in mr_write()
132 gspca_dev->usb_buf[0], rc); in mr_write()
137 static int mr_read(struct gspca_dev *gspca_dev, int len) in mr_read() argument
141 rc = usb_bulk_msg(gspca_dev->dev, in mr_read()
142 usb_rcvbulkpipe(gspca_dev->dev, 3), in mr_read()
143 gspca_dev->usb_buf, len, NULL, 500); in mr_read()
146 gspca_dev->usb_buf[0], rc); in mr_read()
150 static int sensor_write_reg(struct gspca_dev *gspca_dev, u8 reg, u8 flags, in sensor_write_reg() argument
153 gspca_dev->usb_buf[0] = 0x1f; in sensor_write_reg()
154 gspca_dev->usb_buf[1] = flags; in sensor_write_reg()
155 gspca_dev->usb_buf[2] = reg; in sensor_write_reg()
156 memcpy(gspca_dev->usb_buf + 3, data, len); in sensor_write_reg()
158 return mr_write(gspca_dev, len + 3); in sensor_write_reg()
161 static int sensor_write_regs(struct gspca_dev *gspca_dev, in sensor_write_regs() argument
167 rc = sensor_write_reg(gspca_dev, data[i].reg, data[i].flags, in sensor_write_regs()
176 static int sensor_write1(struct gspca_dev *gspca_dev, u8 reg, u8 data) in sensor_write1() argument
178 struct sd *sd = (struct sd *) gspca_dev; in sensor_write1()
184 rc = sensor_write_reg(gspca_dev, reg, 0x01, &buf, 1); in sensor_write1()
187 rc = sensor_write_reg(gspca_dev, reg, 0x00, &buf, 1); in sensor_write1()
194 rc = sensor_write_reg(gspca_dev, confirm_reg, 0x00, &buf, 1); in sensor_write1()
201 static int cam_get_response16(struct gspca_dev *gspca_dev, u8 reg, int verbose) in cam_get_response16() argument
205 gspca_dev->usb_buf[0] = reg; in cam_get_response16()
206 err_code = mr_write(gspca_dev, 1); in cam_get_response16()
210 err_code = mr_read(gspca_dev, 16); in cam_get_response16()
215 gspca_dbg(gspca_dev, D_PROBE, "Register: %02x reads %02x%02x%02x\n", in cam_get_response16()
217 gspca_dev->usb_buf[0], in cam_get_response16()
218 gspca_dev->usb_buf[1], in cam_get_response16()
219 gspca_dev->usb_buf[2]); in cam_get_response16()
224 static int zero_the_pointer(struct gspca_dev *gspca_dev) in zero_the_pointer() argument
226 __u8 *data = gspca_dev->usb_buf; in zero_the_pointer()
231 err_code = cam_get_response16(gspca_dev, 0x21, 0); in zero_the_pointer()
237 err_code = mr_write(gspca_dev, 2); in zero_the_pointer()
241 err_code = cam_get_response16(gspca_dev, 0x21, 0); in zero_the_pointer()
247 err_code = mr_write(gspca_dev, 2); in zero_the_pointer()
251 err_code = cam_get_response16(gspca_dev, 0x21, 0); in zero_the_pointer()
257 err_code = mr_write(gspca_dev, 2); in zero_the_pointer()
261 err_code = cam_get_response16(gspca_dev, 0x21, 0); in zero_the_pointer()
267 err_code = mr_write(gspca_dev, 2); in zero_the_pointer()
272 err_code = cam_get_response16(gspca_dev, 0x21, 0); in zero_the_pointer()
279 gspca_err(gspca_dev, "status is %02x\n", status); in zero_the_pointer()
285 err_code = mr_write(gspca_dev, 2); in zero_the_pointer()
289 err_code = cam_get_response16(gspca_dev, 0x21, 0); in zero_the_pointer()
296 err_code = mr_write(gspca_dev, 1); in zero_the_pointer()
300 err_code = mr_read(gspca_dev, 16); in zero_the_pointer()
307 static int stream_start(struct gspca_dev *gspca_dev) in stream_start() argument
309 gspca_dev->usb_buf[0] = 0x01; in stream_start()
310 gspca_dev->usb_buf[1] = 0x01; in stream_start()
311 return mr_write(gspca_dev, 2); in stream_start()
314 static void stream_stop(struct gspca_dev *gspca_dev) in stream_stop() argument
316 gspca_dev->usb_buf[0] = 0x01; in stream_stop()
317 gspca_dev->usb_buf[1] = 0x00; in stream_stop()
318 if (mr_write(gspca_dev, 2) < 0) in stream_stop()
319 gspca_err(gspca_dev, "Stream Stop failed\n"); in stream_stop()
322 static void lcd_stop(struct gspca_dev *gspca_dev) in lcd_stop() argument
324 gspca_dev->usb_buf[0] = 0x19; in lcd_stop()
325 gspca_dev->usb_buf[1] = 0x54; in lcd_stop()
326 if (mr_write(gspca_dev, 2) < 0) in lcd_stop()
327 gspca_err(gspca_dev, "LCD Stop failed\n"); in lcd_stop()
330 static int isoc_enable(struct gspca_dev *gspca_dev) in isoc_enable() argument
332 gspca_dev->usb_buf[0] = 0x00; in isoc_enable()
333 gspca_dev->usb_buf[1] = 0x4d; /* ISOC transferring enable... */ in isoc_enable()
334 return mr_write(gspca_dev, 2); in isoc_enable()
338 static int sd_config(struct gspca_dev *gspca_dev, in sd_config() argument
341 struct sd *sd = (struct sd *) gspca_dev; in sd_config()
345 cam = &gspca_dev->cam; in sd_config()
358 err_code = zero_the_pointer(gspca_dev); in sd_config()
362 err_code = stream_start(gspca_dev); in sd_config()
367 err_code = cam_get_response16(gspca_dev, 0x07, 1); in sd_config()
395 switch (gspca_dev->usb_buf[0]) { in sd_config()
404 gspca_dev->usb_buf[1]); in sd_config()
407 gspca_dbg(gspca_dev, D_PROBE, "MR97310A CIF camera detected, sensor: %d\n", in sd_config()
434 if (gspca_dev->usb_buf[0] == 0x01) { in sd_config()
436 } else if ((gspca_dev->usb_buf[0] != 0x03) && in sd_config()
437 (gspca_dev->usb_buf[0] != 0x04)) { in sd_config()
439 gspca_dev->usb_buf[0]); in sd_config()
444 if ((gspca_dev->usb_buf[0] == 0x03) && in sd_config()
445 (gspca_dev->usb_buf[1] == 0x50)) in sd_config()
447 if (gspca_dev->usb_buf[0] == 0x04) { in sd_config()
449 switch (gspca_dev->usb_buf[1]) { in sd_config()
452 gspca_dbg(gspca_dev, D_PROBE, "sensor_type corrected to 0\n"); in sd_config()
459 gspca_dev->usb_buf[1]); in sd_config()
464 gspca_dbg(gspca_dev, D_PROBE, "MR97310A VGA camera detected, sensor: %d\n", in sd_config()
468 sd_stopN(gspca_dev); in sd_config()
472 gspca_dbg(gspca_dev, D_PROBE, "Forcing sensor type to: %d\n", in sd_config()
480 static int sd_init(struct gspca_dev *gspca_dev) in sd_init() argument
485 static int start_cif_cam(struct gspca_dev *gspca_dev) in start_cif_cam() argument
487 struct sd *sd = (struct sd *) gspca_dev; in start_cif_cam()
488 __u8 *data = gspca_dev->usb_buf; in start_cif_cam()
510 switch (gspca_dev->pixfmt.width) { in start_cif_cam()
531 err_code = mr_write(gspca_dev, 11); in start_cif_cam()
554 err_code = sensor_write_regs(gspca_dev, cif_sensor0_init_data, in start_cif_cam()
576 gspca_dev->usb_buf[0] = 0x0a; in start_cif_cam()
577 gspca_dev->usb_buf[1] = 0x00; in start_cif_cam()
578 err_code = mr_write(gspca_dev, 2); in start_cif_cam()
581 err_code = sensor_write_regs(gspca_dev, cif_sensor1_init_data, in start_cif_cam()
587 static int start_vga_cam(struct gspca_dev *gspca_dev) in start_vga_cam() argument
589 struct sd *sd = (struct sd *) gspca_dev; in start_vga_cam()
590 __u8 *data = gspca_dev->usb_buf; in start_vga_cam()
607 switch (gspca_dev->pixfmt.width) { in start_vga_cam()
641 err_code = mr_write(gspca_dev, 11); in start_vga_cam()
654 err_code = sensor_write_regs(gspca_dev, vga_sensor0_init_data, in start_vga_cam()
683 err_code = sensor_write_regs(gspca_dev, color_adj, in start_vga_cam()
686 err_code = sensor_write_regs(gspca_dev, color_no_adj, in start_vga_cam()
692 err_code = sensor_write_regs(gspca_dev, vga_sensor1_init_data, in start_vga_cam()
734 err_code = sensor_write_regs(gspca_dev, vga_sensor2_init_data, in start_vga_cam()
740 static int sd_start(struct gspca_dev *gspca_dev) in sd_start() argument
742 struct sd *sd = (struct sd *) gspca_dev; in sd_start()
751 err_code = zero_the_pointer(gspca_dev); in sd_start()
755 err_code = stream_start(gspca_dev); in sd_start()
760 err_code = start_cif_cam(gspca_dev); in sd_start()
762 err_code = start_vga_cam(gspca_dev); in sd_start()
767 return isoc_enable(gspca_dev); in sd_start()
770 static void sd_stopN(struct gspca_dev *gspca_dev) in sd_stopN() argument
772 struct sd *sd = (struct sd *) gspca_dev; in sd_stopN()
774 stream_stop(gspca_dev); in sd_stopN()
776 zero_the_pointer(gspca_dev); in sd_stopN()
778 lcd_stop(gspca_dev); in sd_stopN()
781 static void setbrightness(struct gspca_dev *gspca_dev, s32 val) in setbrightness() argument
783 struct sd *sd = (struct sd *) gspca_dev; in setbrightness()
796 sensor_write1(gspca_dev, sign_reg, 0x00); in setbrightness()
798 sensor_write1(gspca_dev, sign_reg, 0x01); in setbrightness()
805 sensor_write1(gspca_dev, value_reg, val); in setbrightness()
808 static void setexposure(struct gspca_dev *gspca_dev, s32 expo, s32 min_clockdiv) in setexposure() argument
810 struct sd *sd = (struct sd *) gspca_dev; in setexposure()
818 sensor_write1(gspca_dev, 3, exposure >> 4); in setexposure()
819 sensor_write1(gspca_dev, 4, exposure & 0x0f); in setexposure()
823 sensor_write1(gspca_dev, 3, exposure >> 8); in setexposure()
824 sensor_write1(gspca_dev, 4, exposure & 0xff); in setexposure()
836 if (clockdiv < min_clockdiv && gspca_dev->pixfmt.width >= 320) in setexposure()
855 sensor_write_reg(gspca_dev, 0x0e, 0, buf, 2); in setexposure()
856 sensor_write1(gspca_dev, 0x02, clockdiv); in setexposure()
860 static void setgain(struct gspca_dev *gspca_dev, s32 val) in setgain() argument
862 struct sd *sd = (struct sd *) gspca_dev; in setgain()
866 sensor_write1(gspca_dev, 0x0e, val); in setgain()
869 sensor_write1(gspca_dev, gainreg, val >> 8); in setgain()
870 sensor_write1(gspca_dev, gainreg + 1, val & 0xff); in setgain()
873 sensor_write1(gspca_dev, 0x10, val); in setgain()
876 static void setcontrast(struct gspca_dev *gspca_dev, s32 val) in setcontrast() argument
878 sensor_write1(gspca_dev, 0x1c, val); in setcontrast()
883 struct gspca_dev *gspca_dev = in sd_s_ctrl() local
884 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_s_ctrl()
885 struct sd *sd = (struct sd *)gspca_dev; in sd_s_ctrl()
887 gspca_dev->usb_err = 0; in sd_s_ctrl()
889 if (!gspca_dev->streaming) in sd_s_ctrl()
894 setbrightness(gspca_dev, ctrl->val); in sd_s_ctrl()
897 setcontrast(gspca_dev, ctrl->val); in sd_s_ctrl()
900 setexposure(gspca_dev, sd->exposure->val, in sd_s_ctrl()
904 setgain(gspca_dev, ctrl->val); in sd_s_ctrl()
907 return gspca_dev->usb_err; in sd_s_ctrl()
914 static int sd_init_controls(struct gspca_dev *gspca_dev) in sd_init_controls() argument
916 struct sd *sd = (struct sd *)gspca_dev; in sd_init_controls()
917 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; in sd_init_controls()
936 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()
1008 static void sd_pkt_scan(struct gspca_dev *gspca_dev, in sd_pkt_scan() argument
1012 struct sd *sd = (struct sd *) gspca_dev; in sd_pkt_scan()
1015 sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len); in sd_pkt_scan()
1025 gspca_frame_add(gspca_dev, LAST_PACKET, in sd_pkt_scan()
1028 gspca_frame_add(gspca_dev, FIRST_PACKET, in sd_pkt_scan()
1033 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); in sd_pkt_scan()