1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 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_CIRCBUF_COMM_H
17 #define _IA_CSS_CIRCBUF_COMM_H
18 
19 #include <type_support.h>  /* uint8_t, uint32_t */
20 
21 #define IA_CSS_CIRCBUF_PADDING 1 /* The circular buffer is implemented in lock-less manner, wherein
22 				   * the head and tail can advance independently without any locks.
23 				   * But to achieve this, an extra buffer element is required to detect
24 				   * queue full & empty conditions, wherein the tail trails the head for
25 				   * full and is equal to head for empty condition. This causes 1 buffer
26 				   * not being available for use.
27 				   */
28 
29 /****************************************************************
30  *
31  * Portable Data structures
32  *
33  ****************************************************************/
34 /**
35  * @brief Data structure for the circular descriptor.
36  */
37 typedef struct ia_css_circbuf_desc_s ia_css_circbuf_desc_t;
38 struct ia_css_circbuf_desc_s {
39 	u8 size;	/* the maximum number of elements*/
40 	u8 step;   /* number of bytes per element */
41 	u8 start;	/* index of the oldest element */
42 	u8 end;	/* index at which to write the new element */
43 };
44 
45 #define SIZE_OF_IA_CSS_CIRCBUF_DESC_S_STRUCT				\
46 	(4 * sizeof(uint8_t))
47 
48 /**
49  * @brief Data structure for the circular buffer element.
50  */
51 typedef struct ia_css_circbuf_elem_s ia_css_circbuf_elem_t;
52 struct ia_css_circbuf_elem_s {
53 	u32 val;	/* the value stored in the element */
54 };
55 
56 #define SIZE_OF_IA_CSS_CIRCBUF_ELEM_S_STRUCT				\
57 	(sizeof(uint32_t))
58 
59 #endif /*_IA_CSS_CIRCBUF_COMM_H*/
60