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