1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2010 - 2015, Intel Corporation.
5  */
6 
7 #ifndef _IA_CSS_RMGR_VBUF_H
8 #define _IA_CSS_RMGR_VBUF_H
9 
10 #include "ia_css_rmgr.h"
11 #include <type_support.h>
12 #include <ia_css_types.h>
13 #include <system_local.h>
14 
15 /**
16  * @brief Data structure for the resource handle (host, vbuf)
17  */
18 struct ia_css_rmgr_vbuf_handle {
19 	ia_css_ptr vptr;
20 	u8 count;
21 	u32 size;
22 };
23 
24 /**
25  * @brief Data structure for the resource pool (host, vbuf)
26  */
27 struct ia_css_rmgr_vbuf_pool {
28 	u8 copy_on_write;
29 	u8 recycle;
30 	u32 size;
31 	u32 index;
32 	struct ia_css_rmgr_vbuf_handle **handles;
33 };
34 
35 /**
36  * @brief VBUF resource pools
37  */
38 extern struct ia_css_rmgr_vbuf_pool *vbuf_ref;
39 extern struct ia_css_rmgr_vbuf_pool *vbuf_write;
40 extern struct ia_css_rmgr_vbuf_pool *hmm_buffer_pool;
41 
42 /**
43  * @brief Initialize the resource pool (host, vbuf)
44  *
45  * @param pool	The pointer to the pool
46  */
47 STORAGE_CLASS_RMGR_H int ia_css_rmgr_init_vbuf(
48     struct ia_css_rmgr_vbuf_pool *pool);
49 
50 /**
51  * @brief Uninitialize the resource pool (host, vbuf)
52  *
53  * @param pool	The pointer to the pool
54  */
55 STORAGE_CLASS_RMGR_H void ia_css_rmgr_uninit_vbuf(
56     struct ia_css_rmgr_vbuf_pool *pool);
57 
58 /**
59  * @brief Acquire a handle from the pool (host, vbuf)
60  *
61  * @param pool		The pointer to the pool
62  * @param handle	The pointer to the handle
63  */
64 STORAGE_CLASS_RMGR_H void ia_css_rmgr_acq_vbuf(
65     struct ia_css_rmgr_vbuf_pool *pool,
66     struct ia_css_rmgr_vbuf_handle **handle);
67 
68 /**
69  * @brief Release a handle to the pool (host, vbuf)
70  *
71  * @param pool		The pointer to the pool
72  * @param handle	The pointer to the handle
73  */
74 STORAGE_CLASS_RMGR_H void ia_css_rmgr_rel_vbuf(
75     struct ia_css_rmgr_vbuf_pool *pool,
76     struct ia_css_rmgr_vbuf_handle **handle);
77 
78 /**
79  * @brief Retain the reference count for a handle (host, vbuf)
80  *
81  * @param handle	The pointer to the handle
82  */
83 void ia_css_rmgr_refcount_retain_vbuf(struct ia_css_rmgr_vbuf_handle **handle);
84 
85 /**
86  * @brief Release the reference count for a handle (host, vbuf)
87  *
88  * @param handle	The pointer to the handle
89  */
90 void ia_css_rmgr_refcount_release_vbuf(struct ia_css_rmgr_vbuf_handle **handle);
91 
92 #endif	/* _IA_CSS_RMGR_VBUF_H */
93