1 /* 2 * Support for Intel Camera Imaging ISP subsystem. 3 * Copyright (c) 2010 - 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_QUEUE_H 16 #define __IA_CSS_QUEUE_H 17 18 #include <platform_support.h> 19 #include <type_support.h> 20 21 #include "ia_css_queue_comm.h" 22 #include "../src/queue_access.h" 23 24 /* Local Queue object descriptor */ 25 struct ia_css_queue_local { 26 ia_css_circbuf_desc_t *cb_desc; /*Circbuf desc for local queues*/ 27 ia_css_circbuf_elem_t *cb_elems; /*Circbuf elements*/ 28 }; 29 30 typedef struct ia_css_queue_local ia_css_queue_local_t; 31 32 /* Handle for queue object*/ 33 typedef struct ia_css_queue ia_css_queue_t; 34 35 /***************************************************************************** 36 * Queue Public APIs 37 *****************************************************************************/ 38 /* @brief Initialize a local queue instance. 39 * 40 * @param[out] qhandle. Handle to queue instance for use with API 41 * @param[in] desc. Descriptor with queue properties filled-in 42 * @return 0 - Successful init of local queue instance. 43 * @return EINVAL - Invalid argument. 44 * 45 */ 46 int ia_css_queue_local_init( 47 ia_css_queue_t *qhandle, 48 ia_css_queue_local_t *desc); 49 50 /* @brief Initialize a remote queue instance 51 * 52 * @param[out] qhandle. Handle to queue instance for use with API 53 * @param[in] desc. Descriptor with queue properties filled-in 54 * @return 0 - Successful init of remote queue instance. 55 * @return EINVAL - Invalid argument. 56 */ 57 int ia_css_queue_remote_init( 58 ia_css_queue_t *qhandle, 59 ia_css_queue_remote_t *desc); 60 61 /* @brief Uninitialize a queue instance 62 * 63 * @param[in] qhandle. Handle to queue instance 64 * @return 0 - Successful uninit. 65 * 66 */ 67 int ia_css_queue_uninit( 68 ia_css_queue_t *qhandle); 69 70 /* @brief Enqueue an item in the queue instance 71 * 72 * @param[in] qhandle. Handle to queue instance 73 * @param[in] item. Object to be enqueued. 74 * @return 0 - Successful enqueue. 75 * @return EINVAL - Invalid argument. 76 * @return ENOBUFS - Queue is full. 77 * 78 */ 79 int ia_css_queue_enqueue( 80 ia_css_queue_t *qhandle, 81 uint32_t item); 82 83 /* @brief Dequeue an item from the queue instance 84 * 85 * @param[in] qhandle. Handle to queue instance 86 * @param[out] item. Object to be dequeued into this item. 87 88 * @return 0 - Successful dequeue. 89 * @return EINVAL - Invalid argument. 90 * @return ENODATA - Queue is empty. 91 * 92 */ 93 int ia_css_queue_dequeue( 94 ia_css_queue_t *qhandle, 95 uint32_t *item); 96 97 /* @brief Check if the queue is empty 98 * 99 * @param[in] qhandle. Handle to queue instance 100 * @param[in] is_empty True if empty, False if not. 101 * @return 0 - Successful access state. 102 * @return EINVAL - Invalid argument. 103 * @return ENOSYS - Function not implemented. 104 * 105 */ 106 int ia_css_queue_is_empty( 107 ia_css_queue_t *qhandle, 108 bool *is_empty); 109 110 /* @brief Check if the queue is full 111 * 112 * @param[in] qhandle. Handle to queue instance 113 * @param[in] is_full True if Full, False if not. 114 * @return 0 - Successfully access state. 115 * @return EINVAL - Invalid argument. 116 * @return ENOSYS - Function not implemented. 117 * 118 */ 119 int ia_css_queue_is_full( 120 ia_css_queue_t *qhandle, 121 bool *is_full); 122 123 /* @brief Get used space in the queue 124 * 125 * @param[in] qhandle. Handle to queue instance 126 * @param[in] size Number of available elements in the queue 127 * @return 0 - Successfully access state. 128 * @return EINVAL - Invalid argument. 129 * 130 */ 131 int ia_css_queue_get_used_space( 132 ia_css_queue_t *qhandle, 133 uint32_t *size); 134 135 /* @brief Get free space in the queue 136 * 137 * @param[in] qhandle. Handle to queue instance 138 * @param[in] size Number of free elements in the queue 139 * @return 0 - Successfully access state. 140 * @return EINVAL - Invalid argument. 141 * 142 */ 143 int ia_css_queue_get_free_space( 144 ia_css_queue_t *qhandle, 145 uint32_t *size); 146 147 /* @brief Peek at an element in the queue 148 * 149 * @param[in] qhandle. Handle to queue instance 150 * @param[in] offset Offset of element to peek, 151 * starting from head of queue 152 * @param[in] element Value of element returned 153 * @return 0 - Successfully access state. 154 * @return EINVAL - Invalid argument. 155 * 156 */ 157 int ia_css_queue_peek( 158 ia_css_queue_t *qhandle, 159 u32 offset, 160 uint32_t *element); 161 162 /* @brief Get the usable size for the queue 163 * 164 * @param[in] qhandle. Handle to queue instance 165 * @param[out] size Size value to be returned here. 166 * @return 0 - Successful get size. 167 * @return EINVAL - Invalid argument. 168 * @return ENOSYS - Function not implemented. 169 * 170 */ 171 int ia_css_queue_get_size( 172 ia_css_queue_t *qhandle, 173 uint32_t *size); 174 175 #endif /* __IA_CSS_QUEUE_H */ 176