1e9fad6f1SYong Zhi /* SPDX-License-Identifier: GPL-2.0 */ 2e9fad6f1SYong Zhi /* Copyright (C) 2018 Intel Corporation */ 3e9fad6f1SYong Zhi 4e9fad6f1SYong Zhi #ifndef __IPU3_UTIL_H 5e9fad6f1SYong Zhi #define __IPU3_UTIL_H 6e9fad6f1SYong Zhi 7e9fad6f1SYong Zhi struct device; 8e9fad6f1SYong Zhi struct imgu_device; 9e9fad6f1SYong Zhi 10e9fad6f1SYong Zhi #define IPU3_CSS_POOL_SIZE 4 11e9fad6f1SYong Zhi 12e9fad6f1SYong Zhi /** 13328085e1SHans Verkuil * struct imgu_css_map - store DMA mapping info for buffer 14e9fad6f1SYong Zhi * 15e9fad6f1SYong Zhi * @size: size of the buffer in bytes. 16e9fad6f1SYong Zhi * @vaddr: kernel virtual address. 17e9fad6f1SYong Zhi * @daddr: iova dma address to access IPU3. 18*cef944c8SSakari Ailus * @pages: pages mapped to this buffer 19e9fad6f1SYong Zhi */ 2027b795adSYong Zhi struct imgu_css_map { 21e9fad6f1SYong Zhi size_t size; 22e9fad6f1SYong Zhi void *vaddr; 23e9fad6f1SYong Zhi dma_addr_t daddr; 24f8092aa1SChristoph Hellwig struct page **pages; 25e9fad6f1SYong Zhi }; 26e9fad6f1SYong Zhi 27e9fad6f1SYong Zhi /** 28328085e1SHans Verkuil * struct imgu_css_pool - circular buffer pool definition 29e9fad6f1SYong Zhi * 30e9fad6f1SYong Zhi * @entry: array with IPU3_CSS_POOL_SIZE elements. 3127b795adSYong Zhi * @entry.param: a &struct imgu_css_map for storing the mem mapping. 32e9fad6f1SYong Zhi * @entry.valid: used to mark if the entry has valid data. 33e9fad6f1SYong Zhi * @last: write pointer, initialized to IPU3_CSS_POOL_SIZE. 34e9fad6f1SYong Zhi */ 3527b795adSYong Zhi struct imgu_css_pool { 36e9fad6f1SYong Zhi struct { 3727b795adSYong Zhi struct imgu_css_map param; 38e9fad6f1SYong Zhi bool valid; 39e9fad6f1SYong Zhi } entry[IPU3_CSS_POOL_SIZE]; 40e9fad6f1SYong Zhi u32 last; 41e9fad6f1SYong Zhi }; 42e9fad6f1SYong Zhi 4327b795adSYong Zhi int imgu_css_dma_buffer_resize(struct imgu_device *imgu, 4427b795adSYong Zhi struct imgu_css_map *map, size_t size); 4527b795adSYong Zhi void imgu_css_pool_cleanup(struct imgu_device *imgu, 4627b795adSYong Zhi struct imgu_css_pool *pool); 4727b795adSYong Zhi int imgu_css_pool_init(struct imgu_device *imgu, struct imgu_css_pool *pool, 48e9fad6f1SYong Zhi size_t size); 4927b795adSYong Zhi void imgu_css_pool_get(struct imgu_css_pool *pool); 5027b795adSYong Zhi void imgu_css_pool_put(struct imgu_css_pool *pool); 5127b795adSYong Zhi const struct imgu_css_map *imgu_css_pool_last(struct imgu_css_pool *pool, 52e9fad6f1SYong Zhi u32 last); 53e9fad6f1SYong Zhi 54e9fad6f1SYong Zhi #endif 55