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_PORT_PRIVATE_H |
29 | #define MMAL_PORT_PRIVATE_H |
30 | |
31 | #include "interface/mmal/mmal.h" |
32 | #include "interface/mmal/mmal_clock.h" |
33 | #include "interface/mmal/core/mmal_events_private.h" |
34 | |
35 | #ifdef __cplusplus |
36 | extern "C" { |
37 | #endif |
38 | |
39 | /** Definition of a port. */ |
40 | typedef struct MMAL_PORT_PRIVATE_T |
41 | { |
42 | /** Pointer to the private data of the core */ |
43 | struct MMAL_PORT_PRIVATE_CORE_T *core; |
44 | /** Pointer to the private data of the module in use */ |
45 | struct MMAL_PORT_MODULE_T *module; |
46 | /** Pointer to the private data used by clock ports */ |
47 | struct MMAL_PORT_CLOCK_T *clock; |
48 | |
49 | MMAL_STATUS_T (*pf_set_format)(MMAL_PORT_T *port); |
50 | MMAL_STATUS_T (*pf_enable)(MMAL_PORT_T *port, MMAL_PORT_BH_CB_T); |
51 | MMAL_STATUS_T (*pf_disable)(MMAL_PORT_T *port); |
52 | MMAL_STATUS_T (*pf_send)(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *); |
53 | MMAL_STATUS_T (*pf_flush)(MMAL_PORT_T *port); |
54 | MMAL_STATUS_T (*pf_parameter_set)(MMAL_PORT_T *port, const MMAL_PARAMETER_HEADER_T *param); |
55 | MMAL_STATUS_T (*pf_parameter_get)(MMAL_PORT_T *port, MMAL_PARAMETER_HEADER_T *param); |
56 | MMAL_STATUS_T (*pf_connect)(MMAL_PORT_T *port, MMAL_PORT_T *other_port); |
57 | |
58 | uint8_t *(*pf_payload_alloc)(MMAL_PORT_T *port, uint32_t payload_size); |
59 | void (*pf_payload_free)(MMAL_PORT_T *port, uint8_t *payload); |
60 | |
61 | } MMAL_PORT_PRIVATE_T; |
62 | |
63 | /** Callback called by components when a \ref MMAL_BUFFER_HEADER_T needs to be sent back to the |
64 | * user */ |
65 | void (MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer); |
66 | |
67 | /** Callback called by components when an event \ref MMAL_BUFFER_HEADER_T needs to be sent to the |
68 | * user. Events differ from ordinary buffer headers because they originate from the component |
69 | * and do not return data from the client to the component. */ |
70 | void mmal_port_event_send(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer); |
71 | |
72 | /** Allocate a port structure */ |
73 | MMAL_PORT_T *mmal_port_alloc(MMAL_COMPONENT_T *, MMAL_PORT_TYPE_T type, unsigned int ); |
74 | /** Free a port structure */ |
75 | void mmal_port_free(MMAL_PORT_T *port); |
76 | /** Allocate an array of ports */ |
77 | MMAL_PORT_T **mmal_ports_alloc(MMAL_COMPONENT_T *, unsigned int ports_num, MMAL_PORT_TYPE_T type, |
78 | unsigned int ); |
79 | /** Free an array of ports */ |
80 | void mmal_ports_free(MMAL_PORT_T **ports, unsigned int ports_num); |
81 | |
82 | /** Acquire a reference on a port */ |
83 | void mmal_port_acquire(MMAL_PORT_T *port); |
84 | |
85 | /** Release a reference on a port */ |
86 | MMAL_STATUS_T mmal_port_release(MMAL_PORT_T *port); |
87 | |
88 | /** Pause processing on a port */ |
89 | MMAL_STATUS_T mmal_port_pause(MMAL_PORT_T *port, MMAL_BOOL_T pause); |
90 | |
91 | /** Returns whether a port is connected or not */ |
92 | MMAL_BOOL_T mmal_port_is_connected(MMAL_PORT_T *port); |
93 | |
94 | /***************************************************************************** |
95 | * Clock Port API |
96 | *****************************************************************************/ |
97 | /** Definition of a clock port event callback. |
98 | * Used to inform the client of a clock event that has occurred. |
99 | * |
100 | * @param port The clock port where the event occurred |
101 | * @param event The event that has occurred |
102 | */ |
103 | typedef void (*MMAL_PORT_CLOCK_EVENT_CB)(MMAL_PORT_T *port, const MMAL_CLOCK_EVENT_T *event); |
104 | |
105 | /** Allocate a clock port. |
106 | * |
107 | * @param component The component requesting the alloc |
108 | * @param extra_size Size of the port module |
109 | * @param event_cb Clock event callback |
110 | * |
111 | * @return Pointer to new clock port or NULL on failure. |
112 | */ |
113 | MMAL_PORT_T* mmal_port_clock_alloc(MMAL_COMPONENT_T *component, unsigned int , |
114 | MMAL_PORT_CLOCK_EVENT_CB event_cb); |
115 | |
116 | /** Free a clock port. |
117 | * |
118 | * @param port The clock port to free |
119 | */ |
120 | void mmal_port_clock_free(MMAL_PORT_T *port); |
121 | |
122 | /** Allocate an array of clock ports. |
123 | * |
124 | * @param component The component requesting the alloc |
125 | * @param ports_num Number of ports to allocate |
126 | * @param extra_size Size of the port module |
127 | * @param event_cb Clock event callback |
128 | * |
129 | * @return Pointer to a new array of clock ports or NULL on failure. |
130 | */ |
131 | MMAL_PORT_T **mmal_ports_clock_alloc(MMAL_COMPONENT_T *component, unsigned int ports_num, |
132 | unsigned int , MMAL_PORT_CLOCK_EVENT_CB event_cb); |
133 | |
134 | /** Free an array of clock ports. |
135 | * |
136 | * @param ports The clock ports to free |
137 | * @param ports_num Number of ports to free |
138 | */ |
139 | void mmal_ports_clock_free(MMAL_PORT_T **ports, unsigned int ports_num); |
140 | |
141 | /** Definition of a clock port request callback. |
142 | * This is invoked when the media-time requested by the client is reached. |
143 | * |
144 | * @param port The clock port which serviced the request |
145 | * @param media_time The current media-time |
146 | * @param cb_data Client-supplied data |
147 | */ |
148 | typedef void (*MMAL_PORT_CLOCK_REQUEST_CB)(MMAL_PORT_T *port, int64_t media_time, void *cb_data); |
149 | |
150 | /** Register a request with the clock port. |
151 | * When the specified media-time is reached, the clock port will invoke the supplied callback. |
152 | * |
153 | * @param port The clock port |
154 | * @param media_time The media-time at which the callback should be invoked (microseconds) |
155 | * @param cb Callback to invoke |
156 | * @param cb_data Client-supplied callback data |
157 | * |
158 | * @return MMAL_SUCCESS on success |
159 | */ |
160 | MMAL_STATUS_T mmal_port_clock_request_add(MMAL_PORT_T *port, int64_t media_time, |
161 | MMAL_PORT_CLOCK_REQUEST_CB cb, void *cb_data); |
162 | |
163 | /** Remove all previously registered clock port requests. |
164 | * |
165 | * @param port The clock port |
166 | * |
167 | * @return MMAL_SUCCESS on success |
168 | */ |
169 | MMAL_STATUS_T mmal_port_clock_request_flush(MMAL_PORT_T *port); |
170 | |
171 | /** Get/set the clock port's reference state */ |
172 | MMAL_STATUS_T mmal_port_clock_reference_set(MMAL_PORT_T *port, MMAL_BOOL_T reference); |
173 | MMAL_BOOL_T mmal_port_clock_reference_get(MMAL_PORT_T *port); |
174 | |
175 | /** Get/set the clock port's active state */ |
176 | MMAL_STATUS_T mmal_port_clock_active_set(MMAL_PORT_T *port, MMAL_BOOL_T active); |
177 | MMAL_BOOL_T mmal_port_clock_active_get(MMAL_PORT_T *port); |
178 | |
179 | /** Get/set the clock port's scale */ |
180 | MMAL_STATUS_T mmal_port_clock_scale_set(MMAL_PORT_T *port, MMAL_RATIONAL_T scale); |
181 | MMAL_RATIONAL_T mmal_port_clock_scale_get(MMAL_PORT_T *port); |
182 | |
183 | /** Get/set the clock port's media-time */ |
184 | MMAL_STATUS_T mmal_port_clock_media_time_set(MMAL_PORT_T *port, int64_t media_time); |
185 | int64_t mmal_port_clock_media_time_get(MMAL_PORT_T *port); |
186 | |
187 | /** Get/set the clock port's update threshold */ |
188 | MMAL_STATUS_T mmal_port_clock_update_threshold_set(MMAL_PORT_T *port, |
189 | const MMAL_CLOCK_UPDATE_THRESHOLD_T *threshold); |
190 | MMAL_STATUS_T mmal_port_clock_update_threshold_get(MMAL_PORT_T *port, |
191 | MMAL_CLOCK_UPDATE_THRESHOLD_T *threshold); |
192 | |
193 | /** Get/set the clock port's discontinuity threshold */ |
194 | MMAL_STATUS_T mmal_port_clock_discont_threshold_set(MMAL_PORT_T *port, |
195 | const MMAL_CLOCK_DISCONT_THRESHOLD_T *threshold); |
196 | MMAL_STATUS_T mmal_port_clock_discont_threshold_get(MMAL_PORT_T *port, |
197 | MMAL_CLOCK_DISCONT_THRESHOLD_T *threshold); |
198 | |
199 | /** Get/set the clock port's request threshold */ |
200 | MMAL_STATUS_T mmal_port_clock_request_threshold_set(MMAL_PORT_T *port, |
201 | const MMAL_CLOCK_REQUEST_THRESHOLD_T *threshold); |
202 | MMAL_STATUS_T mmal_port_clock_request_threshold_get(MMAL_PORT_T *port, |
203 | MMAL_CLOCK_REQUEST_THRESHOLD_T *threshold); |
204 | |
205 | /** Provide information regarding a buffer received on the component's input/output port */ |
206 | void mmal_port_clock_input_buffer_info(MMAL_PORT_T *port, const MMAL_CLOCK_BUFFER_INFO_T *info); |
207 | void mmal_port_clock_output_buffer_info(MMAL_PORT_T *port, const MMAL_CLOCK_BUFFER_INFO_T *info); |
208 | |
209 | #ifdef __cplusplus |
210 | } |
211 | #endif |
212 | |
213 | #endif /* MMAL_PORT_PRIVATE_H */ |
214 | |