diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-11 23:22:22 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-11 23:22:22 +0300 |
commit | de34f4da7f62ff59ac6e1ef320b0fcfa3296fce3 (patch) | |
tree | 88b5db2fc7fbbb0353edd8447a832a5225a49d01 /drivers/media/pci/bt8xx/bttv-driver.c | |
parent | 56e520c7a0a490b63b042b047ec9659fc08762a4 (diff) | |
parent | 9fce0c226536fc36c7fb0a80000ca38a995be43e (diff) | |
download | linux-de34f4da7f62ff59ac6e1ef320b0fcfa3296fce3.tar.xz |
Merge tag 'media/v4.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab:
- Documentation improvements: conversion of all non-DocBook documents
to Sphinx and lots of fixes to the uAPI media book
- New PCI driver for Techwell TW5864 media grabber boards
- New SoC driver for ATMEL Image Sensor Controller
- Removal of some obsolete SoC drivers (s5p-tv driver and soc_camera
drivers)
- Addition of ST CEC driver
- Lots of drivers fixes, improvements and additions
* tag 'media/v4.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (464 commits)
[media] ttusb_dec: avoid the risk of go past buffer
[media] cx23885: Fix some smatch warnings
[media] si2165: switch to regmap
[media] si2165: use i2c_client->dev instead of i2c_adapter->dev for logging
[media] si2165: Remove legacy attach
[media] cx231xx: attach si2165 driver via i2c_client
[media] cx231xx: Prepare for attaching new style i2c_client DVB demod drivers
[media] cx23885: attach si2165 driver via i2c_client
[media] si2165: support i2c_client attach
[media] si2165: avoid division by zero
[media] rcar-vin: add R-Car gen2 fallback compatibility string
[media] lgdt3306a: remove 20*50 msec unnecessary timeout
[media] cx25821: Remove deprecated create_singlethread_workqueue
[media] cx25821: Drop Freeing of Workqueue
[media] cxd2841er: force 8MHz bandwidth for DVB-C if specified bw not supported
[media] redrat3: hardware-specific parameters
[media] redrat3: remove hw_timeout member
[media] cxd2841er: BER and SNR reading for ISDB-T
[media] dvb-usb: avoid link error with dib3000m{b,c|
[media] dvb-usb: split out common parts of dibusb
...
Diffstat (limited to 'drivers/media/pci/bt8xx/bttv-driver.c')
-rw-r--r-- | drivers/media/pci/bt8xx/bttv-driver.c | 59 |
1 files changed, 39 insertions, 20 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, cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) return -EINVAL; - *cap = bttv_tvnorms[btv->tvnorm].cropcap; + /* defrect and bounds are set via g_selection */ + cap->pixelaspect = bttv_tvnorms[btv->tvnorm].cropcap.pixelaspect; return 0; } -static int bttv_g_crop(struct file *file, void *f, struct v4l2_crop *crop) +static int bttv_g_selection(struct file *file, void *f, struct v4l2_selection *sel) { struct bttv_fh *fh = f; struct bttv *btv = fh->btv; - if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && - crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && + sel->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) return -EINVAL; - /* No fh->do_crop = 1; because btv->crop[1] may be - inconsistent with fh->width or fh->height and apps - do not expect a change here. */ - - crop->c = btv->crop[!!fh->do_crop].rect; + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + /* + * No fh->do_crop = 1; because btv->crop[1] may be + * inconsistent with fh->width or fh->height and apps + * do not expect a change here. + */ + sel->r = btv->crop[!!fh->do_crop].rect; + break; + case V4L2_SEL_TGT_CROP_DEFAULT: + sel->r = bttv_tvnorms[btv->tvnorm].cropcap.defrect; + break; + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r = bttv_tvnorms[btv->tvnorm].cropcap.bounds; + break; + default: + return -EINVAL; + } return 0; } -static int bttv_s_crop(struct file *file, void *f, const struct v4l2_crop *crop) +static int bttv_s_selection(struct file *file, void *f, struct v4l2_selection *sel) { struct bttv_fh *fh = f; struct bttv *btv = fh->btv; @@ -2839,8 +2853,11 @@ static int bttv_s_crop(struct file *file, void *f, const struct v4l2_crop *crop) __s32 b_right; __s32 b_bottom; - if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && - crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && + sel->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) + return -EINVAL; + + if (sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; /* 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) } /* Min. scaled size 48 x 32. */ - c.rect.left = clamp_t(s32, crop->c.left, b_left, b_right - 48); + c.rect.left = clamp_t(s32, sel->r.left, b_left, b_right - 48); c.rect.left = min(c.rect.left, (__s32) MAX_HDELAY); - c.rect.width = clamp_t(s32, crop->c.width, + c.rect.width = clamp_t(s32, sel->r.width, 48, b_right - c.rect.left); - c.rect.top = clamp_t(s32, crop->c.top, b_top, b_bottom - 32); + c.rect.top = clamp_t(s32, sel->r.top, b_top, b_bottom - 32); /* Top and height must be a multiple of two. */ c.rect.top = (c.rect.top + 1) & ~1; - c.rect.height = clamp_t(s32, crop->c.height, + c.rect.height = clamp_t(s32, sel->r.height, 32, b_bottom - c.rect.top); c.rect.height = (c.rect.height + 1) & ~1; bttv_crop_calc_limits(&c); + sel->r = c.rect; + btv->crop[1] = c; fh->do_crop = 1; @@ -3047,10 +3066,10 @@ static int bttv_open(struct file *file) which only change on request. These are stored in btv->crop[1]. However for compatibility with V4L apps and cropping unaware V4L2 apps we now reset the cropping parameters as seen through - this fh, which is to say VIDIOC_G_CROP and scaling limit checks + this fh, which is to say VIDIOC_G_SELECTION and scaling limit checks will use btv->crop[0], the default cropping parameters for the current video standard, and VIDIOC_S_FMT will not implicitely - change the cropping parameters until VIDIOC_S_CROP has been + change the cropping parameters until VIDIOC_S_SELECTION has been called. */ fh->do_crop = !reset_crop; /* module parameter */ @@ -3159,8 +3178,8 @@ static const struct v4l2_ioctl_ops bttv_ioctl_ops = { .vidioc_streamoff = bttv_streamoff, .vidioc_g_tuner = bttv_g_tuner, .vidioc_s_tuner = bttv_s_tuner, - .vidioc_g_crop = bttv_g_crop, - .vidioc_s_crop = bttv_s_crop, + .vidioc_g_selection = bttv_g_selection, + .vidioc_s_selection = bttv_s_selection, .vidioc_g_fbuf = bttv_g_fbuf, .vidioc_s_fbuf = bttv_s_fbuf, .vidioc_overlay = bttv_overlay, |