#include <linux/device.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <media/videobuf2-dma-contig.h>
#include <media/videobuf2-v4l2.h>
#include "sun4i_csi.h"
struct sun4i_csi_buffer { … };
static inline struct sun4i_csi_buffer *
vb2_v4l2_to_csi_buffer(const struct vb2_v4l2_buffer *p)
{ … }
static inline struct sun4i_csi_buffer *
vb2_to_csi_buffer(const struct vb2_buffer *p)
{ … }
static void sun4i_csi_capture_start(struct sun4i_csi *csi)
{ … }
static void sun4i_csi_capture_stop(struct sun4i_csi *csi)
{ … }
static int sun4i_csi_queue_setup(struct vb2_queue *vq,
unsigned int *nbuffers,
unsigned int *nplanes,
unsigned int sizes[],
struct device *alloc_devs[])
{
struct sun4i_csi *csi = vb2_get_drv_priv(vq);
unsigned int num_planes = csi->fmt.num_planes;
unsigned int i;
if (*nplanes) {
if (*nplanes != num_planes)
return -EINVAL;
for (i = 0; i < num_planes; i++)
if (sizes[i] < csi->fmt.plane_fmt[i].sizeimage)
return -EINVAL;
return 0;
}
*nplanes = num_planes;
for (i = 0; i < num_planes; i++)
sizes[i] = csi->fmt.plane_fmt[i].sizeimage;
return 0;
};
static int sun4i_csi_buffer_prepare(struct vb2_buffer *vb)
{ … }
static int sun4i_csi_setup_scratch_buffer(struct sun4i_csi *csi,
unsigned int slot)
{ … }
static int sun4i_csi_buffer_fill_slot(struct sun4i_csi *csi, unsigned int slot)
{ … }
static int sun4i_csi_buffer_fill_all(struct sun4i_csi *csi)
{ … }
static void sun4i_csi_buffer_mark_done(struct sun4i_csi *csi,
unsigned int slot,
unsigned int sequence)
{ … }
static int sun4i_csi_buffer_flip(struct sun4i_csi *csi, unsigned int sequence)
{ … }
static void sun4i_csi_buffer_queue(struct vb2_buffer *vb)
{ … }
static void return_all_buffers(struct sun4i_csi *csi,
enum vb2_buffer_state state)
{ … }
static int sun4i_csi_start_streaming(struct vb2_queue *vq, unsigned int count)
{ … }
static void sun4i_csi_stop_streaming(struct vb2_queue *vq)
{ … }
static const struct vb2_ops sun4i_csi_qops = …;
static irqreturn_t sun4i_csi_irq(int irq, void *data)
{ … }
int sun4i_csi_dma_register(struct sun4i_csi *csi, int irq)
{ … }
void sun4i_csi_dma_unregister(struct sun4i_csi *csi)
{ … }