Skip to contentSkip to conversation

media: blackfin: bfin_capture enhancements

PATCH In review Lad Prabhakar 3 participants 24 messages Mar 8, 2015 – May 5, 2015 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

v4 cover media: blackfin: bfin_capture enhancements

From: "Lad, Prabhakar" <[email protected]>

This patch series, enhances blackfin capture driver with vb2 helpers.

Changes for v4:
1: Improved commit message for path 4/17 and 5/17. 2: Added Ack's from Scott to patches 1-15 3: Two new patches 16/17 and 17/17

Lad, Prabhakar (17):
media: blackfin: bfin_capture: drop buf_init() callback
media: blackfin: bfin_capture: release buffers in case
start_streaming() call back fails
media: blackfin: bfin_capture: set min_buffers_needed
media: blackfin: bfin_capture: set vb2 buffer field
media: blackfin: bfin_capture: improve queue_setup() callback
media: blackfin: bfin_capture: use vb2_fop_mmap/poll
media: blackfin: bfin_capture: use v4l2_fh_open and vb2_fop_release
media: blackfin: bfin_capture: use vb2_ioctl_* helpers
media: blackfin: bfin_capture: make sure all buffers are returned on
stop_streaming() callback
media: blackfin: bfin_capture: return -ENODATA for *std calls
media: blackfin: bfin_capture: return -ENODATA for *dv_timings calls
media: blackfin: bfin_capture: add support for vidioc_create_bufs
media: blackfin: bfin_capture: add support for VB2_DMABUF
media: blackfin: bfin_capture: add support for VIDIOC_EXPBUF
media: blackfin: bfin_capture: set v4l2 buffer sequence
media: blackfin: bfin_capture: drop bcap_get_unmapped_area()
media: blackfin: bfin_capture: embed video_device struct in
bcap_device

 drivers/media/platform/blackfin/bfin_capture.c | 348 ++++++++-----------------
 1 file changed, 103 insertions(+), 245 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH v4 1/17 media: blackfin: bfin_capture: drop buf_init() callback

From: "Lad, Prabhakar" <[email protected]>

this patch drops the buf_init() callback as init of buf list is not required.

---
 drivers/media/platform/blackfin/bfin_capture.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/media/platform/blackfin/bfin_capture.c +0 -9
index 8f66986..c6d8b95 100644
@@ -302,14 +302,6 @@ static int bcap_queue_setup(struct vb2_queue *vq,
 	return 0;
 }
 
-static int bcap_buffer_init(struct vb2_buffer *vb)
-{
-	struct bcap_buffer *buf = to_bcap_vb(vb);
-
-	INIT_LIST_HEAD(&buf->list);
-	return 0;
-}
-
 static int bcap_buffer_prepare(struct vb2_buffer *vb)
 {
 	struct bcap_device *bcap_dev = vb2_get_drv_priv(vb->vb2_queue);
@@ -441,7 +433,6 @@ static void bcap_stop_streaming(struct vb2_queue *vq)
 
 static struct vb2_ops bcap_video_qops = {
 	.queue_setup            = bcap_queue_setup,
-	.buf_init               = bcap_buffer_init,
 	.buf_prepare            = bcap_buffer_prepare,
 	.buf_cleanup            = bcap_buffer_cleanup,
 	.buf_queue              = bcap_buffer_queue,
Signature · 1 line
2.1.0
#2 lore raw

PATCH v4 2/17 media: blackfin: bfin_capture: release buffers in case start_streaming() call back fails

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch adds support to release the buffer by calling vb2_buffer_done(), with state marked as VB2_BUF_STATE_QUEUED if start_streaming() call back fails.

---
 drivers/media/platform/blackfin/bfin_capture.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/media/platform/blackfin/bfin_capture.c +13 -3
index c6d8b95..2c720bc 100644
@@ -345,6 +345,7 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
 {
 	struct bcap_device *bcap_dev = vb2_get_drv_priv(vq);
 	struct ppi_if *ppi = bcap_dev->ppi;
+	struct bcap_buffer *buf, *tmp;
 	struct ppi_params params;
 	int ret;
 
@@ -352,7 +353,7 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
 	ret = v4l2_subdev_call(bcap_dev->sd, video, s_stream, 1);
 	if (ret && (ret != -ENOIOCTLCMD)) {
 		v4l2_err(&bcap_dev->v4l2_dev, "stream on failed in subdev\n");
-		return ret;
+		goto err;
 	}
 
 	/* set ppi params */
@@ -391,7 +392,7 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
 	if (ret < 0) {
 		v4l2_err(&bcap_dev->v4l2_dev,
 				"Error in setting ppi params\n");
-		return ret;
+		goto err;
 	}
 
 	/* attach ppi DMA irq handler */
@@ -399,12 +400,21 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
 	if (ret < 0) {
 		v4l2_err(&bcap_dev->v4l2_dev,
 				"Error in attaching interrupt handler\n");
-		return ret;
+		goto err;
 	}
 
 	reinit_completion(&bcap_dev->comp);
 	bcap_dev->stop = false;
+
 	return 0;
+
+err:
+	list_for_each_entry_safe(buf, tmp, &bcap_dev->dma_queue, list) {
+		list_del(&buf->list);
+		vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED);
+	}
+
+	return ret;
 }
 
 static void bcap_stop_streaming(struct vb2_queue *vq)
Signature · 1 line
2.1.0
#3 lore raw

PATCH v4 3/17 media: blackfin: bfin_capture: set min_buffers_needed

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch sets the min_buffers_needed field of the vb2 queue so that the vb2 core will make sure start_streaming() callback is called only when we have minimum buffers queued.

---
 drivers/media/platform/blackfin/bfin_capture.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/blackfin/bfin_capture.c +1 -0
index 2c720bc..332f8c9 100644
@@ -986,6 +986,7 @@ static int bcap_probe(struct platform_device *pdev)
 	q->mem_ops = &vb2_dma_contig_memops;
 	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 	q->lock = &bcap_dev->mutex;
+	q->min_buffers_needed = 1;
 
 	ret = vb2_queue_init(q);
 	if (ret)
Signature · 1 line
2.1.0
#4 lore raw

PATCH v4 4/17 media: blackfin: bfin_capture: set vb2 buffer field

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

set the vb2 buffer field in buf_prepare() callback, alongside drop local variable buf as we already have a pointer to vb2 buffer.

---
 drivers/media/platform/blackfin/bfin_capture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/platform/blackfin/bfin_capture.c +4 -4
index 332f8c9..a588129 100644
@@ -305,16 +305,16 @@ static int bcap_queue_setup(struct vb2_queue *vq,
 static int bcap_buffer_prepare(struct vb2_buffer *vb)
 {
 	struct bcap_device *bcap_dev = vb2_get_drv_priv(vb->vb2_queue);
-	struct bcap_buffer *buf = to_bcap_vb(vb);
-	unsigned long size;
+	unsigned long size = bcap_dev->fmt.sizeimage;
 
-	size = bcap_dev->fmt.sizeimage;
 	if (vb2_plane_size(vb, 0) < size) {
 		v4l2_err(&bcap_dev->v4l2_dev, "buffer too small (%lu < %lu)\n",
 				vb2_plane_size(vb, 0), size);
 		return -EINVAL;
 	}
-	vb2_set_plane_payload(&buf->vb, 0, size);
+	vb2_set_plane_payload(vb, 0, size);
+
+	vb->v4l2_buf.field = bcap_dev->fmt.field;
 
 	return 0;
 }
Signature · 1 line
2.1.0
#5 lore raw

PATCH v4 5/17 media: blackfin: bfin_capture: improve queue_setup() callback

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

This patch does the following:
a: returns -EINVAL in case format image size is less
then current image size.
b: assigns nbuffers to two in case the total of vq->num_buffers
and nbuffers is less then the number of buffers required by driver.
c: sets the sizes[0] of plane according to the fmt passed or which is
being set in the device.

---
 drivers/media/platform/blackfin/bfin_capture.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/media/platform/blackfin/bfin_capture.c +6 -4
index a588129..bf7e999 100644
@@ -44,7 +44,6 @@
 #include <media/blackfin/ppi.h>
 
 #define CAPTURE_DRV_NAME        "bfin_capture"
-#define BCAP_MIN_NUM_BUF        2
 
 struct bcap_format {
 	char *desc;
@@ -292,11 +291,14 @@ static int bcap_queue_setup(struct vb2_queue *vq,
 {
 	struct bcap_device *bcap_dev = vb2_get_drv_priv(vq);
 
-	if (*nbuffers < BCAP_MIN_NUM_BUF)
-		*nbuffers = BCAP_MIN_NUM_BUF;
+	if (fmt && fmt->fmt.pix.sizeimage < bcap_dev->fmt.sizeimage)
+		return -EINVAL;
+
+	if (vq->num_buffers + *nbuffers < 2)
+		*nbuffers = 2;
 
 	*nplanes = 1;
-	sizes[0] = bcap_dev->fmt.sizeimage;
+	sizes[0] = fmt ? fmt->fmt.pix.sizeimage : bcap_dev->fmt.sizeimage;
 	alloc_ctxs[0] = bcap_dev->alloc_ctx;
 
 	return 0;
Signature · 1 line
2.1.0
#6 lore raw

PATCH v4 6/17 media: blackfin: bfin_capture: use vb2_fop_mmap/poll

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

No need to reinvent the wheel. Just use the already existing functions provided by vb2.

---
 drivers/media/platform/blackfin/bfin_capture.c | 28 +++-----------------------
 1 file changed, 3 insertions(+), 25 deletions(-)
drivers/media/platform/blackfin/bfin_capture.c +3 -25
index bf7e999..84827d2 100644
@@ -244,18 +244,6 @@ static int bcap_release(struct file *file)
 	return 0;
 }
 
-static int bcap_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-	int ret;
-
-	if (mutex_lock_interruptible(&bcap_dev->mutex))
-		return -ERESTARTSYS;
-	ret = vb2_mmap(&bcap_dev->buffer_queue, vma);
-	mutex_unlock(&bcap_dev->mutex);
-	return ret;
-}
-
 #ifndef CONFIG_MMU
 static unsigned long bcap_get_unmapped_area(struct file *file,
 					    unsigned long addr,
@@ -273,17 +261,6 @@ static unsigned long bcap_get_unmapped_area(struct file *file,
 }
 #endif
 
-static unsigned int bcap_poll(struct file *file, poll_table *wait)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-	unsigned int res;
-
-	mutex_lock(&bcap_dev->mutex);
-	res = vb2_poll(&bcap_dev->buffer_queue, file, wait);
-	mutex_unlock(&bcap_dev->mutex);
-	return res;
-}
-
 static int bcap_queue_setup(struct vb2_queue *vq,
 				const struct v4l2_format *fmt,
 				unsigned int *nbuffers, unsigned int *nplanes,
@@ -900,11 +877,11 @@ static struct v4l2_file_operations bcap_fops = {
 	.open = bcap_open,
 	.release = bcap_release,
 	.unlocked_ioctl = video_ioctl2,
-	.mmap = bcap_mmap,
+	.mmap = vb2_fop_mmap,
 #ifndef CONFIG_MMU
 	.get_unmapped_area = bcap_get_unmapped_area,
 #endif
-	.poll = bcap_poll
+	.poll = vb2_fop_poll
 };
 
 static int bcap_probe(struct platform_device *pdev)
@@ -1001,6 +978,7 @@ static int bcap_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&bcap_dev->dma_queue);
 
 	vfd->lock = &bcap_dev->mutex;
+	vfd->queue = q;
 
 	/* register video device */
 	ret = video_register_device(bcap_dev->video_dev, VFL_TYPE_GRABBER, -1);
Signature · 1 line
2.1.0
#7 lore raw

PATCH v4 7/17 media: blackfin: bfin_capture: use v4l2_fh_open and vb2_fop_release

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch adds support to use v4l2_fh_open() and vb2_fop_release, which allows to drop driver specific struct bcap_fh, as this is handled by core.

---
 drivers/media/platform/blackfin/bfin_capture.c | 79 +-------------------------
 1 file changed, 2 insertions(+), 77 deletions(-)
drivers/media/platform/blackfin/bfin_capture.c +2 -77
index 84827d2..01e778d 100644
@@ -105,12 +105,6 @@ struct bcap_device {
 	bool stop;
 };
 
-struct bcap_fh {
-	struct v4l2_fh fh;
-	/* indicates whether this file handle is doing IO */
-	bool io_allowed;
-};
-
 static const struct bcap_format bcap_formats[] = {
 	{
 		.desc        = "YCbCr 4:2:2 Interleaved UYVY",
@@ -200,50 +194,6 @@ static void bcap_free_sensor_formats(struct bcap_device *bcap_dev)
 	bcap_dev->sensor_formats = NULL;
 }
 
-static int bcap_open(struct file *file)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-	struct video_device *vfd = bcap_dev->video_dev;
-	struct bcap_fh *bcap_fh;
-
-	if (!bcap_dev->sd) {
-		v4l2_err(&bcap_dev->v4l2_dev, "No sub device registered\n");
-		return -ENODEV;
-	}
-
-	bcap_fh = kzalloc(sizeof(*bcap_fh), GFP_KERNEL);
-	if (!bcap_fh) {
-		v4l2_err(&bcap_dev->v4l2_dev,
-			 "unable to allocate memory for file handle object\n");
-		return -ENOMEM;
-	}
-
-	v4l2_fh_init(&bcap_fh->fh, vfd);
-
-	/* store pointer to v4l2_fh in private_data member of file */
-	file->private_data = &bcap_fh->fh;
-	v4l2_fh_add(&bcap_fh->fh);
-	bcap_fh->io_allowed = false;
-	return 0;
-}
-
-static int bcap_release(struct file *file)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-	struct v4l2_fh *fh = file->private_data;
-	struct bcap_fh *bcap_fh = container_of(fh, struct bcap_fh, fh);
-
-	/* if this instance is doing IO */
-	if (bcap_fh->io_allowed)
-		vb2_queue_release(&bcap_dev->buffer_queue);
-
-	file->private_data = NULL;
-	v4l2_fh_del(&bcap_fh->fh);
-	v4l2_fh_exit(&bcap_fh->fh);
-	kfree(bcap_fh);
-	return 0;
-}
-
 #ifndef CONFIG_MMU
 static unsigned long bcap_get_unmapped_area(struct file *file,
 					    unsigned long addr,
@@ -436,13 +386,6 @@ static int bcap_reqbufs(struct file *file, void *priv,
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
 	struct vb2_queue *vq = &bcap_dev->buffer_queue;
-	struct v4l2_fh *fh = file->private_data;
-	struct bcap_fh *bcap_fh = container_of(fh, struct bcap_fh, fh);
-
-	if (vb2_is_busy(vq))
-		return -EBUSY;
-
-	bcap_fh->io_allowed = true;
 
 	return vb2_reqbufs(vq, req_buf);
 }
@@ -459,11 +402,6 @@ static int bcap_qbuf(struct file *file, void *priv,
 			struct v4l2_buffer *buf)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
-	struct v4l2_fh *fh = file->private_data;
-	struct bcap_fh *bcap_fh = container_of(fh, struct bcap_fh, fh);
-
-	if (!bcap_fh->io_allowed)
-		return -EBUSY;
 
 	return vb2_qbuf(&bcap_dev->buffer_queue, buf);
 }
@@ -472,11 +410,6 @@ static int bcap_dqbuf(struct file *file, void *priv,
 			struct v4l2_buffer *buf)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
-	struct v4l2_fh *fh = file->private_data;
-	struct bcap_fh *bcap_fh = container_of(fh, struct bcap_fh, fh);
-
-	if (!bcap_fh->io_allowed)
-		return -EBUSY;
 
 	return vb2_dqbuf(&bcap_dev->buffer_queue,
 				buf, file->f_flags & O_NONBLOCK);
@@ -527,14 +460,10 @@ static int bcap_streamon(struct file *file, void *priv,
 				enum v4l2_buf_type buf_type)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
-	struct bcap_fh *fh = file->private_data;
 	struct ppi_if *ppi = bcap_dev->ppi;
 	dma_addr_t addr;
 	int ret;
 
-	if (!fh->io_allowed)
-		return -EBUSY;
-
 	/* call streamon to start streaming in videobuf */
 	ret = vb2_streamon(&bcap_dev->buffer_queue, buf_type);
 	if (ret)
@@ -568,10 +497,6 @@ static int bcap_streamoff(struct file *file, void *priv,
 				enum v4l2_buf_type buf_type)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
-	struct bcap_fh *fh = file->private_data;
-
-	if (!fh->io_allowed)
-		return -EBUSY;
 
 	return vb2_streamoff(&bcap_dev->buffer_queue, buf_type);
 }
@@ -874,8 +799,8 @@ static const struct v4l2_ioctl_ops bcap_ioctl_ops = {
 
 static struct v4l2_file_operations bcap_fops = {
 	.owner = THIS_MODULE,
-	.open = bcap_open,
-	.release = bcap_release,
+	.open = v4l2_fh_open,
+	.release = vb2_fop_release,
 	.unlocked_ioctl = video_ioctl2,
 	.mmap = vb2_fop_mmap,
 #ifndef CONFIG_MMU
Signature · 1 line
2.1.0
#8 lore raw

PATCH v4 8/17 media: blackfin: bfin_capture: use vb2_ioctl_* helpers

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch adds support to vb2_ioctl_* helpers.

---
 drivers/media/platform/blackfin/bfin_capture.c | 103 +++++--------------------
 1 file changed, 18 insertions(+), 85 deletions(-)
drivers/media/platform/blackfin/bfin_capture.c +18 -85
index 01e778d..2a9e933 100644
@@ -276,6 +276,7 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
 	struct ppi_if *ppi = bcap_dev->ppi;
 	struct bcap_buffer *buf, *tmp;
 	struct ppi_params params;
+	dma_addr_t addr;
 	int ret;
 
 	/* enable streamon on the sub device */
@@ -335,6 +336,17 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
 	reinit_completion(&bcap_dev->comp);
 	bcap_dev->stop = false;
 
+	/* get the next frame from the dma queue */
+	bcap_dev->cur_frm = list_entry(bcap_dev->dma_queue.next,
+					struct bcap_buffer, list);
+	/* remove buffer from the dma queue */
+	list_del_init(&bcap_dev->cur_frm->list);
+	addr = vb2_dma_contig_plane_dma_addr(&bcap_dev->cur_frm->vb, 0);
+	/* update DMA address */
+	ppi->ops->update_addr(ppi, (unsigned long)addr);
+	/* enable ppi */
+	ppi->ops->start(ppi);
+
 	return 0;
 
 err:
@@ -381,40 +393,6 @@ static struct vb2_ops bcap_video_qops = {
 	.stop_streaming         = bcap_stop_streaming,
 };
 
-static int bcap_reqbufs(struct file *file, void *priv,
-			struct v4l2_requestbuffers *req_buf)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-	struct vb2_queue *vq = &bcap_dev->buffer_queue;
-
-	return vb2_reqbufs(vq, req_buf);
-}
-
-static int bcap_querybuf(struct file *file, void *priv,
-				struct v4l2_buffer *buf)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-
-	return vb2_querybuf(&bcap_dev->buffer_queue, buf);
-}
-
-static int bcap_qbuf(struct file *file, void *priv,
-			struct v4l2_buffer *buf)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-
-	return vb2_qbuf(&bcap_dev->buffer_queue, buf);
-}
-
-static int bcap_dqbuf(struct file *file, void *priv,
-			struct v4l2_buffer *buf)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-
-	return vb2_dqbuf(&bcap_dev->buffer_queue,
-				buf, file->f_flags & O_NONBLOCK);
-}
-
 static irqreturn_t bcap_isr(int irq, void *dev_id)
 {
 	struct ppi_if *ppi = dev_id;
@@ -456,51 +434,6 @@ static irqreturn_t bcap_isr(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int bcap_streamon(struct file *file, void *priv,
-				enum v4l2_buf_type buf_type)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-	struct ppi_if *ppi = bcap_dev->ppi;
-	dma_addr_t addr;
-	int ret;
-
-	/* call streamon to start streaming in videobuf */
-	ret = vb2_streamon(&bcap_dev->buffer_queue, buf_type);
-	if (ret)
-		return ret;
-
-	/* if dma queue is empty, return error */
-	if (list_empty(&bcap_dev->dma_queue)) {
-		v4l2_err(&bcap_dev->v4l2_dev, "dma queue is empty\n");
-		ret = -EINVAL;
-		goto err;
-	}
-
-	/* get the next frame from the dma queue */
-	bcap_dev->cur_frm = list_entry(bcap_dev->dma_queue.next,
-					struct bcap_buffer, list);
-	/* remove buffer from the dma queue */
-	list_del_init(&bcap_dev->cur_frm->list);
-	addr = vb2_dma_contig_plane_dma_addr(&bcap_dev->cur_frm->vb, 0);
-	/* update DMA address */
-	ppi->ops->update_addr(ppi, (unsigned long)addr);
-	/* enable ppi */
-	ppi->ops->start(ppi);
-
-	return 0;
-err:
-	vb2_streamoff(&bcap_dev->buffer_queue, buf_type);
-	return ret;
-}
-
-static int bcap_streamoff(struct file *file, void *priv,
-				enum v4l2_buf_type buf_type)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-
-	return vb2_streamoff(&bcap_dev->buffer_queue, buf_type);
-}
-
 static int bcap_querystd(struct file *file, void *priv, v4l2_std_id *std)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
@@ -786,12 +719,12 @@ static const struct v4l2_ioctl_ops bcap_ioctl_ops = {
 	.vidioc_g_dv_timings     = bcap_g_dv_timings,
 	.vidioc_query_dv_timings = bcap_query_dv_timings,
 	.vidioc_enum_dv_timings  = bcap_enum_dv_timings,
-	.vidioc_reqbufs          = bcap_reqbufs,
-	.vidioc_querybuf         = bcap_querybuf,
-	.vidioc_qbuf             = bcap_qbuf,
-	.vidioc_dqbuf            = bcap_dqbuf,
-	.vidioc_streamon         = bcap_streamon,
-	.vidioc_streamoff        = bcap_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           = bcap_g_parm,
 	.vidioc_s_parm           = bcap_s_parm,
 	.vidioc_log_status       = bcap_log_status,
Signature · 1 line
2.1.0
#9 lore raw

PATCH v4 9/17 media: blackfin: bfin_capture: make sure all buffers are returned on stop_streaming() callback

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

In start_streaming() callback the buffer is removed from the dma_queue list and assigned to cur_frm, this patch makes sure that is returned to vb2 core with VB2_BUF_STATE_ERROR flag.

---
 drivers/media/platform/blackfin/bfin_capture.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/media/platform/blackfin/bfin_capture.c +3 -0
index 2a9e933..f2b1a23 100644
@@ -374,6 +374,9 @@ static void bcap_stop_streaming(struct vb2_queue *vq)
 				"stream off failed in subdev\n");
 
 	/* release all active buffers */
+	if (bcap_dev->cur_frm)
+		vb2_buffer_done(&bcap_dev->cur_frm->vb, VB2_BUF_STATE_ERROR);
+
 	while (!list_empty(&bcap_dev->dma_queue)) {
 		bcap_dev->cur_frm = list_entry(bcap_dev->dma_queue.next,
 						struct bcap_buffer, list);
Signature · 1 line
2.1.0
#10 lore raw

PATCH v4 10/17 media: blackfin: bfin_capture: return -ENODATA for *std calls

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch adds supports to return -ENODATA to *_std calls if the selected output does not support it.

---
 drivers/media/platform/blackfin/bfin_capture.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/media/platform/blackfin/bfin_capture.c +15 -0
index f2b1a23..f97d94d 100644
@@ -440,6 +440,11 @@ static irqreturn_t bcap_isr(int irq, void *dev_id)
 static int bcap_querystd(struct file *file, void *priv, v4l2_std_id *std)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
+	struct v4l2_input input;
+
+	input = bcap_dev->cfg->inputs[bcap_dev->cur_input];
+	if (!(input.capabilities & V4L2_IN_CAP_STD))
+		return -ENODATA;
 
 	return v4l2_subdev_call(bcap_dev->sd, video, querystd, std);
 }
@@ -447,6 +452,11 @@ static int bcap_querystd(struct file *file, void *priv, v4l2_std_id *std)
 static int bcap_g_std(struct file *file, void *priv, v4l2_std_id *std)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
+	struct v4l2_input input;
+
+	input = bcap_dev->cfg->inputs[bcap_dev->cur_input];
+	if (!(input.capabilities & V4L2_IN_CAP_STD))
+		return -ENODATA;
 
 	*std = bcap_dev->std;
 	return 0;
@@ -455,8 +465,13 @@ static int bcap_g_std(struct file *file, void *priv, v4l2_std_id *std)
 static int bcap_s_std(struct file *file, void *priv, v4l2_std_id std)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
+	struct v4l2_input input;
 	int ret;
 
+	input = bcap_dev->cfg->inputs[bcap_dev->cur_input];
+	if (!(input.capabilities & V4L2_IN_CAP_STD))
+		return -ENODATA;
+
 	if (vb2_is_busy(&bcap_dev->buffer_queue))
 		return -EBUSY;
 
Signature · 1 line
2.1.0
#11 lore raw

PATCH v4 11/17 media: blackfin: bfin_capture: return -ENODATA for *dv_timings calls

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch adds support to return -ENODATA for *dv_timings calls if the current output does not support it.

---
 drivers/media/platform/blackfin/bfin_capture.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/media/platform/blackfin/bfin_capture.c +21 -0
index f97d94d..2dead84 100644
@@ -487,6 +487,11 @@ static int bcap_enum_dv_timings(struct file *file, void *priv,
 				struct v4l2_enum_dv_timings *timings)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
+	struct v4l2_input input;
+
+	input = bcap_dev->cfg->inputs[bcap_dev->cur_input];
+	if (!(input.capabilities & V4L2_IN_CAP_DV_TIMINGS))
+		return -ENODATA;
 
 	timings->pad = 0;
 
@@ -498,6 +503,11 @@ static int bcap_query_dv_timings(struct file *file, void *priv,
 				struct v4l2_dv_timings *timings)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
+	struct v4l2_input input;
+
+	input = bcap_dev->cfg->inputs[bcap_dev->cur_input];
+	if (!(input.capabilities & V4L2_IN_CAP_DV_TIMINGS))
+		return -ENODATA;
 
 	return v4l2_subdev_call(bcap_dev->sd, video,
 				query_dv_timings, timings);
@@ -507,6 +517,11 @@ static int bcap_g_dv_timings(struct file *file, void *priv,
 				struct v4l2_dv_timings *timings)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
+	struct v4l2_input input;
+
+	input = bcap_dev->cfg->inputs[bcap_dev->cur_input];
+	if (!(input.capabilities & V4L2_IN_CAP_DV_TIMINGS))
+		return -ENODATA;
 
 	*timings = bcap_dev->dv_timings;
 	return 0;
@@ -516,7 +531,13 @@ static int bcap_s_dv_timings(struct file *file, void *priv,
 				struct v4l2_dv_timings *timings)
 {
 	struct bcap_device *bcap_dev = video_drvdata(file);
+	struct v4l2_input input;
 	int ret;
+
+	input = bcap_dev->cfg->inputs[bcap_dev->cur_input];
+	if (!(input.capabilities & V4L2_IN_CAP_DV_TIMINGS))
+		return -ENODATA;
+
 	if (vb2_is_busy(&bcap_dev->buffer_queue))
 		return -EBUSY;
 
Signature · 1 line
2.1.0
#12 lore raw

PATCH v4 12/17 media: blackfin: bfin_capture: add support for vidioc_create_bufs

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch adds support for vidioc_create_bufs.

---
 drivers/media/platform/blackfin/bfin_capture.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/blackfin/bfin_capture.c +1 -0
index 2dead84..ec8227f 100644
@@ -759,6 +759,7 @@ static const struct v4l2_ioctl_ops bcap_ioctl_ops = {
 	.vidioc_query_dv_timings = bcap_query_dv_timings,
 	.vidioc_enum_dv_timings  = bcap_enum_dv_timings,
 	.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,
Signature · 1 line
2.1.0
#13 lore raw

PATCH v4 13/17 media: blackfin: bfin_capture: add support for VB2_DMABUF

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch adds support for VB2_DMABUF.

---
 drivers/media/platform/blackfin/bfin_capture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/blackfin/bfin_capture.c +1 -1
index ec8227f..6c58cea 100644
@@ -856,7 +856,7 @@ static int bcap_probe(struct platform_device *pdev)
 	/* initialize queue */
 	q = &bcap_dev->buffer_queue;
 	q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-	q->io_modes = VB2_MMAP;
+	q->io_modes = VB2_MMAP | VB2_DMABUF;
 	q->drv_priv = bcap_dev;
 	q->buf_struct_size = sizeof(struct bcap_buffer);
 	q->ops = &bcap_video_qops;
Signature · 1 line
2.1.0
#14 lore raw

PATCH v4 14/17 media: blackfin: bfin_capture: add support for VIDIOC_EXPBUF

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch adds support for VIDIOC_EXPBUF.

---
 drivers/media/platform/blackfin/bfin_capture.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/blackfin/bfin_capture.c +1 -0
index 6c58cea..c3ede0d 100644
@@ -763,6 +763,7 @@ static const struct v4l2_ioctl_ops bcap_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           = bcap_g_parm,
Signature · 1 line
2.1.0
#15 lore raw

PATCH v4 15/17 media: blackfin: bfin_capture: set v4l2 buffer sequence

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch adds support to set the v4l2 buffer sequence.

---
 drivers/media/platform/blackfin/bfin_capture.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/media/platform/blackfin/bfin_capture.c +5 -0
index c3ede0d..306798e 100644
@@ -103,6 +103,8 @@ struct bcap_device {
 	struct completion comp;
 	/* prepare to stop */
 	bool stop;
+	/* vb2 buffer sequence counter */
+	unsigned sequence;
 };
 
 static const struct bcap_format bcap_formats[] = {
@@ -333,6 +335,8 @@ static int bcap_start_streaming(struct vb2_queue *vq, unsigned int count)
 		goto err;
 	}
 
+	bcap_dev->sequence = 0;
+
 	reinit_completion(&bcap_dev->comp);
 	bcap_dev->stop = false;
 
@@ -411,6 +415,7 @@ static irqreturn_t bcap_isr(int irq, void *dev_id)
 			vb2_buffer_done(vb, VB2_BUF_STATE_ERROR);
 			ppi->err = false;
 		} else {
+			vb->v4l2_buf.sequence = bcap_dev->sequence++;
 			vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
 		}
 		bcap_dev->cur_frm = list_entry(bcap_dev->dma_queue.next,
Signature · 1 line
2.1.0
#16 lore raw

PATCH v4 16/17 media: blackfin: bfin_capture: drop bcap_get_unmapped_area()

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

this patch drops bcap_get_unmapped_area() and uses vb2_fop_get_unmapped_area() helper provided by the vb2 core.

---
 drivers/media/platform/blackfin/bfin_capture.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)
drivers/media/platform/blackfin/bfin_capture.c +1 -18
index 306798e..d390f7c 100644
@@ -196,23 +196,6 @@ static void bcap_free_sensor_formats(struct bcap_device *bcap_dev)
 	bcap_dev->sensor_formats = NULL;
 }
 
-#ifndef CONFIG_MMU
-static unsigned long bcap_get_unmapped_area(struct file *file,
-					    unsigned long addr,
-					    unsigned long len,
-					    unsigned long pgoff,
-					    unsigned long flags)
-{
-	struct bcap_device *bcap_dev = video_drvdata(file);
-
-	return vb2_get_unmapped_area(&bcap_dev->buffer_queue,
-				     addr,
-				     len,
-				     pgoff,
-				     flags);
-}
-#endif
-
 static int bcap_queue_setup(struct vb2_queue *vq,
 				const struct v4l2_format *fmt,
 				unsigned int *nbuffers, unsigned int *nplanes,
@@ -783,7 +766,7 @@ static struct v4l2_file_operations bcap_fops = {
 	.unlocked_ioctl = video_ioctl2,
 	.mmap = vb2_fop_mmap,
 #ifndef CONFIG_MMU
-	.get_unmapped_area = bcap_get_unmapped_area,
+	.get_unmapped_area = vb2_fop_get_unmapped_area,
 #endif
 	.poll = vb2_fop_poll
 };
Signature · 1 line
2.1.0
#17 lore raw

PATCH v4 17/17 media: blackfin: bfin_capture: embed video_device struct in bcap_device

In reply to Lad Prabhakar

From: "Lad, Prabhakar" <[email protected]>

Embed video_device struct (video_dev) in bcap_device and Unregister path doesn't need to free the video_device structure, hence, change the video_device.release callback point to video_device_release_empty.

---
 drivers/media/platform/blackfin/bfin_capture.c | 27 ++++++++------------------
 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/media/platform/blackfin/bfin_capture.c +8 -19
index d390f7c..6a437f8 100644
@@ -64,7 +64,7 @@ struct bcap_device {
 	/* v4l2 control handler */
 	struct v4l2_ctrl_handler ctrl_handler;
 	/* device node data */
-	struct video_device *video_dev;
+	struct video_device video_dev;
 	/* sub device instance */
 	struct v4l2_subdev *sd;
 	/* capture config */
@@ -809,27 +809,20 @@ static int bcap_probe(struct platform_device *pdev)
 		goto err_free_ppi;
 	}
 
-	vfd = video_device_alloc();
-	if (!vfd) {
-		ret = -ENOMEM;
-		v4l2_err(pdev->dev.driver, "Unable to alloc video device\n");
-		goto err_cleanup_ctx;
-	}
-
+	vfd = &bcap_dev->video_dev;
 	/* initialize field of video device */
-	vfd->release            = video_device_release;
+	vfd->release            = video_device_release_empty;
 	vfd->fops               = &bcap_fops;
 	vfd->ioctl_ops          = &bcap_ioctl_ops;
 	vfd->tvnorms            = 0;
 	vfd->v4l2_dev           = &bcap_dev->v4l2_dev;
 	strncpy(vfd->name, CAPTURE_DRV_NAME, sizeof(vfd->name));
-	bcap_dev->video_dev     = vfd;
 
 	ret = v4l2_device_register(&pdev->dev, &bcap_dev->v4l2_dev);
 	if (ret) {
 		v4l2_err(pdev->dev.driver,
 				"Unable to register v4l2 device\n");
-		goto err_release_vdev;
+		goto err_cleanup_ctx;
 	}
 	v4l2_info(&bcap_dev->v4l2_dev, "v4l2 device registered\n");
 
@@ -868,13 +861,13 @@ static int bcap_probe(struct platform_device *pdev)
 	vfd->queue = q;
 
 	/* register video device */
-	ret = video_register_device(bcap_dev->video_dev, VFL_TYPE_GRABBER, -1);
+	ret = video_register_device(&bcap_dev->video_dev, VFL_TYPE_GRABBER, -1);
 	if (ret) {
 		v4l2_err(&bcap_dev->v4l2_dev,
 				"Unable to register video device\n");
 		goto err_free_handler;
 	}
-	video_set_drvdata(bcap_dev->video_dev, bcap_dev);
+	video_set_drvdata(&bcap_dev->video_dev, bcap_dev);
 	v4l2_info(&bcap_dev->v4l2_dev, "video device registered as: %s\n",
 			video_device_node_name(vfd));
 
@@ -952,15 +945,11 @@ static int bcap_probe(struct platform_device *pdev)
 	}
 	return 0;
 err_unreg_vdev:
-	video_unregister_device(bcap_dev->video_dev);
-	bcap_dev->video_dev = NULL;
+	video_unregister_device(&bcap_dev->video_dev);
 err_free_handler:
 	v4l2_ctrl_handler_free(&bcap_dev->ctrl_handler);
 err_unreg_v4l2:
 	v4l2_device_unregister(&bcap_dev->v4l2_dev);
-err_release_vdev:
-	if (bcap_dev->video_dev)
-		video_device_release(bcap_dev->video_dev);
 err_cleanup_ctx:
 	vb2_dma_contig_cleanup_ctx(bcap_dev->alloc_ctx);
 err_free_ppi:
@@ -977,7 +966,7 @@ static int bcap_remove(struct platform_device *pdev)
 						struct bcap_device, v4l2_dev);
 
 	bcap_free_sensor_formats(bcap_dev);
-	video_unregister_device(bcap_dev->video_dev);
+	video_unregister_device(&bcap_dev->video_dev);
 	v4l2_ctrl_handler_free(&bcap_dev->ctrl_handler);
 	v4l2_device_unregister(v4l2_dev);
 	vb2_dma_contig_cleanup_ctx(bcap_dev->alloc_ctx);
Signature · 1 line
2.1.0
Acked-by Tested-by on the v4 series
#18 lore raw
In reply to Lad Prabhakar

Hi Lad and Hans,

2015-03-08 22:40 GMT+08:00 Lad Prabhakar <[email protected]>:

Quoted 32 lines

From: "Lad, Prabhakar" <[email protected]>

This patch series, enhances blackfin capture driver with vb2 helpers.

Changes for v4:
1: Improved commit message for path 4/17 and 5/17. 2: Added Ack's from Scott to patches 1-15 3: Two new patches 16/17 and 17/17

Lad, Prabhakar (17):
media: blackfin: bfin_capture: drop buf_init() callback
media: blackfin: bfin_capture: release buffers in case
start_streaming() call back fails
media: blackfin: bfin_capture: set min_buffers_needed
media: blackfin: bfin_capture: set vb2 buffer field
media: blackfin: bfin_capture: improve queue_setup() callback
media: blackfin: bfin_capture: use vb2_fop_mmap/poll
media: blackfin: bfin_capture: use v4l2_fh_open and vb2_fop_release
media: blackfin: bfin_capture: use vb2_ioctl_* helpers
media: blackfin: bfin_capture: make sure all buffers are returned on
stop_streaming() callback
media: blackfin: bfin_capture: return -ENODATA for *std calls
media: blackfin: bfin_capture: return -ENODATA for *dv_timings calls
media: blackfin: bfin_capture: add support for vidioc_create_bufs
media: blackfin: bfin_capture: add support for VB2_DMABUF
media: blackfin: bfin_capture: add support for VIDIOC_EXPBUF
media: blackfin: bfin_capture: set v4l2 buffer sequence
media: blackfin: bfin_capture: drop bcap_get_unmapped_area()
media: blackfin: bfin_capture: embed video_device struct in
bcap_device

Quoted 3 lines
 drivers/media/platform/blackfin/bfin_capture.c | 348 ++++++++-----------------
 1 file changed, 103 insertions(+), 245 deletions(-)

for patch 16/17,

Hans, I tried to use v4l2-compliance but it failed to compile. Sorry for telling you it have passed compilation because I forgot to use blackfin toolchain.
./configure --without-jpeg --host=bfin-linux-uclibc --disable-libv4l

The main problem is there is no argp.h in uClibc, how to disable checking this?

checking for argp.h... no
configure: error: Cannot continue: argp.h not found

Scott

#19 lore raw
Quoted 48 lines · Scott Jiang

Hi Lad and Hans,

2015-03-08 22:40 GMT+08:00 Lad Prabhakar <[email protected]>:

Quoted 32 lines

From: "Lad, Prabhakar" <[email protected]>

This patch series, enhances blackfin capture driver with vb2 helpers.

Changes for v4:
1: Improved commit message for path 4/17 and 5/17. 2: Added Ack's from Scott to patches 1-15 3: Two new patches 16/17 and 17/17

Lad, Prabhakar (17):
media: blackfin: bfin_capture: drop buf_init() callback
media: blackfin: bfin_capture: release buffers in case
start_streaming() call back fails
media: blackfin: bfin_capture: set min_buffers_needed
media: blackfin: bfin_capture: set vb2 buffer field
media: blackfin: bfin_capture: improve queue_setup() callback
media: blackfin: bfin_capture: use vb2_fop_mmap/poll
media: blackfin: bfin_capture: use v4l2_fh_open and vb2_fop_release
media: blackfin: bfin_capture: use vb2_ioctl_* helpers
media: blackfin: bfin_capture: make sure all buffers are returned on
stop_streaming() callback
media: blackfin: bfin_capture: return -ENODATA for *std calls
media: blackfin: bfin_capture: return -ENODATA for *dv_timings calls
media: blackfin: bfin_capture: add support for vidioc_create_bufs
media: blackfin: bfin_capture: add support for VB2_DMABUF
media: blackfin: bfin_capture: add support for VIDIOC_EXPBUF
media: blackfin: bfin_capture: set v4l2 buffer sequence
media: blackfin: bfin_capture: drop bcap_get_unmapped_area()
media: blackfin: bfin_capture: embed video_device struct in
bcap_device

Quoted 3 lines
 drivers/media/platform/blackfin/bfin_capture.c | 348 ++++++++-----------------
 1 file changed, 103 insertions(+), 245 deletions(-)

for patch 16/17,

Hans, I tried to use v4l2-compliance but it failed to compile. Sorry for telling you it have passed compilation because I forgot to use blackfin toolchain.
./configure --without-jpeg --host=bfin-linux-uclibc --disable-libv4l

Quoted 7 lines

The main problem is there is no argp.h in uClibc, how to disable checking this?

checking for argp.h... no
configure: error: Cannot continue: argp.h not found

Scott

Hi Scott,

Can you try this patch for v4l-utils? It makes argp optional, and it should allow v4l2-compliance to compile with uclibc (unless there are more problems).

I'm no autoconf guru, so I'm not certain if everything is correct, but it seemed to do its job when I remove argp.h from my system.

Regards,

Hans

---

configure.ac +5 -2
index 330479c..0bf9154 100644
@@ -253,14 +253,17 @@ dl_saved_libs=$LIBS
   AC_SUBST([DLOPEN_LIBS])
 LIBS=$dl_saved_libs
 
-AC_CHECK_HEADER([argp.h],,AC_MSG_ERROR(Cannot continue: argp.h not found))
+#AC_CHECK_HEADER([argp.h],,AC_MSG_ERROR(Cannot continue: argp.h not found))
+AC_CHECK_HEADER([argp.h], [argp=yes], [argp=no])
+AS_IF([test "x$argp" = "xyes"],
 argp_saved_libs=$LIBS
   AC_SEARCH_LIBS([argp_parse],
                  [argp],
                  [test "$ac_cv_search_argp_parse" = "none required" || ARGP_LIBS=$ac_cv_search_argp_parse],
                  [AC_MSG_ERROR([unable to find the argp_parse() function])])
   AC_SUBST([ARGP_LIBS])
-LIBS=$argp_saved_libs
+LIBS=$argp_saved_libs)
+AM_CONDITIONAL([HAVE_ARGP], [test x$argp = xyes])
 
 AC_CHECK_HEADER([linux/i2c-dev.h], [linux_i2c_dev=yes], [linux_i2c_dev=no])
 AM_CONDITIONAL([HAVE_LINUX_I2C_DEV], [test x$linux_i2c_dev = xyes])
contrib/test/Makefile.am +3 -1
index 0bfa33e..f87ed3e 100644
@@ -2,7 +2,6 @@ noinst_PROGRAMS = \
 	ioctl-test		\
 	sliced-vbi-test		\
 	sliced-vbi-detect	\
-	v4l2grab		\
 	driver-test		\
 	stress-buffer		\
 	capture-example
@@ -11,9 +10,12 @@ if HAVE_X11
 noinst_PROGRAMS += pixfmt-test
 endif
 
+if HAVE_ARGP
+noinst_PROGRAMS += v4l2grab
 if HAVE_GLU
 noinst_PROGRAMS += v4l2gl
 endif
+endif
 
 driver_test_SOURCES = driver-test.c
 driver_test_LDADD = ../../utils/libv4l2util/libv4l2util.la
utils/decode_tm6000/Makefile.am +2 -0
index ac4e85e..845e35e 100644
@@ -1,4 +1,6 @@
+if HAVE_ARGP
 bin_PROGRAMS = decode_tm6000
 decode_tm6000_SOURCES = decode_tm6000.c
 decode_tm6000_LDADD = ../libv4l2util/libv4l2util.la
 decode_tm6000_LDFLAGS = $(ARGP_LIBS)
+endif
utils/dvb/Makefile.am +2 -1
index 6aae408..32c9fb9 100644
@@ -1,3 +1,4 @@
+if HAVE_ARGP
 bin_PROGRAMS = dvb-fe-tool dvbv5-zap dvbv5-scan dvb-format-convert
 man_MANS = dvb-fe-tool.1 dvbv5-zap.1 dvbv5-scan.1 dvb-format-convert.1
 
@@ -18,4 +19,4 @@ dvb_format_convert_LDADD = ../../lib/libdvbv5/libdvbv5.la
 dvb_format_convert_LDFLAGS = $(ARGP_LIBS) -lm
 
 EXTRA_DIST = README
-
+endif
utils/keytable/Makefile.am +2 -0
index f6a0773..1238e4b 100644
@@ -1,3 +1,4 @@
+if HAVE_ARGP
 bin_PROGRAMS = ir-keytable
 man_MANS = ir-keytable.1
 sysconf_DATA = rc_maps.cfg
@@ -12,6 +13,7 @@ EXTRA_DIST = 70-infrared.rules rc_keymaps gen_keytables.pl ir-keytable.1 rc_maps
 # custom target
 install-data-local:
 	$(install_sh) -d "$(DESTDIR)$(keytableuserdir)"
+endif
 
 sync-with-kernel:
 	@if [ ! -f $(KERNEL_DIR)/usr/include/linux/input.h ]; then \
utils/v4l2-sysfs-path/Makefile.am +2 -0
index 6ef4228..e72e439 100644
@@ -1,4 +1,6 @@
+if HAVE_ARGP
 bin_PROGRAMS = v4l2-sysfs-path
 v4l2_sysfs_path_SOURCES = v4l2-sysfs-path.c
 v4l2_sysfs_path_LDADD = ../libmedia_dev/libmedia_dev.la
 v4l2_sysfs_path_LDFLAGS = $(ARGP_LIBS)
+endif
#20 lore raw

Hi Hans,

Quoted 14 lines
Quoted 6 lines

Hans, I tried to use v4l2-compliance but it failed to compile. Sorry for telling you it have passed compilation because I forgot to use blackfin toolchain.
./configure --without-jpeg --host=bfin-linux-uclibc --disable-libv4l

Quoted 7 lines

The main problem is there is no argp.h in uClibc, how to disable checking this?

checking for argp.h... no
configure: error: Cannot continue: argp.h not found

Scott

Quoted 8 lines

Hi Scott,

Can you try this patch for v4l-utils? It makes argp optional, and it should allow v4l2-compliance to compile with uclibc (unless there are more problems).

I'm no autoconf guru, so I'm not certain if everything is correct, but it seemed to do its job when I remove argp.h from my system.

Yes, I can pass configure now. But there is another error when make

make[3]: Entering directory `/home/scott/projects/git-kernel/v4l-utils/lib/libdvbv5'
CC libdvbv5_la-parse_string.lo
parse_string.c:26:19: error: iconv.h: No such file or directory parse_string.c: In function 'dvb_iconv_to_charset':
parse_string.c:316: error: 'iconv_t' undeclared (first use in this function)

I tried to pass this library, while --without-libdvbv5 is not supported.

Scott

#21 lore raw
Quoted 27 lines · Scott Jiang

Hi Hans,

Quoted 14 lines
Quoted 6 lines

Hans, I tried to use v4l2-compliance but it failed to compile. Sorry for telling you it have passed compilation because I forgot to use blackfin toolchain.
./configure --without-jpeg --host=bfin-linux-uclibc --disable-libv4l

Quoted 7 lines

The main problem is there is no argp.h in uClibc, how to disable checking this?

checking for argp.h... no
configure: error: Cannot continue: argp.h not found

Scott

Quoted 8 lines

Hi Scott,

Can you try this patch for v4l-utils? It makes argp optional, and it should allow v4l2-compliance to compile with uclibc (unless there are more problems).

I'm no autoconf guru, so I'm not certain if everything is correct, but it seemed to do its job when I remove argp.h from my system.

Yes, I can pass configure now. But there is another error when make

Quoted 9 lines

make[3]: Entering directory `/home/scott/projects/git-kernel/v4l-utils/lib/libdvbv5'
CC libdvbv5_la-parse_string.lo
parse_string.c:26:19: error: iconv.h: No such file or directory parse_string.c: In function 'dvb_iconv_to_charset':
parse_string.c:316: error: 'iconv_t' undeclared (first use in this function)

I tried to pass this library, while --without-libdvbv5 is not supported.

If you can pass the configure step, then you should be able to run this:

cd utils/v4l2-compliance
cat *.cpp >x.cpp
g++ -o v4l2-compliance x.cpp -I . -I ../../include/ -DNO_LIBV4L2

(you need to use the right toolchain here, of course)

If this compiles OK, then you have a v4l2-compliance tool that you can use.

Sorry for the delay in answering.

Regards,

Hans

#22 lore raw

2015-04-24 18:04 GMT+08:00 Hans Verkuil <[email protected]>:

Quoted 40 lines · Scott Jiang
Quoted 27 lines

Hi Hans,

Quoted 14 lines
Quoted 6 lines

Hans, I tried to use v4l2-compliance but it failed to compile. Sorry for telling you it have passed compilation because I forgot to use blackfin toolchain.
./configure --without-jpeg --host=bfin-linux-uclibc --disable-libv4l

Quoted 7 lines

The main problem is there is no argp.h in uClibc, how to disable checking this?

checking for argp.h... no
configure: error: Cannot continue: argp.h not found

Scott

Quoted 8 lines

Hi Scott,

Can you try this patch for v4l-utils? It makes argp optional, and it should allow v4l2-compliance to compile with uclibc (unless there are more problems).

I'm no autoconf guru, so I'm not certain if everything is correct, but it seemed to do its job when I remove argp.h from my system.

Yes, I can pass configure now. But there is another error when make

Quoted 9 lines

make[3]: Entering directory `/home/scott/projects/git-kernel/v4l-utils/lib/libdvbv5'
CC libdvbv5_la-parse_string.lo
parse_string.c:26:19: error: iconv.h: No such file or directory parse_string.c: In function 'dvb_iconv_to_charset':
parse_string.c:316: error: 'iconv_t' undeclared (first use in this function)

I tried to pass this library, while --without-libdvbv5 is not supported.

If you can pass the configure step, then you should be able to run this:

Quoted 9 lines

cd utils/v4l2-compliance
cat *.cpp >x.cpp
g++ -o v4l2-compliance x.cpp -I . -I ../../include/ -DNO_LIBV4L2

(you need to use the right toolchain here, of course)

If this compiles OK, then you have a v4l2-compliance tool that you can use.

Yes, this method works. The test results of v4l2-compliance are below, I'm sorry the kernel has not upgraded to 4.0.
root:/> ./v4l2-compliance -d 0
Driver Info:bfin_capture bfin_capture.0: ================= START STATUS =================

Driver name : bfin_capture
Card type :bfin_capture bfin_capture.0: ==================
END STATUS ==================
BF609
Bus info : Blackfin Platform
Driver version: 3.17.0
Capabilities : 0x04200001
Video Capture
Streaming
Extended Pix Format

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
fail: x.cpp(306): missing bus_info prefix ('Blackfin Platform')
test VIDIOC_QUERYCAP: FAIL

Allow for multiple opens:
test second video open: OK
fail: x.cpp(306): missing bus_info prefix ('Blackfin Platform')
test VIDIOC_QUERYCAP: FAIL
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)

Test input 0:

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
fail: x.cpp(2944): subscribe event for control 'User
Controls' failed
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 3 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
fail: x.cpp(3405): pixelformat != V4L2_PIX_FMT_JPEG &&
colorspace == V4L2_COLORSPACE_JPEG
fail: x.cpp(3508): testColorspace(pix.pixelformat,
pix.colorspace, pix.ycbcr_enc, pix.quantization)
test VIDIOC_G_FMT: FAIL
test VIDIOC_TRY_FMT: OK (Not Supported) test VIDIOC_S_FMT: OK (Not Supported)
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
fail: x.cpp(1436): q.has_expbuf(node) test VIDIOC_EXPBUF: FAIL

Total: 42, Succeeded: 37, Failed: 5, Warnings: 0

#23 lore raw

Hi Scott,

Quoted 45 lines · Scott Jiang

2015-04-24 18:04 GMT+08:00 Hans Verkuil <[email protected]>:

Quoted 44 lines · Scott Jiang
Quoted 27 lines

Hi Hans,

Quoted 14 lines
Quoted 6 lines

Hans, I tried to use v4l2-compliance but it failed to compile. Sorry for telling you it have passed compilation because I forgot to use blackfin toolchain.
./configure --without-jpeg --host=bfin-linux-uclibc --disable-libv4l

Quoted 7 lines

The main problem is there is no argp.h in uClibc, how to disable checking this?

checking for argp.h... no
configure: error: Cannot continue: argp.h not found

Scott

Quoted 8 lines

Hi Scott,

Can you try this patch for v4l-utils? It makes argp optional, and it should allow v4l2-compliance to compile with uclibc (unless there are more problems).

I'm no autoconf guru, so I'm not certain if everything is correct, but it seemed to do its job when I remove argp.h from my system.

Yes, I can pass configure now. But there is another error when make

Quoted 9 lines

make[3]: Entering directory `/home/scott/projects/git-kernel/v4l-utils/lib/libdvbv5'
CC libdvbv5_la-parse_string.lo
parse_string.c:26:19: error: iconv.h: No such file or directory parse_string.c: In function 'dvb_iconv_to_charset':
parse_string.c:316: error: 'iconv_t' undeclared (first use in this function)

I tried to pass this library, while --without-libdvbv5 is not supported.

If you can pass the configure step, then you should be able to run this:

cd utils/v4l2-compliance
cat *.cpp >x.cpp
g++ -o v4l2-compliance x.cpp -I . -I ../../include/ -DNO_LIBV4L2

Quoted 8 lines
Quoted 5 lines

(you need to use the right toolchain here, of course)

If this compiles OK, then you have a v4l2-compliance tool that you can use.

Yes, this method works. The test results of v4l2-compliance are below, I'm sorry the kernel has not upgraded to 4.0.
root:/> ./v4l2-compliance -d 0

v4l2-compliance with -s option would interesting to watch.

Cheers,
--Prabhakar Lad