1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14 
15 #ifndef _IA_CSS_REFCOUNT_H_
16 #define _IA_CSS_REFCOUNT_H_
17 
18 #include <type_support.h>
19 #include <system_types.h>
20 #include <ia_css_err.h>
21 #include <ia_css_types.h>
22 
23 typedef void (*clear_func)(ia_css_ptr ptr);
24 
25 /*! \brief Function for initializing refcount list
26  *
27  * \param[in]	size		Size of the refcount list.
28  * \return				ia_css_err
29  */
30 int ia_css_refcount_init(uint32_t size);
31 
32 /*! \brief Function for de-initializing refcount list
33  *
34  * \return				None
35  */
36 void ia_css_refcount_uninit(void);
37 
38 /*! \brief Function for increasing reference by 1.
39  *
40  * \param[in]	id		ID of the object.
41  * \param[in]	ptr		Data of the object (ptr).
42  * \return				ia_css_ptr (saved address)
43  */
44 ia_css_ptr ia_css_refcount_increment(s32 id, ia_css_ptr ptr);
45 
46 /*! \brief Function for decrease reference by 1.
47  *
48  * \param[in]	id		ID of the object.
49  * \param[in]	ptr		Data of the object (ptr).
50  *
51  *	- true, if it is successful.
52  *	- false, otherwise.
53  */
54 bool ia_css_refcount_decrement(s32 id, ia_css_ptr ptr);
55 
56 /*! \brief Function to check if reference count is 1.
57  *
58  * \param[in]	ptr		Data of the object (ptr).
59  *
60  *	- true, if it is successful.
61  *	- false, otherwise.
62  */
63 bool ia_css_refcount_is_single(ia_css_ptr ptr);
64 
65 /*! \brief Function to clear reference list objects.
66  *
67  * \param[in]	id			ID of the object.
68  * \param[in] clear_func	function to be run to free reference objects.
69  *
70  *  return				None
71  */
72 void ia_css_refcount_clear(s32 id,
73 			   clear_func clear_func_ptr);
74 
75 /*! \brief Function to verify if object is valid
76  *
77  * \param[in] ptr       Data of the object (ptr)
78  *
79  *      - true, if valid
80  *      - false, if invalid
81  */
82 bool ia_css_refcount_is_valid(ia_css_ptr ptr);
83 
84 #endif /* _IA_CSS_REFCOUNT_H_ */
85