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.c122
1 files changed, 31 insertions, 91 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index b76295a5be8b..782ee643601c 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -360,9 +360,7 @@ static void usbvision_remove_sysfs(struct video_device *vdev)
360 */ 360 */
361static int usbvision_v4l2_open(struct inode *inode, struct file *file) 361static int usbvision_v4l2_open(struct inode *inode, struct file *file)
362{ 362{
363 struct video_device *dev = video_devdata(file); 363 struct usb_usbvision *usbvision = video_drvdata(file);
364 struct usb_usbvision *usbvision =
365 (struct usb_usbvision *) video_get_drvdata(dev);
366 int errCode = 0; 364 int errCode = 0;
367 365
368 PDEBUG(DBG_IO, "open"); 366 PDEBUG(DBG_IO, "open");
@@ -439,9 +437,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
439 */ 437 */
440static int usbvision_v4l2_close(struct inode *inode, struct file *file) 438static int usbvision_v4l2_close(struct inode *inode, struct file *file)
441{ 439{
442 struct video_device *dev = video_devdata(file); 440 struct usb_usbvision *usbvision = video_drvdata(file);
443 struct usb_usbvision *usbvision =
444 (struct usb_usbvision *) video_get_drvdata(dev);
445 441
446 PDEBUG(DBG_IO, "close"); 442 PDEBUG(DBG_IO, "close");
447 mutex_lock(&usbvision->lock); 443 mutex_lock(&usbvision->lock);
@@ -486,9 +482,7 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file)
486static int vidioc_g_register (struct file *file, void *priv, 482static int vidioc_g_register (struct file *file, void *priv,
487 struct v4l2_register *reg) 483 struct v4l2_register *reg)
488{ 484{
489 struct video_device *dev = video_devdata(file); 485 struct usb_usbvision *usbvision = video_drvdata(file);
490 struct usb_usbvision *usbvision =
491 (struct usb_usbvision *) video_get_drvdata(dev);
492 int errCode; 486 int errCode;
493 487
494 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 488 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
@@ -507,9 +501,7 @@ static int vidioc_g_register (struct file *file, void *priv,
507static int vidioc_s_register (struct file *file, void *priv, 501static int vidioc_s_register (struct file *file, void *priv,
508 struct v4l2_register *reg) 502 struct v4l2_register *reg)
509{ 503{
510 struct video_device *dev = video_devdata(file); 504 struct usb_usbvision *usbvision = video_drvdata(file);
511 struct usb_usbvision *usbvision =
512 (struct usb_usbvision *) video_get_drvdata(dev);
513 int errCode; 505 int errCode;
514 506
515 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 507 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
@@ -528,9 +520,7 @@ static int vidioc_s_register (struct file *file, void *priv,
528static int vidioc_querycap (struct file *file, void *priv, 520static int vidioc_querycap (struct file *file, void *priv,
529 struct v4l2_capability *vc) 521 struct v4l2_capability *vc)
530{ 522{
531 struct video_device *dev = video_devdata(file); 523 struct usb_usbvision *usbvision = video_drvdata(file);
532 struct usb_usbvision *usbvision =
533 (struct usb_usbvision *) video_get_drvdata(dev);
534 524
535 strlcpy(vc->driver, "USBVision", sizeof(vc->driver)); 525 strlcpy(vc->driver, "USBVision", sizeof(vc->driver));
536 strlcpy(vc->card, 526 strlcpy(vc->card,
@@ -550,9 +540,7 @@ static int vidioc_querycap (struct file *file, void *priv,
550static int vidioc_enum_input (struct file *file, void *priv, 540static int vidioc_enum_input (struct file *file, void *priv,
551 struct v4l2_input *vi) 541 struct v4l2_input *vi)
552{ 542{
553 struct video_device *dev = video_devdata(file); 543 struct usb_usbvision *usbvision = video_drvdata(file);
554 struct usb_usbvision *usbvision =
555 (struct usb_usbvision *) video_get_drvdata(dev);
556 int chan; 544 int chan;
557 545
558 if ((vi->index >= usbvision->video_inputs) || (vi->index < 0) ) 546 if ((vi->index >= usbvision->video_inputs) || (vi->index < 0) )
@@ -605,9 +593,7 @@ static int vidioc_enum_input (struct file *file, void *priv,
605 593
606static int vidioc_g_input (struct file *file, void *priv, unsigned int *input) 594static int vidioc_g_input (struct file *file, void *priv, unsigned int *input)
607{ 595{
608 struct video_device *dev = video_devdata(file); 596 struct usb_usbvision *usbvision = video_drvdata(file);
609 struct usb_usbvision *usbvision =
610 (struct usb_usbvision *) video_get_drvdata(dev);
611 597
612 *input = usbvision->ctl_input; 598 *input = usbvision->ctl_input;
613 return 0; 599 return 0;
@@ -615,9 +601,7 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *input)
615 601
616static int vidioc_s_input (struct file *file, void *priv, unsigned int input) 602static int vidioc_s_input (struct file *file, void *priv, unsigned int input)
617{ 603{
618 struct video_device *dev = video_devdata(file); 604 struct usb_usbvision *usbvision = video_drvdata(file);
619 struct usb_usbvision *usbvision =
620 (struct usb_usbvision *) video_get_drvdata(dev);
621 605
622 if ((input >= usbvision->video_inputs) || (input < 0) ) 606 if ((input >= usbvision->video_inputs) || (input < 0) )
623 return -EINVAL; 607 return -EINVAL;
@@ -634,9 +618,8 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int input)
634 618
635static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) 619static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id)
636{ 620{
637 struct video_device *dev = video_devdata(file); 621 struct usb_usbvision *usbvision = video_drvdata(file);
638 struct usb_usbvision *usbvision = 622
639 (struct usb_usbvision *) video_get_drvdata(dev);
640 usbvision->tvnormId=*id; 623 usbvision->tvnormId=*id;
641 624
642 mutex_lock(&usbvision->lock); 625 mutex_lock(&usbvision->lock);
@@ -652,9 +635,7 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id)
652static int vidioc_g_tuner (struct file *file, void *priv, 635static int vidioc_g_tuner (struct file *file, void *priv,
653 struct v4l2_tuner *vt) 636 struct v4l2_tuner *vt)
654{ 637{
655 struct video_device *dev = video_devdata(file); 638 struct usb_usbvision *usbvision = video_drvdata(file);
656 struct usb_usbvision *usbvision =
657 (struct usb_usbvision *) video_get_drvdata(dev);
658 639
659 if (!usbvision->have_tuner || vt->index) // Only tuner 0 640 if (!usbvision->have_tuner || vt->index) // Only tuner 0
660 return -EINVAL; 641 return -EINVAL;
@@ -673,9 +654,7 @@ static int vidioc_g_tuner (struct file *file, void *priv,
673static int vidioc_s_tuner (struct file *file, void *priv, 654static int vidioc_s_tuner (struct file *file, void *priv,
674 struct v4l2_tuner *vt) 655 struct v4l2_tuner *vt)
675{ 656{
676 struct video_device *dev = video_devdata(file); 657 struct usb_usbvision *usbvision = video_drvdata(file);
677 struct usb_usbvision *usbvision =
678 (struct usb_usbvision *) video_get_drvdata(dev);
679 658
680 // Only no or one tuner for now 659 // Only no or one tuner for now
681 if (!usbvision->have_tuner || vt->index) 660 if (!usbvision->have_tuner || vt->index)
@@ -689,9 +668,7 @@ static int vidioc_s_tuner (struct file *file, void *priv,
689static int vidioc_g_frequency (struct file *file, void *priv, 668static int vidioc_g_frequency (struct file *file, void *priv,
690 struct v4l2_frequency *freq) 669 struct v4l2_frequency *freq)
691{ 670{
692 struct video_device *dev = video_devdata(file); 671 struct usb_usbvision *usbvision = video_drvdata(file);
693 struct usb_usbvision *usbvision =
694 (struct usb_usbvision *) video_get_drvdata(dev);
695 672
696 freq->tuner = 0; // Only one tuner 673 freq->tuner = 0; // Only one tuner
697 if(usbvision->radio) { 674 if(usbvision->radio) {
@@ -707,9 +684,7 @@ static int vidioc_g_frequency (struct file *file, void *priv,
707static int vidioc_s_frequency (struct file *file, void *priv, 684static int vidioc_s_frequency (struct file *file, void *priv,
708 struct v4l2_frequency *freq) 685 struct v4l2_frequency *freq)
709{ 686{
710 struct video_device *dev = video_devdata(file); 687 struct usb_usbvision *usbvision = video_drvdata(file);
711 struct usb_usbvision *usbvision =
712 (struct usb_usbvision *) video_get_drvdata(dev);
713 688
714 // Only no or one tuner for now 689 // Only no or one tuner for now
715 if (!usbvision->have_tuner || freq->tuner) 690 if (!usbvision->have_tuner || freq->tuner)
@@ -723,9 +698,7 @@ static int vidioc_s_frequency (struct file *file, void *priv,
723 698
724static int vidioc_g_audio (struct file *file, void *priv, struct v4l2_audio *a) 699static int vidioc_g_audio (struct file *file, void *priv, struct v4l2_audio *a)
725{ 700{
726 struct video_device *dev = video_devdata(file); 701 struct usb_usbvision *usbvision = video_drvdata(file);
727 struct usb_usbvision *usbvision =
728 (struct usb_usbvision *) video_get_drvdata(dev);
729 702
730 memset(a,0,sizeof(*a)); 703 memset(a,0,sizeof(*a));
731 if(usbvision->radio) { 704 if(usbvision->radio) {
@@ -750,9 +723,7 @@ static int vidioc_s_audio (struct file *file, void *fh,
750static int vidioc_queryctrl (struct file *file, void *priv, 723static int vidioc_queryctrl (struct file *file, void *priv,
751 struct v4l2_queryctrl *ctrl) 724 struct v4l2_queryctrl *ctrl)
752{ 725{
753 struct video_device *dev = video_devdata(file); 726 struct usb_usbvision *usbvision = video_drvdata(file);
754 struct usb_usbvision *usbvision =
755 (struct usb_usbvision *) video_get_drvdata(dev);
756 int id=ctrl->id; 727 int id=ctrl->id;
757 728
758 memset(ctrl,0,sizeof(*ctrl)); 729 memset(ctrl,0,sizeof(*ctrl));
@@ -769,9 +740,7 @@ static int vidioc_queryctrl (struct file *file, void *priv,
769static int vidioc_g_ctrl (struct file *file, void *priv, 740static int vidioc_g_ctrl (struct file *file, void *priv,
770 struct v4l2_control *ctrl) 741 struct v4l2_control *ctrl)
771{ 742{
772 struct video_device *dev = video_devdata(file); 743 struct usb_usbvision *usbvision = video_drvdata(file);
773 struct usb_usbvision *usbvision =
774 (struct usb_usbvision *) video_get_drvdata(dev);
775 call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl); 744 call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl);
776 745
777 return 0; 746 return 0;
@@ -780,9 +749,7 @@ static int vidioc_g_ctrl (struct file *file, void *priv,
780static int vidioc_s_ctrl (struct file *file, void *priv, 749static int vidioc_s_ctrl (struct file *file, void *priv,
781 struct v4l2_control *ctrl) 750 struct v4l2_control *ctrl)
782{ 751{
783 struct video_device *dev = video_devdata(file); 752 struct usb_usbvision *usbvision = video_drvdata(file);
784 struct usb_usbvision *usbvision =
785 (struct usb_usbvision *) video_get_drvdata(dev);
786 call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl); 753 call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl);
787 754
788 return 0; 755 return 0;
@@ -791,9 +758,7 @@ static int vidioc_s_ctrl (struct file *file, void *priv,
791static int vidioc_reqbufs (struct file *file, 758static int vidioc_reqbufs (struct file *file,
792 void *priv, struct v4l2_requestbuffers *vr) 759 void *priv, struct v4l2_requestbuffers *vr)
793{ 760{
794 struct video_device *dev = video_devdata(file); 761 struct usb_usbvision *usbvision = video_drvdata(file);
795 struct usb_usbvision *usbvision =
796 (struct usb_usbvision *) video_get_drvdata(dev);
797 int ret; 762 int ret;
798 763
799 RESTRICT_TO_RANGE(vr->count,1,USBVISION_NUMFRAMES); 764 RESTRICT_TO_RANGE(vr->count,1,USBVISION_NUMFRAMES);
@@ -821,9 +786,7 @@ static int vidioc_reqbufs (struct file *file,
821static int vidioc_querybuf (struct file *file, 786static int vidioc_querybuf (struct file *file,
822 void *priv, struct v4l2_buffer *vb) 787 void *priv, struct v4l2_buffer *vb)
823{ 788{
824 struct video_device *dev = video_devdata(file); 789 struct usb_usbvision *usbvision = video_drvdata(file);
825 struct usb_usbvision *usbvision =
826 (struct usb_usbvision *) video_get_drvdata(dev);
827 struct usbvision_frame *frame; 790 struct usbvision_frame *frame;
828 791
829 /* FIXME : must control 792 /* FIXME : must control
@@ -859,9 +822,7 @@ static int vidioc_querybuf (struct file *file,
859 822
860static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb) 823static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb)
861{ 824{
862 struct video_device *dev = video_devdata(file); 825 struct usb_usbvision *usbvision = video_drvdata(file);
863 struct usb_usbvision *usbvision =
864 (struct usb_usbvision *) video_get_drvdata(dev);
865 struct usbvision_frame *frame; 826 struct usbvision_frame *frame;
866 unsigned long lock_flags; 827 unsigned long lock_flags;
867 828
@@ -898,9 +859,7 @@ static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb)
898 859
899static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb) 860static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb)
900{ 861{
901 struct video_device *dev = video_devdata(file); 862 struct usb_usbvision *usbvision = video_drvdata(file);
902 struct usb_usbvision *usbvision =
903 (struct usb_usbvision *) video_get_drvdata(dev);
904 int ret; 863 int ret;
905 struct usbvision_frame *f; 864 struct usbvision_frame *f;
906 unsigned long lock_flags; 865 unsigned long lock_flags;
@@ -941,9 +900,7 @@ static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb)
941 900
942static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) 901static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
943{ 902{
944 struct video_device *dev = video_devdata(file); 903 struct usb_usbvision *usbvision = video_drvdata(file);
945 struct usb_usbvision *usbvision =
946 (struct usb_usbvision *) video_get_drvdata(dev);
947 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE; 904 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE;
948 905
949 usbvision->streaming = Stream_On; 906 usbvision->streaming = Stream_On;
@@ -955,9 +912,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
955static int vidioc_streamoff(struct file *file, 912static int vidioc_streamoff(struct file *file,
956 void *priv, enum v4l2_buf_type type) 913 void *priv, enum v4l2_buf_type type)
957{ 914{
958 struct video_device *dev = video_devdata(file); 915 struct usb_usbvision *usbvision = video_drvdata(file);
959 struct usb_usbvision *usbvision =
960 (struct usb_usbvision *) video_get_drvdata(dev);
961 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE; 916 int b=V4L2_BUF_TYPE_VIDEO_CAPTURE;
962 917
963 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 918 if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -990,9 +945,7 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv,
990static int vidioc_g_fmt_vid_cap (struct file *file, void *priv, 945static int vidioc_g_fmt_vid_cap (struct file *file, void *priv,
991 struct v4l2_format *vf) 946 struct v4l2_format *vf)
992{ 947{
993 struct video_device *dev = video_devdata(file); 948 struct usb_usbvision *usbvision = video_drvdata(file);
994 struct usb_usbvision *usbvision =
995 (struct usb_usbvision *) video_get_drvdata(dev);
996 vf->fmt.pix.width = usbvision->curwidth; 949 vf->fmt.pix.width = usbvision->curwidth;
997 vf->fmt.pix.height = usbvision->curheight; 950 vf->fmt.pix.height = usbvision->curheight;
998 vf->fmt.pix.pixelformat = usbvision->palette.format; 951 vf->fmt.pix.pixelformat = usbvision->palette.format;
@@ -1008,9 +961,7 @@ static int vidioc_g_fmt_vid_cap (struct file *file, void *priv,
1008static int vidioc_try_fmt_vid_cap (struct file *file, void *priv, 961static int vidioc_try_fmt_vid_cap (struct file *file, void *priv,
1009 struct v4l2_format *vf) 962 struct v4l2_format *vf)
1010{ 963{
1011 struct video_device *dev = video_devdata(file); 964 struct usb_usbvision *usbvision = video_drvdata(file);
1012 struct usb_usbvision *usbvision =
1013 (struct usb_usbvision *) video_get_drvdata(dev);
1014 int formatIdx; 965 int formatIdx;
1015 966
1016 /* Find requested format in available ones */ 967 /* Find requested format in available ones */
@@ -1038,9 +989,7 @@ static int vidioc_try_fmt_vid_cap (struct file *file, void *priv,
1038static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, 989static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1039 struct v4l2_format *vf) 990 struct v4l2_format *vf)
1040{ 991{
1041 struct video_device *dev = video_devdata(file); 992 struct usb_usbvision *usbvision = video_drvdata(file);
1042 struct usb_usbvision *usbvision =
1043 (struct usb_usbvision *) video_get_drvdata(dev);
1044 int ret; 993 int ret;
1045 994
1046 if( 0 != (ret=vidioc_try_fmt_vid_cap (file, priv, vf)) ) { 995 if( 0 != (ret=vidioc_try_fmt_vid_cap (file, priv, vf)) ) {
@@ -1068,9 +1017,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1068static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, 1017static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf,
1069 size_t count, loff_t *ppos) 1018 size_t count, loff_t *ppos)
1070{ 1019{
1071 struct video_device *dev = video_devdata(file); 1020 struct usb_usbvision *usbvision = video_drvdata(file);
1072 struct usb_usbvision *usbvision =
1073 (struct usb_usbvision *) video_get_drvdata(dev);
1074 int noblock = file->f_flags & O_NONBLOCK; 1021 int noblock = file->f_flags & O_NONBLOCK;
1075 unsigned long lock_flags; 1022 unsigned long lock_flags;
1076 1023
@@ -1179,10 +1126,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
1179 start = vma->vm_start; 1126 start = vma->vm_start;
1180 void *pos; 1127 void *pos;
1181 u32 i; 1128 u32 i;
1182 1129 struct usb_usbvision *usbvision = video_drvdata(file);
1183 struct video_device *dev = video_devdata(file);
1184 struct usb_usbvision *usbvision =
1185 (struct usb_usbvision *) video_get_drvdata(dev);
1186 1130
1187 PDEBUG(DBG_MMAP, "mmap"); 1131 PDEBUG(DBG_MMAP, "mmap");
1188 1132
@@ -1239,9 +1183,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
1239 */ 1183 */
1240static int usbvision_radio_open(struct inode *inode, struct file *file) 1184static int usbvision_radio_open(struct inode *inode, struct file *file)
1241{ 1185{
1242 struct video_device *dev = video_devdata(file); 1186 struct usb_usbvision *usbvision = video_drvdata(file);
1243 struct usb_usbvision *usbvision =
1244 (struct usb_usbvision *) video_get_drvdata(dev);
1245 int errCode = 0; 1187 int errCode = 0;
1246 1188
1247 PDEBUG(DBG_IO, "%s:", __func__); 1189 PDEBUG(DBG_IO, "%s:", __func__);
@@ -1291,9 +1233,7 @@ out:
1291 1233
1292static int usbvision_radio_close(struct inode *inode, struct file *file) 1234static int usbvision_radio_close(struct inode *inode, struct file *file)
1293{ 1235{
1294 struct video_device *dev = video_devdata(file); 1236 struct usb_usbvision *usbvision = video_drvdata(file);
1295 struct usb_usbvision *usbvision =
1296 (struct usb_usbvision *) video_get_drvdata(dev);
1297 int errCode = 0; 1237 int errCode = 0;
1298 1238
1299 PDEBUG(DBG_IO, ""); 1239 PDEBUG(DBG_IO, "");