[media] omap3isp: Move to videobuf2
Replace the custom buffers queue implementation with a videobuf2 queue. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
parent
34ea4d4417
commit
fbac1400bd
|
@ -3,7 +3,7 @@
|
|||
ccflags-$(CONFIG_VIDEO_OMAP3_DEBUG) += -DDEBUG
|
||||
|
||||
omap3-isp-objs += \
|
||||
isp.o ispqueue.o ispvideo.o \
|
||||
isp.o ispvideo.o \
|
||||
ispcsiphy.o ispccp2.o ispcsi2.o \
|
||||
ispccdc.o isppreview.o ispresizer.o \
|
||||
ispstat.o isph3a_aewb.o isph3a_af.o isphist.o
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,171 +0,0 @@
|
|||
/*
|
||||
* ispqueue.h
|
||||
*
|
||||
* TI OMAP3 ISP - Video buffers queue handling
|
||||
*
|
||||
* Copyright (C) 2010 Nokia Corporation
|
||||
*
|
||||
* Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
||||
* Sakari Ailus <sakari.ailus@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef OMAP3_ISP_QUEUE_H
|
||||
#define OMAP3_ISP_QUEUE_H
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/mm_types.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
struct isp_video_queue;
|
||||
struct page;
|
||||
struct scatterlist;
|
||||
|
||||
#define ISP_VIDEO_MAX_BUFFERS 16
|
||||
|
||||
/**
|
||||
* enum isp_video_buffer_state - ISP video buffer state
|
||||
* @ISP_BUF_STATE_IDLE: The buffer is under userspace control (dequeued
|
||||
* or not queued yet).
|
||||
* @ISP_BUF_STATE_QUEUED: The buffer has been queued but isn't used by the
|
||||
* device yet.
|
||||
* @ISP_BUF_STATE_ACTIVE: The buffer is in use for an active video transfer.
|
||||
* @ISP_BUF_STATE_ERROR: The device is done with the buffer and an error
|
||||
* occurred. For capture device the buffer likely contains corrupted data or
|
||||
* no data at all.
|
||||
* @ISP_BUF_STATE_DONE: The device is done with the buffer and no error occurred.
|
||||
* For capture devices the buffer contains valid data.
|
||||
*/
|
||||
enum isp_video_buffer_state {
|
||||
ISP_BUF_STATE_IDLE,
|
||||
ISP_BUF_STATE_QUEUED,
|
||||
ISP_BUF_STATE_ACTIVE,
|
||||
ISP_BUF_STATE_ERROR,
|
||||
ISP_BUF_STATE_DONE,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct isp_video_buffer - ISP video buffer
|
||||
* @vma_use_count: Number of times the buffer is mmap'ed to userspace
|
||||
* @stream: List head for insertion into main queue
|
||||
* @queue: ISP buffers queue this buffer belongs to
|
||||
* @prepared: Whether the buffer has been prepared
|
||||
* @skip_cache: Whether to skip cache management operations for this buffer
|
||||
* @vaddr: Memory virtual address (for kernel buffers)
|
||||
* @vm_flags: Buffer VMA flags (for userspace buffers)
|
||||
* @npages: Number of pages (for userspace buffers)
|
||||
* @sgt: Scatter gather table (for userspace buffers)
|
||||
* @pages: Pages table (for userspace non-VM_PFNMAP buffers)
|
||||
* @vbuf: V4L2 buffer
|
||||
* @state: Current buffer state
|
||||
* @wait: Wait queue to signal buffer completion
|
||||
*/
|
||||
struct isp_video_buffer {
|
||||
unsigned long vma_use_count;
|
||||
struct list_head stream;
|
||||
struct isp_video_queue *queue;
|
||||
unsigned int prepared:1;
|
||||
bool skip_cache;
|
||||
|
||||
/* For kernel buffers. */
|
||||
void *vaddr;
|
||||
|
||||
/* For userspace buffers. */
|
||||
vm_flags_t vm_flags;
|
||||
unsigned int npages;
|
||||
struct sg_table sgt;
|
||||
|
||||
/* For non-VM_PFNMAP userspace buffers. */
|
||||
struct page **pages;
|
||||
|
||||
/* Touched by the interrupt handler. */
|
||||
struct v4l2_buffer vbuf;
|
||||
enum isp_video_buffer_state state;
|
||||
wait_queue_head_t wait;
|
||||
dma_addr_t dma;
|
||||
};
|
||||
|
||||
#define to_isp_video_buffer(vb) container_of(vb, struct isp_video_buffer, vb)
|
||||
|
||||
/**
|
||||
* struct isp_video_queue_operations - Driver-specific operations
|
||||
* @queue_prepare: Called before allocating buffers. Drivers should clamp the
|
||||
* number of buffers according to their requirements, and must return the
|
||||
* buffer size in bytes.
|
||||
* @buffer_prepare: Called the first time a buffer is queued, or after changing
|
||||
* the userspace memory address for a USERPTR buffer, with the queue lock
|
||||
* held. Drivers should perform device-specific buffer preparation (such as
|
||||
* mapping the buffer memory in an IOMMU). This operation is optional.
|
||||
* @buffer_queue: Called when a buffer is being added.
|
||||
*/
|
||||
struct isp_video_queue_operations {
|
||||
void (*queue_prepare)(struct isp_video_queue *queue,
|
||||
unsigned int *nbuffers, unsigned int *size);
|
||||
int (*buffer_prepare)(struct isp_video_buffer *buf);
|
||||
void (*buffer_queue)(struct isp_video_buffer *buf);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct isp_video_queue - ISP video buffers queue
|
||||
* @type: Type of video buffers handled by this queue
|
||||
* @ops: Queue operations
|
||||
* @dev: Device used for DMA operations
|
||||
* @bufsize: Size of a driver-specific buffer object
|
||||
* @count: Number of currently allocated buffers
|
||||
* @buffers: ISP video buffers
|
||||
* @streaming: Queue state, indicates whether the queue is streaming
|
||||
* @queue: List of all queued buffers
|
||||
*/
|
||||
struct isp_video_queue {
|
||||
enum v4l2_buf_type type;
|
||||
const struct isp_video_queue_operations *ops;
|
||||
struct device *dev;
|
||||
unsigned int bufsize;
|
||||
|
||||
unsigned int count;
|
||||
struct isp_video_buffer *buffers[ISP_VIDEO_MAX_BUFFERS];
|
||||
|
||||
unsigned int streaming:1;
|
||||
|
||||
struct list_head queue;
|
||||
};
|
||||
|
||||
int omap3isp_video_queue_cleanup(struct isp_video_queue *queue);
|
||||
int omap3isp_video_queue_init(struct isp_video_queue *queue,
|
||||
enum v4l2_buf_type type,
|
||||
const struct isp_video_queue_operations *ops,
|
||||
struct device *dev, unsigned int bufsize);
|
||||
|
||||
int omap3isp_video_queue_reqbufs(struct isp_video_queue *queue,
|
||||
struct v4l2_requestbuffers *rb);
|
||||
int omap3isp_video_queue_querybuf(struct isp_video_queue *queue,
|
||||
struct v4l2_buffer *vbuf);
|
||||
int omap3isp_video_queue_qbuf(struct isp_video_queue *queue,
|
||||
struct v4l2_buffer *vbuf);
|
||||
int omap3isp_video_queue_dqbuf(struct isp_video_queue *queue,
|
||||
struct v4l2_buffer *vbuf, int nonblocking);
|
||||
int omap3isp_video_queue_streamon(struct isp_video_queue *queue);
|
||||
void omap3isp_video_queue_streamoff(struct isp_video_queue *queue);
|
||||
void omap3isp_video_queue_discard_done(struct isp_video_queue *queue);
|
||||
int omap3isp_video_queue_mmap(struct isp_video_queue *queue,
|
||||
struct vm_area_struct *vma);
|
||||
unsigned int omap3isp_video_queue_poll(struct isp_video_queue *queue,
|
||||
struct file *file, poll_table *wait);
|
||||
|
||||
#endif /* OMAP3_ISP_QUEUE_H */
|
|
@ -34,6 +34,7 @@
|
|||
#include <linux/vmalloc.h>
|
||||
#include <media/v4l2-dev.h>
|
||||
#include <media/v4l2-ioctl.h>
|
||||
#include <media/videobuf2-dma-contig.h>
|
||||
|
||||
#include "ispvideo.h"
|
||||
#include "isp.h"
|
||||
|
@ -328,25 +329,33 @@ isp_video_check_format(struct isp_video *video, struct isp_video_fh *vfh)
|
|||
* Video queue operations
|
||||
*/
|
||||
|
||||
static void isp_video_queue_prepare(struct isp_video_queue *queue,
|
||||
unsigned int *nbuffers, unsigned int *size)
|
||||
static int isp_video_queue_setup(struct vb2_queue *queue,
|
||||
const struct v4l2_format *fmt,
|
||||
unsigned int *count, unsigned int *num_planes,
|
||||
unsigned int sizes[], void *alloc_ctxs[])
|
||||
{
|
||||
struct isp_video_fh *vfh =
|
||||
container_of(queue, struct isp_video_fh, queue);
|
||||
struct isp_video_fh *vfh = vb2_get_drv_priv(queue);
|
||||
struct isp_video *video = vfh->video;
|
||||
|
||||
*size = vfh->format.fmt.pix.sizeimage;
|
||||
if (*size == 0)
|
||||
return;
|
||||
*num_planes = 1;
|
||||
|
||||
*nbuffers = min(*nbuffers, video->capture_mem / PAGE_ALIGN(*size));
|
||||
sizes[0] = vfh->format.fmt.pix.sizeimage;
|
||||
if (sizes[0] == 0)
|
||||
return -EINVAL;
|
||||
|
||||
alloc_ctxs[0] = video->alloc_ctx;
|
||||
|
||||
*count = min(*count, video->capture_mem / PAGE_ALIGN(sizes[0]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isp_video_buffer_prepare(struct isp_video_buffer *buf)
|
||||
static int isp_video_buffer_prepare(struct vb2_buffer *buf)
|
||||
{
|
||||
struct isp_video_fh *vfh = isp_video_queue_to_isp_video_fh(buf->queue);
|
||||
struct isp_video_fh *vfh = vb2_get_drv_priv(buf->vb2_queue);
|
||||
struct isp_buffer *buffer = to_isp_buffer(buf);
|
||||
struct isp_video *video = vfh->video;
|
||||
dma_addr_t addr;
|
||||
|
||||
/* Refuse to prepare the buffer is the video node has registered an
|
||||
* error. We don't need to take any lock here as the operation is
|
||||
|
@ -357,7 +366,16 @@ static int isp_video_buffer_prepare(struct isp_video_buffer *buf)
|
|||
if (unlikely(video->error))
|
||||
return -EIO;
|
||||
|
||||
buffer->isp_addr = buf->dma;
|
||||
addr = vb2_dma_contig_plane_dma_addr(buf, 0);
|
||||
if (!IS_ALIGNED(addr, 32)) {
|
||||
dev_dbg(video->isp->dev,
|
||||
"Buffer address must be aligned to 32 bytes boundary.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
vb2_set_plane_payload(&buffer->vb, 0, vfh->format.fmt.pix.sizeimage);
|
||||
buffer->isp_addr = addr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -370,9 +388,9 @@ static int isp_video_buffer_prepare(struct isp_video_buffer *buf)
|
|||
* If the pipeline is busy, it will be restarted in the output module interrupt
|
||||
* handler.
|
||||
*/
|
||||
static void isp_video_buffer_queue(struct isp_video_buffer *buf)
|
||||
static void isp_video_buffer_queue(struct vb2_buffer *buf)
|
||||
{
|
||||
struct isp_video_fh *vfh = isp_video_queue_to_isp_video_fh(buf->queue);
|
||||
struct isp_video_fh *vfh = vb2_get_drv_priv(buf->vb2_queue);
|
||||
struct isp_buffer *buffer = to_isp_buffer(buf);
|
||||
struct isp_video *video = vfh->video;
|
||||
struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
|
||||
|
@ -384,8 +402,7 @@ static void isp_video_buffer_queue(struct isp_video_buffer *buf)
|
|||
spin_lock_irqsave(&video->irqlock, flags);
|
||||
|
||||
if (unlikely(video->error)) {
|
||||
buf->state = ISP_BUF_STATE_ERROR;
|
||||
wake_up(&buf->wait);
|
||||
vb2_buffer_done(&buffer->vb, VB2_BUF_STATE_ERROR);
|
||||
spin_unlock_irqrestore(&video->irqlock, flags);
|
||||
return;
|
||||
}
|
||||
|
@ -417,22 +434,22 @@ static void isp_video_buffer_queue(struct isp_video_buffer *buf)
|
|||
}
|
||||
}
|
||||
|
||||
static const struct isp_video_queue_operations isp_video_queue_ops = {
|
||||
.queue_prepare = &isp_video_queue_prepare,
|
||||
.buffer_prepare = &isp_video_buffer_prepare,
|
||||
.buffer_queue = &isp_video_buffer_queue,
|
||||
static const struct vb2_ops isp_video_queue_ops = {
|
||||
.queue_setup = isp_video_queue_setup,
|
||||
.buf_prepare = isp_video_buffer_prepare,
|
||||
.buf_queue = isp_video_buffer_queue,
|
||||
};
|
||||
|
||||
/*
|
||||
* omap3isp_video_buffer_next - Complete the current buffer and return the next
|
||||
* @video: ISP video object
|
||||
*
|
||||
* Remove the current video buffer from the DMA queue and fill its timestamp,
|
||||
* field count and state fields before waking up its completion handler.
|
||||
* Remove the current video buffer from the DMA queue and fill its timestamp and
|
||||
* field count before handing it back to videobuf2.
|
||||
*
|
||||
* For capture video nodes the buffer state is set to ISP_BUF_STATE_DONE if no
|
||||
* error has been flagged in the pipeline, or to ISP_BUF_STATE_ERROR otherwise.
|
||||
* For video output nodes the buffer state is always set to ISP_BUF_STATE_DONE.
|
||||
* For capture video nodes the buffer state is set to VB2_BUF_STATE_DONE if no
|
||||
* error has been flagged in the pipeline, or to VB2_BUF_STATE_ERROR otherwise.
|
||||
* For video output nodes the buffer state is always set to VB2_BUF_STATE_DONE.
|
||||
*
|
||||
* The DMA queue is expected to contain at least one buffer.
|
||||
*
|
||||
|
@ -442,9 +459,6 @@ static const struct isp_video_queue_operations isp_video_queue_ops = {
|
|||
struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
|
||||
{
|
||||
struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
|
||||
struct isp_video_queue *queue = video->queue;
|
||||
struct isp_video_fh *vfh =
|
||||
container_of(queue, struct isp_video_fh, queue);
|
||||
enum isp_pipeline_state state;
|
||||
struct isp_buffer *buf;
|
||||
unsigned long flags;
|
||||
|
@ -461,11 +475,9 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
|
|||
list_del(&buf->irqlist);
|
||||
spin_unlock_irqrestore(&video->irqlock, flags);
|
||||
|
||||
buf->buffer.vbuf.bytesused = vfh->format.fmt.pix.sizeimage;
|
||||
|
||||
ktime_get_ts(&ts);
|
||||
buf->buffer.vbuf.timestamp.tv_sec = ts.tv_sec;
|
||||
buf->buffer.vbuf.timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
|
||||
buf->vb.v4l2_buf.timestamp.tv_sec = ts.tv_sec;
|
||||
buf->vb.v4l2_buf.timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
|
||||
|
||||
/* Do frame number propagation only if this is the output video node.
|
||||
* Frame number either comes from the CSI receivers or it gets
|
||||
|
@ -474,23 +486,27 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
|
|||
* first, so the input number might lag behind by 1 in some cases.
|
||||
*/
|
||||
if (video == pipe->output && !pipe->do_propagation)
|
||||
buf->buffer.vbuf.sequence =
|
||||
buf->vb.v4l2_buf.sequence =
|
||||
atomic_inc_return(&pipe->frame_number);
|
||||
else
|
||||
buf->buffer.vbuf.sequence = atomic_read(&pipe->frame_number);
|
||||
buf->vb.v4l2_buf.sequence = atomic_read(&pipe->frame_number);
|
||||
|
||||
/* Report pipeline errors to userspace on the capture device side. */
|
||||
if (queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) {
|
||||
buf->buffer.state = ISP_BUF_STATE_ERROR;
|
||||
if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) {
|
||||
state = VB2_BUF_STATE_ERROR;
|
||||
pipe->error = false;
|
||||
} else {
|
||||
buf->buffer.state = ISP_BUF_STATE_DONE;
|
||||
state = VB2_BUF_STATE_DONE;
|
||||
}
|
||||
|
||||
wake_up(&buf->buffer.wait);
|
||||
vb2_buffer_done(&buf->vb, state);
|
||||
|
||||
spin_lock_irqsave(&video->irqlock, flags);
|
||||
|
||||
if (list_empty(&video->dmaqueue)) {
|
||||
if (queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||
spin_unlock_irqrestore(&video->irqlock, flags);
|
||||
|
||||
if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
||||
state = ISP_PIPELINE_QUEUE_OUTPUT
|
||||
| ISP_PIPELINE_STREAM;
|
||||
else
|
||||
|
@ -505,15 +521,18 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (queue->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->input != NULL) {
|
||||
spin_lock_irqsave(&pipe->lock, flags);
|
||||
if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->input != NULL) {
|
||||
spin_lock(&pipe->lock);
|
||||
pipe->state &= ~ISP_PIPELINE_STREAM;
|
||||
spin_unlock_irqrestore(&pipe->lock, flags);
|
||||
spin_unlock(&pipe->lock);
|
||||
}
|
||||
|
||||
buf = list_first_entry(&video->dmaqueue, struct isp_buffer,
|
||||
irqlist);
|
||||
buf->buffer.state = ISP_BUF_STATE_ACTIVE;
|
||||
buf->vb.state = VB2_BUF_STATE_ACTIVE;
|
||||
|
||||
spin_unlock_irqrestore(&video->irqlock, flags);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -536,9 +555,7 @@ void omap3isp_video_cancel_stream(struct isp_video *video)
|
|||
buf = list_first_entry(&video->dmaqueue,
|
||||
struct isp_buffer, irqlist);
|
||||
list_del(&buf->irqlist);
|
||||
|
||||
buf->buffer.state = ISP_BUF_STATE_ERROR;
|
||||
wake_up(&buf->buffer.wait);
|
||||
vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
|
||||
}
|
||||
|
||||
video->error = true;
|
||||
|
@ -562,7 +579,7 @@ void omap3isp_video_resume(struct isp_video *video, int continuous)
|
|||
|
||||
if (continuous && video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
|
||||
mutex_lock(&video->queue_lock);
|
||||
omap3isp_video_queue_discard_done(video->queue);
|
||||
vb2_discard_done(video->queue);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
}
|
||||
|
||||
|
@ -780,7 +797,7 @@ isp_video_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers *rb)
|
|||
int ret;
|
||||
|
||||
mutex_lock(&video->queue_lock);
|
||||
ret = omap3isp_video_queue_reqbufs(&vfh->queue, rb);
|
||||
ret = vb2_reqbufs(&vfh->queue, rb);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
|
||||
return ret;
|
||||
|
@ -794,7 +811,7 @@ isp_video_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
|
|||
int ret;
|
||||
|
||||
mutex_lock(&video->queue_lock);
|
||||
ret = omap3isp_video_queue_querybuf(&vfh->queue, b);
|
||||
ret = vb2_querybuf(&vfh->queue, b);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
|
||||
return ret;
|
||||
|
@ -808,7 +825,7 @@ isp_video_qbuf(struct file *file, void *fh, struct v4l2_buffer *b)
|
|||
int ret;
|
||||
|
||||
mutex_lock(&video->queue_lock);
|
||||
ret = omap3isp_video_queue_qbuf(&vfh->queue, b);
|
||||
ret = vb2_qbuf(&vfh->queue, b);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
|
||||
return ret;
|
||||
|
@ -822,8 +839,7 @@ isp_video_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b)
|
|||
int ret;
|
||||
|
||||
mutex_lock(&video->queue_lock);
|
||||
ret = omap3isp_video_queue_dqbuf(&vfh->queue, b,
|
||||
file->f_flags & O_NONBLOCK);
|
||||
ret = vb2_dqbuf(&vfh->queue, b, file->f_flags & O_NONBLOCK);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
|
||||
return ret;
|
||||
|
@ -966,11 +982,6 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
|||
|
||||
mutex_lock(&video->stream_lock);
|
||||
|
||||
if (video->streaming) {
|
||||
mutex_unlock(&video->stream_lock);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* Start streaming on the pipeline. No link touching an entity in the
|
||||
* pipeline can be activated or deactivated once streaming is started.
|
||||
*/
|
||||
|
@ -1030,7 +1041,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
|||
atomic_set(&pipe->frame_number, -1);
|
||||
|
||||
mutex_lock(&video->queue_lock);
|
||||
ret = omap3isp_video_queue_streamon(&vfh->queue);
|
||||
ret = vb2_streamon(&vfh->queue, type);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
if (ret < 0)
|
||||
goto err_check_format;
|
||||
|
@ -1050,14 +1061,12 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
|||
spin_unlock_irqrestore(&video->irqlock, flags);
|
||||
}
|
||||
|
||||
video->streaming = 1;
|
||||
|
||||
mutex_unlock(&video->stream_lock);
|
||||
return 0;
|
||||
|
||||
err_set_stream:
|
||||
mutex_lock(&video->queue_lock);
|
||||
omap3isp_video_queue_streamoff(&vfh->queue);
|
||||
vb2_streamoff(&vfh->queue, type);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
err_check_format:
|
||||
media_entity_pipeline_stop(&video->video.entity);
|
||||
|
@ -1095,7 +1104,7 @@ isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
|
|||
|
||||
/* Make sure we're not streaming yet. */
|
||||
mutex_lock(&video->queue_lock);
|
||||
streaming = vfh->queue.streaming;
|
||||
streaming = vb2_is_streaming(&vfh->queue);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
|
||||
if (!streaming)
|
||||
|
@ -1118,10 +1127,9 @@ isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
|
|||
omap3isp_video_cancel_stream(video);
|
||||
|
||||
mutex_lock(&video->queue_lock);
|
||||
omap3isp_video_queue_streamoff(&vfh->queue);
|
||||
vb2_streamoff(&vfh->queue, type);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
video->queue = NULL;
|
||||
video->streaming = 0;
|
||||
video->error = false;
|
||||
|
||||
if (video->isp->pdata->set_constraints)
|
||||
|
@ -1191,6 +1199,7 @@ static int isp_video_open(struct file *file)
|
|||
{
|
||||
struct isp_video *video = video_drvdata(file);
|
||||
struct isp_video_fh *handle;
|
||||
struct vb2_queue *queue;
|
||||
int ret = 0;
|
||||
|
||||
handle = kzalloc(sizeof(*handle), GFP_KERNEL);
|
||||
|
@ -1212,9 +1221,20 @@ static int isp_video_open(struct file *file)
|
|||
goto done;
|
||||
}
|
||||
|
||||
omap3isp_video_queue_init(&handle->queue, video->type,
|
||||
&isp_video_queue_ops, video->isp->dev,
|
||||
sizeof(struct isp_buffer));
|
||||
queue = &handle->queue;
|
||||
queue->type = video->type;
|
||||
queue->io_modes = VB2_MMAP | VB2_USERPTR;
|
||||
queue->drv_priv = handle;
|
||||
queue->ops = &isp_video_queue_ops;
|
||||
queue->mem_ops = &vb2_dma_contig_memops;
|
||||
queue->buf_struct_size = sizeof(struct isp_buffer);
|
||||
queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
|
||||
|
||||
ret = vb2_queue_init(&handle->queue);
|
||||
if (ret < 0) {
|
||||
omap3isp_put(video->isp);
|
||||
goto done;
|
||||
}
|
||||
|
||||
memset(&handle->format, 0, sizeof(handle->format));
|
||||
handle->format.type = video->type;
|
||||
|
@ -1242,7 +1262,7 @@ static int isp_video_release(struct file *file)
|
|||
isp_video_streamoff(file, vfh, video->type);
|
||||
|
||||
mutex_lock(&video->queue_lock);
|
||||
omap3isp_video_queue_cleanup(&handle->queue);
|
||||
vb2_queue_release(&handle->queue);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
|
||||
omap3isp_pipeline_pm_use(&video->video.entity, 0);
|
||||
|
@ -1264,7 +1284,7 @@ static unsigned int isp_video_poll(struct file *file, poll_table *wait)
|
|||
int ret;
|
||||
|
||||
mutex_lock(&video->queue_lock);
|
||||
ret = omap3isp_video_queue_poll(&vfh->queue, file, wait);
|
||||
ret = vb2_poll(&vfh->queue, file, wait);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
|
||||
return ret;
|
||||
|
@ -1277,7 +1297,7 @@ static int isp_video_mmap(struct file *file, struct vm_area_struct *vma)
|
|||
int ret;
|
||||
|
||||
mutex_lock(&video->queue_lock);
|
||||
ret = omap3isp_video_queue_mmap(&vfh->queue, vma);
|
||||
ret = vb2_mmap(&vfh->queue, vma);
|
||||
mutex_unlock(&video->queue_lock);
|
||||
|
||||
return ret;
|
||||
|
@ -1321,9 +1341,15 @@ int omap3isp_video_init(struct isp_video *video, const char *name)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
video->alloc_ctx = vb2_dma_contig_init_ctx(video->isp->dev);
|
||||
if (IS_ERR(video->alloc_ctx))
|
||||
return PTR_ERR(video->alloc_ctx);
|
||||
|
||||
ret = media_entity_init(&video->video.entity, 1, &video->pad, 0);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
mutex_init(&video->mutex);
|
||||
atomic_set(&video->active, 0);
|
||||
|
@ -1352,6 +1378,7 @@ int omap3isp_video_init(struct isp_video *video, const char *name)
|
|||
|
||||
void omap3isp_video_cleanup(struct isp_video *video)
|
||||
{
|
||||
vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
|
||||
media_entity_cleanup(&video->video.entity);
|
||||
mutex_destroy(&video->queue_lock);
|
||||
mutex_destroy(&video->stream_lock);
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
#include <media/media-entity.h>
|
||||
#include <media/v4l2-dev.h>
|
||||
#include <media/v4l2-fh.h>
|
||||
|
||||
#include "ispqueue.h"
|
||||
#include <media/videobuf2-core.h>
|
||||
|
||||
#define ISP_VIDEO_DRIVER_NAME "ispvideo"
|
||||
#define ISP_VIDEO_DRIVER_VERSION "0.0.2"
|
||||
|
@ -124,19 +123,19 @@ static inline int isp_pipeline_ready(struct isp_pipeline *pipe)
|
|||
ISP_PIPELINE_IDLE_OUTPUT);
|
||||
}
|
||||
|
||||
/*
|
||||
* struct isp_buffer - ISP buffer
|
||||
* @buffer: ISP video buffer
|
||||
/**
|
||||
* struct isp_buffer - ISP video buffer
|
||||
* @vb: videobuf2 buffer
|
||||
* @irqlist: List head for insertion into IRQ queue
|
||||
* @isp_addr: MMU mapped address (a.k.a. device address) of the buffer.
|
||||
* @isp_addr: DMA address
|
||||
*/
|
||||
struct isp_buffer {
|
||||
struct isp_video_buffer buffer;
|
||||
struct vb2_buffer vb;
|
||||
struct list_head irqlist;
|
||||
dma_addr_t isp_addr;
|
||||
};
|
||||
|
||||
#define to_isp_buffer(buf) container_of(buf, struct isp_buffer, buffer)
|
||||
#define to_isp_buffer(buf) container_of(buf, struct isp_buffer, vb)
|
||||
|
||||
enum isp_video_dmaqueue_flags {
|
||||
/* Set if DMA queue becomes empty when ISP_PIPELINE_STREAM_CONTINUOUS */
|
||||
|
@ -174,16 +173,14 @@ struct isp_video {
|
|||
unsigned int bpl_value; /* bytes per line value */
|
||||
unsigned int bpl_padding; /* padding at end of line */
|
||||
|
||||
/* Entity video node streaming */
|
||||
unsigned int streaming:1;
|
||||
|
||||
/* Pipeline state */
|
||||
struct isp_pipeline pipe;
|
||||
struct mutex stream_lock; /* pipeline and stream states */
|
||||
bool error;
|
||||
|
||||
/* Video buffers queue */
|
||||
struct isp_video_queue *queue;
|
||||
void *alloc_ctx;
|
||||
struct vb2_queue *queue;
|
||||
struct mutex queue_lock; /* protects the queue */
|
||||
spinlock_t irqlock; /* protects dmaqueue */
|
||||
struct list_head dmaqueue;
|
||||
|
@ -197,7 +194,7 @@ struct isp_video {
|
|||
struct isp_video_fh {
|
||||
struct v4l2_fh vfh;
|
||||
struct isp_video *video;
|
||||
struct isp_video_queue queue;
|
||||
struct vb2_queue queue;
|
||||
struct v4l2_format format;
|
||||
struct v4l2_fract timeperframe;
|
||||
};
|
||||
|
|
|
@ -396,7 +396,7 @@ static void iss_video_buf_queue(struct vb2_buffer *vb)
|
|||
}
|
||||
}
|
||||
|
||||
static struct vb2_ops iss_video_vb2ops = {
|
||||
static const struct vb2_ops iss_video_vb2ops = {
|
||||
.queue_setup = iss_video_queue_setup,
|
||||
.buf_prepare = iss_video_buf_prepare,
|
||||
.buf_queue = iss_video_buf_queue,
|
||||
|
|
Loading…
Reference in New Issue