My Project
Utility functions

Modules

 utility
 
 Port connection utility
 
 Graph Utility
 
 MMAL to OMX IL conversion utilities
 
 Rational Utility Functions
 

Macros

#define MMAL_OFFSET(TYPE, FIELD)   ((size_t)((uint8_t *)&((TYPE*)0)->FIELD - (uint8_t *)0))
 

Functions

const char * mmal_status_to_string (MMAL_STATUS_T status)
 
uint32_t mmal_encoding_stride_to_width (uint32_t encoding, uint32_t stride)
 
uint32_t mmal_encoding_width_to_stride (uint32_t encoding, uint32_t width)
 
uint32_t mmal_encoding_get_slice_variant (uint32_t encoding)
 
const char * mmal_port_type_to_string (MMAL_PORT_TYPE_T type)
 
MMAL_PARAMETER_HEADER_Tmmal_port_parameter_alloc_get (MMAL_PORT_T *port, uint32_t id, uint32_t size, MMAL_STATUS_T *status)
 
void mmal_port_parameter_free (MMAL_PARAMETER_HEADER_T *param)
 
void mmal_buffer_header_copy_header (MMAL_BUFFER_HEADER_T *dest, const MMAL_BUFFER_HEADER_T *src)
 
MMAL_POOL_Tmmal_port_pool_create (MMAL_PORT_T *port, unsigned int headers, uint32_t payload_size)
 
void mmal_port_pool_destroy (MMAL_PORT_T *port, MMAL_POOL_T *pool)
 
void mmal_log_dump_port (MMAL_PORT_T *port)
 
void mmal_log_dump_format (MMAL_ES_FORMAT_T *format)
 
MMAL_PORT_Tmmal_util_get_port (MMAL_COMPONENT_T *comp, MMAL_PORT_TYPE_T type, unsigned index)
 
char * mmal_4cc_to_string (char *buf, size_t len, uint32_t fourcc)
 
int mmal_util_rgb_order_fixed (MMAL_PORT_T *port)
 

Detailed Description

The utility functions provide helpers for common functionality that is not part of the core MMAL API.

Macro Definition Documentation

◆ MMAL_OFFSET

#define MMAL_OFFSET (   TYPE,
  FIELD 
)    ((size_t)((uint8_t *)&((TYPE*)0)->FIELD - (uint8_t *)0))

Offset in bytes of FIELD in TYPE.

Definition at line 40 of file mmal_util.h.

Function Documentation

◆ mmal_4cc_to_string()

char* mmal_4cc_to_string ( char *  buf,
size_t  len,
uint32_t  fourcc 
)

Convert a 4cc into a string.

Parameters
bufDestination for result
lenSize of result buffer
fourcc4cc to be converted
Returns
converted string (buf)

◆ mmal_buffer_header_copy_header()

void mmal_buffer_header_copy_header ( MMAL_BUFFER_HEADER_T dest,
const MMAL_BUFFER_HEADER_T src 
)

Copy buffer header metadata from source to destination.

Parameters
destThe destination buffer header.
srcThe source buffer header.

◆ mmal_encoding_get_slice_variant()

uint32_t mmal_encoding_get_slice_variant ( uint32_t  encoding)

Return the 16 line high sliced version of a given pixel encoding

Parameters
encodingThe pixel encoding (such as one of the pre-defined encodings)
Returns
The sliced equivalent, or MMAL_ENCODING_UNKNOWN if not supported.

◆ mmal_encoding_stride_to_width()

uint32_t mmal_encoding_stride_to_width ( uint32_t  encoding,
uint32_t  stride 
)

Convert stride to pixel width for a given pixel encoding.

Parameters
encodingThe pixel encoding (such as one of the pre-defined encodings)
strideThe stride in bytes.
Returns
The width in pixels.

◆ mmal_encoding_width_to_stride()

uint32_t mmal_encoding_width_to_stride ( uint32_t  encoding,
uint32_t  width 
)

Convert pixel width to stride for a given pixel encoding

Parameters
encodingThe pixel encoding (such as one of the pre-defined encodings)
widthThe width in pixels.
Returns
The stride in bytes.

◆ mmal_log_dump_format()

void mmal_log_dump_format ( MMAL_ES_FORMAT_T format)

Log the content of a MMAL_ES_FORMAT_T structure.

Parameters
formatPointer to the format to dump.

◆ mmal_log_dump_port()

void mmal_log_dump_port ( MMAL_PORT_T port)

Log the content of a MMAL_PORT_T structure.

Parameters
portPointer to the port to dump.

◆ mmal_port_parameter_alloc_get()

MMAL_PARAMETER_HEADER_T* mmal_port_parameter_alloc_get ( MMAL_PORT_T port,
uint32_t  id,
uint32_t  size,
MMAL_STATUS_T status 
)

Get a parameter from a port allocating the required amount of memory for the parameter (i.e. for variable length parameters like URI or arrays). The size field will be set on output to the actual size of the parameter allocated and retrieved.

The pointer returned must be released by a call to mmal_port_parameter_free().

Parameters
portport to send request to
idparameter id
sizeinitial size hint for allocation (can be 0)
statusstatus of the parameter get operation (can be 0)
Returns
pointer to the header of the parameter or NULL on failure.

◆ mmal_port_parameter_free()

void mmal_port_parameter_free ( MMAL_PARAMETER_HEADER_T param)

Free a parameter structure previously allocated via mmal_port_parameter_alloc_get().

Parameters
parampointer to header of the parameter

◆ mmal_port_pool_create()

MMAL_POOL_T* mmal_port_pool_create ( MMAL_PORT_T port,
unsigned int  headers,
uint32_t  payload_size 
)

Create a pool of MMAL_BUFFER_HEADER_T associated with a specific port. This allows a client to allocate memory for the payload buffers 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. After allocation, all allocated buffer headers will have been added to the queue.

It is valid to create a pool with no buffer headers, or with zero size payload buffers. The mmal_pool_resize() function can be used to increase or decrease the number of buffer headers, or the size of the payload buffers, after creation of the pool.

Parameters
portPort responsible for creating the pool.
headersNumber of buffers which will be allocated with the pool.
payload_sizeSize of the payload buffer which will be allocated in each of the buffer headers.
Returns
Pointer to the newly created pool or NULL on failure.

◆ mmal_port_pool_destroy()

void mmal_port_pool_destroy ( MMAL_PORT_T port,
MMAL_POOL_T pool 
)

Destroy a pool of MMAL_BUFFER_HEADER_T associated with a specific port. This will also deallocate all of the memory which was allocated when creating or resizing the pool.

Parameters
portPointer to the port responsible for creating the pool.
poolPointer to the pool to be destroyed.

◆ mmal_port_type_to_string()

const char* mmal_port_type_to_string ( MMAL_PORT_TYPE_T  type)

Convert a port type to a string.

Parameters
typeThe MMAL port type.
Returns
A NULL-terminated string describing the port type.

◆ mmal_status_to_string()

const char* mmal_status_to_string ( MMAL_STATUS_T  status)

Convert a status to a statically-allocated string.

Parameters
statusThe MMAL status code.
Returns
A C string describing the status code.

◆ mmal_util_get_port()

MMAL_PORT_T* mmal_util_get_port ( MMAL_COMPONENT_T comp,
MMAL_PORT_TYPE_T  type,
unsigned  index 
)

Return the nth port.

Parameters
compcomponent to query
indexport index
typeport type
Returns
port or NULL if not found

◆ mmal_util_rgb_order_fixed()

int mmal_util_rgb_order_fixed ( MMAL_PORT_T port)

On FW prior to June 2016, camera and video_splitter had BGR24 and RGB24 support reversed. This is now fixed, and this function will return whether the FW has the fix or not.

Parameters
portMMAL port to check (on camera or video_splitter)
Returns
0 if old firmware, 1 if new.