linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] em28xx: introduce #define for maximum supported scaling values (register 0x30-0x33)
@ 2013-02-10 20:05 Frank Schäfer
  2013-02-10 20:05 ` [PATCH 2/4] em28xx: rename function get_scale() to size_to_scale() Frank Schäfer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Frank Schäfer @ 2013-02-10 20:05 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media, Frank Schäfer

The maximum supported scaling value for registers 0x30+0x31 (horizontal scaling)
and 0x32+0x33 (vertical scaling) is 0x3fff, which corresponds to 20% of the
input frame size.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/usb/em28xx/em28xx-reg.h   |    2 ++
 drivers/media/usb/em28xx/em28xx-video.c |    8 ++++----
 2 Dateien geändert, 6 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-reg.h b/drivers/media/usb/em28xx/em28xx-reg.h
index 885089e..0a3cb04 100644
--- a/drivers/media/usb/em28xx/em28xx-reg.h
+++ b/drivers/media/usb/em28xx/em28xx-reg.h
@@ -152,6 +152,8 @@
 #define EM28XX_R31_HSCALEHIGH	0x31
 #define EM28XX_R32_VSCALELOW	0x32
 #define EM28XX_R33_VSCALEHIGH	0x33
+#define   EM28XX_HVSCALE_MAX	0x3fff /* => 20% */
+
 #define EM28XX_R34_VBI_START_H	0x34
 #define EM28XX_R35_VBI_START_V	0x35
 #define EM28XX_R36_VBI_WIDTH	0x36
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 6d26123..9451e1e 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -807,12 +807,12 @@ static void get_scale(struct em28xx *dev,
 	unsigned int          maxh = norm_maxh(dev);
 
 	*hscale = (((unsigned long)maxw) << 12) / width - 4096L;
-	if (*hscale >= 0x4000)
-		*hscale = 0x3fff;
+	if (*hscale > EM28XX_HVSCALE_MAX)
+		*hscale = EM28XX_HVSCALE_MAX;
 
 	*vscale = (((unsigned long)maxh) << 12) / height - 4096L;
-	if (*vscale >= 0x4000)
-		*vscale = 0x3fff;
+	if (*vscale > EM28XX_HVSCALE_MAX)
+		*vscale = EM28XX_HVSCALE_MAX;
 }
 
 /* ------------------------------------------------------------------
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/4] em28xx: rename function get_scale() to size_to_scale()
  2013-02-10 20:05 [PATCH 1/4] em28xx: introduce #define for maximum supported scaling values (register 0x30-0x33) Frank Schäfer
@ 2013-02-10 20:05 ` Frank Schäfer
  2013-02-10 20:05 ` [PATCH 3/4] em28xx: add function scale_to_size() Frank Schäfer
  2013-02-10 20:05 ` [PATCH 4/4] em28xx: VIDIOC_ENUM_FRAMESIZES: consider the scaler limits when calculating the minimum frame size Frank Schäfer
  2 siblings, 0 replies; 4+ messages in thread
From: Frank Schäfer @ 2013-02-10 20:05 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media, Frank Schäfer

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/usb/em28xx/em28xx-video.c |    8 ++++----
 1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 9451e1e..197823c 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -799,7 +799,7 @@ const struct v4l2_ctrl_ops em28xx_ctrl_ops = {
 	.s_ctrl = em28xx_s_ctrl,
 };
 
-static void get_scale(struct em28xx *dev,
+static void size_to_scale(struct em28xx *dev,
 			unsigned int width, unsigned int height,
 			unsigned int *hscale, unsigned int *vscale)
 {
@@ -889,7 +889,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
 				      1, 0);
 	}
 
-	get_scale(dev, width, height, &hscale, &vscale);
+	size_to_scale(dev, width, height, &hscale, &vscale);
 
 	width = (((unsigned long)maxw) << 12) / (hscale + 4096L);
 	height = (((unsigned long)maxh) << 12) / (vscale + 4096L);
@@ -923,7 +923,7 @@ static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc,
 	dev->height = height;
 
 	/* set new image size */
-	get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
+	size_to_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
 
 	em28xx_resolution_set(dev);
 
@@ -986,7 +986,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm)
 	/* set new image size */
 	dev->width = f.fmt.pix.width;
 	dev->height = f.fmt.pix.height;
-	get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
+	size_to_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale);
 
 	em28xx_resolution_set(dev);
 	v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/4] em28xx: add function scale_to_size()
  2013-02-10 20:05 [PATCH 1/4] em28xx: introduce #define for maximum supported scaling values (register 0x30-0x33) Frank Schäfer
  2013-02-10 20:05 ` [PATCH 2/4] em28xx: rename function get_scale() to size_to_scale() Frank Schäfer
@ 2013-02-10 20:05 ` Frank Schäfer
  2013-02-10 20:05 ` [PATCH 4/4] em28xx: VIDIOC_ENUM_FRAMESIZES: consider the scaler limits when calculating the minimum frame size Frank Schäfer
  2 siblings, 0 replies; 4+ messages in thread
From: Frank Schäfer @ 2013-02-10 20:05 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media, Frank Schäfer

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/usb/em28xx/em28xx-video.c |   15 ++++++++++++---
 1 Datei geändert, 12 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 197823c..f745617 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -815,6 +815,17 @@ static void size_to_scale(struct em28xx *dev,
 		*vscale = EM28XX_HVSCALE_MAX;
 }
 
+static void scale_to_size(struct em28xx *dev,
+			  unsigned int hscale, unsigned int vscale,
+			  unsigned int *width, unsigned int *height)
+{
+	unsigned int          maxw = norm_maxw(dev);
+	unsigned int          maxh = norm_maxh(dev);
+
+	*width = (((unsigned long)maxw) << 12) / (hscale + 4096L);
+	*height = (((unsigned long)maxh) << 12) / (vscale + 4096L);
+}
+
 /* ------------------------------------------------------------------
 	IOCTL vidioc handling
    ------------------------------------------------------------------*/
@@ -890,9 +901,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
 	}
 
 	size_to_scale(dev, width, height, &hscale, &vscale);
-
-	width = (((unsigned long)maxw) << 12) / (hscale + 4096L);
-	height = (((unsigned long)maxh) << 12) / (vscale + 4096L);
+	scale_to_size(dev, hscale, hscale, &width, &height);
 
 	f->fmt.pix.width = width;
 	f->fmt.pix.height = height;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 4/4] em28xx: VIDIOC_ENUM_FRAMESIZES: consider the scaler limits when calculating the minimum frame size
  2013-02-10 20:05 [PATCH 1/4] em28xx: introduce #define for maximum supported scaling values (register 0x30-0x33) Frank Schäfer
  2013-02-10 20:05 ` [PATCH 2/4] em28xx: rename function get_scale() to size_to_scale() Frank Schäfer
  2013-02-10 20:05 ` [PATCH 3/4] em28xx: add function scale_to_size() Frank Schäfer
@ 2013-02-10 20:05 ` Frank Schäfer
  2 siblings, 0 replies; 4+ messages in thread
From: Frank Schäfer @ 2013-02-10 20:05 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media, Frank Schäfer

Output resolutions <=20% of the input resolution exceed the capabilities of the
scaler.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
 drivers/media/usb/em28xx/em28xx-video.c |    8 ++++++--
 1 Datei geändert, 6 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index f745617..86fd907 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1405,8 +1405,12 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
 
 	/* Report a continuous range */
 	fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
-	fsize->stepwise.min_width = 48;
-	fsize->stepwise.min_height = 32;
+	scale_to_size(dev, EM28XX_HVSCALE_MAX, EM28XX_HVSCALE_MAX,
+		      &fsize->stepwise.min_width, &fsize->stepwise.min_height);
+	if (fsize->stepwise.min_width < 48)
+		fsize->stepwise.min_width = 48;
+	if (fsize->stepwise.min_height < 38)
+		fsize->stepwise.min_height = 38;
 	fsize->stepwise.max_width = maxw;
 	fsize->stepwise.max_height = maxh;
 	fsize->stepwise.step_width = 1;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-10 20:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-10 20:05 [PATCH 1/4] em28xx: introduce #define for maximum supported scaling values (register 0x30-0x33) Frank Schäfer
2013-02-10 20:05 ` [PATCH 2/4] em28xx: rename function get_scale() to size_to_scale() Frank Schäfer
2013-02-10 20:05 ` [PATCH 3/4] em28xx: add function scale_to_size() Frank Schäfer
2013-02-10 20:05 ` [PATCH 4/4] em28xx: VIDIOC_ENUM_FRAMESIZES: consider the scaler limits when calculating the minimum frame size Frank Schäfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).