Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH 00/18] marvell-ccic + ov7670 fixes
@ 2015-03-09 21:22 Hans Verkuil
  2015-03-09 21:22 ` [PATCH 01/18] marvell-ccic: fix vb2 warning Hans Verkuil
                   ` (18 more replies)
  0 siblings, 19 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet

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

This patch series makes loads of fixes and improvements to the marvell-ccic
and ov7670 drivers. This has been tested on an OLPC XO-1 laptop.

This patch series sits on top of this pull request:

https://patchwork.linuxtv.org/patch/28532/

I do need to check the last patch with Libin Yang since his patch from mid-2013
broke the driver for the OLPC laptop. Nobody noticed since the latest released
kernel from the OLPC project for that laptop is 3.3, which didn't have his patch.

This driver now passes the v4l2-compliance test-suite, so that's very nice.

Regards,

	Hans

Hans Verkuil (18):
  marvell-ccic: fix vb2 warning
  marvell-ccic: fill in bus_info
  marvell-ccic: webcam drivers shouldn't support g/s_std
  ov7670: check for valid width/height in ov7670_enum_frame_interval
  marvell-ccic: fill in colorspace
  marvell-ccic: control handler fixes
  marvell-ccic: switch to struct v4l2_fh
  marvell-ccic: implement control events
  marvell-ccic: use vb2 helpers and core locking
  marvell-ccic: add create_bufs support
  marvell-ccic: add DMABUF support for all three DMA modes
  marvell-ccic: fix streaming issues
  marvell-ccic: correctly requeue buffers
  marvell-ccic: add planar support to dma-vmalloc
  marvell-ccic: drop V4L2_PIX_FMT_JPEG dead code
  ov7670: use colorspace SRGB instead of JPEG
  marvell-ccic: fix the bytesperline and sizeimage calculations
  marvell-ccic: fix Y'CbCr ordering

 drivers/media/i2c/ov7670.c                        |  25 +-
 drivers/media/platform/marvell-ccic/cafe-driver.c |   1 +
 drivers/media/platform/marvell-ccic/mcam-core.c   | 461 ++++++++--------------
 drivers/media/platform/marvell-ccic/mcam-core.h   |  11 +-
 drivers/media/platform/marvell-ccic/mmp-driver.c  |   1 +
 5 files changed, 207 insertions(+), 292 deletions(-)

-- 
2.1.4


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

* [PATCH 01/18] marvell-ccic: fix vb2 warning
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 02/18] marvell-ccic: fill in bus_info Hans Verkuil
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

We must set timestamp_flags in vb2_queue otherwise vb2 will complain
loudly about it.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 9c64b5d..bf160dd 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1246,6 +1246,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
 	vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 	vq->drv_priv = cam;
 	vq->lock = &cam->s_mutex;
+	vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 	INIT_LIST_HEAD(&cam->buffers);
 	switch (cam->buffer_mode) {
 	case B_DMA_contig:
-- 
2.1.4


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

* [PATCH 02/18] marvell-ccic: fill in bus_info
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
  2015-03-09 21:22 ` [PATCH 01/18] marvell-ccic: fix vb2 warning Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 03/18] marvell-ccic: webcam drivers shouldn't support g/s_std Hans Verkuil
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

The bus_info field of struct v4l2_querycap wasn't filled in and
v4l2-compliance complained about that. Fix this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/cafe-driver.c | 1 +
 drivers/media/platform/marvell-ccic/mcam-core.c   | 3 +++
 drivers/media/platform/marvell-ccic/mcam-core.h   | 2 ++
 drivers/media/platform/marvell-ccic/mmp-driver.c  | 1 +
 4 files changed, 7 insertions(+)

diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c b/drivers/media/platform/marvell-ccic/cafe-driver.c
index 5628453..e857405 100644
--- a/drivers/media/platform/marvell-ccic/cafe-driver.c
+++ b/drivers/media/platform/marvell-ccic/cafe-driver.c
@@ -476,6 +476,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
 	mcam->plat_power_up = cafe_ctlr_power_up;
 	mcam->plat_power_down = cafe_ctlr_power_down;
 	mcam->dev = &pdev->dev;
+	snprintf(mcam->bus_info, sizeof(mcam->bus_info), "PCI:%s", pci_name(pdev));
 	/*
 	 * Set the clock speed for the XO 1; I don't believe this
 	 * driver has ever run anywhere else.
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index bf160dd..e83ca1f 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1388,8 +1388,11 @@ static int mcam_vidioc_dqbuf(struct file *filp, void *priv,
 static int mcam_vidioc_querycap(struct file *file, void *priv,
 		struct v4l2_capability *cap)
 {
+	struct mcam_camera *cam = priv;
+
 	strcpy(cap->driver, "marvell_ccic");
 	strcpy(cap->card, "marvell_ccic");
+	strlcpy(cap->bus_info, cam->bus_info, sizeof(cap->bus_info));
 	cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
 		V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
 	cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h b/drivers/media/platform/marvell-ccic/mcam-core.h
index aa0c6ea..46bc715 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -163,6 +163,8 @@ struct mcam_camera {
 	unsigned int nbufs;		/* How many are alloc'd */
 	int next_buf;			/* Next to consume (dev_lock) */
 
+	char bus_info[32];		/* querycap bus_info */
+
 	/* DMA buffers - vmalloc mode */
 #ifdef MCAM_MODE_VMALLOC
 	unsigned int dma_buf_size;	/* allocated size */
diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c b/drivers/media/platform/marvell-ccic/mmp-driver.c
index 0ed9b3a..b5f165a 100644
--- a/drivers/media/platform/marvell-ccic/mmp-driver.c
+++ b/drivers/media/platform/marvell-ccic/mmp-driver.c
@@ -371,6 +371,7 @@ static int mmpcam_probe(struct platform_device *pdev)
 	mcam->lane = pdata->lane;
 	mcam->chip_id = MCAM_ARMADA610;
 	mcam->buffer_mode = B_DMA_sg;
+	strlcpy(mcam->bus_info, "platform:mmp-camera", sizeof(mcam->bus_info));
 	spin_lock_init(&mcam->dev_lock);
 	/*
 	 * Get our I/O memory.
-- 
2.1.4


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

* [PATCH 03/18] marvell-ccic: webcam drivers shouldn't support g/s_std
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
  2015-03-09 21:22 ` [PATCH 01/18] marvell-ccic: fix vb2 warning Hans Verkuil
  2015-03-09 21:22 ` [PATCH 02/18] marvell-ccic: fill in bus_info Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 04/18] ov7670: check for valid width/height in ov7670_enum_frame_interval Hans Verkuil
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

TV standards make no sense for webcam drivers, so drop these dummy
functions. This stops v4l2-compliance from complaining about this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index e83ca1f..76357cf 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1508,7 +1508,6 @@ static int mcam_vidioc_enum_input(struct file *filp, void *priv,
 		return -EINVAL;
 
 	input->type = V4L2_INPUT_TYPE_CAMERA;
-	input->std = V4L2_STD_ALL; /* Not sure what should go here */
 	strcpy(input->name, "Camera");
 	return 0;
 }
@@ -1526,18 +1525,6 @@ static int mcam_vidioc_s_input(struct file *filp, void *priv, unsigned int i)
 	return 0;
 }
 
-/* from vivi.c */
-static int mcam_vidioc_s_std(struct file *filp, void *priv, v4l2_std_id a)
-{
-	return 0;
-}
-
-static int mcam_vidioc_g_std(struct file *filp, void *priv, v4l2_std_id *a)
-{
-	*a = V4L2_STD_NTSC_M;
-	return 0;
-}
-
 /*
  * G/S_PARM.  Most of this is done by the sensor, but we are
  * the level which controls the number of read buffers.
@@ -1666,8 +1653,6 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
 	.vidioc_enum_input	= mcam_vidioc_enum_input,
 	.vidioc_g_input		= mcam_vidioc_g_input,
 	.vidioc_s_input		= mcam_vidioc_s_input,
-	.vidioc_s_std		= mcam_vidioc_s_std,
-	.vidioc_g_std		= mcam_vidioc_g_std,
 	.vidioc_reqbufs		= mcam_vidioc_reqbufs,
 	.vidioc_querybuf	= mcam_vidioc_querybuf,
 	.vidioc_qbuf		= mcam_vidioc_qbuf,
-- 
2.1.4


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

* [PATCH 04/18] ov7670: check for valid width/height in ov7670_enum_frame_interval
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (2 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 03/18] marvell-ccic: webcam drivers shouldn't support g/s_std Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 05/18] marvell-ccic: fill in colorspace Hans Verkuil
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

The width and height should be checked in the enum_frame_interval
op. This fixes a v4l2-compliance failure.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/ov7670.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index b984752..81a1e44 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -1073,10 +1073,33 @@ static int ov7670_enum_frame_interval(struct v4l2_subdev *sd,
 				      struct v4l2_subdev_pad_config *cfg,
 				      struct v4l2_subdev_frame_interval_enum *fie)
 {
+	struct ov7670_info *info = to_state(sd);
+	unsigned int n_win_sizes = info->devtype->n_win_sizes;
+	int i;
+
 	if (fie->pad)
 		return -EINVAL;
 	if (fie->index >= ARRAY_SIZE(ov7670_frame_rates))
 		return -EINVAL;
+
+	/*
+	 * Check if the width/height is valid.
+	 *
+	 * If a minimum width/height was requested, filter out the capture
+	 * windows that fall outside that.
+	 */
+	for (i = 0; i < n_win_sizes; i++) {
+		struct ov7670_win_size *win = &info->devtype->win_sizes[i];
+
+		if (info->min_width && win->width < info->min_width)
+			continue;
+		if (info->min_height && win->height < info->min_height)
+			continue;
+		if (fie->width == win->width && fie->height == win->height)
+			break;
+	}
+	if (i == n_win_sizes)
+		return -EINVAL;
 	fie->interval.numerator = 1;
 	fie->interval.denominator = ov7670_frame_rates[fie->index];
 	return 0;
-- 
2.1.4


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

* [PATCH 05/18] marvell-ccic: fill in colorspace
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (3 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 04/18] ov7670: check for valid width/height in ov7670_enum_frame_interval Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 06/18] marvell-ccic: control handler fixes Hans Verkuil
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

The colorspace field wasn't filled in properly. This fixes a v4l2-compliance
failure.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 76357cf..7e54cef 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -188,6 +188,7 @@ static const struct v4l2_pix_format mcam_def_pix_format = {
 	.field		= V4L2_FIELD_NONE,
 	.bytesperline	= VGA_WIDTH*2,
 	.sizeimage	= VGA_WIDTH*VGA_HEIGHT*2,
+	.colorspace	= V4L2_COLORSPACE_SRGB,
 };
 
 static const u32 mcam_def_mbus_code = MEDIA_BUS_FMT_YUYV8_2X8;
@@ -1437,6 +1438,7 @@ static int mcam_vidioc_try_fmt_vid_cap(struct file *filp, void *priv,
 		break;
 	}
 	pix->sizeimage = pix->height * pix->bytesperline;
+	pix->colorspace = V4L2_COLORSPACE_SRGB;
 	return ret;
 }
 
-- 
2.1.4


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

* [PATCH 06/18] marvell-ccic: control handler fixes
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (4 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 05/18] marvell-ccic: fill in colorspace Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 07/18] marvell-ccic: switch to struct v4l2_fh Hans Verkuil
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

No controls were reported, even though the ov7670 does have controls.

Two reasons for this: the v4l2_ctrl_handler_init() call must come
before the ov7670 is loaded (otherwise the ov7670 won't know that
its controls should be added to the bridge driver), and the
v4l2_ctrl_handler_free() call at the end should only be called if
the ret value is non-zero (otherwise you would just free all the
controls that were just added).

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 7e54cef..51c9c8c 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1919,6 +1919,14 @@ int mccic_register(struct mcam_camera *cam)
 	mcam_ctlr_init(cam);
 
 	/*
+	 * Get the v4l2 setup done.
+	 */
+	ret = v4l2_ctrl_handler_init(&cam->ctrl_handler, 10);
+	if (ret)
+		goto out_unregister;
+	cam->v4l2_dev.ctrl_handler = &cam->ctrl_handler;
+
+	/*
 	 * Try to find the sensor.
 	 */
 	sensor_cfg.clock_speed = cam->clock_speed;
@@ -1934,13 +1942,6 @@ int mccic_register(struct mcam_camera *cam)
 	ret = mcam_cam_init(cam);
 	if (ret)
 		goto out_unregister;
-	/*
-	 * Get the v4l2 setup done.
-	 */
-	ret = v4l2_ctrl_handler_init(&cam->ctrl_handler, 10);
-	if (ret)
-		goto out_unregister;
-	cam->v4l2_dev.ctrl_handler = &cam->ctrl_handler;
 
 	mutex_lock(&cam->s_mutex);
 	cam->vdev = mcam_v4l_template;
@@ -1960,10 +1961,12 @@ int mccic_register(struct mcam_camera *cam)
 	}
 
 out:
-	v4l2_ctrl_handler_free(&cam->ctrl_handler);
+	if (ret)
+		v4l2_ctrl_handler_free(&cam->ctrl_handler);
 	mutex_unlock(&cam->s_mutex);
 	return ret;
 out_unregister:
+	v4l2_ctrl_handler_free(&cam->ctrl_handler);
 	v4l2_device_unregister(&cam->v4l2_dev);
 	return ret;
 }
-- 
2.1.4


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

* [PATCH 07/18] marvell-ccic: switch to struct v4l2_fh
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (5 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 06/18] marvell-ccic: control handler fixes Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 08/18] marvell-ccic: implement control events Hans Verkuil
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

Use struct v4l2_fh to represent a filehandle. This fixes the missing
g/s_priority handling of this driver that v4l2-compliance complained
about.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 48 +++++++++++++------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 51c9c8c..8456017 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1314,7 +1314,7 @@ static void mcam_cleanup_vb2(struct mcam_camera *cam)
 static int mcam_vidioc_streamon(struct file *filp, void *priv,
 		enum v4l2_buf_type type)
 {
-	struct mcam_camera *cam = filp->private_data;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
@@ -1327,7 +1327,7 @@ static int mcam_vidioc_streamon(struct file *filp, void *priv,
 static int mcam_vidioc_streamoff(struct file *filp, void *priv,
 		enum v4l2_buf_type type)
 {
-	struct mcam_camera *cam = filp->private_data;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
@@ -1340,7 +1340,7 @@ static int mcam_vidioc_streamoff(struct file *filp, void *priv,
 static int mcam_vidioc_reqbufs(struct file *filp, void *priv,
 		struct v4l2_requestbuffers *req)
 {
-	struct mcam_camera *cam = filp->private_data;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
@@ -1353,7 +1353,7 @@ static int mcam_vidioc_reqbufs(struct file *filp, void *priv,
 static int mcam_vidioc_querybuf(struct file *filp, void *priv,
 		struct v4l2_buffer *buf)
 {
-	struct mcam_camera *cam = filp->private_data;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
@@ -1365,7 +1365,7 @@ static int mcam_vidioc_querybuf(struct file *filp, void *priv,
 static int mcam_vidioc_qbuf(struct file *filp, void *priv,
 		struct v4l2_buffer *buf)
 {
-	struct mcam_camera *cam = filp->private_data;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
@@ -1377,7 +1377,7 @@ static int mcam_vidioc_qbuf(struct file *filp, void *priv,
 static int mcam_vidioc_dqbuf(struct file *filp, void *priv,
 		struct v4l2_buffer *buf)
 {
-	struct mcam_camera *cam = filp->private_data;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
@@ -1389,7 +1389,7 @@ static int mcam_vidioc_dqbuf(struct file *filp, void *priv,
 static int mcam_vidioc_querycap(struct file *file, void *priv,
 		struct v4l2_capability *cap)
 {
-	struct mcam_camera *cam = priv;
+	struct mcam_camera *cam = video_drvdata(file);
 
 	strcpy(cap->driver, "marvell_ccic");
 	strcpy(cap->card, "marvell_ccic");
@@ -1415,7 +1415,7 @@ static int mcam_vidioc_enum_fmt_vid_cap(struct file *filp,
 static int mcam_vidioc_try_fmt_vid_cap(struct file *filp, void *priv,
 		struct v4l2_format *fmt)
 {
-	struct mcam_camera *cam = priv;
+	struct mcam_camera *cam = video_drvdata(filp);
 	struct mcam_format_struct *f;
 	struct v4l2_pix_format *pix = &fmt->fmt.pix;
 	struct v4l2_mbus_framefmt mbus_fmt;
@@ -1445,7 +1445,7 @@ static int mcam_vidioc_try_fmt_vid_cap(struct file *filp, void *priv,
 static int mcam_vidioc_s_fmt_vid_cap(struct file *filp, void *priv,
 		struct v4l2_format *fmt)
 {
-	struct mcam_camera *cam = priv;
+	struct mcam_camera *cam = video_drvdata(filp);
 	struct mcam_format_struct *f;
 	int ret;
 
@@ -1494,7 +1494,7 @@ out:
 static int mcam_vidioc_g_fmt_vid_cap(struct file *filp, void *priv,
 		struct v4l2_format *f)
 {
-	struct mcam_camera *cam = priv;
+	struct mcam_camera *cam = video_drvdata(filp);
 
 	f->fmt.pix = cam->pix_format;
 	return 0;
@@ -1534,7 +1534,7 @@ static int mcam_vidioc_s_input(struct file *filp, void *priv, unsigned int i)
 static int mcam_vidioc_g_parm(struct file *filp, void *priv,
 		struct v4l2_streamparm *parms)
 {
-	struct mcam_camera *cam = priv;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
@@ -1547,7 +1547,7 @@ static int mcam_vidioc_g_parm(struct file *filp, void *priv,
 static int mcam_vidioc_s_parm(struct file *filp, void *priv,
 		struct v4l2_streamparm *parms)
 {
-	struct mcam_camera *cam = priv;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
@@ -1560,7 +1560,7 @@ static int mcam_vidioc_s_parm(struct file *filp, void *priv,
 static int mcam_vidioc_enum_framesizes(struct file *filp, void *priv,
 		struct v4l2_frmsizeenum *sizes)
 {
-	struct mcam_camera *cam = priv;
+	struct mcam_camera *cam = video_drvdata(filp);
 	struct mcam_format_struct *f;
 	struct v4l2_subdev_frame_size_enum fse = {
 		.index = sizes->index,
@@ -1597,7 +1597,7 @@ static int mcam_vidioc_enum_framesizes(struct file *filp, void *priv,
 static int mcam_vidioc_enum_frameintervals(struct file *filp, void *priv,
 		struct v4l2_frmivalenum *interval)
 {
-	struct mcam_camera *cam = priv;
+	struct mcam_camera *cam = video_drvdata(filp);
 	struct mcam_format_struct *f;
 	struct v4l2_subdev_frame_interval_enum fie = {
 		.index = interval->index,
@@ -1625,7 +1625,7 @@ static int mcam_vidioc_enum_frameintervals(struct file *filp, void *priv,
 static int mcam_vidioc_g_register(struct file *file, void *priv,
 		struct v4l2_dbg_register *reg)
 {
-	struct mcam_camera *cam = priv;
+	struct mcam_camera *cam = video_drvdata(file);
 
 	if (reg->reg > cam->regs_size - 4)
 		return -EINVAL;
@@ -1637,7 +1637,7 @@ static int mcam_vidioc_g_register(struct file *file, void *priv,
 static int mcam_vidioc_s_register(struct file *file, void *priv,
 		const struct v4l2_dbg_register *reg)
 {
-	struct mcam_camera *cam = priv;
+	struct mcam_camera *cam = video_drvdata(file);
 
 	if (reg->reg > cam->regs_size - 4)
 		return -EINVAL;
@@ -1678,9 +1678,10 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
 static int mcam_v4l_open(struct file *filp)
 {
 	struct mcam_camera *cam = video_drvdata(filp);
-	int ret = 0;
+	int ret = v4l2_fh_open(filp);
 
-	filp->private_data = cam;
+	if (ret)
+		return ret;
 
 	cam->frame_state.frames = 0;
 	cam->frame_state.singles = 0;
@@ -1699,13 +1700,15 @@ static int mcam_v4l_open(struct file *filp)
 	(cam->users)++;
 out:
 	mutex_unlock(&cam->s_mutex);
+	if (ret)
+		v4l2_fh_release(filp);
 	return ret;
 }
 
 
 static int mcam_v4l_release(struct file *filp)
 {
-	struct mcam_camera *cam = filp->private_data;
+	struct mcam_camera *cam = video_drvdata(filp);
 
 	cam_dbg(cam, "Release, %d frames, %d singles, %d delivered\n",
 			cam->frame_state.frames, cam->frame_state.singles,
@@ -1722,13 +1725,14 @@ static int mcam_v4l_release(struct file *filp)
 	}
 
 	mutex_unlock(&cam->s_mutex);
+	v4l2_fh_release(filp);
 	return 0;
 }
 
 static ssize_t mcam_v4l_read(struct file *filp,
 		char __user *buffer, size_t len, loff_t *pos)
 {
-	struct mcam_camera *cam = filp->private_data;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
@@ -1743,7 +1747,7 @@ static ssize_t mcam_v4l_read(struct file *filp,
 static unsigned int mcam_v4l_poll(struct file *filp,
 		struct poll_table_struct *pt)
 {
-	struct mcam_camera *cam = filp->private_data;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
@@ -1755,7 +1759,7 @@ static unsigned int mcam_v4l_poll(struct file *filp,
 
 static int mcam_v4l_mmap(struct file *filp, struct vm_area_struct *vma)
 {
-	struct mcam_camera *cam = filp->private_data;
+	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
 	mutex_lock(&cam->s_mutex);
-- 
2.1.4


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

* [PATCH 08/18] marvell-ccic: implement control events
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (6 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 07/18] marvell-ccic: switch to struct v4l2_fh Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 09/18] marvell-ccic: use vb2 helpers and core locking Hans Verkuil
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

Now that this driver uses v4l2_fh, it is trivial to add support for
control events. Again, this fixes a v4l2-compliance failure.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 8456017..4d50182 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -24,6 +24,7 @@
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-ctrls.h>
+#include <media/v4l2-event.h>
 #include <media/ov7670.h>
 #include <media/videobuf2-vmalloc.h>
 #include <media/videobuf2-dma-contig.h>
@@ -1665,6 +1666,8 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
 	.vidioc_s_parm		= mcam_vidioc_s_parm,
 	.vidioc_enum_framesizes = mcam_vidioc_enum_framesizes,
 	.vidioc_enum_frameintervals = mcam_vidioc_enum_frameintervals,
+	.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
+	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
 	.vidioc_g_register	= mcam_vidioc_g_register,
 	.vidioc_s_register	= mcam_vidioc_s_register,
-- 
2.1.4


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

* [PATCH 09/18] marvell-ccic: use vb2 helpers and core locking
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (7 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 08/18] marvell-ccic: implement control events Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 10/18] marvell-ccic: add create_bufs support Hans Verkuil
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

Use the V4L2 core locking system instead of rolling your own. Switch to
the vb2 fop and ioctl helpers to get rid of a lot of code. This also made
it easy to add VB2_READ to the DMA modes, since you get read() for free
with vb2 and these helpers.

Finally remove the users field: this information is also available from
the core framework, no need to keep track of it in the driver.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 218 +++++-------------------
 drivers/media/platform/marvell-ccic/mcam-core.h |   1 -
 2 files changed, 43 insertions(+), 176 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 4d50182..b6b838f 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -971,7 +971,6 @@ static int mcam_cam_init(struct mcam_camera *cam)
 {
 	int ret;
 
-	mutex_lock(&cam->s_mutex);
 	if (cam->state != S_NOTREADY)
 		cam_warn(cam, "Cam init with device in funky state %d",
 				cam->state);
@@ -979,7 +978,6 @@ static int mcam_cam_init(struct mcam_camera *cam)
 	/* Get/set parameters? */
 	cam->state = S_IDLE;
 	mcam_ctlr_power_down(cam);
-	mutex_unlock(&cam->s_mutex);
 	return ret;
 }
 
@@ -1116,6 +1114,9 @@ static int mcam_vb_start_streaming(struct vb2_queue *vq, unsigned int count)
 		INIT_LIST_HEAD(&cam->buffers);
 		return -EINVAL;
 	}
+	cam->frame_state.frames = 0;
+	cam->frame_state.singles = 0;
+	cam->frame_state.delivered = 0;
 	cam->sequence = 0;
 	/*
 	 * Videobuf2 sneakily hoards all the buffers and won't
@@ -1144,6 +1145,9 @@ static void mcam_vb_stop_streaming(struct vb2_queue *vq)
 	struct mcam_camera *cam = vb2_get_drv_priv(vq);
 	unsigned long flags;
 
+	cam_dbg(cam, "stop_streaming: %d frames, %d singles, %d delivered\n",
+			cam->frame_state.frames, cam->frame_state.singles,
+			cam->frame_state.delivered);
 	if (cam->state == S_BUFWAIT) {
 		/* They never gave us buffers */
 		cam->state = S_IDLE;
@@ -1256,7 +1260,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
 		vq->ops = &mcam_vb2_ops;
 		vq->mem_ops = &vb2_dma_contig_memops;
 		vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-		vq->io_modes = VB2_MMAP | VB2_USERPTR;
+		vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
 		cam->dma_setup = mcam_ctlr_dma_contig;
 		cam->frame_complete = mcam_dma_contig_done;
 		cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev);
@@ -1269,7 +1273,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
 		vq->ops = &mcam_vb2_sg_ops;
 		vq->mem_ops = &vb2_dma_sg_memops;
 		vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-		vq->io_modes = VB2_MMAP | VB2_USERPTR;
+		vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
 		cam->dma_setup = mcam_ctlr_dma_sg;
 		cam->frame_complete = mcam_dma_sg_done;
 		cam->vb_alloc_ctx_sg = vb2_dma_sg_init_ctx(cam->dev);
@@ -1284,7 +1288,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
 		vq->ops = &mcam_vb2_ops;
 		vq->mem_ops = &vb2_vmalloc_memops;
 		vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-		vq->io_modes = VB2_MMAP;
+		vq->io_modes = VB2_MMAP | VB2_READ;
 		cam->dma_setup = mcam_ctlr_dma_vmalloc;
 		cam->frame_complete = mcam_vmalloc_done;
 #endif
@@ -1295,7 +1299,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
 
 static void mcam_cleanup_vb2(struct mcam_camera *cam)
 {
-	vb2_queue_release(&cam->vb_queue);
 #ifdef MCAM_MODE_DMA_CONTIG
 	if (cam->buffer_mode == B_DMA_contig)
 		vb2_dma_contig_cleanup_ctx(cam->vb_alloc_ctx);
@@ -1312,81 +1315,6 @@ static void mcam_cleanup_vb2(struct mcam_camera *cam)
  * The long list of V4L2 ioctl() operations.
  */
 
-static int mcam_vidioc_streamon(struct file *filp, void *priv,
-		enum v4l2_buf_type type)
-{
-	struct mcam_camera *cam = video_drvdata(filp);
-	int ret;
-
-	mutex_lock(&cam->s_mutex);
-	ret = vb2_streamon(&cam->vb_queue, type);
-	mutex_unlock(&cam->s_mutex);
-	return ret;
-}
-
-
-static int mcam_vidioc_streamoff(struct file *filp, void *priv,
-		enum v4l2_buf_type type)
-{
-	struct mcam_camera *cam = video_drvdata(filp);
-	int ret;
-
-	mutex_lock(&cam->s_mutex);
-	ret = vb2_streamoff(&cam->vb_queue, type);
-	mutex_unlock(&cam->s_mutex);
-	return ret;
-}
-
-
-static int mcam_vidioc_reqbufs(struct file *filp, void *priv,
-		struct v4l2_requestbuffers *req)
-{
-	struct mcam_camera *cam = video_drvdata(filp);
-	int ret;
-
-	mutex_lock(&cam->s_mutex);
-	ret = vb2_reqbufs(&cam->vb_queue, req);
-	mutex_unlock(&cam->s_mutex);
-	return ret;
-}
-
-
-static int mcam_vidioc_querybuf(struct file *filp, void *priv,
-		struct v4l2_buffer *buf)
-{
-	struct mcam_camera *cam = video_drvdata(filp);
-	int ret;
-
-	mutex_lock(&cam->s_mutex);
-	ret = vb2_querybuf(&cam->vb_queue, buf);
-	mutex_unlock(&cam->s_mutex);
-	return ret;
-}
-
-static int mcam_vidioc_qbuf(struct file *filp, void *priv,
-		struct v4l2_buffer *buf)
-{
-	struct mcam_camera *cam = video_drvdata(filp);
-	int ret;
-
-	mutex_lock(&cam->s_mutex);
-	ret = vb2_qbuf(&cam->vb_queue, buf);
-	mutex_unlock(&cam->s_mutex);
-	return ret;
-}
-
-static int mcam_vidioc_dqbuf(struct file *filp, void *priv,
-		struct v4l2_buffer *buf)
-{
-	struct mcam_camera *cam = video_drvdata(filp);
-	int ret;
-
-	mutex_lock(&cam->s_mutex);
-	ret = vb2_dqbuf(&cam->vb_queue, buf, filp->f_flags & O_NONBLOCK);
-	mutex_unlock(&cam->s_mutex);
-	return ret;
-}
-
 static int mcam_vidioc_querycap(struct file *file, void *priv,
 		struct v4l2_capability *cap)
 {
@@ -1425,9 +1353,7 @@ static int mcam_vidioc_try_fmt_vid_cap(struct file *filp, void *priv,
 	f = mcam_find_format(pix->pixelformat);
 	pix->pixelformat = f->pixelformat;
 	v4l2_fill_mbus_format(&mbus_fmt, pix, f->mbus_code);
-	mutex_lock(&cam->s_mutex);
 	ret = sensor_call(cam, video, try_mbus_fmt, &mbus_fmt);
-	mutex_unlock(&cam->s_mutex);
 	v4l2_fill_pix_format(pix, &mbus_fmt);
 	switch (f->pixelformat) {
 	case V4L2_PIX_FMT_YUV420:
@@ -1469,7 +1395,6 @@ static int mcam_vidioc_s_fmt_vid_cap(struct file *filp, void *priv,
 	 * Now we start to change things for real, so let's do it
 	 * under lock.
 	 */
-	mutex_lock(&cam->s_mutex);
 	cam->pix_format = fmt->fmt.pix;
 	cam->mbus_code = f->mbus_code;
 
@@ -1483,7 +1408,6 @@ static int mcam_vidioc_s_fmt_vid_cap(struct file *filp, void *priv,
 	}
 	mcam_set_config_needed(cam, 1);
 out:
-	mutex_unlock(&cam->s_mutex);
 	return ret;
 }
 
@@ -1538,9 +1462,7 @@ static int mcam_vidioc_g_parm(struct file *filp, void *priv,
 	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
-	mutex_lock(&cam->s_mutex);
 	ret = sensor_call(cam, video, g_parm, parms);
-	mutex_unlock(&cam->s_mutex);
 	parms->parm.capture.readbuffers = n_dma_bufs;
 	return ret;
 }
@@ -1551,9 +1473,7 @@ static int mcam_vidioc_s_parm(struct file *filp, void *priv,
 	struct mcam_camera *cam = video_drvdata(filp);
 	int ret;
 
-	mutex_lock(&cam->s_mutex);
 	ret = sensor_call(cam, video, s_parm, parms);
-	mutex_unlock(&cam->s_mutex);
 	parms->parm.capture.readbuffers = n_dma_bufs;
 	return ret;
 }
@@ -1573,9 +1493,7 @@ static int mcam_vidioc_enum_framesizes(struct file *filp, void *priv,
 	if (f->pixelformat != sizes->pixel_format)
 		return -EINVAL;
 	fse.code = f->mbus_code;
-	mutex_lock(&cam->s_mutex);
 	ret = sensor_call(cam, pad, enum_frame_size, NULL, &fse);
-	mutex_unlock(&cam->s_mutex);
 	if (ret)
 		return ret;
 	if (fse.min_width == fse.max_width &&
@@ -1612,9 +1530,7 @@ static int mcam_vidioc_enum_frameintervals(struct file *filp, void *priv,
 	if (f->pixelformat != interval->pixel_format)
 		return -EINVAL;
 	fie.code = f->mbus_code;
-	mutex_lock(&cam->s_mutex);
 	ret = sensor_call(cam, pad, enum_frame_interval, NULL, &fie);
-	mutex_unlock(&cam->s_mutex);
 	if (ret)
 		return ret;
 	interval->type = V4L2_FRMIVAL_TYPE_DISCRETE;
@@ -1656,12 +1572,12 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
 	.vidioc_enum_input	= mcam_vidioc_enum_input,
 	.vidioc_g_input		= mcam_vidioc_g_input,
 	.vidioc_s_input		= mcam_vidioc_s_input,
-	.vidioc_reqbufs		= mcam_vidioc_reqbufs,
-	.vidioc_querybuf	= mcam_vidioc_querybuf,
-	.vidioc_qbuf		= mcam_vidioc_qbuf,
-	.vidioc_dqbuf		= mcam_vidioc_dqbuf,
-	.vidioc_streamon	= mcam_vidioc_streamon,
-	.vidioc_streamoff	= mcam_vidioc_streamoff,
+	.vidioc_reqbufs		= vb2_ioctl_reqbufs,
+	.vidioc_querybuf	= vb2_ioctl_querybuf,
+	.vidioc_qbuf		= vb2_ioctl_qbuf,
+	.vidioc_dqbuf		= vb2_ioctl_dqbuf,
+	.vidioc_streamon	= vb2_ioctl_streamon,
+	.vidioc_streamoff	= vb2_ioctl_streamoff,
 	.vidioc_g_parm		= mcam_vidioc_g_parm,
 	.vidioc_s_parm		= mcam_vidioc_s_parm,
 	.vidioc_enum_framesizes = mcam_vidioc_enum_framesizes,
@@ -1681,26 +1597,19 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
 static int mcam_v4l_open(struct file *filp)
 {
 	struct mcam_camera *cam = video_drvdata(filp);
-	int ret = v4l2_fh_open(filp);
-
-	if (ret)
-		return ret;
+	int ret;
 
-	cam->frame_state.frames = 0;
-	cam->frame_state.singles = 0;
-	cam->frame_state.delivered = 0;
 	mutex_lock(&cam->s_mutex);
-	if (cam->users == 0) {
-		ret = mcam_setup_vb2(cam);
-		if (ret)
-			goto out;
+	ret = v4l2_fh_open(filp);
+	if (ret)
+		goto out;
+	if (v4l2_fh_is_singular_file(filp)) {
 		ret = mcam_ctlr_power_up(cam);
 		if (ret)
 			goto out;
 		__mcam_cam_reset(cam);
 		mcam_set_config_needed(cam, 1);
 	}
-	(cam->users)++;
 out:
 	mutex_unlock(&cam->s_mutex);
 	if (ret)
@@ -1712,15 +1621,12 @@ out:
 static int mcam_v4l_release(struct file *filp)
 {
 	struct mcam_camera *cam = video_drvdata(filp);
+	bool last_open;
 
-	cam_dbg(cam, "Release, %d frames, %d singles, %d delivered\n",
-			cam->frame_state.frames, cam->frame_state.singles,
-			cam->frame_state.delivered);
 	mutex_lock(&cam->s_mutex);
-	(cam->users)--;
-	if (cam->users == 0) {
-		mcam_ctlr_stop_dma(cam);
-		mcam_cleanup_vb2(cam);
+	last_open = v4l2_fh_is_singular_file(filp);
+	_vb2_fop_release(filp, NULL);
+	if (last_open) {
 		mcam_disable_mipi(cam);
 		mcam_ctlr_power_down(cam);
 		if (cam->buffer_mode == B_vmalloc && alloc_bufs_at_read)
@@ -1728,58 +1634,16 @@ static int mcam_v4l_release(struct file *filp)
 	}
 
 	mutex_unlock(&cam->s_mutex);
-	v4l2_fh_release(filp);
 	return 0;
 }
 
-static ssize_t mcam_v4l_read(struct file *filp,
-		char __user *buffer, size_t len, loff_t *pos)
-{
-	struct mcam_camera *cam = video_drvdata(filp);
-	int ret;
-
-	mutex_lock(&cam->s_mutex);
-	ret = vb2_read(&cam->vb_queue, buffer, len, pos,
-			filp->f_flags & O_NONBLOCK);
-	mutex_unlock(&cam->s_mutex);
-	return ret;
-}
-
-
-
-static unsigned int mcam_v4l_poll(struct file *filp,
-		struct poll_table_struct *pt)
-{
-	struct mcam_camera *cam = video_drvdata(filp);
-	int ret;
-
-	mutex_lock(&cam->s_mutex);
-	ret = vb2_poll(&cam->vb_queue, filp, pt);
-	mutex_unlock(&cam->s_mutex);
-	return ret;
-}
-
-
-static int mcam_v4l_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-	struct mcam_camera *cam = video_drvdata(filp);
-	int ret;
-
-	mutex_lock(&cam->s_mutex);
-	ret = vb2_mmap(&cam->vb_queue, vma);
-	mutex_unlock(&cam->s_mutex);
-	return ret;
-}
-
-
-
 static const struct v4l2_file_operations mcam_v4l_fops = {
 	.owner = THIS_MODULE,
 	.open = mcam_v4l_open,
 	.release = mcam_v4l_release,
-	.read = mcam_v4l_read,
-	.poll = mcam_v4l_poll,
-	.mmap = mcam_v4l_mmap,
+	.read = vb2_fop_read,
+	.poll = vb2_fop_poll,
+	.mmap = vb2_fop_mmap,
 	.unlocked_ioctl = video_ioctl2,
 };
 
@@ -1790,8 +1654,6 @@ static const struct v4l2_file_operations mcam_v4l_fops = {
  */
 static struct video_device mcam_v4l_template = {
 	.name = "mcam",
-	.tvnorms = V4L2_STD_NTSC_M,
-
 	.fops = &mcam_v4l_fops,
 	.ioctl_ops = &mcam_v4l_ioctl_ops,
 	.release = video_device_release_empty,
@@ -1950,13 +1812,21 @@ int mccic_register(struct mcam_camera *cam)
 	if (ret)
 		goto out_unregister;
 
+	ret = mcam_setup_vb2(cam);
+	if (ret)
+		goto out_unregister;
+
 	mutex_lock(&cam->s_mutex);
 	cam->vdev = mcam_v4l_template;
 	cam->vdev.v4l2_dev = &cam->v4l2_dev;
+	cam->vdev.lock = &cam->s_mutex;
+	cam->vdev.queue = &cam->vb_queue;
 	video_set_drvdata(&cam->vdev, cam);
 	ret = video_register_device(&cam->vdev, VFL_TYPE_GRABBER, -1);
-	if (ret)
-		goto out;
+	if (ret) {
+		mutex_unlock(&cam->s_mutex);
+		goto out_unregister;
+	}
 
 	/*
 	 * If so requested, try to get our DMA buffers now.
@@ -1967,11 +1837,9 @@ int mccic_register(struct mcam_camera *cam)
 					" will try again later.");
 	}
 
-out:
-	if (ret)
-		v4l2_ctrl_handler_free(&cam->ctrl_handler);
 	mutex_unlock(&cam->s_mutex);
-	return ret;
+	return 0;
+
 out_unregister:
 	v4l2_ctrl_handler_free(&cam->ctrl_handler);
 	v4l2_device_unregister(&cam->v4l2_dev);
@@ -1987,11 +1855,11 @@ void mccic_shutdown(struct mcam_camera *cam)
 	 * take it down again will wedge the machine, which is frowned
 	 * upon.
 	 */
-	if (cam->users > 0) {
+	if (!list_empty(&cam->vdev.fh_list)) {
 		cam_warn(cam, "Removing a device with users!\n");
 		mcam_ctlr_power_down(cam);
 	}
-	vb2_queue_release(&cam->vb_queue);
+	mcam_cleanup_vb2(cam);
 	if (cam->buffer_mode == B_vmalloc)
 		mcam_free_dma_bufs(cam);
 	video_unregister_device(&cam->vdev);
@@ -2007,7 +1875,7 @@ void mccic_shutdown(struct mcam_camera *cam)
 void mccic_suspend(struct mcam_camera *cam)
 {
 	mutex_lock(&cam->s_mutex);
-	if (cam->users > 0) {
+	if (!list_empty(&cam->vdev.fh_list)) {
 		enum mcam_state cstate = cam->state;
 
 		mcam_ctlr_stop_dma(cam);
@@ -2022,7 +1890,7 @@ int mccic_resume(struct mcam_camera *cam)
 	int ret = 0;
 
 	mutex_lock(&cam->s_mutex);
-	if (cam->users > 0) {
+	if (!list_empty(&cam->vdev.fh_list)) {
 		ret = mcam_ctlr_power_up(cam);
 		if (ret) {
 			mutex_unlock(&cam->s_mutex);
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h b/drivers/media/platform/marvell-ccic/mcam-core.h
index 46bc715..2847e06 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -146,7 +146,6 @@ struct mcam_camera {
 	struct v4l2_ctrl_handler ctrl_handler;
 	enum mcam_state state;
 	unsigned long flags;		/* Buffer status, mainly (dev_lock) */
-	int users;			/* How many open FDs */
 
 	struct mcam_frame_state frame_state;	/* Frame state counter */
 	/*
-- 
2.1.4


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

* [PATCH 10/18] marvell-ccic: add create_bufs support
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (8 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 09/18] marvell-ccic: use vb2 helpers and core locking Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 11/18] marvell-ccic: add DMABUF support for all three DMA modes Hans Verkuil
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

This fixes the final v4l2-compliance warning.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index b6b838f..51b7291 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1073,7 +1073,9 @@ static int mcam_vb_queue_setup(struct vb2_queue *vq,
 	struct mcam_camera *cam = vb2_get_drv_priv(vq);
 	int minbufs = (cam->buffer_mode == B_DMA_contig) ? 3 : 2;
 
-	sizes[0] = cam->pix_format.sizeimage;
+	if (fmt && fmt->fmt.pix.sizeimage < cam->pix_format.sizeimage)
+		return -EINVAL;
+	sizes[0] = fmt ? fmt->fmt.pix.sizeimage : cam->pix_format.sizeimage;
 	*num_planes = 1; /* Someday we have to support planar formats... */
 	if (*nbufs < minbufs)
 		*nbufs = minbufs;
@@ -1380,7 +1382,7 @@ static int mcam_vidioc_s_fmt_vid_cap(struct file *filp, void *priv,
 	 * Can't do anything if the device is not idle
 	 * Also can't if there are streaming buffers in place.
 	 */
-	if (cam->state != S_IDLE || cam->vb_queue.num_buffers > 0)
+	if (cam->state != S_IDLE || vb2_is_busy(&cam->vb_queue))
 		return -EBUSY;
 
 	f = mcam_find_format(fmt->fmt.pix.pixelformat);
@@ -1573,6 +1575,7 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
 	.vidioc_g_input		= mcam_vidioc_g_input,
 	.vidioc_s_input		= mcam_vidioc_s_input,
 	.vidioc_reqbufs		= vb2_ioctl_reqbufs,
+	.vidioc_create_bufs	= vb2_ioctl_create_bufs,
 	.vidioc_querybuf	= vb2_ioctl_querybuf,
 	.vidioc_qbuf		= vb2_ioctl_qbuf,
 	.vidioc_dqbuf		= vb2_ioctl_dqbuf,
-- 
2.1.4


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

* [PATCH 11/18] marvell-ccic: add DMABUF support for all three DMA modes
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (9 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 10/18] marvell-ccic: add create_bufs support Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 12/18] marvell-ccic: fix streaming issues Hans Verkuil
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

Add VB2_DMABUF and VIDIOC_EXPBUF support. Also add VB2_USERPTR support
for the vmalloc DMA mode which was missing for no good reason.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 51b7291..a1312a5 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1255,14 +1255,14 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
 	vq->drv_priv = cam;
 	vq->lock = &cam->s_mutex;
 	vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+	vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
+	vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
 	INIT_LIST_HEAD(&cam->buffers);
 	switch (cam->buffer_mode) {
 	case B_DMA_contig:
 #ifdef MCAM_MODE_DMA_CONTIG
 		vq->ops = &mcam_vb2_ops;
 		vq->mem_ops = &vb2_dma_contig_memops;
-		vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-		vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
 		cam->dma_setup = mcam_ctlr_dma_contig;
 		cam->frame_complete = mcam_dma_contig_done;
 		cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev);
@@ -1274,8 +1274,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
 #ifdef MCAM_MODE_DMA_SG
 		vq->ops = &mcam_vb2_sg_ops;
 		vq->mem_ops = &vb2_dma_sg_memops;
-		vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-		vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
 		cam->dma_setup = mcam_ctlr_dma_sg;
 		cam->frame_complete = mcam_dma_sg_done;
 		cam->vb_alloc_ctx_sg = vb2_dma_sg_init_ctx(cam->dev);
@@ -1289,8 +1287,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
 				(unsigned long) cam);
 		vq->ops = &mcam_vb2_ops;
 		vq->mem_ops = &vb2_vmalloc_memops;
-		vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-		vq->io_modes = VB2_MMAP | VB2_READ;
 		cam->dma_setup = mcam_ctlr_dma_vmalloc;
 		cam->frame_complete = mcam_vmalloc_done;
 #endif
@@ -1579,6 +1575,7 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
 	.vidioc_querybuf	= vb2_ioctl_querybuf,
 	.vidioc_qbuf		= vb2_ioctl_qbuf,
 	.vidioc_dqbuf		= vb2_ioctl_dqbuf,
+	.vidioc_expbuf		= vb2_ioctl_expbuf,
 	.vidioc_streamon	= vb2_ioctl_streamon,
 	.vidioc_streamoff	= vb2_ioctl_streamoff,
 	.vidioc_g_parm		= mcam_vidioc_g_parm,
-- 
2.1.4


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

* [PATCH 12/18] marvell-ccic: fix streaming issues
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (10 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 11/18] marvell-ccic: add DMABUF support for all three DMA modes Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 13/18] marvell-ccic: correctly requeue buffers Hans Verkuil
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

- fill in timestamp
- fill in field
- start the sequence counter at 0, not 1

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index a1312a5..6b7b38b 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -239,6 +239,8 @@ static void mcam_buffer_done(struct mcam_camera *cam, int frame,
 {
 	vbuf->v4l2_buf.bytesused = cam->pix_format.sizeimage;
 	vbuf->v4l2_buf.sequence = cam->buf_seq[frame];
+	vbuf->v4l2_buf.field = V4L2_FIELD_NONE;
+	v4l2_get_timestamp(&vbuf->v4l2_buf.timestamp);
 	vb2_set_plane_payload(vbuf, 0, cam->pix_format.sizeimage);
 	vb2_buffer_done(vbuf, VB2_BUF_STATE_DONE);
 }
@@ -1671,7 +1673,7 @@ static void mcam_frame_complete(struct mcam_camera *cam, int frame)
 	set_bit(frame, &cam->flags);
 	clear_bit(CF_DMA_ACTIVE, &cam->flags);
 	cam->next_buf = frame;
-	cam->buf_seq[frame] = ++(cam->sequence);
+	cam->buf_seq[frame] = cam->sequence++;
 	cam->frame_state.frames++;
 	/*
 	 * "This should never happen"
-- 
2.1.4


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

* [PATCH 13/18] marvell-ccic: correctly requeue buffers
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (11 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 12/18] marvell-ccic: fix streaming issues Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 14/18] marvell-ccic: add planar support to dma-vmalloc Hans Verkuil
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

If start_streaming fails or stop_streaming is called, then all queued
buffers need to be given back to vb2.

This prevents vb2 from calling WARN_ON when it detects that this is not
done correctly.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 39 ++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 6b7b38b..0d94696 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -607,6 +607,7 @@ static void mcam_dma_contig_done(struct mcam_camera *cam, int frame)
 
 	if (!test_bit(CF_SINGLE_BUFFER, &cam->flags)) {
 		cam->frame_state.delivered++;
+		cam->vb_bufs[frame] = NULL;
 		mcam_buffer_done(cam, frame, &buf->vb_buf);
 	}
 	mcam_set_contig_buffer(cam, frame);
@@ -1106,6 +1107,30 @@ static void mcam_vb_buf_queue(struct vb2_buffer *vb)
 		mcam_read_setup(cam);
 }
 
+static void mcam_vb_requeue_bufs(struct vb2_queue *vq,
+				 enum vb2_buffer_state state)
+{
+	struct mcam_camera *cam = vb2_get_drv_priv(vq);
+	struct mcam_vb_buffer *buf, *node;
+	unsigned long flags;
+	unsigned i;
+
+	spin_lock_irqsave(&cam->dev_lock, flags);
+	list_for_each_entry_safe(buf, node, &cam->buffers, queue) {
+		vb2_buffer_done(&buf->vb_buf, state);
+		list_del(&buf->queue);
+	}
+	for (i = 0; i < MAX_DMA_BUFS; i++) {
+		buf = cam->vb_bufs[i];
+
+		if (buf) {
+			vb2_buffer_done(&buf->vb_buf, state);
+			cam->vb_bufs[i] = NULL;
+		}
+	}
+	spin_unlock_irqrestore(&cam->dev_lock, flags);
+}
+
 /*
  * These need to be called with the mutex held from vb2
  */
@@ -1113,9 +1138,10 @@ static int mcam_vb_start_streaming(struct vb2_queue *vq, unsigned int count)
 {
 	struct mcam_camera *cam = vb2_get_drv_priv(vq);
 	unsigned int frame;
+	int ret;
 
 	if (cam->state != S_IDLE) {
-		INIT_LIST_HEAD(&cam->buffers);
+		mcam_vb_requeue_bufs(vq, VB2_BUF_STATE_QUEUED);
 		return -EINVAL;
 	}
 	cam->frame_state.frames = 0;
@@ -1141,13 +1167,15 @@ static int mcam_vb_start_streaming(struct vb2_queue *vq, unsigned int count)
 	for (frame = 0; frame < cam->nbufs; frame++)
 		clear_bit(CF_FRAME_SOF0 + frame, &cam->flags);
 
-	return mcam_read_setup(cam);
+	ret = mcam_read_setup(cam);
+	if (ret)
+		mcam_vb_requeue_bufs(vq, VB2_BUF_STATE_QUEUED);
+	return ret;
 }
 
 static void mcam_vb_stop_streaming(struct vb2_queue *vq)
 {
 	struct mcam_camera *cam = vb2_get_drv_priv(vq);
-	unsigned long flags;
 
 	cam_dbg(cam, "stop_streaming: %d frames, %d singles, %d delivered\n",
 			cam->frame_state.frames, cam->frame_state.singles,
@@ -1170,9 +1198,7 @@ static void mcam_vb_stop_streaming(struct vb2_queue *vq)
 	 * VB2 reclaims the buffers, so we need to forget
 	 * about them.
 	 */
-	spin_lock_irqsave(&cam->dev_lock, flags);
-	INIT_LIST_HEAD(&cam->buffers);
-	spin_unlock_irqrestore(&cam->dev_lock, flags);
+	mcam_vb_requeue_bufs(vq, VB2_BUF_STATE_ERROR);
 }
 
 
@@ -1786,7 +1812,6 @@ int mccic_register(struct mcam_camera *cam)
 	mcam_set_config_needed(cam, 1);
 	cam->pix_format = mcam_def_pix_format;
 	cam->mbus_code = mcam_def_mbus_code;
-	INIT_LIST_HEAD(&cam->buffers);
 	mcam_ctlr_init(cam);
 
 	/*
-- 
2.1.4


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

* [PATCH 14/18] marvell-ccic: add planar support to dma-vmalloc
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (12 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 13/18] marvell-ccic: correctly requeue buffers Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 15/18] marvell-ccic: drop V4L2_PIX_FMT_JPEG dead code Hans Verkuil
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

The dma-vmalloc implementation didn't support planar formats, but with
a little bit of refactoring that is easy to fix.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 94 ++++++++++++-------------
 1 file changed, 46 insertions(+), 48 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 0d94696..2495ab6 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -206,12 +206,6 @@ struct mcam_dma_desc {
 	u32 segment_len;
 };
 
-struct yuv_pointer_t {
-	dma_addr_t y;
-	dma_addr_t u;
-	dma_addr_t v;
-};
-
 /*
  * Our buffer type for working with videobuf2.  Note that the vb2
  * developers have decreed that struct vb2_buffer must be at the
@@ -223,7 +217,6 @@ struct mcam_vb_buffer {
 	struct mcam_dma_desc *dma_desc;	/* Descriptor virtual address */
 	dma_addr_t dma_desc_pa;		/* Descriptor physical address */
 	int dma_desc_nent;		/* Number of mapped descriptors */
-	struct yuv_pointer_t yuv_p;
 };
 
 static inline struct mcam_vb_buffer *vb_to_mvb(struct vb2_buffer *vb)
@@ -341,6 +334,47 @@ static void mcam_disable_mipi(struct mcam_camera *mcam)
 	mcam->mipi_enabled = false;
 }
 
+static bool mcam_fmt_is_planar(__u32 pfmt)
+{
+	struct mcam_format_struct *f;
+
+	f = mcam_find_format(pfmt);
+	return f->planar;
+}
+
+static void mcam_write_yuv_bases(struct mcam_camera *cam,
+				 unsigned frame, dma_addr_t base)
+{
+	struct v4l2_pix_format *fmt = &cam->pix_format;
+	u32 pixel_count = fmt->width * fmt->height;
+	dma_addr_t y, u = 0, v = 0;
+
+	y = base;
+
+	switch (fmt->pixelformat) {
+	case V4L2_PIX_FMT_YUV422P:
+		u = y + pixel_count;
+		v = u + pixel_count / 2;
+		break;
+	case V4L2_PIX_FMT_YUV420:
+		u = y + pixel_count;
+		v = u + pixel_count / 4;
+		break;
+	case V4L2_PIX_FMT_YVU420:
+		v = y + pixel_count;
+		u = v + pixel_count / 4;
+		break;
+	default:
+		break;
+	}
+
+	mcam_reg_write(cam, REG_Y0BAR + frame * 4, y);
+	if (mcam_fmt_is_planar(fmt->pixelformat)) {
+		mcam_reg_write(cam, REG_U0BAR + frame * 4, u);
+		mcam_reg_write(cam, REG_V0BAR + frame * 4, v);
+	}
+}
+
 /* ------------------------------------------------------------------- */
 
 #ifdef MCAM_MODE_VMALLOC
@@ -411,15 +445,14 @@ static void mcam_free_dma_bufs(struct mcam_camera *cam)
 static void mcam_ctlr_dma_vmalloc(struct mcam_camera *cam)
 {
 	/*
-	 * Store the first two Y buffers (we aren't supporting
-	 * planar formats for now, so no UV bufs).  Then either
+	 * Store the first two YUV buffers. Then either
 	 * set the third if it exists, or tell the controller
 	 * to just use two.
 	 */
-	mcam_reg_write(cam, REG_Y0BAR, cam->dma_handles[0]);
-	mcam_reg_write(cam, REG_Y1BAR, cam->dma_handles[1]);
+	mcam_write_yuv_bases(cam, 0, cam->dma_handles[0]);
+	mcam_write_yuv_bases(cam, 1, cam->dma_handles[1]);
 	if (cam->nbufs > 2) {
-		mcam_reg_write(cam, REG_Y2BAR, cam->dma_handles[2]);
+		mcam_write_yuv_bases(cam, 2, cam->dma_handles[2]);
 		mcam_reg_clear_bit(cam, REG_CTRL1, C1_TWOBUFS);
 	} else
 		mcam_reg_set_bit(cam, REG_CTRL1, C1_TWOBUFS);
@@ -514,14 +547,6 @@ static inline int mcam_check_dma_buffers(struct mcam_camera *cam)
  * DMA-contiguous code.
  */
 
-static bool mcam_fmt_is_planar(__u32 pfmt)
-{
-	struct mcam_format_struct *f;
-
-	f = mcam_find_format(pfmt);
-	return f->planar;
-}
-
 /*
  * Set up a contiguous buffer for the given frame.  Here also is where
  * the underrun strategy is set: if there is no buffer available, reuse
@@ -533,9 +558,7 @@ static bool mcam_fmt_is_planar(__u32 pfmt)
 static void mcam_set_contig_buffer(struct mcam_camera *cam, int frame)
 {
 	struct mcam_vb_buffer *buf;
-	struct v4l2_pix_format *fmt = &cam->pix_format;
 	dma_addr_t dma_handle;
-	u32 pixel_count = fmt->width * fmt->height;
 	struct vb2_buffer *vb;
 
 	/*
@@ -559,32 +582,7 @@ static void mcam_set_contig_buffer(struct mcam_camera *cam, int frame)
 	vb = &buf->vb_buf;
 
 	dma_handle = vb2_dma_contig_plane_dma_addr(vb, 0);
-	buf->yuv_p.y = dma_handle;
-
-	switch (cam->pix_format.pixelformat) {
-	case V4L2_PIX_FMT_YUV422P:
-		buf->yuv_p.u = buf->yuv_p.y + pixel_count;
-		buf->yuv_p.v = buf->yuv_p.u + pixel_count / 2;
-		break;
-	case V4L2_PIX_FMT_YUV420:
-		buf->yuv_p.u = buf->yuv_p.y + pixel_count;
-		buf->yuv_p.v = buf->yuv_p.u + pixel_count / 4;
-		break;
-	case V4L2_PIX_FMT_YVU420:
-		buf->yuv_p.v = buf->yuv_p.y + pixel_count;
-		buf->yuv_p.u = buf->yuv_p.v + pixel_count / 4;
-		break;
-	default:
-		break;
-	}
-
-	mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR, buf->yuv_p.y);
-	if (mcam_fmt_is_planar(fmt->pixelformat)) {
-		mcam_reg_write(cam, frame == 0 ?
-					REG_U0BAR : REG_U1BAR, buf->yuv_p.u);
-		mcam_reg_write(cam, frame == 0 ?
-					REG_V0BAR : REG_V1BAR, buf->yuv_p.v);
-	}
+	mcam_write_yuv_bases(cam, frame, dma_handle);
 }
 
 /*
-- 
2.1.4


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

* [PATCH 15/18] marvell-ccic: drop V4L2_PIX_FMT_JPEG dead code
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (13 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 14/18] marvell-ccic: add planar support to dma-vmalloc Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 16/18] ov7670: use colorspace SRGB instead of JPEG Hans Verkuil
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

This driver appeared to support the JPEG format when in reality
that was just dead code. Remove it.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 2495ab6..1a32610 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -755,11 +755,6 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
 		widthy = fmt->width * 2;
 		widthuv = 0;
 		break;
-	case V4L2_PIX_FMT_JPEG:
-		imgsz_h = (fmt->sizeimage / fmt->bytesperline) << IMGSZ_V_SHIFT;
-		widthy = fmt->bytesperline;
-		widthuv = 0;
-		break;
 	case V4L2_PIX_FMT_YUV422P:
 	case V4L2_PIX_FMT_YUV420:
 	case V4L2_PIX_FMT_YVU420:
@@ -797,10 +792,6 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
 		mcam_reg_write_mask(cam, REG_CTRL0,
 			C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_YUYV, C0_DF_MASK);
 		break;
-	case V4L2_PIX_FMT_JPEG:
-		mcam_reg_write_mask(cam, REG_CTRL0,
-			C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_YUYV, C0_DF_MASK);
-		break;
 	case V4L2_PIX_FMT_RGB444:
 		mcam_reg_write_mask(cam, REG_CTRL0,
 			C0_DF_RGB | C0_RGBF_444 | C0_RGB4_XRGB, C0_DF_MASK);
-- 
2.1.4


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

* [PATCH 16/18] ov7670: use colorspace SRGB instead of JPEG
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (14 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 15/18] marvell-ccic: drop V4L2_PIX_FMT_JPEG dead code Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 17/18] marvell-ccic: fix the bytesperline and sizeimage calculations Hans Verkuil
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

Even though the format is Y'CbCr, the colorspace used by the sensor
is almost certainly SRGB. The sensor is also not generating JPEG data,
so it makes no sense to use V4L2_COLORSPACE_JPEG here.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/i2c/ov7670.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 81a1e44..504472b 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -639,7 +639,7 @@ static struct ov7670_format_struct {
 } ov7670_formats[] = {
 	{
 		.mbus_code	= MEDIA_BUS_FMT_YUYV8_2X8,
-		.colorspace	= V4L2_COLORSPACE_JPEG,
+		.colorspace	= V4L2_COLORSPACE_SRGB,
 		.regs 		= ov7670_fmt_yuv422,
 		.cmatrix	= { 128, -128, 0, -34, -94, 128 },
 	},
-- 
2.1.4


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

* [PATCH 17/18] marvell-ccic: fix the bytesperline and sizeimage calculations
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (15 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 16/18] ov7670: use colorspace SRGB instead of JPEG Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-09 21:22 ` [PATCH 18/18] marvell-ccic: fix Y'CbCr ordering Hans Verkuil
  2015-03-10 14:30 ` [PATCH 00/18] marvell-ccic + ov7670 fixes Jonathan Corbet
  18 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

These were calculated incorrectly for the planar formats.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 1a32610..9343051 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -127,21 +127,21 @@ static struct mcam_format_struct {
 		.desc		= "YUV 4:2:2 PLANAR",
 		.pixelformat	= V4L2_PIX_FMT_YUV422P,
 		.mbus_code	= MEDIA_BUS_FMT_YUYV8_2X8,
-		.bpp		= 2,
+		.bpp		= 1,
 		.planar		= true,
 	},
 	{
 		.desc		= "YUV 4:2:0 PLANAR",
 		.pixelformat	= V4L2_PIX_FMT_YUV420,
 		.mbus_code	= MEDIA_BUS_FMT_YUYV8_2X8,
-		.bpp		= 2,
+		.bpp		= 1,
 		.planar		= true,
 	},
 	{
 		.desc		= "YVU 4:2:0 PLANAR",
 		.pixelformat	= V4L2_PIX_FMT_YVU420,
 		.mbus_code	= MEDIA_BUS_FMT_YUYV8_2X8,
-		.bpp		= 2,
+		.bpp		= 1,
 		.planar		= true,
 	},
 	{
@@ -764,6 +764,7 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
 	default:
 		widthy = fmt->bytesperline;
 		widthuv = 0;
+		break;
 	}
 
 	mcam_reg_write_mask(cam, REG_IMGPITCH, widthuv << 16 | widthy,
@@ -1370,16 +1371,19 @@ static int mcam_vidioc_try_fmt_vid_cap(struct file *filp, void *priv,
 	v4l2_fill_mbus_format(&mbus_fmt, pix, f->mbus_code);
 	ret = sensor_call(cam, video, try_mbus_fmt, &mbus_fmt);
 	v4l2_fill_pix_format(pix, &mbus_fmt);
+	pix->bytesperline = pix->width * f->bpp;
 	switch (f->pixelformat) {
+	case V4L2_PIX_FMT_YUV422P:
+		pix->sizeimage = pix->height * pix->bytesperline * 2;
+		break;
 	case V4L2_PIX_FMT_YUV420:
 	case V4L2_PIX_FMT_YVU420:
-		pix->bytesperline = pix->width * 3 / 2;
+		pix->sizeimage = pix->height * pix->bytesperline * 3 / 2;
 		break;
 	default:
-		pix->bytesperline = pix->width * f->bpp;
+		pix->sizeimage = pix->height * pix->bytesperline;
 		break;
 	}
-	pix->sizeimage = pix->height * pix->bytesperline;
 	pix->colorspace = V4L2_COLORSPACE_SRGB;
 	return ret;
 }
-- 
2.1.4


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

* [PATCH 18/18] marvell-ccic: fix Y'CbCr ordering
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (16 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 17/18] marvell-ccic: fix the bytesperline and sizeimage calculations Hans Verkuil
@ 2015-03-09 21:22 ` Hans Verkuil
  2015-03-10 15:56   ` Hans Verkuil
  2015-03-10 14:30 ` [PATCH 00/18] marvell-ccic + ov7670 fixes Jonathan Corbet
  18 siblings, 1 reply; 22+ messages in thread
From: Hans Verkuil @ 2015-03-09 21:22 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

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

Various formats had their byte ordering implemented incorrectly, and
the V4L2_PIX_FMT_UYVY is actually impossible to create, instead you
get V4L2_PIX_FMT_YVYU.

This was working before commit ad6ac452227b7cb93ac79beec092850d178740b1
("add new formats support for marvell-ccic driver"). That commit broke
the original format support and the OLPC XO-1 laptop showed wrong
colors ever since (if you are crazy enough to attempt to run the latest
kernel on it, like I did).

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 16 ++++++++--------
 drivers/media/platform/marvell-ccic/mcam-core.h |  8 ++++----
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 9343051..4e3ef68 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -117,8 +117,8 @@ static struct mcam_format_struct {
 		.planar		= false,
 	},
 	{
-		.desc		= "UYVY 4:2:2",
-		.pixelformat	= V4L2_PIX_FMT_UYVY,
+		.desc		= "YVYU 4:2:2",
+		.pixelformat	= V4L2_PIX_FMT_YVYU,
 		.mbus_code	= MEDIA_BUS_FMT_YUYV8_2X8,
 		.bpp		= 2,
 		.planar		= false,
@@ -751,7 +751,7 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
 
 	switch (fmt->pixelformat) {
 	case V4L2_PIX_FMT_YUYV:
-	case V4L2_PIX_FMT_UYVY:
+	case V4L2_PIX_FMT_YVYU:
 		widthy = fmt->width * 2;
 		widthuv = 0;
 		break;
@@ -778,20 +778,20 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
 	switch (fmt->pixelformat) {
 	case V4L2_PIX_FMT_YUV422P:
 		mcam_reg_write_mask(cam, REG_CTRL0,
-			C0_DF_YUV | C0_YUV_PLANAR | C0_YUVE_YVYU, C0_DF_MASK);
+			C0_DF_YUV | C0_YUV_PLANAR | C0_YUVE_UYVY, C0_DF_MASK);
 		break;
 	case V4L2_PIX_FMT_YUV420:
 	case V4L2_PIX_FMT_YVU420:
 		mcam_reg_write_mask(cam, REG_CTRL0,
-			C0_DF_YUV | C0_YUV_420PL | C0_YUVE_YVYU, C0_DF_MASK);
+			C0_DF_YUV | C0_YUV_420PL | C0_YUVE_VYUY, C0_DF_MASK);
 		break;
 	case V4L2_PIX_FMT_YUYV:
 		mcam_reg_write_mask(cam, REG_CTRL0,
-			C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_UYVY, C0_DF_MASK);
+			C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_NOSWAP, C0_DF_MASK);
 		break;
-	case V4L2_PIX_FMT_UYVY:
+	case V4L2_PIX_FMT_YVYU:
 		mcam_reg_write_mask(cam, REG_CTRL0,
-			C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_YUYV, C0_DF_MASK);
+			C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_SWAP24, C0_DF_MASK);
 		break;
 	case V4L2_PIX_FMT_RGB444:
 		mcam_reg_write_mask(cam, REG_CTRL0,
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h b/drivers/media/platform/marvell-ccic/mcam-core.h
index 2847e06..97167f6 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -331,10 +331,10 @@ int mccic_resume(struct mcam_camera *cam);
 #define	  C0_YUVE_YVYU	  0x00010000	/* Y1CrY0Cb		*/
 #define	  C0_YUVE_VYUY	  0x00020000	/* CrY1CbY0		*/
 #define	  C0_YUVE_UYVY	  0x00030000	/* CbY1CrY0		*/
-#define	  C0_YUVE_XYUV	  0x00000000	/* 420: .YUV		*/
-#define	  C0_YUVE_XYVU	  0x00010000	/* 420: .YVU		*/
-#define	  C0_YUVE_XUVY	  0x00020000	/* 420: .UVY		*/
-#define	  C0_YUVE_XVUY	  0x00030000	/* 420: .VUY		*/
+#define	  C0_YUVE_NOSWAP  0x00000000	/* no bytes swapping	*/
+#define	  C0_YUVE_SWAP13  0x00010000	/* swap byte 1 and 3	*/
+#define	  C0_YUVE_SWAP24  0x00020000	/* swap byte 2 and 4	*/
+#define	  C0_YUVE_SWAP1324 0x00030000	/* swap bytes 1&3 and 2&4 */
 /* Bayer bits 18,19 if needed */
 #define	  C0_EOF_VSYNC	  0x00400000	/* Generate EOF by VSYNC */
 #define	  C0_VEDGE_CTRL   0x00800000	/* Detect falling edge of VSYNC */
-- 
2.1.4


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

* Re: [PATCH 00/18] marvell-ccic + ov7670 fixes
  2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
                   ` (17 preceding siblings ...)
  2015-03-09 21:22 ` [PATCH 18/18] marvell-ccic: fix Y'CbCr ordering Hans Verkuil
@ 2015-03-10 14:30 ` Jonathan Corbet
  2015-03-10 14:49   ` Hans Verkuil
  18 siblings, 1 reply; 22+ messages in thread
From: Jonathan Corbet @ 2015-03-10 14:30 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media

On Mon,  9 Mar 2015 22:22:05 +0100
Hans Verkuil <hverkuil@xs4all.nl> wrote:

> This patch series makes loads of fixes and improvements to the marvell-ccic
> and ov7670 drivers. This has been tested on an OLPC XO-1 laptop.

So I'm traveling and even shorter on time than usual.  I've had a quick
look over these patches, and they generally seem OK.  Just don't ding me
for not using a bunch of infrastructure that wasn't there when I wrote
this thing! :)

Ideally it would be nice to see patch 9 split - locking changes separate
from use of helpers - but that's a quibble.

Out of curiosity, is there a use driving this work, or are you just
making things cleaner?

Regardless, it clearly improves the drivers; thanks for doing this.

Acked-by: Jonathan Corbet <corbet@lwn.net>

> I do need to check the last patch with Libin Yang since his patch from mid-2013
> broke the driver for the OLPC laptop. Nobody noticed since the latest released
> kernel from the OLPC project for that laptop is 3.3, which didn't have his patch.

Libin seems to have vanished, and I think that whatever interest Marvell
had in supporting this driver has vanished with him, unfortunately.  I'm
still tempted to revert much of that work, since I'm not sure it has ever
worked on a real system...

jon

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

* Re: [PATCH 00/18] marvell-ccic + ov7670 fixes
  2015-03-10 14:30 ` [PATCH 00/18] marvell-ccic + ov7670 fixes Jonathan Corbet
@ 2015-03-10 14:49   ` Hans Verkuil
  0 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-10 14:49 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: linux-media

On 03/10/2015 03:30 PM, Jonathan Corbet wrote:
> On Mon,  9 Mar 2015 22:22:05 +0100
> Hans Verkuil <hverkuil@xs4all.nl> wrote:
> 
>> This patch series makes loads of fixes and improvements to the marvell-ccic
>> and ov7670 drivers. This has been tested on an OLPC XO-1 laptop.
> 
> So I'm traveling and even shorter on time than usual.  I've had a quick
> look over these patches, and they generally seem OK.  Just don't ding me
> for not using a bunch of infrastructure that wasn't there when I wrote
> this thing! :)
> 
> Ideally it would be nice to see patch 9 split - locking changes separate
> from use of helpers - but that's a quibble.
> 
> Out of curiosity, is there a use driving this work, or are you just
> making things cleaner?

I needed to test my earlier subdev patch series, and since I finally had the
OLPC in a testable state again I thought that was a good opportunity to run
the v4l2-compliance test suite over it. That always generates a lot of failures
when it is run for the first time on a driver. I'm biased since I wrote that
tool, but v4l2-compliance is awesome :-)

As an added bonus this driver is now also converted to the new frameworks.
Eventually all drivers will be converted and we can drop legacy support in the
v4l2 core.

And as a second bonus this was a good reason for me to add support for the
4:2:0 planar formats to the vivid driver, which helped me test the marvell driver.

I've tested all the supported formats and I can confirm that they all work
after this patch series is applied.

> Regardless, it clearly improves the drivers; thanks for doing this.
> 
> Acked-by: Jonathan Corbet <corbet@lwn.net>
> 
>> I do need to check the last patch with Libin Yang since his patch from mid-2013
>> broke the driver for the OLPC laptop. Nobody noticed since the latest released
>> kernel from the OLPC project for that laptop is 3.3, which didn't have his patch.
> 
> Libin seems to have vanished, and I think that whatever interest Marvell
> had in supporting this driver has vanished with him, unfortunately.  I'm
> still tempted to revert much of that work, since I'm not sure it has ever
> worked on a real system...

OK, good to know. I'll try to contact him and if I haven't heard from him by
Monday (or if the email is no longer valid), then I'll make a pull request for
this series to get it in 4.1.

Regards,

	Hans

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

* Re: [PATCH 18/18] marvell-ccic: fix Y'CbCr ordering
  2015-03-09 21:22 ` [PATCH 18/18] marvell-ccic: fix Y'CbCr ordering Hans Verkuil
@ 2015-03-10 15:56   ` Hans Verkuil
  0 siblings, 0 replies; 22+ messages in thread
From: Hans Verkuil @ 2015-03-10 15:56 UTC (permalink / raw)
  To: linux-media; +Cc: corbet, Hans Verkuil

On 03/09/2015 10:22 PM, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> Various formats had their byte ordering implemented incorrectly, and
> the V4L2_PIX_FMT_UYVY is actually impossible to create, instead you
> get V4L2_PIX_FMT_YVYU.
> 
> This was working before commit ad6ac452227b7cb93ac79beec092850d178740b1
> ("add new formats support for marvell-ccic driver"). That commit broke
> the original format support and the OLPC XO-1 laptop showed wrong
> colors ever since (if you are crazy enough to attempt to run the latest
> kernel on it, like I did).

I tried to contact the original authors of that commit but I couldn't reach
them. So I've added the following to the commit log of this patch:

"The email addresses of the authors of that patch are no longer valid,
so without a way to reach them and ask them about their test setup
I am going with what I can test on the OLPC laptop.

If this breaks something for someone on their non-OLPC setup, then
contact the linux-media mailinglist. My suspicion however is that
that commit went in untested."

Regards,

	Hans

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

end of thread, other threads:[~2015-03-10 15:56 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-09 21:22 [PATCH 00/18] marvell-ccic + ov7670 fixes Hans Verkuil
2015-03-09 21:22 ` [PATCH 01/18] marvell-ccic: fix vb2 warning Hans Verkuil
2015-03-09 21:22 ` [PATCH 02/18] marvell-ccic: fill in bus_info Hans Verkuil
2015-03-09 21:22 ` [PATCH 03/18] marvell-ccic: webcam drivers shouldn't support g/s_std Hans Verkuil
2015-03-09 21:22 ` [PATCH 04/18] ov7670: check for valid width/height in ov7670_enum_frame_interval Hans Verkuil
2015-03-09 21:22 ` [PATCH 05/18] marvell-ccic: fill in colorspace Hans Verkuil
2015-03-09 21:22 ` [PATCH 06/18] marvell-ccic: control handler fixes Hans Verkuil
2015-03-09 21:22 ` [PATCH 07/18] marvell-ccic: switch to struct v4l2_fh Hans Verkuil
2015-03-09 21:22 ` [PATCH 08/18] marvell-ccic: implement control events Hans Verkuil
2015-03-09 21:22 ` [PATCH 09/18] marvell-ccic: use vb2 helpers and core locking Hans Verkuil
2015-03-09 21:22 ` [PATCH 10/18] marvell-ccic: add create_bufs support Hans Verkuil
2015-03-09 21:22 ` [PATCH 11/18] marvell-ccic: add DMABUF support for all three DMA modes Hans Verkuil
2015-03-09 21:22 ` [PATCH 12/18] marvell-ccic: fix streaming issues Hans Verkuil
2015-03-09 21:22 ` [PATCH 13/18] marvell-ccic: correctly requeue buffers Hans Verkuil
2015-03-09 21:22 ` [PATCH 14/18] marvell-ccic: add planar support to dma-vmalloc Hans Verkuil
2015-03-09 21:22 ` [PATCH 15/18] marvell-ccic: drop V4L2_PIX_FMT_JPEG dead code Hans Verkuil
2015-03-09 21:22 ` [PATCH 16/18] ov7670: use colorspace SRGB instead of JPEG Hans Verkuil
2015-03-09 21:22 ` [PATCH 17/18] marvell-ccic: fix the bytesperline and sizeimage calculations Hans Verkuil
2015-03-09 21:22 ` [PATCH 18/18] marvell-ccic: fix Y'CbCr ordering Hans Verkuil
2015-03-10 15:56   ` Hans Verkuil
2015-03-10 14:30 ` [PATCH 00/18] marvell-ccic + ov7670 fixes Jonathan Corbet
2015-03-10 14:49   ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox