Commit 2941e81f authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mauro Carvalho Chehab

V4L/DVB (10666): ov772x: move configuration from start_capture() to set_fmt()

soc_camera framework requires, that camera configuration is performed in
set_fmt, and start_capture and stop_capture only turn the camera on/off.
This patch modifies ov772x to comply to this requirement.
Signed-off-by: default avatarKuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 2d9329f3
...@@ -500,9 +500,8 @@ static const struct soc_camera_data_format ov772x_fmt_lists[] = { ...@@ -500,9 +500,8 @@ static const struct soc_camera_data_format ov772x_fmt_lists[] = {
/* /*
* color format list * color format list
*/ */
#define T_YUYV 0
static const struct ov772x_color_format ov772x_cfmts[] = { static const struct ov772x_color_format ov772x_cfmts[] = {
[T_YUYV] = { {
SETFOURCC(YUYV), SETFOURCC(YUYV),
.regs = ov772x_YYUV_regs, .regs = ov772x_YYUV_regs,
}, },
...@@ -635,74 +634,20 @@ static int ov772x_release(struct soc_camera_device *icd) ...@@ -635,74 +634,20 @@ static int ov772x_release(struct soc_camera_device *icd)
static int ov772x_start_capture(struct soc_camera_device *icd) static int ov772x_start_capture(struct soc_camera_device *icd)
{ {
struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd);
int ret;
if (!priv->win)
priv->win = &ov772x_win_vga;
if (!priv->fmt)
priv->fmt = &ov772x_cfmts[T_YUYV];
/*
* reset hardware
*/
ov772x_reset(priv->client);
/*
* set color format
*/
ret = ov772x_write_array(priv->client, priv->fmt->regs);
if (ret < 0)
goto start_end;
/*
* set size format
*/
ret = ov772x_write_array(priv->client, priv->win->regs);
if (ret < 0)
goto start_end;
/*
* set COM7 bit ( QVGA or VGA )
*/
ret = ov772x_mask_set(priv->client,
COM7, SLCT_MASK, priv->win->com7_bit);
if (ret < 0)
goto start_end;
/* if (!priv->win || !priv->fmt) {
* set UV setting dev_err(&icd->dev, "norm or win select error\n");
*/ return -EPERM;
if (priv->fmt->option & OP_UV) {
ret = ov772x_mask_set(priv->client,
DSP_CTRL3, UV_MASK, UV_ON);
if (ret < 0)
goto start_end;
}
/*
* set SWAP setting
*/
if (priv->fmt->option & OP_SWAP_RGB) {
ret = ov772x_mask_set(priv->client,
COM3, SWAP_MASK, SWAP_RGB);
if (ret < 0)
goto start_end;
} }
dev_dbg(&icd->dev, dev_dbg(&icd->dev,
"format %s, win %s\n", priv->fmt->name, priv->win->name); "format %s, win %s\n", priv->fmt->name, priv->win->name);
start_end: return 0;
priv->fmt = NULL;
priv->win = NULL;
return ret;
} }
static int ov772x_stop_capture(struct soc_camera_device *icd) static int ov772x_stop_capture(struct soc_camera_device *icd)
{ {
struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd);
ov772x_reset(priv->client);
return 0; return 0;
} }
...@@ -787,7 +732,6 @@ ov772x_select_win(u32 width, u32 height) ...@@ -787,7 +732,6 @@ ov772x_select_win(u32 width, u32 height)
return win; return win;
} }
static int ov772x_set_fmt(struct soc_camera_device *icd, static int ov772x_set_fmt(struct soc_camera_device *icd,
__u32 pixfmt, __u32 pixfmt,
struct v4l2_rect *rect) struct v4l2_rect *rect)
...@@ -803,16 +747,72 @@ static int ov772x_set_fmt(struct soc_camera_device *icd, ...@@ -803,16 +747,72 @@ static int ov772x_set_fmt(struct soc_camera_device *icd,
for (i = 0; i < ARRAY_SIZE(ov772x_cfmts); i++) { for (i = 0; i < ARRAY_SIZE(ov772x_cfmts); i++) {
if (pixfmt == ov772x_cfmts[i].fourcc) { if (pixfmt == ov772x_cfmts[i].fourcc) {
priv->fmt = ov772x_cfmts + i; priv->fmt = ov772x_cfmts + i;
ret = 0;
break; break;
} }
} }
if (!priv->fmt)
goto ov772x_set_fmt_error;
/* /*
* select win * select win
*/ */
priv->win = ov772x_select_win(rect->width, rect->height); priv->win = ov772x_select_win(rect->width, rect->height);
/*
* reset hardware
*/
ov772x_reset(priv->client);
/*
* set color format
*/
ret = ov772x_write_array(priv->client, priv->fmt->regs);
if (ret < 0)
goto ov772x_set_fmt_error;
/*
* set size format
*/
ret = ov772x_write_array(priv->client, priv->win->regs);
if (ret < 0)
goto ov772x_set_fmt_error;
/*
* set COM7 bit ( QVGA or VGA )
*/
ret = ov772x_mask_set(priv->client,
COM7, SLCT_MASK, priv->win->com7_bit);
if (ret < 0)
goto ov772x_set_fmt_error;
/*
* set UV setting
*/
if (priv->fmt->option & OP_UV) {
ret = ov772x_mask_set(priv->client,
DSP_CTRL3, UV_MASK, UV_ON);
if (ret < 0)
goto ov772x_set_fmt_error;
}
/*
* set SWAP setting
*/
if (priv->fmt->option & OP_SWAP_RGB) {
ret = ov772x_mask_set(priv->client,
COM3, SWAP_MASK, SWAP_RGB);
if (ret < 0)
goto ov772x_set_fmt_error;
}
return ret;
ov772x_set_fmt_error:
ov772x_reset(priv->client);
priv->win = NULL;
priv->fmt = NULL;
return ret; return ret;
} }
...@@ -889,7 +889,6 @@ static int ov772x_video_probe(struct soc_camera_device *icd) ...@@ -889,7 +889,6 @@ static int ov772x_video_probe(struct soc_camera_device *icd)
i2c_smbus_read_byte_data(priv->client, MIDH), i2c_smbus_read_byte_data(priv->client, MIDH),
i2c_smbus_read_byte_data(priv->client, MIDL)); i2c_smbus_read_byte_data(priv->client, MIDL));
return soc_camera_video_start(icd); return soc_camera_video_start(icd);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment