The patch number 10098 was added via Guennadi Liakhovetski 
<g.liakhovet...@gmx.de>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        v4l-dvb-maintai...@linuxtv.org

------

From: Kuninori Morimoto  <morimoto.kunin...@renesas.com>
ov772x: fix try_fmt calculation method

Don't modify driver's state in try_fmt, just verify format acceptability
or adjust it to driver's capabilities.

Signed-off-by: Kuninori Morimoto <morimoto.kunin...@renesas.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovet...@gmx.de>
---
 drivers/media/video/ov772x.c |   55 ++++++++++++++++++++++++++---------------
 1 files changed, 35 insertions(+), 20 deletions(-)


---

 linux/drivers/media/video/ov772x.c |   59 ++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 22 deletions(-)

diff -r 5f88c11cdc4b -r d9ad8dd9fb30 linux/drivers/media/video/ov772x.c
--- a/linux/drivers/media/video/ov772x.c        Mon Dec 29 10:04:37 2008 +0100
+++ b/linux/drivers/media/video/ov772x.c        Mon Dec 29 10:04:44 2008 +0100
@@ -766,6 +766,27 @@ static int ov772x_set_register(struct so
 }
 #endif
 
+static const struct ov772x_win_size*
+ov772x_select_win(u32 width, u32 height)
+{
+       __u32 diff;
+       const struct ov772x_win_size *win;
+
+       /* default is QVGA */
+       diff = abs(width - ov772x_win_qvga.width) +
+               abs(height - ov772x_win_qvga.height);
+       win = &ov772x_win_qvga;
+
+       /* VGA */
+       if (diff >
+           abs(width  - ov772x_win_vga.width) +
+           abs(height - ov772x_win_vga.height))
+               win = &ov772x_win_vga;
+
+       return win;
+}
+
+
 static int ov772x_set_fmt(struct soc_camera_device *icd,
                          __u32                     pixfmt,
                          struct v4l2_rect         *rect)
@@ -786,34 +807,28 @@ static int ov772x_set_fmt(struct soc_cam
                }
        }
 
+       /*
+        * select win
+        */
+       priv->win = ov772x_select_win(rect->width, rect->height);
+
        return ret;
 }
 
 static int ov772x_try_fmt(struct soc_camera_device *icd,
                          struct v4l2_format       *f)
 {
-       struct v4l2_pix_format *pix  = &f->fmt.pix;
-       struct ov772x_priv     *priv;
-
-       priv = container_of(icd, struct ov772x_priv, icd);
-
-       /* QVGA */
-       if (pix->width  <= ov772x_win_qvga.width ||
-           pix->height <= ov772x_win_qvga.height) {
-               priv->win   = &ov772x_win_qvga;
-               pix->width  =  ov772x_win_qvga.width;
-               pix->height =  ov772x_win_qvga.height;
-       }
-
-       /* VGA */
-       else if (pix->width  <= ov772x_win_vga.width ||
-                pix->height <= ov772x_win_vga.height) {
-               priv->win   = &ov772x_win_vga;
-               pix->width  =  ov772x_win_vga.width;
-               pix->height =  ov772x_win_vga.height;
-       }
-
-       pix->field = V4L2_FIELD_NONE;
+       struct v4l2_pix_format *pix = &f->fmt.pix;
+       const struct ov772x_win_size *win;
+
+       /*
+        * select suitable win
+        */
+       win = ov772x_select_win(pix->width, pix->height);
+
+       pix->width  = win->width;
+       pix->height = win->height;
+       pix->field  = V4L2_FIELD_NONE;
 
        return 0;
 }


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/d9ad8dd9fb30dfd9f0710d2ff1a6ca4d65346a6f

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to