1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #ifndef MMAL_BUFFER_PRIVATE_H |
29 | #define MMAL_BUFFER_PRIVATE_H |
30 | |
31 | /** Typedef for the private area the framework reserves for the driver / communication layer */ |
32 | typedef struct MMAL_DRIVER_BUFFER_T MMAL_DRIVER_BUFFER_T; |
33 | |
34 | /** Size of the private area the framework reserves for the driver / communication layer */ |
35 | #define MMAL_DRIVER_BUFFER_SIZE 32 |
36 | |
37 | /** Typedef for the framework's private area in the buffer header */ |
38 | typedef struct |
39 | { |
40 | /** Callback invoked just prior to actually releasing the buffer header. Returns TRUE if |
41 | * release should be delayed. */ |
42 | MMAL_BH_PRE_RELEASE_CB_T ; |
43 | void *; |
44 | |
45 | /** Callback used to release / recycle the buffer header. This needs to be set by |
46 | * whoever allocates the buffer header. */ |
47 | void (*)(struct MMAL_BUFFER_HEADER_T *); |
48 | void *; /**< Context set by the allocator of the buffer header and passed |
49 | during the release callback */ |
50 | |
51 | int32_t ; /**< Reference count of the buffer header. When it reaches 0, |
52 | the release callback will be called. */ |
53 | |
54 | MMAL_BUFFER_HEADER_T *; /**< Reference to another acquired buffer header. */ |
55 | |
56 | /** Callback used to free the payload associated with this buffer header. This is only |
57 | * used if the buffer header was created by MMAL with a payload associated with it. */ |
58 | void (*)(void *payload_context, void *payload); |
59 | void *; /**< Pointer / handle to the allocated payload buffer */ |
60 | void *; /**< Pointer to the context of the payload allocator */ |
61 | uint32_t ; /**< Allocated size in bytes of payload buffer */ |
62 | |
63 | void *; /**< Field reserved for use by the component */ |
64 | void *payload_handle; /**< Field reserved for mmal_buffer_header_mem_lock */ |
65 | |
66 | uint8_t [MMAL_DRIVER_BUFFER_SIZE]; |
67 | |
68 | } ; |
69 | |
70 | /** Get the size in bytes of a fully initialised MMAL_BUFFER_HEADER_T */ |
71 | unsigned int (MMAL_BUFFER_HEADER_T *); |
72 | |
73 | /** Initialise a MMAL_BUFFER_HEADER_T */ |
74 | MMAL_BUFFER_HEADER_T *(void *mem, unsigned int length); |
75 | |
76 | /** Return a pointer to the area reserved for the driver. |
77 | */ |
78 | MMAL_DRIVER_BUFFER_T *(MMAL_BUFFER_HEADER_T *); |
79 | |
80 | /** Return a pointer to a referenced buffer header. |
81 | * It is the caller's responsibility to ensure that the reference is still |
82 | * valid when using it. |
83 | */ |
84 | MMAL_BUFFER_HEADER_T *(MMAL_BUFFER_HEADER_T *); |
85 | |
86 | #endif /* MMAL_BUFFER_PRIVATE_H */ |
87 | |