1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (C) 2018 Intel Corporation */ 3 4 #ifndef __IPU3_UTIL_H 5 #define __IPU3_UTIL_H 6 7 struct device; 8 struct imgu_device; 9 10 #define IPU3_CSS_POOL_SIZE 4 11 12 /** 13 * ipu3_css_map - store DMA mapping info for buffer 14 * 15 * @size: size of the buffer in bytes. 16 * @vaddr: kernel virtual address. 17 * @daddr: iova dma address to access IPU3. 18 * @vma: private, a pointer to &struct vm_struct, 19 * used for ipu3_dmamap_free. 20 */ 21 struct ipu3_css_map { 22 size_t size; 23 void *vaddr; 24 dma_addr_t daddr; 25 struct vm_struct *vma; 26 }; 27 28 /** 29 * ipu3_css_pool - circular buffer pool definition 30 * 31 * @entry: array with IPU3_CSS_POOL_SIZE elements. 32 * @entry.param: a &struct ipu3_css_map for storing the mem mapping. 33 * @entry.valid: used to mark if the entry has valid data. 34 * @last: write pointer, initialized to IPU3_CSS_POOL_SIZE. 35 */ 36 struct ipu3_css_pool { 37 struct { 38 struct ipu3_css_map param; 39 bool valid; 40 } entry[IPU3_CSS_POOL_SIZE]; 41 u32 last; 42 }; 43 44 int ipu3_css_dma_buffer_resize(struct imgu_device *imgu, 45 struct ipu3_css_map *map, size_t size); 46 void ipu3_css_pool_cleanup(struct imgu_device *imgu, 47 struct ipu3_css_pool *pool); 48 int ipu3_css_pool_init(struct imgu_device *imgu, struct ipu3_css_pool *pool, 49 size_t size); 50 void ipu3_css_pool_get(struct ipu3_css_pool *pool); 51 void ipu3_css_pool_put(struct ipu3_css_pool *pool); 52 const struct ipu3_css_map *ipu3_css_pool_last(struct ipu3_css_pool *pool, 53 u32 last); 54 55 #endif 56