Lines Matching refs:gspca_dev
114 struct gspca_dev gspca_dev; /* !! must be the first item */ member
246 static void reg_w_buf(struct gspca_dev *gspca_dev, in reg_w_buf() argument
252 if (gspca_dev->usb_err < 0) in reg_w_buf()
254 memcpy(gspca_dev->usb_buf, buffer, len); in reg_w_buf()
255 ret = usb_control_msg(gspca_dev->dev, in reg_w_buf()
256 usb_sndctrlpipe(gspca_dev->dev, 0), in reg_w_buf()
260 index, gspca_dev->usb_buf, len, in reg_w_buf()
265 gspca_dev->usb_err = ret; in reg_w_buf()
270 static void reg_w(struct gspca_dev *gspca_dev, in reg_w() argument
276 if (gspca_dev->usb_err < 0) in reg_w()
278 gspca_dev->usb_buf[0] = value; in reg_w()
279 ret = usb_control_msg(gspca_dev->dev, in reg_w()
280 usb_sndctrlpipe(gspca_dev->dev, 0), in reg_w()
283 0, index, gspca_dev->usb_buf, 1, in reg_w()
288 gspca_dev->usb_err = ret; in reg_w()
292 static void reg_w_seq(struct gspca_dev *gspca_dev, in reg_w_seq() argument
296 reg_w(gspca_dev, seq[0], seq[1]); in reg_w_seq()
302 static void reg_w_page(struct gspca_dev *gspca_dev, in reg_w_page() argument
308 if (gspca_dev->usb_err < 0) in reg_w_page()
313 gspca_dev->usb_buf[0] = page[index]; in reg_w_page()
314 ret = usb_control_msg(gspca_dev->dev, in reg_w_page()
315 usb_sndctrlpipe(gspca_dev->dev, 0), in reg_w_page()
318 0, index, gspca_dev->usb_buf, 1, in reg_w_page()
323 gspca_dev->usb_err = ret; in reg_w_page()
330 static void reg_w_var(struct gspca_dev *gspca_dev, in reg_w_var() argument
343 reg_w_page(gspca_dev, page3, page3_len); in reg_w_var()
352 reg_w_buf(gspca_dev, in reg_w_var()
357 reg_w_buf(gspca_dev, index, seq, 8); in reg_w_var()
368 static int sd_config(struct gspca_dev *gspca_dev, in sd_config() argument
371 struct sd *sd = (struct sd *) gspca_dev; in sd_config()
374 cam = &gspca_dev->cam; in sd_config()
383 static void setbrightcont(struct gspca_dev *gspca_dev) in setbrightcont() argument
385 struct sd *sd = (struct sd *) gspca_dev; in setbrightcont()
394 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ in setbrightcont()
404 reg_w(gspca_dev, 0xa2 + i, v); in setbrightcont()
406 reg_w(gspca_dev, 0xdc, 0x01); in setbrightcont()
409 static void setcolors(struct gspca_dev *gspca_dev) in setcolors() argument
411 struct sd *sd = (struct sd *) gspca_dev; in setcolors()
418 reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ in setcolors()
419 reg_w(gspca_dev, 0x11, 0x01); in setcolors()
420 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ in setcolors()
424 reg_w(gspca_dev, 0x0f + 2 * i, (v >> 8) & 0x07); in setcolors()
425 reg_w(gspca_dev, 0x0f + 2 * i + 1, v); in setcolors()
427 reg_w(gspca_dev, 0xdc, 0x01); in setcolors()
430 static void setwhitebalance(struct gspca_dev *gspca_dev) in setwhitebalance() argument
432 struct sd *sd = (struct sd *) gspca_dev; in setwhitebalance()
434 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ in setwhitebalance()
435 reg_w(gspca_dev, 0xc6, sd->white_balance->val); in setwhitebalance()
437 reg_w(gspca_dev, 0xdc, 0x01); in setwhitebalance()
458 static void setredbalance(struct gspca_dev *gspca_dev) in setredbalance() argument
460 struct sd *sd = (struct sd *) gspca_dev; in setredbalance()
462 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ in setredbalance()
463 reg_w(gspca_dev, 0x01, in setredbalance()
466 reg_w(gspca_dev, 0xdc, 0x01); in setredbalance()
469 static void setbluebalance(struct gspca_dev *gspca_dev) in setbluebalance() argument
471 struct sd *sd = (struct sd *) gspca_dev; in setbluebalance()
473 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ in setbluebalance()
474 reg_w(gspca_dev, 0x03, in setbluebalance()
477 reg_w(gspca_dev, 0xdc, 0x01); in setbluebalance()
480 static void setgain(struct gspca_dev *gspca_dev) in setgain() argument
484 if (gspca_dev->gain->val < 32) { in setgain()
485 reg10 = gspca_dev->gain->val; in setgain()
489 reg12 = gspca_dev->gain->val - 31; in setgain()
492 reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ in setgain()
493 reg_w(gspca_dev, 0x10, reg10); in setgain()
494 reg_w(gspca_dev, 0x12, reg12); in setgain()
497 reg_w(gspca_dev, 0x11, 0x01); in setgain()
500 static void setexposure(struct gspca_dev *gspca_dev) in setexposure() argument
510 clockdiv = (90 * gspca_dev->exposure->val + 1999) / 2000; in setexposure()
535 exposure = (gspca_dev->exposure->val * 45 * 448) / (1000 * clockdiv); in setexposure()
539 reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ in setexposure()
540 reg_w(gspca_dev, 0x02, clockdiv); in setexposure()
541 reg_w(gspca_dev, 0x0e, exposure & 0xff); in setexposure()
542 reg_w(gspca_dev, 0x0f, exposure >> 8); in setexposure()
545 reg_w(gspca_dev, 0x11, 0x01); in setexposure()
548 static void sethvflip(struct gspca_dev *gspca_dev) in sethvflip() argument
550 struct sd *sd = (struct sd *) gspca_dev; in sethvflip()
560 reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ in sethvflip()
562 reg_w(gspca_dev, 0x21, data); in sethvflip()
565 reg_w(gspca_dev, 0x11, 0x01); in sethvflip()
568 static void setsharpness(struct gspca_dev *gspca_dev) in setsharpness() argument
570 struct sd *sd = (struct sd *) gspca_dev; in setsharpness()
572 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ in setsharpness()
573 reg_w(gspca_dev, 0xb6, sd->sharpness->val); in setsharpness()
575 reg_w(gspca_dev, 0xdc, 0x01); in setsharpness()
579 static int sd_init(struct gspca_dev *gspca_dev) in sd_init() argument
581 reg_w_seq(gspca_dev, init_7302, sizeof(init_7302)/2); in sd_init()
582 return gspca_dev->usb_err; in sd_init()
587 struct gspca_dev *gspca_dev = in sd_s_ctrl() local
588 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in sd_s_ctrl()
589 struct sd *sd = (struct sd *)gspca_dev; in sd_s_ctrl()
591 gspca_dev->usb_err = 0; in sd_s_ctrl()
598 gspca_dev->exposure->val = PAC7302_EXPOSURE_DEFAULT; in sd_s_ctrl()
599 gspca_dev->gain->val = PAC7302_GAIN_DEFAULT; in sd_s_ctrl()
603 if (!gspca_dev->streaming) in sd_s_ctrl()
608 setbrightcont(gspca_dev); in sd_s_ctrl()
611 setcolors(gspca_dev); in sd_s_ctrl()
614 setwhitebalance(gspca_dev); in sd_s_ctrl()
617 setredbalance(gspca_dev); in sd_s_ctrl()
620 setbluebalance(gspca_dev); in sd_s_ctrl()
623 if (gspca_dev->exposure->is_new || (ctrl->is_new && ctrl->val)) in sd_s_ctrl()
624 setexposure(gspca_dev); in sd_s_ctrl()
625 if (gspca_dev->gain->is_new || (ctrl->is_new && ctrl->val)) in sd_s_ctrl()
626 setgain(gspca_dev); in sd_s_ctrl()
629 sethvflip(gspca_dev); in sd_s_ctrl()
632 setsharpness(gspca_dev); in sd_s_ctrl()
637 return gspca_dev->usb_err; in sd_s_ctrl()
645 static int sd_init_controls(struct gspca_dev *gspca_dev) in sd_init_controls() argument
647 struct sd *sd = (struct sd *) gspca_dev; in sd_init_controls()
648 struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; in sd_init_controls()
650 gspca_dev->vdev.ctrl_handler = hdl; in sd_init_controls()
674 gspca_dev->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
676 gspca_dev->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
679 gspca_dev->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
697 v4l2_ctrl_auto_cluster(3, &gspca_dev->autogain, 0, false); in sd_init_controls()
703 static int sd_start(struct gspca_dev *gspca_dev) in sd_start() argument
705 struct sd *sd = (struct sd *) gspca_dev; in sd_start()
707 reg_w_var(gspca_dev, start_7302, in sd_start()
715 reg_w(gspca_dev, 0xff, 0x01); in sd_start()
716 reg_w(gspca_dev, 0x78, 0x01); in sd_start()
718 return gspca_dev->usb_err; in sd_start()
721 static void sd_stopN(struct gspca_dev *gspca_dev) in sd_stopN() argument
725 reg_w(gspca_dev, 0xff, 0x01); in sd_stopN()
726 reg_w(gspca_dev, 0x78, 0x00); in sd_stopN()
730 static void sd_stop0(struct gspca_dev *gspca_dev) in sd_stop0() argument
732 if (!gspca_dev->present) in sd_stop0()
734 reg_w(gspca_dev, 0xff, 0x01); in sd_stop0()
735 reg_w(gspca_dev, 0x78, 0x40); in sd_stop0()
738 static void do_autogain(struct gspca_dev *gspca_dev) in do_autogain() argument
740 struct sd *sd = (struct sd *) gspca_dev; in do_autogain()
753 if (gspca_expo_autogain(gspca_dev, avg_lum, desired_lum, in do_autogain()
786 static void sd_pkt_scan(struct gspca_dev *gspca_dev, in sd_pkt_scan() argument
790 struct sd *sd = (struct sd *) gspca_dev; in sd_pkt_scan()
794 sof = pac_find_sof(gspca_dev, &sd->sof_read, data, len); in sd_pkt_scan()
810 gspca_dev->image_len += n; in sd_pkt_scan()
813 gspca_frame_add(gspca_dev, INTER_PACKET, data, n); in sd_pkt_scan()
816 image = gspca_dev->image; in sd_pkt_scan()
818 && image[gspca_dev->image_len - 2] == 0xff in sd_pkt_scan()
819 && image[gspca_dev->image_len - 1] == 0xd9) in sd_pkt_scan()
820 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); in sd_pkt_scan()
827 if (gspca_dev->last_packet_type == LAST_PACKET && in sd_pkt_scan()
834 gspca_frame_add(gspca_dev, FIRST_PACKET, in sd_pkt_scan()
837 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); in sd_pkt_scan()
841 static int sd_dbg_s_register(struct gspca_dev *gspca_dev, in sd_dbg_s_register() argument
865 reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ in sd_dbg_s_register()
866 reg_w(gspca_dev, index, value); in sd_dbg_s_register()
868 reg_w(gspca_dev, 0xdc, 0x01); in sd_dbg_s_register()
870 return gspca_dev->usb_err; in sd_dbg_s_register()
875 static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, in sd_int_pkt_scan() argument
893 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); in sd_int_pkt_scan()
894 input_sync(gspca_dev->input_dev); in sd_int_pkt_scan()
895 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); in sd_int_pkt_scan()
896 input_sync(gspca_dev->input_dev); in sd_int_pkt_scan()