Skip to content

Commit

Permalink
mmal: Hack to make mmal core register VideoCore components
Browse files Browse the repository at this point in the history
The default linker option with Bullseye appears to now set
as-needed, so as the core doesn't call into mmal_vc_client
it is viewed as unnecesary, missing that mmal_vc_client has
a constructor that registers functions with the core.

Move the registration of the component supplier to the core_init.
The linker is therefore satisfied that mmal_vc_client is used,
and actually links to it.

This allows Picamera to work again.

waveform80/picamera#697

Signed-off-by: Dave Stevenson <[email protected]>
  • Loading branch information
6by9 authored and pelwell committed Nov 25, 2021
1 parent f5404b2 commit 14b90ff
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion interface/mmal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ add_library (mmal_core ${LIBRARY_TYPE}
mmal_clock.c
)

target_link_libraries (mmal_core vcos)
target_link_libraries (mmal_core vcos mmal_vc_client)

install(TARGETS mmal_core DESTINATION lib)
install(FILES
Expand Down
8 changes: 8 additions & 0 deletions interface/mmal/core/mmal_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/mmal_core_private.h"
#include "mmal_logging.h"

#include "vc/mmal_vc_api.h"

/* Minimum number of buffers that will be available on the control port */
#define MMAL_CONTROL_PORT_BUFFERS_MIN 4

Expand Down Expand Up @@ -665,6 +667,12 @@ MMAL_STATUS_T mmal_component_action_unlock(MMAL_COMPONENT_T *component)
static void mmal_core_init_once(void)
{
vcos_mutex_create(&mmal_core_lock, VCOS_FUNCTION);

/* Horrid hack as linkers are now setting --as-needed by default, so fail
* to see the requirement for mmal_vc_client as a library because the core
* never calls it.
*/
mmal_register_component_videocore();
}

static void mmal_core_init(void)
Expand Down
4 changes: 4 additions & 0 deletions interface/mmal/vc/mmal_vc_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,11 @@ static MMAL_STATUS_T mmal_vc_component_create(const char *name, MMAL_COMPONENT_T
return status;
}

/*
* Do NOT register as a constructor due to horrid hack where the core will register
* these components in case the linker has determined that they weren't needed.
MMAL_CONSTRUCTOR(mmal_register_component_videocore);
*/
void mmal_register_component_videocore(void)
{
mmal_component_supplier_register(VIDEOCORE_PREFIX, mmal_vc_component_create);
Expand Down
1 change: 1 addition & 0 deletions interface/mmal/vc/mmal_vc_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ MMAL_STATUS_T mmal_vc_compact(MMAL_VC_COMPACT_MODE_T mode, uint32_t *duration);
*/
MMAL_STATUS_T mmal_vc_lmk(uint32_t alloc_size);

void mmal_register_component_videocore(void);
#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 14b90ff

Please sign in to comment.