All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/10] [media] tvp5150: add MC and DT support
@ 2016-01-07 12:46 Javier Martinez Canillas
  2016-01-07 12:46 ` [PATCH v2 01/10] [media] tvp5150: Restructure version detection Javier Martinez Canillas
                   ` (10 more replies)
  0 siblings, 11 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

Hello,

One of my testing platforms for the MC next gen [0] work has been an OMAP3
board (IGEPv2) with a tvp5151 video decoder attached to the OMAP3ISP block.

I've been using some patches from Laurent Pinchart that adds MC support to
the tvp5150 driver. The patches were never posted to the list and it seems
he doesn't have time to continue working on this so I have taken them from
his personal tree [1] and submitting now for review.

The series also contains patches that adds DT support to the driver so it
can be used in DT based platforms.

This is the second version of the series that fixes issues addressed by
Rob Herring and Laurent Pinchart. The first patch-set version was [2].

To test, the following media pipeline was used:

$ media-ctl -r -l '"tvp5150 1-005c":0->"OMAP3 ISP CCDC":0[1], "OMAP3 ISP CCDC":1->"OMAP3 ISP CCDC output":0[1]'
$ media-ctl -v --set-format '"OMAP3 ISP CCDC":0 [UYVY2X8 720x240 field:alternate]'
$ media-ctl -v --set-format '"OMAP3 ISP CCDC":1 [UYVY2X8 720x240 field:interlaced-tb]'

And frames captured with the yavta tool:

$ yavta -f UYVY -s 720x480 -n 1 --field interlaced-tb --capture=1 -F /dev/video2
$ raw2rgbpnm -f UYVY -s 720x480 frame-000000.bin frame-000000.pnm

The patches are on top of [0] not because is a depedency but just to avoid
merge conflicts and I don't expect them to be picked before that anyways.

Best regards,
Javier

[0]: http://lists.infradead.org/pipermail/linux-arm-kernel/2015-August/367109.html
[1]: http://git.linuxtv.org/pinchartl/media.git/log/?h=omap3isp/tvp5151
[2]: https://lkml.org/lkml/2016/1/4/216

Changes in v2:
- Fix indentation of the DTS example. Suggested by Rob Herring.
- Rename powerdown-gpios to pdn-gpios to match the pin name in
  the datasheet. Suggested by Laurent Pinchart.
- Add optional properties for the video endpoint and list the supported
  values. Suggested by Laurent Pinchart.
- Add Reviewed-by tag from Laurent Pinchart to patch 8/10.
- Include missing linux/gpio/consumer.h header. Reported by kbuild test robot.
- Keep the headers sorted alphabetically. Suggested by Laurent Pinchart.
- Rename powerdown to pdn to match datasheet pin. Suggested by Laurent Pinchart.
- Embed mbus_type into struct tvp5150. Suggested by Laurent Pinchart.
- Remove platform data support. Suggested by Laurent Pinchart.
- Check if the hsync, vsync and field even active properties are correct.
  Suggested by Laurent Pinchart.

Eduard Gavin (1):
  [media] tvp5150: Add OF match table

Javier Martinez Canillas (3):
  [media] tvp5150: Add device tree binding document
  [media] tvp5150: Initialize the chip on probe
  [media] tvp5150: Configure data interface via DT

Laurent Pinchart (6):
  [media] tvp5150: Restructure version detection
  [media] tvp5150: Add tvp5151 support
  [media] tvp5150: Add pad-level subdev operations
  [media] tvp5150: Add pixel rate control support
  [media] tvp5150: Add s_stream subdev operation support
  [media] tvp5150: Add g_mbus_config subdev operation support

 .../devicetree/bindings/media/i2c/tvp5150.txt      |  45 ++++
 drivers/media/i2c/tvp5150.c                        | 269 +++++++++++++++++----
 2 files changed, 268 insertions(+), 46 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/tvp5150.txt

-- 
2.4.3


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 01/10] [media] tvp5150: Restructure version detection
  2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
@ 2016-01-07 12:46 ` Javier Martinez Canillas
  2016-01-07 12:46 ` [PATCH v2 02/10] [media] tvp5150: Add tvp5151 support Javier Martinez Canillas
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Move the version detection code to a separate function and restructure
it to prepare for TVP5151 support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---

Changes in v2: None

 drivers/media/i2c/tvp5150.c | 79 ++++++++++++++++++++++++++-------------------
 1 file changed, 45 insertions(+), 34 deletions(-)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index dda8b3c000cc..9e953e5a7ec9 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1105,13 +1105,53 @@ static const struct v4l2_subdev_ops tvp5150_ops = {
 			I2C Client & Driver
  ****************************************************************************/
 
+static int tvp5150_detect_version(struct tvp5150 *core)
+{
+	struct v4l2_subdev *sd = &core->sd;
+	struct i2c_client *c = v4l2_get_subdevdata(sd);
+	unsigned int i;
+	u16 dev_id;
+	u16 rom_ver;
+	u8 regs[4];
+	int res;
+
+	/*
+	 * Read consequent registers - TVP5150_MSB_DEV_ID, TVP5150_LSB_DEV_ID,
+	 * TVP5150_ROM_MAJOR_VER, TVP5150_ROM_MINOR_VER
+	 */
+	for (i = 0; i < 4; i++) {
+		res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i);
+		if (res < 0)
+			return res;
+		regs[i] = res;
+	}
+
+	dev_id = (regs[0] << 8) | regs[1];
+	rom_ver = (regs[2] << 8) | regs[3];
+
+	v4l2_info(sd, "tvp%04x (%u.%u) chip found @ 0x%02x (%s)\n",
+		  dev_id, regs[2], regs[3], c->addr << 1, c->adapter->name);
+
+	if (dev_id == 0x5150 && rom_ver == 0x0321) { /* TVP51510A */
+		v4l2_info(sd, "tvp5150a detected.\n");
+	} else if (dev_id == 0x5150 && rom_ver == 0x0400) { /* TVP5150AM1 */
+		v4l2_info(sd, "tvp5150am1 detected.\n");
+
+		/* ITU-T BT.656.4 timing */
+		tvp5150_write(sd, TVP5150_REV_SELECT, 0);
+	} else {
+		v4l2_info(sd, "*** unknown tvp%04x chip detected.\n", dev_id);
+	}
+
+	return 0;
+}
+
 static int tvp5150_probe(struct i2c_client *c,
 			 const struct i2c_device_id *id)
 {
 	struct tvp5150 *core;
 	struct v4l2_subdev *sd;
-	int tvp5150_id[4];
-	int i, res;
+	int res;
 
 	/* Check if the adapter supports the needed features */
 	if (!i2c_check_functionality(c->adapter,
@@ -1124,38 +1164,9 @@ static int tvp5150_probe(struct i2c_client *c,
 	sd = &core->sd;
 	v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
 
-	/* 
-	 * Read consequent registers - TVP5150_MSB_DEV_ID, TVP5150_LSB_DEV_ID,
-	 * TVP5150_ROM_MAJOR_VER, TVP5150_ROM_MINOR_VER 
-	 */
-	for (i = 0; i < 4; i++) {
-		res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i);
-		if (res < 0)
-			return res;
-		tvp5150_id[i] = res;
-	}
-
-	v4l_info(c, "chip found @ 0x%02x (%s)\n",
-		 c->addr << 1, c->adapter->name);
-
-	if (tvp5150_id[2] == 4 && tvp5150_id[3] == 0) { /* Is TVP5150AM1 */
-		v4l2_info(sd, "tvp%02x%02xam1 detected.\n",
-			  tvp5150_id[0], tvp5150_id[1]);
-
-		/* ITU-T BT.656.4 timing */
-		tvp5150_write(sd, TVP5150_REV_SELECT, 0);
-	} else {
-		/* Is TVP5150A */
-		if (tvp5150_id[2] == 3 || tvp5150_id[3] == 0x21) {
-			v4l2_info(sd, "tvp%02x%02xa detected.\n",
-				  tvp5150_id[0], tvp5150_id[1]);
-		} else {
-			v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n",
-				  tvp5150_id[0], tvp5150_id[1]);
-			v4l2_info(sd, "*** Rom ver is %d.%d\n",
-				  tvp5150_id[2], tvp5150_id[3]);
-		}
-	}
+	res = tvp5150_detect_version(core);
+	if (res < 0)
+		return res;
 
 	core->norm = V4L2_STD_ALL;	/* Default is autodetect */
 	core->input = TVP5150_COMPOSITE1;
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 02/10] [media] tvp5150: Add tvp5151 support
  2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
  2016-01-07 12:46 ` [PATCH v2 01/10] [media] tvp5150: Restructure version detection Javier Martinez Canillas
@ 2016-01-07 12:46 ` Javier Martinez Canillas
  2016-01-07 12:46 ` [PATCH v2 03/10] [media] tvp5150: Add pad-level subdev operations Javier Martinez Canillas
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Expand the version detection code to identity the tvp5151.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---

Changes in v2: None

 drivers/media/i2c/tvp5150.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 9e953e5a7ec9..b3b34e24db13 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1139,6 +1139,8 @@ static int tvp5150_detect_version(struct tvp5150 *core)
 
 		/* ITU-T BT.656.4 timing */
 		tvp5150_write(sd, TVP5150_REV_SELECT, 0);
+	} else if (dev_id == 0x5151 && rom_ver == 0x0100) { /* TVP5151 */
+		v4l2_info(sd, "tvp5151 detected.\n");
 	} else {
 		v4l2_info(sd, "*** unknown tvp%04x chip detected.\n", dev_id);
 	}
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 03/10] [media] tvp5150: Add pad-level subdev operations
  2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
  2016-01-07 12:46 ` [PATCH v2 01/10] [media] tvp5150: Restructure version detection Javier Martinez Canillas
  2016-01-07 12:46 ` [PATCH v2 02/10] [media] tvp5150: Add tvp5151 support Javier Martinez Canillas
@ 2016-01-07 12:46 ` Javier Martinez Canillas
  2016-01-25 12:48   ` Mauro Carvalho Chehab
  2016-01-07 12:46 ` [PATCH v2 04/10] [media] tvp5150: Add pixel rate control support Javier Martinez Canillas
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

This patch enables the tvp5150 decoder driver to be used with the media
controller framework by adding pad-level subdev operations and init the
media entity pad.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---

Changes in v2: None

 drivers/media/i2c/tvp5150.c | 60 +++++++++++++++++++++++++++++++++------------
 1 file changed, 45 insertions(+), 15 deletions(-)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index b3b34e24db13..82fba9d46f30 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -35,6 +35,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");
 
 struct tvp5150 {
 	struct v4l2_subdev sd;
+	struct media_pad pad;
 	struct v4l2_ctrl_handler hdl;
 	struct v4l2_rect rect;
 
@@ -818,17 +819,6 @@ static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd)
 	}
 }
 
-static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd,
-		struct v4l2_subdev_pad_config *cfg,
-		struct v4l2_subdev_mbus_code_enum *code)
-{
-	if (code->pad || code->index)
-		return -EINVAL;
-
-	code->code = MEDIA_BUS_FMT_UYVY8_2X8;
-	return 0;
-}
-
 static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
 		struct v4l2_subdev_pad_config *cfg,
 		struct v4l2_subdev_format *format)
@@ -841,13 +831,11 @@ static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
 
 	f = &format->format;
 
-	tvp5150_reset(sd, 0);
-
 	f->width = decoder->rect.width;
-	f->height = decoder->rect.height;
+	f->height = decoder->rect.height / 2;
 
 	f->code = MEDIA_BUS_FMT_UYVY8_2X8;
-	f->field = V4L2_FIELD_SEQ_TB;
+	f->field = V4L2_FIELD_ALTERNATE;
 	f->colorspace = V4L2_COLORSPACE_SMPTE170M;
 
 	v4l2_dbg(1, debug, sd, "width = %d, height = %d\n", f->width,
@@ -948,6 +936,39 @@ static int tvp5150_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
 	return 0;
 }
 
+ /****************************************************************************
+			V4L2 subdev pad ops
+ ****************************************************************************/
+
+static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd,
+				  struct v4l2_subdev_pad_config *cfg,
+				  struct v4l2_subdev_mbus_code_enum *code)
+{
+	if (code->index)
+		return -EINVAL;
+
+	code->code = MEDIA_BUS_FMT_UYVY8_2X8;
+	return 0;
+}
+
+static int tvp5150_enum_frame_size(struct v4l2_subdev *sd,
+				   struct v4l2_subdev_pad_config *cfg,
+				   struct v4l2_subdev_frame_size_enum *fse)
+{
+	struct tvp5150 *decoder = to_tvp5150(sd);
+
+	if (fse->index >= 8 || fse->code != MEDIA_BUS_FMT_UYVY8_2X8)
+		return -EINVAL;
+
+	fse->code = MEDIA_BUS_FMT_UYVY8_2X8;
+	fse->min_width = decoder->rect.width;
+	fse->max_width = decoder->rect.width;
+	fse->min_height = decoder->rect.height / 2;
+	fse->max_height = decoder->rect.height / 2;
+
+	return 0;
+}
+
 /****************************************************************************
 			I2C Command
  ****************************************************************************/
@@ -1088,6 +1109,7 @@ static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
 
 static const struct v4l2_subdev_pad_ops tvp5150_pad_ops = {
 	.enum_mbus_code = tvp5150_enum_mbus_code,
+	.enum_frame_size = tvp5150_enum_frame_size,
 	.set_fmt = tvp5150_fill_fmt,
 	.get_fmt = tvp5150_fill_fmt,
 };
@@ -1165,6 +1187,14 @@ static int tvp5150_probe(struct i2c_client *c,
 		return -ENOMEM;
 	sd = &core->sd;
 	v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
+	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	core->pad.flags = MEDIA_PAD_FL_SOURCE;
+	res = media_entity_pads_init(&sd->entity, 1, &core->pad);
+	if (res < 0)
+		return res;
+#endif
 
 	res = tvp5150_detect_version(core);
 	if (res < 0)
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 04/10] [media] tvp5150: Add pixel rate control support
  2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
                   ` (2 preceding siblings ...)
  2016-01-07 12:46 ` [PATCH v2 03/10] [media] tvp5150: Add pad-level subdev operations Javier Martinez Canillas
@ 2016-01-07 12:46 ` Javier Martinez Canillas
  2016-01-07 12:46 ` [PATCH v2 05/10] [media] tvp5150: Add s_stream subdev operation support Javier Martinez Canillas
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

This patch adds support for the V4L2_CID_PIXEL_RATE control.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---

Changes in v2: None

 drivers/media/i2c/tvp5150.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 82fba9d46f30..71473cec236a 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1204,7 +1204,7 @@ static int tvp5150_probe(struct i2c_client *c,
 	core->input = TVP5150_COMPOSITE1;
 	core->enable = 1;
 
-	v4l2_ctrl_handler_init(&core->hdl, 4);
+	v4l2_ctrl_handler_init(&core->hdl, 5);
 	v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
 			V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
 	v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
@@ -1213,6 +1213,9 @@ static int tvp5150_probe(struct i2c_client *c,
 			V4L2_CID_SATURATION, 0, 255, 1, 128);
 	v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
 			V4L2_CID_HUE, -128, 127, 1, 0);
+	v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
+			V4L2_CID_PIXEL_RATE, 27000000,
+			27000000, 1, 27000000);
 	sd->ctrl_handler = &core->hdl;
 	if (core->hdl.error) {
 		res = core->hdl.error;
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 05/10] [media] tvp5150: Add s_stream subdev operation support
  2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
                   ` (3 preceding siblings ...)
  2016-01-07 12:46 ` [PATCH v2 04/10] [media] tvp5150: Add pixel rate control support Javier Martinez Canillas
@ 2016-01-07 12:46 ` Javier Martinez Canillas
  2016-01-07 12:46 ` [PATCH v2 06/10] [media] tvp5150: Add g_mbus_config " Javier Martinez Canillas
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

This patch adds the .s_stream subdev operation to the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---

Changes in v2: None

 drivers/media/i2c/tvp5150.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 71473cec236a..fb7a4ddff1fe 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -973,6 +973,21 @@ static int tvp5150_enum_frame_size(struct v4l2_subdev *sd,
 			I2C Command
  ****************************************************************************/
 
+static int tvp5150_s_stream(struct v4l2_subdev *sd, int enable)
+{
+	/* Initializes TVP5150 to its default values */
+	/* # set PCLK (27MHz) */
+	tvp5150_write(sd, TVP5150_CONF_SHARED_PIN, 0x00);
+
+	/* Output format: 8-bit ITU-R BT.656 with embedded syncs */
+	if (enable)
+		tvp5150_write(sd, TVP5150_MISC_CTL, 0x09);
+	else
+		tvp5150_write(sd, TVP5150_MISC_CTL, 0x00);
+
+	return 0;
+}
+
 static int tvp5150_s_routing(struct v4l2_subdev *sd,
 			     u32 input, u32 output, u32 config)
 {
@@ -1094,6 +1109,7 @@ static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = {
 
 static const struct v4l2_subdev_video_ops tvp5150_video_ops = {
 	.s_std = tvp5150_s_std,
+	.s_stream = tvp5150_s_stream,
 	.s_routing = tvp5150_s_routing,
 	.s_crop = tvp5150_s_crop,
 	.g_crop = tvp5150_g_crop,
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 06/10] [media] tvp5150: Add g_mbus_config subdev operation support
  2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
                   ` (4 preceding siblings ...)
  2016-01-07 12:46 ` [PATCH v2 05/10] [media] tvp5150: Add s_stream subdev operation support Javier Martinez Canillas
@ 2016-01-07 12:46 ` Javier Martinez Canillas
  2016-01-07 12:46 ` [PATCH v2 07/10] [media] tvp5150: Add device tree binding document Javier Martinez Canillas
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

This patch adds the .g_mbus_config subdev operation to the driver.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---

Changes in v2: None

 drivers/media/i2c/tvp5150.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index fb7a4ddff1fe..105bd1c6b17f 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -936,6 +936,16 @@ static int tvp5150_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
 	return 0;
 }
 
+static int tvp5150_g_mbus_config(struct v4l2_subdev *sd,
+				 struct v4l2_mbus_config *cfg)
+{
+	cfg->type = V4L2_MBUS_BT656;
+	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
+		   | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
+
+	return 0;
+}
+
  /****************************************************************************
 			V4L2 subdev pad ops
  ****************************************************************************/
@@ -1114,6 +1124,7 @@ static const struct v4l2_subdev_video_ops tvp5150_video_ops = {
 	.s_crop = tvp5150_s_crop,
 	.g_crop = tvp5150_g_crop,
 	.cropcap = tvp5150_cropcap,
+	.g_mbus_config = tvp5150_g_mbus_config,
 };
 
 static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 07/10] [media] tvp5150: Add device tree binding document
  2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
                   ` (5 preceding siblings ...)
  2016-01-07 12:46 ` [PATCH v2 06/10] [media] tvp5150: Add g_mbus_config " Javier Martinez Canillas
@ 2016-01-07 12:46 ` Javier Martinez Canillas
  2016-01-09 22:24   ` Rob Herring
  2016-01-07 12:46 ` [PATCH v2 08/10] [media] tvp5150: Add OF match table Javier Martinez Canillas
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

Add a Device Tree binding document for the TVP5150 video decoder.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

Changes in v2:
- Fix indentation of the DTS example. Suggested by Rob Herring.
- Rename powerdown-gpios to pdn-gpios to match the pin name in
  the datasheet. Suggested by Laurent Pinchart.
- Add optional properties for the video endpoint and list the supported
  values. Suggested by Laurent Pinchart.

 .../devicetree/bindings/media/i2c/tvp5150.txt      | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/tvp5150.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/tvp5150.txt b/Documentation/devicetree/bindings/media/i2c/tvp5150.txt
new file mode 100644
index 000000000000..8c0fc1a26bf0
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/tvp5150.txt
@@ -0,0 +1,45 @@
+* Texas Instruments TVP5150 and TVP5151 video decoders
+
+The TVP5150 and TVP5151 are video decoders that convert baseband NTSC and PAL
+(and also SECAM in the TVP5151 case) video signals to either 8-bit 4:2:2 YUV
+with discrete syncs or 8-bit ITU-R BT.656 with embedded syncs output formats.
+
+Required Properties:
+- compatible: value must be "ti,tvp5150"
+- reg: I2C slave address
+
+Optional Properties:
+- pdn-gpios: phandle for the GPIO connected to the PDN pin, if any.
+- reset-gpios: phandle for the GPIO connected to the RESETB pin, if any.
+
+The device node must contain one 'port' child node for its digital output
+video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Required Endpoint Properties for parallel synchronization:
+
+- hsync-active: active state of the HSYNC signal. Must be <1> (HIGH).
+- vsync-active: active state of the VSYNC signal. Must be <1> (HIGH).
+- field-even-active: field signal level during the even field data
+  transmission. Must be <0>.
+
+If none of hsync-active, vsync-active and field-even-active is specified,
+the endpoint is assumed to use embedded BT.656 synchronization.
+
+Example:
+
+&i2c2 {
+	...
+	tvp5150@5c {
+		compatible = "ti,tvp5150";
+		reg = <0x5c>;
+		pdn-gpios = <&gpio4 30 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&gpio6 7 GPIO_ACTIVE_LOW>;
+
+		port {
+			tvp5150_1: endpoint {
+				remote-endpoint = <&ccdc_ep>;
+			};
+		};
+	};
+};
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 08/10] [media] tvp5150: Add OF match table
  2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
                   ` (6 preceding siblings ...)
  2016-01-07 12:46 ` [PATCH v2 07/10] [media] tvp5150: Add device tree binding document Javier Martinez Canillas
@ 2016-01-07 12:46 ` Javier Martinez Canillas
  2016-01-07 12:46   ` Javier Martinez Canillas
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

From: Eduard Gavin <egavinc@gmail.com>

The Documentation/devicetree/bindings/media/i2c/tvp5150.txt DT binding doc
lists "ti,tvp5150" as the device compatible string but the driver does not
have an OF match table. Add the table to the driver so the I2C core can do
an OF style match.

Signed-off-by: Eduard Gavin <egavinc@gmail.com>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

Changes in v2:
- Add Reviewed-by tag from Laurent Pinchart to patch 8/10.

 drivers/media/i2c/tvp5150.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 105bd1c6b17f..caac96a577f8 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1295,8 +1295,17 @@ static const struct i2c_device_id tvp5150_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, tvp5150_id);
 
+#if IS_ENABLED(CONFIG_OF)
+static const struct of_device_id tvp5150_of_match[] = {
+	{ .compatible = "ti,tvp5150", },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, tvp5150_of_match);
+#endif
+
 static struct i2c_driver tvp5150_driver = {
 	.driver = {
+		.of_match_table = of_match_ptr(tvp5150_of_match),
 		.name	= "tvp5150",
 	},
 	.probe		= tvp5150_probe,
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 09/10] [media] tvp5150: Initialize the chip on probe
@ 2016-01-07 12:46   ` Javier Martinez Canillas
  0 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

After power-up, the tvp5150 decoder is in a unknown state until the
RESETB pin is driven LOW which reset all the registers and restarts
the chip's internal state machine.

The init sequence has some timing constraints and the RESETB signal
can only be used if the PDN (Power-down) pin is first released.

So, the initialization sequence is as follows:

1- PDN (active-low) is driven HIGH so the chip is power-up
2- A 20 ms delay is needed before sending a RESETB (active-low) signal.
3- The RESETB pulse duration is 500 ns.
4- A 200 us delay is needed for the I2C client to be active after reset.

This patch used as a reference the logic in the IGEPv2 board file from
the ISEE 2.6.37 vendor tree.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>

---

Changes in v2:
- Include missing linux/gpio/consumer.h header. Reported by kbuild test robot.
- Keep the headers sorted alphabetically. Suggested by Laurent Pinchart.
- Rename powerdown to pdn to match datasheet pin. Suggested by Laurent Pinchart.

 drivers/media/i2c/tvp5150.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index caac96a577f8..48df7615eb64 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -9,6 +9,7 @@
 #include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <media/v4l2-async.h>
 #include <media/v4l2-device.h>
@@ -1197,6 +1198,36 @@ static int tvp5150_detect_version(struct tvp5150 *core)
 	return 0;
 }
 
+static int tvp5150_init(struct i2c_client *c)
+{
+	struct gpio_desc *pdn_gpio;
+	struct gpio_desc *reset_gpio;
+
+	pdn_gpio = devm_gpiod_get_optional(&c->dev, "pdn", GPIOD_OUT_HIGH);
+	if (IS_ERR(pdn_gpio))
+		return PTR_ERR(pdn_gpio);
+
+	if (pdn_gpio) {
+		gpiod_set_value_cansleep(pdn_gpio, 0);
+		/* Delay time between power supplies active and reset */
+		msleep(20);
+	}
+
+	reset_gpio = devm_gpiod_get_optional(&c->dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(reset_gpio))
+		return PTR_ERR(reset_gpio);
+
+	if (reset_gpio) {
+		/* RESETB pulse duration */
+		ndelay(500);
+		gpiod_set_value_cansleep(reset_gpio, 0);
+		/* Delay time between end of reset to I2C active */
+		usleep_range(200, 250);
+	}
+
+	return 0;
+}
+
 static int tvp5150_probe(struct i2c_client *c,
 			 const struct i2c_device_id *id)
 {
@@ -1209,6 +1240,10 @@ static int tvp5150_probe(struct i2c_client *c,
 	     I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
 		return -EIO;
 
+	res = tvp5150_init(c);
+	if (res)
+		return res;
+
 	core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL);
 	if (!core)
 		return -ENOMEM;
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 09/10] [media] tvp5150: Initialize the chip on probe
@ 2016-01-07 12:46   ` Javier Martinez Canillas
  0 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, Mauro Carvalho Chehab,
	Enrico Butera, Sakari Ailus, Enric Balletbo i Serra, Rob Herring,
	Eduard Gavin, Laurent Pinchart, Hans Verkuil,
	linux-media-u79uwXL29TY76Z2rM5mHXA, Javier Martinez Canillas

After power-up, the tvp5150 decoder is in a unknown state until the
RESETB pin is driven LOW which reset all the registers and restarts
the chip's internal state machine.

The init sequence has some timing constraints and the RESETB signal
can only be used if the PDN (Power-down) pin is first released.

So, the initialization sequence is as follows:

1- PDN (active-low) is driven HIGH so the chip is power-up
2- A 20 ms delay is needed before sending a RESETB (active-low) signal.
3- The RESETB pulse duration is 500 ns.
4- A 200 us delay is needed for the I2C client to be active after reset.

This patch used as a reference the logic in the IGEPv2 board file from
the ISEE 2.6.37 vendor tree.

Signed-off-by: Javier Martinez Canillas <javier-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>

---

Changes in v2:
- Include missing linux/gpio/consumer.h header. Reported by kbuild test robot.
- Keep the headers sorted alphabetically. Suggested by Laurent Pinchart.
- Rename powerdown to pdn to match datasheet pin. Suggested by Laurent Pinchart.

 drivers/media/i2c/tvp5150.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index caac96a577f8..48df7615eb64 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -9,6 +9,7 @@
 #include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <media/v4l2-async.h>
 #include <media/v4l2-device.h>
@@ -1197,6 +1198,36 @@ static int tvp5150_detect_version(struct tvp5150 *core)
 	return 0;
 }
 
+static int tvp5150_init(struct i2c_client *c)
+{
+	struct gpio_desc *pdn_gpio;
+	struct gpio_desc *reset_gpio;
+
+	pdn_gpio = devm_gpiod_get_optional(&c->dev, "pdn", GPIOD_OUT_HIGH);
+	if (IS_ERR(pdn_gpio))
+		return PTR_ERR(pdn_gpio);
+
+	if (pdn_gpio) {
+		gpiod_set_value_cansleep(pdn_gpio, 0);
+		/* Delay time between power supplies active and reset */
+		msleep(20);
+	}
+
+	reset_gpio = devm_gpiod_get_optional(&c->dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(reset_gpio))
+		return PTR_ERR(reset_gpio);
+
+	if (reset_gpio) {
+		/* RESETB pulse duration */
+		ndelay(500);
+		gpiod_set_value_cansleep(reset_gpio, 0);
+		/* Delay time between end of reset to I2C active */
+		usleep_range(200, 250);
+	}
+
+	return 0;
+}
+
 static int tvp5150_probe(struct i2c_client *c,
 			 const struct i2c_device_id *id)
 {
@@ -1209,6 +1240,10 @@ static int tvp5150_probe(struct i2c_client *c,
 	     I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
 		return -EIO;
 
+	res = tvp5150_init(c);
+	if (res)
+		return res;
+
 	core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL);
 	if (!core)
 		return -ENOMEM;
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 10/10] [media] tvp5150: Configure data interface via DT
  2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
                   ` (8 preceding siblings ...)
  2016-01-07 12:46   ` Javier Martinez Canillas
@ 2016-01-07 12:46 ` Javier Martinez Canillas
  2016-01-25 14:59 ` [PATCH v2 00/10] [media] tvp5150: add MC and DT support Hans Verkuil
  10 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-07 12:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media,
	Javier Martinez Canillas

The video decoder supports either 8-bit 4:2:2 YUV with discrete syncs
or 8-bit ITU-R BT.656 with embedded syncs output format but currently
BT.656 it's always reported. Allow to configure the format to use via
either platform data or a device tree definition.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>

---

Changes in v2:
- Embed mbus_type into struct tvp5150. Suggested by Laurent Pinchart.
- Remove platform data support. Suggested by Laurent Pinchart.
- Check if the hsync, vsync and field even active properties are correct.
  Suggested by Laurent Pinchart.

 drivers/media/i2c/tvp5150.c | 66 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 63 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 48df7615eb64..813c7181dca9 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -15,6 +15,7 @@
 #include <media/v4l2-device.h>
 #include <media/i2c/tvp5150.h>
 #include <media/v4l2-ctrls.h>
+#include <media/v4l2-of.h>
 
 #include "tvp5150_reg.h"
 
@@ -44,6 +45,8 @@ struct tvp5150 {
 	u32 input;
 	u32 output;
 	int enable;
+
+	enum v4l2_mbus_type mbus_type;
 };
 
 static inline struct tvp5150 *to_tvp5150(struct v4l2_subdev *sd)
@@ -774,6 +777,10 @@ static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
 	v4l2_ctrl_handler_setup(&decoder->hdl);
 
 	tvp5150_set_std(sd, decoder->norm);
+
+	if (decoder->mbus_type == V4L2_MBUS_PARALLEL)
+		tvp5150_write(sd, TVP5150_DATA_RATE_SEL, 0x40);
+
 	return 0;
 };
 
@@ -940,7 +947,9 @@ static int tvp5150_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
 static int tvp5150_g_mbus_config(struct v4l2_subdev *sd,
 				 struct v4l2_mbus_config *cfg)
 {
-	cfg->type = V4L2_MBUS_BT656;
+	struct tvp5150 *decoder = to_tvp5150(sd);
+
+	cfg->type = decoder->mbus_type;
 	cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
 		   | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
 
@@ -986,13 +995,20 @@ static int tvp5150_enum_frame_size(struct v4l2_subdev *sd,
 
 static int tvp5150_s_stream(struct v4l2_subdev *sd, int enable)
 {
+	struct tvp5150 *decoder = to_tvp5150(sd);
+	/* Output format: 8-bit ITU-R BT.656 with embedded syncs */
+	int val = 0x09;
+
+	/* Output format: 8-bit 4:2:2 YUV with discrete sync */
+	if (decoder->mbus_type == V4L2_MBUS_PARALLEL)
+		val = 0x0d;
+
 	/* Initializes TVP5150 to its default values */
 	/* # set PCLK (27MHz) */
 	tvp5150_write(sd, TVP5150_CONF_SHARED_PIN, 0x00);
 
-	/* Output format: 8-bit ITU-R BT.656 with embedded syncs */
 	if (enable)
-		tvp5150_write(sd, TVP5150_MISC_CTL, 0x09);
+		tvp5150_write(sd, TVP5150_MISC_CTL, val);
 	else
 		tvp5150_write(sd, TVP5150_MISC_CTL, 0x00);
 
@@ -1228,11 +1244,42 @@ static int tvp5150_init(struct i2c_client *c)
 	return 0;
 }
 
+static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
+{
+	struct v4l2_of_endpoint bus_cfg;
+	struct device_node *ep;
+	unsigned int flags;
+	int ret = 0;
+
+	ep = of_graph_get_next_endpoint(np, NULL);
+	if (!ep)
+		return -EINVAL;
+
+	ret = v4l2_of_parse_endpoint(ep, &bus_cfg);
+	if (ret)
+		goto err;
+
+	flags = bus_cfg.bus.parallel.flags;
+
+	if (bus_cfg.bus_type == V4L2_MBUS_PARALLEL &&
+	    !(flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH &&
+	      flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH &&
+	      flags & V4L2_MBUS_FIELD_EVEN_LOW))
+		return -EINVAL;
+
+	decoder->mbus_type = bus_cfg.bus_type;
+
+err:
+	of_node_put(ep);
+	return ret;
+}
+
 static int tvp5150_probe(struct i2c_client *c,
 			 const struct i2c_device_id *id)
 {
 	struct tvp5150 *core;
 	struct v4l2_subdev *sd;
+	struct device_node *np = c->dev.of_node;
 	int res;
 
 	/* Check if the adapter supports the needed features */
@@ -1247,7 +1294,20 @@ static int tvp5150_probe(struct i2c_client *c,
 	core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL);
 	if (!core)
 		return -ENOMEM;
+
 	sd = &core->sd;
+
+	if (IS_ENABLED(CONFIG_OF) && np) {
+		res = tvp5150_parse_dt(core, np);
+		if (res) {
+			v4l2_err(sd, "DT parsing error: %d\n", res);
+			return res;
+		}
+	} else {
+		/* Default to BT.656 embedded sync */
+		core->mbus_type = V4L2_MBUS_BT656;
+	}
+
 	v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 07/10] [media] tvp5150: Add device tree binding document
  2016-01-07 12:46 ` [PATCH v2 07/10] [media] tvp5150: Add device tree binding document Javier Martinez Canillas
@ 2016-01-09 22:24   ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2016-01-09 22:24 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: linux-kernel, devicetree, Mauro Carvalho Chehab, Enrico Butera,
	Sakari Ailus, Enric Balletbo i Serra, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media

On Thu, Jan 07, 2016 at 09:46:47AM -0300, Javier Martinez Canillas wrote:
> Add a Device Tree binding document for the TVP5150 video decoder.
> 
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> ---
> 
> Changes in v2:
> - Fix indentation of the DTS example. Suggested by Rob Herring.
> - Rename powerdown-gpios to pdn-gpios to match the pin name in
>   the datasheet. Suggested by Laurent Pinchart.
> - Add optional properties for the video endpoint and list the supported
>   values. Suggested by Laurent Pinchart.
> 
>  .../devicetree/bindings/media/i2c/tvp5150.txt      | 45 ++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/i2c/tvp5150.txt

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 03/10] [media] tvp5150: Add pad-level subdev operations
  2016-01-07 12:46 ` [PATCH v2 03/10] [media] tvp5150: Add pad-level subdev operations Javier Martinez Canillas
@ 2016-01-25 12:48   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 16+ messages in thread
From: Mauro Carvalho Chehab @ 2016-01-25 12:48 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: linux-kernel, devicetree, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media

Em Thu,  7 Jan 2016 09:46:43 -0300
Javier Martinez Canillas <javier@osg.samsung.com> escreveu:

> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> This patch enables the tvp5150 decoder driver to be used with the media
> controller framework by adding pad-level subdev operations and init the
> media entity pad.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
> ---
> 
> Changes in v2: None
> 
>  drivers/media/i2c/tvp5150.c | 60 +++++++++++++++++++++++++++++++++------------
>  1 file changed, 45 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
> index b3b34e24db13..82fba9d46f30 100644
> --- a/drivers/media/i2c/tvp5150.c
> +++ b/drivers/media/i2c/tvp5150.c
> @@ -35,6 +35,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");
>  
>  struct tvp5150 {
>  	struct v4l2_subdev sd;
> +	struct media_pad pad;
>  	struct v4l2_ctrl_handler hdl;
>  	struct v4l2_rect rect;
>  
> @@ -818,17 +819,6 @@ static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd)
>  	}
>  }
>  
> -static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd,
> -		struct v4l2_subdev_pad_config *cfg,
> -		struct v4l2_subdev_mbus_code_enum *code)
> -{
> -	if (code->pad || code->index)
> -		return -EINVAL;
> -
> -	code->code = MEDIA_BUS_FMT_UYVY8_2X8;
> -	return 0;
> -}
> -
>  static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
>  		struct v4l2_subdev_pad_config *cfg,
>  		struct v4l2_subdev_format *format)
> @@ -841,13 +831,11 @@ static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
>  
>  	f = &format->format;
>  
> -	tvp5150_reset(sd, 0);
> -
>  	f->width = decoder->rect.width;
> -	f->height = decoder->rect.height;
> +	f->height = decoder->rect.height / 2;
>  
>  	f->code = MEDIA_BUS_FMT_UYVY8_2X8;
> -	f->field = V4L2_FIELD_SEQ_TB;
> +	f->field = V4L2_FIELD_ALTERNATE;
>  	f->colorspace = V4L2_COLORSPACE_SMPTE170M;

I don't think that the above changes belong to this patch. They look
to be a fix, so they should be on a separate patch.

>  
>  	v4l2_dbg(1, debug, sd, "width = %d, height = %d\n", f->width,
> @@ -948,6 +936,39 @@ static int tvp5150_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
>  	return 0;
>  }
>  
> + /****************************************************************************
> +			V4L2 subdev pad ops
> + ****************************************************************************/
> +
> +static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd,
> +				  struct v4l2_subdev_pad_config *cfg,
> +				  struct v4l2_subdev_mbus_code_enum *code)
> +{
> +	if (code->index)
> +		return -EINVAL;
> +
> +	code->code = MEDIA_BUS_FMT_UYVY8_2X8;
> +	return 0;
> +}
> +
> +static int tvp5150_enum_frame_size(struct v4l2_subdev *sd,
> +				   struct v4l2_subdev_pad_config *cfg,
> +				   struct v4l2_subdev_frame_size_enum *fse)
> +{
> +	struct tvp5150 *decoder = to_tvp5150(sd);
> +
> +	if (fse->index >= 8 || fse->code != MEDIA_BUS_FMT_UYVY8_2X8)
> +		return -EINVAL;
> +
> +	fse->code = MEDIA_BUS_FMT_UYVY8_2X8;
> +	fse->min_width = decoder->rect.width;
> +	fse->max_width = decoder->rect.width;
> +	fse->min_height = decoder->rect.height / 2;
> +	fse->max_height = decoder->rect.height / 2;
> +
> +	return 0;
> +}
> +
>  /****************************************************************************
>  			I2C Command
>   ****************************************************************************/
> @@ -1088,6 +1109,7 @@ static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
>  
>  static const struct v4l2_subdev_pad_ops tvp5150_pad_ops = {
>  	.enum_mbus_code = tvp5150_enum_mbus_code,
> +	.enum_frame_size = tvp5150_enum_frame_size,
>  	.set_fmt = tvp5150_fill_fmt,
>  	.get_fmt = tvp5150_fill_fmt,
>  };
> @@ -1165,6 +1187,14 @@ static int tvp5150_probe(struct i2c_client *c,
>  		return -ENOMEM;
>  	sd = &core->sd;
>  	v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
> +	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> +
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> +	core->pad.flags = MEDIA_PAD_FL_SOURCE;
> +	res = media_entity_pads_init(&sd->entity, 1, &core->pad);
> +	if (res < 0)
> +		return res;
> +#endif

Actually, you need to create two pads, one source and one sink.

At the sink pad, the will be the connectors: RF, S-Video and/or
Composite, depending on the board that has it.

Ok, adding support for it is not trivial, as it would likely
require some new callback, as the tvp5150 driver doesn't know how
this is wired on non-DT drivers.

The best would be to add MC support on em28xx, as there are some
devices there with tvp5150. I'll see if I find some time to write
such patches along the week.

>  
>  	res = tvp5150_detect_version(core);
>  	if (res < 0)

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 00/10] [media] tvp5150: add MC and DT support
  2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
                   ` (9 preceding siblings ...)
  2016-01-07 12:46 ` [PATCH v2 10/10] [media] tvp5150: Configure data interface via DT Javier Martinez Canillas
@ 2016-01-25 14:59 ` Hans Verkuil
  2016-01-25 15:04   ` Javier Martinez Canillas
  10 siblings, 1 reply; 16+ messages in thread
From: Hans Verkuil @ 2016-01-25 14:59 UTC (permalink / raw)
  To: Javier Martinez Canillas, linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media

On 01/07/2016 01:46 PM, Javier Martinez Canillas wrote:

FYI: this patch series no longer applies after the merge of 4.5-rc1.

So besides fixing Mauro's comment for 3/10 you need to respin this series
anyway.

Regards,

	Hans

> Hello,
> 
> One of my testing platforms for the MC next gen [0] work has been an OMAP3
> board (IGEPv2) with a tvp5151 video decoder attached to the OMAP3ISP block.
> 
> I've been using some patches from Laurent Pinchart that adds MC support to
> the tvp5150 driver. The patches were never posted to the list and it seems
> he doesn't have time to continue working on this so I have taken them from
> his personal tree [1] and submitting now for review.
> 
> The series also contains patches that adds DT support to the driver so it
> can be used in DT based platforms.
> 
> This is the second version of the series that fixes issues addressed by
> Rob Herring and Laurent Pinchart. The first patch-set version was [2].
> 
> To test, the following media pipeline was used:
> 
> $ media-ctl -r -l '"tvp5150 1-005c":0->"OMAP3 ISP CCDC":0[1], "OMAP3 ISP CCDC":1->"OMAP3 ISP CCDC output":0[1]'
> $ media-ctl -v --set-format '"OMAP3 ISP CCDC":0 [UYVY2X8 720x240 field:alternate]'
> $ media-ctl -v --set-format '"OMAP3 ISP CCDC":1 [UYVY2X8 720x240 field:interlaced-tb]'
> 
> And frames captured with the yavta tool:
> 
> $ yavta -f UYVY -s 720x480 -n 1 --field interlaced-tb --capture=1 -F /dev/video2
> $ raw2rgbpnm -f UYVY -s 720x480 frame-000000.bin frame-000000.pnm
> 
> The patches are on top of [0] not because is a depedency but just to avoid
> merge conflicts and I don't expect them to be picked before that anyways.
> 
> Best regards,
> Javier
> 
> [0]: http://lists.infradead.org/pipermail/linux-arm-kernel/2015-August/367109.html
> [1]: http://git.linuxtv.org/pinchartl/media.git/log/?h=omap3isp/tvp5151
> [2]: https://lkml.org/lkml/2016/1/4/216
> 
> Changes in v2:
> - Fix indentation of the DTS example. Suggested by Rob Herring.
> - Rename powerdown-gpios to pdn-gpios to match the pin name in
>   the datasheet. Suggested by Laurent Pinchart.
> - Add optional properties for the video endpoint and list the supported
>   values. Suggested by Laurent Pinchart.
> - Add Reviewed-by tag from Laurent Pinchart to patch 8/10.
> - Include missing linux/gpio/consumer.h header. Reported by kbuild test robot.
> - Keep the headers sorted alphabetically. Suggested by Laurent Pinchart.
> - Rename powerdown to pdn to match datasheet pin. Suggested by Laurent Pinchart.
> - Embed mbus_type into struct tvp5150. Suggested by Laurent Pinchart.
> - Remove platform data support. Suggested by Laurent Pinchart.
> - Check if the hsync, vsync and field even active properties are correct.
>   Suggested by Laurent Pinchart.
> 
> Eduard Gavin (1):
>   [media] tvp5150: Add OF match table
> 
> Javier Martinez Canillas (3):
>   [media] tvp5150: Add device tree binding document
>   [media] tvp5150: Initialize the chip on probe
>   [media] tvp5150: Configure data interface via DT
> 
> Laurent Pinchart (6):
>   [media] tvp5150: Restructure version detection
>   [media] tvp5150: Add tvp5151 support
>   [media] tvp5150: Add pad-level subdev operations
>   [media] tvp5150: Add pixel rate control support
>   [media] tvp5150: Add s_stream subdev operation support
>   [media] tvp5150: Add g_mbus_config subdev operation support
> 
>  .../devicetree/bindings/media/i2c/tvp5150.txt      |  45 ++++
>  drivers/media/i2c/tvp5150.c                        | 269 +++++++++++++++++----
>  2 files changed, 268 insertions(+), 46 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/media/i2c/tvp5150.txt
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 00/10] [media] tvp5150: add MC and DT support
  2016-01-25 14:59 ` [PATCH v2 00/10] [media] tvp5150: add MC and DT support Hans Verkuil
@ 2016-01-25 15:04   ` Javier Martinez Canillas
  0 siblings, 0 replies; 16+ messages in thread
From: Javier Martinez Canillas @ 2016-01-25 15:04 UTC (permalink / raw)
  To: Hans Verkuil, linux-kernel
  Cc: devicetree, Mauro Carvalho Chehab, Enrico Butera, Sakari Ailus,
	Enric Balletbo i Serra, Rob Herring, Eduard Gavin,
	Laurent Pinchart, Hans Verkuil, linux-media

Hello Hans,

On 01/25/2016 11:59 AM, Hans Verkuil wrote:
> On 01/07/2016 01:46 PM, Javier Martinez Canillas wrote:
>
> FYI: this patch series no longer applies after the merge of 4.5-rc1.
>

That's actually not true :)

I based this series on top of Mauro's latest MC next gen work since I
knew that it was quite unlikely that this set would be applied before
those changes. Sorry for missing mentioning that in the cover letter.
  
> So besides fixing Mauro's comment for 3/10 you need to respin this series
> anyway.
>

In fact, these patches besides 3/10 are already applied in media/master.

> Regards,
>
> 	Hans
>
  
Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-01-25 15:04 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-07 12:46 [PATCH v2 00/10] [media] tvp5150: add MC and DT support Javier Martinez Canillas
2016-01-07 12:46 ` [PATCH v2 01/10] [media] tvp5150: Restructure version detection Javier Martinez Canillas
2016-01-07 12:46 ` [PATCH v2 02/10] [media] tvp5150: Add tvp5151 support Javier Martinez Canillas
2016-01-07 12:46 ` [PATCH v2 03/10] [media] tvp5150: Add pad-level subdev operations Javier Martinez Canillas
2016-01-25 12:48   ` Mauro Carvalho Chehab
2016-01-07 12:46 ` [PATCH v2 04/10] [media] tvp5150: Add pixel rate control support Javier Martinez Canillas
2016-01-07 12:46 ` [PATCH v2 05/10] [media] tvp5150: Add s_stream subdev operation support Javier Martinez Canillas
2016-01-07 12:46 ` [PATCH v2 06/10] [media] tvp5150: Add g_mbus_config " Javier Martinez Canillas
2016-01-07 12:46 ` [PATCH v2 07/10] [media] tvp5150: Add device tree binding document Javier Martinez Canillas
2016-01-09 22:24   ` Rob Herring
2016-01-07 12:46 ` [PATCH v2 08/10] [media] tvp5150: Add OF match table Javier Martinez Canillas
2016-01-07 12:46 ` [PATCH v2 09/10] [media] tvp5150: Initialize the chip on probe Javier Martinez Canillas
2016-01-07 12:46   ` Javier Martinez Canillas
2016-01-07 12:46 ` [PATCH v2 10/10] [media] tvp5150: Configure data interface via DT Javier Martinez Canillas
2016-01-25 14:59 ` [PATCH v2 00/10] [media] tvp5150: add MC and DT support Hans Verkuil
2016-01-25 15:04   ` Javier Martinez Canillas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.