diff mbox

[20/20] mt9m111: s_fmt make use of try_fmt

Message ID 1280501618-23634-21-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 f472ca1..ec758ae 100644
--- a/drivers/media/video/mt9m111.c
+++ b/drivers/media/video/mt9m111.c
@@ -697,38 +697,6 @@  static int mt9m111_set_pixfmt(struct i2c_client *client,
 	return ret;
 }
 
-static int mt9m111_s_fmt(struct v4l2_subdev *sd,
-			 struct v4l2_mbus_framefmt *mf)
-{
-	struct i2c_client *client = sd->priv;
-	const struct mt9m111_datafmt *fmt;
-	struct mt9m111 *mt9m111 = to_mt9m111(client);
-	struct v4l2_rect *rect;
-	struct mt9m111_format format;
-	int ret;
-
-	fmt = mt9m111_find_datafmt(mf->code, mt9m111_colour_fmts,
-				   ARRAY_SIZE(mt9m111_colour_fmts));
-	if (!fmt)
-		return -EINVAL;
-
-	format.rect	= mt9m111->format.rect;
-	format.mf	= *mf;
-	rect		= &format.rect;
-
-	dev_dbg(&client->dev,
-		"%s code=%x left=%d, top=%d, width=%d, height=%d\n", __func__,
-		mf->code, rect->left, rect->top, rect->width, rect->height);
-
-	ret = mt9m111_make_rect(client, &format);
-	if (!ret)
-		ret = mt9m111_set_pixfmt(client, format.mf.code);
-	if (!ret)
-		mt9m111->format = format;
-
-	return ret;
-}
-
 static int mt9m111_try_fmt(struct v4l2_subdev *sd,
 			   struct v4l2_mbus_framefmt *mf)
 {
@@ -763,6 +731,34 @@  static int mt9m111_try_fmt(struct v4l2_subdev *sd,
 	return 0;
 }
 
+static int mt9m111_s_fmt(struct v4l2_subdev *sd,
+			 struct v4l2_mbus_framefmt *mf)
+{
+	struct i2c_client *client = sd->priv;
+	struct mt9m111 *mt9m111 = to_mt9m111(client);
+	struct mt9m111_format format;
+	int ret;
+
+	dev_dbg(&client->dev, "%s: mf: width=%d height=%d pixelcode=%d "
+		"field=%x colorspace=%x\n", __func__, mf->width, mf->height,
+		mf->code, mf->field, mf->colorspace);
+
+	ret = mt9m111_try_fmt(sd, mf);
+
+	if (!ret) {
+		format.rect	= mt9m111->format.rect;
+		format.mf	= *mf;
+
+		ret = mt9m111_make_rect(client, &format);
+	}
+	if (!ret)
+		ret = mt9m111_set_pixfmt(client, format.mf.code);
+	if (!ret)
+		mt9m111->format = format;
+
+	return ret;
+}
+
 static int mt9m111_g_chip_ident(struct v4l2_subdev *sd,
 				struct v4l2_dbg_chip_ident *id)
 {