Definition of a MMAL port and its associated API
#define MMAL_PORT_CAPABILITY_ALLOCATION 0x02 |
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_PASSTHROUGH 0x01 |
The port is pass-through and doesn't need buffer headers allocated
#define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04 |
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).
Definition of the callback used by a port to send a MMAL_BUFFER_HEADER_T back to the user.
- Parameters
-
port | The port sending the buffer header. |
buffer | The buffer header being sent. |
Definition of a port. A port is the entity that is exposed by components to receive or transmit buffer headers (MMAL_BUFFER_HEADER_T). A port is defined by its MMAL_ES_FORMAT_T.
It may be possible to override the buffer requirements of a port by using the MMAL_PARAMETER_BUFFER_REQUIREMENTS parameter.
List of port types
Enumerator |
---|
MMAL_PORT_TYPE_UNKNOWN |
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 |
Dummy value to force 32bit enum
|
Connect an output port to an input port.
When connected and enabled, buffers will automatically progress from the output port to the input port when they become available, and released back to the output port when no longer required by the input port.
Ports can be given either way around, but one must be an output port and the other must be an input port. Neither can be connected or enabled already. The format of the output port will be applied to the input port on connection.
- Parameters
-
port | One of the ports to connect. |
other_port | The other port to connect. |
- Returns
- MMAL_SUCCESS on success.
Disable processing on a port
Disabling a port will stop all processing on this port and return all (non-processed) buffer headers to the client.
If this is a connected output port, the input port to which it is connected shall also be disabled. Any buffer pool shall be released.
- Parameters
-
- Returns
- MMAL_SUCCESS on success
Disconnect a connected port.
If the port is not connected, an error will be returned. Otherwise, if the ports are enabled, they will be disabled and any buffer pool created will be freed.
- Parameters
-
port | The ports to disconnect. |
- Returns
- MMAL_SUCCESS on success.
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:
-
The port shall be populated with a pool of buffers, allocated as required, according to the buffer_num and buffer_size values.
-
The input port to which it is connected shall be set to the same buffer configuration and then be enabled. Should that fail, the original port shall be disabled.
- Parameters
-
- Returns
- MMAL_SUCCESS on success
Get an empty event buffer header from a port
- Parameters
-
port | The port from which to get the event buffer header. |
buffer | The address of a buffer header pointer, which will be set on return. |
event | The specific event FourCC required. See the pre-defined events. |
- Returns
- MMAL_SUCCESS on success
Ask a port to release all the buffer headers it currently has.
Flushing a port will ask the port to send all the buffer headers it currently has to the client. Flushing is an asynchronous request and the flush call will return before all the buffer headers are returned to the client. It is up to the client to keep a count on the buffer headers to know when the flush operation has completed. It is also important to note that flushing will also reset the state of the port and any processing which was buffered by the port will be lost.
- Attention
- Flushing a connected port behaviour TBD.
- Parameters
-
- Returns
- MMAL_SUCCESS on success
Commit format changes on a port.
- Parameters
-
port | The port for which format changes are to be committed. |
- Returns
- MMAL_SUCCESS on success
Get a parameter from a port. The size field must be set on input to the maximum size of the parameter (including the header) and will be set on output to the actual size of the parameter retrieved.
- Note
- If MMAL_ENOSPC is returned, the parameter is larger than the size given. The given parameter will have been filled up to its size and then the size field set to the full parameter's size. This can be used to resize the parameter buffer so that a second call should succeed.
- Parameters
-
port | The port to which the request is sent. |
param | The pointer to the header of the parameter to get. |
- Returns
- MMAL_SUCCESS on success
Set a parameter on a port.
- Parameters
-
port | The port to which the request is sent. |
param | The pointer to the header of the parameter to set. |
- Returns
- MMAL_SUCCESS on success
uint8_t* mmal_port_payload_alloc |
( |
MMAL_PORT_T * |
port, |
|
|
uint32_t |
payload_size |
|
) |
| |
Allocate a payload buffer. This allows a client to allocate memory for a payload buffer based on the preferences of a port. This for instance will allow the port to allocate memory which can be shared between the host processor and videocore.
See mmal_pool_create_with_allocator().
- Parameters
-
port | Port responsible for allocating the memory. |
payload_size | Size of the payload buffer which will be allocated. |
- Returns
- Pointer to the allocated memory.
void mmal_port_payload_free |
( |
MMAL_PORT_T * |
port, |
|
|
uint8_t * |
payload |
|
) |
| |
Send a buffer header to a port.
- Parameters
-
port | The port to which the buffer header is to be sent. |
buffer | The buffer header to send. |
- Returns
- MMAL_SUCCESS on success