#include <linux/io.h>
#include <media/v4l2-common.h>
+#include <media/v4l2-ioctl.h>
#include "omap24xxcam.h"
{
int i;
- mutex_lock(&vbq->lock);
+ mutex_lock(&vbq->vb_lock);
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
if (NULL == vbq->bufs[i])
vbq->bufs[i] = NULL;
}
- mutex_unlock(&vbq->lock);
+ mutex_unlock(&vbq->vb_lock);
videobuf_mmap_free(vbq);
}
struct omap24xxcam_fh *fh =
container_of(vbq, struct omap24xxcam_fh, vbq);
- mutex_lock(&vbq->lock);
+ mutex_lock(&vbq->vb_lock);
for (i = 0; i < count; i++) {
err = omap24xxcam_vbq_alloc_mmap_buffer(vbq->bufs[i]);
videobuf_to_dma(vbq->bufs[i])->sglen, i);
}
- mutex_unlock(&vbq->lock);
+ mutex_unlock(&vbq->vb_lock);
return 0;
out:
omap24xxcam_vbq_free_mmap_buffer(vbq->bufs[i]);
}
- mutex_unlock(&vbq->lock);
+ mutex_unlock(&vbq->vb_lock);
return err;
}
do_gettimeofday(&vb->ts);
vb->field_count = atomic_add_return(2, &fh->field_count);
if (csr & csr_error) {
- vb->state = STATE_ERROR;
+ vb->state = VIDEOBUF_ERROR;
if (!atomic_read(&fh->cam->in_reset)) {
dev_dbg(cam->dev, "resetting camera, csr 0x%x\n", csr);
omap24xxcam_reset(cam);
}
} else
- vb->state = STATE_DONE;
+ vb->state = VIDEOBUF_DONE;
wake_up(&vb->done);
}
videobuf_dma_free(videobuf_to_dma(vb));
}
- vb->state = STATE_NEEDS_INIT;
+ vb->state = VIDEOBUF_NEEDS_INIT;
}
/*
} else
vb->size = fh->pix.sizeimage;
} else {
- if (vb->state != STATE_NEEDS_INIT) {
+ if (vb->state != VIDEOBUF_NEEDS_INIT) {
/*
* We have a kernel bounce buffer that has
* already been allocated.
vb->height = fh->pix.height;
vb->field = field;
- if (vb->state == STATE_NEEDS_INIT) {
+ if (vb->state == VIDEOBUF_NEEDS_INIT) {
if (vb->memory == V4L2_MEMORY_MMAP)
/*
* we have built the scatter-gather list by ourself so
}
if (!err)
- vb->state = STATE_PREPARED;
+ vb->state = VIDEOBUF_PREPARED;
else
omap24xxcam_vbq_release(vbq, vb);
* pretty way of marking it active exactly when the
* scatter-gather transfer starts.
*/
- vb->state = STATE_ACTIVE;
+ vb->state = VIDEOBUF_ACTIVE;
err = omap24xxcam_sgdma_queue(&fh->cam->sgdma,
videobuf_to_dma(vb)->sglist,
mutex_unlock(&cam->mutex);
if (!rval) {
- mutex_lock(&ofh->vbq.lock);
+ mutex_lock(&ofh->vbq.vb_lock);
ofh->pix = f->fmt.pix;
- mutex_unlock(&ofh->vbq.lock);
+ mutex_unlock(&ofh->vbq.vb_lock);
}
memset(f, 0, sizeof(*f));
struct videobuf_buffer *vb;
int rval;
+videobuf_dqbuf_again:
rval = videobuf_dqbuf(&ofh->vbq, b, file->f_flags & O_NONBLOCK);
if (rval)
goto out;
out:
/*
- * This is a hack. User space won't get the index of this
- * buffer and does not want to requeue it so we requeue it
- * here.
+ * This is a hack. We don't want to show -EIO to the user
+ * space. Requeue the buffer and try again if we're not doing
+ * this in non-blocking mode.
*/
- if (rval == -EIO)
+ if (rval == -EIO) {
videobuf_qbuf(&ofh->vbq, b);
+ if (!(file->f_flags & O_NONBLOCK))
+ goto videobuf_dqbuf_again;
+ /*
+ * We don't have a videobuf_buffer now --- maybe next
+ * time...
+ */
+ rval = -EAGAIN;
+ }
return rval;
}
}
mutex_unlock(&cam->mutex);
- mutex_lock(&fh->vbq.lock);
+ mutex_lock(&fh->vbq.vb_lock);
if (list_empty(&fh->vbq.stream)) {
- mutex_unlock(&fh->vbq.lock);
+ mutex_unlock(&fh->vbq.vb_lock);
return POLLERR;
}
vb = list_entry(fh->vbq.stream.next, struct videobuf_buffer, stream);
- mutex_unlock(&fh->vbq.lock);
+ mutex_unlock(&fh->vbq.vb_lock);
poll_wait(file, &vb->done, wait);
- if (vb->state == STATE_DONE || vb->state == STATE_ERROR)
+ if (vb->state == VIDEOBUF_DONE || vb->state == VIDEOBUF_ERROR)
return POLLIN | POLLRDNORM;
return 0;
return -EBUSY;
}
mutex_unlock(&cam->mutex);
- mutex_lock(&vbq->lock);
+ mutex_lock(&vbq->vb_lock);
/* look for first buffer to map */
for (first = 0; first < VIDEO_MAX_FRAME; first++) {
}
out:
- mutex_unlock(&vbq->lock);
+ mutex_unlock(&vbq->vb_lock);
return err;
}
spin_lock_init(&fh->vbq_lock);
- videobuf_queue_pci_init(&fh->vbq, &omap24xxcam_vbq_ops, NULL,
+ videobuf_queue_sg_init(&fh->vbq, &omap24xxcam_vbq_ops, NULL,
&fh->vbq_lock, V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_NONE,
sizeof(struct videobuf_buffer), fh);
}
static struct file_operations omap24xxcam_fops = {
- .owner = THIS_MODULE,
.llseek = no_llseek,
.ioctl = video_ioctl2,
.poll = omap24xxcam_poll,