Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 330867
b: refs/heads/master
c: ca9ef7f
h: refs/heads/master
i:
  330865: 7670e81
  330863: 36ea1ca
v: v3
  • Loading branch information
Laurent Pinchart authored and Mauro Carvalho Chehab committed Aug 15, 2012
1 parent 818ac2d commit fa7787f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 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: edff996eb942ce5595e9b60a0e06586dcc41b19b
refs/heads/master: ca9ef7fa21d6cf26e22c9ff1e00a5abeb2106555
64 changes: 32 additions & 32 deletions trunk/drivers/media/i2c/soc_camera/ov772x.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -504,20 +505,20 @@ static const struct ov772x_color_format ov772x_cfmts[] = {
#define MAX_WIDTH VGA_WIDTH
#define MAX_HEIGHT VGA_HEIGHT

static const struct ov772x_win_size ov772x_win_vga = {
.name = "VGA",
.width = VGA_WIDTH,
.height = VGA_HEIGHT,
.com7_bit = SLCT_VGA,
.regs = ov772x_vga_regs,
};

static const struct ov772x_win_size ov772x_win_qvga = {
.name = "QVGA",
.width = QVGA_WIDTH,
.height = QVGA_HEIGHT,
.com7_bit = SLCT_QVGA,
.regs = ov772x_qvga_regs,
static const struct ov772x_win_size ov772x_win_sizes[] = {
{
.name = "VGA",
.width = VGA_WIDTH,
.height = VGA_HEIGHT,
.com7_bit = SLCT_VGA,
.regs = ov772x_vga_regs,
}, {
.name = "QVGA",
.width = QVGA_WIDTH,
.height = QVGA_HEIGHT,
.com7_bit = SLCT_QVGA,
.regs = ov772x_qvga_regs,
},
};

/*
Expand Down Expand Up @@ -693,19 +694,18 @@ static int ov772x_s_power(struct v4l2_subdev *sd, int on)

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;
const struct ov772x_win_size *win = &ov772x_win_sizes[0];
u32 best_diff = UINT_MAX;
unsigned int i;

for (i = 0; i < ARRAY_SIZE(ov772x_win_sizes); ++i) {
u32 diff = abs(width - ov772x_win_sizes[i].width)
+ abs(height - ov772x_win_sizes[i].height);
if (diff < best_diff) {
best_diff = diff;
win = &ov772x_win_sizes[i];
}
}

return win;
}
Expand Down Expand Up @@ -890,11 +890,6 @@ static int ov772x_g_fmt(struct v4l2_subdev *sd,
{
struct ov772x_priv *priv = container_of(sd, struct ov772x_priv, subdev);

if (!priv->win || !priv->cfmt) {
priv->cfmt = &ov772x_cfmts[0];
priv->win = ov772x_select_win(VGA_WIDTH, VGA_HEIGHT);
}

mf->width = priv->win->width;
mf->height = priv->win->height;
mf->code = priv->cfmt->code;
Expand Down Expand Up @@ -1103,6 +1098,11 @@ static int ov772x_probe(struct i2c_client *client,
}

ret = ov772x_video_probe(client);
if (ret < 0)
goto done;

priv->cfmt = &ov772x_cfmts[0];
priv->win = &ov772x_win_sizes[0];

done:
if (ret) {
Expand Down

0 comments on commit fa7787f

Please sign in to comment.