linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Exynos4-is fixes for libv4l exynos4 camera plugin
@ 2016-01-18 16:10 Jacek Anaszewski
  2016-01-18 16:10 ` [PATCH 1/3] s5k6a3: Fix VIDIOC_SUBDEV_G_FMT ioctl for TRY format Jacek Anaszewski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jacek Anaszewski @ 2016-01-18 16:10 UTC (permalink / raw)
  To: linux-media; +Cc: Jacek Anaszewski

This patch set applies some fixes to the Exynos4412-trats2 platform
camera infrastructure. The modifications address issues detected
while testing libv4l plugin for Exynos4 camera with GStreamer.

Jacek Anaszewski (3):
  s5k6a3: Fix VIDIOC_SUBDEV_G_FMT ioctl for TRY format
  exynos4-is: Open shouldn't fail when sensor entity is not linked
  exynos4-is: Wait for 100us before opening sensor

 drivers/media/i2c/s5k6a3.c                    |    3 +-
 drivers/media/platform/exynos4-is/fimc-is.c   |    6 ++
 drivers/media/platform/exynos4-is/media-dev.c |   95 ++++++++++++++++++++-----
 3 files changed, 83 insertions(+), 21 deletions(-)

-- 
1.7.9.5


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

* [PATCH 1/3] s5k6a3: Fix VIDIOC_SUBDEV_G_FMT ioctl for TRY format
  2016-01-18 16:10 [PATCH 0/3] Exynos4-is fixes for libv4l exynos4 camera plugin Jacek Anaszewski
@ 2016-01-18 16:10 ` Jacek Anaszewski
  2016-01-18 16:10 ` [PATCH 2/3] exynos4-is: Open shouldn't fail when sensor entity is not linked Jacek Anaszewski
  2016-01-18 16:10 ` [PATCH 3/3] exynos4-is: Wait for 100us before opening sensor Jacek Anaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Jacek Anaszewski @ 2016-01-18 16:10 UTC (permalink / raw)
  To: linux-media; +Cc: Jacek Anaszewski, Sylwester Nawrocki

VIDIOC_SUBDEV_G_FMT ioctl should return TRY format previously
set with VIDIOC_SUBDEV_S_FMT. Currently it is not the case as
only ACTIVE formats are saved in the driver. Since the driver
doesn't alter hardware state in the set_fmt op anyway, the
op can save the format in both TRY and ACTIVE case.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 drivers/media/i2c/s5k6a3.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index b1b1574..ba74b91 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -144,8 +144,7 @@ static int s5k6a3_set_fmt(struct v4l2_subdev *sd,
 	mf = __s5k6a3_get_format(sensor, cfg, fmt->pad, fmt->which);
 	if (mf) {
 		mutex_lock(&sensor->lock);
-		if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
-			*mf = fmt->format;
+		*mf = fmt->format;
 		mutex_unlock(&sensor->lock);
 	}
 	return 0;
-- 
1.7.9.5


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

* [PATCH 2/3] exynos4-is: Open shouldn't fail when sensor entity is not linked
  2016-01-18 16:10 [PATCH 0/3] Exynos4-is fixes for libv4l exynos4 camera plugin Jacek Anaszewski
  2016-01-18 16:10 ` [PATCH 1/3] s5k6a3: Fix VIDIOC_SUBDEV_G_FMT ioctl for TRY format Jacek Anaszewski
@ 2016-01-18 16:10 ` Jacek Anaszewski
  2016-01-18 16:10 ` [PATCH 3/3] exynos4-is: Wait for 100us before opening sensor Jacek Anaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Jacek Anaszewski @ 2016-01-18 16:10 UTC (permalink / raw)
  To: linux-media; +Cc: Jacek Anaszewski, Sylwester Nawrocki

In order to allow for automatic media device entities linking
from the level of libv4l plugin the open system call shouldn't
fail, as the libv4l plugins can begin their job not until it
succeeds.
This patch allows for leaving the  pipeline not linked on
open and postpones verifying it to the moment when streamon
callback is called.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 drivers/media/platform/exynos4-is/media-dev.c |   95 ++++++++++++++++++++-----
 1 file changed, 76 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 4f5586a..f4d822c 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -187,6 +187,37 @@ error:
 }
 
 /**
+ * __fimc_pipeline_enable - enable power of all pipeline subdevs
+ *			    and the sensor clock
+ * @ep: video pipeline structure
+ * @fmd: fimc media device
+ *
+ * Called with the graph mutex held.
+ */
+static int __fimc_pipeline_enable(struct exynos_media_pipeline *ep,
+				  struct fimc_md *fmd)
+{
+	struct fimc_pipeline *p = to_fimc_pipeline(ep);
+	int ret;
+
+	/* Enable PXLASYNC clock if this pipeline includes FIMC-IS */
+	if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) {
+		ret = clk_prepare_enable(fmd->wbclk[CLK_IDX_WB_B]);
+		if (ret < 0)
+			return ret;
+	}
+
+	ret = fimc_pipeline_s_power(p, 1);
+	if (!ret)
+		return 0;
+
+	if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP])
+		clk_disable_unprepare(fmd->wbclk[CLK_IDX_WB_B]);
+
+	return ret;
+}
+
+/**
  * __fimc_pipeline_open - update the pipeline information, enable power
  *                        of all pipeline subdevs and the sensor clock
  * @me: media entity to start graph walk with
@@ -200,7 +231,6 @@ static int __fimc_pipeline_open(struct exynos_media_pipeline *ep,
 	struct fimc_md *fmd = entity_to_fimc_mdev(me);
 	struct fimc_pipeline *p = to_fimc_pipeline(ep);
 	struct v4l2_subdev *sd;
-	int ret;
 
 	if (WARN_ON(p == NULL || me == NULL))
 		return -EINVAL;
@@ -209,24 +239,16 @@ static int __fimc_pipeline_open(struct exynos_media_pipeline *ep,
 		fimc_pipeline_prepare(p, me);
 
 	sd = p->subdevs[IDX_SENSOR];
-	if (sd == NULL)
-		return -EINVAL;
-
-	/* Disable PXLASYNC clock if this pipeline includes FIMC-IS */
-	if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) {
-		ret = clk_prepare_enable(fmd->wbclk[CLK_IDX_WB_B]);
-		if (ret < 0)
-			return ret;
-	}
-
-	ret = fimc_pipeline_s_power(p, 1);
-	if (!ret)
+	if (sd == NULL) {
+		pr_warn("%s(): No sensor subdev\n", __func__);
+		/*
+		 * Pipeline open cannot fail so as to make it possible
+		 * for the user space to configure the pipeline.
+		 */
 		return 0;
+	}
 
-	if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP])
-		clk_disable_unprepare(fmd->wbclk[CLK_IDX_WB_B]);
-
-	return ret;
+	return __fimc_pipeline_enable(ep, fmd);
 }
 
 /**
@@ -270,10 +292,43 @@ static int __fimc_pipeline_s_stream(struct exynos_media_pipeline *ep, bool on)
 		{ IDX_CSIS, IDX_FLITE, IDX_FIMC, IDX_SENSOR, IDX_IS_ISP },
 	};
 	struct fimc_pipeline *p = to_fimc_pipeline(ep);
+	struct fimc_md *fmd = entity_to_fimc_mdev(&p->subdevs[IDX_CSIS]->entity);
+	enum fimc_subdev_index sd_id;
 	int i, ret = 0;
 
-	if (p->subdevs[IDX_SENSOR] == NULL)
-		return -ENODEV;
+	if (p->subdevs[IDX_SENSOR] == NULL) {
+		if (!fmd->user_subdev_api) {
+			/*
+			 * Sensor must be already discovered if we
+			 * aren't in the user_subdev_api mode
+			 */
+			return -ENODEV;
+		}
+
+		/* Get pipeline sink entity */
+		if (p->subdevs[IDX_FIMC])
+			sd_id = IDX_FIMC;
+		else if (p->subdevs[IDX_IS_ISP])
+			sd_id = IDX_IS_ISP;
+		else if (p->subdevs[IDX_FLITE])
+			sd_id = IDX_FLITE;
+		else
+			return -ENODEV;
+
+		/*
+		 * Sensor could have been linked between open and STREAMON -
+		 * check if this is the case.
+		 */
+		fimc_pipeline_prepare(p, &p->subdevs[sd_id]->entity);
+
+		if (p->subdevs[IDX_SENSOR] == NULL)
+			return -ENODEV;
+
+		ret = __fimc_pipeline_enable(ep, fmd);
+		if (ret < 0)
+			return ret;
+
+	}
 
 	for (i = 0; i < IDX_MAX; i++) {
 		unsigned int idx = seq[on][i];
@@ -283,8 +338,10 @@ static int __fimc_pipeline_s_stream(struct exynos_media_pipeline *ep, bool on)
 		if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV)
 			goto error;
 	}
+
 	return 0;
 error:
+	fimc_pipeline_s_power(p, !on);
 	for (; i >= 0; i--) {
 		unsigned int idx = seq[on][i];
 		v4l2_subdev_call(p->subdevs[idx], video, s_stream, !on);
-- 
1.7.9.5


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

* [PATCH 3/3] exynos4-is: Wait for 100us before opening sensor
  2016-01-18 16:10 [PATCH 0/3] Exynos4-is fixes for libv4l exynos4 camera plugin Jacek Anaszewski
  2016-01-18 16:10 ` [PATCH 1/3] s5k6a3: Fix VIDIOC_SUBDEV_G_FMT ioctl for TRY format Jacek Anaszewski
  2016-01-18 16:10 ` [PATCH 2/3] exynos4-is: Open shouldn't fail when sensor entity is not linked Jacek Anaszewski
@ 2016-01-18 16:10 ` Jacek Anaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Jacek Anaszewski @ 2016-01-18 16:10 UTC (permalink / raw)
  To: linux-media; +Cc: Jacek Anaszewski, Sylwester Nawrocki

Some user space use cases result in kernel hangup on the HIC_OPEN_SENSOR
command write. In case when a minimalistic application is used for setting
up the streaming, the hangups occur only occasionally. In case of GStreamer
use cases it is always the case.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
 drivers/media/platform/exynos4-is/fimc-is.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 123772f..3f50856 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -631,6 +631,12 @@ static int fimc_is_hw_open_sensor(struct fimc_is *is,
 
 	fimc_is_mem_barrier();
 
+	/*
+	 * Some user space use cases hang up here without this
+	 * empirically chosen delay.
+	 */
+	udelay(100);
+
 	mcuctl_write(HIC_OPEN_SENSOR, is, MCUCTL_REG_ISSR(0));
 	mcuctl_write(is->sensor_index, is, MCUCTL_REG_ISSR(1));
 	mcuctl_write(sensor->drvdata->id, is, MCUCTL_REG_ISSR(2));
-- 
1.7.9.5


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

end of thread, other threads:[~2016-01-18 16:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18 16:10 [PATCH 0/3] Exynos4-is fixes for libv4l exynos4 camera plugin Jacek Anaszewski
2016-01-18 16:10 ` [PATCH 1/3] s5k6a3: Fix VIDIOC_SUBDEV_G_FMT ioctl for TRY format Jacek Anaszewski
2016-01-18 16:10 ` [PATCH 2/3] exynos4-is: Open shouldn't fail when sensor entity is not linked Jacek Anaszewski
2016-01-18 16:10 ` [PATCH 3/3] exynos4-is: Wait for 100us before opening sensor Jacek Anaszewski

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