diff --git a/src/amd/vpelib/inc/vpe_types.h b/src/amd/vpelib/inc/vpe_types.h index a9b0acf93be..9d3f72f3509 100644 --- a/src/amd/vpelib/inc/vpe_types.h +++ b/src/amd/vpelib/inc/vpe_types.h @@ -95,6 +95,27 @@ enum vpe_status { given case. */ }; +/***************************************************** + * Enum for emitting VPE System Events + *****************************************************/ + +/** @enum vpe_event_id + * @brief Event IDs are VPE events that can be emitted through + * the EventLog callback. For each event ID, the number of params + * emitted must by synchronized with handler + */ +enum vpe_event_id { + VPE_EVENT_CHECK_SUPPORT, /**< Event emitted by vpe_check_support. + Params: + UInt32 num_streams, + UInt32 target_rect.width, + UInt32 target_rect.height, + UInt32 target_rect.height + */ + + VPE_EVENT_MAX_ID /**< Max ID represents the number of event IDs supported */ +}; + /** @enum vpe_ip_level * @brief HW IP level */ @@ -312,6 +333,11 @@ struct vpe_cap_funcs { */ typedef void (*vpe_log_func_t)(void *log_ctx, const char *fmt, ...); +/** @brief Sys Event function + * @param[in] event_id event to emit to system log + */ +typedef void (*vpe_sys_event_func_t)(enum vpe_event_id event_id, ...); + /** @brief system memory zalloc, allocated memory initailized with 0 * * @param[in] mem_ctx given in the struct @ref vpe_init_data @@ -333,6 +359,8 @@ struct vpe_callback_funcs { void *log_ctx; /**< optional. provided by the caller and pass back to callback */ vpe_log_func_t log; /**< Logging function */ + vpe_sys_event_func_t sys_event; /**< System event function */ + void *mem_ctx; /**< optional. provided by the caller and pass back to callback */ vpe_zalloc_func_t zalloc; /**< Memory allocation */ vpe_free_func_t free; /**< Free memory. In sync with @ref zalloc */ diff --git a/src/amd/vpelib/src/core/inc/vpe_priv.h b/src/amd/vpelib/src/core/inc/vpe_priv.h index 613ebfef356..6eccc73e26f 100644 --- a/src/amd/vpelib/src/core/inc/vpe_priv.h +++ b/src/amd/vpelib/src/core/inc/vpe_priv.h @@ -46,6 +46,11 @@ extern "C" { vpe_priv->init.funcs.log(vpe_priv->init.funcs.log_ctx, __VA_ARGS__); \ } while (0) +#define vpe_event(event_id, ...) \ + do { \ + vpe_priv->init.funcs.sys_event(event_id, __VA_ARGS__); \ + } while (0) + #define container_of(ptr, type, member) (type *)(void *)((char *)ptr - offsetof(type, member)) #define VPE_MIN_VIEWPORT_SIZE \ diff --git a/src/amd/vpelib/src/core/vpelib.c b/src/amd/vpelib/src/core/vpelib.c index 0c370929c3a..d121f01933a 100644 --- a/src/amd/vpelib/src/core/vpelib.c +++ b/src/amd/vpelib/src/core/vpelib.c @@ -40,6 +40,11 @@ #include #include +static void dummy_sys_event(enum vpe_event_id eventId, ...) +{ + // Do nothing, if no callback is provided for sys event +} + static void override_debug_option( struct vpe_debug_options *debug, const struct vpe_debug_options *user_debug) { @@ -196,6 +201,11 @@ struct vpe *vpe_create(const struct vpe_init_data *params) vpe_priv->init = *params; + // Make sys event an optional feature but hooking up to dummy function if no callback is + // provided + if (vpe_priv->init.funcs.sys_event == NULL) + vpe_priv->init.funcs.sys_event = dummy_sys_event; + vpe_priv->pub.level = vpe_resource_parse_ip_version(params->ver_major, params->ver_minor, params->ver_rev); @@ -600,6 +610,9 @@ enum vpe_status vpe_check_support( if (vpe_priv->init.debug.assert_when_not_support) VPE_ASSERT(status == VPE_STATUS_OK); + vpe_event(VPE_EVENT_CHECK_SUPPORT, vpe_priv->num_streams, param->target_rect.width, + param->target_rect.height, status); + return status; }