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_BUFQ_H
17 #define _IA_CSS_BUFQ_H
18 
19 #include <type_support.h>
20 #include "ia_css_bufq_comm.h"
21 #include "ia_css_buffer.h"
22 #include "ia_css_err.h"
23 #define BUFQ_EVENT_SIZE 4
24 
25 /**
26  * @brief Query the internal frame ID.
27  *
28  * @param[in]	key	The query key.
29  * @param[out]	val	The query value.
30  *
31  * @return
32  *	true, if the query succeeds;
33  *	false, if the query fails.
34  */
35 bool ia_css_query_internal_queue_id(
36     enum ia_css_buffer_type buf_type,
37     unsigned int thread_id,
38     enum sh_css_queue_id *val
39 );
40 
41 /**
42  * @brief  Map buffer type to a internal queue id.
43  *
44  * @param[in] thread id		Thread in which the buffer type has to be mapped or unmapped
45  * @param[in] buf_type		buffer type.
46  * @param[in] map		boolean flag to specify map or unmap
47  * @return none
48  */
49 void ia_css_queue_map(
50     unsigned int thread_id,
51     enum ia_css_buffer_type buf_type,
52     bool map
53 );
54 
55 /**
56  * @brief  Initialize buffer type to a queue id mapping
57  * @return none
58  */
59 void ia_css_queue_map_init(void);
60 
61 /**
62  * @brief initializes bufq module
63  * It create instances of
64  * -host to SP buffer queue  which is a list with predefined size,
65  *	MxN queues where M is the number threads and N is the number queues per thread
66  *-SP to host buffer queue , is a list with N queues
67  *-host to SP event communication queue
68  * -SP to host event communication queue
69  * -queue for tagger commands
70  * @return none
71  */
72 void ia_css_bufq_init(void);
73 
74 /**
75 * @brief Enqueues an item into host to SP buffer queue
76  *
77  * @param thread_index[in]	Thread in which the item to be enqueued
78  *
79  * @param queue_id[in]		Index of the queue in the specified thread
80  * @param item[in]		Object to enqueue.
81  * @return	0 or error code upon error.
82  *
83 */
84 int ia_css_bufq_enqueue_buffer(
85     int thread_index,
86     int queue_id,
87     uint32_t item);
88 
89 /**
90 * @brief Dequeues an item from SP to host buffer queue.
91  *
92  * @param queue_id[in]		Specifies  the index of the queue in the list where
93  *				the item has to be read.
94  * @paramitem [out]		Object to be dequeued into this item.
95  * @return	0 or error code upon error.
96  *
97 */
98 int ia_css_bufq_dequeue_buffer(
99     int queue_id,
100     uint32_t *item);
101 
102 /**
103 * @brief  Enqueue an event item into host to SP communication event queue.
104  *
105  * @param[in]	evt_id		      The event ID.
106  * @param[in]	evt_payload_0	The event payload.
107  * @param[in]	evt_payload_1	The event payload.
108  * @param[in]	evt_payload_2	The event payload.
109  * @return	0 or error code upon error.
110  *
111 */
112 int ia_css_bufq_enqueue_psys_event(
113     u8 evt_id,
114     u8 evt_payload_0,
115     u8 evt_payload_1,
116     uint8_t evt_payload_2
117 );
118 
119 /**
120  * @brief   Dequeue an item from  SP to host communication event queue.
121  *
122  * @param item	Object to be dequeued into this item.
123  * @return	0 or error code upon error.
124  *
125 */
126 int ia_css_bufq_dequeue_psys_event(
127     u8 item[BUFQ_EVENT_SIZE]
128 
129 );
130 
131 /**
132  * @brief  Enqueue an event item into host to SP EOF event queue.
133  *
134  * @param[in]	evt_id		      The event ID.
135  * @return	0 or error code upon error.
136  *
137  */
138 int ia_css_bufq_enqueue_isys_event(
139     uint8_t evt_id);
140 
141 /**
142 * @brief   Dequeue an item from  SP to host communication EOF event queue.
143 
144  *
145  * @param item	Object to be dequeued into this item.
146  * @return	0 or error code upon error.
147  *
148  */
149 int ia_css_bufq_dequeue_isys_event(
150     u8 item[BUFQ_EVENT_SIZE]);
151 
152 /**
153 * @brief   Enqueue a tagger command item into tagger command queue..
154  *
155  * @param item	Object to be enqueue.
156  * @return	0 or error code upon error.
157  *
158 */
159 int ia_css_bufq_enqueue_tag_cmd(
160     uint32_t item);
161 
162 /**
163 * @brief  Uninitializes bufq module.
164  *
165  * @return	0 or error code upon error.
166  *
167 */
168 int ia_css_bufq_deinit(void);
169 
170 /**
171 * @brief  Dump queue states
172  *
173  * @return	None
174  *
175 */
176 void ia_css_bufq_dump_queue_info(void);
177 
178 #endif	/* _IA_CSS_BUFQ_H */
179