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