aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2016-07-03 06:05:16 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-08-24 08:48:22 -0400
commitb714fb006482f23d4439e6916ce922225aa3fe38 (patch)
treecb50108cef20d5000b4d43f57f658401888cad3f
parent10d5509c8d50a2c2f761a08a616530dced35e2d8 (diff)
[media] bttv: 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> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c59
-rw-r--r--drivers/media/pci/bt8xx/bttvp.h2
2 files changed, 40 insertions, 21 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index df54e17ef864..97b91a9f9fa9 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -2804,30 +2804,44 @@ static int bttv_cropcap(struct file *file, void *priv,
2804 cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) 2804 cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
2805 return -EINVAL; 2805 return -EINVAL;
2806 2806
2807 *cap = bttv_tvnorms[btv->tvnorm].cropcap; 2807 /* defrect and bounds are set via g_selection */
2808 cap->pixelaspect = bttv_tvnorms[btv->tvnorm].cropcap.pixelaspect;
2808 2809
2809 return 0; 2810 return 0;
2810} 2811}
2811 2812
2812static int bttv_g_crop(struct file *file, void *f, struct v4l2_crop *crop) 2813static int bttv_g_selection(struct file *file, void *f, struct v4l2_selection *sel)
2813{ 2814{
2814 struct bttv_fh *fh = f; 2815 struct bttv_fh *fh = f;
2815 struct bttv *btv = fh->btv; 2816 struct bttv *btv = fh->btv;
2816 2817
2817 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && 2818 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
2818 crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) 2819 sel->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
2819 return -EINVAL; 2820 return -EINVAL;
2820 2821
2821 /* No fh->do_crop = 1; because btv->crop[1] may be 2822 switch (sel->target) {
2822 inconsistent with fh->width or fh->height and apps 2823 case V4L2_SEL_TGT_CROP:
2823 do not expect a change here. */ 2824 /*
2824 2825 * No fh->do_crop = 1; because btv->crop[1] may be
2825 crop->c = btv->crop[!!fh->do_crop].rect; 2826 * inconsistent with fh->width or fh->height and apps
2827 * do not expect a change here.
2828 */
2829 sel->r = btv->crop[!!fh->do_crop].rect;
2830 break;
2831 case V4L2_SEL_TGT_CROP_DEFAULT:
2832 sel->r = bttv_tvnorms[btv->tvnorm].cropcap.defrect;
2833 break;
2834 case V4L2_SEL_TGT_CROP_BOUNDS:
2835 sel->r = bttv_tvnorms[btv->tvnorm].cropcap.bounds;
2836 break;
2837 default:
2838 return -EINVAL;
2839 }
2826 2840
2827 return 0; 2841 return 0;
2828} 2842}
2829 2843
2830static int bttv_s_crop(struct file *file, void *f, const struct v4l2_crop *crop) 2844static int bttv_s_selection(struct file *file, void *f, struct v4l2_selection *sel)
2831{ 2845{
2832 struct bttv_fh *fh = f; 2846 struct bttv_fh *fh = f;
2833 struct bttv *btv = fh->btv; 2847 struct bttv *btv = fh->btv;
@@ -2839,8 +2853,11 @@ static int bttv_s_crop(struct file *file, void *f, const struct v4l2_crop *crop)
2839 __s32 b_right; 2853 __s32 b_right;
2840 __s32 b_bottom; 2854 __s32 b_bottom;
2841 2855
2842 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && 2856 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
2843 crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) 2857 sel->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
2858 return -EINVAL;
2859
2860 if (sel->target != V4L2_SEL_TGT_CROP)
2844 return -EINVAL; 2861 return -EINVAL;
2845 2862
2846 /* Make sure tvnorm, vbi_end and the current cropping 2863 /* Make sure tvnorm, vbi_end and the current cropping
@@ -2864,22 +2881,24 @@ static int bttv_s_crop(struct file *file, void *f, const struct v4l2_crop *crop)
2864 } 2881 }
2865 2882
2866 /* Min. scaled size 48 x 32. */ 2883 /* Min. scaled size 48 x 32. */
2867 c.rect.left = clamp_t(s32, crop->c.left, b_left, b_right - 48); 2884 c.rect.left = clamp_t(s32, sel->r.left, b_left, b_right - 48);
2868 c.rect.left = min(c.rect.left, (__s32) MAX_HDELAY); 2885 c.rect.left = min(c.rect.left, (__s32) MAX_HDELAY);
2869 2886
2870 c.rect.width = clamp_t(s32, crop->c.width, 2887 c.rect.width = clamp_t(s32, sel->r.width,
2871 48, b_right - c.rect.left); 2888 48, b_right - c.rect.left);
2872 2889
2873 c.rect.top = clamp_t(s32, crop->c.top, b_top, b_bottom - 32); 2890 c.rect.top = clamp_t(s32, sel->r.top, b_top, b_bottom - 32);
2874 /* Top and height must be a multiple of two. */ 2891 /* Top and height must be a multiple of two. */
2875 c.rect.top = (c.rect.top + 1) & ~1; 2892 c.rect.top = (c.rect.top + 1) & ~1;
2876 2893
2877 c.rect.height = clamp_t(s32, crop->c.height, 2894 c.rect.height = clamp_t(s32, sel->r.height,
2878 32, b_bottom - c.rect.top); 2895 32, b_bottom - c.rect.top);
2879 c.rect.height = (c.rect.height + 1) & ~1; 2896 c.rect.height = (c.rect.height + 1) & ~1;
2880 2897
2881 bttv_crop_calc_limits(&c); 2898 bttv_crop_calc_limits(&c);
2882 2899
2900 sel->r = c.rect;
2901
2883 btv->crop[1] = c; 2902 btv->crop[1] = c;
2884 2903
2885 fh->do_crop = 1; 2904 fh->do_crop = 1;
@@ -3047,10 +3066,10 @@ static int bttv_open(struct file *file)
3047 which only change on request. These are stored in btv->crop[1]. 3066 which only change on request. These are stored in btv->crop[1].
3048 However for compatibility with V4L apps and cropping unaware 3067 However for compatibility with V4L apps and cropping unaware
3049 V4L2 apps we now reset the cropping parameters as seen through 3068 V4L2 apps we now reset the cropping parameters as seen through
3050 this fh, which is to say VIDIOC_G_CROP and scaling limit checks 3069 this fh, which is to say VIDIOC_G_SELECTION and scaling limit checks
3051 will use btv->crop[0], the default cropping parameters for the 3070 will use btv->crop[0], the default cropping parameters for the
3052 current video standard, and VIDIOC_S_FMT will not implicitely 3071 current video standard, and VIDIOC_S_FMT will not implicitely
3053 change the cropping parameters until VIDIOC_S_CROP has been 3072 change the cropping parameters until VIDIOC_S_SELECTION has been
3054 called. */ 3073 called. */
3055 fh->do_crop = !reset_crop; /* module parameter */ 3074 fh->do_crop = !reset_crop; /* module parameter */
3056 3075
@@ -3159,8 +3178,8 @@ static const struct v4l2_ioctl_ops bttv_ioctl_ops = {
3159 .vidioc_streamoff = bttv_streamoff, 3178 .vidioc_streamoff = bttv_streamoff,
3160 .vidioc_g_tuner = bttv_g_tuner, 3179 .vidioc_g_tuner = bttv_g_tuner,
3161 .vidioc_s_tuner = bttv_s_tuner, 3180 .vidioc_s_tuner = bttv_s_tuner,
3162 .vidioc_g_crop = bttv_g_crop, 3181 .vidioc_g_selection = bttv_g_selection,
3163 .vidioc_s_crop = bttv_s_crop, 3182 .vidioc_s_selection = bttv_s_selection,
3164 .vidioc_g_fbuf = bttv_g_fbuf, 3183 .vidioc_g_fbuf = bttv_g_fbuf,
3165 .vidioc_s_fbuf = bttv_s_fbuf, 3184 .vidioc_s_fbuf = bttv_s_fbuf,
3166 .vidioc_overlay = bttv_overlay, 3185 .vidioc_overlay = bttv_overlay,
diff --git a/drivers/media/pci/bt8xx/bttvp.h b/drivers/media/pci/bt8xx/bttvp.h
index b1e0023f923c..9efc4559fa8e 100644
--- a/drivers/media/pci/bt8xx/bttvp.h
+++ b/drivers/media/pci/bt8xx/bttvp.h
@@ -232,7 +232,7 @@ struct bttv_fh {
232 const struct bttv_format *ovfmt; 232 const struct bttv_format *ovfmt;
233 struct bttv_overlay ov; 233 struct bttv_overlay ov;
234 234
235 /* Application called VIDIOC_S_CROP. */ 235 /* Application called VIDIOC_S_SELECTION. */
236 int do_crop; 236 int do_crop;
237 237
238 /* vbi capture */ 238 /* vbi capture */