From 2161536516edcc0be31109eb1284939119e7ba6d Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 17 Jun 2019 05:36:16 -0400 Subject: media: media/pci: set device_caps in struct video_device Instead of filling in the struct v4l2_capability device_caps field, fill in the struct video_device device_caps field. That way the V4L2 core knows what the capabilities of the video device are. But this only really works if all drivers use this, so convert all pci drivers in this patch. Tested with cx88-blackbird and ivtv PVR-350. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/saa7134/saa7134-core.c | 15 ++++++++++ drivers/media/pci/saa7134/saa7134-empress.c | 4 +++ drivers/media/pci/saa7134/saa7134-video.c | 46 +++++------------------------ 3 files changed, 27 insertions(+), 38 deletions(-) (limited to 'drivers/media/pci/saa7134') diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c index fa9a0ead46d5..2d582c02adbf 100644 --- a/drivers/media/pci/saa7134/saa7134-core.c +++ b/drivers/media/pci/saa7134/saa7134-core.c @@ -1206,6 +1206,14 @@ static int saa7134_initdev(struct pci_dev *pci_dev, dev->video_dev->ctrl_handler = &dev->ctrl_handler; dev->video_dev->lock = &dev->lock; dev->video_dev->queue = &dev->video_vbq; + dev->video_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | + V4L2_CAP_VIDEO_CAPTURE; + if (dev->tuner_type != TUNER_ABSENT && dev->tuner_type != UNSET) + dev->video_dev->device_caps |= V4L2_CAP_TUNER; + + if (saa7134_no_overlay <= 0) + dev->video_dev->device_caps |= V4L2_CAP_VIDEO_OVERLAY; + err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, video_nr[dev->nr]); if (err < 0) { @@ -1220,6 +1228,10 @@ static int saa7134_initdev(struct pci_dev *pci_dev, dev->vbi_dev->ctrl_handler = &dev->ctrl_handler; dev->vbi_dev->lock = &dev->lock; dev->vbi_dev->queue = &dev->vbi_vbq; + dev->vbi_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | + V4L2_CAP_VBI_CAPTURE; + if (dev->tuner_type != TUNER_ABSENT && dev->tuner_type != UNSET) + dev->vbi_dev->device_caps |= V4L2_CAP_TUNER; err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI, vbi_nr[dev->nr]); @@ -1232,6 +1244,9 @@ static int saa7134_initdev(struct pci_dev *pci_dev, dev->radio_dev = vdev_init(dev,&saa7134_radio_template,"radio"); dev->radio_dev->ctrl_handler = &dev->radio_ctrl_handler; dev->radio_dev->lock = &dev->lock; + dev->radio_dev->device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER; + if (dev->has_rds) + dev->radio_dev->device_caps |= V4L2_CAP_RDS_CAPTURE; err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, radio_nr[dev->nr]); if (err < 0) diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c index 17eafaa5bf02..1a41a56afec6 100644 --- a/drivers/media/pci/saa7134/saa7134-empress.c +++ b/drivers/media/pci/saa7134/saa7134-empress.c @@ -287,6 +287,10 @@ static int empress_init(struct saa7134_dev *dev) if (err) return err; dev->empress_dev->queue = q; + dev->empress_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | + V4L2_CAP_VIDEO_CAPTURE; + if (dev->tuner_type != TUNER_ABSENT && dev->tuner_type != UNSET) + dev->empress_dev->device_caps |= V4L2_CAP_TUNER; video_set_drvdata(dev->empress_dev, dev); err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER, diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index 89c1271476c7..606df51bb636 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -1489,50 +1489,20 @@ int saa7134_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { struct saa7134_dev *dev = video_drvdata(file); - struct video_device *vdev = video_devdata(file); - u32 radio_caps, video_caps, vbi_caps; - - unsigned int tuner_type = dev->tuner_type; strscpy(cap->driver, "saa7134", sizeof(cap->driver)); strscpy(cap->card, saa7134_boards[dev->board].name, sizeof(cap->card)); sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); - - cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; - if ((tuner_type != TUNER_ABSENT) && (tuner_type != UNSET)) - cap->device_caps |= V4L2_CAP_TUNER; - - radio_caps = V4L2_CAP_RADIO; + cap->capabilities = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | + V4L2_CAP_RADIO | V4L2_CAP_VIDEO_CAPTURE | + V4L2_CAP_VBI_CAPTURE | V4L2_CAP_DEVICE_CAPS; + if (dev->tuner_type != TUNER_ABSENT && dev->tuner_type != UNSET) + cap->capabilities |= V4L2_CAP_TUNER; if (dev->has_rds) - radio_caps |= V4L2_CAP_RDS_CAPTURE; - - video_caps = V4L2_CAP_VIDEO_CAPTURE; - if (saa7134_no_overlay <= 0 && !is_empress(file)) - video_caps |= V4L2_CAP_VIDEO_OVERLAY; - - vbi_caps = V4L2_CAP_VBI_CAPTURE; - - switch (vdev->vfl_type) { - case VFL_TYPE_RADIO: - cap->device_caps |= radio_caps; - break; - case VFL_TYPE_GRABBER: - cap->device_caps |= video_caps; - break; - case VFL_TYPE_VBI: - cap->device_caps |= vbi_caps; - break; - default: - return -EINVAL; - } - cap->capabilities = radio_caps | video_caps | vbi_caps | - cap->device_caps | V4L2_CAP_DEVICE_CAPS; - if (vdev->vfl_type == VFL_TYPE_RADIO) { - cap->device_caps &= ~V4L2_CAP_STREAMING; - if (!dev->has_rds) - cap->device_caps &= ~V4L2_CAP_READWRITE; - } + cap->capabilities |= V4L2_CAP_RDS_CAPTURE; + if (saa7134_no_overlay <= 0) + cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY; return 0; } -- cgit