| 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_COMPONENT_PRIVATE_H |
| 29 | #define MMAL_COMPONENT_PRIVATE_H |
| 30 | |
| 31 | #ifdef __cplusplus |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | |
| 35 | #define MMAL_VIDEO_DECODE "video_decode" |
| 36 | #define MMAL_VIDEO_ENCODE "video_encode" |
| 37 | #define MMAL_VIDEO_RENDER "video_render" |
| 38 | #define MMAL_AUDIO_DECODE "audio_decode" |
| 39 | #define MMAL_AUDIO_ENCODE "audio_encode" |
| 40 | #define MMAL_AUDIO_RENDER "audio_render" |
| 41 | #define MMAL_CAMERA "camera" |
| 42 | |
| 43 | #if defined(__GNUC__) && (__GNUC__ > 2) |
| 44 | # define MMAL_CONSTRUCTOR(func) void __attribute__((constructor,used)) func(void) |
| 45 | # define MMAL_DESTRUCTOR(func) void __attribute__((destructor,used)) func(void) |
| 46 | #else |
| 47 | # define MMAL_CONSTRUCTOR(func) void func(void) |
| 48 | # define MMAL_DESTRUCTOR(func) void func(void) |
| 49 | #endif |
| 50 | |
| 51 | #include "mmal.h" |
| 52 | #include "mmal_component.h" |
| 53 | |
| 54 | /** Definition of a component. */ |
| 55 | struct MMAL_COMPONENT_PRIVATE_T |
| 56 | { |
| 57 | /** Pointer to the private data of the component module in use */ |
| 58 | struct MMAL_COMPONENT_MODULE_T *module; |
| 59 | |
| 60 | MMAL_STATUS_T (*pf_enable)(MMAL_COMPONENT_T *component); |
| 61 | MMAL_STATUS_T (*pf_disable)(MMAL_COMPONENT_T *component); |
| 62 | MMAL_STATUS_T (*pf_destroy)(MMAL_COMPONENT_T *component); |
| 63 | |
| 64 | /** Pool of event buffer headers, for sending events from component to client. */ |
| 65 | MMAL_POOL_T *event_pool; |
| 66 | |
| 67 | /** Reference counting of the component */ |
| 68 | int refcount; |
| 69 | /** Reference counting of the ports. Component won't be destroyed until this |
| 70 | * goes to 0 */ |
| 71 | int refcount_ports; |
| 72 | |
| 73 | /** Priority associated with the 'action thread' for this component, when |
| 74 | * such action thread is applicable. */ |
| 75 | int priority; |
| 76 | }; |
| 77 | |
| 78 | /** Set a generic component control parameter. |
| 79 | * |
| 80 | * @param control_port control port of component on which to set the parameter. |
| 81 | * @param param parameter to be set. |
| 82 | * @return MMAL_SUCCESS or another status on error. |
| 83 | */ |
| 84 | MMAL_STATUS_T mmal_component_parameter_set(MMAL_PORT_T *control_port, |
| 85 | const MMAL_PARAMETER_HEADER_T *param); |
| 86 | |
| 87 | /** Get a generic component control parameter. |
| 88 | * |
| 89 | * @param contorl_port control port of component from which to get the parameter. |
| 90 | * @param param parameter to be retrieved. |
| 91 | * @return MMAL_SUCCESS or another status on error. |
| 92 | */ |
| 93 | MMAL_STATUS_T mmal_component_parameter_get(MMAL_PORT_T *control_port, |
| 94 | MMAL_PARAMETER_HEADER_T *param); |
| 95 | |
| 96 | /** Registers an action with the core. |
| 97 | * The MMAL core allows components to register an action which will be run |
| 98 | * from a separate thread context when the action is explicitly triggered by |
| 99 | * the component. |
| 100 | * |
| 101 | * @param component component registering the action. |
| 102 | * @param action action to register. |
| 103 | * @return MMAL_SUCCESS or another status on error. |
| 104 | */ |
| 105 | MMAL_STATUS_T mmal_component_action_register(MMAL_COMPONENT_T *component, |
| 106 | void (*pf_action)(MMAL_COMPONENT_T *)); |
| 107 | |
| 108 | /** De-registers the current action registered with the core. |
| 109 | * |
| 110 | * @param component component de-registering the action. |
| 111 | * @return MMAL_SUCCESS or another status on error. |
| 112 | */ |
| 113 | MMAL_STATUS_T mmal_component_action_deregister(MMAL_COMPONENT_T *component); |
| 114 | |
| 115 | /** Triggers a registered action. |
| 116 | * Explicitly triggers an action registered by a component. |
| 117 | * |
| 118 | * @param component component on which to trigger the action. |
| 119 | * @return MMAL_SUCCESS or another status on error. |
| 120 | */ |
| 121 | MMAL_STATUS_T mmal_component_action_trigger(MMAL_COMPONENT_T *component); |
| 122 | |
| 123 | /** Lock an action to prevent it from running. |
| 124 | * Allows a component to make sure no action is running while the lock is taken. |
| 125 | * |
| 126 | * @param component component. |
| 127 | * @return MMAL_SUCCESS or another status on error. |
| 128 | */ |
| 129 | MMAL_STATUS_T mmal_component_action_lock(MMAL_COMPONENT_T *component); |
| 130 | |
| 131 | /** Unlock an action to allow it to run again. |
| 132 | * |
| 133 | * @param component component. |
| 134 | * @return MMAL_SUCCESS or another status on error. |
| 135 | */ |
| 136 | MMAL_STATUS_T mmal_component_action_unlock(MMAL_COMPONENT_T *component); |
| 137 | |
| 138 | /** Prototype used by components to register themselves to the supplier. */ |
| 139 | typedef MMAL_STATUS_T (*MMAL_COMPONENT_SUPPLIER_FUNCTION_T)(const char *name, |
| 140 | MMAL_COMPONENT_T *component); |
| 141 | |
| 142 | /** Create an instance of a component given a constructor for the component. |
| 143 | * This allows the creation of client-side components which haven't been registered with the core. |
| 144 | * See \ref mmal_component_create for the public interface used to create components. |
| 145 | * |
| 146 | * @param name name assigned to the component by the client |
| 147 | * @param constructor constructor function for the component |
| 148 | * @param constructor_private private data for the constructor |
| 149 | * @param component returned component |
| 150 | * @return MMAL_SUCCESS on success |
| 151 | */ |
| 152 | MMAL_STATUS_T mmal_component_create_with_constructor(const char *name, |
| 153 | MMAL_STATUS_T (*constructor)(const char *name, MMAL_COMPONENT_T *), |
| 154 | struct MMAL_COMPONENT_MODULE_T *constructor_private, |
| 155 | MMAL_COMPONENT_T **component); |
| 156 | |
| 157 | /** Register a component with the mmal component supplier. |
| 158 | * |
| 159 | * @param prefix prefix for this supplier, e.g. "VC" |
| 160 | * @param create_fn function which will instantiate a component given a name. |
| 161 | */ |
| 162 | void mmal_component_supplier_register(const char *prefix, |
| 163 | MMAL_COMPONENT_SUPPLIER_FUNCTION_T create_fn); |
| 164 | |
| 165 | #ifdef __cplusplus |
| 166 | } |
| 167 | #endif |
| 168 | |
| 169 | #endif /* MMAL_COMPONENT_PRIVATE_H */ |
| 170 | |