| 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 cb Callback to invoke |
| 78 | * @param cb_data Client-supplied callback data |
| 79 | * @param priv Function pointer used by the framework |
| 80 | * |
| 81 | * @return MMAL_SUCCESS on success |
| 82 | */ |
| 83 | MMAL_STATUS_T mmal_clock_request_add(MMAL_CLOCK_T *clock, int64_t media_time, |
| 84 | MMAL_CLOCK_REQUEST_CB cb, void *cb_data, MMAL_CLOCK_VOID_FP priv); |
| 85 | |
| 86 | /** Remove all previously registered clock requests. |
| 87 | * |
| 88 | * @param clock The clock |
| 89 | * |
| 90 | * @return MMAL_SUCCESS on success |
| 91 | */ |
| 92 | MMAL_STATUS_T mmal_clock_request_flush(MMAL_CLOCK_T *clock); |
| 93 | |
| 94 | /** Update the clock's media-time. |
| 95 | * |
| 96 | * @param clock The clock to update |
| 97 | * @param media_time New media-time to be applied (microseconds) |
| 98 | * |
| 99 | * @return MMAL_SUCCESS on success |
| 100 | */ |
| 101 | MMAL_STATUS_T mmal_clock_media_time_set(MMAL_CLOCK_T *clock, int64_t media_time); |
| 102 | |
| 103 | /** Set the clock's scale. |
| 104 | * |
| 105 | * @param clock The clock |
| 106 | * @param scale Scale factor |
| 107 | * |
| 108 | * @return MMAL_SUCCESS on success |
| 109 | */ |
| 110 | MMAL_STATUS_T mmal_clock_scale_set(MMAL_CLOCK_T *clock, MMAL_RATIONAL_T scale); |
| 111 | |
| 112 | /** Set the clock state. |
| 113 | * |
| 114 | * @param clock The clock |
| 115 | * @param active TRUE -> clock is active and media-time is advancing |
| 116 | * |
| 117 | * @return MMAL_SUCCESS on success |
| 118 | */ |
| 119 | MMAL_STATUS_T mmal_clock_active_set(MMAL_CLOCK_T *clock, MMAL_BOOL_T active); |
| 120 | |
| 121 | /** Get the clock's scale. |
| 122 | * |
| 123 | * @param clock The clock |
| 124 | * |
| 125 | * @return Current clock scale |
| 126 | */ |
| 127 | MMAL_RATIONAL_T mmal_clock_scale_get(MMAL_CLOCK_T *clock); |
| 128 | |
| 129 | /** Get the clock's current media-time. |
| 130 | * This takes the clock scale and media-time offset into account. |
| 131 | * |
| 132 | * @param clock The clock to query |
| 133 | * |
| 134 | * @return Current media-time in microseconds |
| 135 | */ |
| 136 | int64_t mmal_clock_media_time_get(MMAL_CLOCK_T *clock); |
| 137 | |
| 138 | /** Get the clock's state. |
| 139 | * |
| 140 | * @param clock The clock to query |
| 141 | * |
| 142 | * @return TRUE if clock is running (i.e. local media-time is advancing) |
| 143 | */ |
| 144 | MMAL_BOOL_T mmal_clock_is_active(MMAL_CLOCK_T *clock); |
| 145 | |
| 146 | /** Get the clock's media-time update threshold values. |
| 147 | * |
| 148 | * @param clock The clock |
| 149 | * @param update_threshold Pointer to clock update threshold values to fill |
| 150 | * |
| 151 | * @return MMAL_SUCCESS on success |
| 152 | */ |
| 153 | MMAL_STATUS_T mmal_clock_update_threshold_get(MMAL_CLOCK_T *clock, MMAL_CLOCK_UPDATE_THRESHOLD_T *update_threshold); |
| 154 | |
| 155 | /** Set the clock's media-time update threshold values. |
| 156 | * |
| 157 | * @param clock The clock |
| 158 | * @param update_threshold Pointer to new clock update threshold values |
| 159 | * |
| 160 | * @return MMAL_SUCCESS on success |
| 161 | */ |
| 162 | MMAL_STATUS_T mmal_clock_update_threshold_set(MMAL_CLOCK_T *clock, const MMAL_CLOCK_UPDATE_THRESHOLD_T *update_threshold); |
| 163 | |
| 164 | /** Get the clock's discontinuity threshold values. |
| 165 | * |
| 166 | * @param clock The clock |
| 167 | * @param discont Pointer to clock discontinuity threshold values to fill |
| 168 | * |
| 169 | * @return MMAL_SUCCESS on success |
| 170 | */ |
| 171 | MMAL_STATUS_T mmal_clock_discont_threshold_get(MMAL_CLOCK_T *clock, MMAL_CLOCK_DISCONT_THRESHOLD_T *discont); |
| 172 | |
| 173 | /** Set the clock's discontinuity threshold values. |
| 174 | * |
| 175 | * @param clock The clock |
| 176 | * @param discont Pointer to new clock discontinuity threshold values |
| 177 | * |
| 178 | * @return MMAL_SUCCESS on success |
| 179 | */ |
| 180 | MMAL_STATUS_T mmal_clock_discont_threshold_set(MMAL_CLOCK_T *clock, const MMAL_CLOCK_DISCONT_THRESHOLD_T *discont); |
| 181 | |
| 182 | /** Get the clock's request threshold values. |
| 183 | * |
| 184 | * @param clock The clock |
| 185 | * @param future Pointer to clock request threshold values to fill |
| 186 | * |
| 187 | * @return MMAL_SUCCESS on success |
| 188 | */ |
| 189 | MMAL_STATUS_T mmal_clock_request_threshold_get(MMAL_CLOCK_T *clock, MMAL_CLOCK_REQUEST_THRESHOLD_T *req); |
| 190 | |
| 191 | /** Set the clock's request threshold values. |
| 192 | * |
| 193 | * @param clock The clock |
| 194 | * @param discont Pointer to new clock request threshold values |
| 195 | * |
| 196 | * @return MMAL_SUCCESS on success |
| 197 | */ |
| 198 | MMAL_STATUS_T mmal_clock_request_threshold_set(MMAL_CLOCK_T *clock, const MMAL_CLOCK_REQUEST_THRESHOLD_T *req); |
| 199 | |
| 200 | #ifdef __cplusplus |
| 201 | } |
| 202 | #endif |
| 203 | |
| 204 | #endif /* MMAL_CLOCK_PRIVATE_H */ |
| 205 | |