[PATCH 3/4] stk1160: Fix s_fmt and try_fmt implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The driver was expecting to get a valid pixelformat on s_fmt and try_fmt.
This is wrong, since the user may pass a bitmask and expect the driver
to change it, returning a valid (fourcc) pixelformat.

This problem was spotted by v4l2-compliance.

Signed-off-by: Ezequiel Garcia <elezegarcia@xxxxxxxxx>
---
 drivers/media/usb/stk1160/stk1160-v4l.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c
index 1ad4ac1..63c5832 100644
--- a/drivers/media/usb/stk1160/stk1160-v4l.c
+++ b/drivers/media/usb/stk1160/stk1160-v4l.c
@@ -318,12 +318,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
 {
 	struct stk1160 *dev = video_drvdata(file);
 
-	if (f->fmt.pix.pixelformat != format[0].fourcc) {
-		stk1160_err("fourcc format 0x%08x invalid\n",
-			f->fmt.pix.pixelformat);
-		return -EINVAL;
-	}
-
 	/*
 	 * User can't choose size at his own will,
 	 * so we just return him the current size chosen
@@ -331,6 +325,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
 	 * TODO: Implement frame scaling?
 	 */
 
+	f->fmt.pix.pixelformat = dev->fmt->fourcc;
 	f->fmt.pix.width = dev->width;
 	f->fmt.pix.height = dev->height;
 	f->fmt.pix.field = V4L2_FIELD_INTERLACED;
@@ -346,14 +341,11 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
 {
 	struct stk1160 *dev = video_drvdata(file);
 	struct vb2_queue *q = &dev->vb_vidq;
-	int rc;
 
 	if (vb2_is_busy(q))
 		return -EBUSY;
 
-	rc = vidioc_try_fmt_vid_cap(file, priv, f);
-	if (rc < 0)
-		return rc;
+	vidioc_try_fmt_vid_cap(file, priv, f);
 
 	/* We don't support any format changes */
 
-- 
1.7.8.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux