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_CONTROL_H
17 #define __IA_CSS_CONTROL_H
18 
19 /* @file
20  * This file contains functionality for starting and controlling CSS
21  */
22 
23 #include <type_support.h>
24 #include <ia_css_env.h>
25 #include <ia_css_firmware.h>
26 #include <ia_css_irq.h>
27 
28 /* @brief Initialize the CSS API.
29  * @param[in]	env		Environment, provides functions to access the
30  *				environment in which the CSS code runs. This is
31  *				used for host side memory access and message
32  *				printing. May not be NULL.
33  * @param[in]	fw		Firmware package containing the firmware for all
34  *				predefined ISP binaries.
35  *				if fw is NULL the firmware must be loaded before
36  *				through a call of ia_css_load_firmware
37  * @param[in]	l1_base         Base index (isp2400)
38  *                              of the L1 page table. This is a physical
39  *                              address or index.
40  * @param[in]	irq_type	The type of interrupt to be used (edge or level)
41  * @return				Returns -EINVAL in case of any
42  *				errors and 0 otherwise.
43  *
44  * This function initializes the API which includes allocating and initializing
45  * internal data structures. This also interprets the firmware package. All
46  * contents of this firmware package are copied into local data structures, so
47  * the fw pointer could be freed after this function completes.
48  */
49 int ia_css_init(struct device           *dev,
50 			    const struct ia_css_env *env,
51 			    const struct ia_css_fw  *fw,
52 			    u32                     l1_base,
53 			    enum ia_css_irq_type    irq_type);
54 
55 /* @brief Un-initialize the CSS API.
56  * @return	None
57  *
58  * This function deallocates all memory that has been allocated by the CSS API
59  * Exception: if you explicitly loaded firmware through ia_css_load_firmware
60  * you need to call ia_css_unload_firmware to deallocate the memory reserved
61  * for the firmware.
62  * After this function is called, no other CSS functions should be called
63  * with the exception of ia_css_init which will re-initialize the CSS code,
64  * ia_css_unload_firmware to unload the firmware or ia_css_load_firmware
65  * to load new firmware
66  */
67 void
68 ia_css_uninit(void);
69 
70 /* @brief Enable use of a separate queue for ISYS events.
71  *
72  * @param[in]	enable: enable or disable use of separate ISYS event queues.
73  * @return		error if called when SP is running.
74  *
75  * @deprecated{This is a temporary function that allows drivers to migrate to
76  * the use of the separate ISYS event queue. Once all drivers supports this, it
77  * will be made the default and this function will be removed.
78  * This function should only be called when the SP is not running, calling it
79  * when the SP is running will result in an error value being returned. }
80  */
81 int
82 ia_css_enable_isys_event_queue(bool enable);
83 
84 /* @brief Test whether the ISP has started.
85  *
86  * @return	Boolean flag true if the ISP has started or false otherwise.
87  *
88  * Temporary function to poll whether the ISP has been started. Once it has,
89  * the sensor can also be started. */
90 bool
91 ia_css_isp_has_started(void);
92 
93 /* @brief Test whether the SP has initialized.
94  *
95  * @return	Boolean flag true if the SP has initialized or false otherwise.
96  *
97  * Temporary function to poll whether the SP has been initialized. Once it has,
98  * we can enqueue buffers. */
99 bool
100 ia_css_sp_has_initialized(void);
101 
102 /* @brief Test whether the SP has terminated.
103  *
104  * @return	Boolean flag true if the SP has terminated or false otherwise.
105  *
106  * Temporary function to poll whether the SP has been terminated. Once it has,
107  * we can switch mode. */
108 bool
109 ia_css_sp_has_terminated(void);
110 
111 /* @brief start SP hardware
112  *
113  * @return			0 or error code upon error.
114  *
115  * It will boot the SP hardware and start multi-threading infrastructure.
116  * All threads will be started and blocked by semaphore. This function should
117  * be called before any ia_css_stream_start().
118  */
119 int
120 ia_css_start_sp(void);
121 
122 /* @brief stop SP hardware
123  *
124  * @return			0 or error code upon error.
125  *
126  * This function will terminate all threads and shut down SP. It should be
127  * called after all ia_css_stream_stop().
128  */
129 int
130 ia_css_stop_sp(void);
131 
132 #endif /* __IA_CSS_CONTROL_H */
133