|
| 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_CLOCK_PRIVATE_H |
| 29 | +#define MMAL_CLOCK_PRIVATE_H |
| 30 | + |
| 31 | +#include "interface/mmal/mmal.h" |
| 32 | +#include "interface/mmal/mmal_clock.h" |
| 33 | + |
| 34 | +#ifdef __cplusplus |
| 35 | +extern "C" { |
| 36 | +#endif |
| 37 | + |
| 38 | + |
| 39 | +/** Handle to a clock. */ |
| 40 | +typedef struct MMAL_CLOCK_T |
| 41 | +{ |
| 42 | + void *user_data; /**< Client-supplied data (not used by the clock). */ |
| 43 | +} MMAL_CLOCK_T; |
| 44 | + |
| 45 | +/** Create a new instance of a clock. |
| 46 | + * |
| 47 | + * @param clock Returned clock |
| 48 | + * |
| 49 | + * @return MMAL_SUCCESS on success |
| 50 | + */ |
| 51 | +MMAL_STATUS_T mmal_clock_create(MMAL_CLOCK_T **clock); |
| 52 | + |
| 53 | +/** Destroy a previously created clock. |
| 54 | + * |
| 55 | + * @param clock The clock to destroy |
| 56 | + * |
| 57 | + * @return MMAL_SUCCESS on success |
| 58 | + */ |
| 59 | +MMAL_STATUS_T mmal_clock_destroy(MMAL_CLOCK_T *clock); |
| 60 | + |
| 61 | +/** Definition of a clock request callback. |
| 62 | + * This is invoked when the media-time requested by the client is reached. |
| 63 | + * |
| 64 | + * @param clock The clock which serviced the request |
| 65 | + * @param media_time The current media-time |
| 66 | + * @param cb_data Client-supplied data |
| 67 | + * @param priv Function pointer used by the framework |
| 68 | + */ |
| 69 | +typedef void (*MMAL_CLOCK_VOID_FP)(void); |
| 70 | +typedef void (*MMAL_CLOCK_REQUEST_CB)(MMAL_CLOCK_T *clock, int64_t media_time, void *cb_data, MMAL_CLOCK_VOID_FP priv); |
| 71 | + |
| 72 | +/** Register a request with the clock. |
| 73 | + * When the specified media-time is reached, the clock will invoke the supplied callback. |
| 74 | + * |
| 75 | + * @param clock The clock |
| 76 | + * @param media_time The media-time at which the callback should be invoked (microseconds) |
| 77 | + * @param offset Time offset (in microseconds) applied to the media-time. This can be used |
| 78 | + * to schedule the request slightly in advance of the media-time. |
| 79 | + * @param cb Callback to invoke |
| 80 | + * @param cb_data Client-supplied callback data |
| 81 | + * @param priv Function pointer used by the framework |
| 82 | + * |
| 83 | + * @return MMAL_SUCCESS on success |
| 84 | + */ |
| 85 | +MMAL_STATUS_T mmal_clock_request_add(MMAL_CLOCK_T *clock, int64_t media_time, int64_t offset, |
| 86 | + MMAL_CLOCK_REQUEST_CB cb, void *cb_data, MMAL_CLOCK_VOID_FP priv); |
| 87 | + |
| 88 | +/** Remove all previously registered clock requests. |
| 89 | + * |
| 90 | + * @param clock The clock |
| 91 | + * |
| 92 | + * @return MMAL_SUCCESS on success |
| 93 | + */ |
| 94 | +MMAL_STATUS_T mmal_clock_request_flush(MMAL_CLOCK_T *clock); |
| 95 | + |
| 96 | +/** Update the clock's media-time. |
| 97 | + * |
| 98 | + * @param clock The clock to update |
| 99 | + * @param media_time New media-time to be applied (microseconds) |
| 100 | + * |
| 101 | + * @return MMAL_SUCCESS on success |
| 102 | + */ |
| 103 | +MMAL_STATUS_T mmal_clock_media_time_set(MMAL_CLOCK_T *clock, int64_t media_time); |
| 104 | + |
| 105 | +/** Update the clock's media-time offset. |
| 106 | + * |
| 107 | + * @param clock The clock to update |
| 108 | + * @param media_time New media-time offset to be applied (microseconds) |
| 109 | + * |
| 110 | + * @return MMAL_SUCCESS on success |
| 111 | + */ |
| 112 | +MMAL_STATUS_T mmal_clock_media_time_offset_set(MMAL_CLOCK_T *clock, int64_t offset); |
| 113 | + |
| 114 | +/** Set the clock's scale. |
| 115 | + * |
| 116 | + * @param clock The clock |
| 117 | + * @param scale Scale factor |
| 118 | + * |
| 119 | + * @return MMAL_SUCCESS on success |
| 120 | + */ |
| 121 | +MMAL_STATUS_T mmal_clock_scale_set(MMAL_CLOCK_T *clock, MMAL_RATIONAL_T scale); |
| 122 | + |
| 123 | +/** Set the clock state. |
| 124 | + * |
| 125 | + * @param clock The clock |
| 126 | + * @param active TRUE -> clock is active and media-time is advancing |
| 127 | + * |
| 128 | + * @return MMAL_SUCCESS on success |
| 129 | + */ |
| 130 | +MMAL_STATUS_T mmal_clock_active_set(MMAL_CLOCK_T *clock, MMAL_BOOL_T active); |
| 131 | + |
| 132 | +/** Get the clock's scale. |
| 133 | + * |
| 134 | + * @param clock The clock |
| 135 | + * |
| 136 | + * @return Current clock scale |
| 137 | + */ |
| 138 | +MMAL_RATIONAL_T mmal_clock_scale_get(MMAL_CLOCK_T *clock); |
| 139 | + |
| 140 | +/** Get the clock's current media-time. |
| 141 | + * This takes the clock scale and media-time offset into account. |
| 142 | + * |
| 143 | + * @param clock The clock to query |
| 144 | + * |
| 145 | + * @return Current media-time in microseconds |
| 146 | + */ |
| 147 | +int64_t mmal_clock_media_time_get(MMAL_CLOCK_T *clock); |
| 148 | + |
| 149 | +/** Get the clock's media-time offset. |
| 150 | + * |
| 151 | + * @param clock The clock to query |
| 152 | + * |
| 153 | + * @return Current media-time offset in microseconds |
| 154 | + */ |
| 155 | +int64_t mmal_clock_media_time_offset_get(MMAL_CLOCK_T *clock); |
| 156 | + |
| 157 | +/** Get the clock's state. |
| 158 | + * |
| 159 | + * @param clock The clock to query |
| 160 | + * |
| 161 | + * @return TRUE if clock is running (i.e. local media-time is advancing) |
| 162 | + */ |
| 163 | +MMAL_BOOL_T mmal_clock_is_active(MMAL_CLOCK_T *clock); |
| 164 | + |
| 165 | +/** Get the clock's media-time update threshold values. |
| 166 | + * |
| 167 | + * @param clock The clock |
| 168 | + * @param update_threshold Pointer to clock update threshold values to fill |
| 169 | + * |
| 170 | + * @return MMAL_SUCCESS on success |
| 171 | + */ |
| 172 | +MMAL_STATUS_T mmal_clock_update_threshold_get(MMAL_CLOCK_T *clock, MMAL_PARAMETER_CLOCK_UPDATE_THRESHOLD_T *update_threshold); |
| 173 | + |
| 174 | +/** Set the clock's media-time update threshold values. |
| 175 | + * |
| 176 | + * @param clock The clock |
| 177 | + * @param update_threshold Pointer to new clock update threshold values |
| 178 | + * |
| 179 | + * @return MMAL_SUCCESS on success |
| 180 | + */ |
| 181 | +MMAL_STATUS_T mmal_clock_update_threshold_set(MMAL_CLOCK_T *clock, const MMAL_PARAMETER_CLOCK_UPDATE_THRESHOLD_T *update_threshold); |
| 182 | + |
| 183 | +/** Get the clock's discontinuity threshold values. |
| 184 | + * |
| 185 | + * @param clock The clock |
| 186 | + * @param discont Pointer to clock discontinuity threshold values to fill |
| 187 | + * |
| 188 | + * @return MMAL_SUCCESS on success |
| 189 | + */ |
| 190 | +MMAL_STATUS_T mmal_clock_discont_threshold_get(MMAL_CLOCK_T *clock, MMAL_PARAMETER_CLOCK_DISCONT_THRESHOLD_T *discont); |
| 191 | + |
| 192 | +/** Set the clock's discontinuity threshold values. |
| 193 | + * |
| 194 | + * @param clock The clock |
| 195 | + * @param discont Pointer to new clock discontinuity threshold values |
| 196 | + * |
| 197 | + * @return MMAL_SUCCESS on success |
| 198 | + */ |
| 199 | +MMAL_STATUS_T mmal_clock_discont_threshold_set(MMAL_CLOCK_T *clock, const MMAL_PARAMETER_CLOCK_DISCONT_THRESHOLD_T *discont); |
| 200 | + |
| 201 | +/** Get the clock's request threshold values. |
| 202 | + * |
| 203 | + * @param clock The clock |
| 204 | + * @param future Pointer to clock request threshold values to fill |
| 205 | + * |
| 206 | + * @return MMAL_SUCCESS on success |
| 207 | + */ |
| 208 | +MMAL_STATUS_T mmal_clock_request_threshold_get(MMAL_CLOCK_T *clock, MMAL_PARAMETER_CLOCK_REQUEST_THRESHOLD_T *req); |
| 209 | + |
| 210 | +/** Set the clock's request threshold values. |
| 211 | + * |
| 212 | + * @param clock The clock |
| 213 | + * @param discont Pointer to new clock request threshold values |
| 214 | + * |
| 215 | + * @return MMAL_SUCCESS on success |
| 216 | + */ |
| 217 | +MMAL_STATUS_T mmal_clock_request_threshold_set(MMAL_CLOCK_T *clock, const MMAL_PARAMETER_CLOCK_REQUEST_THRESHOLD_T *req); |
| 218 | + |
| 219 | +#ifdef __cplusplus |
| 220 | +} |
| 221 | +#endif |
| 222 | + |
| 223 | +#endif /* MMAL_CLOCK_PRIVATE_H */ |
0 commit comments