diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2018-10-04 17:06:32 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-11-20 13:37:18 -0500 |
commit | ee10dc36b485920e87eefa325d74fd8804648621 (patch) | |
tree | aff59557bb6ab1dee797943e7248d362bd429541 /drivers/media/pci | |
parent | 98af278b1e0fa6b7e6c762e185e99f0cc5e31cfe (diff) | |
download | linux-ee10dc36b485920e87eefa325d74fd8804648621.tar.gz linux-ee10dc36b485920e87eefa325d74fd8804648621.tar.bz2 linux-ee10dc36b485920e87eefa325d74fd8804648621.zip |
media: cropcap/g_selection split
If g_selection is implemented, then the v4l2-ioctl cropcap code assumes
that cropcap just implements the pixelaspect part and that g_selection
provides the crop bounds and default rectangles.
There are still some drivers that only implement cropcap and not
g_selection. Split up cropcap into a cropcap and g_selection for those
drivers.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r-- | drivers/media/pci/cobalt/cobalt-v4l2.c | 38 | ||||
-rw-r--r-- | drivers/media/pci/cx23885/cx23885-video.c | 28 |
2 files changed, 57 insertions, 9 deletions
diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c index 0525f5e1565b..4a0205aae4b4 100644 --- a/drivers/media/pci/cobalt/cobalt-v4l2.c +++ b/drivers/media/pci/cobalt/cobalt-v4l2.c @@ -1089,14 +1089,43 @@ static int cobalt_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cc) timings = cea1080p60; else err = v4l2_subdev_call(s->sd, video, g_dv_timings, &timings); - if (!err) { - cc->bounds.width = cc->defrect.width = timings.bt.width; - cc->bounds.height = cc->defrect.height = timings.bt.height; + if (!err) cc->pixelaspect = v4l2_dv_timings_aspect_ratio(&timings); - } return err; } +static int cobalt_g_selection(struct file *file, void *fh, + struct v4l2_selection *sel) +{ + struct cobalt_stream *s = video_drvdata(file); + struct v4l2_dv_timings timings; + int err = 0; + + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + if (s->input == 1) + timings = cea1080p60; + else + err = v4l2_subdev_call(s->sd, video, g_dv_timings, &timings); + + if (err) + return err; + + switch (sel->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_CROP_DEFAULT: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = timings.bt.width; + sel->r.height = timings.bt.height; + break; + default: + return -EINVAL; + } + return 0; +} + static const struct v4l2_ioctl_ops cobalt_ioctl_ops = { .vidioc_querycap = cobalt_querycap, .vidioc_g_parm = cobalt_g_parm, @@ -1104,6 +1133,7 @@ static const struct v4l2_ioctl_ops cobalt_ioctl_ops = { .vidioc_streamon = vb2_ioctl_streamon, .vidioc_streamoff = vb2_ioctl_streamoff, .vidioc_cropcap = cobalt_cropcap, + .vidioc_g_selection = cobalt_g_selection, .vidioc_enum_input = cobalt_enum_input, .vidioc_g_input = cobalt_g_input, .vidioc_s_input = cobalt_s_input, diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index 92d32a733f1b..a9844c4020ff 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c @@ -677,17 +677,34 @@ static int vidioc_cropcap(struct file *file, void *priv, if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; - cc->bounds.left = 0; - cc->bounds.top = 0; - cc->bounds.width = 720; - cc->bounds.height = norm_maxh(dev->tvnorm); - cc->defrect = cc->bounds; cc->pixelaspect.numerator = is_50hz ? 54 : 11; cc->pixelaspect.denominator = is_50hz ? 59 : 10; return 0; } +static int vidioc_g_selection(struct file *file, void *fh, + struct v4l2_selection *sel) +{ + struct cx23885_dev *dev = video_drvdata(file); + + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + switch (sel->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_CROP_DEFAULT: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = 720; + sel->r.height = norm_maxh(dev->tvnorm); + break; + default: + return -EINVAL; + } + return 0; +} + static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id) { struct cx23885_dev *dev = video_drvdata(file); @@ -1123,6 +1140,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_streamon = vb2_ioctl_streamon, .vidioc_streamoff = vb2_ioctl_streamoff, .vidioc_cropcap = vidioc_cropcap, + .vidioc_g_selection = vidioc_g_selection, .vidioc_s_std = vidioc_s_std, .vidioc_g_std = vidioc_g_std, .vidioc_enum_input = vidioc_enum_input, |