Lines Matching refs:usbvision
8 * This module is part of usbvision driver project.
71 #include "usbvision.h"
72 #include "usbvision-cards.h"
76 #define DRIVER_NAME "usbvision"
112 /* sequential number of usbvision device */
127 static void usbvision_release(struct usb_usbvision *usbvision);
168 /* Device parameters information is located at /sys/module/usbvision */
194 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
196 usbvision_device_data[usbvision->DevModel].ModelString);
205 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
209 if(usbvision->user)
210 call_all(usbvision, core, g_ctrl, &ctrl);
220 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
224 if(usbvision->user)
225 call_all(usbvision, core, g_ctrl, &ctrl);
235 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
239 if(usbvision->user)
240 call_all(usbvision, core, g_ctrl, &ctrl);
250 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
254 if(usbvision->user)
255 call_all(usbvision, core, g_ctrl, &ctrl);
265 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
267 YES_NO(usbvision->streaming==Stream_On?1:0));
276 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
278 YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS));
287 struct usb_usbvision *usbvision = video_get_drvdata(vdev);
288 return sprintf(buf, "%d\n", usbvision->bridgeType);
349 * client only (checks internal counter 'usbvision->user'). The procedure
355 struct usb_usbvision *usbvision = video_drvdata(file);
361 usbvision_reset_powerOffTimer(usbvision);
363 if (usbvision->user)
367 errCode = usbvision_scratch_alloc(usbvision);
371 errCode = usbvision_decompress_alloc(usbvision);
375 usbvision_scratch_free(usbvision);
376 usbvision_decompress_free(usbvision);
382 mutex_lock(&usbvision->lock);
383 if (usbvision->power == 0) {
384 usbvision_power_on(usbvision);
385 usbvision_i2c_register(usbvision);
389 if (!usbvision->initialized) {
391 setup_ok = usbvision_setup(usbvision,isocMode);
393 usbvision->initialized = 1;
399 usbvision_begin_streaming(usbvision);
400 errCode = usbvision_init_isoc(usbvision);
402 usbvision_muxsel(usbvision,0);
403 usbvision->user++;
406 usbvision_i2c_unregister(usbvision);
407 usbvision_power_off(usbvision);
408 usbvision->initialized = 0;
411 mutex_unlock(&usbvision->lock);
415 usbvision_empty_framequeues(usbvision);
432 struct usb_usbvision *usbvision = video_drvdata(file);
435 mutex_lock(&usbvision->lock);
437 usbvision_audio_off(usbvision);
438 usbvision_restart_isoc(usbvision);
439 usbvision_stop_isoc(usbvision);
441 usbvision_decompress_free(usbvision);
442 usbvision_frames_free(usbvision);
443 usbvision_empty_framequeues(usbvision);
444 usbvision_scratch_free(usbvision);
446 usbvision->user--;
451 usbvision_set_powerOffTimer(usbvision);
452 usbvision->initialized = 0;
455 mutex_unlock(&usbvision->lock);
457 if (usbvision->remove_pending) {
459 usbvision_release(usbvision);
477 struct usb_usbvision *usbvision = video_drvdata(file);
483 errCode = usbvision_read_reg(usbvision, reg->reg&0xff);
485 dev_err(&usbvision->vdev->dev,
498 struct usb_usbvision *usbvision = video_drvdata(file);
504 errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val);
506 dev_err(&usbvision->vdev->dev,
518 struct usb_usbvision *usbvision = video_drvdata(file);
522 usbvision_device_data[usbvision->DevModel].ModelString,
524 usb_make_path(usbvision->dev, vc->bus_info, sizeof(vc->bus_info));
530 (usbvision->have_tuner ? V4L2_CAP_TUNER : 0);
537 struct usb_usbvision *usbvision = video_drvdata(file);
540 if (vi->index >= usbvision->video_inputs)
542 if (usbvision->have_tuner) {
548 specific for each usbvision card model */
551 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) {
563 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) {
572 if (usbvision_device_data[usbvision->DevModel].VideoChannels == 4) {
590 struct usb_usbvision *usbvision = video_drvdata(file);
592 *input = usbvision->ctl_input;
598 struct usb_usbvision *usbvision = video_drvdata(file);
600 if (input >= usbvision->video_inputs)
603 mutex_lock(&usbvision->lock);
604 usbvision_muxsel(usbvision, input);
605 usbvision_set_input(usbvision);
606 usbvision_set_output(usbvision,
607 usbvision->curwidth,
608 usbvision->curheight);
609 mutex_unlock(&usbvision->lock);
615 struct usb_usbvision *usbvision = video_drvdata(file);
617 usbvision->tvnormId=*id;
619 mutex_lock(&usbvision->lock);
620 call_all(usbvision, core, s_std, usbvision->tvnormId);
621 mutex_unlock(&usbvision->lock);
623 usbvision_muxsel(usbvision, usbvision->ctl_input);
631 struct usb_usbvision *usbvision = video_drvdata(file);
633 if (!usbvision->have_tuner || vt->index) // Only tuner 0
635 if(usbvision->radio) {
642 call_all(usbvision, tuner, g_tuner, vt);
650 struct usb_usbvision *usbvision = video_drvdata(file);
653 if (!usbvision->have_tuner || vt->index)
656 call_all(usbvision, tuner, s_tuner, vt);
664 struct usb_usbvision *usbvision = video_drvdata(file);
667 if(usbvision->radio) {
672 freq->frequency = usbvision->freq;
680 struct usb_usbvision *usbvision = video_drvdata(file);
683 if (!usbvision->have_tuner || freq->tuner)
686 usbvision->freq = freq->frequency;
687 call_all(usbvision, tuner, s_frequency, freq);
694 struct usb_usbvision *usbvision = video_drvdata(file);
696 if(usbvision->radio) {
718 struct usb_usbvision *usbvision = video_drvdata(file);
720 call_all(usbvision, core, queryctrl, ctrl);
731 struct usb_usbvision *usbvision = video_drvdata(file);
732 call_all(usbvision, core, g_ctrl, ctrl);
740 struct usb_usbvision *usbvision = video_drvdata(file);
741 call_all(usbvision, core, s_ctrl, ctrl);
749 struct usb_usbvision *usbvision = video_drvdata(file);
759 if(usbvision->streaming == Stream_On) {
760 if ((ret = usbvision_stream_interrupt(usbvision)))
764 usbvision_frames_free(usbvision);
765 usbvision_empty_framequeues(usbvision);
766 vr->count = usbvision_frames_alloc(usbvision,vr->count);
768 usbvision->curFrame = NULL;
776 struct usb_usbvision *usbvision = video_drvdata(file);
779 if(vb->index>=usbvision->num_frames) {
784 frame = &usbvision->frame[vb->index];
793 vb->m.offset = vb->index*PAGE_ALIGN(usbvision->max_frame_size);
797 vb->length = usbvision->curwidth*
798 usbvision->curheight*
799 usbvision->palette.bytes_per_pixel;
800 vb->timestamp = usbvision->frame[vb->index].timestamp;
801 vb->sequence = usbvision->frame[vb->index].sequence;
807 struct usb_usbvision *usbvision = video_drvdata(file);
811 if(vb->index>=usbvision->num_frames) {
815 frame = &usbvision->frame[vb->index];
829 frame->v4l2_format = usbvision->palette;
831 spin_lock_irqsave(&usbvision->queue_lock, lock_flags);
832 list_add_tail(&usbvision->frame[vb->index].frame, &usbvision->inqueue);
833 spin_unlock_irqrestore(&usbvision->queue_lock, lock_flags);
840 struct usb_usbvision *usbvision = video_drvdata(file);
845 if (list_empty(&(usbvision->outqueue))) {
846 if (usbvision->streaming == Stream_Idle)
849 (usbvision->wait_frame,
850 !list_empty(&(usbvision->outqueue)));
855 spin_lock_irqsave(&usbvision->queue_lock, lock_flags);
856 f = list_entry(usbvision->outqueue.next,
858 list_del(usbvision->outqueue.next);
859 spin_unlock_irqrestore(&usbvision->queue_lock, lock_flags);
878 struct usb_usbvision *usbvision = video_drvdata(file);
880 usbvision->streaming = Stream_On;
881 call_all(usbvision, video, s_stream, 1);
889 struct usb_usbvision *usbvision = video_drvdata(file);
894 if(usbvision->streaming == Stream_On) {
895 usbvision_stream_interrupt(usbvision);
897 call_all(usbvision, video, s_stream, 0);
899 usbvision_empty_framequeues(usbvision);
918 struct usb_usbvision *usbvision = video_drvdata(file);
919 vf->fmt.pix.width = usbvision->curwidth;
920 vf->fmt.pix.height = usbvision->curheight;
921 vf->fmt.pix.pixelformat = usbvision->palette.format;
923 usbvision->curwidth*usbvision->palette.bytes_per_pixel;
924 vf->fmt.pix.sizeimage = vf->fmt.pix.bytesperline*usbvision->curheight;
934 struct usb_usbvision *usbvision = video_drvdata(file);
941 usbvision->palette = usbvision_v4l2_format[formatIdx];
953 usbvision->palette.bytes_per_pixel;
962 struct usb_usbvision *usbvision = video_drvdata(file);
970 if(usbvision->streaming == Stream_On) {
971 if ((ret = usbvision_stream_interrupt(usbvision)))
974 usbvision_frames_free(usbvision);
975 usbvision_empty_framequeues(usbvision);
977 usbvision->curFrame = NULL;
980 mutex_lock(&usbvision->lock);
981 usbvision_set_output(usbvision, vf->fmt.pix.width, vf->fmt.pix.height);
982 mutex_unlock(&usbvision->lock);
990 struct usb_usbvision *usbvision = video_drvdata(file);
1000 if (!USBVISION_IS_OPERATIONAL(usbvision) || (buf == NULL))
1006 if(!usbvision->num_frames) {
1009 usbvision_frames_free(usbvision);
1010 usbvision_empty_framequeues(usbvision);
1011 usbvision_frames_alloc(usbvision,USBVISION_NUMFRAMES);
1014 if(usbvision->streaming != Stream_On) {
1016 usbvision->streaming = Stream_On;
1017 call_all(usbvision, video, s_stream, 1);
1022 for(i=0;i<usbvision->num_frames;i++) {
1023 frame = &usbvision->frame[i];
1032 frame->v4l2_format = usbvision->palette;
1034 spin_lock_irqsave(&usbvision->queue_lock, lock_flags);
1035 list_add_tail(&frame->frame, &usbvision->inqueue);
1036 spin_unlock_irqrestore(&usbvision->queue_lock,
1042 if (list_empty(&(usbvision->outqueue))) {
1047 (usbvision->wait_frame,
1048 !list_empty(&(usbvision->outqueue)));
1053 spin_lock_irqsave(&usbvision->queue_lock, lock_flags);
1054 frame = list_entry(usbvision->outqueue.next,
1056 list_del(usbvision->outqueue.next);
1057 spin_unlock_irqrestore(&usbvision->queue_lock, lock_flags);
1099 struct usb_usbvision *usbvision = video_drvdata(file);
1103 mutex_lock(&usbvision->lock);
1105 if (!USBVISION_IS_OPERATIONAL(usbvision)) {
1106 mutex_unlock(&usbvision->lock);
1111 size != PAGE_ALIGN(usbvision->max_frame_size)) {
1112 mutex_unlock(&usbvision->lock);
1116 for (i = 0; i < usbvision->num_frames; i++) {
1117 if (((PAGE_ALIGN(usbvision->max_frame_size)*i) >> PAGE_SHIFT) ==
1121 if (i == usbvision->num_frames) {
1124 mutex_unlock(&usbvision->lock);
1132 pos = usbvision->frame[i].data;
1137 mutex_unlock(&usbvision->lock);
1145 mutex_unlock(&usbvision->lock);
1151 * Here comes the stuff for radio on usbvision based devices
1156 struct usb_usbvision *usbvision = video_drvdata(file);
1161 mutex_lock(&usbvision->lock);
1163 if (usbvision->user) {
1164 dev_err(&usbvision->rdev->dev,
1171 usbvision_reset_powerOffTimer(usbvision);
1172 if (usbvision->power == 0) {
1173 usbvision_power_on(usbvision);
1174 usbvision_i2c_register(usbvision);
1179 errCode = usbvision_set_alternate(usbvision);
1181 usbvision->last_error = errCode;
1187 usbvision->radio = 1;
1188 call_all(usbvision, tuner, s_radio);
1189 usbvision_set_audio(usbvision, USBVISION_AUDIO_RADIO);
1190 usbvision->user++;
1195 usbvision_i2c_unregister(usbvision);
1196 usbvision_power_off(usbvision);
1197 usbvision->initialized = 0;
1201 mutex_unlock(&usbvision->lock);
1208 struct usb_usbvision *usbvision = video_drvdata(file);
1213 mutex_lock(&usbvision->lock);
1216 usbvision->ifaceAlt=0;
1217 errCode = usb_set_interface(usbvision->dev, usbvision->iface,
1218 usbvision->ifaceAlt);
1220 usbvision_audio_off(usbvision);
1221 usbvision->radio=0;
1222 usbvision->user--;
1225 usbvision_set_powerOffTimer(usbvision);
1226 usbvision->initialized = 0;
1229 mutex_unlock(&usbvision->lock);
1231 if (usbvision->remove_pending) {
1233 usbvision_release(usbvision);
1292 .name = "usbvision-video",
1325 .name = "usbvision-radio",
1334 static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision,
1338 struct usb_device *usb_dev = usbvision->dev;
1342 dev_err(&usbvision->dev->dev,
1343 "%s: usbvision->dev is not set\n", __func__);
1352 vdev->v4l2_dev = &usbvision->v4l2_dev;
1354 video_set_drvdata(vdev, usbvision);
1359 static void usbvision_unregister_video(struct usb_usbvision *usbvision)
1362 if (usbvision->rdev) {
1364 video_device_node_name(usbvision->rdev));
1365 if (video_is_registered(usbvision->rdev)) {
1366 video_unregister_device(usbvision->rdev);
1368 video_device_release(usbvision->rdev);
1370 usbvision->rdev = NULL;
1374 if (usbvision->vdev) {
1376 video_device_node_name(usbvision->vdev));
1377 if (video_is_registered(usbvision->vdev)) {
1378 video_unregister_device(usbvision->vdev);
1380 video_device_release(usbvision->vdev);
1382 usbvision->vdev = NULL;
1387 static int __devinit usbvision_register_video(struct usb_usbvision *usbvision)
1390 usbvision->vdev = usbvision_vdev_init(usbvision,
1393 if (usbvision->vdev == NULL) {
1396 if (video_register_device(usbvision->vdev,
1402 usbvision->nr, video_device_node_name(usbvision->vdev));
1405 if (usbvision_device_data[usbvision->DevModel].Radio) {
1406 // usbvision has radio
1407 usbvision->rdev = usbvision_vdev_init(usbvision,
1410 if (usbvision->rdev == NULL) {
1413 if (video_register_device(usbvision->rdev,
1419 usbvision->nr, video_device_node_name(usbvision->rdev));
1425 dev_err(&usbvision->dev->dev,
1427 usbvision->nr);
1428 usbvision_unregister_video(usbvision);
1444 struct usb_usbvision *usbvision;
1446 usbvision = kzalloc(sizeof(struct usb_usbvision), GFP_KERNEL);
1447 if (usbvision == NULL)
1450 usbvision->dev = dev;
1451 if (v4l2_device_register(&intf->dev, &usbvision->v4l2_dev))
1454 mutex_init(&usbvision->lock); /* available */
1457 usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL);
1458 if (usbvision->ctrlUrb == NULL)
1460 init_waitqueue_head(&usbvision->ctrlUrb_wq);
1462 usbvision_init_powerOffTimer(usbvision);
1464 return usbvision;
1467 v4l2_device_unregister(&usbvision->v4l2_dev);
1469 kfree(usbvision);
1480 static void usbvision_release(struct usb_usbvision *usbvision)
1484 mutex_lock(&usbvision->lock);
1486 usbvision_reset_powerOffTimer(usbvision);
1488 usbvision->initialized = 0;
1490 mutex_unlock(&usbvision->lock);
1492 usbvision_remove_sysfs(usbvision->vdev);
1493 usbvision_unregister_video(usbvision);
1495 if (usbvision->ctrlUrb) {
1496 usb_free_urb(usbvision->ctrlUrb);
1499 v4l2_device_unregister(&usbvision->v4l2_dev);
1500 kfree(usbvision);
1508 static void usbvision_configure_video(struct usb_usbvision *usbvision)
1512 if (usbvision == NULL)
1515 model = usbvision->DevModel;
1516 usbvision->palette = usbvision_v4l2_format[2]; // V4L2_PIX_FMT_RGB24;
1518 if (usbvision_device_data[usbvision->DevModel].Vin_Reg2_override) {
1519 usbvision->Vin_Reg2_Preset =
1520 usbvision_device_data[usbvision->DevModel].Vin_Reg2;
1522 usbvision->Vin_Reg2_Preset = 0;
1525 usbvision->tvnormId = usbvision_device_data[model].VideoNorm;
1527 usbvision->video_inputs = usbvision_device_data[model].VideoChannels;
1528 usbvision->ctl_input = 0;
1532 usbvision_audio_off(usbvision);
1535 usbvision_power_on(usbvision);
1536 usbvision_i2c_register(usbvision);
1554 struct usb_usbvision *usbvision = NULL;
1589 usbvision = usbvision_alloc(dev, intf);
1590 if (usbvision == NULL) {
1596 usbvision->bridgeType = BRIDGE_NT1004;
1598 usbvision->bridgeType = BRIDGE_NT1005;
1600 usbvision->bridgeType = BRIDGE_NT1003;
1602 PDEBUG(DBG_PROBE, "bridgeType %d", usbvision->bridgeType);
1604 mutex_lock(&usbvision->lock);
1609 usbvision->num_alt=uif->num_altsetting;
1610 PDEBUG(DBG_PROBE, "Alternate settings: %i",usbvision->num_alt);
1611 usbvision->alt_max_pkt_size = kmalloc(32*
1612 usbvision->num_alt,GFP_KERNEL);
1613 if (usbvision->alt_max_pkt_size == NULL) {
1614 dev_err(&intf->dev, "usbvision: out of memory!\n");
1615 mutex_unlock(&usbvision->lock);
1619 for (i = 0; i < usbvision->num_alt ; i++) {
1622 usbvision->alt_max_pkt_size[i] =
1625 usbvision->alt_max_pkt_size[i]);
1629 usbvision->nr = usbvision_nr++;
1631 usbvision->have_tuner = usbvision_device_data[model].Tuner;
1632 if (usbvision->have_tuner) {
1633 usbvision->tuner_type = usbvision_device_data[model].TunerType;
1636 usbvision->DevModel = model;
1637 usbvision->remove_pending = 0;
1638 usbvision->iface = ifnum;
1639 usbvision->ifaceAlt = 0;
1640 usbvision->video_endp = endpoint->bEndpointAddress;
1641 usbvision->isocPacketSize = 0;
1642 usbvision->usb_bandwidth = 0;
1643 usbvision->user = 0;
1644 usbvision->streaming = Stream_Off;
1645 usbvision_register_video(usbvision);
1646 usbvision_configure_video(usbvision);
1647 mutex_unlock(&usbvision->lock);
1649 usbvision_create_sysfs(usbvision->vdev);
1666 struct usb_usbvision *usbvision = to_usbvision(usb_get_intfdata(intf));
1670 if (usbvision == NULL) {
1675 mutex_lock(&usbvision->lock);
1678 usbvision_stop_isoc(usbvision);
1680 v4l2_device_disconnect(&usbvision->v4l2_dev);
1682 if (usbvision->power) {
1683 usbvision_i2c_unregister(usbvision);
1684 usbvision_power_off(usbvision);
1686 usbvision->remove_pending = 1; // Now all ISO data will be ignored
1688 usb_put_dev(usbvision->dev);
1689 usbvision->dev = NULL; // USB device is no more
1691 mutex_unlock(&usbvision->lock);
1693 if (usbvision->user) {
1696 wake_up_interruptible(&usbvision->wait_frame);
1697 wake_up_interruptible(&usbvision->wait_stream);
1699 usbvision_release(usbvision);
1706 .name = "usbvision",