Lines Matching refs:pdev
33 pdev: struct pwc_devive *
119 static void pwc_isoc_cleanup(struct pwc_device *pdev);
187 static struct pwc_frame_buf *pwc_get_next_fill_buf(struct pwc_device *pdev)
192 spin_lock_irqsave(&pdev->queued_bufs_lock, flags);
193 if (list_empty(&pdev->queued_bufs))
196 buf = list_entry(pdev->queued_bufs.next, struct pwc_frame_buf, list);
199 spin_unlock_irqrestore(&pdev->queued_bufs_lock, flags);
203 static void pwc_snapshot_button(struct pwc_device *pdev, int down)
212 if (pdev->button_dev) {
213 input_report_key(pdev->button_dev, KEY_CAMERA, down);
214 input_sync(pdev->button_dev);
219 static void pwc_frame_complete(struct pwc_device *pdev)
221 struct pwc_frame_buf *fbuf = pdev->fill_buf;
227 if (pdev->type == 730) {
232 pdev->drop_frames += 2;
234 if ((ptr[0] ^ pdev->vmirror) & 0x01) {
235 pwc_snapshot_button(pdev, ptr[0] & 0x01);
237 if ((ptr[0] ^ pdev->vmirror) & 0x02) {
243 pdev->vmirror = ptr[0] & 0x03;
254 pdev->drop_frames++;
255 } else if (pdev->type == 740 || pdev->type == 720) {
257 if ((ptr[0] ^ pdev->vmirror) & 0x01) {
258 pwc_snapshot_button(pdev, ptr[0] & 0x01);
260 pdev->vmirror = ptr[0] & 0x03;
264 if (pdev->drop_frames > 0) {
265 pdev->drop_frames--;
268 if (fbuf->filled < pdev->frame_total_size) {
273 fbuf->vb.sequence = pdev->vframe_count;
275 pdev->fill_buf = NULL;
276 pdev->vsync = 0;
279 pdev->vframe_count++;
287 struct pwc_device *pdev = (struct pwc_device *)urb->context;
292 trace_pwc_handler_enter(urb, pdev);
301 if (pdev->fill_buf == NULL)
302 pdev->fill_buf = pwc_get_next_fill_buf(pdev);
319 if (++pdev->visoc_errors > MAX_ISOC_ERRORS)
322 if (pdev->fill_buf) {
323 vb2_buffer_done(&pdev->fill_buf->vb.vb2_buf,
325 pdev->fill_buf = NULL;
328 pdev->vsync = 0; /* Drop the current frame */
333 pdev->visoc_errors = 0;
353 if (flen > 0 && pdev->vsync) {
354 struct pwc_frame_buf *fbuf = pdev->fill_buf;
356 if (pdev->vsync == 1) {
358 pdev->vsync = 2;
361 if (flen + fbuf->filled > pdev->frame_total_size) {
364 pdev->frame_total_size);
365 pdev->vsync = 0; /* Let's wait for an EOF */
372 if (flen < pdev->vlast_packet_size) {
374 if (pdev->vsync == 2)
375 pwc_frame_complete(pdev);
376 if (pdev->fill_buf == NULL)
377 pdev->fill_buf = pwc_get_next_fill_buf(pdev);
378 if (pdev->fill_buf) {
379 pdev->fill_buf->filled = 0;
380 pdev->vsync = 1;
383 pdev->vlast_packet_size = flen;
392 trace_pwc_handler_exit(urb, pdev);
400 static int pwc_isoc_init(struct pwc_device *pdev)
409 pdev->vsync = 0;
410 pdev->vlast_packet_size = 0;
411 pdev->fill_buf = NULL;
412 pdev->vframe_count = 0;
413 pdev->visoc_errors = 0;
414 udev = pdev->udev;
419 ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt,
420 pdev->vframes, &compression, 1);
425 idesc = usb_altnum_to_altsetting(intf, pdev->valternate);
430 pdev->vmax_packet_size = -1;
432 if ((idesc->endpoint[i].desc.bEndpointAddress & 0xF) == pdev->vendpoint) {
433 pdev->vmax_packet_size = le16_to_cpu(idesc->endpoint[i].desc.wMaxPacketSize);
438 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) {
444 PWC_DEBUG_OPEN("Setting alternate interface %d\n", pdev->valternate);
445 ret = usb_set_interface(pdev->udev, 0, pdev->valternate);
457 pwc_isoc_cleanup(pdev);
460 pdev->urbs[i] = urb;
465 urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint);
473 pwc_isoc_cleanup(pdev);
477 urb->context = pdev;
482 urb->iso_frame_desc[j].length = pdev->vmax_packet_size;
488 ret = usb_submit_urb(pdev->urbs[i], GFP_KERNEL);
491 pwc_isoc_cleanup(pdev);
496 pwc_isoc_cleanup(pdev);
499 PWC_DEBUG_MEMORY("URB 0x%p submitted.\n", pdev->urbs[i]);
507 static void pwc_iso_stop(struct pwc_device *pdev)
513 if (pdev->urbs[i]) {
514 PWC_DEBUG_MEMORY("Unlinking URB %p\n", pdev->urbs[i]);
515 usb_kill_urb(pdev->urbs[i]);
520 static void pwc_iso_free(struct pwc_device *pdev)
526 struct urb *urb = pdev->urbs[i];
536 pdev->urbs[i] = NULL;
542 static void pwc_isoc_cleanup(struct pwc_device *pdev)
546 pwc_iso_stop(pdev);
547 pwc_iso_free(pdev);
548 usb_set_interface(pdev->udev, 0, 0);
554 static void pwc_cleanup_queued_bufs(struct pwc_device *pdev,
559 spin_lock_irqsave(&pdev->queued_bufs_lock, flags);
560 while (!list_empty(&pdev->queued_bufs)) {
563 buf = list_entry(pdev->queued_bufs.next, struct pwc_frame_buf,
568 spin_unlock_irqrestore(&pdev->queued_bufs_lock, flags);
606 struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev);
608 v4l2_ctrl_handler_free(&pdev->ctrl_handler);
609 v4l2_device_unregister(&pdev->v4l2_dev);
610 kfree(pdev->ctrl_buf);
611 kfree(pdev);
621 struct pwc_device *pdev = vb2_get_drv_priv(vq);
631 size = pwc_get_size(pdev, MAX_WIDTH, MAX_HEIGHT);
654 struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue);
657 if (!pdev->udev)
665 struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue);
677 pwc_decompress(pdev, buf);
692 struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue);
699 if (!pdev->udev) {
704 spin_lock_irqsave(&pdev->queued_bufs_lock, flags);
705 list_add_tail(&buf->list, &pdev->queued_bufs);
706 spin_unlock_irqrestore(&pdev->queued_bufs_lock, flags);
711 struct pwc_device *pdev = vb2_get_drv_priv(vq);
714 if (!pdev->udev)
717 if (mutex_lock_interruptible(&pdev->v4l2_lock))
720 pwc_camera_power(pdev, 1);
721 pwc_set_leds(pdev, leds[0], leds[1]);
723 r = pwc_isoc_init(pdev);
726 pwc_set_leds(pdev, 0, 0);
727 pwc_camera_power(pdev, 0);
729 pwc_cleanup_queued_bufs(pdev, VB2_BUF_STATE_QUEUED);
731 mutex_unlock(&pdev->v4l2_lock);
738 struct pwc_device *pdev = vb2_get_drv_priv(vq);
740 mutex_lock(&pdev->v4l2_lock);
741 if (pdev->udev) {
742 pwc_set_leds(pdev, 0, 0);
743 pwc_camera_power(pdev, 0);
744 pwc_isoc_cleanup(pdev);
747 pwc_cleanup_queued_bufs(pdev, VB2_BUF_STATE_ERROR);
748 if (pdev->fill_buf)
749 vb2_buffer_done(&pdev->fill_buf->vb.vb2_buf,
751 mutex_unlock(&pdev->v4l2_lock);
777 struct pwc_device *pdev = NULL;
1032 pdev = kzalloc(sizeof(struct pwc_device), GFP_KERNEL);
1033 if (pdev == NULL) {
1037 pdev->type = type_id;
1038 pdev->features = features;
1039 pwc_construct(pdev); /* set min/max sizes correct */
1041 mutex_init(&pdev->v4l2_lock);
1042 mutex_init(&pdev->vb_queue_lock);
1043 spin_lock_init(&pdev->queued_bufs_lock);
1044 INIT_LIST_HEAD(&pdev->queued_bufs);
1046 pdev->udev = udev;
1047 pdev->power_save = my_power_save;
1050 pdev->vb_queue.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1051 pdev->vb_queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
1052 pdev->vb_queue.drv_priv = pdev;
1053 pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf);
1054 pdev->vb_queue.ops = &pwc_vb_queue_ops;
1055 pdev->vb_queue.mem_ops = &vb2_vmalloc_memops;
1056 pdev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1057 rc = vb2_queue_init(&pdev->vb_queue);
1064 pdev->vdev = pwc_template;
1065 strscpy(pdev->vdev.name, name, sizeof(pdev->vdev.name));
1066 pdev->vdev.queue = &pdev->vb_queue;
1067 pdev->vdev.queue->lock = &pdev->vb_queue_lock;
1068 video_set_drvdata(&pdev->vdev, pdev);
1070 pdev->release = le16_to_cpu(udev->descriptor.bcdDevice);
1071 PWC_DEBUG_PROBE("Release: %04x\n", pdev->release);
1074 pdev->ctrl_buf = kmalloc(sizeof(pdev->cmd_buf), GFP_KERNEL);
1075 if (!pdev->ctrl_buf) {
1083 if (pwc_get_cmos_sensor(pdev, &rc) >= 0) {
1085 pdev->vdev.name,
1091 pwc_set_leds(pdev, 0, 0);
1094 rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT,
1100 rc = pwc_init_controls(pdev);
1107 pwc_camera_power(pdev, 0);
1110 pdev->v4l2_dev.release = pwc_video_release;
1111 rc = v4l2_device_register(&intf->dev, &pdev->v4l2_dev);
1117 pdev->v4l2_dev.ctrl_handler = &pdev->ctrl_handler;
1118 pdev->vdev.v4l2_dev = &pdev->v4l2_dev;
1119 pdev->vdev.lock = &pdev->v4l2_lock;
1120 pdev->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
1123 rc = video_register_device(&pdev->vdev, VFL_TYPE_VIDEO, -1);
1128 PWC_INFO("Registered as %s.\n", video_device_node_name(&pdev->vdev));
1132 pdev->button_dev = input_allocate_device();
1133 if (!pdev->button_dev) {
1138 usb_make_path(udev, pdev->button_phys, sizeof(pdev->button_phys));
1139 strlcat(pdev->button_phys, "/input0", sizeof(pdev->button_phys));
1141 pdev->button_dev->name = "PWC snapshot button";
1142 pdev->button_dev->phys = pdev->button_phys;
1143 usb_to_input_id(pdev->udev, &pdev->button_dev->id);
1144 pdev->button_dev->dev.parent = &pdev->udev->dev;
1145 pdev->button_dev->evbit[0] = BIT_MASK(EV_KEY);
1146 pdev->button_dev->keybit[BIT_WORD(KEY_CAMERA)] = BIT_MASK(KEY_CAMERA);
1148 rc = input_register_device(pdev->button_dev);
1150 input_free_device(pdev->button_dev);
1151 pdev->button_dev = NULL;
1160 video_unregister_device(&pdev->vdev);
1163 v4l2_device_unregister(&pdev->v4l2_dev);
1165 v4l2_ctrl_handler_free(&pdev->ctrl_handler);
1167 kfree(pdev->ctrl_buf);
1168 kfree(pdev);
1176 struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev);
1178 mutex_lock(&pdev->vb_queue_lock);
1179 mutex_lock(&pdev->v4l2_lock);
1181 if (pdev->vb_queue.streaming)
1182 pwc_isoc_cleanup(pdev);
1183 pdev->udev = NULL;
1185 v4l2_device_disconnect(&pdev->v4l2_dev);
1186 video_unregister_device(&pdev->vdev);
1187 mutex_unlock(&pdev->v4l2_lock);
1188 mutex_unlock(&pdev->vb_queue_lock);
1191 if (pdev->button_dev)
1192 input_unregister_device(pdev->button_dev);
1195 v4l2_device_put(&pdev->v4l2_dev);