Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tvservice: Enhance callback mechanism #162

Merged
merged 2 commits into from
Apr 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions interface/vmcs_host/vc_tvservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ VCHPRE_ void vc_tv_register_callback(TVSERVICE_CALLBACK_T callback, void *callba
*/
VCHPRE_ void vc_tv_unregister_callback(TVSERVICE_CALLBACK_T callback);

/**
* <DFN>vc_tv_unregister_callback</DNF> removes a function registered with
* <DFN>vc_tv_register_callback</DNF> from the list of callbacks.
* In contrast to vc_tv_unregister_callback this one matches not only the
* function pointer but also the data pointer before removal.
*
* @param callback function
*
* @return void
*/
VCHPRE_ void vc_tv_unregister_callback_full(TVSERVICE_CALLBACK_T callback, void *callback_data);

/**
* In the following API any functions applying to HDMI only will have hdmi_
* in the name, ditto for SDTV only will have sdtv_ in the name,
Expand Down
2 changes: 1 addition & 1 deletion interface/vmcs_host/vc_tvservice_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define TVSERVICE_CLIENT_NAME MAKE_FOURCC("TVSV")
#define TVSERVICE_NOTIFY_NAME MAKE_FOURCC("TVNT")

#define TVSERVICE_MAX_CALLBACKS 2
#define TVSERVICE_MAX_CALLBACKS 5

//TV service commands
typedef enum {
Expand Down
36 changes: 36 additions & 0 deletions interface/vmcs_host/vc_vchi_tvservice.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,42 @@ VCHPRE_ void VCHPOST_ vc_tv_unregister_callback(TVSERVICE_CALLBACK_T callback)
}
}

/***********************************************************
* Name: vc_tv_unregister_callback_full
*
* Arguments:
* callback function
* callback function context
*
* Description: Unregister a previously-registered callback function for TV notifications
*
* Returns: -
*
***********************************************************/
VCHPRE_ void VCHPOST_ vc_tv_unregister_callback_full(TVSERVICE_CALLBACK_T callback, void *callback_data)
{
vcos_assert(callback != NULL);

vcos_log_trace("[%s]", VCOS_FUNCTION);
if(tvservice_lock_obtain() == 0)
{
uint32_t done = 0;
uint32_t i;
for(i = 0; (i < TVSERVICE_MAX_CALLBACKS) && !done; i++)
{
if(tvservice_client.callbacks[i].notify_fn == callback &&
tvservice_client.callbacks[i].notify_data == callback_data)
{
tvservice_client.callbacks[i].notify_fn = NULL;
tvservice_client.callbacks[i].notify_data = NULL;
done = 1;
} // if
} // for
vcos_assert(done);
tvservice_lock_release();
}
}

/*********************************************************************************
*
* Static functions definitions
Expand Down