All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linux-media@vger.kernel.org
Subject: [PATCH 05/10] ov772x: try_fmt must not default to the current format
Date: Fri,  6 Jul 2012 16:34:56 +0200	[thread overview]
Message-ID: <1341585301-1003-6-git-send-email-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <1341585301-1003-1-git-send-email-laurent.pinchart@ideasonboard.com>

If the requested format isn't supported, return a fixed default format
instead of the current format.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/video/ov772x.c |   36 +++++++-----------------------------
 1 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c
index fcb338a..e3de4de 100644
--- a/drivers/media/video/ov772x.c
+++ b/drivers/media/video/ov772x.c
@@ -902,38 +902,16 @@ static int ov772x_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
 static int ov772x_try_fmt(struct v4l2_subdev *sd,
 			  struct v4l2_mbus_framefmt *mf)
 {
-	struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev);
+	const struct ov772x_color_format *cfmt;
 	const struct ov772x_win_size *win;
-	int i;
-
-	/*
-	 * select suitable win
-	 */
-	win = ov772x_select_win(mf->width, mf->height);
 
-	mf->width	= win->width;
-	mf->height	= win->height;
-	mf->field	= V4L2_FIELD_NONE;
-
-	for (i = 0; i < ARRAY_SIZE(ov772x_cfmts); i++)
-		if (mf->code == ov772x_cfmts[i].code)
-			break;
+	ov772x_select_params(mf, &cfmt, &win);
 
-	if (i == ARRAY_SIZE(ov772x_cfmts)) {
-		/* Unsupported format requested. Propose either */
-		if (priv->cfmt) {
-			/* the current one or */
-			mf->colorspace = priv->cfmt->colorspace;
-			mf->code = priv->cfmt->code;
-		} else {
-			/* the default one */
-			mf->colorspace = ov772x_cfmts[0].colorspace;
-			mf->code = ov772x_cfmts[0].code;
-		}
-	} else {
-		/* Also return the colorspace */
-		mf->colorspace	= ov772x_cfmts[i].colorspace;
-	}
+	mf->code = cfmt->code;
+	mf->width = win->width;
+	mf->height = win->height;
+	mf->field = V4L2_FIELD_NONE;
+	mf->colorspace = cfmt->colorspace;
 
 	return 0;
 }
-- 
1.7.8.6


  parent reply	other threads:[~2012-07-06 14:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-06 14:34 [PATCH 00/10] Miscellaneous ov772x cleanups and fixes Laurent Pinchart
2012-07-06 14:34 ` [PATCH 01/10] ov772x: Reorganize the code in sections Laurent Pinchart
2012-07-06 14:34 ` [PATCH 02/10] ov772x: Fix memory leak in probe error path Laurent Pinchart
2012-07-06 14:34 ` [PATCH 03/10] ov772x: Select the default format at probe time Laurent Pinchart
2012-07-10 13:48   ` Guennadi Liakhovetski
2012-07-06 14:34 ` [PATCH 04/10] ov772x: Don't fail in s_fmt if the requested format isn't supported Laurent Pinchart
2012-07-06 14:34 ` Laurent Pinchart [this message]
2012-07-06 14:34 ` [PATCH 06/10] ov772x: Make to_ov772x convert from v4l2_subdev to ov772x_priv Laurent Pinchart
2012-07-06 14:34 ` [PATCH 07/10] ov772x: Add ov772x_read() and ov772x_write() functions Laurent Pinchart
2012-07-06 14:34 ` [PATCH 08/10] ov772x: Add support for SBGGR10 format Laurent Pinchart
2012-07-06 14:35 ` [PATCH 09/10] ov772x: Compute window size registers at runtime Laurent Pinchart
2012-07-10 21:29   ` Guennadi Liakhovetski
2012-07-06 14:35 ` [PATCH 10/10] ov772x: Stop sensor readout right after reset Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341585301-1003-6-git-send-email-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.