[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1498143942-12682-4-git-send-email-hugues.fruchet@st.com>
Date: Thu, 22 Jun 2017 17:05:39 +0200
From: Hugues Fruchet <hugues.fruchet@...com>
To: Sylwester Nawrocki <sylvester.nawrocki@...il.com>,
" H. Nikolaus Schaller" <hns@...delico.com>,
Guennadi Liakhovetski <g.liakhovetski@....de>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Alexandre Torgue <alexandre.torgue@...com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Hans Verkuil <hverkuil@...all.nl>
CC: <devicetree@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <linux-media@...r.kernel.org>,
Benjamin Gaignard <benjamin.gaignard@...aro.org>,
Yannick Fertre <yannick.fertre@...com>,
Hugues Fruchet <hugues.fruchet@...com>
Subject: [PATCH v1 3/6] [media] ov9650: select the nearest higher resolution
Refine the resolution selection algorithm by selecting
only the nearest higher resolution (instead of lower and higher).
Signed-off-by: Hugues Fruchet <hugues.fruchet@...com>
---
drivers/media/i2c/ov9650.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 8340a45..4311da6 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1196,9 +1196,11 @@ static void __ov965x_try_frame_size(struct v4l2_mbus_framefmt *mf,
unsigned int min_err = UINT_MAX;
while (i--) {
- int err = abs(fsize->width - mf->width)
- + abs(fsize->height - mf->height);
- if (err < min_err) {
+ int w_err = (fsize->width - mf->width);
+ int h_err = (fsize->height - mf->height);
+ int err = w_err + h_err;
+
+ if ((w_err >= 0) && (h_err >= 0) && (err < min_err)) {
min_err = err;
match = fsize;
}
--
1.9.1
Powered by blists - more mailing lists