aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/usbvision/usbvision-video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-video.c')
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c127
1 files changed, 35 insertions, 92 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index b977116a0dd9..e10b256aeba4 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -98,7 +98,8 @@ USBVISION_DRIVER_VERSION_PATCHLEVEL)
98#ifdef USBVISION_DEBUG 98#ifdef USBVISION_DEBUG
99 #define PDEBUG(level, fmt, args...) { \ 99 #define PDEBUG(level, fmt, args...) { \
100 if (video_debug & (level)) \ 100 if (video_debug & (level)) \
101 info("[%s:%d] " fmt, __func__, __LINE__ , ## args); \ 101 printk(KERN_INFO KBUILD_MODNAME ":[%s:%d] " fmt, \
102 __func__, __LINE__ , ## args); \
102 } 103 }
103#else 104#else
104 #define PDEBUG(level, fmt, args...) do {} while(0) 105 #define PDEBUG(level, fmt, args...) do {} while(0)
@@ -360,13 +361,12 @@ static void usbvision_remove_sysfs(struct video_device *vdev)
360 */ 361 */
361static int usbvision_v4l2_open(struct inode *inode, struct file *file) 362static int usbvision_v4l2_open(struct inode *inode, struct file *file)
362{ 363{
363 struct video_device *dev = video_devdata(file); 364 struct usb_usbvision *usbvision = video_drvdata(file);
364 struct usb_usbvision *usbvision =
365 (struct usb_usbvision *) video_get_drvdata(dev);
366 int errCode = 0; 365 int errCode = 0;
367 366
368 PDEBUG(DBG_IO, "open"); 367 PDEBUG(DBG_IO, "open");
369 368
369 lock_kernel();
370 usbvision_reset_powerOffTimer(usbvision); 370 usbvision_reset_powerOffTimer(usbvision);
371 371
372 if (usbvision->user) 372 if (usbvision->user)
@@ -424,6 +424,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
424 usbvision_empty_framequeues(usbvision); 424 usbvision_empty_framequeues(usbvision);
425 425
426 PDEBUG(DBG_IO, "success"); 426 PDEBUG(DBG_IO, "success");
427 unlock_kernel();
427 return errCode; 428 return errCode;
428} 429}
429 430
@@ -437,9 +438,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
437 */ 438 */
438static int usbvision_v4l2_close(struct inode *inode, struct file *file) 439static int usbvision_v4l2_close(struct inode *inode, struct file *file)
439{ 440{
440 struct video_device *dev = video_devdata(file); 441 struct usb_usbvision *usbvision = video_drvdata(file);
441 struct usb_usbvision *usbvision =
442 (struct usb_usbvision *) video_get_drvdata(dev);
443 442
444 PDEBUG(DBG_IO, "close"); 443 PDEBUG(DBG_IO, "close");
445 mutex_lock(&usbvision->lock); 444 mutex_lock(&usbvision->lock);
@@ -484,9 +483,7 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file)
484static int vidioc_g_register (struct file *file, void *priv, 483static int vidioc_g_register (struct file *file, void *priv,
485 struct v4l2_register *reg) 484 struct v4l2_register *reg)
486{ 485{
487 struct video_device *dev = video_devdata(file); 486 struct usb_usbvision *usbvision = video_drvdata(file);
488 struct usb_usbvision *usbvision =
489 (struct usb_usbvision *) video_get_drvdata(dev);
490 int errCode; 487 int errCode;
491 488
492 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 489 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
@@ -505,9 +502,7 @@ static int vidioc_g_register (struct file *file, void *priv,
505static int vidioc_s_register (struct file *file, void *priv, 502static int vidioc_s_register (struct file *file, void *priv,
506 struct v4l2_register *reg) 503 struct v4l2_register *reg)
507{ 504{
508 struct video_device *dev = video_devdata(file); 505 struct usb_usbvision *usbvision = video_drvdata(file);
509 struct usb_usbvision *usbvision =
510 (struct usb_usbvision *) video_get_drvdata(dev);
511 int errCode; 506 int errCode;
512 507
513 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 508 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
@@ -526,9 +521,7 @@ static int vidioc_s_register (struct file *file, void *priv,
526static int vidioc_querycap (struct file *file, void *priv, 521static int vidioc_querycap (struct file *file, void *priv,
527 struct v4l2_capability *vc) 522 struct v4l2_capability *vc)
528{ 523{
529 struct video_device *dev = video_devdata(file); 524 struct usb_usbvision *usbvision = video_drvdata(file);
530 struct usb_usbvision *usbvision =
531 (struct usb_usbvision *) video_get_drvdata(dev);
532 525
533 strlcpy(vc->driver, "USBVision", sizeof(vc->driver)); 526 strlcpy(vc->driver, "USBVision", sizeof(vc->driver));
534 strlcpy(vc->card, 527 strlcpy(vc->card,
@@ -548,9 +541,7 @@ static int vidioc_querycap (struct file *file, void *priv,
548static int vidioc_enum_input (struct file *file, void *priv, 541static int vidioc_enum_input (struct file *file, void *priv,
549 struct v4l2_input *vi) 542 struct v4l2_input *vi)
550{ 543{
551 struct video_device *dev = video_devdata(file); 544 struct usb_usbvision *usbvision = video_drvdata(file);
552 struct usb_usbvision *usbvision =
553 (struct usb_usbvision *) video_get_drvdata(dev);
554 int chan; 545 int chan;
555 546
556 if ((vi->index >= usbvision->video_inputs) || (vi->index < 0) ) 547 if ((vi->index >= usbvision->video_inputs) || (vi->index < 0) )
@@ -603,9 +594,7 @@ static int vidioc_enum_input (struct file *file, void *priv,
603 594
604static int vidioc_g_input (struct file *file, void *priv, unsigned int *input) 595static int vidioc_g_input (struct file *file, void *priv, unsigned int *input)
605{ 596{
606 struct video_device *dev = video_devdata(file); 597 struct usb_usbvision *usbvision = video_drvdata(file);
607 struct usb_usbvision *usbvision =
608 (struct usb_usbvision *) video_get_drvdata(dev);
609 598
610 *input = usbvision->ctl_input; 599 *input = usbvision->ctl_input;
611 return 0; 600 return 0;
@@ -613,9 +602,7 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *input)
613 602
614static int vidioc_s_input (struct file *file, void *priv, unsigned int input) 603static int vidioc_s_input (struct file *file, void *priv, unsigned int input)
615{ 604{
616 struct video_device *dev = video_devdata(file); 605 struct usb_usbvision *usbvision = video_drvdata(file);
617 struct usb_usbvision *usbvision =
618 (struct usb_usbvision *) video_get_drvdata(dev);
619 606
620 if ((input >= usbvision->video_inputs) || (input < 0) ) 607 if ((input >= usbvision->video_inputs) || (input < 0) )
621 return -EINVAL; 608 return -EINVAL;
@@ -632,9 +619,8 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int input)
632 619
633static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) 620static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id)
634{ 621{
635 struct video_device *dev = video_devdata(file); 622 struct usb_usbvision *usbvision = video_drvdata(file);
636 struct usb_usbvision *usbvision = 623
637 (struct usb_usbvision *) video_get_drvdata(dev);
638 usbvision->tvnormId=*id; 624 usbvision->tvnormId=*id;
639 625
640 mutex_lock(&usbvision->lock); 626 mutex_lock(&usbvision->lock);
@@ -650,9 +636,7 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id)
650static int vidioc_g_tuner (struct file *file, void *priv, 636static int vidioc_g_tuner (struct file *file, void *priv,
651 struct v4l2_tuner *vt) 637 struct v4l2_tuner *vt)
652{ 638{
653 struct video_device *dev = video_devdata(file); 639 struct usb_usbvision *usbvision = video_drvdata(file);
654 struct usb_usbvision *usbvision =
655 (struct usb_usbvision *) video_get_drvdata(dev);
656 640
657 if (!usbvision->have_tuner || vt->index) // Only tuner 0 641 if (!usbvision->have_tuner || vt->index) // Only tuner 0
658 return -EINVAL; 642 return -EINVAL;
@@ -671,9 +655,7 @@ static int vidioc_g_tuner (struct file *file, void *priv,
671static int vidioc_s_tuner (struct file *file, void *priv, 655static int vidioc_s_tuner (struct file *file, void *priv,
672 struct v4l2_tuner *vt) 656 struct v4l2_tuner *vt)
673{ 657{
674 struct video_device *dev = video_devdata(file); 658 struct usb_usbvision *usbvision = video_drvdata(file);
675 struct usb_usbvision *usbvision =
676 (struct usb_usbvision *) video_get_drvdata(dev);
677 659
678 // Only no or one tuner for now 660 // Only no or one tuner for now
679 if (!usbvision->have_tuner || vt->index) 661 if (!usbvision->have_tuner || vt->index)
@@ -687,9 +669,7 @@ static int vidioc_s_tuner (struct file *file, void *priv,
687static int vidioc_g_frequency (struct file *file, void *priv, 669static int vidioc_g_frequency (struct file *file, void *priv,
688 struct v4l2_frequency *freq) 670 struct v4l2_frequency *freq)
689{ 671{
690 struct video_device *dev = video_devdata(file); 672 struct usb_usbvision *usbvision = video_drvdata(file);
691 struct usb_usbvision *usbvision =
692 (struct usb_usbvision *) video_get_drvdata(dev);
693 673
694 freq->tuner = 0; // Only one tuner 674 freq->tuner = 0; // Only one tuner
695 if(usbvision->radio) { 675 if(usbvision->radio) {
@@ -705,9 +685,7 @@ static int vidioc_g_frequency (struct file *file, void *priv,
705static int vidioc_s_frequency (struct file *file, void *priv, 685static int vidioc_s_frequency (struct file *file, void *priv,
706 struct v4l2_frequency *freq) 686 struct v4l2_frequency *freq)
707{ 687{
708 struct video_device *dev = video_devdata(file); 688 struct usb_usbvision *usbvision = video_drvdata(file);
709 struct usb_usbvision *usbvision =
710 (struct usb_usbvision *) video_get_drvdata(dev);
711 689
712 // Only no or one tuner for now 690 // Only no or one tuner for now
713 if (!usbvision->have_tuner || freq->tuner) 691 if (!usbvision->have_tuner || freq->tuner)
@@ -721,9 +699,7 @@ static int vidioc_s_frequency (struct file *file, void *priv,
721 699
722static int vidioc_g_audio (struct file *file, void *priv, struct v4l2_audio *a) 700static int vidioc_g_audio (struct file *file, void *priv, struct v4l2_audio *a)
723{ 701{
724 struct video_device *dev = video_devdata(file); 702 struct usb_usbvision *usbvision = video_drvdata(file);
725 struct usb_usbvision *usbvision =
726 (struct usb_usbvision *) video_get_drvdata(dev);
727 703
728 memset(a,0,sizeof(*a)); 704 memset(a,0,sizeof(*a));
729 if(usbvision->radio) { 705 if(usbvision->radio) {
@@ -748,9 +724,7 @@ static int vidioc_s_audio (struct file *file, void *fh,
748static int vidioc_queryctrl (struct file *file, void *priv, 724static int vidioc_queryctrl (struct file *file, void *priv,
749 struct v4l2_queryctrl *ctrl) 725 struct v4l2_queryctrl *ctrl)
750{ 726{
751 struct video_device *dev = video_devdata(file); 727 struct usb_usbvision *usbvision = video_drvdata(file);
752 struct usb_usbvision *usbvision =
753 (struct usb_usbvision *) video_get_drvdata(dev);
754 int id=ctrl->id; 728 int id=ctrl->id;
755 729
756 memset(ctrl,0,sizeof(*ctrl)); 730 memset(ctrl,0,sizeof(*ctrl));
@@ -767,9 +741,7 @@ static int vidioc_queryctrl (struct file *file, void *priv,
767static int vidioc_g_ctrl (struct file *file, void *priv, 741static int vidioc_g_ctrl (struct file *file, void *priv,
768 struct v4l2_control *ctrl) 742 struct v4l2_control *ctrl)
769{ 743{
770 struct video_device *dev = video_devdata(file); 744 struct usb_usbvision *usbvision = video_drvdata(file);
771 struct usb_usbvision *usbvision =
772 (struct usb_usbvision *) video_get_drvdata(dev);
773 call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl); 745 call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl);
774 746
775 return 0; 747 return 0;
@@ -778,9 +750,7 @@ static int vidioc_g_ctrl (struct file *file, void *priv,
778static int vidioc_s_ctrl (struct file *file, void *priv, 750static int vidioc_s_ctrl (struct file *file, void *priv,
779 struct v4l2_control *ctrl) 751 struct v4l2_control *ctrl)
780{ 752{
781 struct video_device *dev = video_devdata(file); 753 struct usb_usbvision *usbvision = video_drvdata(file);
782 struct usb_usbvision *usbvision =
783 (struct usb_usbvision *) video_get_drvdata(dev);
784 call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl); 754 call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl);
785 755
786 return 0; 756 return 0;
@@ -789,9 +759,7 @@ static int vidioc_s_ctrl (struct file *file, void *priv,
789static int vidioc_reqbufs (struct file *file, 759static int vidioc_reqbufs (struct file *file,
790 void *priv, struct v4l2_requestbuffers *vr) 760 void *priv, struct v4l2_requestbuffers *vr)
791{ 761{
792 struct video_device *dev = video_devdata(file); 762 struct usb_usbvision *usbvision = video_drvdata(file);
793 struct usb_usbvision *usbvision =
794 (struct usb_usbvision *) video_get_drvdata(dev);
795 int ret; 763 int ret;
796 764
797 RESTRICT_TO_RANGE(vr->count,1,USBVISION_NUMFRAMES); 765 RESTRICT_TO_RANGE(vr->count,1,USBVISION_NUMFRAMES);
@@ -819,9 +787,7 @@ static int vidioc_reqbufs (struct file *file,
819static int vidioc_querybuf (struct file *file, 787static int vidioc_querybuf (struct file *file,
820 void *priv, struct v4l2_buffer *vb) 788 void *priv, struct v4l2_buffer *vb)
821{ 789{
822 struct video_device *dev = video_devdata(file); 790 struct usb_usbvision *usbvision = video_drvdata(file);
823 struct usb_usbvision *usbvision =
824 (struct usb_usbvision *) video_get_drvdata(dev);
825 struct usbvision_frame *frame; 791 struct usbvision_frame *frame;
826 792
827 /* FIXME : must control 793 /* FIXME : must control
@@ -857,9 +823,7 @@ static int vidioc_querybuf (struct file *file,
857 823
858static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb) 824static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb)
859{ 825{
860 struct video_device *dev = video_devdata(file); 826 struct usb_usbvision *usbvision = video_drvdata(file);
861 struct usb_usbvision *usbvision =
862 (struct usb_usbvision *) video_get_drvdata(dev);
863 struct usbvision_frame *frame; 827 struct usbvision_frame *frame;
864 unsigned long lock_flags; 828 unsigned long lock_flags;
865 829
@@ -896,9 +860,7 @@ static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb)
896 860
897static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb) 861static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb)
898{ 862{
899 struct video_device *dev = video_devdata(file); 863 struct usb_usbvision *usbvision = video_drvdata(file);
900 struct usb_usbvision *usbvision =
901 (struct usb_usbvision *) video_get_drvdata(dev);
902 int ret; 864 int ret;
903 struct usbvision_frame *f; 865 struct usbvision_frame *f;
904 unsigned long lock_flags; 866 unsigned long lock_flags;
@@ -939,9 +901,7 @@ static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb)
939 901
940static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) 902static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
941{ 903{
942 struct video_device *dev = video_devdata(file); 904 struct usb_usbvision *usbvision = video_drvdata(file);
943 struct usb_usbvision *usbvision =
944 (struct usb_usbvision *) video_get_drvdata(dev);
945 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE; 905 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE;
946 906
947 usbvision->streaming = Stream_On; 907 usbvision->streaming = Stream_On;
@@ -953,9 +913,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
953static int vidioc_streamoff(struct file *file, 913static int vidioc_streamoff(struct file *file,
954 void *priv, enum v4l2_buf_type type) 914 void *priv, enum v4l2_buf_type type)
955{ 915{
956 struct video_device *dev = video_devdata(file); 916 struct usb_usbvision *usbvision = video_drvdata(file);
957 struct usb_usbvision *usbvision =
958 (struct usb_usbvision *) video_get_drvdata(dev);
959 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE; 917 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE;
960 918
961 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 919 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -988,9 +946,7 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv,
988static int vidioc_g_fmt_vid_cap (struct file *file, void *priv, 946static int vidioc_g_fmt_vid_cap (struct file *file, void *priv,
989 struct v4l2_format *vf) 947 struct v4l2_format *vf)
990{ 948{
991 struct video_device *dev = video_devdata(file); 949 struct usb_usbvision *usbvision = video_drvdata(file);
992 struct usb_usbvision *usbvision =
993 (struct usb_usbvision *) video_get_drvdata(dev);
994 vf->fmt.pix.width = usbvision->curwidth; 950 vf->fmt.pix.width = usbvision->curwidth;
995 vf->fmt.pix.height = usbvision->curheight; 951 vf->fmt.pix.height = usbvision->curheight;
996 vf->fmt.pix.pixelformat = usbvision->palette.format; 952 vf->fmt.pix.pixelformat = usbvision->palette.format;
@@ -1006,9 +962,7 @@ static int vidioc_g_fmt_vid_cap (struct file *file, void *priv,
1006static int vidioc_try_fmt_vid_cap (struct file *file, void *priv, 962static int vidioc_try_fmt_vid_cap (struct file *file, void *priv,
1007 struct v4l2_format *vf) 963 struct v4l2_format *vf)
1008{ 964{
1009 struct video_device *dev = video_devdata(file); 965 struct usb_usbvision *usbvision = video_drvdata(file);
1010 struct usb_usbvision *usbvision =
1011 (struct usb_usbvision *) video_get_drvdata(dev);
1012 int formatIdx; 966 int formatIdx;
1013 967
1014 /* Find requested format in available ones */ 968 /* Find requested format in available ones */
@@ -1036,9 +990,7 @@ static int vidioc_try_fmt_vid_cap (struct file *file, void *priv,
1036static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, 990static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1037 struct v4l2_format *vf) 991 struct v4l2_format *vf)
1038{ 992{
1039 struct video_device *dev = video_devdata(file); 993 struct usb_usbvision *usbvision = video_drvdata(file);
1040 struct usb_usbvision *usbvision =
1041 (struct usb_usbvision *) video_get_drvdata(dev);
1042 int ret; 994 int ret;
1043 995
1044 if( 0 != (ret=vidioc_try_fmt_vid_cap (file, priv, vf)) ) { 996 if( 0 != (ret=vidioc_try_fmt_vid_cap (file, priv, vf)) ) {
@@ -1066,9 +1018,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1066static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, 1018static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf,
1067 size_t count, loff_t *ppos) 1019 size_t count, loff_t *ppos)
1068{ 1020{
1069 struct video_device *dev = video_devdata(file); 1021 struct usb_usbvision *usbvision = video_drvdata(file);
1070 struct usb_usbvision *usbvision =
1071 (struct usb_usbvision *) video_get_drvdata(dev);
1072 int noblock = file->f_flags & O_NONBLOCK; 1022 int noblock = file->f_flags & O_NONBLOCK;
1073 unsigned long lock_flags; 1023 unsigned long lock_flags;
1074 1024
@@ -1177,10 +1127,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
1177 start = vma->vm_start; 1127 start = vma->vm_start;
1178 void *pos; 1128 void *pos;
1179 u32 i; 1129 u32 i;
1180 1130 struct usb_usbvision *usbvision = video_drvdata(file);
1181 struct video_device *dev = video_devdata(file);
1182 struct usb_usbvision *usbvision =
1183 (struct usb_usbvision *) video_get_drvdata(dev);
1184 1131
1185 PDEBUG(DBG_MMAP, "mmap"); 1132 PDEBUG(DBG_MMAP, "mmap");
1186 1133
@@ -1237,9 +1184,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
1237 */ 1184 */
1238static int usbvision_radio_open(struct inode *inode, struct file *file) 1185static int usbvision_radio_open(struct inode *inode, struct file *file)
1239{ 1186{
1240 struct video_device *dev = video_devdata(file); 1187 struct usb_usbvision *usbvision = video_drvdata(file);
1241 struct usb_usbvision *usbvision =
1242 (struct usb_usbvision *) video_get_drvdata(dev);
1243 int errCode = 0; 1188 int errCode = 0;
1244 1189
1245 PDEBUG(DBG_IO, "%s:", __func__); 1190 PDEBUG(DBG_IO, "%s:", __func__);
@@ -1289,9 +1234,7 @@ out:
1289 1234
1290static int usbvision_radio_close(struct inode *inode, struct file *file) 1235static int usbvision_radio_close(struct inode *inode, struct file *file)
1291{ 1236{
1292 struct video_device *dev = video_devdata(file); 1237 struct usb_usbvision *usbvision = video_drvdata(file);
1293 struct usb_usbvision *usbvision =
1294 (struct usb_usbvision *) video_get_drvdata(dev);
1295 int errCode = 0; 1238 int errCode = 0;
1296 1239
1297 PDEBUG(DBG_IO, ""); 1240 PDEBUG(DBG_IO, "");