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 * 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_RMGR_VBUF_H
17#define _IA_CSS_RMGR_VBUF_H
18
19#include "ia_css_rmgr.h"
20#include <type_support.h>
21#include <ia_css_types.h>
22#include <system_local.h>
23
24/**
25 * @brief Data structure for the resource handle (host, vbuf)
26 */
27struct ia_css_rmgr_vbuf_handle {
28	ia_css_ptr vptr;
29	u8 count;
30	u32 size;
31};
32
33/**
34 * @brief Data structure for the resource pool (host, vbuf)
35 */
36struct ia_css_rmgr_vbuf_pool {
37	u8 copy_on_write;
38	u8 recycle;
39	u32 size;
40	u32 index;
41	struct ia_css_rmgr_vbuf_handle **handles;
42};
43
44/**
45 * @brief VBUF resource pools
46 */
47extern struct ia_css_rmgr_vbuf_pool *vbuf_ref;
48extern struct ia_css_rmgr_vbuf_pool *vbuf_write;
49extern struct ia_css_rmgr_vbuf_pool *hmm_buffer_pool;
50
51/**
52 * @brief Initialize the resource pool (host, vbuf)
53 *
54 * @param pool	The pointer to the pool
55 */
56STORAGE_CLASS_RMGR_H int ia_css_rmgr_init_vbuf(
57    struct ia_css_rmgr_vbuf_pool *pool);
58
59/**
60 * @brief Uninitialize the resource pool (host, vbuf)
61 *
62 * @param pool	The pointer to the pool
63 */
64STORAGE_CLASS_RMGR_H void ia_css_rmgr_uninit_vbuf(
65    struct ia_css_rmgr_vbuf_pool *pool);
66
67/**
68 * @brief Acquire a handle from the pool (host, vbuf)
69 *
70 * @param pool		The pointer to the pool
71 * @param handle	The pointer to the handle
72 */
73STORAGE_CLASS_RMGR_H void ia_css_rmgr_acq_vbuf(
74    struct ia_css_rmgr_vbuf_pool *pool,
75    struct ia_css_rmgr_vbuf_handle **handle);
76
77/**
78 * @brief Release a handle to the pool (host, vbuf)
79 *
80 * @param pool		The pointer to the pool
81 * @param handle	The pointer to the handle
82 */
83STORAGE_CLASS_RMGR_H void ia_css_rmgr_rel_vbuf(
84    struct ia_css_rmgr_vbuf_pool *pool,
85    struct ia_css_rmgr_vbuf_handle **handle);
86
87/**
88 * @brief Retain the reference count for a handle (host, vbuf)
89 *
90 * @param handle	The pointer to the handle
91 */
92void ia_css_rmgr_refcount_retain_vbuf(struct ia_css_rmgr_vbuf_handle **handle);
93
94/**
95 * @brief Release the reference count for a handle (host, vbuf)
96 *
97 * @param handle	The pointer to the handle
98 */
99void ia_css_rmgr_refcount_release_vbuf(struct ia_css_rmgr_vbuf_handle **handle);
100
101#endif	/* _IA_CSS_RMGR_VBUF_H */
102