xref: /linux/drivers/staging/media/atomisp/pci/ia_css_control.h (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
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]	l1_base         Base index (isp2400)
34  *                              of the L1 page table. This is a physical
35  *                              address or index.
36  * @param[in]	irq_type	The type of interrupt to be used (edge or level)
37  * @return			Returns -EINVAL in case of any
38  *				errors and 0 otherwise.
39  *
40  * This function initializes the API which includes allocating and initializing
41  * internal data structures.
42  * ia_css_load_firmware() must be called to load the firmware before calling
43  * this function.
44  */
45 int ia_css_init(struct device           *dev,
46 		const struct ia_css_env *env,
47 		u32                     l1_base,
48 		enum ia_css_irq_type    irq_type);
49 
50 /* @brief Un-initialize the CSS API.
51  * @return	None
52  *
53  * This function deallocates all memory that has been allocated by the CSS API.
54  * After this function is called, no other CSS functions should be called.
55  */
56 void
57 ia_css_uninit(void);
58 
59 /* @brief Enable use of a separate queue for ISYS events.
60  *
61  * @param[in]	enable: enable or disable use of separate ISYS event queues.
62  * @return		error if called when SP is running.
63  *
64  * @deprecated{This is a temporary function that allows drivers to migrate to
65  * the use of the separate ISYS event queue. Once all drivers supports this, it
66  * will be made the default and this function will be removed.
67  * This function should only be called when the SP is not running, calling it
68  * when the SP is running will result in an error value being returned. }
69  */
70 int
71 ia_css_enable_isys_event_queue(bool enable);
72 
73 /* @brief Test whether the ISP has started.
74  *
75  * @return	Boolean flag true if the ISP has started or false otherwise.
76  *
77  * Temporary function to poll whether the ISP has been started. Once it has,
78  * the sensor can also be started. */
79 bool
80 ia_css_isp_has_started(void);
81 
82 /* @brief Test whether the SP has initialized.
83  *
84  * @return	Boolean flag true if the SP has initialized or false otherwise.
85  *
86  * Temporary function to poll whether the SP has been initialized. Once it has,
87  * we can enqueue buffers. */
88 bool
89 ia_css_sp_has_initialized(void);
90 
91 /* @brief Test whether the SP has terminated.
92  *
93  * @return	Boolean flag true if the SP has terminated or false otherwise.
94  *
95  * Temporary function to poll whether the SP has been terminated. Once it has,
96  * we can switch mode. */
97 bool
98 ia_css_sp_has_terminated(void);
99 
100 /* @brief start SP hardware
101  *
102  * @return			0 or error code upon error.
103  *
104  * It will boot the SP hardware and start multi-threading infrastructure.
105  * All threads will be started and blocked by semaphore. This function should
106  * be called before any ia_css_stream_start().
107  */
108 int
109 ia_css_start_sp(void);
110 
111 /* @brief stop SP hardware
112  *
113  * @return			0 or error code upon error.
114  *
115  * This function will terminate all threads and shut down SP. It should be
116  * called after all ia_css_stream_stop().
117  */
118 int
119 ia_css_stop_sp(void);
120 
121 #endif /* __IA_CSS_CONTROL_H */
122