Skip to contentSkip to conversation

ov772x: add edge contrl support

PATCH Superseded Kuninori Morimoto 2 participants 4 messages Mar 24, 2009 – Mar 27, 2009 Media (V4L/DVB)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ov772x: add edge contrl support

---
v2 -> v3
o use edgectrl.strength for judge

Sorry for my miss-understanding.
This patch use edgectrl.strength for judgement. And the explain in the comment has all.
My datasheet doesn't have details more than this explain.

 drivers/media/video/ov772x.c |   25 +++++++++++++++++++++++++
 include/media/ov772x.h       |   21 +++++++++++++++++++++
 2 files changed, 46 insertions(+), 0 deletions(-)
drivers/media/video/ov772x.c +25 -0
index 34c9819..3226c43 100644
@@ -816,6 +816,31 @@ static int ov772x_set_params(struct ov772x_priv *priv, u32 width, u32 height,
 	ov772x_reset(priv->client);
 
 	/*
+	 * set Edge Ctrl
+	 */
+	if (priv->info->edgectrl.strength) {
+		ret = ov772x_mask_set(priv->client, EDGE0, 0x1F,
+				      priv->info->edgectrl.strength);
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client, EDGE1, 0x0F,
+				      priv->info->edgectrl.threshold);
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client, EDGE2, 0xFF,
+				      priv->info->edgectrl.upper);
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client, EDGE3, 0xFF,
+				      priv->info->edgectrl.lower);
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+	}
+
+	/*
 	 * set size format
 	 */
 	ret = ov772x_write_array(priv->client, priv->win->regs);
include/media/ov772x.h +21 -0
index 57db48d..cfdd80e 100644
@@ -17,10 +17,31 @@
 #define OV772X_FLAG_VFLIP     0x00000001 /* Vertical flip image */
 #define OV772X_FLAG_HFLIP     0x00000002 /* Horizontal flip image */
 
+/*
+ * for Edge ctrl
+ */
+struct ov772x_edge_ctrl {
+	unsigned char strength;  /* strength control */
+	unsigned char threshold; /* threshold detection */
+	unsigned char upper;     /* strength upper limit */
+	unsigned char lower;     /* strength lower limit */
+};
+
+#define OV772X_EDGECTRL(s, t, u, l) \
+	{.strength  = (s & 0x1F),\
+	 .threshold = (t & 0x0F),\
+	 .upper     = (u & 0xFF),\
+	 .lower     = (l & 0xFF),\
+	}
+
+/*
+ * ov772x camera info
+ */
 struct ov772x_camera_info {
 	unsigned long          buswidth;
 	unsigned long          flags;
 	struct soc_camera_link link;
+	struct ov772x_edge_ctrl edgectrl;
 };
 
 #endif /* __OV772X_H__ */
Signature · 1 line
1.5.6.3
#1 lore raw
Quoted 19 lines · Kuninori Morimoto

---
v2 -> v3
o use edgectrl.strength for judge

Sorry for my miss-understanding.
This patch use edgectrl.strength for judgement. And the explain in the comment has all.
My datasheet doesn't have details more than this explain.

 drivers/media/video/ov772x.c |   25 +++++++++++++++++++++++++
 include/media/ov772x.h       |   21 +++++++++++++++++++++
 2 files changed, 46 insertions(+), 0 deletions(-)
drivers/media/video/ov772x.c +0 -0
index 34c9819..3226c43 100644

drivers/media/video/ov772x.c static int ov772x_set_params(struct ov772x_priv *priv, u32 width, u32 height, · line 825

Quoted 10 lines
drivers/media/video/ov772x.c +7 -0
@@ -816,6 +816,31 @@ static int ov772x_set_params(struct ov772x_priv *priv, u32 width, u32 height,
 	ov772x_reset(priv->client);
 
 	/*
+	 * set Edge Ctrl
+	 */
+	if (priv->info->edgectrl.strength) {
+		ret = ov772x_mask_set(priv->client, EDGE0, 0x1F,
+				      priv->info->edgectrl.strength);
+		if (ret < 0)
+			goto ov772x_set_fmt_error;

Whatever this "edge" does, isn't it so, that "threshold," "upper," and "lower" parameters configure it and "strength" actually enforces the changes? Say, if strength == 0, edge control is off, and as soon as you switch it to != 0, it is on with all the configured parameters? If my guess is right, wouldn't it make sense to first configure parameters and then set strength? If you agree, I'll just swap them when committing, so, you don't have to resend. Just please either confirm that you agree, or explain why I am wrong.

Quoted 35 lines
drivers/media/video/ov772x.c +18 -0
+
+		ret = ov772x_mask_set(priv->client, EDGE1, 0x0F,
+				      priv->info->edgectrl.threshold);
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client, EDGE2, 0xFF,
+				      priv->info->edgectrl.upper);
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client, EDGE3, 0xFF,
+				      priv->info->edgectrl.lower);
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+	}
+
+	/*
 	 * set size format
 	 */
 	ret = ov772x_write_array(priv->client, priv->win->regs);
include/media/ov772x.h +6 -0
index 57db48d..cfdd80e 100644
@@ -17,10 +17,31 @@
 #define OV772X_FLAG_VFLIP     0x00000001 /* Vertical flip image */
 #define OV772X_FLAG_HFLIP     0x00000002 /* Horizontal flip image */
 
+/*
+ * for Edge ctrl
+ */
+struct ov772x_edge_ctrl {
+	unsigned char strength;  /* strength control */
+	unsigned char threshold; /* threshold detection */

include/media/ov772x.h line 35

Quoted 10 lines
include/media/ov772x.h +10 -0
+	unsigned char upper;     /* strength upper limit */
+	unsigned char lower;     /* strength lower limit */
+};
+
+#define OV772X_EDGECTRL(s, t, u, l) \
+	{.strength  = (s & 0x1F),\
+	 .threshold = (t & 0x0F),\
+	 .upper     = (u & 0xFF),\
+	 .lower     = (l & 0xFF),\
+	}

If you don't mind, I'll reformat this slightly to

+#define OV772X_EDGECTRL(s, t, u, l) \
+{ \
+ .strength = (s & 0x1F), \
+ .threshold = (t & 0x0F), \
+ .upper = (u & 0xFF), \
+ .lower = (l & 0xFF), \
+}

when applying, ok?

Quoted 14 lines
include/media/ov772x.h +5 -0
+
+/*
+ * ov772x camera info
+ */
 struct ov772x_camera_info {
 	unsigned long          buswidth;
 	unsigned long          flags;
 	struct soc_camera_link link;
+	struct ov772x_edge_ctrl edgectrl;
 };
 
 #endif /* __OV772X_H__ */
Signature · 1 line
1.5.6.3

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer

#2 lore raw

Dear Guennadi

Thank you for checking patch

Quoted 8 lines

Whatever this "edge" does, isn't it so, that "threshold," "upper," and "lower" parameters configure it and "strength" actually enforces the changes? Say, if strength == 0, edge control is off, and as soon as you switch it to != 0, it is on with all the configured parameters? If my guess is right, wouldn't it make sense to first configure parameters and then set strength? If you agree, I'll just swap them when committing, so, you don't have to resend. Just please either confirm that you agree, or explain why I am wrong.

I don't know detail of these register's order. Because my datasheet doesn't have detail explain.

For example, does "strength" actually enforce all of configured parameters change ?

So, I tried to test whether these register setting order were important.

It seems to be independent apparently respectively. For example, I can change only "upper" register and the setting was effective.

So, I will ask to maker about these register's behavior. Because it seems to relate to other register. So, please ignore this patch until I get answer. sorry.

Review

Quoted 7 lines
(quoted diff) +7 -0
+#define OV772X_EDGECTRL(s, t, u, l)	\
+{					\
+	.strength	= (s & 0x1F),	\
+	.threshold	= (t & 0x0F),	\
+	.upper		= (u & 0xFF),	\
+	.lower		= (l & 0xFF),	\
+}

I will fix this in next =)

Best regards
--
Kuninori Morimoto

#3 lore raw

Hello Morimoto-san

Quoted 15 lines · On Wed, 25 Mar 2009, [email protected] wrote:
Quoted 8 lines

Whatever this "edge" does, isn't it so, that "threshold," "upper," and "lower" parameters configure it and "strength" actually enforces the changes? Say, if strength == 0, edge control is off, and as soon as you switch it to != 0, it is on with all the configured parameters? If my guess is right, wouldn't it make sense to first configure parameters and then set strength? If you agree, I'll just swap them when committing, so, you don't have to resend. Just please either confirm that you agree, or explain why I am wrong.

I don't know detail of these register's order. Because my datasheet doesn't have detail explain.

For example, does "strength" actually enforce all of configured parameters change ?

Quoted 6 lines

So, I tried to test whether these register setting order were important.

It seems to be independent apparently respectively. For example, I can change only "upper" register and the setting was effective.

So, you _do_ know what that parameter does - if you can verify what effect it produces on the camera? So, that's just what I was asking - what do these settings do? What changes do you observe when you manipulate them? And this your observation actually suffices to me to preserve your original order of register writes. If documentation says nothing about it, and as long as it works - we can keep it.

Quoted 3 lines

So, I will ask to maker about these register's behavior. Because it seems to relate to other register. So, please ignore this patch until I get answer. sorry.

Well, I don't think we have to wait for an answer for too long. If they don't reply within 1-2 days, let's just take the patch as is (with the single minor correction I proposed).

Quoted 9 lines

Review

Quoted 7 lines
(quoted diff) +7 -0
+#define OV772X_EDGECTRL(s, t, u, l)	\
+{					\
+	.strength	= (s & 0x1F),	\
+	.threshold	= (t & 0x0F),	\
+	.upper		= (u & 0xFF),	\
+	.lower		= (l & 0xFF),	\
+}

I will fix this in next =)

That's up to you. This is a minor formatting correction, which I can do myself when merging. But if you like, you can send an update, sure.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer