Lines Matching refs:gspca_dev
53 static void PDEBUG_MODE(struct gspca_dev *gspca_dev, int debug, char *txt, in PDEBUG_MODE() argument
57 gspca_dbg(gspca_dev, debug, "%s %c%c%c%c %dx%d\n", in PDEBUG_MODE()
65 gspca_dbg(gspca_dev, debug, "%s 0x%08x %dx%d\n", in PDEBUG_MODE()
82 struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context; in int_irq() local
88 if (gspca_dev->sd_desc->int_pkt_scan(gspca_dev, in int_irq()
90 gspca_err(gspca_dev, "Unknown packet received\n"); in int_irq()
104 gspca_err(gspca_dev, "URB error %i, resubmitting\n", in int_irq()
117 static int gspca_input_connect(struct gspca_dev *dev) in gspca_input_connect()
154 static int alloc_and_submit_int_urb(struct gspca_dev *gspca_dev, in alloc_and_submit_int_urb() argument
166 gspca_dbg(gspca_dev, D_CONF, "found int in endpoint: 0x%x, buffer_len=%u, interval=%u\n", in alloc_and_submit_int_urb()
169 dev = gspca_dev->dev; in alloc_and_submit_int_urb()
186 int_irq, (void *)gspca_dev, interval); in alloc_and_submit_int_urb()
190 gspca_err(gspca_dev, "submit int URB failed with error %i\n", in alloc_and_submit_int_urb()
194 gspca_dev->int_urb = urb; in alloc_and_submit_int_urb()
208 static void gspca_input_create_urb(struct gspca_dev *gspca_dev) in gspca_input_create_urb() argument
215 if (gspca_dev->sd_desc->int_pkt_scan) { in gspca_input_create_urb()
216 intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface); in gspca_input_create_urb()
223 alloc_and_submit_int_urb(gspca_dev, ep); in gspca_input_create_urb()
230 static void gspca_input_destroy_urb(struct gspca_dev *gspca_dev) in gspca_input_destroy_urb() argument
234 urb = gspca_dev->int_urb; in gspca_input_destroy_urb()
236 gspca_dev->int_urb = NULL; in gspca_input_destroy_urb()
238 usb_free_coherent(gspca_dev->dev, in gspca_input_destroy_urb()
246 static inline void gspca_input_destroy_urb(struct gspca_dev *gspca_dev) in gspca_input_destroy_urb() argument
250 static inline void gspca_input_create_urb(struct gspca_dev *gspca_dev) in gspca_input_create_urb() argument
254 static inline int gspca_input_connect(struct gspca_dev *dev) in gspca_input_connect()
263 static void fill_frame(struct gspca_dev *gspca_dev, in fill_frame() argument
274 if (gspca_dev->frozen) in fill_frame()
277 gspca_err(gspca_dev, "urb status: %d\n", urb->status); in fill_frame()
281 pkt_scan = gspca_dev->sd_desc->pkt_scan; in fill_frame()
288 gspca_dbg(gspca_dev, D_PACK, "ISOC data error: [%d] len=%d, status=%d\n", in fill_frame()
290 gspca_dev->last_packet_type = DISCARD_PACKET; in fill_frame()
294 if (gspca_dev->empty_packet == 0) in fill_frame()
295 gspca_dev->empty_packet = 1; in fill_frame()
300 gspca_dbg(gspca_dev, D_PACK, "packet [%d] o:%d l:%d\n", in fill_frame()
304 pkt_scan(gspca_dev, data, len); in fill_frame()
308 if (!gspca_dev->streaming) in fill_frame()
323 struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context; in isoc_irq() local
325 gspca_dbg(gspca_dev, D_PACK, "isoc irq\n"); in isoc_irq()
326 if (!gspca_dev->streaming) in isoc_irq()
328 fill_frame(gspca_dev, urb); in isoc_irq()
336 struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context; in bulk_irq() local
339 gspca_dbg(gspca_dev, D_PACK, "bulk irq\n"); in bulk_irq()
340 if (!gspca_dev->streaming) in bulk_irq()
349 if (gspca_dev->frozen) in bulk_irq()
352 gspca_err(gspca_dev, "urb status: %d\n", urb->status); in bulk_irq()
357 gspca_dbg(gspca_dev, D_PACK, "packet l:%d\n", urb->actual_length); in bulk_irq()
358 gspca_dev->sd_desc->pkt_scan(gspca_dev, in bulk_irq()
363 if (!gspca_dev->streaming) in bulk_irq()
366 if (gspca_dev->cam.bulk_nurbs != 0) { in bulk_irq()
384 void gspca_frame_add(struct gspca_dev *gspca_dev, in gspca_frame_add() argument
392 gspca_dbg(gspca_dev, D_PACK, "add t:%d l:%d\n", packet_type, len); in gspca_frame_add()
394 spin_lock_irqsave(&gspca_dev->qlock, flags); in gspca_frame_add()
395 buf = list_first_entry_or_null(&gspca_dev->buf_list, in gspca_frame_add()
397 spin_unlock_irqrestore(&gspca_dev->qlock, flags); in gspca_frame_add()
402 gspca_dev->last_packet_type = DISCARD_PACKET; in gspca_frame_add()
403 gspca_dev->sequence++; in gspca_frame_add()
406 gspca_dev->image = vb2_plane_vaddr(&buf->vb.vb2_buf, 0); in gspca_frame_add()
407 gspca_dev->image_len = 0; in gspca_frame_add()
409 switch (gspca_dev->last_packet_type) { in gspca_frame_add()
412 gspca_dev->last_packet_type = packet_type; in gspca_frame_add()
413 gspca_dev->image = NULL; in gspca_frame_add()
414 gspca_dev->image_len = 0; in gspca_frame_add()
424 if (gspca_dev->image_len + len > PAGE_ALIGN(gspca_dev->pixfmt.sizeimage)) { in gspca_frame_add()
425 gspca_err(gspca_dev, "frame overflow %d > %d\n", in gspca_frame_add()
426 gspca_dev->image_len + len, in gspca_frame_add()
427 PAGE_ALIGN(gspca_dev->pixfmt.sizeimage)); in gspca_frame_add()
436 memcpy(gspca_dev->image + gspca_dev->image_len, in gspca_frame_add()
438 gspca_dev->image_len += len; in gspca_frame_add()
441 gspca_dev->last_packet_type = packet_type; in gspca_frame_add()
447 if (gspca_dev->image_len > gspca_dev->pixfmt.sizeimage) in gspca_frame_add()
448 gspca_dev->image_len = gspca_dev->pixfmt.sizeimage; in gspca_frame_add()
449 spin_lock_irqsave(&gspca_dev->qlock, flags); in gspca_frame_add()
451 spin_unlock_irqrestore(&gspca_dev->qlock, flags); in gspca_frame_add()
454 gspca_dev->image_len); in gspca_frame_add()
455 buf->vb.sequence = gspca_dev->sequence++; in gspca_frame_add()
457 gspca_dbg(gspca_dev, D_FRAM, "frame complete len:%d\n", in gspca_frame_add()
458 gspca_dev->image_len); in gspca_frame_add()
460 gspca_dev->image = NULL; in gspca_frame_add()
461 gspca_dev->image_len = 0; in gspca_frame_add()
466 static void destroy_urbs(struct gspca_dev *gspca_dev) in destroy_urbs() argument
471 gspca_dbg(gspca_dev, D_STREAM, "kill transfer\n"); in destroy_urbs()
478 usb_kill_urb(gspca_dev->urb[i]); in destroy_urbs()
480 gspca_dbg(gspca_dev, D_STREAM, "releasing urbs\n"); in destroy_urbs()
482 urb = gspca_dev->urb[i]; in destroy_urbs()
485 gspca_dev->urb[i] = NULL; in destroy_urbs()
486 usb_free_coherent(gspca_dev->dev, in destroy_urbs()
494 static int gspca_set_alt0(struct gspca_dev *gspca_dev) in gspca_set_alt0() argument
498 if (gspca_dev->alt == 0) in gspca_set_alt0()
500 ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0); in gspca_set_alt0()
531 static u32 which_bandwidth(struct gspca_dev *gspca_dev) in which_bandwidth() argument
536 bandwidth = gspca_dev->pixfmt.sizeimage; in which_bandwidth()
539 if (!gspca_dev->cam.needs_full_bandwidth && in which_bandwidth()
540 bandwidth < gspca_dev->pixfmt.width * in which_bandwidth()
541 gspca_dev->pixfmt.height) in which_bandwidth()
545 if (gspca_dev->sd_desc->get_streamparm) { in which_bandwidth()
548 gspca_dev->sd_desc->get_streamparm(gspca_dev, &parm); in which_bandwidth()
555 if (gspca_dev->pixfmt.width >= 640 in which_bandwidth()
556 && gspca_dev->dev->speed == USB_SPEED_FULL) in which_bandwidth()
562 gspca_dbg(gspca_dev, D_STREAM, "min bandwidth: %d\n", bandwidth); in which_bandwidth()
577 static int build_isoc_ep_tb(struct gspca_dev *gspca_dev, in build_isoc_ep_tb() argument
598 gspca_dev->xfer_ep); in build_isoc_ep_tb()
608 if (gspca_dev->dev->speed == USB_SPEED_HIGH in build_isoc_ep_tb()
609 || gspca_dev->dev->speed >= USB_SPEED_SUPER) in build_isoc_ep_tb()
622 gspca_dbg(gspca_dev, D_STREAM, "alt %d bandwidth %d\n", in build_isoc_ep_tb()
637 if (gspca_dev->audio && in build_isoc_ep_tb()
638 gspca_dev->dev->speed == USB_SPEED_FULL && in build_isoc_ep_tb()
641 gspca_dbg(gspca_dev, D_STREAM, "dev has usb audio, skipping highest alt\n"); in build_isoc_ep_tb()
647 bandwidth = which_bandwidth(gspca_dev); in build_isoc_ep_tb()
661 static int create_urbs(struct gspca_dev *gspca_dev, in create_urbs() argument
670 if (!gspca_dev->cam.bulk) { /* isoc */ in create_urbs()
673 if (gspca_dev->pkt_size == 0) in create_urbs()
676 psize = gspca_dev->pkt_size; in create_urbs()
677 npkt = gspca_dev->cam.npkt; in create_urbs()
681 gspca_dbg(gspca_dev, D_STREAM, in create_urbs()
687 bsize = gspca_dev->cam.bulk_size; in create_urbs()
690 gspca_dbg(gspca_dev, D_STREAM, "bulk bsize:%d\n", bsize); in create_urbs()
691 if (gspca_dev->cam.bulk_nurbs != 0) in create_urbs()
692 nurbs = gspca_dev->cam.bulk_nurbs; in create_urbs()
701 gspca_dev->urb[n] = urb; in create_urbs()
702 urb->transfer_buffer = usb_alloc_coherent(gspca_dev->dev, in create_urbs()
711 urb->dev = gspca_dev->dev; in create_urbs()
712 urb->context = gspca_dev; in create_urbs()
715 urb->pipe = usb_rcvisocpipe(gspca_dev->dev, in create_urbs()
727 urb->pipe = usb_rcvbulkpipe(gspca_dev->dev, in create_urbs()
737 static void gspca_stream_off(struct gspca_dev *gspca_dev) in gspca_stream_off() argument
739 gspca_dev->streaming = false; in gspca_stream_off()
740 gspca_dev->usb_err = 0; in gspca_stream_off()
741 if (gspca_dev->sd_desc->stopN) in gspca_stream_off()
742 gspca_dev->sd_desc->stopN(gspca_dev); in gspca_stream_off()
743 destroy_urbs(gspca_dev); in gspca_stream_off()
744 gspca_input_destroy_urb(gspca_dev); in gspca_stream_off()
745 gspca_set_alt0(gspca_dev); in gspca_stream_off()
746 if (gspca_dev->present) in gspca_stream_off()
747 gspca_input_create_urb(gspca_dev); in gspca_stream_off()
748 if (gspca_dev->sd_desc->stop0) in gspca_stream_off()
749 gspca_dev->sd_desc->stop0(gspca_dev); in gspca_stream_off()
750 gspca_dbg(gspca_dev, D_STREAM, "stream off OK\n"); in gspca_stream_off()
756 static int gspca_init_transfer(struct gspca_dev *gspca_dev) in gspca_init_transfer() argument
765 gspca_dev->image = NULL; in gspca_init_transfer()
766 gspca_dev->image_len = 0; in gspca_init_transfer()
767 gspca_dev->last_packet_type = DISCARD_PACKET; in gspca_init_transfer()
769 gspca_dev->usb_err = 0; in gspca_init_transfer()
772 intf = usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface); in gspca_init_transfer()
773 gspca_dev->alt = gspca_dev->cam.bulk ? intf->num_altsetting : 0; in gspca_init_transfer()
774 if (gspca_dev->sd_desc->isoc_init) { in gspca_init_transfer()
775 ret = gspca_dev->sd_desc->isoc_init(gspca_dev); in gspca_init_transfer()
779 xfer = gspca_dev->cam.bulk ? USB_ENDPOINT_XFER_BULK in gspca_init_transfer()
783 if (gspca_dev->alt != 0) { in gspca_init_transfer()
784 gspca_dev->alt--; /* (previous version compatibility) */ in gspca_init_transfer()
785 ep = alt_xfer(&intf->altsetting[gspca_dev->alt], xfer, in gspca_init_transfer()
786 gspca_dev->xfer_ep); in gspca_init_transfer()
788 pr_err("bad altsetting %d\n", gspca_dev->alt); in gspca_init_transfer()
791 ep_tb[0].alt = gspca_dev->alt; in gspca_init_transfer()
796 alt_idx = build_isoc_ep_tb(gspca_dev, intf, ep_tb); in gspca_init_transfer()
805 gspca_input_destroy_urb(gspca_dev); in gspca_init_transfer()
807 gspca_dev->alt = ep_tb[--alt_idx].alt; in gspca_init_transfer()
810 if (alt != gspca_dev->alt) { in gspca_init_transfer()
811 alt = gspca_dev->alt; in gspca_init_transfer()
813 ret = usb_set_interface(gspca_dev->dev, in gspca_init_transfer()
814 gspca_dev->iface, in gspca_init_transfer()
824 if (!gspca_dev->cam.no_urb_create) { in gspca_init_transfer()
825 gspca_dbg(gspca_dev, D_STREAM, "init transfer alt %d\n", in gspca_init_transfer()
827 ret = create_urbs(gspca_dev, in gspca_init_transfer()
829 gspca_dev->xfer_ep)); in gspca_init_transfer()
831 destroy_urbs(gspca_dev); in gspca_init_transfer()
837 if (gspca_dev->cam.bulk) in gspca_init_transfer()
838 usb_clear_halt(gspca_dev->dev, in gspca_init_transfer()
839 gspca_dev->urb[0]->pipe); in gspca_init_transfer()
842 ret = gspca_dev->sd_desc->start(gspca_dev); in gspca_init_transfer()
844 destroy_urbs(gspca_dev); in gspca_init_transfer()
847 v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler); in gspca_init_transfer()
848 gspca_dev->streaming = true; in gspca_init_transfer()
851 if (gspca_dev->cam.bulk && gspca_dev->cam.bulk_nurbs == 0) in gspca_init_transfer()
856 urb = gspca_dev->urb[n]; in gspca_init_transfer()
868 gspca_stream_off(gspca_dev); in gspca_init_transfer()
871 gspca_dev->alt, ret); in gspca_init_transfer()
878 gspca_err(gspca_dev, "alt %d - bandwidth not wide enough, trying again\n", in gspca_init_transfer()
881 if (gspca_dev->sd_desc->isoc_nego) { in gspca_init_transfer()
882 ret = gspca_dev->sd_desc->isoc_nego(gspca_dev); in gspca_init_transfer()
891 gspca_dev->alt = ep_tb[--alt_idx].alt; in gspca_init_transfer()
895 gspca_input_create_urb(gspca_dev); in gspca_init_transfer()
899 static void gspca_set_default_mode(struct gspca_dev *gspca_dev) in gspca_set_default_mode() argument
903 i = gspca_dev->cam.nmodes - 1; /* take the highest mode */ in gspca_set_default_mode()
904 gspca_dev->curr_mode = i; in gspca_set_default_mode()
905 gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i]; in gspca_set_default_mode()
908 v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler); in gspca_set_default_mode()
911 static int wxh_to_mode(struct gspca_dev *gspca_dev, in wxh_to_mode() argument
916 for (i = 0; i < gspca_dev->cam.nmodes; i++) { in wxh_to_mode()
917 if (width == gspca_dev->cam.cam_mode[i].width in wxh_to_mode()
918 && height == gspca_dev->cam.cam_mode[i].height in wxh_to_mode()
919 && pixelformat == gspca_dev->cam.cam_mode[i].pixelformat) in wxh_to_mode()
925 static int wxh_to_nearest_mode(struct gspca_dev *gspca_dev, in wxh_to_nearest_mode() argument
930 for (i = gspca_dev->cam.nmodes; --i >= 0; ) { in wxh_to_nearest_mode()
931 if (width >= gspca_dev->cam.cam_mode[i].width in wxh_to_nearest_mode()
932 && height >= gspca_dev->cam.cam_mode[i].height in wxh_to_nearest_mode()
933 && pixelformat == gspca_dev->cam.cam_mode[i].pixelformat) in wxh_to_nearest_mode()
936 for (i = gspca_dev->cam.nmodes; --i > 0; ) { in wxh_to_nearest_mode()
937 if (width >= gspca_dev->cam.cam_mode[i].width in wxh_to_nearest_mode()
938 && height >= gspca_dev->cam.cam_mode[i].height) in wxh_to_nearest_mode()
947 static int gspca_get_mode(struct gspca_dev *gspca_dev, in gspca_get_mode() argument
954 while ((modeU < gspca_dev->cam.nmodes) || modeD >= 0) { in gspca_get_mode()
956 if (gspca_dev->cam.cam_mode[modeD].pixelformat in gspca_get_mode()
960 if (++modeU < gspca_dev->cam.nmodes) { in gspca_get_mode()
961 if (gspca_dev->cam.cam_mode[modeU].pixelformat in gspca_get_mode()
973 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_g_chip_info() local
975 gspca_dev->usb_err = 0; in vidioc_g_chip_info()
976 if (gspca_dev->sd_desc->get_chip_info) in vidioc_g_chip_info()
977 return gspca_dev->sd_desc->get_chip_info(gspca_dev, chip); in vidioc_g_chip_info()
984 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_g_register() local
986 gspca_dev->usb_err = 0; in vidioc_g_register()
987 return gspca_dev->sd_desc->get_register(gspca_dev, reg); in vidioc_g_register()
993 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_s_register() local
995 gspca_dev->usb_err = 0; in vidioc_s_register()
996 return gspca_dev->sd_desc->set_register(gspca_dev, reg); in vidioc_s_register()
1003 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_enum_fmt_vid_cap() local
1009 for (i = gspca_dev->cam.nmodes; --i >= 0; ) { in vidioc_enum_fmt_vid_cap()
1010 fmt_tb[index] = gspca_dev->cam.cam_mode[i].pixelformat; in vidioc_enum_fmt_vid_cap()
1035 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
1038 fmt->fmt.pix = gspca_dev->pixfmt; in vidioc_g_fmt_vid_cap()
1044 static int try_fmt_vid_cap(struct gspca_dev *gspca_dev, in try_fmt_vid_cap() argument
1052 PDEBUG_MODE(gspca_dev, D_CONF, "try fmt cap", in try_fmt_vid_cap()
1056 mode = wxh_to_nearest_mode(gspca_dev, w, h, fmt->fmt.pix.pixelformat); in try_fmt_vid_cap()
1059 if (gspca_dev->cam.cam_mode[mode].pixelformat in try_fmt_vid_cap()
1063 mode2 = gspca_get_mode(gspca_dev, mode, in try_fmt_vid_cap()
1068 fmt->fmt.pix = gspca_dev->cam.cam_mode[mode]; in try_fmt_vid_cap()
1069 if (gspca_dev->sd_desc->try_fmt) { in try_fmt_vid_cap()
1073 gspca_dev->sd_desc->try_fmt(gspca_dev, fmt); in try_fmt_vid_cap()
1081 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_try_fmt_vid_cap() local
1084 if (try_fmt_vid_cap(gspca_dev, fmt) < 0) in vidioc_try_fmt_vid_cap()
1094 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_s_fmt_vid_cap() local
1098 if (vb2_is_busy(&gspca_dev->queue)) in vidioc_s_fmt_vid_cap()
1101 mode = try_fmt_vid_cap(gspca_dev, fmt); in vidioc_s_fmt_vid_cap()
1105 gspca_dev->curr_mode = mode; in vidioc_s_fmt_vid_cap()
1106 if (gspca_dev->sd_desc->try_fmt) in vidioc_s_fmt_vid_cap()
1108 gspca_dev->pixfmt = fmt->fmt.pix; in vidioc_s_fmt_vid_cap()
1110 gspca_dev->pixfmt = gspca_dev->cam.cam_mode[mode]; in vidioc_s_fmt_vid_cap()
1119 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_enum_framesizes() local
1123 if (gspca_dev->sd_desc->enum_framesizes) in vidioc_enum_framesizes()
1124 return gspca_dev->sd_desc->enum_framesizes(gspca_dev, fsize); in vidioc_enum_framesizes()
1126 for (i = 0; i < gspca_dev->cam.nmodes; i++) { in vidioc_enum_framesizes()
1128 gspca_dev->cam.cam_mode[i].pixelformat) in vidioc_enum_framesizes()
1134 gspca_dev->cam.cam_mode[i].width; in vidioc_enum_framesizes()
1136 gspca_dev->cam.cam_mode[i].height; in vidioc_enum_framesizes()
1148 struct gspca_dev *gspca_dev = video_drvdata(filp); in vidioc_enum_frameintervals() local
1152 mode = wxh_to_mode(gspca_dev, fival->width, fival->height, in vidioc_enum_frameintervals()
1157 if (gspca_dev->cam.mode_framerates == NULL || in vidioc_enum_frameintervals()
1158 gspca_dev->cam.mode_framerates[mode].nrates == 0) in vidioc_enum_frameintervals()
1162 gspca_dev->cam.cam_mode[mode].pixelformat) in vidioc_enum_frameintervals()
1165 for (i = 0; i < gspca_dev->cam.mode_framerates[mode].nrates; i++) { in vidioc_enum_frameintervals()
1170 gspca_dev->cam.mode_framerates[mode].rates[i]; in vidioc_enum_frameintervals()
1180 struct gspca_dev *gspca_dev = in gspca_release() local
1181 container_of(v4l2_device, struct gspca_dev, v4l2_dev); in gspca_release()
1183 v4l2_ctrl_handler_free(gspca_dev->vdev.ctrl_handler); in gspca_release()
1184 v4l2_device_unregister(&gspca_dev->v4l2_dev); in gspca_release()
1185 kfree(gspca_dev->usb_buf); in gspca_release()
1186 kfree(gspca_dev); in gspca_release()
1192 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_querycap() local
1194 strscpy((char *)cap->driver, gspca_dev->sd_desc->name, in vidioc_querycap()
1196 if (gspca_dev->dev->product != NULL) { in vidioc_querycap()
1197 strscpy((char *)cap->card, gspca_dev->dev->product, in vidioc_querycap()
1202 le16_to_cpu(gspca_dev->dev->descriptor.idVendor), in vidioc_querycap()
1203 le16_to_cpu(gspca_dev->dev->descriptor.idProduct)); in vidioc_querycap()
1205 usb_make_path(gspca_dev->dev, (char *) cap->bus_info, in vidioc_querycap()
1213 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_enum_input() local
1218 input->status = gspca_dev->cam.input_flags; in vidioc_enum_input()
1219 strscpy(input->name, gspca_dev->sd_desc->name, in vidioc_enum_input()
1240 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_g_jpegcomp() local
1242 gspca_dev->usb_err = 0; in vidioc_g_jpegcomp()
1243 return gspca_dev->sd_desc->get_jcomp(gspca_dev, jpegcomp); in vidioc_g_jpegcomp()
1249 struct gspca_dev *gspca_dev = video_drvdata(file); in vidioc_s_jpegcomp() local
1251 gspca_dev->usb_err = 0; in vidioc_s_jpegcomp()
1252 return gspca_dev->sd_desc->set_jcomp(gspca_dev, jpegcomp); in vidioc_s_jpegcomp()
1258 struct gspca_dev *gspca_dev = video_drvdata(filp); in vidioc_g_parm() local
1260 parm->parm.capture.readbuffers = gspca_dev->queue.min_buffers_needed; in vidioc_g_parm()
1262 if (!gspca_dev->sd_desc->get_streamparm) in vidioc_g_parm()
1266 gspca_dev->usb_err = 0; in vidioc_g_parm()
1267 gspca_dev->sd_desc->get_streamparm(gspca_dev, parm); in vidioc_g_parm()
1268 return gspca_dev->usb_err; in vidioc_g_parm()
1274 struct gspca_dev *gspca_dev = video_drvdata(filp); in vidioc_s_parm() local
1276 parm->parm.capture.readbuffers = gspca_dev->queue.min_buffers_needed; in vidioc_s_parm()
1278 if (!gspca_dev->sd_desc->set_streamparm) { in vidioc_s_parm()
1284 gspca_dev->usb_err = 0; in vidioc_s_parm()
1285 gspca_dev->sd_desc->set_streamparm(gspca_dev, parm); in vidioc_s_parm()
1286 return gspca_dev->usb_err; in vidioc_s_parm()
1293 struct gspca_dev *gspca_dev = vb2_get_drv_priv(vq); in gspca_queue_setup() local
1294 unsigned int size = PAGE_ALIGN(gspca_dev->pixfmt.sizeimage); in gspca_queue_setup()
1305 struct gspca_dev *gspca_dev = vb2_get_drv_priv(vb->vb2_queue); in gspca_buffer_prepare() local
1306 unsigned long size = PAGE_ALIGN(gspca_dev->pixfmt.sizeimage); in gspca_buffer_prepare()
1309 gspca_err(gspca_dev, "buffer too small (%lu < %lu)\n", in gspca_buffer_prepare()
1318 struct gspca_dev *gspca_dev = vb2_get_drv_priv(vb->vb2_queue); in gspca_buffer_finish() local
1320 if (!gspca_dev->sd_desc->dq_callback) in gspca_buffer_finish()
1323 gspca_dev->usb_err = 0; in gspca_buffer_finish()
1324 if (gspca_dev->present) in gspca_buffer_finish()
1325 gspca_dev->sd_desc->dq_callback(gspca_dev); in gspca_buffer_finish()
1330 struct gspca_dev *gspca_dev = vb2_get_drv_priv(vb->vb2_queue); in gspca_buffer_queue() local
1334 spin_lock_irqsave(&gspca_dev->qlock, flags); in gspca_buffer_queue()
1335 list_add_tail(&buf->list, &gspca_dev->buf_list); in gspca_buffer_queue()
1336 spin_unlock_irqrestore(&gspca_dev->qlock, flags); in gspca_buffer_queue()
1339 static void gspca_return_all_buffers(struct gspca_dev *gspca_dev, in gspca_return_all_buffers() argument
1345 spin_lock_irqsave(&gspca_dev->qlock, flags); in gspca_return_all_buffers()
1346 list_for_each_entry_safe(buf, node, &gspca_dev->buf_list, list) { in gspca_return_all_buffers()
1350 spin_unlock_irqrestore(&gspca_dev->qlock, flags); in gspca_return_all_buffers()
1355 struct gspca_dev *gspca_dev = vb2_get_drv_priv(vq); in gspca_start_streaming() local
1358 gspca_dev->sequence = 0; in gspca_start_streaming()
1360 ret = gspca_init_transfer(gspca_dev); in gspca_start_streaming()
1362 gspca_return_all_buffers(gspca_dev, VB2_BUF_STATE_QUEUED); in gspca_start_streaming()
1368 struct gspca_dev *gspca_dev = vb2_get_drv_priv(vq); in gspca_stop_streaming() local
1370 gspca_stream_off(gspca_dev); in gspca_stop_streaming()
1373 gspca_return_all_buffers(gspca_dev, VB2_BUF_STATE_ERROR); in gspca_stop_streaming()
1450 struct gspca_dev *gspca_dev; in gspca_dev_probe2() local
1459 if (dev_size < sizeof *gspca_dev) in gspca_dev_probe2()
1460 dev_size = sizeof *gspca_dev; in gspca_dev_probe2()
1461 gspca_dev = kzalloc(dev_size, GFP_KERNEL); in gspca_dev_probe2()
1462 if (!gspca_dev) { in gspca_dev_probe2()
1466 gspca_dev->usb_buf = kzalloc(USB_BUF_SZ, GFP_KERNEL); in gspca_dev_probe2()
1467 if (!gspca_dev->usb_buf) { in gspca_dev_probe2()
1472 gspca_dev->dev = dev; in gspca_dev_probe2()
1473 gspca_dev->iface = intf->cur_altsetting->desc.bInterfaceNumber; in gspca_dev_probe2()
1474 gspca_dev->xfer_ep = -1; in gspca_dev_probe2()
1487 gspca_dev->audio = 1; in gspca_dev_probe2()
1493 gspca_dev->v4l2_dev.release = gspca_release; in gspca_dev_probe2()
1494 ret = v4l2_device_register(&intf->dev, &gspca_dev->v4l2_dev); in gspca_dev_probe2()
1497 gspca_dev->present = true; in gspca_dev_probe2()
1498 gspca_dev->sd_desc = sd_desc; in gspca_dev_probe2()
1499 gspca_dev->empty_packet = -1; /* don't check the empty packets */ in gspca_dev_probe2()
1500 gspca_dev->vdev = gspca_template; in gspca_dev_probe2()
1501 gspca_dev->vdev.v4l2_dev = &gspca_dev->v4l2_dev; in gspca_dev_probe2()
1502 gspca_dev->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE | in gspca_dev_probe2()
1504 video_set_drvdata(&gspca_dev->vdev, gspca_dev); in gspca_dev_probe2()
1505 gspca_dev->module = module; in gspca_dev_probe2()
1507 mutex_init(&gspca_dev->usb_lock); in gspca_dev_probe2()
1508 gspca_dev->vdev.lock = &gspca_dev->usb_lock; in gspca_dev_probe2()
1509 init_waitqueue_head(&gspca_dev->wq); in gspca_dev_probe2()
1512 q = &gspca_dev->queue; in gspca_dev_probe2()
1515 q->drv_priv = gspca_dev; in gspca_dev_probe2()
1521 q->lock = &gspca_dev->usb_lock; in gspca_dev_probe2()
1525 gspca_dev->vdev.queue = q; in gspca_dev_probe2()
1527 INIT_LIST_HEAD(&gspca_dev->buf_list); in gspca_dev_probe2()
1528 spin_lock_init(&gspca_dev->qlock); in gspca_dev_probe2()
1531 ret = sd_desc->config(gspca_dev, id); in gspca_dev_probe2()
1534 ret = sd_desc->init(gspca_dev); in gspca_dev_probe2()
1538 ret = sd_desc->init_controls(gspca_dev); in gspca_dev_probe2()
1541 gspca_set_default_mode(gspca_dev); in gspca_dev_probe2()
1543 ret = gspca_input_connect(gspca_dev); in gspca_dev_probe2()
1548 if (!gspca_dev->sd_desc->get_register) in gspca_dev_probe2()
1549 v4l2_disable_ioctl(&gspca_dev->vdev, VIDIOC_DBG_G_REGISTER); in gspca_dev_probe2()
1550 if (!gspca_dev->sd_desc->set_register) in gspca_dev_probe2()
1551 v4l2_disable_ioctl(&gspca_dev->vdev, VIDIOC_DBG_S_REGISTER); in gspca_dev_probe2()
1553 if (!gspca_dev->sd_desc->get_jcomp) in gspca_dev_probe2()
1554 v4l2_disable_ioctl(&gspca_dev->vdev, VIDIOC_G_JPEGCOMP); in gspca_dev_probe2()
1555 if (!gspca_dev->sd_desc->set_jcomp) in gspca_dev_probe2()
1556 v4l2_disable_ioctl(&gspca_dev->vdev, VIDIOC_S_JPEGCOMP); in gspca_dev_probe2()
1559 ret = video_register_device(&gspca_dev->vdev, in gspca_dev_probe2()
1567 usb_set_intfdata(intf, gspca_dev); in gspca_dev_probe2()
1568 gspca_dbg(gspca_dev, D_PROBE, "%s created\n", in gspca_dev_probe2()
1569 video_device_node_name(&gspca_dev->vdev)); in gspca_dev_probe2()
1571 gspca_input_create_urb(gspca_dev); in gspca_dev_probe2()
1576 if (gspca_dev->input_dev) in gspca_dev_probe2()
1577 input_unregister_device(gspca_dev->input_dev); in gspca_dev_probe2()
1579 v4l2_ctrl_handler_free(gspca_dev->vdev.ctrl_handler); in gspca_dev_probe2()
1580 v4l2_device_unregister(&gspca_dev->v4l2_dev); in gspca_dev_probe2()
1582 sd_desc->probe_error(gspca_dev); in gspca_dev_probe2()
1583 kfree(gspca_dev->usb_buf); in gspca_dev_probe2()
1584 kfree(gspca_dev); in gspca_dev_probe2()
1622 struct gspca_dev *gspca_dev = usb_get_intfdata(intf); in gspca_disconnect() local
1627 gspca_dbg(gspca_dev, D_PROBE, "%s disconnect\n", in gspca_disconnect()
1628 video_device_node_name(&gspca_dev->vdev)); in gspca_disconnect()
1630 mutex_lock(&gspca_dev->usb_lock); in gspca_disconnect()
1631 gspca_dev->present = false; in gspca_disconnect()
1632 destroy_urbs(gspca_dev); in gspca_disconnect()
1633 gspca_input_destroy_urb(gspca_dev); in gspca_disconnect()
1635 vb2_queue_error(&gspca_dev->queue); in gspca_disconnect()
1638 input_dev = gspca_dev->input_dev; in gspca_disconnect()
1640 gspca_dev->input_dev = NULL; in gspca_disconnect()
1645 v4l2_device_disconnect(&gspca_dev->v4l2_dev); in gspca_disconnect()
1646 video_unregister_device(&gspca_dev->vdev); in gspca_disconnect()
1648 mutex_unlock(&gspca_dev->usb_lock); in gspca_disconnect()
1651 v4l2_device_put(&gspca_dev->v4l2_dev); in gspca_disconnect()
1658 struct gspca_dev *gspca_dev = usb_get_intfdata(intf); in gspca_suspend() local
1660 gspca_input_destroy_urb(gspca_dev); in gspca_suspend()
1662 if (!vb2_start_streaming_called(&gspca_dev->queue)) in gspca_suspend()
1665 mutex_lock(&gspca_dev->usb_lock); in gspca_suspend()
1666 gspca_dev->frozen = 1; /* avoid urb error messages */ in gspca_suspend()
1667 gspca_dev->usb_err = 0; in gspca_suspend()
1668 if (gspca_dev->sd_desc->stopN) in gspca_suspend()
1669 gspca_dev->sd_desc->stopN(gspca_dev); in gspca_suspend()
1670 destroy_urbs(gspca_dev); in gspca_suspend()
1671 gspca_set_alt0(gspca_dev); in gspca_suspend()
1672 if (gspca_dev->sd_desc->stop0) in gspca_suspend()
1673 gspca_dev->sd_desc->stop0(gspca_dev); in gspca_suspend()
1674 mutex_unlock(&gspca_dev->usb_lock); in gspca_suspend()
1682 struct gspca_dev *gspca_dev = usb_get_intfdata(intf); in gspca_resume() local
1685 mutex_lock(&gspca_dev->usb_lock); in gspca_resume()
1686 gspca_dev->frozen = 0; in gspca_resume()
1687 gspca_dev->usb_err = 0; in gspca_resume()
1688 gspca_dev->sd_desc->init(gspca_dev); in gspca_resume()
1694 streaming = vb2_start_streaming_called(&gspca_dev->queue); in gspca_resume()
1696 ret = gspca_init_transfer(gspca_dev); in gspca_resume()
1698 gspca_input_create_urb(gspca_dev); in gspca_resume()
1699 mutex_unlock(&gspca_dev->usb_lock); in gspca_resume()