| #ifndef __DXS_FIFO_H__ |
| #define __DXS_FIFO_H__ |
| /****************************************************************************** |
| |
| Copyright (c) 2006-2015 Lantiq Deutschland GmbH |
| Copyright (c) 2015 Lantiq Beteiligungs-GmbH & Co.KG |
| Copyright 2018, Intel Corporation. |
| |
| For licensing information, see the file 'LICENSE' in the root folder of |
| this software module. |
| |
| ******************************************************************************/ |
| |
| /** |
| \file dxs_fifo.h |
| DxS fifo declarations. |
| */ |
| |
| /* |
| | header | elem 0 | elem 1 | elem 2 | ... |
| +------------+-------+--------+--------+---+------+---+------+---+------+------- |
| | magic code | count | wr_idx | rd_idx | p | size | p | size | p | size | ... |
| +------------+-------+--------+--------+-+-+------+-+-+------+-+-+------+------- |
| | | | |
| V V V |
| */ |
| |
| /* ========================================================================== */ |
| /* Includes */ |
| /* ========================================================================== */ |
| |
| /* ========================================================================== */ |
| /* Macro definitions */ |
| /* ========================================================================== */ |
| #define MAX_FIFO_SIZE 200 /* in elements */ |
| #define DXS_FIFO_MAGIC_CODE 0x41464946 |
| /* return codes */ |
| #define DXS_FIFO_OK 0 |
| #define DXS_FIFO_FULL (-1) |
| #define DXS_FIFO_EMPTY (-2) |
| #define DXS_FIFO_INV (-3) |
| |
| /* ========================================================================== */ |
| /* Type definitions */ |
| /* ========================================================================== */ |
| /** FIFO_Elem_t */ |
| typedef struct |
| { |
| void *data; |
| uint32_t size; |
| } FIFO_Elem_t; |
| |
| /** FIFO_t */ |
| typedef struct |
| { |
| uint32_t magic; |
| uint32_t in_use; |
| uint32_t fifo_size; |
| uint32_t count; |
| uint32_t wr_idx; |
| uint32_t rd_idx; |
| pthread_mutex_t mtx; |
| FIFO_Elem_t elem[MAX_FIFO_SIZE]; |
| } FIFO_t; |
| |
| /* ========================================================================== */ |
| /* Function prototypes */ |
| /* ========================================================================== */ |
| FIFO_t* fifo_init (uint32_t elememts); |
| void fifo_flush (FIFO_t *fifo); |
| uint32_t fifo_count (FIFO_t *fifo); |
| int32_t fifo_put (FIFO_t *fifo, void *data, uint32_t size); |
| int32_t fifo_get (FIFO_t *fifo, void **data, uint32_t *size); |
| |
| extern void fifo_destroy (FIFO_t *fifo); |
| |
| #endif /* __DXS_FIFO_H__ */ |