Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1388538

[PATCH 3.2 014/115] [media] bttv: Width must be a multiple of 16 when capturing planar formats

From Ben Hutchings <ben@decadent.org.uk>
Newsgroups linux.kernel
Subject [PATCH 3.2 014/115] [media] bttv: Width must be a multiple of 16 when capturing planar formats
Date 2016-04-27 02:50 +0200
Message-ID <rslPX-pf-3@gated-at.bofh.it> (permalink)
References <rskqS-7Qj-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


3.2.80-rc1 review patch.  If anyone has any objections, please let me know.

------------------

From: Hans de Goede <hdegoede@redhat.com>

commit 5c915c68763889f0183a1cc61c84bb228b60124a upstream.

On my bttv card "Hauppauge WinTV [card=10]" capturing in YV12 fmt at max
size results in a solid green rectangle being captured (all colors 0 in
YUV).

This turns out to be caused by max-width (924) not being a multiple of 16.

We've likely never hit this problem before since normally xawtv / tvtime,
etc. will prefer packed pixel formats. But when using a video card which
is using xf86-video-modesetting + glamor, only planar XVideo fmts are
available, and xawtv will chose a matching capture format to avoid needing
to do conversion, triggering the solid green window problem.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[bwh: Backported to 3.2: adjust filename, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/media/video/bt8xx/bttv-driver.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -2480,6 +2480,19 @@ static int bttv_g_fmt_vid_overlay(struct
 	return 0;
 }
 
+static void bttv_get_width_mask_vid_cap(const struct bttv_format *fmt,
+					unsigned int *width_mask,
+					unsigned int *width_bias)
+{
+	if (fmt->flags & FORMAT_FLAGS_PLANAR) {
+		*width_mask = ~15; /* width must be a multiple of 16 pixels */
+		*width_bias = 8;   /* nearest */
+	} else {
+		*width_mask = ~3; /* width must be a multiple of 4 pixels */
+		*width_bias = 2;  /* nearest */
+	}
+}
+
 static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
 						struct v4l2_format *f)
 {
@@ -2488,6 +2501,7 @@ static int bttv_try_fmt_vid_cap(struct f
 	struct bttv *btv = fh->btv;
 	enum v4l2_field field;
 	__s32 width, height;
+	unsigned int width_mask, width_bias;
 	int rc;
 
 	fmt = format_by_fourcc(f->fmt.pix.pixelformat);
@@ -2525,9 +2539,9 @@ static int bttv_try_fmt_vid_cap(struct f
 	width = f->fmt.pix.width;
 	height = f->fmt.pix.height;
 
+	bttv_get_width_mask_vid_cap(fmt, &width_mask, &width_bias);
 	rc = limit_scaled_size_lock(fh, &width, &height, field,
-			       /* width_mask: 4 pixels */ ~3,
-			       /* width_bias: nearest */ 2,
+			       width_mask, width_bias,
 			       /* adjust_size */ 1,
 			       /* adjust_crop */ 0);
 	if (0 != rc)
@@ -2558,6 +2572,7 @@ static int bttv_s_fmt_vid_cap(struct fil
 	struct bttv_fh *fh = priv;
 	struct bttv *btv = fh->btv;
 	__s32 width, height;
+	unsigned int width_mask, width_bias;
 	enum v4l2_field field;
 
 	retval = bttv_switch_type(fh, f->type);
@@ -2572,9 +2587,10 @@ static int bttv_s_fmt_vid_cap(struct fil
 	height = f->fmt.pix.height;
 	field = f->fmt.pix.field;
 
+	fmt = format_by_fourcc(f->fmt.pix.pixelformat);
+	bttv_get_width_mask_vid_cap(fmt, &width_mask, &width_bias);
 	retval = limit_scaled_size_lock(fh, &width, &height, f->fmt.pix.field,
-			       /* width_mask: 4 pixels */ ~3,
-			       /* width_bias: nearest */ 2,
+			       width_mask, width_bias,
 			       /* adjust_size */ 1,
 			       /* adjust_crop */ 1);
 	if (0 != retval)
@@ -2582,8 +2598,6 @@ static int bttv_s_fmt_vid_cap(struct fil
 
 	f->fmt.pix.field = field;
 
-	fmt = format_by_fourcc(f->fmt.pix.pixelformat);
-
 	/* update our state informations */
 	fh->fmt              = fmt;
 	fh->cap.field        = f->fmt.pix.field;

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3.2 000/115] 3.2.80-rc1 review Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 006/115] [media] saa7134: Fix bytesperline not being  set correctly for planar formats Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 014/115] [media] bttv: Width must be a multiple of 16  when capturing planar formats Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 114/115] jme: Fix device PM wakeup API usage Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 018/115] drivers/misc/ad525x_dpot: AD5274 fix RDAC  read back errors Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 008/115] Bluetooth: Add new AR3012 ID 0489:e095 Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 019/115] usb: hub: fix a typo in hub_port_init()  leading to wrong logic Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 007/115] Bluetooth: btusb: Add new AR3012 ID 13d3:3395 Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 115/115] netfilter: x_tables: fix unconditional helper Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 003/115] 8250: use callbacks to access UART_DLL/UART_DLM Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 013/115] Bluetooth: btusb: Add a new AR3012 ID 04ca:3014 Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 005/115] usb: retry reset if a device times out Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 010/115] mac80211: avoid excessive stack usage in sta_info Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 017/115] xfs: fix two memory leaks in xfs_attr_list.c  error paths Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 001/115] EDAC, amd64_edac: Shift wrapping issue in  f1x_get_norm_dct_addr() Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 011/115] mac80211: fix memory leak Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 002/115] [media] pwc: Add USB id for Philips Spc880nc  webcam Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 012/115] PCI: Disable IO/MEM decoding for devices with  non-compliant BARs Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 113/115] jme: Do not enable NIC WoL functions on S0 Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 009/115] aacraid: Fix memory leak in aac_fib_map_free Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  [PATCH 3.2 015/115] watchdog: rc32434_wdt: fix ioctl error handling Ben Hutchings <ben@decadent.org.uk> - 2016-04-27 02:50 +0200
  Re: [PATCH 3.2 000/115] 3.2.80-rc1 review Guenter Roeck <linux@roeck-us.net> - 2016-04-27 05:40 +0200

csiph-web