Lines Matching refs:sur40
242 static void sur40_process_video(struct sur40_state *sur40);
394 struct sur40_state *sur40 = polldev->private; in sur40_open() local
396 dev_dbg(sur40->dev, "open\n"); in sur40_open()
397 sur40_init(sur40); in sur40_open()
403 struct sur40_state *sur40 = polldev->private; in sur40_close() local
405 dev_dbg(sur40->dev, "close\n"); in sur40_close()
457 struct sur40_state *sur40 = polldev->private; in sur40_poll() local
462 struct sur40_header *header = &sur40->bulk_in_buffer->header; in sur40_poll()
463 struct sur40_blob *inblob = &sur40->bulk_in_buffer->blobs[0]; in sur40_poll()
465 dev_dbg(sur40->dev, "poll\n"); in sur40_poll()
472 result = usb_bulk_msg(sur40->usbdev, in sur40_poll()
473 usb_rcvbulkpipe(sur40->usbdev, sur40->bulk_in_epaddr), in sur40_poll()
474 sur40->bulk_in_buffer, sur40->bulk_in_size, in sur40_poll()
477 dev_dbg(sur40->dev, "received %d bytes\n", bulk_read); in sur40_poll()
480 dev_err(sur40->dev, "error in usb_bulk_read\n"); in sur40_poll()
487 dev_err(sur40->dev, "transfer size mismatch\n"); in sur40_poll()
494 dev_dbg(sur40->dev, "need %d blobs\n", need_blobs); in sur40_poll()
510 dev_dbg(sur40->dev, "received %d blobs\n", packet_blobs); in sur40_poll()
518 dev_dbg(sur40->dev, "processing blob\n"); in sur40_poll()
527 sur40_process_video(sur40); in sur40_poll()
531 static void sur40_process_video(struct sur40_state *sur40) in sur40_process_video() argument
534 struct sur40_image_header *img = (void *)(sur40->bulk_in_buffer); in sur40_process_video()
540 if (!vb2_start_streaming_called(&sur40->queue)) in sur40_process_video()
544 spin_lock(&sur40->qlock); in sur40_process_video()
545 if (list_empty(&sur40->buf_list)) { in sur40_process_video()
546 dev_dbg(sur40->dev, "buffer queue empty\n"); in sur40_process_video()
547 spin_unlock(&sur40->qlock); in sur40_process_video()
550 new_buf = list_entry(sur40->buf_list.next, struct sur40_buffer, list); in sur40_process_video()
552 spin_unlock(&sur40->qlock); in sur40_process_video()
554 dev_dbg(sur40->dev, "buffer acquired\n"); in sur40_process_video()
557 result = usb_bulk_msg(sur40->usbdev, in sur40_process_video()
558 usb_rcvbulkpipe(sur40->usbdev, VIDEO_ENDPOINT), in sur40_process_video()
559 sur40->bulk_in_buffer, sur40->bulk_in_size, in sur40_process_video()
563 dev_err(sur40->dev, "error in usb_bulk_read\n"); in sur40_process_video()
568 dev_err(sur40->dev, "received %d bytes (%zd expected)\n", in sur40_process_video()
574 dev_err(sur40->dev, "image magic mismatch\n"); in sur40_process_video()
578 if (le32_to_cpu(img->size) != sur40->pix_fmt.sizeimage) { in sur40_process_video()
579 dev_err(sur40->dev, "image size mismatch\n"); in sur40_process_video()
583 dev_dbg(sur40->dev, "header acquired\n"); in sur40_process_video()
587 result = usb_sg_init(&sgr, sur40->usbdev, in sur40_process_video()
588 usb_rcvbulkpipe(sur40->usbdev, VIDEO_ENDPOINT), 0, in sur40_process_video()
589 sgt->sgl, sgt->nents, sur40->pix_fmt.sizeimage, 0); in sur40_process_video()
591 dev_err(sur40->dev, "error %d in usb_sg_init\n", result); in sur40_process_video()
597 dev_err(sur40->dev, "error %d in usb_sg_wait\n", sgr.status); in sur40_process_video()
601 dev_dbg(sur40->dev, "image acquired\n"); in sur40_process_video()
604 if (sur40->sequence == -1) in sur40_process_video()
609 new_buf->vb.sequence = sur40->sequence++; in sur40_process_video()
612 dev_dbg(sur40->dev, "buffer marked done\n"); in sur40_process_video()
653 struct sur40_state *sur40; in sur40_probe() local
673 sur40 = kzalloc(sizeof(struct sur40_state), GFP_KERNEL); in sur40_probe()
674 if (!sur40) in sur40_probe()
684 INIT_LIST_HEAD(&sur40->buf_list); in sur40_probe()
685 spin_lock_init(&sur40->qlock); in sur40_probe()
686 mutex_init(&sur40->lock); in sur40_probe()
689 poll_dev->private = sur40; in sur40_probe()
700 usb_make_path(usbdev, sur40->phys, sizeof(sur40->phys)); in sur40_probe()
701 strlcat(sur40->phys, "/input0", sizeof(sur40->phys)); in sur40_probe()
702 poll_dev->input->phys = sur40->phys; in sur40_probe()
705 sur40->usbdev = usbdev; in sur40_probe()
706 sur40->dev = &interface->dev; in sur40_probe()
707 sur40->input = poll_dev; in sur40_probe()
710 sur40->bulk_in_size = usb_endpoint_maxp(endpoint); in sur40_probe()
711 sur40->bulk_in_epaddr = endpoint->bEndpointAddress; in sur40_probe()
712 sur40->bulk_in_buffer = kmalloc(sur40->bulk_in_size, GFP_KERNEL); in sur40_probe()
713 if (!sur40->bulk_in_buffer) { in sur40_probe()
728 snprintf(sur40->v4l2.name, sizeof(sur40->v4l2.name), "%s", DRIVER_LONG); in sur40_probe()
729 error = v4l2_device_register(sur40->dev, &sur40->v4l2); in sur40_probe()
737 sur40->queue = sur40_queue; in sur40_probe()
738 sur40->queue.drv_priv = sur40; in sur40_probe()
739 sur40->queue.lock = &sur40->lock; in sur40_probe()
740 sur40->queue.dev = sur40->dev; in sur40_probe()
743 error = vb2_queue_init(&sur40->queue); in sur40_probe()
747 sur40->pix_fmt = sur40_pix_format[0]; in sur40_probe()
748 sur40->vdev = sur40_video_device; in sur40_probe()
749 sur40->vdev.v4l2_dev = &sur40->v4l2; in sur40_probe()
750 sur40->vdev.lock = &sur40->lock; in sur40_probe()
751 sur40->vdev.queue = &sur40->queue; in sur40_probe()
752 video_set_drvdata(&sur40->vdev, sur40); in sur40_probe()
755 v4l2_ctrl_handler_init(&sur40->hdl, 4); in sur40_probe()
756 sur40->v4l2.ctrl_handler = &sur40->hdl; in sur40_probe()
757 sur40->vsvideo = (SUR40_CONTRAST_DEF << 4) | SUR40_GAIN_DEF; in sur40_probe()
759 v4l2_ctrl_new_std(&sur40->hdl, &sur40_ctrl_ops, V4L2_CID_BRIGHTNESS, in sur40_probe()
763 v4l2_ctrl_new_std(&sur40->hdl, &sur40_ctrl_ops, V4L2_CID_CONTRAST, in sur40_probe()
767 v4l2_ctrl_new_std(&sur40->hdl, &sur40_ctrl_ops, V4L2_CID_GAIN, in sur40_probe()
771 v4l2_ctrl_new_std(&sur40->hdl, &sur40_ctrl_ops, in sur40_probe()
775 v4l2_ctrl_handler_setup(&sur40->hdl); in sur40_probe()
777 if (sur40->hdl.error) { in sur40_probe()
780 v4l2_ctrl_handler_free(&sur40->hdl); in sur40_probe()
784 error = video_register_device(&sur40->vdev, VFL_TYPE_TOUCH, -1); in sur40_probe()
792 usb_set_intfdata(interface, sur40); in sur40_probe()
798 video_unregister_device(&sur40->vdev); in sur40_probe()
800 v4l2_device_unregister(&sur40->v4l2); in sur40_probe()
802 kfree(sur40->bulk_in_buffer); in sur40_probe()
804 input_free_polled_device(sur40->input); in sur40_probe()
806 kfree(sur40); in sur40_probe()
814 struct sur40_state *sur40 = usb_get_intfdata(interface); in sur40_disconnect() local
816 v4l2_ctrl_handler_free(&sur40->hdl); in sur40_disconnect()
817 video_unregister_device(&sur40->vdev); in sur40_disconnect()
818 v4l2_device_unregister(&sur40->v4l2); in sur40_disconnect()
820 input_unregister_polled_device(sur40->input); in sur40_disconnect()
821 input_free_polled_device(sur40->input); in sur40_disconnect()
822 kfree(sur40->bulk_in_buffer); in sur40_disconnect()
823 kfree(sur40); in sur40_disconnect()
840 struct sur40_state *sur40 = vb2_get_drv_priv(q); in sur40_queue_setup() local
846 return sizes[0] < sur40->pix_fmt.sizeimage ? -EINVAL : 0; in sur40_queue_setup()
849 sizes[0] = sur40->pix_fmt.sizeimage; in sur40_queue_setup()
860 struct sur40_state *sur40 = vb2_get_drv_priv(vb->vb2_queue); in sur40_buffer_prepare() local
861 unsigned long size = sur40->pix_fmt.sizeimage; in sur40_buffer_prepare()
864 dev_err(&sur40->usbdev->dev, "buffer too small (%lu < %lu)\n", in sur40_buffer_prepare()
878 struct sur40_state *sur40 = vb2_get_drv_priv(vb->vb2_queue); in sur40_buffer_queue() local
881 spin_lock(&sur40->qlock); in sur40_buffer_queue()
882 list_add_tail(&buf->list, &sur40->buf_list); in sur40_buffer_queue()
883 spin_unlock(&sur40->qlock); in sur40_buffer_queue()
886 static void return_all_buffers(struct sur40_state *sur40, in return_all_buffers() argument
891 spin_lock(&sur40->qlock); in return_all_buffers()
892 list_for_each_entry_safe(buf, node, &sur40->buf_list, list) { in return_all_buffers()
896 spin_unlock(&sur40->qlock); in return_all_buffers()
907 struct sur40_state *sur40 = vb2_get_drv_priv(vq); in sur40_start_streaming() local
909 sur40->sequence = 0; in sur40_start_streaming()
919 struct sur40_state *sur40 = vb2_get_drv_priv(vq); in sur40_stop_streaming() local
921 sur40->sequence = -1; in sur40_stop_streaming()
924 return_all_buffers(sur40, VB2_BUF_STATE_ERROR); in sur40_stop_streaming()
931 struct sur40_state *sur40 = video_drvdata(file); in sur40_vidioc_querycap() local
935 usb_make_path(sur40->usbdev, cap->bus_info, sizeof(cap->bus_info)); in sur40_vidioc_querycap()
985 struct sur40_state *sur40 = video_drvdata(file); in sur40_vidioc_s_fmt() local
989 sur40->pix_fmt = sur40_pix_format[1]; in sur40_vidioc_s_fmt()
993 sur40->pix_fmt = sur40_pix_format[0]; in sur40_vidioc_s_fmt()
997 f->fmt.pix = sur40->pix_fmt; in sur40_vidioc_s_fmt()
1004 struct sur40_state *sur40 = video_drvdata(file); in sur40_vidioc_g_fmt() local
1006 f->fmt.pix = sur40->pix_fmt; in sur40_vidioc_g_fmt()
1012 struct sur40_state *sur40 = container_of(ctrl->handler, in sur40_s_ctrl() local
1014 u8 value = sur40->vsvideo; in sur40_s_ctrl()
1018 sur40_set_irlevel(sur40, ctrl->val); in sur40_s_ctrl()
1022 sur40_set_vsvideo(sur40, value); in sur40_s_ctrl()
1026 sur40_set_vsvideo(sur40, value); in sur40_s_ctrl()
1029 sur40_set_preprocessor(sur40, ctrl->val); in sur40_s_ctrl()
1062 struct sur40_state *sur40 = video_drvdata(file); in sur40_vidioc_enum_framesizes() local
1069 f->discrete.width = sur40->pix_fmt.width; in sur40_vidioc_enum_framesizes()
1070 f->discrete.height = sur40->pix_fmt.height; in sur40_vidioc_enum_framesizes()
1077 struct sur40_state *sur40 = video_drvdata(file); in sur40_vidioc_enum_frameintervals() local
1081 || (f->width != sur40->pix_fmt.width) in sur40_vidioc_enum_frameintervals()
1082 || (f->height != sur40->pix_fmt.height)) in sur40_vidioc_enum_frameintervals()