From a261642bf9cf15a132983afba5ef28bd13022469 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Wed, 29 Nov 2017 11:46:22 +0200 Subject: [PATCH 1/1] hwc: add the API function tdm_output_hwc_create_video_window instead of TDM_COMPOSITION_VIDEO. Change-Id: If82b18a3d133abbcedb5d9125e18f5d6682e72f0 Signed-off-by: Roman Marchenko --- include/tdm.h | 10 +++++++++ include/tdm_backend.h | 11 +++++++++- include/tdm_types.h | 15 ++++---------- src/tdm_hwc_window.c | 44 ++++++++++++++++++++++++++++------------ src/tdm_output.c | 26 +++++++++++++++++++++++- src/tdm_private.h | 2 +- utests/src/ut_tdm_hwc_window.cpp | 2 -- 7 files changed, 81 insertions(+), 29 deletions(-) diff --git a/include/tdm.h b/include/tdm.h index a0edef6..77866d5 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -579,6 +579,16 @@ tdm_hwc_window * tdm_output_hwc_create_window(tdm_output *output, tdm_error *error); /** + * @brief Creates a new video window on the given output. + * @param[in] output A output object + * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value. + * @return A created window object + * @since 2.0.0 + */ +tdm_hwc_window * +tdm_output_hwc_create_video_window(tdm_output *output, tdm_error *error); + +/** * @brief Destroys the given window. * @param[in] output A output object * @param[in] window the pointer of the window to destroy diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 51f3d63..b1a3657 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -669,7 +669,16 @@ typedef struct _tdm_func_output { */ tdm_error (*output_hwc_get_video_supported_formats)(tdm_layer *layer, const tbm_format **formats, int *count); - void (*reserved4)(void); + + /** + * @brief Creates a new video window on the given output. + * @param[in] output A output object + * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value. + * @return A created window object. If the video abilities isn't accessed return NULL + * @since 2.0.0 + */ + tdm_hwc_window *(*output_hwc_create_video_window)(tdm_output *output, tdm_error *error); + void (*reserved5)(void); void (*reserved6)(void); void (*reserved7)(void); diff --git a/include/tdm_types.h b/include/tdm_types.h index 626c1c3..c64a351 100644 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -170,10 +170,10 @@ typedef enum { * a type to the TDM_COMPOSITION_CLIENT_CANDIDATE type. * * This transition can happen only if the window has the TDM_COMPOSITION_DEVICE - * or the TDM_COMPOSITION_VIDEO type already. + * type already. * - * If an user changed type of a window from the TDM_COMPOSITION_DEVICE or the - * TDM_COMPOSITION_VIDEO type to the the TDM_COMPOSITION_CLIENT type, the type + * If an user changed type of a window from the TDM_COMPOSITION_DEVICE + * type to the the TDM_COMPOSITION_CLIENT type, the type * will be rejected to the TDM_COMPOSITION_CLIENT_CANDIDATE type. * * The user has to composite this window itself. @@ -184,7 +184,7 @@ typedef enum { * TDM_COMPOSITION_CLIENT_CANDIDATE type. * * This transitional state is used to get rid of blinking at a transition from - * the TDM_COMPOSITION_DEVICE/TDM_COMPOSITION_VIDEO type to the + * the TDM_COMPOSITION_DEVICE type to the * TDM_COMPOSITION_CLIENT type where the hw has to wait till a buffer, which was * on a hw overlay, get composited to the fb_target and only after this happens * unset(or set another window on) this hw overlay. @@ -224,13 +224,6 @@ typedef enum { * still permit the device to composite the layer. */ TDM_COMPOSITION_CURSOR = 5, - /** The device will handle the composition of this layer through a hardware - * overlay or other similar means. - * - * Upon tdm_output_hwc_validate(), the device may request a change from this type to - * either TDM_COMPOSITION_DEVICE or TDM_COMPOSITION_CLIENT, but it is - * unlikely that content will display correctly in these cases. */ - TDM_COMPOSITION_VIDEO = 6, } tdm_hwc_window_composition; /** diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index 91191b8..24b6207 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -293,7 +293,7 @@ tdm_hwc_window_set_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer) } INTERN tdm_hwc_window * -tdm_hwc_window_create_internal(tdm_private_output *private_output, +tdm_hwc_window_create_internal(tdm_private_output *private_output, int is_video, tdm_error *error) { tdm_private_display *private_display = private_output->private_display; @@ -304,20 +304,38 @@ tdm_hwc_window_create_internal(tdm_private_output *private_output, TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), NULL); - if (!func_output->output_hwc_create_window) { - /* LCOV_EXCL_START */ - if (error) - *error = TDM_ERROR_BAD_MODULE; - return NULL; - /* LCOV_EXCL_STOP */ - } + if (!is_video) { + if (!func_output->output_hwc_create_window) { + /* LCOV_EXCL_START */ + if (error) + *error = TDM_ERROR_BAD_MODULE; + return NULL; + /* LCOV_EXCL_STOP */ + } - hwc_window_backend = func_output->output_hwc_create_window( + hwc_window_backend = func_output->output_hwc_create_window( private_output->output_backend, &ret); - if (ret != TDM_ERROR_NONE) { - if (error) - *error = ret; - return NULL; + if (ret != TDM_ERROR_NONE) { + if (error) + *error = ret; + return NULL; + } + } else { + if (!func_output->output_hwc_create_video_window) { + /* LCOV_EXCL_START */ + if (error) + *error = TDM_ERROR_BAD_MODULE; + return NULL; + /* LCOV_EXCL_STOP */ + } + + hwc_window_backend = func_output->output_hwc_create_video_window( + private_output->output_backend, &ret); + if (ret != TDM_ERROR_NONE) { + if (error) + *error = ret; + return NULL; + } } private_hwc_window = calloc(1, sizeof(tdm_private_capture)); diff --git a/src/tdm_output.c b/src/tdm_output.c index 4c1015c..6e08225 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -1434,7 +1434,31 @@ tdm_output_hwc_create_window(tdm_output *output, tdm_error *error) _pthread_mutex_lock(&private_display->lock); if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC) - hwc_window = (tdm_hwc_window *)tdm_hwc_window_create_internal(private_output, error); + hwc_window = (tdm_hwc_window *)tdm_hwc_window_create_internal(private_output, 0, error); + else { + /* LCOV_EXCL_START */ + TDM_ERR("output(%p) not support HWC", private_output); + if (error) + *error = TDM_ERROR_BAD_REQUEST; + /* LCOV_EXCL_STOP */ + } + + _pthread_mutex_unlock(&private_display->lock); + + return hwc_window; +} + +EXTERN tdm_hwc_window * +tdm_output_hwc_create_video_window(tdm_output *output, tdm_error *error) +{ + tdm_hwc_window *hwc_window = NULL; + + OUTPUT_FUNC_ENTRY_ERROR(); + + _pthread_mutex_lock(&private_display->lock); + + if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC) + hwc_window = (tdm_hwc_window *)tdm_hwc_window_create_internal(private_output, 1, error); else { /* LCOV_EXCL_START */ TDM_ERR("output(%p) not support HWC", private_output); diff --git a/src/tdm_private.h b/src/tdm_private.h index 5e63e5c..37cceb0 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -519,7 +519,7 @@ void tdm_pp_destroy_internal(tdm_private_pp *private_pp); tdm_hwc_window * -tdm_hwc_window_create_internal(tdm_private_output *private_output, tdm_error *error); +tdm_hwc_window_create_internal(tdm_private_output *private_output, int is_video, tdm_error *error); tdm_error tdm_hwc_window_destroy_internal(tdm_private_hwc_window * private_hwc_window); diff --git a/utests/src/ut_tdm_hwc_window.cpp b/utests/src/ut_tdm_hwc_window.cpp index d712740..ed12a59 100644 --- a/utests/src/ut_tdm_hwc_window.cpp +++ b/utests/src/ut_tdm_hwc_window.cpp @@ -461,8 +461,6 @@ TEST_F(TDMHwcWindow, SetCompositionTypeSuccessful) ASSERT_EQ(TDM_ERROR_NONE, error); error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_CURSOR); ASSERT_EQ(TDM_ERROR_NONE, error); - error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_VIDEO); - ASSERT_EQ(TDM_ERROR_NONE, error); } } -- 2.7.4