* [PATCH 1/3] ov2640: select sensor register bank before applying h/v-flip settings
@ 2012-09-23 12:07 Frank Schäfer
2012-09-23 12:07 ` [PATCH 2/3] ov2640: add support for V4L2_MBUS_FMT_YUYV8_2X8, V4L2_MBUS_FMT_RGB565_2X8_BE Frank Schäfer
2012-09-23 12:07 ` [PATCH 3/3] ov2640: simplify single register writes Frank Schäfer
0 siblings, 2 replies; 4+ messages in thread
From: Frank Schäfer @ 2012-09-23 12:07 UTC (permalink / raw)
To: g.liakhovetski; +Cc: linux-media, Frank Schäfer
We currently don't select the register bank in ov2640_s_ctrl, so we can end up
writing to DSP register 0x04 instead of sensor register 0x04.
This happens for example when calling ov2640_s_ctrl after ov2640_s_fmt.
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Cc: stable@kernel.org
---
drivers/media/i2c/soc_camera/ov2640.c | 8 ++++++++
1 Datei geändert, 8 Zeilen hinzugefügt(+)
diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c
index 78ac574..e4fc79e 100644
--- a/drivers/media/i2c/soc_camera/ov2640.c
+++ b/drivers/media/i2c/soc_camera/ov2640.c
@@ -683,8 +683,16 @@ static int ov2640_s_ctrl(struct v4l2_ctrl *ctrl)
struct v4l2_subdev *sd =
&container_of(ctrl->handler, struct ov2640_priv, hdl)->subdev;
struct i2c_client *client = v4l2_get_subdevdata(sd);
+ struct regval_list regval;
+ int ret;
u8 val;
+ regval.reg_num = BANK_SEL;
+ regval.value = BANK_SEL_SENS;
+ ret = ov2640_write_array(client, ®val);
+ if (ret < 0)
+ return ret;
+
switch (ctrl->id) {
case V4L2_CID_VFLIP:
val = ctrl->val ? REG04_VFLIP_IMG : 0x00;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] ov2640: add support for V4L2_MBUS_FMT_YUYV8_2X8, V4L2_MBUS_FMT_RGB565_2X8_BE
2012-09-23 12:07 [PATCH 1/3] ov2640: select sensor register bank before applying h/v-flip settings Frank Schäfer
@ 2012-09-23 12:07 ` Frank Schäfer
2012-09-23 12:07 ` [PATCH 3/3] ov2640: simplify single register writes Frank Schäfer
1 sibling, 0 replies; 4+ messages in thread
From: Frank Schäfer @ 2012-09-23 12:07 UTC (permalink / raw)
To: g.liakhovetski; +Cc: linux-media, Frank Schäfer
This is the result of experimenting with the SpeedLink VAD Laplace webcam.
The register sequence for V4L2_MBUS_FMT_YUYV8_2X8 has been identified by
analyzing USB-logs of this device running on MS Windows.
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
drivers/media/i2c/soc_camera/ov2640.c | 49 ++++++++++++++++++++++++++++-----
1 Datei geändert, 42 Zeilen hinzugefügt(+), 7 Zeilen entfernt(-)
diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c
index e4fc79e..182d5a1 100644
--- a/drivers/media/i2c/soc_camera/ov2640.c
+++ b/drivers/media/i2c/soc_camera/ov2640.c
@@ -586,9 +586,20 @@ static const struct regval_list ov2640_format_change_preamble_regs[] = {
ENDMARKER,
};
-static const struct regval_list ov2640_yuv422_regs[] = {
+static const struct regval_list ov2640_yuyv_regs[] = {
+ { IMAGE_MODE, IMAGE_MODE_YUV422 },
+ { 0xd7, 0x03 },
+ { 0x33, 0xa0 },
+ { 0xe5, 0x1f },
+ { 0xe1, 0x67 },
+ { RESET, 0x00 },
+ { R_BYPASS, R_BYPASS_USE_DSP },
+ ENDMARKER,
+};
+
+static const struct regval_list ov2640_uyvy_regs[] = {
{ IMAGE_MODE, IMAGE_MODE_LBYTE_FIRST | IMAGE_MODE_YUV422 },
- { 0xD7, 0x01 },
+ { 0xd7, 0x01 },
{ 0x33, 0xa0 },
{ 0xe1, 0x67 },
{ RESET, 0x00 },
@@ -596,7 +607,15 @@ static const struct regval_list ov2640_yuv422_regs[] = {
ENDMARKER,
};
-static const struct regval_list ov2640_rgb565_regs[] = {
+static const struct regval_list ov2640_rgb565_be_regs[] = {
+ { IMAGE_MODE, IMAGE_MODE_RGB565 },
+ { 0xd7, 0x03 },
+ { RESET, 0x00 },
+ { R_BYPASS, R_BYPASS_USE_DSP },
+ ENDMARKER,
+};
+
+static const struct regval_list ov2640_rgb565_le_regs[] = {
{ IMAGE_MODE, IMAGE_MODE_LBYTE_FIRST | IMAGE_MODE_RGB565 },
{ 0xd7, 0x03 },
{ RESET, 0x00 },
@@ -605,7 +624,9 @@ static const struct regval_list ov2640_rgb565_regs[] = {
};
static enum v4l2_mbus_pixelcode ov2640_codes[] = {
+ V4L2_MBUS_FMT_YUYV8_2X8,
V4L2_MBUS_FMT_UYVY8_2X8,
+ V4L2_MBUS_FMT_RGB565_2X8_BE,
V4L2_MBUS_FMT_RGB565_2X8_LE,
};
@@ -790,14 +811,22 @@ static int ov2640_set_params(struct i2c_client *client, u32 *width, u32 *height,
/* select format */
priv->cfmt_code = 0;
switch (code) {
+ case V4L2_MBUS_FMT_RGB565_2X8_BE:
+ dev_dbg(&client->dev, "%s: Selected cfmt RGB565 BE", __func__);
+ selected_cfmt_regs = ov2640_rgb565_be_regs;
+ break;
case V4L2_MBUS_FMT_RGB565_2X8_LE:
- dev_dbg(&client->dev, "%s: Selected cfmt RGB565", __func__);
- selected_cfmt_regs = ov2640_rgb565_regs;
+ dev_dbg(&client->dev, "%s: Selected cfmt RGB565 LE", __func__);
+ selected_cfmt_regs = ov2640_rgb565_le_regs;
+ break;
+ case V4L2_MBUS_FMT_YUYV8_2X8:
+ dev_dbg(&client->dev, "%s: Selected cfmt YUYV (YUV422)", __func__);
+ selected_cfmt_regs = ov2640_yuyv_regs;
break;
default:
case V4L2_MBUS_FMT_UYVY8_2X8:
- dev_dbg(&client->dev, "%s: Selected cfmt YUV422", __func__);
- selected_cfmt_regs = ov2640_yuv422_regs;
+ dev_dbg(&client->dev, "%s: Selected cfmt UYVY", __func__);
+ selected_cfmt_regs = ov2640_uyvy_regs;
}
/* reset hardware */
@@ -862,10 +891,12 @@ static int ov2640_g_fmt(struct v4l2_subdev *sd,
mf->code = priv->cfmt_code;
switch (mf->code) {
+ case V4L2_MBUS_FMT_RGB565_2X8_BE:
case V4L2_MBUS_FMT_RGB565_2X8_LE:
mf->colorspace = V4L2_COLORSPACE_SRGB;
break;
default:
+ case V4L2_MBUS_FMT_YUYV8_2X8:
case V4L2_MBUS_FMT_UYVY8_2X8:
mf->colorspace = V4L2_COLORSPACE_JPEG;
}
@@ -882,11 +913,13 @@ static int ov2640_s_fmt(struct v4l2_subdev *sd,
switch (mf->code) {
+ case V4L2_MBUS_FMT_RGB565_2X8_BE:
case V4L2_MBUS_FMT_RGB565_2X8_LE:
mf->colorspace = V4L2_COLORSPACE_SRGB;
break;
default:
mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
+ case V4L2_MBUS_FMT_YUYV8_2X8:
case V4L2_MBUS_FMT_UYVY8_2X8:
mf->colorspace = V4L2_COLORSPACE_JPEG;
}
@@ -909,11 +942,13 @@ static int ov2640_try_fmt(struct v4l2_subdev *sd,
mf->field = V4L2_FIELD_NONE;
switch (mf->code) {
+ case V4L2_MBUS_FMT_RGB565_2X8_BE:
case V4L2_MBUS_FMT_RGB565_2X8_LE:
mf->colorspace = V4L2_COLORSPACE_SRGB;
break;
default:
mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
+ case V4L2_MBUS_FMT_YUYV8_2X8:
case V4L2_MBUS_FMT_UYVY8_2X8:
mf->colorspace = V4L2_COLORSPACE_JPEG;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] ov2640: simplify single register writes
2012-09-23 12:07 [PATCH 1/3] ov2640: select sensor register bank before applying h/v-flip settings Frank Schäfer
2012-09-23 12:07 ` [PATCH 2/3] ov2640: add support for V4L2_MBUS_FMT_YUYV8_2X8, V4L2_MBUS_FMT_RGB565_2X8_BE Frank Schäfer
@ 2012-09-23 12:07 ` Frank Schäfer
2012-09-23 18:25 ` Frank Schäfer
1 sibling, 1 reply; 4+ messages in thread
From: Frank Schäfer @ 2012-09-23 12:07 UTC (permalink / raw)
To: g.liakhovetski; +Cc: linux-media, Frank Schäfer
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
---
drivers/media/i2c/soc_camera/ov2640.c | 21 ++++++++++++---------
1 Datei geändert, 12 Zeilen hinzugefügt(+), 9 Zeilen entfernt(-)
diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c
index 182d5a1..70b222f 100644
--- a/drivers/media/i2c/soc_camera/ov2640.c
+++ b/drivers/media/i2c/soc_camera/ov2640.c
@@ -639,17 +639,23 @@ static struct ov2640_priv *to_ov2640(const struct i2c_client *client)
subdev);
}
+static int ov2640_write_single(struct i2c_client *client, u8 reg, u8 val)
+{
+ int ret;
+
+ ret = i2c_smbus_write_byte_data(client, reg, val);
+ dev_vdbg(&client->dev, "write: 0x%02x, 0x%02x", reg, val);
+
+ return ret;
+}
+
static int ov2640_write_array(struct i2c_client *client,
const struct regval_list *vals)
{
int ret;
while ((vals->reg_num != 0xff) || (vals->value != 0xff)) {
- ret = i2c_smbus_write_byte_data(client,
- vals->reg_num, vals->value);
- dev_vdbg(&client->dev, "array: 0x%02x, 0x%02x",
- vals->reg_num, vals->value);
-
+ ret = ov2640_write_single(client, vals->reg_num, vals->value);
if (ret < 0)
return ret;
vals++;
@@ -704,13 +710,10 @@ static int ov2640_s_ctrl(struct v4l2_ctrl *ctrl)
struct v4l2_subdev *sd =
&container_of(ctrl->handler, struct ov2640_priv, hdl)->subdev;
struct i2c_client *client = v4l2_get_subdevdata(sd);
- struct regval_list regval;
int ret;
u8 val;
- regval.reg_num = BANK_SEL;
- regval.value = BANK_SEL_SENS;
- ret = ov2640_write_array(client, ®val);
+ ret = ov2640_write_single(client, BANK_SEL, BANK_SEL_SENS);
if (ret < 0)
return ret;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] ov2640: simplify single register writes
2012-09-23 12:07 ` [PATCH 3/3] ov2640: simplify single register writes Frank Schäfer
@ 2012-09-23 18:25 ` Frank Schäfer
0 siblings, 0 replies; 4+ messages in thread
From: Frank Schäfer @ 2012-09-23 18:25 UTC (permalink / raw)
To: g.liakhovetski; +Cc: linux-media
Am 23.09.2012 15:07, schrieb Frank Schäfer:
> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
> ---
> drivers/media/i2c/soc_camera/ov2640.c | 21 ++++++++++++---------
> 1 Datei geändert, 12 Zeilen hinzugefügt(+), 9 Zeilen entfernt(-)
>
> diff --git a/drivers/media/i2c/soc_camera/ov2640.c b/drivers/media/i2c/soc_camera/ov2640.c
> index 182d5a1..70b222f 100644
> --- a/drivers/media/i2c/soc_camera/ov2640.c
> +++ b/drivers/media/i2c/soc_camera/ov2640.c
> @@ -639,17 +639,23 @@ static struct ov2640_priv *to_ov2640(const struct i2c_client *client)
> subdev);
> }
>
> +static int ov2640_write_single(struct i2c_client *client, u8 reg, u8 val)
> +{
> + int ret;
> +
> + ret = i2c_smbus_write_byte_data(client, reg, val);
> + dev_vdbg(&client->dev, "write: 0x%02x, 0x%02x", reg, val);
> +
> + return ret;
Uhm... wait ! Of course we can get rid of int ret.
Will resend in a minute...
Regards,
Frank
> +}
> +
> static int ov2640_write_array(struct i2c_client *client,
> const struct regval_list *vals)
> {
> int ret;
>
> while ((vals->reg_num != 0xff) || (vals->value != 0xff)) {
> - ret = i2c_smbus_write_byte_data(client,
> - vals->reg_num, vals->value);
> - dev_vdbg(&client->dev, "array: 0x%02x, 0x%02x",
> - vals->reg_num, vals->value);
> -
> + ret = ov2640_write_single(client, vals->reg_num, vals->value);
> if (ret < 0)
> return ret;
> vals++;
> @@ -704,13 +710,10 @@ static int ov2640_s_ctrl(struct v4l2_ctrl *ctrl)
> struct v4l2_subdev *sd =
> &container_of(ctrl->handler, struct ov2640_priv, hdl)->subdev;
> struct i2c_client *client = v4l2_get_subdevdata(sd);
> - struct regval_list regval;
> int ret;
> u8 val;
>
> - regval.reg_num = BANK_SEL;
> - regval.value = BANK_SEL_SENS;
> - ret = ov2640_write_array(client, ®val);
> + ret = ov2640_write_single(client, BANK_SEL, BANK_SEL_SENS);
> if (ret < 0)
> return ret;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-23 19:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-23 12:07 [PATCH 1/3] ov2640: select sensor register bank before applying h/v-flip settings Frank Schäfer
2012-09-23 12:07 ` [PATCH 2/3] ov2640: add support for V4L2_MBUS_FMT_YUYV8_2X8, V4L2_MBUS_FMT_RGB565_2X8_BE Frank Schäfer
2012-09-23 12:07 ` [PATCH 3/3] ov2640: simplify single register writes Frank Schäfer
2012-09-23 18:25 ` Frank Schäfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).