diff mbox

[12/20] mt9m111: s_crop add calculation of output size

Message ID 1280501618-23634-13-git-send-email-m.grzeschik@pengutronix.de (mailing list archive)
State Superseded
Headers show

Commit Message

Michael Grzeschik July 30, 2010, 2:53 p.m. UTC
None
diff mbox

Patch

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 "