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