Skip to contentSkip to conversation

ov772x: add edge contrl support

PATCH Superseded Kuninori Morimoto 2 participants 5 messages Mar 23, 2009 Media (V4L/DVB)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ov772x: add edge contrl support

---
This patch is 1st step for extra settings

 drivers/media/video/ov772x.c |   34 ++++++++++++++++++++++++++++++++++
 include/media/ov772x.h       |   25 +++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)
drivers/media/video/ov772x.c +34 -0
index 34c9819..a951327 100644
@@ -358,6 +358,15 @@
 #define VOSZ_VGA        0xF0
 #define VOSZ_QVGA       0x78
 
+/* EDGE CTRL
+ * see alse
+ *    ov772x.h :: for Edge ctrl
+ */
+#define EDGE0CTRL(param) (((param) >> 24) & 0x1F)
+#define EDGE1CTRL(param) (((param) >> 16) & 0x0F)
+#define EDGE2CTRL(param) (((param) >>  8) & 0xFF)
+#define EDGE3CTRL(param) (((param) >>  0) & 0xFF)
+
 /*
  * ID
  */
@@ -816,6 +825,31 @@ static int ov772x_set_params(struct ov772x_priv *priv, u32 width, u32 height,
 	ov772x_reset(priv->client);
 
 	/*
+	 * set Edge Ctrl if platform has edgectrl
+	 */
+	if (priv->info->edgectrl & OV772X_EDGECTRL_ENABLE) {
+		ret = ov772x_mask_set(priv->client,
+				EDGE0, 0x1F, EDGE0CTRL(priv->info->edgectrl));
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client,
+				EDGE1, 0x0F, EDGE1CTRL(priv->info->edgectrl));
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client,
+				EDGE2, 0xFF, EDGE2CTRL(priv->info->edgectrl));
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client,
+				EDGE3, 0xFF, EDGE3CTRL(priv->info->edgectrl));
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+	}
+
+	/*
 	 * set size format
 	 */
 	ret = ov772x_write_array(priv->client, priv->win->regs);
include/media/ov772x.h +25 -0
index 57db48d..5b083dc 100644
@@ -17,9 +17,34 @@
 #define OV772X_FLAG_VFLIP     0x00000001 /* Vertical flip image */
 #define OV772X_FLAG_HFLIP     0x00000002 /* Horizontal flip image */
 
+/*
+ * for Edge ctrl
+ *
+ * strength  : (for EDGE0) Edge enhancement strength control
+ * threshold : (for EDGE1) Edge enhancement threshold control
+ * low       : (for EDGE2) Edge enhancement strength Low point control
+ * high      : (for EDGE3) Edge enhancement strength High point control
+ *
+ * Meaning of edgectrl bit
+ *
+ * Exx0 0000 xxxx 1111 2222 2222 3333 3333
+ *
+ * E: use edgectrl or not (OV772X_EDGECTRL_ENABLE)
+ * 0: for Edge0 ctrl
+ * 1: for Edge1 ctrl
+ * 2: for Edge2 ctrl
+ * 3: for Edge3 ctrl
+ */
+#define OV772X_EDGECTRL_ENABLE	0x80000000
+#define OV772X_EDGECTRL(strength, threshold, low, high) \
+	(OV772X_EDGECTRL_ENABLE | \
+	 (strength & 0x1F) << 24 | (threshold & 0x0F) << 16 | \
+	 (low & 0xFF) << 8 | (high & 0xFF) << 0)
+
 struct ov772x_camera_info {
 	unsigned long          buswidth;
 	unsigned long          flags;
+	unsigned long          edgectrl;
 	struct soc_camera_link link;
 };
 
Signature · 1 line
1.5.6.3
#1 lore raw
Quoted 87 lines · Kuninori Morimoto

---
This patch is 1st step for extra settings

 drivers/media/video/ov772x.c |   34 ++++++++++++++++++++++++++++++++++
 include/media/ov772x.h       |   25 +++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)
drivers/media/video/ov772x.c +34 -0
index 34c9819..a951327 100644
@@ -358,6 +358,15 @@
 #define VOSZ_VGA        0xF0
 #define VOSZ_QVGA       0x78
 
+/* EDGE CTRL
+ * see alse
+ *    ov772x.h :: for Edge ctrl
+ */
+#define EDGE0CTRL(param) (((param) >> 24) & 0x1F)
+#define EDGE1CTRL(param) (((param) >> 16) & 0x0F)
+#define EDGE2CTRL(param) (((param) >>  8) & 0xFF)
+#define EDGE3CTRL(param) (((param) >>  0) & 0xFF)
+
 /*
  * ID
  */
@@ -816,6 +825,31 @@ static int ov772x_set_params(struct ov772x_priv *priv, u32 width, u32 height,
 	ov772x_reset(priv->client);
 
 	/*
+	 * set Edge Ctrl if platform has edgectrl
+	 */
+	if (priv->info->edgectrl & OV772X_EDGECTRL_ENABLE) {
+		ret = ov772x_mask_set(priv->client,
+				EDGE0, 0x1F, EDGE0CTRL(priv->info->edgectrl));
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client,
+				EDGE1, 0x0F, EDGE1CTRL(priv->info->edgectrl));
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client,
+				EDGE2, 0xFF, EDGE2CTRL(priv->info->edgectrl));
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+
+		ret = ov772x_mask_set(priv->client,
+				EDGE3, 0xFF, EDGE3CTRL(priv->info->edgectrl));
+		if (ret < 0)
+			goto ov772x_set_fmt_error;
+	}
+
+	/*
 	 * set size format
 	 */
 	ret = ov772x_write_array(priv->client, priv->win->regs);
include/media/ov772x.h +18 -0
index 57db48d..5b083dc 100644
@@ -17,9 +17,34 @@
 #define OV772X_FLAG_VFLIP     0x00000001 /* Vertical flip image */
 #define OV772X_FLAG_HFLIP     0x00000002 /* Horizontal flip image */
 
+/*
+ * for Edge ctrl
+ *
+ * strength  : (for EDGE0) Edge enhancement strength control
+ * threshold : (for EDGE1) Edge enhancement threshold control
+ * low       : (for EDGE2) Edge enhancement strength Low point control
+ * high      : (for EDGE3) Edge enhancement strength High point control
+ *
+ * Meaning of edgectrl bit
+ *
+ * Exx0 0000 xxxx 1111 2222 2222 3333 3333
+ *
+ * E: use edgectrl or not (OV772X_EDGECTRL_ENABLE)
+ * 0: for Edge0 ctrl
+ * 1: for Edge1 ctrl
+ * 2: for Edge2 ctrl
+ * 3: for Edge3 ctrl
+ */

include/media/ov772x.h line 47

Quoted 10 lines
include/media/ov772x.h +7 -0
+#define OV772X_EDGECTRL_ENABLE	0x80000000
+#define OV772X_EDGECTRL(strength, threshold, low, high) \
+	(OV772X_EDGECTRL_ENABLE | \
+	 (strength & 0x1F) << 24 | (threshold & 0x0F) << 16 | \
+	 (low & 0xFF) << 8 | (high & 0xFF) << 0)
+
 struct ov772x_camera_info {
 	unsigned long          buswidth;
 	unsigned long          flags;
+	unsigned long          edgectrl;

Wouldn't it be easier to use

	unsigned char	edge_strength;
	unsigned char	edge_threshold;
	unsigned char	edge_low;
	unsigned char	edge_high;

and thus avoid all that shifting?

Quoted 5 lines
include/media/ov772x.h +0 -0
 	struct soc_camera_link link;
 };
 
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

Quoted 8 lines

Wouldn't it be easier to use

	unsigned char	edge_strength;
	unsigned char	edge_threshold;
	unsigned char	edge_low;
	unsigned char	edge_high;

and thus avoid all that shifting?

Yes. it is easier to use.
But, driver should judge whether to use this setting or not. Because this setting is optional.

Because user setting might be 0,
we can not judge it like this.
if (edge_xxx)

       ov772x_mask_set( xxxx )

So, we can use un-used bit to judge whether to use it. and edge_strength and edge_threshold have un-used bit. But edge_low and edge_high doesn't have un-used bit.

Another way to judge it is to use pointer or to add another variable. But I don't like these style.
What do you think about this ?

Best regards
--
Kuninori Morimoto

#3 lore raw
Quoted 22 lines · On Mon, 23 Mar 2009, [email protected] wrote:

Dear Guennadi

Thank you for checking

Quoted 8 lines

Wouldn't it be easier to use

	unsigned char	edge_strength;
	unsigned char	edge_threshold;
	unsigned char	edge_low;
	unsigned char	edge_high;

and thus avoid all that shifting?

Yes. it is easier to use.
But, driver should judge whether to use this setting or not. Because this setting is optional.

Because user setting might be 0,
we can not judge it like this.
if (edge_xxx)

       ov772x_mask_set( xxxx )
Quoted 7 lines

So, we can use un-used bit to judge whether to use it. and edge_strength and edge_threshold have un-used bit. But edge_low and edge_high doesn't have un-used bit.

Another way to judge it is to use pointer or to add another variable. But I don't like these style.
What do you think about this ?

Is edge_strength == 0 a useful edge configuration? Cannot you use it as a test whether to set all edge parameters or not? If you cannot, well, just do the same as what you have done with 32-bits - use one bit in strength as "edge enable" - just exactly in the same way as in your patch. Like

	if (edge_strength & EDGE_ENABLE) {
		set_strength;
		set_threshold;
		set_low;
		set_high;
	}

Thanks
Guennadi
---
Guennadi Liakhovetski

#4 lore raw

Dear Guennadi

Quoted 11 lines

Is edge_strength == 0 a useful edge configuration? Cannot you use it as a test whether to set all edge parameters or not? If you cannot, well, just do the same as what you have done with 32-bits - use one bit in strength as "edge enable" - just exactly in the same way as in your patch. Like

	if (edge_strength & EDGE_ENABLE) {
		set_strength;
		set_threshold;
		set_low;
		set_high;
	}

Hmm..
edge_threshold has 4 un-used bit.
we can use it for judge.

And sorry, I don't like this style

	unsigned char	edge_strength;
	unsigned char	edge_threshold;
	unsigned char	edge_low;
	unsigned char	edge_high;

I will create new struct ov772x_edge for it.

Best regards
--
Kuninori Morimoto