aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2016-07-03 07:14:17 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-08-24 08:54:30 -0400
commit1f981a48dc89c40019819464d71185cc37096dfa (patch)
treef719b9c534a0b84049db2064d04b521f2653bfb0
parent516aca33333d8ea61c1bc0879ed080cbdf196199 (diff)
[media] pvrusb2: convert g/s_crop to g/s_selection
This is part of a final push to convert all drivers to g/s_selection. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-v4l2.c81
1 files changed, 51 insertions, 30 deletions
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index 81f788b7b242..2cc4d2b6f810 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -719,64 +719,85 @@ static int pvr2_cropcap(struct file *file, void *priv, struct v4l2_cropcap *cap)
719 return ret; 719 return ret;
720} 720}
721 721
722static int pvr2_g_crop(struct file *file, void *priv, struct v4l2_crop *crop) 722static int pvr2_g_selection(struct file *file, void *priv,
723 struct v4l2_selection *sel)
723{ 724{
724 struct pvr2_v4l2_fh *fh = file->private_data; 725 struct pvr2_v4l2_fh *fh = file->private_data;
725 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; 726 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
727 struct v4l2_cropcap cap;
726 int val = 0; 728 int val = 0;
727 int ret; 729 int ret;
728 730
729 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 731 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
730 return -EINVAL; 732 return -EINVAL;
731 ret = pvr2_ctrl_get_value( 733
732 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPL), &val); 734 cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
733 if (ret != 0) 735
734 return -EINVAL; 736 switch (sel->target) {
735 crop->c.left = val; 737 case V4L2_SEL_TGT_CROP:
736 ret = pvr2_ctrl_get_value( 738 ret = pvr2_ctrl_get_value(
737 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPT), &val); 739 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPL), &val);
738 if (ret != 0) 740 if (ret != 0)
739 return -EINVAL; 741 return -EINVAL;
740 crop->c.top = val; 742 sel->r.left = val;
741 ret = pvr2_ctrl_get_value( 743 ret = pvr2_ctrl_get_value(
742 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPW), &val); 744 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPT), &val);
743 if (ret != 0) 745 if (ret != 0)
744 return -EINVAL; 746 return -EINVAL;
745 crop->c.width = val; 747 sel->r.top = val;
746 ret = pvr2_ctrl_get_value( 748 ret = pvr2_ctrl_get_value(
747 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPH), &val); 749 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPW), &val);
748 if (ret != 0) 750 if (ret != 0)
751 return -EINVAL;
752 sel->r.width = val;
753 ret = pvr2_ctrl_get_value(
754 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPH), &val);
755 if (ret != 0)
756 return -EINVAL;
757 sel->r.height = val;
758 break;
759 case V4L2_SEL_TGT_CROP_DEFAULT:
760 ret = pvr2_hdw_get_cropcap(hdw, &cap);
761 sel->r = cap.defrect;
762 break;
763 case V4L2_SEL_TGT_CROP_BOUNDS:
764 ret = pvr2_hdw_get_cropcap(hdw, &cap);
765 sel->r = cap.bounds;
766 break;
767 default:
749 return -EINVAL; 768 return -EINVAL;
750 crop->c.height = val; 769 }
751 return 0; 770 return ret;
752} 771}
753 772
754static int pvr2_s_crop(struct file *file, void *priv, const struct v4l2_crop *crop) 773static int pvr2_s_selection(struct file *file, void *priv,
774 struct v4l2_selection *sel)
755{ 775{
756 struct pvr2_v4l2_fh *fh = file->private_data; 776 struct pvr2_v4l2_fh *fh = file->private_data;
757 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; 777 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
758 int ret; 778 int ret;
759 779
760 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 780 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
781 sel->target != V4L2_SEL_TGT_CROP)
761 return -EINVAL; 782 return -EINVAL;
762 ret = pvr2_ctrl_set_value( 783 ret = pvr2_ctrl_set_value(
763 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPL), 784 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPL),
764 crop->c.left); 785 sel->r.left);
765 if (ret != 0) 786 if (ret != 0)
766 return -EINVAL; 787 return -EINVAL;
767 ret = pvr2_ctrl_set_value( 788 ret = pvr2_ctrl_set_value(
768 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPT), 789 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPT),
769 crop->c.top); 790 sel->r.top);
770 if (ret != 0) 791 if (ret != 0)
771 return -EINVAL; 792 return -EINVAL;
772 ret = pvr2_ctrl_set_value( 793 ret = pvr2_ctrl_set_value(
773 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPW), 794 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPW),
774 crop->c.width); 795 sel->r.width);
775 if (ret != 0) 796 if (ret != 0)
776 return -EINVAL; 797 return -EINVAL;
777 ret = pvr2_ctrl_set_value( 798 ret = pvr2_ctrl_set_value(
778 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPH), 799 pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPH),
779 crop->c.height); 800 sel->r.height);
780 if (ret != 0) 801 if (ret != 0)
781 return -EINVAL; 802 return -EINVAL;
782 return 0; 803 return 0;
@@ -798,8 +819,8 @@ static const struct v4l2_ioctl_ops pvr2_ioctl_ops = {
798 .vidioc_enumaudio = pvr2_enumaudio, 819 .vidioc_enumaudio = pvr2_enumaudio,
799 .vidioc_enum_input = pvr2_enum_input, 820 .vidioc_enum_input = pvr2_enum_input,
800 .vidioc_cropcap = pvr2_cropcap, 821 .vidioc_cropcap = pvr2_cropcap,
801 .vidioc_s_crop = pvr2_s_crop, 822 .vidioc_s_selection = pvr2_s_selection,
802 .vidioc_g_crop = pvr2_g_crop, 823 .vidioc_g_selection = pvr2_g_selection,
803 .vidioc_g_input = pvr2_g_input, 824 .vidioc_g_input = pvr2_g_input,
804 .vidioc_s_input = pvr2_s_input, 825 .vidioc_s_input = pvr2_s_input,
805 .vidioc_g_frequency = pvr2_g_frequency, 826 .vidioc_g_frequency = pvr2_g_frequency,