Linux Media Controller development
 help / color / mirror / Atom feed
From: Ondrej Zary <linux@rainbow-software.org>
To: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: linux-media@vger.kernel.org
Subject: [PATCH 1/7] saa7134: v4l2-compliance: implement V4L2_CAP_DEVICE_CAPS
Date: Sun, 27 Jan 2013 20:45:06 +0100	[thread overview]
Message-ID: <1359315912-1767-2-git-send-email-linux@rainbow-software.org> (raw)
In-Reply-To: <1359315912-1767-1-git-send-email-linux@rainbow-software.org>

Make saa7134 driver more V4L2 compliant: implement V4L2_CAP_DEVICE_CAPS support
and fix all capabilities problems reported by v4l2-compliance.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
---
 drivers/media/pci/saa7134/saa7134-video.c |   55 ++++++++++++++++------------
 1 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index 3abf527..ce15f1f 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1805,6 +1805,8 @@ static int saa7134_querycap(struct file *file, void  *priv,
 {
 	struct saa7134_fh *fh = priv;
 	struct saa7134_dev *dev = fh->dev;
+	struct video_device *vdev = video_devdata(file);
+	u32 radio_caps, video_caps, vbi_caps;
 
 	unsigned int tuner_type = dev->tuner_type;
 
@@ -1812,19 +1814,37 @@ static int saa7134_querycap(struct file *file, void  *priv,
 	strlcpy(cap->card, saa7134_boards[dev->board].name,
 		sizeof(cap->card));
 	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
-	cap->capabilities =
-		V4L2_CAP_VIDEO_CAPTURE |
-		V4L2_CAP_VBI_CAPTURE |
-		V4L2_CAP_READWRITE |
-		V4L2_CAP_STREAMING |
-		V4L2_CAP_TUNER;
+
+	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;
 	if (dev->has_rds)
-		cap->capabilities |= V4L2_CAP_RDS_CAPTURE;
+		radio_caps |= V4L2_CAP_RDS_CAPTURE;
+
+	video_caps = V4L2_CAP_VIDEO_CAPTURE;
 	if (saa7134_no_overlay <= 0)
-		cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY;
+		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;
+	}
+	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_READWRITE | V4L2_CAP_STREAMING);
 
-	if ((tuner_type == TUNER_ABSENT) || (tuner_type == UNSET))
-		cap->capabilities &= ~V4L2_CAP_TUNER;
 	return 0;
 }
 
@@ -2299,19 +2319,6 @@ static int vidioc_s_register (struct file *file, void *priv,
 }
 #endif
 
-static int radio_querycap(struct file *file, void *priv,
-					struct v4l2_capability *cap)
-{
-	struct saa7134_fh *fh = file->private_data;
-	struct saa7134_dev *dev = fh->dev;
-
-	strcpy(cap->driver, "saa7134");
-	strlcpy(cap->card, saa7134_boards[dev->board].name, sizeof(cap->card));
-	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
-	cap->capabilities = V4L2_CAP_TUNER;
-	return 0;
-}
-
 static int radio_g_tuner(struct file *file, void *priv,
 					struct v4l2_tuner *t)
 {
@@ -2473,7 +2480,7 @@ static const struct v4l2_file_operations radio_fops = {
 };
 
 static const struct v4l2_ioctl_ops radio_ioctl_ops = {
-	.vidioc_querycap	= radio_querycap,
+	.vidioc_querycap	= saa7134_querycap,
 	.vidioc_g_tuner		= radio_g_tuner,
 	.vidioc_enum_input	= radio_enum_input,
 	.vidioc_g_audio		= radio_g_audio,
-- 
Ondrej Zary


  reply	other threads:[~2013-01-27 19:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-27 19:45 [RFC PATCH 0/7] saa7134: improve v4l2-compliance Ondrej Zary
2013-01-27 19:45 ` Ondrej Zary [this message]
2013-01-28 10:07   ` [PATCH 1/7] saa7134: v4l2-compliance: implement V4L2_CAP_DEVICE_CAPS Hans Verkuil
2013-01-27 19:45 ` [PATCH 2/7] saa7134: v4l2-compliance: don't report invalid audio modes for radio Ondrej Zary
2013-01-28 10:08   ` Hans Verkuil
2013-01-27 19:45 ` [PATCH 3/7] saa7134: v4l2-compliance: use v4l2_fh to fix priority handling Ondrej Zary
2013-01-28 10:08   ` Hans Verkuil
2013-01-27 19:45 ` [PATCH 4/7] saa7134: v4l2-compliance: return real frequency Ondrej Zary
2013-01-28 10:10   ` Hans Verkuil
2013-01-27 19:45 ` [PATCH 5/7] saa7134: v4l2-compliance: fix g_tuner/s_tuner Ondrej Zary
2013-01-28 10:11   ` Hans Verkuil
2013-01-27 19:45 ` [PATCH 6/7] saa7134: v4l2-compliance: remove V4L2_IN_ST_NO_SYNC from enum_input Ondrej Zary
2013-01-28 10:30   ` Mauro Carvalho Chehab
2013-01-28 11:00     ` Hans Verkuil
2013-01-28 10:37   ` Hans Verkuil
2013-01-27 19:45 ` [PATCH 7/7] saa7134: v4l2-compliance: remove bogus audio input support Ondrej Zary
2013-01-28 10:38   ` Hans Verkuil
2013-01-28 10:56 ` [RFC PATCH 0/7] saa7134: improve v4l2-compliance Hans Verkuil
2013-01-28 22:40   ` Ondrej Zary
2013-01-29  7:12     ` Hans Verkuil
2013-01-28 14:11 ` [PATCH 8/7] saa7134: v4l2-compliance: remove bogus g_parm Ondrej Zary
2013-01-28 14:19   ` Hans Verkuil
2013-01-28 14:11 ` [PATCH 9/7] saa7134: v4l2-compliance: initialize VBI structure Ondrej Zary
2013-01-28 14:21   ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359315912-1767-2-git-send-email-linux@rainbow-software.org \
    --to=linux@rainbow-software.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox