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_REFCOUNT_H_
8 #define _IA_CSS_REFCOUNT_H_
9 
10 #include <type_support.h>
11 #include <system_local.h>
12 #include <ia_css_err.h>
13 #include <ia_css_types.h>
14 
15 typedef void (*clear_func)(ia_css_ptr ptr);
16 
17 /*! \brief Function for initializing refcount list
18  *
19  * \param[in]	size		Size of the refcount list.
20  * \return				ia_css_err
21  */
22 int ia_css_refcount_init(uint32_t size);
23 
24 /*! \brief Function for de-initializing refcount list
25  *
26  * \return				None
27  */
28 void ia_css_refcount_uninit(void);
29 
30 /*! \brief Function for increasing reference by 1.
31  *
32  * \param[in]	id		ID of the object.
33  * \param[in]	ptr		Data of the object (ptr).
34  * \return				ia_css_ptr (saved address)
35  */
36 ia_css_ptr ia_css_refcount_increment(s32 id, ia_css_ptr ptr);
37 
38 /*! \brief Function for decrease reference by 1.
39  *
40  * \param[in]	id		ID of the object.
41  * \param[in]	ptr		Data of the object (ptr).
42  *
43  *	- true, if it is successful.
44  *	- false, otherwise.
45  */
46 bool ia_css_refcount_decrement(s32 id, ia_css_ptr ptr);
47 
48 /*! \brief Function to check if reference count is 1.
49  *
50  * \param[in]	ptr		Data of the object (ptr).
51  *
52  *	- true, if it is successful.
53  *	- false, otherwise.
54  */
55 bool ia_css_refcount_is_single(ia_css_ptr ptr);
56 
57 /*! \brief Function to clear reference list objects.
58  *
59  * \param[in]	id			ID of the object.
60  * \param[in] clear_func	function to be run to free reference objects.
61  *
62  *  return				None
63  */
64 void ia_css_refcount_clear(s32 id,
65 			   clear_func clear_func_ptr);
66 
67 /*! \brief Function to verify if object is valid
68  *
69  * \param[in] ptr       Data of the object (ptr)
70  *
71  *      - true, if valid
72  *      - false, if invalid
73  */
74 bool ia_css_refcount_is_valid(ia_css_ptr ptr);
75 
76 #endif /* _IA_CSS_REFCOUNT_H_ */
77