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