1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2015, Intel Corporation. 5 */ 6 7 #ifndef __IA_CSS_ENV_H 8 #define __IA_CSS_ENV_H 9 10 #include <type_support.h> 11 #include <linux/stdarg.h> /* va_list */ 12 #include <linux/bits.h> 13 #include "ia_css_types.h" 14 #include "ia_css_acc_types.h" 15 16 /* @file 17 * This file contains prototypes for functions that need to be provided to the 18 * CSS-API host-code by the environment in which the CSS-API code runs. 19 */ 20 21 /* Memory allocation attributes, for use in ia_css_css_mem_env. */ 22 enum ia_css_mem_attr { 23 IA_CSS_MEM_ATTR_CACHED = BIT(0), 24 IA_CSS_MEM_ATTR_ZEROED = BIT(1), 25 IA_CSS_MEM_ATTR_PAGEALIGN = BIT(2), 26 IA_CSS_MEM_ATTR_CONTIGUOUS = BIT(3), 27 }; 28 29 /* Environment with function pointers for local IA memory allocation. 30 * This provides the CSS code with environment specific functionality 31 * for memory allocation of small local buffers such as local data structures. 32 * This is never expected to allocate more than one page of memory (4K bytes). 33 */ 34 struct ia_css_cpu_mem_env { 35 void (*flush)(struct ia_css_acc_fw *fw); 36 /** Flush function to flush the cache for given accelerator. */ 37 }; 38 39 /* Environment with function pointers to access the CSS hardware. This includes 40 * registers and local memories. 41 */ 42 struct ia_css_hw_access_env { 43 void (*store_8)(hrt_address addr, uint8_t data); 44 /** Store an 8 bit value into an address in the CSS HW address space. 45 The address must be an 8 bit aligned address. */ 46 void (*store_16)(hrt_address addr, uint16_t data); 47 /** Store a 16 bit value into an address in the CSS HW address space. 48 The address must be a 16 bit aligned address. */ 49 void (*store_32)(hrt_address addr, uint32_t data); 50 /** Store a 32 bit value into an address in the CSS HW address space. 51 The address must be a 32 bit aligned address. */ 52 uint8_t (*load_8)(hrt_address addr); 53 /** Load an 8 bit value from an address in the CSS HW address 54 space. The address must be an 8 bit aligned address. */ 55 uint16_t (*load_16)(hrt_address addr); 56 /** Load a 16 bit value from an address in the CSS HW address 57 space. The address must be a 16 bit aligned address. */ 58 uint32_t (*load_32)(hrt_address addr); 59 /** Load a 32 bit value from an address in the CSS HW address 60 space. The address must be a 32 bit aligned address. */ 61 void (*store)(hrt_address addr, const void *data, uint32_t bytes); 62 /** Store a number of bytes into a byte-aligned address in the CSS HW address space. */ 63 void (*load)(hrt_address addr, void *data, uint32_t bytes); 64 /** Load a number of bytes from a byte-aligned address in the CSS HW address space. */ 65 }; 66 67 /* Environment with function pointers to print error and debug messages. 68 */ 69 struct ia_css_print_env { 70 int __printf(1, 0) (*debug_print)(const char *fmt, va_list args); 71 /** Print a debug message. */ 72 int __printf(1, 0) (*error_print)(const char *fmt, va_list args); 73 /** Print an error message.*/ 74 }; 75 76 /* Environment structure. This includes function pointers to access several 77 * features provided by the environment in which the CSS API is used. 78 * This is used to run the camera IP in multiple platforms such as Linux, 79 * Windows and several simulation environments. 80 */ 81 struct ia_css_env { 82 struct ia_css_cpu_mem_env cpu_mem_env; /** local flush. */ 83 struct ia_css_hw_access_env hw_access_env; /** CSS HW access functions */ 84 struct ia_css_print_env print_env; /** Message printing env. */ 85 }; 86 87 #endif /* __IA_CSS_ENV_H */ 88