Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * helper functions for SG DMA video4linux capture buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * The functions expect the hardware being able to scatter gather
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * (i.e. the buffers are not linear in physical memory, but fragmented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * into PAGE_SIZE chunks).  They also assume the driver does not need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * to touch the video data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * (c) 2007 Mauro Carvalho Chehab, <mchehab@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * Highly based on video-buf written originally by:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * (c) 2006 Mauro Carvalho Chehab, <mchehab@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * (c) 2006 Ted Walther and John Sokol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #ifndef _VIDEOBUF_DMA_SG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define _VIDEOBUF_DMA_SG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <media/videobuf-core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) /* --------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * A small set of helper functions to manage buffers (both userland
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * and kernel) for DMA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * videobuf_dma_init_*()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  *	creates a buffer.  The userland version takes a userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *	pointer + length.  The kernel version just wants the size and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  *	does memory allocation too using vmalloc_32().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * videobuf_dma_*()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *	see Documentation/core-api/dma-api-howto.rst, these functions to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *	basically the same.  The map function does also build a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *	scatterlist for the buffer (and unmap frees it ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * videobuf_dma_free()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *	no comment ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct videobuf_dmabuf {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	u32                 magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	/* for userland buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	int                 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	size_t		    size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	struct page         **pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	/* for kernel buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	void                *vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	struct page         **vaddr_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	dma_addr_t          *dma_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	struct device       *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	/* for overlay buffers (pci-pci dma) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	dma_addr_t          bus_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	/* common */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct scatterlist  *sglist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	int                 sglen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	unsigned long       nr_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int                 direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct videobuf_dma_sg_memory {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	u32                 magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	/* for mmap'ed buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	struct videobuf_dmabuf  dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  * Scatter-gather DMA buffer API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * These functions provide a simple way to create a page list and a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * scatter-gather list from a kernel, userspace of physical address and map the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * memory for DMA operation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * Despite the name, this is totally unrelated to videobuf, except that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * videobuf-dma-sg uses the same API internally.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) int videobuf_dma_free(struct videobuf_dmabuf *dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) int videobuf_dma_unmap(struct device *dev, struct videobuf_dmabuf *dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) struct videobuf_dmabuf *videobuf_to_dma(struct videobuf_buffer *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) void *videobuf_sg_alloc(size_t size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) void videobuf_queue_sg_init(struct videobuf_queue *q,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			 const struct videobuf_queue_ops *ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			 struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			 spinlock_t *irqlock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			 enum v4l2_buf_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			 enum v4l2_field field,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			 unsigned int msize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			 void *priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			 struct mutex *ext_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #endif /* _VIDEOBUF_DMA_SG_H */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)