Lines Matching refs:cam
129 struct zr364xx_camera *cam; member
137 void *cam; /* back pointer to zr364xx_camera struct */ member
343 struct zr364xx_camera *cam = vq->priv_data; in buffer_setup() local
345 *size = cam->width * cam->height * (cam->fmt->depth >> 3); in buffer_setup()
367 struct zr364xx_camera *cam = vq->priv_data; in buffer_prepare() local
373 if (!cam->fmt) in buffer_prepare()
376 buf->vb.size = cam->width * cam->height * (cam->fmt->depth >> 3); in buffer_prepare()
383 buf->fmt = cam->fmt; in buffer_prepare()
384 buf->vb.width = cam->width; in buffer_prepare()
385 buf->vb.height = cam->height; in buffer_prepare()
405 struct zr364xx_camera *cam = vq->priv_data; in buffer_queue() local
410 list_add_tail(&buf->vb.queue, &cam->vidq.active); in buffer_queue()
439 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_read() local
450 if (mutex_lock_interruptible(&cam->lock)) in zr364xx_read()
460 err = videobuf_read_one(&cam->vb_vidq, buf, count, ppos, in zr364xx_read()
463 mutex_unlock(&cam->lock); in zr364xx_read()
475 static void zr364xx_fillbuff(struct zr364xx_camera *cam, in zr364xx_fillbuff() argument
487 last_frame = cam->last_frame; in zr364xx_fillbuff()
489 tmpbuf = (const char *)cam->buffer.frame[last_frame].lpvbits; in zr364xx_fillbuff()
498 cam->last_frame = -1; in zr364xx_fillbuff()
506 buf->vb.field_count = cam->frame_count * 2; in zr364xx_fillbuff()
511 static int zr364xx_got_frame(struct zr364xx_camera *cam, int jpgsize) in zr364xx_got_frame() argument
513 struct zr364xx_dmaqueue *dma_q = &cam->vidq; in zr364xx_got_frame()
519 spin_lock_irqsave(&cam->slock, flags); in zr364xx_got_frame()
537 zr364xx_fillbuff(cam, buf, jpgsize); in zr364xx_got_frame()
541 spin_unlock_irqrestore(&cam->slock, flags); in zr364xx_got_frame()
550 static int zr364xx_read_video_callback(struct zr364xx_camera *cam, in zr364xx_read_video_callback() argument
556 s32 idx = cam->cur_frame; in zr364xx_read_video_callback()
557 struct zr364xx_framei *frm = &cam->buffer.frame[idx]; in zr364xx_read_video_callback()
564 if (cam->method == METHOD0) { in zr364xx_read_video_callback()
571 if (!cam->b_acquire) { in zr364xx_read_video_callback()
583 dev_info(&cam->udev->dev, in zr364xx_read_video_callback()
617 dev_info(&cam->udev->dev, in zr364xx_read_video_callback()
631 cam->last_frame = cam->cur_frame; in zr364xx_read_video_callback()
632 cam->cur_frame++; in zr364xx_read_video_callback()
634 if (cam->cur_frame == cam->buffer.dwFrames) in zr364xx_read_video_callback()
635 cam->cur_frame = 0; in zr364xx_read_video_callback()
659 DBG("Bogus frame ? %d\n", ++(cam->nb)); in zr364xx_read_video_callback()
660 } else if (cam->b_acquire) { in zr364xx_read_video_callback()
662 if (cam->skip) in zr364xx_read_video_callback()
663 cam->skip--; in zr364xx_read_video_callback()
670 zr364xx_got_frame(cam, frm->cur_size); in zr364xx_read_video_callback()
673 cam->frame_count++; in zr364xx_read_video_callback()
684 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_vidioc_querycap() local
687 if (cam->udev->product) in zr364xx_vidioc_querycap()
688 strscpy(cap->card, cam->udev->product, sizeof(cap->card)); in zr364xx_vidioc_querycap()
689 strscpy(cap->bus_info, dev_name(&cam->udev->dev), in zr364xx_vidioc_querycap()
721 struct zr364xx_camera *cam = in zr364xx_s_ctrl() local
728 send_control_msg(cam->udev, 1, 0x2001, 0, NULL, 0); in zr364xx_s_ctrl()
730 send_control_msg(cam->udev, 1, temp, 0, NULL, 0); in zr364xx_s_ctrl()
761 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_vidioc_try_fmt_vid_cap() local
764 if (!cam) in zr364xx_vidioc_try_fmt_vid_cap()
792 struct zr364xx_camera *cam; in zr364xx_vidioc_g_fmt_vid_cap() local
796 cam = video_drvdata(file); in zr364xx_vidioc_g_fmt_vid_cap()
800 f->fmt.pix.width = cam->width; in zr364xx_vidioc_g_fmt_vid_cap()
801 f->fmt.pix.height = cam->height; in zr364xx_vidioc_g_fmt_vid_cap()
811 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_vidioc_s_fmt_vid_cap() local
812 struct videobuf_queue *q = &cam->vb_vidq; in zr364xx_vidioc_s_fmt_vid_cap()
814 int ret = zr364xx_vidioc_try_fmt_vid_cap(file, cam, f); in zr364xx_vidioc_s_fmt_vid_cap()
822 if (videobuf_queue_is_busy(&cam->vb_vidq)) { in zr364xx_vidioc_s_fmt_vid_cap()
828 if (cam->owner) { in zr364xx_vidioc_s_fmt_vid_cap()
834 cam->width = f->fmt.pix.width; in zr364xx_vidioc_s_fmt_vid_cap()
835 cam->height = f->fmt.pix.height; in zr364xx_vidioc_s_fmt_vid_cap()
837 cam->width, cam->height); in zr364xx_vidioc_s_fmt_vid_cap()
841 cam->vb_vidq.field = f->fmt.pix.field; in zr364xx_vidioc_s_fmt_vid_cap()
855 if (cam->method == METHOD3) { in zr364xx_vidioc_s_fmt_vid_cap()
869 header2[437] = cam->height / 256; in zr364xx_vidioc_s_fmt_vid_cap()
870 header2[438] = cam->height % 256; in zr364xx_vidioc_s_fmt_vid_cap()
871 header2[439] = cam->width / 256; in zr364xx_vidioc_s_fmt_vid_cap()
872 header2[440] = cam->width % 256; in zr364xx_vidioc_s_fmt_vid_cap()
874 for (i = 0; init[cam->method][i].size != -1; i++) { in zr364xx_vidioc_s_fmt_vid_cap()
876 send_control_msg(cam->udev, 1, init[cam->method][i].value, in zr364xx_vidioc_s_fmt_vid_cap()
877 0, init[cam->method][i].bytes, in zr364xx_vidioc_s_fmt_vid_cap()
878 init[cam->method][i].size); in zr364xx_vidioc_s_fmt_vid_cap()
880 dev_err(&cam->udev->dev, in zr364xx_vidioc_s_fmt_vid_cap()
890 cam->skip = 2; in zr364xx_vidioc_s_fmt_vid_cap()
905 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_vidioc_reqbufs() local
907 if (cam->owner && cam->owner != priv) in zr364xx_vidioc_reqbufs()
909 return videobuf_reqbufs(&cam->vb_vidq, p); in zr364xx_vidioc_reqbufs()
917 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_vidioc_querybuf() local
918 rc = videobuf_querybuf(&cam->vb_vidq, p); in zr364xx_vidioc_querybuf()
927 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_vidioc_qbuf() local
929 if (cam->owner && cam->owner != priv) in zr364xx_vidioc_qbuf()
931 rc = videobuf_qbuf(&cam->vb_vidq, p); in zr364xx_vidioc_qbuf()
940 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_vidioc_dqbuf() local
942 if (cam->owner && cam->owner != priv) in zr364xx_vidioc_dqbuf()
944 rc = videobuf_dqbuf(&cam->vb_vidq, p, file->f_flags & O_NONBLOCK); in zr364xx_vidioc_dqbuf()
951 struct zr364xx_camera *cam; in read_pipe_completion() local
961 cam = pipe_info->cam; in read_pipe_completion()
962 if (!cam) { in read_pipe_completion()
980 dev_err(&cam->udev->dev, "wrong number of bytes\n"); in read_pipe_completion()
985 zr364xx_read_video_callback(cam, pipe_info, purb); in read_pipe_completion()
991 pipe = usb_rcvbulkpipe(cam->udev, cam->read_endpoint); in read_pipe_completion()
994 usb_fill_bulk_urb(pipe_info->stream_urb, cam->udev, in read_pipe_completion()
1005 dev_err(&cam->udev->dev, in read_pipe_completion()
1012 static int zr364xx_start_readpipe(struct zr364xx_camera *cam) in zr364xx_start_readpipe() argument
1016 struct zr364xx_pipeinfo *pipe_info = cam->pipe; in zr364xx_start_readpipe()
1017 pipe = usb_rcvbulkpipe(cam->udev, cam->read_endpoint); in zr364xx_start_readpipe()
1018 DBG("%s: start pipe IN x%x\n", __func__, cam->read_endpoint); in zr364xx_start_readpipe()
1026 usb_fill_bulk_urb(pipe_info->stream_urb, cam->udev, in zr364xx_start_readpipe()
1043 static void zr364xx_stop_readpipe(struct zr364xx_camera *cam) in zr364xx_stop_readpipe() argument
1047 if (!cam) { in zr364xx_stop_readpipe()
1052 pipe_info = cam->pipe; in zr364xx_stop_readpipe()
1068 static int zr364xx_start_acquire(struct zr364xx_camera *cam) in zr364xx_start_acquire() argument
1074 cam->last_frame = -1; in zr364xx_start_acquire()
1075 cam->cur_frame = 0; in zr364xx_start_acquire()
1077 cam->buffer.frame[j].ulState = ZR364XX_READ_IDLE; in zr364xx_start_acquire()
1078 cam->buffer.frame[j].cur_size = 0; in zr364xx_start_acquire()
1080 cam->b_acquire = 1; in zr364xx_start_acquire()
1084 static inline int zr364xx_stop_acquire(struct zr364xx_camera *cam) in zr364xx_stop_acquire() argument
1086 cam->b_acquire = 0; in zr364xx_stop_acquire()
1090 static int zr364xx_prepare(struct zr364xx_camera *cam) in zr364xx_prepare() argument
1095 for (i = 0; init[cam->method][i].size != -1; i++) { in zr364xx_prepare()
1096 res = send_control_msg(cam->udev, 1, init[cam->method][i].value, in zr364xx_prepare()
1097 0, init[cam->method][i].bytes, in zr364xx_prepare()
1098 init[cam->method][i].size); in zr364xx_prepare()
1100 dev_err(&cam->udev->dev, in zr364xx_prepare()
1106 cam->skip = 2; in zr364xx_prepare()
1107 cam->last_frame = -1; in zr364xx_prepare()
1108 cam->cur_frame = 0; in zr364xx_prepare()
1109 cam->frame_count = 0; in zr364xx_prepare()
1111 cam->buffer.frame[j].ulState = ZR364XX_READ_IDLE; in zr364xx_prepare()
1112 cam->buffer.frame[j].cur_size = 0; in zr364xx_prepare()
1114 v4l2_ctrl_handler_setup(&cam->ctrl_handler); in zr364xx_prepare()
1121 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_vidioc_streamon() local
1129 if (cam->owner && cam->owner != priv) in zr364xx_vidioc_streamon()
1132 res = zr364xx_prepare(cam); in zr364xx_vidioc_streamon()
1135 res = videobuf_streamon(&cam->vb_vidq); in zr364xx_vidioc_streamon()
1137 zr364xx_start_acquire(cam); in zr364xx_vidioc_streamon()
1138 cam->owner = file->private_data; in zr364xx_vidioc_streamon()
1146 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_vidioc_streamoff() local
1151 if (cam->owner && cam->owner != priv) in zr364xx_vidioc_streamoff()
1153 zr364xx_stop_acquire(cam); in zr364xx_vidioc_streamoff()
1154 return videobuf_streamoff(&cam->vb_vidq); in zr364xx_vidioc_streamoff()
1161 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_open() local
1166 if (mutex_lock_interruptible(&cam->lock)) in zr364xx_open()
1180 mutex_unlock(&cam->lock); in zr364xx_open()
1185 static void zr364xx_board_uninit(struct zr364xx_camera *cam) in zr364xx_board_uninit() argument
1189 zr364xx_stop_readpipe(cam); in zr364xx_board_uninit()
1193 if (cam->buffer.frame[i].lpvbits) { in zr364xx_board_uninit()
1194 DBG("vfree %p\n", cam->buffer.frame[i].lpvbits); in zr364xx_board_uninit()
1195 vfree(cam->buffer.frame[i].lpvbits); in zr364xx_board_uninit()
1197 cam->buffer.frame[i].lpvbits = NULL; in zr364xx_board_uninit()
1201 kfree(cam->pipe->transfer_buffer); in zr364xx_board_uninit()
1206 struct zr364xx_camera *cam = in zr364xx_release() local
1209 videobuf_mmap_free(&cam->vb_vidq); in zr364xx_release()
1210 v4l2_ctrl_handler_free(&cam->ctrl_handler); in zr364xx_release()
1211 zr364xx_board_uninit(cam); in zr364xx_release()
1212 v4l2_device_unregister(&cam->v4l2_dev); in zr364xx_release()
1213 kfree(cam); in zr364xx_release()
1219 struct zr364xx_camera *cam; in zr364xx_close() local
1224 cam = video_drvdata(file); in zr364xx_close()
1226 mutex_lock(&cam->lock); in zr364xx_close()
1227 udev = cam->udev; in zr364xx_close()
1229 if (file->private_data == cam->owner) { in zr364xx_close()
1231 if (cam->b_acquire) in zr364xx_close()
1232 zr364xx_stop_acquire(cam); in zr364xx_close()
1233 videobuf_streamoff(&cam->vb_vidq); in zr364xx_close()
1236 send_control_msg(udev, 1, init[cam->method][i].value, in zr364xx_close()
1237 0, init[cam->method][i].bytes, in zr364xx_close()
1238 init[cam->method][i].size); in zr364xx_close()
1240 cam->owner = NULL; in zr364xx_close()
1247 mutex_unlock(&cam->lock); in zr364xx_close()
1254 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_mmap() local
1257 if (!cam) { in zr364xx_mmap()
1263 ret = videobuf_mmap_mapper(&cam->vb_vidq, vma); in zr364xx_mmap()
1274 struct zr364xx_camera *cam = video_drvdata(file); in zr364xx_poll() local
1275 struct videobuf_queue *q = &cam->vb_vidq; in zr364xx_poll()
1331 static int zr364xx_board_init(struct zr364xx_camera *cam) in zr364xx_board_init() argument
1333 struct zr364xx_pipeinfo *pipe = cam->pipe; in zr364xx_board_init()
1337 DBG("board init: %p\n", cam); in zr364xx_board_init()
1339 pipe->cam = cam; in zr364xx_board_init()
1349 cam->b_acquire = 0; in zr364xx_board_init()
1350 cam->frame_count = 0; in zr364xx_board_init()
1355 cam->buffer.frame[i].lpvbits = vmalloc(MAX_FRAME_SIZE); in zr364xx_board_init()
1358 &cam->buffer.frame[i], i, in zr364xx_board_init()
1359 cam->buffer.frame[i].lpvbits); in zr364xx_board_init()
1360 if (!cam->buffer.frame[i].lpvbits) { in zr364xx_board_init()
1371 cam->buffer.dwFrames = i; in zr364xx_board_init()
1375 cam->buffer.frame[i].ulState = ZR364XX_READ_IDLE; in zr364xx_board_init()
1376 cam->buffer.frame[i].cur_size = 0; in zr364xx_board_init()
1379 cam->cur_frame = 0; in zr364xx_board_init()
1380 cam->last_frame = -1; in zr364xx_board_init()
1384 err = zr364xx_start_readpipe(cam); in zr364xx_board_init()
1393 vfree(cam->buffer.frame[i].lpvbits); in zr364xx_board_init()
1395 kfree(cam->pipe->transfer_buffer); in zr364xx_board_init()
1396 cam->pipe->transfer_buffer = NULL; in zr364xx_board_init()
1404 struct zr364xx_camera *cam = NULL; in zr364xx_probe() local
1418 cam = kzalloc(sizeof(*cam), GFP_KERNEL); in zr364xx_probe()
1419 if (!cam) in zr364xx_probe()
1422 err = v4l2_device_register(&intf->dev, &cam->v4l2_dev); in zr364xx_probe()
1427 hdl = &cam->ctrl_handler; in zr364xx_probe()
1437 cam->method = id->driver_info; in zr364xx_probe()
1438 mutex_init(&cam->lock); in zr364xx_probe()
1439 cam->vdev = zr364xx_template; in zr364xx_probe()
1440 cam->vdev.lock = &cam->lock; in zr364xx_probe()
1441 cam->vdev.v4l2_dev = &cam->v4l2_dev; in zr364xx_probe()
1442 cam->vdev.ctrl_handler = &cam->ctrl_handler; in zr364xx_probe()
1443 video_set_drvdata(&cam->vdev, cam); in zr364xx_probe()
1445 cam->udev = udev; in zr364xx_probe()
1450 cam->width = 160; in zr364xx_probe()
1451 cam->height = 120; in zr364xx_probe()
1455 cam->width = 640; in zr364xx_probe()
1456 cam->height = 480; in zr364xx_probe()
1460 cam->width = 320; in zr364xx_probe()
1461 cam->height = 240; in zr364xx_probe()
1470 if (cam->method == METHOD3) { in zr364xx_probe()
1484 header2[437] = cam->height / 256; in zr364xx_probe()
1485 header2[438] = cam->height % 256; in zr364xx_probe()
1486 header2[439] = cam->width / 256; in zr364xx_probe()
1487 header2[440] = cam->width % 256; in zr364xx_probe()
1489 cam->nb = 0; in zr364xx_probe()
1491 DBG("dev: %p, udev %p interface %p\n", cam, cam->udev, intf); in zr364xx_probe()
1498 if (!cam->read_endpoint && usb_endpoint_is_bulk_in(endpoint)) { in zr364xx_probe()
1500 cam->read_endpoint = endpoint->bEndpointAddress; in zr364xx_probe()
1504 if (!cam->read_endpoint) { in zr364xx_probe()
1511 INIT_LIST_HEAD(&cam->vidq.active); in zr364xx_probe()
1512 cam->vidq.cam = cam; in zr364xx_probe()
1514 usb_set_intfdata(intf, cam); in zr364xx_probe()
1517 err = zr364xx_board_init(cam); in zr364xx_probe()
1524 spin_lock_init(&cam->slock); in zr364xx_probe()
1526 cam->fmt = formats; in zr364xx_probe()
1528 videobuf_queue_vmalloc_init(&cam->vb_vidq, &zr364xx_video_qops, in zr364xx_probe()
1529 NULL, &cam->slock, in zr364xx_probe()
1532 sizeof(struct zr364xx_buffer), cam, &cam->lock); in zr364xx_probe()
1534 err = video_register_device(&cam->vdev, VFL_TYPE_VIDEO, -1); in zr364xx_probe()
1539 cam->v4l2_dev.release = zr364xx_release; in zr364xx_probe()
1542 video_device_node_name(&cam->vdev)); in zr364xx_probe()
1546 zr364xx_board_uninit(cam); in zr364xx_probe()
1549 v4l2_device_unregister(&cam->v4l2_dev); in zr364xx_probe()
1551 kfree(cam); in zr364xx_probe()
1558 struct zr364xx_camera *cam = usb_get_intfdata(intf); in zr364xx_disconnect() local
1560 mutex_lock(&cam->lock); in zr364xx_disconnect()
1563 video_unregister_device(&cam->vdev); in zr364xx_disconnect()
1564 v4l2_device_disconnect(&cam->v4l2_dev); in zr364xx_disconnect()
1567 if (cam->b_acquire) in zr364xx_disconnect()
1568 zr364xx_stop_acquire(cam); in zr364xx_disconnect()
1570 zr364xx_stop_readpipe(cam); in zr364xx_disconnect()
1571 mutex_unlock(&cam->lock); in zr364xx_disconnect()
1572 v4l2_device_put(&cam->v4l2_dev); in zr364xx_disconnect()
1579 struct zr364xx_camera *cam = usb_get_intfdata(intf); in zr364xx_suspend() local
1581 cam->was_streaming = cam->b_acquire; in zr364xx_suspend()
1582 if (!cam->was_streaming) in zr364xx_suspend()
1584 zr364xx_stop_acquire(cam); in zr364xx_suspend()
1585 zr364xx_stop_readpipe(cam); in zr364xx_suspend()
1591 struct zr364xx_camera *cam = usb_get_intfdata(intf); in zr364xx_resume() local
1594 if (!cam->was_streaming) in zr364xx_resume()
1597 res = zr364xx_start_readpipe(cam); in zr364xx_resume()
1601 res = zr364xx_prepare(cam); in zr364xx_resume()
1605 zr364xx_start_acquire(cam); in zr364xx_resume()
1609 zr364xx_stop_readpipe(cam); in zr364xx_resume()