Lines Matching refs:usbtv

63 static int usbtv_configure_for_norm(struct usbtv *usbtv, v4l2_std_id norm)  in usbtv_configure_for_norm()  argument
76 usbtv->width = params->cap_width; in usbtv_configure_for_norm()
77 usbtv->height = params->cap_height; in usbtv_configure_for_norm()
78 usbtv->n_chunks = usbtv->width * usbtv->height in usbtv_configure_for_norm()
80 usbtv->norm = norm; in usbtv_configure_for_norm()
87 static int usbtv_select_input(struct usbtv *usbtv, int input) in usbtv_select_input() argument
109 ret = usbtv_set_regs(usbtv, composite, ARRAY_SIZE(composite)); in usbtv_select_input()
112 ret = usbtv_set_regs(usbtv, svideo, ARRAY_SIZE(svideo)); in usbtv_select_input()
119 usbtv->input = input; in usbtv_select_input()
145 static int usbtv_select_norm(struct usbtv *usbtv, v4l2_std_id norm) in usbtv_select_norm() argument
239 ret = usbtv_configure_for_norm(usbtv, norm); in usbtv_select_norm()
250 ret = usbtv_set_regs(usbtv, ntsc, ARRAY_SIZE(ntsc)); in usbtv_select_norm()
252 ret = usbtv_set_regs(usbtv, pal, ARRAY_SIZE(pal)); in usbtv_select_norm()
254 ret = usbtv_set_regs(usbtv, secam, ARRAY_SIZE(secam)); in usbtv_select_norm()
264 ret = usbtv_set_regs(usbtv, cfg, ARRAY_SIZE(cfg)); in usbtv_select_norm()
270 static int usbtv_setup_capture(struct usbtv *usbtv) in usbtv_setup_capture() argument
336 ret = usbtv_set_regs(usbtv, setup, ARRAY_SIZE(setup)); in usbtv_setup_capture()
340 ret = usbtv_select_norm(usbtv, usbtv->norm); in usbtv_setup_capture()
344 ret = usbtv_select_input(usbtv, usbtv->input); in usbtv_setup_capture()
348 ret = v4l2_ctrl_handler_setup(&usbtv->ctrl); in usbtv_setup_capture()
394 static void usbtv_image_chunk(struct usbtv *usbtv, __be32 *chunk) in usbtv_image_chunk() argument
407 if (chunk_no >= usbtv->n_chunks) in usbtv_image_chunk()
412 usbtv->frame_id = frame_id; in usbtv_image_chunk()
413 usbtv->chunks_done = 0; in usbtv_image_chunk()
416 if (usbtv->frame_id != frame_id) in usbtv_image_chunk()
419 spin_lock_irqsave(&usbtv->buflock, flags); in usbtv_image_chunk()
420 if (list_empty(&usbtv->bufs)) { in usbtv_image_chunk()
422 spin_unlock_irqrestore(&usbtv->buflock, flags); in usbtv_image_chunk()
427 buf = list_first_entry(&usbtv->bufs, struct usbtv_buf, list); in usbtv_image_chunk()
432 usbtv->chunks_done++; in usbtv_image_chunk()
435 if (chunk_no == usbtv->n_chunks-1) { in usbtv_image_chunk()
437 if (odd && !usbtv->last_odd) { in usbtv_image_chunk()
439 enum vb2_buffer_state state = usbtv->chunks_done == in usbtv_image_chunk()
440 usbtv->n_chunks ? in usbtv_image_chunk()
445 buf->vb.sequence = usbtv->sequence++; in usbtv_image_chunk()
451 usbtv->last_odd = odd; in usbtv_image_chunk()
454 spin_unlock_irqrestore(&usbtv->buflock, flags); in usbtv_image_chunk()
463 struct usbtv *usbtv = (struct usbtv *)ip->context; in usbtv_iso_cb() local
477 dev_warn(usbtv->dev, "Bad response for ISO request.\n"); in usbtv_iso_cb()
488 usbtv_image_chunk(usbtv, in usbtv_iso_cb()
495 dev_warn(usbtv->dev, "Could not resubmit ISO URB\n"); in usbtv_iso_cb()
498 static struct urb *usbtv_setup_iso_transfer(struct usbtv *usbtv) in usbtv_setup_iso_transfer() argument
501 int size = usbtv->iso_size; in usbtv_setup_iso_transfer()
508 ip->dev = usbtv->udev; in usbtv_setup_iso_transfer()
509 ip->context = usbtv; in usbtv_setup_iso_transfer()
510 ip->pipe = usb_rcvisocpipe(usbtv->udev, USBTV_VIDEO_ENDP); in usbtv_setup_iso_transfer()
530 static void usbtv_stop(struct usbtv *usbtv) in usbtv_stop() argument
537 struct urb *ip = usbtv->isoc_urbs[i]; in usbtv_stop()
544 usbtv->isoc_urbs[i] = NULL; in usbtv_stop()
548 spin_lock_irqsave(&usbtv->buflock, flags); in usbtv_stop()
549 while (!list_empty(&usbtv->bufs)) { in usbtv_stop()
550 struct usbtv_buf *buf = list_first_entry(&usbtv->bufs, in usbtv_stop()
555 spin_unlock_irqrestore(&usbtv->buflock, flags); in usbtv_stop()
558 static int usbtv_start(struct usbtv *usbtv) in usbtv_start() argument
563 usbtv_audio_suspend(usbtv); in usbtv_start()
565 ret = usb_set_interface(usbtv->udev, 0, 0); in usbtv_start()
569 ret = usbtv_setup_capture(usbtv); in usbtv_start()
573 ret = usb_set_interface(usbtv->udev, 0, 1); in usbtv_start()
577 usbtv_audio_resume(usbtv); in usbtv_start()
582 ip = usbtv_setup_iso_transfer(usbtv); in usbtv_start()
587 usbtv->isoc_urbs[i] = ip; in usbtv_start()
597 usbtv_stop(usbtv); in usbtv_start()
604 struct usbtv *dev = video_drvdata(file); in usbtv_querycap()
615 struct usbtv *dev = video_drvdata(file); in usbtv_enum_input()
646 struct usbtv *usbtv = video_drvdata(file); in usbtv_fmt_vid_cap() local
648 f->fmt.pix.width = usbtv->width; in usbtv_fmt_vid_cap()
649 f->fmt.pix.height = usbtv->height; in usbtv_fmt_vid_cap()
652 f->fmt.pix.bytesperline = usbtv->width * 2; in usbtv_fmt_vid_cap()
661 struct usbtv *usbtv = video_drvdata(file); in usbtv_g_std() local
662 *norm = usbtv->norm; in usbtv_g_std()
669 struct usbtv *usbtv = video_drvdata(file); in usbtv_s_std() local
672 ret = usbtv_select_norm(usbtv, norm); in usbtv_s_std()
679 struct usbtv *usbtv = video_drvdata(file); in usbtv_g_input() local
680 *i = usbtv->input; in usbtv_g_input()
686 struct usbtv *usbtv = video_drvdata(file); in usbtv_s_input() local
688 return usbtv_select_input(usbtv, i); in usbtv_s_input()
727 struct usbtv *usbtv = vb2_get_drv_priv(vq); in usbtv_queue_setup() local
728 unsigned size = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32); in usbtv_queue_setup()
744 struct usbtv *usbtv = vb2_get_drv_priv(vb->vb2_queue); in usbtv_buf_queue() local
748 if (usbtv->udev == NULL) { in usbtv_buf_queue()
753 spin_lock_irqsave(&usbtv->buflock, flags); in usbtv_buf_queue()
754 list_add_tail(&buf->list, &usbtv->bufs); in usbtv_buf_queue()
755 spin_unlock_irqrestore(&usbtv->buflock, flags); in usbtv_buf_queue()
760 struct usbtv *usbtv = vb2_get_drv_priv(vq); in usbtv_start_streaming() local
762 if (usbtv->udev == NULL) in usbtv_start_streaming()
765 usbtv->last_odd = 1; in usbtv_start_streaming()
766 usbtv->sequence = 0; in usbtv_start_streaming()
767 return usbtv_start(usbtv); in usbtv_start_streaming()
772 struct usbtv *usbtv = vb2_get_drv_priv(vq); in usbtv_stop_streaming() local
774 if (usbtv->udev) in usbtv_stop_streaming()
775 usbtv_stop(usbtv); in usbtv_stop_streaming()
789 struct usbtv *usbtv = container_of(ctrl->handler, struct usbtv, in usbtv_s_ctrl() local
804 ret = usb_control_msg(usbtv->udev, in usbtv_s_ctrl()
805 usb_rcvctrlpipe(usbtv->udev, 0), USBTV_CONTROL_REG, in usbtv_s_ctrl()
856 ret = usb_control_msg(usbtv->udev, usb_sndctrlpipe(usbtv->udev, 0), in usbtv_s_ctrl()
863 dev_warn(usbtv->dev, "Failed to submit a control request.\n"); in usbtv_s_ctrl()
875 struct usbtv *usbtv = container_of(v4l2_dev, struct usbtv, v4l2_dev); in usbtv_release() local
877 v4l2_device_unregister(&usbtv->v4l2_dev); in usbtv_release()
878 v4l2_ctrl_handler_free(&usbtv->ctrl); in usbtv_release()
879 kfree(usbtv); in usbtv_release()
882 int usbtv_video_init(struct usbtv *usbtv) in usbtv_video_init() argument
886 (void)usbtv_configure_for_norm(usbtv, V4L2_STD_525_60); in usbtv_video_init()
888 spin_lock_init(&usbtv->buflock); in usbtv_video_init()
889 mutex_init(&usbtv->v4l2_lock); in usbtv_video_init()
890 mutex_init(&usbtv->vb2q_lock); in usbtv_video_init()
891 INIT_LIST_HEAD(&usbtv->bufs); in usbtv_video_init()
894 usbtv->vb2q.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in usbtv_video_init()
895 usbtv->vb2q.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; in usbtv_video_init()
896 usbtv->vb2q.drv_priv = usbtv; in usbtv_video_init()
897 usbtv->vb2q.buf_struct_size = sizeof(struct usbtv_buf); in usbtv_video_init()
898 usbtv->vb2q.ops = &usbtv_vb2_ops; in usbtv_video_init()
899 usbtv->vb2q.mem_ops = &vb2_vmalloc_memops; in usbtv_video_init()
900 usbtv->vb2q.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in usbtv_video_init()
901 usbtv->vb2q.lock = &usbtv->vb2q_lock; in usbtv_video_init()
902 ret = vb2_queue_init(&usbtv->vb2q); in usbtv_video_init()
904 dev_warn(usbtv->dev, "Could not initialize videobuf2 queue\n"); in usbtv_video_init()
909 v4l2_ctrl_handler_init(&usbtv->ctrl, 4); in usbtv_video_init()
910 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops, in usbtv_video_init()
912 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops, in usbtv_video_init()
914 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops, in usbtv_video_init()
916 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops, in usbtv_video_init()
918 v4l2_ctrl_new_std(&usbtv->ctrl, &usbtv_ctrl_ops, in usbtv_video_init()
920 ret = usbtv->ctrl.error; in usbtv_video_init()
922 dev_warn(usbtv->dev, "Could not initialize controls\n"); in usbtv_video_init()
927 usbtv->v4l2_dev.ctrl_handler = &usbtv->ctrl; in usbtv_video_init()
928 usbtv->v4l2_dev.release = usbtv_release; in usbtv_video_init()
929 ret = v4l2_device_register(usbtv->dev, &usbtv->v4l2_dev); in usbtv_video_init()
931 dev_warn(usbtv->dev, "Could not register v4l2 device\n"); in usbtv_video_init()
936 strscpy(usbtv->vdev.name, "usbtv", sizeof(usbtv->vdev.name)); in usbtv_video_init()
937 usbtv->vdev.v4l2_dev = &usbtv->v4l2_dev; in usbtv_video_init()
938 usbtv->vdev.release = video_device_release_empty; in usbtv_video_init()
939 usbtv->vdev.fops = &usbtv_fops; in usbtv_video_init()
940 usbtv->vdev.ioctl_ops = &usbtv_ioctl_ops; in usbtv_video_init()
941 usbtv->vdev.tvnorms = USBTV_TV_STD; in usbtv_video_init()
942 usbtv->vdev.queue = &usbtv->vb2q; in usbtv_video_init()
943 usbtv->vdev.lock = &usbtv->v4l2_lock; in usbtv_video_init()
944 usbtv->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE | in usbtv_video_init()
946 video_set_drvdata(&usbtv->vdev, usbtv); in usbtv_video_init()
947 ret = video_register_device(&usbtv->vdev, VFL_TYPE_VIDEO, -1); in usbtv_video_init()
949 dev_warn(usbtv->dev, "Could not register video device\n"); in usbtv_video_init()
956 v4l2_device_unregister(&usbtv->v4l2_dev); in usbtv_video_init()
959 v4l2_ctrl_handler_free(&usbtv->ctrl); in usbtv_video_init()
964 void usbtv_video_free(struct usbtv *usbtv) in usbtv_video_free() argument
966 vb2_video_unregister_device(&usbtv->vdev); in usbtv_video_free()
967 v4l2_device_disconnect(&usbtv->v4l2_dev); in usbtv_video_free()
969 v4l2_device_put(&usbtv->v4l2_dev); in usbtv_video_free()