aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-09-08 12:34:37 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-09-09 09:14:50 -0400
commit88b7eb092efb8197d29d5202d77d1fb919419ec5 (patch)
tree73e5b438b8b22bd3b264a59f17abd0c2d07aecc9 /include/media
parentbcb53f07080bb3413f00e2e95c2c6f56eb20c9e5 (diff)
[media] videobuf2-core.h: move function descriptions from c file
There are several functions that were documented at the .c file. As we only include the headers, we need to move them to there, in order to have documentation. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'include/media')
-rw-r--r--include/media/videobuf2-core.h269
1 files changed, 269 insertions, 0 deletions
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index b6546db670ca..68f93dacb38f 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -536,35 +536,274 @@ struct vb2_queue {
536#endif 536#endif
537}; 537};
538 538
539/**
540 * vb2_plane_vaddr() - Return a kernel virtual address of a given plane
541 * @vb: vb2_buffer to which the plane in question belongs to
542 * @plane_no: plane number for which the address is to be returned
543 *
544 * This function returns a kernel virtual address of a given plane if
545 * such a mapping exist, NULL otherwise.
546 */
539void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no); 547void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no);
548
549/**
550 * vb2_plane_cookie() - Return allocator specific cookie for the given plane
551 * @vb: vb2_buffer to which the plane in question belongs to
552 * @plane_no: plane number for which the cookie is to be returned
553 *
554 * This function returns an allocator specific cookie for a given plane if
555 * available, NULL otherwise. The allocator should provide some simple static
556 * inline function, which would convert this cookie to the allocator specific
557 * type that can be used directly by the driver to access the buffer. This can
558 * be for example physical address, pointer to scatter list or IOMMU mapping.
559 */
540void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no); 560void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no);
541 561
562/**
563 * vb2_buffer_done() - inform videobuf that an operation on a buffer is finished
564 * @vb: vb2_buffer returned from the driver
565 * @state: either %VB2_BUF_STATE_DONE if the operation finished successfully,
566 * %VB2_BUF_STATE_ERROR if the operation finished with an error or
567 * %VB2_BUF_STATE_QUEUED if the driver wants to requeue buffers.
568 * If start_streaming fails then it should return buffers with state
569 * %VB2_BUF_STATE_QUEUED to put them back into the queue.
570 *
571 * This function should be called by the driver after a hardware operation on
572 * a buffer is finished and the buffer may be returned to userspace. The driver
573 * cannot use this buffer anymore until it is queued back to it by videobuf
574 * by the means of buf_queue callback. Only buffers previously queued to the
575 * driver by buf_queue can be passed to this function.
576 *
577 * While streaming a buffer can only be returned in state DONE or ERROR.
578 * The start_streaming op can also return them in case the DMA engine cannot
579 * be started for some reason. In that case the buffers should be returned with
580 * state QUEUED.
581 */
542void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state); 582void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state);
583
584/**
585 * vb2_discard_done() - discard all buffers marked as DONE
586 * @q: videobuf2 queue
587 *
588 * This function is intended to be used with suspend/resume operations. It
589 * discards all 'done' buffers as they would be too old to be requested after
590 * resume.
591 *
592 * Drivers must stop the hardware and synchronize with interrupt handlers and/or
593 * delayed works before calling this function to make sure no buffer will be
594 * touched by the driver and/or hardware.
595 */
543void vb2_discard_done(struct vb2_queue *q); 596void vb2_discard_done(struct vb2_queue *q);
597
598/**
599 * vb2_wait_for_all_buffers() - wait until all buffers are given back to vb2
600 * @q: videobuf2 queue
601 *
602 * This function will wait until all buffers that have been given to the driver
603 * by buf_queue() are given back to vb2 with vb2_buffer_done(). It doesn't call
604 * wait_prepare, wait_finish pair. It is intended to be called with all locks
605 * taken, for example from stop_streaming() callback.
606 */
544int vb2_wait_for_all_buffers(struct vb2_queue *q); 607int vb2_wait_for_all_buffers(struct vb2_queue *q);
545 608
609/**
610 * vb2_core_querybuf() - query video buffer information
611 * @q: videobuf queue
612 * @index: id number of the buffer
613 * @pb: buffer struct passed from userspace
614 *
615 * Should be called from vidioc_querybuf ioctl handler in driver.
616 * The passed buffer should have been verified.
617 * This function fills the relevant information for the userspace.
618 */
546void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb); 619void vb2_core_querybuf(struct vb2_queue *q, unsigned int index, void *pb);
620
621/**
622 * vb2_core_reqbufs() - Initiate streaming
623 * @q: videobuf2 queue
624 * @memory: memory type
625 * @count: requested buffer count
626 *
627 * Should be called from vidioc_reqbufs ioctl handler of a driver.
628 * This function:
629 * 1) verifies streaming parameters passed from the userspace,
630 * 2) sets up the queue,
631 * 3) negotiates number of buffers and planes per buffer with the driver
632 * to be used during streaming,
633 * 4) allocates internal buffer structures (struct vb2_buffer), according to
634 * the agreed parameters,
635 * 5) for MMAP memory type, allocates actual video memory, using the
636 * memory handling/allocation routines provided during queue initialization
637 *
638 * If req->count is 0, all the memory will be freed instead.
639 * If the queue has been allocated previously (by a previous vb2_reqbufs) call
640 * and the queue is not busy, memory will be reallocated.
641 *
642 * The return values from this function are intended to be directly returned
643 * from vidioc_reqbufs handler in driver.
644 */
547int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, 645int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
548 unsigned int *count); 646 unsigned int *count);
647
648/**
649 * vb2_core_create_bufs() - Allocate buffers and any required auxiliary structs
650 * @q: videobuf2 queue
651 * @memory: memory type
652 * @count: requested buffer count
653 * @parg: parameter passed to device driver
654 *
655 * Should be called from vidioc_create_bufs ioctl handler of a driver.
656 * This function:
657 * 1) verifies parameter sanity
658 * 2) calls the .queue_setup() queue operation
659 * 3) performs any necessary memory allocations
660 *
661 * The return values from this function are intended to be directly returned
662 * from vidioc_create_bufs handler in driver.
663 */
549int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, 664int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
550 unsigned int *count, unsigned requested_planes, 665 unsigned int *count, unsigned requested_planes,
551 const unsigned int requested_sizes[]); 666 const unsigned int requested_sizes[]);
667
668/**
669 * vb2_core_prepare_buf() - Pass ownership of a buffer from userspace
670 * to the kernel
671 * @q: videobuf2 queue
672 * @index: id number of the buffer
673 * @pb: buffer structure passed from userspace to vidioc_prepare_buf
674 * handler in driver
675 *
676 * Should be called from vidioc_prepare_buf ioctl handler of a driver.
677 * The passed buffer should have been verified.
678 * This function calls buf_prepare callback in the driver (if provided),
679 * in which driver-specific buffer initialization can be performed,
680 *
681 * The return values from this function are intended to be directly returned
682 * from vidioc_prepare_buf handler in driver.
683 */
552int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb); 684int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb);
685
686/**
687 * vb2_core_qbuf() - Queue a buffer from userspace
688 * @q: videobuf2 queue
689 * @index: id number of the buffer
690 * @pb: buffer structure passed from userspace to vidioc_qbuf handler
691 * in driver
692 *
693 * Should be called from vidioc_qbuf ioctl handler of a driver.
694 * The passed buffer should have been verified.
695 * This function:
696 * 1) if necessary, calls buf_prepare callback in the driver (if provided), in
697 * which driver-specific buffer initialization can be performed,
698 * 2) if streaming is on, queues the buffer in driver by the means of buf_queue
699 * callback for processing.
700 *
701 * The return values from this function are intended to be directly returned
702 * from vidioc_qbuf handler in driver.
703 */
553int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); 704int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb);
705
706/**
707 * vb2_core_dqbuf() - Dequeue a buffer to the userspace
708 * @q: videobuf2 queue
709 * @pindex: pointer to the buffer index. May be NULL
710 * @pb: buffer structure passed from userspace to vidioc_dqbuf handler
711 * in driver
712 * @nonblocking: if true, this call will not sleep waiting for a buffer if no
713 * buffers ready for dequeuing are present. Normally the driver
714 * would be passing (file->f_flags & O_NONBLOCK) here
715 *
716 * Should be called from vidioc_dqbuf ioctl handler of a driver.
717 * The passed buffer should have been verified.
718 * This function:
719 * 1) calls buf_finish callback in the driver (if provided), in which
720 * driver can perform any additional operations that may be required before
721 * returning the buffer to userspace, such as cache sync,
722 * 2) the buffer struct members are filled with relevant information for
723 * the userspace.
724 *
725 * The return values from this function are intended to be directly returned
726 * from vidioc_dqbuf handler in driver.
727 */
554int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb, 728int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
555 bool nonblocking); 729 bool nonblocking);
556 730
557int vb2_core_streamon(struct vb2_queue *q, unsigned int type); 731int vb2_core_streamon(struct vb2_queue *q, unsigned int type);
558int vb2_core_streamoff(struct vb2_queue *q, unsigned int type); 732int vb2_core_streamoff(struct vb2_queue *q, unsigned int type);
559 733
734/**
735 * vb2_core_expbuf() - Export a buffer as a file descriptor
736 * @q: videobuf2 queue
737 * @fd: file descriptor associated with DMABUF (set by driver) *
738 * @type: buffer type
739 * @index: id number of the buffer
740 * @plane: index of the plane to be exported, 0 for single plane queues
741 * @flags: flags for newly created file, currently only O_CLOEXEC is
742 * supported, refer to manual of open syscall for more details
743 *
744 * The return values from this function are intended to be directly returned
745 * from vidioc_expbuf handler in driver.
746 */
560int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type, 747int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type,
561 unsigned int index, unsigned int plane, unsigned int flags); 748 unsigned int index, unsigned int plane, unsigned int flags);
562 749
750/**
751 * vb2_core_queue_init() - initialize a videobuf2 queue
752 * @q: videobuf2 queue; this structure should be allocated in driver
753 *
754 * The vb2_queue structure should be allocated by the driver. The driver is
755 * responsible of clearing it's content and setting initial values for some
756 * required entries before calling this function.
757 * q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer
758 * to the struct vb2_queue description in include/media/videobuf2-core.h
759 * for more information.
760 */
563int vb2_core_queue_init(struct vb2_queue *q); 761int vb2_core_queue_init(struct vb2_queue *q);
762
763/**
764 * vb2_core_queue_release() - stop streaming, release the queue and free memory
765 * @q: videobuf2 queue
766 *
767 * This function stops streaming and performs necessary clean ups, including
768 * freeing video buffer memory. The driver is responsible for freeing
769 * the vb2_queue structure itself.
770 */
564void vb2_core_queue_release(struct vb2_queue *q); 771void vb2_core_queue_release(struct vb2_queue *q);
565 772
773/**
774 * vb2_queue_error() - signal a fatal error on the queue
775 * @q: videobuf2 queue
776 *
777 * Flag that a fatal unrecoverable error has occurred and wake up all processes
778 * waiting on the queue. Polling will now set POLLERR and queuing and dequeuing
779 * buffers will return -EIO.
780 *
781 * The error flag will be cleared when cancelling the queue, either from
782 * vb2_streamoff or vb2_queue_release. Drivers should thus not call this
783 * function before starting the stream, otherwise the error flag will remain set
784 * until the queue is released when closing the device node.
785 */
566void vb2_queue_error(struct vb2_queue *q); 786void vb2_queue_error(struct vb2_queue *q);
567 787
788/**
789 * vb2_mmap() - map video buffers into application address space
790 * @q: videobuf2 queue
791 * @vma: vma passed to the mmap file operation handler in the driver
792 *
793 * Should be called from mmap file operation handler of a driver.
794 * This function maps one plane of one of the available video buffers to
795 * userspace. To map whole video memory allocated on reqbufs, this function
796 * has to be called once per each plane per each buffer previously allocated.
797 *
798 * When the userspace application calls mmap, it passes to it an offset returned
799 * to it earlier by the means of vidioc_querybuf handler. That offset acts as
800 * a "cookie", which is then used to identify the plane to be mapped.
801 * This function finds a plane with a matching offset and a mapping is performed
802 * by the means of a provided memory operation.
803 *
804 * The return values from this function are intended to be directly returned
805 * from the mmap handler in driver.
806 */
568int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma); 807int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma);
569#ifndef CONFIG_MMU 808#ifndef CONFIG_MMU
570unsigned long vb2_get_unmapped_area(struct vb2_queue *q, 809unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
@@ -573,6 +812,23 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
573 unsigned long pgoff, 812 unsigned long pgoff,
574 unsigned long flags); 813 unsigned long flags);
575#endif 814#endif
815
816/**
817 * vb2_core_poll() - implements poll userspace operation
818 * @q: videobuf2 queue
819 * @file: file argument passed to the poll file operation handler
820 * @wait: wait argument passed to the poll file operation handler
821 *
822 * This function implements poll file operation handler for a driver.
823 * For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will
824 * be informed that the file descriptor of a video device is available for
825 * reading.
826 * For OUTPUT queues, if a buffer is ready to be dequeued, the file descriptor
827 * will be reported as available for writing.
828 *
829 * The return values from this function are intended to be directly returned
830 * from poll handler in driver.
831 */
576unsigned int vb2_core_poll(struct vb2_queue *q, struct file *file, 832unsigned int vb2_core_poll(struct vb2_queue *q, struct file *file,
577 poll_table *wait); 833 poll_table *wait);
578size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count, 834size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count,
@@ -717,7 +973,20 @@ static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q)
717 * The following functions are not part of the vb2 core API, but are useful 973 * The following functions are not part of the vb2 core API, but are useful
718 * functions for videobuf2-*. 974 * functions for videobuf2-*.
719 */ 975 */
976
977/**
978 * vb2_buffer_in_use() - return true if the buffer is in use and
979 * the queue cannot be freed (by the means of REQBUFS(0)) call
980 *
981 * @vb: buffer for which plane size should be returned
982 * @q: videobuf queue
983 */
720bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb); 984bool vb2_buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb);
985
986/**
987 * vb2_verify_memory_type() - Check whether the memory type and buffer type
988 * passed to a buffer operation are compatible with the queue.
989 */
721int vb2_verify_memory_type(struct vb2_queue *q, 990int vb2_verify_memory_type(struct vb2_queue *q,
722 enum vb2_memory memory, unsigned int type); 991 enum vb2_memory memory, unsigned int type);
723#endif /* _MEDIA_VIDEOBUF2_CORE_H */ 992#endif /* _MEDIA_VIDEOBUF2_CORE_H */