Skip to contentSkip to conversation

Add tw9910 driver

PATCH Superseded Kuninori Morimoto 2 participants 3 messages Dec 17, 2008 – Dec 18, 2008 Media (V4L/DVB)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 Add tw9910 driver

This patch adds tw9910 driver that use soc_camera framework. It was tested on SH Migo-r board and mplayer.

---
v4 -> v5

o change to just return on tw9910_set_fmt
o add i2c_set_clientdata(client, NULL)
these are advice from Hiremath.
Thank you Hiremath

 drivers/media/video/Kconfig     |    6 +
 drivers/media/video/Makefile    |    1 +
 drivers/media/video/tw9910.c    |  959 +++++++++++++++++++++++++++++++++++++++
 include/media/tw9910.h          |   39 ++
 include/media/v4l2-chip-ident.h |    3 +
 5 files changed, 1008 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/tw9910.c
 create mode 100644 include/media/tw9910.h
drivers/media/video/Kconfig +6 -0
index af951bd..8eb3869 100644
@@ -744,6 +744,12 @@ config MT9V022_PCA9536_SWITCH
 	  Select this if your MT9V022 camera uses a PCA9536 I2C GPIO
 	  extender to switch between 8 and 10 bit datawidth modes
 
+config SOC_CAMERA_TW9910
+	tristate "tw9910 support"
+	depends on SOC_CAMERA && I2C
+	help
+	  This is a tw9910 video driver
+
 config SOC_CAMERA_PLATFORM
 	tristate "platform camera support"
 	depends on SOC_CAMERA
drivers/media/video/Makefile +1 -0
index cc6698e..f1e004d 100644
@@ -135,6 +135,7 @@ obj-$(CONFIG_SOC_CAMERA_MT9M111)	+= mt9m111.o
 obj-$(CONFIG_SOC_CAMERA_MT9V022)	+= mt9v022.o
 obj-$(CONFIG_SOC_CAMERA_OV772X)		+= ov772x.o
 obj-$(CONFIG_SOC_CAMERA_PLATFORM)	+= soc_camera_platform.o
+obj-$(CONFIG_SOC_CAMERA_TW9910)		+= tw9910.o
 
 obj-$(CONFIG_VIDEO_AU0828) += au0828/
 
drivers/media/video/tw9910.c new file +959 -0

959 lines not on this page · raw message

include/media/tw9910.h new file +39 -0
new file mode 100644
index 0000000..af825e8
@@ -0,0 +1,39 @@
+/*
+ * tw9910 Driver header
+ *
+ * Copyright (C) 2008 Renesas Solutions Corp.
+ * Kuninori Morimoto <[email protected]>
+ *
+ * Based on ov772x.h
+ *
+ * Copyright (C) Kuninori Morimoto <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __TW9910_H__
+#define __TW9910_H__
+
+#include <media/soc_camera.h>
+
+enum MPOUT_pin {
+	MPO_VLOSS,
+	MPO_HLOCK,
+	MPO_SLOCK,
+	MPO_VLOCK,
+	MPO_MONO,
+	MPO_DET50,
+	MPO_FIELD,
+	MPO_RTCO,
+};
+
+struct tw9910_video_info {
+	unsigned long          buswidth;
+	enum MPOUT_pin         mpout;
+	struct soc_camera_link link;
+};
+
+
+#endif /* __TW9910_H__ */
include/media/v4l2-chip-ident.h +3 -0
index 14a205f..0895eb2 100644
@@ -84,6 +84,9 @@ enum {
 	/* module wm8775: just ident 8775 */
 	V4L2_IDENT_WM8775 = 8775,
 
+	/* module tw9910: just ident 9910 */
+	V4L2_IDENT_TW9910 = 9910,
+
 	/* module cs53132a: just ident 53132 */
 	V4L2_IDENT_CS53l32A = 53132,
 
Signature · 6 lines
1.5.6.3

--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
#1 lore raw

What a pity, you were too fast:-( I tried to comment on your v4 to prevent an extra round, but you were faster:-( Let's hope v6 will be the last one! And the changes I'm proposing below are not too hard, so, should be an easy one.

Quoted 27 lines · Kuninori Morimoto
drivers/media/video/tw9910.c new file +27 -0
+static const struct tw9910_scale_ctrl*
+tw9910_select_norm(v4l2_std_id norm, struct v4l2_rect *rect)
+{
+	const struct tw9910_scale_ctrl *scale;
+	const struct tw9910_scale_ctrl *ret = NULL;
+	int i;
+
+	if (norm & V4L2_STD_NTSC) {
+		scale = tw9910_ntsc_scales;
+		for (i = 0; i < ARRAY_SIZE(tw9910_ntsc_scales); i++) {
+			if (scale[i].width  == rect->width ||
+			    scale[i].height == rect->height) {
+				ret = scale + i;
+			}
+
+			if (scale[i].width  == rect->width &&
+			    scale[i].height == rect->height) {
+				return scale + i;
+			}
+		}
+	} else if (norm & V4L2_STD_PAL) {
+		scale = tw9910_pal_scales;
+		for (i = 0; i < ARRAY_SIZE(tw9910_pal_scales); i++) {
+			if (scale[i].width  == rect->width ||
+			    scale[i].height == rect->height) {
+				ret = scale + i;
+			}

drivers/media/video/tw9910.c line 512

Quoted 10 lines
drivers/media/video/tw9910.c new file +10 -0
+
+			if (scale[i].width  == rect->width &&
+			    scale[i].height == rect->height) {
+				return scale + i;
+			}
+		}
+	}
+
+	return ret;
+}

Hm, sorry, I should have explained "select the nearest if no exact match is found" better. Now you check whether at least one parameter matches exactly, if not, you just fail. But if we allow one parameter to not match and just overwrite it, maybe we could do better yet and allow both to not match? Wouldn't it be better to select some metric in your width-height space and find the nearest point to the requested one? You can either use the classical (w - w_fixed)^2 + (h - h_fixed)^2 or a computationally lighter abs(w - w_fixed) + abs(h - h_fixed).

This method also has an advantage over yours if one of parameters match exactly. Suppose, the user requested 600x480 NTSC. With your current implementation you'd end up selecting 720x480, whereas 640x480 is closer.

Quoted 9 lines
drivers/media/video/tw9910.c new file +9 -0
+static int tw9910_start_capture(struct soc_camera_device *icd)
+{
+	struct tw9910_priv *priv = container_of(icd, struct tw9910_priv, icd);
+
+	if (!priv->scale) {
+		dev_err(&icd->dev, "norm select error\n");
+		return -EPERM;
+	}
+

drivers/media/video/tw9910.c line 563

Quoted 10 lines
drivers/media/video/tw9910.c new file +10 -0
+	if (icd->width  != priv->scale->width ||
+	    icd->height != priv->scale->height) {
+		dev_err(&icd->dev, "norm scale error\n");
+		return -EPERM;
+	}
+
+	dev_info(&icd->dev, "%s %dx%d\n",
+		 priv->scale->name,
+		 priv->scale->width,
+		 priv->scale->height);

dev_dbg, please.

drivers/media/video/tw9910.c line 921

Quoted 5 lines
drivers/media/video/tw9910.c new file +5 -0
+static int tw9910_remove(struct i2c_client *client)
+{
+	struct tw9910_priv *priv = i2c_get_clientdata(client);
+
+	soc_camera_device_unregister(&priv->icd);

Here too:

+ i2c_set_clientdata(client, NULL);

drivers/media/video/tw9910.c line 924

Quoted 3 lines
drivers/media/video/tw9910.c new file +3 -0
+	kfree(priv);
+	return 0;
+}

Fingers crossed for v6!

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

--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

#2 lore raw

Dear Guennadi

Quoted 2 lines

What a pity, you were too fast:-( I tried to comment on your v4 to prevent an extra round, but you were faster:-(

Sorry. I thought that I should wait more...
I would like to be more clever.
But this time, I learned about it.
thank you

Quoted 3 lines

Let's hope v6 will be the last one!
And the changes I'm proposing below are not too hard, so, should be an easy one.

I hope so.

Quoted 8 lines

Hm, sorry, I should have explained "select the nearest if no exact match is found" better. Now you check whether at least one parameter matches exactly, if not, you just fail. But if we allow one parameter to not match and just overwrite it, maybe we could do better yet and allow both to not match? Wouldn't it be better to select some metric in your width-height space and find the nearest point to the requested one? You can either use the classical (w - w_fixed)^2 + (h - h_fixed)^2 or a computationally lighter abs(w - w_fixed) + abs(h - h_fixed).

OK. I could understand.

Best regards
--
Kuninori Morimoto

--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list