Signed-off-by: Philipp Wiesner <p.wies...@phytec.de>
Signed-off-by: Michael Grzeschik <m.grzesc...@pengutronix.de>
---
 drivers/media/video/mt9m111.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c
index cc0f996..2758a97 100644
--- a/drivers/media/video/mt9m111.c
+++ b/drivers/media/video/mt9m111.c
@@ -472,11 +472,19 @@ static int mt9m111_s_crop(struct v4l2_subdev *sd, struct 
v4l2_crop *a)
        struct mt9m111 *mt9m111 = to_mt9m111(client);
        struct mt9m111_format format;
        struct v4l2_mbus_framefmt *mf = &format.mf;
+       s32 rectwidth   = mt9m111->format.rect.width;
+       s32 rectheight  = mt9m111->format.rect.height;
+       u32 pixwidth    = mt9m111->format.mf.width;
+       u32 pixheight   = mt9m111->format.mf.height;
        int ret;
 
        format.rect     = a->c;
        format.mf       = mt9m111->format.mf;
 
+       /* calculate output size, maintain current scaling factors */
+       format.mf.width = pixwidth / rectwidth * format.mf.width;
+       format.mf.height = pixheight / rectheight * format.mf.height;
+
        dev_dbg(&client->dev, "%s: rect: left=%d top=%d width=%d height=%d\n",
                __func__, a->c.left, a->c.top, a->c.width, a->c.height);
        dev_dbg(&client->dev, "%s: mf: width=%d height=%d pixelcode=%d "
-- 
1.7.1

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

Reply via email to