hc
2024-03-26 e0728245c89800c2038c23308f2d88969d5b41c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Support for Intel Camera Imaging ISP subsystem.
 * Copyright (c) 2015, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 */
 
#ifndef _IA_CSS_CIRCBUF_COMM_H
#define _IA_CSS_CIRCBUF_COMM_H
 
#include <type_support.h>  /* uint8_t, uint32_t */
 
#define IA_CSS_CIRCBUF_PADDING 1 /* The circular buffer is implemented in lock-less manner, wherein
                  * the head and tail can advance independently without any locks.
                  * But to achieve this, an extra buffer element is required to detect
                  * queue full & empty conditions, wherein the tail trails the head for
                  * full and is equal to head for empty condition. This causes 1 buffer
                  * not being available for use.
                  */
 
/****************************************************************
 *
 * Portable Data structures
 *
 ****************************************************************/
/**
 * @brief Data structure for the circular descriptor.
 */
typedef struct ia_css_circbuf_desc_s ia_css_circbuf_desc_t;
struct ia_css_circbuf_desc_s {
   u8 size;    /* the maximum number of elements*/
   u8 step;   /* number of bytes per element */
   u8 start;    /* index of the oldest element */
   u8 end;    /* index at which to write the new element */
};
 
#define SIZE_OF_IA_CSS_CIRCBUF_DESC_S_STRUCT                \
   (4 * sizeof(uint8_t))
 
/**
 * @brief Data structure for the circular buffer element.
 */
typedef struct ia_css_circbuf_elem_s ia_css_circbuf_elem_t;
struct ia_css_circbuf_elem_s {
   u32 val;    /* the value stored in the element */
};
 
#define SIZE_OF_IA_CSS_CIRCBUF_ELEM_S_STRUCT                \
   (sizeof(uint32_t))
 
#endif /*_IA_CSS_CIRCBUF_COMM_H*/