type
stringclasses
5 values
content
stringlengths
9
163k
includes
#include <linux/kernel.h>
includes
#include <linux/module.h>
includes
#include <linux/mm.h>
includes
#include <linux/poll.h>
includes
#include <linux/slab.h>
includes
#include <linux/sched.h>
includes
#include <media/v4l2-dev.h>
includes
#include <media/v4l2-fh.h>
includes
#include <media/v4l2-event.h>
includes
#include <media/videobuf2-core.h>
defines
#define dprintk(level, fmt, arg...) \
defines
#define call_memop(q, op, args...) \
defines
#define call_qop(q, op, args...) \
defines
#define V4L2_BUFFER_MASK_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \
structs
struct vb2_fileio_buf { void *vaddr; unsigned int size; unsigned int pos; unsigned int queued:1; };
structs
struct vb2_fileio_data { struct v4l2_requestbuffers req; struct v4l2_buffer b; struct vb2_fileio_buf bufs[VIDEO_MAX_FRAME]; unsigned int index; unsigned int q_count; unsigned int dq_count; unsigned int flags; };
functions
int __vb2_buf_mem_alloc(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; void *mem_priv; int write = !V4L2_TYPE_IS_OUTPUT(q->type); int plane; /* * Allocate memory for all planes in this buffer * NOTE: mmapped areas should be page aligned */ for (plane = 0; plane < vb->num_planes; ++plane) { ...
functions
void __vb2_buf_mem_free(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; unsigned int plane; for (plane = 0; plane < vb->num_planes; ++plane) { call_memop(q, put, vb->planes[plane].mem_priv); vb->planes[plane].mem_priv = NULL; dprintk(3, "Freed plane %d of buffer %d\n", plane, vb->v4l2_buf.ind...
functions
void __vb2_buf_userptr_put(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; unsigned int plane; for (plane = 0; plane < vb->num_planes; ++plane) { if (vb->planes[plane].mem_priv) call_memop(q, put_userptr, vb->planes[plane].mem_priv); vb->planes[plane].mem_priv = NULL; }
functions
void __vb2_plane_dmabuf_put(struct vb2_queue *q, struct vb2_plane *p) { if (!p->mem_priv) return; if (p->dbuf_mapped) call_memop(q, unmap_dmabuf, p->mem_priv); call_memop(q, detach_dmabuf, p->mem_priv); dma_buf_put(p->dbuf); memset(p, 0, sizeof(*p)); }
functions
void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; unsigned int plane; for (plane = 0; plane < vb->num_planes; ++plane) __vb2_plane_dmabuf_put(q, &vb->planes[plane]); }
functions
void __setup_offsets(struct vb2_queue *q, unsigned int n) { unsigned int buffer, plane; struct vb2_buffer *vb; unsigned long off; if (q->num_buffers) { struct v4l2_plane *p; vb = q->bufs[q->num_buffers - 1]; p = &vb->v4l2_planes[vb->num_planes - 1]; off = PAGE_ALIGN(p->m.mem_offset + p->length); }
functions
int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory, unsigned int num_buffers, unsigned int num_planes) { unsigned int buffer; struct vb2_buffer *vb; int ret; q->timeline_max = 0; q->timeline = sw_sync_timeline_create(q->name); if (!q->timeline) { dprintk(1, "Failed to create timeline\n"...
functions
void __vb2_free_mem(struct vb2_queue *q, unsigned int buffers) { unsigned int buffer; struct vb2_buffer *vb; for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { vb = q->bufs[buffer]; if (!vb) continue; /* Free MMAP buffers or release USERPTR buffers */ if (q->memory == V4L...
functions
void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) { unsigned int buffer; /* Call driver-provided cleanup function for each buffer, if provided */ if (q->ops->buf_cleanup) { for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; ++buffer) { if (NULL == q->bufs[buffer]) contin...
functions
int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer *b) { if (!V4L2_TYPE_IS_MULTIPLANAR(b->type)) return 0; /* Is memory for copying plane information present? */ if (NULL == b->m.planes) { dprintk(1, "Multi-planar buffer passed but " "planes array not provided\n"); return -EINVAL;...
functions
bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb) { unsigned int plane; for (plane = 0; plane < vb->num_planes; ++plane) { void *mem_priv = vb->planes[plane].mem_priv; /* * If num_users() has not been provided, call_memop * will return 0, apparently nobody cares about this * case anyway. I...
functions
bool __buffers_in_use(struct vb2_queue *q) { unsigned int buffer; for (buffer = 0; buffer < q->num_buffers; ++buffer) { if (__buffer_in_use(q, q->bufs[buffer])) return true; }
functions
void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) { struct vb2_queue *q = vb->vb2_queue; /* Copy back data such as timestamp, flags, etc. */ memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); b->reserved2 = vb->v4l2_buf.reserved2; b->reserved = vb->v4l2_buf.reserved; if (V4L2_TYPE_IS...
functions
int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) { struct vb2_buffer *vb; int ret; if (b->type != q->type) { dprintk(1, "querybuf: wrong buffer type\n"); return -EINVAL; }
functions
int __verify_userptr_ops(struct vb2_queue *q) { if (!(q->io_modes & VB2_USERPTR) || !q->mem_ops->get_userptr || !q->mem_ops->put_userptr) return -EINVAL; return 0; }
functions
int __verify_mmap_ops(struct vb2_queue *q) { if (!(q->io_modes & VB2_MMAP) || !q->mem_ops->alloc || !q->mem_ops->put || !q->mem_ops->mmap) return -EINVAL; return 0; }
functions
int __verify_dmabuf_ops(struct vb2_queue *q) { if (!(q->io_modes & VB2_DMABUF) || !q->mem_ops->attach_dmabuf || !q->mem_ops->detach_dmabuf || !q->mem_ops->map_dmabuf || !q->mem_ops->unmap_dmabuf) return -EINVAL; return 0; }
functions
int __verify_memory_type(struct vb2_queue *q, enum v4l2_memory memory, enum v4l2_buf_type type) { if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR && memory != V4L2_MEMORY_DMABUF) { dprintk(1, "reqbufs: unsupported memory type\n"); return -EINVAL; }
functions
int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) { unsigned int num_buffers, allocated_buffers, num_planes = 0; int ret; if (q->streaming) { dprintk(1, "reqbufs: streaming active\n"); return -EBUSY; }
functions
int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) { int ret = __verify_memory_type(q, req->memory, req->type); return ret ? ret : __reqbufs(q, req); }
functions
int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) { unsigned int num_planes = 0, num_buffers, allocated_buffers; int ret; if (q->num_buffers == VIDEO_MAX_FRAME) { dprintk(1, "%s(): maximum number of buffers already allocated\n", __func__); return -ENOBUFS; }
functions
int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) { int ret = __verify_memory_type(q, create->memory, create->format.type); create->index = q->num_buffers; if (create->count == 0) return ret != -EBUSY ? ret : 0; return ret ? ret : __create_bufs(q, create); }
functions
void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) { struct vb2_queue *q = vb->vb2_queue; unsigned long flags; unsigned int plane; if (vb->state != VB2_BUF_STATE_ACTIVE) return; if (state != VB2_BUF_STATE_DONE && state != VB2_BUF_STATE_ERROR) return; dprintk(4, "Done processing on buf...
functions
int __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b, struct v4l2_plane *v4l2_planes) { unsigned int plane; int fence_fd = (int)b->reserved; if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { /* Fill in driver-provided information for OUTPUT types */ if (V4L2_TYPE_IS_OUTPUT(b->type)) { /* *...
functions
int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) { struct v4l2_plane planes[VIDEO_MAX_PLANES]; struct vb2_queue *q = vb->vb2_queue; void *mem_priv; unsigned int plane; int ret; int write = !V4L2_TYPE_IS_OUTPUT(q->type); /* Copy relevant information provided by the userspace */ ret = __fil...
functions
int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b) { return __fill_vb2_buffer(vb, b, vb->v4l2_planes); }
functions
int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) { struct v4l2_plane planes[VIDEO_MAX_PLANES]; struct vb2_queue *q = vb->vb2_queue; void *mem_priv; unsigned int plane; int ret; int write = !V4L2_TYPE_IS_OUTPUT(q->type); /* Verify and copy relevant information provided by the userspace */ r...
functions
void __enqueue_in_driver(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; unsigned int plane; vb->state = VB2_BUF_STATE_ACTIVE; atomic_inc(&q->queued_count); /* sync buffers */ for (plane = 0; plane < vb->num_planes; ++plane) call_memop(q, prepare, vb->planes[plane].mem_priv); q->ops->buf_queue...
functions
int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) { struct vb2_queue *q = vb->vb2_queue; int ret; switch (q->memory) { case V4L2_MEMORY_MMAP: ret = __qbuf_mmap(vb, b); break; case V4L2_MEMORY_USERPTR: ret = __qbuf_userptr(vb, b); break; case V4L2_MEMORY_DMABUF: ret = __qbuf_dmabuf(v...
functions
int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) { struct vb2_buffer *vb; int ret; if (q->fileio) { dprintk(1, "%s(): file io in progress\n", __func__); return -EBUSY; }
functions
int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) { struct rw_semaphore *mmap_sem = NULL; struct vb2_buffer *vb; int ret = 0; /* * In case of user pointer buffers vb2 allocator needs to get direct * access to userspace pages. This requires getting read access on * mmap semaphore in the current process...
functions
int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) { /* * All operations on vb_done_list are performed under done_lock * spinlock protection. However, buffers may be removed from * it and returned to userspace only while holding both driver's * lock and the done_lock spinlock. Thus we can be sure...
functions
int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, struct v4l2_buffer *b, int nonblocking) { unsigned long flags; int ret; /* * Wait for at least one buffer to become available on the done_list. */ ret = __vb2_wait_for_done_vb(q, nonblocking); if (ret) return ret; /* * Driver's lock ...
functions
int vb2_wait_for_all_buffers(struct vb2_queue *q) { if (!q->streaming) { dprintk(1, "Streaming off, will not wait for buffers\n"); return -EINVAL; }
functions
void __vb2_dqbuf(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; unsigned int i; /* nothing to do if the buffer is already dequeued */ if (vb->state == VB2_BUF_STATE_DEQUEUED) return; vb->state = VB2_BUF_STATE_DEQUEUED; /* unmap DMABUF buffer */ if (q->memory == V4L2_MEMORY_DMABUF) for (i = ...
functions
int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) { struct vb2_buffer *vb = NULL; int ret; if (q->fileio) { dprintk(1, "dqbuf: file io in progress\n"); return -EBUSY; }
functions
void __vb2_queue_cancel(struct vb2_queue *q) { struct vb2_buffer *vb; unsigned int i; /* * Tell driver to stop all transactions and release all queued * buffers. */ if (q->streaming) call_qop(q, stop_streaming, q); q->streaming = 0; /* * Remove all buffers from videobuf's list... */ list_for_each_e...
functions
int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type) { struct vb2_buffer *vb; int ret; if (q->fileio) { dprintk(1, "streamon: file io in progress\n"); return -EBUSY; }
functions
int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) { if (q->fileio) { dprintk(1, "streamoff: file io in progress\n"); return -EBUSY; }
functions
int __find_plane_by_offset(struct vb2_queue *q, unsigned long off, unsigned int *_buffer, unsigned int *_plane) { struct vb2_buffer *vb; unsigned int buffer, plane; /* * Go over all buffers and their planes, comparing the given offset * with an offset assigned to each plane. If a match is found, * return i...
functions
int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) { struct vb2_buffer *vb = NULL; struct vb2_plane *vb_plane; int ret; struct dma_buf *dbuf; if (q->memory != V4L2_MEMORY_MMAP) { dprintk(1, "Queue is not currently set up for mmap\n"); return -EINVAL; }
functions
int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) { unsigned long off = vma->vm_pgoff << PAGE_SHIFT; struct vb2_buffer *vb; unsigned int buffer, plane; int ret; unsigned long length; if (q->memory != V4L2_MEMORY_MMAP) { dprintk(1, "Queue is not currently set up for mmap\n"); return -EINVAL; }
functions
long vb2_get_unmapped_area(struct vb2_queue *q, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { unsigned long off = pgoff << PAGE_SHIFT; struct vb2_buffer *vb; unsigned int buffer, plane; int ret; if (q->memory != V4L2_MEMORY_MMAP) { dprintk(1, ...
functions
int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) { struct video_device *vfd = video_devdata(file); unsigned long req_events = poll_requested_events(wait); struct vb2_buffer *vb = NULL; unsigned int res = 0; unsigned long flags; if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { struct v4l...
functions
int vb2_queue_init(struct vb2_queue *q) { /* * Sanity check */ if (WARN_ON(!q) || WARN_ON(!q->ops) || WARN_ON(!q->mem_ops) || WARN_ON(!q->type) || WARN_ON(!q->io_modes) || WARN_ON(!q->ops->queue_setup) || WARN_ON(!q->ops->buf_queue) || WARN_ON(q->timestamp_type &...
functions
void vb2_queue_release(struct vb2_queue *q) { __vb2_cleanup_fileio(q); __vb2_queue_cancel(q); __vb2_queue_free(q, q->num_buffers); }
functions
int __vb2_init_fileio(struct vb2_queue *q, int read) { struct vb2_fileio_data *fileio; int i, ret; unsigned int count = 0; /* * Sanity check */ if ((read && !(q->io_modes & VB2_READ)) || (!read && !(q->io_modes & VB2_WRITE))) BUG(); /* * Check if device supports mapping buffers to kernel virtual spa...
functions
int __vb2_cleanup_fileio(struct vb2_queue *q) { struct vb2_fileio_data *fileio = q->fileio; if (fileio) { /* * Hack fileio context to enable direct calls to vb2 ioctl * interface. */ q->fileio = NULL; vb2_streamoff(q, q->type); fileio->req.count = 0; vb2_reqbufs(q, &fileio->req); kfree(fileio);...
functions
size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_t count, loff_t *ppos, int nonblock, int read) { struct vb2_fileio_data *fileio; struct vb2_fileio_buf *buf; int ret, index; dprintk(3, "file io: mode %s, offset %ld, count %zd, %sblocking\n", read ? "read" : "write", (long)*ppos, count, ...
functions
size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count, loff_t *ppos, int nonblocking) { return __vb2_perform_fileio(q, data, count, ppos, nonblocking, 1); }
functions
size_t vb2_write(struct vb2_queue *q, char __user *data, size_t count, loff_t *ppos, int nonblocking) { return __vb2_perform_fileio(q, data, count, ppos, nonblocking, 0); }
functions
bool vb2_queue_is_busy(struct video_device *vdev, struct file *file) { return vdev->queue->owner && vdev->queue->owner != file->private_data; }
functions
int vb2_ioctl_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *p) { struct video_device *vdev = video_devdata(file); int res = __verify_memory_type(vdev->queue, p->memory, p->type); if (res) return res; if (vb2_queue_is_busy(vdev, file)) return -EBUSY; res = __reqbufs(vdev->queue, p); ...
functions
int vb2_ioctl_create_bufs(struct file *file, void *priv, struct v4l2_create_buffers *p) { struct video_device *vdev = video_devdata(file); int res = __verify_memory_type(vdev->queue, p->memory, p->format.type); p->index = vdev->queue->num_buffers; /* If count == 0, then just check if memory and type are valid...
functions
int vb2_ioctl_prepare_buf(struct file *file, void *priv, struct v4l2_buffer *p) { struct video_device *vdev = video_devdata(file); if (vb2_queue_is_busy(vdev, file)) return -EBUSY; return vb2_prepare_buf(vdev->queue, p); }
functions
int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p) { struct video_device *vdev = video_devdata(file); /* No need to call vb2_queue_is_busy(), anyone can query buffers. */ return vb2_querybuf(vdev->queue, p); }
functions
int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) { struct video_device *vdev = video_devdata(file); if (vb2_queue_is_busy(vdev, file)) return -EBUSY; return vb2_qbuf(vdev->queue, p); }
functions
int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) { struct video_device *vdev = video_devdata(file); if (vb2_queue_is_busy(vdev, file)) return -EBUSY; return vb2_dqbuf(vdev->queue, p, file->f_flags & O_NONBLOCK); }
functions
int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i) { struct video_device *vdev = video_devdata(file); if (vb2_queue_is_busy(vdev, file)) return -EBUSY; return vb2_streamon(vdev->queue, i); }
functions
int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) { struct video_device *vdev = video_devdata(file); if (vb2_queue_is_busy(vdev, file)) return -EBUSY; return vb2_streamoff(vdev->queue, i); }
functions
int vb2_ioctl_expbuf(struct file *file, void *priv, struct v4l2_exportbuffer *p) { struct video_device *vdev = video_devdata(file); if (vb2_queue_is_busy(vdev, file)) return -EBUSY; return vb2_expbuf(vdev->queue, p); }
functions
int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma) { struct video_device *vdev = video_devdata(file); return vb2_mmap(vdev->queue, vma); }
functions
int vb2_fop_release(struct file *file) { struct video_device *vdev = video_devdata(file); if (file->private_data == vdev->queue->owner) { vb2_queue_release(vdev->queue); vdev->queue->owner = NULL; }
functions
ssize_t vb2_fop_write(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct video_device *vdev = video_devdata(file); struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; int err = -EBUSY; if (lock && mutex_lock_interruptible(lock)) return -ERESTARTSYS; if (vb2_queue_is...
functions
ssize_t vb2_fop_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct video_device *vdev = video_devdata(file); struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; int err = -EBUSY; if (lock && mutex_lock_interruptible(lock)) return -ERESTARTSYS; if (vb2_queue_is_...
functions
int vb2_fop_poll(struct file *file, poll_table *wait) { struct video_device *vdev = video_devdata(file); struct vb2_queue *q = vdev->queue; struct mutex *lock = q->lock ? q->lock : vdev->lock; unsigned long req_events = poll_requested_events(wait); unsigned res; void *fileio; bool must_lock = false; /* Try to ...
functions
long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { struct video_device *vdev = video_devdata(file); return vb2_get_unmapped_area(vdev->queue, addr, len, pgoff, flags); }
functions
void vb2_ops_wait_prepare(struct vb2_queue *vq) { mutex_unlock(vq->lock); }
functions
void vb2_ops_wait_finish(struct vb2_queue *vq) { mutex_lock(vq->lock); }
includes
#include <linux/irq.h>
includes
#include <linux/slab.h>
includes
#include <linux/export.h>
includes
#include <linux/interrupt.h>
includes
#include <linux/kernel_stat.h>
includes
#include <linux/radix-tree.h>
includes
#include <linux/bitmap.h>
includes
#include <linux/irqdomain.h>
includes
#include <linux/sysfs.h>
defines
#define IRQ_ATTR_RO(_name) \
functions
__init irq_affinity_setup(char *str) { alloc_bootmem_cpumask_var(&irq_default_affinity); cpulist_parse(str, irq_default_affinity); /* * Set at least the boot cpu. We don't want to end up with * bugreports caused by random comandline masks */ cpumask_set_cpu(smp_processor_id(), irq_default_affinity); return 1...
functions
__init init_irq_default_affinity(void) { if (!cpumask_available(irq_default_affinity)) zalloc_cpumask_var(&irq_default_affinity, GFP_NOWAIT); if (cpumask_empty(irq_default_affinity)) cpumask_setall(irq_default_affinity); }
functions
__init init_irq_default_affinity(void) { }
functions
int alloc_masks(struct irq_desc *desc, int node) { if (!zalloc_cpumask_var_node(&desc->irq_common_data.affinity, GFP_KERNEL, node)) return -ENOMEM; #ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK if (!zalloc_cpumask_var_node(&desc->irq_common_data.effective_affinity, GFP_KERNEL, node)) { free_cpum...
functions
void desc_smp_init(struct irq_desc *desc, int node, const struct cpumask *affinity) { if (!affinity) affinity = irq_default_affinity; cpumask_copy(desc->irq_common_data.affinity, affinity); #ifdef CONFIG_GENERIC_PENDING_IRQ cpumask_clear(desc->pending_mask); #endif #ifdef CONFIG_NUMA desc->irq_common_data.n...