/* Copyright (c) 2012, Broadcom Europe Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef MMAL_PORT_H #define MMAL_PORT_H #ifdef __cplusplus extern "C" { #endif /** \defgroup MmalPort Ports * Definition of a MMAL port and its associated API */ /* @{ */ #include "mmal_types.h" #include "mmal_format.h" #include "mmal_buffer.h" #include "mmal_parameters.h" /** List of port types */ typedef enum { MMAL_PORT_TYPE_UNKNOWN = 0, /**< Unknown port type */ MMAL_PORT_TYPE_CONTROL, /**< Control port */ MMAL_PORT_TYPE_INPUT, /**< Input port */ MMAL_PORT_TYPE_OUTPUT, /**< Output port */ MMAL_PORT_TYPE_CLOCK, /**< Clock port */ MMAL_PORT_TYPE_INVALID = 0xffffffff /**< Dummy value to force 32bit enum */ } MMAL_PORT_TYPE_T; /** \name Port capabilities * \anchor portcapabilities * The following flags describe the capabilities advertised by a port */ /* @{ */ /** The port is pass-through and doesn't need buffer headers allocated */ #define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01 /** The port wants to allocate the buffer payloads. This signals a preference that * payload allocation should be done on this port for efficiency reasons. */ #define MMAL_PORT_CAPABILITY_ALLOCATION 0x02 /** The port supports format change events. This applies to input ports and is used * to let the client know whether the port supports being reconfigured via a format * change event (i.e. without having to disable the port). */ #define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04 /* @} */ /** Definition of a port. * A port is the entity that is exposed by components to receive or transmit * buffer headers (\ref MMAL_BUFFER_HEADER_T). A port is defined by its * \ref MMAL_ES_FORMAT_T. * * It may be possible to override the buffer requirements of a port by using * the MMAL_PARAMETER_BUFFER_REQUIREMENTS parameter. */ typedef struct MMAL_PORT_T { struct MMAL_PORT_PRIVATE_T *priv; /**< Private member used by the framework */ const char *name; /**< Port name. Used for debugging purposes (Read Only) */ MMAL_PORT_TYPE_T type; /**< Type of the port (Read Only) */ uint16_t index; /**< Index of the port in its type list (Read Only) */ uint16_t index_all; /**< Index of the port in the list of all ports (Read Only) */ uint32_t is_enabled; /**< Indicates whether the port is enabled or not (Read Only) */ MMAL_ES_FORMAT_T *format; /**< Format of the elementary stream */ uint32_t buffer_num_min; /**< Minimum number of buffers the port requires (Read Only). This is set by the component. */ uint32_t buffer_size_min; /**< Minimum size of buffers the port requires (Read Only). This is set by the component. */ uint32_t buffer_alignment_min; /**< Minimum alignment requirement for the buffers (Read Only). A value of zero means no special alignment requirements. This is set by the component. */ uint32_t buffer_num_recommended; /**< Number of buffers the port recommends for optimal performance (Read Only). A value of zero means no special recommendation. This is set by the component. */ uint32_t buffer_size_recommended; /**< Size of buffers the port recommends for optimal performance (Read Only). A value of zero means no special recommendation. This is set by the component. */ uint32_t buffer_num; /**< Actual number of buffers the port will use. This is set by the client. */ uint32_t buffer_size; /**< Actual maximum size of the buffers that will be sent to the port. This is set by the client. */ struct MMAL_COMPONENT_T *component; /**< Component this port belongs to (Read Only) */ struct MMAL_PORT_USERDATA_T *userdata; /**< Field reserved for use by the client */ uint32_t capabilities; /**< Flags describing the capabilities of a port (Read Only). * Bitwise combination of \ref portcapabilities "Port capabilities" * values. */ } MMAL_PORT_T; /** Commit format changes on a port. * * @param port The port for which format changes are to be committed. * @return MMAL_SUCCESS on success */ MMAL_STATUS_T mmal_port_format_commit(MMAL_PORT_T *port); /** Definition of the callback used by a port to send a \ref MMAL_BUFFER_HEADER_T * back to the user. * * @param port The port sending the buffer header. * @param buffer The buffer header being sent. */ typedef void (*MMAL_PORT_BH_CB_T)(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer); /** Enable processing on a port * * If this port is connected to another, the given callback must be NULL, while for a * disconnected port, the callback must be non-NULL. * * If this is a connected output port and is successfully enabled: *