Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 124569
b: refs/heads/master
c: f82a856
h: refs/heads/master
i:
  124567: d5602cf
v: v3
  • Loading branch information
Kuninori Morimoto authored and Mauro Carvalho Chehab committed Dec 30, 2008
1 parent c5e7fde commit 8fe8708
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 77fe3d4a44f76653263eb8671d7909ab0fdafd71
refs/heads/master: f82a8569bfa10f32a3123ca0b681ec7c3188d2c0
55 changes: 35 additions & 20 deletions trunk/drivers/media/video/ov772x.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,27 @@ static int ov772x_set_register(struct soc_camera_device *icd,
}
#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)
Expand All @@ -786,34 +807,28 @@ static int ov772x_set_fmt(struct soc_camera_device *icd,
}
}

/*
* 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;
}
struct v4l2_pix_format *pix = &f->fmt.pix;
const struct ov772x_win_size *win;

/* 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;
}
/*
* select suitable win
*/
win = ov772x_select_win(pix->width, pix->height);

pix->field = V4L2_FIELD_NONE;
pix->width = win->width;
pix->height = win->height;
pix->field = V4L2_FIELD_NONE;

return 0;
}
Expand Down

0 comments on commit 8fe8708

Please sign in to comment.