GNU Linux-libre 4.14.254-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / base / refcount / interface / ia_css_refcount.h
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
22 typedef void (*clear_func)(hrt_vaddress ptr);
23
24 /*! \brief Function for initializing refcount list
25  *
26  * \param[in]   size            Size of the refcount list.
27  * \return                              ia_css_err
28  */
29 extern enum ia_css_err ia_css_refcount_init(uint32_t size);
30
31 /*! \brief Function for de-initializing refcount list
32  *
33  * \return                              None
34  */
35 extern void ia_css_refcount_uninit(void);
36
37 /*! \brief Function for increasing reference by 1.
38  *
39  * \param[in]   id              ID of the object.
40  * \param[in]   ptr             Data of the object (ptr).
41  * \return                              hrt_vaddress (saved address)
42  */
43 extern hrt_vaddress ia_css_refcount_increment(int32_t id, hrt_vaddress ptr);
44
45 /*! \brief Function for decrease reference by 1.
46  *
47  * \param[in]   id              ID of the object.
48  * \param[in]   ptr             Data of the object (ptr).
49  *
50  *      - true, if it is successful.
51  *      - false, otherwise.
52  */
53 extern bool ia_css_refcount_decrement(int32_t id, hrt_vaddress ptr);
54
55 /*! \brief Function to check if reference count is 1.
56  *
57  * \param[in]   ptr             Data of the object (ptr).
58  *
59  *      - true, if it is successful.
60  *      - false, otherwise.
61  */
62 extern bool ia_css_refcount_is_single(hrt_vaddress ptr);
63
64 /*! \brief Function to clear reference list objects.
65  *
66  * \param[in]   id                      ID of the object.
67  * \param[in] clear_func        function to be run to free reference objects.
68  *
69  *  return                              None
70  */
71 extern void ia_css_refcount_clear(int32_t id,
72                                   clear_func clear_func_ptr);
73
74 /*! \brief Function to verify if object is valid
75  *
76  * \param[in] ptr       Data of the object (ptr)
77  *
78  *      - true, if valid
79  *      - false, if invalid
80  */
81 extern bool ia_css_refcount_is_valid(hrt_vaddress ptr);
82
83 #endif /* _IA_CSS_REFCOUNT_H_ */