linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* HDMI and Composite capture on Lager, for kernel 4.1, version 5
@ 2015-07-23 12:21 William Towle
  2015-07-23 12:21 ` [PATCH 01/13] ARM: shmobile: lager dts: Add entries for VIN HDMI input support William Towle
                   ` (14 more replies)
  0 siblings, 15 replies; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

  Version 5. Some successful upstreaming and some further modification
means this obsoletes version 4, as seen at:
	http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/92832

  This version of the patch series contains a fix for probing the
ADV7611/ADV7612 chips, a reduced (and renamed) "chip info and formats"
patch intended to pave the way for better ADV7612 support, and updates
to rcar_vin_try_fmt() in line with the latest feedback.

Cheers,
  Wills.

To follow:
	[PATCH 01/13] ARM: shmobile: lager dts: Add entries for VIN HDMI
	[PATCH 02/13] ARM: shmobile: lager dts: specify default-input for
	[PATCH 03/13] media: adv7604: fix probe of ADV7611/7612
	[PATCH 04/13] media: adv7604: reduce support to first (digital)
	[PATCH 05/13] v4l: subdev: Add pad config allocator and init
	[PATCH 06/13] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888
	[PATCH 07/13] media: soc_camera pad-aware driver initialisation
	[PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt
	[PATCH 09/13] media: soc_camera: soc_scale_crop: Use correct pad
	[PATCH 10/13] media: soc_camera: Fill std field in enum_input
	[PATCH 11/13] media: soc_camera: Fix error reporting in expbuf
	[PATCH 12/13] media: rcar_vin: fill in bus_info field
	[PATCH 13/13] media: rcar_vin: Reject videobufs that are too small

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

* [PATCH 01/13] ARM: shmobile: lager dts: Add entries for VIN HDMI input support
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-23 12:21 ` [PATCH 02/13] ARM: shmobile: lager dts: specify default-input for ADV7612 William Towle
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

Add DT entries for vin0, vin0_pins, and adv7612

Signed-off-by: William Towle <william.towle@codethink.co.uk>
Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
---
 arch/arm/boot/dts/r8a7790-lager.dts |   41 ++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts
index e02b523..aec7db6 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -378,7 +378,12 @@
 		renesas,function = "usb2";
 	};
 
-	vin1_pins: vin {
+	vin0_pins: vin0 {
+		renesas,groups = "vin0_data24", "vin0_sync", "vin0_field", "vin0_clkenb", "vin0_clk";
+		renesas,function = "vin0";
+	};
+
+	vin1_pins: vin1 {
 		renesas,groups = "vin1_data8", "vin1_clk";
 		renesas,function = "vin1";
 	};
@@ -539,6 +544,18 @@
 		reg = <0x12>;
 	};
 
+	hdmi-in@4c {
+		compatible = "adi,adv7612";
+		reg = <0x4c>;
+		remote = <&vin0>;
+
+		port {
+			hdmi_in_ep: endpoint {
+				remote-endpoint = <&vin0ep0>;
+			};
+		};
+	};
+
 	composite-in@20 {
 		compatible = "adi,adv7180";
 		reg = <0x20>;
@@ -654,6 +671,28 @@
 	status = "okay";
 };
 
+/* HDMI video input */
+&vin0 {
+	pinctrl-0 = <&vin0_pins>;
+	pinctrl-names = "default";
+
+	status = "ok";
+
+	port {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		vin0ep0: endpoint {
+			remote-endpoint = <&hdmi_in_ep>;
+			bus-width = <24>;
+			hsync-active = <0>;
+			vsync-active = <0>;
+			pclk-sample = <1>;
+			data-active = <1>;
+		};
+	};
+};
+
 /* composite video input */
 &vin1 {
 	pinctrl-0 = <&vin1_pins>;
-- 
1.7.10.4


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

* [PATCH 02/13] ARM: shmobile: lager dts: specify default-input for ADV7612
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
  2015-07-23 12:21 ` [PATCH 01/13] ARM: shmobile: lager dts: Add entries for VIN HDMI input support William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-23 12:21 ` [PATCH 03/13] media: adv7604: fix probe of ADV7611/7612 William Towle
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

Set 'default-input' property for ADV7612. Enables image/video capture
without the need to have userspace specifying routing.

Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
Tested-by: William Towle <william.towle@codethink.co.uk>
---
 arch/arm/boot/dts/r8a7790-lager.dts |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts
index aec7db6..e537052 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -552,6 +552,7 @@
 		port {
 			hdmi_in_ep: endpoint {
 				remote-endpoint = <&vin0ep0>;
+				default-input = <0>;
 			};
 		};
 	};
-- 
1.7.10.4


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

* [PATCH 03/13] media: adv7604: fix probe of ADV7611/7612
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
  2015-07-23 12:21 ` [PATCH 01/13] ARM: shmobile: lager dts: Add entries for VIN HDMI input support William Towle
  2015-07-23 12:21 ` [PATCH 02/13] ARM: shmobile: lager dts: specify default-input for ADV7612 William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-24 14:19   ` Hans Verkuil
  2015-07-24 14:34   ` [Linux-kernel] " Ben Dooks
  2015-07-23 12:21 ` [PATCH 04/13] media: adv7604: reduce support to first (digital) input William Towle
                   ` (11 subsequent siblings)
  14 siblings, 2 replies; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

Prior to commit f862f57d ("[media] media: i2c: ADV7604: Migrate to
regmap"), the local variable 'val' contained the combined register
reads used in the chipset version ID test. Restore this expectation
so that the comparison works as it used to.
---
 drivers/media/i2c/adv7604.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index bfb0b6a..0587d27 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3108,7 +3108,7 @@ static int adv76xx_probe(struct i2c_client *client,
 			v4l2_err(sd, "Error %d reading IO Regmap\n", err);
 			return -ENODEV;
 		}
-		val2 |= val;
+		val |= val2;
 		if ((state->info->type == ADV7611 && val != 0x2051) ||
 			(state->info->type == ADV7612 && val != 0x2041)) {
 			v4l2_err(sd, "not an adv761x on address 0x%x\n",
-- 
1.7.10.4


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

* [PATCH 04/13] media: adv7604: reduce support to first (digital) input
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (2 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 03/13] media: adv7604: fix probe of ADV7611/7612 William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-24 14:12   ` Hans Verkuil
  2015-07-23 12:21 ` [PATCH 05/13] v4l: subdev: Add pad config allocator and init William Towle
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

Using adv7611_read_cable_det() for ADV7612 means that full
support for '.max_port = ADV7604_PAD_HDMI_PORT_B,' isn't available
due to the need for multiple port reads to determine cable detection,
and an agreed mechanism for communicating the separate statuses.

This patch replaces adv7611_read_cable_det() with a functionally
identical copy, commented appropriately.

Earlier submissions [leading to commit 8331d30b] also set .cp_csc,
which is used in a cp_read() call within adv76xx_log_status().

Signed-off-by: William Towle <william.towle@codethink.co.uk>
---
 drivers/media/i2c/adv7604.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 0587d27..2524184 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -877,6 +877,16 @@ static unsigned int adv7611_read_cable_det(struct v4l2_subdev *sd)
 	return value & 1;
 }
 
+static unsigned int adv7612_read_cable_det(struct v4l2_subdev *sd)
+{
+	/*  Reads CABLE_DET_A_RAW. For input B support, need to
+	 *  account for bit 7 [MSB] of 0x6a (ie. CABLE_DET_B_RAW)
+	 */
+	u8 value = io_read(sd, 0x6f);
+
+	return value & 1;
+}
+
 static int adv76xx_s_detect_tx_5v_ctrl(struct v4l2_subdev *sd)
 {
 	struct adv76xx_state *state = to_state(sd);
@@ -2728,20 +2738,21 @@ static const struct adv76xx_chip_info adv76xx_chip_info[] = {
 	[ADV7612] = {
 		.type = ADV7612,
 		.has_afe = false,
-		.max_port = ADV7604_PAD_HDMI_PORT_B,
-		.num_dv_ports = 2,
+		.max_port = ADV76XX_PAD_HDMI_PORT_A,	/* B not supported */
+		.num_dv_ports = 1,			/* normally 2 */
 		.edid_enable_reg = 0x74,
 		.edid_status_reg = 0x76,
 		.lcf_reg = 0xa3,
 		.tdms_lock_mask = 0x43,
 		.cable_det_mask = 0x01,
 		.fmt_change_digital_mask = 0x03,
+		.cp_csc = 0xf4,
 		.formats = adv7612_formats,
 		.nformats = ARRAY_SIZE(adv7612_formats),
 		.set_termination = adv7611_set_termination,
 		.setup_irqs = adv7612_setup_irqs,
 		.read_hdmi_pixelclock = adv7611_read_hdmi_pixelclock,
-		.read_cable_det = adv7611_read_cable_det,
+		.read_cable_det = adv7612_read_cable_det,
 		.recommended_settings = {
 		    [1] = adv7612_recommended_settings_hdmi,
 		},
-- 
1.7.10.4


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

* [PATCH 05/13] v4l: subdev: Add pad config allocator and init
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (3 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 04/13] media: adv7604: reduce support to first (digital) input William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-24 14:12   ` Hans Verkuil
  2015-07-23 12:21 ` [PATCH 06/13] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 input support William Towle
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

From: Laurent Pinchart <laurent.pinchart@linaro.org>

Add a new subdev operation to initialize a subdev pad config array, and
a helper function to allocate and initialize the array. This can be used
by bridge drivers to implement try format based on subdev pad
operations.

Signed-off-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Acked-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
---
 drivers/media/v4l2-core/v4l2-subdev.c | 19 ++++++++++++++++++-
 include/media/v4l2-subdev.h           | 10 ++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

Changes since v1:

- Added v4l2_subdev_free_pad_config
---
 drivers/media/v4l2-core/v4l2-subdev.c |   19 ++++++++++++++++++-
 include/media/v4l2-subdev.h           |   10 ++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 83615b8..951a9cf 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -35,7 +35,7 @@
 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-	fh->pad = kzalloc(sizeof(*fh->pad) * sd->entity.num_pads, GFP_KERNEL);
+	fh->pad = v4l2_subdev_alloc_pad_config(sd);
 	if (fh->pad == NULL)
 		return -ENOMEM;
 #endif
@@ -569,6 +569,23 @@ int v4l2_subdev_link_validate(struct media_link *link)
 		sink, link, &source_fmt, &sink_fmt);
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd)
+{
+	struct v4l2_subdev_pad_config *cfg;
+
+	if (!sd->entity.num_pads)
+		return NULL;
+
+	cfg = kcalloc(sd->entity.num_pads, sizeof(*cfg), GFP_KERNEL);
+	if (!cfg)
+		return NULL;
+
+	v4l2_subdev_call(sd, pad, init_cfg, cfg);
+
+	return cfg;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
 #endif /* CONFIG_MEDIA_CONTROLLER */
 
 void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 370fc38..a03b600 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -486,6 +486,8 @@ struct v4l2_subdev_pad_config {
  *                  may be adjusted by the subdev driver to device capabilities.
  */
 struct v4l2_subdev_pad_ops {
+	void (*init_cfg)(struct v4l2_subdev *sd,
+			 struct v4l2_subdev_pad_config *cfg);
 	int (*enum_mbus_code)(struct v4l2_subdev *sd,
 			      struct v4l2_subdev_pad_config *cfg,
 			      struct v4l2_subdev_mbus_code_enum *code);
@@ -680,7 +682,15 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
 				      struct v4l2_subdev_format *source_fmt,
 				      struct v4l2_subdev_format *sink_fmt);
 int v4l2_subdev_link_validate(struct media_link *link);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd);
+
+static inline void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg)
+{
+	kfree(cfg);
+}
 #endif /* CONFIG_MEDIA_CONTROLLER */
+
 void v4l2_subdev_init(struct v4l2_subdev *sd,
 		      const struct v4l2_subdev_ops *ops);
 
-- 
1.7.10.4


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

* [PATCH 06/13] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 input support
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (4 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 05/13] v4l: subdev: Add pad config allocator and init William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-23 12:21 ` [PATCH 07/13] media: soc_camera pad-aware driver initialisation William Towle
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

This adds V4L2_MBUS_FMT_RGB888_1X24 input format support
which is used by the ADV7612 chip.

Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>

Modified to use MEDIA_BUS_FMT_* constants

Signed-off-by: William Towle <william.towle@codethink.co.uk>
Reviewed-by: Rob Taylor <rob.taylor@codethink.co.uk>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/soc_camera/rcar_vin.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index db7700b..16352a8 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -98,6 +98,7 @@
 #define VNMC_INF_YUV10_BT656	(2 << 16)
 #define VNMC_INF_YUV10_BT601	(3 << 16)
 #define VNMC_INF_YUV16		(5 << 16)
+#define VNMC_INF_RGB888		(6 << 16)
 #define VNMC_VUP		(1 << 10)
 #define VNMC_IM_ODD		(0 << 3)
 #define VNMC_IM_ODD_EVEN	(1 << 3)
@@ -589,7 +590,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
 	struct soc_camera_device *icd = priv->ici.icd;
 	struct rcar_vin_cam *cam = icd->host_priv;
 	u32 vnmc, dmr, interrupts;
-	bool progressive = false, output_is_yuv = false;
+	bool progressive = false, output_is_yuv = false, input_is_yuv = false;
 
 	switch (priv->field) {
 	case V4L2_FIELD_TOP:
@@ -623,16 +624,22 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
 	case MEDIA_BUS_FMT_YUYV8_1X16:
 		/* BT.601/BT.1358 16bit YCbCr422 */
 		vnmc |= VNMC_INF_YUV16;
+		input_is_yuv = true;
 		break;
 	case MEDIA_BUS_FMT_YUYV8_2X8:
 		/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
 		vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ?
 			VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
+		input_is_yuv = true;
+		break;
+	case MEDIA_BUS_FMT_RGB888_1X24:
+		vnmc |= VNMC_INF_RGB888;
 		break;
 	case MEDIA_BUS_FMT_YUYV10_2X10:
 		/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
 		vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ?
 			VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
+		input_is_yuv = true;
 		break;
 	default:
 		break;
@@ -676,7 +683,7 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
 	vnmc |= VNMC_VUP;
 
 	/* If input and output use the same colorspace, use bypass mode */
-	if (output_is_yuv)
+	if (input_is_yuv == output_is_yuv)
 		vnmc |= VNMC_BPS;
 
 	/* progressive or interlaced mode */
@@ -1423,6 +1430,7 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx,
 	case MEDIA_BUS_FMT_YUYV8_1X16:
 	case MEDIA_BUS_FMT_YUYV8_2X8:
 	case MEDIA_BUS_FMT_YUYV10_2X10:
+	case MEDIA_BUS_FMT_RGB888_1X24:
 		if (cam->extra_fmt)
 			break;
 
-- 
1.7.10.4


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

* [PATCH 07/13] media: soc_camera pad-aware driver initialisation
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (5 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 06/13] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 input support William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-24 14:18   ` Hans Verkuil
  2017-10-27  8:52   ` Sergei Shtylyov
  2015-07-23 12:21 ` [PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt William Towle
                   ` (7 subsequent siblings)
  14 siblings, 2 replies; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

Add detection of source pad number for drivers aware of the media
controller API, so that the combination of soc_camera and rcar_vin
can create device nodes to support modern drivers such as adv7604.c
(for HDMI on Lager) and the converted adv7180.c (for composite)
underneath.

Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
line with requirements for building the drivers associated with it.

Signed-off-by: William Towle <william.towle@codethink.co.uk>
Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
---
 drivers/media/platform/soc_camera/Kconfig      |    1 +
 drivers/media/platform/soc_camera/rcar_vin.c   |    1 +
 drivers/media/platform/soc_camera/soc_camera.c |   36 ++++++++++++++++++++++++
 include/media/soc_camera.h                     |    1 +
 4 files changed, 39 insertions(+)

diff --git a/drivers/media/platform/soc_camera/Kconfig b/drivers/media/platform/soc_camera/Kconfig
index f2776cd..5c45c83 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -38,6 +38,7 @@ config VIDEO_RCAR_VIN
 	depends on VIDEO_DEV && SOC_CAMERA
 	depends on ARCH_SHMOBILE || COMPILE_TEST
 	depends on HAS_DMA
+	depends on MEDIA_CONTROLLER
 	select VIDEOBUF2_DMA_CONTIG
 	select SOC_CAMERA_SCALE_CROP
 	---help---
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 16352a8..00c1034 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1359,6 +1359,7 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx,
 		struct device *dev = icd->parent;
 		int shift;
 
+		fmt.pad = icd->src_pad_idx;
 		ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt);
 		if (ret < 0)
 			return ret;
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index d708df4..8d4d20c 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1293,6 +1293,9 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd)
 		.which = V4L2_SUBDEV_FORMAT_ACTIVE,
 	};
 	struct v4l2_mbus_framefmt *mf = &fmt.format;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	struct media_pad pad;
+#endif
 	int ret;
 
 	sd->grp_id = soc_camera_grp_id(icd);
@@ -1310,8 +1313,33 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd)
 		return ret;
 	}
 
+	icd->src_pad_idx = 0;
+#if defined(CONFIG_MEDIA_CONTROLLER)
 	/* At this point client .probe() should have run already */
+	ret = media_entity_init(&icd->vdev->entity, 1, &pad, 0);
+	if (ret < 0) {
+		goto eusrfmt;
+	} else {
+		int pad_idx;
+
+		for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
+			if (sd->entity.pads[pad_idx].flags
+					== MEDIA_PAD_FL_SOURCE)
+				break;
+		if (pad_idx >= sd->entity.num_pads)
+			goto eusrfmt;
+
+		icd->src_pad_idx = pad_idx;
+		ret = soc_camera_init_user_formats(icd);
+		if (ret < 0) {
+			icd->src_pad_idx = -1;
+			goto eusrfmt;
+		}
+	}
+#else
 	ret = soc_camera_init_user_formats(icd);
+#endif
+
 	if (ret < 0)
 		goto eusrfmt;
 
@@ -1335,6 +1363,9 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd)
 evidstart:
 	soc_camera_free_user_formats(icd);
 eusrfmt:
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	media_entity_cleanup(&icd->vdev->entity);
+#endif
 	soc_camera_remove_device(icd);
 
 	return ret;
@@ -1856,6 +1887,11 @@ static int soc_camera_remove(struct soc_camera_device *icd)
 	if (icd->num_user_formats)
 		soc_camera_free_user_formats(icd);
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	if (icd->vdev->entity.num_pads)
+		media_entity_cleanup(&icd->vdev->entity);
+#endif
+
 	if (icd->clk) {
 		/* For the synchronous case */
 		v4l2_clk_unregister(icd->clk);
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 2f6261f..30193cf 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -42,6 +42,7 @@ struct soc_camera_device {
 	unsigned char devnum;		/* Device number per host */
 	struct soc_camera_sense *sense;	/* See comment in struct definition */
 	struct video_device *vdev;
+	int src_pad_idx;		/* For media-controller drivers */
 	struct v4l2_ctrl_handler ctrl_handler;
 	const struct soc_camera_format_xlate *current_fmt;
 	struct soc_camera_format_xlate *user_formats;
-- 
1.7.10.4


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

* [PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (6 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 07/13] media: soc_camera pad-aware driver initialisation William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-24 14:14   ` Hans Verkuil
  2015-07-23 12:21 ` [PATCH 09/13] media: soc_camera: soc_scale_crop: " William Towle
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

Fix rcar_vin_try_fmt's use of an inappropriate pad number when calling
the subdev set_fmt function - for the ADV7612, IDs should be non-zero.

Signed-off-by: William Towle <william.towle@codethink.co.uk>
Reviewed-by: Rob Taylor <rob.taylor@codethink.co.uk>
---
 drivers/media/platform/soc_camera/rcar_vin.c |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 00c1034..dab729a 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1697,7 +1697,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
 	const struct soc_camera_format_xlate *xlate;
 	struct v4l2_pix_format *pix = &f->fmt.pix;
 	struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-	struct v4l2_subdev_pad_config pad_cfg;
+	struct v4l2_subdev_pad_config *pad_cfg;
 	struct v4l2_subdev_format format = {
 		.which = V4L2_SUBDEV_FORMAT_TRY,
 	};
@@ -1706,6 +1706,10 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
 	int width, height;
 	int ret;
 
+	pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+	if (pad_cfg == NULL)
+		return -ENOMEM;
+
 	xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
 	if (!xlate) {
 		xlate = icd->current_fmt;
@@ -1734,10 +1738,11 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
 	mf->code = xlate->code;
 	mf->colorspace = pix->colorspace;
 
+	format.pad = icd->src_pad_idx;
 	ret = v4l2_device_call_until_err(sd->v4l2_dev, soc_camera_grp_id(icd),
-					 pad, set_fmt, &pad_cfg, &format);
+					 pad, set_fmt, pad_cfg, &format);
 	if (ret < 0)
-		return ret;
+		goto cleanup;
 
 	/* Adjust only if VIN cannot scale */
 	if (pix->width > mf->width * 2)
@@ -1761,12 +1766,12 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
 			mf->height = VIN_MAX_HEIGHT;
 			ret = v4l2_device_call_until_err(sd->v4l2_dev,
 							 soc_camera_grp_id(icd),
-							 pad, set_fmt, &pad_cfg,
+							 pad, set_fmt, pad_cfg,
 							 &format);
 			if (ret < 0) {
 				dev_err(icd->parent,
 					"client try_fmt() = %d\n", ret);
-				return ret;
+				goto cleanup;
 			}
 		}
 		/* We will scale exactly */
@@ -1776,6 +1781,8 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
 			pix->height = height;
 	}
 
+cleanup:
+	v4l2_subdev_free_pad_config(pad_cfg);
 	return ret;
 }
 
-- 
1.7.10.4


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

* [PATCH 09/13] media: soc_camera: soc_scale_crop: Use correct pad number in try_fmt
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (7 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-24 14:14   ` Hans Verkuil
  2015-07-23 12:21 ` [PATCH 10/13] media: soc_camera: Fill std field in enum_input William Towle
                   ` (5 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

From: Rob Taylor <rob.taylor@codethink.co.uk>

Fix calls to subdev try_fmt function to use valid pad numbers, fixing
the case where subdevs (eg. ADV7612) have valid pad numbers that are
non-zero.

Signed-off-by: William Towle <william.towle@codethink.co.uk>
Reviewed-by: Rob Taylor <rob.taylor@codethink.co.uk>
---
 drivers/media/platform/soc_camera/soc_scale_crop.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c b/drivers/media/platform/soc_camera/soc_scale_crop.c
index bda29bc..2772215 100644
--- a/drivers/media/platform/soc_camera/soc_scale_crop.c
+++ b/drivers/media/platform/soc_camera/soc_scale_crop.c
@@ -225,6 +225,7 @@ static int client_set_fmt(struct soc_camera_device *icd,
 	bool host_1to1;
 	int ret;
 
+	format->pad = icd->src_pad_idx;
 	ret = v4l2_device_call_until_err(sd->v4l2_dev,
 					 soc_camera_grp_id(icd), pad,
 					 set_fmt, NULL, format);
-- 
1.7.10.4


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

* [PATCH 10/13] media: soc_camera: Fill std field in enum_input
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (8 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 09/13] media: soc_camera: soc_scale_crop: " William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-23 12:21 ` [PATCH 11/13] media: soc_camera: Fix error reporting in expbuf William Towle
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Fill in the std field from the video_device tvnorms field in
enum_input.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
---
 drivers/media/platform/soc_camera/soc_camera.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 8d4d20c..7971388 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -309,11 +309,14 @@ static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv,
 static int soc_camera_enum_input(struct file *file, void *priv,
 				 struct v4l2_input *inp)
 {
+	struct soc_camera_device *icd = file->private_data;
+
 	if (inp->index != 0)
 		return -EINVAL;
 
 	/* default is camera */
 	inp->type = V4L2_INPUT_TYPE_CAMERA;
+	inp->std = icd->vdev->tvnorms;
 	strcpy(inp->name, "Camera");
 
 	return 0;
-- 
1.7.10.4


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

* [PATCH 11/13] media: soc_camera: Fix error reporting in expbuf
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (9 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 10/13] media: soc_camera: Fill std field in enum_input William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-23 12:21 ` [PATCH 12/13] media: rcar_vin: fill in bus_info field William Towle
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Remove unnecessary check and fix the error code for vb1 drivers.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
---
 drivers/media/platform/soc_camera/soc_camera.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 7971388..bb181c1 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -470,14 +470,10 @@ static int soc_camera_expbuf(struct file *file, void *priv,
 	struct soc_camera_device *icd = file->private_data;
 	struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
 
-	if (icd->streamer != file)
-		return -EBUSY;
-
 	/* videobuf2 only */
 	if (ici->ops->init_videobuf)
-		return -EINVAL;
-	else
-		return vb2_expbuf(&icd->vb2_vidq, p);
+		return -ENOTTY;
+	return vb2_expbuf(&icd->vb2_vidq, p);
 }
 
 /* Always entered with .host_lock held */
-- 
1.7.10.4


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

* [PATCH 12/13] media: rcar_vin: fill in bus_info field
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (10 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 11/13] media: soc_camera: Fix error reporting in expbuf William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-24 14:14   ` Hans Verkuil
  2015-07-23 12:21 ` [PATCH 13/13] media: rcar_vin: Reject videobufs that are too small for current format William Towle
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

From: Rob Taylor <rob.taylor@codethink.co.uk>

Adapt rcar_vin_querycap() so that cap->bus_info is populated with
something meaningful/unique.

Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
Signed-off-by: William Towle <william.towle@codethink.co.uk>
---
 drivers/media/platform/soc_camera/rcar_vin.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index dab729a..93e20d6 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1799,6 +1799,7 @@ static int rcar_vin_querycap(struct soc_camera_host *ici,
 	strlcpy(cap->card, "R_Car_VIN", sizeof(cap->card));
 	cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
 	cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
+	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s%d", DRV_NAME, ici->nr);
 
 	return 0;
 }
-- 
1.7.10.4


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

* [PATCH 13/13] media: rcar_vin: Reject videobufs that are too small for current format
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (11 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 12/13] media: rcar_vin: fill in bus_info field William Towle
@ 2015-07-23 12:21 ` William Towle
  2015-07-28  8:03 ` HDMI and Composite capture on Lager, for kernel 4.1, version 5 Guennadi Liakhovetski
  2015-07-28  9:20 ` Hans Verkuil
  14 siblings, 0 replies; 29+ messages in thread
From: William Towle @ 2015-07-23 12:21 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov, Hans Verkuil

From: Rob Taylor <rob.taylor@codethink.co.uk>

In videobuf_setup reject buffers that are too small for the configured
format. Fixes v4l2-compliance issue.

Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
Reviewed-by: William Towle <william.towle@codethink.co.uk>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/soc_camera/rcar_vin.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 93e20d6..f4e611b 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -541,6 +541,9 @@ static int rcar_vin_videobuf_setup(struct vb2_queue *vq,
 		unsigned int bytes_per_line;
 		int ret;
 
+		if (fmt->fmt.pix.sizeimage < icd->sizeimage)
+			return -EINVAL;
+
 		xlate = soc_camera_xlate_by_fourcc(icd,
 						   fmt->fmt.pix.pixelformat);
 		if (!xlate)
-- 
1.7.10.4


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

* Re: [PATCH 04/13] media: adv7604: reduce support to first (digital) input
  2015-07-23 12:21 ` [PATCH 04/13] media: adv7604: reduce support to first (digital) input William Towle
@ 2015-07-24 14:12   ` Hans Verkuil
  0 siblings, 0 replies; 29+ messages in thread
From: Hans Verkuil @ 2015-07-24 14:12 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov

On 07/23/2015 02:21 PM, William Towle wrote:
> Using adv7611_read_cable_det() for ADV7612 means that full
> support for '.max_port = ADV7604_PAD_HDMI_PORT_B,' isn't available
> due to the need for multiple port reads to determine cable detection,
> and an agreed mechanism for communicating the separate statuses.
> 
> This patch replaces adv7611_read_cable_det() with a functionally
> identical copy, commented appropriately.
> 
> Earlier submissions [leading to commit 8331d30b] also set .cp_csc,
> which is used in a cp_read() call within adv76xx_log_status().
> 
> Signed-off-by: William Towle <william.towle@codethink.co.uk>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> ---
>  drivers/media/i2c/adv7604.c |   17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
> index 0587d27..2524184 100644
> --- a/drivers/media/i2c/adv7604.c
> +++ b/drivers/media/i2c/adv7604.c
> @@ -877,6 +877,16 @@ static unsigned int adv7611_read_cable_det(struct v4l2_subdev *sd)
>  	return value & 1;
>  }
>  
> +static unsigned int adv7612_read_cable_det(struct v4l2_subdev *sd)
> +{
> +	/*  Reads CABLE_DET_A_RAW. For input B support, need to
> +	 *  account for bit 7 [MSB] of 0x6a (ie. CABLE_DET_B_RAW)
> +	 */
> +	u8 value = io_read(sd, 0x6f);
> +
> +	return value & 1;
> +}
> +
>  static int adv76xx_s_detect_tx_5v_ctrl(struct v4l2_subdev *sd)
>  {
>  	struct adv76xx_state *state = to_state(sd);
> @@ -2728,20 +2738,21 @@ static const struct adv76xx_chip_info adv76xx_chip_info[] = {
>  	[ADV7612] = {
>  		.type = ADV7612,
>  		.has_afe = false,
> -		.max_port = ADV7604_PAD_HDMI_PORT_B,
> -		.num_dv_ports = 2,
> +		.max_port = ADV76XX_PAD_HDMI_PORT_A,	/* B not supported */
> +		.num_dv_ports = 1,			/* normally 2 */
>  		.edid_enable_reg = 0x74,
>  		.edid_status_reg = 0x76,
>  		.lcf_reg = 0xa3,
>  		.tdms_lock_mask = 0x43,
>  		.cable_det_mask = 0x01,
>  		.fmt_change_digital_mask = 0x03,
> +		.cp_csc = 0xf4,
>  		.formats = adv7612_formats,
>  		.nformats = ARRAY_SIZE(adv7612_formats),
>  		.set_termination = adv7611_set_termination,
>  		.setup_irqs = adv7612_setup_irqs,
>  		.read_hdmi_pixelclock = adv7611_read_hdmi_pixelclock,
> -		.read_cable_det = adv7611_read_cable_det,
> +		.read_cable_det = adv7612_read_cable_det,
>  		.recommended_settings = {
>  		    [1] = adv7612_recommended_settings_hdmi,
>  		},
> 


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

* Re: [PATCH 05/13] v4l: subdev: Add pad config allocator and init
  2015-07-23 12:21 ` [PATCH 05/13] v4l: subdev: Add pad config allocator and init William Towle
@ 2015-07-24 14:12   ` Hans Verkuil
  2015-08-11 13:03     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 29+ messages in thread
From: Hans Verkuil @ 2015-07-24 14:12 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov

On 07/23/2015 02:21 PM, William Towle wrote:
> From: Laurent Pinchart <laurent.pinchart@linaro.org>
> 
> Add a new subdev operation to initialize a subdev pad config array, and
> a helper function to allocate and initialize the array. This can be used
> by bridge drivers to implement try format based on subdev pad
> operations.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@linaro.org>
> Acked-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> ---
>  drivers/media/v4l2-core/v4l2-subdev.c | 19 ++++++++++++++++++-
>  include/media/v4l2-subdev.h           | 10 ++++++++++
>  2 files changed, 28 insertions(+), 1 deletion(-)
> 
> Changes since v1:
> 
> - Added v4l2_subdev_free_pad_config
> ---
>  drivers/media/v4l2-core/v4l2-subdev.c |   19 ++++++++++++++++++-
>  include/media/v4l2-subdev.h           |   10 ++++++++++
>  2 files changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 83615b8..951a9cf 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -35,7 +35,7 @@
>  static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
>  {
>  #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
> -	fh->pad = kzalloc(sizeof(*fh->pad) * sd->entity.num_pads, GFP_KERNEL);
> +	fh->pad = v4l2_subdev_alloc_pad_config(sd);
>  	if (fh->pad == NULL)
>  		return -ENOMEM;
>  #endif
> @@ -569,6 +569,23 @@ int v4l2_subdev_link_validate(struct media_link *link)
>  		sink, link, &source_fmt, &sink_fmt);
>  }
>  EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
> +
> +struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd)
> +{
> +	struct v4l2_subdev_pad_config *cfg;
> +
> +	if (!sd->entity.num_pads)
> +		return NULL;
> +
> +	cfg = kcalloc(sd->entity.num_pads, sizeof(*cfg), GFP_KERNEL);
> +	if (!cfg)
> +		return NULL;
> +
> +	v4l2_subdev_call(sd, pad, init_cfg, cfg);
> +
> +	return cfg;
> +}
> +EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
>  #endif /* CONFIG_MEDIA_CONTROLLER */
>  
>  void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index 370fc38..a03b600 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -486,6 +486,8 @@ struct v4l2_subdev_pad_config {
>   *                  may be adjusted by the subdev driver to device capabilities.
>   */
>  struct v4l2_subdev_pad_ops {
> +	void (*init_cfg)(struct v4l2_subdev *sd,
> +			 struct v4l2_subdev_pad_config *cfg);
>  	int (*enum_mbus_code)(struct v4l2_subdev *sd,
>  			      struct v4l2_subdev_pad_config *cfg,
>  			      struct v4l2_subdev_mbus_code_enum *code);
> @@ -680,7 +682,15 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
>  				      struct v4l2_subdev_format *source_fmt,
>  				      struct v4l2_subdev_format *sink_fmt);
>  int v4l2_subdev_link_validate(struct media_link *link);
> +
> +struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd);
> +
> +static inline void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg)
> +{
> +	kfree(cfg);
> +}
>  #endif /* CONFIG_MEDIA_CONTROLLER */
> +
>  void v4l2_subdev_init(struct v4l2_subdev *sd,
>  		      const struct v4l2_subdev_ops *ops);
>  
> 


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

* Re: [PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt
  2015-07-23 12:21 ` [PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt William Towle
@ 2015-07-24 14:14   ` Hans Verkuil
  0 siblings, 0 replies; 29+ messages in thread
From: Hans Verkuil @ 2015-07-24 14:14 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov

On 07/23/2015 02:21 PM, William Towle wrote:
> Fix rcar_vin_try_fmt's use of an inappropriate pad number when calling
> the subdev set_fmt function - for the ADV7612, IDs should be non-zero.
> 
> Signed-off-by: William Towle <william.towle@codethink.co.uk>
> Reviewed-by: Rob Taylor <rob.taylor@codethink.co.uk>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> ---
>  drivers/media/platform/soc_camera/rcar_vin.c |   17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
> index 00c1034..dab729a 100644
> --- a/drivers/media/platform/soc_camera/rcar_vin.c
> +++ b/drivers/media/platform/soc_camera/rcar_vin.c
> @@ -1697,7 +1697,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
>  	const struct soc_camera_format_xlate *xlate;
>  	struct v4l2_pix_format *pix = &f->fmt.pix;
>  	struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
> -	struct v4l2_subdev_pad_config pad_cfg;
> +	struct v4l2_subdev_pad_config *pad_cfg;
>  	struct v4l2_subdev_format format = {
>  		.which = V4L2_SUBDEV_FORMAT_TRY,
>  	};
> @@ -1706,6 +1706,10 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
>  	int width, height;
>  	int ret;
>  
> +	pad_cfg = v4l2_subdev_alloc_pad_config(sd);
> +	if (pad_cfg == NULL)
> +		return -ENOMEM;
> +
>  	xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
>  	if (!xlate) {
>  		xlate = icd->current_fmt;
> @@ -1734,10 +1738,11 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
>  	mf->code = xlate->code;
>  	mf->colorspace = pix->colorspace;
>  
> +	format.pad = icd->src_pad_idx;
>  	ret = v4l2_device_call_until_err(sd->v4l2_dev, soc_camera_grp_id(icd),
> -					 pad, set_fmt, &pad_cfg, &format);
> +					 pad, set_fmt, pad_cfg, &format);
>  	if (ret < 0)
> -		return ret;
> +		goto cleanup;
>  
>  	/* Adjust only if VIN cannot scale */
>  	if (pix->width > mf->width * 2)
> @@ -1761,12 +1766,12 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
>  			mf->height = VIN_MAX_HEIGHT;
>  			ret = v4l2_device_call_until_err(sd->v4l2_dev,
>  							 soc_camera_grp_id(icd),
> -							 pad, set_fmt, &pad_cfg,
> +							 pad, set_fmt, pad_cfg,
>  							 &format);
>  			if (ret < 0) {
>  				dev_err(icd->parent,
>  					"client try_fmt() = %d\n", ret);
> -				return ret;
> +				goto cleanup;
>  			}
>  		}
>  		/* We will scale exactly */
> @@ -1776,6 +1781,8 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
>  			pix->height = height;
>  	}
>  
> +cleanup:
> +	v4l2_subdev_free_pad_config(pad_cfg);
>  	return ret;
>  }
>  
> 


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

* Re: [PATCH 09/13] media: soc_camera: soc_scale_crop: Use correct pad number in try_fmt
  2015-07-23 12:21 ` [PATCH 09/13] media: soc_camera: soc_scale_crop: " William Towle
@ 2015-07-24 14:14   ` Hans Verkuil
  0 siblings, 0 replies; 29+ messages in thread
From: Hans Verkuil @ 2015-07-24 14:14 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov

On 07/23/2015 02:21 PM, William Towle wrote:
> From: Rob Taylor <rob.taylor@codethink.co.uk>
> 
> Fix calls to subdev try_fmt function to use valid pad numbers, fixing
> the case where subdevs (eg. ADV7612) have valid pad numbers that are
> non-zero.
> 
> Signed-off-by: William Towle <william.towle@codethink.co.uk>
> Reviewed-by: Rob Taylor <rob.taylor@codethink.co.uk>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> ---
>  drivers/media/platform/soc_camera/soc_scale_crop.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c b/drivers/media/platform/soc_camera/soc_scale_crop.c
> index bda29bc..2772215 100644
> --- a/drivers/media/platform/soc_camera/soc_scale_crop.c
> +++ b/drivers/media/platform/soc_camera/soc_scale_crop.c
> @@ -225,6 +225,7 @@ static int client_set_fmt(struct soc_camera_device *icd,
>  	bool host_1to1;
>  	int ret;
>  
> +	format->pad = icd->src_pad_idx;
>  	ret = v4l2_device_call_until_err(sd->v4l2_dev,
>  					 soc_camera_grp_id(icd), pad,
>  					 set_fmt, NULL, format);
> 


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

* Re: [PATCH 12/13] media: rcar_vin: fill in bus_info field
  2015-07-23 12:21 ` [PATCH 12/13] media: rcar_vin: fill in bus_info field William Towle
@ 2015-07-24 14:14   ` Hans Verkuil
  0 siblings, 0 replies; 29+ messages in thread
From: Hans Verkuil @ 2015-07-24 14:14 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov

On 07/23/2015 02:21 PM, William Towle wrote:
> From: Rob Taylor <rob.taylor@codethink.co.uk>
> 
> Adapt rcar_vin_querycap() so that cap->bus_info is populated with
> something meaningful/unique.
> 
> Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
> Signed-off-by: William Towle <william.towle@codethink.co.uk>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> ---
>  drivers/media/platform/soc_camera/rcar_vin.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
> index dab729a..93e20d6 100644
> --- a/drivers/media/platform/soc_camera/rcar_vin.c
> +++ b/drivers/media/platform/soc_camera/rcar_vin.c
> @@ -1799,6 +1799,7 @@ static int rcar_vin_querycap(struct soc_camera_host *ici,
>  	strlcpy(cap->card, "R_Car_VIN", sizeof(cap->card));
>  	cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
>  	cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
> +	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s%d", DRV_NAME, ici->nr);
>  
>  	return 0;
>  }
> 


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

* Re: [PATCH 07/13] media: soc_camera pad-aware driver initialisation
  2015-07-23 12:21 ` [PATCH 07/13] media: soc_camera pad-aware driver initialisation William Towle
@ 2015-07-24 14:18   ` Hans Verkuil
  2015-07-27 12:35     ` William Towle
  2017-10-27  8:52   ` Sergei Shtylyov
  1 sibling, 1 reply; 29+ messages in thread
From: Hans Verkuil @ 2015-07-24 14:18 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov

On 07/23/2015 02:21 PM, William Towle wrote:
> Add detection of source pad number for drivers aware of the media
> controller API, so that the combination of soc_camera and rcar_vin
> can create device nodes to support modern drivers such as adv7604.c
> (for HDMI on Lager) and the converted adv7180.c (for composite)
> underneath.
> 
> Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
> line with requirements for building the drivers associated with it.
> 
> Signed-off-by: William Towle <william.towle@codethink.co.uk>
> Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
> ---
>  drivers/media/platform/soc_camera/Kconfig      |    1 +
>  drivers/media/platform/soc_camera/rcar_vin.c   |    1 +
>  drivers/media/platform/soc_camera/soc_camera.c |   36 ++++++++++++++++++++++++
>  include/media/soc_camera.h                     |    1 +
>  4 files changed, 39 insertions(+)
> 
> diff --git a/drivers/media/platform/soc_camera/Kconfig b/drivers/media/platform/soc_camera/Kconfig
> index f2776cd..5c45c83 100644
> --- a/drivers/media/platform/soc_camera/Kconfig
> +++ b/drivers/media/platform/soc_camera/Kconfig
> @@ -38,6 +38,7 @@ config VIDEO_RCAR_VIN
>  	depends on VIDEO_DEV && SOC_CAMERA
>  	depends on ARCH_SHMOBILE || COMPILE_TEST
>  	depends on HAS_DMA
> +	depends on MEDIA_CONTROLLER
>  	select VIDEOBUF2_DMA_CONTIG
>  	select SOC_CAMERA_SCALE_CROP
>  	---help---
> diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
> index 16352a8..00c1034 100644
> --- a/drivers/media/platform/soc_camera/rcar_vin.c
> +++ b/drivers/media/platform/soc_camera/rcar_vin.c
> @@ -1359,6 +1359,7 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx,
>  		struct device *dev = icd->parent;
>  		int shift;
>  
> +		fmt.pad = icd->src_pad_idx;
>  		ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt);
>  		if (ret < 0)
>  			return ret;
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index d708df4..8d4d20c 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -1293,6 +1293,9 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd)
>  		.which = V4L2_SUBDEV_FORMAT_ACTIVE,
>  	};
>  	struct v4l2_mbus_framefmt *mf = &fmt.format;
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> +	struct media_pad pad;
> +#endif
>  	int ret;
>  
>  	sd->grp_id = soc_camera_grp_id(icd);
> @@ -1310,8 +1313,33 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd)
>  		return ret;
>  	}
>  
> +	icd->src_pad_idx = 0;
> +#if defined(CONFIG_MEDIA_CONTROLLER)
>  	/* At this point client .probe() should have run already */
> +	ret = media_entity_init(&icd->vdev->entity, 1, &pad, 0);

Why would you want to init vdev->entity? soc-camera doesn't create a media controller
device, so there is no point in doing this.

> +	if (ret < 0) {
> +		goto eusrfmt;
> +	} else {
> +		int pad_idx;
> +
> +		for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
> +			if (sd->entity.pads[pad_idx].flags
> +					== MEDIA_PAD_FL_SOURCE)
> +				break;
> +		if (pad_idx >= sd->entity.num_pads)
> +			goto eusrfmt;
> +
> +		icd->src_pad_idx = pad_idx;

This is all you need.

> +		ret = soc_camera_init_user_formats(icd);
> +		if (ret < 0) {
> +			icd->src_pad_idx = -1;
> +			goto eusrfmt;
> +		}

Why is this inside the 'else' part? Isn't this shared code that can go
below?

> +	}
> +#else
>  	ret = soc_camera_init_user_formats(icd);
> +#endif
> +
>  	if (ret < 0)
>  		goto eusrfmt;
>  
> @@ -1335,6 +1363,9 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd)
>  evidstart:
>  	soc_camera_free_user_formats(icd);
>  eusrfmt:
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> +	media_entity_cleanup(&icd->vdev->entity);
> +#endif
>  	soc_camera_remove_device(icd);
>  
>  	return ret;
> @@ -1856,6 +1887,11 @@ static int soc_camera_remove(struct soc_camera_device *icd)
>  	if (icd->num_user_formats)
>  		soc_camera_free_user_formats(icd);
>  
> +#if defined(CONFIG_MEDIA_CONTROLLER)
> +	if (icd->vdev->entity.num_pads)
> +		media_entity_cleanup(&icd->vdev->entity);
> +#endif
> +
>  	if (icd->clk) {
>  		/* For the synchronous case */
>  		v4l2_clk_unregister(icd->clk);
> diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
> index 2f6261f..30193cf 100644
> --- a/include/media/soc_camera.h
> +++ b/include/media/soc_camera.h
> @@ -42,6 +42,7 @@ struct soc_camera_device {
>  	unsigned char devnum;		/* Device number per host */
>  	struct soc_camera_sense *sense;	/* See comment in struct definition */
>  	struct video_device *vdev;
> +	int src_pad_idx;		/* For media-controller drivers */
>  	struct v4l2_ctrl_handler ctrl_handler;
>  	const struct soc_camera_format_xlate *current_fmt;
>  	struct soc_camera_format_xlate *user_formats;
> 

Regards,

	Hans

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

* Re: [PATCH 03/13] media: adv7604: fix probe of ADV7611/7612
  2015-07-23 12:21 ` [PATCH 03/13] media: adv7604: fix probe of ADV7611/7612 William Towle
@ 2015-07-24 14:19   ` Hans Verkuil
  2015-07-27 12:29     ` William Towle
  2015-07-24 14:34   ` [Linux-kernel] " Ben Dooks
  1 sibling, 1 reply; 29+ messages in thread
From: Hans Verkuil @ 2015-07-24 14:19 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov

On 07/23/2015 02:21 PM, William Towle wrote:
> Prior to commit f862f57d ("[media] media: i2c: ADV7604: Migrate to
> regmap"), the local variable 'val' contained the combined register
> reads used in the chipset version ID test. Restore this expectation
> so that the comparison works as it used to.
> ---
>  drivers/media/i2c/adv7604.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
> index bfb0b6a..0587d27 100644
> --- a/drivers/media/i2c/adv7604.c
> +++ b/drivers/media/i2c/adv7604.c
> @@ -3108,7 +3108,7 @@ static int adv76xx_probe(struct i2c_client *client,
>  			v4l2_err(sd, "Error %d reading IO Regmap\n", err);
>  			return -ENODEV;
>  		}
> -		val2 |= val;
> +		val |= val2;
>  		if ((state->info->type == ADV7611 && val != 0x2051) ||
>  			(state->info->type == ADV7612 && val != 0x2041)) {
>  			v4l2_err(sd, "not an adv761x on address 0x%x\n",
> 

Oops. Added to my TODO list, I'll probably pick this up on Tuesday for a pull
request.

Regards,

	Hans

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

* Re: [Linux-kernel] [PATCH 03/13] media: adv7604: fix probe of ADV7611/7612
  2015-07-23 12:21 ` [PATCH 03/13] media: adv7604: fix probe of ADV7611/7612 William Towle
  2015-07-24 14:19   ` Hans Verkuil
@ 2015-07-24 14:34   ` Ben Dooks
  1 sibling, 0 replies; 29+ messages in thread
From: Ben Dooks @ 2015-07-24 14:34 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Hans Verkuil, Guennadi Liakhovetski, Sergei Shtylyov

On 23/07/15 13:21, William Towle wrote:
> Prior to commit f862f57d ("[media] media: i2c: ADV7604: Migrate to
> regmap"), the local variable 'val' contained the combined register
> reads used in the chipset version ID test. Restore this expectation
> so that the comparison works as it used to.

Forgot the Signed-off-by: line here.

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

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

* Re: [PATCH 03/13] media: adv7604: fix probe of ADV7611/7612
  2015-07-24 14:19   ` Hans Verkuil
@ 2015-07-27 12:29     ` William Towle
  0 siblings, 0 replies; 29+ messages in thread
From: William Towle @ 2015-07-27 12:29 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: William Towle, linux-media, linux-kernel, Guennadi Liakhovetski,
	Sergei Shtylyov

On Fri, 24 Jul 2015, Hans Verkuil wrote:
>> -		val2 |= val;
>> +		val |= val2;

> Oops. Added to my TODO list, I'll probably pick this up on Tuesday for a pull
> request.

   And an oops from me: a keen-eyed local correspondent spotted that
I'd omitted the S-o-b :(

Wills.

...
Subject: [PATCH] media: adv7604: fix probe of ADV7611/7612

Prior to commit f862f57d ("[media] media: i2c: ADV7604: Migrate to
regmap"), the local variable 'val' contained the combined register
reads used in the chipset version ID test. Restore this expectation
so that the comparison works as it used to.

Signed-off-by: William Towle <william.towle@codethink.co.uk>
---
  drivers/media/i2c/adv7604.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index bfb0b6a..0587d27 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3108,7 +3108,7 @@ static int adv76xx_probe(struct i2c_client *client,
  			v4l2_err(sd, "Error %d reading IO Regmap\n", err);
  			return -ENODEV;
  		}
-		val2 |= val;
+		val |= val2;
  		if ((state->info->type == ADV7611 && val != 0x2051) ||
  			(state->info->type == ADV7612 && val != 0x2041)) {
  			v4l2_err(sd, "not an adv761x on address 0x%x\n",
-- 
1.7.10.4


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

* Re: [PATCH 07/13] media: soc_camera pad-aware driver initialisation
  2015-07-24 14:18   ` Hans Verkuil
@ 2015-07-27 12:35     ` William Towle
  0 siblings, 0 replies; 29+ messages in thread
From: William Towle @ 2015-07-27 12:35 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: William Towle, linux-media, linux-kernel, Guennadi Liakhovetski,
	Sergei Shtylyov

On Fri, 24 Jul 2015, Hans Verkuil wrote:
> Why would you want to init vdev->entity? soc-camera doesn't create a media controller
> device, so there is no point in doing this.

   Thanks, I hadn't quite understood that about the code I was
transplanting to/from. Please find an update below.

Cheers,
   Wills.


...
Subject: [PATCH] media: soc_camera pad-aware driver initialisation

Add detection of source pad number for drivers aware of the media
controller API, so that the combination of soc_camera and rcar_vin
can create device nodes to support modern drivers such as adv7604.c
(for HDMI on Lager) and the converted adv7180.c (for composite)
underneath.

Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
line with requirements for building the drivers associated with it.

Signed-off-by: William Towle <william.towle@codethink.co.uk>
Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
---
  drivers/media/platform/soc_camera/Kconfig      |    1 +
  drivers/media/platform/soc_camera/rcar_vin.c   |    1 +
  drivers/media/platform/soc_camera/soc_camera.c |   20 +++++++++++++++++++-
  include/media/soc_camera.h                     |    1 +
  4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/Kconfig b/drivers/media/platform/soc_camera/Kconfig
index f2776cd..5c45c83 100644
--- a/drivers/media/platform/soc_camera/Kconfig
+++ b/drivers/media/platform/soc_camera/Kconfig
@@ -38,6 +38,7 @@ config VIDEO_RCAR_VIN
  	depends on VIDEO_DEV && SOC_CAMERA
  	depends on ARCH_SHMOBILE || COMPILE_TEST
  	depends on HAS_DMA
+	depends on MEDIA_CONTROLLER
  	select VIDEOBUF2_DMA_CONTIG
  	select SOC_CAMERA_SCALE_CROP
  	---help---
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 16352a8..00c1034 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1359,6 +1359,7 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx,
  		struct device *dev = icd->parent;
  		int shift;

+		fmt.pad = icd->src_pad_idx;
  		ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt);
  		if (ret < 0)
  			return ret;
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index d708df4..82d3ebe 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1293,6 +1293,10 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd)
  		.which = V4L2_SUBDEV_FORMAT_ACTIVE,
  	};
  	struct v4l2_mbus_framefmt *mf = &fmt.format;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	struct media_pad pad;
+	int pad_idx;
+#endif
  	int ret;

  	sd->grp_id = soc_camera_grp_id(icd);
@@ -1311,9 +1315,23 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd)
  	}

  	/* At this point client .probe() should have run already */
+	icd->src_pad_idx = 0;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+	for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
+		if (sd->entity.pads[pad_idx].flags
+				== MEDIA_PAD_FL_SOURCE)
+			break;
+	if (pad_idx >= sd->entity.num_pads)
+		goto eusrfmt;
+
+	icd->src_pad_idx = pad_idx;
+#endif
+
  	ret = soc_camera_init_user_formats(icd);
-	if (ret < 0)
+	if (ret < 0) {
+		icd->src_pad_idx = -1;
  		goto eusrfmt;
+	}

  	icd->field = V4L2_FIELD_ANY;

diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h
index 2f6261f..30193cf 100644
--- a/include/media/soc_camera.h
+++ b/include/media/soc_camera.h
@@ -42,6 +42,7 @@ struct soc_camera_device {
  	unsigned char devnum;		/* Device number per host */
  	struct soc_camera_sense *sense;	/* See comment in struct definition */
  	struct video_device *vdev;
+	int src_pad_idx;		/* For media-controller drivers */
  	struct v4l2_ctrl_handler ctrl_handler;
  	const struct soc_camera_format_xlate *current_fmt;
  	struct soc_camera_format_xlate *user_formats;
-- 
1.7.10.4


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

* Re: HDMI and Composite capture on Lager, for kernel 4.1, version 5
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (12 preceding siblings ...)
  2015-07-23 12:21 ` [PATCH 13/13] media: rcar_vin: Reject videobufs that are too small for current format William Towle
@ 2015-07-28  8:03 ` Guennadi Liakhovetski
  2015-07-28  9:20 ` Hans Verkuil
  14 siblings, 0 replies; 29+ messages in thread
From: Guennadi Liakhovetski @ 2015-07-28  8:03 UTC (permalink / raw)
  To: William Towle; +Cc: linux-media, linux-kernel, Sergei Shtylyov, Hans Verkuil

On Thu, 23 Jul 2015, William Towle wrote:

>   Version 5. Some successful upstreaming and some further modification
> means this obsoletes version 4, as seen at:
> 	http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/92832
> 
>   This version of the patch series contains a fix for probing the
> ADV7611/ADV7612 chips, a reduced (and renamed) "chip info and formats"
> patch intended to pave the way for better ADV7612 support, and updates
> to rcar_vin_try_fmt() in line with the latest feedback.
> 
> Cheers,
>   Wills.
> 
> To follow:
> 	[PATCH 01/13] ARM: shmobile: lager dts: Add entries for VIN HDMI
> 	[PATCH 02/13] ARM: shmobile: lager dts: specify default-input for
> 	[PATCH 03/13] media: adv7604: fix probe of ADV7611/7612
> 	[PATCH 04/13] media: adv7604: reduce support to first (digital)
> 	[PATCH 05/13] v4l: subdev: Add pad config allocator and init
> 	[PATCH 06/13] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888
> 	[PATCH 07/13] media: soc_camera pad-aware driver initialisation
> 	[PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt
> 	[PATCH 09/13] media: soc_camera: soc_scale_crop: Use correct pad
> 	[PATCH 10/13] media: soc_camera: Fill std field in enum_input
> 	[PATCH 11/13] media: soc_camera: Fix error reporting in expbuf
> 	[PATCH 12/13] media: rcar_vin: fill in bus_info field
> 	[PATCH 13/13] media: rcar_vin: Reject videobufs that are too small

Since Hans would like to pull these patches urgently: for patches #6, 7 
(in its updated version 6 of yesterday 27.07.2015), and 8-13:

Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

Thanks
Guennadi

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

* Re: HDMI and Composite capture on Lager, for kernel 4.1, version 5
  2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
                   ` (13 preceding siblings ...)
  2015-07-28  8:03 ` HDMI and Composite capture on Lager, for kernel 4.1, version 5 Guennadi Liakhovetski
@ 2015-07-28  9:20 ` Hans Verkuil
  14 siblings, 0 replies; 29+ messages in thread
From: Hans Verkuil @ 2015-07-28  9:20 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Sergei Shtylyov

Hi William,

On 07/23/2015 02:21 PM, William Towle wrote:
>   Version 5. Some successful upstreaming and some further modification
> means this obsoletes version 4, as seen at:
> 	http://permalink.gmane.org/gmane.linux.drivers.video-input-infrastructure/92832
> 
>   This version of the patch series contains a fix for probing the
> ADV7611/ADV7612 chips, a reduced (and renamed) "chip info and formats"
> patch intended to pave the way for better ADV7612 support, and updates
> to rcar_vin_try_fmt() in line with the latest feedback.
> 
> Cheers,
>   Wills.

I've merged patches 3-13 (patches 10 and 11 are marked superseded since I'm
using versions I posted as part of another patch series).

But you need to repost patches 1 and 2 with a CC to linux-sh@vger.kernel.org
so Simon Horman can either pull them in or Ack them and then I'll merge these
patches. It probably makes more sense that Simon merges them since I believe
these two patches are independent of the others.

Regards,

	Hans

> 
> To follow:
> 	[PATCH 01/13] ARM: shmobile: lager dts: Add entries for VIN HDMI
> 	[PATCH 02/13] ARM: shmobile: lager dts: specify default-input for
> 	[PATCH 03/13] media: adv7604: fix probe of ADV7611/7612
> 	[PATCH 04/13] media: adv7604: reduce support to first (digital)
> 	[PATCH 05/13] v4l: subdev: Add pad config allocator and init
> 	[PATCH 06/13] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888
> 	[PATCH 07/13] media: soc_camera pad-aware driver initialisation
> 	[PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt
> 	[PATCH 09/13] media: soc_camera: soc_scale_crop: Use correct pad
> 	[PATCH 10/13] media: soc_camera: Fill std field in enum_input
> 	[PATCH 11/13] media: soc_camera: Fix error reporting in expbuf
> 	[PATCH 12/13] media: rcar_vin: fill in bus_info field
> 	[PATCH 13/13] media: rcar_vin: Reject videobufs that are too small
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH 05/13] v4l: subdev: Add pad config allocator and init
  2015-07-24 14:12   ` Hans Verkuil
@ 2015-08-11 13:03     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 29+ messages in thread
From: Mauro Carvalho Chehab @ 2015-08-11 13:03 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: William Towle, linux-media, linux-kernel, Guennadi Liakhovetski,
	Sergei Shtylyov

Em Fri, 24 Jul 2015 16:12:44 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 07/23/2015 02:21 PM, William Towle wrote:
> > From: Laurent Pinchart <laurent.pinchart@linaro.org>
> > 
> > Add a new subdev operation to initialize a subdev pad config array, and
> > a helper function to allocate and initialize the array. This can be used
> > by bridge drivers to implement try format based on subdev pad
> > operations.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@linaro.org>
> > Acked-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
> 
> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Won't merge this patch. 

The Media Controller implementation is currently broken.

So, as agreed at the MC workshop, we won't be changing anything related
to the MC while we don't rework its implementation in order to fix its
mess.

In this particular case, we'll very likely need to replace pads from
arrays to linked lists, in order to properly support dynamic addition
and removal. If we go to that direction, the implementation of this
patch will be different.

So, it should wait for the changes.

Feel free to submit a new version of this change once we finish
with the MC rework patches.

Regards,
Mauro

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

* Re: [PATCH 07/13] media: soc_camera pad-aware driver initialisation
  2015-07-23 12:21 ` [PATCH 07/13] media: soc_camera pad-aware driver initialisation William Towle
  2015-07-24 14:18   ` Hans Verkuil
@ 2017-10-27  8:52   ` Sergei Shtylyov
  2017-10-27  8:56     ` Sergei Shtylyov
  1 sibling, 1 reply; 29+ messages in thread
From: Sergei Shtylyov @ 2017-10-27  8:52 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Hans Verkuil

Hello!

On 7/23/2015 2:21 PM, William Towle wrote:

> Add detection of source pad number for drivers aware of the media
> controller API, so that the combination of soc_camera and rcar_vin
> can create device nodes to support modern drivers such as adv7604.c
> (for HDMI on Lager) and the converted adv7180.c (for composite)
> underneath.
> 
> Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
> line with requirements for building the drivers associated with it.
> 
> Signed-off-by: William Towle <william.towle@codethink.co.uk>
> Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
> ---
>   drivers/media/platform/soc_camera/Kconfig      |    1 +
>   drivers/media/platform/soc_camera/rcar_vin.c   |    1 +

    This driver no longer exists. What did you base on?

>   drivers/media/platform/soc_camera/soc_camera.c |   36 ++++++++++++++++++++++++
>   include/media/soc_camera.h                     |    1 +
>   4 files changed, 39 insertions(+)
[...]
> @@ -1310,8 +1313,33 @@ static int soc_camera_probe_finish(struct soc_camera_device *icd)
>   		return ret;
>   	}
>   
> +	icd->src_pad_idx = 0;
> +#if defined(CONFIG_MEDIA_CONTROLLER)
>   	/* At this point client .probe() should have run already */
> +	ret = media_entity_init(&icd->vdev->entity, 1, &pad, 0);
> +	if (ret < 0) {
> +		goto eusrfmt;
> +	} else {
> +		int pad_idx;
> +
> +		for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++)
> +			if (sd->entity.pads[pad_idx].flags
> +					== MEDIA_PAD_FL_SOURCE)

    Please leave == on the previous line...

[...]

MBR, Sergei

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

* Re: [PATCH 07/13] media: soc_camera pad-aware driver initialisation
  2017-10-27  8:52   ` Sergei Shtylyov
@ 2017-10-27  8:56     ` Sergei Shtylyov
  0 siblings, 0 replies; 29+ messages in thread
From: Sergei Shtylyov @ 2017-10-27  8:56 UTC (permalink / raw)
  To: William Towle, linux-media, linux-kernel
  Cc: Guennadi Liakhovetski, Hans Verkuil

On 10/27/2017 10:52 AM, Sergei Shtylyov wrote:

>> Add detection of source pad number for drivers aware of the media
>> controller API, so that the combination of soc_camera and rcar_vin
>> can create device nodes to support modern drivers such as adv7604.c
>> (for HDMI on Lager) and the converted adv7180.c (for composite)
>> underneath.
>>
>> Building rcar_vin gains a dependency on CONFIG_MEDIA_CONTROLLER, in
>> line with requirements for building the drivers associated with it.
>>
>> Signed-off-by: William Towle <william.towle@codethink.co.uk>
>> Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
>> ---
>>   drivers/media/platform/soc_camera/Kconfig      |    1 +
>>   drivers/media/platform/soc_camera/rcar_vin.c   |    1 +
> 
>     This driver no longer exists. What did you base on?

    Sorry, I didn't realize I was replying to 2 years old patch. :-)

[...]

MBR, Sergei

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

end of thread, other threads:[~2017-10-27  8:56 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-23 12:21 HDMI and Composite capture on Lager, for kernel 4.1, version 5 William Towle
2015-07-23 12:21 ` [PATCH 01/13] ARM: shmobile: lager dts: Add entries for VIN HDMI input support William Towle
2015-07-23 12:21 ` [PATCH 02/13] ARM: shmobile: lager dts: specify default-input for ADV7612 William Towle
2015-07-23 12:21 ` [PATCH 03/13] media: adv7604: fix probe of ADV7611/7612 William Towle
2015-07-24 14:19   ` Hans Verkuil
2015-07-27 12:29     ` William Towle
2015-07-24 14:34   ` [Linux-kernel] " Ben Dooks
2015-07-23 12:21 ` [PATCH 04/13] media: adv7604: reduce support to first (digital) input William Towle
2015-07-24 14:12   ` Hans Verkuil
2015-07-23 12:21 ` [PATCH 05/13] v4l: subdev: Add pad config allocator and init William Towle
2015-07-24 14:12   ` Hans Verkuil
2015-08-11 13:03     ` Mauro Carvalho Chehab
2015-07-23 12:21 ` [PATCH 06/13] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 input support William Towle
2015-07-23 12:21 ` [PATCH 07/13] media: soc_camera pad-aware driver initialisation William Towle
2015-07-24 14:18   ` Hans Verkuil
2015-07-27 12:35     ` William Towle
2017-10-27  8:52   ` Sergei Shtylyov
2017-10-27  8:56     ` Sergei Shtylyov
2015-07-23 12:21 ` [PATCH 08/13] media: rcar_vin: Use correct pad number in try_fmt William Towle
2015-07-24 14:14   ` Hans Verkuil
2015-07-23 12:21 ` [PATCH 09/13] media: soc_camera: soc_scale_crop: " William Towle
2015-07-24 14:14   ` Hans Verkuil
2015-07-23 12:21 ` [PATCH 10/13] media: soc_camera: Fill std field in enum_input William Towle
2015-07-23 12:21 ` [PATCH 11/13] media: soc_camera: Fix error reporting in expbuf William Towle
2015-07-23 12:21 ` [PATCH 12/13] media: rcar_vin: fill in bus_info field William Towle
2015-07-24 14:14   ` Hans Verkuil
2015-07-23 12:21 ` [PATCH 13/13] media: rcar_vin: Reject videobufs that are too small for current format William Towle
2015-07-28  8:03 ` HDMI and Composite capture on Lager, for kernel 4.1, version 5 Guennadi Liakhovetski
2015-07-28  9:20 ` Hans Verkuil

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).