Merge git://git.kernel.org/pub/scm/linux/kernel/git/czankel/xtensa-2.6
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / epl / SharedBuff.h
1 /****************************************************************************
2
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
5
6 Project: Project independend shared buffer (linear + circular)
7
8 Description: Declaration of platform independend part for the
9 shared buffer
10
11 License:
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions
15 are met:
16
17 1. Redistributions of source code must retain the above copyright
18 notice, this list of conditions and the following disclaimer.
19
20 2. Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in the
22 documentation and/or other materials provided with the distribution.
23
24 3. Neither the name of SYSTEC electronic GmbH nor the names of its
25 contributors may be used to endorse or promote products derived
26 from this software without prior written permission. For written
27 permission, please contact info@systec-electronic.com.
28
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 POSSIBILITY OF SUCH DAMAGE.
41
42 Severability Clause:
43
44 If a provision of this License is or becomes illegal, invalid or
45 unenforceable in any jurisdiction, that shall not affect:
46 1. the validity or enforceability in that jurisdiction of any other
47 provision of this License; or
48 2. the validity or enforceability in other jurisdictions of that or
49 any other provision of this License.
50
51 -------------------------------------------------------------------------
52
53 2006/06/27 -rs: V 1.00 (initial version)
54
55 ****************************************************************************/
56
57 #ifndef _SHAREDBUFF_H_
58 #define _SHAREDBUFF_H_
59
60 //---------------------------------------------------------------------------
61 // Type definitions
62 //---------------------------------------------------------------------------
63
64 typedef enum {
65 kShbOk = 0,
66 kShbNoReadableData = 1,
67 kShbDataTruncated = 2,
68 kShbBufferFull = 3,
69 kShbDataOutsideBufferArea = 4,
70 kShbBufferAlreadyCompleted = 5,
71 kShbMemUsedByOtherProcs = 6,
72 kShbOpenMismatch = 7,
73 kShbInvalidBufferType = 8,
74 kShbInvalidArg = 9,
75 kShbBufferInvalid = 10,
76 kShbOutOfMem = 11,
77 kShbAlreadyReseting = 12,
78 kShbAlreadySignaling = 13,
79 kShbExceedDataSizeLimit = 14,
80
81 } tShbError;
82
83 // 2006/08/24 d.k.: Priority for threads (new data, job signaling)
84 typedef enum {
85 kShbPriorityLow = 0,
86 kShbPriorityNormal = 1,
87 kshbPriorityHigh = 2
88 } tShbPriority;
89
90 typedef struct {
91 unsigned int m_uiFullBlockSize; // real size of allocated block (incl. alignment fill bytes)
92 unsigned long m_ulAvailableSize; // still available size for data
93 unsigned long m_ulWrIndex; // current write index
94 unsigned int m_fBufferCompleted; // TRUE if allocated block is complete filled with data
95
96 } tShbCirChunk;
97
98 typedef void *tShbInstance;
99
100 typedef void (*tShbCirSigHndlrNewData) (tShbInstance pShbInstance_p,
101 unsigned long ulDataBlockSize_p);
102 typedef void (*tShbCirSigHndlrReset) (tShbInstance pShbInstance_p,
103 unsigned int fTimeOut_p);
104
105 //---------------------------------------------------------------------------
106 // Prototypes
107 //---------------------------------------------------------------------------
108
109 #ifdef __cplusplus
110 extern "C" {
111 #endif
112
113 /*#if defined(INLINE_FUNCTION_DEF)
114 #undef INLINE_FUNCTION
115 #define INLINE_FUNCTION INLINE_FUNCTION_DEF
116 #define INLINE_ENABLED TRUE
117 #define SHAREDBUFF_INLINED
118 #include "SharedBuff.c"
119 #endif
120 */
121
122 tShbError ShbInit(void);
123 tShbError ShbExit(void);
124
125 // Circular Shared Buffer
126 tShbError ShbCirAllocBuffer(unsigned long ulBufferSize_p,
127 const char *pszBufferID_p,
128 tShbInstance * ppShbInstance_p,
129 unsigned int *pfShbNewCreated_p);
130 tShbError ShbCirReleaseBuffer(tShbInstance pShbInstance_p);
131
132 #if !defined(INLINE_ENABLED)
133
134 tShbError ShbCirResetBuffer(tShbInstance pShbInstance_p,
135 unsigned long ulTimeOut_p,
136 tShbCirSigHndlrReset
137 pfnSignalHandlerReset_p);
138 tShbError ShbCirWriteDataBlock(tShbInstance pShbInstance_p,
139 const void *pSrcDataBlock_p,
140 unsigned long ulDataBlockSize_p);
141 tShbError ShbCirAllocDataBlock(tShbInstance pShbInstance_p,
142 tShbCirChunk * pShbCirChunk_p,
143 unsigned long ulDataBufferSize_p);
144 tShbError ShbCirWriteDataChunk(tShbInstance pShbInstance_p,
145 tShbCirChunk * pShbCirChunk_p,
146 const void *pSrcDataChunk_p,
147 unsigned long ulDataChunkSize_p,
148 unsigned int *pfBufferCompleted_p);
149 tShbError ShbCirReadDataBlock(tShbInstance pShbInstance_p,
150 void *pDstDataBlock_p,
151 unsigned long ulRdBuffSize_p,
152 unsigned long *pulDataBlockSize_p);
153 tShbError ShbCirGetReadDataSize(tShbInstance pShbInstance_p,
154 unsigned long *pulDataBlockSize_p);
155 tShbError ShbCirGetReadBlockCount(tShbInstance pShbInstance_p,
156 unsigned long *pulDataBlockCount_p);
157 tShbError ShbCirSetSignalHandlerNewData(tShbInstance pShbInstance_p,
158 tShbCirSigHndlrNewData
159 pfnShbSignalHandlerNewData_p,
160 tShbPriority ShbPriority_p);
161
162 #endif
163
164 // Linear Shared Buffer
165 tShbError ShbLinAllocBuffer(unsigned long ulBufferSize_p,
166 const char *pszBufferID_p,
167 tShbInstance * ppShbInstance_p,
168 unsigned int *pfShbNewCreated_p);
169 tShbError ShbLinReleaseBuffer(tShbInstance pShbInstance_p);
170
171 #if !defined(INLINE_ENABLED)
172
173 tShbError ShbLinWriteDataBlock(tShbInstance pShbInstance_p,
174 unsigned long ulDstBufferOffs_p,
175 const void *pSrcDataBlock_p,
176 unsigned long ulDataBlockSize_p);
177 tShbError ShbLinReadDataBlock(tShbInstance pShbInstance_p,
178 void *pDstDataBlock_p,
179 unsigned long ulSrcBufferOffs_p,
180 unsigned long ulDataBlockSize_p);
181
182 #endif
183
184 #ifndef NDEBUG
185 tShbError ShbCirTraceBuffer(tShbInstance pShbInstance_p);
186 tShbError ShbLinTraceBuffer(tShbInstance pShbInstance_p);
187 tShbError ShbTraceDump(const unsigned char *pabStartAddr_p,
188 unsigned long ulDataSize_p,
189 unsigned long ulAddrOffset_p,
190 const char *pszInfoText_p);
191 #else
192 #define ShbCirTraceBuffer(p0)
193 #define ShbLinTraceBuffer(p0)
194 #define ShbTraceDump(p0, p1, p2, p3)
195 #endif
196
197 #undef INLINE_ENABLED // disable actual inlining of functions
198 #undef INLINE_FUNCTION
199 #define INLINE_FUNCTION // define INLINE_FUNCTION to nothing
200
201 #ifdef __cplusplus
202 }
203 #endif
204 #endif // #ifndef _SHAREDBUFF_H_