Lines Matching refs:sur40
238 static void sur40_process_video(struct sur40_state *sur40);
394 struct sur40_state *sur40 = input_get_drvdata(input); in sur40_open() local
396 dev_dbg(sur40->dev, "open\n"); in sur40_open()
397 return sur40_init(sur40); in sur40_open()
403 struct sur40_state *sur40 = input_get_drvdata(input); in sur40_close() local
405 dev_dbg(sur40->dev, "close\n"); in sur40_close()
457 struct sur40_state *sur40 = input_get_drvdata(input); in sur40_poll() local
459 struct sur40_header *header = &sur40->bulk_in_buffer->header; in sur40_poll()
460 struct sur40_blob *inblob = &sur40->bulk_in_buffer->blobs[0]; in sur40_poll()
462 dev_dbg(sur40->dev, "poll\n"); in sur40_poll()
469 result = usb_bulk_msg(sur40->usbdev, in sur40_poll()
470 usb_rcvbulkpipe(sur40->usbdev, sur40->bulk_in_epaddr), in sur40_poll()
471 sur40->bulk_in_buffer, sur40->bulk_in_size, in sur40_poll()
474 dev_dbg(sur40->dev, "received %d bytes\n", bulk_read); in sur40_poll()
477 dev_err(sur40->dev, "error in usb_bulk_read\n"); in sur40_poll()
484 dev_err(sur40->dev, "transfer size mismatch\n"); in sur40_poll()
491 dev_dbg(sur40->dev, "need %d blobs\n", need_blobs); in sur40_poll()
507 dev_dbg(sur40->dev, "received %d blobs\n", packet_blobs); in sur40_poll()
515 dev_dbg(sur40->dev, "processing blob\n"); in sur40_poll()
524 sur40_process_video(sur40); in sur40_poll()
528 static void sur40_process_video(struct sur40_state *sur40) in sur40_process_video() argument
531 struct sur40_image_header *img = (void *)(sur40->bulk_in_buffer); in sur40_process_video()
537 if (!vb2_start_streaming_called(&sur40->queue)) in sur40_process_video()
541 spin_lock(&sur40->qlock); in sur40_process_video()
542 if (list_empty(&sur40->buf_list)) { in sur40_process_video()
543 dev_dbg(sur40->dev, "buffer queue empty\n"); in sur40_process_video()
544 spin_unlock(&sur40->qlock); in sur40_process_video()
547 new_buf = list_entry(sur40->buf_list.next, struct sur40_buffer, list); in sur40_process_video()
549 spin_unlock(&sur40->qlock); in sur40_process_video()
551 dev_dbg(sur40->dev, "buffer acquired\n"); in sur40_process_video()
554 result = usb_bulk_msg(sur40->usbdev, in sur40_process_video()
555 usb_rcvbulkpipe(sur40->usbdev, VIDEO_ENDPOINT), in sur40_process_video()
556 sur40->bulk_in_buffer, sur40->bulk_in_size, in sur40_process_video()
560 dev_err(sur40->dev, "error in usb_bulk_read\n"); in sur40_process_video()
565 dev_err(sur40->dev, "received %d bytes (%zd expected)\n", in sur40_process_video()
571 dev_err(sur40->dev, "image magic mismatch\n"); in sur40_process_video()
575 if (le32_to_cpu(img->size) != sur40->pix_fmt.sizeimage) { in sur40_process_video()
576 dev_err(sur40->dev, "image size mismatch\n"); in sur40_process_video()
580 dev_dbg(sur40->dev, "header acquired\n"); in sur40_process_video()
584 result = usb_sg_init(&sgr, sur40->usbdev, in sur40_process_video()
585 usb_rcvbulkpipe(sur40->usbdev, VIDEO_ENDPOINT), 0, in sur40_process_video()
586 sgt->sgl, sgt->nents, sur40->pix_fmt.sizeimage, 0); in sur40_process_video()
588 dev_err(sur40->dev, "error %d in usb_sg_init\n", result); in sur40_process_video()
594 dev_err(sur40->dev, "error %d in usb_sg_wait\n", sgr.status); in sur40_process_video()
598 dev_dbg(sur40->dev, "image acquired\n"); in sur40_process_video()
601 if (sur40->sequence == -1) in sur40_process_video()
606 new_buf->vb.sequence = sur40->sequence++; in sur40_process_video()
609 dev_dbg(sur40->dev, "buffer marked done\n"); in sur40_process_video()
655 struct sur40_state *sur40; in sur40_probe() local
675 sur40 = kzalloc(sizeof(struct sur40_state), GFP_KERNEL); in sur40_probe()
676 if (!sur40) in sur40_probe()
686 INIT_LIST_HEAD(&sur40->buf_list); in sur40_probe()
687 spin_lock_init(&sur40->qlock); in sur40_probe()
688 mutex_init(&sur40->lock); in sur40_probe()
693 usb_make_path(usbdev, sur40->phys, sizeof(sur40->phys)); in sur40_probe()
694 strlcat(sur40->phys, "/input0", sizeof(sur40->phys)); in sur40_probe()
695 input->phys = sur40->phys; in sur40_probe()
705 input_set_drvdata(input, sur40); in sur40_probe()
714 sur40->usbdev = usbdev; in sur40_probe()
715 sur40->dev = &interface->dev; in sur40_probe()
716 sur40->input = input; in sur40_probe()
719 sur40->bulk_in_size = usb_endpoint_maxp(endpoint); in sur40_probe()
720 sur40->bulk_in_epaddr = endpoint->bEndpointAddress; in sur40_probe()
721 sur40->bulk_in_buffer = kmalloc(sur40->bulk_in_size, GFP_KERNEL); in sur40_probe()
722 if (!sur40->bulk_in_buffer) { in sur40_probe()
737 snprintf(sur40->v4l2.name, sizeof(sur40->v4l2.name), "%s", DRIVER_LONG); in sur40_probe()
738 error = v4l2_device_register(sur40->dev, &sur40->v4l2); in sur40_probe()
746 sur40->queue = sur40_queue; in sur40_probe()
747 sur40->queue.drv_priv = sur40; in sur40_probe()
748 sur40->queue.lock = &sur40->lock; in sur40_probe()
749 sur40->queue.dev = sur40->dev; in sur40_probe()
752 error = vb2_queue_init(&sur40->queue); in sur40_probe()
756 sur40->pix_fmt = sur40_pix_format[0]; in sur40_probe()
757 sur40->vdev = sur40_video_device; in sur40_probe()
758 sur40->vdev.v4l2_dev = &sur40->v4l2; in sur40_probe()
759 sur40->vdev.lock = &sur40->lock; in sur40_probe()
760 sur40->vdev.queue = &sur40->queue; in sur40_probe()
761 video_set_drvdata(&sur40->vdev, sur40); in sur40_probe()
764 v4l2_ctrl_handler_init(&sur40->hdl, 4); in sur40_probe()
765 sur40->v4l2.ctrl_handler = &sur40->hdl; in sur40_probe()
766 sur40->vsvideo = (SUR40_CONTRAST_DEF << 4) | SUR40_GAIN_DEF; in sur40_probe()
768 v4l2_ctrl_new_std(&sur40->hdl, &sur40_ctrl_ops, V4L2_CID_BRIGHTNESS, in sur40_probe()
772 v4l2_ctrl_new_std(&sur40->hdl, &sur40_ctrl_ops, V4L2_CID_CONTRAST, in sur40_probe()
776 v4l2_ctrl_new_std(&sur40->hdl, &sur40_ctrl_ops, V4L2_CID_GAIN, in sur40_probe()
780 v4l2_ctrl_new_std(&sur40->hdl, &sur40_ctrl_ops, in sur40_probe()
784 v4l2_ctrl_handler_setup(&sur40->hdl); in sur40_probe()
786 if (sur40->hdl.error) { in sur40_probe()
789 v4l2_ctrl_handler_free(&sur40->hdl); in sur40_probe()
790 error = sur40->hdl.error; in sur40_probe()
794 error = video_register_device(&sur40->vdev, VFL_TYPE_TOUCH, -1); in sur40_probe()
802 usb_set_intfdata(interface, sur40); in sur40_probe()
808 video_unregister_device(&sur40->vdev); in sur40_probe()
810 v4l2_device_unregister(&sur40->v4l2); in sur40_probe()
812 kfree(sur40->bulk_in_buffer); in sur40_probe()
816 kfree(sur40); in sur40_probe()
824 struct sur40_state *sur40 = usb_get_intfdata(interface); in sur40_disconnect() local
826 v4l2_ctrl_handler_free(&sur40->hdl); in sur40_disconnect()
827 video_unregister_device(&sur40->vdev); in sur40_disconnect()
828 v4l2_device_unregister(&sur40->v4l2); in sur40_disconnect()
830 input_unregister_device(sur40->input); in sur40_disconnect()
831 kfree(sur40->bulk_in_buffer); in sur40_disconnect()
832 kfree(sur40); in sur40_disconnect()
849 struct sur40_state *sur40 = vb2_get_drv_priv(q); in sur40_queue_setup() local
855 return sizes[0] < sur40->pix_fmt.sizeimage ? -EINVAL : 0; in sur40_queue_setup()
858 sizes[0] = sur40->pix_fmt.sizeimage; in sur40_queue_setup()
869 struct sur40_state *sur40 = vb2_get_drv_priv(vb->vb2_queue); in sur40_buffer_prepare() local
870 unsigned long size = sur40->pix_fmt.sizeimage; in sur40_buffer_prepare()
873 dev_err(&sur40->usbdev->dev, "buffer too small (%lu < %lu)\n", in sur40_buffer_prepare()
887 struct sur40_state *sur40 = vb2_get_drv_priv(vb->vb2_queue); in sur40_buffer_queue() local
890 spin_lock(&sur40->qlock); in sur40_buffer_queue()
891 list_add_tail(&buf->list, &sur40->buf_list); in sur40_buffer_queue()
892 spin_unlock(&sur40->qlock); in sur40_buffer_queue()
895 static void return_all_buffers(struct sur40_state *sur40, in return_all_buffers() argument
900 spin_lock(&sur40->qlock); in return_all_buffers()
901 list_for_each_entry_safe(buf, node, &sur40->buf_list, list) { in return_all_buffers()
905 spin_unlock(&sur40->qlock); in return_all_buffers()
916 struct sur40_state *sur40 = vb2_get_drv_priv(vq); in sur40_start_streaming() local
918 sur40->sequence = 0; in sur40_start_streaming()
928 struct sur40_state *sur40 = vb2_get_drv_priv(vq); in sur40_stop_streaming() local
930 sur40->sequence = -1; in sur40_stop_streaming()
933 return_all_buffers(sur40, VB2_BUF_STATE_ERROR); in sur40_stop_streaming()
940 struct sur40_state *sur40 = video_drvdata(file); in sur40_vidioc_querycap() local
944 usb_make_path(sur40->usbdev, cap->bus_info, sizeof(cap->bus_info)); in sur40_vidioc_querycap()
990 struct sur40_state *sur40 = video_drvdata(file); in sur40_vidioc_s_fmt() local
994 sur40->pix_fmt = sur40_pix_format[1]; in sur40_vidioc_s_fmt()
998 sur40->pix_fmt = sur40_pix_format[0]; in sur40_vidioc_s_fmt()
1002 f->fmt.pix = sur40->pix_fmt; in sur40_vidioc_s_fmt()
1009 struct sur40_state *sur40 = video_drvdata(file); in sur40_vidioc_g_fmt() local
1011 f->fmt.pix = sur40->pix_fmt; in sur40_vidioc_g_fmt()
1017 struct sur40_state *sur40 = container_of(ctrl->handler, in sur40_s_ctrl() local
1019 u8 value = sur40->vsvideo; in sur40_s_ctrl()
1023 sur40_set_irlevel(sur40, ctrl->val); in sur40_s_ctrl()
1027 sur40_set_vsvideo(sur40, value); in sur40_s_ctrl()
1031 sur40_set_vsvideo(sur40, value); in sur40_s_ctrl()
1034 sur40_set_preprocessor(sur40, ctrl->val); in sur40_s_ctrl()
1067 struct sur40_state *sur40 = video_drvdata(file); in sur40_vidioc_enum_framesizes() local
1074 f->discrete.width = sur40->pix_fmt.width; in sur40_vidioc_enum_framesizes()
1075 f->discrete.height = sur40->pix_fmt.height; in sur40_vidioc_enum_framesizes()
1082 struct sur40_state *sur40 = video_drvdata(file); in sur40_vidioc_enum_frameintervals() local
1086 || (f->width != sur40->pix_fmt.width) in sur40_vidioc_enum_frameintervals()
1087 || (f->height != sur40->pix_fmt.height)) in sur40_vidioc_enum_frameintervals()